@stacksjs/stx 0.2.883 → 0.2.885
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-rw5sxr5a.js → chunk-0gkxqcpj.js} +1 -1
- package/dist/chunk-1dhdt31n.js +2 -0
- package/dist/chunk-2mn0w25t.js +2 -0
- package/dist/chunk-2mxqchs1.js +2 -0
- package/dist/{chunk-26yzqev3.js → chunk-2n2102vf.js} +5 -5
- package/dist/{chunk-yaenczev.js → chunk-2v0pcxqs.js} +4 -4
- package/dist/{chunk-rxm46f9z.js → chunk-46cghgdm.js} +2 -2
- package/dist/chunk-4mw05zhy.js +2 -0
- package/dist/{chunk-se53e743.js → chunk-4n1ywp14.js} +1 -1
- package/dist/{chunk-8hc7mec0.js → chunk-4ryy2m8q.js} +3 -3
- package/dist/{chunk-ytbed3rp.js → chunk-5mmgdpjr.js} +6 -6
- package/dist/{chunk-w9zs57z0.js → chunk-5p6xtzkk.js} +1 -1
- package/dist/{chunk-sqjv4kxc.js → chunk-5xhaabn0.js} +1 -1
- package/dist/{chunk-9y2n8wm6.js → chunk-63y8exx2.js} +1 -1
- package/dist/chunk-6cbxs47h.js +2 -0
- package/dist/chunk-6gyy25fz.js +2 -0
- package/dist/{chunk-vsraamv3.js → chunk-6nvm1dgn.js} +1 -1
- package/dist/{chunk-x2a5phpm.js → chunk-72qdbhfh.js} +1 -1
- package/dist/{chunk-w7476ea6.js → chunk-7dtfkf1b.js} +1 -1
- package/dist/{chunk-32z3g0y1.js → chunk-84xnev80.js} +1 -1
- package/dist/{chunk-8a09r8xy.js → chunk-8an1mp1z.js} +4 -4
- package/dist/chunk-8hbzej4h.js +2 -0
- package/dist/chunk-8qkmgxkn.js +2 -0
- package/dist/chunk-8xh4ek56.js +182 -0
- package/dist/{chunk-tzmqvsmf.js → chunk-9cgwe3tb.js} +1 -1
- package/dist/{chunk-x8s9487t.js → chunk-aw6m1t68.js} +6 -6
- package/dist/{chunk-nb6erf75.js → chunk-c47stwqj.js} +1 -1
- package/dist/{chunk-21tx0mbz.js → chunk-c8pdjhxm.js} +1 -1
- package/dist/{chunk-av1acvah.js → chunk-ce1d71m1.js} +2 -2
- package/dist/{chunk-rk98082b.js → chunk-charhv8y.js} +1 -1
- package/dist/{chunk-htrptrn9.js → chunk-css5czqk.js} +1 -1
- package/dist/{chunk-cb2gzs3m.js → chunk-d9hsqh1w.js} +1 -1
- package/dist/chunk-e2d34r31.js +2 -0
- package/dist/{chunk-ykzwrxpn.js → chunk-eebxdb5z.js} +1 -1
- package/dist/chunk-eg3sxm03.js +2 -0
- package/dist/chunk-fdzpphww.js +2 -0
- package/dist/{chunk-4fkcn6z5.js → chunk-fg67643b.js} +1 -1
- package/dist/{chunk-3ahqdb2n.js → chunk-j5a3yrcf.js} +1 -1
- package/dist/{chunk-1r1kfskk.js → chunk-jbv448x5.js} +1 -1
- package/dist/chunk-k3s16azh.js +2 -0
- package/dist/{chunk-kyb5nyt8.js → chunk-kk92sv04.js} +5 -5
- package/dist/chunk-kpkjb7hy.js +2 -0
- package/dist/{chunk-a60ztvnp.js → chunk-kwf3kfr0.js} +1 -1
- package/dist/{chunk-7psdag9t.js → chunk-m321yrb2.js} +1 -1
- package/dist/{chunk-myfsnf67.js → chunk-m4f13mrp.js} +1 -1
- package/dist/{chunk-vz6dtfe9.js → chunk-mejhzan9.js} +1 -1
- package/dist/{chunk-x3py9q5v.js → chunk-mrjr0vtb.js} +21 -20
- package/dist/{chunk-00tq7ghn.js → chunk-n22xtagg.js} +2 -2
- package/dist/{chunk-gw6v6n8y.js → chunk-n63z5hbk.js} +3 -3
- package/dist/{chunk-ptg2karz.js → chunk-nxbws5qm.js} +4 -4
- package/dist/{chunk-r04j085h.js → chunk-p0rpdj1w.js} +1 -1
- package/dist/{chunk-tct0jrp1.js → chunk-p6e48m6t.js} +1 -1
- package/dist/{chunk-0f6k5r31.js → chunk-p6yavy8h.js} +3 -3
- package/dist/{chunk-rcxer2km.js → chunk-pc8dt8xs.js} +1 -1
- package/dist/{chunk-xynq9fcr.js → chunk-pk3pp1j5.js} +1 -1
- package/dist/chunk-qtbbc0h2.js +3 -0
- package/dist/chunk-qw6cyy5j.js +2 -0
- package/dist/{chunk-29btwpda.js → chunk-rtehrddv.js} +2 -2
- package/dist/{chunk-hnnargm3.js → chunk-t4v7pjnh.js} +1 -1
- package/dist/{chunk-e5kygw75.js → chunk-tng16znx.js} +1 -1
- package/dist/chunk-tzvapd0t.js +2 -0
- package/dist/{chunk-an4vtgem.js → chunk-v9wt6jx2.js} +2 -2
- package/dist/{chunk-dzpm2n8g.js → chunk-wh8yhpyh.js} +4 -4
- package/dist/chunk-wkcx67x4.js +2 -0
- package/dist/{chunk-yc9bpftb.js → chunk-ws3wfpy9.js} +1 -1
- package/dist/{chunk-90zpw7zw.js → chunk-xfxcchpt.js} +1 -1
- package/dist/chunk-xwwp2ftx.js +2 -0
- package/dist/{chunk-fk45k15v.js → chunk-y3v0r845.js} +10 -10
- package/dist/{chunk-24f59184.js → chunk-z2mvdnce.js} +1 -1
- package/dist/chunk-z5n2sjg2.js +2 -0
- package/dist/{chunk-yh2hnt3m.js → chunk-zpj6ggee.js} +2 -2
- package/dist/cli.js +9 -9
- package/dist/component-library.js +5 -2
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/compiler/bundle.js +19 -1
- package/dist/native/compiler/html-to-ir.d.ts +16 -0
- package/dist/native/compiler/html-to-ir.js +23 -1
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +6 -6
- package/dist/types/component-types.d.ts +2 -0
- package/package.json +5 -5
- package/dist/chunk-0fmrrsbp.js +0 -2
- package/dist/chunk-0rc5tg89.js +0 -2
- package/dist/chunk-2d170z61.js +0 -2
- package/dist/chunk-3mepf96h.js +0 -2
- package/dist/chunk-6dq3qdg2.js +0 -2
- package/dist/chunk-7hf1xyrb.js +0 -2
- package/dist/chunk-8cnavhtr.js +0 -2
- package/dist/chunk-99956f90.js +0 -177
- package/dist/chunk-a6cwm61q.js +0 -2
- package/dist/chunk-a6mjqetx.js +0 -2
- package/dist/chunk-awywwbc5.js +0 -3
- package/dist/chunk-ckb8yk6a.js +0 -2
- package/dist/chunk-fb5vv2q5.js +0 -2
- package/dist/chunk-gc65patn.js +0 -2
- package/dist/chunk-jr61mjwn.js +0 -2
- package/dist/chunk-pnw1n18p.js +0 -2
- package/dist/chunk-rf5tatrc.js +0 -2
- package/dist/chunk-w2p9mhef.js +0 -2
- package/dist/chunk-wxa1w308.js +0 -2
- package/dist/chunk-xncrk7dz.js +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{fr,Fe}from"./chunk-9f31gs4m.js";import{G,S,Pr,Js,A}from"./chunk-x3py9q5v.js";import{a,L}from"./chunk-av1acvah.js";import{Yo}from"./chunk-vsraamv3.js";import{Z}from"./chunk-nb6erf75.js";import{ft}from"./chunk-6c1vm6bs.js";import{l}from"./chunk-s7xywsqd.js";import{t,C}from"./chunk-yh2hnt3m.js";import d from"path";import j from"fs";import{AsyncLocalStorage as lt}from"async_hooks";import{randomUUID as St}from"crypto";var vt=12;function X(e,n,s){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(e))||Yo(e,n,s)}var ct=2;function Kf(e){let n=process.env.STX_BUNDLE_CACHE_DIR?.trim();return n?d.resolve(n):l(e,"bundle-cache")}function rt(e,n){let s=e;for(let i of Bt(n))if(i!==d.sep)s=s.split(i).join("\x00root");return s}var it=new Map;function Bt(e){let n=d.resolve(e),s=it.get(n);if(!s){let i=n;try{i=j.realpathSync(n)}catch{}s=[...new Set([n,i])].sort((c,p)=>p.length-c.length),it.set(n,s)}return s}function jt(e,n){try{let s=j.statSync(e),i=d.resolve(n),c=e.startsWith(`${i}${d.sep}`);return{path:c?d.relative(i,e):e,...c?{inRoot:!0}:{},mtimeMs:s.mtimeMs,size:s.size,hash:Bun.hash(j.readFileSync(e)).toString(36)}}catch{return null}}function ut(e,n){return e.inRoot?d.join(d.resolve(n),e.path):e.path}function Et(e,n){for(let s of e){let i=ut(s,n);try{let c=j.statSync(i);if(c.size!==s.size)return!1;if(c.mtimeMs!==s.mtimeMs&&Bun.hash(j.readFileSync(i)).toString(36)!==s.hash)return!1}catch{return!1}}return!0}var dt=new Map,_t=100;function Gf(e=process.env){let n=Number(e.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(n)&&n>=1?Math.floor(n):2000}var q=new Map;async function Mt(e){let n=q.get(e)??0;if(n>0&&n<_t){q.set(e,n+1);return}q.set(e,1);try{let s=(await j.promises.readdir(e)).filter((o)=>o.endsWith(".js")),i=Gf();if(s.length<=i)return;let p=(await Promise.all(s.map(async(o)=>{try{return{name:o,at:(await j.promises.stat(d.join(e,o))).mtimeMs}}catch{return null}}))).filter((o)=>o!==null);p.sort((o,b)=>b.at-o.at);for(let o of p.slice(i)){let b=o.name.slice(0,-3);await j.promises.rm(d.join(e,`${b}.js`),{force:!0}),await j.promises.rm(d.join(e,`${b}.deps.json`),{force:!0})}N("pruned bundle cache to",i,"entries")}catch{}}function Ce(e){return dt.get(e)??[]}function Y(e,n){if(e)dt.set(e,n)}function Xf(e=process.env){return e.STX_DEBUG==="true"||e.STX_DEBUG==="1"}function N(...e){if(Xf())console.log("[stx:bundler]",...e)}var et=[];function kc(e,n,s){et.push({filePath:e||"<inline>",message:n,details:s})}function gn(){return et.slice()}function mn(){et.length=0}var K;function Zh(e){K=e}function _c(){if(K)return K;try{let e=L.strict;return typeof e==="object"&&e!==null?e.bundlerFallback??"warn":"warn"}catch{return"warn"}}var tt=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function hn(e){let n=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,s;while((s=n.exec(e))!==null){let c=s[1];if(!tt.some((o)=>o.test(c)))return N("detected user import:",c),!0}let i=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((s=i.exec(e))!==null){let c=s[1];if(/\.css(?:\?.*)?$/.test(c))continue;if(!tt.some((o)=>o.test(c)))return N("detected side-effect import:",c),!0}return!1}var pr="stx-module:",Rt=/\.(?:[cm]?[jt]sx?|json)$/i;function Jf(e,n){return d.relative(e,n).split(d.sep).join("/")}function Yf(e,n){if(n.size===0)return e;return e.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(s,i,c,p)=>{let o=n.get(p);return o&&!p.startsWith(pr)?`${i}${c}${o}${c}`:s})}function Zf(e,n){let s=0,i=(p)=>{let o=`__stxMod${s++}`,b=JSON.stringify(p);return n.push(`var ${o} = globalThis.__stxModules && globalThis.__stxModules[${b}];`,`if (${o} === undefined) throw new Error("[stx] module " + ${JSON.stringify(b)} + " is not registered on this page (#1957)");`),o},c=(p,o)=>{for(let b of p.split(",")){let I=b.trim();if(!I)continue;let M=I.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!M)continue;let w=M[1].startsWith('"')?JSON.parse(M[1]):M[1],f=M[2]??w;n.push(`var ${f} = ${o}[${JSON.stringify(w)}];`)}};return e=e.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,o,b)=>{let I=b.slice(pr.length),M=i(I),w=o.trim(),f=w.match(/^([\w$]+)\s*(?:,\s*|$)/);if(f&&!w.startsWith("{")&&!w.startsWith("*"))n.push(`var ${f[1]} = ${M}.default;`),w=w.slice(f[0].length).trim();let v=w.match(/^\*\s*as\s+([\w$]+)$/);if(v)n.push(`var ${v[1]} = ${M};`);else if(w.startsWith("{"))c(w.replace(/^\{|\}$/g,""),M);return""}),e=e.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,o)=>(i(o.slice(pr.length)),"")),e}function ot(e){let n=[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,`${e}.jsx`,d.join(e,"index.ts"),d.join(e,"index.tsx"),d.join(e,"index.js"),d.join(e,"index.mjs")];for(let s of n)try{if(j.existsSync(s)&&j.statSync(s,{throwIfNoEntry:!1})?.isFile())return s}catch{}return}var H=new lt;function ws(e,n){let s=new Bun.CryptoHasher("md5");for(let[i,c]of[...e].sort(([p],[o])=>p<o?-1:p>o?1:0))s.update(`${i}\x00${c}\x00`);return H.run({modules:e,key:s.digest("hex").slice(0,12)},n)}var pt=new lt;function Qf(e){return pt.run(!0,e)}function eg(){return pt.getStore()===!0}function Cc(e){if(!eg())return;throw Error(`The client script of ${e} needs bundling, and it is being rendered inside a Bun.build loader, where Bun never finishes a second build. Make the page an entrypoint of the build (bun-plugin-stx renders entrypoints before the bundler starts), or render it once outside the build so its bundle is cached.`)}function yn(){return H.getStore()?.key??""}function mt(e,n,s,i,c,p,o=new Map,b,I,M){let w=new Map([[s,i],...M??[]]),f=(B)=>B!==void 0&&w.has(B),v=(B,r,u)=>{if(X(r,e,b))return null;if(!p||!f(B)||!Rt.test(r))return null;try{if(!j.statSync(r,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}c.add(r);let E=`${pr}${Jf(process.cwd(),r)}`;return o.set(u,E),{path:E,external:!0}},y=(B,r)=>{let u=f(B)?n:d.dirname(B),E=d.resolve(u,r);return ot(E)??E};return{name:"stx-client-bundle",setup(B){if(B.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(r)=>({path:r.path,external:!0})),B.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(r)=>({path:r.path,external:!0})),B.onResolve({filter:/^\//},(r)=>{if(f(r.path))return{path:r.path};let u=ot(r.path);if(u){let E=v(r.importer,u,r.path);if(E)return E;if(!f(u))c.add(u);return{path:u}}return{path:r.path,external:!0}}),B.onResolve({filter:/^\.\.?\//},(r)=>{let u=y(r.importer,r.path),E=v(r.importer,u,r.path);if(E)return E;return c.add(u),{path:u}}),B.onResolve({filter:/^[@~]\//},(r)=>{let u=d.resolve(e,r.path.slice(2)),E=[u,`${u}.ts`,`${u}.tsx`,`${u}.js`,`${u}.mjs`,`${u}.jsx`,d.join(u,"index.ts"),d.join(u,"index.tsx"),d.join(u,"index.js"),d.join(u,"index.mjs")];for(let h of E)if(j.existsSync(h)&&j.statSync(h,{throwIfNoEntry:!1})?.isFile()){let D=v(r.importer,h,r.path);if(D)return D;return N(`resolved ${r.path[0]}/ import:`,r.path,"\u2192",h),c.add(h),{path:h}}return console.warn(`[stx:bundler] could not resolve ${r.path[0]}/ import:`,r.path),{path:u}}),p)B.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(r)=>{if(!f(r.importer))return;let u=`${pr}npm:${r.path}`;return o.set(r.path,u),{path:u,external:!0}});B.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(r)=>{if(w.has(r.path))return{contents:w.get(r.path),loader:"ts"};if(X(r.path,e,b))throw Error(`Server-only API source cannot be imported by a client script: ${r.path}`);let u=d.extname(r.path).toLowerCase(),E=u===".json"?"json":u===".tsx"?"tsx":u===".jsx"?"jsx":u===".ts"||u===".mts"||u===".cts"?"ts":"js";if(!f(r.path))c.add(r.path);let h=I?.get(r.path);if(h!==void 0)return{contents:h,loader:"js"};return{contents:j.readFileSync(r.path,"utf8"),loader:E}})}}}var Q=new Map,V=S(64),at=Symbol.for("stx.client-bundle-build-queue");function tg(e){let n=globalThis,i=(n[at]??Promise.resolve()).then(e,e);return n[at]=i.then(()=>{return},()=>{return}),i}async function bn(e,n,s={}){let i=s.projectRoot||process.cwd(),c=(await a(i)).serverApi,p=s.minify??!1,o=s.externalizeUserModules??!0,b=s.expose?.length?[...new Set(s.expose)].sort():void 0,I=s.cacheDir||Kf(i),M=H.getStore(),w=new Bun.CryptoHasher("md5");w.update(`${vt}\x00${ft()}\x00${JSON.stringify(c??!1)}\x00${o?"registry":"inline"}\x00${b?b.join(","):"*"}\x00${p?"minified":"readable"}\x00${M?.key??""}\x00${rt(e,i)}\x00${rt(n,i)}`);let f=w.digest("hex").slice(0,12),v=d.join(I,`${f}.js`),y=V.get(v);if(y){if(Js(y.files)&&y.files.every((h)=>!X(h.path,i,c))){N("memo hit:",f);let h=y.files.map((D)=>D.path);return Y(n,h),s.collectInputs?.push(...h),y.code}V.delete(v),N("memo invalidated by dep change:",f)}let B=d.join(I,`${f}.deps.json`),r=Bun.file(v);if(await r.exists()){let h=Bun.file(B),D=!1,k=null;if(await h.exists())try{let O=JSON.parse(await h.text());if(O.metadataVersion===ct&&Array.isArray(O.files)&&Et(O.files,i))k=Pr(O.files.map((g)=>ut(g,i))),D=k.length===O.files.length&&!k.some((g)=>X(g.path,i,c))}catch{D=!1}if(D){if(N("cache hit:",f),k)Y(n,k.map((U)=>U.path)),s.collectInputs?.push(...k.map((U)=>U.path));let O=await r.text(),g=new Date;if(j.promises.utimes(v,g,g).catch(()=>{}),k)V.set(v,{code:O,files:k});return O}N("cache invalidated by dep change:",f)}let u=Q.get(f);if(u){let h=await u;if(s.collectInputs)s.collectInputs.push(...(V.get(v)?.files??[]).map((D)=>D.path));return h}Cc(n);let E=tg(()=>Ft(e,n,{projectRoot:i,minify:p,cacheDir:I,hash:f,cachePath:v,depsPath:B,collectInputs:s.collectInputs,externalizeUserModules:o,serverApi:c,expose:b,throwOnFailure:s.throwOnFailure,substitutes:M?.modules}));Q.set(f,E);try{return await E}finally{Q.delete(f)}}function Ec(e){return`${e}-${process.pid}-${St()}`}async function Qh(e,n){let{projectRoot:s}=n,i=Ec(new Bun.CryptoHasher("md5").update([...e.keys()].join("\x00")).digest("hex").slice(0,12)),c=d.join(l(s,"bundle-tmp"),"out",i);j.mkdirSync(c,{recursive:!0});let p=new Map,o=new Map,b=0;for(let[f,v]of e){let y=d.join(s,`.stx-split-${i}-${b++}.ts`);p.set(y,v),o.set(d.basename(y).replace(/\.ts$/,""),f)}let[I,M]=[...p][0],w=new Set;Cc(n.filePath);try{let f=await Bun.build({entrypoints:[...p.keys()],outdir:c,target:"browser",format:"esm",splitting:!0,minify:!1,naming:{entry:"[name].js",chunk:"chunk-[hash].js"},plugins:[mt(s,d.dirname(n.filePath),I,M,w,!1,new Map,void 0,H.getStore()?.modules,p)],define:{"process.env.NODE_ENV":'"development"',...A()},root:s});if(!f.success)throw Error(f.logs.filter((y)=>y.level==="error").map((y)=>y.message).join(", ")||"Unable to bundle the entries");let v={entries:new Map,chunks:new Map};for(let y of f.outputs){let B=d.basename(y.path);if(y.kind==="entry-point"){let r=o.get(B.replace(/\.js$/,""));if(r!==void 0)v.entries.set(r,await y.text())}else if(y.kind==="chunk")v.chunks.set(B.replace(/\.js$/,""),await y.text())}return n.collectInputs?.push(...w),v}finally{try{j.rmSync(c,{recursive:!0,force:!0})}catch{}}}async function Ft(e,n,s){let{projectRoot:i,minify:c,cacheDir:p,hash:o,cachePath:b,depsPath:I,externalizeUserModules:M}=s,w=l(i,"bundle-tmp"),f=Ec(o),v=d.join(i,`.stx-client-${f}.ts`),y=d.join(w,"out",f);j.mkdirSync(y,{recursive:!0});let B=d.dirname(n),r=new Set,u=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,E=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,h=t(e),{depths:D,balanced:k}=C(h),O=(R)=>!k||D[R]===0,g;while((g=u.exec(h))!==null){if(g[1])continue;if(!O(g.index))continue;if(g[2])g[2].split(",").forEach((R)=>{let m=It(R);if(m)r.add(m)});else if(g[3])r.add(g[3])}while((g=E.exec(h))!==null){if(g[1])continue;if(!O(g.index))continue;r.add(g[2])}let U=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=U.exec(h))!==null){if(!O(g.index))continue;let R=/^\s*['"]([^'"]+)['"]/.exec(e.slice(g.index+g[0].length))?.[1];if(R&&tt.some((m)=>m.test(R)))continue;if(g[1])r.add(g[1]);if(g[2])r.add(g[2]);for(let m of(g[3]??"").split(",")){let _=m.trim();if(!_||/^type\s/.test(_))continue;let P=/\bas\s+(\w+)\s*$/.exec(_)?.[1]??/^\w+$/.exec(_)?.[0];if(P)r.add(P)}}for(let R of h.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let m of R[1].split(",")){let _=/\bas\s+(\w+)\s*$/.exec(m)?.[1]??/^\s*(\w+)\s*$/.exec(m)?.[1];if(_)r.delete(_)}let gt=r.size>0?`
|
|
3
|
-
export { ${[...r].join(", ")} }`:"";N("bundling:",o,"from:",d.basename(n));let nt=new Set,st=new Map;try{let
|
|
4
|
-
`),wt=
|
|
2
|
+
import{fr,Fe}from"./chunk-9f31gs4m.js";import{G,S,Pr,Js,A}from"./chunk-mrjr0vtb.js";import{a,L}from"./chunk-ce1d71m1.js";import{Yo}from"./chunk-6nvm1dgn.js";import{Z}from"./chunk-c47stwqj.js";import{ft}from"./chunk-6c1vm6bs.js";import{l}from"./chunk-s7xywsqd.js";import{t,E}from"./chunk-zpj6ggee.js";import d from"path";import j from"fs";import{AsyncLocalStorage as lt}from"async_hooks";import{randomUUID as St}from"crypto";var vt=12;function X(e,n,s){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(e))||Yo(e,n,s)}var ct=2;function Kf(e){let n=process.env.STX_BUNDLE_CACHE_DIR?.trim();return n?d.resolve(n):l(e,"bundle-cache")}function rt(e,n){let s=e;for(let i of Bt(n))if(i!==d.sep)s=s.split(i).join("\x00root");return s}var it=new Map;function Bt(e){let n=d.resolve(e),s=it.get(n);if(!s){let i=n;try{i=j.realpathSync(n)}catch{}s=[...new Set([n,i])].sort((c,p)=>p.length-c.length),it.set(n,s)}return s}function jt(e,n){try{let s=j.statSync(e),i=d.resolve(n),c=e.startsWith(`${i}${d.sep}`);return{path:c?d.relative(i,e):e,...c?{inRoot:!0}:{},mtimeMs:s.mtimeMs,size:s.size,hash:Bun.hash(j.readFileSync(e)).toString(36)}}catch{return null}}function ut(e,n){return e.inRoot?d.join(d.resolve(n),e.path):e.path}function Et(e,n){for(let s of e){let i=ut(s,n);try{let c=j.statSync(i);if(c.size!==s.size)return!1;if(c.mtimeMs!==s.mtimeMs&&Bun.hash(j.readFileSync(i)).toString(36)!==s.hash)return!1}catch{return!1}}return!0}var dt=new Map,_t=100;function Gf(e=process.env){let n=Number(e.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(n)&&n>=1?Math.floor(n):2000}var q=new Map;async function Mt(e){let n=q.get(e)??0;if(n>0&&n<_t){q.set(e,n+1);return}q.set(e,1);try{let s=(await j.promises.readdir(e)).filter((o)=>o.endsWith(".js")),i=Gf();if(s.length<=i)return;let p=(await Promise.all(s.map(async(o)=>{try{return{name:o,at:(await j.promises.stat(d.join(e,o))).mtimeMs}}catch{return null}}))).filter((o)=>o!==null);p.sort((o,b)=>b.at-o.at);for(let o of p.slice(i)){let b=o.name.slice(0,-3);await j.promises.rm(d.join(e,`${b}.js`),{force:!0}),await j.promises.rm(d.join(e,`${b}.deps.json`),{force:!0})}N("pruned bundle cache to",i,"entries")}catch{}}function Ce(e){return dt.get(e)??[]}function Y(e,n){if(e)dt.set(e,n)}function Xf(e=process.env){return e.STX_DEBUG==="true"||e.STX_DEBUG==="1"}function N(...e){if(Xf())console.log("[stx:bundler]",...e)}var et=[];function kc(e,n,s){et.push({filePath:e||"<inline>",message:n,details:s})}function gn(){return et.slice()}function mn(){et.length=0}var K;function Zh(e){K=e}function _c(){if(K)return K;try{let e=L.strict;return typeof e==="object"&&e!==null?e.bundlerFallback??"warn":"warn"}catch{return"warn"}}var tt=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function hn(e){let n=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,s;while((s=n.exec(e))!==null){let c=s[1];if(!tt.some((o)=>o.test(c)))return N("detected user import:",c),!0}let i=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((s=i.exec(e))!==null){let c=s[1];if(/\.css(?:\?.*)?$/.test(c))continue;if(!tt.some((o)=>o.test(c)))return N("detected side-effect import:",c),!0}return!1}var pr="stx-module:",Rt=/\.(?:[cm]?[jt]sx?|json)$/i;function Jf(e,n){return d.relative(e,n).split(d.sep).join("/")}function Yf(e,n){if(n.size===0)return e;return e.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(s,i,c,p)=>{let o=n.get(p);return o&&!p.startsWith(pr)?`${i}${c}${o}${c}`:s})}function Zf(e,n){let s=0,i=(p)=>{let o=`__stxMod${s++}`,b=JSON.stringify(p);return n.push(`var ${o} = globalThis.__stxModules && globalThis.__stxModules[${b}];`,`if (${o} === undefined) throw new Error("[stx] module " + ${JSON.stringify(b)} + " is not registered on this page (#1957)");`),o},c=(p,o)=>{for(let b of p.split(",")){let C=b.trim();if(!C)continue;let R=C.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!R)continue;let w=R[1].startsWith('"')?JSON.parse(R[1]):R[1],f=R[2]??w;n.push(`var ${f} = ${o}[${JSON.stringify(w)}];`)}};return e=e.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,o,b)=>{let C=b.slice(pr.length),R=i(C),w=o.trim(),f=w.match(/^([\w$]+)\s*(?:,\s*|$)/);if(f&&!w.startsWith("{")&&!w.startsWith("*"))n.push(`var ${f[1]} = ${R}.default;`),w=w.slice(f[0].length).trim();let v=w.match(/^\*\s*as\s+([\w$]+)$/);if(v)n.push(`var ${v[1]} = ${R};`);else if(w.startsWith("{"))c(w.replace(/^\{|\}$/g,""),R);return""}),e=e.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,o)=>(i(o.slice(pr.length)),"")),e}function ot(e){let n=[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,`${e}.jsx`,d.join(e,"index.ts"),d.join(e,"index.tsx"),d.join(e,"index.js"),d.join(e,"index.mjs")];for(let s of n)try{if(j.existsSync(s)&&j.statSync(s,{throwIfNoEntry:!1})?.isFile())return s}catch{}return}var H=new lt;function ws(e,n){let s=new Bun.CryptoHasher("md5");for(let[i,c]of[...e].sort(([p],[o])=>p<o?-1:p>o?1:0))s.update(`${i}\x00${c}\x00`);return H.run({modules:e,key:s.digest("hex").slice(0,12)},n)}var pt=new lt;function Qf(e){return pt.run(!0,e)}function eg(){return pt.getStore()===!0}function Cc(e){if(!eg())return;throw Error(`The client script of ${e} needs bundling, and it is being rendered inside a Bun.build loader, where Bun never finishes a second build. Make the page an entrypoint of the build (bun-plugin-stx renders entrypoints before the bundler starts), or render it once outside the build so its bundle is cached.`)}function yn(){return H.getStore()?.key??""}function mt(e,n,s,i,c,p,o=new Map,b,C,R){let w=new Map([[s,i],...R??[]]),f=(B)=>B!==void 0&&w.has(B),v=(B,r,u)=>{if(X(r,e,b))return null;if(!p||!f(B)||!Rt.test(r))return null;try{if(!j.statSync(r,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}c.add(r);let _=`${pr}${Jf(process.cwd(),r)}`;return o.set(u,_),{path:_,external:!0}},y=(B,r)=>{let u=f(B)?n:d.dirname(B),_=d.resolve(u,r);return ot(_)??_};return{name:"stx-client-bundle",setup(B){if(B.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(r)=>({path:r.path,external:!0})),B.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(r)=>({path:r.path,external:!0})),B.onResolve({filter:/^\//},(r)=>{if(f(r.path))return{path:r.path};let u=ot(r.path);if(u){let _=v(r.importer,u,r.path);if(_)return _;if(!f(u))c.add(u);return{path:u}}return{path:r.path,external:!0}}),B.onResolve({filter:/^\.\.?\//},(r)=>{let u=y(r.importer,r.path),_=v(r.importer,u,r.path);if(_)return _;return c.add(u),{path:u}}),B.onResolve({filter:/^[@~]\//},(r)=>{let u=d.resolve(e,r.path.slice(2)),_=[u,`${u}.ts`,`${u}.tsx`,`${u}.js`,`${u}.mjs`,`${u}.jsx`,d.join(u,"index.ts"),d.join(u,"index.tsx"),d.join(u,"index.js"),d.join(u,"index.mjs")];for(let h of _)if(j.existsSync(h)&&j.statSync(h,{throwIfNoEntry:!1})?.isFile()){let D=v(r.importer,h,r.path);if(D)return D;return N(`resolved ${r.path[0]}/ import:`,r.path,"\u2192",h),c.add(h),{path:h}}return console.warn(`[stx:bundler] could not resolve ${r.path[0]}/ import:`,r.path),{path:u}}),p)B.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(r)=>{if(!f(r.importer))return;let u=`${pr}npm:${r.path}`;return o.set(r.path,u),{path:u,external:!0}});B.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(r)=>{if(w.has(r.path))return{contents:w.get(r.path),loader:"ts"};if(X(r.path,e,b))throw Error(`Server-only API source cannot be imported by a client script: ${r.path}`);let u=d.extname(r.path).toLowerCase(),_=u===".json"?"json":u===".tsx"?"tsx":u===".jsx"?"jsx":u===".ts"||u===".mts"||u===".cts"?"ts":"js";if(!f(r.path))c.add(r.path);let h=C?.get(r.path);if(h!==void 0)return{contents:h,loader:"js"};return{contents:j.readFileSync(r.path,"utf8"),loader:_}})}}}var Q=new Map,V=S(64),at=Symbol.for("stx.client-bundle-build-queue");function tg(e){let n=globalThis,i=(n[at]??Promise.resolve()).then(e,e);return n[at]=i.then(()=>{return},()=>{return}),i}async function bn(e,n,s={}){let i=s.projectRoot||process.cwd(),c=(await a(i)).serverApi,p=s.minify??!1,o=s.externalizeUserModules??!0,b=s.expose?.length?[...new Set(s.expose)].sort():void 0,C=s.cacheDir||Kf(i),R=H.getStore(),w=new Bun.CryptoHasher("md5");w.update(`${vt}\x00${ft()}\x00${JSON.stringify(c??!1)}\x00${o?"registry":"inline"}\x00${b?b.join(","):"*"}\x00${p?"minified":"readable"}\x00${R?.key??""}\x00${rt(e,i)}\x00${rt(n,i)}`);let f=w.digest("hex").slice(0,12),v=d.join(C,`${f}.js`),y=V.get(v);if(y){if(Js(y.files)&&y.files.every((h)=>!X(h.path,i,c))){N("memo hit:",f);let h=y.files.map((D)=>D.path);return Y(n,h),s.collectInputs?.push(...h),y.code}V.delete(v),N("memo invalidated by dep change:",f)}let B=d.join(C,`${f}.deps.json`),r=Bun.file(v);if(await r.exists()){let h=Bun.file(B),D=!1,k=null;if(await h.exists())try{let O=JSON.parse(await h.text());if(O.metadataVersion===ct&&Array.isArray(O.files)&&Et(O.files,i))k=Pr(O.files.map((g)=>ut(g,i))),D=k.length===O.files.length&&!k.some((g)=>X(g.path,i,c))}catch{D=!1}if(D){if(N("cache hit:",f),k)Y(n,k.map((U)=>U.path)),s.collectInputs?.push(...k.map((U)=>U.path));let O=await r.text(),g=new Date;if(j.promises.utimes(v,g,g).catch(()=>{}),k)V.set(v,{code:O,files:k});return O}N("cache invalidated by dep change:",f)}let u=Q.get(f);if(u){let h=await u;if(s.collectInputs)s.collectInputs.push(...(V.get(v)?.files??[]).map((D)=>D.path));return h}Cc(n);let _=tg(()=>Ft(e,n,{projectRoot:i,minify:p,cacheDir:C,hash:f,cachePath:v,depsPath:B,collectInputs:s.collectInputs,externalizeUserModules:o,serverApi:c,expose:b,throwOnFailure:s.throwOnFailure,substitutes:R?.modules}));Q.set(f,_);try{return await _}finally{Q.delete(f)}}function Ec(e){return`${e}-${process.pid}-${St()}`}async function Qh(e,n){let{projectRoot:s}=n,i=Ec(new Bun.CryptoHasher("md5").update([...e.keys()].join("\x00")).digest("hex").slice(0,12)),c=d.join(l(s,"bundle-tmp"),"out",i);j.mkdirSync(c,{recursive:!0});let p=new Map,o=new Map,b=0;for(let[f,v]of e){let y=d.join(s,`.stx-split-${i}-${b++}.ts`);p.set(y,v),o.set(d.basename(y).replace(/\.ts$/,""),f)}let[C,R]=[...p][0],w=new Set;Cc(n.filePath);try{let f=await Bun.build({entrypoints:[...p.keys()],outdir:c,target:"browser",format:"esm",splitting:!0,minify:!1,naming:{entry:"[name].js",chunk:"chunk-[hash].js"},plugins:[mt(s,d.dirname(n.filePath),C,R,w,!1,new Map,void 0,H.getStore()?.modules,p)],define:{"process.env.NODE_ENV":'"development"',...A()},root:s});if(!f.success)throw Error(f.logs.filter((y)=>y.level==="error").map((y)=>y.message).join(", ")||"Unable to bundle the entries");let v={entries:new Map,chunks:new Map};for(let y of f.outputs){let B=d.basename(y.path);if(y.kind==="entry-point"){let r=o.get(B.replace(/\.js$/,""));if(r!==void 0)v.entries.set(r,await y.text())}else if(y.kind==="chunk")v.chunks.set(B.replace(/\.js$/,""),await y.text())}return n.collectInputs?.push(...w),v}finally{try{j.rmSync(c,{recursive:!0,force:!0})}catch{}}}async function Ft(e,n,s){let{projectRoot:i,minify:c,cacheDir:p,hash:o,cachePath:b,depsPath:C,externalizeUserModules:R}=s,w=l(i,"bundle-tmp"),f=Ec(o),v=d.join(i,`.stx-client-${f}.ts`),y=d.join(w,"out",f);j.mkdirSync(y,{recursive:!0});let B=d.dirname(n),r=new Set,u=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,_=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,h=t(e),{depths:D,balanced:k}=E(h),O=(F)=>!k||D[F]===0,g;while((g=u.exec(h))!==null){if(g[1])continue;if(!O(g.index))continue;if(g[2])g[2].split(",").forEach((F)=>{let m=It(F);if(m)r.add(m)});else if(g[3])r.add(g[3])}while((g=_.exec(h))!==null){if(g[1])continue;if(!O(g.index))continue;r.add(g[2])}let U=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=U.exec(h))!==null){if(!O(g.index))continue;let F=/^\s*['"]([^'"]+)['"]/.exec(e.slice(g.index+g[0].length))?.[1];if(F&&tt.some((m)=>m.test(F)))continue;if(g[1])r.add(g[1]);if(g[2])r.add(g[2]);for(let m of(g[3]??"").split(",")){let M=m.trim();if(!M||/^type\s/.test(M))continue;let P=/\bas\s+(\w+)\s*$/.exec(M)?.[1]??/^\w+$/.exec(M)?.[0];if(P)r.add(P)}}for(let F of h.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let m of F[1].split(",")){let M=/\bas\s+(\w+)\s*$/.exec(m)?.[1]??/^\s*(\w+)\s*$/.exec(m)?.[1];if(M)r.delete(M)}let gt=r.size>0?`
|
|
3
|
+
export { ${[...r].join(", ")} }`:"";N("bundling:",o,"from:",d.basename(n));let nt=new Set,st=new Map;try{let F=await Bun.build({entrypoints:[v],outdir:y,target:"browser",format:"esm",minify:c?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[mt(i,B,v,e+gt,nt,R,st,s.serverApi,s.substitutes)],define:{"process.env.NODE_ENV":c?'"production"':'"development"',...A()},root:i});if(!F.success){let I=F.logs.filter((T)=>T.level==="error").map((T)=>T.message).join(", ")||`Unable to bundle ${d.basename(n)}`,z=fr(F.logs,n||void 0);if(console.warn("[stx:bundler] build failed:",I),kc(n||"",I,z),s.throwOnFailure||_c()==="error")throw Error(I);return e}let m="";for(let x of F.outputs){m=await x.text();break}let M=[];for(let x of m.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let I of x[1].split(",")){let z=I.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(z){M.push([z[2],z[1]]);continue}let T=I.trim();if(/^[A-Za-z_$][\w$]*$/.test(T))M.push([T,T])}if(s.expose){let x=new Set(s.expose);for(let I=M.length-1;I>=0;I--)if(!x.has(M[I][0]))M.splice(I,1)}let P=[];m=Zf(Yf(m,st),P);let ht=m.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(m=m.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),c&&m)try{m=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(m)}catch{}let xt=Z(m),W=`__stxBundle_${o}`,yt=new Set(G(e,!0).split(",").map((x)=>x.trim())),$t=M.map(([x,I])=>`get ${JSON.stringify(x)}() { return ${I} }${yt.has(x)?`, set ${JSON.stringify(x)}(__stxValue_${I}) { ${I} = __stxValue_${I} }`:""}`).join(", "),bt=M.map(([x])=>`var ${x} = undefined;`).join(`
|
|
4
|
+
`),wt=M.map(([x])=>`${x} = ${W}[${JSON.stringify(x)}];`).join(`
|
|
5
5
|
`);if(m=`${ht.join(`
|
|
6
6
|
`)}
|
|
7
7
|
${bt}
|
|
@@ -16,5 +16,5 @@ var __stxLiveBindings = typeof __stxLiveBindings === 'undefined' ? {} : __stxLiv
|
|
|
16
16
|
Object.keys(${W}).forEach(function(name) {
|
|
17
17
|
if (!Object.prototype.hasOwnProperty.call(__stxLiveBindings, name))
|
|
18
18
|
Object.defineProperty(__stxLiveBindings, name, Object.getOwnPropertyDescriptor(${W}, name));
|
|
19
|
-
});`.trim(),N("bundled:",o,"output:",m.length,"bytes"),r.size>0&&
|
|
19
|
+
});`.trim(),N("bundled:",o,"output:",m.length,"bytes"),r.size>0&&M.length===0)return console.warn(`[stx:bundler] dropped every binding for ${d.basename(n)} (${o}); serving the unbundled source and not caching this result`),e;j.mkdirSync(p,{recursive:!0}),await Bun.write(b,m);let J=Pr(nt);return await Bun.write(C,JSON.stringify({metadataVersion:ct,files:J.map((x)=>jt(x.path,i)).filter((x)=>x!==null)})),Y(n,J.map((x)=>x.path)),s.collectInputs?.push(...J.map((x)=>x.path)),V.set(b,{code:m,files:J}),await Mt(p),m}catch(F){let m=fr(F,n||void 0),M=Fe(F,n||void 0);if(console.warn(`[stx:bundler] error: ${M}`),kc(n||"",M,m),s.throwOnFailure||_c()==="error")throw F;return e}finally{try{j.rmSync(y,{recursive:!0,force:!0})}catch{}}}function It(e){let n=e.trim();if(!n)return null;let s=n.indexOf("=");if(s!==-1)n=n.slice(0,s).trim();let i=n.indexOf(":");if(i!==-1)n=n.slice(i+1).trim();if(n.startsWith("..."))n=n.slice(3).trim();return/^[A-Za-z_$][\w$]*$/.test(n)?n:null}
|
|
20
20
|
export{Kf,Gf,Ce,Xf,kc,gn,mn,Zh,_c,hn,pr,Jf,Yf,Zf,ws,Qf,eg,Cc,yn,tg,bn,Ec,Qh};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{cy,ly,cg,Cs}from"./chunk-d9hsqh1w.js";import"./chunk-qtbbc0h2.js";import"./chunk-d2pexm3z.js";import"./chunk-cb0c6959.js";import{Dr}from"./chunk-mrjr0vtb.js";import"./chunk-pk3pp1j5.js";import"./chunk-6t04tqvh.js";import{ht}from"./chunk-295bykzd.js";import"./chunk-hxhmhw23.js";import"./chunk-kwf3kfr0.js";import"./chunk-s29hp1qw.js";import"./chunk-n22xtagg.js";export{ht as freeIdentifiers,Cs as processComponents,cg as processESImports,Dr as rendersAsElement,cy as resetMarginStackWarnings,ly as resetTemplateLoopWarnings};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Q,We}from"./chunk-
|
|
2
|
+
import{Q,We}from"./chunk-mrjr0vtb.js";var o=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function u(t,e,r){let i={fullTag:r,content:e,attrs:t};if(/\bserver\b/.test(t))return{...i,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...i,type:"client"};if(o.test(e))return{...i,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...i,type:"client"};return{...i,type:"server"}}var S=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function fn(t){let e=[],r=[],i=[],c=0;while(c<t.length){let s=t.indexOf("<",c);if(s===-1)break;let p=We(t,s);if(p>s){c=p;continue}let a=Q(t,s);if(a>s){let f=t.slice(s,a),l=S.exec(f);if(l){let n=u(l[1],l[2],f);switch(n.type){case"signals":e.push(n);break;case"client":r.push(n);break;case"server":i.push(n);break}}c=a;continue}c=s+(t.startsWith("<!--",s)?4:1)}return{signals:e,client:r,server:i}}
|
|
3
3
|
export{fn};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{fg,dy,py,fy,gy,gg,mg,my,hy,fi,yy,Sr,kr,Os}from"./chunk-
|
|
2
|
+
import{fg,dy,py,fy,gy,gg,mg,my,hy,fi,yy,Sr,kr,Os}from"./chunk-63y8exx2.js";import{ft}from"./chunk-6c1vm6bs.js";import"./chunk-mrjr0vtb.js";import"./chunk-pk3pp1j5.js";import"./chunk-6t04tqvh.js";import"./chunk-295bykzd.js";import"./chunk-hxhmhw23.js";import"./chunk-kwf3kfr0.js";import"./chunk-s29hp1qw.js";import"./chunk-n22xtagg.js";export{gy as __setSignalsGeneratorsForTest,ft as cacheEngineFingerprint,kr as cacheTemplate,Sr as checkCache,yy as clearDevCaches,mg as getCachedRouterScript,gg as getCachedSignalsRuntime,my as getServeClientAsset,fi as getServeModuleBundle,Os as hashFilePath,py as invalidateFileCache,fy as invalidateFileCacheByDir,dy as readFileCached,hy as registerServeModuleBundle,fg as templateCache};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{gr,i}from"./chunk-nxbws5qm.js";import"./chunk-kk92sv04.js";import"./chunk-8an1mp1z.js";import"./chunk-c0g30cjs.js";import"./chunk-d9hsqh1w.js";import"./chunk-qtbbc0h2.js";import"./chunk-charhv8y.js";import"./chunk-d2pexm3z.js";import"./chunk-v9wt6jx2.js";import{$e}from"./chunk-2v0pcxqs.js";import"./chunk-cb0c6959.js";import"./chunk-63y8exx2.js";import"./chunk-c47stwqj.js";import"./chunk-ce1d71m1.js";import"./chunk-css5czqk.js";import"./chunk-h63ma36g.js";import"./chunk-ssg6ne5b.js";import"./chunk-0rdh8bw3.js";import"./chunk-agd2b928.js";import{Ue,ro,so}from"./chunk-mrjr0vtb.js";import"./chunk-pk3pp1j5.js";import"./chunk-6t04tqvh.js";import"./chunk-295bykzd.js";import"./chunk-hxhmhw23.js";import"./chunk-kwf3kfr0.js";import"./chunk-s29hp1qw.js";import"./chunk-n22xtagg.js";export{gr as buildModulesTag,$e as injectRouterScript,i as processDirectives,ro as processJsonDirective,so as processOnceDirective,Ue as validateClientScript};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{S,
|
|
3
|
-
${l.trim()}`)}catch(l){console.warn(`[stx] Failed to load composable ${o}:`,l)}if(F.length===0||
|
|
4
|
-
`),O=JSON.stringify([...
|
|
2
|
+
import{S,C,A,Ie,J,Qs,oe}from"./chunk-mrjr0vtb.js";import{De}from"./chunk-kwf3kfr0.js";import{_}from"./chunk-n22xtagg.js";import{M,jn}from"./chunk-hxhmhw23.js";import{a}from"./chunk-ce1d71m1.js";import{Ce,hn,yn,bn}from"./chunk-wh8yhpyh.js";import{Pt}from"./chunk-v9wt6jx2.js";import{Tt,er,ln,be}from"./chunk-97kgrevs.js";import{Z}from"./chunk-c47stwqj.js";import{I,et}from"./chunk-ws2h92mm.js";import y from"path";var B=new Map,P=new Map,R=S(64),T=new Map,te=["composables","functions"];function W(e){let s=y.basename(e,".ts");return s==="index"||s==="types"||e.endsWith(".d.ts")}async function ne(e){if(e)return y.resolve(e);let s=`<default>:${process.cwd()}`,i=T.get(s);if(i!==void 0)return i;let t=await se();if(t!==null)T.set(s,t);return t}async function se(){let e=await a(),s=e.root||process.cwd(),i=e.composablesDir;if(i)return y.resolve(s,i);for(let t of te){let n=y.resolve(s,t);try{let c=new Bun.Glob("**/*.ts");for await(let r of c.scan({cwd:n,absolute:!0}))if(!W(r))return n}catch{}}return null}async function X(e){let s=Array.isArray(e)?e:e?[y.resolve(e)]:(await a())._layerComposableDirs??[await ne()].filter((t)=>!!t),i=new Map;for(let t of s){let n=new Bun.Glob("**/*.ts");try{for await(let c of n.scan({cwd:t,absolute:!0})){let r=y.relative(t,c);if(!W(c)&&!i.has(r))i.set(r,c)}}catch{}}return{key:s.join("\x00"),files:[...i.values()].sort()}}async function Lo(e){let{files:s}=await X(e),i=oe({loader:"ts",target:"browser",define:A()}),t=[];for(let n of s)try{let c=await Bun.file(n).text(),r=i.scan(c).exports.filter((d)=>d!=="default");if(r.length>0)t.push({file:n,names:r})}catch{}return t}function re(e,s){return new RegExp(`\\b${s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(e)}function Q(e,s){let i=new Set(e.match(/\w+/g)),t=new Set;for(let n of s)if(/^\w+$/.test(n)?i.has(n):re(e,n))t.add(n);return t}var H=S(64);function U(e,s){let i=C(e,s.size),t=H.get(i);if(t)return t;let n;try{n=De(e,s)}catch{n=Q(e,s)}let c=[...e.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...e.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let r of c)for(let d of r[1].split(",")){let f=d.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(f&&s.has(f))n.add(f)}return H.set(i,n),n}function ie(e){return!e||/^(?:module|(?:text|application)\/(?:java|ecma)script|application\/stx-[\w-]+)$/i.test(e)}var q=S(256);function ae(e,s){let i=new Set(s),t="",n=0,c=new Set;for(let r of Ie(e)){t+=e.slice(n,r.start),n=r.end;let d=J(r.attrs),f=e.slice(r.bodyStart,r.bodyEnd),u=d.get("type"),m=typeof u==="string"?u.trim():void 0;if(!ie(m)){if(!/json/i.test(m??""))t+=` ${f} `;continue}let x=Q(f,i);if(x.size===0)continue;let b=C(f,[...x].sort().join(",")),w=q.get(b);if(!w)w=U(f,x),q.set(b,w);for(let j of w)c.add(j)}t+=e.slice(n);for(let r of Qs(t))for(let d of U(r.code,i))c.add(d);return c}function ce(e,s,i){let t=new Map;for(let{file:f,names:u}of e)for(let m of u)if(!t.has(m))t.set(m,f);let n=new Set(t.keys()),c=(f)=>{let u=[];for(let m of U(f,n))u.push(t.get(m));return u},r=new Set,d=i.flatMap((f,u)=>u===0?[...ae(f,t.keys())].map((m)=>t.get(m)):c(f));while(d.length>0){let f=[];for(let u of d){if(r.has(u))continue;r.add(u);for(let m of c(s.get(u)??""))if(!r.has(m))f.push(m)}d=f}return r}async function jh(e,s,i,t){let{key:n,files:c}=await X(e);if(!n)return null;let r=()=>[...new Set([...c,...c.flatMap((o)=>Ce(o))])],d=Tt(r());if(c.length===0)return be(B,n,d,""),null;c.sort();let f=oe({loader:"ts",target:"browser",define:A()}),u=ln(P,n,d);if(!u){let o=new Map,l=[];for(let p of c)try{let v=await Bun.file(p).text();o.set(p,v);let g=f.scan(v).exports.filter((ee)=>ee!=="default");if(g.length>0)l.push({file:p,names:g})}catch{o.set(p,"")}u=be(P,n,d,{codeByFile:o,modules:l})}let{codeByFile:m,modules:x}=u,b;if(s===void 0)b=new Set(c);else{let o=i?[s,...i]:[s],l=C(o.join("\x00"),n,o.length,d),p=R.get(l);if(b=p??ce(x,m,o),!p)R.set(l,b)}if(b.size===0)return null;let w=c.filter((o)=>b.has(o)),j=()=>{if(!t)return;for(let o of w)t.push(o,...Ce(o))},E=`${n}\x00${w.join("\x00")}\x00${yn()}`,z=ln(B,E,d);if(z!==void 0)return j(),z||null;let F=[],N=new Set,K=new Set;for(let o of w)try{let l=m.get(o)??await Bun.file(o).text(),p=y.basename(o,".ts");for(let g of l.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(g[1])K.add(g[1]);let v=[];try{for(let g of f.scan(l).exports)if(g!=="default")N.add(g),v.push(g)}catch{}if(l=M(l),hn(l))l=await bn(l,o,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:v}),l=Pt(l);l=jn(l),l=l.replace(/^export\s+(default\s+)?/gm,""),l=f.transformSync(l),F.push(`// Composable: ${p}
|
|
3
|
+
${l.trim()}`)}catch(l){console.warn(`[stx] Failed to load composable ${o}:`,l)}if(F.length===0||N.size===0)return be(B,E,d,""),null;let V=[...N].map((o)=>` try { if (!(${JSON.stringify(o)} in __c)) __c[${JSON.stringify(o)}] = ${o}; } catch (e) {}`).join(`
|
|
4
|
+
`),O=JSON.stringify([...N]),k=F.join(`
|
|
5
5
|
|
|
6
|
-
`),Y=
|
|
7
|
-
`),h=JSON.stringify(new Bun.CryptoHasher("md5").update(`${O}\x00${
|
|
6
|
+
`),Y=_.filter((o)=>!K.has(o)&&new RegExp(`\\b${o}\\b`).test(k)).map((o)=>`var ${o} = __stx[${JSON.stringify(o)}];`).join(`
|
|
7
|
+
`),h=JSON.stringify(new Bun.CryptoHasher("md5").update(`${O}\x00${k}`).digest("hex").slice(0,12)),D=Z(k),G=`;${D?"await (async function":"(function"}(){
|
|
8
8
|
var __bundles = window.__stxComposableBundles || (window.__stxComposableBundles = {});
|
|
9
|
-
if (__bundles[${h}]) { ${
|
|
10
|
-
${
|
|
9
|
+
if (__bundles[${h}]) { ${D?"await __bundles["+h+"];":""} return; }
|
|
10
|
+
${D?`var __resolveBundle, __rejectBundle;
|
|
11
11
|
__bundles[${h}]=new Promise(function(resolve,reject){__resolveBundle=resolve;__rejectBundle=reject;});
|
|
12
12
|
__bundles[${h}].catch(function(){});
|
|
13
13
|
try {`:`__bundles[${h}] = true;`}
|
|
@@ -16,7 +16,7 @@ window.__composables = window.__composables || {};
|
|
|
16
16
|
var __c = window.__composables;
|
|
17
17
|
var __stx = window.stx || {};
|
|
18
18
|
${Y}
|
|
19
|
-
${
|
|
19
|
+
${k}
|
|
20
20
|
${V}
|
|
21
21
|
var __names = ${O};
|
|
22
22
|
for (var __i = 0; __i < __names.length; __i++) {
|
|
@@ -32,7 +32,7 @@ ${V}
|
|
|
32
32
|
window[__n] = __c[__n];
|
|
33
33
|
__published[__n] = true;
|
|
34
34
|
}
|
|
35
|
-
${
|
|
35
|
+
${D?`__resolveBundle();
|
|
36
36
|
} catch(error) { delete __bundles[${h}]; __rejectBundle(error); throw error; }`:""}
|
|
37
|
-
})();`,L=I()?et(G):G;return d=Tt(r()),be(B,
|
|
37
|
+
})();`,L=I()?et(G):G;return d=Tt(r()),be(B,E,d,L),j(),L}function Bh(){B.clear(),er(),P.clear(),R.clear(),T.clear()}
|
|
38
38
|
export{Lo,jh,Bh};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{mt,Tg,$g,Rg,Ag,Pg,h,Ig,Di,Og,hl,yl}from"./chunk-
|
|
2
|
+
import{mt,Tg,$g,Rg,Ag,Pg,h,Ig,Di,Og,hl,yl}from"./chunk-mrjr0vtb.js";import"./chunk-pk3pp1j5.js";import"./chunk-6t04tqvh.js";import"./chunk-295bykzd.js";import"./chunk-hxhmhw23.js";import"./chunk-kwf3kfr0.js";import"./chunk-s29hp1qw.js";import"./chunk-n22xtagg.js";export{mt as STX_ENGINE_BINDING_NAMES,Di as convertToCommonJS,hl as extractScriptFromTemplate,h as extractVariables,yl as hasVariables,Ig as isCompleteImport,Pg as isMissingBindingFailure,Rg as isModuleResolutionFailure,Ag as isSyntaxFailure,Og as splitDeclaration,Tg as stripTypeScript,$g as withoutStxReferrer};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ql,eu}from"./chunk-2n2102vf.js";import"./chunk-94ctmp0j.js";import"./chunk-mejhzan9.js";import"./chunk-m4f13mrp.js";import"./chunk-jbv448x5.js";import"./chunk-4n45qa0b.js";import"./chunk-czcx3nbx.js";import"./chunk-aw6m1t68.js";import"./chunk-7dtfkf1b.js";import"./chunk-p6yavy8h.js";import"./chunk-2r0nrvqe.js";import"./chunk-q1mb0fbt.js";import"./chunk-pdprhg5k.js";import"./chunk-p0rpdj1w.js";import"./chunk-q74affc4.js";import"./chunk-gbncp2gp.js";import"./chunk-yp4tn4zn.js";import"./chunk-8va3fs07.js";import"./chunk-sv7fdqmc.js";import"./chunk-a7ryj8z8.js";import"./chunk-5p6xtzkk.js";import"./chunk-5xhaabn0.js";import"./chunk-aaea157p.js";import"./chunk-8e1cv1hh.js";import"./chunk-ybjgnnyf.js";import"./chunk-a0q0kb0s.js";import"./chunk-5mmgdpjr.js";import"./chunk-y3v0r845.js";import"./chunk-fg67643b.js";import"./chunk-rtehrddv.js";import"./chunk-kee5a3ce.js";import"./chunk-59er0fc7.js";import{fn}from"./chunk-ws3wfpy9.js";import{Qf}from"./chunk-wh8yhpyh.js";import"./chunk-6nvm1dgn.js";import"./chunk-9f31gs4m.js";import{ze,i}from"./chunk-nxbws5qm.js";import"./chunk-kk92sv04.js";import"./chunk-8an1mp1z.js";import"./chunk-c0g30cjs.js";import"./chunk-d9hsqh1w.js";import"./chunk-qtbbc0h2.js";import"./chunk-charhv8y.js";import"./chunk-d2pexm3z.js";import"./chunk-v9wt6jx2.js";import{$e}from"./chunk-2v0pcxqs.js";import"./chunk-cb0c6959.js";import{Sr,kr}from"./chunk-63y8exx2.js";import"./chunk-c47stwqj.js";import{Ms,W,a}from"./chunk-ce1d71m1.js";import"./chunk-css5czqk.js";import"./chunk-h63ma36g.js";import"./chunk-ssg6ne5b.js";import"./chunk-0rdh8bw3.js";import"./chunk-agd2b928.js";import{j,h,Ke}from"./chunk-mrjr0vtb.js";import"./chunk-pk3pp1j5.js";import"./chunk-6t04tqvh.js";import"./chunk-295bykzd.js";import"./chunk-hxhmhw23.js";import"./chunk-kwf3kfr0.js";import"./chunk-s29hp1qw.js";import"./chunk-n22xtagg.js";import{ra}from"./chunk-xpbakn6t.js";import"./chunk-463weehv.js";import"./chunk-shcnt6aa.js";export{Ms as buildWebComponents,kr as cacheTemplate,Sr as checkCache,fn as classifyAllScripts,Ql as createMiddleware,eu as createRoute,W as defaultConfig,h as extractVariables,j as findSfcTemplateBlock,$e as injectRouterScript,ra as insertBeforeBodyClose,a as loadStxConfig,Ke as processClientScript,i as processDirectives,ze as readMarkdownFile,Qf as withinBundlerCallback};
|
|
@@ -8,5 +8,5 @@ function b(e,s){let i=e[s],n=s+1;while(n<e.length){if(e[n]==="\\"){n+=2;continue
|
|
|
8
8
|
`?`
|
|
9
9
|
`:" ",n++}i+=s?"$":" ",n++,l=g,r="";continue}if(u==="/"&&o(l,r)){let h=p(e,n);if(h!==-1){i+=`/${" ".repeat(h-n-2)}/`,n=h,l=g,r="";continue}}if(u==="`"){i+=s?"(":" ",n++;while(n<e.length&&e[n]!=="`"){if(e[n]==="\\"){i+=" ",n+=2;continue}if(e[n]==="$"&&e[n+1]==="{"){let h=n+2,a=Dl(e,h);if(i+=s?" {":" ",i+=w(e.slice(h,a),s),a<e.length)i+=s?"}":" ";n=a+1;continue}i+=e[n]===`
|
|
10
10
|
`?`
|
|
11
|
-
`:" ",n++}i+=s?")":" ",n++,l=g,r="";continue}if(i+=u,n++,/[\w$]/.test(u))r=/[\w$]/.test(l)?r+u:u,l=u;else if(!/\s/.test(u))l=u,r=""}return i}function
|
|
12
|
-
export{Dl,t,Bn,
|
|
11
|
+
`:" ",n++}i+=s?")":" ",n++,l=g,r="";continue}if(i+=u,n++,/[\w$]/.test(u))r=/[\w$]/.test(l)?r+u:u,l=u;else if(!/\s/.test(u))l=u,r=""}return i}function E(e){let s=new Uint16Array(e.length),i=0,n=!0;for(let l=0;l<e.length;l++){let r=e[l];if(r===")"||r==="]"||r==="}")if(i===0)n=!1;else i--;if(s[l]=i,r==="("||r==="["||r==="{")i++}return{depths:s,balanced:n&&i===0}}
|
|
12
|
+
export{Dl,t,Bn,E};
|
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{ye}from"./chunk-s29hp1qw.js";import"./chunk-295bykzd.js";import"./chunk-
|
|
3
|
+
import{ye}from"./chunk-s29hp1qw.js";import"./chunk-295bykzd.js";import"./chunk-n22xtagg.js";import"./chunk-hxhmhw23.js";import"./chunk-kwf3kfr0.js";import{Ve,nl}from"./chunk-mrjr0vtb.js";import"./chunk-6t04tqvh.js";import"./chunk-pk3pp1j5.js";import"./chunk-h63ma36g.js";import"./chunk-agd2b928.js";import"./chunk-ce1d71m1.js";import"./chunk-0rdh8bw3.js";import"./chunk-ssg6ne5b.js";import"./chunk-nxbws5qm.js";import"./chunk-63y8exx2.js";import"./chunk-kk92sv04.js";import"./chunk-d9hsqh1w.js";import"./chunk-8an1mp1z.js";import"./chunk-5p6xtzkk.js";import"./chunk-4n45qa0b.js";import"./chunk-kee5a3ce.js";import"./chunk-q74affc4.js";import"./chunk-gbncp2gp.js";import"./chunk-q1mb0fbt.js";import"./chunk-czcx3nbx.js";import"./chunk-p6yavy8h.js";import"./chunk-yp4tn4zn.js";import"./chunk-m4f13mrp.js";import"./chunk-fg67643b.js";import"./chunk-2r0nrvqe.js";import"./chunk-aaea157p.js";import"./chunk-94ctmp0j.js";import"./chunk-v9wt6jx2.js";import"./chunk-charhv8y.js";import"./chunk-c0g30cjs.js";import"./chunk-mejhzan9.js";import"./chunk-8va3fs07.js";import"./chunk-6nvm1dgn.js";import"./chunk-7dtfkf1b.js";import"./chunk-jbv448x5.js";import"./chunk-5xhaabn0.js";import"./chunk-a0q0kb0s.js";import"./chunk-8e1cv1hh.js";import"./chunk-ybjgnnyf.js";import"./chunk-9f31gs4m.js";import{gn,mn}from"./chunk-wh8yhpyh.js";import"./chunk-y3v0r845.js";import"./chunk-aw6m1t68.js";import"./chunk-sv7fdqmc.js";import"./chunk-a7ryj8z8.js";import"./chunk-463weehv.js";import"./chunk-shcnt6aa.js";import"./chunk-pdprhg5k.js";import"./chunk-5mmgdpjr.js";import"./chunk-p0rpdj1w.js";import{ba,wa,va,_o,xa,Sa,ka,Co,Eo,es,ts,ns}from"./chunk-2n2102vf.js";import"./chunk-rtehrddv.js";import"./chunk-59er0fc7.js";import"./chunk-ws3wfpy9.js";import"./chunk-qtbbc0h2.js";import"./chunk-d2pexm3z.js";import"./chunk-2v0pcxqs.js";import"./chunk-cb0c6959.js";import"./chunk-c47stwqj.js";import{Hc}from"./chunk-css5czqk.js";import{b}from"./chunk-94mpe1ny.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(f){let m=typeof f==="string"?Number.parseInt(f,10):f;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(f){try{if(!S.existsSync(f)){let h=p.dirname(f),t=p.basename(f);if(S.existsSync(h)){let o=S.readdirSync(h).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 ${h}: ${o.slice(0,3).join(", ")}`:`File not found. Directory ${h} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${f}`,suggestion:r}}return{isValid:!1,error:`File does not exist: ${f}`,suggestion:"Check the file path and try again"}}if(S.statSync(f).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${f}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(m){return{isValid:!1,error:`Cannot access file: ${f}`,suggestion:"Check file permissions and path"}}}function I(f){let m=typeof f==="string"?Number.parseInt(f,10):f;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=(f)=>f.includes("*")||f.includes("?")||f.includes("{")||f.includes("["),W=(f)=>f.endsWith(".stx")||f.endsWith(".md");function F(f,m=1){if(console.error(`\u274C ${f.error}`),f.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${f.suggestion}`);n.exit(m)}function M(f){if(!f)return;let m;try{m=JSON.parse(f)}catch(h){console.error(`\u274C --info-plist is not valid JSON: ${h.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[h,t]of Object.entries(m))if(typeof t!=="string"&&typeof t!=="number"&&typeof t!=="boolean")console.error(`\u274C --info-plist value for "${h}" must be a string, number or boolean`),n.exit(1);return m}async function V(f,m){try{let h=["test"],t=[];if(f&&f.length>0)for(let c of f)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(h.push(...t),m.filter)h.push("--pattern",m.filter);if(m.timeout)h.push("--timeout",m.timeout.toString());if(m.reporter&&m.reporter!=="default")if(m.reporter==="junit"){let c=p.resolve("stx-test-report.xml");h.push("--reporter",m.reporter),h.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)h.push("--coverage");if(m.watch)h.push("--watch");h.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} ${h.join(" ")}`);let r=performance.now(),s=R(o,h,{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(h){return console.error("Error running tests:",h instanceof Error?h.message:String(h)),!1}}var U=n.argv.length>=3&&(W(n.argv[2])&&S.existsSync(n.argv[2])||O(n.argv[2]));if(U){let f=n.argv[2],m={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let h=3;h<n.argv.length;h++){let t=n.argv[h];if(t==="--port"&&h+1<n.argv.length){let e=E(n.argv[++h]);if(!e.isValid)F(e);m.port=Number.parseInt(n.argv[h],10)}else if(t==="--no-watch")m.watch=!1;else if(t==="--highlight-theme"&&h+1<n.argv.length){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.defaultTheme=n.argv[++h]}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(f))try{let h=await Array.fromAsync(new Bun.Glob(f).scan({onlyFiles:!0,absolute:!0})),t=f.endsWith(".stx")?h.filter((s)=>s.endsWith(".stx")):f.endsWith(".md")?h.filter((s)=>s.endsWith(".md")):h.filter((s)=>s.endsWith(".stx")||s.endsWith(".md")),e=f.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: ${f}`),n.exit(1);if(!await ts(t,m))n.exit(1)}catch(h){console.error("Failed to process files:",h),n.exit(1)}else es(f,m).catch((h)=>{console.error("Failed to start dev server:",h),n.exit(1)})}else{let f=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 va(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-brzjass3.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-8h5nje66.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-8h5nje66.js"),{loadConfig:s}=await import("./chunk-1dhdt31n.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 ns(".",{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 ns(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 ye.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 ts(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 es(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 Hc(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-fdzpphww.js");mn();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-k3s16azh.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-pa6kgbmw.js");if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${Ve}\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,x),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){ye.clear(),console.log("\u2705 Performance statistics cleared");return}let o=ye.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-2mxqchs1.js"),{resolveStxTargets:s}=await import("./chunk-z7k1xn6k.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=ba(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.
|
|
@@ -135,8 +135,8 @@ ${d} files need formatting. Run 'stx format' to fix.`),n.exit(1);else if(!e.chec
|
|
|
135
135
|
`),n.exit(2);let g=u.diagnostics.filter((x)=>x.category==="error");if(u.diagnostics.length>0)console.error(`
|
|
136
136
|
${o(u.diagnostics)}
|
|
137
137
|
`);if(console.log(` Checked ${u.blockCount} script block(s) and ${u.expressionCount} template expression(s) in ${u.checkedFiles.length} file(s) \u2014 `+`${g.length} error(s), ${u.diagnostics.length-g.length} warning(s)
|
|
138
|
-
`),g.length>0)n.exit(1)}),y.command("codemod [patterns...]","Find hand-rolled code that an stx primitive already covers").option("--fix","Write the safe rewrites (default is report-only)").option("--rule <rule>","Run one rule only: confirm | tooltip (rewritable) \xB7 alert | route-params | search-params | navigate | "+"fetch | polling | debounce | click-outside | focus | clipboard | watch (report-only)").example("stx codemod").example("stx codemod --rule route-params").example('stx codemod --fix "resources/views/**/*.stx"').action(async(t,e)=>{let{codemodSource:o,formatCodemodFindings:r}=await import("./chunk-
|
|
139
|
-
${u} file(s) written.`)}),y.command("doctor","Diagnose the stx framework-runtime resolution + staleness chain").option("--json","Output the report as JSON").example("stx doctor").example("stx doctor --json").action(async(t)=>{try{let e;try{let r=await import("./chunk-
|
|
138
|
+
`),g.length>0)n.exit(1)}),y.command("codemod [patterns...]","Find hand-rolled code that an stx primitive already covers").option("--fix","Write the safe rewrites (default is report-only)").option("--rule <rule>","Run one rule only: confirm | tooltip (rewritable) \xB7 alert | route-params | search-params | navigate | "+"fetch | polling | debounce | click-outside | focus | clipboard | watch (report-only)").example("stx codemod").example("stx codemod --rule route-params").example('stx codemod --fix "resources/views/**/*.stx"').action(async(t,e)=>{let{codemodSource:o,formatCodemodFindings:r}=await import("./chunk-pc8dt8xs.js"),s=globalThis.Bun.Glob,c=Array.isArray(t)?t:t?[t]:[],i=c.length?c:["**/*.stx","**/*.ts"],l=e.rule?[e.rule]:void 0;if(e.rule&&e.rule!=="confirm"&&e.rule!=="tooltip")console.error(`Unknown rule "${e.rule}". Expected: confirm | tooltip`),n.exit(1);let d=new Set,a=[],u=0,g=new Set;try{let x=Bun.spawnSync(["git","ls-files","--others","--ignored","--exclude-standard","-z"],{cwd:n.cwd(),stdout:"pipe",stderr:"pipe"});for(let w of new TextDecoder().decode(x.stdout).split("\x00"))if(w)g.add(p.resolve(n.cwd(),w))}catch{}for(let x of i)for await(let w of new s(x).scan({cwd:n.cwd(),absolute:!0})){if(w.includes("/node_modules/")||w.includes("/dist/")||d.has(w)||g.has(w))continue;d.add(w);let k=await Bun.file(w).text(),v=o(k,{file:w,rules:l});if(a.push(...v.findings),e.fix&&v.code!==k)await Bun.write(w,v.code),u++}if(console.error(r(a,Boolean(e.fix))),e.fix)console.error(`
|
|
139
|
+
${u} file(s) written.`)}),y.command("doctor","Diagnose the stx framework-runtime resolution + staleness chain").option("--json","Output the report as JSON").example("stx doctor").example("stx doctor --json").action(async(t)=>{try{let e;try{let r=await import("./chunk-0gkxqcpj.js");e=r.generateSignalsRuntime}catch{e=void 0}let o=await Co({generateRuntime:e});if(t.json)console.log(JSON.stringify(o,null,2));else console.log(Eo(o));if(!o.ok)n.exit(1)}catch(e){console.error("Error running doctor:",e),n.exit(1)}}),y.command("debug <file>","Debug STX template processing step by step").option("--step","Step through processing stages interactively").option("--verbose","Show detailed processing information").option("--context <data>","JSON string of context data to use").option("--save-report <file>","Save debug report to file").example("stx debug template.stx").example("stx debug template.stx --step").example(`stx debug template.stx --context '{"name": "John", "items": [1,2,3]}'`).action(async(t,e)=>{try{let o=A(t);if(!o.isValid)F(o);console.log(`\uD83D\uDD0D Debugging stx template: ${t}
|
|
140
140
|
`);let r={};if(e.context)try{r=JSON.parse(e.context)}catch(i){console.error("\u274C Invalid JSON in --context option"),n.exit(1)}let s=await Bun.file(t).text();console.log(`\uD83D\uDCC4 Template Content (${s.length} chars):`),console.log("\u2500".repeat(50)),console.log(s.substring(0,500)+(s.length>500?`
|
|
141
141
|
...
|
|
142
142
|
`:"")),console.log("\u2500".repeat(50));let c=s.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(c)console.log(`
|
|
@@ -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-cv1vm1w0.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(Ve)}),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(Ve)}),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-8hbzej4h.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-4mw05zhy.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-46cghgdm.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-zch65qrd.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-wbmx0rge.js"),{runVisualTests:o,updateSnapshots:r,formatTestResults:s}=await import("./chunk-j5a3yrcf.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-8xh4ek56.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-h3fv0q25.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 x=p.join(d,`${a}.manifest.json`);if(S.writeFileSync(x,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: ${x}`),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(`
|
|
@@ -239,7 +239,8 @@ function extractTemplate(source) {
|
|
|
239
239
|
return (templateMatch ? templateMatch[1] : source).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, "").trim();
|
|
240
240
|
}
|
|
241
241
|
function extractStyles(source) {
|
|
242
|
-
return [...source.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((match) => match[1].
|
|
242
|
+
return [...source.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((match) => match[1].replace(/\r\n?/g, `
|
|
243
|
+
`).replaceAll("\x00", "\uFFFD").trim()).filter(Boolean).join(`
|
|
243
244
|
|
|
244
245
|
`);
|
|
245
246
|
}
|
|
@@ -1413,7 +1414,9 @@ ${details}` : ""}`);
|
|
|
1413
1414
|
name: component.name,
|
|
1414
1415
|
tag: component.tag,
|
|
1415
1416
|
source: component.sourcePath,
|
|
1416
|
-
module: path.join(outputDir, `${component.tag}.js`)
|
|
1417
|
+
module: path.join(outputDir, `${component.tag}.js`),
|
|
1418
|
+
styles: component.styles,
|
|
1419
|
+
shadowMode: component.shadowMode
|
|
1417
1420
|
})),
|
|
1418
1421
|
files,
|
|
1419
1422
|
manifest,
|
package/dist/craft-entry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-mrjr0vtb.js";import{Fo,Ha,Va}from"./chunk-57q4nvs9.js";import"./chunk-e362e615.js";import"./chunk-s29hp1qw.js";import"./chunk-295bykzd.js";import"./chunk-n22xtagg.js";import"./chunk-hxhmhw23.js";import"./chunk-kwf3kfr0.js";import"./chunk-6t04tqvh.js";import"./chunk-pk3pp1j5.js";import"./chunk-h63ma36g.js";import"./chunk-agd2b928.js";import"./chunk-ce1d71m1.js";import"./chunk-0rdh8bw3.js";import"./chunk-ssg6ne5b.js";import"./chunk-63y8exx2.js";import"./chunk-kk92sv04.js";import"./chunk-nxbws5qm.js";import"./chunk-d9hsqh1w.js";import"./chunk-8an1mp1z.js";import"./chunk-v9wt6jx2.js";import"./chunk-charhv8y.js";import"./chunk-c0g30cjs.js";import"./chunk-kee5a3ce.js";import{Fu,Ua,Kh,Gh,Wa,zo,ps,qa,Ka,Xh,Jh,Ga,Xa,Ja,Ya}from"./chunk-84xnev80.js";import"./chunk-rtehrddv.js";import"./chunk-qtbbc0h2.js";import"./chunk-d2pexm3z.js";import"./chunk-2v0pcxqs.js";import"./chunk-cb0c6959.js";import"./chunk-c47stwqj.js";import"./chunk-css5czqk.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"./chunk-
|
|
2
|
+
import"./chunk-mrjr0vtb.js";import{Fo,Ha,Va}from"./chunk-57q4nvs9.js";import"./chunk-e362e615.js";import"./chunk-s29hp1qw.js";import"./chunk-295bykzd.js";import"./chunk-n22xtagg.js";import"./chunk-hxhmhw23.js";import"./chunk-kwf3kfr0.js";import"./chunk-6t04tqvh.js";import"./chunk-pk3pp1j5.js";import"./chunk-h63ma36g.js";import"./chunk-agd2b928.js";import"./chunk-ce1d71m1.js";import"./chunk-0rdh8bw3.js";import"./chunk-ssg6ne5b.js";import"./chunk-63y8exx2.js";import"./chunk-kk92sv04.js";import"./chunk-nxbws5qm.js";import"./chunk-d9hsqh1w.js";import"./chunk-8an1mp1z.js";import"./chunk-v9wt6jx2.js";import"./chunk-charhv8y.js";import"./chunk-c0g30cjs.js";import"./chunk-kee5a3ce.js";import{Fu,Ua,Kh,Gh,Wa,zo,ps,qa,Ka,Xh,Jh,Ga,Xa,Ja,Ya}from"./chunk-84xnev80.js";import"./chunk-rtehrddv.js";import"./chunk-qtbbc0h2.js";import"./chunk-d2pexm3z.js";import"./chunk-2v0pcxqs.js";import"./chunk-cb0c6959.js";import"./chunk-c47stwqj.js";import"./chunk-css5czqk.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(`
|
|
@@ -9,6 +9,7 @@ import { collectMessageCatalogs } from "../../message-catalogs.js";
|
|
|
9
9
|
import { shareComponentScripts } from "./shared-scripts.js";
|
|
10
10
|
import { compactDocument, compactManifest } from "../runtime/compact-document.js";
|
|
11
11
|
import { buildSharedModuleRegistries, registeredModuleIdsIn, registeredModuleNamesIn } from "../../client-module-registry.js";
|
|
12
|
+
import { STX_RUNTIME_GLOBALS } from "../../runtime-globals.js";
|
|
12
13
|
export async function projectStyleConfig(root) {
|
|
13
14
|
try {
|
|
14
15
|
const { loadCssEngineConfig } = await import("../../dev-server/ts-css.js");
|
|
@@ -28,6 +29,23 @@ function nativeRuntimeModule(name) {
|
|
|
28
29
|
throw Error(`Native runtime module ${name} is missing`);
|
|
29
30
|
return resolved;
|
|
30
31
|
}
|
|
32
|
+
function nativeAuthoringRuntime() {
|
|
33
|
+
return {
|
|
34
|
+
name: "stx-native-authoring-runtime",
|
|
35
|
+
setup(builder) {
|
|
36
|
+
builder.onResolve({ filter: /^(?:stx|@stacksjs\/stx)$/ }, () => ({ path: "api", namespace: "stx-native-authoring-runtime" }));
|
|
37
|
+
builder.onLoad({ filter: /.*/, namespace: "stx-native-authoring-runtime" }, () => ({
|
|
38
|
+
loader: "js",
|
|
39
|
+
contents: STX_RUNTIME_GLOBALS.map((name) => `export function ${name}(...args) {
|
|
40
|
+
const runtime = globalThis.stx;
|
|
41
|
+
if (typeof runtime?.${name} !== 'function') throw new Error('STX native runtime is not ready for ${name}');
|
|
42
|
+
return runtime.${name}(...args);
|
|
43
|
+
}`).join(`
|
|
44
|
+
`)
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
31
49
|
async function build(entry, plugins, minify, dependencies, substitutes) {
|
|
32
50
|
const track = { name: "stx-screen-inputs", setup(builder) {
|
|
33
51
|
builder.onLoad({ filter: /.*/, namespace: "file" }, ({ path: file }) => {
|
|
@@ -40,7 +58,7 @@ async function build(entry, plugins, minify, dependencies, substitutes) {
|
|
|
40
58
|
target: "browser",
|
|
41
59
|
format: "iife",
|
|
42
60
|
minify,
|
|
43
|
-
plugins: [track, ...plugins],
|
|
61
|
+
plugins: [track, nativeAuthoringRuntime(), ...plugins],
|
|
44
62
|
define: { "process.env.NODE_ENV": JSON.stringify(minify ? "production" : "development") }
|
|
45
63
|
});
|
|
46
64
|
if (!result.success) {
|
|
@@ -21,6 +21,20 @@ export declare function mustacheBinding(text: string): string | null;
|
|
|
21
21
|
export declare function translateHtmlToIR(html: string, options?: TranslateOptions): Promise<TranslationResult>;
|
|
22
22
|
/** The same translation, wrapped in an `STXDocument` for the renderers. */
|
|
23
23
|
export declare function translateHtmlToDocument(html: string, options?: TranslateOptions & { script?: STXDocument['script'] }): Promise<{ document: STXDocument, diagnostics: TranslationDiagnostic[] }>;
|
|
24
|
+
/**
|
|
25
|
+
* End tags that close nothing, by tag name, in document order.
|
|
26
|
+
*
|
|
27
|
+
* An HTML parser forgives one extra `</div>`: every element after it closes a
|
|
28
|
+
* tag early, and the last end tag of the run has nothing left to close and is
|
|
29
|
+
* dropped. Nothing fails. The tree is simply not the one written: the rest of
|
|
30
|
+
* a conditional block is hoisted out of its `:if` and stays on screen when the
|
|
31
|
+
* block goes, and what followed the block lands outside its parent. A first-run
|
|
32
|
+
* tour kept its page dots and Continue button above every question that way.
|
|
33
|
+
*
|
|
34
|
+
* Only an end tag with no open element of its name is reported. One that skips
|
|
35
|
+
* over open elements closes them, as HTML allows for `<p>` and `<li>`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function strayEndTags(html: string): string[];
|
|
24
38
|
/** Explicit website-only markup; unlike chrome this does not configure app navigation. */
|
|
25
39
|
export declare function excludeNativeSubtrees(html: string): Promise<string>;
|
|
26
40
|
/**
|
|
@@ -61,6 +75,8 @@ export type TranslationDiagnosticKind = | 'unmapped-tag'
|
|
|
61
75
|
| 'unsupported-list-prop'
|
|
62
76
|
/** A control with no supported native interaction contract. */
|
|
63
77
|
| 'unsupported-control'
|
|
78
|
+
/** An end tag with nothing open to close: the parser drops it, and the element it was written after closed one tag early. */
|
|
79
|
+
| 'stray-end-tag'
|
|
64
80
|
/** A theme declaration cannot be evaluated faithfully on the native target. */
|
|
65
81
|
| 'unsupported-theme-rule'
|
|
66
82
|
| 'unsupported-style-rule';
|