gt 2.14.35 → 2.14.36

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