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,119 +1,119 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { displayResolvedPaths } from '../../console/logging.js';
4
- export default function createESBuildConfig(config = {}) {
5
- const esbuildOptions = {
6
- bundle: true,
7
- format: 'cjs',
8
- platform: 'node',
9
- target: 'es2021',
10
- loader: {
11
- '.js': 'jsx',
12
- '.ts': 'ts',
13
- '.css': 'css', // Add CSS loader
14
- },
15
- sourcemap: 'inline',
16
- external: ['server-only'],
17
- define: {
18
- React: 'global.React',
19
- },
20
- plugins: [],
21
- };
22
- // Add the custom plugin to handle 'server-only' imports
23
- esbuildOptions.plugins?.push({
24
- name: 'ignore-server-only',
25
- setup(build) {
26
- build.onResolve({ filter: /^server-only$/ }, () => {
27
- return {
28
- path: 'server-only',
29
- namespace: 'ignore-server-only',
30
- };
31
- });
32
- build.onLoad({ filter: /^server-only$/, namespace: 'ignore-server-only' }, () => {
33
- return {
34
- contents: 'module.exports = {};',
35
- loader: 'js',
36
- };
37
- });
38
- },
39
- });
40
- // Add a plugin to handle CSS imports
41
- esbuildOptions.plugins?.push({
42
- name: 'css-module',
43
- setup(build) {
44
- build.onResolve({ filter: /\.css$/ }, (args) => {
45
- return {
46
- path: path.resolve(args.resolveDir, args.path),
47
- namespace: 'css-module',
48
- };
49
- });
50
- build.onLoad({ filter: /\.css$/, namespace: 'css-module' }, async (args) => {
51
- const css = await fs.promises.readFile(args.path, 'utf8');
52
- const contents = `
1
+ import { displayResolvedPaths } from "../../console/logging.js";
2
+ import path from "node:path";
3
+ import fs from "node:fs";
4
+ //#region src/react/config/createESBuildConfig.ts
5
+ function createESBuildConfig(config = {}) {
6
+ const esbuildOptions = {
7
+ bundle: true,
8
+ format: "cjs",
9
+ platform: "node",
10
+ target: "es2021",
11
+ loader: {
12
+ ".js": "jsx",
13
+ ".ts": "ts",
14
+ ".css": "css"
15
+ },
16
+ sourcemap: "inline",
17
+ external: ["server-only"],
18
+ define: { React: "global.React" },
19
+ plugins: []
20
+ };
21
+ esbuildOptions.plugins?.push({
22
+ name: "ignore-server-only",
23
+ setup(build) {
24
+ build.onResolve({ filter: /^server-only$/ }, () => {
25
+ return {
26
+ path: "server-only",
27
+ namespace: "ignore-server-only"
28
+ };
29
+ });
30
+ build.onLoad({
31
+ filter: /^server-only$/,
32
+ namespace: "ignore-server-only"
33
+ }, () => {
34
+ return {
35
+ contents: "module.exports = {};",
36
+ loader: "js"
37
+ };
38
+ });
39
+ }
40
+ });
41
+ esbuildOptions.plugins?.push({
42
+ name: "css-module",
43
+ setup(build) {
44
+ build.onResolve({ filter: /\.css$/ }, (args) => {
45
+ return {
46
+ path: path.resolve(args.resolveDir, args.path),
47
+ namespace: "css-module"
48
+ };
49
+ });
50
+ build.onLoad({
51
+ filter: /\.css$/,
52
+ namespace: "css-module"
53
+ }, async (args) => {
54
+ const css = await fs.promises.readFile(args.path, "utf8");
55
+ return {
56
+ contents: `
53
57
  const style = document.createElement('style');
54
58
  style.textContent = ${JSON.stringify(css)};
55
59
  document.head.appendChild(style);
56
- `;
57
- return { contents, loader: 'js' };
58
- });
59
- },
60
- });
61
- if (config.compilerOptions) {
62
- if (config.compilerOptions.paths) {
63
- const aliases = {};
64
- const resolvedPaths = [];
65
- for (const [key, value] of Object.entries(config.compilerOptions.paths)) {
66
- if (Array.isArray(value) && typeof value[0] === 'string') {
67
- const resolvedPath = path.resolve(process.cwd(), value[0].replace('/*', ''));
68
- aliases[key.replace('/*', '')] = resolvedPath;
69
- resolvedPaths.push([key, resolvedPath]);
70
- }
71
- }
72
- if (resolvedPaths.length) {
73
- displayResolvedPaths(resolvedPaths);
74
- }
75
- esbuildOptions.plugins = esbuildOptions.plugins || [];
76
- esbuildOptions.plugins.push({
77
- name: 'alias',
78
- setup(build) {
79
- build.onResolve({ filter: /.*/ }, (args) => {
80
- for (const [aliasKey, aliasPath] of Object.entries(aliases)) {
81
- if (args.path.startsWith(`${aliasKey}/`)) {
82
- const resolvedPath = path.resolve(aliasPath, args.path.slice(aliasKey.length + 1));
83
- const extensions = ['.js', '.ts', '.css']; // Add .css to extensions
84
- function resolveWithExtensions(basePath) {
85
- for (const ext of extensions) {
86
- const fullPath = `${basePath}${ext}`;
87
- try {
88
- const realPath = fs.realpathSync(fullPath);
89
- return realPath;
90
- }
91
- catch {
92
- continue;
93
- }
94
- }
95
- return null;
96
- }
97
- try {
98
- const realPath = fs.realpathSync(resolvedPath);
99
- return { path: realPath };
100
- }
101
- catch {
102
- const hasExtension = extensions.some((ext) => resolvedPath.endsWith(ext));
103
- if (!hasExtension) {
104
- const resolvedWithExt = resolveWithExtensions(resolvedPath);
105
- if (resolvedWithExt) {
106
- return { path: resolvedWithExt };
107
- }
108
- }
109
- throw new Error(`Unable to resolve path: ${resolvedPath}`);
110
- }
111
- }
112
- }
113
- });
114
- },
115
- });
116
- }
117
- }
118
- return esbuildOptions;
60
+ `,
61
+ loader: "js"
62
+ };
63
+ });
64
+ }
65
+ });
66
+ if (config.compilerOptions) {
67
+ if (config.compilerOptions.paths) {
68
+ const aliases = {};
69
+ const resolvedPaths = [];
70
+ for (const [key, value] of Object.entries(config.compilerOptions.paths)) if (Array.isArray(value) && typeof value[0] === "string") {
71
+ const resolvedPath = path.resolve(process.cwd(), value[0].replace("/*", ""));
72
+ aliases[key.replace("/*", "")] = resolvedPath;
73
+ resolvedPaths.push([key, resolvedPath]);
74
+ }
75
+ if (resolvedPaths.length) displayResolvedPaths(resolvedPaths);
76
+ esbuildOptions.plugins = esbuildOptions.plugins || [];
77
+ esbuildOptions.plugins.push({
78
+ name: "alias",
79
+ setup(build) {
80
+ build.onResolve({ filter: /.*/ }, (args) => {
81
+ for (const [aliasKey, aliasPath] of Object.entries(aliases)) if (args.path.startsWith(`${aliasKey}/`)) {
82
+ const resolvedPath = path.resolve(aliasPath, args.path.slice(aliasKey.length + 1));
83
+ const extensions = [
84
+ ".js",
85
+ ".ts",
86
+ ".css"
87
+ ];
88
+ function resolveWithExtensions(basePath) {
89
+ for (const ext of extensions) {
90
+ const fullPath = `${basePath}${ext}`;
91
+ try {
92
+ return fs.realpathSync(fullPath);
93
+ } catch {
94
+ continue;
95
+ }
96
+ }
97
+ return null;
98
+ }
99
+ try {
100
+ return { path: fs.realpathSync(resolvedPath) };
101
+ } catch {
102
+ if (!extensions.some((ext) => resolvedPath.endsWith(ext))) {
103
+ const resolvedWithExt = resolveWithExtensions(resolvedPath);
104
+ if (resolvedWithExt) return { path: resolvedWithExt };
105
+ }
106
+ throw new Error(`Unable to resolve path: ${resolvedPath}`);
107
+ }
108
+ }
109
+ });
110
+ }
111
+ });
112
+ }
113
+ }
114
+ return esbuildOptions;
119
115
  }
116
+ //#endregion
117
+ export { createESBuildConfig as default };
118
+
119
+ //# sourceMappingURL=createESBuildConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createESBuildConfig.js","names":[],"sources":["../../../src/react/config/createESBuildConfig.ts"],"sourcesContent":["import esbuild from 'esbuild';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { displayResolvedPaths } from '../../console/logging.js';\n\ntype TSConfig = {\n compilerOptions?: {\n paths?: Record<string, string[]>;\n };\n};\n\nexport default function createESBuildConfig(config: TSConfig = {}) {\n const esbuildOptions: esbuild.BuildOptions = {\n bundle: true,\n format: 'cjs',\n platform: 'node',\n target: 'es2021',\n loader: {\n '.js': 'jsx',\n '.ts': 'ts',\n '.css': 'css', // Add CSS loader\n },\n sourcemap: 'inline',\n external: ['server-only'],\n define: {\n React: 'global.React',\n },\n plugins: [],\n };\n\n // Add the custom plugin to handle 'server-only' imports\n esbuildOptions.plugins?.push({\n name: 'ignore-server-only',\n setup(build: esbuild.PluginBuild) {\n build.onResolve({ filter: /^server-only$/ }, () => {\n return {\n path: 'server-only',\n namespace: 'ignore-server-only',\n };\n });\n\n build.onLoad(\n { filter: /^server-only$/, namespace: 'ignore-server-only' },\n () => {\n return {\n contents: 'module.exports = {};',\n loader: 'js',\n };\n }\n );\n },\n });\n\n // Add a plugin to handle CSS imports\n esbuildOptions.plugins?.push({\n name: 'css-module',\n setup(build: esbuild.PluginBuild) {\n build.onResolve({ filter: /\\.css$/ }, (args: esbuild.OnResolveArgs) => {\n return {\n path: path.resolve(args.resolveDir, args.path),\n namespace: 'css-module',\n };\n });\n\n build.onLoad(\n { filter: /\\.css$/, namespace: 'css-module' },\n async (args: esbuild.OnLoadArgs) => {\n const css = await fs.promises.readFile(args.path, 'utf8');\n const contents = `\n const style = document.createElement('style');\n style.textContent = ${JSON.stringify(css)};\n document.head.appendChild(style);\n `;\n return { contents, loader: 'js' };\n }\n );\n },\n });\n\n if (config.compilerOptions) {\n if (config.compilerOptions.paths) {\n const aliases: Record<string, string> = {};\n\n const resolvedPaths: [string, string][] = [];\n for (const [key, value] of Object.entries(config.compilerOptions.paths)) {\n if (Array.isArray(value) && typeof value[0] === 'string') {\n const resolvedPath = path.resolve(\n process.cwd(),\n value[0].replace('/*', '')\n );\n aliases[key.replace('/*', '')] = resolvedPath;\n resolvedPaths.push([key, resolvedPath]);\n }\n }\n if (resolvedPaths.length) {\n displayResolvedPaths(resolvedPaths);\n }\n\n esbuildOptions.plugins = esbuildOptions.plugins || [];\n\n esbuildOptions.plugins.push({\n name: 'alias',\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n for (const [aliasKey, aliasPath] of Object.entries(aliases)) {\n if (args.path.startsWith(`${aliasKey}/`)) {\n const resolvedPath = path.resolve(\n aliasPath as string,\n args.path.slice(aliasKey.length + 1)\n );\n\n const extensions = ['.js', '.ts', '.css']; // Add .css to extensions\n\n function resolveWithExtensions(\n basePath: string\n ): string | null {\n for (const ext of extensions) {\n const fullPath = `${basePath}${ext}`;\n try {\n const realPath = fs.realpathSync(fullPath);\n return realPath;\n } catch {\n continue;\n }\n }\n return null;\n }\n\n try {\n const realPath = fs.realpathSync(resolvedPath);\n return { path: realPath };\n } catch {\n const hasExtension = extensions.some((ext) =>\n resolvedPath.endsWith(ext)\n );\n if (!hasExtension) {\n const resolvedWithExt = resolveWithExtensions(resolvedPath);\n if (resolvedWithExt) {\n return { path: resolvedWithExt };\n }\n }\n\n throw new Error(`Unable to resolve path: ${resolvedPath}`);\n }\n }\n }\n });\n },\n });\n }\n }\n\n return esbuildOptions;\n}\n"],"mappings":";;;;AAWA,SAAwB,oBAAoB,SAAmB,EAAE,EAAE;CACjE,MAAM,iBAAuC;EAC3C,QAAQ;EACR,QAAQ;EACR,UAAU;EACV,QAAQ;EACR,QAAQ;GACN,OAAO;GACP,OAAO;GACP,QAAQ;GACT;EACD,WAAW;EACX,UAAU,CAAC,cAAc;EACzB,QAAQ,EACN,OAAO,gBACR;EACD,SAAS,EAAE;EACZ;AAGD,gBAAe,SAAS,KAAK;EAC3B,MAAM;EACN,MAAM,OAA4B;AAChC,SAAM,UAAU,EAAE,QAAQ,iBAAiB,QAAQ;AACjD,WAAO;KACL,MAAM;KACN,WAAW;KACZ;KACD;AAEF,SAAM,OACJ;IAAE,QAAQ;IAAiB,WAAW;IAAsB,QACtD;AACJ,WAAO;KACL,UAAU;KACV,QAAQ;KACT;KAEJ;;EAEJ,CAAC;AAGF,gBAAe,SAAS,KAAK;EAC3B,MAAM;EACN,MAAM,OAA4B;AAChC,SAAM,UAAU,EAAE,QAAQ,UAAU,GAAG,SAAgC;AACrE,WAAO;KACL,MAAM,KAAK,QAAQ,KAAK,YAAY,KAAK,KAAK;KAC9C,WAAW;KACZ;KACD;AAEF,SAAM,OACJ;IAAE,QAAQ;IAAU,WAAW;IAAc,EAC7C,OAAO,SAA6B;IAClC,MAAM,MAAM,MAAM,GAAG,SAAS,SAAS,KAAK,MAAM,OAAO;AAMzD,WAAO;KAAE,UAAA;;0CAHuB,KAAK,UAAU,IAAI,CAAC;;;KAGjC,QAAQ;KAAM;KAEpC;;EAEJ,CAAC;AAEF,KAAI,OAAO;MACL,OAAO,gBAAgB,OAAO;GAChC,MAAM,UAAkC,EAAE;GAE1C,MAAM,gBAAoC,EAAE;AAC5C,QAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,gBAAgB,MAAM,CACrE,KAAI,MAAM,QAAQ,MAAM,IAAI,OAAO,MAAM,OAAO,UAAU;IACxD,MAAM,eAAe,KAAK,QACxB,QAAQ,KAAK,EACb,MAAM,GAAG,QAAQ,MAAM,GAAG,CAC3B;AACD,YAAQ,IAAI,QAAQ,MAAM,GAAG,IAAI;AACjC,kBAAc,KAAK,CAAC,KAAK,aAAa,CAAC;;AAG3C,OAAI,cAAc,OAChB,sBAAqB,cAAc;AAGrC,kBAAe,UAAU,eAAe,WAAW,EAAE;AAErD,kBAAe,QAAQ,KAAK;IAC1B,MAAM;IACN,MAAM,OAAO;AACX,WAAM,UAAU,EAAE,QAAQ,MAAM,GAAG,SAAS;AAC1C,WAAK,MAAM,CAAC,UAAU,cAAc,OAAO,QAAQ,QAAQ,CACzD,KAAI,KAAK,KAAK,WAAW,GAAG,SAAS,GAAG,EAAE;OACxC,MAAM,eAAe,KAAK,QACxB,WACA,KAAK,KAAK,MAAM,SAAS,SAAS,EAAE,CACrC;OAED,MAAM,aAAa;QAAC;QAAO;QAAO;QAAO;OAEzC,SAAS,sBACP,UACe;AACf,aAAK,MAAM,OAAO,YAAY;SAC5B,MAAM,WAAW,GAAG,WAAW;AAC/B,aAAI;AAEF,iBADiB,GAAG,aAAa,SAClB;iBACT;AACN;;;AAGJ,eAAO;;AAGT,WAAI;AAEF,eAAO,EAAE,MADQ,GAAG,aAAa,aACV,EAAE;eACnB;AAIN,YAAI,CAHiB,WAAW,MAAM,QACpC,aAAa,SAAS,IAAI,CAEX,EAAE;SACjB,MAAM,kBAAkB,sBAAsB,aAAa;AAC3D,aAAI,gBACF,QAAO,EAAE,MAAM,iBAAiB;;AAIpC,cAAM,IAAI,MAAM,2BAA2B,eAAe;;;OAIhE;;IAEL,CAAC;;;AAIN,QAAO"}
@@ -1,133 +1,99 @@
1
- import * as t from '@babel/types';
2
- import { parse } from '@formatjs/icu-messageformat-parser';
1
+ import * as t from "@babel/types";
2
+ import { parse } from "@formatjs/icu-messageformat-parser";
3
+ //#region src/react/jsx/evaluateJsx.ts
3
4
  const MEANINGFUL_REGEX = /[\p{L}\p{N}]/u;
4
5
  /**
5
- * Checks if a node is meaningful. Does not recurse into children.
6
- * @param node - The node to check
7
- * @returns Whether the node is meaningful
8
- */
9
- export function isMeaningful(node) {
10
- if (t.isStringLiteral(node) || t.isJSXText(node)) {
11
- return MEANINGFUL_REGEX.test(node.value);
12
- }
13
- // Handle template literals without expressions
14
- if (t.isTemplateLiteral(node) && node.expressions.length === 0) {
15
- return MEANINGFUL_REGEX.test(node.quasis[0].value.raw);
16
- }
17
- if (t.isJSXExpressionContainer(node)) {
18
- const value = isStaticExpression(node.expression);
19
- if (value.isStatic && value.value) {
20
- return MEANINGFUL_REGEX.test(value.value);
21
- }
22
- }
23
- if (t.isBinaryExpression(node)) {
24
- if (node.operator === '+') {
25
- return isMeaningful(node.left) || isMeaningful(node.right);
26
- }
27
- }
28
- return false;
6
+ * Checks if a node is meaningful. Does not recurse into children.
7
+ * @param node - The node to check
8
+ * @returns Whether the node is meaningful
9
+ */
10
+ function isMeaningful(node) {
11
+ if (t.isStringLiteral(node) || t.isJSXText(node)) return MEANINGFUL_REGEX.test(node.value);
12
+ if (t.isTemplateLiteral(node) && node.expressions.length === 0) return MEANINGFUL_REGEX.test(node.quasis[0].value.raw);
13
+ if (t.isJSXExpressionContainer(node)) {
14
+ const value = isStaticExpression(node.expression);
15
+ if (value.isStatic && value.value) return MEANINGFUL_REGEX.test(value.value);
16
+ }
17
+ if (t.isBinaryExpression(node)) {
18
+ if (node.operator === "+") return isMeaningful(node.left) || isMeaningful(node.right);
19
+ }
20
+ return false;
29
21
  }
30
22
  /**
31
- * Checks if an expression is a static expression (does not contain any variables which could change at runtime).
32
- * @param expr - The expression to check
33
- * @param jsxStatic - Whether to return JSX-compatible values (boolean, null) in addition to strings
34
- * @returns An object containing the result of the static check
35
- */
36
- export function isStaticExpression(expr, jsxStatic = false) {
37
- // Handle empty expressions
38
- if (t.isJSXEmptyExpression(expr)) {
39
- return { isStatic: true, value: '' };
40
- }
41
- // Handle direct string literals
42
- if (t.isStringLiteral(expr)) {
43
- return { isStatic: true, value: expr.value };
44
- }
45
- // Handle template literals without expressions
46
- if (t.isTemplateLiteral(expr) && expr.expressions.length === 0) {
47
- return {
48
- isStatic: true,
49
- value: jsxStatic ? expr.quasis[0].value.cooked : expr.quasis[0].value.raw,
50
- };
51
- }
52
- // Binary expressions are not derivable
53
- if (t.isBinaryExpression(expr)) {
54
- // Not a derivable expression
55
- return { isStatic: false };
56
- }
57
- // Handle parenthesized expressions
58
- if (t.isParenthesizedExpression(expr)) {
59
- return isStaticExpression(expr.expression, jsxStatic);
60
- }
61
- // Handle numeric literals by converting them to strings
62
- if (t.isNumericLiteral(expr)) {
63
- return { isStatic: true, value: String(expr.value) };
64
- }
65
- // Handle unary expressions by converting them to strings
66
- if (t.isUnaryExpression(expr)) {
67
- let value;
68
- let operator = '';
69
- if (expr.operator === '-') {
70
- operator = expr.operator;
71
- }
72
- if (t.isNumericLiteral(expr.argument)) {
73
- if (expr.argument.value === 0) {
74
- value = '0';
75
- }
76
- else {
77
- value = operator + expr.argument.value.toString();
78
- }
79
- }
80
- else {
81
- // invalid
82
- return { isStatic: false };
83
- }
84
- return { isStatic: true, value };
85
- }
86
- // Handle boolean literals by converting them to strings
87
- if (t.isBooleanLiteral(expr)) {
88
- return {
89
- isStatic: true,
90
- value: jsxStatic ? expr.value : String(expr.value),
91
- };
92
- }
93
- // Handle null literal
94
- if (t.isNullLiteral(expr)) {
95
- return { isStatic: true, value: jsxStatic ? null : 'null' };
96
- }
97
- // Not a derivable expression
98
- return { isStatic: false };
23
+ * Checks if an expression is a static expression (does not contain any variables which could change at runtime).
24
+ * @param expr - The expression to check
25
+ * @param jsxStatic - Whether to return JSX-compatible values (boolean, null) in addition to strings
26
+ * @returns An object containing the result of the static check
27
+ */
28
+ function isStaticExpression(expr, jsxStatic = false) {
29
+ if (t.isJSXEmptyExpression(expr)) return {
30
+ isStatic: true,
31
+ value: ""
32
+ };
33
+ if (t.isStringLiteral(expr)) return {
34
+ isStatic: true,
35
+ value: expr.value
36
+ };
37
+ if (t.isTemplateLiteral(expr) && expr.expressions.length === 0) return {
38
+ isStatic: true,
39
+ value: jsxStatic ? expr.quasis[0].value.cooked : expr.quasis[0].value.raw
40
+ };
41
+ if (t.isBinaryExpression(expr)) return { isStatic: false };
42
+ if (t.isParenthesizedExpression(expr)) return isStaticExpression(expr.expression, jsxStatic);
43
+ if (t.isNumericLiteral(expr)) return {
44
+ isStatic: true,
45
+ value: String(expr.value)
46
+ };
47
+ if (t.isUnaryExpression(expr)) {
48
+ let value;
49
+ let operator = "";
50
+ if (expr.operator === "-") operator = expr.operator;
51
+ if (t.isNumericLiteral(expr.argument)) if (expr.argument.value === 0) value = "0";
52
+ else value = operator + expr.argument.value.toString();
53
+ else return { isStatic: false };
54
+ return {
55
+ isStatic: true,
56
+ value
57
+ };
58
+ }
59
+ if (t.isBooleanLiteral(expr)) return {
60
+ isStatic: true,
61
+ value: jsxStatic ? expr.value : String(expr.value)
62
+ };
63
+ if (t.isNullLiteral(expr)) return {
64
+ isStatic: true,
65
+ value: jsxStatic ? null : "null"
66
+ };
67
+ return { isStatic: false };
99
68
  }
100
69
  /**
101
- * Checks if an expression is a static value (a string, number, or template literal).
102
- * @param expr - The expression to check
103
- * @returns Whether the expression is a static value
104
- */
105
- export function isStaticValue(expr) {
106
- if (t.isStringLiteral(expr)) {
107
- return true;
108
- }
109
- if (t.isNumericLiteral(expr)) {
110
- return true;
111
- }
112
- if (t.isTemplateLiteral(expr)) {
113
- return true;
114
- }
115
- return false;
70
+ * Checks if an expression is a static value (a string, number, or template literal).
71
+ * @param expr - The expression to check
72
+ * @returns Whether the expression is a static value
73
+ */
74
+ function isStaticValue(expr) {
75
+ if (t.isStringLiteral(expr)) return true;
76
+ if (t.isNumericLiteral(expr)) return true;
77
+ if (t.isTemplateLiteral(expr)) return true;
78
+ return false;
116
79
  }
117
80
  /**
118
- * Checks if a string is a valid ICU message format.
119
- * @param string - The string to check
120
- * @returns Whether the string is a valid ICU message format
121
- */
122
- export function isValidIcu(string) {
123
- try {
124
- parse(string);
125
- }
126
- catch (error) {
127
- return {
128
- isValid: false,
129
- error: error instanceof Error ? error.message : String(error),
130
- };
131
- }
132
- return { isValid: true };
81
+ * Checks if a string is a valid ICU message format.
82
+ * @param string - The string to check
83
+ * @returns Whether the string is a valid ICU message format
84
+ */
85
+ function isValidIcu(string) {
86
+ try {
87
+ parse(string);
88
+ } catch (error) {
89
+ return {
90
+ isValid: false,
91
+ error: error instanceof Error ? error.message : String(error)
92
+ };
93
+ }
94
+ return { isValid: true };
133
95
  }
96
+ //#endregion
97
+ export { isMeaningful, isStaticExpression, isStaticValue, isValidIcu };
98
+
99
+ //# sourceMappingURL=evaluateJsx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluateJsx.js","names":[],"sources":["../../../src/react/jsx/evaluateJsx.ts"],"sourcesContent":["import * as t from '@babel/types';\nimport { parse } from '@formatjs/icu-messageformat-parser';\n\nconst MEANINGFUL_REGEX = /[\\p{L}\\p{N}]/u;\n\n/**\n * Checks if a node is meaningful. Does not recurse into children.\n * @param node - The node to check\n * @returns Whether the node is meaningful\n */\nexport function isMeaningful(node: t.Node): boolean {\n if (t.isStringLiteral(node) || t.isJSXText(node)) {\n return MEANINGFUL_REGEX.test(node.value);\n }\n // Handle template literals without expressions\n if (t.isTemplateLiteral(node) && node.expressions.length === 0) {\n return MEANINGFUL_REGEX.test(node.quasis[0].value.raw);\n }\n if (t.isJSXExpressionContainer(node)) {\n const value = isStaticExpression(node.expression);\n if (value.isStatic && value.value) {\n return MEANINGFUL_REGEX.test(value.value);\n }\n }\n if (t.isBinaryExpression(node)) {\n if (node.operator === '+') {\n return isMeaningful(node.left) || isMeaningful(node.right);\n }\n }\n return false;\n}\n\nexport function isStaticExpression(\n expr: t.Expression | t.JSXEmptyExpression,\n jsxStatic?: false\n): {\n isStatic: boolean;\n value?: string;\n};\nexport function isStaticExpression(\n expr: t.Expression | t.JSXEmptyExpression,\n jsxStatic?: true\n): {\n isStatic: boolean;\n value?: string | boolean | null;\n};\nexport function isStaticExpression(\n expr: t.Expression | t.JSXEmptyExpression,\n jsxStatic?: boolean\n): {\n isStatic: boolean;\n value?: string | boolean | null;\n};\n/**\n * Checks if an expression is a static expression (does not contain any variables which could change at runtime).\n * @param expr - The expression to check\n * @param jsxStatic - Whether to return JSX-compatible values (boolean, null) in addition to strings\n * @returns An object containing the result of the static check\n */\nexport function isStaticExpression(\n expr: t.Expression | t.JSXEmptyExpression,\n jsxStatic = false\n): {\n isStatic: boolean;\n value?: string | boolean | null;\n} {\n // Handle empty expressions\n if (t.isJSXEmptyExpression(expr)) {\n return { isStatic: true, value: '' };\n }\n\n // Handle direct string literals\n if (t.isStringLiteral(expr)) {\n return { isStatic: true, value: expr.value };\n }\n\n // Handle template literals without expressions\n if (t.isTemplateLiteral(expr) && expr.expressions.length === 0) {\n return {\n isStatic: true,\n value: jsxStatic ? expr.quasis[0].value.cooked : expr.quasis[0].value.raw,\n };\n }\n\n // Binary expressions are not derivable\n if (t.isBinaryExpression(expr)) {\n // Not a derivable expression\n return { isStatic: false };\n }\n\n // Handle parenthesized expressions\n if (t.isParenthesizedExpression(expr)) {\n return isStaticExpression(expr.expression, jsxStatic);\n }\n\n // Handle numeric literals by converting them to strings\n if (t.isNumericLiteral(expr)) {\n return { isStatic: true, value: String(expr.value) };\n }\n\n // Handle unary expressions by converting them to strings\n if (t.isUnaryExpression(expr)) {\n let value: string;\n let operator = '';\n if (expr.operator === '-') {\n operator = expr.operator;\n }\n if (t.isNumericLiteral(expr.argument)) {\n if (expr.argument.value === 0) {\n value = '0';\n } else {\n value = operator + expr.argument.value.toString();\n }\n } else {\n // invalid\n return { isStatic: false };\n }\n\n return { isStatic: true, value };\n }\n\n // Handle boolean literals by converting them to strings\n if (t.isBooleanLiteral(expr)) {\n return {\n isStatic: true,\n value: jsxStatic ? expr.value : String(expr.value),\n };\n }\n\n // Handle null literal\n if (t.isNullLiteral(expr)) {\n return { isStatic: true, value: jsxStatic ? null : 'null' };\n }\n\n // Not a derivable expression\n return { isStatic: false };\n}\n\n/**\n * Checks if an expression is a static value (a string, number, or template literal).\n * @param expr - The expression to check\n * @returns Whether the expression is a static value\n */\nexport function isStaticValue(\n expr: t.Expression | t.JSXEmptyExpression\n): boolean {\n if (t.isStringLiteral(expr)) {\n return true;\n }\n if (t.isNumericLiteral(expr)) {\n return true;\n }\n if (t.isTemplateLiteral(expr)) {\n return true;\n }\n return false;\n}\n\n/**\n * Checks if a string is a valid ICU message format.\n * @param string - The string to check\n * @returns Whether the string is a valid ICU message format\n */\nexport function isValidIcu(string: string): {\n isValid: boolean;\n error?: string;\n} {\n try {\n parse(string);\n } catch (error) {\n return {\n isValid: false,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n return { isValid: true };\n}\n"],"mappings":";;;AAGA,MAAM,mBAAmB;;;;;;AAOzB,SAAgB,aAAa,MAAuB;AAClD,KAAI,EAAE,gBAAgB,KAAK,IAAI,EAAE,UAAU,KAAK,CAC9C,QAAO,iBAAiB,KAAK,KAAK,MAAM;AAG1C,KAAI,EAAE,kBAAkB,KAAK,IAAI,KAAK,YAAY,WAAW,EAC3D,QAAO,iBAAiB,KAAK,KAAK,OAAO,GAAG,MAAM,IAAI;AAExD,KAAI,EAAE,yBAAyB,KAAK,EAAE;EACpC,MAAM,QAAQ,mBAAmB,KAAK,WAAW;AACjD,MAAI,MAAM,YAAY,MAAM,MAC1B,QAAO,iBAAiB,KAAK,MAAM,MAAM;;AAG7C,KAAI,EAAE,mBAAmB,KAAK;MACxB,KAAK,aAAa,IACpB,QAAO,aAAa,KAAK,KAAK,IAAI,aAAa,KAAK,MAAM;;AAG9D,QAAO;;;;;;;;AA8BT,SAAgB,mBACd,MACA,YAAY,OAIZ;AAEA,KAAI,EAAE,qBAAqB,KAAK,CAC9B,QAAO;EAAE,UAAU;EAAM,OAAO;EAAI;AAItC,KAAI,EAAE,gBAAgB,KAAK,CACzB,QAAO;EAAE,UAAU;EAAM,OAAO,KAAK;EAAO;AAI9C,KAAI,EAAE,kBAAkB,KAAK,IAAI,KAAK,YAAY,WAAW,EAC3D,QAAO;EACL,UAAU;EACV,OAAO,YAAY,KAAK,OAAO,GAAG,MAAM,SAAS,KAAK,OAAO,GAAG,MAAM;EACvE;AAIH,KAAI,EAAE,mBAAmB,KAAK,CAE5B,QAAO,EAAE,UAAU,OAAO;AAI5B,KAAI,EAAE,0BAA0B,KAAK,CACnC,QAAO,mBAAmB,KAAK,YAAY,UAAU;AAIvD,KAAI,EAAE,iBAAiB,KAAK,CAC1B,QAAO;EAAE,UAAU;EAAM,OAAO,OAAO,KAAK,MAAM;EAAE;AAItD,KAAI,EAAE,kBAAkB,KAAK,EAAE;EAC7B,IAAI;EACJ,IAAI,WAAW;AACf,MAAI,KAAK,aAAa,IACpB,YAAW,KAAK;AAElB,MAAI,EAAE,iBAAiB,KAAK,SAAS,CACnC,KAAI,KAAK,SAAS,UAAU,EAC1B,SAAQ;MAER,SAAQ,WAAW,KAAK,SAAS,MAAM,UAAU;MAInD,QAAO,EAAE,UAAU,OAAO;AAG5B,SAAO;GAAE,UAAU;GAAM;GAAO;;AAIlC,KAAI,EAAE,iBAAiB,KAAK,CAC1B,QAAO;EACL,UAAU;EACV,OAAO,YAAY,KAAK,QAAQ,OAAO,KAAK,MAAM;EACnD;AAIH,KAAI,EAAE,cAAc,KAAK,CACvB,QAAO;EAAE,UAAU;EAAM,OAAO,YAAY,OAAO;EAAQ;AAI7D,QAAO,EAAE,UAAU,OAAO;;;;;;;AAQ5B,SAAgB,cACd,MACS;AACT,KAAI,EAAE,gBAAgB,KAAK,CACzB,QAAO;AAET,KAAI,EAAE,iBAAiB,KAAK,CAC1B,QAAO;AAET,KAAI,EAAE,kBAAkB,KAAK,CAC3B,QAAO;AAET,QAAO;;;;;;;AAQT,SAAgB,WAAW,QAGzB;AACA,KAAI;AACF,QAAM,OAAO;UACN,OAAO;AACd,SAAO;GACL,SAAS;GACT,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;GAC9D;;AAEH,QAAO,EAAE,SAAS,MAAM"}
@@ -1,30 +1,26 @@
1
- import * as t from '@babel/types';
1
+ import * as t from "@babel/types";
2
+ //#region src/react/jsx/utils/buildImportMap.ts
2
3
  /**
3
- * Builds a map of imported function names to their import paths from a given program path.
4
- * Handles both named imports and default imports.
5
- *
6
- * Example: import { getInfo } from './constants' -> Map { 'getInfo' => './constants' }
7
- * Example: import utils from './utils' -> Map { 'utils' => './utils' }
8
- */
9
- export function buildImportMap(programPath) {
10
- const importMap = new Map();
11
- programPath.traverse({
12
- ImportDeclaration(importPath) {
13
- if (t.isStringLiteral(importPath.node.source)) {
14
- const importSource = importPath.node.source.value;
15
- importPath.node.specifiers.forEach((spec) => {
16
- if (t.isImportSpecifier(spec) &&
17
- t.isIdentifier(spec.imported) &&
18
- t.isIdentifier(spec.local)) {
19
- importMap.set(spec.local.name, importSource);
20
- }
21
- else if (t.isImportDefaultSpecifier(spec) &&
22
- t.isIdentifier(spec.local)) {
23
- importMap.set(spec.local.name, importSource);
24
- }
25
- });
26
- }
27
- },
28
- });
29
- return importMap;
4
+ * Builds a map of imported function names to their import paths from a given program path.
5
+ * Handles both named imports and default imports.
6
+ *
7
+ * Example: import { getInfo } from './constants' -> Map { 'getInfo' => './constants' }
8
+ * Example: import utils from './utils' -> Map { 'utils' => './utils' }
9
+ */
10
+ function buildImportMap(programPath) {
11
+ const importMap = /* @__PURE__ */ new Map();
12
+ programPath.traverse({ ImportDeclaration(importPath) {
13
+ if (t.isStringLiteral(importPath.node.source)) {
14
+ const importSource = importPath.node.source.value;
15
+ importPath.node.specifiers.forEach((spec) => {
16
+ if (t.isImportSpecifier(spec) && t.isIdentifier(spec.imported) && t.isIdentifier(spec.local)) importMap.set(spec.local.name, importSource);
17
+ else if (t.isImportDefaultSpecifier(spec) && t.isIdentifier(spec.local)) importMap.set(spec.local.name, importSource);
18
+ });
19
+ }
20
+ } });
21
+ return importMap;
30
22
  }
23
+ //#endregion
24
+ export { buildImportMap };
25
+
26
+ //# sourceMappingURL=buildImportMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildImportMap.js","names":[],"sources":["../../../../src/react/jsx/utils/buildImportMap.ts"],"sourcesContent":["import { NodePath } from '@babel/traverse';\nimport * as t from '@babel/types';\n\n/**\n * Builds a map of imported function names to their import paths from a given program path.\n * Handles both named imports and default imports.\n *\n * Example: import { getInfo } from './constants' -> Map { 'getInfo' => './constants' }\n * Example: import utils from './utils' -> Map { 'utils' => './utils' }\n */\nexport function buildImportMap(programPath: NodePath): Map<string, string> {\n const importMap = new Map<string, string>();\n\n programPath.traverse({\n ImportDeclaration(importPath) {\n if (t.isStringLiteral(importPath.node.source)) {\n const importSource = importPath.node.source.value;\n importPath.node.specifiers.forEach((spec) => {\n if (\n t.isImportSpecifier(spec) &&\n t.isIdentifier(spec.imported) &&\n t.isIdentifier(spec.local)\n ) {\n importMap.set(spec.local.name, importSource);\n } else if (\n t.isImportDefaultSpecifier(spec) &&\n t.isIdentifier(spec.local)\n ) {\n importMap.set(spec.local.name, importSource);\n }\n });\n }\n },\n });\n\n return importMap;\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,eAAe,aAA4C;CACzE,MAAM,4BAAY,IAAI,KAAqB;AAE3C,aAAY,SAAS,EACnB,kBAAkB,YAAY;AAC5B,MAAI,EAAE,gBAAgB,WAAW,KAAK,OAAO,EAAE;GAC7C,MAAM,eAAe,WAAW,KAAK,OAAO;AAC5C,cAAW,KAAK,WAAW,SAAS,SAAS;AAC3C,QACE,EAAE,kBAAkB,KAAK,IACzB,EAAE,aAAa,KAAK,SAAS,IAC7B,EAAE,aAAa,KAAK,MAAM,CAE1B,WAAU,IAAI,KAAK,MAAM,MAAM,aAAa;aAE5C,EAAE,yBAAyB,KAAK,IAChC,EAAE,aAAa,KAAK,MAAM,CAE1B,WAAU,IAAI,KAAK,MAAM,MAAM,aAAa;KAE9C;;IAGP,CAAC;AAEF,QAAO"}