@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.
- package/dist/_virtual/_rolldown/runtime.js +23 -0
- package/dist/config.js +32 -27
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +120 -187
- package/dist/index.js.map +1 -1
- package/dist/passes/basePass.js +40 -83
- package/dist/passes/basePass.js.map +1 -1
- package/dist/passes/collectionPass.js +18 -11
- package/dist/passes/collectionPass.js.map +1 -1
- package/dist/passes/handleErrors.js +21 -30
- package/dist/passes/handleErrors.js.map +1 -1
- package/dist/passes/injectionPass.js +15 -9
- package/dist/passes/injectionPass.js.map +1 -1
- package/dist/passes/jsxInsertionPass.js +33 -31
- package/dist/passes/jsxInsertionPass.js.map +1 -1
- package/dist/passes/macroExpansionPass.js +28 -26
- package/dist/passes/macroExpansionPass.js.map +1 -1
- package/dist/passes/runtimeTranslatePass.js +37 -35
- package/dist/passes/runtimeTranslatePass.js.map +1 -1
- package/dist/processing/collection/processCallExpression.js +144 -249
- package/dist/processing/collection/processCallExpression.js.map +1 -1
- package/dist/processing/collection/processTaggedTemplateExpression.js +38 -75
- package/dist/processing/collection/processTaggedTemplateExpression.js.map +1 -1
- package/dist/processing/collection/processVariableDeclarator.js +20 -18
- package/dist/processing/collection/processVariableDeclarator.js.map +1 -1
- package/dist/processing/index.js +29 -31
- package/dist/processing/injection/processCallExpression.js +69 -142
- package/dist/processing/injection/processCallExpression.js.map +1 -1
- package/dist/processing/injection/processVariableDeclarator.js +22 -20
- package/dist/processing/injection/processVariableDeclarator.js.map +1 -1
- package/dist/processing/jsx-insertion/processCallExpression.js +284 -393
- package/dist/processing/jsx-insertion/processCallExpression.js.map +1 -1
- package/dist/processing/jsx-insertion/processImportDeclaration.js +37 -83
- package/dist/processing/jsx-insertion/processImportDeclaration.js.map +1 -1
- package/dist/processing/jsx-insertion/processProgram.js +26 -66
- package/dist/processing/jsx-insertion/processProgram.js.map +1 -1
- package/dist/processing/macro-expansion/processImportDeclaration.js +21 -55
- package/dist/processing/macro-expansion/processImportDeclaration.js.map +1 -1
- package/dist/processing/macro-expansion/processProgram.js +20 -26
- package/dist/processing/macro-expansion/processProgram.js.map +1 -1
- package/dist/processing/macro-expansion/processTaggedTemplateExpression.js +33 -69
- package/dist/processing/macro-expansion/processTaggedTemplateExpression.js.map +1 -1
- package/dist/processing/processArrowFunctionExpression.js +18 -16
- package/dist/processing/processArrowFunctionExpression.js.map +1 -1
- package/dist/processing/processAssignmentExpression.js +12 -10
- package/dist/processing/processAssignmentExpression.js.map +1 -1
- package/dist/processing/processCatchClause.js +18 -16
- package/dist/processing/processCatchClause.js.map +1 -1
- package/dist/processing/processClassDeclaration.js +18 -16
- package/dist/processing/processClassDeclaration.js.map +1 -1
- package/dist/processing/processClassMethod.js +18 -17
- package/dist/processing/processClassMethod.js.map +1 -1
- package/dist/processing/processClassPrivateMethod.js +18 -17
- package/dist/processing/processClassPrivateMethod.js.map +1 -1
- package/dist/processing/processForInStatement.js +18 -16
- package/dist/processing/processForInStatement.js.map +1 -1
- package/dist/processing/processForOfStatement.js +18 -16
- package/dist/processing/processForOfStatement.js.map +1 -1
- package/dist/processing/processFunctionDeclaration.js +20 -18
- package/dist/processing/processFunctionDeclaration.js.map +1 -1
- package/dist/processing/processFunctionExpression.js +26 -24
- package/dist/processing/processFunctionExpression.js.map +1 -1
- package/dist/processing/processImportDeclaration.js +11 -9
- package/dist/processing/processImportDeclaration.js.map +1 -1
- package/dist/processing/processObjectMethod.js +19 -18
- package/dist/processing/processObjectMethod.js.map +1 -1
- package/dist/processing/processProgram.js +13 -13
- package/dist/processing/processProgram.js.map +1 -1
- package/dist/processing/processScopeChange.js +15 -13
- package/dist/processing/processScopeChange.js.map +1 -1
- package/dist/processing/runtime-translate/processImportDeclaration.js +30 -63
- package/dist/processing/runtime-translate/processImportDeclaration.js.map +1 -1
- package/dist/processing/runtime-translate/processProgram.js +34 -57
- package/dist/processing/runtime-translate/processProgram.js.map +1 -1
- package/dist/state/ErrorTracker.js +18 -17
- package/dist/state/ErrorTracker.js.map +1 -1
- package/dist/state/Logger.js +42 -52
- package/dist/state/Logger.js.map +1 -1
- package/dist/state/ScopeTracker.js +154 -209
- package/dist/state/ScopeTracker.js.map +1 -1
- package/dist/state/StringCollector.js +165 -184
- package/dist/state/StringCollector.js.map +1 -1
- package/dist/state/types.js +1 -3
- package/dist/state/utils/initializeState.js +62 -67
- package/dist/state/utils/initializeState.js.map +1 -1
- package/dist/transform/getTrackedVariable.js +33 -38
- package/dist/transform/getTrackedVariable.js.map +1 -1
- package/dist/transform/injection/callbacks/injectUseGTCallbackParameters.js +19 -27
- package/dist/transform/injection/callbacks/injectUseGTCallbackParameters.js.map +1 -1
- package/dist/transform/injection/callbacks/injectUseMessagesCallbackParameters.js +8 -6
- package/dist/transform/injection/callbacks/injectUseMessagesCallbackParameters.js.map +1 -1
- package/dist/transform/injection/callbacks/injectUseTranslationsCallbackParameters.js +8 -6
- package/dist/transform/injection/callbacks/injectUseTranslationsCallbackParameters.js.map +1 -1
- package/dist/transform/injection/injectCallbackDeclaratorFunctionParameters.js +74 -155
- package/dist/transform/injection/injectCallbackDeclaratorFunctionParameters.js.map +1 -1
- package/dist/transform/injection/injectHashIntoTranslationOptions.js +21 -61
- package/dist/transform/injection/injectHashIntoTranslationOptions.js.map +1 -1
- package/dist/transform/injection/injectStandaloneTFunctionParameters.js +21 -27
- package/dist/transform/injection/injectStandaloneTFunctionParameters.js.map +1 -1
- package/dist/transform/injection/injectTComponentParameters.js +25 -65
- package/dist/transform/injection/injectTComponentParameters.js.map +1 -1
- package/dist/transform/jsx-children/constructJsxChildren.js +273 -392
- package/dist/transform/jsx-children/constructJsxChildren.js.map +1 -1
- package/dist/transform/jsx-children/errors.js +16 -6
- package/dist/transform/jsx-children/errors.js.map +1 -1
- package/dist/transform/jsx-children/index.js +3 -6
- package/dist/transform/jsx-children/utils/getBranchComponentParameters.js +26 -85
- package/dist/transform/jsx-children/utils/getBranchComponentParameters.js.map +1 -1
- package/dist/transform/jsx-children/utils/getCalleeNameFromJsxExpressionParam.js +33 -66
- package/dist/transform/jsx-children/utils/getCalleeNameFromJsxExpressionParam.js.map +1 -1
- package/dist/transform/jsx-children/utils/id.js +18 -17
- package/dist/transform/jsx-children/utils/id.js.map +1 -1
- package/dist/transform/jsx-children/validation/validateChildrenElement.js +13 -47
- package/dist/transform/jsx-children/validation/validateChildrenElement.js.map +1 -1
- package/dist/transform/jsx-children/validation/validateChildrenFromArgs.js +25 -63
- package/dist/transform/jsx-children/validation/validateChildrenFromArgs.js.map +1 -1
- package/dist/transform/jsx-children/validation/validateIdentifier.js +38 -41
- package/dist/transform/jsx-children/validation/validateIdentifier.js.map +1 -1
- package/dist/transform/jsx-children/validation/validateJsxCall.js +15 -26
- package/dist/transform/jsx-children/validation/validateJsxCall.js.map +1 -1
- package/dist/transform/jsx-children/validation/validateNameFieldForVarComponent.js +33 -61
- package/dist/transform/jsx-children/validation/validateNameFieldForVarComponent.js.map +1 -1
- package/dist/transform/jsx-children/validation/validateStringLiteralPropertyFromArg.js +38 -66
- package/dist/transform/jsx-children/validation/validateStringLiteralPropertyFromArg.js.map +1 -1
- package/dist/transform/jsx-children/validation/validateTemplateLiteral.js +17 -13
- package/dist/transform/jsx-children/validation/validateTemplateLiteral.js.map +1 -1
- package/dist/transform/jsx-children/validation/validateUnaryExpression.js +26 -61
- package/dist/transform/jsx-children/validation/validateUnaryExpression.js.map +1 -1
- package/dist/transform/jsx-insertion/injectJsxInsertionImport.js +16 -48
- package/dist/transform/jsx-insertion/injectJsxInsertionImport.js.map +1 -1
- package/dist/transform/macro-expansion/injectMacroImport.js +14 -43
- package/dist/transform/macro-expansion/injectMacroImport.js.map +1 -1
- package/dist/transform/macro-expansion/transformTemplateLiteral.js +23 -22
- package/dist/transform/macro-expansion/transformTemplateLiteral.js.map +1 -1
- package/dist/transform/registration/callbacks/registerUseGTCallback.js +27 -34
- package/dist/transform/registration/callbacks/registerUseGTCallback.js.map +1 -1
- package/dist/transform/registration/callbacks/registerUseMessagesCallback.js +9 -9
- package/dist/transform/registration/callbacks/registerUseMessagesCallback.js.map +1 -1
- package/dist/transform/registration/callbacks/registerUseTranslationsCallback.js +9 -9
- package/dist/transform/registration/callbacks/registerUseTranslationsCallback.js.map +1 -1
- package/dist/transform/registration/registerStandaloneTranslation.js +27 -28
- package/dist/transform/registration/registerStandaloneTranslation.js.map +1 -1
- package/dist/transform/registration/registerTranslationComponent.js +15 -15
- package/dist/transform/registration/registerTranslationComponent.js.map +1 -1
- package/dist/transform/runtime-translate/buildRuntimeTranslateCalls.js +34 -85
- package/dist/transform/runtime-translate/buildRuntimeTranslateCalls.js.map +1 -1
- package/dist/transform/runtime-translate/injectRuntimeTranslateImport.js +25 -55
- package/dist/transform/runtime-translate/injectRuntimeTranslateImport.js.map +1 -1
- package/dist/transform/tracking/trackAssignmentExpression.js +26 -63
- package/dist/transform/tracking/trackAssignmentExpression.js.map +1 -1
- package/dist/transform/tracking/trackCatchClause.js +17 -48
- package/dist/transform/tracking/trackCatchClause.js.map +1 -1
- package/dist/transform/tracking/trackClassDeclaration.js +13 -13
- package/dist/transform/tracking/trackClassDeclaration.js.map +1 -1
- package/dist/transform/tracking/trackForDeclaration.js +17 -53
- package/dist/transform/tracking/trackForDeclaration.js.map +1 -1
- package/dist/transform/tracking/trackFunctionName.js +10 -10
- package/dist/transform/tracking/trackFunctionName.js.map +1 -1
- package/dist/transform/tracking/trackFunctionParams.js +19 -54
- package/dist/transform/tracking/trackFunctionParams.js.map +1 -1
- package/dist/transform/tracking/trackImportDeclaration.js +36 -89
- package/dist/transform/tracking/trackImportDeclaration.js.map +1 -1
- package/dist/transform/tracking/trackOverridingVariable.js +9 -11
- package/dist/transform/tracking/trackOverridingVariable.js.map +1 -1
- package/dist/transform/tracking/trackVariableDeclarator.js +51 -102
- package/dist/transform/tracking/trackVariableDeclarator.js.map +1 -1
- package/dist/transform/validation/validateTranslationComponentArgs.js +156 -232
- package/dist/transform/validation/validateTranslationComponentArgs.js.map +1 -1
- package/dist/transform/validation/validateTranslationFunction.js +218 -329
- package/dist/transform/validation/validateTranslationFunction.js.map +1 -1
- package/dist/utils/calculateHash.js +55 -70
- package/dist/utils/calculateHash.js.map +1 -1
- package/dist/utils/constants/gt/constants.js +142 -132
- package/dist/utils/constants/gt/constants.js.map +1 -1
- package/dist/utils/constants/gt/helpers.js +147 -149
- package/dist/utils/constants/gt/helpers.js.map +1 -1
- package/dist/utils/constants/other/constants.js +45 -41
- package/dist/utils/constants/other/constants.js.map +1 -1
- package/dist/utils/constants/other/helpers.js +13 -11
- package/dist/utils/constants/other/helpers.js.map +1 -1
- package/dist/utils/constants/react/constants.js +47 -41
- package/dist/utils/constants/react/constants.js.map +1 -1
- package/dist/utils/constants/react/helpers.js +17 -16
- package/dist/utils/constants/react/helpers.js.map +1 -1
- package/dist/utils/constants/resolveIdentifier/isGTComponent.js +41 -76
- package/dist/utils/constants/resolveIdentifier/isGTComponent.js.map +1 -1
- package/dist/utils/constants/resolveIdentifier/isReactJsxFunction.js +33 -83
- package/dist/utils/constants/resolveIdentifier/isReactJsxFunction.js.map +1 -1
- package/dist/utils/errors.js +18 -20
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/multiplication/multiply.js +31 -35
- package/dist/utils/multiplication/multiply.js.map +1 -1
- package/dist/utils/multiplication/types.js +1 -3
- package/dist/utils/parsing/extractIdentifiersFromLVal.js +30 -96
- package/dist/utils/parsing/extractIdentifiersFromLVal.js.map +1 -1
- package/dist/utils/parsing/getCalleeNameFromExpression.js +31 -65
- package/dist/utils/parsing/getCalleeNameFromExpression.js.map +1 -1
- package/dist/utils/parsing/getCalleeNameFromExpressionWrapper.js +13 -10
- package/dist/utils/parsing/getCalleeNameFromExpressionWrapper.js.map +1 -1
- package/dist/utils/parsing/getObjectPropertyFromObjectExpression.js +19 -56
- package/dist/utils/parsing/getObjectPropertyFromObjectExpression.js.map +1 -1
- package/dist/utils/parsing/getStringLiteralFromExpression.js +18 -49
- package/dist/utils/parsing/getStringLiteralFromExpression.js.map +1 -1
- package/dist/utils/parsing/isDeriveInvocation.js +25 -61
- package/dist/utils/parsing/isDeriveInvocation.js.map +1 -1
- package/dist/utils/parsing/isStringTranslationTaggedTemplate.js +23 -59
- package/dist/utils/parsing/isStringTranslationTaggedTemplate.js.map +1 -1
- package/dist/utils/string-expressions/buildTransformationResult.js +57 -96
- package/dist/utils/string-expressions/buildTransformationResult.js.map +1 -1
- package/dist/utils/string-expressions/flattenExpressionToParts.js +131 -142
- package/dist/utils/string-expressions/flattenExpressionToParts.js.map +1 -1
- package/dist/utils/string-expressions/resolveStaticExpression.js +36 -34
- package/dist/utils/string-expressions/resolveStaticExpression.js.map +1 -1
- package/dist/utils/validation/validateChildrenFromObjectExpression.js +29 -24
- package/dist/utils/validation/validateChildrenFromObjectExpression.js.map +1 -1
- package/dist/utils/validation/validateExpressionIsNumericLiteral.js +13 -47
- package/dist/utils/validation/validateExpressionIsNumericLiteral.js.map +1 -1
- package/dist/utils/validation/validateExpressionIsStringLiteral.js +15 -48
- package/dist/utils/validation/validateExpressionIsStringLiteral.js.map +1 -1
- package/package.json +8 -5
- package/dist/processing/index.js.map +0 -1
- package/dist/state/types.js.map +0 -1
- package/dist/transform/jsx-children/index.js.map +0 -1
- package/dist/utils/multiplication/types.js.map +0 -1
|
@@ -1,424 +1,315 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
function updateCalleeToSingle({ jsxCallPath, state
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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
|
-
|
|
324
|
-
calleeInfo.singleCallee === calleeInfo.multiCallee);
|
|
231
|
+
return calleeInfo.singleCallee != null && calleeInfo.singleCallee === calleeInfo.multiCallee;
|
|
325
232
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
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
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
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
|