gt 2.14.35 → 2.14.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -1
- package/dist/api/collectUserEditDiffs.js +112 -155
- package/dist/api/collectUserEditDiffs.js.map +1 -0
- package/dist/api/downloadFileBatch.js +164 -241
- package/dist/api/downloadFileBatch.js.map +1 -0
- package/dist/api/saveLocalEdits.js +37 -41
- package/dist/api/saveLocalEdits.js.map +1 -0
- package/dist/bin/bin-entry.js +17 -7
- package/dist/bin/bin-entry.js.map +1 -0
- package/dist/bin/bin-main.js +43 -61
- package/dist/bin/bin-main.js.map +1 -0
- package/dist/cli/base.js +382 -497
- package/dist/cli/base.js.map +1 -0
- package/dist/cli/commands/download.js +41 -49
- package/dist/cli/commands/download.js.map +1 -0
- package/dist/cli/commands/enqueue.js +26 -25
- package/dist/cli/commands/enqueue.js.map +1 -0
- package/dist/cli/commands/setupProject.js +33 -36
- package/dist/cli/commands/setupProject.js.map +1 -0
- package/dist/cli/commands/stage.js +53 -61
- package/dist/cli/commands/stage.js.map +1 -0
- package/dist/cli/commands/translate.js +75 -112
- package/dist/cli/commands/translate.js.map +1 -0
- package/dist/cli/commands/upload.js +185 -213
- package/dist/cli/commands/upload.js.map +1 -0
- package/dist/cli/commands/utils/validation.js +39 -34
- package/dist/cli/commands/utils/validation.js.map +1 -0
- package/dist/cli/flags.js +35 -62
- package/dist/cli/flags.js.map +1 -0
- package/dist/cli/inline.js +112 -137
- package/dist/cli/inline.js.map +1 -0
- package/dist/cli/next.js +17 -12
- package/dist/cli/next.js.map +1 -0
- package/dist/cli/node.js +19 -15
- package/dist/cli/node.js.map +1 -0
- package/dist/cli/python.js +13 -8
- package/dist/cli/python.js.map +1 -0
- package/dist/cli/react.js +61 -78
- package/dist/cli/react.js.map +1 -0
- package/dist/config/defaults.js +16 -11
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/generateSettings.js +167 -269
- package/dist/config/generateSettings.js.map +1 -0
- package/dist/config/optionPresets.js +78 -96
- package/dist/config/optionPresets.js.map +1 -0
- package/dist/config/resolveConfig.js +27 -32
- package/dist/config/resolveConfig.js.map +1 -0
- package/dist/config/utils.js +7 -3
- package/dist/config/utils.js.map +1 -0
- package/dist/config/validateSettings.js +19 -30
- package/dist/config/validateSettings.js.map +1 -0
- package/dist/console/colors.js +18 -13
- package/dist/console/colors.js.map +1 -0
- package/dist/console/displayTranslateSummary.js +40 -37
- package/dist/console/displayTranslateSummary.js.map +1 -0
- package/dist/console/formatting.js +8 -5
- package/dist/console/formatting.js.map +1 -0
- package/dist/console/index.d.ts +11 -9
- package/dist/console/index.js +53 -50
- package/dist/console/index.js.map +1 -0
- package/dist/console/inkFields.d.ts +23 -0
- package/dist/console/inkFields.js +87 -0
- package/dist/console/inkFields.js.map +1 -0
- package/dist/console/inkLayout.d.ts +7 -0
- package/dist/console/inkLayout.js +139 -0
- package/dist/console/inkLayout.js.map +1 -0
- package/dist/console/inkLocaleData.d.ts +4 -0
- package/dist/console/inkLocaleData.js +32 -0
- package/dist/console/inkLocaleData.js.map +1 -0
- package/dist/console/inkPrompts.d.ts +8 -0
- package/dist/console/inkPrompts.js +496 -0
- package/dist/console/inkPrompts.js.map +1 -0
- package/dist/console/inkSession.d.ts +3 -0
- package/dist/console/inkSession.js +42 -0
- package/dist/console/inkSession.js.map +1 -0
- package/dist/console/inkTerminal.d.ts +4 -0
- package/dist/console/inkTerminal.js +15 -0
- package/dist/console/inkTerminal.js.map +1 -0
- package/dist/console/inkTypes.d.ts +66 -0
- package/dist/console/inkTypes.js +1 -0
- package/dist/console/inkUtils.d.ts +24 -0
- package/dist/console/inkUtils.js +87 -0
- package/dist/console/inkUtils.js.map +1 -0
- package/dist/console/logger.js +209 -249
- package/dist/console/logger.js.map +1 -0
- package/dist/console/logging.d.ts +14 -0
- package/dist/console/logging.js +203 -162
- package/dist/console/logging.js.map +1 -0
- package/dist/console/promptParsing.d.ts +5 -0
- package/dist/console/promptParsing.js +28 -0
- package/dist/console/promptParsing.js.map +1 -0
- package/dist/console/terminalSession.d.ts +5 -0
- package/dist/console/terminalSession.js +38 -0
- package/dist/console/terminalSession.js.map +1 -0
- package/dist/extraction/index.js +3 -2
- package/dist/extraction/mapToUpdates.js +19 -18
- package/dist/extraction/mapToUpdates.js.map +1 -0
- package/dist/extraction/postProcess.js +68 -86
- package/dist/extraction/postProcess.js.map +1 -0
- package/dist/formats/files/aggregateFiles.js +223 -304
- package/dist/formats/files/aggregateFiles.js.map +1 -0
- package/dist/formats/files/collectFiles.js +53 -54
- package/dist/formats/files/collectFiles.js.map +1 -0
- package/dist/formats/files/convertToFileTranslationData.js +21 -19
- package/dist/formats/files/convertToFileTranslationData.js.map +1 -0
- package/dist/formats/files/fileMapping.js +82 -119
- package/dist/formats/files/fileMapping.js.map +1 -0
- package/dist/formats/files/preprocess/mdx.js +15 -12
- package/dist/formats/files/preprocess/mdx.js.map +1 -0
- package/dist/formats/files/preprocess/mintlify.js +15 -13
- package/dist/formats/files/preprocess/mintlify.js.map +1 -0
- package/dist/formats/files/preprocessContent.js +20 -21
- package/dist/formats/files/preprocessContent.js.map +1 -0
- package/dist/formats/files/save.js +18 -15
- package/dist/formats/files/save.js.map +1 -0
- package/dist/formats/files/supportedFiles.js +27 -22
- package/dist/formats/files/supportedFiles.js.map +1 -0
- package/dist/formats/files/transformFormat.js +93 -100
- package/dist/formats/files/transformFormat.js.map +1 -0
- package/dist/formats/json/extractJson.js +83 -110
- package/dist/formats/json/extractJson.js.map +1 -0
- package/dist/formats/json/flattenJson.js +41 -48
- package/dist/formats/json/flattenJson.js.map +1 -0
- package/dist/formats/json/jsonPath.js +20 -15
- package/dist/formats/json/jsonPath.js.map +1 -0
- package/dist/formats/json/jsonPointer.js +17 -17
- package/dist/formats/json/jsonPointer.js.map +1 -0
- package/dist/formats/json/mergeJson.js +230 -371
- package/dist/formats/json/mergeJson.js.map +1 -0
- package/dist/formats/json/parseJson.js +74 -111
- package/dist/formats/json/parseJson.js.map +1 -0
- package/dist/formats/json/transformJson.js +53 -61
- package/dist/formats/json/transformJson.js.map +1 -0
- package/dist/formats/json/utils.js +158 -187
- package/dist/formats/json/utils.js.map +1 -0
- package/dist/formats/parseKeyedMetadata.js +85 -106
- package/dist/formats/parseKeyedMetadata.js.map +1 -0
- package/dist/formats/utils.js +13 -23
- package/dist/formats/utils.js.map +1 -0
- package/dist/formats/yaml/extractYaml.js +32 -31
- package/dist/formats/yaml/extractYaml.js.map +1 -0
- package/dist/formats/yaml/mergeYaml.js +43 -60
- package/dist/formats/yaml/mergeYaml.js.map +1 -0
- package/dist/formats/yaml/parseYaml.js +34 -23
- package/dist/formats/yaml/parseYaml.js.map +1 -0
- package/dist/formats/yaml/utils.js +19 -21
- package/dist/formats/yaml/utils.js.map +1 -0
- package/dist/fs/clearLocaleDirs.js +82 -114
- package/dist/fs/clearLocaleDirs.js.map +1 -0
- package/dist/fs/config/downloadedVersions.js +174 -188
- package/dist/fs/config/downloadedVersions.js.map +1 -0
- package/dist/fs/config/loadConfig.js +12 -8
- package/dist/fs/config/loadConfig.js.map +1 -0
- package/dist/fs/config/parseFilesConfig.js +166 -227
- package/dist/fs/config/parseFilesConfig.js.map +1 -0
- package/dist/fs/config/setupConfig.js +43 -52
- package/dist/fs/config/setupConfig.js.map +1 -0
- package/dist/fs/config/updateConfig.js +44 -56
- package/dist/fs/config/updateConfig.js.map +1 -0
- package/dist/fs/config/updateVersions.js +27 -28
- package/dist/fs/config/updateVersions.js.map +1 -0
- package/dist/fs/copyFile.js +33 -37
- package/dist/fs/copyFile.js.map +1 -0
- package/dist/fs/createLoadTranslationsFile.js +32 -48
- package/dist/fs/createLoadTranslationsFile.js.map +1 -0
- package/dist/fs/determineFramework/detectPythonLibrary.js +30 -34
- package/dist/fs/determineFramework/detectPythonLibrary.js.map +1 -0
- package/dist/fs/determineFramework/index.js +46 -64
- package/dist/fs/determineFramework/index.js.map +1 -0
- package/dist/fs/determineFramework/matchPyprojectDependency.js +65 -78
- package/dist/fs/determineFramework/matchPyprojectDependency.js.map +1 -0
- package/dist/fs/determineFramework/matchRequirementsTxtDependency.js +21 -19
- package/dist/fs/determineFramework/matchRequirementsTxtDependency.js.map +1 -0
- package/dist/fs/determineFramework/matchSetupPyDependency.js +60 -81
- package/dist/fs/determineFramework/matchSetupPyDependency.js.map +1 -0
- package/dist/fs/determineFramework/resolveGtDependency.js +15 -15
- package/dist/fs/determineFramework/resolveGtDependency.js.map +1 -0
- package/dist/fs/findFilepath.js +63 -78
- package/dist/fs/findFilepath.js.map +1 -0
- package/dist/fs/loadJSON.js +18 -15
- package/dist/fs/loadJSON.js.map +1 -0
- package/dist/fs/matchFiles.js +12 -7
- package/dist/fs/matchFiles.js.map +1 -0
- package/dist/fs/saveJSON.js +10 -6
- package/dist/fs/saveJSON.js.map +1 -0
- package/dist/fs/utils.js +19 -15
- package/dist/fs/utils.js.map +1 -0
- package/dist/functions.d.ts +2 -1
- package/dist/functions.js +3 -6
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +6 -2
- package/dist/generated/version.js.map +1 -0
- package/dist/git/branches.js +77 -83
- package/dist/git/branches.js.map +1 -0
- package/dist/hooks/postProcess.js +97 -114
- package/dist/hooks/postProcess.js.map +1 -0
- package/dist/index.js +23 -31
- package/dist/index.js.map +1 -0
- package/dist/locadex/setupFlow.js +11 -8
- package/dist/locadex/setupFlow.js.map +1 -0
- package/dist/main.js +17 -7
- package/dist/main.js.map +1 -0
- package/dist/next/config/parseNextConfig.js +32 -51
- package/dist/next/config/parseNextConfig.js.map +1 -0
- package/dist/next/jsx/utils.js +25 -37
- package/dist/next/jsx/utils.js.map +1 -0
- package/dist/next/parse/handleInitGT.js +87 -154
- package/dist/next/parse/handleInitGT.js.map +1 -0
- package/dist/next/parse/wrapContent.js +136 -158
- package/dist/next/parse/wrapContent.js.map +1 -0
- package/dist/python/parse/createPythonInlineUpdates.js +36 -33
- package/dist/python/parse/createPythonInlineUpdates.js.map +1 -0
- package/dist/react/config/createESBuildConfig.js +115 -115
- package/dist/react/config/createESBuildConfig.js.map +1 -0
- package/dist/react/jsx/evaluateJsx.js +90 -124
- package/dist/react/jsx/evaluateJsx.js.map +1 -0
- package/dist/react/jsx/utils/buildImportMap.js +24 -28
- package/dist/react/jsx/utils/buildImportMap.js.map +1 -0
- package/dist/react/jsx/utils/constants.js +79 -87
- package/dist/react/jsx/utils/constants.js.map +1 -0
- package/dist/react/jsx/utils/extractSourceCode.js +36 -37
- package/dist/react/jsx/utils/extractSourceCode.js.map +1 -0
- package/dist/react/jsx/utils/getCalleeNameFromExpression.js +30 -30
- package/dist/react/jsx/utils/getCalleeNameFromExpression.js.map +1 -0
- package/dist/react/jsx/utils/getPathsAndAliases.js +70 -105
- package/dist/react/jsx/utils/getPathsAndAliases.js.map +1 -0
- package/dist/react/jsx/utils/isNumberLiteral.js +13 -11
- package/dist/react/jsx/utils/isNumberLiteral.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.js +103 -148
- package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/autoInsertion.js +305 -389
- package/dist/react/jsx/utils/jsxParsing/autoInsertion.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.js +122 -193
- package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.js +50 -64
- package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.js +41 -68
- package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/parseJsx.js +760 -1107
- package/dist/react/jsx/utils/jsxParsing/parseJsx.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/parseTProps.js +35 -71
- package/dist/react/jsx/utils/jsxParsing/parseTProps.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.js +39 -58
- package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/types.js +10 -24
- package/dist/react/jsx/utils/jsxParsing/types.js.map +1 -0
- package/dist/react/jsx/utils/mapAttributeName.js +13 -13
- package/dist/react/jsx/utils/mapAttributeName.js.map +1 -0
- package/dist/react/jsx/utils/parseAst.js +142 -272
- package/dist/react/jsx/utils/parseAst.js.map +1 -0
- package/dist/react/jsx/utils/parseString.js +726 -1090
- package/dist/react/jsx/utils/parseString.js.map +1 -0
- package/dist/react/jsx/utils/parseStringFunction.js +274 -401
- package/dist/react/jsx/utils/parseStringFunction.js.map +1 -0
- package/dist/react/jsx/utils/resolveImportPath.d.ts +1 -1
- package/dist/react/jsx/utils/resolveImportPath.js +125 -108
- package/dist/react/jsx/utils/resolveImportPath.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/derivation/containsDeriveCall.js +18 -24
- package/dist/react/jsx/utils/stringParsing/derivation/containsDeriveCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/derivation/handleDerivation.js +412 -579
- package/dist/react/jsx/utils/stringParsing/derivation/handleDerivation.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/derivation/index.js +57 -67
- package/dist/react/jsx/utils/stringParsing/derivation/index.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/derivation/isDeriveCall.js +26 -36
- package/dist/react/jsx/utils/stringParsing/derivation/isDeriveCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/handleTaggedTemplateTranslationCall.js +29 -24
- package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/handleTaggedTemplateTranslationCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/index.js +34 -32
- package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/index.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.js +80 -117
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleDeriveTranslationCall.js +24 -19
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleDeriveTranslationCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.js +18 -21
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.js +45 -50
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.js +54 -59
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.js +56 -69
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.js.map +1 -0
- package/dist/react/jsx/utils/validateStringFunction.js +21 -29
- package/dist/react/jsx/utils/validateStringFunction.js.map +1 -0
- package/dist/react/jsx/wrapJsx.js +192 -375
- package/dist/react/jsx/wrapJsx.js.map +1 -0
- package/dist/react/parse/addVitePlugin/index.js +40 -34
- package/dist/react/parse/addVitePlugin/index.js.map +1 -0
- package/dist/react/parse/addVitePlugin/installCompiler.js +18 -20
- package/dist/react/parse/addVitePlugin/installCompiler.js.map +1 -0
- package/dist/react/parse/addVitePlugin/updateViteConfig.js +107 -111
- package/dist/react/parse/addVitePlugin/updateViteConfig.js.map +1 -0
- package/dist/react/parse/addVitePlugin/utils/addCompilerImport.js +23 -26
- package/dist/react/parse/addVitePlugin/utils/addCompilerImport.js.map +1 -0
- package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.js +29 -43
- package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.js.map +1 -0
- package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.js +70 -104
- package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.js.map +1 -0
- package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.js +23 -29
- package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.js.map +1 -0
- package/dist/react/parse/createDictionaryUpdates.js +121 -185
- package/dist/react/parse/createDictionaryUpdates.js.map +1 -0
- package/dist/react/parse/createInlineUpdates.js +123 -139
- package/dist/react/parse/createInlineUpdates.js.map +1 -0
- package/dist/react/parse/wrapContent.js +131 -156
- package/dist/react/parse/wrapContent.js.map +1 -0
- package/dist/react/utils/flattenDictionary.js +55 -70
- package/dist/react/utils/flattenDictionary.js.map +1 -0
- package/dist/react/utils/getEntryAndMetadata.js +14 -10
- package/dist/react/utils/getEntryAndMetadata.js.map +1 -0
- package/dist/react/utils/getVariableName.js +36 -33
- package/dist/react/utils/getVariableName.js.map +1 -0
- package/dist/setup/detectFramework.js +85 -102
- package/dist/setup/detectFramework.js.map +1 -0
- package/dist/setup/frameworkUtils.js +17 -28
- package/dist/setup/frameworkUtils.js.map +1 -0
- package/dist/setup/userInput.js +24 -31
- package/dist/setup/userInput.js.map +1 -0
- package/dist/setup/wizard.js +141 -143
- package/dist/setup/wizard.js.map +1 -0
- package/dist/state/mintlifyRefMap.js +12 -9
- package/dist/state/mintlifyRefMap.js.map +1 -0
- package/dist/state/recentDownloads.js +26 -23
- package/dist/state/recentDownloads.js.map +1 -0
- package/dist/state/translateWarnings.js +17 -8
- package/dist/state/translateWarnings.js.map +1 -0
- package/dist/translation/parse.js +77 -98
- package/dist/translation/parse.js.map +1 -0
- package/dist/translation/stage.js +28 -43
- package/dist/translation/stage.js.map +1 -0
- package/dist/translation/validate.js +68 -91
- package/dist/translation/validate.js.map +1 -0
- package/dist/types/libraries.js +93 -91
- package/dist/types/libraries.js.map +1 -0
- package/dist/types/parsing.js +19 -10
- package/dist/types/parsing.js.map +1 -0
- package/dist/utils/addExplicitAnchorIds.js +270 -389
- package/dist/utils/addExplicitAnchorIds.js.map +1 -0
- package/dist/utils/calculateTimeoutMs.js +11 -6
- package/dist/utils/calculateTimeoutMs.js.map +1 -0
- package/dist/utils/constants.js +15 -12
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/credentials.js +67 -114
- package/dist/utils/credentials.js.map +1 -0
- package/dist/utils/fetch.js +22 -20
- package/dist/utils/fetch.js.map +1 -0
- package/dist/utils/flattenJsonFiles.js +27 -34
- package/dist/utils/flattenJsonFiles.js.map +1 -0
- package/dist/utils/gitDiff.js +30 -32
- package/dist/utils/gitDiff.js.map +1 -0
- package/dist/utils/gt.js +7 -2
- package/dist/utils/gt.js.map +1 -0
- package/dist/utils/hash.js +14 -9
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/headers.js +10 -13
- package/dist/utils/headers.js.map +1 -0
- package/dist/utils/installPackage.js +70 -75
- package/dist/utils/installPackage.js.map +1 -0
- package/dist/utils/localizeRelativeAssets.js +114 -157
- package/dist/utils/localizeRelativeAssets.js.map +1 -0
- package/dist/utils/localizeStaticImports.js +229 -371
- package/dist/utils/localizeStaticImports.js.map +1 -0
- package/dist/utils/localizeStaticUrls.js +241 -424
- package/dist/utils/localizeStaticUrls.js.map +1 -0
- package/dist/utils/mintlifyTitleFallback.js +64 -72
- package/dist/utils/mintlifyTitleFallback.js.map +1 -0
- package/dist/utils/monorepoVersionCheck.js +177 -215
- package/dist/utils/monorepoVersionCheck.js.map +1 -0
- package/dist/utils/packageInfo.js +17 -16
- package/dist/utils/packageInfo.js.map +1 -0
- package/dist/utils/packageJson.js +51 -66
- package/dist/utils/packageJson.js.map +1 -0
- package/dist/utils/packageManager.js +237 -260
- package/dist/utils/packageManager.js.map +1 -0
- package/dist/utils/parse/needsCJS.js +36 -69
- package/dist/utils/parse/needsCJS.js.map +1 -0
- package/dist/utils/persistPostprocessHashes.js +30 -32
- package/dist/utils/persistPostprocessHashes.js.map +1 -0
- package/dist/utils/processAnchorIds.js +32 -54
- package/dist/utils/processAnchorIds.js.map +1 -0
- package/dist/utils/processOpenApi.js +469 -578
- package/dist/utils/processOpenApi.js.map +1 -0
- package/dist/utils/resolveMintlifyRefs.js +89 -105
- package/dist/utils/resolveMintlifyRefs.js.map +1 -0
- package/dist/utils/resolvePublish.js +46 -54
- package/dist/utils/resolvePublish.js.map +1 -0
- package/dist/utils/sanitizeFileContent.js +20 -27
- package/dist/utils/sanitizeFileContent.js.map +1 -0
- package/dist/utils/sharedStaticAssets.js +248 -366
- package/dist/utils/sharedStaticAssets.js.map +1 -0
- package/dist/utils/splitMintlifyLanguageRefs.js +208 -282
- package/dist/utils/splitMintlifyLanguageRefs.js.map +1 -0
- package/dist/utils/validateMdx.js +26 -23
- package/dist/utils/validateMdx.js.map +1 -0
- package/dist/utils/wrapPlainUrls.js +58 -70
- package/dist/utils/wrapPlainUrls.js.map +1 -0
- package/dist/workflows/download.js +92 -126
- package/dist/workflows/download.js.map +1 -0
- package/dist/workflows/enqueue.js +47 -54
- package/dist/workflows/enqueue.js.map +1 -0
- package/dist/workflows/publish.js +29 -29
- package/dist/workflows/publish.js.map +1 -0
- package/dist/workflows/setupProject.js +39 -40
- package/dist/workflows/setupProject.js.map +1 -0
- package/dist/workflows/stage.js +61 -65
- package/dist/workflows/stage.js.map +1 -0
- package/dist/workflows/steps/BranchStep.js +118 -163
- package/dist/workflows/steps/BranchStep.js.map +1 -0
- package/dist/workflows/steps/DownloadStep.js +107 -137
- package/dist/workflows/steps/DownloadStep.js.map +1 -0
- package/dist/workflows/steps/EnqueueStep.js +32 -32
- package/dist/workflows/steps/EnqueueStep.js.map +1 -0
- package/dist/workflows/steps/PollJobsStep.js +208 -292
- package/dist/workflows/steps/PollJobsStep.js.map +1 -0
- package/dist/workflows/steps/PublishStep.js +33 -38
- package/dist/workflows/steps/PublishStep.js.map +1 -0
- package/dist/workflows/steps/SetupStep.js +71 -72
- package/dist/workflows/steps/SetupStep.js.map +1 -0
- package/dist/workflows/steps/TagStep.js +39 -44
- package/dist/workflows/steps/TagStep.js.map +1 -0
- package/dist/workflows/steps/UploadSourcesStep.js +108 -140
- package/dist/workflows/steps/UploadSourcesStep.js.map +1 -0
- package/dist/workflows/steps/UploadTranslationsStep.js +61 -71
- package/dist/workflows/steps/UploadTranslationsStep.js.map +1 -0
- package/dist/workflows/steps/UserEditDiffsStep.js +32 -34
- package/dist/workflows/steps/UserEditDiffsStep.js.map +1 -0
- package/dist/workflows/steps/WorkflowStep.js +6 -2
- package/dist/workflows/steps/WorkflowStep.js.map +1 -0
- package/dist/workflows/upload.js +45 -46
- package/dist/workflows/upload.js.map +1 -0
- package/package.json +14 -7
|
@@ -1,425 +1,298 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import { STRING_REGISTRATION_FUNCS } from "./constants.js";
|
|
2
|
+
import { warnAsyncUseGT, warnSyncGetGT, warnUnresolvedImportSync } from "../../../console/index.js";
|
|
3
|
+
import { resolveImportPath } from "./resolveImportPath.js";
|
|
4
|
+
import { buildImportMap } from "./buildImportMap.js";
|
|
5
|
+
import { processTranslationCall } from "./stringParsing/processTranslationCall/index.js";
|
|
6
|
+
import { processTaggedTemplateCall } from "./stringParsing/processTaggedTemplateCall/index.js";
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import * as t from "@babel/types";
|
|
9
|
+
import { parse } from "@babel/parser";
|
|
10
|
+
import traverseModule from "@babel/traverse";
|
|
11
|
+
//#region src/react/jsx/utils/parseStringFunction.ts
|
|
6
12
|
const traverse = traverseModule.default || traverseModule;
|
|
7
|
-
import fs from 'node:fs';
|
|
8
|
-
import { parse } from '@babel/parser';
|
|
9
|
-
import { resolveImportPath } from './resolveImportPath.js';
|
|
10
|
-
import { buildImportMap } from './buildImportMap.js';
|
|
11
|
-
import { processTranslationCall } from './stringParsing/processTranslationCall/index.js';
|
|
12
|
-
import { processTaggedTemplateCall } from './stringParsing/processTaggedTemplateCall/index.js';
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const resolveImportPathCache = new Map();
|
|
14
|
+
* Cache for resolved import paths to avoid redundant I/O operations.
|
|
15
|
+
* Key: `${currentFile}::${importPath}`
|
|
16
|
+
* Value: resolved absolute path or null
|
|
17
|
+
*/
|
|
18
|
+
const resolveImportPathCache = /* @__PURE__ */ new Map();
|
|
19
19
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const processFunctionCache = new Map();
|
|
20
|
+
* Cache for processed functions to avoid re-parsing the same files.
|
|
21
|
+
* Key: `${filePath}::${functionName}::${argIndex}`
|
|
22
|
+
* Value: boolean indicating whether the function was found and processed
|
|
23
|
+
*/
|
|
24
|
+
const processFunctionCache = /* @__PURE__ */ new Map();
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
* Clears all caches. Useful for testing or when file system changes.
|
|
27
|
+
*/
|
|
28
|
+
function clearParsingCaches() {
|
|
29
|
+
resolveImportPathCache.clear();
|
|
30
|
+
processFunctionCache.clear();
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
* Extracts the parameter name from a function parameter node, handling TypeScript annotations and default values.
|
|
34
|
+
*/
|
|
35
35
|
function extractParameterName(param) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// Handle parameters with default values: (gt = () => {})
|
|
40
|
-
if (t.isAssignmentPattern(param) && t.isIdentifier(param.left)) {
|
|
41
|
-
return param.left.name;
|
|
42
|
-
}
|
|
43
|
-
return null;
|
|
36
|
+
if (t.isIdentifier(param)) return param.name;
|
|
37
|
+
if (t.isAssignmentPattern(param) && t.isIdentifier(param.left)) return param.left.name;
|
|
38
|
+
return null;
|
|
44
39
|
}
|
|
45
40
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const otherBindingTyped = otherBinding;
|
|
68
|
-
if (otherBindingTyped.path &&
|
|
69
|
-
otherBindingTyped.path.isVariableDeclarator() &&
|
|
70
|
-
otherBindingTyped.path.node.init &&
|
|
71
|
-
t.isIdentifier(otherBindingTyped.path.node.init) &&
|
|
72
|
-
otherBindingTyped.path.node.init.name === variableName) {
|
|
73
|
-
// Found an alias: const otherVarName = variableName;
|
|
74
|
-
const nestedAliases = resolveVariableAliases(scope, otherVarName, visited);
|
|
75
|
-
aliases.push(...nestedAliases);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return aliases;
|
|
41
|
+
* Recursively resolves variable assignments to find all aliases of a translation callback parameter.
|
|
42
|
+
* Handles cases like: const t = translate; const a = translate; const b = a; const c = b;
|
|
43
|
+
*
|
|
44
|
+
* @param scope The scope to search within
|
|
45
|
+
* @param variableName The variable name to resolve
|
|
46
|
+
* @param visited Set to track already visited variables to prevent infinite loops
|
|
47
|
+
* @returns Array of all variable names that reference the original translation callback
|
|
48
|
+
*/
|
|
49
|
+
function resolveVariableAliases(scope, variableName, visited = /* @__PURE__ */ new Set()) {
|
|
50
|
+
if (visited.has(variableName)) return [];
|
|
51
|
+
visited.add(variableName);
|
|
52
|
+
const aliases = [variableName];
|
|
53
|
+
if (scope.bindings[variableName]) for (const [otherVarName, otherBinding] of Object.entries(scope.bindings)) {
|
|
54
|
+
if (otherVarName === variableName || visited.has(otherVarName)) continue;
|
|
55
|
+
const otherBindingTyped = otherBinding;
|
|
56
|
+
if (otherBindingTyped.path && otherBindingTyped.path.isVariableDeclarator() && otherBindingTyped.path.node.init && t.isIdentifier(otherBindingTyped.path.node.init) && otherBindingTyped.path.node.init.name === variableName) {
|
|
57
|
+
const nestedAliases = resolveVariableAliases(scope, otherVarName, visited);
|
|
58
|
+
aliases.push(...nestedAliases);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return aliases;
|
|
80
62
|
}
|
|
81
63
|
/**
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
64
|
+
* Handles how translation callbacks are used within code.
|
|
65
|
+
* This covers both direct translation calls (gt('hello')) and prop drilling
|
|
66
|
+
* where the translation callback is passed to other functions (getData(gt)).
|
|
67
|
+
*/
|
|
86
68
|
function handleFunctionCall(tPath, config, state, output, visitedFunctions) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
processFunctionIfMatches(callee.name, argIndex, functionPath.node, functionPath, config, output, visitedFunctions);
|
|
109
|
-
}
|
|
110
|
-
// Handle arrow functions assigned to variables: const getData = (t) => {...}
|
|
111
|
-
else if (calleeBinding &&
|
|
112
|
-
calleeBinding.path.isVariableDeclarator() &&
|
|
113
|
-
calleeBinding.path.node.init &&
|
|
114
|
-
(t.isArrowFunctionExpression(calleeBinding.path.node.init) ||
|
|
115
|
-
t.isFunctionExpression(calleeBinding.path.node.init))) {
|
|
116
|
-
const initPath = calleeBinding.path.get('init');
|
|
117
|
-
processFunctionIfMatches(callee.name, argIndex, calleeBinding.path.node.init, initPath, config, output, visitedFunctions);
|
|
118
|
-
}
|
|
119
|
-
// If not found locally, check if it's an imported function
|
|
120
|
-
else if (state.importMap.has(callee.name)) {
|
|
121
|
-
const importPath = state.importMap.get(callee.name);
|
|
122
|
-
const resolvedPath = resolveImportPath(config.file, importPath, config.parsingOptions, resolveImportPathCache);
|
|
123
|
-
if (resolvedPath) {
|
|
124
|
-
processFunctionInFile(resolvedPath, callee.name, argIndex, config, state, output);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
output.warnings.add(warnUnresolvedImportSync(config.file, callee.name, importPath, tPath.node.loc
|
|
128
|
-
? `${tPath.node.loc.start.line}:${tPath.node.loc.start.column}`
|
|
129
|
-
: undefined));
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
69
|
+
if (tPath.parent.type === "CallExpression" && tPath.parent.callee === tPath.node) processTranslationCall(tPath, config, output);
|
|
70
|
+
else if (!config.ignoreTaggedTemplates && tPath.parent.type === "TaggedTemplateExpression" && tPath.parent.tag === tPath.node) processTaggedTemplateCall(tPath, config, output);
|
|
71
|
+
else if (tPath.parent.type === "CallExpression" && t.isExpression(tPath.node) && tPath.parent.arguments.includes(tPath.node)) {
|
|
72
|
+
const argIndex = tPath.parent.arguments.indexOf(tPath.node);
|
|
73
|
+
const callee = tPath.parent.callee;
|
|
74
|
+
if (t.isIdentifier(callee)) {
|
|
75
|
+
const calleeBinding = tPath.scope.getBinding(callee.name);
|
|
76
|
+
if (calleeBinding && calleeBinding.path.isFunction()) {
|
|
77
|
+
const functionPath = calleeBinding.path;
|
|
78
|
+
processFunctionIfMatches(callee.name, argIndex, functionPath.node, functionPath, config, output, visitedFunctions);
|
|
79
|
+
} else if (calleeBinding && calleeBinding.path.isVariableDeclarator() && calleeBinding.path.node.init && (t.isArrowFunctionExpression(calleeBinding.path.node.init) || t.isFunctionExpression(calleeBinding.path.node.init))) {
|
|
80
|
+
const initPath = calleeBinding.path.get("init");
|
|
81
|
+
processFunctionIfMatches(callee.name, argIndex, calleeBinding.path.node.init, initPath, config, output, visitedFunctions);
|
|
82
|
+
} else if (state.importMap.has(callee.name)) {
|
|
83
|
+
const importPath = state.importMap.get(callee.name);
|
|
84
|
+
const resolvedPath = resolveImportPath(config.file, importPath, config.parsingOptions, resolveImportPathCache);
|
|
85
|
+
if (resolvedPath) processFunctionInFile(resolvedPath, callee.name, argIndex, config, state, output);
|
|
86
|
+
else output.warnings.add(warnUnresolvedImportSync(config.file, callee.name, importPath, tPath.node.loc ? `${tPath.node.loc.start.line}:${tPath.node.loc.start.column}` : void 0));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
134
90
|
}
|
|
135
91
|
/**
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
92
|
+
* Processes a user-defined function that receives a translation callback as a parameter.
|
|
93
|
+
* Validates the function has enough parameters and traces how the translation callback
|
|
94
|
+
* is used within that function's body.
|
|
95
|
+
*/
|
|
140
96
|
function processFunctionIfMatches(_functionName, argIndex, functionNode, functionPath, config, output, visitedFunctions) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
visitedFunctions.delete(functionNode);
|
|
97
|
+
if (visitedFunctions.has(functionNode)) return;
|
|
98
|
+
visitedFunctions.add(functionNode);
|
|
99
|
+
if (functionNode.params.length > argIndex) {
|
|
100
|
+
const param = functionNode.params[argIndex];
|
|
101
|
+
const paramName = extractParameterName(param);
|
|
102
|
+
if (paramName) findFunctionParameterUsage(functionPath, paramName, config, output, visitedFunctions);
|
|
103
|
+
}
|
|
104
|
+
visitedFunctions.delete(functionNode);
|
|
152
105
|
}
|
|
153
106
|
/**
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
107
|
+
* Finds all usages of a translation callback parameter within a user-defined function's scope.
|
|
108
|
+
* Processes both direct translation calls and cases where the translation callback is passed
|
|
109
|
+
* to other functions (prop drilling).
|
|
110
|
+
*
|
|
111
|
+
* Example: In function getInfo(t) { return t('hello'); }, this finds the t('hello') call.
|
|
112
|
+
* Example: In function getData(t) { return getFooter(t); }, this finds and traces into getFooter.
|
|
113
|
+
*/
|
|
161
114
|
function findFunctionParameterUsage(functionPath, parameterName, config, output, visitedFunctions) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
}
|
|
115
|
+
if (functionPath.isFunction()) {
|
|
116
|
+
const functionScope = functionPath.scope;
|
|
117
|
+
const allParameterNames = resolveVariableAliases(functionScope, parameterName);
|
|
118
|
+
const programPath = functionPath.scope.getProgramParent().path;
|
|
119
|
+
const importMap = buildImportMap(programPath);
|
|
120
|
+
allParameterNames.forEach((name) => {
|
|
121
|
+
const binding = functionScope.bindings[name];
|
|
122
|
+
if (binding) binding.referencePaths.forEach((refPath) => {
|
|
123
|
+
handleFunctionCall(refPath, config, {
|
|
124
|
+
visited: /* @__PURE__ */ new Set(),
|
|
125
|
+
importMap
|
|
126
|
+
}, output, visitedFunctions);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
181
130
|
}
|
|
182
131
|
/**
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
132
|
+
* Searches for a specific user-defined function in a file and analyzes how a translation callback
|
|
133
|
+
* parameter (at argIndex position) is used within that function.
|
|
134
|
+
*
|
|
135
|
+
* Handles multiple function declaration patterns:
|
|
136
|
+
* - function getInfo(t) { ... }
|
|
137
|
+
* - export function getInfo(t) { ... }
|
|
138
|
+
* - const getInfo = (t) => { ... }
|
|
139
|
+
*
|
|
140
|
+
* If the function is not found in the file, follows re-exports (export * from './other')
|
|
141
|
+
*/
|
|
193
142
|
function processFunctionInFile(filePath, functionName, argIndex, config, state, output) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
ExportNamedDeclaration(path) {
|
|
245
|
-
if (path.node.source && t.isStringLiteral(path.node.source)) {
|
|
246
|
-
// Check if this export includes our function
|
|
247
|
-
const exportsFunction = path.node.specifiers.some((spec) => {
|
|
248
|
-
if (t.isExportSpecifier(spec)) {
|
|
249
|
-
const exportedName = t.isIdentifier(spec.exported)
|
|
250
|
-
? spec.exported.name
|
|
251
|
-
: spec.exported.value;
|
|
252
|
-
return exportedName === functionName;
|
|
253
|
-
}
|
|
254
|
-
return false;
|
|
255
|
-
});
|
|
256
|
-
if (exportsFunction) {
|
|
257
|
-
reExports.push(path.node.source.value);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
});
|
|
262
|
-
// If function not found, follow re-exports
|
|
263
|
-
if (!found && reExports.length > 0) {
|
|
264
|
-
for (const reExportPath of reExports) {
|
|
265
|
-
const resolvedPath = resolveImportPath(filePath, reExportPath, config.parsingOptions, resolveImportPathCache);
|
|
266
|
-
if (resolvedPath) {
|
|
267
|
-
processFunctionInFile(resolvedPath, functionName, argIndex, config, state, output);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
// Mark this function search as processed in the cache
|
|
272
|
-
processFunctionCache.set(cacheKey, found);
|
|
273
|
-
}
|
|
274
|
-
catch {
|
|
275
|
-
// Silently skip files that can't be parsed or accessed
|
|
276
|
-
// Still mark as processed to avoid retrying failed parses
|
|
277
|
-
processFunctionCache.set(cacheKey, false);
|
|
278
|
-
}
|
|
143
|
+
const cacheKey = `${filePath}::${functionName}::${argIndex}`;
|
|
144
|
+
if (processFunctionCache.has(cacheKey)) return;
|
|
145
|
+
if (state.visited.has(filePath)) return;
|
|
146
|
+
state.visited.add(filePath);
|
|
147
|
+
try {
|
|
148
|
+
const ast = parse(fs.readFileSync(filePath, "utf8"), {
|
|
149
|
+
sourceType: "module",
|
|
150
|
+
plugins: ["jsx", "typescript"]
|
|
151
|
+
});
|
|
152
|
+
let found = false;
|
|
153
|
+
const reExports = [];
|
|
154
|
+
const visitedFunctions = /* @__PURE__ */ new Set();
|
|
155
|
+
const crossFileConfig = {
|
|
156
|
+
...config,
|
|
157
|
+
file: filePath
|
|
158
|
+
};
|
|
159
|
+
traverse(ast, {
|
|
160
|
+
FunctionDeclaration(path) {
|
|
161
|
+
if (path.node.id?.name === functionName) {
|
|
162
|
+
found = true;
|
|
163
|
+
processFunctionIfMatches(functionName, argIndex, path.node, path, crossFileConfig, output, visitedFunctions);
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
VariableDeclarator(path) {
|
|
167
|
+
if (t.isIdentifier(path.node.id) && path.node.id.name === functionName && path.node.init && (t.isArrowFunctionExpression(path.node.init) || t.isFunctionExpression(path.node.init))) {
|
|
168
|
+
found = true;
|
|
169
|
+
const initPath = path.get("init");
|
|
170
|
+
processFunctionIfMatches(functionName, argIndex, path.node.init, initPath, crossFileConfig, output, visitedFunctions);
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
ExportAllDeclaration(path) {
|
|
174
|
+
if (t.isStringLiteral(path.node.source)) reExports.push(path.node.source.value);
|
|
175
|
+
},
|
|
176
|
+
ExportNamedDeclaration(path) {
|
|
177
|
+
if (path.node.source && t.isStringLiteral(path.node.source)) {
|
|
178
|
+
if (path.node.specifiers.some((spec) => {
|
|
179
|
+
if (t.isExportSpecifier(spec)) return (t.isIdentifier(spec.exported) ? spec.exported.name : spec.exported.value) === functionName;
|
|
180
|
+
return false;
|
|
181
|
+
})) reExports.push(path.node.source.value);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
if (!found && reExports.length > 0) for (const reExportPath of reExports) {
|
|
186
|
+
const resolvedPath = resolveImportPath(filePath, reExportPath, config.parsingOptions, resolveImportPathCache);
|
|
187
|
+
if (resolvedPath) processFunctionInFile(resolvedPath, functionName, argIndex, config, state, output);
|
|
188
|
+
}
|
|
189
|
+
processFunctionCache.set(cacheKey, found);
|
|
190
|
+
} catch {
|
|
191
|
+
processFunctionCache.set(cacheKey, false);
|
|
192
|
+
}
|
|
279
193
|
}
|
|
280
194
|
/**
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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
|
-
const isMessageHook = originalName === INLINE_MESSAGE_HOOK ||
|
|
381
|
-
originalName === INLINE_MESSAGE_HOOK_ASYNC;
|
|
382
|
-
const isInlineGT = originalName === INLINE_TRANSLATION_HOOK ||
|
|
383
|
-
originalName === INLINE_TRANSLATION_HOOK_ASYNC;
|
|
384
|
-
const hookConfig = {
|
|
385
|
-
parsingOptions: config.parsingOptions,
|
|
386
|
-
file: config.file,
|
|
387
|
-
ignoreInlineMetadata: isMessageHook,
|
|
388
|
-
ignoreDynamicContent: isMessageHook,
|
|
389
|
-
ignoreInvalidIcu: isMessageHook,
|
|
390
|
-
// TODO: when we add support for array content in gt function, this should just always be false
|
|
391
|
-
ignoreInlineListContent: isInlineGT,
|
|
392
|
-
includeSourceCodeContext: config.includeSourceCodeContext,
|
|
393
|
-
ignoreTaggedTemplates: false,
|
|
394
|
-
ignoreGlobalTaggedTemplates: false,
|
|
395
|
-
// User configurable, otherwise default to DISABLED
|
|
396
|
-
autoderiveMethod: config.autoderiveMethod === 'AUTO'
|
|
397
|
-
? isInlineGT
|
|
398
|
-
? 'ENABLED'
|
|
399
|
-
: 'DISABLED'
|
|
400
|
-
: config.autoderiveMethod,
|
|
401
|
-
};
|
|
402
|
-
const effectiveParent = parentPath?.node.type === 'AwaitExpression'
|
|
403
|
-
? parentPath.parentPath
|
|
404
|
-
: parentPath;
|
|
405
|
-
if (effectiveParent &&
|
|
406
|
-
effectiveParent.node.type === 'VariableDeclarator' &&
|
|
407
|
-
effectiveParent.node.id.type === 'Identifier') {
|
|
408
|
-
const tFuncName = effectiveParent.node.id.name;
|
|
409
|
-
// Get the scope from the variable declaration
|
|
410
|
-
const variableScope = effectiveParent.scope;
|
|
411
|
-
// Resolve all aliases of the translation function
|
|
412
|
-
// Example: translate -> [translate, t, a, b] for const t = translate; const a = t; const b = a;
|
|
413
|
-
const allTranslationNames = resolveVariableAliases(variableScope, tFuncName);
|
|
414
|
-
// Process references for all translation function names and their aliases
|
|
415
|
-
const visitedFunctions = new Set();
|
|
416
|
-
allTranslationNames.forEach((name) => {
|
|
417
|
-
const tReferencePaths = variableScope.bindings[name]?.referencePaths || [];
|
|
418
|
-
for (const tPath of tReferencePaths) {
|
|
419
|
-
handleFunctionCall(tPath, hookConfig, { visited: new Set(), importMap }, output, visitedFunctions);
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
195
|
+
* Main entry point for parsing translation strings from useGT() and getGT() calls.
|
|
196
|
+
*
|
|
197
|
+
* Supports complex patterns including:
|
|
198
|
+
* 1. Direct calls: const gt = useGT(); gt('hello');
|
|
199
|
+
* 2. Translation callback prop drilling: const gt = useGT(); getInfo(gt); where getInfo uses gt() internally
|
|
200
|
+
* 3. Cross-file function calls: imported functions that receive the translation callback as a parameter
|
|
201
|
+
*
|
|
202
|
+
* Example flow:
|
|
203
|
+
* - const gt = useGT();
|
|
204
|
+
* - const { home } = getInfo(gt); // getInfo is imported from './constants'
|
|
205
|
+
* - This will parse constants.ts to find translation calls within getInfo function
|
|
206
|
+
*/
|
|
207
|
+
function parseStrings(importName, originalName, path, config, output) {
|
|
208
|
+
if (originalName === "_gt_internal_t_global_registration_marker") {
|
|
209
|
+
if (!config.ignoreGlobalTaggedTemplates) processTaggedTemplateCall(path, {
|
|
210
|
+
...config,
|
|
211
|
+
autoderiveMethod: config.autoderiveMethod === "AUTO" ? "DISABLED" : config.autoderiveMethod
|
|
212
|
+
}, output);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const importMap = buildImportMap(path.scope.getProgramParent().path);
|
|
216
|
+
const referencePaths = path.scope.bindings[importName]?.referencePaths || [];
|
|
217
|
+
for (const refPath of referencePaths) {
|
|
218
|
+
if (STRING_REGISTRATION_FUNCS.includes(originalName)) {
|
|
219
|
+
const stringRegistrationConfig = {
|
|
220
|
+
parsingOptions: config.parsingOptions,
|
|
221
|
+
file: config.file,
|
|
222
|
+
ignoreInlineMetadata: false,
|
|
223
|
+
ignoreDynamicContent: false,
|
|
224
|
+
ignoreInvalidIcu: false,
|
|
225
|
+
ignoreInlineListContent: false,
|
|
226
|
+
includeSourceCodeContext: config.includeSourceCodeContext,
|
|
227
|
+
ignoreTaggedTemplates: false,
|
|
228
|
+
ignoreGlobalTaggedTemplates: false,
|
|
229
|
+
autoderiveMethod: config.autoderiveMethod === "AUTO" ? "DISABLED" : config.autoderiveMethod
|
|
230
|
+
};
|
|
231
|
+
if (refPath.parent.type === "CallExpression" && refPath.parent.callee === refPath.node)
|
|
232
|
+
/**
|
|
233
|
+
* CASE: Autoderive t() and msg() function
|
|
234
|
+
* The t() function, will treat variable content as if it was marked for derivation
|
|
235
|
+
* without explicit calls to derive().
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* const derivedValue = 'John';
|
|
239
|
+
* const interpolatedValue = "Ernest"
|
|
240
|
+
* t(
|
|
241
|
+
* "Hello, " + derivedValue + "! My name is {interpolatedValue}",
|
|
242
|
+
* { interpolatedValue }
|
|
243
|
+
* );
|
|
244
|
+
* // "Hello, John! My name is {interpolatedValue}"
|
|
245
|
+
*/
|
|
246
|
+
processTranslationCall(refPath, config.autoderiveMethod === "AUTO" ? {
|
|
247
|
+
...stringRegistrationConfig,
|
|
248
|
+
autoderiveMethod: "ENABLED"
|
|
249
|
+
} : stringRegistrationConfig, output);
|
|
250
|
+
else if (!stringRegistrationConfig.ignoreTaggedTemplates && refPath.parent.type === "TaggedTemplateExpression" && refPath.parent.tag === refPath.node) processTaggedTemplateCall(refPath, stringRegistrationConfig, output);
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
const callExpr = refPath.findParent((p) => p.isCallExpression());
|
|
254
|
+
if (callExpr) {
|
|
255
|
+
const parentPath = callExpr.parentPath;
|
|
256
|
+
const asyncScope = refPath.getFunctionParent()?.node.async;
|
|
257
|
+
if (asyncScope && (originalName === "useGT" || originalName === "useMessages")) {
|
|
258
|
+
output.errors.push(warnAsyncUseGT(config.file, `${refPath.node.loc?.start?.line}:${refPath.node.loc?.start?.column}`));
|
|
259
|
+
return;
|
|
260
|
+
} else if (!asyncScope && (originalName === "getGT" || originalName === "getMessages")) {
|
|
261
|
+
output.errors.push(warnSyncGetGT(config.file, `${refPath.node.loc?.start?.line}:${refPath.node.loc?.start?.column}`));
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
const isMessageHook = originalName === "useMessages" || originalName === "getMessages";
|
|
265
|
+
const isInlineGT = originalName === "useGT" || originalName === "getGT";
|
|
266
|
+
const hookConfig = {
|
|
267
|
+
parsingOptions: config.parsingOptions,
|
|
268
|
+
file: config.file,
|
|
269
|
+
ignoreInlineMetadata: isMessageHook,
|
|
270
|
+
ignoreDynamicContent: isMessageHook,
|
|
271
|
+
ignoreInvalidIcu: isMessageHook,
|
|
272
|
+
ignoreInlineListContent: isInlineGT,
|
|
273
|
+
includeSourceCodeContext: config.includeSourceCodeContext,
|
|
274
|
+
ignoreTaggedTemplates: false,
|
|
275
|
+
ignoreGlobalTaggedTemplates: false,
|
|
276
|
+
autoderiveMethod: config.autoderiveMethod === "AUTO" ? isInlineGT ? "ENABLED" : "DISABLED" : config.autoderiveMethod
|
|
277
|
+
};
|
|
278
|
+
const effectiveParent = parentPath?.node.type === "AwaitExpression" ? parentPath.parentPath : parentPath;
|
|
279
|
+
if (effectiveParent && effectiveParent.node.type === "VariableDeclarator" && effectiveParent.node.id.type === "Identifier") {
|
|
280
|
+
const tFuncName = effectiveParent.node.id.name;
|
|
281
|
+
const variableScope = effectiveParent.scope;
|
|
282
|
+
const allTranslationNames = resolveVariableAliases(variableScope, tFuncName);
|
|
283
|
+
const visitedFunctions = /* @__PURE__ */ new Set();
|
|
284
|
+
allTranslationNames.forEach((name) => {
|
|
285
|
+
const tReferencePaths = variableScope.bindings[name]?.referencePaths || [];
|
|
286
|
+
for (const tPath of tReferencePaths) handleFunctionCall(tPath, hookConfig, {
|
|
287
|
+
visited: /* @__PURE__ */ new Set(),
|
|
288
|
+
importMap
|
|
289
|
+
}, output, visitedFunctions);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
425
294
|
}
|
|
295
|
+
//#endregion
|
|
296
|
+
export { clearParsingCaches, parseStrings, resolveVariableAliases };
|
|
297
|
+
|
|
298
|
+
//# sourceMappingURL=parseStringFunction.js.map
|