@generaltranslation/compiler 1.3.22 → 1.3.23

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 (226) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +23 -0
  2. package/dist/config.js +32 -27
  3. package/dist/config.js.map +1 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +120 -187
  7. package/dist/index.js.map +1 -1
  8. package/dist/passes/basePass.js +40 -83
  9. package/dist/passes/basePass.js.map +1 -1
  10. package/dist/passes/collectionPass.js +18 -11
  11. package/dist/passes/collectionPass.js.map +1 -1
  12. package/dist/passes/handleErrors.js +21 -30
  13. package/dist/passes/handleErrors.js.map +1 -1
  14. package/dist/passes/injectionPass.js +15 -9
  15. package/dist/passes/injectionPass.js.map +1 -1
  16. package/dist/passes/jsxInsertionPass.js +33 -31
  17. package/dist/passes/jsxInsertionPass.js.map +1 -1
  18. package/dist/passes/macroExpansionPass.js +28 -26
  19. package/dist/passes/macroExpansionPass.js.map +1 -1
  20. package/dist/passes/runtimeTranslatePass.js +37 -35
  21. package/dist/passes/runtimeTranslatePass.js.map +1 -1
  22. package/dist/processing/collection/processCallExpression.js +144 -249
  23. package/dist/processing/collection/processCallExpression.js.map +1 -1
  24. package/dist/processing/collection/processTaggedTemplateExpression.js +38 -75
  25. package/dist/processing/collection/processTaggedTemplateExpression.js.map +1 -1
  26. package/dist/processing/collection/processVariableDeclarator.js +20 -18
  27. package/dist/processing/collection/processVariableDeclarator.js.map +1 -1
  28. package/dist/processing/index.js +29 -31
  29. package/dist/processing/injection/processCallExpression.js +69 -142
  30. package/dist/processing/injection/processCallExpression.js.map +1 -1
  31. package/dist/processing/injection/processVariableDeclarator.js +22 -20
  32. package/dist/processing/injection/processVariableDeclarator.js.map +1 -1
  33. package/dist/processing/jsx-insertion/processCallExpression.js +284 -393
  34. package/dist/processing/jsx-insertion/processCallExpression.js.map +1 -1
  35. package/dist/processing/jsx-insertion/processImportDeclaration.js +37 -83
  36. package/dist/processing/jsx-insertion/processImportDeclaration.js.map +1 -1
  37. package/dist/processing/jsx-insertion/processProgram.js +26 -66
  38. package/dist/processing/jsx-insertion/processProgram.js.map +1 -1
  39. package/dist/processing/macro-expansion/processImportDeclaration.js +21 -55
  40. package/dist/processing/macro-expansion/processImportDeclaration.js.map +1 -1
  41. package/dist/processing/macro-expansion/processProgram.js +20 -26
  42. package/dist/processing/macro-expansion/processProgram.js.map +1 -1
  43. package/dist/processing/macro-expansion/processTaggedTemplateExpression.js +33 -69
  44. package/dist/processing/macro-expansion/processTaggedTemplateExpression.js.map +1 -1
  45. package/dist/processing/processArrowFunctionExpression.js +18 -16
  46. package/dist/processing/processArrowFunctionExpression.js.map +1 -1
  47. package/dist/processing/processAssignmentExpression.js +12 -10
  48. package/dist/processing/processAssignmentExpression.js.map +1 -1
  49. package/dist/processing/processCatchClause.js +18 -16
  50. package/dist/processing/processCatchClause.js.map +1 -1
  51. package/dist/processing/processClassDeclaration.js +18 -16
  52. package/dist/processing/processClassDeclaration.js.map +1 -1
  53. package/dist/processing/processClassMethod.js +18 -17
  54. package/dist/processing/processClassMethod.js.map +1 -1
  55. package/dist/processing/processClassPrivateMethod.js +18 -17
  56. package/dist/processing/processClassPrivateMethod.js.map +1 -1
  57. package/dist/processing/processForInStatement.js +18 -16
  58. package/dist/processing/processForInStatement.js.map +1 -1
  59. package/dist/processing/processForOfStatement.js +18 -16
  60. package/dist/processing/processForOfStatement.js.map +1 -1
  61. package/dist/processing/processFunctionDeclaration.js +20 -18
  62. package/dist/processing/processFunctionDeclaration.js.map +1 -1
  63. package/dist/processing/processFunctionExpression.js +26 -24
  64. package/dist/processing/processFunctionExpression.js.map +1 -1
  65. package/dist/processing/processImportDeclaration.js +11 -9
  66. package/dist/processing/processImportDeclaration.js.map +1 -1
  67. package/dist/processing/processObjectMethod.js +19 -18
  68. package/dist/processing/processObjectMethod.js.map +1 -1
  69. package/dist/processing/processProgram.js +13 -13
  70. package/dist/processing/processProgram.js.map +1 -1
  71. package/dist/processing/processScopeChange.js +15 -13
  72. package/dist/processing/processScopeChange.js.map +1 -1
  73. package/dist/processing/runtime-translate/processImportDeclaration.js +30 -63
  74. package/dist/processing/runtime-translate/processImportDeclaration.js.map +1 -1
  75. package/dist/processing/runtime-translate/processProgram.js +34 -57
  76. package/dist/processing/runtime-translate/processProgram.js.map +1 -1
  77. package/dist/state/ErrorTracker.js +18 -17
  78. package/dist/state/ErrorTracker.js.map +1 -1
  79. package/dist/state/Logger.js +42 -52
  80. package/dist/state/Logger.js.map +1 -1
  81. package/dist/state/ScopeTracker.js +154 -209
  82. package/dist/state/ScopeTracker.js.map +1 -1
  83. package/dist/state/StringCollector.js +165 -184
  84. package/dist/state/StringCollector.js.map +1 -1
  85. package/dist/state/types.js +1 -3
  86. package/dist/state/utils/initializeState.js +62 -67
  87. package/dist/state/utils/initializeState.js.map +1 -1
  88. package/dist/transform/getTrackedVariable.js +33 -38
  89. package/dist/transform/getTrackedVariable.js.map +1 -1
  90. package/dist/transform/injection/callbacks/injectUseGTCallbackParameters.js +19 -27
  91. package/dist/transform/injection/callbacks/injectUseGTCallbackParameters.js.map +1 -1
  92. package/dist/transform/injection/callbacks/injectUseMessagesCallbackParameters.js +8 -6
  93. package/dist/transform/injection/callbacks/injectUseMessagesCallbackParameters.js.map +1 -1
  94. package/dist/transform/injection/callbacks/injectUseTranslationsCallbackParameters.js +8 -6
  95. package/dist/transform/injection/callbacks/injectUseTranslationsCallbackParameters.js.map +1 -1
  96. package/dist/transform/injection/injectCallbackDeclaratorFunctionParameters.js +74 -155
  97. package/dist/transform/injection/injectCallbackDeclaratorFunctionParameters.js.map +1 -1
  98. package/dist/transform/injection/injectHashIntoTranslationOptions.js +21 -61
  99. package/dist/transform/injection/injectHashIntoTranslationOptions.js.map +1 -1
  100. package/dist/transform/injection/injectStandaloneTFunctionParameters.js +21 -27
  101. package/dist/transform/injection/injectStandaloneTFunctionParameters.js.map +1 -1
  102. package/dist/transform/injection/injectTComponentParameters.js +25 -65
  103. package/dist/transform/injection/injectTComponentParameters.js.map +1 -1
  104. package/dist/transform/jsx-children/constructJsxChildren.js +273 -392
  105. package/dist/transform/jsx-children/constructJsxChildren.js.map +1 -1
  106. package/dist/transform/jsx-children/errors.js +16 -6
  107. package/dist/transform/jsx-children/errors.js.map +1 -1
  108. package/dist/transform/jsx-children/index.js +3 -6
  109. package/dist/transform/jsx-children/utils/getBranchComponentParameters.js +26 -85
  110. package/dist/transform/jsx-children/utils/getBranchComponentParameters.js.map +1 -1
  111. package/dist/transform/jsx-children/utils/getCalleeNameFromJsxExpressionParam.js +33 -66
  112. package/dist/transform/jsx-children/utils/getCalleeNameFromJsxExpressionParam.js.map +1 -1
  113. package/dist/transform/jsx-children/utils/id.js +18 -17
  114. package/dist/transform/jsx-children/utils/id.js.map +1 -1
  115. package/dist/transform/jsx-children/validation/validateChildrenElement.js +13 -47
  116. package/dist/transform/jsx-children/validation/validateChildrenElement.js.map +1 -1
  117. package/dist/transform/jsx-children/validation/validateChildrenFromArgs.js +25 -63
  118. package/dist/transform/jsx-children/validation/validateChildrenFromArgs.js.map +1 -1
  119. package/dist/transform/jsx-children/validation/validateIdentifier.js +38 -41
  120. package/dist/transform/jsx-children/validation/validateIdentifier.js.map +1 -1
  121. package/dist/transform/jsx-children/validation/validateJsxCall.js +15 -26
  122. package/dist/transform/jsx-children/validation/validateJsxCall.js.map +1 -1
  123. package/dist/transform/jsx-children/validation/validateNameFieldForVarComponent.js +33 -61
  124. package/dist/transform/jsx-children/validation/validateNameFieldForVarComponent.js.map +1 -1
  125. package/dist/transform/jsx-children/validation/validateStringLiteralPropertyFromArg.js +38 -66
  126. package/dist/transform/jsx-children/validation/validateStringLiteralPropertyFromArg.js.map +1 -1
  127. package/dist/transform/jsx-children/validation/validateTemplateLiteral.js +17 -13
  128. package/dist/transform/jsx-children/validation/validateTemplateLiteral.js.map +1 -1
  129. package/dist/transform/jsx-children/validation/validateUnaryExpression.js +26 -61
  130. package/dist/transform/jsx-children/validation/validateUnaryExpression.js.map +1 -1
  131. package/dist/transform/jsx-insertion/injectJsxInsertionImport.js +16 -48
  132. package/dist/transform/jsx-insertion/injectJsxInsertionImport.js.map +1 -1
  133. package/dist/transform/macro-expansion/injectMacroImport.js +14 -43
  134. package/dist/transform/macro-expansion/injectMacroImport.js.map +1 -1
  135. package/dist/transform/macro-expansion/transformTemplateLiteral.js +23 -22
  136. package/dist/transform/macro-expansion/transformTemplateLiteral.js.map +1 -1
  137. package/dist/transform/registration/callbacks/registerUseGTCallback.js +27 -34
  138. package/dist/transform/registration/callbacks/registerUseGTCallback.js.map +1 -1
  139. package/dist/transform/registration/callbacks/registerUseMessagesCallback.js +9 -9
  140. package/dist/transform/registration/callbacks/registerUseMessagesCallback.js.map +1 -1
  141. package/dist/transform/registration/callbacks/registerUseTranslationsCallback.js +9 -9
  142. package/dist/transform/registration/callbacks/registerUseTranslationsCallback.js.map +1 -1
  143. package/dist/transform/registration/registerStandaloneTranslation.js +27 -28
  144. package/dist/transform/registration/registerStandaloneTranslation.js.map +1 -1
  145. package/dist/transform/registration/registerTranslationComponent.js +15 -15
  146. package/dist/transform/registration/registerTranslationComponent.js.map +1 -1
  147. package/dist/transform/runtime-translate/buildRuntimeTranslateCalls.js +34 -85
  148. package/dist/transform/runtime-translate/buildRuntimeTranslateCalls.js.map +1 -1
  149. package/dist/transform/runtime-translate/injectRuntimeTranslateImport.js +25 -55
  150. package/dist/transform/runtime-translate/injectRuntimeTranslateImport.js.map +1 -1
  151. package/dist/transform/tracking/trackAssignmentExpression.js +26 -63
  152. package/dist/transform/tracking/trackAssignmentExpression.js.map +1 -1
  153. package/dist/transform/tracking/trackCatchClause.js +17 -48
  154. package/dist/transform/tracking/trackCatchClause.js.map +1 -1
  155. package/dist/transform/tracking/trackClassDeclaration.js +13 -13
  156. package/dist/transform/tracking/trackClassDeclaration.js.map +1 -1
  157. package/dist/transform/tracking/trackForDeclaration.js +17 -53
  158. package/dist/transform/tracking/trackForDeclaration.js.map +1 -1
  159. package/dist/transform/tracking/trackFunctionName.js +10 -10
  160. package/dist/transform/tracking/trackFunctionName.js.map +1 -1
  161. package/dist/transform/tracking/trackFunctionParams.js +19 -54
  162. package/dist/transform/tracking/trackFunctionParams.js.map +1 -1
  163. package/dist/transform/tracking/trackImportDeclaration.js +36 -89
  164. package/dist/transform/tracking/trackImportDeclaration.js.map +1 -1
  165. package/dist/transform/tracking/trackOverridingVariable.js +9 -11
  166. package/dist/transform/tracking/trackOverridingVariable.js.map +1 -1
  167. package/dist/transform/tracking/trackVariableDeclarator.js +51 -102
  168. package/dist/transform/tracking/trackVariableDeclarator.js.map +1 -1
  169. package/dist/transform/validation/validateTranslationComponentArgs.js +156 -232
  170. package/dist/transform/validation/validateTranslationComponentArgs.js.map +1 -1
  171. package/dist/transform/validation/validateTranslationFunction.js +218 -329
  172. package/dist/transform/validation/validateTranslationFunction.js.map +1 -1
  173. package/dist/utils/calculateHash.js +55 -70
  174. package/dist/utils/calculateHash.js.map +1 -1
  175. package/dist/utils/constants/gt/constants.js +142 -132
  176. package/dist/utils/constants/gt/constants.js.map +1 -1
  177. package/dist/utils/constants/gt/helpers.js +147 -149
  178. package/dist/utils/constants/gt/helpers.js.map +1 -1
  179. package/dist/utils/constants/other/constants.js +45 -41
  180. package/dist/utils/constants/other/constants.js.map +1 -1
  181. package/dist/utils/constants/other/helpers.js +13 -11
  182. package/dist/utils/constants/other/helpers.js.map +1 -1
  183. package/dist/utils/constants/react/constants.js +47 -41
  184. package/dist/utils/constants/react/constants.js.map +1 -1
  185. package/dist/utils/constants/react/helpers.js +17 -16
  186. package/dist/utils/constants/react/helpers.js.map +1 -1
  187. package/dist/utils/constants/resolveIdentifier/isGTComponent.js +41 -76
  188. package/dist/utils/constants/resolveIdentifier/isGTComponent.js.map +1 -1
  189. package/dist/utils/constants/resolveIdentifier/isReactJsxFunction.js +33 -83
  190. package/dist/utils/constants/resolveIdentifier/isReactJsxFunction.js.map +1 -1
  191. package/dist/utils/errors.js +18 -20
  192. package/dist/utils/errors.js.map +1 -1
  193. package/dist/utils/multiplication/multiply.js +31 -35
  194. package/dist/utils/multiplication/multiply.js.map +1 -1
  195. package/dist/utils/multiplication/types.js +1 -3
  196. package/dist/utils/parsing/extractIdentifiersFromLVal.js +30 -96
  197. package/dist/utils/parsing/extractIdentifiersFromLVal.js.map +1 -1
  198. package/dist/utils/parsing/getCalleeNameFromExpression.js +31 -65
  199. package/dist/utils/parsing/getCalleeNameFromExpression.js.map +1 -1
  200. package/dist/utils/parsing/getCalleeNameFromExpressionWrapper.js +13 -10
  201. package/dist/utils/parsing/getCalleeNameFromExpressionWrapper.js.map +1 -1
  202. package/dist/utils/parsing/getObjectPropertyFromObjectExpression.js +19 -56
  203. package/dist/utils/parsing/getObjectPropertyFromObjectExpression.js.map +1 -1
  204. package/dist/utils/parsing/getStringLiteralFromExpression.js +18 -49
  205. package/dist/utils/parsing/getStringLiteralFromExpression.js.map +1 -1
  206. package/dist/utils/parsing/isDeriveInvocation.js +25 -61
  207. package/dist/utils/parsing/isDeriveInvocation.js.map +1 -1
  208. package/dist/utils/parsing/isStringTranslationTaggedTemplate.js +23 -59
  209. package/dist/utils/parsing/isStringTranslationTaggedTemplate.js.map +1 -1
  210. package/dist/utils/string-expressions/buildTransformationResult.js +57 -96
  211. package/dist/utils/string-expressions/buildTransformationResult.js.map +1 -1
  212. package/dist/utils/string-expressions/flattenExpressionToParts.js +131 -142
  213. package/dist/utils/string-expressions/flattenExpressionToParts.js.map +1 -1
  214. package/dist/utils/string-expressions/resolveStaticExpression.js +36 -34
  215. package/dist/utils/string-expressions/resolveStaticExpression.js.map +1 -1
  216. package/dist/utils/validation/validateChildrenFromObjectExpression.js +29 -24
  217. package/dist/utils/validation/validateChildrenFromObjectExpression.js.map +1 -1
  218. package/dist/utils/validation/validateExpressionIsNumericLiteral.js +13 -47
  219. package/dist/utils/validation/validateExpressionIsNumericLiteral.js.map +1 -1
  220. package/dist/utils/validation/validateExpressionIsStringLiteral.js +15 -48
  221. package/dist/utils/validation/validateExpressionIsStringLiteral.js.map +1 -1
  222. package/package.json +8 -5
  223. package/dist/processing/index.js.map +0 -1
  224. package/dist/state/types.js.map +0 -1
  225. package/dist/transform/jsx-children/index.js.map +0 -1
  226. package/dist/utils/multiplication/types.js.map +0 -1
@@ -1,424 +1,315 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.processCallExpression = processCallExpression;
37
- const t = __importStar(require("@babel/types"));
38
- const constants_1 = require("../../utils/constants/gt/constants");
39
- const constants_2 = require("../../utils/constants/other/constants");
40
- const constants_3 = require("../../utils/constants/react/constants");
41
- const isReactJsxFunction_1 = require("../../utils/constants/resolveIdentifier/isReactJsxFunction");
42
- const isGTComponent_1 = require("../../utils/constants/resolveIdentifier/isGTComponent");
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_runtime = require("../../_virtual/_rolldown/runtime.js");
3
+ const require_utils_constants_gt_constants = require("../../utils/constants/gt/constants.js");
4
+ require("../../utils/constants/react/constants.js");
5
+ require("../../utils/constants/other/constants.js");
6
+ const require_utils_constants_resolveIdentifier_isReactJsxFunction = require("../../utils/constants/resolveIdentifier/isReactJsxFunction.js");
7
+ const require_utils_constants_resolveIdentifier_isGTComponent = require("../../utils/constants/resolveIdentifier/isGTComponent.js");
8
+ let _babel_types = require("@babel/types");
9
+ _babel_types = require_runtime.__toESM(_babel_types);
10
+ //#region src/processing/jsx-insertion/processCallExpression.ts
43
11
  /**
44
- * Babel visitor entry point for the JSX insertion pass.
45
- *
46
- * All internal functions use NodePath-based traversal via .get() so that
47
- * Babel binding lookups (scope.getBinding) work correctly at every depth.
48
- * This handles aliased imports like `import { jsxDEV as _jsxDEV }`.
49
- */
12
+ * Babel visitor entry point for the JSX insertion pass.
13
+ *
14
+ * All internal functions use NodePath-based traversal via .get() so that
15
+ * Babel binding lookups (scope.getBinding) work correctly at every depth.
16
+ * This handles aliased imports like `import { jsxDEV as _jsxDEV }`.
17
+ */
50
18
  function processCallExpression(state, calleeInfo) {
51
- const jsxState = Object.assign(Object.assign({}, state), { processedNodes: new WeakSet(), calleeInfo, insideUserVarDepth: 0 });
52
- return {
53
- enter: (path) => {
54
- // Check jsx callee first — needed for both user Var detection and processing
55
- const calleePath = path.get('callee');
56
- if ((!calleePath.isIdentifier() && !calleePath.isMemberExpression()) ||
57
- !(0, isReactJsxFunction_1.isReactJsxFunction)(calleePath)) {
58
- return;
59
- }
60
- // Check if this is a user Var/Num/Currency/DateTime — suppress transforms inside.
61
- // This must happen BEFORE the processedNodes check, because user T's
62
- // markDescendantJsxCalls may have already added the Var call to processedNodes,
63
- // but we still need to increment the depth counter so children are suppressed.
64
- const firstArg = path.get('arguments')[0];
65
- if ((firstArg === null || firstArg === void 0 ? void 0 : firstArg.isExpression()) && (0, isGTComponent_1.isUserVariableComponent)(firstArg)) {
66
- jsxState.insideUserVarDepth++;
67
- return;
68
- }
69
- // Skip all processing when inside a user variable component
70
- if (jsxState.insideUserVarDepth > 0)
71
- return;
72
- if (jsxState.processedNodes.has(path.node))
73
- return;
74
- processJsxNode({ path, insideAutoT: false, state: jsxState });
75
- },
76
- exit: (path) => {
77
- // Decrement depth when exiting a user Var/Num/Currency/DateTime
78
- const calleePath = path.get('callee');
79
- if ((!calleePath.isIdentifier() && !calleePath.isMemberExpression()) ||
80
- !(0, isReactJsxFunction_1.isReactJsxFunction)(calleePath)) {
81
- return;
82
- }
83
- const firstArg = path.get('arguments')[0];
84
- if ((firstArg === null || firstArg === void 0 ? void 0 : firstArg.isExpression()) && (0, isGTComponent_1.isUserVariableComponent)(firstArg)) {
85
- jsxState.insideUserVarDepth--;
86
- }
87
- },
88
- };
19
+ const jsxState = {
20
+ ...state,
21
+ processedNodes: /* @__PURE__ */ new WeakSet(),
22
+ calleeInfo,
23
+ insideUserVarDepth: 0
24
+ };
25
+ return {
26
+ enter: (path) => {
27
+ const calleePath = path.get("callee");
28
+ if (!calleePath.isIdentifier() && !calleePath.isMemberExpression() || !require_utils_constants_resolveIdentifier_isReactJsxFunction.isReactJsxFunction(calleePath)) return;
29
+ const firstArg = path.get("arguments")[0];
30
+ if ((firstArg === null || firstArg === void 0 ? void 0 : firstArg.isExpression()) && require_utils_constants_resolveIdentifier_isGTComponent.isUserVariableComponent(firstArg)) {
31
+ jsxState.insideUserVarDepth++;
32
+ return;
33
+ }
34
+ if (jsxState.insideUserVarDepth > 0) return;
35
+ if (jsxState.processedNodes.has(path.node)) return;
36
+ processJsxNode({
37
+ path,
38
+ insideAutoT: false,
39
+ state: jsxState
40
+ });
41
+ },
42
+ exit: (path) => {
43
+ const calleePath = path.get("callee");
44
+ if (!calleePath.isIdentifier() && !calleePath.isMemberExpression() || !require_utils_constants_resolveIdentifier_isReactJsxFunction.isReactJsxFunction(calleePath)) return;
45
+ const firstArg = path.get("arguments")[0];
46
+ if ((firstArg === null || firstArg === void 0 ? void 0 : firstArg.isExpression()) && require_utils_constants_resolveIdentifier_isGTComponent.isUserVariableComponent(firstArg)) jsxState.insideUserVarDepth--;
47
+ }
48
+ };
89
49
  }
90
- // ===== Core recursive function =====
91
- function processJsxNode({ path, insideAutoT, state, }) {
92
- var _a, _b;
93
- state.processedNodes.add(path.node);
94
- const firstArgPath = path.get('arguments')[0];
95
- if (!(firstArgPath === null || firstArgPath === void 0 ? void 0 : firstArgPath.isExpression()))
96
- return;
97
- // User T → mark all descendant jsx calls as processed, hands off
98
- if ((0, isGTComponent_1.isUserTranslationComponent)(firstArgPath)) {
99
- markDescendantJsxCalls({ jsxCallPath: path, state });
100
- return;
101
- }
102
- // User Var/Num/Currency/DateTime → mark descendants, hands off
103
- if ((0, isGTComponent_1.isUserVariableComponent)(firstArgPath)) {
104
- markDescendantJsxCalls({ jsxCallPath: path, state });
105
- return;
106
- }
107
- // Already auto-inserted → skip
108
- const gtName = (0, isGTComponent_1.resolveFirstArgGTName)(firstArgPath);
109
- if (gtName === constants_1.GT_COMPONENT_TYPES.GtInternalTranslateJsx ||
110
- gtName === constants_1.GT_COMPONENT_TYPES.GtInternalVar) {
111
- return;
112
- }
113
- // Branch/Plural/Derive/Static opaque for static JSX, dynamic props get _Var
114
- if ((0, isGTComponent_1.isGTBranchComponent)(firstArgPath) || (0, isGTComponent_1.isGTDeriveComponent)(firstArgPath)) {
115
- // Process props BEFORE wrapping — path still points to the opaque component
116
- processOpaqueComponentProps({
117
- jsxCallPath: path,
118
- insideAutoT: !insideAutoT ? true : insideAutoT,
119
- state,
120
- });
121
- if (!insideAutoT) {
122
- // Root-level opaque component — wrap in _T (single child → use singleCallee)
123
- const callee = (_b = (_a = state.calleeInfo.singleCallee) !== null && _a !== void 0 ? _a : state.calleeInfo.multiCallee) !== null && _b !== void 0 ? _b : constants_3.REACT_FUNTIONS.jsx;
124
- const tWrapped = wrapInT(path.node, t.identifier(callee), state.calleeInfo);
125
- state.processedNodes.add(tWrapped);
126
- path.replaceWith(tWrapped);
127
- state.statistics.jsxInsertionsCount++;
128
- }
129
- return;
130
- }
131
- // --- Get children prop path ---
132
- const childrenPropPath = getChildrenPropPath(path);
133
- if (!childrenPropPath)
134
- return;
135
- const childrenPath = childrenPropPath.get('value');
136
- if (!childrenPath.isExpression())
137
- return;
138
- // --- Determine if this level should claim T ---
139
- const shouldClaimT = !insideAutoT &&
140
- (hasNonWhitespaceText(childrenPath) || hasOpaqueGTChild(childrenPath));
141
- if (shouldClaimT) {
142
- processChildren({ childrenPath, insideAutoT: true, state });
143
- const currentChildren = childrenPropPath.get('value').node;
144
- const tCallee = t.isArrayExpression(currentChildren)
145
- ? state.calleeInfo.multiCallee
146
- : state.calleeInfo.singleCallee;
147
- const tWrapped = wrapInT(currentChildren, t.identifier(tCallee !== null && tCallee !== void 0 ? tCallee : 'jsx'), state.calleeInfo);
148
- state.processedNodes.add(tWrapped);
149
- childrenPropPath.get('value').replaceWith(tWrapped);
150
- updateCalleeToSingle({ jsxCallPath: path, state });
151
- state.statistics.jsxInsertionsCount++;
152
- }
153
- else if (insideAutoT) {
154
- processChildren({ childrenPath, insideAutoT: true, state });
155
- }
156
- else {
157
- recurseChildJsxCalls({ childrenPath, insideAutoT: false, state });
158
- }
50
+ function processJsxNode({ path, insideAutoT, state }) {
51
+ state.processedNodes.add(path.node);
52
+ const firstArgPath = path.get("arguments")[0];
53
+ if (!(firstArgPath === null || firstArgPath === void 0 ? void 0 : firstArgPath.isExpression())) return;
54
+ if (require_utils_constants_resolveIdentifier_isGTComponent.isUserTranslationComponent(firstArgPath)) {
55
+ markDescendantJsxCalls({
56
+ jsxCallPath: path,
57
+ state
58
+ });
59
+ return;
60
+ }
61
+ if (require_utils_constants_resolveIdentifier_isGTComponent.isUserVariableComponent(firstArgPath)) {
62
+ markDescendantJsxCalls({
63
+ jsxCallPath: path,
64
+ state
65
+ });
66
+ return;
67
+ }
68
+ const gtName = require_utils_constants_resolveIdentifier_isGTComponent.resolveFirstArgGTName(firstArgPath);
69
+ if (gtName === "GtInternalTranslateJsx" || gtName === "GtInternalVar") return;
70
+ if (require_utils_constants_resolveIdentifier_isGTComponent.isGTBranchComponent(firstArgPath) || require_utils_constants_resolveIdentifier_isGTComponent.isGTDeriveComponent(firstArgPath)) {
71
+ processOpaqueComponentProps({
72
+ jsxCallPath: path,
73
+ insideAutoT: !insideAutoT ? true : insideAutoT,
74
+ state
75
+ });
76
+ if (!insideAutoT) {
77
+ const callee = state.calleeInfo.singleCallee ?? state.calleeInfo.multiCallee ?? "jsx";
78
+ const tWrapped = wrapInT(path.node, _babel_types.identifier(callee), state.calleeInfo);
79
+ state.processedNodes.add(tWrapped);
80
+ path.replaceWith(tWrapped);
81
+ state.statistics.jsxInsertionsCount++;
82
+ }
83
+ return;
84
+ }
85
+ const childrenPropPath = getChildrenPropPath(path);
86
+ if (!childrenPropPath) return;
87
+ const childrenPath = childrenPropPath.get("value");
88
+ if (!childrenPath.isExpression()) return;
89
+ if (!insideAutoT && (hasNonWhitespaceText(childrenPath) || hasOpaqueGTChild(childrenPath))) {
90
+ processChildren({
91
+ childrenPath,
92
+ insideAutoT: true,
93
+ state
94
+ });
95
+ const currentChildren = childrenPropPath.get("value").node;
96
+ const tCallee = _babel_types.isArrayExpression(currentChildren) ? state.calleeInfo.multiCallee : state.calleeInfo.singleCallee;
97
+ const tWrapped = wrapInT(currentChildren, _babel_types.identifier(tCallee ?? "jsx"), state.calleeInfo);
98
+ state.processedNodes.add(tWrapped);
99
+ childrenPropPath.get("value").replaceWith(tWrapped);
100
+ updateCalleeToSingle({
101
+ jsxCallPath: path,
102
+ state
103
+ });
104
+ state.statistics.jsxInsertionsCount++;
105
+ } else if (insideAutoT) processChildren({
106
+ childrenPath,
107
+ insideAutoT: true,
108
+ state
109
+ });
110
+ else recurseChildJsxCalls({
111
+ childrenPath,
112
+ insideAutoT: false,
113
+ state
114
+ });
159
115
  }
160
- // ===== Children processing ===== //
161
- function processChildren({ childrenPath, insideAutoT, state, }) {
162
- if (childrenPath.isArrayExpression()) {
163
- for (const elPath of childrenPath.get('elements')) {
164
- if (elPath.isExpression()) {
165
- processSingleChild({ childPath: elPath, insideAutoT, state });
166
- }
167
- }
168
- return;
169
- }
170
- processSingleChild({ childPath: childrenPath, insideAutoT, state });
116
+ function processChildren({ childrenPath, insideAutoT, state }) {
117
+ if (childrenPath.isArrayExpression()) {
118
+ for (const elPath of childrenPath.get("elements")) if (elPath.isExpression()) processSingleChild({
119
+ childPath: elPath,
120
+ insideAutoT,
121
+ state
122
+ });
123
+ return;
124
+ }
125
+ processSingleChild({
126
+ childPath: childrenPath,
127
+ insideAutoT,
128
+ state
129
+ });
171
130
  }
172
- function processSingleChild({ childPath, insideAutoT, state, }) {
173
- var _a;
174
- if (childPath.isCallExpression() && isJsxCallPath(childPath)) {
175
- processJsxNode({ path: childPath, insideAutoT, state });
176
- return;
177
- }
178
- // _Var always has a single child → use singleCallee
179
- if (insideAutoT && needsVarWrapping(childPath)) {
180
- const callee = (_a = state.calleeInfo.singleCallee) !== null && _a !== void 0 ? _a : constants_3.REACT_FUNTIONS.jsx;
181
- const wrapped = wrapInVar(childPath.node, t.identifier(callee), state.calleeInfo);
182
- state.processedNodes.add(wrapped);
183
- childPath.replaceWith(wrapped);
184
- }
131
+ function processSingleChild({ childPath, insideAutoT, state }) {
132
+ if (childPath.isCallExpression() && isJsxCallPath(childPath)) {
133
+ processJsxNode({
134
+ path: childPath,
135
+ insideAutoT,
136
+ state
137
+ });
138
+ return;
139
+ }
140
+ if (insideAutoT && needsVarWrapping(childPath)) {
141
+ const callee = state.calleeInfo.singleCallee ?? "jsx";
142
+ const wrapped = wrapInVar(childPath.node, _babel_types.identifier(callee), state.calleeInfo);
143
+ state.processedNodes.add(wrapped);
144
+ childPath.replaceWith(wrapped);
145
+ }
185
146
  }
186
- function recurseChildJsxCalls({ childrenPath, insideAutoT, state, }) {
187
- if (childrenPath.isArrayExpression()) {
188
- for (const elPath of childrenPath.get('elements')) {
189
- if (elPath.isCallExpression() && isJsxCallPath(elPath)) {
190
- processJsxNode({ path: elPath, insideAutoT, state });
191
- }
192
- }
193
- }
194
- else if (childrenPath.isCallExpression() && isJsxCallPath(childrenPath)) {
195
- processJsxNode({ path: childrenPath, insideAutoT, state });
196
- }
147
+ function recurseChildJsxCalls({ childrenPath, insideAutoT, state }) {
148
+ if (childrenPath.isArrayExpression()) {
149
+ for (const elPath of childrenPath.get("elements")) if (elPath.isCallExpression() && isJsxCallPath(elPath)) processJsxNode({
150
+ path: elPath,
151
+ insideAutoT,
152
+ state
153
+ });
154
+ } else if (childrenPath.isCallExpression() && isJsxCallPath(childrenPath)) processJsxNode({
155
+ path: childrenPath,
156
+ insideAutoT,
157
+ state
158
+ });
197
159
  }
198
- // ===== Helper functions =====
199
160
  function getChildrenPropPath(jsxCallPath) {
200
- const args = jsxCallPath.get('arguments');
201
- const propsArg = args[1];
202
- if (!(propsArg === null || propsArg === void 0 ? void 0 : propsArg.isObjectExpression()))
203
- return undefined;
204
- for (const propPath of propsArg.get('properties')) {
205
- if (propPath.isObjectProperty() &&
206
- t.isIdentifier(propPath.node.key, { name: 'children' })) {
207
- return propPath;
208
- }
209
- }
210
- return undefined;
161
+ const propsArg = jsxCallPath.get("arguments")[1];
162
+ if (!(propsArg === null || propsArg === void 0 ? void 0 : propsArg.isObjectExpression())) return void 0;
163
+ for (const propPath of propsArg.get("properties")) if (propPath.isObjectProperty() && _babel_types.isIdentifier(propPath.node.key, { name: "children" })) return propPath;
211
164
  }
212
165
  function isJsxCallPath(callPath) {
213
- const callee = callPath.get('callee');
214
- if (!callee.isIdentifier() && !callee.isMemberExpression())
215
- return false;
216
- return (0, isReactJsxFunction_1.isReactJsxFunction)(callee);
166
+ const callee = callPath.get("callee");
167
+ if (!callee.isIdentifier() && !callee.isMemberExpression()) return false;
168
+ return require_utils_constants_resolveIdentifier_isReactJsxFunction.isReactJsxFunction(callee);
217
169
  }
218
170
  function hasNonWhitespaceText(childrenPath) {
219
- const isText = (p) => {
220
- var _a, _b;
221
- if (p.isStringLiteral())
222
- return p.node.value.trim().length > 0;
223
- if (p.isTemplateLiteral()) {
224
- return (p.node.expressions.length === 0 &&
225
- ((_b = (_a = p.node.quasis[0]) === null || _a === void 0 ? void 0 : _a.value.cooked) !== null && _b !== void 0 ? _b : '').trim().length > 0);
226
- }
227
- return false;
228
- };
229
- if (childrenPath.isArrayExpression()) {
230
- return childrenPath
231
- .get('elements')
232
- .some((el) => el.isExpression() && isText(el));
233
- }
234
- return isText(childrenPath);
171
+ const isText = (p) => {
172
+ if (p.isStringLiteral()) return p.node.value.trim().length > 0;
173
+ if (p.isTemplateLiteral()) {
174
+ var _p$node$quasis$;
175
+ return p.node.expressions.length === 0 && (((_p$node$quasis$ = p.node.quasis[0]) === null || _p$node$quasis$ === void 0 ? void 0 : _p$node$quasis$.value.cooked) ?? "").trim().length > 0;
176
+ }
177
+ return false;
178
+ };
179
+ if (childrenPath.isArrayExpression()) return childrenPath.get("elements").some((el) => el.isExpression() && isText(el));
180
+ return isText(childrenPath);
235
181
  }
236
182
  function hasOpaqueGTChild(childrenPath) {
237
- const isOpaque = (elPath) => {
238
- if (!elPath.isCallExpression() || !isJsxCallPath(elPath))
239
- return false;
240
- const firstArg = elPath.get('arguments')[0];
241
- if (!(firstArg === null || firstArg === void 0 ? void 0 : firstArg.isExpression()))
242
- return false;
243
- return (0, isGTComponent_1.isGTBranchComponent)(firstArg) || (0, isGTComponent_1.isGTDeriveComponent)(firstArg);
244
- };
245
- if (childrenPath.isArrayExpression()) {
246
- return childrenPath
247
- .get('elements')
248
- .some((el) => el.isExpression() && isOpaque(el));
249
- }
250
- return isOpaque(childrenPath);
183
+ const isOpaque = (elPath) => {
184
+ if (!elPath.isCallExpression() || !isJsxCallPath(elPath)) return false;
185
+ const firstArg = elPath.get("arguments")[0];
186
+ if (!(firstArg === null || firstArg === void 0 ? void 0 : firstArg.isExpression())) return false;
187
+ return require_utils_constants_resolveIdentifier_isGTComponent.isGTBranchComponent(firstArg) || require_utils_constants_resolveIdentifier_isGTComponent.isGTDeriveComponent(firstArg);
188
+ };
189
+ if (childrenPath.isArrayExpression()) return childrenPath.get("elements").some((el) => el.isExpression() && isOpaque(el));
190
+ return isOpaque(childrenPath);
251
191
  }
252
192
  function needsVarWrapping(exprPath) {
253
- if (exprPath.isStringLiteral())
254
- return false;
255
- if (exprPath.isNumericLiteral())
256
- return false;
257
- if (exprPath.isBooleanLiteral())
258
- return false;
259
- if (exprPath.isNullLiteral())
260
- return false;
261
- if (exprPath.isTemplateLiteral() && exprPath.node.expressions.length === 0) {
262
- return false;
263
- }
264
- if (exprPath.isUnaryExpression() &&
265
- exprPath.node.operator === '-' &&
266
- t.isNumericLiteral(exprPath.node.argument)) {
267
- return false;
268
- }
269
- if (exprPath.isIdentifier()) {
270
- return ![
271
- constants_2.OTHER_IDENTIFIERS_ENUM.UNDEFINED,
272
- constants_2.OTHER_IDENTIFIERS_ENUM.NAN,
273
- constants_2.OTHER_IDENTIFIERS_ENUM.INFINITY,
274
- ].includes(exprPath.node.name);
275
- }
276
- if (exprPath.isCallExpression() && isJsxCallPath(exprPath)) {
277
- return false;
278
- }
279
- return true;
193
+ if (exprPath.isStringLiteral()) return false;
194
+ if (exprPath.isNumericLiteral()) return false;
195
+ if (exprPath.isBooleanLiteral()) return false;
196
+ if (exprPath.isNullLiteral()) return false;
197
+ if (exprPath.isTemplateLiteral() && exprPath.node.expressions.length === 0) return false;
198
+ if (exprPath.isUnaryExpression() && exprPath.node.operator === "-" && _babel_types.isNumericLiteral(exprPath.node.argument)) return false;
199
+ if (exprPath.isIdentifier()) return ![
200
+ "undefined",
201
+ "NaN",
202
+ "Infinity"
203
+ ].includes(exprPath.node.name);
204
+ if (exprPath.isCallExpression() && isJsxCallPath(exprPath)) return false;
205
+ return true;
280
206
  }
281
207
  /**
282
- * After wrapping children in _T, the parent now has a single child.
283
- * Update its callee from jsxs → jsx if needed.
284
- */
285
- function updateCalleeToSingle({ jsxCallPath, state, }) {
286
- const { singleCallee, multiCallee } = state.calleeInfo;
287
- // Production (jsx/jsxs): update callee name jsxs jsx
288
- if (singleCallee && multiCallee && singleCallee !== multiCallee) {
289
- const callee = jsxCallPath.get('callee');
290
- if (callee.isIdentifier() && callee.node.name === multiCallee) {
291
- callee.node.name = singleCallee;
292
- }
293
- }
294
- // Dev (jsxDEV): update isStaticChildren (4th arg, index 3) to false
295
- const args = jsxCallPath.get('arguments');
296
- const isStaticArg = args[3];
297
- if (isStaticArg === null || isStaticArg === void 0 ? void 0 : isStaticArg.isBooleanLiteral({ value: true })) {
298
- isStaticArg.replaceWith(t.booleanLiteral(false));
299
- }
208
+ * After wrapping children in _T, the parent now has a single child.
209
+ * Update its callee from jsxs → jsx if needed.
210
+ */
211
+ function updateCalleeToSingle({ jsxCallPath, state }) {
212
+ const { singleCallee, multiCallee } = state.calleeInfo;
213
+ if (singleCallee && multiCallee && singleCallee !== multiCallee) {
214
+ const callee = jsxCallPath.get("callee");
215
+ if (callee.isIdentifier() && callee.node.name === multiCallee) callee.node.name = singleCallee;
216
+ }
217
+ const isStaticArg = jsxCallPath.get("arguments")[3];
218
+ if (isStaticArg === null || isStaticArg === void 0 ? void 0 : isStaticArg.isBooleanLiteral({ value: true })) isStaticArg.replaceWith(_babel_types.booleanLiteral(false));
300
219
  }
301
- // ===== AST construction =====
302
220
  function wrapInVar(expr, callee, calleeInfo) {
303
- const args = [
304
- t.identifier(constants_1.GT_COMPONENT_TYPES.GtInternalVar),
305
- t.objectExpression([t.objectProperty(t.identifier('children'), expr)]),
306
- ];
307
- if (isDevMode(calleeInfo)) {
308
- args.push(t.unaryExpression('void', t.numericLiteral(0)), t.booleanLiteral(false));
309
- }
310
- return t.callExpression(t.cloneNode(callee), args);
221
+ const args = [_babel_types.identifier("GtInternalVar"), _babel_types.objectExpression([_babel_types.objectProperty(_babel_types.identifier("children"), expr)])];
222
+ if (isDevMode(calleeInfo)) args.push(_babel_types.unaryExpression("void", _babel_types.numericLiteral(0)), _babel_types.booleanLiteral(false));
223
+ return _babel_types.callExpression(_babel_types.cloneNode(callee), args);
311
224
  }
312
225
  function wrapInT(children, callee, calleeInfo) {
313
- const args = [
314
- t.identifier(constants_1.GT_COMPONENT_TYPES.GtInternalTranslateJsx),
315
- t.objectExpression([t.objectProperty(t.identifier('children'), children)]),
316
- ];
317
- if (isDevMode(calleeInfo)) {
318
- args.push(t.unaryExpression('void', t.numericLiteral(0)), t.booleanLiteral(t.isArrayExpression(children)));
319
- }
320
- return t.callExpression(t.cloneNode(callee), args);
226
+ const args = [_babel_types.identifier("GtInternalTranslateJsx"), _babel_types.objectExpression([_babel_types.objectProperty(_babel_types.identifier("children"), children)])];
227
+ if (isDevMode(calleeInfo)) args.push(_babel_types.unaryExpression("void", _babel_types.numericLiteral(0)), _babel_types.booleanLiteral(_babel_types.isArrayExpression(children)));
228
+ return _babel_types.callExpression(_babel_types.cloneNode(callee), args);
321
229
  }
322
230
  function isDevMode(calleeInfo) {
323
- return (calleeInfo.singleCallee != null &&
324
- calleeInfo.singleCallee === calleeInfo.multiCallee);
231
+ return calleeInfo.singleCallee != null && calleeInfo.singleCallee === calleeInfo.multiCallee;
325
232
  }
326
- // ===== Marking descendants as processed =====
327
- function markDescendantJsxCalls({ jsxCallPath, state, }) {
328
- const childrenPropPath = getChildrenPropPath(jsxCallPath);
329
- if (!childrenPropPath)
330
- return;
331
- const valuePath = childrenPropPath.get('value');
332
- if (valuePath.isExpression()) {
333
- walkAndMark({ exprPath: valuePath, state });
334
- }
233
+ function markDescendantJsxCalls({ jsxCallPath, state }) {
234
+ const childrenPropPath = getChildrenPropPath(jsxCallPath);
235
+ if (!childrenPropPath) return;
236
+ const valuePath = childrenPropPath.get("value");
237
+ if (valuePath.isExpression()) walkAndMark({
238
+ exprPath: valuePath,
239
+ state
240
+ });
335
241
  }
336
- function processOpaqueComponentProps({ jsxCallPath, insideAutoT, state, }) {
337
- var _a;
338
- const args = jsxCallPath.get('arguments');
339
- const propsArg = args[1];
340
- if (!(propsArg === null || propsArg === void 0 ? void 0 : propsArg.isObjectExpression()))
341
- return;
342
- // Resolve component type to filter control props
343
- const firstArgPath = args[0];
344
- const gtName = (firstArgPath === null || firstArgPath === void 0 ? void 0 : firstArgPath.isExpression())
345
- ? (0, isGTComponent_1.resolveFirstArgGTName)(firstArgPath)
346
- : null;
347
- for (const propPath of propsArg.get('properties')) {
348
- if (!propPath.isObjectProperty())
349
- continue;
350
- // Determine prop name and skip control props
351
- const key = propPath.node.key;
352
- const propName = t.isIdentifier(key)
353
- ? key.name
354
- : t.isStringLiteral(key)
355
- ? key.value
356
- : null;
357
- if (isControlProp(gtName, propName))
358
- continue;
359
- const valuePath = propPath.get('value');
360
- if (!valuePath.isExpression())
361
- continue;
362
- // children is fallback content for Branch/Plural — process element-by-element
363
- // For Derive/Static, children is opaque — skip entirely
364
- if (propName === 'children') {
365
- if (insideAutoT &&
366
- (gtName === constants_1.GT_COMPONENT_TYPES.Branch ||
367
- gtName === constants_1.GT_COMPONENT_TYPES.Plural)) {
368
- processChildren({ childrenPath: valuePath, insideAutoT: true, state });
369
- }
370
- continue;
371
- }
372
- if (valuePath.isCallExpression() && isJsxCallPath(valuePath)) {
373
- // Content prop with JSX value — recurse into children for Var-wrapping
374
- if (insideAutoT) {
375
- const childrenPropPath = getChildrenPropPath(valuePath);
376
- if (childrenPropPath) {
377
- const childrenPath = childrenPropPath.get('value');
378
- if (childrenPath.isExpression()) {
379
- processChildren({ childrenPath, insideAutoT: true, state });
380
- }
381
- }
382
- }
383
- state.processedNodes.add(valuePath.node);
384
- walkAndMark({ exprPath: valuePath, state });
385
- }
386
- else if (insideAutoT && needsVarWrapping(valuePath)) {
387
- const callee = (_a = state.calleeInfo.singleCallee) !== null && _a !== void 0 ? _a : constants_3.REACT_FUNTIONS.jsx;
388
- const wrapped = wrapInVar(valuePath.node, t.identifier(callee), state.calleeInfo);
389
- state.processedNodes.add(wrapped);
390
- valuePath.replaceWith(wrapped);
391
- }
392
- }
242
+ function processOpaqueComponentProps({ jsxCallPath, insideAutoT, state }) {
243
+ const args = jsxCallPath.get("arguments");
244
+ const propsArg = args[1];
245
+ if (!(propsArg === null || propsArg === void 0 ? void 0 : propsArg.isObjectExpression())) return;
246
+ const firstArgPath = args[0];
247
+ const gtName = (firstArgPath === null || firstArgPath === void 0 ? void 0 : firstArgPath.isExpression()) ? require_utils_constants_resolveIdentifier_isGTComponent.resolveFirstArgGTName(firstArgPath) : null;
248
+ for (const propPath of propsArg.get("properties")) {
249
+ if (!propPath.isObjectProperty()) continue;
250
+ const key = propPath.node.key;
251
+ const propName = _babel_types.isIdentifier(key) ? key.name : _babel_types.isStringLiteral(key) ? key.value : null;
252
+ if (isControlProp(gtName, propName)) continue;
253
+ const valuePath = propPath.get("value");
254
+ if (!valuePath.isExpression()) continue;
255
+ if (propName === "children") {
256
+ if (insideAutoT && (gtName === "Branch" || gtName === "Plural")) processChildren({
257
+ childrenPath: valuePath,
258
+ insideAutoT: true,
259
+ state
260
+ });
261
+ continue;
262
+ }
263
+ if (valuePath.isCallExpression() && isJsxCallPath(valuePath)) {
264
+ if (insideAutoT) {
265
+ const childrenPropPath = getChildrenPropPath(valuePath);
266
+ if (childrenPropPath) {
267
+ const childrenPath = childrenPropPath.get("value");
268
+ if (childrenPath.isExpression()) processChildren({
269
+ childrenPath,
270
+ insideAutoT: true,
271
+ state
272
+ });
273
+ }
274
+ }
275
+ state.processedNodes.add(valuePath.node);
276
+ walkAndMark({
277
+ exprPath: valuePath,
278
+ state
279
+ });
280
+ } else if (insideAutoT && needsVarWrapping(valuePath)) {
281
+ const callee = state.calleeInfo.singleCallee ?? "jsx";
282
+ const wrapped = wrapInVar(valuePath.node, _babel_types.identifier(callee), state.calleeInfo);
283
+ state.processedNodes.add(wrapped);
284
+ valuePath.replaceWith(wrapped);
285
+ }
286
+ }
393
287
  }
394
288
  function isControlProp(gtName, propName) {
395
- if (!propName)
396
- return false;
397
- if (gtName === constants_1.GT_COMPONENT_TYPES.Branch) {
398
- return constants_1.BRANCH_CONTROL_PROPS.has(propName) || propName.startsWith('data-');
399
- }
400
- if (gtName === constants_1.GT_COMPONENT_TYPES.Plural) {
401
- return constants_1.PLURAL_CONTROL_PROPS.has(propName);
402
- }
403
- return false;
289
+ if (!propName) return false;
290
+ if (gtName === "Branch") return require_utils_constants_gt_constants.BRANCH_CONTROL_PROPS.has(propName) || propName.startsWith("data-");
291
+ if (gtName === "Plural") return require_utils_constants_gt_constants.PLURAL_CONTROL_PROPS.has(propName);
292
+ return false;
404
293
  }
405
- function walkAndMark({ exprPath, state, }) {
406
- if (exprPath.isCallExpression() && isJsxCallPath(exprPath)) {
407
- state.processedNodes.add(exprPath.node);
408
- const childrenPropPath = getChildrenPropPath(exprPath);
409
- if (childrenPropPath) {
410
- const valuePath = childrenPropPath.get('value');
411
- if (valuePath.isExpression()) {
412
- walkAndMark({ exprPath: valuePath, state });
413
- }
414
- }
415
- }
416
- else if (exprPath.isArrayExpression()) {
417
- for (const elPath of exprPath.get('elements')) {
418
- if (elPath.isExpression()) {
419
- walkAndMark({ exprPath: elPath, state });
420
- }
421
- }
422
- }
294
+ function walkAndMark({ exprPath, state }) {
295
+ if (exprPath.isCallExpression() && isJsxCallPath(exprPath)) {
296
+ state.processedNodes.add(exprPath.node);
297
+ const childrenPropPath = getChildrenPropPath(exprPath);
298
+ if (childrenPropPath) {
299
+ const valuePath = childrenPropPath.get("value");
300
+ if (valuePath.isExpression()) walkAndMark({
301
+ exprPath: valuePath,
302
+ state
303
+ });
304
+ }
305
+ } else if (exprPath.isArrayExpression()) {
306
+ for (const elPath of exprPath.get("elements")) if (elPath.isExpression()) walkAndMark({
307
+ exprPath: elPath,
308
+ state
309
+ });
310
+ }
423
311
  }
312
+ //#endregion
313
+ exports.processCallExpression = processCallExpression;
314
+
424
315
  //# sourceMappingURL=processCallExpression.js.map