@generaltranslation/compiler 1.3.21 → 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.d.ts +11 -2
- package/dist/state/ScopeTracker.d.ts.map +1 -1
- package/dist/state/ScopeTracker.js +154 -209
- package/dist/state/ScopeTracker.js.map +1 -1
- package/dist/state/StringCollector.d.ts +9 -2
- package/dist/state/StringCollector.d.ts.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.d.ts +1 -1
- package/dist/transform/jsx-children/constructJsxChildren.d.ts.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.d.ts +1 -1
- package/dist/transform/validation/validateTranslationComponentArgs.d.ts.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.d.ts +1 -1
- package/dist/utils/calculateHash.d.ts.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.d.ts +1 -1
- package/dist/utils/constants/gt/helpers.d.ts.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 -4
- 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,106 +1,40 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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.extractIdentifiersFromLVal = extractIdentifiersFromLVal;
|
|
37
|
-
const t = __importStar(require("@babel/types"));
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
3
|
+
let _babel_types = require("@babel/types");
|
|
4
|
+
_babel_types = require_runtime.__toESM(_babel_types);
|
|
5
|
+
//#region src/utils/parsing/extractIdentifiersFromLVal.ts
|
|
38
6
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
7
|
+
* Extract identifiers from destructuring patterns
|
|
8
|
+
*/
|
|
41
9
|
function extractIdentifiersFromLVal(pattern) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// Handle rest element: const { ...rest } = anything
|
|
51
|
-
identifiers.push(...extractIdentifiersFromLVal(pattern.argument));
|
|
52
|
-
}
|
|
53
|
-
else if (t.isAssignmentPattern(pattern)) {
|
|
54
|
-
// Handle assignment pattern: const { t } = anything
|
|
55
|
-
identifiers.push(...extractIdentifiersFromLVal(pattern.left));
|
|
56
|
-
}
|
|
57
|
-
else if (t.isArrayPattern(pattern)) {
|
|
58
|
-
// Handle array pattern: const [t, ...rest] = anything
|
|
59
|
-
identifiers.push(...handleArrayPattern(pattern));
|
|
60
|
-
}
|
|
61
|
-
else if (t.isObjectPattern(pattern)) {
|
|
62
|
-
// Handle object pattern: const { t, ...rest } = anything
|
|
63
|
-
identifiers.push(...handleObjectPattern(pattern));
|
|
64
|
-
}
|
|
65
|
-
else if (t.isTSParameterProperty(pattern)) {
|
|
66
|
-
// Handle TS parameter property: const { t }: { t: string } = anything
|
|
67
|
-
identifiers.push(...extractIdentifiersFromLVal(pattern.parameter));
|
|
68
|
-
}
|
|
69
|
-
return identifiers;
|
|
10
|
+
const identifiers = [];
|
|
11
|
+
if (_babel_types.isIdentifier(pattern)) identifiers.push(pattern.name);
|
|
12
|
+
else if (_babel_types.isRestElement(pattern)) identifiers.push(...extractIdentifiersFromLVal(pattern.argument));
|
|
13
|
+
else if (_babel_types.isAssignmentPattern(pattern)) identifiers.push(...extractIdentifiersFromLVal(pattern.left));
|
|
14
|
+
else if (_babel_types.isArrayPattern(pattern)) identifiers.push(...handleArrayPattern(pattern));
|
|
15
|
+
else if (_babel_types.isObjectPattern(pattern)) identifiers.push(...handleObjectPattern(pattern));
|
|
16
|
+
else if (_babel_types.isTSParameterProperty(pattern)) identifiers.push(...extractIdentifiersFromLVal(pattern.parameter));
|
|
17
|
+
return identifiers;
|
|
70
18
|
}
|
|
71
|
-
/* =============================== */
|
|
72
|
-
/* Helper Functions */
|
|
73
|
-
/* =============================== */
|
|
74
19
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
20
|
+
* Handle object pattern: const { t } = anything
|
|
21
|
+
*/
|
|
77
22
|
function handleObjectPattern(pattern) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
identifiers.push(...extractIdentifiersFromLVal(prop.value));
|
|
84
|
-
}
|
|
85
|
-
// Ignore Expressions, VoidPattern
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
// Rest element: const { ...rest } = anything
|
|
89
|
-
identifiers.push(...extractIdentifiersFromLVal(prop.argument));
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return identifiers;
|
|
23
|
+
const identifiers = [];
|
|
24
|
+
for (const prop of pattern.properties) if (_babel_types.isObjectProperty(prop)) {
|
|
25
|
+
if (_babel_types.isLVal(prop.value)) identifiers.push(...extractIdentifiersFromLVal(prop.value));
|
|
26
|
+
} else identifiers.push(...extractIdentifiersFromLVal(prop.argument));
|
|
27
|
+
return identifiers;
|
|
93
28
|
}
|
|
94
29
|
/**
|
|
95
|
-
|
|
96
|
-
|
|
30
|
+
* Handle ArrayPattern: const [t, ...rest] = anything
|
|
31
|
+
*/
|
|
97
32
|
function handleArrayPattern(pattern) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
identifiers.push(...extractIdentifiersFromLVal(elem));
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return identifiers;
|
|
33
|
+
const identifiers = [];
|
|
34
|
+
for (const elem of pattern.elements) if (elem && _babel_types.isLVal(elem)) identifiers.push(...extractIdentifiersFromLVal(elem));
|
|
35
|
+
return identifiers;
|
|
105
36
|
}
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.extractIdentifiersFromLVal = extractIdentifiersFromLVal;
|
|
39
|
+
|
|
106
40
|
//# sourceMappingURL=extractIdentifiersFromLVal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractIdentifiersFromLVal.js","
|
|
1
|
+
{"version":3,"file":"extractIdentifiersFromLVal.js","names":["t"],"sources":["../../../src/utils/parsing/extractIdentifiersFromLVal.ts"],"sourcesContent":["import * as t from '@babel/types';\n\n/**\n * Extract identifiers from destructuring patterns\n */\nexport function extractIdentifiersFromLVal(pattern: t.LVal): string[] {\n const identifiers: string[] = [];\n // Get all variables from the LVal\n // ignore: MemberExpression | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression\n if (t.isIdentifier(pattern)) {\n // Handle identifier: const t;\n identifiers.push(pattern.name);\n } else if (t.isRestElement(pattern)) {\n // Handle rest element: const { ...rest } = anything\n identifiers.push(...extractIdentifiersFromLVal(pattern.argument));\n } else if (t.isAssignmentPattern(pattern)) {\n // Handle assignment pattern: const { t } = anything\n identifiers.push(...extractIdentifiersFromLVal(pattern.left));\n } else if (t.isArrayPattern(pattern)) {\n // Handle array pattern: const [t, ...rest] = anything\n identifiers.push(...handleArrayPattern(pattern));\n } else if (t.isObjectPattern(pattern)) {\n // Handle object pattern: const { t, ...rest } = anything\n identifiers.push(...handleObjectPattern(pattern));\n } else if (t.isTSParameterProperty(pattern)) {\n // Handle TS parameter property: const { t }: { t: string } = anything\n identifiers.push(...extractIdentifiersFromLVal(pattern.parameter));\n }\n return identifiers;\n}\n\n/* =============================== */\n/* Helper Functions */\n/* =============================== */\n\n/**\n * Handle object pattern: const { t } = anything\n */\nfunction handleObjectPattern(pattern: t.ObjectPattern): string[] {\n const identifiers: string[] = [];\n for (const prop of pattern.properties) {\n if (t.isObjectProperty(prop)) {\n // LVal: const { t } = anything\n if (t.isLVal(prop.value)) {\n identifiers.push(...extractIdentifiersFromLVal(prop.value));\n }\n // Ignore Expressions, VoidPattern\n } else {\n // Rest element: const { ...rest } = anything\n identifiers.push(...extractIdentifiersFromLVal(prop.argument));\n }\n }\n return identifiers;\n}\n\n/**\n * Handle ArrayPattern: const [t, ...rest] = anything\n */\nfunction handleArrayPattern(pattern: t.ArrayPattern): string[] {\n const identifiers: string[] = [];\n for (const elem of pattern.elements) {\n if (elem && t.isLVal(elem)) {\n identifiers.push(...extractIdentifiersFromLVal(elem));\n }\n }\n return identifiers;\n}\n"],"mappings":";;;;;;;;AAKA,SAAgB,2BAA2B,SAA2B;CACpE,MAAM,cAAwB,EAAE;AAGhC,KAAIA,aAAE,aAAa,QAAQ,CAEzB,aAAY,KAAK,QAAQ,KAAK;UACrBA,aAAE,cAAc,QAAQ,CAEjC,aAAY,KAAK,GAAG,2BAA2B,QAAQ,SAAS,CAAC;UACxDA,aAAE,oBAAoB,QAAQ,CAEvC,aAAY,KAAK,GAAG,2BAA2B,QAAQ,KAAK,CAAC;UACpDA,aAAE,eAAe,QAAQ,CAElC,aAAY,KAAK,GAAG,mBAAmB,QAAQ,CAAC;UACvCA,aAAE,gBAAgB,QAAQ,CAEnC,aAAY,KAAK,GAAG,oBAAoB,QAAQ,CAAC;UACxCA,aAAE,sBAAsB,QAAQ,CAEzC,aAAY,KAAK,GAAG,2BAA2B,QAAQ,UAAU,CAAC;AAEpE,QAAO;;;;;AAUT,SAAS,oBAAoB,SAAoC;CAC/D,MAAM,cAAwB,EAAE;AAChC,MAAK,MAAM,QAAQ,QAAQ,WACzB,KAAIA,aAAE,iBAAiB,KAAK;MAEtBA,aAAE,OAAO,KAAK,MAAM,CACtB,aAAY,KAAK,GAAG,2BAA2B,KAAK,MAAM,CAAC;OAK7D,aAAY,KAAK,GAAG,2BAA2B,KAAK,SAAS,CAAC;AAGlE,QAAO;;;;;AAMT,SAAS,mBAAmB,SAAmC;CAC7D,MAAM,cAAwB,EAAE;AAChC,MAAK,MAAM,QAAQ,QAAQ,SACzB,KAAI,QAAQA,aAAE,OAAO,KAAK,CACxB,aAAY,KAAK,GAAG,2BAA2B,KAAK,CAAC;AAGzD,QAAO"}
|
|
@@ -1,69 +1,35 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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.getCalleeNameFromExpression = getCalleeNameFromExpression;
|
|
37
|
-
const t = __importStar(require("@babel/types"));
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
3
|
+
let _babel_types = require("@babel/types");
|
|
4
|
+
_babel_types = require_runtime.__toESM(_babel_types);
|
|
5
|
+
//#region src/utils/parsing/getCalleeNameFromExpression.ts
|
|
38
6
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
7
|
+
* Get the callee name from an expression: ... = useGT();
|
|
8
|
+
* Rule of thumb, only call on expressions with parentheses
|
|
9
|
+
*/
|
|
42
10
|
function getCalleeNameFromExpression(expr) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
functionName: calleeName.property.name,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return { namespaceName: null, functionName: null };
|
|
11
|
+
if (_babel_types.isAwaitExpression(expr)) return getCalleeNameFromExpression(expr.argument);
|
|
12
|
+
if (!_babel_types.isCallExpression(expr)) return {
|
|
13
|
+
namespaceName: null,
|
|
14
|
+
functionName: null
|
|
15
|
+
};
|
|
16
|
+
const calleeName = expr.callee;
|
|
17
|
+
if (_babel_types.isIdentifier(calleeName)) return {
|
|
18
|
+
namespaceName: null,
|
|
19
|
+
functionName: calleeName.name
|
|
20
|
+
};
|
|
21
|
+
if (_babel_types.isMemberExpression(calleeName)) {
|
|
22
|
+
if (_babel_types.isIdentifier(calleeName.object) && _babel_types.isIdentifier(calleeName.property)) return {
|
|
23
|
+
namespaceName: calleeName.object.name,
|
|
24
|
+
functionName: calleeName.property.name
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
namespaceName: null,
|
|
29
|
+
functionName: null
|
|
30
|
+
};
|
|
68
31
|
}
|
|
32
|
+
//#endregion
|
|
33
|
+
exports.getCalleeNameFromExpression = getCalleeNameFromExpression;
|
|
34
|
+
|
|
69
35
|
//# sourceMappingURL=getCalleeNameFromExpression.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCalleeNameFromExpression.js","
|
|
1
|
+
{"version":3,"file":"getCalleeNameFromExpression.js","names":["t"],"sources":["../../../src/utils/parsing/getCalleeNameFromExpression.ts"],"sourcesContent":["import * as t from '@babel/types';\n\n/**\n * Get the callee name from an expression: ... = useGT();\n * Rule of thumb, only call on expressions with parentheses\n */\nexport function getCalleeNameFromExpression(expr: t.Expression): {\n namespaceName: string | null;\n functionName: string | null;\n} {\n // If its an await expression, unwrap it\n if (t.isAwaitExpression(expr)) {\n return getCalleeNameFromExpression(expr.argument);\n }\n\n // Check that this is a call expression eg: func()\n if (!t.isCallExpression(expr)) {\n return { namespaceName: null, functionName: null };\n }\n\n // Get the callee name\n const calleeName = expr.callee;\n\n // Simple case: ... = useGT();\n if (t.isIdentifier(calleeName)) {\n return { namespaceName: null, functionName: calleeName.name };\n }\n\n // Member expression: ... = GT.useGT();\n if (t.isMemberExpression(calleeName)) {\n if (\n t.isIdentifier(calleeName.object) &&\n t.isIdentifier(calleeName.property)\n ) {\n return {\n namespaceName: calleeName.object.name,\n functionName: calleeName.property.name,\n };\n }\n }\n\n return { namespaceName: null, functionName: null };\n}\n"],"mappings":";;;;;;;;;AAMA,SAAgB,4BAA4B,MAG1C;AAEA,KAAIA,aAAE,kBAAkB,KAAK,CAC3B,QAAO,4BAA4B,KAAK,SAAS;AAInD,KAAI,CAACA,aAAE,iBAAiB,KAAK,CAC3B,QAAO;EAAE,eAAe;EAAM,cAAc;EAAM;CAIpD,MAAM,aAAa,KAAK;AAGxB,KAAIA,aAAE,aAAa,WAAW,CAC5B,QAAO;EAAE,eAAe;EAAM,cAAc,WAAW;EAAM;AAI/D,KAAIA,aAAE,mBAAmB,WAAW;MAEhCA,aAAE,aAAa,WAAW,OAAO,IACjCA,aAAE,aAAa,WAAW,SAAS,CAEnC,QAAO;GACL,eAAe,WAAW,OAAO;GACjC,cAAc,WAAW,SAAS;GACnC;;AAIL,QAAO;EAAE,eAAe;EAAM,cAAc;EAAM"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const getCalleeNameFromExpression_1 = require("./getCalleeNameFromExpression");
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils_parsing_getCalleeNameFromExpression = require("./getCalleeNameFromExpression.js");
|
|
3
|
+
//#region src/utils/parsing/getCalleeNameFromExpressionWrapper.ts
|
|
5
4
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
* Get the callee name from an expression: ... = useGT();
|
|
6
|
+
*/
|
|
8
7
|
function getCalleeNameFromExpressionWrapper(expr) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
if (!expr) return {
|
|
9
|
+
namespaceName: null,
|
|
10
|
+
functionName: null
|
|
11
|
+
};
|
|
12
|
+
return require_utils_parsing_getCalleeNameFromExpression.getCalleeNameFromExpression(expr);
|
|
13
13
|
}
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.getCalleeNameFromExpressionWrapper = getCalleeNameFromExpressionWrapper;
|
|
16
|
+
|
|
14
17
|
//# sourceMappingURL=getCalleeNameFromExpressionWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCalleeNameFromExpressionWrapper.js","
|
|
1
|
+
{"version":3,"file":"getCalleeNameFromExpressionWrapper.js","names":["getCalleeNameFromExpression"],"sources":["../../../src/utils/parsing/getCalleeNameFromExpressionWrapper.ts"],"sourcesContent":["import * as t from '@babel/types';\nimport { getCalleeNameFromExpression } from './getCalleeNameFromExpression';\n/**\n * Get the callee name from an expression: ... = useGT();\n */\nexport function getCalleeNameFromExpressionWrapper(\n expr: t.Expression | null | undefined\n): {\n namespaceName: string | null;\n functionName: string | null;\n} {\n if (!expr) {\n return { namespaceName: null, functionName: null };\n }\n return getCalleeNameFromExpression(expr);\n}\n"],"mappings":";;;;;;AAKA,SAAgB,mCACd,MAIA;AACA,KAAI,CAAC,KACH,QAAO;EAAE,eAAe;EAAM,cAAc;EAAM;AAEpD,QAAOA,kDAAAA,4BAA4B,KAAK"}
|
|
@@ -1,65 +1,28 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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.getObjectPropertyFromObjectExpression = getObjectPropertyFromObjectExpression;
|
|
37
|
-
exports.getObjectPropertyPathFromObjectExpression = getObjectPropertyPathFromObjectExpression;
|
|
38
|
-
const t = __importStar(require("@babel/types"));
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
3
|
+
let _babel_types = require("@babel/types");
|
|
4
|
+
_babel_types = require_runtime.__toESM(_babel_types);
|
|
5
|
+
//#region src/utils/parsing/getObjectPropertyFromObjectExpression.ts
|
|
39
6
|
function objectPropertyMatchesName(property, name) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
if (t.isStringLiteral(property.key) && property.key.value === name) {
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
return false;
|
|
7
|
+
if (_babel_types.isSpreadElement(property)) return false;
|
|
8
|
+
if (_babel_types.isIdentifier(property.key) && property.key.name === name) return true;
|
|
9
|
+
if (_babel_types.isStringLiteral(property.key) && property.key.value === name) return true;
|
|
10
|
+
return false;
|
|
50
11
|
}
|
|
51
12
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
13
|
+
* Given an expression, return the object property
|
|
14
|
+
*/
|
|
54
15
|
function getObjectPropertyFromObjectExpression(objExpr, name) {
|
|
55
|
-
|
|
16
|
+
return objExpr.properties.find((property) => objectPropertyMatchesName(property, name));
|
|
56
17
|
}
|
|
57
18
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
19
|
+
* Given an expression path, return the object property path
|
|
20
|
+
*/
|
|
60
21
|
function getObjectPropertyPathFromObjectExpression(objExprPath, name) {
|
|
61
|
-
|
|
62
|
-
.get('properties')
|
|
63
|
-
.find((propertyPath) => objectPropertyMatchesName(propertyPath.node, name));
|
|
22
|
+
return objExprPath.get("properties").find((propertyPath) => objectPropertyMatchesName(propertyPath.node, name));
|
|
64
23
|
}
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.getObjectPropertyFromObjectExpression = getObjectPropertyFromObjectExpression;
|
|
26
|
+
exports.getObjectPropertyPathFromObjectExpression = getObjectPropertyPathFromObjectExpression;
|
|
27
|
+
|
|
65
28
|
//# sourceMappingURL=getObjectPropertyFromObjectExpression.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getObjectPropertyFromObjectExpression.js","
|
|
1
|
+
{"version":3,"file":"getObjectPropertyFromObjectExpression.js","names":["t"],"sources":["../../../src/utils/parsing/getObjectPropertyFromObjectExpression.ts"],"sourcesContent":["import type { NodePath } from '@babel/traverse';\nimport * as t from '@babel/types';\n\nfunction objectPropertyMatchesName(\n property: t.ObjectExpression['properties'][0],\n name: string\n): boolean {\n if (t.isSpreadElement(property)) {\n return false;\n }\n if (t.isIdentifier(property.key) && property.key.name === name) {\n return true;\n }\n if (t.isStringLiteral(property.key) && property.key.value === name) {\n return true;\n }\n return false;\n}\n\n/**\n * Given an expression, return the object property\n */\nexport function getObjectPropertyFromObjectExpression(\n objExpr: t.ObjectExpression,\n name: string\n): t.ObjectExpression['properties'][0] | undefined {\n return objExpr.properties.find((property) =>\n objectPropertyMatchesName(property, name)\n );\n}\n\n/**\n * Given an expression path, return the object property path\n */\nexport function getObjectPropertyPathFromObjectExpression(\n objExprPath: NodePath<t.ObjectExpression>,\n name: string\n): NodePath<t.ObjectExpression['properties'][0]> | undefined {\n return objExprPath\n .get('properties')\n .find((propertyPath) =>\n objectPropertyMatchesName(propertyPath.node, name)\n ) as NodePath<t.ObjectExpression['properties'][0]> | undefined;\n}\n"],"mappings":";;;;;AAGA,SAAS,0BACP,UACA,MACS;AACT,KAAIA,aAAE,gBAAgB,SAAS,CAC7B,QAAO;AAET,KAAIA,aAAE,aAAa,SAAS,IAAI,IAAI,SAAS,IAAI,SAAS,KACxD,QAAO;AAET,KAAIA,aAAE,gBAAgB,SAAS,IAAI,IAAI,SAAS,IAAI,UAAU,KAC5D,QAAO;AAET,QAAO;;;;;AAMT,SAAgB,sCACd,SACA,MACiD;AACjD,QAAO,QAAQ,WAAW,MAAM,aAC9B,0BAA0B,UAAU,KAAK,CAC1C;;;;;AAMH,SAAgB,0CACd,aACA,MAC2D;AAC3D,QAAO,YACJ,IAAI,aAAa,CACjB,MAAM,iBACL,0BAA0B,aAAa,MAAM,KAAK,CACnD"}
|
|
@@ -1,53 +1,22 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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.getStringLiteralFromExpression = getStringLiteralFromExpression;
|
|
37
|
-
const t = __importStar(require("@babel/types"));
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
3
|
+
let _babel_types = require("@babel/types");
|
|
4
|
+
_babel_types = require_runtime.__toESM(_babel_types);
|
|
5
|
+
//#region src/utils/parsing/getStringLiteralFromExpression.ts
|
|
38
6
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
7
|
+
* Given an expression, return the string literal (throws an error if not a string literal)
|
|
8
|
+
*/
|
|
41
9
|
function getStringLiteralFromExpression(expr) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
throw new Error('Expression is not a string literal');
|
|
10
|
+
if (_babel_types.isStringLiteral(expr)) return expr.value;
|
|
11
|
+
if (_babel_types.isTemplateLiteral(expr)) {
|
|
12
|
+
if (expr.expressions.length === 0) {
|
|
13
|
+
var _expr$quasis$;
|
|
14
|
+
return ((_expr$quasis$ = expr.quasis[0]) === null || _expr$quasis$ === void 0 ? void 0 : _expr$quasis$.value.cooked) || "";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
throw new Error("Expression is not a string literal");
|
|
52
18
|
}
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.getStringLiteralFromExpression = getStringLiteralFromExpression;
|
|
21
|
+
|
|
53
22
|
//# sourceMappingURL=getStringLiteralFromExpression.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStringLiteralFromExpression.js","
|
|
1
|
+
{"version":3,"file":"getStringLiteralFromExpression.js","names":["t"],"sources":["../../../src/utils/parsing/getStringLiteralFromExpression.ts"],"sourcesContent":["import * as t from '@babel/types';\n/**\n * Given an expression, return the string literal (throws an error if not a string literal)\n */\nexport function getStringLiteralFromExpression(expr: t.Expression): string {\n if (t.isStringLiteral(expr)) {\n return expr.value;\n }\n if (t.isTemplateLiteral(expr)) {\n if (expr.expressions.length === 0) {\n return expr.quasis[0]?.value.cooked || '';\n }\n }\n throw new Error('Expression is not a string literal');\n}\n"],"mappings":";;;;;;;;AAIA,SAAgB,+BAA+B,MAA4B;AACzE,KAAIA,aAAE,gBAAgB,KAAK,CACzB,QAAO,KAAK;AAEd,KAAIA,aAAE,kBAAkB,KAAK;MACvB,KAAK,YAAY,WAAW,GAAG;;AACjC,YAAA,gBAAO,KAAK,OAAO,QAAA,QAAA,kBAAA,KAAA,IAAA,KAAA,IAAA,cAAI,MAAM,WAAU;;;AAG3C,OAAM,IAAI,MAAM,qCAAqC"}
|
|
@@ -1,65 +1,29 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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.isDeriveInvocation = isDeriveInvocation;
|
|
37
|
-
const t = __importStar(require("@babel/types"));
|
|
38
|
-
const helpers_1 = require("../constants/gt/helpers");
|
|
39
|
-
const constants_1 = require("../constants/gt/constants");
|
|
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("../constants/gt/constants.js");
|
|
4
|
+
const require_utils_constants_gt_helpers = require("../constants/gt/helpers.js");
|
|
5
|
+
let _babel_types = require("@babel/types");
|
|
6
|
+
_babel_types = require_runtime.__toESM(_babel_types);
|
|
7
|
+
//#region src/utils/parsing/isDeriveInvocation.ts
|
|
40
8
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
9
|
+
* Skip un-interpolation step for derive invocations
|
|
10
|
+
* @param {t.Expression} expr - The expression to check
|
|
11
|
+
* @returns {boolean} True if the expression is a derive invocation, false otherwise
|
|
12
|
+
*/
|
|
45
13
|
function isDeriveInvocation(expr, scope) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (!(0, helpers_1.isGTImportSource)(importSource))
|
|
58
|
-
return false;
|
|
59
|
-
const imported = binding.path.node.imported;
|
|
60
|
-
const originalName = t.isIdentifier(imported)
|
|
61
|
-
? imported.name
|
|
62
|
-
: imported.value;
|
|
63
|
-
return constants_1.GT_DERIVE_STRING_FUNCTIONS.includes(originalName);
|
|
14
|
+
if (!_babel_types.isCallExpression(expr) || !_babel_types.isIdentifier(expr.callee)) return false;
|
|
15
|
+
const binding = scope.getBinding(expr.callee.name);
|
|
16
|
+
if (!binding) return false;
|
|
17
|
+
if (!binding.path.isImportSpecifier()) return false;
|
|
18
|
+
const importDecl = binding.path.parentPath;
|
|
19
|
+
if (!(importDecl === null || importDecl === void 0 ? void 0 : importDecl.isImportDeclaration())) return false;
|
|
20
|
+
const importSource = importDecl.node.source.value;
|
|
21
|
+
if (!require_utils_constants_gt_helpers.isGTImportSource(importSource)) return false;
|
|
22
|
+
const imported = binding.path.node.imported;
|
|
23
|
+
const originalName = _babel_types.isIdentifier(imported) ? imported.name : imported.value;
|
|
24
|
+
return require_utils_constants_gt_constants.GT_DERIVE_STRING_FUNCTIONS.includes(originalName);
|
|
64
25
|
}
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.isDeriveInvocation = isDeriveInvocation;
|
|
28
|
+
|
|
65
29
|
//# sourceMappingURL=isDeriveInvocation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isDeriveInvocation.js","
|
|
1
|
+
{"version":3,"file":"isDeriveInvocation.js","names":["t","isGTImportSource","GT_DERIVE_STRING_FUNCTIONS"],"sources":["../../../src/utils/parsing/isDeriveInvocation.ts"],"sourcesContent":["import * as t from '@babel/types';\nimport { Scope } from '@babel/traverse';\nimport { isGTImportSource } from '../constants/gt/helpers';\nimport { GT_DERIVE_STRING_FUNCTIONS } from '../constants/gt/constants';\n\n/**\n * Skip un-interpolation step for derive invocations\n * @param {t.Expression} expr - The expression to check\n * @returns {boolean} True if the expression is a derive invocation, false otherwise\n */\nexport function isDeriveInvocation(expr: t.Expression, scope: Scope): boolean {\n if (!t.isCallExpression(expr) || !t.isIdentifier(expr.callee)) return false;\n const binding = scope.getBinding(expr.callee.name);\n if (!binding) return false;\n if (!binding.path.isImportSpecifier()) return false;\n const importDecl = binding.path.parentPath;\n if (!importDecl?.isImportDeclaration()) return false;\n const importSource = importDecl.node.source.value;\n if (!isGTImportSource(importSource)) return false;\n const imported = binding.path.node.imported;\n const originalName = t.isIdentifier(imported)\n ? imported.name\n : imported.value;\n return GT_DERIVE_STRING_FUNCTIONS.includes(\n originalName as (typeof GT_DERIVE_STRING_FUNCTIONS)[number]\n );\n}\n"],"mappings":";;;;;;;;;;;;AAUA,SAAgB,mBAAmB,MAAoB,OAAuB;AAC5E,KAAI,CAACA,aAAE,iBAAiB,KAAK,IAAI,CAACA,aAAE,aAAa,KAAK,OAAO,CAAE,QAAO;CACtE,MAAM,UAAU,MAAM,WAAW,KAAK,OAAO,KAAK;AAClD,KAAI,CAAC,QAAS,QAAO;AACrB,KAAI,CAAC,QAAQ,KAAK,mBAAmB,CAAE,QAAO;CAC9C,MAAM,aAAa,QAAQ,KAAK;AAChC,KAAI,EAAA,eAAA,QAAA,eAAA,KAAA,IAAA,KAAA,IAAC,WAAY,qBAAqB,EAAE,QAAO;CAC/C,MAAM,eAAe,WAAW,KAAK,OAAO;AAC5C,KAAI,CAACC,mCAAAA,iBAAiB,aAAa,CAAE,QAAO;CAC5C,MAAM,WAAW,QAAQ,KAAK,KAAK;CACnC,MAAM,eAAeD,aAAE,aAAa,SAAS,GACzC,SAAS,OACT,SAAS;AACb,QAAOE,qCAAAA,2BAA2B,SAChC,aACD"}
|