@stacksjs/stx 0.2.761 → 0.2.762
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-jzajpmke.js → chunk-02c46de1.js} +19 -2
- package/dist/{chunk-64pdwfef.js → chunk-05jdq9tw.js} +4 -4
- package/dist/chunk-0cajfv7y.js +2 -0
- package/dist/{chunk-45g1w1ct.js → chunk-0sd4td6z.js} +1 -1
- package/dist/{chunk-yh5658q8.js → chunk-18chz0q4.js} +1 -1
- package/dist/{chunk-jacb7aw1.js → chunk-28vtqwxh.js} +1 -1
- package/dist/{chunk-aa1y9j3p.js → chunk-2eamszdq.js} +1 -1
- package/dist/{chunk-cgh0k52q.js → chunk-2gn6smrq.js} +1 -1
- package/dist/{chunk-yp80rx17.js → chunk-528cn6qm.js} +1 -1
- package/dist/{chunk-61qh74q1.js → chunk-59k4xb92.js} +1 -1
- package/dist/{chunk-803qm5tk.js → chunk-633a53wg.js} +1 -1
- package/dist/chunk-6b737vch.js +2 -0
- package/dist/{chunk-2wnfqrv5.js → chunk-736ex6r5.js} +1 -1
- package/dist/{chunk-ctdw7fh4.js → chunk-8czxtjwm.js} +1 -1
- package/dist/{chunk-frybxj35.js → chunk-932zx5q4.js} +4 -4
- package/dist/chunk-9fh4ah7t.js +2 -0
- package/dist/{chunk-r6yb0540.js → chunk-a222bwpc.js} +2 -2
- package/dist/chunk-a81rt2t4.js +3 -0
- package/dist/{chunk-x7q4tp3f.js → chunk-ben8bjnk.js} +1 -1
- package/dist/{chunk-wmxsaxt0.js → chunk-cenvzm5q.js} +1 -1
- package/dist/{chunk-z5xermzg.js → chunk-d49pst1m.js} +1 -1
- package/dist/{chunk-8vs5y4h7.js → chunk-d96xddt9.js} +1 -1
- package/dist/chunk-dj0qy19b.js +2 -0
- package/dist/{chunk-wghtdgwj.js → chunk-dvpk4c1y.js} +1 -1
- package/dist/{chunk-fys1patf.js → chunk-ebxncrd8.js} +1 -1
- package/dist/{chunk-vv8dn70r.js → chunk-edhxg3rz.js} +2 -2
- package/dist/{chunk-qx0np0hy.js → chunk-epa73jvs.js} +1 -1
- package/dist/{chunk-yjzk7rwt.js → chunk-fhpsf4z7.js} +3 -3
- package/dist/chunk-fht1zs1r.js +2 -0
- package/dist/chunk-fmk9hjht.js +2 -0
- package/dist/{chunk-yhbsvf65.js → chunk-gwjh981q.js} +4 -4
- package/dist/{chunk-jn78c13y.js → chunk-j1tsda22.js} +1 -1
- package/dist/{chunk-emhbj3xd.js → chunk-j1z7tgdp.js} +1 -1
- package/dist/{chunk-7z2mebp5.js → chunk-k469ym7a.js} +1 -1
- package/dist/{chunk-wycrtkw4.js → chunk-k9wr8xf5.js} +1 -1
- package/dist/{chunk-wk8y89q2.js → chunk-m3z13f59.js} +1 -1
- package/dist/{chunk-0q5dm9r2.js → chunk-m6rzsbas.js} +2 -2
- package/dist/{chunk-p88yh4wt.js → chunk-mbe4gqd3.js} +1 -1
- package/dist/{chunk-1a9h6r9f.js → chunk-mdw96yhg.js} +1 -1
- package/dist/{chunk-qyzjkvme.js → chunk-nm9tnxnw.js} +2 -2
- package/dist/{chunk-wq1vs94k.js → chunk-p2se8s6r.js} +1 -1
- package/dist/{chunk-18gazs55.js → chunk-p7zrz0wb.js} +1 -1
- package/dist/chunk-pdnyfk2v.js +2 -0
- package/dist/{chunk-nm2r4se1.js → chunk-qfhjtz2q.js} +1 -1
- package/dist/{chunk-fke4s0kk.js → chunk-qjbcp3tc.js} +1 -1
- package/dist/{chunk-7y1rpd4g.js → chunk-rd33qkfs.js} +2 -2
- package/dist/{chunk-9nhyq39s.js → chunk-rj3p5fdy.js} +1 -1
- package/dist/{chunk-6fz2n9w6.js → chunk-rmk8efc3.js} +5 -5
- package/dist/{chunk-qm3jbse5.js → chunk-rnvrtcz6.js} +1 -1
- package/dist/{chunk-kj9m0vc6.js → chunk-rqd6b2nc.js} +1 -1
- package/dist/{chunk-4c0qcjac.js → chunk-rxm1mjkb.js} +1 -1
- package/dist/{chunk-g9efdc5v.js → chunk-s36cpnxa.js} +1 -1
- package/dist/{chunk-23t9anc0.js → chunk-t1shvfhm.js} +4 -4
- package/dist/{chunk-x1q7b7jg.js → chunk-vttx66q0.js} +1 -1
- package/dist/chunk-vxs07119.js +2 -0
- package/dist/chunk-x8hz5gzb.js +2 -0
- package/dist/{chunk-8jh2b5k2.js → chunk-xfdtym3s.js} +1 -1
- package/dist/{chunk-bjhesw78.js → chunk-xgnmgjpv.js} +1 -1
- package/dist/{chunk-98t1cv8x.js → chunk-xtwc2dbk.js} +1 -1
- package/dist/{chunk-2cbd1ew6.js → chunk-y4mp1rra.js} +6 -6
- package/dist/chunk-y8pftjg8.js +12 -0
- package/dist/{chunk-4rxmxc1p.js → chunk-yb71b2d6.js} +1 -1
- package/dist/{chunk-w512gnft.js → chunk-ycttwgpg.js} +1 -1
- package/dist/chunk-yd6x9226.js +2 -0
- package/dist/{chunk-vvs28yqw.js → chunk-yk456jp4.js} +2 -2
- package/dist/{chunk-r13fwtas.js → chunk-zpjdp0he.js} +1 -1
- package/dist/cli.js +8 -8
- package/dist/client/signals-hydration-audit-runtime.js +2 -0
- package/dist/client/signals-process-element-runtime.js +17 -2
- package/dist/composables/index.d.ts +3 -0
- package/dist/composables/index.js +1 -0
- package/dist/composables/use-completion.d.ts +29 -0
- package/dist/composables/use-completion.js +125 -0
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/dist/unresolved-identifiers.js +1 -0
- package/package.json +5 -5
- package/dist/chunk-0nynnmya.js +0 -2
- package/dist/chunk-5fg8hqq0.js +0 -2
- package/dist/chunk-7fwcnech.js +0 -2
- package/dist/chunk-927ta2dn.js +0 -2
- package/dist/chunk-c5tkxjb0.js +0 -2
- package/dist/chunk-e5vn76f5.js +0 -2
- package/dist/chunk-gpvfswgj.js +0 -2
- package/dist/chunk-kdqnest3.js +0 -2
- package/dist/chunk-krsg6dgz.js +0 -3
- package/dist/chunk-p2j38381.js +0 -2
- package/dist/chunk-ttqs99jj.js +0 -12
- package/dist/chunk-y5emxzbt.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{_c,r,fe}from"./chunk-
|
|
2
|
+
import{_c,r,fe}from"./chunk-y4mp1rra.js";import{tt}from"./chunk-3csfmhg0.js";import{l}from"./chunk-4tgn1frg.js";import o from"fs";import u from"path";var Af=new Map,m=new Map;async function Eh(e){let n;for(let i=0;i<3;i++)try{let g=(await o.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),w=(await o.promises.stat(e)).mtime.getTime();if(w!==g)continue;return m.set(e,{content:h,mtime:w}),h}catch(s){n=s;break}throw m.delete(e),Error(`File not found: ${e}${n?` (${n.message})`:""}`)}function Th(e){m.delete(e)}function $h(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var f=null,B=null,x=null;function Rh(e){x=e}async function Pf(e=!1){let t=x??await import("./chunk-p7zrz0wb.js");if(e)return t.generateSignalsRuntimeDev();if(f===null)f=t.generateSignalsRuntime();return f}var S=null;async function If(){if(S===null){let{getRouterScript:e}=await import("./chunk-8h5mqs28.js");S=e()}return S}var y={};async function Ah(e,t=!1){let n=e==="runtime"?await Pf(t):await If(),i=e==="runtime"&&t?"runtime-debug":e,s=y[i];if(!s||s.content!==n)s={content:n,hash:Bun.hash(n).toString(16).padStart(16,"0").slice(0,16)},y[i]=s;return{content:n,hash:s.hash,url:`/_stx/${e}.${s.hash}.js`}}var E=500,T=33554432,c=new Map,p=0;function C(e){return l(process.cwd(),"module-bundles",`${e}.js`)}function Ph(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),n=c.get(t),i=n!==void 0;if(i)c.delete(t),p-=n.length*2;c.set(t,e),p+=e.length*2;while(c.size>1&&(c.size>E||p>T)){let s=c.keys().next().value;p-=c.get(s).length*2,c.delete(s)}if(!i)try{let s=C(t);if(!o.existsSync(s))o.mkdirSync(u.dirname(s),{recursive:!0}),o.writeFileSync(s,e)}catch{}return`/_stx/modules.${t}.js`}function Vo(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=c.get(e);if(t!==void 0)return t;try{return o.readFileSync(C(e),"utf8")}catch{return}}function Ih(){m.clear(),fe(),_c(),f=null,B=null,S=null}function v(e){let t={debug:e.debug===!0,middleware:(e.middleware??[]).map((n)=>({name:n.name,timing:n.timing,handler:String(n.handler)})),customDirectives:(e.customDirectives??[]).map((n)=>({name:n.name,hasEndTag:n.hasEndTag===!0,rawParams:n.rawParams===!0,handler:String(n.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(t)).digest("hex")}async function cr(e,t){try{if(!t.cachePath)return null;let n=u.resolve(t.cachePath),i=u.join(n,`${ms(e)}.html`),s=u.join(n,`${ms(e)}.meta.json`);if(!await r(i)||!await r(s))return null;let g=await Bun.file(s).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==tt())return null;if(a.optionsSignature!==v(t))return null;if((await o.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let d of a.dependencies)if(await r(d)){if((await o.promises.stat(d)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(i).text()}catch(n){return console.warn(`Cache error for ${e}:`,n),null}}async function lr(e,t,n,i){try{if(!i.cachePath)return;let s=u.resolve(i.cachePath);await o.promises.mkdir(s,{recursive:!0});let g=u.join(s,`${ms(e)}.html`),a=u.join(s,`${ms(e)}.meta.json`),h=await o.promises.stat(e);await Bun.write(g,t);let d={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(n),cacheVersion:i.cacheVersion,engine:tt(),optionsSignature:v(i),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(d,null,2)),Af.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:n})}catch(s){console.warn(`Failed to cache template ${e}:`,s)}}var _=16;function ms(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,_)}
|
|
3
3
|
export{Af,Eh,Th,$h,Rh,Pf,If,Ah,Ph,Vo,Ih,cr,lr,ms};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{vm,fa,ou,xm,Sm,km,_m,Cm,iu,au,Em,Tm,$m,Rm}from"./chunk-
|
|
2
|
+
import{vm,fa,ou,xm,Sm,km,_m,Cm,iu,au,Em,Tm,$m,Rm}from"./chunk-k9wr8xf5.js";import"./chunk-t1shvfhm.js";import"./chunk-rd33qkfs.js";import"./chunk-b0z2n941.js";import"./chunk-m3z13f59.js";import"./chunk-gwjh981q.js";import"./chunk-xgnmgjpv.js";import"./chunk-a81rt2t4.js";import"./chunk-9k8ztdcc.js";import"./chunk-yk456jp4.js";import"./chunk-932zx5q4.js";import"./chunk-k2ex94n8.js";import"./chunk-yb71b2d6.js";import"./chunk-edhxg3rz.js";import"./chunk-rqd6b2nc.js";import"./chunk-8rk79ha1.js";import"./chunk-q3azy64b.js";import"./chunk-evxp3wmv.js";import"./chunk-f8p8ggvw.js";import"./chunk-y4mp1rra.js";import"./chunk-dvpk4c1y.js";import"./chunk-x5seqmrv.js";import"./chunk-tpfxvw4q.js";import"./chunk-4833k99b.js";import"./chunk-b51p56k5.js";export{ou as SUSPENSE_RESOLVER_RUNTIME,fa as buildSuspenseResolveScript,Cm as createStreamRenderer,km as extractStreamBoundaries,Rm as generateHydrationRuntime,au as islandDirective,Tm as processSectionDirectives,Sm as processStreamDirectives,Em as registerStreamingDirectives,xm as renderStreamingPage,vm as streamTemplate,_m as streamTemplateSimple,$m as streamToResponse,iu as streamingSuspenseDirective};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Kg}from"./chunk-epa73jvs.js";import"./chunk-fhpsf4z7.js";import"./chunk-02c46de1.js";import"./chunk-rxm1mjkb.js";import"./chunk-59k4xb92.js";import"./chunk-t1shvfhm.js";import"./chunk-rd33qkfs.js";import"./chunk-b0z2n941.js";import"./chunk-m3z13f59.js";import"./chunk-gwjh981q.js";import"./chunk-xgnmgjpv.js";import"./chunk-a81rt2t4.js";import"./chunk-9k8ztdcc.js";import"./chunk-yk456jp4.js";import"./chunk-932zx5q4.js";import"./chunk-k2ex94n8.js";import"./chunk-yb71b2d6.js";import"./chunk-edhxg3rz.js";import"./chunk-rqd6b2nc.js";import"./chunk-8rk79ha1.js";import"./chunk-q3azy64b.js";import"./chunk-evxp3wmv.js";import"./chunk-f8p8ggvw.js";import"./chunk-y4mp1rra.js";import"./chunk-dvpk4c1y.js";import"./chunk-x5seqmrv.js";import"./chunk-tpfxvw4q.js";import"./chunk-4833k99b.js";import"./chunk-b51p56k5.js";export{Kg as buildForProduction};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{it,il}from"./chunk-b51p56k5.js";import{A}from"./chunk-4833k99b.js";import{z,Ts,o,un,W,S,Cc,Nt,hn,je,Be}from"./chunk-
|
|
2
|
+
import{it,il}from"./chunk-b51p56k5.js";import{A}from"./chunk-4833k99b.js";import{z,Ts,o,un,W,S,Cc,Nt,hn,je,Be}from"./chunk-y4mp1rra.js";import{ar}from"./chunk-932zx5q4.js";import{L}from"./chunk-0wj31pqy.js";import{cn}from"./chunk-k2ex94n8.js";var D=`(?:"[^"]*"|'[^']*'|[^>"'])*`,q=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,J=65536,K=4,M=new Map;function Ch(){M.clear()}function Y(e){let i=[];for(let n of S(e,W)){let t=n.token.match(/^<script\b([^>]*)>/i),s=n.token.match(/<\/script\s*>$/i);if(!t||!s)continue;let a=t[0].length,f=n.token.length-s[0].length;i.push(Object.freeze({fullMatch:n.token,attrs:t[1],body:n.token.slice(a,f),start:n.start,end:n.end}))}return i}function cs(e,i={}){let n=e.length>=J,t=n?M.get(e):void 0;if(t===void 0){if(t=Y(e),n)Cc(M,K),M.set(e,t)}let s=i.skipAttrs;if(!s)return t.slice();let a=[];for(let f of t)if(s.lastIndex=0,!s.test(f.attrs))a.push(f);return a}function jo(e){let i=e.trim(),n=i.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(n){let s=n[1].trim(),a=n[2].trim(),{itemVar:f,indexVar:c}=F(a);if(f)return{style:"as",iterable:s,itemVar:f,indexVar:c}}let t=i.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(t){let s=t[1].trim(),a=t[2].trim(),{itemVar:f,indexVar:c}=F(s);if(f)return{style:"in",iterable:a,itemVar:f,indexVar:c}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function F(e){let i=e.trim(),n=i.match(/^(\w+)\s*=>\s*(\w+)$/);if(n)return{itemVar:n[2],indexVar:n[1]};let t=i.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(t)return{itemVar:t[1],indexVar:t[2]||null};let s=i.match(/^(\w+)\s*,\s*(\w+)$/);if(s)return{itemVar:s[1],indexVar:s[2]};let a=i.match(/^(\w+)$/);if(a)return{itemVar:a[1],indexVar:null};return{itemVar:null,indexVar:null}}function ls(e,i){return il(e,i)}function ee(e){let i=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,n=0,t;while((t=i.exec(e))!==null){let s=t[1];if(s.startsWith("if"))n++;else if(s==="endif")n--;else if(n===0)return!0}return!1}function or(e){let i=new Set,n=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,t=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel)\s*(?:<[^>]*>)?\s*\(/g,s;while((s=n.exec(e))!==null){let a=s[1],f;while((f=t.exec(a))!==null)i.add(f[1])}return i}function te(e){if(!/[:@]for\s*=/.test(e)&&!/\bx-for\s*=/.test(e))return[];let i=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${D})>`,"iy"),n=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,t=S(e,(a,f)=>{i.lastIndex=f;let c=i.exec(a);if(!c||c.index!==f||!n.test(c[2]))return-1;return i.lastIndex}),s=[];for(let a of t){i.lastIndex=0;let f=i.exec(a.token);if(!f)continue;let c=f[2].match(n),p=jo(c?.[1]??c?.[2]??""),h=[p.itemVar,p.indexVar].filter(Boolean);if(h.length===0)continue;let r=f[1],g=/\/\s*>$/.test(a.token)||P.has(r.toLowerCase())?a.end:Z(e,a.start,r,a.end);if(g!==-1)s.push({start:a.start,end:g,vars:new Set(h)})}return s}var U=new Set(["true","false","null","undefined","NaN","Infinity","typeof","instanceof","in","of","new","void","delete","this","Math","JSON","Date","Number","String","Boolean","Array","Object","RegExp","Map","Set","Symbol","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","window","document","console"]);function ne(e){return e.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function G(e,i,n,t){if(!e)return!1;let s=ne(e),a=!1,f=!1,c=!1,p=/([a-zA-Z_$][\w$]*)/g,h;while((h=p.exec(s))!==null){let l=h[1];if(s.slice(0,h.index).trimEnd().endsWith("."))continue;if(U.has(l))continue;if(i.has(l)||t?.has(l))a=!0;else if(n&&l in n)f=!0}let r=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,u;while((u=r.exec(s))!==null){let l=u[1];if(s.slice(0,u.index).trimEnd().endsWith("."))continue;if(U.has(l)||n&&l in n)continue;c=!0}return(a||c)&&!f}function O(e,i,n){let t=n===void 0?` ${i}`:` ${i}="${n.replace(/"/g,""")}"`,s=e.trim(),a=s.match(q);if(a&&se(a[3],a[1])){let[,f,c,p]=a;return`<${f}${c}${t}>${p}</${f}>`}return`<template${t}>${s}</template>`}function se(e,i){let n=new RegExp(`<(/)?${i}(?=[\\s/>])`,"gi"),t=0,s;while((s=n.exec(e))!==null)if(s[1]){if(t--,t<0)return!1}else t++;return!0}function Bo(e,i){let n=or(e);function t(s){let a=s,f=te(s),c=(u)=>{let g=new Set;for(let l of f)if(u>l.start&&u<l.end)for(let d of l.vars)g.add(d);return g},p=/@if\s*\(/g,h,r=[];while((h=p.exec(a))!==null){let u=h.index,g=u+h[0].length,l=1,d=g;while(d<a.length&&l>0){if(a[d]==="(")l++;else if(a[d]===")")l--;d++}if(l!==0)continue;let b=a.substring(g,d-1).trim(),w=d,E=1,y=w,m=/@(if\s*\(|endif)/g;m.lastIndex=w;let x;while((x=m.exec(a))!==null)if(x[1].startsWith("if"))E++;else if(x[1]==="endif"){if(E--,E===0){y=x.index+x[0].length;break}}if(E!==0)continue;let R=a.substring(w,y-6).trim(),v;if(ee(R)){let I=cn(a.substring(u,y));if(I.length===0)continue;let k=I[0].branches.filter((C)=>C.type!=="else"),V=c(u);if(!(k.length>0&&k.every((C)=>G(C.condition,n,i,V))))continue;v=I[0].branches.map((C)=>{let N=t(C.content);if(C.type==="elseif")return O(N,"@else-if",C.condition??"");if(C.type==="else")return O(N,"@else");return O(N,"@if",C.condition??"")}).join(`
|
|
3
3
|
`)}else{if(!G(b,n,i,c(u)))continue;v=O(t(R),"@if",b)}r.push({start:u,end:y,replacement:v}),p.lastIndex=y}for(let u=r.length-1;u>=0;u--){let{start:g,end:l,replacement:d}=r[u];a=a.substring(0,g)+d+a.substring(l)}return a}return t(e)}function re(e){let i=e.trim();if(i==="")return;if(i==="true")return!0;if(i==="false")return!1;if(i==="null")return!1;if(i==="undefined")return!1;if(i==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(i)){let s=Number(i);return s!==0&&!Number.isNaN(s)}let n=i.match(/^'((?:\\.|[^'\\])*)'$/);if(n)return n[1].length>0;let t=i.match(/^"((?:\\.|[^"\\])*)"$/);if(t)return t[1].length>0;return}var P=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),X=/<(script|style)\b/iy,ie=/<\/script/gi,oe=/<\/style/gi;function Z(e,i,n,t){if(P.has(n.toLowerCase()))return t;let s=n.toLowerCase(),a=e.length,f=1,c=t;while(c<a){let p=e.indexOf("<",c);if(p===-1)return-1;if(c=p,e.startsWith("<!--",c)){let g=e.indexOf("-->",c+4);if(g===-1)return-1;c=g+3;continue}X.lastIndex=c;let h=X.exec(e);if(h){let g=e.indexOf(">",c);if(g===-1)return-1;if(e[g-1]==="/"){c=g+1;continue}let l=h[1].toLowerCase()==="script"?ie:oe;l.lastIndex=c;let d=l.exec(e);if(d===null)return-1;let b=e.indexOf(">",d.index);if(b===-1)return-1;c=b+1;continue}if(e[c+1]==="/"){let g=/^<\/([a-z][\w-]*)\s*>/i.exec(e.slice(c,c+64));if(!g){c++;continue}if(g[1].toLowerCase()===s){if(f--,c+=g[0].length,f===0)return c;continue}c+=g[0].length;continue}let r=/^<([a-z][\w-]*)\b/i.exec(e.slice(c,c+64));if(!r){c++;continue}let u=e.indexOf(">",c);if(u===-1)return-1;if(r[1].toLowerCase()===s){let g=e.slice(c,u+1);if(!(/\/\s*>$/.test(g)||P.has(s)))f++}c=u+1}return-1}var ce=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/;function ae(e,i){let n=i,t=e.length;for(;;){while(n<t&&e[n]!=="<")n++;if(n>=t)return!1;if(e.startsWith("<!--",n)){let f=e.indexOf("-->",n+4);if(f===-1)return!1;n=f+3;continue}break}if(e[n+1]==="/")return!1;let s=e.indexOf(">",n);if(s===-1)return!1;let a=e.slice(n,s+1);return ce.test(a)}function Fo(e){if(!e.includes(":if")&&!e.includes(":show")&&!e.includes("x-if")&&!e.includes("x-show")&&!e.includes("@if=")&&!e.includes("@show="))return e;let i=[],n=/<([a-zA-Z][\w-]*)/y,t=/\s/,s=new Set([":if",":show","x-if","x-show","@if","@show"]);S(e,(r,u)=>{n.lastIndex=u;let g=n.exec(r);if(!g||/^(?:script|style)$/i.test(g[1]))return-1;let l=n.lastIndex,d;while(l<r.length){let b=l;while(l<r.length&&t.test(r[l]))l++;let w=l;if(r[w]==="/"){w++;while(w<r.length&&t.test(r[w]))w++}if(r[w]===">"){if(d)i.push({start:u,end:w+1,tag:g[1],...d});return-1}if(l===b)return-1;let E=l;while(l<r.length&&!t.test(r[l])&&r[l]!=="="&&r[l]!==">")l++;if(l===E)return-1;let y=r.slice(E,l);if(y.startsWith("@")&&y.includes("("))return-1;let m=l,x=l;while(x<r.length&&t.test(r[x]))x++;if(r[x]!=="="){l=m;continue}x++;while(x<r.length&&t.test(r[x]))x++;let R=r[x];if(R==='"'||R==="'"){let v=r.indexOf(R,x+1);if(v===-1)return-1;if(!d&&R==='"'&&s.has(y))d={attrName:y,attrStart:b,attrEnd:v+1,value:r.slice(x+1,v)};l=v+1}else{l=x;while(l<r.length&&!t.test(r[l])&&r[l]!==">")l++}}return-1});let a=[],f=-1;for(let r of i){let{start:u,end:g,tag:l,attrName:d,value:b}=r;if(u<f)continue;let w=re(b);if(w===void 0)continue;let m=/\/\s*>$/.test(e.slice(u,g))||P.has(l.toLowerCase())?g:Z(e,u,l,g);if(m===-1)continue;if((d===":if"||d==="x-if"||d==="@if")&&ae(e,m))continue;if(w===!0){let R=e.slice(u,r.attrStart)+e.slice(r.attrEnd,g);a.push({start:u,end:g,replacement:R});continue}a.push({start:u,end:m,replacement:""}),f=m}if(a.length===0)return e;a.sort((r,u)=>r.start-u.start);let c=[],p=-1;for(let r of a){if(r.start<p)continue;c.push(r),p=r.end}let h=e;for(let r=c.length-1;r>=0;r--){let{start:u,end:g,replacement:l}=c[r];h=h.substring(0,u)+l+h.substring(g)}return h}var H=[":for","@for","x-for"];function us(e,i){if(!i||Object.keys(i).length===0)return e;if(!H.some((c)=>e.includes(`${c}=`)))return e;let n=or(e);if(Array.isArray(i.__stx_client_signal_names)){for(let c of i.__stx_client_signal_names)if(typeof c==="string")n.add(c)}let t=e,s=[],a=/<([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g,f;while((f=a.exec(t))!==null){let[c,p,h]=f,r=f.index,u=r+c.length,g=H.map((v)=>({attr:v,m:new RegExp(`\\s${v}="([^"]*)"`).exec(h)})).find((v)=>v.m!==null);if(!g||!g.m)continue;let l=jo(g.m[1]);if(!l.iterable||!l.itemVar)continue;let d=l.iterable.trim().split(/[.[(]/)[0].trim();if(!d||n.has(d)||!(d in i))continue;let b=Z(t,r,p,u);if(b===-1)continue;let w=h.replace(new RegExp(`\\s${g.attr}="[^"]*"`),"").replace(/\s:key="[^"]*"/,"").replace(/\sx-cloak(?=\s|$)/,""),E=t.slice(u,b-`</${p}>`.length),y={...i,[l.itemVar]:void 0};if(l.indexVar)y[l.indexVar]=void 0;let m=us(E,y),x=l.indexVar?`${l.iterable} as ${l.indexVar} => ${l.itemVar}`:`${l.iterable} as ${l.itemVar}`,R=p.toLowerCase()==="template"?m:`<${p}${w}>${m}</${p}>`;s.push({start:r,end:b,replacement:`@foreach(${x})${R}@endforeach`}),a.lastIndex=b}for(let c=s.length-1;c>=0;c--){let{start:p,end:h,replacement:r}=s[c];t=t.slice(0,p)+r+t.slice(h)}return t}function ds(e,i){let n=e,t=/@(for|foreach)\s*\(/g,s,a=[],f=[];while((s=t.exec(n))!==null){let c=s[1],p=s.index,h=p+s[0].length,r=1,u=h;while(u<n.length&&r>0){if(n[u]==="(")r++;else if(n[u]===")")r--;u++}if(r!==0)continue;let g=n.substring(h,u-1).trim(),l=u,d=jo(g),b=c==="for"?"@endfor":"@endforeach",w=1,E=l,y=c==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${c}\\s*\\(|end${c})`,"g");y.lastIndex=l;let m;while((m=y.exec(n))!==null)if(m[1].startsWith(c))w++;else if(w--,w===0){E=m.index+m[0].length;break}if(w!==0)continue;let x=()=>{let _=[d.itemVar,d.indexVar].filter(Boolean);if(_.length)f.push({start:p,end:E,vars:_})};if(d.iterable){let _=d.iterable.trim();if(_.startsWith("[")||_.startsWith("{")||_.startsWith("'")||_.startsWith('"')||_.startsWith("`")||/^-?\d/.test(_)){x();continue}let T=_.split(/[.[(]/)[0].trim(),C=i?T in i:!1,N=f.some((j)=>p>j.start&&p<j.end&&j.vars.includes(T));if(T&&(C||N)){x();continue}}if(d.style==="as")g=d.indexVar?`(${d.itemVar}, ${d.indexVar}) in ${d.iterable}`:`${d.itemVar} in ${d.iterable}`;let R=n.substring(l,E-b.length).trim(),v=i?{...i}:{};if(d.itemVar)delete v[d.itemVar];if(d.indexVar)delete v[d.indexVar];let I=ds(R,v),k=I.match(q),V;if(k){let[,_,T,C]=k;V=`<${_}${T} @for="${g}">${C}</${_}>`}else V=`<template @for="${g}">${I}</template>`;a.push({start:p,end:E,replacement:V}),t.lastIndex=E}for(let c=a.length-1;c>=0;c--){let{start:p,end:h,replacement:r}=a[c];n=n.substring(0,p)+r+n.substring(h)}return n}function le(e){let i=new Set,n=[],t=0,s=0,a=e.length,f=(r)=>{let u=t+1;while(u<a){let g=e[u];if(g==="\\"){u+=2;continue}if(g===r)return u+1;u++}return a},c=()=>{let r=t+2;while(r<a&&e[r]!==`
|
|
4
4
|
`)r++;return r},p=()=>{let r=t+2;while(r<a-1){if(e[r]==="*"&&e[r+1]==="/")return r+2;r++}return a},h=(r)=>{let u=r,g=0;while(u<a){let l=e[u];if(l==="/"&&e[u+1]==="/"){let d=u+2;while(d<a&&e[d]!==`
|
|
5
|
-
`)d++;u=d;continue}if(l==="/"&&e[u+1]==="*"){let d=u+2;while(d<a-1&&!(e[d]==="*"&&e[d+1]==="/"))d++;u=d+2;continue}if(l==='"'||l==="'"||l==="`"){let d=u+1;while(d<a){if(e[d]==="\\"){d+=2;continue}if(e[d]===l){d++;break}d++}u=d;continue}if(l==="("||l==="["||l==="{"){g++,u++;continue}if(l===")"||l==="]"||l==="}"){g--,u++;continue}if(l===";"&&g===0)return u+1;u++}return a};while(t<a){let r=e[t];if(r==="/"&&e[t+1]==="/"){let u=c();n.push(e.slice(t,u)),t=u;continue}if(r==="/"&&e[t+1]==="*"){let u=p();n.push(e.slice(t,u)),t=u;continue}if(r==='"'||r==="'"||r==="`"){let u=f(r);n.push(e.slice(t,u)),t=u;continue}if(r==="{"){s++,n.push(r),t++;continue}if(r==="}"){s--,n.push(r),t++;continue}if(s===0){let u=t>0?e[t-1]:"";if(u===""||/\s/.test(u)||u===";"||u==="}"||u==="{"){let l=e.slice(t).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(l){let d=l[2],b=h(t+l[0].length);if(i.has(d)){n.push(`/* stx: deduped const ${d} */`),t=b;continue}i.add(d),n.push(e.slice(t,b)),t=b;continue}}}n.push(r),t++}return n.join("")}var ue=new Set(["script","style","html","head","meta","link","title","!doctype"]);function B(e,i,n){for(let t of n){if(t.start>=i)return!1;if(t.end>e)return!0}return!1}function fe(e,i,n){let t=0;while(t<e.length){let s=e.indexOf(i,t);if(s===-1)return!1;if(!B(s,s+i.length,n))return!0;t=s+i.length}return!1}function de(e,i){if(fe(e,"<body",i)){let s=new RegExp(`<body(${D})>`,"g"),a;while((a=s.exec(e))!==null)if(!B(a.index,a.index+a[0].length,i))return a.index+a[0].length-1;return null}let n=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${D})>`,"gi"),t;while((t=n.exec(e))!==null){if(B(t.index,t.index+t[0].length,i))continue;if(ue.has(t[1].toLowerCase()))continue;return t.index+t[0].length-1}return null}function ge(e,i,n,t){let s=[],a=` data-stx="${t}"`,f=0,c=!1,p=(h)=>{if(n!==null&&!c&&n>=f&&n<=h)s.push(e.slice(f,n),a,e.slice(n,h)),c=!0;else s.push(e.slice(f,h))};for(let h of i){if(h.start<f)continue;p(h.start),f=h.end}return p(e.length),s.join("")}async function ps(e,i,n,t={}){let s=cs(e,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),a=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,f=[],{hasUserImports:c,bundleClientScript:p}=await o("stx/client-script-bundler",()=>import("./chunk-
|
|
5
|
+
`)d++;u=d;continue}if(l==="/"&&e[u+1]==="*"){let d=u+2;while(d<a-1&&!(e[d]==="*"&&e[d+1]==="/"))d++;u=d+2;continue}if(l==='"'||l==="'"||l==="`"){let d=u+1;while(d<a){if(e[d]==="\\"){d+=2;continue}if(e[d]===l){d++;break}d++}u=d;continue}if(l==="("||l==="["||l==="{"){g++,u++;continue}if(l===")"||l==="]"||l==="}"){g--,u++;continue}if(l===";"&&g===0)return u+1;u++}return a};while(t<a){let r=e[t];if(r==="/"&&e[t+1]==="/"){let u=c();n.push(e.slice(t,u)),t=u;continue}if(r==="/"&&e[t+1]==="*"){let u=p();n.push(e.slice(t,u)),t=u;continue}if(r==='"'||r==="'"||r==="`"){let u=f(r);n.push(e.slice(t,u)),t=u;continue}if(r==="{"){s++,n.push(r),t++;continue}if(r==="}"){s--,n.push(r),t++;continue}if(s===0){let u=t>0?e[t-1]:"";if(u===""||/\s/.test(u)||u===";"||u==="}"||u==="{"){let l=e.slice(t).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(l){let d=l[2],b=h(t+l[0].length);if(i.has(d)){n.push(`/* stx: deduped const ${d} */`),t=b;continue}i.add(d),n.push(e.slice(t,b)),t=b;continue}}}n.push(r),t++}return n.join("")}var ue=new Set(["script","style","html","head","meta","link","title","!doctype"]);function B(e,i,n){for(let t of n){if(t.start>=i)return!1;if(t.end>e)return!0}return!1}function fe(e,i,n){let t=0;while(t<e.length){let s=e.indexOf(i,t);if(s===-1)return!1;if(!B(s,s+i.length,n))return!0;t=s+i.length}return!1}function de(e,i){if(fe(e,"<body",i)){let s=new RegExp(`<body(${D})>`,"g"),a;while((a=s.exec(e))!==null)if(!B(a.index,a.index+a[0].length,i))return a.index+a[0].length-1;return null}let n=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${D})>`,"gi"),t;while((t=n.exec(e))!==null){if(B(t.index,t.index+t[0].length,i))continue;if(ue.has(t[1].toLowerCase()))continue;return t.index+t[0].length-1}return null}function ge(e,i,n,t){let s=[],a=` data-stx="${t}"`,f=0,c=!1,p=(h)=>{if(n!==null&&!c&&n>=f&&n<=h)s.push(e.slice(f,n),a,e.slice(n,h)),c=!0;else s.push(e.slice(f,h))};for(let h of i){if(h.start<f)continue;p(h.start),f=h.end}return p(e.length),s.join("")}async function ps(e,i,n,t={}){let s=cs(e,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),a=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,f=[],{hasUserImports:c,bundleClientScript:p}=await o("stx/client-script-bundler",()=>import("./chunk-mdw96yhg.js"));for(let m of s){let x=m.body;if(je(m.attrs))x=Be(x);if(t.forceClientSetup||a.test(x)){f.push({content:x,start:m.start,end:m.end});continue}if(!c(x))continue;try{let R=await p(Nt(x).code,i||"",{projectRoot:process.cwd(),externalizeUserModules:!1});if(a.test(R))f.push({content:x,start:m.start,end:m.end})}catch{}}if(f.length===0)return{output:e,setupCode:null};let h=`${i??""}\x00${f.map((m)=>m.content).join("\x00")}`,r=`__stx_setup_${Bun.hash(h).toString(36).slice(0,10)}`,u=[];for(let m=0;m<f.length;m++){let x=f[m].bundled??Nt(f[m].content).code;if(!f[m].bundled&&c(x))x=await p(x,i||"",{projectRoot:process.cwd()});x=bt(x);let R=A(x);u.push(`// \u2500\u2500 merged signal script #${m+1} \u2500\u2500
|
|
6
6
|
${R}`)}let g=u.join(`
|
|
7
7
|
|
|
8
8
|
`);g=le(g);let d=z(g).split(",").map((m)=>m.trim()).filter(Boolean),b=hn(g,n),w=`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Bg}from"./chunk-
|
|
2
|
+
import{Bg}from"./chunk-xtwc2dbk.js";import"./chunk-edhxg3rz.js";import"./chunk-rqd6b2nc.js";import"./chunk-8rk79ha1.js";import"./chunk-q3azy64b.js";import"./chunk-evxp3wmv.js";import"./chunk-f8p8ggvw.js";import"./chunk-y4mp1rra.js";import"./chunk-dvpk4c1y.js";import"./chunk-x5seqmrv.js";import"./chunk-tpfxvw4q.js";import"./chunk-4833k99b.js";import"./chunk-b51p56k5.js";export{Bg as buildApp};
|
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import"./chunk-tpfxvw4q.js";import"./chunk-b51p56k5.js";import"./chunk-4833k99b.js";import{Pe,oe}from"./chunk-
|
|
3
|
+
import"./chunk-tpfxvw4q.js";import"./chunk-b51p56k5.js";import"./chunk-4833k99b.js";import{Pe,oe}from"./chunk-y4mp1rra.js";import"./chunk-x5seqmrv.js";import"./chunk-dvpk4c1y.js";import"./chunk-8rk79ha1.js";import"./chunk-f8p8ggvw.js";import"./chunk-edhxg3rz.js";import"./chunk-evxp3wmv.js";import"./chunk-q3azy64b.js";import"./chunk-t1shvfhm.js";import"./chunk-yb71b2d6.js";import"./chunk-rd33qkfs.js";import"./chunk-xgnmgjpv.js";import"./chunk-gwjh981q.js";import"./chunk-rj3p5fdy.js";import"./chunk-dnsf934e.js";import"./chunk-r8zhed35.js";import"./chunk-mdvtermb.js";import"./chunk-cdcrd33m.js";import"./chunk-2zd51tj4.js";import"./chunk-zhrz4zvw.js";import"./chunk-fhpsf4z7.js";import"./chunk-bvctccab.js";import"./chunk-xtwc2dbk.js";import"./chunk-02c46de1.js";import"./chunk-tshpcvcy.js";import"./chunk-37y8sg48.js";import"./chunk-mbe4gqd3.js";import"./chunk-8yyq3nfg.js";import"./chunk-yk456jp4.js";import"./chunk-m3z13f59.js";import"./chunk-b0z2n941.js";import"./chunk-0sd4td6z.js";import"./chunk-ak93e1zz.js";import"./chunk-59k4xb92.js";import"./chunk-epa73jvs.js";import"./chunk-k9wr8xf5.js";import"./chunk-89801pjp.js";import"./chunk-ds6mbfdq.js";import"./chunk-rh2qth8r.js";import"./chunk-wmnzapn8.js";import{Qt,en}from"./chunk-ben8bjnk.js";import"./chunk-qjbcp3tc.js";import"./chunk-j1tsda22.js";import"./chunk-t2cq4bpe.js";import"./chunk-xt034729.js";import"./chunk-r1tp2gnr.js";import"./chunk-wby7qzha.js";import"./chunk-b7x8b83z.js";import"./chunk-736ex6r5.js";import"./chunk-2eamszdq.js";import{Vi,Ui,Wi,qi,to,Ki,Gi,Xi,no,ro,Lr,jr,Br}from"./chunk-rmk8efc3.js";import"./chunk-m6rzsbas.js";import"./chunk-0fs9kx0h.js";import"./chunk-rxm1mjkb.js";import"./chunk-a81rt2t4.js";import"./chunk-9k8ztdcc.js";import"./chunk-932zx5q4.js";import"./chunk-k2ex94n8.js";import{pc}from"./chunk-rqd6b2nc.js";import{g}from"./chunk-0dve54ne.js";import{spawn as R}from"child_process";import S from"fs";import f from"path";import n from"process";import{CLI as z}from"@stacksjs/clapp";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new z("stx");function E(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(m<1024||m>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function A(h){try{if(!S.existsSync(h)){let x=f.dirname(h),t=f.basename(h);if(S.existsSync(x)){let o=S.readdirSync(x).filter((s)=>s.toLowerCase().includes(t.toLowerCase().substring(0,3))||s.endsWith(".stx")||s.endsWith(".md")),r=o.length>0?`File not found. Similar files in ${x}: ${o.slice(0,3).join(", ")}`:`File not found. Directory ${x} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${h}`,suggestion:r}}return{isValid:!1,error:`File does not exist: ${h}`,suggestion:"Check the file path and try again"}}if(S.statSync(h).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${h}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(m){return{isValid:!1,error:`Cannot access file: ${h}`,suggestion:"Check file permissions and path"}}}function I(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(m<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(m>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var O=(h)=>h.includes("*")||h.includes("?")||h.includes("{")||h.includes("["),W=(h)=>h.endsWith(".stx")||h.endsWith(".md");function F(h,m=1){if(console.error(`\u274C ${h.error}`),h.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${h.suggestion}`);n.exit(m)}function M(h){if(!h)return;let m;try{m=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),n.exit(1)}if(typeof m!=="object"||m===null||Array.isArray(m))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),n.exit(1);for(let[x,t]of Object.entries(m))if(typeof t!=="string"&&typeof t!=="number"&&typeof t!=="boolean")console.error(`\u274C --info-plist value for "${x}" must be a string, number or boolean`),n.exit(1);return m}async function V(h,m){try{let x=["test"],t=[];if(h&&h.length>0)for(let c of h)if(O(c))try{let i=await Array.fromAsync(new Bun.Glob(c).scan({onlyFiles:!0,absolute:!0}));if(i.length===0)console.warn(`Warning: No files found matching pattern: ${c}`);else if(t.push(...i),m.verbose)console.log(`Found ${i.length} file(s) matching pattern: ${c}`)}catch(i){return console.error(`Error expanding glob pattern ${c}:`,i),!1}else t.push(c);if(t.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(x.push(...t),m.filter)x.push("--pattern",m.filter);if(m.timeout)x.push("--timeout",m.timeout.toString());if(m.reporter&&m.reporter!=="default")if(m.reporter==="junit"){let c=f.resolve("stx-test-report.xml");x.push("--reporter",m.reporter),x.push("--reporter-outfile",c),console.log(`JUnit report: ${c}`)}else console.warn(`Warning: Reporter '${m.reporter}' is not supported. Using default reporter.`);if(m.coverage)x.push("--coverage");if(m.watch)x.push("--watch");x.push("--preload",f.join(__dirname,"../../../test-utils/happy-dom.ts"));let e={...n.env,STX_TEST_MODE:"true",STX_TEST_UI:m.ui?"true":"false",STX_TEST_VERBOSE:m.verbose?"true":"false"},o="bun";if(m.verbose)console.log(`Running: ${o} ${x.join(" ")}`);let r=performance.now(),s=R(o,x,{stdio:"inherit",shell:!1,env:e});return new Promise((c)=>{s.on("close",(i)=>{let d=((performance.now()-r)/1000).toFixed(2);if(i===0)c(!0);else c(!1)}),n.on("SIGINT",()=>{console.log(`
|
|
4
4
|
Test run interrupted`),s.kill("SIGINT"),n.exit(1)})})}catch(x){return console.error("Error running tests:",x instanceof Error?x.message:String(x)),!1}}var U=n.argv.length>=3&&(W(n.argv[2])&&S.existsSync(n.argv[2])||O(n.argv[2]));if(U){let h=n.argv[2],m={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let x=3;x<n.argv.length;x++){let t=n.argv[x];if(t==="--port"&&x+1<n.argv.length){let e=E(n.argv[++x]);if(!e.isValid)F(e);m.port=Number.parseInt(n.argv[x],10)}else if(t==="--no-watch")m.watch=!1;else if(t==="--highlight-theme"&&x+1<n.argv.length){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.defaultTheme=n.argv[++x]}else if(t==="--no-highlight"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.enabled=!1}else if(t==="--no-highlight-unknown"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(t==="--no-cache")m.cache=!1;else if(t==="--native")m.native=!0}if(O(h))try{let x=await Array.fromAsync(new Bun.Glob(h).scan({onlyFiles:!0,absolute:!0})),t=h.endsWith(".stx")?x.filter((s)=>s.endsWith(".stx")):h.endsWith(".md")?x.filter((s)=>s.endsWith(".md")):x.filter((s)=>s.endsWith(".stx")||s.endsWith(".md")),e=h.split("*")[0].replace(/\/$/,"")||".",o=f.resolve(e);try{let s=new Bun.Glob("**/*.stx"),i=(await Array.fromAsync(s.scan({cwd:o,onlyFiles:!0,absolute:!0}))).filter((l)=>/\[.+\]/.test(f.basename(l)));for(let l of i)if(!t.includes(l))t.push(l)}catch{}if(t.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${h}`),n.exit(1);if(!await jr(t,m))n.exit(1)}catch(x){console.error("Failed to process files:",x),n.exit(1)}else Lr(h,m).catch((x)=>{console.error("Failed to start dev server:",x),n.exit(1)})}else{let h=function(t,e){let o=[];for(let r=0;r<=e.length;r++)o[r]=[r];for(let r=0;r<=t.length;r++)o[0][r]=r;for(let r=1;r<=e.length;r++)for(let s=1;s<=t.length;s++)if(e.charAt(r-1)===t.charAt(s-1))o[r][s]=o[r-1][s-1];else o[r][s]=Math.min(o[r-1][s-1]+1,o[r][s-1]+1,o[r-1][s]+1);return o[e.length][t.length]};y.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(t)=>{try{if(await qi(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-3wkgd883.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||f.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-fjfrgef4.js"),{loadConfig:s}=await import("./chunk-
|
|
10
|
+
To use the package:`),console.log(` 1. cd packages/collections/iconify-${s}`),console.log(" 2. bun install"),console.log(" 3. bun run build")}else console.error(`Unknown iconify command: ${t}`),console.error("Available commands: list, generate"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("pwa <command>","PWA tools - audit configuration and build output").option("--output <dir>","Build output directory to audit",{default:"dist"}).example("stx pwa audit").example("stx pwa audit --output build").action(async(t,e)=>{try{if(t==="audit"){let{runPwaAudit:o,formatAuditResult:r}=await import("./chunk-fjfrgef4.js"),{loadConfig:s}=await import("./chunk-j1z7tgdp.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 Br(".",{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 Br(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 oe.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=f.resolve(c);try{let d=new Bun.Glob("**/*.stx"),u=(await Array.fromAsync(d.scan({cwd:i,onlyFiles:!0,absolute:!0}))).filter((p)=>/\[.+\]/.test(f.basename(p)));for(let p of u)if(!s.includes(p))s.push(p)}catch{}if(console.log(`Found ${s.length} ${s.length===1?"file":"files"} matching ${t}`),!await jr(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 Lr(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=f.resolve(e.pages),s=f.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-zpjdp0he.js");en();let i=await c({root:t?f.dirname(t):void 0,debug:e.verbose,ssg:{pagesDir:e.pages,outputDir:e.out,domain:e.domain,baseUrl:e.base,sitemap:e.sitemap,rss:e.rss,minify:e.minify,cache:e.cache!==!1,cleanOutput:e.clean,concurrency:Number.parseInt(e.concurrency,10)||10,publicDir:e.public,trailingSlash:e.trailingSlash,generate404:!0,hooks:e.verbose?{onPageStart:(d)=>console.log(` Generating: ${d}`),onPageEnd:(d,a)=>console.log(` Generated: ${d} (${a.length} bytes)`),onError:(d,a)=>console.error(` Error in ${a}: ${d.message}`)}:void 0},ssr:{outputDir:e.out==="dist"?".output":e.out,debug:e.verbose}}),l=((performance.now()-o)/1000).toFixed(2);if(i.mode==="ssr"&&i.ssr)console.log(`
|
|
73
73
|
Build complete! (SSR)
|
|
74
74
|
`),console.log(` Pages compiled: ${i.ssr.pageCount}`),console.log(` Output: ${i.ssr.outputDir}`),console.log(` Duration: ${l}s
|
|
75
75
|
`);else if(i.ssg){if(console.log(`
|
|
@@ -84,7 +84,7 @@ Total: ${i} issues in ${c} files`),e.output){let l=`
|
|
|
84
84
|
Build completed with ${i.ssg.failedCount} error(s). Fix the issues above and try again.
|
|
85
85
|
`),n.exit(1);console.log(" To preview locally:"),console.log(` cd ${e.out||"dist"} && npx serve
|
|
86
86
|
`)}}catch(o){console.error(`
|
|
87
|
-
Build failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("start","Start the production server (serves pre-built .output/)").option("--port <number>","Server port",{default:"3000"}).option("--output <dir>","Output directory from stx build",{default:".output"}).example("stx start").example("stx start --port 8080").action(async(t)=>{try{let e=f.resolve(t.output);if(!S.existsSync(f.join(e,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),n.exit(1);let{startProductionServer:o}=await import("./chunk-
|
|
87
|
+
Build failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("start","Start the production server (serves pre-built .output/)").option("--port <number>","Server port",{default:"3000"}).option("--output <dir>","Output directory from stx build",{default:".output"}).example("stx start").example("stx start --port 8080").action(async(t)=>{try{let e=f.resolve(t.output);if(!S.existsSync(f.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-fht1zs1r.js");await o({outputDir:e,port:Number.parseInt(t.port,10)||3000})}catch(e){console.error(`
|
|
88
88
|
Failed to start production server:`,e instanceof Error?e.message:String(e)),n.exit(1)}}),y.command("deploy [directory]","Deploy built site to Netlify").option("--site-id <id>","Netlify site ID (or set NETLIFY_SITE_ID env var)").option("--token <token>","Auth token (or set NETLIFY_AUTH_TOKEN env var)").option("--production","Deploy to production (default: draft preview)").option("--message <msg>","Deploy message/title").option("--no-build","Skip build step before deploy").option("--open","Open deployed URL in browser").option("--dry-run","Preview deployment without uploading").option("--init","Initialize Netlify configuration for this project").example("stx deploy").example("stx deploy --production").example("stx deploy dist --site-id my-site-abc123").example("stx deploy --init").example("stx deploy --dry-run").action(async(t,e)=>{try{let{deploy:o,initNetlify:r,DeployError:s}=await import("./chunk-yn3kff5k.js");if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${Pe}\x1B[0m`),e.init){console.log(`
|
|
89
89
|
\uD83D\uDCDD Initializing Netlify configuration...
|
|
90
90
|
`);let i=await r({directory:t||n.cwd(),siteId:e.siteId});if(console.log(`\u2713 Created ${i.configPath}`),i.siteId)console.log("\u2713 Saved site ID to .env.local");console.log(`
|
|
@@ -124,7 +124,7 @@ To view it in the development server:`),console.log(` stx dev ${t}
|
|
|
124
124
|
\uD83D\uDCDD ${f.relative(n.cwd(),a)}:`),console.log("--- Original"),console.log("+++ Formatted"),console.log(`@@ Changes in ${f.basename(a)} @@`),console.log("+ Formatted content would be applied");else await Bun.write(a,b),console.log(`\u2705 Formatted ${f.relative(n.cwd(),a)}`),l++}catch(u){console.error(`\u274C Error formatting ${f.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){oe.clear(),console.log("\u2705 Performance statistics cleared");return}let o=oe.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-vxs07119.js"),{resolveStxTargets:s}=await import("./chunk-tfy1m821.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=Vi(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 `+`${p.length} error(s), ${u.diagnostics.length-p.length} warning(s)
|
|
138
138
|
`),p.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-k9247v28.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,p=new Set;try{let b=Bun.spawnSync(["git","ls-files","--others","--ignored","--exclude-standard","-z"],{cwd:n.cwd(),stdout:"pipe",stderr:"pipe"});for(let w of new TextDecoder().decode(b.stdout).split("\x00"))if(w)p.add(f.resolve(n.cwd(),w))}catch{}for(let b of i)for await(let w of new s(b).scan({cwd:n.cwd(),absolute:!0})){if(w.includes("/node_modules/")||w.includes("/dist/")||d.has(w)||p.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-p7zrz0wb.js");e=r.generateSignalsRuntime}catch{e=void 0}let o=await no({generateRuntime:e});if(t.json)console.log(JSON.stringify(o,null,2));else console.log(ro(o));if(!o.ok)n.exit(1)}catch(e){console.error("Error running doctor:",e),n.exit(1)}}),y.command("debug <file>","Debug STX template processing step by step").option("--step","Step through processing stages interactively").option("--verbose","Show detailed processing information").option("--context <data>","JSON string of context data to use").option("--save-report <file>","Save debug report to file").example("stx debug template.stx").example("stx debug template.stx --step").example(`stx debug template.stx --context '{"name": "John", "items": [1,2,3]}'`).action(async(t,e)=>{try{let o=A(t);if(!o.isValid)F(o);console.log(`\uD83D\uDD0D Debugging stx template: ${t}
|
|
140
140
|
`);let r={};if(e.context)try{r=JSON.parse(e.context)}catch(i){console.error("\u274C Invalid JSON in --context option"),n.exit(1)}let s=await Bun.file(t).text();console.log(`\uD83D\uDCC4 Template Content (${s.length} chars):`),console.log("\u2500".repeat(50)),console.log(s.substring(0,500)+(s.length>500?`
|
|
141
141
|
...
|
|
142
142
|
`:"")),console.log("\u2500".repeat(50));let c=s.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(c)console.log(`
|
|
@@ -160,11 +160,11 @@ Press Ctrl+C to stop watching...
|
|
|
160
160
|
\uD83D\uDCC4 Files with issues:`),d.forEach((a)=>{let u=a.issues.filter((p)=>s[p.type]>=c).length;if(u>0)console.log(` ${f.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-00nz3pas.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(Pe)}),y.command("interactive","Start interactive REPL mode for template development").alias("i").option("--context <file>","Load initial context from JSON file").option("--cwd <directory>","Set working directory").option("--verbose","Show verbose output").action(async(t)=>{let{startInteractive:e}=await import("./chunk-
|
|
163
|
+
\u2728 Captured ${s.length} screenshot(s) to ${e.out}/ via Bun WebView`)}catch(s){console.error(`Screenshot failed: ${s.message}`),n.exit(1)}}),y.command("version","Show the version of the CLI").action(()=>{console.log(Pe)}),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-6b737vch.js"),o={};if(t.context){let r=f.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?f.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-0cajfv7y.js"),c=f.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:f.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?f.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-a222bwpc.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-qystt1qc.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-hnen9b45.js"),{runVisualTests:o,updateSnapshots:r,formatTestResults:s}=await import("./chunk-18chz0q4.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-05jdq9tw.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 ${f.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-298gj90a.js"),r=f.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=f.resolve(e.output);if(!S.existsSync(d))S.mkdirSync(d,{recursive:!0});let a=f.basename(t,f.extname(t)),u=e.format==="typescript"?"ts":e.format==="json"?"json":"zig",p=f.join(d,`${a}.${u}`);S.writeFileSync(p,l.code);let b=f.join(d,`${a}.manifest.json`);if(S.writeFileSync(b,JSON.stringify(l.manifest,null,2)),e.sourcemaps&&l.sourceMaps){let w=f.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=f.join(d,`${a}.${w}.${u}`);S.writeFileSync(v,k)}if(console.log("\u2705 Compilation successful!"),console.log(` Output: ${p}`),console.log(` Manifest: ${b}`),console.log(`
|
|
170
170
|
\uD83D\uDCCA Statistics:`),console.log(` Compilation time: ${l.stats.compilationTime.toFixed(2)}ms`),console.log(` Total components: ${l.stats.totalComponents}`),console.log(` Native components: ${l.stats.nativeComponents}`),console.log(` Web fallback components: ${l.stats.webComponents}`),console.log(` Bundle size: ${(l.stats.bundleSize/1024).toFixed(2)}KB`),l.stats.warnings.length>0){console.log(`
|
|
@@ -108,6 +108,8 @@ export const SIGNALS_HYDRATION_AUDIT_RUNTIME = ` // ===========================
|
|
|
108
108
|
// missing String#indexOf method.
|
|
109
109
|
var text = node.nodeValue == null ? '' : String(node.nodeValue);
|
|
110
110
|
if (text.indexOf('{{') === -1 || text.indexOf('}}') === -1) continue;
|
|
111
|
+
// Text a binding wrote is data and may legitimately hold braces.
|
|
112
|
+
if (typeof isInertContent === 'function' && isInertContent(node)) continue;
|
|
111
113
|
if (auditSkipped(node)) continue;
|
|
112
114
|
found.push(text.trim().slice(0, 80));
|
|
113
115
|
if (found.length >= 5) break;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export function signalsProcessElementRuntime(directiveNamesLiteral, eventRegexLiteral, handledXAttrsLiteral) {
|
|
2
|
-
return ` //
|
|
2
|
+
return ` // True for text a binding wrote, or markup :html injected: data, never
|
|
3
|
+
// template. Checked only for text that holds braces, so the climb is rare.
|
|
4
|
+
function isInertContent(node) {
|
|
5
|
+
for (var n = node; n; n = n.parentNode) if (n.__stx_inert_content) return true;
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
// skipChildren: this element's bindings only, because something else already
|
|
3
9
|
// knows where the rest are. The manifest path passes it for every entry, so
|
|
4
10
|
// the tree is never walked; see processFromManifest.
|
|
5
11
|
function processElement(el, scope = componentScope, skipChildren) {
|
|
@@ -65,6 +71,10 @@ export function signalsProcessElementRuntime(directiveNamesLiteral, eventRegexLi
|
|
|
65
71
|
// implementations and user-created nodes can retain a numeric value
|
|
66
72
|
// assigned by a binding. Normalize before interpolation detection.
|
|
67
73
|
const text = el.textContent == null ? '' : String(el.textContent);
|
|
74
|
+
// Text a binding wrote is data, never template: the scan below only
|
|
75
|
+
// reads what the author wrote. A binding marks the element (or text node)
|
|
76
|
+
// that owns its output, so a later pass over the same tree skips it.
|
|
77
|
+
if (text && text.includes('{{') && isInertContent(el)) return;
|
|
68
78
|
if (text && text.includes('{{')) {
|
|
69
79
|
const parts = text.split(/(\\{\\{[\\s\\S]+?\\}\\})/g);
|
|
70
80
|
if (parts.length > 1) {
|
|
@@ -91,6 +101,7 @@ export function signalsProcessElementRuntime(directiveNamesLiteral, eventRegexLi
|
|
|
91
101
|
const bindingNode = isTextOnlyParent
|
|
92
102
|
? document.createTextNode('')
|
|
93
103
|
: document.createElement('span');
|
|
104
|
+
bindingNode.__stx_inert_content = true;
|
|
94
105
|
fragment.appendChild(bindingNode);
|
|
95
106
|
// Use captured scope, not dynamic lookup
|
|
96
107
|
effect(() => {
|
|
@@ -480,12 +491,16 @@ else if (name === '@style' || name === ':style' || name === 'x-style') {
|
|
|
480
491
|
el.removeAttribute(name);
|
|
481
492
|
}
|
|
482
493
|
else if (name === '@text' || name === ':text' || name === 'x-text') {
|
|
494
|
+
el.__stx_inert_content = true;
|
|
483
495
|
effect(() => {
|
|
484
496
|
stxHost.setText(el, evalAttrExpr(value));
|
|
485
497
|
});
|
|
486
498
|
el.removeAttribute(name);
|
|
487
499
|
}
|
|
488
500
|
else if (name === '@html' || name === ':html' || name === 'x-html') {
|
|
501
|
+
// Injected markup is data: nothing in it is a binding, so the child
|
|
502
|
+
// walk below must not read its text or attributes as template syntax.
|
|
503
|
+
el.__stx_inert_content = true;
|
|
489
504
|
effect(() => {
|
|
490
505
|
// Coerce null/undefined to '' so a missing/unresolved binding renders
|
|
491
506
|
// nothing rather than the literal string "undefined" (#1767).
|
|
@@ -700,7 +715,7 @@ catch (e) {
|
|
|
700
715
|
|
|
701
716
|
// Process children (skip script/style elements \u2014 their text content is not template markup)
|
|
702
717
|
// Skip elements that are roots of nested stx.mount() components \u2014 those have their own scope
|
|
703
|
-
if (!skipChildren && el.tagName !== 'SCRIPT' && el.tagName !== 'STYLE') {
|
|
718
|
+
if (!skipChildren && !el.__stx_inert_content && el.tagName !== 'SCRIPT' && el.tagName !== 'STYLE') {
|
|
704
719
|
var children = Array.from(el.childNodes);
|
|
705
720
|
children.forEach(function(child) {
|
|
706
721
|
if (child.nodeType !== Node.ELEMENT_NODE) { processElement(child, scope); return; }
|
|
@@ -444,6 +444,9 @@ export {
|
|
|
444
444
|
// `framework-composables.ts` needs the entry to know to bundle it. One missing
|
|
445
445
|
// re-export, two contradictory test suites. See #1849.
|
|
446
446
|
export { defineForm, useForm } from './use-form';
|
|
447
|
+
// Inline AI-style ghost text for a text field: debounce, abort, stale discard, accept.
|
|
448
|
+
// Demand-bundled for client scripts like useForm.
|
|
449
|
+
export { useCompletion, type Completion, type CompletionContext, type CompletionMeta, type UseCompletionOptions } from './use-completion';
|
|
447
450
|
// Authenticated server broadcasts, demand-bundled for client scripts.
|
|
448
451
|
export { useBroadcastStream, type BroadcastStreamFrame, type BroadcastStreamClientOptions } from './use-broadcast-stream';
|
|
449
452
|
// Breathing exercises: a step-by-step pacer and generated ambient sound,
|
|
@@ -238,6 +238,7 @@ export {
|
|
|
238
238
|
useDark
|
|
239
239
|
} from "./use-color-mode.js";
|
|
240
240
|
export { defineForm, useForm } from "./use-form.js";
|
|
241
|
+
export { useCompletion } from "./use-completion.js";
|
|
241
242
|
export { useBroadcastStream } from "./use-broadcast-stream.js";
|
|
242
243
|
export {
|
|
243
244
|
useBreathPacer
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Signal } from '../signals-api';
|
|
2
|
+
export declare function useCompletion(options: UseCompletionOptions): Completion;
|
|
3
|
+
export declare interface CompletionContext {
|
|
4
|
+
before: string
|
|
5
|
+
after: string
|
|
6
|
+
caret: number
|
|
7
|
+
}
|
|
8
|
+
/** What the host knows about the field that the text alone does not say. */
|
|
9
|
+
export declare interface CompletionMeta {
|
|
10
|
+
composing?: boolean
|
|
11
|
+
selecting?: boolean
|
|
12
|
+
blocked?: boolean
|
|
13
|
+
}
|
|
14
|
+
export declare interface UseCompletionOptions {
|
|
15
|
+
fetch: (context: CompletionContext, signal: AbortSignal) => Promise<string | null | undefined>
|
|
16
|
+
debounceMs?: number
|
|
17
|
+
minChars?: number
|
|
18
|
+
enabled?: boolean | string | (() => unknown)
|
|
19
|
+
}
|
|
20
|
+
export declare interface Completion {
|
|
21
|
+
ghost: Signal<string>
|
|
22
|
+
pending: Signal<boolean>
|
|
23
|
+
error: Signal<Error | null>
|
|
24
|
+
update: (before: string, after: string, caret: number, meta?: CompletionMeta) => void
|
|
25
|
+
accept: () => string
|
|
26
|
+
acceptWord: () => string
|
|
27
|
+
dismiss: () => void
|
|
28
|
+
destroy: () => void
|
|
29
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { state } from "../signals-api.js";
|
|
2
|
+
export function useCompletion(options) {
|
|
3
|
+
const debounceMs = Math.max(0, options.debounceMs ?? 250), minChars = Math.max(0, options.minChars ?? 12), ghost = state(""), pending = state(!1), error = state(null);
|
|
4
|
+
let timer, controller, token = 0, lastKey = "", latest = { before: "", after: "", caret: 0 }, suggestion = "", anchor = null, destroyed = !1;
|
|
5
|
+
function isEnabled() {
|
|
6
|
+
const value = options.enabled, resolved = typeof value === "function" ? value() : value;
|
|
7
|
+
if (typeof resolved === "string")
|
|
8
|
+
return !["false", "0", "off", "no"].includes(resolved.trim().toLowerCase());
|
|
9
|
+
return resolved !== !1;
|
|
10
|
+
}
|
|
11
|
+
function cancelRequest() {
|
|
12
|
+
if (timer !== void 0) {
|
|
13
|
+
clearTimeout(timer);
|
|
14
|
+
timer = void 0;
|
|
15
|
+
}
|
|
16
|
+
token++;
|
|
17
|
+
if (controller) {
|
|
18
|
+
controller.abort();
|
|
19
|
+
controller = void 0;
|
|
20
|
+
}
|
|
21
|
+
if (pending())
|
|
22
|
+
pending.set(!1);
|
|
23
|
+
}
|
|
24
|
+
function clearSuggestion() {
|
|
25
|
+
suggestion = "";
|
|
26
|
+
anchor = null;
|
|
27
|
+
if (ghost() !== "")
|
|
28
|
+
ghost.set("");
|
|
29
|
+
}
|
|
30
|
+
function schedule(context) {
|
|
31
|
+
const mine = ++token;
|
|
32
|
+
timer = setTimeout(() => {
|
|
33
|
+
timer = void 0;
|
|
34
|
+
if (destroyed || mine !== token)
|
|
35
|
+
return;
|
|
36
|
+
const abort = new AbortController;
|
|
37
|
+
controller = abort;
|
|
38
|
+
pending.set(!0);
|
|
39
|
+
error.set(null);
|
|
40
|
+
Promise.resolve().then(() => options.fetch(context, abort.signal)).then((result) => {
|
|
41
|
+
if (destroyed || mine !== token)
|
|
42
|
+
return;
|
|
43
|
+
if (latest.before !== context.before || latest.after !== context.after || latest.caret !== context.caret)
|
|
44
|
+
return;
|
|
45
|
+
controller = void 0;
|
|
46
|
+
pending.set(!1);
|
|
47
|
+
const text = typeof result === "string" ? result : "";
|
|
48
|
+
if (!text) {
|
|
49
|
+
clearSuggestion();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
suggestion = text;
|
|
53
|
+
anchor = { before: context.before, after: context.after };
|
|
54
|
+
ghost.set(text);
|
|
55
|
+
}).catch((failure) => {
|
|
56
|
+
if (destroyed || mine !== token)
|
|
57
|
+
return;
|
|
58
|
+
controller = void 0;
|
|
59
|
+
pending.set(!1);
|
|
60
|
+
clearSuggestion();
|
|
61
|
+
if (!(failure instanceof Error && failure.name === "AbortError"))
|
|
62
|
+
error.set(failure instanceof Error ? failure : Error(String(failure)));
|
|
63
|
+
});
|
|
64
|
+
}, debounceMs);
|
|
65
|
+
}
|
|
66
|
+
function update(before, after, caret, meta = {}) {
|
|
67
|
+
if (destroyed)
|
|
68
|
+
return;
|
|
69
|
+
const key = `${caret}\x00${meta.composing ? 1 : 0}${meta.selecting ? 1 : 0}${meta.blocked ? 1 : 0}\x00${before}\x00${after}`;
|
|
70
|
+
if (key === lastKey)
|
|
71
|
+
return;
|
|
72
|
+
lastKey = key;
|
|
73
|
+
latest = { before, after, caret };
|
|
74
|
+
if (!isEnabled() || meta.composing || meta.selecting || meta.blocked) {
|
|
75
|
+
cancelRequest();
|
|
76
|
+
clearSuggestion();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (anchor && suggestion && after === anchor.after && before.length >= anchor.before.length && before.startsWith(anchor.before)) {
|
|
80
|
+
const typed = before.slice(anchor.before.length);
|
|
81
|
+
if (suggestion.startsWith(typed)) {
|
|
82
|
+
cancelRequest();
|
|
83
|
+
const rest = suggestion.slice(typed.length);
|
|
84
|
+
if (rest) {
|
|
85
|
+
if (ghost() !== rest)
|
|
86
|
+
ghost.set(rest);
|
|
87
|
+
} else
|
|
88
|
+
clearSuggestion();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
cancelRequest();
|
|
93
|
+
clearSuggestion();
|
|
94
|
+
if (before.trim().length < minChars)
|
|
95
|
+
return;
|
|
96
|
+
if (/^[\p{L}\p{N}_]/u.test(after))
|
|
97
|
+
return;
|
|
98
|
+
schedule({ before, after, caret });
|
|
99
|
+
}
|
|
100
|
+
function accept() {
|
|
101
|
+
const text = ghost();
|
|
102
|
+
if (!text)
|
|
103
|
+
return "";
|
|
104
|
+
ghost.set("");
|
|
105
|
+
return text;
|
|
106
|
+
}
|
|
107
|
+
function acceptWord() {
|
|
108
|
+
const text = ghost();
|
|
109
|
+
if (!text)
|
|
110
|
+
return "";
|
|
111
|
+
const match = /^\s*\S+/.exec(text), word = match ? match[0] : text;
|
|
112
|
+
ghost.set(text.slice(word.length));
|
|
113
|
+
return word;
|
|
114
|
+
}
|
|
115
|
+
function dismiss() {
|
|
116
|
+
cancelRequest();
|
|
117
|
+
clearSuggestion();
|
|
118
|
+
}
|
|
119
|
+
function destroy() {
|
|
120
|
+
destroyed = !0;
|
|
121
|
+
cancelRequest();
|
|
122
|
+
clearSuggestion();
|
|
123
|
+
}
|
|
124
|
+
return { ghost, pending, error, update, accept, acceptWord, dismiss, destroy };
|
|
125
|
+
}
|
package/dist/craft-entry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{yo,ga,ma}from"./chunk-319aez2f.js";import"./chunk-48g9wez2.js";import"./chunk-tpfxvw4q.js";import"./chunk-b51p56k5.js";import"./chunk-4833k99b.js";import"./chunk-
|
|
2
|
+
import{yo,ga,ma}from"./chunk-319aez2f.js";import"./chunk-48g9wez2.js";import"./chunk-tpfxvw4q.js";import"./chunk-b51p56k5.js";import"./chunk-4833k99b.js";import"./chunk-y4mp1rra.js";import"./chunk-x5seqmrv.js";import"./chunk-dvpk4c1y.js";import"./chunk-8rk79ha1.js";import"./chunk-f8p8ggvw.js";import"./chunk-edhxg3rz.js";import"./chunk-evxp3wmv.js";import"./chunk-q3azy64b.js";import"./chunk-yb71b2d6.js";import"./chunk-rd33qkfs.js";import"./chunk-t1shvfhm.js";import"./chunk-xgnmgjpv.js";import"./chunk-gwjh981q.js";import"./chunk-yk456jp4.js";import"./chunk-m3z13f59.js";import"./chunk-b0z2n941.js";import"./chunk-r8zhed35.js";import{cu,ha,lh,uh,ya,bo,Xr,ba,wa,dh,ph,va,xa,Sa,ka}from"./chunk-d96xddt9.js";import"./chunk-m6rzsbas.js";import"./chunk-a81rt2t4.js";import"./chunk-9k8ztdcc.js";import"./chunk-932zx5q4.js";import"./chunk-k2ex94n8.js";import"./chunk-rqd6b2nc.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
|
|
3
3
|
`),scripts:t.scripts.join(`
|
|
4
4
|
`),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
|
|
5
5
|
`),scripts:t.scripts.join(`
|
package/dist/craft.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{yo,ga,ma}from"./chunk-319aez2f.js";import"./chunk-48g9wez2.js";import"./chunk-tpfxvw4q.js";import"./chunk-b51p56k5.js";import"./chunk-4833k99b.js";import"./chunk-
|
|
2
|
+
import{yo,ga,ma}from"./chunk-319aez2f.js";import"./chunk-48g9wez2.js";import"./chunk-tpfxvw4q.js";import"./chunk-b51p56k5.js";import"./chunk-4833k99b.js";import"./chunk-y4mp1rra.js";import"./chunk-x5seqmrv.js";import"./chunk-dvpk4c1y.js";import"./chunk-8rk79ha1.js";import"./chunk-f8p8ggvw.js";import"./chunk-edhxg3rz.js";import"./chunk-evxp3wmv.js";import"./chunk-q3azy64b.js";import"./chunk-yb71b2d6.js";import"./chunk-rd33qkfs.js";import"./chunk-t1shvfhm.js";import"./chunk-xgnmgjpv.js";import"./chunk-gwjh981q.js";import"./chunk-yk456jp4.js";import"./chunk-m3z13f59.js";import"./chunk-b0z2n941.js";import"./chunk-r8zhed35.js";import{cu,ha,lh,uh,ya,bo,Xr,ba,wa,dh,ph,va,xa,Sa,ka}from"./chunk-d96xddt9.js";import"./chunk-m6rzsbas.js";import"./chunk-a81rt2t4.js";import"./chunk-9k8ztdcc.js";import"./chunk-932zx5q4.js";import"./chunk-k2ex94n8.js";import"./chunk-rqd6b2nc.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(`
|