@fluxion-ui/compiler-core 0.0.3

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026-present, Fluxion Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ "use strict";var e=require("@fluxion-ui/shared"),n=(e=>(e[e.ROOT=0]="ROOT",e[e.ELEMENT=1]="ELEMENT",e[e.TEXT=2]="TEXT",e[e.INTERPOLATION=3]="INTERPOLATION",e[e.ATTRIBUTE=4]="ATTRIBUTE",e[e.DIRECTIVE=5]="DIRECTIVE",e[e.IF=6]="IF",e[e.IF_BRANCH=7]="IF_BRANCH",e[e.FOR=8]="FOR",e[e.SIMPLE_EXPRESSION=9]="SIMPLE_EXPRESSION",e[e.COMPOUND_EXPRESSION=10]="COMPOUND_EXPRESSION",e[e.JS_CALL_EXPRESSION=11]="JS_CALL_EXPRESSION",e[e.JS_OBJECT_EXPRESSION=12]="JS_OBJECT_EXPRESSION",e[e.JS_ARRAY_EXPRESSION=13]="JS_ARRAY_EXPRESSION",e[e.JS_FUNCTION_EXPRESSION=14]="JS_FUNCTION_EXPRESSION",e[e.JS_CONDITIONAL_EXPRESSION=15]="JS_CONDITIONAL_EXPRESSION",e))(n||{}),t=(e=>(e[e.ELEMENT=0]="ELEMENT",e[e.COMPONENT=1]="COMPONENT",e))(t||{}),r=(e=>(e[e.ABRUPT_CLOSING_OF_EMPTY_COMMENT=0]="ABRUPT_CLOSING_OF_EMPTY_COMMENT",e[e.CDATA_IN_HTML_CONTENT=1]="CDATA_IN_HTML_CONTENT",e[e.DUPLICATE_ATTRIBUTE=2]="DUPLICATE_ATTRIBUTE",e[e.END_TAG_WITH_ATTRIBUTES=3]="END_TAG_WITH_ATTRIBUTES",e[e.END_TAG_WITH_TRAILING_SOLIDUS=4]="END_TAG_WITH_TRAILING_SOLIDUS",e[e.EOF_BEFORE_TAG_NAME=5]="EOF_BEFORE_TAG_NAME",e[e.EOF_IN_CDATA=6]="EOF_IN_CDATA",e[e.EOF_IN_COMMENT=7]="EOF_IN_COMMENT",e[e.EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT=8]="EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",e[e.EOF_IN_TAG=9]="EOF_IN_TAG",e[e.INCORRECTLY_CLOSED_COMMENT=10]="INCORRECTLY_CLOSED_COMMENT",e[e.INCORRECTLY_OPENED_COMMENT=11]="INCORRECTLY_OPENED_COMMENT",e[e.INVALID_FIRST_CHARACTER_OF_TAG_NAME=12]="INVALID_FIRST_CHARACTER_OF_TAG_NAME",e[e.MISSING_ATTRIBUTE_VALUE=13]="MISSING_ATTRIBUTE_VALUE",e[e.MISSING_END_TAG_NAME=14]="MISSING_END_TAG_NAME",e[e.MISSING_WHITESPACE_BETWEEN_ATTRIBUTES=15]="MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",e[e.NESTED_COMMENT=16]="NESTED_COMMENT",e[e.UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME=17]="UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",e[e.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE=18]="UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",e[e.UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME=19]="UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",e[e.UNEXPECTED_NULL_CHARACTER=20]="UNEXPECTED_NULL_CHARACTER",e[e.UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME=21]="UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",e[e.UNEXPECTED_SOLIDUS_IN_TAG=22]="UNEXPECTED_SOLIDUS_IN_TAG",e[e.X_IF_NO_CONDITION=23]="X_IF_NO_CONDITION",e[e.X_ELIF_NO_ADJACENT_IF=24]="X_ELIF_NO_ADJACENT_IF",e[e.X_ELSE_NO_ADJACENT_IF=25]="X_ELSE_NO_ADJACENT_IF",e[e.X_FOR_NO_EXPRESSION=26]="X_FOR_NO_EXPRESSION",e[e.X_FOR_MALFORMED_EXPRESSION=27]="X_FOR_MALFORMED_EXPRESSION",e[e.UNKNOWN_ERROR=28]="UNKNOWN_ERROR",e))(r||{});const o={offset:0,line:1,column:1},s={start:o,end:o,source:""};function E(e="",t=s){return{type:n.TEXT,content:e,loc:t}}function c(e,t=!1,r=s,o){return{type:n.SIMPLE_EXPRESSION,content:e,isStatic:t,loc:r,identifiers:o}}function i(e,t=s){return{type:n.COMPOUND_EXPRESSION,children:e,loc:t}}function u(e,t=[],r=s){return{type:n.JS_CALL_EXPRESSION,callee:e,arguments:t,loc:r}}function N(e=[],t=s){return{type:n.JS_OBJECT_EXPRESSION,properties:e,loc:t}}function l(e=[],t=s){return{type:n.JS_ARRAY_EXPRESSION,elements:e,loc:t}}function _(e=[],t,r=!1,o=!1,E=s){return{type:n.JS_FUNCTION_EXPRESSION,params:e,returns:t,newline:r,isSlot:o,loc:E}}function p(e,t,r,o=!0,E=s){return{type:n.JS_CONDITIONAL_EXPRESSION,test:e,consequent:t,alternate:r,newline:o,loc:E}}function T(e){return e?.type===n.ELEMENT}function d(e){return e?.type===n.TEXT}function I(e){return e?.type===n.INTERPOLATION}function a(e){return e?.type===n.IF}function f(e){return e?.type===n.FOR}function O(e){switch(e.type){case n.ROOT:case n.ELEMENT:case n.IF_BRANCH:case n.FOR:return e.children;case n.IF:return e.branches;default:return[]}}function h(n,t={}){const r={root:n,parent:null,childIndex:0,currentNode:null,helpers:new Set,components:new Set,directives:new Set,nodeTransforms:t.nodeTransforms||[],replaceNode(n){if(!r.parent)return void e.warn("replaceNode: 没有父节点");const t=O(r.parent);t&&(t[r.childIndex]=n),r.currentNode=n},removeNode(n){if(!r.parent)return void e.warn("removeNode: 没有父节点");const t=O(r.parent);if(t){const e=n?t.indexOf(n):r.childIndex;e>-1&&t.splice(e,1)}r.currentNode=null},traverseChildren(e){R(e,r)},traverseNode(e){S(e,r)},helper:e=>(r.helpers.add(e),e),onError:t.onError};return r}function S(e,t){t.currentNode=e;const{nodeTransforms:r}=t,o=[];if(r)for(const n of r){const r=n(e,t);if(!t.currentNode)return;r&&(Array.isArray(r)?o.push(...r):o.push(r))}switch(e.type){case n.ROOT:case n.ELEMENT:case n.IF:case n.FOR:case n.IF_BRANCH:R(e,t)}t.currentNode=e;let s=o.length;for(;s--;)o[s]()}function R(e,n){const t=O(e);if(!t||0===t.length)return;let r=n.parent;n.parent=e;for(let e=0;e<t.length;e++)n.childIndex=e,S(t[e],n);n.parent=r}function A(n,t){a(n)&&function(n){const{branches:t}=n;if(0===t.length)return void e.warn("transformIf: if 节点没有分支");const r=function(e){const{branches:n}=e;let t=n[n.length-1],r=L(t);for(let e=n.length-2;e>=0;e--){const t=n[e];r=p(C(t),L(t),r,!0)}return r}(n);r&&(n.codegenNode=r)}(n)}function C(n,t){if(!n.condition)return e.warn("transformIf: if 分支缺少条件"),c("true",!1);return c(function(e){if(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!e.includes("("))return`${e}()`;return e}(n.condition.content),!1)}function L(e,t){if(1===e.children.length){const t=e.children[0];if(t.type===n.ELEMENT&&t.codegenNode)return t.codegenNode}return c(`/* branch with ${e.children.length} children */`,!1)}var m=(e=>(e.CREATE_ELEMENT_VNODE="h",e.CREATE_TEXT_VNODE="createTextVNode",e.CREATE_COMMENT_VNODE="createCommentVNode",e.RESOLVE_COMPONENT="resolveComponent",e.RESOLVE_DIRECTIVE="resolveDirective",e.RENDER_LIST="renderList",e.RENDER_SLOT="renderSlot",e.MERGE_PROPS="mergeProps",e.NORMALIZE_CLASS="normalizeClass",e.NORMALIZE_STYLE="normalizeStyle",e.NORMALIZE_PROPS="normalizeProps",e.WITH_DIRECTIVES="withDirectives",e.WITH_CTX="withCtx",e))(m||{});const M={CREATE_ELEMENT_VNODE:Symbol("h"),CREATE_TEXT_VNODE:Symbol("createTextVNode"),CREATE_COMMENT_VNODE:Symbol("createCommentVNode"),RESOLVE_COMPONENT:Symbol("resolveComponent"),RESOLVE_DIRECTIVE:Symbol("resolveDirective"),RENDER_LIST:Symbol("renderList"),RENDER_SLOT:Symbol("renderSlot"),MERGE_PROPS:Symbol("mergeProps"),NORMALIZE_CLASS:Symbol("normalizeClass"),NORMALIZE_STYLE:Symbol("normalizeStyle"),NORMALIZE_PROPS:Symbol("normalizeProps"),WITH_DIRECTIVES:Symbol("withDirectives"),WITH_CTX:Symbol("withCtx")};function g(e){for(const[n,t]of Object.entries(M))if(t===e)return m[n];return""}function P(t,r){f(t)&&function(t,r){const{source:o}=t;if(!o)return void e.warn("transformFor: for 节点缺少源表达式");r.helper(M.CREATE_ELEMENT_VNODE);const s=function(e){const{source:t,valueAlias:r,keyAlias:o,indexAlias:s,children:E}=e,c=[r];o&&c.push(o);s&&c.push(s);let i;if(1===E.length){const e=E[0];i=e.type===n.ELEMENT&&e.codegenNode?e.codegenNode:l([e])}else i=l(E.map(e=>e.type===n.ELEMENT&&e.codegenNode?e.codegenNode:e));const N=_(c,i,!1,!1),p=function(e){if(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!e.includes("("))return`${e}()`;return e}(t.content);return u(`${p}.map`,[N])}(t);s&&(t.codegenNode=s)}(t,r)}function y(e,t){if(T(e))return()=>{!function(e,t){t.helper(M.CREATE_ELEMENT_VNODE);const r=function(e,t){const{tag:r,props:o,children:s}=e,E=function(e){return/^[A-Z]/.test(e)||e.includes("-")}(r),c=[];E?(c.push(r),t.components.add(r)):c.push(`"${r}"`);const i=function(e){if(0===e.length)return null;const t=[];for(const r of e)if(r.type===n.ATTRIBUTE)t.push({key:r.name,value:r.value?`"${r.value.content}"`:"true"});else if(r.type===n.DIRECTIVE){const e=x(r);e&&t.push(e)}if(0===t.length)return null;return N(t)}(o);(i||s.length>0)&&c.push(i||"null");if(s.length>0){const e=function(e){if(0===e.length)return null;if(1===e.length){const t=e[0];if(t.type===n.TEXT)return`"${t.content}"`;if(t.type===n.INTERPOLATION)return F(t.content.content);if(t.type===n.ELEMENT&&t.codegenNode)return t.codegenNode}const t=[];for(const r of e)r.type===n.TEXT?t.push(`"${r.content}"`):r.type===n.INTERPOLATION?t.push(F(r.content.content)):r.type===n.ELEMENT||r.type===n.IF?r.codegenNode&&t.push(r.codegenNode):r.type===n.FOR&&r.codegenNode&&t.push(r.codegenNode);return l(t)}(s);c.push(e)}return u(M.CREATE_ELEMENT_VNODE,c)}(e,t);r&&(e.codegenNode=r)}(e,t)}}function x(e,n){const{name:t,exp:r,arg:o}=e;switch(t){case"click":case"mousedown":case"mouseup":case"mouseenter":case"mouseleave":case"keydown":case"keyup":case"submit":case"input":case"change":default:return{key:`on${D(t)}`,value:r?r.content:"() => {}"};case"bind":return o?{key:o.content,value:F(r?.content||"")}:null;case"model":return null}}function D(e){return e.charAt(0).toUpperCase()+e.slice(1)}function F(e){return e?/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!e.includes("(")?`${e}()`:e:""}function X(e,n){if(T(e))return()=>{!function(e){const{children:n}=e;let t=!1,r=null;for(let e=0;e<n.length;e++){const o=n[e];if(d(o)||I(o))if(t=!0,r){if(d(o))r.children.push(o.content);else{r.children.push(c(U(o.content.content),!1))}n.splice(e,1),e--}else if(d(o)){const t=n[e+1];t&&(d(t)||I(t))&&(r=i([o.content]),n[e]=r)}else{const t=o.content.content,s=n[e+1];s&&(d(s)||I(s))?(r=i([c(U(t),!1)]),n[e]=r):o.content=c(U(t),!1)}else r=null}if(!t);}(e)}}function U(e){return e?/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!e.includes("(")?`${e}()`:e:""}function v(t,r){switch(t.type){case n.ELEMENT:!function(e,n){if(e.codegenNode)v(e.codegenNode,n);else{if(n.push(`h("${e.tag}"`),e.props.length>0&&(n.push(", "),function(e,n){n.push("{");for(let t=0;t<e.length;t++){const r=e[t];n.push(`${r.name}: ${r.value?`"${r.value.content}"`:"true"}`),t<e.length-1&&n.push(", ")}n.push("}")}(e.props,n)),e.children.length>0)if(n.push(", "),1===e.children.length)v(e.children[0],n);else{n.push("[");for(let t=0;t<e.children.length;t++)v(e.children[t],n),t<e.children.length-1&&n.push(", ");n.push("]")}n.push(")")}}(t,r);break;case n.TEXT:!function(e,n){n.push(`"${e.content}"`)}(t,r);break;case n.INTERPOLATION:!function(e,n){const t=e.content.content;n.push(t)}(t,r);break;case n.IF:!function(n,t){n.codegenNode?v(n.codegenNode,t):e.warn("genIfNode: if 节点缺少 codegenNode")}(t,r);break;case n.FOR:!function(n,t){n.codegenNode?v(n.codegenNode,t):e.warn("genForNode: for 节点缺少 codegenNode")}(t,r);break;case n.SIMPLE_EXPRESSION:!function(e,n){n.push(e.content)}(t,r);break;case n.COMPOUND_EXPRESSION:!function(e,n){for(const t of e.children)"string"==typeof t?n.push(t):v(t,n)}(t,r);break;case n.JS_CALL_EXPRESSION:!function(e,n){n.push("symbol"==typeof e.callee?g(e.callee)||"h":e.callee);n.push("(");for(let t=0;t<e.arguments.length;t++){const r=e.arguments[t];"string"==typeof r?n.push(r):v(r,n),t<e.arguments.length-1&&n.push(", ")}n.push(")")}(t,r);break;case n.JS_OBJECT_EXPRESSION:!function(e,n){if(0===e.properties.length)return void n.push("{}");n.push("{\n"),n.indentCode();for(let t=0;t<e.properties.length;t++){const r=e.properties[t];n.push(n.indent()),"string"==typeof r.key?n.push(r.key):v(r.key,n),n.push(": "),"string"==typeof r.value?n.push(r.value):v(r.value,n),t<e.properties.length-1&&n.push(","),n.push("\n")}n.deindent(),n.push(n.indent()),n.push("}")}(t,r);break;case n.JS_ARRAY_EXPRESSION:!function(e,n){if(0===e.elements.length)return void n.push("[]");n.push("[\n"),n.indentCode();for(let t=0;t<e.elements.length;t++){const r=e.elements[t];n.push(n.indent()),null===r?n.push("null"):"string"==typeof r?n.push(r):v(r,n),t<e.elements.length-1&&n.push(","),n.push("\n")}n.deindent(),n.push(n.indent()),n.push("]")}(t,r);break;case n.JS_FUNCTION_EXPRESSION:!function(e,n){n.push("(");const t=e.params;for(let e=0;e<t.length;e++)n.push(t[e]),e<t.length-1&&n.push(", ");n.push(") => "),e.returns?e.newline?(n.push("{\n"),n.indentCode(),n.push(n.indent()),n.push("return "),v(e.returns,n),n.push("\n"),n.deindent(),n.push(n.indent()),n.push("}")):v(e.returns,n):e.body&&v(e.body,n)}(t,r);break;case n.JS_CONDITIONAL_EXPRESSION:!function(e,n){v(e.test,n),n.push(" ? "),v(e.consequent,n),n.push(" : "),v(e.alternate,n)}(t,r);break;default:e.warn(`genNode: 未知的节点类型 ${t.type}`)}}exports.ElementTypes=t,exports.ErrorCodes=r,exports.NodeTypes=n,exports.cloneNode=function(e){const n={...e};return e.loc&&(n.loc={...e.loc}),n},exports.createArrayExpression=l,exports.createAttributeNode=function(e,t=null,r=s){const o="string"==typeof t?E(t,r):t;return{type:n.ATTRIBUTE,name:e,value:o,loc:r}},exports.createCallExpression=u,exports.createCompoundExpression=i,exports.createConditionalExpression=p,exports.createDirectiveNode=function(e,t=null,r=null,o=[],E=s){const i="string"==typeof t?c(t,!1,E):t,u="string"==typeof r?c(r,!0,E):r;return{type:n.DIRECTIVE,name:e,exp:i,arg:u,modifiers:o,loc:E}},exports.createElementNode=function(e,t=[],r=[],o=s,E=!1){return{type:n.ELEMENT,tag:e,props:t,children:r,isSelfClosing:E,loc:o}},exports.createForNode=function(e,t,r,o,E,c=s){return{type:n.FOR,source:e,valueAlias:t,keyAlias:o,indexAlias:E,children:r,loc:c}},exports.createFunctionExpression=_,exports.createIfBranchNode=function(e,t,r=s){return{type:n.IF_BRANCH,children:e,condition:t,loc:r}},exports.createIfNode=function(e,t=s){return{type:n.IF,branches:e,loc:t}},exports.createInterpolationNode=function(e,t=s){const r="string"==typeof e?c(e,!1,t):e;return{type:n.INTERPOLATION,content:r,loc:t}},exports.createObjectExpression=N,exports.createPosition=function(e,n,t){return{offset:e,line:n,column:t}},exports.createRoot=function(e=[],t=s){return{type:n.ROOT,children:e,helpers:new Set,components:new Set,directives:new Set,imports:new Set,loc:t}},exports.createSimpleExpression=c,exports.createSourceLocation=function(e,n,t){return{start:e,end:n,source:t}},exports.createTextNode=E,exports.createTransform=function(e,n){return(t,r)=>{if(e.includes(t.type))return n(t,r)}},exports.createTransformContext=h,exports.generate=function(e){const n=function(){const e={code:"",indentLevel:0,indent:(n=e.indentLevel)=>" ".repeat(n),newline:()=>"\n",push(n){e.code+=n},indentCode(){e.indentLevel++},deindent(){e.indentLevel--}};return e}();return function(e,n){if(e.helpers.size>0){const t=[];for(const n of e.helpers){const e=g(n);e&&!t.includes(e)&&t.push(e)}t.length>0&&n.push(`import { ${t.join(", ")} } from '@fluxion-ui/fluxion/runtime'\n`)}n.push("\n")}(e,n),function(e,n){if(n.push("export function render() {\n"),n.indentCode(),n.push(n.indent()),n.push("return "),1===e.children.length)v(e.children[0],n);else if(e.children.length>1){n.push("[\n"),n.indentCode();for(let t=0;t<e.children.length;t++)n.push(n.indent()),v(e.children[t],n),t<e.children.length-1&&n.push(","),n.push("\n");n.deindent(),n.push(n.indent()),n.push("]")}else n.push("null");n.push("\n"),n.deindent(),n.push("}\n")}(e,n),{code:n.code,ast:e,preamble:""}},exports.getDefaultTransforms=function(){return[A,P,y,X]},exports.getIfBranchType=function(e){return e.condition?"if":"else"},exports.getNodeChildren=O,exports.getRuntimeHelperName=g,exports.hasTextChildren=function(e){return e.children.some(e=>d(e)||I(e))},exports.isCompoundExpressionNode=function(e){return e?.type===n.COMPOUND_EXPRESSION},exports.isElementNode=T,exports.isForNode=f,exports.isIfNode=a,exports.isInterpolationNode=I,exports.isRuntimeHelper=function(e){return"symbol"==typeof e&&Object.values(M).includes(e)},exports.isSimpleExpressionNode=function(e){return e?.type===n.SIMPLE_EXPRESSION},exports.isTextNode=d,exports.isValidForNode=function(e){return f(e)&&!!e.source},exports.isValidIfBranch=function(e){return e?.type===n.IF_BRANCH},exports.normalizeTextContent=function(e){const n=[];for(const t of e.children)d(t)?n.push(t.content):I(t)&&n.push(`{${t.content.content}}`);return n.join("")},exports.parseForExpression=function(e,n,t,r){const o=e.match(/^\s*(?:\(([^)]+)\)|(\w+))\s+in\s+(.+)$/);if(!o)return null;const s=o[3].trim();if(o[2])return{source:s,value:o[2]};{const e=o[1].split(",").map(e=>e.trim()),n={source:s,value:e[0]};return 2===e.length?n.index=e[1]:e.length>=3&&(n.key=e[1],n.index=e[2]),n}},exports.runtimeHelpers=M,exports.transform=function(e,n={}){const t=h(e,n);S(e,t),e.helpers=new Set([...e.helpers,...t.helpers]),e.components=new Set([...e.components,...t.components]),e.directives=new Set([...e.directives,...t.directives])},exports.transformElement=y,exports.transformFor=P,exports.transformIf=A,exports.transformText=X,exports.traverseChildren=R,exports.traverseNode=S;
2
+ //# sourceMappingURL=compiler-core.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler-core.cjs","sources":["../src/types.ts","../src/ast.ts","../src/transform.ts","../src/transforms/vIf.ts","../src/runtimeHelpers.ts","../src/transforms/vFor.ts","../src/transforms/transformElement.ts","../src/transforms/transformText.ts","../src/codegen/codegen.ts","../src/transforms/index.ts"],"sourcesContent":["/**\n * compiler-core 核心类型定义\n * 定义 AST 节点类型、转换上下文、编译选项等\n */\n\n// ==================== AST 节点类型枚举 ====================\n\n/**\n * AST 节点类型枚举\n */\nexport const enum NodeTypes {\n\tROOT, // 根节点\n\tELEMENT, // 元素节点\n\tTEXT, // 文本节点\n\tINTERPOLATION, // 插值表达式 {count}\n\tATTRIBUTE, // 属性\n\tDIRECTIVE, // 指令 @click\n\tIF, // if 条件\n\tIF_BRANCH, // if 分支\n\tFOR, // for 循环\n\tSIMPLE_EXPRESSION, // 简单表达式\n\tCOMPOUND_EXPRESSION, // 复合表达式\n\tJS_CALL_EXPRESSION, // JS 函数调用\n\tJS_OBJECT_EXPRESSION, // JS 对象表达式\n\tJS_ARRAY_EXPRESSION, // JS 数组表达式\n\tJS_FUNCTION_EXPRESSION, // JS 函数表达式\n\tJS_CONDITIONAL_EXPRESSION // JS 条件表达式\n}\n\n// ==================== 基础节点接口 ====================\n\n/**\n * AST 节点基础接口\n */\nexport interface BaseNode {\n\ttype: NodeTypes\n\tloc?: SourceLocation\n}\n\n/**\n * 源码位置信息\n */\nexport interface SourceLocation {\n\tstart: Position\n\tend: Position\n\tsource: string\n}\n\n/**\n * 位置信息\n */\nexport interface Position {\n\toffset: number\n\tline: number\n\tcolumn: number\n}\n\n// ==================== 表达式节点 ====================\n\n/**\n * 表达式节点基类\n */\nexport interface ExpressionNode extends BaseNode {\n\tcontent: string\n\tisStatic?: boolean\n}\n\n/**\n * 简单表达式节点\n */\nexport interface SimpleExpressionNode extends ExpressionNode {\n\ttype: NodeTypes.SIMPLE_EXPRESSION\n\tisStatic: boolean\n\tidentifiers?: string[]\n}\n\n/**\n * 复合表达式节点\n */\nexport interface CompoundExpressionNode extends BaseNode {\n\ttype: NodeTypes.COMPOUND_EXPRESSION\n\tchildren: (SimpleExpressionNode | CompoundExpressionNode | InterpolationNode | TextNode | string)[]\n\tidentifiers?: string[]\n}\n\n// ==================== 模板子节点 ====================\n\n/**\n * 模板子节点类型\n */\nexport type TemplateChildNode =\n\t| ElementNode\n\t| TextNode\n\t| InterpolationNode\n\t| IfNode\n\t| ForNode\n\n/**\n * 文本节点\n */\nexport interface TextNode extends BaseNode {\n\ttype: NodeTypes.TEXT\n\tcontent: string\n}\n\n/**\n * 插值节点 {count}\n */\nexport interface InterpolationNode extends BaseNode {\n\ttype: NodeTypes.INTERPOLATION\n\tcontent: ExpressionNode\n}\n\n// ==================== 元素节点 ====================\n\n/**\n * 元素节点\n */\nexport interface ElementNode extends BaseNode {\n\ttype: NodeTypes.ELEMENT\n\ttag: string\n\tprops: Array<AttributeNode | DirectiveNode>\n\tchildren: TemplateChildNode[]\n\tisSelfClosing: boolean\n\tcodegenNode?: CodegenNode\n\ttagType?: ElementTypes\n}\n\n/**\n * 元素类型\n */\nexport const enum ElementTypes {\n\tELEMENT, // 普通元素\n\tCOMPONENT // 组件\n}\n\n/**\n * 属性节点\n */\nexport interface AttributeNode extends BaseNode {\n\ttype: NodeTypes.ATTRIBUTE\n\tname: string\n\tvalue: TextNode | null\n}\n\n/**\n * 指令节点\n */\nexport interface DirectiveNode extends BaseNode {\n\ttype: NodeTypes.DIRECTIVE\n\tname: string\n\texp: ExpressionNode | null\n\targ: ExpressionNode | null\n\tmodifiers: string[]\n}\n\n// ==================== 控制流节点 ====================\n\n/**\n * if 节点\n */\nexport interface IfNode extends BaseNode {\n\ttype: NodeTypes.IF\n\tbranches: IfBranchNode[]\n\tcodegenNode?: CodegenNode\n}\n\n/**\n * if 分支节点\n */\nexport interface IfBranchNode extends BaseNode {\n\ttype: NodeTypes.IF_BRANCH\n\tcondition?: ExpressionNode\n\tchildren: TemplateChildNode[]\n\tuserKey?: string | number\n}\n\n/**\n * for 节点\n */\nexport interface ForNode extends BaseNode {\n\ttype: NodeTypes.FOR\n\tsource: ExpressionNode\n\tvalueAlias: string\n\tkeyAlias?: string\n\tindexAlias?: string\n\tchildren: TemplateChildNode[]\n\tcodegenNode?: CodegenNode\n}\n\n// ==================== 根节点 ====================\n\n/**\n * 根节点\n */\nexport interface RootNode extends BaseNode {\n\ttype: NodeTypes.ROOT\n\tchildren: TemplateChildNode[]\n\thelpers: Set<symbol>\n\tcomponents: Set<string>\n\tdirectives: Set<string>\n\timports: Set<string>\n\thoists?: (JSChildNode | null)[]\n\tcached?: number\n\tcodegenNode?: TemplateChildNode | CodegenNode\n}\n\n// ==================== JS 代码生成节点 ====================\n\n/**\n * JS 子节点类型\n */\nexport type JSChildNode =\n\t| JSCallExpression\n\t| JSObjectExpression\n\t| JSArrayExpression\n\t| JSFunctionExpression\n\t| JSConditionalExpression\n\t| SimpleExpressionNode\n\t| CompoundExpressionNode\n\n/**\n * 代码生成节点\n */\nexport type CodegenNode = JSChildNode\n\n/**\n * JS 函数调用表达式\n */\nexport interface JSCallExpression extends BaseNode {\n\ttype: NodeTypes.JS_CALL_EXPRESSION\n\tcallee: string | symbol\n\targuments: (string | JSChildNode)[]\n}\n\n/**\n * JS 对象表达式\n */\nexport interface JSObjectExpression extends BaseNode {\n\ttype: NodeTypes.JS_OBJECT_EXPRESSION\n\tproperties: Array<JSProperty | SpreadElement>\n}\n\n/**\n * JS 属性\n */\nexport interface JSProperty {\n\tkey: string | ExpressionNode\n\tvalue: JSChildNode | string\n\truntimeName?: string\n}\n\n/**\n * 展开元素\n */\nexport interface SpreadElement extends BaseNode {\n\ttype: NodeTypes.JS_CALL_EXPRESSION\n\targuments: JSChildNode[]\n}\n\n/**\n * JS 数组表达式\n */\nexport interface JSArrayExpression extends BaseNode {\n\ttype: NodeTypes.JS_ARRAY_EXPRESSION\n\telements: (JSChildNode | string | null)[]\n}\n\n/**\n * JS 函数表达式\n */\nexport interface JSFunctionExpression extends BaseNode {\n\ttype: NodeTypes.JS_FUNCTION_EXPRESSION\n\tparams: string[] | ExpressionNode[]\n\treturns?: JSChildNode\n\tbody?: JSChildNode\n\tnewline: boolean\n\tisSlot: boolean\n}\n\n/**\n * JS 条件表达式\n */\nexport interface JSConditionalExpression extends BaseNode {\n\ttype: NodeTypes.JS_CONDITIONAL_EXPRESSION\n\ttest: JSChildNode\n\tconsequent: JSChildNode\n\talternate: JSChildNode | JSConditionalExpression\n\tnewline: boolean\n}\n\n// ==================== 转换上下文 ====================\n\n/**\n * 转换函数类型\n */\nexport type TransformFn = (node: TemplateChildNode, context: TransformContext) => void | (() => void) | (() => void)[]\n\n/**\n * 转换上下文\n */\nexport interface TransformContext {\n\t// 根节点\n\troot: RootNode\n\n\t// 父节点\n\tparent: TemplateChildNode | null\n\n\t// 当前节点索引\n\tchildIndex: number\n\n\t// 当前节点\n\tcurrentNode: TemplateChildNode | null\n\n\t// 帮助函数\n\thelpers: Set<symbol>\n\tcomponents: Set<string>\n\tdirectives: Set<string>\n\n\t// 转换插件\n\tnodeTransforms: TransformFn[]\n\n\t// 替换节点\n\treplaceNode(node: TemplateChildNode): void\n\n\t// 移除节点\n\tremoveNode(node?: TemplateChildNode): void\n\n\t// 遍历子节点\n\ttraverseChildren(parent: TemplateChildNode | RootNode): void\n\n\t// 遍历节点\n\ttraverseNode(node: TemplateChildNode | RootNode): void\n\n\t// 辅助函数\n\thelper(name: symbol): symbol\n\n\t// 错误处理\n\tonError?: (error: CompilerError) => void\n}\n\n// ==================== 编译选项 ====================\n\n/**\n * 编译选项\n */\nexport interface CompilerOptions {\n\t// 是否在开发模式\n\tisBrowser?: boolean\n\n\t// 文件名\n\tfilename?: string\n\n\t// 源码\n\tsource?: string\n\n\t// 前置转换\n\thoistStatic?: boolean\n\n\t// 转换插件\n\tnodeTransforms?: TransformFn[]\n\n\t// 指令转换\n\tdirectiveTransforms?: Record<string, TransformFn>\n\n\t// 表达式转换\n\texpressionTransforms?: Record<string, TransformFn>\n\n\t// 错误处理\n\tonError?: (error: CompilerError) => void\n}\n\n// ==================== 编译结果 ====================\n\n/**\n * 代码生成结果\n */\nexport interface CodegenResult {\n\tcode: string\n\tast: RootNode\n\tpreamble: string\n\tmap?: SourceMap\n}\n\n/**\n * 源码映射(简化版)\n */\nexport interface SourceMap {\n\tfile?: string\n\tmappings: string\n\tnames: string[]\n\tsourceRoot?: string\n\tsources: string[]\n\tsourcesContent?: string[]\n\tversion: number\n}\n\n// ==================== 编译错误 ====================\n\n/**\n * 编译错误\n */\nexport interface CompilerError extends SyntaxError {\n\tcode: number\n\tloc?: SourceLocation\n}\n\n/**\n * 错误代码\n */\nexport const enum ErrorCodes {\n\t// 解析错误\n\tABRUPT_CLOSING_OF_EMPTY_COMMENT,\n\tCDATA_IN_HTML_CONTENT,\n\tDUPLICATE_ATTRIBUTE,\n\tEND_TAG_WITH_ATTRIBUTES,\n\tEND_TAG_WITH_TRAILING_SOLIDUS,\n\tEOF_BEFORE_TAG_NAME,\n\tEOF_IN_CDATA,\n\tEOF_IN_COMMENT,\n\tEOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT,\n\tEOF_IN_TAG,\n\tINCORRECTLY_CLOSED_COMMENT,\n\tINCORRECTLY_OPENED_COMMENT,\n\tINVALID_FIRST_CHARACTER_OF_TAG_NAME,\n\tMISSING_ATTRIBUTE_VALUE,\n\tMISSING_END_TAG_NAME,\n\tMISSING_WHITESPACE_BETWEEN_ATTRIBUTES,\n\tNESTED_COMMENT,\n\tUNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME,\n\tUNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE,\n\tUNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME,\n\tUNEXPECTED_NULL_CHARACTER,\n\tUNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME,\n\tUNEXPECTED_SOLIDUS_IN_TAG,\n\n\t// 转换错误\n\tX_IF_NO_CONDITION,\n\tX_ELIF_NO_ADJACENT_IF,\n\tX_ELSE_NO_ADJACENT_IF,\n\tX_FOR_NO_EXPRESSION,\n\tX_FOR_MALFORMED_EXPRESSION,\n\n\t// 未知错误\n\tUNKNOWN_ERROR\n}","/**\n * AST 节点创建和工具函数\n */\n\nimport {\n\tNodeTypes,\n\tRootNode,\n\tElementNode,\n\tTextNode,\n\tInterpolationNode,\n\tIfNode,\n\tIfBranchNode,\n\tForNode,\n\tAttributeNode,\n\tDirectiveNode,\n\tSimpleExpressionNode,\n\tCompoundExpressionNode,\n\tElementTypes,\n\tSourceLocation,\n\tPosition,\n\tJSCallExpression,\n\tJSObjectExpression,\n\tJSArrayExpression,\n\tJSFunctionExpression,\n\tJSConditionalExpression,\n\tJSChildNode,\n\tTemplateChildNode\n} from './types'\nimport { warn } from '@fluxion-ui/shared'\n\n// ==================== 位置相关 ====================\n\n/**\n * 默认位置\n */\nexport const defaultPosition: Position = {\n\toffset: 0,\n\tline: 1,\n\tcolumn: 1\n}\n\n/**\n * 默认源码位置\n */\nexport const defaultLoc: SourceLocation = {\n\tstart: defaultPosition,\n\tend: defaultPosition,\n\tsource: ''\n}\n\n/**\n * 创建位置对象\n */\nexport function createPosition(\n\toffset: number,\n\tline: number,\n\tcolumn: number\n): Position {\n\treturn { offset, line, column }\n}\n\n/**\n * 创建源码位置对象\n */\nexport function createSourceLocation(\n\tstart: Position,\n\tend: Position,\n\tsource: string\n): SourceLocation {\n\treturn { start, end, source }\n}\n\n// ==================== 根节点 ====================\n\n/**\n * 创建根节点\n */\nexport function createRoot(\n\tchildren: TemplateChildNode[] = [],\n\tloc: SourceLocation = defaultLoc\n): RootNode {\n\treturn {\n\t\ttype: NodeTypes.ROOT,\n\t\tchildren,\n\t\thelpers: new Set(),\n\t\tcomponents: new Set(),\n\t\tdirectives: new Set(),\n\t\timports: new Set(),\n\t\tloc\n\t}\n}\n\n// ==================== 元素节点 ====================\n\n/**\n * 创建元素节点\n */\nexport function createElementNode(\n\ttag: string,\n\tprops: Array<AttributeNode | DirectiveNode> = [],\n\tchildren: TemplateChildNode[] = [],\n\tloc: SourceLocation = defaultLoc,\n\tisSelfClosing: boolean = false\n): ElementNode {\n\treturn {\n\t\ttype: NodeTypes.ELEMENT,\n\t\ttag,\n\t\tprops,\n\t\tchildren,\n\t\tisSelfClosing,\n\t\tloc\n\t}\n}\n\n// ==================== 文本节点 ====================\n\n/**\n * 创建文本节点\n */\nexport function createTextNode(\n\tcontent: string = '',\n\tloc: SourceLocation = defaultLoc\n): TextNode {\n\treturn {\n\t\ttype: NodeTypes.TEXT,\n\t\tcontent,\n\t\tloc\n\t}\n}\n\n// ==================== 插值节点 ====================\n\n/**\n * 创建插值节点\n */\nexport function createInterpolationNode(\n\tcontent: string | ExpressionNode,\n\tloc: SourceLocation = defaultLoc\n): InterpolationNode {\n\tconst expression = typeof content === 'string'\n\t\t? createSimpleExpression(content, false, loc)\n\t\t: content\n\n\treturn {\n\t\ttype: NodeTypes.INTERPOLATION,\n\t\tcontent: expression,\n\t\tloc\n\t}\n}\n\n// ==================== 属性节点 ====================\n\n/**\n * 创建属性节点\n */\nexport function createAttributeNode(\n\tname: string,\n\tvalue: string | TextNode | null = null,\n\tloc: SourceLocation = defaultLoc\n): AttributeNode {\n\tconst valueNode = typeof value === 'string'\n\t\t? createTextNode(value, loc)\n\t\t: value\n\n\treturn {\n\t\ttype: NodeTypes.ATTRIBUTE,\n\t\tname,\n\t\tvalue: valueNode,\n\t\tloc\n\t}\n}\n\n/**\n * 创建指令节点\n */\nexport function createDirectiveNode(\n\tname: string,\n\texp: string | ExpressionNode | null = null,\n\targ: string | ExpressionNode | null = null,\n\tmodifiers: string[] = [],\n\tloc: SourceLocation = defaultLoc\n): DirectiveNode {\n\tconst expNode = typeof exp === 'string'\n\t\t? createSimpleExpression(exp, false, loc)\n\t\t: exp\n\n\tconst argNode = typeof arg === 'string'\n\t\t? createSimpleExpression(arg, true, loc)\n\t\t: arg\n\n\treturn {\n\t\ttype: NodeTypes.DIRECTIVE,\n\t\tname,\n\t\texp: expNode,\n\t\targ: argNode,\n\t\tmodifiers,\n\t\tloc\n\t}\n}\n\n// ==================== 表达式节点 ====================\n\n/**\n * 表达式节点类型\n */\nexport type ExpressionNode = SimpleExpressionNode | CompoundExpressionNode\n\n/**\n * 创建简单表达式节点\n */\nexport function createSimpleExpression(\n\tcontent: string,\n\tisStatic: boolean = false,\n\tloc: SourceLocation = defaultLoc,\n\tidentifiers?: string[]\n): SimpleExpressionNode {\n\treturn {\n\t\ttype: NodeTypes.SIMPLE_EXPRESSION,\n\t\tcontent,\n\t\tisStatic,\n\t\tloc,\n\t\tidentifiers\n\t}\n}\n\n/**\n * 创建复合表达式节点\n */\nexport function createCompoundExpression(\n\tchildren: (SimpleExpressionNode | CompoundExpressionNode | InterpolationNode | TextNode | string)[],\n\tloc: SourceLocation = defaultLoc\n): CompoundExpressionNode {\n\treturn {\n\t\ttype: NodeTypes.COMPOUND_EXPRESSION,\n\t\tchildren,\n\t\tloc\n\t}\n}\n\n// ==================== 控制流节点 ====================\n\n/**\n * 创建 if 节点\n */\nexport function createIfNode(\n\tbranches: IfBranchNode[],\n\tloc: SourceLocation = defaultLoc\n): IfNode {\n\treturn {\n\t\ttype: NodeTypes.IF,\n\t\tbranches,\n\t\tloc\n\t}\n}\n\n/**\n * 创建 if 分支节点\n */\nexport function createIfBranchNode(\n\tchildren: TemplateChildNode[],\n\tcondition?: ExpressionNode,\n\tloc: SourceLocation = defaultLoc\n): IfBranchNode {\n\treturn {\n\t\ttype: NodeTypes.IF_BRANCH,\n\t\tchildren,\n\t\tcondition,\n\t\tloc\n\t}\n}\n\n/**\n * 创建 for 节点\n */\nexport function createForNode(\n\tsource: ExpressionNode,\n\tvalueAlias: string,\n\tchildren: TemplateChildNode[],\n\tkeyAlias?: string,\n\tindexAlias?: string,\n\tloc: SourceLocation = defaultLoc\n): ForNode {\n\treturn {\n\t\ttype: NodeTypes.FOR,\n\t\tsource,\n\t\tvalueAlias,\n\t\tkeyAlias,\n\t\tindexAlias,\n\t\tchildren,\n\t\tloc\n\t}\n}\n\n// ==================== JS 代码节点 ====================\n\n/**\n * 创建 JS 函数调用表达式\n */\nexport function createCallExpression(\n\tcallee: string | symbol,\n\targs: (string | JSChildNode)[] = [],\n\tloc: SourceLocation = defaultLoc\n): JSCallExpression {\n\treturn {\n\t\ttype: NodeTypes.JS_CALL_EXPRESSION,\n\t\tcallee,\n\t\targuments: args,\n\t\tloc\n\t}\n}\n\n/**\n * 创建 JS 对象表达式\n */\nexport function createObjectExpression(\n\tproperties: Array<{ key: string | ExpressionNode; value: JSChildNode | string }> = [],\n\tloc: SourceLocation = defaultLoc\n): JSObjectExpression {\n\treturn {\n\t\ttype: NodeTypes.JS_OBJECT_EXPRESSION,\n\t\tproperties,\n\t\tloc\n\t}\n}\n\n/**\n * 创建 JS 数组表达式\n */\nexport function createArrayExpression(\n\telements: (JSChildNode | string | null)[] = [],\n\tloc: SourceLocation = defaultLoc\n): JSArrayExpression {\n\treturn {\n\t\ttype: NodeTypes.JS_ARRAY_EXPRESSION,\n\t\telements,\n\t\tloc\n\t}\n}\n\n/**\n * 创建 JS 函数表达式\n */\nexport function createFunctionExpression(\n\tparams: string[] | ExpressionNode[] = [],\n\treturns?: JSChildNode,\n\tnewline: boolean = false,\n\tisSlot: boolean = false,\n\tloc: SourceLocation = defaultLoc\n): JSFunctionExpression {\n\treturn {\n\t\ttype: NodeTypes.JS_FUNCTION_EXPRESSION,\n\t\tparams,\n\t\treturns,\n\t\tnewline,\n\t\tisSlot,\n\t\tloc\n\t}\n}\n\n/**\n * 创建 JS 条件表达式\n */\nexport function createConditionalExpression(\n\ttest: JSChildNode,\n\tconsequent: JSChildNode,\n\talternate: JSChildNode | JSConditionalExpression,\n\tnewline: boolean = true,\n\tloc: SourceLocation = defaultLoc\n): JSConditionalExpression {\n\treturn {\n\t\ttype: NodeTypes.JS_CONDITIONAL_EXPRESSION,\n\t\ttest,\n\t\tconsequent,\n\t\talternate,\n\t\tnewline,\n\t\tloc\n\t}\n}\n\n// ==================== 工具函数 ====================\n\n/**\n * 判断是否为元素节点\n */\nexport function isElementNode(node: any): node is ElementNode {\n\treturn node?.type === NodeTypes.ELEMENT\n}\n\n/**\n * 判断是否为文本节点\n */\nexport function isTextNode(node: any): node is TextNode {\n\treturn node?.type === NodeTypes.TEXT\n}\n\n/**\n * 判断是否为插值节点\n */\nexport function isInterpolationNode(node: any): node is InterpolationNode {\n\treturn node?.type === NodeTypes.INTERPOLATION\n}\n\n/**\n * 判断是否为 if 节点\n */\nexport function isIfNode(node: any): node is IfNode {\n\treturn node?.type === NodeTypes.IF\n}\n\n/**\n * 判断是否为 for 节点\n */\nexport function isForNode(node: any): node is ForNode {\n\treturn node?.type === NodeTypes.FOR\n}\n\n/**\n * 判断是否为简单表达式节点\n */\nexport function isSimpleExpressionNode(node: any): node is SimpleExpressionNode {\n\treturn node?.type === NodeTypes.SIMPLE_EXPRESSION\n}\n\n/**\n * 判断是否为复合表达式节点\n */\nexport function isCompoundExpressionNode(node: any): node is CompoundExpressionNode {\n\treturn node?.type === NodeTypes.COMPOUND_EXPRESSION\n}\n\n/**\n * 获取节点的所有子节点\n */\nexport function getNodeChildren(node: RootNode | ElementNode | IfNode | ForNode): TemplateChildNode[] {\n\tswitch (node.type) {\n\t\tcase NodeTypes.ROOT:\n\t\tcase NodeTypes.ELEMENT:\n\t\tcase NodeTypes.IF_BRANCH:\n\t\tcase NodeTypes.FOR:\n\t\t\treturn node.children\n\t\tcase NodeTypes.IF:\n\t\t\treturn node.branches\n\t\tdefault:\n\t\t\treturn []\n\t}\n}\n\n/**\n * 克隆 AST 节点\n */\nexport function cloneNode<T extends BaseNode>(node: T): T {\n\tconst cloned = { ...node }\n\tif (node.loc) {\n\t\tcloned.loc = { ...node.loc }\n\t}\n\treturn cloned\n}","/**\n * AST 转换核心\n * 负责遍历 AST 并执行转换插件\n */\n\nimport {\n\tNodeTypes,\n\tRootNode,\n\tTemplateChildNode,\n\tTransformContext,\n\tTransformFn,\n\tCompilerOptions,\n\tCompilerError\n} from './types'\nimport { createRoot, getNodeChildren } from './ast'\nimport { warn } from '@fluxion-ui/shared'\n\n/**\n * 创建转换上下文\n */\nexport function createTransformContext(\n\troot: RootNode,\n\toptions: CompilerOptions = {}\n): TransformContext {\n\tconst context: TransformContext = {\n\t\troot,\n\t\tparent: null,\n\t\tchildIndex: 0,\n\t\tcurrentNode: null,\n\n\t\thelpers: new Set(),\n\t\tcomponents: new Set(),\n\t\tdirectives: new Set(),\n\n\t\t// 转换插件\n\t\tnodeTransforms: options.nodeTransforms || [],\n\n\t\t// 替换当前节点\n\t\treplaceNode(node: TemplateChildNode) {\n\t\t\tif (!context.parent) {\n\t\t\t\twarn('replaceNode: 没有父节点')\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// 更新父节点的 children\n\t\t\tconst parentChildren = getNodeChildren(context.parent as any)\n\t\t\tif (parentChildren) {\n\t\t\t\tparentChildren[context.childIndex] = node\n\t\t\t}\n\n\t\t\tcontext.currentNode = node\n\t\t},\n\n\t\t// 移除当前节点\n\t\tremoveNode(node?: TemplateChildNode) {\n\t\t\tif (!context.parent) {\n\t\t\t\twarn('removeNode: 没有父节点')\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst parentChildren = getNodeChildren(context.parent as any)\n\t\t\tif (parentChildren) {\n\t\t\t\tconst index = node\n\t\t\t\t\t? parentChildren.indexOf(node)\n\t\t\t\t\t: context.childIndex\n\n\t\t\t\tif (index > -1) {\n\t\t\t\t\tparentChildren.splice(index, 1)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcontext.currentNode = null\n\t\t},\n\n\t\t// 遍历子节点\n\t\ttraverseChildren(parent: TemplateChildNode | RootNode) {\n\t\t\ttraverseChildren(parent, context)\n\t\t},\n\n\t\t// 遍历节点\n\t\ttraverseNode(node: TemplateChildNode | RootNode) {\n\t\t\ttraverseNode(node, context)\n\t\t},\n\n\t\t// 辅助函数\n\t\thelper(name: symbol): symbol {\n\t\t\tcontext.helpers.add(name)\n\t\t\treturn name\n\t\t},\n\n\t\t// 错误处理\n\t\tonError: options.onError\n\t}\n\n\treturn context\n}\n\n/**\n * 执行 AST 转换\n * @param root 根节点\n * @param options 编译选项\n */\nexport function transform(root: RootNode, options: CompilerOptions = {}): void {\n\t// 创建转换上下文\n\tconst context = createTransformContext(root, options)\n\n\t// 遍历根节点\n\ttraverseNode(root, context)\n\n\t// 将 helpers 添加到根节点\n\troot.helpers = new Set([...root.helpers, ...context.helpers])\n\troot.components = new Set([...root.components, ...context.components])\n\troot.directives = new Set([...root.directives, ...context.directives])\n}\n\n/**\n * 遍历 AST 节点\n */\nexport function traverseNode(\n\tnode: TemplateChildNode | RootNode,\n\tcontext: TransformContext\n): void {\n\t// 设置当前节点\n\tcontext.currentNode = node\n\n\t// 获取转换插件\n\tconst { nodeTransforms } = context\n\n\t// 存储退出函数\n\tconst exitFns: (() => void)[] = []\n\n\t// 执行所有转换插件\n\tif (nodeTransforms) {\n\t\tfor (const transform of nodeTransforms) {\n\t\t\tconst onExit = transform(node as TemplateChildNode, context)\n\n\t\t\t// 如果节点被移除,直接返回\n\t\t\tif (!context.currentNode) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// 收集退出函数\n\t\t\tif (onExit) {\n\t\t\t\tif (Array.isArray(onExit)) {\n\t\t\t\t\texitFns.push(...onExit)\n\t\t\t\t} else {\n\t\t\t\t\texitFns.push(onExit)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// 根据节点类型继续遍历子节点\n\tswitch (node.type) {\n\t\tcase NodeTypes.ROOT:\n\t\tcase NodeTypes.ELEMENT:\n\t\tcase NodeTypes.IF:\n\t\tcase NodeTypes.FOR:\n\t\t\ttraverseChildren(node, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.IF_BRANCH:\n\t\t\t// if 分支也需要遍历子节点\n\t\t\ttraverseChildren(node, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.TEXT:\n\t\tcase NodeTypes.INTERPOLATION:\n\t\tcase NodeTypes.SIMPLE_EXPRESSION:\n\t\tcase NodeTypes.COMPOUND_EXPRESSION:\n\t\t\t// 这些节点没有子节点,无需处理\n\t\t\tbreak\n\t}\n\n\t// 逆序执行退出函数\n\tcontext.currentNode = node\n\tlet i = exitFns.length\n\twhile (i--) {\n\t\texitFns[i]()\n\t}\n}\n\n/**\n * 遍历子节点\n */\nexport function traverseChildren(\n\tparent: TemplateChildNode | RootNode,\n\tcontext: TransformContext\n): void {\n\t// 获取子节点\n\tconst children = getNodeChildren(parent as any)\n\n\tif (!children || children.length === 0) {\n\t\treturn\n\t}\n\n\t// 保存父节点\n\tconst parentStack: (TemplateChildNode | RootNode)[] = []\n\tlet currentParent = context.parent\n\n\t// 设置新的父节点\n\tcontext.parent = parent as TemplateChildNode\n\n\t// 遍历子节点\n\tfor (let i = 0; i < children.length; i++) {\n\t\tcontext.childIndex = i\n\t\ttraverseNode(children[i], context)\n\t}\n\n\t// 恢复父节点\n\tcontext.parent = currentParent\n}\n\n/**\n * 创建简单的转换插件\n */\nexport function createTransform(\n\ttypes: NodeTypes[],\n\tfn: TransformFn\n): TransformFn {\n\treturn (node, context) => {\n\t\tif (types.includes(node.type)) {\n\t\t\treturn fn(node, context)\n\t\t}\n\t}\n}","/**\n * if/elif/else 转换插件\n * 将 if 节点转换为三元表达式\n */\n\nimport {\n\tNodeTypes,\n\tIfNode,\n\tIfBranchNode,\n\tTemplateChildNode,\n\tTransformContext,\n\tJSConditionalExpression,\n\tSimpleExpressionNode\n} from '../types'\nimport {\n\tcreateConditionalExpression,\n\tcreateSimpleExpression,\n\tisIfNode\n} from '../ast'\nimport { warn } from '@fluxion-ui/shared'\n\n/**\n * if 转换插件\n *\n * 将:\n * if loading\n * p loading...\n * else\n * p loaded\n *\n * 转换为:\n * loading() ? h(\"p\", \"loading...\") : h(\"p\", \"loaded\")\n */\nexport function transformIf(node: TemplateChildNode, context: TransformContext) {\n\tif (!isIfNode(node)) {\n\t\treturn\n\t}\n\n\t// 处理 if 节点\n\tprocessIf(node, context)\n}\n\n/**\n * 处理 if 节点\n */\nfunction processIf(node: IfNode, context: TransformContext) {\n\tconst { branches } = node\n\n\t// 校验分支\n\tif (branches.length === 0) {\n\t\twarn('transformIf: if 节点没有分支')\n\t\treturn\n\t}\n\n\t// 生成条件表达式\n\tconst codegenNode = createIfCodegen(node, context)\n\n\tif (codegenNode) {\n\t\tnode.codegenNode = codegenNode\n\t}\n}\n\n/**\n * 创建 if 的代码生成节点\n */\nfunction createIfCodegen(\n\tnode: IfNode,\n\tcontext: TransformContext\n): JSConditionalExpression | SimpleExpressionNode | undefined {\n\tconst { branches } = node\n\n\t// 从最后一个分支开始构建\n\tlet currentBranch = branches[branches.length - 1]\n\n\t// 最后一个分支(else 或最后一个 elif)\n\tlet alternate = createBranchCodegen(currentBranch, context)\n\n\t// 从后往前构建三元表达式\n\tfor (let i = branches.length - 2; i >= 0; i--) {\n\t\tconst branch = branches[i]\n\n\t\t// 创建条件表达式\n\t\talternate = createConditionalExpression(\n\t\t\tcreateConditionCodegen(branch, context),\n\t\t\tcreateBranchCodegen(branch, context),\n\t\t\talternate,\n\t\t\ttrue\n\t\t)\n\t}\n\n\treturn alternate as JSConditionalExpression\n}\n\n/**\n * 创建条件表达式的测试部分\n */\nfunction createConditionCodegen(\n\tbranch: IfBranchNode,\n\tcontext: TransformContext\n): SimpleExpressionNode {\n\tif (!branch.condition) {\n\t\t// else 分支不应该有条件\n\t\twarn('transformIf: if 分支缺少条件')\n\t\treturn createSimpleExpression('true', false)\n\t}\n\n\t// 如果条件是简单表达式,需要加上 () 调用(signal)\n\tconst condition = branch.condition\n\n\t// 返回条件表达式\n\t// 注意:signal 变量需要加 () 来获取值\n\t// 这里我们假设条件表达式已经正确处理\n\treturn createSimpleExpression(\n\t\twrapSignalCall(condition.content),\n\t\tfalse\n\t)\n}\n\n/**\n * 创建分支的代码生成节点\n */\nfunction createBranchCodegen(\n\tbranch: IfBranchNode,\n\tcontext: TransformContext\n): SimpleExpressionNode {\n\t// 如果分支只有一个子节点\n\tif (branch.children.length === 1) {\n\t\tconst child = branch.children[0]\n\t\t// 元素节点应该已经有 codegenNode\n\t\tif (child.type === NodeTypes.ELEMENT && (child as any).codegenNode) {\n\t\t\treturn (child as any).codegenNode\n\t\t}\n\t}\n\n\t// 多个子节点或没有 codegenNode,返回一个占位符\n\t// 实际的代码生成会在 codegen 阶段处理\n\treturn createSimpleExpression(\n\t\t`/* branch with ${branch.children.length} children */`,\n\t\tfalse\n\t)\n}\n\n/**\n * 包装 signal 调用\n * 将 count 转换为 count()\n */\nfunction wrapSignalCall(content: string): string {\n\t// 简单的标识符,可能是 signal\n\tif (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(content)) {\n\t\t// 检查是否已经包含函数调用\n\t\tif (!content.includes('(')) {\n\t\t\treturn `${content}()`\n\t\t}\n\t}\n\treturn content\n}\n\n/**\n * 检查节点是否为有效的 if 分支\n */\nexport function isValidIfBranch(node: any): boolean {\n\treturn node?.type === NodeTypes.IF_BRANCH\n}\n\n/**\n * 获取 if 分支的类型\n */\nexport function getIfBranchType(branch: IfBranchNode): 'if' | 'elif' | 'else' {\n\tif (!branch.condition) {\n\t\treturn 'else'\n\t}\n\treturn 'if' // elif 和 if 在 AST 中是一样的,区别在于位置\n}","/**\n * 运行时辅助函数符号\n * 用于在编译时标识需要导入的运行时函数\n */\n\n/**\n * 运行时辅助函数名称映射\n */\nexport const enum RuntimeHelperNames {\n\t// VNode 创建\n\tCREATE_ELEMENT_VNODE = 'h',\n\tCREATE_TEXT_VNODE = 'createTextVNode',\n\tCREATE_COMMENT_VNODE = 'createCommentVNode',\n\n\t// 组件相关\n\tRESOLVE_COMPONENT = 'resolveComponent',\n\tRESOLVE_DIRECTIVE = 'resolveDirective',\n\n\t// 渲染相关\n\tRENDER_LIST = 'renderList',\n\tRENDER_SLOT = 'renderSlot',\n\n\t// 工具函数\n\tMERGE_PROPS = 'mergeProps',\n\tNORMALIZE_CLASS = 'normalizeClass',\n\tNORMALIZE_STYLE = 'normalizeStyle',\n\tNORMALIZE_PROPS = 'normalizeProps',\n\n\t// 事件处理\n\tWITH_DIRECTIVES = 'withDirectives',\n\tWITH_CTX = 'withCtx'\n}\n\n/**\n * 运行时辅助函数符号\n */\nexport const runtimeHelpers = {\n\t// VNode 创建\n\tCREATE_ELEMENT_VNODE: Symbol(RuntimeHelperNames.CREATE_ELEMENT_VNODE),\n\tCREATE_TEXT_VNODE: Symbol(RuntimeHelperNames.CREATE_TEXT_VNODE),\n\tCREATE_COMMENT_VNODE: Symbol(RuntimeHelperNames.CREATE_COMMENT_VNODE),\n\n\t// 组件相关\n\tRESOLVE_COMPONENT: Symbol(RuntimeHelperNames.RESOLVE_COMPONENT),\n\tRESOLVE_DIRECTIVE: Symbol(RuntimeHelperNames.RESOLVE_DIRECTIVE),\n\n\t// 渲染相关\n\tRENDER_LIST: Symbol(RuntimeHelperNames.RENDER_LIST),\n\tRENDER_SLOT: Symbol(RuntimeHelperNames.RENDER_SLOT),\n\n\t// 工具函数\n\tMERGE_PROPS: Symbol(RuntimeHelperNames.MERGE_PROPS),\n\tNORMALIZE_CLASS: Symbol(RuntimeHelperNames.NORMALIZE_CLASS),\n\tNORMALIZE_STYLE: Symbol(RuntimeHelperNames.NORMALIZE_STYLE),\n\tNORMALIZE_PROPS: Symbol(RuntimeHelperNames.NORMALIZE_PROPS),\n\n\t// 事件处理\n\tWITH_DIRECTIVES: Symbol(RuntimeHelperNames.WITH_DIRECTIVES),\n\tWITH_CTX: Symbol(RuntimeHelperNames.WITH_CTX)\n} as const\n\n/**\n * 获取运行时辅助函数名称\n */\nexport function getRuntimeHelperName(symbol: symbol): string {\n\tfor (const [key, value] of Object.entries(runtimeHelpers)) {\n\t\tif (value === symbol) {\n\t\t\treturn RuntimeHelperNames[key as keyof typeof RuntimeHelperNames]\n\t\t}\n\t}\n\treturn ''\n}\n\n/**\n * 判断是否为运行时辅助函数\n */\nexport function isRuntimeHelper(value: unknown): value is symbol {\n\treturn typeof value === 'symbol' && Object.values(runtimeHelpers).includes(value)\n}","/**\n * for 循环转换插件\n * 将 for 节点转换为 map 调用\n */\n\nimport {\n\tNodeTypes,\n\tForNode,\n\tTemplateChildNode,\n\tTransformContext,\n\tJSCallExpression,\n\tJSFunctionExpression,\n\tJSArrayExpression,\n\tSimpleExpressionNode\n} from '../types'\nimport {\n\tcreateCallExpression,\n\tcreateFunctionExpression,\n\tcreateSimpleExpression,\n\tcreateArrayExpression,\n\tisForNode\n} from '../ast'\nimport { runtimeHelpers } from '../runtimeHelpers'\nimport { warn } from '@fluxion-ui/shared'\n\n/**\n * for 转换插件\n *\n * 将:\n * for user in users\n * p {user.name}\n *\n * 转换为:\n * users().map(user => h(\"p\", [user.name]))\n */\nexport function transformFor(node: TemplateChildNode, context: TransformContext) {\n\tif (!isForNode(node)) {\n\t\treturn\n\t}\n\n\t// 处理 for 节点\n\tprocessFor(node, context)\n}\n\n/**\n * 处理 for 节点\n */\nfunction processFor(node: ForNode, context: TransformContext) {\n\tconst { source, valueAlias, keyAlias, indexAlias, children } = node\n\n\t// 校验源表达式\n\tif (!source) {\n\t\twarn('transformFor: for 节点缺少源表达式')\n\t\treturn\n\t}\n\n\t// 添加运行时辅助函数\n\tcontext.helper(runtimeHelpers.CREATE_ELEMENT_VNODE)\n\n\t// 生成代码节点\n\tconst codegenNode = createForCodegen(node, context)\n\n\tif (codegenNode) {\n\t\tnode.codegenNode = codegenNode\n\t}\n}\n\n/**\n * 创建 for 的代码生成节点\n */\nfunction createForCodegen(\n\tnode: ForNode,\n\tcontext: TransformContext\n): JSCallExpression {\n\tconst { source, valueAlias, keyAlias, indexAlias, children } = node\n\n\t// 构建参数列表\n\tconst params: string[] = [valueAlias]\n\tif (keyAlias) {\n\t\tparams.push(keyAlias)\n\t}\n\tif (indexAlias) {\n\t\tparams.push(indexAlias)\n\t}\n\n\t// 创建渲染函数体\n\tlet renderBody: any\n\n\tif (children.length === 1) {\n\t\t// 单个子节点\n\t\tconst child = children[0]\n\t\tif (child.type === NodeTypes.ELEMENT && (child as any).codegenNode) {\n\t\t\trenderBody = (child as any).codegenNode\n\t\t} else {\n\t\t\t// 创建数组包装\n\t\t\trenderBody = createArrayExpression([child as any])\n\t\t}\n\t} else {\n\t\t// 多个子节点,创建数组\n\t\trenderBody = createArrayExpression(\n\t\t\tchildren.map(child => {\n\t\t\t\tif (child.type === NodeTypes.ELEMENT && (child as any).codegenNode) {\n\t\t\t\t\treturn (child as any).codegenNode\n\t\t\t\t}\n\t\t\t\treturn child as any\n\t\t\t})\n\t\t)\n\t}\n\n\t// 创建箭头函数\n\tconst arrowFn = createFunctionExpression(\n\t\tparams,\n\t\trenderBody,\n\t\tfalse, // newline\n\t\tfalse // isSlot\n\t)\n\n\t// 包装源表达式(如果是 signal,需要调用)\n\tconst sourceExpr = wrapSignalCall(source.content)\n\n\t// 创建 map 调用\n\t// source.map(item => ...)\n\tconst mapCall = createCallExpression(\n\t\t`${sourceExpr}.map`,\n\t\t[arrowFn]\n\t)\n\n\treturn mapCall\n}\n\n/**\n * 包装 signal 调用\n * 将 count 转换为 count()\n */\nfunction wrapSignalCall(content: string): string {\n\t// 简单的标识符,可能是 signal\n\tif (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(content)) {\n\t\t// 检查是否已经包含函数调用\n\t\tif (!content.includes('(')) {\n\t\t\treturn `${content}()`\n\t\t}\n\t}\n\treturn content\n}\n\n/**\n * 解析 for 表达式\n * 支持:\n * - for item in list\n * - for (item, index) in list\n * - for (item, key, index) in list\n */\nexport function parseForExpression(\n\tsource: string,\n\tvalueAlias?: string,\n\tkeyAlias?: string,\n\tindexAlias?: string\n): {\n\tsource: string\n\tvalue: string\n\tkey?: string\n\tindex?: string\n} | null {\n\t// 匹配 \"item in list\" 或 \"(item, key, index) in list\"\n\tconst inMatch = source.match(/^\\s*(?:\\(([^)]+)\\)|(\\w+))\\s+in\\s+(.+)$/)\n\n\tif (!inMatch) {\n\t\treturn null\n\t}\n\n\tconst sourceExpr = inMatch[3].trim()\n\n\t// 处理变量\n\tif (inMatch[2]) {\n\t\t// 单变量: for item in list\n\t\treturn {\n\t\t\tsource: sourceExpr,\n\t\t\tvalue: inMatch[2]\n\t\t}\n\t} else {\n\t\t// 多变量: for (item, key, index) in list\n\t\t// 或: for (item, index) in list\n\t\tconst vars = inMatch[1].split(',').map(v => v.trim())\n\t\tconst result: any = {\n\t\t\tsource: sourceExpr,\n\t\t\tvalue: vars[0]\n\t\t}\n\n\t\tif (vars.length === 2) {\n\t\t\t// for (item, index) in list\n\t\t\tresult.index = vars[1]\n\t\t} else if (vars.length >= 3) {\n\t\t\t// for (item, key, index) in list\n\t\t\tresult.key = vars[1]\n\t\t\tresult.index = vars[2]\n\t\t}\n\n\t\treturn result\n\t}\n}\n\n/**\n * 检查节点是否为有效的 for 节点\n */\nexport function isValidForNode(node: any): node is ForNode {\n\treturn isForNode(node) && !!node.source\n}","/**\n * 元素转换插件\n * 将元素节点转换为 h 函数调用\n */\n\nimport {\n\tNodeTypes,\n\tElementNode,\n\tTemplateChildNode,\n\tTransformContext,\n\tJSCallExpression,\n\tJSObjectExpression,\n\tDirectiveNode,\n\tAttributeNode\n} from '../types'\nimport {\n\tcreateCallExpression,\n\tcreateObjectExpression,\n\tcreateSimpleExpression,\n\tcreateArrayExpression,\n\tisElementNode\n} from '../ast'\nimport { runtimeHelpers } from '../runtimeHelpers'\nimport { warn } from '@fluxion-ui/shared'\n\n/**\n * 元素转换插件\n *\n * 将:\n * button @click=increment\n *\n * 转换为:\n * h(\"button\", { onClick: increment })\n */\nexport function transformElement(node: TemplateChildNode, context: TransformContext) {\n\tif (!isElementNode(node)) {\n\t\treturn\n\t}\n\n\t// 返回退出函数,在子节点处理完成后执行\n\treturn () => {\n\t\t// 处理元素节点\n\t\tprocessElement(node, context)\n\t}\n}\n\n/**\n * 处理元素节点\n */\nfunction processElement(node: ElementNode, context: TransformContext) {\n\tconst { tag, props, children, isSelfClosing } = node\n\n\t// 添加运行时辅助函数\n\tcontext.helper(runtimeHelpers.CREATE_ELEMENT_VNODE)\n\n\t// 创建 h 函数调用\n\tconst codegenNode = createElementCodegen(node, context)\n\n\tif (codegenNode) {\n\t\tnode.codegenNode = codegenNode\n\t}\n}\n\n/**\n * 创建元素的代码生成节点\n */\nfunction createElementCodegen(\n\tnode: ElementNode,\n\tcontext: TransformContext\n): JSCallExpression {\n\tconst { tag, props, children } = node\n\n\t// 判断是元素还是组件\n\tconst isComponent = isComponentTag(tag)\n\n\t// 创建参数\n\tconst args: (string | JSCallExpression | JSObjectExpression)[] = []\n\n\t// 第一个参数:标签名或组件\n\tif (isComponent) {\n\t\t// 组件使用变量名\n\t\targs.push(tag)\n\t\tcontext.components.add(tag)\n\t} else {\n\t\t// 元素使用字符串\n\t\targs.push(`\"${tag}\"`)\n\t}\n\n\t// 第二个参数:props 对象\n\tconst propsObj = createPropsObject(props, context)\n\tif (propsObj || children.length > 0) {\n\t\tif (propsObj) {\n\t\t\targs.push(propsObj)\n\t\t} else {\n\t\t\targs.push('null' as any)\n\t\t}\n\t}\n\n\t// 第三个参数:children\n\tif (children.length > 0) {\n\t\tconst childrenArg = createChildrenArg(children, context)\n\t\targs.push(childrenArg as any)\n\t}\n\n\t// 创建 h 函数调用\n\treturn createCallExpression(\n\t\truntimeHelpers.CREATE_ELEMENT_VNODE,\n\t\targs\n\t)\n}\n\n/**\n * 创建 props 对象\n */\nfunction createPropsObject(\n\tprops: Array<AttributeNode | DirectiveNode>,\n\tcontext: TransformContext\n): JSObjectExpression | null {\n\tif (props.length === 0) {\n\t\treturn null\n\t}\n\n\tconst properties: Array<{ key: string; value: any }> = []\n\n\tfor (const prop of props) {\n\t\tif (prop.type === NodeTypes.ATTRIBUTE) {\n\t\t\t// 普通属性\n\t\t\tproperties.push({\n\t\t\t\tkey: prop.name,\n\t\t\t\tvalue: prop.value ? `\"${prop.value.content}\"` : 'true'\n\t\t\t})\n\t\t} else if (prop.type === NodeTypes.DIRECTIVE) {\n\t\t\t// 指令\n\t\t\tconst directiveProp = processDirective(prop, context)\n\t\t\tif (directiveProp) {\n\t\t\t\tproperties.push(directiveProp)\n\t\t\t}\n\t\t}\n\t}\n\n\tif (properties.length === 0) {\n\t\treturn null\n\t}\n\n\treturn createObjectExpression(properties)\n}\n\n/**\n * 处理指令\n */\nfunction processDirective(\n\tdirective: DirectiveNode,\n\tcontext: TransformContext\n): { key: string; value: any } | null {\n\tconst { name, exp, arg, modifiers } = directive\n\n\tswitch (name) {\n\t\tcase 'click':\n\t\tcase 'mousedown':\n\t\tcase 'mouseup':\n\t\tcase 'mouseenter':\n\t\tcase 'mouseleave':\n\t\tcase 'keydown':\n\t\tcase 'keyup':\n\t\tcase 'submit':\n\t\tcase 'input':\n\t\tcase 'change':\n\t\t\t// 事件处理\n\t\t\treturn {\n\t\t\t\tkey: `on${capitalize(name)}`,\n\t\t\t\tvalue: exp ? exp.content : '() => {}'\n\t\t\t}\n\n\t\tcase 'bind':\n\t\t\t// 动态绑定\n\t\t\tif (arg) {\n\t\t\t\treturn {\n\t\t\t\t\tkey: arg.content,\n\t\t\t\t\tvalue: wrapSignalCall(exp?.content || '')\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null\n\n\t\tcase 'model':\n\t\t\t// 双向绑定\n\t\t\t// TODO: 实现 model 指令\n\t\t\treturn null\n\n\t\tdefault:\n\t\t\t// 未知指令,作为事件处理\n\t\t\treturn {\n\t\t\t\tkey: `on${capitalize(name)}`,\n\t\t\t\tvalue: exp ? exp.content : '() => {}'\n\t\t\t}\n\t}\n}\n\n/**\n * 创建 children 参数\n */\nfunction createChildrenArg(\n\tchildren: TemplateChildNode[],\n\tcontext: TransformContext\n): JSCallExpression | any {\n\tif (children.length === 0) {\n\t\treturn null\n\t}\n\n\t// 单个文本节点\n\tif (children.length === 1) {\n\t\tconst child = children[0]\n\t\tif (child.type === NodeTypes.TEXT) {\n\t\t\treturn `\"${child.content}\"`\n\t\t}\n\t\tif (child.type === NodeTypes.INTERPOLATION) {\n\t\t\treturn wrapSignalCall((child.content as any).content)\n\t\t}\n\t\t// 元素节点使用其 codegenNode\n\t\tif (child.type === NodeTypes.ELEMENT && (child as any).codegenNode) {\n\t\t\treturn (child as any).codegenNode\n\t\t}\n\t}\n\n\t// 多个子节点,创建数组\n\tconst elements: any[] = []\n\tfor (const child of children) {\n\t\tif (child.type === NodeTypes.TEXT) {\n\t\t\telements.push(`\"${child.content}\"`)\n\t\t} else if (child.type === NodeTypes.INTERPOLATION) {\n\t\t\telements.push(wrapSignalCall((child.content as any).content))\n\t\t} else if (child.type === NodeTypes.ELEMENT) {\n\t\t\tif ((child as any).codegenNode) {\n\t\t\t\telements.push((child as any).codegenNode)\n\t\t\t}\n\t\t} else if (child.type === NodeTypes.IF) {\n\t\t\tif ((child as any).codegenNode) {\n\t\t\t\telements.push((child as any).codegenNode)\n\t\t\t}\n\t\t} else if (child.type === NodeTypes.FOR) {\n\t\t\tif ((child as any).codegenNode) {\n\t\t\t\telements.push((child as any).codegenNode)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn createArrayExpression(elements)\n}\n\n/**\n * 判断是否为组件标签\n */\nfunction isComponentTag(tag: string): boolean {\n\t// 组件标签以大写字母开头或包含连字符\n\treturn /^[A-Z]/.test(tag) || tag.includes('-')\n}\n\n/**\n * 首字母大写\n */\nfunction capitalize(str: string): string {\n\treturn str.charAt(0).toUpperCase() + str.slice(1)\n}\n\n/**\n * 包装 signal 调用\n */\nfunction wrapSignalCall(content: string): string {\n\tif (!content) return ''\n\t// 简单的标识符,可能是 signal\n\tif (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(content)) {\n\t\tif (!content.includes('(')) {\n\t\t\treturn `${content}()`\n\t\t}\n\t}\n\treturn content\n}","/**\n * 文本插值转换插件\n * 处理文本节点和插值表达式\n */\n\nimport {\n\tNodeTypes,\n\tTextNode,\n\tInterpolationNode,\n\tTemplateChildNode,\n\tTransformContext,\n\tCompoundExpressionNode,\n\tElementNode\n} from '../types'\nimport {\n\tcreateCompoundExpression,\n\tcreateSimpleExpression,\n\tisTextNode,\n\tisInterpolationNode,\n\tisElementNode\n} from '../ast'\nimport { warn } from '@fluxion-ui/shared'\n\n/**\n * 文本转换插件\n *\n * 处理文本和插值的混合情况:\n * - 纯文本:直接使用\n * - 插值表达式:包装 signal 调用\n * - 混合文本:创建复合表达式\n */\nexport function transformText(node: TemplateChildNode, context: TransformContext) {\n\t// 只处理元素节点\n\tif (!isElementNode(node)) {\n\t\treturn\n\t}\n\n\t// 返回退出函数,在子节点处理完成后执行\n\treturn () => {\n\t\tprocessText(node, context)\n\t}\n}\n\n/**\n * 处理元素中的文本\n */\nfunction processText(node: ElementNode, context: TransformContext) {\n\tconst { children } = node\n\n\t// 遍历子节点,合并相邻的文本和插值\n\tlet hasText = false\n\tlet currentContainer: CompoundExpressionNode | null = null\n\n\tfor (let i = 0; i < children.length; i++) {\n\t\tconst child = children[i]\n\n\t\tif (isTextNode(child) || isInterpolationNode(child)) {\n\t\t\thasText = true\n\n\t\t\t// 如果前一个节点也是文本或插值,合并到复合表达式\n\t\t\tif (currentContainer) {\n\t\t\t\t// 添加到复合表达式\n\t\t\t\tif (isTextNode(child)) {\n\t\t\t\t\t// 文本节点\n\t\t\t\t\tcurrentContainer.children.push(child.content)\n\t\t\t\t} else {\n\t\t\t\t\t// 插值节点,包装 signal 调用\n\t\t\t\t\tconst content = (child.content as any).content\n\t\t\t\t\tcurrentContainer.children.push(\n\t\t\t\t\t\tcreateSimpleExpression(wrapSignalCall(content), false)\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\t// 移除当前节点(已合并)\n\t\t\t\tchildren.splice(i, 1)\n\t\t\t\ti--\n\t\t\t} else {\n\t\t\t\t// 创建新的复合表达式\n\t\t\t\tif (isTextNode(child)) {\n\t\t\t\t\t// 检查下一个节点是否也是文本/插值\n\t\t\t\t\tconst next = children[i + 1]\n\t\t\t\t\tif (next && (isTextNode(next) || isInterpolationNode(next))) {\n\t\t\t\t\t\t// 创建复合表达式\n\t\t\t\t\t\tcurrentContainer = createCompoundExpression([child.content])\n\t\t\t\t\t\t// 替换当前节点\n\t\t\t\t\t\tchildren[i] = currentContainer as any\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// 插值节点\n\t\t\t\t\tconst content = (child.content as any).content\n\t\t\t\t\tconst next = children[i + 1]\n\t\t\t\t\tif (next && (isTextNode(next) || isInterpolationNode(next))) {\n\t\t\t\t\t\t// 创建复合表达式\n\t\t\t\t\t\tcurrentContainer = createCompoundExpression([\n\t\t\t\t\t\t\tcreateSimpleExpression(wrapSignalCall(content), false)\n\t\t\t\t\t\t])\n\t\t\t\t\t\t// 替换当前节点\n\t\t\t\t\t\tchildren[i] = currentContainer as any\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// 单独的插值,直接包装\n\t\t\t\t\t\t;(child as any).content = createSimpleExpression(\n\t\t\t\t\t\t\twrapSignalCall(content),\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// 非文本节点,重置容器\n\t\t\tcurrentContainer = null\n\t\t}\n\t}\n\n\t// 如果没有文本节点,不需要处理\n\tif (!hasText) {\n\t\treturn\n\t}\n}\n\n/**\n * 包装 signal 调用\n * 将 count 转换为 count()\n */\nfunction wrapSignalCall(content: string): string {\n\tif (!content) return ''\n\t// 简单的标识符,可能是 signal\n\tif (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(content)) {\n\t\tif (!content.includes('(')) {\n\t\t\treturn `${content}()`\n\t\t}\n\t}\n\treturn content\n}\n\n/**\n * 检查节点是否包含文本\n */\nexport function hasTextChildren(node: ElementNode): boolean {\n\treturn node.children.some(\n\t\tchild => isTextNode(child) || isInterpolationNode(child)\n\t)\n}\n\n/**\n * 规范化文本内容\n */\nexport function normalizeTextContent(node: ElementNode): string {\n\tconst parts: string[] = []\n\n\tfor (const child of node.children) {\n\t\tif (isTextNode(child)) {\n\t\t\tparts.push(child.content)\n\t\t} else if (isInterpolationNode(child)) {\n\t\t\tparts.push(`{${(child.content as any).content}}`)\n\t\t}\n\t}\n\n\treturn parts.join('')\n}","/**\n * 代码生成核心\n * 将 AST 转换为 JavaScript 代码\n */\n\nimport {\n\tNodeTypes,\n\tRootNode,\n\tTemplateChildNode,\n\tCodegenResult,\n\tJSChildNode,\n\tJSCallExpression,\n\tJSObjectExpression,\n\tJSArrayExpression,\n\tJSFunctionExpression,\n\tJSConditionalExpression,\n\tSimpleExpressionNode,\n\tCompoundExpressionNode,\n\tElementNode,\n\tTextNode,\n\tInterpolationNode,\n\tIfNode,\n\tForNode\n} from '../types'\nimport { isRuntimeHelper, runtimeHelpers, getRuntimeHelperName } from '../runtimeHelpers'\nimport { warn } from '@fluxion-ui/shared'\n\n// ==================== 代码生成上下文 ====================\n\n/**\n * 代码生成上下文\n */\ninterface CodegenContext {\n\t// 生成的代码\n\tcode: string\n\n\t// 缩进级别\n\tindentLevel: number\n\n\t// 缩进字符串\n\tindent: (level?: number) => string\n\n\t// 换行\n\tnewline: () => string\n\n\t// 推送代码\n\tpush: (code: string) => void\n\n\t// 缩进\n\tindentCode: () => void\n\n\t// 取消缩进\n\tdeindent: () => void\n}\n\n/**\n * 创建代码生成上下文\n */\nfunction createCodegenContext(): CodegenContext {\n\tconst context: CodegenContext = {\n\t\tcode: '',\n\t\tindentLevel: 0,\n\n\t\tindent(level: number = context.indentLevel) {\n\t\t\treturn ' '.repeat(level)\n\t\t},\n\n\t\tnewline() {\n\t\t\treturn '\\n'\n\t\t},\n\n\t\tpush(code: string) {\n\t\t\tcontext.code += code\n\t\t},\n\n\t\tindentCode() {\n\t\t\tcontext.indentLevel++\n\t\t},\n\n\t\tdeindent() {\n\t\t\tcontext.indentLevel--\n\t\t}\n\t}\n\n\treturn context\n}\n\n// ==================== 代码生成入口 ====================\n\n/**\n * 生成代码\n */\nexport function generate(ast: RootNode): CodegenResult {\n\tconst context = createCodegenContext()\n\n\t// 生成前导代码(导入等)\n\tgenFunctionPreamble(ast, context)\n\n\t// 生成 render 函数\n\tgenRenderFunction(ast, context)\n\n\treturn {\n\t\tcode: context.code,\n\t\tast,\n\t\tpreamble: ''\n\t}\n}\n\n/**\n * 生成函数前导代码(导入语句)\n */\nfunction genFunctionPreamble(ast: RootNode, context: CodegenContext) {\n\t// 如果有帮助函数,生成导入语句\n\tif (ast.helpers.size > 0) {\n\t\t// 收集需要的运行时函数\n\t\tconst imports: string[] = []\n\n\t\tfor (const helper of ast.helpers) {\n\t\t\tconst name = getRuntimeHelperName(helper)\n\t\t\tif (name && !imports.includes(name)) {\n\t\t\t\timports.push(name)\n\t\t\t}\n\t\t}\n\n\t\tif (imports.length > 0) {\n\t\t\tcontext.push(`import { ${imports.join(', ')} } from '@fluxion-ui/fluxion/runtime'\\n`)\n\t\t}\n\t}\n\n\t// 添加空行\n\tcontext.push('\\n')\n}\n\n/**\n * 生成 render 函数\n */\nfunction genRenderFunction(ast: RootNode, context: CodegenContext) {\n\tcontext.push('export function render() {\\n')\n\tcontext.indentCode()\n\n\tcontext.push(context.indent())\n\tcontext.push('return ')\n\n\t// 生成根节点的子节点\n\tif (ast.children.length === 1) {\n\t\t// 单个子节点\n\t\tgenNode(ast.children[0], context)\n\t} else if (ast.children.length > 1) {\n\t\t// 多个子节点,生成数组\n\t\tcontext.push('[\\n')\n\t\tcontext.indentCode()\n\n\t\tfor (let i = 0; i < ast.children.length; i++) {\n\t\t\tcontext.push(context.indent())\n\t\t\tgenNode(ast.children[i], context)\n\n\t\t\tif (i < ast.children.length - 1) {\n\t\t\t\tcontext.push(',')\n\t\t\t}\n\t\t\tcontext.push('\\n')\n\t\t}\n\n\t\tcontext.deindent()\n\t\tcontext.push(context.indent())\n\t\tcontext.push(']')\n\t} else {\n\t\t// 空节点\n\t\tcontext.push('null')\n\t}\n\n\tcontext.push('\\n')\n\tcontext.deindent()\n\tcontext.push('}\\n')\n}\n\n// ==================== 节点代码生成 ====================\n\n/**\n * 生成节点代码\n */\nfunction genNode(node: TemplateChildNode | JSChildNode, context: CodegenContext) {\n\tswitch (node.type) {\n\t\tcase NodeTypes.ELEMENT:\n\t\t\tgenElementNode(node as ElementNode, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.TEXT:\n\t\t\tgenTextNode(node as TextNode, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.INTERPOLATION:\n\t\t\tgenInterpolationNode(node as InterpolationNode, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.IF:\n\t\t\tgenIfNode(node as IfNode, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.FOR:\n\t\t\tgenForNode(node as ForNode, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.SIMPLE_EXPRESSION:\n\t\t\tgenSimpleExpression(node as SimpleExpressionNode, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.COMPOUND_EXPRESSION:\n\t\t\tgenCompoundExpression(node as CompoundExpressionNode, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.JS_CALL_EXPRESSION:\n\t\t\tgenCallExpression(node as JSCallExpression, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.JS_OBJECT_EXPRESSION:\n\t\t\tgenObjectExpression(node as JSObjectExpression, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.JS_ARRAY_EXPRESSION:\n\t\t\tgenArrayExpression(node as JSArrayExpression, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.JS_FUNCTION_EXPRESSION:\n\t\t\tgenFunctionExpression(node as JSFunctionExpression, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.JS_CONDITIONAL_EXPRESSION:\n\t\t\tgenConditionalExpression(node as JSConditionalExpression, context)\n\t\t\tbreak\n\n\t\tdefault:\n\t\t\twarn(`genNode: 未知的节点类型 ${node.type}`)\n\t}\n}\n\n/**\n * 生成元素节点代码\n */\nfunction genElementNode(node: ElementNode, context: CodegenContext) {\n\tif (node.codegenNode) {\n\t\t// 有代码生成节点,直接使用\n\t\tgenNode(node.codegenNode, context)\n\t} else {\n\t\t// 没有代码生成节点,生成默认的 h 调用\n\t\tcontext.push(`h(\"${node.tag}\"`)\n\n\t\tif (node.props.length > 0) {\n\t\t\tcontext.push(', ')\n\t\t\tgenProps(node.props, context)\n\t\t}\n\n\t\tif (node.children.length > 0) {\n\t\t\tcontext.push(', ')\n\t\t\tif (node.children.length === 1) {\n\t\t\t\tgenNode(node.children[0], context)\n\t\t\t} else {\n\t\t\t\tcontext.push('[')\n\t\t\t\tfor (let i = 0; i < node.children.length; i++) {\n\t\t\t\t\tgenNode(node.children[i], context)\n\t\t\t\t\tif (i < node.children.length - 1) {\n\t\t\t\t\t\tcontext.push(', ')\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontext.push(']')\n\t\t\t}\n\t\t}\n\n\t\tcontext.push(')')\n\t}\n}\n\n/**\n * 生成文本节点代码\n */\nfunction genTextNode(node: TextNode, context: CodegenContext) {\n\tcontext.push(`\"${node.content}\"`)\n}\n\n/**\n * 生成插值节点代码\n */\nfunction genInterpolationNode(node: InterpolationNode, context: CodegenContext) {\n\t// 获取插值内容\n\tconst content = (node.content as SimpleExpressionNode).content\n\tcontext.push(content)\n}\n\n/**\n * 生成 if 节点代码\n */\nfunction genIfNode(node: IfNode, context: CodegenContext) {\n\tif (node.codegenNode) {\n\t\tgenNode(node.codegenNode, context)\n\t} else {\n\t\twarn('genIfNode: if 节点缺少 codegenNode')\n\t}\n}\n\n/**\n * 生成 for 节点代码\n */\nfunction genForNode(node: ForNode, context: CodegenContext) {\n\tif (node.codegenNode) {\n\t\tgenNode(node.codegenNode, context)\n\t} else {\n\t\twarn('genForNode: for 节点缺少 codegenNode')\n\t}\n}\n\n/**\n * 生成简单表达式代码\n */\nfunction genSimpleExpression(node: SimpleExpressionNode, context: CodegenContext) {\n\tcontext.push(node.content)\n}\n\n/**\n * 生成复合表达式代码\n */\nfunction genCompoundExpression(node: CompoundExpressionNode, context: CodegenContext) {\n\tfor (const child of node.children) {\n\t\tif (typeof child === 'string') {\n\t\t\tcontext.push(child)\n\t\t} else {\n\t\t\tgenNode(child as any, context)\n\t\t}\n\t}\n}\n\n/**\n * 生成函数调用表达式代码\n */\nfunction genCallExpression(node: JSCallExpression, context: CodegenContext) {\n\t// 生成调用者\n\tif (typeof node.callee === 'symbol') {\n\t\tcontext.push(getRuntimeHelperName(node.callee) || 'h')\n\t} else {\n\t\tcontext.push(node.callee)\n\t}\n\n\tcontext.push('(')\n\n\t// 生成参数\n\tfor (let i = 0; i < node.arguments.length; i++) {\n\t\tconst arg = node.arguments[i]\n\n\t\tif (typeof arg === 'string') {\n\t\t\tcontext.push(arg)\n\t\t} else {\n\t\t\tgenNode(arg, context)\n\t\t}\n\n\t\tif (i < node.arguments.length - 1) {\n\t\t\tcontext.push(', ')\n\t\t}\n\t}\n\n\tcontext.push(')')\n}\n\n/**\n * 生成对象表达式代码\n */\nfunction genObjectExpression(node: JSObjectExpression, context: CodegenContext) {\n\tif (node.properties.length === 0) {\n\t\tcontext.push('{}')\n\t\treturn\n\t}\n\n\tcontext.push('{\\n')\n\tcontext.indentCode()\n\n\tfor (let i = 0; i < node.properties.length; i++) {\n\t\tconst prop = node.properties[i] as any\n\t\tcontext.push(context.indent())\n\n\t\t// key\n\t\tif (typeof prop.key === 'string') {\n\t\t\tcontext.push(prop.key)\n\t\t} else {\n\t\t\tgenNode(prop.key, context)\n\t\t}\n\n\t\tcontext.push(': ')\n\n\t\t// value\n\t\tif (typeof prop.value === 'string') {\n\t\t\tcontext.push(prop.value)\n\t\t} else {\n\t\t\tgenNode(prop.value, context)\n\t\t}\n\n\t\tif (i < node.properties.length - 1) {\n\t\t\tcontext.push(',')\n\t\t}\n\t\tcontext.push('\\n')\n\t}\n\n\tcontext.deindent()\n\tcontext.push(context.indent())\n\tcontext.push('}')\n}\n\n/**\n * 生成数组表达式代码\n */\nfunction genArrayExpression(node: JSArrayExpression, context: CodegenContext) {\n\tif (node.elements.length === 0) {\n\t\tcontext.push('[]')\n\t\treturn\n\t}\n\n\tcontext.push('[\\n')\n\tcontext.indentCode()\n\n\tfor (let i = 0; i < node.elements.length; i++) {\n\t\tconst element = node.elements[i]\n\n\t\tcontext.push(context.indent())\n\n\t\tif (element === null) {\n\t\t\tcontext.push('null')\n\t\t} else if (typeof element === 'string') {\n\t\t\tcontext.push(element)\n\t\t} else {\n\t\t\tgenNode(element, context)\n\t\t}\n\n\t\tif (i < node.elements.length - 1) {\n\t\t\tcontext.push(',')\n\t\t}\n\t\tcontext.push('\\n')\n\t}\n\n\tcontext.deindent()\n\tcontext.push(context.indent())\n\tcontext.push(']')\n}\n\n/**\n * 生成函数表达式代码\n */\nfunction genFunctionExpression(node: JSFunctionExpression, context: CodegenContext) {\n\tcontext.push('(')\n\n\t// 参数\n\tconst params = node.params as string[]\n\tfor (let i = 0; i < params.length; i++) {\n\t\tcontext.push(params[i])\n\t\tif (i < params.length - 1) {\n\t\t\tcontext.push(', ')\n\t\t}\n\t}\n\n\tcontext.push(') => ')\n\n\t// 返回值\n\tif (node.returns) {\n\t\tif (node.newline) {\n\t\t\tcontext.push('{\\n')\n\t\t\tcontext.indentCode()\n\t\t\tcontext.push(context.indent())\n\t\t\tcontext.push('return ')\n\t\t\tgenNode(node.returns, context)\n\t\t\tcontext.push('\\n')\n\t\t\tcontext.deindent()\n\t\t\tcontext.push(context.indent())\n\t\t\tcontext.push('}')\n\t\t} else {\n\t\t\tgenNode(node.returns, context)\n\t\t}\n\t} else if (node.body) {\n\t\tgenNode(node.body, context)\n\t}\n}\n\n/**\n * 生成条件表达式代码\n */\nfunction genConditionalExpression(node: JSConditionalExpression, context: CodegenContext) {\n\t// test\n\tgenNode(node.test, context)\n\tcontext.push(' ? ')\n\n\t// consequent\n\tgenNode(node.consequent, context)\n\tcontext.push(' : ')\n\n\t// alternate\n\tgenNode(node.alternate, context)\n}\n\n// ==================== 辅助函数 ====================\n\n/**\n * 生成 props 代码\n */\nfunction genProps(props: any[], context: CodegenContext) {\n\tcontext.push('{')\n\n\tfor (let i = 0; i < props.length; i++) {\n\t\tconst prop = props[i]\n\t\tcontext.push(`${prop.name}: ${prop.value ? `\"${prop.value.content}\"` : 'true'}`)\n\n\t\tif (i < props.length - 1) {\n\t\t\tcontext.push(', ')\n\t\t}\n\t}\n\n\tcontext.push('}')\n}","/**\n * 转换插件统一导出\n */\n\nexport { transformIf, isValidIfBranch, getIfBranchType } from './vIf'\nexport { transformFor, isValidForNode, parseForExpression } from './vFor'\nexport { transformElement } from './transformElement'\nexport { transformText, hasTextChildren, normalizeTextContent } from './transformText'\n\n// 默认转换插件集合\nimport { TransformFn } from '../types'\nimport { transformIf } from './vIf'\nimport { transformFor } from './vFor'\nimport { transformElement } from './transformElement'\nimport { transformText } from './transformText'\n\n/**\n * 获取默认的节点转换插件\n */\nexport function getDefaultTransforms(): TransformFn[] {\n\treturn [\n\t\ttransformIf,\n\t\ttransformFor,\n\t\ttransformElement,\n\t\ttransformText\n\t]\n}"],"names":["NodeTypes","ElementTypes","ErrorCodes","defaultPosition","offset","line","column","defaultLoc","start","end","source","createTextNode","content","loc","type","TEXT","createSimpleExpression","isStatic","identifiers","SIMPLE_EXPRESSION","createCompoundExpression","children","COMPOUND_EXPRESSION","createCallExpression","callee","args","JS_CALL_EXPRESSION","arguments","createObjectExpression","properties","JS_OBJECT_EXPRESSION","createArrayExpression","elements","JS_ARRAY_EXPRESSION","createFunctionExpression","params","returns","newline","isSlot","JS_FUNCTION_EXPRESSION","createConditionalExpression","test","consequent","alternate","JS_CONDITIONAL_EXPRESSION","isElementNode","node","ELEMENT","isTextNode","isInterpolationNode","INTERPOLATION","isIfNode","IF","isForNode","FOR","getNodeChildren","ROOT","IF_BRANCH","branches","createTransformContext","root","options","context","parent","childIndex","currentNode","helpers","Set","components","directives","nodeTransforms","replaceNode","warn","parentChildren","removeNode","index","indexOf","splice","traverseChildren","traverseNode","helper","name","add","onError","exitFns","transform","onExit","Array","isArray","push","i","length","currentParent","transformIf","codegenNode","currentBranch","createBranchCodegen","branch","createConditionCodegen","createIfCodegen","processIf","condition","includes","wrapSignalCall","child","RuntimeHelperNames","runtimeHelpers","CREATE_ELEMENT_VNODE","Symbol","CREATE_TEXT_VNODE","CREATE_COMMENT_VNODE","RESOLVE_COMPONENT","RESOLVE_DIRECTIVE","RENDER_LIST","RENDER_SLOT","MERGE_PROPS","NORMALIZE_CLASS","NORMALIZE_STYLE","NORMALIZE_PROPS","WITH_DIRECTIVES","WITH_CTX","getRuntimeHelperName","symbol","key","value","Object","entries","transformFor","valueAlias","keyAlias","indexAlias","renderBody","map","arrowFn","sourceExpr","createForCodegen","processFor","transformElement","tag","props","isComponent","isComponentTag","propsObj","prop","ATTRIBUTE","DIRECTIVE","directiveProp","processDirective","createPropsObject","childrenArg","createChildrenArg","createElementCodegen","processElement","directive","exp","arg","capitalize","str","charAt","toUpperCase","slice","transformText","hasText","currentContainer","next","processText","genNode","genProps","genElementNode","genTextNode","genInterpolationNode","genIfNode","genForNode","genSimpleExpression","genCompoundExpression","genCallExpression","indentCode","indent","deindent","genObjectExpression","element","genArrayExpression","body","genFunctionExpression","genConditionalExpression","cloned","valueNode","modifiers","expNode","argNode","isSelfClosing","expression","imports","types","fn","ast","code","indentLevel","level","repeat","createCodegenContext","size","join","genFunctionPreamble","genRenderFunction","preamble","some","values","parts","inMatch","match","trim","vars","split","v","result"],"mappings":"iDAUkBA,GAAAA,IACjBA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,QAAA,GAAA,UACAA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,cAAA,GAAA,gBACAA,EAAAA,EAAA,UAAA,GAAA,YACAA,EAAAA,EAAA,UAAA,GAAA,YACAA,EAAAA,EAAA,GAAA,GAAA,KACAA,EAAAA,EAAA,UAAA,GAAA,YACAA,EAAAA,EAAA,IAAA,GAAA,MACAA,EAAAA,EAAA,kBAAA,GAAA,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nB,6BFLO,SACNhM,EACAsH,EACAC,EACAC,GAQA,MAAM+E,EAAUvM,EAAOwM,MAAM,0CAE7B,IAAKD,EACJ,OAAO,KAGR,MAAM3E,EAAa2E,EAAQ,GAAGE,OAG9B,GAAIF,EAAQ,GAEX,MAAO,CACNvM,OAAQ4H,EACRV,MAAOqF,EAAQ,IAEV,CAGN,MAAMG,EAAOH,EAAQ,GAAGI,MAAM,KAAKjF,IAAIkF,GAAKA,EAAEH,QACxCI,EAAc,CACnB7M,OAAQ4H,EACRV,MAAOwF,EAAK,IAYb,OAToB,IAAhBA,EAAKzH,OAER4H,EAAO5I,MAAQyI,EAAK,GACVA,EAAKzH,QAAU,IAEzB4H,EAAO5F,IAAMyF,EAAK,GAClBG,EAAO5I,MAAQyI,EAAK,IAGdG,CACR,CACD,6CHjGO,SAAmB3J,EAAgBC,EAA2B,IAEpE,MAAMC,EAAUH,EAAuBC,EAAMC,GAG7CkB,EAAanB,EAAME,GAGnBF,EAAKM,QAAU,IAAIC,IAAI,IAAIP,EAAKM,WAAYJ,EAAQI,UACpDN,EAAKQ,WAAa,IAAID,IAAI,IAAIP,EAAKQ,cAAeN,EAAQM,aAC1DR,EAAKS,WAAa,IAAIF,IAAI,IAAIP,EAAKS,cAAeP,EAAQO,YAC3D"}
@@ -0,0 +1,631 @@
1
+ /**
2
+ * compiler-core 核心类型定义
3
+ * 定义 AST 节点类型、转换上下文、编译选项等
4
+ */
5
+ /**
6
+ * AST 节点类型枚举
7
+ */
8
+ declare const enum NodeTypes {
9
+ ROOT = 0,// 根节点
10
+ ELEMENT = 1,// 元素节点
11
+ TEXT = 2,// 文本节点
12
+ INTERPOLATION = 3,// 插值表达式 {count}
13
+ ATTRIBUTE = 4,// 属性
14
+ DIRECTIVE = 5,// 指令 @click
15
+ IF = 6,// if 条件
16
+ IF_BRANCH = 7,// if 分支
17
+ FOR = 8,// for 循环
18
+ SIMPLE_EXPRESSION = 9,// 简单表达式
19
+ COMPOUND_EXPRESSION = 10,// 复合表达式
20
+ JS_CALL_EXPRESSION = 11,// JS 函数调用
21
+ JS_OBJECT_EXPRESSION = 12,// JS 对象表达式
22
+ JS_ARRAY_EXPRESSION = 13,// JS 数组表达式
23
+ JS_FUNCTION_EXPRESSION = 14,// JS 函数表达式
24
+ JS_CONDITIONAL_EXPRESSION = 15
25
+ }
26
+ /**
27
+ * AST 节点基础接口
28
+ */
29
+ interface BaseNode$1 {
30
+ type: NodeTypes;
31
+ loc?: SourceLocation;
32
+ }
33
+ /**
34
+ * 源码位置信息
35
+ */
36
+ interface SourceLocation {
37
+ start: Position;
38
+ end: Position;
39
+ source: string;
40
+ }
41
+ /**
42
+ * 位置信息
43
+ */
44
+ interface Position {
45
+ offset: number;
46
+ line: number;
47
+ column: number;
48
+ }
49
+ /**
50
+ * 表达式节点基类
51
+ */
52
+ interface ExpressionNode$1 extends BaseNode$1 {
53
+ content: string;
54
+ isStatic?: boolean;
55
+ }
56
+ /**
57
+ * 简单表达式节点
58
+ */
59
+ interface SimpleExpressionNode extends ExpressionNode$1 {
60
+ type: NodeTypes.SIMPLE_EXPRESSION;
61
+ isStatic: boolean;
62
+ identifiers?: string[];
63
+ }
64
+ /**
65
+ * 复合表达式节点
66
+ */
67
+ interface CompoundExpressionNode extends BaseNode$1 {
68
+ type: NodeTypes.COMPOUND_EXPRESSION;
69
+ children: (SimpleExpressionNode | CompoundExpressionNode | InterpolationNode | TextNode | string)[];
70
+ identifiers?: string[];
71
+ }
72
+ /**
73
+ * 模板子节点类型
74
+ */
75
+ type TemplateChildNode = ElementNode | TextNode | InterpolationNode | IfNode | ForNode;
76
+ /**
77
+ * 文本节点
78
+ */
79
+ interface TextNode extends BaseNode$1 {
80
+ type: NodeTypes.TEXT;
81
+ content: string;
82
+ }
83
+ /**
84
+ * 插值节点 {count}
85
+ */
86
+ interface InterpolationNode extends BaseNode$1 {
87
+ type: NodeTypes.INTERPOLATION;
88
+ content: ExpressionNode$1;
89
+ }
90
+ /**
91
+ * 元素节点
92
+ */
93
+ interface ElementNode extends BaseNode$1 {
94
+ type: NodeTypes.ELEMENT;
95
+ tag: string;
96
+ props: Array<AttributeNode | DirectiveNode>;
97
+ children: TemplateChildNode[];
98
+ isSelfClosing: boolean;
99
+ codegenNode?: CodegenNode;
100
+ tagType?: ElementTypes;
101
+ }
102
+ /**
103
+ * 元素类型
104
+ */
105
+ declare const enum ElementTypes {
106
+ ELEMENT = 0,// 普通元素
107
+ COMPONENT = 1
108
+ }
109
+ /**
110
+ * 属性节点
111
+ */
112
+ interface AttributeNode extends BaseNode$1 {
113
+ type: NodeTypes.ATTRIBUTE;
114
+ name: string;
115
+ value: TextNode | null;
116
+ }
117
+ /**
118
+ * 指令节点
119
+ */
120
+ interface DirectiveNode extends BaseNode$1 {
121
+ type: NodeTypes.DIRECTIVE;
122
+ name: string;
123
+ exp: ExpressionNode$1 | null;
124
+ arg: ExpressionNode$1 | null;
125
+ modifiers: string[];
126
+ }
127
+ /**
128
+ * if 节点
129
+ */
130
+ interface IfNode extends BaseNode$1 {
131
+ type: NodeTypes.IF;
132
+ branches: IfBranchNode[];
133
+ codegenNode?: CodegenNode;
134
+ }
135
+ /**
136
+ * if 分支节点
137
+ */
138
+ interface IfBranchNode extends BaseNode$1 {
139
+ type: NodeTypes.IF_BRANCH;
140
+ condition?: ExpressionNode$1;
141
+ children: TemplateChildNode[];
142
+ userKey?: string | number;
143
+ }
144
+ /**
145
+ * for 节点
146
+ */
147
+ interface ForNode extends BaseNode$1 {
148
+ type: NodeTypes.FOR;
149
+ source: ExpressionNode$1;
150
+ valueAlias: string;
151
+ keyAlias?: string;
152
+ indexAlias?: string;
153
+ children: TemplateChildNode[];
154
+ codegenNode?: CodegenNode;
155
+ }
156
+ /**
157
+ * 根节点
158
+ */
159
+ interface RootNode extends BaseNode$1 {
160
+ type: NodeTypes.ROOT;
161
+ children: TemplateChildNode[];
162
+ helpers: Set<symbol>;
163
+ components: Set<string>;
164
+ directives: Set<string>;
165
+ imports: Set<string>;
166
+ hoists?: (JSChildNode | null)[];
167
+ cached?: number;
168
+ codegenNode?: TemplateChildNode | CodegenNode;
169
+ }
170
+ /**
171
+ * JS 子节点类型
172
+ */
173
+ type JSChildNode = JSCallExpression | JSObjectExpression | JSArrayExpression | JSFunctionExpression | JSConditionalExpression | SimpleExpressionNode | CompoundExpressionNode;
174
+ /**
175
+ * 代码生成节点
176
+ */
177
+ type CodegenNode = JSChildNode;
178
+ /**
179
+ * JS 函数调用表达式
180
+ */
181
+ interface JSCallExpression extends BaseNode$1 {
182
+ type: NodeTypes.JS_CALL_EXPRESSION;
183
+ callee: string | symbol;
184
+ arguments: (string | JSChildNode)[];
185
+ }
186
+ /**
187
+ * JS 对象表达式
188
+ */
189
+ interface JSObjectExpression extends BaseNode$1 {
190
+ type: NodeTypes.JS_OBJECT_EXPRESSION;
191
+ properties: Array<JSProperty | SpreadElement>;
192
+ }
193
+ /**
194
+ * JS 属性
195
+ */
196
+ interface JSProperty {
197
+ key: string | ExpressionNode$1;
198
+ value: JSChildNode | string;
199
+ runtimeName?: string;
200
+ }
201
+ /**
202
+ * 展开元素
203
+ */
204
+ interface SpreadElement extends BaseNode$1 {
205
+ type: NodeTypes.JS_CALL_EXPRESSION;
206
+ arguments: JSChildNode[];
207
+ }
208
+ /**
209
+ * JS 数组表达式
210
+ */
211
+ interface JSArrayExpression extends BaseNode$1 {
212
+ type: NodeTypes.JS_ARRAY_EXPRESSION;
213
+ elements: (JSChildNode | string | null)[];
214
+ }
215
+ /**
216
+ * JS 函数表达式
217
+ */
218
+ interface JSFunctionExpression extends BaseNode$1 {
219
+ type: NodeTypes.JS_FUNCTION_EXPRESSION;
220
+ params: string[] | ExpressionNode$1[];
221
+ returns?: JSChildNode;
222
+ body?: JSChildNode;
223
+ newline: boolean;
224
+ isSlot: boolean;
225
+ }
226
+ /**
227
+ * JS 条件表达式
228
+ */
229
+ interface JSConditionalExpression extends BaseNode$1 {
230
+ type: NodeTypes.JS_CONDITIONAL_EXPRESSION;
231
+ test: JSChildNode;
232
+ consequent: JSChildNode;
233
+ alternate: JSChildNode | JSConditionalExpression;
234
+ newline: boolean;
235
+ }
236
+ /**
237
+ * 转换函数类型
238
+ */
239
+ type TransformFn = (node: TemplateChildNode, context: TransformContext) => void | (() => void) | (() => void)[];
240
+ /**
241
+ * 转换上下文
242
+ */
243
+ interface TransformContext {
244
+ root: RootNode;
245
+ parent: TemplateChildNode | null;
246
+ childIndex: number;
247
+ currentNode: TemplateChildNode | null;
248
+ helpers: Set<symbol>;
249
+ components: Set<string>;
250
+ directives: Set<string>;
251
+ nodeTransforms: TransformFn[];
252
+ replaceNode(node: TemplateChildNode): void;
253
+ removeNode(node?: TemplateChildNode): void;
254
+ traverseChildren(parent: TemplateChildNode | RootNode): void;
255
+ traverseNode(node: TemplateChildNode | RootNode): void;
256
+ helper(name: symbol): symbol;
257
+ onError?: (error: CompilerError) => void;
258
+ }
259
+ /**
260
+ * 编译选项
261
+ */
262
+ interface CompilerOptions {
263
+ isBrowser?: boolean;
264
+ filename?: string;
265
+ source?: string;
266
+ hoistStatic?: boolean;
267
+ nodeTransforms?: TransformFn[];
268
+ directiveTransforms?: Record<string, TransformFn>;
269
+ expressionTransforms?: Record<string, TransformFn>;
270
+ onError?: (error: CompilerError) => void;
271
+ }
272
+ /**
273
+ * 代码生成结果
274
+ */
275
+ interface CodegenResult {
276
+ code: string;
277
+ ast: RootNode;
278
+ preamble: string;
279
+ map?: SourceMap;
280
+ }
281
+ /**
282
+ * 源码映射(简化版)
283
+ */
284
+ interface SourceMap {
285
+ file?: string;
286
+ mappings: string;
287
+ names: string[];
288
+ sourceRoot?: string;
289
+ sources: string[];
290
+ sourcesContent?: string[];
291
+ version: number;
292
+ }
293
+ /**
294
+ * 编译错误
295
+ */
296
+ interface CompilerError extends SyntaxError {
297
+ code: number;
298
+ loc?: SourceLocation;
299
+ }
300
+ /**
301
+ * 错误代码
302
+ */
303
+ declare const enum ErrorCodes {
304
+ ABRUPT_CLOSING_OF_EMPTY_COMMENT = 0,
305
+ CDATA_IN_HTML_CONTENT = 1,
306
+ DUPLICATE_ATTRIBUTE = 2,
307
+ END_TAG_WITH_ATTRIBUTES = 3,
308
+ END_TAG_WITH_TRAILING_SOLIDUS = 4,
309
+ EOF_BEFORE_TAG_NAME = 5,
310
+ EOF_IN_CDATA = 6,
311
+ EOF_IN_COMMENT = 7,
312
+ EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT = 8,
313
+ EOF_IN_TAG = 9,
314
+ INCORRECTLY_CLOSED_COMMENT = 10,
315
+ INCORRECTLY_OPENED_COMMENT = 11,
316
+ INVALID_FIRST_CHARACTER_OF_TAG_NAME = 12,
317
+ MISSING_ATTRIBUTE_VALUE = 13,
318
+ MISSING_END_TAG_NAME = 14,
319
+ MISSING_WHITESPACE_BETWEEN_ATTRIBUTES = 15,
320
+ NESTED_COMMENT = 16,
321
+ UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME = 17,
322
+ UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE = 18,
323
+ UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME = 19,
324
+ UNEXPECTED_NULL_CHARACTER = 20,
325
+ UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME = 21,
326
+ UNEXPECTED_SOLIDUS_IN_TAG = 22,
327
+ X_IF_NO_CONDITION = 23,
328
+ X_ELIF_NO_ADJACENT_IF = 24,
329
+ X_ELSE_NO_ADJACENT_IF = 25,
330
+ X_FOR_NO_EXPRESSION = 26,
331
+ X_FOR_MALFORMED_EXPRESSION = 27,
332
+ UNKNOWN_ERROR = 28
333
+ }
334
+
335
+ /**
336
+ * AST 节点创建和工具函数
337
+ */
338
+
339
+ /**
340
+ * 创建位置对象
341
+ */
342
+ declare function createPosition(offset: number, line: number, column: number): Position;
343
+ /**
344
+ * 创建源码位置对象
345
+ */
346
+ declare function createSourceLocation(start: Position, end: Position, source: string): SourceLocation;
347
+ /**
348
+ * 创建根节点
349
+ */
350
+ declare function createRoot(children?: TemplateChildNode[], loc?: SourceLocation): RootNode;
351
+ /**
352
+ * 创建元素节点
353
+ */
354
+ declare function createElementNode(tag: string, props?: Array<AttributeNode | DirectiveNode>, children?: TemplateChildNode[], loc?: SourceLocation, isSelfClosing?: boolean): ElementNode;
355
+ /**
356
+ * 创建文本节点
357
+ */
358
+ declare function createTextNode(content?: string, loc?: SourceLocation): TextNode;
359
+ /**
360
+ * 创建插值节点
361
+ */
362
+ declare function createInterpolationNode(content: string | ExpressionNode, loc?: SourceLocation): InterpolationNode;
363
+ /**
364
+ * 创建属性节点
365
+ */
366
+ declare function createAttributeNode(name: string, value?: string | TextNode | null, loc?: SourceLocation): AttributeNode;
367
+ /**
368
+ * 创建指令节点
369
+ */
370
+ declare function createDirectiveNode(name: string, exp?: string | ExpressionNode | null, arg?: string | ExpressionNode | null, modifiers?: string[], loc?: SourceLocation): DirectiveNode;
371
+ /**
372
+ * 表达式节点类型
373
+ */
374
+ type ExpressionNode = SimpleExpressionNode | CompoundExpressionNode;
375
+ /**
376
+ * 创建简单表达式节点
377
+ */
378
+ declare function createSimpleExpression(content: string, isStatic?: boolean, loc?: SourceLocation, identifiers?: string[]): SimpleExpressionNode;
379
+ /**
380
+ * 创建复合表达式节点
381
+ */
382
+ declare function createCompoundExpression(children: (SimpleExpressionNode | CompoundExpressionNode | InterpolationNode | TextNode | string)[], loc?: SourceLocation): CompoundExpressionNode;
383
+ /**
384
+ * 创建 if 节点
385
+ */
386
+ declare function createIfNode(branches: IfBranchNode[], loc?: SourceLocation): IfNode;
387
+ /**
388
+ * 创建 if 分支节点
389
+ */
390
+ declare function createIfBranchNode(children: TemplateChildNode[], condition?: ExpressionNode, loc?: SourceLocation): IfBranchNode;
391
+ /**
392
+ * 创建 for 节点
393
+ */
394
+ declare function createForNode(source: ExpressionNode, valueAlias: string, children: TemplateChildNode[], keyAlias?: string, indexAlias?: string, loc?: SourceLocation): ForNode;
395
+ /**
396
+ * 创建 JS 函数调用表达式
397
+ */
398
+ declare function createCallExpression(callee: string | symbol, args?: (string | JSChildNode)[], loc?: SourceLocation): JSCallExpression;
399
+ /**
400
+ * 创建 JS 对象表达式
401
+ */
402
+ declare function createObjectExpression(properties?: Array<{
403
+ key: string | ExpressionNode;
404
+ value: JSChildNode | string;
405
+ }>, loc?: SourceLocation): JSObjectExpression;
406
+ /**
407
+ * 创建 JS 数组表达式
408
+ */
409
+ declare function createArrayExpression(elements?: (JSChildNode | string | null)[], loc?: SourceLocation): JSArrayExpression;
410
+ /**
411
+ * 创建 JS 函数表达式
412
+ */
413
+ declare function createFunctionExpression(params?: string[] | ExpressionNode[], returns?: JSChildNode, newline?: boolean, isSlot?: boolean, loc?: SourceLocation): JSFunctionExpression;
414
+ /**
415
+ * 创建 JS 条件表达式
416
+ */
417
+ declare function createConditionalExpression(test: JSChildNode, consequent: JSChildNode, alternate: JSChildNode | JSConditionalExpression, newline?: boolean, loc?: SourceLocation): JSConditionalExpression;
418
+ /**
419
+ * 判断是否为元素节点
420
+ */
421
+ declare function isElementNode(node: any): node is ElementNode;
422
+ /**
423
+ * 判断是否为文本节点
424
+ */
425
+ declare function isTextNode(node: any): node is TextNode;
426
+ /**
427
+ * 判断是否为插值节点
428
+ */
429
+ declare function isInterpolationNode(node: any): node is InterpolationNode;
430
+ /**
431
+ * 判断是否为 if 节点
432
+ */
433
+ declare function isIfNode(node: any): node is IfNode;
434
+ /**
435
+ * 判断是否为 for 节点
436
+ */
437
+ declare function isForNode(node: any): node is ForNode;
438
+ /**
439
+ * 判断是否为简单表达式节点
440
+ */
441
+ declare function isSimpleExpressionNode(node: any): node is SimpleExpressionNode;
442
+ /**
443
+ * 判断是否为复合表达式节点
444
+ */
445
+ declare function isCompoundExpressionNode(node: any): node is CompoundExpressionNode;
446
+ /**
447
+ * 获取节点的所有子节点
448
+ */
449
+ declare function getNodeChildren(node: RootNode | ElementNode | IfNode | ForNode): TemplateChildNode[];
450
+ /**
451
+ * 克隆 AST 节点
452
+ */
453
+ declare function cloneNode<T extends BaseNode>(node: T): T;
454
+
455
+ /**
456
+ * AST 转换核心
457
+ * 负责遍历 AST 并执行转换插件
458
+ */
459
+
460
+ /**
461
+ * 创建转换上下文
462
+ */
463
+ declare function createTransformContext(root: RootNode, options?: CompilerOptions): TransformContext;
464
+ /**
465
+ * 执行 AST 转换
466
+ * @param root 根节点
467
+ * @param options 编译选项
468
+ */
469
+ declare function transform(root: RootNode, options?: CompilerOptions): void;
470
+ /**
471
+ * 遍历 AST 节点
472
+ */
473
+ declare function traverseNode(node: TemplateChildNode | RootNode, context: TransformContext): void;
474
+ /**
475
+ * 遍历子节点
476
+ */
477
+ declare function traverseChildren(parent: TemplateChildNode | RootNode, context: TransformContext): void;
478
+ /**
479
+ * 创建简单的转换插件
480
+ */
481
+ declare function createTransform(types: NodeTypes[], fn: TransformFn): TransformFn;
482
+
483
+ /**
484
+ * if/elif/else 转换插件
485
+ * 将 if 节点转换为三元表达式
486
+ */
487
+
488
+ /**
489
+ * if 转换插件
490
+ *
491
+ * 将:
492
+ * if loading
493
+ * p loading...
494
+ * else
495
+ * p loaded
496
+ *
497
+ * 转换为:
498
+ * loading() ? h("p", "loading...") : h("p", "loaded")
499
+ */
500
+ declare function transformIf(node: TemplateChildNode, context: TransformContext): void;
501
+ /**
502
+ * 检查节点是否为有效的 if 分支
503
+ */
504
+ declare function isValidIfBranch(node: any): boolean;
505
+ /**
506
+ * 获取 if 分支的类型
507
+ */
508
+ declare function getIfBranchType(branch: IfBranchNode): 'if' | 'elif' | 'else';
509
+
510
+ /**
511
+ * for 循环转换插件
512
+ * 将 for 节点转换为 map 调用
513
+ */
514
+
515
+ /**
516
+ * for 转换插件
517
+ *
518
+ * 将:
519
+ * for user in users
520
+ * p {user.name}
521
+ *
522
+ * 转换为:
523
+ * users().map(user => h("p", [user.name]))
524
+ */
525
+ declare function transformFor(node: TemplateChildNode, context: TransformContext): void;
526
+ /**
527
+ * 解析 for 表达式
528
+ * 支持:
529
+ * - for item in list
530
+ * - for (item, index) in list
531
+ * - for (item, key, index) in list
532
+ */
533
+ declare function parseForExpression(source: string, valueAlias?: string, keyAlias?: string, indexAlias?: string): {
534
+ source: string;
535
+ value: string;
536
+ key?: string;
537
+ index?: string;
538
+ } | null;
539
+ /**
540
+ * 检查节点是否为有效的 for 节点
541
+ */
542
+ declare function isValidForNode(node: any): node is ForNode;
543
+
544
+ /**
545
+ * 元素转换插件
546
+ * 将元素节点转换为 h 函数调用
547
+ */
548
+
549
+ /**
550
+ * 元素转换插件
551
+ *
552
+ * 将:
553
+ * button @click=increment
554
+ *
555
+ * 转换为:
556
+ * h("button", { onClick: increment })
557
+ */
558
+ declare function transformElement(node: TemplateChildNode, context: TransformContext): (() => void) | undefined;
559
+
560
+ /**
561
+ * 文本插值转换插件
562
+ * 处理文本节点和插值表达式
563
+ */
564
+
565
+ /**
566
+ * 文本转换插件
567
+ *
568
+ * 处理文本和插值的混合情况:
569
+ * - 纯文本:直接使用
570
+ * - 插值表达式:包装 signal 调用
571
+ * - 混合文本:创建复合表达式
572
+ */
573
+ declare function transformText(node: TemplateChildNode, context: TransformContext): (() => void) | undefined;
574
+ /**
575
+ * 检查节点是否包含文本
576
+ */
577
+ declare function hasTextChildren(node: ElementNode): boolean;
578
+ /**
579
+ * 规范化文本内容
580
+ */
581
+ declare function normalizeTextContent(node: ElementNode): string;
582
+
583
+ /**
584
+ * 转换插件统一导出
585
+ */
586
+
587
+ /**
588
+ * 获取默认的节点转换插件
589
+ */
590
+ declare function getDefaultTransforms(): TransformFn[];
591
+
592
+ /**
593
+ * 代码生成核心
594
+ * 将 AST 转换为 JavaScript 代码
595
+ */
596
+
597
+ /**
598
+ * 生成代码
599
+ */
600
+ declare function generate(ast: RootNode): CodegenResult;
601
+
602
+ /**
603
+ * 运行时辅助函数符号
604
+ */
605
+ declare const runtimeHelpers: {
606
+ readonly CREATE_ELEMENT_VNODE: symbol;
607
+ readonly CREATE_TEXT_VNODE: symbol;
608
+ readonly CREATE_COMMENT_VNODE: symbol;
609
+ readonly RESOLVE_COMPONENT: symbol;
610
+ readonly RESOLVE_DIRECTIVE: symbol;
611
+ readonly RENDER_LIST: symbol;
612
+ readonly RENDER_SLOT: symbol;
613
+ readonly MERGE_PROPS: symbol;
614
+ readonly NORMALIZE_CLASS: symbol;
615
+ readonly NORMALIZE_STYLE: symbol;
616
+ readonly NORMALIZE_PROPS: symbol;
617
+ readonly WITH_DIRECTIVES: symbol;
618
+ readonly WITH_CTX: symbol;
619
+ };
620
+ /**
621
+ * 获取运行时辅助函数名称
622
+ */
623
+ declare function getRuntimeHelperName(symbol: symbol): string;
624
+ /**
625
+ * 判断是否为运行时辅助函数
626
+ */
627
+ declare function isRuntimeHelper(value: unknown): value is symbol;
628
+
629
+ export { ElementTypes, ErrorCodes, NodeTypes, cloneNode, createArrayExpression, createAttributeNode, createCallExpression, createCompoundExpression, createConditionalExpression, createDirectiveNode, createElementNode, createForNode, createFunctionExpression, createIfBranchNode, createIfNode, createInterpolationNode, createObjectExpression, createPosition, createRoot, createSimpleExpression, createSourceLocation, createTextNode, createTransform, createTransformContext, generate, getDefaultTransforms, getIfBranchType, getNodeChildren, getRuntimeHelperName, hasTextChildren, isCompoundExpressionNode, isElementNode, isForNode, isIfNode, isInterpolationNode, isRuntimeHelper, isSimpleExpressionNode, isTextNode, isValidForNode, isValidIfBranch, normalizeTextContent, parseForExpression, runtimeHelpers, transform, transformElement, transformFor, transformIf, transformText, traverseChildren, traverseNode };
630
+ export type { AttributeNode, CodegenResult, CompilerError, CompilerOptions, CompoundExpressionNode, DirectiveNode, ElementNode, ExpressionNode$1 as ExpressionNode, ForNode, IfBranchNode, IfNode, InterpolationNode, JSArrayExpression, JSCallExpression, JSChildNode, JSConditionalExpression, JSFunctionExpression, JSObjectExpression, Position, RootNode, SimpleExpressionNode, SourceLocation, TemplateChildNode, TextNode, TransformContext, TransformFn };
631
+ //# sourceMappingURL=compiler-core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler-core.d.ts","sources":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[]}
@@ -0,0 +1,2 @@
1
+ import{warn as e}from"@fluxion-ui/shared";var n=(e=>(e[e.ROOT=0]="ROOT",e[e.ELEMENT=1]="ELEMENT",e[e.TEXT=2]="TEXT",e[e.INTERPOLATION=3]="INTERPOLATION",e[e.ATTRIBUTE=4]="ATTRIBUTE",e[e.DIRECTIVE=5]="DIRECTIVE",e[e.IF=6]="IF",e[e.IF_BRANCH=7]="IF_BRANCH",e[e.FOR=8]="FOR",e[e.SIMPLE_EXPRESSION=9]="SIMPLE_EXPRESSION",e[e.COMPOUND_EXPRESSION=10]="COMPOUND_EXPRESSION",e[e.JS_CALL_EXPRESSION=11]="JS_CALL_EXPRESSION",e[e.JS_OBJECT_EXPRESSION=12]="JS_OBJECT_EXPRESSION",e[e.JS_ARRAY_EXPRESSION=13]="JS_ARRAY_EXPRESSION",e[e.JS_FUNCTION_EXPRESSION=14]="JS_FUNCTION_EXPRESSION",e[e.JS_CONDITIONAL_EXPRESSION=15]="JS_CONDITIONAL_EXPRESSION",e))(n||{}),t=(e=>(e[e.ELEMENT=0]="ELEMENT",e[e.COMPONENT=1]="COMPONENT",e))(t||{}),o=(e=>(e[e.ABRUPT_CLOSING_OF_EMPTY_COMMENT=0]="ABRUPT_CLOSING_OF_EMPTY_COMMENT",e[e.CDATA_IN_HTML_CONTENT=1]="CDATA_IN_HTML_CONTENT",e[e.DUPLICATE_ATTRIBUTE=2]="DUPLICATE_ATTRIBUTE",e[e.END_TAG_WITH_ATTRIBUTES=3]="END_TAG_WITH_ATTRIBUTES",e[e.END_TAG_WITH_TRAILING_SOLIDUS=4]="END_TAG_WITH_TRAILING_SOLIDUS",e[e.EOF_BEFORE_TAG_NAME=5]="EOF_BEFORE_TAG_NAME",e[e.EOF_IN_CDATA=6]="EOF_IN_CDATA",e[e.EOF_IN_COMMENT=7]="EOF_IN_COMMENT",e[e.EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT=8]="EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",e[e.EOF_IN_TAG=9]="EOF_IN_TAG",e[e.INCORRECTLY_CLOSED_COMMENT=10]="INCORRECTLY_CLOSED_COMMENT",e[e.INCORRECTLY_OPENED_COMMENT=11]="INCORRECTLY_OPENED_COMMENT",e[e.INVALID_FIRST_CHARACTER_OF_TAG_NAME=12]="INVALID_FIRST_CHARACTER_OF_TAG_NAME",e[e.MISSING_ATTRIBUTE_VALUE=13]="MISSING_ATTRIBUTE_VALUE",e[e.MISSING_END_TAG_NAME=14]="MISSING_END_TAG_NAME",e[e.MISSING_WHITESPACE_BETWEEN_ATTRIBUTES=15]="MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",e[e.NESTED_COMMENT=16]="NESTED_COMMENT",e[e.UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME=17]="UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",e[e.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE=18]="UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",e[e.UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME=19]="UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",e[e.UNEXPECTED_NULL_CHARACTER=20]="UNEXPECTED_NULL_CHARACTER",e[e.UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME=21]="UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",e[e.UNEXPECTED_SOLIDUS_IN_TAG=22]="UNEXPECTED_SOLIDUS_IN_TAG",e[e.X_IF_NO_CONDITION=23]="X_IF_NO_CONDITION",e[e.X_ELIF_NO_ADJACENT_IF=24]="X_ELIF_NO_ADJACENT_IF",e[e.X_ELSE_NO_ADJACENT_IF=25]="X_ELSE_NO_ADJACENT_IF",e[e.X_FOR_NO_EXPRESSION=26]="X_FOR_NO_EXPRESSION",e[e.X_FOR_MALFORMED_EXPRESSION=27]="X_FOR_MALFORMED_EXPRESSION",e[e.UNKNOWN_ERROR=28]="UNKNOWN_ERROR",e))(o||{});const r={offset:0,line:1,column:1},E={start:r,end:r,source:""};function c(e,n,t){return{offset:e,line:n,column:t}}function s(e,n,t){return{start:e,end:n,source:t}}function u(e=[],t=E){return{type:n.ROOT,children:e,helpers:new Set,components:new Set,directives:new Set,imports:new Set,loc:t}}function i(e,t=[],o=[],r=E,c=!1){return{type:n.ELEMENT,tag:e,props:t,children:o,isSelfClosing:c,loc:r}}function _(e="",t=E){return{type:n.TEXT,content:e,loc:t}}function N(e,t=E){const o="string"==typeof e?p(e,!1,t):e;return{type:n.INTERPOLATION,content:o,loc:t}}function l(e,t=null,o=E){const r="string"==typeof t?_(t,o):t;return{type:n.ATTRIBUTE,name:e,value:r,loc:o}}function T(e,t=null,o=null,r=[],c=E){const s="string"==typeof t?p(t,!1,c):t,u="string"==typeof o?p(o,!0,c):o;return{type:n.DIRECTIVE,name:e,exp:s,arg:u,modifiers:r,loc:c}}function p(e,t=!1,o=E,r){return{type:n.SIMPLE_EXPRESSION,content:e,isStatic:t,loc:o,identifiers:r}}function I(e,t=E){return{type:n.COMPOUND_EXPRESSION,children:e,loc:t}}function O(e,t=E){return{type:n.IF,branches:e,loc:t}}function d(e,t,o=E){return{type:n.IF_BRANCH,children:e,condition:t,loc:o}}function h(e,t,o,r,c,s=E){return{type:n.FOR,source:e,valueAlias:t,keyAlias:r,indexAlias:c,children:o,loc:s}}function f(e,t=[],o=E){return{type:n.JS_CALL_EXPRESSION,callee:e,arguments:t,loc:o}}function S(e=[],t=E){return{type:n.JS_OBJECT_EXPRESSION,properties:e,loc:t}}function R(e=[],t=E){return{type:n.JS_ARRAY_EXPRESSION,elements:e,loc:t}}function A(e=[],t,o=!1,r=!1,c=E){return{type:n.JS_FUNCTION_EXPRESSION,params:e,returns:t,newline:o,isSlot:r,loc:c}}function a(e,t,o,r=!0,c=E){return{type:n.JS_CONDITIONAL_EXPRESSION,test:e,consequent:t,alternate:o,newline:r,loc:c}}function C(e){return e?.type===n.ELEMENT}function L(e){return e?.type===n.TEXT}function M(e){return e?.type===n.INTERPOLATION}function P(e){return e?.type===n.IF}function g(e){return e?.type===n.FOR}function y(e){return e?.type===n.SIMPLE_EXPRESSION}function m(e){return e?.type===n.COMPOUND_EXPRESSION}function D(e){switch(e.type){case n.ROOT:case n.ELEMENT:case n.IF_BRANCH:case n.FOR:return e.children;case n.IF:return e.branches;default:return[]}}function X(e){const n={...e};return e.loc&&(n.loc={...e.loc}),n}function F(n,t={}){const o={root:n,parent:null,childIndex:0,currentNode:null,helpers:new Set,components:new Set,directives:new Set,nodeTransforms:t.nodeTransforms||[],replaceNode(n){if(!o.parent)return void e("replaceNode: 没有父节点");const t=D(o.parent);t&&(t[o.childIndex]=n),o.currentNode=n},removeNode(n){if(!o.parent)return void e("removeNode: 没有父节点");const t=D(o.parent);if(t){const e=n?t.indexOf(n):o.childIndex;e>-1&&t.splice(e,1)}o.currentNode=null},traverseChildren(e){b(e,o)},traverseNode(e){v(e,o)},helper:e=>(o.helpers.add(e),e),onError:t.onError};return o}function U(e,n={}){const t=F(e,n);v(e,t),e.helpers=new Set([...e.helpers,...t.helpers]),e.components=new Set([...e.components,...t.components]),e.directives=new Set([...e.directives,...t.directives])}function v(e,t){t.currentNode=e;const{nodeTransforms:o}=t,r=[];if(o)for(const n of o){const o=n(e,t);if(!t.currentNode)return;o&&(Array.isArray(o)?r.push(...o):r.push(o))}switch(e.type){case n.ROOT:case n.ELEMENT:case n.IF:case n.FOR:case n.IF_BRANCH:b(e,t)}t.currentNode=e;let E=r.length;for(;E--;)r[E]()}function b(e,n){const t=D(e);if(!t||0===t.length)return;let o=n.parent;n.parent=e;for(let e=0;e<t.length;e++)n.childIndex=e,v(t[e],n);n.parent=o}function B(e,n){return(t,o)=>{if(e.includes(t.type))return n(t,o)}}function $(n,t){P(n)&&function(n){const{branches:t}=n;if(0===t.length)return void e("transformIf: if 节点没有分支");const o=function(e){const{branches:n}=e;let t=n[n.length-1],o=G(t);for(let e=n.length-2;e>=0;e--){const t=n[e];o=a(V(t),G(t),o,!0)}return o}(n);o&&(n.codegenNode=o)}(n)}function V(n,t){if(!n.condition)return e("transformIf: if 分支缺少条件"),p("true",!1);return p(function(e){if(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!e.includes("("))return`${e}()`;return e}(n.condition.content),!1)}function G(e,t){if(1===e.children.length){const t=e.children[0];if(t.type===n.ELEMENT&&t.codegenNode)return t.codegenNode}return p(`/* branch with ${e.children.length} children */`,!1)}function H(e){return e?.type===n.IF_BRANCH}function J(e){return e.condition?"if":"else"}var w=(e=>(e.CREATE_ELEMENT_VNODE="h",e.CREATE_TEXT_VNODE="createTextVNode",e.CREATE_COMMENT_VNODE="createCommentVNode",e.RESOLVE_COMPONENT="resolveComponent",e.RESOLVE_DIRECTIVE="resolveDirective",e.RENDER_LIST="renderList",e.RENDER_SLOT="renderSlot",e.MERGE_PROPS="mergeProps",e.NORMALIZE_CLASS="normalizeClass",e.NORMALIZE_STYLE="normalizeStyle",e.NORMALIZE_PROPS="normalizeProps",e.WITH_DIRECTIVES="withDirectives",e.WITH_CTX="withCtx",e))(w||{});const k={CREATE_ELEMENT_VNODE:Symbol("h"),CREATE_TEXT_VNODE:Symbol("createTextVNode"),CREATE_COMMENT_VNODE:Symbol("createCommentVNode"),RESOLVE_COMPONENT:Symbol("resolveComponent"),RESOLVE_DIRECTIVE:Symbol("resolveDirective"),RENDER_LIST:Symbol("renderList"),RENDER_SLOT:Symbol("renderSlot"),MERGE_PROPS:Symbol("mergeProps"),NORMALIZE_CLASS:Symbol("normalizeClass"),NORMALIZE_STYLE:Symbol("normalizeStyle"),NORMALIZE_PROPS:Symbol("normalizeProps"),WITH_DIRECTIVES:Symbol("withDirectives"),WITH_CTX:Symbol("withCtx")};function x(e){for(const[n,t]of Object.entries(k))if(t===e)return w[n];return""}function z(e){return"symbol"==typeof e&&Object.values(k).includes(e)}function Z(t,o){g(t)&&function(t,o){const{source:r}=t;if(!r)return void e("transformFor: for 节点缺少源表达式");o.helper(k.CREATE_ELEMENT_VNODE);const E=function(e){const{source:t,valueAlias:o,keyAlias:r,indexAlias:E,children:c}=e,s=[o];r&&s.push(r);E&&s.push(E);let u;if(1===c.length){const e=c[0];u=e.type===n.ELEMENT&&e.codegenNode?e.codegenNode:R([e])}else u=R(c.map(e=>e.type===n.ELEMENT&&e.codegenNode?e.codegenNode:e));const i=A(s,u,!1,!1),_=function(e){if(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!e.includes("("))return`${e}()`;return e}(t.content);return f(`${_}.map`,[i])}(t);E&&(t.codegenNode=E)}(t,o)}function W(e,n,t,o){const r=e.match(/^\s*(?:\(([^)]+)\)|(\w+))\s+in\s+(.+)$/);if(!r)return null;const E=r[3].trim();if(r[2])return{source:E,value:r[2]};{const e=r[1].split(",").map(e=>e.trim()),n={source:E,value:e[0]};return 2===e.length?n.index=e[1]:e.length>=3&&(n.key=e[1],n.index=e[2]),n}}function Y(e){return g(e)&&!!e.source}function K(e,t){if(C(e))return()=>{!function(e,t){t.helper(k.CREATE_ELEMENT_VNODE);const o=function(e,t){const{tag:o,props:r,children:E}=e,c=function(e){return/^[A-Z]/.test(e)||e.includes("-")}(o),s=[];c?(s.push(o),t.components.add(o)):s.push(`"${o}"`);const u=function(e){if(0===e.length)return null;const t=[];for(const o of e)if(o.type===n.ATTRIBUTE)t.push({key:o.name,value:o.value?`"${o.value.content}"`:"true"});else if(o.type===n.DIRECTIVE){const e=Q(o);e&&t.push(e)}if(0===t.length)return null;return S(t)}(r);(u||E.length>0)&&s.push(u||"null");if(E.length>0){const e=function(e){if(0===e.length)return null;if(1===e.length){const t=e[0];if(t.type===n.TEXT)return`"${t.content}"`;if(t.type===n.INTERPOLATION)return q(t.content.content);if(t.type===n.ELEMENT&&t.codegenNode)return t.codegenNode}const t=[];for(const o of e)o.type===n.TEXT?t.push(`"${o.content}"`):o.type===n.INTERPOLATION?t.push(q(o.content.content)):o.type===n.ELEMENT||o.type===n.IF?o.codegenNode&&t.push(o.codegenNode):o.type===n.FOR&&o.codegenNode&&t.push(o.codegenNode);return R(t)}(E);s.push(e)}return f(k.CREATE_ELEMENT_VNODE,s)}(e,t);o&&(e.codegenNode=o)}(e,t)}}function Q(e,n){const{name:t,exp:o,arg:r}=e;switch(t){case"click":case"mousedown":case"mouseup":case"mouseenter":case"mouseleave":case"keydown":case"keyup":case"submit":case"input":case"change":default:return{key:`on${j(t)}`,value:o?o.content:"() => {}"};case"bind":return r?{key:r.content,value:q(o?.content||"")}:null;case"model":return null}}function j(e){return e.charAt(0).toUpperCase()+e.slice(1)}function q(e){return e?/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!e.includes("(")?`${e}()`:e:""}function ee(e,n){if(C(e))return()=>{!function(e){const{children:n}=e;let t=!1,o=null;for(let e=0;e<n.length;e++){const r=n[e];if(L(r)||M(r))if(t=!0,o){if(L(r))o.children.push(r.content);else{o.children.push(p(ne(r.content.content),!1))}n.splice(e,1),e--}else if(L(r)){const t=n[e+1];t&&(L(t)||M(t))&&(o=I([r.content]),n[e]=o)}else{const t=r.content.content,E=n[e+1];E&&(L(E)||M(E))?(o=I([p(ne(t),!1)]),n[e]=o):r.content=p(ne(t),!1)}else o=null}if(!t);}(e)}}function ne(e){return e?/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!e.includes("(")?`${e}()`:e:""}function te(e){return e.children.some(e=>L(e)||M(e))}function oe(e){const n=[];for(const t of e.children)L(t)?n.push(t.content):M(t)&&n.push(`{${t.content.content}}`);return n.join("")}function re(){return[$,Z,K,ee]}function Ee(e){const n=function(){const e={code:"",indentLevel:0,indent:(n=e.indentLevel)=>" ".repeat(n),newline:()=>"\n",push(n){e.code+=n},indentCode(){e.indentLevel++},deindent(){e.indentLevel--}};return e}();return function(e,n){if(e.helpers.size>0){const t=[];for(const n of e.helpers){const e=x(n);e&&!t.includes(e)&&t.push(e)}t.length>0&&n.push(`import { ${t.join(", ")} } from '@fluxion-ui/fluxion/runtime'\n`)}n.push("\n")}(e,n),function(e,n){if(n.push("export function render() {\n"),n.indentCode(),n.push(n.indent()),n.push("return "),1===e.children.length)ce(e.children[0],n);else if(e.children.length>1){n.push("[\n"),n.indentCode();for(let t=0;t<e.children.length;t++)n.push(n.indent()),ce(e.children[t],n),t<e.children.length-1&&n.push(","),n.push("\n");n.deindent(),n.push(n.indent()),n.push("]")}else n.push("null");n.push("\n"),n.deindent(),n.push("}\n")}(e,n),{code:n.code,ast:e,preamble:""}}function ce(t,o){switch(t.type){case n.ELEMENT:!function(e,n){if(e.codegenNode)ce(e.codegenNode,n);else{if(n.push(`h("${e.tag}"`),e.props.length>0&&(n.push(", "),function(e,n){n.push("{");for(let t=0;t<e.length;t++){const o=e[t];n.push(`${o.name}: ${o.value?`"${o.value.content}"`:"true"}`),t<e.length-1&&n.push(", ")}n.push("}")}(e.props,n)),e.children.length>0)if(n.push(", "),1===e.children.length)ce(e.children[0],n);else{n.push("[");for(let t=0;t<e.children.length;t++)ce(e.children[t],n),t<e.children.length-1&&n.push(", ");n.push("]")}n.push(")")}}(t,o);break;case n.TEXT:!function(e,n){n.push(`"${e.content}"`)}(t,o);break;case n.INTERPOLATION:!function(e,n){const t=e.content.content;n.push(t)}(t,o);break;case n.IF:!function(n,t){n.codegenNode?ce(n.codegenNode,t):e("genIfNode: if 节点缺少 codegenNode")}(t,o);break;case n.FOR:!function(n,t){n.codegenNode?ce(n.codegenNode,t):e("genForNode: for 节点缺少 codegenNode")}(t,o);break;case n.SIMPLE_EXPRESSION:!function(e,n){n.push(e.content)}(t,o);break;case n.COMPOUND_EXPRESSION:!function(e,n){for(const t of e.children)"string"==typeof t?n.push(t):ce(t,n)}(t,o);break;case n.JS_CALL_EXPRESSION:!function(e,n){n.push("symbol"==typeof e.callee?x(e.callee)||"h":e.callee);n.push("(");for(let t=0;t<e.arguments.length;t++){const o=e.arguments[t];"string"==typeof o?n.push(o):ce(o,n),t<e.arguments.length-1&&n.push(", ")}n.push(")")}(t,o);break;case n.JS_OBJECT_EXPRESSION:!function(e,n){if(0===e.properties.length)return void n.push("{}");n.push("{\n"),n.indentCode();for(let t=0;t<e.properties.length;t++){const o=e.properties[t];n.push(n.indent()),"string"==typeof o.key?n.push(o.key):ce(o.key,n),n.push(": "),"string"==typeof o.value?n.push(o.value):ce(o.value,n),t<e.properties.length-1&&n.push(","),n.push("\n")}n.deindent(),n.push(n.indent()),n.push("}")}(t,o);break;case n.JS_ARRAY_EXPRESSION:!function(e,n){if(0===e.elements.length)return void n.push("[]");n.push("[\n"),n.indentCode();for(let t=0;t<e.elements.length;t++){const o=e.elements[t];n.push(n.indent()),null===o?n.push("null"):"string"==typeof o?n.push(o):ce(o,n),t<e.elements.length-1&&n.push(","),n.push("\n")}n.deindent(),n.push(n.indent()),n.push("]")}(t,o);break;case n.JS_FUNCTION_EXPRESSION:!function(e,n){n.push("(");const t=e.params;for(let e=0;e<t.length;e++)n.push(t[e]),e<t.length-1&&n.push(", ");n.push(") => "),e.returns?e.newline?(n.push("{\n"),n.indentCode(),n.push(n.indent()),n.push("return "),ce(e.returns,n),n.push("\n"),n.deindent(),n.push(n.indent()),n.push("}")):ce(e.returns,n):e.body&&ce(e.body,n)}(t,o);break;case n.JS_CONDITIONAL_EXPRESSION:!function(e,n){ce(e.test,n),n.push(" ? "),ce(e.consequent,n),n.push(" : "),ce(e.alternate,n)}(t,o);break;default:e(`genNode: 未知的节点类型 ${t.type}`)}}export{t as ElementTypes,o as ErrorCodes,n as NodeTypes,X as cloneNode,R as createArrayExpression,l as createAttributeNode,f as createCallExpression,I as createCompoundExpression,a as createConditionalExpression,T as createDirectiveNode,i as createElementNode,h as createForNode,A as createFunctionExpression,d as createIfBranchNode,O as createIfNode,N as createInterpolationNode,S as createObjectExpression,c as createPosition,u as createRoot,p as createSimpleExpression,s as createSourceLocation,_ as createTextNode,B as createTransform,F as createTransformContext,Ee as generate,re as getDefaultTransforms,J as getIfBranchType,D as getNodeChildren,x as getRuntimeHelperName,te as hasTextChildren,m as isCompoundExpressionNode,C as isElementNode,g as isForNode,P as isIfNode,M as isInterpolationNode,z as isRuntimeHelper,y as isSimpleExpressionNode,L as isTextNode,Y as isValidForNode,H as isValidIfBranch,oe as normalizeTextContent,W as parseForExpression,k as runtimeHelpers,U as transform,K as transformElement,Z as transformFor,$ as transformIf,ee as transformText,b as traverseChildren,v as traverseNode};
2
+ //# sourceMappingURL=compiler-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler-core.js","sources":["../src/types.ts","../src/ast.ts","../src/transform.ts","../src/transforms/vIf.ts","../src/runtimeHelpers.ts","../src/transforms/vFor.ts","../src/transforms/transformElement.ts","../src/transforms/transformText.ts","../src/transforms/index.ts","../src/codegen/codegen.ts"],"sourcesContent":["/**\n * compiler-core 核心类型定义\n * 定义 AST 节点类型、转换上下文、编译选项等\n */\n\n// ==================== AST 节点类型枚举 ====================\n\n/**\n * AST 节点类型枚举\n */\nexport const enum NodeTypes {\n\tROOT, // 根节点\n\tELEMENT, // 元素节点\n\tTEXT, // 文本节点\n\tINTERPOLATION, // 插值表达式 {count}\n\tATTRIBUTE, // 属性\n\tDIRECTIVE, // 指令 @click\n\tIF, // if 条件\n\tIF_BRANCH, // if 分支\n\tFOR, // for 循环\n\tSIMPLE_EXPRESSION, // 简单表达式\n\tCOMPOUND_EXPRESSION, // 复合表达式\n\tJS_CALL_EXPRESSION, // JS 函数调用\n\tJS_OBJECT_EXPRESSION, // JS 对象表达式\n\tJS_ARRAY_EXPRESSION, // JS 数组表达式\n\tJS_FUNCTION_EXPRESSION, // JS 函数表达式\n\tJS_CONDITIONAL_EXPRESSION // JS 条件表达式\n}\n\n// ==================== 基础节点接口 ====================\n\n/**\n * AST 节点基础接口\n */\nexport interface BaseNode {\n\ttype: NodeTypes\n\tloc?: SourceLocation\n}\n\n/**\n * 源码位置信息\n */\nexport interface SourceLocation {\n\tstart: Position\n\tend: Position\n\tsource: string\n}\n\n/**\n * 位置信息\n */\nexport interface Position {\n\toffset: number\n\tline: number\n\tcolumn: number\n}\n\n// ==================== 表达式节点 ====================\n\n/**\n * 表达式节点基类\n */\nexport interface ExpressionNode extends BaseNode {\n\tcontent: string\n\tisStatic?: boolean\n}\n\n/**\n * 简单表达式节点\n */\nexport interface SimpleExpressionNode extends ExpressionNode {\n\ttype: NodeTypes.SIMPLE_EXPRESSION\n\tisStatic: boolean\n\tidentifiers?: string[]\n}\n\n/**\n * 复合表达式节点\n */\nexport interface CompoundExpressionNode extends BaseNode {\n\ttype: NodeTypes.COMPOUND_EXPRESSION\n\tchildren: (SimpleExpressionNode | CompoundExpressionNode | InterpolationNode | TextNode | string)[]\n\tidentifiers?: string[]\n}\n\n// ==================== 模板子节点 ====================\n\n/**\n * 模板子节点类型\n */\nexport type TemplateChildNode =\n\t| ElementNode\n\t| TextNode\n\t| InterpolationNode\n\t| IfNode\n\t| ForNode\n\n/**\n * 文本节点\n */\nexport interface TextNode extends BaseNode {\n\ttype: NodeTypes.TEXT\n\tcontent: string\n}\n\n/**\n * 插值节点 {count}\n */\nexport interface InterpolationNode extends BaseNode {\n\ttype: NodeTypes.INTERPOLATION\n\tcontent: ExpressionNode\n}\n\n// ==================== 元素节点 ====================\n\n/**\n * 元素节点\n */\nexport interface ElementNode extends BaseNode {\n\ttype: NodeTypes.ELEMENT\n\ttag: string\n\tprops: Array<AttributeNode | DirectiveNode>\n\tchildren: TemplateChildNode[]\n\tisSelfClosing: boolean\n\tcodegenNode?: CodegenNode\n\ttagType?: ElementTypes\n}\n\n/**\n * 元素类型\n */\nexport const enum ElementTypes {\n\tELEMENT, // 普通元素\n\tCOMPONENT // 组件\n}\n\n/**\n * 属性节点\n */\nexport interface AttributeNode extends BaseNode {\n\ttype: NodeTypes.ATTRIBUTE\n\tname: string\n\tvalue: TextNode | null\n}\n\n/**\n * 指令节点\n */\nexport interface DirectiveNode extends BaseNode {\n\ttype: NodeTypes.DIRECTIVE\n\tname: string\n\texp: ExpressionNode | null\n\targ: ExpressionNode | null\n\tmodifiers: string[]\n}\n\n// ==================== 控制流节点 ====================\n\n/**\n * if 节点\n */\nexport interface IfNode extends BaseNode {\n\ttype: NodeTypes.IF\n\tbranches: IfBranchNode[]\n\tcodegenNode?: CodegenNode\n}\n\n/**\n * if 分支节点\n */\nexport interface IfBranchNode extends BaseNode {\n\ttype: NodeTypes.IF_BRANCH\n\tcondition?: ExpressionNode\n\tchildren: TemplateChildNode[]\n\tuserKey?: string | number\n}\n\n/**\n * for 节点\n */\nexport interface ForNode extends BaseNode {\n\ttype: NodeTypes.FOR\n\tsource: ExpressionNode\n\tvalueAlias: string\n\tkeyAlias?: string\n\tindexAlias?: string\n\tchildren: TemplateChildNode[]\n\tcodegenNode?: CodegenNode\n}\n\n// ==================== 根节点 ====================\n\n/**\n * 根节点\n */\nexport interface RootNode extends BaseNode {\n\ttype: NodeTypes.ROOT\n\tchildren: TemplateChildNode[]\n\thelpers: Set<symbol>\n\tcomponents: Set<string>\n\tdirectives: Set<string>\n\timports: Set<string>\n\thoists?: (JSChildNode | null)[]\n\tcached?: number\n\tcodegenNode?: TemplateChildNode | CodegenNode\n}\n\n// ==================== JS 代码生成节点 ====================\n\n/**\n * JS 子节点类型\n */\nexport type JSChildNode =\n\t| JSCallExpression\n\t| JSObjectExpression\n\t| JSArrayExpression\n\t| JSFunctionExpression\n\t| JSConditionalExpression\n\t| SimpleExpressionNode\n\t| CompoundExpressionNode\n\n/**\n * 代码生成节点\n */\nexport type CodegenNode = JSChildNode\n\n/**\n * JS 函数调用表达式\n */\nexport interface JSCallExpression extends BaseNode {\n\ttype: NodeTypes.JS_CALL_EXPRESSION\n\tcallee: string | symbol\n\targuments: (string | JSChildNode)[]\n}\n\n/**\n * JS 对象表达式\n */\nexport interface JSObjectExpression extends BaseNode {\n\ttype: NodeTypes.JS_OBJECT_EXPRESSION\n\tproperties: Array<JSProperty | SpreadElement>\n}\n\n/**\n * JS 属性\n */\nexport interface JSProperty {\n\tkey: string | ExpressionNode\n\tvalue: JSChildNode | string\n\truntimeName?: string\n}\n\n/**\n * 展开元素\n */\nexport interface SpreadElement extends BaseNode {\n\ttype: NodeTypes.JS_CALL_EXPRESSION\n\targuments: JSChildNode[]\n}\n\n/**\n * JS 数组表达式\n */\nexport interface JSArrayExpression extends BaseNode {\n\ttype: NodeTypes.JS_ARRAY_EXPRESSION\n\telements: (JSChildNode | string | null)[]\n}\n\n/**\n * JS 函数表达式\n */\nexport interface JSFunctionExpression extends BaseNode {\n\ttype: NodeTypes.JS_FUNCTION_EXPRESSION\n\tparams: string[] | ExpressionNode[]\n\treturns?: JSChildNode\n\tbody?: JSChildNode\n\tnewline: boolean\n\tisSlot: boolean\n}\n\n/**\n * JS 条件表达式\n */\nexport interface JSConditionalExpression extends BaseNode {\n\ttype: NodeTypes.JS_CONDITIONAL_EXPRESSION\n\ttest: JSChildNode\n\tconsequent: JSChildNode\n\talternate: JSChildNode | JSConditionalExpression\n\tnewline: boolean\n}\n\n// ==================== 转换上下文 ====================\n\n/**\n * 转换函数类型\n */\nexport type TransformFn = (node: TemplateChildNode, context: TransformContext) => void | (() => void) | (() => void)[]\n\n/**\n * 转换上下文\n */\nexport interface TransformContext {\n\t// 根节点\n\troot: RootNode\n\n\t// 父节点\n\tparent: TemplateChildNode | null\n\n\t// 当前节点索引\n\tchildIndex: number\n\n\t// 当前节点\n\tcurrentNode: TemplateChildNode | null\n\n\t// 帮助函数\n\thelpers: Set<symbol>\n\tcomponents: Set<string>\n\tdirectives: Set<string>\n\n\t// 转换插件\n\tnodeTransforms: TransformFn[]\n\n\t// 替换节点\n\treplaceNode(node: TemplateChildNode): void\n\n\t// 移除节点\n\tremoveNode(node?: TemplateChildNode): void\n\n\t// 遍历子节点\n\ttraverseChildren(parent: TemplateChildNode | RootNode): void\n\n\t// 遍历节点\n\ttraverseNode(node: TemplateChildNode | RootNode): void\n\n\t// 辅助函数\n\thelper(name: symbol): symbol\n\n\t// 错误处理\n\tonError?: (error: CompilerError) => void\n}\n\n// ==================== 编译选项 ====================\n\n/**\n * 编译选项\n */\nexport interface CompilerOptions {\n\t// 是否在开发模式\n\tisBrowser?: boolean\n\n\t// 文件名\n\tfilename?: string\n\n\t// 源码\n\tsource?: string\n\n\t// 前置转换\n\thoistStatic?: boolean\n\n\t// 转换插件\n\tnodeTransforms?: TransformFn[]\n\n\t// 指令转换\n\tdirectiveTransforms?: Record<string, TransformFn>\n\n\t// 表达式转换\n\texpressionTransforms?: Record<string, TransformFn>\n\n\t// 错误处理\n\tonError?: (error: CompilerError) => void\n}\n\n// ==================== 编译结果 ====================\n\n/**\n * 代码生成结果\n */\nexport interface CodegenResult {\n\tcode: string\n\tast: RootNode\n\tpreamble: string\n\tmap?: SourceMap\n}\n\n/**\n * 源码映射(简化版)\n */\nexport interface SourceMap {\n\tfile?: string\n\tmappings: string\n\tnames: string[]\n\tsourceRoot?: string\n\tsources: string[]\n\tsourcesContent?: string[]\n\tversion: number\n}\n\n// ==================== 编译错误 ====================\n\n/**\n * 编译错误\n */\nexport interface CompilerError extends SyntaxError {\n\tcode: number\n\tloc?: SourceLocation\n}\n\n/**\n * 错误代码\n */\nexport const enum ErrorCodes {\n\t// 解析错误\n\tABRUPT_CLOSING_OF_EMPTY_COMMENT,\n\tCDATA_IN_HTML_CONTENT,\n\tDUPLICATE_ATTRIBUTE,\n\tEND_TAG_WITH_ATTRIBUTES,\n\tEND_TAG_WITH_TRAILING_SOLIDUS,\n\tEOF_BEFORE_TAG_NAME,\n\tEOF_IN_CDATA,\n\tEOF_IN_COMMENT,\n\tEOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT,\n\tEOF_IN_TAG,\n\tINCORRECTLY_CLOSED_COMMENT,\n\tINCORRECTLY_OPENED_COMMENT,\n\tINVALID_FIRST_CHARACTER_OF_TAG_NAME,\n\tMISSING_ATTRIBUTE_VALUE,\n\tMISSING_END_TAG_NAME,\n\tMISSING_WHITESPACE_BETWEEN_ATTRIBUTES,\n\tNESTED_COMMENT,\n\tUNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME,\n\tUNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE,\n\tUNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME,\n\tUNEXPECTED_NULL_CHARACTER,\n\tUNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME,\n\tUNEXPECTED_SOLIDUS_IN_TAG,\n\n\t// 转换错误\n\tX_IF_NO_CONDITION,\n\tX_ELIF_NO_ADJACENT_IF,\n\tX_ELSE_NO_ADJACENT_IF,\n\tX_FOR_NO_EXPRESSION,\n\tX_FOR_MALFORMED_EXPRESSION,\n\n\t// 未知错误\n\tUNKNOWN_ERROR\n}","/**\n * AST 节点创建和工具函数\n */\n\nimport {\n\tNodeTypes,\n\tRootNode,\n\tElementNode,\n\tTextNode,\n\tInterpolationNode,\n\tIfNode,\n\tIfBranchNode,\n\tForNode,\n\tAttributeNode,\n\tDirectiveNode,\n\tSimpleExpressionNode,\n\tCompoundExpressionNode,\n\tElementTypes,\n\tSourceLocation,\n\tPosition,\n\tJSCallExpression,\n\tJSObjectExpression,\n\tJSArrayExpression,\n\tJSFunctionExpression,\n\tJSConditionalExpression,\n\tJSChildNode,\n\tTemplateChildNode\n} from './types'\nimport { warn } from '@fluxion-ui/shared'\n\n// ==================== 位置相关 ====================\n\n/**\n * 默认位置\n */\nexport const defaultPosition: Position = {\n\toffset: 0,\n\tline: 1,\n\tcolumn: 1\n}\n\n/**\n * 默认源码位置\n */\nexport const defaultLoc: SourceLocation = {\n\tstart: defaultPosition,\n\tend: defaultPosition,\n\tsource: ''\n}\n\n/**\n * 创建位置对象\n */\nexport function createPosition(\n\toffset: number,\n\tline: number,\n\tcolumn: number\n): Position {\n\treturn { offset, line, column }\n}\n\n/**\n * 创建源码位置对象\n */\nexport function createSourceLocation(\n\tstart: Position,\n\tend: Position,\n\tsource: string\n): SourceLocation {\n\treturn { start, end, source }\n}\n\n// ==================== 根节点 ====================\n\n/**\n * 创建根节点\n */\nexport function createRoot(\n\tchildren: TemplateChildNode[] = [],\n\tloc: SourceLocation = defaultLoc\n): RootNode {\n\treturn {\n\t\ttype: NodeTypes.ROOT,\n\t\tchildren,\n\t\thelpers: new Set(),\n\t\tcomponents: new Set(),\n\t\tdirectives: new Set(),\n\t\timports: new Set(),\n\t\tloc\n\t}\n}\n\n// ==================== 元素节点 ====================\n\n/**\n * 创建元素节点\n */\nexport function createElementNode(\n\ttag: string,\n\tprops: Array<AttributeNode | DirectiveNode> = [],\n\tchildren: TemplateChildNode[] = [],\n\tloc: SourceLocation = defaultLoc,\n\tisSelfClosing: boolean = false\n): ElementNode {\n\treturn {\n\t\ttype: NodeTypes.ELEMENT,\n\t\ttag,\n\t\tprops,\n\t\tchildren,\n\t\tisSelfClosing,\n\t\tloc\n\t}\n}\n\n// ==================== 文本节点 ====================\n\n/**\n * 创建文本节点\n */\nexport function createTextNode(\n\tcontent: string = '',\n\tloc: SourceLocation = defaultLoc\n): TextNode {\n\treturn {\n\t\ttype: NodeTypes.TEXT,\n\t\tcontent,\n\t\tloc\n\t}\n}\n\n// ==================== 插值节点 ====================\n\n/**\n * 创建插值节点\n */\nexport function createInterpolationNode(\n\tcontent: string | ExpressionNode,\n\tloc: SourceLocation = defaultLoc\n): InterpolationNode {\n\tconst expression = typeof content === 'string'\n\t\t? createSimpleExpression(content, false, loc)\n\t\t: content\n\n\treturn {\n\t\ttype: NodeTypes.INTERPOLATION,\n\t\tcontent: expression,\n\t\tloc\n\t}\n}\n\n// ==================== 属性节点 ====================\n\n/**\n * 创建属性节点\n */\nexport function createAttributeNode(\n\tname: string,\n\tvalue: string | TextNode | null = null,\n\tloc: SourceLocation = defaultLoc\n): AttributeNode {\n\tconst valueNode = typeof value === 'string'\n\t\t? createTextNode(value, loc)\n\t\t: value\n\n\treturn {\n\t\ttype: NodeTypes.ATTRIBUTE,\n\t\tname,\n\t\tvalue: valueNode,\n\t\tloc\n\t}\n}\n\n/**\n * 创建指令节点\n */\nexport function createDirectiveNode(\n\tname: string,\n\texp: string | ExpressionNode | null = null,\n\targ: string | ExpressionNode | null = null,\n\tmodifiers: string[] = [],\n\tloc: SourceLocation = defaultLoc\n): DirectiveNode {\n\tconst expNode = typeof exp === 'string'\n\t\t? createSimpleExpression(exp, false, loc)\n\t\t: exp\n\n\tconst argNode = typeof arg === 'string'\n\t\t? createSimpleExpression(arg, true, loc)\n\t\t: arg\n\n\treturn {\n\t\ttype: NodeTypes.DIRECTIVE,\n\t\tname,\n\t\texp: expNode,\n\t\targ: argNode,\n\t\tmodifiers,\n\t\tloc\n\t}\n}\n\n// ==================== 表达式节点 ====================\n\n/**\n * 表达式节点类型\n */\nexport type ExpressionNode = SimpleExpressionNode | CompoundExpressionNode\n\n/**\n * 创建简单表达式节点\n */\nexport function createSimpleExpression(\n\tcontent: string,\n\tisStatic: boolean = false,\n\tloc: SourceLocation = defaultLoc,\n\tidentifiers?: string[]\n): SimpleExpressionNode {\n\treturn {\n\t\ttype: NodeTypes.SIMPLE_EXPRESSION,\n\t\tcontent,\n\t\tisStatic,\n\t\tloc,\n\t\tidentifiers\n\t}\n}\n\n/**\n * 创建复合表达式节点\n */\nexport function createCompoundExpression(\n\tchildren: (SimpleExpressionNode | CompoundExpressionNode | InterpolationNode | TextNode | string)[],\n\tloc: SourceLocation = defaultLoc\n): CompoundExpressionNode {\n\treturn {\n\t\ttype: NodeTypes.COMPOUND_EXPRESSION,\n\t\tchildren,\n\t\tloc\n\t}\n}\n\n// ==================== 控制流节点 ====================\n\n/**\n * 创建 if 节点\n */\nexport function createIfNode(\n\tbranches: IfBranchNode[],\n\tloc: SourceLocation = defaultLoc\n): IfNode {\n\treturn {\n\t\ttype: NodeTypes.IF,\n\t\tbranches,\n\t\tloc\n\t}\n}\n\n/**\n * 创建 if 分支节点\n */\nexport function createIfBranchNode(\n\tchildren: TemplateChildNode[],\n\tcondition?: ExpressionNode,\n\tloc: SourceLocation = defaultLoc\n): IfBranchNode {\n\treturn {\n\t\ttype: NodeTypes.IF_BRANCH,\n\t\tchildren,\n\t\tcondition,\n\t\tloc\n\t}\n}\n\n/**\n * 创建 for 节点\n */\nexport function createForNode(\n\tsource: ExpressionNode,\n\tvalueAlias: string,\n\tchildren: TemplateChildNode[],\n\tkeyAlias?: string,\n\tindexAlias?: string,\n\tloc: SourceLocation = defaultLoc\n): ForNode {\n\treturn {\n\t\ttype: NodeTypes.FOR,\n\t\tsource,\n\t\tvalueAlias,\n\t\tkeyAlias,\n\t\tindexAlias,\n\t\tchildren,\n\t\tloc\n\t}\n}\n\n// ==================== JS 代码节点 ====================\n\n/**\n * 创建 JS 函数调用表达式\n */\nexport function createCallExpression(\n\tcallee: string | symbol,\n\targs: (string | JSChildNode)[] = [],\n\tloc: SourceLocation = defaultLoc\n): JSCallExpression {\n\treturn {\n\t\ttype: NodeTypes.JS_CALL_EXPRESSION,\n\t\tcallee,\n\t\targuments: args,\n\t\tloc\n\t}\n}\n\n/**\n * 创建 JS 对象表达式\n */\nexport function createObjectExpression(\n\tproperties: Array<{ key: string | ExpressionNode; value: JSChildNode | string }> = [],\n\tloc: SourceLocation = defaultLoc\n): JSObjectExpression {\n\treturn {\n\t\ttype: NodeTypes.JS_OBJECT_EXPRESSION,\n\t\tproperties,\n\t\tloc\n\t}\n}\n\n/**\n * 创建 JS 数组表达式\n */\nexport function createArrayExpression(\n\telements: (JSChildNode | string | null)[] = [],\n\tloc: SourceLocation = defaultLoc\n): JSArrayExpression {\n\treturn {\n\t\ttype: NodeTypes.JS_ARRAY_EXPRESSION,\n\t\telements,\n\t\tloc\n\t}\n}\n\n/**\n * 创建 JS 函数表达式\n */\nexport function createFunctionExpression(\n\tparams: string[] | ExpressionNode[] = [],\n\treturns?: JSChildNode,\n\tnewline: boolean = false,\n\tisSlot: boolean = false,\n\tloc: SourceLocation = defaultLoc\n): JSFunctionExpression {\n\treturn {\n\t\ttype: NodeTypes.JS_FUNCTION_EXPRESSION,\n\t\tparams,\n\t\treturns,\n\t\tnewline,\n\t\tisSlot,\n\t\tloc\n\t}\n}\n\n/**\n * 创建 JS 条件表达式\n */\nexport function createConditionalExpression(\n\ttest: JSChildNode,\n\tconsequent: JSChildNode,\n\talternate: JSChildNode | JSConditionalExpression,\n\tnewline: boolean = true,\n\tloc: SourceLocation = defaultLoc\n): JSConditionalExpression {\n\treturn {\n\t\ttype: NodeTypes.JS_CONDITIONAL_EXPRESSION,\n\t\ttest,\n\t\tconsequent,\n\t\talternate,\n\t\tnewline,\n\t\tloc\n\t}\n}\n\n// ==================== 工具函数 ====================\n\n/**\n * 判断是否为元素节点\n */\nexport function isElementNode(node: any): node is ElementNode {\n\treturn node?.type === NodeTypes.ELEMENT\n}\n\n/**\n * 判断是否为文本节点\n */\nexport function isTextNode(node: any): node is TextNode {\n\treturn node?.type === NodeTypes.TEXT\n}\n\n/**\n * 判断是否为插值节点\n */\nexport function isInterpolationNode(node: any): node is InterpolationNode {\n\treturn node?.type === NodeTypes.INTERPOLATION\n}\n\n/**\n * 判断是否为 if 节点\n */\nexport function isIfNode(node: any): node is IfNode {\n\treturn node?.type === NodeTypes.IF\n}\n\n/**\n * 判断是否为 for 节点\n */\nexport function isForNode(node: any): node is ForNode {\n\treturn node?.type === NodeTypes.FOR\n}\n\n/**\n * 判断是否为简单表达式节点\n */\nexport function isSimpleExpressionNode(node: any): node is SimpleExpressionNode {\n\treturn node?.type === NodeTypes.SIMPLE_EXPRESSION\n}\n\n/**\n * 判断是否为复合表达式节点\n */\nexport function isCompoundExpressionNode(node: any): node is CompoundExpressionNode {\n\treturn node?.type === NodeTypes.COMPOUND_EXPRESSION\n}\n\n/**\n * 获取节点的所有子节点\n */\nexport function getNodeChildren(node: RootNode | ElementNode | IfNode | ForNode): TemplateChildNode[] {\n\tswitch (node.type) {\n\t\tcase NodeTypes.ROOT:\n\t\tcase NodeTypes.ELEMENT:\n\t\tcase NodeTypes.IF_BRANCH:\n\t\tcase NodeTypes.FOR:\n\t\t\treturn node.children\n\t\tcase NodeTypes.IF:\n\t\t\treturn node.branches\n\t\tdefault:\n\t\t\treturn []\n\t}\n}\n\n/**\n * 克隆 AST 节点\n */\nexport function cloneNode<T extends BaseNode>(node: T): T {\n\tconst cloned = { ...node }\n\tif (node.loc) {\n\t\tcloned.loc = { ...node.loc }\n\t}\n\treturn cloned\n}","/**\n * AST 转换核心\n * 负责遍历 AST 并执行转换插件\n */\n\nimport {\n\tNodeTypes,\n\tRootNode,\n\tTemplateChildNode,\n\tTransformContext,\n\tTransformFn,\n\tCompilerOptions,\n\tCompilerError\n} from './types'\nimport { createRoot, getNodeChildren } from './ast'\nimport { warn } from '@fluxion-ui/shared'\n\n/**\n * 创建转换上下文\n */\nexport function createTransformContext(\n\troot: RootNode,\n\toptions: CompilerOptions = {}\n): TransformContext {\n\tconst context: TransformContext = {\n\t\troot,\n\t\tparent: null,\n\t\tchildIndex: 0,\n\t\tcurrentNode: null,\n\n\t\thelpers: new Set(),\n\t\tcomponents: new Set(),\n\t\tdirectives: new Set(),\n\n\t\t// 转换插件\n\t\tnodeTransforms: options.nodeTransforms || [],\n\n\t\t// 替换当前节点\n\t\treplaceNode(node: TemplateChildNode) {\n\t\t\tif (!context.parent) {\n\t\t\t\twarn('replaceNode: 没有父节点')\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// 更新父节点的 children\n\t\t\tconst parentChildren = getNodeChildren(context.parent as any)\n\t\t\tif (parentChildren) {\n\t\t\t\tparentChildren[context.childIndex] = node\n\t\t\t}\n\n\t\t\tcontext.currentNode = node\n\t\t},\n\n\t\t// 移除当前节点\n\t\tremoveNode(node?: TemplateChildNode) {\n\t\t\tif (!context.parent) {\n\t\t\t\twarn('removeNode: 没有父节点')\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst parentChildren = getNodeChildren(context.parent as any)\n\t\t\tif (parentChildren) {\n\t\t\t\tconst index = node\n\t\t\t\t\t? parentChildren.indexOf(node)\n\t\t\t\t\t: context.childIndex\n\n\t\t\t\tif (index > -1) {\n\t\t\t\t\tparentChildren.splice(index, 1)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcontext.currentNode = null\n\t\t},\n\n\t\t// 遍历子节点\n\t\ttraverseChildren(parent: TemplateChildNode | RootNode) {\n\t\t\ttraverseChildren(parent, context)\n\t\t},\n\n\t\t// 遍历节点\n\t\ttraverseNode(node: TemplateChildNode | RootNode) {\n\t\t\ttraverseNode(node, context)\n\t\t},\n\n\t\t// 辅助函数\n\t\thelper(name: symbol): symbol {\n\t\t\tcontext.helpers.add(name)\n\t\t\treturn name\n\t\t},\n\n\t\t// 错误处理\n\t\tonError: options.onError\n\t}\n\n\treturn context\n}\n\n/**\n * 执行 AST 转换\n * @param root 根节点\n * @param options 编译选项\n */\nexport function transform(root: RootNode, options: CompilerOptions = {}): void {\n\t// 创建转换上下文\n\tconst context = createTransformContext(root, options)\n\n\t// 遍历根节点\n\ttraverseNode(root, context)\n\n\t// 将 helpers 添加到根节点\n\troot.helpers = new Set([...root.helpers, ...context.helpers])\n\troot.components = new Set([...root.components, ...context.components])\n\troot.directives = new Set([...root.directives, ...context.directives])\n}\n\n/**\n * 遍历 AST 节点\n */\nexport function traverseNode(\n\tnode: TemplateChildNode | RootNode,\n\tcontext: TransformContext\n): void {\n\t// 设置当前节点\n\tcontext.currentNode = node\n\n\t// 获取转换插件\n\tconst { nodeTransforms } = context\n\n\t// 存储退出函数\n\tconst exitFns: (() => void)[] = []\n\n\t// 执行所有转换插件\n\tif (nodeTransforms) {\n\t\tfor (const transform of nodeTransforms) {\n\t\t\tconst onExit = transform(node as TemplateChildNode, context)\n\n\t\t\t// 如果节点被移除,直接返回\n\t\t\tif (!context.currentNode) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// 收集退出函数\n\t\t\tif (onExit) {\n\t\t\t\tif (Array.isArray(onExit)) {\n\t\t\t\t\texitFns.push(...onExit)\n\t\t\t\t} else {\n\t\t\t\t\texitFns.push(onExit)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// 根据节点类型继续遍历子节点\n\tswitch (node.type) {\n\t\tcase NodeTypes.ROOT:\n\t\tcase NodeTypes.ELEMENT:\n\t\tcase NodeTypes.IF:\n\t\tcase NodeTypes.FOR:\n\t\t\ttraverseChildren(node, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.IF_BRANCH:\n\t\t\t// if 分支也需要遍历子节点\n\t\t\ttraverseChildren(node, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.TEXT:\n\t\tcase NodeTypes.INTERPOLATION:\n\t\tcase NodeTypes.SIMPLE_EXPRESSION:\n\t\tcase NodeTypes.COMPOUND_EXPRESSION:\n\t\t\t// 这些节点没有子节点,无需处理\n\t\t\tbreak\n\t}\n\n\t// 逆序执行退出函数\n\tcontext.currentNode = node\n\tlet i = exitFns.length\n\twhile (i--) {\n\t\texitFns[i]()\n\t}\n}\n\n/**\n * 遍历子节点\n */\nexport function traverseChildren(\n\tparent: TemplateChildNode | RootNode,\n\tcontext: TransformContext\n): void {\n\t// 获取子节点\n\tconst children = getNodeChildren(parent as any)\n\n\tif (!children || children.length === 0) {\n\t\treturn\n\t}\n\n\t// 保存父节点\n\tconst parentStack: (TemplateChildNode | RootNode)[] = []\n\tlet currentParent = context.parent\n\n\t// 设置新的父节点\n\tcontext.parent = parent as TemplateChildNode\n\n\t// 遍历子节点\n\tfor (let i = 0; i < children.length; i++) {\n\t\tcontext.childIndex = i\n\t\ttraverseNode(children[i], context)\n\t}\n\n\t// 恢复父节点\n\tcontext.parent = currentParent\n}\n\n/**\n * 创建简单的转换插件\n */\nexport function createTransform(\n\ttypes: NodeTypes[],\n\tfn: TransformFn\n): TransformFn {\n\treturn (node, context) => {\n\t\tif (types.includes(node.type)) {\n\t\t\treturn fn(node, context)\n\t\t}\n\t}\n}","/**\n * if/elif/else 转换插件\n * 将 if 节点转换为三元表达式\n */\n\nimport {\n\tNodeTypes,\n\tIfNode,\n\tIfBranchNode,\n\tTemplateChildNode,\n\tTransformContext,\n\tJSConditionalExpression,\n\tSimpleExpressionNode\n} from '../types'\nimport {\n\tcreateConditionalExpression,\n\tcreateSimpleExpression,\n\tisIfNode\n} from '../ast'\nimport { warn } from '@fluxion-ui/shared'\n\n/**\n * if 转换插件\n *\n * 将:\n * if loading\n * p loading...\n * else\n * p loaded\n *\n * 转换为:\n * loading() ? h(\"p\", \"loading...\") : h(\"p\", \"loaded\")\n */\nexport function transformIf(node: TemplateChildNode, context: TransformContext) {\n\tif (!isIfNode(node)) {\n\t\treturn\n\t}\n\n\t// 处理 if 节点\n\tprocessIf(node, context)\n}\n\n/**\n * 处理 if 节点\n */\nfunction processIf(node: IfNode, context: TransformContext) {\n\tconst { branches } = node\n\n\t// 校验分支\n\tif (branches.length === 0) {\n\t\twarn('transformIf: if 节点没有分支')\n\t\treturn\n\t}\n\n\t// 生成条件表达式\n\tconst codegenNode = createIfCodegen(node, context)\n\n\tif (codegenNode) {\n\t\tnode.codegenNode = codegenNode\n\t}\n}\n\n/**\n * 创建 if 的代码生成节点\n */\nfunction createIfCodegen(\n\tnode: IfNode,\n\tcontext: TransformContext\n): JSConditionalExpression | SimpleExpressionNode | undefined {\n\tconst { branches } = node\n\n\t// 从最后一个分支开始构建\n\tlet currentBranch = branches[branches.length - 1]\n\n\t// 最后一个分支(else 或最后一个 elif)\n\tlet alternate = createBranchCodegen(currentBranch, context)\n\n\t// 从后往前构建三元表达式\n\tfor (let i = branches.length - 2; i >= 0; i--) {\n\t\tconst branch = branches[i]\n\n\t\t// 创建条件表达式\n\t\talternate = createConditionalExpression(\n\t\t\tcreateConditionCodegen(branch, context),\n\t\t\tcreateBranchCodegen(branch, context),\n\t\t\talternate,\n\t\t\ttrue\n\t\t)\n\t}\n\n\treturn alternate as JSConditionalExpression\n}\n\n/**\n * 创建条件表达式的测试部分\n */\nfunction createConditionCodegen(\n\tbranch: IfBranchNode,\n\tcontext: TransformContext\n): SimpleExpressionNode {\n\tif (!branch.condition) {\n\t\t// else 分支不应该有条件\n\t\twarn('transformIf: if 分支缺少条件')\n\t\treturn createSimpleExpression('true', false)\n\t}\n\n\t// 如果条件是简单表达式,需要加上 () 调用(signal)\n\tconst condition = branch.condition\n\n\t// 返回条件表达式\n\t// 注意:signal 变量需要加 () 来获取值\n\t// 这里我们假设条件表达式已经正确处理\n\treturn createSimpleExpression(\n\t\twrapSignalCall(condition.content),\n\t\tfalse\n\t)\n}\n\n/**\n * 创建分支的代码生成节点\n */\nfunction createBranchCodegen(\n\tbranch: IfBranchNode,\n\tcontext: TransformContext\n): SimpleExpressionNode {\n\t// 如果分支只有一个子节点\n\tif (branch.children.length === 1) {\n\t\tconst child = branch.children[0]\n\t\t// 元素节点应该已经有 codegenNode\n\t\tif (child.type === NodeTypes.ELEMENT && (child as any).codegenNode) {\n\t\t\treturn (child as any).codegenNode\n\t\t}\n\t}\n\n\t// 多个子节点或没有 codegenNode,返回一个占位符\n\t// 实际的代码生成会在 codegen 阶段处理\n\treturn createSimpleExpression(\n\t\t`/* branch with ${branch.children.length} children */`,\n\t\tfalse\n\t)\n}\n\n/**\n * 包装 signal 调用\n * 将 count 转换为 count()\n */\nfunction wrapSignalCall(content: string): string {\n\t// 简单的标识符,可能是 signal\n\tif (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(content)) {\n\t\t// 检查是否已经包含函数调用\n\t\tif (!content.includes('(')) {\n\t\t\treturn `${content}()`\n\t\t}\n\t}\n\treturn content\n}\n\n/**\n * 检查节点是否为有效的 if 分支\n */\nexport function isValidIfBranch(node: any): boolean {\n\treturn node?.type === NodeTypes.IF_BRANCH\n}\n\n/**\n * 获取 if 分支的类型\n */\nexport function getIfBranchType(branch: IfBranchNode): 'if' | 'elif' | 'else' {\n\tif (!branch.condition) {\n\t\treturn 'else'\n\t}\n\treturn 'if' // elif 和 if 在 AST 中是一样的,区别在于位置\n}","/**\n * 运行时辅助函数符号\n * 用于在编译时标识需要导入的运行时函数\n */\n\n/**\n * 运行时辅助函数名称映射\n */\nexport const enum RuntimeHelperNames {\n\t// VNode 创建\n\tCREATE_ELEMENT_VNODE = 'h',\n\tCREATE_TEXT_VNODE = 'createTextVNode',\n\tCREATE_COMMENT_VNODE = 'createCommentVNode',\n\n\t// 组件相关\n\tRESOLVE_COMPONENT = 'resolveComponent',\n\tRESOLVE_DIRECTIVE = 'resolveDirective',\n\n\t// 渲染相关\n\tRENDER_LIST = 'renderList',\n\tRENDER_SLOT = 'renderSlot',\n\n\t// 工具函数\n\tMERGE_PROPS = 'mergeProps',\n\tNORMALIZE_CLASS = 'normalizeClass',\n\tNORMALIZE_STYLE = 'normalizeStyle',\n\tNORMALIZE_PROPS = 'normalizeProps',\n\n\t// 事件处理\n\tWITH_DIRECTIVES = 'withDirectives',\n\tWITH_CTX = 'withCtx'\n}\n\n/**\n * 运行时辅助函数符号\n */\nexport const runtimeHelpers = {\n\t// VNode 创建\n\tCREATE_ELEMENT_VNODE: Symbol(RuntimeHelperNames.CREATE_ELEMENT_VNODE),\n\tCREATE_TEXT_VNODE: Symbol(RuntimeHelperNames.CREATE_TEXT_VNODE),\n\tCREATE_COMMENT_VNODE: Symbol(RuntimeHelperNames.CREATE_COMMENT_VNODE),\n\n\t// 组件相关\n\tRESOLVE_COMPONENT: Symbol(RuntimeHelperNames.RESOLVE_COMPONENT),\n\tRESOLVE_DIRECTIVE: Symbol(RuntimeHelperNames.RESOLVE_DIRECTIVE),\n\n\t// 渲染相关\n\tRENDER_LIST: Symbol(RuntimeHelperNames.RENDER_LIST),\n\tRENDER_SLOT: Symbol(RuntimeHelperNames.RENDER_SLOT),\n\n\t// 工具函数\n\tMERGE_PROPS: Symbol(RuntimeHelperNames.MERGE_PROPS),\n\tNORMALIZE_CLASS: Symbol(RuntimeHelperNames.NORMALIZE_CLASS),\n\tNORMALIZE_STYLE: Symbol(RuntimeHelperNames.NORMALIZE_STYLE),\n\tNORMALIZE_PROPS: Symbol(RuntimeHelperNames.NORMALIZE_PROPS),\n\n\t// 事件处理\n\tWITH_DIRECTIVES: Symbol(RuntimeHelperNames.WITH_DIRECTIVES),\n\tWITH_CTX: Symbol(RuntimeHelperNames.WITH_CTX)\n} as const\n\n/**\n * 获取运行时辅助函数名称\n */\nexport function getRuntimeHelperName(symbol: symbol): string {\n\tfor (const [key, value] of Object.entries(runtimeHelpers)) {\n\t\tif (value === symbol) {\n\t\t\treturn RuntimeHelperNames[key as keyof typeof RuntimeHelperNames]\n\t\t}\n\t}\n\treturn ''\n}\n\n/**\n * 判断是否为运行时辅助函数\n */\nexport function isRuntimeHelper(value: unknown): value is symbol {\n\treturn typeof value === 'symbol' && Object.values(runtimeHelpers).includes(value)\n}","/**\n * for 循环转换插件\n * 将 for 节点转换为 map 调用\n */\n\nimport {\n\tNodeTypes,\n\tForNode,\n\tTemplateChildNode,\n\tTransformContext,\n\tJSCallExpression,\n\tJSFunctionExpression,\n\tJSArrayExpression,\n\tSimpleExpressionNode\n} from '../types'\nimport {\n\tcreateCallExpression,\n\tcreateFunctionExpression,\n\tcreateSimpleExpression,\n\tcreateArrayExpression,\n\tisForNode\n} from '../ast'\nimport { runtimeHelpers } from '../runtimeHelpers'\nimport { warn } from '@fluxion-ui/shared'\n\n/**\n * for 转换插件\n *\n * 将:\n * for user in users\n * p {user.name}\n *\n * 转换为:\n * users().map(user => h(\"p\", [user.name]))\n */\nexport function transformFor(node: TemplateChildNode, context: TransformContext) {\n\tif (!isForNode(node)) {\n\t\treturn\n\t}\n\n\t// 处理 for 节点\n\tprocessFor(node, context)\n}\n\n/**\n * 处理 for 节点\n */\nfunction processFor(node: ForNode, context: TransformContext) {\n\tconst { source, valueAlias, keyAlias, indexAlias, children } = node\n\n\t// 校验源表达式\n\tif (!source) {\n\t\twarn('transformFor: for 节点缺少源表达式')\n\t\treturn\n\t}\n\n\t// 添加运行时辅助函数\n\tcontext.helper(runtimeHelpers.CREATE_ELEMENT_VNODE)\n\n\t// 生成代码节点\n\tconst codegenNode = createForCodegen(node, context)\n\n\tif (codegenNode) {\n\t\tnode.codegenNode = codegenNode\n\t}\n}\n\n/**\n * 创建 for 的代码生成节点\n */\nfunction createForCodegen(\n\tnode: ForNode,\n\tcontext: TransformContext\n): JSCallExpression {\n\tconst { source, valueAlias, keyAlias, indexAlias, children } = node\n\n\t// 构建参数列表\n\tconst params: string[] = [valueAlias]\n\tif (keyAlias) {\n\t\tparams.push(keyAlias)\n\t}\n\tif (indexAlias) {\n\t\tparams.push(indexAlias)\n\t}\n\n\t// 创建渲染函数体\n\tlet renderBody: any\n\n\tif (children.length === 1) {\n\t\t// 单个子节点\n\t\tconst child = children[0]\n\t\tif (child.type === NodeTypes.ELEMENT && (child as any).codegenNode) {\n\t\t\trenderBody = (child as any).codegenNode\n\t\t} else {\n\t\t\t// 创建数组包装\n\t\t\trenderBody = createArrayExpression([child as any])\n\t\t}\n\t} else {\n\t\t// 多个子节点,创建数组\n\t\trenderBody = createArrayExpression(\n\t\t\tchildren.map(child => {\n\t\t\t\tif (child.type === NodeTypes.ELEMENT && (child as any).codegenNode) {\n\t\t\t\t\treturn (child as any).codegenNode\n\t\t\t\t}\n\t\t\t\treturn child as any\n\t\t\t})\n\t\t)\n\t}\n\n\t// 创建箭头函数\n\tconst arrowFn = createFunctionExpression(\n\t\tparams,\n\t\trenderBody,\n\t\tfalse, // newline\n\t\tfalse // isSlot\n\t)\n\n\t// 包装源表达式(如果是 signal,需要调用)\n\tconst sourceExpr = wrapSignalCall(source.content)\n\n\t// 创建 map 调用\n\t// source.map(item => ...)\n\tconst mapCall = createCallExpression(\n\t\t`${sourceExpr}.map`,\n\t\t[arrowFn]\n\t)\n\n\treturn mapCall\n}\n\n/**\n * 包装 signal 调用\n * 将 count 转换为 count()\n */\nfunction wrapSignalCall(content: string): string {\n\t// 简单的标识符,可能是 signal\n\tif (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(content)) {\n\t\t// 检查是否已经包含函数调用\n\t\tif (!content.includes('(')) {\n\t\t\treturn `${content}()`\n\t\t}\n\t}\n\treturn content\n}\n\n/**\n * 解析 for 表达式\n * 支持:\n * - for item in list\n * - for (item, index) in list\n * - for (item, key, index) in list\n */\nexport function parseForExpression(\n\tsource: string,\n\tvalueAlias?: string,\n\tkeyAlias?: string,\n\tindexAlias?: string\n): {\n\tsource: string\n\tvalue: string\n\tkey?: string\n\tindex?: string\n} | null {\n\t// 匹配 \"item in list\" 或 \"(item, key, index) in list\"\n\tconst inMatch = source.match(/^\\s*(?:\\(([^)]+)\\)|(\\w+))\\s+in\\s+(.+)$/)\n\n\tif (!inMatch) {\n\t\treturn null\n\t}\n\n\tconst sourceExpr = inMatch[3].trim()\n\n\t// 处理变量\n\tif (inMatch[2]) {\n\t\t// 单变量: for item in list\n\t\treturn {\n\t\t\tsource: sourceExpr,\n\t\t\tvalue: inMatch[2]\n\t\t}\n\t} else {\n\t\t// 多变量: for (item, key, index) in list\n\t\t// 或: for (item, index) in list\n\t\tconst vars = inMatch[1].split(',').map(v => v.trim())\n\t\tconst result: any = {\n\t\t\tsource: sourceExpr,\n\t\t\tvalue: vars[0]\n\t\t}\n\n\t\tif (vars.length === 2) {\n\t\t\t// for (item, index) in list\n\t\t\tresult.index = vars[1]\n\t\t} else if (vars.length >= 3) {\n\t\t\t// for (item, key, index) in list\n\t\t\tresult.key = vars[1]\n\t\t\tresult.index = vars[2]\n\t\t}\n\n\t\treturn result\n\t}\n}\n\n/**\n * 检查节点是否为有效的 for 节点\n */\nexport function isValidForNode(node: any): node is ForNode {\n\treturn isForNode(node) && !!node.source\n}","/**\n * 元素转换插件\n * 将元素节点转换为 h 函数调用\n */\n\nimport {\n\tNodeTypes,\n\tElementNode,\n\tTemplateChildNode,\n\tTransformContext,\n\tJSCallExpression,\n\tJSObjectExpression,\n\tDirectiveNode,\n\tAttributeNode\n} from '../types'\nimport {\n\tcreateCallExpression,\n\tcreateObjectExpression,\n\tcreateSimpleExpression,\n\tcreateArrayExpression,\n\tisElementNode\n} from '../ast'\nimport { runtimeHelpers } from '../runtimeHelpers'\nimport { warn } from '@fluxion-ui/shared'\n\n/**\n * 元素转换插件\n *\n * 将:\n * button @click=increment\n *\n * 转换为:\n * h(\"button\", { onClick: increment })\n */\nexport function transformElement(node: TemplateChildNode, context: TransformContext) {\n\tif (!isElementNode(node)) {\n\t\treturn\n\t}\n\n\t// 返回退出函数,在子节点处理完成后执行\n\treturn () => {\n\t\t// 处理元素节点\n\t\tprocessElement(node, context)\n\t}\n}\n\n/**\n * 处理元素节点\n */\nfunction processElement(node: ElementNode, context: TransformContext) {\n\tconst { tag, props, children, isSelfClosing } = node\n\n\t// 添加运行时辅助函数\n\tcontext.helper(runtimeHelpers.CREATE_ELEMENT_VNODE)\n\n\t// 创建 h 函数调用\n\tconst codegenNode = createElementCodegen(node, context)\n\n\tif (codegenNode) {\n\t\tnode.codegenNode = codegenNode\n\t}\n}\n\n/**\n * 创建元素的代码生成节点\n */\nfunction createElementCodegen(\n\tnode: ElementNode,\n\tcontext: TransformContext\n): JSCallExpression {\n\tconst { tag, props, children } = node\n\n\t// 判断是元素还是组件\n\tconst isComponent = isComponentTag(tag)\n\n\t// 创建参数\n\tconst args: (string | JSCallExpression | JSObjectExpression)[] = []\n\n\t// 第一个参数:标签名或组件\n\tif (isComponent) {\n\t\t// 组件使用变量名\n\t\targs.push(tag)\n\t\tcontext.components.add(tag)\n\t} else {\n\t\t// 元素使用字符串\n\t\targs.push(`\"${tag}\"`)\n\t}\n\n\t// 第二个参数:props 对象\n\tconst propsObj = createPropsObject(props, context)\n\tif (propsObj || children.length > 0) {\n\t\tif (propsObj) {\n\t\t\targs.push(propsObj)\n\t\t} else {\n\t\t\targs.push('null' as any)\n\t\t}\n\t}\n\n\t// 第三个参数:children\n\tif (children.length > 0) {\n\t\tconst childrenArg = createChildrenArg(children, context)\n\t\targs.push(childrenArg as any)\n\t}\n\n\t// 创建 h 函数调用\n\treturn createCallExpression(\n\t\truntimeHelpers.CREATE_ELEMENT_VNODE,\n\t\targs\n\t)\n}\n\n/**\n * 创建 props 对象\n */\nfunction createPropsObject(\n\tprops: Array<AttributeNode | DirectiveNode>,\n\tcontext: TransformContext\n): JSObjectExpression | null {\n\tif (props.length === 0) {\n\t\treturn null\n\t}\n\n\tconst properties: Array<{ key: string; value: any }> = []\n\n\tfor (const prop of props) {\n\t\tif (prop.type === NodeTypes.ATTRIBUTE) {\n\t\t\t// 普通属性\n\t\t\tproperties.push({\n\t\t\t\tkey: prop.name,\n\t\t\t\tvalue: prop.value ? `\"${prop.value.content}\"` : 'true'\n\t\t\t})\n\t\t} else if (prop.type === NodeTypes.DIRECTIVE) {\n\t\t\t// 指令\n\t\t\tconst directiveProp = processDirective(prop, context)\n\t\t\tif (directiveProp) {\n\t\t\t\tproperties.push(directiveProp)\n\t\t\t}\n\t\t}\n\t}\n\n\tif (properties.length === 0) {\n\t\treturn null\n\t}\n\n\treturn createObjectExpression(properties)\n}\n\n/**\n * 处理指令\n */\nfunction processDirective(\n\tdirective: DirectiveNode,\n\tcontext: TransformContext\n): { key: string; value: any } | null {\n\tconst { name, exp, arg, modifiers } = directive\n\n\tswitch (name) {\n\t\tcase 'click':\n\t\tcase 'mousedown':\n\t\tcase 'mouseup':\n\t\tcase 'mouseenter':\n\t\tcase 'mouseleave':\n\t\tcase 'keydown':\n\t\tcase 'keyup':\n\t\tcase 'submit':\n\t\tcase 'input':\n\t\tcase 'change':\n\t\t\t// 事件处理\n\t\t\treturn {\n\t\t\t\tkey: `on${capitalize(name)}`,\n\t\t\t\tvalue: exp ? exp.content : '() => {}'\n\t\t\t}\n\n\t\tcase 'bind':\n\t\t\t// 动态绑定\n\t\t\tif (arg) {\n\t\t\t\treturn {\n\t\t\t\t\tkey: arg.content,\n\t\t\t\t\tvalue: wrapSignalCall(exp?.content || '')\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null\n\n\t\tcase 'model':\n\t\t\t// 双向绑定\n\t\t\t// TODO: 实现 model 指令\n\t\t\treturn null\n\n\t\tdefault:\n\t\t\t// 未知指令,作为事件处理\n\t\t\treturn {\n\t\t\t\tkey: `on${capitalize(name)}`,\n\t\t\t\tvalue: exp ? exp.content : '() => {}'\n\t\t\t}\n\t}\n}\n\n/**\n * 创建 children 参数\n */\nfunction createChildrenArg(\n\tchildren: TemplateChildNode[],\n\tcontext: TransformContext\n): JSCallExpression | any {\n\tif (children.length === 0) {\n\t\treturn null\n\t}\n\n\t// 单个文本节点\n\tif (children.length === 1) {\n\t\tconst child = children[0]\n\t\tif (child.type === NodeTypes.TEXT) {\n\t\t\treturn `\"${child.content}\"`\n\t\t}\n\t\tif (child.type === NodeTypes.INTERPOLATION) {\n\t\t\treturn wrapSignalCall((child.content as any).content)\n\t\t}\n\t\t// 元素节点使用其 codegenNode\n\t\tif (child.type === NodeTypes.ELEMENT && (child as any).codegenNode) {\n\t\t\treturn (child as any).codegenNode\n\t\t}\n\t}\n\n\t// 多个子节点,创建数组\n\tconst elements: any[] = []\n\tfor (const child of children) {\n\t\tif (child.type === NodeTypes.TEXT) {\n\t\t\telements.push(`\"${child.content}\"`)\n\t\t} else if (child.type === NodeTypes.INTERPOLATION) {\n\t\t\telements.push(wrapSignalCall((child.content as any).content))\n\t\t} else if (child.type === NodeTypes.ELEMENT) {\n\t\t\tif ((child as any).codegenNode) {\n\t\t\t\telements.push((child as any).codegenNode)\n\t\t\t}\n\t\t} else if (child.type === NodeTypes.IF) {\n\t\t\tif ((child as any).codegenNode) {\n\t\t\t\telements.push((child as any).codegenNode)\n\t\t\t}\n\t\t} else if (child.type === NodeTypes.FOR) {\n\t\t\tif ((child as any).codegenNode) {\n\t\t\t\telements.push((child as any).codegenNode)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn createArrayExpression(elements)\n}\n\n/**\n * 判断是否为组件标签\n */\nfunction isComponentTag(tag: string): boolean {\n\t// 组件标签以大写字母开头或包含连字符\n\treturn /^[A-Z]/.test(tag) || tag.includes('-')\n}\n\n/**\n * 首字母大写\n */\nfunction capitalize(str: string): string {\n\treturn str.charAt(0).toUpperCase() + str.slice(1)\n}\n\n/**\n * 包装 signal 调用\n */\nfunction wrapSignalCall(content: string): string {\n\tif (!content) return ''\n\t// 简单的标识符,可能是 signal\n\tif (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(content)) {\n\t\tif (!content.includes('(')) {\n\t\t\treturn `${content}()`\n\t\t}\n\t}\n\treturn content\n}","/**\n * 文本插值转换插件\n * 处理文本节点和插值表达式\n */\n\nimport {\n\tNodeTypes,\n\tTextNode,\n\tInterpolationNode,\n\tTemplateChildNode,\n\tTransformContext,\n\tCompoundExpressionNode,\n\tElementNode\n} from '../types'\nimport {\n\tcreateCompoundExpression,\n\tcreateSimpleExpression,\n\tisTextNode,\n\tisInterpolationNode,\n\tisElementNode\n} from '../ast'\nimport { warn } from '@fluxion-ui/shared'\n\n/**\n * 文本转换插件\n *\n * 处理文本和插值的混合情况:\n * - 纯文本:直接使用\n * - 插值表达式:包装 signal 调用\n * - 混合文本:创建复合表达式\n */\nexport function transformText(node: TemplateChildNode, context: TransformContext) {\n\t// 只处理元素节点\n\tif (!isElementNode(node)) {\n\t\treturn\n\t}\n\n\t// 返回退出函数,在子节点处理完成后执行\n\treturn () => {\n\t\tprocessText(node, context)\n\t}\n}\n\n/**\n * 处理元素中的文本\n */\nfunction processText(node: ElementNode, context: TransformContext) {\n\tconst { children } = node\n\n\t// 遍历子节点,合并相邻的文本和插值\n\tlet hasText = false\n\tlet currentContainer: CompoundExpressionNode | null = null\n\n\tfor (let i = 0; i < children.length; i++) {\n\t\tconst child = children[i]\n\n\t\tif (isTextNode(child) || isInterpolationNode(child)) {\n\t\t\thasText = true\n\n\t\t\t// 如果前一个节点也是文本或插值,合并到复合表达式\n\t\t\tif (currentContainer) {\n\t\t\t\t// 添加到复合表达式\n\t\t\t\tif (isTextNode(child)) {\n\t\t\t\t\t// 文本节点\n\t\t\t\t\tcurrentContainer.children.push(child.content)\n\t\t\t\t} else {\n\t\t\t\t\t// 插值节点,包装 signal 调用\n\t\t\t\t\tconst content = (child.content as any).content\n\t\t\t\t\tcurrentContainer.children.push(\n\t\t\t\t\t\tcreateSimpleExpression(wrapSignalCall(content), false)\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\t// 移除当前节点(已合并)\n\t\t\t\tchildren.splice(i, 1)\n\t\t\t\ti--\n\t\t\t} else {\n\t\t\t\t// 创建新的复合表达式\n\t\t\t\tif (isTextNode(child)) {\n\t\t\t\t\t// 检查下一个节点是否也是文本/插值\n\t\t\t\t\tconst next = children[i + 1]\n\t\t\t\t\tif (next && (isTextNode(next) || isInterpolationNode(next))) {\n\t\t\t\t\t\t// 创建复合表达式\n\t\t\t\t\t\tcurrentContainer = createCompoundExpression([child.content])\n\t\t\t\t\t\t// 替换当前节点\n\t\t\t\t\t\tchildren[i] = currentContainer as any\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// 插值节点\n\t\t\t\t\tconst content = (child.content as any).content\n\t\t\t\t\tconst next = children[i + 1]\n\t\t\t\t\tif (next && (isTextNode(next) || isInterpolationNode(next))) {\n\t\t\t\t\t\t// 创建复合表达式\n\t\t\t\t\t\tcurrentContainer = createCompoundExpression([\n\t\t\t\t\t\t\tcreateSimpleExpression(wrapSignalCall(content), false)\n\t\t\t\t\t\t])\n\t\t\t\t\t\t// 替换当前节点\n\t\t\t\t\t\tchildren[i] = currentContainer as any\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// 单独的插值,直接包装\n\t\t\t\t\t\t;(child as any).content = createSimpleExpression(\n\t\t\t\t\t\t\twrapSignalCall(content),\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// 非文本节点,重置容器\n\t\t\tcurrentContainer = null\n\t\t}\n\t}\n\n\t// 如果没有文本节点,不需要处理\n\tif (!hasText) {\n\t\treturn\n\t}\n}\n\n/**\n * 包装 signal 调用\n * 将 count 转换为 count()\n */\nfunction wrapSignalCall(content: string): string {\n\tif (!content) return ''\n\t// 简单的标识符,可能是 signal\n\tif (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(content)) {\n\t\tif (!content.includes('(')) {\n\t\t\treturn `${content}()`\n\t\t}\n\t}\n\treturn content\n}\n\n/**\n * 检查节点是否包含文本\n */\nexport function hasTextChildren(node: ElementNode): boolean {\n\treturn node.children.some(\n\t\tchild => isTextNode(child) || isInterpolationNode(child)\n\t)\n}\n\n/**\n * 规范化文本内容\n */\nexport function normalizeTextContent(node: ElementNode): string {\n\tconst parts: string[] = []\n\n\tfor (const child of node.children) {\n\t\tif (isTextNode(child)) {\n\t\t\tparts.push(child.content)\n\t\t} else if (isInterpolationNode(child)) {\n\t\t\tparts.push(`{${(child.content as any).content}}`)\n\t\t}\n\t}\n\n\treturn parts.join('')\n}","/**\n * 转换插件统一导出\n */\n\nexport { transformIf, isValidIfBranch, getIfBranchType } from './vIf'\nexport { transformFor, isValidForNode, parseForExpression } from './vFor'\nexport { transformElement } from './transformElement'\nexport { transformText, hasTextChildren, normalizeTextContent } from './transformText'\n\n// 默认转换插件集合\nimport { TransformFn } from '../types'\nimport { transformIf } from './vIf'\nimport { transformFor } from './vFor'\nimport { transformElement } from './transformElement'\nimport { transformText } from './transformText'\n\n/**\n * 获取默认的节点转换插件\n */\nexport function getDefaultTransforms(): TransformFn[] {\n\treturn [\n\t\ttransformIf,\n\t\ttransformFor,\n\t\ttransformElement,\n\t\ttransformText\n\t]\n}","/**\n * 代码生成核心\n * 将 AST 转换为 JavaScript 代码\n */\n\nimport {\n\tNodeTypes,\n\tRootNode,\n\tTemplateChildNode,\n\tCodegenResult,\n\tJSChildNode,\n\tJSCallExpression,\n\tJSObjectExpression,\n\tJSArrayExpression,\n\tJSFunctionExpression,\n\tJSConditionalExpression,\n\tSimpleExpressionNode,\n\tCompoundExpressionNode,\n\tElementNode,\n\tTextNode,\n\tInterpolationNode,\n\tIfNode,\n\tForNode\n} from '../types'\nimport { isRuntimeHelper, runtimeHelpers, getRuntimeHelperName } from '../runtimeHelpers'\nimport { warn } from '@fluxion-ui/shared'\n\n// ==================== 代码生成上下文 ====================\n\n/**\n * 代码生成上下文\n */\ninterface CodegenContext {\n\t// 生成的代码\n\tcode: string\n\n\t// 缩进级别\n\tindentLevel: number\n\n\t// 缩进字符串\n\tindent: (level?: number) => string\n\n\t// 换行\n\tnewline: () => string\n\n\t// 推送代码\n\tpush: (code: string) => void\n\n\t// 缩进\n\tindentCode: () => void\n\n\t// 取消缩进\n\tdeindent: () => void\n}\n\n/**\n * 创建代码生成上下文\n */\nfunction createCodegenContext(): CodegenContext {\n\tconst context: CodegenContext = {\n\t\tcode: '',\n\t\tindentLevel: 0,\n\n\t\tindent(level: number = context.indentLevel) {\n\t\t\treturn ' '.repeat(level)\n\t\t},\n\n\t\tnewline() {\n\t\t\treturn '\\n'\n\t\t},\n\n\t\tpush(code: string) {\n\t\t\tcontext.code += code\n\t\t},\n\n\t\tindentCode() {\n\t\t\tcontext.indentLevel++\n\t\t},\n\n\t\tdeindent() {\n\t\t\tcontext.indentLevel--\n\t\t}\n\t}\n\n\treturn context\n}\n\n// ==================== 代码生成入口 ====================\n\n/**\n * 生成代码\n */\nexport function generate(ast: RootNode): CodegenResult {\n\tconst context = createCodegenContext()\n\n\t// 生成前导代码(导入等)\n\tgenFunctionPreamble(ast, context)\n\n\t// 生成 render 函数\n\tgenRenderFunction(ast, context)\n\n\treturn {\n\t\tcode: context.code,\n\t\tast,\n\t\tpreamble: ''\n\t}\n}\n\n/**\n * 生成函数前导代码(导入语句)\n */\nfunction genFunctionPreamble(ast: RootNode, context: CodegenContext) {\n\t// 如果有帮助函数,生成导入语句\n\tif (ast.helpers.size > 0) {\n\t\t// 收集需要的运行时函数\n\t\tconst imports: string[] = []\n\n\t\tfor (const helper of ast.helpers) {\n\t\t\tconst name = getRuntimeHelperName(helper)\n\t\t\tif (name && !imports.includes(name)) {\n\t\t\t\timports.push(name)\n\t\t\t}\n\t\t}\n\n\t\tif (imports.length > 0) {\n\t\t\tcontext.push(`import { ${imports.join(', ')} } from '@fluxion-ui/fluxion/runtime'\\n`)\n\t\t}\n\t}\n\n\t// 添加空行\n\tcontext.push('\\n')\n}\n\n/**\n * 生成 render 函数\n */\nfunction genRenderFunction(ast: RootNode, context: CodegenContext) {\n\tcontext.push('export function render() {\\n')\n\tcontext.indentCode()\n\n\tcontext.push(context.indent())\n\tcontext.push('return ')\n\n\t// 生成根节点的子节点\n\tif (ast.children.length === 1) {\n\t\t// 单个子节点\n\t\tgenNode(ast.children[0], context)\n\t} else if (ast.children.length > 1) {\n\t\t// 多个子节点,生成数组\n\t\tcontext.push('[\\n')\n\t\tcontext.indentCode()\n\n\t\tfor (let i = 0; i < ast.children.length; i++) {\n\t\t\tcontext.push(context.indent())\n\t\t\tgenNode(ast.children[i], context)\n\n\t\t\tif (i < ast.children.length - 1) {\n\t\t\t\tcontext.push(',')\n\t\t\t}\n\t\t\tcontext.push('\\n')\n\t\t}\n\n\t\tcontext.deindent()\n\t\tcontext.push(context.indent())\n\t\tcontext.push(']')\n\t} else {\n\t\t// 空节点\n\t\tcontext.push('null')\n\t}\n\n\tcontext.push('\\n')\n\tcontext.deindent()\n\tcontext.push('}\\n')\n}\n\n// ==================== 节点代码生成 ====================\n\n/**\n * 生成节点代码\n */\nfunction genNode(node: TemplateChildNode | JSChildNode, context: CodegenContext) {\n\tswitch (node.type) {\n\t\tcase NodeTypes.ELEMENT:\n\t\t\tgenElementNode(node as ElementNode, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.TEXT:\n\t\t\tgenTextNode(node as TextNode, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.INTERPOLATION:\n\t\t\tgenInterpolationNode(node as InterpolationNode, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.IF:\n\t\t\tgenIfNode(node as IfNode, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.FOR:\n\t\t\tgenForNode(node as ForNode, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.SIMPLE_EXPRESSION:\n\t\t\tgenSimpleExpression(node as SimpleExpressionNode, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.COMPOUND_EXPRESSION:\n\t\t\tgenCompoundExpression(node as CompoundExpressionNode, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.JS_CALL_EXPRESSION:\n\t\t\tgenCallExpression(node as JSCallExpression, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.JS_OBJECT_EXPRESSION:\n\t\t\tgenObjectExpression(node as JSObjectExpression, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.JS_ARRAY_EXPRESSION:\n\t\t\tgenArrayExpression(node as JSArrayExpression, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.JS_FUNCTION_EXPRESSION:\n\t\t\tgenFunctionExpression(node as JSFunctionExpression, context)\n\t\t\tbreak\n\n\t\tcase NodeTypes.JS_CONDITIONAL_EXPRESSION:\n\t\t\tgenConditionalExpression(node as JSConditionalExpression, context)\n\t\t\tbreak\n\n\t\tdefault:\n\t\t\twarn(`genNode: 未知的节点类型 ${node.type}`)\n\t}\n}\n\n/**\n * 生成元素节点代码\n */\nfunction genElementNode(node: ElementNode, context: CodegenContext) {\n\tif (node.codegenNode) {\n\t\t// 有代码生成节点,直接使用\n\t\tgenNode(node.codegenNode, context)\n\t} else {\n\t\t// 没有代码生成节点,生成默认的 h 调用\n\t\tcontext.push(`h(\"${node.tag}\"`)\n\n\t\tif (node.props.length > 0) {\n\t\t\tcontext.push(', ')\n\t\t\tgenProps(node.props, context)\n\t\t}\n\n\t\tif (node.children.length > 0) {\n\t\t\tcontext.push(', ')\n\t\t\tif (node.children.length === 1) {\n\t\t\t\tgenNode(node.children[0], context)\n\t\t\t} else {\n\t\t\t\tcontext.push('[')\n\t\t\t\tfor (let i = 0; i < node.children.length; i++) {\n\t\t\t\t\tgenNode(node.children[i], context)\n\t\t\t\t\tif (i < node.children.length - 1) {\n\t\t\t\t\t\tcontext.push(', ')\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontext.push(']')\n\t\t\t}\n\t\t}\n\n\t\tcontext.push(')')\n\t}\n}\n\n/**\n * 生成文本节点代码\n */\nfunction genTextNode(node: TextNode, context: CodegenContext) {\n\tcontext.push(`\"${node.content}\"`)\n}\n\n/**\n * 生成插值节点代码\n */\nfunction genInterpolationNode(node: InterpolationNode, context: CodegenContext) {\n\t// 获取插值内容\n\tconst content = (node.content as SimpleExpressionNode).content\n\tcontext.push(content)\n}\n\n/**\n * 生成 if 节点代码\n */\nfunction genIfNode(node: IfNode, context: CodegenContext) {\n\tif (node.codegenNode) {\n\t\tgenNode(node.codegenNode, context)\n\t} else {\n\t\twarn('genIfNode: if 节点缺少 codegenNode')\n\t}\n}\n\n/**\n * 生成 for 节点代码\n */\nfunction genForNode(node: ForNode, context: CodegenContext) {\n\tif (node.codegenNode) {\n\t\tgenNode(node.codegenNode, context)\n\t} else {\n\t\twarn('genForNode: for 节点缺少 codegenNode')\n\t}\n}\n\n/**\n * 生成简单表达式代码\n */\nfunction genSimpleExpression(node: SimpleExpressionNode, context: CodegenContext) {\n\tcontext.push(node.content)\n}\n\n/**\n * 生成复合表达式代码\n */\nfunction genCompoundExpression(node: CompoundExpressionNode, context: CodegenContext) {\n\tfor (const child of node.children) {\n\t\tif (typeof child === 'string') {\n\t\t\tcontext.push(child)\n\t\t} else {\n\t\t\tgenNode(child as any, context)\n\t\t}\n\t}\n}\n\n/**\n * 生成函数调用表达式代码\n */\nfunction genCallExpression(node: JSCallExpression, context: CodegenContext) {\n\t// 生成调用者\n\tif (typeof node.callee === 'symbol') {\n\t\tcontext.push(getRuntimeHelperName(node.callee) || 'h')\n\t} else {\n\t\tcontext.push(node.callee)\n\t}\n\n\tcontext.push('(')\n\n\t// 生成参数\n\tfor (let i = 0; i < node.arguments.length; i++) {\n\t\tconst arg = node.arguments[i]\n\n\t\tif (typeof arg === 'string') {\n\t\t\tcontext.push(arg)\n\t\t} else {\n\t\t\tgenNode(arg, context)\n\t\t}\n\n\t\tif (i < node.arguments.length - 1) {\n\t\t\tcontext.push(', ')\n\t\t}\n\t}\n\n\tcontext.push(')')\n}\n\n/**\n * 生成对象表达式代码\n */\nfunction genObjectExpression(node: JSObjectExpression, context: CodegenContext) {\n\tif (node.properties.length === 0) {\n\t\tcontext.push('{}')\n\t\treturn\n\t}\n\n\tcontext.push('{\\n')\n\tcontext.indentCode()\n\n\tfor (let i = 0; i < node.properties.length; i++) {\n\t\tconst prop = node.properties[i] as any\n\t\tcontext.push(context.indent())\n\n\t\t// key\n\t\tif (typeof prop.key === 'string') {\n\t\t\tcontext.push(prop.key)\n\t\t} else {\n\t\t\tgenNode(prop.key, context)\n\t\t}\n\n\t\tcontext.push(': ')\n\n\t\t// value\n\t\tif (typeof prop.value === 'string') {\n\t\t\tcontext.push(prop.value)\n\t\t} else {\n\t\t\tgenNode(prop.value, context)\n\t\t}\n\n\t\tif (i < node.properties.length - 1) {\n\t\t\tcontext.push(',')\n\t\t}\n\t\tcontext.push('\\n')\n\t}\n\n\tcontext.deindent()\n\tcontext.push(context.indent())\n\tcontext.push('}')\n}\n\n/**\n * 生成数组表达式代码\n */\nfunction genArrayExpression(node: JSArrayExpression, context: CodegenContext) {\n\tif (node.elements.length === 0) {\n\t\tcontext.push('[]')\n\t\treturn\n\t}\n\n\tcontext.push('[\\n')\n\tcontext.indentCode()\n\n\tfor (let i = 0; i < node.elements.length; i++) {\n\t\tconst element = node.elements[i]\n\n\t\tcontext.push(context.indent())\n\n\t\tif (element === null) {\n\t\t\tcontext.push('null')\n\t\t} else if (typeof element === 'string') {\n\t\t\tcontext.push(element)\n\t\t} else {\n\t\t\tgenNode(element, context)\n\t\t}\n\n\t\tif (i < node.elements.length - 1) {\n\t\t\tcontext.push(',')\n\t\t}\n\t\tcontext.push('\\n')\n\t}\n\n\tcontext.deindent()\n\tcontext.push(context.indent())\n\tcontext.push(']')\n}\n\n/**\n * 生成函数表达式代码\n */\nfunction genFunctionExpression(node: JSFunctionExpression, context: CodegenContext) {\n\tcontext.push('(')\n\n\t// 参数\n\tconst params = node.params as string[]\n\tfor (let i = 0; i < params.length; i++) {\n\t\tcontext.push(params[i])\n\t\tif (i < params.length - 1) {\n\t\t\tcontext.push(', ')\n\t\t}\n\t}\n\n\tcontext.push(') => ')\n\n\t// 返回值\n\tif (node.returns) {\n\t\tif (node.newline) {\n\t\t\tcontext.push('{\\n')\n\t\t\tcontext.indentCode()\n\t\t\tcontext.push(context.indent())\n\t\t\tcontext.push('return ')\n\t\t\tgenNode(node.returns, context)\n\t\t\tcontext.push('\\n')\n\t\t\tcontext.deindent()\n\t\t\tcontext.push(context.indent())\n\t\t\tcontext.push('}')\n\t\t} else {\n\t\t\tgenNode(node.returns, context)\n\t\t}\n\t} else if (node.body) {\n\t\tgenNode(node.body, context)\n\t}\n}\n\n/**\n * 生成条件表达式代码\n */\nfunction genConditionalExpression(node: JSConditionalExpression, context: CodegenContext) {\n\t// test\n\tgenNode(node.test, context)\n\tcontext.push(' ? ')\n\n\t// consequent\n\tgenNode(node.consequent, context)\n\tcontext.push(' : ')\n\n\t// alternate\n\tgenNode(node.alternate, context)\n}\n\n// ==================== 辅助函数 ====================\n\n/**\n * 生成 props 代码\n */\nfunction genProps(props: any[], context: CodegenContext) {\n\tcontext.push('{')\n\n\tfor (let i = 0; i < props.length; i++) {\n\t\tconst prop = props[i]\n\t\tcontext.push(`${prop.name}: ${prop.value ? `\"${prop.value.content}\"` : 'true'}`)\n\n\t\tif (i < props.length - 1) {\n\t\t\tcontext.push(', ')\n\t\t}\n\t}\n\n\tcontext.push('}')\n}"],"names":["NodeTypes","ElementTypes","ErrorCodes","defaultPosition","offset","line","column","defaultLoc","start","end","source","createPosition","createSourceLocation","createRoot","children","loc","type","ROOT","helpers","Set","components","directives","imports","createElementNode","tag","props","isSelfClosing","ELEMENT","createTextNode","content","TEXT","createInterpolationNode","expression","createSimpleExpression","INTERPOLATION","createAttributeNode","name","value","valueNode","ATTRIBUTE","createDirectiveNode","exp","arg","modifiers","expNode","argNode","DIRECTIVE","isStatic","identifiers","SIMPLE_EXPRESSION","createCompoundExpression","COMPOUND_EXPRESSION","createIfNode","branches","IF","createIfBranchNode","condition","IF_BRANCH","createForNode","valueAlias","keyAlias","indexAlias","FOR","createCallExpression","callee","args","JS_CALL_EXPRESSION","arguments","createObjectExpression","properties","JS_OBJECT_EXPRESSION","createArrayExpression","elements","JS_ARRAY_EXPRESSION","createFunctionExpression","params","returns","newline","isSlot","JS_FUNCTION_EXPRESSION","createConditionalExpression","test","consequent","alternate","JS_CONDITIONAL_EXPRESSION","isElementNode","node","isTextNode","isInterpolationNode","isIfNode","isForNode","isSimpleExpressionNode","isCompoundExpressionNode","getNodeChildren","cloneNode","cloned","createTransformContext","root","options","context","parent","childIndex","currentNode","nodeTransforms","replaceNode","warn","parentChildren","removeNode","index","indexOf","splice","traverseChildren","traverseNode","helper","add","onError","transform","exitFns","onExit","Array","isArray","push","i","length","currentParent","createTransform","types","fn","includes","transformIf","codegenNode","currentBranch","createBranchCodegen","branch","createConditionCodegen","createIfCodegen","processIf","wrapSignalCall","child","isValidIfBranch","getIfBranchType","RuntimeHelperNames","runtimeHelpers","CREATE_ELEMENT_VNODE","Symbol","CREATE_TEXT_VNODE","CREATE_COMMENT_VNODE","RESOLVE_COMPONENT","RESOLVE_DIRECTIVE","RENDER_LIST","RENDER_SLOT","MERGE_PROPS","NORMALIZE_CLASS","NORMALIZE_STYLE","NORMALIZE_PROPS","WITH_DIRECTIVES","WITH_CTX","getRuntimeHelperName","symbol","key","Object","entries","isRuntimeHelper","values","transformFor","renderBody","map","arrowFn","sourceExpr","createForCodegen","processFor","parseForExpression","inMatch","match","trim","vars","split","v","result","isValidForNode","transformElement","isComponent","isComponentTag","propsObj","prop","directiveProp","processDirective","createPropsObject","childrenArg","createChildrenArg","createElementCodegen","processElement","directive","capitalize","str","charAt","toUpperCase","slice","transformText","hasText","currentContainer","next","processText","hasTextChildren","some","normalizeTextContent","parts","join","getDefaultTransforms","generate","ast","code","indentLevel","indent","level","repeat","indentCode","deindent","createCodegenContext","size","genFunctionPreamble","genNode","genRenderFunction","preamble","genProps","genElementNode","genTextNode","genInterpolationNode","genIfNode","genForNode","genSimpleExpression","genCompoundExpression","genCallExpression","genObjectExpression","element","genArrayExpression","body","genFunctionExpression","genConditionalExpression"],"mappings":"0CAUO,IAAWA,GAAAA,IACjBA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,QAAA,GAAA,UACAA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,cAAA,GAAA,gBACAA,EAAAA,EAAA,UAAA,GAAA,YACAA,EAAAA,EAAA,UAAA,GAAA,YACAA,EAAAA,EAAA,GAAA,GAAA,KACAA,EAAAA,EAAA,UA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kH,CAAmBrJ,EAA2Ba,GAC9C,MAED,KAAKnG,EAAU+E,wBA4NjB,SAA+BO,EAA4Ba,GAC1DA,EAAQsB,KAAK,KAGb,MAAM9C,EAASW,EAAKX,OACpB,IAAA,IAAS+C,EAAI,EAAGA,EAAI/C,EAAOgD,OAAQD,IAClCvB,EAAQsB,KAAK9C,EAAO+C,IAChBA,EAAI/C,EAAOgD,OAAS,GACvBxB,EAAQsB,KAAK,MAIftB,EAAQsB,KAAK,SAGTnC,EAAKV,QACJU,EAAKT,SACRsB,EAAQsB,KAAK,OACbtB,EAAQqH,aACRrH,EAAQsB,KAAKtB,EAAQkH,UACrBlH,EAAQsB,KAAK,WACboG,GAAQvI,EAAKV,QAASuB,GACtBA,EAAQsB,KAAK,MACbtB,EAAQsH,WACRtH,EAAQsB,KAAKtB,EAAQkH,UACrBlH,EAAQsB,KAAK,MAEboG,GAAQvI,EAAKV,QAASuB,GAEbb,EAAKsJ,MACff,GAAQvI,EAAKsJ,KAAMzI,EAErB,CA3PG0I,CAAsBvJ,EAA8Ba,GACpD,MAED,KAAKnG,EAAUoF,2BA6PjB,SAAkCE,EAA+Ba,GAEhE0H,GAAQvI,EAAKL,KAAMkB,GACnBA,EAAQsB,KAAK,OAGboG,GAAQvI,EAAKJ,WAAYiB,GACzBA,EAAQsB,KAAK,OAGboG,GAAQvI,EAAKH,UAAWgB,EACzB,CAvQG2I,CAAyBxJ,EAAiCa,GAC1D,MAED,QACCM,EAAK,oBAAoBnB,EAAKtE,QAEjC"}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@fluxion-ui/compiler-core",
3
+ "version": "0.0.3",
4
+ "description": "Fluxion compiler core - platform-independent AST transforms and codegen",
5
+ "type": "module",
6
+ "main": "./dist/compiler-core.cjs",
7
+ "module": "./dist/compiler-core.js",
8
+ "types": "./dist/compiler-core.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/compiler-core.js",
12
+ "require": "./dist/compiler-core.cjs",
13
+ "types": "./dist/compiler-core.d.ts"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/AiFu-o/fluxion"
22
+ },
23
+ "keywords": [
24
+ "fluxion",
25
+ "compiler",
26
+ "ast",
27
+ "codegen"
28
+ ],
29
+ "author": "Fluxion Team",
30
+ "license": "MIT",
31
+ "dependencies": {
32
+ "@fluxion-ui/shared": "0.0.3"
33
+ }
34
+ }