@rspress/core 2.0.23 → 2.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/dist/cli/index.js +2 -2
  2. package/dist/{common-Qw-RoVFD.js → common-Bo3KCGim.js} +4 -1
  3. package/dist/config/loadConfigFile.js +1 -1
  4. package/dist/eject-theme/components/CdnTabs/index.test.tsx +71 -0
  5. package/dist/eject-theme/components/CdnTabs/index.tsx +175 -0
  6. package/dist/eject-theme/components/DocContent/index.tsx +0 -3
  7. package/dist/eject-theme/components/FallbackHeading/index.tsx +6 -1
  8. package/dist/eject-theme/components/Link/getHref.ts +1 -0
  9. package/dist/eject-theme/components/Link/index.tsx +9 -21
  10. package/dist/eject-theme/components/Link/useLinkNavigate.ts +43 -54
  11. package/dist/eject-theme/components/NavTitle/index.test.tsx +78 -0
  12. package/dist/eject-theme/components/NavTitle/index.tsx +9 -5
  13. package/dist/eject-theme/components/PackageManagerTabs/index.test.tsx +79 -1
  14. package/dist/eject-theme/components/PackageManagerTabs/index.tsx +25 -12
  15. package/dist/eject-theme/components/Search/NoSearchResult.scss +1 -2
  16. package/dist/eject-theme/components/Search/SearchPanel.scss +75 -63
  17. package/dist/eject-theme/components/Search/SuggestItem.scss +28 -41
  18. package/dist/eject-theme/components/Search/logic/providers/LocalProvider.ts +4 -1
  19. package/dist/eject-theme/components/Search/useSearchPanel.ts +103 -36
  20. package/dist/eject-theme/components/Sidebar/SidebarItem.scss +8 -0
  21. package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.scss +3 -0
  22. package/dist/eject-theme/components/SocialLinks/GithubStars.test.tsx +4 -1
  23. package/dist/eject-theme/components/SocialLinks/GithubStars.tsx +1 -1
  24. package/dist/entry/worker.js +1 -1
  25. package/dist/index.d.ts +1 -1
  26. package/dist/node/PluginDriver.d.ts +5 -0
  27. package/dist/node/PluginDriver.js +17 -2
  28. package/dist/node/auto-nav-sidebar/index.js +1 -1
  29. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  30. package/dist/node/auto-nav-sidebar/normalize.js +1 -1
  31. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  32. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  33. package/dist/node/constants.js +1 -1
  34. package/dist/node/eject.js +1 -1
  35. package/dist/node/initRsbuild.js +19 -7
  36. package/dist/node/llms.d.ts +1 -1
  37. package/dist/node/llms.js +2 -2
  38. package/dist/node/logger/hint.d.ts +1 -0
  39. package/dist/node/logger/hint.js +8 -2
  40. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -0
  41. package/dist/node/mdx/remarkPlugins/link.js +1 -1
  42. package/dist/node/route/RoutePage.js +1 -1
  43. package/dist/node/route/RouteService.js +1 -1
  44. package/dist/node/route/extractPageData.js +1 -1
  45. package/dist/node/route/normalizeRoutePath.js +1 -1
  46. package/dist/node/runtimeModule/{DEFAULT_I18N_TEXT.d.ts → i18n/DEFAULT_I18N_TEXT.d.ts} +28 -0
  47. package/dist/node/runtimeModule/{DEFAULT_I18N_TEXT.js → i18n/DEFAULT_I18N_TEXT.js} +28 -0
  48. package/dist/node/runtimeModule/i18n/getI18nData.d.ts +11 -0
  49. package/dist/node/runtimeModule/{i18n.js → i18n/getI18nData.js} +35 -22
  50. package/dist/node/runtimeModule/i18n/rsbuildPlugin.d.ts +5 -0
  51. package/dist/node/runtimeModule/i18n/rsbuildPlugin.js +21 -0
  52. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  53. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  54. package/dist/node/runtimeModule/searchHooks.js +2 -2
  55. package/dist/node/runtimeModule/siteData/createSiteData.d.ts +2 -1
  56. package/dist/node/runtimeModule/siteData/createSiteData.js +3 -3
  57. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.d.ts +2 -1
  58. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +3 -4
  59. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +2 -2
  60. package/dist/node/serve.js +1 -1
  61. package/dist/node/sitemap.d.ts +7 -0
  62. package/dist/node/sitemap.js +86 -0
  63. package/dist/node/ssg/alternateLinks.js +1 -1
  64. package/dist/node/ssg/htmlFile.js +1 -1
  65. package/dist/node/ssg/renderHtmlTemplate.js +1 -1
  66. package/dist/node/ssg/renderPage.js +1 -1
  67. package/dist/node/ssg/renderPageWorker.js +1 -1
  68. package/dist/node/ssg/renderPages.js +2 -2
  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/renderPage.js +5 -4
  74. package/dist/node/ssg-md/renderPages.js +2 -2
  75. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  76. package/dist/node/utils/checkLanguageParity.js +1 -1
  77. package/dist/node/utils/createHash.js +1 -1
  78. package/dist/node/utils/flattenMdxContent.js +1 -1
  79. package/dist/node/utils/getPageKey.js +1 -1
  80. package/dist/node/utils/reactAlias.js +6 -3
  81. package/dist/{a~0.js → p~0.js} +23 -18
  82. package/dist/runtime/App.js +20 -29
  83. package/dist/runtime/BrowserOnly.d.ts +1 -1
  84. package/dist/runtime/BrowserOnly.js +53 -20
  85. package/dist/runtime/ClientApp.d.ts +3 -2
  86. package/dist/runtime/ClientApp.js +31 -21
  87. package/dist/runtime/ErrorRoute.d.ts +1 -0
  88. package/dist/runtime/ErrorRoute.js +30 -0
  89. package/dist/runtime/NoSSR.d.ts +7 -3
  90. package/dist/runtime/NoSSR.js +30 -9
  91. package/dist/runtime/PageRoute.d.ts +2 -0
  92. package/dist/runtime/PageRoute.js +70 -0
  93. package/dist/runtime/createServerRouter.d.ts +4 -0
  94. package/dist/runtime/createServerRouter.js +17 -0
  95. package/dist/runtime/csrClientEntry.js +5 -2
  96. package/dist/runtime/hooks/useWebMcp.d.ts +36 -0
  97. package/dist/runtime/hooks/useWebMcp.js +80 -0
  98. package/dist/runtime/index.d.ts +6 -3
  99. package/dist/runtime/index.js +6 -5
  100. package/dist/runtime/initPageData.d.ts +0 -3
  101. package/dist/runtime/initPageData.js +9 -45
  102. package/dist/runtime/pageDataLoader.d.ts +11 -0
  103. package/dist/runtime/pageDataLoader.js +7 -0
  104. package/dist/runtime/react.d.ts +5 -0
  105. package/dist/runtime/react.js +4 -0
  106. package/dist/runtime/reactDom.d.ts +6 -0
  107. package/dist/runtime/reactDom.js +2 -1
  108. package/dist/runtime/socialLinks.d.ts +1 -0
  109. package/dist/runtime/socialLinks.js +3 -0
  110. package/dist/runtime/ssrClientEntry.js +14 -6
  111. package/dist/runtime/ssrMdServerEntry.js +10 -21
  112. package/dist/runtime/ssrServerEntry.js +10 -21
  113. package/dist/static/assets/package.json +58 -0
  114. package/dist/theme/assets/bun.js +101 -0
  115. package/dist/theme/assets/deno.js +15 -0
  116. package/dist/theme/assets/jsdelivr.js +53 -0
  117. package/dist/theme/{components/PackageManagerTabs/icons/Npm.js → assets/npm.js} +4 -4
  118. package/dist/theme/{components/PackageManagerTabs/icons/Pnpm.js → assets/pnpm.js} +4 -4
  119. package/dist/theme/assets/unpkg.js +15 -0
  120. package/dist/theme/assets/yarn.js +22 -0
  121. package/dist/theme/components/CdnTabs/index.d.ts +10 -0
  122. package/dist/theme/components/CdnTabs/index.js +146 -0
  123. package/dist/theme/components/DocContent/index.js +1 -2
  124. package/dist/theme/components/FallbackHeading/index.js +1 -0
  125. package/dist/theme/components/Link/index.js +4 -17
  126. package/dist/theme/components/Link/useLinkNavigate.d.ts +2 -2
  127. package/dist/theme/components/Link/useLinkNavigate.js +22 -36
  128. package/dist/theme/components/NavTitle/index.js +10 -5
  129. package/dist/theme/components/PackageManagerTabs/index.d.ts +2 -0
  130. package/dist/theme/components/PackageManagerTabs/index.js +22 -12
  131. package/dist/theme/components/Search/NoSearchResult.css +1 -2
  132. package/dist/theme/components/Search/SearchPanel.css +72 -51
  133. package/dist/theme/components/Search/SuggestItem.css +21 -34
  134. package/dist/theme/components/Search/logic/providers/LocalProvider.js +4 -1
  135. package/dist/theme/components/Search/useSearchPanel.js +74 -26
  136. package/dist/theme/components/Sidebar/SidebarItem.css +5 -0
  137. package/dist/theme/components/Sidebar/SidebarSectionHeader.css +1 -0
  138. package/dist/theme/components/SocialLinks/GithubStars.js +1 -1
  139. package/dist/theme/hooks/useDynamicToc.js +27 -34
  140. package/dist/theme/hooks/useWebMcpNavigation.d.ts +6 -0
  141. package/dist/theme/hooks/useWebMcpNavigation.js +123 -0
  142. package/dist/theme/hooks/useWebMcpPageList.d.ts +6 -0
  143. package/dist/theme/hooks/useWebMcpPageList.js +25 -0
  144. package/dist/theme/hooks/useWebMcpPageReading.d.ts +7 -0
  145. package/dist/theme/hooks/useWebMcpPageReading.js +23 -0
  146. package/dist/theme/hooks/useWebMcpSiteInfo.d.ts +6 -0
  147. package/dist/theme/hooks/useWebMcpSiteInfo.js +22 -0
  148. package/dist/theme/icons.d.ts +7 -0
  149. package/dist/theme/icons.js +15 -1
  150. package/dist/theme/index.d.ts +6 -2
  151. package/dist/theme/index.js +6 -2
  152. package/dist/theme/layout/ErrorLayout/index.css +52 -0
  153. package/dist/theme/layout/ErrorLayout/index.d.ts +8 -0
  154. package/dist/theme/layout/ErrorLayout/index.js +76 -0
  155. package/dist/theme/layout/Layout/index.js +1 -2
  156. package/dist/theme/webMcp/tools.d.ts +56 -0
  157. package/dist/theme/webMcp/tools.js +122 -0
  158. package/dist/theme/webMcp/types.d.ts +35 -0
  159. package/dist/theme/webMcp/types.js +0 -0
  160. package/dist/tinypool~0.js +19 -49
  161. package/dist/y~0.js +166 -0
  162. package/package.json +18 -18
  163. package/dist/b~0.js +0 -106
  164. package/dist/eject-theme/components/PackageManagerTabs/icons/Bun.tsx +0 -101
  165. package/dist/eject-theme/components/PackageManagerTabs/icons/Deno.tsx +0 -18
  166. package/dist/eject-theme/components/PackageManagerTabs/icons/Npm.tsx +0 -16
  167. package/dist/eject-theme/components/PackageManagerTabs/icons/Pnpm.tsx +0 -22
  168. package/dist/eject-theme/components/PackageManagerTabs/icons/Yarn.tsx +0 -18
  169. package/dist/node/runtimeModule/i18n.d.ts +0 -8
  170. package/dist/theme/components/PackageManagerTabs/icons/Bun.d.ts +0 -2
  171. package/dist/theme/components/PackageManagerTabs/icons/Bun.js +0 -137
  172. package/dist/theme/components/PackageManagerTabs/icons/Deno.d.ts +0 -2
  173. package/dist/theme/components/PackageManagerTabs/icons/Deno.js +0 -15
  174. package/dist/theme/components/PackageManagerTabs/icons/Npm.d.ts +0 -2
  175. package/dist/theme/components/PackageManagerTabs/icons/Pnpm.d.ts +0 -2
  176. package/dist/theme/components/PackageManagerTabs/icons/Yarn.d.ts +0 -2
  177. package/dist/theme/components/PackageManagerTabs/icons/Yarn.js +0 -22
  178. package/dist/theme/logic/useScrollAfterNav.d.ts +0 -5
  179. package/dist/theme/logic/useScrollAfterNav.js +0 -35
  180. package/dist/theme/logic/useScrollReset.d.ts +0 -5
  181. package/dist/theme/logic/useScrollReset.js +0 -12
@@ -1,6 +1,6 @@
1
- import { getIconUrlPath } from "../../../a~0.js";
1
+ import { getIconUrlPath } from "../../../p~0.js";
2
2
  import { normalizeThemeConfig } from "./normalizeThemeConfig.js";
3
- async function createSiteData(userConfig) {
3
+ async function createSiteData(userConfig, pluginDriver) {
4
4
  const tempSearchObj = Object.assign({}, userConfig.search);
5
5
  if (tempSearchObj) tempSearchObj.searchHooks = void 0;
6
6
  const siteData = {
@@ -13,7 +13,7 @@ async function createSiteData(userConfig) {
13
13
  useTransitions: true,
14
14
  ...userConfig?.route
15
15
  },
16
- themeConfig: await normalizeThemeConfig(userConfig),
16
+ themeConfig: await normalizeThemeConfig(userConfig, pluginDriver),
17
17
  lang: userConfig?.lang || '',
18
18
  locales: userConfig?.locales || userConfig.themeConfig?.locales || [],
19
19
  logo: userConfig?.logo || '',
@@ -1,2 +1,3 @@
1
1
  import { type NormalizedDefaultThemeConfig, type UserConfig } from '@rspress/shared';
2
- export declare function normalizeThemeConfig(docConfig: UserConfig): Promise<NormalizedDefaultThemeConfig>;
2
+ import type { PluginDriver } from '../../PluginDriver.js';
3
+ export declare function normalizeThemeConfig(docConfig: UserConfig, pluginDriver: PluginDriver): Promise<NormalizedDefaultThemeConfig>;
@@ -1,14 +1,13 @@
1
- import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../a~0.js";
2
- import { getI18nData } from "../i18n.js";
1
+ import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../p~0.js";
3
2
  import { applyReplaceRules } from "../../utils/applyReplaceRules.js";
4
- async function normalizeThemeConfig(docConfig) {
3
+ async function normalizeThemeConfig(docConfig, pluginDriver) {
5
4
  const { locales: siteLocales, lang, replaceRules = [], multiVersion } = docConfig;
6
5
  const { versions = [] } = multiVersion || {};
7
6
  const hasMultiVersion = versions.length > 0;
8
7
  docConfig.themeConfig = docConfig.themeConfig || {};
9
8
  const { themeConfig } = docConfig;
10
9
  const locales = siteLocales ?? (themeConfig?.locales || []);
11
- const i18nTextData = await getI18nData(docConfig);
10
+ const i18nTextData = await pluginDriver.getI18nData();
12
11
  const normalizeLinkPrefix = (link, currentLang)=>{
13
12
  const normalizedLink = slash(link);
14
13
  if (!currentLang || !link || normalizedLink.startsWith(`/${currentLang}`) || isExternalUrl(normalizedLink) || hasMultiVersion) return normalizedLink;
@@ -1,4 +1,4 @@
1
- import { isProduction, logger } from "../../../a~0.js";
1
+ import { isProduction, logger } from "../../../p~0.js";
2
2
  import { modifyConfigWithAutoNavSide } from "../../auto-nav-sidebar/index.js";
3
3
  import { createSiteData } from "./createSiteData.js";
4
4
  const siteDataVMPlugin = (context)=>{
@@ -12,7 +12,7 @@ const siteDataVMPlugin = (context)=>{
12
12
  } finally{
13
13
  logger.debug(`modifyConfigWithAutoNavSide - size: ${mdFileSet.size} cost: ${performance.now() - now}ms`);
14
14
  }
15
- const { siteData } = await createSiteData(config);
15
+ const { siteData } = await createSiteData(config, pluginDriver);
16
16
  return {
17
17
  code: `export default ${JSON.stringify(siteData, null, 2)}`,
18
18
  metaFileSet,
@@ -1,4 +1,4 @@
1
- import { mergeRsbuildConfig } from "../a~0.js";
1
+ import { mergeRsbuildConfig } from "../p~0.js";
2
2
  import { normalizeConfigResult } from "../config/loadConfigFile.js";
3
3
  import { PluginDriver } from "./PluginDriver.js";
4
4
  import { initRsbuild } from "./initRsbuild.js";
@@ -0,0 +1,7 @@
1
+ import type { RsbuildPlugin } from '@rsbuild/core';
2
+ import { type UserConfig } from '@rspress/shared';
3
+ import type { RouteService } from './route/RouteService.js';
4
+ export declare function rsbuildPluginSitemap({ config, routeService, }: {
5
+ config: UserConfig;
6
+ routeService: Pick<RouteService, 'getRoutes'>;
7
+ }): RsbuildPlugin;
@@ -0,0 +1,86 @@
1
+ import { withSiteOrigin, logger, glob, promises_stat, withBase } from "../p~0.js";
2
+ import { routePath2HtmlFileName } from "./ssg/htmlFile.js";
3
+ function ensureTrailingSlash(url) {
4
+ return url.endsWith('/') ? url : `${url}/`;
5
+ }
6
+ function normalizeSiteUrl(siteUrl) {
7
+ try {
8
+ const url = new URL(siteUrl);
9
+ if (![
10
+ 'http:',
11
+ 'https:'
12
+ ].includes(url.protocol) || url.href.includes('?') || url.href.includes('#')) throw new Error('Expected an HTTP(S) URL without a query or fragment.');
13
+ url.pathname = ensureTrailingSlash(url.pathname);
14
+ return url.href;
15
+ } catch {
16
+ throw new Error('[sitemap] `sitemap.siteUrl` must be an absolute HTTP(S) URL without a query or fragment, such as `https://example.com/base/`.');
17
+ }
18
+ }
19
+ function getSiteUrl(siteUrl, config) {
20
+ if (siteUrl) return normalizeSiteUrl(siteUrl);
21
+ const base = withBase('/', config.base ?? '/');
22
+ try {
23
+ return config.siteOrigin ? withSiteOrigin(base, config.siteOrigin) : encodeURI(base);
24
+ } catch {
25
+ throw new Error('[sitemap] `siteOrigin` in rspress.config.ts must be a valid absolute URL origin with protocol, such as `https://example.com`.');
26
+ }
27
+ }
28
+ const generateNode = (sitemap)=>{
29
+ let result = '<url>';
30
+ for (const [tag, value] of Object.entries(sitemap)){
31
+ const escaped = String(value).replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;').replaceAll("'", '&#39;');
32
+ result += `<${tag}>${escaped}</${tag}>`;
33
+ }
34
+ result += '</url>';
35
+ return result;
36
+ };
37
+ const generateXml = (sitemaps)=>{
38
+ logger.info(`Generate sitemap.xml for ${sitemaps.length} pages.`);
39
+ return `<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">${sitemaps.reduce((node, sitemap)=>node + generateNode(sitemap), '')}</urlset>`;
40
+ };
41
+ function rsbuildPluginSitemap({ config, routeService }) {
42
+ const options = 'object' == typeof config.sitemap ? config.sitemap : {};
43
+ const cleanUrls = config.route?.cleanUrls ?? false;
44
+ return {
45
+ name: 'rspress:sitemap',
46
+ setup (api) {
47
+ api.modifyBundlerChain((_chain, { isProd, environment })=>{
48
+ if (!isProd || 'web' !== environment.name) return;
49
+ const resolvedSiteUrl = getSiteUrl(options.siteUrl, config);
50
+ api.processAssets({
51
+ stage: 'additional',
52
+ environments: [
53
+ 'web'
54
+ ]
55
+ }, async ({ compilation, sources })=>{
56
+ if (compilation.errors.length) return;
57
+ for (const publicDir of api.getNormalizedConfig().server.publicDir){
58
+ if (false === publicDir.copyOnBuild) continue;
59
+ const files = await glob('sitemap.xml', {
60
+ cwd: publicDir.name,
61
+ ignore: publicDir.ignore
62
+ });
63
+ if (files.length) return void logger.warn('[sitemap] Preserving public sitemap.xml.');
64
+ }
65
+ const sitemaps = [];
66
+ const seen = new Set();
67
+ for (const { routePath, absolutePath } of routeService.getRoutes()){
68
+ if (seen.has(routePath)) continue;
69
+ seen.add(routePath);
70
+ const pathname = cleanUrls ? routePath : `/${routePath2HtmlFileName(routePath)}`;
71
+ const encodedPath = pathname.split('/').map(encodeURIComponent).join('/');
72
+ sitemaps.push({
73
+ loc: `${resolvedSiteUrl.replace(/\/$/, '')}${encodedPath}`,
74
+ lastmod: (await promises_stat(absolutePath)).mtime.toISOString(),
75
+ priority: '/' === routePath ? '1.0' : options.defaultPriority ?? '0.5',
76
+ changefreq: options.defaultChangeFreq ?? 'monthly',
77
+ ...options.customMaps?.[routePath] ?? {}
78
+ });
79
+ }
80
+ compilation.emitAsset('sitemap.xml', new sources.RawSource(generateXml(sitemaps)));
81
+ });
82
+ });
83
+ }
84
+ };
85
+ }
86
+ export { rsbuildPluginSitemap };
@@ -1,4 +1,4 @@
1
- import { normalizeHref, removeTrailingSlash, addLeadingSlash, normalizePosixPath, withSiteOrigin } from "../../a~0.js";
1
+ import { normalizeHref, removeTrailingSlash, addLeadingSlash, normalizePosixPath, withSiteOrigin } from "../../p~0.js";
2
2
  function createAlternateLinksByRoute(routes, config) {
3
3
  const routeGroups = new Map();
4
4
  for (const route of routes){
@@ -1,4 +1,4 @@
1
- import { external_node_path_resolve, relative, isAbsolute } from "../../b~0.js";
1
+ import { external_node_path_resolve, relative, isAbsolute } from "../../y~0.js";
2
2
  const routePath2HtmlFileName = (routePath)=>{
3
3
  let fileName = routePath;
4
4
  fileName = fileName.endsWith('/') ? `${routePath}index.html` : `${routePath}.html`;
@@ -1,4 +1,4 @@
1
- import { posix } from "../../b~0.js";
1
+ import { posix } from "../../y~0.js";
2
2
  import { META_GENERATOR, RSPRESS_VERSION, APP_HTML_MARKER, HEAD_MARKER } from "../constants.js";
3
3
  import { routePath2HtmlFileName } from "./htmlFile.js";
4
4
  import { createError } from "../utils/error.js";
@@ -1,6 +1,6 @@
1
1
  import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
2
2
  import "../../t~0.js";
3
- import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../b~0.js";
3
+ import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../y~0.js";
4
4
  import { hintSSGFailed } from "../logger/hint.js";
5
5
  import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
6
6
  const picocolors = rspackRequire("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
@@ -1,7 +1,7 @@
1
1
  import { writeFile, mkdir, dirname, workerData } from "../../4~0.js";
2
2
  import { createError } from "../utils/error.js";
3
3
  import { resolveHtmlFilePath } from "./htmlFile.js";
4
- import { pMap } from "../../b~0.js";
4
+ import { pMap } from "../../y~0.js";
5
5
  import { renderPage } from "./renderPage.js";
6
6
  const params = workerData?.[1]?.params;
7
7
  if (!params) throw createError('SSG Worker Thread workerData params missing');
@@ -1,11 +1,11 @@
1
1
  /*! LICENSE: renderPages.js.LICENSE.txt */
2
2
  import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
3
3
  import "../../t~0.js";
4
- import { node_path, fileURLToPath, logger, chunk } from "../../a~0.js";
4
+ import { node_path, fileURLToPath, logger, chunk } from "../../p~0.js";
5
5
  import { createAlternateLinksByRoute } from "./alternateLinks.js";
6
6
  import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
7
7
  import { routePath2HtmlFileName } from "./htmlFile.js";
8
- import { pMap } from "../../b~0.js";
8
+ import { pMap } from "../../y~0.js";
9
9
  import { renderPage } from "./renderPage.js";
10
10
  import { hintSSGFailed } from "../logger/hint.js";
11
11
  import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
@@ -1,4 +1,4 @@
1
- import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../a~0.js";
1
+ import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../p~0.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, routeChunkAssets })=>({
@@ -1,5 +1,5 @@
1
1
  /*! LICENSE: ssgEnv.js.LICENSE.txt */
2
- import { node_os } from "../../a~0.js";
2
+ import { node_os } from "../../p~0.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 "../../../a~0.js";
1
+ import { matchPath, getSidebarDataGroup } from "../../../p~0.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, withSiteOrigin, logger, withBase } from "../../../a~0.js";
1
+ import { normalizeHref, withSiteOrigin, logger, withBase } from "../../../p~0.js";
2
2
  import { extractInfoFromFrontmatterWithAbsolutePath } from "../../auto-nav-sidebar/utils.js";
3
3
  function routePathToMdPath(routePath, base, siteOrigin) {
4
4
  let url = routePath;
@@ -1,7 +1,7 @@
1
1
  import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
2
2
  import "../../t~0.js";
3
- import { createHead, pathToFileURL, logger } from "../../a~0.js";
4
- import { hintSSGFailed } from "../logger/hint.js";
3
+ import { createHead, pathToFileURL, logger } from "../../p~0.js";
4
+ import { hintSSGMDFailed } from "../logger/hint.js";
5
5
  const picocolors = rspackRequire("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6
6
  var picocolors_default = /*#__PURE__*/ compatGetDefaultExport(picocolors);
7
7
  async function renderPage(route, ssrBundlePath) {
@@ -12,9 +12,9 @@ async function renderPage(route, ssrBundlePath) {
12
12
  render = ssrExports.render;
13
13
  } catch (e) {
14
14
  if (e instanceof Error) {
15
- logger.error(`Failed to load SSG bundle: ${picocolors_default().yellow(ssrBundlePath)}: ${e.message}`);
15
+ logger.error(`Failed to load SSG-MD bundle: ${picocolors_default().yellow(ssrBundlePath)}: ${e.message}`);
16
16
  logger.debug(e);
17
- hintSSGFailed();
17
+ hintSSGMDFailed();
18
18
  }
19
19
  throw e;
20
20
  }
@@ -27,6 +27,7 @@ async function renderPage(route, ssrBundlePath) {
27
27
  if (e instanceof Error) {
28
28
  logger.error(`Page "${picocolors_default().yellow(routePath)}" SSG-MD rendering failed.
29
29
  ${absolutePath ? picocolors_default().gray(` File: ${absolutePath}\n`) : ''} ${picocolors_default().gray(e.toString())}`);
30
+ hintSSGMDFailed();
30
31
  throw e;
31
32
  }
32
33
  }
@@ -1,7 +1,7 @@
1
1
  import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
2
2
  import "../../t~0.js";
3
- import { logger } from "../../a~0.js";
4
- import { pMap } from "../../b~0.js";
3
+ import { logger } from "../../p~0.js";
4
+ import { pMap } from "../../y~0.js";
5
5
  import { renderPage } from "./renderPage.js";
6
6
  import { SSGConcurrency } from "../ssg/ssgEnv.js";
7
7
  const picocolors = rspackRequire("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
@@ -1,4 +1,4 @@
1
- import { writeFile, mkdir, rm, join, isDebugMode } from "../../a~0.js";
1
+ import { writeFile, mkdir, rm, join, isDebugMode } from "../../p~0.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 "../../a~0.js";
1
+ import { node_path, logger, promises } from "../../p~0.js";
2
2
  import { slash } from "./slash.js";
3
3
  import { createError } from "./error.js";
4
4
  async function getAllMarkdownFilesFrom(dirPath) {
@@ -1,4 +1,4 @@
1
- import { createHash as external_node_crypto_createHash } from "../../a~0.js";
1
+ import { createHash as external_node_crypto_createHash } from "../../p~0.js";
2
2
  function createHash(str, length = 8) {
3
3
  return external_node_crypto_createHash('sha256').update(str).digest('hex').slice(0, length);
4
4
  }
@@ -1,4 +1,4 @@
1
- import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../a~0.js";
1
+ import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../p~0.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 { removeLeadingSlash } from "../../a~0.js";
1
+ import { removeLeadingSlash } from "../../p~0.js";
2
2
  function getPageKey(route) {
3
3
  const cleanRoute = removeLeadingSlash(route);
4
4
  return cleanRoute.replace(/\//g, '_').replace(/\.[^.]+$/, '') || 'index';
@@ -1,6 +1,6 @@
1
1
  import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
2
2
  import "../../t~0.js";
3
- import { node_path, core_rspack, logger } from "../../a~0.js";
3
+ import { node_path, core_rspack, logger } from "../../p~0.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";
@@ -36,8 +36,11 @@ async function resolveReactRouterDomAlias() {
36
36
  const resolved = await resolver.async(basedir, 'react-router-dom/package.json');
37
37
  if (resolved.error) throw Error(resolved.error);
38
38
  if (!resolved.path) throw Error("'react-router-dom' resolved to empty path");
39
+ const packageRoot = node_path.dirname(resolved.path);
40
+ const { version } = await readJson(resolved.path);
39
41
  return {
40
- 'react-router-dom': node_path.dirname(resolved.path)
42
+ 'react-router-dom': packageRoot,
43
+ 'virtual-react-router-server': version.startsWith('6.') ? node_path.join(packageRoot, 'server.mjs') : packageRoot
41
44
  };
42
45
  } catch (e) {
43
46
  logger.warn('react-router-dom not found: \n', e);
@@ -92,7 +95,7 @@ async function resolveReactRenderToMarkdownAlias() {
92
95
  const hasInstalled = await detectPackageMajorVersion('react-render-to-markdown');
93
96
  if (!hasInstalled) {
94
97
  const reactMajorVersion = await detectPackageMajorVersion('react');
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`));
98
+ if (reactMajorVersion && reactMajorVersion < 19) logger.warn(`You are using React ${reactMajorVersion} with \`llms: true\`. Please install \`react-render-to-markdown@18\` 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`));
96
99
  return {};
97
100
  }
98
101
  const alias = {};
@@ -1769,7 +1769,7 @@ function findAllBrackets(v) {
1769
1769
  }
1770
1770
  function getMriOptions(options) {
1771
1771
  const result = {
1772
- alias: {},
1772
+ alias: Object.create(null),
1773
1773
  boolean: []
1774
1774
  };
1775
1775
  for (const [index, option] of options.entries()){
@@ -1781,7 +1781,7 @@ function getMriOptions(options) {
1781
1781
  return result;
1782
1782
  }
1783
1783
  function findLongest(arr) {
1784
- return arr.sort((a, b)=>a.length > b.length ? -1 : 1)[0];
1784
+ return arr.sort((a, b)=>b.length - a.length)[0];
1785
1785
  }
1786
1786
  function padRight(str, length) {
1787
1787
  return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
@@ -1789,7 +1789,13 @@ function padRight(str, length) {
1789
1789
  function camelcase(input) {
1790
1790
  return input.replaceAll(/([a-z])-([a-z])/g, (_, p1, p2)=>p1 + p2.toUpperCase());
1791
1791
  }
1792
+ const UNSAFE_KEYS = /* @__PURE__ */ new Set([
1793
+ "__proto__",
1794
+ "constructor",
1795
+ "prototype"
1796
+ ]);
1792
1797
  function setDotProp(obj, keys, val) {
1798
+ if (keys.some((key)=>UNSAFE_KEYS.has(key))) return;
1793
1799
  let current = obj;
1794
1800
  for(let i = 0; i < keys.length; i++){
1795
1801
  const key = keys[i];
@@ -1805,14 +1811,11 @@ function setDotProp(obj, keys, val) {
1805
1811
  }
1806
1812
  }
1807
1813
  function setByType(obj, transforms) {
1808
- for (const key of Object.keys(transforms)){
1809
- const transform = transforms[key];
1810
- if (transform.shouldTransform) {
1811
- obj[key] = [
1812
- obj[key]
1813
- ].flat();
1814
- if ("function" == typeof transform.transformFunction) obj[key] = obj[key].map(transform.transformFunction);
1815
- }
1814
+ for (const [key, transform] of Object.entries(transforms))if (transform.shouldTransform && key in obj) {
1815
+ obj[key] = [
1816
+ obj[key]
1817
+ ].flat();
1818
+ if ("function" == typeof transform.transformFunction) obj[key] = obj[key].map(transform.transformFunction);
1816
1819
  }
1817
1820
  }
1818
1821
  function getFileName(input) {
@@ -1851,7 +1854,7 @@ var Option = class {
1851
1854
  name = name.replace(/^no-/, "");
1852
1855
  }
1853
1856
  return camelcaseOptionName(name);
1854
- }).sort((a, b)=>a.length > b.length ? 1 : -1);
1857
+ }).sort((a, b)=>a.length - b.length);
1855
1858
  this.name = this.names.at(-1);
1856
1859
  if (this.negated && null == this.config.default) this.config.default = true;
1857
1860
  if (rawName.includes("<")) this.required = true;
@@ -1859,14 +1862,15 @@ var Option = class {
1859
1862
  else this.isBoolean = true;
1860
1863
  }
1861
1864
  };
1862
- let runtimeProcessArgs;
1863
1865
  let runtimeInfo;
1864
1866
  if ("u" > typeof process) {
1865
1867
  let runtimeName;
1866
1868
  runtimeName = "u" > typeof Deno && "string" == typeof Deno.version?.deno ? "deno" : "u" > typeof Bun && "string" == typeof Bun.version ? "bun" : "node";
1867
1869
  runtimeInfo = `${process.platform}-${process.arch} ${runtimeName}-${process.version}`;
1868
- runtimeProcessArgs = process.argv;
1869
1870
  } else runtimeInfo = "u" < typeof navigator ? "unknown" : `${navigator.platform} ${navigator.userAgent}`;
1871
+ function getRuntimeProcessArgs() {
1872
+ return "u" < typeof process ? void 0 : process.argv;
1873
+ }
1870
1874
  var Command = class {
1871
1875
  rawName;
1872
1876
  description;
@@ -1937,7 +1941,7 @@ var Command = class {
1937
1941
  return this instanceof GlobalCommand;
1938
1942
  }
1939
1943
  hasOption(name) {
1940
- name = name.split(".")[0];
1944
+ name = name.split(".", 1)[0];
1941
1945
  return this.options.find((option)=>option.names.includes(name));
1942
1946
  }
1943
1947
  outputHelp() {
@@ -2006,7 +2010,7 @@ var Command = class {
2006
2010
  ...this.options
2007
2011
  ];
2008
2012
  for (const option of options){
2009
- const value = parsedOptions[option.name.split(".")[0]];
2013
+ const value = parsedOptions[option.name.split(".", 1)[0]];
2010
2014
  if (option.required) {
2011
2015
  const hasNegated = options.some((o)=>o.negated && o.names.includes(option.name));
2012
2016
  if (true === value || false === value && !hasNegated) throw new CACError(`option \`${option.rawName}\` value is missing`);
@@ -2093,6 +2097,7 @@ var CAC = class extends EventTarget {
2093
2097
  }
2094
2098
  parse(argv, { run = true } = {}) {
2095
2099
  if (!argv) {
2100
+ const runtimeProcessArgs = getRuntimeProcessArgs();
2096
2101
  if (!runtimeProcessArgs) throw new Error("No argv provided and runtime process argv is not available.");
2097
2102
  argv = runtimeProcessArgs;
2098
2103
  }
@@ -2181,8 +2186,8 @@ var CAC = class extends EventTarget {
2181
2186
  transforms[cliOption.name].transformFunction = cliOption.config.type[0];
2182
2187
  }
2183
2188
  }
2184
- for (const key of Object.keys(parsed))if ("_" !== key) {
2185
- setDotProp(options, key.split("."), parsed[key]);
2189
+ for (const [key, value] of Object.entries(parsed))if ("_" !== key) {
2190
+ setDotProp(options, key.split("."), value);
2186
2191
  setByType(options, transforms);
2187
2192
  }
2188
2193
  return {
@@ -3006,7 +3011,7 @@ async function glob(globInput, options) {
3006
3011
  }
3007
3012
  export { logger } from "@rspress/shared/logger";
3008
3013
  export { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, DEFAULT_PAGE_EXTENSIONS } from "@rspress/shared/constants";
3009
- export { default as promises, mkdir, readdir as promises_readdir, rm, stat as promises_stat, writeFile } from "node:fs/promises";
3014
+ export { default as promises, mkdir, readFile, readdir as promises_readdir, rm, stat as promises_stat, writeFile } from "node:fs/promises";
3010
3015
  export { createRequire } from "node:module";
3011
3016
  export { cwd as external_node_process_cwd } from "node:process";
3012
3017
  export { fileURLToPath, pathToFileURL } from "node:url";
@@ -1,44 +1,35 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { PageContext, useLocation } from "@rspress/core/runtime";
3
- import { Layout, Root } from "@rspress/core/theme";
4
- import { LlmsHint } from "@rspress/core/theme-original";
5
- import react, { useContext, useLayoutEffect } from "react";
3
+ import { Layout, LlmsHint, Root, useWebMcpNavigation, useWebMcpPageList, useWebMcpPageReading, useWebMcpSiteInfo } from "@rspress/core/theme";
4
+ import react, { useContext } from "react";
6
5
  import { useGlobalComponents } from "./hooks/useGlobalComponents.js";
7
- import { consumeCachedPageData, initPageData, setCurrentPageData } from "./initPageData.js";
6
+ const GLOBAL_COMPONENTS_KEY = 'globalUIComponents';
7
+ const WebMcpPageReading = import.meta.env.ENABLE_WEBMCP && import.meta.env.ENABLE_SSG_MD ? ()=>{
8
+ useWebMcpPageReading();
9
+ return null;
10
+ } : null;
11
+ const WebMCP = import.meta.env.ENABLE_WEBMCP && !import.meta.env.SSR ? ()=>{
12
+ useWebMcpSiteInfo();
13
+ useWebMcpPageList();
14
+ useWebMcpNavigation();
15
+ return WebMcpPageReading ? /*#__PURE__*/ jsx(WebMcpPageReading, {}) : null;
16
+ } : null;
8
17
  function App() {
9
18
  const globalComponents = useGlobalComponents();
10
- const { setData: setPageData, data } = useContext(PageContext);
11
- const { pathname, search } = useLocation();
12
- useLayoutEffect(()=>{
13
- const cached = consumeCachedPageData(pathname);
14
- if (cached) return void setPageData?.(cached);
15
- async function refetchData() {
16
- try {
17
- const pageData = await initPageData(pathname);
18
- setCurrentPageData(pathname, pageData);
19
- setPageData?.(pageData);
20
- } catch (e) {
21
- console.log(e);
22
- }
23
- }
24
- refetchData();
25
- }, [
26
- pathname,
27
- setPageData
28
- ]);
29
- if (!data) return /*#__PURE__*/ jsx(Fragment, {});
30
- const frontmatter = data.frontmatter || {};
31
- const GLOBAL_COMPONENTS_KEY = 'globalUIComponents';
32
- const query = new URLSearchParams(search);
33
- const hideGlobalUIComponents = false === frontmatter[GLOBAL_COMPONENTS_KEY] || "0" === query.get(GLOBAL_COMPONENTS_KEY);
19
+ const { data } = useContext(PageContext);
20
+ const location = useLocation();
21
+ const { search } = location;
22
+ const hideGlobalUIComponents = data?.frontmatter?.[GLOBAL_COMPONENTS_KEY] === false || Boolean(search) && "0" === new URLSearchParams(search).get(GLOBAL_COMPONENTS_KEY);
34
23
  if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsxs(Root, {
35
24
  children: [
25
+ WebMCP && /*#__PURE__*/ jsx(WebMCP, {}),
36
26
  import.meta.env.ENABLE_LLMS_HINT && /*#__PURE__*/ jsx(LlmsHint, {}),
37
27
  /*#__PURE__*/ jsx(Layout, {})
38
28
  ]
39
29
  });
40
30
  return /*#__PURE__*/ jsxs(Root, {
41
31
  children: [
32
+ WebMCP && /*#__PURE__*/ jsx(WebMCP, {}),
42
33
  import.meta.env.ENABLE_LLMS_HINT && /*#__PURE__*/ jsx(LlmsHint, {}),
43
34
  /*#__PURE__*/ jsx(Layout, {}),
44
35
  !hideGlobalUIComponents && globalComponents.map((componentInfo, index)=>{
@@ -3,5 +3,5 @@ export interface BrowserOnlyProps {
3
3
  children: () => ReactNode | Promise<ReactNode>;
4
4
  fallback?: ReactNode;
5
5
  }
6
- export declare function BrowserOnly(props: BrowserOnlyProps): ReactNode;
6
+ export declare function BrowserOnly(props: BrowserOnlyProps): import("react").JSX.Element;
7
7
  export default BrowserOnly;