@fluixi/compiler 1.0.0-alpha.74 → 1.0.0-alpha.76
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/analyze/intrinsics.cjs +1 -0
- package/dist/analyze/intrinsics.d.ts +67 -0
- package/dist/analyze/intrinsics.d.ts.map +1 -0
- package/dist/analyze/intrinsics.js +91 -0
- package/dist/analyze/intrinsics.mjs +1 -0
- package/dist/analyze/props-destructure.cjs +1 -0
- package/dist/analyze/props-destructure.d.ts +84 -0
- package/dist/analyze/props-destructure.d.ts.map +1 -0
- package/dist/analyze/props-destructure.js +272 -0
- package/dist/analyze/props-destructure.mjs +1 -0
- package/dist/analyze/reactive-bindings.cjs +1 -0
- package/dist/analyze/reactive-bindings.d.ts +34 -0
- package/dist/analyze/reactive-bindings.d.ts.map +1 -0
- package/dist/analyze/reactive-bindings.js +153 -0
- package/dist/analyze/reactive-bindings.mjs +1 -0
- package/dist/{babel-GXO3KAVI.mjs → babel-YQ42WUS3.mjs} +1 -1
- package/dist/chunk-545LMC5W.mjs +1 -0
- package/dist/{chunk-TIE4XNAM.mjs → chunk-L2QPV25P.mjs} +1 -1
- package/dist/frontend/babel/build-ir-lit.cjs +1 -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.mjs +1 -1
- package/dist/frontend/babel/index.cjs +1 -1
- package/dist/frontend/babel/index.mjs +1 -1
- package/dist/frontend/babel/lower-template.cjs +1 -1
- package/dist/frontend/babel/lower-template.mjs +1 -1
- package/dist/frontend/babel/plugin.cjs +1 -1
- package/dist/frontend/babel/plugin.mjs +1 -1
- package/dist/index.cjs +8 -8
- package/dist/index.mjs +9 -9
- package/dist/integrations.cjs +18 -14
- package/dist/integrations.d.ts +14 -0
- package/dist/integrations.d.ts.map +1 -1
- package/dist/integrations.js +16 -1
- package/dist/integrations.mjs +11 -11
- package/dist/lower/compile-template.cjs +1 -1
- package/dist/lower/compile-template.mjs +1 -1
- package/dist/lower/template.cjs +1 -1
- package/dist/lower/template.d.ts.map +1 -1
- package/dist/lower/template.js +7 -5
- package/dist/lower/template.mjs +1 -1
- package/dist/resolve/component-globals.cjs +9 -9
- package/dist/resolve/component-globals.d.ts +8 -0
- package/dist/resolve/component-globals.d.ts.map +1 -1
- package/dist/resolve/component-globals.js +17 -3
- package/dist/resolve/component-globals.mjs +9 -9
- package/dist/resolve/write-globals.cjs +9 -9
- package/dist/resolve/write-globals.mjs +9 -9
- package/dist/transform/index.cjs +5 -1
- package/dist/transform/index.d.ts +4 -0
- package/dist/transform/index.d.ts.map +1 -1
- package/dist/transform/index.js +2 -0
- package/dist/transform/index.mjs +14 -10
- package/dist/transform/intrinsics.cjs +3 -0
- package/dist/transform/intrinsics.d.ts +22 -0
- package/dist/transform/intrinsics.d.ts.map +1 -0
- package/dist/transform/intrinsics.js +78 -0
- package/dist/transform/intrinsics.mjs +3 -0
- package/dist/transform/props.cjs +3 -0
- package/dist/transform/props.d.ts +46 -0
- package/dist/transform/props.d.ts.map +1 -0
- package/dist/transform/props.js +221 -0
- package/dist/transform/props.mjs +12 -0
- package/dist/transform/templates.cjs +4 -1
- package/dist/transform/templates.d.ts +20 -0
- package/dist/transform/templates.d.ts.map +1 -1
- package/dist/transform/templates.js +41 -6
- package/dist/transform/templates.mjs +13 -10
- package/dist/transform-ZWIHEZVN.mjs +7 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +8 -7
- package/dist/transform-PJX2GNSV.mjs +0 -3
package/dist/index.cjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
"use strict";var F=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var Ce=(t,e)=>{for(var n in e)F(t,n,{get:e[n],enumerable:!0})},Ee=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ye(e))!Ne.call(t,r)&&r!==n&&F(t,r,{get:()=>e[r],enumerable:!(o=be(e,r))||o.enumerable});return t};var Ie=t=>Ee(F({},"__esModule",{value:!0}),t);var mt={};Ce(mt,{BUILTIN_COMPONENTS:()=>Ye,CORE_CONTROL_FLOW:()=>B,DEFAULT_GLOBALS_PATH:()=>ve,DOM_CONTROL_FLOW:()=>_,RESERVED_COMPONENTS:()=>H,ROUTER_COMPONENTS:()=>b,RUNTIME_CONTRACT_V1:()=>j,RUNTIME_CONTRACT_V2:()=>Fe,backends:()=>ut,builtinComponentMap:()=>y,builtinComponents:()=>Xe,cleanTemplateText:()=>w,compilePieces:()=>fe,compileTemplate:()=>rt,componentGlobals:()=>U,createComponentResolver:()=>T,defaultOptions:()=>dt,imperativeBackend:()=>v,isReactiveShape:()=>V,lowerTemplate:()=>L,resolveComponentSources:()=>z,routerComponents:()=>Qe,walk:()=>$,writeComponentGlobals:()=>pt});module.exports=Ie(mt);var we="children";function V(t){switch(t.kind){case"call":return!0;case"member":return t.property!==we;case"compound":return t.parts.some(V);case"opaque":return!1}}var pe=require("@fluixi/template-parser");var M={kind:"eager"},$e=["pointerdown","focusin","keydown"],q=new Set(["eager","idle","visible","interaction","media","never"]),k=class extends Error{};function K(t,e){let n=t.slice(5);if(!q.has(n))throw new k(`Unknown load strategy 'load:${n}'. Expected one of ${[...q].join(", ")}.`);switch(n){case"eager":return M;case"idle":return{kind:"idle"};case"never":return{kind:"never"};case"visible":return e?{kind:"visible",rootMargin:e}:{kind:"visible"};case"interaction":return{kind:"interaction",events:e?Te(e):[...$e]};case"media":if(!e)throw new k(`'load:media' needs a query, e.g. load:media="(min-width: 1024px)".`);return{kind:"media",query:e};default:throw new k(`Unhandled load strategy '${n}'.`)}}function Te(t){let e=t.split(/[\s,]+/).map(n=>n.trim()).filter(Boolean);if(e.length===0)throw new k("'load:interaction' was given no event names.");return e}function Z(t){return t.kind!=="eager"&&t.kind!=="never"}var Se=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Y={className:"class",htmlFor:"for"},Oe=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),Me=new Set(["script","style","textarea","title"]);function G(t){return Me.has(t)}function X(t){return Y[t]??t}function C(t){return t.kind!=="attr"||t.expr!==void 0||t.name.includes(":")?!1:!Oe.has(t.name)}function W(t){if(!t.static||G(t.tag))return!1;for(let e of t.props)if(!C(e))return!1;for(let e of t.children)if(e.kind!=="text"&&!(e.kind==="element"&&W(e)))return!1;return!0}function E(t){let e=t.props.map(Pe).filter(Boolean).join(""),n=`<${t.tag}${e}>`;return Se.has(t.tag)?n:`${n}${t.children.map(Ae).join("")}</${t.tag}>`}function Ae(t){if(t.kind==="text")return De(t.value);if(t.kind!=="element")throw new Error(`serializeStatic: unexpected ${t.kind}`);return E(t)}function Pe(t){let e=Y[t.name]??t.name,n=t.literal;return n===!0||n===void 0?` ${e}`:n===!1||n===null?"":` ${e}="${je(String(n))}"`}function je(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function De(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var Le="<!--fx-->",_e="<!--fx/-->";function P(t){return t.kind==="expr"||t.kind==="component"||t.kind==="control"}function Be(t){return t.kind==="text"||t.kind==="element"&&Q(t)}function Q(t){return t.svg||G(t.tag)||!t.props.every(e=>C(e))?!1:t.children.every(e=>Be(e)||P(e))}function A(t){if(P(t))return!0;let e=t.children;return e?e.some(A):!1}function ee(t){for(let e=0;e<t.children.length;e++){let n=t.children[e];if(n.kind==="text"&&(n.value===""||t.children[e+1]?.kind==="text"))return!1}return t.children.every(e=>e.kind!=="element"||ee(e))}function te(t){if(!Q(t)||!ee(t)||!t.children.some(A))return null;let e=[],n=[],o=0,r=l=>{let s=`_n$${o++}`;return e.push({ref:s,expr:l}),s};return i(t,"_el$"),{html:He(t),tag:t.tag,steps:e,holes:n};function i(l,s){let a=-1;l.children.forEach((d,p)=>{A(d)&&(a=p)});let c=null;for(let d=0;d<=a;d++){let p=l.children[d],u=c?`${c}.nextSibling`:`${s}.firstChild`;if(P(p)){let x=r(u),S=r(`holeEnd(${x})`);n.push({parentRef:s,startRef:x,endRef:S,node:p}),c=S;continue}let h=r(u);p.kind==="element"&&A(p)&&i(p,h),c=h}}}function He(t){return E(ne(t)).split(re).join(Le+_e)}function ne(t){return{...t,children:t.children.map(e=>P(e)?{kind:"text",value:re}:e.kind==="element"?ne(e):e)}}var re="\0fx-hole\0";var j={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},Fe={version:2,module:"@fluixi/dom",symbols:[...j.symbols,"template","cloneTemplate","walk"]};var Ge={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function We(t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)}function ie(t){return We(t)?t:JSON.stringify(t)}function Je(t){return t.expr!==void 0?t.reactive?`() => (${t.expr})`:`(${t.expr})`:JSON.stringify(t.literal??!0)}function ze(t){return t.expr!==void 0?`(${t.expr})`:JSON.stringify(t.literal??!0)}function Ue(t,e,n){let o=t.filter(s=>s.kind==="spread"),i=t.filter(s=>s.kind!=="spread").map(s=>`${ie(s.name)}: ${Je(s)}`);e!=null&&i.push(`children: ${e}`);let l=`{ ${i.join(", ")} }`;return o.length>0?(n.add("mergeProps"),`mergeProps(${o.map(s=>s.expr).join(", ")}, ${l})`):l}function se(t,e,n){return t.length===1?I(t[0],e,n):`[${t.map(o=>I(o,e,n)).join(", ")}]`}function oe(t,e,n,o,r){o.add("createMemo"),o.add("createComponent");let i=e.filter(c=>c.kind==="spread"),s=e.filter(c=>c.kind!=="spread").map(c=>`get ${ie(c.name)}() { return ${ze(c)}; }`);n.length>0&&s.push(`get children() { return ${se(n,o,r)}; }`);let a=`{ ${s.join(", ")} }`;return i.length>0&&(o.add("mergeProps"),a=`mergeProps(${i.map(c=>c.expr).join(", ")}, ${a})`),`createMemo(() => createComponent(${t}, ${a}))`}function Ve(t,e){let n=X(e.name),o=e.literal;return o===!0||o===void 0?`${t}.setAttribute(${JSON.stringify(n)}, "");`:o===!1||o===null?"":`${t}.setAttribute(${JSON.stringify(n)}, ${JSON.stringify(String(o))});`}var le=!1;function I(t,e,n){switch(t.kind){case"text":return JSON.stringify(t.value);case"expr":return t.reactive?`() => (${t.code})`:`(${t.code})`;case"fragment":return t.children.length===0?"null":se(t.children,e,n);case"component":return oe(t.name,t.props,t.children,e,n);case"control":{let o=Ge[t.control]??t.control;return e.add(o),oe(o,t.props,t.children,e,n)}case"element":{if(n&&t.static&&!t.svg&&W(t)){e.add("templateNode");let s=`_tmpl$${n.length}`;return n.push({id:s,html:E(t),tag:t.tag,svg:!1}),`templateNode(${s}, ${JSON.stringify(t.tag)})`}if(n&&le){let s=te(t);if(s){e.add("templateNode"),e.add("insert"),e.add("holeEnd"),e.add("holeContent"),e.add("holeScope");let a=`_tmpl$${n.length}`;n.push({id:a,html:s.html,tag:s.tag,svg:!1});let c=[`const _el$ = templateNode(${a}, ${JSON.stringify(s.tag)}, true);`];for(let d of s.steps)c.push(`const ${d.ref} = ${d.expr};`);for(let d of s.holes)c.push(`insert(${d.parentRef}, holeScope(${d.startRef}, () => (${I(d.node,e,n)})), ${d.endRef}, holeContent(${d.startRef}, ${d.endRef}));`);return c.push("return _el$;"),`(() => { ${c.join(" ")} })()`}}e.add("createNativeElement");let o=JSON.stringify(t.tag),r="_el$",i=[],l=t.svg?`${o}, true`:o;if(i.push(`const ${r} = createNativeElement(${l});`),t.props.length>0)if(!t.svg&&t.props.every(C))for(let s of t.props)i.push(Ve(r,s));else{e.add("spread");let s=t.svg?", isSVG: true":"";i.push(`spread({ element: ${r}, props: ${Ue(t.props,null,e)}${s} });`)}for(let s of t.children){e.add("insert");let a=I(s,e,n),c=s.kind==="expr"&&s.reactive||s.kind==="component"||s.kind==="control";i.push(c?`insert(${r}, ${a}, null);`:`insert(${r}, ${a});`)}return i.push(`return ${r};`),`(() => { ${i.join(" ")} })()`}}}function D(t,e){if(!e||e.length===0)return t;let n=new Map(e.map(o=>[o.id,JSON.stringify(o.html)]));return t.replace(/_tmpl\$\d+/g,o=>n.get(o)??o)}var v={name:"imperative",contract:j,emit(t,e){let n=new Set,o=e?.templateClone!==!1?[]:void 0;return le=e?.partialTemplates===!0,{code:I(t,n,o),imports:Array.from(n),templates:o}}};function w(t){let e=t.split(/\r\n|\n|\r/),n=0;for(let r=0;r<e.length;r++)/[^ \t]/.test(e[r])&&(n=r);let o="";for(let r=0;r<e.length;r++){let i=e[r].replace(/\t/g," ");r!==0&&(i=i.replace(/^ +/,"")),r!==e.length-1&&(i=i.replace(/ +$/,"")),i&&(r!==n&&(i+=" "),o+=i)}return o}var ae=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function qe(t){return t.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function ce(t){return t.charAt(0).toUpperCase()+t.slice(1)}var J=class{constructor(e,n){this.holes=e;this.used=n}hole(e){return this.holes[e]??{code:"undefined",reactive:!1}}emit(e){let{code:n,imports:o,templates:r}=v.emit(e,{});for(let i of o)this.used.add(i);return D(n,r)}lowerRoot(e){let n=this.lowerChildren(e);return n.length===1?n[0]:{kind:"fragment",children:n}}lowerChildren(e){let n=[];for(let o=0;o<e.length;o++){let r=e[o];if(r.kind==="Element"||r.kind==="Component"){let l=r.attributes.find(s=>s.kind==="IfDirective");if(l&&l.kind==="IfDirective"){let s=o+1;s<e.length&&this.isBlankText(e[s])&&s++;let a=e[s],c=a&&(a.kind==="Element"||a.kind==="Component")&&a.attributes.some(d=>d.kind==="ElseDirective");n.push(this.lowerIf(r,l.hole,c?a:null)),c&&(o=s);continue}if(r.attributes.some(s=>s.kind==="EachDirective")){n.push(this.lowerEach(r));continue}}let i=this.lowerNode(r);i&&n.push(i)}return n}isBlankText(e){return e.kind==="Text"&&!e.raw&&w(e.value)===""}lowerNode(e){switch(e.kind){case"Text":{if(e.raw)return{kind:"text",value:e.value};let n=w(e.value);return n?{kind:"text",value:n}:null}case"Comment":return null;case"Expression":{let n=this.hole(e.hole);return{kind:"expr",code:n.code,reactive:n.reactive}}case"Fragment":return{kind:"fragment",children:this.lowerChildren(e.children)};case"Element":return this.lowerElement(e);case"Component":return this.lowerComponent(e);default:return null}}lowerElement(e){let n=e.attributes.find(o=>o.kind==="Attribute"&&o.name==="is");if(e.tag==="component"&&n&&n.value&&n.value.kind==="hole"){let o=e.attributes.filter(i=>i!==n),r=this.lowerComponent({...e,kind:"Component",tag:"Dynamic",tagHole:null,attributes:o});return r.props.unshift({name:"component",kind:"attr",expr:`() => (${this.hole(n.value.hole).code})`}),r}return{kind:"element",tag:e.tag,svg:e.namespace==="svg",props:this.lowerAttributes(e.attributes),children:this.lowerChildren(e.children),static:!1}}lowerComponent(e){let n=e.tagHole!=null?this.hole(e.tagHole).code:e.tag,o=this.lowerAttributes(e.attributes),{slots:r,rest:i}=this.partitionSlots(e.children);for(let[a,c]of r){let d=c.length===1?c[0]:{kind:"fragment",children:c},p={name:a,kind:"attr",expr:this.emit(d),jsxElement:!0},u=o.findIndex(h=>h.name===a);u>=0?o[u]=p:o.push(p)}let l=e.attributes.find(a=>a.kind==="LoadDirective"),s=l?K(`load:${l.strategy}`,l.modifier):void 0;return{kind:"component",name:n,props:o,children:this.lowerChildren(i),...s?{load:s}:{}}}partitionSlots(e){let n=new Map,o=[];for(let r of e){if(r.kind==="Element"||r.kind==="Component"){let i=r.attributes.find(l=>l.kind==="Attribute"&&l.name==="slot");if(i&&i.value&&i.value.kind==="static"){let l={...r,attributes:r.attributes.filter(c=>c!==i)},s=l.kind==="Element"?this.lowerElement(l):this.lowerComponent(l),a=n.get(i.value.value)??[];a.push(s),n.set(i.value.value,a);continue}}o.push(r)}return{slots:n,rest:o}}lowerIf(e,n,o){let r=this.hole(n),i=[{name:"when",kind:"attr",expr:r.code,reactive:r.reactive}];if(o){let s=this.stripAndLower(o,a=>a.kind==="ElseDirective");i.push({name:"fallback",kind:"attr",expr:this.emit(s),jsxElement:!0})}let l=this.stripAndLower(e,s=>s.kind==="IfDirective");return{kind:"component",name:"Show",props:i,children:[l]}}lowerEach(e){let n=e.attributes.find(a=>a.kind==="EachDirective");if(!n||n.kind!=="EachDirective")return this.lowerNode(e);let o=this.hole(n.hole),r=[{name:"each",kind:"attr",expr:o.code,reactive:o.reactive}];if(n.key){let a="static"in n.key?`(item) => item[${JSON.stringify(n.key.static)}]`:this.hole(n.key.hole).code;r.push({name:"by",kind:"attr",expr:a})}let i=this.itemArrow(e),l;if(i){let a={kind:"expr",code:i.body,reactive:i.bodyReactive},c=this.rebuildWithChildren(e,[a]);l=`(${i.params.join(", ")}) => (${this.emit(c)})`}else{let a=this.stripAndLower(e,c=>c.kind==="EachDirective");l=`() => (${this.emit(a)})`}return{kind:"component",name:"For",props:r,children:[{kind:"expr",code:l,reactive:!1}]}}itemArrow(e){let n=e.children.filter(o=>!this.isBlankText(o));return n.length!==1||n[0].kind!=="Expression"?null:this.hole(n[0].hole).arrow??null}stripAndLower(e,n){let o={...e,attributes:e.attributes.filter(r=>!n(r))};return o.kind==="Element"?this.lowerElement(o):this.lowerComponent(o)}rebuildWithChildren(e,n){let o=this.lowerAttributes(e.attributes.filter(r=>r.kind!=="EachDirective"));return e.kind==="Element"?{kind:"element",tag:e.tag,svg:e.namespace==="svg",props:o,children:n,static:!1}:{kind:"component",name:e.tag,props:o,children:n}}lowerAttributes(e){let n=[],o=[],r=!1,i=[],l=!1,s=[];for(let a of e)switch(a.kind){case"IfDirective":case"EachDirective":case"ElseDirective":break;case"Attribute":n.push(this.plainAttr(a));break;case"PropertyBinding":n.push({name:a.name,kind:"prop",expr:this.hole(a.hole).code,reactive:this.hole(a.hole).reactive});break;case"EventBinding":n.push(this.eventProp(a));break;case"RefBinding":n.push({name:"ref",kind:"ref",expr:this.hole(a.hole).code,reactive:this.hole(a.hole).reactive});break;case"Spread":n.push({name:"",kind:"spread",expr:this.hole(a.hole).code});break;case"ClassDirective":{let c=this.hole(a.hole);o.push(`${JSON.stringify(a.name)}: ${c.code}`),r=r||c.reactive;break}case"StyleDirective":{let c=this.hole(a.hole);i.push(`${JSON.stringify(a.name)}: ${c.code}`),l=l||c.reactive;break}case"BindDirective":n.push(...this.bindProps(a.name,this.hole(a.hole).code));break;case"UseDirective":{let c=a.name??(a.hole!=null?this.hole(a.hole).code:null);if(!c)break;s.push(a.name!=null&&a.hole!=null?`[${c}, () => (${this.hole(a.hole).code})]`:`[${c}]`);break}}return o.length>0&&n.push({name:"classList",kind:"attr",expr:`{ ${o.join(", ")} }`,reactive:r}),i.length>0&&n.push({name:"style",kind:"attr",expr:`{ ${i.join(", ")} }`,reactive:l}),s.length>0&&n.push({name:"use",kind:"attr",expr:`[${s.join(", ")}]`}),n}eventProp(e){let n=e.name.toLowerCase(),o=this.hole(e.hole).code;if(!(e.syntax==="colon"||e.modifiers.length>0))return{name:"on"+ce(e.name),kind:"event",event:{name:n,delegated:ae.has(n)},expr:o};let i=this.wrapHandler(o,e.modifiers),l=this.eventOptions(e.modifiers),s=l?`[${i}, ${l}]`:i;return{name:"on:"+n,kind:"attr",expr:s}}wrapHandler(e,n){let o=n.includes("self")?"if (e.target !== e.currentTarget) return; ":"",r=[];return n.includes("prevent")&&r.push("e.preventDefault();"),n.includes("stop")&&r.push("e.stopPropagation();"),!o&&r.length===0?e:`(e) => { ${o}${r.join(" ")} return (${e})(e); }`}eventOptions(e){let n=[];return e.includes("capture")&&n.push("capture: true"),e.includes("once")&&n.push("once: true"),e.includes("passive")&&n.push("passive: true"),n.length?`{ ${n.join(", ")} }`:null}bindProps(e,n){let o=e==="checked",r=o?"change":"input",i=o?"checked":"value",l=`(${n})`;return[{name:e,kind:"attr",expr:`${l}[0]()`,reactive:!0},{name:"on"+ce(r),kind:"event",event:{name:r,delegated:ae.has(r)},expr:`(e) => ${l}[1](e.target.${i})`}]}plainAttr(e){let n=e.value,o=e.name;e.name==="class"?o=n&&n.kind==="hole"&&this.hole(n.hole).object?"classList":"className":e.name==="html"&&(o="innerHTML");let i={name:o,kind:"attr"};if(n==null)return i.literal=!0,i;if(n.kind==="static")return i.literal=n.value,i;if(n.kind==="hole"){let a=this.hole(n.hole);return i.expr=a.code,i.reactive=a.reactive,i}let l=!1,s=n.parts.map(a=>{if("text"in a)return qe(a.text);let c=this.hole(a.hole);return l=l||c.reactive,"${"+c.code+"}"}).join("");return i.expr="`"+s+"`",i.reactive=l,i}};function L(t,e,n,o={}){let{root:r}=(0,pe.parseTemplate)(t,{svg:o.svg});return new J(e,n).lowerRoot(r.children)}function Ke(t){switch(t.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 t.reactive?"reactive-prop":t.expr!==void 0?"expression-prop":void 0;default:return"expression-prop"}}function de(t){let e=[],n=new Map,o=r=>{switch(r.kind){case"text":return!0;case"expr":return!1;case"component":case"control":for(let i of r.children)o(i);return!1;case"fragment":for(let i of r.children)o(i);return!1;case"element":{let i=!0;for(let s of r.children)o(s)||(i=!1);let l;for(let s of r.props)if(l=Ke(s),l)break;return!l&&!i&&(l=Ze(r)),r.static=!l,l?n.set(r,l):e.push(r),r.static}default:return!1}};for(let r of Array.isArray(t)?t:[t])o(r);return{staticElements:e,reasons:n}}function Ze(t){for(let e of t.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"}var _=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],B=["Suspense","SuspenseList","Await"],b=["Router","Outlet","Redirect","Link"],Ye=[..._,...B,...b],H=new Set([..._,...B]);function y(t={}){let{controlFlowModule:e="@fluixi/dom",coreModule:n="@fluixi/core",routerModule:o="@fluixi/core/router-next"}=t,r={};for(let i of _)r[i]=e;for(let i of B)r[i]=n;for(let i of b)r[i]=o;return r}function Xe(t={}){return{components:y(t)}}function Qe(t){let e=t??"@fluixi/core/router-next";return{components:Object.fromEntries(b.map(n=>[n,e]))}}function z(t,e={}){let{resolver:n,isBound:o,modules:r,strategyFor:i}=e,l=y(r),s=new Map,a=new Set,c=p=>{let{name:u}=p;if(!u||u.includes(".")||o?.(u))return;let h=d(u);if(!h){a.add(u);return}let x=h.origin==="builtin"&&H.has(u)?M:i?.(p)??M;p.source={...h,loading:x},s.set(u,p.source)},d=p=>{if(H.has(p))return{module:l[p],export:p,origin:"builtin"};let u=n?.resolve(p);if(u)return{module:u.module,export:u.export,origin:"rule"};if(b.includes(p))return{module:l[p],export:p,origin:"builtin"}};return $(t,p=>{p.kind==="component"&&c(p)}),{resolved:s,unresolved:[...a]}}function $(t,e){let n=Array.isArray(t)?t:[t];for(let o of n){e(o);let r=o.children;r&&$(r,e)}}function ue(t){let e=[];$(t,i=>{i.kind==="component"&&i.source&&e.push(i)});let n=new Set,o=new Set;for(let i of e){let{module:l,loading:s}=i.source;s.kind==="eager"&&n.add(l),s.kind==="never"&&o.add(l)}let r=new Map;for(let i of e){let l=i.source;Z(l.loading)&&n.has(l.module)&&(l.loading={kind:"eager"},r.set(l.module,(r.get(l.module)??0)+1))}return{collapsed:r,conflicted:[...o].filter(i=>n.has(i))}}var et=t=>"components"in t;function me(t,e){return t.replace(/\$(\d+)/g,(n,o)=>e[Number(o)]??n)}function tt(t,e){return typeof e=="string"?{module:e,export:t}:e}function T(t=[]){let e=new Map,n=[],o=[];for(let l of t){if(!et(l)){o.push(l);continue}for(let[s,a]of Object.entries(l.components)){let c=tt(s,a),d=e.get(s);if(d&&d.module!==c.module){let p=n.find(u=>u.name===s);p?p.modules.push(c.module):n.push({name:s,modules:[d.module,c.module]});continue}e.set(s,c)}}let r=new Map;return{resolve:l=>{if(r.has(l))return r.get(l);let s=e.get(l);if(!s)for(let a of o){let c=l.match(new RegExp(a.match.source,a.match.flags.replace("g","")));if(c){s={module:me(a.module,c),export:a.export?me(a.export,c):l};break}}return r.set(l,s),s},names:()=>[...e.keys()],conflicts:()=>n}}function nt(t){let e=[],n=0;return t.statics.forEach((o,r)=>{if(e.push({kind:"static",text:o,start:n}),n+=o.length,r<t.holes.length){let i=n+t.holes[r].code.length;e.push({kind:"hole",index:r,start:n,end:i}),n=i}}),e}function rt(t,e={}){if(t.statics.length!==t.holes.length+1)throw new Error(`[fluixi] compileTemplate: ${t.statics.length} static runs for ${t.holes.length} holes — a template always has exactly one more.`);return fe(nt(t),t.holes,e)}function fe(t,e,n={}){let o=new Set,r=L(t,[...e],o,{svg:n.svg});de(r),z(r,{resolver:T(n.resolve??[]),modules:{controlFlowModule:n.controlFlowModule??"@fluixi/dom",coreModule:n.coreModule??"@fluixi/core",routerModule:n.routerModule??"@fluixi/core/router-next"},strategyFor:a=>a.load}),ue(r);let{code:i,imports:l,templates:s}=v.emit(r,{templateClone:n.templateClone,partialTemplates:n.partialTemplates});for(let a of l)o.add(a);return n.hoistTemplates?{code:i,imports:[...o],ir:r,templates:s}:{code:D(i,s),imports:[...o],ir:r}}var ot=new Set(["Text","Image","Option","Audio","Comment","Range","Selection","Notification","Event","Document","Element","Node","Screen","Window","Location","History","Storage","Response","Request","Headers"]);function it(t){if(t.startsWith(".")||t.startsWith("/")||/^[~@]\//.test(t))return;let e=t.split("/");return t.startsWith("@")?e.slice(0,2).join("/"):e[0]}function ge(t){return`_${t.replace(/[^A-Za-z0-9]/g,"_")}`}function U(t,e={}){let{available:n,builtins:o=!0,generator:r="@fluixi/compiler",specifier:i=m=>m}=e,l=[...t];o&&l.push({components:y()});let s=T(l),a=n?new Set(n):void 0,c=[],d=[],p=[],u=new Map;for(let m of[...s.names()].sort()){let g=s.resolve(m);if(!g)continue;let N=it(g.module);ot.has(m)?d.push(m):a&&N&&!a.has(N)?p.push(m):(c.push(m),u.set(m,g))}let x=[...new Set(c.map(m=>u.get(m).module))].sort().map(m=>`import * as ${ge(m)} from '${i(m)}';`),S=c.map(m=>{let g=u.get(m),N=ge(g.module);return g.export==="default"?` const ${m}: typeof ${N}.default;`:` export import ${m} = ${N}.${g.export};`}),xe=d.length>0?`//
|
|
1
|
+
"use strict";var W=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var we=Object.prototype.hasOwnProperty;var Se=(t,e)=>{for(var n in e)W(t,n,{get:e[n],enumerable:!0})},Te=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of $e(e))!we.call(t,r)&&r!==n&&W(t,r,{get:()=>e[r],enumerable:!(o=Ce(e,r))||o.enumerable});return t};var Oe=t=>Te(W({},"__esModule",{value:!0}),t);var Rt={};Se(Rt,{BUILTIN_COMPONENTS:()=>nt,CORE_CONTROL_FLOW:()=>B,DEFAULT_GLOBALS_PATH:()=>be,DOM_CONTROL_FLOW:()=>_,RESERVED_COMPONENTS:()=>H,ROUTER_COMPONENTS:()=>y,RUNTIME_CONTRACT_V1:()=>j,RUNTIME_CONTRACT_V2:()=>ze,backends:()=>vt,builtinComponentMap:()=>N,builtinComponents:()=>rt,cleanTemplateText:()=>w,compilePieces:()=>Re,compileTemplate:()=>lt,componentGlobals:()=>K,createComponentResolver:()=>T,defaultOptions:()=>ht,imperativeBackend:()=>v,isReactiveShape:()=>Y,lowerTemplate:()=>L,resolveComponentSources:()=>V,routerComponents:()=>ot,walk:()=>S,writeComponentGlobals:()=>gt});module.exports=Oe(Rt);var Me="children";function Y(t){switch(t.kind){case"call":return!0;case"member":return t.property!==Me;case"compound":return t.parts.some(Y);case"opaque":return!1}}var fe=require("@fluixi/template-parser");var M={kind:"eager"},Pe=["pointerdown","focusin","keydown"],X=new Set(["eager","idle","visible","interaction","media","never"]),k=class extends Error{};function Q(t,e){let n=t.slice(5);if(!X.has(n))throw new k(`Unknown load strategy 'load:${n}'. Expected one of ${[...X].join(", ")}.`);switch(n){case"eager":return M;case"idle":return{kind:"idle"};case"never":return{kind:"never"};case"visible":return e?{kind:"visible",rootMargin:e}:{kind:"visible"};case"interaction":return{kind:"interaction",events:e?Ae(e):[...Pe]};case"media":if(!e)throw new k(`'load:media' needs a query, e.g. load:media="(min-width: 1024px)".`);return{kind:"media",query:e};default:throw new k(`Unhandled load strategy '${n}'.`)}}function Ae(t){let e=t.split(/[\s,]+/).map(n=>n.trim()).filter(Boolean);if(e.length===0)throw new k("'load:interaction' was given no event names.");return e}function ee(t){return t.kind!=="eager"&&t.kind!=="never"}var je=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),te={className:"class",htmlFor:"for"},De=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),Le=new Set(["script","style","textarea","title"]);function U(t){return Le.has(t)}function ne(t){return te[t]??t}function E(t){return t.kind!=="attr"||t.expr!==void 0||t.name.includes(":")?!1:!De.has(t.name)}function J(t){if(!t.static||U(t.tag))return!1;for(let e of t.props)if(!E(e))return!1;for(let e of t.children)if(e.kind!=="text"&&!(e.kind==="element"&&J(e)))return!1;return!0}function C(t){let e=t.props.map(Be).filter(Boolean).join(""),n=`<${t.tag}${e}>`;return je.has(t.tag)?n:`${n}${t.children.map(_e).join("")}</${t.tag}>`}function _e(t){if(t.kind==="text")return Fe(t.value);if(t.kind!=="element")throw new Error(`serializeStatic: unexpected ${t.kind}`);return C(t)}function Be(t){let e=te[t.name]??t.name,n=t.literal;return n===!0||n===void 0?` ${e}`:n===!1||n===null?"":` ${e}="${He(String(n))}"`}function He(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Fe(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var Ge="<!--fx-->",We="<!--fx/-->";function A(t){return t.kind==="expr"||t.kind==="component"||t.kind==="control"}function Ue(t){return t.kind==="text"||t.kind==="element"&&re(t)}function re(t){return t.svg||U(t.tag)||!t.props.every(e=>E(e))?!1:t.children.every(e=>Ue(e)||A(e))}function P(t){if(A(t))return!0;let e=t.children;return e?e.some(P):!1}function oe(t){for(let e=0;e<t.children.length;e++){let n=t.children[e];if(n.kind==="text"&&(n.value===""||t.children[e+1]?.kind==="text"))return!1}return t.children.every(e=>e.kind!=="element"||oe(e))}function ie(t){if(!re(t)||!oe(t)||!t.children.some(P))return null;let e=[],n=[],o=0,r=a=>{let s=`_n$${o++}`;return e.push({ref:s,expr:a}),s};return i(t,"_el$"),{html:Je(t),tag:t.tag,steps:e,holes:n};function i(a,s){let l=-1;a.children.forEach((d,p)=>{P(d)&&(l=p)});let c=null;for(let d=0;d<=l;d++){let p=a.children[d],m=c?`${c}.nextSibling`:`${s}.firstChild`;if(A(p)){let b=r(m),G=r(`holeEnd(${b})`);n.push({parentRef:s,startRef:b,endRef:G,node:p}),c=G;continue}let h=r(m);p.kind==="element"&&P(p)&&i(p,h),c=h}}}function Je(t){return C(se(t)).split(ae).join(Ge+We)}function se(t){return{...t,children:t.children.map(e=>A(e)?{kind:"text",value:ae}:e.kind==="element"?se(e):e)}}var ae="\0fx-hole\0";var j={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},ze={version:2,module:"@fluixi/dom",symbols:[...j.symbols,"template","cloneTemplate","walk"]};var Ve={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function qe(t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)}function ce(t){return qe(t)?t:JSON.stringify(t)}function Ke(t){return t.expr!==void 0?t.reactive?`() => (${t.expr})`:`(${t.expr})`:JSON.stringify(t.literal??!0)}function Ze(t){return t.expr!==void 0?`(${t.expr})`:JSON.stringify(t.literal??!0)}function Ye(t,e,n){let o=t.filter(s=>s.kind==="spread"),i=t.filter(s=>s.kind!=="spread").map(s=>`${ce(s.name)}: ${Ke(s)}`);e!=null&&i.push(`children: ${e}`);let a=`{ ${i.join(", ")} }`;return o.length>0?(n.add("mergeProps"),`mergeProps(${o.map(s=>s.expr).join(", ")}, ${a})`):a}function pe(t,e,n){return t.length===1?$(t[0],e,n):`[${t.map(o=>$(o,e,n)).join(", ")}]`}function le(t,e,n,o,r){o.add("createMemo"),o.add("createComponent");let i=e.filter(c=>c.kind==="spread"),s=e.filter(c=>c.kind!=="spread").map(c=>`get ${ce(c.name)}() { return ${Ze(c)}; }`);n.length>0&&s.push(`get children() { return ${pe(n,o,r)}; }`);let l=`{ ${s.join(", ")} }`;return i.length>0&&(o.add("mergeProps"),l=`mergeProps(${i.map(c=>c.expr).join(", ")}, ${l})`),`createMemo(() => createComponent(${t}, ${l}))`}function Xe(t,e){let n=ne(e.name),o=e.literal;return o===!0||o===void 0?`${t}.setAttribute(${JSON.stringify(n)}, "");`:o===!1||o===null?"":`${t}.setAttribute(${JSON.stringify(n)}, ${JSON.stringify(String(o))});`}var de=!1;function $(t,e,n){switch(t.kind){case"text":return JSON.stringify(t.value);case"expr":return t.reactive?`() => (${t.code})`:`(${t.code})`;case"fragment":return t.children.length===0?"null":pe(t.children,e,n);case"component":return le(t.name,t.props,t.children,e,n);case"control":{let o=Ve[t.control]??t.control;return e.add(o),le(o,t.props,t.children,e,n)}case"element":{if(n&&t.static&&!t.svg&&J(t)){e.add("templateNode");let s=`_tmpl$${n.length}`;return n.push({id:s,html:C(t),tag:t.tag,svg:!1}),`templateNode(${s}, ${JSON.stringify(t.tag)})`}if(n&&de){let s=ie(t);if(s){e.add("templateNode"),e.add("insert"),e.add("holeEnd"),e.add("holeContent"),e.add("holeScope");let l=`_tmpl$${n.length}`;n.push({id:l,html:s.html,tag:s.tag,svg:!1});let c=[`const _el$ = templateNode(${l}, ${JSON.stringify(s.tag)}, true);`];for(let d of s.steps)c.push(`const ${d.ref} = ${d.expr};`);for(let d of s.holes)c.push(`insert(${d.parentRef}, holeScope(${d.startRef}, () => (${$(d.node,e,n)})), ${d.endRef}, holeContent(${d.startRef}, ${d.endRef}));`);return c.push("return _el$;"),`(() => { ${c.join(" ")} })()`}}e.add("createNativeElement");let o=JSON.stringify(t.tag),r="_el$",i=[],a=t.svg?`${o}, true`:o;if(i.push(`const ${r} = createNativeElement(${a});`),t.props.length>0)if(!t.svg&&t.props.every(E))for(let s of t.props)i.push(Xe(r,s));else{e.add("spread");let s=t.svg?", isSVG: true":"";i.push(`spread({ element: ${r}, props: ${Ye(t.props,null,e)}${s} });`)}for(let s of t.children){e.add("insert");let l=$(s,e,n),c=s.kind==="expr"&&s.reactive||s.kind==="component"||s.kind==="control";i.push(c?`insert(${r}, ${l}, null);`:`insert(${r}, ${l});`)}return i.push(`return ${r};`),`(() => { ${i.join(" ")} })()`}}}function D(t,e){if(!e||e.length===0)return t;let n=new Map(e.map(o=>[o.id,JSON.stringify(o.html)]));return t.replace(/_tmpl\$\d+/g,o=>n.get(o)??o)}var v={name:"imperative",contract:j,emit(t,e){let n=new Set,o=e?.templateClone!==!1?[]:void 0;return de=e?.partialTemplates===!0,{code:$(t,n,o),imports:Array.from(n),templates:o}}};function w(t){let e=t.split(/\r\n|\n|\r/),n=0;for(let r=0;r<e.length;r++)/[^ \t]/.test(e[r])&&(n=r);let o="";for(let r=0;r<e.length;r++){let i=e[r].replace(/\t/g," ");r!==0&&(i=i.replace(/^ +/,"")),r!==e.length-1&&(i=i.replace(/ +$/,"")),i&&(r!==n&&(i+=" "),o+=i)}return o}var ue=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function Qe(t){return t.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function me(t){return t.charAt(0).toUpperCase()+t.slice(1)}var z=class{constructor(e,n){this.holes=e;this.used=n}hole(e){return this.holes[e]??{code:"undefined",reactive:!1}}emit(e){let{code:n,imports:o,templates:r}=v.emit(e,{});for(let i of o)this.used.add(i);return D(n,r)}lowerRoot(e){let n=this.lowerChildren(e);return n.length===1?n[0]:{kind:"fragment",children:n}}lowerChildren(e){let n=[];for(let o=0;o<e.length;o++){let r=e[o];if(r.kind==="Element"||r.kind==="Component"){let a=r.attributes.find(s=>s.kind==="IfDirective");if(a&&a.kind==="IfDirective"){let s=o+1;s<e.length&&this.isBlankText(e[s])&&s++;let l=e[s],c=l&&(l.kind==="Element"||l.kind==="Component")&&l.attributes.some(d=>d.kind==="ElseDirective");n.push(this.lowerIf(r,a.hole,c?l:null)),c&&(o=s);continue}if(r.attributes.some(s=>s.kind==="EachDirective")){n.push(this.lowerEach(r));continue}}let i=this.lowerNode(r);i&&n.push(i)}return n}isBlankText(e){return e.kind==="Text"&&!e.raw&&w(e.value)===""}lowerNode(e){switch(e.kind){case"Text":{if(e.raw)return{kind:"text",value:e.value};let n=w(e.value);return n?{kind:"text",value:n}:null}case"Comment":return null;case"Expression":{let n=this.hole(e.hole);return{kind:"expr",code:n.code,reactive:n.reactive}}case"Fragment":return{kind:"fragment",children:this.lowerChildren(e.children)};case"Element":return this.lowerElement(e);case"Component":return this.lowerComponent(e);default:return null}}lowerElement(e){let n=e.attributes.find(o=>o.kind==="Attribute"&&o.name==="is");if(e.tag==="component"&&n&&n.value&&n.value.kind==="hole"){let o=e.attributes.filter(i=>i!==n),r=this.lowerComponent({...e,kind:"Component",tag:"Dynamic",tagHole:null,attributes:o});return r.props.unshift({name:"component",kind:"attr",expr:`() => (${this.hole(n.value.hole).code})`}),r}return{kind:"element",tag:e.tag,svg:e.namespace==="svg",props:this.lowerAttributes(e.attributes),children:this.lowerChildren(e.children),static:!1}}lowerComponent(e){let n=e.tagHole!=null?this.hole(e.tagHole).code:e.tag,o=this.lowerAttributes(e.attributes),{slots:r,rest:i}=this.partitionSlots(e.children);for(let[l,c]of r){let d=c.length===1?c[0]:{kind:"fragment",children:c},p={name:l,kind:"attr",expr:this.emit(d),jsxElement:!0},m=o.findIndex(h=>h.name===l);m>=0?o[m]=p:o.push(p)}let a=e.attributes.find(l=>l.kind==="LoadDirective"),s=a?Q(`load:${a.strategy}`,a.modifier):void 0;return{kind:"component",name:n,props:o,children:this.lowerChildren(i),...s?{load:s}:{}}}partitionSlots(e){let n=new Map,o=[];for(let r of e){if(r.kind==="Element"||r.kind==="Component"){let i=r.attributes.find(a=>a.kind==="Attribute"&&a.name==="slot");if(i&&i.value&&i.value.kind==="static"){let a={...r,attributes:r.attributes.filter(c=>c!==i)},s=a.kind==="Element"?this.lowerElement(a):this.lowerComponent(a),l=n.get(i.value.value)??[];l.push(s),n.set(i.value.value,l);continue}}o.push(r)}return{slots:n,rest:o}}lowerIf(e,n,o){let r=this.hole(n),i=[{name:"when",kind:"attr",expr:r.code,reactive:r.reactive}];if(o){let s=this.stripAndLower(o,l=>l.kind==="ElseDirective");i.push({name:"fallback",kind:"attr",expr:this.emit(s),jsxElement:!0})}let a=this.stripAndLower(e,s=>s.kind==="IfDirective");return{kind:"component",name:"Show",props:i,children:[a]}}lowerEach(e){let n=e.attributes.find(l=>l.kind==="EachDirective");if(!n||n.kind!=="EachDirective")return this.lowerNode(e);let o=this.hole(n.hole),r=[{name:"each",kind:"attr",expr:o.code,reactive:o.reactive}];if(n.key){let l="static"in n.key?`(item) => item[${JSON.stringify(n.key.static)}]`:this.hole(n.key.hole).code;r.push({name:"by",kind:"attr",expr:l})}let i=this.itemArrow(e),a;if(i){let l={kind:"expr",code:i.body,reactive:i.bodyReactive},c=this.rebuildWithChildren(e,[l]);a=`(${i.params.join(", ")}) => (${this.emit(c)})`}else{let l=this.stripAndLower(e,c=>c.kind==="EachDirective");a=`() => (${this.emit(l)})`}return{kind:"component",name:"For",props:r,children:[{kind:"expr",code:a,reactive:!1}]}}itemArrow(e){let n=e.children.filter(o=>!this.isBlankText(o));return n.length!==1||n[0].kind!=="Expression"?null:this.hole(n[0].hole).arrow??null}stripAndLower(e,n){let o={...e,attributes:e.attributes.filter(r=>!n(r))};return o.kind==="Element"?this.lowerElement(o):this.lowerComponent(o)}rebuildWithChildren(e,n){let o=this.lowerAttributes(e.attributes.filter(r=>r.kind!=="EachDirective"));return e.kind==="Element"?{kind:"element",tag:e.tag,svg:e.namespace==="svg",props:o,children:n,static:!1}:{kind:"component",name:e.tag,props:o,children:n}}lowerAttributes(e){let n=[],o=[],r=!1,i=[],a=!1,s=[];for(let l of e)switch(l.kind){case"IfDirective":case"EachDirective":case"ElseDirective":break;case"Attribute":n.push(this.plainAttr(l));break;case"PropertyBinding":n.push({name:l.name,kind:"prop",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"EventBinding":n.push(this.eventProp(l));break;case"RefBinding":n.push({name:"ref",kind:"ref",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"Spread":n.push({name:"",kind:"spread",expr:this.hole(l.hole).code});break;case"ClassDirective":{let c=this.hole(l.hole);o.push(`${JSON.stringify(l.name)}: ${c.code}`),r=r||c.reactive;break}case"StyleDirective":{let c=this.hole(l.hole);i.push(`${JSON.stringify(l.name)}: ${c.code}`),a=a||c.reactive;break}case"BindDirective":n.push(...this.bindProps(l.name,this.hole(l.hole).code));break;case"UseDirective":{let c=l.name??(l.hole!=null?this.hole(l.hole).code:null);if(!c)break;s.push(l.name!=null&&l.hole!=null?`[${c}, () => (${this.hole(l.hole).code})]`:`[${c}]`);break}}return o.length>0&&n.push({name:"classList",kind:"attr",expr:`{ ${o.join(", ")} }`,reactive:r}),i.length>0&&n.push({name:"style",kind:"attr",expr:`{ ${i.join(", ")} }`,reactive:a}),s.length>0&&n.push({name:"use",kind:"attr",expr:`[${s.join(", ")}]`}),n}eventProp(e){let n=e.name.toLowerCase(),o=this.hole(e.hole).code;if(!(e.syntax==="colon"||e.modifiers.length>0))return{name:"on"+me(e.name),kind:"event",event:{name:n,delegated:ue.has(n)},expr:o};let i=this.wrapHandler(o,e.modifiers),a=this.eventOptions(e.modifiers),s=a?`[${i}, ${a}]`:i;return{name:"on:"+n,kind:"attr",expr:s}}wrapHandler(e,n){let o=n.includes("self")?"if (e.target !== e.currentTarget) return; ":"",r=[];return n.includes("prevent")&&r.push("e.preventDefault();"),n.includes("stop")&&r.push("e.stopPropagation();"),!o&&r.length===0?e:`(e) => { ${o}${r.join(" ")} return (${e})(e); }`}eventOptions(e){let n=[];return e.includes("capture")&&n.push("capture: true"),e.includes("once")&&n.push("once: true"),e.includes("passive")&&n.push("passive: true"),n.length?`{ ${n.join(", ")} }`:null}bindProps(e,n){let o=e==="checked",r=o?"change":"input",i=o?"checked":"value";this.used.add("bindPair");let a=`bindPair(${n})`;return[{name:e,kind:"attr",expr:`${a}[0]()`,reactive:!0},{name:"on"+me(r),kind:"event",event:{name:r,delegated:ue.has(r)},expr:`(e) => ${a}[1](e.target.${i})`}]}plainAttr(e){let n=e.value,o=e.name;e.name==="class"?o=n&&n.kind==="hole"&&this.hole(n.hole).object?"classList":"className":e.name==="html"&&(o="innerHTML");let i={name:o,kind:"attr"};if(n==null)return i.literal=!0,i;if(n.kind==="static")return i.literal=n.value,i;if(n.kind==="hole"){let l=this.hole(n.hole);return i.expr=l.code,i.reactive=l.reactive,i}let a=!1,s=n.parts.map(l=>{if("text"in l)return Qe(l.text);let c=this.hole(l.hole);return a=a||c.reactive,"${"+c.code+"}"}).join("");return i.expr="`"+s+"`",i.reactive=a,i}};function L(t,e,n,o={}){let{root:r}=(0,fe.parseTemplate)(t,{svg:o.svg});return new z(e,n).lowerRoot(r.children)}function et(t){switch(t.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 t.reactive?"reactive-prop":t.expr!==void 0?"expression-prop":void 0;default:return"expression-prop"}}function ge(t){let e=[],n=new Map,o=r=>{switch(r.kind){case"text":return!0;case"expr":return!1;case"component":case"control":for(let i of r.children)o(i);return!1;case"fragment":for(let i of r.children)o(i);return!1;case"element":{let i=!0;for(let s of r.children)o(s)||(i=!1);let a;for(let s of r.props)if(a=et(s),a)break;return!a&&!i&&(a=tt(r)),r.static=!a,a?n.set(r,a):e.push(r),r.static}default:return!1}};for(let r of Array.isArray(t)?t:[t])o(r);return{staticElements:e,reasons:n}}function tt(t){for(let e of t.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"}var _=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],B=["Suspense","SuspenseList","Await"],y=["Router","Outlet","Redirect","Link"],nt=[..._,...B,...y],H=new Set([..._,...B]);function N(t={}){let{controlFlowModule:e="@fluixi/dom",coreModule:n="@fluixi/core",routerModule:o="@fluixi/core/router-next"}=t,r={};for(let i of _)r[i]=e;for(let i of B)r[i]=n;for(let i of y)r[i]=o;return r}function rt(t={}){return{components:N(t)}}function ot(t){let e=t??"@fluixi/core/router-next";return{components:Object.fromEntries(y.map(n=>[n,e]))}}function V(t,e={}){let{resolver:n,isBound:o,modules:r,strategyFor:i}=e,a=N(r),s=new Map,l=new Set,c=p=>{let{name:m}=p;if(!m||m.includes(".")||o?.(m))return;let h=d(m);if(!h){l.add(m);return}let b=h.origin==="builtin"&&H.has(m)?M:i?.(p)??M;p.source={...h,loading:b},s.set(m,p.source)},d=p=>{if(H.has(p))return{module:a[p],export:p,origin:"builtin"};let m=n?.resolve(p);if(m)return{module:m.module,export:m.export,origin:"rule"};if(y.includes(p))return{module:a[p],export:p,origin:"builtin"}};return S(t,p=>{p.kind==="component"&&c(p)}),{resolved:s,unresolved:[...l]}}function S(t,e){let n=Array.isArray(t)?t:[t];for(let o of n){e(o);let r=o.children;r&&S(r,e)}}function he(t){let e=[];S(t,i=>{i.kind==="component"&&i.source&&e.push(i)});let n=new Set,o=new Set;for(let i of e){let{module:a,loading:s}=i.source;s.kind==="eager"&&n.add(a),s.kind==="never"&&o.add(a)}let r=new Map;for(let i of e){let a=i.source;ee(a.loading)&&n.has(a.module)&&(a.loading={kind:"eager"},r.set(a.module,(r.get(a.module)??0)+1))}return{collapsed:r,conflicted:[...o].filter(i=>n.has(i))}}var it=t=>"components"in t;function ve(t,e){return t.replace(/\$(\d+)/g,(n,o)=>e[Number(o)]??n)}function st(t,e){return typeof e=="string"?{module:e,export:t}:e}function T(t=[]){let e=new Map,n=[],o=[];for(let a of t){if(!it(a)){o.push(a);continue}for(let[s,l]of Object.entries(a.components)){let c=st(s,l),d=e.get(s);if(d&&d.module!==c.module){let p=n.find(m=>m.name===s);p?p.modules.push(c.module):n.push({name:s,modules:[d.module,c.module]});continue}e.set(s,c)}}let r=new Map;return{resolve:a=>{if(r.has(a))return r.get(a);let s=e.get(a);if(!s)for(let l of o){let c=a.match(new RegExp(l.match.source,l.match.flags.replace("g","")));if(c){s={module:ve(l.module,c),export:l.export?ve(l.export,c):a};break}}return r.set(a,s),s},names:()=>[...e.keys()],conflicts:()=>n}}function at(t){let e=[],n=0;return t.statics.forEach((o,r)=>{if(e.push({kind:"static",text:o,start:n}),n+=o.length,r<t.holes.length){let i=n+t.holes[r].code.length;e.push({kind:"hole",index:r,start:n,end:i}),n=i}}),e}function lt(t,e={}){if(t.statics.length!==t.holes.length+1)throw new Error(`[fluixi] compileTemplate: ${t.statics.length} static runs for ${t.holes.length} holes — a template always has exactly one more.`);return Re(at(t),t.holes,e)}function Re(t,e,n={}){let o=new Set,r=L(t,[...e],o,{svg:n.svg});ge(r),V(r,{resolver:T(n.resolve??[]),modules:{controlFlowModule:n.controlFlowModule??"@fluixi/dom",coreModule:n.coreModule??"@fluixi/core",routerModule:n.routerModule??"@fluixi/core/router-next"},strategyFor:l=>l.load}),he(r);let{code:i,imports:a,templates:s}=v.emit(r,{templateClone:n.templateClone,partialTemplates:n.partialTemplates});for(let l of a)o.add(l);return n.hoistTemplates?{code:i,imports:[...o],ir:r,templates:s}:{code:D(i,s),imports:[...o],ir:r}}var x="@fluixi/reactive/signal",F={$signal:{export:"signal",module:x,returns:"signal-handle"},$memo:{export:"memo",module:x,returns:"memo-handle"},$effect:{export:"effect",module:x,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:x,returns:"resource-handle"},$selector:{export:"createSelector",module:x,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:x,returns:"memo-accessor"},$untrack:{export:"untrack",module:x,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}};var Xt=new RegExp(`\\$(?:${Object.keys(F).map(t=>t.slice(1)).join("|")})\\s*\\(`);var ct=new Set(["Text","Image","Option","Audio","Comment","Range","Selection","Notification","Event","Document","Element","Node","Screen","Window","Location","History","Storage","Response","Request","Headers"]);function pt(t){if(t.startsWith(".")||t.startsWith("/")||/^[~@]\//.test(t))return;let e=t.split("/");return t.startsWith("@")?e.slice(0,2).join("/"):e[0]}function q(t){return`_${t.replace(/[^A-Za-z0-9]/g,"_")}`}function K(t,e={}){let{available:n,builtins:o=!0,intrinsics:r=!0,generator:i="@fluixi/compiler",specifier:a=u=>u}=e,s=[...t];o&&s.push({components:N()});let l=T(s),c=n?new Set(n):void 0,d=[],p=[],m=[],h=new Map;for(let u of[...l.names()].sort()){let g=l.resolve(u);if(!g)continue;let I=pt(g.module);ct.has(u)?p.push(u):c&&I&&!c.has(I)?m.push(u):(d.push(u),h.set(u,g))}let b=r?[...new Set(Object.values(F).map(u=>u.module))]:[],Z=[...new Set([...d.map(u=>h.get(u).module),...b])].sort().map(u=>`import * as ${q(u)} from '${a(u)}';`),ye=d.map(u=>{let g=h.get(u),I=q(g.module);return g.export==="default"?` const ${u}: typeof ${I}.default;`:` export import ${u} = ${I}.${g.export};`}),Ne=p.length>0?`//
|
|
2
2
|
// Import these explicitly — lib.dom already declares the name, so an ambient
|
|
3
3
|
// declaration cannot win:
|
|
4
|
-
`+
|
|
5
|
-
`}).join(""):"",O=t.filter(
|
|
4
|
+
`+p.map(u=>{let g=l.resolve(u)?.module;return`// import { ${u} } from '${g?a(g):""}';
|
|
5
|
+
`}).join(""):"",Ie=r?Object.entries(F).map(([u,g])=>` const ${u}: typeof ${q(g.module)}.${g.export};`):[],O=t.filter(u=>"match"in u).length,Ee=O>0?`//
|
|
6
6
|
// ${O} pattern rule${O===1?"":"s"} cannot be declared:
|
|
7
7
|
// a pattern matches unboundedly many names, so there is no list to emit. Those
|
|
8
8
|
// tags still resolve at build time; declare them by hand if the editor needs them.
|
|
9
|
-
`:"";return{source:`// GENERATED by ${
|
|
9
|
+
`:"";return{source:`// GENERATED by ${i} — do not edit.
|
|
10
10
|
//
|
|
11
11
|
// The components \`resolve\` supplies without an import. This describes what the
|
|
12
12
|
// compiler already does; it does not enable it.
|
|
13
|
-
`+
|
|
14
|
-
${
|
|
13
|
+
`+Ne+Ee+(Z.length>0?`
|
|
14
|
+
${Z.join(`
|
|
15
15
|
`)}
|
|
16
16
|
`:`
|
|
17
17
|
`)+`
|
|
18
18
|
declare global {
|
|
19
|
-
${
|
|
19
|
+
${[...ye,...Ie].join(`
|
|
20
20
|
`)}
|
|
21
21
|
}
|
|
22
|
-
`,declared:
|
|
22
|
+
`,declared:d,shadowedByDom:p,unavailable:m,patternRules:O}}var R=require("node:fs"),f=require("node:path");var dt="GENERATED by @fluixi/compiler",be="fluixi.d.ts";function ut(t,e){let n;try{let r=(0,R.readFileSync)((0,f.resolve)(t,"tsconfig.json"),"utf8");n=JSON.parse(r.replace(/^\s*\/\/.*$/gm,""))}catch{return}if(n.extends!==void 0)return;if(!Array.isArray(n.include))return!0;let o=ke(t,e);return n.include.some(r=>{if(typeof r!="string")return!1;let i=r.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\//g,"(?:.*/)?").replace(/\*/g,"[^/]*");return new RegExp(`^${i}(?:/.*)?$`).test(o)})}function ke(t,e){return(0,f.relative)(t,e).split(f.sep).join("/")}function mt(t,e,n){if(!t.startsWith("/"))return t;let o=(0,f.resolve)(n,t.slice(1)),r=(0,f.relative)(e,o).split(f.sep).join("/");return r.startsWith(".")||(r=`./${r}`),r.replace(/\.(tsx|ts|jsx|mts|cts)$/,".js")}function ft(t){try{let e=JSON.parse((0,R.readFileSync)((0,f.resolve)(t,"package.json"),"utf8"));return[...Object.keys(e.dependencies??{}),...Object.keys(e.devDependencies??{}),...Object.keys(e.peerDependencies??{})]}catch{return}}function gt(t,e){if(t.globals===!1)return{status:"skipped",reason:"disabled"};let n=t.resolve??[],o=(0,f.resolve)(e,t.globals??be),r;try{r=(0,R.readFileSync)(o,"utf8")}catch{r=void 0}if(r!==void 0&&!r.includes(dt))return{status:"skipped",reason:"foreign-file",path:o};let{source:i,declared:a}=K(n,{available:ft(e),specifier:s=>mt(s,(0,f.dirname)(o),e)});return r===i?{status:"unchanged",path:o,declared:a.length,warning:xe(e,o)}:((0,R.mkdirSync)((0,f.dirname)(o),{recursive:!0}),(0,R.writeFileSync)(o,i),{status:"written",path:o,declared:a.length,warning:xe(e,o)})}function xe(t,e){if(ut(t,e)!==!1)return;let n=ke(t,e);return`[fluixi] ${n} is not covered by "include" in tsconfig.json, so TypeScript will ignore it and every resolved component stays "Cannot find name". Add "${n}" to "include".`}var ht={backend:"imperative",moduleName:"@fluixi/dom",delegateEvents:!0,hydratable:!1,sourceMaps:!0,dev:!1};var vt={imperative:v};
|
package/dist/index.mjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
var xe="children";function ke(t){switch(t.kind){case"call":return!0;case"member":return t.property!==xe;case"compound":return t.parts.some(ke);case"opaque":return!1}}import{parseTemplate as He}from"@fluixi/template-parser";var w={kind:"eager"},be=["pointerdown","focusin","keydown"],J=new Set(["eager","idle","visible","interaction","media","never"]),R=class extends Error{};function z(t,e){let n=t.slice(5);if(!J.has(n))throw new R(`Unknown load strategy 'load:${n}'. Expected one of ${[...J].join(", ")}.`);switch(n){case"eager":return w;case"idle":return{kind:"idle"};case"never":return{kind:"never"};case"visible":return e?{kind:"visible",rootMargin:e}:{kind:"visible"};case"interaction":return{kind:"interaction",events:e?ye(e):[...be]};case"media":if(!e)throw new R(`'load:media' needs a query, e.g. load:media="(min-width: 1024px)".`);return{kind:"media",query:e};default:throw new R(`Unhandled load strategy '${n}'.`)}}function ye(t){let e=t.split(/[\s,]+/).map(n=>n.trim()).filter(Boolean);if(e.length===0)throw new R("'load:interaction' was given no event names.");return e}function U(t){return t.kind!=="eager"&&t.kind!=="never"}var Ne=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),V={className:"class",htmlFor:"for"},Ce=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),Ee=new Set(["script","style","textarea","title"]);function j(t){return Ee.has(t)}function q(t){return V[t]??t}function k(t){return t.kind!=="attr"||t.expr!==void 0||t.name.includes(":")?!1:!Ce.has(t.name)}function D(t){if(!t.static||j(t.tag))return!1;for(let e of t.props)if(!k(e))return!1;for(let e of t.children)if(e.kind!=="text"&&!(e.kind==="element"&&D(e)))return!1;return!0}function b(t){let e=t.props.map(we).filter(Boolean).join(""),n=`<${t.tag}${e}>`;return Ne.has(t.tag)?n:`${n}${t.children.map(Ie).join("")}</${t.tag}>`}function Ie(t){if(t.kind==="text")return Te(t.value);if(t.kind!=="element")throw new Error(`serializeStatic: unexpected ${t.kind}`);return b(t)}function we(t){let e=V[t.name]??t.name,n=t.literal;return n===!0||n===void 0?` ${e}`:n===!1||n===null?"":` ${e}="${$e(String(n))}"`}function $e(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Te(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var Se="<!--fx-->",Oe="<!--fx/-->";function T(t){return t.kind==="expr"||t.kind==="component"||t.kind==="control"}function Me(t){return t.kind==="text"||t.kind==="element"&&K(t)}function K(t){return t.svg||j(t.tag)||!t.props.every(e=>k(e))?!1:t.children.every(e=>Me(e)||T(e))}function $(t){if(T(t))return!0;let e=t.children;return e?e.some($):!1}function Z(t){for(let e=0;e<t.children.length;e++){let n=t.children[e];if(n.kind==="text"&&(n.value===""||t.children[e+1]?.kind==="text"))return!1}return t.children.every(e=>e.kind!=="element"||Z(e))}function Y(t){if(!K(t)||!Z(t)||!t.children.some($))return null;let e=[],n=[],o=0,r=l=>{let s=`_n$${o++}`;return e.push({ref:s,expr:l}),s};return i(t,"_el$"),{html:Ae(t),tag:t.tag,steps:e,holes:n};function i(l,s){let a=-1;l.children.forEach((d,p)=>{$(d)&&(a=p)});let c=null;for(let d=0;d<=a;d++){let p=l.children[d],u=c?`${c}.nextSibling`:`${s}.firstChild`;if(T(p)){let h=r(u),E=r(`holeEnd(${h})`);n.push({parentRef:s,startRef:h,endRef:E,node:p}),c=E;continue}let g=r(u);p.kind==="element"&&$(p)&&i(p,g),c=g}}}function Ae(t){return b(X(t)).split(Q).join(Se+Oe)}function X(t){return{...t,children:t.children.map(e=>T(e)?{kind:"text",value:Q}:e.kind==="element"?X(e):e)}}var Q="\0fx-hole\0";var L={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},ct={version:2,module:"@fluixi/dom",symbols:[...L.symbols,"template","cloneTemplate","walk"]};var Pe={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function je(t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)}function te(t){return je(t)?t:JSON.stringify(t)}function De(t){return t.expr!==void 0?t.reactive?`() => (${t.expr})`:`(${t.expr})`:JSON.stringify(t.literal??!0)}function Le(t){return t.expr!==void 0?`(${t.expr})`:JSON.stringify(t.literal??!0)}function _e(t,e,n){let o=t.filter(s=>s.kind==="spread"),i=t.filter(s=>s.kind!=="spread").map(s=>`${te(s.name)}: ${De(s)}`);e!=null&&i.push(`children: ${e}`);let l=`{ ${i.join(", ")} }`;return o.length>0?(n.add("mergeProps"),`mergeProps(${o.map(s=>s.expr).join(", ")}, ${l})`):l}function ne(t,e,n){return t.length===1?y(t[0],e,n):`[${t.map(o=>y(o,e,n)).join(", ")}]`}function ee(t,e,n,o,r){o.add("createMemo"),o.add("createComponent");let i=e.filter(c=>c.kind==="spread"),s=e.filter(c=>c.kind!=="spread").map(c=>`get ${te(c.name)}() { return ${Le(c)}; }`);n.length>0&&s.push(`get children() { return ${ne(n,o,r)}; }`);let a=`{ ${s.join(", ")} }`;return i.length>0&&(o.add("mergeProps"),a=`mergeProps(${i.map(c=>c.expr).join(", ")}, ${a})`),`createMemo(() => createComponent(${t}, ${a}))`}function Be(t,e){let n=q(e.name),o=e.literal;return o===!0||o===void 0?`${t}.setAttribute(${JSON.stringify(n)}, "");`:o===!1||o===null?"":`${t}.setAttribute(${JSON.stringify(n)}, ${JSON.stringify(String(o))});`}var re=!1;function y(t,e,n){switch(t.kind){case"text":return JSON.stringify(t.value);case"expr":return t.reactive?`() => (${t.code})`:`(${t.code})`;case"fragment":return t.children.length===0?"null":ne(t.children,e,n);case"component":return ee(t.name,t.props,t.children,e,n);case"control":{let o=Pe[t.control]??t.control;return e.add(o),ee(o,t.props,t.children,e,n)}case"element":{if(n&&t.static&&!t.svg&&D(t)){e.add("templateNode");let s=`_tmpl$${n.length}`;return n.push({id:s,html:b(t),tag:t.tag,svg:!1}),`templateNode(${s}, ${JSON.stringify(t.tag)})`}if(n&&re){let s=Y(t);if(s){e.add("templateNode"),e.add("insert"),e.add("holeEnd"),e.add("holeContent"),e.add("holeScope");let a=`_tmpl$${n.length}`;n.push({id:a,html:s.html,tag:s.tag,svg:!1});let c=[`const _el$ = templateNode(${a}, ${JSON.stringify(s.tag)}, true);`];for(let d of s.steps)c.push(`const ${d.ref} = ${d.expr};`);for(let d of s.holes)c.push(`insert(${d.parentRef}, holeScope(${d.startRef}, () => (${y(d.node,e,n)})), ${d.endRef}, holeContent(${d.startRef}, ${d.endRef}));`);return c.push("return _el$;"),`(() => { ${c.join(" ")} })()`}}e.add("createNativeElement");let o=JSON.stringify(t.tag),r="_el$",i=[],l=t.svg?`${o}, true`:o;if(i.push(`const ${r} = createNativeElement(${l});`),t.props.length>0)if(!t.svg&&t.props.every(k))for(let s of t.props)i.push(Be(r,s));else{e.add("spread");let s=t.svg?", isSVG: true":"";i.push(`spread({ element: ${r}, props: ${_e(t.props,null,e)}${s} });`)}for(let s of t.children){e.add("insert");let a=y(s,e,n),c=s.kind==="expr"&&s.reactive||s.kind==="component"||s.kind==="control";i.push(c?`insert(${r}, ${a}, null);`:`insert(${r}, ${a});`)}return i.push(`return ${r};`),`(() => { ${i.join(" ")} })()`}}}function S(t,e){if(!e||e.length===0)return t;let n=new Map(e.map(o=>[o.id,JSON.stringify(o.html)]));return t.replace(/_tmpl\$\d+/g,o=>n.get(o)??o)}var v={name:"imperative",contract:L,emit(t,e){let n=new Set,o=e?.templateClone!==!1?[]:void 0;return re=e?.partialTemplates===!0,{code:y(t,n,o),imports:Array.from(n),templates:o}}};function O(t){let e=t.split(/\r\n|\n|\r/),n=0;for(let r=0;r<e.length;r++)/[^ \t]/.test(e[r])&&(n=r);let o="";for(let r=0;r<e.length;r++){let i=e[r].replace(/\t/g," ");r!==0&&(i=i.replace(/^ +/,"")),r!==e.length-1&&(i=i.replace(/ +$/,"")),i&&(r!==n&&(i+=" "),o+=i)}return o}var oe=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function Fe(t){return t.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function ie(t){return t.charAt(0).toUpperCase()+t.slice(1)}var _=class{constructor(e,n){this.holes=e;this.used=n}hole(e){return this.holes[e]??{code:"undefined",reactive:!1}}emit(e){let{code:n,imports:o,templates:r}=v.emit(e,{});for(let i of o)this.used.add(i);return S(n,r)}lowerRoot(e){let n=this.lowerChildren(e);return n.length===1?n[0]:{kind:"fragment",children:n}}lowerChildren(e){let n=[];for(let o=0;o<e.length;o++){let r=e[o];if(r.kind==="Element"||r.kind==="Component"){let l=r.attributes.find(s=>s.kind==="IfDirective");if(l&&l.kind==="IfDirective"){let s=o+1;s<e.length&&this.isBlankText(e[s])&&s++;let a=e[s],c=a&&(a.kind==="Element"||a.kind==="Component")&&a.attributes.some(d=>d.kind==="ElseDirective");n.push(this.lowerIf(r,l.hole,c?a:null)),c&&(o=s);continue}if(r.attributes.some(s=>s.kind==="EachDirective")){n.push(this.lowerEach(r));continue}}let i=this.lowerNode(r);i&&n.push(i)}return n}isBlankText(e){return e.kind==="Text"&&!e.raw&&O(e.value)===""}lowerNode(e){switch(e.kind){case"Text":{if(e.raw)return{kind:"text",value:e.value};let n=O(e.value);return n?{kind:"text",value:n}:null}case"Comment":return null;case"Expression":{let n=this.hole(e.hole);return{kind:"expr",code:n.code,reactive:n.reactive}}case"Fragment":return{kind:"fragment",children:this.lowerChildren(e.children)};case"Element":return this.lowerElement(e);case"Component":return this.lowerComponent(e);default:return null}}lowerElement(e){let n=e.attributes.find(o=>o.kind==="Attribute"&&o.name==="is");if(e.tag==="component"&&n&&n.value&&n.value.kind==="hole"){let o=e.attributes.filter(i=>i!==n),r=this.lowerComponent({...e,kind:"Component",tag:"Dynamic",tagHole:null,attributes:o});return r.props.unshift({name:"component",kind:"attr",expr:`() => (${this.hole(n.value.hole).code})`}),r}return{kind:"element",tag:e.tag,svg:e.namespace==="svg",props:this.lowerAttributes(e.attributes),children:this.lowerChildren(e.children),static:!1}}lowerComponent(e){let n=e.tagHole!=null?this.hole(e.tagHole).code:e.tag,o=this.lowerAttributes(e.attributes),{slots:r,rest:i}=this.partitionSlots(e.children);for(let[a,c]of r){let d=c.length===1?c[0]:{kind:"fragment",children:c},p={name:a,kind:"attr",expr:this.emit(d),jsxElement:!0},u=o.findIndex(g=>g.name===a);u>=0?o[u]=p:o.push(p)}let l=e.attributes.find(a=>a.kind==="LoadDirective"),s=l?z(`load:${l.strategy}`,l.modifier):void 0;return{kind:"component",name:n,props:o,children:this.lowerChildren(i),...s?{load:s}:{}}}partitionSlots(e){let n=new Map,o=[];for(let r of e){if(r.kind==="Element"||r.kind==="Component"){let i=r.attributes.find(l=>l.kind==="Attribute"&&l.name==="slot");if(i&&i.value&&i.value.kind==="static"){let l={...r,attributes:r.attributes.filter(c=>c!==i)},s=l.kind==="Element"?this.lowerElement(l):this.lowerComponent(l),a=n.get(i.value.value)??[];a.push(s),n.set(i.value.value,a);continue}}o.push(r)}return{slots:n,rest:o}}lowerIf(e,n,o){let r=this.hole(n),i=[{name:"when",kind:"attr",expr:r.code,reactive:r.reactive}];if(o){let s=this.stripAndLower(o,a=>a.kind==="ElseDirective");i.push({name:"fallback",kind:"attr",expr:this.emit(s),jsxElement:!0})}let l=this.stripAndLower(e,s=>s.kind==="IfDirective");return{kind:"component",name:"Show",props:i,children:[l]}}lowerEach(e){let n=e.attributes.find(a=>a.kind==="EachDirective");if(!n||n.kind!=="EachDirective")return this.lowerNode(e);let o=this.hole(n.hole),r=[{name:"each",kind:"attr",expr:o.code,reactive:o.reactive}];if(n.key){let a="static"in n.key?`(item) => item[${JSON.stringify(n.key.static)}]`:this.hole(n.key.hole).code;r.push({name:"by",kind:"attr",expr:a})}let i=this.itemArrow(e),l;if(i){let a={kind:"expr",code:i.body,reactive:i.bodyReactive},c=this.rebuildWithChildren(e,[a]);l=`(${i.params.join(", ")}) => (${this.emit(c)})`}else{let a=this.stripAndLower(e,c=>c.kind==="EachDirective");l=`() => (${this.emit(a)})`}return{kind:"component",name:"For",props:r,children:[{kind:"expr",code:l,reactive:!1}]}}itemArrow(e){let n=e.children.filter(o=>!this.isBlankText(o));return n.length!==1||n[0].kind!=="Expression"?null:this.hole(n[0].hole).arrow??null}stripAndLower(e,n){let o={...e,attributes:e.attributes.filter(r=>!n(r))};return o.kind==="Element"?this.lowerElement(o):this.lowerComponent(o)}rebuildWithChildren(e,n){let o=this.lowerAttributes(e.attributes.filter(r=>r.kind!=="EachDirective"));return e.kind==="Element"?{kind:"element",tag:e.tag,svg:e.namespace==="svg",props:o,children:n,static:!1}:{kind:"component",name:e.tag,props:o,children:n}}lowerAttributes(e){let n=[],o=[],r=!1,i=[],l=!1,s=[];for(let a of e)switch(a.kind){case"IfDirective":case"EachDirective":case"ElseDirective":break;case"Attribute":n.push(this.plainAttr(a));break;case"PropertyBinding":n.push({name:a.name,kind:"prop",expr:this.hole(a.hole).code,reactive:this.hole(a.hole).reactive});break;case"EventBinding":n.push(this.eventProp(a));break;case"RefBinding":n.push({name:"ref",kind:"ref",expr:this.hole(a.hole).code,reactive:this.hole(a.hole).reactive});break;case"Spread":n.push({name:"",kind:"spread",expr:this.hole(a.hole).code});break;case"ClassDirective":{let c=this.hole(a.hole);o.push(`${JSON.stringify(a.name)}: ${c.code}`),r=r||c.reactive;break}case"StyleDirective":{let c=this.hole(a.hole);i.push(`${JSON.stringify(a.name)}: ${c.code}`),l=l||c.reactive;break}case"BindDirective":n.push(...this.bindProps(a.name,this.hole(a.hole).code));break;case"UseDirective":{let c=a.name??(a.hole!=null?this.hole(a.hole).code:null);if(!c)break;s.push(a.name!=null&&a.hole!=null?`[${c}, () => (${this.hole(a.hole).code})]`:`[${c}]`);break}}return o.length>0&&n.push({name:"classList",kind:"attr",expr:`{ ${o.join(", ")} }`,reactive:r}),i.length>0&&n.push({name:"style",kind:"attr",expr:`{ ${i.join(", ")} }`,reactive:l}),s.length>0&&n.push({name:"use",kind:"attr",expr:`[${s.join(", ")}]`}),n}eventProp(e){let n=e.name.toLowerCase(),o=this.hole(e.hole).code;if(!(e.syntax==="colon"||e.modifiers.length>0))return{name:"on"+ie(e.name),kind:"event",event:{name:n,delegated:oe.has(n)},expr:o};let i=this.wrapHandler(o,e.modifiers),l=this.eventOptions(e.modifiers),s=l?`[${i}, ${l}]`:i;return{name:"on:"+n,kind:"attr",expr:s}}wrapHandler(e,n){let o=n.includes("self")?"if (e.target !== e.currentTarget) return; ":"",r=[];return n.includes("prevent")&&r.push("e.preventDefault();"),n.includes("stop")&&r.push("e.stopPropagation();"),!o&&r.length===0?e:`(e) => { ${o}${r.join(" ")} return (${e})(e); }`}eventOptions(e){let n=[];return e.includes("capture")&&n.push("capture: true"),e.includes("once")&&n.push("once: true"),e.includes("passive")&&n.push("passive: true"),n.length?`{ ${n.join(", ")} }`:null}bindProps(e,n){let o=e==="checked",r=o?"change":"input",i=o?"checked":"value",l=`(${n})`;return[{name:e,kind:"attr",expr:`${l}[0]()`,reactive:!0},{name:"on"+ie(r),kind:"event",event:{name:r,delegated:oe.has(r)},expr:`(e) => ${l}[1](e.target.${i})`}]}plainAttr(e){let n=e.value,o=e.name;e.name==="class"?o=n&&n.kind==="hole"&&this.hole(n.hole).object?"classList":"className":e.name==="html"&&(o="innerHTML");let i={name:o,kind:"attr"};if(n==null)return i.literal=!0,i;if(n.kind==="static")return i.literal=n.value,i;if(n.kind==="hole"){let a=this.hole(n.hole);return i.expr=a.code,i.reactive=a.reactive,i}let l=!1,s=n.parts.map(a=>{if("text"in a)return Fe(a.text);let c=this.hole(a.hole);return l=l||c.reactive,"${"+c.code+"}"}).join("");return i.expr="`"+s+"`",i.reactive=l,i}};function B(t,e,n,o={}){let{root:r}=He(t,{svg:o.svg});return new _(e,n).lowerRoot(r.children)}function Ge(t){switch(t.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 t.reactive?"reactive-prop":t.expr!==void 0?"expression-prop":void 0;default:return"expression-prop"}}function se(t){let e=[],n=new Map,o=r=>{switch(r.kind){case"text":return!0;case"expr":return!1;case"component":case"control":for(let i of r.children)o(i);return!1;case"fragment":for(let i of r.children)o(i);return!1;case"element":{let i=!0;for(let s of r.children)o(s)||(i=!1);let l;for(let s of r.props)if(l=Ge(s),l)break;return!l&&!i&&(l=We(r)),r.static=!l,l?n.set(r,l):e.push(r),r.static}default:return!1}};for(let r of Array.isArray(t)?t:[t])o(r);return{staticElements:e,reasons:n}}function We(t){for(let e of t.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"}var H=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],F=["Suspense","SuspenseList","Await"],N=["Router","Outlet","Redirect","Link"],yt=[...H,...F,...N],G=new Set([...H,...F]);function C(t={}){let{controlFlowModule:e="@fluixi/dom",coreModule:n="@fluixi/core",routerModule:o="@fluixi/core/router-next"}=t,r={};for(let i of H)r[i]=e;for(let i of F)r[i]=n;for(let i of N)r[i]=o;return r}function Nt(t={}){return{components:C(t)}}function Ct(t){let e=t??"@fluixi/core/router-next";return{components:Object.fromEntries(N.map(n=>[n,e]))}}function le(t,e={}){let{resolver:n,isBound:o,modules:r,strategyFor:i}=e,l=C(r),s=new Map,a=new Set,c=p=>{let{name:u}=p;if(!u||u.includes(".")||o?.(u))return;let g=d(u);if(!g){a.add(u);return}let h=g.origin==="builtin"&&G.has(u)?w:i?.(p)??w;p.source={...g,loading:h},s.set(u,p.source)},d=p=>{if(G.has(p))return{module:l[p],export:p,origin:"builtin"};let u=n?.resolve(p);if(u)return{module:u.module,export:u.export,origin:"rule"};if(N.includes(p))return{module:l[p],export:p,origin:"builtin"}};return M(t,p=>{p.kind==="component"&&c(p)}),{resolved:s,unresolved:[...a]}}function M(t,e){let n=Array.isArray(t)?t:[t];for(let o of n){e(o);let r=o.children;r&&M(r,e)}}function ae(t){let e=[];M(t,i=>{i.kind==="component"&&i.source&&e.push(i)});let n=new Set,o=new Set;for(let i of e){let{module:l,loading:s}=i.source;s.kind==="eager"&&n.add(l),s.kind==="never"&&o.add(l)}let r=new Map;for(let i of e){let l=i.source;U(l.loading)&&n.has(l.module)&&(l.loading={kind:"eager"},r.set(l.module,(r.get(l.module)??0)+1))}return{collapsed:r,conflicted:[...o].filter(i=>n.has(i))}}var Je=t=>"components"in t;function ce(t,e){return t.replace(/\$(\d+)/g,(n,o)=>e[Number(o)]??n)}function ze(t,e){return typeof e=="string"?{module:e,export:t}:e}function A(t=[]){let e=new Map,n=[],o=[];for(let l of t){if(!Je(l)){o.push(l);continue}for(let[s,a]of Object.entries(l.components)){let c=ze(s,a),d=e.get(s);if(d&&d.module!==c.module){let p=n.find(u=>u.name===s);p?p.modules.push(c.module):n.push({name:s,modules:[d.module,c.module]});continue}e.set(s,c)}}let r=new Map;return{resolve:l=>{if(r.has(l))return r.get(l);let s=e.get(l);if(!s)for(let a of o){let c=l.match(new RegExp(a.match.source,a.match.flags.replace("g","")));if(c){s={module:ce(a.module,c),export:a.export?ce(a.export,c):l};break}}return r.set(l,s),s},names:()=>[...e.keys()],conflicts:()=>n}}function Ue(t){let e=[],n=0;return t.statics.forEach((o,r)=>{if(e.push({kind:"static",text:o,start:n}),n+=o.length,r<t.holes.length){let i=n+t.holes[r].code.length;e.push({kind:"hole",index:r,start:n,end:i}),n=i}}),e}function Bt(t,e={}){if(t.statics.length!==t.holes.length+1)throw new Error(`[fluixi] compileTemplate: ${t.statics.length} static runs for ${t.holes.length} holes — a template always has exactly one more.`);return Ve(Ue(t),t.holes,e)}function Ve(t,e,n={}){let o=new Set,r=B(t,[...e],o,{svg:n.svg});se(r),le(r,{resolver:A(n.resolve??[]),modules:{controlFlowModule:n.controlFlowModule??"@fluixi/dom",coreModule:n.coreModule??"@fluixi/core",routerModule:n.routerModule??"@fluixi/core/router-next"},strategyFor:a=>a.load}),ae(r);let{code:i,imports:l,templates:s}=v.emit(r,{templateClone:n.templateClone,partialTemplates:n.partialTemplates});for(let a of l)o.add(a);return n.hoistTemplates?{code:i,imports:[...o],ir:r,templates:s}:{code:S(i,s),imports:[...o],ir:r}}var qe=new Set(["Text","Image","Option","Audio","Comment","Range","Selection","Notification","Event","Document","Element","Node","Screen","Window","Location","History","Storage","Response","Request","Headers"]);function Ke(t){if(t.startsWith(".")||t.startsWith("/")||/^[~@]\//.test(t))return;let e=t.split("/");return t.startsWith("@")?e.slice(0,2).join("/"):e[0]}function pe(t){return`_${t.replace(/[^A-Za-z0-9]/g,"_")}`}function de(t,e={}){let{available:n,builtins:o=!0,generator:r="@fluixi/compiler",specifier:i=m=>m}=e,l=[...t];o&&l.push({components:C()});let s=A(l),a=n?new Set(n):void 0,c=[],d=[],p=[],u=new Map;for(let m of[...s.names()].sort()){let f=s.resolve(m);if(!f)continue;let x=Ke(f.module);qe.has(m)?d.push(m):a&&x&&!a.has(x)?p.push(m):(c.push(m),u.set(m,f))}let h=[...new Set(c.map(m=>u.get(m).module))].sort().map(m=>`import * as ${pe(m)} from '${i(m)}';`),E=c.map(m=>{let f=u.get(m),x=pe(f.module);return f.export==="default"?` const ${m}: typeof ${x}.default;`:` export import ${m} = ${x}.${f.export};`}),ve=d.length>0?`//
|
|
1
|
+
var Ie="children";function Ee(t){switch(t.kind){case"call":return!0;case"member":return t.property!==Ie;case"compound":return t.parts.some(Ee);case"opaque":return!1}}import{parseTemplate as Je}from"@fluixi/template-parser";var $={kind:"eager"},Ce=["pointerdown","focusin","keydown"],q=new Set(["eager","idle","visible","interaction","media","never"]),x=class extends Error{};function K(t,e){let n=t.slice(5);if(!q.has(n))throw new x(`Unknown load strategy 'load:${n}'. Expected one of ${[...q].join(", ")}.`);switch(n){case"eager":return $;case"idle":return{kind:"idle"};case"never":return{kind:"never"};case"visible":return e?{kind:"visible",rootMargin:e}:{kind:"visible"};case"interaction":return{kind:"interaction",events:e?$e(e):[...Ce]};case"media":if(!e)throw new x(`'load:media' needs a query, e.g. load:media="(min-width: 1024px)".`);return{kind:"media",query:e};default:throw new x(`Unhandled load strategy '${n}'.`)}}function $e(t){let e=t.split(/[\s,]+/).map(n=>n.trim()).filter(Boolean);if(e.length===0)throw new x("'load:interaction' was given no event names.");return e}function Z(t){return t.kind!=="eager"&&t.kind!=="never"}var we=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Y={className:"class",htmlFor:"for"},Se=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),Te=new Set(["script","style","textarea","title"]);function L(t){return Te.has(t)}function X(t){return Y[t]??t}function k(t){return t.kind!=="attr"||t.expr!==void 0||t.name.includes(":")?!1:!Se.has(t.name)}function _(t){if(!t.static||L(t.tag))return!1;for(let e of t.props)if(!k(e))return!1;for(let e of t.children)if(e.kind!=="text"&&!(e.kind==="element"&&_(e)))return!1;return!0}function y(t){let e=t.props.map(Me).filter(Boolean).join(""),n=`<${t.tag}${e}>`;return we.has(t.tag)?n:`${n}${t.children.map(Oe).join("")}</${t.tag}>`}function Oe(t){if(t.kind==="text")return Ae(t.value);if(t.kind!=="element")throw new Error(`serializeStatic: unexpected ${t.kind}`);return y(t)}function Me(t){let e=Y[t.name]??t.name,n=t.literal;return n===!0||n===void 0?` ${e}`:n===!1||n===null?"":` ${e}="${Pe(String(n))}"`}function Pe(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Ae(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var je="<!--fx-->",De="<!--fx/-->";function S(t){return t.kind==="expr"||t.kind==="component"||t.kind==="control"}function Le(t){return t.kind==="text"||t.kind==="element"&&Q(t)}function Q(t){return t.svg||L(t.tag)||!t.props.every(e=>k(e))?!1:t.children.every(e=>Le(e)||S(e))}function w(t){if(S(t))return!0;let e=t.children;return e?e.some(w):!1}function ee(t){for(let e=0;e<t.children.length;e++){let n=t.children[e];if(n.kind==="text"&&(n.value===""||t.children[e+1]?.kind==="text"))return!1}return t.children.every(e=>e.kind!=="element"||ee(e))}function te(t){if(!Q(t)||!ee(t)||!t.children.some(w))return null;let e=[],n=[],o=0,r=a=>{let s=`_n$${o++}`;return e.push({ref:s,expr:a}),s};return i(t,"_el$"),{html:_e(t),tag:t.tag,steps:e,holes:n};function i(a,s){let l=-1;a.children.forEach((d,p)=>{w(d)&&(l=p)});let c=null;for(let d=0;d<=l;d++){let p=a.children[d],m=c?`${c}.nextSibling`:`${s}.firstChild`;if(S(p)){let R=r(m),D=r(`holeEnd(${R})`);n.push({parentRef:s,startRef:R,endRef:D,node:p}),c=D;continue}let g=r(m);p.kind==="element"&&w(p)&&i(p,g),c=g}}}function _e(t){return y(ne(t)).split(re).join(je+De)}function ne(t){return{...t,children:t.children.map(e=>S(e)?{kind:"text",value:re}:e.kind==="element"?ne(e):e)}}var re="\0fx-hole\0";var B={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},ft={version:2,module:"@fluixi/dom",symbols:[...B.symbols,"template","cloneTemplate","walk"]};var Be={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function He(t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)}function ie(t){return He(t)?t:JSON.stringify(t)}function Fe(t){return t.expr!==void 0?t.reactive?`() => (${t.expr})`:`(${t.expr})`:JSON.stringify(t.literal??!0)}function Ge(t){return t.expr!==void 0?`(${t.expr})`:JSON.stringify(t.literal??!0)}function We(t,e,n){let o=t.filter(s=>s.kind==="spread"),i=t.filter(s=>s.kind!=="spread").map(s=>`${ie(s.name)}: ${Fe(s)}`);e!=null&&i.push(`children: ${e}`);let a=`{ ${i.join(", ")} }`;return o.length>0?(n.add("mergeProps"),`mergeProps(${o.map(s=>s.expr).join(", ")}, ${a})`):a}function se(t,e,n){return t.length===1?N(t[0],e,n):`[${t.map(o=>N(o,e,n)).join(", ")}]`}function oe(t,e,n,o,r){o.add("createMemo"),o.add("createComponent");let i=e.filter(c=>c.kind==="spread"),s=e.filter(c=>c.kind!=="spread").map(c=>`get ${ie(c.name)}() { return ${Ge(c)}; }`);n.length>0&&s.push(`get children() { return ${se(n,o,r)}; }`);let l=`{ ${s.join(", ")} }`;return i.length>0&&(o.add("mergeProps"),l=`mergeProps(${i.map(c=>c.expr).join(", ")}, ${l})`),`createMemo(() => createComponent(${t}, ${l}))`}function Ue(t,e){let n=X(e.name),o=e.literal;return o===!0||o===void 0?`${t}.setAttribute(${JSON.stringify(n)}, "");`:o===!1||o===null?"":`${t}.setAttribute(${JSON.stringify(n)}, ${JSON.stringify(String(o))});`}var ae=!1;function N(t,e,n){switch(t.kind){case"text":return JSON.stringify(t.value);case"expr":return t.reactive?`() => (${t.code})`:`(${t.code})`;case"fragment":return t.children.length===0?"null":se(t.children,e,n);case"component":return oe(t.name,t.props,t.children,e,n);case"control":{let o=Be[t.control]??t.control;return e.add(o),oe(o,t.props,t.children,e,n)}case"element":{if(n&&t.static&&!t.svg&&_(t)){e.add("templateNode");let s=`_tmpl$${n.length}`;return n.push({id:s,html:y(t),tag:t.tag,svg:!1}),`templateNode(${s}, ${JSON.stringify(t.tag)})`}if(n&&ae){let s=te(t);if(s){e.add("templateNode"),e.add("insert"),e.add("holeEnd"),e.add("holeContent"),e.add("holeScope");let l=`_tmpl$${n.length}`;n.push({id:l,html:s.html,tag:s.tag,svg:!1});let c=[`const _el$ = templateNode(${l}, ${JSON.stringify(s.tag)}, true);`];for(let d of s.steps)c.push(`const ${d.ref} = ${d.expr};`);for(let d of s.holes)c.push(`insert(${d.parentRef}, holeScope(${d.startRef}, () => (${N(d.node,e,n)})), ${d.endRef}, holeContent(${d.startRef}, ${d.endRef}));`);return c.push("return _el$;"),`(() => { ${c.join(" ")} })()`}}e.add("createNativeElement");let o=JSON.stringify(t.tag),r="_el$",i=[],a=t.svg?`${o}, true`:o;if(i.push(`const ${r} = createNativeElement(${a});`),t.props.length>0)if(!t.svg&&t.props.every(k))for(let s of t.props)i.push(Ue(r,s));else{e.add("spread");let s=t.svg?", isSVG: true":"";i.push(`spread({ element: ${r}, props: ${We(t.props,null,e)}${s} });`)}for(let s of t.children){e.add("insert");let l=N(s,e,n),c=s.kind==="expr"&&s.reactive||s.kind==="component"||s.kind==="control";i.push(c?`insert(${r}, ${l}, null);`:`insert(${r}, ${l});`)}return i.push(`return ${r};`),`(() => { ${i.join(" ")} })()`}}}function T(t,e){if(!e||e.length===0)return t;let n=new Map(e.map(o=>[o.id,JSON.stringify(o.html)]));return t.replace(/_tmpl\$\d+/g,o=>n.get(o)??o)}var h={name:"imperative",contract:B,emit(t,e){let n=new Set,o=e?.templateClone!==!1?[]:void 0;return ae=e?.partialTemplates===!0,{code:N(t,n,o),imports:Array.from(n),templates:o}}};function O(t){let e=t.split(/\r\n|\n|\r/),n=0;for(let r=0;r<e.length;r++)/[^ \t]/.test(e[r])&&(n=r);let o="";for(let r=0;r<e.length;r++){let i=e[r].replace(/\t/g," ");r!==0&&(i=i.replace(/^ +/,"")),r!==e.length-1&&(i=i.replace(/ +$/,"")),i&&(r!==n&&(i+=" "),o+=i)}return o}var le=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function ze(t){return t.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function ce(t){return t.charAt(0).toUpperCase()+t.slice(1)}var H=class{constructor(e,n){this.holes=e;this.used=n}hole(e){return this.holes[e]??{code:"undefined",reactive:!1}}emit(e){let{code:n,imports:o,templates:r}=h.emit(e,{});for(let i of o)this.used.add(i);return T(n,r)}lowerRoot(e){let n=this.lowerChildren(e);return n.length===1?n[0]:{kind:"fragment",children:n}}lowerChildren(e){let n=[];for(let o=0;o<e.length;o++){let r=e[o];if(r.kind==="Element"||r.kind==="Component"){let a=r.attributes.find(s=>s.kind==="IfDirective");if(a&&a.kind==="IfDirective"){let s=o+1;s<e.length&&this.isBlankText(e[s])&&s++;let l=e[s],c=l&&(l.kind==="Element"||l.kind==="Component")&&l.attributes.some(d=>d.kind==="ElseDirective");n.push(this.lowerIf(r,a.hole,c?l:null)),c&&(o=s);continue}if(r.attributes.some(s=>s.kind==="EachDirective")){n.push(this.lowerEach(r));continue}}let i=this.lowerNode(r);i&&n.push(i)}return n}isBlankText(e){return e.kind==="Text"&&!e.raw&&O(e.value)===""}lowerNode(e){switch(e.kind){case"Text":{if(e.raw)return{kind:"text",value:e.value};let n=O(e.value);return n?{kind:"text",value:n}:null}case"Comment":return null;case"Expression":{let n=this.hole(e.hole);return{kind:"expr",code:n.code,reactive:n.reactive}}case"Fragment":return{kind:"fragment",children:this.lowerChildren(e.children)};case"Element":return this.lowerElement(e);case"Component":return this.lowerComponent(e);default:return null}}lowerElement(e){let n=e.attributes.find(o=>o.kind==="Attribute"&&o.name==="is");if(e.tag==="component"&&n&&n.value&&n.value.kind==="hole"){let o=e.attributes.filter(i=>i!==n),r=this.lowerComponent({...e,kind:"Component",tag:"Dynamic",tagHole:null,attributes:o});return r.props.unshift({name:"component",kind:"attr",expr:`() => (${this.hole(n.value.hole).code})`}),r}return{kind:"element",tag:e.tag,svg:e.namespace==="svg",props:this.lowerAttributes(e.attributes),children:this.lowerChildren(e.children),static:!1}}lowerComponent(e){let n=e.tagHole!=null?this.hole(e.tagHole).code:e.tag,o=this.lowerAttributes(e.attributes),{slots:r,rest:i}=this.partitionSlots(e.children);for(let[l,c]of r){let d=c.length===1?c[0]:{kind:"fragment",children:c},p={name:l,kind:"attr",expr:this.emit(d),jsxElement:!0},m=o.findIndex(g=>g.name===l);m>=0?o[m]=p:o.push(p)}let a=e.attributes.find(l=>l.kind==="LoadDirective"),s=a?K(`load:${a.strategy}`,a.modifier):void 0;return{kind:"component",name:n,props:o,children:this.lowerChildren(i),...s?{load:s}:{}}}partitionSlots(e){let n=new Map,o=[];for(let r of e){if(r.kind==="Element"||r.kind==="Component"){let i=r.attributes.find(a=>a.kind==="Attribute"&&a.name==="slot");if(i&&i.value&&i.value.kind==="static"){let a={...r,attributes:r.attributes.filter(c=>c!==i)},s=a.kind==="Element"?this.lowerElement(a):this.lowerComponent(a),l=n.get(i.value.value)??[];l.push(s),n.set(i.value.value,l);continue}}o.push(r)}return{slots:n,rest:o}}lowerIf(e,n,o){let r=this.hole(n),i=[{name:"when",kind:"attr",expr:r.code,reactive:r.reactive}];if(o){let s=this.stripAndLower(o,l=>l.kind==="ElseDirective");i.push({name:"fallback",kind:"attr",expr:this.emit(s),jsxElement:!0})}let a=this.stripAndLower(e,s=>s.kind==="IfDirective");return{kind:"component",name:"Show",props:i,children:[a]}}lowerEach(e){let n=e.attributes.find(l=>l.kind==="EachDirective");if(!n||n.kind!=="EachDirective")return this.lowerNode(e);let o=this.hole(n.hole),r=[{name:"each",kind:"attr",expr:o.code,reactive:o.reactive}];if(n.key){let l="static"in n.key?`(item) => item[${JSON.stringify(n.key.static)}]`:this.hole(n.key.hole).code;r.push({name:"by",kind:"attr",expr:l})}let i=this.itemArrow(e),a;if(i){let l={kind:"expr",code:i.body,reactive:i.bodyReactive},c=this.rebuildWithChildren(e,[l]);a=`(${i.params.join(", ")}) => (${this.emit(c)})`}else{let l=this.stripAndLower(e,c=>c.kind==="EachDirective");a=`() => (${this.emit(l)})`}return{kind:"component",name:"For",props:r,children:[{kind:"expr",code:a,reactive:!1}]}}itemArrow(e){let n=e.children.filter(o=>!this.isBlankText(o));return n.length!==1||n[0].kind!=="Expression"?null:this.hole(n[0].hole).arrow??null}stripAndLower(e,n){let o={...e,attributes:e.attributes.filter(r=>!n(r))};return o.kind==="Element"?this.lowerElement(o):this.lowerComponent(o)}rebuildWithChildren(e,n){let o=this.lowerAttributes(e.attributes.filter(r=>r.kind!=="EachDirective"));return e.kind==="Element"?{kind:"element",tag:e.tag,svg:e.namespace==="svg",props:o,children:n,static:!1}:{kind:"component",name:e.tag,props:o,children:n}}lowerAttributes(e){let n=[],o=[],r=!1,i=[],a=!1,s=[];for(let l of e)switch(l.kind){case"IfDirective":case"EachDirective":case"ElseDirective":break;case"Attribute":n.push(this.plainAttr(l));break;case"PropertyBinding":n.push({name:l.name,kind:"prop",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"EventBinding":n.push(this.eventProp(l));break;case"RefBinding":n.push({name:"ref",kind:"ref",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"Spread":n.push({name:"",kind:"spread",expr:this.hole(l.hole).code});break;case"ClassDirective":{let c=this.hole(l.hole);o.push(`${JSON.stringify(l.name)}: ${c.code}`),r=r||c.reactive;break}case"StyleDirective":{let c=this.hole(l.hole);i.push(`${JSON.stringify(l.name)}: ${c.code}`),a=a||c.reactive;break}case"BindDirective":n.push(...this.bindProps(l.name,this.hole(l.hole).code));break;case"UseDirective":{let c=l.name??(l.hole!=null?this.hole(l.hole).code:null);if(!c)break;s.push(l.name!=null&&l.hole!=null?`[${c}, () => (${this.hole(l.hole).code})]`:`[${c}]`);break}}return o.length>0&&n.push({name:"classList",kind:"attr",expr:`{ ${o.join(", ")} }`,reactive:r}),i.length>0&&n.push({name:"style",kind:"attr",expr:`{ ${i.join(", ")} }`,reactive:a}),s.length>0&&n.push({name:"use",kind:"attr",expr:`[${s.join(", ")}]`}),n}eventProp(e){let n=e.name.toLowerCase(),o=this.hole(e.hole).code;if(!(e.syntax==="colon"||e.modifiers.length>0))return{name:"on"+ce(e.name),kind:"event",event:{name:n,delegated:le.has(n)},expr:o};let i=this.wrapHandler(o,e.modifiers),a=this.eventOptions(e.modifiers),s=a?`[${i}, ${a}]`:i;return{name:"on:"+n,kind:"attr",expr:s}}wrapHandler(e,n){let o=n.includes("self")?"if (e.target !== e.currentTarget) return; ":"",r=[];return n.includes("prevent")&&r.push("e.preventDefault();"),n.includes("stop")&&r.push("e.stopPropagation();"),!o&&r.length===0?e:`(e) => { ${o}${r.join(" ")} return (${e})(e); }`}eventOptions(e){let n=[];return e.includes("capture")&&n.push("capture: true"),e.includes("once")&&n.push("once: true"),e.includes("passive")&&n.push("passive: true"),n.length?`{ ${n.join(", ")} }`:null}bindProps(e,n){let o=e==="checked",r=o?"change":"input",i=o?"checked":"value";this.used.add("bindPair");let a=`bindPair(${n})`;return[{name:e,kind:"attr",expr:`${a}[0]()`,reactive:!0},{name:"on"+ce(r),kind:"event",event:{name:r,delegated:le.has(r)},expr:`(e) => ${a}[1](e.target.${i})`}]}plainAttr(e){let n=e.value,o=e.name;e.name==="class"?o=n&&n.kind==="hole"&&this.hole(n.hole).object?"classList":"className":e.name==="html"&&(o="innerHTML");let i={name:o,kind:"attr"};if(n==null)return i.literal=!0,i;if(n.kind==="static")return i.literal=n.value,i;if(n.kind==="hole"){let l=this.hole(n.hole);return i.expr=l.code,i.reactive=l.reactive,i}let a=!1,s=n.parts.map(l=>{if("text"in l)return ze(l.text);let c=this.hole(l.hole);return a=a||c.reactive,"${"+c.code+"}"}).join("");return i.expr="`"+s+"`",i.reactive=a,i}};function F(t,e,n,o={}){let{root:r}=Je(t,{svg:o.svg});return new H(e,n).lowerRoot(r.children)}function Ve(t){switch(t.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 t.reactive?"reactive-prop":t.expr!==void 0?"expression-prop":void 0;default:return"expression-prop"}}function pe(t){let e=[],n=new Map,o=r=>{switch(r.kind){case"text":return!0;case"expr":return!1;case"component":case"control":for(let i of r.children)o(i);return!1;case"fragment":for(let i of r.children)o(i);return!1;case"element":{let i=!0;for(let s of r.children)o(s)||(i=!1);let a;for(let s of r.props)if(a=Ve(s),a)break;return!a&&!i&&(a=qe(r)),r.static=!a,a?n.set(r,a):e.push(r),r.static}default:return!1}};for(let r of Array.isArray(t)?t:[t])o(r);return{staticElements:e,reasons:n}}function qe(t){for(let e of t.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"}var G=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],W=["Suspense","SuspenseList","Await"],I=["Router","Outlet","Redirect","Link"],$t=[...G,...W,...I],U=new Set([...G,...W]);function E(t={}){let{controlFlowModule:e="@fluixi/dom",coreModule:n="@fluixi/core",routerModule:o="@fluixi/core/router-next"}=t,r={};for(let i of G)r[i]=e;for(let i of W)r[i]=n;for(let i of I)r[i]=o;return r}function wt(t={}){return{components:E(t)}}function St(t){let e=t??"@fluixi/core/router-next";return{components:Object.fromEntries(I.map(n=>[n,e]))}}function de(t,e={}){let{resolver:n,isBound:o,modules:r,strategyFor:i}=e,a=E(r),s=new Map,l=new Set,c=p=>{let{name:m}=p;if(!m||m.includes(".")||o?.(m))return;let g=d(m);if(!g){l.add(m);return}let R=g.origin==="builtin"&&U.has(m)?$:i?.(p)??$;p.source={...g,loading:R},s.set(m,p.source)},d=p=>{if(U.has(p))return{module:a[p],export:p,origin:"builtin"};let m=n?.resolve(p);if(m)return{module:m.module,export:m.export,origin:"rule"};if(I.includes(p))return{module:a[p],export:p,origin:"builtin"}};return M(t,p=>{p.kind==="component"&&c(p)}),{resolved:s,unresolved:[...l]}}function M(t,e){let n=Array.isArray(t)?t:[t];for(let o of n){e(o);let r=o.children;r&&M(r,e)}}function ue(t){let e=[];M(t,i=>{i.kind==="component"&&i.source&&e.push(i)});let n=new Set,o=new Set;for(let i of e){let{module:a,loading:s}=i.source;s.kind==="eager"&&n.add(a),s.kind==="never"&&o.add(a)}let r=new Map;for(let i of e){let a=i.source;Z(a.loading)&&n.has(a.module)&&(a.loading={kind:"eager"},r.set(a.module,(r.get(a.module)??0)+1))}return{collapsed:r,conflicted:[...o].filter(i=>n.has(i))}}var Ke=t=>"components"in t;function me(t,e){return t.replace(/\$(\d+)/g,(n,o)=>e[Number(o)]??n)}function Ze(t,e){return typeof e=="string"?{module:e,export:t}:e}function P(t=[]){let e=new Map,n=[],o=[];for(let a of t){if(!Ke(a)){o.push(a);continue}for(let[s,l]of Object.entries(a.components)){let c=Ze(s,l),d=e.get(s);if(d&&d.module!==c.module){let p=n.find(m=>m.name===s);p?p.modules.push(c.module):n.push({name:s,modules:[d.module,c.module]});continue}e.set(s,c)}}let r=new Map;return{resolve:a=>{if(r.has(a))return r.get(a);let s=e.get(a);if(!s)for(let l of o){let c=a.match(new RegExp(l.match.source,l.match.flags.replace("g","")));if(c){s={module:me(l.module,c),export:l.export?me(l.export,c):a};break}}return r.set(a,s),s},names:()=>[...e.keys()],conflicts:()=>n}}function Ye(t){let e=[],n=0;return t.statics.forEach((o,r)=>{if(e.push({kind:"static",text:o,start:n}),n+=o.length,r<t.holes.length){let i=n+t.holes[r].code.length;e.push({kind:"hole",index:r,start:n,end:i}),n=i}}),e}function Ut(t,e={}){if(t.statics.length!==t.holes.length+1)throw new Error(`[fluixi] compileTemplate: ${t.statics.length} static runs for ${t.holes.length} holes — a template always has exactly one more.`);return Xe(Ye(t),t.holes,e)}function Xe(t,e,n={}){let o=new Set,r=F(t,[...e],o,{svg:n.svg});pe(r),de(r,{resolver:P(n.resolve??[]),modules:{controlFlowModule:n.controlFlowModule??"@fluixi/dom",coreModule:n.coreModule??"@fluixi/core",routerModule:n.routerModule??"@fluixi/core/router-next"},strategyFor:l=>l.load}),ue(r);let{code:i,imports:a,templates:s}=h.emit(r,{templateClone:n.templateClone,partialTemplates:n.partialTemplates});for(let l of a)o.add(l);return n.hoistTemplates?{code:i,imports:[...o],ir:r,templates:s}:{code:T(i,s),imports:[...o],ir:r}}var v="@fluixi/reactive/signal",A={$signal:{export:"signal",module:v,returns:"signal-handle"},$memo:{export:"memo",module:v,returns:"memo-handle"},$effect:{export:"effect",module:v,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:v,returns:"resource-handle"},$selector:{export:"createSelector",module:v,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:v,returns:"memo-accessor"},$untrack:{export:"untrack",module:v,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}};var zt=new RegExp(`\\$(?:${Object.keys(A).map(t=>t.slice(1)).join("|")})\\s*\\(`);var Qe=new Set(["Text","Image","Option","Audio","Comment","Range","Selection","Notification","Event","Document","Element","Node","Screen","Window","Location","History","Storage","Response","Request","Headers"]);function et(t){if(t.startsWith(".")||t.startsWith("/")||/^[~@]\//.test(t))return;let e=t.split("/");return t.startsWith("@")?e.slice(0,2).join("/"):e[0]}function J(t){return`_${t.replace(/[^A-Za-z0-9]/g,"_")}`}function fe(t,e={}){let{available:n,builtins:o=!0,intrinsics:r=!0,generator:i="@fluixi/compiler",specifier:a=u=>u}=e,s=[...t];o&&s.push({components:E()});let l=P(s),c=n?new Set(n):void 0,d=[],p=[],m=[],g=new Map;for(let u of[...l.names()].sort()){let f=l.resolve(u);if(!f)continue;let b=et(f.module);Qe.has(u)?p.push(u):c&&b&&!c.has(b)?m.push(u):(d.push(u),g.set(u,f))}let R=r?[...new Set(Object.values(A).map(u=>u.module))]:[],V=[...new Set([...d.map(u=>g.get(u).module),...R])].sort().map(u=>`import * as ${J(u)} from '${a(u)}';`),be=d.map(u=>{let f=g.get(u),b=J(f.module);return f.export==="default"?` const ${u}: typeof ${b}.default;`:` export import ${u} = ${b}.${f.export};`}),ke=p.length>0?`//
|
|
2
2
|
// Import these explicitly — lib.dom already declares the name, so an ambient
|
|
3
3
|
// declaration cannot win:
|
|
4
|
-
`+
|
|
5
|
-
`}).join(""):"",
|
|
6
|
-
// ${
|
|
4
|
+
`+p.map(u=>{let f=l.resolve(u)?.module;return`// import { ${u} } from '${f?a(f):""}';
|
|
5
|
+
`}).join(""):"",ye=r?Object.entries(A).map(([u,f])=>` const ${u}: typeof ${J(f.module)}.${f.export};`):[],C=t.filter(u=>"match"in u).length,Ne=C>0?`//
|
|
6
|
+
// ${C} pattern rule${C===1?"":"s"} cannot be declared:
|
|
7
7
|
// a pattern matches unboundedly many names, so there is no list to emit. Those
|
|
8
8
|
// tags still resolve at build time; declare them by hand if the editor needs them.
|
|
9
|
-
`:"";return{source:`// GENERATED by ${
|
|
9
|
+
`:"";return{source:`// GENERATED by ${i} — do not edit.
|
|
10
10
|
//
|
|
11
11
|
// The components \`resolve\` supplies without an import. This describes what the
|
|
12
12
|
// compiler already does; it does not enable it.
|
|
13
|
-
`+
|
|
14
|
-
${
|
|
13
|
+
`+ke+Ne+(V.length>0?`
|
|
14
|
+
${V.join(`
|
|
15
15
|
`)}
|
|
16
16
|
`:`
|
|
17
17
|
`)+`
|
|
18
18
|
declare global {
|
|
19
|
-
${
|
|
19
|
+
${[...be,...ye].join(`
|
|
20
20
|
`)}
|
|
21
21
|
}
|
|
22
|
-
`,declared:
|
|
22
|
+
`,declared:d,shadowedByDom:p,unavailable:m,patternRules:C}}import{mkdirSync as tt,readFileSync as z,writeFileSync as nt}from"node:fs";import{dirname as ge,relative as ve,sep as Re,resolve as j}from"node:path";var rt="GENERATED by @fluixi/compiler",ot="fluixi.d.ts";function it(t,e){let n;try{let r=z(j(t,"tsconfig.json"),"utf8");n=JSON.parse(r.replace(/^\s*\/\/.*$/gm,""))}catch{return}if(n.extends!==void 0)return;if(!Array.isArray(n.include))return!0;let o=xe(t,e);return n.include.some(r=>{if(typeof r!="string")return!1;let i=r.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\//g,"(?:.*/)?").replace(/\*/g,"[^/]*");return new RegExp(`^${i}(?:/.*)?$`).test(o)})}function xe(t,e){return ve(t,e).split(Re).join("/")}function st(t,e,n){if(!t.startsWith("/"))return t;let o=j(n,t.slice(1)),r=ve(e,o).split(Re).join("/");return r.startsWith(".")||(r=`./${r}`),r.replace(/\.(tsx|ts|jsx|mts|cts)$/,".js")}function at(t){try{let e=JSON.parse(z(j(t,"package.json"),"utf8"));return[...Object.keys(e.dependencies??{}),...Object.keys(e.devDependencies??{}),...Object.keys(e.peerDependencies??{})]}catch{return}}function tn(t,e){if(t.globals===!1)return{status:"skipped",reason:"disabled"};let n=t.resolve??[],o=j(e,t.globals??ot),r;try{r=z(o,"utf8")}catch{r=void 0}if(r!==void 0&&!r.includes(rt))return{status:"skipped",reason:"foreign-file",path:o};let{source:i,declared:a}=fe(n,{available:at(e),specifier:s=>st(s,ge(o),e)});return r===i?{status:"unchanged",path:o,declared:a.length,warning:he(e,o)}:(tt(ge(o),{recursive:!0}),nt(o,i),{status:"written",path:o,declared:a.length,warning:he(e,o)})}function he(t,e){if(it(t,e)!==!1)return;let n=xe(t,e);return`[fluixi] ${n} is not covered by "include" in tsconfig.json, so TypeScript will ignore it and every resolved component stays "Cannot find name". Add "${n}" to "include".`}var rn={backend:"imperative",moduleName:"@fluixi/dom",delegateEvents:!0,hydratable:!1,sourceMaps:!0,dev:!1};var an={imperative:h};export{$t as BUILTIN_COMPONENTS,W as CORE_CONTROL_FLOW,ot as DEFAULT_GLOBALS_PATH,G as DOM_CONTROL_FLOW,U as RESERVED_COMPONENTS,I as ROUTER_COMPONENTS,B as RUNTIME_CONTRACT_V1,ft as RUNTIME_CONTRACT_V2,an as backends,E as builtinComponentMap,wt as builtinComponents,O as cleanTemplateText,Xe as compilePieces,Ut as compileTemplate,fe as componentGlobals,P as createComponentResolver,rn as defaultOptions,h as imperativeBackend,Ee as isReactiveShape,F as lowerTemplate,de as resolveComponentSources,St as routerComponents,M as walk,tn as writeComponentGlobals};
|