@rspress/core 2.0.12 → 2.0.14

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 (133) hide show
  1. package/dist/0~execa.js +1 -1
  2. package/dist/0~rslib-runtime.js +9 -5
  3. package/dist/{2235.js → 4942.js} +12 -9
  4. package/dist/{8857.js → 5580.js} +3 -3
  5. package/dist/6646.js +3 -0
  6. package/dist/{1688.js → 7261.js} +6 -1
  7. package/dist/{8006.js → 7986.js} +1 -6
  8. package/dist/cli/index.js +4 -4
  9. package/dist/config/loadConfigFile.js +1 -1
  10. package/dist/eject-theme/components/Banner/index.scss +11 -0
  11. package/dist/eject-theme/components/Banner/index.tsx +5 -1
  12. package/dist/eject-theme/components/CodeBlock/index.test.tsx +49 -0
  13. package/dist/eject-theme/components/CodeBlock/index.tsx +1 -1
  14. package/dist/eject-theme/components/CodeButtonGroup/index.tsx +5 -2
  15. package/dist/eject-theme/components/FallbackHeading/index.test.tsx +45 -0
  16. package/dist/eject-theme/components/FallbackHeading/index.tsx +1 -1
  17. package/dist/eject-theme/components/Link/index.tsx +6 -0
  18. package/dist/eject-theme/components/Link/useLinkNavigate.ts +2 -2
  19. package/dist/eject-theme/components/Outline/index.tsx +0 -6
  20. package/dist/eject-theme/components/Overview/index.test.tsx +57 -0
  21. package/dist/eject-theme/components/Overview/index.tsx +1 -1
  22. package/dist/eject-theme/components/OverviewGroup/index.test.tsx +61 -0
  23. package/dist/eject-theme/components/OverviewGroup/index.tsx +1 -1
  24. package/dist/eject-theme/components/PackageManagerTabs/index.test.tsx +54 -0
  25. package/dist/eject-theme/components/PackageManagerTabs/index.tsx +1 -1
  26. package/dist/eject-theme/components/Search/SearchPanel.tsx +1 -0
  27. package/dist/eject-theme/components/Search/logic/search.ts +15 -16
  28. package/dist/eject-theme/components/SidebarMenu/index.tsx +10 -3
  29. package/dist/eject-theme/components/SidebarMenu/useSidebarMenu.tsx +12 -3
  30. package/dist/eject-theme/components/SocialLinks/GithubStars.tsx +120 -0
  31. package/dist/eject-theme/components/SocialLinks/SocialLink.tsx +5 -0
  32. package/dist/eject-theme/components/SocialLinks/index.scss +17 -0
  33. package/dist/eject-theme/components/Steps/index.scss +6 -4
  34. package/dist/eject-theme/components/Tabs/index.test.tsx +51 -0
  35. package/dist/eject-theme/components/Tabs/index.tsx +1 -1
  36. package/dist/eject-theme/components/Tag/index.test.tsx +55 -0
  37. package/dist/eject-theme/components/Tag/index.tsx +19 -5
  38. package/dist/index.js +1 -1
  39. package/dist/node/PluginDriver.js +1 -1
  40. package/dist/node/auto-nav-sidebar/index.js +1 -1
  41. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  42. package/dist/node/auto-nav-sidebar/normalize.js +3 -4
  43. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  44. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  45. package/dist/node/constants.js +3 -3
  46. package/dist/node/eject.js +2 -2
  47. package/dist/node/initRsbuild.js +20 -14
  48. package/dist/node/logger/hint.js +1 -1
  49. package/dist/node/mdx/options.js +1 -1
  50. package/dist/node/mdx/processor.js +1 -1
  51. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  52. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
  53. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  54. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  55. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +2 -2
  56. package/dist/node/mdx/remarkPlugins/image.js +3 -4
  57. package/dist/node/mdx/remarkPlugins/link.js +2 -2
  58. package/dist/node/mdx/remarkPlugins/toc.js +1 -1
  59. package/dist/node/medium-zoom/index.js +1 -1
  60. package/dist/node/route/RoutePage.js +1 -1
  61. package/dist/node/route/RouteService.js +2 -3
  62. package/dist/node/route/extractPageData.js +1 -1
  63. package/dist/node/route/normalizeRoutePath.js +1 -1
  64. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +119 -112
  65. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +7 -0
  66. package/dist/node/runtimeModule/i18n.js +2 -2
  67. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  68. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  69. package/dist/node/runtimeModule/searchHooks.js +1 -1
  70. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  71. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  72. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +33 -9
  73. package/dist/node/serve.js +1 -1
  74. package/dist/node/ssg/htmlFile.d.ts +2 -0
  75. package/dist/node/ssg/htmlFile.js +14 -0
  76. package/dist/node/ssg/renderPage.js +2 -2
  77. package/dist/node/ssg/renderPageWorker.d.ts +3 -6
  78. package/dist/node/ssg/renderPageWorker.js +24 -4
  79. package/dist/node/ssg/renderPages.d.ts +1 -1
  80. package/dist/node/ssg/renderPages.js +19 -18
  81. package/dist/node/ssg/rsbuildPluginSSG.js +2 -2
  82. package/dist/node/ssg/ssgEnv.js +1 -1
  83. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  84. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  85. package/dist/node/ssg-md/remarkSplitMdx.js +1 -1
  86. package/dist/node/ssg-md/renderPage.js +2 -2
  87. package/dist/node/ssg-md/renderPages.js +3 -3
  88. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  89. package/dist/node/utils/checkLanguageParity.js +1 -1
  90. package/dist/node/utils/createHash.js +1 -1
  91. package/dist/node/utils/error.js +1 -1
  92. package/dist/node/utils/flattenMdxContent.js +1 -1
  93. package/dist/node/utils/fs.js +1 -1
  94. package/dist/node/utils/getPageKey.js +1 -1
  95. package/dist/node/utils/normalizePath.js +1 -1
  96. package/dist/node/utils/reactAlias.js +2 -2
  97. package/dist/runtime/App.js +1 -1
  98. package/dist/theme/components/Banner/index.css +11 -0
  99. package/dist/theme/components/Banner/index.js +1 -0
  100. package/dist/theme/components/CodeBlock/index.js +1 -1
  101. package/dist/theme/components/CodeButtonGroup/index.js +4 -2
  102. package/dist/theme/components/FallbackHeading/index.js +1 -1
  103. package/dist/theme/components/Link/index.js +6 -0
  104. package/dist/theme/components/Link/useLinkNavigate.js +2 -2
  105. package/dist/theme/components/Outline/index.js +1 -3
  106. package/dist/theme/components/Overview/index.js +1 -1
  107. package/dist/theme/components/OverviewGroup/index.js +1 -1
  108. package/dist/theme/components/PackageManagerTabs/index.js +1 -1
  109. package/dist/theme/components/Search/SearchPanel.js +1 -0
  110. package/dist/theme/components/Search/logic/search.js +12 -7
  111. package/dist/theme/components/SidebarMenu/index.d.ts +3 -0
  112. package/dist/theme/components/SidebarMenu/index.js +4 -3
  113. package/dist/theme/components/SidebarMenu/useSidebarMenu.d.ts +2 -1
  114. package/dist/theme/components/SidebarMenu/useSidebarMenu.js +7 -3
  115. package/dist/theme/components/SocialLinks/GithubStars.d.ts +7 -0
  116. package/dist/theme/components/SocialLinks/GithubStars.js +85 -0
  117. package/dist/theme/components/SocialLinks/SocialLink.js +5 -0
  118. package/dist/theme/components/SocialLinks/index.css +19 -0
  119. package/dist/theme/components/Steps/index.css +6 -4
  120. package/dist/theme/components/Tabs/index.js +1 -1
  121. package/dist/theme/components/Tag/index.js +9 -5
  122. package/dist/theme/layout/DocLayout/index.js +2 -2
  123. package/dist/theme/layout/HomeLayout/index.js +1 -1
  124. package/dist/theme/layout/Layout/index.js +1 -1
  125. package/package.json +13 -14
  126. package/dist/9224.js +0 -1
  127. package/dist/runtime/BrowserOnly.test.d.ts +0 -1
  128. /package/dist/{0~1402.js → 0~8787.js} +0 -0
  129. /package/dist/{3323.js → 3358.js} +0 -0
  130. /package/dist/{8857.js.LICENSE.txt → 5580.js.LICENSE.txt} +0 -0
  131. /package/dist/{3294.js → 8005.js} +0 -0
  132. /package/dist/{6162.js → 9283.js} +0 -0
  133. /package/dist/{8474.js → 9882.js} +0 -0
package/dist/0~execa.js CHANGED
@@ -8,7 +8,7 @@ import { createReadStream, createWriteStream, readFileSync } from "node:fs";
8
8
  import { setTimeout as promises_setTimeout } from "node:timers/promises";
9
9
  import { debuglog } from "node:util";
10
10
  import { __webpack_require__ } from "./0~rslib-runtime.js";
11
- import "./2235.js";
11
+ import "./4942.js";
12
12
  __webpack_require__.add({
13
13
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js" (module, __unused_rspack_exports, __webpack_require__) {
14
14
  const cp = __webpack_require__("child_process");
@@ -20,11 +20,15 @@ __webpack_require__.m = __webpack_modules__;
20
20
  };
21
21
  })();
22
22
  (()=>{
23
- __webpack_require__.d = (exports, definition)=>{
24
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
25
- enumerable: true,
26
- get: definition[key]
27
- });
23
+ __webpack_require__.d = (exports, getters, values)=>{
24
+ var define = (defs, kind)=>{
25
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ [kind]: defs[key]
28
+ });
29
+ };
30
+ define(getters, "get");
31
+ define(values, "value");
28
32
  };
29
33
  })();
30
34
  (()=>{
@@ -2128,6 +2128,7 @@ var Builder = class {
2128
2128
  const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js");
2129
2129
  const isReadonlyArray = Array.isArray;
2130
2130
  const BACKSLASHES = /\\/g;
2131
+ const DRIVE_RELATIVE_PATH = /^[A-Za-z]:$/;
2131
2132
  const isWin = "win32" === process.platform;
2132
2133
  const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
2133
2134
  function getPartialMatcher(patterns, options = {}) {
@@ -2193,6 +2194,9 @@ function buildRelative(cwd, root) {
2193
2194
  return "/" === p[p.length - 1] && "" !== result ? `${result}/` : result || ".";
2194
2195
  };
2195
2196
  }
2197
+ function ensureNonDriveRelativePath(path) {
2198
+ return path.replace(DRIVE_RELATIVE_PATH, (match)=>`${match}/`);
2199
+ }
2196
2200
  const splitPatternOptions = {
2197
2201
  parts: true
2198
2202
  };
@@ -2243,7 +2247,7 @@ function normalizePattern(pattern, opts, props, isIgnore) {
2243
2247
  }
2244
2248
  const potentialRoot = posix.join(cwd, parentDir.slice(3 * i));
2245
2249
  if ("." !== potentialRoot[0] && props.root.length > potentialRoot.length) {
2246
- props.root = potentialRoot;
2250
+ props.root = ensureNonDriveRelativePath(potentialRoot);
2247
2251
  props.depthOffset = -n + i;
2248
2252
  }
2249
2253
  }
@@ -2262,7 +2266,7 @@ function normalizePattern(pattern, opts, props, isIgnore) {
2262
2266
  }
2263
2267
  props.depthOffset = newCommonPath.length;
2264
2268
  props.commonPath = newCommonPath;
2265
- props.root = newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd;
2269
+ props.root = ensureNonDriveRelativePath(newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd);
2266
2270
  }
2267
2271
  return result;
2268
2272
  }
@@ -2354,18 +2358,17 @@ function formatPaths(paths, mapper) {
2354
2358
  }
2355
2359
  const defaultOptions = {
2356
2360
  caseSensitiveMatch: true,
2357
- cwd: process.cwd(),
2358
2361
  debug: !!process.env.TINYGLOBBY_DEBUG,
2359
2362
  expandDirectories: true,
2360
2363
  followSymbolicLinks: true,
2361
2364
  onlyFiles: true
2362
2365
  };
2363
2366
  function getOptions(options) {
2364
- const opts = {
2365
- ...defaultOptions,
2366
- ...options
2367
- };
2368
- opts.cwd = (opts.cwd instanceof URL ? fileURLToPath(opts.cwd) : resolve(opts.cwd)).replace(BACKSLASHES, "/");
2367
+ const opts = Object.assign({}, options);
2368
+ for(const key in defaultOptions)if (void 0 === opts[key]) Object.assign(opts, {
2369
+ [key]: defaultOptions[key]
2370
+ });
2371
+ opts.cwd = (opts.cwd instanceof URL ? fileURLToPath(opts.cwd) : resolve(opts.cwd || process.cwd())).replace(BACKSLASHES, "/");
2369
2372
  opts.ignore = ensureStringArray(opts.ignore);
2370
2373
  opts.fs && (opts.fs = {
2371
2374
  readdir: opts.fs.readdir || readdir,
@@ -2436,7 +2439,7 @@ const pluginVirtualModule = (pluginOptions = {})=>({
2436
2439
  });
2437
2440
  export { DEFAULT_PAGE_EXTENSIONS } from "@rspress/shared/constants";
2438
2441
  export { default as promises, mkdir, readdir as promises_readdir, rm, stat as promises_stat, writeFile } from "node:fs/promises";
2439
- export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, normalizeHref, removeLeadingSlash, removeTrailingSlash, slash, withBase } from "@rspress/shared";
2442
+ export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, normalizeHref, removeLeadingSlash, removeTrailingSlash, slash, withBase } from "@rspress/shared";
2440
2443
  export { logger } from "@rspress/shared/logger";
2441
2444
  export { extractTextAndId, getIconUrlPath, loadFrontMatter } from "@rspress/shared/node-utils";
2442
2445
  export { createRequire as external_node_module_createRequire } from "node:module";
@@ -1,6 +1,6 @@
1
- /*! LICENSE: 8857.js.LICENSE.txt */
1
+ /*! LICENSE: 5580.js.LICENSE.txt */
2
2
  import { __webpack_require__ } from "./0~rslib-runtime.js";
3
- import "./2235.js";
3
+ import "./4942.js";
4
4
  import { createRequire as __rspack_createRequire } from "node:module";
5
5
  const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
6
6
  __webpack_require__.add({
@@ -4268,7 +4268,7 @@ __webpack_require__.add({
4268
4268
  module.exports = __rspack_createRequire_require("util");
4269
4269
  },
4270
4270
  "../../node_modules/.pnpm/binary-extensions@2.3.0/node_modules/binary-extensions/binary-extensions.json" (module) {
4271
- module.exports = JSON.parse('["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]');
4271
+ module.exports = /*#__PURE__*/ JSON.parse('["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]');
4272
4272
  }
4273
4273
  });
4274
4274
  function toArr(any) {
package/dist/6646.js ADDED
@@ -0,0 +1,3 @@
1
+ export { mkdir, writeFile } from "node:fs/promises";
2
+ export { dirname } from "node:path";
3
+ export { workerData } from "node:worker_threads";
@@ -1,3 +1,6 @@
1
+ var package_namespaceObject = {
2
+ rE: "2.0.14"
3
+ };
1
4
  async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true, signal } = {}) {
2
5
  return new Promise((resolve_, reject_)=>{
3
6
  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})`);
@@ -89,7 +92,9 @@ async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true,
89
92
  });
90
93
  }
91
94
  const pMapSkip = Symbol('skip');
95
+ export { createRequire } from "node:module";
96
+ export { default as node_path, isAbsolute, relative, resolve as external_node_path_resolve } from "node:path";
92
97
  export { pathToFileURL } from "node:url";
93
98
  export { logger } from "@rspress/shared/logger";
94
99
  export { createHead, transformHtmlTemplate } from "@unhead/react/server";
95
- export { pMap };
100
+ export { pMap, package_namespaceObject };
@@ -67,11 +67,6 @@ __webpack_require__.add({
67
67
  module.exports.createColors = createColors;
68
68
  }
69
69
  });
70
- var package_namespaceObject = {
71
- rE: "2.0.12"
72
- };
73
70
  export { default as promises, readFile } from "node:fs/promises";
74
- export { default as node_path, join, relative } from "node:path";
71
+ export { join, relative } from "node:path";
75
72
  export { logger } from "@rspress/shared/logger";
76
- export { createRequire } from "node:module";
77
- export { package_namespaceObject };
package/dist/cli/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { __webpack_require__ } from "../0~rslib-runtime.js";
2
- import { node_path, logger, join, cac } from "../8857.js";
3
- import { package_namespaceObject } from "../8006.js";
2
+ import { node_path, logger, join, cac } from "../5580.js";
3
+ import "../7986.js";
4
+ import { package_namespaceObject } from "../7261.js";
4
5
  import { loadConfigFile, resolveDocRoot } from "../config/loadConfigFile.js";
5
6
  import { dev } from "../node/dev.js";
6
- import { PUBLIC_DIR } from "../node/constants.js";
7
7
  import { build } from "../node/build.js";
8
8
  import { serve } from "../node/serve.js";
9
9
  import { listComponents, ejectComponent } from "../node/eject.js";
@@ -54,7 +54,7 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
54
54
  '**/node_modules/**',
55
55
  '**/.git/**',
56
56
  '**/.DS_Store/**',
57
- join(docDirectory, PUBLIC_DIR)
57
+ join(docDirectory, "public")
58
58
  ]
59
59
  });
60
60
  cliWatcher.on('all', async (eventName, filepath)=>{
@@ -1,4 +1,4 @@
1
- import { node_fs, node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../8857.js";
1
+ import { node_fs, node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../5580.js";
2
2
  const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(node_fs.existsSync);
3
3
  async function loadConfigFile(customConfigFile) {
4
4
  const baseDir = process.cwd();
@@ -17,11 +17,22 @@
17
17
  z-index: 999;
18
18
  background: var(--rp-banner-background);
19
19
  height: 36px;
20
+ box-sizing: border-box;
21
+ padding: 0 3.5rem;
20
22
 
21
23
  &__link {
24
+ display: block;
25
+ flex: 1 1 auto;
26
+ min-width: 0;
27
+ max-width: 100%;
28
+ overflow: hidden;
22
29
  color: #fff;
23
30
  font-weight: 700;
31
+ line-height: 36px;
32
+ text-align: center;
24
33
  text-decoration: none;
34
+ text-overflow: ellipsis;
35
+ white-space: nowrap;
25
36
 
26
37
  &:hover {
27
38
  text-decoration: underline;
@@ -97,7 +97,11 @@ export const Banner = forwardRef<HTMLDivElement, BannerProps>(
97
97
  <div className={clsx('rp-banner', className)} ref={ref}>
98
98
  {customChildren ?? (
99
99
  <>
100
- <Link href={href} className="rp-banner__link">
100
+ <Link
101
+ href={href}
102
+ className="rp-banner__link"
103
+ title={typeof message === 'string' ? message : undefined}
104
+ >
101
105
  {message}
102
106
  </Link>
103
107
  <SvgWrapper
@@ -0,0 +1,49 @@
1
+ import { afterEach, describe, expect, it, rs } from '@rstest/core';
2
+ import { renderToMarkdownString } from 'react-render-to-markdown';
3
+ import { CodeBlock } from './index';
4
+
5
+ rs.mock('@rspress/core/theme', () => ({
6
+ CodeButtonGroup: () => null,
7
+ IconArrowDown: () => null,
8
+ SvgWrapper: () => null,
9
+ useCodeButtonGroup: () => ({
10
+ copyElementRef: { current: null },
11
+ toggleWrapCode: () => {},
12
+ wrapCode: false,
13
+ }),
14
+ }));
15
+
16
+ const originalSsgMd = import.meta.env.SSG_MD;
17
+
18
+ const setSsgMd = (value: boolean | undefined) => {
19
+ if (value === undefined) {
20
+ delete (import.meta.env as unknown as Record<string, unknown>).SSG_MD;
21
+ return;
22
+ }
23
+
24
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = value;
25
+ };
26
+
27
+ afterEach(() => {
28
+ setSsgMd(originalSsgMd);
29
+ });
30
+
31
+ describe('CodeBlock', () => {
32
+ it('renders only its children when SSG_MD is enabled', async () => {
33
+ setSsgMd(true);
34
+
35
+ expect(
36
+ await renderToMarkdownString(
37
+ <CodeBlock title="example.ts">
38
+ <pre>const value = true;</pre>
39
+ </CodeBlock>,
40
+ ),
41
+ ).toMatchInlineSnapshot(`
42
+ "
43
+ \`\`\`\`
44
+ const value = true;
45
+ \`\`\`\`
46
+ "
47
+ `);
48
+ });
49
+ });
@@ -81,7 +81,7 @@ export function CodeBlock({
81
81
  codeButtonGroupProps,
82
82
  children,
83
83
  }: CodeBlockProps) {
84
- if (process.env.__SSR_MD__) {
84
+ if (import.meta.env.SSG_MD) {
85
85
  return <>{children}</>;
86
86
  }
87
87
 
@@ -1,4 +1,4 @@
1
- import { useSite } from '@rspress/core/runtime';
1
+ import { useI18n, useSite } from '@rspress/core/runtime';
2
2
  import { IconWrap, IconWrapped, SvgWrapper } from '@rspress/core/theme';
3
3
  import clsx from 'clsx';
4
4
  import { useRef, useState } from 'react';
@@ -43,6 +43,8 @@ export function CodeButtonGroup({
43
43
  showWrapCodeButton = true,
44
44
  showCopyButton = true,
45
45
  }: CodeButtonGroupProps) {
46
+ const t = useI18n();
47
+
46
48
  return (
47
49
  <>
48
50
  <div className="rp-code-button-group">
@@ -54,7 +56,8 @@ export function CodeButtonGroup({
54
56
  wrapCode && 'rp-code-wrap-button--wrapped',
55
57
  )}
56
58
  onClick={() => toggleWrapCode()}
57
- title="Toggle code wrap"
59
+ title={t('codeButtonGroupWrapButtonText')}
60
+ aria-label={t('codeButtonGroupWrapButtonText')}
58
61
  >
59
62
  <SvgWrapper
60
63
  icon={IconWrapped}
@@ -0,0 +1,45 @@
1
+ import { afterEach, describe, expect, it, rs } from '@rstest/core';
2
+ import { renderToMarkdownString } from 'react-render-to-markdown';
3
+ import { FallbackHeading } from './index';
4
+
5
+ rs.mock('@rspress/core/theme', () => ({
6
+ getCustomMDXComponent: () => ({
7
+ a: 'a',
8
+ h1: 'h1',
9
+ h2: 'h2',
10
+ h3: 'h3',
11
+ h4: 'h4',
12
+ h5: 'h5',
13
+ h6: 'h6',
14
+ }),
15
+ renderInlineMarkdown: (text: string) => ({
16
+ dangerouslySetInnerHTML: { __html: text },
17
+ }),
18
+ }));
19
+
20
+ const originalSsgMd = import.meta.env.SSG_MD;
21
+
22
+ const setSsgMd = (value: boolean | undefined) => {
23
+ if (value === undefined) {
24
+ delete (import.meta.env as unknown as Record<string, unknown>).SSG_MD;
25
+ return;
26
+ }
27
+
28
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = value;
29
+ };
30
+
31
+ afterEach(() => {
32
+ setSsgMd(originalSsgMd);
33
+ });
34
+
35
+ describe('FallbackHeading', () => {
36
+ it('renders markdown when SSG_MD is enabled', async () => {
37
+ setSsgMd(true);
38
+
39
+ expect(
40
+ await renderToMarkdownString(
41
+ <FallbackHeading level={2} title="Getting Started" />,
42
+ ),
43
+ ).toBe('## Getting Started\n\n');
44
+ });
45
+ });
@@ -31,7 +31,7 @@ export function FallbackHeading({
31
31
  level: 1 | 2 | 3 | 4 | 5 | 6;
32
32
  title: string;
33
33
  }) {
34
- if (process.env.__SSR_MD__) {
34
+ if (import.meta.env.SSG_MD) {
35
35
  return <>{`${'#'.repeat(level)} ${title}\n\n`}</>;
36
36
  }
37
37
 
@@ -100,6 +100,9 @@ export const Link = forwardRef<HTMLAnchorElement, LinkProps>((props, ref) => {
100
100
  onMouseEnter?.(event);
101
101
  preloadLink(removeBaseHref);
102
102
  }}
103
+ onTouchStart={() => {
104
+ preloadLink(removeBaseHref);
105
+ }}
103
106
  onClick={e => {
104
107
  onClick?.(e);
105
108
  if (
@@ -134,6 +137,9 @@ export const Link = forwardRef<HTMLAnchorElement, LinkProps>((props, ref) => {
134
137
  onMouseEnter?.(event);
135
138
  preloadLink(removeBaseHref);
136
139
  }}
140
+ onTouchStart={() => {
141
+ preloadLink(removeBaseHref);
142
+ }}
137
143
  onClick={e => {
138
144
  onClick?.(e);
139
145
  if (
@@ -52,7 +52,7 @@ export function getHref(href: string): {
52
52
  return { linkType: linkType, withBaseHref: href, removeBaseHref: href };
53
53
  }
54
54
 
55
- if (linkType === 'relative' && !process.env.__SSR__) {
55
+ if (linkType === 'relative' && !import.meta.env.SSR) {
56
56
  withBaseHref = new URL(href, window.location.href).pathname;
57
57
  } else {
58
58
  withBaseHref = withBase(cleanUrlByConfig(href));
@@ -84,7 +84,7 @@ export function useLinkNavigate(
84
84
 
85
85
  const preloadChunkThenNavigate = async () => {
86
86
  const inCurrPage = isActive(removeBaseHref, currPagePathname);
87
- if (!process.env.__SSR__ && !inCurrPage) {
87
+ if (!import.meta.env.SSR && !inCurrPage) {
88
88
  const matchedRoute = pathnameToRouteService(removeBaseHref);
89
89
  if (matchedRoute) {
90
90
  const timer = setTimeout(() => {
@@ -5,7 +5,6 @@ import {
5
5
  LlmsOpenRow,
6
6
  ReadPercent,
7
7
  Toc,
8
- useDynamicToc,
9
8
  } from '@rspress/core/theme';
10
9
  import './index.scss';
11
10
  import { ScrollToTop } from './ScrollToTop';
@@ -13,17 +12,12 @@ import { ScrollToTop } from './ScrollToTop';
13
12
  export function Outline() {
14
13
  const t = useI18n();
15
14
 
16
- const headers = useDynamicToc();
17
15
  const {
18
16
  site: {
19
17
  themeConfig: { enableScrollToTop = true, llmsUI },
20
18
  },
21
19
  } = useSite();
22
20
 
23
- if (headers.length === 0) {
24
- return <></>;
25
- }
26
-
27
21
  const placement =
28
22
  typeof llmsUI === 'object' ? (llmsUI?.placement ?? 'title') : 'title';
29
23
 
@@ -0,0 +1,57 @@
1
+ import { afterEach, describe, expect, it, rs } from '@rstest/core';
2
+ import { renderToMarkdownString } from 'react-render-to-markdown';
3
+ import { Overview } from './index';
4
+
5
+ rs.mock('@rspress/core/runtime', () => ({
6
+ isEqualPath: (a: string, b: string) => a === b,
7
+ useI18n: () => (key: string) => key,
8
+ usePageData: () => ({
9
+ page: {
10
+ frontmatter: { overview: true },
11
+ routePath: '/guide/overview',
12
+ title: 'Guide Overview',
13
+ },
14
+ siteData: { pages: [] },
15
+ }),
16
+ useSidebar: () => [{ link: '/guide/overview', text: 'Overview' }],
17
+ }));
18
+
19
+ rs.mock('@rspress/core/theme', () => ({
20
+ FallbackHeading: ({ level, title }: { level: number; title: string }) =>
21
+ `${'#'.repeat(level)} ${title}\n\n`,
22
+ OverviewGroup: ({ group }: { group: { name: string } }) =>
23
+ `## ${group.name}\n\n`,
24
+ }));
25
+
26
+ const originalSsgMd = import.meta.env.SSG_MD;
27
+
28
+ const setSsgMd = (value: boolean | undefined) => {
29
+ if (value === undefined) {
30
+ delete (import.meta.env as unknown as Record<string, unknown>).SSG_MD;
31
+ return;
32
+ }
33
+
34
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = value;
35
+ };
36
+
37
+ afterEach(() => {
38
+ setSsgMd(originalSsgMd);
39
+ });
40
+
41
+ describe('Overview', () => {
42
+ it('renders heading and groups as markdown when SSG_MD is enabled', async () => {
43
+ setSsgMd(true);
44
+
45
+ expect(
46
+ await renderToMarkdownString(
47
+ <Overview groups={[{ name: 'Guides', items: [] }]} />,
48
+ ),
49
+ ).toMatchInlineSnapshot(`
50
+ "# Guide Overview
51
+
52
+ ## Guides
53
+
54
+ "
55
+ `);
56
+ });
57
+ });
@@ -242,7 +242,7 @@ export function Overview(props: {
242
242
 
243
243
  const overviewTitle = title || 'Overview';
244
244
 
245
- if (process.env.__SSR_MD__) {
245
+ if (import.meta.env.SSG_MD) {
246
246
  return (
247
247
  <>
248
248
  <FallbackHeading level={1} title={overviewTitle} />
@@ -0,0 +1,61 @@
1
+ import { afterEach, describe, expect, it, rs } from '@rstest/core';
2
+ import { renderToMarkdownString } from 'react-render-to-markdown';
3
+ import { OverviewGroup, type Group } from './index';
4
+
5
+ rs.mock('@rspress/core/runtime', () => ({
6
+ routePathToMdPath: (routePath: string) => `${routePath}.md`,
7
+ }));
8
+
9
+ rs.mock('@rspress/core/theme', () => ({
10
+ FallbackHeading: () => null,
11
+ Link: 'a',
12
+ SvgWrapper: () => null,
13
+ renderInlineMarkdown: (text: string) => ({
14
+ dangerouslySetInnerHTML: { __html: text },
15
+ }),
16
+ }));
17
+
18
+ const originalSsgMd = import.meta.env.SSG_MD;
19
+
20
+ const setSsgMd = (value: boolean | undefined) => {
21
+ if (value === undefined) {
22
+ delete (import.meta.env as unknown as Record<string, unknown>).SSG_MD;
23
+ return;
24
+ }
25
+
26
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = value;
27
+ };
28
+
29
+ afterEach(() => {
30
+ setSsgMd(originalSsgMd);
31
+ });
32
+
33
+ describe('OverviewGroup', () => {
34
+ it('renders overview links as markdown when SSG_MD is enabled', async () => {
35
+ setSsgMd(true);
36
+
37
+ const group: Group = {
38
+ name: 'Guide',
39
+ items: [
40
+ {
41
+ text: 'Introduction',
42
+ link: '/guide/introduction',
43
+ headers: [{ id: 'install', text: 'Install', depth: 2 }],
44
+ items: [{ text: 'Configuration', link: '/guide/configuration' }],
45
+ },
46
+ ],
47
+ };
48
+
49
+ expect(await renderToMarkdownString(<OverviewGroup group={group} />))
50
+ .toMatchInlineSnapshot(`
51
+ "## Guide
52
+
53
+ ### [Introduction](/guide/introduction.md)
54
+
55
+ - [Install](/guide/introduction.md#install)
56
+
57
+ - [Configuration](/guide/configuration.md)
58
+ "
59
+ `);
60
+ });
61
+ });
@@ -62,7 +62,7 @@ export interface Group {
62
62
  }
63
63
 
64
64
  export const OverviewGroup = ({ group }: { group: Group }) => {
65
- if (process.env.__SSR_MD__) {
65
+ if (import.meta.env.SSG_MD) {
66
66
  return <OverviewGroupMarkdown group={group} />;
67
67
  }
68
68
 
@@ -0,0 +1,54 @@
1
+ import { afterEach, describe, expect, it, rs } from '@rstest/core';
2
+ import type { ReactNode } from 'react';
3
+ import { renderToMarkdownString } from 'react-render-to-markdown';
4
+ import { PackageManagerTabs } from './index';
5
+
6
+ rs.mock('@rspress/core/theme', () => ({
7
+ getCustomMDXComponent: () => ({
8
+ pre: 'pre',
9
+ }),
10
+ Tab: ({ children }: { children: ReactNode }) => children,
11
+ Tabs: ({ children }: { children: ReactNode }) => children,
12
+ }));
13
+
14
+ const originalSsgMd = import.meta.env.SSG_MD;
15
+
16
+ const setSsgMd = (value: boolean | undefined) => {
17
+ if (value === undefined) {
18
+ delete (import.meta.env as unknown as Record<string, unknown>).SSG_MD;
19
+ return;
20
+ }
21
+
22
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = value;
23
+ };
24
+
25
+ afterEach(() => {
26
+ setSsgMd(originalSsgMd);
27
+ });
28
+
29
+ describe('PackageManagerTabs', () => {
30
+ it('renders install commands as markdown code fences when SSG_MD is enabled', async () => {
31
+ setSsgMd(true);
32
+
33
+ expect(
34
+ await renderToMarkdownString(
35
+ <PackageManagerTabs
36
+ command={{
37
+ npm: 'npm install rspress',
38
+ pnpm: 'pnpm add rspress',
39
+ }}
40
+ />,
41
+ ),
42
+ ).toMatchInlineSnapshot(`
43
+ "
44
+ \`\`\`sh [npm]
45
+ npm install rspress
46
+ \`\`\`
47
+
48
+ \`\`\`sh [pnpm]
49
+ pnpm add rspress
50
+ \`\`\`
51
+ "
52
+ `);
53
+ });
54
+ });
@@ -218,7 +218,7 @@ export function PackageManagerTabs({
218
218
  commandInfo = command;
219
219
  }
220
220
 
221
- if (process.env.__SSR_MD__) {
221
+ if (import.meta.env.SSG_MD) {
222
222
  return Object.values(commandInfo).reduce((previous, current) => {
223
223
  const [packageManager, command] = splitTo2Parts(current);
224
224
  return (
@@ -511,6 +511,7 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
511
511
  aria-label="SearchPanelInput"
512
512
  autoComplete="off"
513
513
  autoFocus
514
+ inputMode="search"
514
515
  onChange={e => handleQueryChange(e.target.value)}
515
516
  />
516
517
  <label>