@rspress/core 2.0.11 → 2.0.13

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 (119) hide show
  1. package/dist/0~execa.js +1 -1
  2. package/dist/{8857.js → 5580.js} +2 -2
  3. package/dist/{1688.js → 7275.js} +6 -1
  4. package/dist/{8006.js → 7986.js} +1 -6
  5. package/dist/cli/index.js +4 -4
  6. package/dist/config/loadConfigFile.js +1 -1
  7. package/dist/eject-theme/components/CodeBlock/index.test.tsx +49 -0
  8. package/dist/eject-theme/components/CodeBlock/index.tsx +1 -1
  9. package/dist/eject-theme/components/CodeButtonGroup/index.tsx +5 -2
  10. package/dist/eject-theme/components/FallbackHeading/index.test.tsx +45 -0
  11. package/dist/eject-theme/components/FallbackHeading/index.tsx +1 -1
  12. package/dist/eject-theme/components/Link/useLinkNavigate.ts +2 -2
  13. package/dist/eject-theme/components/Overview/index.test.tsx +57 -0
  14. package/dist/eject-theme/components/Overview/index.tsx +1 -1
  15. package/dist/eject-theme/components/OverviewGroup/index.test.tsx +61 -0
  16. package/dist/eject-theme/components/OverviewGroup/index.tsx +1 -1
  17. package/dist/eject-theme/components/PackageManagerTabs/index.test.tsx +54 -0
  18. package/dist/eject-theme/components/PackageManagerTabs/index.tsx +17 -18
  19. package/dist/eject-theme/components/Search/SearchPanel.tsx +1 -6
  20. package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +1 -1
  21. package/dist/eject-theme/components/Steps/index.scss +6 -4
  22. package/dist/eject-theme/components/Tabs/index.test.tsx +51 -0
  23. package/dist/eject-theme/components/Tabs/index.tsx +49 -42
  24. package/dist/index.js +1 -1
  25. package/dist/node/PluginDriver.js +1 -1
  26. package/dist/node/auto-nav-sidebar/index.js +1 -1
  27. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  28. package/dist/node/auto-nav-sidebar/normalize.d.ts +1 -1
  29. package/dist/node/auto-nav-sidebar/normalize.js +3 -4
  30. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  31. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  32. package/dist/node/constants.js +3 -3
  33. package/dist/node/eject.js +2 -2
  34. package/dist/node/initRsbuild.js +5 -8
  35. package/dist/node/logger/hint.js +1 -1
  36. package/dist/node/mdx/options.js +1 -1
  37. package/dist/node/mdx/processor.js +1 -1
  38. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  39. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
  40. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  41. package/dist/node/mdx/rehypePlugins/transformers/add-title.js +3 -6
  42. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  43. package/dist/node/mdx/remarkPlugins/containerSyntax.d.ts +1 -1
  44. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +2 -2
  45. package/dist/node/mdx/remarkPlugins/image.d.ts +1 -1
  46. package/dist/node/mdx/remarkPlugins/image.js +4 -4
  47. package/dist/node/mdx/remarkPlugins/link.d.ts +1 -1
  48. package/dist/node/mdx/remarkPlugins/link.js +2 -2
  49. package/dist/node/mdx/remarkPlugins/toc.js +1 -1
  50. package/dist/node/medium-zoom/index.js +1 -1
  51. package/dist/node/route/RoutePage.js +1 -1
  52. package/dist/node/route/RouteService.js +2 -3
  53. package/dist/node/route/extractPageData.js +1 -1
  54. package/dist/node/route/normalizeRoutePath.js +1 -1
  55. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +147 -140
  56. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +7 -0
  57. package/dist/node/runtimeModule/i18n.js +2 -2
  58. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  59. package/dist/node/runtimeModule/pageData/rsbuildPlugin.d.ts +1 -1
  60. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  61. package/dist/node/runtimeModule/searchHooks.js +1 -1
  62. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  63. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  64. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  65. package/dist/node/serve.js +1 -1
  66. package/dist/node/ssg/renderPage.js +2 -2
  67. package/dist/node/ssg/renderPageWorker.js +2 -2
  68. package/dist/node/ssg/renderPages.js +3 -3
  69. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  70. package/dist/node/ssg/ssgEnv.js +1 -1
  71. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  72. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  73. package/dist/node/ssg-md/remarkSplitMdx.js +1 -1
  74. package/dist/node/ssg-md/renderPage.js +2 -2
  75. package/dist/node/ssg-md/renderPages.js +3 -3
  76. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  77. package/dist/node/utils/checkLanguageParity.js +1 -1
  78. package/dist/node/utils/createHash.js +1 -1
  79. package/dist/node/utils/error.js +1 -1
  80. package/dist/node/utils/flattenMdxContent.js +1 -1
  81. package/dist/node/utils/fs.js +1 -1
  82. package/dist/node/utils/getPageKey.js +1 -1
  83. package/dist/node/utils/normalizePath.js +1 -1
  84. package/dist/node/utils/reactAlias.js +2 -2
  85. package/dist/runtime/App.js +1 -1
  86. package/dist/theme/components/CodeBlock/index.js +1 -1
  87. package/dist/theme/components/CodeButtonGroup/index.js +4 -2
  88. package/dist/theme/components/DocContent/docComponents/a.d.ts +1 -1
  89. package/dist/theme/components/DocContent/docComponents/hr.d.ts +1 -1
  90. package/dist/theme/components/DocContent/docComponents/img.d.ts +1 -1
  91. package/dist/theme/components/DocContent/docComponents/index.d.ts +18 -18
  92. package/dist/theme/components/DocContent/docComponents/list.d.ts +3 -3
  93. package/dist/theme/components/DocContent/docComponents/paragraph.d.ts +3 -3
  94. package/dist/theme/components/DocContent/docComponents/table.d.ts +3 -3
  95. package/dist/theme/components/DocContent/docComponents/title.d.ts +6 -6
  96. package/dist/theme/components/FallbackHeading/index.js +1 -1
  97. package/dist/theme/components/Link/useLinkNavigate.js +2 -2
  98. package/dist/theme/components/Nav/hooks.d.ts +1 -1
  99. package/dist/theme/components/Overview/index.js +1 -1
  100. package/dist/theme/components/OverviewGroup/index.js +1 -1
  101. package/dist/theme/components/PackageManagerTabs/index.js +18 -18
  102. package/dist/theme/components/Search/SearchPanel.js +1 -2
  103. package/dist/theme/components/Sidebar/SidebarItem.js +1 -0
  104. package/dist/theme/components/Steps/index.css +6 -4
  105. package/dist/theme/components/Tabs/index.d.ts +8 -4
  106. package/dist/theme/components/Tabs/index.js +20 -20
  107. package/dist/theme/layout/DocLayout/index.js +1 -1
  108. package/dist/theme/layout/HomeLayout/index.js +1 -1
  109. package/dist/theme/layout/Layout/index.js +1 -1
  110. package/package.json +9 -9
  111. package/dist/runtime/BrowserOnly.test.d.ts +0 -1
  112. /package/dist/{0~1402.js → 0~8787.js} +0 -0
  113. /package/dist/{5810.js → 2633.js} +0 -0
  114. /package/dist/{3323.js → 3358.js} +0 -0
  115. /package/dist/{8857.js.LICENSE.txt → 5580.js.LICENSE.txt} +0 -0
  116. /package/dist/{9224.js → 559.js} +0 -0
  117. /package/dist/{3294.js → 8005.js} +0 -0
  118. /package/dist/{6162.js → 9283.js} +0 -0
  119. /package/dist/{8474.js → 9882.js} +0 -0
@@ -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,
@@ -1,2 +1,2 @@
1
1
  import type { ComponentProps } from 'react';
2
- export declare const A: (props: ComponentProps<"a">) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const A: (props: ComponentProps<'a'>) => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import type { ComponentProps } from 'react';
2
- export declare const Hr: (props: ComponentProps<"hr">) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const Hr: (props: ComponentProps<'hr'>) => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import type { ComponentProps } from 'react';
2
- export declare const Img: (props: ComponentProps<"img">) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const Img: (props: ComponentProps<'img'>) => import("react/jsx-runtime").JSX.Element;
@@ -1,25 +1,25 @@
1
1
  import { Code } from './code.js';
2
2
  import { ShikiPre } from './pre.js';
3
3
  export declare function getCustomMDXComponent(): {
4
- h1: (props: React.ComponentProps<"h1">) => import("react/jsx-runtime").JSX.Element;
5
- h2: (props: React.ComponentProps<"h2">) => import("react/jsx-runtime").JSX.Element;
6
- h3: (props: React.ComponentProps<"h3">) => import("react/jsx-runtime").JSX.Element;
7
- h4: (props: React.ComponentProps<"h4">) => import("react/jsx-runtime").JSX.Element;
8
- h5: (props: React.ComponentProps<"h5">) => import("react/jsx-runtime").JSX.Element;
9
- h6: (props: React.ComponentProps<"h6">) => import("react/jsx-runtime").JSX.Element;
10
- ul: (props: import("react").ComponentProps<"ul">) => import("react/jsx-runtime").JSX.Element;
11
- ol: (props: import("react").ComponentProps<"ol">) => import("react/jsx-runtime").JSX.Element;
12
- li: (props: import("react").ComponentProps<"li">) => import("react/jsx-runtime").JSX.Element;
4
+ h1: (props: React.ComponentProps<'h1'>) => import("react/jsx-runtime").JSX.Element;
5
+ h2: (props: React.ComponentProps<'h2'>) => import("react/jsx-runtime").JSX.Element;
6
+ h3: (props: React.ComponentProps<'h3'>) => import("react/jsx-runtime").JSX.Element;
7
+ h4: (props: React.ComponentProps<'h4'>) => import("react/jsx-runtime").JSX.Element;
8
+ h5: (props: React.ComponentProps<'h5'>) => import("react/jsx-runtime").JSX.Element;
9
+ h6: (props: React.ComponentProps<'h6'>) => import("react/jsx-runtime").JSX.Element;
10
+ ul: (props: import("react").ComponentProps<'ul'>) => import("react/jsx-runtime").JSX.Element;
11
+ ol: (props: import("react").ComponentProps<'ol'>) => import("react/jsx-runtime").JSX.Element;
12
+ li: (props: import("react").ComponentProps<'li'>) => import("react/jsx-runtime").JSX.Element;
13
13
  table: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, "ref"> & import("react").RefAttributes<HTMLTableElement>>;
14
- td: (props: import("react").ComponentProps<"td">) => import("react/jsx-runtime").JSX.Element;
15
- th: (props: import("react").ComponentProps<"th">) => import("react/jsx-runtime").JSX.Element;
16
- tr: (props: import("react").ComponentProps<"tr">) => import("react/jsx-runtime").JSX.Element;
17
- hr: (props: import("react").ComponentProps<"hr">) => import("react/jsx-runtime").JSX.Element;
18
- p: (props: import("react").ComponentProps<"p">) => import("react/jsx-runtime").JSX.Element;
19
- blockquote: (props: import("react").ComponentProps<"blockquote">) => import("react/jsx-runtime").JSX.Element;
20
- strong: (props: import("react").ComponentProps<"strong">) => import("react/jsx-runtime").JSX.Element;
21
- a: (props: import("react").ComponentProps<"a">) => import("react/jsx-runtime").JSX.Element;
14
+ td: (props: import("react").ComponentProps<'td'>) => import("react/jsx-runtime").JSX.Element;
15
+ th: (props: import("react").ComponentProps<'th'>) => import("react/jsx-runtime").JSX.Element;
16
+ tr: (props: import("react").ComponentProps<'tr'>) => import("react/jsx-runtime").JSX.Element;
17
+ hr: (props: import("react").ComponentProps<'hr'>) => import("react/jsx-runtime").JSX.Element;
18
+ p: (props: import("react").ComponentProps<'p'>) => import("react/jsx-runtime").JSX.Element;
19
+ blockquote: (props: import("react").ComponentProps<'blockquote'>) => import("react/jsx-runtime").JSX.Element;
20
+ strong: (props: import("react").ComponentProps<'strong'>) => import("react/jsx-runtime").JSX.Element;
21
+ a: (props: import("react").ComponentProps<'a'>) => import("react/jsx-runtime").JSX.Element;
22
22
  code: typeof Code;
23
- img: (props: import("react").ComponentProps<"img">) => import("react/jsx-runtime").JSX.Element;
23
+ img: (props: import("react").ComponentProps<'img'>) => import("react/jsx-runtime").JSX.Element;
24
24
  pre: typeof ShikiPre;
25
25
  };
@@ -1,4 +1,4 @@
1
1
  import type { ComponentProps } from 'react';
2
- export declare const Ol: (props: ComponentProps<"ol">) => import("react/jsx-runtime").JSX.Element;
3
- export declare const Ul: (props: ComponentProps<"ul">) => import("react/jsx-runtime").JSX.Element;
4
- export declare const Li: (props: ComponentProps<"li">) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const Ol: (props: ComponentProps<'ol'>) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const Ul: (props: ComponentProps<'ul'>) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const Li: (props: ComponentProps<'li'>) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
1
  import type { ComponentProps } from 'react';
2
- export declare const P: (props: ComponentProps<"p">) => import("react/jsx-runtime").JSX.Element;
3
- export declare const Blockquote: (props: ComponentProps<"blockquote">) => import("react/jsx-runtime").JSX.Element;
4
- export declare const Strong: (props: ComponentProps<"strong">) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const P: (props: ComponentProps<'p'>) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const Blockquote: (props: ComponentProps<'blockquote'>) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const Strong: (props: ComponentProps<'strong'>) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { type ComponentProps } from 'react';
2
2
  export declare const Table: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, "ref"> & import("react").RefAttributes<HTMLTableElement>>;
3
- export declare const Tr: (props: ComponentProps<"tr">) => import("react/jsx-runtime").JSX.Element;
4
- export declare const Td: (props: ComponentProps<"td">) => import("react/jsx-runtime").JSX.Element;
5
- export declare const Th: (props: ComponentProps<"th">) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const Tr: (props: ComponentProps<'tr'>) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const Td: (props: ComponentProps<'td'>) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const Th: (props: ComponentProps<'th'>) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import type React from 'react';
2
- export declare const H1: (props: React.ComponentProps<"h1">) => import("react/jsx-runtime").JSX.Element;
3
- export declare const H2: (props: React.ComponentProps<"h2">) => import("react/jsx-runtime").JSX.Element;
4
- export declare const H3: (props: React.ComponentProps<"h3">) => import("react/jsx-runtime").JSX.Element;
5
- export declare const H4: (props: React.ComponentProps<"h4">) => import("react/jsx-runtime").JSX.Element;
6
- export declare const H5: (props: React.ComponentProps<"h5">) => import("react/jsx-runtime").JSX.Element;
7
- export declare const H6: (props: React.ComponentProps<"h6">) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const H1: (props: React.ComponentProps<'h1'>) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const H2: (props: React.ComponentProps<'h2'>) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const H3: (props: React.ComponentProps<'h3'>) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const H4: (props: React.ComponentProps<'h4'>) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const H5: (props: React.ComponentProps<'h5'>) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const H6: (props: React.ComponentProps<'h6'>) => import("react/jsx-runtime").JSX.Element;
@@ -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());
@@ -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
  {
@@ -7,8 +7,8 @@ export declare function useLangsMenu(): {
7
7
  }[];
8
8
  activeValue: string | undefined;
9
9
  } | {
10
- items: never[];
11
10
  activeValue?: undefined;
11
+ items: never[];
12
12
  };
13
13
  export declare function useVersionsMenu(): {
14
14
  items: {
@@ -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,32 +111,32 @@ 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
  }, '');
118
118
  return /*#__PURE__*/ jsx(Tabs, {
119
119
  groupId: "package.manager",
120
- values: Object.entries(commandInfo).map(([key])=>/*#__PURE__*/ jsxs("div", {
121
- style: {
122
- display: 'flex',
123
- alignItems: 'center',
124
- fontSize: 15
125
- },
126
- children: [
127
- packageMangerToIcon[key],
128
- /*#__PURE__*/ jsx("span", {
129
- style: {
130
- marginLeft: 6,
131
- marginBottom: 2
132
- },
133
- children: key
134
- })
135
- ]
136
- }, key)),
137
120
  children: Object.entries(commandInfo).map(([key, value])=>{
138
121
  const [packageManager, command] = splitTo2Parts(value);
139
122
  return /*#__PURE__*/ jsx(Tab, {
123
+ label: /*#__PURE__*/ jsxs("div", {
124
+ style: {
125
+ display: 'flex',
126
+ alignItems: 'center',
127
+ fontSize: 15
128
+ },
129
+ children: [
130
+ packageMangerToIcon[key],
131
+ /*#__PURE__*/ jsx("span", {
132
+ style: {
133
+ marginLeft: 6,
134
+ marginBottom: 2
135
+ },
136
+ children: key
137
+ })
138
+ ]
139
+ }),
140
140
  children: /*#__PURE__*/ jsx(Pre, {
141
141
  lang: "bash",
142
142
  className: "shiki css-variables",
@@ -239,10 +239,8 @@ function SearchPanel({ focused, setFocused }) {
239
239
  children: renderSearchResultItem(currentSearchResult, query, isSearching)
240
240
  });
241
241
  }
242
- const tabValues = result.map((item)=>item.group);
243
242
  const renderKey = 'render';
244
243
  return /*#__PURE__*/ jsx(Tabs, {
245
- values: tabValues,
246
244
  className: "rp-search-panel__tabs",
247
245
  onChange: (index)=>{
248
246
  setResultTabIndex(index);
@@ -251,6 +249,7 @@ function SearchPanel({ focused, setFocused }) {
251
249
  keepDOM: false,
252
250
  ref: searchResultTabRef,
253
251
  children: result.map((item)=>/*#__PURE__*/ jsxs(Tab, {
252
+ label: item.group,
254
253
  children: [
255
254
  item.renderType === RenderType.Default && renderSearchResultItem(item.result, query, isSearching),
256
255
  item.renderType === RenderType.Custom && __rspack_external_virtual_search_hooks_9d01d01f[renderKey](item.result)
@@ -28,6 +28,7 @@ function SidebarItemRaw({ active, text, tag, link, context, className, left, rig
28
28
  ref: ref,
29
29
  children: [
30
30
  /*#__PURE__*/ jsx("span", {
31
+ className: "rp-doc",
31
32
  ...renderInlineMarkdown(text)
32
33
  }),
33
34
  left
@@ -1,6 +1,7 @@
1
1
  :root {
2
2
  --rp-steps-gap: 24px;
3
3
  --rp-steps-size: 30px;
4
+ --rp-steps-offset-y: 4px;
4
5
  }
5
6
 
6
7
  .rp-steps {
@@ -13,15 +14,14 @@
13
14
 
14
15
  .rp-steps h3 {
15
16
  counter-increment: step;
16
- align-items: center;
17
- min-height: 30px;
17
+ min-height: var(--rp-steps-size);
18
18
  margin-top: 0;
19
- display: flex;
20
19
  position: relative;
21
20
  }
22
21
 
23
22
  .rp-steps h3:before {
24
23
  content: counter(step);
24
+ top: calc(var(--rp-steps-size)/2 + var(--rp-steps-offset-y));
25
25
  left: calc(-1*var(--rp-steps-gap));
26
26
  width: var(--rp-steps-size);
27
27
  height: var(--rp-steps-size);
@@ -37,11 +37,13 @@
37
37
  font-weight: 500;
38
38
  display: flex;
39
39
  position: absolute;
40
- transform: translate(-50%);
40
+ transform: translate(-50%, -50%);
41
41
  }
42
42
 
43
43
  .rp-steps h3 .rp-header-anchor {
44
+ top: calc(var(--rp-steps-size)/2 + var(--rp-steps-offset-y));
44
45
  left: calc(-1*var(--rp-steps-gap) - var(--rp-steps-size)/2);
45
46
  position: absolute;
47
+ transform: translate(0, -50%);
46
48
  }
47
49
 
@@ -1,16 +1,17 @@
1
1
  import { type ReactElement, type ReactNode } from 'react';
2
2
  import './index.scss';
3
3
  type TabItem = {
4
- label?: string | ReactNode;
4
+ label: ReactNode;
5
+ value: string;
5
6
  disabled?: boolean;
6
- content?: ReactNode;
7
7
  };
8
8
  export interface TabsProps {
9
- values?: ReactNode[] | ReadonlyArray<ReactNode> | TabItem[];
9
+ values?: ReadonlyArray<TabItem>;
10
10
  /**
11
11
  * @default 0
12
12
  */
13
13
  defaultIndex?: number;
14
+ defaultValue?: string;
14
15
  onChange?: (index: number) => void;
15
16
  children: ReactNode;
16
17
  /**
@@ -29,7 +30,10 @@ export interface TabsProps {
29
30
  contentItemClassName?: string;
30
31
  }
31
32
  export declare const Tabs: import("react").ForwardRefExoticComponent<TabsProps & import("react").RefAttributes<HTMLDivElement>>;
32
- export type TabProps = Pick<TabItem, 'label' | 'disabled'> & {
33
+ export type TabProps = {
34
+ label?: ReactNode;
35
+ value?: string;
36
+ disabled?: boolean;
33
37
  children: ReactNode;
34
38
  };
35
39
  export declare function Tab({ children }: TabProps): ReactElement;
@@ -3,18 +3,19 @@ import { useStorageValue } from "@rspress/core/theme";
3
3
  import clsx from "clsx";
4
4
  import { Children, forwardRef, isValidElement, useMemo, useState } from "react";
5
5
  import "./index.css";
6
- function getTabValuesFromChildren(children, defaultValues) {
7
- if (defaultValues?.every((item)=>isTabItem(item) && item.content)) return defaultValues;
8
- if (defaultValues && defaultValues.length > 0) return defaultValues.map((item, index)=>{
9
- if (isTabItem(item)) return item;
6
+ function getTabValuesFromChildren(children, values) {
7
+ if (values && values.length > 0) return values.map((item, index)=>{
8
+ const content = children.find((child)=>child.props?.value === item.value) ?? children[index];
10
9
  return {
11
- label: item,
12
- content: children[index]
10
+ ...item,
11
+ content
13
12
  };
14
13
  });
15
14
  return Children.map(children, (child, index)=>{
16
15
  if (/*#__PURE__*/ isValidElement(child)) return {
17
16
  label: child.props?.label || void 0,
17
+ value: child.props?.value,
18
+ disabled: child.props?.disabled,
18
19
  content: children[index]
19
20
  };
20
21
  return {
@@ -23,19 +24,15 @@ function getTabValuesFromChildren(children, defaultValues) {
23
24
  };
24
25
  });
25
26
  }
26
- function isTabItem(item) {
27
- if (item && 'object' == typeof item && 'label' in item) return true;
28
- return false;
29
- }
30
27
  const groupIdPrefix = 'rspress.tabs.';
31
28
  const Tabs = /*#__PURE__*/ forwardRef((props, ref)=>{
32
- const { values, defaultIndex, onChange, children: rawChildren, groupId, tabPosition = 'left', className, labelItemClassName, contentItemClassName, keepDOM = true } = props;
29
+ const { values, defaultIndex, defaultValue, onChange, children: rawChildren, groupId, tabPosition = 'left', className, labelItemClassName, contentItemClassName, keepDOM = true } = props;
33
30
  const children = Children.toArray(rawChildren).filter((child)=>!('string' == typeof child && '' === child.trim()) && /*#__PURE__*/ isValidElement(child));
34
31
  const tabValues = useMemo(()=>getTabValuesFromChildren(children, values), [
35
- values,
36
- children
32
+ children,
33
+ values
37
34
  ]);
38
- if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(Fragment, {
35
+ if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsx(Fragment, {
39
36
  children: tabValues.map(({ label, content })=>/*#__PURE__*/ jsxs(Fragment, {
40
37
  children: [
41
38
  `\n**${label}**\n\n`,
@@ -44,8 +41,10 @@ const Tabs = /*#__PURE__*/ forwardRef((props, ref)=>{
44
41
  ]
45
42
  }))
46
43
  });
47
- const [activeIndex, setActiveIndex] = useState(defaultIndex ?? 0);
48
- const [storageIndex, setStorageIndex] = useStorageValue(`${groupIdPrefix}${groupId}`, activeIndex.toString());
44
+ const defaultValueIndex = void 0 !== defaultValue ? tabValues.findIndex((item)=>item.value === defaultValue) : -1;
45
+ const initialActiveIndex = -1 === defaultValueIndex ? defaultIndex ?? 0 : defaultValueIndex;
46
+ const [activeIndex, setActiveIndex] = useState(initialActiveIndex);
47
+ const [storageIndex, setStorageIndex] = useStorageValue(`${groupIdPrefix}${groupId}`, initialActiveIndex.toString());
49
48
  const currentIndex = groupId ? Number(storageIndex) : activeIndex;
50
49
  return /*#__PURE__*/ jsxs("div", {
51
50
  className: clsx('rp-tabs', className),
@@ -56,23 +55,24 @@ const Tabs = /*#__PURE__*/ forwardRef((props, ref)=>{
56
55
  style: {
57
56
  justifyContent: 'center' === tabPosition ? 'center' : 'flex-start'
58
57
  },
59
- children: tabValues.map(({ label }, index)=>{
58
+ children: tabValues.map(({ label, value, disabled }, index)=>{
60
59
  const isActive = index === currentIndex;
61
60
  return /*#__PURE__*/ jsx("div", {
62
61
  className: clsx('rp-tabs__label__item', isActive ? 'rp-tabs__label__item--selected' : 'rp-tabs__label__item--not-selected', labelItemClassName),
63
62
  "data-index": index,
64
63
  onClick: ()=>{
64
+ if (disabled) return;
65
65
  onChange?.(index);
66
66
  if (groupId) setStorageIndex(index.toString());
67
67
  else setActiveIndex(index);
68
68
  },
69
69
  children: label
70
- }, 'string' == typeof label ? label : index);
70
+ }, value ?? index);
71
71
  })
72
72
  }) : null,
73
73
  /*#__PURE__*/ jsx("div", {
74
74
  className: "rp-tabs__content",
75
- children: tabValues.map(({ label, content }, index)=>{
75
+ children: tabValues.map(({ value, content }, index)=>{
76
76
  const isActive = index === currentIndex;
77
77
  if (!keepDOM && !isActive) return null;
78
78
  return /*#__PURE__*/ jsx("div", {
@@ -80,7 +80,7 @@ const Tabs = /*#__PURE__*/ forwardRef((props, ref)=>{
80
80
  "aria-hidden": !isActive,
81
81
  "data-index": index,
82
82
  children: content
83
- }, 'string' == typeof label ? label : index);
83
+ }, value ?? index);
84
84
  })
85
85
  })
86
86
  ]
@@ -14,7 +14,7 @@ function DocLayout(props) {
14
14
  const isLegacyPlaceholder = 'placeholder' === sidebar;
15
15
  const { outline: showOutline = true, footer: showDocFooter = true, pageType } = frontmatter;
16
16
  const showSidebarMenu = showSidebar || !isOverviewPage && showOutline;
17
- if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(Fragment, {
17
+ if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsx(Fragment, {
18
18
  children: isOverviewPage ? /*#__PURE__*/ jsx(Overview, {
19
19
  content: /*#__PURE__*/ jsx(DocContent, {
20
20
  components: components,
@@ -40,7 +40,7 @@ function HomeLayoutMarkdown() {
40
40
  });
41
41
  }
42
42
  function HomeLayout(props) {
43
- if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(HomeLayoutMarkdown, {});
43
+ if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsx(HomeLayoutMarkdown, {});
44
44
  const { beforeHero, afterHero, beforeFeatures, afterFeatures, beforeHeroActions, afterHeroActions } = props;
45
45
  return /*#__PURE__*/ jsxs(Fragment, {
46
46
  children: [
@@ -111,7 +111,7 @@ function Layout(props) {
111
111
  });
112
112
  }
113
113
  };
114
- if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(Fragment, {
114
+ if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsx(Fragment, {
115
115
  children: getContentLayout()
116
116
  });
117
117
  useSetup();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "2.0.11",
3
+ "version": "2.0.13",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -60,7 +60,7 @@
60
60
  "dependencies": {
61
61
  "@mdx-js/mdx": "^3.1.1",
62
62
  "@mdx-js/react": "^3.1.1",
63
- "@rsbuild/core": "^2.0.5",
63
+ "@rsbuild/core": "^2.0.7",
64
64
  "@rsbuild/plugin-react": "~2.0.0",
65
65
  "@shikijs/rehype": "^4.0.2",
66
66
  "@types/unist": "^3.0.3",
@@ -79,8 +79,8 @@
79
79
  "react-dom": "^19.2.6",
80
80
  "react-lazy-with-preload": "^2.2.1",
81
81
  "react-reconciler": "0.33.0",
82
- "react-render-to-markdown": "19.0.1",
83
- "react-router-dom": "^7.15.0",
82
+ "react-render-to-markdown": "19.1.0",
83
+ "react-router-dom": "^7.15.1",
84
84
  "rehype-external-links": "^3.0.0",
85
85
  "rehype-raw": "^7.0.0",
86
86
  "remark-cjk-friendly": "^2.0.1",
@@ -95,19 +95,19 @@
95
95
  "unist-util-remove": "^4.0.0",
96
96
  "unist-util-visit": "^5.1.0",
97
97
  "unist-util-visit-children": "^3.0.0",
98
- "@rspress/shared": "2.0.11"
98
+ "@rspress/shared": "2.0.13"
99
99
  },
100
100
  "devDependencies": {
101
101
  "@microsoft/api-extractor": "^7.57.7",
102
102
  "@rsbuild/plugin-sass": "~1.5.2",
103
103
  "@rsbuild/plugin-svgr": "^2.0.2",
104
- "@rslib/core": "0.21.4",
104
+ "@rslib/core": "0.21.5",
105
105
  "@types/body-scroll-lock": "^3.1.2",
106
106
  "@types/hast": "^3.0.4",
107
107
  "@types/mdast": "^4.0.4",
108
108
  "@types/node": "^22.8.1",
109
109
  "@types/nprogress": "^0.2.3",
110
- "@types/react": "^19.2.14",
110
+ "@types/react": "^19.2.15",
111
111
  "@types/react-dom": "^19.2.3",
112
112
  "@types/react-reconciler": "^0.33.0",
113
113
  "@types/web": "^0.0.349",
@@ -119,7 +119,7 @@
119
119
  "memfs": "^4.57.2",
120
120
  "p-map": "^7.0.4",
121
121
  "picocolors": "^1.1.1",
122
- "postcss": "8.5.14",
122
+ "postcss": "8.5.15",
123
123
  "remark-directive": "^4.0.0",
124
124
  "rsbuild-plugin-publint": "^0.3.4",
125
125
  "rsbuild-plugin-virtual-module": "0.4.2",
@@ -127,7 +127,7 @@
127
127
  "tinyglobby": "^0.2.16",
128
128
  "tinypool": "^1.1.1",
129
129
  "ts-json-schema-generator": "^2.9.0",
130
- "typescript": "^5.8.2",
130
+ "typescript": "^6.0.3",
131
131
  "vfile": "^6.0.3",
132
132
  "@rspress/config": "1.0.0"
133
133
  },
@@ -1 +0,0 @@
1
- export {};
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes