@saykit/transform-jsx 0.0.0-beta-20260422181516 → 0.0.0-beta-20260423010238
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/parser.mjs +11 -9
- package/package.json +3 -3
package/dist/parser.mjs
CHANGED
|
@@ -6,17 +6,19 @@ function parseJSXContainerElement(element) {
|
|
|
6
6
|
const processed = processJSXOpeningElement(element.openingElement);
|
|
7
7
|
if (!processed) return null;
|
|
8
8
|
const [accessor] = processed;
|
|
9
|
-
const children = element.children.reduce((c,
|
|
10
|
-
if (t.isJSXText(
|
|
11
|
-
|
|
12
|
-
if (
|
|
9
|
+
const children = element.children.reduce((p, c, i, a) => {
|
|
10
|
+
if (t.isJSXText(c)) {
|
|
11
|
+
let text = c.value.replace(/\s+/g, " ");
|
|
12
|
+
if (i === 0) text = text.trimStart();
|
|
13
|
+
if (i === a.length - 1) text = text.trimEnd();
|
|
14
|
+
if (text) p.push(new LiteralMessage(text));
|
|
13
15
|
}
|
|
14
|
-
if (t.isJSXElement(
|
|
15
|
-
else if (t.isJSXFragment(
|
|
16
|
-
else if (t.isJSXExpressionContainer(
|
|
17
|
-
if (t.isExpression(
|
|
16
|
+
if (t.isJSXElement(c)) p.push(parseJSXElement(c, true));
|
|
17
|
+
else if (t.isJSXFragment(c)) p.push(new ElementMessage(AUTO_INCREMENT_IDENTIFIER, [], c));
|
|
18
|
+
else if (t.isJSXExpressionContainer(c)) {
|
|
19
|
+
if (t.isExpression(c.expression)) p.push(new ArgumentMessage(getExpressionAsIdentifier(c.expression), c.expression));
|
|
18
20
|
}
|
|
19
|
-
return
|
|
21
|
+
return p;
|
|
20
22
|
}, []);
|
|
21
23
|
return new CompositeMessage({
|
|
22
24
|
id: findAttributeValueIfStringLiteralAsString(element.openingElement.attributes, "id"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saykit/transform-jsx",
|
|
3
|
-
"version": "0.0.0-beta-
|
|
3
|
+
"version": "0.0.0-beta-20260423010238",
|
|
4
4
|
"description": "JSX and TSX source transformer for SayKit",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"@babel/parser": "^7.29.2",
|
|
48
48
|
"@babel/traverse": "^7.29.0",
|
|
49
49
|
"@babel/types": "^7.29.0",
|
|
50
|
-
"@saykit/config": "^0.0.0-beta-
|
|
51
|
-
"@saykit/transform-js": "^0.0.0-beta-
|
|
50
|
+
"@saykit/config": "^0.0.0-beta-20260423010238",
|
|
51
|
+
"@saykit/transform-js": "^0.0.0-beta-20260423010238"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@babel/core": "^7.29.0",
|