babel-plugin-essor 0.0.7-beta.5 → 0.0.8

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 CHANGED
@@ -1,20 +1,20 @@
1
- MIT License
2
-
3
- Copyright (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
4
- Permission is hereby granted, free of charge, to any person obtaining a copy
5
- of this software and associated documentation files (the "Software"), to deal
6
- in the Software without restriction, including without limitation the rights
7
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the Software is
9
- furnished to do so, subject to the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be included in all
12
- copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md CHANGED
@@ -1,14 +1,14 @@
1
- # Essor babel plugin
2
-
3
- ## 安装
4
-
5
- ```bash
6
- npm install @essor/babel-plugin --save-dev
7
- ```
8
-
9
- ## 使用
10
-
11
-
12
- ::: warn
13
- 不要在pops中使用$,props是个reactive,必须添加value
14
- :::
1
+ # Essor babel plugin
2
+
3
+ ## 安装
4
+
5
+ ```bash
6
+ npm install @essor/babel-plugin --save-dev
7
+ ```
8
+
9
+ ## 使用
10
+
11
+
12
+ ::: warn
13
+ 不要在pops中使用$,props是个reactive,必须添加value
14
+ :::
package/dist/index.cjs CHANGED
@@ -127,7 +127,9 @@ var svgTags = [
127
127
  var import_core2 = require("@babel/core");
128
128
  function hasSiblingElement(path) {
129
129
  const siblings = path.getAllPrevSiblings().concat(path.getAllNextSiblings());
130
- const hasSibling = siblings.some((siblingPath) => siblingPath.isJSXElement());
130
+ const hasSibling = siblings.some(
131
+ (siblingPath) => siblingPath.isJSXElement() || siblingPath.isJSXExpressionContainer()
132
+ );
131
133
  return hasSibling;
132
134
  }
133
135
  function getAttrName(attribute) {
@@ -153,7 +155,7 @@ function jsxElementNameToString(node) {
153
155
  return `${node.namespace.name}:${node.name.name}`;
154
156
  }
155
157
  function isComponent(tagName) {
156
- return tagName[0] && tagName[0].toLowerCase() !== tagName[0] || tagName.includes(".") || /[^A-Za-z]/.test(tagName[0]);
158
+ return tagName[0] && tagName[0].toLowerCase() !== tagName[0] || tagName.includes(".") || /[^a-z]/i.test(tagName[0]);
157
159
  }
158
160
  function isTextChild(path) {
159
161
  if (path.isJSXExpressionContainer()) {
@@ -628,7 +630,7 @@ function handleAttributes2(props, result) {
628
630
  let klass = "";
629
631
  let style = "";
630
632
  for (const prop in props) {
631
- const value = props[prop];
633
+ let value = props[prop];
632
634
  if (prop === "class" && typeof value === "string") {
633
635
  klass += ` ${value}`;
634
636
  delete props[prop];
@@ -650,6 +652,23 @@ function handleAttributes2(props, result) {
650
652
  result.template += ` ${prop}="${value}"`;
651
653
  delete props[prop];
652
654
  }
655
+ if (import_core4.types.isConditionalExpression(value)) {
656
+ const { test, consequent, alternate } = value;
657
+ value = import_core4.types.arrowFunctionExpression([], import_core4.types.conditionalExpression(test, consequent, alternate));
658
+ props[prop] = value;
659
+ }
660
+ if (import_core4.types.isObjectExpression(value)) {
661
+ let hasConditional = false;
662
+ value.properties.forEach((property) => {
663
+ if (import_core4.types.isObjectProperty(property) && import_core4.types.isConditionalExpression(property.value)) {
664
+ hasConditional = true;
665
+ }
666
+ });
667
+ if (hasConditional) {
668
+ value = import_core4.types.arrowFunctionExpression([], value);
669
+ }
670
+ props[prop] = value;
671
+ }
653
672
  }
654
673
  if (Object.keys(props).length > 0) {
655
674
  result.props[result.index] = props;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../../shared/src/is.ts","../../shared/src/comm.ts","../../shared/src/name.ts","../src/jsx/server.ts","../src/program.ts","../src/jsx/constants.ts","../src/jsx/shared.ts","../src/jsx/client.ts","../src/jsx/index.ts","../src/signal/symbol.ts","../src/signal/import.ts","../src/signal/props.ts"],"sourcesContent":["import { transformJSX } from './jsx';\nimport { transformProgram } from './program';\nimport {\n replaceSymbol,\n symbolArrayPattern,\n symbolIdentifier,\n symbolObjectPattern,\n} from './signal/symbol';\nimport { replaceImportDeclaration } from './signal/import';\nimport { replaceProps } from './signal/props';\nimport type { PluginObj } from '@babel/core';\nexport { Options, State } from './types';\nexport default function (): PluginObj {\n return {\n name: 'babel-plugin-essor',\n manipulateOptions({ filename }, parserOpts) {\n if (filename.endsWith('.ts') || filename.endsWith('.tsx')) {\n parserOpts.plugins.push('typescript');\n }\n parserOpts.plugins.push('jsx');\n },\n visitor: {\n Program: transformProgram,\n JSXElement: transformJSX,\n JSXFragment: transformJSX,\n FunctionDeclaration: replaceProps,\n ArrowFunctionExpression: replaceProps,\n VariableDeclarator: replaceSymbol,\n ImportDeclaration: replaceImportDeclaration,\n Identifier: symbolIdentifier,\n ObjectPattern: symbolObjectPattern,\n ArrayPattern: symbolArrayPattern,\n },\n };\n}\n","import { _toString } from './comm';\n\nexport const isObject = (val: unknown): val is Record<any, any> =>\n val !== null && typeof val === 'object';\nexport function isPromise(val: any): boolean {\n return _toString.call(val) === '[object Promise]';\n}\n\nexport const isArray = Array.isArray;\n\nexport function isString(val: unknown): val is string {\n return typeof val === 'string';\n}\nexport function isNull(val: any): val is null {\n return val === null;\n}\nexport function isSymbol(val: unknown): val is symbol {\n return typeof val === 'symbol';\n}\nexport function isMap(val: unknown): val is Map<any, any> {\n return _toString.call(val) === '[object Map]';\n}\nexport function isNil(x: any): x is null | undefined {\n return x === null || x === undefined;\n}\n\nexport const isFunction = (val: unknown): val is Function => typeof val === 'function';\n\nexport function isFalsy(x: any): x is false | null | undefined {\n return x === false || x === null || x === undefined || x === '';\n}\n\nexport const isPrimitive = (\n val: unknown,\n): val is string | number | boolean | symbol | null | undefined =>\n ['string', 'number', 'boolean', 'symbol', 'undefined'].includes(typeof val) || isNull(val);\n\nexport const isHtmlElement = (val: unknown): val is HTMLElement => {\n return val instanceof HTMLElement || val instanceof SVGElement;\n};\n","import { isFunction, isPrimitive, isString } from './is';\n\nexport const _toString = Object.prototype.toString;\nexport const extend = Object.assign;\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nexport const hasOwn = (val: object, key: string | symbol): key is keyof typeof val =>\n hasOwnProperty.call(val, key);\n\nexport function coerceArray<T>(data: T | T[]): T[] {\n return Array.isArray(data) ? (data.flat() as T[]) : [data];\n}\nexport const hasChanged = (value, oldValue) =>\n value !== oldValue && (value === value || oldValue === oldValue);\nexport const noop = Function.prototype as () => void;\n\n/**\n * A function that checks if a string starts with a specific substring.\n * indexOf faster under normal circumstances\n * @see https://www.measurethat.net/Benchmarks/Show/12350/0/startswith-vs-test-vs-match-vs-indexof#latest_results_block\n\n * @param {string} str - The input string to check.\n * @param {string} searchString - The substring to check for at the beginning of the input string.\n * @return {boolean} Returns true if the input string starts with the specified substring, otherwise false.\n */\nexport function startsWith(str, searchString) {\n if (!isString(str)) {\n return false;\n }\n return str.indexOf(searchString) === 0;\n}\n\n/**\n * Recursively clones an object, including its nested properties and special types like Date, RegExp, Map, and Set.\n *\n * @param {any} obj - The object to clone.\n * @param {WeakMap<object, object>} [hash] - A WeakMap used to track circular references.\n * @return {any} The cloned object.\n */\nexport function deepClone(obj, hash = new WeakMap()) {\n // Return primitives and functions as-is\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n // Handle circular references\n if (hash.has(obj)) {\n return hash.get(obj);\n }\n\n // Handle special types\n if (obj instanceof Date) {\n return new Date(obj);\n }\n\n if (obj instanceof RegExp) {\n return new RegExp(obj);\n }\n\n if (obj instanceof Map) {\n const mapClone = new Map();\n hash.set(obj, mapClone);\n obj.forEach((value, key) => {\n mapClone.set(deepClone(key, hash), deepClone(value, hash));\n });\n return mapClone;\n }\n\n if (obj instanceof Set) {\n const setClone = new Set();\n hash.set(obj, setClone);\n obj.forEach(value => {\n setClone.add(deepClone(value, hash));\n });\n return setClone;\n }\n\n // Initialize the clone and store it in the WeakMap\n const cloneObj = Array.isArray(obj) ? [] : {};\n hash.set(obj, cloneObj);\n\n // Iterate over object keys\n const keys = Object.keys(obj);\n for (const key of keys) {\n cloneObj[key] = deepClone(obj[key], hash);\n }\n\n return cloneObj;\n}\n\n/**\n * Determines whether two values are deeply equal.\n *\n * @param {any} a - The first value to compare.\n * @param {any} b - The second value to compare.\n * @param {WeakMap<object, object>} [seen] - A WeakMap used to store previously seen objects to avoid infinite recursion.\n * @return {boolean} True if the values are deeply equal, false otherwise.\n */\nexport function deepEqual(a: any, b: any, seen = new WeakMap()): boolean {\n if (isPrimitive(a) && isPrimitive(b)) {\n return a === b;\n }\n\n if (a === b) {\n return true;\n }\n\n if (a == null || b == null || typeof a !== 'object' || typeof b !== 'object') {\n return false;\n }\n\n if (a.constructor !== b.constructor) {\n return false;\n }\n\n if (seen.has(a)) {\n return seen.get(a) === b;\n }\n\n seen.set(a, b);\n\n if (Array.isArray(a)) {\n if (a.length !== b.length) {\n return false;\n }\n for (const [i, element] of a.entries()) {\n if (!deepEqual(element, b[i], seen)) {\n return false;\n }\n }\n return true;\n }\n\n if (a instanceof Map) {\n if (a.size !== b.size) {\n return false;\n }\n for (const [key, value] of a) {\n if (!b.has(key) || !deepEqual(value, b.get(key), seen)) {\n return false;\n }\n }\n return true;\n }\n\n if (a instanceof Set) {\n if (a.size !== b.size) {\n return false;\n }\n const arrA = Array.from(a).sort();\n const arrB = Array.from(b).sort();\n for (const [i, element] of arrA.entries()) {\n if (!deepEqual(element, arrB[i], seen)) {\n return false;\n }\n }\n return true;\n }\n\n const keysA = Object.keys(a);\n const keysB = new Set(Object.keys(b));\n\n if (keysA.length !== keysB.size) {\n return false;\n }\n\n for (const key of keysA) {\n if (!keysB.has(key) || !deepEqual(a[key], b[key], seen)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Escapes special HTML characters in a string.\n * @param str - The string to escape.\n * @returns The escaped string.\n */\nexport function escape(str: string): string {\n return str.replaceAll(/[\"&'<>]/g, char => {\n switch (char) {\n case '&':\n return '&amp;';\n case '<':\n return '&lt;';\n case '>':\n return '&gt;';\n case '\"':\n return '&quot;';\n case \"'\":\n return '&#039;';\n default:\n return char;\n }\n });\n}\n\nexport type ExcludeType = ((key: string | symbol) => boolean) | (string | symbol)[];\n\n/**\n * Checks if a key should be excluded based on the provided exclude criteria.\n * @param key - The key to check.\n * @param exclude - The exclusion criteria.\n * @returns True if the key should be excluded, otherwise false.\n */\nexport function isExclude(key: string | symbol, exclude?: ExcludeType): boolean {\n return Array.isArray(exclude)\n ? exclude.includes(key)\n : isFunction(exclude)\n ? exclude(key)\n : false;\n}\n","export const kebabCase = (string: string): string => {\n return string.replaceAll(/[A-Z]+/g, (match, offset) => {\n return `${offset > 0 ? '-' : ''}${match.toLocaleLowerCase()}`;\n });\n};\n\nexport const camelCase = (str: string): string => {\n const s = str.replaceAll(/[\\s_-]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''));\n return s[0].toLowerCase() + s.slice(1);\n};\n/**\n * Capitalizes the first letter of a string.\n *\n * @param {string} inputString - The input string to capitalize the first letter.\n * @return {string} The string with the first letter capitalized.\n */\nexport const capitalizeFirstLetter = (inputString: string): string => {\n return inputString.charAt(0).toUpperCase() + inputString.slice(1);\n};\n","import { capitalizeFirstLetter } from 'essor-shared';\nimport { types as t } from '@babel/core';\nimport { imports } from '../program';\nimport { selfClosingTags, svgTags } from './constants';\nimport {\n type JSXChild,\n type JSXElement,\n getAttrName,\n getTagName,\n isComponent,\n isTextChild,\n setNodeText,\n} from './shared';\nimport type { OptionalMemberExpression } from '@babel/types';\nimport type { State } from '../types';\nimport type { NodePath } from '@babel/core';\n\nexport interface Result {\n index: number;\n isLastChild: boolean;\n parentIndex: number;\n props: Record<string, any>;\n template: string[];\n}\n\nexport function transformJSXService(path: NodePath<JSXElement>): void {\n const result: Result = {\n index: 0,\n isLastChild: false,\n parentIndex: 0,\n props: {},\n template: [], // 修改为数组\n };\n transformJSXServiceElement(path, result, true);\n path.replaceWith(createEssorNode(path, result));\n}\n\nfunction createEssorNode(path: NodePath<JSXElement>, result: Result): t.CallExpression {\n const state: State = path.state;\n\n let tmpl: t.Identifier;\n if (path.isJSXElement() && isComponent(getTagName(path.node))) {\n tmpl = t.identifier(getTagName(path.node));\n } else {\n tmpl = path.scope.generateUidIdentifier('_tmpl$');\n const template = t.arrayExpression(result.template.map(t.stringLiteral));\n const declarator = t.variableDeclarator(tmpl, template);\n state.tmplDeclaration.declarations.push(declarator);\n }\n\n const args = [tmpl, createProps(result.props)];\n const key = result.props.key || result.props[0]?.key;\n if (key) {\n args.push(key);\n }\n imports.add('renderTemplate');\n return t.callExpression(state.renderTemplate, args);\n}\n\nfunction createProps(props: Record<string, any>): t.ObjectExpression {\n const result: (t.ObjectProperty | t.SpreadElement)[] = [];\n\n for (const prop in props) {\n let value = props[prop];\n\n if (prop === 'key') {\n continue;\n }\n\n if (Array.isArray(value)) {\n value = t.arrayExpression(value);\n }\n\n if (typeof value === 'object' && value !== null && !t.isNode(value)) {\n value = createProps(value);\n }\n\n if (typeof value === 'string') {\n value = t.stringLiteral(value);\n }\n\n if (typeof value === 'number') {\n value = t.numericLiteral(value);\n }\n\n if (typeof value === 'boolean') {\n value = t.booleanLiteral(value);\n }\n\n if (value === undefined) {\n value = t.tsUndefinedKeyword();\n }\n\n if (value === null) {\n value = t.nullLiteral();\n }\n\n if (prop === '_$spread$') {\n result.push(t.spreadElement(value));\n } else {\n result.push(t.objectProperty(t.stringLiteral(prop), value));\n }\n }\n\n return t.objectExpression(result);\n}\nfunction transformJSXServiceElement(\n path: NodePath<JSXElement>,\n result: Result,\n isRoot: boolean = false,\n): void {\n if (path.isJSXElement()) {\n const tagName = getTagName(path.node);\n const tagIsComponent = isComponent(tagName);\n const isSelfClose = !tagIsComponent && selfClosingTags.includes(tagName);\n const isSvg = svgTags.includes(tagName) && result.index === 1;\n const { props, hasExpression } = getAttrProps(path);\n if (tagIsComponent) {\n if (isRoot) {\n result.props = props;\n const children = getChildren(path) as any;\n if (children.length > 0) {\n const childrenGenerator =\n children.length === 1 ? children[0] : t.arrayExpression(children);\n result.props.children = childrenGenerator;\n }\n } else {\n transformJSXService(path);\n replaceChild(path.node, result);\n }\n } else {\n if (isSvg) {\n result.template.push('<svg _svg_>');\n }\n result.template.push(`<${tagName}`);\n handleAttributes(props, result);\n\n if (hasExpression) {\n result.template.push(isSelfClose ? '/>' : '>');\n result.props ||= {};\n } else {\n result.template[result.template.length - 1] += isSelfClose ? '/>' : '>';\n }\n transformChildren(path, result);\n\n if (!isSelfClose) {\n result.template.push(`</${tagName}>`);\n }\n }\n } else {\n result.index--;\n transformChildren(path, result);\n }\n}\n\nfunction transformChildren(path: NodePath<JSXElement>, result: Result): void {\n const parentIndex = result.template.length;\n path\n .get('children')\n .reduce((pre, cur) => {\n if (isValidChild(cur)) {\n const lastChild = pre.at(-1);\n if (lastChild && isTextChild(cur) && isTextChild(lastChild)) {\n setNodeText(lastChild, getNodeText(lastChild) + getNodeText(cur));\n } else {\n pre.push(cur);\n }\n }\n return pre;\n }, [] as NodePath<JSXChild>[])\n .forEach((child, i, arr) => {\n result.parentIndex = parentIndex;\n result.isLastChild = i === arr.length - 1;\n transformChild(child, result);\n });\n}\n\nfunction transformChild(child: NodePath<JSXChild>, result: Result): void {\n if (child.isJSXElement() || child.isJSXFragment()) {\n transformJSXServiceElement(child, result, false);\n } else if (child.isJSXExpressionContainer()) {\n const expression = child.get('expression');\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\n result.template[result.template.length - 1] += String(expression.node.value);\n } else if (expression.isExpression()) {\n replaceChild(expression.node, result);\n } else if (t.isJSXEmptyExpression(expression.node)) {\n // it is empty expression\n // do nothing\n } else {\n throw new Error('Unsupported child type');\n }\n } else if (child.isJSXText()) {\n result.template.push(String(child.node.value));\n } else {\n throw new Error('Unsupported child type');\n }\n}\n\nfunction getNodeText(path: NodePath<JSXChild>): string {\n if (path.isJSXText()) {\n return path.node.value;\n }\n if (path.isJSXExpressionContainer()) {\n const expression = path.get('expression');\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\n return String(expression.node.value);\n }\n }\n return '';\n}\n\nfunction handleAttributes(props: Record<string, any>, result: Result): void {\n let klass = '';\n let style = '';\n\n for (const prop in props) {\n const value = props[prop];\n\n if (prop === 'class' && typeof value === 'string') {\n klass += ` ${value}`;\n delete props[prop];\n continue;\n }\n\n if (prop === 'style' && typeof value === 'string') {\n style += `${value}${value.at(-1) === ';' ? '' : ';'}`;\n delete props[prop];\n continue;\n }\n\n if (value === true) {\n result.template[result.template.length - 1] += ` ${prop}`;\n delete props[prop];\n }\n if (value === false) {\n delete props[prop];\n }\n if (typeof value === 'string' || typeof value === 'number') {\n result.template[result.template.length - 1] += ` ${prop}=\"${value}\"`;\n delete props[prop];\n }\n }\n\n if (Object.keys(props).length > 0) {\n result.props[result.index] = props;\n }\n\n klass = klass.trim();\n style = style.trim();\n\n if (klass) {\n result.template[result.template.length - 1] += ` class=\"${klass}\"`;\n }\n if (style) {\n result.template[result.template.length - 1] += ` style=\"${style}\"`;\n }\n}\n\nfunction replaceChild(node: t.Expression, result: Result): void {\n if (result.isLastChild) {\n result.index--;\n }\n result.props[result.parentIndex] ??= {};\n result.props[result.parentIndex].children ??= [];\n result.props[result.parentIndex].children.push(\n t.arrayExpression([\n t.arrowFunctionExpression([], node),\n t.identifier(String(result.template.length)),\n ]),\n );\n}\n\nfunction getChildren(path: NodePath<JSXElement>): JSXChild[] {\n return path\n .get('children')\n .filter(child => isValidChild(child))\n .map(child => {\n if (child.isJSXElement() || child.isJSXFragment()) {\n transformJSXService(child);\n } else if (child.isJSXExpressionContainer()) {\n child.replaceWith(child.get('expression'));\n } else if (child.isJSXText()) {\n child.replaceWith(t.stringLiteral(child.node.value));\n } else {\n throw new Error('Unsupported child type');\n }\n return child.node;\n });\n}\n\nfunction isValidChild(path: NodePath<JSXChild>): boolean {\n const regex = /^\\s*$/;\n if (path.isStringLiteral() || path.isJSXText()) {\n return !regex.test(path.node.value);\n }\n return Object.keys(path.node).length > 0;\n}\nfunction getAttrProps(path: NodePath<t.JSXElement>): Record<string, any> {\n const props: Record<string, any> = {};\n let hasExpression = false;\n path\n .get('openingElement')\n .get('attributes')\n .forEach(attribute => {\n if (attribute.isJSXAttribute()) {\n const name = getAttrName(attribute.node);\n const value = attribute.get('value');\n\n if (!value.node) {\n props[name] = true;\n } else if (value.isStringLiteral()) {\n props[name] = value.node.value;\n } else {\n if (value.isJSXExpressionContainer()) {\n const expression = value.get('expression');\n\n if (expression.isStringLiteral()) {\n props[name] = expression.node.value;\n } else if (expression.isNumericLiteral()) {\n props[name] = expression.node.value;\n } else if (expression.isJSXElement() || expression.isJSXFragment()) {\n transformJSXService(expression);\n props[name] = expression.node;\n } else if (expression.isExpression()) {\n hasExpression = true;\n if (/^key|ref|on.+$/.test(name)) {\n props[name] = expression.node;\n } else if (/^bind:.+/.test(name)) {\n const value = path.scope.generateUidIdentifier('value');\n const bindName = name.slice(5).toLocaleLowerCase();\n props[bindName] = expression.node;\n props[`update${capitalizeFirstLetter(bindName)}`] = t.arrowFunctionExpression(\n [value],\n t.assignmentExpression('=', expression.node as OptionalMemberExpression, value),\n );\n } else {\n if (expression.isConditionalExpression()) {\n props[name] = t.arrowFunctionExpression([], expression.node);\n } else {\n props[name] = expression.node;\n }\n }\n }\n } else if (value.isJSXElement() || value.isJSXFragment()) {\n transformJSXService(value);\n props[name] = value.node;\n }\n }\n } else if (attribute.isJSXSpreadAttribute()) {\n props._$spread$ = attribute.get('argument').node;\n hasExpression = true;\n } else {\n throw new Error('Unsupported attribute type');\n }\n });\n\n return {\n props,\n hasExpression,\n };\n}\n","import { type NodePath, types as t } from '@babel/core';\nimport type { State } from './types';\nexport const imports = new Set<string>();\n\nexport const transformProgram = {\n enter(path: NodePath<t.Program>, state) {\n imports.clear();\n\n path.state = {\n h: path.scope.generateUidIdentifier('h$'),\n renderTemplate: path.scope.generateUidIdentifier('renderTemplate$'),\n template: path.scope.generateUidIdentifier('template$'),\n\n useSignal: path.scope.generateUidIdentifier('signal$'),\n useComputed: path.scope.generateUidIdentifier('computed$'),\n useReactive: path.scope.generateUidIdentifier('reactive$'),\n\n tmplDeclaration: t.variableDeclaration('const', []),\n opts: state.opts,\n } as State;\n },\n exit(path: NodePath<t.Program>) {\n const state: State = path.state;\n if (state.tmplDeclaration.declarations.length > 0) {\n const index = path.node.body.findIndex(\n node => !t.isImportDeclaration(node) && !t.isExportDeclaration(node),\n );\n path.node.body.splice(index, 0, state.tmplDeclaration);\n }\n if (imports.size > 0) {\n path.node.body.unshift(createImport(state, 'essor'));\n }\n },\n};\nfunction createImport(state: State, from: string) {\n const ImportSpecifier: t.ImportSpecifier[] = [];\n imports.forEach(name => {\n const local = t.identifier(state[name].name);\n const imported = t.identifier(name);\n ImportSpecifier.push(t.importSpecifier(local, imported));\n });\n\n const importSource = t.stringLiteral(from);\n return t.importDeclaration(ImportSpecifier, importSource);\n}\n","export const selfClosingTags = [\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n];\n\nexport const svgTags = [\n 'circle',\n 'clipPath',\n 'defs',\n 'ellipse',\n 'filter',\n 'g',\n 'line',\n 'linearGradient',\n 'mask',\n 'path',\n 'pattern',\n 'polygon',\n 'polyline',\n 'radialGradient',\n 'rect',\n 'stop',\n 'symbol',\n 'text',\n 'use',\n];\n","import { type NodePath, types as t } from '@babel/core';\n\nexport type JSXElement = t.JSXElement | t.JSXFragment;\n\nexport type JSXChild =\n | t.JSXElement\n | t.JSXFragment\n | t.JSXExpressionContainer\n | t.JSXSpreadChild\n | t.JSXText;\n\n/**\n * Checks if the given Babel path has a sibling element.\n *\n * @param {NodePath} path - The Babel path to check.\n * @return {boolean} True if the path has a sibling element, false otherwise.\n */\nexport function hasSiblingElement(path) {\n // Get all siblings (both previous and next)\n const siblings = path.getAllPrevSiblings().concat(path.getAllNextSiblings());\n\n // Check for non-self-closing sibling elements\n const hasSibling = siblings.some(siblingPath => siblingPath.isJSXElement());\n\n return hasSibling;\n}\n\n/**\n * Retrieves the name of a JSX attribute.\n *\n * @param {t.JSXAttribute} attribute - The JSX attribute to retrieve the name from.\n * @return {string} The name of the attribute.\n * @throws {Error} If the attribute type is unsupported.\n */\nexport function getAttrName(attribute: t.JSXAttribute): string {\n if (t.isJSXIdentifier(attribute.name)) {\n return attribute.name.name;\n }\n if (t.isJSXNamespacedName(attribute.name)) {\n return `${attribute.name.namespace.name}:${attribute.name.name.name}`;\n }\n throw new Error('Unsupported attribute type');\n}\n\n/**\n * Retrieves the tag name of a JSX element.\n *\n * @param {t.JSXElement} node - The JSX element.\n * @return {string} The tag name of the JSX element.\n */\nexport function getTagName(node: t.JSXElement): string {\n const tag = node.openingElement.name;\n return jsxElementNameToString(tag);\n}\n\n/**\n * Converts a JSX element name to a string representation.\n *\n * case1: <MyComponent />\n * case2: <SomeLibrary.SomeComponent />;\n * case3: <namespace:ComponentName />;\n * case4: <SomeLibrary.Nested.ComponentName />;\n *\n * @param {t.JSXMemberExpression | t.JSXIdentifier | t.JSXNamespacedName} node The JSX element name to convert.\n * @returns {string} The string representation of the JSX element name.\n */\nexport function jsxElementNameToString(\n node: t.JSXMemberExpression | t.JSXIdentifier | t.JSXNamespacedName,\n) {\n if (t.isJSXMemberExpression(node)) {\n return `${jsxElementNameToString(node.object)}.${jsxElementNameToString(node.property)}`;\n }\n\n if (t.isJSXIdentifier(node) || t.isIdentifier(node)) {\n return node.name;\n }\n\n return `${node.namespace.name}:${node.name.name}`;\n}\n\n/**\n * Determines if the given tagName is a component.\n *\n * case1: <MyComponent />\n * case2: <SomeLibrary.SomeComponent />;\n * case3: <_component />;\n *\n * @param {string} tagName - The name of the tag to check.\n * @return {boolean} True if the tagName is a component, false otherwise.\n */\nexport function isComponent(tagName: string): boolean {\n return (\n (tagName[0] && tagName[0].toLowerCase() !== tagName[0]) ||\n tagName.includes('.') ||\n /[^A-Za-z]/.test(tagName[0])\n );\n}\n\n/**\n * Determines if the given path represents a text child node in a JSX expression.\n *\n * @param {NodePath<JSXChild>} path - The path to the potential text child node.\n * @return {boolean} True if the path represents a text child node, false otherwise.\n */\nexport function isTextChild(path: NodePath<JSXChild>): boolean {\n if (path.isJSXExpressionContainer()) {\n const expression = path.get('expression');\n if (expression.isJSXText() || expression.isStringLiteral() || expression.isNumericLiteral()) {\n return true;\n }\n }\n if (path.isJSXText() || path.isStringLiteral() || path.isNullLiteral()) {\n return true;\n }\n return false;\n}\n\n/**\n * Sets the text content of a JSX node.\n *\n * @param {NodePath<JSXChild>} path - The path to the JSX node.\n * @param {string} text - The text to set.\n * @return {void}\n */\nexport function setNodeText(path: NodePath<JSXChild>, text: string): void {\n if (path.isJSXText()) {\n path.node.value = text;\n }\n if (path.isJSXExpressionContainer()) {\n const expression = path.get('expression');\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\n expression.replaceWith(t.stringLiteral(text));\n }\n }\n}\n","import { types as t } from '@babel/core';\nimport { capitalizeFirstLetter } from 'essor-shared';\nimport { imports } from '../program';\nimport { selfClosingTags, svgTags } from './constants';\nimport {\n type JSXChild,\n type JSXElement,\n getAttrName,\n getTagName,\n hasSiblingElement,\n isComponent,\n isTextChild,\n setNodeText,\n} from './shared';\nimport type { OptionalMemberExpression } from '@babel/types';\nimport type { State } from '../types';\nimport type { NodePath } from '@babel/core';\n\nexport interface Result {\n index: number;\n isLastChild: boolean;\n parentIndex: number;\n props: Record<string, any>;\n template: string;\n}\n\nexport function transformJSXClient(path: NodePath<JSXElement>): void {\n const result: Result = {\n index: 1,\n isLastChild: false,\n parentIndex: 0,\n props: {},\n template: '',\n };\n transformJSXElement(path, result, true);\n\n path.replaceWith(createEssorNode(path, result));\n}\n\nfunction createEssorNode(path: NodePath<JSXElement>, result: Result): t.CallExpression {\n const state: State = path.state;\n\n let tmpl: t.Identifier;\n if (path.isJSXElement() && isComponent(getTagName(path.node))) {\n tmpl = t.identifier(getTagName(path.node));\n } else {\n tmpl = path.scope.generateUidIdentifier('_tmpl$');\n const template = t.callExpression(state.template, [t.stringLiteral(result.template)]);\n const declarator = t.variableDeclarator(tmpl, template);\n state.tmplDeclaration.declarations.push(declarator);\n imports.add('template');\n }\n\n const args = [tmpl, createProps(result.props)];\n const key = result.props.key || result.props[0]?.key;\n if (key) {\n args.push(key);\n }\n imports.add('h');\n return t.callExpression(state.h, args);\n}\n\nfunction createProps(props) {\n const toAstNode = value => {\n if (Array.isArray(value)) {\n return t.arrayExpression(value.map(toAstNode));\n }\n if (value && typeof value === 'object' && !t.isNode(value)) {\n return createProps(value);\n }\n\n switch (typeof value) {\n case 'string':\n return t.stringLiteral(value);\n case 'number':\n return t.numericLiteral(value);\n case 'boolean':\n return t.booleanLiteral(value);\n case 'undefined':\n return t.tsUndefinedKeyword();\n case undefined:\n return t.tsUndefinedKeyword();\n case null:\n return t.nullLiteral();\n default:\n return value;\n }\n };\n\n const result = Object.keys(props)\n .filter(prop => prop !== 'key')\n .map(prop => {\n const value = toAstNode(props[prop]);\n return prop === '_$spread$'\n ? t.spreadElement(value)\n : t.objectProperty(t.stringLiteral(prop), value);\n });\n\n return t.objectExpression(result);\n}\nfunction transformJSXElement(\n path: NodePath<JSXElement>,\n result: Result,\n isRoot: boolean = false,\n): void {\n if (path.isJSXElement()) {\n const tagName = getTagName(path.node);\n const tagIsComponent = isComponent(tagName);\n const isSelfClose = !tagIsComponent && selfClosingTags.includes(tagName);\n const isSvg = svgTags.includes(tagName) && result.index === 1;\n const props = getAttrProps(path);\n if (tagIsComponent) {\n if (isRoot) {\n result.props = props;\n const children = getChildren(path) as any;\n if (children.length > 0) {\n const childrenGenerator =\n children.length === 1 ? children[0] : t.arrayExpression(children);\n result.props.children = childrenGenerator;\n }\n } else {\n transformJSXClient(path);\n replaceChild(path.node, result);\n }\n } else {\n if (isSvg) {\n result.template = '<svg _svg_>';\n }\n result.template += `<${tagName}`;\n handleAttributes(props, result);\n result.template += isSelfClose ? '/>' : '>';\n if (!isSelfClose) {\n transformChildren(path, result);\n if (hasSiblingElement(path)) {\n result.template += `</${tagName}>`;\n }\n }\n }\n } else {\n result.index--;\n transformChildren(path, result);\n }\n}\n\nfunction transformChildren(path: NodePath<JSXElement>, result: Result): void {\n const parentIndex = result.index;\n path\n .get('children')\n .reduce((pre, cur) => {\n if (isValidChild(cur)) {\n const lastChild = pre.at(-1);\n if (lastChild && isTextChild(cur) && isTextChild(lastChild)) {\n setNodeText(lastChild, getNodeText(lastChild) + getNodeText(cur));\n } else {\n pre.push(cur);\n }\n }\n return pre;\n }, [] as NodePath<JSXChild>[])\n .forEach((child, i, arr) => {\n result.parentIndex = parentIndex;\n result.isLastChild = i === arr.length - 1;\n transformChild(child, result);\n });\n}\n\nfunction transformChild(child: NodePath<JSXChild>, result: Result): void {\n result.index++;\n if (child.isJSXElement() || child.isJSXFragment()) {\n transformJSXElement(child, result, false);\n } else if (child.isJSXExpressionContainer()) {\n const expression = child.get('expression');\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\n result.template += String(expression.node.value);\n } else if (expression.isExpression()) {\n replaceChild(expression.node, result);\n } else if (t.isJSXEmptyExpression(expression.node)) {\n // it is empty expression\n // do nothing\n } else {\n throw new Error('Unsupported child type');\n }\n } else if (child.isJSXText()) {\n result.template += String(child.node.value);\n } else {\n throw new Error('Unsupported child type');\n }\n}\n\nfunction getNodeText(path: NodePath<JSXChild>): string {\n if (path.isJSXText()) {\n return path.node.value;\n }\n if (path.isJSXExpressionContainer()) {\n const expression = path.get('expression');\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\n return String(expression.node.value);\n }\n }\n return '';\n}\n\nfunction handleAttributes(props: Record<string, any>, result: Result): void {\n let klass = '';\n let style = '';\n\n for (const prop in props) {\n const value = props[prop];\n\n if (prop === 'class' && typeof value === 'string') {\n klass += ` ${value}`;\n delete props[prop];\n continue;\n }\n\n if (prop === 'style' && typeof value === 'string') {\n style += `${value}${value.at(-1) === ';' ? '' : ';'}`;\n delete props[prop];\n continue;\n }\n\n if (value === true) {\n result.template += ` ${prop}`;\n delete props[prop];\n }\n if (value === false) {\n delete props[prop];\n }\n if (typeof value === 'string' || typeof value === 'number') {\n result.template += ` ${prop}=\"${value}\"`;\n delete props[prop];\n }\n }\n\n if (Object.keys(props).length > 0) {\n result.props[result.index] = props;\n }\n\n klass = klass.trim();\n style = style.trim();\n\n if (klass) {\n result.template += ` class=\"${klass}\"`;\n }\n if (style) {\n result.template += ` style=\"${style}\"`;\n }\n}\n\nfunction replaceChild(node: t.Expression, result: Result): void {\n if (result.isLastChild) {\n result.index--;\n } else {\n result.template += '<!>';\n }\n result.props[result.parentIndex] ??= {};\n result.props[result.parentIndex].children ??= [];\n result.props[result.parentIndex].children.push(\n t.arrayExpression([\n t.arrowFunctionExpression([], node),\n result.isLastChild ? t.nullLiteral() : t.identifier(String(result.index)),\n ]),\n );\n}\n\nfunction getChildren(path: NodePath<JSXElement>): JSXChild[] {\n return path\n .get('children')\n .filter(child => isValidChild(child))\n .map(child => {\n if (child.isJSXElement() || child.isJSXFragment()) {\n transformJSXClient(child);\n } else if (child.isJSXExpressionContainer()) {\n child.replaceWith(child.get('expression'));\n } else if (child.isJSXText()) {\n child.replaceWith(t.stringLiteral(child.node.value));\n } else {\n throw new Error('Unsupported child type');\n }\n return child.node;\n });\n}\n\nexport function isValidChild(path: NodePath<JSXChild>): boolean {\n const regex = /^\\s*$/;\n if (path.isStringLiteral() || path.isJSXText()) {\n return !regex.test(path.node.value);\n }\n return Object.keys(path.node).length > 0;\n}\nexport function getAttrProps(path: NodePath<t.JSXElement>): Record<string, any> {\n const props: Record<string, any> = {};\n\n path\n .get('openingElement')\n .get('attributes')\n .forEach(attribute => {\n if (attribute.isJSXAttribute()) {\n const name = getAttrName(attribute.node);\n const value = attribute.get('value');\n\n if (!value.node) {\n props[name] = true;\n } else if (value.isStringLiteral()) {\n props[name] = value.node.value;\n } else {\n if (value.isJSXExpressionContainer()) {\n const expression = value.get('expression');\n\n if (expression.isStringLiteral()) {\n props[name] = expression.node.value;\n } else if (expression.isNumericLiteral()) {\n props[name] = expression.node.value;\n } else if (expression.isJSXElement() || expression.isJSXFragment()) {\n transformJSXClient(expression);\n props[name] = expression.node;\n } else if (expression.isExpression()) {\n if (/^key|ref|on.+$/.test(name)) {\n props[name] = expression.node;\n } else if (/^bind:.+/.test(name)) {\n const value = path.scope.generateUidIdentifier('value');\n const bindName = name.slice(5).toLocaleLowerCase();\n props[bindName] = expression.node;\n props[`update${capitalizeFirstLetter(bindName)}`] = t.arrowFunctionExpression(\n [value],\n t.assignmentExpression('=', expression.node as OptionalMemberExpression, value),\n );\n } else {\n if (expression.isConditionalExpression()) {\n props[name] = t.arrowFunctionExpression([], expression.node);\n } else {\n props[name] = expression.node;\n }\n }\n }\n } else if (value.isJSXElement() || value.isJSXFragment()) {\n transformJSXClient(value);\n props[name] = value.node;\n }\n }\n } else if (attribute.isJSXSpreadAttribute()) {\n props._$spread$ = attribute.get('argument').node;\n } else {\n throw new Error('Unsupported attribute type');\n }\n });\n\n return props;\n}\n","import { transformJSXService } from './server';\nimport { transformJSXClient } from './client';\nimport type { NodePath, types as t } from '@babel/core';\nimport type { State } from '../types';\ntype JSXElement = t.JSXElement | t.JSXFragment;\nexport function transformJSX(path: NodePath<JSXElement>) {\n const state: State = path.state;\n const isSsg = state.opts.ssg;\n return isSsg ? transformJSXService(path) : transformJSXClient(path);\n}\n","import { types as t } from '@babel/core';\nimport { startsWith } from 'essor-shared';\nimport { imports } from '../program';\nimport type { Identifier, VariableDeclarator } from '@babel/types';\nimport type { NodePath } from '@babel/core';\n\n/**\n * 当一个变量/常量声明的时候,判断是否是$(定义的符号)开头,如果是,则进行转换。\n *\n * case 1: let $a = 1 => let $a = useSignal(1);\n * case 2: const $a = ()=>{return $a} => const $a = useComputed(()=>{return $a})\n *\n * 并且所有当前用到的值,都会添加.value\n * @param path\n * @returns {void}\n */\nexport function replaceSymbol(path: NodePath<VariableDeclarator>) {\n const init = path.node.init;\n const variableName = (path.node.id as Identifier).name;\n\n if (t.isObjectPattern(path.node.id) || t.isArrayPattern(path.node.id)) {\n return;\n }\n\n if (!startsWith(variableName, '$')) {\n return;\n }\n\n if (\n init &&\n (t.isFunctionExpression(init) || t.isArrowFunctionExpression(init)) &&\n (path.parent as t.VariableDeclaration).kind === 'const'\n ) {\n const newInit = t.callExpression(t.identifier(path.state.useComputed.name), init ? [init] : []);\n imports.add('useComputed');\n path.node.init = newInit;\n } else {\n const newInit = t.callExpression(t.identifier(path.state.useSignal.name), init ? [init] : []);\n imports.add('useSignal');\n path.node.init = newInit;\n }\n}\n\nexport function symbolIdentifier(path) {\n const parentPath = path.parentPath;\n\n if (\n !parentPath ||\n t.isVariableDeclarator(parentPath) ||\n t.isImportSpecifier(parentPath) ||\n t.isObjectProperty(parentPath) ||\n t.isArrayPattern(parentPath) ||\n t.isObjectPattern(parentPath)\n ) {\n return;\n }\n\n const { node } = path;\n\n if (node.name.startsWith('$')) {\n // check is has .value\n let currentPath = path;\n while (currentPath.parentPath && !currentPath.parentPath.isProgram()) {\n if (\n currentPath.parentPath.isMemberExpression() &&\n currentPath.parentPath.node.property.name === 'value'\n ) {\n return;\n }\n currentPath = currentPath.parentPath;\n }\n\n // add with .value\n const newNode = t.memberExpression(t.identifier(node.name), t.identifier('value'));\n\n path.replaceWith(newNode);\n }\n}\n\nexport function symbolObjectPattern(path) {\n path.node.properties.forEach(property => {\n if (\n t.isObjectProperty(property) &&\n t.isIdentifier(property.key) &&\n property.key.name.startsWith('$')\n ) {\n const newKey = t.identifier(property.key.name);\n property.key = newKey;\n }\n });\n}\n\nexport function symbolArrayPattern(path) {\n path.node.elements.forEach(element => {\n if (t.isIdentifier(element) && element.name.startsWith('$')) {\n const newElement = t.identifier(element.name);\n element.name = newElement.name;\n } else if (t.isObjectPattern(element)) {\n element.properties.forEach(property => {\n if (\n t.isObjectProperty(property) &&\n t.isIdentifier(property.key) &&\n property.key.name.startsWith('$')\n ) {\n const newKey = t.identifier(property.key.name);\n property.key = newKey;\n }\n });\n }\n });\n}\n","import { type NodePath, types as t } from '@babel/core';\nimport { startsWith } from 'essor-shared';\nimport type { ImportDeclaration } from '@babel/types';\n\nfunction isVariableUsedAsObject(path: NodePath<ImportDeclaration>, variableName: string) {\n const binding = path.scope.getBinding(variableName);\n let isUsedObject = false;\n if (!binding || !binding.referencePaths) {\n return isUsedObject;\n }\n\n for (const referencePath of binding.referencePaths) {\n if (t.isMemberExpression(referencePath.parent)) {\n // const memberExprParent = referencePath.parent;\n\n // if (memberExprParent.object && memberExprParent.property) {\n // const newMemberExpr = t.memberExpression(\n // memberExprParent.object,\n // t.identifier(`${(memberExprParent.property as t.Identifier).name}.value`),\n // );\n // referencePath.parentPath?.replaceWith(newMemberExpr);\n isUsedObject = true;\n // }\n }\n }\n\n return isUsedObject;\n}\n// TODO: 暂时不支持对象\nexport function replaceImportDeclaration(path: NodePath<ImportDeclaration>) {\n const imports = path.node.specifiers;\n imports.forEach(specifier => {\n const variableName = specifier.local.name;\n\n if (startsWith(variableName, '$') && !isVariableUsedAsObject(path, variableName)) {\n path.scope.rename(variableName, `${variableName}.value`);\n specifier.local.name = `${variableName}`;\n }\n });\n}\n","import { startsWith } from 'essor-shared';\nimport { type NodePath, types as t } from '@babel/core';\nimport { imports } from '../program';\nimport type { State } from '../types';\nimport type {\n ArrowFunctionExpression,\n FunctionDeclaration,\n Identifier,\n ObjectProperty,\n RestElement,\n} from '@babel/types';\n\nexport function replaceProps(path: NodePath<FunctionDeclaration | ArrowFunctionExpression>) {\n const state: State = path.state;\n\n const firstParam = path.node.params[0];\n\n if (!firstParam || !t.isObjectPattern(firstParam)) {\n return;\n }\n\n const returnStatement = path\n .get('body')\n .get('body')\n .find(statement => statement.isReturnStatement());\n\n if (!returnStatement) {\n return;\n }\n\n const returnValue = (returnStatement.node as any)?.argument;\n if (!t.isJSXElement(returnValue)) {\n return;\n }\n\n function replaceProperties(properties: (ObjectProperty | RestElement)[], parentPath: string) {\n properties.forEach(property => {\n if (t.isObjectProperty(property)) {\n const keyName = (property.key as Identifier).name;\n\n if (t.isIdentifier(property.value)) {\n const propertyName = property.value.name;\n const newName = `${parentPath}${keyName}`;\n path.scope.rename(propertyName, newName);\n } else if (t.isObjectPattern(property.value)) {\n replaceProperties(property.value.properties, `${parentPath}${keyName}.`);\n }\n }\n });\n }\n\n const properties = firstParam.properties;\n replaceProperties(\n properties.filter(property => !t.isRestElement(property)),\n '__props.',\n );\n const notRestProperties = properties.filter(property => !t.isRestElement(property));\n const notRestNames = notRestProperties.map(\n property => ((property as ObjectProperty).key as Identifier).name,\n );\n if (__DEV__ && notRestNames.some(name => startsWith(name, '$'))) {\n console.warn('props name can not start with $');\n return;\n }\n\n const restElement = properties.find(property => t.isRestElement(property)) as\n | RestElement\n | undefined;\n path.node.params[0] = t.identifier('__props');\n\n if (restElement) {\n const restName = (restElement.argument as any).name;\n if (notRestProperties.length === 0) {\n path.node.params[0] = t.identifier(restName);\n } else {\n const restVariableDeclaration = t.variableDeclaration('const', [\n t.variableDeclarator(\n t.identifier(restName),\n t.callExpression(state.useReactive, [\n t.identifier('__props'),\n t.arrayExpression(notRestNames.map(name => t.stringLiteral(name))),\n ]),\n ),\n ]);\n imports.add('useReactive');\n\n (path.node.body as any).body.unshift(restVariableDeclaration);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQO,IAAM,UAAU,MAAM;AAEtB,SAAS,SAAS,KAA6B;AACpD,SAAO,OAAO,QAAQ;AACxB;ACCO,IAAM,OAAO,SAAS;AAWtB,SAAS,WAAW,KAAK,cAAc;AAC5C,MAAI,CAAC,SAAS,GAAG,GAAG;AAClB,WAAO;EACT;AACA,SAAO,IAAI,QAAQ,YAAY,MAAM;AACvC;ACbO,IAAM,wBAAwB,CAAC,gBAAgC;AACpE,SAAO,YAAY,OAAO,CAAC,EAAE,YAAY,IAAI,YAAY,MAAM,CAAC;AAClE;;;ACjBA,IAAAA,eAA2B;;;ACD3B,kBAA0C;AAEnC,IAAM,UAAU,oBAAI,IAAY;AAEhC,IAAM,mBAAmB;AAAA,EAC9B,MAAM,MAA2B,OAAO;AACtC,YAAQ,MAAM;AAEd,SAAK,QAAQ;AAAA,MACX,GAAG,KAAK,MAAM,sBAAsB,IAAI;AAAA,MACxC,gBAAg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SAAS;AAAA,QAC7D,aAAAA,MAAE;AAAA,UACA,aAAAA,MAAE,WAAW,QAAQ;AAAA,UACrB,aAAAA,MAAE,eAAe,MAAM,aAAa;AAAA,YAClC,aAAAA,MAAE,WAAW,SAAS;AAAA,YACtB,aAAAA,MAAE,gBAAgB,aAAa,IAAI,UAAQ,aAAAA,MAAE,cAAc,IAAI,CAAC,CAAC;AAAA,UACnE,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AACD,cAAQ,IAAI,aAAa;AAEzB,MAAC,KAAK,KAAK,KAAa,KAAK,QAAQ,uBAAuB;AAAA,IAC9D;AAAA,EACF;AACF;;;AZ7Ee,SAAR,cAA+B;AACpC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,kBAAkB,EAAE,SAAS,GAAG,YAAY;AAC1C,UAAI,SAAS,SAAS,KAAK,KAAK,SAAS,SAAS,MAAM,GAAG;AACzD,mBAAW,QAAQ,KAAK,YAAY;AAAA,MACtC;AACA,iBAAW,QAAQ,KAAK,KAAK;AAAA,IAC/B;AAAA,IACA,SAAS;AAAA,MACP,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,qBAAqB;AAAA,MACrB,yBAAyB;AAAA,MACzB,oBAAoB;AAAA,MACpB,mBAAmB;AAAA,MACnB,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,cAAc;AAAA,IAChB;AAAA,EACF;AACF;","names":["import_core","t","import_core","t","t","value","import_core","createEssorNode","t","createProps","getAttrProps","getChildren","replaceChild","handleAttributes","transformChildren","isValidChild","getNodeText","transformChild","value","import_core","t","import_core","t","imports","import_core","t","properties"]}
1
+ {"version":3,"sources":["../src/index.ts","../../shared/src/is.ts","../../shared/src/comm.ts","../../shared/src/name.ts","../src/jsx/server.ts","../src/program.ts","../src/jsx/constants.ts","../src/jsx/shared.ts","../src/jsx/client.ts","../src/jsx/index.ts","../src/signal/symbol.ts","../src/signal/import.ts","../src/signal/props.ts"],"sourcesContent":["import { transformJSX } from './jsx';\r\nimport { transformProgram } from './program';\r\nimport {\r\n replaceSymbol,\r\n symbolArrayPattern,\r\n symbolIdentifier,\r\n symbolObjectPattern,\r\n} from './signal/symbol';\r\nimport { replaceImportDeclaration } from './signal/import';\r\nimport { replaceProps } from './signal/props';\r\nimport type { PluginObj } from '@babel/core';\r\nexport { Options, State } from './types';\r\nexport default function (): PluginObj {\r\n return {\r\n name: 'babel-plugin-essor',\r\n manipulateOptions({ filename }, parserOpts) {\r\n if (filename.endsWith('.ts') || filename.endsWith('.tsx')) {\r\n parserOpts.plugins.push('typescript');\r\n }\r\n parserOpts.plugins.push('jsx');\r\n },\r\n visitor: {\r\n Program: transformProgram,\r\n JSXElement: transformJSX,\r\n JSXFragment: transformJSX,\r\n FunctionDeclaration: replaceProps,\r\n ArrowFunctionExpression: replaceProps,\r\n VariableDeclarator: replaceSymbol,\r\n ImportDeclaration: replaceImportDeclaration,\r\n Identifier: symbolIdentifier,\r\n ObjectPattern: symbolObjectPattern,\r\n ArrayPattern: symbolArrayPattern,\r\n },\r\n };\r\n}\r\n","import { _toString } from './comm';\r\n\r\nexport const isObject = (val: unknown): val is Record<any, any> =>\r\n val !== null && typeof val === 'object';\r\nexport function isPromise(val: any): boolean {\r\n return _toString.call(val) === '[object Promise]';\r\n}\r\n\r\nexport const isArray = Array.isArray;\r\n\r\nexport function isString(val: unknown): val is string {\r\n return typeof val === 'string';\r\n}\r\nexport function isNull(val: any): val is null {\r\n return val === null;\r\n}\r\nexport function isSymbol(val: unknown): val is symbol {\r\n return typeof val === 'symbol';\r\n}\r\nexport function isMap(val: unknown): val is Map<any, any> {\r\n return _toString.call(val) === '[object Map]';\r\n}\r\nexport function isNil(x: any): x is null | undefined {\r\n return x === null || x === undefined;\r\n}\r\n\r\nexport const isFunction = (val: unknown): val is Function => typeof val === 'function';\r\n\r\nexport function isFalsy(x: any): x is false | null | undefined {\r\n return x === false || x === null || x === undefined || x === '';\r\n}\r\n\r\nexport const isPrimitive = (\r\n val: unknown,\r\n): val is string | number | boolean | symbol | null | undefined =>\r\n ['string', 'number', 'boolean', 'symbol', 'undefined'].includes(typeof val) || isNull(val);\r\n\r\nexport function isHTMLElement(obj) {\r\n if (!obj) return false;\r\n return obj && typeof obj === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string';\r\n}\r\n","import { isFunction, isPrimitive, isString } from './is';\r\n\r\nexport const _toString = Object.prototype.toString;\r\nexport const extend = Object.assign;\r\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\r\nexport const hasOwn = (val: object, key: string | symbol): key is keyof typeof val =>\r\n hasOwnProperty.call(val, key);\r\n\r\nexport function coerceArray<T>(data: T | T[]): T[] {\r\n return Array.isArray(data) ? (data.flat() as T[]) : [data];\r\n}\r\nexport const hasChanged = (value, oldValue) =>\r\n value !== oldValue && (value === value || oldValue === oldValue);\r\nexport const noop = Function.prototype as () => void;\r\n\r\n/**\r\n * A function that checks if a string starts with a specific substring.\r\n * indexOf faster under normal circumstances\r\n * @see https://www.measurethat.net/Benchmarks/Show/12350/0/startswith-vs-test-vs-match-vs-indexof#latest_results_block\r\n\r\n * @param {string} str - The input string to check.\r\n * @param {string} searchString - The substring to check for at the beginning of the input string.\r\n * @return {boolean} Returns true if the input string starts with the specified substring, otherwise false.\r\n */\r\nexport function startsWith(str, searchString) {\r\n if (!isString(str)) {\r\n return false;\r\n }\r\n return str.indexOf(searchString) === 0;\r\n}\r\n\r\n/**\r\n * Recursively clones an object, including its nested properties and special types like Date, RegExp, Map, and Set.\r\n *\r\n * @param {any} obj - The object to clone.\r\n * @param {WeakMap<object, object>} [hash] - A WeakMap used to track circular references.\r\n * @return {any} The cloned object.\r\n */\r\nexport function deepClone(obj, hash = new WeakMap()) {\r\n // Return primitives and functions as-is\r\n if (obj === null || typeof obj !== 'object') {\r\n return obj;\r\n }\r\n\r\n // Handle circular references\r\n if (hash.has(obj)) {\r\n return hash.get(obj);\r\n }\r\n\r\n // Handle special types\r\n if (obj instanceof Date) {\r\n return new Date(obj);\r\n }\r\n\r\n if (obj instanceof RegExp) {\r\n return new RegExp(obj);\r\n }\r\n\r\n if (obj instanceof Map) {\r\n const mapClone = new Map();\r\n hash.set(obj, mapClone);\r\n obj.forEach((value, key) => {\r\n mapClone.set(deepClone(key, hash), deepClone(value, hash));\r\n });\r\n return mapClone;\r\n }\r\n\r\n if (obj instanceof Set) {\r\n const setClone = new Set();\r\n hash.set(obj, setClone);\r\n obj.forEach(value => {\r\n setClone.add(deepClone(value, hash));\r\n });\r\n return setClone;\r\n }\r\n\r\n // Initialize the clone and store it in the WeakMap\r\n const cloneObj = Array.isArray(obj) ? [] : {};\r\n hash.set(obj, cloneObj);\r\n\r\n // Iterate over object keys\r\n const keys = Object.keys(obj);\r\n for (const key of keys) {\r\n cloneObj[key] = deepClone(obj[key], hash);\r\n }\r\n\r\n return cloneObj;\r\n}\r\n\r\n/**\r\n * Determines whether two values are deeply equal.\r\n *\r\n * @param {any} a - The first value to compare.\r\n * @param {any} b - The second value to compare.\r\n * @param {WeakMap<object, object>} [seen] - A WeakMap used to store previously seen objects to avoid infinite recursion.\r\n * @return {boolean} True if the values are deeply equal, false otherwise.\r\n */\r\nexport function deepEqual(a: any, b: any, seen = new WeakMap()): boolean {\r\n if (isPrimitive(a) && isPrimitive(b)) {\r\n return a === b;\r\n }\r\n\r\n if (a === b) {\r\n return true;\r\n }\r\n\r\n if (a == null || b == null || typeof a !== 'object' || typeof b !== 'object') {\r\n return false;\r\n }\r\n\r\n if (a.constructor !== b.constructor) {\r\n return false;\r\n }\r\n\r\n if (seen.has(a)) {\r\n return seen.get(a) === b;\r\n }\r\n\r\n seen.set(a, b);\r\n\r\n if (Array.isArray(a)) {\r\n if (a.length !== b.length) {\r\n return false;\r\n }\r\n for (const [i, element] of a.entries()) {\r\n if (!deepEqual(element, b[i], seen)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n if (a instanceof Map) {\r\n if (a.size !== b.size) {\r\n return false;\r\n }\r\n for (const [key, value] of a) {\r\n if (!b.has(key) || !deepEqual(value, b.get(key), seen)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n if (a instanceof Set) {\r\n if (a.size !== b.size) {\r\n return false;\r\n }\r\n const arrA = Array.from(a).sort();\r\n const arrB = Array.from(b).sort();\r\n for (const [i, element] of arrA.entries()) {\r\n if (!deepEqual(element, arrB[i], seen)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n const keysA = Object.keys(a);\r\n const keysB = new Set(Object.keys(b));\r\n\r\n if (keysA.length !== keysB.size) {\r\n return false;\r\n }\r\n\r\n for (const key of keysA) {\r\n if (!keysB.has(key) || !deepEqual(a[key], b[key], seen)) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n}\r\n\r\n/**\r\n * Escapes special HTML characters in a string.\r\n * @param str - The string to escape.\r\n * @returns The escaped string.\r\n */\r\nexport function escape(str: string): string {\r\n return str.replaceAll(/[\"&'<>]/g, char => {\r\n switch (char) {\r\n case '&':\r\n return '&amp;';\r\n case '<':\r\n return '&lt;';\r\n case '>':\r\n return '&gt;';\r\n case '\"':\r\n return '&quot;';\r\n case \"'\":\r\n return '&#039;';\r\n default:\r\n return char;\r\n }\r\n });\r\n}\r\n\r\nexport type ExcludeType = ((key: string | symbol) => boolean) | (string | symbol)[];\r\n\r\n/**\r\n * Checks if a key should be excluded based on the provided exclude criteria.\r\n * @param key - The key to check.\r\n * @param exclude - The exclusion criteria.\r\n * @returns True if the key should be excluded, otherwise false.\r\n */\r\nexport function isExclude(key: string | symbol, exclude?: ExcludeType): boolean {\r\n return Array.isArray(exclude)\r\n ? exclude.includes(key)\r\n : isFunction(exclude)\r\n ? exclude(key)\r\n : false;\r\n}\r\n","export const kebabCase = (string: string): string => {\r\n return string.replaceAll(/[A-Z]+/g, (match, offset) => {\r\n return `${offset > 0 ? '-' : ''}${match.toLocaleLowerCase()}`;\r\n });\r\n};\r\n\r\nexport const camelCase = (str: string): string => {\r\n const s = str.replaceAll(/[\\s_-]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''));\r\n return s[0].toLowerCase() + s.slice(1);\r\n};\r\n/**\r\n * Capitalizes the first letter of a string.\r\n *\r\n * @param {string} inputString - The input string to capitalize the first letter.\r\n * @return {string} The string with the first letter capitalized.\r\n */\r\nexport const capitalizeFirstLetter = (inputString: string): string => {\r\n return inputString.charAt(0).toUpperCase() + inputString.slice(1);\r\n};\r\n","import { capitalizeFirstLetter } from 'essor-shared';\r\nimport { types as t } from '@babel/core';\r\nimport { imports } from '../program';\r\nimport { selfClosingTags, svgTags } from './constants';\r\nimport {\r\n type JSXChild,\r\n type JSXElement,\r\n getAttrName,\r\n getTagName,\r\n isComponent,\r\n isTextChild,\r\n setNodeText,\r\n} from './shared';\r\nimport type { OptionalMemberExpression } from '@babel/types';\r\nimport type { State } from '../types';\r\nimport type { NodePath } from '@babel/core';\r\n\r\nexport interface Result {\r\n index: number;\r\n isLastChild: boolean;\r\n parentIndex: number;\r\n props: Record<string, any>;\r\n template: string[];\r\n}\r\n\r\nexport function transformJSXService(path: NodePath<JSXElement>): void {\r\n const result: Result = {\r\n index: 0,\r\n isLastChild: false,\r\n parentIndex: 0,\r\n props: {},\r\n template: [], // 修改为数组\r\n };\r\n transformJSXServiceElement(path, result, true);\r\n path.replaceWith(createEssorNode(path, result));\r\n}\r\n\r\nfunction createEssorNode(path: NodePath<JSXElement>, result: Result): t.CallExpression {\r\n const state: State = path.state;\r\n\r\n let tmpl: t.Identifier;\r\n if (path.isJSXElement() && isComponent(getTagName(path.node))) {\r\n tmpl = t.identifier(getTagName(path.node));\r\n } else {\r\n tmpl = path.scope.generateUidIdentifier('_tmpl$');\r\n const template = t.arrayExpression(result.template.map(t.stringLiteral));\r\n const declarator = t.variableDeclarator(tmpl, template);\r\n state.tmplDeclaration.declarations.push(declarator);\r\n }\r\n\r\n const args = [tmpl, createProps(result.props)];\r\n const key = result.props.key || result.props[0]?.key;\r\n if (key) {\r\n args.push(key);\r\n }\r\n imports.add('renderTemplate');\r\n return t.callExpression(state.renderTemplate, args);\r\n}\r\n\r\nfunction createProps(props: Record<string, any>): t.ObjectExpression {\r\n const result: (t.ObjectProperty | t.SpreadElement)[] = [];\r\n\r\n for (const prop in props) {\r\n let value = props[prop];\r\n\r\n if (prop === 'key') {\r\n continue;\r\n }\r\n\r\n if (Array.isArray(value)) {\r\n value = t.arrayExpression(value);\r\n }\r\n\r\n if (typeof value === 'object' && value !== null && !t.isNode(value)) {\r\n value = createProps(value);\r\n }\r\n\r\n if (typeof value === 'string') {\r\n value = t.stringLiteral(value);\r\n }\r\n\r\n if (typeof value === 'number') {\r\n value = t.numericLiteral(value);\r\n }\r\n\r\n if (typeof value === 'boolean') {\r\n value = t.booleanLiteral(value);\r\n }\r\n\r\n if (value === undefined) {\r\n value = t.tsUndefinedKeyword();\r\n }\r\n\r\n if (value === null) {\r\n value = t.nullLiteral();\r\n }\r\n\r\n if (prop === '_$spread$') {\r\n result.push(t.spreadElement(value));\r\n } else {\r\n result.push(t.objectProperty(t.stringLiteral(prop), value));\r\n }\r\n }\r\n\r\n return t.objectExpression(result);\r\n}\r\nfunction transformJSXServiceElement(\r\n path: NodePath<JSXElement>,\r\n result: Result,\r\n isRoot: boolean = false,\r\n): void {\r\n if (path.isJSXElement()) {\r\n const tagName = getTagName(path.node);\r\n const tagIsComponent = isComponent(tagName);\r\n const isSelfClose = !tagIsComponent && selfClosingTags.includes(tagName);\r\n const isSvg = svgTags.includes(tagName) && result.index === 1;\r\n const { props, hasExpression } = getAttrProps(path);\r\n if (tagIsComponent) {\r\n if (isRoot) {\r\n result.props = props;\r\n const children = getChildren(path) as any;\r\n if (children.length > 0) {\r\n const childrenGenerator =\r\n children.length === 1 ? children[0] : t.arrayExpression(children);\r\n result.props.children = childrenGenerator;\r\n }\r\n } else {\r\n transformJSXService(path);\r\n replaceChild(path.node, result);\r\n }\r\n } else {\r\n if (isSvg) {\r\n result.template.push('<svg _svg_>');\r\n }\r\n result.template.push(`<${tagName}`);\r\n handleAttributes(props, result);\r\n\r\n if (hasExpression) {\r\n result.template.push(isSelfClose ? '/>' : '>');\r\n result.props ||= {};\r\n } else {\r\n result.template[result.template.length - 1] += isSelfClose ? '/>' : '>';\r\n }\r\n transformChildren(path, result);\r\n\r\n if (!isSelfClose) {\r\n result.template.push(`</${tagName}>`);\r\n }\r\n }\r\n } else {\r\n result.index--;\r\n transformChildren(path, result);\r\n }\r\n}\r\n\r\nfunction transformChildren(path: NodePath<JSXElement>, result: Result): void {\r\n const parentIndex = result.template.length;\r\n path\r\n .get('children')\r\n .reduce((pre, cur) => {\r\n if (isValidChild(cur)) {\r\n const lastChild = pre.at(-1);\r\n if (lastChild && isTextChild(cur) && isTextChild(lastChild)) {\r\n setNodeText(lastChild, getNodeText(lastChild) + getNodeText(cur));\r\n } else {\r\n pre.push(cur);\r\n }\r\n }\r\n return pre;\r\n }, [] as NodePath<JSXChild>[])\r\n .forEach((child, i, arr) => {\r\n result.parentIndex = parentIndex;\r\n result.isLastChild = i === arr.length - 1;\r\n transformChild(child, result);\r\n });\r\n}\r\n\r\nfunction transformChild(child: NodePath<JSXChild>, result: Result): void {\r\n if (child.isJSXElement() || child.isJSXFragment()) {\r\n transformJSXServiceElement(child, result, false);\r\n } else if (child.isJSXExpressionContainer()) {\r\n const expression = child.get('expression');\r\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\r\n result.template[result.template.length - 1] += String(expression.node.value);\r\n } else if (expression.isExpression()) {\r\n replaceChild(expression.node, result);\r\n } else if (t.isJSXEmptyExpression(expression.node)) {\r\n // it is empty expression\r\n // do nothing\r\n } else {\r\n throw new Error('Unsupported child type');\r\n }\r\n } else if (child.isJSXText()) {\r\n result.template.push(String(child.node.value));\r\n } else {\r\n throw new Error('Unsupported child type');\r\n }\r\n}\r\n\r\nfunction getNodeText(path: NodePath<JSXChild>): string {\r\n if (path.isJSXText()) {\r\n return path.node.value;\r\n }\r\n if (path.isJSXExpressionContainer()) {\r\n const expression = path.get('expression');\r\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\r\n return String(expression.node.value);\r\n }\r\n }\r\n return '';\r\n}\r\n\r\nfunction handleAttributes(props: Record<string, any>, result: Result): void {\r\n let klass = '';\r\n let style = '';\r\n\r\n for (const prop in props) {\r\n const value = props[prop];\r\n\r\n if (prop === 'class' && typeof value === 'string') {\r\n klass += ` ${value}`;\r\n delete props[prop];\r\n continue;\r\n }\r\n\r\n if (prop === 'style' && typeof value === 'string') {\r\n style += `${value}${value.at(-1) === ';' ? '' : ';'}`;\r\n delete props[prop];\r\n continue;\r\n }\r\n\r\n if (value === true) {\r\n result.template[result.template.length - 1] += ` ${prop}`;\r\n delete props[prop];\r\n }\r\n if (value === false) {\r\n delete props[prop];\r\n }\r\n if (typeof value === 'string' || typeof value === 'number') {\r\n result.template[result.template.length - 1] += ` ${prop}=\"${value}\"`;\r\n delete props[prop];\r\n }\r\n }\r\n\r\n if (Object.keys(props).length > 0) {\r\n result.props[result.index] = props;\r\n }\r\n\r\n klass = klass.trim();\r\n style = style.trim();\r\n\r\n if (klass) {\r\n result.template[result.template.length - 1] += ` class=\"${klass}\"`;\r\n }\r\n if (style) {\r\n result.template[result.template.length - 1] += ` style=\"${style}\"`;\r\n }\r\n}\r\n\r\nfunction replaceChild(node: t.Expression, result: Result): void {\r\n if (result.isLastChild) {\r\n result.index--;\r\n }\r\n result.props[result.parentIndex] ??= {};\r\n result.props[result.parentIndex].children ??= [];\r\n result.props[result.parentIndex].children.push(\r\n t.arrayExpression([\r\n t.arrowFunctionExpression([], node),\r\n t.identifier(String(result.template.length)),\r\n ]),\r\n );\r\n}\r\n\r\nfunction getChildren(path: NodePath<JSXElement>): JSXChild[] {\r\n return path\r\n .get('children')\r\n .filter(child => isValidChild(child))\r\n .map(child => {\r\n if (child.isJSXElement() || child.isJSXFragment()) {\r\n transformJSXService(child);\r\n } else if (child.isJSXExpressionContainer()) {\r\n child.replaceWith(child.get('expression'));\r\n } else if (child.isJSXText()) {\r\n child.replaceWith(t.stringLiteral(child.node.value));\r\n } else {\r\n throw new Error('Unsupported child type');\r\n }\r\n return child.node;\r\n });\r\n}\r\n\r\nfunction isValidChild(path: NodePath<JSXChild>): boolean {\r\n const regex = /^\\s*$/;\r\n if (path.isStringLiteral() || path.isJSXText()) {\r\n return !regex.test(path.node.value);\r\n }\r\n return Object.keys(path.node).length > 0;\r\n}\r\nfunction getAttrProps(path: NodePath<t.JSXElement>): Record<string, any> {\r\n const props: Record<string, any> = {};\r\n let hasExpression = false;\r\n path\r\n .get('openingElement')\r\n .get('attributes')\r\n .forEach(attribute => {\r\n if (attribute.isJSXAttribute()) {\r\n const name = getAttrName(attribute.node);\r\n const value = attribute.get('value');\r\n\r\n if (!value.node) {\r\n props[name] = true;\r\n } else if (value.isStringLiteral()) {\r\n props[name] = value.node.value;\r\n } else {\r\n if (value.isJSXExpressionContainer()) {\r\n const expression = value.get('expression');\r\n\r\n if (expression.isStringLiteral()) {\r\n props[name] = expression.node.value;\r\n } else if (expression.isNumericLiteral()) {\r\n props[name] = expression.node.value;\r\n } else if (expression.isJSXElement() || expression.isJSXFragment()) {\r\n transformJSXService(expression);\r\n props[name] = expression.node;\r\n } else if (expression.isExpression()) {\r\n hasExpression = true;\r\n if (/^key|ref|on.+$/.test(name)) {\r\n props[name] = expression.node;\r\n } else if (/^bind:.+/.test(name)) {\r\n const value = path.scope.generateUidIdentifier('value');\r\n const bindName = name.slice(5).toLocaleLowerCase();\r\n props[bindName] = expression.node;\r\n props[`update${capitalizeFirstLetter(bindName)}`] = t.arrowFunctionExpression(\r\n [value],\r\n t.assignmentExpression('=', expression.node as OptionalMemberExpression, value),\r\n );\r\n } else {\r\n if (expression.isConditionalExpression()) {\r\n props[name] = t.arrowFunctionExpression([], expression.node);\r\n } else {\r\n props[name] = expression.node;\r\n }\r\n }\r\n }\r\n } else if (value.isJSXElement() || value.isJSXFragment()) {\r\n transformJSXService(value);\r\n props[name] = value.node;\r\n }\r\n }\r\n } else if (attribute.isJSXSpreadAttribute()) {\r\n props._$spread$ = attribute.get('argument').node;\r\n hasExpression = true;\r\n } else {\r\n throw new Error('Unsupported attribute type');\r\n }\r\n });\r\n\r\n return {\r\n props,\r\n hasExpression,\r\n };\r\n}\r\n","import { type NodePath, types as t } from '@babel/core';\nimport type { State } from './types';\nexport const imports = new Set<string>();\n\nexport const transformProgram = {\n enter(path: NodePath<t.Program>, state) {\n imports.clear();\n\n path.state = {\n h: path.scope.generateUidIdentifier('h$'),\n renderTemplate: path.scope.generateUidIdentifier('renderTemplate$'),\n template: path.scope.generateUidIdentifier('template$'),\n\n useSignal: path.scope.generateUidIdentifier('signal$'),\n useComputed: path.scope.generateUidIdentifier('computed$'),\n useReactive: path.scope.generateUidIdentifier('reactive$'),\n\n tmplDeclaration: t.variableDeclaration('const', []),\n opts: state.opts,\n } as State;\n },\n exit(path: NodePath<t.Program>) {\n const state: State = path.state;\n if (state.tmplDeclaration.declarations.length > 0) {\n const index = path.node.body.findIndex(\n node => !t.isImportDeclaration(node) && !t.isExportDeclaration(node),\n );\n path.node.body.splice(index, 0, state.tmplDeclaration);\n }\n if (imports.size > 0) {\n path.node.body.unshift(createImport(state, 'essor'));\n }\n },\n};\nfunction createImport(state: State, from: string) {\n const ImportSpecifier: t.ImportSpecifier[] = [];\n imports.forEach(name => {\n const local = t.identifier(state[name].name);\n const imported = t.identifier(name);\n ImportSpecifier.push(t.importSpecifier(local, imported));\n });\n\n const importSource = t.stringLiteral(from);\n return t.importDeclaration(ImportSpecifier, importSource);\n}\n","export const selfClosingTags = [\r\n 'area',\r\n 'base',\r\n 'br',\r\n 'col',\r\n 'embed',\r\n 'hr',\r\n 'img',\r\n 'input',\r\n 'link',\r\n 'meta',\r\n 'param',\r\n 'source',\r\n 'track',\r\n 'wbr',\r\n];\r\n\r\nexport const svgTags = [\r\n 'circle',\r\n 'clipPath',\r\n 'defs',\r\n 'ellipse',\r\n 'filter',\r\n 'g',\r\n 'line',\r\n 'linearGradient',\r\n 'mask',\r\n 'path',\r\n 'pattern',\r\n 'polygon',\r\n 'polyline',\r\n 'radialGradient',\r\n 'rect',\r\n 'stop',\r\n 'symbol',\r\n 'text',\r\n 'use',\r\n];\r\n","import { type NodePath, types as t } from '@babel/core';\r\n\r\nexport type JSXElement = t.JSXElement | t.JSXFragment;\r\n\r\nexport type JSXChild =\r\n | t.JSXElement\r\n | t.JSXFragment\r\n | t.JSXExpressionContainer\r\n | t.JSXSpreadChild\r\n | t.JSXText;\r\n\r\n/**\r\n * Checks if the given Babel path has a sibling element.\r\n *\r\n * @param {NodePath} path - The Babel path to check.\r\n * @return {boolean} True if the path has a sibling element, false otherwise.\r\n */\r\nexport function hasSiblingElement(path) {\r\n // Get all siblings (both previous and next)\r\n const siblings = path.getAllPrevSiblings().concat(path.getAllNextSiblings());\r\n\r\n // Check for non-self-closing sibling elements or JSXExpressionContainer\r\n const hasSibling = siblings.some(\r\n siblingPath => siblingPath.isJSXElement() || siblingPath.isJSXExpressionContainer(),\r\n );\r\n\r\n return hasSibling;\r\n}\r\n/**\r\n * Retrieves the name of a JSX attribute.\r\n *\r\n * @param {t.JSXAttribute} attribute - The JSX attribute to retrieve the name from.\r\n * @return {string} The name of the attribute.\r\n * @throws {Error} If the attribute type is unsupported.\r\n */\r\nexport function getAttrName(attribute: t.JSXAttribute): string {\r\n if (t.isJSXIdentifier(attribute.name)) {\r\n return attribute.name.name;\r\n }\r\n if (t.isJSXNamespacedName(attribute.name)) {\r\n return `${attribute.name.namespace.name}:${attribute.name.name.name}`;\r\n }\r\n throw new Error('Unsupported attribute type');\r\n}\r\n\r\n/**\r\n * Retrieves the tag name of a JSX element.\r\n *\r\n * @param {t.JSXElement} node - The JSX element.\r\n * @return {string} The tag name of the JSX element.\r\n */\r\nexport function getTagName(node: t.JSXElement): string {\r\n const tag = node.openingElement.name;\r\n return jsxElementNameToString(tag);\r\n}\r\n\r\n/**\r\n * Converts a JSX element name to a string representation.\r\n *\r\n * case1: <MyComponent />\r\n * case2: <SomeLibrary.SomeComponent />;\r\n * case3: <namespace:ComponentName />;\r\n * case4: <SomeLibrary.Nested.ComponentName />;\r\n *\r\n * @param {t.JSXMemberExpression | t.JSXIdentifier | t.JSXNamespacedName} node The JSX element name to convert.\r\n * @returns {string} The string representation of the JSX element name.\r\n */\r\nexport function jsxElementNameToString(\r\n node: t.JSXMemberExpression | t.JSXIdentifier | t.JSXNamespacedName,\r\n) {\r\n if (t.isJSXMemberExpression(node)) {\r\n return `${jsxElementNameToString(node.object)}.${jsxElementNameToString(node.property)}`;\r\n }\r\n\r\n if (t.isJSXIdentifier(node) || t.isIdentifier(node)) {\r\n return node.name;\r\n }\r\n\r\n return `${node.namespace.name}:${node.name.name}`;\r\n}\r\n\r\n/**\r\n * Determines if the given tagName is a component.\r\n *\r\n * case1: <MyComponent />\r\n * case2: <SomeLibrary.SomeComponent />;\r\n * case3: <_component />;\r\n *\r\n * @param {string} tagName - The name of the tag to check.\r\n * @return {boolean} True if the tagName is a component, false otherwise.\r\n */\r\nexport function isComponent(tagName: string): boolean {\r\n return (\r\n (tagName[0] && tagName[0].toLowerCase() !== tagName[0]) ||\r\n tagName.includes('.') ||\r\n /[^a-z]/i.test(tagName[0])\r\n );\r\n}\r\n\r\n/**\r\n * Determines if the given path represents a text child node in a JSX expression.\r\n *\r\n * @param {NodePath<JSXChild>} path - The path to the potential text child node.\r\n * @return {boolean} True if the path represents a text child node, false otherwise.\r\n */\r\nexport function isTextChild(path: NodePath<JSXChild>): boolean {\r\n if (path.isJSXExpressionContainer()) {\r\n const expression = path.get('expression');\r\n if (expression.isJSXText() || expression.isStringLiteral() || expression.isNumericLiteral()) {\r\n return true;\r\n }\r\n }\r\n if (path.isJSXText() || path.isStringLiteral() || path.isNullLiteral()) {\r\n return true;\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Sets the text content of a JSX node.\r\n *\r\n * @param {NodePath<JSXChild>} path - The path to the JSX node.\r\n * @param {string} text - The text to set.\r\n * @return {void}\r\n */\r\nexport function setNodeText(path: NodePath<JSXChild>, text: string): void {\r\n if (path.isJSXText()) {\r\n path.node.value = text;\r\n }\r\n if (path.isJSXExpressionContainer()) {\r\n const expression = path.get('expression');\r\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\r\n expression.replaceWith(t.stringLiteral(text));\r\n }\r\n }\r\n}\r\n","import { types as t } from '@babel/core';\nimport { capitalizeFirstLetter } from 'essor-shared';\nimport { imports } from '../program';\nimport { selfClosingTags, svgTags } from './constants';\nimport {\n type JSXChild,\n type JSXElement,\n getAttrName,\n getTagName,\n hasSiblingElement,\n isComponent,\n isTextChild,\n setNodeText,\n} from './shared';\nimport type { OptionalMemberExpression } from '@babel/types';\nimport type { State } from '../types';\nimport type { NodePath } from '@babel/core';\n\nexport interface Result {\n index: number;\n isLastChild: boolean;\n parentIndex: number;\n props: Record<string, any>;\n template: string;\n}\n\nexport function transformJSXClient(path: NodePath<JSXElement>): void {\n const result: Result = {\n index: 1,\n isLastChild: false,\n parentIndex: 0,\n props: {},\n template: '',\n };\n transformJSXElement(path, result, true);\n\n path.replaceWith(createEssorNode(path, result));\n}\n\nfunction createEssorNode(path: NodePath<JSXElement>, result: Result): t.CallExpression {\n const state: State = path.state;\n\n let tmpl: t.Identifier;\n if (path.isJSXElement() && isComponent(getTagName(path.node))) {\n tmpl = t.identifier(getTagName(path.node));\n } else {\n tmpl = path.scope.generateUidIdentifier('_tmpl$');\n const template = t.callExpression(state.template, [t.stringLiteral(result.template)]);\n const declarator = t.variableDeclarator(tmpl, template);\n state.tmplDeclaration.declarations.push(declarator);\n imports.add('template');\n }\n\n const args = [tmpl, createProps(result.props)];\n const key = result.props.key || result.props[0]?.key;\n if (key) {\n args.push(key);\n }\n imports.add('h');\n return t.callExpression(state.h, args);\n}\n\nfunction createProps(props) {\n const toAstNode = value => {\n if (Array.isArray(value)) {\n return t.arrayExpression(value.map(toAstNode));\n }\n if (value && typeof value === 'object' && !t.isNode(value)) {\n return createProps(value);\n }\n\n switch (typeof value) {\n case 'string':\n return t.stringLiteral(value);\n case 'number':\n return t.numericLiteral(value);\n case 'boolean':\n return t.booleanLiteral(value);\n case 'undefined':\n return t.tsUndefinedKeyword();\n case undefined:\n return t.tsUndefinedKeyword();\n case null:\n return t.nullLiteral();\n default:\n return value;\n }\n };\n\n const result = Object.keys(props)\n .filter(prop => prop !== 'key')\n .map(prop => {\n const value = toAstNode(props[prop]);\n return prop === '_$spread$'\n ? t.spreadElement(value)\n : t.objectProperty(t.stringLiteral(prop), value);\n });\n\n return t.objectExpression(result);\n}\nfunction transformJSXElement(\n path: NodePath<JSXElement>,\n result: Result,\n isRoot: boolean = false,\n): void {\n if (path.isJSXElement()) {\n const tagName = getTagName(path.node);\n const tagIsComponent = isComponent(tagName);\n const isSelfClose = !tagIsComponent && selfClosingTags.includes(tagName);\n const isSvg = svgTags.includes(tagName) && result.index === 1;\n const props = getAttrProps(path);\n if (tagIsComponent) {\n if (isRoot) {\n result.props = props;\n const children = getChildren(path) as any;\n if (children.length > 0) {\n const childrenGenerator =\n children.length === 1 ? children[0] : t.arrayExpression(children);\n result.props.children = childrenGenerator;\n }\n } else {\n transformJSXClient(path);\n replaceChild(path.node, result);\n }\n } else {\n if (isSvg) {\n result.template = '<svg _svg_>';\n }\n result.template += `<${tagName}`;\n handleAttributes(props, result);\n result.template += isSelfClose ? '/>' : '>';\n if (!isSelfClose) {\n transformChildren(path, result);\n\n if (hasSiblingElement(path)) {\n result.template += `</${tagName}>`;\n }\n }\n }\n } else {\n result.index--;\n transformChildren(path, result);\n }\n}\n\nfunction transformChildren(path: NodePath<JSXElement>, result: Result): void {\n const parentIndex = result.index;\n path\n .get('children')\n .reduce((pre, cur) => {\n if (isValidChild(cur)) {\n const lastChild = pre.at(-1);\n if (lastChild && isTextChild(cur) && isTextChild(lastChild)) {\n setNodeText(lastChild, getNodeText(lastChild) + getNodeText(cur));\n } else {\n pre.push(cur);\n }\n }\n return pre;\n }, [] as NodePath<JSXChild>[])\n .forEach((child, i, arr) => {\n result.parentIndex = parentIndex;\n result.isLastChild = i === arr.length - 1;\n transformChild(child, result);\n });\n}\n\nfunction transformChild(child: NodePath<JSXChild>, result: Result): void {\n result.index++;\n if (child.isJSXElement() || child.isJSXFragment()) {\n transformJSXElement(child, result, false);\n } else if (child.isJSXExpressionContainer()) {\n const expression = child.get('expression');\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\n result.template += String(expression.node.value);\n } else if (expression.isExpression()) {\n replaceChild(expression.node, result);\n } else if (t.isJSXEmptyExpression(expression.node)) {\n // it is empty expression\n // do nothing\n } else {\n throw new Error('Unsupported child type');\n }\n } else if (child.isJSXText()) {\n result.template += String(child.node.value);\n } else {\n throw new Error('Unsupported child type');\n }\n}\n\nfunction getNodeText(path: NodePath<JSXChild>): string {\n if (path.isJSXText()) {\n return path.node.value;\n }\n if (path.isJSXExpressionContainer()) {\n const expression = path.get('expression');\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\n return String(expression.node.value);\n }\n }\n return '';\n}\n\nfunction handleAttributes(props: Record<string, any>, result: Result): void {\n let klass = '';\n let style = '';\n\n for (const prop in props) {\n let value = props[prop];\n\n if (prop === 'class' && typeof value === 'string') {\n klass += ` ${value}`;\n delete props[prop];\n continue;\n }\n\n if (prop === 'style' && typeof value === 'string') {\n style += `${value}${value.at(-1) === ';' ? '' : ';'}`;\n delete props[prop];\n continue;\n }\n\n if (value === true) {\n result.template += ` ${prop}`;\n delete props[prop];\n }\n if (value === false) {\n delete props[prop];\n }\n if (typeof value === 'string' || typeof value === 'number') {\n result.template += ` ${prop}=\"${value}\"`;\n delete props[prop];\n }\n\n // if value is conditional expression\n if (t.isConditionalExpression(value)) {\n const { test, consequent, alternate } = value;\n value = t.arrowFunctionExpression([], t.conditionalExpression(test, consequent, alternate));\n props[prop] = value;\n }\n\n // if value is object expression and has conditional\n if (t.isObjectExpression(value)) {\n let hasConditional = false;\n value.properties.forEach(property => {\n if (t.isObjectProperty(property) && t.isConditionalExpression(property.value)) {\n hasConditional = true;\n }\n });\n if (hasConditional) {\n value = t.arrowFunctionExpression([], value);\n }\n\n props[prop] = value;\n }\n }\n\n if (Object.keys(props).length > 0) {\n result.props[result.index] = props;\n }\n\n klass = klass.trim();\n style = style.trim();\n\n if (klass) {\n result.template += ` class=\"${klass}\"`;\n }\n if (style) {\n result.template += ` style=\"${style}\"`;\n }\n}\n\nfunction replaceChild(node: t.Expression, result: Result): void {\n if (result.isLastChild) {\n result.index--;\n } else {\n result.template += '<!>';\n }\n result.props[result.parentIndex] ??= {};\n result.props[result.parentIndex].children ??= [];\n result.props[result.parentIndex].children.push(\n t.arrayExpression([\n t.arrowFunctionExpression([], node),\n result.isLastChild ? t.nullLiteral() : t.identifier(String(result.index)),\n ]),\n );\n}\n\nfunction getChildren(path: NodePath<JSXElement>): JSXChild[] {\n return path\n .get('children')\n .filter(child => isValidChild(child))\n .map(child => {\n if (child.isJSXElement() || child.isJSXFragment()) {\n transformJSXClient(child);\n } else if (child.isJSXExpressionContainer()) {\n child.replaceWith(child.get('expression'));\n } else if (child.isJSXText()) {\n child.replaceWith(t.stringLiteral(child.node.value));\n } else {\n throw new Error('Unsupported child type');\n }\n return child.node;\n });\n}\n\nexport function isValidChild(path: NodePath<JSXChild>): boolean {\n const regex = /^\\s*$/;\n if (path.isStringLiteral() || path.isJSXText()) {\n return !regex.test(path.node.value);\n }\n return Object.keys(path.node).length > 0;\n}\nexport function getAttrProps(path: NodePath<t.JSXElement>): Record<string, any> {\n const props: Record<string, any> = {};\n\n path\n .get('openingElement')\n .get('attributes')\n .forEach(attribute => {\n if (attribute.isJSXAttribute()) {\n const name = getAttrName(attribute.node);\n const value = attribute.get('value');\n\n if (!value.node) {\n props[name] = true;\n } else if (value.isStringLiteral()) {\n props[name] = value.node.value;\n } else {\n if (value.isJSXExpressionContainer()) {\n const expression = value.get('expression');\n\n if (expression.isStringLiteral()) {\n props[name] = expression.node.value;\n } else if (expression.isNumericLiteral()) {\n props[name] = expression.node.value;\n } else if (expression.isJSXElement() || expression.isJSXFragment()) {\n transformJSXClient(expression);\n props[name] = expression.node;\n } else if (expression.isExpression()) {\n if (/^key|ref|on.+$/.test(name)) {\n props[name] = expression.node;\n } else if (/^bind:.+/.test(name)) {\n const value = path.scope.generateUidIdentifier('value');\n const bindName = name.slice(5).toLocaleLowerCase();\n props[bindName] = expression.node;\n props[`update${capitalizeFirstLetter(bindName)}`] = t.arrowFunctionExpression(\n [value],\n t.assignmentExpression('=', expression.node as OptionalMemberExpression, value),\n );\n } else {\n if (expression.isConditionalExpression()) {\n props[name] = t.arrowFunctionExpression([], expression.node);\n } else {\n props[name] = expression.node;\n }\n }\n }\n } else if (value.isJSXElement() || value.isJSXFragment()) {\n transformJSXClient(value);\n props[name] = value.node;\n }\n }\n } else if (attribute.isJSXSpreadAttribute()) {\n props._$spread$ = attribute.get('argument').node;\n } else {\n throw new Error('Unsupported attribute type');\n }\n });\n\n return props;\n}\n","import { transformJSXService } from './server';\r\nimport { transformJSXClient } from './client';\r\nimport type { NodePath, types as t } from '@babel/core';\r\nimport type { State } from '../types';\r\ntype JSXElement = t.JSXElement | t.JSXFragment;\r\nexport function transformJSX(path: NodePath<JSXElement>) {\r\n const state: State = path.state;\r\n const isSsg = state.opts.ssg;\r\n return isSsg ? transformJSXService(path) : transformJSXClient(path);\r\n}\r\n","import { types as t } from '@babel/core';\r\nimport { startsWith } from 'essor-shared';\r\nimport { imports } from '../program';\r\nimport type { Identifier, VariableDeclarator } from '@babel/types';\r\nimport type { NodePath } from '@babel/core';\r\n\r\n/**\r\n * 当一个变量/常量声明的时候,判断是否是$(定义的符号)开头,如果是,则进行转换。\r\n *\r\n * case 1: let $a = 1 => let $a = useSignal(1);\r\n * case 2: const $a = ()=>{return $a} => const $a = useComputed(()=>{return $a})\r\n *\r\n * 并且所有当前用到的值,都会添加.value\r\n * @param path\r\n * @returns {void}\r\n */\r\nexport function replaceSymbol(path: NodePath<VariableDeclarator>) {\r\n const init = path.node.init;\r\n const variableName = (path.node.id as Identifier).name;\r\n\r\n if (t.isObjectPattern(path.node.id) || t.isArrayPattern(path.node.id)) {\r\n return;\r\n }\r\n\r\n if (!startsWith(variableName, '$')) {\r\n return;\r\n }\r\n\r\n if (\r\n init &&\r\n (t.isFunctionExpression(init) || t.isArrowFunctionExpression(init)) &&\r\n (path.parent as t.VariableDeclaration).kind === 'const'\r\n ) {\r\n const newInit = t.callExpression(t.identifier(path.state.useComputed.name), init ? [init] : []);\r\n imports.add('useComputed');\r\n path.node.init = newInit;\r\n } else {\r\n const newInit = t.callExpression(t.identifier(path.state.useSignal.name), init ? [init] : []);\r\n imports.add('useSignal');\r\n path.node.init = newInit;\r\n }\r\n}\r\n\r\nexport function symbolIdentifier(path) {\r\n const parentPath = path.parentPath;\r\n\r\n if (\r\n !parentPath ||\r\n t.isVariableDeclarator(parentPath) ||\r\n t.isImportSpecifier(parentPath) ||\r\n t.isObjectProperty(parentPath) ||\r\n t.isArrayPattern(parentPath) ||\r\n t.isObjectPattern(parentPath)\r\n ) {\r\n return;\r\n }\r\n\r\n const { node } = path;\r\n\r\n if (node.name.startsWith('$')) {\r\n // check is has .value\r\n let currentPath = path;\r\n while (currentPath.parentPath && !currentPath.parentPath.isProgram()) {\r\n if (\r\n currentPath.parentPath.isMemberExpression() &&\r\n currentPath.parentPath.node.property.name === 'value'\r\n ) {\r\n return;\r\n }\r\n currentPath = currentPath.parentPath;\r\n }\r\n\r\n // add with .value\r\n const newNode = t.memberExpression(t.identifier(node.name), t.identifier('value'));\r\n\r\n path.replaceWith(newNode);\r\n }\r\n}\r\n\r\nexport function symbolObjectPattern(path) {\r\n path.node.properties.forEach(property => {\r\n if (\r\n t.isObjectProperty(property) &&\r\n t.isIdentifier(property.key) &&\r\n property.key.name.startsWith('$')\r\n ) {\r\n const newKey = t.identifier(property.key.name);\r\n property.key = newKey;\r\n }\r\n });\r\n}\r\n\r\nexport function symbolArrayPattern(path) {\r\n path.node.elements.forEach(element => {\r\n if (t.isIdentifier(element) && element.name.startsWith('$')) {\r\n const newElement = t.identifier(element.name);\r\n element.name = newElement.name;\r\n } else if (t.isObjectPattern(element)) {\r\n element.properties.forEach(property => {\r\n if (\r\n t.isObjectProperty(property) &&\r\n t.isIdentifier(property.key) &&\r\n property.key.name.startsWith('$')\r\n ) {\r\n const newKey = t.identifier(property.key.name);\r\n property.key = newKey;\r\n }\r\n });\r\n }\r\n });\r\n}\r\n","import { type NodePath, types as t } from '@babel/core';\r\nimport { startsWith } from 'essor-shared';\r\nimport type { ImportDeclaration } from '@babel/types';\r\n\r\nfunction isVariableUsedAsObject(path: NodePath<ImportDeclaration>, variableName: string) {\r\n const binding = path.scope.getBinding(variableName);\r\n let isUsedObject = false;\r\n if (!binding || !binding.referencePaths) {\r\n return isUsedObject;\r\n }\r\n\r\n for (const referencePath of binding.referencePaths) {\r\n if (t.isMemberExpression(referencePath.parent)) {\r\n // const memberExprParent = referencePath.parent;\r\n\r\n // if (memberExprParent.object && memberExprParent.property) {\r\n // const newMemberExpr = t.memberExpression(\r\n // memberExprParent.object,\r\n // t.identifier(`${(memberExprParent.property as t.Identifier).name}.value`),\r\n // );\r\n // referencePath.parentPath?.replaceWith(newMemberExpr);\r\n isUsedObject = true;\r\n // }\r\n }\r\n }\r\n\r\n return isUsedObject;\r\n}\r\n// TODO: 暂时不支持对象\r\nexport function replaceImportDeclaration(path: NodePath<ImportDeclaration>) {\r\n const imports = path.node.specifiers;\r\n imports.forEach(specifier => {\r\n const variableName = specifier.local.name;\r\n\r\n if (startsWith(variableName, '$') && !isVariableUsedAsObject(path, variableName)) {\r\n path.scope.rename(variableName, `${variableName}.value`);\r\n specifier.local.name = `${variableName}`;\r\n }\r\n });\r\n}\r\n","import { startsWith } from 'essor-shared';\r\nimport { type NodePath, types as t } from '@babel/core';\r\nimport { imports } from '../program';\r\nimport type { State } from '../types';\r\nimport type {\r\n ArrowFunctionExpression,\r\n FunctionDeclaration,\r\n Identifier,\r\n ObjectProperty,\r\n RestElement,\r\n} from '@babel/types';\r\n\r\nexport function replaceProps(path: NodePath<FunctionDeclaration | ArrowFunctionExpression>) {\r\n const state: State = path.state;\r\n\r\n const firstParam = path.node.params[0];\r\n\r\n if (!firstParam || !t.isObjectPattern(firstParam)) {\r\n return;\r\n }\r\n\r\n const returnStatement = path\r\n .get('body')\r\n .get('body')\r\n .find(statement => statement.isReturnStatement());\r\n\r\n if (!returnStatement) {\r\n return;\r\n }\r\n\r\n const returnValue = (returnStatement.node as any)?.argument;\r\n if (!t.isJSXElement(returnValue)) {\r\n return;\r\n }\r\n\r\n function replaceProperties(properties: (ObjectProperty | RestElement)[], parentPath: string) {\r\n properties.forEach(property => {\r\n if (t.isObjectProperty(property)) {\r\n const keyName = (property.key as Identifier).name;\r\n\r\n if (t.isIdentifier(property.value)) {\r\n const propertyName = property.value.name;\r\n const newName = `${parentPath}${keyName}`;\r\n path.scope.rename(propertyName, newName);\r\n } else if (t.isObjectPattern(property.value)) {\r\n replaceProperties(property.value.properties, `${parentPath}${keyName}.`);\r\n }\r\n }\r\n });\r\n }\r\n\r\n const properties = firstParam.properties;\r\n replaceProperties(\r\n properties.filter(property => !t.isRestElement(property)),\r\n '__props.',\r\n );\r\n const notRestProperties = properties.filter(property => !t.isRestElement(property));\r\n const notRestNames = notRestProperties.map(\r\n property => ((property as ObjectProperty).key as Identifier).name,\r\n );\r\n if (__DEV__ && notRestNames.some(name => startsWith(name, '$'))) {\r\n console.warn('props name can not start with $');\r\n return;\r\n }\r\n\r\n const restElement = properties.find(property => t.isRestElement(property)) as\r\n | RestElement\r\n | undefined;\r\n path.node.params[0] = t.identifier('__props');\r\n\r\n if (restElement) {\r\n const restName = (restElement.argument as any).name;\r\n if (notRestProperties.length === 0) {\r\n path.node.params[0] = t.identifier(restName);\r\n } else {\r\n const restVariableDeclaration = t.variableDeclaration('const', [\r\n t.variableDeclarator(\r\n t.identifier(restName),\r\n t.callExpression(state.useReactive, [\r\n t.identifier('__props'),\r\n t.arrayExpression(notRestNames.map(name => t.stringLiteral(name))),\r\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K,OAAO,CAAC,IAAI,aAAAA,MAAE,WAAW,QAAQ;AAAA,IAC7C,OAAO;AACL,YAAM,0BAA0B,aAAAA,MAAE,oBAAoB,SAAS;AAAA,QAC7D,aAAAA,MAAE;AAAA,UACA,aAAAA,MAAE,WAAW,QAAQ;AAAA,UACrB,aAAAA,MAAE,eAAe,MAAM,aAAa;AAAA,YAClC,aAAAA,MAAE,WAAW,SAAS;AAAA,YACtB,aAAAA,MAAE,gBAAgB,aAAa,IAAI,UAAQ,aAAAA,MAAE,cAAc,IAAI,CAAC,CAAC;AAAA,UACnE,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AACD,cAAQ,IAAI,aAAa;AAEzB,MAAC,KAAK,KAAK,KAAa,KAAK,QAAQ,uBAAuB;AAAA,IAC9D;AAAA,EACF;AACF;;;AZ7Ee,SAAR,cAA+B;AACpC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,kBAAkB,EAAE,SAAS,GAAG,YAAY;AAC1C,UAAI,SAAS,SAAS,KAAK,KAAK,SAAS,SAAS,MAAM,GAAG;AACzD,mBAAW,QAAQ,KAAK,YAAY;AAAA,MACtC;AACA,iBAAW,QAAQ,KAAK,KAAK;AAAA,IAC/B;AAAA,IACA,SAAS;AAAA,MACP,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,qBAAqB;AAAA,MACrB,yBAAyB;AAAA,MACzB,oBAAoB;AAAA,MACpB,mBAAmB;AAAA,MACnB,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,cAAc;AAAA,IAChB;AAAA,EACF;AACF;","names":["import_core","t","import_core","t","t","value","import_core","createEssorNode","t","createProps","getAttrProps","getChildren","replaceChild","handleAttributes","transformChildren","isValidChild","getNodeText","transformChild","value","import_core","t","import_core","t","imports","import_core","t","properties"]}
package/dist/index.js CHANGED
@@ -101,7 +101,9 @@ var svgTags = [
101
101
  import { types as t2 } from "@babel/core";
102
102
  function hasSiblingElement(path) {
103
103
  const siblings = path.getAllPrevSiblings().concat(path.getAllNextSiblings());
104
- const hasSibling = siblings.some((siblingPath) => siblingPath.isJSXElement());
104
+ const hasSibling = siblings.some(
105
+ (siblingPath) => siblingPath.isJSXElement() || siblingPath.isJSXExpressionContainer()
106
+ );
105
107
  return hasSibling;
106
108
  }
107
109
  function getAttrName(attribute) {
@@ -127,7 +129,7 @@ function jsxElementNameToString(node) {
127
129
  return `${node.namespace.name}:${node.name.name}`;
128
130
  }
129
131
  function isComponent(tagName) {
130
- return tagName[0] && tagName[0].toLowerCase() !== tagName[0] || tagName.includes(".") || /[^A-Za-z]/.test(tagName[0]);
132
+ return tagName[0] && tagName[0].toLowerCase() !== tagName[0] || tagName.includes(".") || /[^a-z]/i.test(tagName[0]);
131
133
  }
132
134
  function isTextChild(path) {
133
135
  if (path.isJSXExpressionContainer()) {
@@ -602,7 +604,7 @@ function handleAttributes2(props, result) {
602
604
  let klass = "";
603
605
  let style = "";
604
606
  for (const prop in props) {
605
- const value = props[prop];
607
+ let value = props[prop];
606
608
  if (prop === "class" && typeof value === "string") {
607
609
  klass += ` ${value}`;
608
610
  delete props[prop];
@@ -624,6 +626,23 @@ function handleAttributes2(props, result) {
624
626
  result.template += ` ${prop}="${value}"`;
625
627
  delete props[prop];
626
628
  }
629
+ if (t4.isConditionalExpression(value)) {
630
+ const { test, consequent, alternate } = value;
631
+ value = t4.arrowFunctionExpression([], t4.conditionalExpression(test, consequent, alternate));
632
+ props[prop] = value;
633
+ }
634
+ if (t4.isObjectExpression(value)) {
635
+ let hasConditional = false;
636
+ value.properties.forEach((property) => {
637
+ if (t4.isObjectProperty(property) && t4.isConditionalExpression(property.value)) {
638
+ hasConditional = true;
639
+ }
640
+ });
641
+ if (hasConditional) {
642
+ value = t4.arrowFunctionExpression([], value);
643
+ }
644
+ props[prop] = value;
645
+ }
627
646
  }
628
647
  if (Object.keys(props).length > 0) {
629
648
  result.props[result.index] = props;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../shared/src/is.ts","../../shared/src/comm.ts","../../shared/src/name.ts","../src/jsx/server.ts","../src/program.ts","../src/jsx/constants.ts","../src/jsx/shared.ts","../src/jsx/client.ts","../src/jsx/index.ts","../src/signal/symbol.ts","../src/signal/import.ts","../src/signal/props.ts","../src/index.ts"],"sourcesContent":["import { _toString } from './comm';\n\nexport const isObject = (val: unknown): val is Record<any, any> =>\n val !== null && typeof val === 'object';\nexport function isPromise(val: any): boolean {\n return _toString.call(val) === '[object Promise]';\n}\n\nexport const isArray = Array.isArray;\n\nexport function isString(val: unknown): val is string {\n return typeof val === 'string';\n}\nexport function isNull(val: any): val is null {\n return val === null;\n}\nexport function isSymbol(val: unknown): val is symbol {\n return typeof val === 'symbol';\n}\nexport function isMap(val: unknown): val is Map<any, any> {\n return _toString.call(val) === '[object Map]';\n}\nexport function isNil(x: any): x is null | undefined {\n return x === null || x === undefined;\n}\n\nexport const isFunction = (val: unknown): val is Function => typeof val === 'function';\n\nexport function isFalsy(x: any): x is false | null | undefined {\n return x === false || x === null || x === undefined || x === '';\n}\n\nexport const isPrimitive = (\n val: unknown,\n): val is string | number | boolean | symbol | null | undefined =>\n ['string', 'number', 'boolean', 'symbol', 'undefined'].includes(typeof val) || isNull(val);\n\nexport const isHtmlElement = (val: unknown): val is HTMLElement => {\n return val instanceof HTMLElement || val instanceof SVGElement;\n};\n","import { isFunction, isPrimitive, isString } from './is';\n\nexport const _toString = Object.prototype.toString;\nexport const extend = Object.assign;\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nexport const hasOwn = (val: object, key: string | symbol): key is keyof typeof val =>\n hasOwnProperty.call(val, key);\n\nexport function coerceArray<T>(data: T | T[]): T[] {\n return Array.isArray(data) ? (data.flat() as T[]) : [data];\n}\nexport const hasChanged = (value, oldValue) =>\n value !== oldValue && (value === value || oldValue === oldValue);\nexport const noop = Function.prototype as () => void;\n\n/**\n * A function that checks if a string starts with a specific substring.\n * indexOf faster under normal circumstances\n * @see https://www.measurethat.net/Benchmarks/Show/12350/0/startswith-vs-test-vs-match-vs-indexof#latest_results_block\n\n * @param {string} str - The input string to check.\n * @param {string} searchString - The substring to check for at the beginning of the input string.\n * @return {boolean} Returns true if the input string starts with the specified substring, otherwise false.\n */\nexport function startsWith(str, searchString) {\n if (!isString(str)) {\n return false;\n }\n return str.indexOf(searchString) === 0;\n}\n\n/**\n * Recursively clones an object, including its nested properties and special types like Date, RegExp, Map, and Set.\n *\n * @param {any} obj - The object to clone.\n * @param {WeakMap<object, object>} [hash] - A WeakMap used to track circular references.\n * @return {any} The cloned object.\n */\nexport function deepClone(obj, hash = new WeakMap()) {\n // Return primitives and functions as-is\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n // Handle circular references\n if (hash.has(obj)) {\n return hash.get(obj);\n }\n\n // Handle special types\n if (obj instanceof Date) {\n return new Date(obj);\n }\n\n if (obj instanceof RegExp) {\n return new RegExp(obj);\n }\n\n if (obj instanceof Map) {\n const mapClone = new Map();\n hash.set(obj, mapClone);\n obj.forEach((value, key) => {\n mapClone.set(deepClone(key, hash), deepClone(value, hash));\n });\n return mapClone;\n }\n\n if (obj instanceof Set) {\n const setClone = new Set();\n hash.set(obj, setClone);\n obj.forEach(value => {\n setClone.add(deepClone(value, hash));\n });\n return setClone;\n }\n\n // Initialize the clone and store it in the WeakMap\n const cloneObj = Array.isArray(obj) ? [] : {};\n hash.set(obj, cloneObj);\n\n // Iterate over object keys\n const keys = Object.keys(obj);\n for (const key of keys) {\n cloneObj[key] = deepClone(obj[key], hash);\n }\n\n return cloneObj;\n}\n\n/**\n * Determines whether two values are deeply equal.\n *\n * @param {any} a - The first value to compare.\n * @param {any} b - The second value to compare.\n * @param {WeakMap<object, object>} [seen] - A WeakMap used to store previously seen objects to avoid infinite recursion.\n * @return {boolean} True if the values are deeply equal, false otherwise.\n */\nexport function deepEqual(a: any, b: any, seen = new WeakMap()): boolean {\n if (isPrimitive(a) && isPrimitive(b)) {\n return a === b;\n }\n\n if (a === b) {\n return true;\n }\n\n if (a == null || b == null || typeof a !== 'object' || typeof b !== 'object') {\n return false;\n }\n\n if (a.constructor !== b.constructor) {\n return false;\n }\n\n if (seen.has(a)) {\n return seen.get(a) === b;\n }\n\n seen.set(a, b);\n\n if (Array.isArray(a)) {\n if (a.length !== b.length) {\n return false;\n }\n for (const [i, element] of a.entries()) {\n if (!deepEqual(element, b[i], seen)) {\n return false;\n }\n }\n return true;\n }\n\n if (a instanceof Map) {\n if (a.size !== b.size) {\n return false;\n }\n for (const [key, value] of a) {\n if (!b.has(key) || !deepEqual(value, b.get(key), seen)) {\n return false;\n }\n }\n return true;\n }\n\n if (a instanceof Set) {\n if (a.size !== b.size) {\n return false;\n }\n const arrA = Array.from(a).sort();\n const arrB = Array.from(b).sort();\n for (const [i, element] of arrA.entries()) {\n if (!deepEqual(element, arrB[i], seen)) {\n return false;\n }\n }\n return true;\n }\n\n const keysA = Object.keys(a);\n const keysB = new Set(Object.keys(b));\n\n if (keysA.length !== keysB.size) {\n return false;\n }\n\n for (const key of keysA) {\n if (!keysB.has(key) || !deepEqual(a[key], b[key], seen)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Escapes special HTML characters in a string.\n * @param str - The string to escape.\n * @returns The escaped string.\n */\nexport function escape(str: string): string {\n return str.replaceAll(/[\"&'<>]/g, char => {\n switch (char) {\n case '&':\n return '&amp;';\n case '<':\n return '&lt;';\n case '>':\n return '&gt;';\n case '\"':\n return '&quot;';\n case \"'\":\n return '&#039;';\n default:\n return char;\n }\n });\n}\n\nexport type ExcludeType = ((key: string | symbol) => boolean) | (string | symbol)[];\n\n/**\n * Checks if a key should be excluded based on the provided exclude criteria.\n * @param key - The key to check.\n * @param exclude - The exclusion criteria.\n * @returns True if the key should be excluded, otherwise false.\n */\nexport function isExclude(key: string | symbol, exclude?: ExcludeType): boolean {\n return Array.isArray(exclude)\n ? exclude.includes(key)\n : isFunction(exclude)\n ? exclude(key)\n : false;\n}\n","export const kebabCase = (string: string): string => {\n return string.replaceAll(/[A-Z]+/g, (match, offset) => {\n return `${offset > 0 ? '-' : ''}${match.toLocaleLowerCase()}`;\n });\n};\n\nexport const camelCase = (str: string): string => {\n const s = str.replaceAll(/[\\s_-]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''));\n return s[0].toLowerCase() + s.slice(1);\n};\n/**\n * Capitalizes the first letter of a string.\n *\n * @param {string} inputString - The input string to capitalize the first letter.\n * @return {string} The string with the first letter capitalized.\n */\nexport const capitalizeFirstLetter = (inputString: string): string => {\n return inputString.charAt(0).toUpperCase() + inputString.slice(1);\n};\n","import { capitalizeFirstLetter } from 'essor-shared';\nimport { types as t } from '@babel/core';\nimport { imports } from '../program';\nimport { selfClosingTags, svgTags } from './constants';\nimport {\n type JSXChild,\n type JSXElement,\n getAttrName,\n getTagName,\n isComponent,\n isTextChild,\n setNodeText,\n} from './shared';\nimport type { OptionalMemberExpression } from '@babel/types';\nimport type { State } from '../types';\nimport type { NodePath } from '@babel/core';\n\nexport interface Result {\n index: number;\n isLastChild: boolean;\n parentIndex: number;\n props: Record<string, any>;\n template: string[];\n}\n\nexport function transformJSXService(path: NodePath<JSXElement>): void {\n const result: Result = {\n index: 0,\n isLastChild: false,\n parentIndex: 0,\n props: {},\n template: [], // 修改为数组\n };\n transformJSXServiceElement(path, result, true);\n path.replaceWith(createEssorNode(path, result));\n}\n\nfunction createEssorNode(path: NodePath<JSXElement>, result: Result): t.CallExpression {\n const state: State = path.state;\n\n let tmpl: t.Identifier;\n if (path.isJSXElement() && isComponent(getTagName(path.node))) {\n tmpl = t.identifier(getTagName(path.node));\n } else {\n tmpl = path.scope.generateUidIdentifier('_tmpl$');\n const template = t.arrayExpression(result.template.map(t.stringLiteral));\n const declarator = t.variableDeclarator(tmpl, template);\n state.tmplDeclaration.declarations.push(declarator);\n }\n\n const args = [tmpl, createProps(result.props)];\n const key = result.props.key || result.props[0]?.key;\n if (key) {\n args.push(key);\n }\n imports.add('renderTemplate');\n return t.callExpression(state.renderTemplate, args);\n}\n\nfunction createProps(props: Record<string, any>): t.ObjectExpression {\n const result: (t.ObjectProperty | t.SpreadElement)[] = [];\n\n for (const prop in props) {\n let value = props[prop];\n\n if (prop === 'key') {\n continue;\n }\n\n if (Array.isArray(value)) {\n value = t.arrayExpression(value);\n }\n\n if (typeof value === 'object' && value !== null && !t.isNode(value)) {\n value = createProps(value);\n }\n\n if (typeof value === 'string') {\n value = t.stringLiteral(value);\n }\n\n if (typeof value === 'number') {\n value = t.numericLiteral(value);\n }\n\n if (typeof value === 'boolean') {\n value = t.booleanLiteral(value);\n }\n\n if (value === undefined) {\n value = t.tsUndefinedKeyword();\n }\n\n if (value === null) {\n value = t.nullLiteral();\n }\n\n if (prop === '_$spread$') {\n result.push(t.spreadElement(value));\n } else {\n result.push(t.objectProperty(t.stringLiteral(prop), value));\n }\n }\n\n return t.objectExpression(result);\n}\nfunction transformJSXServiceElement(\n path: NodePath<JSXElement>,\n result: Result,\n isRoot: boolean = false,\n): void {\n if (path.isJSXElement()) {\n const tagName = getTagName(path.node);\n const tagIsComponent = isComponent(tagName);\n const isSelfClose = !tagIsComponent && selfClosingTags.includes(tagName);\n const isSvg = svgTags.includes(tagName) && result.index === 1;\n const { props, hasExpression } = getAttrProps(path);\n if (tagIsComponent) {\n if (isRoot) {\n result.props = props;\n const children = getChildren(path) as any;\n if (children.length > 0) {\n const childrenGenerator =\n children.length === 1 ? children[0] : t.arrayExpression(children);\n result.props.children = childrenGenerator;\n }\n } else {\n transformJSXService(path);\n replaceChild(path.node, result);\n }\n } else {\n if (isSvg) {\n result.template.push('<svg _svg_>');\n }\n result.template.push(`<${tagName}`);\n handleAttributes(props, result);\n\n if (hasExpression) {\n result.template.push(isSelfClose ? '/>' : '>');\n result.props ||= {};\n } else {\n result.template[result.template.length - 1] += isSelfClose ? '/>' : '>';\n }\n transformChildren(path, result);\n\n if (!isSelfClose) {\n result.template.push(`</${tagName}>`);\n }\n }\n } else {\n result.index--;\n transformChildren(path, result);\n }\n}\n\nfunction transformChildren(path: NodePath<JSXElement>, result: Result): void {\n const parentIndex = result.template.length;\n path\n .get('children')\n .reduce((pre, cur) => {\n if (isValidChild(cur)) {\n const lastChild = pre.at(-1);\n if (lastChild && isTextChild(cur) && isTextChild(lastChild)) {\n setNodeText(lastChild, getNodeText(lastChild) + getNodeText(cur));\n } else {\n pre.push(cur);\n }\n }\n return pre;\n }, [] as NodePath<JSXChild>[])\n .forEach((child, i, arr) => {\n result.parentIndex = parentIndex;\n result.isLastChild = i === arr.length - 1;\n transformChild(child, result);\n });\n}\n\nfunction transformChild(child: NodePath<JSXChild>, result: Result): void {\n if (child.isJSXElement() || child.isJSXFragment()) {\n transformJSXServiceElement(child, result, false);\n } else if (child.isJSXExpressionContainer()) {\n const expression = child.get('expression');\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\n result.template[result.template.length - 1] += String(expression.node.value);\n } else if (expression.isExpression()) {\n replaceChild(expression.node, result);\n } else if (t.isJSXEmptyExpression(expression.node)) {\n // it is empty expression\n // do nothing\n } else {\n throw new Error('Unsupported child type');\n }\n } else if (child.isJSXText()) {\n result.template.push(String(child.node.value));\n } else {\n throw new Error('Unsupported child type');\n }\n}\n\nfunction getNodeText(path: NodePath<JSXChild>): string {\n if (path.isJSXText()) {\n return path.node.value;\n }\n if (path.isJSXExpressionContainer()) {\n const expression = path.get('expression');\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\n return String(expression.node.value);\n }\n }\n return '';\n}\n\nfunction handleAttributes(props: Record<string, any>, result: Result): void {\n let klass = '';\n let style = '';\n\n for (const prop in props) {\n const value = props[prop];\n\n if (prop === 'class' && typeof value === 'string') {\n klass += ` ${value}`;\n delete props[prop];\n continue;\n }\n\n if (prop === 'style' && typeof value === 'string') {\n style += `${value}${value.at(-1) === ';' ? '' : ';'}`;\n delete props[prop];\n continue;\n }\n\n if (value === true) {\n result.template[result.template.length - 1] += ` ${prop}`;\n delete props[prop];\n }\n if (value === false) {\n delete props[prop];\n }\n if (typeof value === 'string' || typeof value === 'number') {\n result.template[result.template.length - 1] += ` ${prop}=\"${value}\"`;\n delete props[prop];\n }\n }\n\n if (Object.keys(props).length > 0) {\n result.props[result.index] = props;\n }\n\n klass = klass.trim();\n style = style.trim();\n\n if (klass) {\n result.template[result.template.length - 1] += ` class=\"${klass}\"`;\n }\n if (style) {\n result.template[result.template.length - 1] += ` style=\"${style}\"`;\n }\n}\n\nfunction replaceChild(node: t.Expression, result: Result): void {\n if (result.isLastChild) {\n result.index--;\n }\n result.props[result.parentIndex] ??= {};\n result.props[result.parentIndex].children ??= [];\n result.props[result.parentIndex].children.push(\n t.arrayExpression([\n t.arrowFunctionExpression([], node),\n t.identifier(String(result.template.length)),\n ]),\n );\n}\n\nfunction getChildren(path: NodePath<JSXElement>): JSXChild[] {\n return path\n .get('children')\n .filter(child => isValidChild(child))\n .map(child => {\n if (child.isJSXElement() || child.isJSXFragment()) {\n transformJSXService(child);\n } else if (child.isJSXExpressionContainer()) {\n child.replaceWith(child.get('expression'));\n } else if (child.isJSXText()) {\n child.replaceWith(t.stringLiteral(child.node.value));\n } else {\n throw new Error('Unsupported child type');\n }\n return child.node;\n });\n}\n\nfunction isValidChild(path: NodePath<JSXChild>): boolean {\n const regex = /^\\s*$/;\n if (path.isStringLiteral() || path.isJSXText()) {\n return !regex.test(path.node.value);\n }\n return Object.keys(path.node).length > 0;\n}\nfunction getAttrProps(path: NodePath<t.JSXElement>): Record<string, any> {\n const props: Record<string, any> = {};\n let hasExpression = false;\n path\n .get('openingElement')\n .get('attributes')\n .forEach(attribute => {\n if (attribute.isJSXAttribute()) {\n const name = getAttrName(attribute.node);\n const value = attribute.get('value');\n\n if (!value.node) {\n props[name] = true;\n } else if (value.isStringLiteral()) {\n props[name] = value.node.value;\n } else {\n if (value.isJSXExpressionContainer()) {\n const expression = value.get('expression');\n\n if (expression.isStringLiteral()) {\n props[name] = expression.node.value;\n } else if (expression.isNumericLiteral()) {\n props[name] = expression.node.value;\n } else if (expression.isJSXElement() || expression.isJSXFragment()) {\n transformJSXService(expression);\n props[name] = expression.node;\n } else if (expression.isExpression()) {\n hasExpression = true;\n if (/^key|ref|on.+$/.test(name)) {\n props[name] = expression.node;\n } else if (/^bind:.+/.test(name)) {\n const value = path.scope.generateUidIdentifier('value');\n const bindName = name.slice(5).toLocaleLowerCase();\n props[bindName] = expression.node;\n props[`update${capitalizeFirstLetter(bindName)}`] = t.arrowFunctionExpression(\n [value],\n t.assignmentExpression('=', expression.node as OptionalMemberExpression, value),\n );\n } else {\n if (expression.isConditionalExpression()) {\n props[name] = t.arrowFunctionExpression([], expression.node);\n } else {\n props[name] = expression.node;\n }\n }\n }\n } else if (value.isJSXElement() || value.isJSXFragment()) {\n transformJSXService(value);\n props[name] = value.node;\n }\n }\n } else if (attribute.isJSXSpreadAttribute()) {\n props._$spread$ = attribute.get('argument').node;\n hasExpression = true;\n } else {\n throw new Error('Unsupported attribute type');\n }\n });\n\n return {\n props,\n hasExpression,\n };\n}\n","import { type NodePath, types as t } from '@babel/core';\nimport type { State } from './types';\nexport const imports = new Set<string>();\n\nexport const transformProgram = {\n enter(path: NodePath<t.Program>, state) {\n imports.clear();\n\n path.state = {\n h: path.scope.generateUidIdentifier('h$'),\n renderTemplate: path.scope.generateUidIdentifier('renderTemplate$'),\n template: path.scope.generateUidIdentifier('template$'),\n\n useSignal: path.scope.generateUidIdentifier('signal$'),\n useComputed: path.scope.generateUidIdentifier('computed$'),\n useReactive: path.scope.generateUidIdentifier('reactive$'),\n\n tmplDeclaration: t.variableDeclaration('const', []),\n opts: state.opts,\n } as State;\n },\n exit(path: NodePath<t.Program>) {\n const state: State = path.state;\n if (state.tmplDeclaration.declarations.length > 0) {\n const index = path.node.body.findIndex(\n node => !t.isImportDeclaration(node) && !t.isExportDeclaration(node),\n );\n path.node.body.splice(index, 0, state.tmplDeclaration);\n }\n if (imports.size > 0) {\n path.node.body.unshift(createImport(state, 'essor'));\n }\n },\n};\nfunction createImport(state: State, from: string) {\n const ImportSpecifier: t.ImportSpecifier[] = [];\n imports.forEach(name => {\n const local = t.identifier(state[name].name);\n const imported = t.identifier(name);\n ImportSpecifier.push(t.importSpecifier(local, imported));\n });\n\n const importSource = t.stringLiteral(from);\n return t.importDeclaration(ImportSpecifier, importSource);\n}\n","export const selfClosingTags = [\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n];\n\nexport const svgTags = [\n 'circle',\n 'clipPath',\n 'defs',\n 'ellipse',\n 'filter',\n 'g',\n 'line',\n 'linearGradient',\n 'mask',\n 'path',\n 'pattern',\n 'polygon',\n 'polyline',\n 'radialGradient',\n 'rect',\n 'stop',\n 'symbol',\n 'text',\n 'use',\n];\n","import { type NodePath, types as t } from '@babel/core';\n\nexport type JSXElement = t.JSXElement | t.JSXFragment;\n\nexport type JSXChild =\n | t.JSXElement\n | t.JSXFragment\n | t.JSXExpressionContainer\n | t.JSXSpreadChild\n | t.JSXText;\n\n/**\n * Checks if the given Babel path has a sibling element.\n *\n * @param {NodePath} path - The Babel path to check.\n * @return {boolean} True if the path has a sibling element, false otherwise.\n */\nexport function hasSiblingElement(path) {\n // Get all siblings (both previous and next)\n const siblings = path.getAllPrevSiblings().concat(path.getAllNextSiblings());\n\n // Check for non-self-closing sibling elements\n const hasSibling = siblings.some(siblingPath => siblingPath.isJSXElement());\n\n return hasSibling;\n}\n\n/**\n * Retrieves the name of a JSX attribute.\n *\n * @param {t.JSXAttribute} attribute - The JSX attribute to retrieve the name from.\n * @return {string} The name of the attribute.\n * @throws {Error} If the attribute type is unsupported.\n */\nexport function getAttrName(attribute: t.JSXAttribute): string {\n if (t.isJSXIdentifier(attribute.name)) {\n return attribute.name.name;\n }\n if (t.isJSXNamespacedName(attribute.name)) {\n return `${attribute.name.namespace.name}:${attribute.name.name.name}`;\n }\n throw new Error('Unsupported attribute type');\n}\n\n/**\n * Retrieves the tag name of a JSX element.\n *\n * @param {t.JSXElement} node - The JSX element.\n * @return {string} The tag name of the JSX element.\n */\nexport function getTagName(node: t.JSXElement): string {\n const tag = node.openingElement.name;\n return jsxElementNameToString(tag);\n}\n\n/**\n * Converts a JSX element name to a string representation.\n *\n * case1: <MyComponent />\n * case2: <SomeLibrary.SomeComponent />;\n * case3: <namespace:ComponentName />;\n * case4: <SomeLibrary.Nested.ComponentName />;\n *\n * @param {t.JSXMemberExpression | t.JSXIdentifier | t.JSXNamespacedName} node The JSX element name to convert.\n * @returns {string} The string representation of the JSX element name.\n */\nexport function jsxElementNameToString(\n node: t.JSXMemberExpression | t.JSXIdentifier | t.JSXNamespacedName,\n) {\n if (t.isJSXMemberExpression(node)) {\n return `${jsxElementNameToString(node.object)}.${jsxElementNameToString(node.property)}`;\n }\n\n if (t.isJSXIdentifier(node) || t.isIdentifier(node)) {\n return node.name;\n }\n\n return `${node.namespace.name}:${node.name.name}`;\n}\n\n/**\n * Determines if the given tagName is a component.\n *\n * case1: <MyComponent />\n * case2: <SomeLibrary.SomeComponent />;\n * case3: <_component />;\n *\n * @param {string} tagName - The name of the tag to check.\n * @return {boolean} True if the tagName is a component, false otherwise.\n */\nexport function isComponent(tagName: string): boolean {\n return (\n (tagName[0] && tagName[0].toLowerCase() !== tagName[0]) ||\n tagName.includes('.') ||\n /[^A-Za-z]/.test(tagName[0])\n );\n}\n\n/**\n * Determines if the given path represents a text child node in a JSX expression.\n *\n * @param {NodePath<JSXChild>} path - The path to the potential text child node.\n * @return {boolean} True if the path represents a text child node, false otherwise.\n */\nexport function isTextChild(path: NodePath<JSXChild>): boolean {\n if (path.isJSXExpressionContainer()) {\n const expression = path.get('expression');\n if (expression.isJSXText() || expression.isStringLiteral() || expression.isNumericLiteral()) {\n return true;\n }\n }\n if (path.isJSXText() || path.isStringLiteral() || path.isNullLiteral()) {\n return true;\n }\n return false;\n}\n\n/**\n * Sets the text content of a JSX node.\n *\n * @param {NodePath<JSXChild>} path - The path to the JSX node.\n * @param {string} text - The text to set.\n * @return {void}\n */\nexport function setNodeText(path: NodePath<JSXChild>, text: string): void {\n if (path.isJSXText()) {\n path.node.value = text;\n }\n if (path.isJSXExpressionContainer()) {\n const expression = path.get('expression');\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\n expression.replaceWith(t.stringLiteral(text));\n }\n }\n}\n","import { types as t } from '@babel/core';\nimport { capitalizeFirstLetter } from 'essor-shared';\nimport { imports } from '../program';\nimport { selfClosingTags, svgTags } from './constants';\nimport {\n type JSXChild,\n type JSXElement,\n getAttrName,\n getTagName,\n hasSiblingElement,\n isComponent,\n isTextChild,\n setNodeText,\n} from './shared';\nimport type { OptionalMemberExpression } from '@babel/types';\nimport type { State } from '../types';\nimport type { NodePath } from '@babel/core';\n\nexport interface Result {\n index: number;\n isLastChild: boolean;\n parentIndex: number;\n props: Record<string, any>;\n template: string;\n}\n\nexport function transformJSXClient(path: NodePath<JSXElement>): void {\n const result: Result = {\n index: 1,\n isLastChild: false,\n parentIndex: 0,\n props: {},\n template: '',\n };\n transformJSXElement(path, result, true);\n\n path.replaceWith(createEssorNode(path, result));\n}\n\nfunction createEssorNode(path: NodePath<JSXElement>, result: Result): t.CallExpression {\n const state: State = path.state;\n\n let tmpl: t.Identifier;\n if (path.isJSXElement() && isComponent(getTagName(path.node))) {\n tmpl = t.identifier(getTagName(path.node));\n } else {\n tmpl = path.scope.generateUidIdentifier('_tmpl$');\n const template = t.callExpression(state.template, [t.stringLiteral(result.template)]);\n const declarator = t.variableDeclarator(tmpl, template);\n state.tmplDeclaration.declarations.push(declarator);\n imports.add('template');\n }\n\n const args = [tmpl, createProps(result.props)];\n const key = result.props.key || result.props[0]?.key;\n if (key) {\n args.push(key);\n }\n imports.add('h');\n return t.callExpression(state.h, args);\n}\n\nfunction createProps(props) {\n const toAstNode = value => {\n if (Array.isArray(value)) {\n return t.arrayExpression(value.map(toAstNode));\n }\n if (value && typeof value === 'object' && !t.isNode(value)) {\n return createProps(value);\n }\n\n switch (typeof value) {\n case 'string':\n return t.stringLiteral(value);\n case 'number':\n return t.numericLiteral(value);\n case 'boolean':\n return t.booleanLiteral(value);\n case 'undefined':\n return t.tsUndefinedKeyword();\n case undefined:\n return t.tsUndefinedKeyword();\n case null:\n return t.nullLiteral();\n default:\n return value;\n }\n };\n\n const result = Object.keys(props)\n .filter(prop => prop !== 'key')\n .map(prop => {\n const value = toAstNode(props[prop]);\n return prop === '_$spread$'\n ? t.spreadElement(value)\n : t.objectProperty(t.stringLiteral(prop), value);\n });\n\n return t.objectExpression(result);\n}\nfunction transformJSXElement(\n path: NodePath<JSXElement>,\n result: Result,\n isRoot: boolean = false,\n): void {\n if (path.isJSXElement()) {\n const tagName = getTagName(path.node);\n const tagIsComponent = isComponent(tagName);\n const isSelfClose = !tagIsComponent && selfClosingTags.includes(tagName);\n const isSvg = svgTags.includes(tagName) && result.index === 1;\n const props = getAttrProps(path);\n if (tagIsComponent) {\n if (isRoot) {\n result.props = props;\n const children = getChildren(path) as any;\n if (children.length > 0) {\n const childrenGenerator =\n children.length === 1 ? children[0] : t.arrayExpression(children);\n result.props.children = childrenGenerator;\n }\n } else {\n transformJSXClient(path);\n replaceChild(path.node, result);\n }\n } else {\n if (isSvg) {\n result.template = '<svg _svg_>';\n }\n result.template += `<${tagName}`;\n handleAttributes(props, result);\n result.template += isSelfClose ? '/>' : '>';\n if (!isSelfClose) {\n transformChildren(path, result);\n if (hasSiblingElement(path)) {\n result.template += `</${tagName}>`;\n }\n }\n }\n } else {\n result.index--;\n transformChildren(path, result);\n }\n}\n\nfunction transformChildren(path: NodePath<JSXElement>, result: Result): void {\n const parentIndex = result.index;\n path\n .get('children')\n .reduce((pre, cur) => {\n if (isValidChild(cur)) {\n const lastChild = pre.at(-1);\n if (lastChild && isTextChild(cur) && isTextChild(lastChild)) {\n setNodeText(lastChild, getNodeText(lastChild) + getNodeText(cur));\n } else {\n pre.push(cur);\n }\n }\n return pre;\n }, [] as NodePath<JSXChild>[])\n .forEach((child, i, arr) => {\n result.parentIndex = parentIndex;\n result.isLastChild = i === arr.length - 1;\n transformChild(child, result);\n });\n}\n\nfunction transformChild(child: NodePath<JSXChild>, result: Result): void {\n result.index++;\n if (child.isJSXElement() || child.isJSXFragment()) {\n transformJSXElement(child, result, false);\n } else if (child.isJSXExpressionContainer()) {\n const expression = child.get('expression');\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\n result.template += String(expression.node.value);\n } else if (expression.isExpression()) {\n replaceChild(expression.node, result);\n } else if (t.isJSXEmptyExpression(expression.node)) {\n // it is empty expression\n // do nothing\n } else {\n throw new Error('Unsupported child type');\n }\n } else if (child.isJSXText()) {\n result.template += String(child.node.value);\n } else {\n throw new Error('Unsupported child type');\n }\n}\n\nfunction getNodeText(path: NodePath<JSXChild>): string {\n if (path.isJSXText()) {\n return path.node.value;\n }\n if (path.isJSXExpressionContainer()) {\n const expression = path.get('expression');\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\n return String(expression.node.value);\n }\n }\n return '';\n}\n\nfunction handleAttributes(props: Record<string, any>, result: Result): void {\n let klass = '';\n let style = '';\n\n for (const prop in props) {\n const value = props[prop];\n\n if (prop === 'class' && typeof value === 'string') {\n klass += ` ${value}`;\n delete props[prop];\n continue;\n }\n\n if (prop === 'style' && typeof value === 'string') {\n style += `${value}${value.at(-1) === ';' ? '' : ';'}`;\n delete props[prop];\n continue;\n }\n\n if (value === true) {\n result.template += ` ${prop}`;\n delete props[prop];\n }\n if (value === false) {\n delete props[prop];\n }\n if (typeof value === 'string' || typeof value === 'number') {\n result.template += ` ${prop}=\"${value}\"`;\n delete props[prop];\n }\n }\n\n if (Object.keys(props).length > 0) {\n result.props[result.index] = props;\n }\n\n klass = klass.trim();\n style = style.trim();\n\n if (klass) {\n result.template += ` class=\"${klass}\"`;\n }\n if (style) {\n result.template += ` style=\"${style}\"`;\n }\n}\n\nfunction replaceChild(node: t.Expression, result: Result): void {\n if (result.isLastChild) {\n result.index--;\n } else {\n result.template += '<!>';\n }\n result.props[result.parentIndex] ??= {};\n result.props[result.parentIndex].children ??= [];\n result.props[result.parentIndex].children.push(\n t.arrayExpression([\n t.arrowFunctionExpression([], node),\n result.isLastChild ? t.nullLiteral() : t.identifier(String(result.index)),\n ]),\n );\n}\n\nfunction getChildren(path: NodePath<JSXElement>): JSXChild[] {\n return path\n .get('children')\n .filter(child => isValidChild(child))\n .map(child => {\n if (child.isJSXElement() || child.isJSXFragment()) {\n transformJSXClient(child);\n } else if (child.isJSXExpressionContainer()) {\n child.replaceWith(child.get('expression'));\n } else if (child.isJSXText()) {\n child.replaceWith(t.stringLiteral(child.node.value));\n } else {\n throw new Error('Unsupported child type');\n }\n return child.node;\n });\n}\n\nexport function isValidChild(path: NodePath<JSXChild>): boolean {\n const regex = /^\\s*$/;\n if (path.isStringLiteral() || path.isJSXText()) {\n return !regex.test(path.node.value);\n }\n return Object.keys(path.node).length > 0;\n}\nexport function getAttrProps(path: NodePath<t.JSXElement>): Record<string, any> {\n const props: Record<string, any> = {};\n\n path\n .get('openingElement')\n .get('attributes')\n .forEach(attribute => {\n if (attribute.isJSXAttribute()) {\n const name = getAttrName(attribute.node);\n const value = attribute.get('value');\n\n if (!value.node) {\n props[name] = true;\n } else if (value.isStringLiteral()) {\n props[name] = value.node.value;\n } else {\n if (value.isJSXExpressionContainer()) {\n const expression = value.get('expression');\n\n if (expression.isStringLiteral()) {\n props[name] = expression.node.value;\n } else if (expression.isNumericLiteral()) {\n props[name] = expression.node.value;\n } else if (expression.isJSXElement() || expression.isJSXFragment()) {\n transformJSXClient(expression);\n props[name] = expression.node;\n } else if (expression.isExpression()) {\n if (/^key|ref|on.+$/.test(name)) {\n props[name] = expression.node;\n } else if (/^bind:.+/.test(name)) {\n const value = path.scope.generateUidIdentifier('value');\n const bindName = name.slice(5).toLocaleLowerCase();\n props[bindName] = expression.node;\n props[`update${capitalizeFirstLetter(bindName)}`] = t.arrowFunctionExpression(\n [value],\n t.assignmentExpression('=', expression.node as OptionalMemberExpression, value),\n );\n } else {\n if (expression.isConditionalExpression()) {\n props[name] = t.arrowFunctionExpression([], expression.node);\n } else {\n props[name] = expression.node;\n }\n }\n }\n } else if (value.isJSXElement() || value.isJSXFragment()) {\n transformJSXClient(value);\n props[name] = value.node;\n }\n }\n } else if (attribute.isJSXSpreadAttribute()) {\n props._$spread$ = attribute.get('argument').node;\n } else {\n throw new Error('Unsupported attribute type');\n }\n });\n\n return props;\n}\n","import { transformJSXService } from './server';\nimport { transformJSXClient } from './client';\nimport type { NodePath, types as t } from '@babel/core';\nimport type { State } from '../types';\ntype JSXElement = t.JSXElement | t.JSXFragment;\nexport function transformJSX(path: NodePath<JSXElement>) {\n const state: State = path.state;\n const isSsg = state.opts.ssg;\n return isSsg ? transformJSXService(path) : transformJSXClient(path);\n}\n","import { types as t } from '@babel/core';\nimport { startsWith } from 'essor-shared';\nimport { imports } from '../program';\nimport type { Identifier, VariableDeclarator } from '@babel/types';\nimport type { NodePath } from '@babel/core';\n\n/**\n * 当一个变量/常量声明的时候,判断是否是$(定义的符号)开头,如果是,则进行转换。\n *\n * case 1: let $a = 1 => let $a = useSignal(1);\n * case 2: const $a = ()=>{return $a} => const $a = useComputed(()=>{return $a})\n *\n * 并且所有当前用到的值,都会添加.value\n * @param path\n * @returns {void}\n */\nexport function replaceSymbol(path: NodePath<VariableDeclarator>) {\n const init = path.node.init;\n const variableName = (path.node.id as Identifier).name;\n\n if (t.isObjectPattern(path.node.id) || t.isArrayPattern(path.node.id)) {\n return;\n }\n\n if (!startsWith(variableName, '$')) {\n return;\n }\n\n if (\n init &&\n (t.isFunctionExpression(init) || t.isArrowFunctionExpression(init)) &&\n (path.parent as t.VariableDeclaration).kind === 'const'\n ) {\n const newInit = t.callExpression(t.identifier(path.state.useComputed.name), init ? [init] : []);\n imports.add('useComputed');\n path.node.init = newInit;\n } else {\n const newInit = t.callExpression(t.identifier(path.state.useSignal.name), init ? [init] : []);\n imports.add('useSignal');\n path.node.init = newInit;\n }\n}\n\nexport function symbolIdentifier(path) {\n const parentPath = path.parentPath;\n\n if (\n !parentPath ||\n t.isVariableDeclarator(parentPath) ||\n t.isImportSpecifier(parentPath) ||\n t.isObjectProperty(parentPath) ||\n t.isArrayPattern(parentPath) ||\n t.isObjectPattern(parentPath)\n ) {\n return;\n }\n\n const { node } = path;\n\n if (node.name.startsWith('$')) {\n // check is has .value\n let currentPath = path;\n while (currentPath.parentPath && !currentPath.parentPath.isProgram()) {\n if (\n currentPath.parentPath.isMemberExpression() &&\n currentPath.parentPath.node.property.name === 'value'\n ) {\n return;\n }\n currentPath = currentPath.parentPath;\n }\n\n // add with .value\n const newNode = t.memberExpression(t.identifier(node.name), t.identifier('value'));\n\n path.replaceWith(newNode);\n }\n}\n\nexport function symbolObjectPattern(path) {\n path.node.properties.forEach(property => {\n if (\n t.isObjectProperty(property) &&\n t.isIdentifier(property.key) &&\n property.key.name.startsWith('$')\n ) {\n const newKey = t.identifier(property.key.name);\n property.key = newKey;\n }\n });\n}\n\nexport function symbolArrayPattern(path) {\n path.node.elements.forEach(element => {\n if (t.isIdentifier(element) && element.name.startsWith('$')) {\n const newElement = t.identifier(element.name);\n element.name = newElement.name;\n } else if (t.isObjectPattern(element)) {\n element.properties.forEach(property => {\n if (\n t.isObjectProperty(property) &&\n t.isIdentifier(property.key) &&\n property.key.name.startsWith('$')\n ) {\n const newKey = t.identifier(property.key.name);\n property.key = newKey;\n }\n });\n }\n });\n}\n","import { type NodePath, types as t } from '@babel/core';\nimport { startsWith } from 'essor-shared';\nimport type { ImportDeclaration } from '@babel/types';\n\nfunction isVariableUsedAsObject(path: NodePath<ImportDeclaration>, variableName: string) {\n const binding = path.scope.getBinding(variableName);\n let isUsedObject = false;\n if (!binding || !binding.referencePaths) {\n return isUsedObject;\n }\n\n for (const referencePath of binding.referencePaths) {\n if (t.isMemberExpression(referencePath.parent)) {\n // const memberExprParent = referencePath.parent;\n\n // if (memberExprParent.object && memberExprParent.property) {\n // const newMemberExpr = t.memberExpression(\n // memberExprParent.object,\n // t.identifier(`${(memberExprParent.property as t.Identifier).name}.value`),\n // );\n // referencePath.parentPath?.replaceWith(newMemberExpr);\n isUsedObject = true;\n // }\n }\n }\n\n return isUsedObject;\n}\n// TODO: 暂时不支持对象\nexport function replaceImportDeclaration(path: NodePath<ImportDeclaration>) {\n const imports = path.node.specifiers;\n imports.forEach(specifier => {\n const variableName = specifier.local.name;\n\n if (startsWith(variableName, '$') && !isVariableUsedAsObject(path, variableName)) {\n path.scope.rename(variableName, `${variableName}.value`);\n specifier.local.name = `${variableName}`;\n }\n });\n}\n","import { startsWith } from 'essor-shared';\nimport { type NodePath, types as t } from '@babel/core';\nimport { imports } from '../program';\nimport type { State } from '../types';\nimport type {\n ArrowFunctionExpression,\n FunctionDeclaration,\n Identifier,\n ObjectProperty,\n RestElement,\n} from '@babel/types';\n\nexport function replaceProps(path: NodePath<FunctionDeclaration | ArrowFunctionExpression>) {\n const state: State = path.state;\n\n const firstParam = path.node.params[0];\n\n if (!firstParam || !t.isObjectPattern(firstParam)) {\n return;\n }\n\n const returnStatement = path\n .get('body')\n .get('body')\n .find(statement => statement.isReturnStatement());\n\n if (!returnStatement) {\n return;\n }\n\n const returnValue = (returnStatement.node as any)?.argument;\n if (!t.isJSXElement(returnValue)) {\n return;\n }\n\n function replaceProperties(properties: (ObjectProperty | RestElement)[], parentPath: string) {\n properties.forEach(property => {\n if (t.isObjectProperty(property)) {\n const keyName = (property.key as Identifier).name;\n\n if (t.isIdentifier(property.value)) {\n const propertyName = property.value.name;\n const newName = `${parentPath}${keyName}`;\n path.scope.rename(propertyName, newName);\n } else if (t.isObjectPattern(property.value)) {\n replaceProperties(property.value.properties, `${parentPath}${keyName}.`);\n }\n }\n });\n }\n\n const properties = firstParam.properties;\n replaceProperties(\n properties.filter(property => !t.isRestElement(property)),\n '__props.',\n );\n const notRestProperties = properties.filter(property => !t.isRestElement(property));\n const notRestNames = notRestProperties.map(\n property => ((property as ObjectProperty).key as Identifier).name,\n );\n if (__DEV__ && notRestNames.some(name => startsWith(name, '$'))) {\n console.warn('props name can not start with $');\n return;\n }\n\n const restElement = properties.find(property => t.isRestElement(property)) as\n | RestElement\n | undefined;\n path.node.params[0] = t.identifier('__props');\n\n if (restElement) {\n const restName = (restElement.argument as any).name;\n if (notRestProperties.length === 0) {\n path.node.params[0] = t.identifier(restName);\n } else {\n const restVariableDeclaration = t.variableDeclaration('const', [\n t.variableDeclarator(\n t.identifier(restName),\n t.callExpression(state.useReactive, [\n t.identifier('__props'),\n t.arrayExpression(notRestNames.map(name => t.stringLiteral(name))),\n ]),\n ),\n ]);\n imports.add('useReactive');\n\n (path.node.body as any).body.unshift(restVariableDeclaration);\n }\n }\n}\n","import { transformJSX } from './jsx';\nimport { transformProgram } from './program';\nimport {\n replaceSymbol,\n symbolArrayPattern,\n symbolIdentifier,\n symbolObjectPattern,\n} from './signal/symbol';\nimport { replaceImportDeclaration } from './signal/import';\nimport { replaceProps } from './signal/props';\nimport type { PluginObj } from '@babel/core';\nexport { Options, State } from './types';\nexport default function (): PluginObj {\n return {\n name: 'babel-plugin-essor',\n manipulateOptions({ filename }, parserOpts) {\n if (filename.endsWith('.ts') || filename.endsWith('.tsx')) {\n parserOpts.plugins.push('typescript');\n }\n parserOpts.plugins.push('jsx');\n },\n visitor: {\n Program: transformProgram,\n JSXElement: transformJSX,\n JSXFragment: transformJSX,\n FunctionDeclaration: replaceProps,\n ArrowFunctionExpression: replaceProps,\n VariableDeclarator: replaceSymbol,\n ImportDeclaration: replaceImportDeclaration,\n Identifier: symbolIdentifier,\n ObjectPattern: symbolObjectPattern,\n ArrayPattern: symbolArrayPattern,\n },\n };\n}\n"],"mappings":";AAQO,IAAM,UAAU,MAAM;AAEtB,SAAS,SAAS,KAA6B;AACpD,SAAO,OAAO,QAAQ;AACxB;ACCO,IAAM,OAAO,SAAS;AAWtB,SAAS,WAAW,KAAK,cAAc;AAC5C,MAAI,CAAC,SAAS,GAAG,GAAG;AAClB,WAAO;EACT;AACA,SAAO,IAAI,QAAQ,YAAY,MAAM;AACv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,MAAC,KAAK,KAAK,KAAa,KAAK,QAAQ,uBAAuB;AAAA,IAC9D;AAAA,EACF;AACF;;;AC7Ee,SAAR,cAA+B;AACpC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,kBAAkB,EAAE,SAAS,GAAG,YAAY;AAC1C,UAAI,SAAS,SAAS,KAAK,KAAK,SAAS,SAAS,MAAM,GAAG;AACzD,mBAAW,QAAQ,KAAK,YAAY;AAAA,MACtC;AACA,iBAAW,QAAQ,KAAK,KAAK;AAAA,IAC/B;AAAA,IACA,SAAS;AAAA,MACP,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,qBAAqB;AAAA,MACrB,yBAAyB;AAAA,MACzB,oBAAoB;AAAA,MACpB,mBAAmB;AAAA,MACnB,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,cAAc;AAAA,IAChB;AAAA,EACF;AACF;","names":["t","t","t","value","t","createEssorNode","t","createProps","getAttrProps","getChildren","replaceChild","handleAttributes","transformChildren","isValidChild","getNodeText","transformChild","value","t","t","t","t","imports","t","t","properties"]}
1
+ {"version":3,"sources":["../../shared/src/is.ts","../../shared/src/comm.ts","../../shared/src/name.ts","../src/jsx/server.ts","../src/program.ts","../src/jsx/constants.ts","../src/jsx/shared.ts","../src/jsx/client.ts","../src/jsx/index.ts","../src/signal/symbol.ts","../src/signal/import.ts","../src/signal/props.ts","../src/index.ts"],"sourcesContent":["import { _toString } from './comm';\r\n\r\nexport const isObject = (val: unknown): val is Record<any, any> =>\r\n val !== null && typeof val === 'object';\r\nexport function isPromise(val: any): boolean {\r\n return _toString.call(val) === '[object Promise]';\r\n}\r\n\r\nexport const isArray = Array.isArray;\r\n\r\nexport function isString(val: unknown): val is string {\r\n return typeof val === 'string';\r\n}\r\nexport function isNull(val: any): val is null {\r\n return val === null;\r\n}\r\nexport function isSymbol(val: unknown): val is symbol {\r\n return typeof val === 'symbol';\r\n}\r\nexport function isMap(val: unknown): val is Map<any, any> {\r\n return _toString.call(val) === '[object Map]';\r\n}\r\nexport function isNil(x: any): x is null | undefined {\r\n return x === null || x === undefined;\r\n}\r\n\r\nexport const isFunction = (val: unknown): val is Function => typeof val === 'function';\r\n\r\nexport function isFalsy(x: any): x is false | null | undefined {\r\n return x === false || x === null || x === undefined || x === '';\r\n}\r\n\r\nexport const isPrimitive = (\r\n val: unknown,\r\n): val is string | number | boolean | symbol | null | undefined =>\r\n ['string', 'number', 'boolean', 'symbol', 'undefined'].includes(typeof val) || isNull(val);\r\n\r\nexport function isHTMLElement(obj) {\r\n if (!obj) return false;\r\n return obj && typeof obj === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string';\r\n}\r\n","import { isFunction, isPrimitive, isString } from './is';\r\n\r\nexport const _toString = Object.prototype.toString;\r\nexport const extend = Object.assign;\r\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\r\nexport const hasOwn = (val: object, key: string | symbol): key is keyof typeof val =>\r\n hasOwnProperty.call(val, key);\r\n\r\nexport function coerceArray<T>(data: T | T[]): T[] {\r\n return Array.isArray(data) ? (data.flat() as T[]) : [data];\r\n}\r\nexport const hasChanged = (value, oldValue) =>\r\n value !== oldValue && (value === value || oldValue === oldValue);\r\nexport const noop = Function.prototype as () => void;\r\n\r\n/**\r\n * A function that checks if a string starts with a specific substring.\r\n * indexOf faster under normal circumstances\r\n * @see https://www.measurethat.net/Benchmarks/Show/12350/0/startswith-vs-test-vs-match-vs-indexof#latest_results_block\r\n\r\n * @param {string} str - The input string to check.\r\n * @param {string} searchString - The substring to check for at the beginning of the input string.\r\n * @return {boolean} Returns true if the input string starts with the specified substring, otherwise false.\r\n */\r\nexport function startsWith(str, searchString) {\r\n if (!isString(str)) {\r\n return false;\r\n }\r\n return str.indexOf(searchString) === 0;\r\n}\r\n\r\n/**\r\n * Recursively clones an object, including its nested properties and special types like Date, RegExp, Map, and Set.\r\n *\r\n * @param {any} obj - The object to clone.\r\n * @param {WeakMap<object, object>} [hash] - A WeakMap used to track circular references.\r\n * @return {any} The cloned object.\r\n */\r\nexport function deepClone(obj, hash = new WeakMap()) {\r\n // Return primitives and functions as-is\r\n if (obj === null || typeof obj !== 'object') {\r\n return obj;\r\n }\r\n\r\n // Handle circular references\r\n if (hash.has(obj)) {\r\n return hash.get(obj);\r\n }\r\n\r\n // Handle special types\r\n if (obj instanceof Date) {\r\n return new Date(obj);\r\n }\r\n\r\n if (obj instanceof RegExp) {\r\n return new RegExp(obj);\r\n }\r\n\r\n if (obj instanceof Map) {\r\n const mapClone = new Map();\r\n hash.set(obj, mapClone);\r\n obj.forEach((value, key) => {\r\n mapClone.set(deepClone(key, hash), deepClone(value, hash));\r\n });\r\n return mapClone;\r\n }\r\n\r\n if (obj instanceof Set) {\r\n const setClone = new Set();\r\n hash.set(obj, setClone);\r\n obj.forEach(value => {\r\n setClone.add(deepClone(value, hash));\r\n });\r\n return setClone;\r\n }\r\n\r\n // Initialize the clone and store it in the WeakMap\r\n const cloneObj = Array.isArray(obj) ? [] : {};\r\n hash.set(obj, cloneObj);\r\n\r\n // Iterate over object keys\r\n const keys = Object.keys(obj);\r\n for (const key of keys) {\r\n cloneObj[key] = deepClone(obj[key], hash);\r\n }\r\n\r\n return cloneObj;\r\n}\r\n\r\n/**\r\n * Determines whether two values are deeply equal.\r\n *\r\n * @param {any} a - The first value to compare.\r\n * @param {any} b - The second value to compare.\r\n * @param {WeakMap<object, object>} [seen] - A WeakMap used to store previously seen objects to avoid infinite recursion.\r\n * @return {boolean} True if the values are deeply equal, false otherwise.\r\n */\r\nexport function deepEqual(a: any, b: any, seen = new WeakMap()): boolean {\r\n if (isPrimitive(a) && isPrimitive(b)) {\r\n return a === b;\r\n }\r\n\r\n if (a === b) {\r\n return true;\r\n }\r\n\r\n if (a == null || b == null || typeof a !== 'object' || typeof b !== 'object') {\r\n return false;\r\n }\r\n\r\n if (a.constructor !== b.constructor) {\r\n return false;\r\n }\r\n\r\n if (seen.has(a)) {\r\n return seen.get(a) === b;\r\n }\r\n\r\n seen.set(a, b);\r\n\r\n if (Array.isArray(a)) {\r\n if (a.length !== b.length) {\r\n return false;\r\n }\r\n for (const [i, element] of a.entries()) {\r\n if (!deepEqual(element, b[i], seen)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n if (a instanceof Map) {\r\n if (a.size !== b.size) {\r\n return false;\r\n }\r\n for (const [key, value] of a) {\r\n if (!b.has(key) || !deepEqual(value, b.get(key), seen)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n if (a instanceof Set) {\r\n if (a.size !== b.size) {\r\n return false;\r\n }\r\n const arrA = Array.from(a).sort();\r\n const arrB = Array.from(b).sort();\r\n for (const [i, element] of arrA.entries()) {\r\n if (!deepEqual(element, arrB[i], seen)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n const keysA = Object.keys(a);\r\n const keysB = new Set(Object.keys(b));\r\n\r\n if (keysA.length !== keysB.size) {\r\n return false;\r\n }\r\n\r\n for (const key of keysA) {\r\n if (!keysB.has(key) || !deepEqual(a[key], b[key], seen)) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n}\r\n\r\n/**\r\n * Escapes special HTML characters in a string.\r\n * @param str - The string to escape.\r\n * @returns The escaped string.\r\n */\r\nexport function escape(str: string): string {\r\n return str.replaceAll(/[\"&'<>]/g, char => {\r\n switch (char) {\r\n case '&':\r\n return '&amp;';\r\n case '<':\r\n return '&lt;';\r\n case '>':\r\n return '&gt;';\r\n case '\"':\r\n return '&quot;';\r\n case \"'\":\r\n return '&#039;';\r\n default:\r\n return char;\r\n }\r\n });\r\n}\r\n\r\nexport type ExcludeType = ((key: string | symbol) => boolean) | (string | symbol)[];\r\n\r\n/**\r\n * Checks if a key should be excluded based on the provided exclude criteria.\r\n * @param key - The key to check.\r\n * @param exclude - The exclusion criteria.\r\n * @returns True if the key should be excluded, otherwise false.\r\n */\r\nexport function isExclude(key: string | symbol, exclude?: ExcludeType): boolean {\r\n return Array.isArray(exclude)\r\n ? exclude.includes(key)\r\n : isFunction(exclude)\r\n ? exclude(key)\r\n : false;\r\n}\r\n","export const kebabCase = (string: string): string => {\r\n return string.replaceAll(/[A-Z]+/g, (match, offset) => {\r\n return `${offset > 0 ? '-' : ''}${match.toLocaleLowerCase()}`;\r\n });\r\n};\r\n\r\nexport const camelCase = (str: string): string => {\r\n const s = str.replaceAll(/[\\s_-]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''));\r\n return s[0].toLowerCase() + s.slice(1);\r\n};\r\n/**\r\n * Capitalizes the first letter of a string.\r\n *\r\n * @param {string} inputString - The input string to capitalize the first letter.\r\n * @return {string} The string with the first letter capitalized.\r\n */\r\nexport const capitalizeFirstLetter = (inputString: string): string => {\r\n return inputString.charAt(0).toUpperCase() + inputString.slice(1);\r\n};\r\n","import { capitalizeFirstLetter } from 'essor-shared';\r\nimport { types as t } from '@babel/core';\r\nimport { imports } from '../program';\r\nimport { selfClosingTags, svgTags } from './constants';\r\nimport {\r\n type JSXChild,\r\n type JSXElement,\r\n getAttrName,\r\n getTagName,\r\n isComponent,\r\n isTextChild,\r\n setNodeText,\r\n} from './shared';\r\nimport type { OptionalMemberExpression } from '@babel/types';\r\nimport type { State } from '../types';\r\nimport type { NodePath } from '@babel/core';\r\n\r\nexport interface Result {\r\n index: number;\r\n isLastChild: boolean;\r\n parentIndex: number;\r\n props: Record<string, any>;\r\n template: string[];\r\n}\r\n\r\nexport function transformJSXService(path: NodePath<JSXElement>): void {\r\n const result: Result = {\r\n index: 0,\r\n isLastChild: false,\r\n parentIndex: 0,\r\n props: {},\r\n template: [], // 修改为数组\r\n };\r\n transformJSXServiceElement(path, result, true);\r\n path.replaceWith(createEssorNode(path, result));\r\n}\r\n\r\nfunction createEssorNode(path: NodePath<JSXElement>, result: Result): t.CallExpression {\r\n const state: State = path.state;\r\n\r\n let tmpl: t.Identifier;\r\n if (path.isJSXElement() && isComponent(getTagName(path.node))) {\r\n tmpl = t.identifier(getTagName(path.node));\r\n } else {\r\n tmpl = path.scope.generateUidIdentifier('_tmpl$');\r\n const template = t.arrayExpression(result.template.map(t.stringLiteral));\r\n const declarator = t.variableDeclarator(tmpl, template);\r\n state.tmplDeclaration.declarations.push(declarator);\r\n }\r\n\r\n const args = [tmpl, createProps(result.props)];\r\n const key = result.props.key || result.props[0]?.key;\r\n if (key) {\r\n args.push(key);\r\n }\r\n imports.add('renderTemplate');\r\n return t.callExpression(state.renderTemplate, args);\r\n}\r\n\r\nfunction createProps(props: Record<string, any>): t.ObjectExpression {\r\n const result: (t.ObjectProperty | t.SpreadElement)[] = [];\r\n\r\n for (const prop in props) {\r\n let value = props[prop];\r\n\r\n if (prop === 'key') {\r\n continue;\r\n }\r\n\r\n if (Array.isArray(value)) {\r\n value = t.arrayExpression(value);\r\n }\r\n\r\n if (typeof value === 'object' && value !== null && !t.isNode(value)) {\r\n value = createProps(value);\r\n }\r\n\r\n if (typeof value === 'string') {\r\n value = t.stringLiteral(value);\r\n }\r\n\r\n if (typeof value === 'number') {\r\n value = t.numericLiteral(value);\r\n }\r\n\r\n if (typeof value === 'boolean') {\r\n value = t.booleanLiteral(value);\r\n }\r\n\r\n if (value === undefined) {\r\n value = t.tsUndefinedKeyword();\r\n }\r\n\r\n if (value === null) {\r\n value = t.nullLiteral();\r\n }\r\n\r\n if (prop === '_$spread$') {\r\n result.push(t.spreadElement(value));\r\n } else {\r\n result.push(t.objectProperty(t.stringLiteral(prop), value));\r\n }\r\n }\r\n\r\n return t.objectExpression(result);\r\n}\r\nfunction transformJSXServiceElement(\r\n path: NodePath<JSXElement>,\r\n result: Result,\r\n isRoot: boolean = false,\r\n): void {\r\n if (path.isJSXElement()) {\r\n const tagName = getTagName(path.node);\r\n const tagIsComponent = isComponent(tagName);\r\n const isSelfClose = !tagIsComponent && selfClosingTags.includes(tagName);\r\n const isSvg = svgTags.includes(tagName) && result.index === 1;\r\n const { props, hasExpression } = getAttrProps(path);\r\n if (tagIsComponent) {\r\n if (isRoot) {\r\n result.props = props;\r\n const children = getChildren(path) as any;\r\n if (children.length > 0) {\r\n const childrenGenerator =\r\n children.length === 1 ? children[0] : t.arrayExpression(children);\r\n result.props.children = childrenGenerator;\r\n }\r\n } else {\r\n transformJSXService(path);\r\n replaceChild(path.node, result);\r\n }\r\n } else {\r\n if (isSvg) {\r\n result.template.push('<svg _svg_>');\r\n }\r\n result.template.push(`<${tagName}`);\r\n handleAttributes(props, result);\r\n\r\n if (hasExpression) {\r\n result.template.push(isSelfClose ? '/>' : '>');\r\n result.props ||= {};\r\n } else {\r\n result.template[result.template.length - 1] += isSelfClose ? '/>' : '>';\r\n }\r\n transformChildren(path, result);\r\n\r\n if (!isSelfClose) {\r\n result.template.push(`</${tagName}>`);\r\n }\r\n }\r\n } else {\r\n result.index--;\r\n transformChildren(path, result);\r\n }\r\n}\r\n\r\nfunction transformChildren(path: NodePath<JSXElement>, result: Result): void {\r\n const parentIndex = result.template.length;\r\n path\r\n .get('children')\r\n .reduce((pre, cur) => {\r\n if (isValidChild(cur)) {\r\n const lastChild = pre.at(-1);\r\n if (lastChild && isTextChild(cur) && isTextChild(lastChild)) {\r\n setNodeText(lastChild, getNodeText(lastChild) + getNodeText(cur));\r\n } else {\r\n pre.push(cur);\r\n }\r\n }\r\n return pre;\r\n }, [] as NodePath<JSXChild>[])\r\n .forEach((child, i, arr) => {\r\n result.parentIndex = parentIndex;\r\n result.isLastChild = i === arr.length - 1;\r\n transformChild(child, result);\r\n });\r\n}\r\n\r\nfunction transformChild(child: NodePath<JSXChild>, result: Result): void {\r\n if (child.isJSXElement() || child.isJSXFragment()) {\r\n transformJSXServiceElement(child, result, false);\r\n } else if (child.isJSXExpressionContainer()) {\r\n const expression = child.get('expression');\r\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\r\n result.template[result.template.length - 1] += String(expression.node.value);\r\n } else if (expression.isExpression()) {\r\n replaceChild(expression.node, result);\r\n } else if (t.isJSXEmptyExpression(expression.node)) {\r\n // it is empty expression\r\n // do nothing\r\n } else {\r\n throw new Error('Unsupported child type');\r\n }\r\n } else if (child.isJSXText()) {\r\n result.template.push(String(child.node.value));\r\n } else {\r\n throw new Error('Unsupported child type');\r\n }\r\n}\r\n\r\nfunction getNodeText(path: NodePath<JSXChild>): string {\r\n if (path.isJSXText()) {\r\n return path.node.value;\r\n }\r\n if (path.isJSXExpressionContainer()) {\r\n const expression = path.get('expression');\r\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\r\n return String(expression.node.value);\r\n }\r\n }\r\n return '';\r\n}\r\n\r\nfunction handleAttributes(props: Record<string, any>, result: Result): void {\r\n let klass = '';\r\n let style = '';\r\n\r\n for (const prop in props) {\r\n const value = props[prop];\r\n\r\n if (prop === 'class' && typeof value === 'string') {\r\n klass += ` ${value}`;\r\n delete props[prop];\r\n continue;\r\n }\r\n\r\n if (prop === 'style' && typeof value === 'string') {\r\n style += `${value}${value.at(-1) === ';' ? '' : ';'}`;\r\n delete props[prop];\r\n continue;\r\n }\r\n\r\n if (value === true) {\r\n result.template[result.template.length - 1] += ` ${prop}`;\r\n delete props[prop];\r\n }\r\n if (value === false) {\r\n delete props[prop];\r\n }\r\n if (typeof value === 'string' || typeof value === 'number') {\r\n result.template[result.template.length - 1] += ` ${prop}=\"${value}\"`;\r\n delete props[prop];\r\n }\r\n }\r\n\r\n if (Object.keys(props).length > 0) {\r\n result.props[result.index] = props;\r\n }\r\n\r\n klass = klass.trim();\r\n style = style.trim();\r\n\r\n if (klass) {\r\n result.template[result.template.length - 1] += ` class=\"${klass}\"`;\r\n }\r\n if (style) {\r\n result.template[result.template.length - 1] += ` style=\"${style}\"`;\r\n }\r\n}\r\n\r\nfunction replaceChild(node: t.Expression, result: Result): void {\r\n if (result.isLastChild) {\r\n result.index--;\r\n }\r\n result.props[result.parentIndex] ??= {};\r\n result.props[result.parentIndex].children ??= [];\r\n result.props[result.parentIndex].children.push(\r\n t.arrayExpression([\r\n t.arrowFunctionExpression([], node),\r\n t.identifier(String(result.template.length)),\r\n ]),\r\n );\r\n}\r\n\r\nfunction getChildren(path: NodePath<JSXElement>): JSXChild[] {\r\n return path\r\n .get('children')\r\n .filter(child => isValidChild(child))\r\n .map(child => {\r\n if (child.isJSXElement() || child.isJSXFragment()) {\r\n transformJSXService(child);\r\n } else if (child.isJSXExpressionContainer()) {\r\n child.replaceWith(child.get('expression'));\r\n } else if (child.isJSXText()) {\r\n child.replaceWith(t.stringLiteral(child.node.value));\r\n } else {\r\n throw new Error('Unsupported child type');\r\n }\r\n return child.node;\r\n });\r\n}\r\n\r\nfunction isValidChild(path: NodePath<JSXChild>): boolean {\r\n const regex = /^\\s*$/;\r\n if (path.isStringLiteral() || path.isJSXText()) {\r\n return !regex.test(path.node.value);\r\n }\r\n return Object.keys(path.node).length > 0;\r\n}\r\nfunction getAttrProps(path: NodePath<t.JSXElement>): Record<string, any> {\r\n const props: Record<string, any> = {};\r\n let hasExpression = false;\r\n path\r\n .get('openingElement')\r\n .get('attributes')\r\n .forEach(attribute => {\r\n if (attribute.isJSXAttribute()) {\r\n const name = getAttrName(attribute.node);\r\n const value = attribute.get('value');\r\n\r\n if (!value.node) {\r\n props[name] = true;\r\n } else if (value.isStringLiteral()) {\r\n props[name] = value.node.value;\r\n } else {\r\n if (value.isJSXExpressionContainer()) {\r\n const expression = value.get('expression');\r\n\r\n if (expression.isStringLiteral()) {\r\n props[name] = expression.node.value;\r\n } else if (expression.isNumericLiteral()) {\r\n props[name] = expression.node.value;\r\n } else if (expression.isJSXElement() || expression.isJSXFragment()) {\r\n transformJSXService(expression);\r\n props[name] = expression.node;\r\n } else if (expression.isExpression()) {\r\n hasExpression = true;\r\n if (/^key|ref|on.+$/.test(name)) {\r\n props[name] = expression.node;\r\n } else if (/^bind:.+/.test(name)) {\r\n const value = path.scope.generateUidIdentifier('value');\r\n const bindName = name.slice(5).toLocaleLowerCase();\r\n props[bindName] = expression.node;\r\n props[`update${capitalizeFirstLetter(bindName)}`] = t.arrowFunctionExpression(\r\n [value],\r\n t.assignmentExpression('=', expression.node as OptionalMemberExpression, value),\r\n );\r\n } else {\r\n if (expression.isConditionalExpression()) {\r\n props[name] = t.arrowFunctionExpression([], expression.node);\r\n } else {\r\n props[name] = expression.node;\r\n }\r\n }\r\n }\r\n } else if (value.isJSXElement() || value.isJSXFragment()) {\r\n transformJSXService(value);\r\n props[name] = value.node;\r\n }\r\n }\r\n } else if (attribute.isJSXSpreadAttribute()) {\r\n props._$spread$ = attribute.get('argument').node;\r\n hasExpression = true;\r\n } else {\r\n throw new Error('Unsupported attribute type');\r\n }\r\n });\r\n\r\n return {\r\n props,\r\n hasExpression,\r\n };\r\n}\r\n","import { type NodePath, types as t } from '@babel/core';\nimport type { State } from './types';\nexport const imports = new Set<string>();\n\nexport const transformProgram = {\n enter(path: NodePath<t.Program>, state) {\n imports.clear();\n\n path.state = {\n h: path.scope.generateUidIdentifier('h$'),\n renderTemplate: path.scope.generateUidIdentifier('renderTemplate$'),\n template: path.scope.generateUidIdentifier('template$'),\n\n useSignal: path.scope.generateUidIdentifier('signal$'),\n useComputed: path.scope.generateUidIdentifier('computed$'),\n useReactive: path.scope.generateUidIdentifier('reactive$'),\n\n tmplDeclaration: t.variableDeclaration('const', []),\n opts: state.opts,\n } as State;\n },\n exit(path: NodePath<t.Program>) {\n const state: State = path.state;\n if (state.tmplDeclaration.declarations.length > 0) {\n const index = path.node.body.findIndex(\n node => !t.isImportDeclaration(node) && !t.isExportDeclaration(node),\n );\n path.node.body.splice(index, 0, state.tmplDeclaration);\n }\n if (imports.size > 0) {\n path.node.body.unshift(createImport(state, 'essor'));\n }\n },\n};\nfunction createImport(state: State, from: string) {\n const ImportSpecifier: t.ImportSpecifier[] = [];\n imports.forEach(name => {\n const local = t.identifier(state[name].name);\n const imported = t.identifier(name);\n ImportSpecifier.push(t.importSpecifier(local, imported));\n });\n\n const importSource = t.stringLiteral(from);\n return t.importDeclaration(ImportSpecifier, importSource);\n}\n","export const selfClosingTags = [\r\n 'area',\r\n 'base',\r\n 'br',\r\n 'col',\r\n 'embed',\r\n 'hr',\r\n 'img',\r\n 'input',\r\n 'link',\r\n 'meta',\r\n 'param',\r\n 'source',\r\n 'track',\r\n 'wbr',\r\n];\r\n\r\nexport const svgTags = [\r\n 'circle',\r\n 'clipPath',\r\n 'defs',\r\n 'ellipse',\r\n 'filter',\r\n 'g',\r\n 'line',\r\n 'linearGradient',\r\n 'mask',\r\n 'path',\r\n 'pattern',\r\n 'polygon',\r\n 'polyline',\r\n 'radialGradient',\r\n 'rect',\r\n 'stop',\r\n 'symbol',\r\n 'text',\r\n 'use',\r\n];\r\n","import { type NodePath, types as t } from '@babel/core';\r\n\r\nexport type JSXElement = t.JSXElement | t.JSXFragment;\r\n\r\nexport type JSXChild =\r\n | t.JSXElement\r\n | t.JSXFragment\r\n | t.JSXExpressionContainer\r\n | t.JSXSpreadChild\r\n | t.JSXText;\r\n\r\n/**\r\n * Checks if the given Babel path has a sibling element.\r\n *\r\n * @param {NodePath} path - The Babel path to check.\r\n * @return {boolean} True if the path has a sibling element, false otherwise.\r\n */\r\nexport function hasSiblingElement(path) {\r\n // Get all siblings (both previous and next)\r\n const siblings = path.getAllPrevSiblings().concat(path.getAllNextSiblings());\r\n\r\n // Check for non-self-closing sibling elements or JSXExpressionContainer\r\n const hasSibling = siblings.some(\r\n siblingPath => siblingPath.isJSXElement() || siblingPath.isJSXExpressionContainer(),\r\n );\r\n\r\n return hasSibling;\r\n}\r\n/**\r\n * Retrieves the name of a JSX attribute.\r\n *\r\n * @param {t.JSXAttribute} attribute - The JSX attribute to retrieve the name from.\r\n * @return {string} The name of the attribute.\r\n * @throws {Error} If the attribute type is unsupported.\r\n */\r\nexport function getAttrName(attribute: t.JSXAttribute): string {\r\n if (t.isJSXIdentifier(attribute.name)) {\r\n return attribute.name.name;\r\n }\r\n if (t.isJSXNamespacedName(attribute.name)) {\r\n return `${attribute.name.namespace.name}:${attribute.name.name.name}`;\r\n }\r\n throw new Error('Unsupported attribute type');\r\n}\r\n\r\n/**\r\n * Retrieves the tag name of a JSX element.\r\n *\r\n * @param {t.JSXElement} node - The JSX element.\r\n * @return {string} The tag name of the JSX element.\r\n */\r\nexport function getTagName(node: t.JSXElement): string {\r\n const tag = node.openingElement.name;\r\n return jsxElementNameToString(tag);\r\n}\r\n\r\n/**\r\n * Converts a JSX element name to a string representation.\r\n *\r\n * case1: <MyComponent />\r\n * case2: <SomeLibrary.SomeComponent />;\r\n * case3: <namespace:ComponentName />;\r\n * case4: <SomeLibrary.Nested.ComponentName />;\r\n *\r\n * @param {t.JSXMemberExpression | t.JSXIdentifier | t.JSXNamespacedName} node The JSX element name to convert.\r\n * @returns {string} The string representation of the JSX element name.\r\n */\r\nexport function jsxElementNameToString(\r\n node: t.JSXMemberExpression | t.JSXIdentifier | t.JSXNamespacedName,\r\n) {\r\n if (t.isJSXMemberExpression(node)) {\r\n return `${jsxElementNameToString(node.object)}.${jsxElementNameToString(node.property)}`;\r\n }\r\n\r\n if (t.isJSXIdentifier(node) || t.isIdentifier(node)) {\r\n return node.name;\r\n }\r\n\r\n return `${node.namespace.name}:${node.name.name}`;\r\n}\r\n\r\n/**\r\n * Determines if the given tagName is a component.\r\n *\r\n * case1: <MyComponent />\r\n * case2: <SomeLibrary.SomeComponent />;\r\n * case3: <_component />;\r\n *\r\n * @param {string} tagName - The name of the tag to check.\r\n * @return {boolean} True if the tagName is a component, false otherwise.\r\n */\r\nexport function isComponent(tagName: string): boolean {\r\n return (\r\n (tagName[0] && tagName[0].toLowerCase() !== tagName[0]) ||\r\n tagName.includes('.') ||\r\n /[^a-z]/i.test(tagName[0])\r\n );\r\n}\r\n\r\n/**\r\n * Determines if the given path represents a text child node in a JSX expression.\r\n *\r\n * @param {NodePath<JSXChild>} path - The path to the potential text child node.\r\n * @return {boolean} True if the path represents a text child node, false otherwise.\r\n */\r\nexport function isTextChild(path: NodePath<JSXChild>): boolean {\r\n if (path.isJSXExpressionContainer()) {\r\n const expression = path.get('expression');\r\n if (expression.isJSXText() || expression.isStringLiteral() || expression.isNumericLiteral()) {\r\n return true;\r\n }\r\n }\r\n if (path.isJSXText() || path.isStringLiteral() || path.isNullLiteral()) {\r\n return true;\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Sets the text content of a JSX node.\r\n *\r\n * @param {NodePath<JSXChild>} path - The path to the JSX node.\r\n * @param {string} text - The text to set.\r\n * @return {void}\r\n */\r\nexport function setNodeText(path: NodePath<JSXChild>, text: string): void {\r\n if (path.isJSXText()) {\r\n path.node.value = text;\r\n }\r\n if (path.isJSXExpressionContainer()) {\r\n const expression = path.get('expression');\r\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\r\n expression.replaceWith(t.stringLiteral(text));\r\n }\r\n }\r\n}\r\n","import { types as t } from '@babel/core';\nimport { capitalizeFirstLetter } from 'essor-shared';\nimport { imports } from '../program';\nimport { selfClosingTags, svgTags } from './constants';\nimport {\n type JSXChild,\n type JSXElement,\n getAttrName,\n getTagName,\n hasSiblingElement,\n isComponent,\n isTextChild,\n setNodeText,\n} from './shared';\nimport type { OptionalMemberExpression } from '@babel/types';\nimport type { State } from '../types';\nimport type { NodePath } from '@babel/core';\n\nexport interface Result {\n index: number;\n isLastChild: boolean;\n parentIndex: number;\n props: Record<string, any>;\n template: string;\n}\n\nexport function transformJSXClient(path: NodePath<JSXElement>): void {\n const result: Result = {\n index: 1,\n isLastChild: false,\n parentIndex: 0,\n props: {},\n template: '',\n };\n transformJSXElement(path, result, true);\n\n path.replaceWith(createEssorNode(path, result));\n}\n\nfunction createEssorNode(path: NodePath<JSXElement>, result: Result): t.CallExpression {\n const state: State = path.state;\n\n let tmpl: t.Identifier;\n if (path.isJSXElement() && isComponent(getTagName(path.node))) {\n tmpl = t.identifier(getTagName(path.node));\n } else {\n tmpl = path.scope.generateUidIdentifier('_tmpl$');\n const template = t.callExpression(state.template, [t.stringLiteral(result.template)]);\n const declarator = t.variableDeclarator(tmpl, template);\n state.tmplDeclaration.declarations.push(declarator);\n imports.add('template');\n }\n\n const args = [tmpl, createProps(result.props)];\n const key = result.props.key || result.props[0]?.key;\n if (key) {\n args.push(key);\n }\n imports.add('h');\n return t.callExpression(state.h, args);\n}\n\nfunction createProps(props) {\n const toAstNode = value => {\n if (Array.isArray(value)) {\n return t.arrayExpression(value.map(toAstNode));\n }\n if (value && typeof value === 'object' && !t.isNode(value)) {\n return createProps(value);\n }\n\n switch (typeof value) {\n case 'string':\n return t.stringLiteral(value);\n case 'number':\n return t.numericLiteral(value);\n case 'boolean':\n return t.booleanLiteral(value);\n case 'undefined':\n return t.tsUndefinedKeyword();\n case undefined:\n return t.tsUndefinedKeyword();\n case null:\n return t.nullLiteral();\n default:\n return value;\n }\n };\n\n const result = Object.keys(props)\n .filter(prop => prop !== 'key')\n .map(prop => {\n const value = toAstNode(props[prop]);\n return prop === '_$spread$'\n ? t.spreadElement(value)\n : t.objectProperty(t.stringLiteral(prop), value);\n });\n\n return t.objectExpression(result);\n}\nfunction transformJSXElement(\n path: NodePath<JSXElement>,\n result: Result,\n isRoot: boolean = false,\n): void {\n if (path.isJSXElement()) {\n const tagName = getTagName(path.node);\n const tagIsComponent = isComponent(tagName);\n const isSelfClose = !tagIsComponent && selfClosingTags.includes(tagName);\n const isSvg = svgTags.includes(tagName) && result.index === 1;\n const props = getAttrProps(path);\n if (tagIsComponent) {\n if (isRoot) {\n result.props = props;\n const children = getChildren(path) as any;\n if (children.length > 0) {\n const childrenGenerator =\n children.length === 1 ? children[0] : t.arrayExpression(children);\n result.props.children = childrenGenerator;\n }\n } else {\n transformJSXClient(path);\n replaceChild(path.node, result);\n }\n } else {\n if (isSvg) {\n result.template = '<svg _svg_>';\n }\n result.template += `<${tagName}`;\n handleAttributes(props, result);\n result.template += isSelfClose ? '/>' : '>';\n if (!isSelfClose) {\n transformChildren(path, result);\n\n if (hasSiblingElement(path)) {\n result.template += `</${tagName}>`;\n }\n }\n }\n } else {\n result.index--;\n transformChildren(path, result);\n }\n}\n\nfunction transformChildren(path: NodePath<JSXElement>, result: Result): void {\n const parentIndex = result.index;\n path\n .get('children')\n .reduce((pre, cur) => {\n if (isValidChild(cur)) {\n const lastChild = pre.at(-1);\n if (lastChild && isTextChild(cur) && isTextChild(lastChild)) {\n setNodeText(lastChild, getNodeText(lastChild) + getNodeText(cur));\n } else {\n pre.push(cur);\n }\n }\n return pre;\n }, [] as NodePath<JSXChild>[])\n .forEach((child, i, arr) => {\n result.parentIndex = parentIndex;\n result.isLastChild = i === arr.length - 1;\n transformChild(child, result);\n });\n}\n\nfunction transformChild(child: NodePath<JSXChild>, result: Result): void {\n result.index++;\n if (child.isJSXElement() || child.isJSXFragment()) {\n transformJSXElement(child, result, false);\n } else if (child.isJSXExpressionContainer()) {\n const expression = child.get('expression');\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\n result.template += String(expression.node.value);\n } else if (expression.isExpression()) {\n replaceChild(expression.node, result);\n } else if (t.isJSXEmptyExpression(expression.node)) {\n // it is empty expression\n // do nothing\n } else {\n throw new Error('Unsupported child type');\n }\n } else if (child.isJSXText()) {\n result.template += String(child.node.value);\n } else {\n throw new Error('Unsupported child type');\n }\n}\n\nfunction getNodeText(path: NodePath<JSXChild>): string {\n if (path.isJSXText()) {\n return path.node.value;\n }\n if (path.isJSXExpressionContainer()) {\n const expression = path.get('expression');\n if (expression.isStringLiteral() || expression.isNumericLiteral()) {\n return String(expression.node.value);\n }\n }\n return '';\n}\n\nfunction handleAttributes(props: Record<string, any>, result: Result): void {\n let klass = '';\n let style = '';\n\n for (const prop in props) {\n let value = props[prop];\n\n if (prop === 'class' && typeof value === 'string') {\n klass += ` ${value}`;\n delete props[prop];\n continue;\n }\n\n if (prop === 'style' && typeof value === 'string') {\n style += `${value}${value.at(-1) === ';' ? '' : ';'}`;\n delete props[prop];\n continue;\n }\n\n if (value === true) {\n result.template += ` ${prop}`;\n delete props[prop];\n }\n if (value === false) {\n delete props[prop];\n }\n if (typeof value === 'string' || typeof value === 'number') {\n result.template += ` ${prop}=\"${value}\"`;\n delete props[prop];\n }\n\n // if value is conditional expression\n if (t.isConditionalExpression(value)) {\n const { test, consequent, alternate } = value;\n value = t.arrowFunctionExpression([], t.conditionalExpression(test, consequent, alternate));\n props[prop] = value;\n }\n\n // if value is object expression and has conditional\n if (t.isObjectExpression(value)) {\n let hasConditional = false;\n value.properties.forEach(property => {\n if (t.isObjectProperty(property) && t.isConditionalExpression(property.value)) {\n hasConditional = true;\n }\n });\n if (hasConditional) {\n value = t.arrowFunctionExpression([], value);\n }\n\n props[prop] = value;\n }\n }\n\n if (Object.keys(props).length > 0) {\n result.props[result.index] = props;\n }\n\n klass = klass.trim();\n style = style.trim();\n\n if (klass) {\n result.template += ` class=\"${klass}\"`;\n }\n if (style) {\n result.template += ` style=\"${style}\"`;\n }\n}\n\nfunction replaceChild(node: t.Expression, result: Result): void {\n if (result.isLastChild) {\n result.index--;\n } else {\n result.template += '<!>';\n }\n result.props[result.parentIndex] ??= {};\n result.props[result.parentIndex].children ??= [];\n result.props[result.parentIndex].children.push(\n t.arrayExpression([\n t.arrowFunctionExpression([], node),\n result.isLastChild ? t.nullLiteral() : t.identifier(String(result.index)),\n ]),\n );\n}\n\nfunction getChildren(path: NodePath<JSXElement>): JSXChild[] {\n return path\n .get('children')\n .filter(child => isValidChild(child))\n .map(child => {\n if (child.isJSXElement() || child.isJSXFragment()) {\n transformJSXClient(child);\n } else if (child.isJSXExpressionContainer()) {\n child.replaceWith(child.get('expression'));\n } else if (child.isJSXText()) {\n child.replaceWith(t.stringLiteral(child.node.value));\n } else {\n throw new Error('Unsupported child type');\n }\n return child.node;\n });\n}\n\nexport function isValidChild(path: NodePath<JSXChild>): boolean {\n const regex = /^\\s*$/;\n if (path.isStringLiteral() || path.isJSXText()) {\n return !regex.test(path.node.value);\n }\n return Object.keys(path.node).length > 0;\n}\nexport function getAttrProps(path: NodePath<t.JSXElement>): Record<string, any> {\n const props: Record<string, any> = {};\n\n path\n .get('openingElement')\n .get('attributes')\n .forEach(attribute => {\n if (attribute.isJSXAttribute()) {\n const name = getAttrName(attribute.node);\n const value = attribute.get('value');\n\n if (!value.node) {\n props[name] = true;\n } else if (value.isStringLiteral()) {\n props[name] = value.node.value;\n } else {\n if (value.isJSXExpressionContainer()) {\n const expression = value.get('expression');\n\n if (expression.isStringLiteral()) {\n props[name] = expression.node.value;\n } else if (expression.isNumericLiteral()) {\n props[name] = expression.node.value;\n } else if (expression.isJSXElement() || expression.isJSXFragment()) {\n transformJSXClient(expression);\n props[name] = expression.node;\n } else if (expression.isExpression()) {\n if (/^key|ref|on.+$/.test(name)) {\n props[name] = expression.node;\n } else if (/^bind:.+/.test(name)) {\n const value = path.scope.generateUidIdentifier('value');\n const bindName = name.slice(5).toLocaleLowerCase();\n props[bindName] = expression.node;\n props[`update${capitalizeFirstLetter(bindName)}`] = t.arrowFunctionExpression(\n [value],\n t.assignmentExpression('=', expression.node as OptionalMemberExpression, value),\n );\n } else {\n if (expression.isConditionalExpression()) {\n props[name] = t.arrowFunctionExpression([], expression.node);\n } else {\n props[name] = expression.node;\n }\n }\n }\n } else if (value.isJSXElement() || value.isJSXFragment()) {\n transformJSXClient(value);\n props[name] = value.node;\n }\n }\n } else if (attribute.isJSXSpreadAttribute()) {\n props._$spread$ = attribute.get('argument').node;\n } else {\n throw new Error('Unsupported attribute type');\n }\n });\n\n return props;\n}\n","import { transformJSXService } from './server';\r\nimport { transformJSXClient } from './client';\r\nimport type { NodePath, types as t } from '@babel/core';\r\nimport type { State } from '../types';\r\ntype JSXElement = t.JSXElement | t.JSXFragment;\r\nexport function transformJSX(path: NodePath<JSXElement>) {\r\n const state: State = path.state;\r\n const isSsg = state.opts.ssg;\r\n return isSsg ? transformJSXService(path) : transformJSXClient(path);\r\n}\r\n","import { types as t } from '@babel/core';\r\nimport { startsWith } from 'essor-shared';\r\nimport { imports } from '../program';\r\nimport type { Identifier, VariableDeclarator } from '@babel/types';\r\nimport type { NodePath } from '@babel/core';\r\n\r\n/**\r\n * 当一个变量/常量声明的时候,判断是否是$(定义的符号)开头,如果是,则进行转换。\r\n *\r\n * case 1: let $a = 1 => let $a = useSignal(1);\r\n * case 2: const $a = ()=>{return $a} => const $a = useComputed(()=>{return $a})\r\n *\r\n * 并且所有当前用到的值,都会添加.value\r\n * @param path\r\n * @returns {void}\r\n */\r\nexport function replaceSymbol(path: NodePath<VariableDeclarator>) {\r\n const init = path.node.init;\r\n const variableName = (path.node.id as Identifier).name;\r\n\r\n if (t.isObjectPattern(path.node.id) || t.isArrayPattern(path.node.id)) {\r\n return;\r\n }\r\n\r\n if (!startsWith(variableName, '$')) {\r\n return;\r\n }\r\n\r\n if (\r\n init &&\r\n (t.isFunctionExpression(init) || t.isArrowFunctionExpression(init)) &&\r\n (path.parent as t.VariableDeclaration).kind === 'const'\r\n ) {\r\n const newInit = t.callExpression(t.identifier(path.state.useComputed.name), init ? [init] : []);\r\n imports.add('useComputed');\r\n path.node.init = newInit;\r\n } else {\r\n const newInit = t.callExpression(t.identifier(path.state.useSignal.name), init ? [init] : []);\r\n imports.add('useSignal');\r\n path.node.init = newInit;\r\n }\r\n}\r\n\r\nexport function symbolIdentifier(path) {\r\n const parentPath = path.parentPath;\r\n\r\n if (\r\n !parentPath ||\r\n t.isVariableDeclarator(parentPath) ||\r\n t.isImportSpecifier(parentPath) ||\r\n t.isObjectProperty(parentPath) ||\r\n t.isArrayPattern(parentPath) ||\r\n t.isObjectPattern(parentPath)\r\n ) {\r\n return;\r\n }\r\n\r\n const { node } = path;\r\n\r\n if (node.name.startsWith('$')) {\r\n // check is has .value\r\n let currentPath = path;\r\n while (currentPath.parentPath && !currentPath.parentPath.isProgram()) {\r\n if (\r\n currentPath.parentPath.isMemberExpression() &&\r\n currentPath.parentPath.node.property.name === 'value'\r\n ) {\r\n return;\r\n }\r\n currentPath = currentPath.parentPath;\r\n }\r\n\r\n // add with .value\r\n const newNode = t.memberExpression(t.identifier(node.name), t.identifier('value'));\r\n\r\n path.replaceWith(newNode);\r\n }\r\n}\r\n\r\nexport function symbolObjectPattern(path) {\r\n path.node.properties.forEach(property => {\r\n if (\r\n t.isObjectProperty(property) &&\r\n t.isIdentifier(property.key) &&\r\n property.key.name.startsWith('$')\r\n ) {\r\n const newKey = t.identifier(property.key.name);\r\n property.key = newKey;\r\n }\r\n });\r\n}\r\n\r\nexport function symbolArrayPattern(path) {\r\n path.node.elements.forEach(element => {\r\n if (t.isIdentifier(element) && element.name.startsWith('$')) {\r\n const newElement = t.identifier(element.name);\r\n element.name = newElement.name;\r\n } else if (t.isObjectPattern(element)) {\r\n element.properties.forEach(property => {\r\n if (\r\n t.isObjectProperty(property) &&\r\n t.isIdentifier(property.key) &&\r\n property.key.name.startsWith('$')\r\n ) {\r\n const newKey = t.identifier(property.key.name);\r\n property.key = newKey;\r\n }\r\n });\r\n }\r\n });\r\n}\r\n","import { type NodePath, types as t } from '@babel/core';\r\nimport { startsWith } from 'essor-shared';\r\nimport type { ImportDeclaration } from '@babel/types';\r\n\r\nfunction isVariableUsedAsObject(path: NodePath<ImportDeclaration>, variableName: string) {\r\n const binding = path.scope.getBinding(variableName);\r\n let isUsedObject = false;\r\n if (!binding || !binding.referencePaths) {\r\n return isUsedObject;\r\n }\r\n\r\n for (const referencePath of binding.referencePaths) {\r\n if (t.isMemberExpression(referencePath.parent)) {\r\n // const memberExprParent = referencePath.parent;\r\n\r\n // if (memberExprParent.object && memberExprParent.property) {\r\n // const newMemberExpr = t.memberExpression(\r\n // memberExprParent.object,\r\n // t.identifier(`${(memberExprParent.property as t.Identifier).name}.value`),\r\n // );\r\n // referencePath.parentPath?.replaceWith(newMemberExpr);\r\n isUsedObject = true;\r\n // }\r\n }\r\n }\r\n\r\n return isUsedObject;\r\n}\r\n// TODO: 暂时不支持对象\r\nexport function replaceImportDeclaration(path: NodePath<ImportDeclaration>) {\r\n const imports = path.node.specifiers;\r\n imports.forEach(specifier => {\r\n const variableName = specifier.local.name;\r\n\r\n if (startsWith(variableName, '$') && !isVariableUsedAsObject(path, variableName)) {\r\n path.scope.rename(variableName, `${variableName}.value`);\r\n specifier.local.name = `${variableName}`;\r\n }\r\n });\r\n}\r\n","import { startsWith } from 'essor-shared';\r\nimport { type NodePath, types as t } from '@babel/core';\r\nimport { imports } from '../program';\r\nimport type { State } from '../types';\r\nimport type {\r\n ArrowFunctionExpression,\r\n FunctionDeclaration,\r\n Identifier,\r\n ObjectProperty,\r\n RestElement,\r\n} from '@babel/types';\r\n\r\nexport function replaceProps(path: NodePath<FunctionDeclaration | ArrowFunctionExpression>) {\r\n const state: State = path.state;\r\n\r\n const firstParam = path.node.params[0];\r\n\r\n if (!firstParam || !t.isObjectPattern(firstParam)) {\r\n return;\r\n }\r\n\r\n const returnStatement = path\r\n .get('body')\r\n .get('body')\r\n .find(statement => statement.isReturnStatement());\r\n\r\n if (!returnStatement) {\r\n return;\r\n }\r\n\r\n const returnValue = (returnStatement.node as any)?.argument;\r\n if (!t.isJSXElement(returnValue)) {\r\n return;\r\n }\r\n\r\n function replaceProperties(properties: (ObjectProperty | RestElement)[], parentPath: string) {\r\n properties.forEach(property => {\r\n if (t.isObjectProperty(property)) {\r\n const keyName = (property.key as Identifier).name;\r\n\r\n if (t.isIdentifier(property.value)) {\r\n const propertyName = property.value.name;\r\n const newName = `${parentPath}${keyName}`;\r\n path.scope.rename(propertyName, newName);\r\n } else if (t.isObjectPattern(property.value)) {\r\n replaceProperties(property.value.properties, `${parentPath}${keyName}.`);\r\n }\r\n }\r\n });\r\n }\r\n\r\n const properties = firstParam.properties;\r\n replaceProperties(\r\n properties.filter(property => !t.isRestElement(property)),\r\n '__props.',\r\n );\r\n const notRestProperties = properties.filter(property => !t.isRestElement(property));\r\n const notRestNames = notRestProperties.map(\r\n property => ((property as ObjectProperty).key as Identifier).name,\r\n );\r\n if (__DEV__ && notRestNames.some(name => startsWith(name, '$'))) {\r\n console.warn('props name can not start with $');\r\n return;\r\n }\r\n\r\n const restElement = properties.find(property => t.isRestElement(property)) as\r\n | RestElement\r\n | undefined;\r\n path.node.params[0] = t.identifier('__props');\r\n\r\n if (restElement) {\r\n const restName = (restElement.argument as any).name;\r\n if (notRestProperties.length === 0) {\r\n path.node.params[0] = t.identifier(restName);\r\n } else {\r\n const restVariableDeclaration = t.variableDeclaration('const', [\r\n t.variableDeclarator(\r\n t.identifier(restName),\r\n t.callExpression(state.useReactive, [\r\n t.identifier('__props'),\r\n t.arrayExpression(notRestNames.map(name => t.stringLiteral(name))),\r\n ]),\r\n ),\r\n ]);\r\n imports.add('useReactive');\r\n\r\n (path.node.body as any).body.unshift(restVariableDeclaration);\r\n }\r\n }\r\n}\r\n","import { transformJSX } from './jsx';\r\nimport { transformProgram } from './program';\r\nimport {\r\n replaceSymbol,\r\n symbolArrayPattern,\r\n symbolIdentifier,\r\n symbolObjectPattern,\r\n} from './signal/symbol';\r\nimport { replaceImportDeclaration } from './signal/import';\r\nimport { replaceProps } from './signal/props';\r\nimport type { PluginObj } from '@babel/core';\r\nexport { Options, State } from './types';\r\nexport default function (): PluginObj {\r\n return {\r\n name: 'babel-plugin-essor',\r\n manipulateOptions({ filename }, parserOpts) {\r\n if (filename.endsWith('.ts') || filename.endsWith('.tsx')) {\r\n parserOpts.plugins.push('typescript');\r\n }\r\n parserOpts.plugins.push('jsx');\r\n },\r\n visitor: {\r\n Program: transformProgram,\r\n JSXElement: transformJSX,\r\n JSXFragment: transformJSX,\r\n FunctionDeclaration: replaceProps,\r\n ArrowFunctionExpression: replaceProps,\r\n VariableDeclarator: replaceSymbol,\r\n ImportDeclaration: replaceImportDeclaration,\r\n Identifier: symbolIdentifier,\r\n ObjectPattern: symbolObjectPattern,\r\n ArrayPattern: symbolArrayPattern,\r\n },\r\n };\r\n}\r\n"],"mappings":";AAQO,IAAM,UAAU,MAAM;AAEtB,SAAS,SAAS,KAA6B;AACpD,SAAO,OAAO,QAAQ;AACxB;ACCO,IAAM,OAAO,SAAS;AAWtB,SAAS,WAAW,KAAK,cAAc;AAC5C,MAAI,CAAC,SAAS,GAAG,GAAG;AAClB,WAAO;EACT;AACA,SAAO,IAAI,QAAQ,YAAY,MAAM;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K,cAAYA,GAAE,cAAc,QAAQ,CAAC;AAGzE,OAAK,KAAK,OAAO,CAAC,IAAIA,GAAE,WAAW,SAAS;AAE5C,MAAI,aAAa;AACf,UAAM,WAAY,YAAY,SAAiB;AAC/C,QAAI,kBAAkB,WAAW,GAAG;AAClC,WAAK,KAAK,OAAO,CAAC,IAAIA,GAAE,WAAW,QAAQ;AAAA,IAC7C,OAAO;AACL,YAAM,0BAA0BA,GAAE,oBAAoB,SAAS;AAAA,QAC7DA,GAAE;AAAA,UACAA,GAAE,WAAW,QAAQ;AAAA,UACrBA,GAAE,eAAe,MAAM,aAAa;AAAA,YAClCA,GAAE,WAAW,SAAS;AAAA,YACtBA,GAAE,gBAAgB,aAAa,IAAI,UAAQA,GAAE,cAAc,IAAI,CAAC,CAAC;AAAA,UACnE,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AACD,cAAQ,IAAI,aAAa;AAEzB,MAAC,KAAK,KAAK,KAAa,KAAK,QAAQ,uBAAuB;AAAA,IAC9D;AAAA,EACF;AACF;;;AC7Ee,SAAR,cAA+B;AACpC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,kBAAkB,EAAE,SAAS,GAAG,YAAY;AAC1C,UAAI,SAAS,SAAS,KAAK,KAAK,SAAS,SAAS,MAAM,GAAG;AACzD,mBAAW,QAAQ,KAAK,YAAY;AAAA,MACtC;AACA,iBAAW,QAAQ,KAAK,KAAK;AAAA,IAC/B;AAAA,IACA,SAAS;AAAA,MACP,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,qBAAqB;AAAA,MACrB,yBAAyB;AAAA,MACzB,oBAAoB;AAAA,MACpB,mBAAmB;AAAA,MACnB,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,cAAc;AAAA,IAChB;AAAA,EACF;AACF;","names":["t","t","t","value","t","createEssorNode","t","createProps","getAttrProps","getChildren","replaceChild","handleAttributes","transformChildren","isValidChild","getNodeText","transformChild","value","t","t","t","t","imports","t","t","properties"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-essor",
3
- "version": "0.0.7-beta.5",
3
+ "version": "0.0.8",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -28,13 +28,13 @@
28
28
  },
29
29
  "sideEffects": false,
30
30
  "dependencies": {
31
- "@babel/core": "^7.24.7",
32
- "@babel/types": "^7.24.7",
33
- "essor-shared": "0.0.7-beta.5"
31
+ "@babel/core": "^7.25.2",
32
+ "@babel/types": "^7.25.2",
33
+ "essor-shared": "0.0.8"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/babel__core": "^7.20.5",
37
- "typescript": "^5.4.5"
37
+ "typescript": "^5.5.4"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "tsup",