@fluixi/compiler 1.0.0-alpha.68 → 1.0.0-alpha.70
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-NY6FXXLW.mjs +2 -0
- package/dist/codegen/backend.cjs +1 -1
- package/dist/codegen/backend.d.ts +14 -0
- package/dist/codegen/backend.d.ts.map +1 -1
- package/dist/codegen/backends/imperative.cjs +1 -1
- package/dist/codegen/backends/imperative.d.ts +10 -1
- package/dist/codegen/backends/imperative.d.ts.map +1 -1
- package/dist/codegen/backends/imperative.js +127 -16
- package/dist/codegen/backends/imperative.mjs +1 -1
- package/dist/codegen/partial-template.cjs +1 -0
- package/dist/codegen/partial-template.d.ts +62 -0
- package/dist/codegen/partial-template.d.ts.map +1 -0
- package/dist/codegen/partial-template.js +0 -0
- package/dist/codegen/partial-template.mjs +1 -0
- package/dist/codegen/serialize-static.cjs +1 -0
- package/dist/codegen/serialize-static.d.ts +23 -0
- package/dist/codegen/serialize-static.d.ts.map +1 -0
- package/dist/codegen/serialize-static.js +140 -0
- package/dist/codegen/serialize-static.mjs +1 -0
- package/dist/frontend/babel/build-ir-lit.cjs +1 -1
- package/dist/frontend/babel/build-ir-lit.d.ts.map +1 -1
- package/dist/frontend/babel/build-ir-lit.js +5 -1
- package/dist/frontend/babel/build-ir-lit.mjs +1 -1
- package/dist/frontend/babel/build-ir.cjs +1 -1
- package/dist/frontend/babel/build-ir.d.ts.map +1 -1
- package/dist/frontend/babel/build-ir.js +36 -8
- package/dist/frontend/babel/build-ir.mjs +1 -1
- package/dist/frontend/babel/index.cjs +2 -2
- package/dist/frontend/babel/index.mjs +2 -2
- package/dist/frontend/babel/lower-template.cjs +1 -1
- package/dist/frontend/babel/lower-template.d.ts.map +1 -1
- package/dist/frontend/babel/lower-template.js +34 -5
- package/dist/frontend/babel/lower-template.mjs +1 -1
- package/dist/frontend/babel/plugin.cjs +2 -2
- package/dist/frontend/babel/plugin.d.ts +14 -0
- package/dist/frontend/babel/plugin.d.ts.map +1 -1
- package/dist/frontend/babel/plugin.js +291 -34
- package/dist/frontend/babel/plugin.mjs +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.mjs +1 -1
- package/dist/integrations.cjs +8 -8
- package/dist/integrations.d.ts +13 -0
- package/dist/integrations.d.ts.map +1 -1
- package/dist/integrations.js +9 -0
- package/dist/integrations.mjs +3 -3
- package/dist/ir/nodes.cjs +1 -1
- package/dist/ir/nodes.d.ts +43 -0
- package/dist/ir/nodes.d.ts.map +1 -1
- package/dist/optimize/analyze-static.cjs +1 -0
- package/dist/optimize/analyze-static.d.ts +40 -0
- package/dist/optimize/analyze-static.d.ts.map +1 -0
- package/dist/optimize/analyze-static.js +131 -0
- package/dist/optimize/analyze-static.mjs +1 -0
- package/dist/optimize/collapse-strategies.cjs +1 -0
- package/dist/optimize/collapse-strategies.d.ts +31 -0
- package/dist/optimize/collapse-strategies.d.ts.map +1 -0
- package/dist/optimize/collapse-strategies.js +33 -0
- package/dist/optimize/collapse-strategies.mjs +1 -0
- package/dist/options.cjs +1 -1
- package/dist/options.d.ts +24 -0
- package/dist/options.d.ts.map +1 -1
- package/dist/resolve/builtins.cjs +1 -0
- package/dist/resolve/builtins.d.ts +69 -0
- package/dist/resolve/builtins.d.ts.map +1 -0
- package/dist/resolve/builtins.js +64 -0
- package/dist/resolve/builtins.mjs +1 -0
- package/dist/resolve/component-resolver.cjs +1 -0
- package/dist/resolve/component-resolver.d.ts +69 -0
- package/dist/resolve/component-resolver.d.ts.map +1 -0
- package/dist/resolve/component-resolver.js +95 -0
- package/dist/resolve/component-resolver.mjs +1 -0
- package/dist/resolve/load-directive.cjs +1 -0
- package/dist/resolve/load-directive.d.ts +54 -0
- package/dist/resolve/load-directive.d.ts.map +1 -0
- package/dist/resolve/load-directive.js +93 -0
- package/dist/resolve/load-directive.mjs +1 -0
- package/dist/resolve/resolve-ir.cjs +1 -0
- package/dist/resolve/resolve-ir.d.ts +54 -0
- package/dist/resolve/resolve-ir.d.ts.map +1 -0
- package/dist/resolve/resolve-ir.js +58 -0
- package/dist/resolve/resolve-ir.mjs +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/dist/babel-6UTCV3CC.mjs +0 -2
package/dist/integrations.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";var bt=Object.create;var U=Object.defineProperty;var vt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var Ct=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var X=(e,t)=>()=>(e&&(t=e(e=0)),t);var Xe=(e,t)=>{for(var n in t)U(e,n,{get:t[n],enumerable:!0})},je=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of wt(t))!Jt.call(e,s)&&s!==n&&U(e,s,{get:()=>t[s],enumerable:!(i=vt(t,s))||i.enumerable});return e};var q=(e,t,n)=>(n=e!=null?bt(Ct(e)):{},je(t||!e||!e.__esModule?U(n,"default",{value:e,enumerable:!0}):n,e)),kt=e=>je(U({},"__esModule",{value:!0}),e);var oe,Rn,Fe=X(()=>{"use strict";oe={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},Rn={version:2,module:"@fluixi/dom",symbols:[...oe.symbols,"template","cloneTemplate","walk"]}});function Rt(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function $e(e){return Rt(e)?e:JSON.stringify(e)}function Ft(e){return e.expr!==void 0?e.reactive?`() => (${e.expr})`:`(${e.expr})`:JSON.stringify(e.literal??!0)}function Pt(e){return e.expr!==void 0?`(${e.expr})`:JSON.stringify(e.literal??!0)}function $t(e,t,n){let i=e.filter(l=>l.kind==="spread"),o=e.filter(l=>l.kind!=="spread").map(l=>`${$e(l.name)}: ${Ft(l)}`);t!=null&&o.push(`children: ${t}`);let a=`{ ${o.join(", ")} }`;return i.length>0?(n.add("mergeProps"),`mergeProps(${i.map(l=>l.expr).join(", ")}, ${a})`):a}function Me(e,t){return e.length===1?Z(e[0],t):`[${e.map(n=>Z(n,t)).join(", ")}]`}function Pe(e,t,n,i){i.add("createMemo"),i.add("createComponent");let s=t.filter(c=>c.kind==="spread"),a=t.filter(c=>c.kind!=="spread").map(c=>`get ${$e(c.name)}() { return ${Pt(c)}; }`);n.length>0&&a.push(`get children() { return ${Me(n,i)}; }`);let l=`{ ${a.join(", ")} }`;return s.length>0&&(i.add("mergeProps"),l=`mergeProps(${s.map(c=>c.expr).join(", ")}, ${l})`),`createMemo(() => createComponent(${e}, ${l}))`}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":Me(e.children,t);case"component":return Pe(e.name,e.props,e.children,t);case"control":{let n=jt[e.control]??e.control;return t.add(n),Pe(n,e.props,e.children,t)}case"element":{t.add("createNativeElement");let n=JSON.stringify(e.tag),i="_el$",s=[],o=e.svg?`${n}, true`:n;if(s.push(`const ${i} = createNativeElement(${o});`),e.props.length>0){t.add("spread");let a=e.svg?", isSVG: true":"";s.push(`spread({ element: ${i}, props: ${$t(e.props,null,t)}${a} });`)}for(let a of e.children){t.add("insert");let l=Z(a,t),c=a.kind==="expr"&&a.reactive||a.kind==="component"||a.kind==="control";s.push(c?`insert(${i}, ${l}, null);`:`insert(${i}, ${l});`)}return s.push(`return ${i};`),`(() => { ${s.join(" ")} })()`}}}var jt,j,K=X(()=>{"use strict";Fe();jt={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};j={name:"imperative",contract:oe,emit(e,t){let n=new Set;return{code:Z(e,n),imports:Array.from(n)}}}});function Tt(e){return Mt(e,{concise:!0}).code}function Lt(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function Le(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Oe(e,t,n={}){let i=e.quasi,s=i.expressions.map(l=>{let c=l;return{node:c,code:R(c,t),reactive:v(c)}}),o=At(i),{root:a}=(0,Ae.parseTemplate)(o,{svg:n.svg});return new le(s,t).lowerRoot(a.children)}function At(e){let t=[];return e.quasis.forEach((n,i)=>{let s=n.value.cooked??n.value.raw;if(t.push({kind:"static",text:s,start:n.start??0}),i<e.expressions.length){let o=e.expressions[i];t.push({kind:"hole",index:i,start:o.start??0,end:o.end??0})}}),t}var D,ae,Ae,Mt,Te,le,De=X(()=>{"use strict";D=require("@babel/core"),ae=q(require("@babel/generator"),1),Ae=require("@fluixi/template-parser");K();ce();Mt=ae.default.default??ae.default;Te=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);le=class{constructor(t,n){this.holes=t;this.used=n}hole(t){return this.holes[t]??{node:D.types.identifier("undefined"),code:"undefined",reactive:!1}}emit(t){let{code:n,imports:i}=j.emit(t,{});for(let s of i)this.used.add(s);return n}lowerRoot(t){let n=this.lowerChildren(t);return n.length===1?n[0]:{kind:"fragment",children:n}}lowerChildren(t){let n=[];for(let i=0;i<t.length;i++){let s=t[i];if(s.kind==="Element"||s.kind==="Component"){let a=s.attributes.find(l=>l.kind==="IfDirective");if(a&&a.kind==="IfDirective"){let l=i+1;l<t.length&&this.isBlankText(t[l])&&l++;let c=t[l],p=c&&(c.kind==="Element"||c.kind==="Component")&&c.attributes.some(g=>g.kind==="ElseDirective");n.push(this.lowerIf(s,a.hole,p?c:null)),p&&(i=l);continue}if(s.attributes.some(l=>l.kind==="EachDirective")){n.push(this.lowerEach(s));continue}}let o=this.lowerNode(s);o&&n.push(o)}return n}isBlankText(t){return t.kind==="Text"&&!t.raw&&Y(t.value)===""}lowerNode(t){switch(t.kind){case"Text":{if(t.raw)return{kind:"text",value:t.value};let n=Y(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(i=>i.kind==="Attribute"&&i.name==="is");if(t.tag==="component"&&n&&n.value&&n.value.kind==="hole"){let i=t.attributes.filter(o=>o!==n),s=this.lowerComponent({...t,kind:"Component",tag:"Dynamic",tagHole:null,attributes:i});return s.props.unshift({name:"component",kind:"attr",expr:`() => (${this.hole(n.value.hole).code})`}),s}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,i=this.lowerAttributes(t.attributes),{slots:s,rest:o}=this.partitionSlots(t.children);for(let[a,l]of s){let c=l.length===1?l[0]:{kind:"fragment",children:l};i.push({name:a,kind:"attr",expr:this.emit(c),jsxElement:!0})}return{kind:"component",name:n,props:i,children:this.lowerChildren(o)}}partitionSlots(t){let n=new Map,i=[];for(let s of t){if(s.kind==="Element"||s.kind==="Component"){let o=s.attributes.find(a=>a.kind==="Attribute"&&a.name==="slot");if(o&&o.value&&o.value.kind==="static"){let a={...s,attributes:s.attributes.filter(p=>p!==o)},l=a.kind==="Element"?this.lowerElement(a):this.lowerComponent(a),c=n.get(o.value.value)??[];c.push(l),n.set(o.value.value,c);continue}}i.push(s)}return{slots:n,rest:i}}lowerIf(t,n,i){let s=this.hole(n),o=[{name:"when",kind:"attr",expr:s.code,reactive:s.reactive}];if(i){let l=this.stripAndLower(i,c=>c.kind==="ElseDirective");o.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:o,children:[a]}}lowerEach(t){let n=t.attributes.find(c=>c.kind==="EachDirective");if(!n||n.kind!=="EachDirective")return this.lowerNode(t);let i=this.hole(n.hole),s=[{name:"each",kind:"attr",expr:i.code,reactive:i.reactive}];if(n.key){let c="static"in n.key?`(item) => item[${JSON.stringify(n.key.static)}]`:this.hole(n.key.hole).code;s.push({name:"by",kind:"attr",expr:c})}let o=this.itemArrow(t),a;if(o){let c=o.body,p={kind:"expr",code:R(c,this.used),reactive:v(c)},g=this.rebuildWithChildren(t,[p]);a=`(${o.params.map(m=>Tt(m)).join(", ")}) => (${this.emit(g)})`}else{let c=this.stripAndLower(t,p=>p.kind==="EachDirective");a=`() => (${this.emit(c)})`}return{kind:"component",name:"For",props:s,children:[{kind:"expr",code:a,reactive:!1}]}}itemArrow(t){let n=t.children.filter(s=>!this.isBlankText(s));if(n.length!==1||n[0].kind!=="Expression")return null;let i=this.hole(n[0].hole).node;return D.types.isArrowFunctionExpression(i)&&!D.types.isBlockStatement(i.body)?i:null}stripAndLower(t,n){let i={...t,attributes:t.attributes.filter(s=>!n(s))};return i.kind==="Element"?this.lowerElement(i):this.lowerComponent(i)}rebuildWithChildren(t,n){let i=this.lowerAttributes(t.attributes.filter(s=>s.kind!=="EachDirective"));return t.kind==="Element"?{kind:"element",tag:t.tag,svg:t.namespace==="svg",props:i,children:n,static:!1}:{kind:"component",name:t.tag,props:i,children:n}}lowerAttributes(t){let n=[],i=[],s=!1,o=[],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);i.push(`${JSON.stringify(c.name)}: ${p.code}`),s=s||p.reactive;break}case"StyleDirective":{let p=this.hole(c.hole);o.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 i.length>0&&n.push({name:"classList",kind:"attr",expr:`{ ${i.join(", ")} }`,reactive:s}),o.length>0&&n.push({name:"style",kind:"attr",expr:`{ ${o.join(", ")} }`,reactive:a}),l.length>0&&n.push({name:"use",kind:"attr",expr:`[${l.join(", ")}]`}),n}eventProp(t){let n=t.name.toLowerCase(),i=this.hole(t.hole).code;if(!(t.syntax==="colon"||t.modifiers.length>0))return{name:"on"+Le(t.name),kind:"event",event:{name:n,delegated:Te.has(n)},expr:i};let o=this.wrapHandler(i,t.modifiers),a=this.eventOptions(t.modifiers),l=a?`[${o}, ${a}]`:o;return{name:"on:"+n,kind:"attr",expr:l}}wrapHandler(t,n){let i=n.includes("self")?"if (e.target !== e.currentTarget) return; ":"",s=[];return n.includes("prevent")&&s.push("e.preventDefault();"),n.includes("stop")&&s.push("e.stopPropagation();"),!i&&s.length===0?t:`(e) => { ${i}${s.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 i=t==="checked",s=i?"change":"input",o=i?"checked":"value",a=`(${n})`;return[{name:t,kind:"attr",expr:`${a}[0]()`,reactive:!0},{name:"on"+Le(s),kind:"event",event:{name:s,delegated:Te.has(s)},expr:`(e) => ${a}[1](e.target.${o})`}]}plainAttr(t){let n=t.value,i=t.name;t.name==="class"?i=n&&n.kind==="hole"&&D.types.isObjectExpression(this.hole(n.hole).node)?"classList":"className":t.name==="html"&&(i="innerHTML");let o={name:i,kind:"attr"};if(n==null)return o.literal=!0,o;if(n.kind==="static")return o.literal=n.value,o;if(n.kind==="hole"){let c=this.hole(n.hole);return o.expr=c.code,o.reactive=c.reactive,o}let a=!1,l=n.parts.map(c=>{if("text"in c)return Lt(c.text);let p=this.hole(c.hole);return a=a||p.reactive,"${"+p.code+"}"}).join("");return o.expr="`"+l+"`",o.reactive=a,o}}});function Q(e,t=new Set,n={}){return Oe(e,t,n)}var pe=X(()=>{"use strict";De()});function Ve(e){return Ot(e,{concise:!0}).code}function Dt(e,t){let n=u.types.cloneNode(e,!0),i=u.types.file(u.types.program([u.types.expressionStatement(n)])),s=!1,o=(a,l,c)=>{for(let p of c)t.add(p);a.replaceWith(u.template.expression(l,{placeholderPattern:!1,plugins:["typescript"]})()),a.skip(),s=!0};return(0,u.traverse)(i,{"JSXElement|JSXFragment"(a){let l=a.node,{code:c,imports:p}=j.emit(_(l,t),{});o(a,c,p)},TaggedTemplateExpression(a){let l=a.node.tag;if(!u.types.isIdentifier(l)||l.name!=="html"&&l.name!=="svg")return;let c=Q(a.node,t,{svg:l.name==="svg"}),{code:p,imports:g}=j.emit(c,{});o(a,p,g)}}),s?i.program.body[0].expression:e}function R(e,t){return Ve(Dt(e,t))}function zt(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:Ve(e),component:!0}:u.types.isJSXNamespacedName(e)?{tag:`${e.namespace.name}:${e.name.name}`,component:!1}:{tag:"div",component:!1}}function Ht(e){return u.types.isJSXIdentifier(e)?e.name==="class"?"className":e.name:u.types.isJSXNamespacedName(e)?`${e.namespace.name}:${e.name.name}`:"unknown"}function v(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)?v(e.test)||v(e.consequent)||v(e.alternate):u.types.isLogicalExpression(e)||u.types.isBinaryExpression(e)?v(e.left)||v(e.right):u.types.isTemplateLiteral(e)?e.expressions.some(t=>v(t)):u.types.isObjectExpression(e)?e.properties.some(t=>u.types.isObjectProperty(t)&&!t.computed&&v(t.value)):u.types.isArrayExpression(e)?e.elements.some(t=>t!=null&&!u.types.isSpreadElement(t)&&v(t)):!1}function Wt(e,t){let n=Ht(e.name),i=Bt.test(n),s=i||n.startsWith("on:"),a={name:n,kind:i?"event":"attr"};i&&(a.event={name:n.slice(2).toLowerCase(),delegated:Vt.has(n.slice(2).toLowerCase())});let l=e.value;if(l==null)return a.literal=!0,a;if(u.types.isStringLiteral(l))return a.literal=l.value,a;if(u.types.isJSXExpressionContainer(l)&&!u.types.isJSXEmptyExpression(l.expression)){let c=l.expression;return u.types.isStringLiteral(c)||u.types.isNumericLiteral(c)||u.types.isBooleanLiteral(c)?(a.literal=c.value,a):(a.expr=R(c,t),a.reactive=s?!1:v(c),(u.types.isJSXElement(c)||u.types.isJSXFragment(c))&&(a.jsxElement=!0),a)}return a.literal=!0,a}function _e(e,t){let n=e.value;return n==null?null:u.types.isStringLiteral(n)?JSON.stringify(n.value):u.types.isJSXExpressionContainer(n)&&!u.types.isJSXEmptyExpression(n.expression)?R(n.expression,t):null}function Ut(e,t){let n=[],i=[];for(let s of e){if(u.types.isJSXSpreadAttribute(s)){n.push({name:"",kind:"spread",expr:R(s.argument,t)});continue}if(!u.types.isJSXAttribute(s))continue;let o=u.types.isJSXNamespacedName(s.name)?s.name.namespace.name:null;if(o==="use"){let a=s.name.name.name;t.add(a);let l=_e(s,t);i.push(l!=null?`[${a}, () => (${l})]`:`[${a}]`);continue}if(o==="oncapture"){let a=s.name.name.name.toLowerCase(),l=_e(s,t)??"undefined";n.push({name:"on:"+a,kind:"attr",expr:`[${l}, { capture: true }]`});continue}n.push(Wt(s,t))}return i.length>0&&n.push({name:"use",kind:"attr",expr:`[${i.join(", ")}]`}),n}function Y(e){let t=e.split(/\r\n|\n|\r/),n=0;for(let s=0;s<t.length;s++)/[^ \t]/.test(t[s])&&(n=s);let i="";for(let s=0;s<t.length;s++){let o=t[s].replace(/\t/g," ");s!==0&&(o=o.replace(/^ +/,"")),s!==t.length-1&&(o=o.replace(/ +$/,"")),o&&(s!==n&&(o+=" "),i+=o)}return i}function Be(e,t){let n=[];for(let i of e)if(u.types.isJSXText(i)){let s=Y(i.value);s&&n.push({kind:"text",value:s})}else if(u.types.isJSXExpressionContainer(i)){if(!u.types.isJSXEmptyExpression(i.expression)){let s=i.expression;n.push({kind:"expr",code:R(s,t),reactive:v(s)})}}else u.types.isJSXElement(i)||u.types.isJSXFragment(i)?n.push(_(i,t)):u.types.isJSXSpreadChild(i)&&n.push({kind:"expr",code:R(i.expression,t),reactive:!1});return n}function _(e,t=new Set){if(u.types.isJSXFragment(e))return{kind:"fragment",children:Be(e.children,t)};let{tag:n,component:i}=zt(e.openingElement.name),s=Ut(e.openingElement.attributes,t),o=Be(e.children,t);return i?{kind:"component",name:n,props:s,children:o}:{kind:"element",tag:n,svg:_t.has(n),props:s,children:o,static:!1}}var u,ue,Ot,_t,Bt,Vt,ce=X(()=>{"use strict";u=require("@babel/core"),ue=q(require("@babel/generator"),1);K();pe();Ot=ue.default.default??ue.default;_t=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),Bt=/^on[A-Z]/,Vt=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"])});function Gt(e,t,n){let{runtime:i,pragma:s,development:o,autoShow:a=!0}=n;return i==="automatic"?z(e,t,o,a):nn(e,t,s)}function He(e,t,n){return t.length>0?(n.needsMergeProps=!0,r.types.callExpression(r.types.identifier("mergeProps"),[...t,r.types.objectExpression(e)])):r.types.objectExpression(e)}function Ke(e){return e.length===1?e[0]:r.types.arrayExpression(e)}function Kt(e,t,n,i,s,o){if(!t){let m=[...n];return s.length>0&&m.push(r.types.objectMethod("get",r.types.identifier("children"),[],r.types.blockStatement([r.types.returnStatement(Ke(s))]))),Ye(e,He(m,i,o),o)}let a=e.value,l=Zt.has(a),c=r.types.identifier("_el$"),p=[];o.needsCreateNativeElement=!0;let g=[e];if(l&&g.push(r.types.booleanLiteral(!0)),p.push(r.types.variableDeclaration("const",[r.types.variableDeclarator(c,r.types.callExpression(r.types.identifier("createNativeElement"),g))])),n.length>0||i.length>0){o.needsSpread=!0;let m=[r.types.objectProperty(r.types.identifier("element"),c),r.types.objectProperty(r.types.identifier("props"),He(n,i,o))];l&&m.push(r.types.objectProperty(r.types.identifier("isSVG"),r.types.booleanLiteral(!0))),p.push(r.types.expressionStatement(r.types.callExpression(r.types.identifier("spread"),[r.types.objectExpression(m)])))}if(s.length>0){o.needsInsert=!0;for(let m of s){let $=r.types.isArrowFunctionExpression(m)||r.types.isFunctionExpression(m)||r.types.isCallExpression(m)&&r.types.isIdentifier(m.callee)&&m.callee.name==="createMemo"?[r.types.cloneNode(c),m,r.types.nullLiteral()]:[r.types.cloneNode(c),m];p.push(r.types.expressionStatement(r.types.callExpression(r.types.identifier("insert"),$)))}}return p.push(r.types.returnStatement(c)),r.types.callExpression(r.types.arrowFunctionExpression([],r.types.blockStatement(p)),[])}function Ye(e,t,n){return r.types.isIdentifier(e)&&B.has(e.name)&&(n.controlFlowComponents.add(e.name),n.needsControlFlowImport=!0),n.backend==="imperative"?(n.needsCreateComponent=!0,n.needsCreateMemo=!0,r.types.callExpression(r.types.identifier("createMemo"),[r.types.arrowFunctionExpression([],r.types.callExpression(r.types.identifier("createComponent"),[e,t]))])):r.types.callExpression(r.types.identifier("jsx"),[e,t])}function We(e,t){let n=new Set,i=_(e,n),{code:s,imports:o}=j.emit(i,{});for(let a of o)n.add(a);for(let a of n)t.irImports.add(a);return r.template.expression(s,{placeholderPattern:!1,plugins:["typescript"]})()}function Yt(e){let t=new Map,n=[];for(let i of e){let s=i.source.value;if(!i.specifiers.every(l=>r.types.isImportSpecifier(l))){n.push(i);continue}let a=t.get(s);if(!a){let l=new Set(i.specifiers.map(c=>c.local.name));t.set(s,{decl:i,names:l}),n.push(i);continue}for(let l of i.specifiers)a.names.has(l.local.name)||(a.names.add(l.local.name),a.decl.specifiers.push(l))}return n}function Qt(e,t){let n=new Set,i=r.types.isIdentifier(e.tag)&&e.tag.name==="svg",s=Q(e,n,{svg:i}),{code:o,imports:a}=j.emit(s,{});for(let c of a)n.add(c);for(let c of n)t.irImports.add(c);Qe(s,t),t.hasLitIR=!0;let l=r.template.expression(o,{placeholderPattern:!1,plugins:["typescript"]})();return en(l,e),l}function en(e,t){if(!t.loc)return;let n=new Set,i=s=>{if(!n.has(s)){n.add(s),s.loc||(s.loc=t.loc,s.start=t.start,s.end=t.end);for(let o of r.types.VISITOR_KEYS[s.type]??[]){let a=s[o];if(Array.isArray(a))for(let l of a)l&&typeof l=="object"&&"type"in l&&i(l);else a&&typeof a=="object"&&"type"in a&&i(a)}}};i(e)}function Qe(e,t){if(e.kind==="component"&&(me.has(e.name)||B.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 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)Qe(n,t)}function tn(e){return e.map(t=>{if(r.types.isObjectProperty(t)){let n=t.key,i=t.computed,s=t.value;return r.types.objectMethod("get",n,[],r.types.blockStatement([r.types.returnStatement(s)]),i)}return t})}function z(e,t,n,i=!0){let s=e.openingElement,o=e.children,a=et(s.name),l=r.types.isJSXIdentifier(s.name)&&/^[a-z]/.test(s.name.name),c=nt(s.attributes,t,l,r.types.isJSXIdentifier(s.name)?s.name.name:""),p=c.props,g=c.spreads;l||(p=tn(p));let m=de(o,t,i);if(t.backend==="imperative")return Kt(a,l,p,g,m,t);if(m.length>0){let N=m.length===1?m[0]:r.types.arrayExpression(m);p.push(r.types.objectProperty(r.types.identifier("children"),N))}let w;if(g.length>0){let N=p.length>0?r.types.objectExpression(p):r.types.objectExpression([]);t.needsMergeProps=!0,w=r.types.callExpression(r.types.identifier("mergeProps"),[...g,N])}else w=r.types.objectExpression(p);let $=n?"jsxDEV":m.length>1?"jsxs":"jsx",C=[a,w];return n&&C.push(r.types.identifier("undefined"),r.types.booleanLiteral(!1),r.types.identifier("undefined"),r.types.identifier("undefined")),r.types.callExpression(r.types.identifier($),C)}function nn(e,t,n){let i=e.openingElement,s=e.children,o=et(i.name),a=r.types.isJSXIdentifier(i.name)&&/^[a-z]/.test(i.name.name),{props:l,spreads:c}=nt(i.attributes,t,a,r.types.isJSXIdentifier(i.name)?i.name.name:""),p=de(s,t,t.autoShow??!0),g;if(c.length>0){let w=l.length>0?r.types.objectExpression(l):r.types.objectExpression([]);t.needsMergeProps=!0,g=r.types.callExpression(r.types.identifier("mergeProps"),[...c,w])}else g=l.length>0?r.types.objectExpression(l):r.types.nullLiteral();let m=[o,g,...p];return r.types.callExpression(r.types.identifier(n),m)}function ee(e,t,n){let{runtime:i,pragmaFrag:s,development:o}=n,a=de(e.children,t,t.autoShow??!0);if(t.backend==="imperative")return a.length===0?r.types.nullLiteral():Ke(a);if(i==="automatic"){let l=o?"jsxDEV":a.length>1?"jsxs":"jsx",c=r.types.objectExpression([r.types.objectProperty(r.types.identifier("children"),a.length===1?a[0]:r.types.arrayExpression(a))]),p=[r.types.identifier("Fragment"),c];return o&&p.push(r.types.identifier("undefined"),r.types.booleanLiteral(!1),r.types.identifier("undefined"),r.types.identifier("undefined")),r.types.callExpression(r.types.identifier(l),p)}else return r.types.callExpression(r.types.identifier(s),a)}function et(e){if(r.types.isJSXIdentifier(e)){let t=e.name;return t[0]===t[0].toLowerCase()?r.types.stringLiteral(t):r.types.identifier(t)}return r.types.isJSXMemberExpression(e)?tt(e):r.types.isJSXNamespacedName(e)?r.types.stringLiteral(`${e.namespace.name}:${e.name.name}`):r.types.stringLiteral("div")}function tt(e){let t;return r.types.isJSXIdentifier(e.object)?t=r.types.identifier(e.object.name):t=tt(e.object),r.types.memberExpression(t,r.types.identifier(e.property.name))}function rn(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)}function nt(e,t,n=!0,i=""){let s=[],o=[],a=qt[i];for(let l of e)if(r.types.isJSXSpreadAttribute(l))o.push(l.argument);else if(r.types.isJSXAttribute(l)){let c=sn(l.name),p=on(l.value,t,c,n);if(Ge.test(c)){let H=c.slice(2).toLowerCase();Ze.includes(H)&&t.delegatedEvents.add(H)}let g=rn(c)?r.types.identifier(c):r.types.stringLiteral(c),m=l.value,w=r.types.isJSXElement(m)||r.types.isJSXFragment(m)||r.types.isJSXExpressionContainer(m)&&(r.types.isJSXElement(m.expression)||r.types.isJSXFragment(m.expression)),$=!n&&c===a,C=r.types.isJSXExpressionContainer(m)&&!r.types.isJSXEmptyExpression(m.expression)?m.expression:null,N=!n&&!!C&&rt(C,c);!n&&w||$||N?s.push(r.types.objectMethod("get",g,[],r.types.blockStatement([r.types.returnStatement(p)]))):s.push(r.types.objectProperty(g,p))}return{props:s,spreads:o}}function sn(e){return r.types.isJSXIdentifier(e)?e.name==="class"?"className":e.name:r.types.isJSXNamespacedName(e)?`${e.namespace.name}:${e.name.name}`:"unknown"}function on(e,t,n="",i=!0){if(e===null)return r.types.booleanLiteral(!0);if(r.types.isStringLiteral(e))return e.value.includes(`
|
|
2
|
-
`)?r.types.stringLiteral(e.value.replace(/\s+/g," ").trim()):e;if(r.types.isJSXExpressionContainer(e)){if(r.types.isJSXEmptyExpression(e.expression))return r.types.booleanLiteral(!0);let s=e.expression;return i&&rt(s,n)?r.types.arrowFunctionExpression([],s):s}return r.types.isJSXElement(e)?z(e,t,!1,t.autoShow??!0):r.types.isJSXFragment(e)?ee(e,t,{runtime:"automatic",pragmaFrag:"Fragment",development:!1}):r.types.booleanLiteral(!0)}function rt(e,t){return Ge.test(t)||t.startsWith("on:")||t==="ref"||t.startsWith("use:")||r.types.isArrowFunctionExpression(e)||r.types.isFunctionExpression(e)||r.types.isIdentifier(e)||r.types.isStringLiteral(e)||r.types.isNumericLiteral(e)||r.types.isBooleanLiteral(e)||r.types.isNullLiteral(e)?!1:!!(r.types.isCallExpression(e)||r.types.isOptionalCallExpression(e)||r.types.isMemberExpression(e)||r.types.isOptionalMemberExpression(e)||r.types.isLogicalExpression(e)||r.types.isConditionalExpression(e)||r.types.isBinaryExpression(e)||r.types.isUnaryExpression(e)||r.types.isTemplateLiteral(e)||r.types.isObjectExpression(e)||r.types.isArrayExpression(e))}function an(e){let t=e.split(/\r\n|\n|\r/),n=0;for(let s=0;s<t.length;s++)/[^ \t]/.test(t[s])&&(n=s);let i="";for(let s=0;s<t.length;s++){let o=t[s].replace(/\t/g," ");s!==0&&(o=o.replace(/^ +/,"")),s!==t.length-1&&(o=o.replace(/ +$/,"")),o&&(s!==n&&(o+=" "),i+=o)}return i}function de(e,t,n=!0){let i=[];for(let s of e)if(r.types.isJSXText(s)){let o=an(s.value);o&&i.push(r.types.stringLiteral(o))}else if(r.types.isJSXExpressionContainer(s)){if(!r.types.isJSXEmptyExpression(s.expression)){let o=s.expression;if(n){let a=ln(o,t)??cn(o,t);if(a){i.push(a);continue}}else{let a=pn(o,t);if(a){i.push(a);continue}}fn(o)?i.push(r.types.arrowFunctionExpression([],o)):i.push(o)}}else r.types.isJSXElement(s)?i.push(z(s,t,!1,t.autoShow??!0)):r.types.isJSXFragment(s)?i.push(ee(s,t,{runtime:"automatic",pragmaFrag:"Fragment",development:!1})):r.types.isJSXSpreadChild(s)&&i.push(s.expression);return i}function ln(e,t){if(!r.types.isArrowFunctionExpression(e)||e.params.length!==0||e.async)return null;let n=e.body;if(r.types.isLogicalExpression(n)&&n.operator==="&&"){let i=J(n.right);if(i)return V(F(n.left),i,null,t)}if(r.types.isConditionalExpression(n)){let i=J(n.consequent);if(i){let s=ge(n.alternate,t);return V(F(n.test),i,s,t,!0)}}return null}function cn(e,t){if(r.types.isLogicalExpression(e)&&e.operator==="&&"){let n=J(e.right);if(n)return V(F(e.left),n,null,t)}if(r.types.isConditionalExpression(e)){let n=J(e.consequent);if(n){let i=ge(e.alternate,t);return V(F(e.test),n,i,t)}}return null}function pn(e,t){let n=r.types.isArrowFunctionExpression(e)&&e.params.length===0&&!e.async&&r.types.isExpression(e.body)?e.body:e;if(r.types.isConditionalExpression(n)){let i=F(n.test),o=J(n.consequent)??n.consequent,l=J(n.alternate)??n.alternate,c=r.types.conditionalExpression(i,o,l);return fe(n.consequent)||fe(n.alternate)?null:(t.needsCreateMemo=!0,r.types.callExpression(r.types.identifier("createMemo"),[r.types.arrowFunctionExpression([],c)]))}if(r.types.isLogicalExpression(n)&&n.operator==="&&"){let i=F(n.left),o=J(n.right)??n.right,a=r.types.logicalExpression("&&",i,o);return fe(n.right)?null:(t.needsCreateMemo=!0,r.types.callExpression(r.types.identifier("createMemo"),[r.types.arrowFunctionExpression([],a)]))}return null}function ge(e,t){if(un(e))return null;let n=J(e);if(n)return it(n,t);if(r.types.isConditionalExpression(e)){let i=e,s=J(i.consequent);if(s){let o=ge(i.alternate,t);return V(F(i.test),s,o,t)}}return e}function Ue(e){return r.types.isJSXElement(e)||r.types.isJSXFragment(e)}function fe(e){let t=J(e);if(!t||!r.types.isJSXElement(t))return!1;let n=t.openingElement.name;return r.types.isJSXIdentifier(n)&&me.has(n.name)}function J(e){return Ue(e)?e:r.types.isArrowFunctionExpression(e)&&e.params.length===0&&!e.async&&Ue(e.body)?e.body:null}function F(e){return r.types.isArrowFunctionExpression(e)&&e.params.length===0&&!e.async&&r.types.isExpression(e.body)?e.body:e}function un(e){return r.types.isNullLiteral(e)||r.types.isIdentifier(e)&&e.name==="undefined"||r.types.isBooleanLiteral(e)&&e.value===!1}function it(e,t){return r.types.isJSXElement(e)?z(e,t,!1,t.autoShow??!0):ee(e,t,{runtime:"automatic",pragmaFrag:"Fragment",development:!1})}function V(e,t,n,i,s=!1){i.controlFlowComponents.add("Show"),i.needsControlFlowImport=!0;let o=it(t,i),a=[r.types.objectProperty(r.types.identifier("when"),r.types.arrowFunctionExpression([],e)),r.types.objectProperty(r.types.identifier("children"),o)];return n&&a.push(r.types.objectProperty(r.types.identifier("fallback"),n)),Ye(r.types.identifier("Show"),r.types.objectExpression(a),i)}function fn(e){return r.types.isMemberExpression(e)||r.types.isOptionalMemberExpression(e)?!(!e.computed&&r.types.isIdentifier(e.property,{name:"children"})):r.types.isCallExpression(e)||r.types.isOptionalCallExpression(e)?!0:r.types.isIdentifier(e)?!1:!!(r.types.isLogicalExpression(e)||r.types.isConditionalExpression(e)||r.types.isBinaryExpression(e)||r.types.isUnaryExpression(e)||r.types.isTemplateLiteral(e))}function st(e,t){let n=e.openingElement;if(!r.types.isJSXIdentifier(n.name))return!1;let i=n.name.name;if(i[0]!==i[0].toLowerCase())return!1;for(let s of n.attributes){if(r.types.isJSXSpreadAttribute(s))return!1;if(r.types.isJSXAttribute(s)){let o=s.value;if(r.types.isJSXExpressionContainer(o)&&!r.types.isStringLiteral(o.expression)&&!r.types.isNumericLiteral(o.expression))return!1}}for(let s of e.children)if(r.types.isJSXElement(s)&&!st(s,t)||r.types.isJSXExpressionContainer(s))return!1;return!0}function mn(e,t){let n=`_$static${t.staticCounter++}`,i=z(e,t,!1);return t.staticElements.set(n,i),r.types.identifier(n)}function dn(e,t){let n=e.openingElement.name.name;return n==="Show"?gn(e,t):n==="For"?hn(e,t):null}function gn(e,t){return null}function hn(e,t){return null}var qe,r,me,ze,B,qt,Ge,Ze,L,Zt,he=X(()=>{"use strict";qe=require("@babel/helper-plugin-utils"),r=require("@babel/core");ce();pe();K();me=new Set(["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary","Suspense","SuspenseList","Await"]),ze=new Set(["Suspense","SuspenseList","Await"]),B=new Set(["Router","Outlet","Redirect","Link"]),qt={Show:"when",For:"each",Index:"each",Match:"when"},Ge=/^on[A-Z]/,Ze=["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave"],L=(0,qe.declare)((e,t={})=>{e.assertVersion(7);let{runtime:n="automatic",importSource:i="@fluixi/jsx",pragma:s="jsx",pragmaFrag:o="Fragment",development:a=!1,detectReactivity:l=!0,useLitHTML:c=!0,hoistStatics:p=!0,delegateEvents:g=!0,delegatedEvents:m=Ze,optimizeControlFlow:w=!0,sourceMaps:$=!0,signalModule:C="@fluixi/dom",controlFlowModule:N="@fluixi/dom",routerModule:H="@fluixi/core/router-next",reactiveModule:ke="@fluixi/reactive/signal",autoShowTransform:Ne=!1,backend:k="imperative",codegen:O="inline",format:Ie="both",litTag:Et="html"}=t,St=Ie==="lit"||Ie==="both",yt={backend:k,codegen:O,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,f){f.plugins.push("jsx","typescript")},pre(d){Object.assign(d,yt)},visitor:{ImportDeclaration(d,f){d.node.source.value==="@fluixi/core/rx"&&(d.node.source=r.types.stringLiteral("@fluixi/reactive"))},Program:{enter(d,f){Object.assign(f,{hasJSX:!1,hasReactivity:!1,hasLitHTML:!1,hasLitIR:!1,needsSignalImport:!1,needsControlFlowImport:!1,needsCreateMemo:!1,controlFlowComponents:new Set,delegatedEvents:new Set,staticElements:new Map,autoShow:Ne,staticCounter:0,libModule:"@fluixi/core",backend:k,codegen:O,irImports:new Set,needsCreateNativeElement:!1,needsInsert:!1,needsSpread:!1,needsCreateComponent:!1,needsMergeProps:!1})},exit(d,f){let h=[];if(f.hasJSX||f.needsSignalImport&&h.push(r.types.importDeclaration([r.types.importSpecifier(r.types.identifier("signal"),r.types.identifier("signal"))],r.types.stringLiteral(C))),f.hasJSX||f.hasLitIR){if(f.irImports.size>0){let x=new Set(["Show","For","Index","Switch","Match","Dynamic","ErrorBoundary","Portal","Suspense"]),y=new Set(["createMemo","createEffect","createRenderEffect","createRoot","createSignal","onCleanup","batch","untrack"]),E=Array.from(f.irImports),I=S=>r.types.importSpecifier(r.types.identifier(S),r.types.identifier(S)),M=S=>!d.scope.hasBinding(S),T=E.filter(S=>y.has(S)&&M(S)),b=E.filter(S=>!x.has(S)&&!y.has(S)&&M(S)),W=E.filter(S=>x.has(S)&&M(S));T.length>0&&h.push(r.types.importDeclaration(T.map(I),r.types.stringLiteral(ke))),b.length>0&&h.push(r.types.importDeclaration(b.map(I),r.types.stringLiteral(C))),W.length>0&&h.push(r.types.importDeclaration(W.map(I),r.types.stringLiteral(N)))}if(f.hasJSX&&k==="imperative"&&O!=="ir"){let y=[[!!f.needsCreateNativeElement,"createNativeElement"],[!!f.needsSpread,"spread"],[!!f.needsInsert,"insert"],[!!f.needsCreateComponent,"createComponent"],[!!f.needsMergeProps,"mergeProps"]].filter(([E,I])=>E&&!d.scope.hasBinding(I)).map(([,E])=>r.types.importSpecifier(r.types.identifier(E),r.types.identifier(E)));y.length>0&&h.push(r.types.importDeclaration(y,r.types.stringLiteral(C)))}else if(f.hasJSX&&n==="automatic"){let x=[r.types.importSpecifier(r.types.identifier("jsx"),r.types.identifier("jsx")),r.types.importSpecifier(r.types.identifier("jsxs"),r.types.identifier("jsxs")),r.types.importSpecifier(r.types.identifier("Fragment"),r.types.identifier("Fragment"))];a&&x.push(r.types.importSpecifier(r.types.identifier("jsxDEV"),r.types.identifier("jsxDEV"))),f.needsMergeProps&&x.push(r.types.importSpecifier(r.types.identifier("mergeProps"),r.types.identifier("mergeProps"))),h.push(r.types.importDeclaration(x,r.types.stringLiteral(i)))}if(f.needsCreateMemo&&!d.scope.hasBinding("createMemo")&&h.push(r.types.importDeclaration([r.types.importSpecifier(r.types.identifier("createMemo"),r.types.identifier("createMemo"))],r.types.stringLiteral(k==="imperative"?ke:f.libModule??"@fluixi/core"))),f.needsControlFlowImport&&f.controlFlowComponents.size>0){let x=Array.from(f.controlFlowComponents).filter(b=>!d.scope.hasBinding(b)),y=f.libModule??"@fluixi/core",E=x.filter(b=>B.has(b)),I=x.filter(b=>ze.has(b)),M=x.filter(b=>!ze.has(b)&&!B.has(b)),T=(b,W)=>r.types.importDeclaration(b.map(S=>r.types.importSpecifier(r.types.identifier(S),r.types.identifier(S))),r.types.stringLiteral(W));M.length>0&&h.push(T(M,N)),I.length>0&&h.push(T(I,y)),E.length>0&&h.push(T(E,H))}if(g&&f.delegatedEvents.size>0){h.push(r.types.importDeclaration([r.types.importSpecifier(r.types.identifier("delegateEvents"),r.types.identifier("delegateEvents"))],r.types.stringLiteral(k==="imperative"?C:"@fluixi/jsx")));let x=r.types.arrayExpression(Array.from(f.delegatedEvents).map(E=>r.types.stringLiteral(E))),y=r.types.expressionStatement(r.types.callExpression(r.types.identifier("delegateEvents"),[x]));d.node.body.unshift(y)}if(p&&f.staticElements.size>0){let x=[];f.staticElements.forEach((y,E)=>{x.push(r.types.variableDeclaration("const",[r.types.variableDeclarator(r.types.identifier(E),y)]))}),d.node.body.unshift(...x)}}h.length>0&&d.node.body.unshift(...Yt(h))}},JSXElement(d,f){if(f.hasJSX=!0,k==="imperative"&&O==="ir"){d.replaceWith(We(d.node,f));return}let h=d.node,x=h.openingElement;if(r.types.isJSXIdentifier(x.name)&&B.has(x.name.name)&&(f.controlFlowComponents.add(x.name.name),f.needsControlFlowImport=!0),r.types.isJSXIdentifier(x.name)&&me.has(x.name.name)&&(f.controlFlowComponents.add(x.name.name),w)){let E=dn(h,f);if(E){d.replaceWith(E);return}}if(p&&k!=="imperative"&&st(h,f)){let E=mn(h,f);if(E){d.replaceWith(E);return}}let y=Gt(h,f,{runtime:n,pragma:s,development:a,detectReactivity:l,useLitHTML:c,autoShow:Ne});d.replaceWith(y)},JSXFragment(d,f){if(f.hasJSX=!0,k==="imperative"&&O==="ir"){d.replaceWith(We(d.node,f));return}let h=ee(d.node,f,{runtime:n,pragmaFrag:o,development:a});d.replaceWith(h)},CallExpression(d,f){if(!l)return;let h=d.node.callee;h.name,r.types.isIdentifier(h)&&(h.name==="createSignal"||h.name==="createStore"||h.name==="useContext"||h.name==="useLocation")&&(f.hasReactivity=!0)},JSXExpressionContainer(d){},TaggedTemplateExpression(d,f){if(St&&k==="imperative"&&r.types.isIdentifier(d.node.tag)&&(d.node.tag.name===Et||d.node.tag.name==="svg")){d.replaceWith(Qt(d.node,f));return}}}}});Zt=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"])});var ot=X(()=>{"use strict"});var at={};Xe(at,{babelPluginReactiveJSX:()=>xn,createPlugin:()=>En,createPreset:()=>te,default:()=>L,presets:()=>Sn});function En(e){return[L,e]}function te(e={}){return{plugins:[[L,{runtime:"automatic",importSource:"@fluixi/jsx",development:!1,detectReactivity:!0,useLitHTML:!0,hoistStatics:!0,delegateEvents:!0,optimizeControlFlow:!0,sourceMaps:!0,...e}]]}}var xn,Sn,lt=X(()=>{"use strict";he();ot();he();xn=L;Sn={production:te({development:!1,hoistStatics:!0,delegateEvents:!0,optimizeControlFlow:!0}),development:te({development:!0,hoistStatics:!1,sourceMaps:!0}),minimal:te({detectReactivity:!1,useLitHTML:!1,hoistStatics:!1,delegateEvents:!1,optimizeControlFlow:!1})}});var In={};Xe(In,{analyzeProp:()=>ne,analyzeProps:()=>re,createBabelPlugin:()=>A,createESBuildPlugin:()=>ht,createRollupPlugin:()=>gt,createTypeScriptTransformer:()=>ft,createVitePlugin:()=>mt,createWebpackLoader:()=>dt,default:()=>Nn,generateChildrenCode:()=>ye,generateCreateElement:()=>pt,generateEventDelegation:()=>Ce,generateLitHTMLTemplate:()=>be,generatePropsCode:()=>Se,hoistStatic:()=>we,isLitTemplate:()=>ct,optimizeSpreads:()=>ut,optimizeStatic:()=>ve,serverFunctionsVitePlugin:()=>kn,shouldUseLitTemplate:()=>Ee,transform:()=>P,transformServerFunctions:()=>G});module.exports=kt(In);var Re=require("@babel/core"),Nt="@fluixi/start/server-fn";function It(e){let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return(t>>>0).toString(16)}function Xt({types:e}){return{name:"fluixi-server-functions",visitor:{Program:{enter(t,n){n.fxIndex=0,n.fxUsed=null},exit(t,n){n.fxUsed&&t.unshiftContainer("body",e.importDeclaration([e.importSpecifier(e.identifier(n.fxUsed),e.identifier(n.fxUsed))],e.stringLiteral(n.opts.runtimeModule||Nt)))}},"FunctionDeclaration|FunctionExpression|ArrowFunctionExpression":(t,n)=>{let i=t.node.body;if(!e.isBlockStatement(i))return;let o=(i.directives||[]).findIndex(m=>m.value.value==="use server");if(o<0)return;i.directives.splice(o,1);let a=(n.opts.filename||n.filename||"unknown").replace(n.opts.root?n.opts.root+"/":"",""),l=`${It(a)}:${n.fxIndex++}`,c=!!n.opts.ssr,p=c?"$$registerServerFn":"$$createServerReference";n.fxUsed=p;let g=c?e.callExpression(e.identifier(p),[e.stringLiteral(l),t.isFunctionDeclaration()?e.functionExpression(null,t.node.params,i,t.node.generator,t.node.async):t.node]):e.callExpression(e.identifier(p),[e.stringLiteral(l)]);t.isFunctionDeclaration()?t.replaceWith(e.variableDeclaration("const",[e.variableDeclarator(t.node.id,g)])):t.replaceWith(g),t.skip()}}}}function G(e,t){if(!e.includes("use server"))return null;let n=(0,Re.transformSync)(e,{filename:t.filename,configFile:!1,babelrc:!1,sourceMaps:!0,parserOpts:{plugins:["typescript","jsx"]},plugins:[[Xt,t]]});return n?.code?{code:n.code,map:n.map}:null}var se=require("node:fs"),Je=require("node:path"),yn=new Set(["key","ref","children"]),bn=[/\(\)\s*=>/,/function\s*\(\)/,/\w+\(\)/,/\w+\.\w+/,/\w+\[.+\]/,/createSignal/,/createStore/,/createMemo/,/createEffect/],vn=/^on[A-Z]/;function ne(e,t){let n={name:e,isStatic:!0,isReactive:!1,isEvent:vn.test(e),isRef:e==="ref",isSpread:e.startsWith("...")};if(yn.has(e))return n;if(n.isEvent||n.isRef)return n.isStatic=!1,n;if(typeof t=="string"){let i=t;for(let s of bn)if(s.test(i)){n.isStatic=!1,n.isReactive=!0;break}i.includes("${")&&(n.isStatic=!1,n.isReactive=!0)}else typeof t=="function"?(n.isStatic=!1,n.isReactive=!0):typeof t=="object"&&t!==null&&(n.isStatic=!1);return n}function re(e){let t=new Map;for(let[n,i]of Object.entries(e))t.set(n,ne(n,i));return t}function Ee(e,t,n){if(typeof e!="string")return!1;let i=re(t);for(let s of i.values()){if(s.isSpread)return!1;s.isReactive&&s.isEvent}return!0}function ct(e){return e&&typeof e=="object"&&"_$litType$"in e}function pt(e,t,n,i={}){let s=["svg","path","circle","rect","g"].includes(e),o=Se(t,i),a=n.length>0?`, ${ye(n)}`:"";return i.useLitHTML!==!1&&Ee(e,t,n)?be(e,t,n,s):`jsx('${e}', ${o}${a})`}function Se(e,t={}){if(Object.keys(e).length===0)return"{}";let n=re(e),i=[];for(let[s,o]of Object.entries(e)){let a=n.get(s);a.isReactive&&!a.isStatic?i.push(`${s}: () => ${o}`):typeof o=="string"?i.push(`${s}: "${o}"`):typeof o=="number"||typeof o=="boolean"?i.push(`${s}: ${o}`):i.push(`${s}: ${o}`)}return`{ ${i.join(", ")} }`}function ye(e){return e.length===0?"undefined":e.length===1?String(e[0]):`[${e.join(", ")}]`}function be(e,t,n,i=!1){let s=i?"svg":"html",o=`<${e}`,a=[];for(let[l,c]of Object.entries(t)){if(l==="children"||l==="key"||l==="ref")continue;let p=ne(l,c);if(p.isEvent){let g=l.slice(2).toLowerCase();o+=` @${g}=\${${a.length}}`,a.push(String(c))}else p.isReactive?(o+=` ${l}=\${${a.length}}`,a.push(`signal(() => ${c})`)):typeof c=="string"?o+=` ${l}="${c}"`:(o+=` ${l}=\${${a.length}}`,a.push(String(c)))}if(o+=">",n.length>0)for(let l of n)typeof l=="string"?o+=l:(o+=`\${${a.length}}`,a.push(String(l)));return o+=`</${e}>`,`${s}\`${o}\`${a.length>0?`, ${a.join(", ")}`:""}`}function ve(e){return e=e.replace(/jsx\('([^']+)',\s*{},\s*"([^"]+)"\s*\)/g,(t,n,i)=>`_$staticNode('${n}', '${i}')`),e}function ut(e){return e}function we(e){let t=[],n=0;return e=e.replace(/jsx\('([^']+)',\s*{([^}]*)},\s*([^)]*)\)/g,(i,s,o,a)=>{if(!o.includes("()")&&!o.includes("=>")){let l=`_$static${n++}`;return t.push(`const ${l} = ${i};`),l}return i}),t.length>0?t.join(`
|
|
1
|
+
"use strict";var hn=Object.create;var oe=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var En=Object.getOwnPropertyNames;var Sn=Object.getPrototypeOf,vn=Object.prototype.hasOwnProperty;var b=(e,t)=>()=>(e&&(t=e(e=0)),t);var at=(e,t)=>{for(var n in t)oe(e,n,{get:t[n],enumerable:!0})},lt=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of En(t))!vn.call(e,o)&&o!==n&&oe(e,o,{get:()=>t[o],enumerable:!(i=xn(t,o))||i.enumerable});return e};var se=(e,t,n)=>(n=e!=null?hn(Sn(e)):{},lt(t||!e||!e.__esModule?oe(n,"default",{value:e,enumerable:!0}):n,e)),yn=e=>lt(oe({},"__esModule",{value:!0}),e);function pt(e,t){return e.replace(/\$(\d+)/g,(n,i)=>t[Number(i)]??n)}function In(e,t){return typeof t=="string"?{module:t,export:e}:t}function ut(e=[]){let t=new Map,n=[],i=[];for(let a of e){if(!wn(a)){i.push(a);continue}for(let[l,c]of Object.entries(a.components)){let p=In(l,c),f=t.get(l);if(f&&f.module!==p.module){let u=n.find(x=>x.name===l);u?u.modules.push(p.module):n.push({name:l,modules:[f.module,p.module]});continue}t.set(l,p)}}let o=new Map;return{resolve:a=>{if(o.has(a))return o.get(a);let l=t.get(a);if(!l)for(let c of i){let p=a.match(new RegExp(c.match.source,c.match.flags.replace("g","")));if(p){l={module:pt(c.module,p),export:c.export?pt(c.export,p):a};break}}return o.set(a,l),l},names:()=>[...t.keys()],conflicts:()=>n}}var wn,ft=b(()=>{"use strict";wn=e=>"components"in e});function dt(e={}){let{controlFlowModule:t="@fluixi/dom",coreModule:n="@fluixi/core",routerModule:i="@fluixi/core/router-next"}=e,o={};for(let s of G)o[s]=t;for(let s of z)o[s]=n;for(let s of B)o[s]=i;return o}var G,z,B,Ur,Re,Ce=b(()=>{"use strict";G=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],z=["Suspense","SuspenseList","Await"],B=["Router","Outlet","Redirect","Link"],Ur=[...G,...z,...B],Re=new Set([...G,...z])});function Z(e){return e.startsWith("load:")}function V(e,t){let n=e.slice(5);if(!mt.has(n))throw new $(`Unknown load strategy 'load:${n}'. Expected one of ${[...mt].join(", ")}.`);switch(n){case"eager":return X;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?kn(t):[...Nn]};case"media":if(!t)throw new $(`'load:media' needs a query, e.g. load:media="(min-width: 1024px)".`);return{kind:"media",query:t};default:throw new $(`Unhandled load strategy '${n}'.`)}}function kn(e){let t=e.split(/[\s,]+/).map(n=>n.trim()).filter(Boolean);if(t.length===0)throw new $("'load:interaction' was given no event names.");return t}function P(e){return e.kind!=="eager"&&e.kind!=="never"}var X,Nn,mt,$,H=b(()=>{"use strict";X={kind:"eager"},Nn=["pointerdown","focusin","keydown"],mt=new Set(["eager","idle","visible","interaction","media","never"]),$=class extends Error{}});function we(e,t={}){let{resolver:n,isBound:i,modules:o,strategyFor:s}=t,a=dt(o),l=new Map,c=new Set,p=u=>{let{name:x}=u;if(!x||x.includes(".")||i?.(x))return;let R=f(x);if(!R){c.add(x);return}let C=R.origin==="builtin"&&Re.has(x)?X:s?.(u)??X;u.source={...R,loading:C},l.set(x,u.source)},f=u=>{if(Re.has(u))return{module:a[u],export:u,origin:"builtin"};let x=n?.resolve(u);if(x)return{module:x.module,export:x.export,origin:"rule"};if(B.includes(u))return{module:a[u],export:u,origin:"builtin"}};return le(e,u=>{u.kind==="component"&&p(u)}),{resolved:l,unresolved:[...c]}}function le(e,t){let n=Array.isArray(e)?e:[e];for(let i of n){t(i);let o=i.children;o&&le(o,t)}}var Ie=b(()=>{"use strict";Ce();H()});function Ne(e){let t=[];le(e,s=>{s.kind==="component"&&s.source&&t.push(s)});let n=new Set,i=new Set;for(let s of t){let{module:a,loading:l}=s.source;l.kind==="eager"&&n.add(a),l.kind==="never"&&i.add(a)}let o=new Map;for(let s of t){let a=s.source;P(a.loading)&&n.has(a.module)&&(a.loading={kind:"eager"},o.set(a.module,(o.get(a.module)??0)+1))}return{collapsed:o,conflicted:[...i].filter(s=>n.has(s))}}var gt=b(()=>{"use strict";H();Ie()});function ke(e){return Ln.has(e)}function xt(e){return ht[e]??e}function K(e){return e.kind!=="attr"||e.expr!==void 0||e.name.includes(":")?!1:!Tn.has(e.name)}function Me(e){if(!e.static||ke(e.tag))return!1;for(let t of e.props)if(!K(t))return!1;for(let t of e.children)if(t.kind!=="text"&&!(t.kind==="element"&&Me(t)))return!1;return!0}function Y(e){let t=e.props.map(Jn).filter(Boolean).join(""),n=`<${e.tag}${t}>`;return Mn.has(e.tag)?n:`${n}${e.children.map($n).join("")}</${e.tag}>`}function $n(e){if(e.kind==="text")return jn(e.value);if(e.kind!=="element")throw new Error(`serializeStatic: unexpected ${e.kind}`);return Y(e)}function Jn(e){let t=ht[e.name]??e.name,n=e.literal;return n===!0||n===void 0?` ${t}`:n===!1||n===null?"":` ${t}="${Pn(String(n))}"`}function Pn(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function jn(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var Mn,ht,Tn,Ln,Te=b(()=>{"use strict";Mn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ht={className:"class",htmlFor:"for"},Tn=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),Ln=new Set(["script","style","textarea","title"])});function pe(e){return e.kind==="expr"||e.kind==="component"||e.kind==="control"}function On(e){return e.kind==="text"||e.kind==="element"&&Et(e)}function Et(e){return e.svg||ke(e.tag)||!e.props.every(t=>K(t))?!1:e.children.every(t=>On(t)||pe(t))}function ce(e){if(pe(e))return!0;let t=e.children;return t?t.some(ce):!1}function St(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"||St(t))}function vt(e){if(!Et(e)||!St(e)||!e.children.some(ce))return null;let t=[],n=[],i=0,o=a=>{let l=`_n$${i++}`;return t.push({ref:l,expr:a}),l};return s(e,"_el$"),{html:An(e),tag:e.tag,steps:t,holes:n};function s(a,l){let c=-1;a.children.forEach((f,u)=>{ce(f)&&(c=u)});let p=null;for(let f=0;f<=c;f++){let u=a.children[f],x=p?`${p}.nextSibling`:`${l}.firstChild`;if(pe(u)){let C=o(x),I=o(`holeEnd(${C})`);n.push({parentRef:l,startRef:C,endRef:I,node:u}),p=I;continue}let R=o(x);u.kind==="element"&&ce(u)&&s(u,R),p=R}}}function An(e){return Y(yt(e)).split(bt).join(Fn+Xn)}function yt(e){return{...e,children:e.children.map(t=>pe(t)?{kind:"text",value:bt}:t.kind==="element"?yt(t):t)}}var Fn,Xn,bt,Rt=b(()=>{"use strict";Te();Fn="<!--fx-->",Xn="<!--fx/-->";bt="\0fx-hole\0"});var Le,oi,Ct=b(()=>{"use strict";Le={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},oi={version:2,module:"@fluixi/dom",symbols:[...Le.symbols,"template","cloneTemplate","walk"]}});function _n(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function It(e){return _n(e)?e:JSON.stringify(e)}function zn(e){return e.expr!==void 0?e.reactive?`() => (${e.expr})`:`(${e.expr})`:JSON.stringify(e.literal??!0)}function Bn(e){return e.expr!==void 0?`(${e.expr})`:JSON.stringify(e.literal??!0)}function Vn(e,t,n){let i=e.filter(l=>l.kind==="spread"),s=e.filter(l=>l.kind!=="spread").map(l=>`${It(l.name)}: ${zn(l)}`);t!=null&&s.push(`children: ${t}`);let a=`{ ${s.join(", ")} }`;return i.length>0?(n.add("mergeProps"),`mergeProps(${i.map(l=>l.expr).join(", ")}, ${a})`):a}function Nt(e,t,n){return e.length===1?Q(e[0],t,n):`[${e.map(i=>Q(i,t,n)).join(", ")}]`}function wt(e,t,n,i,o){i.add("createMemo"),i.add("createComponent");let s=t.filter(p=>p.kind==="spread"),l=t.filter(p=>p.kind!=="spread").map(p=>`get ${It(p.name)}() { return ${Bn(p)}; }`);n.length>0&&l.push(`get children() { return ${Nt(n,i,o)}; }`);let c=`{ ${l.join(", ")} }`;return s.length>0&&(i.add("mergeProps"),c=`mergeProps(${s.map(p=>p.expr).join(", ")}, ${c})`),`createMemo(() => createComponent(${e}, ${c}))`}function Hn(e,t){let n=xt(t.name),i=t.literal;return i===!0||i===void 0?`${e}.setAttribute(${JSON.stringify(n)}, "");`:i===!1||i===null?"":`${e}.setAttribute(${JSON.stringify(n)}, ${JSON.stringify(String(i))});`}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":Nt(e.children,t,n);case"component":return wt(e.name,e.props,e.children,t,n);case"control":{let i=Dn[e.control]??e.control;return t.add(i),wt(i,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:Y(e),tag:e.tag,svg:!1}),`templateNode(${l}, ${JSON.stringify(e.tag)})`}if(n&&kt){let l=vt(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 f of l.steps)p.push(`const ${f.ref} = ${f.expr};`);for(let f of l.holes)p.push(`insert(${f.parentRef}, holeScope(${f.startRef}, () => (${Q(f.node,t,n)})), ${f.endRef}, holeContent(${f.startRef}, ${f.endRef}));`);return p.push("return _el$;"),`(() => { ${p.join(" ")} })()`}}t.add("createNativeElement");let i=JSON.stringify(e.tag),o="_el$",s=[],a=e.svg?`${i}, true`:i;if(s.push(`const ${o} = createNativeElement(${a});`),e.props.length>0)if(!e.svg&&e.props.every(K))for(let l of e.props)s.push(Hn(o,l));else{t.add("spread");let l=e.svg?", isSVG: true":"";s.push(`spread({ element: ${o}, props: ${Vn(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(${o}, ${c}, null);`:`insert(${o}, ${c});`)}return s.push(`return ${o};`),`(() => { ${s.join(" ")} })()`}}}function ee(e,t){if(!t||t.length===0)return e;let n=new Map(t.map(i=>[i.id,JSON.stringify(i.html)]));return e.replace(/_tmpl\$\d+/g,i=>n.get(i)??i)}var Dn,kt,j,ue=b(()=>{"use strict";Rt();Te();Ct();Dn={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};kt=!1;j={name:"imperative",contract:Le,emit(e,t){let n=new Set,i=t?.templateClone!==!1?[]:void 0;return kt=t?.partialTemplates===!0,{code:Q(e,n,i),imports:Array.from(n),templates:i}}}});function Un(e){return Wn(e,{concise:!0}).code}function qn(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function Tt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function $t(e,t,n={}){let i=e.quasi,o=i.expressions.map(l=>{let c=l;return{node:c,code:F(c,t),reactive:k(c)}}),s=Gn(i),{root:a}=(0,Lt.parseTemplate)(s,{svg:n.svg});return new Je(o,t).lowerRoot(a.children)}function Gn(e){let t=[];return e.quasis.forEach((n,i)=>{let o=n.value.cooked??n.value.raw;if(t.push({kind:"static",text:o,start:n.start??0}),i<e.expressions.length){let s=e.expressions[i];t.push({kind:"hole",index:i,start:s.start??0,end:s.end??0})}}),t}var te,$e,Lt,Wn,Mt,Je,Jt=b(()=>{"use strict";te=require("@babel/core"),$e=se(require("@babel/generator"),1),Lt=require("@fluixi/template-parser");H();ue();Pe();Wn=$e.default.default??$e.default;Mt=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);Je=class{constructor(t,n){this.holes=t;this.used=n}hole(t){return this.holes[t]??{node:te.types.identifier("undefined"),code:"undefined",reactive:!1}}emit(t){let{code:n,imports:i,templates:o}=j.emit(t,{});for(let s of i)this.used.add(s);return ee(n,o)}lowerRoot(t){let n=this.lowerChildren(t);return n.length===1?n[0]:{kind:"fragment",children:n}}lowerChildren(t){let n=[];for(let i=0;i<t.length;i++){let o=t[i];if(o.kind==="Element"||o.kind==="Component"){let a=o.attributes.find(l=>l.kind==="IfDirective");if(a&&a.kind==="IfDirective"){let l=i+1;l<t.length&&this.isBlankText(t[l])&&l++;let c=t[l],p=c&&(c.kind==="Element"||c.kind==="Component")&&c.attributes.some(f=>f.kind==="ElseDirective");n.push(this.lowerIf(o,a.hole,p?c:null)),p&&(i=l);continue}if(o.attributes.some(l=>l.kind==="EachDirective")){n.push(this.lowerEach(o));continue}}let s=this.lowerNode(o);s&&n.push(s)}return n}isBlankText(t){return t.kind==="Text"&&!t.raw&&fe(t.value)===""}lowerNode(t){switch(t.kind){case"Text":{if(t.raw)return{kind:"text",value:t.value};let n=fe(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(i=>i.kind==="Attribute"&&i.name==="is");if(t.tag==="component"&&n&&n.value&&n.value.kind==="hole"){let i=t.attributes.filter(s=>s!==n),o=this.lowerComponent({...t,kind:"Component",tag:"Dynamic",tagHole:null,attributes:i});return o.props.unshift({name:"component",kind:"attr",expr:`() => (${this.hole(n.value.hole).code})`}),o}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,i=this.lowerAttributes(t.attributes),{slots:o,rest:s}=this.partitionSlots(t.children);for(let[c,p]of o){let f=p.length===1?p[0]:{kind:"fragment",children:p},u={name:c,kind:"attr",expr:this.emit(f),jsxElement:!0},x=i.findIndex(R=>R.name===c);x>=0?i[x]=u:i.push(u)}let a=t.attributes.find(c=>c.kind==="LoadDirective"),l=a?V(`load:${a.strategy}`,a.modifier):void 0;return{kind:"component",name:n,props:i,children:this.lowerChildren(s),...l?{load:l}:{}}}partitionSlots(t){let n=new Map,i=[];for(let o of t){if(o.kind==="Element"||o.kind==="Component"){let s=o.attributes.find(a=>a.kind==="Attribute"&&a.name==="slot");if(s&&s.value&&s.value.kind==="static"){let a={...o,attributes:o.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}}i.push(o)}return{slots:n,rest:i}}lowerIf(t,n,i){let o=this.hole(n),s=[{name:"when",kind:"attr",expr:o.code,reactive:o.reactive}];if(i){let l=this.stripAndLower(i,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 i=this.hole(n.hole),o=[{name:"each",kind:"attr",expr:i.code,reactive:i.reactive}];if(n.key){let c="static"in n.key?`(item) => item[${JSON.stringify(n.key.static)}]`:this.hole(n.key.hole).code;o.push({name:"by",kind:"attr",expr:c})}let s=this.itemArrow(t),a;if(s){let c=s.body,p={kind:"expr",code:F(c,this.used),reactive:k(c)},f=this.rebuildWithChildren(t,[p]);a=`(${s.params.map(u=>Un(u)).join(", ")}) => (${this.emit(f)})`}else{let c=this.stripAndLower(t,p=>p.kind==="EachDirective");a=`() => (${this.emit(c)})`}return{kind:"component",name:"For",props:o,children:[{kind:"expr",code:a,reactive:!1}]}}itemArrow(t){let n=t.children.filter(o=>!this.isBlankText(o));if(n.length!==1||n[0].kind!=="Expression")return null;let i=this.hole(n[0].hole).node;return te.types.isArrowFunctionExpression(i)&&!te.types.isBlockStatement(i.body)?i:null}stripAndLower(t,n){let i={...t,attributes:t.attributes.filter(o=>!n(o))};return i.kind==="Element"?this.lowerElement(i):this.lowerComponent(i)}rebuildWithChildren(t,n){let i=this.lowerAttributes(t.attributes.filter(o=>o.kind!=="EachDirective"));return t.kind==="Element"?{kind:"element",tag:t.tag,svg:t.namespace==="svg",props:i,children:n,static:!1}:{kind:"component",name:t.tag,props:i,children:n}}lowerAttributes(t){let n=[],i=[],o=!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);i.push(`${JSON.stringify(c.name)}: ${p.code}`),o=o||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 i.length>0&&n.push({name:"classList",kind:"attr",expr:`{ ${i.join(", ")} }`,reactive:o}),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(),i=this.hole(t.hole).code;if(!(t.syntax==="colon"||t.modifiers.length>0))return{name:"on"+Tt(t.name),kind:"event",event:{name:n,delegated:Mt.has(n)},expr:i};let s=this.wrapHandler(i,t.modifiers),a=this.eventOptions(t.modifiers),l=a?`[${s}, ${a}]`:s;return{name:"on:"+n,kind:"attr",expr:l}}wrapHandler(t,n){let i=n.includes("self")?"if (e.target !== e.currentTarget) return; ":"",o=[];return n.includes("prevent")&&o.push("e.preventDefault();"),n.includes("stop")&&o.push("e.stopPropagation();"),!i&&o.length===0?t:`(e) => { ${i}${o.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 i=t==="checked",o=i?"change":"input",s=i?"checked":"value",a=`(${n})`;return[{name:t,kind:"attr",expr:`${a}[0]()`,reactive:!0},{name:"on"+Tt(o),kind:"event",event:{name:o,delegated:Mt.has(o)},expr:`(e) => ${a}[1](e.target.${s})`}]}plainAttr(t){let n=t.value,i=t.name;t.name==="class"?i=n&&n.kind==="hole"&&te.types.isObjectExpression(this.hole(n.hole).node)?"classList":"className":t.name==="html"&&(i="innerHTML");let s={name:i,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 qn(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 Zn(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 de(e){let t=[],n=new Map,i=o=>{switch(o.kind){case"text":return!0;case"expr":return!1;case"component":case"control":for(let s of o.children)i(s);return!1;case"fragment":for(let s of o.children)i(s);return!1;case"element":{let s=!0;for(let l of o.children)i(l)||(s=!1);let a;for(let l of o.props)if(a=Zn(l),a)break;return!a&&!s&&(a=Kn(o)),o.static=!a,a?n.set(o,a):t.push(o),o.static}default:return!1}};for(let o of Array.isArray(e)?e:[e])i(o);return{staticElements:t,reasons:n}}function Kn(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"}var je=b(()=>{"use strict"});function me(e,t=new Set,n={}){let i=$t(e,t,n);return de(i),i}var Fe=b(()=>{"use strict";Jt();je()});function Ft(e){return Yn(e,{concise:!0}).code}function Qn(e,t){let n=m.types.cloneNode(e,!0),i=m.types.file(m.types.program([m.types.expressionStatement(n)])),o=!1,s=(a,l,c)=>{for(let p of c)t.add(p);a.replaceWith(m.template.expression(l,{placeholderPattern:!1,plugins:["typescript"]})()),a.skip(),o=!0};return(0,m.traverse)(i,{"JSXElement|JSXFragment"(a){let l=a.node,{code:c,imports:p,templates:f}=j.emit(De(l,t),{});s(a,ee(c,f),p)},TaggedTemplateExpression(a){let l=a.node.tag;if(!m.types.isIdentifier(l)||l.name!=="html"&&l.name!=="svg")return;let c=me(a.node,t,{svg:l.name==="svg"}),{code:p,imports:f,templates:u}=j.emit(c,{});s(a,ee(p,u),f)}}),o?i.program.body[0].expression:e}function F(e,t){return Ft(Qn(e,t))}function rr(e){if(m.types.isJSXIdentifier(e)){let t=e.name[0]!==e.name[0].toLowerCase();return{tag:e.name,component:t}}return m.types.isJSXMemberExpression(e)?{tag:Ft(e),component:!0}:m.types.isJSXNamespacedName(e)?{tag:`${e.namespace.name}:${e.name.name}`,component:!1}:{tag:"div",component:!1}}function Ae(e){return m.types.isJSXIdentifier(e)?e.name==="class"?"className":e.name:m.types.isJSXNamespacedName(e)?`${e.namespace.name}:${e.name.name}`:"unknown"}function k(e){return m.types.isCallExpression(e)||m.types.isOptionalCallExpression(e)?!0:m.types.isMemberExpression(e)||m.types.isOptionalMemberExpression(e)?!(!e.computed&&m.types.isIdentifier(e.property,{name:"children"})):m.types.isConditionalExpression(e)?k(e.test)||k(e.consequent)||k(e.alternate):m.types.isLogicalExpression(e)||m.types.isBinaryExpression(e)?k(e.left)||k(e.right):m.types.isTemplateLiteral(e)?e.expressions.some(t=>k(t)):m.types.isObjectExpression(e)?e.properties.some(t=>m.types.isObjectProperty(t)&&!t.computed&&k(t.value)):m.types.isArrayExpression(e)?e.elements.some(t=>t!=null&&!m.types.isSpreadElement(t)&&k(t)):!1}function ir(e,t){let n=Ae(e.name),i=tr.test(n),o=i||n.startsWith("on:"),a={name:n,kind:i?"event":"attr"};i&&(a.event={name:n.slice(2).toLowerCase(),delegated:nr.has(n.slice(2).toLowerCase())});let l=e.value;if(l==null)return a.literal=!0,a;if(m.types.isStringLiteral(l))return a.literal=l.value,a;if(m.types.isJSXExpressionContainer(l)&&!m.types.isJSXEmptyExpression(l.expression)){let c=l.expression;return m.types.isStringLiteral(c)||m.types.isNumericLiteral(c)||m.types.isBooleanLiteral(c)?(a.literal=c.value,a):(a.expr=F(c,t),a.reactive=o?!1:k(c),(m.types.isJSXElement(c)||m.types.isJSXFragment(c))&&(a.jsxElement=!0),a)}return a.literal=!0,a}function Pt(e,t){let n=e.value;return n==null?null:m.types.isStringLiteral(n)?JSON.stringify(n.value):m.types.isJSXExpressionContainer(n)&&!m.types.isJSXEmptyExpression(n.expression)?F(n.expression,t):null}function or(e,t){let n=[],i=[];for(let o of e){if(m.types.isJSXSpreadAttribute(o)){n.push({name:"",kind:"spread",expr:F(o.argument,t)});continue}if(!m.types.isJSXAttribute(o)||Z(Ae(o.name)))continue;let s=m.types.isJSXNamespacedName(o.name)?o.name.namespace.name:null;if(s==="use"){let a=o.name.name.name;t.add(a);let l=Pt(o,t);i.push(l!=null?`[${a}, () => (${l})]`:`[${a}]`);continue}if(s==="oncapture"){let a=o.name.name.name.toLowerCase(),l=Pt(o,t)??"undefined";n.push({name:"on:"+a,kind:"attr",expr:`[${l}, { capture: true }]`});continue}n.push(ir(o,t))}return i.length>0&&n.push({name:"use",kind:"attr",expr:`[${i.join(", ")}]`}),n}function fe(e){let t=e.split(/\r\n|\n|\r/),n=0;for(let o=0;o<t.length;o++)/[^ \t]/.test(t[o])&&(n=o);let i="";for(let o=0;o<t.length;o++){let s=t[o].replace(/\t/g," ");o!==0&&(s=s.replace(/^ +/,"")),o!==t.length-1&&(s=s.replace(/ +$/,"")),s&&(o!==n&&(s+=" "),i+=s)}return i}function jt(e,t){let n=[];for(let i of e)if(m.types.isJSXText(i)){let o=fe(i.value);o&&n.push({kind:"text",value:o})}else if(m.types.isJSXExpressionContainer(i)){if(!m.types.isJSXEmptyExpression(i.expression)){let o=i.expression;n.push({kind:"expr",code:F(o,t),reactive:k(o)})}}else m.types.isJSXElement(i)||m.types.isJSXFragment(i)?n.push(Oe(i,t)):m.types.isJSXSpreadChild(i)&&n.push({kind:"expr",code:F(i.expression,t),reactive:!1});return n}function De(e,t=new Set){let n=Oe(e,t);return de(n),n}function Oe(e,t){if(m.types.isJSXFragment(e))return{kind:"fragment",children:jt(e.children,t)};let{tag:n,component:i}=rr(e.openingElement.name),o=or(e.openingElement.attributes,t),s=jt(e.children,t);if(i){let a=sr(e.openingElement.attributes);return{kind:"component",name:n,props:o,children:s,...a?{load:a}:{}}}return{kind:"element",tag:n,svg:er.has(n),props:o,children:s,static:!1}}function sr(e){for(let t of e){if(!m.types.isJSXAttribute(t))continue;let n=Ae(t.name);if(Z(n)){if(t.value&&!m.types.isStringLiteral(t.value))throw new $(`'${n}' needs a literal value, not an expression — the strategy is compile-time.`);return V(n,t.value?t.value.value:null)}}}var m,Xe,Yn,er,tr,nr,Pe=b(()=>{"use strict";m=require("@babel/core"),Xe=se(require("@babel/generator"),1);ue();Fe();je();H();Yn=Xe.default.default??Xe.default;er=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),tr=/^on[A-Z]/,nr=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"])});function lr(e,t,n){let{runtime:i,pragma:o,development:s,autoShow:a=!0}=n;return i==="automatic"?re(e,t,s,a):Er(e,t,o)}function Ot(e,t,n){return t.length>0?(n.needsMergeProps=!0,r.types.callExpression(r.types.identifier("mergeProps"),[...t,r.types.objectExpression(e)])):r.types.objectExpression(e)}function Vt(e){return e.length===1?e[0]:r.types.arrayExpression(e)}function pr(e,t,n,i,o,s){if(!t){let u=[...n];return o.length>0&&u.push(r.types.objectMethod("get",r.types.identifier("children"),[],r.types.blockStatement([r.types.returnStatement(Vt(o))]))),Ht(e,Ot(u,i,s),s)}let a=e.value,l=cr.has(a),c=r.types.identifier("_el$"),p=[];s.needsCreateNativeElement=!0;let f=[e];if(l&&f.push(r.types.booleanLiteral(!0)),p.push(r.types.variableDeclaration("const",[r.types.variableDeclarator(c,r.types.callExpression(r.types.identifier("createNativeElement"),f))])),n.length>0||i.length>0){s.needsSpread=!0;let u=[r.types.objectProperty(r.types.identifier("element"),c),r.types.objectProperty(r.types.identifier("props"),Ot(n,i,s))];l&&u.push(r.types.objectProperty(r.types.identifier("isSVG"),r.types.booleanLiteral(!0))),p.push(r.types.expressionStatement(r.types.callExpression(r.types.identifier("spread"),[r.types.objectExpression(u)])))}if(o.length>0){s.needsInsert=!0;for(let u of o){let R=r.types.isArrowFunctionExpression(u)||r.types.isFunctionExpression(u)||r.types.isCallExpression(u)&&r.types.isIdentifier(u.callee)&&u.callee.name==="createMemo"?[r.types.cloneNode(c),u,r.types.nullLiteral()]:[r.types.cloneNode(c),u];p.push(r.types.expressionStatement(r.types.callExpression(r.types.identifier("insert"),R)))}}return p.push(r.types.returnStatement(c)),r.types.callExpression(r.types.arrowFunctionExpression([],r.types.blockStatement(p)),[])}function ur(e,t){let n=null;if(t.value)if(r.types.isStringLiteral(t.value))n=t.value.value;else throw new $(`'${e}' needs a literal value, not an expression — the strategy is compile-time.`);return V(e,n)}function fr(e){let t=[r.types.objectProperty(r.types.identifier("kind"),r.types.stringLiteral(e.kind))];return e.kind==="visible"&&e.rootMargin&&t.push(r.types.objectProperty(r.types.identifier("rootMargin"),r.types.stringLiteral(e.rootMargin))),e.kind==="interaction"&&t.push(r.types.objectProperty(r.types.identifier("events"),r.types.arrayExpression(e.events.map(n=>r.types.stringLiteral(n))))),e.kind==="media"&&t.push(r.types.objectProperty(r.types.identifier("query"),r.types.stringLiteral(e.query))),r.types.objectExpression(t)}function dr(e,t){return!P(e)||!P(t)?X:e}function Ht(e,t,n){r.types.isIdentifier(e)&&he.has(e.name)&&(n.controlFlowComponents.add(e.name),n.needsControlFlowImport=!0);let i=!1;if(r.types.isIdentifier(e)&&!he.has(e.name)&&n.componentResolver){let o=n.componentResolver.resolve(e.name);if(o){let s=n.pendingLoad??X,a=n.resolvedComponents.has(e.name);if(P(s)&&!a){let l=n.deferredComponents.get(e.name),c=l?dr(l.strategy,s):s;P(c)?n.deferredComponents.set(e.name,{...o,strategy:c}):(n.deferredComponents.delete(e.name),n.resolvedComponents.set(e.name,o))}else n.deferredComponents.delete(e.name),n.resolvedComponents.set(e.name,o);i=!0}}return n.pendingLoad=void 0,!i&&r.types.isIdentifier(e)&&ge.has(e.name)&&(n.controlFlowComponents.add(e.name),n.needsControlFlowImport=!0),n.backend==="imperative"?(n.needsCreateComponent=!0,n.needsCreateMemo=!0,r.types.callExpression(r.types.identifier("createMemo"),[r.types.arrowFunctionExpression([],r.types.callExpression(r.types.identifier("createComponent"),[e,t]))])):r.types.callExpression(r.types.identifier("jsx"),[e,t])}function Wt(e,t,n){if(!t||t.length===0)return e;let i=new Map;for(let o of t){let s=`${o.svg?"svg:":""}${o.html}`,a=n.staticTemplates.get(s);a||(a=`_tmpl$${n.staticTemplates.size}`,n.staticTemplates.set(s,a)),i.set(o.id,a)}return e.replace(/_tmpl\$\d+/g,o=>i.get(o)??o)}function At(e,t){let n=new Set,i=De(e,n);we(i,{resolver:t.componentResolver,modules:{controlFlowModule:t.controlFlowModule,coreModule:t.libModule,routerModule:t.routerModule},strategyFor:c=>c.load}),Ne(i);let{code:o,imports:s,templates:a}=j.emit(i,{templateClone:t.templateClone,partialTemplates:t.partialTemplates});for(let c of s)n.add(c);for(let c of n)t.irImports.add(c);ze(i,t);let l=Wt(o,a,t);return r.template.expression(l,{placeholderPattern:!1,plugins:["typescript"]})()}function mr(e){let t=new Map,n=[];for(let i of e){let o=i.source.value;if(!i.specifiers.every(l=>r.types.isImportSpecifier(l))){n.push(i);continue}let a=t.get(o);if(!a){let l=new Set(i.specifiers.map(c=>c.local.name));t.set(o,{decl:i,names:l}),n.push(i);continue}for(let l of i.specifiers)a.names.has(l.local.name)||(a.names.add(l.local.name),a.decl.specifiers.push(l))}return n}function gr(e,t){let n=new Set,i=r.types.isIdentifier(e.tag)&&e.tag.name==="svg",o=me(e,n,{svg:i});we(o,{resolver:t.componentResolver,modules:{controlFlowModule:t.controlFlowModule,coreModule:t.libModule,routerModule:t.routerModule},strategyFor:p=>p.load}),Ne(o);let{code:s,imports:a,templates:l}=j.emit(o,{templateClone:t.templateClone,partialTemplates:t.partialTemplates});for(let p of a)n.add(p);for(let p of n)t.irImports.add(p);ze(o,t),t.hasLitIR=!0;let c=r.template.expression(Wt(s,l,t),{placeholderPattern:!1,plugins:["typescript"]})();return hr(c,e),c}function hr(e,t){if(!t.loc)return;let n=new Set,i=o=>{if(!n.has(o)){n.add(o),o.loc||(o.loc=t.loc,o.start=t.start,o.end=t.end);for(let s of r.types.VISITOR_KEYS[o.type]??[]){let a=o[s];if(Array.isArray(a))for(let l of a)l&&typeof l=="object"&&"type"in l&&i(l);else a&&typeof a=="object"&&"type"in a&&i(a)}}};i(e)}function ze(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)ze(n,t)}function xr(e){return e.map(t=>{if(r.types.isObjectProperty(t)){let n=t.key,i=t.computed,o=t.value;return r.types.objectMethod("get",n,[],r.types.blockStatement([r.types.returnStatement(o)]),i)}return t})}function re(e,t,n,i=!0){let o=e.openingElement,s=e.children,a=Ut(o.name),l=r.types.isJSXIdentifier(o.name)&&/^[a-z]/.test(o.name.name),c=Gt(o.attributes,t,l,r.types.isJSXIdentifier(o.name)?o.name.name:""),p=c.props,f=c.spreads;l||(p=xr(p));let u=Be(s,t,i);if(t.backend==="imperative")return pr(a,l,p,f,u,t);if(u.length>0){let I=u.length===1?u[0]:r.types.arrayExpression(u);p.push(r.types.objectProperty(r.types.identifier("children"),I))}let x;if(f.length>0){let I=p.length>0?r.types.objectExpression(p):r.types.objectExpression([]);t.needsMergeProps=!0,x=r.types.callExpression(r.types.identifier("mergeProps"),[...f,I])}else x=r.types.objectExpression(p);let R=n?"jsxDEV":u.length>1?"jsxs":"jsx",C=[a,x];return n&&C.push(r.types.identifier("undefined"),r.types.booleanLiteral(!1),r.types.identifier("undefined"),r.types.identifier("undefined")),r.types.callExpression(r.types.identifier(R),C)}function Er(e,t,n){let i=e.openingElement,o=e.children,s=Ut(i.name),a=r.types.isJSXIdentifier(i.name)&&/^[a-z]/.test(i.name.name),{props:l,spreads:c}=Gt(i.attributes,t,a,r.types.isJSXIdentifier(i.name)?i.name.name:""),p=Be(o,t,t.autoShow??!0),f;if(c.length>0){let x=l.length>0?r.types.objectExpression(l):r.types.objectExpression([]);t.needsMergeProps=!0,f=r.types.callExpression(r.types.identifier("mergeProps"),[...c,x])}else f=l.length>0?r.types.objectExpression(l):r.types.nullLiteral();let u=[s,f,...p];return r.types.callExpression(r.types.identifier(n),u)}function xe(e,t,n){let{runtime:i,pragmaFrag:o,development:s}=n,a=Be(e.children,t,t.autoShow??!0);if(t.backend==="imperative")return a.length===0?r.types.nullLiteral():Vt(a);if(i==="automatic"){let l=s?"jsxDEV":a.length>1?"jsxs":"jsx",c=r.types.objectExpression([r.types.objectProperty(r.types.identifier("children"),a.length===1?a[0]:r.types.arrayExpression(a))]),p=[r.types.identifier("Fragment"),c];return s&&p.push(r.types.identifier("undefined"),r.types.booleanLiteral(!1),r.types.identifier("undefined"),r.types.identifier("undefined")),r.types.callExpression(r.types.identifier(l),p)}else return r.types.callExpression(r.types.identifier(o),a)}function Ut(e){if(r.types.isJSXIdentifier(e)){let t=e.name;return t[0]===t[0].toLowerCase()?r.types.stringLiteral(t):r.types.identifier(t)}return r.types.isJSXMemberExpression(e)?qt(e):r.types.isJSXNamespacedName(e)?r.types.stringLiteral(`${e.namespace.name}:${e.name.name}`):r.types.stringLiteral("div")}function qt(e){let t;return r.types.isJSXIdentifier(e.object)?t=r.types.identifier(e.object.name):t=qt(e.object),r.types.memberExpression(t,r.types.identifier(e.property.name))}function Sr(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)}function Gt(e,t,n=!0,i=""){let o=[],s=[],a=ar[i];t.pendingLoad=void 0;for(let l of e)if(r.types.isJSXSpreadAttribute(l))s.push(l.argument);else if(r.types.isJSXAttribute(l)){let c=vr(l.name);if(Z(c)){t.pendingLoad=ur(c,l);continue}let p=yr(l.value,t,c,n);if(zt.test(c)){let D=c.slice(2).toLowerCase();Bt.includes(D)&&t.delegatedEvents.add(D)}let f=Sr(c)?r.types.identifier(c):r.types.stringLiteral(c),u=l.value,x=r.types.isJSXElement(u)||r.types.isJSXFragment(u)||r.types.isJSXExpressionContainer(u)&&(r.types.isJSXElement(u.expression)||r.types.isJSXFragment(u.expression)),R=!n&&c===a,C=r.types.isJSXExpressionContainer(u)&&!r.types.isJSXEmptyExpression(u.expression)?u.expression:null,I=!n&&!!C&&Zt(C,c);!n&&x||R||I?o.push(r.types.objectMethod("get",f,[],r.types.blockStatement([r.types.returnStatement(p)]))):o.push(r.types.objectProperty(f,p))}return{props:o,spreads:s}}function vr(e){return r.types.isJSXIdentifier(e)?e.name==="class"?"className":e.name:r.types.isJSXNamespacedName(e)?`${e.namespace.name}:${e.name.name}`:"unknown"}function yr(e,t,n="",i=!0){if(e===null)return r.types.booleanLiteral(!0);if(r.types.isStringLiteral(e))return e.value.includes(`
|
|
2
|
+
`)?r.types.stringLiteral(e.value.replace(/\s+/g," ").trim()):e;if(r.types.isJSXExpressionContainer(e)){if(r.types.isJSXEmptyExpression(e.expression))return r.types.booleanLiteral(!0);let o=e.expression;return i&&Zt(o,n)?r.types.arrowFunctionExpression([],o):o}return r.types.isJSXElement(e)?re(e,t,!1,t.autoShow??!0):r.types.isJSXFragment(e)?xe(e,t,{runtime:"automatic",pragmaFrag:"Fragment",development:!1}):r.types.booleanLiteral(!0)}function Zt(e,t){return zt.test(t)||t.startsWith("on:")||t==="ref"||t.startsWith("use:")||r.types.isArrowFunctionExpression(e)||r.types.isFunctionExpression(e)||r.types.isIdentifier(e)||r.types.isStringLiteral(e)||r.types.isNumericLiteral(e)||r.types.isBooleanLiteral(e)||r.types.isNullLiteral(e)?!1:!!(r.types.isCallExpression(e)||r.types.isOptionalCallExpression(e)||r.types.isMemberExpression(e)||r.types.isOptionalMemberExpression(e)||r.types.isLogicalExpression(e)||r.types.isConditionalExpression(e)||r.types.isBinaryExpression(e)||r.types.isUnaryExpression(e)||r.types.isTemplateLiteral(e)||r.types.isObjectExpression(e)||r.types.isArrayExpression(e))}function br(e){let t=e.split(/\r\n|\n|\r/),n=0;for(let o=0;o<t.length;o++)/[^ \t]/.test(t[o])&&(n=o);let i="";for(let o=0;o<t.length;o++){let s=t[o].replace(/\t/g," ");o!==0&&(s=s.replace(/^ +/,"")),o!==t.length-1&&(s=s.replace(/ +$/,"")),s&&(o!==n&&(s+=" "),i+=s)}return i}function Be(e,t,n=!0){let i=[];for(let o of e)if(r.types.isJSXText(o)){let s=br(o.value);s&&i.push(r.types.stringLiteral(s))}else if(r.types.isJSXExpressionContainer(o)){if(!r.types.isJSXEmptyExpression(o.expression)){let s=o.expression;if(n){let a=Rr(s,t)??Cr(s,t);if(a){i.push(a);continue}}else{let a=wr(s,t);if(a){i.push(a);continue}}Nr(s)?i.push(r.types.arrowFunctionExpression([],s)):i.push(s)}}else r.types.isJSXElement(o)?i.push(re(o,t,!1,t.autoShow??!0)):r.types.isJSXFragment(o)?i.push(xe(o,t,{runtime:"automatic",pragmaFrag:"Fragment",development:!1})):r.types.isJSXSpreadChild(o)&&i.push(o.expression);return i}function Rr(e,t){if(!r.types.isArrowFunctionExpression(e)||e.params.length!==0||e.async)return null;let n=e.body;if(r.types.isLogicalExpression(n)&&n.operator==="&&"){let i=J(n.right);if(i)return ne(O(n.left),i,null,t)}if(r.types.isConditionalExpression(n)){let i=J(n.consequent);if(i){let o=Ve(n.alternate,t);return ne(O(n.test),i,o,t,!0)}}return null}function Cr(e,t){if(r.types.isLogicalExpression(e)&&e.operator==="&&"){let n=J(e.right);if(n)return ne(O(e.left),n,null,t)}if(r.types.isConditionalExpression(e)){let n=J(e.consequent);if(n){let i=Ve(e.alternate,t);return ne(O(e.test),n,i,t)}}return null}function wr(e,t){let n=r.types.isArrowFunctionExpression(e)&&e.params.length===0&&!e.async&&r.types.isExpression(e.body)?e.body:e;if(r.types.isConditionalExpression(n)){let i=O(n.test),s=J(n.consequent)??n.consequent,l=J(n.alternate)??n.alternate,c=r.types.conditionalExpression(i,s,l);return _e(n.consequent)||_e(n.alternate)?null:(t.needsCreateMemo=!0,r.types.callExpression(r.types.identifier("createMemo"),[r.types.arrowFunctionExpression([],c)]))}if(r.types.isLogicalExpression(n)&&n.operator==="&&"){let i=O(n.left),s=J(n.right)??n.right,a=r.types.logicalExpression("&&",i,s);return _e(n.right)?null:(t.needsCreateMemo=!0,r.types.callExpression(r.types.identifier("createMemo"),[r.types.arrowFunctionExpression([],a)]))}return null}function Ve(e,t){if(Ir(e))return null;let n=J(e);if(n)return Kt(n,t);if(r.types.isConditionalExpression(e)){let i=e,o=J(i.consequent);if(o){let s=Ve(i.alternate,t);return ne(O(i.test),o,s,t)}}return e}function Dt(e){return r.types.isJSXElement(e)||r.types.isJSXFragment(e)}function _e(e){let t=J(e);if(!t||!r.types.isJSXElement(t))return!1;let n=t.openingElement.name;return r.types.isJSXIdentifier(n)&&he.has(n.name)}function J(e){return Dt(e)?e:r.types.isArrowFunctionExpression(e)&&e.params.length===0&&!e.async&&Dt(e.body)?e.body:null}function O(e){return r.types.isArrowFunctionExpression(e)&&e.params.length===0&&!e.async&&r.types.isExpression(e.body)?e.body:e}function Ir(e){return r.types.isNullLiteral(e)||r.types.isIdentifier(e)&&e.name==="undefined"||r.types.isBooleanLiteral(e)&&e.value===!1}function Kt(e,t){return r.types.isJSXElement(e)?re(e,t,!1,t.autoShow??!0):xe(e,t,{runtime:"automatic",pragmaFrag:"Fragment",development:!1})}function ne(e,t,n,i,o=!1){i.controlFlowComponents.add("Show"),i.needsControlFlowImport=!0;let s=Kt(t,i),a=[r.types.objectProperty(r.types.identifier("when"),r.types.arrowFunctionExpression([],e)),r.types.objectProperty(r.types.identifier("children"),s)];return n&&a.push(r.types.objectProperty(r.types.identifier("fallback"),n)),Ht(r.types.identifier("Show"),r.types.objectExpression(a),i)}function Nr(e){return r.types.isMemberExpression(e)||r.types.isOptionalMemberExpression(e)?!(!e.computed&&r.types.isIdentifier(e.property,{name:"children"})):r.types.isCallExpression(e)||r.types.isOptionalCallExpression(e)?!0:r.types.isIdentifier(e)?!1:!!(r.types.isLogicalExpression(e)||r.types.isConditionalExpression(e)||r.types.isBinaryExpression(e)||r.types.isUnaryExpression(e)||r.types.isTemplateLiteral(e))}function Yt(e,t){let n=e.openingElement;if(!r.types.isJSXIdentifier(n.name))return!1;let i=n.name.name;if(i[0]!==i[0].toLowerCase())return!1;for(let o of n.attributes){if(r.types.isJSXSpreadAttribute(o))return!1;if(r.types.isJSXAttribute(o)){let s=o.value;if(r.types.isJSXExpressionContainer(s)&&!r.types.isStringLiteral(s.expression)&&!r.types.isNumericLiteral(s.expression))return!1}}for(let o of e.children)if(r.types.isJSXElement(o)&&!Yt(o,t)||r.types.isJSXExpressionContainer(o))return!1;return!0}function kr(e,t){let n=`_$static${t.staticCounter++}`,i=re(e,t,!1);return t.staticElements.set(n,i),r.types.identifier(n)}function Mr(e,t){let n=e.openingElement.name.name;return n==="Show"?Tr(e,t):n==="For"?Lr(e,t):null}function Tr(e,t){return null}function Lr(e,t){return null}var _t,r,he,Xt,ge,ar,zt,Bt,W,cr,He=b(()=>{"use strict";_t=require("@babel/helper-plugin-utils");ft();Ie();gt();H();Ce();r=require("@babel/core");Pe();Fe();ue();he=new Set([...G,...z]),Xt=new Set(z),ge=new Set(B),ar={Show:"when",For:"each",Index:"each",Match:"when"},zt=/^on[A-Z]/,Bt=["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave"],W=(0,_t.declare)((e,t={})=>{e.assertVersion(7);let{runtime:n="automatic",importSource:i="@fluixi/jsx",pragma:o="jsx",pragmaFrag:s="Fragment",development:a=!1,detectReactivity:l=!0,useLitHTML:c=!0,hoistStatics:p=!0,delegateEvents:f=!0,delegatedEvents:u=Bt,optimizeControlFlow:x=!0,sourceMaps:R=!0,signalModule:C="@fluixi/dom",controlFlowModule:I="@fluixi/dom",routerModule:D="@fluixi/core/router-next",reactiveModule:tt="@fluixi/reactive/signal",autoShowTransform:nt=!1,backend:L="imperative",codegen:q="inline",templateClone:rt=!0,partialTemplates:it=!0,format:ot="both",litTag:fn="html",resolve:dn=[]}=t,st=ut(dn),mn=ot==="lit"||ot==="both",gn={backend:L,codegen:q,irImports:new Set,libModule:"@fluixi/core",controlFlowModule:I,routerModule:D,templateClone:rt,partialTemplates:it,hasJSX:!1,hasReactivity:!1,hasLitHTML:!1,needsSignalImport:!1,needsControlFlowImport:!1,needsCreateMemo:!1,controlFlowComponents:new Set,resolvedComponents:new Map,deferredComponents:new Map,componentResolver:st,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,gn)},visitor:{ImportDeclaration(g,d){g.node.source.value==="@fluixi/core/rx"&&(g.node.source=r.types.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:st,delegatedEvents:new Set,staticElements:new Map,staticTemplates:new Map,autoShow:nt,staticCounter:0,libModule:"@fluixi/core",controlFlowModule:I,routerModule:D,templateClone:rt,partialTemplates:it,backend:L,codegen:q,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.types.importDeclaration([r.types.importSpecifier(r.types.identifier("signal"),r.types.identifier("signal"))],r.types.stringLiteral(C))),d.hasJSX||d.hasLitIR){if(d.irImports.size>0){let S=new Set(["Show","For","Index","Switch","Match","Dynamic","ErrorBoundary","Portal","Suspense"]),E=new Set(["createMemo","createEffect","createRenderEffect","createRoot","createSignal","onCleanup","batch","untrack"]),v=Array.from(d.irImports),w=y=>r.types.importSpecifier(r.types.identifier(y),r.types.identifier(y)),T=y=>!g.scope.hasBinding(y),_=v.filter(y=>E.has(y)&&T(y)),N=v.filter(y=>!S.has(y)&&!E.has(y)&&T(y)),ie=v.filter(y=>S.has(y)&&T(y));_.length>0&&h.push(r.types.importDeclaration(_.map(w),r.types.stringLiteral(tt))),N.length>0&&h.push(r.types.importDeclaration(N.map(w),r.types.stringLiteral(C))),ie.length>0&&h.push(r.types.importDeclaration(ie.map(w),r.types.stringLiteral(I)))}if(d.hasJSX&&L==="imperative"&&q!=="ir"){let E=[[!!d.needsCreateNativeElement,"createNativeElement"],[!!d.needsSpread,"spread"],[!!d.needsInsert,"insert"],[!!d.needsCreateComponent,"createComponent"],[!!d.needsMergeProps,"mergeProps"]].filter(([v,w])=>v&&!g.scope.hasBinding(w)).map(([,v])=>r.types.importSpecifier(r.types.identifier(v),r.types.identifier(v)));E.length>0&&h.push(r.types.importDeclaration(E,r.types.stringLiteral(C)))}else if(d.hasJSX&&n==="automatic"&&L!=="imperative"){let S=[r.types.importSpecifier(r.types.identifier("jsx"),r.types.identifier("jsx")),r.types.importSpecifier(r.types.identifier("jsxs"),r.types.identifier("jsxs")),r.types.importSpecifier(r.types.identifier("Fragment"),r.types.identifier("Fragment"))];a&&S.push(r.types.importSpecifier(r.types.identifier("jsxDEV"),r.types.identifier("jsxDEV"))),d.needsMergeProps&&S.push(r.types.importSpecifier(r.types.identifier("mergeProps"),r.types.identifier("mergeProps"))),h.push(r.types.importDeclaration(S,r.types.stringLiteral(i)))}if(d.needsCreateMemo&&!g.scope.hasBinding("createMemo")&&h.push(r.types.importDeclaration([r.types.importSpecifier(r.types.identifier("createMemo"),r.types.identifier("createMemo"))],r.types.stringLiteral(L==="imperative"?tt:d.libModule??"@fluixi/core"))),d.needsControlFlowImport&&d.controlFlowComponents.size>0){let S=Array.from(d.controlFlowComponents).filter(N=>!g.scope.hasBinding(N)),E=d.libModule??"@fluixi/core",v=S.filter(N=>ge.has(N)),w=S.filter(N=>Xt.has(N)),T=S.filter(N=>!Xt.has(N)&&!ge.has(N)),_=(N,ie)=>r.types.importDeclaration(N.map(y=>r.types.importSpecifier(r.types.identifier(y),r.types.identifier(y))),r.types.stringLiteral(ie));T.length>0&&h.push(_(T,I)),w.length>0&&h.push(_(w,E)),v.length>0&&h.push(_(v,D))}let M=[];if(d.deferredComponents.size>0){for(let[S,E]of d.deferredComponents)g.scope.hasBinding(S)||M.push(r.types.variableDeclaration("const",[r.types.variableDeclarator(r.types.identifier(S),r.types.callExpression(r.types.identifier("deferred"),[r.types.arrowFunctionExpression([],r.types.callExpression(r.types.import(),[r.types.stringLiteral(E.module)])),r.types.objectExpression([r.types.objectProperty(r.types.identifier("strategy"),fr(E.strategy)),r.types.objectProperty(r.types.identifier("export"),r.types.stringLiteral(E.export))])]))]));M.length>0&&!g.scope.hasBinding("deferred")&&h.push(r.types.importDeclaration([r.types.importSpecifier(r.types.identifier("deferred"),r.types.identifier("deferred"))],r.types.stringLiteral(d.libModule??"@fluixi/core")))}if(d.resolvedComponents.size>0){let S=new Map;for(let[E,v]of d.resolvedComponents){if(g.scope.hasBinding(E))continue;let w=S.get(v.module)??[];w.push({local:E,exported:v.export}),S.set(v.module,w)}for(let[E,v]of S)h.push(r.types.importDeclaration(v.map(({local:w,exported:T})=>T==="default"?r.types.importDefaultSpecifier(r.types.identifier(w)):r.types.importSpecifier(r.types.identifier(w),r.types.identifier(T))),r.types.stringLiteral(E)))}if(f&&d.delegatedEvents.size>0){h.push(r.types.importDeclaration([r.types.importSpecifier(r.types.identifier("delegateEvents"),r.types.identifier("delegateEvents"))],r.types.stringLiteral(L==="imperative"?C:"@fluixi/jsx")));let S=r.types.arrayExpression(Array.from(d.delegatedEvents).map(v=>r.types.stringLiteral(v))),E=r.types.expressionStatement(r.types.callExpression(r.types.identifier("delegateEvents"),[S]));g.node.body.unshift(E)}if(p&&d.staticElements.size>0){let S=[];d.staticElements.forEach((E,v)=>{S.push(r.types.variableDeclaration("const",[r.types.variableDeclarator(r.types.identifier(v),E)]))}),g.node.body.unshift(...S)}if(M.length>0&&g.node.body.unshift(...M),d.staticTemplates.size>0){let S=[];for(let[E,v]of d.staticTemplates){let T=E.startsWith("svg:")?E.slice(4):E;S.push(r.types.variableDeclaration("const",[r.types.variableDeclarator(r.types.identifier(v),r.types.stringLiteral(T))]))}g.node.body.unshift(...S)}}h.length>0&&g.node.body.unshift(...mr(h))}},JSXElement(g,d){if(d.hasJSX=!0,L==="imperative"&&q==="ir"){g.replaceWith(At(g.node,d));return}let h=g.node,M=h.openingElement;if(r.types.isJSXIdentifier(M.name)&&ge.has(M.name.name)&&!d.componentResolver?.resolve(M.name.name)&&(d.controlFlowComponents.add(M.name.name),d.needsControlFlowImport=!0),r.types.isJSXIdentifier(M.name)&&he.has(M.name.name)&&(d.controlFlowComponents.add(M.name.name),x)){let E=Mr(h,d);if(E){g.replaceWith(E);return}}if(p&&L!=="imperative"&&Yt(h,d)){let E=kr(h,d);if(E){g.replaceWith(E);return}}let S=lr(h,d,{runtime:n,pragma:o,development:a,detectReactivity:l,useLitHTML:c,autoShow:nt});g.replaceWith(S)},JSXFragment(g,d){if(d.hasJSX=!0,L==="imperative"&&q==="ir"){g.replaceWith(At(g.node,d));return}let h=xe(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.types.isIdentifier(h)&&(h.name==="createSignal"||h.name==="createStore"||h.name==="useContext"||h.name==="useLocation")&&(d.hasReactivity=!0)},JSXExpressionContainer(g){},TaggedTemplateExpression(g,d){if(mn&&L==="imperative"&&r.types.isIdentifier(g.node.tag)&&(g.node.tag.name===fn||g.node.tag.name==="svg")){g.replaceWith(gr(g.node,d));return}}}}});cr=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"])});var Qt=b(()=>{"use strict"});var en={};at(en,{babelPluginReactiveJSX:()=>$r,createPlugin:()=>Jr,createPreset:()=>Ee,default:()=>W,presets:()=>Pr});function Jr(e){return[W,e]}function Ee(e={}){return{plugins:[[W,{runtime:"automatic",importSource:"@fluixi/jsx",development:!1,detectReactivity:!0,useLitHTML:!0,hoistStatics:!0,delegateEvents:!0,optimizeControlFlow:!0,sourceMaps:!0,...e}]]}}var $r,Pr,tn=b(()=>{"use strict";He();Qt();He();$r=W;Pr={production:Ee({development:!1,hoistStatics:!0,delegateEvents:!0,optimizeControlFlow:!0}),development:Ee({development:!0,hoistStatics:!1,sourceMaps:!0}),minimal:Ee({detectReactivity:!1,useLitHTML:!1,hoistStatics:!1,delegateEvents:!1,optimizeControlFlow:!1})}});var Br={};at(Br,{analyzeProp:()=>Se,analyzeProps:()=>ve,createBabelPlugin:()=>U,createESBuildPlugin:()=>pn,createRollupPlugin:()=>cn,createTypeScriptTransformer:()=>sn,createVitePlugin:()=>an,createWebpackLoader:()=>ln,default:()=>zr,generateChildrenCode:()=>Ge,generateCreateElement:()=>rn,generateEventDelegation:()=>Qe,generateLitHTMLTemplate:()=>Ze,generatePropsCode:()=>qe,hoistStatic:()=>Ye,isLitTemplate:()=>nn,optimizeSpreads:()=>on,optimizeStatic:()=>Ke,serverFunctionsVitePlugin:()=>_r,shouldUseLitTemplate:()=>Ue,transform:()=>A,transformServerFunctions:()=>ae});module.exports=yn(Br);var ct=require("@babel/core"),bn="@fluixi/start/server-fn";function Rn(e){let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return(t>>>0).toString(16)}function Cn({types:e}){return{name:"fluixi-server-functions",visitor:{Program:{enter(t,n){n.fxIndex=0,n.fxUsed=null},exit(t,n){n.fxUsed&&t.unshiftContainer("body",e.importDeclaration([e.importSpecifier(e.identifier(n.fxUsed),e.identifier(n.fxUsed))],e.stringLiteral(n.opts.runtimeModule||bn)))}},"FunctionDeclaration|FunctionExpression|ArrowFunctionExpression":(t,n)=>{let i=t.node.body;if(!e.isBlockStatement(i))return;let s=(i.directives||[]).findIndex(u=>u.value.value==="use server");if(s<0)return;i.directives.splice(s,1);let a=(n.opts.filename||n.filename||"unknown").replace(n.opts.root?n.opts.root+"/":"",""),l=`${Rn(a)}:${n.fxIndex++}`,c=!!n.opts.ssr,p=c?"$$registerServerFn":"$$createServerReference";n.fxUsed=p;let f=c?e.callExpression(e.identifier(p),[e.stringLiteral(l),t.isFunctionDeclaration()?e.functionExpression(null,t.node.params,i,t.node.generator,t.node.async):t.node]):e.callExpression(e.identifier(p),[e.stringLiteral(l)]);t.isFunctionDeclaration()?t.replaceWith(e.variableDeclaration("const",[e.variableDeclarator(t.node.id,f)])):t.replaceWith(f),t.skip()}}}}function ae(e,t){if(!e.includes("use server"))return null;let n=(0,ct.transformSync)(e,{filename:t.filename,configFile:!1,babelrc:!1,sourceMaps:!0,parserOpts:{plugins:["typescript","jsx"]},plugins:[[Cn,t]]});return n?.code?{code:n.code,map:n.map}:null}var be=require("node:fs"),et=require("node:path"),jr=new Set(["key","ref","children"]),Fr=[/\(\)\s*=>/,/function\s*\(\)/,/\w+\(\)/,/\w+\.\w+/,/\w+\[.+\]/,/createSignal/,/createStore/,/createMemo/,/createEffect/],Xr=/^on[A-Z]/;function Se(e,t){let n={name:e,isStatic:!0,isReactive:!1,isEvent:Xr.test(e),isRef:e==="ref",isSpread:e.startsWith("...")};if(jr.has(e))return n;if(n.isEvent||n.isRef)return n.isStatic=!1,n;if(typeof t=="string"){let i=t;for(let o of Fr)if(o.test(i)){n.isStatic=!1,n.isReactive=!0;break}i.includes("${")&&(n.isStatic=!1,n.isReactive=!0)}else typeof t=="function"?(n.isStatic=!1,n.isReactive=!0):typeof t=="object"&&t!==null&&(n.isStatic=!1);return n}function ve(e){let t=new Map;for(let[n,i]of Object.entries(e))t.set(n,Se(n,i));return t}function Ue(e,t,n){if(typeof e!="string")return!1;let i=ve(t);for(let o of i.values()){if(o.isSpread)return!1;o.isReactive&&o.isEvent}return!0}function nn(e){return e&&typeof e=="object"&&"_$litType$"in e}function rn(e,t,n,i={}){let o=["svg","path","circle","rect","g"].includes(e),s=qe(t,i),a=n.length>0?`, ${Ge(n)}`:"";return i.useLitHTML!==!1&&Ue(e,t,n)?Ze(e,t,n,o):`jsx('${e}', ${s}${a})`}function qe(e,t={}){if(Object.keys(e).length===0)return"{}";let n=ve(e),i=[];for(let[o,s]of Object.entries(e)){let a=n.get(o);a.isReactive&&!a.isStatic?i.push(`${o}: () => ${s}`):typeof s=="string"?i.push(`${o}: "${s}"`):typeof s=="number"||typeof s=="boolean"?i.push(`${o}: ${s}`):i.push(`${o}: ${s}`)}return`{ ${i.join(", ")} }`}function Ge(e){return e.length===0?"undefined":e.length===1?String(e[0]):`[${e.join(", ")}]`}function Ze(e,t,n,i=!1){let o=i?"svg":"html",s=`<${e}`,a=[];for(let[l,c]of Object.entries(t)){if(l==="children"||l==="key"||l==="ref")continue;let p=Se(l,c);if(p.isEvent){let f=l.slice(2).toLowerCase();s+=` @${f}=\${${a.length}}`,a.push(String(c))}else p.isReactive?(s+=` ${l}=\${${a.length}}`,a.push(`signal(() => ${c})`)):typeof c=="string"?s+=` ${l}="${c}"`:(s+=` ${l}=\${${a.length}}`,a.push(String(c)))}if(s+=">",n.length>0)for(let l of n)typeof l=="string"?s+=l:(s+=`\${${a.length}}`,a.push(String(l)));return s+=`</${e}>`,`${o}\`${s}\`${a.length>0?`, ${a.join(", ")}`:""}`}function Ke(e){return e=e.replace(/jsx\('([^']+)',\s*{},\s*"([^"]+)"\s*\)/g,(t,n,i)=>`_$staticNode('${n}', '${i}')`),e}function on(e){return e}function Ye(e){let t=[],n=0;return e=e.replace(/jsx\('([^']+)',\s*{([^}]*)},\s*([^)]*)\)/g,(i,o,s,a)=>{if(!s.includes("()")&&!s.includes("=>")){let l=`_$static${n++}`;return t.push(`const ${l} = ${i};`),l}return i}),t.length>0?t.join(`
|
|
3
3
|
`)+`
|
|
4
|
-
`+e:e}function
|
|
5
|
-
`+i)}return i=
|
|
4
|
+
`+e:e}function Qe(e,t={}){let n=t.delegatedEvents||["click","input","change","submit"],i=e.filter(o=>n.includes(o.toLowerCase()));return i.length===0?"":`delegateEvents([${i.map(o=>`'${o}'`).join(", ")}]);`}function A(e,t={}){let n={hasSignals:/createSignal|signal\(/.test(e),hasStores:/createStore|store\(/.test(e),hasLitHTML:/html`|svg`/.test(e),staticProps:new Set,dynamicProps:new Set,components:new Set},i=e;if(t.optimize!==!1&&(i=Ke(i),i=Ye(i)),t.delegateEvents!==!1){let o=Or(e),s=Qe(o,t);s&&(i=s+`
|
|
5
|
+
`+i)}return i=Ar(i,n,t),{code:i,metadata:n}}function Or(e){let t=new Set,n=/on([A-Z][a-z]+)/g,i;for(;(i=n.exec(e))!==null;)t.add(i[1].toLowerCase());return Array.from(t)}function Ar(e,t,n){let i=[],o=n.importSource||"@fluixi/jsx";return i.push(`import { jsx, jsxs, Fragment, spread } from '${o}';`),t.hasSignals&&i.push("import { signal } from '@fluixi/dom/reactive';"),(e.includes("<Show")||e.includes("<For")||e.includes("<Switch"))&&i.push("import { Show, For, Index, Switch, Match } from '@fluixi/dom/control-flow';"),n.delegateEvents!==!1&&i.push("import { delegateEvents } from '@fluixi/dom/runtime';"),i.join(`
|
|
6
6
|
`)+`
|
|
7
7
|
|
|
8
|
-
`+e}async function
|
|
9
|
-
`,
|
|
10
|
-
`);return i+
|
|
8
|
+
`+e}async function U(e={}){let t=null;try{t=await Promise.resolve().then(()=>(tn(),en))}catch(n){console.warn("Could not load the babel front-end:",n)}return{name:"babel-fluixi-jsx",plugin:t?t.default||t:null,getOptions(){return{runtime:"automatic",importSource:e.importSource||"@fluixi/jsx",pragma:e.pragma||"jsx",pragmaFrag:e.pragmaFrag||"Fragment",development:e.development||!1,detectReactivity:!0,useLitHTML:e.useLitHTML!==!1,hoistStatics:e.optimize!==!1,delegateEvents:e.delegateEvents!==!1,delegatedEvents:e.delegatedEvents||["click","input","change","submit"],optimizeControlFlow:e.optimize!==!1,sourceMaps:e.sourceMaps!==!1,backend:e.backend||"imperative",...e.codegen?{codegen:e.codegen}:{},...e.format?{format:e.format}:{},...e.resolve?{resolve:e.resolve}:{},...e.templateClone!==void 0?{templateClone:e.templateClone}:{},...e.partialTemplates!==void 0?{partialTemplates:e.partialTemplates}:{},...e.litTag?{litTag:e.litTag}:{},...e.signalModule?{signalModule:e.signalModule}:{},...e.controlFlowModule?{controlFlowModule:e.controlFlowModule}:{},...e.routerModule?{routerModule:e.routerModule}:{},...e.reactiveModule?{reactiveModule:e.reactiveModule}:{}}}}}function sn(e={}){let t=ye("typescript");return t?n=>{let i=o=>t.isJsxElement(o)||t.isJsxSelfClosingElement(o)?Dr(o,e,t):t.visitEachChild(o,i,n);return o=>t.visitNode(o,i)}:(console.warn("TypeScript not found, transformer unavailable"),n=>i=>i)}function Dr(e,t,n){return e}function ye(e){try{return require(e)}catch{return null}}function an(e={}){return{name:"vite-fluixi-jsx",enforce:"pre",config(){return{esbuild:{jsx:"automatic",jsxImportSource:e.importSource||"@fluixi/jsx"}}},async transform(t,n){let i=await U(e);if(!/\.(jsx|tsx|ts)$/i.test(n))return null;try{let o=await import("@babel/core").catch(()=>null);if(!o)return{code:A(t,e).code,map:null};let s=/\.tsx$/.test(n),a=/\.ts$/.test(n),l=[],c=[];if(s||a){let f=await import("@babel/preset-typescript").then(u=>u.default||u).catch(()=>null);f&&l.push([f,{isTSX:s,allExtensions:!0,jsxPragma:e.pragma||"jsx",jsxPragmaFrag:e.pragmaFrag||"Fragment",onlyRemoveTypeImports:!0}])}i&&i.plugin?c.push([i.plugin,i.getOptions()]):console.warn("[createVitePlugin] custom babel plugin not found");let p=await o.transformAsync(t,{filename:n,configFile:!1,babelrc:!1,presets:l,plugins:c,sourceMaps:e.sourceMaps!==!1});return{code:p?.code||t,map:p?.map}}catch(o){console.error("Transform error:",o);try{return{code:A(t,e).code,map:null}}catch(s){return console.error("Fallback transform also failed:",s),null}}}}}function ln(e={}){return async function(t){let n=this.async(),i=ye("@babel/core"),o=await U(e);if(!i||!o.plugin){let s=A(t,e);n(null,s.code);return}i.transformAsync(t,{filename:this.resourcePath,plugins:[[o.plugin,o.getOptions()]],sourceMaps:e.sourceMaps!==!1}).then(s=>{n(null,s?.code,s?.map)}).catch(s=>{n(s)})}}function cn(e={}){return{name:"rollup-fluixi-jsx",async transform(t,n){let i=await U(e);if(!/\.[jt]sx$/.test(n))return null;try{let o=ye("@babel/core");if(!o||!i.plugin)return{code:A(t,e).code,map:null};let s=await o.transformAsync(t,{filename:n,plugins:[[i.plugin,i.getOptions()]],sourceMaps:e.sourceMaps!==!1});return{code:s?.code||t,map:s?.map}}catch(o){return console.error("Transform error:",o),null}}}}function pn(e={}){return{name:"esbuild-fluixi-jsx",setup(t){t.onLoad({filter:/\.[jt]sx$/},async n=>{let i=ye("@babel/core"),o=await U(e),a=require("fs").readFileSync(n.path,"utf8");try{return!i||!o.plugin?{contents:A(a,e).code,loader:"js"}:{contents:(await i.transformAsync(a,{filename:n.path,plugins:[[o.plugin,o.getOptions()]],sourceMaps:!1}))?.code||a,loader:"js"}}catch(l){return{errors:[{text:`Transform error: ${l}`}]}}})}}}var We="virtual:fluixi-server-fns";function un(e,t=[]){let n;try{n=(0,be.readdirSync)(e,{withFileTypes:!0})}catch{return t}for(let i of n){if(i.name==="node_modules"||i.name==="dist"||i.name.startsWith("."))continue;let o=(0,et.join)(e,i.name);if(i.isDirectory())un(o,t);else if(/\.[jt]sx?$/.test(i.name))try{(0,be.readFileSync)(o,"utf8").includes("use server")&&t.push(o)}catch{}}return t}function _r(){let e=process.cwd();return{name:"fluixi-server-functions",enforce:"pre",configResolved(t){e=t.root||e},resolveId(t){return t===We?"\0"+We:null},load(t){if(t!=="\0"+We)return null;let n=un((0,et.join)(e,"src")),i=`import '@fluixi/start/server-fn-setup';
|
|
9
|
+
`,o=n.map(a=>`import ${JSON.stringify(a)};`).join(`
|
|
10
|
+
`);return i+o+`
|
|
11
11
|
export { isServerFnRequest, handleServerFn } from '@fluixi/start/server-fn';
|
|
12
|
-
`},transform(t,n,i){return!/\.[jt]sx?$/.test(n)||!t.includes("use server")?null:
|
|
12
|
+
`},transform(t,n,i){return!/\.[jt]sx?$/.test(n)||!t.includes("use server")?null:ae(t,{ssr:!!i?.ssr,filename:n,root:e})}}}var zr={analyzeProp:Se,analyzeProps:ve,shouldUseLitTemplate:Ue,isLitTemplate:nn,generateCreateElement:rn,generatePropsCode:qe,generateChildrenCode:Ge,generateLitHTMLTemplate:Ze,optimizeStatic:Ke,optimizeSpreads:on,hoistStatic:Ye,generateEventDelegation:Qe,transform:A,createBabelPlugin:U,createTypeScriptTransformer:sn,createVitePlugin:an,createWebpackLoader:ln,createRollupPlugin:cn,createESBuildPlugin:pn};
|
package/dist/integrations.d.ts
CHANGED
|
@@ -14,6 +14,15 @@
|
|
|
14
14
|
* - Static vs dynamic prop detection
|
|
15
15
|
*/
|
|
16
16
|
export interface CompilerOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Rules that resolve an unbound capitalised tag to a module, so a component can be
|
|
19
|
+
* used in a template without an import. See `createComponentResolver`.
|
|
20
|
+
*/
|
|
21
|
+
resolve?: readonly ComponentResolverRule[];
|
|
22
|
+
/** Clone static subtrees from a `<template>` instead of building them element by element. */
|
|
23
|
+
templateClone?: boolean;
|
|
24
|
+
/** Also clone subtrees whose structure is static but which contain dynamic holes. */
|
|
25
|
+
partialTemplates?: boolean;
|
|
17
26
|
/**
|
|
18
27
|
* Whether to use lit-html templates when possible
|
|
19
28
|
* @default true
|
|
@@ -189,6 +198,9 @@ export declare function createBabelPlugin(options?: CompilerOptions): Promise<{
|
|
|
189
198
|
controlFlowModule?: string | undefined;
|
|
190
199
|
signalModule?: string | undefined;
|
|
191
200
|
litTag?: string | undefined;
|
|
201
|
+
partialTemplates?: boolean | undefined;
|
|
202
|
+
templateClone?: boolean | undefined;
|
|
203
|
+
resolve?: readonly ComponentResolverRule[] | undefined;
|
|
192
204
|
format?: "both" | "jsx" | "lit" | undefined;
|
|
193
205
|
codegen?: "inline" | "ir" | undefined;
|
|
194
206
|
runtime: string;
|
|
@@ -236,6 +248,7 @@ export declare function createESBuildPlugin(options?: CompilerOptions): {
|
|
|
236
248
|
setup(build: any): void;
|
|
237
249
|
};
|
|
238
250
|
export { transformServerFunctions } from './frontend/babel/server-functions.js';
|
|
251
|
+
import type { ComponentResolverRule } from './resolve/component-resolver.js';
|
|
239
252
|
/**
|
|
240
253
|
* Vite plugin for `"use server"`: applies the transform (client→RPC stub, server→register
|
|
241
254
|
* the body), and provides `virtual:fluixi-server-fns` — side-effect imports of every
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../src/integrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,KAAK,GAAG,YAAY,CAAC;IAE/B;;;;OAIG;IACH,OAAO,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAE1B;;;;OAIG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MA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AM,GAAG,EAAE,QAAQ,MAAM,mBAyBjD;AAMD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,eAAoB;;oBAItC,MAAM,MAAM,MAAM;;;;EAgC3C;AAMD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,eAAoB;;iBAIhD,GAAG;EAsCnB;AAWD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AA6B7E;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CA6BtD;;;;;;;;;;;;;;;;;;;;;;AAED,wBA6BE"}
|
package/dist/integrations.js
CHANGED
|
@@ -408,6 +408,15 @@ export async function createBabelPlugin(options = {}) {
|
|
|
408
408
|
backend: options.backend || 'imperative',
|
|
409
409
|
...(options.codegen ? { codegen: options.codegen } : {}),
|
|
410
410
|
...(options.format ? { format: options.format } : {}),
|
|
411
|
+
// Forwarded explicitly: getOptions() is an allowlist, so an option missing
|
|
412
|
+
// here is silently dropped rather than rejected.
|
|
413
|
+
...(options.resolve ? { resolve: options.resolve } : {}),
|
|
414
|
+
...(options.templateClone !== undefined
|
|
415
|
+
? { templateClone: options.templateClone }
|
|
416
|
+
: {}),
|
|
417
|
+
...(options.partialTemplates !== undefined
|
|
418
|
+
? { partialTemplates: options.partialTemplates }
|
|
419
|
+
: {}),
|
|
411
420
|
...(options.litTag ? { litTag: options.litTag } : {}),
|
|
412
421
|
...(options.signalModule ? { signalModule: options.signalModule } : {}),
|
|
413
422
|
...(options.controlFlowModule
|
package/dist/integrations.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{a as d}from"./chunk-3SAEGOMQ.mjs";import{transformSync as
|
|
1
|
+
import{a as d}from"./chunk-3SAEGOMQ.mjs";import{transformSync as C}from"@babel/core";var R="@fluixi/start/server-fn";function P(e){let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return(t>>>0).toString(16)}function O({types:e}){return{name:"fluixi-server-functions",visitor:{Program:{enter(t,n){n.fxIndex=0,n.fxUsed=null},exit(t,n){n.fxUsed&&t.unshiftContainer("body",e.importDeclaration([e.importSpecifier(e.identifier(n.fxUsed),e.identifier(n.fxUsed))],e.stringLiteral(n.opts.runtimeModule||R)))}},"FunctionDeclaration|FunctionExpression|ArrowFunctionExpression":(t,n)=>{let r=t.node.body;if(!e.isBlockStatement(r))return;let i=(r.directives||[]).findIndex(g=>g.value.value==="use server");if(i<0)return;r.directives.splice(i,1);let a=(n.opts.filename||n.filename||"unknown").replace(n.opts.root?n.opts.root+"/":"",""),o=`${P(a)}:${n.fxIndex++}`,l=!!n.opts.ssr,c=l?"$$registerServerFn":"$$createServerReference";n.fxUsed=c;let u=l?e.callExpression(e.identifier(c),[e.stringLiteral(o),t.isFunctionDeclaration()?e.functionExpression(null,t.node.params,r,t.node.generator,t.node.async):t.node]):e.callExpression(e.identifier(c),[e.stringLiteral(o)]);t.isFunctionDeclaration()?t.replaceWith(e.variableDeclaration("const",[e.variableDeclarator(t.node.id,u)])):t.replaceWith(u),t.skip()}}}}function y(e,t){if(!e.includes("use server"))return null;let n=C(e,{filename:t.filename,configFile:!1,babelrc:!1,sourceMaps:!0,parserOpts:{plugins:["typescript","jsx"]},plugins:[[O,t]]});return n?.code?{code:n.code,map:n.map}:null}import{readdirSync as J,readFileSync as X}from"node:fs";import{join as E}from"node:path";var L=new Set(["key","ref","children"]),A=[/\(\)\s*=>/,/function\s*\(\)/,/\w+\(\)/,/\w+\.\w+/,/\w+\[.+\]/,/createSignal/,/createStore/,/createMemo/,/createEffect/],k=/^on[A-Z]/;function v(e,t){let n={name:e,isStatic:!0,isReactive:!1,isEvent:k.test(e),isRef:e==="ref",isSpread:e.startsWith("...")};if(L.has(e))return n;if(n.isEvent||n.isRef)return n.isStatic=!1,n;if(typeof t=="string"){let r=t;for(let s of A)if(s.test(r)){n.isStatic=!1,n.isReactive=!0;break}r.includes("${")&&(n.isStatic=!1,n.isReactive=!0)}else typeof t=="function"?(n.isStatic=!1,n.isReactive=!0):typeof t=="object"&&t!==null&&(n.isStatic=!1);return n}function b(e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n,v(n,r));return t}function h(e,t,n){if(typeof e!="string")return!1;let r=b(t);for(let s of r.values()){if(s.isSpread)return!1;s.isReactive&&s.isEvent}return!0}function _(e){return e&&typeof e=="object"&&"_$litType$"in e}function I(e,t,n,r={}){let s=["svg","path","circle","rect","g"].includes(e),i=S(t,r),a=n.length>0?`, ${$(n)}`:"";return r.useLitHTML!==!1&&h(e,t,n)?T(e,t,n,s):`jsx('${e}', ${i}${a})`}function S(e,t={}){if(Object.keys(e).length===0)return"{}";let n=b(e),r=[];for(let[s,i]of Object.entries(e)){let a=n.get(s);a.isReactive&&!a.isStatic?r.push(`${s}: () => ${i}`):typeof i=="string"?r.push(`${s}: "${i}"`):typeof i=="number"||typeof i=="boolean"?r.push(`${s}: ${i}`):r.push(`${s}: ${i}`)}return`{ ${r.join(", ")} }`}function $(e){return e.length===0?"undefined":e.length===1?String(e[0]):`[${e.join(", ")}]`}function T(e,t,n,r=!1){let s=r?"svg":"html",i=`<${e}`,a=[];for(let[o,l]of Object.entries(t)){if(o==="children"||o==="key"||o==="ref")continue;let c=v(o,l);if(c.isEvent){let u=o.slice(2).toLowerCase();i+=` @${u}=\${${a.length}}`,a.push(String(l))}else c.isReactive?(i+=` ${o}=\${${a.length}}`,a.push(`signal(() => ${l})`)):typeof l=="string"?i+=` ${o}="${l}"`:(i+=` ${o}=\${${a.length}}`,a.push(String(l)))}if(i+=">",n.length>0)for(let o of n)typeof o=="string"?i+=o:(i+=`\${${a.length}}`,a.push(String(o)));return i+=`</${e}>`,`${s}\`${i}\`${a.length>0?`, ${a.join(", ")}`:""}`}function M(e){return e=e.replace(/jsx\('([^']+)',\s*{},\s*"([^"]+)"\s*\)/g,(t,n,r)=>`_$staticNode('${n}', '${r}')`),e}function N(e){return e}function j(e){let t=[],n=0;return e=e.replace(/jsx\('([^']+)',\s*{([^}]*)},\s*([^)]*)\)/g,(r,s,i,a)=>{if(!i.includes("()")&&!i.includes("=>")){let o=`_$static${n++}`;return t.push(`const ${o} = ${r};`),o}return r}),t.length>0?t.join(`
|
|
2
2
|
`)+`
|
|
3
3
|
`+e:e}function w(e,t={}){let n=t.delegatedEvents||["click","input","change","submit"],r=e.filter(s=>n.includes(s.toLowerCase()));return r.length===0?"":`delegateEvents([${r.map(s=>`'${s}'`).join(", ")}]);`}function f(e,t={}){let n={hasSignals:/createSignal|signal\(/.test(e),hasStores:/createStore|store\(/.test(e),hasLitHTML:/html`|svg`/.test(e),staticProps:new Set,dynamicProps:new Set,components:new Set},r=e;if(t.optimize!==!1&&(r=M(r),r=j(r)),t.delegateEvents!==!1){let s=z(e),i=w(s,t);i&&(r=i+`
|
|
4
4
|
`+r)}return r=D(r,n,t),{code:r,metadata:n}}function z(e){let t=new Set,n=/on([A-Z][a-z]+)/g,r;for(;(r=n.exec(e))!==null;)t.add(r[1].toLowerCase());return Array.from(t)}function D(e,t,n){let r=[],s=n.importSource||"@fluixi/jsx";return r.push(`import { jsx, jsxs, Fragment, spread } from '${s}';`),t.hasSignals&&r.push("import { signal } from '@fluixi/dom/reactive';"),(e.includes("<Show")||e.includes("<For")||e.includes("<Switch"))&&r.push("import { Show, For, Index, Switch, Match } from '@fluixi/dom/control-flow';"),n.delegateEvents!==!1&&r.push("import { delegateEvents } from '@fluixi/dom/runtime';"),r.join(`
|
|
5
5
|
`)+`
|
|
6
6
|
|
|
7
|
-
`+e}async function p(e={}){let t=null;try{t=await import("./babel-
|
|
7
|
+
`+e}async function p(e={}){let t=null;try{t=await import("./babel-NY6FXXLW.mjs")}catch(n){console.warn("Could not load the babel front-end:",n)}return{name:"babel-fluixi-jsx",plugin:t?t.default||t:null,getOptions(){return{runtime:"automatic",importSource:e.importSource||"@fluixi/jsx",pragma:e.pragma||"jsx",pragmaFrag:e.pragmaFrag||"Fragment",development:e.development||!1,detectReactivity:!0,useLitHTML:e.useLitHTML!==!1,hoistStatics:e.optimize!==!1,delegateEvents:e.delegateEvents!==!1,delegatedEvents:e.delegatedEvents||["click","input","change","submit"],optimizeControlFlow:e.optimize!==!1,sourceMaps:e.sourceMaps!==!1,backend:e.backend||"imperative",...e.codegen?{codegen:e.codegen}:{},...e.format?{format:e.format}:{},...e.resolve?{resolve:e.resolve}:{},...e.templateClone!==void 0?{templateClone:e.templateClone}:{},...e.partialTemplates!==void 0?{partialTemplates:e.partialTemplates}:{},...e.litTag?{litTag:e.litTag}:{},...e.signalModule?{signalModule:e.signalModule}:{},...e.controlFlowModule?{controlFlowModule:e.controlFlowModule}:{},...e.routerModule?{routerModule:e.routerModule}:{},...e.reactiveModule?{reactiveModule:e.reactiveModule}:{}}}}}function V(e={}){let t=m("typescript");return t?n=>{let r=s=>t.isJsxElement(s)||t.isJsxSelfClosingElement(s)?H(s,e,t):t.visitEachChild(s,r,n);return s=>t.visitNode(s,r)}:(console.warn("TypeScript not found, transformer unavailable"),n=>r=>r)}function H(e,t,n){return e}function m(e){try{return d(e)}catch{return null}}function U(e={}){return{name:"vite-fluixi-jsx",enforce:"pre",config(){return{esbuild:{jsx:"automatic",jsxImportSource:e.importSource||"@fluixi/jsx"}}},async transform(t,n){let r=await p(e);if(!/\.(jsx|tsx|ts)$/i.test(n))return null;try{let s=await import("@babel/core").catch(()=>null);if(!s)return{code:f(t,e).code,map:null};let i=/\.tsx$/.test(n),a=/\.ts$/.test(n),o=[],l=[];if(i||a){let u=await import("@babel/preset-typescript").then(g=>g.default||g).catch(()=>null);u&&o.push([u,{isTSX:i,allExtensions:!0,jsxPragma:e.pragma||"jsx",jsxPragmaFrag:e.pragmaFrag||"Fragment",onlyRemoveTypeImports:!0}])}r&&r.plugin?l.push([r.plugin,r.getOptions()]):console.warn("[createVitePlugin] custom babel plugin not found");let c=await s.transformAsync(t,{filename:n,configFile:!1,babelrc:!1,presets:o,plugins:l,sourceMaps:e.sourceMaps!==!1});return{code:c?.code||t,map:c?.map}}catch(s){console.error("Transform error:",s);try{return{code:f(t,e).code,map:null}}catch(i){return console.error("Fallback transform also failed:",i),null}}}}}function W(e={}){return async function(t){let n=this.async(),r=m("@babel/core"),s=await p(e);if(!r||!s.plugin){let i=f(t,e);n(null,i.code);return}r.transformAsync(t,{filename:this.resourcePath,plugins:[[s.plugin,s.getOptions()]],sourceMaps:e.sourceMaps!==!1}).then(i=>{n(null,i?.code,i?.map)}).catch(i=>{n(i)})}}function q(e={}){return{name:"rollup-fluixi-jsx",async transform(t,n){let r=await p(e);if(!/\.[jt]sx$/.test(n))return null;try{let s=m("@babel/core");if(!s||!r.plugin)return{code:f(t,e).code,map:null};let i=await s.transformAsync(t,{filename:n,plugins:[[r.plugin,r.getOptions()]],sourceMaps:e.sourceMaps!==!1});return{code:i?.code||t,map:i?.map}}catch(s){return console.error("Transform error:",s),null}}}}function B(e={}){return{name:"esbuild-fluixi-jsx",setup(t){t.onLoad({filter:/\.[jt]sx$/},async n=>{let r=m("@babel/core"),s=await p(e),a=d("fs").readFileSync(n.path,"utf8");try{return!r||!s.plugin?{contents:f(a,e).code,loader:"js"}:{contents:(await r.transformAsync(a,{filename:n.path,plugins:[[s.plugin,s.getOptions()]],sourceMaps:!1}))?.code||a,loader:"js"}}catch(o){return{errors:[{text:`Transform error: ${o}`}]}}})}}}var x="virtual:fluixi-server-fns";function F(e,t=[]){let n;try{n=J(e,{withFileTypes:!0})}catch{return t}for(let r of n){if(r.name==="node_modules"||r.name==="dist"||r.name.startsWith("."))continue;let s=E(e,r.name);if(r.isDirectory())F(s,t);else if(/\.[jt]sx?$/.test(r.name))try{X(s,"utf8").includes("use server")&&t.push(s)}catch{}}return t}function ee(){let e=process.cwd();return{name:"fluixi-server-functions",enforce:"pre",configResolved(t){e=t.root||e},resolveId(t){return t===x?"\0"+x:null},load(t){if(t!=="\0"+x)return null;let n=F(E(e,"src")),r=`import '@fluixi/start/server-fn-setup';
|
|
8
8
|
`,s=n.map(a=>`import ${JSON.stringify(a)};`).join(`
|
|
9
9
|
`);return r+s+`
|
|
10
10
|
export { isServerFnRequest, handleServerFn } from '@fluixi/start/server-fn';
|
|
11
|
-
`},transform(t,n,r){return!/\.[jt]sx?$/.test(n)||!t.includes("use server")?null:y(t,{ssr:!!r?.ssr,filename:n,root:e})}}}var te={analyzeProp:v,analyzeProps:
|
|
11
|
+
`},transform(t,n,r){return!/\.[jt]sx?$/.test(n)||!t.includes("use server")?null:y(t,{ssr:!!r?.ssr,filename:n,root:e})}}}var te={analyzeProp:v,analyzeProps:b,shouldUseLitTemplate:h,isLitTemplate:_,generateCreateElement:I,generatePropsCode:S,generateChildrenCode:$,generateLitHTMLTemplate:T,optimizeStatic:M,optimizeSpreads:N,hoistStatic:j,generateEventDelegation:w,transform:f,createBabelPlugin:p,createTypeScriptTransformer:V,createVitePlugin:U,createWebpackLoader:W,createRollupPlugin:q,createESBuildPlugin:B};export{v as analyzeProp,b as analyzeProps,p as createBabelPlugin,B as createESBuildPlugin,q as createRollupPlugin,V as createTypeScriptTransformer,U as createVitePlugin,W as createWebpackLoader,te as default,$ as generateChildrenCode,I as generateCreateElement,w as generateEventDelegation,T as generateLitHTMLTemplate,S as generatePropsCode,j as hoistStatic,_ as isLitTemplate,N as optimizeSpreads,M as optimizeStatic,ee as serverFunctionsVitePlugin,h as shouldUseLitTemplate,f as transform,y as transformServerFunctions};
|
package/dist/ir/nodes.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=Object.defineProperty;var
|
|
1
|
+
"use strict";var t=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var l=(o,e,a,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!c.call(o,r)&&r!==a&&t(o,r,{get:()=>e[r],enumerable:!(n=i(e,r))||n.enumerable});return o};var d=o=>l(t({},"__esModule",{value:!0}),o);var s={};module.exports=d(s);
|
package/dist/ir/nodes.d.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* between parsing and code generation — the layer your own improvements
|
|
5
5
|
* (hoisting, islands, resumability hints) transform.
|
|
6
6
|
*/
|
|
7
|
+
import type { IRLoadStrategy } from '../resolve/load-directive.js';
|
|
8
|
+
export type { IRLoadStrategy };
|
|
7
9
|
export interface SourceSpan {
|
|
8
10
|
start: number;
|
|
9
11
|
end: number;
|
|
@@ -46,11 +48,52 @@ export interface IRElement {
|
|
|
46
48
|
static: boolean;
|
|
47
49
|
loc?: SourceSpan;
|
|
48
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Where a component reference comes from, attached to the reference itself.
|
|
53
|
+
*
|
|
54
|
+
* A capitalised tag with no binding in the file is supplied by the compiler — from a
|
|
55
|
+
* `resolve` rule, or from the built-in control-flow/router sets. That decision used to
|
|
56
|
+
* live only in the Babel plugin's state, which meant the IR could not see which
|
|
57
|
+
* components a template referenced: no pass could vary a decision per usage, group
|
|
58
|
+
* references into chunks, or drop a subtree it knows is server-only. Recording it on
|
|
59
|
+
* the node is what turns resolution from a convenience into something later passes can
|
|
60
|
+
* read.
|
|
61
|
+
*
|
|
62
|
+
* `origin` distinguishes the two suppliers because they behave differently: a `rule`
|
|
63
|
+
* is configuration and may be overridden or re-targeted, while a `builtin` control-flow
|
|
64
|
+
* name also selects codegen and cannot be re-pointed at another module.
|
|
65
|
+
*/
|
|
66
|
+
export interface IRComponentSource {
|
|
67
|
+
module: string;
|
|
68
|
+
/** The export to import, or `default`. */
|
|
69
|
+
export: string;
|
|
70
|
+
origin: 'rule' | 'builtin';
|
|
71
|
+
/**
|
|
72
|
+
* When the module is fetched. Set from a `load:` directive at the usage site, and
|
|
73
|
+
* `eager` otherwise — resolution decides where a component comes from, this decides
|
|
74
|
+
* when, and the two vary independently.
|
|
75
|
+
*/
|
|
76
|
+
loading: IRLoadStrategy;
|
|
77
|
+
/** Assigned by the optimizer once references are grouped. */
|
|
78
|
+
chunk?: string;
|
|
79
|
+
}
|
|
49
80
|
export interface IRComponent {
|
|
50
81
|
kind: 'component';
|
|
51
82
|
name: string;
|
|
52
83
|
props: IRProp[];
|
|
53
84
|
children: IRNode[];
|
|
85
|
+
/**
|
|
86
|
+
* Set by the resolve pass when the compiler supplies this reference. Absent when the
|
|
87
|
+
* name is bound in the file — an ordinary import the author wrote — or when nothing
|
|
88
|
+
* claims it, which is a diagnostic rather than a resolution.
|
|
89
|
+
*/
|
|
90
|
+
source?: IRComponentSource;
|
|
91
|
+
/**
|
|
92
|
+
* A `load:` strategy read off the tag by the frontend. The resolve pass folds it into
|
|
93
|
+
* `source.loading`; it lives here first because the frontend knows the directive and
|
|
94
|
+
* the resolve pass knows whether the name is deferrable at all.
|
|
95
|
+
*/
|
|
96
|
+
load?: IRLoadStrategy;
|
|
54
97
|
loc?: SourceSpan;
|
|
55
98
|
}
|
|
56
99
|
export interface IRText {
|
package/dist/ir/nodes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/ir/nodes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IAAG,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;CAAE;AAE3D,MAAM,MAAM,MAAM,GACd,SAAS,GACT,WAAW,GACX,MAAM,GACN,YAAY,GACZ,SAAS,GACT,UAAU,CAAC;AAEf,MAAM,MAAM,UAAU,GAClB,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE,MAAM,WAAW,MAAM;IACrB,4FAA4F;IAC5F,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAA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AC,EAAE,UAAU,CAAC;CAAE;AAEvF,MAAM,MAAM,WAAW,GACnB,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAC7C,SAAS,GAAG,eAAe,GAAG,UAAU,CAAC;AAE7C,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,GAAG,CAAC,EAAE,UAAU,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var d=(r,e)=>{for(var s in e)a(r,s,{get:e[s],enumerable:!0})},u=(r,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of f(e))!p.call(r,t)&&t!==s&&a(r,t,{get:()=>e[t],enumerable:!(n=l(e,t))||n.enumerable});return r};var R=r=>u(a({},"__esModule",{value:!0}),r);var y={};d(y,{analyzeStatic:()=>m,staticRoots:()=>x});module.exports=R(y);function h(r){switch(r.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 r.reactive?"reactive-prop":r.expr!==void 0?"expression-prop":void 0;default:return"expression-prop"}}function m(r){let e=[],s=new Map,n=t=>{switch(t.kind){case"text":return!0;case"expr":return!1;case"component":case"control":for(let i of t.children)n(i);return!1;case"fragment":for(let i of t.children)n(i);return!1;case"element":{let i=!0;for(let o of t.children)n(o)||(i=!1);let c;for(let o of t.props)if(c=h(o),c)break;return!c&&!i&&(c=I(t)),t.static=!c,c?s.set(t,c):e.push(t),t.static}default:return!1}};for(let t of Array.isArray(r)?r:[r])n(t);return{staticElements:e,reasons:s}}function I(r){for(let e of r.children){if(e.kind==="expr")return"expression-child";if(e.kind==="component")return"component-child";if(e.kind==="control")return"control-child";if(e.kind==="element"&&!e.static||e.kind==="fragment")return"expression-child"}return"expression-child"}function x(r){let e=[],s=n=>{if(n.kind==="element"&&n.static){e.push(n);return}let t=n.children;if(t)for(let i of t)s(i)};for(let n of Array.isArray(r)?r:[r])s(n);return e}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static analysis: mark the element subtrees that never change after creation.
|
|
3
|
+
*
|
|
4
|
+
* A static subtree can be built once as an HTML string and cloned per instance, instead
|
|
5
|
+
* of constructed an element at a time. That is the difference between one `cloneNode`
|
|
6
|
+
* and N `createElement` + N `spread` calls — measured at 2.1x faster for a three-element
|
|
7
|
+
* row and 2.4x for a nine-element card, with the gap widening as components grow.
|
|
8
|
+
*
|
|
9
|
+
* `IRElement.static` has existed since the IR was written, documented as
|
|
10
|
+
* "subtree has no dynamic parts → hoistable (template-clone)", but was hardcoded `false`
|
|
11
|
+
* with no producer. This is the producer.
|
|
12
|
+
*
|
|
13
|
+
* The analysis is deliberately conservative: marking something static that is not is a
|
|
14
|
+
* correctness bug (a shared DOM node across renders), while missing one is only a lost
|
|
15
|
+
* optimisation. Anything not positively known to be inert makes its whole ancestry
|
|
16
|
+
* dynamic.
|
|
17
|
+
*/
|
|
18
|
+
import type { IRNode, IRElement } from '../ir/nodes.js';
|
|
19
|
+
/** Why a subtree could not be treated as static. Useful for diagnostics and tests. */
|
|
20
|
+
export type DynamicReason = 'reactive-prop' | 'expression-prop' | 'event' | 'ref' | 'spread' | 'class-or-style-directive' | 'expression-child' | 'component-child' | 'control-child';
|
|
21
|
+
export interface StaticReport {
|
|
22
|
+
/** Elements marked static, in visit order. */
|
|
23
|
+
staticElements: IRElement[];
|
|
24
|
+
/** Why each non-static element was rejected, keyed by the element node. */
|
|
25
|
+
reasons: Map<IRElement, DynamicReason>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Mark every static element in the tree, returning what was decided.
|
|
29
|
+
*
|
|
30
|
+
* Mutates `IRElement.static` in place, since that field is the contract codegen reads.
|
|
31
|
+
*/
|
|
32
|
+
export declare function analyzeStatic(root: IRNode | IRNode[]): StaticReport;
|
|
33
|
+
/**
|
|
34
|
+
* The outermost static elements — the roots worth turning into templates.
|
|
35
|
+
*
|
|
36
|
+
* Cloning a static child of a static parent is wasted: the parent's template already
|
|
37
|
+
* contains it.
|
|
38
|
+
*/
|
|
39
|
+
export declare function staticRoots(root: IRNode | IRNode[]): IRElement[];
|
|
40
|
+
//# sourceMappingURL=analyze-static.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze-static.d.ts","sourceRoot":"","sources":["../../src/optimize/analyze-static.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAU,MAAM,gBAAgB,CAAC;AAEhE,sFAAsF;AACtF,MAAM,MAAM,aAAa,GACrB,eAAe,GACf,iBAAiB,GACjB,OAAO,GACP,KAAK,GACL,QAAQ,GACR,0BAA0B,GAC1B,kBAAkB,GAClB,iBAAiB,GACjB,eAAe,CAAC;AAEpB,MAAM,WAAW,YAAY;IAC3B,8CAA8C;IAC9C,cAAc,EAAE,SAAS,EAAE,CAAC;IAC5B,2EAA2E;IAC3E,OAAO,EAAE,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;CACxC;AA+BD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,YAAY,CA2DnE;AAeD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EAAE,CAchE"}
|