@mui/internal-docs-infra 0.1.0 → 0.1.1-alpha.0

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 (294) hide show
  1. package/README.md +3 -1
  2. package/build/CodeControllerContext/CodeControllerContext.d.ts +22 -0
  3. package/build/CodeControllerContext/CodeControllerContext.js +21 -0
  4. package/build/CodeControllerContext/index.d.ts +1 -0
  5. package/build/CodeControllerContext/index.js +16 -0
  6. package/build/CodeHighlighter/CodeHighlighter.d.ts +2 -0
  7. package/build/CodeHighlighter/CodeHighlighter.js +329 -0
  8. package/build/CodeHighlighter/CodeHighlighterClient.d.ts +2 -0
  9. package/build/CodeHighlighter/CodeHighlighterClient.js +406 -0
  10. package/build/CodeHighlighter/CodeHighlighterContext.d.ts +14 -0
  11. package/build/CodeHighlighter/CodeHighlighterContext.js +22 -0
  12. package/build/CodeHighlighter/CodeHighlighterFallbackContext.d.ts +7 -0
  13. package/build/CodeHighlighter/CodeHighlighterFallbackContext.js +18 -0
  14. package/build/CodeHighlighter/applyTransform.d.ts +19 -0
  15. package/build/CodeHighlighter/applyTransform.js +83 -0
  16. package/build/CodeHighlighter/codeToFallbackProps.d.ts +2 -0
  17. package/build/CodeHighlighter/codeToFallbackProps.js +77 -0
  18. package/build/CodeHighlighter/errors.d.ts +0 -0
  19. package/build/CodeHighlighter/errors.js +2 -0
  20. package/build/CodeHighlighter/hasAllVariants.d.ts +2 -0
  21. package/build/CodeHighlighter/hasAllVariants.js +37 -0
  22. package/build/CodeHighlighter/index.d.ts +4 -0
  23. package/build/CodeHighlighter/index.js +49 -0
  24. package/build/CodeHighlighter/loadFallbackCode.d.ts +9 -0
  25. package/build/CodeHighlighter/loadFallbackCode.js +474 -0
  26. package/build/CodeHighlighter/loadVariant.d.ts +11 -0
  27. package/build/CodeHighlighter/loadVariant.js +715 -0
  28. package/build/CodeHighlighter/maybeInitialData.d.ts +10 -0
  29. package/build/CodeHighlighter/maybeInitialData.js +101 -0
  30. package/build/CodeHighlighter/parseCode.d.ts +6 -0
  31. package/build/CodeHighlighter/parseCode.js +129 -0
  32. package/build/CodeHighlighter/parseControlledCode.d.ts +6 -0
  33. package/build/CodeHighlighter/parseControlledCode.js +83 -0
  34. package/build/CodeHighlighter/transformCode.d.ts +20 -0
  35. package/build/CodeHighlighter/transformCode.js +231 -0
  36. package/build/CodeHighlighter/transformParsedSource.d.ts +3 -0
  37. package/build/CodeHighlighter/transformParsedSource.js +73 -0
  38. package/build/CodeHighlighter/transformSource.d.ts +2 -0
  39. package/build/CodeHighlighter/transformSource.js +114 -0
  40. package/build/CodeHighlighter/types.d.ts +138 -0
  41. package/build/CodeHighlighter/types.js +5 -0
  42. package/build/CodeProvider/CodeContext.d.ts +12 -0
  43. package/build/CodeProvider/CodeContext.js +14 -0
  44. package/build/CodeProvider/CodeProvider.d.ts +13 -0
  45. package/build/CodeProvider/CodeProvider.js +57 -0
  46. package/build/CodeProvider/index.d.ts +2 -0
  47. package/build/CodeProvider/index.js +27 -0
  48. package/build/README.md +19 -0
  49. package/build/esm/CodeControllerContext/CodeControllerContext.d.ts +22 -0
  50. package/build/esm/CodeControllerContext/CodeControllerContext.d.ts.map +1 -0
  51. package/build/esm/CodeControllerContext/CodeControllerContext.js +14 -0
  52. package/build/esm/CodeControllerContext/index.d.ts +1 -0
  53. package/build/esm/CodeControllerContext/index.d.ts.map +1 -0
  54. package/build/esm/CodeControllerContext/index.js +1 -0
  55. package/build/esm/CodeHighlighter/CodeHighlighter.d.ts +2 -0
  56. package/build/esm/CodeHighlighter/CodeHighlighter.d.ts.map +1 -0
  57. package/build/esm/CodeHighlighter/CodeHighlighter.js +321 -0
  58. package/build/esm/CodeHighlighter/CodeHighlighterClient.d.ts +2 -0
  59. package/build/esm/CodeHighlighter/CodeHighlighterClient.d.ts.map +1 -0
  60. package/build/esm/CodeHighlighter/CodeHighlighterClient.js +399 -0
  61. package/build/esm/CodeHighlighter/CodeHighlighterContext.d.ts +14 -0
  62. package/build/esm/CodeHighlighter/CodeHighlighterContext.d.ts.map +1 -0
  63. package/build/esm/CodeHighlighter/CodeHighlighterContext.js +14 -0
  64. package/build/esm/CodeHighlighter/CodeHighlighterFallbackContext.d.ts +7 -0
  65. package/build/esm/CodeHighlighter/CodeHighlighterFallbackContext.d.ts.map +1 -0
  66. package/build/esm/CodeHighlighter/CodeHighlighterFallbackContext.js +11 -0
  67. package/build/esm/CodeHighlighter/applyTransform.d.ts +19 -0
  68. package/build/esm/CodeHighlighter/applyTransform.d.ts.map +1 -0
  69. package/build/esm/CodeHighlighter/applyTransform.js +75 -0
  70. package/build/esm/CodeHighlighter/codeToFallbackProps.d.ts +2 -0
  71. package/build/esm/CodeHighlighter/codeToFallbackProps.d.ts.map +1 -0
  72. package/build/esm/CodeHighlighter/codeToFallbackProps.js +70 -0
  73. package/build/esm/CodeHighlighter/errors.d.ts +0 -0
  74. package/build/esm/CodeHighlighter/errors.d.ts.map +1 -0
  75. package/build/esm/CodeHighlighter/errors.js +1 -0
  76. package/build/esm/CodeHighlighter/hasAllVariants.d.ts +2 -0
  77. package/build/esm/CodeHighlighter/hasAllVariants.d.ts.map +1 -0
  78. package/build/esm/CodeHighlighter/hasAllVariants.js +31 -0
  79. package/build/esm/CodeHighlighter/index.d.ts +4 -0
  80. package/build/esm/CodeHighlighter/index.d.ts.map +1 -0
  81. package/build/esm/CodeHighlighter/index.js +4 -0
  82. package/build/esm/CodeHighlighter/loadFallbackCode.d.ts +9 -0
  83. package/build/esm/CodeHighlighter/loadFallbackCode.d.ts.map +1 -0
  84. package/build/esm/CodeHighlighter/loadFallbackCode.js +468 -0
  85. package/build/esm/CodeHighlighter/loadVariant.d.ts +11 -0
  86. package/build/esm/CodeHighlighter/loadVariant.d.ts.map +1 -0
  87. package/build/esm/CodeHighlighter/loadVariant.js +708 -0
  88. package/build/esm/CodeHighlighter/maybeInitialData.d.ts +10 -0
  89. package/build/esm/CodeHighlighter/maybeInitialData.d.ts.map +1 -0
  90. package/build/esm/CodeHighlighter/maybeInitialData.js +94 -0
  91. package/build/esm/CodeHighlighter/parseCode.d.ts +6 -0
  92. package/build/esm/CodeHighlighter/parseCode.d.ts.map +1 -0
  93. package/build/esm/CodeHighlighter/parseCode.js +122 -0
  94. package/build/esm/CodeHighlighter/parseControlledCode.d.ts +6 -0
  95. package/build/esm/CodeHighlighter/parseControlledCode.d.ts.map +1 -0
  96. package/build/esm/CodeHighlighter/parseControlledCode.js +76 -0
  97. package/build/esm/CodeHighlighter/transformCode.d.ts +20 -0
  98. package/build/esm/CodeHighlighter/transformCode.d.ts.map +1 -0
  99. package/build/esm/CodeHighlighter/transformCode.js +223 -0
  100. package/build/esm/CodeHighlighter/transformParsedSource.d.ts +3 -0
  101. package/build/esm/CodeHighlighter/transformParsedSource.d.ts.map +1 -0
  102. package/build/esm/CodeHighlighter/transformParsedSource.js +66 -0
  103. package/build/esm/CodeHighlighter/transformSource.d.ts +2 -0
  104. package/build/esm/CodeHighlighter/transformSource.d.ts.map +1 -0
  105. package/build/esm/CodeHighlighter/transformSource.js +107 -0
  106. package/build/esm/CodeHighlighter/types.d.ts +138 -0
  107. package/build/esm/CodeHighlighter/types.d.ts.map +1 -0
  108. package/build/esm/CodeHighlighter/types.js +1 -0
  109. package/build/esm/CodeProvider/CodeContext.d.ts +12 -0
  110. package/build/esm/CodeProvider/CodeContext.d.ts.map +1 -0
  111. package/build/esm/CodeProvider/CodeContext.js +8 -0
  112. package/build/esm/CodeProvider/CodeProvider.d.ts +13 -0
  113. package/build/esm/CodeProvider/CodeProvider.d.ts.map +1 -0
  114. package/build/esm/CodeProvider/CodeProvider.js +50 -0
  115. package/build/esm/CodeProvider/index.d.ts +2 -0
  116. package/build/esm/CodeProvider/index.d.ts.map +1 -0
  117. package/build/esm/CodeProvider/index.js +2 -0
  118. package/build/esm/hast/hast.d.ts +11 -0
  119. package/build/esm/hast/hast.d.ts.map +1 -0
  120. package/build/esm/hast/hast.js +66 -0
  121. package/build/esm/hast/index.d.ts +1 -0
  122. package/build/esm/hast/index.d.ts.map +1 -0
  123. package/build/esm/hast/index.js +1 -0
  124. package/build/esm/loadPrecomputedCodeHighlighter/index.d.ts +2 -0
  125. package/build/esm/loadPrecomputedCodeHighlighter/index.d.ts.map +1 -0
  126. package/build/esm/loadPrecomputedCodeHighlighter/index.js +4 -0
  127. package/build/esm/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +57 -0
  128. package/build/esm/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +1 -0
  129. package/build/esm/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +194 -0
  130. package/build/esm/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts +20 -0
  131. package/build/esm/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +1 -0
  132. package/build/esm/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +243 -0
  133. package/build/esm/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts +15 -0
  134. package/build/esm/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +1 -0
  135. package/build/esm/loadPrecomputedCodeHighlighter/parseFunctionParameters.js +168 -0
  136. package/build/esm/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +27 -0
  137. package/build/esm/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +1 -0
  138. package/build/esm/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +37 -0
  139. package/build/esm/loadServerCodeMeta/index.d.ts +1 -0
  140. package/build/esm/loadServerCodeMeta/index.d.ts.map +1 -0
  141. package/build/esm/loadServerCodeMeta/index.js +1 -0
  142. package/build/esm/loadServerCodeMeta/serverLoadCodeMeta.d.ts +24 -0
  143. package/build/esm/loadServerCodeMeta/serverLoadCodeMeta.d.ts.map +1 -0
  144. package/build/esm/loadServerCodeMeta/serverLoadCodeMeta.js +77 -0
  145. package/build/esm/loadServerSource/index.d.ts +1 -0
  146. package/build/esm/loadServerSource/index.d.ts.map +1 -0
  147. package/build/esm/loadServerSource/index.js +1 -0
  148. package/build/esm/loadServerSource/serverLoadSource.d.ts +25 -0
  149. package/build/esm/loadServerSource/serverLoadSource.d.ts.map +1 -0
  150. package/build/esm/loadServerSource/serverLoadSource.js +100 -0
  151. package/build/esm/loaderUtils/getFileNameFromUrl.d.ts +11 -0
  152. package/build/esm/loaderUtils/getFileNameFromUrl.d.ts.map +1 -0
  153. package/build/esm/loaderUtils/getFileNameFromUrl.js +32 -0
  154. package/build/esm/loaderUtils/index.d.ts +5 -0
  155. package/build/esm/loaderUtils/index.d.ts.map +1 -0
  156. package/build/esm/loaderUtils/index.js +5 -0
  157. package/build/esm/loaderUtils/processImports.d.ts +19 -0
  158. package/build/esm/loaderUtils/processImports.d.ts.map +1 -0
  159. package/build/esm/loaderUtils/processImports.js +82 -0
  160. package/build/esm/loaderUtils/resolveImports.d.ts +4 -0
  161. package/build/esm/loaderUtils/resolveImports.d.ts.map +1 -0
  162. package/build/esm/loaderUtils/resolveImports.js +71 -0
  163. package/build/esm/loaderUtils/resolveModulePath.d.ts +74 -0
  164. package/build/esm/loaderUtils/resolveModulePath.d.ts.map +1 -0
  165. package/build/esm/loaderUtils/resolveModulePath.js +827 -0
  166. package/build/esm/loaderUtils/resolveModulePathWithFs.d.ts +44 -0
  167. package/build/esm/loaderUtils/resolveModulePathWithFs.d.ts.map +1 -0
  168. package/build/esm/loaderUtils/resolveModulePathWithFs.js +159 -0
  169. package/build/esm/loaderUtils/rewriteImports.d.ts +9 -0
  170. package/build/esm/loaderUtils/rewriteImports.d.ts.map +1 -0
  171. package/build/esm/loaderUtils/rewriteImports.js +57 -0
  172. package/build/esm/parseSource/grammars.d.ts +2 -0
  173. package/build/esm/parseSource/grammars.d.ts.map +1 -0
  174. package/build/esm/parseSource/grammars.js +27 -0
  175. package/build/esm/parseSource/index.d.ts +1 -0
  176. package/build/esm/parseSource/index.d.ts.map +1 -0
  177. package/build/esm/parseSource/index.js +1 -0
  178. package/build/esm/parseSource/parseSource.d.ts +3 -0
  179. package/build/esm/parseSource/parseSource.d.ts.map +1 -0
  180. package/build/esm/parseSource/parseSource.js +37 -0
  181. package/build/esm/transformRelativeMarkdownPaths/index.d.ts +2 -0
  182. package/build/esm/transformRelativeMarkdownPaths/index.d.ts.map +1 -0
  183. package/build/esm/transformRelativeMarkdownPaths/index.js +4 -0
  184. package/build/esm/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts +12 -0
  185. package/build/esm/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts.map +1 -0
  186. package/build/esm/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.js +30 -0
  187. package/build/esm/transformTsToJs/index.d.ts +1 -0
  188. package/build/esm/transformTsToJs/index.d.ts.map +1 -0
  189. package/build/esm/transformTsToJs/index.js +1 -0
  190. package/build/esm/transformTsToJs/removeTypes.d.ts +13 -0
  191. package/build/esm/transformTsToJs/removeTypes.d.ts.map +1 -0
  192. package/build/esm/transformTsToJs/removeTypes.js +134 -0
  193. package/build/esm/transformTsToJs/transformTsToJs.d.ts +3 -0
  194. package/build/esm/transformTsToJs/transformTsToJs.d.ts.map +1 -0
  195. package/build/esm/transformTsToJs/transformTsToJs.js +34 -0
  196. package/build/esm/useCode/index.d.ts +1 -0
  197. package/build/esm/useCode/index.d.ts.map +1 -0
  198. package/build/esm/useCode/index.js +1 -0
  199. package/build/esm/useCode/useCode.d.ts +37 -0
  200. package/build/esm/useCode/useCode.d.ts.map +1 -0
  201. package/build/esm/useCode/useCode.js +393 -0
  202. package/{esm → build/esm}/useDemo/index.d.ts +12 -24
  203. package/build/esm/useDemo/index.d.ts.map +1 -0
  204. package/build/esm/useDemo/index.js +17 -0
  205. package/build/esm/useOnHydrate/index.d.ts +1 -0
  206. package/build/esm/useOnHydrate/index.d.ts.map +1 -0
  207. package/build/esm/useOnHydrate/index.js +1 -0
  208. package/build/esm/useOnHydrate/useOnHydrate.d.ts +1 -0
  209. package/build/esm/useOnHydrate/useOnHydrate.d.ts.map +1 -0
  210. package/build/esm/useOnHydrate/useOnHydrate.js +18 -0
  211. package/build/esm/useOnIdle/index.d.ts +1 -0
  212. package/build/esm/useOnIdle/index.d.ts.map +1 -0
  213. package/build/esm/useOnIdle/index.js +1 -0
  214. package/build/esm/useOnIdle/useOnIdle.d.ts +1 -0
  215. package/build/esm/useOnIdle/useOnIdle.d.ts.map +1 -0
  216. package/build/esm/useOnIdle/useOnIdle.js +39 -0
  217. package/build/hast/hast.d.ts +11 -0
  218. package/build/hast/hast.js +75 -0
  219. package/build/hast/index.d.ts +1 -0
  220. package/build/hast/index.js +16 -0
  221. package/build/loadPrecomputedCodeHighlighter/index.d.ts +2 -0
  222. package/build/loadPrecomputedCodeHighlighter/index.js +9 -0
  223. package/build/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +57 -0
  224. package/build/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +201 -0
  225. package/build/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts +20 -0
  226. package/build/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +248 -0
  227. package/build/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts +15 -0
  228. package/build/loadPrecomputedCodeHighlighter/parseFunctionParameters.js +174 -0
  229. package/build/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +27 -0
  230. package/build/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +43 -0
  231. package/build/loadServerCodeMeta/index.d.ts +1 -0
  232. package/build/loadServerCodeMeta/index.js +16 -0
  233. package/build/loadServerCodeMeta/serverLoadCodeMeta.d.ts +24 -0
  234. package/build/loadServerCodeMeta/serverLoadCodeMeta.js +85 -0
  235. package/build/loadServerSource/index.d.ts +1 -0
  236. package/build/loadServerSource/index.js +16 -0
  237. package/build/loadServerSource/serverLoadSource.d.ts +25 -0
  238. package/build/loadServerSource/serverLoadSource.js +108 -0
  239. package/build/loaderUtils/getFileNameFromUrl.d.ts +11 -0
  240. package/build/loaderUtils/getFileNameFromUrl.js +38 -0
  241. package/build/loaderUtils/index.d.ts +5 -0
  242. package/build/loaderUtils/index.js +60 -0
  243. package/build/loaderUtils/processImports.d.ts +19 -0
  244. package/build/loaderUtils/processImports.js +89 -0
  245. package/build/loaderUtils/resolveImports.d.ts +4 -0
  246. package/build/loaderUtils/resolveImports.js +78 -0
  247. package/build/loaderUtils/resolveModulePath.d.ts +74 -0
  248. package/build/loaderUtils/resolveModulePath.js +835 -0
  249. package/build/loaderUtils/resolveModulePathWithFs.d.ts +44 -0
  250. package/build/loaderUtils/resolveModulePathWithFs.js +163 -0
  251. package/build/loaderUtils/rewriteImports.d.ts +9 -0
  252. package/build/loaderUtils/rewriteImports.js +62 -0
  253. package/build/package.json +101 -0
  254. package/build/parseSource/grammars.d.ts +2 -0
  255. package/build/parseSource/grammars.js +34 -0
  256. package/build/parseSource/index.d.ts +1 -0
  257. package/build/parseSource/index.js +16 -0
  258. package/build/parseSource/parseSource.d.ts +3 -0
  259. package/build/parseSource/parseSource.js +44 -0
  260. package/build/transformRelativeMarkdownPaths/index.d.ts +2 -0
  261. package/build/transformRelativeMarkdownPaths/index.js +9 -0
  262. package/build/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts +12 -0
  263. package/build/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.js +36 -0
  264. package/build/transformTsToJs/index.d.ts +1 -0
  265. package/build/transformTsToJs/index.js +16 -0
  266. package/build/transformTsToJs/removeTypes.d.ts +13 -0
  267. package/build/transformTsToJs/removeTypes.js +141 -0
  268. package/build/transformTsToJs/transformTsToJs.d.ts +3 -0
  269. package/build/transformTsToJs/transformTsToJs.js +41 -0
  270. package/build/useCode/index.d.ts +1 -0
  271. package/build/useCode/index.js +16 -0
  272. package/build/useCode/useCode.d.ts +37 -0
  273. package/build/useCode/useCode.js +401 -0
  274. package/{useDemo → build/useDemo}/index.d.ts +12 -24
  275. package/build/useDemo/index.js +25 -0
  276. package/build/useOnHydrate/index.d.ts +1 -0
  277. package/build/useOnHydrate/index.js +16 -0
  278. package/build/useOnHydrate/useOnHydrate.d.ts +1 -0
  279. package/build/useOnHydrate/useOnHydrate.js +26 -0
  280. package/build/useOnIdle/index.d.ts +1 -0
  281. package/build/useOnIdle/index.js +16 -0
  282. package/build/useOnIdle/useOnIdle.d.ts +1 -0
  283. package/build/useOnIdle/useOnIdle.js +47 -0
  284. package/package.json +86 -14
  285. package/esm/useDemo/index.d.ts.map +0 -1
  286. package/esm/useDemo/index.js +0 -104
  287. package/useDemo/index.js +0 -112
  288. /package/{LICENSE → build/LICENSE} +0 -0
  289. /package/{esm → build/esm}/package.json +0 -0
  290. /package/{esm → build/esm}/useCopier/index.d.ts +0 -0
  291. /package/{esm → build/esm}/useCopier/index.d.ts.map +0 -0
  292. /package/{esm → build/esm}/useCopier/index.js +0 -0
  293. /package/{useCopier → build/useCopier}/index.d.ts +0 -0
  294. /package/{useCopier → build/useCopier}/index.js +0 -0
@@ -0,0 +1,44 @@
1
+ import { type DirectoryEntry, type DirectoryReader, type ResolveModulePathOptions } from "./resolveModulePath.js";
2
+ /**
3
+ * Resolves a module path using Node.js filesystem APIs.
4
+ * This is a convenience wrapper around the generic resolveModulePath function.
5
+ *
6
+ * @param modulePath - The module path to resolve (without file extension)
7
+ * @param options - Configuration options
8
+ * @returns Promise<string> - The resolved file path, or throws if not found
9
+ */
10
+ export declare function resolveModulePathWithFs(modulePath: string, options?: ResolveModulePathOptions): Promise<string>;
11
+ /**
12
+ * Resolves multiple module paths using Node.js filesystem APIs.
13
+ * This is a convenience wrapper around the generic resolveModulePaths function.
14
+ *
15
+ * @param modulePaths - Array of module paths to resolve (without file extensions)
16
+ * @param options - Configuration options
17
+ * @returns Promise<Map<string, string>> - Map from input path to resolved file path
18
+ */
19
+ export declare function resolveModulePathsWithFs(modulePaths: string[], options?: ResolveModulePathOptions): Promise<Map<string, string>>;
20
+ /**
21
+ * Resolves import result by separating JavaScript modules from static assets,
22
+ * only resolving JavaScript modules and returning a combined map.
23
+ * This is a convenience wrapper around the generic resolveImportResult function
24
+ * that uses Node.js filesystem APIs.
25
+ *
26
+ * @param importResult - The result from resolveImports containing all imports
27
+ * @param options - Configuration options for module resolution
28
+ * @returns Promise<Map<string, string>> - Map from import path to resolved file path
29
+ */
30
+ export declare function resolveImportResultWithFs(importResult: Record<string, {
31
+ path: string;
32
+ names: string[];
33
+ }>, options?: ResolveModulePathOptions): Promise<Map<string, string>>;
34
+ /**
35
+ * Resolves variant paths from a variants object mapping variant names to their file paths.
36
+ * This is a convenience wrapper around the generic resolveVariantPaths function
37
+ * that uses Node.js filesystem APIs.
38
+ *
39
+ * @param variants - Object mapping variant names to their file paths
40
+ * @param options - Configuration options for module resolution
41
+ * @returns Promise<Map<string, string>> - Map from variant name to resolved file URL
42
+ */
43
+ export declare function resolveVariantPathsWithFs(variants: Record<string, string>, options?: ResolveModulePathOptions): Promise<Map<string, string>>;
44
+ export type { DirectoryEntry, DirectoryReader, ResolveModulePathOptions };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveModulePathWithFs.d.ts","sourceRoot":"","sources":["../../../src/loaderUtils/resolveModulePathWithFs.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC9B,MAAM,qBAAqB,CAAC;AAe7B;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED;;;;;;;GAOG;AACH,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,MAAM,EAAE,EACrB,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAE9B;AAED;;;;;;;;;GASG;AACH,wBAAsB,yBAAyB,CAC7C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,EAC/D,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAE9B;AAED;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAE9B;AAGD,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,wBAAwB,EAAE,CAAC"}
@@ -0,0 +1,159 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import { readdir } from 'node:fs/promises';
4
+ import { resolveModulePath, resolveModulePaths, resolveImportResult, resolveVariantPaths } from "./resolveModulePath.js";
5
+
6
+ /**
7
+ * Node.js filesystem-based directory reader that converts Dirent objects
8
+ * to the DirectoryEntry interface expected by the resolver functions.
9
+ */
10
+ var nodeDirectoryReader = /*#__PURE__*/function () {
11
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(path) {
12
+ var entries;
13
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
14
+ while (1) switch (_context.prev = _context.next) {
15
+ case 0:
16
+ _context.next = 2;
17
+ return readdir(path, {
18
+ withFileTypes: true
19
+ });
20
+ case 2:
21
+ entries = _context.sent;
22
+ return _context.abrupt("return", entries.map(function (entry) {
23
+ return {
24
+ name: entry.name,
25
+ isFile: entry.isFile(),
26
+ isDirectory: entry.isDirectory()
27
+ };
28
+ }));
29
+ case 4:
30
+ case "end":
31
+ return _context.stop();
32
+ }
33
+ }, _callee);
34
+ }));
35
+ return function nodeDirectoryReader(_x) {
36
+ return _ref.apply(this, arguments);
37
+ };
38
+ }();
39
+
40
+ /**
41
+ * Resolves a module path using Node.js filesystem APIs.
42
+ * This is a convenience wrapper around the generic resolveModulePath function.
43
+ *
44
+ * @param modulePath - The module path to resolve (without file extension)
45
+ * @param options - Configuration options
46
+ * @returns Promise<string> - The resolved file path, or throws if not found
47
+ */
48
+ export function resolveModulePathWithFs(_x2) {
49
+ return _resolveModulePathWithFs.apply(this, arguments);
50
+ }
51
+
52
+ /**
53
+ * Resolves multiple module paths using Node.js filesystem APIs.
54
+ * This is a convenience wrapper around the generic resolveModulePaths function.
55
+ *
56
+ * @param modulePaths - Array of module paths to resolve (without file extensions)
57
+ * @param options - Configuration options
58
+ * @returns Promise<Map<string, string>> - Map from input path to resolved file path
59
+ */
60
+ function _resolveModulePathWithFs() {
61
+ _resolveModulePathWithFs = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(modulePath) {
62
+ var options,
63
+ _args2 = arguments;
64
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
65
+ while (1) switch (_context2.prev = _context2.next) {
66
+ case 0:
67
+ options = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
68
+ return _context2.abrupt("return", resolveModulePath(modulePath, nodeDirectoryReader, options));
69
+ case 2:
70
+ case "end":
71
+ return _context2.stop();
72
+ }
73
+ }, _callee2);
74
+ }));
75
+ return _resolveModulePathWithFs.apply(this, arguments);
76
+ }
77
+ export function resolveModulePathsWithFs(_x3) {
78
+ return _resolveModulePathsWithFs.apply(this, arguments);
79
+ }
80
+
81
+ /**
82
+ * Resolves import result by separating JavaScript modules from static assets,
83
+ * only resolving JavaScript modules and returning a combined map.
84
+ * This is a convenience wrapper around the generic resolveImportResult function
85
+ * that uses Node.js filesystem APIs.
86
+ *
87
+ * @param importResult - The result from resolveImports containing all imports
88
+ * @param options - Configuration options for module resolution
89
+ * @returns Promise<Map<string, string>> - Map from import path to resolved file path
90
+ */
91
+ function _resolveModulePathsWithFs() {
92
+ _resolveModulePathsWithFs = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(modulePaths) {
93
+ var options,
94
+ _args3 = arguments;
95
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
96
+ while (1) switch (_context3.prev = _context3.next) {
97
+ case 0:
98
+ options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
99
+ return _context3.abrupt("return", resolveModulePaths(modulePaths, nodeDirectoryReader, options));
100
+ case 2:
101
+ case "end":
102
+ return _context3.stop();
103
+ }
104
+ }, _callee3);
105
+ }));
106
+ return _resolveModulePathsWithFs.apply(this, arguments);
107
+ }
108
+ export function resolveImportResultWithFs(_x4) {
109
+ return _resolveImportResultWithFs.apply(this, arguments);
110
+ }
111
+
112
+ /**
113
+ * Resolves variant paths from a variants object mapping variant names to their file paths.
114
+ * This is a convenience wrapper around the generic resolveVariantPaths function
115
+ * that uses Node.js filesystem APIs.
116
+ *
117
+ * @param variants - Object mapping variant names to their file paths
118
+ * @param options - Configuration options for module resolution
119
+ * @returns Promise<Map<string, string>> - Map from variant name to resolved file URL
120
+ */
121
+ function _resolveImportResultWithFs() {
122
+ _resolveImportResultWithFs = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(importResult) {
123
+ var options,
124
+ _args4 = arguments;
125
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
126
+ while (1) switch (_context4.prev = _context4.next) {
127
+ case 0:
128
+ options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
129
+ return _context4.abrupt("return", resolveImportResult(importResult, nodeDirectoryReader, options));
130
+ case 2:
131
+ case "end":
132
+ return _context4.stop();
133
+ }
134
+ }, _callee4);
135
+ }));
136
+ return _resolveImportResultWithFs.apply(this, arguments);
137
+ }
138
+ export function resolveVariantPathsWithFs(_x5) {
139
+ return _resolveVariantPathsWithFs.apply(this, arguments);
140
+ }
141
+
142
+ // Re-export types for convenience
143
+ function _resolveVariantPathsWithFs() {
144
+ _resolveVariantPathsWithFs = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(variants) {
145
+ var options,
146
+ _args5 = arguments;
147
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
148
+ while (1) switch (_context5.prev = _context5.next) {
149
+ case 0:
150
+ options = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
151
+ return _context5.abrupt("return", resolveVariantPaths(variants, nodeDirectoryReader, options));
152
+ case 2:
153
+ case "end":
154
+ return _context5.stop();
155
+ }
156
+ }, _callee5);
157
+ }));
158
+ return _resolveVariantPathsWithFs.apply(this, arguments);
159
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Rewrites relative imports in source code to assume all files are in the same directory.
3
+ * Converts imports like '../utils/helper' or './components/Button' to './helper' and './Button'
4
+ *
5
+ * @param source - The source code to process
6
+ * @param filePaths - Set of file paths that are available as dependencies
7
+ * @returns The source code with rewritten imports
8
+ */
9
+ export declare function rewriteImportsToSameDirectory(source: string, filePaths: Set<string>): string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rewriteImports.d.ts","sourceRoot":"","sources":["../../../src/loaderUtils/rewriteImports.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAmD5F"}
@@ -0,0 +1,57 @@
1
+ import { JAVASCRIPT_MODULE_EXTENSIONS, isJavaScriptModule } from "./resolveModulePath.js";
2
+ import { getFileNameFromUrl } from "./getFileNameFromUrl.js";
3
+
4
+ /**
5
+ * Rewrites relative imports in source code to assume all files are in the same directory.
6
+ * Converts imports like '../utils/helper' or './components/Button' to './helper' and './Button'
7
+ *
8
+ * @param source - The source code to process
9
+ * @param filePaths - Set of file paths that are available as dependencies
10
+ * @returns The source code with rewritten imports
11
+ */
12
+ export function rewriteImportsToSameDirectory(source, filePaths) {
13
+ // Create a map of original file paths to just their basenames
14
+ var fileBasenames = new Map();
15
+ Array.from(filePaths).forEach(function (path) {
16
+ fileBasenames.set(path, getFileNameFromUrl(path).fileName);
17
+ });
18
+
19
+ // Regex to match import statements with relative paths
20
+ var importRegex = /import\s+((?:\w+|\*\s+as\s+\w+|{[^}]+})\s+from\s+)['"]([^'"]+)['"]/g;
21
+ return source.replace(importRegex, function (match, importPart, modulePath) {
22
+ // Only process relative imports
23
+ if (modulePath.startsWith('.')) {
24
+ // Extract the filename from the path
25
+ var filename = getFileNameFromUrl(modulePath).fileName;
26
+
27
+ // For static assets (CSS, JSON, etc.), use the filename as-is
28
+ if (!isJavaScriptModule(modulePath)) {
29
+ var matchingPath = Array.from(filePaths).find(function (path) {
30
+ return getFileNameFromUrl(path).fileName === filename;
31
+ });
32
+ if (matchingPath) {
33
+ return "import ".concat(importPart, "'./").concat(filename, "'");
34
+ }
35
+ } else {
36
+ // For JS/TS modules, check against all possible extensions
37
+ var _matchingPath = Array.from(filePaths).find(function (path) {
38
+ var pathBasename = getFileNameFromUrl(path).fileName;
39
+ return pathBasename === filename || JAVASCRIPT_MODULE_EXTENSIONS.some(function (ext) {
40
+ var _getFileNameFromUrl = getFileNameFromUrl(path),
41
+ fileName = _getFileNameFromUrl.fileName;
42
+ return fileName.endsWith(ext) ? fileName.slice(0, -ext.length) === filename : false;
43
+ });
44
+ });
45
+ if (_matchingPath) {
46
+ // For JS/TS modules, rewrite to same directory without extension
47
+ var pathBasename = getFileNameFromUrl(_matchingPath).fileName;
48
+ var nameWithoutExt = JAVASCRIPT_MODULE_EXTENSIONS.reduce(function (name, ext) {
49
+ return name.replace(new RegExp("\\".concat(ext, "$")), '');
50
+ }, pathBasename);
51
+ return "import ".concat(importPart, "'./").concat(nameWithoutExt, "'");
52
+ }
53
+ }
54
+ }
55
+ return match;
56
+ });
57
+ }
@@ -0,0 +1,2 @@
1
+ export declare const grammars: import("@wooorm/starry-night").Grammar[];
2
+ export declare const extensionMap: Record<string, string>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grammars.d.ts","sourceRoot":"","sources":["../../../src/parseSource/grammars.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,QAAQ,0CAWpB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAY/C,CAAC"}
@@ -0,0 +1,27 @@
1
+ import sourceJs from '@wooorm/starry-night/source.js';
2
+ import sourceTs from '@wooorm/starry-night/source.ts';
3
+ import sourceTsx from '@wooorm/starry-night/source.tsx';
4
+ import sourceJson from '@wooorm/starry-night/source.json';
5
+ import textMd from '@wooorm/starry-night/text.md';
6
+ import sourceMdx from '@wooorm/starry-night/source.mdx';
7
+ import textHtmlBasic from '@wooorm/starry-night/text.html.basic';
8
+ import sourceCss from '@wooorm/starry-night/source.css';
9
+ import sourceShell from '@wooorm/starry-night/source.shell';
10
+ import sourceYaml from '@wooorm/starry-night/source.yaml';
11
+ export var grammars = [sourceJs, sourceTs, sourceTsx, sourceJson, textMd, sourceMdx,
12
+ // needs sourceTsx
13
+ textHtmlBasic, sourceCss, sourceShell, sourceYaml];
14
+ export var extensionMap = {
15
+ '.js': 'source.js',
16
+ '.ts': 'source.ts',
17
+ '.jsx': 'source.tsx',
18
+ // TODO: is there a JSX grammar?
19
+ '.tsx': 'source.tsx',
20
+ '.json': 'source.json',
21
+ '.md': 'text.md',
22
+ '.mdx': 'source.mdx',
23
+ '.html': 'text.html.basic',
24
+ '.css': 'source.css',
25
+ '.sh': 'source.shell',
26
+ '.yaml': 'source.yaml'
27
+ };
@@ -0,0 +1 @@
1
+ export * from "./parseSource.js";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/parseSource/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./parseSource.js";
@@ -0,0 +1,3 @@
1
+ import { ParseSource } from "../CodeHighlighter/index.js";
2
+ export declare const parseSource: ParseSource;
3
+ export declare const parseSourceFactory: () => Promise<ParseSource>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseSource.d.ts","sourceRoot":"","sources":["../../../src/parseSource/parseSource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAOjD,eAAO,MAAM,WAAW,EAAE,WASzB,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAa,OAAO,CAAC,WAAW,CAM9D,CAAC"}
@@ -0,0 +1,37 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import { createStarryNight } from '@wooorm/starry-night';
4
+ import { grammars, extensionMap } from "./grammars.js";
5
+ var starryNight = null;
6
+ export var parseSource = function parseSource(source, fileName) {
7
+ if (!starryNight) {
8
+ throw new Error('Starry Night not initialized. Use parseSourceFactory to create an initialized parseSource function.');
9
+ }
10
+ var fileType = fileName.slice(fileName.lastIndexOf('.')) || 'plaintext';
11
+ return starryNight.highlight(source, extensionMap[fileType] || 'plaintext');
12
+ };
13
+ export var parseSourceFactory = /*#__PURE__*/function () {
14
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
15
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
16
+ while (1) switch (_context.prev = _context.next) {
17
+ case 0:
18
+ if (starryNight) {
19
+ _context.next = 4;
20
+ break;
21
+ }
22
+ _context.next = 3;
23
+ return createStarryNight(grammars);
24
+ case 3:
25
+ starryNight = _context.sent;
26
+ case 4:
27
+ return _context.abrupt("return", parseSource);
28
+ case 5:
29
+ case "end":
30
+ return _context.stop();
31
+ }
32
+ }, _callee);
33
+ }));
34
+ return function parseSourceFactory() {
35
+ return _ref.apply(this, arguments);
36
+ };
37
+ }();
@@ -0,0 +1,2 @@
1
+ import { transformRelativeMarkdownPaths } from "./transformRelativeMarkdownPaths.js";
2
+ export default transformRelativeMarkdownPaths;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transformRelativeMarkdownPaths/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF,eAAe,8BAA8B,CAAC"}
@@ -0,0 +1,4 @@
1
+ // This is the export format expected by a remark plugin.
2
+
3
+ import { transformRelativeMarkdownPaths } from "./transformRelativeMarkdownPaths.js";
4
+ export default transformRelativeMarkdownPaths;
@@ -0,0 +1,12 @@
1
+ import type { Plugin } from 'unified';
2
+ /**
3
+ * Remark plugin that strips page file extensions from URLs.
4
+ * Removes /page.tsx, /page.jsx, /page.js, /page.mdx, /page.md from both absolute and relative URLs.
5
+ * For relative URLs, converts them to absolute paths based on the current file's location.
6
+ *
7
+ * Examples:
8
+ * - /components/page.tsx -> /components
9
+ * - ./code-highlighter/page.mdx -> /components/code-highlighter (when processed from /components/page.mdx)
10
+ * This allows URLs to resolve when reading in VSCode and Github
11
+ */
12
+ export declare const transformRelativeMarkdownPaths: Plugin;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformRelativeMarkdownPaths.d.ts","sourceRoot":"","sources":["../../../src/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAItC;;;;;;;;;GASG;AACH,eAAO,MAAM,8BAA8B,EAAE,MAmB5C,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { visit } from 'unist-util-visit';
2
+ import path from 'path';
3
+
4
+ /**
5
+ * Remark plugin that strips page file extensions from URLs.
6
+ * Removes /page.tsx, /page.jsx, /page.js, /page.mdx, /page.md from both absolute and relative URLs.
7
+ * For relative URLs, converts them to absolute paths based on the current file's location.
8
+ *
9
+ * Examples:
10
+ * - /components/page.tsx -> /components
11
+ * - ./code-highlighter/page.mdx -> /components/code-highlighter (when processed from /components/page.mdx)
12
+ * This allows URLs to resolve when reading in VSCode and Github
13
+ */
14
+ export var transformRelativeMarkdownPaths = function transformRelativeMarkdownPaths() {
15
+ return function (tree, file) {
16
+ visit(tree, 'link', function (node) {
17
+ if (node.url) {
18
+ node.url = node.url.replace(/\/page\.(tsx|jsx|js|mdx|md)$/g, '');
19
+ node.url = node.url.replace(/\/page\.(tsx|jsx|js|mdx|md)(\?[^#]*)?(#.*)?$/g, '$2$3');
20
+ if (node.url.startsWith('./') && file.path) {
21
+ var currentDir = path.dirname(file.path);
22
+ var appIndex = currentDir.indexOf('/app/');
23
+ var baseDir = appIndex !== -1 ? currentDir.substring(appIndex + 4) : '/';
24
+ node.url = path.join('/', baseDir, node.url.replace(/^\.\//, ''));
25
+ }
26
+ node.url = node.url.replace(/\/$/, '');
27
+ }
28
+ });
29
+ };
30
+ };
@@ -0,0 +1 @@
1
+ export * from "./transformTsToJs.js";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transformTsToJs/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./transformTsToJs.js";
@@ -0,0 +1,13 @@
1
+ import type { Options as PrettierOptions } from 'prettier';
2
+ /**
3
+ * Strips TypeScript types and decorators from code (including React in TSX),
4
+ * preserving blank lines and optionally formatting with Prettier.
5
+ *
6
+ * @param code - The source code string to transform.
7
+ * @param filename - The name of the file (e.g. "foo.ts" or "Foo.tsx").
8
+ * Determines whether TSX parsing is enabled.
9
+ * @param prettierConfig - `true` for default formatting, `false` to skip,
10
+ * or a Prettier options object to customize.
11
+ * @returns The transformed (and optionally formatted) code.
12
+ */
13
+ export declare function removeTypes(code: string, filename?: string, prettierConfig?: PrettierOptions | boolean): Promise<string>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeTypes.d.ts","sourceRoot":"","sources":["../../../src/transformTsToJs/removeTypes.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3D;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,QAAQ,SAAY,EACpB,cAAc,GAAE,eAAe,GAAG,OAAc,GAC/C,OAAO,CAAC,MAAM,CAAC,CAkGjB"}
@@ -0,0 +1,134 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
+ // Based on https://github.com/ember-cli/babel-remove-types/blob/fc3be010e99c4f4926fd70d00242d6777ab1b8d7/src/index.ts
5
+ // Converted to use Babel standalone, with added TSX support
6
+
7
+ import * as Babel from '@babel/standalone';
8
+ import prettier from 'prettier/standalone';
9
+ import prettierPluginEstree from 'prettier/plugins/estree';
10
+ import parserBabel from 'prettier/parser-babel';
11
+ /**
12
+ * Strips TypeScript types and decorators from code (including React in TSX),
13
+ * preserving blank lines and optionally formatting with Prettier.
14
+ *
15
+ * @param code - The source code string to transform.
16
+ * @param filename - The name of the file (e.g. "foo.ts" or "Foo.tsx").
17
+ * Determines whether TSX parsing is enabled.
18
+ * @param prettierConfig - `true` for default formatting, `false` to skip,
19
+ * or a Prettier options object to customize.
20
+ * @returns The transformed (and optionally formatted) code.
21
+ */
22
+ export function removeTypes(_x) {
23
+ return _removeTypes.apply(this, arguments);
24
+ }
25
+ function _removeTypes() {
26
+ _removeTypes = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(code) {
27
+ var filename,
28
+ prettierConfig,
29
+ removeComments,
30
+ isTSX,
31
+ transformed,
32
+ fixed,
33
+ standardPrettierOptions,
34
+ mergedPrettierOptions,
35
+ _args = arguments;
36
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
37
+ while (1) switch (_context.prev = _context.next) {
38
+ case 0:
39
+ filename = _args.length > 1 && _args[1] !== undefined ? _args[1] : 'file.ts';
40
+ prettierConfig = _args.length > 2 && _args[2] !== undefined ? _args[2] : true;
41
+ // Babel collapses newlines all over the place, which messes with the formatting of almost any
42
+ // code you pass to it. To preserve the formatting, we go through and mark all the empty lines
43
+ // in the code string *before* transforming it. This allows us to go back through after the
44
+ // transformation re-insert the empty lines in the correct place relative to the new code that
45
+ // has been generated.
46
+ code = code.replace(/\n\n+/g, '/* ___NEWLINE___ */\n');
47
+
48
+ // When removing TS-specific constructs (e.g. interfaces), we want to make sure we also remove
49
+ // any comments that are associated with those constructs, since otherwise we'll be left with
50
+ // comments that refer to something that isn't actually there.
51
+ // Credit to https://github.com/cyco130/detype for figuring out this very useful pattern
52
+ removeComments = {
53
+ enter: function enter(nodePath) {
54
+ if (!nodePath.node.leadingComments) {
55
+ return;
56
+ }
57
+ for (var i = nodePath.node.leadingComments.length - 1; i >= 0; i -= 1) {
58
+ var comment = nodePath.node.leadingComments[i];
59
+ if (code.slice(comment.end).match(/^\s*\n\s*\n/) || comment.value.includes('___NEWLINE___')) {
60
+ // There is at least one empty line between the comment and the TypeScript specific construct
61
+ // We should keep this comment and those before it
62
+ break;
63
+ }
64
+ comment.value = '___REMOVE_ME___';
65
+ }
66
+ }
67
+ };
68
+ isTSX = /\.tsx$/i.test(filename);
69
+ transformed = Babel.transform(code, {
70
+ filename: filename,
71
+ plugins: [{
72
+ name: 'comment-remover',
73
+ visitor: {
74
+ TSTypeAliasDeclaration: removeComments,
75
+ TSInterfaceDeclaration: removeComments,
76
+ TSDeclareFunction: removeComments,
77
+ TSDeclareMethod: removeComments,
78
+ TSImportType: removeComments,
79
+ TSModuleDeclaration: removeComments
80
+ }
81
+ }, ['transform-typescript', {
82
+ onlyRemoveTypeImports: true,
83
+ isTSX: isTSX,
84
+ allExtensions: true
85
+ }], ['proposal-decorators', {
86
+ legacy: true
87
+ }]],
88
+ generatorOpts: {
89
+ retainLines: true,
90
+ shouldPrintComment: function shouldPrintComment(c) {
91
+ return c !== '___REMOVE_ME___';
92
+ }
93
+ }
94
+ });
95
+ if (!(!transformed || !transformed.code)) {
96
+ _context.next = 8;
97
+ break;
98
+ }
99
+ throw new Error('There was an issue with the Babel transform.');
100
+ case 8:
101
+ fixed = transformed.code.replace(/\/\* ___NEWLINE___ \*\//g, '\n'); // If the user has *explicitly* passed `false` here, it means they do not want us to run Prettier
102
+ // at all, so we bail here.
103
+ if (!(prettierConfig === false)) {
104
+ _context.next = 11;
105
+ break;
106
+ }
107
+ return _context.abrupt("return", fixed);
108
+ case 11:
109
+ standardPrettierOptions = {
110
+ parser: 'babel',
111
+ singleQuote: true,
112
+ plugins: [prettierPluginEstree, parserBabel]
113
+ }; // If `prettierConfig` is *explicitly* true (as opposed to truthy), it means the user has opted in
114
+ // to default behavior either explicitly or implicitly. Either way, we run basic Prettier on it.
115
+ if (!(prettierConfig === true)) {
116
+ _context.next = 14;
117
+ break;
118
+ }
119
+ return _context.abrupt("return", prettier.format(fixed, standardPrettierOptions));
120
+ case 14:
121
+ // If we've made it here, the user has passed their own Prettier options so we merge it with ours
122
+ // and let theirs overwrite any of the default settings.
123
+ mergedPrettierOptions = _objectSpread(_objectSpread(_objectSpread({}, standardPrettierOptions), prettierConfig), {}, {
124
+ plugins: standardPrettierOptions.plugins
125
+ });
126
+ return _context.abrupt("return", prettier.format(fixed, mergedPrettierOptions));
127
+ case 16:
128
+ case "end":
129
+ return _context.stop();
130
+ }
131
+ }, _callee);
132
+ }));
133
+ return _removeTypes.apply(this, arguments);
134
+ }
@@ -0,0 +1,3 @@
1
+ import type { SourceTransformer, TransformSource } from "../CodeHighlighter/index.js";
2
+ export declare const transformTsToJs: TransformSource;
3
+ export declare const TsToJsTransformer: SourceTransformer;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformTsToJs.d.ts","sourceRoot":"","sources":["../../../src/transformTsToJs/transformTsToJs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE7E,eAAO,MAAM,eAAe,EAAE,eAO7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,iBAG/B,CAAC"}
@@ -0,0 +1,34 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import { removeTypes } from "./removeTypes.js";
4
+ export var transformTsToJs = /*#__PURE__*/function () {
5
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(source, fileName) {
6
+ var transformed, transformedFileName;
7
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
8
+ while (1) switch (_context.prev = _context.next) {
9
+ case 0:
10
+ _context.next = 2;
11
+ return removeTypes(source, fileName);
12
+ case 2:
13
+ transformed = _context.sent;
14
+ transformedFileName = fileName.replace(/\.ts$/, '.js').replace(/\.tsx$/, '.jsx');
15
+ return _context.abrupt("return", {
16
+ js: {
17
+ source: transformed,
18
+ fileName: transformedFileName
19
+ }
20
+ });
21
+ case 5:
22
+ case "end":
23
+ return _context.stop();
24
+ }
25
+ }, _callee);
26
+ }));
27
+ return function transformTsToJs(_x, _x2) {
28
+ return _ref.apply(this, arguments);
29
+ };
30
+ }();
31
+ export var TsToJsTransformer = {
32
+ extensions: ['ts', 'tsx'],
33
+ transformer: transformTsToJs
34
+ };
@@ -0,0 +1 @@
1
+ export * from "./useCode.js";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/useCode/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}