@rspress/core 2.0.8 → 2.0.10

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 (127) hide show
  1. package/dist/0~execa.js +8 -8
  2. package/dist/0~rslib-runtime.js +20 -0
  3. package/dist/0~tinypool.js +828 -0
  4. package/dist/{8311.js → 1688.js} +1 -7
  5. package/dist/{7397.js → 2240.js} +4 -2
  6. package/dist/2287.js +2458 -0
  7. package/dist/{1361.js → 3294.js} +1 -1
  8. package/dist/{1965.js → 3425.js} +0 -1
  9. package/dist/8006.js +77 -0
  10. package/dist/8857.js +4826 -0
  11. package/dist/8857.js.LICENSE.txt +41 -0
  12. package/dist/cli/index.js +14 -7
  13. package/dist/config/loadConfigFile.js +1 -1
  14. package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.scss +1 -1
  15. package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.tsx +17 -21
  16. package/dist/eject-theme/components/CodeButtonGroup/index.scss +1 -1
  17. package/dist/eject-theme/components/DocContent/doc.scss +16 -41
  18. package/dist/eject-theme/components/FallbackHeading/index.tsx +1 -1
  19. package/dist/eject-theme/components/Link/useLinkNavigate.ts +4 -1
  20. package/dist/eject-theme/components/Llms/LlmsCopyButton.scss +3 -3
  21. package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +13 -6
  22. package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +13 -5
  23. package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +7 -3
  24. package/dist/eject-theme/components/Outline/index.scss +1 -1
  25. package/dist/eject-theme/components/Prompt/icons.tsx +80 -0
  26. package/dist/eject-theme/components/Prompt/index.scss +478 -0
  27. package/dist/eject-theme/components/Prompt/index.tsx +335 -0
  28. package/dist/eject-theme/components/Search/SearchPanel.tsx +1 -1
  29. package/dist/eject-theme/components/SidebarMenu/index.tsx +5 -1
  30. package/dist/eject-theme/components/Steps/index.scss +32 -13
  31. package/dist/node/PluginDriver.js +1 -1
  32. package/dist/node/auto-nav-sidebar/index.js +1 -1
  33. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  34. package/dist/node/auto-nav-sidebar/normalize.js +10 -6
  35. package/dist/node/auto-nav-sidebar/utils.js +8 -2
  36. package/dist/node/auto-nav-sidebar/walk.js +2 -8
  37. package/dist/node/constants.js +1 -1
  38. package/dist/node/eject.js +12 -7
  39. package/dist/node/initRsbuild.js +6 -6
  40. package/dist/node/logger/hint.js +9 -6
  41. package/dist/node/mdx/options.js +13 -2
  42. package/dist/node/mdx/processor.js +1 -1
  43. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  44. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
  45. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  46. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  47. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +6 -2
  48. package/dist/node/mdx/remarkPlugins/image.d.ts +7 -2
  49. package/dist/node/mdx/remarkPlugins/image.js +51 -2
  50. package/dist/node/mdx/remarkPlugins/link.js +7 -3
  51. package/dist/node/mdx/remarkPlugins/toc.js +1 -1
  52. package/dist/node/route/RoutePage.js +1 -1
  53. package/dist/node/route/RouteService.js +1 -1
  54. package/dist/node/route/extractPageData.js +75 -26
  55. package/dist/node/route/normalizeRoutePath.js +1 -1
  56. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +28 -0
  57. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +28 -0
  58. package/dist/node/runtimeModule/i18n.js +10 -6
  59. package/dist/node/runtimeModule/pageData/createPageData.js +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 +8 -4
  67. package/dist/node/ssg/renderPageWorker.js +1 -1
  68. package/dist/node/ssg/renderPages.js +9 -5
  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 +8 -4
  75. package/dist/node/ssg-md/renderPages.js +7 -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 +5 -2
  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 +7 -3
  85. package/dist/runtime/App.js +4 -1
  86. package/dist/runtime/index.d.ts +2 -1
  87. package/dist/runtime/index.js +2 -1
  88. package/dist/runtime/initPageData.d.ts +3 -0
  89. package/dist/runtime/initPageData.js +37 -2
  90. package/dist/runtime/ssrClientEntry.js +4 -2
  91. package/dist/theme/assets/success.js +1 -1
  92. package/dist/theme/assets/wrapped.js +1 -1
  93. package/dist/theme/components/CodeButtonGroup/CopyCodeButton.css +1 -1
  94. package/dist/theme/components/CodeButtonGroup/CopyCodeButton.js +14 -12
  95. package/dist/theme/components/CodeButtonGroup/index.css +1 -1
  96. package/dist/theme/components/DocContent/doc.css +14 -21
  97. package/dist/theme/components/FallbackHeading/index.js +1 -1
  98. package/dist/theme/components/Link/useLinkNavigate.js +3 -2
  99. package/dist/theme/components/Llms/LlmsCopyButton.css +5 -5
  100. package/dist/theme/components/Llms/LlmsCopyButton.js +5 -6
  101. package/dist/theme/components/Llms/LlmsCopyRow.js +5 -5
  102. package/dist/theme/components/Llms/LlmsViewOptions.js +1 -3
  103. package/dist/theme/components/Outline/index.css +1 -1
  104. package/dist/theme/components/Prompt/icons.d.ts +10 -0
  105. package/dist/theme/components/Prompt/icons.js +64 -0
  106. package/dist/theme/components/Prompt/index.css +352 -0
  107. package/dist/theme/components/Prompt/index.d.ts +33 -0
  108. package/dist/theme/components/Prompt/index.js +262 -0
  109. package/dist/theme/components/Search/SearchPanel.js +1 -1
  110. package/dist/theme/components/SidebarMenu/index.js +2 -1
  111. package/dist/theme/components/Steps/index.css +23 -12
  112. package/dist/theme/index.d.ts +3 -0
  113. package/dist/theme/index.js +3 -0
  114. package/dist/theme/layout/DocLayout/index.css +5 -1
  115. package/dist/theme/layout/DocLayout/index.js +8 -4
  116. package/dist/theme/logic/copyToClipboard.d.ts +1 -0
  117. package/dist/theme/{components/Llms/copy.js → logic/copyToClipboard.js} +4 -3
  118. package/dist/theme/logic/getCopyableText.d.ts +5 -0
  119. package/dist/theme/logic/getCopyableText.js +52 -0
  120. package/dist/theme/logic/useThemeState.js +1 -1
  121. package/dist/theme/styles/vars/base-vars.css +4 -4
  122. package/package.json +20 -23
  123. package/dist/4454.js +0 -8
  124. package/dist/7319.js +0 -88
  125. package/dist/8885.js +0 -4
  126. package/dist/eject-theme/components/Llms/copy.ts +0 -12
  127. package/dist/theme/components/Llms/copy.d.ts +0 -1
@@ -0,0 +1,262 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useI18n } from "@rspress/core/runtime";
3
+ import { IconArrowDown, IconCopy, IconSuccess, SvgWrapper, copyToClipboard, renderInlineMarkdown } from "@rspress/core/theme";
4
+ import clsx from "clsx";
5
+ import { useCallback, useEffect, useId, useRef, useState } from "react";
6
+ import { AGENT_ICONS } from "./icons.js";
7
+ import "./index.css";
8
+ const ROTATE_INTERVAL = 3500;
9
+ const FADE_DURATION = 400;
10
+ function RotatingIcon({ index, fading }) {
11
+ return /*#__PURE__*/ jsx("span", {
12
+ className: clsx('rp-prompt__icon', fading && 'rp-prompt__icon--fade-out'),
13
+ title: AGENT_ICONS[index].name,
14
+ children: AGENT_ICONS[index].svg
15
+ });
16
+ }
17
+ function useRotatingIcon() {
18
+ const [iconIndex, setIconIndex] = useState(0);
19
+ const [fading, setFading] = useState(false);
20
+ const rotateTimeoutRef = useRef(null);
21
+ useEffect(()=>{
22
+ const timer = setInterval(()=>{
23
+ setFading(true);
24
+ rotateTimeoutRef.current = setTimeout(()=>{
25
+ setIconIndex((prev)=>(prev + 1) % AGENT_ICONS.length);
26
+ setFading(false);
27
+ rotateTimeoutRef.current = null;
28
+ }, FADE_DURATION);
29
+ }, ROTATE_INTERVAL);
30
+ return ()=>{
31
+ clearInterval(timer);
32
+ if (rotateTimeoutRef.current) clearTimeout(rotateTimeoutRef.current);
33
+ };
34
+ }, []);
35
+ return {
36
+ fading,
37
+ iconIndex
38
+ };
39
+ }
40
+ function CustomPrompt({ children, className, defaultCollapsed: _defaultCollapsed, description: _description, eyebrow = 'For your Agent', prompt: _prompt, style, title: _title, ...props }) {
41
+ const { fading, iconIndex } = useRotatingIcon();
42
+ return /*#__PURE__*/ jsxs("div", {
43
+ ...props,
44
+ className: clsx('rp-prompt', 'rp-prompt--custom', className),
45
+ style: {
46
+ '--rp-prompt-accent': AGENT_ICONS[iconIndex].color,
47
+ ...style
48
+ },
49
+ children: [
50
+ /*#__PURE__*/ jsx("div", {
51
+ className: "rp-prompt__backdrop"
52
+ }),
53
+ /*#__PURE__*/ jsxs("div", {
54
+ className: "rp-prompt__panel",
55
+ children: [
56
+ /*#__PURE__*/ jsx("div", {
57
+ className: "rp-prompt__meta",
58
+ children: /*#__PURE__*/ jsxs("span", {
59
+ className: "rp-prompt__eyebrow",
60
+ children: [
61
+ /*#__PURE__*/ jsx(RotatingIcon, {
62
+ index: iconIndex,
63
+ fading: fading
64
+ }),
65
+ eyebrow
66
+ ]
67
+ })
68
+ }),
69
+ /*#__PURE__*/ jsx("div", {
70
+ className: "rp-prompt__custom-content",
71
+ children: children
72
+ })
73
+ ]
74
+ })
75
+ ]
76
+ });
77
+ }
78
+ function CopyablePrompt({ className, defaultCollapsed = true, description, eyebrow = 'For your Agent', onClick, prompt, style, title = 'Agent Prompt', ...props }) {
79
+ const t = useI18n();
80
+ const contentId = useId();
81
+ const [collapsed, setCollapsed] = useState(defaultCollapsed);
82
+ const [copied, setCopied] = useState(false);
83
+ const { fading, iconIndex } = useRotatingIcon();
84
+ const [ripples, setRipples] = useState([]);
85
+ const cardRef = useRef(null);
86
+ const copyTimerRef = useRef(null);
87
+ const rippleTimersRef = useRef(new Set());
88
+ useEffect(()=>()=>{
89
+ copyTimerRef.current && clearTimeout(copyTimerRef.current);
90
+ rippleTimersRef.current.forEach(clearTimeout);
91
+ rippleTimersRef.current.clear();
92
+ }, []);
93
+ const handleCopy = useCallback(async ()=>{
94
+ if (!prompt) return;
95
+ const isCopied = await copyToClipboard(prompt);
96
+ if (!isCopied) return;
97
+ setCopied(true);
98
+ if (copyTimerRef.current) clearTimeout(copyTimerRef.current);
99
+ copyTimerRef.current = setTimeout(()=>{
100
+ setCopied(false);
101
+ copyTimerRef.current = null;
102
+ }, 2000);
103
+ }, [
104
+ prompt
105
+ ]);
106
+ const handleCardActivate = useCallback((e)=>{
107
+ onClick?.(e);
108
+ if (e.defaultPrevented) return;
109
+ if (window.getSelection()?.toString()) return;
110
+ const target = e.target;
111
+ if (target.closest('a, button, .rp-prompt__action-copy, .rp-prompt__action-toggle')) return;
112
+ const rect = cardRef.current?.getBoundingClientRect();
113
+ if (!rect) return;
114
+ const id = Date.now() + Math.random();
115
+ setRipples((prev)=>[
116
+ ...prev,
117
+ {
118
+ id,
119
+ x: e.clientX - rect.left,
120
+ y: e.clientY - rect.top
121
+ }
122
+ ]);
123
+ const timer = setTimeout(()=>{
124
+ setRipples((prev)=>prev.filter((r)=>r.id !== id));
125
+ rippleTimersRef.current.delete(timer);
126
+ }, 600);
127
+ rippleTimersRef.current.add(timer);
128
+ handleCopy();
129
+ }, [
130
+ handleCopy,
131
+ onClick
132
+ ]);
133
+ return /*#__PURE__*/ jsxs("div", {
134
+ ...props,
135
+ ref: cardRef,
136
+ className: clsx('rp-prompt', className),
137
+ style: {
138
+ '--rp-prompt-accent': AGENT_ICONS[iconIndex].color,
139
+ ...style
140
+ },
141
+ onClick: handleCardActivate,
142
+ children: [
143
+ /*#__PURE__*/ jsx("div", {
144
+ className: "rp-prompt__backdrop"
145
+ }),
146
+ ripples.map((r)=>/*#__PURE__*/ jsx("span", {
147
+ className: "rp-prompt__ripple",
148
+ style: {
149
+ left: r.x,
150
+ top: r.y
151
+ }
152
+ }, r.id)),
153
+ /*#__PURE__*/ jsxs("div", {
154
+ className: "rp-prompt__panel",
155
+ children: [
156
+ /*#__PURE__*/ jsxs("div", {
157
+ className: "rp-prompt__header",
158
+ children: [
159
+ /*#__PURE__*/ jsx("div", {
160
+ className: clsx('rp-prompt__meta', copied && 'rp-prompt__meta--copied'),
161
+ children: /*#__PURE__*/ jsxs("span", {
162
+ className: "rp-prompt__eyebrow",
163
+ children: [
164
+ /*#__PURE__*/ jsx(RotatingIcon, {
165
+ index: iconIndex,
166
+ fading: fading
167
+ }),
168
+ eyebrow
169
+ ]
170
+ })
171
+ }),
172
+ /*#__PURE__*/ jsxs("div", {
173
+ className: "rp-prompt__header-row",
174
+ children: [
175
+ /*#__PURE__*/ jsxs("div", {
176
+ className: "rp-prompt__header-left",
177
+ children: [
178
+ /*#__PURE__*/ jsx("div", {
179
+ className: "rp-prompt__title-with-icon",
180
+ children: /*#__PURE__*/ jsx("div", {
181
+ className: "rp-prompt__title",
182
+ children: title
183
+ })
184
+ }),
185
+ description ? /*#__PURE__*/ jsx("p", {
186
+ className: "rp-prompt__description",
187
+ ...renderInlineMarkdown(description)
188
+ }) : null
189
+ ]
190
+ }),
191
+ /*#__PURE__*/ jsxs("div", {
192
+ className: "rp-prompt__header-actions",
193
+ children: [
194
+ /*#__PURE__*/ jsxs("button", {
195
+ type: "button",
196
+ className: clsx('rp-prompt__action-copy', copied && 'rp-prompt__action-copy--copied'),
197
+ onClick: (e)=>{
198
+ e.stopPropagation();
199
+ handleCopy();
200
+ },
201
+ title: t('promptCopyText'),
202
+ children: [
203
+ /*#__PURE__*/ jsx(SvgWrapper, {
204
+ icon: copied ? IconSuccess : IconCopy,
205
+ className: "rp-prompt__action-icon"
206
+ }),
207
+ /*#__PURE__*/ jsx("span", {
208
+ children: copied ? t('promptCopiedText') : t('promptCopyText')
209
+ })
210
+ ]
211
+ }),
212
+ /*#__PURE__*/ jsx("button", {
213
+ type: "button",
214
+ className: "rp-prompt__action-toggle",
215
+ onClick: (e)=>{
216
+ e.stopPropagation();
217
+ setCollapsed((value)=>!value);
218
+ },
219
+ "aria-controls": contentId,
220
+ "aria-expanded": !collapsed,
221
+ title: collapsed ? t('promptExpandText') : t('promptCollapseText'),
222
+ children: /*#__PURE__*/ jsx(SvgWrapper, {
223
+ icon: IconArrowDown,
224
+ className: clsx('rp-prompt__action-toggle-icon', !collapsed && 'rp-prompt__action-toggle-icon--expanded')
225
+ })
226
+ })
227
+ ]
228
+ })
229
+ ]
230
+ })
231
+ ]
232
+ }),
233
+ /*#__PURE__*/ jsx("div", {
234
+ id: contentId,
235
+ className: clsx('rp-prompt__content', collapsed && 'rp-prompt__content--collapsed'),
236
+ "aria-hidden": collapsed,
237
+ children: /*#__PURE__*/ jsx("div", {
238
+ className: "rp-prompt__content-inner",
239
+ children: /*#__PURE__*/ jsx("div", {
240
+ className: "rp-prompt__content-body",
241
+ style: {
242
+ whiteSpace: 'pre-wrap'
243
+ },
244
+ children: prompt
245
+ })
246
+ })
247
+ })
248
+ ]
249
+ })
250
+ ]
251
+ });
252
+ }
253
+ function Prompt({ custom = false, ...props }) {
254
+ return custom ? /*#__PURE__*/ jsx(CustomPrompt, {
255
+ ...props
256
+ }) : /*#__PURE__*/ jsx(CopyablePrompt, {
257
+ ...props
258
+ });
259
+ }
260
+ var components_Prompt = Prompt;
261
+ export default components_Prompt;
262
+ export { Prompt };
@@ -1,7 +1,7 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useI18n, usePageData } from "@rspress/core/runtime";
3
3
  import { IconClose, IconLoading, IconSearch, SvgWrapper, Tab, Tabs, useLinkNavigate } from "@rspress/core/theme";
4
- import { debounce } from "lodash-es";
4
+ import { debounce } from "@rspress/shared/lodash-es";
5
5
  import { useCallback, useEffect, useRef, useState } from "react";
6
6
  import { createPortal } from "react-dom";
7
7
  import * as __rspack_external_virtual_search_hooks_9d01d01f from "virtual-search-hooks";
@@ -10,7 +10,8 @@ const SidebarMenu = /*#__PURE__*/ forwardRef(({ isSidebarOpen, onIsSidebarOpenCh
10
10
  const { pathname, hash } = useLocation();
11
11
  const headers = useDynamicToc();
12
12
  const { scrolledHeader } = useActiveAnchor(headers);
13
- const { frontmatter: { sidebar: showSidebar = true, outline: showOutline = true } } = useFrontmatter();
13
+ const { frontmatter: { sidebar: sidebarConfig = true, outline: showOutline = true } } = useFrontmatter();
14
+ const showSidebar = true === sidebarConfig;
14
15
  function openSidebar() {
15
16
  onIsSidebarOpenChange(true);
16
17
  }
@@ -1,36 +1,47 @@
1
+ :root {
2
+ --rp-steps-gap: 24px;
3
+ --rp-steps-size: 30px;
4
+ }
5
+
1
6
  .rp-steps {
2
7
  border-left: 1px solid var(--rp-c-text-3);
8
+ padding-left: var(--rp-steps-gap);
3
9
  counter-reset: step;
4
- margin-bottom: 44px;
5
- margin-left: 16px;
6
- padding-left: 24px;
10
+ margin-bottom: 2.5rem;
11
+ margin-left: 1rem;
7
12
  }
8
13
 
9
14
  .rp-steps h3 {
10
15
  counter-increment: step;
11
- margin-top: 3px;
16
+ align-items: center;
17
+ min-height: 30px;
18
+ margin-top: 0;
19
+ display: flex;
12
20
  position: relative;
13
21
  }
14
22
 
15
23
  .rp-steps h3:before {
16
24
  content: counter(step);
17
- width: 30px;
18
- height: 30px;
25
+ left: calc(-1*var(--rp-steps-gap));
26
+ width: var(--rp-steps-size);
27
+ height: var(--rp-steps-size);
28
+ line-height: var(--rp-steps-size);
19
29
  color: var(--rp-c-text-1);
20
- background-color: var(--rp-code-block-bg);
30
+ background-color: var(--rp-c-bg);
31
+ outline: 6px solid var(--rp-c-bg);
21
32
  border: 1.5px solid var(--rp-c-text-3);
22
33
  border-radius: 50%;
23
34
  justify-content: center;
24
35
  align-items: center;
25
36
  font-size: 1.1rem;
26
- font-weight: 400;
27
- line-height: 30px;
37
+ font-weight: 500;
28
38
  display: flex;
29
39
  position: absolute;
30
- left: -41px;
40
+ transform: translate(-50%);
31
41
  }
32
42
 
33
- .rp-steps p {
34
- color: var(--rp-c-text-1);
43
+ .rp-steps h3 .rp-header-anchor {
44
+ left: calc(-1*var(--rp-steps-gap) - var(--rp-steps-size)/2);
45
+ position: absolute;
35
46
  }
36
47
 
@@ -33,6 +33,7 @@ export { type Group, type GroupItem, OverviewGroup, } from './components/Overvie
33
33
  export { type PackageManagerTabProps, PackageManagerTabs, } from './components/PackageManagerTabs/index.js';
34
34
  export { PageTab, type PageTabProps, PageTabs, type PageTabsProps, } from './components/PageTabs/index.js';
35
35
  export { PrevNextPage } from './components/PrevNextPage/index.js';
36
+ export { Prompt, type PromptProps } from './components/Prompt/index.js';
36
37
  export { ReadPercent } from './components/ReadPercent/index.js';
37
38
  export { useReadPercent } from './components/ReadPercent/useReadPercent.js';
38
39
  export { Root, type RootProps } from './components/Root/index.js';
@@ -57,6 +58,8 @@ export { DocLayout, type DocLayoutProps } from './layout/DocLayout/index.js';
57
58
  export { HomeLayout, type HomeLayoutProps } from './layout/HomeLayout/index.js';
58
59
  export { Layout, type LayoutProps } from './layout/Layout/index.js';
59
60
  export { NotFoundLayout } from './layout/NotFountLayout/index.js';
61
+ export { copyToClipboard } from './logic/copyToClipboard.js';
62
+ export { getCopyableText } from './logic/getCopyableText.js';
60
63
  export { mergeRefs } from './logic/mergeRefs.js';
61
64
  export { useFullTextSearch } from './logic/useFullTextSearch.js';
62
65
  export { usePrevNextPage } from './logic/usePrevNextPage.js';
@@ -33,6 +33,7 @@ export { OverviewGroup } from "./components/OverviewGroup/index.js";
33
33
  export { PackageManagerTabs } from "./components/PackageManagerTabs/index.js";
34
34
  export { PageTab, PageTabs } from "./components/PageTabs/index.js";
35
35
  export { PrevNextPage } from "./components/PrevNextPage/index.js";
36
+ export { Prompt } from "./components/Prompt/index.js";
36
37
  export { ReadPercent } from "./components/ReadPercent/index.js";
37
38
  export { useReadPercent } from "./components/ReadPercent/useReadPercent.js";
38
39
  export { Root } from "./components/Root/index.js";
@@ -55,6 +56,8 @@ export { DocLayout } from "./layout/DocLayout/index.js";
55
56
  export { HomeLayout } from "./layout/HomeLayout/index.js";
56
57
  export { Layout } from "./layout/Layout/index.js";
57
58
  export { NotFoundLayout } from "./layout/NotFountLayout/index.js";
59
+ export { copyToClipboard } from "./logic/copyToClipboard.js";
60
+ export { getCopyableText } from "./logic/getCopyableText.js";
58
61
  export { mergeRefs } from "./logic/mergeRefs.js";
59
62
  export { useFullTextSearch } from "./logic/useFullTextSearch.js";
60
63
  export { usePrevNextPage } from "./logic/usePrevNextPage.js";
@@ -115,10 +115,14 @@
115
115
  }
116
116
 
117
117
  .rp-doc-layout__sidebar-placeholder {
118
- width: var(--rp-sidebar-width);
118
+ width: 12vw;
119
119
  margin-left: var(--rp-sidebar-margin-left);
120
120
  }
121
121
 
122
+ .rp-doc-layout__sidebar-placeholder--legacy {
123
+ width: var(--rp-sidebar-width);
124
+ }
125
+
122
126
  .rp-doc-layout__outline {
123
127
  margin-right: var(--rp-outline-margin-right);
124
128
  padding-bottom: var(--rp-content-padding-y);
@@ -8,7 +8,11 @@ function DocLayout(props) {
8
8
  const { beforeDocFooter, afterDocFooter, beforeDoc, afterDoc, beforeDocContent, afterDocContent, beforeOutline, afterOutline, beforeSidebar, afterSidebar, components } = props;
9
9
  const { frontmatter } = useFrontmatter();
10
10
  const isOverviewPage = frontmatter?.overview ?? false;
11
- const { sidebar: showSidebar = true, outline: showOutline = true, footer: showDocFooter = true, pageType } = frontmatter;
11
+ const sidebar = frontmatter?.sidebar ?? true;
12
+ const showSidebar = true === sidebar;
13
+ const showSidebarPlaceholder = false === sidebar || 'placeholder' === sidebar;
14
+ const isLegacyPlaceholder = 'placeholder' === sidebar;
15
+ const { outline: showOutline = true, footer: showDocFooter = true, pageType } = frontmatter;
12
16
  if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(Fragment, {
13
17
  children: isOverviewPage ? /*#__PURE__*/ jsx(Overview, {
14
18
  content: /*#__PURE__*/ jsx(DocContent, {
@@ -40,12 +44,12 @@ function DocLayout(props) {
40
44
  /*#__PURE__*/ jsx(Sidebar, {}),
41
45
  afterSidebar
42
46
  ]
43
- }) : /*#__PURE__*/ jsx("aside", {
44
- className: "rp-doc-layout__sidebar-placeholder",
47
+ }) : showSidebarPlaceholder ? /*#__PURE__*/ jsx("aside", {
48
+ className: clsx('rp-doc-layout__sidebar-placeholder', isLegacyPlaceholder && 'rp-doc-layout__sidebar-placeholder--legacy'),
45
49
  style: isDocWide ? {
46
50
  width: '0'
47
51
  } : {}
48
- }),
52
+ }) : null,
49
53
  isOverviewPage ? /*#__PURE__*/ jsx(Fragment, {
50
54
  children: /*#__PURE__*/ jsxs("main", {
51
55
  className: "rp-doc-layout__overview",
@@ -0,0 +1 @@
1
+ export declare function copyToClipboard(text: string): Promise<boolean>;
@@ -1,9 +1,10 @@
1
1
  import copy_to_clipboard from "copy-to-clipboard";
2
2
  async function copyToClipboard(text) {
3
- if (navigator.clipboard?.writeText) try {
3
+ if ("u" > typeof navigator && navigator.clipboard?.writeText) try {
4
4
  await navigator.clipboard.writeText(text);
5
- return;
5
+ return true;
6
6
  } catch {}
7
- copy_to_clipboard(text);
7
+ if ("u" < typeof document) return false;
8
+ return copy_to_clipboard(text);
8
9
  }
9
10
  export { copyToClipboard };
@@ -0,0 +1,5 @@
1
+ export interface GetCopyableTextOptions {
2
+ ignoreClasses?: string[];
3
+ ignoreSelectors?: string[];
4
+ }
5
+ export declare function getCopyableText(element: HTMLElement | null, options?: GetCopyableTextOptions): string;
@@ -0,0 +1,52 @@
1
+ function getCopyableText(element, options = {}) {
2
+ if (!element) return '';
3
+ const { ignoreClasses = [], ignoreSelectors = [] } = options;
4
+ const nodeFilter = element.ownerDocument.defaultView?.NodeFilter ?? NodeFilter;
5
+ const walk = element.ownerDocument.createTreeWalker(element, nodeFilter.SHOW_TEXT);
6
+ let text = '';
7
+ let node = walk.nextNode();
8
+ const markdownState = {
9
+ seenNodes: new WeakSet()
10
+ };
11
+ let previousBlock = null;
12
+ while(node){
13
+ const parentElement = node.parentElement;
14
+ const shouldIgnore = !parentElement || ignoreClasses.some((className)=>parentElement.classList.contains(className)) || ignoreSelectors.some((selector)=>parentElement.closest(selector));
15
+ if (!shouldIgnore) {
16
+ const currentBlock = getBlockElement(parentElement, element);
17
+ if ((node.previousSibling?.nodeName === 'BR' || parentElement.previousSibling?.nodeName === 'BR') && !text.endsWith('\n')) text += '\n';
18
+ if (currentBlock && previousBlock && currentBlock !== previousBlock && !text.endsWith('\n')) text += '\n';
19
+ text += toMarkdown(parentElement, markdownState);
20
+ text += node.nodeValue ?? '';
21
+ previousBlock = currentBlock;
22
+ }
23
+ node = walk.nextNode();
24
+ }
25
+ return text;
26
+ }
27
+ function getBlockElement(element, rootElement) {
28
+ const blockElement = element.closest('li, p, div, pre, blockquote');
29
+ if (!blockElement) return null;
30
+ return rootElement.contains(blockElement) ? blockElement : null;
31
+ }
32
+ function toMarkdown(node, state) {
33
+ if (node.nodeType !== Node.ELEMENT_NODE) return '';
34
+ const element = node;
35
+ const listItem = element.closest('li');
36
+ if (listItem && !state.seenNodes.has(listItem)) {
37
+ state.seenNodes.add(listItem);
38
+ return toMarkdownListItem(listItem);
39
+ }
40
+ return '';
41
+ }
42
+ function toMarkdownListItem(listItem) {
43
+ const list = listItem.parentElement;
44
+ if (!list) return '- ';
45
+ if ('OL' === list.tagName) {
46
+ const listItems = Array.from(list.children).filter((child)=>'LI' === child.tagName);
47
+ const index = listItems.indexOf(listItem);
48
+ return `${index + 1}. `;
49
+ }
50
+ return '- ';
51
+ }
52
+ export { getCopyableText };
@@ -5,7 +5,7 @@ import { useStorageValue } from "./useStorageValue.js";
5
5
  const APPEARANCE_KEY = 'rspress-theme-appearance';
6
6
  const MEDIA_QUERY = '(prefers-color-scheme: dark)';
7
7
  const applyThemeToDOM = (theme)=>{
8
- if (!document || !document.documentElement) return;
8
+ if (!document?.documentElement) return;
9
9
  const root = document.documentElement;
10
10
  root.classList.toggle('dark', 'dark' === theme);
11
11
  root.classList.toggle('rp-dark', 'dark' === theme);
@@ -11,8 +11,8 @@
11
11
  --rp-c-text-3: #3c3c3c54;
12
12
  --rp-c-text-4: #3c3c3c2e;
13
13
  --rp-c-text-code: #476582;
14
- --rp-c-text-code-bg: #99a1b314;
15
- --rp-c-text-code-border: #0000000d;
14
+ --rp-c-text-code-bg: #99a1b30f;
15
+ --rp-c-text-code-border: #00000009;
16
16
  --rp-c-link: var(--rp-c-brand-dark);
17
17
  }
18
18
 
@@ -29,8 +29,8 @@
29
29
  --rp-c-text-3: #ebebeb61;
30
30
  --rp-c-text-4: #ebebeb2e;
31
31
  --rp-c-text-code: #c9def1;
32
- --rp-c-text-code-bg: #ffffff14;
33
- --rp-c-text-code-border: #ffffff0d;
32
+ --rp-c-text-code-bg: #ffffff0f;
33
+ --rp-c-text-code-border: #ffffff0a;
34
34
  --rp-c-link: var(--rp-c-brand-light);
35
35
  }
36
36
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "2.0.8",
3
+ "version": "2.0.10",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -60,28 +60,23 @@
60
60
  "dependencies": {
61
61
  "@mdx-js/mdx": "^3.1.1",
62
62
  "@mdx-js/react": "^3.1.1",
63
- "@rsbuild/core": "2.0.0-beta.11",
64
- "@rsbuild/plugin-react": "~1.4.6",
63
+ "@rsbuild/core": "^2.0.2",
64
+ "@rsbuild/plugin-react": "~2.0.0",
65
65
  "@shikijs/rehype": "^4.0.2",
66
66
  "@types/unist": "^3.0.3",
67
- "@unhead/react": "^2.1.12",
67
+ "@unhead/react": "^2.1.13",
68
68
  "body-scroll-lock": "4.0.0-beta.0",
69
- "cac": "^7.0.0",
70
- "chokidar": "^3.6.0",
71
69
  "clsx": "2.1.1",
72
70
  "copy-to-clipboard": "^3.3.3",
73
71
  "flexsearch": "0.8.212",
74
- "github-slugger": "^2.0.0",
75
72
  "hast-util-heading-rank": "^3.0.0",
76
73
  "hast-util-to-jsx-runtime": "^2.3.6",
77
- "lodash-es": "^4.17.23",
78
74
  "mdast-util-mdx": "^3.0.0",
79
75
  "mdast-util-mdxjs-esm": "^2.0.1",
80
76
  "medium-zoom": "1.1.0",
81
77
  "nprogress": "^0.2.0",
82
- "picocolors": "^1.1.1",
83
- "react": "^19.2.4",
84
- "react-dom": "^19.2.4",
78
+ "react": "^19.2.5",
79
+ "react-dom": "^19.2.5",
85
80
  "react-lazy-with-preload": "^2.2.1",
86
81
  "react-reconciler": "0.33.0",
87
82
  "react-render-to-markdown": "19.0.1",
@@ -96,40 +91,42 @@
96
91
  "remark-stringify": "^11.0.0",
97
92
  "scroll-into-view-if-needed": "^3.1.0",
98
93
  "shiki": "^4.0.2",
99
- "tinyglobby": "^0.2.15",
100
- "tinypool": "^1.1.1",
101
94
  "unified": "^11.0.5",
102
95
  "unist-util-remove": "^4.0.0",
103
- "unist-util-visit": "^5.0.0",
96
+ "unist-util-visit": "^5.1.0",
104
97
  "unist-util-visit-children": "^3.0.0",
105
- "@rspress/shared": "2.0.8"
98
+ "@rspress/shared": "2.0.10"
106
99
  },
107
100
  "devDependencies": {
108
101
  "@microsoft/api-extractor": "^7.57.7",
109
102
  "@rsbuild/plugin-sass": "~1.5.1",
110
- "@rsbuild/plugin-svgr": "^1.3.1",
111
- "@rslib/core": "0.20.2",
103
+ "@rsbuild/plugin-svgr": "^2.0.1",
104
+ "@rslib/core": "0.21.3",
112
105
  "@types/body-scroll-lock": "^3.1.2",
113
106
  "@types/hast": "^3.0.4",
114
- "@types/lodash-es": "^4.17.12",
115
107
  "@types/mdast": "^4.0.4",
116
108
  "@types/node": "^22.8.1",
117
109
  "@types/nprogress": "^0.2.3",
118
110
  "@types/react": "^19.2.14",
119
111
  "@types/react-dom": "^19.2.3",
120
112
  "@types/react-reconciler": "^0.33.0",
121
- "@types/web": "^0.0.345",
113
+ "@types/web": "^0.0.347",
114
+ "cac": "^7.0.0",
115
+ "chokidar": "^3.6.0",
122
116
  "execa": "8.0.1",
123
117
  "mdast-util-directive": "^3.1.0",
124
118
  "mdast-util-mdx-expression": "^2.0.1",
125
- "memfs": "^4.57.1",
119
+ "memfs": "^4.57.2",
126
120
  "p-map": "^7.0.4",
127
- "postcss": "8.5.8",
121
+ "picocolors": "^1.1.1",
122
+ "postcss": "8.5.12",
128
123
  "remark-directive": "^4.0.0",
129
124
  "rsbuild-plugin-publint": "^0.3.4",
130
- "rsbuild-plugin-virtual-module": "0.4.1",
125
+ "rsbuild-plugin-virtual-module": "0.4.2",
131
126
  "tailwindcss": "^3.4.19",
132
- "ts-json-schema-generator": "^2.4.0",
127
+ "tinyglobby": "^0.2.16",
128
+ "tinypool": "^1.1.1",
129
+ "ts-json-schema-generator": "^2.9.0",
133
130
  "typescript": "^5.8.2",
134
131
  "vfile": "^6.0.3",
135
132
  "@rspress/config": "1.0.0"
package/dist/4454.js DELETED
@@ -1,8 +0,0 @@
1
- export { default as node_path, join } from "node:path";
2
- export { logger } from "@rspress/shared/logger";
3
- export { cac } from "cac";
4
- export { default as chokidar } from "chokidar";
5
- export { default as picocolors } from "picocolors";
6
- export { default as node_fs } from "node:fs";
7
- export { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "@rspress/shared/constants";
8
- export { default as promises } from "node:fs/promises";