@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,41 @@
1
+ /*!
2
+ * fill-range <https://github.com/jonschlinkert/fill-range>
3
+ *
4
+ * Copyright (c) 2014-present, Jon Schlinkert.
5
+ * Licensed under the MIT License.
6
+ */
7
+
8
+ /*!
9
+ * is-extglob <https://github.com/jonschlinkert/is-extglob>
10
+ *
11
+ * Copyright (c) 2014-2016, Jon Schlinkert.
12
+ * Licensed under the MIT License.
13
+ */
14
+
15
+ /*!
16
+ * is-glob <https://github.com/jonschlinkert/is-glob>
17
+ *
18
+ * Copyright (c) 2014-2017, Jon Schlinkert.
19
+ * Released under the MIT License.
20
+ */
21
+
22
+ /*!
23
+ * is-number <https://github.com/jonschlinkert/is-number>
24
+ *
25
+ * Copyright (c) 2014-present, Jon Schlinkert.
26
+ * Released under the MIT License.
27
+ */
28
+
29
+ /*!
30
+ * normalize-path <https://github.com/jonschlinkert/normalize-path>
31
+ *
32
+ * Copyright (c) 2014-2018, Jon Schlinkert.
33
+ * Released under the MIT License.
34
+ */
35
+
36
+ /*!
37
+ * to-regex-range <https://github.com/micromatch/to-regex-range>
38
+ *
39
+ * Copyright (c) 2015-present, Jon Schlinkert.
40
+ * Released under the MIT License.
41
+ */
package/dist/cli/index.js CHANGED
@@ -1,11 +1,15 @@
1
- import { chokidar, node_path, logger, picocolors, join, cac } from "../4454.js";
2
- import { package_namespaceObject } from "../8311.js";
1
+ import { __webpack_require__ } from "../0~rslib-runtime.js";
2
+ import { node_path, logger, join, cac } from "../8857.js";
3
+ import { package_namespaceObject } from "../8006.js";
3
4
  import { loadConfigFile, resolveDocRoot } from "../config/loadConfigFile.js";
4
5
  import { dev } from "../node/dev.js";
5
6
  import { PUBLIC_DIR } from "../node/constants.js";
6
7
  import { build } from "../node/build.js";
7
8
  import { serve } from "../node/serve.js";
8
9
  import { listComponents, ejectComponent } from "../node/eject.js";
10
+ const chokidar = __webpack_require__("../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/index.js");
11
+ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
12
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
9
13
  const META_FILES = [
10
14
  '_meta.json',
11
15
  '_nav.json'
@@ -17,7 +21,7 @@ const setNodeEnv = (env)=>{
17
21
  process.env.NODE_ENV = env;
18
22
  };
19
23
  cli.option('-c,--config [config]', 'Specify the path to the config file');
20
- cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', 'port number').option('--host [host]', 'hostname').action(async (root, options)=>{
24
+ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', 'port number').option('--host [host]', 'hostname').option('--base <base>', 'deployment base path').action(async (root, options)=>{
21
25
  setNodeEnv('development');
22
26
  let isRestarting = false;
23
27
  const cwd = process.cwd();
@@ -27,6 +31,7 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
27
31
  const { port, host } = options || {};
28
32
  const { config, configFilePath } = await loadConfigFile(options?.config);
29
33
  config.root = resolveDocRoot(cwd, root, config.root);
34
+ if (options?.base) config.base = options.base;
30
35
  const docDirectory = config.root;
31
36
  devServer = await dev({
32
37
  appDirectory: cwd,
@@ -40,7 +45,7 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
40
45
  }
41
46
  }
42
47
  });
43
- cliWatcher = chokidar.watch([
48
+ cliWatcher = chokidar.w([
44
49
  configFilePath,
45
50
  docDirectory
46
51
  ], {
@@ -58,7 +63,7 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
58
63
  if ('add' === eventName || 'unlink' === eventName || 'change' === eventName && filepath === configFilePath) {
59
64
  if (isRestarting) return;
60
65
  isRestarting = true;
61
- console.log(`\n✨ ${eventName} ${picocolors.green(node_path.relative(cwd, filepath))}, dev server will restart...\n`);
66
+ console.log(`\n✨ ${eventName} ${picocolors_default().green(node_path.relative(cwd, filepath))}, dev server will restart...\n`);
62
67
  await devServer.close();
63
68
  await cliWatcher.close();
64
69
  await startDevServer();
@@ -78,11 +83,12 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
78
83
  process.on('SIGINT', exitProcess);
79
84
  process.on('SIGTERM', exitProcess);
80
85
  });
81
- cli.command('build [root]').action(async (root, options)=>{
86
+ cli.command('build [root]').option('--base <base>', 'deployment base path').action(async (root, options)=>{
82
87
  setNodeEnv('production');
83
88
  const cwd = process.cwd();
84
89
  const { config, configFilePath } = await loadConfigFile(options.config);
85
90
  config.root = resolveDocRoot(cwd, root, config.root);
91
+ if (options.base) config.base = options.base;
86
92
  const docDirectory = config.root;
87
93
  try {
88
94
  await build({
@@ -95,12 +101,13 @@ cli.command('build [root]').action(async (root, options)=>{
95
101
  process.exit(1);
96
102
  }
97
103
  });
98
- cli.command('preview [root]').alias('serve').option('--port [port]', 'port number').option('--host [host]', 'hostname').action(async (root, options)=>{
104
+ cli.command('preview [root]').alias('serve').option('--port [port]', 'port number').option('--host [host]', 'hostname').option('--base <base>', 'deployment base path').action(async (root, options)=>{
99
105
  setNodeEnv('production');
100
106
  const cwd = process.cwd();
101
107
  const { port, host } = options || {};
102
108
  const { config, configFilePath } = await loadConfigFile(options?.config);
103
109
  config.root = resolveDocRoot(cwd, root, config.root);
110
+ if (options?.base) config.base = options.base;
104
111
  await serve({
105
112
  config,
106
113
  host,
@@ -1,4 +1,4 @@
1
- import { node_fs, node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../4454.js";
1
+ import { node_fs, node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../8857.js";
2
2
  const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(node_fs.existsSync);
3
3
  async function loadConfigFile(customConfigFile) {
4
4
  const baseDir = process.cwd();
@@ -8,7 +8,7 @@
8
8
  left: 50%;
9
9
  transform: translate(-50%, -50%) scale(0);
10
10
  opacity: 0;
11
- color: #00d600;
11
+ color: #10b981;
12
12
  }
13
13
 
14
14
  .rp-code-copy-button--copied .rp-code-copy-button__icon--copy {
@@ -1,5 +1,10 @@
1
- import { IconCopy, IconSuccess, SvgWrapper } from '@rspress/core/theme';
2
- import copy from 'copy-to-clipboard';
1
+ import {
2
+ copyToClipboard,
3
+ getCopyableText,
4
+ IconCopy,
5
+ IconSuccess,
6
+ SvgWrapper,
7
+ } from '@rspress/core/theme';
3
8
  import { useRef } from 'react';
4
9
  import './CopyCodeButton.scss';
5
10
  import { useI18n } from '@rspress/core/runtime';
@@ -7,31 +12,20 @@ import { useI18n } from '@rspress/core/runtime';
7
12
  const timeoutIdMap: Map<HTMLElement, NodeJS.Timeout> = new Map();
8
13
  const COPIED_CLASS = 'rp-code-copy-button--copied';
9
14
 
10
- function copyCode(
15
+ async function copyCode(
11
16
  codeBlockElement: HTMLElement | null,
12
17
  copyButtonElement: HTMLButtonElement | null,
13
18
  ) {
14
- let text = '';
15
19
  if (!codeBlockElement) {
16
20
  return;
17
21
  }
18
- const walk = document.createTreeWalker(
19
- codeBlockElement,
20
- NodeFilter.SHOW_TEXT,
21
- null,
22
- );
23
- let node = walk.nextNode();
24
- while (node) {
25
- if (
26
- !node.parentElement!.classList.contains('linenumber') &&
27
- !node.parentElement!.closest('.rp-copy-ignore')
28
- ) {
29
- text += node.nodeValue;
30
- }
31
- node = walk.nextNode();
32
- }
33
22
 
34
- const isCopied = copy(text);
23
+ const text = getCopyableText(codeBlockElement, {
24
+ ignoreClasses: ['linenumber'],
25
+ ignoreSelectors: ['.rp-copy-ignore'],
26
+ });
27
+
28
+ const isCopied = await copyToClipboard(text);
35
29
 
36
30
  if (isCopied && copyButtonElement) {
37
31
  copyButtonElement.classList.add(COPIED_CLASS);
@@ -56,7 +50,9 @@ export function CopyCodeButton({
56
50
  return (
57
51
  <button
58
52
  className="rp-code-button-group__button rp-code-copy-button"
59
- onClick={() => copyCode(codeBlockRef.current, copyButtonRef.current!)}
53
+ onClick={() => {
54
+ void copyCode(codeBlockRef.current, copyButtonRef.current);
55
+ }}
60
56
  ref={copyButtonRef}
61
57
  title={t('codeButtonGroupCopyButtonText')}
62
58
  >
@@ -47,7 +47,7 @@
47
47
  left: 50%;
48
48
  transform: translate(-50%, -50%) scale(0);
49
49
  opacity: 0;
50
- color: #00d600;
50
+ color: #10b981;
51
51
  }
52
52
  }
53
53
  }
@@ -73,6 +73,8 @@
73
73
  transition:
74
74
  color 0.25s,
75
75
  opacity 0.25s;
76
+ border-bottom: 1px solid transparent;
77
+
76
78
  &:hover {
77
79
  border-bottom: 1px solid var(--rp-c-brand);
78
80
  opacity: 0.85;
@@ -175,30 +177,24 @@
175
177
  /* table */
176
178
  /* #region */
177
179
  &:where(.rp-table-scroll-container) {
180
+ margin: 1.5rem 0;
178
181
  overflow-x: auto;
182
+ overscroll-behavior-x: contain;
179
183
  }
184
+
180
185
  &:where(table) {
181
186
  width: 100%;
182
-
187
+ min-width: 100%;
183
188
  table-layout: auto;
184
189
  border-collapse: separate;
185
190
  border-spacing: 0;
186
-
187
191
  border: var(--rp-code-block-border);
188
192
  border-radius: var(--rp-radius);
189
193
  overflow: hidden;
194
+ }
190
195
 
191
- &::-webkit-scrollbar {
192
- height: 5px;
193
- width: 5px;
194
- }
195
- &::-webkit-scrollbar-corner {
196
- display: none;
197
- }
198
- &::-webkit-scrollbar-thumb {
199
- background-color: rgba(0, 0, 0, 0.05);
200
- border-radius: 10px;
201
- }
196
+ &:where(table:not(.rp-table-scroll-container > table)) {
197
+ margin: 1.5rem 0;
202
198
  }
203
199
 
204
200
  /* thead */
@@ -208,7 +204,8 @@
208
204
  }
209
205
 
210
206
  &:where(th) {
211
- padding: 0.75rem 1.25rem;
207
+ min-width: 8rem;
208
+ padding: 0.75rem 1rem;
212
209
  font-weight: 600;
213
210
  font-size: 0.875rem;
214
211
  text-align: left;
@@ -222,14 +219,15 @@
222
219
  }
223
220
 
224
221
  &:where(td) {
225
- padding: 0.75rem 1.25rem;
222
+ min-width: 8rem;
223
+ padding: 0.75rem 1rem;
226
224
  border-bottom: 1px solid var(--rp-c-divider-light);
227
-
228
225
  font-size: 0.875rem;
226
+ color: var(--rp-c-text-1);
229
227
  }
230
228
 
231
- &:where(tr) {
232
- transition: background-color 0.2s ease;
229
+ &:where(tbody tr) {
230
+ transition: background-color 0.2s ease-out;
233
231
 
234
232
  &:hover {
235
233
  background: var(--rp-c-bg-soft);
@@ -280,26 +278,3 @@
280
278
  }
281
279
  }
282
280
  }
283
-
284
- /* Dark mode styles */
285
- :where(.rp-dark) .rp-doc {
286
- :not(:where(.rp-not-doc, .rp-not-doc *)) {
287
- /* table */
288
- /* #region */
289
- &:where(table) {
290
- border-color: var(--rp-c-divider);
291
- }
292
-
293
- &:where(table tr) {
294
- border-color: var(--rp-c-divider);
295
- }
296
-
297
- &:where(table td) {
298
- border-color: var(--rp-c-divider);
299
- }
300
-
301
- &:where(table th) {
302
- border-color: var(--rp-c-divider);
303
- }
304
- }
305
- }
@@ -2,7 +2,7 @@ import {
2
2
  getCustomMDXComponent,
3
3
  renderInlineMarkdown,
4
4
  } from '@rspress/core/theme';
5
- import { slug } from 'github-slugger';
5
+ import { slug } from '@rspress/shared/github-slugger';
6
6
  import { useMemo } from 'react';
7
7
 
8
8
  const getHeadingMap = () => {
@@ -1,11 +1,13 @@
1
1
  import {
2
2
  cleanUrlByConfig,
3
+ initPageData,
3
4
  isActive,
4
5
  isExternalUrl,
5
6
  pathnameToRouteService,
6
7
  removeBase,
7
8
  useLocation,
8
9
  useNavigate as useNavigateInner,
10
+ warmPageData,
9
11
  withBase,
10
12
  } from '@rspress/core/runtime';
11
13
  import nprogress from 'nprogress';
@@ -88,7 +90,8 @@ export function useLinkNavigate(
88
90
  const timer = setTimeout(() => {
89
91
  nprogress.start();
90
92
  }, 200);
91
- await matchedRoute.preload();
93
+ const data = await initPageData(removeBaseHref);
94
+ warmPageData(removeBaseHref, data);
92
95
  clearTimeout(timer);
93
96
  nprogress.done();
94
97
  } else {
@@ -9,8 +9,8 @@
9
9
  }
10
10
 
11
11
  &--success.rp-llms-copy-button {
12
- color: var(--rp-c-green-1, #10b981);
13
- border-color: var(--rp-c-green-1, #10b981);
12
+ color: #10b981;
13
+ border-color: #10b981;
14
14
  background: var(--rp-c-bg-soft);
15
15
  }
16
16
  }
@@ -48,7 +48,7 @@
48
48
  position: absolute;
49
49
  top: 50%;
50
50
  left: 50%;
51
- color: var(--rp-c-green-1, #10b981);
51
+ color: #10b981;
52
52
 
53
53
  visibility: hidden;
54
54
  opacity: 0;
@@ -4,12 +4,15 @@
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
18
  export interface LlmsCopyButtonProps
@@ -52,9 +55,11 @@ export function LlmsCopyButton(props: LlmsCopyButtonProps) {
52
55
  cache.get(url) ?? (await fetch(url).then(res => res.text()));
53
56
 
54
57
  cache.set(url, content);
55
- await copyToClipboard(content);
56
- } finally {
57
- setLoading(false);
58
+ const isCopied = await copyToClipboard(content);
59
+ if (!isCopied) {
60
+ return;
61
+ }
62
+
58
63
  setFinished(true);
59
64
  if (timer.current) {
60
65
  clearTimeout(timer.current);
@@ -64,6 +69,8 @@ export function LlmsCopyButton(props: LlmsCopyButtonProps) {
64
69
  setFinished(false);
65
70
  timer.current = null;
66
71
  }, 500);
72
+ } finally {
73
+ setLoading(false);
67
74
  }
68
75
  }, [pathname]);
69
76
 
@@ -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 =
@@ -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: '#434343',
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
+ ];