@rspress/core 2.0.20 → 2.0.22

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 (179) hide show
  1. package/dist/cli/index.js +12 -13
  2. package/dist/config/loadConfigFile.d.ts +3 -4
  3. package/dist/config/loadConfigFile.js +13 -17
  4. package/dist/{7748~0.js → d~0.js} +0 -2
  5. package/dist/eject-theme/components/Banner/index.tsx +50 -9
  6. package/dist/eject-theme/components/Callout/index.scss +6 -1
  7. package/dist/eject-theme/components/CodeBlock/index.scss +2 -0
  8. package/dist/eject-theme/components/DocContent/doc.scss +2 -2
  9. package/dist/eject-theme/components/Link/getHref.test.ts +33 -0
  10. package/dist/eject-theme/components/Link/getHref.ts +60 -0
  11. package/dist/eject-theme/components/Link/index.tsx +7 -6
  12. package/dist/eject-theme/components/Link/useLinkNavigate.ts +6 -51
  13. package/dist/eject-theme/components/Llms/LlmsHint.test.tsx +8 -0
  14. package/dist/eject-theme/components/Llms/LlmsHint.tsx +11 -3
  15. package/dist/eject-theme/components/Nav/NavMenu.scss +19 -3
  16. package/dist/eject-theme/components/Nav/NavMenu.tsx +20 -13
  17. package/dist/eject-theme/components/Nav/index.scss +3 -1
  18. package/dist/eject-theme/components/Nav/index.tsx +30 -4
  19. package/dist/eject-theme/components/NavHamburger/index.tsx +11 -3
  20. package/dist/eject-theme/components/NavList/context.ts +3 -0
  21. package/dist/eject-theme/components/NavList/index.tsx +24 -0
  22. package/dist/eject-theme/components/NavScreen/NavScreenMenu.test.tsx +59 -0
  23. package/dist/eject-theme/components/NavScreen/NavScreenMenu.tsx +43 -2
  24. package/dist/eject-theme/components/NavScreen/index.scss +0 -6
  25. package/dist/eject-theme/components/NavScreen/index.tsx +20 -3
  26. package/dist/eject-theme/components/Prompt/index.scss +2 -1
  27. package/dist/eject-theme/components/ReadPercent/useReadPercent.ts +1 -1
  28. package/dist/eject-theme/components/Search/SearchButton.scss +1 -0
  29. package/dist/eject-theme/components/Search/SearchPanel.scss +51 -12
  30. package/dist/eject-theme/components/Search/SearchPanel.tsx +54 -212
  31. package/dist/eject-theme/components/Search/logic/providers/LocalProvider.ts +38 -16
  32. package/dist/eject-theme/components/Search/useSearchPanel.ts +216 -0
  33. package/dist/eject-theme/components/Steps/index.scss +1 -1
  34. package/dist/eject-theme/components/SwitchAppearance/getClipPath.test.ts +15 -0
  35. package/dist/eject-theme/components/SwitchAppearance/getClipPath.ts +26 -0
  36. package/dist/eject-theme/components/SwitchAppearance/global.scss +18 -0
  37. package/dist/eject-theme/components/SwitchAppearance/index.tsx +26 -35
  38. package/dist/eject-theme/components/Tabs/index.tsx +14 -14
  39. package/dist/index.js +1 -1
  40. package/dist/node/PluginDriver.d.ts +1 -1
  41. package/dist/node/PluginDriver.js +5 -9
  42. package/dist/node/auto-nav-sidebar/index.js +1 -1
  43. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  44. package/dist/node/auto-nav-sidebar/normalize.js +6 -6
  45. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  46. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  47. package/dist/node/build.d.ts +3 -2
  48. package/dist/node/build.js +9 -3
  49. package/dist/node/constants.js +1 -1
  50. package/dist/node/dev.d.ts +4 -4
  51. package/dist/node/dev.js +8 -6
  52. package/dist/node/eject.js +5 -5
  53. package/dist/node/initRsbuild.d.ts +2 -3
  54. package/dist/node/initRsbuild.js +9 -7
  55. package/dist/node/last-updated/index.js +2 -2
  56. package/dist/node/logger/hint.js +4 -4
  57. package/dist/node/mdx/options.js +1 -1
  58. package/dist/node/mdx/processor.js +3 -3
  59. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  60. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
  61. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  62. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  63. package/dist/node/mdx/remarkPlugins/containerSyntax.js +6 -5
  64. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +5 -5
  65. package/dist/node/mdx/remarkPlugins/image.js +5 -5
  66. package/dist/node/mdx/remarkPlugins/link.js +5 -5
  67. package/dist/node/mdx/remarkPlugins/toc.js +1 -1
  68. package/dist/node/medium-zoom/index.js +1 -1
  69. package/dist/node/route/RoutePage.js +6 -4
  70. package/dist/node/route/RouteService.js +3 -3
  71. package/dist/node/route/extractPageData.js +20 -7
  72. package/dist/node/route/normalizeRoutePath.js +1 -1
  73. package/dist/node/runtimeModule/i18n.js +5 -5
  74. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  75. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  76. package/dist/node/runtimeModule/searchHooks.js +1 -1
  77. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  78. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  79. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  80. package/dist/node/serve.d.ts +3 -3
  81. package/dist/node/serve.js +10 -4
  82. package/dist/node/ssg/alternateLinks.js +1 -1
  83. package/dist/node/ssg/htmlFile.js +1 -1
  84. package/dist/node/ssg/renderHtmlTemplate.js +1 -1
  85. package/dist/node/ssg/renderPage.js +5 -5
  86. package/dist/node/ssg/renderPageWorker.js +2 -2
  87. package/dist/node/ssg/renderPages.js +6 -6
  88. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  89. package/dist/node/ssg/ssgEnv.js +1 -1
  90. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  91. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  92. package/dist/node/ssg-md/remarkSplitMdx.js +1 -1
  93. package/dist/node/ssg-md/renderPage.js +5 -5
  94. package/dist/node/ssg-md/renderPages.js +6 -6
  95. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  96. package/dist/node/utils/checkLanguageParity.js +5 -7
  97. package/dist/node/utils/createHash.js +1 -1
  98. package/dist/node/utils/error.js +4 -4
  99. package/dist/node/utils/flattenMdxContent.js +2 -2
  100. package/dist/node/utils/fs.js +1 -1
  101. package/dist/node/utils/getPageKey.js +1 -1
  102. package/dist/node/utils/index.d.ts +1 -1
  103. package/dist/node/utils/reactAlias.js +5 -5
  104. package/dist/node/utils/slash.d.ts +1 -0
  105. package/dist/node/utils/slash.js +4 -0
  106. package/dist/{864~0.js → n~0.js} +41 -41
  107. package/dist/{2711~0.js → o~0.js} +90 -56
  108. package/dist/rslib-runtime~0.js +27 -35
  109. package/dist/theme/components/Banner/index.js +53 -9
  110. package/dist/theme/components/Callout/index.css +6 -1
  111. package/dist/theme/components/CodeBlock/index.css +2 -0
  112. package/dist/theme/components/DocContent/doc.css +2 -2
  113. package/dist/theme/components/Link/getHref.d.ts +8 -0
  114. package/dist/theme/components/Link/getHref.js +33 -0
  115. package/dist/theme/components/Link/index.js +7 -6
  116. package/dist/theme/components/Link/useLinkNavigate.d.ts +0 -7
  117. package/dist/theme/components/Link/useLinkNavigate.js +8 -32
  118. package/dist/theme/components/Llms/LlmsHint.js +23 -6
  119. package/dist/theme/components/Nav/NavMenu.css +18 -6
  120. package/dist/theme/components/Nav/NavMenu.d.ts +4 -2
  121. package/dist/theme/components/Nav/NavMenu.js +17 -9
  122. package/dist/theme/components/Nav/index.css +3 -1
  123. package/dist/theme/components/Nav/index.d.ts +7 -1
  124. package/dist/theme/components/Nav/index.js +13 -4
  125. package/dist/theme/components/NavHamburger/index.d.ts +2 -1
  126. package/dist/theme/components/NavHamburger/index.js +8 -2
  127. package/dist/theme/components/NavList/context.d.ts +1 -0
  128. package/dist/theme/components/NavList/context.js +3 -0
  129. package/dist/theme/components/NavList/index.d.ts +6 -0
  130. package/dist/theme/components/NavList/index.js +17 -0
  131. package/dist/theme/components/NavScreen/NavScreenMenu.d.ts +3 -2
  132. package/dist/theme/components/NavScreen/NavScreenMenu.js +42 -6
  133. package/dist/theme/components/NavScreen/index.css +0 -10
  134. package/dist/theme/components/NavScreen/index.d.ts +2 -1
  135. package/dist/theme/components/NavScreen/index.js +11 -3
  136. package/dist/theme/components/PackageManagerTabs/index.js +2 -2
  137. package/dist/theme/components/Prompt/index.css +2 -1
  138. package/dist/theme/components/ReadPercent/useReadPercent.js +1 -0
  139. package/dist/theme/components/Search/SearchButton.css +1 -0
  140. package/dist/theme/components/Search/SearchPanel.css +47 -9
  141. package/dist/theme/components/Search/SearchPanel.js +97 -205
  142. package/dist/theme/components/Search/logic/providers/LocalProvider.d.ts +1 -0
  143. package/dist/theme/components/Search/logic/providers/LocalProvider.js +23 -13
  144. package/dist/theme/components/Search/logic/search.js +1 -1
  145. package/dist/theme/components/Search/useSearchPanel.d.ts +23 -0
  146. package/dist/theme/components/Search/useSearchPanel.js +155 -0
  147. package/dist/theme/components/Steps/index.css +3 -3
  148. package/dist/theme/components/SwitchAppearance/getClipPath.d.ts +8 -0
  149. package/dist/theme/components/SwitchAppearance/getClipPath.js +13 -0
  150. package/dist/theme/components/SwitchAppearance/global.css +12 -0
  151. package/dist/theme/components/SwitchAppearance/index.js +11 -15
  152. package/dist/theme/components/Tabs/index.js +4 -4
  153. package/dist/theme/components/Tag/index.js +2 -2
  154. package/dist/theme/index.d.ts +1 -0
  155. package/dist/theme/index.js +1 -0
  156. package/dist/theme/layout/DocLayout/index.js +2 -2
  157. package/dist/theme/layout/Layout/index.js +12 -4
  158. package/dist/theme/logic/applyThemeToDOM.d.ts +2 -0
  159. package/dist/theme/logic/applyThemeToDOM.js +17 -0
  160. package/dist/theme/logic/useFullTextSearch.js +6 -1
  161. package/dist/theme/logic/useThemeState.d.ts +1 -2
  162. package/dist/theme/logic/useThemeState.js +1 -7
  163. package/dist/theme/styles/vars/shiki-vars.css +1 -1
  164. package/dist/tinypool~0.js +5 -3
  165. package/dist/{4538~0.js → t~0.js} +2 -2
  166. package/dist/{8472~0.js → v~0.js} +1 -1
  167. package/package.json +11 -12
  168. package/dist/eject-theme/components/NavScreen/NavScreenMenuOthers.tsx +0 -29
  169. package/dist/node/utils/normalizePath.d.ts +0 -3
  170. package/dist/node/utils/normalizePath.js +0 -10
  171. package/dist/theme/components/NavScreen/NavScreenMenuOthers.d.ts +0 -2
  172. package/dist/theme/components/NavScreen/NavScreenMenuOthers.js +0 -30
  173. package/dist/theme/logic/useHandler.d.ts +0 -6
  174. package/dist/theme/logic/useHandler.js +0 -7
  175. /package/dist/{9857~0.js → 4~0.js} +0 -0
  176. /package/dist/{8016~0.js → i~0.js} +0 -0
  177. /package/dist/{5357~0.js → r~0.js} +0 -0
  178. /package/dist/{102~0.js → t2~0.js} +0 -0
  179. /package/dist/{9940~0.js → tx~0.js} +0 -0
@@ -0,0 +1,15 @@
1
+ import { describe, expect, it } from '@rstest/core';
2
+ import { getClipPath } from './getClipPath';
3
+
4
+ describe('getClipPath', () => {
5
+ it('uses percentages relative to the view transition snapshot', () => {
6
+ expect(
7
+ getClipPath({
8
+ height: 600,
9
+ width: 800,
10
+ x: 800,
11
+ y: 0,
12
+ }),
13
+ ).toEqual(['circle(0% at 100% 0%)', 'circle(160% at 100% 0%)']);
14
+ });
15
+ });
@@ -0,0 +1,26 @@
1
+ type ClipPathOptions = {
2
+ height: number;
3
+ width: number;
4
+ x: number;
5
+ y: number;
6
+ };
7
+
8
+ const roundPercentage = (value: number) => Math.round(value * 1e6) / 1e6;
9
+
10
+ export const getClipPath = ({ height, width, x, y }: ClipPathOptions) => {
11
+ const endRadius = Math.hypot(
12
+ Math.max(x, width - x + 200),
13
+ Math.max(y, height - y + 200),
14
+ );
15
+ const normalizedDiagonal = Math.hypot(width, height) / Math.SQRT2;
16
+ const xPercentage = roundPercentage((x / width) * 100);
17
+ const yPercentage = roundPercentage((y / height) * 100);
18
+ const endRadiusPercentage = roundPercentage(
19
+ (endRadius / normalizedDiagonal) * 100,
20
+ );
21
+
22
+ return [
23
+ `circle(0% at ${xPercentage}% ${yPercentage}%)`,
24
+ `circle(${endRadiusPercentage}% at ${xPercentage}% ${yPercentage}%)`,
25
+ ];
26
+ };
@@ -4,6 +4,24 @@
4
4
  mix-blend-mode: normal;
5
5
  }
6
6
 
7
+ /* Toggled by applyThemeToDOM for one frame while the theme class flips, so
8
+ every themed surface switches in sync instead of fading at its own pace.
9
+ A static rule toggled via a root class (rather than an injected <style>)
10
+ stays compatible with strict CSP. */
11
+ html.rp-theme-switching *,
12
+ html.rp-theme-switching *::before,
13
+ html.rp-theme-switching *::after,
14
+ html.rp-theme-switching *::-webkit-scrollbar-thumb {
15
+ transition: none !important;
16
+ }
17
+
18
+ /* Toggled by SwitchAppearance while the appearance view transition runs; the
19
+ 'flip' and 'root' view-transition names conflict otherwise, see
20
+ https://github.com/web-infra-dev/rspress/pull/1272 */
21
+ html.rp-appearance-transition .rspress-doc {
22
+ view-transition-name: none !important;
23
+ }
24
+
7
25
  ::view-transition-old(root),
8
26
  .dark::view-transition-new(root) {
9
27
  z-index: 1;
@@ -4,6 +4,7 @@ import { type MouseEvent, useContext } from 'react';
4
4
  import './global.scss';
5
5
  import './index.scss';
6
6
  import { flushSync } from 'react-dom';
7
+ import { getClipPath } from './getClipPath';
7
8
 
8
9
  const supportAppearanceTransition = () => {
9
10
  return (
@@ -12,17 +13,12 @@ const supportAppearanceTransition = () => {
12
13
  );
13
14
  };
14
15
 
15
- // two view-transition name is conflicted, 'flip' and 'root', see https://github.com/web-infra-dev/rspress/pull/1272
16
+ // Toggles the `html.rp-appearance-transition` rule in global.scss — see the
17
+ // comment there and https://github.com/web-infra-dev/rspress/pull/1272
16
18
  const removeClipViewTransition = () => {
17
- const styleDom = document.createElement('style');
18
- styleDom.innerHTML = `
19
- .rspress-doc {
20
- view-transition-name: none !important;
21
- }
22
- `;
23
- document.head.appendChild(styleDom);
19
+ document.documentElement.classList.add('rp-appearance-transition');
24
20
  return () => {
25
- document.head.removeChild(styleDom);
21
+ document.documentElement.classList.remove('rp-appearance-transition');
26
22
  };
27
23
  };
28
24
 
@@ -41,11 +37,6 @@ export function SwitchAppearance({ onClick }: { onClick?: () => void }) {
41
37
  const x = event.clientX;
42
38
  const y = event.clientY;
43
39
 
44
- const endRadius = Math.hypot(
45
- Math.max(x, innerWidth - x + 200),
46
- Math.max(y, innerHeight - y + 200),
47
- );
48
-
49
40
  const dispose = removeClipViewTransition();
50
41
  const transition = document.startViewTransition(async () => {
51
42
  flushSync(() => {
@@ -54,30 +45,30 @@ export function SwitchAppearance({ onClick }: { onClick?: () => void }) {
54
45
  });
55
46
  });
56
47
 
57
- const clipPath = [
58
- `circle(0px at ${x}px ${y}px)`,
59
- `circle(${endRadius}px at ${x}px ${y}px)`,
60
- ];
48
+ const clipPath = getClipPath({
49
+ height: innerHeight,
50
+ width: innerWidth,
51
+ x,
52
+ y,
53
+ });
61
54
  transition.ready.then(() => {
62
- document.documentElement
63
- .animate(
64
- {
65
- clipPath: isDark ? [...clipPath].reverse() : clipPath,
66
- },
67
- {
68
- duration: 400,
69
- easing: 'ease-in',
70
- pseudoElement: isDark
71
- ? '::view-transition-old(root)'
72
- : '::view-transition-new(root)',
55
+ document.documentElement.animate(
56
+ {
57
+ clipPath: isDark ? [...clipPath].reverse() : clipPath,
58
+ },
59
+ {
60
+ duration: 400,
61
+ easing: 'ease-in',
62
+ fill: 'both',
63
+ pseudoElement: isDark
64
+ ? '::view-transition-old(root)'
65
+ : '::view-transition-new(root)',
73
66
 
74
- id: '',
75
- },
76
- )
77
- .finished.then(() => {
78
- dispose();
79
- });
67
+ id: '',
68
+ },
69
+ );
80
70
  });
71
+ transition.finished.then(dispose, dispose);
81
72
  } else {
82
73
  setTheme(nextTheme);
83
74
  onClick?.();
@@ -116,6 +116,20 @@ export const Tabs = forwardRef(
116
116
  return getTabValuesFromChildren(children, values);
117
117
  }, [children, values]);
118
118
 
119
+ const defaultValueIndex =
120
+ defaultValue !== undefined
121
+ ? tabValues.findIndex(item => item.value === defaultValue)
122
+ : -1;
123
+ const initialActiveIndex =
124
+ defaultValueIndex === -1 ? (defaultIndex ?? 0) : defaultValueIndex;
125
+
126
+ const [activeIndex, setActiveIndex] = useState(initialActiveIndex);
127
+
128
+ const [storageIndex, setStorageIndex] = useStorageValue<string>(
129
+ `${groupIdPrefix}${groupId}`,
130
+ initialActiveIndex.toString(),
131
+ );
132
+
119
133
  if (import.meta.env.SSG_MD) {
120
134
  return (
121
135
  <>
@@ -132,20 +146,6 @@ export const Tabs = forwardRef(
132
146
  );
133
147
  }
134
148
 
135
- const defaultValueIndex =
136
- defaultValue !== undefined
137
- ? tabValues.findIndex(item => item.value === defaultValue)
138
- : -1;
139
- const initialActiveIndex =
140
- defaultValueIndex === -1 ? (defaultIndex ?? 0) : defaultValueIndex;
141
-
142
- const [activeIndex, setActiveIndex] = useState(initialActiveIndex);
143
-
144
- const [storageIndex, setStorageIndex] = useStorageValue<string>(
145
- `${groupIdPrefix}${groupId}`,
146
- initialActiveIndex.toString(),
147
- );
148
-
149
149
  const currentIndex: number = groupId ? Number(storageIndex) : activeIndex;
150
150
 
151
151
  return (
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { PluginDriver } from "./node/PluginDriver.js";
2
- export { RSPRESS_TEMP_DIR, getIconUrlPath, getNodeAttribute, getSidebarDataGroup, logger, matchPath, mergeDocConfig, normalizeHref, normalizePosixPath, removeTrailingSlash, withBase, withSiteOrigin } from "./102~0.js";
2
+ export { RSPRESS_TEMP_DIR, getIconUrlPath, getNodeAttribute, getSidebarDataGroup, logger, matchPath, mergeDocConfig, normalizeHref, normalizePosixPath, removeTrailingSlash, withBase, withSiteOrigin } from "./t2~0.js";
3
3
  export { RouteService } from "./node/route/RouteService.js";
4
4
  export { build } from "./node/build.js";
5
5
  export { defineConfig } from "./config/defineConfig.js";
@@ -4,9 +4,9 @@ type RspressPluginHookKeys = 'beforeBuild' | 'config' | 'afterBuild' | 'addPages
4
4
  export declare class PluginDriver {
5
5
  #private;
6
6
  haveNavSidebarConfig: boolean;
7
+ static create(config: UserConfig, isProd: boolean): Promise<PluginDriver>;
7
8
  static create(config: UserConfig, configFilePath: string, isProd: boolean): Promise<PluginDriver>;
8
9
  private constructor();
9
- getConfigFilePath(): string;
10
10
  init(): Promise<void>;
11
11
  addPlugin(plugin: RspressPlugin): void;
12
12
  getPlugins(): RspressPlugin[];
@@ -1,26 +1,22 @@
1
- import { addTrailingSlash, node_path, addLeadingSlash } from "../2711~0.js";
1
+ import { addTrailingSlash, node_path, addLeadingSlash } from "../o~0.js";
2
2
  import { createError } from "./utils/error.js";
3
3
  import { haveNavSidebarConfig as auto_nav_sidebar_haveNavSidebarConfig } from "./auto-nav-sidebar/index.js";
4
4
  class PluginDriver {
5
5
  #config;
6
- #configFilePath;
7
6
  #plugins;
8
7
  #isProd;
9
8
  haveNavSidebarConfig = false;
10
- static async create(config, configFilePath, isProd) {
11
- const pluginDriver = new PluginDriver(config, configFilePath, isProd);
9
+ static async create(config, configFilePathOrIsProd, isProd = false) {
10
+ if ('boolean' == typeof configFilePathOrIsProd) isProd = configFilePathOrIsProd;
11
+ const pluginDriver = new PluginDriver(config, isProd);
12
12
  await pluginDriver.init();
13
13
  return pluginDriver;
14
14
  }
15
- constructor(config, configFilePath, isProd){
15
+ constructor(config, isProd){
16
16
  this.#config = config;
17
- this.#configFilePath = configFilePath;
18
17
  this.#isProd = isProd;
19
18
  this.#plugins = [];
20
19
  }
21
- getConfigFilePath() {
22
- return this.#configFilePath;
23
- }
24
20
  async init() {
25
21
  this.clearPlugins();
26
22
  const config = this.#config;
@@ -1,4 +1,4 @@
1
- import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../2711~0.js";
1
+ import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../o~0.js";
2
2
  import { processLocales, combineWalkResult } from "./locales.js";
3
3
  import { walk } from "./walk.js";
4
4
  async function runAutoNavSide(config, metaFileSet, mdFileSet) {
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../2711~0.js";
1
+ import { node_path } from "../../o~0.js";
2
2
  import { walk } from "./walk.js";
3
3
  function combineWalkResult(walks, versions) {
4
4
  return walks.reduce((acc, cur, curIndex)=>({
@@ -1,12 +1,12 @@
1
- import { __webpack_require__ } from "../../rslib-runtime~0.js";
2
- import "../../4538~0.js";
3
- import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../2711~0.js";
1
+ import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
2
+ import "../../t~0.js";
3
+ import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../o~0.js";
4
4
  import { createError } from "../utils/error.js";
5
5
  import { pathExists, extractInfoFromFrontmatterWithAbsolutePath, readJson } from "./utils.js";
6
6
  import { absolutePathToRoutePath, addRoutePrefix } from "../route/RoutePage.js";
7
7
  import { RouteService } from "../route/RouteService.js";
8
- const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
9
- var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
8
+ const picocolors = rspackRequire("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
9
+ var picocolors_default = /*#__PURE__*/ compatGetDefaultExport(picocolors);
10
10
  const AUTO_NAV_SIDEBAR_ERROR_PREFIX = '[auto-nav-sidebar] ';
11
11
  function getFileKey(realPath, docsDir) {
12
12
  return realPath ? slash(external_node_path_relative(docsDir, realPath).replace(extname(realPath), '')) : '';
@@ -168,7 +168,7 @@ async function metaDirItemToSidebarItem(metaItem, workDir, docsDir, extensions,
168
168
  context: metaJsonContext,
169
169
  _fileKey: getFileKey(dirAbsolutePath, docsDir)
170
170
  };
171
- {
171
+ else {
172
172
  const indexFile = await metaFileItemToSidebarItem('index', dirAbsolutePath, docsDir, extensions, mdFileSet);
173
173
  if (!indexFile) return {
174
174
  text: label || name,
@@ -1,4 +1,4 @@
1
- import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../2711~0.js";
1
+ import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../o~0.js";
2
2
  import { createError } from "../utils/error.js";
3
3
  async function pathExists(path) {
4
4
  try {
@@ -1,4 +1,4 @@
1
- import { isExternalUrl, node_path, promises } from "../../2711~0.js";
1
+ import { isExternalUrl, node_path, promises } from "../../o~0.js";
2
2
  import { pathExists } from "../utils/fs.js";
3
3
  import { readJson } from "./utils.js";
4
4
  import { addRoutePrefix } from "../route/RoutePage.js";
@@ -1,8 +1,9 @@
1
+ import type { LoadConfigResult } from '@rsbuild/core';
1
2
  import type { UserConfig } from '@rspress/shared';
2
3
  interface BuildOptions {
3
4
  docDirectory: string;
4
- config: UserConfig;
5
- configFilePath: string;
5
+ config: UserConfig | LoadConfigResult<UserConfig>;
6
+ configFilePath?: string;
6
7
  }
7
8
  export declare function build(options: BuildOptions): Promise<void>;
8
9
  export {};
@@ -1,3 +1,4 @@
1
+ import { normalizeConfigResult } from "../config/loadConfigFile.js";
1
2
  import { PluginDriver } from "./PluginDriver.js";
2
3
  import { RouteService } from "./route/RouteService.js";
3
4
  import { modifyConfigWithAutoNavSide } from "./auto-nav-sidebar/index.js";
@@ -5,8 +6,10 @@ import { initRsbuild } from "./initRsbuild.js";
5
6
  import { checkLanguageParity } from "./utils/checkLanguageParity.js";
6
7
  import { hintSSGFalse } from "./logger/hint.js";
7
8
  async function build(options) {
8
- const { docDirectory, config, configFilePath } = options;
9
- const pluginDriver = await PluginDriver.create(config, configFilePath, true);
9
+ const { docDirectory } = options;
10
+ const configResult = normalizeConfigResult(options.config, options.configFilePath);
11
+ const { content: config } = configResult;
12
+ const pluginDriver = await PluginDriver.create(configResult.content, true);
10
13
  const modifiedConfig = await pluginDriver.modifyConfig();
11
14
  const enableSSG = Boolean((modifiedConfig.ssg || modifiedConfig.llms) ?? true);
12
15
  const additionalPages = await pluginDriver.addPages();
@@ -20,7 +23,10 @@ async function build(options) {
20
23
  await modifyConfigWithAutoNavSide(modifiedConfig);
21
24
  try {
22
25
  await pluginDriver.beforeBuild();
23
- const rsbuild = await initRsbuild(docDirectory, modifiedConfig, pluginDriver, routeService, enableSSG);
26
+ const rsbuild = await initRsbuild(docDirectory, {
27
+ ...configResult,
28
+ content: modifiedConfig
29
+ }, pluginDriver, routeService, enableSSG);
24
30
  await rsbuild.build();
25
31
  } finally{
26
32
  await checkLanguageParity(config);
@@ -1,4 +1,4 @@
1
- import { isDarkModeSwitchEnabled, node_path, package_namespaceObject, getDefaultDarkModeValue, createRequire } from "../8472~0.js";
1
+ import { isDarkModeSwitchEnabled, node_path, package_namespaceObject, getDefaultDarkModeValue, createRequire } from "../v~0.js";
2
2
  const constants_require = createRequire(import.meta.url);
3
3
  const RSPRESS_VERSION = package_namespaceObject.rE;
4
4
  const APPEARANCE_KEY = 'rspress-theme-appearance';
@@ -1,13 +1,13 @@
1
- import type { RestartFn, RsbuildConfig } from '@rsbuild/core';
1
+ import type { LoadConfigResult, RestartFn, RsbuildConfig } from '@rsbuild/core';
2
2
  import type { UserConfig } from '@rspress/shared';
3
3
  interface ServerInstance {
4
4
  close: () => Promise<void>;
5
5
  }
6
6
  interface DevOptions {
7
- appDirectory: string;
7
+ appDirectory?: string;
8
8
  docDirectory: string;
9
- config: UserConfig;
10
- configFilePath: string;
9
+ config: UserConfig | LoadConfigResult<UserConfig>;
10
+ configFilePath?: string;
11
11
  extraBuilderConfig?: RsbuildConfig;
12
12
  restart?: RestartFn;
13
13
  }
package/dist/node/dev.js CHANGED
@@ -1,12 +1,12 @@
1
+ import { normalizeConfigResult } from "../config/loadConfigFile.js";
1
2
  import { PluginDriver } from "./PluginDriver.js";
2
3
  import { RouteService } from "./route/RouteService.js";
3
4
  import { initRsbuild } from "./initRsbuild.js";
4
5
  import { checkLanguageParity } from "./utils/checkLanguageParity.js";
5
6
  async function dev(options) {
6
- const { docDirectory, config, extraBuilderConfig, configFilePath, restart } = options;
7
- const configFileMeta = config._privateMeta;
8
- const isProd = false;
9
- const pluginDriver = await PluginDriver.create(config, configFilePath, isProd);
7
+ const { docDirectory, extraBuilderConfig, restart } = options;
8
+ const configResult = normalizeConfigResult(options.config, options.configFilePath);
9
+ const pluginDriver = await PluginDriver.create(configResult.content, false);
10
10
  const modifiedConfig = await pluginDriver.modifyConfig();
11
11
  try {
12
12
  const additionalPages = await pluginDriver.addPages();
@@ -18,8 +18,10 @@ async function dev(options) {
18
18
  await pluginDriver.routeGenerated(routeService.getRoutes());
19
19
  await pluginDriver.routeServiceGenerated(routeService);
20
20
  await pluginDriver.beforeBuild();
21
- const rsbuild = await initRsbuild(docDirectory, modifiedConfig, pluginDriver, routeService, false, {
22
- configFileMeta,
21
+ const rsbuild = await initRsbuild(docDirectory, {
22
+ ...configResult,
23
+ content: modifiedConfig
24
+ }, pluginDriver, routeService, false, {
23
25
  extraRsbuildConfig: extraBuilderConfig,
24
26
  restart
25
27
  });
@@ -1,9 +1,9 @@
1
- import { __webpack_require__ } from "../rslib-runtime~0.js";
2
- import "../4538~0.js";
3
- import { node_path, logger, promises } from "../2711~0.js";
1
+ import { rspackRequire, compatGetDefaultExport } from "../rslib-runtime~0.js";
2
+ import "../t~0.js";
3
+ import { node_path, logger, promises } from "../o~0.js";
4
4
  import { EJECTED_THEME } from "./constants.js";
5
- const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6
- var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
5
+ const picocolors = rspackRequire("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6
+ var picocolors_default = /*#__PURE__*/ compatGetDefaultExport(picocolors);
7
7
  let _themeComponentsPathOverride;
8
8
  function getThemeComponentsPath() {
9
9
  if (_themeComponentsPathOverride) return _themeComponentsPathOverride;
@@ -1,9 +1,8 @@
1
- import type { RestartFn, RsbuildConfig, RsbuildInstance } from '@rsbuild/core';
1
+ import type { LoadConfigResult, RestartFn, RsbuildConfig, RsbuildInstance } from '@rsbuild/core';
2
2
  import { type UserConfig } from '@rspress/shared';
3
3
  import type { PluginDriver } from './PluginDriver.js';
4
4
  import type { RouteService } from './route/RouteService.js';
5
- export declare function initRsbuild(rootDir: string, config: UserConfig, pluginDriver: PluginDriver, routeService: RouteService, enableSSG: boolean, options?: {
6
- configFileMeta?: RsbuildConfig['_privateMeta'];
5
+ export declare function initRsbuild(rootDir: string, configResult: LoadConfigResult<UserConfig>, pluginDriver: PluginDriver, routeService: RouteService, enableSSG: boolean, options?: {
7
6
  extraRsbuildConfig?: RsbuildConfig;
8
7
  restart?: RestartFn;
9
8
  }): Promise<RsbuildInstance>;
@@ -1,4 +1,4 @@
1
- import { external_node_process_cwd, node_path, fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, removeTrailingSlash, normalizeDarkMode, pluginVirtualModule, pluginReact, createRequire, MDX_OR_MD_REGEXP } from "../2711~0.js";
1
+ import { external_node_process_cwd, node_path, fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, removeTrailingSlash, normalizeDarkMode, pluginVirtualModule, pluginReact, createRequire, MDX_OR_MD_REGEXP } from "../o~0.js";
2
2
  import { createError } from "./utils/error.js";
3
3
  import { CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, NODE_SSG_BUNDLE_FOLDER, getInlineLocaleRedirectScript, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, getInlineThemeScript, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
4
4
  import { isLlmsUIEnabled, isLlmsHintEnabled } from "./llms.js";
@@ -16,7 +16,7 @@ import { siteDataVMPlugin } from "./runtimeModule/siteData/rsbuildPlugin.js";
16
16
  import { rsbuildPluginSSG } from "./ssg/rsbuildPluginSSG.js";
17
17
  import { rsbuildPluginCSR } from "./ssg/rsbuildPluginCSR.js";
18
18
  import { rsbuildPluginSSGMD } from "./ssg-md/rsbuildPluginSSGMD.js";
19
- import { package_namespaceObject } from "../8472~0.js";
19
+ import { package_namespaceObject } from "../v~0.js";
20
20
  function isPluginIncluded(config, pluginName) {
21
21
  return Boolean(config.builderConfig?.plugins?.some((plugin)=>plugin && plugin.name === pluginName));
22
22
  }
@@ -197,8 +197,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
197
197
  ...'false' !== process.env.RSPRESS_PERSISTENT_CACHE ? {
198
198
  buildCache: {
199
199
  buildDependencies: [
200
- fileURLToPath(import.meta.url),
201
- pluginDriver.getConfigFilePath()
200
+ fileURLToPath(import.meta.url)
202
201
  ],
203
202
  cacheDigest: [
204
203
  routeService.generateRoutesCode(),
@@ -376,17 +375,20 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
376
375
  }
377
376
  };
378
377
  }
379
- async function initRsbuild(rootDir, config, pluginDriver, routeService, enableSSG, options = {}) {
378
+ async function initRsbuild(rootDir, configResult, pluginDriver, routeService, enableSSG, options = {}) {
379
+ const { content: config } = configResult;
380
380
  const userDocRoot = node_path.resolve(rootDir || config.root);
381
381
  hintBuilderPluginsBreakingChange(config);
382
382
  const { createRsbuild, mergeRsbuildConfig } = await import("@rsbuild/core");
383
383
  const internalRsbuildConfig = await createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, options.restart);
384
384
  const rsbuildConfig = mergeRsbuildConfig(internalRsbuildConfig, ...pluginDriver.getPlugins()?.map((plugin)=>plugin.builderConfig ?? {}) || [], config.builderConfig || {}, options.extraRsbuildConfig || {});
385
- if (options.configFileMeta) rsbuildConfig._privateMeta = options.configFileMeta;
386
385
  const rsbuild = await createRsbuild({
387
386
  callerName: 'rspress',
388
387
  restart: options.restart,
389
- rsbuildConfig
388
+ config: {
389
+ ...configResult,
390
+ content: rsbuildConfig
391
+ }
390
392
  });
391
393
  return rsbuild;
392
394
  }
@@ -1,5 +1,5 @@
1
- import { node_path, execa } from "../../864~0.js";
2
- import { slash } from "../utils/normalizePath.js";
1
+ import { node_path, execa } from "../../n~0.js";
2
+ import { slash } from "../utils/slash.js";
3
3
  function transform(timestamp, lang) {
4
4
  return new Date(timestamp).toLocaleString(lang || 'zh');
5
5
  }
@@ -1,8 +1,8 @@
1
- import { __webpack_require__ } from "../../rslib-runtime~0.js";
2
- import { relative, logger, join, readFile } from "../../4538~0.js";
1
+ import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
2
+ import { relative, logger, join, readFile } from "../../t~0.js";
3
3
  import { pathExists } from "../utils/fs.js";
4
- const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
5
- var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
4
+ const picocolors = rspackRequire("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
5
+ var picocolors_default = /*#__PURE__*/ compatGetDefaultExport(picocolors);
6
6
  const THEME_DEFAULT_EXPORT_PATTERN = /export\s+default\s+\{/;
7
7
  const THEME_OLD_IMPORT_0 = /from\s+['"]rspress\/theme['"]/;
8
8
  const THEME_OLD_IMPORT_1 = /from\s+['"]@rspress\/core\/theme['"]/;
@@ -1,4 +1,4 @@
1
- import { node_path, rehype_external_links, rehype_raw, remark_cjk_friendly, nodeTypes, remark_gfm, rehype, remark_cjk_friendly_gfm_strikethrough } from "../../9940~0.js";
1
+ import { node_path, rehype_external_links, rehype_raw, remark_cjk_friendly, nodeTypes, remark_gfm, rehype, remark_cjk_friendly_gfm_strikethrough } from "../../tx~0.js";
2
2
  import { remarkToc } from "./remarkPlugins/toc.js";
3
3
  import { remarkContainerSyntax } from "./remarkPlugins/containerSyntax.js";
4
4
  import { remarkFileCodeBlock } from "./remarkPlugins/fileCodeBlock.js";
@@ -1,8 +1,8 @@
1
- import { node_path, extractTextAndId, createProcessor, loadFrontMatter } from "../../9940~0.js";
1
+ import { node_path, extractTextAndId, createProcessor, loadFrontMatter } from "../../tx~0.js";
2
2
  import { createMDXOptions } from "./options.js";
3
3
  import { applyReplaceRules } from "../utils/applyReplaceRules.js";
4
4
  import { escapeMarkdownHeadingIds } from "../utils/escapeHeadingIds.js";
5
- import { normalizePath } from "../utils/normalizePath.js";
5
+ import { slash } from "../utils/slash.js";
6
6
  import { createError } from "../utils/error.js";
7
7
  async function compile(options) {
8
8
  const { source, filepath, docDirectory, config, routeService, pluginDriver, addDependency, isSsgMd = false } = options;
@@ -49,7 +49,7 @@ async function compile(options) {
49
49
  const result = `${compileResult}
50
50
 
51
51
  MDXContent.__RSPRESS_PAGE_META = {};
52
- MDXContent.__RSPRESS_PAGE_META["${encodeURIComponent(normalizePath(node_path.relative(docDirectory, filepath)))}"] = ${JSON.stringify(pageMeta)};
52
+ MDXContent.__RSPRESS_PAGE_META["${encodeURIComponent(slash(node_path.relative(docDirectory, filepath)))}"] = ${JSON.stringify(pageMeta)};
53
53
  `;
54
54
  return result;
55
55
  } catch (e) {
@@ -1,4 +1,4 @@
1
- import { visit } from "../../../9940~0.js";
1
+ import { visit } from "../../../tx~0.js";
2
2
  const rehypeCodeMeta = ()=>(tree)=>{
3
3
  visit(tree, 'element', (node)=>{
4
4
  if ('pre' === node.tagName && node.children[0]?.type === 'element' && 'code' === node.children[0].tagName) {
@@ -1,4 +1,4 @@
1
- import { visit, extractTextAndId, github_slugger, headingRank } from "../../../9940~0.js";
1
+ import { visit, extractTextAndId, github_slugger, headingRank } from "../../../tx~0.js";
2
2
  const rehypeHeaderAnchor = ()=>{
3
3
  const slugger = new github_slugger();
4
4
  return (tree)=>{
@@ -1,4 +1,4 @@
1
- import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddFold, createCssVariablesTheme, transformerAddWrapCode } from "../../../9940~0.js";
1
+ import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddFold, createCssVariablesTheme, transformerAddWrapCode } from "../../../tx~0.js";
2
2
  const cssVariablesTheme = createCssVariablesTheme({
3
3
  name: 'css-variables',
4
4
  variablePrefix: '--shiki-',
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../../9940~0.js";
1
+ import { node_path } from "../../../tx~0.js";
2
2
  import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
3
3
  const remarkBuiltin = ({ globalComponents })=>(tree)=>{
4
4
  const demos = globalComponents.map((componentPath)=>{
@@ -170,12 +170,13 @@ function transformer(tree, warnUnknownType) {
170
170
  const newChild = createContainer(type, title, wrappedChildren);
171
171
  tree.children.splice(i, j - i + 1, newChild);
172
172
  break;
173
+ } else {
174
+ wrappedChildren.push({
175
+ ...currentParagraph,
176
+ children: currentParagraph.children.filter((child)=>child !== firstTextNode)
177
+ });
178
+ j++;
173
179
  }
174
- wrappedChildren.push({
175
- ...currentParagraph,
176
- children: currentParagraph.children.filter((child)=>child !== firstTextNode)
177
- });
178
- j++;
179
180
  }
180
181
  }
181
182
  i++;
@@ -1,9 +1,9 @@
1
- import { __webpack_require__ } from "../../../rslib-runtime~0.js";
2
- import "../../../4538~0.js";
3
- import { visit, node_path, logger, cwd, readFile } from "../../../5357~0.js";
1
+ import { rspackRequire, compatGetDefaultExport } from "../../../rslib-runtime~0.js";
2
+ import "../../../t~0.js";
3
+ import { visit, node_path, logger, cwd, readFile } from "../../../r~0.js";
4
4
  import { createError } from "../../utils/error.js";
5
- const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6
- var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
5
+ const picocolors = rspackRequire("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6
+ var picocolors_default = /*#__PURE__*/ compatGetDefaultExport(picocolors);
7
7
  const ERROR_PREFIX = '[remarkFileCodeBlock]';
8
8
  function parseFileFromMeta(meta) {
9
9
  if (!meta) return '';
@@ -1,10 +1,10 @@
1
- import { __webpack_require__ } from "../../../rslib-runtime~0.js";
2
- import "../../../4538~0.js";
3
- import { visit, node_path, logger, isDataUrl, existsSync, getNodeAttribute, isExternalUrl, isProduction, parseUrl } from "../../../5357~0.js";
1
+ import { rspackRequire, compatGetDefaultExport } from "../../../rslib-runtime~0.js";
2
+ import "../../../t~0.js";
3
+ import { visit, node_path, logger, isDataUrl, existsSync, getNodeAttribute, isExternalUrl, isProduction, parseUrl } from "../../../r~0.js";
4
4
  import { createError } from "../../utils/error.js";
5
5
  import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
6
- const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
7
- var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
6
+ const picocolors = rspackRequire("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
7
+ var picocolors_default = /*#__PURE__*/ compatGetDefaultExport(picocolors);
8
8
  const normalizeImageUrl = (imageUrl)=>{
9
9
  if (isExternalUrl(imageUrl) || imageUrl.startsWith('/')) return '';
10
10
  return imageUrl;