babel-plugin-essor 0.0.12-beta.1 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -163,7 +163,7 @@ function setNodeText(path, text) {
163
163
  }
164
164
  function isSymbolStart(path, name) {
165
165
  const state = path.state;
166
- const { symbol } = state.opts;
166
+ const { symbol } = (state == null ? void 0 : state.opts) || "$";
167
167
  return startsWith(name, symbol);
168
168
  }
169
169
 
@@ -235,14 +235,11 @@ function transformJSX(path) {
235
235
  function createEssorNode(path, result) {
236
236
  var _a;
237
237
  const state = path.state;
238
- let tmpl;
239
- if (path.isJSXElement() && isComponent(getTagName(path.node))) {
240
- tmpl = import_core3.types.identifier(getTagName(path.node));
241
- } else {
242
- tmpl = path.scope.generateUidIdentifier("_tmpl$");
238
+ const isComponent2 = path.isJSXElement() && isComponent(getTagName(path.node));
239
+ const tmpl = isComponent2 ? import_core3.types.identifier(getTagName(path.node)) : path.scope.generateUidIdentifier("_tmpl$");
240
+ if (!isComponent2) {
243
241
  const template = isSsg ? import_core3.types.arrayExpression(result.template.map(import_core3.types.stringLiteral)) : import_core3.types.callExpression(state.template, [import_core3.types.stringLiteral(result.template)]);
244
- const declarator = import_core3.types.variableDeclarator(tmpl, template);
245
- state.tmplDeclaration.declarations.push(declarator);
242
+ state.tmplDeclaration.declarations.push(import_core3.types.variableDeclarator(tmpl, template));
246
243
  if (!isSsg) {
247
244
  imports.add("template");
248
245
  }
@@ -252,13 +249,9 @@ function createEssorNode(path, result) {
252
249
  if (key) {
253
250
  args.push(import_core3.types.identifier(`${key}`));
254
251
  }
255
- if (isSsg) {
256
- imports.add("ssg");
257
- return import_core3.types.callExpression(state.ssg, args);
258
- } else {
259
- imports.add("h");
260
- return import_core3.types.callExpression(state.h, args);
261
- }
252
+ const fnName = isSsg ? "ssg" : "h";
253
+ imports.add(fnName);
254
+ return import_core3.types.callExpression(state[fnName], args);
262
255
  }
263
256
  function createProps(props) {
264
257
  const toAstNode = (value) => {
@@ -382,54 +375,25 @@ function getNodeText(path) {
382
375
  function handleAttributes(props, result) {
383
376
  let klass = "";
384
377
  let style = "";
385
- for (const prop in props) {
386
- let value = props[prop];
378
+ for (const [prop, value] of Object.entries(props)) {
387
379
  if (prop === "class" && typeof value === "string") {
388
380
  klass += ` ${value}`;
389
381
  delete props[prop];
390
- continue;
391
- }
392
- if (prop === "style" && typeof value === "string") {
382
+ } else if (prop === "style" && typeof value === "string") {
393
383
  style += `${value}${value.at(-1) === ";" ? "" : ";"}`;
394
384
  delete props[prop];
395
- continue;
396
- }
397
- if (value === true) {
385
+ } else if (value === true) {
398
386
  addToTemplate(result, ` ${prop}`);
399
387
  delete props[prop];
400
- }
401
- if (value === false) {
388
+ } else if (value === false) {
402
389
  delete props[prop];
403
- }
404
- if (typeof value === "string" || typeof value === "number") {
390
+ } else if (typeof value === "string" || typeof value === "number") {
405
391
  addToTemplate(result, ` ${prop}="${value}"`);
406
392
  delete props[prop];
407
- }
408
- if (import_core3.types.isConditionalExpression(value)) {
409
- const { test, consequent, alternate } = value;
410
- value = import_core3.types.arrowFunctionExpression([], import_core3.types.conditionalExpression(test, consequent, alternate));
411
- props[prop] = value;
412
- }
413
- if (import_core3.types.isObjectExpression(value)) {
414
- let hasConditional = false;
415
- value.properties.forEach((property) => {
416
- if (import_core3.types.isObjectProperty(property) && import_core3.types.isConditionalExpression(property.value)) {
417
- hasConditional = true;
418
- }
419
- });
420
- if (hasConditional) {
421
- value = import_core3.types.arrowFunctionExpression([], value);
422
- props[prop] = value;
423
- } else {
424
- if (prop === "style") {
425
- value.properties.forEach((property) => {
426
- if (import_core3.types.isObjectProperty(property)) {
427
- style += `${property.key.name}:${property.value.value};`;
428
- }
429
- });
430
- delete props[prop];
431
- }
432
- }
393
+ } else if (import_core3.types.isConditionalExpression(value)) {
394
+ props[prop] = import_core3.types.arrowFunctionExpression([], value);
395
+ } else if (import_core3.types.isObjectExpression(value)) {
396
+ handleObjectExpression(prop, value, props, style);
433
397
  }
434
398
  }
435
399
  if (Object.keys(props).length > 0) {
@@ -444,6 +408,21 @@ function handleAttributes(props, result) {
444
408
  addToTemplate(result, ` style="${style}"`);
445
409
  }
446
410
  }
411
+ function handleObjectExpression(prop, value, props, style) {
412
+ const hasConditional = value.properties.some(
413
+ (property) => import_core3.types.isObjectProperty(property) && import_core3.types.isConditionalExpression(property.value)
414
+ );
415
+ if (hasConditional) {
416
+ props[prop] = import_core3.types.arrowFunctionExpression([], value);
417
+ } else if (prop === "style") {
418
+ value.properties.forEach((property) => {
419
+ if (import_core3.types.isObjectProperty(property)) {
420
+ style += `${property.key.name}:${property.value.value};`;
421
+ }
422
+ });
423
+ delete props[prop];
424
+ }
425
+ }
447
426
  function replaceChild(node, result) {
448
427
  var _a, _b, _c, _d, _e;
449
428
  if (result.isLastChild) {
@@ -543,62 +522,40 @@ function getAttrProps(path) {
543
522
  // src/signal/symbol.ts
544
523
  var import_core4 = require("@babel/core");
545
524
  function replaceSymbol(path) {
546
- const init = path.node.init;
547
- const variableName = path.node.id.name;
548
- if (import_core4.types.isObjectPattern(path.node.id) || import_core4.types.isArrayPattern(path.node.id)) {
549
- return;
550
- }
551
- if (!isSymbolStart(path, variableName)) {
552
- return;
553
- }
554
- if (init && (import_core4.types.isFunctionExpression(init) || import_core4.types.isArrowFunctionExpression(init)) && path.parent.kind === "const") {
555
- const newInit = import_core4.types.callExpression(import_core4.types.identifier(path.state.useComputed.name), init ? [init] : []);
556
- imports.add("useComputed");
557
- path.node.init = newInit;
558
- } else {
559
- const newInit = import_core4.types.callExpression(import_core4.types.identifier(path.state.useSignal.name), init ? [init] : []);
560
- imports.add("useSignal");
561
- path.node.init = newInit;
562
- }
525
+ const { init, id } = path.node;
526
+ const variableName = id.name;
527
+ if (import_core4.types.isObjectPattern(id) || import_core4.types.isArrayPattern(id) || !isSymbolStart(path, variableName)) return;
528
+ const isComputed = init && (import_core4.types.isFunctionExpression(init) || import_core4.types.isArrowFunctionExpression(init)) && path.parent.kind === "const";
529
+ const hookName = isComputed ? "useComputed" : "useSignal";
530
+ const newInit = import_core4.types.callExpression(import_core4.types.identifier(path.state[hookName].name), init ? [init] : []);
531
+ imports.add(hookName);
532
+ path.node.init = newInit;
563
533
  }
564
534
  function symbolIdentifier(path) {
565
535
  const parentPath = path.parentPath;
566
- if (!parentPath || import_core4.types.isVariableDeclarator(parentPath) || import_core4.types.isImportSpecifier(parentPath) || import_core4.types.isObjectProperty(parentPath) || import_core4.types.isArrayPattern(parentPath) || import_core4.types.isObjectPattern(parentPath)) {
567
- return;
568
- }
536
+ if (!shouldProcessIdentifier(parentPath)) return;
569
537
  const { node } = path;
570
- if (isSymbolStart(path, node.name)) {
571
- let currentPath = path;
572
- while (currentPath.parentPath && !currentPath.parentPath.isProgram()) {
573
- if (currentPath.parentPath.isMemberExpression() && currentPath.parentPath.node.property.name === "value") {
574
- return;
575
- }
576
- currentPath = currentPath.parentPath;
577
- }
578
- const newNode = import_core4.types.memberExpression(import_core4.types.identifier(node.name), import_core4.types.identifier("value"));
579
- path.replaceWith(newNode);
538
+ if (!isSymbolStart(path, node.name)) return;
539
+ if (!path.findParent((p) => p.isMemberExpression() && p.node.property.name === "value")) {
540
+ path.replaceWith(import_core4.types.memberExpression(import_core4.types.identifier(node.name), import_core4.types.identifier("value")));
580
541
  }
581
542
  }
543
+ function shouldProcessIdentifier(parentPath) {
544
+ return parentPath && !import_core4.types.isVariableDeclarator(parentPath) && !import_core4.types.isImportSpecifier(parentPath) && !import_core4.types.isObjectProperty(parentPath) && !import_core4.types.isArrayPattern(parentPath) && !import_core4.types.isObjectPattern(parentPath);
545
+ }
582
546
  function symbolObjectPattern(path) {
583
547
  path.node.properties.forEach((property) => {
584
548
  if (import_core4.types.isObjectProperty(property) && import_core4.types.isIdentifier(property.key) && isSymbolStart(path, property.key.name)) {
585
- const newKey = import_core4.types.identifier(property.key.name);
586
- property.key = newKey;
549
+ property.key = import_core4.types.identifier(property.key.name);
587
550
  }
588
551
  });
589
552
  }
590
553
  function symbolArrayPattern(path) {
591
554
  path.node.elements.forEach((element) => {
592
555
  if (import_core4.types.isIdentifier(element) && element.name.startsWith("$")) {
593
- const newElement = import_core4.types.identifier(element.name);
594
- element.name = newElement.name;
556
+ element.name = import_core4.types.identifier(element.name).name;
595
557
  } else if (import_core4.types.isObjectPattern(element)) {
596
- element.properties.forEach((property) => {
597
- if (import_core4.types.isObjectProperty(property) && import_core4.types.isIdentifier(property.key) && isSymbolStart(path, property.key.name)) {
598
- const newKey = import_core4.types.identifier(property.key.name);
599
- property.key = newKey;
600
- }
601
- });
558
+ symbolObjectPattern({ node: element });
602
559
  }
603
560
  });
604
561
  }
@@ -606,35 +563,29 @@ function symbolArrayPattern(path) {
606
563
  // src/signal/import.ts
607
564
  var import_core5 = require("@babel/core");
608
565
  function replaceImportDeclaration(path) {
609
- const imports2 = path.node.specifiers;
610
- imports2.forEach((specifier) => {
566
+ path.node.specifiers.forEach((specifier) => {
611
567
  const variableName = specifier.local.name;
612
568
  if (startsWith(variableName, "$") && !isVariableUsedAsObject(path, variableName)) {
613
569
  path.scope.rename(variableName, `${variableName}.value`);
614
- specifier.local.name = `${variableName}`;
570
+ specifier.local.name = variableName;
615
571
  }
616
572
  });
617
573
  }
618
574
  function isVariableUsedAsObject(path, variableName) {
575
+ var _a;
619
576
  const binding = path.scope.getBinding(variableName);
620
- let isUsedObject = false;
621
- if (!binding || !binding.referencePaths) {
622
- return isUsedObject;
623
- }
624
- for (const referencePath of binding.referencePaths) {
577
+ return ((_a = binding == null ? void 0 : binding.referencePaths) == null ? void 0 : _a.some((referencePath) => {
625
578
  if (import_core5.types.isMemberExpression(referencePath.parent)) {
626
- const memberExprParent = referencePath.parent;
627
- if (import_core5.types.isIdentifier(memberExprParent.object, { name: variableName })) {
628
- const newMemberExpr = import_core5.types.memberExpression(
629
- import_core5.types.memberExpression(memberExprParent.object, import_core5.types.identifier("value")),
630
- memberExprParent.property
579
+ const { object, property } = referencePath.parent;
580
+ if (import_core5.types.isIdentifier(object, { name: variableName })) {
581
+ referencePath.parentPath.replaceWith(
582
+ import_core5.types.memberExpression(import_core5.types.memberExpression(object, import_core5.types.identifier("value")), property)
631
583
  );
632
- referencePath.parentPath.replaceWith(newMemberExpr);
633
- isUsedObject = true;
584
+ return true;
634
585
  }
635
586
  }
636
- }
637
- return isUsedObject;
587
+ return false;
588
+ })) || false;
638
589
  }
639
590
 
640
591
  // src/signal/props.ts
@@ -643,65 +594,56 @@ function replaceProps(path) {
643
594
  var _a;
644
595
  const state = path.state;
645
596
  const firstParam = path.node.params[0];
646
- if (!firstParam || !import_core6.types.isObjectPattern(firstParam)) {
647
- return;
648
- }
597
+ if (!firstParam || !import_core6.types.isObjectPattern(firstParam)) return;
649
598
  const returnStatement = path.get("body").get("body").find((statement) => statement.isReturnStatement());
650
- if (!returnStatement) {
651
- return;
652
- }
653
- const returnValue = (_a = returnStatement.node) == null ? void 0 : _a.argument;
654
- if (!import_core6.types.isJSXElement(returnValue)) {
655
- return;
656
- }
657
- function replaceProperties(properties2, parentPath) {
599
+ if (!returnStatement || !import_core6.types.isJSXElement((_a = returnStatement.node) == null ? void 0 : _a.argument)) return;
600
+ const replaceProperties = (properties2, parentPath) => {
658
601
  properties2.forEach((property) => {
659
- if (import_core6.types.isObjectProperty(property)) {
602
+ if (import_core6.types.isObjectProperty(property) && import_core6.types.isIdentifier(property.key)) {
660
603
  const keyName = property.key.name;
661
604
  if (import_core6.types.isIdentifier(property.value)) {
662
- const propertyName = property.value.name;
663
- const newName = `${parentPath}${keyName}`;
664
- path.scope.rename(propertyName, newName);
605
+ path.scope.rename(property.value.name, `${parentPath}${keyName}`);
665
606
  } else if (import_core6.types.isObjectPattern(property.value)) {
666
607
  replaceProperties(property.value.properties, `${parentPath}${keyName}.`);
667
608
  }
668
609
  }
669
610
  });
670
- }
611
+ };
671
612
  const properties = firstParam.properties;
672
- replaceProperties(
673
- properties.filter((property) => !import_core6.types.isRestElement(property)),
674
- "__props."
675
- );
676
613
  const notRestProperties = properties.filter((property) => !import_core6.types.isRestElement(property));
677
- const notRestNames = notRestProperties.map(
678
- (property) => property.key.name
679
- );
614
+ replaceProperties(notRestProperties, "__props.");
615
+ const notRestNames = notRestProperties.map((property) => property.key.name);
680
616
  if (notRestNames.some((name) => startsWith(name, "$"))) {
681
617
  console.warn("props name can not start with $");
682
618
  return;
683
619
  }
620
+ handleRestElement(path, state, properties, notRestNames);
621
+ }
622
+ function handleRestElement(path, state, properties, notRestNames) {
684
623
  const restElement = properties.find((property) => import_core6.types.isRestElement(property));
685
624
  path.node.params[0] = import_core6.types.identifier("__props");
686
625
  if (restElement) {
687
626
  const restName = restElement.argument.name;
688
- if (notRestProperties.length === 0) {
627
+ if (notRestNames.length === 0) {
689
628
  path.node.params[0] = import_core6.types.identifier(restName);
690
629
  } else {
691
- const restVariableDeclaration = import_core6.types.variableDeclaration("const", [
692
- import_core6.types.variableDeclarator(
693
- import_core6.types.identifier(restName),
694
- import_core6.types.callExpression(state.useReactive, [
695
- import_core6.types.identifier("__props"),
696
- import_core6.types.arrayExpression(notRestNames.map((name) => import_core6.types.stringLiteral(name)))
697
- ])
698
- )
699
- ]);
630
+ const restVariableDeclaration = createRestVariableDeclaration(state, restName, notRestNames);
700
631
  imports.add("useReactive");
701
632
  path.node.body.body.unshift(restVariableDeclaration);
702
633
  }
703
634
  }
704
635
  }
636
+ function createRestVariableDeclaration(state, restName, notRestNames) {
637
+ return import_core6.types.variableDeclaration("const", [
638
+ import_core6.types.variableDeclarator(
639
+ import_core6.types.identifier(restName),
640
+ import_core6.types.callExpression(state.useReactive, [
641
+ import_core6.types.identifier("__props"),
642
+ import_core6.types.arrayExpression(notRestNames.map((name) => import_core6.types.stringLiteral(name)))
643
+ ])
644
+ )
645
+ ]);
646
+ }
705
647
 
706
648
  // src/index.ts
707
649
  function src_default() {
@@ -728,7 +670,7 @@ function src_default() {
728
670
  };
729
671
  }
730
672
  /**
731
- * @estjs/shared v0.0.12-beta.1
673
+ * @estjs/shared v0.0.12
732
674
  * (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
733
675
  * @license MIT
734
676
  **/
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/jsx/index.ts","../../shared/src/is.ts","../../shared/src/comm.ts","../../shared/src/name.ts","../../shared/src/console.ts","../src/program.ts","../src/shared.ts","../src/jsx/constants.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\n FunctionDeclaration: replaceProps,\n ArrowFunctionExpression: replaceProps,\n VariableDeclarator: replaceSymbol,\n ImportDeclaration: replaceImportDeclaration,\n Identifier: symbolIdentifier,\n ObjectPattern: symbolObjectPattern,\n ArrayPattern: symbolArrayPattern,\n\n JSXElement: transformJSX,\n JSXFragment: transformJSX,\n },\n };\n}\n","import { types as t } from '@babel/core';\nimport { capitalizeFirstLetter } from '@estjs/shared';\nimport { imports } from '../program';\nimport {\n type JSXChild,\n type JSXElement,\n getAttrName,\n getTagName,\n hasSiblingElement,\n isComponent,\n isTextChild,\n setNodeText,\n} from '../shared';\nimport { selfClosingTags, svgTags } from './constants';\nimport type { Identifier, OptionalMemberExpression, StringLiteral } 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 | string[];\n}\nlet isSsg = false;\n\nfunction addToTemplate(result: Result, content: string, join = false): void {\n if (isSsg) {\n if (join && result.template.length > 0) {\n (result.template as string[])[result.template.length - 1] += content;\n } else {\n (result.template as string[]).push(content);\n }\n } else {\n result.template += content;\n }\n}\nexport function transformJSX(path: NodePath<JSXElement>): void {\n const state: State = path.state;\n isSsg = state.opts.ssg;\n\n const result: Result = {\n index: 1,\n isLastChild: false,\n parentIndex: 0,\n props: {},\n template: isSsg ? [] : '',\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\n const template = isSsg\n ? t.arrayExpression((result.template as string[]).map(t.stringLiteral))\n : t.callExpression(state.template, [t.stringLiteral(result.template as string)]);\n const declarator = t.variableDeclarator(tmpl, template);\n state.tmplDeclaration.declarations.push(declarator);\n if (!isSsg) {\n imports.add('template');\n }\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(t.identifier(`${key}`));\n }\n if (isSsg) {\n imports.add('ssg');\n return t.callExpression(state.ssg, args);\n } else {\n imports.add('h');\n return t.callExpression(state.h, args);\n }\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, 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 transformJSX(path);\n replaceChild(path.node, result);\n }\n } else {\n if (isSvg) {\n result.template = isSsg ? ['<svg _svg_>'] : '<svg _svg_>';\n }\n\n addToTemplate(result, `<${tagName}`, true);\n handleAttributes(props, result);\n\n addToTemplate(result, isSelfClose ? '/>' : '>', !hasExpression);\n\n if (!isSelfClose) {\n transformChildren(path, result);\n if (hasSiblingElement(path) || isSsg) {\n addToTemplate(result, `</${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 = isSsg ? result.template.length : 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 addToTemplate(result, 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 addToTemplate(result, 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 addToTemplate(result, ` ${prop}`);\n delete props[prop];\n }\n if (value === false) {\n delete props[prop];\n }\n if (typeof value === 'string' || typeof value === 'number') {\n addToTemplate(result, ` ${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 props[prop] = value;\n } else {\n // TODO: For the time being, only support style\n if (prop === 'style') {\n value.properties.forEach(property => {\n if (t.isObjectProperty(property)) {\n style += `${(property.key as Identifier).name}:${(property.value as StringLiteral).value};`;\n }\n });\n\n delete props[prop];\n }\n }\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 addToTemplate(result, ` class=\"${klass}\"`);\n }\n if (style) {\n addToTemplate(result, ` style=\"${style}\"`);\n }\n}\n\nfunction replaceChild(node: t.Expression, result: Result): void {\n if (result.isLastChild) {\n result.index--;\n } else {\n addToTemplate(result, '<!>');\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 transformJSX(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}\n\nexport function 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 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 transformJSX(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[bindName] = t.memberExpression(\n // t.identifier((expression.node as Identifier).name),\n // t.identifier('value'),\n // );\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 transformJSX(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 { _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}\n\nexport function isSet(val: any): val is Set<any> {\n return _toString.call(val) === '[object Set]';\n}\nexport function isWeakMap(val: any): val is WeakMap<any, any> {\n return _toString.call(val) === '[object WeakMap]';\n}\nexport function isWeakSet(val: any): val is WeakSet<any> {\n return _toString.call(val) === '[object WeakSet]';\n}\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;\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 function isHTMLElement(obj) {\n if (!obj) return false;\n return obj && typeof obj === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string';\n}\n","import { isFunction, 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 * 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\n/**\n * Generates a unique random 8 character string ID.\n * The generated IDs only contain alphanumeric characters.\n * @returns A unique random 8 character string ID.\n */\nexport function generateUniqueId() {\n const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n let result = '';\n const charactersLength = characters.length;\n for (let i = 0; i < 8; i++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n return result;\n}\n\n/**\n * Checks if the current environment is a browser.\n * @returns True if the current environment is a browser, otherwise false.\n */\nexport function isBrowser() {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\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","export function warn(msg: string, ..._args: any[]): void;\nexport function warn(msg: string, ...args): void {\n // eslint-disable-next-line prefer-spread\n console.warn.apply(console, [`[Essor warn]: ${msg}`].concat(args) as [string, ...any[]]);\n}\n\nexport function info(msg: string, ..._args: any[]): void;\nexport function info(msg: string, ...args): void {\n // eslint-disable-next-line prefer-spread, no-console\n console.info.apply(console, [`[Essor info]: ${msg}`].concat(args) as [string, ...any[]]);\n}\n\nexport function error(msg: string, ..._args: any[]): void;\nexport function error(msg: string, ...args): void {\n // eslint-disable-next-line prefer-spread\n console.error.apply(console, [`[Essor error]: ${msg}`].concat(args) as [string, ...any[]]);\n}\n","import { type NodePath, types as t } from '@babel/core';\nimport type { Options, State } from './types';\nexport const imports = new Set<string>();\n\nconst defaultOption: Options = {\n ssg: false,\n symbol: '$',\n props: true,\n};\n\nexport const transformProgram = {\n enter(path: NodePath<t.Program>, state) {\n imports.clear();\n\n // merge options\n state.opts = { ...defaultOption, ...state.opts };\n\n path.state = {\n h: path.scope.generateUidIdentifier('h$'),\n template: path.scope.generateUidIdentifier('template$'),\n ssg: path.scope.generateUidIdentifier('ssg$'),\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","import { type NodePath, types as t } from '@babel/core';\nimport { startsWith } from '@estjs/shared';\nimport type { State } from './types';\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 or JSXExpressionContainer\n const hasSibling = siblings.some(\n siblingPath => siblingPath.isJSXElement() || siblingPath.isJSXExpressionContainer(),\n );\n\n return hasSibling;\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-z]/i.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\n/**\n * get the symbol start with\n */\nexport function isSymbolStart(path: NodePath<any>, name: string) {\n const state: State = path.state;\n const { symbol } = state.opts;\n\n return startsWith(name, symbol);\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 { types as t } from '@babel/core';\nimport { imports } from '../program';\nimport { isSymbolStart } from '../shared';\nimport type { Identifier, VariableDeclarator } from '@babel/types';\nimport type { NodePath } from '@babel/core';\n\n/**\n * Replaces the symbol in a variable declarator with a computed or signal expression.\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 * @param {NodePath<VariableDeclarator>} path - The path to the variable declarator node.\n * @return {void}\n */\nexport function replaceSymbol(path: NodePath<VariableDeclarator>) {\n const init = path.node.init;\n\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 (!isSymbolStart(path, 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 (isSymbolStart(path, node.name)) {\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 isSymbolStart(path, property.key.name)\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 isSymbolStart(path, property.key.name)\n ) {\n const newKey = t.identifier(property.key.name);\n property.key = newKey;\n }\n });\n }\n });\n}\n","import { types as t } from '@babel/core';\nimport { startsWith } from '@estjs/shared';\n\n/**\n * Replaces import declarations\n *\n * case1: import { $a } from 'a';console.log(a) => import { $a } from 'a';console.log($a.value)\n * case2: import $a from 'a';console.log(a) => import $a from 'a';console.log($a.value)\n *\n * @param {object} path - The path to replace import declarations.\n * @return {void}\n */\nexport function replaceImportDeclaration(path) {\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}\nfunction isVariableUsedAsObject(path, variableName) {\n const binding = path.scope.getBinding(variableName);\n let isUsedObject = false;\n\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 (t.isIdentifier(memberExprParent.object, { name: variableName })) {\n const newMemberExpr = t.memberExpression(\n t.memberExpression(memberExprParent.object, t.identifier('value')),\n memberExprParent.property,\n );\n referencePath.parentPath.replaceWith(newMemberExpr);\n isUsedObject = true;\n }\n }\n }\n\n return isUsedObject;\n}\n","import { startsWith } from '@estjs/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\n/**\n * Replaces the properties of a function's first parameter with new names.\n *\n * auto replace pattern to props object\n *\n * rule1: function argument\n * rule2: first argument is object and it pattern\n * rule3: function has return\n *\n * transform case\n * case1 ({a, b}) => <div>{a.value}</div> to=> (_props)=><div>{_props.a.value}</div>\n * case2 ({a, b, ...rest}) => <div>{a.value}{rest}</div> to=> (_props)=> {const restProps = reactive(props,[a,b]);return <div>{_props.a.value}{reset}</div>}\n *\n * not transform case\n * case1 ([a,b])=> <div>{a.value}</div>\n * case2 ({a.,b}) ={}\n *\n * @param {NodePath<FunctionDeclaration | ArrowFunctionExpression>} path - The path to the function node.\n * @return {void}\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;;;ACAA,IAAAA,eAA2B;;;ACQpB,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;;;AElBA,kBAA0C;AAEnC,IAAM,UAAU,oBAAI,IAAY;AAEvC,IAAM,gBAAyB;AAAA,EAC7B,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO;AACT;AAEO,IAAM,mBAAmB;AAAA,EAC9B,MAAM,MAA2B,OAAO;AACtC,YAAQ,MAAM;AAGd,UAAM,OAAO,kCAAK,gBAAkB,MAAM;AAE1C,SAAK,QAAQ;AAAA,MACX,GAAG,KAAK,MAAM,sBAAsB,IAAI;AAAA,MACxC,UAAU,KAAK,MAAM,sBAAsB,WAAW;A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AA+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,MAET,qBAAqB;AAAA,MACrB,yBAAyB;AAAA,MACzB,oBAAoB;AAAA,MACpB,mBAAmB;AAAA,MACnB,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,cAAc;AAAA,MAEd,YAAY;AAAA,MACZ,aAAa;AAAA,IACf;AAAA,EACF;AACF;","names":["import_core","t","import_core","t","t","value","import_core","t","import_core","imports","t","import_core","t","properties"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/jsx/index.ts","../../shared/src/is.ts","../../shared/src/comm.ts","../../shared/src/name.ts","../../shared/src/console.ts","../src/program.ts","../src/shared.ts","../src/jsx/constants.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\n FunctionDeclaration: replaceProps,\n ArrowFunctionExpression: replaceProps,\n VariableDeclarator: replaceSymbol,\n ImportDeclaration: replaceImportDeclaration,\n Identifier: symbolIdentifier,\n ObjectPattern: symbolObjectPattern,\n ArrayPattern: symbolArrayPattern,\n\n JSXElement: transformJSX,\n JSXFragment: transformJSX,\n },\n };\n}\n","import { types as t } from '@babel/core';\nimport { capitalizeFirstLetter } from '@estjs/shared';\nimport { imports } from '../program';\nimport {\n type JSXChild,\n type JSXElement,\n getAttrName,\n getTagName,\n hasSiblingElement,\n isComponent as isComponentName,\n isTextChild,\n setNodeText,\n} from '../shared';\nimport { selfClosingTags, svgTags } from './constants';\nimport type { Identifier, OptionalMemberExpression, StringLiteral } 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 | string[];\n}\nlet isSsg = false;\n\nfunction addToTemplate(result: Result, content: string, join = false): void {\n if (isSsg) {\n if (join && result.template.length > 0) {\n (result.template as string[])[result.template.length - 1] += content;\n } else {\n (result.template as string[]).push(content);\n }\n } else {\n result.template += content;\n }\n}\nexport function transformJSX(path: NodePath<JSXElement>): void {\n const state: State = path.state;\n isSsg = state.opts.ssg;\n\n const result: Result = {\n index: 1,\n isLastChild: false,\n parentIndex: 0,\n props: {},\n template: isSsg ? [] : '',\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 const isComponent = path.isJSXElement() && isComponentName(getTagName(path.node));\n\n const tmpl = isComponent\n ? t.identifier(getTagName(path.node))\n : path.scope.generateUidIdentifier('_tmpl$');\n\n if (!isComponent) {\n const template = isSsg\n ? t.arrayExpression((result.template as string[]).map(t.stringLiteral))\n : t.callExpression(state.template, [t.stringLiteral(result.template as string)]);\n state.tmplDeclaration.declarations.push(t.variableDeclarator(tmpl, template));\n if (!isSsg) {\n imports.add('template');\n }\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(t.identifier(`${key}`));\n }\n\n const fnName = isSsg ? 'ssg' : 'h';\n imports.add(fnName);\n return t.callExpression(state[fnName], 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 = isComponentName(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 transformJSX(path);\n replaceChild(path.node, result);\n }\n } else {\n if (isSvg) {\n result.template = isSsg ? ['<svg _svg_>'] : '<svg _svg_>';\n }\n\n addToTemplate(result, `<${tagName}`, true);\n handleAttributes(props, result);\n\n addToTemplate(result, isSelfClose ? '/>' : '>', !hasExpression);\n\n if (!isSelfClose) {\n transformChildren(path, result);\n if (hasSiblingElement(path) || isSsg) {\n addToTemplate(result, `</${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 = isSsg ? result.template.length : 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 addToTemplate(result, 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 // just for tracking value\n } else {\n throw new Error('Unsupported child type');\n }\n } else if (child.isJSXText()) {\n addToTemplate(result, 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, value] of Object.entries(props)) {\n if (prop === 'class' && typeof value === 'string') {\n klass += ` ${value}`;\n delete props[prop];\n } else if (prop === 'style' && typeof value === 'string') {\n style += `${value}${value.at(-1) === ';' ? '' : ';'}`;\n delete props[prop];\n } else if (value === true) {\n addToTemplate(result, ` ${prop}`);\n delete props[prop];\n } else if (value === false) {\n delete props[prop];\n } else if (typeof value === 'string' || typeof value === 'number') {\n addToTemplate(result, ` ${prop}=\"${value}\"`);\n delete props[prop];\n } else if (t.isConditionalExpression(value)) {\n props[prop] = t.arrowFunctionExpression([], value);\n } else if (t.isObjectExpression(value)) {\n handleObjectExpression(prop, value, props, style);\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 addToTemplate(result, ` class=\"${klass}\"`);\n }\n if (style) {\n addToTemplate(result, ` style=\"${style}\"`);\n }\n}\n\nfunction handleObjectExpression(\n prop: string,\n value: t.ObjectExpression,\n props: Record<string, any>,\n // eslint-disable-next-line unused-imports/no-unused-vars\n style: string,\n): void {\n const hasConditional = value.properties.some(\n property => t.isObjectProperty(property) && t.isConditionalExpression(property.value),\n );\n\n if (hasConditional) {\n props[prop] = t.arrowFunctionExpression([], value);\n } else if (prop === 'style') {\n value.properties.forEach(property => {\n if (t.isObjectProperty(property)) {\n style += `${(property.key as Identifier).name}:${(property.value as StringLiteral).value};`;\n }\n });\n delete props[prop];\n }\n}\n\nfunction replaceChild(node: t.Expression, result: Result): void {\n if (result.isLastChild) {\n result.index--;\n } else {\n addToTemplate(result, '<!>');\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 transformJSX(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}\n\nexport function 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 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 transformJSX(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[bindName] = t.memberExpression(\n // t.identifier((expression.node as Identifier).name),\n // t.identifier('value'),\n // );\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 transformJSX(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 { _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): val is Promise<any> {\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}\n\nexport function isSet(val: any): val is Set<any> {\n return _toString.call(val) === '[object Set]';\n}\nexport function isWeakMap(val: any): val is WeakMap<any, any> {\n return _toString.call(val) === '[object WeakMap]';\n}\nexport function isWeakSet(val: any): val is WeakSet<any> {\n return _toString.call(val) === '[object WeakSet]';\n}\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;\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 function isHTMLElement(obj) {\n if (!obj) return false;\n return obj && typeof obj === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string';\n}\n\nexport const isPlainObject = (val: unknown): val is object =>\n _toString.call(val) === '[object Object]';\n\nexport type StringNumber = `${number}`;\nexport function isStringNumber(val: unknown): val is StringNumber {\n if (!isString(val)) {\n return false;\n }\n return !Number.isNaN(Number(val));\n}\n","import { isFunction, 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 * 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\n/**\n * Generates a unique random 8 character string ID.\n * The generated IDs only contain alphanumeric characters.\n * @returns A unique random 8 character string ID.\n */\nexport function generateUniqueId() {\n const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n let result = '';\n const charactersLength = characters.length;\n for (let i = 0; i < 8; i++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n return result;\n}\n\n/**\n * Checks if the current environment is a browser.\n * @returns True if the current environment is a browser, otherwise false.\n */\nexport function isBrowser() {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\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","export function warn(msg: string, ..._args: any[]): void;\nexport function warn(msg: string, ...args): void {\n // eslint-disable-next-line prefer-spread\n console.warn.apply(console, [`[Essor warn]: ${msg}`].concat(args) as [string, ...any[]]);\n}\n\nexport function info(msg: string, ..._args: any[]): void;\nexport function info(msg: string, ...args): void {\n // eslint-disable-next-line prefer-spread, no-console\n console.info.apply(console, [`[Essor info]: ${msg}`].concat(args) as [string, ...any[]]);\n}\n\nexport function error(msg: string, ..._args: any[]): void;\nexport function error(msg: string, ...args): void {\n // eslint-disable-next-line prefer-spread\n console.error.apply(console, [`[Essor error]: ${msg}`].concat(args) as [string, ...any[]]);\n}\n","import { type NodePath, types as t } from '@babel/core';\nimport type { Options, State } from './types';\nexport const imports = new Set<string>();\n\nconst defaultOption: Options = {\n ssg: false,\n symbol: '$',\n props: true,\n};\n\nexport const transformProgram = {\n enter(path: NodePath<t.Program>, state) {\n imports.clear();\n\n // merge options\n state.opts = { ...defaultOption, ...state.opts };\n\n path.state = {\n h: path.scope.generateUidIdentifier('h$'),\n template: path.scope.generateUidIdentifier('template$'),\n ssg: path.scope.generateUidIdentifier('ssg$'),\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","import { type NodePath, types as t } from '@babel/core';\nimport { startsWith } from '@estjs/shared';\nimport type { State } from './types';\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 or JSXExpressionContainer\n const hasSibling = siblings.some(\n siblingPath => siblingPath.isJSXElement() || siblingPath.isJSXExpressionContainer(),\n );\n\n return hasSibling;\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-z]/i.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\n/**\n * get the symbol start with\n */\nexport function isSymbolStart(path: NodePath<any>, name: string) {\n const state: State = path.state;\n const { symbol } = state?.opts || '$';\n\n return startsWith(name, symbol);\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 { types as t } from '@babel/core';\nimport { imports } from '../program';\nimport { isSymbolStart } from '../shared';\nimport type { Identifier, VariableDeclarator } from '@babel/types';\nimport type { NodePath } from '@babel/core';\n\n/**\n * Replaces the symbol in a variable declarator with a computed or signal expression.\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 * @param {NodePath<VariableDeclarator>} path - The path to the variable declarator node.\n * @return {void}\n */\nexport function replaceSymbol(path: NodePath<VariableDeclarator>) {\n const { init, id } = path.node;\n const variableName = (id as Identifier).name;\n\n if (t.isObjectPattern(id) || t.isArrayPattern(id) || !isSymbolStart(path, variableName)) return;\n\n const isComputed =\n init &&\n (t.isFunctionExpression(init) || t.isArrowFunctionExpression(init)) &&\n (path.parent as t.VariableDeclaration).kind === 'const';\n\n const hookName = isComputed ? 'useComputed' : 'useSignal';\n const newInit = t.callExpression(t.identifier(path.state[hookName].name), init ? [init] : []);\n\n imports.add(hookName);\n path.node.init = newInit;\n}\n\nexport function symbolIdentifier(path) {\n const parentPath = path.parentPath;\n if (!shouldProcessIdentifier(parentPath)) return;\n\n const { node } = path;\n if (!isSymbolStart(path, node.name)) return;\n\n if (!path.findParent(p => p.isMemberExpression() && p.node.property.name === 'value')) {\n path.replaceWith(t.memberExpression(t.identifier(node.name), t.identifier('value')));\n }\n}\n\nfunction shouldProcessIdentifier(parentPath) {\n return (\n parentPath &&\n !t.isVariableDeclarator(parentPath) &&\n !t.isImportSpecifier(parentPath) &&\n !t.isObjectProperty(parentPath) &&\n !t.isArrayPattern(parentPath) &&\n !t.isObjectPattern(parentPath)\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 isSymbolStart(path, property.key.name)\n ) {\n property.key = t.identifier(property.key.name);\n }\n });\n}\n\nexport function symbolArrayPattern(path) {\n path.node.elements.forEach(element => {\n if (t.isIdentifier(element) && element.name.startsWith('$')) {\n element.name = t.identifier(element.name).name;\n } else if (t.isObjectPattern(element)) {\n symbolObjectPattern({ node: element } as NodePath);\n }\n });\n}\n","import { types as t } from '@babel/core';\nimport { startsWith } from '@estjs/shared';\n\n/**\n * Replaces import declarations\n *\n * case1: import { $a } from 'a';console.log(a) => import { $a } from 'a';console.log($a.value)\n * case2: import $a from 'a';console.log(a) => import $a from 'a';console.log($a.value)\n *\n * @param {object} path - The path to replace import declarations.\n * @return {void}\n */\nexport function replaceImportDeclaration(path) {\n path.node.specifiers.forEach(specifier => {\n const variableName = specifier.local.name;\n if (startsWith(variableName, '$') && !isVariableUsedAsObject(path, variableName)) {\n path.scope.rename(variableName, `${variableName}.value`);\n specifier.local.name = variableName;\n }\n });\n}\n\n/**\n * Checks if a variable is used as an object.\n *\n * @param path - The path to the variable.\n * @param variableName - The name of the variable.\n * @returns {boolean} - Whether the variable is used as an object.\n */\nfunction isVariableUsedAsObject(path, variableName) {\n const binding = path.scope.getBinding(variableName);\n return (\n binding?.referencePaths?.some(referencePath => {\n if (t.isMemberExpression(referencePath.parent)) {\n const { object, property } = referencePath.parent;\n if (t.isIdentifier(object, { name: variableName })) {\n referencePath.parentPath.replaceWith(\n t.memberExpression(t.memberExpression(object, t.identifier('value')), property),\n );\n return true;\n }\n }\n return false;\n }) || false\n );\n}\n","import { startsWith } from '@estjs/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\n/**\n * Replaces the properties of a function's first parameter with new names.\n *\n * auto replace pattern to props object\n *\n * rule1: function argument\n * rule2: first argument is object and it pattern\n * rule3: function has return\n *\n * transform case\n * case1 ({a, b}) => <div>{a.value}</div> to=> (_props)=><div>{_props.a.value}</div>\n * case2 ({a, b, ...rest}) => <div>{a.value}{rest}</div> to=> (_props)=> {const restProps = reactive(props,[a,b]);return <div>{_props.a.value}{reset}</div>}\n *\n * not transform case\n * case1 ([a,b])=> <div>{a.value}</div>\n * case2 ({a.,b}) ={}\n *\n * @param {NodePath<FunctionDeclaration | ArrowFunctionExpression>} path - The path to the function node.\n * @return {void}\n */\nexport function replaceProps(path: NodePath<FunctionDeclaration | ArrowFunctionExpression>) {\n const state: State = path.state;\n const firstParam = path.node.params[0];\n\n if (!firstParam || !t.isObjectPattern(firstParam)) return;\n\n const returnStatement = path\n .get('body')\n .get('body')\n .find(statement => statement.isReturnStatement());\n\n if (!returnStatement || !t.isJSXElement((returnStatement.node as any)?.argument)) return;\n\n const replaceProperties = (properties: (ObjectProperty | RestElement)[], parentPath: string) => {\n properties.forEach(property => {\n if (t.isObjectProperty(property) && t.isIdentifier(property.key)) {\n const keyName = property.key.name;\n if (t.isIdentifier(property.value)) {\n path.scope.rename(property.value.name, `${parentPath}${keyName}`);\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 const notRestProperties = properties.filter(property => !t.isRestElement(property)) as ObjectProperty[];\n replaceProperties(notRestProperties, '__props.');\n\n const notRestNames = notRestProperties.map(property => (property.key as Identifier).name);\n if (__DEV__ && notRestNames.some(name => startsWith(name, '$'))) {\n console.warn('props name can not start with $');\n return;\n }\n\n handleRestElement(path, state, properties, notRestNames);\n}\n\nfunction handleRestElement(path, state: State, properties, notRestNames) {\n const restElement = properties.find(property => t.isRestElement(property)) as RestElement | undefined;\n path.node.params[0] = t.identifier('__props');\n\n if (restElement) {\n const restName = (restElement.argument as Identifier).name;\n if (notRestNames.length === 0) {\n path.node.params[0] = t.identifier(restName);\n } else {\n const restVariableDeclaration = createRestVariableDeclaration(state, restName, notRestNames);\n imports.add('useReactive');\n (path.node.body as t.BlockStatement).body.unshift(restVariableDeclaration);\n }\n }\n}\n\nfunction createRestVariableDeclaration(state: State, restName: string, notRestNames: string[]) {\n return 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}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAA2B;;;ACQpB,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;;;AElBA,kBAA0C;AAEnC,IAAM,UAAU,oBAAI,IAAY;AAEvC,IAAM,gBAAyB;AAAA,EAC7B,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO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,CAAC,IAAI,aAAAA,MAAE,WAAW,QAAQ;AAAA,IAC7C,OAAO;AACL,YAAM,0BAA0B,8BAA8B,OAAO,UAAU,YAAY;AAC3F,cAAQ,IAAI,aAAa;AACzB,MAAC,KAAK,KAAK,KAA0B,KAAK,QAAQ,uBAAuB;AAAA,IAC3E;AAAA,EACF;AACF;AAEA,SAAS,8BAA8B,OAAc,UAAkB,cAAwB;AAC7F,SAAO,aAAAA,MAAE,oBAAoB,SAAS;AAAA,IACpC,aAAAA,MAAE;AAAA,MACA,aAAAA,MAAE,WAAW,QAAQ;AAAA,MACrB,aAAAA,MAAE,eAAe,MAAM,aAAa;AAAA,QAClC,aAAAA,MAAE,WAAW,SAAS;AAAA,QACtB,aAAAA,MAAE,gBAAgB,aAAa,IAAI,UAAQ,aAAAA,MAAE,cAAc,IAAI,CAAC,CAAC;AAAA,MACnE,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;;;AXrFe,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,MAET,qBAAqB;AAAA,MACrB,yBAAyB;AAAA,MACzB,oBAAoB;AAAA,MACpB,mBAAmB;AAAA,MACnB,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,cAAc;AAAA,MAEd,YAAY;AAAA,MACZ,aAAa;AAAA,IACf;AAAA,EACF;AACF;","names":["import_core","t","import_core","t","isComponent","t","value","import_core","t","import_core","t","import_core","t","properties"]}
package/dist/index.js CHANGED
@@ -140,7 +140,7 @@ function setNodeText(path, text) {
140
140
  }
141
141
  function isSymbolStart(path, name) {
142
142
  const state = path.state;
143
- const { symbol } = state.opts;
143
+ const { symbol } = (state == null ? void 0 : state.opts) || "$";
144
144
  return startsWith(name, symbol);
145
145
  }
146
146
 
@@ -212,14 +212,11 @@ function transformJSX(path) {
212
212
  function createEssorNode(path, result) {
213
213
  var _a;
214
214
  const state = path.state;
215
- let tmpl;
216
- if (path.isJSXElement() && isComponent(getTagName(path.node))) {
217
- tmpl = t3.identifier(getTagName(path.node));
218
- } else {
219
- tmpl = path.scope.generateUidIdentifier("_tmpl$");
215
+ const isComponent2 = path.isJSXElement() && isComponent(getTagName(path.node));
216
+ const tmpl = isComponent2 ? t3.identifier(getTagName(path.node)) : path.scope.generateUidIdentifier("_tmpl$");
217
+ if (!isComponent2) {
220
218
  const template = isSsg ? t3.arrayExpression(result.template.map(t3.stringLiteral)) : t3.callExpression(state.template, [t3.stringLiteral(result.template)]);
221
- const declarator = t3.variableDeclarator(tmpl, template);
222
- state.tmplDeclaration.declarations.push(declarator);
219
+ state.tmplDeclaration.declarations.push(t3.variableDeclarator(tmpl, template));
223
220
  if (!isSsg) {
224
221
  imports.add("template");
225
222
  }
@@ -229,13 +226,9 @@ function createEssorNode(path, result) {
229
226
  if (key) {
230
227
  args.push(t3.identifier(`${key}`));
231
228
  }
232
- if (isSsg) {
233
- imports.add("ssg");
234
- return t3.callExpression(state.ssg, args);
235
- } else {
236
- imports.add("h");
237
- return t3.callExpression(state.h, args);
238
- }
229
+ const fnName = isSsg ? "ssg" : "h";
230
+ imports.add(fnName);
231
+ return t3.callExpression(state[fnName], args);
239
232
  }
240
233
  function createProps(props) {
241
234
  const toAstNode = (value) => {
@@ -359,54 +352,25 @@ function getNodeText(path) {
359
352
  function handleAttributes(props, result) {
360
353
  let klass = "";
361
354
  let style = "";
362
- for (const prop in props) {
363
- let value = props[prop];
355
+ for (const [prop, value] of Object.entries(props)) {
364
356
  if (prop === "class" && typeof value === "string") {
365
357
  klass += ` ${value}`;
366
358
  delete props[prop];
367
- continue;
368
- }
369
- if (prop === "style" && typeof value === "string") {
359
+ } else if (prop === "style" && typeof value === "string") {
370
360
  style += `${value}${value.at(-1) === ";" ? "" : ";"}`;
371
361
  delete props[prop];
372
- continue;
373
- }
374
- if (value === true) {
362
+ } else if (value === true) {
375
363
  addToTemplate(result, ` ${prop}`);
376
364
  delete props[prop];
377
- }
378
- if (value === false) {
365
+ } else if (value === false) {
379
366
  delete props[prop];
380
- }
381
- if (typeof value === "string" || typeof value === "number") {
367
+ } else if (typeof value === "string" || typeof value === "number") {
382
368
  addToTemplate(result, ` ${prop}="${value}"`);
383
369
  delete props[prop];
384
- }
385
- if (t3.isConditionalExpression(value)) {
386
- const { test, consequent, alternate } = value;
387
- value = t3.arrowFunctionExpression([], t3.conditionalExpression(test, consequent, alternate));
388
- props[prop] = value;
389
- }
390
- if (t3.isObjectExpression(value)) {
391
- let hasConditional = false;
392
- value.properties.forEach((property) => {
393
- if (t3.isObjectProperty(property) && t3.isConditionalExpression(property.value)) {
394
- hasConditional = true;
395
- }
396
- });
397
- if (hasConditional) {
398
- value = t3.arrowFunctionExpression([], value);
399
- props[prop] = value;
400
- } else {
401
- if (prop === "style") {
402
- value.properties.forEach((property) => {
403
- if (t3.isObjectProperty(property)) {
404
- style += `${property.key.name}:${property.value.value};`;
405
- }
406
- });
407
- delete props[prop];
408
- }
409
- }
370
+ } else if (t3.isConditionalExpression(value)) {
371
+ props[prop] = t3.arrowFunctionExpression([], value);
372
+ } else if (t3.isObjectExpression(value)) {
373
+ handleObjectExpression(prop, value, props, style);
410
374
  }
411
375
  }
412
376
  if (Object.keys(props).length > 0) {
@@ -421,6 +385,21 @@ function handleAttributes(props, result) {
421
385
  addToTemplate(result, ` style="${style}"`);
422
386
  }
423
387
  }
388
+ function handleObjectExpression(prop, value, props, style) {
389
+ const hasConditional = value.properties.some(
390
+ (property) => t3.isObjectProperty(property) && t3.isConditionalExpression(property.value)
391
+ );
392
+ if (hasConditional) {
393
+ props[prop] = t3.arrowFunctionExpression([], value);
394
+ } else if (prop === "style") {
395
+ value.properties.forEach((property) => {
396
+ if (t3.isObjectProperty(property)) {
397
+ style += `${property.key.name}:${property.value.value};`;
398
+ }
399
+ });
400
+ delete props[prop];
401
+ }
402
+ }
424
403
  function replaceChild(node, result) {
425
404
  var _a, _b, _c, _d, _e;
426
405
  if (result.isLastChild) {
@@ -520,62 +499,40 @@ function getAttrProps(path) {
520
499
  // src/signal/symbol.ts
521
500
  import { types as t4 } from "@babel/core";
522
501
  function replaceSymbol(path) {
523
- const init = path.node.init;
524
- const variableName = path.node.id.name;
525
- if (t4.isObjectPattern(path.node.id) || t4.isArrayPattern(path.node.id)) {
526
- return;
527
- }
528
- if (!isSymbolStart(path, variableName)) {
529
- return;
530
- }
531
- if (init && (t4.isFunctionExpression(init) || t4.isArrowFunctionExpression(init)) && path.parent.kind === "const") {
532
- const newInit = t4.callExpression(t4.identifier(path.state.useComputed.name), init ? [init] : []);
533
- imports.add("useComputed");
534
- path.node.init = newInit;
535
- } else {
536
- const newInit = t4.callExpression(t4.identifier(path.state.useSignal.name), init ? [init] : []);
537
- imports.add("useSignal");
538
- path.node.init = newInit;
539
- }
502
+ const { init, id } = path.node;
503
+ const variableName = id.name;
504
+ if (t4.isObjectPattern(id) || t4.isArrayPattern(id) || !isSymbolStart(path, variableName)) return;
505
+ const isComputed = init && (t4.isFunctionExpression(init) || t4.isArrowFunctionExpression(init)) && path.parent.kind === "const";
506
+ const hookName = isComputed ? "useComputed" : "useSignal";
507
+ const newInit = t4.callExpression(t4.identifier(path.state[hookName].name), init ? [init] : []);
508
+ imports.add(hookName);
509
+ path.node.init = newInit;
540
510
  }
541
511
  function symbolIdentifier(path) {
542
512
  const parentPath = path.parentPath;
543
- if (!parentPath || t4.isVariableDeclarator(parentPath) || t4.isImportSpecifier(parentPath) || t4.isObjectProperty(parentPath) || t4.isArrayPattern(parentPath) || t4.isObjectPattern(parentPath)) {
544
- return;
545
- }
513
+ if (!shouldProcessIdentifier(parentPath)) return;
546
514
  const { node } = path;
547
- if (isSymbolStart(path, node.name)) {
548
- let currentPath = path;
549
- while (currentPath.parentPath && !currentPath.parentPath.isProgram()) {
550
- if (currentPath.parentPath.isMemberExpression() && currentPath.parentPath.node.property.name === "value") {
551
- return;
552
- }
553
- currentPath = currentPath.parentPath;
554
- }
555
- const newNode = t4.memberExpression(t4.identifier(node.name), t4.identifier("value"));
556
- path.replaceWith(newNode);
515
+ if (!isSymbolStart(path, node.name)) return;
516
+ if (!path.findParent((p) => p.isMemberExpression() && p.node.property.name === "value")) {
517
+ path.replaceWith(t4.memberExpression(t4.identifier(node.name), t4.identifier("value")));
557
518
  }
558
519
  }
520
+ function shouldProcessIdentifier(parentPath) {
521
+ return parentPath && !t4.isVariableDeclarator(parentPath) && !t4.isImportSpecifier(parentPath) && !t4.isObjectProperty(parentPath) && !t4.isArrayPattern(parentPath) && !t4.isObjectPattern(parentPath);
522
+ }
559
523
  function symbolObjectPattern(path) {
560
524
  path.node.properties.forEach((property) => {
561
525
  if (t4.isObjectProperty(property) && t4.isIdentifier(property.key) && isSymbolStart(path, property.key.name)) {
562
- const newKey = t4.identifier(property.key.name);
563
- property.key = newKey;
526
+ property.key = t4.identifier(property.key.name);
564
527
  }
565
528
  });
566
529
  }
567
530
  function symbolArrayPattern(path) {
568
531
  path.node.elements.forEach((element) => {
569
532
  if (t4.isIdentifier(element) && element.name.startsWith("$")) {
570
- const newElement = t4.identifier(element.name);
571
- element.name = newElement.name;
533
+ element.name = t4.identifier(element.name).name;
572
534
  } else if (t4.isObjectPattern(element)) {
573
- element.properties.forEach((property) => {
574
- if (t4.isObjectProperty(property) && t4.isIdentifier(property.key) && isSymbolStart(path, property.key.name)) {
575
- const newKey = t4.identifier(property.key.name);
576
- property.key = newKey;
577
- }
578
- });
535
+ symbolObjectPattern({ node: element });
579
536
  }
580
537
  });
581
538
  }
@@ -583,35 +540,29 @@ function symbolArrayPattern(path) {
583
540
  // src/signal/import.ts
584
541
  import { types as t5 } from "@babel/core";
585
542
  function replaceImportDeclaration(path) {
586
- const imports2 = path.node.specifiers;
587
- imports2.forEach((specifier) => {
543
+ path.node.specifiers.forEach((specifier) => {
588
544
  const variableName = specifier.local.name;
589
545
  if (startsWith(variableName, "$") && !isVariableUsedAsObject(path, variableName)) {
590
546
  path.scope.rename(variableName, `${variableName}.value`);
591
- specifier.local.name = `${variableName}`;
547
+ specifier.local.name = variableName;
592
548
  }
593
549
  });
594
550
  }
595
551
  function isVariableUsedAsObject(path, variableName) {
552
+ var _a;
596
553
  const binding = path.scope.getBinding(variableName);
597
- let isUsedObject = false;
598
- if (!binding || !binding.referencePaths) {
599
- return isUsedObject;
600
- }
601
- for (const referencePath of binding.referencePaths) {
554
+ return ((_a = binding == null ? void 0 : binding.referencePaths) == null ? void 0 : _a.some((referencePath) => {
602
555
  if (t5.isMemberExpression(referencePath.parent)) {
603
- const memberExprParent = referencePath.parent;
604
- if (t5.isIdentifier(memberExprParent.object, { name: variableName })) {
605
- const newMemberExpr = t5.memberExpression(
606
- t5.memberExpression(memberExprParent.object, t5.identifier("value")),
607
- memberExprParent.property
556
+ const { object, property } = referencePath.parent;
557
+ if (t5.isIdentifier(object, { name: variableName })) {
558
+ referencePath.parentPath.replaceWith(
559
+ t5.memberExpression(t5.memberExpression(object, t5.identifier("value")), property)
608
560
  );
609
- referencePath.parentPath.replaceWith(newMemberExpr);
610
- isUsedObject = true;
561
+ return true;
611
562
  }
612
563
  }
613
- }
614
- return isUsedObject;
564
+ return false;
565
+ })) || false;
615
566
  }
616
567
 
617
568
  // src/signal/props.ts
@@ -620,65 +571,56 @@ function replaceProps(path) {
620
571
  var _a;
621
572
  const state = path.state;
622
573
  const firstParam = path.node.params[0];
623
- if (!firstParam || !t6.isObjectPattern(firstParam)) {
624
- return;
625
- }
574
+ if (!firstParam || !t6.isObjectPattern(firstParam)) return;
626
575
  const returnStatement = path.get("body").get("body").find((statement) => statement.isReturnStatement());
627
- if (!returnStatement) {
628
- return;
629
- }
630
- const returnValue = (_a = returnStatement.node) == null ? void 0 : _a.argument;
631
- if (!t6.isJSXElement(returnValue)) {
632
- return;
633
- }
634
- function replaceProperties(properties2, parentPath) {
576
+ if (!returnStatement || !t6.isJSXElement((_a = returnStatement.node) == null ? void 0 : _a.argument)) return;
577
+ const replaceProperties = (properties2, parentPath) => {
635
578
  properties2.forEach((property) => {
636
- if (t6.isObjectProperty(property)) {
579
+ if (t6.isObjectProperty(property) && t6.isIdentifier(property.key)) {
637
580
  const keyName = property.key.name;
638
581
  if (t6.isIdentifier(property.value)) {
639
- const propertyName = property.value.name;
640
- const newName = `${parentPath}${keyName}`;
641
- path.scope.rename(propertyName, newName);
582
+ path.scope.rename(property.value.name, `${parentPath}${keyName}`);
642
583
  } else if (t6.isObjectPattern(property.value)) {
643
584
  replaceProperties(property.value.properties, `${parentPath}${keyName}.`);
644
585
  }
645
586
  }
646
587
  });
647
- }
588
+ };
648
589
  const properties = firstParam.properties;
649
- replaceProperties(
650
- properties.filter((property) => !t6.isRestElement(property)),
651
- "__props."
652
- );
653
590
  const notRestProperties = properties.filter((property) => !t6.isRestElement(property));
654
- const notRestNames = notRestProperties.map(
655
- (property) => property.key.name
656
- );
591
+ replaceProperties(notRestProperties, "__props.");
592
+ const notRestNames = notRestProperties.map((property) => property.key.name);
657
593
  if (notRestNames.some((name) => startsWith(name, "$"))) {
658
594
  console.warn("props name can not start with $");
659
595
  return;
660
596
  }
597
+ handleRestElement(path, state, properties, notRestNames);
598
+ }
599
+ function handleRestElement(path, state, properties, notRestNames) {
661
600
  const restElement = properties.find((property) => t6.isRestElement(property));
662
601
  path.node.params[0] = t6.identifier("__props");
663
602
  if (restElement) {
664
603
  const restName = restElement.argument.name;
665
- if (notRestProperties.length === 0) {
604
+ if (notRestNames.length === 0) {
666
605
  path.node.params[0] = t6.identifier(restName);
667
606
  } else {
668
- const restVariableDeclaration = t6.variableDeclaration("const", [
669
- t6.variableDeclarator(
670
- t6.identifier(restName),
671
- t6.callExpression(state.useReactive, [
672
- t6.identifier("__props"),
673
- t6.arrayExpression(notRestNames.map((name) => t6.stringLiteral(name)))
674
- ])
675
- )
676
- ]);
607
+ const restVariableDeclaration = createRestVariableDeclaration(state, restName, notRestNames);
677
608
  imports.add("useReactive");
678
609
  path.node.body.body.unshift(restVariableDeclaration);
679
610
  }
680
611
  }
681
612
  }
613
+ function createRestVariableDeclaration(state, restName, notRestNames) {
614
+ return t6.variableDeclaration("const", [
615
+ t6.variableDeclarator(
616
+ t6.identifier(restName),
617
+ t6.callExpression(state.useReactive, [
618
+ t6.identifier("__props"),
619
+ t6.arrayExpression(notRestNames.map((name) => t6.stringLiteral(name)))
620
+ ])
621
+ )
622
+ ]);
623
+ }
682
624
 
683
625
  // src/index.ts
684
626
  function src_default() {
@@ -708,7 +650,7 @@ export {
708
650
  src_default as default
709
651
  };
710
652
  /**
711
- * @estjs/shared v0.0.12-beta.1
653
+ * @estjs/shared v0.0.12
712
654
  * (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
713
655
  * @license MIT
714
656
  **/
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/jsx/index.ts","../../shared/src/is.ts","../../shared/src/comm.ts","../../shared/src/name.ts","../../shared/src/console.ts","../src/program.ts","../src/shared.ts","../src/jsx/constants.ts","../src/signal/symbol.ts","../src/signal/import.ts","../src/signal/props.ts","../src/index.ts"],"sourcesContent":["import { types as t } from '@babel/core';\nimport { capitalizeFirstLetter } from '@estjs/shared';\nimport { imports } from '../program';\nimport {\n type JSXChild,\n type JSXElement,\n getAttrName,\n getTagName,\n hasSiblingElement,\n isComponent,\n isTextChild,\n setNodeText,\n} from '../shared';\nimport { selfClosingTags, svgTags } from './constants';\nimport type { Identifier, OptionalMemberExpression, StringLiteral } 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 | string[];\n}\nlet isSsg = false;\n\nfunction addToTemplate(result: Result, content: string, join = false): void {\n if (isSsg) {\n if (join && result.template.length > 0) {\n (result.template as string[])[result.template.length - 1] += content;\n } else {\n (result.template as string[]).push(content);\n }\n } else {\n result.template += content;\n }\n}\nexport function transformJSX(path: NodePath<JSXElement>): void {\n const state: State = path.state;\n isSsg = state.opts.ssg;\n\n const result: Result = {\n index: 1,\n isLastChild: false,\n parentIndex: 0,\n props: {},\n template: isSsg ? [] : '',\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\n const template = isSsg\n ? t.arrayExpression((result.template as string[]).map(t.stringLiteral))\n : t.callExpression(state.template, [t.stringLiteral(result.template as string)]);\n const declarator = t.variableDeclarator(tmpl, template);\n state.tmplDeclaration.declarations.push(declarator);\n if (!isSsg) {\n imports.add('template');\n }\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(t.identifier(`${key}`));\n }\n if (isSsg) {\n imports.add('ssg');\n return t.callExpression(state.ssg, args);\n } else {\n imports.add('h');\n return t.callExpression(state.h, args);\n }\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, 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 transformJSX(path);\n replaceChild(path.node, result);\n }\n } else {\n if (isSvg) {\n result.template = isSsg ? ['<svg _svg_>'] : '<svg _svg_>';\n }\n\n addToTemplate(result, `<${tagName}`, true);\n handleAttributes(props, result);\n\n addToTemplate(result, isSelfClose ? '/>' : '>', !hasExpression);\n\n if (!isSelfClose) {\n transformChildren(path, result);\n if (hasSiblingElement(path) || isSsg) {\n addToTemplate(result, `</${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 = isSsg ? result.template.length : 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 addToTemplate(result, 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 addToTemplate(result, 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 addToTemplate(result, ` ${prop}`);\n delete props[prop];\n }\n if (value === false) {\n delete props[prop];\n }\n if (typeof value === 'string' || typeof value === 'number') {\n addToTemplate(result, ` ${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 props[prop] = value;\n } else {\n // TODO: For the time being, only support style\n if (prop === 'style') {\n value.properties.forEach(property => {\n if (t.isObjectProperty(property)) {\n style += `${(property.key as Identifier).name}:${(property.value as StringLiteral).value};`;\n }\n });\n\n delete props[prop];\n }\n }\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 addToTemplate(result, ` class=\"${klass}\"`);\n }\n if (style) {\n addToTemplate(result, ` style=\"${style}\"`);\n }\n}\n\nfunction replaceChild(node: t.Expression, result: Result): void {\n if (result.isLastChild) {\n result.index--;\n } else {\n addToTemplate(result, '<!>');\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 transformJSX(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}\n\nexport function 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 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 transformJSX(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[bindName] = t.memberExpression(\n // t.identifier((expression.node as Identifier).name),\n // t.identifier('value'),\n // );\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 transformJSX(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 { _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}\n\nexport function isSet(val: any): val is Set<any> {\n return _toString.call(val) === '[object Set]';\n}\nexport function isWeakMap(val: any): val is WeakMap<any, any> {\n return _toString.call(val) === '[object WeakMap]';\n}\nexport function isWeakSet(val: any): val is WeakSet<any> {\n return _toString.call(val) === '[object WeakSet]';\n}\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;\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 function isHTMLElement(obj) {\n if (!obj) return false;\n return obj && typeof obj === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string';\n}\n","import { isFunction, 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 * 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\n/**\n * Generates a unique random 8 character string ID.\n * The generated IDs only contain alphanumeric characters.\n * @returns A unique random 8 character string ID.\n */\nexport function generateUniqueId() {\n const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n let result = '';\n const charactersLength = characters.length;\n for (let i = 0; i < 8; i++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n return result;\n}\n\n/**\n * Checks if the current environment is a browser.\n * @returns True if the current environment is a browser, otherwise false.\n */\nexport function isBrowser() {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\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","export function warn(msg: string, ..._args: any[]): void;\nexport function warn(msg: string, ...args): void {\n // eslint-disable-next-line prefer-spread\n console.warn.apply(console, [`[Essor warn]: ${msg}`].concat(args) as [string, ...any[]]);\n}\n\nexport function info(msg: string, ..._args: any[]): void;\nexport function info(msg: string, ...args): void {\n // eslint-disable-next-line prefer-spread, no-console\n console.info.apply(console, [`[Essor info]: ${msg}`].concat(args) as [string, ...any[]]);\n}\n\nexport function error(msg: string, ..._args: any[]): void;\nexport function error(msg: string, ...args): void {\n // eslint-disable-next-line prefer-spread\n console.error.apply(console, [`[Essor error]: ${msg}`].concat(args) as [string, ...any[]]);\n}\n","import { type NodePath, types as t } from '@babel/core';\nimport type { Options, State } from './types';\nexport const imports = new Set<string>();\n\nconst defaultOption: Options = {\n ssg: false,\n symbol: '$',\n props: true,\n};\n\nexport const transformProgram = {\n enter(path: NodePath<t.Program>, state) {\n imports.clear();\n\n // merge options\n state.opts = { ...defaultOption, ...state.opts };\n\n path.state = {\n h: path.scope.generateUidIdentifier('h$'),\n template: path.scope.generateUidIdentifier('template$'),\n ssg: path.scope.generateUidIdentifier('ssg$'),\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","import { type NodePath, types as t } from '@babel/core';\nimport { startsWith } from '@estjs/shared';\nimport type { State } from './types';\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 or JSXExpressionContainer\n const hasSibling = siblings.some(\n siblingPath => siblingPath.isJSXElement() || siblingPath.isJSXExpressionContainer(),\n );\n\n return hasSibling;\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-z]/i.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\n/**\n * get the symbol start with\n */\nexport function isSymbolStart(path: NodePath<any>, name: string) {\n const state: State = path.state;\n const { symbol } = state.opts;\n\n return startsWith(name, symbol);\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 { types as t } from '@babel/core';\nimport { imports } from '../program';\nimport { isSymbolStart } from '../shared';\nimport type { Identifier, VariableDeclarator } from '@babel/types';\nimport type { NodePath } from '@babel/core';\n\n/**\n * Replaces the symbol in a variable declarator with a computed or signal expression.\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 * @param {NodePath<VariableDeclarator>} path - The path to the variable declarator node.\n * @return {void}\n */\nexport function replaceSymbol(path: NodePath<VariableDeclarator>) {\n const init = path.node.init;\n\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 (!isSymbolStart(path, 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 (isSymbolStart(path, node.name)) {\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 isSymbolStart(path, property.key.name)\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 isSymbolStart(path, property.key.name)\n ) {\n const newKey = t.identifier(property.key.name);\n property.key = newKey;\n }\n });\n }\n });\n}\n","import { types as t } from '@babel/core';\nimport { startsWith } from '@estjs/shared';\n\n/**\n * Replaces import declarations\n *\n * case1: import { $a } from 'a';console.log(a) => import { $a } from 'a';console.log($a.value)\n * case2: import $a from 'a';console.log(a) => import $a from 'a';console.log($a.value)\n *\n * @param {object} path - The path to replace import declarations.\n * @return {void}\n */\nexport function replaceImportDeclaration(path) {\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}\nfunction isVariableUsedAsObject(path, variableName) {\n const binding = path.scope.getBinding(variableName);\n let isUsedObject = false;\n\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 (t.isIdentifier(memberExprParent.object, { name: variableName })) {\n const newMemberExpr = t.memberExpression(\n t.memberExpression(memberExprParent.object, t.identifier('value')),\n memberExprParent.property,\n );\n referencePath.parentPath.replaceWith(newMemberExpr);\n isUsedObject = true;\n }\n }\n }\n\n return isUsedObject;\n}\n","import { startsWith } from '@estjs/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\n/**\n * Replaces the properties of a function's first parameter with new names.\n *\n * auto replace pattern to props object\n *\n * rule1: function argument\n * rule2: first argument is object and it pattern\n * rule3: function has return\n *\n * transform case\n * case1 ({a, b}) => <div>{a.value}</div> to=> (_props)=><div>{_props.a.value}</div>\n * case2 ({a, b, ...rest}) => <div>{a.value}{rest}</div> to=> (_props)=> {const restProps = reactive(props,[a,b]);return <div>{_props.a.value}{reset}</div>}\n *\n * not transform case\n * case1 ([a,b])=> <div>{a.value}</div>\n * case2 ({a.,b}) ={}\n *\n * @param {NodePath<FunctionDeclaration | ArrowFunctionExpression>} path - The path to the function node.\n * @return {void}\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\n FunctionDeclaration: replaceProps,\n ArrowFunctionExpression: replaceProps,\n VariableDeclarator: replaceSymbol,\n ImportDeclaration: replaceImportDeclaration,\n Identifier: symbolIdentifier,\n ObjectPattern: symbolObjectPattern,\n ArrayPattern: symbolArrayPattern,\n\n JSXElement: transformJSX,\n JSXFragment: transformJSX,\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,SAASA,UAAS;;;ACQpB,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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D,mBAAW,QAAQ,KAAK,YAAY;AAAA,MACtC;AACA,iBAAW,QAAQ,KAAK,KAAK;AAAA,IAC/B;AAAA,IACA,SAAS;AAAA,MACP,SAAS;AAAA,MAET,qBAAqB;AAAA,MACrB,yBAAyB;AAAA,MACzB,oBAAoB;AAAA,MACpB,mBAAmB;AAAA,MACnB,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,cAAc;AAAA,MAEd,YAAY;AAAA,MACZ,aAAa;AAAA,IACf;AAAA,EACF;AACF;","names":["t","t","t","t","value","t","t","t","imports","t","t","t","properties"]}
1
+ {"version":3,"sources":["../src/jsx/index.ts","../../shared/src/is.ts","../../shared/src/comm.ts","../../shared/src/name.ts","../../shared/src/console.ts","../src/program.ts","../src/shared.ts","../src/jsx/constants.ts","../src/signal/symbol.ts","../src/signal/import.ts","../src/signal/props.ts","../src/index.ts"],"sourcesContent":["import { types as t } from '@babel/core';\nimport { capitalizeFirstLetter } from '@estjs/shared';\nimport { imports } from '../program';\nimport {\n type JSXChild,\n type JSXElement,\n getAttrName,\n getTagName,\n hasSiblingElement,\n isComponent as isComponentName,\n isTextChild,\n setNodeText,\n} from '../shared';\nimport { selfClosingTags, svgTags } from './constants';\nimport type { Identifier, OptionalMemberExpression, StringLiteral } 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 | string[];\n}\nlet isSsg = false;\n\nfunction addToTemplate(result: Result, content: string, join = false): void {\n if (isSsg) {\n if (join && result.template.length > 0) {\n (result.template as string[])[result.template.length - 1] += content;\n } else {\n (result.template as string[]).push(content);\n }\n } else {\n result.template += content;\n }\n}\nexport function transformJSX(path: NodePath<JSXElement>): void {\n const state: State = path.state;\n isSsg = state.opts.ssg;\n\n const result: Result = {\n index: 1,\n isLastChild: false,\n parentIndex: 0,\n props: {},\n template: isSsg ? [] : '',\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 const isComponent = path.isJSXElement() && isComponentName(getTagName(path.node));\n\n const tmpl = isComponent\n ? t.identifier(getTagName(path.node))\n : path.scope.generateUidIdentifier('_tmpl$');\n\n if (!isComponent) {\n const template = isSsg\n ? t.arrayExpression((result.template as string[]).map(t.stringLiteral))\n : t.callExpression(state.template, [t.stringLiteral(result.template as string)]);\n state.tmplDeclaration.declarations.push(t.variableDeclarator(tmpl, template));\n if (!isSsg) {\n imports.add('template');\n }\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(t.identifier(`${key}`));\n }\n\n const fnName = isSsg ? 'ssg' : 'h';\n imports.add(fnName);\n return t.callExpression(state[fnName], 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 = isComponentName(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 transformJSX(path);\n replaceChild(path.node, result);\n }\n } else {\n if (isSvg) {\n result.template = isSsg ? ['<svg _svg_>'] : '<svg _svg_>';\n }\n\n addToTemplate(result, `<${tagName}`, true);\n handleAttributes(props, result);\n\n addToTemplate(result, isSelfClose ? '/>' : '>', !hasExpression);\n\n if (!isSelfClose) {\n transformChildren(path, result);\n if (hasSiblingElement(path) || isSsg) {\n addToTemplate(result, `</${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 = isSsg ? result.template.length : 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 addToTemplate(result, 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 // just for tracking value\n } else {\n throw new Error('Unsupported child type');\n }\n } else if (child.isJSXText()) {\n addToTemplate(result, 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, value] of Object.entries(props)) {\n if (prop === 'class' && typeof value === 'string') {\n klass += ` ${value}`;\n delete props[prop];\n } else if (prop === 'style' && typeof value === 'string') {\n style += `${value}${value.at(-1) === ';' ? '' : ';'}`;\n delete props[prop];\n } else if (value === true) {\n addToTemplate(result, ` ${prop}`);\n delete props[prop];\n } else if (value === false) {\n delete props[prop];\n } else if (typeof value === 'string' || typeof value === 'number') {\n addToTemplate(result, ` ${prop}=\"${value}\"`);\n delete props[prop];\n } else if (t.isConditionalExpression(value)) {\n props[prop] = t.arrowFunctionExpression([], value);\n } else if (t.isObjectExpression(value)) {\n handleObjectExpression(prop, value, props, style);\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 addToTemplate(result, ` class=\"${klass}\"`);\n }\n if (style) {\n addToTemplate(result, ` style=\"${style}\"`);\n }\n}\n\nfunction handleObjectExpression(\n prop: string,\n value: t.ObjectExpression,\n props: Record<string, any>,\n // eslint-disable-next-line unused-imports/no-unused-vars\n style: string,\n): void {\n const hasConditional = value.properties.some(\n property => t.isObjectProperty(property) && t.isConditionalExpression(property.value),\n );\n\n if (hasConditional) {\n props[prop] = t.arrowFunctionExpression([], value);\n } else if (prop === 'style') {\n value.properties.forEach(property => {\n if (t.isObjectProperty(property)) {\n style += `${(property.key as Identifier).name}:${(property.value as StringLiteral).value};`;\n }\n });\n delete props[prop];\n }\n}\n\nfunction replaceChild(node: t.Expression, result: Result): void {\n if (result.isLastChild) {\n result.index--;\n } else {\n addToTemplate(result, '<!>');\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 transformJSX(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}\n\nexport function 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 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 transformJSX(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[bindName] = t.memberExpression(\n // t.identifier((expression.node as Identifier).name),\n // t.identifier('value'),\n // );\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 transformJSX(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 { _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): val is Promise<any> {\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}\n\nexport function isSet(val: any): val is Set<any> {\n return _toString.call(val) === '[object Set]';\n}\nexport function isWeakMap(val: any): val is WeakMap<any, any> {\n return _toString.call(val) === '[object WeakMap]';\n}\nexport function isWeakSet(val: any): val is WeakSet<any> {\n return _toString.call(val) === '[object WeakSet]';\n}\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;\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 function isHTMLElement(obj) {\n if (!obj) return false;\n return obj && typeof obj === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string';\n}\n\nexport const isPlainObject = (val: unknown): val is object =>\n _toString.call(val) === '[object Object]';\n\nexport type StringNumber = `${number}`;\nexport function isStringNumber(val: unknown): val is StringNumber {\n if (!isString(val)) {\n return false;\n }\n return !Number.isNaN(Number(val));\n}\n","import { isFunction, 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 * 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\n/**\n * Generates a unique random 8 character string ID.\n * The generated IDs only contain alphanumeric characters.\n * @returns A unique random 8 character string ID.\n */\nexport function generateUniqueId() {\n const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n let result = '';\n const charactersLength = characters.length;\n for (let i = 0; i < 8; i++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n return result;\n}\n\n/**\n * Checks if the current environment is a browser.\n * @returns True if the current environment is a browser, otherwise false.\n */\nexport function isBrowser() {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\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","export function warn(msg: string, ..._args: any[]): void;\nexport function warn(msg: string, ...args): void {\n // eslint-disable-next-line prefer-spread\n console.warn.apply(console, [`[Essor warn]: ${msg}`].concat(args) as [string, ...any[]]);\n}\n\nexport function info(msg: string, ..._args: any[]): void;\nexport function info(msg: string, ...args): void {\n // eslint-disable-next-line prefer-spread, no-console\n console.info.apply(console, [`[Essor info]: ${msg}`].concat(args) as [string, ...any[]]);\n}\n\nexport function error(msg: string, ..._args: any[]): void;\nexport function error(msg: string, ...args): void {\n // eslint-disable-next-line prefer-spread\n console.error.apply(console, [`[Essor error]: ${msg}`].concat(args) as [string, ...any[]]);\n}\n","import { type NodePath, types as t } from '@babel/core';\nimport type { Options, State } from './types';\nexport const imports = new Set<string>();\n\nconst defaultOption: Options = {\n ssg: false,\n symbol: '$',\n props: true,\n};\n\nexport const transformProgram = {\n enter(path: NodePath<t.Program>, state) {\n imports.clear();\n\n // merge options\n state.opts = { ...defaultOption, ...state.opts };\n\n path.state = {\n h: path.scope.generateUidIdentifier('h$'),\n template: path.scope.generateUidIdentifier('template$'),\n ssg: path.scope.generateUidIdentifier('ssg$'),\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","import { type NodePath, types as t } from '@babel/core';\nimport { startsWith } from '@estjs/shared';\nimport type { State } from './types';\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 or JSXExpressionContainer\n const hasSibling = siblings.some(\n siblingPath => siblingPath.isJSXElement() || siblingPath.isJSXExpressionContainer(),\n );\n\n return hasSibling;\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-z]/i.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\n/**\n * get the symbol start with\n */\nexport function isSymbolStart(path: NodePath<any>, name: string) {\n const state: State = path.state;\n const { symbol } = state?.opts || '$';\n\n return startsWith(name, symbol);\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 { types as t } from '@babel/core';\nimport { imports } from '../program';\nimport { isSymbolStart } from '../shared';\nimport type { Identifier, VariableDeclarator } from '@babel/types';\nimport type { NodePath } from '@babel/core';\n\n/**\n * Replaces the symbol in a variable declarator with a computed or signal expression.\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 * @param {NodePath<VariableDeclarator>} path - The path to the variable declarator node.\n * @return {void}\n */\nexport function replaceSymbol(path: NodePath<VariableDeclarator>) {\n const { init, id } = path.node;\n const variableName = (id as Identifier).name;\n\n if (t.isObjectPattern(id) || t.isArrayPattern(id) || !isSymbolStart(path, variableName)) return;\n\n const isComputed =\n init &&\n (t.isFunctionExpression(init) || t.isArrowFunctionExpression(init)) &&\n (path.parent as t.VariableDeclaration).kind === 'const';\n\n const hookName = isComputed ? 'useComputed' : 'useSignal';\n const newInit = t.callExpression(t.identifier(path.state[hookName].name), init ? [init] : []);\n\n imports.add(hookName);\n path.node.init = newInit;\n}\n\nexport function symbolIdentifier(path) {\n const parentPath = path.parentPath;\n if (!shouldProcessIdentifier(parentPath)) return;\n\n const { node } = path;\n if (!isSymbolStart(path, node.name)) return;\n\n if (!path.findParent(p => p.isMemberExpression() && p.node.property.name === 'value')) {\n path.replaceWith(t.memberExpression(t.identifier(node.name), t.identifier('value')));\n }\n}\n\nfunction shouldProcessIdentifier(parentPath) {\n return (\n parentPath &&\n !t.isVariableDeclarator(parentPath) &&\n !t.isImportSpecifier(parentPath) &&\n !t.isObjectProperty(parentPath) &&\n !t.isArrayPattern(parentPath) &&\n !t.isObjectPattern(parentPath)\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 isSymbolStart(path, property.key.name)\n ) {\n property.key = t.identifier(property.key.name);\n }\n });\n}\n\nexport function symbolArrayPattern(path) {\n path.node.elements.forEach(element => {\n if (t.isIdentifier(element) && element.name.startsWith('$')) {\n element.name = t.identifier(element.name).name;\n } else if (t.isObjectPattern(element)) {\n symbolObjectPattern({ node: element } as NodePath);\n }\n });\n}\n","import { types as t } from '@babel/core';\nimport { startsWith } from '@estjs/shared';\n\n/**\n * Replaces import declarations\n *\n * case1: import { $a } from 'a';console.log(a) => import { $a } from 'a';console.log($a.value)\n * case2: import $a from 'a';console.log(a) => import $a from 'a';console.log($a.value)\n *\n * @param {object} path - The path to replace import declarations.\n * @return {void}\n */\nexport function replaceImportDeclaration(path) {\n path.node.specifiers.forEach(specifier => {\n const variableName = specifier.local.name;\n if (startsWith(variableName, '$') && !isVariableUsedAsObject(path, variableName)) {\n path.scope.rename(variableName, `${variableName}.value`);\n specifier.local.name = variableName;\n }\n });\n}\n\n/**\n * Checks if a variable is used as an object.\n *\n * @param path - The path to the variable.\n * @param variableName - The name of the variable.\n * @returns {boolean} - Whether the variable is used as an object.\n */\nfunction isVariableUsedAsObject(path, variableName) {\n const binding = path.scope.getBinding(variableName);\n return (\n binding?.referencePaths?.some(referencePath => {\n if (t.isMemberExpression(referencePath.parent)) {\n const { object, property } = referencePath.parent;\n if (t.isIdentifier(object, { name: variableName })) {\n referencePath.parentPath.replaceWith(\n t.memberExpression(t.memberExpression(object, t.identifier('value')), property),\n );\n return true;\n }\n }\n return false;\n }) || false\n );\n}\n","import { startsWith } from '@estjs/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\n/**\n * Replaces the properties of a function's first parameter with new names.\n *\n * auto replace pattern to props object\n *\n * rule1: function argument\n * rule2: first argument is object and it pattern\n * rule3: function has return\n *\n * transform case\n * case1 ({a, b}) => <div>{a.value}</div> to=> (_props)=><div>{_props.a.value}</div>\n * case2 ({a, b, ...rest}) => <div>{a.value}{rest}</div> to=> (_props)=> {const restProps = reactive(props,[a,b]);return <div>{_props.a.value}{reset}</div>}\n *\n * not transform case\n * case1 ([a,b])=> <div>{a.value}</div>\n * case2 ({a.,b}) ={}\n *\n * @param {NodePath<FunctionDeclaration | ArrowFunctionExpression>} path - The path to the function node.\n * @return {void}\n */\nexport function replaceProps(path: NodePath<FunctionDeclaration | ArrowFunctionExpression>) {\n const state: State = path.state;\n const firstParam = path.node.params[0];\n\n if (!firstParam || !t.isObjectPattern(firstParam)) return;\n\n const returnStatement = path\n .get('body')\n .get('body')\n .find(statement => statement.isReturnStatement());\n\n if (!returnStatement || !t.isJSXElement((returnStatement.node as any)?.argument)) return;\n\n const replaceProperties = (properties: (ObjectProperty | RestElement)[], parentPath: string) => {\n properties.forEach(property => {\n if (t.isObjectProperty(property) && t.isIdentifier(property.key)) {\n const keyName = property.key.name;\n if (t.isIdentifier(property.value)) {\n path.scope.rename(property.value.name, `${parentPath}${keyName}`);\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 const notRestProperties = properties.filter(property => !t.isRestElement(property)) as ObjectProperty[];\n replaceProperties(notRestProperties, '__props.');\n\n const notRestNames = notRestProperties.map(property => (property.key as Identifier).name);\n if (__DEV__ && notRestNames.some(name => startsWith(name, '$'))) {\n console.warn('props name can not start with $');\n return;\n }\n\n handleRestElement(path, state, properties, notRestNames);\n}\n\nfunction handleRestElement(path, state: State, properties, notRestNames) {\n const restElement = properties.find(property => t.isRestElement(property)) as RestElement | undefined;\n path.node.params[0] = t.identifier('__props');\n\n if (restElement) {\n const restName = (restElement.argument as Identifier).name;\n if (notRestNames.length === 0) {\n path.node.params[0] = t.identifier(restName);\n } else {\n const restVariableDeclaration = createRestVariableDeclaration(state, restName, notRestNames);\n imports.add('useReactive');\n (path.node.body as t.BlockStatement).body.unshift(restVariableDeclaration);\n }\n }\n}\n\nfunction createRestVariableDeclaration(state: State, restName: string, notRestNames: string[]) {\n return 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}\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\n FunctionDeclaration: replaceProps,\n ArrowFunctionExpression: replaceProps,\n VariableDeclarator: replaceSymbol,\n ImportDeclaration: replaceImportDeclaration,\n Identifier: symbolIdentifier,\n ObjectPattern: symbolObjectPattern,\n ArrayPattern: symbolArrayPattern,\n\n JSXElement: transformJSX,\n JSXFragment: transformJSX,\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,SAASA,UAAS;;;ACQpB,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;;;AElBA,SAAwB,SAAS,SAAS;AAEnC,IAAM,UAAU,oBAAI,IAAY;AAEvC,IAAM,gBAAyB;AAAA,EAC7B,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO;AACT;AAEO,IAAM,mBAAmB;AAAA,EAC9B,MAAM,MAA2B,OAAO;AACtC,YAAQ,MAAM;AAGd,UAAM,OAAO,kCAAK,gBAAkB,MAAM;AAE1C,SAAK,QAAQ;AAAA,MACX,GAAG,KAAK,MAAM,sBAAsB,IAAI;AAAA,MACxC,U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AAAA,MACtC;AACA,iBAAW,QAAQ,KAAK,KAAK;AAAA,IAC/B;AAAA,IACA,SAAS;AAAA,MACP,SAAS;AAAA,MAET,qBAAqB;AAAA,MACrB,yBAAyB;AAAA,MACzB,oBAAoB;AAAA,MACpB,mBAAmB;AAAA,MACnB,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,cAAc;AAAA,MAEd,YAAY;AAAA,MACZ,aAAa;AAAA,IACf;AAAA,EACF;AACF;","names":["t","t","t","isComponent","t","value","t","t","t","t","t","t","properties"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-essor",
3
- "version": "0.0.12-beta.1",
3
+ "version": "0.0.12",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -34,7 +34,7 @@
34
34
  "dependencies": {
35
35
  "@babel/core": "^7.25.2",
36
36
  "@babel/types": "^7.25.6",
37
- "@estjs/shared": "0.0.12-beta.1"
37
+ "@estjs/shared": "0.0.12"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/babel__core": "^7.20.5",