@akashjs/compiler 0.1.9 → 0.1.11

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/index.cjs CHANGED
@@ -1,42 +1,42 @@
1
- 'use strict';var crypto=require('crypto');function v(e){return {script:w(e,"script",(t,n,r,i)=>({content:t,lang:Z(n,"lang")??"ts",start:r,end:i})),template:w(e,"template",(t,n,r,i)=>({content:t,start:r,end:i})),style:w(e,"style",(t,n,r,i)=>({content:t,scoped:n.includes("scoped"),start:r,end:i}))}}function w(e,t,n){let r=new RegExp(`<${t}(\\b[^>]*)>`,"i"),i=new RegExp(`</${t}>`,"i"),s=r.exec(e);if(!s)return null;let o=s[1]??"",c=s.index+s[0].length,u=i.exec(e.slice(c));if(!u)return null;let p=c+u.index,l=e.slice(c,p);return n(l.trim(),o,c,p)}function Z(e,t){return new RegExp(`${t}=["']([^"']+)["']`).exec(e)?.[1]??null}function h(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="<"){if(e[n+1]==="/")break;let s=K(e,n);if(s){t.push(s.node),n=s.end;continue}}if(e[n]==="{"){let s=Q(e,n);if(s){t.push(s.node),n=s.end;continue}}let r=X(e,n),i=e.slice(n,r).trim();i&&t.push({type:"text",content:i}),n=r;}return t}function K(e,t){let n=/^<([a-zA-Z][a-zA-Z0-9-]*)/.exec(e.slice(t));if(!n)return null;let r=n[1],i=t+n[0].length,s=[],o=[];for(;i<e.length;){let g=/^\s+/.exec(e.slice(i));if(g&&(i+=g[0].length),e[i]===">"||e.slice(i,i+2)==="/>")break;let f=q(e,i);f?(f.attr.name.startsWith("bind:")?o.push({name:"bind",arg:f.attr.name.slice(5),value:f.attr.value}):f.attr.name.startsWith(":")?o.push({name:f.attr.name.slice(1),value:f.attr.value}):s.push(f.attr),i=f.end):i++;}let c=r[0]===r[0].toUpperCase();if(e.slice(i,i+2)==="/>")return {node:{type:c?"component":"element",tag:r,attrs:s,directives:o.length>0?o:void 0,children:[]},end:i+2};i++;let u=h(e.slice(i));e.slice(i);let l=`</${r}>`,a=Y(e,i,r);if(a===-1)return {node:{type:c?"component":"element",tag:r,attrs:s,directives:o.length>0?o:void 0,children:u},end:e.length};let m=e.slice(i,a),d=h(m);return {node:{type:c?"component":"element",tag:r,attrs:s,directives:o.length>0?o:void 0,children:d},end:a+l.length}}function q(e,t){let n=/^(?:bind:|[:a-zA-Z_])[\w:.-]*/.exec(e.slice(t));if(!n)return null;let r=n[0],i=t+r.length;if(e[i]!=="=")return {attr:{name:r,value:"true",dynamic:false},end:i};if(i++,e[i]==="{"){let o=M(e,i);if(o)return {attr:{name:r,value:o.content,dynamic:true},end:o.end}}let s=e[i];if(s==='"'||s==="'"){let o=e.indexOf(s,i+1);return o===-1?null:{attr:{name:r,value:e.slice(i+1,o),dynamic:false},end:o+1}}return null}function Q(e,t){let n=M(e,t);return n?{node:{type:"expression",content:n.content},end:n.end}:null}function M(e,t){if(e[t]!=="{")return null;let n=1,r=t+1;for(;r<e.length&&n>0;){let i=e[r];if(i==='"'||i==="'"||i==="`"){r=G(e,r)+1;continue}i==="{"?n++:i==="}"&&n--,r++;}return {content:e.slice(t+1,r-1).trim(),end:r}}function G(e,t){let n=e[t],r=t+1;for(;r<e.length;){if(e[r]==="\\"){r+=2;continue}if(e[r]===n)return r;r++;}return r}function X(e,t){let n=t;for(;n<e.length;){if(e[n]==="<"||e[n]==="{")return n;n++;}return n}function Y(e,t,n){let r=`</${n}>`,i=1,s=t;for(;s<e.length;){let o=e.indexOf(`<${n}`,s),c=e.indexOf(r,s);if(c===-1)return -1;if(o!==-1&&o<c){let u=e.indexOf(">",o);u!==-1&&e[u-1]!=="/"&&i++,s=o+1;}else {if(i--,i===0)return c;s=c+1;}}return -1}function N(e){return `data-a-${crypto.createHash("md5").update(e).digest("hex").slice(0,6)}`}function R(e,t){return H(e,t)}function H(e,t,n){let r="",i=0;for(;i<e.length;){let s=/^\s+/.exec(e.slice(i));if(s&&(r+=s[0],i+=s[0].length,i>=e.length))break;if(e.slice(i,i+2)==="/*"){let m=e.indexOf("*/",i+2);if(m===-1){r+=e.slice(i);break}r+=e.slice(i,m+2),i=m+2;continue}if(e[i]==="}"){r+="}",i++;continue}let o=e.indexOf("{",i);if(o===-1){r+=e.slice(i);break}let c=e.slice(i,o),u=c.trim(),p=o+1,l=te(e,o),a=e.slice(p,l);if(u.startsWith("@")){let m=u.split(/\s/)[0];m==="@keyframes"||m==="@-webkit-keyframes"||m==="@font-face"?r+=c+"{"+a+"}":r+=c+"{"+H(a,t)+"}";}else {let m=ne(u,t);r+=c.replace(u,m)+"{"+a+"}";}i=l+1;}return r}function te(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;)e[r]==="{"?n++:e[r]==="}"&&n--,n>0&&r++;return r}function ne(e,t){return e.split(",").map(n=>{let r=n.trim();return !r||r===":root"||r===":host"||r.includes(t)?n:re(r,t)}).join(",")}function re(e,t){let n=e.split(/(\s*[>+~]\s*|\s+)/);for(let r=n.length-1;r>=0;r--){let i=n[r].trim();if(i&&!ie(i)){if(i.includes("::")){let[s,o]=i.split("::");n[r]=n[r].replace(i,`${s}[${t}]::${o}`);}else if(i.includes(":")){let s=i.indexOf(":"),o=i.slice(0,s),c=i.slice(s);n[r]=n[r].replace(i,`${o}[${t}]${c}`);}else n[r]=n[r].replace(i,`${i}[${t}]`);break}}return n.join("")}function ie(e){return e===">"||e==="+"||e==="~"}function O(e,t={}){let n=t.scopeId??(t.filename?N(t.filename):void 0),i=new Set;i.add("defineComponent");let s=e.script?.content??"",o=e.template?.content??"";oe(s,o,i);let c=t.mode==="server",u="";if(e.template){let b=h(e.template.content);c?u=me(b,i,n):u=le(b,i,n);}let p="";i.size>0&&(p+=`import { ${[...i].join(", ")} } from '@akashjs/runtime';
2
- `);let{cleanScript:l,propsInterface:a}=ce(s),{userImports:m,bodyScript:d}=ae(l);m.length>0&&(p+=m.join(`
1
+ 'use strict';var crypto=require('crypto');function v(e){return {script:w(e,"script",(t,n,r,i)=>({content:t,lang:Z(n,"lang")??"ts",start:r,end:i})),template:w(e,"template",(t,n,r,i)=>({content:t,start:r,end:i})),style:w(e,"style",(t,n,r,i)=>({content:t,scoped:n.includes("scoped"),start:r,end:i}))}}function w(e,t,n){let r=new RegExp(`<${t}(\\b[^>]*)>`,"i"),i=new RegExp(`</${t}>`,"i"),s=r.exec(e);if(!s)return null;let o=s[1]??"",l=s.index+s[0].length,p=i.exec(e.slice(l));if(!p)return null;let u=l+p.index,c=e.slice(l,u);return n(c.trim(),o,l,u)}function Z(e,t){return new RegExp(`${t}=["']([^"']+)["']`).exec(e)?.[1]??null}function h(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="<"){if(e[n+1]==="/")break;let s=K(e,n);if(s){t.push(s.node),n=s.end;continue}}if(e[n]==="{"){let s=Q(e,n);if(s){t.push(s.node),n=s.end;continue}}let r=X(e,n),i=e.slice(n,r).trim();i&&t.push({type:"text",content:i}),n=r;}return t}function K(e,t){let n=/^<([a-zA-Z][a-zA-Z0-9-]*)/.exec(e.slice(t));if(!n)return null;let r=n[1],i=t+n[0].length,s=[],o=[];for(;i<e.length;){let g=/^\s+/.exec(e.slice(i));if(g&&(i+=g[0].length),e[i]===">"||e.slice(i,i+2)==="/>")break;let f=q(e,i);f?(f.attr.name.startsWith("bind:")?o.push({name:"bind",arg:f.attr.name.slice(5),value:f.attr.value}):f.attr.name.startsWith(":")?o.push({name:f.attr.name.slice(1),value:f.attr.value}):s.push(f.attr),i=f.end):i++;}let l=r[0]===r[0].toUpperCase();if(e.slice(i,i+2)==="/>")return {node:{type:l?"component":"element",tag:r,attrs:s,directives:o.length>0?o:void 0,children:[]},end:i+2};i++;let p=h(e.slice(i));e.slice(i);let c=`</${r}>`,a=Y(e,i,r);if(a===-1)return {node:{type:l?"component":"element",tag:r,attrs:s,directives:o.length>0?o:void 0,children:p},end:e.length};let m=e.slice(i,a),d=h(m);return {node:{type:l?"component":"element",tag:r,attrs:s,directives:o.length>0?o:void 0,children:d},end:a+c.length}}function q(e,t){let n=/^(?:bind:|[:a-zA-Z_])[\w:.-]*/.exec(e.slice(t));if(!n)return null;let r=n[0],i=t+r.length;if(e[i]!=="=")return {attr:{name:r,value:"true",dynamic:false},end:i};if(i++,e[i]==="{"){let o=M(e,i);if(o)return {attr:{name:r,value:o.content,dynamic:true},end:o.end}}let s=e[i];if(s==='"'||s==="'"){let o=e.indexOf(s,i+1);return o===-1?null:{attr:{name:r,value:e.slice(i+1,o),dynamic:false},end:o+1}}return null}function Q(e,t){let n=M(e,t);return n?{node:{type:"expression",content:n.content},end:n.end}:null}function M(e,t){if(e[t]!=="{")return null;let n=1,r=t+1;for(;r<e.length&&n>0;){let i=e[r];if(i==='"'||i==="'"||i==="`"){r=G(e,r)+1;continue}i==="{"?n++:i==="}"&&n--,r++;}return {content:e.slice(t+1,r-1).trim(),end:r}}function G(e,t){let n=e[t],r=t+1;for(;r<e.length;){if(e[r]==="\\"){r+=2;continue}if(e[r]===n)return r;r++;}return r}function X(e,t){let n=t;for(;n<e.length;){if(e[n]==="<"||e[n]==="{")return n;n++;}return n}function Y(e,t,n){let r=`</${n}>`,i=1,s=t;for(;s<e.length;){let o=e.indexOf(`<${n}`,s),l=e.indexOf(r,s);if(l===-1)return -1;if(o!==-1&&o<l){let p=e.indexOf(">",o);p!==-1&&e[p-1]!=="/"&&i++,s=o+1;}else {if(i--,i===0)return l;s=l+1;}}return -1}function N(e){return `data-a-${crypto.createHash("md5").update(e).digest("hex").slice(0,6)}`}function R(e,t){return P(e,t)}function P(e,t,n){let r="",i=0;for(;i<e.length;){let s=/^\s+/.exec(e.slice(i));if(s&&(r+=s[0],i+=s[0].length,i>=e.length))break;if(e.slice(i,i+2)==="/*"){let m=e.indexOf("*/",i+2);if(m===-1){r+=e.slice(i);break}r+=e.slice(i,m+2),i=m+2;continue}if(e[i]==="}"){r+="}",i++;continue}let o=e.indexOf("{",i);if(o===-1){r+=e.slice(i);break}let l=e.slice(i,o),p=l.trim(),u=o+1,c=te(e,o),a=e.slice(u,c);if(p.startsWith("@")){let m=p.split(/\s/)[0];m==="@keyframes"||m==="@-webkit-keyframes"||m==="@font-face"?r+=l+"{"+a+"}":r+=l+"{"+P(a,t)+"}";}else {let m=ne(p,t);r+=l.replace(p,m)+"{"+a+"}";}i=c+1;}return r}function te(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;)e[r]==="{"?n++:e[r]==="}"&&n--,n>0&&r++;return r}function ne(e,t){return e.split(",").map(n=>{let r=n.trim();return !r||r===":root"||r===":host"||r.includes(t)?n:re(r,t)}).join(",")}function re(e,t){let n=e.split(/(\s*[>+~]\s*|\s+)/);for(let r=n.length-1;r>=0;r--){let i=n[r].trim();if(i&&!ie(i)){if(i.includes("::")){let[s,o]=i.split("::");n[r]=n[r].replace(i,`${s}[${t}]::${o}`);}else if(i.includes(":")){let s=i.indexOf(":"),o=i.slice(0,s),l=i.slice(s);n[r]=n[r].replace(i,`${o}[${t}]${l}`);}else n[r]=n[r].replace(i,`${i}[${t}]`);break}}return n.join("")}function ie(e){return e===">"||e==="+"||e==="~"}function O(e,t={}){let n=t.scopeId??(t.filename?N(t.filename):void 0),i=new Set;i.add("defineComponent");let s=e.script?.content??"",o=e.template?.content??"";ae(s,o,i);let l=t.mode==="server",p="";if(e.template){let $=h(e.template.content);l?p=de($,i,n):p=ue($,i,n);}let u="";i.size>0&&(u+=`import { ${[...i].join(", ")} } from '@akashjs/runtime';
2
+ `);let{cleanScript:c,propsInterface:a}=ce(s),{userImports:m,bodyScript:d}=le(c);m.length>0&&(u+=m.join(`
3
3
  `)+`
4
- `);let g=a?`<${a}>`:"";if(p+=`
5
- `,p+=`export default defineComponent${g}((ctx) => {
6
- `,s.includes("props")&&(p+=` const props = ctx.props;
7
- `),d.trim()){let b=d.trim().split(`
4
+ `);let g=a?`<${a}>`:"";if(u+=`
5
+ `,u+=`export default defineComponent${g}((ctx) => {
6
+ `,s.includes("props")&&(u+=` const props = ctx.props;
7
+ `),d.trim()){let $=d.trim().split(`
8
8
  `).map(_=>` ${_}`).join(`
9
- `);p+=`${b}
10
- `;}p+=`
11
- `,p+=` return () => {
12
- `,p+=u,p+=` };
13
- `,p+=`});
14
- `;let f;return e.style&&(f=e.style.scoped&&n?R(e.style.content,n):e.style.content),{code:p,css:f}}function se(e){let t=e.trim();return !!(/^(?:\([^)]*\)|[a-zA-Z_$]\w*)\s*=>/.test(t)||/^function[\s(]/.test(t))}function oe(e,t,n){let r=["signal","computed","effect","batch","untrack","onMount","onUnmount","onError","ref","createContext","provide","inject","Show","For"];for(let s of r){let o=new RegExp(`\\b${s}\\b`),c=new RegExp(`import\\s+.*\\b${s}\\b.*from`);o.test(e)&&!c.test(e)&&n.add(s);}let i=["Show","For"];for(let s of i)new RegExp(`<${s}[\\s/>]`).test(t)&&!n.has(s)&&n.add(s);}function ae(e){let t=e.split(`
9
+ `);u+=`${$}
10
+ `;}u+=`
11
+ `,u+=` return () => {
12
+ `,u+=p,u+=` };
13
+ `,u+=`});
14
+ `;let f;return e.style&&(f=e.style.scoped&&n?R(e.style.content,n):e.style.content),{code:u,css:f}}function se(e){let t=e.trim();return !!(/^(?:\([^)]*\)|[a-zA-Z_$]\w*)\s*=>/.test(t)||/^function[\s(]/.test(t))}function oe(e){let t=e.trim();return /^\[/.test(t)&&!t.includes("(")||/^\{/.test(t)&&!t.includes("(")||/^["'`]/.test(t)||/^\d/.test(t)||t==="true"||t==="false"||t==="null"||t==="undefined"||t.startsWith("`")&&!t.includes("(")?false:/\w\(/.test(t)?true:!(/^[a-zA-Z_$][\w$.]*$/.test(t)||!t.includes("("))}function ae(e,t,n){let r=["signal","computed","effect","batch","untrack","onMount","onUnmount","onError","ref","createContext","provide","inject","Show","For"];for(let s of r){let o=new RegExp(`\\b${s}\\b`),l=new RegExp(`import\\s+.*\\b${s}\\b.*from`);o.test(e)&&!l.test(e)&&n.add(s);}let i=["Show","For"];for(let s of i)new RegExp(`<${s}[\\s/>]`).test(t)&&!n.has(s)&&n.add(s);}function le(e){let t=e.split(`
15
15
  `),n=[],r=[],i=false;for(let s of t){if(i){n[n.length-1]+=`
16
16
  `+s,(s.includes("from ")||s.trimEnd().endsWith(";"))&&(i=false);continue}let o=s.trim();/^import\s/.test(o)?(n.push(s.trim()),!o.includes("from ")&&!o.endsWith(";")&&(i=true)):r.push(s);}return {userImports:n,bodyScript:r.join(`
17
- `)}}function ce(e){let t=/interface\s+Props\s*\{([^}]*)\}/s.exec(e);if(!t)return {cleanScript:e,propsInterface:null};let n=e.replace(t[0],"").trim(),r=`{${t[1].trim()}}`;return {cleanScript:n,propsInterface:r}}function le(e,t,n){if(e.length===0)return ` return null;
18
- `;if(e.length===1){let i=[];return $(e[0],i,t,4,"root",n),i.push(" return root;"),i.join(`
17
+ `)}}function ce(e){let t=/interface\s+Props\s*\{([^}]*)\}/s.exec(e);if(!t)return {cleanScript:e,propsInterface:null};let n=e.replace(t[0],"").trim(),r=`{${t[1].trim()}}`;return {cleanScript:n,propsInterface:r}}function ue(e,t,n){if(e.length===0)return ` return null;
18
+ `;if(e.length===1){let i=[];return b(e[0],i,t,4,"root",n),i.push(" return root;"),i.join(`
19
19
  `)+`
20
- `}t.add("createElement");let r=[];r.push(" const __fragment = document.createDocumentFragment();");for(let i=0;i<e.length;i++){let s=`__n${i}`;$(e[i],r,t,4,s,n),r.push(` __fragment.appendChild(${s});`);}return r.push(" return __fragment;"),r.join(`
20
+ `}t.add("createElement");let r=[];r.push(" const __fragment = document.createDocumentFragment();");for(let i=0;i<e.length;i++){let s=`__n${i}`;b(e[i],r,t,4,s,n),r.push(` __fragment.appendChild(${s});`);}return r.push(" return __fragment;"),r.join(`
21
21
  `)+`
22
- `}function $(e,t,n,r,i,s){let o=" ".repeat(r);switch(e.type){case "element":E(e,t,n,r,i,s);break;case "component":ue(e,t,n,r,i,s);break;case "text":t.push(`${o}const ${i} = document.createTextNode(${JSON.stringify(e.content??"")});`);break;case "expression":n.add("effect"),t.push(`${o}const ${i} = document.createTextNode('');`),t.push(`${o}effect(() => { ${i}.textContent = String(${e.content}); }, { render: true });`);break}}function E(e,t,n,r,i,s){let o=" ".repeat(r),c=e.tag,u=e.directives?.find(a=>a.name==="if");if(u){n.add("renderConditional"),t.push(`${o}const ${i}_anchor = document.createComment('if');`),t.push(`${o}const ${i} = document.createDocumentFragment();`),t.push(`${o}${i}.appendChild(${i}_anchor);`),t.push(`${o}renderConditional(${i}, ${i}_anchor, () => ${u.value}, () => {`);let a=[],m={...e,directives:e.directives?.filter(d=>d.name!=="if")};E(m,a,n,r+2,"__el",s),a.push(`${o} return __el;`),t.push(...a),t.push(`${o}});`);return}let p=e.directives?.find(a=>a.name==="for");if(p){n.add("renderList");let a=e.directives?.find(d=>d.name==="key"),m=/^(?:\(([^)]+)\)|(\w+))\s+of\s+(.+)$/.exec(p.value);if(m){let d=m[1]??m[2],g=m[3],f=a?.value??`${d}`;t.push(`${o}const ${i}_anchor = document.createComment('for');`),t.push(`${o}const ${i} = document.createDocumentFragment();`),t.push(`${o}${i}.appendChild(${i}_anchor);`),t.push(`${o}renderList(${i}, ${i}_anchor, () => ${g}, (${d}) => ${f}, (${d}) => {`);let b=[],_={...e,directives:e.directives?.filter(j=>j.name!=="for"&&j.name!=="key")};E(_,b,n,r+2,"__el",s),b.push(`${o} return __el;`),t.push(...b),t.push(`${o}});`);}return}let l=e.directives?.filter(a=>a.name==="bind")??[];if(l.length>0&&e.directives&&(e.directives=e.directives.filter(a=>a.name!=="bind")),t.push(`${o}const ${i} = document.createElement('${c}');`),s&&t.push(`${o}${i}.setAttribute('${s}', '');`),e.attrs)for(let a of e.attrs)a.dynamic?(n.add("effect"),a.name.startsWith("on")?t.push(`${o}${i}.addEventListener('${a.name.slice(2).toLowerCase()}', ${a.value});`):(t.push(`${o}effect(() => {`),a.name==="class"||a.name==="className"?t.push(`${o} ${i}.className = ${a.value};`):t.push(`${o} ${i}.setAttribute('${a.name}', String(${a.value}));`),t.push(`${o}}, { render: true });`))):a.name==="class"||a.name==="className"?t.push(`${o}${i}.className = ${JSON.stringify(a.value)};`):a.name.startsWith("on")?t.push(`${o}${i}.setAttribute('${a.name}', ${JSON.stringify(a.value)});`):t.push(`${o}${i}.setAttribute('${a.name}', ${JSON.stringify(a.value)});`);for(let a of l){let m=a.arg??"value",d=a.value;n.add("effect"),t.push(`${o}effect(() => { ${i}.${m} = ${d}(); }, { render: true });`);let g=m==="value"||m==="checked"?"input":"change",f=m==="checked"?"checked":"value";t.push(`${o}${i}.addEventListener('${g}', (e) => { ${d}.set(e.target.${f}); });`);}if(e.children&&e.children.length>0)for(let a=0;a<e.children.length;a++){let m=`${i}_c${a}`;$(e.children[a],t,n,r,m,s),t.push(`${o}${i}.appendChild(${m});`);}}function ue(e,t,n,r,i,s){let o=" ".repeat(r),c=e.tag,u=[];if(e.attrs)for(let l of e.attrs)if(l.dynamic){let a=pe(l.value,n,r,s);a?u.push(`${l.name}: ${a}`):l.name.startsWith("on")||se(l.value)?u.push(`${l.name}: ${l.value}`):u.push(`${l.name}: () => ${l.value}`);}else u.push(`${l.name}: ${JSON.stringify(l.value)}`);if(e.children&&e.children.length>0){let l=P(e.children,n,r+2,s);u.push(`children: ${l}`);}let p=u.length>0?`{ ${u.join(", ")} }`:"{}";t.push(`${o}const ${i} = ${c}(${p});`);}function P(e,t,n,r){if(e.length===1&&e[0].type==="expression"){let c=z(e[0].content??"",t,n,r);if(c)return c}let i=" ".repeat(n),s=[],o=e.filter(c=>!(c.type==="text"&&!(c.content??"").trim()));if(o.length===1)$(o[0],s,t,n,"__child",r),s.push(`${i}return __child;`);else {s.push(`${i}const __frag = document.createDocumentFragment();`);for(let c=0;c<o.length;c++){let u=`__child${c}`;$(o[c],s,t,n,u,r),s.push(`${i}__frag.appendChild(${u});`);}s.push(`${i}return __frag;`);}return `() => {
22
+ `}function b(e,t,n,r,i,s){let o=" ".repeat(r);switch(e.type){case "element":E(e,t,n,r,i,s);break;case "component":pe(e,t,n,r,i,s);break;case "text":t.push(`${o}const ${i} = document.createTextNode(${JSON.stringify(e.content??"")});`);break;case "expression":n.add("effect"),t.push(`${o}const ${i} = document.createTextNode('');`),t.push(`${o}effect(() => { ${i}.textContent = String(${e.content}); }, { render: true });`);break}}function E(e,t,n,r,i,s){let o=" ".repeat(r),l=e.tag,p=e.directives?.find(a=>a.name==="if");if(p){n.add("renderConditional"),t.push(`${o}const ${i}_anchor = document.createComment('if');`),t.push(`${o}const ${i} = document.createDocumentFragment();`),t.push(`${o}${i}.appendChild(${i}_anchor);`),t.push(`${o}renderConditional(${i}, ${i}_anchor, () => ${p.value}, () => {`);let a=[],m={...e,directives:e.directives?.filter(d=>d.name!=="if")};E(m,a,n,r+2,"__el",s),a.push(`${o} return __el;`),t.push(...a),t.push(`${o}});`);return}let u=e.directives?.find(a=>a.name==="for");if(u){n.add("renderList");let a=e.directives?.find(d=>d.name==="key"),m=/^(?:\(([^)]+)\)|(\w+))\s+of\s+(.+)$/.exec(u.value);if(m){let d=m[1]??m[2],g=m[3],f=a?.value??`${d}`;t.push(`${o}const ${i}_anchor = document.createComment('for');`),t.push(`${o}const ${i} = document.createDocumentFragment();`),t.push(`${o}${i}.appendChild(${i}_anchor);`),t.push(`${o}renderList(${i}, ${i}_anchor, () => ${g}, (${d}) => ${f}, (${d}) => {`);let $=[],_={...e,directives:e.directives?.filter(j=>j.name!=="for"&&j.name!=="key")};E(_,$,n,r+2,"__el",s),$.push(`${o} return __el;`),t.push(...$),t.push(`${o}});`);}return}let c=e.directives?.filter(a=>a.name==="bind")??[];if(c.length>0&&e.directives&&(e.directives=e.directives.filter(a=>a.name!=="bind")),t.push(`${o}const ${i} = document.createElement('${l}');`),s&&t.push(`${o}${i}.setAttribute('${s}', '');`),e.attrs)for(let a of e.attrs)a.dynamic?(n.add("effect"),a.name.startsWith("on")?t.push(`${o}${i}.addEventListener('${a.name.slice(2).toLowerCase()}', ${a.value});`):(t.push(`${o}effect(() => {`),a.name==="class"||a.name==="className"?t.push(`${o} ${i}.className = ${a.value};`):t.push(`${o} ${i}.setAttribute('${a.name}', String(${a.value}));`),t.push(`${o}}, { render: true });`))):a.name==="class"||a.name==="className"?t.push(`${o}${i}.className = ${JSON.stringify(a.value)};`):a.name.startsWith("on")?t.push(`${o}${i}.setAttribute('${a.name}', ${JSON.stringify(a.value)});`):t.push(`${o}${i}.setAttribute('${a.name}', ${JSON.stringify(a.value)});`);for(let a of c){let m=a.arg??"value",d=a.value;n.add("effect"),t.push(`${o}effect(() => { ${i}.${m} = ${d}(); }, { render: true });`);let g=m==="value"||m==="checked"?"input":"change",f=m==="checked"?"checked":"value";t.push(`${o}${i}.addEventListener('${g}', (e) => { ${d}.set(e.target.${f}); });`);}if(e.children&&e.children.length>0)for(let a=0;a<e.children.length;a++){let m=`${i}_c${a}`;b(e.children[a],t,n,r,m,s),t.push(`${o}${i}.appendChild(${m});`);}}function pe(e,t,n,r,i,s){let o=" ".repeat(r),l=e.tag,p=l==="Show"||l==="For"||l==="Switch",u=[];if(e.attrs)for(let a of e.attrs)if(a.dynamic){let m=me(a.value,n,r,s);m?u.push(`${a.name}: ${m}`):a.name.startsWith("on")||se(a.value)?u.push(`${a.name}: ${a.value}`):p&&oe(a.value)?u.push(`${a.name}: () => ${a.value}`):u.push(`${a.name}: ${a.value}`);}else u.push(`${a.name}: ${JSON.stringify(a.value)}`);if(e.children&&e.children.length>0){let a=H(e.children,n,r+2,s);u.push(`children: ${a}`);}let c=u.length>0?`{ ${u.join(", ")} }`:"{}";t.push(`${o}const ${i} = ${l}(${c});`);}function H(e,t,n,r){if(e.length===1&&e[0].type==="expression"){let l=z(e[0].content??"",t,n,r);if(l)return l}let i=" ".repeat(n),s=[],o=e.filter(l=>!(l.type==="text"&&!(l.content??"").trim()));if(o.length===1)b(o[0],s,t,n,"__child",r),s.push(`${i}return __child;`);else {s.push(`${i}const __frag = document.createDocumentFragment();`);for(let l=0;l<o.length;l++){let p=`__child${l}`;b(o[l],s,t,n,p,r),s.push(`${i}__frag.appendChild(${p});`);}s.push(`${i}return __frag;`);}return `() => {
23
23
  ${s.join(`
24
24
  `)}
25
- ${" ".repeat(n-2)}}`}function z(e,t,n,r){let i=e.trim(),s=/^(\(?[^)]*\)?)\s*=>\s*(<[a-zA-Z].*)$/s.exec(i);if(!s)return null;let o=s[1],c=s[2],u=h(c);if(u.length===0)return null;let p=" ".repeat(n),l=[];if(u.length===1)$(u[0],l,t,n,"__child",r),l.push(`${p}return __child;`);else {l.push(`${p}const __frag = document.createDocumentFragment();`);for(let a=0;a<u.length;a++){let m=`__child${a}`;$(u[a],l,t,n,m,r),l.push(`${p}__frag.appendChild(${m});`);}l.push(`${p}return __frag;`);}return `${o} => {
26
- ${l.join(`
25
+ ${" ".repeat(n-2)}}`}function z(e,t,n,r){let i=e.trim(),s=/^(\(?[^)]*\)?)\s*=>\s*(<[a-zA-Z].*)$/s.exec(i);if(!s)return null;let o=s[1],l=s[2],p=h(l);if(p.length===0)return null;let u=" ".repeat(n),c=[];if(p.length===1)b(p[0],c,t,n,"__child",r),c.push(`${u}return __child;`);else {c.push(`${u}const __frag = document.createDocumentFragment();`);for(let a=0;a<p.length;a++){let m=`__child${a}`;b(p[a],c,t,n,m,r),c.push(`${u}__frag.appendChild(${m});`);}c.push(`${u}return __frag;`);}return `${o} => {
26
+ ${c.join(`
27
27
  `)}
28
- ${" ".repeat(n-2)}}`}function pe(e,t,n,r){let i=e.trim(),s=z(i,t,n+2,r);if(s)return s;if(!/^<[a-zA-Z]/.test(i))return null;let o=h(i);return o.length===0?null:P(o,t,n+2,r)}function me(e,t,n){if(e.length===0)return ` return '';
28
+ ${" ".repeat(n-2)}}`}function me(e,t,n,r){let i=e.trim(),s=z(i,t,n+2,r);if(s)return s;if(!/^<[a-zA-Z]/.test(i))return null;let o=h(i);return o.length===0?null:H(o,t,n+2,r)}function de(e,t,n){if(e.length===0)return ` return '';
29
29
  `;let r=[];r.push(" let __html = '';");for(let i of e)B(i,r,t,4,n);return r.push(" return __html;"),r.join(`
30
30
  `)+`
31
- `}function B(e,t,n,r,i){let s=" ".repeat(r);switch(e.type){case "text":t.push(`${s}__html += ${JSON.stringify(e.content??"")};`);break;case "expression":n.add("escapeHtml"),t.push(`${s}__html += escapeHtml(String(${e.content}));`);break;case "element":D(e,t,n,r,i);break;case "component":t.push(`${s}// TODO: SSR component rendering for ${e.tag}`),t.push(`${s}__html += '';`);break}}var de=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function D(e,t,n,r,i){let s=" ".repeat(r),o=e.tag,c=e.directives?.find(l=>l.name==="if");if(c){t.push(`${s}if (${c.value}) {`);let l={...e,directives:e.directives?.filter(a=>a.name!=="if")};D(l,t,n,r+2,i),t.push(`${s}}`);return}let u=e.directives?.find(l=>l.name==="for");if(u){let l=/^(?:\(([^)]+)\)|(\w+))\s+of\s+(.+)$/.exec(u.value);if(l){let a=l[1]??l[2],m=l[3];t.push(`${s}for (const ${a} of ${m}) {`);let d={...e,directives:e.directives?.filter(g=>g.name!=="for"&&g.name!=="key")};D(d,t,n,r+2,i),t.push(`${s}}`);}return}let p=`'<${o}`;if(i&&(p+=` ${i}`),e.attrs)for(let l of e.attrs)l.name.startsWith("on")||(l.dynamic?(t.push(`${s}__html += ${p}';`),p="'",n.add("escapeHtml"),l.name==="class"||l.name==="className"?t.push(`${s}__html += ' class="' + escapeHtml(String(${l.value})) + '"';`):t.push(`${s}__html += ' ${l.name}="' + escapeHtml(String(${l.value})) + '"';`)):l.name==="class"||l.name==="className"?p+=` class="${l.value}"`:p+=` ${l.name}="${l.value}"`);if(de.has(o)){t.push(`${s}__html += ${p} />';`);return}if(t.push(`${s}__html += ${p}>';`),e.children)for(let l of e.children)B(l,t,n,r,i);t.push(`${s}__html += '</${o}>';`);}function fe(e){let t={signalReads:[],eventHandlers:[],hasDynamicContent:false,staticSubtrees:[],reactiveExpressions:[],componentRefs:[]};for(let n of e)L(n,t);return t}function L(e,t){switch(e.type){case "expression":t.hasDynamicContent=true,e.content&&(t.reactiveExpressions.push({expression:e.content,kind:"text"}),y(e.content,"text",t));break;case "element":ge(e,t);break;case "component":if(e.tag&&t.componentRefs.push(e.tag),t.hasDynamicContent=true,F(e,t),e.children)for(let n of e.children)L(n,t);break;}}function ge(e,t){let n=V(e);if(e.directives)for(let r of e.directives)t.hasDynamicContent=true,he(r,e,t);if(F(e,t),!n&&!e.directives?.length&&t.staticSubtrees.push(e),e.children)for(let r of e.children)L(r,t);}function F(e,t){if(e.attrs){for(let n of e.attrs)if(n.dynamic)if(t.hasDynamicContent=true,n.name.startsWith("on")){let r=n.name.slice(2).toLowerCase();t.eventHandlers.push({event:r,handler:n.value,tag:e.tag??"unknown"});}else t.reactiveExpressions.push({expression:n.value,kind:"attribute",attributeName:n.name}),y(n.value,"attribute",t);}}function he(e,t,n){switch(e.name){case "if":case "else-if":case "show":n.reactiveExpressions.push({expression:e.value,kind:"conditional"}),y(e.value,"directive",n);break;case "for":{let r=/\bof\s+(.+)$/.exec(e.value);r&&(n.reactiveExpressions.push({expression:r[1],kind:"list"}),y(r[1],"directive",n));break}case "bind":{n.reactiveExpressions.push({expression:e.value,kind:"attribute",attributeName:e.value}),y(e.value,"directive",n);break}}}function y(e,t,n){let r=new Set(["console","Math","JSON","Object","Array","String","Number","Boolean","Date","RegExp","Error","Promise","parseInt","parseFloat","setTimeout","setInterval","clearTimeout","clearInterval","document","window","navigator","fetch"]),i=/\b([a-zA-Z_$][\w$]*)\s*\(\s*\)/g,s;for(;(s=i.exec(e))!==null;){let o=s[1];r.has(o)||n.signalReads.push({expression:`${o}()`,context:t});}}function V(e){return !!(e.attrs?.some(t=>t.dynamic)||e.directives?.length||e.children?.some(t=>t.type==="expression"||t.type==="component")||e.children?.some(t=>V(t)))}function be(e){let t=e.trim();return !!(/^['"`].*['"`]$/.test(t)||/^-?\d+(\.\d+)?$/.test(t)||t==="true"||t==="false"||t==="null"||t==="undefined")}var $e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function x(e){let t="",n=e<0?-e<<1|1:e<<1;do{let r=n&31;n>>>=5,n>0&&(r|=32),t+=$e[r];}while(n>0);return t}var S=class{mappings=[];sources=[];sourcesContent=[];addSource(t,n){let r=this.sources.length;return this.sources.push(t),this.sourcesContent.push(n??null),r}addMapping(t){this.mappings.push(t);}addLineRange(t,n,r,i=0){for(let s=0;s<r;s++)this.addMapping({generatedLine:t+s,generatedColumn:0,originalLine:n+s,originalColumn:0,source:i});}build(t){let n=[...this.mappings].sort((r,i)=>r.generatedLine-i.generatedLine||r.generatedColumn-i.generatedColumn);return {version:3,file:t,sources:this.sources,sourcesContent:this.sourcesContent,names:[],mappings:ve(n)}}toJSON(t){return JSON.stringify(this.build(t))}toDataUrl(t){let n=this.toJSON(t);return `data:application/json;charset=utf-8;base64,${typeof btoa=="function"?btoa(n):Buffer.from(n).toString("base64")}`}};function ve(e){let t=[],n=0,r=0,i=0,s=0,o=0;for(let c of e){for(;t.length<=c.generatedLine;)t.push([]);c.generatedLine!==n&&(r=0,n=c.generatedLine);let u="";u+=x(c.generatedColumn-r),r=c.generatedColumn;let p=c.source??0;u+=x(p-o),o=p,u+=x(c.originalLine-i),i=c.originalLine,u+=x(c.originalColumn-s),s=c.originalColumn,t[c.generatedLine].push(u);}return t.map(c=>c.join(",")).join(";")}function ye(e,t,n,r,i){let s=new S;return s.addSource(e,t),s.addLineRange(i,n,r,0),s}function T(e){return e.type==="expression"||e.type==="component"?false:e.type==="text"?true:!(e.directives&&e.directives.length>0||e.attrs?.some(t=>t.dynamic)||e.children?.some(t=>!T(t)))}function A(e){switch(e.type){case "text":return e.content??"";case "element":{let t=`<${e.tag}`;if(e.attrs)for(let n of e.attrs)n.name==="class"||n.name==="className"?t+=` class="${n.value}"`:t+=` ${n.name}="${n.value}"`;if(t+=">",e.children)for(let n of e.children)t+=A(n);return t+=`</${e.tag}>`,t}default:return ""}}function J(e){let t=[],n=0;function r(i){if(i.type==="element"){if(T(i)&&i.children&&i.children.length>0){let s=`__hoisted_${n++}`;t.push({varName:s,html:A(i)}),i._hoisted=s;return}if(i.children)for(let s of i.children)r(s);}}for(let i of e)r(i);return t}function xe(e){if(e.length===0)return "";let t=`// Hoisted static templates (created once, cloned per instance)
31
+ `}function B(e,t,n,r,i){let s=" ".repeat(r);switch(e.type){case "text":t.push(`${s}__html += ${JSON.stringify(e.content??"")};`);break;case "expression":n.add("escapeHtml"),t.push(`${s}__html += escapeHtml(String(${e.content}));`);break;case "element":D(e,t,n,r,i);break;case "component":t.push(`${s}// TODO: SSR component rendering for ${e.tag}`),t.push(`${s}__html += '';`);break}}var fe=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function D(e,t,n,r,i){let s=" ".repeat(r),o=e.tag,l=e.directives?.find(c=>c.name==="if");if(l){t.push(`${s}if (${l.value}) {`);let c={...e,directives:e.directives?.filter(a=>a.name!=="if")};D(c,t,n,r+2,i),t.push(`${s}}`);return}let p=e.directives?.find(c=>c.name==="for");if(p){let c=/^(?:\(([^)]+)\)|(\w+))\s+of\s+(.+)$/.exec(p.value);if(c){let a=c[1]??c[2],m=c[3];t.push(`${s}for (const ${a} of ${m}) {`);let d={...e,directives:e.directives?.filter(g=>g.name!=="for"&&g.name!=="key")};D(d,t,n,r+2,i),t.push(`${s}}`);}return}let u=`'<${o}`;if(i&&(u+=` ${i}`),e.attrs)for(let c of e.attrs)c.name.startsWith("on")||(c.dynamic?(t.push(`${s}__html += ${u}';`),u="'",n.add("escapeHtml"),c.name==="class"||c.name==="className"?t.push(`${s}__html += ' class="' + escapeHtml(String(${c.value})) + '"';`):t.push(`${s}__html += ' ${c.name}="' + escapeHtml(String(${c.value})) + '"';`)):c.name==="class"||c.name==="className"?u+=` class="${c.value}"`:u+=` ${c.name}="${c.value}"`);if(fe.has(o)){t.push(`${s}__html += ${u} />';`);return}if(t.push(`${s}__html += ${u}>';`),e.children)for(let c of e.children)B(c,t,n,r,i);t.push(`${s}__html += '</${o}>';`);}function ge(e){let t={signalReads:[],eventHandlers:[],hasDynamicContent:false,staticSubtrees:[],reactiveExpressions:[],componentRefs:[]};for(let n of e)A(n,t);return t}function A(e,t){switch(e.type){case "expression":t.hasDynamicContent=true,e.content&&(t.reactiveExpressions.push({expression:e.content,kind:"text"}),y(e.content,"text",t));break;case "element":he(e,t);break;case "component":if(e.tag&&t.componentRefs.push(e.tag),t.hasDynamicContent=true,F(e,t),e.children)for(let n of e.children)A(n,t);break;}}function he(e,t){let n=V(e);if(e.directives)for(let r of e.directives)t.hasDynamicContent=true,$e(r,e,t);if(F(e,t),!n&&!e.directives?.length&&t.staticSubtrees.push(e),e.children)for(let r of e.children)A(r,t);}function F(e,t){if(e.attrs){for(let n of e.attrs)if(n.dynamic)if(t.hasDynamicContent=true,n.name.startsWith("on")){let r=n.name.slice(2).toLowerCase();t.eventHandlers.push({event:r,handler:n.value,tag:e.tag??"unknown"});}else t.reactiveExpressions.push({expression:n.value,kind:"attribute",attributeName:n.name}),y(n.value,"attribute",t);}}function $e(e,t,n){switch(e.name){case "if":case "else-if":case "show":n.reactiveExpressions.push({expression:e.value,kind:"conditional"}),y(e.value,"directive",n);break;case "for":{let r=/\bof\s+(.+)$/.exec(e.value);r&&(n.reactiveExpressions.push({expression:r[1],kind:"list"}),y(r[1],"directive",n));break}case "bind":{n.reactiveExpressions.push({expression:e.value,kind:"attribute",attributeName:e.value}),y(e.value,"directive",n);break}}}function y(e,t,n){let r=new Set(["console","Math","JSON","Object","Array","String","Number","Boolean","Date","RegExp","Error","Promise","parseInt","parseFloat","setTimeout","setInterval","clearTimeout","clearInterval","document","window","navigator","fetch"]),i=/\b([a-zA-Z_$][\w$]*)\s*\(\s*\)/g,s;for(;(s=i.exec(e))!==null;){let o=s[1];r.has(o)||n.signalReads.push({expression:`${o}()`,context:t});}}function V(e){return !!(e.attrs?.some(t=>t.dynamic)||e.directives?.length||e.children?.some(t=>t.type==="expression"||t.type==="component")||e.children?.some(t=>V(t)))}function be(e){let t=e.trim();return !!(/^['"`].*['"`]$/.test(t)||/^-?\d+(\.\d+)?$/.test(t)||t==="true"||t==="false"||t==="null"||t==="undefined")}var ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function x(e){let t="",n=e<0?-e<<1|1:e<<1;do{let r=n&31;n>>>=5,n>0&&(r|=32),t+=ve[r];}while(n>0);return t}var S=class{mappings=[];sources=[];sourcesContent=[];addSource(t,n){let r=this.sources.length;return this.sources.push(t),this.sourcesContent.push(n??null),r}addMapping(t){this.mappings.push(t);}addLineRange(t,n,r,i=0){for(let s=0;s<r;s++)this.addMapping({generatedLine:t+s,generatedColumn:0,originalLine:n+s,originalColumn:0,source:i});}build(t){let n=[...this.mappings].sort((r,i)=>r.generatedLine-i.generatedLine||r.generatedColumn-i.generatedColumn);return {version:3,file:t,sources:this.sources,sourcesContent:this.sourcesContent,names:[],mappings:ye(n)}}toJSON(t){return JSON.stringify(this.build(t))}toDataUrl(t){let n=this.toJSON(t);return `data:application/json;charset=utf-8;base64,${typeof btoa=="function"?btoa(n):Buffer.from(n).toString("base64")}`}};function ye(e){let t=[],n=0,r=0,i=0,s=0,o=0;for(let l of e){for(;t.length<=l.generatedLine;)t.push([]);l.generatedLine!==n&&(r=0,n=l.generatedLine);let p="";p+=x(l.generatedColumn-r),r=l.generatedColumn;let u=l.source??0;p+=x(u-o),o=u,p+=x(l.originalLine-i),i=l.originalLine,p+=x(l.originalColumn-s),s=l.originalColumn,t[l.generatedLine].push(p);}return t.map(l=>l.join(",")).join(";")}function xe(e,t,n,r,i){let s=new S;return s.addSource(e,t),s.addLineRange(i,n,r,0),s}function T(e){return e.type==="expression"||e.type==="component"?false:e.type==="text"?true:!(e.directives&&e.directives.length>0||e.attrs?.some(t=>t.dynamic)||e.children?.some(t=>!T(t)))}function L(e){switch(e.type){case "text":return e.content??"";case "element":{let t=`<${e.tag}`;if(e.attrs)for(let n of e.attrs)n.name==="class"||n.name==="className"?t+=` class="${n.value}"`:t+=` ${n.name}="${n.value}"`;if(t+=">",e.children)for(let n of e.children)t+=L(n);return t+=`</${e.tag}>`,t}default:return ""}}function W(e){let t=[],n=0;function r(i){if(i.type==="element"){if(T(i)&&i.children&&i.children.length>0){let s=`__hoisted_${n++}`;t.push({varName:s,html:L(i)}),i._hoisted=s;return}if(i.children)for(let s of i.children)r(s);}}for(let i of e)r(i);return t}function Se(e){if(e.length===0)return "";let t=`// Hoisted static templates (created once, cloned per instance)
32
32
  `;for(let n of e)t+=`const ${n.varName} = /*#__PURE__*/ (() => {
33
33
  `,t+=` const _t = document.createElement('template');
34
34
  `,t+=` _t.innerHTML = ${JSON.stringify(n.html)};
35
35
  `,t+=` return _t;
36
36
  `,t+=`})();
37
- `;return t}function Se(e){return e._hoisted??null}function Te(e){let t=0,n=0;function r(s){if(t++,T(s)&&n++,s.children)for(let o of s.children)r(o);}for(let s of e)r(s);let i=J(JSON.parse(JSON.stringify(e)));return {totalNodes:t,staticNodes:n,hoistedTemplates:i.length,staticRatio:t>0?n/t:0}}var I=[{label:"signal",kind:"property",detail:"signal<T>(initial: T): Signal<T>",documentation:"Create a reactive signal"},{label:"computed",kind:"property",detail:"computed<T>(fn: () => T): ReadonlySignal<T>",documentation:"Create a derived reactive value"},{label:"effect",kind:"property",detail:"effect(fn: () => void): () => void",documentation:"Run a side-effect when dependencies change"},{label:"batch",kind:"property",detail:"batch(fn: () => void): void",documentation:"Batch signal updates"},{label:"untrack",kind:"property",detail:"untrack<T>(fn: () => T): T",documentation:"Read signals without tracking"},{label:"onMount",kind:"property",detail:"onMount(fn: () => void | (() => void)): void",documentation:"Run after component mounts"},{label:"onUnmount",kind:"property",detail:"onUnmount(fn: () => void): void",documentation:"Run before component unmounts"},{label:"provide",kind:"property",detail:"provide<T>(key: InjectionKey<T>, value: T): void",documentation:"Provide a value to descendants"},{label:"inject",kind:"property",detail:"inject<T>(key: InjectionKey<T>): T",documentation:"Inject a value from ancestors"},{label:"defineStore",kind:"property",detail:"defineStore(id, config): () => Store",documentation:"Define a global store"},{label:"useHead",kind:"property",detail:"useHead(config: HeadConfig): void",documentation:"Manage document head tags"},{label:"cx",kind:"property",detail:"cx(...inputs): string",documentation:"Merge CSS class names"},{label:"pipe",kind:"property",detail:"pipe(value, transform, ...args): any",documentation:"Apply a pipe transform"}],k=[{label:"Show",kind:"component",detail:"<Show when={condition}>{value => ...}</Show>",documentation:"Conditional rendering with type narrowing"},{label:"For",kind:"component",detail:"<For each={items} key={fn}>{item => ...}</For>",documentation:"List rendering with keyed reconciliation"},{label:"Switch",kind:"component",detail:"<Switch on={value} cases={...} />",documentation:"Switch/case rendering"},{label:"Portal",kind:"component",detail:'<Portal target="selector">...</Portal>',documentation:"Render into different DOM node"},{label:"Transition",kind:"component",detail:'<Transition name="fade" when={show}>...</Transition>',documentation:"CSS enter/exit transitions"},{label:"ErrorBoundary",kind:"component",detail:"<ErrorBoundary fallback={fn}>...</ErrorBoundary>",documentation:"Catch errors from children"},{label:"Suspense",kind:"component",detail:"<Suspense fallback={fn}>...</Suspense>",documentation:"Show fallback during async loading"},{label:"VirtualFor",kind:"component",detail:"<VirtualFor each={items} itemHeight={40}>...</VirtualFor>",documentation:"Virtual scrolling for large lists"},{label:"Image",kind:"component",detail:'<Image src="..." alt="..." />',documentation:"Optimized image with lazy loading"}],C=[{label:":if",kind:"directive",detail:":if={condition}",documentation:"Conditional rendering"},{label:":for",kind:"directive",detail:":for={item of items()}",documentation:"List rendering"},{label:":show",kind:"directive",detail:":show={condition}",documentation:"Toggle visibility (display)"},{label:":key",kind:"directive",detail:":key={uniqueId}",documentation:"Reconciliation key for lists"},{label:"bind:value",kind:"directive",detail:"bind:value={signal}",documentation:"Two-way binding"},{label:"bind:checked",kind:"directive",detail:"bind:checked={signal}",documentation:"Two-way checkbox binding"}],W=["onClick","onInput","onChange","onSubmit","onKeyDown","onKeyUp","onFocus","onBlur","onMouseEnter","onMouseLeave","onScroll","onLoad","onError","onResize","onPointerDown","onPointerUp"].map(e=>({label:e,kind:"event",detail:`${e}={(e) => { ... }}`,documentation:`${e.slice(2)} event handler`}));function ke(){return {getDiagnostics(e,t){let n=[];try{let r=v(e);if(r.template||n.push({range:{start:{line:0,character:0},end:{line:0,character:0}},message:"Missing <template> block",severity:"warning"}),r.template){let i=h(r.template.content);U(i,n,r.template.start);}}catch(r){n.push({range:{start:{line:0,character:0},end:{line:0,character:0}},message:`Parse error: ${r instanceof Error?r.message:String(r)}`,severity:"error"});}return n},getCompletions(e,t){let r=(e.split(`
38
- `)[t.line]??"").slice(0,t.character);return Ce(e,t)?[...I]:_e(e,t)?r.endsWith("<")||/^<[A-Z]/.test(r.trimStart())?[...k]:r.endsWith(":")||r.includes(":")?[...C]:we(r)?[...C,...W]:[...k,...C]:[]},getHoverInfo(e,t){let n=e.split(`
39
- `)[t.line]??"",r=Ne(n,t.character),i=I.find(o=>o.label===r);if(i)return {contents:`**${i.label}**
37
+ `;return t}function Te(e){return e._hoisted??null}function ke(e){let t=0,n=0;function r(s){if(t++,T(s)&&n++,s.children)for(let o of s.children)r(o);}for(let s of e)r(s);let i=W(JSON.parse(JSON.stringify(e)));return {totalNodes:t,staticNodes:n,hoistedTemplates:i.length,staticRatio:t>0?n/t:0}}var I=[{label:"signal",kind:"property",detail:"signal<T>(initial: T): Signal<T>",documentation:"Create a reactive signal"},{label:"computed",kind:"property",detail:"computed<T>(fn: () => T): ReadonlySignal<T>",documentation:"Create a derived reactive value"},{label:"effect",kind:"property",detail:"effect(fn: () => void): () => void",documentation:"Run a side-effect when dependencies change"},{label:"batch",kind:"property",detail:"batch(fn: () => void): void",documentation:"Batch signal updates"},{label:"untrack",kind:"property",detail:"untrack<T>(fn: () => T): T",documentation:"Read signals without tracking"},{label:"onMount",kind:"property",detail:"onMount(fn: () => void | (() => void)): void",documentation:"Run after component mounts"},{label:"onUnmount",kind:"property",detail:"onUnmount(fn: () => void): void",documentation:"Run before component unmounts"},{label:"provide",kind:"property",detail:"provide<T>(key: InjectionKey<T>, value: T): void",documentation:"Provide a value to descendants"},{label:"inject",kind:"property",detail:"inject<T>(key: InjectionKey<T>): T",documentation:"Inject a value from ancestors"},{label:"defineStore",kind:"property",detail:"defineStore(id, config): () => Store",documentation:"Define a global store"},{label:"useHead",kind:"property",detail:"useHead(config: HeadConfig): void",documentation:"Manage document head tags"},{label:"cx",kind:"property",detail:"cx(...inputs): string",documentation:"Merge CSS class names"},{label:"pipe",kind:"property",detail:"pipe(value, transform, ...args): any",documentation:"Apply a pipe transform"}],k=[{label:"Show",kind:"component",detail:"<Show when={condition}>{value => ...}</Show>",documentation:"Conditional rendering with type narrowing"},{label:"For",kind:"component",detail:"<For each={items} key={fn}>{item => ...}</For>",documentation:"List rendering with keyed reconciliation"},{label:"Switch",kind:"component",detail:"<Switch on={value} cases={...} />",documentation:"Switch/case rendering"},{label:"Portal",kind:"component",detail:'<Portal target="selector">...</Portal>',documentation:"Render into different DOM node"},{label:"Transition",kind:"component",detail:'<Transition name="fade" when={show}>...</Transition>',documentation:"CSS enter/exit transitions"},{label:"ErrorBoundary",kind:"component",detail:"<ErrorBoundary fallback={fn}>...</ErrorBoundary>",documentation:"Catch errors from children"},{label:"Suspense",kind:"component",detail:"<Suspense fallback={fn}>...</Suspense>",documentation:"Show fallback during async loading"},{label:"VirtualFor",kind:"component",detail:"<VirtualFor each={items} itemHeight={40}>...</VirtualFor>",documentation:"Virtual scrolling for large lists"},{label:"Image",kind:"component",detail:'<Image src="..." alt="..." />',documentation:"Optimized image with lazy loading"}],C=[{label:":if",kind:"directive",detail:":if={condition}",documentation:"Conditional rendering"},{label:":for",kind:"directive",detail:":for={item of items()}",documentation:"List rendering"},{label:":show",kind:"directive",detail:":show={condition}",documentation:"Toggle visibility (display)"},{label:":key",kind:"directive",detail:":key={uniqueId}",documentation:"Reconciliation key for lists"},{label:"bind:value",kind:"directive",detail:"bind:value={signal}",documentation:"Two-way binding"},{label:"bind:checked",kind:"directive",detail:"bind:checked={signal}",documentation:"Two-way checkbox binding"}],J=["onClick","onInput","onChange","onSubmit","onKeyDown","onKeyUp","onFocus","onBlur","onMouseEnter","onMouseLeave","onScroll","onLoad","onError","onResize","onPointerDown","onPointerUp"].map(e=>({label:e,kind:"event",detail:`${e}={(e) => { ... }}`,documentation:`${e.slice(2)} event handler`}));function Ce(){return {getDiagnostics(e,t){let n=[];try{let r=v(e);if(r.template||n.push({range:{start:{line:0,character:0},end:{line:0,character:0}},message:"Missing <template> block",severity:"warning"}),r.template){let i=h(r.template.content);U(i,n,r.template.start);}}catch(r){n.push({range:{start:{line:0,character:0},end:{line:0,character:0}},message:`Parse error: ${r instanceof Error?r.message:String(r)}`,severity:"error"});}return n},getCompletions(e,t){let r=(e.split(`
38
+ `)[t.line]??"").slice(0,t.character);return _e(e,t)?[...I]:we(e,t)?r.endsWith("<")||/^<[A-Z]/.test(r.trimStart())?[...k]:r.endsWith(":")||r.includes(":")?[...C]:Ne(r)?[...C,...J]:[...k,...C]:[]},getHoverInfo(e,t){let n=e.split(`
39
+ `)[t.line]??"",r=Re(n,t.character),i=I.find(o=>o.label===r);if(i)return {contents:`**${i.label}**
40
40
 
41
41
  ${i.detail}
42
42
 
@@ -44,7 +44,7 @@ ${i.documentation}`};let s=k.find(o=>o.label===r);return s?{contents:`**${s.labe
44
44
 
45
45
  ${s.detail}
46
46
 
47
- ${s.documentation}`}:null},getAllCompletions(){return {apis:I,components:k,directives:C,events:W}}}}function U(e,t,n){for(let r of e)r.type==="element"&&r.tag==="img"&&(r.attrs?.some(s=>s.name==="alt")||t.push({range:{start:{line:0,character:0},end:{line:0,character:0}},message:"<img> element should have an alt attribute for accessibility",severity:"warning",code:"a11y-img-alt"})),r.type==="element"&&r.tag==="button"&&(r.attrs?.some(s=>s.name==="type")||t.push({range:{start:{line:0,character:0},end:{line:0,character:0}},message:'<button> should have an explicit type attribute (type="button" or type="submit")',severity:"hint",code:"a11y-button-type"})),r.children&&U(r.children,t);}function Ce(e,t){let n=e.split(`
48
- `),r=false;for(let i=0;i<=t.line&&i<n.length;i++)n[i].includes("<script")&&(r=true),n[i].includes("</script>")&&(r=false);return r}function _e(e,t){let n=e.split(`
49
- `),r=false;for(let i=0;i<=t.line&&i<n.length;i++)n[i].includes("<template>")&&(r=true),n[i].includes("</template>")&&(r=false);return r}function we(e){let t=e.lastIndexOf("<"),n=e.lastIndexOf(">");return t>n}function Ne(e,t){let n=t,r=t;for(;n>0&&/\w/.test(e[n-1]);)n--;for(;r<e.length&&/\w/.test(e[r]);)r++;return e.slice(n,r)}function Je(e,t={}){let n=v(e);return O(n,t)}exports.SourceMapBuilder=S;exports.analyzeTemplate=fe;exports.compile=Je;exports.createAkashSourceMap=ye;exports.createLanguageService=ke;exports.encodeVLQ=x;exports.extractHoistedTemplates=J;exports.generateHoistedDeclarations=xe;exports.generateScopeId=N;exports.getHoistedVar=Se;exports.getOptimizationStats=Te;exports.isStaticExpression=be;exports.isStaticNode=T;exports.parse=v;exports.parseTemplate=h;exports.scopeStyles=R;exports.staticNodeToHtml=A;exports.transform=O;//# sourceMappingURL=index.cjs.map
47
+ ${s.documentation}`}:null},getAllCompletions(){return {apis:I,components:k,directives:C,events:J}}}}function U(e,t,n){for(let r of e)r.type==="element"&&r.tag==="img"&&(r.attrs?.some(s=>s.name==="alt")||t.push({range:{start:{line:0,character:0},end:{line:0,character:0}},message:"<img> element should have an alt attribute for accessibility",severity:"warning",code:"a11y-img-alt"})),r.type==="element"&&r.tag==="button"&&(r.attrs?.some(s=>s.name==="type")||t.push({range:{start:{line:0,character:0},end:{line:0,character:0}},message:'<button> should have an explicit type attribute (type="button" or type="submit")',severity:"hint",code:"a11y-button-type"})),r.children&&U(r.children,t);}function _e(e,t){let n=e.split(`
48
+ `),r=false;for(let i=0;i<=t.line&&i<n.length;i++)n[i].includes("<script")&&(r=true),n[i].includes("</script>")&&(r=false);return r}function we(e,t){let n=e.split(`
49
+ `),r=false;for(let i=0;i<=t.line&&i<n.length;i++)n[i].includes("<template>")&&(r=true),n[i].includes("</template>")&&(r=false);return r}function Ne(e){let t=e.lastIndexOf("<"),n=e.lastIndexOf(">");return t>n}function Re(e,t){let n=t,r=t;for(;n>0&&/\w/.test(e[n-1]);)n--;for(;r<e.length&&/\w/.test(e[r]);)r++;return e.slice(n,r)}function Je(e,t={}){let n=v(e);return O(n,t)}exports.SourceMapBuilder=S;exports.analyzeTemplate=ge;exports.compile=Je;exports.createAkashSourceMap=xe;exports.createLanguageService=Ce;exports.encodeVLQ=x;exports.extractHoistedTemplates=W;exports.generateHoistedDeclarations=Se;exports.generateScopeId=N;exports.getHoistedVar=Te;exports.getOptimizationStats=ke;exports.isStaticExpression=be;exports.isStaticNode=T;exports.parse=v;exports.parseTemplate=h;exports.scopeStyles=R;exports.staticNodeToHtml=L;exports.transform=O;//# sourceMappingURL=index.cjs.map
50
50
  //# sourceMappingURL=index.cjs.map