gt 2.14.35 → 2.14.36
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 +16 -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.js +104 -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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseJsx.js","names":[],"sources":["../../../../../src/react/jsx/utils/jsxParsing/parseJsx.ts"],"sourcesContent":["import { Updates } from '../../../../types/index.js';\nimport { randomUUID } from 'node:crypto';\nimport generateModule from '@babel/generator';\n// Handle CommonJS/ESM interop\nconst generate = generateModule.default || generateModule;\n\nimport * as t from '@babel/types';\nimport fs from 'node:fs';\nimport { parse } from '@babel/parser';\nimport addGTIdentifierToSyntaxTree from './addGTIdentifierToSyntaxTree.js';\nimport {\n warnHasUnwrappedExpressionSync,\n warnNestedTComponent,\n warnFunctionNotFoundSync,\n warnMissingReturnSync,\n warnDuplicateFunctionDefinitionSync,\n warnInvalidDeriveInitSync,\n warnRecursiveFunctionCallSync,\n warnDataAttrOnBranch,\n warnNestedInternalTComponent,\n warnDeriveNonConstVariableSync,\n warnDeriveDestructuringSync,\n} from '../../../../console/index.js';\nimport { isAcceptedPluralForm } from 'generaltranslation/internal';\nimport { isStaticExpression } from '../../evaluateJsx.js';\nimport {\n DATA_ATTR_PREFIX,\n STATIC_COMPONENT,\n DERIVE_COMPONENT,\n TRANSLATION_COMPONENT,\n INTERNAL_TRANSLATION_COMPONENT,\n VARIABLE_COMPONENTS,\n} from '../constants.js';\nimport {\n HTML_CONTENT_PROPS,\n type JsxChildren,\n} from '@generaltranslation/format/types';\nimport type { Metadata } from 'generaltranslation/types';\nimport { NodePath } from '@babel/traverse';\nimport { ParsingConfigOptions } from '../../../../types/parsing.js';\nimport { resolveImportPath } from '../resolveImportPath.js';\n\nimport traverseModule from '@babel/traverse';\nimport { buildImportMap } from '../buildImportMap.js';\nimport { getPathsAndAliases } from '../getPathsAndAliases.js';\nimport { parseTProps } from './parseTProps.js';\nimport { handleChildrenWhitespace } from './handleChildrenWhitespace.js';\nimport { MultiplicationNode, JsxTree, isElementNode } from './types.js';\nimport { multiplyJsxTree } from './multiplication/multiplyJsxTree.js';\nimport { removeNullChildrenFields } from './removeNullChildrenFields.js';\nimport {\n ensureTAndVarImported,\n autoInsertJsxComponents,\n} from './autoInsertion.js';\nimport { GTLibrary } from '../../../../types/libraries.js';\nimport path from 'node:path';\nimport { extractSourceCode } from '../extractSourceCode.js';\nimport { SURROUNDING_LINE_COUNT } from '../../../../utils/constants.js';\nimport { handleDerivation } from '../stringParsing/derivation/handleDerivation.js';\nimport { parseStringExpression, nodeToStrings } from '../parseString.js';\n\n// Handle CommonJS/ESM interop\nconst traverse = traverseModule.default || traverseModule;\n\n// For tracking Derive\ntype DerivableTracker = {\n isDerivable: boolean;\n};\n\n/**\n * Union type representing all possible JSX child node types from Babel.\n */\ntype JSXChildNode =\n | t.JSXText\n | t.JSXExpressionContainer\n | t.JSXSpreadChild\n | t.JSXElement\n | t.JSXFragment;\n\n/**\n * Props object for JSX elements and fragments.\n */\ntype JSXProps = {\n children?: JsxTree | MultiplicationNode | (JsxTree | MultiplicationNode)[];\n [key: string]:\n | string\n | number\n | boolean\n | JsxTree\n | MultiplicationNode\n | (JsxTree | MultiplicationNode)[]\n | null\n | undefined;\n};\n\n/**\n * Immutable configuration options for parsing.\n */\ntype ConfigOptions = {\n parsingOptions: ParsingConfigOptions;\n importAliases: Record<string, string>;\n pkgs: GTLibrary[];\n file: string;\n includeSourceCodeContext?: boolean;\n enableAutoJsxInjection?: boolean;\n autoderive?: boolean;\n};\n\n/**\n * Mutable state for tracking parsing progress.\n */\ntype StateTracker = {\n visited: Set<string> | null;\n callStack: string[];\n derivableTracker: DerivableTracker;\n importedFunctionsMap: Map<string, string>;\n};\n\n/**\n * Collectors for errors, warnings, and unwrapped expressions.\n */\ntype OutputCollector = {\n errors: string[];\n warnings: Set<string>;\n unwrappedExpressions: string[];\n};\n\n// TODO: currently we cover VariableDeclaration and FunctionDeclaration nodes, but are there others we should cover as well?\n\n/**\n * Cache for resolved import paths to avoid redundant I/O operations.\n * Key: `${currentFile}::${importPath}`\n * Value: resolved absolute path or null\n */\nconst resolveImportPathCache = new Map<string, string | null>();\n\n/**\n * Cache for processed functions to avoid re-parsing the same files.\n * Key: `${filePath}::${functionName}::${argIndex}`\n * Value: boolean indicating whether the function was found and processed\n */\nconst processFunctionCache = new Map<string, MultiplicationNode | null>();\n\n/**\n * Entry point for JSX parsing\n */\nexport function parseTranslationComponent({\n originalName,\n localName,\n path,\n updates,\n config,\n output,\n}: {\n originalName: string;\n localName: string;\n path: traverseModule.NodePath<traverseModule.Node>;\n updates: Updates;\n config: ConfigOptions;\n output: OutputCollector;\n}) {\n // First, collect all imports in this file to track cross-file function calls\n const importedFunctionsMap: Map<string, string> = buildImportMap(\n path.scope.getProgramParent().path\n );\n const referencePaths = path.scope.bindings[localName]?.referencePaths || [];\n for (const refPath of referencePaths) {\n // Only start at opening tag\n if (\n !t.isJSXOpeningElement(refPath.parent) ||\n !refPath.parentPath?.parentPath\n ) {\n continue;\n }\n\n // Get the JSX element NodePath\n const jsxElementPath = refPath.parentPath\n ?.parentPath as NodePath<t.JSXElement>;\n\n // Parse <T> component\n parseJSXElement({\n scopeNode: jsxElementPath,\n node: jsxElementPath.node,\n originalName,\n updates,\n config,\n state: {\n visited: null,\n callStack: [],\n derivableTracker: { isDerivable: false },\n importedFunctionsMap,\n },\n output,\n });\n }\n}\n\n/**\n * Builds a JSX tree from a given node, recursively handling children.\n * @param node - The node to build the tree from\n * @param helperPath - NodePath for AST traversal\n * @param scopeNode - Scope node for binding resolution\n * @param insideT - Whether the current node is inside a <T> component\n * @param inDerive - Whether we're inside a <Derive> component\n * @param config - Immutable configuration options\n * @param state - Mutable state tracking\n * @param output - Error/warning collectors\n * @returns The built JSX tree\n */\nfunction buildJSXTree({\n node,\n helperPath,\n scopeNode,\n insideT,\n inDerive,\n config,\n state,\n output,\n}: {\n node: t.Node | null | undefined;\n helperPath: NodePath;\n scopeNode: NodePath;\n insideT: boolean;\n inDerive: boolean;\n config: ConfigOptions;\n state: StateTracker;\n output: OutputCollector;\n}): JsxTree | MultiplicationNode | (JsxTree | MultiplicationNode)[] {\n if (t.isJSXExpressionContainer(node)) {\n // Skip JSX comments\n if (t.isJSXEmptyExpression(node.expression)) {\n return null;\n }\n\n if (inDerive) {\n return processDeriveExpression({\n config,\n state,\n output,\n expressionNodePath: helperPath.get(\n 'expression'\n ) as NodePath<t.Expression>,\n scopeNode,\n });\n }\n\n const expr = node.expression;\n if (t.isJSXElement(expr) || t.isJSXFragment(expr)) {\n return buildJSXTree({\n node: expr,\n insideT,\n inDerive: inDerive,\n scopeNode,\n helperPath: helperPath.get('expression'),\n config,\n state,\n output,\n });\n }\n\n const staticAnalysis = isStaticExpression(expr, true);\n if (staticAnalysis.isStatic && staticAnalysis.value !== undefined) {\n // Preserve the exact whitespace for static string expressions\n return {\n nodeType: 'expression',\n result: staticAnalysis.value,\n };\n }\n\n // Keep existing behavior for non-static expressions\n const code = generate(node).code;\n output.unwrappedExpressions.push(code); // Keep track of unwrapped expressions for error reporting\n return code;\n } else if (t.isJSXText(node)) {\n // Updated JSX Text handling\n // JSX Text handling following React's rules\n const text = node.value;\n return text;\n } else if (t.isJSXElement(node)) {\n const element = node;\n const elementName = element.openingElement.name;\n\n let typeName;\n if (t.isJSXIdentifier(elementName)) {\n typeName = elementName.name;\n } else if (t.isJSXMemberExpression(elementName)) {\n typeName = generate(elementName).code;\n } else {\n typeName = null;\n }\n\n // Convert from alias to original name\n const componentType = config.importAliases[typeName ?? ''];\n\n // When enableAutoJsxInjection is on and we're inside a Derive context,\n // any auto-inserted T component will be stripped at runtime by\n // removeInjectedT. Unwrap it transparently — process the T's children\n // as if the T wasn't there. Check this BEFORE the nested-T warning\n // so we don't emit spurious errors for expected auto-inserted nesting.\n if (\n componentType === INTERNAL_TRANSLATION_COMPONENT &&\n inDerive &&\n config.enableAutoJsxInjection\n ) {\n const childResults: (JsxTree | MultiplicationNode)[] = [];\n const helperChildren = helperPath.get('children');\n for (let i = 0; i < element.children.length; i++) {\n const child = element.children[i];\n const helperChild = helperChildren[i];\n const result = buildJSXTree({\n node: child,\n helperPath: helperChild,\n scopeNode,\n insideT: true,\n inDerive: true,\n config,\n state,\n output,\n });\n if (result !== null) {\n if (Array.isArray(result)) {\n childResults.push(...result);\n } else {\n childResults.push(result);\n }\n }\n }\n if (childResults.length === 0) return null;\n if (childResults.length === 1) return childResults[0];\n // Return array — callers flatten this into parent's children\n return childResults;\n }\n\n if (\n (componentType === TRANSLATION_COMPONENT ||\n componentType === INTERNAL_TRANSLATION_COMPONENT) &&\n insideT\n ) {\n // Add warning: Nested <T> components are allowed, but they are advised against\n output.warnings.add(\n warnNestedTComponent(\n config.file,\n `${element.loc?.start?.line}:${element.loc?.start?.column}`\n )\n );\n if (componentType === INTERNAL_TRANSLATION_COMPONENT) {\n output.errors.push(\n warnNestedInternalTComponent(\n config.file,\n `${element.loc?.start?.line}:${element.loc?.start?.column}`\n )\n );\n }\n }\n\n // If this JSXElement is one of the recognized variable components,\n const elementIsVariable = VARIABLE_COMPONENTS.includes(componentType);\n\n const props: JSXProps = {};\n\n const elementIsPlural = componentType === 'Plural';\n const elementIsBranch = componentType === 'Branch';\n\n element.openingElement.attributes.forEach((attr, index) => {\n const helperAttribute = helperPath\n .get('openingElement')\n .get('attributes')[index];\n if (t.isJSXAttribute(attr)) {\n const attrName =\n typeof attr.name.name === 'string'\n ? attr.name.name\n : attr.name.name.name;\n let attrValue = null;\n if (elementIsBranch && attrName.startsWith(DATA_ATTR_PREFIX)) {\n const location = `${attr.loc?.start?.line}:${attr.loc?.start?.column}`;\n output.errors.push(\n warnDataAttrOnBranch(config.file, attrName, location)\n );\n }\n if (attr.value) {\n if (t.isStringLiteral(attr.value)) {\n attrValue = attr.value.value;\n } else if (t.isJSXExpressionContainer(attr.value)) {\n const helperValue = helperAttribute.get(\n 'value'\n ) as NodePath<t.JSXExpressionContainer>;\n // Check if this is an HTML content prop (title, placeholder, alt, etc.)\n const isHtmlContentProp = (\n Object.values(HTML_CONTENT_PROPS) as string[]\n ).includes(attrName);\n\n // If its a plural or branch prop\n if (\n (elementIsPlural && isAcceptedPluralForm(attrName as string)) ||\n (elementIsBranch &&\n attrName !== 'branch' &&\n !attrName.startsWith(DATA_ATTR_PREFIX))\n ) {\n // Make sure that variable strings like {`I have ${count} book`} are invalid!\n if (\n t.isTemplateLiteral(attr.value.expression) &&\n !isStaticExpression(attr.value.expression, true).isStatic\n ) {\n output.unwrappedExpressions.push(generate(attr.value).code);\n }\n // If it's an array, flag as an unwrapped expression\n if (t.isArrayExpression(attr.value.expression)) {\n output.unwrappedExpressions.push(\n generate(attr.value.expression).code\n );\n }\n attrValue = buildJSXTree({\n node: attr.value,\n insideT: true,\n inDerive: inDerive,\n scopeNode,\n helperPath: helperValue,\n config,\n state,\n output,\n });\n }\n // For HTML content props, only accept static string expressions\n else if (isHtmlContentProp) {\n const staticAnalysis = isStaticExpression(\n attr.value.expression,\n true\n );\n if (\n staticAnalysis.isStatic &&\n staticAnalysis.value !== undefined\n ) {\n attrValue = staticAnalysis.value;\n }\n // Otherwise attrValue stays null and won't be included\n }\n }\n }\n props[attrName] = attrValue;\n }\n });\n\n if (elementIsVariable) {\n if (\n componentType === STATIC_COMPONENT ||\n componentType === DERIVE_COMPONENT\n ) {\n const helperElement = helperPath.get('children');\n const results = {\n nodeType: 'element' as const,\n type: componentType,\n props,\n };\n // Create children array if necessary\n const childrenArray: (JsxTree | MultiplicationNode)[] = [];\n if (state.visited === null) {\n state.visited = new Set();\n }\n for (let index = 0; index < element.children.length; index++) {\n const helperChild = helperElement[index];\n const result = buildJSXTree({\n node: helperChild.node,\n insideT: true,\n inDerive: true,\n scopeNode,\n helperPath: helperChild,\n config,\n state,\n output,\n });\n // Flatten array results from _T transparency unwrap inside Derive\n if (Array.isArray(result)) {\n childrenArray.push(...result);\n } else {\n childrenArray.push(result);\n }\n }\n if (childrenArray.length) {\n results.props.children = childrenArray;\n }\n return results;\n }\n\n return {\n nodeType: 'element',\n // if componentType is undefined, use typeName\n // Basically, if componentType is not a GT component, use typeName such as <div>\n type: componentType ?? typeName ?? '',\n props,\n };\n }\n\n const children: (JsxTree | MultiplicationNode)[] = element.children\n .flatMap((child, index) => {\n const result = buildJSXTree({\n node: child,\n insideT: true,\n inDerive: inDerive,\n scopeNode,\n helperPath: helperPath.get('children')[index],\n config,\n state,\n output,\n });\n // Flatten array results from _T transparency unwrap inside Derive\n if (Array.isArray(result)) return result;\n return [result];\n })\n .filter(\n (child): child is JsxTree | MultiplicationNode =>\n child !== null && child !== ''\n );\n\n if (children.length === 1) {\n props.children = children[0];\n } else if (children.length > 1) {\n props.children = children;\n }\n\n return {\n nodeType: 'element',\n // if componentType is undefined, use typeName\n // Basically, if componentType is not a GT component, use typeName such as <div>\n type: componentType ?? typeName,\n props,\n };\n }\n // If it's a JSX fragment\n else if (t.isJSXFragment(node)) {\n const children = node.children\n .flatMap((child: JSXChildNode, index: number) => {\n const result = buildJSXTree({\n node: child,\n insideT: true,\n inDerive: inDerive,\n scopeNode,\n helperPath: helperPath.get('children')[index],\n config,\n state,\n output,\n });\n // Flatten array results from _T transparency unwrap inside Derive\n if (Array.isArray(result)) return result;\n return [result];\n })\n .filter(\n (child): child is JsxTree | MultiplicationNode =>\n child !== null && child !== ''\n );\n\n const props: JSXProps = {};\n\n if (children.length === 1) {\n props.children = children[0];\n } else if (children.length > 1) {\n props.children = children;\n }\n\n return {\n nodeType: 'element',\n type: '',\n props,\n };\n }\n // If it's a string literal (standalone)\n else if (t.isStringLiteral(node)) {\n return node.value;\n }\n // If it's a template literal\n else if (t.isTemplateLiteral(node)) {\n // We've already checked that it's derivable, and and added a warning if it's not, this check is just for fallback behavior\n if (\n !isStaticExpression(node, true).isStatic ||\n node.quasis[0].value.cooked === undefined\n ) {\n return generate(node).code;\n }\n return node.quasis[0].value.cooked;\n } else if (t.isNullLiteral(node)) {\n // If it's null, return null\n return null;\n } else if (t.isBooleanLiteral(node)) {\n // If it's a boolean, return the boolean\n return node.value;\n } else if (t.isNumericLiteral(node)) {\n // If it's a number, return the number\n return node.value.toString();\n }\n // Negative\n else if (t.isUnaryExpression(node)) {\n // If it's a unary expression, return the expression\n const staticAnalysis = isStaticExpression(node, true);\n if (staticAnalysis.isStatic && staticAnalysis.value !== undefined) {\n return staticAnalysis.value;\n }\n return generate(node).code;\n } else if (\n (t.isCallExpression(node) && t.isIdentifier(node.callee)) ||\n (t.isAwaitExpression(node) &&\n t.isCallExpression(node.argument) &&\n t.isIdentifier(node.argument.callee))\n ) {\n if (inDerive) {\n const callExpression = (\n node.type === 'AwaitExpression' ? node.argument : node\n ) as t.CallExpression;\n const callee = callExpression.callee as t.Identifier;\n const calleeBinding = scopeNode.scope.getBinding(callee.name);\n if (!calleeBinding) {\n output.warnings.add(\n warnFunctionNotFoundSync(\n config.file,\n callee.name,\n `${callee.loc?.start?.line}:${callee.loc?.start?.column}`\n )\n );\n return null;\n }\n return resolveDeriveFunctionInvocationFromBinding({\n calleeBinding,\n callee,\n config,\n state,\n output,\n });\n } else {\n output.unwrappedExpressions.push(generate(node).code);\n }\n } else if (t.isParenthesizedExpression(node)) {\n const child = node.expression;\n return buildJSXTree({\n node: child,\n insideT,\n inDerive: inDerive,\n scopeNode,\n helperPath: helperPath.get('expression'),\n config,\n state,\n output,\n });\n }\n // If it's some other JS expression\n else if (\n t.isIdentifier(node) ||\n t.isMemberExpression(node) ||\n t.isCallExpression(node) ||\n t.isBinaryExpression(node) ||\n t.isLogicalExpression(node) ||\n t.isConditionalExpression(node)\n ) {\n output.unwrappedExpressions.push(generate(node).code);\n } else {\n if (node === undefined || node === null) {\n output.unwrappedExpressions.push(String(node));\n } else {\n output.unwrappedExpressions.push(generate(node).code);\n }\n }\n return null;\n}\n// end buildJSXTree\n\n// Parses a JSX element and adds it to the updates array\nfunction parseJSXElement({\n node,\n originalName,\n scopeNode,\n updates,\n config,\n state,\n output,\n}: {\n node: t.JSXElement;\n originalName: string;\n scopeNode: NodePath<t.JSXElement>;\n updates: Updates;\n config: ConfigOptions;\n state: StateTracker;\n output: OutputCollector;\n}) {\n const openingElement = node.openingElement;\n const name = openingElement.name;\n\n // Only proceed if it's <T> ...\n // TODO: i don't think this condition is needed anymore\n if (\n !(\n name.type === 'JSXIdentifier' &&\n (originalName === TRANSLATION_COMPONENT ||\n originalName === INTERNAL_TRANSLATION_COMPONENT)\n )\n ) {\n return;\n }\n\n const componentErrors: string[] = [];\n const componentWarnings: Set<string> = new Set();\n const metadata: Metadata = {};\n const relativeFilepath = path.relative(process.cwd(), config.file);\n metadata.filePaths = [relativeFilepath];\n\n // Extract surrounding lines from source file\n const startLine = node.loc?.start?.line;\n const endLine = node.loc?.end?.line;\n if (config.includeSourceCodeContext && startLine && endLine) {\n const entry = extractSourceCode(\n config.file,\n startLine,\n endLine,\n SURROUNDING_LINE_COUNT\n );\n if (entry && relativeFilepath) {\n metadata.sourceCode = { [relativeFilepath]: [entry] };\n }\n }\n\n // We'll track this flag to know if any unwrapped {variable} is found in children\n const unwrappedExpressions: string[] = [];\n\n // Gather <T>'s props\n parseTProps({\n openingElement,\n metadata,\n componentErrors,\n file: config.file,\n });\n\n // Flag for if contains derivable content\n const derivableTracker: DerivableTracker = {\n isDerivable: false,\n };\n\n // Build the JSX tree for this component\n const treeResult = buildJSXTree({\n node,\n scopeNode,\n insideT: false,\n inDerive: config.autoderive ?? false,\n helperPath: scopeNode,\n config,\n state: {\n visited: null,\n callStack: [],\n derivableTracker: derivableTracker,\n importedFunctionsMap: state.importedFunctionsMap,\n },\n output: {\n unwrappedExpressions,\n errors: componentErrors,\n warnings: componentWarnings,\n },\n }) as JsxTree;\n\n // Strip the outer <T> component if necessary\n const jsxTree =\n isElementNode(treeResult) && treeResult.props?.children\n ? // We know this b/c the direct children of <T> will never be a multiplication node\n (treeResult.props.children as JsxTree | JsxTree[])\n : treeResult;\n\n // Update warnings\n if (componentWarnings.size > 0) {\n componentWarnings.forEach((warning) => output.warnings.add(warning));\n }\n\n // Update errors\n if (componentErrors.length > 0) {\n output.errors.push(...componentErrors);\n return;\n }\n\n // Handle whitespace in children\n const whitespaceHandledTree = handleChildrenWhitespace(jsxTree);\n\n // Multiply the tree\n const multipliedTrees = multiplyJsxTree(whitespaceHandledTree);\n\n // Add GT identifiers to the tree\n // TODO: do this in parallel\n const minifiedTress: JsxChildren[] = [];\n for (const multipliedTree of multipliedTrees) {\n // Build set of confirmed GT variable names from importAliases.\n // Only pass when enableAutoJsxInjection is on, to avoid breaking\n // existing behavior where importAliases may be incomplete.\n const gtVariableNames = config.enableAutoJsxInjection\n ? new Set(\n Object.values(config.importAliases).filter(\n (name) =>\n VARIABLE_COMPONENTS.includes(name) &&\n name !== DERIVE_COMPONENT &&\n name !== STATIC_COMPONENT\n )\n )\n : undefined;\n const minifiedTree = addGTIdentifierToSyntaxTree(\n multipliedTree,\n 0,\n gtVariableNames\n );\n minifiedTress.push(\n Array.isArray(minifiedTree) && minifiedTree.length === 1\n ? minifiedTree[0]\n : minifiedTree\n );\n }\n\n // If we found an unwrapped expression, skip\n if (unwrappedExpressions.length > 0) {\n output.errors.push(\n warnHasUnwrappedExpressionSync(\n config.file,\n unwrappedExpressions,\n metadata.id,\n `${node.loc?.start?.line}:${node.loc?.start?.column}`\n )\n );\n return;\n }\n\n // Create a temporary unique flag for derivable content\n const temporaryDeriveId = `derive-temp-id-${randomUUID()}`;\n\n // Resolve derive context variants if present\n let contextVariants: string[] | undefined;\n if (metadata._contextDeriveExpr) {\n const contextExpr = metadata._contextDeriveExpr as t.Expression;\n delete metadata._contextDeriveExpr;\n\n const contextNode = handleDerivation({\n expr: contextExpr,\n tPath: scopeNode,\n file: config.file,\n parsingOptions: config.parsingOptions,\n errors: componentErrors,\n warnings: componentWarnings,\n });\n if (contextNode) {\n contextVariants = nodeToStrings(contextNode);\n }\n }\n\n // <T> is valid here\n for (const minifiedTree of minifiedTress) {\n // Clean the tree by removing null 'c' fields from JsxElements\n const cleanedTree = removeNullChildrenFields(minifiedTree);\n\n if (contextVariants) {\n for (const context of contextVariants) {\n updates.push({\n dataFormat: 'JSX',\n source: cleanedTree,\n metadata: {\n ...structuredClone(metadata),\n context,\n staticId: temporaryDeriveId,\n },\n });\n }\n } else {\n updates.push({\n dataFormat: 'JSX',\n source: cleanedTree,\n metadata: {\n ...structuredClone(metadata),\n ...(derivableTracker.isDerivable && { staticId: temporaryDeriveId }),\n },\n });\n }\n }\n}\n\nfunction resolveDeriveFunctionInvocationFromBinding({\n calleeBinding,\n callee,\n config,\n state,\n output,\n}: {\n calleeBinding: traverseModule.Binding;\n callee: t.Identifier;\n config: ConfigOptions;\n state: StateTracker;\n output: OutputCollector;\n}): MultiplicationNode | null {\n // Stop recursive calls\n type RecursiveGuardCallback = () =>\n | ReturnType<typeof processFunctionDeclarationNodePath>\n | ReturnType<typeof processVariableDeclarationNodePath>\n | ReturnType<typeof processFunctionInFile>;\n function withRecusionGuard({\n cb,\n filename,\n functionName,\n }: {\n cb: RecursiveGuardCallback;\n filename: string;\n functionName: string;\n }) {\n const cacheKey = `${filename}::${functionName}`;\n if (state.callStack.includes(cacheKey)) {\n output.errors.push(\n warnRecursiveFunctionCallSync(config.file, functionName)\n );\n return null;\n }\n state.callStack.push(cacheKey);\n const result = cb();\n state.callStack.pop();\n return result;\n }\n\n // check for recursive calls\n if (calleeBinding.path.isFunctionDeclaration()) {\n // Handle function declarations: function getSubject() { ... }\n const functionName = callee.name;\n const path = calleeBinding.path;\n return withRecusionGuard({\n filename: config.file,\n functionName,\n cb: () =>\n processFunctionDeclarationNodePath({\n config,\n state,\n output,\n path,\n }),\n });\n } else if (\n calleeBinding.path.isVariableDeclarator() &&\n calleeBinding.path.node.init &&\n (t.isArrowFunctionExpression(calleeBinding.path.node.init) ||\n t.isFunctionExpression(calleeBinding.path.node.init))\n ) {\n // Handle arrow functions assigned to variables: const getData = (t) => {...}\n const functionName = callee.name;\n const path = calleeBinding.path;\n return withRecusionGuard({\n filename: config.file,\n functionName,\n cb: () =>\n processVariableDeclarationNodePath({\n config,\n state,\n output,\n functionName,\n path,\n }),\n });\n } else if (state.importedFunctionsMap.has(callee.name)) {\n // Get the original function name\n let originalName: string | undefined;\n if (calleeBinding.path.isImportSpecifier()) {\n originalName = t.isIdentifier(calleeBinding.path.node.imported)\n ? calleeBinding.path.node.imported.name\n : calleeBinding.path.node.imported.value;\n } else if (calleeBinding.path.isImportDefaultSpecifier()) {\n originalName = calleeBinding.path.node.local.name;\n } else if (calleeBinding.path.isImportNamespaceSpecifier()) {\n originalName = calleeBinding.path.node.local.name;\n }\n\n // Function is being imported\n const importPath = state.importedFunctionsMap.get(callee.name)!;\n const filePath = resolveImportPath(\n config.file,\n importPath,\n config.parsingOptions,\n resolveImportPathCache\n );\n if (filePath && originalName) {\n const result = withRecusionGuard({\n filename: filePath,\n functionName: originalName,\n cb: () =>\n processFunctionInFile({\n config,\n state,\n output,\n filePath,\n functionName: originalName,\n }),\n });\n if (result !== null) {\n return result;\n }\n }\n }\n output.warnings.add(\n warnFunctionNotFoundSync(\n config.file,\n callee.name,\n `${callee.loc?.start?.line}:${callee.loc?.start?.column}`\n )\n );\n return null;\n}\n\n/**\n * Searches for a specific user-defined function in a file.\n * This is the resolution logic\n *\n * Handles multiple function declaration patterns:\n * - function getInfo() { ... }\n * - export function getInfo() { ... }\n * - const getInfo = () => { ... }\n *\n * If the function is not found in the file, follows re-exports (export * from './other')\n */\nfunction processFunctionInFile({\n config,\n state,\n output,\n filePath,\n functionName,\n}: {\n config: ConfigOptions;\n state: StateTracker;\n output: OutputCollector;\n filePath: string;\n functionName: string;\n}): MultiplicationNode | null {\n // Create a custom key for the function call\n const cacheKey = `${filePath}::${functionName}`;\n // Check cache first to avoid redundant parsing\n if (processFunctionCache.has(cacheKey)) {\n return processFunctionCache.get(cacheKey) ?? null;\n }\n\n // Prevent infinite loops from circular re-exports\n if (state.visited && state.visited.has(filePath)) {\n return null;\n }\n if (state.visited) {\n state.visited.add(filePath);\n }\n\n let result: MultiplicationNode | null | undefined = undefined;\n try {\n const code = fs.readFileSync(filePath, 'utf8');\n const ast = parse(code, {\n sourceType: 'module',\n plugins: ['jsx', 'typescript'],\n });\n\n const pathsResult = getPathsAndAliases(ast, config.pkgs);\n const importAliases = { ...pathsResult.importAliases };\n // Merge translation component names into importAliases so\n // autoInsertJsxComponents can recognize user T/Var and skip them\n for (const {\n localName,\n originalName,\n } of pathsResult.translationComponentPaths) {\n importAliases[localName] = originalName;\n }\n\n // Auto-inject T/Var into the cross-file AST when enabled,\n // so that Derive extraction sees the same structure as same-file\n if (config.enableAutoJsxInjection) {\n ensureTAndVarImported(ast, importAliases);\n autoInsertJsxComponents(ast, importAliases);\n }\n\n // Collect all imports in this file to track cross-file function calls\n let importedFunctionsMap: Map<string, string> = new Map();\n traverse(ast, {\n Program(path) {\n importedFunctionsMap = buildImportMap(path);\n },\n });\n\n const reExports: string[] = [];\n\n const warnDuplicateFuncDef = (path: NodePath) => {\n output.warnings.add(\n warnDuplicateFunctionDefinitionSync(\n filePath,\n functionName,\n `${path.node.loc?.start?.line}:${path.node.loc?.start?.column}`\n )\n );\n };\n\n traverse(ast, {\n // Handle function declarations: function getInfo() { ... }\n FunctionDeclaration(path) {\n if (path.node.id?.name === functionName) {\n if (result !== undefined) return warnDuplicateFuncDef(path);\n result = processFunctionDeclarationNodePath({\n config: {\n importAliases,\n parsingOptions: config.parsingOptions,\n pkgs: config.pkgs,\n file: filePath,\n enableAutoJsxInjection: config.enableAutoJsxInjection,\n },\n state: {\n ...state,\n importedFunctionsMap,\n },\n output,\n path,\n });\n }\n },\n // Handle variable declarations: const getInfo = () => { ... }\n VariableDeclarator(path) {\n if (\n t.isIdentifier(path.node.id) &&\n path.node.id.name === functionName &&\n path.node.init &&\n (t.isArrowFunctionExpression(path.node.init) ||\n t.isFunctionExpression(path.node.init))\n ) {\n if (result !== undefined) return warnDuplicateFuncDef(path);\n result = processVariableDeclarationNodePath({\n config: {\n importAliases,\n parsingOptions: config.parsingOptions,\n pkgs: config.pkgs,\n file: filePath,\n enableAutoJsxInjection: config.enableAutoJsxInjection,\n },\n state: {\n ...state,\n importedFunctionsMap,\n },\n output,\n functionName,\n path,\n });\n }\n },\n // Collect re-exports: export * from './other'\n ExportAllDeclaration(path) {\n if (t.isStringLiteral(path.node.source)) {\n reExports.push(path.node.source.value);\n }\n },\n // Collect named re-exports: export { foo } from './other'\n ExportNamedDeclaration(path) {\n if (path.node.source && t.isStringLiteral(path.node.source)) {\n // Check if this export includes our function\n const exportsFunction = path.node.specifiers.some((spec) => {\n if (t.isExportSpecifier(spec)) {\n const exportedName = t.isIdentifier(spec.exported)\n ? spec.exported.name\n : spec.exported.value;\n return exportedName === functionName;\n }\n return false;\n });\n if (exportsFunction) {\n reExports.push(path.node.source.value);\n }\n }\n },\n });\n\n // If function not found, follow re-exports\n if (result === undefined && reExports.length > 0) {\n for (const reExportPath of reExports) {\n const resolvedPath = resolveImportPath(\n filePath,\n reExportPath,\n config.parsingOptions,\n resolveImportPathCache\n );\n if (resolvedPath) {\n const foundResult = processFunctionInFile({\n config: {\n importAliases,\n parsingOptions: config.parsingOptions,\n pkgs: config.pkgs,\n file: filePath,\n enableAutoJsxInjection: config.enableAutoJsxInjection,\n },\n state: {\n ...state,\n importedFunctionsMap,\n },\n output,\n filePath: resolvedPath,\n functionName,\n });\n if (foundResult != null) {\n result = foundResult;\n break;\n }\n }\n }\n }\n\n // Mark this function search as processed in the cache\n processFunctionCache.set(cacheKey, result !== undefined ? result : null);\n } catch {\n // Silently skip files that can't be parsed or accessed\n // Still mark as processed to avoid retrying failed parses\n processFunctionCache.set(cacheKey, null);\n }\n return result !== undefined ? result : null;\n}\n\n/**\n * Process a function declaration\n * function getInfo() { ... }\n */\nfunction processFunctionDeclarationNodePath({\n config,\n state,\n output,\n path,\n}: {\n config: ConfigOptions;\n state: StateTracker;\n output: OutputCollector;\n path: NodePath<t.FunctionDeclaration>;\n}): MultiplicationNode | null {\n const result: MultiplicationNode = {\n nodeType: 'multiplication',\n branches: [],\n };\n path.traverse({\n Function(path) {\n path.skip();\n },\n ReturnStatement(returnPath) {\n const returnNodePath = returnPath.get('argument');\n if (!returnNodePath.isExpression()) {\n return;\n }\n const deriveResult = processDeriveExpression({\n config,\n state,\n output,\n expressionNodePath: returnNodePath,\n scopeNode: returnPath,\n });\n if (Array.isArray(deriveResult)) {\n result.branches.push(...deriveResult);\n } else {\n result.branches.push(deriveResult);\n }\n },\n });\n if (result.branches.length === 0) {\n return null;\n }\n return result;\n}\n\n/**\n * Process a variable declaration of a function\n * const getInfo = () => { ... }\n *\n * IMPORTANT: the RHand value must be the function definition, or this will fail\n */\nfunction processVariableDeclarationNodePath({\n config,\n state,\n output,\n functionName,\n path,\n}: {\n config: ConfigOptions;\n state: StateTracker;\n output: OutputCollector;\n functionName: string;\n path: NodePath<t.VariableDeclarator>;\n}): MultiplicationNode | null {\n const result: MultiplicationNode = {\n nodeType: 'multiplication',\n branches: [],\n };\n\n // Enforce the Rhand is a function definition\n const arrowFunctionPath = path.get('init');\n if (!arrowFunctionPath.isArrowFunctionExpression()) {\n output.errors.push(\n warnInvalidDeriveInitSync(\n config.file,\n functionName,\n `${path.node.loc?.start?.line}:${path.node.loc?.start?.column}`\n )\n );\n return null;\n }\n\n const bodyNodePath = arrowFunctionPath.get('body');\n if (bodyNodePath.isExpression()) {\n // process expression return\n const deriveResult = processDeriveExpression({\n config,\n state,\n output,\n expressionNodePath: bodyNodePath,\n scopeNode: arrowFunctionPath,\n });\n if (Array.isArray(deriveResult)) {\n result.branches.push(...deriveResult);\n } else {\n result.branches.push(deriveResult);\n }\n } else {\n // search for a return statement\n bodyNodePath.traverse({\n Function(path) {\n path.skip();\n },\n ReturnStatement(returnPath) {\n const returnNodePath = returnPath.get('argument');\n if (!returnNodePath.isExpression()) {\n return;\n }\n const deriveResult = processDeriveExpression({\n config,\n state,\n output,\n expressionNodePath: returnNodePath,\n scopeNode: returnPath,\n });\n if (Array.isArray(deriveResult)) {\n result.branches.push(...deriveResult);\n } else {\n result.branches.push(deriveResult);\n }\n },\n });\n }\n\n if (result.branches.length === 0) {\n output.errors.push(\n warnMissingReturnSync(\n config.file,\n functionName,\n `${path.node.loc?.start?.line}:${path.node.loc?.start?.column}`\n )\n );\n return null;\n }\n return result;\n}\n\n/**\n * Process a <Derive> expression\n */\nfunction processDeriveExpression({\n config,\n state,\n output,\n expressionNodePath,\n scopeNode,\n}: {\n config: ConfigOptions;\n state: StateTracker;\n output: OutputCollector;\n expressionNodePath: NodePath<t.Expression>;\n scopeNode: NodePath;\n}): JsxTree | MultiplicationNode | (JsxTree | MultiplicationNode)[] {\n // Mark the derivable tracker as true\n state.derivableTracker.isDerivable = true;\n\n // Remove parentheses if they exist\n if (t.isParenthesizedExpression(expressionNodePath.node)) {\n // ex: return (value)\n return processDeriveExpression({\n config,\n state,\n output,\n scopeNode,\n expressionNodePath: expressionNodePath.get('expression'),\n });\n } else if (\n t.isCallExpression(expressionNodePath.node) &&\n t.isIdentifier(expressionNodePath.node.callee)\n ) {\n // ex: return someFunc()\n const callee = expressionNodePath.node.callee;\n const calleeBinding = scopeNode.scope.getBinding(callee.name);\n if (!calleeBinding) {\n output.warnings.add(\n warnFunctionNotFoundSync(\n config.file,\n callee.name,\n `${callee.loc?.start?.line}:${callee.loc?.start?.column}`\n )\n );\n return null;\n }\n // Function is found\n return resolveDeriveFunctionInvocationFromBinding({\n calleeBinding,\n callee,\n config,\n state,\n output,\n });\n } else if (\n t.isAwaitExpression(expressionNodePath.node) &&\n t.isCallExpression(expressionNodePath.node.argument) &&\n t.isIdentifier(expressionNodePath.node.argument.callee)\n ) {\n // ex: return await someFunc()\n const callee = expressionNodePath.node.argument.callee;\n const calleeBinding = scopeNode.scope.getBinding(callee.name);\n if (!calleeBinding) {\n output.warnings.add(\n warnFunctionNotFoundSync(\n config.file,\n callee.name,\n `${callee.loc?.start?.line}:${callee.loc?.start?.column}`\n )\n );\n return null;\n }\n // Function is found\n return resolveDeriveFunctionInvocationFromBinding({\n calleeBinding,\n callee,\n config,\n state,\n output,\n });\n } else if (\n t.isJSXElement(expressionNodePath.node) ||\n t.isJSXFragment(expressionNodePath.node)\n ) {\n // ex: return <div>Jsx content</div>\n return buildJSXTree({\n node: expressionNodePath.node,\n helperPath: expressionNodePath,\n scopeNode,\n insideT: true,\n inDerive: true,\n config,\n state,\n output,\n });\n } else if (t.isConditionalExpression(expressionNodePath.node)) {\n // ex: return condition ? <div>Jsx content</div> : <div>Jsx content</div>\n // since two options here we must construct a new multiplication node\n const consequentNodePath = expressionNodePath.get('consequent');\n const alternateNodePath = expressionNodePath.get('alternate');\n const result: MultiplicationNode = {\n nodeType: 'multiplication' as const,\n branches: [consequentNodePath, alternateNodePath].flatMap(\n (expressionNodePath) => {\n const r = processDeriveExpression({\n config,\n state,\n output,\n scopeNode,\n expressionNodePath,\n });\n return Array.isArray(r) ? r : [r];\n }\n ),\n };\n return result;\n } else if (t.isIdentifier(expressionNodePath.node)) {\n // Resolve variable declarations: const label = cond ? \"boy\" : \"girl\"\n const name = expressionNodePath.node.name;\n const binding = scopeNode.scope.getBinding(name);\n\n if (\n binding &&\n binding.path.isVariableDeclarator() &&\n binding.path.node.init\n ) {\n // Reject destructuring patterns\n if (\n t.isObjectPattern(binding.path.node.id) ||\n t.isArrayPattern(binding.path.node.id)\n ) {\n output.errors.push(\n warnDeriveDestructuringSync(\n config.file,\n name,\n `${expressionNodePath.node.loc?.start?.line}:${expressionNodePath.node.loc?.start?.column}`\n )\n );\n return null;\n }\n\n // Enforce const-only\n const declaration = binding.path.parentPath;\n if (\n declaration?.isVariableDeclaration() &&\n declaration.node.kind !== 'const'\n ) {\n output.warnings.add(\n warnDeriveNonConstVariableSync(\n config.file,\n name,\n declaration.node.kind,\n `${expressionNodePath.node.loc?.start?.line}:${expressionNodePath.node.loc?.start?.column}`\n )\n );\n return null;\n }\n\n // Resolve via parseStringExpression (handles all derivable expression types)\n const errorsBefore = output.errors.length;\n const stringNode = parseStringExpression(\n binding.path.node.init,\n binding.path,\n config.file,\n config.parsingOptions,\n output.warnings,\n output.errors\n );\n if (stringNode) {\n const strings = nodeToStrings(stringNode);\n if (strings.length === 0) {\n return null;\n }\n if (strings.length === 1) {\n return strings[0];\n }\n return {\n nodeType: 'multiplication' as const,\n branches: strings.map((s) => s),\n };\n }\n // parseStringExpression returned null — if it already pushed errors,\n // avoid double-reporting by skipping the buildJSXTree fallthrough.\n if (output.errors.length > errorsBefore) {\n return null;\n }\n }\n\n // Not resolvable — fall through to existing buildJSXTree behavior\n return buildJSXTree({\n node: expressionNodePath.node,\n helperPath: expressionNodePath,\n scopeNode,\n insideT: true,\n inDerive: true,\n config,\n state,\n output,\n });\n } else {\n return buildJSXTree({\n node: expressionNodePath.node,\n helperPath: expressionNodePath,\n scopeNode,\n insideT: true,\n inDerive: true,\n config,\n state,\n output,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,WAAW,eAAe,WAAW;AA0D3C,MAAM,WAAW,eAAe,WAAW;;;;;;AAwE3C,MAAM,yCAAyB,IAAI,KAA4B;;;;;;AAO/D,MAAM,uCAAuB,IAAI,KAAwC;;;;AAKzE,SAAgB,0BAA0B,EACxC,cACA,WACA,MACA,SACA,QACA,UAQC;CAED,MAAM,uBAA4C,eAChD,KAAK,MAAM,kBAAkB,CAAC,KAC/B;CACD,MAAM,iBAAiB,KAAK,MAAM,SAAS,YAAY,kBAAkB,EAAE;AAC3E,MAAK,MAAM,WAAW,gBAAgB;AAEpC,MACE,CA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;EACZ;EACA,SAAS;EACT,UAAU;EACV;EACA;EACA;EACD,CAAC"}
|
|
@@ -1,73 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { isStaticExpression } from "../../evaluateJsx.js";
|
|
2
|
+
import { GT_ATTRIBUTES } from "../constants.js";
|
|
3
|
+
import { warnInvalidMaxCharsSync, warnVariablePropSync } from "../../../../console/index.js";
|
|
4
|
+
import { mapAttributeName } from "../mapAttributeName.js";
|
|
5
|
+
import { isNumberLiteral } from "../isNumberLiteral.js";
|
|
6
|
+
import { containsDeriveCall } from "../stringParsing/derivation/containsDeriveCall.js";
|
|
7
|
+
import * as t from "@babel/types";
|
|
8
|
+
import generateModule from "@babel/generator";
|
|
9
|
+
//#region src/react/jsx/utils/jsxParsing/parseTProps.ts
|
|
4
10
|
const generate = generateModule.default || generateModule;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const code = generate(expr).code;
|
|
28
|
-
// Only check for derivable expressions on id and context and maxChars props
|
|
29
|
-
if (GT_ATTRIBUTES.includes(attrName)) {
|
|
30
|
-
const staticAnalysis = isStaticExpression(expr);
|
|
31
|
-
if (!staticAnalysis.isStatic) {
|
|
32
|
-
if (mapAttributeName(attrName) === 'context' &&
|
|
33
|
-
t.isExpression(expr) &&
|
|
34
|
-
containsDeriveCall(expr)) {
|
|
35
|
-
metadata._contextDeriveExpr = expr;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
componentErrors.push(warnVariablePropSync(file, attrName, code, `${expr.loc?.start?.line}:${expr.loc?.start?.column}`));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
// Use the derived value if available
|
|
42
|
-
if (staticAnalysis.isStatic && staticAnalysis.value !== undefined) {
|
|
43
|
-
// Check for invalid maxChars values
|
|
44
|
-
if (attrName === '$maxChars' || attrName === 'maxChars') {
|
|
45
|
-
if (typeof staticAnalysis.value === 'string' &&
|
|
46
|
-
(isNaN(Number(staticAnalysis.value)) ||
|
|
47
|
-
(t.isExpression(expr) && !isNumberLiteral(expr)) ||
|
|
48
|
-
!Number.isInteger(Number(staticAnalysis.value)))) {
|
|
49
|
-
componentErrors.push(warnInvalidMaxCharsSync(file, code, `${expr.loc?.start?.line}:${expr.loc?.start?.column}`));
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
// Add the maxChars value to the metadata
|
|
53
|
-
metadata[mapAttributeName(attrName)] = Math.abs(Number(staticAnalysis.value));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
// Add the $context or $id or other attributes value to the metadata
|
|
58
|
-
metadata[mapAttributeName(attrName)] = staticAnalysis.value;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
// Only store the code if we couldn't extract a derivable value
|
|
63
|
-
metadata[attrName] = code;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
// For other attributes that aren't id or context
|
|
68
|
-
metadata[attrName] = code;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
});
|
|
11
|
+
function parseTProps({ openingElement, metadata, componentErrors, file }) {
|
|
12
|
+
openingElement.attributes.forEach((attr) => {
|
|
13
|
+
if (!t.isJSXAttribute(attr)) return;
|
|
14
|
+
const attrName = attr.name.name;
|
|
15
|
+
if (typeof attrName !== "string") return;
|
|
16
|
+
if (attr.value) {
|
|
17
|
+
if (t.isStringLiteral(attr.value)) metadata[attrName] = attr.value.value;
|
|
18
|
+
else if (t.isJSXExpressionContainer(attr.value)) {
|
|
19
|
+
const expr = attr.value.expression;
|
|
20
|
+
const code = generate(expr).code;
|
|
21
|
+
if (GT_ATTRIBUTES.includes(attrName)) {
|
|
22
|
+
const staticAnalysis = isStaticExpression(expr);
|
|
23
|
+
if (!staticAnalysis.isStatic) if (mapAttributeName(attrName) === "context" && t.isExpression(expr) && containsDeriveCall(expr)) metadata._contextDeriveExpr = expr;
|
|
24
|
+
else componentErrors.push(warnVariablePropSync(file, attrName, code, `${expr.loc?.start?.line}:${expr.loc?.start?.column}`));
|
|
25
|
+
if (staticAnalysis.isStatic && staticAnalysis.value !== void 0) if (attrName === "$maxChars" || attrName === "maxChars") if (typeof staticAnalysis.value === "string" && (isNaN(Number(staticAnalysis.value)) || t.isExpression(expr) && !isNumberLiteral(expr) || !Number.isInteger(Number(staticAnalysis.value)))) componentErrors.push(warnInvalidMaxCharsSync(file, code, `${expr.loc?.start?.line}:${expr.loc?.start?.column}`));
|
|
26
|
+
else metadata[mapAttributeName(attrName)] = Math.abs(Number(staticAnalysis.value));
|
|
27
|
+
else metadata[mapAttributeName(attrName)] = staticAnalysis.value;
|
|
28
|
+
else metadata[attrName] = code;
|
|
29
|
+
} else metadata[attrName] = code;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
73
33
|
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { parseTProps };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=parseTProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseTProps.js","names":[],"sources":["../../../../../src/react/jsx/utils/jsxParsing/parseTProps.ts"],"sourcesContent":["import { Metadata } from 'generaltranslation/types';\nimport * as t from '@babel/types';\nimport generateModule from '@babel/generator';\n// Handle CommonJS/ESM interop\nconst generate = generateModule.default || generateModule;\n\nimport { GT_ATTRIBUTES } from '../constants.js';\nimport { mapAttributeName } from '../mapAttributeName.js';\nimport { isStaticExpression } from '../../evaluateJsx.js';\nimport {\n warnInvalidMaxCharsSync,\n warnVariablePropSync,\n} from '../../../../console/index.js';\nimport { isNumberLiteral } from '../isNumberLiteral.js';\nimport { containsDeriveCall } from '../stringParsing/derivation/containsDeriveCall.js';\n\n// Parse the props of a <T> component\nexport function parseTProps({\n openingElement,\n metadata,\n componentErrors,\n file,\n}: {\n openingElement: t.JSXOpeningElement;\n metadata: Metadata;\n componentErrors: string[];\n file: string;\n}) {\n openingElement.attributes.forEach((attr) => {\n if (!t.isJSXAttribute(attr)) return;\n const attrName = attr.name.name;\n if (typeof attrName !== 'string') return;\n\n if (attr.value) {\n // If it's a plain string literal like id=\"hello\"\n if (t.isStringLiteral(attr.value)) {\n metadata[attrName] = attr.value.value;\n }\n // If it's an expression container like id={\"hello\"}, id={someVar}, etc.\n else if (t.isJSXExpressionContainer(attr.value)) {\n const expr = attr.value.expression;\n const code = generate(expr).code;\n\n // Only check for derivable expressions on id and context and maxChars props\n if (\n GT_ATTRIBUTES.includes(attrName as (typeof GT_ATTRIBUTES)[number])\n ) {\n const staticAnalysis = isStaticExpression(expr);\n if (!staticAnalysis.isStatic) {\n if (\n mapAttributeName(attrName) === 'context' &&\n t.isExpression(expr) &&\n containsDeriveCall(expr)\n ) {\n metadata._contextDeriveExpr = expr;\n } else {\n componentErrors.push(\n warnVariablePropSync(\n file,\n attrName,\n code,\n `${expr.loc?.start?.line}:${expr.loc?.start?.column}`\n )\n );\n }\n }\n // Use the derived value if available\n if (staticAnalysis.isStatic && staticAnalysis.value !== undefined) {\n // Check for invalid maxChars values\n if (attrName === '$maxChars' || attrName === 'maxChars') {\n if (\n typeof staticAnalysis.value === 'string' &&\n (isNaN(Number(staticAnalysis.value)) ||\n (t.isExpression(expr) && !isNumberLiteral(expr)) ||\n !Number.isInteger(Number(staticAnalysis.value)))\n ) {\n componentErrors.push(\n warnInvalidMaxCharsSync(\n file,\n code,\n `${expr.loc?.start?.line}:${expr.loc?.start?.column}`\n )\n );\n } else {\n // Add the maxChars value to the metadata\n metadata[mapAttributeName(attrName)] = Math.abs(\n Number(staticAnalysis.value)\n );\n }\n } else {\n // Add the $context or $id or other attributes value to the metadata\n metadata[mapAttributeName(attrName)] = staticAnalysis.value;\n }\n } else {\n // Only store the code if we couldn't extract a derivable value\n metadata[attrName] = code;\n }\n } else {\n // For other attributes that aren't id or context\n metadata[attrName] = code;\n }\n }\n }\n });\n}\n"],"mappings":";;;;;;;;;AAIA,MAAM,WAAW,eAAe,WAAW;AAa3C,SAAgB,YAAY,EAC1B,gBACA,UACA,iBACA,QAMC;AACD,gBAAe,WAAW,SAAS,SAAS;AAC1C,MAAI,CAAC,EAAE,eAAe,KAAK,CAAE;EAC7B,MAAM,WAAW,KAAK,KAAK;AAC3B,MAAI,OAAO,aAAa,SAAU;AAElC,MAAI,KAAK;OAEH,EAAE,gBAAgB,KAAK,MAAM,CAC/B,UAAS,YAAY,KAAK,MAAM;YAGzB,EAAE,yBAAyB,KAAK,MAAM,EAAE;IAC/C,MAAM,OAAO,KAAK,MAAM;IACxB,MAAM,OAAO,SAAS,KAAK,CAAC;AAG5B,QACE,cAAc,SAAS,SAA2C,EAClE;KACA,MAAM,iBAAiB,mBAAmB,KAAK;AAC/C,SAAI,CAAC,eAAe,SAClB,KACE,iBAAiB,SAAS,KAAK,aAC/B,EAAE,aAAa,KAAK,IACpB,mBAAmB,KAAK,CAExB,UAAS,qBAAqB;SAE9B,iBAAgB,KACd,qBACE,MACA,UACA,MACA,GAAG,KAAK,KAAK,OAAO,KAAK,GAAG,KAAK,KAAK,OAAO,SAC9C,CACF;AAIL,SAAI,eAAe,YAAY,eAAe,UAAU,KAAA,EAEtD,KAAI,aAAa,eAAe,aAAa,WAC3C,KACE,OAAO,eAAe,UAAU,aAC/B,MAAM,OAAO,eAAe,MAAM,CAAC,IACjC,EAAE,aAAa,KAAK,IAAI,CAAC,gBAAgB,KAAK,IAC/C,CAAC,OAAO,UAAU,OAAO,eAAe,MAAM,CAAC,EAEjD,iBAAgB,KACd,wBACE,MACA,MACA,GAAG,KAAK,KAAK,OAAO,KAAK,GAAG,KAAK,KAAK,OAAO,SAC9C,CACF;SAGD,UAAS,iBAAiB,SAAS,IAAI,KAAK,IAC1C,OAAO,eAAe,MAAM,CAC7B;SAIH,UAAS,iBAAiB,SAAS,IAAI,eAAe;SAIxD,UAAS,YAAY;UAIvB,UAAS,YAAY;;;GAI3B"}
|
|
@@ -1,59 +1,40 @@
|
|
|
1
|
-
import { isVariable } from
|
|
2
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
handleChildren(value),
|
|
37
|
-
]));
|
|
38
|
-
}
|
|
39
|
-
d = {
|
|
40
|
-
...(b != null && { b }),
|
|
41
|
-
...(child.d?.t != null && { t: child.d.t }),
|
|
42
|
-
...Object.fromEntries(Object.entries(child.d)
|
|
43
|
-
.filter(([key, value]) => key !== 'b' && key !== 't' && value != null)
|
|
44
|
-
.map(([key, value]) => [key, value])),
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
// children
|
|
48
|
-
let c;
|
|
49
|
-
if (child && 'c' in child && child.c != null) {
|
|
50
|
-
c = handleChildren(child.c);
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
...(t != null && { t }),
|
|
54
|
-
...(i != null && { i }),
|
|
55
|
-
...(d != null && { d }),
|
|
56
|
-
...(c != null && { c }),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
1
|
+
import { isVariable } from "generaltranslation/internal";
|
|
2
|
+
//#region src/react/jsx/utils/jsxParsing/removeNullChildrenFields.ts
|
|
3
|
+
function removeNullChildrenFields(tree) {
|
|
4
|
+
return handleChildren(tree);
|
|
5
|
+
function handleChildren(children) {
|
|
6
|
+
if (Array.isArray(children)) return children.filter((child) => child != null).map(handleChild);
|
|
7
|
+
return handleChild(children);
|
|
8
|
+
}
|
|
9
|
+
function handleChild(child) {
|
|
10
|
+
if (typeof child === "string") return child;
|
|
11
|
+
if (typeof child !== "object" || child === null) return child;
|
|
12
|
+
if (isVariable(child)) return child;
|
|
13
|
+
let t;
|
|
14
|
+
if (child && "t" in child && child.t != null) t = child.t;
|
|
15
|
+
let i;
|
|
16
|
+
if (child && "i" in child && child.i != null) i = child.i;
|
|
17
|
+
let d;
|
|
18
|
+
if (child && "d" in child && child.d != null) {
|
|
19
|
+
let b;
|
|
20
|
+
if (child.d && "b" in child.d && child.d.b != null) b = Object.fromEntries(Object.entries(child.d.b).map(([key, value]) => [key, handleChildren(value)]));
|
|
21
|
+
d = {
|
|
22
|
+
...b != null && { b },
|
|
23
|
+
...child.d?.t != null && { t: child.d.t },
|
|
24
|
+
...Object.fromEntries(Object.entries(child.d).filter(([key, value]) => key !== "b" && key !== "t" && value != null).map(([key, value]) => [key, value]))
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
let c;
|
|
28
|
+
if (child && "c" in child && child.c != null) c = handleChildren(child.c);
|
|
29
|
+
return {
|
|
30
|
+
...t != null && { t },
|
|
31
|
+
...i != null && { i },
|
|
32
|
+
...d != null && { d },
|
|
33
|
+
...c != null && { c }
|
|
34
|
+
};
|
|
35
|
+
}
|
|
59
36
|
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { removeNullChildrenFields };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=removeNullChildrenFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeNullChildrenFields.js","names":[],"sources":["../../../../../src/react/jsx/utils/jsxParsing/removeNullChildrenFields.ts"],"sourcesContent":["import type {\n GTProp,\n JsxChild,\n JsxChildren,\n} from '@generaltranslation/format/types';\n\nimport { isVariable } from 'generaltranslation/internal';\n\nexport function removeNullChildrenFields(tree: JsxChildren): JsxChildren {\n return handleChildren(tree);\n\n function handleChildren(children: JsxChildren): JsxChildren {\n if (Array.isArray(children)) {\n return children.filter((child) => child != null).map(handleChild);\n }\n return handleChild(children);\n }\n\n function handleChild(child: JsxChild): JsxChild {\n if (typeof child === 'string') {\n return child;\n }\n if (typeof child !== 'object' || child === null) {\n return child;\n }\n if (isVariable(child)) {\n return child;\n }\n // other fields\n let t: string | undefined;\n if (child && 't' in child && child.t != null) {\n t = child.t;\n }\n let i: number | undefined;\n if (child && 'i' in child && child.i != null) {\n i = child.i;\n }\n // gtprop\n let d: GTProp | undefined;\n if (child && 'd' in child && child.d != null) {\n let b: Record<string, JsxChildren> | undefined;\n if (child.d && 'b' in child.d && child.d.b != null) {\n b = Object.fromEntries(\n Object.entries(child.d.b).map(([key, value]) => [\n key,\n handleChildren(value),\n ])\n );\n }\n d = {\n ...(b != null && { b }),\n ...(child.d?.t != null && { t: child.d.t }),\n ...Object.fromEntries(\n Object.entries(child.d)\n .filter(\n ([key, value]) => key !== 'b' && key !== 't' && value != null\n )\n .map(([key, value]) => [key, value])\n ),\n };\n }\n // children\n let c: JsxChildren | undefined;\n if (child && 'c' in child && child.c != null) {\n c = handleChildren(child.c);\n }\n return {\n ...(t != null && { t }),\n ...(i != null && { i }),\n ...(d != null && { d }),\n ...(c != null && { c }),\n };\n }\n}\n"],"mappings":";;AAQA,SAAgB,yBAAyB,MAAgC;AACvE,QAAO,eAAe,KAAK;CAE3B,SAAS,eAAe,UAAoC;AAC1D,MAAI,MAAM,QAAQ,SAAS,CACzB,QAAO,SAAS,QAAQ,UAAU,SAAS,KAAK,CAAC,IAAI,YAAY;AAEnE,SAAO,YAAY,SAAS;;CAG9B,SAAS,YAAY,OAA2B;AAC9C,MAAI,O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
6
|
-
node.nodeType === 'element');
|
|
3
|
+
return typeof node === "object" && node !== null && "nodeType" in node && node.nodeType === "element";
|
|
7
4
|
}
|
|
8
5
|
function isExpressionNode(node) {
|
|
9
|
-
|
|
10
|
-
node !== null &&
|
|
11
|
-
'nodeType' in node &&
|
|
12
|
-
node.nodeType === 'expression');
|
|
6
|
+
return typeof node === "object" && node !== null && "nodeType" in node && node.nodeType === "expression";
|
|
13
7
|
}
|
|
14
8
|
function isMultiplicationNode(node) {
|
|
15
|
-
|
|
16
|
-
node !== null &&
|
|
17
|
-
'nodeType' in node &&
|
|
18
|
-
node.nodeType === 'multiplication');
|
|
9
|
+
return typeof node === "object" && node !== null && "nodeType" in node && node.nodeType === "multiplication";
|
|
19
10
|
}
|
|
20
|
-
export { isElementNode, isExpressionNode, isMultiplicationNode };
|
|
21
|
-
// ----- Helpers ----- //
|
|
22
11
|
function isWhitespaceJsxTree(node) {
|
|
23
|
-
|
|
24
|
-
node !== null &&
|
|
25
|
-
'nodeType' in node &&
|
|
26
|
-
node.nodeType === 'element');
|
|
12
|
+
return typeof node === "object" && node !== null && "nodeType" in node && node.nodeType === "element";
|
|
27
13
|
}
|
|
28
14
|
function isWhitespaceMultiplicationNode(node) {
|
|
29
|
-
|
|
30
|
-
node !== null &&
|
|
31
|
-
'nodeType' in node &&
|
|
32
|
-
node.nodeType === 'multiplication');
|
|
15
|
+
return typeof node === "object" && node !== null && "nodeType" in node && node.nodeType === "multiplication";
|
|
33
16
|
}
|
|
34
|
-
|
|
17
|
+
//#endregion
|
|
18
|
+
export { isElementNode, isExpressionNode, isMultiplicationNode, isWhitespaceJsxTree, isWhitespaceMultiplicationNode };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/react/jsx/utils/jsxParsing/types.ts"],"sourcesContent":["// ===== Tree Construction ===== //\ntype MultiplicationNode = {\n nodeType: 'multiplication';\n branches: (JsxTree | MultiplicationNode)[];\n};\n\ntype ExpressionNode = {\n nodeType: 'expression';\n result: string | number | boolean | MultiplicationNode | null;\n};\n\n// TODO: have some sort of type identifier field here that is Multiplication | Expression | Element\ntype ElementNode = {\n nodeType: 'element';\n type: string;\n props?: {\n children?: JsxTree | MultiplicationNode | (JsxTree | MultiplicationNode)[];\n [key: string]: unknown;\n };\n};\ntype JsxTree = ElementNode | ExpressionNode | string | number | boolean | null;\n\nexport type { MultiplicationNode, ExpressionNode, ElementNode, JsxTree };\n\n// ----- Helpers ----- //\n\nfunction isElementNode(\n node: JsxTree | MultiplicationNode\n): node is ElementNode {\n return (\n typeof node === 'object' &&\n node !== null &&\n 'nodeType' in node &&\n node.nodeType === 'element'\n );\n}\n\nfunction isExpressionNode(\n node: JsxTree | MultiplicationNode\n): node is ExpressionNode {\n return (\n typeof node === 'object' &&\n node !== null &&\n 'nodeType' in node &&\n node.nodeType === 'expression'\n );\n}\n\nfunction isMultiplicationNode(\n node: JsxTree | MultiplicationNode\n): node is MultiplicationNode {\n return (\n typeof node === 'object' &&\n node !== null &&\n 'nodeType' in node &&\n node.nodeType === 'multiplication'\n );\n}\n\nexport { isElementNode, isExpressionNode, isMultiplicationNode };\n\n// ===== Whitespace Handling ===== //\ntype WhitespaceMultiplicationNode = {\n nodeType: 'multiplication';\n branches: (WhitespaceJsxTreeResult | WhitespaceMultiplicationNode)[];\n};\n\ntype WhitespaceJsxTree = {\n nodeType?: 'element';\n type: string;\n props?: {\n children?: (WhitespaceJsxTreeResult | WhitespaceMultiplicationNode)[];\n // Other attributess\n [key: string]: unknown;\n };\n};\ntype WhitespaceJsxTreeResult =\n | WhitespaceJsxTree\n | string\n | number\n | boolean\n | null;\n\nexport type {\n WhitespaceMultiplicationNode,\n WhitespaceJsxTree,\n WhitespaceJsxTreeResult,\n};\n\n// ----- Helpers ----- //\n\nfunction isWhitespaceJsxTree(\n node: WhitespaceJsxTreeResult | WhitespaceMultiplicationNode\n): node is WhitespaceJsxTree {\n return (\n typeof node === 'object' &&\n node !== null &&\n 'nodeType' in node &&\n node.nodeType === 'element'\n );\n}\n\nfunction isWhitespaceMultiplicationNode(\n node: WhitespaceJsxTreeResult | WhitespaceMultiplicationNode\n): node is WhitespaceMultiplicationNode {\n return (\n typeof node === 'object' &&\n node !== null &&\n 'nodeType' in node &&\n node.nodeType === 'multiplication'\n );\n}\n\nexport { isWhitespaceJsxTree, isWhitespaceMultiplicationNode };\n\n// ===== Multiplied Tree ===== //\n\n// No multiplication nodes\ntype MultipliedTree = {\n nodeType?: 'element';\n type: string;\n props?: {\n children?: MultipliedTreeNode;\n };\n};\ntype MultipliedTreeNode = MultipliedTree | string | number | boolean | null;\n\nexport type { MultipliedTree, MultipliedTreeNode };\n"],"mappings":";AA0BA,SAAS,cACP,MACqB;AACrB,QACE,OAAO,SAAS,YAChB,SAAS,QACT,cAAc,QACd,KAAK,aAAa;;AAItB,SAAS,iBACP,MACwB;AACxB,QACE,OAAO,SAAS,YAChB,SAAS,QACT,cAAc,QACd,KAAK,aAAa;;AAItB,SAAS,qBACP,MAC4B;AAC5B,QACE,OAAO,SAAS,YAChB,SAAS,QACT,cAAc,QACd,KAAK,aAAa;;AAoCtB,SAAS,oBACP,MAC2B;AAC3B,QACE,OAAO,SAAS,YAChB,SAAS,QACT,cAAc,QACd,KAAK,aAAa;;AAItB,SAAS,+BACP,MACsC;AACtC,QACE,OAAO,SAAS,YAChB,SAAS,QACT,cAAc,QACd,KAAK,aAAa"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return 'format';
|
|
11
|
-
default:
|
|
12
|
-
return attrName;
|
|
13
|
-
}
|
|
1
|
+
//#region src/react/jsx/utils/mapAttributeName.ts
|
|
2
|
+
function mapAttributeName(attrName) {
|
|
3
|
+
switch (attrName) {
|
|
4
|
+
case "$id": return "id";
|
|
5
|
+
case "$context": return "context";
|
|
6
|
+
case "$maxChars": return "maxChars";
|
|
7
|
+
case "$format": return "format";
|
|
8
|
+
default: return attrName;
|
|
9
|
+
}
|
|
14
10
|
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { mapAttributeName };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=mapAttributeName.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapAttributeName.js","names":[],"sources":["../../../../src/react/jsx/utils/mapAttributeName.ts"],"sourcesContent":["/**\n * Type logic implementation\n */\ntype MapAttributeName<T extends string> = T extends '$id'\n ? 'id'\n : T extends '$context'\n ? 'context'\n : T extends '$maxChars'\n ? 'maxChars'\n : T extends '$format'\n ? 'format'\n : T;\n\n/**\n * Map the attribute name to the corresponding attribute name in the metadata\n * @param attrName - The attribute name to map\n * @returns The mapped attribute name\n */\nexport function mapAttributeName<T extends string>(\n attrName: T\n): MapAttributeName<T>;\nexport function mapAttributeName(attrName: string): string {\n switch (attrName) {\n case '$id':\n return 'id';\n case '$context':\n return 'context';\n case '$maxChars':\n return 'maxChars';\n case '$format':\n return 'format';\n default:\n return attrName;\n }\n}\n"],"mappings":";AAqBA,SAAgB,iBAAiB,UAA0B;AACzD,SAAQ,UAAR;EACE,KAAK,MACH,QAAO;EACT,KAAK,WACH,QAAO;EACT,KAAK,YACH,QAAO;EACT,KAAK,UACH,QAAO;EACT,QACE,QAAO"}
|