@stacksjs/stx 0.2.670 → 0.2.672
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-cxmdbhwb.js → chunk-06b8btkv.js} +1 -1
- package/dist/chunk-0dcrd58z.js +2 -0
- package/dist/{chunk-xsbacs9w.js → chunk-0f33ssaq.js} +1 -1
- package/dist/chunk-17yfcd5s.js +2 -0
- package/dist/{chunk-tnfbx8he.js → chunk-1mj9crcg.js} +4 -4
- package/dist/{chunk-0gxxknfy.js → chunk-23b0khvh.js} +1 -1
- package/dist/{chunk-54gq98a2.js → chunk-3349573p.js} +1 -1
- package/dist/chunk-4ve8vsw5.js +2 -0
- package/dist/{chunk-3cr5yths.js → chunk-5pgk3w2c.js} +1 -1
- package/dist/{chunk-skwjbhfh.js → chunk-5w1c7x22.js} +1 -1
- package/dist/{chunk-7hzjnzex.js → chunk-6xe8rnfv.js} +1 -1
- package/dist/chunk-7a3g26kk.js +2 -0
- package/dist/{chunk-zrged04y.js → chunk-7d2fab0z.js} +1 -1
- package/dist/chunk-7dtpszqq.js +2 -0
- package/dist/{chunk-tm6z49c5.js → chunk-7kk2m44a.js} +2 -2
- package/dist/{chunk-3m0cebvd.js → chunk-7spxdz5k.js} +1 -1
- package/dist/{chunk-sbvmcwqg.js → chunk-8k3rwv8r.js} +2 -2
- package/dist/{chunk-8p14rew3.js → chunk-96mm4q2g.js} +1 -1
- package/dist/{chunk-hvsv59f5.js → chunk-9gfffs28.js} +2 -2
- package/dist/{chunk-57vwx6nv.js → chunk-9yxgdy4z.js} +1 -1
- package/dist/{chunk-jy89bcma.js → chunk-a3yte051.js} +1 -1
- package/dist/{chunk-0dxkj53f.js → chunk-a5zqqgx2.js} +1 -1
- package/dist/{chunk-2f2q31yc.js → chunk-a91atghh.js} +1 -1
- package/dist/{chunk-2q8maj3k.js → chunk-a95r5nmq.js} +1 -1
- package/dist/{chunk-hjccqjt4.js → chunk-am246nf3.js} +1 -1
- package/dist/{chunk-pjdsvqzc.js → chunk-avnhsjq0.js} +1 -1
- package/dist/{chunk-dxc782vg.js → chunk-aw3meb8t.js} +1 -1
- package/dist/{chunk-qqzmmnga.js → chunk-d6en3vz7.js} +1 -1
- package/dist/{chunk-e7avmdqn.js → chunk-dnw3knxq.js} +1 -1
- package/dist/{chunk-v2yjapag.js → chunk-dw81nc5v.js} +1 -1
- package/dist/{chunk-77dewvn4.js → chunk-e44z03s5.js} +1 -1
- package/dist/chunk-f8dkq3ta.js +2 -0
- package/dist/{chunk-m2znv53p.js → chunk-f9hrpwsw.js} +1 -1
- package/dist/{chunk-0zqzn3hr.js → chunk-kenbxxbn.js} +1 -1
- package/dist/{chunk-rwyexk13.js → chunk-kwek8xdt.js} +6 -6
- package/dist/{chunk-38th7z7d.js → chunk-mjm3tyfj.js} +5 -5
- package/dist/{chunk-6vk1jvx5.js → chunk-n3m7fkv1.js} +20 -20
- package/dist/{chunk-3ttr743b.js → chunk-p3x21vp7.js} +5 -5
- package/dist/{chunk-p450pdx3.js → chunk-pvb48ehs.js} +1 -1
- package/dist/{chunk-h1qz5xd6.js → chunk-qffbkvfn.js} +1 -1
- package/dist/{chunk-8yry75vs.js → chunk-qq1k3364.js} +1 -1
- package/dist/{chunk-kjhbchxn.js → chunk-s20h5gmr.js} +2 -2
- package/dist/chunk-sc7hszsx.js +2 -0
- package/dist/{chunk-1a7k07b8.js → chunk-sj6mhjdq.js} +1 -1
- package/dist/{chunk-cxc3zdhn.js → chunk-sjcqxfq1.js} +2 -2
- package/dist/{chunk-4v1582qk.js → chunk-sqayfat9.js} +1 -1
- package/dist/{chunk-h1gjww3q.js → chunk-sqhmkvwd.js} +1 -1
- package/dist/{chunk-pgs6p767.js → chunk-sw6p5176.js} +1 -1
- package/dist/{chunk-beccrqdy.js → chunk-t961jbzc.js} +1 -1
- package/dist/chunk-t9yqq483.js +18 -0
- package/dist/{chunk-82w7h48a.js → chunk-tb6vacgp.js} +1 -1
- package/dist/{chunk-mrs4sw7d.js → chunk-ttbn287w.js} +1 -1
- package/dist/{chunk-28qn219e.js → chunk-wankp78x.js} +4 -4
- package/dist/chunk-we8ptx6w.js +2 -0
- package/dist/{chunk-wf7wxa9h.js → chunk-wyq0c4wy.js} +1 -1
- package/dist/{chunk-rmdc1bqn.js → chunk-wz2zb53w.js} +1 -1
- package/dist/{chunk-rt2v4sy2.js → chunk-wz6368p4.js} +1 -1
- package/dist/{chunk-7hm5asnb.js → chunk-x68etmdg.js} +1 -1
- package/dist/{chunk-egt49kgq.js → chunk-yqz01qvy.js} +1 -1
- package/dist/chunk-z8j2sbnb.js +2 -0
- package/dist/chunk-zp9k5pha.js +2 -0
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/menubar-build.d.ts +10 -0
- package/dist/menubar-build.js +38 -0
- package/dist/native/compiler/headwind-to-style.d.ts +3 -1
- package/dist/native/compiler/headwind-to-style.js +11 -8
- package/dist/native/runtime/native-host.js +8 -4
- package/dist/pwa.js +1 -1
- package/dist/render.js +3 -0
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-4ef70h09.js +0 -2
- package/dist/chunk-5r6jbxyk.js +0 -2
- package/dist/chunk-ccwattyw.js +0 -2
- package/dist/chunk-f87ycgnc.js +0 -2
- package/dist/chunk-ffd48ere.js +0 -2
- package/dist/chunk-ng1mgtph.js +0 -2
- package/dist/chunk-q19vdv8m.js +0 -2
- package/dist/chunk-qmtpvrz4.js +0 -2
- package/dist/chunk-x4t3mjg0.js +0 -2
- package/dist/chunk-y4n984em.js +0 -2
- package/dist/chunk-zgg6w9pt.js +0 -18
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ae,Ma,ds,ln,g,Oe,Ne}from"./chunk-kwek8xdt.js";import{Yn,Xe,N}from"./chunk-9gfffs28.js";import{Hn,s}from"./chunk-mjm3tyfj.js";import{me}from"./chunk-wankp78x.js";function b(o){return o.endsWith(".md")||o.endsWith(".markdown")}function k(o){let e=[];m(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let r=[...e];m(/<code\b[^>]*>[\s\S]*?<\/code>/gi,r);function m(n,p){let u;while((u=n.exec(o))!==null){let t=u.index,i=t+u[0].length;if(p?.some((l)=>t>=l.start&&i<=l.end))continue;e.push({start:t,end:i})}}if(e.length===0)return o;e.sort((n,p)=>n.start-p.start);let c="",a=0;for(let n of e){if(n.start<a)continue;c+=o.slice(a,n.start),c+=`@raw${o.slice(n.start,n.end)}@endraw`,a=n.end}return c+=o.slice(a),c}async function R(o,e={}){let{data:r,content:m}=Yn(o),a=await(e.renderer??((n)=>Xe(n)))(m);return{html:k(a),frontmatter:r??{}}}import{dirname as v,resolve as _}from"path";function M(o){let e=o,r=ae(o);if(r)e=r.content.trim();let m=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,c=[],a=[],n=[],p=(i)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(i),u;while((u=m.exec(o))!==null){let i=u[1],l=u[2],d=u[0],f=i.includes("server");if(p(l))n.push(d);else if(f)a.push(l);else c.push(d)}let t=e;{let i=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,l,d=[];while((l=i.exec(t))!==null){let f=l.index+l[0].length,x=t.indexOf("</script>",f);if(x===-1)continue;d.push({start:l.index,end:x+9}),i.lastIndex=x+9}for(let f=d.length-1;f>=0;f--)t=t.substring(0,d[f].start)+t.substring(d[f].end)}for(let i of c)t=t.replace(i,"");return{templateContent:t,serverScripts:a,clientScripts:c,signalsScripts:n}}function E(o,e){return`<!DOCTYPE html>
|
|
3
|
+
<html lang="en">
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<title>${(e||"stx").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
${o}
|
|
11
|
+
</body>
|
|
12
|
+
</html>`}async function Ki(o,e={}){let r=_(o),m=Bun.file(r);if(!await m.exists())throw Error(`Template file not found: ${r}`);let c=await m.text(),a=null;if(b(r)){let n=await R(c,{renderer:e.markdownRenderer});c=n.html,a=n.frontmatter}if(a)e={...e,context:{...a,...e.context||{}}};if(e.layout){let n=_(e.layout),p=Bun.file(n);if(!await p.exists())throw Error(`Layout template not found: ${n}`);let{layout:u,injectCSS:t,...i}=e,l={...e.context||{}};ln(l);let d=await S(c,r,{...i,context:{...l,__stx_defer_server_data:!0},injectCSS:!1}),f=await p.text(),x={...l,content:d},y={...i,context:x,injectCSS:t};return S(f,n,y)}return S(c,r,e)}async function S(o,e,r={}){let{templateContent:m,serverScripts:c,clientScripts:a}=M(o),n={...N,...r.options},p={__filename:e,__dirname:v(e),__stx:{},__stx_options:n,__stx_sfc_mode:!0,__stx_inject_css:r.injectCSS===!0,__stxServeContext:void 0,...ds(r.context??{}),definePageMeta:()=>{},...r.context||{}};for(let i of c)await g(i,p,e);let u=new Set,t=m;if(t=await s(t,p,e,n,u),Ma(p,r.context),r.templateOnly){if(t=t.replace(/<script data-stx-scoped>[\s\S]*?<\/script>\s*/gi,""),t=t.replace(/<!-- stx SEO Tags -->[\s\S]*?(?=<)/i,""),a.length>0)t+=`
|
|
13
|
+
${a.join(`
|
|
14
|
+
`)}`}else{if(r.processClientScripts!==!1&&a.length>0){let i=p.__stx_event_bindings||[],l=Oe(p),d=await Promise.all(a.map(async(w)=>{let C=w.match(/<script\b([^>]*)>/i)?.[1]||"";if(/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(C))return w;let h=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!h)return w;return await Ne(h[1],{eventBindings:i,templateContent:t,serverData:l,filePath:e})})),x=[await Hn(d,{...n,buildMode:"compile"}),...d].filter(Boolean).join(`
|
|
15
|
+
`);if(t.match(/(<\/body>)/i))t=t.replace(/(<\/body>)/i,`${x}
|
|
16
|
+
$1`);else t+=`
|
|
17
|
+
${x}`}t=await me(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=E(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-5w1c7x22.js");t=await i(t)}catch{}return t}
|
|
18
|
+
export{Ki};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Nr,qn,xl}from"./chunk-
|
|
2
|
+
import{Nr,qn,xl}from"./chunk-a95r5nmq.js";import"./chunk-ka8befem.js";import"./chunk-p472crv1.js";import{Tt}from"./chunk-kwek8xdt.js";import"./chunk-pvb48ehs.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{xl as declareBareLoopHead,Tt as parseLoopBinding,qn as processLoops,Nr as reportDeferredLoopWarnings};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-2dp7hyv7.js";import"./chunk-pxdww4rb.js";import"./chunk-ce6zddpf.js";import"./chunk-
|
|
2
|
+
import"./chunk-2dp7hyv7.js";import"./chunk-pxdww4rb.js";import"./chunk-ce6zddpf.js";import"./chunk-kwek8xdt.js";import"./chunk-1sr6c0nk.js";import"./chunk-pvb48ehs.js";import"./chunk-a3d0g4mr.js";import"./chunk-a5zqqgx2.js";import{c}from"./chunk-zhf01af3.js";import u from"fs";import l 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||c(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=l.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"),m=JSON.parse(p);if(m.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(m.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};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Qn}from"./chunk-365vg0eg.js";import{dr}from"./chunk-2dp7hyv7.js";import{o}from"./chunk-
|
|
2
|
+
import{Qn}from"./chunk-365vg0eg.js";import{dr}from"./chunk-2dp7hyv7.js";import{o}from"./chunk-9gfffs28.js";import{U,Ge}from"./chunk-bnn7pd62.js";import{la}from"./chunk-g8r0km7g.js";var p=/<style\b[^>]*>/iy,x=/<\/style>/gi,R=/<script\b[^>]*>/iy,b=/<template(?=[\s>/])[^>]*>/iy,S=/<\/template\s*>/iy;function Gn(e){let r=0,t=0,s=-1;while(r<e.length){let n=e.indexOf("<",r);if(n===-1)return-1;if(e.startsWith("<!--",n)){let d=e.indexOf("-->",n+4);r=d===-1?e.length:d+3;continue}p.lastIndex=n;let u=p.exec(e);if(u){x.lastIndex=n+u[0].length;let d=x.exec(e);r=d===null?e.length:d.index+8;continue}b.lastIndex=n;let c=b.exec(e);if(c){if(t===0)s=n;t++,r=n+c[0].length;continue}S.lastIndex=n;let a=S.exec(e);if(a){if(t>0)t--;r=n+a[0].length;continue}if(R.lastIndex=n,R.test(e))return t>0?s:n;r=n+1}return-1}function V(e,r={}){return new Qn(e,r).routes}import w from"path";var T=new Map;async function y(e,r){let t=e,s=r;if(!t||!s)try{let a=await o();t||=a?.pagesDir||"pages",s||=a?.root||"."}catch{t||="pages",s||="."}let n=w.isAbsolute(t)?t:w.join(s,t),u=T.get(n);if(u)return u;let c=[];try{c=V(".",{pagesDir:n,emit:!1}).map((a)=>a.regex.source).filter(Boolean)}catch{c=[]}return T.set(n,c),c}function O(e){return e.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function l(e){return O(JSON.stringify(e))}function ge(e){return e.includes("data-stx-runtime")}function aa(e){let r=/window\.stx\s*\.\s*[A-Za-z_$]|\}\s*=\s*window\.stx\s*;/g;for(let t=r.exec(e);t!==null;t=r.exec(e)){let s=e.slice(Math.max(0,t.index-80),t.index);if(/if\s*\(\s*window\.stx\s*\)|window\.stx\s*&&/.test(s))continue;return!0}return!1}function f(e,r){let t=Gn(e),s=e.search(/<!doctype\b/i);if(t!==-1&&(s===-1||t>s))return e.slice(0,t)+r+`
|
|
3
3
|
`+e.slice(t);let n=dr(e);if(n!==null)return`${e.slice(0,n)}
|
|
4
4
|
${r}${e.slice(n)}`;if(e.includes("</head>")){let c=e.indexOf("</head>");return e.slice(0,c)+r+`
|
|
5
5
|
`+e.slice(c)}if(U(e))return Ge(e,(c)=>`${c}
|
|
6
6
|
${r}`);return`${r}
|
|
7
|
-
${e}`}async function Kn(e,r){if(e.includes("data-stx-runtime")||e.includes("window.stx.state")||e.includes("STX Signals Runtime"))return e;if(r.buildMode==="serve"){let{getServeClientAsset:n}=await import("./chunk-
|
|
7
|
+
${e}`}async function Kn(e,r){if(e.includes("data-stx-runtime")||e.includes("window.stx.state")||e.includes("STX Signals Runtime"))return e;if(r.buildMode==="serve"){let{getServeClientAsset:n}=await import("./chunk-0f33ssaq.js"),{url:u}=await n("runtime",r.debug===!0);return f(e,`<script data-stx-runtime src="${u}"></script>`)}if(r.buildMode==="compile")return f(e,'<script data-stx-runtime src="/__stx/runtime.__STX_HASH__.js"></script>');let{getCachedSignalsRuntime:t}=await import("./chunk-0f33ssaq.js"),s=await t(r.debug);return f(e,`<script data-stx-scoped data-stx-runtime>${s}</script>`)}function m(e){return/<[a-z][^>]*?\sx-tooltip\s*=/i.test(e)}function ca(e){if(e.includes("data-stx-tooltip-runtime")||!m(e))return e;let r=`<script data-stx-scoped data-stx-tooltip-runtime>${la()}</script>`,t=e.lastIndexOf("</body>");if(t===-1)return`${e}
|
|
8
8
|
${r}`;return`${e.slice(0,t)}${r}
|
|
9
|
-
${e.slice(t)}`}var E=/<script\b[^>]*\sdata-stx-router(?=[\s=>])/i;function C(e){return E.test(e)||e.includes("__stxRouter)return")||e.includes("__stxRouter=true")}async function me(e,r){if(!e.includes("</body>"))return e;if(C(e))return e;let t=r?.router,s="",n="";{let i={};if(t){if(t.container)i.container=t.container;if(t.interceptAllLinks!==void 0)i.interceptAllLinks=t.interceptAllLinks;if(t.progress!==void 0)i.progress=t.progress;if(t.viewTransitions!==void 0)i.viewTransitions=t.viewTransitions;if(t.viewTransitionDuration!==void 0)i.viewTransitionDuration=t.viewTransitionDuration;if(t.viewTransitionEasing!==void 0)i.viewTransitionEasing=t.viewTransitionEasing;if(t.scrollToTop!==void 0)i.scrollToTop=t.scrollToTop;if(t.scrollRestoration!==void 0)i.scrollRestoration=t.scrollRestoration;if(t.prefetch!==void 0)i.prefetch=t.prefetch;if(t.cache!==void 0)i.cache=t.cache;if(t.progressColor!==void 0)i.progressColor=t.progressColor;if(t.progressHeight!==void 0)i.progressHeight=t.progressHeight;if(t.prefetchVisible!==void 0)i.prefetchVisible=t.prefetchVisible;if(t.prefetchVisibleMax!==void 0)i.prefetchVisibleMax=t.prefetchVisibleMax;if(t.keepOpening!==void 0)i.keepOpening=t.keepOpening}try{let g=await y(r?.pagesDir,r?.root);if(g.length>0)if(r?.buildMode==="serve"){let{registerServeModuleBundle:h}=await import("./chunk-
|
|
9
|
+
${e.slice(t)}`}var E=/<script\b[^>]*\sdata-stx-router(?=[\s=>])/i;function C(e){return E.test(e)||e.includes("__stxRouter)return")||e.includes("__stxRouter=true")}async function me(e,r){if(!e.includes("</body>"))return e;if(C(e))return e;let t=r?.router,s="",n="";{let i={};if(t){if(t.container)i.container=t.container;if(t.interceptAllLinks!==void 0)i.interceptAllLinks=t.interceptAllLinks;if(t.progress!==void 0)i.progress=t.progress;if(t.viewTransitions!==void 0)i.viewTransitions=t.viewTransitions;if(t.viewTransitionDuration!==void 0)i.viewTransitionDuration=t.viewTransitionDuration;if(t.viewTransitionEasing!==void 0)i.viewTransitionEasing=t.viewTransitionEasing;if(t.scrollToTop!==void 0)i.scrollToTop=t.scrollToTop;if(t.scrollRestoration!==void 0)i.scrollRestoration=t.scrollRestoration;if(t.prefetch!==void 0)i.prefetch=t.prefetch;if(t.cache!==void 0)i.cache=t.cache;if(t.progressColor!==void 0)i.progressColor=t.progressColor;if(t.progressHeight!==void 0)i.progressHeight=t.progressHeight;if(t.prefetchVisible!==void 0)i.prefetchVisible=t.prefetchVisible;if(t.prefetchVisibleMax!==void 0)i.prefetchVisibleMax=t.prefetchVisibleMax;if(t.keepOpening!==void 0)i.keepOpening=t.keepOpening}try{let g=await y(r?.pagesDir,r?.root);if(g.length>0)if(r?.buildMode==="serve"){let{registerServeModuleBundle:h}=await import("./chunk-0f33ssaq.js");n=`<script data-stx-owned-routes src="${h(`(window.__stxRouterConfig=window.__stxRouterConfig||{}).ownedRoutes=${l(g)};
|
|
10
10
|
`)}"></script>
|
|
11
11
|
`}else i.ownedRoutes=g}catch{}if(Object.keys(i).length>0)s=`<script>window.__stxRouterConfig=${l(i)};</script>
|
|
12
|
-
`}let{getCachedRouterScript:u,getServeClientAsset:c}=await import("./chunk-
|
|
12
|
+
`}let{getCachedRouterScript:u,getServeClientAsset:c}=await import("./chunk-0f33ssaq.js"),a=r?.buildMode==="compile"?'<script data-stx-router src="/__stx/router.__STX_HASH__.js"></script>':r?.buildMode==="serve"?`<script data-stx-router src="${(await c("router")).url}"></script>`:`<script data-stx-router>${await u()}</script>`,d=e.lastIndexOf("</body>");return e.slice(0,d)+s+n+a+`
|
|
13
13
|
</body>`+e.slice(d+7)}
|
|
14
14
|
export{Gn,V,ge,aa,Kn,ca,me};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Bd,Fd}from"./chunk-dw81nc5v.js";import"./chunk-x68etmdg.js";import"./chunk-wz2zb53w.js";import"./chunk-md2jn67b.js";import"./chunk-sjcqxfq1.js";import"./chunk-wankp78x.js";import"./chunk-p472crv1.js";import"./chunk-9gfffs28.js";import"./chunk-a5zqqgx2.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import"./chunk-kwek8xdt.js";import"./chunk-pvb48ehs.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Fd as clearStoreCache,Bd as getStoreScript};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{he,hs,ru,Ap,su,Pp,It,d,F,K,fn,ve,ou,Lo,iu,Ip,k,au,Op,_,Np}from"./chunk-
|
|
2
|
+
import{he,hs,ru,Ap,su,Pp,It,d,F,K,fn,ve,ou,Lo,iu,Ip,k,au,Op,_,Np}from"./chunk-kwek8xdt.js";import"./chunk-pvb48ehs.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{au as applyFilters,Pp as clearCustomFilters,ou as clientLoopScopes,hs as defaultFilters,fn as escapeAttributeValue,d as escapeHtml,F as escapeHtmlValue,K as escapeInterpolatedHtmlValue,_ as evaluateExpression,he as findMustacheEnd,su as getAllFilters,iu as interpolateScriptAttributes,Lo as interpolateScriptExpressions,Ip as interpolateScriptsInTemplate,k as processExpressions,ru as registerFilter,Ap as registerFilters,It as replaceInterpolations,Op as resetRejectedExpressionWarnings,Np as unescapeHtml,ve as usesSignalsInScript};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{ie}from"./chunk-365vg0eg.js";import{je,A}from"./chunk-1sr6c0nk.js";import{ba}from"./chunk-04kg16qs.js";import{c}from"./chunk-zhf01af3.js";import S from"fs";import m from"path";import{pathToFileURL as O}from"url";var E=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],P=new Set;function Zt(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!S.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let p=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=p.pop(),u=n.lastIndexOf("."),d=u>=0?n.slice(u+1):"get",g=d.toUpperCase();if(!E.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${E.map((y)=>y.toLowerCase()).join(", ")}`);if(u>=0)n=n.slice(0,u);if(n!=="index")p.push(n);let r=new Set,h=p.map((y,I)=>{let v=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(y);if(v){if(r.has(v[2])||v[1]&&I!==p.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(v[2]),`:${v[2]}${v[1]?"*":""}`}if(!/^[\w-]+$/.test(y))throw Error(`Unsupported API path segment ${y} in ${e}`);return y}),w=`/api${h.length?`/${h.join("/")}`:""}`,x=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(x))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(x)} and ${e}`);f.set(x,e);let R=m.join(o,e);P.add(m.resolve(R)),P.add(S.realpathSync(R)),i.push({pattern:w,method:g,filePath:R})}return i.sort((e,a)=>{let p=e.pattern.split("/"),n=a.pattern.split("/"),u=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(p.length,n.length);d++){let g=u(n[d])-u(p[d]);if(g)return g}return e.pattern.localeCompare(a.pattern)||e.method.localeCompare(a.method)})}async function Gs(s,l){let o=c(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:a}=ie(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${a.map((p)=>`${JSON.stringify(p)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
|
|
3
3
|
`);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function Ks(s,l,o={}){let i=Zt(s,o);await Gs(s,i);let f=[];for(let t of i){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
|
|
4
|
-
`)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),a),f.push({...t,filePath:n})}return f}function j(s,l){let o=s.map((i)=>({route:i,...ie(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Xs(s,l){return j(l,async(o)=>(await import(O(m.resolve(s,o.filePath)).href)).default)}async function sp(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=Zt(s,o);return await Gs(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=Zt(s,o);await Gs(s,t);let{loadStxConfig:e}=await import("./chunk-
|
|
4
|
+
`)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),a),f.push({...t,filePath:n})}return f}function j(s,l){let o=s.map((i)=>({route:i,...ie(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Xs(s,l){return j(l,async(o)=>(await import(O(m.resolve(s,o.filePath)).href)).default)}async function sp(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=Zt(s,o);return await Gs(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=Zt(s,o);await Gs(s,t);let{loadStxConfig:e}=await import("./chunk-aw3meb8t.js"),a=A((await e(s)).runtimeConfig);return await je(a,()=>j(t,async(p)=>{let n=await Bun.build({entrypoints:[p.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
|
|
5
5
|
`));let u=n.outputs.find((d)=>d.kind==="entry-point");if(!u||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${p.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await u.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function Js(s,l,o){if(ba(s))return!0;let i=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(i.test(m.basename(s)))return!0;try{if(i.test(m.basename(S.realpathSync(s))))return!0}catch{}if(P.has(m.resolve(s)))return!0;if(!o)return!1;let f=m.resolve(l,typeof o==="object"?o.dir??"server/api":"server/api"),t=(a)=>{try{return S.realpathSync(a)}catch{return m.resolve(a)}},e=t(s);return[f,m.resolve(l,"server"),m.resolve(l,".output/server")].some((a)=>{let p=t(a);return e===p||e.startsWith(`${p}${m.sep}`)})}
|
|
6
6
|
export{Zt,Gs,Ks,Xs,sp,Js};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ll,ul,Ce,dl,Qi,Gt,Kt,rp,ea,Xt,Fn,pl,fl,gl,qs,Jt,ml,Yt,hl}from"./chunk-
|
|
2
|
+
import{ll,ul,Ce,dl,Qi,Gt,Kt,rp,ea,Xt,Fn,pl,fl,gl,qs,Jt,ml,Yt,hl}from"./chunk-x68etmdg.js";import"./chunk-wz2zb53w.js";import"./chunk-md2jn67b.js";import"./chunk-9gfffs28.js";import"./chunk-a5zqqgx2.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import"./chunk-kwek8xdt.js";import"./chunk-pvb48ehs.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Fn as MODULE_SPECIFIER_PREFIX,ll as bundleCacheDir,ul as bundleCacheEntryLimit,Yt as bundleClientScript,Kt as clearBundleFailures,Ce as clientBundleDependencies,Gt as getBundleFailures,Xt as hasUserImports,Jt as moduleSubstitutionKey,fl as normalizeRegistrySpecifiers,ml as queueClientBundleBuild,Qi as recordBundleFailure,pl as registryIdForPath,ea as resolveBundlerFallback,gl as rewriteRegistryImports,rp as setBundlerFallbackMode,dl as shouldLogBundlerDiagnostics,hl as tempBuildName,qs as withModuleSubstitutes};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{zn,Ee}from"./chunk-md2jn67b.js";import{L,y,rr,as,S}from"./chunk-rwyexk13.js";import{o,R}from"./chunk-hvsv59f5.js";import{Js}from"./chunk-rmdc1bqn.js";import{Ze}from"./chunk-2zzc7006.js";import{c}from"./chunk-zhf01af3.js";import{i,et}from"./chunk-qjtpxsyx.js";import d from"path";import b 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))||Js(t,e,n)}var at=2;function ll(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):c(t,"bundle-cache")}function st(t,e){let n=t;for(let r of $t(e))if(r!==d.sep)n=n.split(r).join("\x00root");return n}var rt=new Map;function $t(t){let e=d.resolve(t),n=rt.get(e);if(!n){let r=e;try{r=b.realpathSync(e)}catch{}n=[...new Set([e,r])].sort((u,m)=>m.length-u.length),rt.set(e,n)}return n}function yt(t,e){try{let n=b.statSync(t),r=d.resolve(e),u=t.startsWith(`${r}${d.sep}`);return{path:u?d.relative(r,t):t,...u?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(b.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 r=ct(n,e);try{let u=b.statSync(r);if(u.size!==n.size)return!1;if(u.mtimeMs!==n.mtimeMs&&Bun.hash(b.readFileSync(r)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var lt=new Map,wt=100;function ul(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 b.promises.readdir(t)).filter((l)=>l.endsWith(".js")),r=ul();if(n.length<=r)return;let m=(await Promise.all(n.map(async(l)=>{try{return{name:l,at:(await b.promises.stat(d.join(t,l))).mtimeMs}}catch{return null}}))).filter((l)=>l!==null);m.sort((l,w)=>w.at-l.at);for(let l of m.slice(r)){let w=l.name.slice(0,-3);await b.promises.rm(d.join(t,`${w}.js`),{force:!0}),await b.promises.rm(d.join(t,`${w}.deps.json`),{force:!0})}C("pruned bundle cache to",r,"entries")}catch{}}function Ce(t){return lt.get(t)??[]}function q(t,e){if(t)lt.set(t,e)}function dl(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function C(...t){if(dl())console.log("[stx:bundler]",...t)}var Y=[];function Qi(t,e,n){Y.push({filePath:t||"<inline>",message:e,details:n})}function Gt(){return Y.slice()}function Kt(){Y.length=0}var Z;function rp(t){Z=t}function ea(){if(Z)return Z;try{let t=R.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function Xt(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((l)=>l.test(u)))return C("detected user import:",u),!0}let r=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=r.exec(t))!==null){let u=n[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!Q.some((l)=>l.test(u)))return C("detected side-effect import:",u),!0}return!1}var Fn="stx-module:",vt=/\.(?:[cm]?[jt]sx?|json)$/i;function pl(t,e){return d.relative(t,e).split(d.sep).join("/")}function fl(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,r,u,m)=>{let l=e.get(m);return l&&!m.startsWith(Fn)?`${r}${u}${l}${u}`:n})}function gl(t,e){let n=0,r=(m)=>{let l=`__stxMod${n++}`,w=JSON.stringify(m);return e.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${w}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(w)} + " is not registered on this page (#1957)");`),l},u=(m,l)=>{for(let w of m.split(",")){let F=w.trim();if(!F)continue;let j=F.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!j)continue;let p=j[1].startsWith('"')?JSON.parse(j[1]):j[1],s=j[2]??p;e.push(`var ${s} = ${l}[${JSON.stringify(p)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l,w)=>{let F=w.slice(Fn.length),j=r(F),p=l.trim(),s=p.match(/^([\w$]+)\s*(?:,\s*|$)/);if(s&&!p.startsWith("{")&&!p.startsWith("*"))e.push(`var ${s[1]} = ${j}.default;`),p=p.slice(s[0].length).trim();let a=p.match(/^\*\s*as\s+([\w$]+)$/);if(a)e.push(`var ${a[1]} = ${j};`);else if(p.startsWith("{"))u(p.replace(/^\{|\}$/g,""),j);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l)=>(r(l.slice(Fn.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(b.existsSync(n)&&b.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var K=new ht;function qs(t,e){let n=new Bun.CryptoHasher("md5");for(let[r,u]of[...t].sort(([m],[l])=>m<l?-1:m>l?1:0))n.update(`${r}\x00${u}\x00`);return K.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function Jt(){return K.getStore()?.key??""}function Bt(t,e,n,r,u,m=new Map,l,w){let F=(p,s,a)=>{if(X(s,t,l))return null;if(!u||p!==n||!vt.test(s))return null;try{if(!b.statSync(s,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}r.add(s);let h=`${Fn}${pl(process.cwd(),s)}`;return m.set(a,h),{path:h,external:!0}},j=(p,s)=>{let a=p===n?e:d.dirname(p),h=d.resolve(a,s);return it(h)??h};return{name:"stx-client-bundle",setup(p){if(p.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^\//},(s)=>{let a=it(s.path);if(a){let h=F(s.importer,a,s.path);if(h)return h;if(a!==n)r.add(a);return{path:a}}return{path:s.path,external:!0}}),p.onResolve({filter:/^\.\.?\//},(s)=>{let a=j(s.importer,s.path),h=F(s.importer,a,s.path);if(h)return h;return r.add(a),{path:a}}),p.onResolve({filter:/^[@~]\//},(s)=>{let a=d.resolve(t,s.path.slice(2)),h=[a,`${a}.ts`,`${a}.tsx`,`${a}.js`,`${a}.mjs`,`${a}.jsx`,d.join(a,"index.ts"),d.join(a,"index.tsx"),d.join(a,"index.js"),d.join(a,"index.mjs")];for(let I of h)if(b.existsSync(I)&&b.statSync(I,{throwIfNoEntry:!1})?.isFile()){let E=F(s.importer,I,s.path);if(E)return E;return C(`resolved ${s.path[0]}/ import:`,s.path,"\u2192",I),r.add(I),{path:I}}return console.warn(`[stx:bundler] could not resolve ${s.path[0]}/ import:`,s.path),{path:a}}),u)p.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(s)=>{if(s.importer!==n)return;let a=`${Fn}npm:${s.path}`;return m.set(s.path,a),{path:a,external:!0}});p.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(s)=>{if(X(s.path,t,l))throw Error(`Server-only API source cannot be imported by a client script: ${s.path}`);let a=d.extname(s.path).toLowerCase(),h=a===".json"?"json":a===".tsx"?"tsx":a===".jsx"?"jsx":a===".ts"||a===".mts"||a===".cts"?"ts":"js";if(s.path!==n)r.add(s.path);let I=w?.get(s.path);if(I!==void 0)return{contents:I,loader:"js"};return{contents:b.readFileSync(s.path,"utf8"),loader:h}})}}}var H=new Map,z=y(64),ot=Symbol.for("stx.client-bundle-build-queue");function ml(t){let e=globalThis,r=(e[ot]??Promise.resolve()).then(t,t);return e[ot]=r.then(()=>{return},()=>{return}),r}async function Yt(t,e,n={}){let r=n.projectRoot||process.cwd(),u=(await o(r)).serverApi,m=n.minify??!1,l=n.externalizeUserModules??!0,w=n.expose?.length?[...new Set(n.expose)].sort():void 0,F=n.cacheDir||ll(r),j=K.getStore(),p=new Bun.CryptoHasher("md5");p.update(`${xt}\x00${Ze()}\x00${JSON.stringify(u??!1)}\x00${l?"registry":"inline"}\x00${w?w.join(","):"*"}\x00${m?"minified":"readable"}\x00${j?.key??""}\x00${st(t,r)}\x00${st(e,r)}`);let s=p.digest("hex").slice(0,12),a=d.join(F,`${s}.js`),h=z.get(a);if(h){if(as(h.files)&&h.files.every((M)=>!X(M.path,r,u))){C("memo hit:",s);let M=h.files.map((A)=>A.path);return q(e,M),n.collectInputs?.push(...M),h.code}z.delete(a),C("memo invalidated by dep change:",s)}let I=d.join(F,`${s}.deps.json`),E=Bun.file(a);if(await E.exists()){let M=Bun.file(I),A=!1,O=null;if(await M.exists())try{let D=JSON.parse(await M.text());if(D.metadataVersion===at&&Array.isArray(D.files)&&bt(D.files,r))O=rr(D.files.map((g)=>ct(g,r))),A=O.length===D.files.length&&!O.some((g)=>X(g.path,r,u))}catch{A=!1}if(A){if(C("cache hit:",s),O)q(e,O.map((T)=>T.path)),n.collectInputs?.push(...O.map((T)=>T.path));let D=await E.text(),g=new Date;if(b.promises.utimes(a,g,g).catch(()=>{}),O)z.set(a,{code:D,files:O});return D}C("cache invalidated by dep change:",s)}let P=H.get(s);if(P){let M=await P;if(n.collectInputs)n.collectInputs.push(...(z.get(a)?.files??[]).map((A)=>A.path));return M}let V=ml(()=>Et(t,e,{projectRoot:r,minify:m,cacheDir:F,hash:s,cachePath:a,depsPath:I,collectInputs:n.collectInputs,externalizeUserModules:l,serverApi:u,expose:w,throwOnFailure:n.throwOnFailure,substitutes:j?.modules}));H.set(s,V);try{return await V}finally{H.delete(s)}}var jt=0;function hl(t){return`${t}-${process.pid}-${++jt}`}async function Et(t,e,n){let{projectRoot:r,minify:u,cacheDir:m,hash:l,cachePath:w,depsPath:F,externalizeUserModules:j}=n,p=c(r,"bundle-tmp"),s=hl(l),a=d.join(p,`${s}.ts`),h=d.join(p,"out",s);b.mkdirSync(p,{recursive:!0}),b.mkdirSync(h,{recursive:!0});let I=d.dirname(e),E=new Set,P=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,V=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,M=i(t),{depths:A,balanced:O}=et(M),D=(B)=>!O||A[B]===0,g;while((g=P.exec(M))!==null){if(g[1])continue;if(!D(g.index))continue;if(g[2])g[2].split(",").forEach((B)=>{let f=_t(B);if(f)E.add(f)});else if(g[3])E.add(g[3])}while((g=V.exec(M))!==null){if(g[1])continue;if(!D(g.index))continue;E.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(!D(g.index))continue;let B=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(B&&Q.some((f)=>f.test(B)))continue;if(g[1])E.add(g[1]);if(g[2])E.add(g[2]);for(let f of(g[3]??"").split(",")){let v=f.trim();if(!v||/^type\s/.test(v))continue;let U=/\bas\s+(\w+)\s*$/.exec(v)?.[1]??/^\w+$/.exec(v)?.[0];if(U)E.add(U)}}for(let B of M.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let f of B[1].split(",")){let v=/\bas\s+(\w+)\s*$/.exec(f)?.[1]??/^\s*(\w+)\s*$/.exec(f)?.[1];if(v)E.delete(v)}let ut=E.size>0?`
|
|
2
|
+
import{zn,Ee}from"./chunk-md2jn67b.js";import{L,y,rr,as,S}from"./chunk-kwek8xdt.js";import{o,R}from"./chunk-9gfffs28.js";import{Js}from"./chunk-wz2zb53w.js";import{Ze}from"./chunk-2zzc7006.js";import{c}from"./chunk-zhf01af3.js";import{i,et}from"./chunk-qjtpxsyx.js";import d from"path";import b 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))||Js(t,e,n)}var at=2;function ll(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):c(t,"bundle-cache")}function st(t,e){let n=t;for(let r of $t(e))if(r!==d.sep)n=n.split(r).join("\x00root");return n}var rt=new Map;function $t(t){let e=d.resolve(t),n=rt.get(e);if(!n){let r=e;try{r=b.realpathSync(e)}catch{}n=[...new Set([e,r])].sort((u,m)=>m.length-u.length),rt.set(e,n)}return n}function yt(t,e){try{let n=b.statSync(t),r=d.resolve(e),u=t.startsWith(`${r}${d.sep}`);return{path:u?d.relative(r,t):t,...u?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(b.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 r=ct(n,e);try{let u=b.statSync(r);if(u.size!==n.size)return!1;if(u.mtimeMs!==n.mtimeMs&&Bun.hash(b.readFileSync(r)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var lt=new Map,wt=100;function ul(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 b.promises.readdir(t)).filter((l)=>l.endsWith(".js")),r=ul();if(n.length<=r)return;let m=(await Promise.all(n.map(async(l)=>{try{return{name:l,at:(await b.promises.stat(d.join(t,l))).mtimeMs}}catch{return null}}))).filter((l)=>l!==null);m.sort((l,w)=>w.at-l.at);for(let l of m.slice(r)){let w=l.name.slice(0,-3);await b.promises.rm(d.join(t,`${w}.js`),{force:!0}),await b.promises.rm(d.join(t,`${w}.deps.json`),{force:!0})}C("pruned bundle cache to",r,"entries")}catch{}}function Ce(t){return lt.get(t)??[]}function q(t,e){if(t)lt.set(t,e)}function dl(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function C(...t){if(dl())console.log("[stx:bundler]",...t)}var Y=[];function Qi(t,e,n){Y.push({filePath:t||"<inline>",message:e,details:n})}function Gt(){return Y.slice()}function Kt(){Y.length=0}var Z;function rp(t){Z=t}function ea(){if(Z)return Z;try{let t=R.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function Xt(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((l)=>l.test(u)))return C("detected user import:",u),!0}let r=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=r.exec(t))!==null){let u=n[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!Q.some((l)=>l.test(u)))return C("detected side-effect import:",u),!0}return!1}var Fn="stx-module:",vt=/\.(?:[cm]?[jt]sx?|json)$/i;function pl(t,e){return d.relative(t,e).split(d.sep).join("/")}function fl(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,r,u,m)=>{let l=e.get(m);return l&&!m.startsWith(Fn)?`${r}${u}${l}${u}`:n})}function gl(t,e){let n=0,r=(m)=>{let l=`__stxMod${n++}`,w=JSON.stringify(m);return e.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${w}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(w)} + " is not registered on this page (#1957)");`),l},u=(m,l)=>{for(let w of m.split(",")){let F=w.trim();if(!F)continue;let j=F.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!j)continue;let p=j[1].startsWith('"')?JSON.parse(j[1]):j[1],s=j[2]??p;e.push(`var ${s} = ${l}[${JSON.stringify(p)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l,w)=>{let F=w.slice(Fn.length),j=r(F),p=l.trim(),s=p.match(/^([\w$]+)\s*(?:,\s*|$)/);if(s&&!p.startsWith("{")&&!p.startsWith("*"))e.push(`var ${s[1]} = ${j}.default;`),p=p.slice(s[0].length).trim();let a=p.match(/^\*\s*as\s+([\w$]+)$/);if(a)e.push(`var ${a[1]} = ${j};`);else if(p.startsWith("{"))u(p.replace(/^\{|\}$/g,""),j);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l)=>(r(l.slice(Fn.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(b.existsSync(n)&&b.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var K=new ht;function qs(t,e){let n=new Bun.CryptoHasher("md5");for(let[r,u]of[...t].sort(([m],[l])=>m<l?-1:m>l?1:0))n.update(`${r}\x00${u}\x00`);return K.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function Jt(){return K.getStore()?.key??""}function Bt(t,e,n,r,u,m=new Map,l,w){let F=(p,s,a)=>{if(X(s,t,l))return null;if(!u||p!==n||!vt.test(s))return null;try{if(!b.statSync(s,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}r.add(s);let h=`${Fn}${pl(process.cwd(),s)}`;return m.set(a,h),{path:h,external:!0}},j=(p,s)=>{let a=p===n?e:d.dirname(p),h=d.resolve(a,s);return it(h)??h};return{name:"stx-client-bundle",setup(p){if(p.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^\//},(s)=>{let a=it(s.path);if(a){let h=F(s.importer,a,s.path);if(h)return h;if(a!==n)r.add(a);return{path:a}}return{path:s.path,external:!0}}),p.onResolve({filter:/^\.\.?\//},(s)=>{let a=j(s.importer,s.path),h=F(s.importer,a,s.path);if(h)return h;return r.add(a),{path:a}}),p.onResolve({filter:/^[@~]\//},(s)=>{let a=d.resolve(t,s.path.slice(2)),h=[a,`${a}.ts`,`${a}.tsx`,`${a}.js`,`${a}.mjs`,`${a}.jsx`,d.join(a,"index.ts"),d.join(a,"index.tsx"),d.join(a,"index.js"),d.join(a,"index.mjs")];for(let I of h)if(b.existsSync(I)&&b.statSync(I,{throwIfNoEntry:!1})?.isFile()){let E=F(s.importer,I,s.path);if(E)return E;return C(`resolved ${s.path[0]}/ import:`,s.path,"\u2192",I),r.add(I),{path:I}}return console.warn(`[stx:bundler] could not resolve ${s.path[0]}/ import:`,s.path),{path:a}}),u)p.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(s)=>{if(s.importer!==n)return;let a=`${Fn}npm:${s.path}`;return m.set(s.path,a),{path:a,external:!0}});p.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(s)=>{if(X(s.path,t,l))throw Error(`Server-only API source cannot be imported by a client script: ${s.path}`);let a=d.extname(s.path).toLowerCase(),h=a===".json"?"json":a===".tsx"?"tsx":a===".jsx"?"jsx":a===".ts"||a===".mts"||a===".cts"?"ts":"js";if(s.path!==n)r.add(s.path);let I=w?.get(s.path);if(I!==void 0)return{contents:I,loader:"js"};return{contents:b.readFileSync(s.path,"utf8"),loader:h}})}}}var H=new Map,z=y(64),ot=Symbol.for("stx.client-bundle-build-queue");function ml(t){let e=globalThis,r=(e[ot]??Promise.resolve()).then(t,t);return e[ot]=r.then(()=>{return},()=>{return}),r}async function Yt(t,e,n={}){let r=n.projectRoot||process.cwd(),u=(await o(r)).serverApi,m=n.minify??!1,l=n.externalizeUserModules??!0,w=n.expose?.length?[...new Set(n.expose)].sort():void 0,F=n.cacheDir||ll(r),j=K.getStore(),p=new Bun.CryptoHasher("md5");p.update(`${xt}\x00${Ze()}\x00${JSON.stringify(u??!1)}\x00${l?"registry":"inline"}\x00${w?w.join(","):"*"}\x00${m?"minified":"readable"}\x00${j?.key??""}\x00${st(t,r)}\x00${st(e,r)}`);let s=p.digest("hex").slice(0,12),a=d.join(F,`${s}.js`),h=z.get(a);if(h){if(as(h.files)&&h.files.every((M)=>!X(M.path,r,u))){C("memo hit:",s);let M=h.files.map((A)=>A.path);return q(e,M),n.collectInputs?.push(...M),h.code}z.delete(a),C("memo invalidated by dep change:",s)}let I=d.join(F,`${s}.deps.json`),E=Bun.file(a);if(await E.exists()){let M=Bun.file(I),A=!1,O=null;if(await M.exists())try{let D=JSON.parse(await M.text());if(D.metadataVersion===at&&Array.isArray(D.files)&&bt(D.files,r))O=rr(D.files.map((g)=>ct(g,r))),A=O.length===D.files.length&&!O.some((g)=>X(g.path,r,u))}catch{A=!1}if(A){if(C("cache hit:",s),O)q(e,O.map((T)=>T.path)),n.collectInputs?.push(...O.map((T)=>T.path));let D=await E.text(),g=new Date;if(b.promises.utimes(a,g,g).catch(()=>{}),O)z.set(a,{code:D,files:O});return D}C("cache invalidated by dep change:",s)}let P=H.get(s);if(P){let M=await P;if(n.collectInputs)n.collectInputs.push(...(z.get(a)?.files??[]).map((A)=>A.path));return M}let V=ml(()=>Et(t,e,{projectRoot:r,minify:m,cacheDir:F,hash:s,cachePath:a,depsPath:I,collectInputs:n.collectInputs,externalizeUserModules:l,serverApi:u,expose:w,throwOnFailure:n.throwOnFailure,substitutes:j?.modules}));H.set(s,V);try{return await V}finally{H.delete(s)}}var jt=0;function hl(t){return`${t}-${process.pid}-${++jt}`}async function Et(t,e,n){let{projectRoot:r,minify:u,cacheDir:m,hash:l,cachePath:w,depsPath:F,externalizeUserModules:j}=n,p=c(r,"bundle-tmp"),s=hl(l),a=d.join(p,`${s}.ts`),h=d.join(p,"out",s);b.mkdirSync(p,{recursive:!0}),b.mkdirSync(h,{recursive:!0});let I=d.dirname(e),E=new Set,P=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,V=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,M=i(t),{depths:A,balanced:O}=et(M),D=(B)=>!O||A[B]===0,g;while((g=P.exec(M))!==null){if(g[1])continue;if(!D(g.index))continue;if(g[2])g[2].split(",").forEach((B)=>{let f=_t(B);if(f)E.add(f)});else if(g[3])E.add(g[3])}while((g=V.exec(M))!==null){if(g[1])continue;if(!D(g.index))continue;E.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(!D(g.index))continue;let B=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(B&&Q.some((f)=>f.test(B)))continue;if(g[1])E.add(g[1]);if(g[2])E.add(g[2]);for(let f of(g[3]??"").split(",")){let v=f.trim();if(!v||/^type\s/.test(v))continue;let U=/\bas\s+(\w+)\s*$/.exec(v)?.[1]??/^\w+$/.exec(v)?.[0];if(U)E.add(U)}}for(let B of M.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let f of B[1].split(",")){let v=/\bas\s+(\w+)\s*$/.exec(f)?.[1]??/^\s*(\w+)\s*$/.exec(f)?.[1];if(v)E.delete(v)}let ut=E.size>0?`
|
|
3
3
|
export { ${[...E].join(", ")} }`:"";await Bun.write(a,t+ut),C("bundling:",l,"from:",d.basename(e));let tt=new Set,nt=new Map;try{let B=await Bun.build({entrypoints:[a],outdir:h,target:"browser",format:"esm",minify:u?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[Bt(r,I,a,tt,j,nt,n.serverApi,n.substitutes)],define:{"process.env.NODE_ENV":u?'"production"':'"development"',...S()},root:r});if(!B.success){let _=B.logs.filter((N)=>N.level==="error").map((N)=>N.message).join(", ")||`Unable to bundle ${d.basename(e)}`,k=zn(B.logs,e||void 0);if(console.warn("[stx:bundler] build failed:",_),Qi(e||"",_,k),n.throwOnFailure||ea()==="error")throw Error(_);return t}let f="";for(let x of B.outputs){f=await x.text();break}let v=[];for(let x of f.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let _ of x[1].split(",")){let k=_.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(k){v.push([k[2],k[1]]);continue}let N=_.trim();if(/^[A-Za-z_$][\w$]*$/.test(N))v.push([N,N])}if(n.expose){let x=new Set(n.expose);for(let _=v.length-1;_>=0;_--)if(!x.has(v[_][0]))v.splice(_,1)}let U=[];f=gl(fl(f,nt),U);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_${l}`,pt=new Set(L(t,!0).split(",").map((x)=>x.trim())),ft=v.map(([x,_])=>`get ${JSON.stringify(x)}() { return ${_} }${pt.has(x)?`, set ${JSON.stringify(x)}(__stxValue_${_}) { ${_} = __stxValue_${_} }`:""}`).join(", "),mt=v.map(([x])=>`var ${x} = undefined;`).join(`
|
|
4
4
|
`),gt=v.map(([x])=>`${x} = ${J}[${JSON.stringify(x)}];`).join(`
|
|
5
5
|
`);if(f=`${dt.join(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{k}from"./chunk-
|
|
2
|
+
import{k}from"./chunk-kwek8xdt.js";import{s}from"./chunk-mjm3tyfj.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let n=u[t[0]];console.log(`
|
|
3
3
|
${e.bold}${t[0]}${e.reset} - ${n.description}`),console.log(` Usage: ${e.cyan}${n.usage}${e.reset}
|
|
4
4
|
`)}else{console.log(`
|
|
5
5
|
${e.bold}Available Commands:${e.reset}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$u}from"./chunk-a3yte051.js";import"./chunk-7kk2m44a.js";import"./chunk-wz2zb53w.js";import"./chunk-wankp78x.js";import"./chunk-9gfffs28.js";import"./chunk-a5zqqgx2.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import"./chunk-kwek8xdt.js";import"./chunk-pvb48ehs.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{$u as startProductionServer};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{zs,zd,Hd}from"./chunk-t961jbzc.js";import"./chunk-x68etmdg.js";import"./chunk-wz2zb53w.js";import"./chunk-md2jn67b.js";import"./chunk-sjcqxfq1.js";import"./chunk-wankp78x.js";import"./chunk-p472crv1.js";import"./chunk-9gfffs28.js";import"./chunk-a5zqqgx2.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import"./chunk-kwek8xdt.js";import"./chunk-pvb48ehs.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Hd as clearComposableCache,zd as getComposableScript,zs as listComposableModules};
|
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import"./chunk-2dp7hyv7.js";import"./chunk-pxdww4rb.js";import"./chunk-ce6zddpf.js";import{Re,te}from"./chunk-
|
|
3
|
+
import"./chunk-2dp7hyv7.js";import"./chunk-pxdww4rb.js";import"./chunk-ce6zddpf.js";import{Re,te}from"./chunk-kwek8xdt.js";import"./chunk-1sr6c0nk.js";import"./chunk-pvb48ehs.js";import"./chunk-a3d0g4mr.js";import"./chunk-365vg0eg.js";import"./chunk-9gfffs28.js";import"./chunk-fzqj1mjz.js";import"./chunk-04kg16qs.js";import"./chunk-mjm3tyfj.js";import"./chunk-6xe8rnfv.js";import"./chunk-8k3rwv8r.js";import"./chunk-9yxgdy4z.js";import"./chunk-1mj9crcg.js";import"./chunk-qffbkvfn.js";import"./chunk-7met6yva.js";import"./chunk-yfvm7q6t.js";import"./chunk-b823zxq6.js";import"./chunk-tre98h62.js";import"./chunk-89jbdtgw.js";import"./chunk-7d4z944r.js";import"./chunk-7kk2m44a.js";import"./chunk-kgfgb971.js";import"./chunk-f9hrpwsw.js";import"./chunk-3y41efsf.js";import"./chunk-jxda11cg.js";import"./chunk-dgb4z4kw.js";import"./chunk-a3yte051.js";import"./chunk-zqtbtqbq.js";import"./chunk-a95r5nmq.js";import"./chunk-sjcqxfq1.js";import"./chunk-prf164ct.js";import"./chunk-yqz01qvy.js";import"./chunk-nrvwejdw.js";import"./chunk-wz2zb53w.js";import"./chunk-5pgk3w2c.js";import"./chunk-kenbxxbn.js";import"./chunk-aprhqxky.js";import"./chunk-r3e6x87d.js";import"./chunk-mmwedr93.js";import"./chunk-md2jn67b.js";import{Gt,Kt}from"./chunk-x68etmdg.js";import"./chunk-t961jbzc.js";import"./chunk-06b8btkv.js";import"./chunk-ym41ybz2.js";import"./chunk-n38yb274.js";import"./chunk-9p6efb17.js";import"./chunk-t2pzy3x1.js";import"./chunk-rcadtv3x.js";import"./chunk-dw81nc5v.js";import"./chunk-23b0khvh.js";import{di,pi,fi,gi,As,mi,hi,yi,Ps,Is,Sr,kr,_r}from"./chunk-p3x21vp7.js";import"./chunk-t9yqq483.js";import"./chunk-6ajahb2x.js";import"./chunk-ka8befem.js";import"./chunk-wankp78x.js";import"./chunk-p472crv1.js";import{ma}from"./chunk-a5zqqgx2.js";import{f}from"./chunk-b7e07ybq.js";import{spawn as R}from"child_process";import S from"fs";import p from"path";import n from"process";import{CLI as z}from"@stacksjs/clapp";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new z("stx");function E(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(m<1024||m>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function A(h){try{if(!S.existsSync(h)){let x=p.dirname(h),t=p.basename(h);if(S.existsSync(x)){let o=S.readdirSync(x).filter((s)=>s.toLowerCase().includes(t.toLowerCase().substring(0,3))||s.endsWith(".stx")||s.endsWith(".md")),r=o.length>0?`File not found. Similar files in ${x}: ${o.slice(0,3).join(", ")}`:`File not found. Directory ${x} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${h}`,suggestion:r}}return{isValid:!1,error:`File does not exist: ${h}`,suggestion:"Check the file path and try again"}}if(S.statSync(h).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${h}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(m){return{isValid:!1,error:`Cannot access file: ${h}`,suggestion:"Check file permissions and path"}}}function I(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(m<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(m>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var O=(h)=>h.includes("*")||h.includes("?")||h.includes("{")||h.includes("["),W=(h)=>h.endsWith(".stx")||h.endsWith(".md");function F(h,m=1){if(console.error(`\u274C ${h.error}`),h.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${h.suggestion}`);n.exit(m)}function M(h){if(!h)return;let m;try{m=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),n.exit(1)}if(typeof m!=="object"||m===null||Array.isArray(m))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),n.exit(1);for(let[x,t]of Object.entries(m))if(typeof t!=="string"&&typeof t!=="number"&&typeof t!=="boolean")console.error(`\u274C --info-plist value for "${x}" must be a string, number or boolean`),n.exit(1);return m}async function V(h,m){try{let x=["test"],t=[];if(h&&h.length>0)for(let c of h)if(O(c))try{let i=await Array.fromAsync(new Bun.Glob(c).scan({onlyFiles:!0,absolute:!0}));if(i.length===0)console.warn(`Warning: No files found matching pattern: ${c}`);else if(t.push(...i),m.verbose)console.log(`Found ${i.length} file(s) matching pattern: ${c}`)}catch(i){return console.error(`Error expanding glob pattern ${c}:`,i),!1}else t.push(c);if(t.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(x.push(...t),m.filter)x.push("--pattern",m.filter);if(m.timeout)x.push("--timeout",m.timeout.toString());if(m.reporter&&m.reporter!=="default")if(m.reporter==="junit"){let c=p.resolve("stx-test-report.xml");x.push("--reporter",m.reporter),x.push("--reporter-outfile",c),console.log(`JUnit report: ${c}`)}else console.warn(`Warning: Reporter '${m.reporter}' is not supported. Using default reporter.`);if(m.coverage)x.push("--coverage");if(m.watch)x.push("--watch");x.push("--preload",p.join(__dirname,"../../../test-utils/happy-dom.ts"));let e={...n.env,STX_TEST_MODE:"true",STX_TEST_UI:m.ui?"true":"false",STX_TEST_VERBOSE:m.verbose?"true":"false"},o="bun";if(m.verbose)console.log(`Running: ${o} ${x.join(" ")}`);let r=performance.now(),s=R(o,x,{stdio:"inherit",shell:!1,env:e});return new Promise((c)=>{s.on("close",(i)=>{let d=((performance.now()-r)/1000).toFixed(2);if(i===0)c(!0);else c(!1)}),n.on("SIGINT",()=>{console.log(`
|
|
4
4
|
Test run interrupted`),s.kill("SIGINT"),n.exit(1)})})}catch(x){return console.error("Error running tests:",x instanceof Error?x.message:String(x)),!1}}var U=n.argv.length>=3&&(W(n.argv[2])&&S.existsSync(n.argv[2])||O(n.argv[2]));if(U){let h=n.argv[2],m={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let x=3;x<n.argv.length;x++){let t=n.argv[x];if(t==="--port"&&x+1<n.argv.length){let e=E(n.argv[++x]);if(!e.isValid)F(e);m.port=Number.parseInt(n.argv[x],10)}else if(t==="--no-watch")m.watch=!1;else if(t==="--highlight-theme"&&x+1<n.argv.length){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.defaultTheme=n.argv[++x]}else if(t==="--no-highlight"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.enabled=!1}else if(t==="--no-highlight-unknown"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(t==="--no-cache")m.cache=!1;else if(t==="--native")m.native=!0}if(O(h))try{let x=await Array.fromAsync(new Bun.Glob(h).scan({onlyFiles:!0,absolute:!0})),t=h.endsWith(".stx")?x.filter((s)=>s.endsWith(".stx")):h.endsWith(".md")?x.filter((s)=>s.endsWith(".md")):x.filter((s)=>s.endsWith(".stx")||s.endsWith(".md")),e=h.split("*")[0].replace(/\/$/,"")||".",o=p.resolve(e);try{let s=new Bun.Glob("**/*.stx"),i=(await Array.fromAsync(s.scan({cwd:o,onlyFiles:!0,absolute:!0}))).filter((l)=>/\[.+\]/.test(p.basename(l)));for(let l of i)if(!t.includes(l))t.push(l)}catch{}if(t.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${h}`),n.exit(1);if(!await kr(t,m))n.exit(1)}catch(x){console.error("Failed to process files:",x),n.exit(1)}else Sr(h,m).catch((x)=>{console.error("Failed to start dev server:",x),n.exit(1)})}else{let h=function(t,e){let o=[];for(let r=0;r<=e.length;r++)o[r]=[r];for(let r=0;r<=t.length;r++)o[0][r]=r;for(let r=1;r<=e.length;r++)for(let s=1;s<=t.length;s++)if(e.charAt(r-1)===t.charAt(s-1))o[r][s]=o[r-1][s-1];else o[r][s]=Math.min(o[r-1][s-1]+1,o[r][s-1]+1,o[r-1][s]+1);return o[e.length][t.length]};y.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(t)=>{try{if(await gi(t))console.log("Documentation generated successfully."),n.exit(0);else console.error("Documentation generation failed."),n.exit(1)}catch(e){console.error("Error generating documentation:",e),n.exit(1)}}),y.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(t,e)=>{try{let{fetchCollections:o,generatePackage:r}=await import("./chunk-3850m7ab.js");if(t==="list"){console.log(`
|
|
5
5
|
\uD83D\uDCDA Fetching available icon collections...
|
|
6
6
|
`);let s=await o(),c=Object.entries(s).sort((i,l)=>l[1].total-i[1].total);console.log(`Available collections:
|
|
7
7
|
`);for(let[i,l]of c){let d=l;console.log(` ${i.padEnd(30)} ${d.name} (${d.total} icons)`)}console.log(`
|
|
8
8
|
Total: ${c.length} collections`)}else if(t.startsWith("generate")){let s=t==="generate"?"":t.replace("generate:","").replace("generate-","").replace("generate","").trim();if(!s)console.error("Error: Please specify a collection prefix"),console.error("Usage: stx iconify generate <prefix> [--icons icon1,icon2,...]"),n.exit(1);let c=e.output||p.join(n.cwd(),"packages/collections"),i=e.icons?e.icons.split(",").map((l)=>l.trim()):void 0;await r(s,c,i),console.log(`
|
|
9
9
|
\u2713 Package generated successfully!`),console.log(`
|
|
10
|
-
To use the package:`),console.log(` 1. cd packages/collections/iconify-${s}`),console.log(" 2. bun install"),console.log(" 3. bun run build")}else console.error(`Unknown iconify command: ${t}`),console.error("Available commands: list, generate"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("pwa <command>","PWA tools - audit configuration and build output").option("--output <dir>","Build output directory to audit",{default:"dist"}).example("stx pwa audit").example("stx pwa audit --output build").action(async(t,e)=>{try{if(t==="audit"){let{runPwaAudit:o,formatAuditResult:r}=await import("./chunk-864qtx7y.js"),{loadConfig:s}=await import("./chunk-
|
|
10
|
+
To use the package:`),console.log(` 1. cd packages/collections/iconify-${s}`),console.log(" 2. bun install"),console.log(" 3. bun run build")}else console.error(`Unknown iconify command: ${t}`),console.error("Available commands: list, generate"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("pwa <command>","PWA tools - audit configuration and build output").option("--output <dir>","Build output directory to audit",{default:"dist"}).example("stx pwa audit").example("stx pwa audit --output build").action(async(t,e)=>{try{if(t==="audit"){let{runPwaAudit:o,formatAuditResult:r}=await import("./chunk-864qtx7y.js"),{loadConfig:s}=await import("./chunk-aw3meb8t.js");console.log(`
|
|
11
11
|
\uD83D\uDD0D Running PWA audit...
|
|
12
12
|
`);let c=await s(),i=e.output||"dist",l=o(c,i);if(console.log(r(l)),l.failed>0)n.exit(1)}else console.error(`Unknown pwa command: ${t}`),console.error("Available commands: audit"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("dev [file]","Start a development server for an STX app or file").option("--port <port>","Port to use for the dev server",{default:3000}).option("--pages <dir>",'Directory containing page templates (default: pagesDir from stx.config.ts, else "pages")').option("--no-watch","Disable file watching and auto-reload").option("--native","Open in a native desktop window using Zyte").option("--titlebar-hidden","Hide the native titlebar but keep the traffic-light buttons (web content draws under a transparent full-size titlebar). Implies --native.").option("--highlight-theme <theme>","Syntax highlighting theme for Markdown code blocks",{default:"github-dark"}).option("--no-highlight","Disable syntax highlighting for Markdown code blocks").option("--no-highlight-unknown","Disable syntax highlighting for unknown languages in Markdown").option("--no-cache","Disable caching of parsed files").option("--no-hmr","Disable HMR / live-reload script injection (useful for clean network traces)").option("--profile","Print per-directive timing for every page render via performanceMonitor").option("--debug-directives","Log directive ordering and intermediate template state during rendering").example("stx dev").example("stx dev --port 8080").example("stx dev --pages src/pages").example("stx dev template.stx").example("stx dev components/hero.stx --port 8080").example("stx dev **/*.stx").example("stx dev docs/guide.md").example("stx dev template.stx --native").action(async(t,e)=>{try{if(e.port!==void 0){let r=E(e.port);if(!r.isValid)F(r);e.port=Number.parseInt(String(e.port),10)}if(e.timeout!==void 0){let r=I(e.timeout);if(!r.isValid)F(r)}let o={syntaxHighlighting:{enabled:e.highlight!==!1,serverSide:!0,defaultTheme:e.highlightTheme||"github-dark",highlightUnknownLanguages:e.highlightUnknown!==!1}};if(!t){if(!await _r(".",{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,cache:e.cache!==!1,hotReload:e.hmr!==!1,profile:e.profile===!0,debugDirectives:e.debugDirectives===!0,...e.pages&&{pagesDir:e.pages}}))n.exit(1);return}if(!O(t))try{let r=await import("fs");if(r.existsSync(t)&&r.statSync(t).isDirectory()){if(!await _r(t,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,cache:e.cache!==!1,hotReload:e.hmr!==!1,profile:e.profile===!0,debugDirectives:e.debugDirectives===!0,...e.pages&&{pagesDir:e.pages}}))n.exit(1);return}}catch{}if(O(t)){console.log(`Expanding glob pattern: ${t}`);let r=await te.timeAsync("glob-expansion",async()=>Array.fromAsync(new Bun.Glob(t).scan({onlyFiles:!0,absolute:!0}))),s=t.endsWith(".stx")?r.filter((d)=>d.endsWith(".stx")):t.endsWith(".md")?r.filter((d)=>d.endsWith(".md")):r.filter((d)=>d.endsWith(".stx")||d.endsWith(".md"));if(s.length===0)console.error(`No STX or Markdown files found matching pattern: ${t}`),console.error("Try using patterns like '*.stx' or 'components/**/*.stx'"),n.exit(1);let c=t.split("*")[0].replace(/\/$/,"")||".",i=p.resolve(c);try{let d=new Bun.Glob("**/*.stx"),u=(await Array.fromAsync(d.scan({cwd:i,onlyFiles:!0,absolute:!0}))).filter((g)=>/\[.+\]/.test(p.basename(g)));for(let g of u)if(!s.includes(g))s.push(g)}catch{}if(console.log(`Found ${s.length} ${s.length===1?"file":"files"} matching ${t}`),!await kr(s,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,markdown:o,cache:e.cache!==!1}))n.exit(1)}else{if(!O(t)){let s=A(t);if(!s.isValid)F(s)}if(!await Sr(t,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,markdown:o,cache:e.cache!==!1}))n.exit(1)}}catch(o){console.error("Error starting dev server:",o),n.exit(1)}}),y.command("a11y [target]","Scan .stx files for accessibility issues (directory, file, or glob)").option("--no-recursive","Disable recursive scanning of directories").option("--ignore <paths>","Comma-separated paths to ignore",{default:""}).option("--json","Output results as JSON").option("--output <file>","Write results to a file instead of stdout").option("--fix","Automatically fix common accessibility issues").example("stx a11y ./templates").example('stx a11y "resources/**/*.stx"').example("stx a11y resources/emails/welcome.stx").example("stx a11y --json --output a11y-report.json").action(async(t=".",e)=>{try{console.log(`Scanning ${t} for accessibility issues...`);let o=e.ignore?e.ignore.split(",").map((l)=>l.trim()):[],{results:r,scannedFiles:s}=await ma(t,{recursive:e.recursive!==!1,ignorePaths:o});if(s.length===0)console.log(`
|
|
13
13
|
No .stx files matched ${t}
|
|
@@ -69,7 +69,7 @@ Total: ${i} issues in ${c} files`),e.output){let l=`
|
|
|
69
69
|
File not found: ${t}`),n.exit(1);if(!t.endsWith(".stx"))console.error(`
|
|
70
70
|
File must have .stx extension: ${t}`),n.exit(1)}let r=p.resolve(e.pages),s=p.resolve(e.out);if(!t&&!S.existsSync(r))console.error(`
|
|
71
71
|
Pages directory not found: ${r}`),console.log(`
|
|
72
|
-
Create a 'pages' directory with .stx files, or use --pages to specify a different directory.`),n.exit(1);let{buildApp:c}=await import("./chunk-
|
|
72
|
+
Create a 'pages' directory with .stx files, or use --pages to specify a different directory.`),n.exit(1);let{buildApp:c}=await import("./chunk-qq1k3364.js");Kt();let i=await c({root:t?p.dirname(t):void 0,debug:e.verbose,ssg:{pagesDir:e.pages,outputDir:e.out,domain:e.domain,baseUrl:e.base,sitemap:e.sitemap,rss:e.rss,minify:e.minify,cache:e.cache!==!1,cleanOutput:e.clean,concurrency:Number.parseInt(e.concurrency,10)||10,publicDir:e.public,trailingSlash:e.trailingSlash,generate404:!0,hooks:e.verbose?{onPageStart:(d)=>console.log(` Generating: ${d}`),onPageEnd:(d,a)=>console.log(` Generated: ${d} (${a.length} bytes)`),onError:(d,a)=>console.error(` Error in ${a}: ${d.message}`)}:void 0},ssr:{outputDir:e.out==="dist"?".output":e.out,debug:e.verbose}}),l=((performance.now()-o)/1000).toFixed(2);if(i.mode==="ssr"&&i.ssr)console.log(`
|
|
73
73
|
Build complete! (SSR)
|
|
74
74
|
`),console.log(` Pages compiled: ${i.ssr.pageCount}`),console.log(` Output: ${i.ssr.outputDir}`),console.log(` Duration: ${l}s
|
|
75
75
|
`);else if(i.ssg){if(console.log(`
|
|
@@ -84,7 +84,7 @@ Total: ${i} issues in ${c} files`),e.output){let l=`
|
|
|
84
84
|
Build completed with ${i.ssg.failedCount} error(s). Fix the issues above and try again.
|
|
85
85
|
`),n.exit(1);console.log(" To preview locally:"),console.log(` cd ${e.out||"dist"} && npx serve
|
|
86
86
|
`)}}catch(o){console.error(`
|
|
87
|
-
Build failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("start","Start the production server (serves pre-built .output/)").option("--port <number>","Server port",{default:"3000"}).option("--output <dir>","Output directory from stx build",{default:".output"}).example("stx start").example("stx start --port 8080").action(async(t)=>{try{let e=p.resolve(t.output);if(!S.existsSync(p.join(e,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),n.exit(1);let{startProductionServer:o}=await import("./chunk-
|
|
87
|
+
Build failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("start","Start the production server (serves pre-built .output/)").option("--port <number>","Server port",{default:"3000"}).option("--output <dir>","Output directory from stx build",{default:".output"}).example("stx start").example("stx start --port 8080").action(async(t)=>{try{let e=p.resolve(t.output);if(!S.existsSync(p.join(e,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),n.exit(1);let{startProductionServer:o}=await import("./chunk-z8j2sbnb.js");await o({outputDir:e,port:Number.parseInt(t.port,10)||3000})}catch(e){console.error(`
|
|
88
88
|
Failed to start production server:`,e instanceof Error?e.message:String(e)),n.exit(1)}}),y.command("deploy [directory]","Deploy built site to Netlify").option("--site-id <id>","Netlify site ID (or set NETLIFY_SITE_ID env var)").option("--token <token>","Auth token (or set NETLIFY_AUTH_TOKEN env var)").option("--production","Deploy to production (default: draft preview)").option("--message <msg>","Deploy message/title").option("--no-build","Skip build step before deploy").option("--open","Open deployed URL in browser").option("--dry-run","Preview deployment without uploading").option("--init","Initialize Netlify configuration for this project").example("stx deploy").example("stx deploy --production").example("stx deploy dist --site-id my-site-abc123").example("stx deploy --init").example("stx deploy --dry-run").action(async(t,e)=>{try{let{deploy:o,initNetlify:r,DeployError:s}=await import("./chunk-bdg0fydw.js");if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${Re}\x1B[0m`),e.init){console.log(`
|
|
89
89
|
\uD83D\uDCDD Initializing Netlify configuration...
|
|
90
90
|
`);let i=await r({directory:t||n.cwd(),siteId:e.siteId});if(console.log(`\u2713 Created ${i.configPath}`),i.siteId)console.log("\u2713 Saved site ID to .env.local");console.log(`
|
|
@@ -124,7 +124,7 @@ To view it in the development server:`),console.log(` stx dev ${t}
|
|
|
124
124
|
\uD83D\uDCDD ${p.relative(n.cwd(),a)}:`),console.log("--- Original"),console.log("+++ Formatted"),console.log(`@@ Changes in ${p.basename(a)} @@`),console.log("+ Formatted content would be applied");else await Bun.write(a,b),console.log(`\u2705 Formatted ${p.relative(n.cwd(),a)}`),l++}catch(u){console.error(`\u274C Error formatting ${p.relative(n.cwd(),a)}:`,u),d++}if(e.check&&d>0)console.log(`
|
|
125
125
|
${d} files need formatting. Run 'stx format' to fix.`),n.exit(1);else if(!e.check&&!e.diff)console.log(`\u2728 Formatted ${l} files successfully`)}catch(o){console.error("Error formatting files:",o),n.exit(1)}}),y.command("perf [command...]","Show performance statistics for STX operations").option("--clear","Clear performance statistics").option("--json","Output as JSON").example("stx perf").example("stx perf --clear").example("stx perf --json").action(async(t,e)=>{try{if(e.clear){te.clear(),console.log("\u2705 Performance statistics cleared");return}let o=te.getStats();if(Object.keys(o).length===0){if(e.json){console.log(JSON.stringify({},null,2));return}console.log("No performance data available. Run some STX commands first.");return}if(e.json)console.log(JSON.stringify(o,null,2));else{console.log(`
|
|
126
126
|
\uD83D\uDCCA STX Performance Statistics
|
|
127
|
-
`);for(let[r,s]of Object.entries(o))console.log(`\uD83D\uDD27 ${r}:`),console.log(` Count: ${s.count}`),console.log(` Average: ${s.avgTime.toFixed(2)}ms`),console.log(` Total: ${s.totalTime.toFixed(2)}ms`),console.log(` Min: ${s.minTime.toFixed(2)}ms`),console.log(` Max: ${s.maxTime.toFixed(2)}ms`),console.log("")}}catch(o){console.error("Error showing performance stats:",o),n.exit(1)}}),y.command("typecheck [patterns...]","Type-check the TypeScript inside .stx script blocks").option("--no-client","Skip <script client> and bare <script> blocks").option("--no-server","Skip <script server> blocks").option("--no-templates","Skip {{ }} and directive expressions in the markup").option("--lib <path>","Extra ambient declaration file (repeatable)").example("stx typecheck").example('stx typecheck "resources/views/**/*.stx"').action(async(t,e)=>{let{formatTypecheckDiagnostics:o,typecheckStxFiles:r}=await import("./chunk-
|
|
127
|
+
`);for(let[r,s]of Object.entries(o))console.log(`\uD83D\uDD27 ${r}:`),console.log(` Count: ${s.count}`),console.log(` Average: ${s.avgTime.toFixed(2)}ms`),console.log(` Total: ${s.totalTime.toFixed(2)}ms`),console.log(` Min: ${s.minTime.toFixed(2)}ms`),console.log(` Max: ${s.maxTime.toFixed(2)}ms`),console.log("")}}catch(o){console.error("Error showing performance stats:",o),n.exit(1)}}),y.command("typecheck [patterns...]","Type-check the TypeScript inside .stx script blocks").option("--no-client","Skip <script client> and bare <script> blocks").option("--no-server","Skip <script server> blocks").option("--no-templates","Skip {{ }} and directive expressions in the markup").option("--lib <path>","Extra ambient declaration file (repeatable)").example("stx typecheck").example('stx typecheck "resources/views/**/*.stx"').action(async(t,e)=>{let{formatTypecheckDiagnostics:o,typecheckStxFiles:r}=await import("./chunk-17yfcd5s.js"),{resolveStxTargets:s}=await import("./chunk-52gp2xxk.js"),c=Array.isArray(t)?t:t?[t]:[],i=c.length?c:["**/*.stx"],l=await s(i);if(l.length===0){console.log(`
|
|
128
128
|
No .stx files matched ${i.join(", ")}
|
|
129
129
|
`);return}let d=di(n.argv,"--lib"),a=d.length>0?d:e.lib?Array.isArray(e.lib)?e.lib:[e.lib]:[],u=await r(l,{client:e.client!==!1,server:e.server!==!1,templates:e.templates!==!1,extraLibs:a});if(u.failure)console.error(`
|
|
130
130
|
Type-check did not run.
|
|
@@ -160,11 +160,11 @@ Press Ctrl+C to stop watching...
|
|
|
160
160
|
\uD83D\uDCC4 Files with issues:`),d.forEach((a)=>{let u=a.issues.filter((g)=>s[g.type]>=c).length;if(u>0)console.log(` ${p.relative(n.cwd(),a.file)} (${u} issues)`)});if(e.saveReport){let a={summary:l,results:d,generatedAt:new Date().toISOString(),commandOptions:e};await Bun.write(e.saveReport,JSON.stringify(a,null,2)),console.log(`
|
|
161
161
|
\uD83D\uDCCB Analysis report saved to: ${e.saveReport}`)}console.log(`
|
|
162
162
|
\u2728 Analysis complete! Use --detailed for more information.`)}catch(o){console.error("Error analyzing templates:",o),n.exit(1)}}),y.command("screenshot [input]","Capture PNG screenshot(s) of page(s) via Bun WebView \u2014 a file, URL, or dist directory").option("--out <dir>","Output directory",{default:"screenshots"}).option("--width <px>","Viewport width",{default:"1440"}).option("--height <px>","Viewport height",{default:"2200"}).option("--wait <ms>","Settle time after navigation before capture",{default:"800"}).option("--timeout <ms>","Hard cap on waiting for navigation",{default:"15000"}).option("--full-page","Capture the entire scrollable page, not just the viewport").option("--wait-selector <sel>","Wait until a CSS selector exists before capturing").option("--format <fmt>","Image format: png | jpeg | webp",{default:"png"}).option("--backend <name>","WebView backend: webkit (macOS, default) | chrome").action(async(t,e)=>{let{captureScreenshots:o}=await import("./chunk-jk41jwsc.js"),r=t||"dist";try{let s=await o(r,e.out,{width:Number.parseInt(e.width,10),height:Number.parseInt(e.height,10),waitMs:Number.parseInt(e.wait,10),timeoutMs:Number.parseInt(e.timeout,10),fullPage:Boolean(e.fullPage),waitSelector:e.waitSelector,format:e.format,backend:e.backend});for(let c of s)console.log(`\uD83D\uDCF8 ${c.output} (${(c.bytes/1024).toFixed(0)} KB)`);console.log(`
|
|
163
|
-
\u2728 Captured ${s.length} screenshot(s) to ${e.out}/ via Bun WebView`)}catch(s){console.error(`Screenshot failed: ${s.message}`),n.exit(1)}}),y.command("version","Show the version of the CLI").action(()=>{console.log(Re)}),y.command("interactive","Start interactive REPL mode for template development").alias("i").option("--context <file>","Load initial context from JSON file").option("--cwd <directory>","Set working directory").option("--verbose","Show verbose output").action(async(t)=>{let{startInteractive:e}=await import("./chunk-
|
|
163
|
+
\u2728 Captured ${s.length} screenshot(s) to ${e.out}/ via Bun WebView`)}catch(s){console.error(`Screenshot failed: ${s.message}`),n.exit(1)}}),y.command("version","Show the version of the CLI").action(()=>{console.log(Re)}),y.command("interactive","Start interactive REPL mode for template development").alias("i").option("--context <file>","Load initial context from JSON file").option("--cwd <directory>","Set working directory").option("--verbose","Show verbose output").action(async(t)=>{let{startInteractive:e}=await import("./chunk-0dcrd58z.js"),o={};if(t.context){let r=p.resolve(t.context);if(S.existsSync(r))try{let s=S.readFileSync(r,"utf-8");o=JSON.parse(s)}catch(s){console.error("Error loading context file:",s),n.exit(1)}else console.error(`Context file not found: ${r}`),n.exit(1)}await e({context:o,cwd:t.cwd?p.resolve(t.cwd):n.cwd(),verbose:t.verbose})}),y.command("build:native <input>","Build stx template into a native desktop/mobile app").option("--output <dir>","Output directory",{default:"dist/native"}).option("--target <platform>","Target platform: macos, windows, linux, ios, android").option("--format <format>","Output format: app, dmg, pkg, msi, zip, deb, rpm, appimage, ipa, apk").option("--name <name>","Application name (defaults to filename)").option("--version <version>","Application version",{default:"1.0.0"}).option("--description <desc>","Application description").option("--author <author>","Author/Maintainer name").option("--bundle-id <id>","Bundle identifier (macOS/iOS)").option("--icon <path>","Path to application icon").option("--width <width>","Window width",{default:"1200"}).option("--height <height>","Window height",{default:"800"}).option("--title <title>","Window title").option("--system-tray","Enable system tray/menubar mode").option("--menubar-only","Run without a dock icon (implied by --system-tray)").option("--category <type>","LSApplicationCategoryType (macOS)").option("--copyright <text>","NSHumanReadableCopyright (macOS)").option("--min-system-version <v>","LSMinimumSystemVersion (macOS)").option("--info-plist <json>","Extra Info.plist keys as a JSON object (macOS)").option("--dev-tools","Enable developer tools").option("--frameless","Create frameless window").option("--always-on-top","Keep window always on top").option("--craft-path <path>","Path to Craft binary").option("--verbose","Show verbose output").example("stx build:native app.stx --target macos").example("stx build:native app.stx --target macos --format dmg").example("stx build:native app.stx --target linux --format appimage").example('stx build:native app.stx --name "My App" --icon icon.png').action(async(t,e)=>{try{let{buildNative:o,getAvailableTargets:r,getAvailableFormats:s}=await import("./chunk-4ve8vsw5.js"),c=p.resolve(t);if(!S.existsSync(c))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let i=r();if(e.target&&!["macos","windows","linux","ios","android"].includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error("\uD83D\uDCA1 Available targets: macos, windows, linux, ios, android"),console.error(`\uD83D\uDCA1 Targets available on this machine: ${i.join(", ")}`),n.exit(1);let l=e.target||i[0],d=s(l);if(e.format&&!d.includes(e.format))console.error(`\u274C Invalid format for ${l}: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${d.join(", ")}`),n.exit(1);console.log(`
|
|
164
164
|
\uD83D\uDD28 Building native app...`),console.log(` Input: ${t}`),console.log(` Target: ${l}`),console.log(` Format: ${e.format||"default"}`),console.log(` Output: ${e.output}
|
|
165
165
|
`);let a=await o({input:c,output:p.resolve(e.output),target:l,format:e.format,name:e.name,version:e.version,description:e.description,author:e.author,bundleId:e.bundleId,icon:e.icon?p.resolve(e.icon):void 0,window:{title:e.title,width:Number.parseInt(e.width,10),height:Number.parseInt(e.height,10),frameless:e.frameless,alwaysOnTop:e.alwaysOnTop},systemTray:e.systemTray,menubarOnly:e.menubarOnly,category:e.category,copyright:e.copyright,minimumSystemVersion:e.minSystemVersion,infoPlist:M(e.infoPlist),devTools:e.devTools,craftPath:e.craftPath,verbose:e.verbose});if(a.success){if(console.log("\u2705 Build successful!"),console.log(` Output: ${a.outputPath}`),a.duration)console.log(` Duration: ${(a.duration/1000).toFixed(2)}s`);if(l==="macos"&&a.format==="app")console.log(`
|
|
166
166
|
\uD83D\uDCA1 To run: open "${a.outputPath}"`);else if(l==="linux"&&a.format==="appimage")console.log(`
|
|
167
|
-
\uD83D\uDCA1 To run: chmod +x "${a.outputPath}" && "${a.outputPath}"`)}else console.error(`\u274C Build failed: ${a.error}`),n.exit(1)}catch(o){console.error(`\u274C Build error: ${o.message}`),n.exit(1)}}),y.command("story","Start component showcase and testing server").option("-p, --port <port>","Server port",{default:"6006"}).option("-o, --open","Open browser automatically",{default:!1}).option("--host <host>","Host to bind to",{default:"localhost"}).example("stx story").example("stx story --port 3000 --open").action(async(t)=>{try{let{devCommand:e}=await import("./chunk-
|
|
167
|
+
\uD83D\uDCA1 To run: chmod +x "${a.outputPath}" && "${a.outputPath}"`)}else console.error(`\u274C Build failed: ${a.error}`),n.exit(1)}catch(o){console.error(`\u274C Build error: ${o.message}`),n.exit(1)}}),y.command("story","Start component showcase and testing server").option("-p, --port <port>","Server port",{default:"6006"}).option("-o, --open","Open browser automatically",{default:!1}).option("--host <host>","Host to bind to",{default:"localhost"}).example("stx story").example("stx story --port 3000 --open").action(async(t)=>{try{let{devCommand:e}=await import("./chunk-s20h5gmr.js");await e({port:t.port?Number.parseInt(t.port,10):6006,open:t.open,host:t.host})}catch(e){console.error(`\u274C Story error: ${e.message}`),n.exit(1)}}),y.command("story:build","Build static story site").option("-o, --outDir <dir>","Output directory",{default:".stx/dist/story"}).example("stx story:build").example("stx story:build --outDir ./docs/components").action(async(t)=>{try{let{buildCommand:e}=await import("./chunk-b4pcw34n.js");await e({outDir:t.outDir})}catch(e){console.error(`\u274C Story build error: ${e.message}`),n.exit(1)}}),y.command("story:test","Run visual regression tests").option("-u, --update","Update snapshots",{default:!1}).option("-f, --filter <name>","Filter components by name").example("stx story:test").example("stx story:test --update").example("stx story:test --filter Button").action(async(t)=>{try{let{createContext:e}=await import("./chunk-1e79xcc8.js"),{runVisualTests:o,updateSnapshots:r,formatTestResults:s}=await import("./chunk-ttbn287w.js"),c=await e({mode:"build"});if(t.update){let i=await r(c,{filter:t.filter?[t.filter]:void 0});console.log(`Updated ${i} snapshots`)}else{let i=await o(c,{filter:t.filter?[t.filter]:void 0});if(console.log(s(i)),i.failed>0)n.exit(1)}}catch(e){console.error(`\u274C Story test error: ${e.message}`),n.exit(1)}}),y.command("native <action> [file]","Compile .stx screens into the JavaScriptCore bundle Craft renders natively").option("--format <format>","bundle (the JavaScriptCore bundle) or ir (the template as JSON)",{default:"ir"}).option("--output <path>","Write to this file instead of stdout").option("--minify","Minify the bundle",{default:!1}).option("--config <file>","Screens config (default: native.config.json in the working directory)").example("stx native compile Screen.stx --format bundle --output native-screen.js").example("stx native compile --format bundle --output native-screen.js --minify").example("stx native compile Screen.stx").action(async(t,e,o)=>{if(t!=="compile")console.error(`Unknown native command: ${t}`),console.error("Usage: stx native compile [file.stx] --format bundle|ir [--output <file>] [--minify] [--config <file>]"),n.exit(1);try{let{runNativeCompile:r}=await import("./chunk-n3m7fkv1.js"),s=await r(e,{format:o.format,output:o.output,minify:Boolean(o.minify),config:o.config});for(let c of s.diagnostics)console.warn(`${c.level}: ${c.message}`);if(s.written)console.log(`Compiled: ${e??"screens"} \u2192 ${p.relative(n.cwd(),s.written)||s.written}`);else console.log(s.output)}catch(r){console.error(r instanceof Error?r.message:String(r)),n.exit(1)}}),y.command("compile <input>","Compile stx template to native Craft component code").option("--target <platform>","Target platform: macos, windows, linux, ios, android, universal",{default:"universal"}).option("--format <format>","Output format: zig, typescript, json",{default:"zig"}).option("--output <path>","Output directory for compiled files",{default:"./dist"}).option("--optimize","Enable optimizations",{default:!0}).option("--tree-shake","Enable tree shaking",{default:!0}).option("--hot-reload","Enable hot reload support",{default:!1}).option("--sourcemaps","Generate source maps",{default:!1}).option("--bundle","Bundle all dependencies",{default:!0}).option("--minify","Minify output",{default:!1}).option("--verbose","Show detailed output",{default:!1}).example("stx compile app.stx").example("stx compile app.stx --target macos --format zig").example("stx compile app.stx --format typescript --output ./native").example("stx compile app.stx --optimize --tree-shake --minify").action(async(t,e)=>{try{let{compileToNative:o}=await import("./chunk-g2jmwh7p.js"),r=p.resolve(t);if(!S.existsSync(r))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let s=["macos","windows","linux","ios","android","universal"];if(!s.includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error(`\uD83D\uDCA1 Available targets: ${s.join(", ")}`),n.exit(1);let c=["zig","typescript","json"];if(!c.includes(e.format))console.error(`\u274C Invalid format: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${c.join(", ")}`),n.exit(1);console.log(`
|
|
168
168
|
\uD83D\uDD27 Compiling stx template to native code...`),console.log(` Input: ${t}`),console.log(` Target: ${e.target}`),console.log(` Format: ${e.format}`),console.log(` Output: ${e.output}
|
|
169
169
|
`);let i=S.readFileSync(r,"utf-8"),l=await o(i,{target:e.target,format:e.format,optimize:e.optimize,treeShake:e.treeShake,hotReload:e.hotReload,debug:e.verbose,sourceMaps:e.sourcemaps,bundle:e.bundle,minify:e.minify}),d=p.resolve(e.output);if(!S.existsSync(d))S.mkdirSync(d,{recursive:!0});let a=p.basename(t,p.extname(t)),u=e.format==="typescript"?"ts":e.format==="json"?"json":"zig",g=p.join(d,`${a}.${u}`);S.writeFileSync(g,l.code);let b=p.join(d,`${a}.manifest.json`);if(S.writeFileSync(b,JSON.stringify(l.manifest,null,2)),e.sourcemaps&&l.sourceMaps){let w=p.join(d,`${a}.${u}.map`);S.writeFileSync(w,l.sourceMaps)}if(e.target==="universal"&&l.platformCode.size>0)for(let[w,k]of l.platformCode){let v=p.join(d,`${a}.${w}.${u}`);S.writeFileSync(v,k)}if(console.log("\u2705 Compilation successful!"),console.log(` Output: ${g}`),console.log(` Manifest: ${b}`),console.log(`
|
|
170
170
|
\uD83D\uDCCA Statistics:`),console.log(` Compilation time: ${l.stats.compilationTime.toFixed(2)}ms`),console.log(` Total components: ${l.stats.totalComponents}`),console.log(` Native components: ${l.stats.nativeComponents}`),console.log(` Web fallback components: ${l.stats.webComponents}`),console.log(` Bundle size: ${(l.stats.bundleSize/1024).toFixed(2)}KB`),l.stats.warnings.length>0){console.log(`
|
package/dist/craft-entry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ws,qi,Gi}from"./chunk-120ze5ms.js";import"./chunk-2dp7hyv7.js";import"./chunk-pxdww4rb.js";import"./chunk-ce6zddpf.js";import"./chunk-
|
|
2
|
+
import{Ws,qi,Gi}from"./chunk-120ze5ms.js";import"./chunk-2dp7hyv7.js";import"./chunk-pxdww4rb.js";import"./chunk-ce6zddpf.js";import"./chunk-kwek8xdt.js";import"./chunk-1sr6c0nk.js";import"./chunk-pvb48ehs.js";import"./chunk-a3d0g4mr.js";import"./chunk-365vg0eg.js";import"./chunk-9gfffs28.js";import"./chunk-fzqj1mjz.js";import"./chunk-04kg16qs.js";import"./chunk-6xe8rnfv.js";import"./chunk-8k3rwv8r.js";import"./chunk-mjm3tyfj.js";import"./chunk-9yxgdy4z.js";import"./chunk-1mj9crcg.js";import"./chunk-a95r5nmq.js";import"./chunk-sjcqxfq1.js";import"./chunk-prf164ct.js";import"./chunk-yfvm7q6t.js";import{Xd,ji,Jd,Yd,Bi,Us,Fi,Zd,zi,Qd,ep,Hi,Vi,Ui,Wi}from"./chunk-3349573p.js";import"./chunk-t9yqq483.js";import"./chunk-ka8befem.js";import"./chunk-wankp78x.js";import"./chunk-p472crv1.js";import"./chunk-a5zqqgx2.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
|
|
3
3
|
`),scripts:t.scripts.join(`
|
|
4
4
|
`),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
|
|
5
5
|
`),scripts:t.scripts.join(`
|
package/dist/craft.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ws,qi,Gi}from"./chunk-120ze5ms.js";import"./chunk-2dp7hyv7.js";import"./chunk-pxdww4rb.js";import"./chunk-ce6zddpf.js";import"./chunk-
|
|
2
|
+
import{Ws,qi,Gi}from"./chunk-120ze5ms.js";import"./chunk-2dp7hyv7.js";import"./chunk-pxdww4rb.js";import"./chunk-ce6zddpf.js";import"./chunk-kwek8xdt.js";import"./chunk-1sr6c0nk.js";import"./chunk-pvb48ehs.js";import"./chunk-a3d0g4mr.js";import"./chunk-365vg0eg.js";import"./chunk-9gfffs28.js";import"./chunk-fzqj1mjz.js";import"./chunk-04kg16qs.js";import"./chunk-6xe8rnfv.js";import"./chunk-8k3rwv8r.js";import"./chunk-mjm3tyfj.js";import"./chunk-9yxgdy4z.js";import"./chunk-1mj9crcg.js";import"./chunk-a95r5nmq.js";import"./chunk-sjcqxfq1.js";import"./chunk-prf164ct.js";import"./chunk-yfvm7q6t.js";import{Xd,ji,Jd,Yd,Bi,Us,Fi,Zd,zi,Qd,ep,Hi,Vi,Ui,Wi}from"./chunk-3349573p.js";import"./chunk-t9yqq483.js";import"./chunk-ka8befem.js";import"./chunk-wankp78x.js";import"./chunk-p472crv1.js";import"./chunk-a5zqqgx2.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
|
|
3
3
|
`),scripts:t.scripts.join(`
|
|
4
4
|
`),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
|
|
5
5
|
`),scripts:t.scripts.join(`
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BunPlugin } from 'bun';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve client imports before starting Bun's outer native build. Server
|
|
4
|
+
* rendering and signal hydration remain runtime operations, so each popup
|
|
5
|
+
* opens with fresh preferences. Every embedded template must be listed.
|
|
6
|
+
*/
|
|
7
|
+
export declare function menuBarTemplatePlugin(options: {
|
|
8
|
+
templates: string[]
|
|
9
|
+
projectRoot?: string
|
|
10
|
+
}): Promise<BunPlugin>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { extractAndStripCssImports, renderVendorStyleTags } from "./client-script.js";
|
|
4
|
+
import { bundleClientScript, hasUserImports } from "./client-script-bundler.js";
|
|
5
|
+
import { scanScriptTags } from "./signal-processing.js";
|
|
6
|
+
export async function menuBarTemplatePlugin(options) {
|
|
7
|
+
const templates = new Map;
|
|
8
|
+
for (const template of options.templates) {
|
|
9
|
+
const path = realpathSync(resolve(template));
|
|
10
|
+
let source = await Bun.file(path).text();
|
|
11
|
+
const scripts = scanScriptTags(source, {
|
|
12
|
+
skipAttrs: /\bserver\b|\bsrc\s*=|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/
|
|
13
|
+
});
|
|
14
|
+
for (const script of scripts.reverse()) {
|
|
15
|
+
const css = extractAndStripCssImports(script.body, { filePath: path, projectRoot: options.projectRoot || process.cwd() }), imported = hasUserImports(css.code);
|
|
16
|
+
if (!imported && css.styles.length === 0)
|
|
17
|
+
continue;
|
|
18
|
+
const transpiler = new Bun.Transpiler({ loader: "ts", target: "browser" }), code = imported ? await bundleClientScript(transpiler.transformSync(css.code), path, {
|
|
19
|
+
projectRoot: options.projectRoot || process.cwd(),
|
|
20
|
+
externalizeUserModules: !1,
|
|
21
|
+
throwOnFailure: !0
|
|
22
|
+
}) : css.code, replacement = `${renderVendorStyleTags(css.styles)}<script${script.attrs}>${code.replace(/<\/script/gi, "<\\/script")}</script>`;
|
|
23
|
+
source = source.slice(0, script.start) + replacement + source.slice(script.end);
|
|
24
|
+
}
|
|
25
|
+
templates.set(path, source);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
name: "stx-menubar-template",
|
|
29
|
+
setup(build) {
|
|
30
|
+
build.onLoad({ filter: /\.stx$/ }, ({ path }) => {
|
|
31
|
+
const contents = templates.get(path);
|
|
32
|
+
if (contents === void 0)
|
|
33
|
+
throw Error(`Embedded template was not prepared: ${path}`);
|
|
34
|
+
return { contents, loader: "text" };
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -13,8 +13,10 @@ export declare function nativePaletteColor(reference: string): string | undefine
|
|
|
13
13
|
* `focus:` is opt-in for hosts that report it (currently TextInput). Other
|
|
14
14
|
* variants remain diagnostic, including focus-visible: focus alone does not
|
|
15
15
|
* establish keyboard modality. Unsupported rings are never faked as borders.
|
|
16
|
+
* With `appearance`, semantic token defaults are resolved in the ordinary
|
|
17
|
+
* style, leaving `dark` for selectors with explicit appearance specificity.
|
|
16
18
|
*/
|
|
17
|
-
export declare function compileClassStyles(classes: string, variables?: NativeStyleVariables, options?: { focus?: boolean, focusWithin?: boolean, rules?: NativeStylesheetRules }): ClassStyles;
|
|
19
|
+
export declare function compileClassStyles(classes: string, variables?: NativeStyleVariables, options?: { focus?: boolean, focusWithin?: boolean, rules?: NativeStylesheetRules, appearance?: 'light' | 'dark' }): ClassStyles;
|
|
18
20
|
export declare function compileHeadwindToStyle(classes: string | string[], unknown?: string[]): STXStyle;
|
|
19
21
|
/**
|
|
20
22
|
* ============================================================================
|
|
@@ -431,6 +431,10 @@ const classParsers = {
|
|
|
431
431
|
style.display = "flex";
|
|
432
432
|
return !0;
|
|
433
433
|
},
|
|
434
|
+
block: (_, style) => {
|
|
435
|
+
style.display = "flex";
|
|
436
|
+
return !0;
|
|
437
|
+
},
|
|
434
438
|
hidden: (_, style) => {
|
|
435
439
|
style.display = "none";
|
|
436
440
|
return !0;
|
|
@@ -679,7 +683,6 @@ const classParsers = {
|
|
|
679
683
|
return !0;
|
|
680
684
|
},
|
|
681
685
|
"tabular-nums": () => !0,
|
|
682
|
-
block: () => !0,
|
|
683
686
|
"inline-flex": (_, style) => {
|
|
684
687
|
style.display = "flex";
|
|
685
688
|
return !0;
|
|
@@ -1385,7 +1388,7 @@ export function compileClassStyles(classes, variables, options = {}) {
|
|
|
1385
1388
|
for (const layer of groups.values()) {
|
|
1386
1389
|
if (layer === base)
|
|
1387
1390
|
continue;
|
|
1388
|
-
const compiled = compileLayer(layer.classes.join(" "), variables);
|
|
1391
|
+
const compiled = compileLayer(layer.classes.join(" "), variables, { appearance: options.appearance });
|
|
1389
1392
|
result.unknown = [...new Set([...result.unknown, ...authoredNames(layer, compiled.unknown)])];
|
|
1390
1393
|
const entry = { style: compiled.style, ...compiled.dark ? { dark: compiled.dark } : {} };
|
|
1391
1394
|
if (layer.disabled)
|
|
@@ -1474,7 +1477,7 @@ function compileLayer(classes, variables, options = {}) {
|
|
|
1474
1477
|
else
|
|
1475
1478
|
dark.push(...translated.map((value) => remember(value, name)));
|
|
1476
1479
|
} else if (!name.includes(":") || name.startsWith("[")) {
|
|
1477
|
-
const lightClasses = roleClasses(name, "light"), darkClasses = roleClasses(name, "dark");
|
|
1480
|
+
const lightClasses = roleClasses(name, options.appearance ?? "light"), darkClasses = roleClasses(name, "dark");
|
|
1478
1481
|
if (!lightClasses || !darkClasses) {
|
|
1479
1482
|
unsupported.push(name);
|
|
1480
1483
|
continue;
|
|
@@ -1485,9 +1488,9 @@ function compileLayer(classes, variables, options = {}) {
|
|
|
1485
1488
|
} else
|
|
1486
1489
|
unsupported.push(name);
|
|
1487
1490
|
}
|
|
1488
|
-
const unknown = [], style = compileHeadwindToStyle(plain, unknown), result = { style, unknown };
|
|
1489
|
-
if (
|
|
1490
|
-
result.dark = compileHeadwindToStyle(
|
|
1491
|
+
const unknown = [], style = compileHeadwindToStyle(plain, unknown), result = { style, unknown }, darkClasses = [...options.appearance === void 0 ? semanticDark : [], ...dark];
|
|
1492
|
+
if (darkClasses.length)
|
|
1493
|
+
result.dark = compileHeadwindToStyle(darkClasses, unknown);
|
|
1491
1494
|
if (style.transform && result.dark?.transform) {
|
|
1492
1495
|
const overridden = new Set(result.dark.transform.flatMap((step) => Object.keys(step)));
|
|
1493
1496
|
result.dark.transform = [...style.transform.filter((step) => !Object.keys(step).some((key) => overridden.has(key))), ...result.dark.transform];
|
|
@@ -1507,7 +1510,7 @@ function compileLayer(classes, variables, options = {}) {
|
|
|
1507
1510
|
const authoredUnknown = unknown.flatMap((name) => [...originals.get(name) ?? [name]]);
|
|
1508
1511
|
result.unknown = [...new Set([...authoredUnknown.filter((name) => !/^line-clamp-\d+$/.test(name)), ...unsupported])];
|
|
1509
1512
|
if (dividers.length) {
|
|
1510
|
-
const divided = compileLayer(dividers.join(" "), variables);
|
|
1513
|
+
const divided = compileLayer(dividers.join(" "), variables, { appearance: options.appearance });
|
|
1511
1514
|
result.divide = { style: divided.style, ...divided.dark ? { dark: divided.dark } : {} };
|
|
1512
1515
|
result.unknown = [...new Set([...result.unknown, ...divided.unknown.map((name) => dividerOriginals.get(name) ?? name)])];
|
|
1513
1516
|
}
|
|
@@ -1515,7 +1518,7 @@ function compileLayer(classes, variables, options = {}) {
|
|
|
1515
1518
|
const layer = focusLayers[key];
|
|
1516
1519
|
if (!layer.classes.length)
|
|
1517
1520
|
continue;
|
|
1518
|
-
const focused = compileLayer(layer.classes.join(" "), variables);
|
|
1521
|
+
const focused = compileLayer(layer.classes.join(" "), variables, { appearance: options.appearance });
|
|
1519
1522
|
result[key] = { style: focused.style, dark: focused.dark };
|
|
1520
1523
|
result.unknown = [...new Set([...result.unknown, ...focused.unknown.flatMap((name) => layer.originals.get(name) ?? [name])])];
|
|
1521
1524
|
for (const name of layer.classes)
|