@fluixi/compiler 1.0.0-alpha.70 → 1.0.0-alpha.71
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/babel-DFIRSRWC.mjs +2 -0
- package/dist/chunk-EF6V4GTD.mjs +1 -0
- package/dist/frontend/babel/index.cjs +2 -2
- package/dist/frontend/babel/index.mjs +2 -2
- package/dist/frontend/babel/plugin.cjs +2 -2
- package/dist/frontend/babel/plugin.js +19 -1
- package/dist/frontend/babel/plugin.mjs +2 -2
- package/dist/index.cjs +22 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.mjs +22 -1
- package/dist/integrations.cjs +27 -6
- package/dist/integrations.d.ts +16 -0
- package/dist/integrations.d.ts.map +1 -1
- package/dist/integrations.js +8 -0
- package/dist/integrations.mjs +27 -6
- package/dist/resolve/component-globals.cjs +22 -0
- package/dist/resolve/component-globals.d.ts +73 -0
- package/dist/resolve/component-globals.d.ts.map +1 -0
- package/dist/resolve/component-globals.js +137 -0
- package/dist/resolve/component-globals.mjs +22 -0
- package/dist/resolve/write-globals.cjs +22 -0
- package/dist/resolve/write-globals.d.ts +31 -0
- package/dist/resolve/write-globals.d.ts.map +1 -0
- package/dist/resolve/write-globals.js +136 -0
- package/dist/resolve/write-globals.mjs +22 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/babel-NY6FXXLW.mjs +0 -2
- package/dist/chunk-3SAEGOMQ.mjs +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{declare as rn}from"@babel/helper-plugin-utils";var xt=e=>"components"in e;function Le(e,t){return e.replace(/\$(\d+)/g,(n,o)=>t[Number(o)]??n)}function St(e,t){return typeof t=="string"?{module:t,export:e}:t}function Me(e=[]){let t=new Map,n=[],o=[];for(let a of e){if(!xt(a)){o.push(a);continue}for(let[l,c]of Object.entries(a.components)){let p=St(l,c),m=t.get(l);if(m&&m.module!==p.module){let u=n.find(E=>E.name===l);u?u.modules.push(p.module):n.push({name:l,modules:[m.module,p.module]});continue}t.set(l,p)}}let i=new Map;return{resolve:a=>{if(i.has(a))return i.get(a);let l=t.get(a);if(!l)for(let c of o){let p=a.match(new RegExp(c.match.source,c.match.flags.replace("g","")));if(p){l={module:Le(c.module,p),export:c.export?Le(c.export,p):a};break}}return i.set(a,l),l},names:()=>[...t.keys()],conflicts:()=>n}}var V=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],D=["Suspense","SuspenseList","Await"],_=["Router","Outlet","Redirect","Link"],Jn=[...V,...D,..._],ce=new Set([...V,...D]);function Je(e={}){let{controlFlowModule:t="@fluixi/dom",coreModule:n="@fluixi/core",routerModule:o="@fluixi/core/router-next"}=e,i={};for(let s of V)i[s]=t;for(let s of D)i[s]=n;for(let s of _)i[s]=o;return i}var A={kind:"eager"},vt=["pointerdown","focusin","keydown"],Te=new Set(["eager","idle","visible","interaction","media","never"]),J=class extends Error{};function W(e){return e.startsWith("load:")}function B(e,t){let n=e.slice(5);if(!Te.has(n))throw new J(`Unknown load strategy 'load:${n}'. Expected one of ${[...Te].join(", ")}.`);switch(n){case"eager":return A;case"idle":return{kind:"idle"};case"never":return{kind:"never"};case"visible":return t?{kind:"visible",rootMargin:t}:{kind:"visible"};case"interaction":return{kind:"interaction",events:t?bt(t):[...vt]};case"media":if(!t)throw new J(`'load:media' needs a query, e.g. load:media="(min-width: 1024px)".`);return{kind:"media",query:t};default:throw new J(`Unhandled load strategy '${n}'.`)}}function bt(e){let t=e.split(/[\s,]+/).map(n=>n.trim()).filter(Boolean);if(t.length===0)throw new J("'load:interaction' was given no event names.");return t}function P(e){return e.kind!=="eager"&&e.kind!=="never"}function pe(e,t={}){let{resolver:n,isBound:o,modules:i,strategyFor:s}=t,a=Je(i),l=new Map,c=new Set,p=u=>{let{name:E}=u;if(!E||E.includes(".")||o?.(E))return;let y=m(E);if(!y){c.add(E);return}let R=y.origin==="builtin"&&ce.has(E)?A:s?.(u)??A;u.source={...y,loading:R},l.set(E,u.source)},m=u=>{if(ce.has(u))return{module:a[u],export:u,origin:"builtin"};let E=n?.resolve(u);if(E)return{module:E.module,export:E.export,origin:"rule"};if(_.includes(u))return{module:a[u],export:u,origin:"builtin"}};return Q(e,u=>{u.kind==="component"&&p(u)}),{resolved:l,unresolved:[...c]}}function Q(e,t){let n=Array.isArray(e)?e:[e];for(let o of n){t(o);let i=o.children;i&&Q(i,t)}}function ue(e){let t=[];Q(e,s=>{s.kind==="component"&&s.source&&t.push(s)});let n=new Set,o=new Set;for(let s of t){let{module:a,loading:l}=s.source;l.kind==="eager"&&n.add(a),l.kind==="never"&&o.add(a)}let i=new Map;for(let s of t){let a=s.source;P(a.loading)&&n.has(a.module)&&(a.loading={kind:"eager"},i.set(a.module,(i.get(a.module)??0)+1))}return{collapsed:i,conflicted:[...o].filter(s=>n.has(s))}}import{types as r,template as nt}from"@babel/core";import{types as f,traverse as Ht,template as Ut}from"@babel/core";import qe from"@babel/generator";var yt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Pe={className:"class",htmlFor:"for"},Rt=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),Ct=new Set(["script","style","textarea","title"]);function de(e){return Ct.has(e)}function Xe(e){return Pe[e]??e}function H(e){return e.kind!=="attr"||e.expr!==void 0||e.name.includes(":")?!1:!Rt.has(e.name)}function me(e){if(!e.static||de(e.tag))return!1;for(let t of e.props)if(!H(t))return!1;for(let t of e.children)if(t.kind!=="text"&&!(t.kind==="element"&&me(t)))return!1;return!0}function U(e){let t=e.props.map(wt).filter(Boolean).join(""),n=`<${e.tag}${t}>`;return yt.has(e.tag)?n:`${n}${e.children.map(It).join("")}</${e.tag}>`}function It(e){if(e.kind==="text")return kt(e.value);if(e.kind!=="element")throw new Error(`serializeStatic: unexpected ${e.kind}`);return U(e)}function wt(e){let t=Pe[e.name]??e.name,n=e.literal;return n===!0||n===void 0?` ${t}`:n===!1||n===null?"":` ${t}="${Nt(String(n))}"`}function Nt(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function kt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var Lt="<!--fx-->",Mt="<!--fx/-->";function te(e){return e.kind==="expr"||e.kind==="component"||e.kind==="control"}function Jt(e){return e.kind==="text"||e.kind==="element"&&$e(e)}function $e(e){return e.svg||de(e.tag)||!e.props.every(t=>H(t))?!1:e.children.every(t=>Jt(t)||te(t))}function ee(e){if(te(e))return!0;let t=e.children;return t?t.some(ee):!1}function Ae(e){for(let t=0;t<e.children.length;t++){let n=e.children[t];if(n.kind==="text"&&(n.value===""||e.children[t+1]?.kind==="text"))return!1}return e.children.every(t=>t.kind!=="element"||Ae(t))}function je(e){if(!$e(e)||!Ae(e)||!e.children.some(ee))return null;let t=[],n=[],o=0,i=a=>{let l=`_n$${o++}`;return t.push({ref:l,expr:a}),l};return s(e,"_el$"),{html:Tt(e),tag:e.tag,steps:t,holes:n};function s(a,l){let c=-1;a.children.forEach((m,u)=>{ee(m)&&(c=u)});let p=null;for(let m=0;m<=c;m++){let u=a.children[m],E=p?`${p}.nextSibling`:`${l}.firstChild`;if(te(u)){let R=i(E),I=i(`holeEnd(${R})`);n.push({parentRef:l,startRef:R,endRef:I,node:u}),p=I;continue}let y=i(E);u.kind==="element"&&ee(u)&&s(u,y),p=y}}}function Tt(e){return U(Oe(e)).split(Fe).join(Lt+Mt)}function Oe(e){return{...e,children:e.children.map(t=>te(t)?{kind:"text",value:Fe}:t.kind==="element"?Oe(t):t)}}var Fe="\0fx-hole\0";var fe={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},zn={version:2,module:"@fluixi/dom",symbols:[...fe.symbols,"template","cloneTemplate","walk"]};var Pt={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function Xt(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function _e(e){return Xt(e)?e:JSON.stringify(e)}function $t(e){return e.expr!==void 0?e.reactive?`() => (${e.expr})`:`(${e.expr})`:JSON.stringify(e.literal??!0)}function At(e){return e.expr!==void 0?`(${e.expr})`:JSON.stringify(e.literal??!0)}function jt(e,t,n){let o=e.filter(l=>l.kind==="spread"),s=e.filter(l=>l.kind!=="spread").map(l=>`${_e(l.name)}: ${$t(l)}`);t!=null&&s.push(`children: ${t}`);let a=`{ ${s.join(", ")} }`;return o.length>0?(n.add("mergeProps"),`mergeProps(${o.map(l=>l.expr).join(", ")}, ${a})`):a}function Be(e,t,n){return e.length===1?q(e[0],t,n):`[${e.map(o=>q(o,t,n)).join(", ")}]`}function De(e,t,n,o,i){o.add("createMemo"),o.add("createComponent");let s=t.filter(p=>p.kind==="spread"),l=t.filter(p=>p.kind!=="spread").map(p=>`get ${_e(p.name)}() { return ${At(p)}; }`);n.length>0&&l.push(`get children() { return ${Be(n,o,i)}; }`);let c=`{ ${l.join(", ")} }`;return s.length>0&&(o.add("mergeProps"),c=`mergeProps(${s.map(p=>p.expr).join(", ")}, ${c})`),`createMemo(() => createComponent(${e}, ${c}))`}function Ot(e,t){let n=Xe(t.name),o=t.literal;return o===!0||o===void 0?`${e}.setAttribute(${JSON.stringify(n)}, "");`:o===!1||o===null?"":`${e}.setAttribute(${JSON.stringify(n)}, ${JSON.stringify(String(o))});`}var ze=!1;function q(e,t,n){switch(e.kind){case"text":return JSON.stringify(e.value);case"expr":return e.reactive?`() => (${e.code})`:`(${e.code})`;case"fragment":return e.children.length===0?"null":Be(e.children,t,n);case"component":return De(e.name,e.props,e.children,t,n);case"control":{let o=Pt[e.control]??e.control;return t.add(o),De(o,e.props,e.children,t,n)}case"element":{if(n&&e.static&&!e.svg&&me(e)){t.add("templateNode");let l=`_tmpl$${n.length}`;return n.push({id:l,html:U(e),tag:e.tag,svg:!1}),`templateNode(${l}, ${JSON.stringify(e.tag)})`}if(n&&ze){let l=je(e);if(l){t.add("templateNode"),t.add("insert"),t.add("holeEnd"),t.add("holeContent"),t.add("holeScope");let c=`_tmpl$${n.length}`;n.push({id:c,html:l.html,tag:l.tag,svg:!1});let p=[`const _el$ = templateNode(${c}, ${JSON.stringify(l.tag)}, true);`];for(let m of l.steps)p.push(`const ${m.ref} = ${m.expr};`);for(let m of l.holes)p.push(`insert(${m.parentRef}, holeScope(${m.startRef}, () => (${q(m.node,t,n)})), ${m.endRef}, holeContent(${m.startRef}, ${m.endRef}));`);return p.push("return _el$;"),`(() => { ${p.join(" ")} })()`}}t.add("createNativeElement");let o=JSON.stringify(e.tag),i="_el$",s=[],a=e.svg?`${o}, true`:o;if(s.push(`const ${i} = createNativeElement(${a});`),e.props.length>0)if(!e.svg&&e.props.every(H))for(let l of e.props)s.push(Ot(i,l));else{t.add("spread");let l=e.svg?", isSVG: true":"";s.push(`spread({ element: ${i}, props: ${jt(e.props,null,t)}${l} });`)}for(let l of e.children){t.add("insert");let c=q(l,t,n),p=l.kind==="expr"&&l.reactive||l.kind==="component"||l.kind==="control";s.push(p?`insert(${i}, ${c}, null);`:`insert(${i}, ${c});`)}return s.push(`return ${i};`),`(() => { ${s.join(" ")} })()`}}}function G(e,t){if(!t||t.length===0)return e;let n=new Map(t.map(o=>[o.id,JSON.stringify(o.html)]));return e.replace(/_tmpl\$\d+/g,o=>n.get(o)??o)}var X={name:"imperative",contract:fe,emit(e,t){let n=new Set,o=t?.templateClone!==!1?[]:void 0;return ze=t?.partialTemplates===!0,{code:q(e,n,o),imports:Array.from(n),templates:o}}};import{types as ne}from"@babel/core";import Ve from"@babel/generator";import{parseTemplate as Ft}from"@fluixi/template-parser";var Dt=Ve.default??Ve;function _t(e){return Dt(e,{concise:!0}).code}var We=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function Bt(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function He(e){return e.charAt(0).toUpperCase()+e.slice(1)}var ge=class{constructor(t,n){this.holes=t;this.used=n}hole(t){return this.holes[t]??{node:ne.identifier("undefined"),code:"undefined",reactive:!1}}emit(t){let{code:n,imports:o,templates:i}=X.emit(t,{});for(let s of o)this.used.add(s);return G(n,i)}lowerRoot(t){let n=this.lowerChildren(t);return n.length===1?n[0]:{kind:"fragment",children:n}}lowerChildren(t){let n=[];for(let o=0;o<t.length;o++){let i=t[o];if(i.kind==="Element"||i.kind==="Component"){let a=i.attributes.find(l=>l.kind==="IfDirective");if(a&&a.kind==="IfDirective"){let l=o+1;l<t.length&&this.isBlankText(t[l])&&l++;let c=t[l],p=c&&(c.kind==="Element"||c.kind==="Component")&&c.attributes.some(m=>m.kind==="ElseDirective");n.push(this.lowerIf(i,a.hole,p?c:null)),p&&(o=l);continue}if(i.attributes.some(l=>l.kind==="EachDirective")){n.push(this.lowerEach(i));continue}}let s=this.lowerNode(i);s&&n.push(s)}return n}isBlankText(t){return t.kind==="Text"&&!t.raw&&re(t.value)===""}lowerNode(t){switch(t.kind){case"Text":{if(t.raw)return{kind:"text",value:t.value};let n=re(t.value);return n?{kind:"text",value:n}:null}case"Comment":return null;case"Expression":{let n=this.hole(t.hole);return{kind:"expr",code:n.code,reactive:n.reactive}}case"Fragment":return{kind:"fragment",children:this.lowerChildren(t.children)};case"Element":return this.lowerElement(t);case"Component":return this.lowerComponent(t);default:return null}}lowerElement(t){let n=t.attributes.find(o=>o.kind==="Attribute"&&o.name==="is");if(t.tag==="component"&&n&&n.value&&n.value.kind==="hole"){let o=t.attributes.filter(s=>s!==n),i=this.lowerComponent({...t,kind:"Component",tag:"Dynamic",tagHole:null,attributes:o});return i.props.unshift({name:"component",kind:"attr",expr:`() => (${this.hole(n.value.hole).code})`}),i}return{kind:"element",tag:t.tag,svg:t.namespace==="svg",props:this.lowerAttributes(t.attributes),children:this.lowerChildren(t.children),static:!1}}lowerComponent(t){let n=t.tagHole!=null?this.hole(t.tagHole).code:t.tag,o=this.lowerAttributes(t.attributes),{slots:i,rest:s}=this.partitionSlots(t.children);for(let[c,p]of i){let m=p.length===1?p[0]:{kind:"fragment",children:p},u={name:c,kind:"attr",expr:this.emit(m),jsxElement:!0},E=o.findIndex(y=>y.name===c);E>=0?o[E]=u:o.push(u)}let a=t.attributes.find(c=>c.kind==="LoadDirective"),l=a?B(`load:${a.strategy}`,a.modifier):void 0;return{kind:"component",name:n,props:o,children:this.lowerChildren(s),...l?{load:l}:{}}}partitionSlots(t){let n=new Map,o=[];for(let i of t){if(i.kind==="Element"||i.kind==="Component"){let s=i.attributes.find(a=>a.kind==="Attribute"&&a.name==="slot");if(s&&s.value&&s.value.kind==="static"){let a={...i,attributes:i.attributes.filter(p=>p!==s)},l=a.kind==="Element"?this.lowerElement(a):this.lowerComponent(a),c=n.get(s.value.value)??[];c.push(l),n.set(s.value.value,c);continue}}o.push(i)}return{slots:n,rest:o}}lowerIf(t,n,o){let i=this.hole(n),s=[{name:"when",kind:"attr",expr:i.code,reactive:i.reactive}];if(o){let l=this.stripAndLower(o,c=>c.kind==="ElseDirective");s.push({name:"fallback",kind:"attr",expr:this.emit(l),jsxElement:!0})}let a=this.stripAndLower(t,l=>l.kind==="IfDirective");return{kind:"component",name:"Show",props:s,children:[a]}}lowerEach(t){let n=t.attributes.find(c=>c.kind==="EachDirective");if(!n||n.kind!=="EachDirective")return this.lowerNode(t);let o=this.hole(n.hole),i=[{name:"each",kind:"attr",expr:o.code,reactive:o.reactive}];if(n.key){let c="static"in n.key?`(item) => item[${JSON.stringify(n.key.static)}]`:this.hole(n.key.hole).code;i.push({name:"by",kind:"attr",expr:c})}let s=this.itemArrow(t),a;if(s){let c=s.body,p={kind:"expr",code:$(c,this.used),reactive:N(c)},m=this.rebuildWithChildren(t,[p]);a=`(${s.params.map(u=>_t(u)).join(", ")}) => (${this.emit(m)})`}else{let c=this.stripAndLower(t,p=>p.kind==="EachDirective");a=`() => (${this.emit(c)})`}return{kind:"component",name:"For",props:i,children:[{kind:"expr",code:a,reactive:!1}]}}itemArrow(t){let n=t.children.filter(i=>!this.isBlankText(i));if(n.length!==1||n[0].kind!=="Expression")return null;let o=this.hole(n[0].hole).node;return ne.isArrowFunctionExpression(o)&&!ne.isBlockStatement(o.body)?o:null}stripAndLower(t,n){let o={...t,attributes:t.attributes.filter(i=>!n(i))};return o.kind==="Element"?this.lowerElement(o):this.lowerComponent(o)}rebuildWithChildren(t,n){let o=this.lowerAttributes(t.attributes.filter(i=>i.kind!=="EachDirective"));return t.kind==="Element"?{kind:"element",tag:t.tag,svg:t.namespace==="svg",props:o,children:n,static:!1}:{kind:"component",name:t.tag,props:o,children:n}}lowerAttributes(t){let n=[],o=[],i=!1,s=[],a=!1,l=[];for(let c of t)switch(c.kind){case"IfDirective":case"EachDirective":case"ElseDirective":break;case"Attribute":n.push(this.plainAttr(c));break;case"PropertyBinding":n.push({name:c.name,kind:"prop",expr:this.hole(c.hole).code,reactive:this.hole(c.hole).reactive});break;case"EventBinding":n.push(this.eventProp(c));break;case"RefBinding":n.push({name:"ref",kind:"ref",expr:this.hole(c.hole).code,reactive:this.hole(c.hole).reactive});break;case"Spread":n.push({name:"",kind:"spread",expr:this.hole(c.hole).code});break;case"ClassDirective":{let p=this.hole(c.hole);o.push(`${JSON.stringify(c.name)}: ${p.code}`),i=i||p.reactive;break}case"StyleDirective":{let p=this.hole(c.hole);s.push(`${JSON.stringify(c.name)}: ${p.code}`),a=a||p.reactive;break}case"BindDirective":n.push(...this.bindProps(c.name,this.hole(c.hole).code));break;case"UseDirective":{let p=c.name??(c.hole!=null?this.hole(c.hole).code:null);if(!p)break;l.push(c.name!=null&&c.hole!=null?`[${p}, () => (${this.hole(c.hole).code})]`:`[${p}]`);break}}return o.length>0&&n.push({name:"classList",kind:"attr",expr:`{ ${o.join(", ")} }`,reactive:i}),s.length>0&&n.push({name:"style",kind:"attr",expr:`{ ${s.join(", ")} }`,reactive:a}),l.length>0&&n.push({name:"use",kind:"attr",expr:`[${l.join(", ")}]`}),n}eventProp(t){let n=t.name.toLowerCase(),o=this.hole(t.hole).code;if(!(t.syntax==="colon"||t.modifiers.length>0))return{name:"on"+He(t.name),kind:"event",event:{name:n,delegated:We.has(n)},expr:o};let s=this.wrapHandler(o,t.modifiers),a=this.eventOptions(t.modifiers),l=a?`[${s}, ${a}]`:s;return{name:"on:"+n,kind:"attr",expr:l}}wrapHandler(t,n){let o=n.includes("self")?"if (e.target !== e.currentTarget) return; ":"",i=[];return n.includes("prevent")&&i.push("e.preventDefault();"),n.includes("stop")&&i.push("e.stopPropagation();"),!o&&i.length===0?t:`(e) => { ${o}${i.join(" ")} return (${t})(e); }`}eventOptions(t){let n=[];return t.includes("capture")&&n.push("capture: true"),t.includes("once")&&n.push("once: true"),t.includes("passive")&&n.push("passive: true"),n.length?`{ ${n.join(", ")} }`:null}bindProps(t,n){let o=t==="checked",i=o?"change":"input",s=o?"checked":"value",a=`(${n})`;return[{name:t,kind:"attr",expr:`${a}[0]()`,reactive:!0},{name:"on"+He(i),kind:"event",event:{name:i,delegated:We.has(i)},expr:`(e) => ${a}[1](e.target.${s})`}]}plainAttr(t){let n=t.value,o=t.name;t.name==="class"?o=n&&n.kind==="hole"&&ne.isObjectExpression(this.hole(n.hole).node)?"classList":"className":t.name==="html"&&(o="innerHTML");let s={name:o,kind:"attr"};if(n==null)return s.literal=!0,s;if(n.kind==="static")return s.literal=n.value,s;if(n.kind==="hole"){let c=this.hole(n.hole);return s.expr=c.code,s.reactive=c.reactive,s}let a=!1,l=n.parts.map(c=>{if("text"in c)return Bt(c.text);let p=this.hole(c.hole);return a=a||p.reactive,"${"+p.code+"}"}).join("");return s.expr="`"+l+"`",s.reactive=a,s}};function Ue(e,t,n={}){let o=e.quasi,i=o.expressions.map(l=>{let c=l;return{node:c,code:$(c,t),reactive:N(c)}}),s=zt(o),{root:a}=Ft(s,{svg:n.svg});return new ge(i,t).lowerRoot(a.children)}function zt(e){let t=[];return e.quasis.forEach((n,o)=>{let i=n.value.cooked??n.value.raw;if(t.push({kind:"static",text:i,start:n.start??0}),o<e.expressions.length){let s=e.expressions[o];t.push({kind:"hole",index:o,start:s.start??0,end:s.end??0})}}),t}function Vt(e){switch(e.kind){case"event":return"event";case"ref":return"ref";case"spread":return"spread";case"class":case"style":return"class-or-style-directive";case"attr":case"prop":return e.reactive?"reactive-prop":e.expr!==void 0?"expression-prop":void 0;default:return"expression-prop"}}function ie(e){let t=[],n=new Map,o=i=>{switch(i.kind){case"text":return!0;case"expr":return!1;case"component":case"control":for(let s of i.children)o(s);return!1;case"fragment":for(let s of i.children)o(s);return!1;case"element":{let s=!0;for(let l of i.children)o(l)||(s=!1);let a;for(let l of i.props)if(a=Vt(l),a)break;return!a&&!s&&(a=Wt(i)),i.static=!a,a?n.set(i,a):t.push(i),i.static}default:return!1}};for(let i of Array.isArray(e)?e:[e])o(i);return{staticElements:t,reasons:n}}function Wt(e){for(let t of e.children){if(t.kind==="expr")return"expression-child";if(t.kind==="component")return"component-child";if(t.kind==="control")return"control-child";if(t.kind==="element"&&!t.static||t.kind==="fragment")return"expression-child"}return"expression-child"}function oe(e,t=new Set,n={}){let o=Ue(e,t,n);return ie(o),o}var qt=qe.default??qe;function Ze(e){return qt(e,{concise:!0}).code}function Gt(e,t){let n=f.cloneNode(e,!0),o=f.file(f.program([f.expressionStatement(n)])),i=!1,s=(a,l,c)=>{for(let p of c)t.add(p);a.replaceWith(Ut.expression(l,{placeholderPattern:!1,plugins:["typescript"]})()),a.skip(),i=!0};return Ht(o,{"JSXElement|JSXFragment"(a){let l=a.node,{code:c,imports:p,templates:m}=X.emit(xe(l,t),{});s(a,G(c,m),p)},TaggedTemplateExpression(a){let l=a.node.tag;if(!f.isIdentifier(l)||l.name!=="html"&&l.name!=="svg")return;let c=oe(a.node,t,{svg:l.name==="svg"}),{code:p,imports:m,templates:u}=X.emit(c,{});s(a,G(p,u),m)}}),i?o.program.body[0].expression:e}function $(e,t){return Ze(Gt(e,t))}var Kt=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),Zt=/^on[A-Z]/,Yt=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function Qt(e){if(f.isJSXIdentifier(e)){let t=e.name[0]!==e.name[0].toLowerCase();return{tag:e.name,component:t}}return f.isJSXMemberExpression(e)?{tag:Ze(e),component:!0}:f.isJSXNamespacedName(e)?{tag:`${e.namespace.name}:${e.name.name}`,component:!1}:{tag:"div",component:!1}}function Ee(e){return f.isJSXIdentifier(e)?e.name==="class"?"className":e.name:f.isJSXNamespacedName(e)?`${e.namespace.name}:${e.name.name}`:"unknown"}function N(e){return f.isCallExpression(e)||f.isOptionalCallExpression(e)?!0:f.isMemberExpression(e)||f.isOptionalMemberExpression(e)?!(!e.computed&&f.isIdentifier(e.property,{name:"children"})):f.isConditionalExpression(e)?N(e.test)||N(e.consequent)||N(e.alternate):f.isLogicalExpression(e)||f.isBinaryExpression(e)?N(e.left)||N(e.right):f.isTemplateLiteral(e)?e.expressions.some(t=>N(t)):f.isObjectExpression(e)?e.properties.some(t=>f.isObjectProperty(t)&&!t.computed&&N(t.value)):f.isArrayExpression(e)?e.elements.some(t=>t!=null&&!f.isSpreadElement(t)&&N(t)):!1}function en(e,t){let n=Ee(e.name),o=Zt.test(n),i=o||n.startsWith("on:"),a={name:n,kind:o?"event":"attr"};o&&(a.event={name:n.slice(2).toLowerCase(),delegated:Yt.has(n.slice(2).toLowerCase())});let l=e.value;if(l==null)return a.literal=!0,a;if(f.isStringLiteral(l))return a.literal=l.value,a;if(f.isJSXExpressionContainer(l)&&!f.isJSXEmptyExpression(l.expression)){let c=l.expression;return f.isStringLiteral(c)||f.isNumericLiteral(c)||f.isBooleanLiteral(c)?(a.literal=c.value,a):(a.expr=$(c,t),a.reactive=i?!1:N(c),(f.isJSXElement(c)||f.isJSXFragment(c))&&(a.jsxElement=!0),a)}return a.literal=!0,a}function Ge(e,t){let n=e.value;return n==null?null:f.isStringLiteral(n)?JSON.stringify(n.value):f.isJSXExpressionContainer(n)&&!f.isJSXEmptyExpression(n.expression)?$(n.expression,t):null}function tn(e,t){let n=[],o=[];for(let i of e){if(f.isJSXSpreadAttribute(i)){n.push({name:"",kind:"spread",expr:$(i.argument,t)});continue}if(!f.isJSXAttribute(i)||W(Ee(i.name)))continue;let s=f.isJSXNamespacedName(i.name)?i.name.namespace.name:null;if(s==="use"){let a=i.name.name.name;t.add(a);let l=Ge(i,t);o.push(l!=null?`[${a}, () => (${l})]`:`[${a}]`);continue}if(s==="oncapture"){let a=i.name.name.name.toLowerCase(),l=Ge(i,t)??"undefined";n.push({name:"on:"+a,kind:"attr",expr:`[${l}, { capture: true }]`});continue}n.push(en(i,t))}return o.length>0&&n.push({name:"use",kind:"attr",expr:`[${o.join(", ")}]`}),n}function re(e){let t=e.split(/\r\n|\n|\r/),n=0;for(let i=0;i<t.length;i++)/[^ \t]/.test(t[i])&&(n=i);let o="";for(let i=0;i<t.length;i++){let s=t[i].replace(/\t/g," ");i!==0&&(s=s.replace(/^ +/,"")),i!==t.length-1&&(s=s.replace(/ +$/,"")),s&&(i!==n&&(s+=" "),o+=s)}return o}function Ke(e,t){let n=[];for(let o of e)if(f.isJSXText(o)){let i=re(o.value);i&&n.push({kind:"text",value:i})}else if(f.isJSXExpressionContainer(o)){if(!f.isJSXEmptyExpression(o.expression)){let i=o.expression;n.push({kind:"expr",code:$(i,t),reactive:N(i)})}}else f.isJSXElement(o)||f.isJSXFragment(o)?n.push(he(o,t)):f.isJSXSpreadChild(o)&&n.push({kind:"expr",code:$(o.expression,t),reactive:!1});return n}function xe(e,t=new Set){let n=he(e,t);return ie(n),n}function he(e,t){if(f.isJSXFragment(e))return{kind:"fragment",children:Ke(e.children,t)};let{tag:n,component:o}=Qt(e.openingElement.name),i=tn(e.openingElement.attributes,t),s=Ke(e.children,t);if(o){let a=nn(e.openingElement.attributes);return{kind:"component",name:n,props:i,children:s,...a?{load:a}:{}}}return{kind:"element",tag:n,svg:Kt.has(n),props:i,children:s,static:!1}}function nn(e){for(let t of e){if(!f.isJSXAttribute(t))continue;let n=Ee(t.name);if(W(n)){if(t.value&&!f.isStringLiteral(t.value))throw new J(`'${n}' needs a literal value, not an expression — the strategy is compile-time.`);return B(n,t.value?t.value.value:null)}}}var ae=new Set([...V,...D]),Ye=new Set(D),se=new Set(_),on={Show:"when",For:"each",Index:"each",Match:"when"};var rt=/^on[A-Z]/,it=["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave"],Rr=rn((e,t={})=>{e.assertVersion(7);let{runtime:n="automatic",importSource:o="@fluixi/jsx",pragma:i="jsx",pragmaFrag:s="Fragment",development:a=!1,detectReactivity:l=!0,useLitHTML:c=!0,hoistStatics:p=!0,delegateEvents:m=!0,delegatedEvents:u=it,optimizeControlFlow:E=!0,sourceMaps:y=!0,signalModule:R="@fluixi/dom",controlFlowModule:I="@fluixi/dom",routerModule:O="@fluixi/core/router-next",reactiveModule:Re="@fluixi/reactive/signal",autoShowTransform:Ce=!1,backend:M="imperative",codegen:z="inline",templateClone:Ie=!0,partialTemplates:we=!0,format:Ne="both",litTag:ft="html",resolve:gt=[]}=t,ke=Me(gt),ht=Ne==="lit"||Ne==="both",Et={backend:M,codegen:z,irImports:new Set,libModule:"@fluixi/core",controlFlowModule:I,routerModule:O,templateClone:Ie,partialTemplates:we,hasJSX:!1,hasReactivity:!1,hasLitHTML:!1,needsSignalImport:!1,needsControlFlowImport:!1,needsCreateMemo:!1,controlFlowComponents:new Set,resolvedComponents:new Map,deferredComponents:new Map,componentResolver:ke,delegatedEvents:new Set,staticElements:new Map,staticTemplates:new Map,staticCounter:0};return{name:"@fluixi/babel-plugin-jsx",manipulateOptions(g,d){d.plugins.push("jsx","typescript")},pre(g){Object.assign(g,Et)},visitor:{ImportDeclaration(g,d){g.node.source.value==="@fluixi/core/rx"&&(g.node.source=r.stringLiteral("@fluixi/reactive"))},Program:{enter(g,d){Object.assign(d,{hasJSX:!1,hasReactivity:!1,hasLitHTML:!1,hasLitIR:!1,needsSignalImport:!1,needsControlFlowImport:!1,needsCreateMemo:!1,controlFlowComponents:new Set,resolvedComponents:new Map,deferredComponents:new Map,componentResolver:ke,delegatedEvents:new Set,staticElements:new Map,staticTemplates:new Map,autoShow:Ce,staticCounter:0,libModule:"@fluixi/core",controlFlowModule:I,routerModule:O,templateClone:Ie,partialTemplates:we,backend:M,codegen:z,irImports:new Set,needsCreateNativeElement:!1,needsInsert:!1,needsSpread:!1,needsCreateComponent:!1,needsMergeProps:!1})},exit(g,d){let h=[];if(d.hasJSX||d.needsSignalImport&&h.push(r.importDeclaration([r.importSpecifier(r.identifier("signal"),r.identifier("signal"))],r.stringLiteral(R))),d.hasJSX||d.hasLitIR){if(d.irImports.size>0){let S=new Set(["Show","For","Index","Switch","Match","Dynamic","ErrorBoundary","Portal","Suspense"]),x=new Set(["createMemo","createEffect","createRenderEffect","createRoot","createSignal","onCleanup","batch","untrack"]),v=Array.from(d.irImports),C=b=>r.importSpecifier(r.identifier(b),r.identifier(b)),L=b=>!g.scope.hasBinding(b),F=v.filter(b=>x.has(b)&&L(b)),w=v.filter(b=>!S.has(b)&&!x.has(b)&&L(b)),Y=v.filter(b=>S.has(b)&&L(b));F.length>0&&h.push(r.importDeclaration(F.map(C),r.stringLiteral(Re))),w.length>0&&h.push(r.importDeclaration(w.map(C),r.stringLiteral(R))),Y.length>0&&h.push(r.importDeclaration(Y.map(C),r.stringLiteral(I)))}if(d.hasJSX&&M==="imperative"&&z!=="ir"){let x=[[!!d.needsCreateNativeElement,"createNativeElement"],[!!d.needsSpread,"spread"],[!!d.needsInsert,"insert"],[!!d.needsCreateComponent,"createComponent"],[!!d.needsMergeProps,"mergeProps"]].filter(([v,C])=>v&&!g.scope.hasBinding(C)).map(([,v])=>r.importSpecifier(r.identifier(v),r.identifier(v)));x.length>0&&h.push(r.importDeclaration(x,r.stringLiteral(R)))}else if(d.hasJSX&&n==="automatic"&&M!=="imperative"){let S=[r.importSpecifier(r.identifier("jsx"),r.identifier("jsx")),r.importSpecifier(r.identifier("jsxs"),r.identifier("jsxs")),r.importSpecifier(r.identifier("Fragment"),r.identifier("Fragment"))];a&&S.push(r.importSpecifier(r.identifier("jsxDEV"),r.identifier("jsxDEV"))),d.needsMergeProps&&S.push(r.importSpecifier(r.identifier("mergeProps"),r.identifier("mergeProps"))),h.push(r.importDeclaration(S,r.stringLiteral(o)))}if(d.needsCreateMemo&&!g.scope.hasBinding("createMemo")&&h.push(r.importDeclaration([r.importSpecifier(r.identifier("createMemo"),r.identifier("createMemo"))],r.stringLiteral(M==="imperative"?Re:d.libModule??"@fluixi/core"))),d.needsControlFlowImport&&d.controlFlowComponents.size>0){let S=Array.from(d.controlFlowComponents).filter(w=>!g.scope.hasBinding(w)),x=d.libModule??"@fluixi/core",v=S.filter(w=>se.has(w)),C=S.filter(w=>Ye.has(w)),L=S.filter(w=>!Ye.has(w)&&!se.has(w)),F=(w,Y)=>r.importDeclaration(w.map(b=>r.importSpecifier(r.identifier(b),r.identifier(b))),r.stringLiteral(Y));L.length>0&&h.push(F(L,I)),C.length>0&&h.push(F(C,x)),v.length>0&&h.push(F(v,O))}let k=[];if(d.deferredComponents.size>0){for(let[S,x]of d.deferredComponents)g.scope.hasBinding(S)||k.push(r.variableDeclaration("const",[r.variableDeclarator(r.identifier(S),r.callExpression(r.identifier("deferred"),[r.arrowFunctionExpression([],r.callExpression(r.import(),[r.stringLiteral(x.module)])),r.objectExpression([r.objectProperty(r.identifier("strategy"),pn(x.strategy)),r.objectProperty(r.identifier("export"),r.stringLiteral(x.export))])]))]));k.length>0&&!g.scope.hasBinding("deferred")&&h.push(r.importDeclaration([r.importSpecifier(r.identifier("deferred"),r.identifier("deferred"))],r.stringLiteral(d.libModule??"@fluixi/core")))}if(d.resolvedComponents.size>0){let S=new Map;for(let[x,v]of d.resolvedComponents){if(g.scope.hasBinding(x))continue;let C=S.get(v.module)??[];C.push({local:x,exported:v.export}),S.set(v.module,C)}for(let[x,v]of S)h.push(r.importDeclaration(v.map(({local:C,exported:L})=>L==="default"?r.importDefaultSpecifier(r.identifier(C)):r.importSpecifier(r.identifier(C),r.identifier(L))),r.stringLiteral(x)))}if(m&&d.delegatedEvents.size>0){h.push(r.importDeclaration([r.importSpecifier(r.identifier("delegateEvents"),r.identifier("delegateEvents"))],r.stringLiteral(M==="imperative"?R:"@fluixi/jsx")));let S=r.arrayExpression(Array.from(d.delegatedEvents).map(v=>r.stringLiteral(v))),x=r.expressionStatement(r.callExpression(r.identifier("delegateEvents"),[S]));g.node.body.unshift(x)}if(p&&d.staticElements.size>0){let S=[];d.staticElements.forEach((x,v)=>{S.push(r.variableDeclaration("const",[r.variableDeclarator(r.identifier(v),x)]))}),g.node.body.unshift(...S)}if(k.length>0&&g.node.body.unshift(...k),d.staticTemplates.size>0){let S=[];for(let[x,v]of d.staticTemplates){let L=x.startsWith("svg:")?x.slice(4):x;S.push(r.variableDeclaration("const",[r.variableDeclarator(r.identifier(v),r.stringLiteral(L))]))}g.node.body.unshift(...S)}}h.length>0&&g.node.body.unshift(...dn(h))}},JSXElement(g,d){if(d.hasJSX=!0,M==="imperative"&&z==="ir"){g.replaceWith(et(g.node,d));return}let h=g.node,k=h.openingElement;if(r.isJSXIdentifier(k.name)&&se.has(k.name.name)&&!d.componentResolver?.resolve(k.name.name)&&(d.controlFlowComponents.add(k.name.name),d.needsControlFlowImport=!0),r.isJSXIdentifier(k.name)&&ae.has(k.name.name)&&(d.controlFlowComponents.add(k.name.name),E)){let x=Nn(h,d);if(x){g.replaceWith(x);return}}if(p&&M!=="imperative"&&mt(h,d)){let x=wn(h,d);if(x){g.replaceWith(x);return}}let S=sn(h,d,{runtime:n,pragma:i,development:a,detectReactivity:l,useLitHTML:c,autoShow:Ce});g.replaceWith(S)},JSXFragment(g,d){if(d.hasJSX=!0,M==="imperative"&&z==="ir"){g.replaceWith(et(g.node,d));return}let h=le(g.node,d,{runtime:n,pragmaFrag:s,development:a});g.replaceWith(h)},CallExpression(g,d){if(!l)return;let h=g.node.callee;h.name,r.isIdentifier(h)&&(h.name==="createSignal"||h.name==="createStore"||h.name==="useContext"||h.name==="useLocation")&&(d.hasReactivity=!0)},JSXExpressionContainer(g){},TaggedTemplateExpression(g,d){if(ht&&M==="imperative"&&r.isIdentifier(g.node.tag)&&(g.node.tag.name===ft||g.node.tag.name==="svg")){g.replaceWith(mn(g.node,d));return}}}}});function sn(e,t,n){let{runtime:o,pragma:i,development:s,autoShow:a=!0}=n;return o==="automatic"?Z(e,t,s,a):hn(e,t,i)}var an=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]);function Qe(e,t,n){return t.length>0?(n.needsMergeProps=!0,r.callExpression(r.identifier("mergeProps"),[...t,r.objectExpression(e)])):r.objectExpression(e)}function ot(e){return e.length===1?e[0]:r.arrayExpression(e)}function ln(e,t,n,o,i,s){if(!t){let u=[...n];return i.length>0&&u.push(r.objectMethod("get",r.identifier("children"),[],r.blockStatement([r.returnStatement(ot(i))]))),st(e,Qe(u,o,s),s)}let a=e.value,l=an.has(a),c=r.identifier("_el$"),p=[];s.needsCreateNativeElement=!0;let m=[e];if(l&&m.push(r.booleanLiteral(!0)),p.push(r.variableDeclaration("const",[r.variableDeclarator(c,r.callExpression(r.identifier("createNativeElement"),m))])),n.length>0||o.length>0){s.needsSpread=!0;let u=[r.objectProperty(r.identifier("element"),c),r.objectProperty(r.identifier("props"),Qe(n,o,s))];l&&u.push(r.objectProperty(r.identifier("isSVG"),r.booleanLiteral(!0))),p.push(r.expressionStatement(r.callExpression(r.identifier("spread"),[r.objectExpression(u)])))}if(i.length>0){s.needsInsert=!0;for(let u of i){let y=r.isArrowFunctionExpression(u)||r.isFunctionExpression(u)||r.isCallExpression(u)&&r.isIdentifier(u.callee)&&u.callee.name==="createMemo"?[r.cloneNode(c),u,r.nullLiteral()]:[r.cloneNode(c),u];p.push(r.expressionStatement(r.callExpression(r.identifier("insert"),y)))}}return p.push(r.returnStatement(c)),r.callExpression(r.arrowFunctionExpression([],r.blockStatement(p)),[])}function cn(e,t){let n=null;if(t.value)if(r.isStringLiteral(t.value))n=t.value.value;else throw new J(`'${e}' needs a literal value, not an expression — the strategy is compile-time.`);return B(e,n)}function pn(e){let t=[r.objectProperty(r.identifier("kind"),r.stringLiteral(e.kind))];return e.kind==="visible"&&e.rootMargin&&t.push(r.objectProperty(r.identifier("rootMargin"),r.stringLiteral(e.rootMargin))),e.kind==="interaction"&&t.push(r.objectProperty(r.identifier("events"),r.arrayExpression(e.events.map(n=>r.stringLiteral(n))))),e.kind==="media"&&t.push(r.objectProperty(r.identifier("query"),r.stringLiteral(e.query))),r.objectExpression(t)}function un(e,t){return!P(e)||!P(t)?A:e}function st(e,t,n){r.isIdentifier(e)&&ae.has(e.name)&&(n.controlFlowComponents.add(e.name),n.needsControlFlowImport=!0);let o=!1;if(r.isIdentifier(e)&&!ae.has(e.name)&&n.componentResolver){let i=n.componentResolver.resolve(e.name);if(i){let s=n.pendingLoad??A,a=n.resolvedComponents.has(e.name);if(P(s)&&!a){let l=n.deferredComponents.get(e.name),c=l?un(l.strategy,s):s;P(c)?n.deferredComponents.set(e.name,{...i,strategy:c}):(n.deferredComponents.delete(e.name),n.resolvedComponents.set(e.name,i))}else n.deferredComponents.delete(e.name),n.resolvedComponents.set(e.name,i);o=!0}}return n.pendingLoad=void 0,!o&&r.isIdentifier(e)&&se.has(e.name)&&(n.controlFlowComponents.add(e.name),n.needsControlFlowImport=!0),n.backend==="imperative"?(n.needsCreateComponent=!0,n.needsCreateMemo=!0,r.callExpression(r.identifier("createMemo"),[r.arrowFunctionExpression([],r.callExpression(r.identifier("createComponent"),[e,t]))])):r.callExpression(r.identifier("jsx"),[e,t])}function at(e,t,n){if(!t||t.length===0)return e;let o=new Map;for(let i of t){let s=`${i.svg?"svg:":""}${i.html}`,a=n.staticTemplates.get(s);a||(a=`_tmpl$${n.staticTemplates.size}`,n.staticTemplates.set(s,a)),o.set(i.id,a)}return e.replace(/_tmpl\$\d+/g,i=>o.get(i)??i)}function et(e,t){let n=new Set,o=xe(e,n);pe(o,{resolver:t.componentResolver,modules:{controlFlowModule:t.controlFlowModule,coreModule:t.libModule,routerModule:t.routerModule},strategyFor:c=>c.load}),ue(o);let{code:i,imports:s,templates:a}=X.emit(o,{templateClone:t.templateClone,partialTemplates:t.partialTemplates});for(let c of s)n.add(c);for(let c of n)t.irImports.add(c);ve(o,t);let l=at(i,a,t);return nt.expression(l,{placeholderPattern:!1,plugins:["typescript"]})()}function dn(e){let t=new Map,n=[];for(let o of e){let i=o.source.value;if(!o.specifiers.every(l=>r.isImportSpecifier(l))){n.push(o);continue}let a=t.get(i);if(!a){let l=new Set(o.specifiers.map(c=>c.local.name));t.set(i,{decl:o,names:l}),n.push(o);continue}for(let l of o.specifiers)a.names.has(l.local.name)||(a.names.add(l.local.name),a.decl.specifiers.push(l))}return n}function mn(e,t){let n=new Set,o=r.isIdentifier(e.tag)&&e.tag.name==="svg",i=oe(e,n,{svg:o});pe(i,{resolver:t.componentResolver,modules:{controlFlowModule:t.controlFlowModule,coreModule:t.libModule,routerModule:t.routerModule},strategyFor:p=>p.load}),ue(i);let{code:s,imports:a,templates:l}=X.emit(i,{templateClone:t.templateClone,partialTemplates:t.partialTemplates});for(let p of a)n.add(p);for(let p of n)t.irImports.add(p);ve(i,t),t.hasLitIR=!0;let c=nt.expression(at(s,l,t),{placeholderPattern:!1,plugins:["typescript"]})();return fn(c,e),c}function fn(e,t){if(!t.loc)return;let n=new Set,o=i=>{if(!n.has(i)){n.add(i),i.loc||(i.loc=t.loc,i.start=t.start,i.end=t.end);for(let s of r.VISITOR_KEYS[i.type]??[]){let a=i[s];if(Array.isArray(a))for(let l of a)l&&typeof l=="object"&&"type"in l&&o(l);else a&&typeof a=="object"&&"type"in a&&o(a)}}};o(e)}function ve(e,t){if(e.kind==="component"&&e.source&&(e.source.origin==="builtin"?(t.controlFlowComponents.add(e.name),t.needsControlFlowImport=!0):P(e.source.loading)&&!t.resolvedComponents.has(e.name)?t.deferredComponents.set(e.name,{module:e.source.module,export:e.source.export,strategy:e.source.loading}):(t.deferredComponents.delete(e.name),t.resolvedComponents.set(e.name,{module:e.source.module,export:e.source.export}))),(e.kind==="element"||e.kind==="component"||e.kind==="control")&&"props"in e)for(let n of e.props)n.kind==="event"&&n.event?.delegated&&t.delegatedEvents.add(n.event.name);if("children"in e&&e.children)for(let n of e.children)ve(n,t)}function gn(e){return e.map(t=>{if(r.isObjectProperty(t)){let n=t.key,o=t.computed,i=t.value;return r.objectMethod("get",n,[],r.blockStatement([r.returnStatement(i)]),o)}return t})}function Z(e,t,n,o=!0){let i=e.openingElement,s=e.children,a=lt(i.name),l=r.isJSXIdentifier(i.name)&&/^[a-z]/.test(i.name.name),c=pt(i.attributes,t,l,r.isJSXIdentifier(i.name)?i.name.name:""),p=c.props,m=c.spreads;l||(p=gn(p));let u=be(s,t,o);if(t.backend==="imperative")return ln(a,l,p,m,u,t);if(u.length>0){let I=u.length===1?u[0]:r.arrayExpression(u);p.push(r.objectProperty(r.identifier("children"),I))}let E;if(m.length>0){let I=p.length>0?r.objectExpression(p):r.objectExpression([]);t.needsMergeProps=!0,E=r.callExpression(r.identifier("mergeProps"),[...m,I])}else E=r.objectExpression(p);let y=n?"jsxDEV":u.length>1?"jsxs":"jsx",R=[a,E];return n&&R.push(r.identifier("undefined"),r.booleanLiteral(!1),r.identifier("undefined"),r.identifier("undefined")),r.callExpression(r.identifier(y),R)}function hn(e,t,n){let o=e.openingElement,i=e.children,s=lt(o.name),a=r.isJSXIdentifier(o.name)&&/^[a-z]/.test(o.name.name),{props:l,spreads:c}=pt(o.attributes,t,a,r.isJSXIdentifier(o.name)?o.name.name:""),p=be(i,t,t.autoShow??!0),m;if(c.length>0){let E=l.length>0?r.objectExpression(l):r.objectExpression([]);t.needsMergeProps=!0,m=r.callExpression(r.identifier("mergeProps"),[...c,E])}else m=l.length>0?r.objectExpression(l):r.nullLiteral();let u=[s,m,...p];return r.callExpression(r.identifier(n),u)}function le(e,t,n){let{runtime:o,pragmaFrag:i,development:s}=n,a=be(e.children,t,t.autoShow??!0);if(t.backend==="imperative")return a.length===0?r.nullLiteral():ot(a);if(o==="automatic"){let l=s?"jsxDEV":a.length>1?"jsxs":"jsx",c=r.objectExpression([r.objectProperty(r.identifier("children"),a.length===1?a[0]:r.arrayExpression(a))]),p=[r.identifier("Fragment"),c];return s&&p.push(r.identifier("undefined"),r.booleanLiteral(!1),r.identifier("undefined"),r.identifier("undefined")),r.callExpression(r.identifier(l),p)}else return r.callExpression(r.identifier(i),a)}function lt(e){if(r.isJSXIdentifier(e)){let t=e.name;return t[0]===t[0].toLowerCase()?r.stringLiteral(t):r.identifier(t)}return r.isJSXMemberExpression(e)?ct(e):r.isJSXNamespacedName(e)?r.stringLiteral(`${e.namespace.name}:${e.name.name}`):r.stringLiteral("div")}function ct(e){let t;return r.isJSXIdentifier(e.object)?t=r.identifier(e.object.name):t=ct(e.object),r.memberExpression(t,r.identifier(e.property.name))}function En(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)}function pt(e,t,n=!0,o=""){let i=[],s=[],a=on[o];t.pendingLoad=void 0;for(let l of e)if(r.isJSXSpreadAttribute(l))s.push(l.argument);else if(r.isJSXAttribute(l)){let c=xn(l.name);if(W(c)){t.pendingLoad=cn(c,l);continue}let p=Sn(l.value,t,c,n);if(rt.test(c)){let O=c.slice(2).toLowerCase();it.includes(O)&&t.delegatedEvents.add(O)}let m=En(c)?r.identifier(c):r.stringLiteral(c),u=l.value,E=r.isJSXElement(u)||r.isJSXFragment(u)||r.isJSXExpressionContainer(u)&&(r.isJSXElement(u.expression)||r.isJSXFragment(u.expression)),y=!n&&c===a,R=r.isJSXExpressionContainer(u)&&!r.isJSXEmptyExpression(u.expression)?u.expression:null,I=!n&&!!R&&ut(R,c);!n&&E||y||I?i.push(r.objectMethod("get",m,[],r.blockStatement([r.returnStatement(p)]))):i.push(r.objectProperty(m,p))}return{props:i,spreads:s}}function xn(e){return r.isJSXIdentifier(e)?e.name==="class"?"className":e.name:r.isJSXNamespacedName(e)?`${e.namespace.name}:${e.name.name}`:"unknown"}function Sn(e,t,n="",o=!0){if(e===null)return r.booleanLiteral(!0);if(r.isStringLiteral(e))return e.value.includes(`
|
|
2
|
-
`)?r.stringLiteral(e.value.replace(/\s+/g," ").trim()):e;if(r.isJSXExpressionContainer(e)){if(r.isJSXEmptyExpression(e.expression))return r.booleanLiteral(!0);let i=e.expression;return o&&
|
|
1
|
+
import{declare as on}from"@babel/helper-plugin-utils";var St=e=>"components"in e;function Le(e,t){return e.replace(/\$(\d+)/g,(n,o)=>t[Number(o)]??n)}function vt(e,t){return typeof t=="string"?{module:t,export:e}:t}function Me(e=[]){let t=new Map,n=[],o=[];for(let a of e){if(!St(a)){o.push(a);continue}for(let[l,c]of Object.entries(a.components)){let p=vt(l,c),m=t.get(l);if(m&&m.module!==p.module){let u=n.find(h=>h.name===l);u?u.modules.push(p.module):n.push({name:l,modules:[m.module,p.module]});continue}t.set(l,p)}}let i=new Map;return{resolve:a=>{if(i.has(a))return i.get(a);let l=t.get(a);if(!l)for(let c of o){let p=a.match(new RegExp(c.match.source,c.match.flags.replace("g","")));if(p){l={module:Le(c.module,p),export:c.export?Le(c.export,p):a};break}}return i.set(a,l),l},names:()=>[...t.keys()],conflicts:()=>n}}var H=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],D=["Suspense","SuspenseList","Await"],_=["Router","Outlet","Redirect","Link"],Jn=[...H,...D,..._],ue=new Set([...H,...D]);function Je(e={}){let{controlFlowModule:t="@fluixi/dom",coreModule:n="@fluixi/core",routerModule:o="@fluixi/core/router-next"}=e,i={};for(let s of H)i[s]=t;for(let s of D)i[s]=n;for(let s of _)i[s]=o;return i}var j={kind:"eager"},bt=["pointerdown","focusin","keydown"],Te=new Set(["eager","idle","visible","interaction","media","never"]),J=class extends Error{};function U(e){return e.startsWith("load:")}function B(e,t){let n=e.slice(5);if(!Te.has(n))throw new J(`Unknown load strategy 'load:${n}'. Expected one of ${[...Te].join(", ")}.`);switch(n){case"eager":return j;case"idle":return{kind:"idle"};case"never":return{kind:"never"};case"visible":return t?{kind:"visible",rootMargin:t}:{kind:"visible"};case"interaction":return{kind:"interaction",events:t?yt(t):[...bt]};case"media":if(!t)throw new J(`'load:media' needs a query, e.g. load:media="(min-width: 1024px)".`);return{kind:"media",query:t};default:throw new J(`Unhandled load strategy '${n}'.`)}}function yt(e){let t=e.split(/[\s,]+/).map(n=>n.trim()).filter(Boolean);if(t.length===0)throw new J("'load:interaction' was given no event names.");return t}function X(e){return e.kind!=="eager"&&e.kind!=="never"}function de(e,t={}){let{resolver:n,isBound:o,modules:i,strategyFor:s}=t,a=Je(i),l=new Map,c=new Set,p=u=>{let{name:h}=u;if(!h||h.includes(".")||o?.(h))return;let y=m(h);if(!y){c.add(h);return}let C=y.origin==="builtin"&&ue.has(h)?j:s?.(u)??j;u.source={...y,loading:C},l.set(h,u.source)},m=u=>{if(ue.has(u))return{module:a[u],export:u,origin:"builtin"};let h=n?.resolve(u);if(h)return{module:h.module,export:h.export,origin:"rule"};if(_.includes(u))return{module:a[u],export:u,origin:"builtin"}};return te(e,u=>{u.kind==="component"&&p(u)}),{resolved:l,unresolved:[...c]}}function te(e,t){let n=Array.isArray(e)?e:[e];for(let o of n){t(o);let i=o.children;i&&te(i,t)}}function me(e){let t=[];te(e,s=>{s.kind==="component"&&s.source&&t.push(s)});let n=new Set,o=new Set;for(let s of t){let{module:a,loading:l}=s.source;l.kind==="eager"&&n.add(a),l.kind==="never"&&o.add(a)}let i=new Map;for(let s of t){let a=s.source;X(a.loading)&&n.has(a.module)&&(a.loading={kind:"eager"},i.set(a.module,(i.get(a.module)??0)+1))}return{collapsed:i,conflicted:[...o].filter(s=>n.has(s))}}import{types as r,template as rt}from"@babel/core";import{types as f,traverse as Ut,template as qt}from"@babel/core";import qe from"@babel/generator";var Rt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Pe={className:"class",htmlFor:"for"},Ct=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),It=new Set(["script","style","textarea","title"]);function fe(e){return It.has(e)}function Xe(e){return Pe[e]??e}function q(e){return e.kind!=="attr"||e.expr!==void 0||e.name.includes(":")?!1:!Ct.has(e.name)}function ge(e){if(!e.static||fe(e.tag))return!1;for(let t of e.props)if(!q(t))return!1;for(let t of e.children)if(t.kind!=="text"&&!(t.kind==="element"&&ge(t)))return!1;return!0}function G(e){let t=e.props.map(Nt).filter(Boolean).join(""),n=`<${e.tag}${t}>`;return Rt.has(e.tag)?n:`${n}${e.children.map(wt).join("")}</${e.tag}>`}function wt(e){if(e.kind==="text")return Lt(e.value);if(e.kind!=="element")throw new Error(`serializeStatic: unexpected ${e.kind}`);return G(e)}function Nt(e){let t=Pe[e.name]??e.name,n=e.literal;return n===!0||n===void 0?` ${t}`:n===!1||n===null?"":` ${t}="${kt(String(n))}"`}function kt(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Lt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var Mt="<!--fx-->",Jt="<!--fx/-->";function re(e){return e.kind==="expr"||e.kind==="component"||e.kind==="control"}function Tt(e){return e.kind==="text"||e.kind==="element"&&$e(e)}function $e(e){return e.svg||fe(e.tag)||!e.props.every(t=>q(t))?!1:e.children.every(t=>Tt(t)||re(t))}function ne(e){if(re(e))return!0;let t=e.children;return t?t.some(ne):!1}function Ae(e){for(let t=0;t<e.children.length;t++){let n=e.children[t];if(n.kind==="text"&&(n.value===""||e.children[t+1]?.kind==="text"))return!1}return e.children.every(t=>t.kind!=="element"||Ae(t))}function je(e){if(!$e(e)||!Ae(e)||!e.children.some(ne))return null;let t=[],n=[],o=0,i=a=>{let l=`_n$${o++}`;return t.push({ref:l,expr:a}),l};return s(e,"_el$"),{html:Pt(e),tag:e.tag,steps:t,holes:n};function s(a,l){let c=-1;a.children.forEach((m,u)=>{ne(m)&&(c=u)});let p=null;for(let m=0;m<=c;m++){let u=a.children[m],h=p?`${p}.nextSibling`:`${l}.firstChild`;if(re(u)){let C=i(h),I=i(`holeEnd(${C})`);n.push({parentRef:l,startRef:C,endRef:I,node:u}),p=I;continue}let y=i(h);u.kind==="element"&&ne(u)&&s(u,y),p=y}}}function Pt(e){return G(Oe(e)).split(Fe).join(Mt+Jt)}function Oe(e){return{...e,children:e.children.map(t=>re(t)?{kind:"text",value:Fe}:t.kind==="element"?Oe(t):t)}}var Fe="\0fx-hole\0";var he={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},zn={version:2,module:"@fluixi/dom",symbols:[...he.symbols,"template","cloneTemplate","walk"]};var Xt={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function $t(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function _e(e){return $t(e)?e:JSON.stringify(e)}function At(e){return e.expr!==void 0?e.reactive?`() => (${e.expr})`:`(${e.expr})`:JSON.stringify(e.literal??!0)}function jt(e){return e.expr!==void 0?`(${e.expr})`:JSON.stringify(e.literal??!0)}function Ot(e,t,n){let o=e.filter(l=>l.kind==="spread"),s=e.filter(l=>l.kind!=="spread").map(l=>`${_e(l.name)}: ${At(l)}`);t!=null&&s.push(`children: ${t}`);let a=`{ ${s.join(", ")} }`;return o.length>0?(n.add("mergeProps"),`mergeProps(${o.map(l=>l.expr).join(", ")}, ${a})`):a}function Be(e,t,n){return e.length===1?K(e[0],t,n):`[${e.map(o=>K(o,t,n)).join(", ")}]`}function De(e,t,n,o,i){o.add("createMemo"),o.add("createComponent");let s=t.filter(p=>p.kind==="spread"),l=t.filter(p=>p.kind!=="spread").map(p=>`get ${_e(p.name)}() { return ${jt(p)}; }`);n.length>0&&l.push(`get children() { return ${Be(n,o,i)}; }`);let c=`{ ${l.join(", ")} }`;return s.length>0&&(o.add("mergeProps"),c=`mergeProps(${s.map(p=>p.expr).join(", ")}, ${c})`),`createMemo(() => createComponent(${e}, ${c}))`}function Ft(e,t){let n=Xe(t.name),o=t.literal;return o===!0||o===void 0?`${e}.setAttribute(${JSON.stringify(n)}, "");`:o===!1||o===null?"":`${e}.setAttribute(${JSON.stringify(n)}, ${JSON.stringify(String(o))});`}var ze=!1;function K(e,t,n){switch(e.kind){case"text":return JSON.stringify(e.value);case"expr":return e.reactive?`() => (${e.code})`:`(${e.code})`;case"fragment":return e.children.length===0?"null":Be(e.children,t,n);case"component":return De(e.name,e.props,e.children,t,n);case"control":{let o=Xt[e.control]??e.control;return t.add(o),De(o,e.props,e.children,t,n)}case"element":{if(n&&e.static&&!e.svg&&ge(e)){t.add("templateNode");let l=`_tmpl$${n.length}`;return n.push({id:l,html:G(e),tag:e.tag,svg:!1}),`templateNode(${l}, ${JSON.stringify(e.tag)})`}if(n&&ze){let l=je(e);if(l){t.add("templateNode"),t.add("insert"),t.add("holeEnd"),t.add("holeContent"),t.add("holeScope");let c=`_tmpl$${n.length}`;n.push({id:c,html:l.html,tag:l.tag,svg:!1});let p=[`const _el$ = templateNode(${c}, ${JSON.stringify(l.tag)}, true);`];for(let m of l.steps)p.push(`const ${m.ref} = ${m.expr};`);for(let m of l.holes)p.push(`insert(${m.parentRef}, holeScope(${m.startRef}, () => (${K(m.node,t,n)})), ${m.endRef}, holeContent(${m.startRef}, ${m.endRef}));`);return p.push("return _el$;"),`(() => { ${p.join(" ")} })()`}}t.add("createNativeElement");let o=JSON.stringify(e.tag),i="_el$",s=[],a=e.svg?`${o}, true`:o;if(s.push(`const ${i} = createNativeElement(${a});`),e.props.length>0)if(!e.svg&&e.props.every(q))for(let l of e.props)s.push(Ft(i,l));else{t.add("spread");let l=e.svg?", isSVG: true":"";s.push(`spread({ element: ${i}, props: ${Ot(e.props,null,t)}${l} });`)}for(let l of e.children){t.add("insert");let c=K(l,t,n),p=l.kind==="expr"&&l.reactive||l.kind==="component"||l.kind==="control";s.push(p?`insert(${i}, ${c}, null);`:`insert(${i}, ${c});`)}return s.push(`return ${i};`),`(() => { ${s.join(" ")} })()`}}}function Z(e,t){if(!t||t.length===0)return e;let n=new Map(t.map(o=>[o.id,JSON.stringify(o.html)]));return e.replace(/_tmpl\$\d+/g,o=>n.get(o)??o)}var $={name:"imperative",contract:he,emit(e,t){let n=new Set,o=t?.templateClone!==!1?[]:void 0;return ze=t?.partialTemplates===!0,{code:K(e,n,o),imports:Array.from(n),templates:o}}};import{types as ie}from"@babel/core";import Ve from"@babel/generator";import{parseTemplate as Dt}from"@fluixi/template-parser";var _t=Ve.default??Ve;function Bt(e){return _t(e,{concise:!0}).code}var We=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function zt(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function He(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Ee=class{constructor(t,n){this.holes=t;this.used=n}hole(t){return this.holes[t]??{node:ie.identifier("undefined"),code:"undefined",reactive:!1}}emit(t){let{code:n,imports:o,templates:i}=$.emit(t,{});for(let s of o)this.used.add(s);return Z(n,i)}lowerRoot(t){let n=this.lowerChildren(t);return n.length===1?n[0]:{kind:"fragment",children:n}}lowerChildren(t){let n=[];for(let o=0;o<t.length;o++){let i=t[o];if(i.kind==="Element"||i.kind==="Component"){let a=i.attributes.find(l=>l.kind==="IfDirective");if(a&&a.kind==="IfDirective"){let l=o+1;l<t.length&&this.isBlankText(t[l])&&l++;let c=t[l],p=c&&(c.kind==="Element"||c.kind==="Component")&&c.attributes.some(m=>m.kind==="ElseDirective");n.push(this.lowerIf(i,a.hole,p?c:null)),p&&(o=l);continue}if(i.attributes.some(l=>l.kind==="EachDirective")){n.push(this.lowerEach(i));continue}}let s=this.lowerNode(i);s&&n.push(s)}return n}isBlankText(t){return t.kind==="Text"&&!t.raw&&oe(t.value)===""}lowerNode(t){switch(t.kind){case"Text":{if(t.raw)return{kind:"text",value:t.value};let n=oe(t.value);return n?{kind:"text",value:n}:null}case"Comment":return null;case"Expression":{let n=this.hole(t.hole);return{kind:"expr",code:n.code,reactive:n.reactive}}case"Fragment":return{kind:"fragment",children:this.lowerChildren(t.children)};case"Element":return this.lowerElement(t);case"Component":return this.lowerComponent(t);default:return null}}lowerElement(t){let n=t.attributes.find(o=>o.kind==="Attribute"&&o.name==="is");if(t.tag==="component"&&n&&n.value&&n.value.kind==="hole"){let o=t.attributes.filter(s=>s!==n),i=this.lowerComponent({...t,kind:"Component",tag:"Dynamic",tagHole:null,attributes:o});return i.props.unshift({name:"component",kind:"attr",expr:`() => (${this.hole(n.value.hole).code})`}),i}return{kind:"element",tag:t.tag,svg:t.namespace==="svg",props:this.lowerAttributes(t.attributes),children:this.lowerChildren(t.children),static:!1}}lowerComponent(t){let n=t.tagHole!=null?this.hole(t.tagHole).code:t.tag,o=this.lowerAttributes(t.attributes),{slots:i,rest:s}=this.partitionSlots(t.children);for(let[c,p]of i){let m=p.length===1?p[0]:{kind:"fragment",children:p},u={name:c,kind:"attr",expr:this.emit(m),jsxElement:!0},h=o.findIndex(y=>y.name===c);h>=0?o[h]=u:o.push(u)}let a=t.attributes.find(c=>c.kind==="LoadDirective"),l=a?B(`load:${a.strategy}`,a.modifier):void 0;return{kind:"component",name:n,props:o,children:this.lowerChildren(s),...l?{load:l}:{}}}partitionSlots(t){let n=new Map,o=[];for(let i of t){if(i.kind==="Element"||i.kind==="Component"){let s=i.attributes.find(a=>a.kind==="Attribute"&&a.name==="slot");if(s&&s.value&&s.value.kind==="static"){let a={...i,attributes:i.attributes.filter(p=>p!==s)},l=a.kind==="Element"?this.lowerElement(a):this.lowerComponent(a),c=n.get(s.value.value)??[];c.push(l),n.set(s.value.value,c);continue}}o.push(i)}return{slots:n,rest:o}}lowerIf(t,n,o){let i=this.hole(n),s=[{name:"when",kind:"attr",expr:i.code,reactive:i.reactive}];if(o){let l=this.stripAndLower(o,c=>c.kind==="ElseDirective");s.push({name:"fallback",kind:"attr",expr:this.emit(l),jsxElement:!0})}let a=this.stripAndLower(t,l=>l.kind==="IfDirective");return{kind:"component",name:"Show",props:s,children:[a]}}lowerEach(t){let n=t.attributes.find(c=>c.kind==="EachDirective");if(!n||n.kind!=="EachDirective")return this.lowerNode(t);let o=this.hole(n.hole),i=[{name:"each",kind:"attr",expr:o.code,reactive:o.reactive}];if(n.key){let c="static"in n.key?`(item) => item[${JSON.stringify(n.key.static)}]`:this.hole(n.key.hole).code;i.push({name:"by",kind:"attr",expr:c})}let s=this.itemArrow(t),a;if(s){let c=s.body,p={kind:"expr",code:A(c,this.used),reactive:N(c)},m=this.rebuildWithChildren(t,[p]);a=`(${s.params.map(u=>Bt(u)).join(", ")}) => (${this.emit(m)})`}else{let c=this.stripAndLower(t,p=>p.kind==="EachDirective");a=`() => (${this.emit(c)})`}return{kind:"component",name:"For",props:i,children:[{kind:"expr",code:a,reactive:!1}]}}itemArrow(t){let n=t.children.filter(i=>!this.isBlankText(i));if(n.length!==1||n[0].kind!=="Expression")return null;let o=this.hole(n[0].hole).node;return ie.isArrowFunctionExpression(o)&&!ie.isBlockStatement(o.body)?o:null}stripAndLower(t,n){let o={...t,attributes:t.attributes.filter(i=>!n(i))};return o.kind==="Element"?this.lowerElement(o):this.lowerComponent(o)}rebuildWithChildren(t,n){let o=this.lowerAttributes(t.attributes.filter(i=>i.kind!=="EachDirective"));return t.kind==="Element"?{kind:"element",tag:t.tag,svg:t.namespace==="svg",props:o,children:n,static:!1}:{kind:"component",name:t.tag,props:o,children:n}}lowerAttributes(t){let n=[],o=[],i=!1,s=[],a=!1,l=[];for(let c of t)switch(c.kind){case"IfDirective":case"EachDirective":case"ElseDirective":break;case"Attribute":n.push(this.plainAttr(c));break;case"PropertyBinding":n.push({name:c.name,kind:"prop",expr:this.hole(c.hole).code,reactive:this.hole(c.hole).reactive});break;case"EventBinding":n.push(this.eventProp(c));break;case"RefBinding":n.push({name:"ref",kind:"ref",expr:this.hole(c.hole).code,reactive:this.hole(c.hole).reactive});break;case"Spread":n.push({name:"",kind:"spread",expr:this.hole(c.hole).code});break;case"ClassDirective":{let p=this.hole(c.hole);o.push(`${JSON.stringify(c.name)}: ${p.code}`),i=i||p.reactive;break}case"StyleDirective":{let p=this.hole(c.hole);s.push(`${JSON.stringify(c.name)}: ${p.code}`),a=a||p.reactive;break}case"BindDirective":n.push(...this.bindProps(c.name,this.hole(c.hole).code));break;case"UseDirective":{let p=c.name??(c.hole!=null?this.hole(c.hole).code:null);if(!p)break;l.push(c.name!=null&&c.hole!=null?`[${p}, () => (${this.hole(c.hole).code})]`:`[${p}]`);break}}return o.length>0&&n.push({name:"classList",kind:"attr",expr:`{ ${o.join(", ")} }`,reactive:i}),s.length>0&&n.push({name:"style",kind:"attr",expr:`{ ${s.join(", ")} }`,reactive:a}),l.length>0&&n.push({name:"use",kind:"attr",expr:`[${l.join(", ")}]`}),n}eventProp(t){let n=t.name.toLowerCase(),o=this.hole(t.hole).code;if(!(t.syntax==="colon"||t.modifiers.length>0))return{name:"on"+He(t.name),kind:"event",event:{name:n,delegated:We.has(n)},expr:o};let s=this.wrapHandler(o,t.modifiers),a=this.eventOptions(t.modifiers),l=a?`[${s}, ${a}]`:s;return{name:"on:"+n,kind:"attr",expr:l}}wrapHandler(t,n){let o=n.includes("self")?"if (e.target !== e.currentTarget) return; ":"",i=[];return n.includes("prevent")&&i.push("e.preventDefault();"),n.includes("stop")&&i.push("e.stopPropagation();"),!o&&i.length===0?t:`(e) => { ${o}${i.join(" ")} return (${t})(e); }`}eventOptions(t){let n=[];return t.includes("capture")&&n.push("capture: true"),t.includes("once")&&n.push("once: true"),t.includes("passive")&&n.push("passive: true"),n.length?`{ ${n.join(", ")} }`:null}bindProps(t,n){let o=t==="checked",i=o?"change":"input",s=o?"checked":"value",a=`(${n})`;return[{name:t,kind:"attr",expr:`${a}[0]()`,reactive:!0},{name:"on"+He(i),kind:"event",event:{name:i,delegated:We.has(i)},expr:`(e) => ${a}[1](e.target.${s})`}]}plainAttr(t){let n=t.value,o=t.name;t.name==="class"?o=n&&n.kind==="hole"&&ie.isObjectExpression(this.hole(n.hole).node)?"classList":"className":t.name==="html"&&(o="innerHTML");let s={name:o,kind:"attr"};if(n==null)return s.literal=!0,s;if(n.kind==="static")return s.literal=n.value,s;if(n.kind==="hole"){let c=this.hole(n.hole);return s.expr=c.code,s.reactive=c.reactive,s}let a=!1,l=n.parts.map(c=>{if("text"in c)return zt(c.text);let p=this.hole(c.hole);return a=a||p.reactive,"${"+p.code+"}"}).join("");return s.expr="`"+l+"`",s.reactive=a,s}};function Ue(e,t,n={}){let o=e.quasi,i=o.expressions.map(l=>{let c=l;return{node:c,code:A(c,t),reactive:N(c)}}),s=Vt(o),{root:a}=Dt(s,{svg:n.svg});return new Ee(i,t).lowerRoot(a.children)}function Vt(e){let t=[];return e.quasis.forEach((n,o)=>{let i=n.value.cooked??n.value.raw;if(t.push({kind:"static",text:i,start:n.start??0}),o<e.expressions.length){let s=e.expressions[o];t.push({kind:"hole",index:o,start:s.start??0,end:s.end??0})}}),t}function Wt(e){switch(e.kind){case"event":return"event";case"ref":return"ref";case"spread":return"spread";case"class":case"style":return"class-or-style-directive";case"attr":case"prop":return e.reactive?"reactive-prop":e.expr!==void 0?"expression-prop":void 0;default:return"expression-prop"}}function se(e){let t=[],n=new Map,o=i=>{switch(i.kind){case"text":return!0;case"expr":return!1;case"component":case"control":for(let s of i.children)o(s);return!1;case"fragment":for(let s of i.children)o(s);return!1;case"element":{let s=!0;for(let l of i.children)o(l)||(s=!1);let a;for(let l of i.props)if(a=Wt(l),a)break;return!a&&!s&&(a=Ht(i)),i.static=!a,a?n.set(i,a):t.push(i),i.static}default:return!1}};for(let i of Array.isArray(e)?e:[e])o(i);return{staticElements:t,reasons:n}}function Ht(e){for(let t of e.children){if(t.kind==="expr")return"expression-child";if(t.kind==="component")return"component-child";if(t.kind==="control")return"control-child";if(t.kind==="element"&&!t.static||t.kind==="fragment")return"expression-child"}return"expression-child"}function ae(e,t=new Set,n={}){let o=Ue(e,t,n);return se(o),o}var Gt=qe.default??qe;function Ze(e){return Gt(e,{concise:!0}).code}function Kt(e,t){let n=f.cloneNode(e,!0),o=f.file(f.program([f.expressionStatement(n)])),i=!1,s=(a,l,c)=>{for(let p of c)t.add(p);a.replaceWith(qt.expression(l,{placeholderPattern:!1,plugins:["typescript"]})()),a.skip(),i=!0};return Ut(o,{"JSXElement|JSXFragment"(a){let l=a.node,{code:c,imports:p,templates:m}=$.emit(ve(l,t),{});s(a,Z(c,m),p)},TaggedTemplateExpression(a){let l=a.node.tag;if(!f.isIdentifier(l)||l.name!=="html"&&l.name!=="svg")return;let c=ae(a.node,t,{svg:l.name==="svg"}),{code:p,imports:m,templates:u}=$.emit(c,{});s(a,Z(p,u),m)}}),i?o.program.body[0].expression:e}function A(e,t){return Ze(Kt(e,t))}var Zt=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),Yt=/^on[A-Z]/,Qt=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function en(e){if(f.isJSXIdentifier(e)){let t=e.name[0]!==e.name[0].toLowerCase();return{tag:e.name,component:t}}return f.isJSXMemberExpression(e)?{tag:Ze(e),component:!0}:f.isJSXNamespacedName(e)?{tag:`${e.namespace.name}:${e.name.name}`,component:!1}:{tag:"div",component:!1}}function Se(e){return f.isJSXIdentifier(e)?e.name==="class"?"className":e.name:f.isJSXNamespacedName(e)?`${e.namespace.name}:${e.name.name}`:"unknown"}function N(e){return f.isCallExpression(e)||f.isOptionalCallExpression(e)?!0:f.isMemberExpression(e)||f.isOptionalMemberExpression(e)?!(!e.computed&&f.isIdentifier(e.property,{name:"children"})):f.isConditionalExpression(e)?N(e.test)||N(e.consequent)||N(e.alternate):f.isLogicalExpression(e)||f.isBinaryExpression(e)?N(e.left)||N(e.right):f.isTemplateLiteral(e)?e.expressions.some(t=>N(t)):f.isObjectExpression(e)?e.properties.some(t=>f.isObjectProperty(t)&&!t.computed&&N(t.value)):f.isArrayExpression(e)?e.elements.some(t=>t!=null&&!f.isSpreadElement(t)&&N(t)):!1}function tn(e,t){let n=Se(e.name),o=Yt.test(n),i=o||n.startsWith("on:"),a={name:n,kind:o?"event":"attr"};o&&(a.event={name:n.slice(2).toLowerCase(),delegated:Qt.has(n.slice(2).toLowerCase())});let l=e.value;if(l==null)return a.literal=!0,a;if(f.isStringLiteral(l))return a.literal=l.value,a;if(f.isJSXExpressionContainer(l)&&!f.isJSXEmptyExpression(l.expression)){let c=l.expression;return f.isStringLiteral(c)||f.isNumericLiteral(c)||f.isBooleanLiteral(c)?(a.literal=c.value,a):(a.expr=A(c,t),a.reactive=i?!1:N(c),(f.isJSXElement(c)||f.isJSXFragment(c))&&(a.jsxElement=!0),a)}return a.literal=!0,a}function Ge(e,t){let n=e.value;return n==null?null:f.isStringLiteral(n)?JSON.stringify(n.value):f.isJSXExpressionContainer(n)&&!f.isJSXEmptyExpression(n.expression)?A(n.expression,t):null}function nn(e,t){let n=[],o=[];for(let i of e){if(f.isJSXSpreadAttribute(i)){n.push({name:"",kind:"spread",expr:A(i.argument,t)});continue}if(!f.isJSXAttribute(i)||U(Se(i.name)))continue;let s=f.isJSXNamespacedName(i.name)?i.name.namespace.name:null;if(s==="use"){let a=i.name.name.name;t.add(a);let l=Ge(i,t);o.push(l!=null?`[${a}, () => (${l})]`:`[${a}]`);continue}if(s==="oncapture"){let a=i.name.name.name.toLowerCase(),l=Ge(i,t)??"undefined";n.push({name:"on:"+a,kind:"attr",expr:`[${l}, { capture: true }]`});continue}n.push(tn(i,t))}return o.length>0&&n.push({name:"use",kind:"attr",expr:`[${o.join(", ")}]`}),n}function oe(e){let t=e.split(/\r\n|\n|\r/),n=0;for(let i=0;i<t.length;i++)/[^ \t]/.test(t[i])&&(n=i);let o="";for(let i=0;i<t.length;i++){let s=t[i].replace(/\t/g," ");i!==0&&(s=s.replace(/^ +/,"")),i!==t.length-1&&(s=s.replace(/ +$/,"")),s&&(i!==n&&(s+=" "),o+=s)}return o}function Ke(e,t){let n=[];for(let o of e)if(f.isJSXText(o)){let i=oe(o.value);i&&n.push({kind:"text",value:i})}else if(f.isJSXExpressionContainer(o)){if(!f.isJSXEmptyExpression(o.expression)){let i=o.expression;n.push({kind:"expr",code:A(i,t),reactive:N(i)})}}else f.isJSXElement(o)||f.isJSXFragment(o)?n.push(xe(o,t)):f.isJSXSpreadChild(o)&&n.push({kind:"expr",code:A(o.expression,t),reactive:!1});return n}function ve(e,t=new Set){let n=xe(e,t);return se(n),n}function xe(e,t){if(f.isJSXFragment(e))return{kind:"fragment",children:Ke(e.children,t)};let{tag:n,component:o}=en(e.openingElement.name),i=nn(e.openingElement.attributes,t),s=Ke(e.children,t);if(o){let a=rn(e.openingElement.attributes);return{kind:"component",name:n,props:i,children:s,...a?{load:a}:{}}}return{kind:"element",tag:n,svg:Zt.has(n),props:i,children:s,static:!1}}function rn(e){for(let t of e){if(!f.isJSXAttribute(t))continue;let n=Se(t.name);if(U(n)){if(t.value&&!f.isStringLiteral(t.value))throw new J(`'${n}' needs a literal value, not an expression — the strategy is compile-time.`);return B(n,t.value?t.value.value:null)}}}var ce=new Set([...H,...D]),Ye=new Set(D),le=new Set(_),sn={Show:"when",For:"each",Index:"each",Match:"when"};var it=/^on[A-Z]/,ot=["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave"],Rr=on((e,t={})=>{e.assertVersion(7);let{runtime:n="automatic",importSource:o="@fluixi/jsx",pragma:i="jsx",pragmaFrag:s="Fragment",development:a=!1,detectReactivity:l=!0,useLitHTML:c=!0,hoistStatics:p=!0,delegateEvents:m=!0,delegatedEvents:u=ot,optimizeControlFlow:h=!0,sourceMaps:y=!0,signalModule:C="@fluixi/dom",controlFlowModule:I="@fluixi/dom",routerModule:z="@fluixi/core/router-next",reactiveModule:P="@fluixi/reactive/signal",autoShowTransform:V=!1,backend:M="imperative",codegen:W="ir",templateClone:Ie=!0,partialTemplates:we=!0,format:Ne="both",litTag:gt="html",resolve:ht=[]}=t,ke=Me(ht),Et=Ne==="lit"||Ne==="both",xt={backend:M,codegen:W,irImports:new Set,libModule:"@fluixi/core",controlFlowModule:I,routerModule:z,templateClone:Ie,partialTemplates:we,hasJSX:!1,hasReactivity:!1,hasLitHTML:!1,needsSignalImport:!1,needsControlFlowImport:!1,needsCreateMemo:!1,controlFlowComponents:new Set,resolvedComponents:new Map,deferredComponents:new Map,componentResolver:ke,delegatedEvents:new Set,staticElements:new Map,staticTemplates:new Map,staticCounter:0};return{name:"@fluixi/babel-plugin-jsx",manipulateOptions(g,d){d.plugins.push("jsx","typescript")},pre(g){Object.assign(g,xt)},visitor:{ImportDeclaration(g,d){g.node.source.value==="@fluixi/core/rx"&&(g.node.source=r.stringLiteral("@fluixi/reactive"))},Program:{enter(g,d){Object.assign(d,{hasJSX:!1,hasReactivity:!1,hasLitHTML:!1,hasLitIR:!1,needsSignalImport:!1,needsControlFlowImport:!1,needsCreateMemo:!1,controlFlowComponents:new Set,resolvedComponents:new Map,deferredComponents:new Map,componentResolver:ke,delegatedEvents:new Set,staticElements:new Map,staticTemplates:new Map,autoShow:V,staticCounter:0,libModule:"@fluixi/core",controlFlowModule:I,routerModule:z,templateClone:Ie,partialTemplates:we,backend:M,codegen:W,irImports:new Set,needsCreateNativeElement:!1,needsInsert:!1,needsSpread:!1,needsCreateComponent:!1,needsMergeProps:!1})},exit(g,d){let E=[];if(d.hasJSX||d.needsSignalImport&&E.push(r.importDeclaration([r.importSpecifier(r.identifier("signal"),r.identifier("signal"))],r.stringLiteral(C))),d.hasJSX||d.hasLitIR){if(d.irImports.size>0){let S=new Set(["Show","For","Index","Switch","Match","Dynamic","ErrorBoundary","Portal","Suspense"]),x=new Set(["createMemo","createEffect","createRenderEffect","createRoot","createSignal","onCleanup","batch","untrack"]),v=Array.from(d.irImports),R=b=>r.importSpecifier(r.identifier(b),r.identifier(b)),L=b=>!g.scope.hasBinding(b),F=v.filter(b=>x.has(b)&&L(b)),w=v.filter(b=>!S.has(b)&&!x.has(b)&&L(b)),ee=v.filter(b=>S.has(b)&&L(b));F.length>0&&E.push(r.importDeclaration(F.map(R),r.stringLiteral(P))),w.length>0&&E.push(r.importDeclaration(w.map(R),r.stringLiteral(C))),ee.length>0&&E.push(r.importDeclaration(ee.map(R),r.stringLiteral(I)))}if(d.hasJSX&&M==="imperative"&&W!=="ir"){let x=[[!!d.needsCreateNativeElement,"createNativeElement"],[!!d.needsSpread,"spread"],[!!d.needsInsert,"insert"],[!!d.needsCreateComponent,"createComponent"],[!!d.needsMergeProps,"mergeProps"]].filter(([v,R])=>v&&!g.scope.hasBinding(R)).map(([,v])=>r.importSpecifier(r.identifier(v),r.identifier(v)));x.length>0&&E.push(r.importDeclaration(x,r.stringLiteral(C)))}else if(d.hasJSX&&n==="automatic"&&M!=="imperative"){let S=[r.importSpecifier(r.identifier("jsx"),r.identifier("jsx")),r.importSpecifier(r.identifier("jsxs"),r.identifier("jsxs")),r.importSpecifier(r.identifier("Fragment"),r.identifier("Fragment"))];a&&S.push(r.importSpecifier(r.identifier("jsxDEV"),r.identifier("jsxDEV"))),d.needsMergeProps&&S.push(r.importSpecifier(r.identifier("mergeProps"),r.identifier("mergeProps"))),E.push(r.importDeclaration(S,r.stringLiteral(o)))}if(d.needsCreateMemo&&!g.scope.hasBinding("createMemo")&&E.push(r.importDeclaration([r.importSpecifier(r.identifier("createMemo"),r.identifier("createMemo"))],r.stringLiteral(M==="imperative"?P:d.libModule??"@fluixi/core"))),d.needsControlFlowImport&&d.controlFlowComponents.size>0){let S=Array.from(d.controlFlowComponents).filter(w=>!g.scope.hasBinding(w)),x=d.libModule??"@fluixi/core",v=S.filter(w=>le.has(w)),R=S.filter(w=>Ye.has(w)),L=S.filter(w=>!Ye.has(w)&&!le.has(w)),F=(w,ee)=>r.importDeclaration(w.map(b=>r.importSpecifier(r.identifier(b),r.identifier(b))),r.stringLiteral(ee));L.length>0&&E.push(F(L,I)),R.length>0&&E.push(F(R,x)),v.length>0&&E.push(F(v,z))}let k=[];if(d.deferredComponents.size>0){for(let[S,x]of d.deferredComponents)g.scope.hasBinding(S)||k.push(r.variableDeclaration("const",[r.variableDeclarator(r.identifier(S),r.callExpression(r.identifier("deferred"),[r.arrowFunctionExpression([],r.callExpression(r.import(),[r.stringLiteral(x.module)])),r.objectExpression([r.objectProperty(r.identifier("strategy"),un(x.strategy)),r.objectProperty(r.identifier("export"),r.stringLiteral(x.export))])]))]));k.length>0&&!g.scope.hasBinding("deferred")&&E.push(r.importDeclaration([r.importSpecifier(r.identifier("deferred"),r.identifier("deferred"))],r.stringLiteral(d.libModule??"@fluixi/core")))}if(d.resolvedComponents.size>0){let S=new Map;for(let[x,v]of d.resolvedComponents){if(g.scope.hasBinding(x))continue;let R=S.get(v.module)??[];R.push({local:x,exported:v.export}),S.set(v.module,R)}for(let[x,v]of S)E.push(r.importDeclaration(v.map(({local:R,exported:L})=>L==="default"?r.importDefaultSpecifier(r.identifier(R)):r.importSpecifier(r.identifier(R),r.identifier(L))),r.stringLiteral(x)))}if(m&&d.delegatedEvents.size>0){E.push(r.importDeclaration([r.importSpecifier(r.identifier("delegateEvents"),r.identifier("delegateEvents"))],r.stringLiteral(M==="imperative"?C:"@fluixi/jsx")));let S=r.arrayExpression(Array.from(d.delegatedEvents).map(v=>r.stringLiteral(v))),x=r.expressionStatement(r.callExpression(r.identifier("delegateEvents"),[S]));g.node.body.unshift(x)}if(p&&d.staticElements.size>0){let S=[];d.staticElements.forEach((x,v)=>{S.push(r.variableDeclaration("const",[r.variableDeclarator(r.identifier(v),x)]))}),g.node.body.unshift(...S)}if(k.length>0&&g.node.body.unshift(...k),d.staticTemplates.size>0){let S=[];for(let[x,v]of d.staticTemplates){let L=x.startsWith("svg:")?x.slice(4):x;S.push(r.variableDeclaration("const",[r.variableDeclarator(r.identifier(v),r.stringLiteral(L))]))}g.node.body.unshift(...S)}}E.length>0&&g.node.body.unshift(...mn(E))}},JSXElement(g,d){if(d.hasJSX=!0,M==="imperative"&&W==="ir"){g.replaceWith(et(g.node,d));return}let E=g.node,k=E.openingElement;if(r.isJSXIdentifier(k.name)&&le.has(k.name.name)&&!d.componentResolver?.resolve(k.name.name)&&(d.controlFlowComponents.add(k.name.name),d.needsControlFlowImport=!0),r.isJSXIdentifier(k.name)&&ce.has(k.name.name)&&(d.controlFlowComponents.add(k.name.name),h)){let x=Nn(E,d);if(x){g.replaceWith(x);return}}if(p&&M!=="imperative"&&ft(E,d)){let x=wn(E,d);if(x){g.replaceWith(x);return}}let S=an(E,d,{runtime:n,pragma:i,development:a,detectReactivity:l,useLitHTML:c,autoShow:V});g.replaceWith(S)},JSXFragment(g,d){if(d.hasJSX=!0,M==="imperative"&&W==="ir"){g.replaceWith(et(g.node,d));return}let E=pe(g.node,d,{runtime:n,pragmaFrag:s,development:a});g.replaceWith(E)},CallExpression(g,d){if(!l)return;let E=g.node.callee;E.name,r.isIdentifier(E)&&(E.name==="createSignal"||E.name==="createStore"||E.name==="useContext"||E.name==="useLocation")&&(d.hasReactivity=!0)},JSXExpressionContainer(g){},TaggedTemplateExpression(g,d){if(Et&&M==="imperative"&&r.isIdentifier(g.node.tag)&&(g.node.tag.name===gt||g.node.tag.name==="svg")){g.replaceWith(fn(g.node,d));return}}}}});function an(e,t,n){let{runtime:o,pragma:i,development:s,autoShow:a=!0}=n;return o==="automatic"?Q(e,t,s,a):En(e,t,i)}var ln=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]);function Qe(e,t,n){return t.length>0?(n.needsMergeProps=!0,r.callExpression(r.identifier("mergeProps"),[...t,r.objectExpression(e)])):r.objectExpression(e)}function st(e){return e.length===1?e[0]:r.arrayExpression(e)}function cn(e,t,n,o,i,s){if(!t){let u=[...n];return i.length>0&&u.push(r.objectMethod("get",r.identifier("children"),[],r.blockStatement([r.returnStatement(st(i))]))),at(e,Qe(u,o,s),s)}let a=e.value,l=ln.has(a),c=r.identifier("_el$"),p=[];s.needsCreateNativeElement=!0;let m=[e];if(l&&m.push(r.booleanLiteral(!0)),p.push(r.variableDeclaration("const",[r.variableDeclarator(c,r.callExpression(r.identifier("createNativeElement"),m))])),n.length>0||o.length>0){s.needsSpread=!0;let u=[r.objectProperty(r.identifier("element"),c),r.objectProperty(r.identifier("props"),Qe(n,o,s))];l&&u.push(r.objectProperty(r.identifier("isSVG"),r.booleanLiteral(!0))),p.push(r.expressionStatement(r.callExpression(r.identifier("spread"),[r.objectExpression(u)])))}if(i.length>0){s.needsInsert=!0;for(let u of i){let y=r.isArrowFunctionExpression(u)||r.isFunctionExpression(u)||r.isCallExpression(u)&&r.isIdentifier(u.callee)&&u.callee.name==="createMemo"?[r.cloneNode(c),u,r.nullLiteral()]:[r.cloneNode(c),u];p.push(r.expressionStatement(r.callExpression(r.identifier("insert"),y)))}}return p.push(r.returnStatement(c)),r.callExpression(r.arrowFunctionExpression([],r.blockStatement(p)),[])}function pn(e,t){let n=null;if(t.value)if(r.isStringLiteral(t.value))n=t.value.value;else throw new J(`'${e}' needs a literal value, not an expression — the strategy is compile-time.`);return B(e,n)}function un(e){let t=[r.objectProperty(r.identifier("kind"),r.stringLiteral(e.kind))];return e.kind==="visible"&&e.rootMargin&&t.push(r.objectProperty(r.identifier("rootMargin"),r.stringLiteral(e.rootMargin))),e.kind==="interaction"&&t.push(r.objectProperty(r.identifier("events"),r.arrayExpression(e.events.map(n=>r.stringLiteral(n))))),e.kind==="media"&&t.push(r.objectProperty(r.identifier("query"),r.stringLiteral(e.query))),r.objectExpression(t)}function dn(e,t){return!X(e)||!X(t)?j:e}function at(e,t,n){r.isIdentifier(e)&&ce.has(e.name)&&(n.controlFlowComponents.add(e.name),n.needsControlFlowImport=!0);let o=!1;if(r.isIdentifier(e)&&!ce.has(e.name)&&n.componentResolver){let i=n.componentResolver.resolve(e.name);if(i){let s=n.pendingLoad??j,a=n.resolvedComponents.has(e.name);if(X(s)&&!a){let l=n.deferredComponents.get(e.name),c=l?dn(l.strategy,s):s;X(c)?n.deferredComponents.set(e.name,{...i,strategy:c}):(n.deferredComponents.delete(e.name),n.resolvedComponents.set(e.name,i))}else n.deferredComponents.delete(e.name),n.resolvedComponents.set(e.name,i);o=!0}}return n.pendingLoad=void 0,!o&&r.isIdentifier(e)&&le.has(e.name)&&(n.controlFlowComponents.add(e.name),n.needsControlFlowImport=!0),n.backend==="imperative"?(n.needsCreateComponent=!0,n.needsCreateMemo=!0,r.callExpression(r.identifier("createMemo"),[r.arrowFunctionExpression([],r.callExpression(r.identifier("createComponent"),[e,t]))])):r.callExpression(r.identifier("jsx"),[e,t])}function lt(e,t,n){if(!t||t.length===0)return e;let o=new Map;for(let i of t){let s=`${i.svg?"svg:":""}${i.html}`,a=n.staticTemplates.get(s);a||(a=`_tmpl$${n.staticTemplates.size}`,n.staticTemplates.set(s,a)),o.set(i.id,a)}return e.replace(/_tmpl\$\d+/g,i=>o.get(i)??i)}function et(e,t){let n=new Set,o=ve(e,n);de(o,{resolver:t.componentResolver,modules:{controlFlowModule:t.controlFlowModule,coreModule:t.libModule,routerModule:t.routerModule},strategyFor:c=>c.load}),me(o);let{code:i,imports:s,templates:a}=$.emit(o,{templateClone:t.templateClone,partialTemplates:t.partialTemplates});for(let c of s)n.add(c);for(let c of n)t.irImports.add(c);ye(o,t);let l=lt(i,a,t);return rt.expression(l,{placeholderPattern:!1,plugins:["typescript"]})()}function mn(e){let t=new Map,n=[];for(let o of e){let i=o.source.value;if(!o.specifiers.every(l=>r.isImportSpecifier(l))){n.push(o);continue}let a=t.get(i);if(!a){let l=new Set(o.specifiers.map(c=>c.local.name));t.set(i,{decl:o,names:l}),n.push(o);continue}for(let l of o.specifiers)a.names.has(l.local.name)||(a.names.add(l.local.name),a.decl.specifiers.push(l))}return n}function fn(e,t){let n=new Set,o=r.isIdentifier(e.tag)&&e.tag.name==="svg",i=ae(e,n,{svg:o});de(i,{resolver:t.componentResolver,modules:{controlFlowModule:t.controlFlowModule,coreModule:t.libModule,routerModule:t.routerModule},strategyFor:p=>p.load}),me(i);let{code:s,imports:a,templates:l}=$.emit(i,{templateClone:t.templateClone,partialTemplates:t.partialTemplates});for(let p of a)n.add(p);for(let p of n)t.irImports.add(p);ye(i,t),t.hasLitIR=!0;let c=rt.expression(lt(s,l,t),{placeholderPattern:!1,plugins:["typescript"]})();return gn(c,e),c}function gn(e,t){if(!t.loc)return;let n=new Set,o=i=>{if(!n.has(i)){n.add(i),i.loc||(i.loc=t.loc,i.start=t.start,i.end=t.end);for(let s of r.VISITOR_KEYS[i.type]??[]){let a=i[s];if(Array.isArray(a))for(let l of a)l&&typeof l=="object"&&"type"in l&&o(l);else a&&typeof a=="object"&&"type"in a&&o(a)}}};o(e)}function ye(e,t){if(e.kind==="component"&&e.source&&(e.source.origin==="builtin"?(t.controlFlowComponents.add(e.name),t.needsControlFlowImport=!0):X(e.source.loading)&&!t.resolvedComponents.has(e.name)?t.deferredComponents.set(e.name,{module:e.source.module,export:e.source.export,strategy:e.source.loading}):(t.deferredComponents.delete(e.name),t.resolvedComponents.set(e.name,{module:e.source.module,export:e.source.export}))),(e.kind==="element"||e.kind==="component"||e.kind==="control")&&"props"in e)for(let n of e.props)n.kind==="event"&&n.event?.delegated&&t.delegatedEvents.add(n.event.name);if("children"in e&&e.children)for(let n of e.children)ye(n,t)}function hn(e){return e.map(t=>{if(r.isObjectProperty(t)){let n=t.key,o=t.computed,i=t.value;return r.objectMethod("get",n,[],r.blockStatement([r.returnStatement(i)]),o)}return t})}function Q(e,t,n,o=!0){let i=e.openingElement,s=e.children,a=ct(i.name),l=r.isJSXIdentifier(i.name)&&/^[a-z]/.test(i.name.name),c=ut(i.attributes,t,l,r.isJSXIdentifier(i.name)?i.name.name:""),p=c.props,m=c.spreads;l||(p=hn(p));let u=Re(s,t,o);if(t.backend==="imperative")return cn(a,l,p,m,u,t);if(u.length>0){let I=u.length===1?u[0]:r.arrayExpression(u);p.push(r.objectProperty(r.identifier("children"),I))}let h;if(m.length>0){let I=p.length>0?r.objectExpression(p):r.objectExpression([]);t.needsMergeProps=!0,h=r.callExpression(r.identifier("mergeProps"),[...m,I])}else h=r.objectExpression(p);let y=n?"jsxDEV":u.length>1?"jsxs":"jsx",C=[a,h];return n&&C.push(r.identifier("undefined"),r.booleanLiteral(!1),r.identifier("undefined"),r.identifier("undefined")),r.callExpression(r.identifier(y),C)}function En(e,t,n){let o=e.openingElement,i=e.children,s=ct(o.name),a=r.isJSXIdentifier(o.name)&&/^[a-z]/.test(o.name.name),{props:l,spreads:c}=ut(o.attributes,t,a,r.isJSXIdentifier(o.name)?o.name.name:""),p=Re(i,t,t.autoShow??!0),m;if(c.length>0){let h=l.length>0?r.objectExpression(l):r.objectExpression([]);t.needsMergeProps=!0,m=r.callExpression(r.identifier("mergeProps"),[...c,h])}else m=l.length>0?r.objectExpression(l):r.nullLiteral();let u=[s,m,...p];return r.callExpression(r.identifier(n),u)}function pe(e,t,n){let{runtime:o,pragmaFrag:i,development:s}=n,a=Re(e.children,t,t.autoShow??!0);if(t.backend==="imperative")return a.length===0?r.nullLiteral():st(a);if(o==="automatic"){let l=s?"jsxDEV":a.length>1?"jsxs":"jsx",c=r.objectExpression([r.objectProperty(r.identifier("children"),a.length===1?a[0]:r.arrayExpression(a))]),p=[r.identifier("Fragment"),c];return s&&p.push(r.identifier("undefined"),r.booleanLiteral(!1),r.identifier("undefined"),r.identifier("undefined")),r.callExpression(r.identifier(l),p)}else return r.callExpression(r.identifier(i),a)}function ct(e){if(r.isJSXIdentifier(e)){let t=e.name;return t[0]===t[0].toLowerCase()?r.stringLiteral(t):r.identifier(t)}return r.isJSXMemberExpression(e)?pt(e):r.isJSXNamespacedName(e)?r.stringLiteral(`${e.namespace.name}:${e.name.name}`):r.stringLiteral("div")}function pt(e){let t;return r.isJSXIdentifier(e.object)?t=r.identifier(e.object.name):t=pt(e.object),r.memberExpression(t,r.identifier(e.property.name))}function xn(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)}function ut(e,t,n=!0,o=""){let i=[],s=[],a=sn[o],l=[];t.pendingLoad=void 0;for(let c of e)if(r.isJSXSpreadAttribute(c))s.push(c.argument);else if(r.isJSXAttribute(c)){let p=Sn(c.name);if(U(p)){t.pendingLoad=pn(p,c);continue}if(r.isJSXNamespacedName(c.name)&&c.name.namespace.name==="use"){let P=r.identifier(c.name.name.name),V=c.value===null?null:tt(c.value,t,p,n);l.push(r.arrayExpression(V?[P,r.arrowFunctionExpression([],V)]:[P]));continue}let m=tt(c.value,t,p,n);if(it.test(p)){let P=p.slice(2).toLowerCase();ot.includes(P)&&t.delegatedEvents.add(P)}let u=xn(p)?r.identifier(p):r.stringLiteral(p),h=c.value,y=r.isJSXElement(h)||r.isJSXFragment(h)||r.isJSXExpressionContainer(h)&&(r.isJSXElement(h.expression)||r.isJSXFragment(h.expression)),C=!n&&p===a,I=r.isJSXExpressionContainer(h)&&!r.isJSXEmptyExpression(h.expression)?h.expression:null,z=!n&&!!I&&dt(I,p);!n&&y||C||z?i.push(r.objectMethod("get",u,[],r.blockStatement([r.returnStatement(m)]))):i.push(r.objectProperty(u,m))}return l.length>0&&i.push(r.objectProperty(r.identifier("use"),r.arrayExpression(l))),{props:i,spreads:s}}function Sn(e){return r.isJSXIdentifier(e)?e.name==="class"?"className":e.name:r.isJSXNamespacedName(e)?`${e.namespace.name}:${e.name.name}`:"unknown"}function tt(e,t,n="",o=!0){if(e===null)return r.booleanLiteral(!0);if(r.isStringLiteral(e))return e.value.includes(`
|
|
2
|
+
`)?r.stringLiteral(e.value.replace(/\s+/g," ").trim()):e;if(r.isJSXExpressionContainer(e)){if(r.isJSXEmptyExpression(e.expression))return r.booleanLiteral(!0);let i=e.expression;return o&&dt(i,n)?r.arrowFunctionExpression([],i):i}return r.isJSXElement(e)?Q(e,t,!1,t.autoShow??!0):r.isJSXFragment(e)?pe(e,t,{runtime:"automatic",pragmaFrag:"Fragment",development:!1}):r.booleanLiteral(!0)}function dt(e,t){return it.test(t)||t.startsWith("on:")||t==="ref"||t.startsWith("use:")||r.isArrowFunctionExpression(e)||r.isFunctionExpression(e)||r.isIdentifier(e)||r.isStringLiteral(e)||r.isNumericLiteral(e)||r.isBooleanLiteral(e)||r.isNullLiteral(e)?!1:!!(r.isCallExpression(e)||r.isOptionalCallExpression(e)||r.isMemberExpression(e)||r.isOptionalMemberExpression(e)||r.isLogicalExpression(e)||r.isConditionalExpression(e)||r.isBinaryExpression(e)||r.isUnaryExpression(e)||r.isTemplateLiteral(e)||r.isObjectExpression(e)||r.isArrayExpression(e))}function vn(e){let t=e.split(/\r\n|\n|\r/),n=0;for(let i=0;i<t.length;i++)/[^ \t]/.test(t[i])&&(n=i);let o="";for(let i=0;i<t.length;i++){let s=t[i].replace(/\t/g," ");i!==0&&(s=s.replace(/^ +/,"")),i!==t.length-1&&(s=s.replace(/ +$/,"")),s&&(i!==n&&(s+=" "),o+=s)}return o}function Re(e,t,n=!0){let o=[];for(let i of e)if(r.isJSXText(i)){let s=vn(i.value);s&&o.push(r.stringLiteral(s))}else if(r.isJSXExpressionContainer(i)){if(!r.isJSXEmptyExpression(i.expression)){let s=i.expression;if(n){let a=bn(s,t)??yn(s,t);if(a){o.push(a);continue}}else{let a=Rn(s,t);if(a){o.push(a);continue}}In(s)?o.push(r.arrowFunctionExpression([],s)):o.push(s)}}else r.isJSXElement(i)?o.push(Q(i,t,!1,t.autoShow??!0)):r.isJSXFragment(i)?o.push(pe(i,t,{runtime:"automatic",pragmaFrag:"Fragment",development:!1})):r.isJSXSpreadChild(i)&&o.push(i.expression);return o}function bn(e,t){if(!r.isArrowFunctionExpression(e)||e.params.length!==0||e.async)return null;let n=e.body;if(r.isLogicalExpression(n)&&n.operator==="&&"){let o=T(n.right);if(o)return Y(O(n.left),o,null,t)}if(r.isConditionalExpression(n)){let o=T(n.consequent);if(o){let i=Ce(n.alternate,t);return Y(O(n.test),o,i,t,!0)}}return null}function yn(e,t){if(r.isLogicalExpression(e)&&e.operator==="&&"){let n=T(e.right);if(n)return Y(O(e.left),n,null,t)}if(r.isConditionalExpression(e)){let n=T(e.consequent);if(n){let o=Ce(e.alternate,t);return Y(O(e.test),n,o,t)}}return null}function Rn(e,t){let n=r.isArrowFunctionExpression(e)&&e.params.length===0&&!e.async&&r.isExpression(e.body)?e.body:e;if(r.isConditionalExpression(n)){let o=O(n.test),s=T(n.consequent)??n.consequent,l=T(n.alternate)??n.alternate,c=r.conditionalExpression(o,s,l);return be(n.consequent)||be(n.alternate)?null:(t.needsCreateMemo=!0,r.callExpression(r.identifier("createMemo"),[r.arrowFunctionExpression([],c)]))}if(r.isLogicalExpression(n)&&n.operator==="&&"){let o=O(n.left),s=T(n.right)??n.right,a=r.logicalExpression("&&",o,s);return be(n.right)?null:(t.needsCreateMemo=!0,r.callExpression(r.identifier("createMemo"),[r.arrowFunctionExpression([],a)]))}return null}function Ce(e,t){if(Cn(e))return null;let n=T(e);if(n)return mt(n,t);if(r.isConditionalExpression(e)){let o=e,i=T(o.consequent);if(i){let s=Ce(o.alternate,t);return Y(O(o.test),i,s,t)}}return e}function nt(e){return r.isJSXElement(e)||r.isJSXFragment(e)}function be(e){let t=T(e);if(!t||!r.isJSXElement(t))return!1;let n=t.openingElement.name;return r.isJSXIdentifier(n)&&ce.has(n.name)}function T(e){return nt(e)?e:r.isArrowFunctionExpression(e)&&e.params.length===0&&!e.async&&nt(e.body)?e.body:null}function O(e){return r.isArrowFunctionExpression(e)&&e.params.length===0&&!e.async&&r.isExpression(e.body)?e.body:e}function Cn(e){return r.isNullLiteral(e)||r.isIdentifier(e)&&e.name==="undefined"||r.isBooleanLiteral(e)&&e.value===!1}function mt(e,t){return r.isJSXElement(e)?Q(e,t,!1,t.autoShow??!0):pe(e,t,{runtime:"automatic",pragmaFrag:"Fragment",development:!1})}function Y(e,t,n,o,i=!1){o.controlFlowComponents.add("Show"),o.needsControlFlowImport=!0;let s=mt(t,o),a=[r.objectProperty(r.identifier("when"),r.arrowFunctionExpression([],e)),r.objectProperty(r.identifier("children"),s)];return n&&a.push(r.objectProperty(r.identifier("fallback"),n)),at(r.identifier("Show"),r.objectExpression(a),o)}function In(e){return r.isMemberExpression(e)||r.isOptionalMemberExpression(e)?!(!e.computed&&r.isIdentifier(e.property,{name:"children"})):r.isCallExpression(e)||r.isOptionalCallExpression(e)?!0:r.isIdentifier(e)?!1:!!(r.isLogicalExpression(e)||r.isConditionalExpression(e)||r.isBinaryExpression(e)||r.isUnaryExpression(e)||r.isTemplateLiteral(e))}function ft(e,t){let n=e.openingElement;if(!r.isJSXIdentifier(n.name))return!1;let o=n.name.name;if(o[0]!==o[0].toLowerCase())return!1;for(let i of n.attributes){if(r.isJSXSpreadAttribute(i))return!1;if(r.isJSXAttribute(i)){let s=i.value;if(r.isJSXExpressionContainer(s)&&!r.isStringLiteral(s.expression)&&!r.isNumericLiteral(s.expression))return!1}}for(let i of e.children)if(r.isJSXElement(i)&&!ft(i,t)||r.isJSXExpressionContainer(i))return!1;return!0}function wn(e,t){let n=`_$static${t.staticCounter++}`,o=Q(e,t,!1);return t.staticElements.set(n,o),r.identifier(n)}function Nn(e,t){let n=e.openingElement.name.name;return n==="Show"?kn(e,t):n==="For"?Ln(e,t):null}function kn(e,t){return null}function Ln(e,t){return null}export{Rr as default};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var j=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var le=Object.prototype.hasOwnProperty;var ae=(e,t)=>{for(var n in t)j(e,n,{get:t[n],enumerable:!0})},ce=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of se(t))!le.call(e,i)&&i!==n&&j(e,i,{get:()=>t[i],enumerable:!(r=ie(t,i))||r.enumerable});return e};var pe=e=>ce(j({},"__esModule",{value:!0}),e);var Je={};ae(Je,{BUILTIN_COMPONENTS:()=>me,CORE_CONTROL_FLOW:()=>I,DEFAULT_GLOBALS_PATH:()=>J,DOM_CONTROL_FLOW:()=>k,RESERVED_COMPONENTS:()=>O,ROUTER_COMPONENTS:()=>v,RUNTIME_CONTRACT_V1:()=>T,RUNTIME_CONTRACT_V2:()=>Ee,backends:()=>He,builtinComponentMap:()=>b,builtinComponents:()=>fe,componentGlobals:()=>_,createComponentResolver:()=>P,defaultOptions:()=>Se,imperativeBackend:()=>A,resolveComponentSources:()=>Ce,routerComponents:()=>ge,walk:()=>B,writeComponentGlobals:()=>$e});module.exports=pe(Je);var ue=e=>"components"in e;function W(e,t){return e.replace(/\$(\d+)/g,(n,r)=>t[Number(r)]??n)}function de(e,t){return typeof t=="string"?{module:t,export:e}:t}function P(e=[]){let t=new Map,n=[],r=[];for(let a of e){if(!ue(a)){r.push(a);continue}for(let[o,p]of Object.entries(a.components)){let s=de(o,p),u=t.get(o);if(u&&u.module!==s.module){let c=n.find(m=>m.name===o);c?c.modules.push(s.module):n.push({name:o,modules:[u.module,s.module]});continue}t.set(o,s)}}let i=new Map;return{resolve:a=>{if(i.has(a))return i.get(a);let o=t.get(a);if(!o)for(let p of r){let s=a.match(new RegExp(p.match.source,p.match.flags.replace("g","")));if(s){o={module:W(p.module,s),export:p.export?W(p.export,s):a};break}}return i.set(a,o),o},names:()=>[...t.keys()],conflicts:()=>n}}var k=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],I=["Suspense","SuspenseList","Await"],v=["Router","Outlet","Redirect","Link"],me=[...k,...I,...v],O=new Set([...k,...I]);function b(e={}){let{controlFlowModule:t="@fluixi/dom",coreModule:n="@fluixi/core",routerModule:r="@fluixi/core/router-next"}=e,i={};for(let l of k)i[l]=t;for(let l of I)i[l]=n;for(let l of v)i[l]=r;return i}function fe(e={}){return{components:b(e)}}function ge(e){let t=e??"@fluixi/core/router-next";return{components:Object.fromEntries(v.map(n=>[n,t]))}}var Re=new Set(["Text","Image","Option","Audio","Comment","Range","Selection","Notification","Event","Document","Element","Node","Screen","Window","Location","History","Storage","Response","Request","Headers"]);function he(e){if(e.startsWith(".")||e.startsWith("/")||/^[~@]\//.test(e))return;let t=e.split("/");return e.startsWith("@")?t.slice(0,2).join("/"):t[0]}function F(e){return`_${e.replace(/[^A-Za-z0-9]/g,"_")}`}function _(e,t={}){let{available:n,builtins:r=!0,generator:i="@fluixi/compiler",specifier:l=d=>d}=t,a=[...e];r&&a.push({components:b()});let o=P(a),p=n?new Set(n):void 0,s=[],u=[],c=[],m=new Map;for(let d of[...o.names()].sort()){let g=o.resolve(d);if(!g)continue;let y=he(g.module);Re.has(d)?u.push(d):p&&y&&!p.has(y)?c.push(d):(s.push(d),m.set(d,g))}let x=[...new Set(s.map(d=>m.get(d).module))].sort().map(d=>`import * as ${F(d)} from '${l(d)}';`),E=s.map(d=>{let g=m.get(d),y=F(g.module);return g.export==="default"?` const ${d}: typeof ${y}.default;`:` export import ${d} = ${y}.${g.export};`}),re=u.length>0?`//
|
|
2
|
+
// Import these explicitly — lib.dom already declares the name, so an ambient
|
|
3
|
+
// declaration cannot win:
|
|
4
|
+
`+u.map(d=>{let g=o.resolve(d)?.module;return`// import { ${d} } from '${g?l(g):""}';
|
|
5
|
+
`}).join(""):"",N=e.filter(d=>"match"in d).length,oe=N>0?`//
|
|
6
|
+
// ${N} pattern rule${N===1?"":"s"} cannot be declared:
|
|
7
|
+
// a pattern matches unboundedly many names, so there is no list to emit. Those
|
|
8
|
+
// tags still resolve at build time; declare them by hand if the editor needs them.
|
|
9
|
+
`:"";return{source:`// GENERATED by ${i} — do not edit.
|
|
10
|
+
//
|
|
11
|
+
// The components \`resolve\` supplies without an import. This describes what the
|
|
12
|
+
// compiler already does; it does not enable it.
|
|
13
|
+
`+re+oe+(x.length>0?`
|
|
14
|
+
${x.join(`
|
|
15
|
+
`)}
|
|
16
|
+
`:`
|
|
17
|
+
`)+`
|
|
18
|
+
declare global {
|
|
19
|
+
${E.join(`
|
|
20
|
+
`)}
|
|
21
|
+
}
|
|
22
|
+
`,declared:s,shadowedByDom:u,unavailable:c,patternRules:N}}var R=require("node:fs"),f=require("node:path");var xe="GENERATED by @fluixi/compiler",J="fluixi.d.ts";function ve(e,t){let n;try{let i=(0,R.readFileSync)((0,f.resolve)(e,"tsconfig.json"),"utf8");n=JSON.parse(i.replace(/^\s*\/\/.*$/gm,""))}catch{return}if(n.extends!==void 0)return;if(!Array.isArray(n.include))return!0;let r=z(e,t);return n.include.some(i=>{if(typeof i!="string")return!1;let l=i.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\//g,"(?:.*/)?").replace(/\*/g,"[^/]*");return new RegExp(`^${l}(?:/.*)?$`).test(r)})}function z(e,t){return(0,f.relative)(e,t).split(f.sep).join("/")}function be(e,t,n){if(!e.startsWith("/"))return e;let r=(0,f.resolve)(n,e.slice(1)),i=(0,f.relative)(t,r).split(f.sep).join("/");return i.startsWith(".")||(i=`./${i}`),i.replace(/\.(tsx|ts|jsx|mts|cts)$/,".js")}function ye(e){try{let t=JSON.parse((0,R.readFileSync)((0,f.resolve)(e,"package.json"),"utf8"));return[...Object.keys(t.dependencies??{}),...Object.keys(t.devDependencies??{}),...Object.keys(t.peerDependencies??{})]}catch{return}}function $e(e,t){if(e.globals===!1)return{status:"skipped",reason:"disabled"};let n=e.resolve??[],r=(0,f.resolve)(t,e.globals??J),i;try{i=(0,R.readFileSync)(r,"utf8")}catch{i=void 0}if(i!==void 0&&!i.includes(xe))return{status:"skipped",reason:"foreign-file",path:r};let{source:l,declared:a}=_(n,{available:ye(t),specifier:o=>be(o,(0,f.dirname)(r),t)});return i===l?{status:"unchanged",path:r,declared:a.length,warning:H(t,r)}:((0,R.mkdirSync)((0,f.dirname)(r),{recursive:!0}),(0,R.writeFileSync)(r,l),{status:"written",path:r,declared:a.length,warning:H(t,r)})}function H(e,t){if(ve(e,t)!==!1)return;let n=z(e,t);return`[fluixi] ${n} is not covered by "include" in tsconfig.json, so TypeScript will ignore it and every resolved component stays "Cannot find name". Add "${n}" to "include".`}var L={kind:"eager"};function Ce(e,t={}){let{resolver:n,isBound:r,modules:i,strategyFor:l}=t,a=b(i),o=new Map,p=new Set,s=c=>{let{name:m}=c;if(!m||m.includes(".")||r?.(m))return;let h=u(m);if(!h){p.add(m);return}let x=h.origin==="builtin"&&O.has(m)?L:l?.(c)??L;c.source={...h,loading:x},o.set(m,c.source)},u=c=>{if(O.has(c))return{module:a[c],export:c,origin:"builtin"};let m=n?.resolve(c);if(m)return{module:m.module,export:m.export,origin:"rule"};if(v.includes(c))return{module:a[c],export:c,origin:"builtin"}};return B(e,c=>{c.kind==="component"&&s(c)}),{resolved:o,unresolved:[...p]}}function B(e,t){let n=Array.isArray(e)?e:[e];for(let r of n){t(r);let i=r.children;i&&B(i,t)}}var Se={backend:"imperative",generate:"dom",moduleName:"@fluixi/dom",delegateEvents:!0,hydratable:!1,sourceMaps:!0,dev:!1};var T={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},Ee={version:2,module:"@fluixi/dom",symbols:[...T.symbols,"template","cloneTemplate","walk"]};var Ne=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),U={className:"class",htmlFor:"for"},ke=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),Ie=new Set(["script","style","textarea","title"]);function D(e){return Ie.has(e)}function V(e){return U[e]??e}function $(e){return e.kind!=="attr"||e.expr!==void 0||e.name.includes(":")?!1:!ke.has(e.name)}function G(e){if(!e.static||D(e.tag))return!1;for(let t of e.props)if(!$(t))return!1;for(let t of e.children)if(t.kind!=="text"&&!(t.kind==="element"&&G(t)))return!1;return!0}function C(e){let t=e.props.map(Te).filter(Boolean).join(""),n=`<${e.tag}${t}>`;return Ne.has(e.tag)?n:`${n}${e.children.map(Oe).join("")}</${e.tag}>`}function Oe(e){if(e.kind==="text")return Me(e.value);if(e.kind!=="element")throw new Error(`serializeStatic: unexpected ${e.kind}`);return C(e)}function Te(e){let t=U[e.name]??e.name,n=e.literal;return n===!0||n===void 0?` ${t}`:n===!1||n===null?"":` ${t}="${we(String(n))}"`}function we(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Me(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var Ae="<!--fx-->",je="<!--fx/-->";function M(e){return e.kind==="expr"||e.kind==="component"||e.kind==="control"}function Pe(e){return e.kind==="text"||e.kind==="element"&&q(e)}function q(e){return e.svg||D(e.tag)||!e.props.every(t=>$(t))?!1:e.children.every(t=>Pe(t)||M(t))}function w(e){if(M(e))return!0;let t=e.children;return t?t.some(w):!1}function K(e){for(let t=0;t<e.children.length;t++){let n=e.children[t];if(n.kind==="text"&&(n.value===""||e.children[t+1]?.kind==="text"))return!1}return e.children.every(t=>t.kind!=="element"||K(t))}function Z(e){if(!q(e)||!K(e)||!e.children.some(w))return null;let t=[],n=[],r=0,i=a=>{let o=`_n$${r++}`;return t.push({ref:o,expr:a}),o};return l(e,"_el$"),{html:_e(e),tag:e.tag,steps:t,holes:n};function l(a,o){let p=-1;a.children.forEach((u,c)=>{w(u)&&(p=c)});let s=null;for(let u=0;u<=p;u++){let c=a.children[u],m=s?`${s}.nextSibling`:`${o}.firstChild`;if(M(c)){let x=i(m),E=i(`holeEnd(${x})`);n.push({parentRef:o,startRef:x,endRef:E,node:c}),s=E;continue}let h=i(m);c.kind==="element"&&w(c)&&l(c,h),s=h}}}function _e(e){return C(Y(e)).split(X).join(Ae+je)}function Y(e){return{...e,children:e.children.map(t=>M(t)?{kind:"text",value:X}:t.kind==="element"?Y(t):t)}}var X="\0fx-hole\0";var Le={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function Be(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function ee(e){return Be(e)?e:JSON.stringify(e)}function De(e){return e.expr!==void 0?e.reactive?`() => (${e.expr})`:`(${e.expr})`:JSON.stringify(e.literal??!0)}function Ge(e){return e.expr!==void 0?`(${e.expr})`:JSON.stringify(e.literal??!0)}function We(e,t,n){let r=e.filter(o=>o.kind==="spread"),l=e.filter(o=>o.kind!=="spread").map(o=>`${ee(o.name)}: ${De(o)}`);t!=null&&l.push(`children: ${t}`);let a=`{ ${l.join(", ")} }`;return r.length>0?(n.add("mergeProps"),`mergeProps(${r.map(o=>o.expr).join(", ")}, ${a})`):a}function te(e,t,n){return e.length===1?S(e[0],t,n):`[${e.map(r=>S(r,t,n)).join(", ")}]`}function Q(e,t,n,r,i){r.add("createMemo"),r.add("createComponent");let l=t.filter(s=>s.kind==="spread"),o=t.filter(s=>s.kind!=="spread").map(s=>`get ${ee(s.name)}() { return ${Ge(s)}; }`);n.length>0&&o.push(`get children() { return ${te(n,r,i)}; }`);let p=`{ ${o.join(", ")} }`;return l.length>0&&(r.add("mergeProps"),p=`mergeProps(${l.map(s=>s.expr).join(", ")}, ${p})`),`createMemo(() => createComponent(${e}, ${p}))`}function Fe(e,t){let n=V(t.name),r=t.literal;return r===!0||r===void 0?`${e}.setAttribute(${JSON.stringify(n)}, "");`:r===!1||r===null?"":`${e}.setAttribute(${JSON.stringify(n)}, ${JSON.stringify(String(r))});`}var ne=!1;function S(e,t,n){switch(e.kind){case"text":return JSON.stringify(e.value);case"expr":return e.reactive?`() => (${e.code})`:`(${e.code})`;case"fragment":return e.children.length===0?"null":te(e.children,t,n);case"component":return Q(e.name,e.props,e.children,t,n);case"control":{let r=Le[e.control]??e.control;return t.add(r),Q(r,e.props,e.children,t,n)}case"element":{if(n&&e.static&&!e.svg&&G(e)){t.add("templateNode");let o=`_tmpl$${n.length}`;return n.push({id:o,html:C(e),tag:e.tag,svg:!1}),`templateNode(${o}, ${JSON.stringify(e.tag)})`}if(n&&ne){let o=Z(e);if(o){t.add("templateNode"),t.add("insert"),t.add("holeEnd"),t.add("holeContent"),t.add("holeScope");let p=`_tmpl$${n.length}`;n.push({id:p,html:o.html,tag:o.tag,svg:!1});let s=[`const _el$ = templateNode(${p}, ${JSON.stringify(o.tag)}, true);`];for(let u of o.steps)s.push(`const ${u.ref} = ${u.expr};`);for(let u of o.holes)s.push(`insert(${u.parentRef}, holeScope(${u.startRef}, () => (${S(u.node,t,n)})), ${u.endRef}, holeContent(${u.startRef}, ${u.endRef}));`);return s.push("return _el$;"),`(() => { ${s.join(" ")} })()`}}t.add("createNativeElement");let r=JSON.stringify(e.tag),i="_el$",l=[],a=e.svg?`${r}, true`:r;if(l.push(`const ${i} = createNativeElement(${a});`),e.props.length>0)if(!e.svg&&e.props.every($))for(let o of e.props)l.push(Fe(i,o));else{t.add("spread");let o=e.svg?", isSVG: true":"";l.push(`spread({ element: ${i}, props: ${We(e.props,null,t)}${o} });`)}for(let o of e.children){t.add("insert");let p=S(o,t,n),s=o.kind==="expr"&&o.reactive||o.kind==="component"||o.kind==="control";l.push(s?`insert(${i}, ${p}, null);`:`insert(${i}, ${p});`)}return l.push(`return ${i};`),`(() => { ${l.join(" ")} })()`}}}var A={name:"imperative",contract:T,emit(e,t){let n=new Set,r=t?.templateClone!==!1?[]:void 0;return ne=t?.partialTemplates===!0,{code:S(e,n,r),imports:Array.from(n),templates:r}}};var He={imperative:A};
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export * from './ir/nodes.js';
|
|
11
11
|
export * from './resolve/component-resolver.js';
|
|
12
|
+
export * from './resolve/component-globals.js';
|
|
13
|
+
export * from './resolve/write-globals.js';
|
|
12
14
|
export * from './resolve/builtins.js';
|
|
13
15
|
export * from './resolve/resolve-ir.js';
|
|
14
16
|
export * from './options.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,cAAc,eAAe,CAAC;AAG9B,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,iFAAiF;AACjF,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAEnD,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,cAAc,eAAe,CAAC;AAG9B,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,iFAAiF;AACjF,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAEnD,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,8 @@ export * from './ir/nodes.js';
|
|
|
11
11
|
// Component resolution — shared by the compiler, the TS plugin (to synthesise the
|
|
12
12
|
// import the author did not write) and codemods, so all three agree on one answer.
|
|
13
13
|
export * from './resolve/component-resolver.js';
|
|
14
|
+
export * from './resolve/component-globals.js';
|
|
15
|
+
export * from './resolve/write-globals.js';
|
|
14
16
|
export * from './resolve/builtins.js';
|
|
15
17
|
export * from './resolve/resolve-ir.js';
|
|
16
18
|
export * from './options.js';
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
var
|
|
1
|
+
var se=e=>"components"in e;function L(e,t){return e.replace(/\$(\d+)/g,(n,o)=>t[Number(o)]??n)}function le(e,t){return typeof t=="string"?{module:t,export:e}:t}function B(e=[]){let t=new Map,n=[],o=[];for(let a of e){if(!se(a)){o.push(a);continue}for(let[r,p]of Object.entries(a.components)){let s=le(r,p),u=t.get(r);if(u&&u.module!==s.module){let c=n.find(m=>m.name===r);c?c.modules.push(s.module):n.push({name:r,modules:[u.module,s.module]});continue}t.set(r,s)}}let i=new Map;return{resolve:a=>{if(i.has(a))return i.get(a);let r=t.get(a);if(!r)for(let p of o){let s=a.match(new RegExp(p.match.source,p.match.flags.replace("g","")));if(s){r={module:L(p.module,s),export:p.export?L(p.export,s):a};break}}return i.set(a,r),r},names:()=>[...t.keys()],conflicts:()=>n}}var I=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],O=["Suspense","SuspenseList","Await"],x=["Router","Outlet","Redirect","Link"],_e=[...I,...O,...x],T=new Set([...I,...O]);function v(e={}){let{controlFlowModule:t="@fluixi/dom",coreModule:n="@fluixi/core",routerModule:o="@fluixi/core/router-next"}=e,i={};for(let l of I)i[l]=t;for(let l of O)i[l]=n;for(let l of x)i[l]=o;return i}function Le(e={}){return{components:v(e)}}function Be(e){let t=e??"@fluixi/core/router-next";return{components:Object.fromEntries(x.map(n=>[n,t]))}}var ae=new Set(["Text","Image","Option","Audio","Comment","Range","Selection","Notification","Event","Document","Element","Node","Screen","Window","Location","History","Storage","Response","Request","Headers"]);function ce(e){if(e.startsWith(".")||e.startsWith("/")||/^[~@]\//.test(e))return;let t=e.split("/");return e.startsWith("@")?t.slice(0,2).join("/"):t[0]}function D(e){return`_${e.replace(/[^A-Za-z0-9]/g,"_")}`}function G(e,t={}){let{available:n,builtins:o=!0,generator:i="@fluixi/compiler",specifier:l=d=>d}=t,a=[...e];o&&a.push({components:v()});let r=B(a),p=n?new Set(n):void 0,s=[],u=[],c=[],m=new Map;for(let d of[...r.names()].sort()){let f=r.resolve(d);if(!f)continue;let h=ce(f.module);ae.has(d)?u.push(d):p&&h&&!p.has(h)?c.push(d):(s.push(d),m.set(d,f))}let R=[...new Set(s.map(d=>m.get(d).module))].sort().map(d=>`import * as ${D(d)} from '${l(d)}';`),C=s.map(d=>{let f=m.get(d),h=D(f.module);return f.export==="default"?` const ${d}: typeof ${h}.default;`:` export import ${d} = ${h}.${f.export};`}),oe=u.length>0?`//
|
|
2
|
+
// Import these explicitly — lib.dom already declares the name, so an ambient
|
|
3
|
+
// declaration cannot win:
|
|
4
|
+
`+u.map(d=>{let f=r.resolve(d)?.module;return`// import { ${d} } from '${f?l(f):""}';
|
|
5
|
+
`}).join(""):"",S=e.filter(d=>"match"in d).length,ie=S>0?`//
|
|
6
|
+
// ${S} pattern rule${S===1?"":"s"} cannot be declared:
|
|
7
|
+
// a pattern matches unboundedly many names, so there is no list to emit. Those
|
|
8
|
+
// tags still resolve at build time; declare them by hand if the editor needs them.
|
|
9
|
+
`:"";return{source:`// GENERATED by ${i} — do not edit.
|
|
10
|
+
//
|
|
11
|
+
// The components \`resolve\` supplies without an import. This describes what the
|
|
12
|
+
// compiler already does; it does not enable it.
|
|
13
|
+
`+oe+ie+(R.length>0?`
|
|
14
|
+
${R.join(`
|
|
15
|
+
`)}
|
|
16
|
+
`:`
|
|
17
|
+
`)+`
|
|
18
|
+
declare global {
|
|
19
|
+
${C.join(`
|
|
20
|
+
`)}
|
|
21
|
+
}
|
|
22
|
+
`,declared:s,shadowedByDom:u,unavailable:c,patternRules:S}}import{mkdirSync as pe,readFileSync as w,writeFileSync as ue}from"node:fs";import{dirname as W,relative as H,sep as J,resolve as E}from"node:path";var de="GENERATED by @fluixi/compiler",me="fluixi.d.ts";function fe(e,t){let n;try{let i=w(E(e,"tsconfig.json"),"utf8");n=JSON.parse(i.replace(/^\s*\/\/.*$/gm,""))}catch{return}if(n.extends!==void 0)return;if(!Array.isArray(n.include))return!0;let o=z(e,t);return n.include.some(i=>{if(typeof i!="string")return!1;let l=i.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\//g,"(?:.*/)?").replace(/\*/g,"[^/]*");return new RegExp(`^${l}(?:/.*)?$`).test(o)})}function z(e,t){return H(e,t).split(J).join("/")}function ge(e,t,n){if(!e.startsWith("/"))return e;let o=E(n,e.slice(1)),i=H(t,o).split(J).join("/");return i.startsWith(".")||(i=`./${i}`),i.replace(/\.(tsx|ts|jsx|mts|cts)$/,".js")}function Re(e){try{let t=JSON.parse(w(E(e,"package.json"),"utf8"));return[...Object.keys(t.dependencies??{}),...Object.keys(t.devDependencies??{}),...Object.keys(t.peerDependencies??{})]}catch{return}}function Ue(e,t){if(e.globals===!1)return{status:"skipped",reason:"disabled"};let n=e.resolve??[],o=E(t,e.globals??me),i;try{i=w(o,"utf8")}catch{i=void 0}if(i!==void 0&&!i.includes(de))return{status:"skipped",reason:"foreign-file",path:o};let{source:l,declared:a}=G(n,{available:Re(t),specifier:r=>ge(r,W(o),t)});return i===l?{status:"unchanged",path:o,declared:a.length,warning:F(t,o)}:(pe(W(o),{recursive:!0}),ue(o,l),{status:"written",path:o,declared:a.length,warning:F(t,o)})}function F(e,t){if(fe(e,t)!==!1)return;let n=z(e,t);return`[fluixi] ${n} is not covered by "include" in tsconfig.json, so TypeScript will ignore it and every resolved component stays "Cannot find name". Add "${n}" to "include".`}var M={kind:"eager"};function Ye(e,t={}){let{resolver:n,isBound:o,modules:i,strategyFor:l}=t,a=v(i),r=new Map,p=new Set,s=c=>{let{name:m}=c;if(!m||m.includes(".")||o?.(m))return;let g=u(m);if(!g){p.add(m);return}let R=g.origin==="builtin"&&T.has(m)?M:l?.(c)??M;c.source={...g,loading:R},r.set(m,c.source)},u=c=>{if(T.has(c))return{module:a[c],export:c,origin:"builtin"};let m=n?.resolve(c);if(m)return{module:m.module,export:m.export,origin:"rule"};if(x.includes(c))return{module:a[c],export:c,origin:"builtin"}};return U(e,c=>{c.kind==="component"&&s(c)}),{resolved:r,unresolved:[...p]}}function U(e,t){let n=Array.isArray(e)?e:[e];for(let o of n){t(o);let i=o.children;i&&U(i,t)}}var Qe={backend:"imperative",generate:"dom",moduleName:"@fluixi/dom",delegateEvents:!0,hydratable:!1,sourceMaps:!0,dev:!1};var A={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},tt={version:2,module:"@fluixi/dom",symbols:[...A.symbols,"template","cloneTemplate","walk"]};var he=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),V={className:"class",htmlFor:"for"},xe=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),ve=new Set(["script","style","textarea","title"]);function j(e){return ve.has(e)}function q(e){return V[e]??e}function b(e){return e.kind!=="attr"||e.expr!==void 0||e.name.includes(":")?!1:!xe.has(e.name)}function P(e){if(!e.static||j(e.tag))return!1;for(let t of e.props)if(!b(t))return!1;for(let t of e.children)if(t.kind!=="text"&&!(t.kind==="element"&&P(t)))return!1;return!0}function y(e){let t=e.props.map(ye).filter(Boolean).join(""),n=`<${e.tag}${t}>`;return he.has(e.tag)?n:`${n}${e.children.map(be).join("")}</${e.tag}>`}function be(e){if(e.kind==="text")return Ce(e.value);if(e.kind!=="element")throw new Error(`serializeStatic: unexpected ${e.kind}`);return y(e)}function ye(e){let t=V[e.name]??e.name,n=e.literal;return n===!0||n===void 0?` ${t}`:n===!1||n===null?"":` ${t}="${$e(String(n))}"`}function $e(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Ce(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var Se="<!--fx-->",Ee="<!--fx/-->";function k(e){return e.kind==="expr"||e.kind==="component"||e.kind==="control"}function Ne(e){return e.kind==="text"||e.kind==="element"&&K(e)}function K(e){return e.svg||j(e.tag)||!e.props.every(t=>b(t))?!1:e.children.every(t=>Ne(t)||k(t))}function N(e){if(k(e))return!0;let t=e.children;return t?t.some(N):!1}function Z(e){for(let t=0;t<e.children.length;t++){let n=e.children[t];if(n.kind==="text"&&(n.value===""||e.children[t+1]?.kind==="text"))return!1}return e.children.every(t=>t.kind!=="element"||Z(t))}function Y(e){if(!K(e)||!Z(e)||!e.children.some(N))return null;let t=[],n=[],o=0,i=a=>{let r=`_n$${o++}`;return t.push({ref:r,expr:a}),r};return l(e,"_el$"),{html:ke(e),tag:e.tag,steps:t,holes:n};function l(a,r){let p=-1;a.children.forEach((u,c)=>{N(u)&&(p=c)});let s=null;for(let u=0;u<=p;u++){let c=a.children[u],m=s?`${s}.nextSibling`:`${r}.firstChild`;if(k(c)){let R=i(m),C=i(`holeEnd(${R})`);n.push({parentRef:r,startRef:R,endRef:C,node:c}),s=C;continue}let g=i(m);c.kind==="element"&&N(c)&&l(c,g),s=g}}}function ke(e){return y(X(e)).split(Q).join(Se+Ee)}function X(e){return{...e,children:e.children.map(t=>k(t)?{kind:"text",value:Q}:t.kind==="element"?X(t):t)}}var Q="\0fx-hole\0";var Ie={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function Oe(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function te(e){return Oe(e)?e:JSON.stringify(e)}function Te(e){return e.expr!==void 0?e.reactive?`() => (${e.expr})`:`(${e.expr})`:JSON.stringify(e.literal??!0)}function we(e){return e.expr!==void 0?`(${e.expr})`:JSON.stringify(e.literal??!0)}function Me(e,t,n){let o=e.filter(r=>r.kind==="spread"),l=e.filter(r=>r.kind!=="spread").map(r=>`${te(r.name)}: ${Te(r)}`);t!=null&&l.push(`children: ${t}`);let a=`{ ${l.join(", ")} }`;return o.length>0?(n.add("mergeProps"),`mergeProps(${o.map(r=>r.expr).join(", ")}, ${a})`):a}function ne(e,t,n){return e.length===1?$(e[0],t,n):`[${e.map(o=>$(o,t,n)).join(", ")}]`}function ee(e,t,n,o,i){o.add("createMemo"),o.add("createComponent");let l=t.filter(s=>s.kind==="spread"),r=t.filter(s=>s.kind!=="spread").map(s=>`get ${te(s.name)}() { return ${we(s)}; }`);n.length>0&&r.push(`get children() { return ${ne(n,o,i)}; }`);let p=`{ ${r.join(", ")} }`;return l.length>0&&(o.add("mergeProps"),p=`mergeProps(${l.map(s=>s.expr).join(", ")}, ${p})`),`createMemo(() => createComponent(${e}, ${p}))`}function Ae(e,t){let n=q(t.name),o=t.literal;return o===!0||o===void 0?`${e}.setAttribute(${JSON.stringify(n)}, "");`:o===!1||o===null?"":`${e}.setAttribute(${JSON.stringify(n)}, ${JSON.stringify(String(o))});`}var re=!1;function $(e,t,n){switch(e.kind){case"text":return JSON.stringify(e.value);case"expr":return e.reactive?`() => (${e.code})`:`(${e.code})`;case"fragment":return e.children.length===0?"null":ne(e.children,t,n);case"component":return ee(e.name,e.props,e.children,t,n);case"control":{let o=Ie[e.control]??e.control;return t.add(o),ee(o,e.props,e.children,t,n)}case"element":{if(n&&e.static&&!e.svg&&P(e)){t.add("templateNode");let r=`_tmpl$${n.length}`;return n.push({id:r,html:y(e),tag:e.tag,svg:!1}),`templateNode(${r}, ${JSON.stringify(e.tag)})`}if(n&&re){let r=Y(e);if(r){t.add("templateNode"),t.add("insert"),t.add("holeEnd"),t.add("holeContent"),t.add("holeScope");let p=`_tmpl$${n.length}`;n.push({id:p,html:r.html,tag:r.tag,svg:!1});let s=[`const _el$ = templateNode(${p}, ${JSON.stringify(r.tag)}, true);`];for(let u of r.steps)s.push(`const ${u.ref} = ${u.expr};`);for(let u of r.holes)s.push(`insert(${u.parentRef}, holeScope(${u.startRef}, () => (${$(u.node,t,n)})), ${u.endRef}, holeContent(${u.startRef}, ${u.endRef}));`);return s.push("return _el$;"),`(() => { ${s.join(" ")} })()`}}t.add("createNativeElement");let o=JSON.stringify(e.tag),i="_el$",l=[],a=e.svg?`${o}, true`:o;if(l.push(`const ${i} = createNativeElement(${a});`),e.props.length>0)if(!e.svg&&e.props.every(b))for(let r of e.props)l.push(Ae(i,r));else{t.add("spread");let r=e.svg?", isSVG: true":"";l.push(`spread({ element: ${i}, props: ${Me(e.props,null,t)}${r} });`)}for(let r of e.children){t.add("insert");let p=$(r,t,n),s=r.kind==="expr"&&r.reactive||r.kind==="component"||r.kind==="control";l.push(s?`insert(${i}, ${p}, null);`:`insert(${i}, ${p});`)}return l.push(`return ${i};`),`(() => { ${l.join(" ")} })()`}}}var _={name:"imperative",contract:A,emit(e,t){let n=new Set,o=t?.templateClone!==!1?[]:void 0;return re=t?.partialTemplates===!0,{code:$(e,n,o),imports:Array.from(n),templates:o}}};var ut={imperative:_};export{_e as BUILTIN_COMPONENTS,O as CORE_CONTROL_FLOW,me as DEFAULT_GLOBALS_PATH,I as DOM_CONTROL_FLOW,T as RESERVED_COMPONENTS,x as ROUTER_COMPONENTS,A as RUNTIME_CONTRACT_V1,tt as RUNTIME_CONTRACT_V2,ut as backends,v as builtinComponentMap,Le as builtinComponents,G as componentGlobals,B as createComponentResolver,Qe as defaultOptions,_ as imperativeBackend,Ye as resolveComponentSources,Be as routerComponents,U as walk,Ue as writeComponentGlobals};
|