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

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 (172) hide show
  1. package/dist/{0~7675.989ee664.js → 0~7675.723d12b2.js} +18 -15
  2. package/dist/{5313.6594aba0.js → 3521.9eb6b114.js} +12 -19
  3. package/dist/4669.69cb6b18.js +1 -0
  4. package/dist/{5485.2a0273cf.js → 5485.9fc7f63d.js} +5 -5
  5. package/dist/6289.29817fb4.js +4 -0
  6. package/dist/8813.4b28f4bb.js +1 -0
  7. package/dist/9643.2dff683e.js +4 -0
  8. package/dist/_private/react/render.js +17 -4
  9. package/dist/cli/config/loadConfigFile.js +2 -2
  10. package/dist/cli/index.44f3184c.js +2 -0
  11. package/dist/cli/index.js +3 -3
  12. package/dist/eject-theme/components/Badge/index.scss +1 -0
  13. package/dist/eject-theme/components/Banner/index.tsx +3 -1
  14. package/dist/eject-theme/components/Callout/index.tsx +8 -2
  15. package/dist/eject-theme/components/CodeBlock/index.scss +8 -6
  16. package/dist/eject-theme/components/CodeBlock/index.tsx +4 -0
  17. package/dist/eject-theme/components/CodeBlockRuntime/index.tsx +50 -11
  18. package/dist/eject-theme/components/DocContent/doc.scss +1 -1
  19. package/dist/eject-theme/components/DocContent/docComponents/pre.tsx +2 -1
  20. package/dist/eject-theme/components/DocContent/index.tsx +21 -4
  21. package/dist/eject-theme/components/DocFooter/index.tsx +1 -6
  22. package/dist/eject-theme/components/HoverGroup/index.scss +4 -3
  23. package/dist/eject-theme/components/HoverGroup/index.tsx +104 -22
  24. package/dist/eject-theme/components/LastUpdated/index.tsx +8 -1
  25. package/dist/eject-theme/components/Link/index.tsx +9 -2
  26. package/dist/eject-theme/components/Nav/NavMenu.scss +1 -1
  27. package/dist/eject-theme/components/Nav/NavMenu.tsx +50 -28
  28. package/dist/eject-theme/components/NavScreen/NavScreenLangs.scss +6 -0
  29. package/dist/eject-theme/components/NavScreen/NavScreenLangs.tsx +23 -9
  30. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +26 -11
  31. package/dist/eject-theme/components/NavScreen/NavScreenVersions.scss +6 -0
  32. package/dist/eject-theme/components/NavScreen/NavScreenVersions.tsx +22 -9
  33. package/dist/eject-theme/components/Overview/index.tsx +66 -6
  34. package/dist/eject-theme/components/{Overview/OverviewGroup.scss → OverviewGroup/index.scss} +66 -12
  35. package/dist/eject-theme/components/{Overview/OverviewGroup.tsx → OverviewGroup/index.tsx} +50 -3
  36. package/dist/eject-theme/components/Search/logic/util.test.ts +1 -1
  37. package/dist/eject-theme/components/Tabs/index.scss +12 -4
  38. package/dist/eject-theme/components/Tabs/index.tsx +16 -0
  39. package/dist/eject-theme/components/Tag/index.tsx +84 -5
  40. package/dist/index.js +7 -11
  41. package/dist/node/PluginDriver.js +5 -6
  42. package/dist/node/auto-nav-sidebar/index.js +3 -3
  43. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  44. package/dist/node/auto-nav-sidebar/normalize.js +12 -10
  45. package/dist/node/auto-nav-sidebar/utils.js +2 -2
  46. package/dist/node/auto-nav-sidebar/walk.js +13 -9
  47. package/dist/node/constants.d.ts +1 -0
  48. package/dist/node/constants.js +4 -3
  49. package/dist/node/eject.js +7 -10
  50. package/dist/node/initRsbuild.js +25 -11
  51. package/dist/node/last-updated/index.js +1 -1
  52. package/dist/node/logger/hint.js +1 -1
  53. package/dist/node/mdx/loader.7c249a26.js +12 -0
  54. package/dist/node/mdx/loader.js +2 -1
  55. package/dist/node/mdx/options.js +9 -6
  56. package/dist/node/mdx/processor.js +2 -2
  57. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  58. package/dist/node/mdx/rehypePlugins/headerAnchor.js +4 -4
  59. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  60. package/dist/node/mdx/rehypePlugins/transformers/index.js +5 -5
  61. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  62. package/dist/node/mdx/remarkPlugins/containerSyntax.js +1 -1
  63. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +3 -3
  64. package/dist/node/mdx/remarkPlugins/image.js +3 -3
  65. package/dist/node/mdx/remarkPlugins/link.js +3 -3
  66. package/dist/node/mdx/remarkPlugins/toc.js +3 -3
  67. package/dist/node/medium-zoom/index.js +1 -1
  68. package/dist/node/route/RoutePage.js +1 -1
  69. package/dist/node/route/RouteService.js +3 -3
  70. package/dist/node/route/extractPageData.js +5 -5
  71. package/dist/node/route/normalizeRoutePath.js +2 -2
  72. package/dist/node/runtimeModule/i18n.js +2 -2
  73. package/dist/node/runtimeModule/pageData/createPageData.js +2 -2
  74. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  75. package/dist/node/runtimeModule/searchHooks.js +1 -1
  76. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  77. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  78. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  79. package/dist/node/serve.js +1 -1
  80. package/dist/node/ssg/renderPage.js +2 -2
  81. package/dist/node/ssg/renderPageWorker.165b5d46.js +1 -0
  82. package/dist/node/ssg/renderPageWorker.js +2 -2
  83. package/dist/node/ssg/renderPages.js +3 -3
  84. package/dist/node/ssg/rsbuildPluginSSG.js +2 -2
  85. package/dist/node/ssg/ssgEnv.js +1 -1
  86. package/dist/node/ssg-md/llms/emitLlmsTxt.js +9 -3
  87. package/dist/node/ssg-md/llms/llmsTxt.js +2 -2
  88. package/dist/node/ssg-md/remarkSplitMdx.js +141 -99
  89. package/dist/node/ssg-md/renderPage.js +2 -2
  90. package/dist/node/ssg-md/renderPages.js +2 -2
  91. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +2 -2
  92. package/dist/node/utils/checkLanguageParity.js +1 -1
  93. package/dist/node/utils/createHash.js +1 -1
  94. package/dist/node/utils/error.js +2 -1
  95. package/dist/node/utils/flattenMdxContent.js +5 -5
  96. package/dist/node/utils/fs.js +1 -1
  97. package/dist/node/utils/getPageKey.js +1 -1
  98. package/dist/node/utils/normalizePath.js +3 -3
  99. package/dist/node/utils/reactAlias.js +2 -2
  100. package/dist/runtime/App.js +4 -2
  101. package/dist/runtime/initPageData.js +1 -1
  102. package/dist/runtime.js +1 -2
  103. package/dist/shiki-transformers.js +2 -2
  104. package/dist/theme/assets/deprecated.js +18 -0
  105. package/dist/theme/assets/experimental.js +21 -0
  106. package/dist/theme/components/Badge/index.css +1 -0
  107. package/dist/theme/components/Banner/index.js +2 -2
  108. package/dist/theme/components/Callout/index.js +5 -2
  109. package/dist/theme/components/CodeBlock/index.css +7 -6
  110. package/dist/theme/components/CodeBlock/index.js +4 -1
  111. package/dist/theme/components/CodeBlockRuntime/index.d.ts +1 -1
  112. package/dist/theme/components/CodeBlockRuntime/index.js +38 -8
  113. package/dist/theme/components/DocContent/doc.css +1 -1
  114. package/dist/theme/components/DocContent/docComponents/pre.js +3 -1
  115. package/dist/theme/components/DocContent/index.d.ts +11 -2
  116. package/dist/theme/components/DocContent/index.js +6 -5
  117. package/dist/theme/components/DocFooter/index.js +1 -5
  118. package/dist/theme/components/HoverGroup/index.css +6 -5
  119. package/dist/theme/components/HoverGroup/index.js +88 -17
  120. package/dist/theme/components/LastUpdated/index.d.ts +1 -1
  121. package/dist/theme/components/LastUpdated/index.js +5 -1
  122. package/dist/theme/components/Link/index.d.ts +1 -1
  123. package/dist/theme/components/Link/index.js +8 -2
  124. package/dist/theme/components/Nav/NavMenu.css +1 -1
  125. package/dist/theme/components/Nav/NavMenu.d.ts +6 -1
  126. package/dist/theme/components/Nav/NavMenu.js +47 -45
  127. package/dist/theme/components/NavScreen/NavScreenLangs.css +6 -0
  128. package/dist/theme/components/NavScreen/NavScreenLangs.js +13 -3
  129. package/dist/theme/components/NavScreen/NavScreenMenuItem.d.ts +1 -1
  130. package/dist/theme/components/NavScreen/NavScreenMenuItem.js +21 -11
  131. package/dist/theme/components/NavScreen/NavScreenVersions.css +6 -0
  132. package/dist/theme/components/NavScreen/NavScreenVersions.js +12 -3
  133. package/dist/theme/components/Overview/index.d.ts +0 -1
  134. package/dist/theme/components/Overview/index.js +46 -3
  135. package/dist/theme/components/{Overview/OverviewGroup.css → OverviewGroup/index.css} +60 -8
  136. package/dist/theme/components/{Overview/OverviewGroup.d.ts → OverviewGroup/index.d.ts} +1 -1
  137. package/dist/theme/components/OverviewGroup/index.js +88 -0
  138. package/dist/theme/components/Search/logic/util.test.js +1 -1
  139. package/dist/theme/components/Tabs/index.css +6 -5
  140. package/dist/theme/components/Tabs/index.js +9 -0
  141. package/dist/theme/components/Tag/index.d.ts +3 -0
  142. package/dist/theme/components/Tag/index.js +63 -8
  143. package/dist/theme/hooks/useActiveAnchor.js +1 -1
  144. package/dist/theme/icons.d.ts +26 -24
  145. package/dist/theme/icons.js +5 -1
  146. package/dist/theme/index.d.ts +3 -1
  147. package/dist/theme/index.js +4 -2
  148. package/dist/theme/layout/DocLayout/index.css +0 -2
  149. package/dist/theme/layout/DocLayout/index.js +10 -0
  150. package/dist/theme/layout/HomeLayout/index.js +40 -0
  151. package/dist/theme/layout/Layout/index.js +11 -8
  152. package/dist/theme/layout/NotFountLayout/index.js +1 -1
  153. package/dist/theme/logic/useAppearance.js +1 -1
  154. package/dist/theme/logic/useMediaQuery.js +1 -1
  155. package/dist/theme/logic/useStorageValue.js +6 -3
  156. package/dist/theme/styles/base.css +1 -0
  157. package/dist/theme/styles/shiki.css +9 -3
  158. package/dist/theme/styles/vars/base-vars.css +4 -4
  159. package/dist/theme/styles/vars/code-vars.css +2 -0
  160. package/nav-json-schema.json +2 -2
  161. package/package.json +15 -15
  162. package/dist/1218.3869bad6.js +0 -2
  163. package/dist/4669.12208c6a.js +0 -2
  164. package/dist/6289.c67fe0d5.js +0 -5
  165. package/dist/7805.cadab34e.js +0 -4
  166. package/dist/8813.9da1f210.js +0 -2
  167. package/dist/cli/index.cb89dbd1.js +0 -3
  168. package/dist/node/mdx/loader.e1578c62.js +0 -13
  169. package/dist/node/ssg/renderPageWorker.474f9f73.js +0 -2
  170. package/dist/theme/components/Overview/OverviewGroup.js +0 -57
  171. /package/dist/eject-theme/components/{Overview → OverviewGroup}/icons/plugin.svg +0 -0
  172. /package/dist/theme/components/{Overview → OverviewGroup}/icons/plugin.js +0 -0
@@ -24,7 +24,7 @@ import { Nav } from "./components/Nav/index.js";
24
24
  import { NavHamburger } from "./components/NavHamburger/index.js";
25
25
  import { Outline } from "./components/Outline/index.js";
26
26
  import { Overview } from "./components/Overview/index.js";
27
- import { OverviewGroup } from "./components/Overview/OverviewGroup.js";
27
+ import { OverviewGroup } from "./components/OverviewGroup/index.js";
28
28
  import { PackageManagerTabs } from "./components/PackageManagerTabs/index.js";
29
29
  import { PageTab, PageTabs } from "./components/PageTabs/index.js";
30
30
  import { PrevNextPage } from "./components/PrevNextPage/index.js";
@@ -54,8 +54,10 @@ import { useThemeState } from "./logic/useAppearance.js";
54
54
  import { useFullTextSearch } from "./logic/useFullTextSearch.js";
55
55
  import { usePrevNextPage } from "./logic/usePrevNextPage.js";
56
56
  import { useRedirect4FirstVisit } from "./logic/useRedirect4FirstVisit.js";
57
+ import { useScrollAfterNav } from "./logic/useScrollAfterNav.js";
58
+ import { useScrollReset } from "./logic/useScrollReset.js";
57
59
  import { useSetup } from "./logic/useSetup.js";
58
60
  import { useStorageValue } from "./logic/useStorageValue.js";
59
61
  import { parseInlineMarkdownText, renderHtmlOrText, renderInlineMarkdown } from "./logic/utils.js";
60
62
  export * from "./icons.js";
61
- export { Badge, Banner, Button, Callout, CodeBlock, CodeBlockRuntime, CodeButtonGroup, DocContent, DocFooter, DocLayout, EditLink, FallbackHeading, HomeBackground, HomeFeature, HomeFooter, HomeHero, HomeLayout, HoverGroup, LastUpdated, Layout, Link, Nav, NavHamburger, NotFoundLayout, Outline, Overview, OverviewGroup, PackageManagerTabs, PageTab, PageTabs, PrevNextPage, ReadPercent, RenderType, Root, Search, SearchButton, SearchPanel, Sidebar, SidebarList, SocialLinks, SourceCode, Steps, SvgWrapper, SwitchAppearance, Tab, Tabs, Tag, Toc, getCustomMDXComponent, mergeRefs, parseInlineMarkdownText, renderHtmlOrText, renderInlineMarkdown, useActiveAnchor, useCodeButtonGroup, useDynamicToc, useEditLink, useFullTextSearch, useHoverGroup, useLinkNavigate, usePrevNextPage, useRedirect4FirstVisit, useSetup, useStorageValue, useThemeState, useWatchToc };
63
+ export { Badge, Banner, Button, Callout, CodeBlock, CodeBlockRuntime, CodeButtonGroup, DocContent, DocFooter, DocLayout, EditLink, FallbackHeading, HomeBackground, HomeFeature, HomeFooter, HomeHero, HomeLayout, HoverGroup, LastUpdated, Layout, Link, Nav, NavHamburger, NotFoundLayout, Outline, Overview, OverviewGroup, PackageManagerTabs, PageTab, PageTabs, PrevNextPage, ReadPercent, RenderType, Root, Search, SearchButton, SearchPanel, Sidebar, SidebarList, SocialLinks, SourceCode, Steps, SvgWrapper, SwitchAppearance, Tab, Tabs, Tag, Toc, getCustomMDXComponent, mergeRefs, parseInlineMarkdownText, renderHtmlOrText, renderInlineMarkdown, useActiveAnchor, useCodeButtonGroup, useDynamicToc, useEditLink, useFullTextSearch, useHoverGroup, useLinkNavigate, usePrevNextPage, useRedirect4FirstVisit, useScrollAfterNav, useScrollReset, useSetup, useStorageValue, useThemeState, useWatchToc };
@@ -44,7 +44,6 @@
44
44
  .rp-doc-layout__overview {
45
45
  width: 100%;
46
46
  max-width: min(100%, 1280px);
47
- min-height: 60vh;
48
47
  padding: var(--rp-content-padding-y) var(--rp-content-padding-x);
49
48
  position: relative;
50
49
  overflow-x: auto;
@@ -69,7 +68,6 @@
69
68
  }
70
69
 
71
70
  .rp-doc-layout__doc-container {
72
- min-height: 60vh;
73
71
  padding: var(--rp-content-padding-y) var(--rp-content-padding-x);
74
72
  }
75
73
 
@@ -9,6 +9,16 @@ function DocLayout(props) {
9
9
  const { frontmatter } = useFrontmatter();
10
10
  const isOverviewPage = frontmatter?.overview ?? false;
11
11
  const { sidebar: showSidebar = true, outline: showOutline = true, footer: showDocFooter = true, pageType } = frontmatter;
12
+ if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(Fragment, {
13
+ children: isOverviewPage ? /*#__PURE__*/ jsx(Overview, {
14
+ content: /*#__PURE__*/ jsx(DocContent, {
15
+ components: components,
16
+ isOverviewPage: true
17
+ })
18
+ }) : /*#__PURE__*/ jsx(DocContent, {
19
+ components: components
20
+ })
21
+ });
12
22
  const isDocWide = 'doc-wide' === pageType;
13
23
  const { isOutlineOpen, isSidebarOpen, sidebarMenu, asideLayoutRef, sidebarLayoutRef } = useSidebarMenu();
14
24
  const { rspressDocRef } = useWatchToc();
@@ -1,6 +1,46 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useFrontmatter } from "@rspress/core/runtime";
2
3
  import { HomeBackground, HomeFeature, HomeFooter, HomeHero } from "@theme";
4
+ function HomeLayoutMarkdown() {
5
+ const { frontmatter } = useFrontmatter();
6
+ const hero = frontmatter?.hero;
7
+ const features = frontmatter?.features;
8
+ const lines = [];
9
+ if (hero) {
10
+ if (hero.name) {
11
+ lines.push(`# ${hero.name}`);
12
+ lines.push('');
13
+ }
14
+ if (hero.text) {
15
+ lines.push(hero.text);
16
+ lines.push('');
17
+ }
18
+ if (hero.tagline) {
19
+ lines.push(`> ${hero.tagline}`);
20
+ lines.push('');
21
+ }
22
+ if (hero.actions && hero.actions.length > 0) {
23
+ const actionLinks = hero.actions.map((action)=>`[${action.text}](${action.link})`).join(' | ');
24
+ lines.push(actionLinks);
25
+ lines.push('');
26
+ }
27
+ }
28
+ if (features && features.length > 0) {
29
+ lines.push('## Features');
30
+ lines.push('');
31
+ for (const feature of features){
32
+ const icon = feature.icon ? `${feature.icon} ` : '';
33
+ const title = feature.link ? `[${icon}**${feature.title}**](${feature.link})` : `${icon}**${feature.title}**`;
34
+ lines.push(`- ${title}: ${feature.details}`);
35
+ }
36
+ lines.push('');
37
+ }
38
+ return /*#__PURE__*/ jsx(Fragment, {
39
+ children: lines.join('\n')
40
+ });
41
+ }
3
42
  function HomeLayout(props) {
43
+ if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(HomeLayoutMarkdown, {});
4
44
  const { beforeHero, afterHero, beforeFeatures, afterFeatures, beforeHeroActions, afterHeroActions } = props;
5
45
  return /*#__PURE__*/ jsxs(Fragment, {
6
46
  children: [
@@ -1,9 +1,8 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { Content, useFrontmatter, useLocaleSiteData, usePageData, useSite } from "@rspress/core/runtime";
3
- import { DocLayout, HomeLayout as external_theme_HomeLayout, Nav, NotFoundLayout as external_theme_NotFoundLayout, useRedirect4FirstVisit, useSetup } from "@theme";
2
+ import { Content, useFrontmatter, useLocaleSiteData, usePage, useSite } from "@rspress/core/runtime";
3
+ import { DocLayout, HomeLayout as external_theme_HomeLayout, Nav, NotFoundLayout as external_theme_NotFoundLayout, useRedirect4FirstVisit, useScrollReset, useSetup } from "@theme";
4
4
  import { Head, useHead } from "@unhead/react";
5
5
  import react, { memo, useMemo } from "react";
6
- import { useScrollReset } from "../../logic/useScrollReset.js";
7
6
  const concatTitle = (title, suffix)=>{
8
7
  if (!suffix) return title;
9
8
  title = title.trim();
@@ -44,7 +43,7 @@ const HeadTags = /*#__PURE__*/ memo((props)=>{
44
43
  });
45
44
  });
46
45
  function Layout(props) {
47
- const { top, bottom, beforeDocFooter, afterDocFooter, beforeDoc, afterDoc, beforeDocContent, afterDocContent, beforeSidebar, afterSidebar, beforeOutline, afterOutline, beforeNavTitle, afterNavTitle, navTitle, beforeNav, afterNav, beforeHero, afterHero, beforeFeatures, afterFeatures, afterNavMenu, components, HomeLayout = external_theme_HomeLayout, NotFoundLayout = external_theme_NotFoundLayout } = props;
46
+ const { top, bottom, beforeDocFooter, afterDocFooter, beforeDoc, afterDoc, beforeDocContent, afterDocContent, beforeSidebar, afterSidebar, beforeOutline, afterOutline, beforeNavTitle, afterNavTitle, navTitle, beforeNav, afterNav, beforeHero, afterHero, beforeFeatures, afterFeatures, beforeNavMenu, afterNavMenu, components, HomeLayout = external_theme_HomeLayout, NotFoundLayout = external_theme_NotFoundLayout } = props;
48
47
  const docProps = {
49
48
  beforeDocFooter,
50
49
  afterDocFooter,
@@ -64,14 +63,11 @@ function Layout(props) {
64
63
  beforeFeatures,
65
64
  afterFeatures
66
65
  };
67
- const { page } = usePageData();
66
+ const { page } = usePage();
68
67
  const { site } = useSite();
69
68
  const { frontmatter } = useFrontmatter();
70
69
  const { pageType, lang: currentLang, title: articleTitle } = page;
71
70
  const localesData = useLocaleSiteData();
72
- useSetup();
73
- useScrollReset();
74
- useRedirect4FirstVisit();
75
71
  let title = frontmatter.title ?? articleTitle;
76
72
  const mainTitle = site.title || localesData.title || '';
77
73
  title = title && ('doc' === pageType || 'doc-wide' === pageType) ? concatTitle(title, frontmatter.titleSuffix || mainTitle) : 'home' === pageType ? concatTitle(mainTitle, frontmatter.titleSuffix) : '404' === pageType ? concatTitle('404', mainTitle) : mainTitle;
@@ -99,6 +95,12 @@ function Layout(props) {
99
95
  });
100
96
  }
101
97
  };
98
+ if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(Fragment, {
99
+ children: getContentLayout()
100
+ });
101
+ useSetup();
102
+ useScrollReset();
103
+ useRedirect4FirstVisit();
102
104
  const { frontmatter: { navbar: showNavbar = true } } = useFrontmatter();
103
105
  return /*#__PURE__*/ jsxs(Fragment, {
104
106
  children: [
@@ -116,6 +118,7 @@ function Layout(props) {
116
118
  beforeNavTitle: beforeNavTitle,
117
119
  afterNavTitle: afterNavTitle,
118
120
  navTitle: navTitle,
121
+ beforeNavMenu: beforeNavMenu,
119
122
  afterNavMenu: afterNavMenu
120
123
  }),
121
124
  afterNav
@@ -7,7 +7,7 @@ function NotFoundLayout() {
7
7
  const defaultLang = siteData.lang;
8
8
  const defaultVersion = siteData.multiVersion.default;
9
9
  const t = useI18n();
10
- if (defaultLang && 'undefined' != typeof window) {
10
+ if (defaultLang && "u" > typeof window) {
11
11
  const regexp = new RegExp(`/${defaultLang}(\\/|$)`);
12
12
  if (regexp.test(location.pathname)) {
13
13
  const redirectUrl = location.pathname.replace(regexp, '/');
@@ -20,7 +20,7 @@ const useThemeState = ()=>{
20
20
  return 'auto' === sanitized ? matchesDark ? 'dark' : 'light' : sanitized;
21
21
  });
22
22
  const [theme, setThemeInternal] = useState(()=>{
23
- if ('undefined' == typeof window) return 'light';
23
+ if ("u" < typeof window) return 'light';
24
24
  const defaultTheme = window.RSPRESS_THEME ?? window.MODERN_THEME;
25
25
  if (defaultTheme) return 'dark' === defaultTheme ? 'dark' : 'light';
26
26
  return getPreferredTheme();
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useState } from "react";
2
2
  const useMediaQuery = (query)=>{
3
- const [matches, setMatches] = useState(()=>'undefined' != typeof window ? window.matchMedia(query).matches : false);
3
+ const [matches, setMatches] = useState(()=>"u" > typeof window ? window.matchMedia(query).matches : false);
4
4
  useEffect(()=>{
5
5
  const mediaQueryList = window.matchMedia(query);
6
6
  const listener = (e)=>setMatches(e.matches);
@@ -1,11 +1,14 @@
1
- import { useCallback, useEffect, useLayoutEffect, useState } from "react";
1
+ import { useCallback, useEffect, useState } from "react";
2
2
  const SYNC_STORAGE_EVENT_NAME = 'RSPRESS_SYNC_STORAGE_EVENT_NAME';
3
3
  const useStorageValue = (key, defaultValue)=>{
4
4
  const [value, setValueInternal] = useState(defaultValue);
5
- useLayoutEffect(()=>{
5
+ useEffect(()=>{
6
+ if ("u" < typeof window) return;
6
7
  const storedValue = localStorage.getItem(key);
7
8
  if (null != storedValue) setValueInternal(storedValue);
8
- }, []);
9
+ }, [
10
+ key
11
+ ]);
9
12
  const setValue = useCallback((value)=>{
10
13
  const next = value;
11
14
  if (null == next) localStorage.removeItem(key);
@@ -40,6 +40,7 @@ body {
40
40
  :root {
41
41
  --rp-font-family-base: "Inter var experimental", "Inter var", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
42
42
  --rp-font-family-mono: Menlo, Monaco, Consolas, "Courier New", monospace;
43
+ text-autospace: normal;
43
44
  }
44
45
 
45
46
  :root #nprogress .bar {
@@ -42,18 +42,24 @@
42
42
  }
43
43
 
44
44
  .shiki.has-highlighted .line.highlighted {
45
- background-color: #0063c71a;
46
45
  width: 100%;
47
46
  display: inline-block;
48
47
  position: static;
49
48
  }
50
49
 
50
+ .shiki.has-highlighted .line.highlighted:not(.error):not(.warning) {
51
+ background-color: #3b82f61a;
52
+ box-shadow: inset 2px 0 #3b82f6;
53
+ }
54
+
51
55
  .shiki.has-highlighted .line.highlighted.error {
52
- background-color: #f43f5e1a;
56
+ background-color: #ed3c501a;
57
+ box-shadow: inset 2px 0 #ed3c50;
53
58
  }
54
59
 
55
60
  .shiki.has-highlighted .line.highlighted.warning {
56
- background-color: #eab3081a;
61
+ background-color: #ffc5171a;
62
+ box-shadow: inset 2px 0 #ffc517;
57
63
  }
58
64
 
59
65
  .shiki.has-focused .line:not(.focused) {
@@ -3,8 +3,8 @@
3
3
  --rp-c-bg-soft: #f8f8f9;
4
4
  --rp-c-bg-mute: #f1f1f1;
5
5
  --rp-c-bg-alt: #fff;
6
- --rp-c-divider: #0003;
7
- --rp-c-divider-light: #0000001a;
6
+ --rp-c-divider: #00000040;
7
+ --rp-c-divider-light: #0000001f;
8
8
  --rp-c-text-0: #000;
9
9
  --rp-c-text-1: #242424;
10
10
  --rp-c-text-2: #000000b3;
@@ -41,8 +41,8 @@
41
41
  --rp-c-gray-light-3: #d1d1d1;
42
42
  --rp-c-gray-light-4: #e5e5e5;
43
43
  --rp-c-gray-light-5: #f2f2f2;
44
- --rp-shadow-1: 0 1px 4px #00000005, 0 1px 0 #0000000f;
45
- --rp-shadow-2: 0 3px 12px #00000012, 0 1px 4px #00000012;
44
+ --rp-shadow-1: 0 1px 2px #00000005, 0 1px 0 #0000000f;
45
+ --rp-shadow-2: 0 3px 12px #0000000f, 0 1px 4px #00000012;
46
46
  --rp-shadow-3: 0 12px 32px #0000001a, 0 2px 6px #00000014;
47
47
  --rp-shadow-4: 0 14px 44px #0000001f, 0 3px 9px #0000001f;
48
48
  --rp-shadow-5: 0 18px 56px #00000029, 0 4px 12px #00000029;
@@ -4,6 +4,7 @@
4
4
  --rp-code-block-color: #2e3440;
5
5
  --rp-code-block-bg: var(--rp-c-bg);
6
6
  --rp-code-block-border: 1px solid var(--rp-c-divider-light);
7
+ --rp-code-block-shadow: none;
7
8
  }
8
9
 
9
10
  :where(html.rp-dark) {
@@ -12,5 +13,6 @@
12
13
  --rp-code-block-color: #e5e7eb;
13
14
  --rp-code-block-bg: var(--rp-c-bg);
14
15
  --rp-code-block-border: 1px solid var(--rp-c-divider-light);
16
+ --rp-code-block-shadow: none;
15
17
  }
16
18
 
@@ -62,7 +62,7 @@
62
62
  "items": {
63
63
  "type": "array",
64
64
  "items": {
65
- "$ref": "#/definitions/NavItemWithLink"
65
+ "$ref": "#/definitions/NavItem"
66
66
  }
67
67
  },
68
68
  "position": {
@@ -90,7 +90,7 @@
90
90
  "items": {
91
91
  "type": "array",
92
92
  "items": {
93
- "$ref": "#/definitions/NavItemWithLink"
93
+ "$ref": "#/definitions/NavItem"
94
94
  }
95
95
  },
96
96
  "tag": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "2.0.0-rc.2",
3
+ "version": "2.0.0-rc.4",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -63,10 +63,10 @@
63
63
  "dependencies": {
64
64
  "@mdx-js/mdx": "^3.1.1",
65
65
  "@mdx-js/react": "^3.1.1",
66
- "@rsbuild/core": "~1.6.13",
66
+ "@rsbuild/core": "~1.6.15",
67
67
  "@rsbuild/plugin-react": "~1.4.2",
68
68
  "@rspress/mdx-rs": "0.6.6",
69
- "@shikijs/rehype": "^3.12.2",
69
+ "@shikijs/rehype": "^3.20.0",
70
70
  "@types/unist": "^3.0.3",
71
71
  "@unhead/react": "^2.0.19",
72
72
  "body-scroll-lock": "4.0.0-beta.0",
@@ -79,37 +79,37 @@
79
79
  "hast-util-heading-rank": "^3.0.0",
80
80
  "hast-util-to-jsx-runtime": "^2.3.6",
81
81
  "html-to-text": "^9.0.5",
82
- "lodash-es": "^4.17.21",
82
+ "lodash-es": "^4.17.22",
83
83
  "mdast-util-mdx": "^3.0.0",
84
84
  "mdast-util-mdxjs-esm": "^2.0.1",
85
85
  "medium-zoom": "1.1.0",
86
86
  "nprogress": "^0.2.0",
87
87
  "picocolors": "^1.1.1",
88
- "react": "^19.2.1",
89
- "react-dom": "^19.2.1",
88
+ "react": "^19.2.3",
89
+ "react-dom": "^19.2.3",
90
90
  "react-lazy-with-preload": "^2.2.1",
91
91
  "react-reconciler": "0.33.0",
92
- "react-router-dom": "^7.10.1",
92
+ "react-router-dom": "^7.11.0",
93
93
  "rehype-external-links": "^3.0.0",
94
94
  "rehype-raw": "^7.0.0",
95
95
  "remark-gfm": "^4.0.1",
96
96
  "remark-mdx": "^3.1.1",
97
97
  "remark-stringify": "^11.0.0",
98
98
  "scroll-into-view-if-needed": "^3.1.0",
99
- "shiki": "^3.12.2",
99
+ "shiki": "^3.20.0",
100
100
  "tinyglobby": "^0.2.15",
101
101
  "tinypool": "^1.1.1",
102
102
  "unified": "^11.0.5",
103
103
  "unist-util-visit": "^5.0.0",
104
104
  "unist-util-visit-children": "^3.0.0",
105
- "@rspress/runtime": "2.0.0-rc.2",
106
- "@rspress/shared": "2.0.0-rc.2"
105
+ "@rspress/runtime": "2.0.0-rc.4",
106
+ "@rspress/shared": "2.0.0-rc.4"
107
107
  },
108
108
  "devDependencies": {
109
109
  "@microsoft/api-extractor": "^7.55.2",
110
110
  "@rsbuild/plugin-sass": "~1.4.0",
111
- "@rsbuild/plugin-svgr": "^1.2.2",
112
- "@rslib/core": "0.18.3",
111
+ "@rsbuild/plugin-svgr": "^1.2.3",
112
+ "@rslib/core": "0.18.6",
113
113
  "@types/body-scroll-lock": "^3.1.2",
114
114
  "@types/hast": "^3.0.4",
115
115
  "@types/html-to-text": "^9.0.4",
@@ -120,7 +120,7 @@
120
120
  "@types/react": "^19.2.7",
121
121
  "@types/react-dom": "^19.2.3",
122
122
  "@types/react-reconciler": "^0.32.3",
123
- "@types/web": "^0.0.297",
123
+ "@types/web": "^0.0.309",
124
124
  "execa": "8.0.1",
125
125
  "mdast-util-directive": "^3.1.0",
126
126
  "mdast-util-mdx-expression": "^2.0.1",
@@ -130,14 +130,14 @@
130
130
  "remark-directive": "^4.0.0",
131
131
  "rsbuild-plugin-publint": "^0.3.3",
132
132
  "rsbuild-plugin-virtual-module": "0.4.1",
133
- "tailwindcss": "^3.4.18",
133
+ "tailwindcss": "^3.4.19",
134
134
  "ts-json-schema-generator": "^2.4.0",
135
135
  "typescript": "^5.8.2",
136
136
  "vfile": "^6.0.3",
137
137
  "@rspress/config": "1.0.0"
138
138
  },
139
139
  "engines": {
140
- "node": ">=18.0.0"
140
+ "node": ">=20.9.0"
141
141
  },
142
142
  "publishConfig": {
143
143
  "access": "public",
@@ -1,2 +0,0 @@
1
- import node_process, { cwd } from "node:process";
2
- export { cwd, node_process };
@@ -1,2 +0,0 @@
1
- import { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, normalizeHref, parseUrl, removeLeadingSlash, removeTrailingSlash, slash, withBase } from "@rspress/shared";
2
- export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, normalizeHref, parseUrl, removeLeadingSlash, removeTrailingSlash, slash, withBase };
@@ -1,5 +0,0 @@
1
- import { logger } from "@rspress/shared/logger";
2
- import node_path, { extname, join, relative } from "node:path";
3
- import promises, { mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
4
- import picocolors from "picocolors";
5
- export { extname, join, logger, mkdir, node_path, picocolors, promises, readFile, readdir, relative, rm, stat, writeFile };
@@ -1,4 +0,0 @@
1
- import { extractTextAndId, getIconUrlPath, getNodeAttribute, loadFrontMatter } from "@rspress/shared/node-utils";
2
- import node_os, { constants } from "node:os";
3
- import { createProcessor, nodeTypes } from "@mdx-js/mdx";
4
- export { constants, createProcessor, extractTextAndId, getIconUrlPath, getNodeAttribute, loadFrontMatter, nodeTypes, node_os };
@@ -1,2 +0,0 @@
1
- import { visit } from "unist-util-visit";
2
- export { visit };
@@ -1,3 +0,0 @@
1
- import { cac } from "cac";
2
- import chokidar from "chokidar";
3
- export { cac, chokidar };
@@ -1,13 +0,0 @@
1
- import rehype from "@shikijs/rehype";
2
- import rehype_external_links from "rehype-external-links";
3
- import rehype_raw from "rehype-raw";
4
- import remark_gfm from "remark-gfm";
5
- import remark_mdx from "remark-mdx";
6
- import remark_stringify from "remark-stringify";
7
- import { unified } from "unified";
8
- import github_slugger from "github-slugger";
9
- import { headingRank } from "hast-util-heading-rank";
10
- import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddWrapCode } from "@rspress/core/shiki-transformers";
11
- import { createCssVariablesTheme } from "shiki";
12
- import { visitChildren } from "unist-util-visit-children";
13
- export { createCssVariablesTheme, github_slugger, headingRank, rehype, rehype_external_links, rehype_raw, remark_gfm, remark_mdx, remark_stringify, transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddWrapCode, unified, visitChildren };
@@ -1,2 +0,0 @@
1
- import { workerData } from "node:worker_threads";
2
- export { workerData };
@@ -1,57 +0,0 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { FallbackHeading, Link, SvgWrapper, renderInlineMarkdown } from "@theme";
3
- import "./OverviewGroup.css";
4
- import icons_plugin from "./icons/plugin.js";
5
- const OverviewGroup = ({ group })=>/*#__PURE__*/ jsxs(Fragment, {
6
- children: [
7
- /*#__PURE__*/ jsx(FallbackHeading, {
8
- level: 2,
9
- title: group.name
10
- }),
11
- /*#__PURE__*/ jsx("div", {
12
- className: "rp-overview-group rp-not-doc",
13
- children: group.items.map((item)=>/*#__PURE__*/ jsxs("div", {
14
- className: "rp-overview-group__item",
15
- children: [
16
- /*#__PURE__*/ jsxs("div", {
17
- className: "rp-overview-group__item__title",
18
- children: [
19
- item.link ? /*#__PURE__*/ jsx(Link, {
20
- href: item.link,
21
- ...renderInlineMarkdown(item.text)
22
- }) : /*#__PURE__*/ jsx("span", {
23
- ...renderInlineMarkdown(item.text)
24
- }),
25
- /*#__PURE__*/ jsx(SvgWrapper, {
26
- icon: icons_plugin,
27
- className: "rp-overview-group__item__title__icon"
28
- })
29
- ]
30
- }),
31
- /*#__PURE__*/ jsxs("ul", {
32
- className: "rp-overview-group__item__content",
33
- children: [
34
- item.headers?.map((header)=>/*#__PURE__*/ jsx("li", {
35
- className: "rp-overview-group__item__content__item",
36
- children: /*#__PURE__*/ jsx(Link, {
37
- className: "rp-overview-group__item__content__item__link",
38
- href: `${item.link}#${header.id}`,
39
- ...renderInlineMarkdown(header.text)
40
- })
41
- }, header.id)),
42
- item.items?.map(({ link, text })=>/*#__PURE__*/ jsx("li", {
43
- className: "rp-overview-group__item__content__item",
44
- children: /*#__PURE__*/ jsx(Link, {
45
- className: "rp-overview-group__item__content__item__link",
46
- href: link,
47
- ...renderInlineMarkdown(text)
48
- })
49
- }, link))
50
- ]
51
- })
52
- ]
53
- }, item.link))
54
- })
55
- ]
56
- });
57
- export { OverviewGroup };