@rspress/core 2.0.8 → 2.0.10

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 (127) hide show
  1. package/dist/0~execa.js +8 -8
  2. package/dist/0~rslib-runtime.js +20 -0
  3. package/dist/0~tinypool.js +828 -0
  4. package/dist/{8311.js → 1688.js} +1 -7
  5. package/dist/{7397.js → 2240.js} +4 -2
  6. package/dist/2287.js +2458 -0
  7. package/dist/{1361.js → 3294.js} +1 -1
  8. package/dist/{1965.js → 3425.js} +0 -1
  9. package/dist/8006.js +77 -0
  10. package/dist/8857.js +4826 -0
  11. package/dist/8857.js.LICENSE.txt +41 -0
  12. package/dist/cli/index.js +14 -7
  13. package/dist/config/loadConfigFile.js +1 -1
  14. package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.scss +1 -1
  15. package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.tsx +17 -21
  16. package/dist/eject-theme/components/CodeButtonGroup/index.scss +1 -1
  17. package/dist/eject-theme/components/DocContent/doc.scss +16 -41
  18. package/dist/eject-theme/components/FallbackHeading/index.tsx +1 -1
  19. package/dist/eject-theme/components/Link/useLinkNavigate.ts +4 -1
  20. package/dist/eject-theme/components/Llms/LlmsCopyButton.scss +3 -3
  21. package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +13 -6
  22. package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +13 -5
  23. package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +7 -3
  24. package/dist/eject-theme/components/Outline/index.scss +1 -1
  25. package/dist/eject-theme/components/Prompt/icons.tsx +80 -0
  26. package/dist/eject-theme/components/Prompt/index.scss +478 -0
  27. package/dist/eject-theme/components/Prompt/index.tsx +335 -0
  28. package/dist/eject-theme/components/Search/SearchPanel.tsx +1 -1
  29. package/dist/eject-theme/components/SidebarMenu/index.tsx +5 -1
  30. package/dist/eject-theme/components/Steps/index.scss +32 -13
  31. package/dist/node/PluginDriver.js +1 -1
  32. package/dist/node/auto-nav-sidebar/index.js +1 -1
  33. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  34. package/dist/node/auto-nav-sidebar/normalize.js +10 -6
  35. package/dist/node/auto-nav-sidebar/utils.js +8 -2
  36. package/dist/node/auto-nav-sidebar/walk.js +2 -8
  37. package/dist/node/constants.js +1 -1
  38. package/dist/node/eject.js +12 -7
  39. package/dist/node/initRsbuild.js +6 -6
  40. package/dist/node/logger/hint.js +9 -6
  41. package/dist/node/mdx/options.js +13 -2
  42. package/dist/node/mdx/processor.js +1 -1
  43. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  44. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
  45. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  46. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  47. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +6 -2
  48. package/dist/node/mdx/remarkPlugins/image.d.ts +7 -2
  49. package/dist/node/mdx/remarkPlugins/image.js +51 -2
  50. package/dist/node/mdx/remarkPlugins/link.js +7 -3
  51. package/dist/node/mdx/remarkPlugins/toc.js +1 -1
  52. package/dist/node/route/RoutePage.js +1 -1
  53. package/dist/node/route/RouteService.js +1 -1
  54. package/dist/node/route/extractPageData.js +75 -26
  55. package/dist/node/route/normalizeRoutePath.js +1 -1
  56. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +28 -0
  57. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +28 -0
  58. package/dist/node/runtimeModule/i18n.js +10 -6
  59. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  60. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  61. package/dist/node/runtimeModule/searchHooks.js +1 -1
  62. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  63. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  64. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  65. package/dist/node/serve.js +1 -1
  66. package/dist/node/ssg/renderPage.js +8 -4
  67. package/dist/node/ssg/renderPageWorker.js +1 -1
  68. package/dist/node/ssg/renderPages.js +9 -5
  69. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  70. package/dist/node/ssg/ssgEnv.js +1 -1
  71. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  72. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  73. package/dist/node/ssg-md/remarkSplitMdx.js +1 -1
  74. package/dist/node/ssg-md/renderPage.js +8 -4
  75. package/dist/node/ssg-md/renderPages.js +7 -3
  76. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  77. package/dist/node/utils/checkLanguageParity.js +1 -1
  78. package/dist/node/utils/createHash.js +1 -1
  79. package/dist/node/utils/error.js +5 -2
  80. package/dist/node/utils/flattenMdxContent.js +1 -1
  81. package/dist/node/utils/fs.js +1 -1
  82. package/dist/node/utils/getPageKey.js +1 -1
  83. package/dist/node/utils/normalizePath.js +1 -1
  84. package/dist/node/utils/reactAlias.js +7 -3
  85. package/dist/runtime/App.js +4 -1
  86. package/dist/runtime/index.d.ts +2 -1
  87. package/dist/runtime/index.js +2 -1
  88. package/dist/runtime/initPageData.d.ts +3 -0
  89. package/dist/runtime/initPageData.js +37 -2
  90. package/dist/runtime/ssrClientEntry.js +4 -2
  91. package/dist/theme/assets/success.js +1 -1
  92. package/dist/theme/assets/wrapped.js +1 -1
  93. package/dist/theme/components/CodeButtonGroup/CopyCodeButton.css +1 -1
  94. package/dist/theme/components/CodeButtonGroup/CopyCodeButton.js +14 -12
  95. package/dist/theme/components/CodeButtonGroup/index.css +1 -1
  96. package/dist/theme/components/DocContent/doc.css +14 -21
  97. package/dist/theme/components/FallbackHeading/index.js +1 -1
  98. package/dist/theme/components/Link/useLinkNavigate.js +3 -2
  99. package/dist/theme/components/Llms/LlmsCopyButton.css +5 -5
  100. package/dist/theme/components/Llms/LlmsCopyButton.js +5 -6
  101. package/dist/theme/components/Llms/LlmsCopyRow.js +5 -5
  102. package/dist/theme/components/Llms/LlmsViewOptions.js +1 -3
  103. package/dist/theme/components/Outline/index.css +1 -1
  104. package/dist/theme/components/Prompt/icons.d.ts +10 -0
  105. package/dist/theme/components/Prompt/icons.js +64 -0
  106. package/dist/theme/components/Prompt/index.css +352 -0
  107. package/dist/theme/components/Prompt/index.d.ts +33 -0
  108. package/dist/theme/components/Prompt/index.js +262 -0
  109. package/dist/theme/components/Search/SearchPanel.js +1 -1
  110. package/dist/theme/components/SidebarMenu/index.js +2 -1
  111. package/dist/theme/components/Steps/index.css +23 -12
  112. package/dist/theme/index.d.ts +3 -0
  113. package/dist/theme/index.js +3 -0
  114. package/dist/theme/layout/DocLayout/index.css +5 -1
  115. package/dist/theme/layout/DocLayout/index.js +8 -4
  116. package/dist/theme/logic/copyToClipboard.d.ts +1 -0
  117. package/dist/theme/{components/Llms/copy.js → logic/copyToClipboard.js} +4 -3
  118. package/dist/theme/logic/getCopyableText.d.ts +5 -0
  119. package/dist/theme/logic/getCopyableText.js +52 -0
  120. package/dist/theme/logic/useThemeState.js +1 -1
  121. package/dist/theme/styles/vars/base-vars.css +4 -4
  122. package/package.json +20 -23
  123. package/dist/4454.js +0 -8
  124. package/dist/7319.js +0 -88
  125. package/dist/8885.js +0 -4
  126. package/dist/eject-theme/components/Llms/copy.ts +0 -12
  127. package/dist/theme/components/Llms/copy.d.ts +0 -1
@@ -1,10 +1,14 @@
1
1
  /*! LICENSE: renderPages.js.LICENSE.txt */
2
- import { chunk, logger, picocolors } from "../../7319.js";
2
+ import { __webpack_require__ } from "../../0~rslib-runtime.js";
3
+ import "../../8006.js";
4
+ import { chunk, logger } from "../../2287.js";
3
5
  import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
4
- import { pMap } from "../../8311.js";
6
+ import { pMap } from "../../1688.js";
5
7
  import { renderPage } from "./renderPage.js";
6
8
  import { hintSSGFailed } from "../logger/hint.js";
7
9
  import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
10
+ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
11
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
8
12
  const routePath2HtmlFileName = (routePath)=>{
9
13
  let fileName = routePath;
10
14
  fileName = fileName.endsWith('/') ? `${routePath}index.html` : `${routePath}.html`;
@@ -36,7 +40,7 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
36
40
  const MAX_DISPLAY_ROUTES = 10;
37
41
  const displayedRoutes = csrRoutePaths.slice(0, MAX_DISPLAY_ROUTES);
38
42
  const remainingCount = csrRoutePaths.length - MAX_DISPLAY_ROUTES;
39
- logger.info(`Some routes (${picocolors.yellow(csrRoutePaths.length)} total) are ignored in SSG and fallback to CSR via \`ssg.experimentalExcludeRoutePaths\`: ${picocolors.yellow(displayedRoutes.join(', '))}${remainingCount > 0 ? picocolors.dim(` ... and ${remainingCount} more`) : ''}`);
43
+ logger.info(`Some routes (${picocolors_default().yellow(csrRoutePaths.length)} total) are ignored in SSG and fallback to CSR via \`ssg.experimentalExcludeRoutePaths\`: ${picocolors_default().yellow(displayedRoutes.join(', '))}${remainingCount > 0 ? picocolors_default().dim(` ... and ${remainingCount} more`) : ''}`);
40
44
  await Promise.all(promiseList);
41
45
  routes.length = 0;
42
46
  routes.push(...ssgRoutes);
@@ -44,7 +48,7 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
44
48
  }
45
49
  if ('object' == typeof ssg && ssg?.experimentalWorker) {
46
50
  const numberOfThreads = getNumberOfThreads(routes.length);
47
- const Tinypool = await import("tinypool").then((m)=>m.default);
51
+ const Tinypool = await import("../../0~tinypool.js").then((m)=>m.default);
48
52
  const pool = new Tinypool({
49
53
  filename: new URL('./renderPageWorker.js', import.meta.url).href,
50
54
  concurrentTasksPerWorker: 1,
@@ -83,7 +87,7 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
83
87
  concurrency: SSGConcurrency()
84
88
  });
85
89
  const totalTime = Date.now() - startTime;
86
- logger.success(`Pages rendered in ${picocolors.yellow(totalTime)} ms.`);
90
+ logger.success(`Pages rendered in ${picocolors_default().yellow(totalTime)} ms.`);
87
91
  } catch (e) {
88
92
  if (e instanceof Error) {
89
93
  logger.error(`Pages render error: ${e.message}`);
@@ -1,4 +1,4 @@
1
- import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../7319.js";
1
+ import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../2287.js";
2
2
  import { NODE_SSG_BUNDLE_FOLDER, NODE_SSG_BUNDLE_NAME } from "../constants.js";
3
3
  import { renderPages } from "./renderPages.js";
4
4
  const rsbuildPluginSSG = ({ routeService, config })=>({
@@ -1,5 +1,5 @@
1
1
  /*! LICENSE: ssgEnv.js.LICENSE.txt */
2
- import { node_os } from "../../7319.js";
2
+ import { node_os } from "../../2287.js";
3
3
  /**
4
4
  * these codes are copied from
5
5
  * @link https://github.com/facebook/docusaurus/blob/45065e8d2b5831117b8d69fec1be28f5520cf105/packages/docusaurus/src/ssg/ssgEnv.ts#L11
@@ -1,4 +1,4 @@
1
- import { matchPath, getSidebarDataGroup } from "../../../7319.js";
1
+ import { matchPath, getSidebarDataGroup } from "../../../2287.js";
2
2
  import { generateLlmsTxt, generateLlmsFullTxt } from "./llmsTxt.js";
3
3
  async function emitLlmsTxt(config, routeService, emitAsset, mdContents) {
4
4
  const base = config.base ?? '/';
@@ -1,4 +1,4 @@
1
- import { normalizeHref, logger, withBase } from "../../../7319.js";
1
+ import { normalizeHref, logger, withBase } from "../../../2287.js";
2
2
  import { extractInfoFromFrontmatterWithAbsolutePath } from "../../auto-nav-sidebar/utils.js";
3
3
  function routePathToMdPath(routePath, base) {
4
4
  let url = routePath;
@@ -1,4 +1,4 @@
1
- import { unified, visit, remark_gfm, remark_mdx, remark_stringify } from "../../7397.js";
1
+ import { unified, visit, remark_gfm, remark_mdx, remark_stringify } from "../../2240.js";
2
2
  function remarkSplitMdx(options = {}) {
3
3
  return (tree)=>{
4
4
  const newChildren = [];
@@ -1,5 +1,9 @@
1
- import { createHead, logger, pathToFileURL, picocolors } from "../../7319.js";
1
+ import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
+ import "../../8006.js";
3
+ import { createHead, pathToFileURL, logger } from "../../2287.js";
2
4
  import { hintSSGFailed } from "../logger/hint.js";
5
+ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
3
7
  async function renderPage(route, ssrBundlePath) {
4
8
  let render;
5
9
  try {
@@ -8,7 +12,7 @@ async function renderPage(route, ssrBundlePath) {
8
12
  render = ssrExports.render;
9
13
  } catch (e) {
10
14
  if (e instanceof Error) {
11
- logger.error(`Failed to load SSG bundle: ${picocolors.yellow(ssrBundlePath)}: ${e.message}`);
15
+ logger.error(`Failed to load SSG bundle: ${picocolors_default().yellow(ssrBundlePath)}: ${e.message}`);
12
16
  logger.debug(e);
13
17
  hintSSGFailed();
14
18
  }
@@ -21,8 +25,8 @@ async function renderPage(route, ssrBundlePath) {
21
25
  ({ appMd } = await render(routePath, head));
22
26
  } catch (e) {
23
27
  if (e instanceof Error) {
24
- logger.error(`Page "${picocolors.yellow(routePath)}" SSG-MD rendering failed.
25
- ${absolutePath ? picocolors.gray(` File: ${absolutePath}\n`) : ''} ${picocolors.gray(e.toString())}`);
28
+ logger.error(`Page "${picocolors_default().yellow(routePath)}" SSG-MD rendering failed.
29
+ ${absolutePath ? picocolors_default().gray(` File: ${absolutePath}\n`) : ''} ${picocolors_default().gray(e.toString())}`);
26
30
  throw e;
27
31
  }
28
32
  }
@@ -1,7 +1,11 @@
1
- import { logger, picocolors } from "../../7319.js";
2
- import { pMap } from "../../8311.js";
1
+ import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
+ import "../../8006.js";
3
+ import { logger } from "../../2287.js";
4
+ import { pMap } from "../../1688.js";
3
5
  import { renderPage } from "./renderPage.js";
4
6
  import { SSGConcurrency } from "../ssg/ssgEnv.js";
7
+ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
8
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
5
9
  const routePage2MdFilename = (routePath)=>{
6
10
  let fileName = routePath;
7
11
  fileName = fileName.endsWith('/') ? `${routePath}index.md` : `${routePath}.md`;
@@ -21,7 +25,7 @@ async function renderPages(routeService, ssrBundlePath, emitAsset) {
21
25
  concurrency: SSGConcurrency()
22
26
  });
23
27
  const totalTime = Date.now() - startTime;
24
- logger.success(`Markdown rendered in ${picocolors.yellow(totalTime)} ms.`);
28
+ logger.success(`Markdown rendered in ${picocolors_default().yellow(totalTime)} ms.`);
25
29
  return result;
26
30
  }
27
31
  export { renderPages };
@@ -1,4 +1,4 @@
1
- import { writeFile, mkdir, rm, join, isDebugMode } from "../../7319.js";
1
+ import { writeFile, mkdir, rm, join, isDebugMode } from "../../2287.js";
2
2
  import { NODE_SSG_MD_BUNDLE_FOLDER, NODE_SSG_MD_BUNDLE_NAME } from "../constants.js";
3
3
  import { renderPages } from "./renderPages.js";
4
4
  import { emitLlmsTxt } from "./llms/emitLlmsTxt.js";
@@ -1,4 +1,4 @@
1
- import { node_path, logger, promises } from "../../7319.js";
1
+ import { node_path, logger, promises } from "../../2287.js";
2
2
  import { createError } from "./error.js";
3
3
  function normalizePath(filePath) {
4
4
  return filePath.split(node_path.sep).join('/');
@@ -1,4 +1,4 @@
1
- import { createHash as external_node_crypto_createHash } from "../../7319.js";
1
+ import { createHash as external_node_crypto_createHash } from "../../2287.js";
2
2
  function createHash(str) {
3
3
  return external_node_crypto_createHash('sha256').update(str).digest('hex').slice(0, 8);
4
4
  }
@@ -1,9 +1,12 @@
1
- import { picocolors } from "../../8885.js";
1
+ import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
+ import "../../8006.js";
3
+ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
4
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
2
5
  function createError(message, maxStackLines = 5) {
3
6
  const error = new Error(message);
4
7
  if (error.stack) {
5
8
  const lines = error.stack.split('\n');
6
- if (lines.length > maxStackLines + 1) error.stack = `${lines.slice(0, maxStackLines + 1).map((line)=>picocolors.gray(line)).join('\n')}\n ${picocolors.gray('... (truncated)')}`;
9
+ if (lines.length > maxStackLines + 1) error.stack = `${lines.slice(0, maxStackLines + 1).map((line)=>picocolors_default().gray(line)).join('\n')}\n ${picocolors_default().gray('... (truncated)')}`;
7
10
  }
8
11
  return error;
9
12
  }
@@ -1,4 +1,4 @@
1
- import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../7319.js";
1
+ import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../2287.js";
2
2
  import { createError } from "./error.js";
3
3
  import { importStatementRegex } from "../constants.js";
4
4
  const RspackResolveFactory = core_rspack.experiments.resolver.ResolverFactory;
@@ -1,4 +1,4 @@
1
- import { promises } from "../../8885.js";
1
+ import { promises } from "../../8006.js";
2
2
  async function pathExists(path) {
3
3
  try {
4
4
  await promises.access(path);
@@ -1,4 +1,4 @@
1
- import { removeLeadingSlash } from "../../7319.js";
1
+ import { removeLeadingSlash } from "../../2287.js";
2
2
  function getPageKey(route) {
3
3
  const cleanRoute = removeLeadingSlash(route);
4
4
  return cleanRoute.replace(/\//g, '_').replace(/\.[^.]+$/, '') || 'index';
@@ -1,4 +1,4 @@
1
- import { node_os, node_path } from "../../1361.js";
1
+ import { node_os, node_path } from "../../3294.js";
2
2
  const isWindows = 'win32' === node_os.platform();
3
3
  function slash(p) {
4
4
  return p.replace(/\\/g, '/');
@@ -1,7 +1,11 @@
1
- import { node_path, core_rspack, logger, picocolors } from "../../7319.js";
1
+ import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
+ import "../../8006.js";
3
+ import { node_path, core_rspack, logger } from "../../2287.js";
2
4
  import { pathExists, readJson } from "./fs.js";
3
5
  import { PACKAGE_ROOT } from "../constants.js";
4
6
  import { hintReactVersion } from "../logger/hint.js";
7
+ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
8
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
5
9
  const Resolver = core_rspack.experiments.resolver.ResolverFactory;
6
10
  async function detectPackageMajorVersion(name) {
7
11
  const cwd = process.cwd();
@@ -77,7 +81,7 @@ async function resolveReactAlias(isSSR) {
77
81
  alias[lib] = resolved.path;
78
82
  } catch (e) {
79
83
  if (e instanceof Error) {
80
- logger.warn(`${lib} not found: \n ${picocolors.gray(e.toString())}`);
84
+ logger.warn(`${lib} not found: \n ${picocolors_default().gray(e.toString())}`);
81
85
  hintReactVersion();
82
86
  }
83
87
  }
@@ -88,7 +92,7 @@ async function resolveReactRenderToMarkdownAlias() {
88
92
  const hasInstalled = await detectPackageMajorVersion('react-render-to-markdown');
89
93
  if (!hasInstalled) {
90
94
  const reactMajorVersion = await detectPackageMajorVersion('react');
91
- if (reactMajorVersion && reactMajorVersion < 19) logger.warn(`You are using React ${reactMajorVersion} with \`llms: true\`. Please install \`react-render-to-markdown\` to ensure compatibility.\n\nAdd the following to your ${picocolors.greenBright('package.json')}:\n\n` + picocolors.greenBright(` "dependencies": {\n "react": "^18.3.1",\n "react-dom": "^18.3.1",\n "react-render-to-markdown": "^18.3.1"\n }\n`));
95
+ if (reactMajorVersion && reactMajorVersion < 19) logger.warn(`You are using React ${reactMajorVersion} with \`llms: true\`. Please install \`react-render-to-markdown\` to ensure compatibility.\n\nAdd the following to your ${picocolors_default().greenBright('package.json')}:\n\n` + picocolors_default().greenBright(` "dependencies": {\n "react": "^18.3.1",\n "react-dom": "^18.3.1",\n "react-render-to-markdown": "^18.3.1"\n }\n`));
92
96
  return {};
93
97
  }
94
98
  const alias = {};
@@ -3,14 +3,17 @@ import { PageContext, useLocation } from "@rspress/core/runtime";
3
3
  import { Layout, Root } from "@theme";
4
4
  import react, { useContext, useLayoutEffect } from "react";
5
5
  import virtual_global_components from "virtual-global-components";
6
- import { initPageData } from "./initPageData.js";
6
+ import { consumeCachedPageData, initPageData, setCurrentPageData } from "./initPageData.js";
7
7
  function App() {
8
8
  const { setData: setPageData, data } = useContext(PageContext);
9
9
  const { pathname, search } = useLocation();
10
10
  useLayoutEffect(()=>{
11
+ const cached = consumeCachedPageData(pathname);
12
+ if (cached) return void setPageData?.(cached);
11
13
  async function refetchData() {
12
14
  try {
13
15
  const pageData = await initPageData(pathname);
16
+ setCurrentPageData(pathname, pageData);
14
17
  setPageData?.(pageData);
15
18
  } catch (e) {
16
19
  console.log(e);
@@ -1,5 +1,5 @@
1
1
  export { isDataUrl, isExternalUrl, matchNavbar, matchSidebar, normalizeHref, } from '@rspress/shared';
2
- export { Head } from '@unhead/react';
2
+ export { Head, useHead } from '@unhead/react';
3
3
  export * from 'react-router-dom';
4
4
  export { Content } from './Content.js';
5
5
  export { useActiveMatcher } from './hooks/useActiveMatcher.js';
@@ -16,6 +16,7 @@ export { getSidebarDataGroup, useSidebar, useSidebarDynamic, } from './hooks/use
16
16
  export { useSite } from './hooks/useSite.js';
17
17
  export { useVersion } from './hooks/useVersion.js';
18
18
  export { useWindowSize } from './hooks/useWindowSize.js';
19
+ export { initPageData, warmPageData } from './initPageData.js';
19
20
  export { NoSSR } from './NoSSR.js';
20
21
  export { isActive, pathnameToRouteService, preloadLink } from './route.js';
21
22
  export { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, removeBase, removeTrailingSlash, routePathToMdPath, withBase, } from './utils.js';
@@ -1,6 +1,6 @@
1
1
  export * from "react-router-dom";
2
2
  export { isDataUrl, isExternalUrl, matchNavbar, matchSidebar, normalizeHref } from "@rspress/shared";
3
- export { Head } from "@unhead/react";
3
+ export { Head, useHead } from "@unhead/react";
4
4
  export { Content } from "./Content.js";
5
5
  export { useActiveMatcher } from "./hooks/useActiveMatcher.js";
6
6
  export { ThemeContext, useDark } from "./hooks/useDark.js";
@@ -16,6 +16,7 @@ export { getSidebarDataGroup, useSidebar, useSidebarDynamic } from "./hooks/useS
16
16
  export { useSite } from "./hooks/useSite.js";
17
17
  export { useVersion } from "./hooks/useVersion.js";
18
18
  export { useWindowSize } from "./hooks/useWindowSize.js";
19
+ export { initPageData, warmPageData } from "./initPageData.js";
19
20
  export { NoSSR } from "./NoSSR.js";
20
21
  export { isActive, pathnameToRouteService, preloadLink } from "./route.js";
21
22
  export { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, removeBase, removeTrailingSlash, routePathToMdPath, withBase } from "./utils.js";
@@ -1,3 +1,6 @@
1
1
  import { type PageDataLegacy } from '@rspress/shared';
2
2
  export type Page = PageDataLegacy['page'];
3
+ export declare function warmPageData(routePath: string, data: Page): void;
4
+ export declare function consumeCachedPageData(routePath: string): Page | undefined;
5
+ export declare function setCurrentPageData(routePath: string, data: Page): void;
3
6
  export declare function initPageData(routePath: string): Promise<Page>;
@@ -1,7 +1,42 @@
1
- import { isEqualPath, pathnameToRouteService } from "@rspress/core/runtime";
2
1
  import { MDX_OR_MD_REGEXP, cleanUrl } from "@rspress/shared";
3
2
  import { pageData } from "virtual-page-data";
4
3
  import virtual_site_data from "virtual-site-data";
4
+ import { pathnameToRouteService } from "./route.js";
5
+ import { isEqualPath } from "./utils.js";
6
+ const slots = [
7
+ void 0,
8
+ void 0,
9
+ void 0
10
+ ];
11
+ function warmPageData(routePath, data) {
12
+ slots[0] = {
13
+ routePath,
14
+ data
15
+ };
16
+ }
17
+ function consumeCachedPageData(routePath) {
18
+ if (slots[0]?.routePath === routePath) {
19
+ const data = slots[0].data;
20
+ slots[2] = slots[1];
21
+ slots[1] = slots[0];
22
+ slots[0] = void 0;
23
+ return data;
24
+ }
25
+ if (slots[2]?.routePath === routePath) {
26
+ const data = slots[2].data;
27
+ slots[0] = slots[1];
28
+ slots[1] = slots[2];
29
+ slots[2] = void 0;
30
+ return data;
31
+ }
32
+ }
33
+ function setCurrentPageData(routePath, data) {
34
+ slots[2] = slots[1];
35
+ slots[1] = {
36
+ routePath,
37
+ data
38
+ };
39
+ }
5
40
  async function initPageData(routePath) {
6
41
  const matchedRoute = pathnameToRouteService(routePath);
7
42
  if (matchedRoute) {
@@ -48,4 +83,4 @@ async function initPageData(routePath) {
48
83
  _relativePath: ''
49
84
  };
50
85
  }
51
- export { initPageData };
86
+ export { consumeCachedPageData, initPageData, setCurrentPageData, warmPageData };
@@ -3,10 +3,12 @@ import { removeBase } from "@rspress/core/runtime";
3
3
  import { startTransition } from "react";
4
4
  import { hydrateRoot } from "react-dom/client";
5
5
  import { ClientApp } from "./ClientApp.js";
6
- import { initPageData } from "./initPageData.js";
6
+ import { initPageData, setCurrentPageData } from "./initPageData.js";
7
7
  async function renderInBrowser() {
8
8
  const container = document.getElementById('__rspress_root');
9
- const initialPageData = await initPageData(removeBase(window.location.pathname));
9
+ const pathname = removeBase(window.location.pathname);
10
+ const initialPageData = await initPageData(pathname);
11
+ setCurrentPageData(pathname, initialPageData);
10
12
  startTransition(()=>{
11
13
  hydrateRoot(container, /*#__PURE__*/ jsx(ClientApp, {
12
14
  initialPageData: initialPageData
@@ -7,7 +7,7 @@ const SvgSuccess = (props)=>/*#__PURE__*/ jsx("svg", {
7
7
  viewBox: "0 0 24 24",
8
8
  ...props,
9
9
  children: /*#__PURE__*/ jsx("path", {
10
- fill: "#49cd37",
10
+ fill: "currentColor",
11
11
  d: "m9.55 18-5.7-5.7 1.425-1.425L9.55 15.15l9.175-9.175L20.15 7.4z"
12
12
  })
13
13
  });
@@ -7,7 +7,7 @@ const SvgWrapped = (props)=>/*#__PURE__*/ jsx("svg", {
7
7
  viewBox: "0 0 24 24",
8
8
  ...props,
9
9
  children: /*#__PURE__*/ jsx("path", {
10
- fill: "#22a041",
10
+ fill: "currentColor",
11
11
  d: "M21 5H3v2h18zM3 19h7v-2H3zm0-6h15c1 0 2 .43 2 2s-1 2-2 2h-2v-2l-4 3 4 3v-2h2c2.95 0 4-1.27 4-4 0-2.72-1-4-4-4H3z"
12
12
  })
13
13
  });
@@ -4,7 +4,7 @@
4
4
 
5
5
  .rp-code-copy-button__icon--success {
6
6
  opacity: 0;
7
- color: #00d600;
7
+ color: #10b981;
8
8
  position: absolute;
9
9
  top: 50%;
10
10
  left: 50%;
@@ -1,21 +1,21 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { IconCopy, IconSuccess, SvgWrapper } from "@rspress/core/theme";
3
- import copy_to_clipboard from "copy-to-clipboard";
2
+ import { IconCopy, IconSuccess, SvgWrapper, copyToClipboard, getCopyableText } from "@rspress/core/theme";
4
3
  import { useRef } from "react";
5
4
  import "./CopyCodeButton.css";
6
5
  import { useI18n } from "@rspress/core/runtime";
7
6
  const timeoutIdMap = new Map();
8
7
  const COPIED_CLASS = 'rp-code-copy-button--copied';
9
- function copyCode(codeBlockElement, copyButtonElement) {
10
- let text = '';
8
+ async function copyCode(codeBlockElement, copyButtonElement) {
11
9
  if (!codeBlockElement) return;
12
- const walk = document.createTreeWalker(codeBlockElement, NodeFilter.SHOW_TEXT, null);
13
- let node = walk.nextNode();
14
- while(node){
15
- if (!node.parentElement.classList.contains('linenumber') && !node.parentElement.closest('.rp-copy-ignore')) text += node.nodeValue;
16
- node = walk.nextNode();
17
- }
18
- const isCopied = copy_to_clipboard(text);
10
+ const text = getCopyableText(codeBlockElement, {
11
+ ignoreClasses: [
12
+ 'linenumber'
13
+ ],
14
+ ignoreSelectors: [
15
+ '.rp-copy-ignore'
16
+ ]
17
+ });
18
+ const isCopied = await copyToClipboard(text);
19
19
  if (isCopied && copyButtonElement) {
20
20
  copyButtonElement.classList.add(COPIED_CLASS);
21
21
  clearTimeout(timeoutIdMap.get(copyButtonElement));
@@ -32,7 +32,9 @@ function CopyCodeButton({ codeBlockRef }) {
32
32
  const t = useI18n();
33
33
  return /*#__PURE__*/ jsxs("button", {
34
34
  className: "rp-code-button-group__button rp-code-copy-button",
35
- onClick: ()=>copyCode(codeBlockRef.current, copyButtonRef.current),
35
+ onClick: ()=>{
36
+ copyCode(codeBlockRef.current, copyButtonRef.current);
37
+ },
36
38
  ref: copyButtonRef,
37
39
  title: t('codeButtonGroupCopyButtonText'),
38
40
  children: [
@@ -45,7 +45,7 @@
45
45
 
46
46
  .rp-code-button-group__icon--wrapped {
47
47
  opacity: 0;
48
- color: #00d600;
48
+ color: #10b981;
49
49
  position: absolute;
50
50
  top: 50%;
51
51
  left: 50%;
@@ -54,6 +54,7 @@
54
54
  opacity: 0;
55
55
  font-weight: 500;
56
56
  font-size: inherit;
57
+ border-bottom: 1px solid #0000;
57
58
  margin-left: -.8em;
58
59
  transition: color .25s, opacity .25s;
59
60
  }
@@ -150,6 +151,8 @@
150
151
  }
151
152
 
152
153
  .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(.rp-table-scroll-container) {
154
+ overscroll-behavior-x: contain;
155
+ margin: 1.5rem 0;
153
156
  overflow-x: auto;
154
157
  }
155
158
 
@@ -160,21 +163,12 @@
160
163
  border: var(--rp-code-block-border);
161
164
  border-radius: var(--rp-radius);
162
165
  width: 100%;
166
+ min-width: 100%;
163
167
  overflow: hidden;
164
168
  }
165
169
 
166
- .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table)::-webkit-scrollbar {
167
- width: 5px;
168
- height: 5px;
169
- }
170
-
171
- .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table)::-webkit-scrollbar-corner {
172
- display: none;
173
- }
174
-
175
- .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table)::-webkit-scrollbar-thumb {
176
- background-color: #0000000d;
177
- border-radius: 10px;
170
+ .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table:not(.rp-table-scroll-container > table)) {
171
+ margin: 1.5rem 0;
178
172
  }
179
173
 
180
174
  .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(thead) {
@@ -185,7 +179,8 @@
185
179
  .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(th) {
186
180
  text-align: left;
187
181
  border-bottom: 1px solid var(--rp-c-divider-light);
188
- padding: .75rem 1.25rem;
182
+ min-width: 8rem;
183
+ padding: .75rem 1rem;
189
184
  font-size: .875rem;
190
185
  font-weight: 600;
191
186
  position: relative;
@@ -197,15 +192,17 @@
197
192
 
198
193
  .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(td) {
199
194
  border-bottom: 1px solid var(--rp-c-divider-light);
200
- padding: .75rem 1.25rem;
195
+ min-width: 8rem;
196
+ color: var(--rp-c-text-1);
197
+ padding: .75rem 1rem;
201
198
  font-size: .875rem;
202
199
  }
203
200
 
204
- .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(tr) {
205
- transition: background-color .2s;
201
+ .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(tbody tr) {
202
+ transition: background-color .2s ease-out;
206
203
  }
207
204
 
208
- .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(tr):hover {
205
+ .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(tbody tr):hover {
209
206
  background: var(--rp-c-bg-soft);
210
207
  }
211
208
 
@@ -247,7 +244,3 @@
247
244
  background-color: var(--rp-c-bg-mute);
248
245
  }
249
246
 
250
- :where(.rp-dark) .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table), :where(.rp-dark) .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table tr), :where(.rp-dark) .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table td), :where(.rp-dark) .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table th) {
251
- border-color: var(--rp-c-divider);
252
- }
253
-
@@ -1,6 +1,6 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { getCustomMDXComponent, renderInlineMarkdown } from "@rspress/core/theme";
3
- import { slug } from "github-slugger";
3
+ import { slug } from "@rspress/shared/github-slugger";
4
4
  import { useMemo } from "react";
5
5
  const getHeadingMap = ()=>{
6
6
  const { h1, h2, h3, h4, h5, h6 } = getCustomMDXComponent();
@@ -1,4 +1,4 @@
1
- import { cleanUrlByConfig, isActive, isExternalUrl, pathnameToRouteService, removeBase, useLocation, useNavigate, withBase } from "@rspress/core/runtime";
1
+ import { cleanUrlByConfig, initPageData, isActive, isExternalUrl, pathnameToRouteService, removeBase, useLocation, useNavigate, warmPageData, withBase } from "@rspress/core/runtime";
2
2
  import nprogress from "nprogress";
3
3
  import { startTransition as external_react_startTransition, useCallback } from "react";
4
4
  nprogress.configure({
@@ -46,7 +46,8 @@ function useLinkNavigate({ startTransition } = {
46
46
  const timer = setTimeout(()=>{
47
47
  nprogress.start();
48
48
  }, 200);
49
- await matchedRoute.preload();
49
+ const data = await initPageData(removeBaseHref);
50
+ warmPageData(removeBaseHref, data);
50
51
  clearTimeout(timer);
51
52
  nprogress.done();
52
53
  }
@@ -10,9 +10,9 @@
10
10
  }
11
11
 
12
12
  .rp-llms-copy-button--success.rp-llms-copy-button {
13
- color: var(--rp-c-green-1, #10b981);
14
- border-color: var(--rp-c-green-1, #10b981);
13
+ color: #10b981;
15
14
  background: var(--rp-c-bg-soft);
15
+ border-color: #10b981;
16
16
  }
17
17
 
18
18
  .rp-llms-copy-button--success .rp-llms-copy-button__icon-copy {
@@ -43,11 +43,11 @@
43
43
  }
44
44
 
45
45
  .rp-llms-copy-button__icon-success {
46
- width: 16px;
47
- height: 16px;
48
- color: var(--rp-c-green-1, #10b981);
46
+ color: #10b981;
49
47
  visibility: hidden;
50
48
  opacity: 0;
49
+ width: 16px;
50
+ height: 16px;
51
51
  transition: all .2s cubic-bezier(.18, .89, .32, 1.28);
52
52
  position: absolute;
53
53
  top: 50%;
@@ -1,12 +1,10 @@
1
1
  /*! LICENSE: LlmsCopyButton.js.LICENSE.txt */
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useI18n } from "@rspress/core/runtime";
4
- import { IconCopy, IconSuccess } from "@rspress/core/theme";
4
+ import { IconCopy, IconSuccess, SvgWrapper, copyToClipboard } from "@rspress/core/theme";
5
5
  import { useCallback, useRef, useState } from "react";
6
- import { SvgWrapper } from "../SvgWrapper/index.js";
7
6
  import "./index.css";
8
7
  import "./LlmsCopyButton.css";
9
- import { copyToClipboard } from "./copy.js";
10
8
  import { useMdUrl } from "./useMdUrl.js";
11
9
  /**
12
10
  * Inspired from fumadocs docsite
@@ -26,9 +24,8 @@ function LlmsCopyButton(props) {
26
24
  try {
27
25
  const content = cache.get(url) ?? await fetch(url).then((res)=>res.text());
28
26
  cache.set(url, content);
29
- await copyToClipboard(content);
30
- } finally{
31
- setLoading(false);
27
+ const isCopied = await copyToClipboard(content);
28
+ if (!isCopied) return;
32
29
  setFinished(true);
33
30
  if (timer.current) {
34
31
  clearTimeout(timer.current);
@@ -38,6 +35,8 @@ function LlmsCopyButton(props) {
38
35
  setFinished(false);
39
36
  timer.current = null;
40
37
  }, 500);
38
+ } finally{
39
+ setLoading(false);
41
40
  }
42
41
  }, [
43
42
  pathname