@rspress/core 2.0.15 → 2.0.16

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.
package/dist/9958.js CHANGED
@@ -1,5 +1,5 @@
1
1
  var package_namespaceObject = {
2
- rE: "2.0.15"
2
+ rE: "2.0.16"
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
@@ -20,8 +20,8 @@ logger.greet(landingMessage);
20
20
  const setNodeEnv = (env)=>{
21
21
  process.env.NODE_ENV = env;
22
22
  };
23
- cli.option('-c,--config [config]', 'Specify the path to the config file');
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)=>{
23
+ cli.option('-c, --config <config>', 'Set the configuration file (relative or absolute path)');
24
+ cli.command('[root]', 'Start the dev server').alias('dev').option('--port <port>', 'Set the port number for the server').option('--host [host]', 'Set the host that the server listens to').option('--base <base>', 'Set the base path and override config.base').action(async (root, options)=>{
25
25
  setNodeEnv('development');
26
26
  let isRestarting = false;
27
27
  const cwd = process.cwd();
@@ -83,7 +83,7 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
83
83
  process.on('SIGINT', exitProcess);
84
84
  process.on('SIGTERM', exitProcess);
85
85
  });
86
- cli.command('build [root]').option('--base <base>', 'deployment base path').action(async (root, options)=>{
86
+ cli.command('build [root]', 'Build the documentation site for production').option('--base <base>', 'Set the base path and override config.base').action(async (root, options)=>{
87
87
  setNodeEnv('production');
88
88
  const cwd = process.cwd();
89
89
  const { config, configFilePath } = await loadConfigFile(options.config);
@@ -101,7 +101,7 @@ cli.command('build [root]').option('--base <base>', 'deployment base path').acti
101
101
  process.exit(1);
102
102
  }
103
103
  });
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)=>{
104
+ cli.command('preview [root]', 'Preview the production build locally').alias('serve').option('--port <port>', 'Set the port number for the server').option('--host [host]', 'Set the host that the server listens to').option('--base <base>', 'Set the base path and override config.base').action(async (root, options)=>{
105
105
  setNodeEnv('production');
106
106
  const cwd = process.cwd();
107
107
  const { port, host } = options || {};
@@ -115,7 +115,7 @@ cli.command('preview [root]').alias('serve').option('--port [port]', 'port numbe
115
115
  configFilePath
116
116
  });
117
117
  });
118
- cli.command('eject [component]', 'Eject a theme component to customize it').action(async (component)=>{
118
+ cli.command('eject [component]', 'Eject a theme component for customization').action(async (component)=>{
119
119
  if (!component) return void await listComponents();
120
120
  const cwd = process.cwd();
121
121
  try {
@@ -18,6 +18,11 @@
18
18
  --rp-container-info-bg: rgba(0, 149, 255, 0.06);
19
19
  --rp-container-info-code-bg: rgba(0, 149, 255, 0.1);
20
20
 
21
+ --rp-container-important-border: rgba(137, 87, 229, 0.3);
22
+ --rp-container-important-text: #8250df;
23
+ --rp-container-important-bg: rgba(137, 87, 229, 0.08);
24
+ --rp-container-important-code-bg: rgba(137, 87, 229, 0.1);
25
+
21
26
  --rp-container-warning-border: rgba(255, 197, 23, 0.4);
22
27
  --rp-container-warning-text: #887233;
23
28
  --rp-container-warning-bg: rgba(255, 197, 23, 0.1);
@@ -52,6 +57,10 @@
52
57
  --rp-container-info-text: #66c2ff;
53
58
  --rp-container-info-bg: rgba(0, 149, 255, 0.1);
54
59
 
60
+ --rp-container-important-text: #b083f0;
61
+ --rp-container-important-border: rgba(137, 87, 229, 0.35);
62
+ --rp-container-important-bg: rgba(137, 87, 229, 0.12);
63
+
55
64
  --rp-container-warning-text: rgb(251, 180, 81);
56
65
  --rp-container-warning-border: rgba(255, 197, 23, 0.25);
57
66
  --rp-container-warning-bg: rgba(255, 197, 23, 0.12);
@@ -176,6 +185,29 @@
176
185
  }
177
186
  }
178
187
 
188
+ // important
189
+ .rp-callout--important {
190
+ border-color: var(--rp-container-important-border);
191
+ background-color: var(--rp-container-important-bg);
192
+
193
+ .rp-callout__title {
194
+ color: var(--rp-container-important-text);
195
+ &::before {
196
+ background-color: var(--rp-container-important-text);
197
+ }
198
+ }
199
+
200
+ // inline code
201
+ :not(pre) > code {
202
+ color: var(--rp-container-important-text);
203
+ background-color: var(--rp-container-important-code-bg);
204
+ }
205
+
206
+ a {
207
+ color: var(--rp-container-important-text);
208
+ }
209
+ }
210
+
179
211
  // warning
180
212
  .rp-callout--warning {
181
213
  border-color: var(--rp-container-warning-border);
@@ -2,7 +2,15 @@ import type { ReactNode } from 'react';
2
2
  import './index.scss';
3
3
 
4
4
  export interface CalloutProps {
5
- type: 'tip' | 'note' | 'warning' | 'caution' | 'danger' | 'info' | 'details';
5
+ type:
6
+ | 'tip'
7
+ | 'note'
8
+ | 'important'
9
+ | 'warning'
10
+ | 'caution'
11
+ | 'danger'
12
+ | 'info'
13
+ | 'details';
6
14
  title?: string;
7
15
  children: ReactNode;
8
16
  }
@@ -99,7 +99,7 @@ export function useLinkNavigate(
99
99
  return;
100
100
  }
101
101
  }
102
- navigate(removeBaseHref, { replace: false });
102
+ await navigate(removeBaseHref, { replace: false });
103
103
  };
104
104
 
105
105
  if (startTransition) {
@@ -1,7 +1,7 @@
1
1
  import type React from 'react';
2
2
  import './LlmsContainer.scss';
3
3
 
4
- export interface LlmsContainerProps extends React.HTMLAttributes<HTMLDivElement> {}
4
+ export type LlmsContainerProps = React.HTMLAttributes<HTMLDivElement>;
5
5
 
6
6
  export function LlmsContainer(props: LlmsContainerProps) {
7
7
  return <div {...props} className={'rp-not-doc rp-llms-container'} />;
@@ -109,8 +109,7 @@ export function Overview(props: {
109
109
  const { pages } = siteData;
110
110
  const overviewModules = pages.filter(page => subFilter(page.routePath));
111
111
  let overviewSidebarGroups = useSidebar() as (
112
- | NormalizedSidebarGroup
113
- | SidebarItem
112
+ NormalizedSidebarGroup | SidebarItem
114
113
  )[];
115
114
 
116
115
  if (overviewSidebarGroups[0]?.link !== routePath) {
@@ -17,10 +17,7 @@ function removeIndex(link: string) {
17
17
  */
18
18
  export function findItemByRoutePath(
19
19
  items: (
20
- | SidebarItem
21
- | NormalizedSidebarGroup
22
- | SidebarDivider
23
- | SidebarSectionHeader
20
+ SidebarItem | NormalizedSidebarGroup | SidebarDivider | SidebarSectionHeader
24
21
  )[],
25
22
  routePath: string,
26
23
  ): (SidebarItem | NormalizedSidebarGroup)[] {
@@ -61,8 +58,7 @@ export function findItemByRoutePath(
61
58
  }
62
59
 
63
60
  const matchRoutePathItem = items[matchRoutePathItemIndex] as
64
- | SidebarItem
65
- | NormalizedSidebarGroup;
61
+ SidebarItem | NormalizedSidebarGroup;
66
62
 
67
63
  const isArray = (i: unknown): i is Array<unknown> =>
68
64
  Array.isArray(i) && i.length >= 1;
@@ -75,8 +71,7 @@ export function findItemByRoutePath(
75
71
  }
76
72
 
77
73
  return matchRoutePathItem.items.filter(item => !isSidebarDivider(item)) as (
78
- | SidebarItem
79
- | NormalizedSidebarGroup
74
+ SidebarItem | NormalizedSidebarGroup
80
75
  )[];
81
76
  }
82
77
 
@@ -86,8 +81,7 @@ export function findItemByRoutePath(
86
81
  result.splice(matchRoutePathItemIndex, 1);
87
82
  }
88
83
  const res = result.filter(item => !isSidebarDivider(item)) as (
89
- | SidebarItem
90
- | NormalizedSidebarGroup
84
+ SidebarItem | NormalizedSidebarGroup
91
85
  )[];
92
86
 
93
87
  return res;
@@ -29,7 +29,9 @@ interface PageIndexForFlexSearch extends PageIndexInfo {
29
29
  // Create a type that satisfies DocumentData constraints by mapping all properties
30
30
  // to DocumentValue | DocumentValue[] while preserving the original structure
31
31
  type FlexSearchCompatibleData = {
32
- [K in keyof PageIndexForFlexSearch]: PageIndexForFlexSearch[K] extends DocumentValue
32
+ [
33
+ K in keyof PageIndexForFlexSearch
34
+ ]: PageIndexForFlexSearch[K] extends DocumentValue
33
35
  ? PageIndexForFlexSearch[K]
34
36
  : DocumentValue;
35
37
  } & {
@@ -2,8 +2,7 @@ import { useEffect } from 'react';
2
2
 
3
3
  function useClickOutside(
4
4
  ref:
5
- | React.RefObject<HTMLElement | null>
6
- | React.RefObject<HTMLElement | null>[],
5
+ React.RefObject<HTMLElement | null> | React.RefObject<HTMLElement | null>[],
7
6
  handler: (event: MouseEvent | TouchEvent) => void,
8
7
  ) {
9
8
  useEffect(() => {
@@ -13,10 +13,11 @@
13
13
  */
14
14
  import type { Root } from 'mdast';
15
15
  import type { Plugin } from 'unified';
16
- export declare const DIRECTIVE_TYPES: readonly ['tip', 'note', 'warning', 'caution', 'danger', 'info', 'details'];
16
+ export declare const DIRECTIVE_TYPES: readonly ['tip', 'note', 'important', 'warning', 'caution', 'danger', 'info', 'details'];
17
17
  export declare const REGEX_BEGIN: RegExp;
18
18
  export declare const REGEX_END: RegExp;
19
19
  export declare const REGEX_GH_BEGIN: RegExp;
20
+ export declare const REGEX_GH_MARKER: RegExp;
20
21
  export declare const TITLE_REGEX_IN_MD: RegExp;
21
22
  export declare const TITLE_REGEX_IN_MDX: RegExp;
22
23
  export type DirectiveType = (typeof DIRECTIVE_TYPES)[number];
@@ -2,6 +2,7 @@ import { getNamedImportAstNode } from "../../utils/getImportAstNode.js";
2
2
  const DIRECTIVE_TYPES = [
3
3
  'tip',
4
4
  'note',
5
+ 'important',
5
6
  'warning',
6
7
  'caution',
7
8
  'danger',
@@ -10,7 +11,8 @@ const DIRECTIVE_TYPES = [
10
11
  ];
11
12
  const REGEX_BEGIN = /^\s*:::\s*(\w+)\s*(.*)?/;
12
13
  const REGEX_END = /\s*:::$/;
13
- const REGEX_GH_BEGIN = /^\s*\s*\[!(\w+)\]\s*(.*)?/;
14
+ const REGEX_GH_BEGIN = /^\s*\[!(\w+)\]/;
15
+ const REGEX_GH_MARKER = /^\s*\[!\w+\][^\S\n]*\n?/;
14
16
  const TITLE_REGEX_IN_MD = /{\s*title=["']?(.+)}\s*/;
15
17
  const TITLE_REGEX_IN_MDX = /\s*title=["']?(.+)\s*/;
16
18
  const CALLOUT_COMPONENT = '$$$callout$$$';
@@ -50,7 +52,9 @@ function transformer(tree, warnUnknownType) {
50
52
  if (DIRECTIVE_TYPES.includes(type)) tree.children.splice(i, 1, createContainer(type, node.attributes?.title ?? type.toUpperCase(), node.children));
51
53
  else warnUnknownType(type);
52
54
  } else if ('blockquote' === node.type && node.children[0]?.type === 'paragraph' && node.children[0].children?.[0] && 'value' in node.children[0].children[0]) {
53
- const initiatorTag = node.children[0].children[0].value;
55
+ const firstParagraph = node.children[0];
56
+ const firstTextNode = firstParagraph.children[0];
57
+ const initiatorTag = firstTextNode.value;
54
58
  const match = initiatorTag.match(REGEX_GH_BEGIN);
55
59
  if (match) {
56
60
  const [, type] = match;
@@ -59,8 +63,10 @@ function transformer(tree, warnUnknownType) {
59
63
  i++;
60
64
  continue;
61
65
  }
62
- if (1 === node.children.length && 'paragraph' === node.children[0].type) node.children[0].children[0].value = match[2] ?? '';
63
- const newChild = createContainer(type.toLowerCase(), type.toUpperCase(), 0 === node.children.slice(1).length ? node.children.slice(0) : node.children.slice(1));
66
+ firstTextNode.value = initiatorTag.replace(REGEX_GH_MARKER, '');
67
+ const isFirstParagraphEmpty = firstParagraph.children.every((child)=>'text' === child.type && '' === child.value.trim());
68
+ const children = isFirstParagraphEmpty ? node.children.slice(1) : node.children;
69
+ const newChild = createContainer(type.toLowerCase(), type.toUpperCase(), children);
64
70
  tree.children.splice(i, 1, newChild);
65
71
  }
66
72
  }
@@ -184,13 +190,14 @@ const remarkContainerSyntax = ()=>{
184
190
  };
185
191
  return (tree)=>{
186
192
  transformer(tree, warnUnknownType);
187
- tree.children.unshift(getNamedImportAstNode('Callout', CALLOUT_COMPONENT, '@theme'));
193
+ tree.children.unshift(getNamedImportAstNode('Callout', CALLOUT_COMPONENT, '@rspress/core/theme'));
188
194
  };
189
195
  };
190
196
  var containerSyntax_DIRECTIVE_TYPES = void 0;
191
197
  var containerSyntax_REGEX_BEGIN = void 0;
192
198
  var containerSyntax_REGEX_END = void 0;
193
199
  var containerSyntax_REGEX_GH_BEGIN = void 0;
200
+ var containerSyntax_REGEX_GH_MARKER = void 0;
194
201
  var containerSyntax_TITLE_REGEX_IN_MD = void 0;
195
202
  var containerSyntax_TITLE_REGEX_IN_MDX = void 0;
196
- export { containerSyntax_DIRECTIVE_TYPES as DIRECTIVE_TYPES, containerSyntax_REGEX_BEGIN as REGEX_BEGIN, containerSyntax_REGEX_END as REGEX_END, containerSyntax_REGEX_GH_BEGIN as REGEX_GH_BEGIN, containerSyntax_TITLE_REGEX_IN_MD as TITLE_REGEX_IN_MD, containerSyntax_TITLE_REGEX_IN_MDX as TITLE_REGEX_IN_MDX, remarkContainerSyntax };
203
+ export { containerSyntax_DIRECTIVE_TYPES as DIRECTIVE_TYPES, containerSyntax_REGEX_BEGIN as REGEX_BEGIN, containerSyntax_REGEX_END as REGEX_END, containerSyntax_REGEX_GH_BEGIN as REGEX_GH_BEGIN, containerSyntax_REGEX_GH_MARKER as REGEX_GH_MARKER, containerSyntax_TITLE_REGEX_IN_MD as TITLE_REGEX_IN_MD, containerSyntax_TITLE_REGEX_IN_MDX as TITLE_REGEX_IN_MDX, remarkContainerSyntax };
@@ -1,6 +1,6 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { PageContext, useLocation } from "@rspress/core/runtime";
3
- import { Layout, Root } from "@theme";
3
+ import { Layout, Root } from "@rspress/core/theme";
4
4
  import react, { useContext, useLayoutEffect } from "react";
5
5
  import virtual_global_components from "virtual-global-components";
6
6
  import { consumeCachedPageData, initPageData, setCurrentPageData } from "./initPageData.js";
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { BrowserRouter, PageContext, ThemeContext, removeTrailingSlash, withBase } from "@rspress/core/runtime";
3
- import { useThemeState } from "@theme";
3
+ import { useThemeState } from "@rspress/core/theme";
4
4
  import { UnheadProvider, createHead } from "@unhead/react/client";
5
5
  import { useMemo, useState } from "react";
6
6
  import { App } from "./App.js";
@@ -26,6 +26,7 @@ function ClientApp({ initialPageData = null }) {
26
26
  ]),
27
27
  children: /*#__PURE__*/ jsx(BrowserRouter, {
28
28
  basename: removeTrailingSlash(withBase('/')),
29
+ useTransitions: true,
29
30
  children: /*#__PURE__*/ jsx(UnheadProvider, {
30
31
  head: head,
31
32
  children: /*#__PURE__*/ jsx(App, {})
@@ -12,6 +12,10 @@
12
12
  --rp-container-info-text: #07f;
13
13
  --rp-container-info-bg: #0095ff0f;
14
14
  --rp-container-info-code-bg: #0095ff1a;
15
+ --rp-container-important-border: #8957e54d;
16
+ --rp-container-important-text: #8250df;
17
+ --rp-container-important-bg: #8957e514;
18
+ --rp-container-important-code-bg: #8957e51a;
15
19
  --rp-container-warning-border: #ffc51766;
16
20
  --rp-container-warning-text: #887233;
17
21
  --rp-container-warning-bg: #ffc5171a;
@@ -33,6 +37,9 @@
33
37
  --rp-container-tip-bg: #079c701a;
34
38
  --rp-container-info-text: #66c2ff;
35
39
  --rp-container-info-bg: #0095ff1a;
40
+ --rp-container-important-text: #b083f0;
41
+ --rp-container-important-border: #8957e559;
42
+ --rp-container-important-bg: #8957e51f;
36
43
  --rp-container-warning-text: #fbb451;
37
44
  --rp-container-warning-border: #ffc51740;
38
45
  --rp-container-warning-bg: #ffc5171f;
@@ -152,6 +159,28 @@
152
159
  color: var(--rp-container-info-text);
153
160
  }
154
161
 
162
+ .rp-callout--important {
163
+ border-color: var(--rp-container-important-border);
164
+ background-color: var(--rp-container-important-bg);
165
+ }
166
+
167
+ .rp-callout--important .rp-callout__title {
168
+ color: var(--rp-container-important-text);
169
+ }
170
+
171
+ .rp-callout--important .rp-callout__title:before {
172
+ background-color: var(--rp-container-important-text);
173
+ }
174
+
175
+ .rp-callout--important :not(pre) > code {
176
+ color: var(--rp-container-important-text);
177
+ background-color: var(--rp-container-important-code-bg);
178
+ }
179
+
180
+ .rp-callout--important a {
181
+ color: var(--rp-container-important-text);
182
+ }
183
+
155
184
  .rp-callout--warning {
156
185
  border-color: var(--rp-container-warning-border);
157
186
  background-color: var(--rp-container-warning-bg);
@@ -1,7 +1,7 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import './index.scss';
3
3
  export interface CalloutProps {
4
- type: 'tip' | 'note' | 'warning' | 'caution' | 'danger' | 'info' | 'details';
4
+ type: 'tip' | 'note' | 'important' | 'warning' | 'caution' | 'danger' | 'info' | 'details';
5
5
  title?: string;
6
6
  children: ReactNode;
7
7
  }
@@ -52,7 +52,7 @@ function useLinkNavigate({ startTransition } = {
52
52
  nprogress.done();
53
53
  }
54
54
  }
55
- navigate(removeBaseHref, {
55
+ await navigate(removeBaseHref, {
56
56
  replace: false
57
57
  });
58
58
  };
@@ -1,5 +1,4 @@
1
1
  import type React from 'react';
2
2
  import './LlmsContainer.scss';
3
- export interface LlmsContainerProps extends React.HTMLAttributes<HTMLDivElement> {
4
- }
3
+ export type LlmsContainerProps = React.HTMLAttributes<HTMLDivElement>;
5
4
  export declare function LlmsContainer(props: LlmsContainerProps): React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "2.0.15",
3
+ "version": "2.0.16",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -80,11 +80,11 @@
80
80
  "react-lazy-with-preload": "^2.2.1",
81
81
  "react-reconciler": "0.33.0",
82
82
  "react-render-to-markdown": "19.1.0",
83
- "react-router-dom": "^7.15.1",
83
+ "react-router-dom": "^7.18.1",
84
84
  "rehype-external-links": "^3.0.0",
85
85
  "rehype-raw": "^7.0.0",
86
86
  "remark-cjk-friendly": "^2.3.1",
87
- "remark-cjk-friendly-gfm-strikethrough": "^2.1.0",
87
+ "remark-cjk-friendly-gfm-strikethrough": "^2.3.1",
88
88
  "remark-gfm": "^4.0.1",
89
89
  "remark-mdx": "^3.1.1",
90
90
  "remark-parse": "^11.0.0",
@@ -95,7 +95,7 @@
95
95
  "unist-util-remove": "^4.0.0",
96
96
  "unist-util-visit": "^5.1.0",
97
97
  "unist-util-visit-children": "^3.0.0",
98
- "@rspress/shared": "2.0.15"
98
+ "@rspress/shared": "2.0.16"
99
99
  },
100
100
  "devDependencies": {
101
101
  "@microsoft/api-extractor": "^7.58.9",
@@ -110,7 +110,7 @@
110
110
  "@types/react": "^19.2.17",
111
111
  "@types/react-dom": "^19.2.3",
112
112
  "@types/react-reconciler": "^0.33.0",
113
- "@types/web": "^0.0.350",
113
+ "@types/web": "^0.0.351",
114
114
  "cac": "^7.0.0",
115
115
  "chokidar": "^3.6.0",
116
116
  "execa": "8.0.1",
@@ -119,7 +119,7 @@
119
119
  "memfs": "^4.57.8",
120
120
  "p-map": "^7.0.4",
121
121
  "picocolors": "^1.1.1",
122
- "postcss": "8.5.15",
122
+ "postcss": "8.5.16",
123
123
  "remark-directive": "^4.0.0",
124
124
  "rsbuild-plugin-publint": "^1.0.0",
125
125
  "rsbuild-plugin-virtual-module": "0.4.4",