@saykit/transform-jsx 0.0.0-beta-20260717182009 → 0.0.0-beta-20260717205137
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/README.md +2 -0
- package/dist/parser.mjs +3 -5
- package/package.json +3 -5
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
> JSX and TSX transformer for [SayKit](https://saykit.js.org).
|
|
4
4
|
|
|
5
|
+
[](https://codecov.io/gh/k0d13/saykit?flags%5B0%5D=transform-jsx)
|
|
6
|
+
|
|
5
7
|
Extracts and rewrites the `<Say>` macro (and its `<Say.Plural>`, `<Say.Ordinal>`, `<Say.Select>` sub-components) in `.jsx` and `.tsx` files. Used inside a `saykit.config.ts` bucket alongside [`@saykit/transform-js`](https://github.com/k0d13/saykit/tree/main/packages/transform-js).
|
|
6
8
|
|
|
7
9
|
## Install
|
package/dist/parser.mjs
CHANGED
|
@@ -83,13 +83,10 @@ function parseJSXElement(element, fallback) {
|
|
|
83
83
|
if (message) return message;
|
|
84
84
|
if (!fallback) return null;
|
|
85
85
|
if (element.openingElement.selfClosing) return new ElementMessage(AUTO_INCREMENT_IDENTIFIER, [], element);
|
|
86
|
-
|
|
87
|
-
if (wrapped) return new ElementMessage(AUTO_INCREMENT_IDENTIFIER, [wrapped], element);
|
|
88
|
-
return null;
|
|
86
|
+
return new ElementMessage(AUTO_INCREMENT_IDENTIFIER, [parseJSXElement(t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier("Say"), []), t.jsxClosingElement(t.jsxIdentifier("Say")), element.children), true)], element);
|
|
89
87
|
}
|
|
90
88
|
function getAttributeNameAsString(attribute) {
|
|
91
|
-
|
|
92
|
-
if (t.isJSXNamespacedName(attribute.name)) return attribute.name.name.name;
|
|
89
|
+
return t.isJSXIdentifier(attribute.name) ? attribute.name.name : attribute.name.name.name;
|
|
93
90
|
}
|
|
94
91
|
function findAttributeValueIfStringLiteralAsString(attributes, identifier) {
|
|
95
92
|
for (const attribute of attributes) {
|
|
@@ -118,6 +115,7 @@ function findAttributeValueAsBoolean(attributes, identifier) {
|
|
|
118
115
|
}
|
|
119
116
|
function getExpressionAsIdentifier(node) {
|
|
120
117
|
if (t.isIdentifier(node)) return node.name;
|
|
118
|
+
/* v8 ignore next */
|
|
121
119
|
if (t.isJSXIdentifier(node)) return node.name;
|
|
122
120
|
return AUTO_INCREMENT_IDENTIFIER;
|
|
123
121
|
}
|
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-20260717205137",
|
|
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.7",
|
|
48
48
|
"@babel/traverse": "^7.29.7",
|
|
49
49
|
"@babel/types": "^7.29.7",
|
|
50
|
-
"@saykit/config": "^0.0.0-beta-
|
|
51
|
-
"@saykit/transform-js": "^0.0.0-beta-
|
|
50
|
+
"@saykit/config": "^0.0.0-beta-20260717205137",
|
|
51
|
+
"@saykit/transform-js": "^0.0.0-beta-20260717205137"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@babel/core": "^7.29.7",
|
|
@@ -58,8 +58,6 @@
|
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"check": "tsc --noEmit",
|
|
61
|
-
"test": "vitest",
|
|
62
|
-
"coverage": "vitest run --coverage",
|
|
63
61
|
"build": "tsdown"
|
|
64
62
|
}
|
|
65
63
|
}
|