gt 2.14.35 → 2.14.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -1
- package/dist/api/collectUserEditDiffs.js +112 -155
- package/dist/api/collectUserEditDiffs.js.map +1 -0
- package/dist/api/downloadFileBatch.js +164 -241
- package/dist/api/downloadFileBatch.js.map +1 -0
- package/dist/api/saveLocalEdits.js +37 -41
- package/dist/api/saveLocalEdits.js.map +1 -0
- package/dist/bin/bin-entry.js +17 -7
- package/dist/bin/bin-entry.js.map +1 -0
- package/dist/bin/bin-main.js +43 -61
- package/dist/bin/bin-main.js.map +1 -0
- package/dist/cli/base.js +382 -497
- package/dist/cli/base.js.map +1 -0
- package/dist/cli/commands/download.js +41 -49
- package/dist/cli/commands/download.js.map +1 -0
- package/dist/cli/commands/enqueue.js +26 -25
- package/dist/cli/commands/enqueue.js.map +1 -0
- package/dist/cli/commands/setupProject.js +33 -36
- package/dist/cli/commands/setupProject.js.map +1 -0
- package/dist/cli/commands/stage.js +53 -61
- package/dist/cli/commands/stage.js.map +1 -0
- package/dist/cli/commands/translate.js +75 -112
- package/dist/cli/commands/translate.js.map +1 -0
- package/dist/cli/commands/upload.js +185 -213
- package/dist/cli/commands/upload.js.map +1 -0
- package/dist/cli/commands/utils/validation.js +39 -34
- package/dist/cli/commands/utils/validation.js.map +1 -0
- package/dist/cli/flags.js +35 -62
- package/dist/cli/flags.js.map +1 -0
- package/dist/cli/inline.js +112 -137
- package/dist/cli/inline.js.map +1 -0
- package/dist/cli/next.js +17 -12
- package/dist/cli/next.js.map +1 -0
- package/dist/cli/node.js +19 -15
- package/dist/cli/node.js.map +1 -0
- package/dist/cli/python.js +13 -8
- package/dist/cli/python.js.map +1 -0
- package/dist/cli/react.js +61 -78
- package/dist/cli/react.js.map +1 -0
- package/dist/config/defaults.js +16 -11
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/generateSettings.js +167 -269
- package/dist/config/generateSettings.js.map +1 -0
- package/dist/config/optionPresets.js +78 -96
- package/dist/config/optionPresets.js.map +1 -0
- package/dist/config/resolveConfig.js +27 -32
- package/dist/config/resolveConfig.js.map +1 -0
- package/dist/config/utils.js +7 -3
- package/dist/config/utils.js.map +1 -0
- package/dist/config/validateSettings.js +19 -30
- package/dist/config/validateSettings.js.map +1 -0
- package/dist/console/colors.js +18 -13
- package/dist/console/colors.js.map +1 -0
- package/dist/console/displayTranslateSummary.js +40 -37
- package/dist/console/displayTranslateSummary.js.map +1 -0
- package/dist/console/formatting.js +8 -5
- package/dist/console/formatting.js.map +1 -0
- package/dist/console/index.d.ts +11 -9
- package/dist/console/index.js +53 -50
- package/dist/console/index.js.map +1 -0
- package/dist/console/inkFields.d.ts +23 -0
- package/dist/console/inkFields.js +87 -0
- package/dist/console/inkFields.js.map +1 -0
- package/dist/console/inkLayout.d.ts +7 -0
- package/dist/console/inkLayout.js +139 -0
- package/dist/console/inkLayout.js.map +1 -0
- package/dist/console/inkLocaleData.d.ts +4 -0
- package/dist/console/inkLocaleData.js +32 -0
- package/dist/console/inkLocaleData.js.map +1 -0
- package/dist/console/inkPrompts.d.ts +8 -0
- package/dist/console/inkPrompts.js +496 -0
- package/dist/console/inkPrompts.js.map +1 -0
- package/dist/console/inkSession.d.ts +3 -0
- package/dist/console/inkSession.js +42 -0
- package/dist/console/inkSession.js.map +1 -0
- package/dist/console/inkTerminal.d.ts +4 -0
- package/dist/console/inkTerminal.js +15 -0
- package/dist/console/inkTerminal.js.map +1 -0
- package/dist/console/inkTypes.d.ts +66 -0
- package/dist/console/inkTypes.js +1 -0
- package/dist/console/inkUtils.d.ts +24 -0
- package/dist/console/inkUtils.js +87 -0
- package/dist/console/inkUtils.js.map +1 -0
- package/dist/console/logger.js +209 -249
- package/dist/console/logger.js.map +1 -0
- package/dist/console/logging.d.ts +14 -0
- package/dist/console/logging.js +203 -162
- package/dist/console/logging.js.map +1 -0
- package/dist/console/promptParsing.d.ts +5 -0
- package/dist/console/promptParsing.js +28 -0
- package/dist/console/promptParsing.js.map +1 -0
- package/dist/console/terminalSession.d.ts +5 -0
- package/dist/console/terminalSession.js +38 -0
- package/dist/console/terminalSession.js.map +1 -0
- package/dist/extraction/index.js +3 -2
- package/dist/extraction/mapToUpdates.js +19 -18
- package/dist/extraction/mapToUpdates.js.map +1 -0
- package/dist/extraction/postProcess.js +68 -86
- package/dist/extraction/postProcess.js.map +1 -0
- package/dist/formats/files/aggregateFiles.js +223 -304
- package/dist/formats/files/aggregateFiles.js.map +1 -0
- package/dist/formats/files/collectFiles.js +53 -54
- package/dist/formats/files/collectFiles.js.map +1 -0
- package/dist/formats/files/convertToFileTranslationData.js +21 -19
- package/dist/formats/files/convertToFileTranslationData.js.map +1 -0
- package/dist/formats/files/fileMapping.js +82 -119
- package/dist/formats/files/fileMapping.js.map +1 -0
- package/dist/formats/files/preprocess/mdx.js +15 -12
- package/dist/formats/files/preprocess/mdx.js.map +1 -0
- package/dist/formats/files/preprocess/mintlify.js +15 -13
- package/dist/formats/files/preprocess/mintlify.js.map +1 -0
- package/dist/formats/files/preprocessContent.js +20 -21
- package/dist/formats/files/preprocessContent.js.map +1 -0
- package/dist/formats/files/save.js +18 -15
- package/dist/formats/files/save.js.map +1 -0
- package/dist/formats/files/supportedFiles.js +27 -22
- package/dist/formats/files/supportedFiles.js.map +1 -0
- package/dist/formats/files/transformFormat.js +93 -100
- package/dist/formats/files/transformFormat.js.map +1 -0
- package/dist/formats/json/extractJson.js +83 -110
- package/dist/formats/json/extractJson.js.map +1 -0
- package/dist/formats/json/flattenJson.js +41 -48
- package/dist/formats/json/flattenJson.js.map +1 -0
- package/dist/formats/json/jsonPath.js +20 -15
- package/dist/formats/json/jsonPath.js.map +1 -0
- package/dist/formats/json/jsonPointer.js +17 -17
- package/dist/formats/json/jsonPointer.js.map +1 -0
- package/dist/formats/json/mergeJson.js +230 -371
- package/dist/formats/json/mergeJson.js.map +1 -0
- package/dist/formats/json/parseJson.js +74 -111
- package/dist/formats/json/parseJson.js.map +1 -0
- package/dist/formats/json/transformJson.js +53 -61
- package/dist/formats/json/transformJson.js.map +1 -0
- package/dist/formats/json/utils.js +158 -187
- package/dist/formats/json/utils.js.map +1 -0
- package/dist/formats/parseKeyedMetadata.js +85 -106
- package/dist/formats/parseKeyedMetadata.js.map +1 -0
- package/dist/formats/utils.js +13 -23
- package/dist/formats/utils.js.map +1 -0
- package/dist/formats/yaml/extractYaml.js +32 -31
- package/dist/formats/yaml/extractYaml.js.map +1 -0
- package/dist/formats/yaml/mergeYaml.js +43 -60
- package/dist/formats/yaml/mergeYaml.js.map +1 -0
- package/dist/formats/yaml/parseYaml.js +34 -23
- package/dist/formats/yaml/parseYaml.js.map +1 -0
- package/dist/formats/yaml/utils.js +19 -21
- package/dist/formats/yaml/utils.js.map +1 -0
- package/dist/fs/clearLocaleDirs.js +82 -114
- package/dist/fs/clearLocaleDirs.js.map +1 -0
- package/dist/fs/config/downloadedVersions.js +174 -188
- package/dist/fs/config/downloadedVersions.js.map +1 -0
- package/dist/fs/config/loadConfig.js +12 -8
- package/dist/fs/config/loadConfig.js.map +1 -0
- package/dist/fs/config/parseFilesConfig.js +166 -227
- package/dist/fs/config/parseFilesConfig.js.map +1 -0
- package/dist/fs/config/setupConfig.js +43 -52
- package/dist/fs/config/setupConfig.js.map +1 -0
- package/dist/fs/config/updateConfig.js +44 -56
- package/dist/fs/config/updateConfig.js.map +1 -0
- package/dist/fs/config/updateVersions.js +27 -28
- package/dist/fs/config/updateVersions.js.map +1 -0
- package/dist/fs/copyFile.js +33 -37
- package/dist/fs/copyFile.js.map +1 -0
- package/dist/fs/createLoadTranslationsFile.js +32 -48
- package/dist/fs/createLoadTranslationsFile.js.map +1 -0
- package/dist/fs/determineFramework/detectPythonLibrary.js +30 -34
- package/dist/fs/determineFramework/detectPythonLibrary.js.map +1 -0
- package/dist/fs/determineFramework/index.js +46 -64
- package/dist/fs/determineFramework/index.js.map +1 -0
- package/dist/fs/determineFramework/matchPyprojectDependency.js +65 -78
- package/dist/fs/determineFramework/matchPyprojectDependency.js.map +1 -0
- package/dist/fs/determineFramework/matchRequirementsTxtDependency.js +21 -19
- package/dist/fs/determineFramework/matchRequirementsTxtDependency.js.map +1 -0
- package/dist/fs/determineFramework/matchSetupPyDependency.js +60 -81
- package/dist/fs/determineFramework/matchSetupPyDependency.js.map +1 -0
- package/dist/fs/determineFramework/resolveGtDependency.js +15 -15
- package/dist/fs/determineFramework/resolveGtDependency.js.map +1 -0
- package/dist/fs/findFilepath.js +63 -78
- package/dist/fs/findFilepath.js.map +1 -0
- package/dist/fs/loadJSON.js +18 -15
- package/dist/fs/loadJSON.js.map +1 -0
- package/dist/fs/matchFiles.js +12 -7
- package/dist/fs/matchFiles.js.map +1 -0
- package/dist/fs/saveJSON.js +10 -6
- package/dist/fs/saveJSON.js.map +1 -0
- package/dist/fs/utils.js +19 -15
- package/dist/fs/utils.js.map +1 -0
- package/dist/functions.d.ts +2 -1
- package/dist/functions.js +3 -6
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +6 -2
- package/dist/generated/version.js.map +1 -0
- package/dist/git/branches.js +77 -83
- package/dist/git/branches.js.map +1 -0
- package/dist/hooks/postProcess.js +97 -114
- package/dist/hooks/postProcess.js.map +1 -0
- package/dist/index.js +23 -31
- package/dist/index.js.map +1 -0
- package/dist/locadex/setupFlow.js +11 -8
- package/dist/locadex/setupFlow.js.map +1 -0
- package/dist/main.js +17 -7
- package/dist/main.js.map +1 -0
- package/dist/next/config/parseNextConfig.js +32 -51
- package/dist/next/config/parseNextConfig.js.map +1 -0
- package/dist/next/jsx/utils.js +25 -37
- package/dist/next/jsx/utils.js.map +1 -0
- package/dist/next/parse/handleInitGT.js +87 -154
- package/dist/next/parse/handleInitGT.js.map +1 -0
- package/dist/next/parse/wrapContent.js +136 -158
- package/dist/next/parse/wrapContent.js.map +1 -0
- package/dist/python/parse/createPythonInlineUpdates.js +36 -33
- package/dist/python/parse/createPythonInlineUpdates.js.map +1 -0
- package/dist/react/config/createESBuildConfig.js +115 -115
- package/dist/react/config/createESBuildConfig.js.map +1 -0
- package/dist/react/jsx/evaluateJsx.js +90 -124
- package/dist/react/jsx/evaluateJsx.js.map +1 -0
- package/dist/react/jsx/utils/buildImportMap.js +24 -28
- package/dist/react/jsx/utils/buildImportMap.js.map +1 -0
- package/dist/react/jsx/utils/constants.js +79 -87
- package/dist/react/jsx/utils/constants.js.map +1 -0
- package/dist/react/jsx/utils/extractSourceCode.js +36 -37
- package/dist/react/jsx/utils/extractSourceCode.js.map +1 -0
- package/dist/react/jsx/utils/getCalleeNameFromExpression.js +30 -30
- package/dist/react/jsx/utils/getCalleeNameFromExpression.js.map +1 -0
- package/dist/react/jsx/utils/getPathsAndAliases.js +70 -105
- package/dist/react/jsx/utils/getPathsAndAliases.js.map +1 -0
- package/dist/react/jsx/utils/isNumberLiteral.js +13 -11
- package/dist/react/jsx/utils/isNumberLiteral.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.js +103 -148
- package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/autoInsertion.js +305 -389
- package/dist/react/jsx/utils/jsxParsing/autoInsertion.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.js +122 -193
- package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.js +50 -64
- package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.js +41 -68
- package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/parseJsx.js +760 -1107
- package/dist/react/jsx/utils/jsxParsing/parseJsx.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/parseTProps.js +35 -71
- package/dist/react/jsx/utils/jsxParsing/parseTProps.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.js +39 -58
- package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.js.map +1 -0
- package/dist/react/jsx/utils/jsxParsing/types.js +10 -24
- package/dist/react/jsx/utils/jsxParsing/types.js.map +1 -0
- package/dist/react/jsx/utils/mapAttributeName.js +13 -13
- package/dist/react/jsx/utils/mapAttributeName.js.map +1 -0
- package/dist/react/jsx/utils/parseAst.js +142 -272
- package/dist/react/jsx/utils/parseAst.js.map +1 -0
- package/dist/react/jsx/utils/parseString.js +726 -1090
- package/dist/react/jsx/utils/parseString.js.map +1 -0
- package/dist/react/jsx/utils/parseStringFunction.js +274 -401
- package/dist/react/jsx/utils/parseStringFunction.js.map +1 -0
- package/dist/react/jsx/utils/resolveImportPath.d.ts +1 -1
- package/dist/react/jsx/utils/resolveImportPath.js +125 -108
- package/dist/react/jsx/utils/resolveImportPath.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/derivation/containsDeriveCall.js +18 -24
- package/dist/react/jsx/utils/stringParsing/derivation/containsDeriveCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/derivation/handleDerivation.js +412 -579
- package/dist/react/jsx/utils/stringParsing/derivation/handleDerivation.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/derivation/index.js +57 -67
- package/dist/react/jsx/utils/stringParsing/derivation/index.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/derivation/isDeriveCall.js +26 -36
- package/dist/react/jsx/utils/stringParsing/derivation/isDeriveCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/handleTaggedTemplateTranslationCall.js +29 -24
- package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/handleTaggedTemplateTranslationCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/index.js +34 -32
- package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/index.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.js +80 -117
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleDeriveTranslationCall.js +24 -19
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleDeriveTranslationCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.js +18 -21
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.js +45 -50
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.js +54 -59
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.js.map +1 -0
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.js +56 -69
- package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.js.map +1 -0
- package/dist/react/jsx/utils/validateStringFunction.js +21 -29
- package/dist/react/jsx/utils/validateStringFunction.js.map +1 -0
- package/dist/react/jsx/wrapJsx.js +192 -375
- package/dist/react/jsx/wrapJsx.js.map +1 -0
- package/dist/react/parse/addVitePlugin/index.js +40 -34
- package/dist/react/parse/addVitePlugin/index.js.map +1 -0
- package/dist/react/parse/addVitePlugin/installCompiler.js +18 -20
- package/dist/react/parse/addVitePlugin/installCompiler.js.map +1 -0
- package/dist/react/parse/addVitePlugin/updateViteConfig.js +107 -111
- package/dist/react/parse/addVitePlugin/updateViteConfig.js.map +1 -0
- package/dist/react/parse/addVitePlugin/utils/addCompilerImport.js +23 -26
- package/dist/react/parse/addVitePlugin/utils/addCompilerImport.js.map +1 -0
- package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.js +29 -43
- package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.js.map +1 -0
- package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.js +70 -104
- package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.js.map +1 -0
- package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.js +23 -29
- package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.js.map +1 -0
- package/dist/react/parse/createDictionaryUpdates.js +121 -185
- package/dist/react/parse/createDictionaryUpdates.js.map +1 -0
- package/dist/react/parse/createInlineUpdates.js +123 -139
- package/dist/react/parse/createInlineUpdates.js.map +1 -0
- package/dist/react/parse/wrapContent.js +131 -156
- package/dist/react/parse/wrapContent.js.map +1 -0
- package/dist/react/utils/flattenDictionary.js +55 -70
- package/dist/react/utils/flattenDictionary.js.map +1 -0
- package/dist/react/utils/getEntryAndMetadata.js +14 -10
- package/dist/react/utils/getEntryAndMetadata.js.map +1 -0
- package/dist/react/utils/getVariableName.js +36 -33
- package/dist/react/utils/getVariableName.js.map +1 -0
- package/dist/setup/detectFramework.js +85 -102
- package/dist/setup/detectFramework.js.map +1 -0
- package/dist/setup/frameworkUtils.js +17 -28
- package/dist/setup/frameworkUtils.js.map +1 -0
- package/dist/setup/userInput.js +24 -31
- package/dist/setup/userInput.js.map +1 -0
- package/dist/setup/wizard.js +141 -143
- package/dist/setup/wizard.js.map +1 -0
- package/dist/state/mintlifyRefMap.js +12 -9
- package/dist/state/mintlifyRefMap.js.map +1 -0
- package/dist/state/recentDownloads.js +26 -23
- package/dist/state/recentDownloads.js.map +1 -0
- package/dist/state/translateWarnings.js +17 -8
- package/dist/state/translateWarnings.js.map +1 -0
- package/dist/translation/parse.js +77 -98
- package/dist/translation/parse.js.map +1 -0
- package/dist/translation/stage.js +28 -43
- package/dist/translation/stage.js.map +1 -0
- package/dist/translation/validate.js +68 -91
- package/dist/translation/validate.js.map +1 -0
- package/dist/types/libraries.js +93 -91
- package/dist/types/libraries.js.map +1 -0
- package/dist/types/parsing.js +19 -10
- package/dist/types/parsing.js.map +1 -0
- package/dist/utils/addExplicitAnchorIds.js +270 -389
- package/dist/utils/addExplicitAnchorIds.js.map +1 -0
- package/dist/utils/calculateTimeoutMs.js +11 -6
- package/dist/utils/calculateTimeoutMs.js.map +1 -0
- package/dist/utils/constants.js +15 -12
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/credentials.js +67 -114
- package/dist/utils/credentials.js.map +1 -0
- package/dist/utils/fetch.js +22 -20
- package/dist/utils/fetch.js.map +1 -0
- package/dist/utils/flattenJsonFiles.js +27 -34
- package/dist/utils/flattenJsonFiles.js.map +1 -0
- package/dist/utils/gitDiff.js +30 -32
- package/dist/utils/gitDiff.js.map +1 -0
- package/dist/utils/gt.js +7 -2
- package/dist/utils/gt.js.map +1 -0
- package/dist/utils/hash.js +14 -9
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/headers.js +10 -13
- package/dist/utils/headers.js.map +1 -0
- package/dist/utils/installPackage.js +70 -75
- package/dist/utils/installPackage.js.map +1 -0
- package/dist/utils/localizeRelativeAssets.js +114 -157
- package/dist/utils/localizeRelativeAssets.js.map +1 -0
- package/dist/utils/localizeStaticImports.js +229 -371
- package/dist/utils/localizeStaticImports.js.map +1 -0
- package/dist/utils/localizeStaticUrls.js +241 -424
- package/dist/utils/localizeStaticUrls.js.map +1 -0
- package/dist/utils/mintlifyTitleFallback.js +64 -72
- package/dist/utils/mintlifyTitleFallback.js.map +1 -0
- package/dist/utils/monorepoVersionCheck.js +177 -215
- package/dist/utils/monorepoVersionCheck.js.map +1 -0
- package/dist/utils/packageInfo.js +17 -16
- package/dist/utils/packageInfo.js.map +1 -0
- package/dist/utils/packageJson.js +51 -66
- package/dist/utils/packageJson.js.map +1 -0
- package/dist/utils/packageManager.js +237 -260
- package/dist/utils/packageManager.js.map +1 -0
- package/dist/utils/parse/needsCJS.js +36 -69
- package/dist/utils/parse/needsCJS.js.map +1 -0
- package/dist/utils/persistPostprocessHashes.js +30 -32
- package/dist/utils/persistPostprocessHashes.js.map +1 -0
- package/dist/utils/processAnchorIds.js +32 -54
- package/dist/utils/processAnchorIds.js.map +1 -0
- package/dist/utils/processOpenApi.js +469 -578
- package/dist/utils/processOpenApi.js.map +1 -0
- package/dist/utils/resolveMintlifyRefs.js +89 -105
- package/dist/utils/resolveMintlifyRefs.js.map +1 -0
- package/dist/utils/resolvePublish.js +46 -54
- package/dist/utils/resolvePublish.js.map +1 -0
- package/dist/utils/sanitizeFileContent.js +20 -27
- package/dist/utils/sanitizeFileContent.js.map +1 -0
- package/dist/utils/sharedStaticAssets.js +248 -366
- package/dist/utils/sharedStaticAssets.js.map +1 -0
- package/dist/utils/splitMintlifyLanguageRefs.js +208 -282
- package/dist/utils/splitMintlifyLanguageRefs.js.map +1 -0
- package/dist/utils/validateMdx.js +26 -23
- package/dist/utils/validateMdx.js.map +1 -0
- package/dist/utils/wrapPlainUrls.js +58 -70
- package/dist/utils/wrapPlainUrls.js.map +1 -0
- package/dist/workflows/download.js +92 -126
- package/dist/workflows/download.js.map +1 -0
- package/dist/workflows/enqueue.js +47 -54
- package/dist/workflows/enqueue.js.map +1 -0
- package/dist/workflows/publish.js +29 -29
- package/dist/workflows/publish.js.map +1 -0
- package/dist/workflows/setupProject.js +39 -40
- package/dist/workflows/setupProject.js.map +1 -0
- package/dist/workflows/stage.js +61 -65
- package/dist/workflows/stage.js.map +1 -0
- package/dist/workflows/steps/BranchStep.js +118 -163
- package/dist/workflows/steps/BranchStep.js.map +1 -0
- package/dist/workflows/steps/DownloadStep.js +107 -137
- package/dist/workflows/steps/DownloadStep.js.map +1 -0
- package/dist/workflows/steps/EnqueueStep.js +32 -32
- package/dist/workflows/steps/EnqueueStep.js.map +1 -0
- package/dist/workflows/steps/PollJobsStep.js +208 -292
- package/dist/workflows/steps/PollJobsStep.js.map +1 -0
- package/dist/workflows/steps/PublishStep.js +33 -38
- package/dist/workflows/steps/PublishStep.js.map +1 -0
- package/dist/workflows/steps/SetupStep.js +71 -72
- package/dist/workflows/steps/SetupStep.js.map +1 -0
- package/dist/workflows/steps/TagStep.js +39 -44
- package/dist/workflows/steps/TagStep.js.map +1 -0
- package/dist/workflows/steps/UploadSourcesStep.js +108 -140
- package/dist/workflows/steps/UploadSourcesStep.js.map +1 -0
- package/dist/workflows/steps/UploadTranslationsStep.js +61 -71
- package/dist/workflows/steps/UploadTranslationsStep.js.map +1 -0
- package/dist/workflows/steps/UserEditDiffsStep.js +32 -34
- package/dist/workflows/steps/UserEditDiffsStep.js.map +1 -0
- package/dist/workflows/steps/WorkflowStep.js +6 -2
- package/dist/workflows/steps/WorkflowStep.js.map +1 -0
- package/dist/workflows/upload.js +45 -46
- package/dist/workflows/upload.js.map +1 -0
- package/package.json +14 -7
package/dist/console/index.js
CHANGED
|
@@ -1,55 +1,58 @@
|
|
|
1
|
-
import { BRANCH_COMPONENT } from
|
|
2
|
-
import {
|
|
3
|
-
import { formatCodeClamp } from
|
|
1
|
+
import { BRANCH_COMPONENT } from "../react/jsx/utils/constants.js";
|
|
2
|
+
import { colorizeComponent, colorizeContent, colorizeFilepath, colorizeFunctionName, colorizeIdString, colorizeLine } from "./colors.js";
|
|
3
|
+
import { formatCodeClamp } from "./formatting.js";
|
|
4
|
+
//#region src/console/index.ts
|
|
4
5
|
const withWillErrorInNextVersion = (message) => `${message} (This will become an error in the next major version of the CLI.)`;
|
|
5
|
-
// Derive function related errors
|
|
6
6
|
const withDeriveComponentError = (message) => `<Derive> rules violation: ${message}`;
|
|
7
7
|
const withDeriveFunctionError = (message) => `derive() rules violation: ${message}`;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export const warnDuplicateFunctionDefinitionSync = (file, functionName, location) => withLocation(file, `Function ${colorizeFunctionName(functionName)} is defined multiple times. Only the first definition will be used.`, location);
|
|
31
|
-
export const warnInvalidDeriveInitSync = (file, functionName, location) => withLocation(file, withDeriveComponentError(`The definition for ${colorizeFunctionName(functionName)} could not be resolved. When using arrow syntax to define a derivable (statically analyzable) function, the right hand side or the assignment MUST only contain the arrow function itself and no other expressions.
|
|
8
|
+
const warnApiKeyInConfigSync = (optionsFilepath) => `${colorizeFilepath(optionsFilepath)}: Your API key is exposed! Remove it from the file and include it as an environment variable.`;
|
|
9
|
+
const warnVariablePropSync = (file, attrName, value, location) => withLocation(file, `${colorizeComponent("<T>")} component has dynamic attribute ${colorizeIdString(attrName)} with value: ${colorizeContent(value)}. Change ${colorizeIdString(attrName)} to ensure this content is translated.`, location);
|
|
10
|
+
const warnInvalidReturnSync = (file, functionName, expression, location) => withLocation(file, withDeriveComponentError(`Function ${colorizeFunctionName(functionName)} does not return a derivable (statically analyzable) expression. ${colorizeFunctionName(functionName)} must return either (1) a derivable string literal, (2) another derivable function invocation, (3) derivable JSX content, or (4) a ternary expression. Instead got:\n${colorizeContent(expression)}`), location);
|
|
11
|
+
const warnMissingReturnSync = (file, functionName, location) => withLocation(file, `Function ${colorizeFunctionName(functionName)} is wrapped in ${colorizeComponent("<Derive>")} (formerly ${colorizeComponent("<Static>")}) tags but does not have an explicit return statement. Derivable functions must have an explicit return statement.`, location);
|
|
12
|
+
const warnHasUnwrappedExpressionSync = (file, unwrappedExpressions, id, location) => withLocation(file, `${colorizeComponent("<T>")} component${id ? ` with id ${colorizeIdString(id)}` : ""} has children that could change at runtime. Use a variable component like ${colorizeComponent("<Var>")} to ensure this content is translated.\n${colorizeContent(unwrappedExpressions.join("\n"))}`, location);
|
|
13
|
+
const warnFailedToConstructJsxTreeSync = (file, code, location) => withLocation(file, `Failed to construct JsxTree! Call expression is not a valid createElement call: ${colorizeContent(code)}`, location);
|
|
14
|
+
const warnNestedTComponent = (file, location) => withLocation(file, `Found nested <T> component. <T> components cannot be directly nested.`, location);
|
|
15
|
+
const warnNestedInternalTComponent = (file, location) => withLocation(file, `DEBUG: Found nested <GtInternalTranslateJsx> component. <GtInternalTranslateJsx> components cannot be directly nested.`, location);
|
|
16
|
+
const warnNonStaticExpressionSync = (file, attrName, value, location) => withLocation(file, `Found non-static expression for attribute ${colorizeIdString(attrName)}: ${colorizeContent(value)}. Change "${colorizeIdString(attrName)}" to ensure this content is translated.`, location);
|
|
17
|
+
const warnInvalidMaxCharsSync = (file, value, location) => withLocation(file, `Found invalid maxChars value: ${colorizeContent(value)}. Change the value to a valid number to ensure this content is translated.`, location);
|
|
18
|
+
const warnInvalidFormatSync = (file, value, location) => withLocation(file, `Found invalid $format value: ${colorizeContent(value)}. Must be one of: 'ICU', 'STRING', 'I18NEXT'.`, location);
|
|
19
|
+
const warnInvalidIcuSync = (file, value, error, location) => withWillErrorInNextVersion(withLocation(file, `Found invalid ICU string: ${colorizeContent(value)}. Change the value to a valid ICU to ensure this content is translated. Error message: ${error}.`, location));
|
|
20
|
+
const warnTemplateLiteralSync = (file, value, location) => withLocation(file, `Found template literal with quasis (${colorizeContent(value)}). Change the template literal to a string to ensure this content is translated.`, location);
|
|
21
|
+
const warnNonStringSync = (file, value, location) => withLocation(file, `Found non-string literal (${colorizeContent(value)}). Change the value to a string literal to ensure this content is translated.`, location);
|
|
22
|
+
const warnAsyncUseGT = (file, location) => withLocation(file, `Found useGT() in an async function. Use getGT() instead, or make the function synchronous.`, location);
|
|
23
|
+
const warnSyncGetGT = (file, location) => withLocation(file, `Found getGT() in a synchronous function. Use useGT() instead, or make the function async.`, location);
|
|
24
|
+
const warnTernarySync = (file, location) => withLocation(file, "Found ternary expression. A Branch component may be more appropriate here.", location);
|
|
25
|
+
const withLocation = (file, message, location) => `${colorizeFilepath(file)}${location ? ` (${colorizeLine(location)})` : ""}: ${message}`;
|
|
26
|
+
const warnFunctionNotFoundSync = (file, functionName, location) => withLocation(file, `Function ${colorizeFunctionName(functionName)} definition could not be resolved. This might affect translation resolution for this ${colorizeComponent("<T>")} component.`, location);
|
|
27
|
+
const warnInvalidDeclareVarNameSync = (file, value, location) => withLocation(file, `Found invalid declareVar() $name tag. Must be a derivable (statically analyzable) expression. Received: ${colorizeContent(value)}.`, location);
|
|
28
|
+
const warnDuplicateFunctionDefinitionSync = (file, functionName, location) => withLocation(file, `Function ${colorizeFunctionName(functionName)} is defined multiple times. Only the first definition will be used.`, location);
|
|
29
|
+
const warnInvalidDeriveInitSync = (file, functionName, location) => withLocation(file, withDeriveComponentError(`The definition for ${colorizeFunctionName(functionName)} could not be resolved. When using arrow syntax to define a derivable (statically analyzable) function, the right hand side or the assignment MUST only contain the arrow function itself and no other expressions.
|
|
32
30
|
Example: ${colorizeContent(`const ${colorizeFunctionName(functionName)} = () => { ... }`)}
|
|
33
31
|
Invalid: ${colorizeContent(`const ${colorizeFunctionName(functionName)} = [() => { ... }][0]`)}`), location);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
32
|
+
const warnDataAttrOnBranch = (file, attrName, location) => withLocation(file, `${colorizeComponent(`<${BRANCH_COMPONENT}>`)} component ignores attributes prefixed with ${colorizeIdString("\"data-\"")}. Found ${colorizeIdString(attrName)}. Remove it or use a different attribute name.`, location);
|
|
33
|
+
const warnRecursiveFunctionCallSync = (file, functionName, location) => withLocation(file, withDeriveComponentError(`Recursive function call detected: ${colorizeFunctionName(functionName)}. A derivable (statically analyzable) function cannot use recursive calls to construct its result.`), location);
|
|
34
|
+
const warnDeriveFunctionNotWrappedSync = (file, functionName, location) => withLocation(file, withDeriveFunctionError(`Could not resolve ${colorizeFunctionName(formatCodeClamp(functionName))}. This call is not wrapped in derive() (formerly declareStatic()). Ensure the function is properly wrapped with derive() and does not have circular import dependencies.`), location);
|
|
35
|
+
const warnDeriveNonConstVariableSync = (file, varName, kind, location) => withLocation(file, withDeriveFunctionError(`Variable ${colorizeFunctionName(varName)} is declared with '${kind}' but only 'const' declarations can be resolved statically. Change it to 'const'.`), location);
|
|
36
|
+
const warnDeriveFunctionNoResultsSync = (file, functionName, location) => withLocation(file, withDeriveFunctionError(`Could not resolve ${colorizeFunctionName(formatCodeClamp(functionName))}. derive() (formerly declareStatic()) can only receive function invocations and cannot use undefined values or looped calls to construct its result.`), location);
|
|
37
|
+
const warnAutoderiveNoResultsSync = (file, expression, location) => withLocation(file, `Autoderive could not resolve ${colorizeFunctionName(formatCodeClamp(expression))}. Only function calls with statically determinable return values can be used directly in t(). Consider wrapping with derive() for explicit derivation, or use an interpolation variable instead.`, location);
|
|
38
|
+
const warnDeriveUnresolvableValueSync = (file, key, location) => withLocation(file, withDeriveFunctionError(`Object property ${colorizeFunctionName(formatCodeClamp(key))} could not be resolved to a static string value. Only string literals, template literals, conditionals, and function calls returning strings are supported.`), location);
|
|
39
|
+
const warnDeriveCircularSpreadSync = (file, varName, location) => withLocation(file, withDeriveFunctionError(`Circular spread detected involving ${colorizeFunctionName(varName)}. Spread references that form a cycle cannot be resolved statically.`), location);
|
|
40
|
+
const warnDeriveDestructuringSync = (file, varName, location) => withLocation(file, withDeriveFunctionError(`Variable ${colorizeFunctionName(varName)} uses destructuring syntax, which is not yet supported in derive(). Assign the value to a const variable directly instead.`), location);
|
|
41
|
+
const warnDeriveOptionalChainingSync = (file, code, location) => withLocation(file, withDeriveFunctionError(`Optional chaining (${colorizeFunctionName(formatCodeClamp(code))}) is not supported in derive(). Optional chaining implies the value could be undefined, which cannot be resolved statically. Use a non-optional access instead.`), location);
|
|
42
|
+
const warnUnresolvedImportSync = (file, functionName, importPath, location) => withLocation(file, `Could not resolve import ${colorizeFunctionName(importPath)} for function ${colorizeFunctionName(functionName)}. Translation strings inside this function will not be extracted.`, location);
|
|
43
|
+
const noLocalesError = `No target locales were found. Add locales to gt.config.json or pass them with the --locales flag.`;
|
|
44
|
+
const noDefaultLocaleError = `No default locale was found. Add defaultLocale to gt.config.json or pass it with --default-locale.`;
|
|
45
|
+
const noFilesError = `The files configuration is missing or invalid. Check the files section in gt.config.json and try again.`;
|
|
46
|
+
const noSourceFileError = `No source translation file was found. Check your translations directory and default locale configuration.`;
|
|
47
|
+
const noSupportedFormatError = `The translation file format is not supported. Use a supported file extension in translationsDir.`;
|
|
48
|
+
const noApiKeyError = `No API key was found. Pass --api-key or set the GT_API_KEY environment variable.`;
|
|
49
|
+
const devApiKeyError = `Development API keys cannot be used with the General Translation API. Use a production API key instead.\nGenerate a production API key with: npx gt auth -t production`;
|
|
50
|
+
const noProjectIdError = `No project ID was found. Pass --project-id, add projectId to gt.config.json, or set the GT_PROJECT_ID environment variable.`;
|
|
51
|
+
const noVersionIdError = `No version ID was found. Pass --version-id or add _versionId to gt.config.json.`;
|
|
52
|
+
const invalidConfigurationError = `The files configuration cannot be used for this operation. Provide a valid download configuration or set --publish true to upload translations to the CDN.`;
|
|
53
|
+
const branchResolutionError = `The current git branch could not be resolved. Specify a branch explicitly or run the command from a git worktree with branch metadata available.`;
|
|
54
|
+
const withOriginalError = (message, error) => error != null ? `${message} Original error: ${String(error)}` : message;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { branchResolutionError, devApiKeyError, invalidConfigurationError, noApiKeyError, noDefaultLocaleError, noFilesError, noLocalesError, noProjectIdError, noSourceFileError, noSupportedFormatError, noVersionIdError, warnApiKeyInConfigSync, warnAsyncUseGT, warnAutoderiveNoResultsSync, warnDataAttrOnBranch, warnDeriveCircularSpreadSync, warnDeriveDestructuringSync, warnDeriveFunctionNoResultsSync, warnDeriveFunctionNotWrappedSync, warnDeriveNonConstVariableSync, warnDeriveOptionalChainingSync, warnDeriveUnresolvableValueSync, warnDuplicateFunctionDefinitionSync, warnFailedToConstructJsxTreeSync, warnFunctionNotFoundSync, warnHasUnwrappedExpressionSync, warnInvalidDeclareVarNameSync, warnInvalidDeriveInitSync, warnInvalidFormatSync, warnInvalidIcuSync, warnInvalidMaxCharsSync, warnInvalidReturnSync, warnMissingReturnSync, warnNestedInternalTComponent, warnNestedTComponent, warnNonStaticExpressionSync, warnNonStringSync, warnRecursiveFunctionCallSync, warnSyncGetGT, warnTemplateLiteralSync, warnTernarySync, warnUnresolvedImportSync, warnVariablePropSync, withLocation, withOriginalError };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/console/index.ts"],"sourcesContent":["import { BRANCH_COMPONENT } from '../react/jsx/utils/constants.js';\nimport {\n colorizeFilepath,\n colorizeComponent,\n colorizeIdString,\n colorizeContent,\n colorizeLine,\n colorizeFunctionName,\n} from './colors.js';\nimport { formatCodeClamp } from './formatting.js';\n\nconst withWillErrorInNextVersion = (message: string): string =>\n `${message} (This will become an error in the next major version of the CLI.)`;\n\n// Derive function related errors\nconst withDeriveComponentError = (message: string): string =>\n `<Derive> rules violation: ${message}`;\n\nconst withDeriveFunctionError = (message: string): string =>\n `derive() rules violation: ${message}`;\n// Synchronous wrappers for backward compatibility\nexport const warnApiKeyInConfigSync = (optionsFilepath: string): string =>\n `${colorizeFilepath(\n optionsFilepath\n )}: Your API key is exposed! Remove it from the file and include it as an environment variable.`;\n\nexport const warnVariablePropSync = (\n file: string,\n attrName: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `${colorizeComponent('<T>')} component has dynamic attribute ${colorizeIdString(attrName)} with value: ${colorizeContent(\n value\n )}. Change ${colorizeIdString(attrName)} to ensure this content is translated.`,\n location\n );\n\nexport const warnInvalidReturnSync = (\n file: string,\n functionName: string,\n expression: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveComponentError(\n `Function ${colorizeFunctionName(functionName)} does not return a derivable (statically analyzable) expression. ${colorizeFunctionName(functionName)} must return either (1) a derivable string literal, (2) another derivable function invocation, (3) derivable JSX content, or (4) a ternary expression. Instead got:\\n${colorizeContent(expression)}`\n ),\n location\n );\n\n// TODO: this is temporary until we handle implicit returns\nexport const warnMissingReturnSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Function ${colorizeFunctionName(functionName)} is wrapped in ${colorizeComponent('<Derive>')} (formerly ${colorizeComponent('<Static>')}) tags but does not have an explicit return statement. Derivable functions must have an explicit return statement.`,\n location\n );\n\nexport const warnHasUnwrappedExpressionSync = (\n file: string,\n unwrappedExpressions: string[],\n id?: string,\n location?: string\n): string =>\n withLocation(\n file,\n `${colorizeComponent('<T>')} component${\n id ? ` with id ${colorizeIdString(id)}` : ''\n } has children that could change at runtime. Use a variable component like ${colorizeComponent(\n '<Var>'\n )} to ensure this content is translated.\\n${colorizeContent(\n unwrappedExpressions.join('\\n')\n )}`,\n location\n );\n\nexport const warnFailedToConstructJsxTreeSync = (\n file: string,\n code: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Failed to construct JsxTree! Call expression is not a valid createElement call: ${colorizeContent(code)}`,\n location\n );\n\nexport const warnNestedTComponent = (file: string, location?: string): string =>\n withLocation(\n file,\n `Found nested <T> component. <T> components cannot be directly nested.`,\n location\n );\n\nexport const warnNestedInternalTComponent = (\n file: string,\n location?: string\n): string =>\n withLocation(\n file,\n `DEBUG: Found nested <GtInternalTranslateJsx> component. <GtInternalTranslateJsx> components cannot be directly nested.`,\n location\n );\n\nexport const warnNonStaticExpressionSync = (\n file: string,\n attrName: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found non-static expression for attribute ${colorizeIdString(\n attrName\n )}: ${colorizeContent(value)}. Change \"${colorizeIdString(attrName)}\" to ensure this content is translated.`,\n location\n );\n\nexport const warnInvalidMaxCharsSync = (\n file: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found invalid maxChars value: ${colorizeContent(value)}. Change the value to a valid number to ensure this content is translated.`,\n location\n );\n\nexport const warnInvalidFormatSync = (\n file: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found invalid $format value: ${colorizeContent(value)}. Must be one of: 'ICU', 'STRING', 'I18NEXT'.`,\n location\n );\n\nexport const warnInvalidIcuSync = (\n file: string,\n value: string,\n error: string,\n location?: string\n): string =>\n withWillErrorInNextVersion(\n withLocation(\n file,\n `Found invalid ICU string: ${colorizeContent(value)}. Change the value to a valid ICU to ensure this content is translated. Error message: ${error}.`,\n location\n )\n );\n\nexport const warnTemplateLiteralSync = (\n file: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found template literal with quasis (${colorizeContent(value)}). Change the template literal to a string to ensure this content is translated.`,\n location\n );\n\nexport const warnNonStringSync = (\n file: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found non-string literal (${colorizeContent(value)}). Change the value to a string literal to ensure this content is translated.`,\n location\n );\n\nexport const warnAsyncUseGT = (file: string, location?: string): string =>\n withLocation(\n file,\n `Found useGT() in an async function. Use getGT() instead, or make the function synchronous.`,\n location\n );\n\nexport const warnSyncGetGT = (file: string, location?: string): string =>\n withLocation(\n file,\n `Found getGT() in a synchronous function. Use useGT() instead, or make the function async.`,\n location\n );\n\nexport const warnTernarySync = (file: string, location?: string): string =>\n withLocation(\n file,\n 'Found ternary expression. A Branch component may be more appropriate here.',\n location\n );\n\nexport const withLocation = (\n file: string,\n message: string,\n location?: string\n): string =>\n `${colorizeFilepath(file)}${location ? ` (${colorizeLine(location)})` : ''}: ${message}`;\n\nexport const warnFunctionNotFoundSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Function ${colorizeFunctionName(functionName)} definition could not be resolved. This might affect translation resolution for this ${colorizeComponent('<T>')} component.`,\n location\n );\n\nexport const warnInvalidDeclareVarNameSync = (\n file: string,\n value: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Found invalid declareVar() $name tag. Must be a derivable (statically analyzable) expression. Received: ${colorizeContent(value)}.`,\n location\n );\n\nexport const warnDuplicateFunctionDefinitionSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Function ${colorizeFunctionName(functionName)} is defined multiple times. Only the first definition will be used.`,\n location\n );\n\nexport const warnInvalidDeriveInitSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveComponentError(\n `The definition for ${colorizeFunctionName(functionName)} could not be resolved. When using arrow syntax to define a derivable (statically analyzable) function, the right hand side or the assignment MUST only contain the arrow function itself and no other expressions.\nExample: ${colorizeContent(`const ${colorizeFunctionName(functionName)} = () => { ... }`)}\nInvalid: ${colorizeContent(`const ${colorizeFunctionName(functionName)} = [() => { ... }][0]`)}`\n ),\n location\n );\n\nexport const warnDataAttrOnBranch = (\n file: string,\n attrName: string,\n location?: string\n): string =>\n withLocation(\n file,\n `${colorizeComponent(`<${BRANCH_COMPONENT}>`)} component ignores attributes prefixed with ${colorizeIdString('\"data-\"')}. Found ${colorizeIdString(attrName)}. Remove it or use a different attribute name.`,\n location\n );\n\nexport const warnRecursiveFunctionCallSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveComponentError(\n `Recursive function call detected: ${colorizeFunctionName(functionName)}. A derivable (statically analyzable) function cannot use recursive calls to construct its result.`\n ),\n location\n );\n\nexport const warnDeriveFunctionNotWrappedSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Could not resolve ${colorizeFunctionName(formatCodeClamp(functionName))}. This call is not wrapped in derive() (formerly declareStatic()). Ensure the function is properly wrapped with derive() and does not have circular import dependencies.`\n ),\n location\n );\n\nexport const warnDeriveNonConstVariableSync = (\n file: string,\n varName: string,\n kind: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Variable ${colorizeFunctionName(varName)} is declared with '${kind}' but only 'const' declarations can be resolved statically. Change it to 'const'.`\n ),\n location\n );\n\nexport const warnDeriveFunctionNoResultsSync = (\n file: string,\n functionName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Could not resolve ${colorizeFunctionName(formatCodeClamp(functionName))}. derive() (formerly declareStatic()) can only receive function invocations and cannot use undefined values or looped calls to construct its result.`\n ),\n location\n );\n\nexport const warnAutoderiveNoResultsSync = (\n file: string,\n expression: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Autoderive could not resolve ${colorizeFunctionName(formatCodeClamp(expression))}. Only function calls with statically determinable return values can be used directly in t(). Consider wrapping with derive() for explicit derivation, or use an interpolation variable instead.`,\n location\n );\n\nexport const warnDeriveUnresolvableValueSync = (\n file: string,\n key: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Object property ${colorizeFunctionName(formatCodeClamp(key))} could not be resolved to a static string value. Only string literals, template literals, conditionals, and function calls returning strings are supported.`\n ),\n location\n );\n\nexport const warnDeriveCircularSpreadSync = (\n file: string,\n varName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Circular spread detected involving ${colorizeFunctionName(varName)}. Spread references that form a cycle cannot be resolved statically.`\n ),\n location\n );\n\nexport const warnDeriveDestructuringSync = (\n file: string,\n varName: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Variable ${colorizeFunctionName(varName)} uses destructuring syntax, which is not yet supported in derive(). Assign the value to a const variable directly instead.`\n ),\n location\n );\n\nexport const warnDeriveOptionalChainingSync = (\n file: string,\n code: string,\n location?: string\n): string =>\n withLocation(\n file,\n withDeriveFunctionError(\n `Optional chaining (${colorizeFunctionName(formatCodeClamp(code))}) is not supported in derive(). Optional chaining implies the value could be undefined, which cannot be resolved statically. Use a non-optional access instead.`\n ),\n location\n );\n\nexport const warnUnresolvedImportSync = (\n file: string,\n functionName: string,\n importPath: string,\n location?: string\n): string =>\n withLocation(\n file,\n `Could not resolve import ${colorizeFunctionName(importPath)} for function ${colorizeFunctionName(functionName)}. Translation strings inside this function will not be extracted.`,\n location\n );\n\n// Re-export error messages\nexport const noLocalesError = `No target locales were found. Add locales to gt.config.json or pass them with the --locales flag.`;\nexport const noDefaultLocaleError = `No default locale was found. Add defaultLocale to gt.config.json or pass it with --default-locale.`;\nexport const noFilesError = `The files configuration is missing or invalid. Check the files section in gt.config.json and try again.`;\nexport const noSourceFileError = `No source translation file was found. Check your translations directory and default locale configuration.`;\nexport const noSupportedFormatError = `The translation file format is not supported. Use a supported file extension in translationsDir.`;\nexport const noApiKeyError = `No API key was found. Pass --api-key or set the GT_API_KEY environment variable.`;\nexport const devApiKeyError = `Development API keys cannot be used with the General Translation API. Use a production API key instead.\\nGenerate a production API key with: npx gt auth -t production`;\nexport const noProjectIdError = `No project ID was found. Pass --project-id, add projectId to gt.config.json, or set the GT_PROJECT_ID environment variable.`;\nexport const noVersionIdError = `No version ID was found. Pass --version-id or add _versionId to gt.config.json.`;\nexport const invalidConfigurationError = `The files configuration cannot be used for this operation. Provide a valid download configuration or set --publish true to upload translations to the CDN.`;\nexport const branchResolutionError = `The current git branch could not be resolved. Specify a branch explicitly or run the command from a git worktree with branch metadata available.`;\n\nexport const withOriginalError = (message: string, error: unknown): string =>\n error != null ? `${message} Original error: ${String(error)}` : message;\n"],"mappings":";;;;AAWA,MAAM,8BAA8B,YAClC,GAAG,QAAQ;AAGb,MAAM,4BAA4B,YAChC,6BAA6B;AAE/B,MAAM,2BAA2B,YAC/B,6BAA6B;AAE/B,MAAa,0BAA0B,oBACrC,GAAG,iBACD,gBACD,CAAC;AAEJ,MAAa,wBACX,MACA,UACA,OACA,aAEA,aACE,MACA,GAAG,kBAAkB,MAAM,CAAC,mCAAmC,iBAAiB,SAAS,CAAC,eAAe,gBACvG,MACD,CAAC,WAAW,iBAAiB,SAAS,CAAC,yCACxC,SACD;AAEH,MAAa,yBACX,MACA,cACA,YACA,aAEA,aACE,MACA,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A,aACE,MACA,wBACE,qBAAqB,qBAAqB,gBAAgB,aAAa,CAAC,CAAC,sJAC1E,EACD,SACD;AAEH,MAAa,+BACX,MACA,YACA,aAEA,aACE,MACA,gCAAgC,qBAAqB,gBAAgB,WAAW,CAAC,CAAC,mMAClF,SACD;AAEH,MAAa,mCACX,MACA,KACA,aAEA,aACE,MACA,wBACE,mBAAmB,qBAAqB,gBAAgB,IAAI,CAAC,CAAC,6JAC/D,EACD,SACD;AAEH,MAAa,gCACX,MACA,SACA,aAEA,aACE,MACA,wBACE,sCAAsC,qBAAqB,QAAQ,CAAC,sEACrE,EACD,SACD;AAEH,MAAa,+BACX,MACA,SACA,aAEA,aACE,MACA,wBACE,YAAY,qBAAqB,QAAQ,CAAC,4HAC3C,EACD,SACD;AAEH,MAAa,kCACX,MACA,MACA,aAEA,aACE,MACA,wBACE,sBAAsB,qBAAqB,gBAAgB,KAAK,CAAC,CAAC,iKACnE,EACD,SACD;AAEH,MAAa,4BACX,MACA,cACA,YACA,aAEA,aACE,MACA,4BAA4B,qBAAqB,WAAW,CAAC,gBAAgB,qBAAqB,aAAa,CAAC,oEAChH,SACD;AAGH,MAAa,iBAAiB;AAC9B,MAAa,uBAAuB;AACpC,MAAa,eAAe;AAC5B,MAAa,oBAAoB;AACjC,MAAa,yBAAyB;AACtC,MAAa,gBAAgB;AAC7B,MAAa,iBAAiB;AAC9B,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,4BAA4B;AACzC,MAAa,wBAAwB;AAErC,MAAa,qBAAqB,SAAiB,UACjD,SAAS,OAAO,GAAG,QAAQ,mBAAmB,OAAO,MAAM,KAAK"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { LocaleOption } from './inkTypes.js';
|
|
2
|
+
export declare function OptionRow({ active, selected, label, hint, width, }: {
|
|
3
|
+
active: boolean;
|
|
4
|
+
selected?: boolean;
|
|
5
|
+
label: string;
|
|
6
|
+
hint?: string;
|
|
7
|
+
width?: number;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function SelectedTags({ selectedLocales, active, activeIndex, width, }: {
|
|
10
|
+
selectedLocales: string[];
|
|
11
|
+
active: boolean;
|
|
12
|
+
activeIndex: number;
|
|
13
|
+
width: number;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
15
|
+
export declare function LocaleOptionsList({ options, activeIndex, width, }: {
|
|
16
|
+
options: LocaleOption[];
|
|
17
|
+
activeIndex: number;
|
|
18
|
+
width: number;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function RemainingMatches({ total, visible, }: {
|
|
21
|
+
total: number;
|
|
22
|
+
visible: number;
|
|
23
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { stripAnsi } from "./logging.js";
|
|
2
|
+
import { getLocaleCodeWidth } from "./inkLocaleData.js";
|
|
3
|
+
import { truncate } from "./inkUtils.js";
|
|
4
|
+
import { Box, Text } from "ink";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/console/inkFields.tsx
|
|
7
|
+
function OptionRow({ active, selected, label, hint, width }) {
|
|
8
|
+
const text = `${active ? ">" : " "} ${selected == null ? "" : selected ? "[x] " : "[ ] "}${stripAnsi(label)}${hint ? ` ${stripAnsi(hint)}` : ""}`;
|
|
9
|
+
return active ? /* @__PURE__ */ jsx(Text, {
|
|
10
|
+
color: "cyan",
|
|
11
|
+
bold: true,
|
|
12
|
+
children: width ? truncate(text, width) : text
|
|
13
|
+
}) : /* @__PURE__ */ jsx(Text, { children: width ? truncate(text, width) : text });
|
|
14
|
+
}
|
|
15
|
+
function SelectedTags({ selectedLocales, active, activeIndex, width }) {
|
|
16
|
+
if (selectedLocales.length === 0) return null;
|
|
17
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
18
|
+
width,
|
|
19
|
+
flexWrap: "wrap",
|
|
20
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
21
|
+
dimColor: true,
|
|
22
|
+
children: "Selected "
|
|
23
|
+
}), selectedLocales.map((locale, index) => {
|
|
24
|
+
const isActive = active && index === activeIndex;
|
|
25
|
+
return /* @__PURE__ */ jsxs(Text, { children: [/* @__PURE__ */ jsx(Text, {
|
|
26
|
+
backgroundColor: isActive ? "cyanBright" : "gray",
|
|
27
|
+
color: "black",
|
|
28
|
+
bold: isActive,
|
|
29
|
+
children: ` ${locale} `
|
|
30
|
+
}), index < selectedLocales.length - 1 ? /* @__PURE__ */ jsx(Text, { children: " " }) : null] }, locale);
|
|
31
|
+
})]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function LocaleOptionsList({ options, activeIndex, width }) {
|
|
35
|
+
const codeWidth = getLocaleCodeWidth();
|
|
36
|
+
return /* @__PURE__ */ jsx(Box, {
|
|
37
|
+
flexDirection: "column",
|
|
38
|
+
marginTop: 1,
|
|
39
|
+
children: options.map((option, index) => /* @__PURE__ */ jsx(LocaleRow, {
|
|
40
|
+
active: index === activeIndex,
|
|
41
|
+
option,
|
|
42
|
+
width,
|
|
43
|
+
codeWidth
|
|
44
|
+
}, option.code))
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function LocaleRow({ active, option, width, codeWidth }) {
|
|
48
|
+
const marker = active ? ">" : " ";
|
|
49
|
+
const sameName = option.name === option.nativeName;
|
|
50
|
+
const codeStr = option.code.padEnd(codeWidth);
|
|
51
|
+
const reserved = 2 + codeWidth + 2;
|
|
52
|
+
const remainingForName = Math.max(1, width - reserved);
|
|
53
|
+
const nameMax = sameName ? remainingForName : Math.max(1, Math.ceil(remainingForName * .55));
|
|
54
|
+
const truncatedName = truncate(option.name, nameMax);
|
|
55
|
+
const nativeMax = sameName ? 0 : Math.max(1, remainingForName - truncatedName.length - 2);
|
|
56
|
+
const truncatedNative = sameName ? "" : truncate(option.nativeName, nativeMax);
|
|
57
|
+
if (active) return /* @__PURE__ */ jsxs(Text, {
|
|
58
|
+
color: "cyan",
|
|
59
|
+
bold: true,
|
|
60
|
+
children: [`${marker} ${codeStr} ${truncatedName}`, sameName ? "" : ` ${truncatedNative}`]
|
|
61
|
+
});
|
|
62
|
+
return /* @__PURE__ */ jsxs(Text, { children: [
|
|
63
|
+
/* @__PURE__ */ jsx(Text, { children: `${marker} ` }),
|
|
64
|
+
/* @__PURE__ */ jsx(Text, {
|
|
65
|
+
dimColor: true,
|
|
66
|
+
children: codeStr
|
|
67
|
+
}),
|
|
68
|
+
/* @__PURE__ */ jsx(Text, { children: ` ${truncatedName}` }),
|
|
69
|
+
sameName ? null : /* @__PURE__ */ jsx(Text, {
|
|
70
|
+
dimColor: true,
|
|
71
|
+
italic: true,
|
|
72
|
+
children: ` ${truncatedNative}`
|
|
73
|
+
})
|
|
74
|
+
] });
|
|
75
|
+
}
|
|
76
|
+
function RemainingMatches({ total, visible }) {
|
|
77
|
+
const remaining = total - visible;
|
|
78
|
+
if (remaining <= 0) return null;
|
|
79
|
+
return /* @__PURE__ */ jsxs(Text, {
|
|
80
|
+
dimColor: true,
|
|
81
|
+
children: [remaining, " more matches"]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { LocaleOptionsList, OptionRow, RemainingMatches, SelectedTags };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=inkFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inkFields.js","names":[],"sources":["../../src/console/inkFields.tsx"],"sourcesContent":["import { Box, Text } from 'ink';\nimport { getLocaleCodeWidth } from './inkLocaleData.js';\nimport type { LocaleOption } from './inkTypes.js';\nimport { stripAnsi, truncate } from './inkUtils.js';\n\nexport function OptionRow({\n active,\n selected,\n label,\n hint,\n width,\n}: {\n active: boolean;\n selected?: boolean;\n label: string;\n hint?: string;\n width?: number;\n}) {\n const marker = active ? '>' : ' ';\n const selectedMarker = selected == null ? '' : selected ? '[x] ' : '[ ] ';\n const text = `${marker} ${selectedMarker}${stripAnsi(label)}${\n hint ? ` ${stripAnsi(hint)}` : ''\n }`;\n\n return active ? (\n <Text color='cyan' bold>\n {width ? truncate(text, width) : text}\n </Text>\n ) : (\n <Text>{width ? truncate(text, width) : text}</Text>\n );\n}\n\nexport function SelectedTags({\n selectedLocales,\n active,\n activeIndex,\n width,\n}: {\n selectedLocales: string[];\n active: boolean;\n activeIndex: number;\n width: number;\n}) {\n if (selectedLocales.length === 0) return null;\n\n return (\n <Box width={width} flexWrap='wrap'>\n <Text dimColor>Selected </Text>\n {selectedLocales.map((locale, index) => {\n const isActive = active && index === activeIndex;\n return (\n <Text key={locale}>\n <Text\n backgroundColor={isActive ? 'cyanBright' : 'gray'}\n color='black'\n bold={isActive}\n >{` ${locale} `}</Text>\n {index < selectedLocales.length - 1 ? <Text> </Text> : null}\n </Text>\n );\n })}\n </Box>\n );\n}\n\nexport function LocaleOptionsList({\n options,\n activeIndex,\n width,\n}: {\n options: LocaleOption[];\n activeIndex: number;\n width: number;\n}) {\n const codeWidth = getLocaleCodeWidth();\n return (\n <Box flexDirection='column' marginTop={1}>\n {options.map((option, index) => (\n <LocaleRow\n key={option.code}\n active={index === activeIndex}\n option={option}\n width={width}\n codeWidth={codeWidth}\n />\n ))}\n </Box>\n );\n}\n\nfunction LocaleRow({\n active,\n option,\n width,\n codeWidth,\n}: {\n active: boolean;\n option: LocaleOption;\n width: number;\n codeWidth: number;\n}) {\n const marker = active ? '>' : ' ';\n const sameName = option.name === option.nativeName;\n const codeStr = option.code.padEnd(codeWidth);\n const reserved = 2 + codeWidth + 2;\n const remainingForName = Math.max(1, width - reserved);\n const nameMax = sameName\n ? remainingForName\n : Math.max(1, Math.ceil(remainingForName * 0.55));\n const truncatedName = truncate(option.name, nameMax);\n const nativeMax = sameName\n ? 0\n : Math.max(1, remainingForName - truncatedName.length - 2);\n const truncatedNative = sameName\n ? ''\n : truncate(option.nativeName, nativeMax);\n\n if (active) {\n return (\n <Text color='cyan' bold>\n {`${marker} ${codeStr} ${truncatedName}`}\n {sameName ? '' : ` ${truncatedNative}`}\n </Text>\n );\n }\n\n return (\n <Text>\n <Text>{`${marker} `}</Text>\n <Text dimColor>{codeStr}</Text>\n <Text>{` ${truncatedName}`}</Text>\n {sameName ? null : <Text dimColor italic>{` ${truncatedNative}`}</Text>}\n </Text>\n );\n}\n\nexport function RemainingMatches({\n total,\n visible,\n}: {\n total: number;\n visible: number;\n}) {\n const remaining = total - visible;\n if (remaining <= 0) return null;\n return <Text dimColor>{remaining} more matches</Text>;\n}\n"],"mappings":";;;;;;AAKA,SAAgB,UAAU,EACxB,QACA,UACA,OACA,MACA,SAOC;CAGD,MAAM,OAAO,GAFE,SAAS,MAAM,IAEP,GADA,YAAY,OAAO,KAAK,WAAW,SAAS,SACxB,UAAU,MAAM,GACzD,OAAO,IAAI,UAAU,KAAK,KAAK;AAGjC,QAAO,SACL,oBAAC,MAAD;EAAM,OAAM;EAAO,MAAA;YAChB,QAAQ,SAAS,MAAM,MAAM,GAAG;EAC5B,CAAA,GAEP,oBAAC,MAAD,EAAA,UAAO,QAAQ,SAAS,MAAM,MAAM,GAAG,MAAY,CAAA;;AAIvD,SAAgB,aAAa,EAC3B,iBACA,QACA,aACA,SAMC;AACD,KAAI,gBAAgB,WAAW,EAAG,QAAO;AAEzC,QACE,qBAAC,KAAD;EAAY;EAAO,UAAS;YAA5B,CACE,oBAAC,MAAD;GAAM,UAAA;aAAS;GAAgB,CAAA,EAC9B,gBAAgB,KAAK,QAAQ,UAAU;GACtC,MAAM,WAAW,UAAU,UAAU;AACrC,UACE,qBAAC,MAAD,EAAA,UAAA,CACE,oBAAC,MAAD;IACE,iBAAiB,WAAW,eAAe;IAC3C,OAAM;IACN,MAAM;cACN,IAAI,OAAO;IAAU,CAAA,EACtB,QAAQ,gBAAgB,SAAS,IAAI,oBAAC,MAAD,EAAA,UAAM,KAAQ,CAAA,GAAG,KAClD,EAAA,EAPI,OAOJ;IAET,CACE;;;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AI,aAAa,EAAG,QAAO;AAC3B,QAAO,qBAAC,MAAD;EAAM,UAAA;YAAN,CAAgB,WAAU,gBAAoB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PromptFrameProps } from './inkTypes.js';
|
|
2
|
+
export declare function PromptFrame({ message, children, footer }: PromptFrameProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function InputBox({ value, width, placeholder, }: {
|
|
4
|
+
value: string;
|
|
5
|
+
width: number;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { PACKAGE_VERSION } from "../generated/version.js";
|
|
2
|
+
import { getContentWidth, normalizedMessage, truncate, wrapText } from "./inkUtils.js";
|
|
3
|
+
import { useTerminalSize } from "./inkTerminal.js";
|
|
4
|
+
import { Box, Text } from "ink";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/console/inkLayout.tsx
|
|
7
|
+
function PromptFrame({ message, children, footer }) {
|
|
8
|
+
const { columns, rows } = useTerminalSize();
|
|
9
|
+
const width = getContentWidth(columns);
|
|
10
|
+
const topPadding = Math.max(1, Math.min(5, Math.floor(rows * .1)));
|
|
11
|
+
const showFeedback = columns >= 88;
|
|
12
|
+
const footerText = columns < 50 ? ultraCompactFooter(footer) : columns < 72 ? compactFooter(footer) : footer;
|
|
13
|
+
const messageLines = wrapText(normalizedMessage(message), width);
|
|
14
|
+
const headerTitle = ` General Translation Wizard v${PACKAGE_VERSION}`;
|
|
15
|
+
const headerFeedback = "Feedback: support@generaltranslation.com ";
|
|
16
|
+
const headerGap = Math.max(1, columns - headerTitle.length - (showFeedback ? 42 : 0));
|
|
17
|
+
const headerText = `${headerTitle}${" ".repeat(headerGap)}${showFeedback ? headerFeedback : ""}`;
|
|
18
|
+
const footerLine = ` ${footerText}`.padEnd(columns, " ");
|
|
19
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
20
|
+
width: columns,
|
|
21
|
+
height: rows,
|
|
22
|
+
flexDirection: "column",
|
|
23
|
+
children: [
|
|
24
|
+
/* @__PURE__ */ jsx(Box, {
|
|
25
|
+
width: columns,
|
|
26
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
27
|
+
bold: true,
|
|
28
|
+
color: "black",
|
|
29
|
+
backgroundColor: "cyan",
|
|
30
|
+
children: headerText
|
|
31
|
+
})
|
|
32
|
+
}),
|
|
33
|
+
/* @__PURE__ */ jsx(Box, {
|
|
34
|
+
flexDirection: "column",
|
|
35
|
+
alignItems: "center",
|
|
36
|
+
paddingTop: topPadding,
|
|
37
|
+
flexShrink: 1,
|
|
38
|
+
children: /* @__PURE__ */ jsxs(Box, {
|
|
39
|
+
width,
|
|
40
|
+
flexDirection: "column",
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ jsx(Box, {
|
|
43
|
+
justifyContent: "center",
|
|
44
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
45
|
+
bold: true,
|
|
46
|
+
color: "cyan",
|
|
47
|
+
children: "GT Wizard"
|
|
48
|
+
})
|
|
49
|
+
}),
|
|
50
|
+
/* @__PURE__ */ jsx(Box, {
|
|
51
|
+
flexDirection: "column",
|
|
52
|
+
marginTop: 1,
|
|
53
|
+
children: messageLines.map((line, index) => /* @__PURE__ */ jsx(Text, { children: line }, `${index}-${line}`))
|
|
54
|
+
}),
|
|
55
|
+
/* @__PURE__ */ jsx(Box, {
|
|
56
|
+
marginTop: 2,
|
|
57
|
+
flexDirection: "column",
|
|
58
|
+
children
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
})
|
|
62
|
+
}),
|
|
63
|
+
/* @__PURE__ */ jsx(Box, { flexGrow: 1 }),
|
|
64
|
+
/* @__PURE__ */ jsx(Box, {
|
|
65
|
+
width: columns,
|
|
66
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
67
|
+
color: "black",
|
|
68
|
+
backgroundColor: "cyan",
|
|
69
|
+
wrap: "truncate-end",
|
|
70
|
+
children: footerLine
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function compactFooter(footer) {
|
|
77
|
+
return footer.replace("↑↓ navigate", "↑↓ move").replace("enter confirm", "enter done").replace("enter select", "enter choose").replace("esc cancel", "esc quit");
|
|
78
|
+
}
|
|
79
|
+
function ultraCompactFooter(footer) {
|
|
80
|
+
return compactFooter(footer).replace(/\s{2,}esc quit\s*$/, "").replace("↑↓ move", "↑↓").replace("space toggle", "spc").replace("enter done", "enter").replace("enter choose", "enter").replace("enter select", "enter").replace("enter save", "enter").replace("enter confirm", "enter").replace("type to edit", "type").replace("y/n select", "y/n").replace("←→ choose", "←→");
|
|
81
|
+
}
|
|
82
|
+
function InputBox({ value, width, placeholder }) {
|
|
83
|
+
const innerWidth = Math.max(1, width - 4);
|
|
84
|
+
if (value.length > 0) {
|
|
85
|
+
const visibleValue = truncate(value, Math.max(0, innerWidth - 1));
|
|
86
|
+
const padding = Math.max(0, innerWidth - visibleValue.length - 1);
|
|
87
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
88
|
+
width,
|
|
89
|
+
borderStyle: "round",
|
|
90
|
+
borderColor: "cyan",
|
|
91
|
+
paddingX: 1,
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ jsx(Text, { children: visibleValue }),
|
|
94
|
+
/* @__PURE__ */ jsx(Text, {
|
|
95
|
+
inverse: true,
|
|
96
|
+
children: " "
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ jsx(Text, { children: " ".repeat(padding) })
|
|
99
|
+
]
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
const placeholderText = truncate(placeholder ?? "", Math.max(0, innerWidth - 1));
|
|
103
|
+
if (!placeholderText) {
|
|
104
|
+
const padding = Math.max(0, innerWidth - 1);
|
|
105
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
106
|
+
width,
|
|
107
|
+
borderStyle: "round",
|
|
108
|
+
borderColor: "cyan",
|
|
109
|
+
paddingX: 1,
|
|
110
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
111
|
+
inverse: true,
|
|
112
|
+
children: " "
|
|
113
|
+
}), /* @__PURE__ */ jsx(Text, { children: " ".repeat(padding) })]
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
const padding = Math.max(0, innerWidth - placeholderText.length);
|
|
117
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
118
|
+
width,
|
|
119
|
+
borderStyle: "round",
|
|
120
|
+
borderColor: "cyan",
|
|
121
|
+
paddingX: 1,
|
|
122
|
+
children: [
|
|
123
|
+
/* @__PURE__ */ jsx(Text, {
|
|
124
|
+
inverse: true,
|
|
125
|
+
dimColor: true,
|
|
126
|
+
children: placeholderText.slice(0, 1)
|
|
127
|
+
}),
|
|
128
|
+
/* @__PURE__ */ jsx(Text, {
|
|
129
|
+
dimColor: true,
|
|
130
|
+
children: placeholderText.slice(1)
|
|
131
|
+
}),
|
|
132
|
+
/* @__PURE__ */ jsx(Text, { children: " ".repeat(padding) })
|
|
133
|
+
]
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
|
137
|
+
export { InputBox, PromptFrame };
|
|
138
|
+
|
|
139
|
+
//# sourceMappingURL=inkLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inkLayout.js","names":[],"sources":["../../src/console/inkLayout.tsx"],"sourcesContent":["import { Box, Text } from 'ink';\nimport { PACKAGE_VERSION } from '../generated/version.js';\nimport { useTerminalSize } from './inkTerminal.js';\nimport type { PromptFrameProps } from './inkTypes.js';\nimport {\n getContentWidth,\n normalizedMessage,\n truncate,\n wrapText,\n} from './inkUtils.js';\n\nexport function PromptFrame({ message, children, footer }: PromptFrameProps) {\n const { columns, rows } = useTerminalSize();\n const width = getContentWidth(columns);\n const topPadding = Math.max(1, Math.min(5, Math.floor(rows * 0.1)));\n const showFeedback = columns >= 88;\n const footerText =\n columns < 50\n ? ultraCompactFooter(footer)\n : columns < 72\n ? compactFooter(footer)\n : footer;\n const messageLines = wrapText(normalizedMessage(message), width);\n const headerTitle = ` General Translation Wizard v${PACKAGE_VERSION}`;\n const headerFeedback = 'Feedback: support@generaltranslation.com ';\n const headerGap = Math.max(\n 1,\n columns - headerTitle.length - (showFeedback ? headerFeedback.length : 0)\n );\n const headerText = `${headerTitle}${' '.repeat(headerGap)}${\n showFeedback ? headerFeedback : ''\n }`;\n const footerLine = ` ${footerText}`.padEnd(columns, ' ');\n\n return (\n <Box width={columns} height={rows} flexDirection='column'>\n <Box width={columns}>\n <Text bold color='black' backgroundColor='cyan'>\n {headerText}\n </Text>\n </Box>\n\n <Box\n flexDirection='column'\n alignItems='center'\n paddingTop={topPadding}\n flexShrink={1}\n >\n <Box width={width} flexDirection='column'>\n <Box justifyContent='center'>\n <Text bold color='cyan'>\n GT Wizard\n </Text>\n </Box>\n <Box flexDirection='column' marginTop={1}>\n {messageLines.map((line, index) => (\n <Text key={`${index}-${line}`}>{line}</Text>\n ))}\n </Box>\n <Box marginTop={2} flexDirection='column'>\n {children}\n </Box>\n </Box>\n </Box>\n\n <Box flexGrow={1} />\n <Box width={columns}>\n <Text color='black' backgroundColor='cyan' wrap='truncate-end'>\n {footerLine}\n </Text>\n </Box>\n </Box>\n );\n}\n\nfunction compactFooter(footer: string) {\n return footer\n .replace('↑↓ navigate', '↑↓ move')\n .replace('enter confirm', 'enter done')\n .replace('enter select', 'enter choose')\n .replace('esc cancel', 'esc quit');\n}\n\nfunction ultraCompactFooter(footer: string) {\n return compactFooter(footer)\n .replace(/\\s{2,}esc quit\\s*$/, '')\n .replace('↑↓ move', '↑↓')\n .replace('space toggle', 'spc')\n .replace('enter done', 'enter')\n .replace('enter choose', 'enter')\n .replace('enter select', 'enter')\n .replace('enter save', 'enter')\n .replace('enter confirm', 'enter')\n .replace('type to edit', 'type')\n .replace('y/n select', 'y/n')\n .replace('←→ choose', '←→');\n}\n\nexport function InputBox({\n value,\n width,\n placeholder,\n}: {\n value: string;\n width: number;\n placeholder?: string;\n}) {\n const innerWidth = Math.max(1, width - 4);\n const hasValue = value.length > 0;\n\n if (hasValue) {\n const visibleValue = truncate(value, Math.max(0, innerWidth - 1));\n const padding = Math.max(0, innerWidth - visibleValue.length - 1);\n return (\n <Box width={width} borderStyle='round' borderColor='cyan' paddingX={1}>\n <Text>{visibleValue}</Text>\n <Text inverse> </Text>\n <Text>{' '.repeat(padding)}</Text>\n </Box>\n );\n }\n\n const placeholderText = truncate(\n placeholder ?? '',\n Math.max(0, innerWidth - 1)\n );\n\n if (!placeholderText) {\n const padding = Math.max(0, innerWidth - 1);\n return (\n <Box width={width} borderStyle='round' borderColor='cyan' paddingX={1}>\n <Text inverse> </Text>\n <Text>{' '.repeat(padding)}</Text>\n </Box>\n );\n }\n\n const padding = Math.max(0, innerWidth - placeholderText.length);\n return (\n <Box width={width} borderStyle='round' borderColor='cyan' paddingX={1}>\n <Text inverse dimColor>\n {placeholderText.slice(0, 1)}\n </Text>\n <Text dimColor>{placeholderText.slice(1)}</Text>\n <Text>{' '.repeat(padding)}</Text>\n </Box>\n );\n}\n"],"mappings":";;;;;;AAWA,SAAgB,YAAY,EAAE,SAAS,UAAU,UAA4B;CAC3E,MAAM,EAAE,SAAS,SAAS,iBAAiB;CAC3C,MAAM,QAAQ,gBAAgB,QAAQ;CACtC,MAAM,aAAa,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,MAAM,OAAO,GAAI,CAAC,CAAC;CACnE,MAAM,eAAe,WAAW;CAChC,MAAM,aACJ,UAAU,KACN,mBAAmB,OAAO,GAC1B,UAAU,KACR,cAAc,OAAO,GACrB;CACR,MAAM,eAAe,SAAS,kBAAkB,QAAQ,EAAE,MAAM;CAChE,MAAM,cAAc,iCAAiC;CACrD,MAAM,iBAAiB;CACvB,MAAM,YAAY,KAAK,IACrB,GACA,UAAU,YAAY,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,gBAAgB,MAAM,GAAG,EAAE;IACvB,CAAA;GACP,oBAAC,MAAD;IAAM,UAAA;cAAU,gBAAgB,MAAM,EAAE;IAAQ,CAAA;GAChD,oBAAC,MAAD,EAAA,UAAO,IAAI,OAAO,QAAQ,EAAQ,CAAA;GAC9B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getLocaleProperties } from "generaltranslation";
|
|
2
|
+
import { listSupportedLocales } from "@generaltranslation/supported-locales";
|
|
3
|
+
//#region src/console/inkLocaleData.ts
|
|
4
|
+
let localeOptionsCache;
|
|
5
|
+
let localeCodeWidthCache;
|
|
6
|
+
function getLocaleOptions() {
|
|
7
|
+
localeOptionsCache ??= listSupportedLocales().map((code) => {
|
|
8
|
+
const properties = getLocaleProperties(code);
|
|
9
|
+
return {
|
|
10
|
+
code,
|
|
11
|
+
label: properties.name === properties.nativeName ? `${code} ${properties.name}` : `${code} ${properties.name} / ${properties.nativeName}`,
|
|
12
|
+
name: properties.name,
|
|
13
|
+
nativeName: properties.nativeName,
|
|
14
|
+
searchable: `${code} ${properties.name} ${properties.nativeName}`.toLowerCase()
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
return localeOptionsCache;
|
|
18
|
+
}
|
|
19
|
+
function getLocaleCodeWidth() {
|
|
20
|
+
localeCodeWidthCache ??= getLocaleOptions().reduce((max, option) => Math.max(max, option.code.length), 0);
|
|
21
|
+
return localeCodeWidthCache;
|
|
22
|
+
}
|
|
23
|
+
function getFilteredLocaleOptions(query) {
|
|
24
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
25
|
+
const options = getLocaleOptions();
|
|
26
|
+
if (!normalizedQuery) return options;
|
|
27
|
+
return options.filter((option) => option.searchable.includes(normalizedQuery));
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { getFilteredLocaleOptions, getLocaleCodeWidth, getLocaleOptions };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=inkLocaleData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inkLocaleData.js","names":[],"sources":["../../src/console/inkLocaleData.ts"],"sourcesContent":["import { listSupportedLocales } from '@generaltranslation/supported-locales';\nimport { getLocaleProperties } from 'generaltranslation';\nimport type { LocaleOption } from './inkTypes.js';\n\nlet localeOptionsCache: LocaleOption[] | undefined;\nlet localeCodeWidthCache: number | undefined;\n\nexport function getLocaleOptions(): LocaleOption[] {\n localeOptionsCache ??= listSupportedLocales().map((code) => {\n const properties = getLocaleProperties(code);\n const label =\n properties.name === properties.nativeName\n ? `${code} ${properties.name}`\n : `${code} ${properties.name} / ${properties.nativeName}`;\n\n return {\n code,\n label,\n name: properties.name,\n nativeName: properties.nativeName,\n searchable:\n `${code} ${properties.name} ${properties.nativeName}`.toLowerCase(),\n };\n });\n return localeOptionsCache;\n}\n\nexport function getLocaleCodeWidth(): number {\n localeCodeWidthCache ??= getLocaleOptions().reduce(\n (max, option) => Math.max(max, option.code.length),\n 0\n );\n return localeCodeWidthCache;\n}\n\nexport function getFilteredLocaleOptions(query: string) {\n const normalizedQuery = query.trim().toLowerCase();\n const options = getLocaleOptions();\n if (!normalizedQuery) return options;\n\n return options.filter((option) =>\n option.searchable.includes(normalizedQuery)\n );\n}\n"],"mappings":";;;AAIA,IAAI;AACJ,IAAI;AAEJ,SAAgB,mBAAmC;AACjD,wBAAuB,sBAAsB,CAAC,KAAK,SAAS;EAC1D,MAAM,aAAa,oBAAoB,KAAK;AAM5C,SAAO;GACL;GACA,OANA,WAAW,SAAS,WAAW,aAC3B,GAAG,KAAK,IAAI,WAAW,SACvB,GAAG,KAAK,IAAI,WAAW,KAAK,KAAK,WAAW;GAKhD,MAAM,WAAW;GACjB,YAAY,WAAW;GACvB,YACE,GAAG,KAAK,GAAG,WAAW,KAAK,GAAG,WAAW,aAAa,aAAa;GACtE;GACD;AACF,QAAO;;AAGT,SAAgB,qBAA6B;AAC3C,0BAAyB,kBAAkB,CAAC,QACzC,KAAK,WAAW,KAAK,IAAI,KAAK,OAAO,KAAK,OAAO,EAClD,EACD;AACD,QAAO;;AAGT,SAAgB,yBAAyB,OAAe;CACtD,MAAM,kBAAkB,MAAM,MAAM,CAAC,aAAa;CAClD,MAAM,UAAU,kBAAkB;AAClC,KAAI,CAAC,gBAAiB,QAAO;AAE7B,QAAO,QAAQ,QAAQ,WACrB,OAAO,WAAW,SAAS,gBAAgB,CAC5C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ConfirmPromptProps, GlobPromptProps, LocaleMultiPromptProps, LocalePromptProps, MultiSelectPromptProps, SelectPromptProps, TextPromptProps } from './inkTypes.js';
|
|
2
|
+
export declare function inkPromptText(options: Omit<TextPromptProps, 'onComplete'>): Promise<import("./inkTypes.js").PromptResult<string>>;
|
|
3
|
+
export declare function inkPromptLocale(options: Omit<LocalePromptProps, 'onComplete'>): Promise<import("./inkTypes.js").PromptResult<string>>;
|
|
4
|
+
export declare function inkPromptLocaleMulti(options: Omit<LocaleMultiPromptProps, 'onComplete'>): Promise<import("./inkTypes.js").PromptResult<string[]>>;
|
|
5
|
+
export declare function inkPromptGlob(options: Omit<GlobPromptProps, 'onComplete'>): Promise<import("./inkTypes.js").PromptResult<string>>;
|
|
6
|
+
export declare function inkPromptSelect<T>(options: Omit<SelectPromptProps<T>, 'onComplete'>): Promise<import("./inkTypes.js").PromptResult<T>>;
|
|
7
|
+
export declare function inkPromptMultiSelect<T extends string>(options: Omit<MultiSelectPromptProps<T>, 'onComplete'>): Promise<import("./inkTypes.js").PromptResult<T[]>>;
|
|
8
|
+
export declare function inkPromptConfirm(options: Omit<ConfirmPromptProps, 'onComplete'>): Promise<import("./inkTypes.js").PromptResult<boolean>>;
|