@rspress/core 2.0.9 → 2.0.11

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/3323.js +8 -0
  3. package/dist/{740.js → 5810.js} +127 -139
  4. package/dist/{2240.js → 6162.js} +1 -4
  5. package/dist/8006.js +1 -1
  6. package/dist/8857.js +2 -3
  7. package/dist/cli/index.js +7 -4
  8. package/dist/common-Qw-RoVFD.js +25 -0
  9. package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.tsx +17 -21
  10. package/dist/eject-theme/components/DocContent/doc.scss +14 -41
  11. package/dist/eject-theme/components/Llms/LlmsContainer.tsx +1 -2
  12. package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +14 -8
  13. package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +13 -5
  14. package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +8 -5
  15. package/dist/eject-theme/components/Outline/index.scss +1 -1
  16. package/dist/eject-theme/components/Prompt/icons.tsx +80 -0
  17. package/dist/eject-theme/components/Prompt/index.scss +423 -0
  18. package/dist/eject-theme/components/Prompt/index.tsx +335 -0
  19. package/dist/eject-theme/components/Search/logic/search.ts +10 -5
  20. package/dist/eject-theme/components/Search/logic/util.test.ts +20 -1
  21. package/dist/eject-theme/components/Search/logic/util.ts +4 -1
  22. package/dist/eject-theme/components/SidebarMenu/index.tsx +5 -1
  23. package/dist/entry/process.d.ts +1 -0
  24. package/dist/entry/process.js +65 -0
  25. package/dist/entry/utils.d.ts +7 -0
  26. package/dist/entry/utils.js +2 -0
  27. package/dist/entry/worker.d.ts +1 -0
  28. package/dist/entry/worker.js +74 -0
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +1 -0
  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 +2 -2
  35. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  36. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  37. package/dist/node/eject.js +1 -0
  38. package/dist/node/index.d.ts +1 -0
  39. package/dist/node/initRsbuild.js +1 -1
  40. package/dist/node/mdx/options.js +2 -1
  41. package/dist/node/mdx/processor.js +1 -1
  42. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  43. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
  44. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  45. package/dist/node/mdx/rehypePlugins/transformers/index.d.ts +1 -1
  46. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  47. package/dist/node/mdx/remarkPlugins/fileCodeBlock.d.ts +1 -0
  48. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +9 -4
  49. package/dist/node/mdx/remarkPlugins/image.js +1 -1
  50. package/dist/node/mdx/remarkPlugins/link.js +1 -1
  51. package/dist/node/route/RoutePage.js +1 -1
  52. package/dist/node/route/RouteService.js +1 -1
  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 +28 -0
  56. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +28 -0
  57. package/dist/node/runtimeModule/i18n.js +1 -1
  58. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  59. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  60. package/dist/node/runtimeModule/searchHooks.js +1 -1
  61. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  62. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  63. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  64. package/dist/node/serve.js +1 -1
  65. package/dist/node/ssg/renderPages.js +2 -2
  66. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  67. package/dist/node/ssg/ssgEnv.js +1 -1
  68. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  69. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  70. package/dist/node/ssg-md/remarkSplitMdx.js +1 -1
  71. package/dist/node/ssg-md/renderPage.js +1 -1
  72. package/dist/node/ssg-md/renderPages.js +1 -1
  73. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  74. package/dist/node/utils/checkLanguageParity.js +1 -1
  75. package/dist/node/utils/createHash.js +1 -1
  76. package/dist/node/utils/flattenMdxContent.js +1 -1
  77. package/dist/node/utils/getPageKey.js +1 -1
  78. package/dist/node/utils/reactAlias.js +1 -1
  79. package/dist/runtime/BrowserOnly.d.ts +7 -0
  80. package/dist/runtime/BrowserOnly.js +40 -0
  81. package/dist/runtime/BrowserOnly.test.d.ts +1 -0
  82. package/dist/runtime/index.d.ts +1 -0
  83. package/dist/runtime/index.js +1 -0
  84. package/dist/theme/components/CodeButtonGroup/CopyCodeButton.js +14 -12
  85. package/dist/theme/components/DocContent/doc.css +13 -21
  86. package/dist/theme/components/Llms/LlmsCopyButton.js +5 -6
  87. package/dist/theme/components/Llms/LlmsCopyRow.js +5 -5
  88. package/dist/theme/components/Llms/LlmsViewOptions.js +1 -3
  89. package/dist/theme/components/Outline/index.css +1 -1
  90. package/dist/theme/components/Prompt/icons.d.ts +10 -0
  91. package/dist/theme/components/Prompt/icons.js +64 -0
  92. package/dist/theme/components/Prompt/index.css +326 -0
  93. package/dist/theme/components/Prompt/index.d.ts +33 -0
  94. package/dist/theme/components/Prompt/index.js +262 -0
  95. package/dist/theme/components/Search/logic/search.js +5 -3
  96. package/dist/theme/components/Search/logic/util.js +2 -1
  97. package/dist/theme/components/SidebarMenu/index.js +2 -1
  98. package/dist/theme/index.d.ts +3 -0
  99. package/dist/theme/index.js +3 -0
  100. package/dist/theme/layout/DocLayout/index.css +9 -1
  101. package/dist/theme/layout/DocLayout/index.js +11 -6
  102. package/dist/theme/logic/copyToClipboard.d.ts +1 -0
  103. package/dist/theme/{components/Llms/copy.js → logic/copyToClipboard.js} +4 -3
  104. package/dist/theme/logic/getCopyableText.d.ts +5 -0
  105. package/dist/theme/logic/getCopyableText.js +52 -0
  106. package/dist/theme/logic/useThemeState.d.ts +5 -10
  107. package/dist/theme/logic/useThemeState.js +15 -20
  108. package/dist/theme/styles/vars/base-vars.css +4 -4
  109. package/dist/utils-B--2TaWv.js +34 -0
  110. package/dist/utils-De75vAgL.js +7 -0
  111. package/package.json +16 -16
  112. package/dist/3425.js +0 -6
  113. package/dist/eject-theme/components/Llms/copy.ts +0 -12
  114. package/dist/runtime/getSidebarDataGroup.test.js +0 -68
  115. package/dist/runtime/hooks/useWindowSize.test.js +0 -36
  116. package/dist/runtime/route.test.js +0 -154
  117. package/dist/runtime/utils.test.js +0 -34
  118. package/dist/theme/components/Llms/copy.d.ts +0 -1
  119. package/dist/theme/components/Search/logic/util.test.js +0 -51
@@ -177,30 +177,24 @@
177
177
  /* table */
178
178
  /* #region */
179
179
  &:where(.rp-table-scroll-container) {
180
+ margin: 1.5rem 0;
180
181
  overflow-x: auto;
182
+ overscroll-behavior-x: contain;
181
183
  }
184
+
182
185
  &:where(table) {
183
186
  width: 100%;
184
-
187
+ min-width: 100%;
185
188
  table-layout: auto;
186
189
  border-collapse: separate;
187
190
  border-spacing: 0;
188
-
189
191
  border: var(--rp-code-block-border);
190
192
  border-radius: var(--rp-radius);
191
193
  overflow: hidden;
194
+ }
192
195
 
193
- &::-webkit-scrollbar {
194
- height: 5px;
195
- width: 5px;
196
- }
197
- &::-webkit-scrollbar-corner {
198
- display: none;
199
- }
200
- &::-webkit-scrollbar-thumb {
201
- background-color: rgba(0, 0, 0, 0.05);
202
- border-radius: 10px;
203
- }
196
+ &:where(table:not(.rp-table-scroll-container > table)) {
197
+ margin: 1.5rem 0;
204
198
  }
205
199
 
206
200
  /* thead */
@@ -210,7 +204,8 @@
210
204
  }
211
205
 
212
206
  &:where(th) {
213
- padding: 0.75rem 1.25rem;
207
+ min-width: 8rem;
208
+ padding: 0.75rem 1rem;
214
209
  font-weight: 600;
215
210
  font-size: 0.875rem;
216
211
  text-align: left;
@@ -224,14 +219,15 @@
224
219
  }
225
220
 
226
221
  &:where(td) {
227
- padding: 0.75rem 1.25rem;
222
+ min-width: 8rem;
223
+ padding: 0.75rem 1rem;
228
224
  border-bottom: 1px solid var(--rp-c-divider-light);
229
-
230
225
  font-size: 0.875rem;
226
+ color: var(--rp-c-text-1);
231
227
  }
232
228
 
233
- &:where(tr) {
234
- transition: background-color 0.2s ease;
229
+ &:where(tbody tr) {
230
+ transition: background-color 0.2s ease-out;
235
231
 
236
232
  &:hover {
237
233
  background: var(--rp-c-bg-soft);
@@ -282,26 +278,3 @@
282
278
  }
283
279
  }
284
280
  }
285
-
286
- /* Dark mode styles */
287
- :where(.rp-dark) .rp-doc {
288
- :not(:where(.rp-not-doc, .rp-not-doc *)) {
289
- /* table */
290
- /* #region */
291
- &:where(table) {
292
- border-color: var(--rp-c-divider);
293
- }
294
-
295
- &:where(table tr) {
296
- border-color: var(--rp-c-divider);
297
- }
298
-
299
- &:where(table td) {
300
- border-color: var(--rp-c-divider);
301
- }
302
-
303
- &:where(table th) {
304
- border-color: var(--rp-c-divider);
305
- }
306
- }
307
- }
@@ -1,8 +1,7 @@
1
1
  import type React from 'react';
2
2
  import './LlmsContainer.scss';
3
3
 
4
- export interface LlmsContainerProps
5
- extends React.HTMLAttributes<HTMLDivElement> {}
4
+ export interface LlmsContainerProps extends React.HTMLAttributes<HTMLDivElement> {}
6
5
 
7
6
  export function LlmsContainer(props: LlmsContainerProps) {
8
7
  return <div {...props} className={'rp-not-doc rp-llms-container'} />;
@@ -4,16 +4,18 @@
4
4
  * @license MIT
5
5
  */
6
6
  import { useI18n } from '@rspress/core/runtime';
7
- import { IconCopy, IconSuccess } from '@rspress/core/theme';
7
+ import {
8
+ copyToClipboard,
9
+ IconCopy,
10
+ IconSuccess,
11
+ SvgWrapper,
12
+ } from '@rspress/core/theme';
8
13
  import { useCallback, useRef, useState } from 'react';
9
- import { SvgWrapper } from '../SvgWrapper';
10
14
  import './index.scss';
11
15
  import './LlmsCopyButton.scss';
12
- import { copyToClipboard } from './copy';
13
16
  import { useMdUrl } from './useMdUrl';
14
17
 
15
- export interface LlmsCopyButtonProps
16
- extends React.ButtonHTMLAttributes<HTMLButtonElement> {
18
+ export interface LlmsCopyButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
17
19
  /**
18
20
  * Text by language, used with `useLang`.
19
21
  * @default en: 'Copy Markdown', zh: '\u590d\u5236 Markdown'
@@ -52,9 +54,11 @@ export function LlmsCopyButton(props: LlmsCopyButtonProps) {
52
54
  cache.get(url) ?? (await fetch(url).then(res => res.text()));
53
55
 
54
56
  cache.set(url, content);
55
- await copyToClipboard(content);
56
- } finally {
57
- setLoading(false);
57
+ const isCopied = await copyToClipboard(content);
58
+ if (!isCopied) {
59
+ return;
60
+ }
61
+
58
62
  setFinished(true);
59
63
  if (timer.current) {
60
64
  clearTimeout(timer.current);
@@ -64,6 +68,8 @@ export function LlmsCopyButton(props: LlmsCopyButtonProps) {
64
68
  setFinished(false);
65
69
  timer.current = null;
66
70
  }, 500);
71
+ } finally {
72
+ setLoading(false);
67
73
  }
68
74
  }, [pathname]);
69
75
 
@@ -1,7 +1,11 @@
1
1
  import { useI18n } from '@rspress/core/runtime';
2
- import { IconCopy, IconSuccess, SvgWrapper } from '@rspress/core/theme';
2
+ import {
3
+ copyToClipboard,
4
+ IconCopy,
5
+ IconSuccess,
6
+ SvgWrapper,
7
+ } from '@rspress/core/theme';
3
8
  import { useCallback, useRef, useState } from 'react';
4
- import { copyToClipboard } from './copy';
5
9
  import { useMdUrl } from './useMdUrl';
6
10
 
7
11
  const cache = new Map<string, string>();
@@ -20,9 +24,11 @@ export function LlmsCopyRow() {
20
24
  const content: string =
21
25
  cache.get(pathname) ?? (await fetch(pathname).then(res => res.text()));
22
26
  cache.set(pathname, content);
23
- await copyToClipboard(content);
24
- } finally {
25
- setLoading(false);
27
+ const isCopied = await copyToClipboard(content);
28
+ if (!isCopied) {
29
+ return;
30
+ }
31
+
26
32
  setFinished(true);
27
33
  if (timer.current) {
28
34
  clearTimeout(timer.current);
@@ -32,6 +38,8 @@ export function LlmsCopyRow() {
32
38
  setFinished(false);
33
39
  timer.current = null;
34
40
  }, 1500);
41
+ } finally {
42
+ setLoading(false);
35
43
  }
36
44
  }, [pathname]);
37
45
 
@@ -4,13 +4,17 @@
4
4
  * @license MIT
5
5
  */
6
6
  import { useI18n, useSite } from '@rspress/core/runtime';
7
- import { IconDown, IconExternalLink, IconLink } from '@rspress/core/theme';
7
+ import {
8
+ copyToClipboard,
9
+ IconDown,
10
+ IconExternalLink,
11
+ IconLink,
12
+ SvgWrapper,
13
+ } from '@rspress/core/theme';
8
14
  import type React from 'react';
9
15
  import { useEffect, useMemo, useRef, useState } from 'react';
10
- import { SvgWrapper } from '../SvgWrapper';
11
16
  import './index.scss';
12
17
  import './LlmsViewOptions.scss';
13
- import { copyToClipboard } from './copy';
14
18
  import { useMdUrl } from './useMdUrl';
15
19
 
16
20
  type Option =
@@ -28,8 +32,7 @@ type Option =
28
32
  | 'chatgpt'
29
33
  | 'claude';
30
34
 
31
- export interface LlmsViewOptionsProps
32
- extends React.ButtonHTMLAttributes<HTMLButtonElement> {
35
+ export interface LlmsViewOptionsProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
33
36
  /**
34
37
  * Default options for the dropdown.
35
38
  * @default ['markdownLink', 'chatgpt', 'claude']
@@ -48,7 +48,7 @@
48
48
  overflow: auto scroll;
49
49
  scrollbar-width: none;
50
50
 
51
- mask-image: linear-gradient(#0000, #fff 12px calc(100% - 12px), #0000);
51
+ mask-image: linear-gradient(#0000, #fff 8px calc(100% - 8px), #0000);
52
52
 
53
53
  // limit height on mobile where outline is a floating panel
54
54
  @media (max-width: 1280px) {
@@ -0,0 +1,80 @@
1
+ import type React from 'react';
2
+
3
+ export interface AgentIcon {
4
+ color: string;
5
+ name: string;
6
+ svg: React.ReactNode;
7
+ }
8
+
9
+ /**
10
+ * SVG icons sourced from @lobehub/icons (MIT license).
11
+ */
12
+ export const AGENT_ICONS: AgentIcon[] = [
13
+ {
14
+ name: 'Codex',
15
+ color: '#6366F1',
16
+ svg: (
17
+ <svg
18
+ aria-hidden="true"
19
+ viewBox="0 0 24 24"
20
+ xmlns="http://www.w3.org/2000/svg"
21
+ >
22
+ <path
23
+ d="M19.503 0H4.496A4.496 4.496 0 000 4.496v15.007A4.496 4.496 0 004.496 24h15.007A4.496 4.496 0 0024 19.503V4.496A4.496 4.496 0 0019.503 0z"
24
+ fill="#fff"
25
+ />
26
+ <path
27
+ d="M9.064 3.344a4.578 4.578 0 012.285-.312c1 .115 1.891.54 2.673 1.275.01.01.024.017.037.021a.09.09 0 00.043 0 4.55 4.55 0 013.046.275l.047.022.116.057a4.581 4.581 0 012.188 2.399c.209.51.313 1.041.315 1.595a4.24 4.24 0 01-.134 1.223.123.123 0 00.03.115c.594.607.988 1.33 1.183 2.17.289 1.425-.007 2.71-.887 3.854l-.136.166a4.548 4.548 0 01-2.201 1.388.123.123 0 00-.081.076c-.191.551-.383 1.023-.74 1.494-.9 1.187-2.222 1.846-3.711 1.838-1.187-.006-2.239-.44-3.157-1.302a.107.107 0 00-.105-.024c-.388.125-.78.143-1.204.138a4.441 4.441 0 01-1.945-.466 4.544 4.544 0 01-1.61-1.335c-.152-.202-.303-.392-.414-.617a5.81 5.81 0 01-.37-.961 4.582 4.582 0 01-.014-2.298.124.124 0 00.006-.056.085.085 0 00-.027-.048 4.467 4.467 0 01-1.034-1.651 3.896 3.896 0 01-.251-1.192 5.189 5.189 0 01.141-1.6c.337-1.112.982-1.985 1.933-2.618.212-.141.413-.251.601-.33.215-.089.43-.164.646-.227a.098.098 0 00.065-.066 4.51 4.51 0 01.829-1.615 4.535 4.535 0 011.837-1.388zm3.482 10.565a.637.637 0 000 1.272h3.636a.637.637 0 100-1.272h-3.636zM8.462 9.23a.637.637 0 00-1.106.631l1.272 2.224-1.266 2.136a.636.636 0 101.095.649l1.454-2.455a.636.636 0 00.005-.64L8.462 9.23z"
28
+ fill="#6366F1"
29
+ />
30
+ </svg>
31
+ ),
32
+ },
33
+ {
34
+ name: 'Claude Code',
35
+ color: '#D97757',
36
+ svg: (
37
+ <svg
38
+ aria-hidden="true"
39
+ viewBox="0 0 24 24"
40
+ xmlns="http://www.w3.org/2000/svg"
41
+ >
42
+ <path
43
+ clipRule="evenodd"
44
+ d="M20.998 10.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6 10.949h1.488V8.102H6v2.847zm10.51 0H18V8.102h-1.49v2.847z"
45
+ fill="#D97757"
46
+ fillRule="evenodd"
47
+ />
48
+ </svg>
49
+ ),
50
+ },
51
+ {
52
+ name: 'Cursor',
53
+ color: '#737373',
54
+ svg: (
55
+ <svg
56
+ aria-hidden="true"
57
+ viewBox="0 0 24 24"
58
+ xmlns="http://www.w3.org/2000/svg"
59
+ >
60
+ <path
61
+ d="M22.106 5.68L12.5.135a.998.998 0 00-.998 0L1.893 5.68a.84.84 0 00-.419.726v11.186c0 .3.16.577.42.727l9.607 5.547a.999.999 0 00.998 0l9.608-5.547a.84.84 0 00.42-.727V6.407a.84.84 0 00-.42-.726zm-.603 1.176L12.228 22.92c-.063.108-.228.064-.228-.061V12.34a.59.59 0 00-.295-.51l-9.11-5.26c-.107-.062-.063-.228.062-.228h18.55c.264 0 .428.286.296.514z"
62
+ fill="currentColor"
63
+ />
64
+ </svg>
65
+ ),
66
+ },
67
+ {
68
+ name: 'opencode',
69
+ color: '#6B7280',
70
+ svg: (
71
+ <svg
72
+ aria-hidden="true"
73
+ viewBox="0 0 24 24"
74
+ xmlns="http://www.w3.org/2000/svg"
75
+ >
76
+ <path d="M16 6H8v12h8V6zm4 16H4V2h16v20z" fill="currentColor" />
77
+ </svg>
78
+ ),
79
+ },
80
+ ];