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,72 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import * as t from "@babel/types";
|
|
2
|
+
import traverseModule from "@babel/traverse";
|
|
3
|
+
//#region src/utils/parse/needsCJS.ts
|
|
4
4
|
const traverse = traverseModule.default || traverseModule;
|
|
5
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
|
-
// Mixed usage - this is unusual but we'll default to ES6 imports
|
|
36
|
-
warnings.push(`Mixed ES6 imports and CommonJS require detected in ${filepath}. Defaulting to ES6 imports.`);
|
|
37
|
-
needsCJS = false;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
// No imports/requires found, fall back to configuration-based logic
|
|
41
|
-
if (filepath.endsWith('.ts') || filepath.endsWith('.tsx')) {
|
|
42
|
-
// For TypeScript files, check tsconfig.json compilerOptions.module
|
|
43
|
-
const moduleSetting = tsconfigJson?.compilerOptions?.module;
|
|
44
|
-
if (moduleSetting === 'commonjs' || moduleSetting === 'node') {
|
|
45
|
-
needsCJS = true;
|
|
46
|
-
}
|
|
47
|
-
else if (moduleSetting === 'esnext' ||
|
|
48
|
-
moduleSetting === 'es2022' ||
|
|
49
|
-
moduleSetting === 'es2020' ||
|
|
50
|
-
moduleSetting === 'es2015' ||
|
|
51
|
-
moduleSetting === 'es6' ||
|
|
52
|
-
moduleSetting === 'node16' ||
|
|
53
|
-
moduleSetting === 'nodenext') {
|
|
54
|
-
needsCJS = false;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
// Default to ESM for TypeScript files if no module setting is specified
|
|
58
|
-
needsCJS = false;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
else if (filepath.endsWith('.js')) {
|
|
62
|
-
// For JavaScript files, check package.json type
|
|
63
|
-
// If package.json has "type": "module", .js files are treated as ES modules
|
|
64
|
-
needsCJS = packageJson?.type !== 'module';
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
// For other file extensions, default to ESM
|
|
68
|
-
needsCJS = false;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return needsCJS;
|
|
6
|
+
* Given an AST determines if the file needs to be compiled as CommonJS or ESM.
|
|
7
|
+
* @param ast - The AST to analyze
|
|
8
|
+
* @returns True if the file needs to be compiled as CommonJS, false if it needs to be compiled as ESM
|
|
9
|
+
*/
|
|
10
|
+
function needsCJS({ ast, warnings, filepath, packageJson, tsconfigJson }) {
|
|
11
|
+
let hasES6Imports = false;
|
|
12
|
+
let hasCommonJSRequire = false;
|
|
13
|
+
traverse(ast, {
|
|
14
|
+
ImportDeclaration() {
|
|
15
|
+
hasES6Imports = true;
|
|
16
|
+
},
|
|
17
|
+
CallExpression(path) {
|
|
18
|
+
if (t.isIdentifier(path.node.callee, { name: "require" })) hasCommonJSRequire = true;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
let needsCJS = false;
|
|
22
|
+
if (hasES6Imports && !hasCommonJSRequire) needsCJS = false;
|
|
23
|
+
else if (hasCommonJSRequire && !hasES6Imports) needsCJS = true;
|
|
24
|
+
else if (hasES6Imports && hasCommonJSRequire) {
|
|
25
|
+
warnings.push(`Mixed ES6 imports and CommonJS require detected in ${filepath}. Defaulting to ES6 imports.`);
|
|
26
|
+
needsCJS = false;
|
|
27
|
+
} else if (filepath.endsWith(".ts") || filepath.endsWith(".tsx")) {
|
|
28
|
+
const moduleSetting = tsconfigJson?.compilerOptions?.module;
|
|
29
|
+
if (moduleSetting === "commonjs" || moduleSetting === "node") needsCJS = true;
|
|
30
|
+
else if (moduleSetting === "esnext" || moduleSetting === "es2022" || moduleSetting === "es2020" || moduleSetting === "es2015" || moduleSetting === "es6" || moduleSetting === "node16" || moduleSetting === "nodenext") needsCJS = false;
|
|
31
|
+
else needsCJS = false;
|
|
32
|
+
} else if (filepath.endsWith(".js")) needsCJS = packageJson?.type !== "module";
|
|
33
|
+
else needsCJS = false;
|
|
34
|
+
return needsCJS;
|
|
72
35
|
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { needsCJS };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=needsCJS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"needsCJS.js","names":[],"sources":["../../../src/utils/parse/needsCJS.ts"],"sourcesContent":["import { ParseResult } from '@babel/parser';\nimport traverseModule from '@babel/traverse';\nimport * as t from '@babel/types';\n\n// Handle CommonJS/ESM interop\nconst traverse = traverseModule.default || traverseModule;\n\n/**\n * Given an AST determines if the file needs to be compiled as CommonJS or ESM.\n * @param ast - The AST to analyze\n * @returns True if the file needs to be compiled as CommonJS, false if it needs to be compiled as ESM\n */\nexport function needsCJS({\n ast,\n warnings,\n filepath,\n packageJson,\n tsconfigJson,\n}: {\n ast: ParseResult<t.File>;\n warnings: string[];\n filepath: string;\n packageJson?: { type?: string };\n tsconfigJson?: { compilerOptions?: { module?: string } };\n}) {\n // Analyze the actual file content to determine module system\n let hasES6Imports = false;\n let hasCommonJSRequire = false;\n\n traverse(ast, {\n ImportDeclaration() {\n hasES6Imports = true;\n },\n CallExpression(path) {\n if (t.isIdentifier(path.node.callee, { name: 'require' })) {\n hasCommonJSRequire = true;\n }\n },\n });\n\n // Determine if we need CommonJS based on actual file content and fallback to config-based logic\n let needsCJS = false;\n\n if (hasES6Imports && !hasCommonJSRequire) {\n // File uses ES6 imports, so we should use ES6 imports\n needsCJS = false;\n } else if (hasCommonJSRequire && !hasES6Imports) {\n // File uses CommonJS require, so we should use CommonJS require\n needsCJS = true;\n } else if (hasES6Imports && hasCommonJSRequire) {\n // Mixed usage - this is unusual but we'll default to ES6 imports\n warnings.push(\n `Mixed ES6 imports and CommonJS require detected in ${filepath}. Defaulting to ES6 imports.`\n );\n needsCJS = false;\n } else {\n // No imports/requires found, fall back to configuration-based logic\n if (filepath.endsWith('.ts') || filepath.endsWith('.tsx')) {\n // For TypeScript files, check tsconfig.json compilerOptions.module\n const moduleSetting = tsconfigJson?.compilerOptions?.module;\n if (moduleSetting === 'commonjs' || moduleSetting === 'node') {\n needsCJS = true;\n } else if (\n moduleSetting === 'esnext' ||\n moduleSetting === 'es2022' ||\n moduleSetting === 'es2020' ||\n moduleSetting === 'es2015' ||\n moduleSetting === 'es6' ||\n moduleSetting === 'node16' ||\n moduleSetting === 'nodenext'\n ) {\n needsCJS = false;\n } else {\n // Default to ESM for TypeScript files if no module setting is specified\n needsCJS = false;\n }\n } else if (filepath.endsWith('.js')) {\n // For JavaScript files, check package.json type\n // If package.json has \"type\": \"module\", .js files are treated as ES modules\n needsCJS = packageJson?.type !== 'module';\n } else {\n // For other file extensions, default to ESM\n needsCJS = false;\n }\n }\n\n return needsCJS;\n}\n"],"mappings":";;;AAKA,MAAM,WAAW,eAAe,WAAW;;;;;;AAO3C,SAAgB,SAAS,EACvB,KACA,UACA,UACA,aACA,gBAOC;CAED,IAAI,gBAAgB;CACpB,IAAI,qBAAqB;AAEzB,UAAS,KAAK;EACZ,oBAAoB;AAClB,mBAAgB;;EAElB,eAAe,MAAM;AACnB,OAAI,EAAE,aAAa,KAAK,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC,CACvD,sBAAqB;;EAG1B,CAAC;CAGF,IAAI,WAAW;AAEf,KAAI,iBAAiB,CAAC,mBAEpB,YAAW;UACF,sBAAsB,CAAC,cAEhC,YAAW;UACF,iBAAiB,oBAAoB;AAE9C,WAAS,KACP,sDAAsD,SAAS,8BAChE;AACD,aAAW;YAGP,SAAS,SAAS,MAAM,IAAI,SAAS,SAAS,OAAO,EAAE;EAEzD,MAAM,gBAAgB,cAAc,iBAAiB;AACrD,MAAI,kBAAkB,cAAc,kBAAkB,OACpD,YAAW;WAEX,kBAAkB,YAClB,kBAAkB,YAClB,kBAAkB,YAClB,kBAAkB,YAClB,kBAAkB,SAClB,kBAAkB,YAClB,kBAAkB,WAElB,YAAW;MAGX,YAAW;YAEJ,SAAS,SAAS,MAAM,CAGjC,YAAW,aAAa,SAAS;KAGjC,YAAW;AAIf,QAAO"}
|
|
@@ -1,34 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { findOrCreateEntry, readLockfile, writeLockfile
|
|
3
|
-
import
|
|
1
|
+
import { hashStringSync } from "./hash.js";
|
|
2
|
+
import { findOrCreateEntry, readLockfile, writeLockfile } from "../fs/config/downloadedVersions.js";
|
|
3
|
+
import * as fs$1 from "node:fs";
|
|
4
|
+
//#region src/utils/persistPostprocessHashes.ts
|
|
4
5
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
lockUpdated = true;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if (lockUpdated) {
|
|
32
|
-
writeLockfile(data, originalV1);
|
|
33
|
-
}
|
|
6
|
+
* Persist postprocessed content hashes for recently downloaded files into gt-lock.json.
|
|
7
|
+
*/
|
|
8
|
+
function persistPostProcessHashes(settings, includeFiles, downloadedMeta) {
|
|
9
|
+
if (!includeFiles || includeFiles.size === 0 || downloadedMeta.size === 0) return;
|
|
10
|
+
const { data, entryMap, originalV1 } = readLockfile(settings);
|
|
11
|
+
let lockUpdated = false;
|
|
12
|
+
for (const filePath of includeFiles) {
|
|
13
|
+
const meta = downloadedMeta.get(filePath);
|
|
14
|
+
if (!meta) continue;
|
|
15
|
+
if (!fs$1.existsSync(filePath)) continue;
|
|
16
|
+
const hash = hashStringSync(fs$1.readFileSync(filePath, "utf8"));
|
|
17
|
+
const entry = findOrCreateEntry(entryMap, data.entries, meta.fileId, meta.versionId);
|
|
18
|
+
const existing = entry.translations[meta.locale] || {};
|
|
19
|
+
if (existing.postProcessHash !== hash) {
|
|
20
|
+
entry.translations[meta.locale] = {
|
|
21
|
+
...existing,
|
|
22
|
+
postProcessHash: hash
|
|
23
|
+
};
|
|
24
|
+
lockUpdated = true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (lockUpdated) writeLockfile(data, originalV1);
|
|
34
28
|
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { persistPostProcessHashes };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=persistPostprocessHashes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persistPostprocessHashes.js","names":["fs"],"sources":["../../src/utils/persistPostprocessHashes.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport {\n findOrCreateEntry,\n readLockfile,\n writeLockfile,\n} from '../fs/config/downloadedVersions.js';\nimport { hashStringSync } from './hash.js';\nimport type { Settings } from '../types/index.js';\n\ntype DownloadMeta = {\n branchId: string;\n fileId: string;\n versionId: string;\n locale: string;\n};\n\n/**\n * Persist postprocessed content hashes for recently downloaded files into gt-lock.json.\n */\nexport function persistPostProcessHashes(\n settings: Settings,\n includeFiles: Set<string> | undefined,\n downloadedMeta: Map<string, DownloadMeta>\n): void {\n if (!includeFiles || includeFiles.size === 0 || downloadedMeta.size === 0) {\n return;\n }\n\n const { data, entryMap, originalV1 } = readLockfile(settings);\n let lockUpdated = false;\n\n for (const filePath of includeFiles) {\n const meta = downloadedMeta.get(filePath);\n if (!meta) continue;\n if (!fs.existsSync(filePath)) continue;\n\n const content = fs.readFileSync(filePath, 'utf8');\n const hash = hashStringSync(content);\n\n const entry = findOrCreateEntry(\n entryMap,\n data.entries,\n meta.fileId,\n meta.versionId\n );\n\n const existing = entry.translations[meta.locale] || {};\n\n if (existing.postProcessHash !== hash) {\n entry.translations[meta.locale] = {\n ...existing,\n postProcessHash: hash,\n };\n lockUpdated = true;\n }\n }\n\n if (lockUpdated) {\n writeLockfile(data, originalV1);\n }\n}\n"],"mappings":";;;;;;;AAmBA,SAAgB,yBACd,UACA,cACA,gBACM;AACN,KAAI,CAAC,gBAAgB,aAAa,SAAS,KAAK,eAAe,SAAS,EACtE;CAGF,MAAM,EAAE,MAAM,UAAU,eAAe,aAAa,SAAS;CAC7D,IAAI,cAAc;AAElB,MAAK,MAAM,YAAY,cAAc;EACnC,MAAM,OAAO,eAAe,IAAI,SAAS;AACzC,MAAI,CAAC,KAAM;AACX,MAAI,CAACA,KAAG,WAAW,SAAS,CAAE;EAG9B,MAAM,OAAO,eADGA,KAAG,aAAa,UAAU,OACP,CAAC;EAEpC,MAAM,QAAQ,kBACZ,UACA,KAAK,SACL,KAAK,QACL,KAAK,UACN;EAED,MAAM,WAAW,MAAM,aAAa,KAAK,WAAW,EAAE;AAEtD,MAAI,SAAS,oBAAoB,MAAM;AACrC,SAAM,aAAa,KAAK,UAAU;IAChC,GAAG;IACH,iBAAiB;IAClB;AACD,iBAAc;;;AAIlB,KAAI,YACF,eAAc,MAAM,WAAW"}
|
|
@@ -1,56 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import * as fs from
|
|
1
|
+
import { getRelative, readFile } from "../fs/findFilepath.js";
|
|
2
|
+
import { createFileMapping } from "../formats/files/fileMapping.js";
|
|
3
|
+
import { addExplicitAnchorIds, extractHeadingInfo } from "./addExplicitAnchorIds.js";
|
|
4
|
+
import * as fs$1 from "fs";
|
|
5
|
+
//#region src/utils/processAnchorIds.ts
|
|
5
6
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// Get all translated files whose sources are md or mdx
|
|
30
|
-
const mdFiles = Object.entries(filesMap).filter(([sourcePath, translatedPath]) => translatedPath &&
|
|
31
|
-
sourceTypeByPath.has(sourcePath) &&
|
|
32
|
-
(!includeFiles || includeFiles.has(translatedPath)));
|
|
33
|
-
for (const [sourcePath, translatedPath] of mdFiles) {
|
|
34
|
-
try {
|
|
35
|
-
// Check if translated file exists before processing
|
|
36
|
-
if (!fs.existsSync(translatedPath)) {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
// Extract heading info from source file
|
|
40
|
-
const sourceContent = readFile(sourcePath);
|
|
41
|
-
const sourceHeadingMap = extractHeadingInfo(sourceContent);
|
|
42
|
-
const fileTypeHint = sourceTypeByPath.get(sourcePath);
|
|
43
|
-
// Read translated file and apply anchor IDs
|
|
44
|
-
const translatedContent = readFile(translatedPath);
|
|
45
|
-
const result = addExplicitAnchorIds(translatedContent, sourceHeadingMap, settings, sourcePath, translatedPath, fileTypeHint);
|
|
46
|
-
if (result.hasChanges) {
|
|
47
|
-
fs.writeFileSync(translatedPath, result.content, 'utf8');
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
console.warn(`Failed to process IDs for ${translatedPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
await Promise.all(processPromises);
|
|
7
|
+
* Processes all translated MD/MDX files to add explicit anchor IDs
|
|
8
|
+
* This preserves navigation links when headings are translated
|
|
9
|
+
*/
|
|
10
|
+
async function processAnchorIds(settings, includeFiles) {
|
|
11
|
+
if (!settings.files) return;
|
|
12
|
+
const { resolvedPaths, placeholderPaths, transformPaths, transformFormats } = settings.files;
|
|
13
|
+
const fileMapping = createFileMapping(resolvedPaths, placeholderPaths, transformPaths, transformFormats, settings.locales, settings.defaultLocale);
|
|
14
|
+
const sourceTypeByPath = /* @__PURE__ */ new Map();
|
|
15
|
+
if (resolvedPaths.md) for (const filePath of resolvedPaths.md) sourceTypeByPath.set(getRelative(filePath), "md");
|
|
16
|
+
if (resolvedPaths.mdx) for (const filePath of resolvedPaths.mdx) sourceTypeByPath.set(getRelative(filePath), "mdx");
|
|
17
|
+
const processPromises = Object.entries(fileMapping).filter(([locale]) => locale !== settings.defaultLocale).map(async ([, filesMap]) => {
|
|
18
|
+
const mdFiles = Object.entries(filesMap).filter(([sourcePath, translatedPath]) => translatedPath && sourceTypeByPath.has(sourcePath) && (!includeFiles || includeFiles.has(translatedPath)));
|
|
19
|
+
for (const [sourcePath, translatedPath] of mdFiles) try {
|
|
20
|
+
if (!fs$1.existsSync(translatedPath)) continue;
|
|
21
|
+
const sourceHeadingMap = extractHeadingInfo(readFile(sourcePath));
|
|
22
|
+
const fileTypeHint = sourceTypeByPath.get(sourcePath);
|
|
23
|
+
const result = addExplicitAnchorIds(readFile(translatedPath), sourceHeadingMap, settings, sourcePath, translatedPath, fileTypeHint);
|
|
24
|
+
if (result.hasChanges) fs$1.writeFileSync(translatedPath, result.content, "utf8");
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.warn(`Failed to process IDs for ${translatedPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
await Promise.all(processPromises);
|
|
56
30
|
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { processAnchorIds as default };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=processAnchorIds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processAnchorIds.js","names":["fs"],"sources":["../../src/utils/processAnchorIds.ts"],"sourcesContent":["import {\n addExplicitAnchorIds,\n extractHeadingInfo,\n} from './addExplicitAnchorIds.js';\nimport { getRelative, readFile } from '../fs/findFilepath.js';\nimport { createFileMapping } from '../formats/files/fileMapping.js';\nimport { Settings } from '../types/index.js';\nimport * as fs from 'fs';\n\n/**\n * Processes all translated MD/MDX files to add explicit anchor IDs\n * This preserves navigation links when headings are translated\n */\nexport default async function processAnchorIds(\n settings: Settings,\n includeFiles?: Set<string>\n) {\n if (!settings.files) return;\n\n const { resolvedPaths, placeholderPaths, transformPaths, transformFormats } =\n settings.files;\n const fileMapping = createFileMapping(\n resolvedPaths,\n placeholderPaths,\n transformPaths,\n transformFormats,\n settings.locales,\n settings.defaultLocale\n );\n const sourceTypeByPath = new Map<string, 'md' | 'mdx'>();\n if (resolvedPaths.md) {\n for (const filePath of resolvedPaths.md) {\n sourceTypeByPath.set(getRelative(filePath), 'md');\n }\n }\n if (resolvedPaths.mdx) {\n for (const filePath of resolvedPaths.mdx) {\n sourceTypeByPath.set(getRelative(filePath), 'mdx');\n }\n }\n\n // Process each locale's translated files\n const processPromises = Object.entries(fileMapping)\n .filter(([locale]) => locale !== settings.defaultLocale) // Skip default locale\n .map(async ([, filesMap]) => {\n // Get all translated files whose sources are md or mdx\n const mdFiles = Object.entries(filesMap).filter(\n ([sourcePath, translatedPath]) =>\n translatedPath &&\n sourceTypeByPath.has(sourcePath) &&\n (!includeFiles || includeFiles.has(translatedPath))\n );\n\n for (const [sourcePath, translatedPath] of mdFiles) {\n try {\n // Check if translated file exists before processing\n if (!fs.existsSync(translatedPath)) {\n continue;\n }\n\n // Extract heading info from source file\n const sourceContent = readFile(sourcePath);\n const sourceHeadingMap = extractHeadingInfo(sourceContent);\n const fileTypeHint = sourceTypeByPath.get(sourcePath);\n\n // Read translated file and apply anchor IDs\n const translatedContent = readFile(translatedPath);\n const result = addExplicitAnchorIds(\n translatedContent,\n sourceHeadingMap,\n settings,\n sourcePath,\n translatedPath,\n fileTypeHint\n );\n\n if (result.hasChanges) {\n fs.writeFileSync(translatedPath, result.content, 'utf8');\n }\n } catch (error) {\n console.warn(\n `Failed to process IDs for ${translatedPath}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n });\n\n await Promise.all(processPromises);\n}\n"],"mappings":";;;;;;;;;AAaA,eAA8B,iBAC5B,UACA,cACA;AACA,KAAI,CAAC,SAAS,MAAO;CAErB,MAAM,EAAE,eAAe,kBAAkB,gBAAgB,qBACvD,SAAS;CACX,MAAM,cAAc,kBAClB,eACA,kBACA,gBACA,kBACA,SAAS,SACT,SAAS,cACV;CACD,MAAM,mCAAmB,IAAI,KAA2B;AACxD,KAAI,cAAc,GAChB,MAAK,MAAM,YAAY,cAAc,GACnC,kBAAiB,IAAI,YAAY,SAAS,EAAE,KAAK;AAGrD,KAAI,cAAc,IAChB,MAAK,MAAM,YAAY,cAAc,IACnC,kBAAiB,IAAI,YAAY,SAAS,EAAE,MAAM;CAKtD,MAAM,kBAAkB,OAAO,QAAQ,YAAY,CAChD,QAAQ,CAAC,YAAY,WAAW,SAAS,cAAc,CACvD,IAAI,OAAO,GAAG,cAAc;EAE3B,MAAM,UAAU,OAAO,QAAQ,SAAS,CAAC,QACtC,CAAC,YAAY,oBACZ,kBACA,iBAAiB,IAAI,WAAW,KAC/B,CAAC,gBAAgB,aAAa,IAAI,eAAe,EACrD;AAED,OAAK,MAAM,CAAC,YAAY,mBAAmB,QACzC,KAAI;AAEF,OAAI,CAACA,KAAG,WAAW,eAAe,CAChC;GAKF,MAAM,mBAAmB,mBADH,SAAS,WAC0B,CAAC;GAC1D,MAAM,eAAe,iBAAiB,IAAI,WAAW;GAIrD,MAAM,SAAS,qBADW,SAAS,eAEhB,EACjB,kBACA,UACA,YACA,gBACA,aACD;AAED,OAAI,OAAO,WACT,MAAG,cAAc,gBAAgB,OAAO,SAAS,OAAO;WAEnD,OAAO;AACd,WAAQ,KACN,6BAA6B,eAAe,IAAI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GACvG;;GAGL;AAEJ,OAAM,QAAQ,IAAI,gBAAgB"}
|