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

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 (256) hide show
  1. package/bin/rspress.js +1 -1
  2. package/dist/0~7675.989ee664.js +1791 -0
  3. package/dist/1218.3869bad6.js +2 -0
  4. package/dist/4669.12208c6a.js +2 -0
  5. package/dist/5313.6594aba0.js +63 -0
  6. package/dist/5485.2a0273cf.js +98 -0
  7. package/dist/6289.c67fe0d5.js +5 -0
  8. package/dist/7805.cadab34e.js +4 -0
  9. package/dist/8813.9da1f210.js +2 -0
  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/Banner/index.tsx +3 -4
  15. package/dist/eject-theme/components/Callout/index.scss +0 -2
  16. package/dist/eject-theme/components/CodeBlock/index.scss +4 -12
  17. package/dist/eject-theme/components/CodeBlock/index.tsx +6 -1
  18. package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.tsx +1 -3
  19. package/dist/eject-theme/components/CodeButtonGroup/index.scss +5 -1
  20. package/dist/eject-theme/components/CodeButtonGroup/index.tsx +1 -3
  21. package/dist/eject-theme/components/DocContent/doc.scss +27 -7
  22. package/dist/eject-theme/components/DocContent/docComponents/table.tsx +10 -4
  23. package/dist/eject-theme/components/DocContent/index.tsx +3 -3
  24. package/dist/eject-theme/components/{DocContent/FallbackHeading.tsx → FallbackHeading/index.tsx} +20 -11
  25. package/dist/eject-theme/components/Link/index.tsx +13 -4
  26. package/dist/eject-theme/components/Nav/NavMenu.tsx +2 -3
  27. package/dist/eject-theme/components/NavHamburger/index.tsx +3 -4
  28. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +2 -3
  29. package/dist/eject-theme/components/Overview/OverviewGroup.tsx +1 -2
  30. package/dist/eject-theme/components/Overview/index.tsx +6 -2
  31. package/dist/eject-theme/components/PackageManagerTabs/index.tsx +12 -0
  32. package/dist/eject-theme/components/PrevNextPage/index.tsx +6 -3
  33. package/dist/eject-theme/components/Root/index.tsx +58 -0
  34. package/dist/eject-theme/components/Search/NoSearchResult.tsx +2 -3
  35. package/dist/eject-theme/components/Search/SearchButton.tsx +3 -4
  36. package/dist/eject-theme/components/Search/SearchPanel.tsx +12 -7
  37. package/dist/eject-theme/components/Search/SuggestItem.tsx +15 -12
  38. package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +2 -3
  39. package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +1 -0
  40. package/dist/eject-theme/components/SidebarMenu/index.tsx +4 -4
  41. package/dist/eject-theme/components/SocialLinks/index.tsx +2 -3
  42. package/dist/eject-theme/components/SourceCode/index.tsx +6 -4
  43. package/dist/eject-theme/components/SwitchAppearance/index.tsx +3 -5
  44. package/dist/eject-theme/components/Tabs/index.scss +19 -22
  45. package/dist/eject-theme/components/Toc/TocItem.scss +3 -3
  46. package/dist/eject-theme/components/Toc/TocItem.tsx +1 -0
  47. package/dist/index.d.ts +6 -6
  48. package/dist/index.js +16 -3134
  49. package/dist/node/PluginDriver.d.ts +1 -1
  50. package/dist/node/PluginDriver.js +143 -0
  51. package/dist/node/auto-nav-sidebar/index.js +44 -0
  52. package/dist/node/auto-nav-sidebar/locales.js +26 -0
  53. package/dist/node/auto-nav-sidebar/normalize.js +228 -0
  54. package/dist/node/auto-nav-sidebar/utils.js +68 -0
  55. package/dist/node/auto-nav-sidebar/walk.js +67 -0
  56. package/dist/node/build.js +31 -0
  57. package/dist/node/constants.d.ts +1 -0
  58. package/dist/node/constants.js +33 -0
  59. package/dist/node/dev.js +32 -0
  60. package/dist/node/eject.js +111 -0
  61. package/dist/node/index.d.ts +5 -5
  62. package/dist/node/initRsbuild.d.ts +2 -2
  63. package/dist/node/initRsbuild.js +338 -0
  64. package/dist/node/last-updated/index.js +28 -0
  65. package/dist/node/logger/hint.d.ts +1 -1
  66. package/dist/node/logger/hint.js +85 -0
  67. package/dist/node/mdx/loader.d.ts +1 -1
  68. package/dist/node/mdx/loader.e1578c62.js +13 -0
  69. package/dist/{loader.js → node/mdx/loader.js} +2 -2
  70. package/dist/node/mdx/options.d.ts +2 -2
  71. package/dist/node/mdx/options.js +100 -0
  72. package/dist/node/mdx/processor.d.ts +2 -2
  73. package/dist/node/mdx/processor.js +71 -0
  74. package/dist/node/mdx/rehypePlugins/codeMeta.js +10 -0
  75. package/dist/node/mdx/rehypePlugins/headerAnchor.js +53 -0
  76. package/dist/node/mdx/rehypePlugins/shiki.js +34 -0
  77. package/dist/node/mdx/rehypePlugins/transformers/add-lang.js +15 -0
  78. package/dist/node/mdx/rehypePlugins/transformers/add-line-numbers.js +22 -0
  79. package/dist/node/mdx/rehypePlugins/transformers/add-title.js +24 -0
  80. package/dist/node/mdx/rehypePlugins/transformers/add-wrap-code.js +22 -0
  81. package/dist/node/mdx/rehypePlugins/transformers/index.d.ts +5 -5
  82. package/dist/node/mdx/rehypePlugins/transformers/index.js +5 -0
  83. package/dist/node/mdx/rehypePlugins/transformers/meta-highlight.js +41 -0
  84. package/dist/node/mdx/remarkPlugins/builtin.js +11 -0
  85. package/dist/node/mdx/remarkPlugins/containerSyntax.js +190 -0
  86. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +66 -0
  87. package/dist/node/mdx/remarkPlugins/image.js +67 -0
  88. package/dist/node/mdx/remarkPlugins/link.d.ts +1 -1
  89. package/dist/node/mdx/remarkPlugins/link.js +99 -0
  90. package/dist/node/mdx/remarkPlugins/toc.js +50 -0
  91. package/dist/node/mdx/types.d.ts +3 -3
  92. package/dist/node/medium-zoom/index.d.ts +1 -1
  93. package/dist/node/medium-zoom/index.js +14 -0
  94. package/dist/node/route/RoutePage.d.ts +1 -1
  95. package/dist/node/route/RoutePage.js +61 -0
  96. package/dist/node/route/RouteService.d.ts +1 -1
  97. package/dist/node/route/RouteService.js +177 -0
  98. package/dist/node/route/extractPageData.d.ts +1 -1
  99. package/dist/node/route/extractPageData.js +112 -0
  100. package/dist/node/route/normalizeRoutePath.js +54 -0
  101. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +21 -0
  102. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +150 -0
  103. package/dist/node/runtimeModule/globalStyles.d.ts +1 -1
  104. package/dist/node/runtimeModule/globalStyles.js +12 -0
  105. package/dist/node/runtimeModule/globalUIComponents.d.ts +1 -1
  106. package/dist/node/runtimeModule/globalUIComponents.js +25 -0
  107. package/dist/node/runtimeModule/i18n.d.ts +2 -2
  108. package/dist/node/runtimeModule/i18n.js +83 -0
  109. package/dist/node/runtimeModule/pageData/createPageData.d.ts +1 -1
  110. package/dist/node/runtimeModule/pageData/createPageData.js +64 -0
  111. package/dist/node/runtimeModule/pageData/rsbuildPlugin.d.ts +1 -1
  112. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +51 -0
  113. package/dist/node/runtimeModule/routeList.d.ts +1 -1
  114. package/dist/node/runtimeModule/routeList.js +7 -0
  115. package/dist/node/runtimeModule/searchHooks.d.ts +1 -1
  116. package/dist/node/runtimeModule/searchHooks.js +11 -0
  117. package/dist/node/runtimeModule/siteData/createSiteData.js +34 -0
  118. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +94 -0
  119. package/dist/node/runtimeModule/siteData/rsbuildPlugin.d.ts +1 -1
  120. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +24 -0
  121. package/dist/node/runtimeModule/socialLinks.d.ts +1 -1
  122. package/dist/node/runtimeModule/socialLinks.js +8 -0
  123. package/dist/node/runtimeModule/types.d.ts +2 -2
  124. package/dist/node/serve.js +23 -0
  125. package/dist/node/ssg/renderHtmlTemplate.js +33 -0
  126. package/dist/node/ssg/renderPage.js +34 -0
  127. package/dist/node/ssg/renderPageWorker.474f9f73.js +2 -0
  128. package/dist/node/ssg/renderPageWorker.js +15 -0
  129. package/dist/node/ssg/renderPages.d.ts +1 -1
  130. package/dist/node/ssg/renderPages.js +105 -0
  131. package/dist/node/ssg/renderPages.js.LICENSE.txt +4 -0
  132. package/dist/node/ssg/rsbuildPluginCSR.d.ts +1 -1
  133. package/dist/node/ssg/rsbuildPluginCSR.js +27 -0
  134. package/dist/node/ssg/rsbuildPluginSSG.d.ts +1 -1
  135. package/dist/node/ssg/rsbuildPluginSSG.js +72 -0
  136. package/dist/node/ssg/ssgEnv.js +33 -0
  137. package/dist/node/ssg/ssgEnv.js.LICENSE.txt +5 -0
  138. package/dist/node/ssg-md/llms/emitLlmsTxt.d.ts +1 -1
  139. package/dist/node/ssg-md/llms/emitLlmsTxt.js +80 -0
  140. package/dist/node/ssg-md/llms/llmsTxt.d.ts +1 -1
  141. package/dist/node/ssg-md/llms/llmsTxt.js +66 -0
  142. package/dist/node/ssg-md/react/index.d.ts +1 -1
  143. package/dist/node/ssg-md/remarkSplitMdx.js +202 -0
  144. package/dist/node/ssg-md/renderPage.js +31 -0
  145. package/dist/node/ssg-md/renderPages.d.ts +1 -1
  146. package/dist/node/ssg-md/renderPages.js +27 -0
  147. package/dist/node/ssg-md/rsbuildPluginSSGMD.d.ts +1 -1
  148. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +47 -0
  149. package/dist/node/utils/applyReplaceRules.js +6 -0
  150. package/dist/node/utils/checkLanguageParity.js +77 -0
  151. package/dist/node/utils/createHash.js +5 -0
  152. package/dist/node/utils/error.d.ts +9 -0
  153. package/dist/node/utils/error.js +9 -0
  154. package/dist/node/utils/escapeHeadingIds.js +5 -0
  155. package/dist/node/utils/flattenMdxContent.js +74 -0
  156. package/dist/node/utils/fs.js +14 -0
  157. package/dist/node/utils/getImportAstNode.js +63 -0
  158. package/dist/node/utils/getPageKey.js +6 -0
  159. package/dist/node/utils/getSocialIcons.js +32 -0
  160. package/dist/node/utils/index.d.ts +10 -9
  161. package/dist/node/utils/normalizePath.js +10 -0
  162. package/dist/node/utils/reactAlias.d.ts +2 -0
  163. package/dist/node/utils/reactAlias.js +83 -0
  164. package/dist/rslib-runtime.99091bf6.js +18 -0
  165. package/dist/runtime/App.js +2 -2
  166. package/dist/runtime/ClientApp.d.ts +1 -1
  167. package/dist/runtime/ClientApp.js +0 -4
  168. package/dist/runtime/ssrMdServerEntry.js +1 -1
  169. package/dist/runtime/ssrServerEntry.js +2 -1
  170. package/dist/runtime.72d450ac.js +1 -0
  171. package/dist/runtime.js +3 -2
  172. package/dist/shiki-transformers.d.ts +1 -1
  173. package/dist/shiki-transformers.js +6 -120
  174. package/dist/theme/components/Banner/index.d.ts +1 -1
  175. package/dist/theme/components/Banner/index.js +2 -3
  176. package/dist/theme/components/Callout/index.css +0 -2
  177. package/dist/theme/components/CodeBlock/index.css +4 -15
  178. package/dist/theme/components/CodeBlock/index.js +1 -0
  179. package/dist/theme/components/CodeButtonGroup/CopyCodeButton.js +3 -5
  180. package/dist/theme/components/CodeButtonGroup/index.css +5 -1
  181. package/dist/theme/components/CodeButtonGroup/index.js +3 -5
  182. package/dist/theme/components/DocContent/doc.css +28 -7
  183. package/dist/theme/components/DocContent/docComponents/index.d.ts +3 -3
  184. package/dist/theme/components/DocContent/docComponents/table.d.ts +2 -2
  185. package/dist/theme/components/DocContent/docComponents/table.js +8 -3
  186. package/dist/theme/components/DocContent/index.js +2 -3
  187. package/dist/theme/components/{DocContent/FallbackHeading.js → FallbackHeading/index.js} +19 -11
  188. package/dist/theme/components/HoverGroup/useHoverGroup.d.ts +1 -1
  189. package/dist/theme/components/Link/index.js +9 -5
  190. package/dist/theme/components/Nav/NavMenu.js +2 -3
  191. package/dist/theme/components/NavHamburger/index.js +3 -4
  192. package/dist/theme/components/NavScreen/NavScreenMenuItem.js +2 -3
  193. package/dist/theme/components/Overview/OverviewGroup.js +1 -2
  194. package/dist/theme/components/Overview/index.js +1 -2
  195. package/dist/theme/components/PackageManagerTabs/index.d.ts +1 -1
  196. package/dist/theme/components/PackageManagerTabs/index.js +4 -0
  197. package/dist/theme/components/PrevNextPage/index.js +3 -4
  198. package/dist/theme/components/Root/index.d.ts +54 -0
  199. package/dist/theme/components/Root/index.js +7 -0
  200. package/dist/theme/components/Search/NoSearchResult.js +2 -3
  201. package/dist/theme/components/Search/SearchButton.js +3 -4
  202. package/dist/theme/components/Search/SearchPanel.js +12 -15
  203. package/dist/theme/components/Search/SuggestItem.d.ts +1 -1
  204. package/dist/theme/components/Search/SuggestItem.js +7 -11
  205. package/dist/theme/components/Search/logic/Provider.d.ts +1 -1
  206. package/dist/theme/components/Search/logic/providers/LocalProvider.d.ts +2 -2
  207. package/dist/theme/components/Search/logic/search.d.ts +1 -1
  208. package/dist/theme/components/Sidebar/SidebarGroup.js +2 -3
  209. package/dist/theme/components/Sidebar/SidebarItem.js +1 -0
  210. package/dist/theme/components/SidebarMenu/index.js +3 -5
  211. package/dist/theme/components/SocialLinks/index.js +2 -3
  212. package/dist/theme/components/SourceCode/index.js +2 -4
  213. package/dist/theme/components/SwitchAppearance/index.js +3 -5
  214. package/dist/theme/components/Tabs/index.css +13 -22
  215. package/dist/theme/components/Toc/TocItem.css +2 -3
  216. package/dist/theme/components/Toc/TocItem.js +1 -0
  217. package/dist/theme/icons.d.ts +25 -0
  218. package/dist/theme/icons.js +47 -0
  219. package/dist/theme/index.d.ts +62 -59
  220. package/dist/theme/index.js +4 -1
  221. package/dist/theme/layout/DocLayout/index.css +2 -2
  222. package/dist/theme/logic/useFullTextSearch.d.ts +1 -1
  223. package/dist/theme/styles/scrollbar.css +1 -0
  224. package/dist/theme/styles/vars/base-vars.css +5 -3
  225. package/dist/theme/styles/vars/home-vars.css +2 -1
  226. package/package.json +17 -18
  227. package/dist/3~128.js +0 -74
  228. package/dist/3~517.js +0 -1786
  229. package/dist/3~894.js +0 -26
  230. package/dist/cli.js +0 -259
  231. package/dist/index.js.LICENSE.txt +0 -10
  232. package/dist/node/auto-nav-sidebar/fixtures/docs/guide/c.d.ts +0 -2
  233. package/dist/node/auto-nav-sidebar/fixtures/docs-locales/en/guide/c.d.ts +0 -2
  234. package/dist/node/auto-nav-sidebar/fixtures/docs-locales/zh/guide/c.d.ts +0 -2
  235. package/dist/node/auto-nav-sidebar/locales.test.d.ts +0 -1
  236. package/dist/node/auto-nav-sidebar/walk.test.d.ts +0 -1
  237. package/dist/node/mdx/rehypePlugins/headerAnchor.test.d.ts +0 -1
  238. package/dist/node/mdx/remarkPlugins/containerSyntax.test.d.ts +0 -1
  239. package/dist/node/mdx/remarkPlugins/fileCodeBlock.test.d.ts +0 -1
  240. package/dist/node/mdx/remarkPlugins/image.test.d.ts +0 -1
  241. package/dist/node/mdx/remarkPlugins/link.test.d.ts +0 -1
  242. package/dist/node/route/RouteService.test.d.ts +0 -1
  243. package/dist/node/route/extractPageData.test.d.ts +0 -1
  244. package/dist/node/route/fixtures/basic/guide/c.d.ts +0 -2
  245. package/dist/node/route/normalizeRoutePath.test.d.ts +0 -1
  246. package/dist/node/runtimeModule/i18n.test.d.ts +0 -1
  247. package/dist/node/ssg-md/remarkSplitMdx.test.d.ts +0 -4
  248. package/dist/node/utils/checkLanguageParity.test.d.ts +0 -1
  249. package/dist/node/utils/detectCustomIcon.d.ts +0 -1
  250. package/dist/node/utils/detectReactVersion.d.ts +0 -3
  251. package/dist/processor.js +0 -4539
  252. package/dist/renderPageWorker.js +0 -196
  253. package/dist/theme/components/Search/logic/util.test.d.ts +0 -1
  254. /package/dist/cli/{config.d.ts → config/index.d.ts} +0 -0
  255. /package/dist/{shiki-transformers.js.LICENSE.txt → node/mdx/rehypePlugins/transformers/meta-highlight.js.LICENSE.txt} +0 -0
  256. /package/dist/theme/components/{DocContent/FallbackHeading.d.ts → FallbackHeading/index.d.ts} +0 -0
@@ -0,0 +1,2 @@
1
+ import node_process, { cwd } from "node:process";
2
+ export { cwd, node_process };
@@ -0,0 +1,2 @@
1
+ import { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, normalizeHref, parseUrl, removeLeadingSlash, removeTrailingSlash, slash, withBase } from "@rspress/shared";
2
+ export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, normalizeHref, parseUrl, removeLeadingSlash, removeTrailingSlash, slash, withBase };
@@ -0,0 +1,63 @@
1
+ import * as __rspack_external_path from "path";
2
+ import { __webpack_require__ } from "./rslib-runtime.99091bf6.js";
3
+ import { matchPath } from "react-router-dom";
4
+ import { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, DEFAULT_PAGE_EXTENSIONS } from "@rspress/shared/constants";
5
+ import { glob } from "tinyglobby";
6
+ import { PLUGIN_REACT_NAME, pluginReact } from "@rsbuild/plugin-react";
7
+ import { chunk, groupBy } from "lodash-es";
8
+ import { compile } from "@rspress/mdx-rs";
9
+ import { htmlToText } from "html-to-text";
10
+ import node_fs, { createReadStream, createWriteStream, readFileSync } from "node:fs";
11
+ import { mergeRsbuildConfig, rspack as core_rspack } from "@rsbuild/core";
12
+ import { createHash } from "node:crypto";
13
+ import { extname, join } from "./6289.c67fe0d5.js";
14
+ __webpack_require__.add({
15
+ path (module) {
16
+ module.exports = __rspack_external_path;
17
+ }
18
+ });
19
+ const PLUGIN_VIRTUAL_MODULE_NAME = 'rsbuild:virtual-module';
20
+ const pluginVirtualModule = (pluginOptions = {})=>({
21
+ name: PLUGIN_VIRTUAL_MODULE_NAME,
22
+ async setup (api) {
23
+ const { virtualModules = {}, tempDir: virtualFolderName = '.rsbuild-virtual-module' } = pluginOptions;
24
+ const TEMP_DIR = join(api.context.rootPath, virtualFolderName);
25
+ const virtualFileAbsolutePaths = Object.keys(virtualModules).map((i)=>{
26
+ let absolutePath = join(TEMP_DIR, i);
27
+ if (!extname(absolutePath)) absolutePath = `${absolutePath}.js`;
28
+ return [
29
+ i,
30
+ absolutePath
31
+ ];
32
+ });
33
+ api.modifyBundlerChain((chain, { rspack })=>{
34
+ const pluginId = 'RSBUILD_VIRTUAL_MODULE_PLUGIN';
35
+ const virtualModules = Object.fromEntries(virtualFileAbsolutePaths.map((i)=>[
36
+ i[1],
37
+ ''
38
+ ]));
39
+ if (chain.plugins.has(pluginId)) chain.plugin(pluginId).tap((options)=>{
40
+ const existingPaths = new Set(Object.keys(options[0] ?? {}));
41
+ const conflictPath = virtualFileAbsolutePaths.find(([, path])=>existingPaths.has(path));
42
+ if (conflictPath) throw new Error(`Virtual module name conflicted: ${conflictPath[0]}`);
43
+ return [
44
+ {
45
+ ...options[0],
46
+ ...virtualModules
47
+ }
48
+ ];
49
+ });
50
+ else chain.plugin(pluginId).use(rspack.experiments.VirtualModulesPlugin, [
51
+ virtualModules
52
+ ]);
53
+ chain.resolve.alias.merge(Object.fromEntries(virtualFileAbsolutePaths));
54
+ });
55
+ for (const [moduleName, absolutePath] of virtualFileAbsolutePaths){
56
+ const handler = virtualModules[moduleName];
57
+ if (handler) api.transform({
58
+ test: absolutePath
59
+ }, handler);
60
+ }
61
+ }
62
+ });
63
+ export { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, DEFAULT_PAGE_EXTENSIONS, PLUGIN_REACT_NAME, chunk, compile, core_rspack, createHash, createReadStream, createWriteStream, glob, groupBy, htmlToText, matchPath, mergeRsbuildConfig, node_fs, pluginReact, pluginVirtualModule, readFileSync };
@@ -0,0 +1,98 @@
1
+ import { createRequire } from "node:module";
2
+ import node_url, { fileURLToPath, pathToFileURL } from "node:url";
3
+ import { createHead, transformHtmlTemplate } from "@unhead/react/server";
4
+ var package_namespaceObject = {
5
+ rE: "2.0.0-rc.2"
6
+ };
7
+ async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true, signal } = {}) {
8
+ return new Promise((resolve_, reject_)=>{
9
+ if (void 0 === iterable[Symbol.iterator] && void 0 === iterable[Symbol.asyncIterator]) throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
10
+ if ('function' != typeof mapper) throw new TypeError('Mapper function is required');
11
+ if (!(Number.isSafeInteger(concurrency) && concurrency >= 1 || concurrency === 1 / 0)) throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
12
+ const result = [];
13
+ const errors = [];
14
+ const skippedIndexesMap = new Map();
15
+ let isRejected = false;
16
+ let isResolved = false;
17
+ let isIterableDone = false;
18
+ let resolvingCount = 0;
19
+ let currentIndex = 0;
20
+ const iterator = void 0 === iterable[Symbol.iterator] ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
21
+ const signalListener = ()=>{
22
+ reject(signal.reason);
23
+ };
24
+ const cleanup = ()=>{
25
+ signal?.removeEventListener('abort', signalListener);
26
+ };
27
+ const resolve = (value)=>{
28
+ resolve_(value);
29
+ cleanup();
30
+ };
31
+ const reject = (reason)=>{
32
+ isRejected = true;
33
+ isResolved = true;
34
+ reject_(reason);
35
+ cleanup();
36
+ };
37
+ if (signal) {
38
+ if (signal.aborted) reject(signal.reason);
39
+ signal.addEventListener('abort', signalListener, {
40
+ once: true
41
+ });
42
+ }
43
+ const next = async ()=>{
44
+ if (isResolved) return;
45
+ const nextItem = await iterator.next();
46
+ const index = currentIndex;
47
+ currentIndex++;
48
+ if (nextItem.done) {
49
+ isIterableDone = true;
50
+ if (0 === resolvingCount && !isResolved) {
51
+ if (!stopOnError && errors.length > 0) return void reject(new AggregateError(errors));
52
+ isResolved = true;
53
+ if (0 === skippedIndexesMap.size) return void resolve(result);
54
+ const pureResult = [];
55
+ for (const [index, value] of result.entries())if (skippedIndexesMap.get(index) !== pMapSkip) pureResult.push(value);
56
+ resolve(pureResult);
57
+ }
58
+ return;
59
+ }
60
+ resolvingCount++;
61
+ (async ()=>{
62
+ try {
63
+ const element = await nextItem.value;
64
+ if (isResolved) return;
65
+ const value = await mapper(element, index);
66
+ if (value === pMapSkip) skippedIndexesMap.set(index, value);
67
+ result[index] = value;
68
+ resolvingCount--;
69
+ await next();
70
+ } catch (error) {
71
+ if (stopOnError) reject(error);
72
+ else {
73
+ errors.push(error);
74
+ resolvingCount--;
75
+ try {
76
+ await next();
77
+ } catch (error) {
78
+ reject(error);
79
+ }
80
+ }
81
+ }
82
+ })();
83
+ };
84
+ (async ()=>{
85
+ for(let index = 0; index < concurrency; index++){
86
+ try {
87
+ await next();
88
+ } catch (error) {
89
+ reject(error);
90
+ break;
91
+ }
92
+ if (isIterableDone || isRejected) break;
93
+ }
94
+ })();
95
+ });
96
+ }
97
+ const pMapSkip = Symbol('skip');
98
+ export { createHead, createRequire, fileURLToPath, node_url, pMap, package_namespaceObject, pathToFileURL, transformHtmlTemplate };
@@ -0,0 +1,5 @@
1
+ import { logger } from "@rspress/shared/logger";
2
+ import node_path, { extname, join, relative } from "node:path";
3
+ import promises, { mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
4
+ import picocolors from "picocolors";
5
+ export { extname, join, logger, mkdir, node_path, picocolors, promises, readFile, readdir, relative, rm, stat, writeFile };
@@ -0,0 +1,4 @@
1
+ import { extractTextAndId, getIconUrlPath, getNodeAttribute, loadFrontMatter } from "@rspress/shared/node-utils";
2
+ import node_os, { constants } from "node:os";
3
+ import { createProcessor, nodeTypes } from "@mdx-js/mdx";
4
+ export { constants, createProcessor, extractTextAndId, getIconUrlPath, getNodeAttribute, loadFrontMatter, nodeTypes, node_os };
@@ -0,0 +1,2 @@
1
+ import { visit } from "unist-util-visit";
2
+ export { visit };
@@ -0,0 +1,4 @@
1
+ function defineConfig(config) {
2
+ return config;
3
+ }
4
+ export { defineConfig };
@@ -0,0 +1,30 @@
1
+ import { node_fs, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "../../5313.6594aba0.js";
2
+ import { node_path, logger } from "../../6289.c67fe0d5.js";
3
+ const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(node_fs.existsSync);
4
+ async function loadConfigFile(customConfigFile) {
5
+ const baseDir = process.cwd();
6
+ let configFilePath = '';
7
+ configFilePath = customConfigFile ? node_path.isAbsolute(customConfigFile) ? customConfigFile : node_path.join(baseDir, customConfigFile) : findConfig(node_path.join(baseDir, DEFAULT_CONFIG_NAME));
8
+ if (!configFilePath) {
9
+ logger.info(`No config file found in ${baseDir}`);
10
+ return {
11
+ config: {},
12
+ configFilePath: ''
13
+ };
14
+ }
15
+ const { loadConfig } = await import("@rsbuild/core");
16
+ const { content } = await loadConfig({
17
+ cwd: node_path.dirname(configFilePath),
18
+ path: configFilePath
19
+ });
20
+ return {
21
+ config: content,
22
+ configFilePath
23
+ };
24
+ }
25
+ function resolveDocRoot(cwd, cliRoot, configRoot) {
26
+ if (cliRoot) return node_path.join(cwd, cliRoot);
27
+ if (configRoot) return node_path.isAbsolute(configRoot) ? configRoot : node_path.join(cwd, configRoot);
28
+ return node_path.join(cwd, 'docs');
29
+ }
30
+ export { loadConfigFile, resolveDocRoot };
@@ -0,0 +1,3 @@
1
+ import { cac } from "cac";
2
+ import chokidar from "chokidar";
3
+ export { cac, chokidar };
@@ -0,0 +1,122 @@
1
+ import { node_path, logger, join, picocolors } from "../6289.c67fe0d5.js";
2
+ import { chokidar, cac } from "./index.cb89dbd1.js";
3
+ import { package_namespaceObject } from "../5485.2a0273cf.js";
4
+ import { loadConfigFile, resolveDocRoot } from "./config/loadConfigFile.js";
5
+ import { dev } from "../node/dev.js";
6
+ import { PUBLIC_DIR } from "../node/constants.js";
7
+ import { build } from "../node/build.js";
8
+ import { serve } from "../node/serve.js";
9
+ import { listComponents, ejectComponent } from "../node/eject.js";
10
+ const META_FILES = [
11
+ '_meta.json',
12
+ '_nav.json'
13
+ ];
14
+ const cli = cac('rspress').version(package_namespaceObject.rE).help();
15
+ const landingMessage = `🔥 Rspress v${package_namespaceObject.rE}\n`;
16
+ logger.greet(landingMessage);
17
+ const setNodeEnv = (env)=>{
18
+ process.env.NODE_ENV = env;
19
+ };
20
+ cli.option('-c,--config [config]', 'Specify the path to the config file');
21
+ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', 'port number').option('--host [host]', 'hostname').action(async (root, options)=>{
22
+ setNodeEnv('development');
23
+ let isRestarting = false;
24
+ const cwd = process.cwd();
25
+ let cliWatcher;
26
+ let devServer;
27
+ const startDevServer = async ()=>{
28
+ const { port, host } = options || {};
29
+ const { config, configFilePath } = await loadConfigFile(options?.config);
30
+ config.root = resolveDocRoot(cwd, root, config.root);
31
+ const docDirectory = config.root;
32
+ devServer = await dev({
33
+ appDirectory: cwd,
34
+ docDirectory,
35
+ config,
36
+ configFilePath,
37
+ extraBuilderConfig: {
38
+ server: {
39
+ port,
40
+ host
41
+ }
42
+ }
43
+ });
44
+ cliWatcher = chokidar.watch([
45
+ configFilePath,
46
+ docDirectory
47
+ ], {
48
+ ignoreInitial: true,
49
+ ignored: [
50
+ '**/node_modules/**',
51
+ '**/.git/**',
52
+ '**/.DS_Store/**',
53
+ join(docDirectory, PUBLIC_DIR)
54
+ ]
55
+ });
56
+ cliWatcher.on('all', async (eventName, filepath)=>{
57
+ const basename = node_path.basename(filepath);
58
+ if ('change' === eventName && META_FILES.includes(basename)) return;
59
+ if ('add' === eventName || 'unlink' === eventName || 'change' === eventName && filepath === configFilePath) {
60
+ if (isRestarting) return;
61
+ isRestarting = true;
62
+ console.log(`\n✨ ${eventName} ${picocolors.green(node_path.relative(cwd, filepath))}, dev server will restart...\n`);
63
+ await devServer.close();
64
+ await cliWatcher.close();
65
+ await startDevServer();
66
+ isRestarting = false;
67
+ }
68
+ });
69
+ };
70
+ await startDevServer();
71
+ const exitProcess = async ()=>{
72
+ try {
73
+ await devServer.close();
74
+ await cliWatcher.close();
75
+ } finally{
76
+ process.exit(0);
77
+ }
78
+ };
79
+ process.on('SIGINT', exitProcess);
80
+ process.on('SIGTERM', exitProcess);
81
+ });
82
+ cli.command('build [root]').action(async (root, options)=>{
83
+ setNodeEnv('production');
84
+ const cwd = process.cwd();
85
+ const { config, configFilePath } = await loadConfigFile(options.config);
86
+ config.root = resolveDocRoot(cwd, root, config.root);
87
+ const docDirectory = config.root;
88
+ try {
89
+ await build({
90
+ docDirectory,
91
+ config,
92
+ configFilePath
93
+ });
94
+ } catch (err) {
95
+ logger.error(err);
96
+ process.exit(1);
97
+ }
98
+ });
99
+ cli.command('preview [root]').alias('serve').option('--port [port]', 'port number').option('--host [host]', 'hostname').action(async (root, options)=>{
100
+ setNodeEnv('production');
101
+ const cwd = process.cwd();
102
+ const { port, host } = options || {};
103
+ const { config, configFilePath } = await loadConfigFile(options?.config);
104
+ config.root = resolveDocRoot(cwd, root, config.root);
105
+ await serve({
106
+ config,
107
+ host,
108
+ port,
109
+ configFilePath
110
+ });
111
+ });
112
+ cli.command('eject [component]', 'Eject a theme component to customize it').action(async (component)=>{
113
+ if (!component) return void await listComponents();
114
+ const cwd = process.cwd();
115
+ try {
116
+ await ejectComponent(component, cwd);
117
+ } catch (error) {
118
+ logger.error(`Failed to eject component: ${error}`);
119
+ process.exit(1);
120
+ }
121
+ });
122
+ cli.parse();
@@ -1,5 +1,4 @@
1
- import { Link, mergeRefs, SvgWrapper } from '@theme';
2
- import CloseSvg from '@theme-assets/close';
1
+ import { IconClose, Link, mergeRefs, SvgWrapper } from '@theme';
3
2
  import clsx from 'clsx';
4
3
  import { forwardRef, type ReactNode, useEffect, useState } from 'react';
5
4
  import './index.scss';
@@ -31,7 +30,7 @@ export type BannerProps = {
31
30
  /**
32
31
  * @example
33
32
  * // theme/index.tsx
34
- * import { Layout as BasicLayout, Banner } from '@rspress/core/theme';
33
+ * import { Layout as BasicLayout, Banner } from '@rspress/core/theme-original';
35
34
  * import { useLang } from '@rspress/core/runtime';
36
35
  * const Layout = () => {
37
36
  const lang = useLang();
@@ -100,7 +99,7 @@ export const Banner = forwardRef<HTMLDivElement, BannerProps>(
100
99
  {message}
101
100
  </Link>
102
101
  <SvgWrapper
103
- icon={CloseSvg}
102
+ icon={IconClose}
104
103
  onClick={() => {
105
104
  setDisable(true);
106
105
  if (storage) {
@@ -102,8 +102,6 @@
102
102
  }
103
103
 
104
104
  a {
105
- font-weight: 500;
106
- transition: color 0.25s;
107
105
  border-bottom: 1px solid currentColor;
108
106
  }
109
107
  }
@@ -25,6 +25,10 @@
25
25
  color: var(--rp-code-block-color);
26
26
  background-color: var(--rp-code-block-bg);
27
27
 
28
+ &__scroll-container {
29
+ overflow-x: auto;
30
+ }
31
+
28
32
  & :where(pre) {
29
33
  outline: none; // avoid focus outline https://github.com/web-infra-dev/rspack/issues/11775
30
34
 
@@ -47,18 +51,6 @@
47
51
  z-index: 1;
48
52
  margin: 0;
49
53
  background: transparent;
50
- overflow-x: auto;
51
- &::-webkit-scrollbar {
52
- height: 5px;
53
- width: 5px;
54
- }
55
- &::-webkit-scrollbar-corner {
56
- display: none;
57
- }
58
- &::-webkit-scrollbar-thumb {
59
- background-color: var(--rp-code-block-scroll-bar-bg);
60
- border-radius: 10px;
61
- }
62
54
  }
63
55
 
64
56
  & :where(code) {
@@ -87,7 +87,12 @@ export function CodeBlock({
87
87
  lineNumbersProp && 'rp-codeblock__content--line-numbers',
88
88
  )}
89
89
  >
90
- <div ref={copyElementRef}>{children}</div>
90
+ <div
91
+ className="rp-codeblock__content__scroll-container rp-scrollbar"
92
+ ref={copyElementRef}
93
+ >
94
+ {children}
95
+ </div>
91
96
  <CodeButtonGroup
92
97
  {...codeButtonGroupProps}
93
98
  copyElementRef={copyElementRef}
@@ -1,6 +1,4 @@
1
- import { SvgWrapper } from '@theme';
2
- import IconCopy from '@theme-assets/copy';
3
- import IconSuccess from '@theme-assets/success';
1
+ import { IconCopy, IconSuccess, SvgWrapper } from '@theme';
4
2
  import copy from 'copy-to-clipboard';
5
3
  import { useRef } from 'react';
6
4
  import './CopyCodeButton.scss';
@@ -1,3 +1,7 @@
1
+ :root {
2
+ --rp-code-button-group-z-index: 10;
3
+ }
4
+
1
5
  .rp-codeblock__content:hover .rp-code-button-group__button {
2
6
  opacity: 1;
3
7
  }
@@ -6,7 +10,7 @@
6
10
  position: absolute;
7
11
  right: 20px;
8
12
  top: 20px;
9
- z-index: 10;
13
+ z-index: var(--rp-code-button-group-z-index);
10
14
  display: flex;
11
15
  gap: 10px;
12
16
 
@@ -1,7 +1,5 @@
1
1
  import { useSite } from '@rspress/core/runtime';
2
- import { SvgWrapper } from '@theme';
3
- import IconWrap from '@theme-assets/wrap';
4
- import IconWrapped from '@theme-assets/wrapped';
2
+ import { IconWrap, IconWrapped, SvgWrapper } from '@theme';
5
3
  import clsx from 'clsx';
6
4
  import { useRef, useState } from 'react';
7
5
  import './index.scss';
@@ -36,7 +36,7 @@
36
36
  overflow-wrap: break-word;
37
37
 
38
38
  &:hover {
39
- border-bottom: 1px solid var(--rp-c-brand);
39
+ border-bottom: 1px solid currentColor;
40
40
  opacity: 0.85;
41
41
  }
42
42
  &[target='_blank'] {
@@ -174,22 +174,41 @@
174
174
 
175
175
  /* table */
176
176
  /* #region */
177
+ &:where(.rp-table-scroll-container) {
178
+ overflow-x: auto;
179
+ }
177
180
  &:where(table) {
178
181
  width: 100%;
182
+
183
+ table-layout: auto;
184
+ border-collapse: separate;
185
+ border-spacing: 0;
186
+
187
+ border: 1px solid var(--rp-c-divider-light);
179
188
  border-radius: var(--rp-radius);
180
189
  overflow: hidden;
181
- box-shadow: inset 0 0 0 0.5px var(--rp-c-divider-light);
182
- outline: 1px solid var(--rp-c-divider-light);
190
+
191
+ &::-webkit-scrollbar {
192
+ height: 5px;
193
+ width: 5px;
194
+ }
195
+ &::-webkit-scrollbar-corner {
196
+ display: none;
197
+ }
198
+ &::-webkit-scrollbar-thumb {
199
+ background-color: rgba(0, 0, 0, 0.05);
200
+ border-radius: 10px;
201
+ }
183
202
  }
184
203
 
185
204
  /* thead */
186
205
  &:where(thead) {
187
206
  color: var(--rp-c-text-0);
188
- background: var(--rp-c-bg-soft);
207
+ background: var(--rp-code-title-bg);
189
208
  }
190
209
 
191
210
  &:where(th) {
192
- padding: 1rem 2rem;
211
+ padding: 0.75rem 1.25rem;
193
212
  font-weight: 600;
194
213
  font-size: 0.875rem;
195
214
  text-align: left;
@@ -199,11 +218,11 @@
199
218
 
200
219
  /* tbody */
201
220
  &:where(tbody) {
202
- background: transparent;
221
+ background: var(--rp-c-bg);
203
222
  }
204
223
 
205
224
  &:where(td) {
206
- padding: 1rem 1.5rem;
225
+ padding: 0.75rem 1.25rem;
207
226
  border-bottom: 1px solid var(--rp-c-divider-light);
208
227
 
209
228
  font-size: 0.875rem;
@@ -235,6 +254,7 @@
235
254
  padding: 3px 6px;
236
255
  border-radius: var(--rp-radius-small);
237
256
  background-color: var(--rp-c-text-code-bg);
257
+ border: 1px solid var(--rp-c-text-code-border);
238
258
  overflow-wrap: break-word;
239
259
  }
240
260
  &:where(:not(pre, a) > code) {
@@ -1,8 +1,14 @@
1
- import type { ComponentProps } from 'react';
1
+ import { type ComponentProps, forwardRef } from 'react';
2
2
 
3
- export const Table = (props: ComponentProps<'table'>) => {
4
- return <table {...props} />;
5
- };
3
+ export const Table = forwardRef<HTMLTableElement, ComponentProps<'table'>>(
4
+ (props, ref) => {
5
+ return (
6
+ <div className="rp-table-scroll-container rp-scrollbar">
7
+ <table ref={ref} {...props} />
8
+ </div>
9
+ );
10
+ },
11
+ );
6
12
 
7
13
  export const Tr = (props: ComponentProps<'tr'>) => {
8
14
  return <tr {...props} />;
@@ -1,9 +1,9 @@
1
1
  import { MDXProvider } from '@mdx-js/react';
2
2
  import { Content, usePage, useSite } from '@rspress/core/runtime';
3
- import { Callout, getCustomMDXComponent } from '@theme';
4
- import './doc.scss';
3
+ import { Callout, FallbackHeading, getCustomMDXComponent } from '@theme';
5
4
  import { useScrollAfterNav } from '../../logic/useScrollAfterNav';
6
- import { FallbackHeading } from './FallbackHeading';
5
+
6
+ import './doc.scss';
7
7
 
8
8
  export function FallbackTitle() {
9
9
  const { site } = useSite();
@@ -1,15 +1,17 @@
1
- import { renderInlineMarkdown } from '@theme';
1
+ import { getCustomMDXComponent, renderInlineMarkdown } from '@theme';
2
2
  import { slug } from 'github-slugger';
3
- import { A } from './docComponents/a';
4
- import { H1, H2, H3, H4, H5, H6 } from './docComponents/title';
3
+ import { useMemo } from 'react';
5
4
 
6
- const HEADING_MAP = {
7
- 1: H1,
8
- 2: H2,
9
- 3: H3,
10
- 4: H4,
11
- 5: H5,
12
- 6: H6,
5
+ const getHeadingMap = () => {
6
+ const { h1, h2, h3, h4, h5, h6 } = getCustomMDXComponent();
7
+ return {
8
+ 1: h1,
9
+ 2: h2,
10
+ 3: h3,
11
+ 4: h4,
12
+ 5: h5,
13
+ 6: h6,
14
+ };
13
15
  };
14
16
 
15
17
  /**
@@ -28,7 +30,14 @@ export function FallbackHeading({
28
30
  }) {
29
31
  const titleSlug = title && slug(title.trim());
30
32
 
31
- const Element = HEADING_MAP[level] || H1;
33
+ const Element = useMemo(() => {
34
+ const headingMap = getHeadingMap();
35
+ return headingMap[level] || headingMap[1];
36
+ }, [level]);
37
+
38
+ const A = useMemo(() => {
39
+ return getCustomMDXComponent().a;
40
+ }, []);
32
41
 
33
42
  return (
34
43
  titleSlug && (