@rspress/core 2.1.3 → 2.1.5
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/bb~0.js +1 -0
- package/dist/b~0.js +3026 -1
- package/dist/cli/index.js +1 -1
- package/dist/config/loadConfigFile.js +1 -1
- package/dist/eject-theme/components/Callout/index.test.tsx +52 -0
- package/dist/eject-theme/components/Callout/index.tsx +11 -0
- package/dist/eject-theme/components/CodeBlock/index.tsx +1 -1
- package/dist/eject-theme/components/HomeFeature/index.scss +12 -0
- package/dist/eject-theme/components/HomeHero/index.scss +4 -1
- package/dist/eject-theme/components/PageTabs/index.test.tsx +45 -0
- package/dist/eject-theme/components/PageTabs/index.tsx +17 -0
- package/dist/eject-theme/components/Prompt/index.tsx +2 -1
- package/dist/eject-theme/components/Sidebar/SidebarGroup.scss +14 -0
- package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +6 -1
- package/dist/eject-theme/components/Sidebar/SidebarItem.scss +0 -10
- package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +2 -2
- package/dist/eject-theme/components/Tabs/index.test.tsx +26 -4
- package/dist/eject-theme/components/Tabs/index.tsx +8 -5
- package/dist/node/PluginDriver.js +1 -1
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/locales.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +1 -1
- package/dist/node/auto-nav-sidebar/utils.js +1 -1
- package/dist/node/auto-nav-sidebar/walk.js +1 -1
- package/dist/node/eject.js +1 -1
- package/dist/node/initRsbuild.js +6 -1
- package/dist/node/mdx/options.js +1 -1
- package/dist/node/mdx/processor.js +1 -1
- package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
- package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
- package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
- package/dist/node/route/RoutePage.js +1 -1
- package/dist/node/route/RouteService.js +1 -1
- package/dist/node/route/extractPageData.js +19 -3
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/route/routeChunkAssets.d.ts +2 -0
- package/dist/node/route/routeChunkAssets.js +6 -0
- package/dist/node/runtimeModule/i18n/getI18nData.js +1 -1
- package/dist/node/runtimeModule/i18n/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/searchHooks.js +1 -1
- package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
- package/dist/node/serve.js +1 -1
- package/dist/node/sitemap.js +1 -1
- package/dist/node/ssg/alternateLinks.js +1 -1
- package/dist/node/ssg/renderHtmlTemplate.js +5 -1
- package/dist/node/ssg/renderPageWorker.js +1 -1
- package/dist/node/ssg/renderPages.js +1 -1
- package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
- package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
- package/dist/node/ssg-md/remarkSplitMdx.d.ts +0 -4
- package/dist/node/ssg-md/remarkSplitMdx.js +266 -163
- package/dist/node/ssg-md/renderPage.js +1 -1
- package/dist/node/ssg-md/renderPages.js +1 -1
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/flattenMdxContent.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/reactAlias.js +3 -1
- package/dist/n~0.js +1 -1
- package/dist/{tx~0.js → q~0.js} +3 -3
- package/dist/shiki-transformers.js +1 -1
- package/dist/theme/components/Callout/index.js +10 -0
- package/dist/theme/components/CodeBlock/index.d.ts +1 -1
- package/dist/theme/components/HomeFeature/index.css +10 -0
- package/dist/theme/components/HomeHero/index.css +5 -1
- package/dist/theme/components/PageTabs/index.js +12 -0
- package/dist/theme/components/Prompt/index.js +1 -1
- package/dist/theme/components/Sidebar/SidebarGroup.css +14 -0
- package/dist/theme/components/Sidebar/SidebarGroup.js +29 -22
- package/dist/theme/components/Sidebar/SidebarItem.css +0 -10
- package/dist/theme/components/Sidebar/SidebarItem.js +2 -2
- package/dist/theme/components/Tabs/index.js +8 -5
- package/dist/tinypool~0.js +2 -2
- package/dist/y~0.js +1 -1
- package/package.json +14 -11
- package/skills/rspress-best-practices/SKILL.md +82 -0
- package/skills/rspress-custom-theme/SKILL.md +242 -0
- package/skills/rspress-custom-theme/references/css-variables.md +177 -0
- package/skills/rspress-custom-theme/references/eject-components.md +154 -0
- package/skills/rspress-custom-theme/references/layout-slots.md +153 -0
- package/skills/rspress-description-generator/SKILL.md +118 -0
- package/skills/rspress-docs-generator/SKILL.md +60 -0
- package/skills/rspress-docs-generator/references/create-new-docs.md +73 -0
- package/skills/rspress-docs-generator/references/doc-structure-conventions.md +117 -0
- package/skills/rspress-docs-generator/references/maintain-docs-for-prs.md +31 -0
- package/skills/rspress-docs-generator/references/rspress-version-guard.md +13 -0
- package/dist/p~0.js +0 -3032
package/dist/cli/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../
|
|
1
|
+
import { node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../b~0.js";
|
|
2
2
|
async function loadConfigFile(customConfigFile) {
|
|
3
3
|
const { loadConfig } = await import("@rsbuild/core");
|
|
4
4
|
const result = await loadConfig({
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it } from '@rstest/core';
|
|
2
|
+
import { renderToMarkdownString } from 'react-render-to-markdown';
|
|
3
|
+
import { Callout } from './index';
|
|
4
|
+
|
|
5
|
+
const originalSsgMd = import.meta.env.SSG_MD;
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
(import.meta.env as unknown as Record<string, unknown>).SSG_MD =
|
|
8
|
+
originalSsgMd;
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
describe('Callout Markdown rendering', () => {
|
|
12
|
+
it('keeps the title and multiple paragraphs inside a quote', async () => {
|
|
13
|
+
(import.meta.env as unknown as Record<string, unknown>).SSG_MD = true;
|
|
14
|
+
const markdown = await renderToMarkdownString(
|
|
15
|
+
<Callout type="warning" title="Before you begin">
|
|
16
|
+
<p>Install dependencies.</p>
|
|
17
|
+
<p>
|
|
18
|
+
Then run <code>pnpm dev</code>.
|
|
19
|
+
</p>
|
|
20
|
+
</Callout>,
|
|
21
|
+
);
|
|
22
|
+
expect(markdown).toMatchInlineSnapshot(`
|
|
23
|
+
"> **Before you begin**
|
|
24
|
+
>
|
|
25
|
+
> Install dependencies.
|
|
26
|
+
>
|
|
27
|
+
> Then run \`pnpm dev\`.
|
|
28
|
+
>
|
|
29
|
+
>
|
|
30
|
+
|
|
31
|
+
"
|
|
32
|
+
`);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('exports all details content with the default title', async () => {
|
|
36
|
+
(import.meta.env as unknown as Record<string, unknown>).SSG_MD = true;
|
|
37
|
+
const markdown = await renderToMarkdownString(
|
|
38
|
+
<Callout type="details">
|
|
39
|
+
<p>Hidden in the browser.</p>
|
|
40
|
+
</Callout>,
|
|
41
|
+
);
|
|
42
|
+
expect(markdown).toMatchInlineSnapshot(`
|
|
43
|
+
"> **Details**
|
|
44
|
+
>
|
|
45
|
+
> Hidden in the browser.
|
|
46
|
+
>
|
|
47
|
+
>
|
|
48
|
+
|
|
49
|
+
"
|
|
50
|
+
`);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -37,6 +37,17 @@ function capitalize(type: string) {
|
|
|
37
37
|
* </div>
|
|
38
38
|
*/
|
|
39
39
|
export function Callout({ type, title, children }: CalloutProps): ReactNode {
|
|
40
|
+
if (import.meta.env.SSG_MD) {
|
|
41
|
+
return (
|
|
42
|
+
<blockquote>
|
|
43
|
+
<p>
|
|
44
|
+
<strong>{title ?? capitalize(type)}</strong>
|
|
45
|
+
</p>
|
|
46
|
+
{children}
|
|
47
|
+
</blockquote>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
40
51
|
const isDetails = type === 'details';
|
|
41
52
|
|
|
42
53
|
if (isDetails) {
|
|
@@ -30,7 +30,7 @@ export type CodeBlockProps = {
|
|
|
30
30
|
containerElementClassName?: string;
|
|
31
31
|
codeButtonGroupProps?: Omit<
|
|
32
32
|
CodeButtonGroupProps,
|
|
33
|
-
'
|
|
33
|
+
'copyElementRef' | 'wrapCode' | 'toggleWrapCode'
|
|
34
34
|
>;
|
|
35
35
|
children?: React.ReactNode;
|
|
36
36
|
};
|
|
@@ -59,6 +59,18 @@
|
|
|
59
59
|
height: 100%;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
@media (prefers-reduced-motion: reduce) {
|
|
63
|
+
&__item,
|
|
64
|
+
&__item-wrapper {
|
|
65
|
+
// Override the inline transforms applied by useCardAnimation.
|
|
66
|
+
transform: none !important;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&__item__shine {
|
|
70
|
+
display: none;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
62
74
|
&__card {
|
|
63
75
|
height: 100%;
|
|
64
76
|
padding: 2rem;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { afterEach, expect, it, rs } from '@rstest/core';
|
|
2
|
+
import { renderToMarkdownString } from 'react-render-to-markdown';
|
|
3
|
+
import { PageTab, PageTabs } from './index';
|
|
4
|
+
|
|
5
|
+
rs.mock('@rspress/core/runtime', () => ({
|
|
6
|
+
useSearchParams: () => [new URLSearchParams(), () => {}],
|
|
7
|
+
useLocation: () => ({ search: '' }),
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
const originalSsgMd = import.meta.env.SSG_MD;
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
(import.meta.env as unknown as Record<string, unknown>).SSG_MD =
|
|
13
|
+
originalSsgMd;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('places each page label next to its content in Markdown', async () => {
|
|
17
|
+
(import.meta.env as unknown as Record<string, unknown>).SSG_MD = true;
|
|
18
|
+
const markdown = await renderToMarkdownString(
|
|
19
|
+
<PageTabs>
|
|
20
|
+
<PageTab
|
|
21
|
+
label={
|
|
22
|
+
<span>
|
|
23
|
+
API <code>v2</code>
|
|
24
|
+
</span>
|
|
25
|
+
}
|
|
26
|
+
>
|
|
27
|
+
<p>API content</p>
|
|
28
|
+
</PageTab>
|
|
29
|
+
<PageTab label="How it works">
|
|
30
|
+
<p>Implementation content</p>
|
|
31
|
+
</PageTab>
|
|
32
|
+
</PageTabs>,
|
|
33
|
+
);
|
|
34
|
+
expect(markdown).toMatchInlineSnapshot(`
|
|
35
|
+
"**API \`v2\`**
|
|
36
|
+
|
|
37
|
+
API content
|
|
38
|
+
|
|
39
|
+
**How it works**
|
|
40
|
+
|
|
41
|
+
Implementation content
|
|
42
|
+
|
|
43
|
+
"
|
|
44
|
+
`);
|
|
45
|
+
});
|
|
@@ -111,6 +111,23 @@ export const PageTabs = forwardRef(
|
|
|
111
111
|
children,
|
|
112
112
|
);
|
|
113
113
|
|
|
114
|
+
if (import.meta.env.SSG_MD) {
|
|
115
|
+
return (
|
|
116
|
+
<>
|
|
117
|
+
{tabValues.map(({ label, content }, index) => (
|
|
118
|
+
<div key={index}>
|
|
119
|
+
{label != null && (
|
|
120
|
+
<p>
|
|
121
|
+
<strong>{label}</strong>
|
|
122
|
+
</p>
|
|
123
|
+
)}
|
|
124
|
+
{content}
|
|
125
|
+
</div>
|
|
126
|
+
))}
|
|
127
|
+
</>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
114
131
|
return (
|
|
115
132
|
<>
|
|
116
133
|
{/* First screen during SSR */}
|
|
@@ -218,7 +218,8 @@ function CopyablePrompt({
|
|
|
218
218
|
<div
|
|
219
219
|
{...props}
|
|
220
220
|
ref={cardRef}
|
|
221
|
-
|
|
221
|
+
// Copyable prompt chrome owns its typography; custom MDX keeps doc styles.
|
|
222
|
+
className={clsx('rp-prompt', 'rp-not-doc', className)}
|
|
222
223
|
style={
|
|
223
224
|
{
|
|
224
225
|
'--rp-prompt-accent': AGENT_ICONS[iconIndex].color,
|
|
@@ -1,3 +1,17 @@
|
|
|
1
1
|
.rp-sidebar-group {
|
|
2
2
|
color: var(--rp-c-text-1);
|
|
3
|
+
|
|
4
|
+
&__items {
|
|
5
|
+
position: relative;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
&__line {
|
|
10
|
+
position: absolute;
|
|
11
|
+
top: 0;
|
|
12
|
+
bottom: 0;
|
|
13
|
+
width: 1px;
|
|
14
|
+
background-color: var(--rp-c-divider-light);
|
|
15
|
+
pointer-events: none;
|
|
16
|
+
}
|
|
3
17
|
}
|
|
@@ -114,7 +114,12 @@ export function SidebarGroup(props: SidebarGroupProps) {
|
|
|
114
114
|
transition: 'grid-template-rows 0.2s ease-out',
|
|
115
115
|
}}
|
|
116
116
|
>
|
|
117
|
-
<div
|
|
117
|
+
<div className="rp-sidebar-group__items">
|
|
118
|
+
<span
|
|
119
|
+
aria-hidden="true"
|
|
120
|
+
className="rp-sidebar-group__line"
|
|
121
|
+
style={{ left: (depth + 1) * 20 - 7 }}
|
|
122
|
+
/>
|
|
118
123
|
{item.items?.map((item, index) =>
|
|
119
124
|
isSidebarGroup(item) ? (
|
|
120
125
|
<SidebarGroup
|
|
@@ -51,16 +51,6 @@
|
|
|
51
51
|
outline-offset: -2px;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
&--group-item::before {
|
|
55
|
-
content: '';
|
|
56
|
-
position: absolute;
|
|
57
|
-
top: -2px;
|
|
58
|
-
left: -7px;
|
|
59
|
-
bottom: 0;
|
|
60
|
-
width: 1px;
|
|
61
|
-
background-color: var(--rp-c-divider-light);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
54
|
&--group-item.rp-sidebar-item--active {
|
|
65
55
|
.rp-sidebar-item__left::before {
|
|
66
56
|
content: '';
|
|
@@ -88,7 +88,7 @@ export function SidebarItemRaw({
|
|
|
88
88
|
className,
|
|
89
89
|
)}
|
|
90
90
|
style={{
|
|
91
|
-
marginLeft: depth *
|
|
91
|
+
marginLeft: depth * 20,
|
|
92
92
|
}}
|
|
93
93
|
{...{ 'data-depth': depth }}
|
|
94
94
|
{...(context ? { 'data-context': context } : {})}
|
|
@@ -110,7 +110,7 @@ export function SidebarItemRaw({
|
|
|
110
110
|
className,
|
|
111
111
|
)}
|
|
112
112
|
style={{
|
|
113
|
-
marginLeft: depth *
|
|
113
|
+
marginLeft: depth * 20,
|
|
114
114
|
}}
|
|
115
115
|
{...{ 'data-depth': depth }}
|
|
116
116
|
{...(context ? { 'data-context': context } : {})}
|
|
@@ -60,15 +60,37 @@ describe('Tabs', () => {
|
|
|
60
60
|
await setImmediate();
|
|
61
61
|
expect(errors).toEqual([]);
|
|
62
62
|
expect(markdown).toMatchInlineSnapshot(`
|
|
63
|
-
"
|
|
64
|
-
**npm**
|
|
63
|
+
"**npm**
|
|
65
64
|
|
|
66
65
|
npm install
|
|
67
66
|
|
|
68
67
|
**pnpm**
|
|
69
68
|
|
|
70
|
-
pnpm install
|
|
71
|
-
|
|
69
|
+
pnpm install"
|
|
70
|
+
`);
|
|
71
|
+
});
|
|
72
|
+
it('renders React labels and omits missing labels', async () => {
|
|
73
|
+
setSsgMd(true);
|
|
74
|
+
const markdown = await renderToMarkdownString(
|
|
75
|
+
<Tabs>
|
|
76
|
+
<Tab
|
|
77
|
+
label={
|
|
78
|
+
<span>
|
|
79
|
+
GitHub <code>repo</code>
|
|
80
|
+
</span>
|
|
81
|
+
}
|
|
82
|
+
>
|
|
83
|
+
Repository settings
|
|
84
|
+
</Tab>
|
|
85
|
+
<Tab>Unlabelled content</Tab>
|
|
86
|
+
</Tabs>,
|
|
87
|
+
);
|
|
88
|
+
expect(markdown).toMatchInlineSnapshot(`
|
|
89
|
+
"**GitHub \`repo\`**
|
|
90
|
+
|
|
91
|
+
Repository settings
|
|
92
|
+
|
|
93
|
+
Unlabelled content"
|
|
72
94
|
`);
|
|
73
95
|
});
|
|
74
96
|
});
|
|
@@ -133,13 +133,16 @@ export const Tabs = forwardRef(
|
|
|
133
133
|
if (import.meta.env.SSG_MD) {
|
|
134
134
|
return (
|
|
135
135
|
<>
|
|
136
|
-
{tabValues.map(({ label, content }) => {
|
|
136
|
+
{tabValues.map(({ label, content }, index) => {
|
|
137
137
|
return (
|
|
138
|
-
|
|
139
|
-
{
|
|
138
|
+
<div key={index}>
|
|
139
|
+
{label != null && (
|
|
140
|
+
<p>
|
|
141
|
+
<strong>{label}</strong>
|
|
142
|
+
</p>
|
|
143
|
+
)}
|
|
140
144
|
{content}
|
|
141
|
-
|
|
142
|
-
</>
|
|
145
|
+
</div>
|
|
143
146
|
);
|
|
144
147
|
})}
|
|
145
148
|
</>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addTrailingSlash, node_path, addLeadingSlash } from "../
|
|
1
|
+
import { addTrailingSlash, node_path, addLeadingSlash } from "../b~0.js";
|
|
2
2
|
import { createI18nDataLoader } from "./runtimeModule/i18n/getI18nData.js";
|
|
3
3
|
import { createError } from "./utils/error.js";
|
|
4
4
|
import { haveNavSidebarConfig as auto_nav_sidebar_haveNavSidebarConfig } from "./auto-nav-sidebar/index.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../
|
|
1
|
+
import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../b~0.js";
|
|
2
2
|
import { processLocales, combineWalkResult } from "./locales.js";
|
|
3
3
|
import { walk } from "./walk.js";
|
|
4
4
|
async function runAutoNavSide(config, metaFileSet, mdFileSet) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../t~0.js";
|
|
3
|
-
import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../
|
|
3
|
+
import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../b~0.js";
|
|
4
4
|
import { createError } from "../utils/error.js";
|
|
5
5
|
import { pathExists, extractInfoFromFrontmatterWithAbsolutePath, readJson } from "./utils.js";
|
|
6
6
|
import { absolutePathToRoutePath, addRoutePrefix } from "../route/RoutePage.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isExternalUrl, node_path, promises } from "../../
|
|
1
|
+
import { isExternalUrl, node_path, promises } from "../../b~0.js";
|
|
2
2
|
import { pathExists } from "../utils/fs.js";
|
|
3
3
|
import { readJson } from "./utils.js";
|
|
4
4
|
import { addRoutePrefix } from "../route/RoutePage.js";
|
package/dist/node/eject.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { rspackRequire, compatGetDefaultExport } from "../rslib-runtime~0.js";
|
|
2
2
|
import "../t~0.js";
|
|
3
|
-
import { node_path, logger, promises } from "../
|
|
3
|
+
import { node_path, logger, promises } from "../b~0.js";
|
|
4
4
|
import { EJECTED_THEME } from "./constants.js";
|
|
5
5
|
const picocolors = rspackRequire("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
6
6
|
var picocolors_default = /*#__PURE__*/ compatGetDefaultExport(picocolors);
|
package/dist/node/initRsbuild.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { external_node_process_cwd, node_path, fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, removeTrailingSlash, normalizeDarkMode, pluginVirtualModule, pluginReact, createRequire, MDX_OR_MD_REGEXP } from "../
|
|
1
|
+
import { external_node_process_cwd, node_path, fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, removeTrailingSlash, normalizeDarkMode, pluginVirtualModule, pluginReact, createRequire, MDX_OR_MD_REGEXP } from "../b~0.js";
|
|
2
2
|
import { createError } from "./utils/error.js";
|
|
3
3
|
import { CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, NODE_SSG_BUNDLE_FOLDER, getInlineLocaleRedirectScript, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, getInlineThemeScript, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
|
|
4
4
|
import { isLlmsUIEnabled, isLlmsHintEnabled } from "./llms.js";
|
|
@@ -236,6 +236,11 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
236
236
|
}
|
|
237
237
|
},
|
|
238
238
|
tools: {
|
|
239
|
+
rspack: {
|
|
240
|
+
experiments: {
|
|
241
|
+
runtimeMode: 'rspack'
|
|
242
|
+
}
|
|
243
|
+
},
|
|
239
244
|
swc: {
|
|
240
245
|
jsc: {
|
|
241
246
|
transform: {
|
package/dist/node/mdx/options.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_path, rehype_external_links, rehype_raw, remark_cjk_friendly, nodeTypes, remark_gfm, rehype, remark_cjk_friendly_gfm_strikethrough } from "../../
|
|
1
|
+
import { node_path, rehype_external_links, rehype_raw, remark_cjk_friendly, nodeTypes, remark_gfm, rehype, remark_cjk_friendly_gfm_strikethrough } from "../../q~0.js";
|
|
2
2
|
import { remarkToc } from "./remarkPlugins/toc.js";
|
|
3
3
|
import { remarkContainerSyntax } from "./remarkPlugins/containerSyntax.js";
|
|
4
4
|
import { remarkFileCodeBlock } from "./remarkPlugins/fileCodeBlock.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_path, extractTextAndId, createProcessor, loadFrontMatter } from "../../
|
|
1
|
+
import { node_path, extractTextAndId, createProcessor, loadFrontMatter } from "../../q~0.js";
|
|
2
2
|
import { createMDXOptions } from "./options.js";
|
|
3
3
|
import { applyReplaceRules } from "../utils/applyReplaceRules.js";
|
|
4
4
|
import { escapeMarkdownHeadingIds } from "../utils/escapeHeadingIds.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit, extractTextAndId, github_slugger, headingRank } from "../../../
|
|
1
|
+
import { visit, extractTextAndId, github_slugger, headingRank } from "../../../q~0.js";
|
|
2
2
|
const rehypeHeaderAnchor = ()=>{
|
|
3
3
|
const slugger = new github_slugger();
|
|
4
4
|
return (tree)=>{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddFold, getShikiTransformers, transformerAddWrapCode, createCssVariablesTheme } from "../../../
|
|
1
|
+
import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddFold, getShikiTransformers, transformerAddWrapCode, createCssVariablesTheme } from "../../../q~0.js";
|
|
2
2
|
const cssVariablesTheme = createCssVariablesTheme({
|
|
3
3
|
name: 'css-variables',
|
|
4
4
|
variablePrefix: '--shiki-',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_path } from "../../../
|
|
1
|
+
import { node_path } from "../../../q~0.js";
|
|
2
2
|
import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
|
|
3
3
|
const remarkBuiltin = ({ globalComponents })=>(tree)=>{
|
|
4
4
|
const demos = globalComponents.map((componentPath)=>{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../
|
|
1
|
+
import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../b~0.js";
|
|
2
2
|
import { RoutePage, absolutePathToRoutePath, absolutePathToRelativePath } from "./RoutePage.js";
|
|
3
3
|
import { createError } from "../utils/error.js";
|
|
4
4
|
import { getRouteChunkName } from "./routeChunkAssets.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unified, node_path, promises, loadFrontMatter, extractTextAndId, remark_gfm,
|
|
1
|
+
import { unified, node_path, promises, loadFrontMatter, extractTextAndId, remark_gfm, remark_mdx, MDX_OR_MD_REGEXP, remark_parse } from "../../b~0.js";
|
|
2
2
|
import { applyReplaceRules } from "../utils/applyReplaceRules.js";
|
|
3
3
|
import { flattenMdxContent } from "../utils/flattenMdxContent.js";
|
|
4
4
|
import { importStatementRegex } from "../constants.js";
|
|
@@ -9,6 +9,7 @@ function applyReplaceRulesToNestedObject(obj, replaceRules) {
|
|
|
9
9
|
return obj;
|
|
10
10
|
}
|
|
11
11
|
const processor = unified().use(remark_parse).use(remark_gfm);
|
|
12
|
+
const mdxProcessor = unified().use(remark_parse).use(remark_gfm).use(remark_mdx);
|
|
12
13
|
function extractTextFromNode(node) {
|
|
13
14
|
if ('value' in node && 'string' == typeof node.value) return node.value;
|
|
14
15
|
if ('children' in node && Array.isArray(node.children)) return node.children.map(extractTextFromNode).join('');
|
|
@@ -99,6 +100,9 @@ const SKIP_NODE_TYPES = new Set([
|
|
|
99
100
|
'html',
|
|
100
101
|
'mdxjsEsm',
|
|
101
102
|
'mdxFlowExpression',
|
|
103
|
+
'mdxJsxFlowElement',
|
|
104
|
+
'mdxJsxTextElement',
|
|
105
|
+
'mdxTextExpression',
|
|
102
106
|
'thematicBreak',
|
|
103
107
|
'image',
|
|
104
108
|
'table'
|
|
@@ -138,7 +142,7 @@ function extractDescription(tree) {
|
|
|
138
142
|
if ('heading' === node.type && 2 === node.depth) break;
|
|
139
143
|
if (!SKIP_NODE_TYPES.has(node.type)) {
|
|
140
144
|
if (foundH1) {
|
|
141
|
-
const text =
|
|
145
|
+
const text = extractDescriptionText(node).trim();
|
|
142
146
|
if (text) textParts.push(text);
|
|
143
147
|
}
|
|
144
148
|
}
|
|
@@ -146,6 +150,18 @@ function extractDescription(tree) {
|
|
|
146
150
|
const joined = textParts.join('\n');
|
|
147
151
|
return stripContainerDirectives(joined).split('\n').map((l)=>l.trim()).filter(Boolean).join(' ');
|
|
148
152
|
}
|
|
153
|
+
function extractDescriptionText(node) {
|
|
154
|
+
if (SKIP_NODE_TYPES.has(node.type)) return '';
|
|
155
|
+
if ('children' in node && Array.isArray(node.children)) return node.children.map(extractDescriptionText).join('');
|
|
156
|
+
return extractTextFromNode(node);
|
|
157
|
+
}
|
|
158
|
+
function parsePageTree(content) {
|
|
159
|
+
try {
|
|
160
|
+
return mdxProcessor.parse(content);
|
|
161
|
+
} catch {
|
|
162
|
+
return processor.parse(content);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
149
165
|
async function getPageIndexInfoByRoute(route, options) {
|
|
150
166
|
const { alias, replaceRules, root, searchCodeBlocks, extractDescription: extractDescriptionConfig = true, searchEnabled = true } = options;
|
|
151
167
|
const defaultIndexInfo = {
|
|
@@ -167,7 +183,7 @@ async function getPageIndexInfoByRoute(route, options) {
|
|
|
167
183
|
const { flattenContent } = await flattenMdxContent(applyReplaceRules(contentWithoutFrontMatter, replaceRules), route.absolutePath, alias);
|
|
168
184
|
content = flattenContent.replace(importStatementRegex, '');
|
|
169
185
|
content = content.replace(/\r\n/g, '\n');
|
|
170
|
-
const tree =
|
|
186
|
+
const tree = parsePageTree(content);
|
|
171
187
|
const { title, toc: rawToc } = parseToc(tree);
|
|
172
188
|
const extractedDescription = frontmatter.description || !extractDescriptionConfig ? '' : extractDescription(tree);
|
|
173
189
|
if (!searchEnabled) return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../
|
|
1
|
+
import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../b~0.js";
|
|
2
2
|
const getRoutePathParts = (relativePath, lang, version, langs, versions)=>{
|
|
3
3
|
const [versionPart, langPart, purePath] = splitRoutePathParts(relativePath, lang, version, langs, versions);
|
|
4
4
|
return [
|
|
@@ -3,6 +3,8 @@ import type { RouteMeta } from '@rspress/shared';
|
|
|
3
3
|
import type { RouteService } from './RouteService.js';
|
|
4
4
|
export interface RouteChunkAssetsManifest {
|
|
5
5
|
assetPrefix: string;
|
|
6
|
+
isModule: boolean;
|
|
7
|
+
crossOriginLoading: false | 'anonymous' | 'use-credentials';
|
|
6
8
|
assets: Record<string, string[]>;
|
|
7
9
|
}
|
|
8
10
|
export declare function getRouteChunkName(route: RouteMeta): string;
|
|
@@ -8,12 +8,16 @@ function getRouteChunkName(route) {
|
|
|
8
8
|
class RouteChunkAssetsPlugin {
|
|
9
9
|
routeService;
|
|
10
10
|
#assetPrefix = '/';
|
|
11
|
+
#isModule = false;
|
|
12
|
+
#crossOriginLoading = false;
|
|
11
13
|
#chunks = new Map();
|
|
12
14
|
constructor(routeService){
|
|
13
15
|
this.routeService = routeService;
|
|
14
16
|
}
|
|
15
17
|
apply(compiler) {
|
|
16
18
|
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation)=>{
|
|
19
|
+
this.#isModule = Boolean(compilation.outputOptions.module);
|
|
20
|
+
this.#crossOriginLoading = compilation.outputOptions.crossOriginLoading ?? false;
|
|
17
21
|
this.#assetPrefix = 'string' == typeof compilation.outputOptions.publicPath ? compilation.outputOptions.publicPath : '/';
|
|
18
22
|
this.#chunks.clear();
|
|
19
23
|
const routePathsByChunkName = new Map();
|
|
@@ -38,6 +42,8 @@ class RouteChunkAssetsPlugin {
|
|
|
38
42
|
getManifest() {
|
|
39
43
|
return {
|
|
40
44
|
assetPrefix: this.#assetPrefix,
|
|
45
|
+
isModule: this.#isModule,
|
|
46
|
+
crossOriginLoading: this.#crossOriginLoading,
|
|
41
47
|
assets: Object.fromEntries([
|
|
42
48
|
...this.#chunks
|
|
43
49
|
].map(([routePath, chunks])=>{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { rspackRequire, compatGetDefaultExport } from "../../../rslib-runtime~0.js";
|
|
2
2
|
import "../../../t~0.js";
|
|
3
|
-
import { logger, join, readFile } from "../../../
|
|
3
|
+
import { logger, join, readFile } from "../../../b~0.js";
|
|
4
4
|
import { pathExists } from "../../utils/fs.js";
|
|
5
5
|
import { DEFAULT_I18N_TEXT } from "./DEFAULT_I18N_TEXT.js";
|
|
6
6
|
import { createError } from "../../utils/error.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SEARCH_INDEX_NAME, groupBy } from "../../../
|
|
1
|
+
import { SEARCH_INDEX_NAME, groupBy } from "../../../b~0.js";
|
|
2
2
|
import { extractPageData } from "../../route/extractPageData.js";
|
|
3
3
|
import { createHash } from "../../utils/createHash.js";
|
|
4
4
|
function deletePrivateField(obj) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger, pluginVirtualModule } from "../../../
|
|
1
|
+
import { logger, pluginVirtualModule } from "../../../b~0.js";
|
|
2
2
|
import { createPageData } from "./createPageData.js";
|
|
3
3
|
const rsbuildPluginDocVM = async ({ config, userDocRoot, routeService, pluginDriver })=>{
|
|
4
4
|
const ref = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getIconUrlPath } from "../../../
|
|
1
|
+
import { getIconUrlPath } from "../../../b~0.js";
|
|
2
2
|
import { normalizeThemeConfig } from "./normalizeThemeConfig.js";
|
|
3
3
|
async function createSiteData(userConfig, pluginDriver) {
|
|
4
4
|
const tempSearchObj = Object.assign({}, userConfig.search);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../
|
|
1
|
+
import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../b~0.js";
|
|
2
2
|
import { applyReplaceRules } from "../../utils/applyReplaceRules.js";
|
|
3
3
|
async function normalizeThemeConfig(docConfig, pluginDriver) {
|
|
4
4
|
const { locales: siteLocales, lang, replaceRules = [], multiVersion } = docConfig;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isProduction, logger } from "../../../
|
|
1
|
+
import { isProduction, logger } from "../../../b~0.js";
|
|
2
2
|
import { modifyConfigWithAutoNavSide } from "../../auto-nav-sidebar/index.js";
|
|
3
3
|
import { createSiteData } from "./createSiteData.js";
|
|
4
4
|
const siteDataVMPlugin = (context)=>{
|