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,164 +1,142 @@
1
- import fs from 'node:fs';
2
- import * as t from '@babel/types';
3
- import { parse } from '@babel/parser';
4
- import traverseModule from '@babel/traverse';
5
- import generateModule from '@babel/generator';
6
- // Handle CommonJS/ESM interop
1
+ import { getRelativePath } from "../../fs/findFilepath.js";
2
+ import { isMeaningful } from "../../react/jsx/evaluateJsx.js";
3
+ import { createImports, generateImportMap } from "../../react/jsx/utils/parseAst.js";
4
+ import "../../types/libraries.js";
5
+ import { matchFiles } from "../../fs/matchFiles.js";
6
+ import { DEFAULT_SRC_PATTERNS } from "../../config/generateSettings.js";
7
+ import { handleJsxElement } from "../../react/jsx/wrapJsx.js";
8
+ import { addDynamicLangAttribute, hasGTProviderChild, isBodyElement, isHtmlElement, makeParentFunctionAsync } from "../jsx/utils.js";
9
+ import fs from "node:fs";
10
+ import * as t from "@babel/types";
11
+ import { parse } from "@babel/parser";
12
+ import generateModule from "@babel/generator";
13
+ import traverseModule from "@babel/traverse";
14
+ //#region src/next/parse/wrapContent.ts
7
15
  const traverse = traverseModule.default || traverseModule;
8
16
  const generate = generateModule.default || generateModule;
9
- import { isMeaningful } from '../../react/jsx/evaluateJsx.js';
10
- import { handleJsxElement } from '../../react/jsx/wrapJsx.js';
11
- import { getRelativePath } from '../../fs/findFilepath.js';
12
- import { isHtmlElement, isBodyElement, hasGTProviderChild, addDynamicLangAttribute, makeParentFunctionAsync, } from '../jsx/utils.js';
13
- import { generateImportMap, createImports, } from '../../react/jsx/utils/parseAst.js';
14
- import { matchFiles } from '../../fs/matchFiles.js';
15
- import { DEFAULT_SRC_PATTERNS } from '../../config/generateSettings.js';
16
- import { Libraries } from '../../types/libraries.js';
17
17
  const IMPORT_MAP = {
18
- T: { name: 'T', source: Libraries.GT_NEXT },
19
- Var: { name: 'Var', source: Libraries.GT_NEXT },
20
- GTT: { name: 'T', source: Libraries.GT_NEXT },
21
- GTVar: { name: 'Var', source: Libraries.GT_NEXT },
22
- GTProvider: { name: 'GTProvider', source: Libraries.GT_NEXT },
23
- getLocale: { name: 'getLocale', source: Libraries.GT_NEXT + '/server' },
18
+ T: {
19
+ name: "T",
20
+ source: "gt-next"
21
+ },
22
+ Var: {
23
+ name: "Var",
24
+ source: "gt-next"
25
+ },
26
+ GTT: {
27
+ name: "T",
28
+ source: "gt-next"
29
+ },
30
+ GTVar: {
31
+ name: "Var",
32
+ source: "gt-next"
33
+ },
34
+ GTProvider: {
35
+ name: "GTProvider",
36
+ source: "gt-next"
37
+ },
38
+ getLocale: {
39
+ name: "getLocale",
40
+ source: "gt-next/server"
41
+ }
24
42
  };
25
43
  /**
26
- * Wraps all JSX elements in the src directory with a <T> tag, with unique ids.
27
- * - Ignores pure strings
28
- *
29
- * @param options - The options object
30
- * @returns An object containing the updates and errors
31
- */
32
- export async function wrapContentNext(options, pkg, errors, warnings) {
33
- const files = matchFiles(process.cwd(), options.src || DEFAULT_SRC_PATTERNS);
34
- const filesUpdated = [];
35
- for (const file of files) {
36
- const code = await fs.promises.readFile(file, 'utf8');
37
- // Create relative path from src directory and remove extension
38
- const relativePath = getRelativePath(file, process.cwd());
39
- let ast;
40
- try {
41
- ast = parse(code, {
42
- sourceType: 'module',
43
- plugins: ['jsx', 'typescript'],
44
- tokens: true,
45
- createParenthesizedExpressions: true,
46
- });
47
- }
48
- catch (error) {
49
- errors.push(`Error: Failed to parse ${file}: ${error}`);
50
- continue;
51
- }
52
- let modified = false;
53
- const usedImports = [];
54
- const { importAlias, initialImports } = generateImportMap(ast, pkg);
55
- // If the file already has a T import, skip processing it
56
- if (initialImports.includes(IMPORT_MAP.T.name)) {
57
- continue;
58
- }
59
- let globalId = 0;
60
- traverse(ast, {
61
- JSXElement(path) {
62
- if (pkg === Libraries.GT_NEXT &&
63
- options.addGTProvider &&
64
- isHtmlElement(path.node.openingElement)) {
65
- // Find the body element recursively in the HTML tree
66
- const findBodyElement = (children) => {
67
- for (const child of children) {
68
- if (t.isJSXElement(child) &&
69
- isBodyElement(child.openingElement)) {
70
- return child;
71
- }
72
- if (t.isJSXElement(child)) {
73
- const bodyInChild = findBodyElement(child.children);
74
- if (bodyInChild)
75
- return bodyInChild;
76
- }
77
- }
78
- return null;
79
- };
80
- const bodyElement = findBodyElement(path.node.children);
81
- if (!bodyElement) {
82
- warnings.push(`File ${file} has a <html> tag without a <body> tag. Skipping GTProvider insertion.`);
83
- return;
84
- }
85
- // Skip if body already has GTProvider
86
- if (hasGTProviderChild(bodyElement)) {
87
- return;
88
- }
89
- // Handle lang attribute for html tag
90
- const langAttr = path.node.openingElement.attributes.find((attr) => t.isJSXAttribute(attr) &&
91
- t.isJSXIdentifier(attr.name) &&
92
- t.isStringLiteral(attr.value) &&
93
- attr.name.name === 'lang');
94
- if (langAttr) {
95
- makeParentFunctionAsync(path);
96
- addDynamicLangAttribute(path.node.openingElement);
97
- usedImports.push('getLocale');
98
- }
99
- // Wrap body children with GTProvider
100
- const bodyChildren = bodyElement.children;
101
- const gtProviderElement = t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier('GTProvider'), [], false), t.jsxClosingElement(t.jsxIdentifier('GTProvider')), bodyChildren, false);
102
- bodyElement.children = [gtProviderElement];
103
- usedImports.push('GTProvider');
104
- modified = true;
105
- path.skip();
106
- return;
107
- }
108
- // If skip wrapping Ts, skip processing this node
109
- if (options.skipTs) {
110
- return;
111
- }
112
- // Check if this JSX element has any JSX element ancestors
113
- if (t.isJSXElement(path.parentPath?.node) ||
114
- t.isJSXExpressionContainer(path.parentPath?.node)) {
115
- // If we found a JSX parent, skip processing this node
116
- return;
117
- }
118
- // At this point, we're only processing top-level JSX elements
119
- const opts = {
120
- ...importAlias,
121
- idPrefix: relativePath,
122
- idCount: globalId,
123
- usedImports,
124
- modified: false,
125
- createIds: !options.disableIds,
126
- warnings,
127
- file,
128
- };
129
- const wrapped = handleJsxElement(path.node, opts, isMeaningful);
130
- path.replaceWith(wrapped.node);
131
- // Update global counters
132
- modified = modified || opts.modified;
133
- globalId = opts.idCount;
134
- },
135
- });
136
- if (!modified)
137
- continue;
138
- const needsImport = usedImports.filter((imp) => !initialImports.includes(imp));
139
- if (needsImport.length > 0) {
140
- createImports(ast, needsImport, IMPORT_MAP);
141
- }
142
- try {
143
- const output = generate(ast, {
144
- retainLines: true,
145
- retainFunctionParens: true,
146
- comments: true,
147
- compact: 'auto',
148
- }, code);
149
- // Post-process the output to fix import spacing
150
- let processedCode = output.code;
151
- if (needsImport.length > 0) {
152
- // Add newline after the comment only
153
- processedCode = processedCode.replace(/((?:import\s*{\s*(?:T|GTT|Var|GTVar|GTProvider|getLocale)(?:\s*,\s*(?:T|GTT|Var|GTVar|GTProvider|getLocale))*\s*}\s*from|const\s*{\s*(?:T|GTT|Var|GTVar|GTProvider|getLocale)(?:\s*,\s*(?:T|GTT|Var|GTVar|GTProvider|getLocale))*\s*}\s*=\s*require)\s*['"]gt-(?:next|react)(?:\/server)?['"];?)/, '\n$1\n');
154
- }
155
- // Write the modified code back to the file
156
- await fs.promises.writeFile(file, processedCode);
157
- filesUpdated.push(file);
158
- }
159
- catch (error) {
160
- errors.push(`Error: Failed to write ${file}: ${error}`);
161
- }
162
- }
163
- return { filesUpdated };
44
+ * Wraps all JSX elements in the src directory with a <T> tag, with unique ids.
45
+ * - Ignores pure strings
46
+ *
47
+ * @param options - The options object
48
+ * @returns An object containing the updates and errors
49
+ */
50
+ async function wrapContentNext(options, pkg, errors, warnings) {
51
+ const files = matchFiles(process.cwd(), options.src || DEFAULT_SRC_PATTERNS);
52
+ const filesUpdated = [];
53
+ for (const file of files) {
54
+ const code = await fs.promises.readFile(file, "utf8");
55
+ const relativePath = getRelativePath(file, process.cwd());
56
+ let ast;
57
+ try {
58
+ ast = parse(code, {
59
+ sourceType: "module",
60
+ plugins: ["jsx", "typescript"],
61
+ tokens: true,
62
+ createParenthesizedExpressions: true
63
+ });
64
+ } catch (error) {
65
+ errors.push(`Error: Failed to parse ${file}: ${error}`);
66
+ continue;
67
+ }
68
+ let modified = false;
69
+ const usedImports = [];
70
+ const { importAlias, initialImports } = generateImportMap(ast, pkg);
71
+ if (initialImports.includes(IMPORT_MAP.T.name)) continue;
72
+ let globalId = 0;
73
+ traverse(ast, { JSXElement(path) {
74
+ if (pkg === "gt-next" && options.addGTProvider && isHtmlElement(path.node.openingElement)) {
75
+ const findBodyElement = (children) => {
76
+ for (const child of children) {
77
+ if (t.isJSXElement(child) && isBodyElement(child.openingElement)) return child;
78
+ if (t.isJSXElement(child)) {
79
+ const bodyInChild = findBodyElement(child.children);
80
+ if (bodyInChild) return bodyInChild;
81
+ }
82
+ }
83
+ return null;
84
+ };
85
+ const bodyElement = findBodyElement(path.node.children);
86
+ if (!bodyElement) {
87
+ warnings.push(`File ${file} has a <html> tag without a <body> tag. Skipping GTProvider insertion.`);
88
+ return;
89
+ }
90
+ if (hasGTProviderChild(bodyElement)) return;
91
+ if (path.node.openingElement.attributes.find((attr) => t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name) && t.isStringLiteral(attr.value) && attr.name.name === "lang")) {
92
+ makeParentFunctionAsync(path);
93
+ addDynamicLangAttribute(path.node.openingElement);
94
+ usedImports.push("getLocale");
95
+ }
96
+ const bodyChildren = bodyElement.children;
97
+ bodyElement.children = [t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier("GTProvider"), [], false), t.jsxClosingElement(t.jsxIdentifier("GTProvider")), bodyChildren, false)];
98
+ usedImports.push("GTProvider");
99
+ modified = true;
100
+ path.skip();
101
+ return;
102
+ }
103
+ if (options.skipTs) return;
104
+ if (t.isJSXElement(path.parentPath?.node) || t.isJSXExpressionContainer(path.parentPath?.node)) return;
105
+ const opts = {
106
+ ...importAlias,
107
+ idPrefix: relativePath,
108
+ idCount: globalId,
109
+ usedImports,
110
+ modified: false,
111
+ createIds: !options.disableIds,
112
+ warnings,
113
+ file
114
+ };
115
+ const wrapped = handleJsxElement(path.node, opts, isMeaningful);
116
+ path.replaceWith(wrapped.node);
117
+ modified = modified || opts.modified;
118
+ globalId = opts.idCount;
119
+ } });
120
+ if (!modified) continue;
121
+ const needsImport = usedImports.filter((imp) => !initialImports.includes(imp));
122
+ if (needsImport.length > 0) createImports(ast, needsImport, IMPORT_MAP);
123
+ try {
124
+ let processedCode = generate(ast, {
125
+ retainLines: true,
126
+ retainFunctionParens: true,
127
+ comments: true,
128
+ compact: "auto"
129
+ }, code).code;
130
+ if (needsImport.length > 0) processedCode = processedCode.replace(/((?:import\s*{\s*(?:T|GTT|Var|GTVar|GTProvider|getLocale)(?:\s*,\s*(?:T|GTT|Var|GTVar|GTProvider|getLocale))*\s*}\s*from|const\s*{\s*(?:T|GTT|Var|GTVar|GTProvider|getLocale)(?:\s*,\s*(?:T|GTT|Var|GTVar|GTProvider|getLocale))*\s*}\s*=\s*require)\s*['"]gt-(?:next|react)(?:\/server)?['"];?)/, "\n$1\n");
131
+ await fs.promises.writeFile(file, processedCode);
132
+ filesUpdated.push(file);
133
+ } catch (error) {
134
+ errors.push(`Error: Failed to write ${file}: ${error}`);
135
+ }
136
+ }
137
+ return { filesUpdated };
164
138
  }
139
+ //#endregion
140
+ export { wrapContentNext };
141
+
142
+ //# sourceMappingURL=wrapContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapContent.js","names":[],"sources":["../../../src/next/parse/wrapContent.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { WrapOptions } from '../../types/index.js';\nimport * as t from '@babel/types';\nimport { parse } from '@babel/parser';\nimport traverseModule from '@babel/traverse';\nimport generateModule from '@babel/generator';\n\n// Handle CommonJS/ESM interop\nconst traverse = traverseModule.default || traverseModule;\nconst generate = generateModule.default || generateModule;\n\nimport { isMeaningful } from '../../react/jsx/evaluateJsx.js';\nimport { handleJsxElement } from '../../react/jsx/wrapJsx.js';\nimport { getRelativePath } from '../../fs/findFilepath.js';\nimport {\n isHtmlElement,\n isBodyElement,\n hasGTProviderChild,\n addDynamicLangAttribute,\n makeParentFunctionAsync,\n} from '../jsx/utils.js';\nimport {\n generateImportMap,\n createImports,\n} from '../../react/jsx/utils/parseAst.js';\nimport { matchFiles } from '../../fs/matchFiles.js';\nimport { DEFAULT_SRC_PATTERNS } from '../../config/generateSettings.js';\nimport { Libraries } from '../../types/libraries.js';\n\nconst IMPORT_MAP = {\n T: { name: 'T', source: Libraries.GT_NEXT },\n Var: { name: 'Var', source: Libraries.GT_NEXT },\n GTT: { name: 'T', source: Libraries.GT_NEXT },\n GTVar: { name: 'Var', source: Libraries.GT_NEXT },\n GTProvider: { name: 'GTProvider', source: Libraries.GT_NEXT },\n getLocale: { name: 'getLocale', source: Libraries.GT_NEXT + '/server' },\n};\n\n/**\n * Wraps all JSX elements in the src directory with a <T> tag, with unique ids.\n * - Ignores pure strings\n *\n * @param options - The options object\n * @returns An object containing the updates and errors\n */\nexport async function wrapContentNext(\n options: WrapOptions,\n pkg: `${typeof Libraries.GT_NEXT}`,\n errors: string[],\n warnings: string[]\n): Promise<{ filesUpdated: string[] }> {\n const files = matchFiles(process.cwd(), options.src || DEFAULT_SRC_PATTERNS);\n const filesUpdated = [];\n\n for (const file of files) {\n const code = await fs.promises.readFile(file, 'utf8');\n\n // Create relative path from src directory and remove extension\n const relativePath = getRelativePath(file, process.cwd());\n\n let ast;\n try {\n ast = parse(code, {\n sourceType: 'module',\n plugins: ['jsx', 'typescript'],\n tokens: true,\n createParenthesizedExpressions: true,\n });\n } catch (error) {\n errors.push(`Error: Failed to parse ${file}: ${error}`);\n continue;\n }\n\n let modified = false;\n const usedImports: string[] = [];\n\n const { importAlias, initialImports } = generateImportMap(ast, pkg);\n\n // If the file already has a T import, skip processing it\n if (initialImports.includes(IMPORT_MAP.T.name)) {\n continue;\n }\n\n let globalId = 0;\n traverse(ast, {\n JSXElement(path) {\n if (\n pkg === Libraries.GT_NEXT &&\n options.addGTProvider &&\n isHtmlElement(path.node.openingElement)\n ) {\n // Find the body element recursively in the HTML tree\n const findBodyElement = (\n children: t.JSXElement['children']\n ): t.JSXElement | null => {\n for (const child of children) {\n if (\n t.isJSXElement(child) &&\n isBodyElement(child.openingElement)\n ) {\n return child;\n }\n if (t.isJSXElement(child)) {\n const bodyInChild = findBodyElement(child.children);\n if (bodyInChild) return bodyInChild;\n }\n }\n return null;\n };\n\n const bodyElement = findBodyElement(path.node.children);\n\n if (!bodyElement) {\n warnings.push(\n `File ${file} has a <html> tag without a <body> tag. Skipping GTProvider insertion.`\n );\n return;\n }\n\n // Skip if body already has GTProvider\n if (hasGTProviderChild(bodyElement)) {\n return;\n }\n\n // Handle lang attribute for html tag\n const langAttr = path.node.openingElement.attributes.find(\n (attr) =>\n t.isJSXAttribute(attr) &&\n t.isJSXIdentifier(attr.name) &&\n t.isStringLiteral(attr.value) &&\n attr.name.name === 'lang'\n );\n\n if (langAttr) {\n makeParentFunctionAsync(path);\n addDynamicLangAttribute(path.node.openingElement);\n usedImports.push('getLocale');\n }\n\n // Wrap body children with GTProvider\n const bodyChildren = bodyElement.children;\n const gtProviderElement = t.jsxElement(\n t.jsxOpeningElement(t.jsxIdentifier('GTProvider'), [], false),\n t.jsxClosingElement(t.jsxIdentifier('GTProvider')),\n bodyChildren,\n false\n );\n bodyElement.children = [gtProviderElement];\n usedImports.push('GTProvider');\n modified = true;\n path.skip();\n return;\n }\n // If skip wrapping Ts, skip processing this node\n if (options.skipTs) {\n return;\n }\n // Check if this JSX element has any JSX element ancestors\n if (\n t.isJSXElement(path.parentPath?.node) ||\n t.isJSXExpressionContainer(path.parentPath?.node)\n ) {\n // If we found a JSX parent, skip processing this node\n return;\n }\n\n // At this point, we're only processing top-level JSX elements\n const opts = {\n ...importAlias,\n idPrefix: relativePath,\n idCount: globalId,\n usedImports,\n modified: false,\n createIds: !options.disableIds,\n warnings,\n file,\n };\n const wrapped = handleJsxElement(path.node, opts, isMeaningful);\n path.replaceWith(wrapped.node);\n\n // Update global counters\n modified = modified || opts.modified;\n globalId = opts.idCount;\n },\n });\n if (!modified) continue;\n\n const needsImport = usedImports.filter(\n (imp) => !initialImports.includes(imp)\n );\n\n if (needsImport.length > 0) {\n createImports(ast, needsImport, IMPORT_MAP);\n }\n\n try {\n const output = generate(\n ast,\n {\n retainLines: true,\n retainFunctionParens: true,\n comments: true,\n compact: 'auto',\n },\n code\n );\n\n // Post-process the output to fix import spacing\n let processedCode = output.code;\n if (needsImport.length > 0) {\n // Add newline after the comment only\n processedCode = processedCode.replace(\n /((?:import\\s*{\\s*(?:T|GTT|Var|GTVar|GTProvider|getLocale)(?:\\s*,\\s*(?:T|GTT|Var|GTVar|GTProvider|getLocale))*\\s*}\\s*from|const\\s*{\\s*(?:T|GTT|Var|GTVar|GTProvider|getLocale)(?:\\s*,\\s*(?:T|GTT|Var|GTVar|GTProvider|getLocale))*\\s*}\\s*=\\s*require)\\s*['\"]gt-(?:next|react)(?:\\/server)?['\"];?)/,\n '\\n$1\\n'\n );\n }\n\n // Write the modified code back to the file\n await fs.promises.writeFile(file, processedCode);\n filesUpdated.push(file);\n } catch (error) {\n errors.push(`Error: Failed to write ${file}: ${error}`);\n }\n }\n\n return { filesUpdated };\n}\n"],"mappings":"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"}
@@ -1,34 +1,37 @@
1
- import fs from 'node:fs';
2
- import { extractFromPythonSource } from '@generaltranslation/python-extractor';
3
- import { mapExtractionResultsToUpdates } from '../../extraction/mapToUpdates.js';
4
- import { calculateHashes, dedupeUpdates, linkDeriveUpdates, } from '../../extraction/postProcess.js';
5
- import { matchFiles } from '../../fs/matchFiles.js';
6
- import { DEFAULT_PYTHON_SRC_PATTERNS, DEFAULT_PYTHON_SRC_EXCLUDES, } from '../../config/generateSettings.js';
7
- export async function createPythonInlineUpdates(filePatterns) {
8
- const updates = [];
9
- const errors = [];
10
- const warnings = [];
11
- // Match Python source files, excluding common non-source directories
12
- const patterns = filePatterns || DEFAULT_PYTHON_SRC_PATTERNS;
13
- const files = matchFiles(process.cwd(), [
14
- ...patterns,
15
- ...DEFAULT_PYTHON_SRC_EXCLUDES.map((p) => `!${p}`),
16
- ]);
17
- for (const file of files) {
18
- const code = await fs.promises.readFile(file, 'utf8');
19
- try {
20
- const { results, errors: fileErrors, warnings: fileWarnings, } = await extractFromPythonSource(code, file);
21
- updates.push(...mapExtractionResultsToUpdates(results));
22
- errors.push(...fileErrors);
23
- warnings.push(...fileWarnings);
24
- }
25
- catch (error) {
26
- errors.push(`Error extracting from ${file}: ${String(error)}`);
27
- }
28
- }
29
- // Post processing steps
30
- await calculateHashes(updates);
31
- dedupeUpdates(updates);
32
- linkDeriveUpdates(updates);
33
- return { updates, errors, warnings };
1
+ import { matchFiles } from "../../fs/matchFiles.js";
2
+ import { DEFAULT_PYTHON_SRC_EXCLUDES, DEFAULT_PYTHON_SRC_PATTERNS } from "../../config/generateSettings.js";
3
+ import { calculateHashes, dedupeUpdates, linkDeriveUpdates } from "../../extraction/postProcess.js";
4
+ import { mapExtractionResultsToUpdates } from "../../extraction/mapToUpdates.js";
5
+ import fs from "node:fs";
6
+ import { extractFromPythonSource } from "@generaltranslation/python-extractor";
7
+ //#region src/python/parse/createPythonInlineUpdates.ts
8
+ async function createPythonInlineUpdates(filePatterns) {
9
+ const updates = [];
10
+ const errors = [];
11
+ const warnings = [];
12
+ const patterns = filePatterns || DEFAULT_PYTHON_SRC_PATTERNS;
13
+ const files = matchFiles(process.cwd(), [...patterns, ...DEFAULT_PYTHON_SRC_EXCLUDES.map((p) => `!${p}`)]);
14
+ for (const file of files) {
15
+ const code = await fs.promises.readFile(file, "utf8");
16
+ try {
17
+ const { results, errors: fileErrors, warnings: fileWarnings } = await extractFromPythonSource(code, file);
18
+ updates.push(...mapExtractionResultsToUpdates(results));
19
+ errors.push(...fileErrors);
20
+ warnings.push(...fileWarnings);
21
+ } catch (error) {
22
+ errors.push(`Error extracting from ${file}: ${String(error)}`);
23
+ }
24
+ }
25
+ await calculateHashes(updates);
26
+ dedupeUpdates(updates);
27
+ linkDeriveUpdates(updates);
28
+ return {
29
+ updates,
30
+ errors,
31
+ warnings
32
+ };
34
33
  }
34
+ //#endregion
35
+ export { createPythonInlineUpdates };
36
+
37
+ //# sourceMappingURL=createPythonInlineUpdates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createPythonInlineUpdates.js","names":[],"sources":["../../../src/python/parse/createPythonInlineUpdates.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { Updates } from '../../types/index.js';\nimport { extractFromPythonSource } from '@generaltranslation/python-extractor';\nimport { mapExtractionResultsToUpdates } from '../../extraction/mapToUpdates.js';\nimport {\n calculateHashes,\n dedupeUpdates,\n linkDeriveUpdates,\n} from '../../extraction/postProcess.js';\nimport { matchFiles } from '../../fs/matchFiles.js';\nimport {\n DEFAULT_PYTHON_SRC_PATTERNS,\n DEFAULT_PYTHON_SRC_EXCLUDES,\n} from '../../config/generateSettings.js';\n\nexport async function createPythonInlineUpdates(\n filePatterns: string[] | undefined\n): Promise<{ updates: Updates; errors: string[]; warnings: string[] }> {\n const updates: Updates = [];\n const errors: string[] = [];\n const warnings: string[] = [];\n\n // Match Python source files, excluding common non-source directories\n const patterns = filePatterns || DEFAULT_PYTHON_SRC_PATTERNS;\n const files = matchFiles(process.cwd(), [\n ...patterns,\n ...DEFAULT_PYTHON_SRC_EXCLUDES.map((p) => `!${p}`),\n ]);\n\n for (const file of files) {\n const code = await fs.promises.readFile(file, 'utf8');\n try {\n const {\n results,\n errors: fileErrors,\n warnings: fileWarnings,\n } = await extractFromPythonSource(code, file);\n\n updates.push(...mapExtractionResultsToUpdates(results));\n errors.push(...fileErrors);\n warnings.push(...fileWarnings);\n } catch (error) {\n errors.push(`Error extracting from ${file}: ${String(error)}`);\n }\n }\n\n // Post processing steps\n await calculateHashes(updates);\n dedupeUpdates(updates);\n linkDeriveUpdates(updates);\n\n return { updates, errors, warnings };\n}\n"],"mappings":";;;;;;;AAeA,eAAsB,0BACpB,cACqE;CACrE,MAAM,UAAmB,EAAE;CAC3B,MAAM,SAAmB,EAAE;CAC3B,MAAM,WAAqB,EAAE;CAG7B,MAAM,WAAW,gBAAgB;CACjC,MAAM,QAAQ,WAAW,QAAQ,KAAK,EAAE,CACtC,GAAG,UACH,GAAG,4BAA4B,KAAK,MAAM,IAAI,IAAI,CACnD,CAAC;AAEF,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,OAAO,MAAM,GAAG,SAAS,SAAS,MAAM,OAAO;AACrD,MAAI;GACF,MAAM,EACJ,SACA,QAAQ,YACR,UAAU,iBACR,MAAM,wBAAwB,MAAM,KAAK;AAE7C,WAAQ,KAAK,GAAG,8BAA8B,QAAQ,CAAC;AACvD,UAAO,KAAK,GAAG,WAAW;AAC1B,YAAS,KAAK,GAAG,aAAa;WACvB,OAAO;AACd,UAAO,KAAK,yBAAyB,KAAK,IAAI,OAAO,MAAM,GAAG;;;AAKlE,OAAM,gBAAgB,QAAQ;AAC9B,eAAc,QAAQ;AACtB,mBAAkB,QAAQ;AAE1B,QAAO;EAAE;EAAS;EAAQ;EAAU"}