@akashjs/compiler 0.1.18 → 0.1.19
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 +16 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {createHash}from'crypto';function y(e){return {script:N(e,"script",(t,n,i,r)=>({content:t,lang:G(n,"lang")??"ts",start:i,end:r})),template:N(e,"template",(t,n,i,r)=>({content:t,start:i,end:r})),style:N(e,"style",(t,n,i,r)=>({content:t,scoped:n.includes("scoped"),start:i,end:r}))}}function N(e,t,n){let i=new RegExp(`<${t}(\\b[^>]*)>`,"i"),r=new RegExp(`</${t}>`,"i"),s=i.exec(e);if(!s)return null;let o=s[1]??"",a=s.index+s[0].length,
|
|
2
|
-
`);let{cleanScript:
|
|
1
|
+
import {createHash}from'crypto';function y(e){return {script:N(e,"script",(t,n,i,r)=>({content:t,lang:G(n,"lang")??"ts",start:i,end:r})),template:N(e,"template",(t,n,i,r)=>({content:t,start:i,end:r})),style:N(e,"style",(t,n,i,r)=>({content:t,scoped:n.includes("scoped"),start:i,end:r}))}}function N(e,t,n){let i=new RegExp(`<${t}(\\b[^>]*)>`,"i"),r=new RegExp(`</${t}>`,"i"),s=i.exec(e);if(!s)return null;let o=s[1]??"",a=s.index+s[0].length,u=r.exec(e.slice(a));if(!u)return null;let p=a+u.index,l=e.slice(a,p);return n(l.trim(),o,a,p)}function G(e,t){return new RegExp(`${t}=["']([^"']+)["']`).exec(e)?.[1]??null}function b(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="<"){if(e[n+1]==="/")break;let s=X(e,n);if(s){t.push(s.node),n=s.end;continue}}if(e[n]==="{"){let s=ee(e,n);if(s){t.push(s.node),n=s.end;continue}}let i=ne(e,n+1),r=e.slice(n,i).trim();r&&t.push({type:"text",content:r}),n=i;}return t}function X(e,t){let n=/^<([a-zA-Z][a-zA-Z0-9-]*)/.exec(e.slice(t));if(!n)return null;let i=n[1],r=t+n[0].length,s=[],o=[];for(;r<e.length;){let h=/^\s+/.exec(e.slice(r));if(h&&(r+=h[0].length),e[r]===">"||e.slice(r,r+2)==="/>")break;let c=Y(e,r);c?(c.attr.name.startsWith("bind:")?o.push({name:"bind",arg:c.attr.name.slice(5),value:c.attr.value}):c.attr.name.startsWith(":")?o.push({name:c.attr.name.slice(1),value:c.attr.value}):s.push(c.attr),r=c.end):r++;}let a=i[0]===i[0].toUpperCase();if(e.slice(r,r+2)==="/>")return {node:{type:a?"component":"element",tag:i,attrs:s,directives:o.length>0?o:void 0,children:[]},end:r+2};r++;let u=b(e.slice(r));e.slice(r);let l=`</${i}>`,f=re(e,r,i);if(f===-1)return {node:{type:a?"component":"element",tag:i,attrs:s,directives:o.length>0?o:void 0,children:u},end:e.length};let d=e.slice(r,f),$=b(d);return {node:{type:a?"component":"element",tag:i,attrs:s,directives:o.length>0?o:void 0,children:$},end:f+l.length}}function Y(e,t){let n=/^(?:bind:|[:a-zA-Z_])[\w:.-]*/.exec(e.slice(t));if(!n)return null;let i=n[0],r=t+i.length;if(e[r]!=="=")return {attr:{name:i,value:"true",dynamic:false},end:r};if(r++,e[r]==="{"){let o=z(e,r);if(o)return {attr:{name:i,value:o.content,dynamic:true},end:o.end}}let s=e[r];if(s==='"'||s==="'"){let o=e.indexOf(s,r+1);return o===-1?null:{attr:{name:i,value:e.slice(r+1,o),dynamic:false},end:o+1}}return null}function ee(e,t){let n=z(e,t);return n?{node:{type:"expression",content:n.content},end:n.end}:null}function z(e,t){if(e[t]!=="{")return null;let n=1,i=t+1;for(;i<e.length&&n>0;){let r=e[i];if(r==='"'||r==="'"||r==="`"){i=te(e,i)+1;continue}r==="{"?n++:r==="}"&&n--,i++;}return {content:e.slice(t+1,i-1).trim(),end:i}}function te(e,t){let n=e[t],i=t+1;for(;i<e.length;){if(e[i]==="\\"){i+=2;continue}if(e[i]===n)return i;i++;}return i}function ne(e,t){let n=t;for(;n<e.length;){if(e[n]==="<"||e[n]==="{")return n;n++;}return n}function re(e,t,n){let i=`</${n}>`,r=1,s=t,o=e.length*2,a=0;for(;s<e.length&&a++<o;){let u=e.indexOf(`<${n}`,s),p=e.indexOf(i,s);if(p===-1)return -1;if(u!==-1&&u<p){let l=ie(e,u);l!==-1&&e[l-1]==="/"?s=l+1:l!==-1?(r++,s=l+1):s=u+1;}else {if(r--,r===0)return p;s=p+1;}}return -1}function ie(e,t){let n=t,i=0;for(;n<e.length;){let r=e[n];if(r==="{")i++;else if(r==="}")i--;else if(r===">"&&i===0)return n;n++;}return -1}function A(e){return `data-a-${createHash("md5").update(e).digest("hex").slice(0,6)}`}function D(e,t){return B(e,t)}function B(e,t,n){let i="",r=0;for(;r<e.length;){let s=/^\s+/.exec(e.slice(r));if(s&&(i+=s[0],r+=s[0].length,r>=e.length))break;if(e.slice(r,r+2)==="/*"){let d=e.indexOf("*/",r+2);if(d===-1){i+=e.slice(r);break}i+=e.slice(r,d+2),r=d+2;continue}if(e[r]==="}"){i+="}",r++;continue}let o=e.indexOf("{",r);if(o===-1){i+=e.slice(r);break}let a=e.slice(r,o),u=a.trim(),p=o+1,l=oe(e,o),f=e.slice(p,l);if(u.startsWith("@")){let d=u.split(/\s/)[0];d==="@keyframes"||d==="@-webkit-keyframes"||d==="@font-face"?i+=a+"{"+f+"}":i+=a+"{"+B(f,t)+"}";}else {let d=ae(u,t);i+=a.replace(u,d)+"{"+f+"}";}r=l+1;}return i}function oe(e,t){let n=1,i=t+1;for(;i<e.length&&n>0;)e[i]==="{"?n++:e[i]==="}"&&n--,n>0&&i++;return i}function ae(e,t){return e.split(",").map(n=>{let i=n.trim();return !i||i===":root"||i===":host"||i.includes(t)?n:le(i,t)}).join(",")}function le(e,t){let n=e.split(/(\s*[>+~]\s*|\s+)/);for(let i=n.length-1;i>=0;i--){let r=n[i].trim();if(r&&!ce(r)){if(r.includes("::")){let[s,o]=r.split("::");n[i]=n[i].replace(r,`${s}[${t}]::${o}`);}else if(r.includes(":")){let s=r.indexOf(":"),o=r.slice(0,s),a=r.slice(s);n[i]=n[i].replace(r,`${o}[${t}]${a}`);}else n[i]=n[i].replace(r,`${r}[${t}]`);break}}return n.join("")}function ce(e){return e===">"||e==="+"||e==="~"}function I(e,t={}){let n=t.scopeId??(t.filename?A(t.filename):void 0),r=new Set;r.add("defineComponent");let s=e.script?.content??"",o=e.template?.content??"";fe(s,o,r);let a=t.mode==="server",u="";if(e.template){let m=b(e.template.content);a?u=be(m,r,n):u=ge(m,r,n);}let p="";r.size>0&&(p+=`import { ${[...r].join(", ")} } from '@akashjs/runtime';
|
|
2
|
+
`);let{cleanScript:l,propsInterface:f}=me(s),{userImports:d,bodyScript:$}=de(l);d.length>0&&(p+=d.join(`
|
|
3
3
|
`)+`
|
|
4
|
-
`);let h=f?`<${f}>`:"";if(
|
|
5
|
-
`,
|
|
6
|
-
`,s.includes("props")&&(
|
|
4
|
+
`);let h=f?`<${f}>`:"";if(p+=`
|
|
5
|
+
`,p+=`export default defineComponent${h}((ctx) => {
|
|
6
|
+
`,s.includes("props")&&(p+=` const props = ctx.props;
|
|
7
7
|
`),$.trim()){let m=$.trim().split(`
|
|
8
8
|
`).map(g=>` ${g}`).join(`
|
|
9
|
-
`);
|
|
10
|
-
`;}
|
|
11
|
-
`,
|
|
12
|
-
`,u
|
|
13
|
-
`,
|
|
14
|
-
`;let
|
|
9
|
+
`);p+=`${m}
|
|
10
|
+
`;}p+=`
|
|
11
|
+
`,p+=` return () => {
|
|
12
|
+
`,p+=u,p+=` };
|
|
13
|
+
`,p+=`});
|
|
14
|
+
`;let c;return e.style&&(c=e.style.scoped&&n?D(e.style.content,n):e.style.content),{code:p,css:c}}function ue(e){let t=e.trim();return !!(/^(?:\([^)]*\)|[a-zA-Z_$]\w*)\s*=>/.test(t)||/^function[\s(]/.test(t))}function pe(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 fe(e,t,n){let i=["signal","computed","effect","batch","untrack","onMount","onUnmount","onError","ref","createContext","provide","inject","Show","For"];for(let s of i){let o=new RegExp(`\\b${s}\\b`),a=new RegExp(`import\\s+.*\\b${s}\\b.*from`);o.test(e)&&!a.test(e)&&n.add(s);}let r=["Show","For"];for(let s of r)new RegExp(`<${s}[\\s/>]`).test(t)&&!n.has(s)&&n.add(s);}function de(e){let t=e.split(`
|
|
15
15
|
`),n=[],i=[],r=false,s=false;for(let o of t){if(r){n[n.length-1]+=`
|
|
16
16
|
`+o,(o.includes("from ")||o.trimEnd().endsWith(";"))&&(r=false);continue}if(s){n[n.length-1]+=`
|
|
17
17
|
`+o,(o.trimEnd().endsWith("}")||o.trimEnd().endsWith("};"))&&(s=false);continue}let a=o.trim();/^import\s/.test(a)?(n.push(o.trim()),!a.includes("from ")&&!a.endsWith(";")&&(r=true)):/^export\s+(interface|type|enum)\s/.test(a)?(n.push(o.trim()),!a.endsWith("}")&&!a.endsWith("};")&&!a.endsWith(";")&&(s=true)):/^export\s+(const|let|var|function|class)\s/.test(a)?i.push(o.replace(/\bexport\s+/,"")):/^declare\s/.test(a)?(n.push(o.trim()),!a.endsWith("}")&&!a.endsWith("};")&&!a.endsWith(";")&&(s=true)):i.push(o);}return {userImports:n,bodyScript:i.join(`
|
|
@@ -20,16 +20,16 @@ import {createHash}from'crypto';function y(e){return {script:N(e,"script",(t,n,i
|
|
|
20
20
|
`)+`
|
|
21
21
|
`}t.add("createElement");let i=[];i.push(" const __fragment = document.createDocumentFragment();");for(let r=0;r<e.length;r++){let s=`__n${r}`;v(e[r],i,t,4,s,n),i.push(` __fragment.appendChild(${s});`);}return i.push(" return __fragment;"),i.join(`
|
|
22
22
|
`)+`
|
|
23
|
-
`}function v(e,t,n,i,r,s){let o=" ".repeat(i);switch(e.type){case "element":O(e,t,n,i,r,s);break;case "component":he(e,t,n,i,r,s);break;case "text":t.push(`${o}const ${r} = document.createTextNode(${JSON.stringify(e.content??"")});`);break;case "expression":n.add("effect"),t.push(`${o}const ${r} = document.createTextNode('');`),t.push(`${o}effect(() => { ${r}.textContent = String(${e.content}); }, { render: true });`);break}}function O(e,t,n,i,r,s){let o=" ".repeat(i),a=e.tag,
|
|
23
|
+
`}function v(e,t,n,i,r,s){let o=" ".repeat(i);switch(e.type){case "element":O(e,t,n,i,r,s);break;case "component":he(e,t,n,i,r,s);break;case "text":t.push(`${o}const ${r} = document.createTextNode(${JSON.stringify(e.content??"")});`);break;case "expression":n.add("effect"),t.push(`${o}const ${r} = document.createTextNode('');`),t.push(`${o}effect(() => { ${r}.textContent = String(${e.content}); }, { render: true });`);break}}function O(e,t,n,i,r,s){let o=" ".repeat(i),a=e.tag,u=e.directives?.find(c=>c.name==="if");if(u){n.add("renderConditional"),t.push(`${o}const ${r}_anchor = document.createComment('if');`),t.push(`${o}const ${r} = document.createDocumentFragment();`),t.push(`${o}${r}.appendChild(${r}_anchor);`),t.push(`${o}renderConditional(${r}, ${r}_anchor, () => ${u.value}, () => {`);let c=[],m={...e,directives:e.directives?.filter(g=>g.name!=="if")};O(m,c,n,i+2,"__el",s),c.push(`${o} return __el;`),t.push(...c),t.push(`${o}});`);return}let p=e.directives?.find(c=>c.name==="for");if(p){n.add("renderList");let c=e.directives?.find(g=>g.name==="key"),m=/^(?:\(([^)]+)\)|(\w+))\s+of\s+(.+)$/.exec(p.value);if(m){let g=m[1]??m[2],w=m[3],E=c?.value??`${g}`;t.push(`${o}const ${r}_anchor = document.createComment('for');`),t.push(`${o}const ${r} = document.createDocumentFragment();`),t.push(`${o}${r}.appendChild(${r}_anchor);`),t.push(`${o}renderList(${r}, ${r}_anchor, () => ${w}, (${g}) => ${E}, (${g}) => {`);let R=[],Q={...e,directives:e.directives?.filter(H=>H.name!=="for"&&H.name!=="key")};O(Q,R,n,i+2,"__el",s),R.push(`${o} return __el;`),t.push(...R),t.push(`${o}});`);}return}let l=e.directives?.filter(c=>c.name==="bind")??[];l.length>0&&e.directives&&(e.directives=e.directives.filter(c=>c.name!=="bind")),t.push(`${o}const ${r} = document.createElement('${a}');`),s&&t.push(`${o}${r}.setAttribute('${s}', '');`);let f=[],d=[];if(e.attrs)for(let c of e.attrs)c.name.startsWith("on")?f.push(c):d.push(c);let $=[],h=[];for(let c of d)c.name==="value"?$.push(c):h.push(c);for(let c of h)c.dynamic?(n.add("effect"),t.push(`${o}effect(() => {`),c.name==="class"||c.name==="className"?t.push(`${o} ${r}.className = ${c.value};`):t.push(`${o} ${r}.setAttribute('${c.name}', String(${c.value}));`),t.push(`${o}}, { render: true });`)):c.name==="class"||c.name==="className"?t.push(`${o}${r}.className = ${JSON.stringify(c.value)};`):t.push(`${o}${r}.setAttribute('${c.name}', ${JSON.stringify(c.value)});`);for(let c of l){let m=c.arg??"value",g=c.value;n.add("effect"),t.push(`${o}effect(() => { const __v = ${g}(); if (${r}.${m} !== __v) ${r}.${m} = __v; }, { render: true });`);let w=m==="value"||m==="checked"?"input":"change",E=m==="checked"?"checked":"value";t.push(`${o}${r}.addEventListener('${w}', (e) => { ${g}.set(e.target.${E}); });`);}if(e.children&&e.children.length>0)for(let c=0;c<e.children.length;c++){let m=`${r}_c${c}`;v(e.children[c],t,n,i,m,s),t.push(`${o}${r}.appendChild(${m});`);}for(let c of $)c.dynamic?(t.push(`${o}${r}.value = ${c.value};`),n.add("effect"),t.push(`${o}effect(() => {`),t.push(`${o} const __v = ${c.value};`),t.push(`${o} if (${r}.value !== String(__v)) ${r}.value = __v;`),t.push(`${o}}, { render: true });`)):t.push(`${o}${r}.value = ${JSON.stringify(c.value)};`);for(let c of f)c.dynamic?t.push(`${o}${r}.addEventListener('${c.name.slice(2).toLowerCase()}', ${c.value});`):t.push(`${o}${r}.setAttribute('${c.name}', ${JSON.stringify(c.value)});`);}function he(e,t,n,i,r,s){let o=" ".repeat(i),a=e.tag,u=[];if(e.attrs)for(let l of e.attrs)if(l.dynamic){let f=$e(l.value,n,i,s);f?u.push(`${l.name}: ${f}`):l.name.startsWith("on")||ue(l.value)?u.push(`${l.name}: ${l.value}`):pe(l.value)?(n.add("__getter"),u.push(`${l.name}: __getter(() => ${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=W(e.children,n,i+2,s);u.push(`children: ${l}`);}let p=u.length>0?`{ ${u.join(", ")} }`:"{}";t.push(`${o}const ${r} = ${a}(${p});`);}function W(e,t,n,i){if(e.length===1&&e[0].type==="expression"){let a=F(e[0].content??"",t,n,i);if(a)return a}let r=" ".repeat(n),s=[],o=e.filter(a=>!(a.type==="text"&&!(a.content??"").trim()));if(o.length===1)v(o[0],s,t,n,"__child",i),s.push(`${r}return __child;`);else {s.push(`${r}const __frag = document.createDocumentFragment();`);for(let a=0;a<o.length;a++){let u=`__child${a}`;v(o[a],s,t,n,u,i),s.push(`${r}__frag.appendChild(${u});`);}s.push(`${r}return __frag;`);}return `() => {
|
|
24
24
|
${s.join(`
|
|
25
25
|
`)}
|
|
26
|
-
${" ".repeat(n-2)}}`}function
|
|
27
|
-
${
|
|
26
|
+
${" ".repeat(n-2)}}`}function F(e,t,n,i){let r=e.trim(),s=/^(\(?[^)]*\)?)\s*=>\s*(<[a-zA-Z].*)$/s.exec(r);if(!s)return null;let o=s[1],a=s[2],u=b(a);if(u.length===0)return null;let p=" ".repeat(n),l=[];if(u.length===1)v(u[0],l,t,n,"__child",i),l.push(`${p}return __child;`);else {l.push(`${p}const __frag = document.createDocumentFragment();`);for(let f=0;f<u.length;f++){let d=`__child${f}`;v(u[f],l,t,n,d,i),l.push(`${p}__frag.appendChild(${d});`);}l.push(`${p}return __frag;`);}return `${o} => {
|
|
27
|
+
${l.join(`
|
|
28
28
|
`)}
|
|
29
|
-
${" ".repeat(n-2)}}`}function $e(e,t,n,i){let r=e.trim(),s=
|
|
29
|
+
${" ".repeat(n-2)}}`}function $e(e,t,n,i){let r=e.trim(),s=F(r,t,n+2,i);if(s)return s;if(!/^<[a-zA-Z]/.test(r))return null;let o=b(r);return o.length===0?null:W(o,t,n+2,i)}function be(e,t,n){if(e.length===0)return ` return '';
|
|
30
30
|
`;let i=[];i.push(" let __html = '';");for(let r of e)V(r,i,t,4,n);return i.push(" return __html;"),i.join(`
|
|
31
31
|
`)+`
|
|
32
|
-
`}function V(e,t,n,i,r){let s=" ".repeat(i);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":L(e,t,n,i,r);break;case "component":t.push(`${s}// TODO: SSR component rendering for ${e.tag}`),t.push(`${s}__html += '';`);break}}var ve=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function L(e,t,n,i,r){let s=" ".repeat(i),o=e.tag,a=e.directives?.find(
|
|
32
|
+
`}function V(e,t,n,i,r){let s=" ".repeat(i);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":L(e,t,n,i,r);break;case "component":t.push(`${s}// TODO: SSR component rendering for ${e.tag}`),t.push(`${s}__html += '';`);break}}var ve=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function L(e,t,n,i,r){let s=" ".repeat(i),o=e.tag,a=e.directives?.find(l=>l.name==="if");if(a){t.push(`${s}if (${a.value}) {`);let l={...e,directives:e.directives?.filter(f=>f.name!=="if")};L(l,t,n,i+2,r),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 f=l[1]??l[2],d=l[3];t.push(`${s}for (const ${f} of ${d}) {`);let $={...e,directives:e.directives?.filter(h=>h.name!=="for"&&h.name!=="key")};L($,t,n,i+2,r),t.push(`${s}}`);}return}let p=`'<${o}`;if(r&&(p+=` ${r}`),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(ve.has(o)){t.push(`${s}__html += ${p} />';`);return}if(t.push(`${s}__html += ${p}>';`),e.children)for(let l of e.children)V(l,t,n,i,r);t.push(`${s}__html += '</${o}>';`);}function ye(e){let t={signalReads:[],eventHandlers:[],hasDynamicContent:false,staticSubtrees:[],reactiveExpressions:[],componentRefs:[]};for(let n of e)M(n,t);return t}function M(e,t){switch(e.type){case "expression":t.hasDynamicContent=true,e.content&&(t.reactiveExpressions.push({expression:e.content,kind:"text"}),x(e.content,"text",t));break;case "element":xe(e,t);break;case "component":if(e.tag&&t.componentRefs.push(e.tag),t.hasDynamicContent=true,J(e,t),e.children)for(let n of e.children)M(n,t);break;}}function xe(e,t){let n=U(e);if(e.directives)for(let i of e.directives)t.hasDynamicContent=true,Se(i,e,t);if(J(e,t),!n&&!e.directives?.length&&t.staticSubtrees.push(e),e.children)for(let i of e.children)M(i,t);}function J(e,t){if(e.attrs){for(let n of e.attrs)if(n.dynamic)if(t.hasDynamicContent=true,n.name.startsWith("on")){let i=n.name.slice(2).toLowerCase();t.eventHandlers.push({event:i,handler:n.value,tag:e.tag??"unknown"});}else t.reactiveExpressions.push({expression:n.value,kind:"attribute",attributeName:n.name}),x(n.value,"attribute",t);}}function Se(e,t,n){switch(e.name){case "if":case "else-if":case "show":n.reactiveExpressions.push({expression:e.value,kind:"conditional"}),x(e.value,"directive",n);break;case "for":{let i=/\bof\s+(.+)$/.exec(e.value);i&&(n.reactiveExpressions.push({expression:i[1],kind:"list"}),x(i[1],"directive",n));break}case "bind":{n.reactiveExpressions.push({expression:e.value,kind:"attribute",attributeName:e.value}),x(e.value,"directive",n);break}}}function x(e,t,n){let i=new Set(["console","Math","JSON","Object","Array","String","Number","Boolean","Date","RegExp","Error","Promise","parseInt","parseFloat","setTimeout","setInterval","clearTimeout","clearInterval","document","window","navigator","fetch"]),r=/\b([a-zA-Z_$][\w$]*)\s*\(\s*\)/g,s;for(;(s=r.exec(e))!==null;){let o=s[1];i.has(o)||n.signalReads.push({expression:`${o}()`,context:t});}}function U(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=>U(t)))}function _e(e){let t=e.trim();return !!(/^['"`].*['"`]$/.test(t)||/^-?\d+(\.\d+)?$/.test(t)||t==="true"||t==="false"||t==="null"||t==="undefined")}var Te="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function S(e){let t="",n=e<0?-e<<1|1:e<<1;do{let i=n&31;n>>>=5,n>0&&(i|=32),t+=Te[i];}while(n>0);return t}var _=class{mappings=[];sources=[];sourcesContent=[];addSource(t,n){let i=this.sources.length;return this.sources.push(t),this.sourcesContent.push(n??null),i}addMapping(t){this.mappings.push(t);}addLineRange(t,n,i,r=0){for(let s=0;s<i;s++)this.addMapping({generatedLine:t+s,generatedColumn:0,originalLine:n+s,originalColumn:0,source:r});}build(t){let n=[...this.mappings].sort((i,r)=>i.generatedLine-r.generatedLine||i.generatedColumn-r.generatedColumn);return {version:3,file:t,sources:this.sources,sourcesContent:this.sourcesContent,names:[],mappings:ke(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 ke(e){let t=[],n=0,i=0,r=0,s=0,o=0;for(let a of e){for(;t.length<=a.generatedLine;)t.push([]);a.generatedLine!==n&&(i=0,n=a.generatedLine);let u="";u+=S(a.generatedColumn-i),i=a.generatedColumn;let p=a.source??0;u+=S(p-o),o=p,u+=S(a.originalLine-r),r=a.originalLine,u+=S(a.originalColumn-s),s=a.originalColumn,t[a.generatedLine].push(u);}return t.map(a=>a.join(",")).join(";")}function Ce(e,t,n,i,r){let s=new _;return s.addSource(e,t),s.addLineRange(r,n,i,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 j(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+=j(n);return t+=`</${e.tag}>`,t}default:return ""}}function Z(e){let t=[],n=0;function i(r){if(r.type==="element"){if(T(r)&&r.children&&r.children.length>0){let s=`__hoisted_${n++}`;t.push({varName:s,html:j(r)}),r._hoisted=s;return}if(r.children)for(let s of r.children)i(s);}}for(let r of e)i(r);return t}function we(e){if(e.length===0)return "";let t=`// Hoisted static templates (created once, cloned per instance)
|
|
33
33
|
`;for(let n of e)t+=`const ${n.varName} = /*#__PURE__*/ (() => {
|
|
34
34
|
`,t+=` const _t = document.createElement('template');
|
|
35
35
|
`,t+=` _t.innerHTML = ${JSON.stringify(n.html)};
|