@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
@@ -1,4 +1,4 @@
1
- import { getIconUrlPath } from "../../../2235.js";
1
+ import { getIconUrlPath } from "../../../4942.js";
2
2
  import { normalizeThemeConfig } from "./normalizeThemeConfig.js";
3
3
  async function createSiteData(userConfig) {
4
4
  const tempSearchObj = Object.assign({}, userConfig.search);
@@ -1,4 +1,4 @@
1
- import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../2235.js";
1
+ import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../4942.js";
2
2
  import { getI18nData } from "../i18n.js";
3
3
  import { applyReplaceRules } from "../../utils/applyReplaceRules.js";
4
4
  async function normalizeThemeConfig(docConfig) {
@@ -1,23 +1,47 @@
1
- import { logger } from "../../../2235.js";
1
+ import { isProduction, logger } from "../../../4942.js";
2
2
  import { modifyConfigWithAutoNavSide } from "../../auto-nav-sidebar/index.js";
3
3
  import { createSiteData } from "./createSiteData.js";
4
4
  const siteDataVMPlugin = (context)=>{
5
5
  const { config, pluginDriver } = context;
6
+ let siteDataModulePromise;
7
+ const createSiteDataModule = async (metaFileSet = new Set(), mdFileSet = new Set())=>{
8
+ const force = !pluginDriver.haveNavSidebarConfig;
9
+ const now = performance.now();
10
+ try {
11
+ await modifyConfigWithAutoNavSide(config, metaFileSet, mdFileSet, force);
12
+ } finally{
13
+ logger.debug(`modifyConfigWithAutoNavSide - size: ${mdFileSet.size} cost: ${performance.now() - now}ms`);
14
+ }
15
+ const { siteData } = await createSiteData(config);
16
+ return {
17
+ code: `export default ${JSON.stringify(siteData, null, 2)}`,
18
+ metaFileSet,
19
+ mdFileSet
20
+ };
21
+ };
22
+ const getSiteDataModule = (metaFileSet, mdFileSet)=>{
23
+ if (!isProduction()) return createSiteDataModule(metaFileSet, mdFileSet);
24
+ siteDataModulePromise ??= createSiteDataModule(metaFileSet, mdFileSet).catch((error)=>{
25
+ siteDataModulePromise = void 0;
26
+ throw error;
27
+ });
28
+ return siteDataModulePromise;
29
+ };
30
+ const addSiteDataDependencies = (addDependency, metaFileSet, mdFileSet)=>{
31
+ for (const metaFile of metaFileSet)addDependency(metaFile);
32
+ for (const mdFile of mdFileSet)addDependency(mdFile);
33
+ };
6
34
  return {
7
35
  ["virtual-site-data"]: async ({ addDependency })=>{
8
- const force = !pluginDriver.haveNavSidebarConfig;
9
36
  const metaFileSet = new Set();
10
37
  const mdFileSet = new Set();
11
- const now = performance.now();
38
+ let siteDataModule;
12
39
  try {
13
- await modifyConfigWithAutoNavSide(config, metaFileSet, mdFileSet, force);
40
+ siteDataModule = await getSiteDataModule(metaFileSet, mdFileSet);
41
+ return siteDataModule.code;
14
42
  } finally{
15
- for (const metaFile of metaFileSet)addDependency(metaFile);
16
- for (const mdFile of mdFileSet)addDependency(mdFile);
17
- logger.debug(`modifyConfigWithAutoNavSide - size: ${mdFileSet.size} cost: ${performance.now() - now}ms`);
43
+ addSiteDataDependencies(addDependency, siteDataModule?.metaFileSet ?? metaFileSet, siteDataModule?.mdFileSet ?? mdFileSet);
18
44
  }
19
- const { siteData } = await createSiteData(config);
20
- return `export default ${JSON.stringify(siteData, null, 2)}`;
21
45
  }
22
46
  };
23
47
  };
@@ -1,4 +1,4 @@
1
- import { mergeRsbuildConfig } from "../2235.js";
1
+ import { mergeRsbuildConfig } from "../4942.js";
2
2
  import { PluginDriver } from "./PluginDriver.js";
3
3
  import { initRsbuild } from "./initRsbuild.js";
4
4
  import { RouteService } from "./route/RouteService.js";
@@ -0,0 +1,2 @@
1
+ export declare const routePath2HtmlFileName: (routePath: string) => string;
2
+ export declare function resolveHtmlFilePath(distPath: string, routePath: string): string;
@@ -0,0 +1,14 @@
1
+ import { external_node_path_resolve, relative, isAbsolute } from "../../7261.js";
2
+ const routePath2HtmlFileName = (routePath)=>{
3
+ let fileName = routePath;
4
+ fileName = fileName.endsWith('/') ? `${routePath}index.html` : `${routePath}.html`;
5
+ return fileName.replace(/^\/+/, '');
6
+ };
7
+ function resolveHtmlFilePath(distPath, routePath) {
8
+ const distPathAbsolute = external_node_path_resolve(distPath);
9
+ const fileAbsolutePath = external_node_path_resolve(distPathAbsolute, routePath2HtmlFileName(routePath));
10
+ const relativePath = relative(distPathAbsolute, fileAbsolutePath);
11
+ if (relativePath.startsWith('..') || isAbsolute(relativePath)) throw new Error(`SSG route path "${routePath}" resolves outside of the output directory.`);
12
+ return fileAbsolutePath;
13
+ }
14
+ export { resolveHtmlFilePath, routePath2HtmlFileName };
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
- import "../../8006.js";
3
- import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../1688.js";
2
+ import "../../7986.js";
3
+ import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../7261.js";
4
4
  import { hintSSGFailed } from "../logger/hint.js";
5
5
  import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
6
6
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
@@ -1,9 +1,6 @@
1
- import type { RouteMeta, UserConfig } from '@rspress/shared';
2
- interface Args {
1
+ import type { RouteMeta } from '@rspress/shared';
2
+ interface WorkerTask {
3
3
  routes: RouteMeta[];
4
- htmlTemplate: string;
5
- head: UserConfig['head'];
6
- ssrBundlePath: string;
7
4
  }
8
- declare const exportWorkerGlueFn: ({ routes }: Args) => Promise<string[]>;
5
+ declare const exportWorkerGlueFn: ({ routes, }: WorkerTask) => Promise<string[]>;
9
6
  export default exportWorkerGlueFn;
@@ -1,15 +1,35 @@
1
- import { workerData } from "../../9224.js";
1
+ import { writeFile, mkdir, dirname, workerData } from "../../6646.js";
2
2
  import { createError } from "../utils/error.js";
3
- import { pMap } from "../../1688.js";
3
+ import { resolveHtmlFilePath } from "./htmlFile.js";
4
+ import { pMap } from "../../7261.js";
4
5
  import { renderPage } from "./renderPage.js";
5
6
  const params = workerData?.[1]?.params;
6
7
  if (!params) throw createError('SSG Worker Thread workerData params missing');
7
- const { htmlTemplate: htmlTemplate, head: head, ssrBundlePath: ssrBundlePath } = params;
8
- const exportWorkerGlueFn = async ({ routes })=>pMap(routes, async (route)=>{
8
+ const { htmlTemplate: htmlTemplate, head: head, ssrBundlePath: ssrBundlePath, distPath: distPath } = params;
9
+ async function writeHtmlFile(routePath, html) {
10
+ if (!distPath) return;
11
+ const fileAbsolutePath = resolveHtmlFilePath(distPath, routePath);
12
+ await mkdir(dirname(fileAbsolutePath), {
13
+ recursive: true
14
+ });
15
+ await writeFile(fileAbsolutePath, html);
16
+ }
17
+ const exportWorkerGlueFn = async ({ routes })=>{
18
+ if (distPath) {
19
+ await pMap(routes, async (route)=>{
20
+ const html = await renderPage(route, htmlTemplate, head, ssrBundlePath);
21
+ await writeHtmlFile(route.routePath, html);
22
+ }, {
23
+ concurrency: 10
24
+ });
25
+ return [];
26
+ }
27
+ return pMap(routes, async (route)=>{
9
28
  const html = await renderPage(route, htmlTemplate, head, ssrBundlePath);
10
29
  return html;
11
30
  }, {
12
31
  concurrency: 10
13
32
  });
33
+ };
14
34
  const renderPageWorker = exportWorkerGlueFn;
15
35
  export default renderPageWorker;
@@ -1,4 +1,4 @@
1
1
  import type { UserConfig } from '@rspress/shared';
2
2
  import type { RouteService } from '../route/RouteService.js';
3
- export declare function renderPages(routeService: RouteService, config: UserConfig, ssrBundlePath: string, htmlTemplate: string, emitAsset: (assetName: string, content: string | Buffer) => void): Promise<void>;
3
+ export declare function renderPages(routeService: RouteService, config: UserConfig, ssrBundlePath: string, htmlTemplate: string, emitAsset: (assetName: string, content: string | Buffer) => void, workerOutputDistPath?: string): Promise<void>;
4
4
  export declare function renderCSRPages(routeService: RouteService, config: UserConfig, htmlTemplate: string, emitAsset: (assetName: string, content: string | Buffer) => void): Promise<void>;
@@ -1,21 +1,16 @@
1
1
  /*! LICENSE: renderPages.js.LICENSE.txt */
2
2
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
3
- import "../../8006.js";
4
- import { chunk, logger } from "../../2235.js";
3
+ import "../../7986.js";
4
+ import { chunk, logger } from "../../4942.js";
5
5
  import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
6
- import { pMap } from "../../1688.js";
6
+ import { routePath2HtmlFileName } from "./htmlFile.js";
7
+ import { pMap } from "../../7261.js";
7
8
  import { renderPage } from "./renderPage.js";
8
9
  import { hintSSGFailed } from "../logger/hint.js";
9
10
  import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
10
11
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
11
12
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
12
- const routePath2HtmlFileName = (routePath)=>{
13
- let fileName = routePath;
14
- fileName = fileName.endsWith('/') ? `${routePath}index.html` : `${routePath}.html`;
15
- return fileName.replace(/^\/+/, '');
16
- };
17
- async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, emitAsset) {
18
- logger.info('Rendering pages...');
13
+ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, emitAsset, workerOutputDistPath) {
19
14
  const startTime = Date.now();
20
15
  const ssg = config.ssg ?? true;
21
16
  try {
@@ -48,6 +43,7 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
48
43
  }
49
44
  if ('object' == typeof ssg && ssg?.experimentalWorker) {
50
45
  const numberOfThreads = getNumberOfThreads(routes.length);
46
+ logger.info(`Rendering pages with experimental SSG worker (${picocolors_default().yellow(numberOfThreads)} threads)...`);
51
47
  const Tinypool = await import("../../0~tinypool.js").then((m)=>m.default);
52
48
  const pool = new Tinypool({
53
49
  filename: new URL('./renderPageWorker.js', import.meta.url).href,
@@ -63,7 +59,8 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
63
59
  params: {
64
60
  htmlTemplate,
65
61
  head: config.head,
66
- ssrBundlePath
62
+ ssrBundlePath,
63
+ distPath: workerOutputDistPath
67
64
  }
68
65
  }
69
66
  });
@@ -71,6 +68,7 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
71
68
  const htmlList = await pool.run({
72
69
  routes
73
70
  });
71
+ if (workerOutputDistPath) return;
74
72
  for(let i = 0; i < routes.length; i++){
75
73
  const route = routes[i];
76
74
  const html = htmlList[i];
@@ -79,13 +77,16 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
79
77
  }
80
78
  }));
81
79
  await pool.destroy();
82
- } else await pMap(routes, async (route)=>{
83
- const html = await renderPage(route, htmlTemplate, config.head, ssrBundlePath);
84
- const fileName = routePath2HtmlFileName(route.routePath);
85
- emitAsset(fileName, html);
86
- }, {
87
- concurrency: SSGConcurrency()
88
- });
80
+ } else {
81
+ logger.info('Rendering pages...');
82
+ await pMap(routes, async (route)=>{
83
+ const html = await renderPage(route, htmlTemplate, config.head, ssrBundlePath);
84
+ const fileName = routePath2HtmlFileName(route.routePath);
85
+ emitAsset(fileName, html);
86
+ }, {
87
+ concurrency: SSGConcurrency()
88
+ });
89
+ }
89
90
  const totalTime = Date.now() - startTime;
90
91
  logger.success(`Pages rendered in ${picocolors_default().yellow(totalTime)} ms.`);
91
92
  } catch (e) {
@@ -1,4 +1,4 @@
1
- import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../2235.js";
1
+ import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../4942.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 })=>({
@@ -73,7 +73,7 @@ const rsbuildPluginSSG = ({ routeService, config })=>({
73
73
  }));
74
74
  await indexHtmlEmittedInWeb;
75
75
  if (hasError) return;
76
- await renderPages(routeService, config, mainCjsAbsolutePath, htmlTemplate, emitAsset);
76
+ await renderPages(routeService, config, mainCjsAbsolutePath, htmlTemplate, emitAsset, distPath);
77
77
  if (!isDebugMode()) await rm(ssgFolderPath, {
78
78
  recursive: true
79
79
  });
@@ -1,5 +1,5 @@
1
1
  /*! LICENSE: ssgEnv.js.LICENSE.txt */
2
- import { node_os } from "../../2235.js";
2
+ import { node_os } from "../../4942.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 "../../../2235.js";
1
+ import { matchPath, getSidebarDataGroup } from "../../../4942.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 "../../../2235.js";
1
+ import { normalizeHref, logger, withBase } from "../../../4942.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 "../../6162.js";
1
+ import { unified, visit, remark_gfm, remark_mdx, remark_stringify } from "../../9283.js";
2
2
  function remarkSplitMdx(options = {}) {
3
3
  return (tree)=>{
4
4
  const newChildren = [];
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
- import "../../8006.js";
3
- import { createHead, pathToFileURL, logger } from "../../2235.js";
2
+ import "../../7986.js";
3
+ import { createHead, pathToFileURL, logger } from "../../4942.js";
4
4
  import { hintSSGFailed } from "../logger/hint.js";
5
5
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6
6
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
@@ -1,7 +1,7 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
- import "../../8006.js";
3
- import { logger } from "../../2235.js";
4
- import { pMap } from "../../1688.js";
2
+ import "../../7986.js";
3
+ import { logger } from "../../4942.js";
4
+ import { pMap } from "../../7261.js";
5
5
  import { renderPage } from "./renderPage.js";
6
6
  import { SSGConcurrency } from "../ssg/ssgEnv.js";
7
7
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
@@ -1,4 +1,4 @@
1
- import { writeFile, mkdir, rm, join, isDebugMode } from "../../2235.js";
1
+ import { writeFile, mkdir, rm, join, isDebugMode } from "../../4942.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 "../../2235.js";
1
+ import { node_path, logger, promises } from "../../4942.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 "../../2235.js";
1
+ import { createHash as external_node_crypto_createHash } from "../../4942.js";
2
2
  function createHash(str) {
3
3
  return external_node_crypto_createHash('sha256').update(str).digest('hex').slice(0, 8);
4
4
  }
@@ -1,5 +1,5 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
- import "../../8006.js";
2
+ import "../../7986.js";
3
3
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
4
4
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
5
5
  function createError(message, maxStackLines = 5) {
@@ -1,4 +1,4 @@
1
- import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../2235.js";
1
+ import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../4942.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 "../../8006.js";
1
+ import { promises } from "../../7986.js";
2
2
  async function pathExists(path) {
3
3
  try {
4
4
  await promises.access(path);
@@ -1,4 +1,4 @@
1
- import { removeLeadingSlash } from "../../2235.js";
1
+ import { removeLeadingSlash } from "../../4942.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 "../../3294.js";
1
+ import { node_os, node_path } from "../../8005.js";
2
2
  const isWindows = 'win32' === node_os.platform();
3
3
  function slash(p) {
4
4
  return p.replace(/\\/g, '/');
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
- import "../../8006.js";
3
- import { node_path, core_rspack, logger } from "../../2235.js";
2
+ import "../../7986.js";
3
+ import { node_path, core_rspack, logger } from "../../4942.js";
4
4
  import { pathExists, readJson } from "./fs.js";
5
5
  import { PACKAGE_ROOT } from "../constants.js";
6
6
  import { hintReactVersion } from "../logger/hint.js";
@@ -29,7 +29,7 @@ function App() {
29
29
  const GLOBAL_COMPONENTS_KEY = 'globalUIComponents';
30
30
  const query = new URLSearchParams(search);
31
31
  const hideGlobalUIComponents = false === frontmatter[GLOBAL_COMPONENTS_KEY] || "0" === query.get(GLOBAL_COMPONENTS_KEY);
32
- if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(Root, {
32
+ if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsx(Root, {
33
33
  children: /*#__PURE__*/ jsx(Layout, {})
34
34
  });
35
35
  return /*#__PURE__*/ jsxs(Root, {
@@ -6,9 +6,11 @@
6
6
  color: #fff;
7
7
  z-index: 999;
8
8
  background: var(--rp-banner-background);
9
+ box-sizing: border-box;
9
10
  justify-content: center;
10
11
  align-items: center;
11
12
  height: 36px;
13
+ padding: 0 3.5rem;
12
14
  display: flex;
13
15
  position: sticky;
14
16
  top: 0;
@@ -17,8 +19,17 @@
17
19
 
18
20
  .rp-banner__link {
19
21
  color: #fff;
22
+ text-align: center;
23
+ text-overflow: ellipsis;
24
+ white-space: nowrap;
25
+ flex: auto;
26
+ min-width: 0;
27
+ max-width: 100%;
20
28
  font-weight: 700;
29
+ line-height: 36px;
21
30
  text-decoration: none;
31
+ display: block;
32
+ overflow: hidden;
22
33
  }
23
34
 
24
35
  .rp-banner__link:hover {
@@ -25,6 +25,7 @@ const Banner = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
25
25
  /*#__PURE__*/ jsx(Link, {
26
26
  href: href,
27
27
  className: "rp-banner__link",
28
+ title: 'string' == typeof message ? message : void 0,
28
29
  children: message
29
30
  }),
30
31
  /*#__PURE__*/ jsx(SvgWrapper, {
@@ -5,7 +5,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
5
5
  import "./index.css";
6
6
  const DEFAULT_FOLD_HEIGHT = 300;
7
7
  function CodeBlock({ containerElementClassName, title, lang = 'txt', wrapCode: wrapCodeProp = false, lineNumbers: lineNumbersProp = false, fold = false, height, codeButtonGroupProps, children }) {
8
- if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(Fragment, {
8
+ if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsx(Fragment, {
9
9
  children: children
10
10
  });
11
11
  const { wrapCode: wrapCodeState, toggleWrapCode, copyElementRef } = useCodeButtonGroup(wrapCodeProp);
@@ -1,5 +1,5 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { useSite } from "@rspress/core/runtime";
2
+ import { useI18n, useSite } from "@rspress/core/runtime";
3
3
  import { IconWrap, IconWrapped, SvgWrapper } from "@rspress/core/theme";
4
4
  import clsx from "clsx";
5
5
  import { useRef, useState } from "react";
@@ -20,6 +20,7 @@ const useCodeButtonGroup = (initialWrapCode)=>{
20
20
  };
21
21
  };
22
22
  function CodeButtonGroup({ wrapCode, toggleWrapCode, copyElementRef, showWrapCodeButton = true, showCopyButton = true }) {
23
+ const t = useI18n();
23
24
  return /*#__PURE__*/ jsx(Fragment, {
24
25
  children: /*#__PURE__*/ jsxs("div", {
25
26
  className: "rp-code-button-group",
@@ -27,7 +28,8 @@ function CodeButtonGroup({ wrapCode, toggleWrapCode, copyElementRef, showWrapCod
27
28
  showWrapCodeButton && /*#__PURE__*/ jsxs("button", {
28
29
  className: clsx('rp-code-button-group__button', 'rp-code-wrap-button', wrapCode && 'rp-code-wrap-button--wrapped'),
29
30
  onClick: ()=>toggleWrapCode(),
30
- title: "Toggle code wrap",
31
+ title: t('codeButtonGroupWrapButtonText'),
32
+ "aria-label": t('codeButtonGroupWrapButtonText'),
31
33
  children: [
32
34
  /*#__PURE__*/ jsx(SvgWrapper, {
33
35
  icon: IconWrapped,
@@ -14,7 +14,7 @@ const getHeadingMap = ()=>{
14
14
  };
15
15
  };
16
16
  function FallbackHeading({ level, title }) {
17
- if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(Fragment, {
17
+ if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsx(Fragment, {
18
18
  children: `${'#'.repeat(level)} ${title}\n\n`
19
19
  });
20
20
  const titleSlug = title && slug(title.trim());
@@ -42,6 +42,9 @@ const Link = /*#__PURE__*/ forwardRef((props, ref)=>{
42
42
  onMouseEnter?.(event);
43
43
  preloadLink(removeBaseHref);
44
44
  },
45
+ onTouchStart: ()=>{
46
+ preloadLink(removeBaseHref);
47
+ },
45
48
  onClick: (e)=>{
46
49
  onClick?.(e);
47
50
  if (0 !== e.button || e.currentTarget.target && '_self' !== e.currentTarget.target || e.metaKey || e.shiftKey || e.altKey || e.ctrlKey) return;
@@ -59,6 +62,9 @@ const Link = /*#__PURE__*/ forwardRef((props, ref)=>{
59
62
  onMouseEnter?.(event);
60
63
  preloadLink(removeBaseHref);
61
64
  },
65
+ onTouchStart: ()=>{
66
+ preloadLink(removeBaseHref);
67
+ },
62
68
  onClick: (e)=>{
63
69
  onClick?.(e);
64
70
  if (0 !== e.button || e.currentTarget.target && '_self' !== e.currentTarget.target || e.metaKey || e.shiftKey || e.altKey || e.ctrlKey) return;
@@ -21,7 +21,7 @@ function getHref(href) {
21
21
  withBaseHref: href,
22
22
  removeBaseHref: href
23
23
  };
24
- withBaseHref = 'relative' !== linkType || process.env.__SSR__ ? withBase(cleanUrlByConfig(href)) : new URL(href, window.location.href).pathname;
24
+ withBaseHref = 'relative' !== linkType || import.meta.env.SSR ? withBase(cleanUrlByConfig(href)) : new URL(href, window.location.href).pathname;
25
25
  const removeBaseHref = removeBase(withBaseHref);
26
26
  return {
27
27
  withBaseHref,
@@ -39,7 +39,7 @@ function useLinkNavigate({ startTransition } = {
39
39
  if ('external' === linkType || 'hashOnly' === linkType) return void window.location.assign(href);
40
40
  const preloadChunkThenNavigate = async ()=>{
41
41
  const inCurrPage = isActive(removeBaseHref, currPagePathname);
42
- if (!process.env.__SSR__ && !inCurrPage) {
42
+ if (!import.meta.env.SSR && !inCurrPage) {
43
43
  const matchedRoute = pathnameToRouteService(removeBaseHref);
44
44
  if (!matchedRoute) return void window.location.assign(withBaseHref);
45
45
  {
@@ -1,13 +1,11 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useI18n, useSite } from "@rspress/core/runtime";
3
- import { EditLink, LlmsCopyRow, LlmsOpenRow, ReadPercent, Toc, useDynamicToc } from "@rspress/core/theme";
3
+ import { EditLink, LlmsCopyRow, LlmsOpenRow, ReadPercent, Toc } from "@rspress/core/theme";
4
4
  import "./index.css";
5
5
  import { ScrollToTop } from "./ScrollToTop.js";
6
6
  function Outline() {
7
7
  const t = useI18n();
8
- const headers = useDynamicToc();
9
8
  const { site: { themeConfig: { enableScrollToTop = true, llmsUI } } } = useSite();
10
- if (0 === headers.length) return /*#__PURE__*/ jsx(Fragment, {});
11
9
  const placement = 'object' == typeof llmsUI ? llmsUI?.placement ?? 'title' : 'title';
12
10
  return /*#__PURE__*/ jsxs("div", {
13
11
  className: "rp-outline",
@@ -115,7 +115,7 @@ function Overview(props) {
115
115
  query
116
116
  ]);
117
117
  const overviewTitle = title || 'Overview';
118
- if (process.env.__SSR_MD__) return /*#__PURE__*/ jsxs(Fragment, {
118
+ if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsxs(Fragment, {
119
119
  children: [
120
120
  /*#__PURE__*/ jsx(FallbackHeading, {
121
121
  level: 1,
@@ -34,7 +34,7 @@ function OverviewGroupMarkdown({ group }) {
34
34
  });
35
35
  }
36
36
  const OverviewGroup = ({ group })=>{
37
- if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(OverviewGroupMarkdown, {
37
+ if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsx(OverviewGroupMarkdown, {
38
38
  group: group
39
39
  });
40
40
  const { itemsWithContent, itemsWithoutContent } = useMemo(()=>{
@@ -111,7 +111,7 @@ function PackageManagerTabs({ command, exec, dlx, additionalTabs = [] }) {
111
111
  commandInfo.bun = normalizeCommand(commandInfo.bun);
112
112
  commandInfo.deno = normalizeCommand(commandInfo.deno);
113
113
  } else commandInfo = command;
114
- if (process.env.__SSR_MD__) return Object.values(commandInfo).reduce((previous, current)=>{
114
+ if (import.meta.env.SSG_MD) return Object.values(commandInfo).reduce((previous, current)=>{
115
115
  const [packageManager, command] = splitTo2Parts(current);
116
116
  return previous + `\n\`\`\`sh [${packageManager}]\n` + `${packageManager}${command}\n` + "```\n";
117
117
  }, '');
@@ -335,6 +335,7 @@ function SearchPanel({ focused, setFocused }) {
335
335
  "aria-label": "SearchPanelInput",
336
336
  autoComplete: "off",
337
337
  autoFocus: true,
338
+ inputMode: "search",
338
339
  onChange: (e)=>handleQueryChange(e.target.value)
339
340
  }),
340
341
  /*#__PURE__*/ jsx("label", {
@@ -128,13 +128,18 @@ class PageSearcher {
128
128
  const statementStartIndex = byteToCharIndex(content, highlightStartIndex);
129
129
  const statementEndIndex = byteToCharIndex(content, highlightStartIndex + THRESHOLD_CONTENT_LENGTH);
130
130
  const statement = content.slice(statementStartIndex, statementEndIndex);
131
- const highlightInfoList = item._matchesPosition.content.filter((match)=>match.start >= highlightStartIndex && match.start + match.length <= highlightStartIndex + THRESHOLD_CONTENT_LENGTH).map((match)=>{
132
- const startCharIndex = byteToCharIndex(content, match.start) - statementStartIndex + 3;
133
- return {
134
- start: startCharIndex,
135
- length: match.length
136
- };
137
- });
131
+ const highlightInfoList = [];
132
+ const limitIndex = highlightStartIndex + THRESHOLD_CONTENT_LENGTH;
133
+ for (const match of item._matchesPosition?.content || []){
134
+ const { start, length } = match;
135
+ if (start >= highlightStartIndex && start + length <= limitIndex) {
136
+ const startCharIndex = byteToCharIndex(content, start) - statementStartIndex + 3;
137
+ highlightInfoList.push({
138
+ start: startCharIndex,
139
+ length
140
+ });
141
+ }
142
+ }
138
143
  matchedResult.push({
139
144
  type: 'content',
140
145
  title: item.title,
@@ -1,7 +1,10 @@
1
+ import { type ReactNode } from 'react';
1
2
  import './index.scss';
2
3
  export declare const SidebarMenu: import("react").ForwardRefExoticComponent<{
3
4
  isSidebarOpen: boolean;
4
5
  onIsSidebarOpenChange: (isOpen: boolean) => void;
5
6
  isOutlineOpen: boolean;
6
7
  onIsOutlineOpenChange: (isOpen: boolean) => void;
8
+ beforeOutline?: ReactNode;
9
+ afterOutline?: ReactNode;
7
10
  } & import("react").RefAttributes<unknown>>;