gtx-cli 2.5.0 → 2.5.1
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# gtx-cli
|
|
2
2
|
|
|
3
|
+
## 2.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#796](https://github.com/generaltranslation/gt/pull/796) [`855a653`](https://github.com/generaltranslation/gt/commit/855a6538e2a080fc73d97585df2a838f02a3d00a) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - fix: remove null vals from jsx children
|
|
8
|
+
|
|
3
9
|
## 2.5.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -5,7 +5,7 @@ import * as t from '@babel/types';
|
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import { parse } from '@babel/parser';
|
|
7
7
|
import addGTIdentifierToSyntaxTree from './addGTIdentifierToSyntaxTree.js';
|
|
8
|
-
import { warnHasUnwrappedExpressionSync, warnNestedTComponent, warnInvalidStaticChildSync,
|
|
8
|
+
import { warnHasUnwrappedExpressionSync, warnNestedTComponent, warnInvalidStaticChildSync, warnFunctionNotFoundSync, warnMissingReturnSync, warnDuplicateFunctionDefinitionSync, warnInvalidStaticInitSync, warnRecursiveFunctionCallSync, } from '../../../../console/index.js';
|
|
9
9
|
import { isAcceptedPluralForm } from 'generaltranslation/internal';
|
|
10
10
|
import { isStaticExpression } from '../../evaluateJsx.js';
|
|
11
11
|
import { STATIC_COMPONENT, TRANSLATION_COMPONENT, VARIABLE_COMPONENTS, } from '../constants.js';
|
|
@@ -18,6 +18,7 @@ import { parseTProps } from './parseTProps.js';
|
|
|
18
18
|
import { handleChildrenWhitespace } from './handleChildrenWhitespace.js';
|
|
19
19
|
import { isElementNode, } from './types.js';
|
|
20
20
|
import { multiplyJsxTree } from './multiplication/multiplyJsxTree.js';
|
|
21
|
+
import { removeNullChildrenFields } from './removeNullChildrenFields.js';
|
|
21
22
|
// Handle CommonJS/ESM interop
|
|
22
23
|
const traverse = traverseModule.default || traverseModule;
|
|
23
24
|
// TODO: currently we cover VariableDeclaration and FunctionDeclaration nodes, but are there others we should cover as well?
|
|
@@ -421,9 +422,11 @@ export function parseJSXElement({ importAliases, node, originalName, pkg, update
|
|
|
421
422
|
}
|
|
422
423
|
// <T> is valid here
|
|
423
424
|
for (const minifiedTree of minifiedTress) {
|
|
425
|
+
// Clean the tree by removing null 'c' fields from JsxElements
|
|
426
|
+
const cleanedTree = removeNullChildrenFields(minifiedTree);
|
|
424
427
|
updates.push({
|
|
425
428
|
dataFormat: 'JSX',
|
|
426
|
-
source:
|
|
429
|
+
source: cleanedTree,
|
|
427
430
|
// eslint-disable-next-line no-undef
|
|
428
431
|
metadata: { ...structuredClone(metadata) },
|
|
429
432
|
});
|
|
@@ -992,14 +995,21 @@ function processReturnExpression({ unwrappedExpressions, scopeNode, expressionNo
|
|
|
992
995
|
return result;
|
|
993
996
|
}
|
|
994
997
|
else {
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
998
|
+
return buildJSXTree({
|
|
999
|
+
importAliases,
|
|
1000
|
+
node: expressionNodePath.node,
|
|
1001
|
+
unwrappedExpressions,
|
|
1002
|
+
visited,
|
|
1003
|
+
callStack,
|
|
1004
|
+
updates,
|
|
1005
|
+
errors,
|
|
1006
|
+
warnings,
|
|
1007
|
+
file,
|
|
1008
|
+
insideT: true,
|
|
1009
|
+
parsingOptions,
|
|
1010
|
+
scopeNode,
|
|
1011
|
+
importedFunctionsMap,
|
|
1012
|
+
pkg,
|
|
1013
|
+
});
|
|
1004
1014
|
}
|
|
1005
1015
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { isVariable } from 'generaltranslation/internal';
|
|
2
|
+
export function removeNullChildrenFields(tree) {
|
|
3
|
+
return handleChildren(tree);
|
|
4
|
+
function handleChildren(children) {
|
|
5
|
+
if (Array.isArray(children)) {
|
|
6
|
+
return children.filter((child) => child != null).map(handleChild);
|
|
7
|
+
}
|
|
8
|
+
return handleChild(children);
|
|
9
|
+
}
|
|
10
|
+
function handleChild(child) {
|
|
11
|
+
if (typeof child === 'string') {
|
|
12
|
+
return child;
|
|
13
|
+
}
|
|
14
|
+
if (typeof child !== 'object' || child === null) {
|
|
15
|
+
return child;
|
|
16
|
+
}
|
|
17
|
+
if (isVariable(child)) {
|
|
18
|
+
return child;
|
|
19
|
+
}
|
|
20
|
+
// other fields
|
|
21
|
+
let t;
|
|
22
|
+
if (child && 't' in child && child.t != null) {
|
|
23
|
+
t = child.t;
|
|
24
|
+
}
|
|
25
|
+
let i;
|
|
26
|
+
if (child && 'i' in child && child.i != null) {
|
|
27
|
+
i = child.i;
|
|
28
|
+
}
|
|
29
|
+
// gtprop
|
|
30
|
+
let d;
|
|
31
|
+
if (child && 'd' in child && child.d != null) {
|
|
32
|
+
let b;
|
|
33
|
+
if (child.d && 'b' in child.d && child.d.b != null) {
|
|
34
|
+
b = {
|
|
35
|
+
...Object.fromEntries(Object.entries(child.d.b).map(([key, value]) => [
|
|
36
|
+
key,
|
|
37
|
+
handleChildren(value),
|
|
38
|
+
])),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
d = {
|
|
42
|
+
...(b != null && { b }),
|
|
43
|
+
...(child.d?.t != null && { t: child.d.t }),
|
|
44
|
+
...Object.fromEntries(Object.entries(child.d)
|
|
45
|
+
.filter(([key, value]) => key !== 'b' && key !== 't' && value != null)
|
|
46
|
+
.map(([key, value]) => [key, value])),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
// children
|
|
50
|
+
let c;
|
|
51
|
+
if (child && 'c' in child && child.c != null) {
|
|
52
|
+
c = handleChildren(child.c);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
...(t != null && { t }),
|
|
56
|
+
...(i != null && { i }),
|
|
57
|
+
...(d != null && { d }),
|
|
58
|
+
...(c != null && { c }),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|