@rspress/core 2.0.0-rc.1 → 2.0.0-rc.3

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 (307) hide show
  1. package/bin/rspress.js +1 -1
  2. package/dist/0~7675.723d12b2.js +1794 -0
  3. package/dist/3521.56e42d70.js +56 -0
  4. package/dist/4669.12208c6a.js +2 -0
  5. package/dist/5485.077f14ff.js +98 -0
  6. package/dist/6289.c67fe0d5.js +5 -0
  7. package/dist/8813.9da1f210.js +2 -0
  8. package/dist/9643.f109822d.js +5 -0
  9. package/dist/_private/react/render.js +17 -4
  10. package/dist/cli/config/index.js +4 -0
  11. package/dist/cli/config/loadConfigFile.js +30 -0
  12. package/dist/cli/index.cb89dbd1.js +3 -0
  13. package/dist/cli/index.js +122 -0
  14. package/dist/eject-theme/components/Badge/index.scss +1 -0
  15. package/dist/eject-theme/components/Banner/index.tsx +6 -5
  16. package/dist/eject-theme/components/Callout/index.scss +0 -2
  17. package/dist/eject-theme/components/Callout/index.tsx +8 -2
  18. package/dist/eject-theme/components/CodeBlock/index.scss +12 -18
  19. package/dist/eject-theme/components/CodeBlock/index.tsx +10 -1
  20. package/dist/eject-theme/components/CodeBlockRuntime/index.tsx +50 -11
  21. package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.tsx +1 -3
  22. package/dist/eject-theme/components/CodeButtonGroup/index.scss +5 -1
  23. package/dist/eject-theme/components/CodeButtonGroup/index.tsx +1 -3
  24. package/dist/eject-theme/components/DocContent/doc.scss +27 -7
  25. package/dist/eject-theme/components/DocContent/docComponents/pre.tsx +2 -1
  26. package/dist/eject-theme/components/DocContent/docComponents/table.tsx +10 -4
  27. package/dist/eject-theme/components/DocContent/index.tsx +21 -4
  28. package/dist/eject-theme/components/DocFooter/index.tsx +1 -6
  29. package/dist/eject-theme/components/{DocContent/FallbackHeading.tsx → FallbackHeading/index.tsx} +20 -11
  30. package/dist/eject-theme/components/HoverGroup/index.scss +1 -1
  31. package/dist/eject-theme/components/LastUpdated/index.tsx +8 -1
  32. package/dist/eject-theme/components/Link/index.tsx +22 -6
  33. package/dist/eject-theme/components/Nav/NavMenu.tsx +2 -3
  34. package/dist/eject-theme/components/NavHamburger/index.tsx +3 -4
  35. package/dist/eject-theme/components/NavScreen/NavScreenLangs.scss +6 -0
  36. package/dist/eject-theme/components/NavScreen/NavScreenLangs.tsx +23 -9
  37. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +2 -3
  38. package/dist/eject-theme/components/NavScreen/NavScreenVersions.scss +6 -0
  39. package/dist/eject-theme/components/NavScreen/NavScreenVersions.tsx +22 -9
  40. package/dist/eject-theme/components/Overview/index.tsx +7 -8
  41. package/dist/eject-theme/components/{Overview/OverviewGroup.scss → OverviewGroup/index.scss} +66 -12
  42. package/dist/eject-theme/components/{Overview/OverviewGroup.tsx → OverviewGroup/index.tsx} +51 -5
  43. package/dist/eject-theme/components/PackageManagerTabs/index.tsx +12 -0
  44. package/dist/eject-theme/components/PrevNextPage/index.tsx +6 -3
  45. package/dist/eject-theme/components/Root/index.tsx +58 -0
  46. package/dist/eject-theme/components/Search/NoSearchResult.tsx +2 -3
  47. package/dist/eject-theme/components/Search/SearchButton.tsx +3 -4
  48. package/dist/eject-theme/components/Search/SearchPanel.tsx +12 -7
  49. package/dist/eject-theme/components/Search/SuggestItem.tsx +15 -12
  50. package/dist/eject-theme/components/Search/logic/util.test.ts +1 -1
  51. package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +2 -3
  52. package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +1 -0
  53. package/dist/eject-theme/components/SidebarMenu/index.tsx +4 -4
  54. package/dist/eject-theme/components/SocialLinks/index.tsx +2 -3
  55. package/dist/eject-theme/components/SourceCode/index.tsx +6 -4
  56. package/dist/eject-theme/components/SwitchAppearance/index.tsx +3 -5
  57. package/dist/eject-theme/components/Tabs/index.scss +31 -26
  58. package/dist/eject-theme/components/Tabs/index.tsx +16 -0
  59. package/dist/eject-theme/components/Tag/index.tsx +84 -5
  60. package/dist/eject-theme/components/Toc/TocItem.scss +3 -3
  61. package/dist/eject-theme/components/Toc/TocItem.tsx +1 -0
  62. package/dist/index.d.ts +6 -6
  63. package/dist/index.js +16 -3134
  64. package/dist/node/PluginDriver.d.ts +1 -1
  65. package/dist/node/PluginDriver.js +142 -0
  66. package/dist/node/auto-nav-sidebar/index.js +44 -0
  67. package/dist/node/auto-nav-sidebar/locales.js +26 -0
  68. package/dist/node/auto-nav-sidebar/normalize.js +230 -0
  69. package/dist/node/auto-nav-sidebar/utils.js +68 -0
  70. package/dist/node/auto-nav-sidebar/walk.js +67 -0
  71. package/dist/node/build.js +31 -0
  72. package/dist/node/constants.d.ts +2 -0
  73. package/dist/node/constants.js +34 -0
  74. package/dist/node/dev.js +32 -0
  75. package/dist/node/eject.js +111 -0
  76. package/dist/node/index.d.ts +5 -5
  77. package/dist/node/initRsbuild.d.ts +2 -2
  78. package/dist/node/initRsbuild.js +346 -0
  79. package/dist/node/last-updated/index.js +28 -0
  80. package/dist/node/logger/hint.d.ts +1 -1
  81. package/dist/node/logger/hint.js +85 -0
  82. package/dist/node/mdx/loader.d.ts +1 -1
  83. package/dist/node/mdx/loader.e1578c62.js +13 -0
  84. package/dist/{loader.js → node/mdx/loader.js} +4 -3
  85. package/dist/node/mdx/options.d.ts +2 -2
  86. package/dist/node/mdx/options.js +103 -0
  87. package/dist/node/mdx/processor.d.ts +2 -2
  88. package/dist/node/mdx/processor.js +71 -0
  89. package/dist/node/mdx/rehypePlugins/codeMeta.js +10 -0
  90. package/dist/node/mdx/rehypePlugins/headerAnchor.js +53 -0
  91. package/dist/node/mdx/rehypePlugins/shiki.js +34 -0
  92. package/dist/node/mdx/rehypePlugins/transformers/add-lang.js +15 -0
  93. package/dist/node/mdx/rehypePlugins/transformers/add-line-numbers.js +22 -0
  94. package/dist/node/mdx/rehypePlugins/transformers/add-title.js +24 -0
  95. package/dist/node/mdx/rehypePlugins/transformers/add-wrap-code.js +22 -0
  96. package/dist/node/mdx/rehypePlugins/transformers/index.d.ts +5 -5
  97. package/dist/node/mdx/rehypePlugins/transformers/index.js +5 -0
  98. package/dist/node/mdx/rehypePlugins/transformers/meta-highlight.js +41 -0
  99. package/dist/node/mdx/remarkPlugins/builtin.js +11 -0
  100. package/dist/node/mdx/remarkPlugins/containerSyntax.js +190 -0
  101. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +66 -0
  102. package/dist/node/mdx/remarkPlugins/image.js +67 -0
  103. package/dist/node/mdx/remarkPlugins/link.d.ts +1 -1
  104. package/dist/node/mdx/remarkPlugins/link.js +99 -0
  105. package/dist/node/mdx/remarkPlugins/toc.js +50 -0
  106. package/dist/node/mdx/types.d.ts +3 -3
  107. package/dist/node/medium-zoom/index.d.ts +1 -1
  108. package/dist/node/medium-zoom/index.js +14 -0
  109. package/dist/node/route/RoutePage.d.ts +1 -1
  110. package/dist/node/route/RoutePage.js +61 -0
  111. package/dist/node/route/RouteService.d.ts +1 -1
  112. package/dist/node/route/RouteService.js +177 -0
  113. package/dist/node/route/extractPageData.d.ts +1 -1
  114. package/dist/node/route/extractPageData.js +112 -0
  115. package/dist/node/route/normalizeRoutePath.js +54 -0
  116. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +21 -0
  117. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +150 -0
  118. package/dist/node/runtimeModule/globalStyles.d.ts +1 -1
  119. package/dist/node/runtimeModule/globalStyles.js +12 -0
  120. package/dist/node/runtimeModule/globalUIComponents.d.ts +1 -1
  121. package/dist/node/runtimeModule/globalUIComponents.js +25 -0
  122. package/dist/node/runtimeModule/i18n.d.ts +2 -2
  123. package/dist/node/runtimeModule/i18n.js +83 -0
  124. package/dist/node/runtimeModule/pageData/createPageData.d.ts +1 -1
  125. package/dist/node/runtimeModule/pageData/createPageData.js +64 -0
  126. package/dist/node/runtimeModule/pageData/rsbuildPlugin.d.ts +1 -1
  127. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +51 -0
  128. package/dist/node/runtimeModule/routeList.d.ts +1 -1
  129. package/dist/node/runtimeModule/routeList.js +7 -0
  130. package/dist/node/runtimeModule/searchHooks.d.ts +1 -1
  131. package/dist/node/runtimeModule/searchHooks.js +11 -0
  132. package/dist/node/runtimeModule/siteData/createSiteData.js +34 -0
  133. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +94 -0
  134. package/dist/node/runtimeModule/siteData/rsbuildPlugin.d.ts +1 -1
  135. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +24 -0
  136. package/dist/node/runtimeModule/socialLinks.d.ts +1 -1
  137. package/dist/node/runtimeModule/socialLinks.js +8 -0
  138. package/dist/node/runtimeModule/types.d.ts +2 -2
  139. package/dist/node/serve.js +23 -0
  140. package/dist/node/ssg/renderHtmlTemplate.js +33 -0
  141. package/dist/node/ssg/renderPage.js +34 -0
  142. package/dist/node/ssg/renderPageWorker.474f9f73.js +2 -0
  143. package/dist/node/ssg/renderPageWorker.js +15 -0
  144. package/dist/node/ssg/renderPages.d.ts +1 -1
  145. package/dist/node/ssg/renderPages.js +105 -0
  146. package/dist/node/ssg/renderPages.js.LICENSE.txt +4 -0
  147. package/dist/node/ssg/rsbuildPluginCSR.d.ts +1 -1
  148. package/dist/node/ssg/rsbuildPluginCSR.js +27 -0
  149. package/dist/node/ssg/rsbuildPluginSSG.d.ts +1 -1
  150. package/dist/node/ssg/rsbuildPluginSSG.js +72 -0
  151. package/dist/node/ssg/ssgEnv.js +33 -0
  152. package/dist/node/ssg/ssgEnv.js.LICENSE.txt +5 -0
  153. package/dist/node/ssg-md/llms/emitLlmsTxt.d.ts +1 -1
  154. package/dist/node/ssg-md/llms/emitLlmsTxt.js +84 -0
  155. package/dist/node/ssg-md/llms/llmsTxt.d.ts +1 -1
  156. package/dist/node/ssg-md/llms/llmsTxt.js +66 -0
  157. package/dist/node/ssg-md/react/index.d.ts +1 -1
  158. package/dist/node/ssg-md/remarkSplitMdx.js +244 -0
  159. package/dist/node/ssg-md/renderPage.js +31 -0
  160. package/dist/node/ssg-md/renderPages.d.ts +1 -1
  161. package/dist/node/ssg-md/renderPages.js +27 -0
  162. package/dist/node/ssg-md/rsbuildPluginSSGMD.d.ts +1 -1
  163. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +47 -0
  164. package/dist/node/utils/applyReplaceRules.js +6 -0
  165. package/dist/node/utils/checkLanguageParity.js +77 -0
  166. package/dist/node/utils/createHash.js +5 -0
  167. package/dist/node/utils/error.d.ts +9 -0
  168. package/dist/node/utils/error.js +10 -0
  169. package/dist/node/utils/escapeHeadingIds.js +5 -0
  170. package/dist/node/utils/flattenMdxContent.js +74 -0
  171. package/dist/node/utils/fs.js +14 -0
  172. package/dist/node/utils/getImportAstNode.js +63 -0
  173. package/dist/node/utils/getPageKey.js +6 -0
  174. package/dist/node/utils/getSocialIcons.js +32 -0
  175. package/dist/node/utils/index.d.ts +10 -9
  176. package/dist/node/utils/normalizePath.js +10 -0
  177. package/dist/node/utils/reactAlias.d.ts +2 -0
  178. package/dist/node/utils/reactAlias.js +83 -0
  179. package/dist/rslib-runtime.99091bf6.js +18 -0
  180. package/dist/runtime/App.js +2 -2
  181. package/dist/runtime/ClientApp.d.ts +1 -1
  182. package/dist/runtime/ClientApp.js +0 -4
  183. package/dist/runtime/initPageData.js +1 -1
  184. package/dist/runtime/ssrMdServerEntry.js +1 -1
  185. package/dist/runtime/ssrServerEntry.js +2 -1
  186. package/dist/runtime.72d450ac.js +1 -0
  187. package/dist/runtime.js +3 -2
  188. package/dist/shiki-transformers.d.ts +1 -1
  189. package/dist/shiki-transformers.js +6 -120
  190. package/dist/theme/assets/deprecated.js +18 -0
  191. package/dist/theme/assets/experimental.js +21 -0
  192. package/dist/theme/components/Badge/index.css +1 -0
  193. package/dist/theme/components/Banner/index.d.ts +1 -1
  194. package/dist/theme/components/Banner/index.js +4 -5
  195. package/dist/theme/components/Callout/index.css +0 -2
  196. package/dist/theme/components/Callout/index.js +5 -2
  197. package/dist/theme/components/CodeBlock/index.css +11 -21
  198. package/dist/theme/components/CodeBlock/index.js +5 -1
  199. package/dist/theme/components/CodeBlockRuntime/index.d.ts +1 -1
  200. package/dist/theme/components/CodeBlockRuntime/index.js +38 -8
  201. package/dist/theme/components/CodeButtonGroup/CopyCodeButton.js +3 -5
  202. package/dist/theme/components/CodeButtonGroup/index.css +5 -1
  203. package/dist/theme/components/CodeButtonGroup/index.js +3 -5
  204. package/dist/theme/components/DocContent/doc.css +28 -7
  205. package/dist/theme/components/DocContent/docComponents/index.d.ts +3 -3
  206. package/dist/theme/components/DocContent/docComponents/pre.js +3 -1
  207. package/dist/theme/components/DocContent/docComponents/table.d.ts +2 -2
  208. package/dist/theme/components/DocContent/docComponents/table.js +8 -3
  209. package/dist/theme/components/DocContent/index.d.ts +11 -2
  210. package/dist/theme/components/DocContent/index.js +6 -6
  211. package/dist/theme/components/DocFooter/index.js +1 -5
  212. package/dist/theme/components/{DocContent/FallbackHeading.js → FallbackHeading/index.js} +19 -11
  213. package/dist/theme/components/HoverGroup/index.css +3 -3
  214. package/dist/theme/components/HoverGroup/useHoverGroup.d.ts +1 -1
  215. package/dist/theme/components/LastUpdated/index.d.ts +1 -1
  216. package/dist/theme/components/LastUpdated/index.js +5 -1
  217. package/dist/theme/components/Link/index.d.ts +1 -1
  218. package/dist/theme/components/Link/index.js +17 -7
  219. package/dist/theme/components/Nav/NavMenu.js +2 -3
  220. package/dist/theme/components/NavHamburger/index.js +3 -4
  221. package/dist/theme/components/NavScreen/NavScreenLangs.css +6 -0
  222. package/dist/theme/components/NavScreen/NavScreenLangs.js +13 -3
  223. package/dist/theme/components/NavScreen/NavScreenMenuItem.js +2 -3
  224. package/dist/theme/components/NavScreen/NavScreenVersions.css +6 -0
  225. package/dist/theme/components/NavScreen/NavScreenVersions.js +12 -3
  226. package/dist/theme/components/Overview/index.d.ts +0 -1
  227. package/dist/theme/components/Overview/index.js +2 -3
  228. package/dist/theme/components/{Overview/OverviewGroup.css → OverviewGroup/index.css} +60 -8
  229. package/dist/theme/components/{Overview/OverviewGroup.d.ts → OverviewGroup/index.d.ts} +1 -1
  230. package/dist/theme/components/OverviewGroup/index.js +88 -0
  231. package/dist/theme/components/PackageManagerTabs/index.d.ts +1 -1
  232. package/dist/theme/components/PackageManagerTabs/index.js +4 -0
  233. package/dist/theme/components/PrevNextPage/index.js +3 -4
  234. package/dist/theme/components/Root/index.d.ts +54 -0
  235. package/dist/theme/components/Root/index.js +7 -0
  236. package/dist/theme/components/Search/NoSearchResult.js +2 -3
  237. package/dist/theme/components/Search/SearchButton.js +3 -4
  238. package/dist/theme/components/Search/SearchPanel.js +12 -15
  239. package/dist/theme/components/Search/SuggestItem.d.ts +1 -1
  240. package/dist/theme/components/Search/SuggestItem.js +7 -11
  241. package/dist/theme/components/Search/logic/Provider.d.ts +1 -1
  242. package/dist/theme/components/Search/logic/providers/LocalProvider.d.ts +2 -2
  243. package/dist/theme/components/Search/logic/search.d.ts +1 -1
  244. package/dist/theme/components/Search/logic/util.test.js +1 -1
  245. package/dist/theme/components/Sidebar/SidebarGroup.js +2 -3
  246. package/dist/theme/components/Sidebar/SidebarItem.js +1 -0
  247. package/dist/theme/components/SidebarMenu/index.js +3 -5
  248. package/dist/theme/components/SocialLinks/index.js +2 -3
  249. package/dist/theme/components/SourceCode/index.js +2 -4
  250. package/dist/theme/components/SwitchAppearance/index.js +3 -5
  251. package/dist/theme/components/Tabs/index.css +19 -27
  252. package/dist/theme/components/Tabs/index.js +9 -0
  253. package/dist/theme/components/Tag/index.d.ts +3 -0
  254. package/dist/theme/components/Tag/index.js +63 -8
  255. package/dist/theme/components/Toc/TocItem.css +2 -3
  256. package/dist/theme/components/Toc/TocItem.js +1 -0
  257. package/dist/theme/hooks/useActiveAnchor.js +1 -1
  258. package/dist/theme/icons.d.ts +27 -0
  259. package/dist/theme/icons.js +51 -0
  260. package/dist/theme/index.d.ts +64 -59
  261. package/dist/theme/index.js +7 -2
  262. package/dist/theme/layout/DocLayout/index.css +2 -4
  263. package/dist/theme/layout/Layout/index.js +1 -2
  264. package/dist/theme/layout/NotFountLayout/index.js +1 -1
  265. package/dist/theme/logic/useAppearance.js +1 -1
  266. package/dist/theme/logic/useFullTextSearch.d.ts +1 -1
  267. package/dist/theme/logic/useMediaQuery.js +1 -1
  268. package/dist/theme/styles/base.css +1 -0
  269. package/dist/theme/styles/scrollbar.css +1 -0
  270. package/dist/theme/styles/shiki.css +9 -3
  271. package/dist/theme/styles/vars/base-vars.css +7 -5
  272. package/dist/theme/styles/vars/code-vars.css +2 -0
  273. package/dist/theme/styles/vars/home-vars.css +2 -1
  274. package/package.json +22 -23
  275. package/dist/3~128.js +0 -74
  276. package/dist/3~517.js +0 -1786
  277. package/dist/3~894.js +0 -26
  278. package/dist/cli.js +0 -259
  279. package/dist/index.js.LICENSE.txt +0 -10
  280. package/dist/node/auto-nav-sidebar/fixtures/docs/guide/c.d.ts +0 -2
  281. package/dist/node/auto-nav-sidebar/fixtures/docs-locales/en/guide/c.d.ts +0 -2
  282. package/dist/node/auto-nav-sidebar/fixtures/docs-locales/zh/guide/c.d.ts +0 -2
  283. package/dist/node/auto-nav-sidebar/locales.test.d.ts +0 -1
  284. package/dist/node/auto-nav-sidebar/walk.test.d.ts +0 -1
  285. package/dist/node/mdx/rehypePlugins/headerAnchor.test.d.ts +0 -1
  286. package/dist/node/mdx/remarkPlugins/containerSyntax.test.d.ts +0 -1
  287. package/dist/node/mdx/remarkPlugins/fileCodeBlock.test.d.ts +0 -1
  288. package/dist/node/mdx/remarkPlugins/image.test.d.ts +0 -1
  289. package/dist/node/mdx/remarkPlugins/link.test.d.ts +0 -1
  290. package/dist/node/route/RouteService.test.d.ts +0 -1
  291. package/dist/node/route/extractPageData.test.d.ts +0 -1
  292. package/dist/node/route/fixtures/basic/guide/c.d.ts +0 -2
  293. package/dist/node/route/normalizeRoutePath.test.d.ts +0 -1
  294. package/dist/node/runtimeModule/i18n.test.d.ts +0 -1
  295. package/dist/node/ssg-md/remarkSplitMdx.test.d.ts +0 -4
  296. package/dist/node/utils/checkLanguageParity.test.d.ts +0 -1
  297. package/dist/node/utils/detectCustomIcon.d.ts +0 -1
  298. package/dist/node/utils/detectReactVersion.d.ts +0 -3
  299. package/dist/processor.js +0 -4539
  300. package/dist/renderPageWorker.js +0 -196
  301. package/dist/theme/components/Overview/OverviewGroup.js +0 -58
  302. package/dist/theme/components/Search/logic/util.test.d.ts +0 -1
  303. /package/dist/cli/{config.d.ts → config/index.d.ts} +0 -0
  304. /package/dist/eject-theme/components/{Overview → OverviewGroup}/icons/plugin.svg +0 -0
  305. /package/dist/{shiki-transformers.js.LICENSE.txt → node/mdx/rehypePlugins/transformers/meta-highlight.js.LICENSE.txt} +0 -0
  306. /package/dist/theme/components/{DocContent/FallbackHeading.d.ts → FallbackHeading/index.d.ts} +0 -0
  307. /package/dist/theme/components/{Overview → OverviewGroup}/icons/plugin.js +0 -0
@@ -0,0 +1,66 @@
1
+ import { node_path, logger, picocolors, readFile } from "../../../6289.c67fe0d5.js";
2
+ import { cwd } from "../../../9643.f109822d.js";
3
+ import { visit } from "../../../8813.9da1f210.js";
4
+ import { createError } from "../../utils/error.js";
5
+ const ERROR_PREFIX = '[remarkFileCodeBlock]';
6
+ function parseFileFromMeta(meta) {
7
+ if (!meta) return '';
8
+ const kvList = meta.split(' ').filter(Boolean);
9
+ for (const item of kvList){
10
+ const [k, v = ''] = item.split('=');
11
+ if ('file' === k && v.length > 0) return v.replace(/["'`]/g, '');
12
+ }
13
+ return '';
14
+ }
15
+ const remarkFileCodeBlock = ({ filepath, addDependency })=>async (tree)=>{
16
+ const promiseList = [];
17
+ visit(tree, 'code', (node)=>{
18
+ const { meta, value, lang } = node;
19
+ const file = parseFileFromMeta(meta ?? '');
20
+ if (!file) return;
21
+ const originalMetaForErrorInfo = picocolors.cyan(`\`\`\`${lang} ${meta}`);
22
+ if (file.startsWith('./') || file.startsWith('../') || file.startsWith('<root>/')) {
23
+ let resolvedFilePath;
24
+ resolvedFilePath = file.startsWith('<root>/') ? node_path.join(cwd(), file.slice(7)) : node_path.join(node_path.dirname(filepath), file);
25
+ if ('' !== value.trim()) {
26
+ logger.error(`${ERROR_PREFIX} ${originalMetaForErrorInfo} The content of file code block should be empty.
27
+
28
+ \`\`\`tsx file="./filename"
29
+ content
30
+ \`\`\`
31
+
32
+ this usage is not allowed, please use below:
33
+
34
+ \`\`\`tsx file="./filename"
35
+ \`\`\`
36
+ `);
37
+ throw createError(`${ERROR_PREFIX} ${originalMetaForErrorInfo} The content of file code block should be empty.`);
38
+ }
39
+ const promise = readFile(resolvedFilePath, 'utf-8').then((fileContent)=>{
40
+ addDependency?.(resolvedFilePath);
41
+ node.value = fileContent;
42
+ }).catch((e)=>{
43
+ const message = `${ERROR_PREFIX} ${originalMetaForErrorInfo} introduces another file in "${resolvedFilePath}", but the file does not exist.`;
44
+ logger.error(message);
45
+ e.message = `${message}\n${e.message}`;
46
+ throw e;
47
+ });
48
+ promiseList.push(promise);
49
+ return;
50
+ }
51
+ logger.error(`${ERROR_PREFIX} ${originalMetaForErrorInfo} syntax error of file code block:
52
+ Please use below:
53
+
54
+ \`\`\`tsx file="./filename"
55
+ \`\`\`
56
+
57
+ or
58
+
59
+ \`\`\`tsx file="<root>/path/to/filename"
60
+ \`\`\`
61
+ `);
62
+ throw createError(`${ERROR_PREFIX} ${originalMetaForErrorInfo} syntax error of file code block`);
63
+ });
64
+ await Promise.all(promiseList);
65
+ };
66
+ export { remarkFileCodeBlock };
@@ -0,0 +1,67 @@
1
+ import { isExternalUrl } from "../../../4669.12208c6a.js";
2
+ import { getNodeAttribute } from "../../../9643.f109822d.js";
3
+ import { visit } from "../../../8813.9da1f210.js";
4
+ import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
5
+ const normalizeImageUrl = (imageUrl)=>{
6
+ if (isExternalUrl(imageUrl) || imageUrl.startsWith('/')) return '';
7
+ return imageUrl;
8
+ };
9
+ const remarkImage = ()=>(tree, _file)=>{
10
+ const images = [];
11
+ const getMdxSrcAttribute = (tempVar)=>({
12
+ type: 'mdxJsxAttribute',
13
+ name: 'src',
14
+ value: {
15
+ type: 'mdxJsxAttributeValueExpression',
16
+ value: tempVar,
17
+ data: {
18
+ estree: {
19
+ type: 'Program',
20
+ sourceType: 'module',
21
+ body: [
22
+ {
23
+ type: 'ExpressionStatement',
24
+ expression: {
25
+ type: 'Identifier',
26
+ name: tempVar
27
+ }
28
+ }
29
+ ]
30
+ }
31
+ }
32
+ }
33
+ });
34
+ visit(tree, 'image', (node)=>{
35
+ const { alt, url } = node;
36
+ if (!url) return;
37
+ const imagePath = normalizeImageUrl(url);
38
+ if (!imagePath) return;
39
+ const tempVariableName = `image${images.length}`;
40
+ Object.assign(node, {
41
+ type: 'mdxJsxFlowElement',
42
+ name: 'img',
43
+ children: [],
44
+ attributes: [
45
+ alt && {
46
+ type: 'mdxJsxAttribute',
47
+ name: 'alt',
48
+ value: alt
49
+ },
50
+ getMdxSrcAttribute(tempVariableName)
51
+ ].filter(Boolean)
52
+ });
53
+ images.push(getDefaultImportAstNode(tempVariableName, imagePath));
54
+ });
55
+ visit(tree, (node)=>{
56
+ if ('mdxJsxFlowElement' !== node.type && 'mdxJsxTextElement' !== node.type || 'img' !== node.name) return;
57
+ const srcAttr = getNodeAttribute(node, 'src', true);
58
+ if ('string' != typeof srcAttr?.value) return;
59
+ const imagePath = normalizeImageUrl(srcAttr.value);
60
+ if (!imagePath) return;
61
+ const tempVariableName = `image${images.length}`;
62
+ Object.assign(srcAttr, getMdxSrcAttribute(tempVariableName));
63
+ images.push(getDefaultImportAstNode(tempVariableName, imagePath));
64
+ });
65
+ tree.children.unshift(...images);
66
+ };
67
+ export { remarkImage };
@@ -1,7 +1,7 @@
1
1
  import { type MarkdownOptions } from '@rspress/shared';
2
2
  import type { Root } from 'mdast';
3
3
  import type { VFile } from 'vfile';
4
- import type { RouteService } from '../../route/RouteService';
4
+ import type { RouteService } from '../../route/RouteService.js';
5
5
  /**
6
6
  * Remark plugin to normalize a link href
7
7
  * 1. add version and lang prefix to the link
@@ -0,0 +1,99 @@
1
+ import { node_path, logger, picocolors } from "../../../6289.c67fe0d5.js";
2
+ import { isExternalUrl, isProduction, addLeadingSlash, parseUrl, normalizeHref, withBase } from "../../../4669.12208c6a.js";
3
+ import { visit } from "../../../8813.9da1f210.js";
4
+ import { hintRelativeMarkdownLink } from "../../logger/hint.js";
5
+ import { createError } from "../../utils/error.js";
6
+ function link_checkDeadLinks(checkDeadLinks, internalLinks, file, lint) {
7
+ const errorInfos = [];
8
+ const excludes = 'object' == typeof checkDeadLinks ? checkDeadLinks.excludes : void 0;
9
+ const excludesUrl = Array.isArray(excludes) ? new Set(excludes) : void 0;
10
+ const excludesFn = 'function' == typeof excludes ? excludes : void 0;
11
+ let possibleBreakingChange = false;
12
+ [
13
+ ...internalLinks.entries()
14
+ ].forEach(([nodeUrl, link])=>{
15
+ if (excludesUrl?.has(nodeUrl)) return;
16
+ if (excludesFn?.(nodeUrl)) return;
17
+ if (!nodeUrl.startsWith('/') && /^\w/.test(nodeUrl)) possibleBreakingChange = true;
18
+ errorInfos.push([
19
+ nodeUrl,
20
+ link
21
+ ]);
22
+ });
23
+ if (errorInfos.length > 0) {
24
+ if (possibleBreakingChange) hintRelativeMarkdownLink();
25
+ const message = `Dead links found${lint ? '' : ` in ${picocolors.cyan(file.path)}`}:
26
+ ${errorInfos.map(([nodeUrl, link])=>` ${picocolors.green(`"[..](${nodeUrl})"`)} ${picocolors.gray(link)}`).join('\n')}`;
27
+ if (lint) file.message(message);
28
+ else {
29
+ logger.error(message);
30
+ if (isProduction()) throw createError('Dead link found');
31
+ }
32
+ }
33
+ }
34
+ function looseMarkdownLink(url, routeService, filePath) {
35
+ if (!routeService.isInDocsDir(filePath)) return url;
36
+ const [versionPart, langPart, pureRoute] = routeService.splitRoutePathParts(url);
37
+ const relativePath = routeService.absolutePathToRelativePath(filePath);
38
+ const [versionPartCurrFile, langPartCurrFile] = routeService.getRoutePathParts(relativePath);
39
+ if ('' === versionPart) {
40
+ if ('' === langPart) return addLeadingSlash(`${[
41
+ versionPartCurrFile,
42
+ langPartCurrFile
43
+ ].filter(Boolean).join('/')}${addLeadingSlash(pureRoute.replace(/^\/*/, ''))}`);
44
+ return addLeadingSlash(`${[
45
+ versionPartCurrFile,
46
+ langPart
47
+ ].filter(Boolean).join('/')}${addLeadingSlash(pureRoute.replace(/^\/*/, ''))}`);
48
+ }
49
+ return url;
50
+ }
51
+ function normalizeLink(nodeUrl, routeService, filePath, cleanUrls, autoPrefix, deadLinks, __base) {
52
+ if (!nodeUrl) return '';
53
+ if (nodeUrl.startsWith('#')) return nodeUrl;
54
+ if (isExternalUrl(nodeUrl)) return nodeUrl;
55
+ if (!routeService) return nodeUrl;
56
+ let { url, hash, search } = parseUrl(nodeUrl);
57
+ if (url.startsWith('/')) {
58
+ if (autoPrefix) url = looseMarkdownLink(url, routeService, filePath);
59
+ const { routePath } = routeService.normalizeRoutePath(url);
60
+ url = routePath;
61
+ } else {
62
+ const anotherFileAbsolutePath = node_path.join(node_path.dirname(filePath), url);
63
+ url = routeService.absolutePathToRoutePath(anotherFileAbsolutePath);
64
+ }
65
+ if ('boolean' == typeof cleanUrls) {
66
+ url = normalizeHref(url, cleanUrls);
67
+ if (!routeService.isExistRoute(url)) {
68
+ deadLinks.set(nodeUrl, url);
69
+ return nodeUrl;
70
+ }
71
+ } else {
72
+ url = normalizeHref(url, false);
73
+ if (!routeService.isExistRoute(url)) {
74
+ deadLinks.set(nodeUrl, url);
75
+ return nodeUrl;
76
+ }
77
+ url = url.replace(/\.html$/, cleanUrls);
78
+ }
79
+ if (search) url += `?${search}`;
80
+ if (hash) url += `#${hash}`;
81
+ if (__base) url = withBase(url, __base);
82
+ return url;
83
+ }
84
+ const remarkLink = ({ cleanUrls, routeService, remarkLinkOptions, lint, __base })=>(tree, file)=>{
85
+ const { checkDeadLinks: shouldCheckDeadLinks = true, autoPrefix = true } = remarkLinkOptions ?? {};
86
+ const deadLinks = new Map();
87
+ visit(tree, 'link', (node)=>{
88
+ const { url: nodeUrl } = node;
89
+ const link = normalizeLink(nodeUrl, routeService, file.path, cleanUrls, autoPrefix, deadLinks, __base);
90
+ node.url = link;
91
+ });
92
+ visit(tree, 'definition', (node)=>{
93
+ const { url: nodeUrl } = node;
94
+ const link = normalizeLink(nodeUrl, routeService, file.path, cleanUrls, autoPrefix, deadLinks, __base);
95
+ node.url = link;
96
+ });
97
+ if (shouldCheckDeadLinks && routeService) link_checkDeadLinks(shouldCheckDeadLinks, deadLinks, file, lint);
98
+ };
99
+ export { remarkLink };
@@ -0,0 +1,50 @@
1
+ import { extractTextAndId } from "../../../9643.f109822d.js";
2
+ import { github_slugger, visitChildren } from "../loader.e1578c62.js";
3
+ const parseToc = (tree)=>{
4
+ let title = '';
5
+ const toc = [];
6
+ const slugger = new github_slugger();
7
+ visitChildren((node)=>{
8
+ if ('heading' !== node.type || !node.depth || !node.children) return;
9
+ if (node.depth >= 1 && node.depth < 5) {
10
+ let customId = '';
11
+ const text = node.children.map((child)=>{
12
+ if ('link' === child.type) return child.children?.map((item)=>item.value).join('');
13
+ if ('strong' === child.type) return `**${child.children?.map((item)=>item.value).join('')}**`;
14
+ if ('emphasis' === child.type) return `*${child.children?.map((item)=>item.value).join('')}*`;
15
+ if ('delete' === child.type) return `~~${child.children?.map((item)=>item.value).join('')}~~`;
16
+ if ('text' === child.type) {
17
+ const [textPart, idPart] = extractTextAndId(child.value);
18
+ customId = idPart;
19
+ return textPart;
20
+ }
21
+ if ('inlineCode' === child.type) return `\`${child.value}\``;
22
+ return '';
23
+ }).join('');
24
+ if (1 === node.depth) {
25
+ if (!title) title = text;
26
+ } else {
27
+ const id = customId ? customId : slugger.slug(text.trim());
28
+ const { depth } = node;
29
+ toc.push({
30
+ id,
31
+ text,
32
+ depth
33
+ });
34
+ }
35
+ }
36
+ })(tree);
37
+ return {
38
+ title,
39
+ toc
40
+ };
41
+ };
42
+ const remarkToc = function() {
43
+ const data = this.data();
44
+ return (tree)=>{
45
+ const { toc, title } = parseToc(tree);
46
+ data.pageMeta.toc = toc;
47
+ if (title) data.pageMeta.title = title;
48
+ };
49
+ };
50
+ export { parseToc, remarkToc };
@@ -1,7 +1,7 @@
1
1
  import type { FrontMatterMeta, UserConfig } from '@rspress/shared';
2
- import type { PluginDriver } from '../PluginDriver';
3
- import type { RouteService } from '../route/RouteService';
4
- import type { TocItem } from './remarkPlugins/toc';
2
+ import type { PluginDriver } from '../PluginDriver.js';
3
+ import type { RouteService } from '../route/RouteService.js';
4
+ import type { TocItem } from './remarkPlugins/toc.js';
5
5
  export interface MdxLoaderOptions {
6
6
  config: UserConfig;
7
7
  docDirectory: string;
@@ -1,4 +1,4 @@
1
- import { type RspressPlugin } from '@rspress/shared';
1
+ import type { RspressPlugin } from '@rspress/shared';
2
2
  import type { ZoomOptions } from 'medium-zoom';
3
3
  interface Options {
4
4
  selector?: string;
@@ -0,0 +1,14 @@
1
+ import { node_path } from "../../6289.c67fe0d5.js";
2
+ import { PACKAGE_ROOT } from "../constants.js";
3
+ function pluginMediumZoom(options = {}) {
4
+ return {
5
+ name: '@rspress/plugin-medium-zoom',
6
+ globalUIComponents: [
7
+ [
8
+ node_path.join(PACKAGE_ROOT, './static/MediumZoom.tsx'),
9
+ options
10
+ ]
11
+ ]
12
+ };
13
+ }
14
+ export { pluginMediumZoom };
@@ -1,5 +1,5 @@
1
1
  import type { RouteMeta } from '@rspress/shared';
2
- import { RouteService } from './RouteService';
2
+ import { RouteService } from './RouteService.js';
3
3
  export declare class RoutePage {
4
4
  #private;
5
5
  routeMeta: RouteMeta;
@@ -0,0 +1,61 @@
1
+ import { node_path } from "../../6289.c67fe0d5.js";
2
+ import { RouteService } from "./RouteService.js";
3
+ import { normalizePath, slash } from "../utils/normalizePath.js";
4
+ import { getPageKey } from "../utils/getPageKey.js";
5
+ class RoutePage {
6
+ routeMeta;
7
+ #docDir;
8
+ static create(absolutePath, docsDir) {
9
+ const routeMeta = absolutePathToRouteMeta(absolutePath, docsDir, RouteService.getInstance());
10
+ return new RoutePage(routeMeta, docsDir);
11
+ }
12
+ static createFromExternal(routePath, filepath, docDir) {
13
+ const routeMeta = RoutePage.generateRouteMeta(routePath, filepath, docDir);
14
+ return new RoutePage(routeMeta, node_path.dirname(filepath));
15
+ }
16
+ constructor(routeMeta, docDir){
17
+ this.routeMeta = routeMeta;
18
+ this.#docDir = docDir;
19
+ }
20
+ static generateRouteMeta(routePath, filepath, docDir) {
21
+ const routeService = RouteService.getInstance();
22
+ const { routePath: normalizedPath, lang, version } = routeService.normalizeRoutePath(routePath);
23
+ return {
24
+ routePath: normalizedPath,
25
+ absolutePath: normalizePath(filepath),
26
+ relativePath: absolutePathToRelativePath(filepath, docDir),
27
+ pageName: getPageKey(routePath),
28
+ lang,
29
+ version
30
+ };
31
+ }
32
+ }
33
+ function absolutePathToRelativePath(absolutePath, docsDir) {
34
+ return slash(node_path.relative(docsDir, absolutePath));
35
+ }
36
+ function absolutePathToRouteMeta(absolutePath, docsDir, routeService = RouteService.getInstance()) {
37
+ const relativePath = absolutePathToRelativePath(absolutePath, docsDir);
38
+ const { lang, routePath, version } = routeService.normalizeRoutePath(relativePath);
39
+ return {
40
+ pageName: getPageKey(relativePath),
41
+ absolutePath,
42
+ lang,
43
+ version,
44
+ routePath,
45
+ relativePath
46
+ };
47
+ }
48
+ function absolutePathToRoutePath(absolutePath, docsDir, routeService = RouteService.getInstance()) {
49
+ return absolutePathToRouteMeta(absolutePath, docsDir, routeService).routePath;
50
+ }
51
+ function absolutePathToRoutePrefix(absolutePath, docsDir) {
52
+ const relativePath = slash(node_path.relative(docsDir, absolutePath.replace(node_path.extname(absolutePath), '')));
53
+ const routeService = RouteService.getInstance();
54
+ const [versionPrefix, langPrefix] = routeService.getRoutePathParts(relativePath);
55
+ return `${versionPrefix ? `/${versionPrefix}` : ''}${langPrefix ? `/${langPrefix}` : ''}`;
56
+ }
57
+ function addRoutePrefix(workDir, docsDir, link) {
58
+ const routePrefix = absolutePathToRoutePrefix(workDir, docsDir);
59
+ return `${routePrefix.replace(/\/$/, '')}/${link.replace(/^\//, '')}`;
60
+ }
61
+ export { RoutePage, absolutePathToRelativePath, absolutePathToRoutePath, addRoutePrefix };
@@ -1,6 +1,6 @@
1
1
  import { type AdditionalPage, type PageModule, type RouteMeta, type UserConfig } from '@rspress/shared';
2
2
  import type { ComponentType } from 'react';
3
- import { RoutePage } from './RoutePage';
3
+ import { RoutePage } from './RoutePage.js';
4
4
  interface InitOptions {
5
5
  scanDir: string;
6
6
  config: UserConfig;
@@ -0,0 +1,177 @@
1
+ import { node_path, promises } from "../../6289.c67fe0d5.js";
2
+ import { RSPRESS_TEMP_DIR, removeTrailingSlash, addTrailingSlash } from "../../4669.12208c6a.js";
3
+ import { DEFAULT_PAGE_EXTENSIONS, glob } from "../../3521.56e42d70.js";
4
+ import { PUBLIC_DIR } from "../constants.js";
5
+ import { RoutePage, absolutePathToRoutePath, absolutePathToRelativePath } from "./RoutePage.js";
6
+ import { createError } from "../utils/error.js";
7
+ import { getRoutePathParts, normalizeRoutePath, splitRoutePathParts } from "./normalizeRoutePath.js";
8
+ class RouteService {
9
+ routeData = new Map();
10
+ #scanDir;
11
+ #defaultLang;
12
+ #defaultVersion;
13
+ #extensions;
14
+ #langs;
15
+ #versions;
16
+ #include;
17
+ #exclude;
18
+ #excludeConvention;
19
+ #tempDir;
20
+ #externalPages;
21
+ static __instance__ = null;
22
+ static getInstance() {
23
+ return RouteService.__instance__;
24
+ }
25
+ static async create(options) {
26
+ const { scanDir, config, externalPages } = options;
27
+ const runtimeAbsTempDir = node_path.join(process.cwd(), 'node_modules', RSPRESS_TEMP_DIR, 'runtime');
28
+ await promises.mkdir(runtimeAbsTempDir, {
29
+ recursive: true
30
+ });
31
+ const routeService = new RouteService(scanDir, config, externalPages || [], runtimeAbsTempDir);
32
+ RouteService.__instance__ = routeService;
33
+ await routeService.#init();
34
+ return routeService;
35
+ }
36
+ static async createSimple() {
37
+ return new RouteService('', {}, [], '');
38
+ }
39
+ constructor(scanDir, userConfig, externalPages, runtimeAbsTempDir){
40
+ const routeOptions = userConfig?.route || {};
41
+ this.#scanDir = scanDir;
42
+ this.#extensions = routeOptions.extensions || DEFAULT_PAGE_EXTENSIONS;
43
+ this.#include = routeOptions.include || [];
44
+ this.#exclude = routeOptions.exclude || [];
45
+ this.#excludeConvention = routeOptions.excludeConvention || [
46
+ '**/_[^_]*'
47
+ ];
48
+ this.#defaultLang = userConfig?.lang || '';
49
+ this.#langs = (userConfig?.locales ?? userConfig?.themeConfig?.locales ?? []).map((item)=>item.lang);
50
+ this.#tempDir = runtimeAbsTempDir;
51
+ this.#externalPages = externalPages;
52
+ if (userConfig.multiVersion) {
53
+ this.#defaultVersion = userConfig.multiVersion.default || '';
54
+ this.#versions = userConfig.multiVersion.versions || [];
55
+ } else {
56
+ this.#defaultVersion = '';
57
+ this.#versions = [];
58
+ }
59
+ }
60
+ get extensions() {
61
+ return this.#extensions;
62
+ }
63
+ async #init() {
64
+ const extensions = this.#extensions.map((i)=>i.slice(1));
65
+ const files = (await glob([
66
+ `**/*.{${extensions.join(',')}}`,
67
+ ...this.#include
68
+ ], {
69
+ cwd: this.#scanDir,
70
+ absolute: true,
71
+ onlyFiles: true,
72
+ ignore: [
73
+ ...this.#exclude,
74
+ ...this.#excludeConvention,
75
+ '**/node_modules/**',
76
+ '**/.eslintrc.js',
77
+ '**/.nx/**',
78
+ `./${PUBLIC_DIR}/**`,
79
+ '**/*.d.ts'
80
+ ]
81
+ })).sort();
82
+ files.forEach((filePath)=>{
83
+ const routePage = RoutePage.create(filePath, this.#scanDir);
84
+ this.addRoute(routePage);
85
+ });
86
+ const externalPages = this.#externalPages;
87
+ await Promise.all(externalPages.map(async (route, index)=>{
88
+ const { routePath, content, filepath } = route;
89
+ if (filepath) {
90
+ const routePage = RoutePage.createFromExternal(routePath, filepath, this.#scanDir);
91
+ this.addRoute(routePage);
92
+ return;
93
+ }
94
+ if (content) {
95
+ const filepath = await this.#writeTempFile(index, content);
96
+ const routePage = RoutePage.createFromExternal(routePath, filepath, this.#scanDir);
97
+ this.addRoute(routePage);
98
+ }
99
+ }));
100
+ }
101
+ async addRoute(routePage) {
102
+ const { routeMeta: { routePath } } = routePage;
103
+ if (this.routeData.has(routePath)) throw createError(`routePath ${routePath} has already been added`);
104
+ this.routeData.set(routePath, routePage);
105
+ }
106
+ getRoutes() {
107
+ return Array.from(this.routeData.values()).map((i)=>i.routeMeta);
108
+ }
109
+ getRoutePages() {
110
+ return Array.from(this.routeData.values());
111
+ }
112
+ isExistRoute(link) {
113
+ function linkToRoutePath(routePath) {
114
+ return decodeURIComponent(routePath.split('#')[0]).replace(/\.html$/, '').replace(/\/index$/, '/');
115
+ }
116
+ const cleanLinkPath = linkToRoutePath(link);
117
+ if (!this.routeData.has(removeTrailingSlash(cleanLinkPath)) && !this.routeData.has(addTrailingSlash(cleanLinkPath))) return false;
118
+ return true;
119
+ }
120
+ generateRoutesCode() {
121
+ return this.generateRoutesCodeByRouteMeta(this.getRoutes());
122
+ }
123
+ generateRoutesCodeByRouteMeta(routeMeta) {
124
+ return `
125
+ import React from 'react';
126
+ import { lazyWithPreload } from "react-lazy-with-preload";
127
+ ${routeMeta.map((route, index)=>`const Route${index} = lazyWithPreload(() => import('${route.absolutePath}'))`).join('\n')}
128
+ export const routes = [
129
+ ${routeMeta.map((route, index)=>{
130
+ const preload = `async () => {
131
+ await Route${index}.preload();
132
+ return import("${route.absolutePath}");
133
+ }`;
134
+ const component = `Route${index}`;
135
+ return `{ path: '${route.routePath}', element: React.createElement(${component}), filePath: '${route.relativePath}', preload: ${preload}, lang: '${route.lang}', version: '${route.version}' }`;
136
+ }).join(',\n')}
137
+ ];
138
+ `;
139
+ }
140
+ getRoutePathParts(relativePath) {
141
+ return getRoutePathParts(relativePath, this.#defaultLang, this.#defaultVersion, this.#langs, this.#versions);
142
+ }
143
+ splitRoutePathParts(relativePath) {
144
+ return splitRoutePathParts(relativePath, this.#defaultLang, this.#defaultVersion, this.#langs, this.#versions);
145
+ }
146
+ normalizeRoutePath(relativePath) {
147
+ return normalizeRoutePath(relativePath, this.#defaultLang, this.#defaultVersion, this.#langs, this.#versions, this.#extensions);
148
+ }
149
+ absolutePathToRoutePath(absolutePath) {
150
+ return absolutePathToRoutePath(absolutePath, this.#scanDir, this);
151
+ }
152
+ isInDocsDir(absolutePath) {
153
+ const relativePath = node_path.relative(this.#scanDir, absolutePath);
154
+ return !relativePath.startsWith('..') && !node_path.isAbsolute(relativePath);
155
+ }
156
+ absolutePathToRelativePath(absolutePath) {
157
+ return absolutePathToRelativePath(absolutePath, this.#scanDir);
158
+ }
159
+ async #writeTempFile(index, content) {
160
+ const tempFilePath = node_path.join(this.#tempDir, `temp-${index}.mdx`);
161
+ await promises.writeFile(tempFilePath, content);
162
+ return tempFilePath;
163
+ }
164
+ getRoutePageByRoutePath(routePath) {
165
+ return this.routeData.get(routePath);
166
+ }
167
+ getDocsDir() {
168
+ return this.#scanDir;
169
+ }
170
+ getLangs() {
171
+ return this.#langs;
172
+ }
173
+ getDefaultLang() {
174
+ return this.#defaultLang;
175
+ }
176
+ }
177
+ export { RouteService };
@@ -1,5 +1,5 @@
1
1
  import { type PageIndexInfo, type ReplaceRule, type RouteMeta } from '@rspress/shared';
2
- import type { RouteService } from './RouteService';
2
+ import type { RouteService } from './RouteService.js';
3
3
  interface ExtractPageDataOptions {
4
4
  root: string;
5
5
  searchCodeBlocks: boolean;