babel-plugin-essor 0.0.17-beta.6 → 0.0.17-beta.7

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
@@ -101,7 +101,8 @@ var IMPORTS_MAPS = [
101
101
  "nthChild"
102
102
  ];
103
103
  var SERVER_IMPORT_REMAPS = {
104
- createComponent: "createSSRComponent",
104
+ createComponent: "ssrComponent",
105
+ render: "ssr",
105
106
  patchAttr: "ssrAttrDynamic"
106
107
  };
107
108
  var HYDRATE_IMPORT_REMAPS = {
@@ -1073,7 +1074,7 @@ function bindObjectPattern(pattern, base) {
1073
1074
  }
1074
1075
  function resolveObjectProp(prop) {
1075
1076
  const target = prop.value;
1076
- const shorthandId = core.types.isAssignmentPattern(target) ? target.left : target;
1077
+ const shorthandId = unwrapBindingTarget(core.types.isAssignmentPattern(target) ? target.left : target);
1077
1078
  if (prop.shorthand && core.types.isIdentifier(shorthandId) && isSignal(shorthandId.name)) {
1078
1079
  return { keyExpr: core.types.identifier(stripSignalPrefix(shorthandId.name)), computed: false, target };
1079
1080
  }
@@ -1093,7 +1094,9 @@ function bindArrayPattern(pattern, base) {
1093
1094
  out.push(...bindTarget(el.argument, slice));
1094
1095
  return;
1095
1096
  }
1096
- out.push(...bindTarget(el, core.types.memberExpression(clone(base), core.types.numericLiteral(i2), true)));
1097
+ out.push(
1098
+ ...bindTarget(el, core.types.memberExpression(clone(base), core.types.numericLiteral(i2), true))
1099
+ );
1097
1100
  });
1098
1101
  return out;
1099
1102
  }
@@ -1101,14 +1104,28 @@ function bindTarget(target, access) {
1101
1104
  if (core.types.isAssignmentPattern(target)) {
1102
1105
  return bindTarget(target.left, applyDefault(access, target.right));
1103
1106
  }
1107
+ if (isTSWrappedBindingTarget(target)) {
1108
+ return bindTarget(unwrapBindingTarget(target), access);
1109
+ }
1104
1110
  if (core.types.isIdentifier(target)) {
1105
1111
  const value = isSignal(target.name) ? makeComputed(access) : access;
1106
1112
  return [core.types.variableDeclarator(core.types.identifier(target.name), value)];
1107
1113
  }
1108
1114
  if (core.types.isObjectPattern(target)) return bindObjectPattern(target, access);
1109
1115
  if (core.types.isArrayPattern(target)) return bindArrayPattern(target, access);
1116
+ if (core.types.isMemberExpression(target)) return [];
1110
1117
  return [core.types.variableDeclarator(target, access)];
1111
1118
  }
1119
+ function isTSWrappedBindingTarget(target) {
1120
+ return core.types.isTSAsExpression(target) || core.types.isTSSatisfiesExpression(target) || core.types.isTSTypeAssertion(target) || core.types.isTSNonNullExpression(target);
1121
+ }
1122
+ function unwrapBindingTarget(target) {
1123
+ let current = target;
1124
+ while (isTSWrappedBindingTarget(current)) {
1125
+ current = current.expression;
1126
+ }
1127
+ return current;
1128
+ }
1112
1129
  function applyDefault(access, def) {
1113
1130
  return core.types.conditionalExpression(
1114
1131
  core.types.binaryExpression("===", clone(access), core.types.identifier("undefined")),
@@ -1907,7 +1924,7 @@ function renderChildExpressions(children, render, options = {}) {
1907
1924
  }
1908
1925
  function buildComponentInvocation(tag, node, options) {
1909
1926
  const createComponentId = options.wrap ? useImport("createComponent") : null;
1910
- const callee = resolveComponentCallee(tag, core.types.identifier(tag));
1927
+ const callee = resolveComponentCallee(tag, buildComponentTagExpression(tag));
1911
1928
  const props = buildComponentPropsExpression(node, {
1912
1929
  dynamicPropsAsGetters: options.dynamicPropsAsGetters,
1913
1930
  cloneValues: options.cloneValues,
@@ -1920,6 +1937,13 @@ function buildComponentInvocation(tag, node, options) {
1920
1937
  }
1921
1938
  return core.types.callExpression(callee, [props]);
1922
1939
  }
1940
+ function buildComponentTagExpression(tag) {
1941
+ const [head, ...parts] = tag.split(".");
1942
+ return parts.reduce(
1943
+ (expr, part) => core.types.memberExpression(expr, core.types.identifier(part)),
1944
+ core.types.identifier(head)
1945
+ );
1946
+ }
1923
1947
 
1924
1948
  // src/jsx/server.ts
1925
1949
  var SERVER_TEXT_ESCAPES = {
@@ -2022,28 +2046,13 @@ function escapeChildExpression(expr) {
2022
2046
  if (isSafeServerHtml(expr)) {
2023
2047
  return expr;
2024
2048
  }
2025
- if (core.types.isParenthesizedExpression(expr)) {
2026
- expr.expression = escapeChildExpression(expr.expression);
2027
- return expr;
2028
- }
2029
2049
  if (core.types.isLogicalExpression(expr)) {
2030
2050
  if (expr.operator === "&&") {
2031
2051
  expr.right = escapeChildExpression(expr.right);
2052
+ return expr;
2032
2053
  } else {
2033
- expr.left = escapeChildExpression(expr.left);
2034
- expr.right = escapeChildExpression(expr.right);
2054
+ return core.types.callExpression(useImport("escape"), [expr]);
2035
2055
  }
2036
- return expr;
2037
- }
2038
- if (core.types.isConditionalExpression(expr)) {
2039
- expr.consequent = escapeChildExpression(expr.consequent);
2040
- expr.alternate = escapeChildExpression(expr.alternate);
2041
- return expr;
2042
- }
2043
- if (core.types.isSequenceExpression(expr) && expr.expressions.length > 0) {
2044
- const last = expr.expressions.length - 1;
2045
- expr.expressions[last] = escapeChildExpression(expr.expressions[last]);
2046
- return expr;
2047
2056
  }
2048
2057
  return core.types.callExpression(useImport("escape"), [expr]);
2049
2058
  }
package/dist/index.d.cts CHANGED
@@ -1,11 +1,11 @@
1
- import { PluginObj } from '@babel/core';
1
+ import { PluginObject } from '@babel/core';
2
2
 
3
3
  /**
4
4
  * Babel plugin for Essor framework.
5
5
  * Transforms Essor JSX and reactivity syntax into runtime calls.
6
6
  *
7
- * @returns {PluginObj} The Babel plugin object.
7
+ * @returns {PluginObject} The Babel plugin object.
8
8
  */
9
- declare function export_default(): PluginObj;
9
+ declare function export_default(): PluginObject;
10
10
 
11
11
  export { export_default as default };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { PluginObj } from '@babel/core';
1
+ import { PluginObject } from '@babel/core';
2
2
 
3
3
  /**
4
4
  * Babel plugin for Essor framework.
5
5
  * Transforms Essor JSX and reactivity syntax into runtime calls.
6
6
  *
7
- * @returns {PluginObj} The Babel plugin object.
7
+ * @returns {PluginObject} The Babel plugin object.
8
8
  */
9
- declare function export_default(): PluginObj;
9
+ declare function export_default(): PluginObject;
10
10
 
11
11
  export { export_default as default };
package/dist/index.js CHANGED
@@ -99,7 +99,8 @@ var IMPORTS_MAPS = [
99
99
  "nthChild"
100
100
  ];
101
101
  var SERVER_IMPORT_REMAPS = {
102
- createComponent: "createSSRComponent",
102
+ createComponent: "ssrComponent",
103
+ render: "ssr",
103
104
  patchAttr: "ssrAttrDynamic"
104
105
  };
105
106
  var HYDRATE_IMPORT_REMAPS = {
@@ -1071,7 +1072,7 @@ function bindObjectPattern(pattern, base) {
1071
1072
  }
1072
1073
  function resolveObjectProp(prop) {
1073
1074
  const target = prop.value;
1074
- const shorthandId = types.isAssignmentPattern(target) ? target.left : target;
1075
+ const shorthandId = unwrapBindingTarget(types.isAssignmentPattern(target) ? target.left : target);
1075
1076
  if (prop.shorthand && types.isIdentifier(shorthandId) && isSignal(shorthandId.name)) {
1076
1077
  return { keyExpr: types.identifier(stripSignalPrefix(shorthandId.name)), computed: false, target };
1077
1078
  }
@@ -1091,7 +1092,9 @@ function bindArrayPattern(pattern, base) {
1091
1092
  out.push(...bindTarget(el.argument, slice));
1092
1093
  return;
1093
1094
  }
1094
- out.push(...bindTarget(el, types.memberExpression(clone(base), types.numericLiteral(i2), true)));
1095
+ out.push(
1096
+ ...bindTarget(el, types.memberExpression(clone(base), types.numericLiteral(i2), true))
1097
+ );
1095
1098
  });
1096
1099
  return out;
1097
1100
  }
@@ -1099,14 +1102,28 @@ function bindTarget(target, access) {
1099
1102
  if (types.isAssignmentPattern(target)) {
1100
1103
  return bindTarget(target.left, applyDefault(access, target.right));
1101
1104
  }
1105
+ if (isTSWrappedBindingTarget(target)) {
1106
+ return bindTarget(unwrapBindingTarget(target), access);
1107
+ }
1102
1108
  if (types.isIdentifier(target)) {
1103
1109
  const value = isSignal(target.name) ? makeComputed(access) : access;
1104
1110
  return [types.variableDeclarator(types.identifier(target.name), value)];
1105
1111
  }
1106
1112
  if (types.isObjectPattern(target)) return bindObjectPattern(target, access);
1107
1113
  if (types.isArrayPattern(target)) return bindArrayPattern(target, access);
1114
+ if (types.isMemberExpression(target)) return [];
1108
1115
  return [types.variableDeclarator(target, access)];
1109
1116
  }
1117
+ function isTSWrappedBindingTarget(target) {
1118
+ return types.isTSAsExpression(target) || types.isTSSatisfiesExpression(target) || types.isTSTypeAssertion(target) || types.isTSNonNullExpression(target);
1119
+ }
1120
+ function unwrapBindingTarget(target) {
1121
+ let current = target;
1122
+ while (isTSWrappedBindingTarget(current)) {
1123
+ current = current.expression;
1124
+ }
1125
+ return current;
1126
+ }
1110
1127
  function applyDefault(access, def) {
1111
1128
  return types.conditionalExpression(
1112
1129
  types.binaryExpression("===", clone(access), types.identifier("undefined")),
@@ -1905,7 +1922,7 @@ function renderChildExpressions(children, render, options = {}) {
1905
1922
  }
1906
1923
  function buildComponentInvocation(tag, node, options) {
1907
1924
  const createComponentId = options.wrap ? useImport("createComponent") : null;
1908
- const callee = resolveComponentCallee(tag, types.identifier(tag));
1925
+ const callee = resolveComponentCallee(tag, buildComponentTagExpression(tag));
1909
1926
  const props = buildComponentPropsExpression(node, {
1910
1927
  dynamicPropsAsGetters: options.dynamicPropsAsGetters,
1911
1928
  cloneValues: options.cloneValues,
@@ -1918,6 +1935,13 @@ function buildComponentInvocation(tag, node, options) {
1918
1935
  }
1919
1936
  return types.callExpression(callee, [props]);
1920
1937
  }
1938
+ function buildComponentTagExpression(tag) {
1939
+ const [head, ...parts] = tag.split(".");
1940
+ return parts.reduce(
1941
+ (expr, part) => types.memberExpression(expr, types.identifier(part)),
1942
+ types.identifier(head)
1943
+ );
1944
+ }
1921
1945
 
1922
1946
  // src/jsx/server.ts
1923
1947
  var SERVER_TEXT_ESCAPES = {
@@ -2020,28 +2044,13 @@ function escapeChildExpression(expr) {
2020
2044
  if (isSafeServerHtml(expr)) {
2021
2045
  return expr;
2022
2046
  }
2023
- if (types.isParenthesizedExpression(expr)) {
2024
- expr.expression = escapeChildExpression(expr.expression);
2025
- return expr;
2026
- }
2027
2047
  if (types.isLogicalExpression(expr)) {
2028
2048
  if (expr.operator === "&&") {
2029
2049
  expr.right = escapeChildExpression(expr.right);
2050
+ return expr;
2030
2051
  } else {
2031
- expr.left = escapeChildExpression(expr.left);
2032
- expr.right = escapeChildExpression(expr.right);
2052
+ return types.callExpression(useImport("escape"), [expr]);
2033
2053
  }
2034
- return expr;
2035
- }
2036
- if (types.isConditionalExpression(expr)) {
2037
- expr.consequent = escapeChildExpression(expr.consequent);
2038
- expr.alternate = escapeChildExpression(expr.alternate);
2039
- return expr;
2040
- }
2041
- if (types.isSequenceExpression(expr) && expr.expressions.length > 0) {
2042
- const last = expr.expressions.length - 1;
2043
- expr.expressions[last] = escapeChildExpression(expr.expressions[last]);
2044
- return expr;
2045
2054
  }
2046
2055
  return types.callExpression(useImport("escape"), [expr]);
2047
2056
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-essor",
3
- "version": "0.0.17-beta.6",
3
+ "version": "0.0.17-beta.7",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -32,16 +32,16 @@
32
32
  },
33
33
  "sideEffects": false,
34
34
  "dependencies": {
35
- "@babel/core": "^7.29.7",
36
- "@babel/generator": "^7.29.7",
37
- "@estjs/shared": "0.0.17-beta.6"
35
+ "@babel/core": "^8.0.1",
36
+ "@babel/generator": "^8.0.0",
37
+ "@estjs/shared": "0.0.17-beta.7"
38
38
  },
39
39
  "devDependencies": {
40
- "@babel/traverse": "^7.29.7",
41
- "@babel/types": "^7.29.7",
42
- "@types/babel__core": "^7.20.5",
43
- "@types/babel__generator": "^7.27.0",
44
- "@types/babel__traverse": "^7.28.0"
40
+ "@babel/traverse": "^8.0.0",
41
+ "@babel/types": "^8.0.0"
42
+ },
43
+ "engines": {
44
+ "node": "^22.18.0 || >=24.11.0"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "tsup",