@rspress/core 2.0.0-rc.6 → 2.0.0-rc.7

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 (50) hide show
  1. package/dist/{0~7675.d236b058.js → 0~7675.efbf8813.js} +2 -2
  2. package/dist/{5485.7586c86a.js → 5485.e8bfcd99.js} +1 -1
  3. package/dist/cli/index.js +1 -1
  4. package/dist/config/loadConfigFile.js +1 -1
  5. package/dist/eject-theme/components/HomeFeature/index.scss +6 -0
  6. package/dist/eject-theme/components/HomeFeature/index.tsx +5 -6
  7. package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +9 -2
  8. package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +6 -56
  9. package/dist/eject-theme/components/Overview/index.tsx +3 -1
  10. package/dist/eject-theme/components/OverviewGroup/index.tsx +1 -1
  11. package/dist/eject-theme/components/SvgWrapper/index.tsx +41 -7
  12. package/dist/index.js +1 -1
  13. package/dist/node/auto-nav-sidebar/index.js +1 -1
  14. package/dist/node/constants.js +1 -1
  15. package/dist/node/initRsbuild.js +11 -2
  16. package/dist/node/last-updated/index.js +1 -1
  17. package/dist/node/route/RouteService.js +1 -1
  18. package/dist/node/route/extractPageData.js +1 -1
  19. package/dist/node/route/normalizeRoutePath.js +1 -1
  20. package/dist/node/runtimeModule/i18n.js +1 -1
  21. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  22. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  23. package/dist/node/serve.js +1 -1
  24. package/dist/node/ssg/renderPage.js +1 -1
  25. package/dist/node/ssg/renderPageWorker.js +1 -1
  26. package/dist/node/ssg/renderPages.js +2 -2
  27. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  28. package/dist/node/ssg-md/renderPage.js +1 -1
  29. package/dist/node/ssg-md/renderPages.js +1 -1
  30. package/dist/node/utils/createHash.js +1 -1
  31. package/dist/node/utils/flattenMdxContent.js +1 -1
  32. package/dist/node/utils/reactAlias.js +1 -1
  33. package/dist/runtime/hooks/usePageData.d.ts +1 -0
  34. package/dist/theme/assets/external-link.js +16 -0
  35. package/dist/theme/assets/link.js +26 -0
  36. package/dist/theme/components/HomeFeature/index.css +5 -0
  37. package/dist/theme/components/HomeFeature/index.js +4 -2
  38. package/dist/theme/components/Llms/LlmsCopyButton.js +5 -2
  39. package/dist/theme/components/Llms/LlmsViewOptions.js +10 -54
  40. package/dist/theme/components/Overview/index.js +1 -1
  41. package/dist/theme/components/OverviewGroup/index.d.ts +1 -1
  42. package/dist/theme/components/SvgWrapper/index.d.ts +9 -3
  43. package/dist/theme/components/SvgWrapper/index.js +22 -5
  44. package/dist/theme/icons.d.ts +2 -2
  45. package/dist/theme/icons.js +5 -5
  46. package/dist/theme/logic/useScrollAfterNav.js +1 -0
  47. package/package.json +3 -3
  48. package/dist/theme/assets/right.js +0 -14
  49. package/dist/theme/assets/translator.js +0 -14
  50. /package/dist/{7786.421b464f.js → 9446.421b464f.js} +0 -0
@@ -9,8 +9,8 @@ import { setTimeout as promises_setTimeout } from "node:timers/promises";
9
9
  import { debuglog } from "node:util";
10
10
  import { node_process, node_os, constants } from "./9348.1beb3e25.js";
11
11
  import { node_path } from "./6289.29817fb4.js";
12
- import { node_url } from "./5485.7586c86a.js";
13
- import { createWriteStream, createReadStream, readFileSync } from "./7786.421b464f.js";
12
+ import { node_url } from "./5485.e8bfcd99.js";
13
+ import { createWriteStream, createReadStream, readFileSync } from "./9446.421b464f.js";
14
14
  __webpack_require__.add({
15
15
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js" (module, __unused_rspack_exports, __webpack_require__) {
16
16
  const cp = __webpack_require__("child_process");
@@ -1,5 +1,5 @@
1
1
  var package_namespaceObject = {
2
- rE: "2.0.0-rc.6"
2
+ rE: "2.0.0-rc.7"
3
3
  };
4
4
  async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true, signal } = {}) {
5
5
  return new Promise((resolve_, reject_)=>{
package/dist/cli/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { node_path, logger, join, picocolors } from "../6289.29817fb4.js";
2
2
  import { chokidar, cac } from "./index.44f3184c.js";
3
- import { package_namespaceObject } from "../5485.7586c86a.js";
3
+ import { package_namespaceObject } from "../5485.e8bfcd99.js";
4
4
  import { loadConfigFile, resolveDocRoot } from "../config/loadConfigFile.js";
5
5
  import { dev } from "../node/dev.js";
6
6
  import { PUBLIC_DIR } from "../node/constants.js";
@@ -1,4 +1,4 @@
1
- import { node_fs, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "../7786.421b464f.js";
1
+ import { node_fs, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "../9446.421b464f.js";
2
2
  import { node_path, logger } from "../6289.29817fb4.js";
3
3
  const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(node_fs.existsSync);
4
4
  async function loadConfigFile(customConfigFile) {
@@ -97,6 +97,12 @@
97
97
  background-color: var(--rp-c-bg);
98
98
  border-radius: 1rem;
99
99
  border: 3px solid var(--rp-c-divider-light);
100
+
101
+ img,
102
+ svg {
103
+ width: 1.5rem;
104
+ height: 1.5rem;
105
+ }
100
106
  }
101
107
 
102
108
  &__title {
@@ -1,6 +1,6 @@
1
1
  import type { Feature } from '@rspress/core';
2
2
  import { useFrontmatter } from '@rspress/core/runtime';
3
- import { renderHtmlOrText, useLinkNavigate } from '@theme';
3
+ import { renderHtmlOrText, SvgWrapper, useLinkNavigate } from '@theme';
4
4
  import type { JSX } from 'react';
5
5
  import './index.scss';
6
6
  import { useCardAnimation } from './useCardAnimation';
@@ -48,10 +48,9 @@ function HomeFeatureItem({ feature }: { feature: Feature }): JSX.Element {
48
48
  >
49
49
  <div className="rp-home-feature__title-wrapper">
50
50
  {icon ? (
51
- <div
52
- className="rp-home-feature__icon"
53
- {...renderHtmlOrText(icon)}
54
- ></div>
51
+ <div className="rp-home-feature__icon">
52
+ <SvgWrapper icon={icon} />
53
+ </div>
55
54
  ) : null}
56
55
 
57
56
  <h2 className="rp-home-feature__title">{title}</h2>
@@ -59,7 +58,7 @@ function HomeFeatureItem({ feature }: { feature: Feature }): JSX.Element {
59
58
  <p
60
59
  className="rp-home-feature__detail"
61
60
  {...renderHtmlOrText(details)}
62
- ></p>
61
+ />
63
62
  </article>
64
63
  </div>
65
64
  {shineDom}
@@ -6,6 +6,7 @@
6
6
  import { useI18n } from '@rspress/core/runtime';
7
7
  import { IconCopy, IconSuccess } from '@theme';
8
8
  import { useCallback, useRef, useState } from 'react';
9
+ import { SvgWrapper } from '../SvgWrapper';
9
10
  import './index.scss';
10
11
  import './LlmsCopyButton.scss';
11
12
  import { useMdUrl } from './useMdUrl';
@@ -85,8 +86,14 @@ export function LlmsCopyButton(props: LlmsCopyButtonProps) {
85
86
  onClick={onClick ?? handleClick}
86
87
  >
87
88
  <div className="rp-llms-copy-button__icon-wrapper">
88
- <IconSuccess className="rp-llms-copy-button__icon-success" />
89
- <IconCopy className="rp-llms-copy-button__icon-copy" />
89
+ <SvgWrapper
90
+ icon={IconSuccess}
91
+ className="rp-llms-copy-button__icon-success"
92
+ />
93
+ <SvgWrapper
94
+ icon={IconCopy}
95
+ className="rp-llms-copy-button__icon-copy"
96
+ />
90
97
  </div>
91
98
  <span>{t('copyMarkdownText')}</span>
92
99
  </button>
@@ -4,9 +4,10 @@
4
4
  * @license MIT
5
5
  */
6
6
  import { useI18n, useSite } from '@rspress/core/runtime';
7
- import { IconDown } from '@theme';
7
+ import { IconDown, IconExternalLink, IconLink } from '@theme';
8
8
  import type React from 'react';
9
9
  import { useEffect, useMemo, useRef, useState } from 'react';
10
+ import { SvgWrapper } from '../SvgWrapper';
10
11
  import './index.scss';
11
12
  import './LlmsViewOptions.scss';
12
13
  import { useMdUrl } from './useMdUrl';
@@ -48,40 +49,6 @@ export interface LlmsViewOptionsProps
48
49
  text?: string;
49
50
  }
50
51
 
51
- const IconExternalLink = () => {
52
- return (
53
- <svg
54
- xmlns="http://www.w3.org/2000/svg"
55
- width="16"
56
- height="16"
57
- viewBox="0 0 16 16"
58
- fill="none"
59
- >
60
- <path
61
- d="M9.33301 2H13.9997V6.66667"
62
- stroke="currentColor"
63
- strokeWidth="1.33333"
64
- strokeLinecap="round"
65
- strokeLinejoin="round"
66
- />
67
- <path
68
- d="M14 9.82457V13C14 13.5523 13.5523 14 13 14H3C2.44772 14 2 13.5523 2 13V3C2 2.44772 2.44772 2 3 2H6"
69
- stroke="currentColor"
70
- strokeWidth="1.33333"
71
- strokeLinecap="round"
72
- strokeLinejoin="round"
73
- />
74
- <path
75
- d="M8.59961 7.39996L13.6996 2.29996"
76
- stroke="currentColor"
77
- strokeWidth="1.33333"
78
- strokeLinecap="round"
79
- strokeLinejoin="round"
80
- />
81
- </svg>
82
- );
83
- };
84
-
85
52
  const DEFAULT_OPTIONS: Option[] = ['markdownLink', 'chatgpt', 'claude'];
86
53
 
87
54
  export function LlmsViewOptions({
@@ -129,25 +96,7 @@ export function LlmsViewOptions({
129
96
  return {
130
97
  markdownLink: {
131
98
  title: t('copyMarkdownLinkText'),
132
- icon: (
133
- <svg
134
- xmlns="http://www.w3.org/2000/svg"
135
- viewBox="0 0 24 24"
136
- width="24"
137
- height="24"
138
- >
139
- <g
140
- fill="none"
141
- stroke="currentColor"
142
- strokeLinecap="round"
143
- strokeLinejoin="round"
144
- strokeWidth="2"
145
- >
146
- <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" />
147
- <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />
148
- </g>
149
- </svg>
150
- ),
99
+ icon: <SvgWrapper icon={IconLink} />,
151
100
  onClick: () => {
152
101
  navigator.clipboard.writeText(fullMarkdownUrl);
153
102
  },
@@ -200,7 +149,8 @@ export function LlmsViewOptions({
200
149
  isOpen ? 'rp-llms-view-options__trigger--active' : ''
201
150
  }`}
202
151
  >
203
- <IconDown
152
+ <SvgWrapper
153
+ icon={IconDown}
204
154
  className={`rp-llms-view-options__arrow ${isOpen ? 'rp-llms-view-options__arrow--rotated' : ''}`}
205
155
  />
206
156
  {isOpen && (
@@ -233,7 +183,7 @@ export function LlmsViewOptions({
233
183
  </span>
234
184
  <span>{displayItem.title}</span>
235
185
  <span className="rp-llms-view-options__external-icon">
236
- <IconExternalLink />
186
+ <SvgWrapper icon={IconExternalLink} />
237
187
  </span>
238
188
  </a>
239
189
  );
@@ -82,7 +82,9 @@ export function Overview(props: {
82
82
 
83
83
  // Added effect to focus search input on mount
84
84
  useEffect(() => {
85
- searchRef.current?.focus();
85
+ if (frontmatter.overview === true) {
86
+ searchRef.current?.focus();
87
+ }
86
88
  }, []);
87
89
 
88
90
  const subFilter = (link: string) =>
@@ -50,7 +50,7 @@ function OverviewGroupMarkdown({ group }: { group: Group }) {
50
50
  export interface GroupItem {
51
51
  text: string;
52
52
  link: string;
53
- headers?: Header[];
53
+ headers?: Omit<Header, 'charIndex'>[];
54
54
 
55
55
  // For customization
56
56
  items?: { text: string; link: string }[];
@@ -1,19 +1,53 @@
1
+ import { renderHtmlOrText } from '@theme';
2
+
3
+ /**
4
+ * Check if a string is a URL or file path
5
+ */
6
+ function isUrlOrPath(str: string): boolean {
7
+ return (
8
+ str.startsWith('/') ||
9
+ str.startsWith('./') ||
10
+ str.startsWith('../') ||
11
+ str.startsWith('http://') ||
12
+ str.startsWith('https://') ||
13
+ str.startsWith('data:')
14
+ );
15
+ }
16
+
17
+ type SvgWrapperProps = {
18
+ icon: string | React.FC<React.SVGProps<SVGSVGElement>>;
19
+ } & React.SVGProps<SVGSVGElement>;
20
+
1
21
  /**
2
22
  * A wrapper for custom SVG icon.
3
23
  * When the user uses a custom SVG, the imported icon can be a string or a React component.
24
+ * - React component: render directly
25
+ * - SVG string (starts with `<svg`): render with dangerouslySetInnerHTML
26
+ * - URL/path: render with `<img>`
27
+ * - Other strings (emoji/text/HTML): render with renderHtmlOrText
4
28
  * @internal
5
29
  */
6
- export function SvgWrapper({
7
- icon: Icon,
8
- ...rest
9
- }: {
10
- icon: string | React.FC<React.SVGProps<SVGSVGElement>>;
11
- } & React.SVGAttributes<SVGSVGElement | HTMLImageElement>) {
30
+ export function SvgWrapper({ icon: Icon, ...rest }: SvgWrapperProps) {
12
31
  if (!Icon) {
13
32
  return null;
14
33
  }
15
34
  if (typeof Icon === 'string') {
16
- return <img src={Icon} alt="" {...rest} />;
35
+ const { className } = rest;
36
+ // SVG inline string
37
+ if (Icon.trim().startsWith('<svg')) {
38
+ return (
39
+ <span
40
+ className={className}
41
+ dangerouslySetInnerHTML={{ __html: Icon }}
42
+ />
43
+ );
44
+ }
45
+ // URL or file path
46
+ if (isUrlOrPath(Icon)) {
47
+ return <img className={className} src={Icon} alt="" />;
48
+ }
49
+ // Fallback: emoji/text/HTML
50
+ return <span className={className} {...renderHtmlOrText(Icon)} />;
17
51
  }
18
52
 
19
53
  return <Icon {...rest} />;
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ export { build } from "./node/build.js";
5
5
  export { defineConfig } from "./config/defineConfig.js";
6
6
  export { dev } from "./node/dev.js";
7
7
  export { logger } from "./6289.29817fb4.js";
8
- export { matchPath } from "./7786.421b464f.js";
8
+ export { matchPath } from "./9446.421b464f.js";
9
9
  export { remarkFileCodeBlock } from "./node/mdx/remarkPlugins/fileCodeBlock.js";
10
10
  export { remarkLink } from "./node/mdx/remarkPlugins/link.js";
11
11
  export { serve } from "./node/serve.js";
@@ -1,5 +1,5 @@
1
1
  import { node_path } from "../../6289.29817fb4.js";
2
- import { DEFAULT_PAGE_EXTENSIONS } from "../../7786.421b464f.js";
2
+ import { DEFAULT_PAGE_EXTENSIONS } from "../../9446.421b464f.js";
3
3
  import { processLocales, combineWalkResult } from "./locales.js";
4
4
  import { walk } from "./walk.js";
5
5
  async function runAutoNavSide(config, metaFileSet, mdFileSet) {
@@ -1,4 +1,4 @@
1
- import { createRequire, package_namespaceObject } from "../5485.7586c86a.js";
1
+ import { createRequire, package_namespaceObject } from "../5485.e8bfcd99.js";
2
2
  import { node_path } from "../6289.29817fb4.js";
3
3
  const constants_require = createRequire(import.meta.url);
4
4
  const RSPRESS_VERSION = package_namespaceObject.rE;
@@ -1,7 +1,7 @@
1
- import { createRequire, fileURLToPath, package_namespaceObject } from "../5485.7586c86a.js";
1
+ import { createRequire, fileURLToPath, package_namespaceObject } from "../5485.e8bfcd99.js";
2
2
  import { node_path } from "../6289.29817fb4.js";
3
3
  import { removeTrailingSlash, MDX_OR_MD_REGEXP, cwd } from "../9348.1beb3e25.js";
4
- import { PLUGIN_REACT_NAME, pluginReact, pluginVirtualModule } from "../7786.421b464f.js";
4
+ import { PLUGIN_REACT_NAME, pluginReact, pluginVirtualModule } from "../9446.421b464f.js";
5
5
  import { createError } from "./utils/error.js";
6
6
  import { PUBLIC_DIR, CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, inlineThemeScript, NODE_SSG_BUNDLE_FOLDER, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
7
7
  import { hintBuilderPluginsBreakingChange, hintThemeBreakingChange } from "./logger/hint.js";
@@ -190,6 +190,13 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
190
190
  }
191
191
  },
192
192
  tools: {
193
+ swc: {
194
+ jsc: {
195
+ transform: {
196
+ verbatimModuleSyntax: false
197
+ }
198
+ }
199
+ },
193
200
  bundlerChain (chain, { CHAIN_ID, environment }) {
194
201
  const isSsg = 'node' === environment.name;
195
202
  const isSsgMd = 'node_md' === environment.name;
@@ -292,6 +299,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
292
299
  output: {
293
300
  emitAssets: false,
294
301
  target: 'node',
302
+ module: false,
295
303
  minify: false
296
304
  }
297
305
  }
@@ -331,6 +339,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
331
339
  output: {
332
340
  emitAssets: false,
333
341
  target: 'node',
342
+ module: false,
334
343
  minify: false
335
344
  }
336
345
  }
@@ -1,4 +1,4 @@
1
- import { execa } from "../../0~7675.d236b058.js";
1
+ import { execa } from "../../0~7675.efbf8813.js";
2
2
  function transform(timestamp, lang) {
3
3
  return new Date(timestamp).toLocaleString(lang || 'zh');
4
4
  }
@@ -1,6 +1,6 @@
1
1
  import { node_path, promises } from "../../6289.29817fb4.js";
2
2
  import { RSPRESS_TEMP_DIR, removeTrailingSlash, addTrailingSlash } from "../../9348.1beb3e25.js";
3
- import { DEFAULT_PAGE_EXTENSIONS, glob } from "../../7786.421b464f.js";
3
+ import { DEFAULT_PAGE_EXTENSIONS, glob } from "../../9446.421b464f.js";
4
4
  import { PUBLIC_DIR } from "../constants.js";
5
5
  import { RoutePage, absolutePathToRoutePath, absolutePathToRelativePath } from "./RoutePage.js";
6
6
  import { createError } from "../utils/error.js";
@@ -1,6 +1,6 @@
1
1
  import { node_path, promises } from "../../6289.29817fb4.js";
2
2
  import { unified, visit, remark_gfm, loadFrontMatter, remark_stringify, MDX_OR_MD_REGEXP } from "../../9348.1beb3e25.js";
3
- import { remove, remark_parse } from "../../7786.421b464f.js";
3
+ import { remove, remark_parse } from "../../9446.421b464f.js";
4
4
  import { applyReplaceRules } from "../utils/applyReplaceRules.js";
5
5
  import { flattenMdxContent } from "../utils/flattenMdxContent.js";
6
6
  import { importStatementRegex } from "../constants.js";
@@ -1,5 +1,5 @@
1
1
  import { addTrailingSlash, addLeadingSlash } from "../../9348.1beb3e25.js";
2
- import { DEFAULT_PAGE_EXTENSIONS } from "../../7786.421b464f.js";
2
+ import { DEFAULT_PAGE_EXTENSIONS } from "../../9446.421b464f.js";
3
3
  const getRoutePathParts = (relativePath, lang, version, langs, versions)=>{
4
4
  const [versionPart, langPart, purePath] = splitRoutePathParts(relativePath, lang, version, langs, versions);
5
5
  return [
@@ -1,4 +1,4 @@
1
- import { createRequire } from "../../5485.7586c86a.js";
1
+ import { createRequire } from "../../5485.e8bfcd99.js";
2
2
  import { picocolors, join, logger } from "../../6289.29817fb4.js";
3
3
  import { DEFAULT_I18N_TEXT } from "./DEFAULT_I18N_TEXT.js";
4
4
  import { createError } from "../utils/error.js";
@@ -1,5 +1,5 @@
1
1
  import { SEARCH_INDEX_NAME } from "../../../9348.1beb3e25.js";
2
- import { groupBy } from "../../../7786.421b464f.js";
2
+ import { groupBy } from "../../../9446.421b464f.js";
3
3
  import { extractPageData } from "../../route/extractPageData.js";
4
4
  import { createHash } from "../../utils/createHash.js";
5
5
  function deletePrivateField(obj) {
@@ -1,5 +1,5 @@
1
1
  import { logger } from "../../../6289.29817fb4.js";
2
- import { pluginVirtualModule } from "../../../7786.421b464f.js";
2
+ import { pluginVirtualModule } from "../../../9446.421b464f.js";
3
3
  import { createPageData } from "./createPageData.js";
4
4
  const rsbuildPluginDocVM = async ({ config, userDocRoot, routeService, pluginDriver })=>{
5
5
  const ref = {
@@ -1,4 +1,4 @@
1
- import { mergeRsbuildConfig } from "../7786.421b464f.js";
1
+ import { mergeRsbuildConfig } from "../9446.421b464f.js";
2
2
  import { PluginDriver } from "./PluginDriver.js";
3
3
  import { initRsbuild } from "./initRsbuild.js";
4
4
  import { RouteService } from "./route/RouteService.js";
@@ -1,4 +1,4 @@
1
- import { transformHtmlTemplate, pathToFileURL, createHead } from "../../5485.7586c86a.js";
1
+ import { transformHtmlTemplate, pathToFileURL, createHead } from "../../5485.e8bfcd99.js";
2
2
  import { logger, picocolors } from "../../6289.29817fb4.js";
3
3
  import { hintSSGFailed } from "../logger/hint.js";
4
4
  import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
@@ -1,6 +1,6 @@
1
1
  import { workerData } from "./renderPageWorker.165b5d46.js";
2
2
  import { createError } from "../utils/error.js";
3
- import { pMap } from "../../5485.7586c86a.js";
3
+ import { pMap } from "../../5485.e8bfcd99.js";
4
4
  import { renderPage } from "./renderPage.js";
5
5
  const params = workerData?.[1]?.params;
6
6
  if (!params) throw createError('SSG Worker Thread workerData params missing');
@@ -1,8 +1,8 @@
1
1
  /*! For license information please see renderPages.js.LICENSE.txt */
2
2
  import { logger, picocolors } from "../../6289.29817fb4.js";
3
- import { chunk } from "../../7786.421b464f.js";
3
+ import { chunk } from "../../9446.421b464f.js";
4
4
  import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
5
- import { pMap } from "../../5485.7586c86a.js";
5
+ import { pMap } from "../../5485.e8bfcd99.js";
6
6
  import { renderPage } from "./renderPage.js";
7
7
  import { hintSSGFailed } from "../logger/hint.js";
8
8
  import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
@@ -1,5 +1,5 @@
1
1
  import { getSidebarDataGroup } from "../../../9348.1beb3e25.js";
2
- import { matchPath } from "../../../7786.421b464f.js";
2
+ import { matchPath } from "../../../9446.421b464f.js";
3
3
  import { generateLlmsTxt, generateLlmsFullTxt } from "./llmsTxt.js";
4
4
  async function emitLlmsTxt(config, routeService, emitAsset, mdContents) {
5
5
  const base = config.base ?? '/';
@@ -1,4 +1,4 @@
1
- import { pathToFileURL, createHead } from "../../5485.7586c86a.js";
1
+ import { pathToFileURL, createHead } from "../../5485.e8bfcd99.js";
2
2
  import { logger, picocolors } from "../../6289.29817fb4.js";
3
3
  import { hintSSGFailed } from "../logger/hint.js";
4
4
  async function renderPage(route, ssrBundlePath) {
@@ -1,5 +1,5 @@
1
1
  import { logger, picocolors } from "../../6289.29817fb4.js";
2
- import { pMap } from "../../5485.7586c86a.js";
2
+ import { pMap } from "../../5485.e8bfcd99.js";
3
3
  import { renderPage } from "./renderPage.js";
4
4
  import { SSGConcurrency } from "../ssg/ssgEnv.js";
5
5
  const routePage2MdFilename = (routePath)=>{
@@ -1,4 +1,4 @@
1
- import { createHash as external_node_crypto_createHash } from "../../7786.421b464f.js";
1
+ import { createHash as external_node_crypto_createHash } from "../../9446.421b464f.js";
2
2
  function createHash(str) {
3
3
  return external_node_crypto_createHash('sha256').update(str).digest('hex').slice(0, 8);
4
4
  }
@@ -1,4 +1,4 @@
1
- import { node_fs, core_rspack } from "../../7786.421b464f.js";
1
+ import { node_fs, core_rspack } from "../../9446.421b464f.js";
2
2
  import { node_path, logger } from "../../6289.29817fb4.js";
3
3
  import { createProcessor, MDX_OR_MD_REGEXP } from "../../9348.1beb3e25.js";
4
4
  import { createError } from "./error.js";
@@ -1,5 +1,5 @@
1
1
  import { node_path, logger, picocolors } from "../../6289.29817fb4.js";
2
- import { core_rspack } from "../../7786.421b464f.js";
2
+ import { core_rspack } from "../../9446.421b464f.js";
3
3
  import { pathExists, readJson } from "./fs.js";
4
4
  import { PACKAGE_ROOT } from "../constants.js";
5
5
  import { hintReactVersion } from "../logger/hint.js";
@@ -1,5 +1,6 @@
1
1
  import type { PageDataLegacy } from '@rspress/shared';
2
2
  /**
3
3
  * should use `usePage` and `useSite` instead
4
+ * @deprecated
4
5
  */
5
6
  export declare function usePageData(): PageDataLegacy;
@@ -0,0 +1,16 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import "react";
3
+ const SvgExternalLink = (props)=>/*#__PURE__*/ jsx("svg", {
4
+ xmlns: "http://www.w3.org/2000/svg",
5
+ width: 16,
6
+ height: 16,
7
+ fill: "none",
8
+ viewBox: "0 0 16 16",
9
+ ...props,
10
+ children: /*#__PURE__*/ jsx("path", {
11
+ stroke: "currentColor",
12
+ d: "M9.333 2H14v4.667M14 9.825V13a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h3M8.6 7.4l5.1-5.1"
13
+ })
14
+ });
15
+ var external_link = SvgExternalLink;
16
+ export { external_link as default };
@@ -0,0 +1,26 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import "react";
3
+ const SvgLink = (props)=>/*#__PURE__*/ jsx("svg", {
4
+ xmlns: "http://www.w3.org/2000/svg",
5
+ width: 24,
6
+ height: 24,
7
+ viewBox: "0 0 24 24",
8
+ ...props,
9
+ children: /*#__PURE__*/ jsxs("g", {
10
+ fill: "none",
11
+ stroke: "currentColor",
12
+ strokeLinecap: "round",
13
+ strokeLinejoin: "round",
14
+ strokeWidth: 2,
15
+ children: [
16
+ /*#__PURE__*/ jsx("path", {
17
+ d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"
18
+ }),
19
+ /*#__PURE__*/ jsx("path", {
20
+ d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"
21
+ })
22
+ ]
23
+ })
24
+ });
25
+ var assets_link = SvgLink;
26
+ export { assets_link as default };
@@ -87,6 +87,11 @@
87
87
  display: inline-flex;
88
88
  }
89
89
 
90
+ .rp-home-feature__icon img, .rp-home-feature__icon svg {
91
+ width: 1.5rem;
92
+ height: 1.5rem;
93
+ }
94
+
90
95
  .rp-home-feature__title {
91
96
  text-align: left;
92
97
  margin: 0;
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useFrontmatter } from "@rspress/core/runtime";
3
- import { renderHtmlOrText, useLinkNavigate } from "@theme";
3
+ import { SvgWrapper, renderHtmlOrText, useLinkNavigate } from "@theme";
4
4
  import "./index.css";
5
5
  import { useCardAnimation } from "./useCardAnimation.js";
6
6
  const getGridClass = (feature)=>{
@@ -43,7 +43,9 @@ function HomeFeatureItem({ feature }) {
43
43
  children: [
44
44
  icon ? /*#__PURE__*/ jsx("div", {
45
45
  className: "rp-home-feature__icon",
46
- ...renderHtmlOrText(icon)
46
+ children: /*#__PURE__*/ jsx(SvgWrapper, {
47
+ icon: icon
48
+ })
47
49
  }) : null,
48
50
  /*#__PURE__*/ jsx("h2", {
49
51
  className: "rp-home-feature__title",
@@ -3,6 +3,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useI18n } from "@rspress/core/runtime";
4
4
  import { IconCopy, IconSuccess } from "@theme";
5
5
  import { useCallback, useRef, useState } from "react";
6
+ import { SvgWrapper } from "../SvgWrapper/index.js";
6
7
  import "./index.css";
7
8
  import "./LlmsCopyButton.css";
8
9
  import { useMdUrl } from "./useMdUrl.js";
@@ -56,10 +57,12 @@ function LlmsCopyButton(props) {
56
57
  /*#__PURE__*/ jsxs("div", {
57
58
  className: "rp-llms-copy-button__icon-wrapper",
58
59
  children: [
59
- /*#__PURE__*/ jsx(IconSuccess, {
60
+ /*#__PURE__*/ jsx(SvgWrapper, {
61
+ icon: IconSuccess,
60
62
  className: "rp-llms-copy-button__icon-success"
61
63
  }),
62
- /*#__PURE__*/ jsx(IconCopy, {
64
+ /*#__PURE__*/ jsx(SvgWrapper, {
65
+ icon: IconCopy,
63
66
  className: "rp-llms-copy-button__icon-copy"
64
67
  })
65
68
  ]
@@ -1,8 +1,9 @@
1
1
  /*! For license information please see LlmsViewOptions.js.LICENSE.txt */
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useI18n, useSite } from "@rspress/core/runtime";
4
- import { IconDown } from "@theme";
4
+ import { IconDown, IconExternalLink, IconLink } from "@theme";
5
5
  import { useEffect, useMemo, useRef, useState } from "react";
6
+ import { SvgWrapper } from "../SvgWrapper/index.js";
6
7
  import "./index.css";
7
8
  import "./LlmsViewOptions.css";
8
9
  import { useMdUrl } from "./useMdUrl.js";
@@ -10,37 +11,7 @@ import { useMdUrl } from "./useMdUrl.js";
10
11
  * Inspired from fumadocs docsite
11
12
  * @from https://github.com/fuma-nama/fumadocs/blob/5723bbe58ef805a5421a780abf235a10b251be2f/apps/docs/app/docs/%5B...slug%5D/page.client.tsx#L11
12
13
  * @license MIT
13
- */ const IconExternalLink = ()=>/*#__PURE__*/ jsxs("svg", {
14
- xmlns: "http://www.w3.org/2000/svg",
15
- width: "16",
16
- height: "16",
17
- viewBox: "0 0 16 16",
18
- fill: "none",
19
- children: [
20
- /*#__PURE__*/ jsx("path", {
21
- d: "M9.33301 2H13.9997V6.66667",
22
- stroke: "currentColor",
23
- strokeWidth: "1.33333",
24
- strokeLinecap: "round",
25
- strokeLinejoin: "round"
26
- }),
27
- /*#__PURE__*/ jsx("path", {
28
- d: "M14 9.82457V13C14 13.5523 13.5523 14 13 14H3C2.44772 14 2 13.5523 2 13V3C2 2.44772 2.44772 2 3 2H6",
29
- stroke: "currentColor",
30
- strokeWidth: "1.33333",
31
- strokeLinecap: "round",
32
- strokeLinejoin: "round"
33
- }),
34
- /*#__PURE__*/ jsx("path", {
35
- d: "M8.59961 7.39996L13.6996 2.29996",
36
- stroke: "currentColor",
37
- strokeWidth: "1.33333",
38
- strokeLinecap: "round",
39
- strokeLinejoin: "round"
40
- })
41
- ]
42
- });
43
- const DEFAULT_OPTIONS = [
14
+ */ const DEFAULT_OPTIONS = [
44
15
  'markdownLink',
45
16
  'chatgpt',
46
17
  'claude'
@@ -71,26 +42,8 @@ function LlmsViewOptions({ options: propsOptions }) {
71
42
  return {
72
43
  markdownLink: {
73
44
  title: t('copyMarkdownLinkText'),
74
- icon: /*#__PURE__*/ jsx("svg", {
75
- xmlns: "http://www.w3.org/2000/svg",
76
- viewBox: "0 0 24 24",
77
- width: "24",
78
- height: "24",
79
- children: /*#__PURE__*/ jsxs("g", {
80
- fill: "none",
81
- stroke: "currentColor",
82
- strokeLinecap: "round",
83
- strokeLinejoin: "round",
84
- strokeWidth: "2",
85
- children: [
86
- /*#__PURE__*/ jsx("path", {
87
- d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"
88
- }),
89
- /*#__PURE__*/ jsx("path", {
90
- d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"
91
- })
92
- ]
93
- })
45
+ icon: /*#__PURE__*/ jsx(SvgWrapper, {
46
+ icon: IconLink
94
47
  }),
95
48
  onClick: ()=>{
96
49
  navigator.clipboard.writeText(fullMarkdownUrl);
@@ -155,7 +108,8 @@ function LlmsViewOptions({ options: propsOptions }) {
155
108
  onClick: toggleDropdown,
156
109
  className: `rp-llms-button rp-llms-view-options__trigger ${isOpen ? 'rp-llms-view-options__trigger--active' : ''}`,
157
110
  children: [
158
- /*#__PURE__*/ jsx(IconDown, {
111
+ /*#__PURE__*/ jsx(SvgWrapper, {
112
+ icon: IconDown,
159
113
  className: `rp-llms-view-options__arrow ${isOpen ? 'rp-llms-view-options__arrow--rotated' : ''}`
160
114
  }),
161
115
  isOpen && /*#__PURE__*/ jsx("div", {
@@ -180,7 +134,9 @@ function LlmsViewOptions({ options: propsOptions }) {
180
134
  }),
181
135
  /*#__PURE__*/ jsx("span", {
182
136
  className: "rp-llms-view-options__external-icon",
183
- children: /*#__PURE__*/ jsx(IconExternalLink, {})
137
+ children: /*#__PURE__*/ jsx(SvgWrapper, {
138
+ icon: IconExternalLink
139
+ })
184
140
  })
185
141
  ]
186
142
  }, displayItem.title);
@@ -36,7 +36,7 @@ function Overview(props) {
36
36
  const [query, setQuery] = useState('');
37
37
  const searchRef = useRef(null);
38
38
  useEffect(()=>{
39
- searchRef.current?.focus();
39
+ if (true === frontmatter.overview) searchRef.current?.focus();
40
40
  }, []);
41
41
  const subFilter = (link)=>link.startsWith(routePath.replace(/overview$/, '')) && !isEqualPath(link, routePath);
42
42
  const getChildLink = (traverseItem)=>{
@@ -3,7 +3,7 @@ import type { Header } from '@rspress/core';
3
3
  export interface GroupItem {
4
4
  text: string;
5
5
  link: string;
6
- headers?: Header[];
6
+ headers?: Omit<Header, 'charIndex'>[];
7
7
  items?: {
8
8
  text: string;
9
9
  link: string;
@@ -1,8 +1,14 @@
1
+ type SvgWrapperProps = {
2
+ icon: string | React.FC<React.SVGProps<SVGSVGElement>>;
3
+ } & React.SVGProps<SVGSVGElement>;
1
4
  /**
2
5
  * A wrapper for custom SVG icon.
3
6
  * When the user uses a custom SVG, the imported icon can be a string or a React component.
7
+ * - React component: render directly
8
+ * - SVG string (starts with `<svg`): render with dangerouslySetInnerHTML
9
+ * - URL/path: render with `<img>`
10
+ * - Other strings (emoji/text/HTML): render with renderHtmlOrText
4
11
  * @internal
5
12
  */
6
- export declare function SvgWrapper({ icon: Icon, ...rest }: {
7
- icon: string | React.FC<React.SVGProps<SVGSVGElement>>;
8
- } & React.SVGAttributes<SVGSVGElement | HTMLImageElement>): import("react/jsx-runtime").JSX.Element | null;
13
+ export declare function SvgWrapper({ icon: Icon, ...rest }: SvgWrapperProps): import("react/jsx-runtime").JSX.Element | null;
14
+ export {};
@@ -1,11 +1,28 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
+ import { renderHtmlOrText } from "@theme";
3
+ function isUrlOrPath(str) {
4
+ return str.startsWith('/') || str.startsWith('./') || str.startsWith('../') || str.startsWith('http://') || str.startsWith('https://') || str.startsWith('data:');
5
+ }
2
6
  function SvgWrapper({ icon: Icon, ...rest }) {
3
7
  if (!Icon) return null;
4
- if ('string' == typeof Icon) return /*#__PURE__*/ jsx("img", {
5
- src: Icon,
6
- alt: "",
7
- ...rest
8
- });
8
+ if ('string' == typeof Icon) {
9
+ const { className } = rest;
10
+ if (Icon.trim().startsWith('<svg')) return /*#__PURE__*/ jsx("span", {
11
+ className: className,
12
+ dangerouslySetInnerHTML: {
13
+ __html: Icon
14
+ }
15
+ });
16
+ if (isUrlOrPath(Icon)) return /*#__PURE__*/ jsx("img", {
17
+ className: className,
18
+ src: Icon,
19
+ alt: ""
20
+ });
21
+ return /*#__PURE__*/ jsx("span", {
22
+ className: className,
23
+ ...renderHtmlOrText(Icon)
24
+ });
25
+ }
9
26
  return /*#__PURE__*/ jsx(Icon, {
10
27
  ...rest
11
28
  });
@@ -15,13 +15,13 @@ export declare const IconJump: Icon;
15
15
  export declare const IconLoading: Icon;
16
16
  export declare const IconMenu: Icon;
17
17
  export declare const IconMoon: Icon;
18
- export declare const IconRight: Icon;
19
18
  export declare const IconSearch: Icon;
20
19
  export declare const IconSmallMenu: Icon;
21
20
  export declare const IconSuccess: Icon;
22
21
  export declare const IconSun: Icon;
23
22
  export declare const IconTitle: Icon;
24
- export declare const IconTranslator: Icon;
25
23
  export declare const IconWrap: Icon;
26
24
  export declare const IconWrapped: Icon;
25
+ export declare const IconExternalLink: Icon;
26
+ export declare const IconLink: Icon;
27
27
  export {};
@@ -6,21 +6,21 @@ import deprecated from "./assets/deprecated.js";
6
6
  import down from "./assets/down.js";
7
7
  import empty from "./assets/empty.js";
8
8
  import experimental from "./assets/experimental.js";
9
+ import external_link from "./assets/external-link.js";
9
10
  import file from "./assets/file.js";
10
11
  import github from "./assets/github.js";
11
12
  import gitlab from "./assets/gitlab.js";
12
13
  import header from "./assets/header.js";
13
14
  import jump from "./assets/jump.js";
15
+ import assets_link from "./assets/link.js";
14
16
  import loading from "./assets/loading.js";
15
17
  import menu from "./assets/menu.js";
16
18
  import moon from "./assets/moon.js";
17
- import right from "./assets/right.js";
18
19
  import search from "./assets/search.js";
19
20
  import small_menu from "./assets/small-menu.js";
20
21
  import success from "./assets/success.js";
21
22
  import sun from "./assets/sun.js";
22
23
  import title from "./assets/title.js";
23
- import translator from "./assets/translator.js";
24
24
  import wrap from "./assets/wrap.js";
25
25
  import wrapped from "./assets/wrapped.js";
26
26
  const IconDeprecated = deprecated;
@@ -39,13 +39,13 @@ const IconJump = jump;
39
39
  const IconLoading = loading;
40
40
  const IconMenu = menu;
41
41
  const IconMoon = moon;
42
- const IconRight = right;
43
42
  const IconSearch = search;
44
43
  const IconSmallMenu = small_menu;
45
44
  const IconSuccess = success;
46
45
  const IconSun = sun;
47
46
  const IconTitle = title;
48
- const IconTranslator = translator;
49
47
  const IconWrap = wrap;
50
48
  const IconWrapped = wrapped;
51
- export { IconArrowDown, IconArrowRight, IconClose, IconCopy, IconDeprecated, IconDown, IconEmpty, IconExperimental, IconFile, IconGithub, IconGitlab, IconHeader, IconJump, IconLoading, IconMenu, IconMoon, IconRight, IconSearch, IconSmallMenu, IconSuccess, IconSun, IconTitle, IconTranslator, IconWrap, IconWrapped };
49
+ const IconExternalLink = external_link;
50
+ const IconLink = assets_link;
51
+ export { IconArrowDown, IconArrowRight, IconClose, IconCopy, IconDeprecated, IconDown, IconEmpty, IconExperimental, IconExternalLink, IconFile, IconGithub, IconGitlab, IconHeader, IconJump, IconLink, IconLoading, IconMenu, IconMoon, IconSearch, IconSmallMenu, IconSuccess, IconSun, IconTitle, IconWrap, IconWrapped };
@@ -21,6 +21,7 @@ function scrollToTarget(target) {
21
21
  function useScrollAfterNav() {
22
22
  const location = useLocation();
23
23
  useLayoutEffect(()=>{
24
+ if ("u" < typeof window) return;
24
25
  const decodedHash = decodeURIComponent(window.location.hash);
25
26
  if (decodedHash.length > 0) {
26
27
  const target = document.getElementById(decodedHash.slice(1));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "2.0.0-rc.6",
3
+ "version": "2.0.0-rc.7",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -63,7 +63,7 @@
63
63
  "dependencies": {
64
64
  "@mdx-js/mdx": "^3.1.1",
65
65
  "@mdx-js/react": "^3.1.1",
66
- "@rsbuild/core": "~1.7.2",
66
+ "@rsbuild/core": "2.0.0-alpha.2",
67
67
  "@rsbuild/plugin-react": "~1.4.3",
68
68
  "@shikijs/rehype": "^3.21.0",
69
69
  "@types/unist": "^3.0.3",
@@ -102,7 +102,7 @@
102
102
  "unist-util-remove": "^4.0.0",
103
103
  "unist-util-visit": "^5.0.0",
104
104
  "unist-util-visit-children": "^3.0.0",
105
- "@rspress/shared": "2.0.0-rc.6"
105
+ "@rspress/shared": "2.0.0-rc.7"
106
106
  },
107
107
  "devDependencies": {
108
108
  "@microsoft/api-extractor": "^7.55.2",
@@ -1,14 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import "react";
3
- const SvgRight = (props)=>/*#__PURE__*/ jsx("svg", {
4
- width: 32,
5
- height: 32,
6
- viewBox: "0 0 32 32",
7
- ...props,
8
- children: /*#__PURE__*/ jsx("path", {
9
- fill: "currentColor",
10
- d: "M10 6v2h12.59L6 24.59 7.41 26 24 9.41V22h2V6z"
11
- })
12
- });
13
- var right = SvgRight;
14
- export { right as default };
@@ -1,14 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import "react";
3
- const SvgTranslator = (props)=>/*#__PURE__*/ jsx("svg", {
4
- width: 18,
5
- height: 18,
6
- viewBox: "0 0 32 32",
7
- ...props,
8
- children: /*#__PURE__*/ jsx("path", {
9
- fill: "currentColor",
10
- d: "M27.85 29H30l-6-15h-2.35l-6 15h2.15l1.6-4h6.85zm-7.65-6 2.62-6.56L25.45 23zM18 7V5h-7V2H9v3H2v2h10.74a14.7 14.7 0 0 1-3.19 6.18A13.5 13.5 0 0 1 7.26 9h-2.1a16.5 16.5 0 0 0 3 5.58A16.8 16.8 0 0 1 3 18l.75 1.86A18.5 18.5 0 0 0 9.53 16a16.9 16.9 0 0 0 5.76 3.84L16 18a14.5 14.5 0 0 1-5.12-3.37A17.64 17.64 0 0 0 14.8 7z"
11
- })
12
- });
13
- var translator = SvgTranslator;
14
- export { translator as default };
File without changes