gtx-cli 1.2.14 → 1.2.15

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.
Files changed (141) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +1 -2
  3. package/.env +0 -2
  4. package/dist/api/checkFileTranslations.d.ts +0 -19
  5. package/dist/api/checkFileTranslations.js +0 -244
  6. package/dist/api/downloadFile.d.ts +0 -1
  7. package/dist/api/downloadFile.js +0 -83
  8. package/dist/api/downloadFileBatch.d.ts +0 -16
  9. package/dist/api/downloadFileBatch.js +0 -127
  10. package/dist/api/fetchTranslations.d.ts +0 -10
  11. package/dist/api/fetchTranslations.js +0 -35
  12. package/dist/api/sendFiles.d.ts +0 -24
  13. package/dist/api/sendFiles.js +0 -63
  14. package/dist/api/sendUpdates.d.ts +0 -19
  15. package/dist/api/sendUpdates.js +0 -75
  16. package/dist/api/waitForUpdates.d.ts +0 -11
  17. package/dist/api/waitForUpdates.js +0 -96
  18. package/dist/cli/base.d.ts +0 -28
  19. package/dist/cli/base.js +0 -322
  20. package/dist/cli/next.d.ts +0 -10
  21. package/dist/cli/next.js +0 -27
  22. package/dist/cli/react.d.ts +0 -18
  23. package/dist/cli/react.js +0 -305
  24. package/dist/config/generateSettings.d.ts +0 -7
  25. package/dist/config/generateSettings.js +0 -94
  26. package/dist/config/utils.d.ts +0 -2
  27. package/dist/config/utils.js +0 -7
  28. package/dist/config/validateSettings.d.ts +0 -2
  29. package/dist/config/validateSettings.js +0 -23
  30. package/dist/console/colors.d.ts +0 -5
  31. package/dist/console/colors.js +0 -26
  32. package/dist/console/console.d.ts +0 -1
  33. package/dist/console/console.js +0 -20
  34. package/dist/console/errors.d.ts +0 -1
  35. package/dist/console/errors.js +0 -20
  36. package/dist/console/index.d.ts +0 -19
  37. package/dist/console/index.js +0 -48
  38. package/dist/console/logging.d.ts +0 -55
  39. package/dist/console/logging.js +0 -207
  40. package/dist/console/warnings.d.ts +0 -1
  41. package/dist/console/warnings.js +0 -20
  42. package/dist/formats/files/save.d.ts +0 -5
  43. package/dist/formats/files/save.js +0 -23
  44. package/dist/formats/files/supportedFiles.d.ts +0 -8
  45. package/dist/formats/files/supportedFiles.js +0 -17
  46. package/dist/formats/files/translate.d.ts +0 -14
  47. package/dist/formats/files/translate.js +0 -218
  48. package/dist/formats/gt/save.d.ts +0 -10
  49. package/dist/formats/gt/save.js +0 -34
  50. package/dist/fs/config/loadConfig.d.ts +0 -1
  51. package/dist/fs/config/loadConfig.js +0 -15
  52. package/dist/fs/config/parseFilesConfig.d.ts +0 -23
  53. package/dist/fs/config/parseFilesConfig.js +0 -128
  54. package/dist/fs/config/setupConfig.d.ts +0 -15
  55. package/dist/fs/config/setupConfig.js +0 -51
  56. package/dist/fs/config/updateConfig.d.ts +0 -11
  57. package/dist/fs/config/updateConfig.js +0 -41
  58. package/dist/fs/determineFramework.d.ts +0 -5
  59. package/dist/fs/determineFramework.js +0 -52
  60. package/dist/fs/findFilepath.d.ts +0 -36
  61. package/dist/fs/findFilepath.js +0 -101
  62. package/dist/fs/findJsxFilepath.d.ts +0 -7
  63. package/dist/fs/findJsxFilepath.js +0 -36
  64. package/dist/fs/index.d.ts +0 -1
  65. package/dist/fs/index.js +0 -2
  66. package/dist/fs/loadJSON.d.ts +0 -6
  67. package/dist/fs/loadJSON.js +0 -23
  68. package/dist/fs/saveJSON.d.ts +0 -1
  69. package/dist/fs/saveJSON.js +0 -13
  70. package/dist/fs/utils.d.ts +0 -1
  71. package/dist/fs/utils.js +0 -19
  72. package/dist/hooks/postProcess.d.ts +0 -4
  73. package/dist/hooks/postProcess.js +0 -118
  74. package/dist/index.d.ts +0 -3
  75. package/dist/index.js +0 -24
  76. package/dist/main.d.ts +0 -2
  77. package/dist/main.js +0 -12
  78. package/dist/next/config/parseNextConfig.d.ts +0 -10
  79. package/dist/next/config/parseNextConfig.js +0 -59
  80. package/dist/next/jsx/utils.d.ts +0 -7
  81. package/dist/next/jsx/utils.js +0 -82
  82. package/dist/next/parse/handleInitGT.d.ts +0 -1
  83. package/dist/next/parse/handleInitGT.js +0 -153
  84. package/dist/next/parse/wrapContent.d.ts +0 -11
  85. package/dist/next/parse/wrapContent.js +0 -181
  86. package/dist/react/config/createESBuildConfig.d.ts +0 -2
  87. package/dist/react/config/createESBuildConfig.js +0 -125
  88. package/dist/react/data-_gt/addGTIdentifierToSyntaxTree.d.ts +0 -1
  89. package/dist/react/data-_gt/addGTIdentifierToSyntaxTree.js +0 -87
  90. package/dist/react/jsx/evaluateJsx.d.ts +0 -17
  91. package/dist/react/jsx/evaluateJsx.js +0 -133
  92. package/dist/react/jsx/parse/parseStringFunction.d.ts +0 -12
  93. package/dist/react/jsx/parse/parseStringFunction.js +0 -118
  94. package/dist/react/jsx/trimJsxStringChildren.d.ts +0 -7
  95. package/dist/react/jsx/trimJsxStringChildren.js +0 -100
  96. package/dist/react/jsx/utils/parseAst.d.ts +0 -30
  97. package/dist/react/jsx/utils/parseAst.js +0 -319
  98. package/dist/react/jsx/utils/parseJsx.d.ts +0 -13
  99. package/dist/react/jsx/utils/parseJsx.js +0 -250
  100. package/dist/react/jsx/utils/parseStringFunction.d.ts +0 -12
  101. package/dist/react/jsx/utils/parseStringFunction.js +0 -121
  102. package/dist/react/jsx/wrapJsx.d.ts +0 -51
  103. package/dist/react/jsx/wrapJsx.js +0 -411
  104. package/dist/react/parse/createDictionaryUpdates.d.ts +0 -3
  105. package/dist/react/parse/createDictionaryUpdates.js +0 -78
  106. package/dist/react/parse/createInlineUpdates.d.ts +0 -5
  107. package/dist/react/parse/createInlineUpdates.js +0 -135
  108. package/dist/react/parse/wrapContent.d.ts +0 -11
  109. package/dist/react/parse/wrapContent.js +0 -197
  110. package/dist/react/utils/flattenDictionary.d.ts +0 -20
  111. package/dist/react/utils/flattenDictionary.js +0 -79
  112. package/dist/react/utils/getEntryAndMetadata.d.ts +0 -5
  113. package/dist/react/utils/getEntryAndMetadata.js +0 -14
  114. package/dist/react/utils/getVariableName.d.ts +0 -2
  115. package/dist/react/utils/getVariableName.js +0 -17
  116. package/dist/setup/userInput.d.ts +0 -4
  117. package/dist/setup/userInput.js +0 -35
  118. package/dist/setup/wizard.d.ts +0 -2
  119. package/dist/setup/wizard.js +0 -171
  120. package/dist/translation/parse.d.ts +0 -14
  121. package/dist/translation/parse.js +0 -82
  122. package/dist/translation/stage.d.ts +0 -5
  123. package/dist/translation/stage.js +0 -80
  124. package/dist/translation/translate.d.ts +0 -2
  125. package/dist/translation/translate.js +0 -21
  126. package/dist/types/api.d.ts +0 -6
  127. package/dist/types/api.js +0 -2
  128. package/dist/types/data.d.ts +0 -31
  129. package/dist/types/data.js +0 -2
  130. package/dist/types/index.d.ts +0 -101
  131. package/dist/types/index.js +0 -2
  132. package/dist/utils/constants.d.ts +0 -1
  133. package/dist/utils/constants.js +0 -4
  134. package/dist/utils/credentials.d.ts +0 -12
  135. package/dist/utils/credentials.js +0 -128
  136. package/dist/utils/installPackage.d.ts +0 -2
  137. package/dist/utils/installPackage.js +0 -45
  138. package/dist/utils/packageJson.d.ts +0 -5
  139. package/dist/utils/packageJson.js +0 -78
  140. package/dist/utils/packageManager.d.ts +0 -23
  141. package/dist/utils/packageManager.js +0 -261
@@ -1,250 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.buildJSXTree = buildJSXTree;
40
- exports.parseJSXElement = parseJSXElement;
41
- const generator_1 = __importDefault(require("@babel/generator"));
42
- const t = __importStar(require("@babel/types"));
43
- const addGTIdentifierToSyntaxTree_1 = __importDefault(require("../../data-_gt/addGTIdentifierToSyntaxTree"));
44
- const console_1 = require("../../../console");
45
- const internal_1 = require("generaltranslation/internal");
46
- const trimJsxStringChildren_1 = require("../trimJsxStringChildren");
47
- const evaluateJsx_1 = require("../evaluateJsx");
48
- // Valid variable components
49
- const VARIABLE_COMPONENTS = ['Var', 'DateTime', 'Currency', 'Num'];
50
- /**
51
- * Builds a JSX tree from a given node, recursively handling children.
52
- * @param node - The node to build the tree from
53
- * @param unwrappedExpressions - An array to store unwrapped expressions
54
- * @param updates - The updates array
55
- * @param errors - The errors array
56
- * @param file - The file name
57
- * @returns The built JSX tree
58
- */
59
- function buildJSXTree(importAliases, node, unwrappedExpressions, updates, errors, file) {
60
- if (t.isJSXExpressionContainer(node)) {
61
- // Skip JSX comments
62
- if (t.isJSXEmptyExpression(node.expression)) {
63
- return null;
64
- }
65
- const expr = node.expression;
66
- const staticAnalysis = (0, evaluateJsx_1.isStaticExpression)(expr);
67
- if (staticAnalysis.isStatic && staticAnalysis.value !== undefined) {
68
- // Preserve the exact whitespace for static string expressions
69
- return {
70
- expression: true,
71
- result: staticAnalysis.value,
72
- };
73
- }
74
- // Keep existing behavior for non-static expressions
75
- const code = (0, generator_1.default)(node).code;
76
- unwrappedExpressions.push(code); // Keep track of unwrapped expressions for error reporting
77
- return code;
78
- }
79
- else if (t.isJSXText(node)) {
80
- // Updated JSX Text handling
81
- // JSX Text handling following React's rules
82
- let text = node.value;
83
- return text;
84
- }
85
- else if (t.isJSXElement(node)) {
86
- const element = node;
87
- const elementName = element.openingElement.name;
88
- let typeName;
89
- if (t.isJSXIdentifier(elementName)) {
90
- typeName = elementName.name;
91
- }
92
- else if (t.isJSXMemberExpression(elementName)) {
93
- typeName = (0, generator_1.default)(elementName).code;
94
- }
95
- else {
96
- typeName = null;
97
- }
98
- // Convert from alias to original name
99
- const componentType = importAliases[typeName ?? ''];
100
- // If this JSXElement is one of the recognized variable components,
101
- const elementIsVariable = VARIABLE_COMPONENTS.includes(componentType);
102
- const props = {};
103
- const elementIsPlural = componentType === 'Plural';
104
- const elementIsBranch = componentType === 'Branch';
105
- element.openingElement.attributes.forEach((attr) => {
106
- if (t.isJSXAttribute(attr)) {
107
- const attrName = attr.name.name;
108
- let attrValue = null;
109
- if (attr.value) {
110
- if (t.isStringLiteral(attr.value)) {
111
- attrValue = attr.value.value;
112
- }
113
- else if (t.isJSXExpressionContainer(attr.value)) {
114
- if ((elementIsPlural && (0, internal_1.isAcceptedPluralForm)(attrName)) ||
115
- (elementIsBranch && attrName !== 'branch')) {
116
- // Make sure that variable strings like {`I have ${count} book`} are invalid!
117
- if (t.isTemplateLiteral(attr.value.expression) &&
118
- !(0, evaluateJsx_1.isStaticExpression)(attr.value.expression).isStatic) {
119
- unwrappedExpressions.push((0, generator_1.default)(attr.value).code);
120
- }
121
- }
122
- attrValue = buildJSXTree(importAliases, attr.value.expression, unwrappedExpressions, updates, errors, file);
123
- }
124
- }
125
- props[attrName] = attrValue;
126
- }
127
- });
128
- if (elementIsVariable) {
129
- parseJSXElement(importAliases, element, updates, errors, file);
130
- return {
131
- type: componentType,
132
- props,
133
- };
134
- }
135
- const children = element.children
136
- .map((child) => buildJSXTree(importAliases, child, unwrappedExpressions, updates, errors, file))
137
- .filter((child) => child !== null && child !== '');
138
- if (children.length === 1) {
139
- props.children = children[0];
140
- }
141
- else if (children.length > 1) {
142
- props.children = children;
143
- }
144
- return {
145
- type: componentType,
146
- props,
147
- };
148
- }
149
- // If it's a JSX fragment
150
- else if (t.isJSXFragment(node)) {
151
- const children = node.children
152
- .map((child) => buildJSXTree(importAliases, child, unwrappedExpressions, updates, errors, file))
153
- .filter((child) => child !== null && child !== '');
154
- const props = {};
155
- if (children.length === 1) {
156
- props.children = children[0];
157
- }
158
- else if (children.length > 1) {
159
- props.children = children;
160
- }
161
- return {
162
- type: '',
163
- props,
164
- };
165
- }
166
- // If it's a string literal (standalone)
167
- else if (t.isStringLiteral(node)) {
168
- return node.value;
169
- }
170
- // If it's some other JS expression
171
- else if (t.isIdentifier(node) ||
172
- t.isMemberExpression(node) ||
173
- t.isCallExpression(node) ||
174
- t.isBinaryExpression(node) ||
175
- t.isLogicalExpression(node) ||
176
- t.isConditionalExpression(node)) {
177
- return (0, generator_1.default)(node).code;
178
- }
179
- else {
180
- return (0, generator_1.default)(node).code;
181
- }
182
- }
183
- // end buildJSXTree
184
- // Parses a JSX element and adds it to the updates array
185
- function parseJSXElement(importAliases, node, updates, errors, file) {
186
- const openingElement = node.openingElement;
187
- const name = openingElement.name;
188
- // Only proceed if it's <T> ...
189
- if (name.type === 'JSXIdentifier' && importAliases[name.name] === 'T') {
190
- const componentObj = { props: {} };
191
- // We'll track this flag to know if any unwrapped {variable} is found in children
192
- const unwrappedExpressions = [];
193
- // Gather <T>'s props
194
- openingElement.attributes.forEach((attr) => {
195
- if (!t.isJSXAttribute(attr))
196
- return;
197
- const attrName = attr.name.name;
198
- if (typeof attrName !== 'string')
199
- return;
200
- if (attr.value) {
201
- // If it's a plain string literal like id="hello"
202
- if (t.isStringLiteral(attr.value)) {
203
- componentObj.props[attrName] = attr.value.value;
204
- }
205
- // If it's an expression container like id={"hello"}, id={someVar}, etc.
206
- else if (t.isJSXExpressionContainer(attr.value)) {
207
- const expr = attr.value.expression;
208
- const code = (0, generator_1.default)(expr).code;
209
- // Only check for static expressions on id and context props
210
- if (attrName === 'id' || attrName === 'context') {
211
- const staticAnalysis = (0, evaluateJsx_1.isStaticExpression)(expr);
212
- if (!staticAnalysis.isStatic) {
213
- errors.push((0, console_1.warnVariablePropSync)(file, attrName, code, `${expr.loc?.start?.line}:${expr.loc?.start?.column}`));
214
- }
215
- // Use the static value if available
216
- if (staticAnalysis.isStatic && staticAnalysis.value !== undefined) {
217
- componentObj.props[attrName] = staticAnalysis.value;
218
- }
219
- else {
220
- // Only store the code if we couldn't extract a static value
221
- componentObj.props[attrName] = code;
222
- }
223
- }
224
- else {
225
- // For other attributes that aren't id or context
226
- componentObj.props[attrName] = code;
227
- }
228
- }
229
- }
230
- });
231
- // Build the JSX tree for this component
232
- const initialTree = buildJSXTree(importAliases, node, unwrappedExpressions, updates, errors, file).props.children;
233
- const whitespaceHandledTree = (0, trimJsxStringChildren_1.handleChildrenWhitespace)(initialTree);
234
- const tree = (0, addGTIdentifierToSyntaxTree_1.default)(whitespaceHandledTree);
235
- componentObj.tree = tree.length === 1 ? tree[0] : tree;
236
- const id = componentObj.props.id;
237
- // If we found an unwrapped expression, skip
238
- if (unwrappedExpressions.length > 0) {
239
- errors.push((0, console_1.warnHasUnwrappedExpressionSync)(file, unwrappedExpressions, id, `${node.loc?.start?.line}:${node.loc?.start?.column}`));
240
- }
241
- if (errors.length > 0)
242
- return;
243
- // <T> is valid here
244
- updates.push({
245
- dataFormat: 'JSX',
246
- source: componentObj.tree,
247
- metadata: componentObj.props,
248
- });
249
- }
250
- }
@@ -1,12 +0,0 @@
1
- import { NodePath } from '@babel/traverse';
2
- import { Updates } from '../../../types';
3
- export declare const attributes: string[];
4
- /**
5
- * For the following example code:
6
- * const t = useGT();
7
- * t('string to translate', { id: 'exampleId', context: 'exampleContext' });
8
- *
9
- * This function will find all call expressions of useGT(), then find all call expressions
10
- * of the subsequent tx() calls, and append the content and metadata to the updates array.
11
- */
12
- export declare function parseStrings(importName: string, path: NodePath, updates: Updates, errors: string[], file: string): void;
@@ -1,121 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.attributes = void 0;
40
- exports.parseStrings = parseStrings;
41
- const generaltranslation_1 = require("generaltranslation");
42
- const t = __importStar(require("@babel/types"));
43
- const evaluateJsx_1 = require("../evaluateJsx");
44
- const console_1 = require("../../../console");
45
- const generator_1 = __importDefault(require("@babel/generator"));
46
- exports.attributes = ['id', 'context'];
47
- /**
48
- * For the following example code:
49
- * const t = useGT();
50
- * t('string to translate', { id: 'exampleId', context: 'exampleContext' });
51
- *
52
- * This function will find all call expressions of useGT(), then find all call expressions
53
- * of the subsequent tx() calls, and append the content and metadata to the updates array.
54
- */
55
- function parseStrings(importName, path, updates, errors, file) {
56
- path.scope.bindings[importName]?.referencePaths.forEach((refPath) => {
57
- // Find call expressions of useGT() / await getGT()
58
- const callExpr = refPath.findParent((p) => p.isCallExpression());
59
- if (callExpr) {
60
- // Get the parent, handling both await and non-await cases
61
- const parentPath = callExpr.parentPath;
62
- const effectiveParent = parentPath?.node.type === 'AwaitExpression'
63
- ? parentPath.parentPath
64
- : parentPath;
65
- if (effectiveParent &&
66
- effectiveParent.node.type === 'VariableDeclarator' &&
67
- effectiveParent.node.id.type === 'Identifier') {
68
- const tFuncName = effectiveParent.node.id.name;
69
- // Get the scope from the variable declaration
70
- const variableScope = effectiveParent.scope;
71
- variableScope.bindings[tFuncName]?.referencePaths.forEach((tPath) => {
72
- if (tPath.parent.type === 'CallExpression' &&
73
- tPath.parent.arguments.length > 0) {
74
- const arg = tPath.parent.arguments[0];
75
- if (arg.type === 'StringLiteral' ||
76
- (t.isTemplateLiteral(arg) && arg.expressions.length === 0)) {
77
- const source = arg.type === 'StringLiteral'
78
- ? arg.value
79
- : arg.quasis[0].value.raw;
80
- // split the string into content (same as runtime behavior)
81
- const content = (0, generaltranslation_1.splitStringToContent)(source);
82
- // get metadata and id from options
83
- const options = tPath.parent.arguments[1];
84
- let metadata = {};
85
- if (options && options.type === 'ObjectExpression') {
86
- options.properties.forEach((prop) => {
87
- if (prop.type === 'ObjectProperty' &&
88
- prop.key.type === 'Identifier') {
89
- const attribute = prop.key.name;
90
- if (exports.attributes.includes(attribute) &&
91
- t.isExpression(prop.value)) {
92
- const result = (0, evaluateJsx_1.isStaticExpression)(prop.value);
93
- if (!result.isStatic) {
94
- errors.push((0, console_1.warnNonStaticExpressionSync)(file, attribute, (0, generator_1.default)(prop.value).code, `${prop.loc?.start?.line}:${prop.loc?.start?.column}`));
95
- }
96
- if (result.isStatic && result.value) {
97
- metadata[attribute] = result.value;
98
- }
99
- }
100
- }
101
- });
102
- }
103
- updates.push({
104
- dataFormat: 'JSX',
105
- source: content,
106
- metadata,
107
- });
108
- }
109
- else if (t.isTemplateLiteral(arg)) {
110
- // warn if template literal
111
- errors.push((0, console_1.warnTemplateLiteralSync)(file, (0, generator_1.default)(arg).code, `${arg.loc?.start?.line}:${arg.loc?.start?.column}`));
112
- }
113
- else {
114
- errors.push((0, console_1.warnNonStringSync)(file, (0, generator_1.default)(arg).code, `${arg.loc?.start?.line}:${arg.loc?.start?.column}`));
115
- }
116
- }
117
- });
118
- }
119
- }
120
- });
121
- }
@@ -1,51 +0,0 @@
1
- import * as t from '@babel/types';
2
- import { ImportItem } from './utils/parseAst';
3
- /**
4
- * Recursively wraps a JSX element with a <T> component and unique id
5
- * @param node - The JSX element to wrap
6
- * @param updates - The updates array
7
- * @param errors - The errors array
8
- * @param file - The file name
9
- * @param options - Optional component names for T and Var
10
- */
11
- export interface WrapResult {
12
- node: t.JSXElement | t.JSXFragment;
13
- hasMeaningfulContent: boolean;
14
- wrappedInT: boolean;
15
- }
16
- /**
17
- * Recursively traverse a JSX element and wrap variables with a <Var> component
18
- * @param node - The JSX element to wrap
19
- * @param options - Optional component names for T and Var
20
- * @param isMeaningful - A function to determine if a node is meaningful
21
- * @returns The wrapped JSX element
22
- */
23
- export declare function wrapJsxElement(node: t.JSXElement | t.JSXFragment, options: {
24
- createIds: boolean;
25
- TComponent?: string;
26
- VarComponent?: string;
27
- idPrefix: string;
28
- idCount: number;
29
- usedImports: ImportItem[];
30
- modified: boolean;
31
- warnings: string[];
32
- file: string;
33
- }, isMeaningful: (node: t.Node) => boolean, mark: boolean): WrapResult;
34
- /**
35
- * Wraps a JSX element with a <T> component and unique id
36
- * @param rootNode - The JSX element to wrap
37
- * @param options - Optional component names for T and Var
38
- * @param isMeaningful - A function to determine if a node is meaningful
39
- * @returns The wrapped JSX element
40
- */
41
- export declare function handleJsxElement(rootNode: t.JSXElement | t.JSXFragment, options: {
42
- createIds: boolean;
43
- usedImports: ImportItem[];
44
- TComponent?: string;
45
- VarComponent?: string;
46
- idPrefix: string;
47
- idCount: number;
48
- modified: boolean;
49
- warnings: string[];
50
- file: string;
51
- }, isMeaningful: (node: t.Node) => boolean): WrapResult;