@fluixi/compiler 1.0.0-alpha.55 → 1.0.0-alpha.56

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.
@@ -1,2 +1,2 @@
1
- "use strict";var Se=Object.create;var $=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var ye=Object.getPrototypeOf,Je=Object.prototype.hasOwnProperty;var Ce=(e,n)=>{for(var r in n)$(e,r,{get:n[r],enumerable:!0})},U=(e,n,r,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of be(n))!Je.call(e,s)&&s!==r&&$(e,s,{get:()=>n[s],enumerable:!(i=he(n,s))||i.enumerable});return e};var Xe=(e,n,r)=>(r=e!=null?Se(ye(e)):{},U(n||!e||!e.__esModule?$(r,"default",{value:e,enumerable:!0}):r,e)),we=e=>U($({},"__esModule",{value:!0}),e);var at={};Ce(at,{default:()=>_e});module.exports=we(at);var se=require("@babel/helper-plugin-utils"),t=require("@babel/core");var p=require("@babel/core"),W=Xe(require("@babel/generator"),1);var B={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},ct={version:2,module:"@fluixi/dom",symbols:[...B.symbols,"template","cloneTemplate","walk"]};var ve={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function Fe(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function Q(e){return Fe(e)?e:JSON.stringify(e)}function je(e){return e.expr!==void 0?e.reactive?`() => (${e.expr})`:`(${e.expr})`:JSON.stringify(e.literal??!0)}function Ie(e){return e.expr!==void 0?`(${e.expr})`:JSON.stringify(e.literal??!0)}function Pe(e,n,r){let i=e.filter(l=>l.kind==="spread"),o=e.filter(l=>l.kind!=="spread").map(l=>`${Q(l.name)}: ${je(l)}`);n!=null&&o.push(`children: ${n}`);let a=`{ ${o.join(", ")} }`;return i.length>0?(r.add("mergeProps"),`mergeProps(${i.map(l=>l.expr).join(", ")}, ${a})`):a}function Y(e,n){return e.length===1?T(e[0],n):`[${e.map(r=>T(r,n)).join(", ")}]`}function K(e,n,r,i){i.add("createMemo"),i.add("createComponent");let s=n.filter(u=>u.kind==="spread"),a=n.filter(u=>u.kind!=="spread").map(u=>`get ${Q(u.name)}() { return ${Ie(u)}; }`);r.length>0&&a.push(`get children() { return ${Y(r,i)}; }`);let l=`{ ${a.join(", ")} }`;return s.length>0&&(i.add("mergeProps"),l=`mergeProps(${s.map(u=>u.expr).join(", ")}, ${l})`),`createMemo(() => createComponent(${e}, ${l}))`}function T(e,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":Y(e.children,n);case"component":return K(e.name,e.props,e.children,n);case"control":{let r=ve[e.control]??e.control;return n.add(r),K(r,e.props,e.children,n)}case"element":{n.add("createNativeElement");let r=JSON.stringify(e.tag),i="_el$",s=[],o=e.svg?`${r}, true`:r;if(s.push(`const ${i} = createNativeElement(${o});`),e.props.length>0){n.add("spread");let a=e.svg?", isSVG: true":"";s.push(`spread({ element: ${i}, props: ${Pe(e.props,null,n)}${a} });`)}for(let a of e.children){n.add("insert");let l=T(a,n),u=a.kind==="expr"&&a.reactive||a.kind==="component"||a.kind==="control";s.push(u?`insert(${i}, ${l}, null);`:`insert(${i}, ${l});`)}return s.push(`return ${i};`),`(() => { ${s.join(" ")} })()`}}}var D={name:"imperative",contract:B,emit(e,n){let r=new Set;return{code:T(e,r),imports:Array.from(r)}}};var Le=W.default.default??W.default;function te(e){return Le(e,{concise:!0}).code}function Me(e,n){let r=p.types.cloneNode(e,!0),i=p.types.file(p.types.program([p.types.expressionStatement(r)])),s=!1;return(0,p.traverse)(i,{"JSXElement|JSXFragment"(o){let a=o.node,{code:l,imports:u}=D.emit(A(a,n),{});for(let b of u)n.add(b);let E=p.template.expression(l,{placeholderPattern:!1})();o.replaceWith(E),o.skip(),s=!0}}),s?i.program.body[0].expression:e}function V(e,n){return te(Me(e,n))}var Ne=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),Ae=/^on[A-Z]/,Re=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function Oe(e){if(p.types.isJSXIdentifier(e)){let n=e.name[0]!==e.name[0].toLowerCase();return{tag:e.name,component:n}}return p.types.isJSXMemberExpression(e)?{tag:te(e),component:!0}:p.types.isJSXNamespacedName(e)?{tag:`${e.namespace.name}:${e.name.name}`,component:!1}:{tag:"div",component:!1}}function ke(e){return p.types.isJSXIdentifier(e)?e.name==="class"?"className":e.name:p.types.isJSXNamespacedName(e)?`${e.namespace.name}:${e.name.name}`:"unknown"}function F(e){return p.types.isCallExpression(e)||p.types.isOptionalCallExpression(e)?!0:p.types.isMemberExpression(e)||p.types.isOptionalMemberExpression(e)?!(!e.computed&&p.types.isIdentifier(e.property,{name:"children"})):p.types.isConditionalExpression(e)?F(e.test)||F(e.consequent)||F(e.alternate):p.types.isLogicalExpression(e)||p.types.isBinaryExpression(e)?F(e.left)||F(e.right):p.types.isTemplateLiteral(e)?e.expressions.some(n=>F(n)):!1}function $e(e,n){let r=ke(e.name),i=Ae.test(r),o={name:r,kind:i?"event":"attr"};i&&(o.event={name:r.slice(2).toLowerCase(),delegated:Re.has(r.slice(2).toLowerCase())});let a=e.value;if(a==null)return o.literal=!0,o;if(p.types.isStringLiteral(a))return o.literal=a.value,o;if(p.types.isJSXExpressionContainer(a)&&!p.types.isJSXEmptyExpression(a.expression)){let l=a.expression;return p.types.isStringLiteral(l)||p.types.isNumericLiteral(l)||p.types.isBooleanLiteral(l)?(o.literal=l.value,o):(o.expr=V(l,n),o.reactive=i?!1:F(l),(p.types.isJSXElement(l)||p.types.isJSXFragment(l))&&(o.jsxElement=!0),o)}return o.literal=!0,o}function Te(e,n){let r=[];for(let i of e)p.types.isJSXSpreadAttribute(i)?r.push({name:"",kind:"spread",expr:V(i.argument,n)}):p.types.isJSXAttribute(i)&&r.push($e(i,n));return r}function De(e){let n=e.split(/\r\n|\n|\r/),r=0;for(let s=0;s<n.length;s++)/[^ \t]/.test(n[s])&&(r=s);let i="";for(let s=0;s<n.length;s++){let o=n[s].replace(/\t/g," ");s!==0&&(o=o.replace(/^ +/,"")),s!==n.length-1&&(o=o.replace(/ +$/,"")),o&&(s!==r&&(o+=" "),i+=o)}return i}function ee(e,n){let r=[];for(let i of e)if(p.types.isJSXText(i)){let s=De(i.value);s&&r.push({kind:"text",value:s})}else if(p.types.isJSXExpressionContainer(i)){if(!p.types.isJSXEmptyExpression(i.expression)){let s=i.expression;r.push({kind:"expr",code:V(s,n),reactive:F(s)})}}else p.types.isJSXElement(i)||p.types.isJSXFragment(i)?r.push(A(i,n)):p.types.isJSXSpreadChild(i)&&r.push({kind:"expr",code:V(i.expression,n),reactive:!1});return r}function A(e,n=new Set){if(p.types.isJSXFragment(e))return{kind:"fragment",children:ee(e.children,n)};let{tag:r,component:i}=Oe(e.openingElement.name),s=Te(e.openingElement.attributes,n),o=ee(e.children,n);return i?{kind:"component",name:r,props:s,children:o}:{kind:"element",tag:r,svg:Ne.has(r),props:s,children:o,static:!1}}var oe=new Set(["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary","Suspense"]),Ve={Show:"when",For:"each",Index:"each",Match:"when"};var ae=/^on[A-Z]/,le=["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave"],_e=(0,se.declare)((e,n={})=>{e.assertVersion(7);let{runtime:r="automatic",importSource:i="@fluixi/jsx",pragma:s="jsx",pragmaFrag:o="Fragment",development:a=!1,detectReactivity:l=!0,useLitHTML:u=!0,hoistStatics:E=!0,delegateEvents:b=!0,delegatedEvents:m=le,optimizeControlFlow:y=!0,sourceMaps:I=!0,signalModule:J="@fluixi/dom",controlFlowModule:v="@fluixi/dom",reactiveModule:L="@fluixi/reactive/signal",autoShowTransform:H=!1,backend:X="imperative",codegen:M="inline"}=n,xe={backend:X,codegen:M,irImports:new Set,libModule:"@fluixi/core",hasJSX:!1,hasReactivity:!1,hasLitHTML:!1,needsSignalImport:!1,needsControlFlowImport:!1,needsCreateMemo:!1,controlFlowComponents:new Set,delegatedEvents:new Set,staticElements:new Map,staticCounter:0};return{name:"@fluixi/babel-plugin-jsx",manipulateOptions(f,c){c.plugins.push("jsx","typescript")},pre(f){Object.assign(f,xe)},visitor:{ImportDeclaration(f,c){f.node.source.value==="@fluixi/core/rx"&&(f.node.source=t.types.stringLiteral("@fluixi/reactive"))},Program:{enter(f,c){Object.assign(c,{hasJSX:!1,hasReactivity:!1,hasLitHTML:!1,needsSignalImport:!1,needsLitrxImport:!1,needsControlFlowImport:!1,needsCreateMemo:!1,controlFlowComponents:new Set,delegatedEvents:new Set,staticElements:new Map,autoShow:H,staticCounter:0,libModule:"@fluixi/core",backend:X,codegen:M,irImports:new Set,needsCreateNativeElement:!1,needsInsert:!1,needsSpread:!1,needsCreateComponent:!1,needsMergeProps:!1})},exit(f,c){let d=[];if(c.hasJSX||(c.needsSignalImport&&d.push(t.types.importDeclaration([t.types.importSpecifier(t.types.identifier("signal"),t.types.identifier("signal"))],t.types.stringLiteral(J))),c.needsLitrxImport&&!f.scope.hasBinding("litrx")&&d.push(t.types.importDeclaration([t.types.importSpecifier(t.types.identifier("litrx"),t.types.identifier("litrx"))],t.types.stringLiteral(c.libModule)))),c.hasJSX){if(X==="imperative"&&M==="ir"){let x=new Set(["Show","For","Index","Switch","Match","Dynamic","ErrorBoundary","Portal","Suspense"]),S=new Set(["createMemo","createEffect","createRenderEffect","createRoot","createSignal","onCleanup","batch","untrack"]),g=Array.from(c.irImports),w=h=>t.types.importSpecifier(t.types.identifier(h),t.types.identifier(h)),P=h=>!f.scope.hasBinding(h),z=g.filter(h=>S.has(h)&&P(h)),k=g.filter(h=>!x.has(h)&&!S.has(h)&&P(h)),N=g.filter(h=>x.has(h)&&P(h));z.length>0&&d.push(t.types.importDeclaration(z.map(w),t.types.stringLiteral(L))),k.length>0&&d.push(t.types.importDeclaration(k.map(w),t.types.stringLiteral(J))),N.length>0&&d.push(t.types.importDeclaration(N.map(w),t.types.stringLiteral(v)))}else if(X==="imperative"){let S=[[!!c.needsCreateNativeElement,"createNativeElement"],[!!c.needsSpread,"spread"],[!!c.needsInsert,"insert"],[!!c.needsCreateComponent,"createComponent"],[!!c.needsMergeProps,"mergeProps"]].filter(([g,w])=>g&&!f.scope.hasBinding(w)).map(([,g])=>t.types.importSpecifier(t.types.identifier(g),t.types.identifier(g)));S.length>0&&d.push(t.types.importDeclaration(S,t.types.stringLiteral(J)))}else if(r==="automatic"){let x=[t.types.importSpecifier(t.types.identifier("jsx"),t.types.identifier("jsx")),t.types.importSpecifier(t.types.identifier("jsxs"),t.types.identifier("jsxs")),t.types.importSpecifier(t.types.identifier("Fragment"),t.types.identifier("Fragment"))];a&&x.push(t.types.importSpecifier(t.types.identifier("jsxDEV"),t.types.identifier("jsxDEV"))),c.needsMergeProps&&x.push(t.types.importSpecifier(t.types.identifier("mergeProps"),t.types.identifier("mergeProps"))),d.push(t.types.importDeclaration(x,t.types.stringLiteral(i)))}if(c.needsCreateMemo&&!f.scope.hasBinding("createMemo")&&d.push(t.types.importDeclaration([t.types.importSpecifier(t.types.identifier("createMemo"),t.types.identifier("createMemo"))],t.types.stringLiteral(X==="imperative"?L:c.libModule??"@fluixi/core"))),c.needsControlFlowImport&&c.controlFlowComponents.size>0){let x=Array.from(c.controlFlowComponents).filter(S=>!f.scope.hasBinding(S));if(x.length>0){let S=x.map(g=>t.types.importSpecifier(t.types.identifier(g),t.types.identifier(g)));d.push(t.types.importDeclaration(S,t.types.stringLiteral(v)))}}if(b&&c.delegatedEvents.size>0){d.push(t.types.importDeclaration([t.types.importSpecifier(t.types.identifier("delegateEvents"),t.types.identifier("delegateEvents"))],t.types.stringLiteral(X==="imperative"?J:"@fluixi/jsx")));let x=t.types.arrayExpression(Array.from(c.delegatedEvents).map(g=>t.types.stringLiteral(g))),S=t.types.expressionStatement(t.types.callExpression(t.types.identifier("delegateEvents"),[x]));f.node.body.unshift(S)}if(E&&c.staticElements.size>0){let x=[];c.staticElements.forEach((S,g)=>{x.push(t.types.variableDeclaration("const",[t.types.variableDeclarator(t.types.identifier(g),S)]))}),f.node.body.unshift(...x)}}d.length>0&&f.node.body.unshift(...d)}},JSXElement(f,c){if(c.hasJSX=!0,X==="imperative"&&M==="ir"){f.replaceWith(re(f.node,c));return}let d=f.node,x=d.openingElement;if(t.types.isJSXIdentifier(x.name)&&oe.has(x.name.name)&&(c.controlFlowComponents.add(x.name.name),y)){let g=it(d,c);if(g){f.replaceWith(g);return}}if(E&&X!=="imperative"&&ge(d,c)){let g=rt(d,c);if(g){f.replaceWith(g);return}}let S=ze(d,c,{runtime:r,pragma:s,development:a,detectReactivity:l,useLitHTML:u,autoShow:H});f.replaceWith(S)},JSXFragment(f,c){if(c.hasJSX=!0,X==="imperative"&&M==="ir"){f.replaceWith(re(f.node,c));return}let d=_(f.node,c,{runtime:r,pragmaFrag:o,development:a});f.replaceWith(d)},CallExpression(f,c){if(!l)return;let d=f.node.callee;d.name,t.types.isIdentifier(d)&&(d.name==="createSignal"||d.name==="createStore"||d.name==="useContext"||d.name==="useLocation")&&(c.hasReactivity=!0)},JSXExpressionContainer(f){},TaggedTemplateExpression(f,c){let{tag:d,quasi:x}=f.node;f.get("quasi").get("expressions").forEach((S,g)=>{let w=S.node,P=x.quasis[g].value.raw;if(P.trim().endsWith("=")||P.match(/@[\w-]+$/))return;let k=!1,N=!1;if(t.types.isMemberExpression(w)){let h=w.property;t.types.isIdentifier(h)&&(h.name=h.name.replace("$",""),c.needsLitrxImport=!0,N=!0)}(k||N)&&S.replaceWith(t.types.callExpression(t.types.identifier("((window as any).Fluixi.litrx || litrx)"),[t.types.arrowFunctionExpression([],w)]))})}}}});function ze(e,n,r){let{runtime:i,pragma:s,development:o,autoShow:a=!0}=r;return i==="automatic"?O(e,n,o,a):Ge(e,n,s)}var Be=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]);function ne(e,n,r){return n.length>0?(r.needsMergeProps=!0,t.types.callExpression(t.types.identifier("mergeProps"),[...n,t.types.objectExpression(e)])):t.types.objectExpression(e)}function ce(e){return e.length===1?e[0]:t.types.arrayExpression(e)}function We(e,n,r,i,s,o){if(!n){let m=[...r];return s.length>0&&m.push(t.types.objectMethod("get",t.types.identifier("children"),[],t.types.blockStatement([t.types.returnStatement(ce(s))]))),pe(e,ne(m,i,o),o)}let a=e.value,l=Be.has(a),u=t.types.identifier("_el$"),E=[];o.needsCreateNativeElement=!0;let b=[e];if(l&&b.push(t.types.booleanLiteral(!0)),E.push(t.types.variableDeclaration("const",[t.types.variableDeclarator(u,t.types.callExpression(t.types.identifier("createNativeElement"),b))])),r.length>0||i.length>0){o.needsSpread=!0;let m=[t.types.objectProperty(t.types.identifier("element"),u),t.types.objectProperty(t.types.identifier("props"),ne(r,i,o))];l&&m.push(t.types.objectProperty(t.types.identifier("isSVG"),t.types.booleanLiteral(!0))),E.push(t.types.expressionStatement(t.types.callExpression(t.types.identifier("spread"),[t.types.objectExpression(m)])))}if(s.length>0){o.needsInsert=!0;for(let m of s){let I=t.types.isArrowFunctionExpression(m)||t.types.isFunctionExpression(m)||t.types.isCallExpression(m)&&t.types.isIdentifier(m.callee)&&m.callee.name==="createMemo"?[t.types.cloneNode(u),m,t.types.nullLiteral()]:[t.types.cloneNode(u),m];E.push(t.types.expressionStatement(t.types.callExpression(t.types.identifier("insert"),I)))}}return E.push(t.types.returnStatement(u)),t.types.callExpression(t.types.arrowFunctionExpression([],t.types.blockStatement(E)),[])}function pe(e,n,r){return r.backend==="imperative"?(r.needsCreateComponent=!0,r.needsCreateMemo=!0,t.types.callExpression(t.types.identifier("createMemo"),[t.types.arrowFunctionExpression([],t.types.callExpression(t.types.identifier("createComponent"),[e,n]))])):t.types.callExpression(t.types.identifier("jsx"),[e,n])}function re(e,n){let r=new Set,i=A(e,r),{code:s,imports:o}=D.emit(i,{});for(let a of o)r.add(a);for(let a of r)n.irImports.add(a);return t.template.expression(s,{placeholderPattern:!1})()}function qe(e){return e.map(n=>{if(t.types.isObjectProperty(n)){let r=n.key,i=n.computed,s=n.value;return t.types.objectMethod("get",r,[],t.types.blockStatement([t.types.returnStatement(s)]),i)}return n})}function O(e,n,r,i=!0){let s=e.openingElement,o=e.children,a=ue(s.name),l=t.types.isJSXIdentifier(s.name)&&/^[a-z]/.test(s.name.name),u=me(s.attributes,n,l,t.types.isJSXIdentifier(s.name)?s.name.name:""),E=u.props,b=u.spreads;l||(E=qe(E));let m=G(o,n,i);if(n.backend==="imperative")return We(a,l,E,b,m,n);if(m.length>0){let v=m.length===1?m[0]:t.types.arrayExpression(m);E.push(t.types.objectProperty(t.types.identifier("children"),v))}let y;if(b.length>0){let v=E.length>0?t.types.objectExpression(E):t.types.objectExpression([]);n.needsMergeProps=!0,y=t.types.callExpression(t.types.identifier("mergeProps"),[...b,v])}else y=t.types.objectExpression(E);let I=r?"jsxDEV":m.length>1?"jsxs":"jsx",J=[a,y];return r&&J.push(t.types.identifier("undefined"),t.types.booleanLiteral(!1),t.types.identifier("undefined"),t.types.identifier("undefined")),t.types.callExpression(t.types.identifier(I),J)}function Ge(e,n,r){let i=e.openingElement,s=e.children,o=ue(i.name),a=t.types.isJSXIdentifier(i.name)&&/^[a-z]/.test(i.name.name),{props:l,spreads:u}=me(i.attributes,n,a,t.types.isJSXIdentifier(i.name)?i.name.name:""),E=G(s,n,n.autoShow??!0),b;if(u.length>0){let y=l.length>0?t.types.objectExpression(l):t.types.objectExpression([]);n.needsMergeProps=!0,b=t.types.callExpression(t.types.identifier("mergeProps"),[...u,y])}else b=l.length>0?t.types.objectExpression(l):t.types.nullLiteral();let m=[o,b,...E];return t.types.callExpression(t.types.identifier(r),m)}function _(e,n,r){let{runtime:i,pragmaFrag:s,development:o}=r,a=G(e.children,n,n.autoShow??!0);if(n.backend==="imperative")return a.length===0?t.types.nullLiteral():ce(a);if(i==="automatic"){let l=o?"jsxDEV":a.length>1?"jsxs":"jsx",u=t.types.objectExpression([t.types.objectProperty(t.types.identifier("children"),a.length===1?a[0]:t.types.arrayExpression(a))]),E=[t.types.identifier("Fragment"),u];return o&&E.push(t.types.identifier("undefined"),t.types.booleanLiteral(!1),t.types.identifier("undefined"),t.types.identifier("undefined")),t.types.callExpression(t.types.identifier(l),E)}else return t.types.callExpression(t.types.identifier(s),a)}function ue(e){if(t.types.isJSXIdentifier(e)){let n=e.name;return n[0]===n[0].toLowerCase()?t.types.stringLiteral(n):t.types.identifier(n)}return t.types.isJSXMemberExpression(e)?fe(e):t.types.isJSXNamespacedName(e)?t.types.stringLiteral(`${e.namespace.name}:${e.name.name}`):t.types.stringLiteral("div")}function fe(e){let n;return t.types.isJSXIdentifier(e.object)?n=t.types.identifier(e.object.name):n=fe(e.object),t.types.memberExpression(n,t.types.identifier(e.property.name))}function Ze(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)}function me(e,n,r=!0,i=""){let s=[],o=[],a=Ve[i];for(let l of e)if(t.types.isJSXSpreadAttribute(l))o.push(l.argument);else if(t.types.isJSXAttribute(l)){let u=He(l.name),E=Ue(l.value,n,u,r);if(ae.test(u)){let L=u.slice(2).toLowerCase();le.includes(L)&&n.delegatedEvents.add(L)}let b=Ze(u)?t.types.identifier(u):t.types.stringLiteral(u),m=l.value,y=t.types.isJSXElement(m)||t.types.isJSXFragment(m)||t.types.isJSXExpressionContainer(m)&&(t.types.isJSXElement(m.expression)||t.types.isJSXFragment(m.expression)),I=!r&&u===a,J=t.types.isJSXExpressionContainer(m)&&!t.types.isJSXEmptyExpression(m.expression)?m.expression:null,v=!r&&!!J&&de(J,u);!r&&y||I||v?s.push(t.types.objectMethod("get",b,[],t.types.blockStatement([t.types.returnStatement(E)]))):s.push(t.types.objectProperty(b,E))}return{props:s,spreads:o}}function He(e){return t.types.isJSXIdentifier(e)?e.name==="class"?"className":e.name:t.types.isJSXNamespacedName(e)?`${e.namespace.name}:${e.name.name}`:"unknown"}function Ue(e,n,r="",i=!0){if(e===null)return t.types.booleanLiteral(!0);if(t.types.isStringLiteral(e))return e.value.includes(`
2
- `)?t.types.stringLiteral(e.value.replace(/\s+/g," ").trim()):e;if(t.types.isJSXExpressionContainer(e)){if(t.types.isJSXEmptyExpression(e.expression))return t.types.booleanLiteral(!0);let s=e.expression;return i&&de(s,r)?t.types.arrowFunctionExpression([],s):s}return t.types.isJSXElement(e)?O(e,n,!1,n.autoShow??!0):t.types.isJSXFragment(e)?_(e,n,{runtime:"automatic",pragmaFrag:"Fragment",development:!1}):t.types.booleanLiteral(!0)}function de(e,n){return ae.test(n)||n.startsWith("on:")||n==="ref"||n.startsWith("use:")||t.types.isArrowFunctionExpression(e)||t.types.isFunctionExpression(e)||t.types.isIdentifier(e)||t.types.isStringLiteral(e)||t.types.isNumericLiteral(e)||t.types.isBooleanLiteral(e)||t.types.isNullLiteral(e)?!1:!!(t.types.isCallExpression(e)||t.types.isOptionalCallExpression(e)||t.types.isMemberExpression(e)||t.types.isOptionalMemberExpression(e)||t.types.isLogicalExpression(e)||t.types.isConditionalExpression(e)||t.types.isBinaryExpression(e)||t.types.isUnaryExpression(e)||t.types.isTemplateLiteral(e)||t.types.isObjectExpression(e)||t.types.isArrayExpression(e))}function Ke(e){let n=e.split(/\r\n|\n|\r/),r=0;for(let s=0;s<n.length;s++)/[^ \t]/.test(n[s])&&(r=s);let i="";for(let s=0;s<n.length;s++){let o=n[s].replace(/\t/g," ");s!==0&&(o=o.replace(/^ +/,"")),s!==n.length-1&&(o=o.replace(/ +$/,"")),o&&(s!==r&&(o+=" "),i+=o)}return i}function G(e,n,r=!0){let i=[];for(let s of e)if(t.types.isJSXText(s)){let o=Ke(s.value);o&&i.push(t.types.stringLiteral(o))}else if(t.types.isJSXExpressionContainer(s)){if(!t.types.isJSXEmptyExpression(s.expression)){let o=s.expression;if(r){let a=Qe(o,n)??Ye(o,n);if(a){i.push(a);continue}}else{let a=et(o,n);if(a){i.push(a);continue}}nt(o)?i.push(t.types.arrowFunctionExpression([],o)):i.push(o)}}else t.types.isJSXElement(s)?i.push(O(s,n,!1,n.autoShow??!0)):t.types.isJSXFragment(s)?i.push(_(s,n,{runtime:"automatic",pragmaFrag:"Fragment",development:!1})):t.types.isJSXSpreadChild(s)&&i.push(s.expression);return i}function Qe(e,n){if(!t.types.isArrowFunctionExpression(e)||e.params.length!==0||e.async)return null;let r=e.body;if(t.types.isLogicalExpression(r)&&r.operator==="&&"){let i=C(r.right);if(i)return R(j(r.left),i,null,n)}if(t.types.isConditionalExpression(r)){let i=C(r.consequent);if(i){let s=Z(r.alternate,n);return R(j(r.test),i,s,n,!0)}}return null}function Ye(e,n){if(t.types.isLogicalExpression(e)&&e.operator==="&&"){let r=C(e.right);if(r)return R(j(e.left),r,null,n)}if(t.types.isConditionalExpression(e)){let r=C(e.consequent);if(r){let i=Z(e.alternate,n);return R(j(e.test),r,i,n)}}return null}function et(e,n){let r=t.types.isArrowFunctionExpression(e)&&e.params.length===0&&!e.async&&t.types.isExpression(e.body)?e.body:e;if(t.types.isConditionalExpression(r)){let i=j(r.test),o=C(r.consequent)??r.consequent,l=C(r.alternate)??r.alternate,u=t.types.conditionalExpression(i,o,l);return q(r.consequent)||q(r.alternate)?null:(n.needsCreateMemo=!0,t.types.callExpression(t.types.identifier("createMemo"),[t.types.arrowFunctionExpression([],u)]))}if(t.types.isLogicalExpression(r)&&r.operator==="&&"){let i=j(r.left),o=C(r.right)??r.right,a=t.types.logicalExpression("&&",i,o);return q(r.right)?null:(n.needsCreateMemo=!0,t.types.callExpression(t.types.identifier("createMemo"),[t.types.arrowFunctionExpression([],a)]))}return null}function Z(e,n){if(tt(e))return null;let r=C(e);if(r)return Ee(r,n);if(t.types.isConditionalExpression(e)){let i=e,s=C(i.consequent);if(s){let o=Z(i.alternate,n);return R(j(i.test),s,o,n)}}return e}function ie(e){return t.types.isJSXElement(e)||t.types.isJSXFragment(e)}function q(e){let n=C(e);if(!n||!t.types.isJSXElement(n))return!1;let r=n.openingElement.name;return t.types.isJSXIdentifier(r)&&oe.has(r.name)}function C(e){return ie(e)?e:t.types.isArrowFunctionExpression(e)&&e.params.length===0&&!e.async&&ie(e.body)?e.body:null}function j(e){return t.types.isArrowFunctionExpression(e)&&e.params.length===0&&!e.async&&t.types.isExpression(e.body)?e.body:e}function tt(e){return t.types.isNullLiteral(e)||t.types.isIdentifier(e)&&e.name==="undefined"||t.types.isBooleanLiteral(e)&&e.value===!1}function Ee(e,n){return t.types.isJSXElement(e)?O(e,n,!1,n.autoShow??!0):_(e,n,{runtime:"automatic",pragmaFrag:"Fragment",development:!1})}function R(e,n,r,i,s=!1){i.controlFlowComponents.add("Show"),i.needsControlFlowImport=!0;let o=Ee(n,i),a=[t.types.objectProperty(t.types.identifier("when"),t.types.arrowFunctionExpression([],e)),t.types.objectProperty(t.types.identifier("children"),o)];return r&&a.push(t.types.objectProperty(t.types.identifier("fallback"),r)),pe(t.types.identifier("Show"),t.types.objectExpression(a),i)}function nt(e){return t.types.isMemberExpression(e)||t.types.isOptionalMemberExpression(e)?!(!e.computed&&t.types.isIdentifier(e.property,{name:"children"})):t.types.isCallExpression(e)||t.types.isOptionalCallExpression(e)?!0:t.types.isIdentifier(e)?!1:!!(t.types.isLogicalExpression(e)||t.types.isConditionalExpression(e)||t.types.isBinaryExpression(e)||t.types.isUnaryExpression(e)||t.types.isTemplateLiteral(e))}function ge(e,n){let r=e.openingElement;if(!t.types.isJSXIdentifier(r.name))return!1;let i=r.name.name;if(i[0]!==i[0].toLowerCase())return!1;for(let s of r.attributes){if(t.types.isJSXSpreadAttribute(s))return!1;if(t.types.isJSXAttribute(s)){let o=s.value;if(t.types.isJSXExpressionContainer(o)&&!t.types.isStringLiteral(o.expression)&&!t.types.isNumericLiteral(o.expression))return!1}}for(let s of e.children)if(t.types.isJSXElement(s)&&!ge(s,n)||t.types.isJSXExpressionContainer(s))return!1;return!0}function rt(e,n){let r=`_$static${n.staticCounter++}`,i=O(e,n,!1);return n.staticElements.set(r,i),t.types.identifier(r)}function it(e,n){let r=e.openingElement.name.name;return r==="Show"?st(e,n):r==="For"?ot(e,n):null}function st(e,n){return null}function ot(e,n){return null}
1
+ "use strict";var Me=Object.create;var V=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Oe=Object.getPrototypeOf,De=Object.prototype.hasOwnProperty;var Be=(e,t)=>{for(var r in t)V(e,r,{get:t[r],enumerable:!0})},se=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Te(t))!De.call(e,i)&&i!==r&&V(e,i,{get:()=>t[i],enumerable:!(s=$e(t,i))||s.enumerable});return e};var oe=(e,t,r)=>(r=e!=null?Me(Oe(e)):{},se(t||!e||!e.__esModule?V(r,"default",{value:e,enumerable:!0}):r,e)),_e=e=>se(V({},"__esModule",{value:!0}),e);var Xt={};Be(Xt,{default:()=>lt});module.exports=_e(Xt);var ve=require("@babel/helper-plugin-utils"),n=require("@babel/core");var u=require("@babel/core"),K=oe(require("@babel/generator"),1);var q={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},Pt={version:2,module:"@fluixi/dom",symbols:[...q.symbols,"template","cloneTemplate","walk"]};var Ve={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function ze(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function le(e){return ze(e)?e:JSON.stringify(e)}function We(e){return e.expr!==void 0?e.reactive?`() => (${e.expr})`:`(${e.expr})`:JSON.stringify(e.literal??!0)}function He(e){return e.expr!==void 0?`(${e.expr})`:JSON.stringify(e.literal??!0)}function Ge(e,t,r){let s=e.filter(c=>c.kind==="spread"),o=e.filter(c=>c.kind!=="spread").map(c=>`${le(c.name)}: ${We(c)}`);t!=null&&o.push(`children: ${t}`);let a=`{ ${o.join(", ")} }`;return s.length>0?(r.add("mergeProps"),`mergeProps(${s.map(c=>c.expr).join(", ")}, ${a})`):a}function ce(e,t){return e.length===1?z(e[0],t):`[${e.map(r=>z(r,t)).join(", ")}]`}function ae(e,t,r,s){s.add("createMemo"),s.add("createComponent");let i=t.filter(l=>l.kind==="spread"),a=t.filter(l=>l.kind!=="spread").map(l=>`get ${le(l.name)}() { return ${He(l)}; }`);r.length>0&&a.push(`get children() { return ${ce(r,s)}; }`);let c=`{ ${a.join(", ")} }`;return i.length>0&&(s.add("mergeProps"),c=`mergeProps(${i.map(l=>l.expr).join(", ")}, ${c})`),`createMemo(() => createComponent(${e}, ${c}))`}function z(e,t){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":ce(e.children,t);case"component":return ae(e.name,e.props,e.children,t);case"control":{let r=Ve[e.control]??e.control;return t.add(r),ae(r,e.props,e.children,t)}case"element":{t.add("createNativeElement");let r=JSON.stringify(e.tag),s="_el$",i=[],o=e.svg?`${r}, true`:r;if(i.push(`const ${s} = createNativeElement(${o});`),e.props.length>0){t.add("spread");let a=e.svg?", isSVG: true":"";i.push(`spread({ element: ${s}, props: ${Ge(e.props,null,t)}${a} });`)}for(let a of e.children){t.add("insert");let c=z(a,t),l=a.kind==="expr"&&a.reactive||a.kind==="component"||a.kind==="control";i.push(l?`insert(${s}, ${c}, null);`:`insert(${s}, ${c});`)}return i.push(`return ${s};`),`(() => { ${i.join(" ")} })()`}}}var X={name:"imperative",contract:q,emit(e,t){let r=new Set;return{code:z(e,r),imports:Array.from(r)}}};var M=require("@babel/core"),U=oe(require("@babel/generator"),1),me=require("@fluixi/template-parser");var qe=U.default.default??U.default;function Ue(e){return qe(e,{concise:!0}).code}var pe=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function Ze(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function ue(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Z=class{constructor(t,r){this.holes=t;this.used=r}hole(t){return this.holes[t]??{node:M.types.identifier("undefined"),code:"undefined",reactive:!1}}emit(t){let{code:r,imports:s}=X.emit(t,{});for(let i of s)this.used.add(i);return r}lowerRoot(t){let r=this.lowerChildren(t);return r.length===1?r[0]:{kind:"fragment",children:r}}lowerChildren(t){let r=[];for(let s=0;s<t.length;s++){let i=t[s];if(i.kind==="Element"||i.kind==="Component"){let a=i.attributes.find(c=>c.kind==="IfDirective");if(a&&a.kind==="IfDirective"){let c=s+1;c<t.length&&this.isBlankText(t[c])&&c++;let l=t[c],p=l&&(l.kind==="Element"||l.kind==="Component")&&l.attributes.some(E=>E.kind==="ElseDirective");r.push(this.lowerIf(i,a.hole,p?l:null)),p&&(s=c);continue}if(i.attributes.some(c=>c.kind==="EachDirective")){r.push(this.lowerEach(i));continue}}let o=this.lowerNode(i);o&&r.push(o)}return r}isBlankText(t){return t.kind==="Text"&&!t.raw&&W(t.value)===""}lowerNode(t){switch(t.kind){case"Text":{if(t.raw)return{kind:"text",value:t.value};let r=W(t.value);return r?{kind:"text",value:r}:null}case"Comment":return null;case"Expression":{let r=this.hole(t.hole);return{kind:"expr",code:r.code,reactive:r.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 r=t.attributes.find(s=>s.kind==="Attribute"&&s.name==="is");if(t.tag==="component"&&r&&r.value&&r.value.kind==="hole"){let s=t.attributes.filter(o=>o!==r),i=this.lowerComponent({...t,kind:"Component",tag:"Dynamic",tagHole:null,attributes:s});return i.props.unshift({name:"component",kind:"attr",expr:`() => (${this.hole(r.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 r=t.tagHole!=null?this.hole(t.tagHole).code:t.tag,s=this.lowerAttributes(t.attributes),{slots:i,rest:o}=this.partitionSlots(t.children);for(let[a,c]of i){let l=c.length===1?c[0]:{kind:"fragment",children:c};s.push({name:a,kind:"attr",expr:this.emit(l),jsxElement:!0})}return{kind:"component",name:r,props:s,children:this.lowerChildren(o)}}partitionSlots(t){let r=new Map,s=[];for(let i of t){if(i.kind==="Element"||i.kind==="Component"){let o=i.attributes.find(a=>a.kind==="Attribute"&&a.name==="slot");if(o&&o.value&&o.value.kind==="static"){let a={...i,attributes:i.attributes.filter(p=>p!==o)},c=a.kind==="Element"?this.lowerElement(a):this.lowerComponent(a),l=r.get(o.value.value)??[];l.push(c),r.set(o.value.value,l);continue}}s.push(i)}return{slots:r,rest:s}}lowerIf(t,r,s){let i=this.hole(r),o=[{name:"when",kind:"attr",expr:i.code,reactive:i.reactive}];if(s){let c=this.stripAndLower(s,l=>l.kind==="ElseDirective");o.push({name:"fallback",kind:"attr",expr:this.emit(c),jsxElement:!0})}let a=this.stripAndLower(t,c=>c.kind==="IfDirective");return{kind:"component",name:"Show",props:o,children:[a]}}lowerEach(t){let r=t.attributes.find(l=>l.kind==="EachDirective");if(!r||r.kind!=="EachDirective")return this.lowerNode(t);let s=this.hole(r.hole),i=[{name:"each",kind:"attr",expr:s.code,reactive:s.reactive}];if(r.key){let l="static"in r.key?`(item) => item[${JSON.stringify(r.key.static)}]`:this.hole(r.key.hole).code;i.push({name:"by",kind:"attr",expr:l})}let o=this.itemArrow(t),a;if(o){let l=o.body,p={kind:"expr",code:R(l,this.used),reactive:y(l)},E=this.rebuildWithChildren(t,[p]);a=`(${o.params.map(f=>Ue(f)).join(", ")}) => (${this.emit(E)})`}else{let l=this.stripAndLower(t,p=>p.kind==="EachDirective");a=`() => (${this.emit(l)})`}return{kind:"component",name:"For",props:i,children:[{kind:"expr",code:a,reactive:!1}]}}itemArrow(t){let r=t.children.filter(i=>!this.isBlankText(i));if(r.length!==1||r[0].kind!=="Expression")return null;let s=this.hole(r[0].hole).node;return M.types.isArrowFunctionExpression(s)&&!M.types.isBlockStatement(s.body)?s:null}stripAndLower(t,r){let s={...t,attributes:t.attributes.filter(i=>!r(i))};return s.kind==="Element"?this.lowerElement(s):this.lowerComponent(s)}rebuildWithChildren(t,r){let s=this.lowerAttributes(t.attributes.filter(i=>i.kind!=="EachDirective"));return t.kind==="Element"?{kind:"element",tag:t.tag,svg:t.namespace==="svg",props:s,children:r,static:!1}:{kind:"component",name:t.tag,props:s,children:r}}lowerAttributes(t){let r=[],s=[],i=!1,o=[],a=!1,c=[];for(let l of t)switch(l.kind){case"IfDirective":case"EachDirective":case"ElseDirective":break;case"Attribute":r.push(this.plainAttr(l));break;case"PropertyBinding":r.push({name:l.name,kind:"prop",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"EventBinding":r.push(this.eventProp(l));break;case"RefBinding":r.push({name:"ref",kind:"ref",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"Spread":r.push({name:"",kind:"spread",expr:this.hole(l.hole).code});break;case"ClassDirective":{let p=this.hole(l.hole);s.push(`${JSON.stringify(l.name)}: ${p.code}`),i=i||p.reactive;break}case"StyleDirective":{let p=this.hole(l.hole);o.push(`${JSON.stringify(l.name)}: ${p.code}`),a=a||p.reactive;break}case"BindDirective":r.push(...this.bindProps(l.name,this.hole(l.hole).code));break;case"UseDirective":{let p=l.name??(l.hole!=null?this.hole(l.hole).code:null);if(!p)break;c.push(l.name!=null&&l.hole!=null?`[${p}, () => (${this.hole(l.hole).code})]`:`[${p}]`);break}}return s.length>0&&r.push({name:"classList",kind:"attr",expr:`{ ${s.join(", ")} }`,reactive:i}),o.length>0&&r.push({name:"style",kind:"attr",expr:`{ ${o.join(", ")} }`,reactive:a}),c.length>0&&r.push({name:"use",kind:"attr",expr:`[${c.join(", ")}]`}),r}eventProp(t){let r=t.name.toLowerCase(),s=this.hole(t.hole).code;if(!(t.syntax==="colon"||t.modifiers.length>0))return{name:"on"+ue(t.name),kind:"event",event:{name:r,delegated:pe.has(r)},expr:s};let o=this.wrapHandler(s,t.modifiers),a=this.eventOptions(t.modifiers),c=a?`[${o}, ${a}]`:o;return{name:"on:"+r,kind:"attr",expr:c}}wrapHandler(t,r){let s=r.includes("self")?"if (e.target !== e.currentTarget) return; ":"",i=[];return r.includes("prevent")&&i.push("e.preventDefault();"),r.includes("stop")&&i.push("e.stopPropagation();"),!s&&i.length===0?t:`(e) => { ${s}${i.join(" ")} return (${t})(e); }`}eventOptions(t){let r=[];return t.includes("capture")&&r.push("capture: true"),t.includes("once")&&r.push("once: true"),t.includes("passive")&&r.push("passive: true"),r.length?`{ ${r.join(", ")} }`:null}bindProps(t,r){let s=t==="checked",i=s?"change":"input",o=s?"checked":"value",a=`(${r})`;return[{name:t,kind:"attr",expr:`${a}[0]()`,reactive:!0},{name:"on"+ue(i),kind:"event",event:{name:i,delegated:pe.has(i)},expr:`(e) => ${a}[1](e.target.${o})`}]}plainAttr(t){let r=t.value,s=t.name;t.name==="class"?s=r&&r.kind==="hole"&&M.types.isObjectExpression(this.hole(r.hole).node)?"classList":"className":t.name==="html"&&(s="innerHTML");let o={name:s,kind:"attr"};if(r==null)return o.literal=!0,o;if(r.kind==="static")return o.literal=r.value,o;if(r.kind==="hole"){let l=this.hole(r.hole);return o.expr=l.code,o.reactive=l.reactive,o}let a=!1,c=r.parts.map(l=>{if("text"in l)return Ze(l.text);let p=this.hole(l.hole);return a=a||p.reactive,"${"+p.code+"}"}).join("");return o.expr="`"+c+"`",o.reactive=a,o}};function de(e,t,r={}){let s=e.quasi,i=s.expressions.map(c=>{let l=c;return{node:l,code:R(l,t),reactive:y(l)}}),o=Ke(s),{root:a}=(0,me.parseTemplate)(o,{svg:r.svg});return new Z(i,t).lowerRoot(a.children)}function Ke(e){let t=[];return e.quasis.forEach((r,s)=>{let i=r.value.cooked??r.value.raw;if(t.push({kind:"static",text:i,start:r.start??0}),s<e.expressions.length){let o=e.expressions[s];t.push({kind:"hole",index:s,start:o.start??0,end:o.end??0})}}),t}function H(e,t=new Set,r={}){return de(e,t,r)}var Ye=K.default.default??K.default;function he(e){return Ye(e,{concise:!0}).code}function Qe(e,t){let r=u.types.cloneNode(e,!0),s=u.types.file(u.types.program([u.types.expressionStatement(r)])),i=!1,o=(a,c,l)=>{for(let p of l)t.add(p);a.replaceWith(u.template.expression(c,{placeholderPattern:!1,plugins:["typescript"]})()),a.skip(),i=!0};return(0,u.traverse)(s,{"JSXElement|JSXFragment"(a){let c=a.node,{code:l,imports:p}=X.emit($(c,t),{});o(a,l,p)},TaggedTemplateExpression(a){let c=a.node.tag;if(!u.types.isIdentifier(c)||c.name!=="html"&&c.name!=="svg")return;let l=H(a.node,t,{svg:c.name==="svg"}),{code:p,imports:E}=X.emit(l,{});o(a,p,E)}}),i?s.program.body[0].expression:e}function R(e,t){return he(Qe(e,t))}var et=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),tt=/^on[A-Z]/,nt=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function rt(e){if(u.types.isJSXIdentifier(e)){let t=e.name[0]!==e.name[0].toLowerCase();return{tag:e.name,component:t}}return u.types.isJSXMemberExpression(e)?{tag:he(e),component:!0}:u.types.isJSXNamespacedName(e)?{tag:`${e.namespace.name}:${e.name.name}`,component:!1}:{tag:"div",component:!1}}function it(e){return u.types.isJSXIdentifier(e)?e.name==="class"?"className":e.name:u.types.isJSXNamespacedName(e)?`${e.namespace.name}:${e.name.name}`:"unknown"}function y(e){return u.types.isCallExpression(e)||u.types.isOptionalCallExpression(e)?!0:u.types.isMemberExpression(e)||u.types.isOptionalMemberExpression(e)?!(!e.computed&&u.types.isIdentifier(e.property,{name:"children"})):u.types.isConditionalExpression(e)?y(e.test)||y(e.consequent)||y(e.alternate):u.types.isLogicalExpression(e)||u.types.isBinaryExpression(e)?y(e.left)||y(e.right):u.types.isTemplateLiteral(e)?e.expressions.some(t=>y(t)):u.types.isObjectExpression(e)?e.properties.some(t=>u.types.isObjectProperty(t)&&!t.computed&&y(t.value)):u.types.isArrayExpression(e)?e.elements.some(t=>t!=null&&!u.types.isSpreadElement(t)&&y(t)):!1}function st(e,t){let r=it(e.name),s=tt.test(r),i=s||r.startsWith("on:"),a={name:r,kind:s?"event":"attr"};s&&(a.event={name:r.slice(2).toLowerCase(),delegated:nt.has(r.slice(2).toLowerCase())});let c=e.value;if(c==null)return a.literal=!0,a;if(u.types.isStringLiteral(c))return a.literal=c.value,a;if(u.types.isJSXExpressionContainer(c)&&!u.types.isJSXEmptyExpression(c.expression)){let l=c.expression;return u.types.isStringLiteral(l)||u.types.isNumericLiteral(l)||u.types.isBooleanLiteral(l)?(a.literal=l.value,a):(a.expr=R(l,t),a.reactive=i?!1:y(l),(u.types.isJSXElement(l)||u.types.isJSXFragment(l))&&(a.jsxElement=!0),a)}return a.literal=!0,a}function fe(e,t){let r=e.value;return r==null?null:u.types.isStringLiteral(r)?JSON.stringify(r.value):u.types.isJSXExpressionContainer(r)&&!u.types.isJSXEmptyExpression(r.expression)?R(r.expression,t):null}function ot(e,t){let r=[],s=[];for(let i of e){if(u.types.isJSXSpreadAttribute(i)){r.push({name:"",kind:"spread",expr:R(i.argument,t)});continue}if(!u.types.isJSXAttribute(i))continue;let o=u.types.isJSXNamespacedName(i.name)?i.name.namespace.name:null;if(o==="use"){let a=i.name.name.name;t.add(a);let c=fe(i,t);s.push(c!=null?`[${a}, () => (${c})]`:`[${a}]`);continue}if(o==="oncapture"){let a=i.name.name.name.toLowerCase(),c=fe(i,t)??"undefined";r.push({name:"on:"+a,kind:"attr",expr:`[${c}, { capture: true }]`});continue}r.push(st(i,t))}return s.length>0&&r.push({name:"use",kind:"attr",expr:`[${s.join(", ")}]`}),r}function W(e){let t=e.split(/\r\n|\n|\r/),r=0;for(let i=0;i<t.length;i++)/[^ \t]/.test(t[i])&&(r=i);let s="";for(let i=0;i<t.length;i++){let o=t[i].replace(/\t/g," ");i!==0&&(o=o.replace(/^ +/,"")),i!==t.length-1&&(o=o.replace(/ +$/,"")),o&&(i!==r&&(o+=" "),s+=o)}return s}function ge(e,t){let r=[];for(let s of e)if(u.types.isJSXText(s)){let i=W(s.value);i&&r.push({kind:"text",value:i})}else if(u.types.isJSXExpressionContainer(s)){if(!u.types.isJSXEmptyExpression(s.expression)){let i=s.expression;r.push({kind:"expr",code:R(i,t),reactive:y(i)})}}else u.types.isJSXElement(s)||u.types.isJSXFragment(s)?r.push($(s,t)):u.types.isJSXSpreadChild(s)&&r.push({kind:"expr",code:R(s.expression,t),reactive:!1});return r}function $(e,t=new Set){if(u.types.isJSXFragment(e))return{kind:"fragment",children:ge(e.children,t)};let{tag:r,component:s}=rt(e.openingElement.name),i=ot(e.openingElement.attributes,t),o=ge(e.children,t);return s?{kind:"component",name:r,props:i,children:o}:{kind:"element",tag:r,svg:et.has(r),props:i,children:o,static:!1}}var Q=new Set(["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary","Suspense","Await"]),Ee=new Set(["Suspense","SuspenseList","Await"]),T=new Set(["Router","Outlet","Redirect","Link"]),at={Show:"when",For:"each",Index:"each",Match:"when"};var ye=/^on[A-Z]/,we=["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave"],lt=(0,ve.declare)((e,t={})=>{e.assertVersion(7);let{runtime:r="automatic",importSource:s="@fluixi/jsx",pragma:i="jsx",pragmaFrag:o="Fragment",development:a=!1,detectReactivity:c=!0,useLitHTML:l=!0,hoistStatics:p=!0,delegateEvents:E=!0,delegatedEvents:f=we,optimizeControlFlow:w=!0,sourceMaps:L=!0,signalModule:C="@fluixi/dom",controlFlowModule:J="@fluixi/dom",routerModule:B="@fluixi/core/router-next",reactiveModule:ne="@fluixi/reactive/signal",autoShowTransform:re=!1,backend:N="imperative",codegen:A="inline",format:ie="both",litTag:je="html"}=t,Fe=ie==="lit"||ie==="both",Ae={backend:N,codegen:A,irImports:new Set,libModule:"@fluixi/core",hasJSX:!1,hasReactivity:!1,hasLitHTML:!1,needsSignalImport:!1,needsControlFlowImport:!1,needsCreateMemo:!1,controlFlowComponents:new Set,delegatedEvents:new Set,staticElements:new Map,staticCounter:0};return{name:"@fluixi/babel-plugin-jsx",manipulateOptions(d,m){m.plugins.push("jsx","typescript")},pre(d){Object.assign(d,Ae)},visitor:{ImportDeclaration(d,m){d.node.source.value==="@fluixi/core/rx"&&(d.node.source=n.types.stringLiteral("@fluixi/reactive"))},Program:{enter(d,m){Object.assign(m,{hasJSX:!1,hasReactivity:!1,hasLitHTML:!1,hasLitIR:!1,needsSignalImport:!1,needsControlFlowImport:!1,needsCreateMemo:!1,controlFlowComponents:new Set,delegatedEvents:new Set,staticElements:new Map,autoShow:re,staticCounter:0,libModule:"@fluixi/core",backend:N,codegen:A,irImports:new Set,needsCreateNativeElement:!1,needsInsert:!1,needsSpread:!1,needsCreateComponent:!1,needsMergeProps:!1})},exit(d,m){let g=[];if(m.hasJSX||m.needsSignalImport&&g.push(n.types.importDeclaration([n.types.importSpecifier(n.types.identifier("signal"),n.types.identifier("signal"))],n.types.stringLiteral(C))),m.hasJSX||m.hasLitIR){if(m.irImports.size>0){let h=new Set(["Show","For","Index","Switch","Match","Dynamic","ErrorBoundary","Portal","Suspense"]),b=new Set(["createMemo","createEffect","createRenderEffect","createRoot","createSignal","onCleanup","batch","untrack"]),x=Array.from(m.irImports),I=S=>n.types.importSpecifier(n.types.identifier(S),n.types.identifier(S)),j=S=>!d.scope.hasBinding(S),F=x.filter(S=>b.has(S)&&j(S)),v=x.filter(S=>!h.has(S)&&!b.has(S)&&j(S)),_=x.filter(S=>h.has(S)&&j(S));F.length>0&&g.push(n.types.importDeclaration(F.map(I),n.types.stringLiteral(ne))),v.length>0&&g.push(n.types.importDeclaration(v.map(I),n.types.stringLiteral(C))),_.length>0&&g.push(n.types.importDeclaration(_.map(I),n.types.stringLiteral(J)))}if(m.hasJSX&&N==="imperative"&&A!=="ir"){let b=[[!!m.needsCreateNativeElement,"createNativeElement"],[!!m.needsSpread,"spread"],[!!m.needsInsert,"insert"],[!!m.needsCreateComponent,"createComponent"],[!!m.needsMergeProps,"mergeProps"]].filter(([x,I])=>x&&!d.scope.hasBinding(I)).map(([,x])=>n.types.importSpecifier(n.types.identifier(x),n.types.identifier(x)));b.length>0&&g.push(n.types.importDeclaration(b,n.types.stringLiteral(C)))}else if(m.hasJSX&&r==="automatic"){let h=[n.types.importSpecifier(n.types.identifier("jsx"),n.types.identifier("jsx")),n.types.importSpecifier(n.types.identifier("jsxs"),n.types.identifier("jsxs")),n.types.importSpecifier(n.types.identifier("Fragment"),n.types.identifier("Fragment"))];a&&h.push(n.types.importSpecifier(n.types.identifier("jsxDEV"),n.types.identifier("jsxDEV"))),m.needsMergeProps&&h.push(n.types.importSpecifier(n.types.identifier("mergeProps"),n.types.identifier("mergeProps"))),g.push(n.types.importDeclaration(h,n.types.stringLiteral(s)))}if(m.needsCreateMemo&&!d.scope.hasBinding("createMemo")&&g.push(n.types.importDeclaration([n.types.importSpecifier(n.types.identifier("createMemo"),n.types.identifier("createMemo"))],n.types.stringLiteral(N==="imperative"?ne:m.libModule??"@fluixi/core"))),m.needsControlFlowImport&&m.controlFlowComponents.size>0){let h=Array.from(m.controlFlowComponents).filter(v=>!d.scope.hasBinding(v)),b=m.libModule??"@fluixi/core",x=h.filter(v=>T.has(v)),I=h.filter(v=>Ee.has(v)),j=h.filter(v=>!Ee.has(v)&&!T.has(v)),F=(v,_)=>n.types.importDeclaration(v.map(S=>n.types.importSpecifier(n.types.identifier(S),n.types.identifier(S))),n.types.stringLiteral(_));j.length>0&&g.push(F(j,J)),I.length>0&&g.push(F(I,b)),x.length>0&&g.push(F(x,B))}if(E&&m.delegatedEvents.size>0){g.push(n.types.importDeclaration([n.types.importSpecifier(n.types.identifier("delegateEvents"),n.types.identifier("delegateEvents"))],n.types.stringLiteral(N==="imperative"?C:"@fluixi/jsx")));let h=n.types.arrayExpression(Array.from(m.delegatedEvents).map(x=>n.types.stringLiteral(x))),b=n.types.expressionStatement(n.types.callExpression(n.types.identifier("delegateEvents"),[h]));d.node.body.unshift(b)}if(p&&m.staticElements.size>0){let h=[];m.staticElements.forEach((b,x)=>{h.push(n.types.variableDeclaration("const",[n.types.variableDeclarator(n.types.identifier(x),b)]))}),d.node.body.unshift(...h)}}g.length>0&&d.node.body.unshift(...mt(g))}},JSXElement(d,m){if(m.hasJSX=!0,N==="imperative"&&A==="ir"){d.replaceWith(Se(d.node,m));return}let g=d.node,h=g.openingElement;if(n.types.isJSXIdentifier(h.name)&&T.has(h.name.name)&&(m.controlFlowComponents.add(h.name.name),m.needsControlFlowImport=!0),n.types.isJSXIdentifier(h.name)&&Q.has(h.name.name)&&(m.controlFlowComponents.add(h.name.name),w)){let x=Nt(g,m);if(x){d.replaceWith(x);return}}if(p&&N!=="imperative"&&Le(g,m)){let x=kt(g,m);if(x){d.replaceWith(x);return}}let b=ct(g,m,{runtime:r,pragma:i,development:a,detectReactivity:c,useLitHTML:l,autoShow:re});d.replaceWith(b)},JSXFragment(d,m){if(m.hasJSX=!0,N==="imperative"&&A==="ir"){d.replaceWith(Se(d.node,m));return}let g=G(d.node,m,{runtime:r,pragmaFrag:o,development:a});d.replaceWith(g)},CallExpression(d,m){if(!c)return;let g=d.node.callee;g.name,n.types.isIdentifier(g)&&(g.name==="createSignal"||g.name==="createStore"||g.name==="useContext"||g.name==="useLocation")&&(m.hasReactivity=!0)},JSXExpressionContainer(d){},TaggedTemplateExpression(d,m){if(Fe&&N==="imperative"&&n.types.isIdentifier(d.node.tag)&&(d.node.tag.name===je||d.node.tag.name==="svg")){d.replaceWith(dt(d.node,m));return}}}}});function ct(e,t,r){let{runtime:s,pragma:i,development:o,autoShow:a=!0}=r;return s==="automatic"?D(e,t,o,a):gt(e,t,i)}var pt=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]);function xe(e,t,r){return t.length>0?(r.needsMergeProps=!0,n.types.callExpression(n.types.identifier("mergeProps"),[...t,n.types.objectExpression(e)])):n.types.objectExpression(e)}function Ce(e){return e.length===1?e[0]:n.types.arrayExpression(e)}function ut(e,t,r,s,i,o){if(!t){let f=[...r];return i.length>0&&f.push(n.types.objectMethod("get",n.types.identifier("children"),[],n.types.blockStatement([n.types.returnStatement(Ce(i))]))),ke(e,xe(f,s,o),o)}let a=e.value,c=pt.has(a),l=n.types.identifier("_el$"),p=[];o.needsCreateNativeElement=!0;let E=[e];if(c&&E.push(n.types.booleanLiteral(!0)),p.push(n.types.variableDeclaration("const",[n.types.variableDeclarator(l,n.types.callExpression(n.types.identifier("createNativeElement"),E))])),r.length>0||s.length>0){o.needsSpread=!0;let f=[n.types.objectProperty(n.types.identifier("element"),l),n.types.objectProperty(n.types.identifier("props"),xe(r,s,o))];c&&f.push(n.types.objectProperty(n.types.identifier("isSVG"),n.types.booleanLiteral(!0))),p.push(n.types.expressionStatement(n.types.callExpression(n.types.identifier("spread"),[n.types.objectExpression(f)])))}if(i.length>0){o.needsInsert=!0;for(let f of i){let L=n.types.isArrowFunctionExpression(f)||n.types.isFunctionExpression(f)||n.types.isCallExpression(f)&&n.types.isIdentifier(f.callee)&&f.callee.name==="createMemo"?[n.types.cloneNode(l),f,n.types.nullLiteral()]:[n.types.cloneNode(l),f];p.push(n.types.expressionStatement(n.types.callExpression(n.types.identifier("insert"),L)))}}return p.push(n.types.returnStatement(l)),n.types.callExpression(n.types.arrowFunctionExpression([],n.types.blockStatement(p)),[])}function ke(e,t,r){return n.types.isIdentifier(e)&&T.has(e.name)&&(r.controlFlowComponents.add(e.name),r.needsControlFlowImport=!0),r.backend==="imperative"?(r.needsCreateComponent=!0,r.needsCreateMemo=!0,n.types.callExpression(n.types.identifier("createMemo"),[n.types.arrowFunctionExpression([],n.types.callExpression(n.types.identifier("createComponent"),[e,t]))])):n.types.callExpression(n.types.identifier("jsx"),[e,t])}function Se(e,t){let r=new Set,s=$(e,r),{code:i,imports:o}=X.emit(s,{});for(let a of o)r.add(a);for(let a of r)t.irImports.add(a);return n.template.expression(i,{placeholderPattern:!1,plugins:["typescript"]})()}function mt(e){let t=new Map,r=[];for(let s of e){let i=s.source.value;if(!s.specifiers.every(c=>n.types.isImportSpecifier(c))){r.push(s);continue}let a=t.get(i);if(!a){let c=new Set(s.specifiers.map(l=>l.local.name));t.set(i,{decl:s,names:c}),r.push(s);continue}for(let c of s.specifiers)a.names.has(c.local.name)||(a.names.add(c.local.name),a.decl.specifiers.push(c))}return r}function dt(e,t){let r=new Set,s=n.types.isIdentifier(e.tag)&&e.tag.name==="svg",i=H(e,r,{svg:s}),{code:o,imports:a}=X.emit(i,{});for(let c of a)r.add(c);for(let c of r)t.irImports.add(c);return Ne(i,t),t.hasLitIR=!0,n.template.expression(o,{placeholderPattern:!1,plugins:["typescript"]})()}function Ne(e,t){if(e.kind==="component"&&(Q.has(e.name)||T.has(e.name))&&(t.controlFlowComponents.add(e.name),t.needsControlFlowImport=!0),(e.kind==="element"||e.kind==="component"||e.kind==="control")&&"props"in e)for(let r of e.props)r.kind==="event"&&r.event?.delegated&&t.delegatedEvents.add(r.event.name);if("children"in e&&e.children)for(let r of e.children)Ne(r,t)}function ft(e){return e.map(t=>{if(n.types.isObjectProperty(t)){let r=t.key,s=t.computed,i=t.value;return n.types.objectMethod("get",r,[],n.types.blockStatement([n.types.returnStatement(i)]),s)}return t})}function D(e,t,r,s=!0){let i=e.openingElement,o=e.children,a=Je(i.name),c=n.types.isJSXIdentifier(i.name)&&/^[a-z]/.test(i.name.name),l=Xe(i.attributes,t,c,n.types.isJSXIdentifier(i.name)?i.name.name:""),p=l.props,E=l.spreads;c||(p=ft(p));let f=ee(o,t,s);if(t.backend==="imperative")return ut(a,c,p,E,f,t);if(f.length>0){let J=f.length===1?f[0]:n.types.arrayExpression(f);p.push(n.types.objectProperty(n.types.identifier("children"),J))}let w;if(E.length>0){let J=p.length>0?n.types.objectExpression(p):n.types.objectExpression([]);t.needsMergeProps=!0,w=n.types.callExpression(n.types.identifier("mergeProps"),[...E,J])}else w=n.types.objectExpression(p);let L=r?"jsxDEV":f.length>1?"jsxs":"jsx",C=[a,w];return r&&C.push(n.types.identifier("undefined"),n.types.booleanLiteral(!1),n.types.identifier("undefined"),n.types.identifier("undefined")),n.types.callExpression(n.types.identifier(L),C)}function gt(e,t,r){let s=e.openingElement,i=e.children,o=Je(s.name),a=n.types.isJSXIdentifier(s.name)&&/^[a-z]/.test(s.name.name),{props:c,spreads:l}=Xe(s.attributes,t,a,n.types.isJSXIdentifier(s.name)?s.name.name:""),p=ee(i,t,t.autoShow??!0),E;if(l.length>0){let w=c.length>0?n.types.objectExpression(c):n.types.objectExpression([]);t.needsMergeProps=!0,E=n.types.callExpression(n.types.identifier("mergeProps"),[...l,w])}else E=c.length>0?n.types.objectExpression(c):n.types.nullLiteral();let f=[o,E,...p];return n.types.callExpression(n.types.identifier(r),f)}function G(e,t,r){let{runtime:s,pragmaFrag:i,development:o}=r,a=ee(e.children,t,t.autoShow??!0);if(t.backend==="imperative")return a.length===0?n.types.nullLiteral():Ce(a);if(s==="automatic"){let c=o?"jsxDEV":a.length>1?"jsxs":"jsx",l=n.types.objectExpression([n.types.objectProperty(n.types.identifier("children"),a.length===1?a[0]:n.types.arrayExpression(a))]),p=[n.types.identifier("Fragment"),l];return o&&p.push(n.types.identifier("undefined"),n.types.booleanLiteral(!1),n.types.identifier("undefined"),n.types.identifier("undefined")),n.types.callExpression(n.types.identifier(c),p)}else return n.types.callExpression(n.types.identifier(i),a)}function Je(e){if(n.types.isJSXIdentifier(e)){let t=e.name;return t[0]===t[0].toLowerCase()?n.types.stringLiteral(t):n.types.identifier(t)}return n.types.isJSXMemberExpression(e)?Ie(e):n.types.isJSXNamespacedName(e)?n.types.stringLiteral(`${e.namespace.name}:${e.name.name}`):n.types.stringLiteral("div")}function Ie(e){let t;return n.types.isJSXIdentifier(e.object)?t=n.types.identifier(e.object.name):t=Ie(e.object),n.types.memberExpression(t,n.types.identifier(e.property.name))}function ht(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)}function Xe(e,t,r=!0,s=""){let i=[],o=[],a=at[s];for(let c of e)if(n.types.isJSXSpreadAttribute(c))o.push(c.argument);else if(n.types.isJSXAttribute(c)){let l=Et(c.name),p=xt(c.value,t,l,r);if(ye.test(l)){let B=l.slice(2).toLowerCase();we.includes(B)&&t.delegatedEvents.add(B)}let E=ht(l)?n.types.identifier(l):n.types.stringLiteral(l),f=c.value,w=n.types.isJSXElement(f)||n.types.isJSXFragment(f)||n.types.isJSXExpressionContainer(f)&&(n.types.isJSXElement(f.expression)||n.types.isJSXFragment(f.expression)),L=!r&&l===a,C=n.types.isJSXExpressionContainer(f)&&!n.types.isJSXEmptyExpression(f.expression)?f.expression:null,J=!r&&!!C&&Re(C,l);!r&&w||L||J?i.push(n.types.objectMethod("get",E,[],n.types.blockStatement([n.types.returnStatement(p)]))):i.push(n.types.objectProperty(E,p))}return{props:i,spreads:o}}function Et(e){return n.types.isJSXIdentifier(e)?e.name==="class"?"className":e.name:n.types.isJSXNamespacedName(e)?`${e.namespace.name}:${e.name.name}`:"unknown"}function xt(e,t,r="",s=!0){if(e===null)return n.types.booleanLiteral(!0);if(n.types.isStringLiteral(e))return e.value.includes(`
2
+ `)?n.types.stringLiteral(e.value.replace(/\s+/g," ").trim()):e;if(n.types.isJSXExpressionContainer(e)){if(n.types.isJSXEmptyExpression(e.expression))return n.types.booleanLiteral(!0);let i=e.expression;return s&&Re(i,r)?n.types.arrowFunctionExpression([],i):i}return n.types.isJSXElement(e)?D(e,t,!1,t.autoShow??!0):n.types.isJSXFragment(e)?G(e,t,{runtime:"automatic",pragmaFrag:"Fragment",development:!1}):n.types.booleanLiteral(!0)}function Re(e,t){return ye.test(t)||t.startsWith("on:")||t==="ref"||t.startsWith("use:")||n.types.isArrowFunctionExpression(e)||n.types.isFunctionExpression(e)||n.types.isIdentifier(e)||n.types.isStringLiteral(e)||n.types.isNumericLiteral(e)||n.types.isBooleanLiteral(e)||n.types.isNullLiteral(e)?!1:!!(n.types.isCallExpression(e)||n.types.isOptionalCallExpression(e)||n.types.isMemberExpression(e)||n.types.isOptionalMemberExpression(e)||n.types.isLogicalExpression(e)||n.types.isConditionalExpression(e)||n.types.isBinaryExpression(e)||n.types.isUnaryExpression(e)||n.types.isTemplateLiteral(e)||n.types.isObjectExpression(e)||n.types.isArrayExpression(e))}function St(e){let t=e.split(/\r\n|\n|\r/),r=0;for(let i=0;i<t.length;i++)/[^ \t]/.test(t[i])&&(r=i);let s="";for(let i=0;i<t.length;i++){let o=t[i].replace(/\t/g," ");i!==0&&(o=o.replace(/^ +/,"")),i!==t.length-1&&(o=o.replace(/ +$/,"")),o&&(i!==r&&(o+=" "),s+=o)}return s}function ee(e,t,r=!0){let s=[];for(let i of e)if(n.types.isJSXText(i)){let o=St(i.value);o&&s.push(n.types.stringLiteral(o))}else if(n.types.isJSXExpressionContainer(i)){if(!n.types.isJSXEmptyExpression(i.expression)){let o=i.expression;if(r){let a=bt(o,t)??vt(o,t);if(a){s.push(a);continue}}else{let a=yt(o,t);if(a){s.push(a);continue}}Ct(o)?s.push(n.types.arrowFunctionExpression([],o)):s.push(o)}}else n.types.isJSXElement(i)?s.push(D(i,t,!1,t.autoShow??!0)):n.types.isJSXFragment(i)?s.push(G(i,t,{runtime:"automatic",pragmaFrag:"Fragment",development:!1})):n.types.isJSXSpreadChild(i)&&s.push(i.expression);return s}function bt(e,t){if(!n.types.isArrowFunctionExpression(e)||e.params.length!==0||e.async)return null;let r=e.body;if(n.types.isLogicalExpression(r)&&r.operator==="&&"){let s=k(r.right);if(s)return O(P(r.left),s,null,t)}if(n.types.isConditionalExpression(r)){let s=k(r.consequent);if(s){let i=te(r.alternate,t);return O(P(r.test),s,i,t,!0)}}return null}function vt(e,t){if(n.types.isLogicalExpression(e)&&e.operator==="&&"){let r=k(e.right);if(r)return O(P(e.left),r,null,t)}if(n.types.isConditionalExpression(e)){let r=k(e.consequent);if(r){let s=te(e.alternate,t);return O(P(e.test),r,s,t)}}return null}function yt(e,t){let r=n.types.isArrowFunctionExpression(e)&&e.params.length===0&&!e.async&&n.types.isExpression(e.body)?e.body:e;if(n.types.isConditionalExpression(r)){let s=P(r.test),o=k(r.consequent)??r.consequent,c=k(r.alternate)??r.alternate,l=n.types.conditionalExpression(s,o,c);return Y(r.consequent)||Y(r.alternate)?null:(t.needsCreateMemo=!0,n.types.callExpression(n.types.identifier("createMemo"),[n.types.arrowFunctionExpression([],l)]))}if(n.types.isLogicalExpression(r)&&r.operator==="&&"){let s=P(r.left),o=k(r.right)??r.right,a=n.types.logicalExpression("&&",s,o);return Y(r.right)?null:(t.needsCreateMemo=!0,n.types.callExpression(n.types.identifier("createMemo"),[n.types.arrowFunctionExpression([],a)]))}return null}function te(e,t){if(wt(e))return null;let r=k(e);if(r)return Pe(r,t);if(n.types.isConditionalExpression(e)){let s=e,i=k(s.consequent);if(i){let o=te(s.alternate,t);return O(P(s.test),i,o,t)}}return e}function be(e){return n.types.isJSXElement(e)||n.types.isJSXFragment(e)}function Y(e){let t=k(e);if(!t||!n.types.isJSXElement(t))return!1;let r=t.openingElement.name;return n.types.isJSXIdentifier(r)&&Q.has(r.name)}function k(e){return be(e)?e:n.types.isArrowFunctionExpression(e)&&e.params.length===0&&!e.async&&be(e.body)?e.body:null}function P(e){return n.types.isArrowFunctionExpression(e)&&e.params.length===0&&!e.async&&n.types.isExpression(e.body)?e.body:e}function wt(e){return n.types.isNullLiteral(e)||n.types.isIdentifier(e)&&e.name==="undefined"||n.types.isBooleanLiteral(e)&&e.value===!1}function Pe(e,t){return n.types.isJSXElement(e)?D(e,t,!1,t.autoShow??!0):G(e,t,{runtime:"automatic",pragmaFrag:"Fragment",development:!1})}function O(e,t,r,s,i=!1){s.controlFlowComponents.add("Show"),s.needsControlFlowImport=!0;let o=Pe(t,s),a=[n.types.objectProperty(n.types.identifier("when"),n.types.arrowFunctionExpression([],e)),n.types.objectProperty(n.types.identifier("children"),o)];return r&&a.push(n.types.objectProperty(n.types.identifier("fallback"),r)),ke(n.types.identifier("Show"),n.types.objectExpression(a),s)}function Ct(e){return n.types.isMemberExpression(e)||n.types.isOptionalMemberExpression(e)?!(!e.computed&&n.types.isIdentifier(e.property,{name:"children"})):n.types.isCallExpression(e)||n.types.isOptionalCallExpression(e)?!0:n.types.isIdentifier(e)?!1:!!(n.types.isLogicalExpression(e)||n.types.isConditionalExpression(e)||n.types.isBinaryExpression(e)||n.types.isUnaryExpression(e)||n.types.isTemplateLiteral(e))}function Le(e,t){let r=e.openingElement;if(!n.types.isJSXIdentifier(r.name))return!1;let s=r.name.name;if(s[0]!==s[0].toLowerCase())return!1;for(let i of r.attributes){if(n.types.isJSXSpreadAttribute(i))return!1;if(n.types.isJSXAttribute(i)){let o=i.value;if(n.types.isJSXExpressionContainer(o)&&!n.types.isStringLiteral(o.expression)&&!n.types.isNumericLiteral(o.expression))return!1}}for(let i of e.children)if(n.types.isJSXElement(i)&&!Le(i,t)||n.types.isJSXExpressionContainer(i))return!1;return!0}function kt(e,t){let r=`_$static${t.staticCounter++}`,s=D(e,t,!1);return t.staticElements.set(r,s),n.types.identifier(r)}function Nt(e,t){let r=e.openingElement.name.name;return r==="Show"?Jt(e,t):r==="For"?It(e,t):null}function Jt(e,t){return null}function It(e,t){return null}
@@ -89,6 +89,11 @@ export interface PluginOptions {
89
89
  * @default '@fluixi/dom'
90
90
  */
91
91
  controlFlowModule?: string;
92
+ /**
93
+ * Module the router components (Router/Outlet/…) are auto-imported from.
94
+ * @default '@fluixi/core/router-next'
95
+ */
96
+ routerModule?: string;
92
97
  /**
93
98
  * Where reactive primitives (createMemo) are imported from — the signal core,
94
99
  * not the dom runtime.
@@ -116,6 +121,22 @@ export interface PluginOptions {
116
121
  * @default 'inline'
117
122
  */
118
123
  codegen?: 'inline' | 'ir';
124
+ /**
125
+ * Which authoring syntaxes to compile:
126
+ * - 'jsx' (default): only JSX elements/fragments.
127
+ * - 'lit': also compile `` html`...` `` tagged templates through the shared IR
128
+ * pipeline (imperative backend). Off the JSX path — same runtime output.
129
+ * - 'both': JSX and `html``` templates in the same file.
130
+ * Lit compilation targets the imperative backend.
131
+ * @default 'jsx'
132
+ */
133
+ format?: 'jsx' | 'lit' | 'both';
134
+ /**
135
+ * Tag name that marks a lit template for compilation (when `format` includes
136
+ * lit). Other tagged templates are left untouched.
137
+ * @default 'html'
138
+ */
139
+ litTag?: string;
119
140
  }
120
141
  declare const _default: (api: object, options: PluginOptions | null | undefined, dirname: string) => PluginObj<PluginPass>;
121
142
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/frontend/babel/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AAQrB,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAElC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,KAAK,GAAG,YAAY,CAAC;IAE/B;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC3B;;AA4FD,wBA4lBG"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/frontend/babel/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AAUrB,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAElC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,KAAK,GAAG,YAAY,CAAC;IAE/B;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAE1B;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;IAEhC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;AAuGD,wBAubG"}