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,427 +1,343 @@
|
|
|
1
|
+
import { isStaticExpression } from "../../evaluateJsx.js";
|
|
2
|
+
import { BRANCH_CONTROL_PROPS, DEFAULT_GT_IMPORT_SOURCE, INTERNAL_TRANSLATION_COMPONENT, INTERNAL_VAR_COMPONENT, PLURAL_CONTROL_PROPS, VARIABLE_COMPONENTS } from "../constants.js";
|
|
3
|
+
import * as t from "@babel/types";
|
|
4
|
+
import traverseModule from "@babel/traverse";
|
|
5
|
+
//#region src/react/jsx/utils/jsxParsing/autoInsertion.ts
|
|
1
6
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import * as t from '@babel/types';
|
|
11
|
-
import traverseModule from '@babel/traverse';
|
|
7
|
+
* Auto JSX Insertion for CLI extraction.
|
|
8
|
+
*
|
|
9
|
+
* Inserts <T> and <Var> JSX elements into the AST so the extraction pipeline
|
|
10
|
+
* can process them as if the user wrote them. This operates on raw JSX syntax
|
|
11
|
+
* (JSXElement, JSXText, JSXExpressionContainer) — NOT compiled jsx() calls.
|
|
12
|
+
*
|
|
13
|
+
* Rules follow JSX_INSERTION_RULES.md from the compiler package.
|
|
14
|
+
*/
|
|
12
15
|
const traverse = traverseModule.default || traverseModule;
|
|
13
|
-
import { isStaticExpression } from '../../evaluateJsx.js';
|
|
14
|
-
import { TRANSLATION_COMPONENT, INTERNAL_TRANSLATION_COMPONENT, INTERNAL_VAR_COMPONENT, VARIABLE_COMPONENTS, BRANCH_COMPONENT, PLURAL_COMPONENT, DEFAULT_GT_IMPORT_SOURCE, DERIVE_COMPONENT, STATIC_COMPONENT, BRANCH_CONTROL_PROPS, PLURAL_CONTROL_PROPS, } from '../constants.js';
|
|
15
16
|
/** Tracks which AST nodes were auto-inserted by this module */
|
|
16
|
-
const autoInsertedNodes = new WeakSet();
|
|
17
|
+
const autoInsertedNodes = /* @__PURE__ */ new WeakSet();
|
|
17
18
|
/** Check if a node was auto-inserted */
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
function isAutoInserted(node) {
|
|
20
|
+
return autoInsertedNodes.has(node);
|
|
20
21
|
}
|
|
21
|
-
// ===== Public API ===== //
|
|
22
22
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
Program(path) {
|
|
48
|
-
path.unshiftContainer('body', importDecl);
|
|
49
|
-
path.stop();
|
|
50
|
-
},
|
|
51
|
-
});
|
|
23
|
+
* Ensure GtInternalTranslateJsx and GtInternalVar are imported in the AST.
|
|
24
|
+
* Always adds: import { GtInternalTranslateJsx, GtInternalVar } from 'gt-react/browser';
|
|
25
|
+
* These are distinct from user T/Var so there's no ambiguity.
|
|
26
|
+
*
|
|
27
|
+
* Updates importAliases in-place.
|
|
28
|
+
*/
|
|
29
|
+
function ensureTAndVarImported(ast, importAliases) {
|
|
30
|
+
const hasInternalT = Object.values(importAliases).includes(INTERNAL_TRANSLATION_COMPONENT);
|
|
31
|
+
const hasInternalVar = Object.values(importAliases).includes(INTERNAL_VAR_COMPONENT);
|
|
32
|
+
if (hasInternalT && hasInternalVar) return;
|
|
33
|
+
const specifiers = [];
|
|
34
|
+
if (!hasInternalT) {
|
|
35
|
+
specifiers.push(t.importSpecifier(t.identifier(INTERNAL_TRANSLATION_COMPONENT), t.identifier(INTERNAL_TRANSLATION_COMPONENT)));
|
|
36
|
+
importAliases[INTERNAL_TRANSLATION_COMPONENT] = INTERNAL_TRANSLATION_COMPONENT;
|
|
37
|
+
}
|
|
38
|
+
if (!hasInternalVar) {
|
|
39
|
+
specifiers.push(t.importSpecifier(t.identifier(INTERNAL_VAR_COMPONENT), t.identifier(INTERNAL_VAR_COMPONENT)));
|
|
40
|
+
importAliases[INTERNAL_VAR_COMPONENT] = INTERNAL_VAR_COMPONENT;
|
|
41
|
+
}
|
|
42
|
+
const importDecl = t.importDeclaration(specifiers, t.stringLiteral(DEFAULT_GT_IMPORT_SOURCE));
|
|
43
|
+
traverse(ast, { Program(path) {
|
|
44
|
+
path.unshiftContainer("body", importDecl);
|
|
45
|
+
path.stop();
|
|
46
|
+
} });
|
|
52
47
|
}
|
|
53
48
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
},
|
|
88
|
-
});
|
|
49
|
+
* Traverse the AST and insert GtInternalTranslateJsx and GtInternalVar JSX elements following
|
|
50
|
+
* the insertion rules. Uses deliberate children traversal.
|
|
51
|
+
*
|
|
52
|
+
* Every inserted node gets node._autoInserted = true.
|
|
53
|
+
*/
|
|
54
|
+
function autoInsertJsxComponents(ast, importAliases) {
|
|
55
|
+
const processedNodes = /* @__PURE__ */ new WeakSet();
|
|
56
|
+
const tLocalName = getLocalName(importAliases, INTERNAL_TRANSLATION_COMPONENT);
|
|
57
|
+
const varLocalName = getLocalName(importAliases, INTERNAL_VAR_COMPONENT);
|
|
58
|
+
traverse(ast, {
|
|
59
|
+
JSXElement(path) {
|
|
60
|
+
if (processedNodes.has(path.node)) return;
|
|
61
|
+
processJsxElement({
|
|
62
|
+
path,
|
|
63
|
+
insideAutoT: false,
|
|
64
|
+
importAliases,
|
|
65
|
+
processedNodes,
|
|
66
|
+
tLocalName,
|
|
67
|
+
varLocalName
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
JSXFragment(path) {
|
|
71
|
+
if (processedNodes.has(path.node)) return;
|
|
72
|
+
processJsxFragment({
|
|
73
|
+
path,
|
|
74
|
+
insideAutoT: false,
|
|
75
|
+
importAliases,
|
|
76
|
+
processedNodes,
|
|
77
|
+
tLocalName,
|
|
78
|
+
varLocalName
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
89
82
|
}
|
|
90
|
-
function processJsxElement({ path, insideAutoT, importAliases, processedNodes, tLocalName, varLocalName
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
// Process children
|
|
129
|
-
processElementChildren({
|
|
130
|
-
path,
|
|
131
|
-
insideAutoT,
|
|
132
|
-
importAliases,
|
|
133
|
-
processedNodes,
|
|
134
|
-
tLocalName,
|
|
135
|
-
varLocalName,
|
|
136
|
-
});
|
|
83
|
+
function processJsxElement({ path, insideAutoT, importAliases, processedNodes, tLocalName, varLocalName }) {
|
|
84
|
+
processedNodes.add(path.node);
|
|
85
|
+
const typeName = getElementTypeName(path.node);
|
|
86
|
+
const canonicalName = typeName ? importAliases[typeName] : void 0;
|
|
87
|
+
if (canonicalName === "T") {
|
|
88
|
+
markDescendantJsx(path, processedNodes);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (canonicalName === "Branch" || canonicalName === "Plural" || canonicalName === "Derive" || canonicalName === "Static") {
|
|
92
|
+
if (!insideAutoT) {
|
|
93
|
+
const tWrapper = createTWrapper([path.node], tLocalName);
|
|
94
|
+
processedNodes.add(tWrapper);
|
|
95
|
+
path.replaceWith(tWrapper);
|
|
96
|
+
}
|
|
97
|
+
processOpaqueComponentProps({
|
|
98
|
+
path,
|
|
99
|
+
insideAutoT: true,
|
|
100
|
+
importAliases,
|
|
101
|
+
processedNodes,
|
|
102
|
+
tLocalName,
|
|
103
|
+
varLocalName,
|
|
104
|
+
canonicalName
|
|
105
|
+
});
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (canonicalName && VARIABLE_COMPONENTS.includes(canonicalName)) {
|
|
109
|
+
markDescendantJsx(path, processedNodes);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
processElementChildren({
|
|
113
|
+
path,
|
|
114
|
+
insideAutoT,
|
|
115
|
+
importAliases,
|
|
116
|
+
processedNodes,
|
|
117
|
+
tLocalName,
|
|
118
|
+
varLocalName
|
|
119
|
+
});
|
|
137
120
|
}
|
|
138
|
-
function processJsxFragment({ path, insideAutoT, importAliases, processedNodes, tLocalName, varLocalName
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
});
|
|
121
|
+
function processJsxFragment({ path, insideAutoT, importAliases, processedNodes, tLocalName, varLocalName }) {
|
|
122
|
+
processedNodes.add(path.node);
|
|
123
|
+
processFragmentChildren({
|
|
124
|
+
path,
|
|
125
|
+
insideAutoT,
|
|
126
|
+
importAliases,
|
|
127
|
+
processedNodes,
|
|
128
|
+
tLocalName,
|
|
129
|
+
varLocalName
|
|
130
|
+
});
|
|
149
131
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
for (const childPath of childPaths) {
|
|
183
|
-
if (childPath.isJSXElement() && !processedNodes.has(childPath.node)) {
|
|
184
|
-
processJsxElement({ path: childPath, ...ctx });
|
|
185
|
-
}
|
|
186
|
-
else if (childPath.isJSXFragment() &&
|
|
187
|
-
!processedNodes.has(childPath.node)) {
|
|
188
|
-
processJsxFragment({ path: childPath, ...ctx });
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
132
|
+
function processElementChildren({ path, insideAutoT, importAliases, processedNodes, tLocalName, varLocalName }) {
|
|
133
|
+
const children = path.node.children;
|
|
134
|
+
const ctx = {
|
|
135
|
+
insideAutoT,
|
|
136
|
+
importAliases,
|
|
137
|
+
processedNodes,
|
|
138
|
+
tLocalName,
|
|
139
|
+
varLocalName
|
|
140
|
+
};
|
|
141
|
+
const hasText = hasTranslatableText(children);
|
|
142
|
+
const hasOpaque = hasOpaqueGTChild(children, importAliases);
|
|
143
|
+
if (!insideAutoT && (hasText || hasOpaque)) {
|
|
144
|
+
const childPaths = path.get("children");
|
|
145
|
+
for (const childPath of childPaths) processChild(childPath, {
|
|
146
|
+
...ctx,
|
|
147
|
+
insideAutoT: true
|
|
148
|
+
});
|
|
149
|
+
wrapChildrenInT(path, tLocalName, processedNodes);
|
|
150
|
+
} else if (insideAutoT) {
|
|
151
|
+
const childPaths = path.get("children");
|
|
152
|
+
for (const childPath of childPaths) processChild(childPath, ctx);
|
|
153
|
+
} else {
|
|
154
|
+
const childPaths = path.get("children");
|
|
155
|
+
for (const childPath of childPaths) if (childPath.isJSXElement() && !processedNodes.has(childPath.node)) processJsxElement({
|
|
156
|
+
path: childPath,
|
|
157
|
+
...ctx
|
|
158
|
+
});
|
|
159
|
+
else if (childPath.isJSXFragment() && !processedNodes.has(childPath.node)) processJsxFragment({
|
|
160
|
+
path: childPath,
|
|
161
|
+
...ctx
|
|
162
|
+
});
|
|
163
|
+
}
|
|
192
164
|
}
|
|
193
|
-
function processFragmentChildren({ path, insideAutoT, importAliases, processedNodes, tLocalName, varLocalName
|
|
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
|
-
!processedNodes.has(childPath.node)) {
|
|
226
|
-
processJsxFragment({ path: childPath, ...ctx });
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
165
|
+
function processFragmentChildren({ path, insideAutoT, importAliases, processedNodes, tLocalName, varLocalName }) {
|
|
166
|
+
const children = path.node.children;
|
|
167
|
+
const ctx = {
|
|
168
|
+
insideAutoT,
|
|
169
|
+
importAliases,
|
|
170
|
+
processedNodes,
|
|
171
|
+
tLocalName,
|
|
172
|
+
varLocalName
|
|
173
|
+
};
|
|
174
|
+
const hasText = hasTranslatableText(children);
|
|
175
|
+
const hasOpaque = hasOpaqueGTChild(children, importAliases);
|
|
176
|
+
if (!insideAutoT && (hasText || hasOpaque)) {
|
|
177
|
+
const childPaths = path.get("children");
|
|
178
|
+
for (const childPath of childPaths) processChild(childPath, {
|
|
179
|
+
...ctx,
|
|
180
|
+
insideAutoT: true
|
|
181
|
+
});
|
|
182
|
+
wrapFragmentChildrenInT(path, tLocalName, processedNodes);
|
|
183
|
+
} else if (insideAutoT) {
|
|
184
|
+
const childPaths = path.get("children");
|
|
185
|
+
for (const childPath of childPaths) processChild(childPath, ctx);
|
|
186
|
+
} else {
|
|
187
|
+
const childPaths = path.get("children");
|
|
188
|
+
for (const childPath of childPaths) if (childPath.isJSXElement() && !processedNodes.has(childPath.node)) processJsxElement({
|
|
189
|
+
path: childPath,
|
|
190
|
+
...ctx
|
|
191
|
+
});
|
|
192
|
+
else if (childPath.isJSXFragment() && !processedNodes.has(childPath.node)) processJsxFragment({
|
|
193
|
+
path: childPath,
|
|
194
|
+
...ctx
|
|
195
|
+
});
|
|
196
|
+
}
|
|
230
197
|
}
|
|
231
198
|
function processChild(childPath, ctx) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
ctx.processedNodes.add(varWrapper);
|
|
246
|
-
}
|
|
199
|
+
if (childPath.isJSXElement() && !ctx.processedNodes.has(childPath.node)) processJsxElement({
|
|
200
|
+
path: childPath,
|
|
201
|
+
...ctx
|
|
202
|
+
});
|
|
203
|
+
else if (childPath.isJSXFragment() && !ctx.processedNodes.has(childPath.node)) processJsxFragment({
|
|
204
|
+
path: childPath,
|
|
205
|
+
...ctx
|
|
206
|
+
});
|
|
207
|
+
else if (childPath.isJSXExpressionContainer() && ctx.insideAutoT && needsVarWrapping(childPath.node)) {
|
|
208
|
+
const varWrapper = createVarWrapper(childPath.node, ctx.varLocalName, ctx.processedNodes);
|
|
209
|
+
childPath.replaceWith(varWrapper);
|
|
210
|
+
ctx.processedNodes.add(varWrapper);
|
|
211
|
+
}
|
|
247
212
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
// Non-JSX dynamic value — wrap in Var
|
|
303
|
-
if (needsVarWrapping(valuePath.node)) {
|
|
304
|
-
const varWrapper = createVarWrapper(valuePath.node, varLocalName, processedNodes);
|
|
305
|
-
valuePath.replaceWith(varWrapper);
|
|
306
|
-
processedNodes.add(varWrapper);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
// Mark remaining descendant JSX as processed, but skip auto-inserted nodes
|
|
310
|
-
// so the top-level visitor can still discover JSX inside _Var wrappers.
|
|
311
|
-
// For Derive/Static, only mark props — leave children unmarked so the
|
|
312
|
-
// top-level visitor can independently process them (e.g. Branch/Plural
|
|
313
|
-
// inside Derive should get their own _T, matching compiler behavior).
|
|
314
|
-
if (canonicalName === DERIVE_COMPONENT ||
|
|
315
|
-
canonicalName === STATIC_COMPONENT) {
|
|
316
|
-
for (const attrPath of path.get('openingElement').get('attributes')) {
|
|
317
|
-
attrPath.traverse({
|
|
318
|
-
JSXElement(childPath) {
|
|
319
|
-
processedNodes.add(childPath.node);
|
|
320
|
-
},
|
|
321
|
-
JSXFragment(childPath) {
|
|
322
|
-
processedNodes.add(childPath.node);
|
|
323
|
-
},
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
markDescendantJsx(path, processedNodes);
|
|
329
|
-
}
|
|
213
|
+
function processOpaqueComponentProps({ path, insideAutoT, importAliases, processedNodes, tLocalName, varLocalName, canonicalName }) {
|
|
214
|
+
if (insideAutoT && (canonicalName === "Branch" || canonicalName === "Plural")) {
|
|
215
|
+
const childPaths = path.get("children");
|
|
216
|
+
for (const childPath of childPaths) processChild(childPath, {
|
|
217
|
+
insideAutoT: true,
|
|
218
|
+
importAliases,
|
|
219
|
+
processedNodes,
|
|
220
|
+
tLocalName,
|
|
221
|
+
varLocalName
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
if (!insideAutoT) {
|
|
225
|
+
markDescendantJsx(path, processedNodes);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const ctx = {
|
|
229
|
+
insideAutoT: true,
|
|
230
|
+
importAliases,
|
|
231
|
+
processedNodes,
|
|
232
|
+
tLocalName,
|
|
233
|
+
varLocalName
|
|
234
|
+
};
|
|
235
|
+
const attrs = path.get("openingElement").get("attributes");
|
|
236
|
+
for (const attrPath of attrs) {
|
|
237
|
+
if (!attrPath.isJSXAttribute()) continue;
|
|
238
|
+
const nameNode = attrPath.node.name;
|
|
239
|
+
if (isControlProp(canonicalName, t.isJSXIdentifier(nameNode) ? nameNode.name : null)) continue;
|
|
240
|
+
const valuePath = attrPath.get("value");
|
|
241
|
+
if (!valuePath.isJSXExpressionContainer()) continue;
|
|
242
|
+
const expr = valuePath.node.expression;
|
|
243
|
+
if (t.isJSXElement(expr) || t.isJSXFragment(expr)) {
|
|
244
|
+
const exprPath = valuePath.get("expression");
|
|
245
|
+
if (exprPath.isJSXElement() || exprPath.isJSXFragment()) {
|
|
246
|
+
const childPaths = exprPath.get("children");
|
|
247
|
+
for (const childPath of childPaths) processChild(childPath, ctx);
|
|
248
|
+
}
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if (needsVarWrapping(valuePath.node)) {
|
|
252
|
+
const varWrapper = createVarWrapper(valuePath.node, varLocalName, processedNodes);
|
|
253
|
+
valuePath.replaceWith(varWrapper);
|
|
254
|
+
processedNodes.add(varWrapper);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (canonicalName === "Derive" || canonicalName === "Static") for (const attrPath of path.get("openingElement").get("attributes")) attrPath.traverse({
|
|
258
|
+
JSXElement(childPath) {
|
|
259
|
+
processedNodes.add(childPath.node);
|
|
260
|
+
},
|
|
261
|
+
JSXFragment(childPath) {
|
|
262
|
+
processedNodes.add(childPath.node);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
else markDescendantJsx(path, processedNodes);
|
|
330
266
|
}
|
|
331
267
|
function isControlProp(canonicalName, propName) {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
if (canonicalName === PLURAL_COMPONENT) {
|
|
338
|
-
return PLURAL_CONTROL_PROPS.has(propName);
|
|
339
|
-
}
|
|
340
|
-
return false;
|
|
268
|
+
if (!propName) return false;
|
|
269
|
+
if (canonicalName === "Branch") return BRANCH_CONTROL_PROPS.has(propName) || propName.startsWith("data-");
|
|
270
|
+
if (canonicalName === "Plural") return PLURAL_CONTROL_PROPS.has(propName);
|
|
271
|
+
return false;
|
|
341
272
|
}
|
|
342
|
-
// ===== Helper functions ===== //
|
|
343
273
|
function getElementTypeName(element) {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
return null;
|
|
274
|
+
const name = element.openingElement.name;
|
|
275
|
+
if (t.isJSXIdentifier(name)) return name.name;
|
|
276
|
+
return null;
|
|
348
277
|
}
|
|
349
278
|
function getLocalName(importAliases, canonicalName) {
|
|
350
|
-
|
|
351
|
-
|
|
279
|
+
const entry = Object.entries(importAliases).find(([, v]) => v === canonicalName);
|
|
280
|
+
return entry ? entry[0] : canonicalName;
|
|
352
281
|
}
|
|
353
282
|
function hasTranslatableText(children) {
|
|
354
|
-
|
|
283
|
+
return children.some((child) => t.isJSXText(child) && child.value.trim().length > 0);
|
|
355
284
|
}
|
|
356
285
|
function hasOpaqueGTChild(children, importAliases) {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
return (canonical === BRANCH_COMPONENT ||
|
|
365
|
-
canonical === PLURAL_COMPONENT ||
|
|
366
|
-
canonical === DERIVE_COMPONENT ||
|
|
367
|
-
canonical === STATIC_COMPONENT);
|
|
368
|
-
});
|
|
286
|
+
return children.some((child) => {
|
|
287
|
+
if (!t.isJSXElement(child)) return false;
|
|
288
|
+
const typeName = getElementTypeName(child);
|
|
289
|
+
if (!typeName) return false;
|
|
290
|
+
const canonical = importAliases[typeName];
|
|
291
|
+
return canonical === "Branch" || canonical === "Plural" || canonical === "Derive" || canonical === "Static";
|
|
292
|
+
});
|
|
369
293
|
}
|
|
370
294
|
function needsVarWrapping(container) {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
if (analysis.isStatic)
|
|
377
|
-
return false;
|
|
378
|
-
// JSX elements/fragments inside expressions are not dynamic — they're valid children
|
|
379
|
-
if (t.isJSXElement(expr) || t.isJSXFragment(expr))
|
|
380
|
-
return false;
|
|
381
|
-
return true;
|
|
295
|
+
const expr = container.expression;
|
|
296
|
+
if (t.isJSXEmptyExpression(expr)) return false;
|
|
297
|
+
if (isStaticExpression(expr, true).isStatic) return false;
|
|
298
|
+
if (t.isJSXElement(expr) || t.isJSXFragment(expr)) return false;
|
|
299
|
+
return true;
|
|
382
300
|
}
|
|
383
|
-
// ===== AST construction ===== //
|
|
384
301
|
function createTWrapper(children, tName) {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
302
|
+
const element = t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier(tName), []), t.jsxClosingElement(t.jsxIdentifier(tName)), children);
|
|
303
|
+
autoInsertedNodes.add(element);
|
|
304
|
+
return element;
|
|
388
305
|
}
|
|
389
306
|
function createVarWrapper(child, varName, processedNodes) {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
307
|
+
const varElement = t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier(varName), []), t.jsxClosingElement(t.jsxIdentifier(varName)), [child]);
|
|
308
|
+
autoInsertedNodes.add(varElement);
|
|
309
|
+
processedNodes.add(varElement);
|
|
310
|
+
return t.jsxExpressionContainer(varElement);
|
|
394
311
|
}
|
|
395
312
|
function wrapChildrenInT(elementPath, tName, processedNodes) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
elementPath.node.children = [tWrapper];
|
|
313
|
+
const tWrapper = createTWrapper([...elementPath.node.children], tName);
|
|
314
|
+
processedNodes.add(tWrapper);
|
|
315
|
+
elementPath.node.children = [tWrapper];
|
|
400
316
|
}
|
|
401
317
|
function wrapFragmentChildrenInT(fragmentPath, tName, processedNodes) {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
fragmentPath.node.children = [tWrapper];
|
|
318
|
+
const tWrapper = createTWrapper([...fragmentPath.node.children], tName);
|
|
319
|
+
processedNodes.add(tWrapper);
|
|
320
|
+
fragmentPath.node.children = [tWrapper];
|
|
406
321
|
}
|
|
407
|
-
// ===== Marking descendants as processed ===== //
|
|
408
322
|
function markDescendantJsx(path, processedNodes) {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
},
|
|
426
|
-
});
|
|
323
|
+
path.traverse({
|
|
324
|
+
JSXElement(childPath) {
|
|
325
|
+
if (autoInsertedNodes.has(childPath.node)) {
|
|
326
|
+
childPath.skip();
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
processedNodes.add(childPath.node);
|
|
330
|
+
},
|
|
331
|
+
JSXFragment(childPath) {
|
|
332
|
+
if (autoInsertedNodes.has(childPath.node)) {
|
|
333
|
+
childPath.skip();
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
processedNodes.add(childPath.node);
|
|
337
|
+
}
|
|
338
|
+
});
|
|
427
339
|
}
|
|
340
|
+
//#endregion
|
|
341
|
+
export { autoInsertJsxComponents, ensureTAndVarImported, isAutoInserted };
|
|
342
|
+
|
|
343
|
+
//# sourceMappingURL=autoInsertion.js.map
|