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,95 +1,87 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/react/jsx/utils/constants.ts
|
|
2
|
+
const DECLARE_VAR_FUNCTION = "declareVar";
|
|
2
3
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
* COMPAT: Legacy support for declareStatic function.
|
|
5
|
+
*/
|
|
6
|
+
const DECLARE_STATIC_FUNCTION = "declareStatic";
|
|
7
|
+
const DERIVE_FUNCTION = "derive";
|
|
8
|
+
const MSG_REGISTRATION_FUNCTION = "msg";
|
|
9
|
+
const T_REGISTRATION_FUNCTION = "t";
|
|
10
|
+
const T_GLOBAL_REGISTRATION_FUNCTION = "t";
|
|
11
|
+
const INLINE_TRANSLATION_HOOK = "useGT";
|
|
12
|
+
const INLINE_TRANSLATION_HOOK_ASYNC = "getGT";
|
|
13
|
+
const INLINE_MESSAGE_HOOK = "useMessages";
|
|
14
|
+
const INLINE_MESSAGE_HOOK_ASYNC = "getMessages";
|
|
15
|
+
const TRANSLATION_COMPONENT = "T";
|
|
15
16
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
INTERNAL_VAR_COMPONENT,
|
|
53
|
-
PLURAL_COMPONENT,
|
|
17
|
+
* COMPAT: Legacy support for Static component.
|
|
18
|
+
*/
|
|
19
|
+
const STATIC_COMPONENT = "Static";
|
|
20
|
+
const DERIVE_COMPONENT = "Derive";
|
|
21
|
+
const BRANCH_COMPONENT = "Branch";
|
|
22
|
+
const DEFAULT_GT_IMPORT_SOURCE = "gt-react/browser";
|
|
23
|
+
const INTERNAL_TRANSLATION_COMPONENT = "GtInternalTranslateJsx";
|
|
24
|
+
const INTERNAL_VAR_COMPONENT = "GtInternalVar";
|
|
25
|
+
const VAR_COMPONENT = "Var";
|
|
26
|
+
const DATETIME_COMPONENT = "DateTime";
|
|
27
|
+
const RELATIVE_TIME_COMPONENT = "RelativeTime";
|
|
28
|
+
const CURRENCY_COMPONENT = "Currency";
|
|
29
|
+
const NUM_COMPONENT = "Num";
|
|
30
|
+
const PLURAL_COMPONENT = "Plural";
|
|
31
|
+
const GT_TRANSLATION_FUNCS = [
|
|
32
|
+
INLINE_TRANSLATION_HOOK,
|
|
33
|
+
INLINE_TRANSLATION_HOOK_ASYNC,
|
|
34
|
+
INLINE_MESSAGE_HOOK,
|
|
35
|
+
INLINE_MESSAGE_HOOK_ASYNC,
|
|
36
|
+
"msg",
|
|
37
|
+
"t",
|
|
38
|
+
DECLARE_VAR_FUNCTION,
|
|
39
|
+
DECLARE_STATIC_FUNCTION,
|
|
40
|
+
DERIVE_FUNCTION,
|
|
41
|
+
"T",
|
|
42
|
+
STATIC_COMPONENT,
|
|
43
|
+
DERIVE_COMPONENT,
|
|
44
|
+
"Var",
|
|
45
|
+
DATETIME_COMPONENT,
|
|
46
|
+
RELATIVE_TIME_COMPONENT,
|
|
47
|
+
CURRENCY_COMPONENT,
|
|
48
|
+
"Num",
|
|
49
|
+
BRANCH_COMPONENT,
|
|
50
|
+
INTERNAL_TRANSLATION_COMPONENT,
|
|
51
|
+
INTERNAL_VAR_COMPONENT,
|
|
52
|
+
PLURAL_COMPONENT
|
|
54
53
|
];
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
const STRING_REGISTRATION_FUNCS = ["msg", "t"];
|
|
55
|
+
const GT_DERIVE_STRING_FUNCTIONS = [DECLARE_STATIC_FUNCTION, DERIVE_FUNCTION];
|
|
56
|
+
const VARIABLE_COMPONENTS = [
|
|
57
|
+
"Var",
|
|
58
|
+
DATETIME_COMPONENT,
|
|
59
|
+
RELATIVE_TIME_COMPONENT,
|
|
60
|
+
CURRENCY_COMPONENT,
|
|
61
|
+
"Num",
|
|
62
|
+
STATIC_COMPONENT,
|
|
63
|
+
DERIVE_COMPONENT,
|
|
64
|
+
INTERNAL_VAR_COMPONENT
|
|
59
65
|
];
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
const GT_ATTRIBUTES_WITH_SUGAR = [
|
|
67
|
+
"$id",
|
|
68
|
+
"$context",
|
|
69
|
+
"$maxChars",
|
|
70
|
+
"$format"
|
|
64
71
|
];
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
CURRENCY_COMPONENT,
|
|
71
|
-
NUM_COMPONENT,
|
|
72
|
-
STATIC_COMPONENT,
|
|
73
|
-
DERIVE_COMPONENT,
|
|
74
|
-
INTERNAL_VAR_COMPONENT,
|
|
72
|
+
const GT_ATTRIBUTES = [
|
|
73
|
+
"id",
|
|
74
|
+
"context",
|
|
75
|
+
"maxChars",
|
|
76
|
+
...GT_ATTRIBUTES_WITH_SUGAR
|
|
75
77
|
];
|
|
76
|
-
|
|
77
|
-
'$id',
|
|
78
|
-
'$context',
|
|
79
|
-
'$maxChars',
|
|
80
|
-
'$format',
|
|
81
|
-
];
|
|
82
|
-
export const GT_ATTRIBUTES = [
|
|
83
|
-
'id',
|
|
84
|
-
'context',
|
|
85
|
-
'maxChars',
|
|
86
|
-
...GT_ATTRIBUTES_WITH_SUGAR,
|
|
87
|
-
];
|
|
88
|
-
// Data attribute prefix injected by build tools
|
|
89
|
-
export const DATA_ATTR_PREFIX = 'data-';
|
|
78
|
+
const DATA_ATTR_PREFIX = "data-";
|
|
90
79
|
/** Branch control props — not translatable content. */
|
|
91
|
-
|
|
80
|
+
const BRANCH_CONTROL_PROPS = new Set(["branch"]);
|
|
92
81
|
/** Plural control props — not translatable content. */
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
82
|
+
const PLURAL_CONTROL_PROPS = new Set(["n", "locales"]);
|
|
83
|
+
const T_GLOBAL_REGISTRATION_FUNCTION_MARKER = "_gt_internal_t_global_registration_marker";
|
|
84
|
+
//#endregion
|
|
85
|
+
export { BRANCH_COMPONENT, BRANCH_CONTROL_PROPS, CURRENCY_COMPONENT, DATA_ATTR_PREFIX, DATETIME_COMPONENT, DECLARE_STATIC_FUNCTION, DECLARE_VAR_FUNCTION, DEFAULT_GT_IMPORT_SOURCE, DERIVE_COMPONENT, DERIVE_FUNCTION, GT_ATTRIBUTES, GT_ATTRIBUTES_WITH_SUGAR, GT_DERIVE_STRING_FUNCTIONS, GT_TRANSLATION_FUNCS, INLINE_MESSAGE_HOOK, INLINE_MESSAGE_HOOK_ASYNC, INLINE_TRANSLATION_HOOK, INLINE_TRANSLATION_HOOK_ASYNC, INTERNAL_TRANSLATION_COMPONENT, INTERNAL_VAR_COMPONENT, MSG_REGISTRATION_FUNCTION, NUM_COMPONENT, PLURAL_COMPONENT, PLURAL_CONTROL_PROPS, RELATIVE_TIME_COMPONENT, STATIC_COMPONENT, STRING_REGISTRATION_FUNCS, TRANSLATION_COMPONENT, T_GLOBAL_REGISTRATION_FUNCTION, T_GLOBAL_REGISTRATION_FUNCTION_MARKER, T_REGISTRATION_FUNCTION, VARIABLE_COMPONENTS, VAR_COMPONENT };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../../../src/react/jsx/utils/constants.ts"],"sourcesContent":["export const DECLARE_VAR_FUNCTION = 'declareVar';\n/**\n * COMPAT: Legacy support for declareStatic function.\n */\nexport const DECLARE_STATIC_FUNCTION = 'declareStatic';\nexport const DERIVE_FUNCTION = 'derive';\nexport const MSG_REGISTRATION_FUNCTION = 'msg';\nexport const T_REGISTRATION_FUNCTION = 't';\nexport const T_GLOBAL_REGISTRATION_FUNCTION = T_REGISTRATION_FUNCTION;\nexport const INLINE_TRANSLATION_HOOK = 'useGT';\nexport const INLINE_TRANSLATION_HOOK_ASYNC = 'getGT';\nexport const INLINE_MESSAGE_HOOK = 'useMessages';\nexport const INLINE_MESSAGE_HOOK_ASYNC = 'getMessages';\nexport const TRANSLATION_COMPONENT = 'T';\n/**\n * COMPAT: Legacy support for Static component.\n */\nexport const STATIC_COMPONENT = 'Static';\nexport const DERIVE_COMPONENT = 'Derive';\nexport const BRANCH_COMPONENT = 'Branch';\nexport const DEFAULT_GT_IMPORT_SOURCE = 'gt-react/browser';\nexport const INTERNAL_TRANSLATION_COMPONENT = 'GtInternalTranslateJsx';\nexport const INTERNAL_VAR_COMPONENT = 'GtInternalVar';\n\n// Variable components\nexport const VAR_COMPONENT = 'Var';\nexport const DATETIME_COMPONENT = 'DateTime';\nexport const RELATIVE_TIME_COMPONENT = 'RelativeTime';\nexport const CURRENCY_COMPONENT = 'Currency';\nexport const NUM_COMPONENT = 'Num';\nexport const PLURAL_COMPONENT = 'Plural';\n\n// GT translation functions\nexport const GT_TRANSLATION_FUNCS = [\n INLINE_TRANSLATION_HOOK,\n INLINE_TRANSLATION_HOOK_ASYNC,\n INLINE_MESSAGE_HOOK,\n INLINE_MESSAGE_HOOK_ASYNC,\n MSG_REGISTRATION_FUNCTION,\n T_REGISTRATION_FUNCTION,\n DECLARE_VAR_FUNCTION,\n DECLARE_STATIC_FUNCTION,\n DERIVE_FUNCTION,\n TRANSLATION_COMPONENT,\n STATIC_COMPONENT,\n DERIVE_COMPONENT,\n VAR_COMPONENT,\n DATETIME_COMPONENT,\n RELATIVE_TIME_COMPONENT,\n CURRENCY_COMPONENT,\n NUM_COMPONENT,\n BRANCH_COMPONENT,\n INTERNAL_TRANSLATION_COMPONENT,\n INTERNAL_VAR_COMPONENT,\n PLURAL_COMPONENT,\n];\n// GT String translation functions\nexport const STRING_REGISTRATION_FUNCS = [\n MSG_REGISTRATION_FUNCTION,\n T_REGISTRATION_FUNCTION,\n] as const;\n\n// Derive functions that are imported from GT\nexport const GT_DERIVE_STRING_FUNCTIONS = [\n DECLARE_STATIC_FUNCTION,\n DERIVE_FUNCTION,\n];\n\n// Valid variable components\nexport const VARIABLE_COMPONENTS = [\n VAR_COMPONENT,\n DATETIME_COMPONENT,\n RELATIVE_TIME_COMPONENT,\n CURRENCY_COMPONENT,\n NUM_COMPONENT,\n STATIC_COMPONENT,\n DERIVE_COMPONENT,\n INTERNAL_VAR_COMPONENT,\n];\n\nexport const GT_ATTRIBUTES_WITH_SUGAR = [\n '$id',\n '$context',\n '$maxChars',\n '$format',\n] as const;\n\nexport const GT_ATTRIBUTES = [\n 'id',\n 'context',\n 'maxChars',\n ...GT_ATTRIBUTES_WITH_SUGAR,\n] as const;\n\n// Data attribute prefix injected by build tools\nexport const DATA_ATTR_PREFIX = 'data-' as const;\n\n/** Branch control props — not translatable content. */\nexport const BRANCH_CONTROL_PROPS = new Set(['branch']);\n\n/** Plural control props — not translatable content. */\nexport const PLURAL_CONTROL_PROPS = new Set(['n', 'locales']);\n\n// demarcation for global t macro\nexport const T_GLOBAL_REGISTRATION_FUNCTION_MARKER =\n '_gt_internal_t_global_registration_marker';\n"],"mappings":";AAAA,MAAa,uBAAuB;;;;AAIpC,MAAa,0BAA0B;AACvC,MAAa,kBAAkB;AAC/B,MAAa,4BAA4B;AACzC,MAAa,0BAA0B;AACvC,MAAa,iCAAA;AACb,MAAa,0BAA0B;AACvC,MAAa,gCAAgC;AAC7C,MAAa,sBAAsB;AACnC,MAAa,4BAA4B;AACzC,MAAa,wBAAwB;;;;AAIrC,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,2BAA2B;AACxC,MAAa,iCAAiC;AAC9C,MAAa,yBAAyB;AAGtC,MAAa,gBAAgB;AAC7B,MAAa,qBAAqB;AAClC,MAAa,0BAA0B;AACvC,MAAa,qBAAqB;AAClC,MAAa,gBAAgB;AAC7B,MAAa,mBAAmB;AAGhC,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;;;CAGA;CACA;CACA;;CAEA;CACA;;CAEA;CACA;CACA;;CAEA;CACA;CACA;CACA;CACD;AAED,MAAa,4BAA4B,CAAA,OAAA,IAGxC;AAGD,MAAa,6BAA6B,CACxC,yBACA,gBACD;AAGD,MAAa,sBAAsB;;CAEjC;CACA;CACA;;CAEA;CACA;CACA;CACD;AAED,MAAa,2BAA2B;CACtC;CACA;CACA;CACA;CACD;AAED,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA,GAAG;CACJ;AAGD,MAAa,mBAAmB;;AAGhC,MAAa,uBAAuB,IAAI,IAAI,CAAC,SAAS,CAAC;;AAGvD,MAAa,uBAAuB,IAAI,IAAI,CAAC,KAAK,UAAU,CAAC;AAG7D,MAAa,wCACX"}
|
|
@@ -1,39 +1,38 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
|
|
3
|
-
const fileContentCache = new Map();
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
//#region src/react/jsx/utils/extractSourceCode.ts
|
|
3
|
+
const fileContentCache = /* @__PURE__ */ new Map();
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const afterEnd = Math.min(totalLines - 1, targetEnd + n);
|
|
35
|
-
const before = lines.slice(beforeStart, targetStart).join('\n');
|
|
36
|
-
const target = lines.slice(targetStart, targetEnd + 1).join('\n');
|
|
37
|
-
const after = lines.slice(targetEnd + 1, afterEnd + 1).join('\n');
|
|
38
|
-
return { before, target, after };
|
|
5
|
+
* Extracts the surrounding lines of source code around a target node.
|
|
6
|
+
*
|
|
7
|
+
* @param filePath - Absolute path to the source file
|
|
8
|
+
* @param startLine - 1-based start line of the target node
|
|
9
|
+
* @param endLine - 1-based end line of the target node
|
|
10
|
+
* @param n - Number of surrounding lines before and after to capture
|
|
11
|
+
* @returns The surrounding lines, or undefined if the file can't be read
|
|
12
|
+
*/
|
|
13
|
+
function extractSourceCode(filePath, startLine, endLine, n) {
|
|
14
|
+
let fileContent = fileContentCache.get(filePath);
|
|
15
|
+
if (fileContent === void 0) try {
|
|
16
|
+
const result = fs.readFileSync(filePath, "utf8");
|
|
17
|
+
if (typeof result !== "string") return;
|
|
18
|
+
fileContent = result;
|
|
19
|
+
fileContentCache.set(filePath, fileContent);
|
|
20
|
+
} catch {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const lines = fileContent.split("\n");
|
|
24
|
+
const totalLines = lines.length;
|
|
25
|
+
const targetStart = Math.max(0, startLine - 1);
|
|
26
|
+
const targetEnd = Math.min(totalLines - 1, endLine - 1);
|
|
27
|
+
const beforeStart = Math.max(0, targetStart - n);
|
|
28
|
+
const afterEnd = Math.min(totalLines - 1, targetEnd + n);
|
|
29
|
+
return {
|
|
30
|
+
before: lines.slice(beforeStart, targetStart).join("\n"),
|
|
31
|
+
target: lines.slice(targetStart, targetEnd + 1).join("\n"),
|
|
32
|
+
after: lines.slice(targetEnd + 1, afterEnd + 1).join("\n")
|
|
33
|
+
};
|
|
39
34
|
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { extractSourceCode };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=extractSourceCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractSourceCode.js","names":[],"sources":["../../../../src/react/jsx/utils/extractSourceCode.ts"],"sourcesContent":["import fs from 'node:fs';\n\nexport type SourceCode = {\n before: string;\n target: string;\n after: string;\n};\n\n// Cache file contents to avoid re-reading the same file for multiple translation sites\nconst fileContentCache = new Map<string, string>();\n\n/**\n * Extracts the surrounding lines of source code around a target node.\n *\n * @param filePath - Absolute path to the source file\n * @param startLine - 1-based start line of the target node\n * @param endLine - 1-based end line of the target node\n * @param n - Number of surrounding lines before and after to capture\n * @returns The surrounding lines, or undefined if the file can't be read\n */\nexport function extractSourceCode(\n filePath: string,\n startLine: number,\n endLine: number,\n n: number\n): SourceCode | undefined {\n let fileContent = fileContentCache.get(filePath);\n\n if (fileContent === undefined) {\n try {\n const result = fs.readFileSync(filePath, 'utf8');\n if (typeof result !== 'string') {\n return undefined;\n }\n fileContent = result;\n fileContentCache.set(filePath, fileContent);\n } catch {\n return undefined;\n }\n }\n\n const lines = fileContent.split('\\n');\n const totalLines = lines.length;\n\n // Clamp to valid line ranges (convert to 0-based)\n const targetStart = Math.max(0, startLine - 1);\n const targetEnd = Math.min(totalLines - 1, endLine - 1);\n\n const beforeStart = Math.max(0, targetStart - n);\n const afterEnd = Math.min(totalLines - 1, targetEnd + n);\n\n const before = lines.slice(beforeStart, targetStart).join('\\n');\n const target = lines.slice(targetStart, targetEnd + 1).join('\\n');\n const after = lines.slice(targetEnd + 1, afterEnd + 1).join('\\n');\n\n return { before, target, after };\n}\n"],"mappings":";;AASA,MAAM,mCAAmB,IAAI,KAAqB;;;;;;;;;;AAWlD,SAAgB,kBACd,UACA,WACA,SACA,GACwB;CACxB,IAAI,cAAc,iBAAiB,IAAI,SAAS;AAEhD,KAAI,gBAAgB,KAAA,EAClB,KAAI;EACF,MAAM,SAAS,GAAG,aAAa,UAAU,OAAO;AAChD,MAAI,OAAO,WAAW,SACpB;AAEF,gBAAc;AACd,mBAAiB,IAAI,UAAU,YAAY;SACrC;AACN;;CAIJ,MAAM,QAAQ,YAAY,MAAM,KAAK;CACrC,MAAM,aAAa,MAAM;CAGzB,MAAM,cAAc,KAAK,IAAI,GAAG,YAAY,EAAE;CAC9C,MAAM,YAAY,KAAK,IAAI,aAAa,GAAG,UAAU,EAAE;CAEvD,MAAM,cAAc,KAAK,IAAI,GAAG,cAAc,EAAE;CAChD,MAAM,WAAW,KAAK,IAAI,aAAa,GAAG,YAAY,EAAE;AAMxD,QAAO;EAAE,QAJM,MAAM,MAAM,aAAa,YAAY,CAAC,KAAK,KAI3C;EAAE,QAHF,MAAM,MAAM,aAAa,YAAY,EAAE,CAAC,KAAK,KAGrC;EAAE,OAFX,MAAM,MAAM,YAAY,GAAG,WAAW,EAAE,CAAC,KAAK,KAE9B;EAAE"}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import * as t from
|
|
1
|
+
import * as t from "@babel/types";
|
|
2
|
+
//#region src/react/jsx/utils/getCalleeNameFromExpression.ts
|
|
2
3
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
functionName: calleeName.property.name,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return { namespaceName: null, functionName: null };
|
|
4
|
+
* Get the callee name from an expression: ... = useGT();
|
|
5
|
+
* Rule of thumb, only call on expressions with parentheses
|
|
6
|
+
*/
|
|
7
|
+
function getCalleeNameFromExpression(expr) {
|
|
8
|
+
if (t.isAwaitExpression(expr)) return getCalleeNameFromExpression(expr.argument);
|
|
9
|
+
if (!t.isCallExpression(expr)) return {
|
|
10
|
+
namespaceName: null,
|
|
11
|
+
functionName: null
|
|
12
|
+
};
|
|
13
|
+
const calleeName = expr.callee;
|
|
14
|
+
if (t.isIdentifier(calleeName)) return {
|
|
15
|
+
namespaceName: null,
|
|
16
|
+
functionName: calleeName.name
|
|
17
|
+
};
|
|
18
|
+
if (t.isMemberExpression(calleeName)) {
|
|
19
|
+
if (t.isIdentifier(calleeName.object) && t.isIdentifier(calleeName.property)) return {
|
|
20
|
+
namespaceName: calleeName.object.name,
|
|
21
|
+
functionName: calleeName.property.name
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
namespaceName: null,
|
|
26
|
+
functionName: null
|
|
27
|
+
};
|
|
32
28
|
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { getCalleeNameFromExpression };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=getCalleeNameFromExpression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCalleeNameFromExpression.js","names":[],"sources":["../../../../src/react/jsx/utils/getCalleeNameFromExpression.ts"],"sourcesContent":["import * as t from '@babel/types';\n\n/**\n * Get the callee name from an expression: ... = useGT();\n * Rule of thumb, only call on expressions with parentheses\n */\nexport function getCalleeNameFromExpression(expr: t.Expression): {\n namespaceName: string | null;\n functionName: string | null;\n} {\n // If its an await expression, unwrap it\n if (t.isAwaitExpression(expr)) {\n return getCalleeNameFromExpression(expr.argument);\n }\n\n // Check that this is a call expression eg: func()\n if (!t.isCallExpression(expr)) {\n return { namespaceName: null, functionName: null };\n }\n\n // Get the callee name\n const calleeName = expr.callee;\n\n // Simple case: ... = useGT();\n if (t.isIdentifier(calleeName)) {\n return { namespaceName: null, functionName: calleeName.name };\n }\n\n // Member expression: ... = GT.useGT();\n if (t.isMemberExpression(calleeName)) {\n if (\n t.isIdentifier(calleeName.object) &&\n t.isIdentifier(calleeName.property)\n ) {\n return {\n namespaceName: calleeName.object.name,\n functionName: calleeName.property.name,\n };\n }\n }\n\n return { namespaceName: null, functionName: null };\n}\n"],"mappings":";;;;;;AAMA,SAAgB,4BAA4B,MAG1C;AAEA,KAAI,EAAE,kBAAkB,KAAK,CAC3B,QAAO,4BAA4B,KAAK,SAAS;AAInD,KAAI,CAAC,EAAE,iBAAiB,KAAK,CAC3B,QAAO;EAAE,eAAe;EAAM,cAAc;EAAM;CAIpD,MAAM,aAAa,KAAK;AAGxB,KAAI,EAAE,aAAa,WAAW,CAC5B,QAAO;EAAE,eAAe;EAAM,cAAc,WAAW;EAAM;AAI/D,KAAI,EAAE,mBAAmB,WAAW;MAEhC,EAAE,aAAa,WAAW,OAAO,IACjC,EAAE,aAAa,WAAW,SAAS,CAEnC,QAAO;GACL,eAAe,WAAW,OAAO;GACjC,cAAc,WAAW,SAAS;GACnC;;AAIL,QAAO;EAAE,eAAe;EAAM,cAAc;EAAM"}
|
|
@@ -1,108 +1,73 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import { GT_TRANSLATION_FUNCS, T_GLOBAL_REGISTRATION_FUNCTION_MARKER } from "./constants.js";
|
|
2
|
+
import { extractImportName } from "./parseAst.js";
|
|
3
|
+
import * as t from "@babel/types";
|
|
4
|
+
import traverseModule from "@babel/traverse";
|
|
5
|
+
//#region src/react/jsx/utils/getPathsAndAliases.ts
|
|
6
6
|
const traverse = traverseModule.default || traverseModule;
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (args.length === 1 &&
|
|
70
|
-
args[0].type === 'StringLiteral' &&
|
|
71
|
-
pkgs.some((pkg) => args[0].value.startsWith(pkg))) {
|
|
72
|
-
const parentPath = path.parentPath;
|
|
73
|
-
if (parentPath.isVariableDeclaration()) {
|
|
74
|
-
const importName = extractImportName(parentPath.node, pkgs, GT_TRANSLATION_FUNCS);
|
|
75
|
-
for (const name of importName) {
|
|
76
|
-
if (name.original === INLINE_TRANSLATION_HOOK ||
|
|
77
|
-
name.original === INLINE_TRANSLATION_HOOK_ASYNC ||
|
|
78
|
-
name.original === INLINE_MESSAGE_HOOK ||
|
|
79
|
-
name.original === INLINE_MESSAGE_HOOK_ASYNC) {
|
|
80
|
-
inlineTranslationPaths.push({
|
|
81
|
-
localName: name.local,
|
|
82
|
-
path: parentPath,
|
|
83
|
-
originalName: name.original,
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
else if (name.original === TRANSLATION_COMPONENT ||
|
|
87
|
-
name.original === INTERNAL_TRANSLATION_COMPONENT) {
|
|
88
|
-
translationComponentPaths.push({
|
|
89
|
-
localName: name.local,
|
|
90
|
-
path: parentPath,
|
|
91
|
-
originalName: name.original,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
importAliases[name.local] = name.original;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
});
|
|
103
|
-
return {
|
|
104
|
-
importAliases,
|
|
105
|
-
inlineTranslationPaths,
|
|
106
|
-
translationComponentPaths,
|
|
107
|
-
};
|
|
8
|
+
* Constructs tracking for gt related variables of interest
|
|
9
|
+
* inlineTranslationPaths: these are string-related translation functions
|
|
10
|
+
* translationComponentPaths: these are just <T> components
|
|
11
|
+
* importAliases: any other GT related imports
|
|
12
|
+
*/
|
|
13
|
+
function getPathsAndAliases(ast, pkgs) {
|
|
14
|
+
const importAliases = {};
|
|
15
|
+
const inlineTranslationPaths = [];
|
|
16
|
+
const translationComponentPaths = [];
|
|
17
|
+
traverse(ast, {
|
|
18
|
+
TaggedTemplateExpression(path) {
|
|
19
|
+
if (t.isIdentifier(path.node.tag, { name: "t" }) && !path.scope.hasBinding("t")) inlineTranslationPaths.push({
|
|
20
|
+
localName: "t",
|
|
21
|
+
path: path.get("tag"),
|
|
22
|
+
originalName: T_GLOBAL_REGISTRATION_FUNCTION_MARKER
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
ImportDeclaration(path) {
|
|
26
|
+
if (pkgs.some((pkg) => path.node.source.value.startsWith(pkg))) {
|
|
27
|
+
const importName = extractImportName(path.node, pkgs, GT_TRANSLATION_FUNCS);
|
|
28
|
+
for (const name of importName) if (name.original === "useGT" || name.original === "getGT" || name.original === "useMessages" || name.original === "getMessages" || name.original === "msg" || name.original === "t") inlineTranslationPaths.push({
|
|
29
|
+
localName: name.local,
|
|
30
|
+
path,
|
|
31
|
+
originalName: name.original
|
|
32
|
+
});
|
|
33
|
+
else if (name.original === "T" || name.original === "GtInternalTranslateJsx") translationComponentPaths.push({
|
|
34
|
+
localName: name.local,
|
|
35
|
+
path,
|
|
36
|
+
originalName: name.original
|
|
37
|
+
});
|
|
38
|
+
else importAliases[name.local] = name.original;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
VariableDeclarator(path) {
|
|
42
|
+
if (path.node.init?.type === "CallExpression" && path.node.init.callee.type === "Identifier" && path.node.init.callee.name === "require") {
|
|
43
|
+
const args = path.node.init.arguments;
|
|
44
|
+
if (args.length === 1 && args[0].type === "StringLiteral" && pkgs.some((pkg) => args[0].value.startsWith(pkg))) {
|
|
45
|
+
const parentPath = path.parentPath;
|
|
46
|
+
if (parentPath.isVariableDeclaration()) {
|
|
47
|
+
const importName = extractImportName(parentPath.node, pkgs, GT_TRANSLATION_FUNCS);
|
|
48
|
+
for (const name of importName) if (name.original === "useGT" || name.original === "getGT" || name.original === "useMessages" || name.original === "getMessages") inlineTranslationPaths.push({
|
|
49
|
+
localName: name.local,
|
|
50
|
+
path: parentPath,
|
|
51
|
+
originalName: name.original
|
|
52
|
+
});
|
|
53
|
+
else if (name.original === "T" || name.original === "GtInternalTranslateJsx") translationComponentPaths.push({
|
|
54
|
+
localName: name.local,
|
|
55
|
+
path: parentPath,
|
|
56
|
+
originalName: name.original
|
|
57
|
+
});
|
|
58
|
+
else importAliases[name.local] = name.original;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
importAliases,
|
|
66
|
+
inlineTranslationPaths,
|
|
67
|
+
translationComponentPaths
|
|
68
|
+
};
|
|
108
69
|
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { getPathsAndAliases };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=getPathsAndAliases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPathsAndAliases.js","names":[],"sources":["../../../../src/react/jsx/utils/getPathsAndAliases.ts"],"sourcesContent":["import traverseModule from '@babel/traverse';\nimport { NodePath } from '@babel/traverse';\nimport {\n GT_TRANSLATION_FUNCS,\n INLINE_TRANSLATION_HOOK,\n INLINE_TRANSLATION_HOOK_ASYNC,\n INLINE_MESSAGE_HOOK,\n INLINE_MESSAGE_HOOK_ASYNC,\n MSG_REGISTRATION_FUNCTION,\n T_REGISTRATION_FUNCTION,\n TRANSLATION_COMPONENT,\n INTERNAL_TRANSLATION_COMPONENT,\n T_GLOBAL_REGISTRATION_FUNCTION,\n T_GLOBAL_REGISTRATION_FUNCTION_MARKER,\n} from '../../jsx/utils/constants.js';\nimport { GTLibrary } from '../../../types/libraries.js';\nimport { extractImportName } from './parseAst.js';\nimport * as t from '@babel/types';\n\n// Handle CommonJS/ESM interop\nconst traverse = traverseModule.default || traverseModule;\n\n/**\n * Constructs tracking for gt related variables of interest\n * inlineTranslationPaths: these are string-related translation functions\n * translationComponentPaths: these are just <T> components\n * importAliases: any other GT related imports\n */\nexport function getPathsAndAliases(\n ast: t.Node,\n pkgs: GTLibrary[]\n): {\n importAliases: Record<string, string>;\n inlineTranslationPaths: Array<{\n localName: string;\n path: NodePath;\n originalName: string;\n }>;\n translationComponentPaths: Array<{\n localName: string;\n path: NodePath;\n originalName: string;\n }>;\n} {\n // First pass: collect imports and process translation functions\n const importAliases: Record<string, string> = {};\n const inlineTranslationPaths: Array<{\n localName: string;\n path: NodePath;\n originalName: string;\n }> = [];\n\n const translationComponentPaths: Array<{\n localName: string;\n path: NodePath;\n originalName: string;\n }> = [];\n\n traverse(ast, {\n // extract global t tagged template\n TaggedTemplateExpression(path) {\n if (\n t.isIdentifier(path.node.tag, {\n name: T_GLOBAL_REGISTRATION_FUNCTION,\n }) &&\n !path.scope.hasBinding(T_GLOBAL_REGISTRATION_FUNCTION)\n ) {\n inlineTranslationPaths.push({\n localName: T_GLOBAL_REGISTRATION_FUNCTION,\n path: path.get('tag') as NodePath,\n originalName: T_GLOBAL_REGISTRATION_FUNCTION_MARKER,\n });\n }\n },\n ImportDeclaration(path) {\n if (pkgs.some((pkg) => path.node.source.value.startsWith(pkg))) {\n const importName = extractImportName(\n path.node,\n pkgs,\n GT_TRANSLATION_FUNCS\n );\n for (const name of importName) {\n if (\n name.original === INLINE_TRANSLATION_HOOK ||\n name.original === INLINE_TRANSLATION_HOOK_ASYNC ||\n name.original === INLINE_MESSAGE_HOOK ||\n name.original === INLINE_MESSAGE_HOOK_ASYNC ||\n name.original === MSG_REGISTRATION_FUNCTION ||\n name.original === T_REGISTRATION_FUNCTION\n ) {\n inlineTranslationPaths.push({\n localName: name.local,\n path,\n originalName: name.original,\n });\n } else if (\n name.original === TRANSLATION_COMPONENT ||\n name.original === INTERNAL_TRANSLATION_COMPONENT\n ) {\n translationComponentPaths.push({\n localName: name.local,\n path,\n originalName: name.original,\n });\n } else {\n importAliases[name.local] = name.original;\n }\n }\n }\n },\n VariableDeclarator(path) {\n // Check if the init is a require call\n if (\n path.node.init?.type === 'CallExpression' &&\n path.node.init.callee.type === 'Identifier' &&\n path.node.init.callee.name === 'require'\n ) {\n // Check if it's requiring our package\n const args = path.node.init.arguments;\n if (\n args.length === 1 &&\n args[0].type === 'StringLiteral' &&\n pkgs.some((pkg) => (args[0] as t.StringLiteral).value.startsWith(pkg))\n ) {\n const parentPath = path.parentPath;\n if (parentPath.isVariableDeclaration()) {\n const importName = extractImportName(\n parentPath.node,\n pkgs,\n GT_TRANSLATION_FUNCS\n );\n for (const name of importName) {\n if (\n name.original === INLINE_TRANSLATION_HOOK ||\n name.original === INLINE_TRANSLATION_HOOK_ASYNC ||\n name.original === INLINE_MESSAGE_HOOK ||\n name.original === INLINE_MESSAGE_HOOK_ASYNC\n ) {\n inlineTranslationPaths.push({\n localName: name.local,\n path: parentPath,\n originalName: name.original,\n });\n } else if (\n name.original === TRANSLATION_COMPONENT ||\n name.original === INTERNAL_TRANSLATION_COMPONENT\n ) {\n translationComponentPaths.push({\n localName: name.local,\n path: parentPath,\n originalName: name.original,\n });\n } else {\n importAliases[name.local] = name.original;\n }\n }\n }\n }\n }\n },\n });\n return {\n importAliases,\n inlineTranslationPaths,\n translationComponentPaths,\n };\n}\n"],"mappings":";;;;;AAoBA,MAAM,WAAW,eAAe,WAAW;;;;;;;AAQ3C,SAAgB,mBACd,KACA,MAaA;CAEA,MAAM,gBAAwC,EAAE;CAChD,MAAM,yBAID,EAAE;CAEP,MAAM,4BAID,EAAE;AAEP,UAAS,KAAK;EAEZ,yBAAyB,MAAM;AAC7B,OACE,EAAE,aAAa,KAAK,KAAK,KAAK,EAC5B,MAAA,KACD,CAAC,IACF,CAAC,KAAK,MAAM,WAAA,IAA0C,CAEtD,wBAAuB,KAAK;IAC1B,WAAA;IACA,MAAM,KAAK,IAAI,MAAM;IACrB,cAAc;IACf,CAAC;;EAGN,kBAAkB,MAAM;AACtB,OAAI,KAAK,MAAM,QAAQ,KAAK,KAAK,OAAO,MAAM,WAAW,IAAI,CAAC,EAAE;IAC9D,MAAM,aAAa,kBACjB,KAAK,MACL,MACA,qBACD;AACD,SAAK,MAAM,QAAQ,WACjB,KACE,KAAK,aAAA,WACL,KAAK,aAAA,WACL,KAAK,aAAA,iBACL,KAAK,aAAA,iBACL,KAAK,aAAA,SACL,KAAK,aAAA,IAEL,wBAAuB,KAAK;KAC1B,WAAW,KAAK;KAChB;KACA,cAAc,KAAK;KACpB,CAAC;aAEF,KAAK,aAAA,OACL,KAAK,aAAA,yBAEL,2BAA0B,KAAK;KAC7B,WAAW,KAAK;KAChB;KACA,cAAc,KAAK;KACpB,CAAC;QAEF,eAAc,KAAK,SAAS,KAAK;;;EAKzC,mBAAmB,MAAM;AAEvB,OACE,KAAK,KAAK,MAAM,SAAS,oBACzB,KAAK,KAAK,KAAK,OAAO,SAAS,gBAC/B,KAAK,KAAK,KAAK,OAAO,SAAS,WAC/B;IAEA,MAAM,OAAO,KAAK,KAAK,KAAK;AAC5B,QACE,KAAK,WAAW,KAChB,KAAK,GAAG,SAAS,mBACjB,KAAK,MAAM,QAAS,KAAK,GAAuB,MAAM,WAAW,IAAI,CAAC,EACtE;KACA,MAAM,aAAa,KAAK;AACxB,SAAI,WAAW,uBAAuB,EAAE;MACtC,MAAM,aAAa,kBACjB,WAAW,MACX,MACA,qBACD;AACD,WAAK,MAAM,QAAQ,WACjB,KACE,KAAK,aAAA,WACL,KAAK,aAAA,WACL,KAAK,aAAA,iBACL,KAAK,aAAA,cAEL,wBAAuB,KAAK;OAC1B,WAAW,KAAK;OAChB,MAAM;OACN,cAAc,KAAK;OACpB,CAAC;eAEF,KAAK,aAAA,OACL,KAAK,aAAA,yBAEL,2BAA0B,KAAK;OAC7B,WAAW,KAAK;OAChB,MAAM;OACN,cAAc,KAAK;OACpB,CAAC;UAEF,eAAc,KAAK,SAAS,KAAK;;;;;EAO9C,CAAC;AACF,QAAO;EACL;EACA;EACA;EACD"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import * as t from
|
|
1
|
+
import * as t from "@babel/types";
|
|
2
|
+
//#region src/react/jsx/utils/isNumberLiteral.ts
|
|
2
3
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
(expr.operator === '-' || expr.operator === '+'));
|
|
11
|
-
}
|
|
12
|
-
return t.isNumericLiteral(expr);
|
|
4
|
+
* Given an expression, return true if it is a number literal
|
|
5
|
+
* @param expr - The expression to check
|
|
6
|
+
* @returns True if the expression is a number literal, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
function isNumberLiteral(expr) {
|
|
9
|
+
if (t.isUnaryExpression(expr)) return isNumberLiteral(expr.argument) && (expr.operator === "-" || expr.operator === "+");
|
|
10
|
+
return t.isNumericLiteral(expr);
|
|
13
11
|
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { isNumberLiteral };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=isNumberLiteral.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isNumberLiteral.js","names":[],"sources":["../../../../src/react/jsx/utils/isNumberLiteral.ts"],"sourcesContent":["import * as t from '@babel/types';\n/**\n * Given an expression, return true if it is a number literal\n * @param expr - The expression to check\n * @returns True if the expression is a number literal, false otherwise\n */\nexport function isNumberLiteral(expr: t.Expression): boolean {\n if (t.isUnaryExpression(expr)) {\n return (\n isNumberLiteral(expr.argument) &&\n (expr.operator === '-' || expr.operator === '+')\n );\n }\n return t.isNumericLiteral(expr);\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,gBAAgB,MAA6B;AAC3D,KAAI,EAAE,kBAAkB,KAAK,CAC3B,QACE,gBAAgB,KAAK,SAAS,KAC7B,KAAK,aAAa,OAAO,KAAK,aAAa;AAGhD,QAAO,EAAE,iBAAiB,KAAK"}
|