@stacksjs/stx 0.2.863 → 0.2.865
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-gp8hgpt9.js → chunk-01mwbg1r.js} +3 -3
- package/dist/{chunk-k7dxm48r.js → chunk-0dyec13e.js} +1 -1
- package/dist/{chunk-fnv94wc6.js → chunk-0v2yj490.js} +1 -1
- package/dist/chunk-16qzr5ga.js +2 -0
- package/dist/chunk-2hq6mq6r.js +2 -0
- package/dist/chunk-2qjyzekc.js +3 -0
- package/dist/{chunk-czca8yds.js → chunk-46x7a1cj.js} +1 -1
- package/dist/chunk-49r1z20v.js +2 -0
- package/dist/chunk-4b0mjyn7.js +2 -0
- package/dist/{chunk-y190sh29.js → chunk-4q0rgnw0.js} +9 -9
- package/dist/{chunk-5zzrrxns.js → chunk-4sfrfag1.js} +4 -4
- package/dist/{chunk-zsnmk5me.js → chunk-5dvkphbe.js} +1 -1
- package/dist/{chunk-qxw9h564.js → chunk-5ep1qbjt.js} +1 -1
- package/dist/{chunk-v408qsze.js → chunk-5kkq2eqr.js} +1 -1
- package/dist/{chunk-85zmxbt0.js → chunk-67xreg70.js} +4 -4
- package/dist/{chunk-gjngg182.js → chunk-6pqfar3p.js} +8 -8
- package/dist/{chunk-wk4wg6sn.js → chunk-764f1sf1.js} +2 -2
- package/dist/chunk-77km1je8.js +2 -0
- package/dist/{chunk-prrvggcy.js → chunk-78eyz4ch.js} +1 -1
- package/dist/{chunk-8502xb4n.js → chunk-79y9amt1.js} +7 -7
- package/dist/{chunk-8v1zpdef.js → chunk-7chzhef2.js} +1 -1
- package/dist/{chunk-sj3ry5ck.js → chunk-7xhwqc0c.js} +7 -1
- package/dist/chunk-822gnnpd.js +2 -0
- package/dist/{chunk-mfa07erx.js → chunk-83tvkw4y.js} +1 -1
- package/dist/{chunk-gw7t6a3t.js → chunk-86xt8cs8.js} +1 -1
- package/dist/{chunk-ntbe5q5x.js → chunk-8efn9agz.js} +2 -2
- package/dist/{chunk-58sh82aj.js → chunk-97cyjqa5.js} +1 -1
- package/dist/{chunk-jfmj0wsy.js → chunk-98v8smzf.js} +1 -1
- package/dist/chunk-9cwag0tk.js +2 -0
- package/dist/{chunk-32ty2zx6.js → chunk-9tsp5ytb.js} +1 -1
- package/dist/{chunk-xfd3yqgj.js → chunk-a2yk8sw0.js} +12 -12
- package/dist/chunk-aef82ns3.js +2 -0
- package/dist/{chunk-reeaknf2.js → chunk-ajkqbjbp.js} +1 -1
- package/dist/chunk-angv3d3s.js +2 -0
- package/dist/{chunk-z383x16t.js → chunk-aqn8y42n.js} +1 -1
- package/dist/{chunk-46ddesnf.js → chunk-b666d8m6.js} +1 -1
- package/dist/{chunk-vwwpbhd2.js → chunk-bzt73fj0.js} +1 -1
- package/dist/chunk-c2bhc5wg.js +2 -0
- package/dist/{chunk-ztbexx3h.js → chunk-c57g2mtw.js} +1 -1
- package/dist/{chunk-yakdcak2.js → chunk-c60qda5c.js} +1 -1
- package/dist/{chunk-az5xw3w8.js → chunk-cjy9cdm0.js} +1 -1
- package/dist/{chunk-nttsc0aw.js → chunk-dx2t73jn.js} +5 -5
- package/dist/{chunk-5p1k2h5q.js → chunk-dy1d7ep7.js} +1 -1
- package/dist/{chunk-yr1zx78b.js → chunk-e8y2c1sq.js} +2 -2
- package/dist/{chunk-1grdbpsk.js → chunk-efjmpq6r.js} +2 -2
- package/dist/{chunk-g4gcf4jn.js → chunk-et9pa7gr.js} +1 -1
- package/dist/chunk-f52b9hjv.js +2 -0
- package/dist/{chunk-021tjkd6.js → chunk-f57t1bcs.js} +1 -1
- package/dist/{chunk-qmkaqjba.js → chunk-f5vdse5a.js} +1 -1
- package/dist/{chunk-bx5d87xx.js → chunk-f6ypmk8x.js} +1 -1
- package/dist/{chunk-y036cwc7.js → chunk-fbtm3frc.js} +2 -2
- package/dist/{chunk-s9df8srx.js → chunk-fd1bpv35.js} +3 -3
- package/dist/{chunk-5s1fb8z4.js → chunk-fm9kas0a.js} +1 -1
- package/dist/{chunk-0xtda6aw.js → chunk-fmzyrg2e.js} +1 -1
- package/dist/{chunk-h816ta81.js → chunk-fnha6bbj.js} +2 -2
- package/dist/{chunk-qa5y30sy.js → chunk-g0xn80gz.js} +7 -7
- package/dist/{chunk-pyckafsb.js → chunk-g8zgfmk3.js} +1 -1
- package/dist/chunk-gp7derwj.js +2 -0
- package/dist/{chunk-wtfamngc.js → chunk-gwa31y9x.js} +4 -4
- package/dist/{chunk-x3p4emdp.js → chunk-hdyacfen.js} +1 -1
- package/dist/{chunk-jgra00m8.js → chunk-hwqrejq3.js} +1 -1
- package/dist/{chunk-w468n41y.js → chunk-j4mtcbvz.js} +18 -18
- package/dist/{chunk-xymr4ys9.js → chunk-jbgj2hph.js} +1 -1
- package/dist/{chunk-x512h2gv.js → chunk-kh6njq2r.js} +2 -2
- package/dist/{chunk-2n932qtv.js → chunk-mkyn95mf.js} +1 -1
- package/dist/{chunk-dtarm8x9.js → chunk-nack2xs5.js} +4 -4
- package/dist/{chunk-xcjvx6zt.js → chunk-p2f308sq.js} +1 -1
- package/dist/{chunk-zr22gtpf.js → chunk-p8apfhg9.js} +1 -1
- package/dist/{chunk-dpmayc2w.js → chunk-r0v2chpn.js} +2 -2
- package/dist/chunk-razx95wk.js +2 -0
- package/dist/{chunk-2c18y094.js → chunk-rb41t77f.js} +1 -1
- package/dist/{chunk-b6w0f610.js → chunk-rkd27m4m.js} +19 -19
- package/dist/{chunk-669b2bya.js → chunk-rw5492e2.js} +3 -3
- package/dist/chunk-tx6t331f.js +2 -0
- package/dist/chunk-v4pswhj1.js +2 -0
- package/dist/{chunk-15m7jnc0.js → chunk-w19myass.js} +1 -1
- package/dist/{chunk-r4v4vswq.js → chunk-w1vk83kx.js} +1 -1
- package/dist/{chunk-p0tkhd12.js → chunk-w8qr5414.js} +1 -1
- package/dist/chunk-x1zzy6c7.js +2 -0
- package/dist/{chunk-qbghf76y.js → chunk-x64afx6z.js} +2 -2
- package/dist/chunk-x95031qg.js +2 -0
- package/dist/{chunk-ks5p5w6z.js → chunk-xempkjvd.js} +1 -1
- package/dist/{chunk-yhc1c4tr.js → chunk-xt1cxmkx.js} +52 -52
- package/dist/chunk-yq0kcw7h.js +2 -0
- package/dist/chunk-z4yzk0d4.js +2 -0
- package/dist/chunk-z6c4c951.js +2 -0
- package/dist/chunk-z98qxjne.js +2 -0
- package/dist/{chunk-d0afg5f7.js → chunk-zacjg4p1.js} +1 -1
- package/dist/{chunk-hc6111md.js → chunk-zfd9dmsn.js} +4 -4
- package/dist/cli.js +13 -13
- package/dist/client/signals-component-props-runtime.js +7 -1
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/floating-actions-web.d.ts +20 -0
- package/dist/native/floating-actions-web.js +177 -0
- package/dist/native/floating-actions.d.ts +8 -1
- package/dist/native/floating-actions.js +1 -1
- package/dist/native/primitives/FloatingActions.stx +22 -2
- package/dist/pwa.js +3 -3
- package/dist/site-builder/build.d.ts +6 -0
- package/dist/site-builder/build.js +13 -3
- package/dist/site-builder/types.d.ts +3 -0
- package/dist/ssg.js +4 -4
- package/package.json +5 -5
- package/dist/chunk-0bfgsv31.js +0 -2
- package/dist/chunk-36j129p1.js +0 -2
- package/dist/chunk-7mjf144y.js +0 -2
- package/dist/chunk-a4cn8rf4.js +0 -2
- package/dist/chunk-ap84eenm.js +0 -2
- package/dist/chunk-as2ffje6.js +0 -2
- package/dist/chunk-c0t2tdfk.js +0 -2
- package/dist/chunk-caxqwrnc.js +0 -2
- package/dist/chunk-d9vzfbdp.js +0 -2
- package/dist/chunk-e634vffz.js +0 -3
- package/dist/chunk-g65dptx2.js +0 -2
- package/dist/chunk-kw11yydy.js +0 -2
- package/dist/chunk-ns04v3am.js +0 -2
- package/dist/chunk-p2etn78y.js +0 -2
- package/dist/chunk-r23zq8yk.js +0 -2
- package/dist/chunk-rqmb09ss.js +0 -2
- package/dist/chunk-sz6d3v6b.js +0 -2
- package/dist/chunk-va07zs9v.js +0 -2
- package/dist/chunk-vc42mvjn.js +0 -2
- package/dist/chunk-xzdkjkyp.js +0 -2
- package/dist/chunk-ybkwnscv.js +0 -2
- package/dist/chunk-z3gz5fy4.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{P,d,m,O,p,J}from"./chunk-
|
|
2
|
+
import{P,d,m,O,p,J}from"./chunk-g0xn80gz.js";import{q,js,je,he,Mt,Ar,Ve,Ue,s,y,Te,R}from"./chunk-rkd27m4m.js";import{ft}from"./chunk-qjey0jk6.js";import{N}from"./chunk-farh4p7f.js";import{le}from"./chunk-jbgj2hph.js";import{H,nt}from"./chunk-8s6s6nd0.js";import{A,Pn}from"./chunk-bwdbj60y.js";import M from"path";import{existsSync as ye}from"fs";function ce(c,e){let a=0;for(let r=e;r<c.length;r++){let b=c[r];if(b==="("||b==="["||b==="{")a++;else if(b===")"||b==="]"||b==="}")a--;else if(b===","&&a===0)return r}return-1}function $e(c,e,a){let r=c,b=new RegExp(`${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),n=b.exec(r);while(n){let u=n.index,t=u+n[0].length-1,T=1,L=t+1;while(L<r.length&&T>0){if(r[L]==="(")T++;else if(r[L]===")")T--;L++}if(T!==0)break;let re=r.substring(t+1,L-1),B=`${a}(${re})`;r=r.substring(0,u)+B+r.substring(L),b.lastIndex=u+B.length,n=b.exec(r)}return r}function Ee(c){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(c)}function me(c){let e=c,a=[],r=new Set,b=0,n=0,u=e.length,t=(B)=>{n++;while(n<u){if(e[n]==="\\"){n+=2;continue}if(e[n]===B){n++;return}n++}},T=()=>{n++;while(n<u){if(e[n]==="\\"){n+=2;continue}if(e[n]==="`"){n++;return}if(e[n]==="$"&&e[n+1]==="{"){n+=2;let B=1;while(n<u&&B>0)if(e[n]==="{")B++,n++;else if(e[n]==="}")B--,n++;else if(e[n]==="'"||e[n]==='"')t(e[n]);else if(e[n]==="`")T();else n++;continue}n++}},L=()=>{if(e[n]==="/"&&e[n+1]==="/"){while(n<u&&e[n]!==`
|
|
3
3
|
`)n++;return!0}if(e[n]==="/"&&e[n+1]==="*"){n+=2;while(n<u-1&&!(e[n]==="*"&&e[n+1]==="/"))n++;return n+=2,!0}return!1},re=()=>{if(b!==0)return;let B=e.slice(n).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(B){let U=B[2];if(!r.has(U))a.push(U),r.add(U);return}let te=e.slice(n).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(te){let U=te[1];if(!r.has(U))a.push(U),r.add(U);return}let Y=e.slice(n).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(Y){let U=Y[1];if(!r.has(U))a.push(U),r.add(U)}};while(n<u){if(L())continue;if(e[n]==="'"||e[n]==='"'){t(e[n]);continue}if(e[n]==="`"){T();continue}if(e[n]==="{"){b++,n++;continue}if(e[n]==="}"){b--,n++;continue}if(b===0&&/[a-z]/i.test(e[n])&&(n===0||/\s|[;{}()]/.test(e[n-1])))re();n++}return a.join(", ")}function ve(c,e=""){let a=me(c).split(",").map((r)=>r.trim()).filter(Boolean);return`
|
|
4
4
|
(function() {
|
|
5
5
|
${ft("var",a)}
|
|
@@ -44,10 +44,10 @@ ${n}
|
|
|
44
44
|
}
|
|
45
45
|
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
46
46
|
}
|
|
47
|
-
})();`;return a+c+r}function Me(c,e){if(H(c)){let n=H(c).tag.match(/data-stx-scope="([^"]*)"/);if(n)return{html:c,mergedIntoExisting:n[1],stamped:!0,root:"body"};return{html:nt(c,(u,t)=>`<body${t} data-stx-scope="${e}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let a=
|
|
47
|
+
})();`;return a+c+r}function Me(c,e){if(H(c)){let n=H(c).tag.match(/data-stx-scope="([^"]*)"/);if(n)return{html:c,mergedIntoExisting:n[1],stamped:!0,root:"body"};return{html:nt(c,(u,t)=>`<body${t} data-stx-scope="${e}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let a=Mt(c),r=c.slice(a).match(/^(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(r){let b=r[1]+r[2],n=r[1].slice(1),u=b.match(/data-stx-scope="([^"]*)"/);if(u)return{html:c,mergedIntoExisting:u[1],stamped:!0,root:n};let t=c.slice(0,a),T=r[1],L=r[2];return{html:`${t}${T} data-stx-scope="${e}"${L}${c.slice(a+r[0].length)}`,mergedIntoExisting:null,stamped:!0,root:n}}return{html:c,mergedIntoExisting:null,stamped:!1,root:null}}var Ae=0;function ue(c,e){let a=M.basename(c,".stx").replace(/[^a-zA-Z0-9]/g,"_"),r=e.__stx_scope_seq;return r?`stx_scope_${a}_${++r.n}_${r.key}`:`stx_scope_${a}_${++Ae}`}var ae=new Set,pe=new Set;function qh(){ae.clear(),pe.clear()}var Ce=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Gf(c){let e=(t)=>t.replace(/[^\n]/g," "),a=c.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,e).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,e).replace(/<!--[\s\S]*?-->/g,e).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,e).replace(/\{\{[\s\S]*?\}\}/g,e).replace(/\{!![\s\S]*?!!\}/g,e),r=[],b=0,n=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,u;while((u=n.exec(a))!==null){let t=u[1]==="/",T=u[2],L=u[3]==="/"||Ce.has(T.toLowerCase());if(t){b=Math.max(0,b-1);continue}if(b===0)r.push(T);if(!L)b++}return r}function fe(c){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(c)}var tt=new P(500),wc=new Set;function Kh(){wc.clear()}function De(c){if(c.__onceStore instanceof Set)return c.__onceStore;return wc}async function gs(c,e,a,r,b,n=new Set){let u=r.partialsDir||M.join(M.dirname(a),"partials");if(u&&!M.isAbsolute(u))u=M.resolve(process.cwd(),u);let t=$e(c,"@partial","@include"),T=De(e);t=t.replace(/@once([\s\S]*?)@endonce/g,(f,v,h)=>{let g=v.trim(),i=`${a}:${g}`;if(T.has(i))return"";return T.add(i),v});{let f=/@includeIf\s*\(/g,v;while((v=f.exec(t))!==null){let h=v.index,g=h+v[0].length-1,i=1,x=g+1;while(x<t.length&&i>0){if(t[x]==="(")i++;else if(t[x]===")")i--;x++}if(i!==0)break;let l=t.substring(g+1,x-1),o=l.match(/^\s*['"]([^'"]+)['"]/);if(!o){f.lastIndex=x;continue}let C=o[1],W=L(C,u,a),E="";if(W&&await Bun.file(W).exists())b.add(W),E=`@include(${l})`;t=t.substring(0,h)+E+t.substring(x),f.lastIndex=0}}for(let[f,v]of[["@includeWhen",!1],["@includeUnless",!0]]){let h=new RegExp(`${f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),g;while((g=h.exec(t))!==null){let i=g.index,x=i+g[0].length-1,l=1,o=x+1;while(o<t.length&&l>0){if(t[o]==="(")l++;else if(t[o]===")")l--;o++}if(l!==0)break;let C=t.substring(x+1,o-1),W=ce(C,0);if(W===-1){h.lastIndex=o;continue}let E=C.substring(0,W).trim(),Z=C.substring(W+1).trim(),z=Z.match(/^\s*['"]([^'"]+)['"]/);if(!z){h.lastIndex=o;continue}let _=z[1],K=Z.substring(z[0].length),D,k=ce(K,0);if(k!==-1)D=K.substring(k+1).trim();try{let I=`Boolean(${E})`,j;if(m(I)){let ie=p(I,Object.keys(e));j=Boolean(ie(...Object.values(e)))}else j=Boolean(d(I,e));let ee=v?!j:j,ne="";if(ee){let ie=L(_,u,a);if(ie&&await Bun.file(ie).exists())b.add(ie);ne=`@include('${_}'${D?`, ${D}`:""})`}t=t.substring(0,i)+ne+t.substring(o),h.lastIndex=0}catch(I){let j=I instanceof Error?I.message:String(I),ee=y("Include",`Error evaluating ${f} condition: ${j}`,a,c,i);t=t.substring(0,i)+ee+t.substring(o),h.lastIndex=0}}}{let f=/@each\s*\(/g,v;while((v=f.exec(t))!==null){let h=v.index,g=h+v[0].length-1,i=1,x=g+1;while(x<t.length&&i>0){if(t[x]==="(")i++;else if(t[x]===")"){if(i--,i===0)break}x++}if(i!==0)break;let l=t.substring(g+1,x),o=t.substring(h,x+1),C=l.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!C){f.lastIndex=0,t=t.replace(o,"");continue}let[,W,E,Z,z]=C;try{let _,K=E.trim();if(m(K))_=p(K,Object.keys(e))(...Object.values(e));else _=d(K,e);let D="";if(Array.isArray(_)&&_.length>0)for(let k of _){let I={...e,[Z]:k},j=await te(W,I,c,h);D+=j}else if(z)D=await te(z,{},c,h);t=t.substring(0,h)+D+t.substring(x+1),f.lastIndex=0}catch(_){let K=_ instanceof Error?_.message:String(_);t=t.substring(0,h)+y("Each",`Error in @each: ${K}`,a,c,h)+t.substring(x+1),f.lastIndex=0}}}{let f=/@includeFirst\s*\(/g,v;while((v=f.exec(t))!==null){let h=v.index,g=h+v[0].length-1,i=1,x=g+1;while(x<t.length&&i>0){if(t[x]==="(")i++;else if(t[x]===")"){if(i--,i===0)break}x++}if(i!==0)break;let l=t.substring(g+1,x),o=t.substring(h,x+1),C=l.match(/^\s*(\[[^\]]+\])/);if(!C){f.lastIndex=0,t=t.replace(o,"");continue}let W=C[1],E=l.slice(C[0].length),Z,z=E.match(/^\s*,\s*\{/);if(z){E=E.slice(z[0].length-1);let D=1,k=1;while(k<E.length&&D>0){if(E[k]==="{")D++;else if(E[k]==="}"){if(D--,D===0)break}k++}Z=E.substring(0,k+1),E=E.slice(k+1)}let _,K=E.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(K)_=K[1];try{let D=JSON.parse(W.replace(/'/g,'"')),k={};if(Z)try{k=O(Z,e)}catch(j){let ee=j instanceof Error?j.message:String(j);if(r.debug){let ne=y("Include",`Error parsing includeFirst variables: ${ee}`,a,c,h,o);t=t.replace(o,()=>ne)}else t=t.replace(o,()=>_||"");continue}let I=!1;for(let j of D){let ee=L(j,u,a);if(!ee)continue;if(await s(ee)){let ne=await te(j,k,c,h);t=t.replace(o,()=>ne),I=!0;break}}if(!I)if(_!==void 0)t=t.replace(o,()=>_);else if(r.debug){let j=y("Include",`None of the includeFirst paths exist: ${W}`,a,c,h,o);t=t.replace(o,()=>j)}else t=t.replace(o,"")}catch(D){let k=D instanceof Error?D.message:String(D),I=y("Include",`Error processing @includeFirst: ${k}`,a,c,h,o);t=t.replace(o,()=>I)}f.lastIndex=0}}function L(f,v,h){try{let g=f;if(!f.endsWith(".stx"))g=`${f}.stx`;let i=M.resolve(v),x=M.resolve(M.dirname(h)),l;if(!g.startsWith("./")&&!g.startsWith("../")){for(let z of r._layerPartialDirs??[]){let _=M.resolve(z,g);if(_.startsWith(`${M.resolve(z)}${M.sep}`)&&ye(_))return _}l=M.resolve(v,g)}else l=M.resolve(x,g);let o=M.normalize(l),C=o.startsWith(i+M.sep)||o===i,W=o.startsWith(x+M.sep)||o===x,E=!1,Z=M.dirname(x);if(o.startsWith(Z+M.sep)){if(!M.relative(Z,o).split(M.sep).some((D)=>D.startsWith(".")&&D!=="."&&D!==".."))E=!0}if(!C&&!W&&!E)return console.error(`Security: Path traversal attempt blocked for include path: ${f}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${i}, ${x}`),null;return o}catch(g){return console.error(`Error resolving path ${f}: ${g}`),null}}let re=M.resolve(a);n.add(re);function B(f,v,h,g){return r.onIncludeError?.({includePath:f,templatePath:a,message:v,partialsDir:u}),y("Include",v,a,h,g)}async function te(f,v={},h,g){let i=L(f,u,a);if(!i)return B(f,`Could not resolve path for include: ${f}`,h,g);let x=M.resolve(i);if(n.has(x)){let l=[...n,x].map((o)=>M.basename(o)).join(" -> ");return B(f,`Circular include detected: ${l}`,h,g)}try{b.add(i);let l;if(!l)try{l=await Bun.file(i).text()}catch(S){let X=S instanceof Error?S.message:String(S);return B(f,`Error loading include file ${f}: ${X}`,h,g)}if(l)l=l.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(l&&l.includes("@stream")){let{processStreamDirectives:S}=await import("./chunk-razx95wk.js");l=S(l,e)}if(l&&(r.debug||!A()&&!Pn()))try{let{warnUnbalancedTags:S}=await import("./chunk-vk98r75z.js");S(l,i)}catch{}try{let{processESImports:S}=await import("./chunk-yq0kcw7h.js");l=await S(l,e,i,r,b)}catch(S){if(r.debug)console.warn(`[stx] partial ES import extraction skipped for ${i}:`,S instanceof Error?S.message:S)}let o=l,C=he(o);if(C)o=C.content.trim();let E=l.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),Z="";if(E)Z=`<style${E[1]}>${E[2]}</style>`;let z=[];o=o.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(S,X,w)=>{if(!fe(X))return"";return z.push({attrs:X,body:w}),`__STX_DATA_BLOCK_${z.length-1}__`}),o=o.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let _={...e};_.__stx_signals_gate=Te(l,i);for(let[S,X]of Object.entries(v))_[S]=X;let K=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,D=[...l.matchAll(K)].sort((S,X)=>{let w=(S[1]||"").includes("server"),V=(X[1]||"").includes("server");return Number(V)-Number(w)}),k="",I=null,j=!1,ee=!1;for(let S of D){let X=S[1]||"",w=S[2]||"";if(fe(X))continue;let V=X.includes("server"),be=Ve(X);if(!V&&!/\bsrc\s*=/i.test(X))je(w,i,r.strict);if(!V&&w.trim()){let{interpolateScriptExpressions:F}=await import("./chunk-c57g2mtw.js");w=F(w,_,f)}let oe="";try{let{extractAndStripCssImports:F,renderVendorStyleTags:Q}=await import("./chunk-98v8smzf.js"),se=F(w,{filePath:i,projectRoot:process.cwd()});w=se.code,oe=Q(se.styles)}catch(F){if(r.debug)console.warn(`[stx] vendor-css extractor skipped for ${i}:`,F instanceof Error?F.message:F)}if(be&&w.trim())w=Ue(w);if(!V){try{let{injectBrowserCoreAutoImports:Q}=await import("./chunk-98v8smzf.js");w=Q(w).code;let{hasUserImports:se,bundleClientScript:Se}=await import("./chunk-x95031qg.js");if(se(w))w=await Se(w,i,{projectRoot:process.cwd()})}catch(Q){if(r.debug)console.warn(`[stx] bundler skipped for ${i}:`,Q instanceof Error?Q.message:Q)}let{stripStxRuntimeImports:F}=await import("./chunk-f5vdse5a.js");w=F(w)}let de=Ee(w);if(!V){let{extractBridgeData:F,generateServerDataBridge:Q}=await import("./chunk-98v8smzf.js"),se=Q(w,F(_));if(se)w=`${se}
|
|
48
48
|
${w}`}if(de&&!V){j=!0,I=ue(i,e);let F=N(w),Q=ge(F,I);k+=`${oe}<script data-stx-scoped data-stx-run="always" data-stx-owner="${I}">${Q}</script>
|
|
49
|
-
`;continue}if(V)try{let{extractVariables:F}=await import("./chunk-
|
|
50
|
-
`}}if(z.length>0){let{interpolateScriptExpressions:S}=await import("./chunk-
|
|
49
|
+
`;continue}if(V)try{let{extractVariables:F}=await import("./chunk-hdyacfen.js");await F(w,_,i)}catch(F){if(r.debug)console.warn(`Warning: Could not extract variables from server script in ${i}:`,F)}if(!V&&!de){let F=X.replace(/\bclient\b/i,"").trim();I=ue(i,e);let Q=N(w),se=ge(Q,I);if(/__scopeRegistration\["(?!__stx)[^"]+"\]\s*=|Object\.defineProperty\(__scopeRegistration, "(?!__stx)/.test(se))ee=!0;k+=`${oe}<script data-stx-scoped data-stx-run="always" data-stx-owner="${I}"${F?` ${F}`:""}>${se}</script>
|
|
50
|
+
`}}if(z.length>0){let{interpolateScriptExpressions:S}=await import("./chunk-c57g2mtw.js");o=o.replace(/__STX_DATA_BLOCK_(\d+)__/g,(X,w)=>{let V=z[Number(w)];return`<script${V.attrs}>${S(V.body,_,f)}</script>`})}if(I){let S=Me(o,I);if(o=S.html,S.mergedIntoExisting){let w=I,V=S.mergedIntoExisting;k=k.split(`'${w}'`).join(`'${V}'`).split(`"${w}"`).join(`"${V}"`),I=V}else if(!S.stamped&&j&&!ae.has(i))ae.add(i),console.warn(`[stx] ${M.relative(process.cwd(),i)} declares signals but has no element to scope them to, so nothing in it will hydrate. Wrap the partial's markup in a single root element.`);if(S.stamped&&S.root!=="body"&&(j||ee)&&!pe.has(i)){let w=Gf(o);if(w.length>1)pe.add(i),console.warn(`[stx] ${M.relative(process.cwd(),i)} declares ${j?"signals":"bindings"} and has ${w.length} top-level elements (${w.map((V)=>`<${V}>`).join(", ")}). Only the first is scoped, so bindings in the others cannot see what this partial's script declares. Wrap the partial's markup in a single root element.`)}let X=S.stamped&&S.root!==null&&Ar(S.root);k=ke(k,X?I:null)}if(o.includes("@include")||o.includes("@partial"))o=await gs(o,_,i,r,b,n);let{processLoops:ne,reportDeferredLoopWarnings:ie}=await import("./chunk-v4pswhj1.js"),G=ne(o,_,i,void 0,!0);G=le(G,_,i),G=ie(G);let{processMetaDirectives:xe,processSeoDirective:_e,processStructuredData:we}=await import("./chunk-fmzyrg2e.js");if(G=xe(G,_,i,r),G=we(G,_,i),G=_e(G,_,i,r),G=R(G,_,i),Z)G+=`
|
|
51
51
|
`+Z;if(k)G+=`
|
|
52
52
|
`+k;return G}catch(l){if(l instanceof J)throw l;let o=l instanceof Error?l.message:String(l);return B(f,`Error processing include ${f}: ${o}`,h,g)}}let Y=/@include\s*\(/g,U;while((U=Y.exec(t))!==null){let f=U.index,v=f+U[0].length-1,h=1,g=v+1;while(g<t.length&&h>0){if(t[g]==="(")h++;else if(t[g]===")")h--;g++}if(h!==0)break;let i=t.substring(f,g),x=t.substring(v+1,g-1),l=x.match(/^\s*['"]([^'"]+)['"]/);if(!l){Y.lastIndex=g;continue}let o=l[1],C,W=x.substring(l[0].length),E=ce(W,0);if(E!==-1)C=W.substring(E+1).trim();let Z={};if(C)try{Z=O(C,e)}catch(_){let K=_ instanceof Error?_.message:String(_);t=t.replace(i,y("Include",`Error parsing include variables for ${o}: ${K}`,a,c,f)),Y.lastIndex=0;continue}let z=await te(o,Z,c,f);t=t.substring(0,f)+z+t.substring(g),Y.lastIndex=0}return t}function ms(c,e){let a=c;function r(b,n,u,t){let T=b,L=!0;while(L){L=!1;let re=new RegExp(`@${n}\\(['"]([^'"]+)['"]\\)`),B=T.match(re);if(!B||B.index===void 0)break;let te=B.index,Y=B[1],U=te+B[0].length,f=new RegExp(`@${n}\\(`),v=new RegExp(`@${u}(?![a-z])`),h=1,g=U,i=-1;while(h>0&&g<T.length){let l=T.slice(g),o=l.match(f),C=l.match(v),W=o?g+o.index:1/0,E=C?g+C.index:1/0;if(W<E)h++,g=W+(o[0].length||1);else if(E<1/0){if(h--,h===0){i=E;break}g=E+u.length+1}else break}if(i===-1)break;let x=T.slice(U,i);if(!e[Y])e[Y]=[];if(t)e[Y].unshift(x);else e[Y].push(x);T=T.substring(0,te)+T.substring(i+`@${u}`.length),L=!0}return T}return a=r(a,"push","endpush",!1),a=r(a,"prepend","endprepend",!0),a}function hs(c,e){return c.replace(/@stack\(['"]([^'"]+)['"]\)/g,(a,r)=>{if(!e[r]||e[r].length===0)return"";return e[r].join(`
|
|
53
53
|
`)})}
|
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{pe}from"./chunk-
|
|
3
|
+
import{pe}from"./chunk-g0xn80gz.js";import"./chunk-qjey0jk6.js";import"./chunk-farh4p7f.js";import{Me}from"./chunk-rkd27m4m.js";import"./chunk-k32q90b2.js";import"./chunk-0dyec13e.js";import"./chunk-tnp2ta5q.js";import"./chunk-kh6njq2r.js";import"./chunk-xt1cxmkx.js";import"./chunk-83tvkw4y.js";import"./chunk-rw5492e2.js";import"./chunk-a2yk8sw0.js";import"./chunk-f57t1bcs.js";import"./chunk-4q0rgnw0.js";import"./chunk-46x7a1cj.js";import"./chunk-zfd9dmsn.js";import"./chunk-c60qda5c.js";import"./chunk-nack2xs5.js";import"./chunk-vvzys1x7.js";import"./chunk-8me8hamk.js";import"./chunk-ysfeg3cn.js";import"./chunk-gd56arnm.js";import"./chunk-mcnwvh06.js";import"./chunk-67xreg70.js";import"./chunk-01mwbg1r.js";import"./chunk-hwqrejq3.js";import"./chunk-7xhwqc0c.js";import"./chunk-6ftee542.js";import"./chunk-qcxrcypb.js";import"./chunk-v37zmez0.js";import"./chunk-fbtm3frc.js";import"./chunk-xempkjvd.js";import"./chunk-q1wxgw5s.js";import"./chunk-78eyz4ch.js";import"./chunk-55zq2ha8.js";import"./chunk-764f1sf1.js";import"./chunk-fm9kas0a.js";import"./chunk-e8y2c1sq.js";import"./chunk-9tsp5ytb.js";import"./chunk-j1efsjsb.js";import"./chunk-gbtbfg7e.js";import"./chunk-cqhwzd9y.js";import"./chunk-9zrvh3pz.js";import{cn,ln}from"./chunk-gwa31y9x.js";import"./chunk-w19myass.js";import"./chunk-mkyn95mf.js";import"./chunk-hev4t4d5.js";import"./chunk-1mqcttg3.js";import"./chunk-6m6y9bbx.js";import"./chunk-z512gt4v.js";import"./chunk-ew5cey88.js";import"./chunk-dy1d7ep7.js";import"./chunk-bzt73fj0.js";import{oa,ia,aa,ca,go,la,ua,da,mo,ho,Kr,Gr,Xr}from"./chunk-j4mtcbvz.js";import"./chunk-8efn9agz.js";import"./chunk-v4xes880.js";import"./chunk-97cyjqa5.js";import"./chunk-2qjyzekc.js";import"./chunk-jbgj2hph.js";import"./chunk-dx2t73jn.js";import"./chunk-5dvkphbe.js";import{Pc}from"./chunk-w1vk83kx.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 Gr(t,m))n.exit(1)}catch(h){console.error("Failed to process files:",h),n.exit(1)}else Kr(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 ca(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-
|
|
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-z6c4c951.js"),{loadConfig:s}=await import("./chunk-angv3d3s.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 Xr(".",{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 Xr(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 pe.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 Gr(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 Kr(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 Pc(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-gp7derwj.js");ln();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,8 +84,8 @@ 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-
|
|
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-
|
|
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-c2bhc5wg.js");await o({outputDir:e,port:Number.parseInt(t.port,10)||3000})}catch(e){console.error(`
|
|
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-w8qr5414.js");if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${Me}\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(`
|
|
91
91
|
You can now deploy with: stx deploy`);return}if(e.build!==!1){if(console.log(`
|
|
@@ -97,7 +97,7 @@ You can now deploy with: stx deploy`);return}if(e.build!==!1){if(console.log(`
|
|
|
97
97
|
`),console.log(` ${e.dryRun?"Would deploy":"Draft URL"}: ${c.url}`),c.siteUrl)console.log(` Site URL: ${c.siteUrl}`);if(!e.dryRun)console.log(`
|
|
98
98
|
Deploy ID: ${c.deployId}`),console.log(` Duration: ${(c.duration/1000).toFixed(1)}s`),console.log(` Files: ${c.filesUploaded}`)}}catch(o){if(o instanceof Error&&o.name==="DeployError")console.error(`
|
|
99
99
|
\u274C ${o.message}`),n.exit(1);console.error(`
|
|
100
|
-
\u274C Deploy failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("images <input>","Optimize images for production").option("-o, --output <dir>","Output directory",{default:"dist/images"}).option("-w, --widths <sizes>","Output widths (comma-separated)",{default:"320,640,768,1024,1280,1536,1920"}).option("-f, --formats <types>","Output formats (comma-separated)",{default:"webp,jpeg"}).option("-q, --quality <n>","Output quality (1-100)",{default:"80"}).option("--placeholder <type>","Placeholder type: blur, dominant-color, none",{default:"none"}).option("--dry-run","Preview without processing").option("--verbose","Show detailed output").example("stx images public/images").example("stx images public/images -o dist/images").example("stx images public/images --widths 640,1024,1920").example("stx images public/images --formats webp,avif").example("stx images public/images --quality 85").example("stx images public/images --dry-run").action(async(t,e)=>{try{let{optimizeDirectory:o,isSharpAvailable:r,formatSize:s}=await import("./chunk-eafqxbr0.js"),c=await import("fs"),i=await import("path");if(console.log(`\x1B[1mstx images\x1B[0m \x1B[2mv${
|
|
100
|
+
\u274C Deploy failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("images <input>","Optimize images for production").option("-o, --output <dir>","Output directory",{default:"dist/images"}).option("-w, --widths <sizes>","Output widths (comma-separated)",{default:"320,640,768,1024,1280,1536,1920"}).option("-f, --formats <types>","Output formats (comma-separated)",{default:"webp,jpeg"}).option("-q, --quality <n>","Output quality (1-100)",{default:"80"}).option("--placeholder <type>","Placeholder type: blur, dominant-color, none",{default:"none"}).option("--dry-run","Preview without processing").option("--verbose","Show detailed output").example("stx images public/images").example("stx images public/images -o dist/images").example("stx images public/images --widths 640,1024,1920").example("stx images public/images --formats webp,avif").example("stx images public/images --quality 85").example("stx images public/images --dry-run").action(async(t,e)=>{try{let{optimizeDirectory:o,isSharpAvailable:r,formatSize:s}=await import("./chunk-eafqxbr0.js"),c=await import("fs"),i=await import("path");if(console.log(`\x1B[1mstx images\x1B[0m \x1B[2mv${Me}\x1B[0m`),!await r())console.error(`
|
|
101
101
|
\u274C sharp is required for image optimization.`),console.log(`
|
|
102
102
|
Install sharp with:`),console.log(" bun add sharp"),n.exit(1);let d=e.widths.split(",").map((v)=>Number.parseInt(v.trim(),10)).filter((v)=>!Number.isNaN(v)),a=e.formats.split(",").map((v)=>v.trim().toLowerCase()),u=Number.parseInt(e.quality,10)||80,g=e.placeholder,x=i.resolve(t);if(!c.existsSync(x))console.error(`
|
|
103
103
|
\u274C Input directory not found: ${x}`),n.exit(1);if(!c.statSync(x).isDirectory())console.error(`
|
|
@@ -110,13 +110,13 @@ Would generate ~${P} image variants`);return}console.log(`
|
|
|
110
110
|
`);let k=await o(x,e.output,{widths:d,formats:a,quality:u,placeholder:g,verbose:e.verbose});if(console.log(`
|
|
111
111
|
\u2713 Optimization complete!
|
|
112
112
|
`),console.log(` Images processed: ${k.stats.optimizedImages}/${k.stats.totalImages}`),console.log(` Variants created: ${k.stats.variants}`),k.stats.savedBytes>0)console.log(` Estimated savings: ~${s(k.stats.savedBytes)}`)}catch(o){console.error(`
|
|
113
|
-
\u274C Image optimization failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("bundle [directory]","Analyze bundle size and composition").option("-o, --output <file>","Output file path").option("--json","Output as JSON").option("--text","Output as text summary").option("--markdown","Output as Markdown").option("--no-open","Do not open HTML report in browser").option("--no-gzip","Do not show gzip sizes").option("--threshold <size>","Fail if total size exceeds threshold (e.g., 500KB, 1MB)").option("--top <n>","Number of top modules to show",{default:"20"}).example("stx bundle").example("stx bundle dist/").example("stx bundle dist/ --json").example("stx bundle dist/ --text").example("stx bundle dist/ --threshold 500KB").example("stx bundle dist/ --no-open").action(async(t,e)=>{try{let{analyze:o,formatBytes:r,parseSize:s}=await import("./chunk-6q6g76vg.js"),c=await import("path");console.log(`\x1B[1mstx bundle\x1B[0m \x1B[2mv${
|
|
113
|
+
\u274C Image optimization failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("bundle [directory]","Analyze bundle size and composition").option("-o, --output <file>","Output file path").option("--json","Output as JSON").option("--text","Output as text summary").option("--markdown","Output as Markdown").option("--no-open","Do not open HTML report in browser").option("--no-gzip","Do not show gzip sizes").option("--threshold <size>","Fail if total size exceeds threshold (e.g., 500KB, 1MB)").option("--top <n>","Number of top modules to show",{default:"20"}).example("stx bundle").example("stx bundle dist/").example("stx bundle dist/ --json").example("stx bundle dist/ --text").example("stx bundle dist/ --threshold 500KB").example("stx bundle dist/ --no-open").action(async(t,e)=>{try{let{analyze:o,formatBytes:r,parseSize:s}=await import("./chunk-6q6g76vg.js"),c=await import("path");console.log(`\x1B[1mstx bundle\x1B[0m \x1B[2mv${Me}\x1B[0m`);let l=c.resolve(t||"dist"),d=await import("fs");if(!d.existsSync(l))console.error(`
|
|
114
114
|
\u274C Directory not found: ${l}`),console.log("\nRun `stx build` first to generate build output."),n.exit(1);let a="html";if(e.json)a="json";else if(e.text)a="text";else if(e.markdown)a="markdown";console.log(`
|
|
115
115
|
\uD83D\uDCE6 Analyzing: ${l}`);let u=await o({directory:l,output:e.output,format:a,open:e.open!==!1&&a==="html",gzip:e.gzip!==!1,threshold:e.threshold,topModules:Number.parseInt(e.top||"20",10),recommendations:!0});if(a==="html"){if(console.log(`
|
|
116
116
|
\u2713 Report generated: ${u.outputPath}`),e.open!==!1)console.log(" Opening in browser...")}else console.log(u.report);if(u.exceedsThreshold){let g=e.threshold;console.error(`
|
|
117
117
|
\u274C Bundle size (${r(u.stats.totalSize)}) exceeds threshold (${g})`),n.exit(1)}if(a==="html"){if(console.log(`
|
|
118
118
|
\uD83D\uDCCA Summary:`),console.log(` Total Size: ${r(u.stats.totalSize)}`),console.log(` Gzip Size: ${r(u.stats.totalGzipSize)}`),console.log(` Modules: ${u.stats.moduleCount}`),console.log(` Chunks: ${u.stats.chunks.length}`),u.stats.duplicates.length>0)console.log(` Duplicates: ${u.stats.duplicates.length}`)}}catch(o){console.error(`
|
|
119
|
-
\u274C Bundle analysis failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("test [patterns...]","Run tests with Bun test runner and browser environment").option("--watch","Watch for changes and rerun tests").option("--filter <pattern>","Only run tests matching the given pattern").option("--reporter <reporter>","Test reporter to use: default or junit (junit requires Bun v1.0+)",{default:"default"}).option("--timeout <ms>","Test timeout in milliseconds",{default:5000}).option("--coverage","Enable code coverage").option("--ui","Coming soon").option("--verbose","Show verbose output including test command").example("stx test").example("stx test packages/stx/test/").example("stx test **/*.test.ts --verbose").example('stx test --filter "should process"').example("stx test --watch --verbose").example("stx test --reporter junit").action(async(t,e)=>{try{if(console.log(`\x1B[1mstx test\x1B[0m \x1B[2mv${
|
|
119
|
+
\u274C Bundle analysis failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("test [patterns...]","Run tests with Bun test runner and browser environment").option("--watch","Watch for changes and rerun tests").option("--filter <pattern>","Only run tests matching the given pattern").option("--reporter <reporter>","Test reporter to use: default or junit (junit requires Bun v1.0+)",{default:"default"}).option("--timeout <ms>","Test timeout in milliseconds",{default:5000}).option("--coverage","Enable code coverage").option("--ui","Coming soon").option("--verbose","Show verbose output including test command").example("stx test").example("stx test packages/stx/test/").example("stx test **/*.test.ts --verbose").example('stx test --filter "should process"').example("stx test --watch --verbose").example("stx test --reporter junit").action(async(t,e)=>{try{if(console.log(`\x1B[1mstx test\x1B[0m \x1B[2mv${Me} (${da})\x1B[0m`),e.timeout){let s=I(e.timeout);if(!s.isValid)F(s)}let o=typeof t==="string"?[t]:t||[];if(o.length===0)o.push("**/*.test.ts","**/*.test.js","**/*.spec.ts","**/*.spec.js");if(e.verbose)console.log("Test patterns:",o),console.log("Options:",JSON.stringify({watch:e.watch||!1,filter:e.filter||"none",reporter:e.reporter||"default",timeout:e.timeout||5000,coverage:e.coverage||!1,ui:e.ui||!1},null,2));if(!await pe.timeAsync("test-execution",()=>V(o,e))&&!e.watch)n.exit(1)}catch(o){console.error("Error running tests:",o),n.exit(1)}}),y.command("init [file]","Create a new STX file").alias("new").option("--force","Overwrite existing file").option("--template <file>","Path to a template file to use as a base").example("stx init").example("stx init page.stx").example("stx new contact.stx").example("stx new components/button.stx --template examples/components/button.stx").action(async(t="index.stx",e)=>{try{if(await ua(t,{force:e.force,template:e.template}))console.log(`
|
|
120
120
|
\u2728 Successfully created file: ${t}`),console.log(`
|
|
121
121
|
To view it in the development server:`),console.log(` stx dev ${t}
|
|
122
122
|
`);else console.error(`
|
|
@@ -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){pe.clear(),console.log("\u2705 Performance statistics cleared");return}let o=pe.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-2hq6mq6r.js"),{resolveStxTargets:s}=await import("./chunk-h2qgqjkn.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=oa(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.
|
|
@@ -136,7 +136,7 @@ ${d} files need formatting. Run 'stx format' to fix.`),n.exit(1);else if(!e.chec
|
|
|
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
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-sb8n32rn.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-
|
|
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-0v2yj490.js");e=r.generateSignalsRuntime}catch{e=void 0}let o=await mo({generateRuntime:e});if(t.json)console.log(JSON.stringify(o,null,2));else console.log(ho(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,15 +160,15 @@ 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-s92j8k4z.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(
|
|
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(Me)}),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-z4yzk0d4.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-tx6t331f.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-efjmpq6r.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-adqh1gp1.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-snz2cxqv.js"),{runVisualTests:o,updateSnapshots:r,formatTestResults:s}=await import("./chunk-rb41t77f.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-4sfrfag1.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-yxpjj003.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(`
|
|
171
171
|
\u26A0\uFE0F Warnings:`);for(let w of l.stats.warnings)console.log(` - ${w.message}`)}if(l.stats.errors.length>0){console.log(`
|
|
172
172
|
\u274C Errors:`);for(let w of l.stats.errors)console.log(` - ${w.message}`)}}catch(o){console.error(`\u274C Compilation error: ${o.message}`),n.exit(1)}});let m=y.commands.flatMap((t)=>[t.name,...t.aliasNames??[]]).filter((t)=>Boolean(t)),h=n.argv.slice(2);if(h.length>0&&!h[0].startsWith("-")){let t=h[0];if(t==="")console.error("\u274C No command provided"),console.error("\uD83D\uDCA1 Use --help to see available commands"),n.exit(1);if(!m.includes(t)){let e=b("fs"),o=b("path"),r=t;if(!o.isAbsolute(r))r=o.resolve(n.cwd(),r);if(e.existsSync(r)){let s=e.statSync(r);if(s.isFile()||s.isDirectory())n.argv=[n.argv[0],n.argv[1],"dev",...h]}else{let s=m.map((i)=>({command:i,distance:f(t,i)}));s.sort((i,l)=>i.distance-l.distance);let c=s[0];if(c.distance<=3)console.error(`\u274C Unknown command: ${t}`),console.error(`\uD83D\uDCA1 Did you mean: ${c.command}?`),console.error(`
|
|
173
173
|
Run 'stx --help' to see available commands.`),n.exit(1);console.error(`\u274C Unknown command or path: ${t}`),console.error(`
|
|
174
|
-
Run 'stx --help' to see available commands.`),n.exit(1)}}}y.help(),y.version(
|
|
174
|
+
Run 'stx --help' to see available commands.`),n.exit(1)}}}y.help(),y.version(Me),y.parse(n.argv)}
|
|
@@ -93,7 +93,13 @@ export const SIGNALS_COMPONENT_PROPS_RUNTIME = ` function bindParentComponentPr
|
|
|
93
93
|
if (receiver.__stx_page_scope) return layerTemplateScopes(receiver.__stx_page_scope, pageScope);
|
|
94
94
|
// A routed page or keyed row can replace the caller inside a persistent shell.
|
|
95
95
|
if (receiver.__stx_scope && !receiver.hasAttribute('data-stx-scope')) return receiver.__stx_scope;
|
|
96
|
-
|
|
96
|
+
// The owner is named by whichever id the slot content was stamped with:
|
|
97
|
+
// the component's live scope id, or the template id it was cloned from.
|
|
98
|
+
// A loop clone carries both, and they differ. Reading only the template
|
|
99
|
+
// id when present missed a clone whose slot content had been renamed
|
|
100
|
+
// with it, so the walk went on past the component to the next row scope
|
|
101
|
+
// above, which knows the outer loop's item and not this one's (#2185).
|
|
102
|
+
if (receiver.getAttribute && (receiver.getAttribute('data-stx-scope') === owner || receiver.getAttribute('data-stx-template-scope') === owner))
|
|
97
103
|
return receiver.__stx_parent_scope || componentCallerScopeFrom(receiver.parentElement || receiver.parentNode, pageScope);
|
|
98
104
|
receiver = receiver.parentElement || receiver.parentNode;
|
|
99
105
|
}
|
package/dist/craft-entry.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-rkd27m4m.js";import{Ro,Pa,Ia}from"./chunk-5a0d3048.js";import"./chunk-79y9amt1.js";import"./chunk-g0xn80gz.js";import"./chunk-qjey0jk6.js";import"./chunk-farh4p7f.js";import"./chunk-k32q90b2.js";import"./chunk-0dyec13e.js";import"./chunk-tnp2ta5q.js";import"./chunk-kh6njq2r.js";import"./chunk-xt1cxmkx.js";import"./chunk-83tvkw4y.js";import"./chunk-rw5492e2.js";import"./chunk-f57t1bcs.js";import"./chunk-4q0rgnw0.js";import"./chunk-a2yk8sw0.js";import"./chunk-46x7a1cj.js";import"./chunk-zfd9dmsn.js";import"./chunk-fbtm3frc.js";import"./chunk-xempkjvd.js";import"./chunk-q1wxgw5s.js";import"./chunk-vvzys1x7.js";import{Tu,Oa,Dh,Mh,Na,Ao,os,Da,Ma,Lh,jh,La,ja,Ba,Fa}from"./chunk-6pqfar3p.js";import"./chunk-8efn9agz.js";import"./chunk-2qjyzekc.js";import"./chunk-jbgj2hph.js";import"./chunk-dx2t73jn.js";import"./chunk-5dvkphbe.js";import"./chunk-w1vk83kx.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(`
|
|
6
6
|
`),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
|
|
7
7
|
<script data-craft-hydration>
|
|
8
8
|
window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
|
|
9
|
-
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{Tu as CRAFT_BRIDGE_SCRIPT,Ao as CRAFT_COMPONENTS,
|
|
9
|
+
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{Tu as CRAFT_BRIDGE_SCRIPT,Ao as CRAFT_COMPONENTS,Da as CRAFT_COMPONENT_RUNTIME,os as CRAFT_COMPONENT_STYLES,Ro as NATIVE_COMPONENTS,La as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Pa as compileToNative,Ia as createHotReloadServer,ja as findCraftBinary,Oa as generateCraftBridgeScript,V as generateCraftOptimizations,Fa as getAvailableFormats,Ba as getAvailableTargets,jh as getCraftComponents,G as getSSRCacheStats,Na as injectCraftBridge,Dh as isCraftEnvironment,Y as prerenderForCraft,Ma as processCraftComponents,Mh as processCraftDirective,Lh as registerCraftComponent,Q as renderSSR};
|
package/dist/craft.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-rkd27m4m.js";import{Ro,Pa,Ia}from"./chunk-5a0d3048.js";import"./chunk-79y9amt1.js";import"./chunk-g0xn80gz.js";import"./chunk-qjey0jk6.js";import"./chunk-farh4p7f.js";import"./chunk-k32q90b2.js";import"./chunk-0dyec13e.js";import"./chunk-tnp2ta5q.js";import"./chunk-kh6njq2r.js";import"./chunk-xt1cxmkx.js";import"./chunk-83tvkw4y.js";import"./chunk-rw5492e2.js";import"./chunk-f57t1bcs.js";import"./chunk-4q0rgnw0.js";import"./chunk-a2yk8sw0.js";import"./chunk-46x7a1cj.js";import"./chunk-zfd9dmsn.js";import"./chunk-fbtm3frc.js";import"./chunk-xempkjvd.js";import"./chunk-q1wxgw5s.js";import"./chunk-vvzys1x7.js";import{Tu,Oa,Dh,Mh,Na,Ao,os,Da,Ma,Lh,jh,La,ja,Ba,Fa}from"./chunk-6pqfar3p.js";import"./chunk-8efn9agz.js";import"./chunk-2qjyzekc.js";import"./chunk-jbgj2hph.js";import"./chunk-dx2t73jn.js";import"./chunk-5dvkphbe.js";import"./chunk-w1vk83kx.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(`
|
|
6
6
|
`),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
|
|
7
7
|
<script data-craft-hydration>
|
|
8
8
|
window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
|
|
9
|
-
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{Tu as CRAFT_BRIDGE_SCRIPT,Ao as CRAFT_COMPONENTS,
|
|
9
|
+
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{Tu as CRAFT_BRIDGE_SCRIPT,Ao as CRAFT_COMPONENTS,Da as CRAFT_COMPONENT_RUNTIME,os as CRAFT_COMPONENT_STYLES,Ro as NATIVE_COMPONENTS,La as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Pa as compileToNative,Ia as createHotReloadServer,ja as findCraftBinary,Oa as generateCraftBridgeScript,V as generateCraftOptimizations,Fa as getAvailableFormats,Ba as getAvailableTargets,jh as getCraftComponents,G as getSSRCacheStats,Na as injectCraftBridge,Dh as isCraftEnvironment,Y as prerenderForCraft,Ma as processCraftComponents,Mh as processCraftDirective,Lh as registerCraftComponent,Q as renderSSR};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { NativeFloatingAction, NativeFloatingActionsLayout } from './floating-actions.js';
|
|
2
|
+
export declare function mountFloatingActionsWeb(doc?: Document): FloatingActionsWeb;
|
|
3
|
+
/**
|
|
4
|
+
* Every rule inside `:where()`, so none outweighs a class. One control as the
|
|
5
|
+
* hosts draw it: 48 across, symbols 55 apart, no divider; the first and last
|
|
6
|
+
* symbols at the centres of the capsule's round ends (24 from each), as Maps
|
|
7
|
+
* places them. A round surface each when they are kept separate.
|
|
8
|
+
*/
|
|
9
|
+
export declare const FLOATING_ACTIONS_CSS: unknown;
|
|
10
|
+
/** The page's own classes for the parts it draws. */
|
|
11
|
+
export declare interface FloatingActionsWebClasses {
|
|
12
|
+
group?: string
|
|
13
|
+
badge?: string
|
|
14
|
+
menu?: string
|
|
15
|
+
}
|
|
16
|
+
export declare interface FloatingActionsWeb {
|
|
17
|
+
update: (actions: ReadonlyArray<NativeFloatingAction | null | undefined | false>, layout?: NativeFloatingActionsLayout, classes?: string | FloatingActionsWebClasses) => void
|
|
18
|
+
dispose: () => void
|
|
19
|
+
readonly element: HTMLElement | null
|
|
20
|
+
}
|