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
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
import
|
|
2
|
-
import path from
|
|
3
|
-
import
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
1
|
+
import { displayResolvedPaths } from "../../console/logging.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
//#region src/react/config/createESBuildConfig.ts
|
|
5
|
+
function createESBuildConfig(config = {}) {
|
|
6
|
+
const esbuildOptions = {
|
|
7
|
+
bundle: true,
|
|
8
|
+
format: "cjs",
|
|
9
|
+
platform: "node",
|
|
10
|
+
target: "es2021",
|
|
11
|
+
loader: {
|
|
12
|
+
".js": "jsx",
|
|
13
|
+
".ts": "ts",
|
|
14
|
+
".css": "css"
|
|
15
|
+
},
|
|
16
|
+
sourcemap: "inline",
|
|
17
|
+
external: ["server-only"],
|
|
18
|
+
define: { React: "global.React" },
|
|
19
|
+
plugins: []
|
|
20
|
+
};
|
|
21
|
+
esbuildOptions.plugins?.push({
|
|
22
|
+
name: "ignore-server-only",
|
|
23
|
+
setup(build) {
|
|
24
|
+
build.onResolve({ filter: /^server-only$/ }, () => {
|
|
25
|
+
return {
|
|
26
|
+
path: "server-only",
|
|
27
|
+
namespace: "ignore-server-only"
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
build.onLoad({
|
|
31
|
+
filter: /^server-only$/,
|
|
32
|
+
namespace: "ignore-server-only"
|
|
33
|
+
}, () => {
|
|
34
|
+
return {
|
|
35
|
+
contents: "module.exports = {};",
|
|
36
|
+
loader: "js"
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
esbuildOptions.plugins?.push({
|
|
42
|
+
name: "css-module",
|
|
43
|
+
setup(build) {
|
|
44
|
+
build.onResolve({ filter: /\.css$/ }, (args) => {
|
|
45
|
+
return {
|
|
46
|
+
path: path.resolve(args.resolveDir, args.path),
|
|
47
|
+
namespace: "css-module"
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
build.onLoad({
|
|
51
|
+
filter: /\.css$/,
|
|
52
|
+
namespace: "css-module"
|
|
53
|
+
}, async (args) => {
|
|
54
|
+
const css = await fs.promises.readFile(args.path, "utf8");
|
|
55
|
+
return {
|
|
56
|
+
contents: `
|
|
53
57
|
const style = document.createElement('style');
|
|
54
58
|
style.textContent = ${JSON.stringify(css)};
|
|
55
59
|
document.head.appendChild(style);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return esbuildOptions;
|
|
60
|
+
`,
|
|
61
|
+
loader: "js"
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
if (config.compilerOptions) {
|
|
67
|
+
if (config.compilerOptions.paths) {
|
|
68
|
+
const aliases = {};
|
|
69
|
+
const resolvedPaths = [];
|
|
70
|
+
for (const [key, value] of Object.entries(config.compilerOptions.paths)) if (Array.isArray(value) && typeof value[0] === "string") {
|
|
71
|
+
const resolvedPath = path.resolve(process.cwd(), value[0].replace("/*", ""));
|
|
72
|
+
aliases[key.replace("/*", "")] = resolvedPath;
|
|
73
|
+
resolvedPaths.push([key, resolvedPath]);
|
|
74
|
+
}
|
|
75
|
+
if (resolvedPaths.length) displayResolvedPaths(resolvedPaths);
|
|
76
|
+
esbuildOptions.plugins = esbuildOptions.plugins || [];
|
|
77
|
+
esbuildOptions.plugins.push({
|
|
78
|
+
name: "alias",
|
|
79
|
+
setup(build) {
|
|
80
|
+
build.onResolve({ filter: /.*/ }, (args) => {
|
|
81
|
+
for (const [aliasKey, aliasPath] of Object.entries(aliases)) if (args.path.startsWith(`${aliasKey}/`)) {
|
|
82
|
+
const resolvedPath = path.resolve(aliasPath, args.path.slice(aliasKey.length + 1));
|
|
83
|
+
const extensions = [
|
|
84
|
+
".js",
|
|
85
|
+
".ts",
|
|
86
|
+
".css"
|
|
87
|
+
];
|
|
88
|
+
function resolveWithExtensions(basePath) {
|
|
89
|
+
for (const ext of extensions) {
|
|
90
|
+
const fullPath = `${basePath}${ext}`;
|
|
91
|
+
try {
|
|
92
|
+
return fs.realpathSync(fullPath);
|
|
93
|
+
} catch {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
return { path: fs.realpathSync(resolvedPath) };
|
|
101
|
+
} catch {
|
|
102
|
+
if (!extensions.some((ext) => resolvedPath.endsWith(ext))) {
|
|
103
|
+
const resolvedWithExt = resolveWithExtensions(resolvedPath);
|
|
104
|
+
if (resolvedWithExt) return { path: resolvedWithExt };
|
|
105
|
+
}
|
|
106
|
+
throw new Error(`Unable to resolve path: ${resolvedPath}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return esbuildOptions;
|
|
119
115
|
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { createESBuildConfig as default };
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=createESBuildConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createESBuildConfig.js","names":[],"sources":["../../../src/react/config/createESBuildConfig.ts"],"sourcesContent":["import esbuild from 'esbuild';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { displayResolvedPaths } from '../../console/logging.js';\n\ntype TSConfig = {\n compilerOptions?: {\n paths?: Record<string, string[]>;\n };\n};\n\nexport default function createESBuildConfig(config: TSConfig = {}) {\n const esbuildOptions: esbuild.BuildOptions = {\n bundle: true,\n format: 'cjs',\n platform: 'node',\n target: 'es2021',\n loader: {\n '.js': 'jsx',\n '.ts': 'ts',\n '.css': 'css', // Add CSS loader\n },\n sourcemap: 'inline',\n external: ['server-only'],\n define: {\n React: 'global.React',\n },\n plugins: [],\n };\n\n // Add the custom plugin to handle 'server-only' imports\n esbuildOptions.plugins?.push({\n name: 'ignore-server-only',\n setup(build: esbuild.PluginBuild) {\n build.onResolve({ filter: /^server-only$/ }, () => {\n return {\n path: 'server-only',\n namespace: 'ignore-server-only',\n };\n });\n\n build.onLoad(\n { filter: /^server-only$/, namespace: 'ignore-server-only' },\n () => {\n return {\n contents: 'module.exports = {};',\n loader: 'js',\n };\n }\n );\n },\n });\n\n // Add a plugin to handle CSS imports\n esbuildOptions.plugins?.push({\n name: 'css-module',\n setup(build: esbuild.PluginBuild) {\n build.onResolve({ filter: /\\.css$/ }, (args: esbuild.OnResolveArgs) => {\n return {\n path: path.resolve(args.resolveDir, args.path),\n namespace: 'css-module',\n };\n });\n\n build.onLoad(\n { filter: /\\.css$/, namespace: 'css-module' },\n async (args: esbuild.OnLoadArgs) => {\n const css = await fs.promises.readFile(args.path, 'utf8');\n const contents = `\n const style = document.createElement('style');\n style.textContent = ${JSON.stringify(css)};\n document.head.appendChild(style);\n `;\n return { contents, loader: 'js' };\n }\n );\n },\n });\n\n if (config.compilerOptions) {\n if (config.compilerOptions.paths) {\n const aliases: Record<string, string> = {};\n\n const resolvedPaths: [string, string][] = [];\n for (const [key, value] of Object.entries(config.compilerOptions.paths)) {\n if (Array.isArray(value) && typeof value[0] === 'string') {\n const resolvedPath = path.resolve(\n process.cwd(),\n value[0].replace('/*', '')\n );\n aliases[key.replace('/*', '')] = resolvedPath;\n resolvedPaths.push([key, resolvedPath]);\n }\n }\n if (resolvedPaths.length) {\n displayResolvedPaths(resolvedPaths);\n }\n\n esbuildOptions.plugins = esbuildOptions.plugins || [];\n\n esbuildOptions.plugins.push({\n name: 'alias',\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n for (const [aliasKey, aliasPath] of Object.entries(aliases)) {\n if (args.path.startsWith(`${aliasKey}/`)) {\n const resolvedPath = path.resolve(\n aliasPath as string,\n args.path.slice(aliasKey.length + 1)\n );\n\n const extensions = ['.js', '.ts', '.css']; // Add .css to extensions\n\n function resolveWithExtensions(\n basePath: string\n ): string | null {\n for (const ext of extensions) {\n const fullPath = `${basePath}${ext}`;\n try {\n const realPath = fs.realpathSync(fullPath);\n return realPath;\n } catch {\n continue;\n }\n }\n return null;\n }\n\n try {\n const realPath = fs.realpathSync(resolvedPath);\n return { path: realPath };\n } catch {\n const hasExtension = extensions.some((ext) =>\n resolvedPath.endsWith(ext)\n );\n if (!hasExtension) {\n const resolvedWithExt = resolveWithExtensions(resolvedPath);\n if (resolvedWithExt) {\n return { path: resolvedWithExt };\n }\n }\n\n throw new Error(`Unable to resolve path: ${resolvedPath}`);\n }\n }\n }\n });\n },\n });\n }\n }\n\n return esbuildOptions;\n}\n"],"mappings":";;;;AAWA,SAAwB,oBAAoB,SAAmB,EAAE,EAAE;CACjE,MAAM,iBAAuC;EAC3C,QAAQ;EACR,QAAQ;EACR,UAAU;EACV,QAAQ;EACR,QAAQ;GACN,OAAO;GACP,OAAO;GACP,QAAQ;GACT;EACD,WAAW;EACX,UAAU,CAAC,cAAc;EACzB,QAAQ,EACN,OAAO,gBACR;EACD,SAAS,EAAE;EACZ;AAGD,gBAAe,SAAS,KAAK;EAC3B,MAAM;EACN,MAAM,OAA4B;AAChC,SAAM,UAAU,EAAE,QAAQ,iBAAiB,QAAQ;AACjD,WAAO;KACL,MAAM;KACN,WAAW;KACZ;KACD;AAEF,SAAM,OACJ;IAAE,QAAQ;IAAiB,WAAW;IAAsB,QACtD;AACJ,WAAO;KACL,UAAU;KACV,QAAQ;KACT;KAEJ;;EAEJ,CAAC;AAGF,gBAAe,SAAS,KAAK;EAC3B,MAAM;EACN,MAAM,OAA4B;AAChC,SAAM,UAAU,EAAE,QAAQ,UAAU,GAAG,SAAgC;AACrE,WAAO;KACL,MAAM,KAAK,QAAQ,KAAK,YAAY,KAAK,KAAK;KAC9C,WAAW;KACZ;KACD;AAEF,SAAM,OACJ;IAAE,QAAQ;IAAU,WAAW;IAAc,EAC7C,OAAO,SAA6B;IAClC,MAAM,MAAM,MAAM,GAAG,SAAS,SAAS,KAAK,MAAM,OAAO;AAMzD,WAAO;KAAE,UAAA;;0CAHuB,KAAK,UAAU,IAAI,CAAC;;;KAGjC,QAAQ;KAAM;KAEpC;;EAEJ,CAAC;AAEF,KAAI,OAAO;MACL,OAAO,gBAAgB,OAAO;GAChC,MAAM,UAAkC,EAAE;GAE1C,MAAM,gBAAoC,EAAE;AAC5C,QAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,gBAAgB,MAAM,CACrE,KAAI,MAAM,QAAQ,MAAM,IAAI,OAAO,MAAM,OAAO,UAAU;IACxD,MAAM,eAAe,KAAK,QACxB,QAAQ,KAAK,EACb,MAAM,GAAG,QAAQ,MAAM,GAAG,CAC3B;AACD,YAAQ,IAAI,QAAQ,MAAM,GAAG,IAAI;AACjC,kBAAc,KAAK,CAAC,KAAK,aAAa,CAAC;;AAG3C,OAAI,cAAc,OAChB,sBAAqB,cAAc;AAGrC,kBAAe,UAAU,eAAe,WAAW,EAAE;AAErD,kBAAe,QAAQ,KAAK;IAC1B,MAAM;IACN,MAAM,OAAO;AACX,WAAM,UAAU,EAAE,QAAQ,MAAM,GAAG,SAAS;AAC1C,WAAK,MAAM,CAAC,UAAU,cAAc,OAAO,QAAQ,QAAQ,CACzD,KAAI,KAAK,KAAK,WAAW,GAAG,SAAS,GAAG,EAAE;OACxC,MAAM,eAAe,KAAK,QACxB,WACA,KAAK,KAAK,MAAM,SAAS,SAAS,EAAE,CACrC;OAED,MAAM,aAAa;QAAC;QAAO;QAAO;QAAO;OAEzC,SAAS,sBACP,UACe;AACf,aAAK,MAAM,OAAO,YAAY;SAC5B,MAAM,WAAW,GAAG,WAAW;AAC/B,aAAI;AAEF,iBADiB,GAAG,aAAa,SAClB;iBACT;AACN;;;AAGJ,eAAO;;AAGT,WAAI;AAEF,eAAO,EAAE,MADQ,GAAG,aAAa,aACV,EAAE;eACnB;AAIN,YAAI,CAHiB,WAAW,MAAM,QACpC,aAAa,SAAS,IAAI,CAEX,EAAE;SACjB,MAAM,kBAAkB,sBAAsB,aAAa;AAC3D,aAAI,gBACF,QAAO,EAAE,MAAM,iBAAiB;;AAIpC,cAAM,IAAI,MAAM,2BAA2B,eAAe;;;OAIhE;;IAEL,CAAC;;;AAIN,QAAO"}
|
|
@@ -1,133 +1,99 @@
|
|
|
1
|
-
import * as t from
|
|
2
|
-
import { parse } from
|
|
1
|
+
import * as t from "@babel/types";
|
|
2
|
+
import { parse } from "@formatjs/icu-messageformat-parser";
|
|
3
|
+
//#region src/react/jsx/evaluateJsx.ts
|
|
3
4
|
const MEANINGFUL_REGEX = /[\p{L}\p{N}]/u;
|
|
4
5
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return MEANINGFUL_REGEX.test(value.value);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (t.isBinaryExpression(node)) {
|
|
24
|
-
if (node.operator === '+') {
|
|
25
|
-
return isMeaningful(node.left) || isMeaningful(node.right);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
6
|
+
* Checks if a node is meaningful. Does not recurse into children.
|
|
7
|
+
* @param node - The node to check
|
|
8
|
+
* @returns Whether the node is meaningful
|
|
9
|
+
*/
|
|
10
|
+
function isMeaningful(node) {
|
|
11
|
+
if (t.isStringLiteral(node) || t.isJSXText(node)) return MEANINGFUL_REGEX.test(node.value);
|
|
12
|
+
if (t.isTemplateLiteral(node) && node.expressions.length === 0) return MEANINGFUL_REGEX.test(node.quasis[0].value.raw);
|
|
13
|
+
if (t.isJSXExpressionContainer(node)) {
|
|
14
|
+
const value = isStaticExpression(node.expression);
|
|
15
|
+
if (value.isStatic && value.value) return MEANINGFUL_REGEX.test(value.value);
|
|
16
|
+
}
|
|
17
|
+
if (t.isBinaryExpression(node)) {
|
|
18
|
+
if (node.operator === "+") return isMeaningful(node.left) || isMeaningful(node.right);
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
29
21
|
}
|
|
30
22
|
/**
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
else {
|
|
77
|
-
value = operator + expr.argument.value.toString();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
// invalid
|
|
82
|
-
return { isStatic: false };
|
|
83
|
-
}
|
|
84
|
-
return { isStatic: true, value };
|
|
85
|
-
}
|
|
86
|
-
// Handle boolean literals by converting them to strings
|
|
87
|
-
if (t.isBooleanLiteral(expr)) {
|
|
88
|
-
return {
|
|
89
|
-
isStatic: true,
|
|
90
|
-
value: jsxStatic ? expr.value : String(expr.value),
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
// Handle null literal
|
|
94
|
-
if (t.isNullLiteral(expr)) {
|
|
95
|
-
return { isStatic: true, value: jsxStatic ? null : 'null' };
|
|
96
|
-
}
|
|
97
|
-
// Not a derivable expression
|
|
98
|
-
return { isStatic: false };
|
|
23
|
+
* Checks if an expression is a static expression (does not contain any variables which could change at runtime).
|
|
24
|
+
* @param expr - The expression to check
|
|
25
|
+
* @param jsxStatic - Whether to return JSX-compatible values (boolean, null) in addition to strings
|
|
26
|
+
* @returns An object containing the result of the static check
|
|
27
|
+
*/
|
|
28
|
+
function isStaticExpression(expr, jsxStatic = false) {
|
|
29
|
+
if (t.isJSXEmptyExpression(expr)) return {
|
|
30
|
+
isStatic: true,
|
|
31
|
+
value: ""
|
|
32
|
+
};
|
|
33
|
+
if (t.isStringLiteral(expr)) return {
|
|
34
|
+
isStatic: true,
|
|
35
|
+
value: expr.value
|
|
36
|
+
};
|
|
37
|
+
if (t.isTemplateLiteral(expr) && expr.expressions.length === 0) return {
|
|
38
|
+
isStatic: true,
|
|
39
|
+
value: jsxStatic ? expr.quasis[0].value.cooked : expr.quasis[0].value.raw
|
|
40
|
+
};
|
|
41
|
+
if (t.isBinaryExpression(expr)) return { isStatic: false };
|
|
42
|
+
if (t.isParenthesizedExpression(expr)) return isStaticExpression(expr.expression, jsxStatic);
|
|
43
|
+
if (t.isNumericLiteral(expr)) return {
|
|
44
|
+
isStatic: true,
|
|
45
|
+
value: String(expr.value)
|
|
46
|
+
};
|
|
47
|
+
if (t.isUnaryExpression(expr)) {
|
|
48
|
+
let value;
|
|
49
|
+
let operator = "";
|
|
50
|
+
if (expr.operator === "-") operator = expr.operator;
|
|
51
|
+
if (t.isNumericLiteral(expr.argument)) if (expr.argument.value === 0) value = "0";
|
|
52
|
+
else value = operator + expr.argument.value.toString();
|
|
53
|
+
else return { isStatic: false };
|
|
54
|
+
return {
|
|
55
|
+
isStatic: true,
|
|
56
|
+
value
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (t.isBooleanLiteral(expr)) return {
|
|
60
|
+
isStatic: true,
|
|
61
|
+
value: jsxStatic ? expr.value : String(expr.value)
|
|
62
|
+
};
|
|
63
|
+
if (t.isNullLiteral(expr)) return {
|
|
64
|
+
isStatic: true,
|
|
65
|
+
value: jsxStatic ? null : "null"
|
|
66
|
+
};
|
|
67
|
+
return { isStatic: false };
|
|
99
68
|
}
|
|
100
69
|
/**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
if (t.isTemplateLiteral(expr)) {
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
return false;
|
|
70
|
+
* Checks if an expression is a static value (a string, number, or template literal).
|
|
71
|
+
* @param expr - The expression to check
|
|
72
|
+
* @returns Whether the expression is a static value
|
|
73
|
+
*/
|
|
74
|
+
function isStaticValue(expr) {
|
|
75
|
+
if (t.isStringLiteral(expr)) return true;
|
|
76
|
+
if (t.isNumericLiteral(expr)) return true;
|
|
77
|
+
if (t.isTemplateLiteral(expr)) return true;
|
|
78
|
+
return false;
|
|
116
79
|
}
|
|
117
80
|
/**
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return { isValid: true };
|
|
81
|
+
* Checks if a string is a valid ICU message format.
|
|
82
|
+
* @param string - The string to check
|
|
83
|
+
* @returns Whether the string is a valid ICU message format
|
|
84
|
+
*/
|
|
85
|
+
function isValidIcu(string) {
|
|
86
|
+
try {
|
|
87
|
+
parse(string);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
return {
|
|
90
|
+
isValid: false,
|
|
91
|
+
error: error instanceof Error ? error.message : String(error)
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return { isValid: true };
|
|
133
95
|
}
|
|
96
|
+
//#endregion
|
|
97
|
+
export { isMeaningful, isStaticExpression, isStaticValue, isValidIcu };
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=evaluateJsx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluateJsx.js","names":[],"sources":["../../../src/react/jsx/evaluateJsx.ts"],"sourcesContent":["import * as t from '@babel/types';\nimport { parse } from '@formatjs/icu-messageformat-parser';\n\nconst MEANINGFUL_REGEX = /[\\p{L}\\p{N}]/u;\n\n/**\n * Checks if a node is meaningful. Does not recurse into children.\n * @param node - The node to check\n * @returns Whether the node is meaningful\n */\nexport function isMeaningful(node: t.Node): boolean {\n if (t.isStringLiteral(node) || t.isJSXText(node)) {\n return MEANINGFUL_REGEX.test(node.value);\n }\n // Handle template literals without expressions\n if (t.isTemplateLiteral(node) && node.expressions.length === 0) {\n return MEANINGFUL_REGEX.test(node.quasis[0].value.raw);\n }\n if (t.isJSXExpressionContainer(node)) {\n const value = isStaticExpression(node.expression);\n if (value.isStatic && value.value) {\n return MEANINGFUL_REGEX.test(value.value);\n }\n }\n if (t.isBinaryExpression(node)) {\n if (node.operator === '+') {\n return isMeaningful(node.left) || isMeaningful(node.right);\n }\n }\n return false;\n}\n\nexport function isStaticExpression(\n expr: t.Expression | t.JSXEmptyExpression,\n jsxStatic?: false\n): {\n isStatic: boolean;\n value?: string;\n};\nexport function isStaticExpression(\n expr: t.Expression | t.JSXEmptyExpression,\n jsxStatic?: true\n): {\n isStatic: boolean;\n value?: string | boolean | null;\n};\nexport function isStaticExpression(\n expr: t.Expression | t.JSXEmptyExpression,\n jsxStatic?: boolean\n): {\n isStatic: boolean;\n value?: string | boolean | null;\n};\n/**\n * Checks if an expression is a static expression (does not contain any variables which could change at runtime).\n * @param expr - The expression to check\n * @param jsxStatic - Whether to return JSX-compatible values (boolean, null) in addition to strings\n * @returns An object containing the result of the static check\n */\nexport function isStaticExpression(\n expr: t.Expression | t.JSXEmptyExpression,\n jsxStatic = false\n): {\n isStatic: boolean;\n value?: string | boolean | null;\n} {\n // Handle empty expressions\n if (t.isJSXEmptyExpression(expr)) {\n return { isStatic: true, value: '' };\n }\n\n // Handle direct string literals\n if (t.isStringLiteral(expr)) {\n return { isStatic: true, value: expr.value };\n }\n\n // Handle template literals without expressions\n if (t.isTemplateLiteral(expr) && expr.expressions.length === 0) {\n return {\n isStatic: true,\n value: jsxStatic ? expr.quasis[0].value.cooked : expr.quasis[0].value.raw,\n };\n }\n\n // Binary expressions are not derivable\n if (t.isBinaryExpression(expr)) {\n // Not a derivable expression\n return { isStatic: false };\n }\n\n // Handle parenthesized expressions\n if (t.isParenthesizedExpression(expr)) {\n return isStaticExpression(expr.expression, jsxStatic);\n }\n\n // Handle numeric literals by converting them to strings\n if (t.isNumericLiteral(expr)) {\n return { isStatic: true, value: String(expr.value) };\n }\n\n // Handle unary expressions by converting them to strings\n if (t.isUnaryExpression(expr)) {\n let value: string;\n let operator = '';\n if (expr.operator === '-') {\n operator = expr.operator;\n }\n if (t.isNumericLiteral(expr.argument)) {\n if (expr.argument.value === 0) {\n value = '0';\n } else {\n value = operator + expr.argument.value.toString();\n }\n } else {\n // invalid\n return { isStatic: false };\n }\n\n return { isStatic: true, value };\n }\n\n // Handle boolean literals by converting them to strings\n if (t.isBooleanLiteral(expr)) {\n return {\n isStatic: true,\n value: jsxStatic ? expr.value : String(expr.value),\n };\n }\n\n // Handle null literal\n if (t.isNullLiteral(expr)) {\n return { isStatic: true, value: jsxStatic ? null : 'null' };\n }\n\n // Not a derivable expression\n return { isStatic: false };\n}\n\n/**\n * Checks if an expression is a static value (a string, number, or template literal).\n * @param expr - The expression to check\n * @returns Whether the expression is a static value\n */\nexport function isStaticValue(\n expr: t.Expression | t.JSXEmptyExpression\n): boolean {\n if (t.isStringLiteral(expr)) {\n return true;\n }\n if (t.isNumericLiteral(expr)) {\n return true;\n }\n if (t.isTemplateLiteral(expr)) {\n return true;\n }\n return false;\n}\n\n/**\n * Checks if a string is a valid ICU message format.\n * @param string - The string to check\n * @returns Whether the string is a valid ICU message format\n */\nexport function isValidIcu(string: string): {\n isValid: boolean;\n error?: string;\n} {\n try {\n parse(string);\n } catch (error) {\n return {\n isValid: false,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n return { isValid: true };\n}\n"],"mappings":";;;AAGA,MAAM,mBAAmB;;;;;;AAOzB,SAAgB,aAAa,MAAuB;AAClD,KAAI,EAAE,gBAAgB,KAAK,IAAI,EAAE,UAAU,KAAK,CAC9C,QAAO,iBAAiB,KAAK,KAAK,MAAM;AAG1C,KAAI,EAAE,kBAAkB,KAAK,IAAI,KAAK,YAAY,WAAW,EAC3D,QAAO,iBAAiB,KAAK,KAAK,OAAO,GAAG,MAAM,IAAI;AAExD,KAAI,EAAE,yBAAyB,KAAK,EAAE;EACpC,MAAM,QAAQ,mBAAmB,KAAK,WAAW;AACjD,MAAI,MAAM,YAAY,MAAM,MAC1B,QAAO,iBAAiB,KAAK,MAAM,MAAM;;AAG7C,KAAI,EAAE,mBAAmB,KAAK;MACxB,KAAK,aAAa,IACpB,QAAO,aAAa,KAAK,KAAK,IAAI,aAAa,KAAK,MAAM;;AAG9D,QAAO;;;;;;;;AA8BT,SAAgB,mBACd,MACA,YAAY,OAIZ;AAEA,KAAI,EAAE,qBAAqB,KAAK,CAC9B,QAAO;EAAE,UAAU;EAAM,OAAO;EAAI;AAItC,KAAI,EAAE,gBAAgB,KAAK,CACzB,QAAO;EAAE,UAAU;EAAM,OAAO,KAAK;EAAO;AAI9C,KAAI,EAAE,kBAAkB,KAAK,IAAI,KAAK,YAAY,WAAW,EAC3D,QAAO;EACL,UAAU;EACV,OAAO,YAAY,KAAK,OAAO,GAAG,MAAM,SAAS,KAAK,OAAO,GAAG,MAAM;EACvE;AAIH,KAAI,EAAE,mBAAmB,KAAK,CAE5B,QAAO,EAAE,UAAU,OAAO;AAI5B,KAAI,EAAE,0BAA0B,KAAK,CACnC,QAAO,mBAAmB,KAAK,YAAY,UAAU;AAIvD,KAAI,EAAE,iBAAiB,KAAK,CAC1B,QAAO;EAAE,UAAU;EAAM,OAAO,OAAO,KAAK,MAAM;EAAE;AAItD,KAAI,EAAE,kBAAkB,KAAK,EAAE;EAC7B,IAAI;EACJ,IAAI,WAAW;AACf,MAAI,KAAK,aAAa,IACpB,YAAW,KAAK;AAElB,MAAI,EAAE,iBAAiB,KAAK,SAAS,CACnC,KAAI,KAAK,SAAS,UAAU,EAC1B,SAAQ;MAER,SAAQ,WAAW,KAAK,SAAS,MAAM,UAAU;MAInD,QAAO,EAAE,UAAU,OAAO;AAG5B,SAAO;GAAE,UAAU;GAAM;GAAO;;AAIlC,KAAI,EAAE,iBAAiB,KAAK,CAC1B,QAAO;EACL,UAAU;EACV,OAAO,YAAY,KAAK,QAAQ,OAAO,KAAK,MAAM;EACnD;AAIH,KAAI,EAAE,cAAc,KAAK,CACvB,QAAO;EAAE,UAAU;EAAM,OAAO,YAAY,OAAO;EAAQ;AAI7D,QAAO,EAAE,UAAU,OAAO;;;;;;;AAQ5B,SAAgB,cACd,MACS;AACT,KAAI,EAAE,gBAAgB,KAAK,CACzB,QAAO;AAET,KAAI,EAAE,iBAAiB,KAAK,CAC1B,QAAO;AAET,KAAI,EAAE,kBAAkB,KAAK,CAC3B,QAAO;AAET,QAAO;;;;;;;AAQT,SAAgB,WAAW,QAGzB;AACA,KAAI;AACF,QAAM,OAAO;UACN,OAAO;AACd,SAAO;GACL,SAAS;GACT,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;GAC9D;;AAEH,QAAO,EAAE,SAAS,MAAM"}
|
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
import * as t from
|
|
1
|
+
import * as t from "@babel/types";
|
|
2
|
+
//#region src/react/jsx/utils/buildImportMap.ts
|
|
2
3
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
else if (t.isImportDefaultSpecifier(spec) &&
|
|
22
|
-
t.isIdentifier(spec.local)) {
|
|
23
|
-
importMap.set(spec.local.name, importSource);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
return importMap;
|
|
4
|
+
* Builds a map of imported function names to their import paths from a given program path.
|
|
5
|
+
* Handles both named imports and default imports.
|
|
6
|
+
*
|
|
7
|
+
* Example: import { getInfo } from './constants' -> Map { 'getInfo' => './constants' }
|
|
8
|
+
* Example: import utils from './utils' -> Map { 'utils' => './utils' }
|
|
9
|
+
*/
|
|
10
|
+
function buildImportMap(programPath) {
|
|
11
|
+
const importMap = /* @__PURE__ */ new Map();
|
|
12
|
+
programPath.traverse({ ImportDeclaration(importPath) {
|
|
13
|
+
if (t.isStringLiteral(importPath.node.source)) {
|
|
14
|
+
const importSource = importPath.node.source.value;
|
|
15
|
+
importPath.node.specifiers.forEach((spec) => {
|
|
16
|
+
if (t.isImportSpecifier(spec) && t.isIdentifier(spec.imported) && t.isIdentifier(spec.local)) importMap.set(spec.local.name, importSource);
|
|
17
|
+
else if (t.isImportDefaultSpecifier(spec) && t.isIdentifier(spec.local)) importMap.set(spec.local.name, importSource);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
} });
|
|
21
|
+
return importMap;
|
|
30
22
|
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { buildImportMap };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=buildImportMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildImportMap.js","names":[],"sources":["../../../../src/react/jsx/utils/buildImportMap.ts"],"sourcesContent":["import { NodePath } from '@babel/traverse';\nimport * as t from '@babel/types';\n\n/**\n * Builds a map of imported function names to their import paths from a given program path.\n * Handles both named imports and default imports.\n *\n * Example: import { getInfo } from './constants' -> Map { 'getInfo' => './constants' }\n * Example: import utils from './utils' -> Map { 'utils' => './utils' }\n */\nexport function buildImportMap(programPath: NodePath): Map<string, string> {\n const importMap = new Map<string, string>();\n\n programPath.traverse({\n ImportDeclaration(importPath) {\n if (t.isStringLiteral(importPath.node.source)) {\n const importSource = importPath.node.source.value;\n importPath.node.specifiers.forEach((spec) => {\n if (\n t.isImportSpecifier(spec) &&\n t.isIdentifier(spec.imported) &&\n t.isIdentifier(spec.local)\n ) {\n importMap.set(spec.local.name, importSource);\n } else if (\n t.isImportDefaultSpecifier(spec) &&\n t.isIdentifier(spec.local)\n ) {\n importMap.set(spec.local.name, importSource);\n }\n });\n }\n },\n });\n\n return importMap;\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,eAAe,aAA4C;CACzE,MAAM,4BAAY,IAAI,KAAqB;AAE3C,aAAY,SAAS,EACnB,kBAAkB,YAAY;AAC5B,MAAI,EAAE,gBAAgB,WAAW,KAAK,OAAO,EAAE;GAC7C,MAAM,eAAe,WAAW,KAAK,OAAO;AAC5C,cAAW,KAAK,WAAW,SAAS,SAAS;AAC3C,QACE,EAAE,kBAAkB,KAAK,IACzB,EAAE,aAAa,KAAK,SAAS,IAC7B,EAAE,aAAa,KAAK,MAAM,CAE1B,WAAU,IAAI,KAAK,MAAM,MAAM,aAAa;aAE5C,EAAE,yBAAyB,KAAK,IAChC,EAAE,aAAa,KAAK,MAAM,CAE1B,WAAU,IAAI,KAAK,MAAM,MAAM,aAAa;KAE9C;;IAGP,CAAC;AAEF,QAAO"}
|