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,595 +1,428 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { buildImportMap } from
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import fs from
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import generateModule from
|
|
10
|
-
import
|
|
11
|
-
|
|
1
|
+
import { warnAutoderiveNoResultsSync, warnDeriveFunctionNoResultsSync, warnDeriveFunctionNotWrappedSync, warnFunctionNotFoundSync } from "../../../../../console/index.js";
|
|
2
|
+
import { resolveImportPath } from "../../resolveImportPath.js";
|
|
3
|
+
import { buildImportMap } from "../../buildImportMap.js";
|
|
4
|
+
import { nodeToStrings, parseStringExpression } from "../../parseString.js";
|
|
5
|
+
import { isDeriveCall } from "./isDeriveCall.js";
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import * as t from "@babel/types";
|
|
8
|
+
import { parse } from "@babel/parser";
|
|
9
|
+
import generateModule from "@babel/generator";
|
|
10
|
+
import traverseModule from "@babel/traverse";
|
|
11
|
+
//#region src/react/jsx/utils/stringParsing/derivation/handleDerivation.ts
|
|
12
12
|
const traverse = traverseModule.default || traverseModule;
|
|
13
13
|
const generate = generateModule.default || generateModule;
|
|
14
14
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const resolveImportPathCache = new Map();
|
|
15
|
+
* Cache for resolved import paths to avoid redundant I/O operations.
|
|
16
|
+
* Key: `${currentFile}::${importPath}`
|
|
17
|
+
* Value: resolved absolute path or null
|
|
18
|
+
*/
|
|
19
|
+
const resolveImportPathCache = /* @__PURE__ */ new Map();
|
|
20
20
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const processFunctionCache = new Map();
|
|
21
|
+
* Cache for processed functions to avoid re-parsing the same files.
|
|
22
|
+
* Key: `${filePath}::${functionName}`
|
|
23
|
+
* Value: Node result or null
|
|
24
|
+
*/
|
|
25
|
+
const processFunctionCache = /* @__PURE__ */ new Map();
|
|
26
26
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return { type: 'text', text: 'null' };
|
|
212
|
-
}
|
|
213
|
-
// Non-static expression
|
|
214
|
-
if (skipDeriveInvocation) {
|
|
215
|
-
// Skip pass a `derive()` invocation to do derivation
|
|
216
|
-
const variants = resolveCallStringVariants(expr, tPath, file, parsingOptions, errors, warnings);
|
|
217
|
-
if (variants) {
|
|
218
|
-
return {
|
|
219
|
-
type: 'choice',
|
|
220
|
-
nodes: variants.map((v) => ({ type: 'text', text: v })),
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
// Autoderive had no resolvable results
|
|
224
|
-
const code = generate(expr).code;
|
|
225
|
-
errors.push(warnAutoderiveNoResultsSync(file, code, `${expr.loc?.start?.line}:${expr.loc?.start?.column}`));
|
|
226
|
-
return null;
|
|
227
|
-
}
|
|
228
|
-
// Not a derivable expression
|
|
229
|
-
if (runtimeInterpolationState) {
|
|
230
|
-
return { type: 'text', text: `{${runtimeInterpolationState.index++}}` };
|
|
231
|
-
}
|
|
232
|
-
return null;
|
|
27
|
+
* Extracts content if an expression is derivable (statically analyzable) or uses derive()
|
|
28
|
+
* Returns a Node representing the parsed expression
|
|
29
|
+
* @param expr - The expression to check
|
|
30
|
+
* @param tPath - NodePath for scope resolution
|
|
31
|
+
* @param file - Current file path
|
|
32
|
+
* @param parsingOptions - Parsing configuration
|
|
33
|
+
* @param errors - Errors to add to
|
|
34
|
+
* @param runtimeInterpolationState - When provided, non-derive dynamic expressions become {n} placeholders instead of errors. Pass { index: 0 } at the entry point for template macros.
|
|
35
|
+
* @param skipDeriveInvocation - If true, skip derive invocation check
|
|
36
|
+
* @returns Node | null - The parsed node, or null if invalid
|
|
37
|
+
*
|
|
38
|
+
* @note runtimeInterpolationState
|
|
39
|
+
* - Only provide at entry for template macros, otherwise omit
|
|
40
|
+
* - t`Hello {nonDerivableValue}` -> t`Hello {0}`
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
function handleDerivation({ expr, tPath, file, parsingOptions, errors, warnings, runtimeInterpolationState, skipDeriveInvocation }) {
|
|
44
|
+
if (!expr) return null;
|
|
45
|
+
if (t.isCallExpression(expr)) {
|
|
46
|
+
if (isDeriveCall({
|
|
47
|
+
expr,
|
|
48
|
+
tPath
|
|
49
|
+
})) {
|
|
50
|
+
const variants = getDeriveVariants({
|
|
51
|
+
call: expr,
|
|
52
|
+
tPath,
|
|
53
|
+
file,
|
|
54
|
+
parsingOptions,
|
|
55
|
+
errors,
|
|
56
|
+
warnings
|
|
57
|
+
});
|
|
58
|
+
if (variants) return {
|
|
59
|
+
type: "choice",
|
|
60
|
+
nodes: variants.map((v) => ({
|
|
61
|
+
type: "text",
|
|
62
|
+
text: v
|
|
63
|
+
}))
|
|
64
|
+
};
|
|
65
|
+
const code = expr.arguments.length > 0 ? generate(expr.arguments[0]).code : "no arguments";
|
|
66
|
+
errors.push(warnDeriveFunctionNoResultsSync(file, code, `${expr.loc?.start?.line}:${expr.loc?.start?.column}`));
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
if (runtimeInterpolationState) return {
|
|
70
|
+
type: "text",
|
|
71
|
+
text: `{${runtimeInterpolationState.index++}}`
|
|
72
|
+
};
|
|
73
|
+
const calleeName = t.isIdentifier(expr.callee) ? expr.callee.name : generate(expr.callee).code;
|
|
74
|
+
errors.push(warnDeriveFunctionNotWrappedSync(file, calleeName, `${expr.callee.loc?.start?.line}:${expr.callee.loc?.start?.column}`));
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
if (t.isStringLiteral(expr)) return {
|
|
78
|
+
type: "text",
|
|
79
|
+
text: expr.value
|
|
80
|
+
};
|
|
81
|
+
if (t.isTemplateLiteral(expr)) {
|
|
82
|
+
const parts = [];
|
|
83
|
+
for (let index = 0; index < expr.quasis.length; index++) {
|
|
84
|
+
const quasi = expr.quasis[index];
|
|
85
|
+
const text = quasi.value.cooked ?? quasi.value.raw ?? "";
|
|
86
|
+
if (text) parts.push({
|
|
87
|
+
type: "text",
|
|
88
|
+
text
|
|
89
|
+
});
|
|
90
|
+
const exprNode = expr.expressions[index];
|
|
91
|
+
if (exprNode && t.isExpression(exprNode)) if (isDeriveCall({
|
|
92
|
+
expr: exprNode,
|
|
93
|
+
tPath
|
|
94
|
+
})) {
|
|
95
|
+
const result = handleDerivation({
|
|
96
|
+
expr: exprNode,
|
|
97
|
+
tPath,
|
|
98
|
+
file,
|
|
99
|
+
parsingOptions,
|
|
100
|
+
errors,
|
|
101
|
+
warnings
|
|
102
|
+
});
|
|
103
|
+
if (result === null) return null;
|
|
104
|
+
parts.push(result);
|
|
105
|
+
} else {
|
|
106
|
+
const result = handleDerivation({
|
|
107
|
+
expr: exprNode,
|
|
108
|
+
tPath,
|
|
109
|
+
file,
|
|
110
|
+
parsingOptions,
|
|
111
|
+
errors,
|
|
112
|
+
warnings,
|
|
113
|
+
runtimeInterpolationState,
|
|
114
|
+
skipDeriveInvocation
|
|
115
|
+
});
|
|
116
|
+
if (result === null) return null;
|
|
117
|
+
parts.push(result);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (parts.length === 0) return {
|
|
121
|
+
type: "text",
|
|
122
|
+
text: ""
|
|
123
|
+
};
|
|
124
|
+
if (parts.length === 1) return parts[0];
|
|
125
|
+
return {
|
|
126
|
+
type: "sequence",
|
|
127
|
+
nodes: parts
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (t.isBinaryExpression(expr) && expr.operator === "+") {
|
|
131
|
+
if (!t.isExpression(expr.left) || !t.isExpression(expr.right)) return null;
|
|
132
|
+
const leftResult = handleDerivation({
|
|
133
|
+
expr: expr.left,
|
|
134
|
+
tPath,
|
|
135
|
+
file,
|
|
136
|
+
parsingOptions,
|
|
137
|
+
errors,
|
|
138
|
+
warnings,
|
|
139
|
+
runtimeInterpolationState,
|
|
140
|
+
skipDeriveInvocation
|
|
141
|
+
});
|
|
142
|
+
const rightResult = handleDerivation({
|
|
143
|
+
expr: expr.right,
|
|
144
|
+
tPath,
|
|
145
|
+
file,
|
|
146
|
+
parsingOptions,
|
|
147
|
+
errors,
|
|
148
|
+
warnings,
|
|
149
|
+
runtimeInterpolationState,
|
|
150
|
+
skipDeriveInvocation
|
|
151
|
+
});
|
|
152
|
+
if (leftResult === null || rightResult === null) return null;
|
|
153
|
+
return {
|
|
154
|
+
type: "sequence",
|
|
155
|
+
nodes: [leftResult, rightResult]
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (t.isParenthesizedExpression(expr)) return handleDerivation({
|
|
159
|
+
expr: expr.expression,
|
|
160
|
+
tPath,
|
|
161
|
+
file,
|
|
162
|
+
parsingOptions,
|
|
163
|
+
errors,
|
|
164
|
+
warnings,
|
|
165
|
+
runtimeInterpolationState,
|
|
166
|
+
skipDeriveInvocation
|
|
167
|
+
});
|
|
168
|
+
if (t.isNumericLiteral(expr)) return {
|
|
169
|
+
type: "text",
|
|
170
|
+
text: String(expr.value)
|
|
171
|
+
};
|
|
172
|
+
if (t.isUnaryExpression(expr)) {
|
|
173
|
+
let operator = "";
|
|
174
|
+
if (expr.operator === "-") operator = expr.operator;
|
|
175
|
+
if (t.isNumericLiteral(expr.argument)) if (expr.argument.value === 0) return {
|
|
176
|
+
type: "text",
|
|
177
|
+
text: "0"
|
|
178
|
+
};
|
|
179
|
+
else return {
|
|
180
|
+
type: "text",
|
|
181
|
+
text: operator + expr.argument.value.toString()
|
|
182
|
+
};
|
|
183
|
+
else return null;
|
|
184
|
+
}
|
|
185
|
+
if (t.isBooleanLiteral(expr)) return {
|
|
186
|
+
type: "text",
|
|
187
|
+
text: String(expr.value)
|
|
188
|
+
};
|
|
189
|
+
if (t.isNullLiteral(expr)) return {
|
|
190
|
+
type: "text",
|
|
191
|
+
text: "null"
|
|
192
|
+
};
|
|
193
|
+
if (skipDeriveInvocation) {
|
|
194
|
+
const variants = resolveCallStringVariants(expr, tPath, file, parsingOptions, errors, warnings);
|
|
195
|
+
if (variants) return {
|
|
196
|
+
type: "choice",
|
|
197
|
+
nodes: variants.map((v) => ({
|
|
198
|
+
type: "text",
|
|
199
|
+
text: v
|
|
200
|
+
}))
|
|
201
|
+
};
|
|
202
|
+
const code = generate(expr).code;
|
|
203
|
+
errors.push(warnAutoderiveNoResultsSync(file, code, `${expr.loc?.start?.line}:${expr.loc?.start?.column}`));
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
if (runtimeInterpolationState) return {
|
|
207
|
+
type: "text",
|
|
208
|
+
text: `{${runtimeInterpolationState.index++}}`
|
|
209
|
+
};
|
|
210
|
+
return null;
|
|
233
211
|
}
|
|
234
212
|
/**
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
function getDeriveVariants({ call, tPath, file, parsingOptions, errors, warnings
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
// Handle other expressions (ternary, string literal, etc.) by recursing into handleDerivation
|
|
270
|
-
const node = handleDerivation({
|
|
271
|
-
expr: arg,
|
|
272
|
-
tPath,
|
|
273
|
-
file,
|
|
274
|
-
parsingOptions,
|
|
275
|
-
errors,
|
|
276
|
-
warnings,
|
|
277
|
-
skipDeriveInvocation: true,
|
|
278
|
-
});
|
|
279
|
-
if (node) {
|
|
280
|
-
return nodeToStrings(node);
|
|
281
|
-
}
|
|
282
|
-
return null;
|
|
213
|
+
* Given a CallExpression, if it is derive(<call>) or derive(await <call>),
|
|
214
|
+
* return all possible string outcomes of that argument call as an array of strings.
|
|
215
|
+
*
|
|
216
|
+
* Examples:
|
|
217
|
+
* derive(time()) -> ["day", "night"]
|
|
218
|
+
* derive(await time()) -> ["day", "night"]
|
|
219
|
+
*
|
|
220
|
+
* Returns null if it can't be resolved.
|
|
221
|
+
*/
|
|
222
|
+
function getDeriveVariants({ call, tPath, file, parsingOptions, errors, warnings }) {
|
|
223
|
+
if (!isDeriveCall({
|
|
224
|
+
expr: call,
|
|
225
|
+
tPath
|
|
226
|
+
})) {
|
|
227
|
+
const calleeName = t.isIdentifier(call.callee) ? call.callee.name : generate(call.callee).code;
|
|
228
|
+
errors.push(warnDeriveFunctionNotWrappedSync(file, calleeName, `${call.callee.loc?.start?.line}:${call.callee.loc?.start?.column}`));
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
if (call.arguments.length !== 1) return null;
|
|
232
|
+
const arg = call.arguments[0];
|
|
233
|
+
if (!t.isExpression(arg)) return null;
|
|
234
|
+
if (t.isAwaitExpression(arg)) return resolveCallStringVariants(arg.argument, tPath, file, parsingOptions, errors, warnings);
|
|
235
|
+
if (t.isCallExpression(arg)) return resolveCallStringVariants(arg, tPath, file, parsingOptions, errors, warnings);
|
|
236
|
+
const node = handleDerivation({
|
|
237
|
+
expr: arg,
|
|
238
|
+
tPath,
|
|
239
|
+
file,
|
|
240
|
+
parsingOptions,
|
|
241
|
+
errors,
|
|
242
|
+
warnings,
|
|
243
|
+
skipDeriveInvocation: true
|
|
244
|
+
});
|
|
245
|
+
if (node) return nodeToStrings(node);
|
|
246
|
+
return null;
|
|
283
247
|
}
|
|
284
248
|
function resolveCallStringVariants(expression, tPath, file, parsingOptions, errors, warnings) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
const node = resolveFunctionInFile(filePath, originalName, parsingOptions, errors, warnings);
|
|
315
|
-
if (node) {
|
|
316
|
-
return nodeToStrings(node);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
else {
|
|
322
|
-
// Function is local - use parseStringExpression with resolveFunctionCall
|
|
323
|
-
const node = resolveFunctionCallFromBinding(calleeBinding, tPath, file, parsingOptions, warnings, errors);
|
|
324
|
-
if (node) {
|
|
325
|
-
return nodeToStrings(node);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
else {
|
|
330
|
-
// Function not found in scope
|
|
331
|
-
errors.push(warnFunctionNotFoundSync(file, functionName, `${expression.callee.loc?.start?.line}:${expression.callee.loc?.start?.column}`));
|
|
332
|
-
return null;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
// If we get here: analyze this call as derivable (statically analyzable)
|
|
336
|
-
const node = parseStringExpression(expression, tPath, file, parsingOptions, warnings, errors);
|
|
337
|
-
if (node) {
|
|
338
|
-
return nodeToStrings(node);
|
|
339
|
-
}
|
|
340
|
-
return null;
|
|
249
|
+
if (t.isCallExpression(expression) && t.isIdentifier(expression.callee)) {
|
|
250
|
+
const functionName = expression.callee.name;
|
|
251
|
+
const calleeBinding = tPath.scope.getBinding(functionName);
|
|
252
|
+
if (calleeBinding) if (calleeBinding.path.isImportSpecifier() || calleeBinding.path.isImportDefaultSpecifier() || calleeBinding.path.isImportNamespaceSpecifier()) {
|
|
253
|
+
const importedFunctionsMap = buildImportMap(tPath.scope.getProgramParent().path);
|
|
254
|
+
let originalName;
|
|
255
|
+
if (calleeBinding.path.isImportSpecifier()) originalName = t.isIdentifier(calleeBinding.path.node.imported) ? calleeBinding.path.node.imported.name : calleeBinding.path.node.imported.value;
|
|
256
|
+
else if (calleeBinding.path.isImportDefaultSpecifier()) originalName = calleeBinding.path.node.local.name;
|
|
257
|
+
else if (calleeBinding.path.isImportNamespaceSpecifier()) originalName = calleeBinding.path.node.local.name;
|
|
258
|
+
const importPath = importedFunctionsMap.get(functionName);
|
|
259
|
+
if (importPath) {
|
|
260
|
+
const filePath = resolveImportPath(file, importPath, parsingOptions, resolveImportPathCache);
|
|
261
|
+
if (filePath && originalName) {
|
|
262
|
+
const node = resolveFunctionInFile(filePath, originalName, parsingOptions, errors, warnings);
|
|
263
|
+
if (node) return nodeToStrings(node);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
const node = resolveFunctionCallFromBinding(calleeBinding, tPath, file, parsingOptions, warnings, errors);
|
|
268
|
+
if (node) return nodeToStrings(node);
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
errors.push(warnFunctionNotFoundSync(file, functionName, `${expression.callee.loc?.start?.line}:${expression.callee.loc?.start?.column}`));
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const node = parseStringExpression(expression, tPath, file, parsingOptions, warnings, errors);
|
|
276
|
+
if (node) return nodeToStrings(node);
|
|
277
|
+
return null;
|
|
341
278
|
}
|
|
342
279
|
/**
|
|
343
|
-
|
|
344
|
-
|
|
280
|
+
* Resolves a function from a binding (local function) using parseStringExpression logic
|
|
281
|
+
*/
|
|
345
282
|
function resolveFunctionCallFromBinding(calleeBinding, tPath, file, parsingOptions, warnings, errors) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
const bodyResult = parseStringExpression(body.node, body, file, parsingOptions, warnings, errors);
|
|
381
|
-
if (bodyResult !== null) {
|
|
382
|
-
branches.push(bodyResult);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
// Handle block body: () => { return "day"; }
|
|
386
|
-
else if (body.isBlockStatement()) {
|
|
387
|
-
const arrowFunction = init.node;
|
|
388
|
-
body.traverse({
|
|
389
|
-
ReturnStatement(returnPath) {
|
|
390
|
-
// Only process return statements that are direct children of this function
|
|
391
|
-
const parentFunction = returnPath.getFunctionParent();
|
|
392
|
-
if (parentFunction?.node !== arrowFunction) {
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
const returnArg = returnPath.node.argument;
|
|
396
|
-
if (!returnArg || !t.isExpression(returnArg)) {
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
399
|
-
const returnResult = parseStringExpression(returnArg, returnPath, file, parsingOptions, warnings, errors);
|
|
400
|
-
if (returnResult !== null) {
|
|
401
|
-
branches.push(returnResult);
|
|
402
|
-
}
|
|
403
|
-
},
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
if (branches.length === 0) {
|
|
408
|
-
return null;
|
|
409
|
-
}
|
|
410
|
-
if (branches.length === 1) {
|
|
411
|
-
return branches[0];
|
|
412
|
-
}
|
|
413
|
-
return { type: 'choice', nodes: branches };
|
|
283
|
+
if (!calleeBinding) return null;
|
|
284
|
+
const bindingPath = calleeBinding.path;
|
|
285
|
+
const branches = [];
|
|
286
|
+
if (bindingPath.isFunctionDeclaration()) bindingPath.traverse({ ReturnStatement(returnPath) {
|
|
287
|
+
if (returnPath.getFunctionParent()?.node !== bindingPath.node) return;
|
|
288
|
+
const returnArg = returnPath.node.argument;
|
|
289
|
+
if (!returnArg || !t.isExpression(returnArg)) return;
|
|
290
|
+
const returnResult = parseStringExpression(returnArg, returnPath, file, parsingOptions, warnings, errors);
|
|
291
|
+
if (returnResult !== null) branches.push(returnResult);
|
|
292
|
+
} });
|
|
293
|
+
else if (bindingPath.isVariableDeclarator()) {
|
|
294
|
+
const init = bindingPath.get("init");
|
|
295
|
+
if (!init.isArrowFunctionExpression()) return null;
|
|
296
|
+
const body = init.get("body");
|
|
297
|
+
if (body.isExpression()) {
|
|
298
|
+
const bodyResult = parseStringExpression(body.node, body, file, parsingOptions, warnings, errors);
|
|
299
|
+
if (bodyResult !== null) branches.push(bodyResult);
|
|
300
|
+
} else if (body.isBlockStatement()) {
|
|
301
|
+
const arrowFunction = init.node;
|
|
302
|
+
body.traverse({ ReturnStatement(returnPath) {
|
|
303
|
+
if (returnPath.getFunctionParent()?.node !== arrowFunction) return;
|
|
304
|
+
const returnArg = returnPath.node.argument;
|
|
305
|
+
if (!returnArg || !t.isExpression(returnArg)) return;
|
|
306
|
+
const returnResult = parseStringExpression(returnArg, returnPath, file, parsingOptions, warnings, errors);
|
|
307
|
+
if (returnResult !== null) branches.push(returnResult);
|
|
308
|
+
} });
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (branches.length === 0) return null;
|
|
312
|
+
if (branches.length === 1) return branches[0];
|
|
313
|
+
return {
|
|
314
|
+
type: "choice",
|
|
315
|
+
nodes: branches
|
|
316
|
+
};
|
|
414
317
|
}
|
|
415
318
|
/**
|
|
416
|
-
|
|
417
|
-
|
|
319
|
+
* Resolves a function definition in an external file
|
|
320
|
+
*/
|
|
418
321
|
function resolveFunctionInFile(filePath, functionName, parsingOptions, errors, warnings) {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
else if (branches.length > 1) {
|
|
522
|
-
result = { type: 'choice', nodes: branches };
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
},
|
|
526
|
-
// Handle variable declarations: const woah = () => { ... }
|
|
527
|
-
VariableDeclarator(path) {
|
|
528
|
-
if (t.isIdentifier(path.node.id) &&
|
|
529
|
-
path.node.id.name === functionName &&
|
|
530
|
-
path.node.init &&
|
|
531
|
-
(t.isArrowFunctionExpression(path.node.init) ||
|
|
532
|
-
t.isFunctionExpression(path.node.init)) &&
|
|
533
|
-
result === null) {
|
|
534
|
-
const init = path.get('init');
|
|
535
|
-
if (!init.isArrowFunctionExpression() &&
|
|
536
|
-
!init.isFunctionExpression()) {
|
|
537
|
-
return;
|
|
538
|
-
}
|
|
539
|
-
const bodyPath = init.get('body');
|
|
540
|
-
const branches = [];
|
|
541
|
-
// Handle expression body: () => "day"
|
|
542
|
-
if (!Array.isArray(bodyPath) && t.isExpression(bodyPath.node)) {
|
|
543
|
-
const bodyResult = parseStringExpression(bodyPath.node, bodyPath, filePath, parsingOptions, warnings, errors);
|
|
544
|
-
if (bodyResult !== null) {
|
|
545
|
-
branches.push(bodyResult);
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
// Handle block body: () => { return "day"; }
|
|
549
|
-
else if (!Array.isArray(bodyPath) &&
|
|
550
|
-
t.isBlockStatement(bodyPath.node)) {
|
|
551
|
-
const arrowFunction = init.node;
|
|
552
|
-
bodyPath.traverse({
|
|
553
|
-
Function(innerPath) {
|
|
554
|
-
// Skip nested functions
|
|
555
|
-
innerPath.skip();
|
|
556
|
-
},
|
|
557
|
-
ReturnStatement(returnPath) {
|
|
558
|
-
// Only process return statements that are direct children of this function
|
|
559
|
-
const parentFunction = returnPath.getFunctionParent();
|
|
560
|
-
if (parentFunction?.node !== arrowFunction) {
|
|
561
|
-
return;
|
|
562
|
-
}
|
|
563
|
-
if (!t.isReturnStatement(returnPath.node)) {
|
|
564
|
-
return;
|
|
565
|
-
}
|
|
566
|
-
const returnArg = returnPath.node.argument;
|
|
567
|
-
if (!returnArg || !t.isExpression(returnArg)) {
|
|
568
|
-
return;
|
|
569
|
-
}
|
|
570
|
-
const returnResult = parseStringExpression(returnArg, returnPath, filePath, parsingOptions, warnings, errors);
|
|
571
|
-
if (returnResult !== null) {
|
|
572
|
-
branches.push(returnResult);
|
|
573
|
-
}
|
|
574
|
-
},
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
if (branches.length === 1) {
|
|
578
|
-
result = branches[0];
|
|
579
|
-
}
|
|
580
|
-
else if (branches.length > 1) {
|
|
581
|
-
result = { type: 'choice', nodes: branches };
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
},
|
|
585
|
-
});
|
|
586
|
-
}
|
|
587
|
-
catch (error) {
|
|
588
|
-
// File read or parse error - return null
|
|
589
|
-
errors.push(warnDeriveFunctionNoResultsSync(filePath, functionName, 'file read/parse error: ' + error));
|
|
590
|
-
result = null;
|
|
591
|
-
}
|
|
592
|
-
// Cache the result
|
|
593
|
-
processFunctionCache.set(cacheKey, result);
|
|
594
|
-
return result;
|
|
322
|
+
const cacheKey = `${filePath}::${functionName}`;
|
|
323
|
+
if (processFunctionCache.has(cacheKey)) return processFunctionCache.get(cacheKey) ?? null;
|
|
324
|
+
let result = null;
|
|
325
|
+
try {
|
|
326
|
+
traverse(parse(fs.readFileSync(filePath, "utf8"), {
|
|
327
|
+
sourceType: "module",
|
|
328
|
+
plugins: ["jsx", "typescript"]
|
|
329
|
+
}), {
|
|
330
|
+
ExportAllDeclaration(path) {
|
|
331
|
+
if (result !== null) return;
|
|
332
|
+
if (t.isStringLiteral(path.node.source)) {
|
|
333
|
+
const reexportPath = path.node.source.value;
|
|
334
|
+
const resolvedPath = resolveImportPath(filePath, reexportPath, parsingOptions, resolveImportPathCache);
|
|
335
|
+
if (resolvedPath) {
|
|
336
|
+
const reexportResult = resolveFunctionInFile(resolvedPath, functionName, parsingOptions, errors, warnings);
|
|
337
|
+
if (reexportResult) result = reexportResult;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
ExportNamedDeclaration(path) {
|
|
342
|
+
if (result !== null) return;
|
|
343
|
+
if (path.node.source && t.isStringLiteral(path.node.source)) {
|
|
344
|
+
if (path.node.specifiers.some((spec) => {
|
|
345
|
+
if (t.isExportSpecifier(spec)) return (t.isIdentifier(spec.exported) ? spec.exported.name : spec.exported.value) === functionName;
|
|
346
|
+
return false;
|
|
347
|
+
})) {
|
|
348
|
+
const reexportPath = path.node.source.value;
|
|
349
|
+
const resolvedPath = resolveImportPath(filePath, reexportPath, parsingOptions, resolveImportPathCache);
|
|
350
|
+
if (resolvedPath) {
|
|
351
|
+
const specifier = path.node.specifiers.find((spec) => {
|
|
352
|
+
if (t.isExportSpecifier(spec)) return (t.isIdentifier(spec.exported) ? spec.exported.name : spec.exported.value) === functionName;
|
|
353
|
+
return false;
|
|
354
|
+
});
|
|
355
|
+
let originalName = functionName;
|
|
356
|
+
if (specifier && t.isExportSpecifier(specifier) && t.isIdentifier(specifier.local)) originalName = specifier.local.name;
|
|
357
|
+
const reexportResult = resolveFunctionInFile(resolvedPath, originalName, parsingOptions, errors, warnings);
|
|
358
|
+
if (reexportResult) result = reexportResult;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
FunctionDeclaration(path) {
|
|
364
|
+
if (path.node.id?.name === functionName && result === null) {
|
|
365
|
+
const branches = [];
|
|
366
|
+
path.traverse({
|
|
367
|
+
Function(innerPath) {
|
|
368
|
+
innerPath.skip();
|
|
369
|
+
},
|
|
370
|
+
ReturnStatement(returnPath) {
|
|
371
|
+
if (!t.isReturnStatement(returnPath.node)) return;
|
|
372
|
+
const returnArg = returnPath.node.argument;
|
|
373
|
+
if (!returnArg || !t.isExpression(returnArg)) return;
|
|
374
|
+
const returnResult = parseStringExpression(returnArg, returnPath, filePath, parsingOptions, warnings, errors);
|
|
375
|
+
if (returnResult !== null) branches.push(returnResult);
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
if (branches.length === 1) result = branches[0];
|
|
379
|
+
else if (branches.length > 1) result = {
|
|
380
|
+
type: "choice",
|
|
381
|
+
nodes: branches
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
VariableDeclarator(path) {
|
|
386
|
+
if (t.isIdentifier(path.node.id) && path.node.id.name === functionName && path.node.init && (t.isArrowFunctionExpression(path.node.init) || t.isFunctionExpression(path.node.init)) && result === null) {
|
|
387
|
+
const init = path.get("init");
|
|
388
|
+
if (!init.isArrowFunctionExpression() && !init.isFunctionExpression()) return;
|
|
389
|
+
const bodyPath = init.get("body");
|
|
390
|
+
const branches = [];
|
|
391
|
+
if (!Array.isArray(bodyPath) && t.isExpression(bodyPath.node)) {
|
|
392
|
+
const bodyResult = parseStringExpression(bodyPath.node, bodyPath, filePath, parsingOptions, warnings, errors);
|
|
393
|
+
if (bodyResult !== null) branches.push(bodyResult);
|
|
394
|
+
} else if (!Array.isArray(bodyPath) && t.isBlockStatement(bodyPath.node)) {
|
|
395
|
+
const arrowFunction = init.node;
|
|
396
|
+
bodyPath.traverse({
|
|
397
|
+
Function(innerPath) {
|
|
398
|
+
innerPath.skip();
|
|
399
|
+
},
|
|
400
|
+
ReturnStatement(returnPath) {
|
|
401
|
+
if (returnPath.getFunctionParent()?.node !== arrowFunction) return;
|
|
402
|
+
if (!t.isReturnStatement(returnPath.node)) return;
|
|
403
|
+
const returnArg = returnPath.node.argument;
|
|
404
|
+
if (!returnArg || !t.isExpression(returnArg)) return;
|
|
405
|
+
const returnResult = parseStringExpression(returnArg, returnPath, filePath, parsingOptions, warnings, errors);
|
|
406
|
+
if (returnResult !== null) branches.push(returnResult);
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
if (branches.length === 1) result = branches[0];
|
|
411
|
+
else if (branches.length > 1) result = {
|
|
412
|
+
type: "choice",
|
|
413
|
+
nodes: branches
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
} catch (error) {
|
|
419
|
+
errors.push(warnDeriveFunctionNoResultsSync(filePath, functionName, "file read/parse error: " + error));
|
|
420
|
+
result = null;
|
|
421
|
+
}
|
|
422
|
+
processFunctionCache.set(cacheKey, result);
|
|
423
|
+
return result;
|
|
595
424
|
}
|
|
425
|
+
//#endregion
|
|
426
|
+
export { handleDerivation };
|
|
427
|
+
|
|
428
|
+
//# sourceMappingURL=handleDerivation.js.map
|