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.
Files changed (430) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/dist/api/collectUserEditDiffs.js +112 -155
  3. package/dist/api/collectUserEditDiffs.js.map +1 -0
  4. package/dist/api/downloadFileBatch.js +164 -241
  5. package/dist/api/downloadFileBatch.js.map +1 -0
  6. package/dist/api/saveLocalEdits.js +37 -41
  7. package/dist/api/saveLocalEdits.js.map +1 -0
  8. package/dist/bin/bin-entry.js +17 -7
  9. package/dist/bin/bin-entry.js.map +1 -0
  10. package/dist/bin/bin-main.js +43 -61
  11. package/dist/bin/bin-main.js.map +1 -0
  12. package/dist/cli/base.js +382 -497
  13. package/dist/cli/base.js.map +1 -0
  14. package/dist/cli/commands/download.js +41 -49
  15. package/dist/cli/commands/download.js.map +1 -0
  16. package/dist/cli/commands/enqueue.js +26 -25
  17. package/dist/cli/commands/enqueue.js.map +1 -0
  18. package/dist/cli/commands/setupProject.js +33 -36
  19. package/dist/cli/commands/setupProject.js.map +1 -0
  20. package/dist/cli/commands/stage.js +53 -61
  21. package/dist/cli/commands/stage.js.map +1 -0
  22. package/dist/cli/commands/translate.js +75 -112
  23. package/dist/cli/commands/translate.js.map +1 -0
  24. package/dist/cli/commands/upload.js +185 -213
  25. package/dist/cli/commands/upload.js.map +1 -0
  26. package/dist/cli/commands/utils/validation.js +39 -34
  27. package/dist/cli/commands/utils/validation.js.map +1 -0
  28. package/dist/cli/flags.js +35 -62
  29. package/dist/cli/flags.js.map +1 -0
  30. package/dist/cli/inline.js +112 -137
  31. package/dist/cli/inline.js.map +1 -0
  32. package/dist/cli/next.js +17 -12
  33. package/dist/cli/next.js.map +1 -0
  34. package/dist/cli/node.js +19 -15
  35. package/dist/cli/node.js.map +1 -0
  36. package/dist/cli/python.js +13 -8
  37. package/dist/cli/python.js.map +1 -0
  38. package/dist/cli/react.js +61 -78
  39. package/dist/cli/react.js.map +1 -0
  40. package/dist/config/defaults.js +16 -11
  41. package/dist/config/defaults.js.map +1 -0
  42. package/dist/config/generateSettings.js +167 -269
  43. package/dist/config/generateSettings.js.map +1 -0
  44. package/dist/config/optionPresets.js +78 -96
  45. package/dist/config/optionPresets.js.map +1 -0
  46. package/dist/config/resolveConfig.js +27 -32
  47. package/dist/config/resolveConfig.js.map +1 -0
  48. package/dist/config/utils.js +7 -3
  49. package/dist/config/utils.js.map +1 -0
  50. package/dist/config/validateSettings.js +19 -30
  51. package/dist/config/validateSettings.js.map +1 -0
  52. package/dist/console/colors.js +18 -13
  53. package/dist/console/colors.js.map +1 -0
  54. package/dist/console/displayTranslateSummary.js +40 -37
  55. package/dist/console/displayTranslateSummary.js.map +1 -0
  56. package/dist/console/formatting.js +8 -5
  57. package/dist/console/formatting.js.map +1 -0
  58. package/dist/console/index.d.ts +11 -9
  59. package/dist/console/index.js +53 -50
  60. package/dist/console/index.js.map +1 -0
  61. package/dist/console/inkFields.d.ts +23 -0
  62. package/dist/console/inkFields.js +87 -0
  63. package/dist/console/inkFields.js.map +1 -0
  64. package/dist/console/inkLayout.d.ts +7 -0
  65. package/dist/console/inkLayout.js +139 -0
  66. package/dist/console/inkLayout.js.map +1 -0
  67. package/dist/console/inkLocaleData.d.ts +4 -0
  68. package/dist/console/inkLocaleData.js +32 -0
  69. package/dist/console/inkLocaleData.js.map +1 -0
  70. package/dist/console/inkPrompts.d.ts +8 -0
  71. package/dist/console/inkPrompts.js +496 -0
  72. package/dist/console/inkPrompts.js.map +1 -0
  73. package/dist/console/inkSession.d.ts +3 -0
  74. package/dist/console/inkSession.js +42 -0
  75. package/dist/console/inkSession.js.map +1 -0
  76. package/dist/console/inkTerminal.d.ts +4 -0
  77. package/dist/console/inkTerminal.js +15 -0
  78. package/dist/console/inkTerminal.js.map +1 -0
  79. package/dist/console/inkTypes.d.ts +66 -0
  80. package/dist/console/inkTypes.js +1 -0
  81. package/dist/console/inkUtils.d.ts +24 -0
  82. package/dist/console/inkUtils.js +87 -0
  83. package/dist/console/inkUtils.js.map +1 -0
  84. package/dist/console/logger.js +209 -249
  85. package/dist/console/logger.js.map +1 -0
  86. package/dist/console/logging.d.ts +14 -0
  87. package/dist/console/logging.js +203 -162
  88. package/dist/console/logging.js.map +1 -0
  89. package/dist/console/promptParsing.d.ts +5 -0
  90. package/dist/console/promptParsing.js +28 -0
  91. package/dist/console/promptParsing.js.map +1 -0
  92. package/dist/console/terminalSession.d.ts +5 -0
  93. package/dist/console/terminalSession.js +38 -0
  94. package/dist/console/terminalSession.js.map +1 -0
  95. package/dist/extraction/index.js +3 -2
  96. package/dist/extraction/mapToUpdates.js +19 -18
  97. package/dist/extraction/mapToUpdates.js.map +1 -0
  98. package/dist/extraction/postProcess.js +68 -86
  99. package/dist/extraction/postProcess.js.map +1 -0
  100. package/dist/formats/files/aggregateFiles.js +223 -304
  101. package/dist/formats/files/aggregateFiles.js.map +1 -0
  102. package/dist/formats/files/collectFiles.js +53 -54
  103. package/dist/formats/files/collectFiles.js.map +1 -0
  104. package/dist/formats/files/convertToFileTranslationData.js +21 -19
  105. package/dist/formats/files/convertToFileTranslationData.js.map +1 -0
  106. package/dist/formats/files/fileMapping.js +82 -119
  107. package/dist/formats/files/fileMapping.js.map +1 -0
  108. package/dist/formats/files/preprocess/mdx.js +15 -12
  109. package/dist/formats/files/preprocess/mdx.js.map +1 -0
  110. package/dist/formats/files/preprocess/mintlify.js +15 -13
  111. package/dist/formats/files/preprocess/mintlify.js.map +1 -0
  112. package/dist/formats/files/preprocessContent.js +20 -21
  113. package/dist/formats/files/preprocessContent.js.map +1 -0
  114. package/dist/formats/files/save.js +18 -15
  115. package/dist/formats/files/save.js.map +1 -0
  116. package/dist/formats/files/supportedFiles.js +27 -22
  117. package/dist/formats/files/supportedFiles.js.map +1 -0
  118. package/dist/formats/files/transformFormat.js +93 -100
  119. package/dist/formats/files/transformFormat.js.map +1 -0
  120. package/dist/formats/json/extractJson.js +83 -110
  121. package/dist/formats/json/extractJson.js.map +1 -0
  122. package/dist/formats/json/flattenJson.js +41 -48
  123. package/dist/formats/json/flattenJson.js.map +1 -0
  124. package/dist/formats/json/jsonPath.js +20 -15
  125. package/dist/formats/json/jsonPath.js.map +1 -0
  126. package/dist/formats/json/jsonPointer.js +17 -17
  127. package/dist/formats/json/jsonPointer.js.map +1 -0
  128. package/dist/formats/json/mergeJson.js +230 -371
  129. package/dist/formats/json/mergeJson.js.map +1 -0
  130. package/dist/formats/json/parseJson.js +74 -111
  131. package/dist/formats/json/parseJson.js.map +1 -0
  132. package/dist/formats/json/transformJson.js +53 -61
  133. package/dist/formats/json/transformJson.js.map +1 -0
  134. package/dist/formats/json/utils.js +158 -187
  135. package/dist/formats/json/utils.js.map +1 -0
  136. package/dist/formats/parseKeyedMetadata.js +85 -106
  137. package/dist/formats/parseKeyedMetadata.js.map +1 -0
  138. package/dist/formats/utils.js +13 -23
  139. package/dist/formats/utils.js.map +1 -0
  140. package/dist/formats/yaml/extractYaml.js +32 -31
  141. package/dist/formats/yaml/extractYaml.js.map +1 -0
  142. package/dist/formats/yaml/mergeYaml.js +43 -60
  143. package/dist/formats/yaml/mergeYaml.js.map +1 -0
  144. package/dist/formats/yaml/parseYaml.js +34 -23
  145. package/dist/formats/yaml/parseYaml.js.map +1 -0
  146. package/dist/formats/yaml/utils.js +19 -21
  147. package/dist/formats/yaml/utils.js.map +1 -0
  148. package/dist/fs/clearLocaleDirs.js +82 -114
  149. package/dist/fs/clearLocaleDirs.js.map +1 -0
  150. package/dist/fs/config/downloadedVersions.js +174 -188
  151. package/dist/fs/config/downloadedVersions.js.map +1 -0
  152. package/dist/fs/config/loadConfig.js +12 -8
  153. package/dist/fs/config/loadConfig.js.map +1 -0
  154. package/dist/fs/config/parseFilesConfig.js +166 -227
  155. package/dist/fs/config/parseFilesConfig.js.map +1 -0
  156. package/dist/fs/config/setupConfig.js +43 -52
  157. package/dist/fs/config/setupConfig.js.map +1 -0
  158. package/dist/fs/config/updateConfig.js +44 -56
  159. package/dist/fs/config/updateConfig.js.map +1 -0
  160. package/dist/fs/config/updateVersions.js +27 -28
  161. package/dist/fs/config/updateVersions.js.map +1 -0
  162. package/dist/fs/copyFile.js +33 -37
  163. package/dist/fs/copyFile.js.map +1 -0
  164. package/dist/fs/createLoadTranslationsFile.js +32 -48
  165. package/dist/fs/createLoadTranslationsFile.js.map +1 -0
  166. package/dist/fs/determineFramework/detectPythonLibrary.js +30 -34
  167. package/dist/fs/determineFramework/detectPythonLibrary.js.map +1 -0
  168. package/dist/fs/determineFramework/index.js +46 -64
  169. package/dist/fs/determineFramework/index.js.map +1 -0
  170. package/dist/fs/determineFramework/matchPyprojectDependency.js +65 -78
  171. package/dist/fs/determineFramework/matchPyprojectDependency.js.map +1 -0
  172. package/dist/fs/determineFramework/matchRequirementsTxtDependency.js +21 -19
  173. package/dist/fs/determineFramework/matchRequirementsTxtDependency.js.map +1 -0
  174. package/dist/fs/determineFramework/matchSetupPyDependency.js +60 -81
  175. package/dist/fs/determineFramework/matchSetupPyDependency.js.map +1 -0
  176. package/dist/fs/determineFramework/resolveGtDependency.js +15 -15
  177. package/dist/fs/determineFramework/resolveGtDependency.js.map +1 -0
  178. package/dist/fs/findFilepath.js +63 -78
  179. package/dist/fs/findFilepath.js.map +1 -0
  180. package/dist/fs/loadJSON.js +18 -15
  181. package/dist/fs/loadJSON.js.map +1 -0
  182. package/dist/fs/matchFiles.js +12 -7
  183. package/dist/fs/matchFiles.js.map +1 -0
  184. package/dist/fs/saveJSON.js +10 -6
  185. package/dist/fs/saveJSON.js.map +1 -0
  186. package/dist/fs/utils.js +19 -15
  187. package/dist/fs/utils.js.map +1 -0
  188. package/dist/functions.d.ts +2 -1
  189. package/dist/functions.js +3 -6
  190. package/dist/generated/version.d.ts +1 -1
  191. package/dist/generated/version.js +6 -2
  192. package/dist/generated/version.js.map +1 -0
  193. package/dist/git/branches.js +77 -83
  194. package/dist/git/branches.js.map +1 -0
  195. package/dist/hooks/postProcess.js +97 -114
  196. package/dist/hooks/postProcess.js.map +1 -0
  197. package/dist/index.js +23 -31
  198. package/dist/index.js.map +1 -0
  199. package/dist/locadex/setupFlow.js +11 -8
  200. package/dist/locadex/setupFlow.js.map +1 -0
  201. package/dist/main.js +17 -7
  202. package/dist/main.js.map +1 -0
  203. package/dist/next/config/parseNextConfig.js +32 -51
  204. package/dist/next/config/parseNextConfig.js.map +1 -0
  205. package/dist/next/jsx/utils.js +25 -37
  206. package/dist/next/jsx/utils.js.map +1 -0
  207. package/dist/next/parse/handleInitGT.js +87 -154
  208. package/dist/next/parse/handleInitGT.js.map +1 -0
  209. package/dist/next/parse/wrapContent.js +136 -158
  210. package/dist/next/parse/wrapContent.js.map +1 -0
  211. package/dist/python/parse/createPythonInlineUpdates.js +36 -33
  212. package/dist/python/parse/createPythonInlineUpdates.js.map +1 -0
  213. package/dist/react/config/createESBuildConfig.js +115 -115
  214. package/dist/react/config/createESBuildConfig.js.map +1 -0
  215. package/dist/react/jsx/evaluateJsx.js +90 -124
  216. package/dist/react/jsx/evaluateJsx.js.map +1 -0
  217. package/dist/react/jsx/utils/buildImportMap.js +24 -28
  218. package/dist/react/jsx/utils/buildImportMap.js.map +1 -0
  219. package/dist/react/jsx/utils/constants.js +79 -87
  220. package/dist/react/jsx/utils/constants.js.map +1 -0
  221. package/dist/react/jsx/utils/extractSourceCode.js +36 -37
  222. package/dist/react/jsx/utils/extractSourceCode.js.map +1 -0
  223. package/dist/react/jsx/utils/getCalleeNameFromExpression.js +30 -30
  224. package/dist/react/jsx/utils/getCalleeNameFromExpression.js.map +1 -0
  225. package/dist/react/jsx/utils/getPathsAndAliases.js +70 -105
  226. package/dist/react/jsx/utils/getPathsAndAliases.js.map +1 -0
  227. package/dist/react/jsx/utils/isNumberLiteral.js +13 -11
  228. package/dist/react/jsx/utils/isNumberLiteral.js.map +1 -0
  229. package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.js +103 -148
  230. package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.js.map +1 -0
  231. package/dist/react/jsx/utils/jsxParsing/autoInsertion.js +305 -389
  232. package/dist/react/jsx/utils/jsxParsing/autoInsertion.js.map +1 -0
  233. package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.js +122 -193
  234. package/dist/react/jsx/utils/jsxParsing/handleChildrenWhitespace.js.map +1 -0
  235. package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.js +50 -64
  236. package/dist/react/jsx/utils/jsxParsing/multiplication/findMultiplicationNode.js.map +1 -0
  237. package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.js +41 -68
  238. package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.js.map +1 -0
  239. package/dist/react/jsx/utils/jsxParsing/parseJsx.js +760 -1107
  240. package/dist/react/jsx/utils/jsxParsing/parseJsx.js.map +1 -0
  241. package/dist/react/jsx/utils/jsxParsing/parseTProps.js +35 -71
  242. package/dist/react/jsx/utils/jsxParsing/parseTProps.js.map +1 -0
  243. package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.js +39 -58
  244. package/dist/react/jsx/utils/jsxParsing/removeNullChildrenFields.js.map +1 -0
  245. package/dist/react/jsx/utils/jsxParsing/types.js +10 -24
  246. package/dist/react/jsx/utils/jsxParsing/types.js.map +1 -0
  247. package/dist/react/jsx/utils/mapAttributeName.js +13 -13
  248. package/dist/react/jsx/utils/mapAttributeName.js.map +1 -0
  249. package/dist/react/jsx/utils/parseAst.js +142 -272
  250. package/dist/react/jsx/utils/parseAst.js.map +1 -0
  251. package/dist/react/jsx/utils/parseString.js +726 -1090
  252. package/dist/react/jsx/utils/parseString.js.map +1 -0
  253. package/dist/react/jsx/utils/parseStringFunction.js +274 -401
  254. package/dist/react/jsx/utils/parseStringFunction.js.map +1 -0
  255. package/dist/react/jsx/utils/resolveImportPath.d.ts +1 -1
  256. package/dist/react/jsx/utils/resolveImportPath.js +125 -108
  257. package/dist/react/jsx/utils/resolveImportPath.js.map +1 -0
  258. package/dist/react/jsx/utils/stringParsing/derivation/containsDeriveCall.js +18 -24
  259. package/dist/react/jsx/utils/stringParsing/derivation/containsDeriveCall.js.map +1 -0
  260. package/dist/react/jsx/utils/stringParsing/derivation/handleDerivation.js +412 -579
  261. package/dist/react/jsx/utils/stringParsing/derivation/handleDerivation.js.map +1 -0
  262. package/dist/react/jsx/utils/stringParsing/derivation/index.js +57 -67
  263. package/dist/react/jsx/utils/stringParsing/derivation/index.js.map +1 -0
  264. package/dist/react/jsx/utils/stringParsing/derivation/isDeriveCall.js +26 -36
  265. package/dist/react/jsx/utils/stringParsing/derivation/isDeriveCall.js.map +1 -0
  266. package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/handleTaggedTemplateTranslationCall.js +29 -24
  267. package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/handleTaggedTemplateTranslationCall.js.map +1 -0
  268. package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/index.js +34 -32
  269. package/dist/react/jsx/utils/stringParsing/processTaggedTemplateCall/index.js.map +1 -0
  270. package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.js +80 -117
  271. package/dist/react/jsx/utils/stringParsing/processTranslationCall/extractStringEntryMetadata.js.map +1 -0
  272. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleDeriveTranslationCall.js +24 -19
  273. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleDeriveTranslationCall.js.map +1 -0
  274. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.js +18 -21
  275. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleInvalidTranslationCall.js.map +1 -0
  276. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.js +45 -50
  277. package/dist/react/jsx/utils/stringParsing/processTranslationCall/handleLiteralTranslationCall.js.map +1 -0
  278. package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.js +54 -59
  279. package/dist/react/jsx/utils/stringParsing/processTranslationCall/index.js.map +1 -0
  280. package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.js +56 -69
  281. package/dist/react/jsx/utils/stringParsing/processTranslationCall/routeTranslationCall.js.map +1 -0
  282. package/dist/react/jsx/utils/validateStringFunction.js +21 -29
  283. package/dist/react/jsx/utils/validateStringFunction.js.map +1 -0
  284. package/dist/react/jsx/wrapJsx.js +192 -375
  285. package/dist/react/jsx/wrapJsx.js.map +1 -0
  286. package/dist/react/parse/addVitePlugin/index.js +40 -34
  287. package/dist/react/parse/addVitePlugin/index.js.map +1 -0
  288. package/dist/react/parse/addVitePlugin/installCompiler.js +18 -20
  289. package/dist/react/parse/addVitePlugin/installCompiler.js.map +1 -0
  290. package/dist/react/parse/addVitePlugin/updateViteConfig.js +107 -111
  291. package/dist/react/parse/addVitePlugin/updateViteConfig.js.map +1 -0
  292. package/dist/react/parse/addVitePlugin/utils/addCompilerImport.js +23 -26
  293. package/dist/react/parse/addVitePlugin/utils/addCompilerImport.js.map +1 -0
  294. package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.js +29 -43
  295. package/dist/react/parse/addVitePlugin/utils/addPluginInvocation.js.map +1 -0
  296. package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.js +70 -104
  297. package/dist/react/parse/addVitePlugin/utils/checkCompilerImport.js.map +1 -0
  298. package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.js +23 -29
  299. package/dist/react/parse/addVitePlugin/utils/checkPluginInvocation.js.map +1 -0
  300. package/dist/react/parse/createDictionaryUpdates.js +121 -185
  301. package/dist/react/parse/createDictionaryUpdates.js.map +1 -0
  302. package/dist/react/parse/createInlineUpdates.js +123 -139
  303. package/dist/react/parse/createInlineUpdates.js.map +1 -0
  304. package/dist/react/parse/wrapContent.js +131 -156
  305. package/dist/react/parse/wrapContent.js.map +1 -0
  306. package/dist/react/utils/flattenDictionary.js +55 -70
  307. package/dist/react/utils/flattenDictionary.js.map +1 -0
  308. package/dist/react/utils/getEntryAndMetadata.js +14 -10
  309. package/dist/react/utils/getEntryAndMetadata.js.map +1 -0
  310. package/dist/react/utils/getVariableName.js +36 -33
  311. package/dist/react/utils/getVariableName.js.map +1 -0
  312. package/dist/setup/detectFramework.js +85 -102
  313. package/dist/setup/detectFramework.js.map +1 -0
  314. package/dist/setup/frameworkUtils.js +17 -28
  315. package/dist/setup/frameworkUtils.js.map +1 -0
  316. package/dist/setup/userInput.js +24 -31
  317. package/dist/setup/userInput.js.map +1 -0
  318. package/dist/setup/wizard.js +141 -143
  319. package/dist/setup/wizard.js.map +1 -0
  320. package/dist/state/mintlifyRefMap.js +12 -9
  321. package/dist/state/mintlifyRefMap.js.map +1 -0
  322. package/dist/state/recentDownloads.js +26 -23
  323. package/dist/state/recentDownloads.js.map +1 -0
  324. package/dist/state/translateWarnings.js +17 -8
  325. package/dist/state/translateWarnings.js.map +1 -0
  326. package/dist/translation/parse.js +77 -98
  327. package/dist/translation/parse.js.map +1 -0
  328. package/dist/translation/stage.js +28 -43
  329. package/dist/translation/stage.js.map +1 -0
  330. package/dist/translation/validate.js +68 -91
  331. package/dist/translation/validate.js.map +1 -0
  332. package/dist/types/libraries.js +93 -91
  333. package/dist/types/libraries.js.map +1 -0
  334. package/dist/types/parsing.js +19 -10
  335. package/dist/types/parsing.js.map +1 -0
  336. package/dist/utils/addExplicitAnchorIds.js +270 -389
  337. package/dist/utils/addExplicitAnchorIds.js.map +1 -0
  338. package/dist/utils/calculateTimeoutMs.js +11 -6
  339. package/dist/utils/calculateTimeoutMs.js.map +1 -0
  340. package/dist/utils/constants.js +15 -12
  341. package/dist/utils/constants.js.map +1 -0
  342. package/dist/utils/credentials.js +67 -114
  343. package/dist/utils/credentials.js.map +1 -0
  344. package/dist/utils/fetch.js +22 -20
  345. package/dist/utils/fetch.js.map +1 -0
  346. package/dist/utils/flattenJsonFiles.js +27 -34
  347. package/dist/utils/flattenJsonFiles.js.map +1 -0
  348. package/dist/utils/gitDiff.js +30 -32
  349. package/dist/utils/gitDiff.js.map +1 -0
  350. package/dist/utils/gt.js +7 -2
  351. package/dist/utils/gt.js.map +1 -0
  352. package/dist/utils/hash.js +14 -9
  353. package/dist/utils/hash.js.map +1 -0
  354. package/dist/utils/headers.js +10 -13
  355. package/dist/utils/headers.js.map +1 -0
  356. package/dist/utils/installPackage.js +70 -75
  357. package/dist/utils/installPackage.js.map +1 -0
  358. package/dist/utils/localizeRelativeAssets.js +114 -157
  359. package/dist/utils/localizeRelativeAssets.js.map +1 -0
  360. package/dist/utils/localizeStaticImports.js +229 -371
  361. package/dist/utils/localizeStaticImports.js.map +1 -0
  362. package/dist/utils/localizeStaticUrls.js +241 -424
  363. package/dist/utils/localizeStaticUrls.js.map +1 -0
  364. package/dist/utils/mintlifyTitleFallback.js +64 -72
  365. package/dist/utils/mintlifyTitleFallback.js.map +1 -0
  366. package/dist/utils/monorepoVersionCheck.js +177 -215
  367. package/dist/utils/monorepoVersionCheck.js.map +1 -0
  368. package/dist/utils/packageInfo.js +17 -16
  369. package/dist/utils/packageInfo.js.map +1 -0
  370. package/dist/utils/packageJson.js +51 -66
  371. package/dist/utils/packageJson.js.map +1 -0
  372. package/dist/utils/packageManager.js +237 -260
  373. package/dist/utils/packageManager.js.map +1 -0
  374. package/dist/utils/parse/needsCJS.js +36 -69
  375. package/dist/utils/parse/needsCJS.js.map +1 -0
  376. package/dist/utils/persistPostprocessHashes.js +30 -32
  377. package/dist/utils/persistPostprocessHashes.js.map +1 -0
  378. package/dist/utils/processAnchorIds.js +32 -54
  379. package/dist/utils/processAnchorIds.js.map +1 -0
  380. package/dist/utils/processOpenApi.js +469 -578
  381. package/dist/utils/processOpenApi.js.map +1 -0
  382. package/dist/utils/resolveMintlifyRefs.js +89 -105
  383. package/dist/utils/resolveMintlifyRefs.js.map +1 -0
  384. package/dist/utils/resolvePublish.js +46 -54
  385. package/dist/utils/resolvePublish.js.map +1 -0
  386. package/dist/utils/sanitizeFileContent.js +20 -27
  387. package/dist/utils/sanitizeFileContent.js.map +1 -0
  388. package/dist/utils/sharedStaticAssets.js +248 -366
  389. package/dist/utils/sharedStaticAssets.js.map +1 -0
  390. package/dist/utils/splitMintlifyLanguageRefs.js +208 -282
  391. package/dist/utils/splitMintlifyLanguageRefs.js.map +1 -0
  392. package/dist/utils/validateMdx.js +26 -23
  393. package/dist/utils/validateMdx.js.map +1 -0
  394. package/dist/utils/wrapPlainUrls.js +58 -70
  395. package/dist/utils/wrapPlainUrls.js.map +1 -0
  396. package/dist/workflows/download.js +92 -126
  397. package/dist/workflows/download.js.map +1 -0
  398. package/dist/workflows/enqueue.js +47 -54
  399. package/dist/workflows/enqueue.js.map +1 -0
  400. package/dist/workflows/publish.js +29 -29
  401. package/dist/workflows/publish.js.map +1 -0
  402. package/dist/workflows/setupProject.js +39 -40
  403. package/dist/workflows/setupProject.js.map +1 -0
  404. package/dist/workflows/stage.js +61 -65
  405. package/dist/workflows/stage.js.map +1 -0
  406. package/dist/workflows/steps/BranchStep.js +118 -163
  407. package/dist/workflows/steps/BranchStep.js.map +1 -0
  408. package/dist/workflows/steps/DownloadStep.js +107 -137
  409. package/dist/workflows/steps/DownloadStep.js.map +1 -0
  410. package/dist/workflows/steps/EnqueueStep.js +32 -32
  411. package/dist/workflows/steps/EnqueueStep.js.map +1 -0
  412. package/dist/workflows/steps/PollJobsStep.js +208 -292
  413. package/dist/workflows/steps/PollJobsStep.js.map +1 -0
  414. package/dist/workflows/steps/PublishStep.js +33 -38
  415. package/dist/workflows/steps/PublishStep.js.map +1 -0
  416. package/dist/workflows/steps/SetupStep.js +71 -72
  417. package/dist/workflows/steps/SetupStep.js.map +1 -0
  418. package/dist/workflows/steps/TagStep.js +39 -44
  419. package/dist/workflows/steps/TagStep.js.map +1 -0
  420. package/dist/workflows/steps/UploadSourcesStep.js +108 -140
  421. package/dist/workflows/steps/UploadSourcesStep.js.map +1 -0
  422. package/dist/workflows/steps/UploadTranslationsStep.js +61 -71
  423. package/dist/workflows/steps/UploadTranslationsStep.js.map +1 -0
  424. package/dist/workflows/steps/UserEditDiffsStep.js +32 -34
  425. package/dist/workflows/steps/UserEditDiffsStep.js.map +1 -0
  426. package/dist/workflows/steps/WorkflowStep.js +6 -2
  427. package/dist/workflows/steps/WorkflowStep.js.map +1 -0
  428. package/dist/workflows/upload.js +45 -46
  429. package/dist/workflows/upload.js.map +1 -0
  430. package/package.json +14 -7
@@ -1,425 +1,298 @@
1
- import * as t from '@babel/types';
2
- import { INLINE_TRANSLATION_HOOK, INLINE_TRANSLATION_HOOK_ASYNC, INLINE_MESSAGE_HOOK, INLINE_MESSAGE_HOOK_ASYNC, STRING_REGISTRATION_FUNCS, T_GLOBAL_REGISTRATION_FUNCTION_MARKER, } from './constants.js';
3
- import { warnAsyncUseGT, warnSyncGetGT, warnUnresolvedImportSync, } from '../../../console/index.js';
4
- import traverseModule from '@babel/traverse';
5
- // Handle CommonJS/ESM interop
1
+ import { STRING_REGISTRATION_FUNCS } from "./constants.js";
2
+ import { warnAsyncUseGT, warnSyncGetGT, warnUnresolvedImportSync } from "../../../console/index.js";
3
+ import { resolveImportPath } from "./resolveImportPath.js";
4
+ import { buildImportMap } from "./buildImportMap.js";
5
+ import { processTranslationCall } from "./stringParsing/processTranslationCall/index.js";
6
+ import { processTaggedTemplateCall } from "./stringParsing/processTaggedTemplateCall/index.js";
7
+ import fs from "node:fs";
8
+ import * as t from "@babel/types";
9
+ import { parse } from "@babel/parser";
10
+ import traverseModule from "@babel/traverse";
11
+ //#region src/react/jsx/utils/parseStringFunction.ts
6
12
  const traverse = traverseModule.default || traverseModule;
7
- import fs from 'node:fs';
8
- import { parse } from '@babel/parser';
9
- import { resolveImportPath } from './resolveImportPath.js';
10
- import { buildImportMap } from './buildImportMap.js';
11
- import { processTranslationCall } from './stringParsing/processTranslationCall/index.js';
12
- import { processTaggedTemplateCall } from './stringParsing/processTaggedTemplateCall/index.js';
13
13
  /**
14
- * Cache for resolved import paths to avoid redundant I/O operations.
15
- * Key: `${currentFile}::${importPath}`
16
- * Value: resolved absolute path or null
17
- */
18
- const resolveImportPathCache = new Map();
14
+ * Cache for resolved import paths to avoid redundant I/O operations.
15
+ * Key: `${currentFile}::${importPath}`
16
+ * Value: resolved absolute path or null
17
+ */
18
+ const resolveImportPathCache = /* @__PURE__ */ new Map();
19
19
  /**
20
- * Cache for processed functions to avoid re-parsing the same files.
21
- * Key: `${filePath}::${functionName}::${argIndex}`
22
- * Value: boolean indicating whether the function was found and processed
23
- */
24
- const processFunctionCache = new Map();
20
+ * Cache for processed functions to avoid re-parsing the same files.
21
+ * Key: `${filePath}::${functionName}::${argIndex}`
22
+ * Value: boolean indicating whether the function was found and processed
23
+ */
24
+ const processFunctionCache = /* @__PURE__ */ new Map();
25
25
  /**
26
- * Clears all caches. Useful for testing or when file system changes.
27
- */
28
- export function clearParsingCaches() {
29
- resolveImportPathCache.clear();
30
- processFunctionCache.clear();
26
+ * Clears all caches. Useful for testing or when file system changes.
27
+ */
28
+ function clearParsingCaches() {
29
+ resolveImportPathCache.clear();
30
+ processFunctionCache.clear();
31
31
  }
32
32
  /**
33
- * Extracts the parameter name from a function parameter node, handling TypeScript annotations and default values.
34
- */
33
+ * Extracts the parameter name from a function parameter node, handling TypeScript annotations and default values.
34
+ */
35
35
  function extractParameterName(param) {
36
- if (t.isIdentifier(param)) {
37
- return param.name;
38
- }
39
- // Handle parameters with default values: (gt = () => {})
40
- if (t.isAssignmentPattern(param) && t.isIdentifier(param.left)) {
41
- return param.left.name;
42
- }
43
- return null;
36
+ if (t.isIdentifier(param)) return param.name;
37
+ if (t.isAssignmentPattern(param) && t.isIdentifier(param.left)) return param.left.name;
38
+ return null;
44
39
  }
45
40
  /**
46
- * Recursively resolves variable assignments to find all aliases of a translation callback parameter.
47
- * Handles cases like: const t = translate; const a = translate; const b = a; const c = b;
48
- *
49
- * @param scope The scope to search within
50
- * @param variableName The variable name to resolve
51
- * @param visited Set to track already visited variables to prevent infinite loops
52
- * @returns Array of all variable names that reference the original translation callback
53
- */
54
- export function resolveVariableAliases(scope, variableName, visited = new Set()) {
55
- if (visited.has(variableName)) {
56
- return []; // Prevent infinite loops
57
- }
58
- visited.add(variableName);
59
- const aliases = [variableName];
60
- const binding = scope.bindings[variableName];
61
- if (binding) {
62
- // Look for variable declarations that assign this variable to another name
63
- // Example: const t = translate; or const a = t;
64
- for (const [otherVarName, otherBinding] of Object.entries(scope.bindings)) {
65
- if (otherVarName === variableName || visited.has(otherVarName))
66
- continue;
67
- const otherBindingTyped = otherBinding;
68
- if (otherBindingTyped.path &&
69
- otherBindingTyped.path.isVariableDeclarator() &&
70
- otherBindingTyped.path.node.init &&
71
- t.isIdentifier(otherBindingTyped.path.node.init) &&
72
- otherBindingTyped.path.node.init.name === variableName) {
73
- // Found an alias: const otherVarName = variableName;
74
- const nestedAliases = resolveVariableAliases(scope, otherVarName, visited);
75
- aliases.push(...nestedAliases);
76
- }
77
- }
78
- }
79
- return aliases;
41
+ * Recursively resolves variable assignments to find all aliases of a translation callback parameter.
42
+ * Handles cases like: const t = translate; const a = translate; const b = a; const c = b;
43
+ *
44
+ * @param scope The scope to search within
45
+ * @param variableName The variable name to resolve
46
+ * @param visited Set to track already visited variables to prevent infinite loops
47
+ * @returns Array of all variable names that reference the original translation callback
48
+ */
49
+ function resolveVariableAliases(scope, variableName, visited = /* @__PURE__ */ new Set()) {
50
+ if (visited.has(variableName)) return [];
51
+ visited.add(variableName);
52
+ const aliases = [variableName];
53
+ if (scope.bindings[variableName]) for (const [otherVarName, otherBinding] of Object.entries(scope.bindings)) {
54
+ if (otherVarName === variableName || visited.has(otherVarName)) continue;
55
+ const otherBindingTyped = otherBinding;
56
+ if (otherBindingTyped.path && otherBindingTyped.path.isVariableDeclarator() && otherBindingTyped.path.node.init && t.isIdentifier(otherBindingTyped.path.node.init) && otherBindingTyped.path.node.init.name === variableName) {
57
+ const nestedAliases = resolveVariableAliases(scope, otherVarName, visited);
58
+ aliases.push(...nestedAliases);
59
+ }
60
+ }
61
+ return aliases;
80
62
  }
81
63
  /**
82
- * Handles how translation callbacks are used within code.
83
- * This covers both direct translation calls (gt('hello')) and prop drilling
84
- * where the translation callback is passed to other functions (getData(gt)).
85
- */
64
+ * Handles how translation callbacks are used within code.
65
+ * This covers both direct translation calls (gt('hello')) and prop drilling
66
+ * where the translation callback is passed to other functions (getData(gt)).
67
+ */
86
68
  function handleFunctionCall(tPath, config, state, output, visitedFunctions) {
87
- if (tPath.parent.type === 'CallExpression' &&
88
- tPath.parent.callee === tPath.node) {
89
- // Direct translation call: t('hello')
90
- processTranslationCall(tPath, config, output);
91
- }
92
- else if (!config.ignoreTaggedTemplates &&
93
- tPath.parent.type === 'TaggedTemplateExpression' &&
94
- tPath.parent.tag === tPath.node) {
95
- // Tagged template: t`hello ${name}`
96
- processTaggedTemplateCall(tPath, config, output);
97
- }
98
- else if (tPath.parent.type === 'CallExpression' &&
99
- t.isExpression(tPath.node) &&
100
- tPath.parent.arguments.includes(tPath.node)) {
101
- // Parameter passed to another function: getData(t)
102
- const argIndex = tPath.parent.arguments.indexOf(tPath.node);
103
- const callee = tPath.parent.callee;
104
- if (t.isIdentifier(callee)) {
105
- const calleeBinding = tPath.scope.getBinding(callee.name);
106
- if (calleeBinding && calleeBinding.path.isFunction()) {
107
- const functionPath = calleeBinding.path;
108
- processFunctionIfMatches(callee.name, argIndex, functionPath.node, functionPath, config, output, visitedFunctions);
109
- }
110
- // Handle arrow functions assigned to variables: const getData = (t) => {...}
111
- else if (calleeBinding &&
112
- calleeBinding.path.isVariableDeclarator() &&
113
- calleeBinding.path.node.init &&
114
- (t.isArrowFunctionExpression(calleeBinding.path.node.init) ||
115
- t.isFunctionExpression(calleeBinding.path.node.init))) {
116
- const initPath = calleeBinding.path.get('init');
117
- processFunctionIfMatches(callee.name, argIndex, calleeBinding.path.node.init, initPath, config, output, visitedFunctions);
118
- }
119
- // If not found locally, check if it's an imported function
120
- else if (state.importMap.has(callee.name)) {
121
- const importPath = state.importMap.get(callee.name);
122
- const resolvedPath = resolveImportPath(config.file, importPath, config.parsingOptions, resolveImportPathCache);
123
- if (resolvedPath) {
124
- processFunctionInFile(resolvedPath, callee.name, argIndex, config, state, output);
125
- }
126
- else {
127
- output.warnings.add(warnUnresolvedImportSync(config.file, callee.name, importPath, tPath.node.loc
128
- ? `${tPath.node.loc.start.line}:${tPath.node.loc.start.column}`
129
- : undefined));
130
- }
131
- }
132
- }
133
- }
69
+ if (tPath.parent.type === "CallExpression" && tPath.parent.callee === tPath.node) processTranslationCall(tPath, config, output);
70
+ else if (!config.ignoreTaggedTemplates && tPath.parent.type === "TaggedTemplateExpression" && tPath.parent.tag === tPath.node) processTaggedTemplateCall(tPath, config, output);
71
+ else if (tPath.parent.type === "CallExpression" && t.isExpression(tPath.node) && tPath.parent.arguments.includes(tPath.node)) {
72
+ const argIndex = tPath.parent.arguments.indexOf(tPath.node);
73
+ const callee = tPath.parent.callee;
74
+ if (t.isIdentifier(callee)) {
75
+ const calleeBinding = tPath.scope.getBinding(callee.name);
76
+ if (calleeBinding && calleeBinding.path.isFunction()) {
77
+ const functionPath = calleeBinding.path;
78
+ processFunctionIfMatches(callee.name, argIndex, functionPath.node, functionPath, config, output, visitedFunctions);
79
+ } else if (calleeBinding && calleeBinding.path.isVariableDeclarator() && calleeBinding.path.node.init && (t.isArrowFunctionExpression(calleeBinding.path.node.init) || t.isFunctionExpression(calleeBinding.path.node.init))) {
80
+ const initPath = calleeBinding.path.get("init");
81
+ processFunctionIfMatches(callee.name, argIndex, calleeBinding.path.node.init, initPath, config, output, visitedFunctions);
82
+ } else if (state.importMap.has(callee.name)) {
83
+ const importPath = state.importMap.get(callee.name);
84
+ const resolvedPath = resolveImportPath(config.file, importPath, config.parsingOptions, resolveImportPathCache);
85
+ if (resolvedPath) processFunctionInFile(resolvedPath, callee.name, argIndex, config, state, output);
86
+ else output.warnings.add(warnUnresolvedImportSync(config.file, callee.name, importPath, tPath.node.loc ? `${tPath.node.loc.start.line}:${tPath.node.loc.start.column}` : void 0));
87
+ }
88
+ }
89
+ }
134
90
  }
135
91
  /**
136
- * Processes a user-defined function that receives a translation callback as a parameter.
137
- * Validates the function has enough parameters and traces how the translation callback
138
- * is used within that function's body.
139
- */
92
+ * Processes a user-defined function that receives a translation callback as a parameter.
93
+ * Validates the function has enough parameters and traces how the translation callback
94
+ * is used within that function's body.
95
+ */
140
96
  function processFunctionIfMatches(_functionName, argIndex, functionNode, functionPath, config, output, visitedFunctions) {
141
- if (visitedFunctions.has(functionNode))
142
- return;
143
- visitedFunctions.add(functionNode);
144
- if (functionNode.params.length > argIndex) {
145
- const param = functionNode.params[argIndex];
146
- const paramName = extractParameterName(param);
147
- if (paramName) {
148
- findFunctionParameterUsage(functionPath, paramName, config, output, visitedFunctions);
149
- }
150
- }
151
- visitedFunctions.delete(functionNode);
97
+ if (visitedFunctions.has(functionNode)) return;
98
+ visitedFunctions.add(functionNode);
99
+ if (functionNode.params.length > argIndex) {
100
+ const param = functionNode.params[argIndex];
101
+ const paramName = extractParameterName(param);
102
+ if (paramName) findFunctionParameterUsage(functionPath, paramName, config, output, visitedFunctions);
103
+ }
104
+ visitedFunctions.delete(functionNode);
152
105
  }
153
106
  /**
154
- * Finds all usages of a translation callback parameter within a user-defined function's scope.
155
- * Processes both direct translation calls and cases where the translation callback is passed
156
- * to other functions (prop drilling).
157
- *
158
- * Example: In function getInfo(t) { return t('hello'); }, this finds the t('hello') call.
159
- * Example: In function getData(t) { return getFooter(t); }, this finds and traces into getFooter.
160
- */
107
+ * Finds all usages of a translation callback parameter within a user-defined function's scope.
108
+ * Processes both direct translation calls and cases where the translation callback is passed
109
+ * to other functions (prop drilling).
110
+ *
111
+ * Example: In function getInfo(t) { return t('hello'); }, this finds the t('hello') call.
112
+ * Example: In function getData(t) { return getFooter(t); }, this finds and traces into getFooter.
113
+ */
161
114
  function findFunctionParameterUsage(functionPath, parameterName, config, output, visitedFunctions) {
162
- // Look for the function body and find all usages of the parameter
163
- if (functionPath.isFunction()) {
164
- const functionScope = functionPath.scope;
165
- // Resolve all aliases of the translation callback parameter
166
- // Example: translate -> [translate, t, a, b] for const t = translate; const a = t; const b = a;
167
- const allParameterNames = resolveVariableAliases(functionScope, parameterName);
168
- // Build import map for this function's scope to handle cross-file calls
169
- const programPath = functionPath.scope.getProgramParent().path;
170
- const importMap = buildImportMap(programPath);
171
- // Process references for all parameter names and their aliases
172
- allParameterNames.forEach((name) => {
173
- const binding = functionScope.bindings[name];
174
- if (binding) {
175
- binding.referencePaths.forEach((refPath) => {
176
- handleFunctionCall(refPath, config, { visited: new Set(), importMap }, output, visitedFunctions);
177
- });
178
- }
179
- });
180
- }
115
+ if (functionPath.isFunction()) {
116
+ const functionScope = functionPath.scope;
117
+ const allParameterNames = resolveVariableAliases(functionScope, parameterName);
118
+ const programPath = functionPath.scope.getProgramParent().path;
119
+ const importMap = buildImportMap(programPath);
120
+ allParameterNames.forEach((name) => {
121
+ const binding = functionScope.bindings[name];
122
+ if (binding) binding.referencePaths.forEach((refPath) => {
123
+ handleFunctionCall(refPath, config, {
124
+ visited: /* @__PURE__ */ new Set(),
125
+ importMap
126
+ }, output, visitedFunctions);
127
+ });
128
+ });
129
+ }
181
130
  }
182
131
  /**
183
- * Searches for a specific user-defined function in a file and analyzes how a translation callback
184
- * parameter (at argIndex position) is used within that function.
185
- *
186
- * Handles multiple function declaration patterns:
187
- * - function getInfo(t) { ... }
188
- * - export function getInfo(t) { ... }
189
- * - const getInfo = (t) => { ... }
190
- *
191
- * If the function is not found in the file, follows re-exports (export * from './other')
192
- */
132
+ * Searches for a specific user-defined function in a file and analyzes how a translation callback
133
+ * parameter (at argIndex position) is used within that function.
134
+ *
135
+ * Handles multiple function declaration patterns:
136
+ * - function getInfo(t) { ... }
137
+ * - export function getInfo(t) { ... }
138
+ * - const getInfo = (t) => { ... }
139
+ *
140
+ * If the function is not found in the file, follows re-exports (export * from './other')
141
+ */
193
142
  function processFunctionInFile(filePath, functionName, argIndex, config, state, output) {
194
- // Check cache first to avoid redundant parsing
195
- const cacheKey = `${filePath}::${functionName}::${argIndex}`;
196
- if (processFunctionCache.has(cacheKey)) {
197
- return;
198
- }
199
- // Prevent infinite loops from circular re-exports
200
- if (state.visited.has(filePath)) {
201
- return;
202
- }
203
- state.visited.add(filePath);
204
- try {
205
- const code = fs.readFileSync(filePath, 'utf8');
206
- const ast = parse(code, {
207
- sourceType: 'module',
208
- plugins: ['jsx', 'typescript'],
209
- });
210
- let found = false;
211
- const reExports = [];
212
- // Fresh set per cross-file parse — node identity is only stable within a single parse.
213
- // Cross-file cycles are already guarded by processFunctionCache above.
214
- const visitedFunctions = new Set();
215
- // Update config.file so relative imports in the target file resolve correctly
216
- const crossFileConfig = { ...config, file: filePath };
217
- traverse(ast, {
218
- // Handle function declarations: function getInfo(t) { ... }
219
- FunctionDeclaration(path) {
220
- if (path.node.id?.name === functionName) {
221
- found = true;
222
- processFunctionIfMatches(functionName, argIndex, path.node, path, crossFileConfig, output, visitedFunctions);
223
- }
224
- },
225
- // Handle variable declarations: const getInfo = (t) => { ... }
226
- VariableDeclarator(path) {
227
- if (t.isIdentifier(path.node.id) &&
228
- path.node.id.name === functionName &&
229
- path.node.init &&
230
- (t.isArrowFunctionExpression(path.node.init) ||
231
- t.isFunctionExpression(path.node.init))) {
232
- found = true;
233
- const initPath = path.get('init');
234
- processFunctionIfMatches(functionName, argIndex, path.node.init, initPath, crossFileConfig, output, visitedFunctions);
235
- }
236
- },
237
- // Collect re-exports: export * from './other'
238
- ExportAllDeclaration(path) {
239
- if (t.isStringLiteral(path.node.source)) {
240
- reExports.push(path.node.source.value);
241
- }
242
- },
243
- // Collect named re-exports: export { foo } from './other'
244
- ExportNamedDeclaration(path) {
245
- if (path.node.source && t.isStringLiteral(path.node.source)) {
246
- // Check if this export includes our function
247
- const exportsFunction = path.node.specifiers.some((spec) => {
248
- if (t.isExportSpecifier(spec)) {
249
- const exportedName = t.isIdentifier(spec.exported)
250
- ? spec.exported.name
251
- : spec.exported.value;
252
- return exportedName === functionName;
253
- }
254
- return false;
255
- });
256
- if (exportsFunction) {
257
- reExports.push(path.node.source.value);
258
- }
259
- }
260
- },
261
- });
262
- // If function not found, follow re-exports
263
- if (!found && reExports.length > 0) {
264
- for (const reExportPath of reExports) {
265
- const resolvedPath = resolveImportPath(filePath, reExportPath, config.parsingOptions, resolveImportPathCache);
266
- if (resolvedPath) {
267
- processFunctionInFile(resolvedPath, functionName, argIndex, config, state, output);
268
- }
269
- }
270
- }
271
- // Mark this function search as processed in the cache
272
- processFunctionCache.set(cacheKey, found);
273
- }
274
- catch {
275
- // Silently skip files that can't be parsed or accessed
276
- // Still mark as processed to avoid retrying failed parses
277
- processFunctionCache.set(cacheKey, false);
278
- }
143
+ const cacheKey = `${filePath}::${functionName}::${argIndex}`;
144
+ if (processFunctionCache.has(cacheKey)) return;
145
+ if (state.visited.has(filePath)) return;
146
+ state.visited.add(filePath);
147
+ try {
148
+ const ast = parse(fs.readFileSync(filePath, "utf8"), {
149
+ sourceType: "module",
150
+ plugins: ["jsx", "typescript"]
151
+ });
152
+ let found = false;
153
+ const reExports = [];
154
+ const visitedFunctions = /* @__PURE__ */ new Set();
155
+ const crossFileConfig = {
156
+ ...config,
157
+ file: filePath
158
+ };
159
+ traverse(ast, {
160
+ FunctionDeclaration(path) {
161
+ if (path.node.id?.name === functionName) {
162
+ found = true;
163
+ processFunctionIfMatches(functionName, argIndex, path.node, path, crossFileConfig, output, visitedFunctions);
164
+ }
165
+ },
166
+ VariableDeclarator(path) {
167
+ if (t.isIdentifier(path.node.id) && path.node.id.name === functionName && path.node.init && (t.isArrowFunctionExpression(path.node.init) || t.isFunctionExpression(path.node.init))) {
168
+ found = true;
169
+ const initPath = path.get("init");
170
+ processFunctionIfMatches(functionName, argIndex, path.node.init, initPath, crossFileConfig, output, visitedFunctions);
171
+ }
172
+ },
173
+ ExportAllDeclaration(path) {
174
+ if (t.isStringLiteral(path.node.source)) reExports.push(path.node.source.value);
175
+ },
176
+ ExportNamedDeclaration(path) {
177
+ if (path.node.source && t.isStringLiteral(path.node.source)) {
178
+ if (path.node.specifiers.some((spec) => {
179
+ if (t.isExportSpecifier(spec)) return (t.isIdentifier(spec.exported) ? spec.exported.name : spec.exported.value) === functionName;
180
+ return false;
181
+ })) reExports.push(path.node.source.value);
182
+ }
183
+ }
184
+ });
185
+ if (!found && reExports.length > 0) for (const reExportPath of reExports) {
186
+ const resolvedPath = resolveImportPath(filePath, reExportPath, config.parsingOptions, resolveImportPathCache);
187
+ if (resolvedPath) processFunctionInFile(resolvedPath, functionName, argIndex, config, state, output);
188
+ }
189
+ processFunctionCache.set(cacheKey, found);
190
+ } catch {
191
+ processFunctionCache.set(cacheKey, false);
192
+ }
279
193
  }
280
194
  /**
281
- * Main entry point for parsing translation strings from useGT() and getGT() calls.
282
- *
283
- * Supports complex patterns including:
284
- * 1. Direct calls: const gt = useGT(); gt('hello');
285
- * 2. Translation callback prop drilling: const gt = useGT(); getInfo(gt); where getInfo uses gt() internally
286
- * 3. Cross-file function calls: imported functions that receive the translation callback as a parameter
287
- *
288
- * Example flow:
289
- * - const gt = useGT();
290
- * - const { home } = getInfo(gt); // getInfo is imported from './constants'
291
- * - This will parse constants.ts to find translation calls within getInfo function
292
- */
293
- export function parseStrings(importName, originalName, path, config, output) {
294
- // Handle global t macro directly — path is already the tag identifier
295
- // NOTE: if we decide to add support for a global t() function in addition to the macro,
296
- // then we need to add support for skipDeriveInvocation here
297
- if (originalName === T_GLOBAL_REGISTRATION_FUNCTION_MARKER) {
298
- if (!config.ignoreGlobalTaggedTemplates) {
299
- processTaggedTemplateCall(path, {
300
- ...config,
301
- autoderiveMethod: config.autoderiveMethod === 'AUTO'
302
- ? 'DISABLED'
303
- : config.autoderiveMethod,
304
- }, output);
305
- }
306
- return;
307
- }
308
- // First, collect all imports in this file to track cross-file function calls
309
- const importMap = buildImportMap(path.scope.getProgramParent().path);
310
- const referencePaths = path.scope.bindings[importName]?.referencePaths || [];
311
- for (const refPath of referencePaths) {
312
- // Handle msg(), t() calls directly without variable assignment
313
- if (STRING_REGISTRATION_FUNCS.includes(originalName)) {
314
- const stringRegistrationConfig = {
315
- parsingOptions: config.parsingOptions,
316
- file: config.file,
317
- ignoreInlineMetadata: false,
318
- ignoreDynamicContent: false,
319
- ignoreInvalidIcu: false,
320
- ignoreInlineListContent: false,
321
- includeSourceCodeContext: config.includeSourceCodeContext,
322
- ignoreTaggedTemplates: false,
323
- ignoreGlobalTaggedTemplates: false,
324
- // User configurable, otherwise default to AUTO
325
- autoderiveMethod: config.autoderiveMethod === 'AUTO'
326
- ? 'DISABLED'
327
- : config.autoderiveMethod,
328
- };
329
- // Check if this is a direct call to msg('string') or t('string')
330
- if (refPath.parent.type === 'CallExpression' &&
331
- refPath.parent.callee === refPath.node) {
332
- /**
333
- * CASE: Autoderive t() and msg() function
334
- * The t() function, will treat variable content as if it was marked for derivation
335
- * without explicit calls to derive().
336
- *
337
- * @example
338
- * const derivedValue = 'John';
339
- * const interpolatedValue = "Ernest"
340
- * t(
341
- * "Hello, " + derivedValue + "! My name is {interpolatedValue}",
342
- * { interpolatedValue }
343
- * );
344
- * // "Hello, John! My name is {interpolatedValue}"
345
- */
346
- processTranslationCall(refPath, config.autoderiveMethod === 'AUTO'
347
- ? {
348
- ...stringRegistrationConfig,
349
- autoderiveMethod: 'ENABLED',
350
- }
351
- : stringRegistrationConfig, output);
352
- }
353
- else if (!stringRegistrationConfig.ignoreTaggedTemplates &&
354
- refPath.parent.type === 'TaggedTemplateExpression' &&
355
- refPath.parent.tag === refPath.node) {
356
- // Tagged template: t`hello ${name}`
357
- processTaggedTemplateCall(refPath, stringRegistrationConfig, output);
358
- }
359
- continue;
360
- }
361
- // Handle useGT(), getGT(), useMessages(), and getMessages() calls that need variable assignment
362
- const callExpr = refPath.findParent((p) => p.isCallExpression());
363
- if (callExpr) {
364
- // Get the parent, handling both await and non-await cases
365
- const parentPath = callExpr.parentPath;
366
- const parentFunction = refPath.getFunctionParent();
367
- const asyncScope = parentFunction?.node.async;
368
- if (asyncScope &&
369
- (originalName === INLINE_TRANSLATION_HOOK ||
370
- originalName === INLINE_MESSAGE_HOOK)) {
371
- output.errors.push(warnAsyncUseGT(config.file, `${refPath.node.loc?.start?.line}:${refPath.node.loc?.start?.column}`));
372
- return;
373
- }
374
- else if (!asyncScope &&
375
- (originalName === INLINE_TRANSLATION_HOOK_ASYNC ||
376
- originalName === INLINE_MESSAGE_HOOK_ASYNC)) {
377
- output.errors.push(warnSyncGetGT(config.file, `${refPath.node.loc?.start?.line}:${refPath.node.loc?.start?.column}`));
378
- return;
379
- }
380
- const isMessageHook = originalName === INLINE_MESSAGE_HOOK ||
381
- originalName === INLINE_MESSAGE_HOOK_ASYNC;
382
- const isInlineGT = originalName === INLINE_TRANSLATION_HOOK ||
383
- originalName === INLINE_TRANSLATION_HOOK_ASYNC;
384
- const hookConfig = {
385
- parsingOptions: config.parsingOptions,
386
- file: config.file,
387
- ignoreInlineMetadata: isMessageHook,
388
- ignoreDynamicContent: isMessageHook,
389
- ignoreInvalidIcu: isMessageHook,
390
- // TODO: when we add support for array content in gt function, this should just always be false
391
- ignoreInlineListContent: isInlineGT,
392
- includeSourceCodeContext: config.includeSourceCodeContext,
393
- ignoreTaggedTemplates: false,
394
- ignoreGlobalTaggedTemplates: false,
395
- // User configurable, otherwise default to DISABLED
396
- autoderiveMethod: config.autoderiveMethod === 'AUTO'
397
- ? isInlineGT
398
- ? 'ENABLED'
399
- : 'DISABLED'
400
- : config.autoderiveMethod,
401
- };
402
- const effectiveParent = parentPath?.node.type === 'AwaitExpression'
403
- ? parentPath.parentPath
404
- : parentPath;
405
- if (effectiveParent &&
406
- effectiveParent.node.type === 'VariableDeclarator' &&
407
- effectiveParent.node.id.type === 'Identifier') {
408
- const tFuncName = effectiveParent.node.id.name;
409
- // Get the scope from the variable declaration
410
- const variableScope = effectiveParent.scope;
411
- // Resolve all aliases of the translation function
412
- // Example: translate -> [translate, t, a, b] for const t = translate; const a = t; const b = a;
413
- const allTranslationNames = resolveVariableAliases(variableScope, tFuncName);
414
- // Process references for all translation function names and their aliases
415
- const visitedFunctions = new Set();
416
- allTranslationNames.forEach((name) => {
417
- const tReferencePaths = variableScope.bindings[name]?.referencePaths || [];
418
- for (const tPath of tReferencePaths) {
419
- handleFunctionCall(tPath, hookConfig, { visited: new Set(), importMap }, output, visitedFunctions);
420
- }
421
- });
422
- }
423
- }
424
- }
195
+ * Main entry point for parsing translation strings from useGT() and getGT() calls.
196
+ *
197
+ * Supports complex patterns including:
198
+ * 1. Direct calls: const gt = useGT(); gt('hello');
199
+ * 2. Translation callback prop drilling: const gt = useGT(); getInfo(gt); where getInfo uses gt() internally
200
+ * 3. Cross-file function calls: imported functions that receive the translation callback as a parameter
201
+ *
202
+ * Example flow:
203
+ * - const gt = useGT();
204
+ * - const { home } = getInfo(gt); // getInfo is imported from './constants'
205
+ * - This will parse constants.ts to find translation calls within getInfo function
206
+ */
207
+ function parseStrings(importName, originalName, path, config, output) {
208
+ if (originalName === "_gt_internal_t_global_registration_marker") {
209
+ if (!config.ignoreGlobalTaggedTemplates) processTaggedTemplateCall(path, {
210
+ ...config,
211
+ autoderiveMethod: config.autoderiveMethod === "AUTO" ? "DISABLED" : config.autoderiveMethod
212
+ }, output);
213
+ return;
214
+ }
215
+ const importMap = buildImportMap(path.scope.getProgramParent().path);
216
+ const referencePaths = path.scope.bindings[importName]?.referencePaths || [];
217
+ for (const refPath of referencePaths) {
218
+ if (STRING_REGISTRATION_FUNCS.includes(originalName)) {
219
+ const stringRegistrationConfig = {
220
+ parsingOptions: config.parsingOptions,
221
+ file: config.file,
222
+ ignoreInlineMetadata: false,
223
+ ignoreDynamicContent: false,
224
+ ignoreInvalidIcu: false,
225
+ ignoreInlineListContent: false,
226
+ includeSourceCodeContext: config.includeSourceCodeContext,
227
+ ignoreTaggedTemplates: false,
228
+ ignoreGlobalTaggedTemplates: false,
229
+ autoderiveMethod: config.autoderiveMethod === "AUTO" ? "DISABLED" : config.autoderiveMethod
230
+ };
231
+ if (refPath.parent.type === "CallExpression" && refPath.parent.callee === refPath.node)
232
+ /**
233
+ * CASE: Autoderive t() and msg() function
234
+ * The t() function, will treat variable content as if it was marked for derivation
235
+ * without explicit calls to derive().
236
+ *
237
+ * @example
238
+ * const derivedValue = 'John';
239
+ * const interpolatedValue = "Ernest"
240
+ * t(
241
+ * "Hello, " + derivedValue + "! My name is {interpolatedValue}",
242
+ * { interpolatedValue }
243
+ * );
244
+ * // "Hello, John! My name is {interpolatedValue}"
245
+ */
246
+ processTranslationCall(refPath, config.autoderiveMethod === "AUTO" ? {
247
+ ...stringRegistrationConfig,
248
+ autoderiveMethod: "ENABLED"
249
+ } : stringRegistrationConfig, output);
250
+ else if (!stringRegistrationConfig.ignoreTaggedTemplates && refPath.parent.type === "TaggedTemplateExpression" && refPath.parent.tag === refPath.node) processTaggedTemplateCall(refPath, stringRegistrationConfig, output);
251
+ continue;
252
+ }
253
+ const callExpr = refPath.findParent((p) => p.isCallExpression());
254
+ if (callExpr) {
255
+ const parentPath = callExpr.parentPath;
256
+ const asyncScope = refPath.getFunctionParent()?.node.async;
257
+ if (asyncScope && (originalName === "useGT" || originalName === "useMessages")) {
258
+ output.errors.push(warnAsyncUseGT(config.file, `${refPath.node.loc?.start?.line}:${refPath.node.loc?.start?.column}`));
259
+ return;
260
+ } else if (!asyncScope && (originalName === "getGT" || originalName === "getMessages")) {
261
+ output.errors.push(warnSyncGetGT(config.file, `${refPath.node.loc?.start?.line}:${refPath.node.loc?.start?.column}`));
262
+ return;
263
+ }
264
+ const isMessageHook = originalName === "useMessages" || originalName === "getMessages";
265
+ const isInlineGT = originalName === "useGT" || originalName === "getGT";
266
+ const hookConfig = {
267
+ parsingOptions: config.parsingOptions,
268
+ file: config.file,
269
+ ignoreInlineMetadata: isMessageHook,
270
+ ignoreDynamicContent: isMessageHook,
271
+ ignoreInvalidIcu: isMessageHook,
272
+ ignoreInlineListContent: isInlineGT,
273
+ includeSourceCodeContext: config.includeSourceCodeContext,
274
+ ignoreTaggedTemplates: false,
275
+ ignoreGlobalTaggedTemplates: false,
276
+ autoderiveMethod: config.autoderiveMethod === "AUTO" ? isInlineGT ? "ENABLED" : "DISABLED" : config.autoderiveMethod
277
+ };
278
+ const effectiveParent = parentPath?.node.type === "AwaitExpression" ? parentPath.parentPath : parentPath;
279
+ if (effectiveParent && effectiveParent.node.type === "VariableDeclarator" && effectiveParent.node.id.type === "Identifier") {
280
+ const tFuncName = effectiveParent.node.id.name;
281
+ const variableScope = effectiveParent.scope;
282
+ const allTranslationNames = resolveVariableAliases(variableScope, tFuncName);
283
+ const visitedFunctions = /* @__PURE__ */ new Set();
284
+ allTranslationNames.forEach((name) => {
285
+ const tReferencePaths = variableScope.bindings[name]?.referencePaths || [];
286
+ for (const tPath of tReferencePaths) handleFunctionCall(tPath, hookConfig, {
287
+ visited: /* @__PURE__ */ new Set(),
288
+ importMap
289
+ }, output, visitedFunctions);
290
+ });
291
+ }
292
+ }
293
+ }
425
294
  }
295
+ //#endregion
296
+ export { clearParsingCaches, parseStrings, resolveVariableAliases };
297
+
298
+ //# sourceMappingURL=parseStringFunction.js.map