@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/node/serve.js
CHANGED
package/dist/node/sitemap.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { withSiteOrigin, logger, glob, promises_stat, withBase } from "../
|
|
1
|
+
import { withSiteOrigin, logger, glob, promises_stat, withBase } from "../b~0.js";
|
|
2
2
|
import { routePath2HtmlFileName } from "./ssg/htmlFile.js";
|
|
3
3
|
function ensureTrailingSlash(url) {
|
|
4
4
|
return url.endsWith('/') ? url : `${url}/`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeHref, removeTrailingSlash, addLeadingSlash, normalizePosixPath, withSiteOrigin } from "../../
|
|
1
|
+
import { normalizeHref, removeTrailingSlash, addLeadingSlash, normalizePosixPath, withSiteOrigin } from "../../b~0.js";
|
|
2
2
|
function createAlternateLinksByRoute(routes, config) {
|
|
3
3
|
const routeGroups = new Map();
|
|
4
4
|
for (const route of routes){
|
|
@@ -37,7 +37,11 @@ function renderRoutePreloadLinks(route, manifest) {
|
|
|
37
37
|
if (!assets) return '';
|
|
38
38
|
return assets.map((asset)=>{
|
|
39
39
|
const href = 'auto' === manifest.assetPrefix ? posix.relative(posix.dirname(routePath2HtmlFileName(route.routePath)), asset) : `${manifest.assetPrefix}${asset}`;
|
|
40
|
-
|
|
40
|
+
const rel = manifest.isModule ? 'modulepreload' : 'preload';
|
|
41
|
+
const as = manifest.isModule ? '' : ' as="script"';
|
|
42
|
+
const crossOrigin = manifest.crossOriginLoading;
|
|
43
|
+
const crossorigin = crossOrigin && (manifest.isModule || 'use-credentials' === crossOrigin || /^(?:[a-z][a-z\d+.-]*:)?\/\//i.test(href)) ? ` crossorigin="${crossOrigin}"` : '';
|
|
44
|
+
return `<link rel="${rel}" href="${escapeHtmlAttribute(href)}"${as}${crossorigin}>`;
|
|
41
45
|
}).join('');
|
|
42
46
|
}
|
|
43
47
|
function escapeHtmlAttribute(value) {
|
|
@@ -5,7 +5,7 @@ import { pMap } from "../../y~0.js";
|
|
|
5
5
|
import { renderPage } from "./renderPage.js";
|
|
6
6
|
const params = workerData?.[1]?.params;
|
|
7
7
|
if (!params) throw createError('SSG Worker Thread workerData params missing');
|
|
8
|
-
const { htmlTemplate
|
|
8
|
+
const { htmlTemplate, head, ssrBundlePath, alternateLinksByRoute, distPath, routeChunkAssets } = params;
|
|
9
9
|
async function writeHtmlFile(routePath, html) {
|
|
10
10
|
if (!distPath) return;
|
|
11
11
|
const fileAbsolutePath = resolveHtmlFilePath(distPath, routePath);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! LICENSE: renderPages.js.LICENSE.txt */
|
|
2
2
|
import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
|
|
3
3
|
import "../../t~0.js";
|
|
4
|
-
import { node_path, fileURLToPath, logger, chunk } from "../../
|
|
4
|
+
import { node_path, fileURLToPath, logger, chunk } from "../../b~0.js";
|
|
5
5
|
import { createAlternateLinksByRoute } from "./alternateLinks.js";
|
|
6
6
|
import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
|
|
7
7
|
import { routePath2HtmlFileName } from "./htmlFile.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../
|
|
1
|
+
import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../b~0.js";
|
|
2
2
|
import { NODE_SSG_BUNDLE_FOLDER, NODE_SSG_BUNDLE_NAME } from "../constants.js";
|
|
3
3
|
import { renderPages } from "./renderPages.js";
|
|
4
4
|
const rsbuildPluginSSG = ({ routeService, config, routeChunkAssets })=>({
|
package/dist/node/ssg/ssgEnv.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! LICENSE: ssgEnv.js.LICENSE.txt */
|
|
2
|
-
import { node_os } from "../../
|
|
2
|
+
import { node_os } from "../../b~0.js";
|
|
3
3
|
/**
|
|
4
4
|
* these codes are copied from
|
|
5
5
|
* @link https://github.com/facebook/docusaurus/blob/45065e8d2b5831117b8d69fec1be28f5520cf105/packages/docusaurus/src/ssg/ssgEnv.ts#L11
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { matchPath, getSidebarDataGroup } from "../../../
|
|
1
|
+
import { matchPath, getSidebarDataGroup } from "../../../b~0.js";
|
|
2
2
|
import { generateLlmsTxt, generateLlmsFullTxt } from "./llmsTxt.js";
|
|
3
3
|
async function emitLlmsTxt(config, routeService, emitAsset, mdContents) {
|
|
4
4
|
const base = config.base ?? '/';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeHref, withSiteOrigin, logger, withBase } from "../../../
|
|
1
|
+
import { normalizeHref, withSiteOrigin, logger, withBase } from "../../../b~0.js";
|
|
2
2
|
import { extractInfoFromFrontmatterWithAbsolutePath } from "../../auto-nav-sidebar/utils.js";
|
|
3
3
|
function routePathToMdPath(routePath, base, siteOrigin) {
|
|
4
4
|
let url = routePath;
|
|
@@ -32,8 +32,4 @@ export interface RemarkSplitMdxOptions {
|
|
|
32
32
|
*/
|
|
33
33
|
excludes?: FilterRule[];
|
|
34
34
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Custom remark plugin that wraps markdown content in React Fragment
|
|
37
|
-
* Only processes top-level markdown nodes, keeps JSX elements and their children intact
|
|
38
|
-
*/
|
|
39
35
|
export declare function remarkSplitMdx(options?: RemarkSplitMdxOptions): (tree: Root) => void;
|
|
@@ -1,157 +1,250 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { gfmToMarkdown, toMarkdown, mdxToMarkdown } from "../../q~0.js";
|
|
2
2
|
function remarkSplitMdx(options = {}) {
|
|
3
3
|
return (tree)=>{
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
const context = {
|
|
5
|
+
...prepareTree(tree),
|
|
6
|
+
options
|
|
7
|
+
};
|
|
8
|
+
const writer = new MarkdownWriter(context);
|
|
9
|
+
writer.flow(tree.children);
|
|
10
|
+
tree.children = [
|
|
11
|
+
...context.esmNodes,
|
|
12
|
+
{
|
|
13
|
+
type: 'mdxJsxFlowElement',
|
|
14
|
+
name: null,
|
|
15
|
+
attributes: [],
|
|
16
|
+
children: writer.finish()
|
|
12
17
|
}
|
|
13
|
-
|
|
14
|
-
newChildren.push(processJsxElement(node, importMap, options));
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
const hasJsxChildren = node.children?.some((child)=>'mdxJsxFlowElement' === child.type || 'mdxJsxTextElement' === child.type || 'mdxFlowExpression' === child.type || 'mdxTextExpression' === child.type);
|
|
18
|
-
if (hasJsxChildren) {
|
|
19
|
-
const processedChildren = processMixedContent(node, node.children || [], importMap, options);
|
|
20
|
-
newChildren.push({
|
|
21
|
-
type: 'mdxJsxFlowElement',
|
|
22
|
-
name: null,
|
|
23
|
-
attributes: [],
|
|
24
|
-
children: processedChildren
|
|
25
|
-
});
|
|
26
|
-
} else newChildren.push(buildMdxFlowExpressionFragment(node));
|
|
27
|
-
}
|
|
28
|
-
tree.children = newChildren;
|
|
18
|
+
];
|
|
29
19
|
};
|
|
30
20
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
let textBuffer = [];
|
|
42
|
-
const flushTextBuffer = ()=>{
|
|
43
|
-
if (0 === textBuffer.length) return;
|
|
44
|
-
const combined = textBuffer.map((child)=>serializeNodeToMarkdown(child)).join('');
|
|
45
|
-
if (combined) processedChildren.push(createTextExpression(combined));
|
|
46
|
-
textBuffer = [];
|
|
47
|
-
};
|
|
48
|
-
for (const child of node.children)if ('mdxJsxFlowElement' === child.type || 'mdxJsxTextElement' === child.type) {
|
|
49
|
-
flushTextBuffer();
|
|
50
|
-
processedChildren.push(processJsxElement(child, importMap, options));
|
|
51
|
-
} else if ('mdxFlowExpression' === child.type || 'mdxTextExpression' === child.type) {
|
|
52
|
-
flushTextBuffer();
|
|
53
|
-
processedChildren.push(child);
|
|
54
|
-
} else textBuffer.push(child);
|
|
55
|
-
flushTextBuffer();
|
|
56
|
-
return {
|
|
57
|
-
...node,
|
|
58
|
-
children: processedChildren
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function getComponentName(name) {
|
|
62
|
-
if (!name) return null;
|
|
63
|
-
if ('string' == typeof name) {
|
|
64
|
-
const dotIndex = name.indexOf('.');
|
|
65
|
-
if (dotIndex > 0) return name.substring(0, dotIndex);
|
|
66
|
-
return name;
|
|
21
|
+
class MarkdownWriter {
|
|
22
|
+
text = '';
|
|
23
|
+
output = [];
|
|
24
|
+
lineStart = true;
|
|
25
|
+
prefix = '';
|
|
26
|
+
inTable = false;
|
|
27
|
+
isLiteralText = false;
|
|
28
|
+
context;
|
|
29
|
+
constructor(context){
|
|
30
|
+
this.context = context;
|
|
67
31
|
}
|
|
68
|
-
|
|
69
|
-
if (
|
|
32
|
+
write(value) {
|
|
33
|
+
if (!value) return;
|
|
34
|
+
if (this.inTable) value = value.replace(/(?<!\\)\|/g, '\\|');
|
|
35
|
+
if (!this.prefix) {
|
|
36
|
+
this.text += value;
|
|
37
|
+
this.lineStart = value.endsWith('\n');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
for (const line of value.split(/(?<=\n)/)){
|
|
41
|
+
if (!line) continue;
|
|
42
|
+
const prefix = '\n' === line ? this.prefix.includes('>') ? this.prefix.trimEnd() : '' : this.prefix;
|
|
43
|
+
this.text += (this.lineStart ? prefix : '') + line;
|
|
44
|
+
this.lineStart = line.endsWith('\n');
|
|
45
|
+
}
|
|
70
46
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
let textBuffer = [];
|
|
76
|
-
const prefix = 'heading' === parentNode.type ? `${'#'.repeat(parentNode.depth || 1)} ` : '';
|
|
77
|
-
let prefixAdded = false;
|
|
78
|
-
const flushTextBuffer = ()=>{
|
|
79
|
-
if (textBuffer.length > 0) {
|
|
80
|
-
let combined = textBuffer.join('');
|
|
81
|
-
if (!prefixAdded && prefix) {
|
|
82
|
-
combined = prefix + combined;
|
|
83
|
-
prefixAdded = true;
|
|
84
|
-
}
|
|
85
|
-
if (combined) result.push(createTextExpression(combined));
|
|
86
|
-
textBuffer = [];
|
|
87
|
-
} else if (!prefixAdded && prefix) {
|
|
88
|
-
result.push(createTextExpression(prefix.trimEnd()));
|
|
89
|
-
prefixAdded = true;
|
|
47
|
+
emit(node) {
|
|
48
|
+
if (this.lineStart) {
|
|
49
|
+
this.text += this.prefix;
|
|
50
|
+
this.lineStart = false;
|
|
90
51
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const stringified = JSON.stringify(textContent);
|
|
112
|
-
const fragment = {
|
|
113
|
-
type: 'mdxFlowExpression',
|
|
114
|
-
value: stringified,
|
|
115
|
-
data: {
|
|
116
|
-
estree: {
|
|
117
|
-
type: 'Program',
|
|
118
|
-
body: [
|
|
119
|
-
{
|
|
120
|
-
type: 'ExpressionStatement',
|
|
121
|
-
expression: {
|
|
122
|
-
type: 'Literal',
|
|
123
|
-
value: textContent,
|
|
124
|
-
raw: stringified
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
],
|
|
128
|
-
sourceType: 'module'
|
|
52
|
+
if (this.text) {
|
|
53
|
+
this.output.push(createTextExpression(this.text));
|
|
54
|
+
this.text = '';
|
|
55
|
+
}
|
|
56
|
+
this.output.push(node);
|
|
57
|
+
}
|
|
58
|
+
finish() {
|
|
59
|
+
if (this.text) this.output.push(createTextExpression(this.text));
|
|
60
|
+
return this.output;
|
|
61
|
+
}
|
|
62
|
+
flow(children) {
|
|
63
|
+
if (this.isLiteralText) return void this.phrasing(children);
|
|
64
|
+
let markdown = [];
|
|
65
|
+
let afterMdx = false;
|
|
66
|
+
const flush = (beforeMdx = false)=>{
|
|
67
|
+
if (!markdown.length) return;
|
|
68
|
+
if (markdown.every((node)=>!this.context.mixedNodes.has(node))) this.write(stringifyMarkdown(markdown));
|
|
69
|
+
else {
|
|
70
|
+
this.blocks(markdown);
|
|
71
|
+
this.write('\n');
|
|
129
72
|
}
|
|
73
|
+
if (beforeMdx) this.write('\n');
|
|
74
|
+
markdown = [];
|
|
75
|
+
};
|
|
76
|
+
for (const node of children)if ('mdxjsEsm' !== node.type) {
|
|
77
|
+
if (afterMdx) this.write('\n');
|
|
78
|
+
afterMdx = isMdxNode(node);
|
|
79
|
+
if (afterMdx) {
|
|
80
|
+
flush(true);
|
|
81
|
+
this.node(node);
|
|
82
|
+
} else markdown.push(node);
|
|
130
83
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
84
|
+
flush();
|
|
85
|
+
}
|
|
86
|
+
blocks(children, separator = '\n\n') {
|
|
87
|
+
children.forEach((node, index)=>{
|
|
88
|
+
if (index) this.write(separator);
|
|
89
|
+
this.node(node, isMdxNode(node));
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
phrasing(children) {
|
|
93
|
+
for (const child of children)this.node(child, true);
|
|
94
|
+
}
|
|
95
|
+
indented(prefix, action) {
|
|
96
|
+
const previous = this.prefix;
|
|
97
|
+
this.prefix += prefix;
|
|
98
|
+
action();
|
|
99
|
+
this.prefix = previous;
|
|
100
|
+
}
|
|
101
|
+
jsx(node) {
|
|
102
|
+
if (!shouldKeepJsxElement(node.name, this.context.importMap, this.context.options)) {
|
|
103
|
+
if (node.children.length) {
|
|
104
|
+
this.write(serializeOpeningTag(node));
|
|
105
|
+
if ('mdxJsxTextElement' === node.type) this.phrasing(node.children);
|
|
106
|
+
else this.flow(node.children);
|
|
107
|
+
this.write(serializeClosingTag(node));
|
|
108
|
+
} else this.write(stringifyMarkdown([
|
|
109
|
+
node
|
|
110
|
+
]).replace(/\n$/, ''));
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (!node.children.length) return node;
|
|
114
|
+
const writer = new MarkdownWriter(this.context);
|
|
115
|
+
writer.inTable = this.inTable;
|
|
116
|
+
writer.isLiteralText = this.isLiteralText || 'code' === node.name || 'pre' === node.name;
|
|
117
|
+
if ('mdxJsxTextElement' === node.type) writer.phrasing(node.children);
|
|
118
|
+
else writer.flow(node.children);
|
|
119
|
+
return {
|
|
120
|
+
...node,
|
|
121
|
+
children: writer.finish()
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
node(node, inline = false) {
|
|
125
|
+
if (isMdxNode(node)) {
|
|
126
|
+
const processed = isJsxNode(node) ? this.jsx(node) : node;
|
|
127
|
+
if (!processed) return;
|
|
128
|
+
this.emit(inline || 'mdxJsxTextElement' === node.type || 'mdxTextExpression' === node.type ? inlineNode(processed) : processed);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if ((inline || this.isLiteralText) && 'text' === node.type) return void this.write(this.isLiteralText ? node.value : node.value.replace(/[\\`*_[\]<>~]/g, '\\$&'));
|
|
132
|
+
if (this.isLiteralText && 'paragraph' === node.type) return void this.phrasing(node.children);
|
|
133
|
+
if (!this.context.mixedNodes.has(node)) return void this.write(stringifyMarkdown([
|
|
134
|
+
node
|
|
135
|
+
]).replace(/\n$/, ''));
|
|
136
|
+
switch(node.type){
|
|
137
|
+
case 'paragraph':
|
|
138
|
+
this.phrasing(node.children);
|
|
139
|
+
break;
|
|
140
|
+
case 'heading':
|
|
141
|
+
this.write('#'.repeat(node.depth) + ' ');
|
|
142
|
+
this.phrasing(node.children);
|
|
143
|
+
break;
|
|
144
|
+
case 'emphasis':
|
|
145
|
+
this.wrap('_', node.children);
|
|
146
|
+
break;
|
|
147
|
+
case 'strong':
|
|
148
|
+
this.wrap('**', node.children);
|
|
149
|
+
break;
|
|
150
|
+
case 'delete':
|
|
151
|
+
this.wrap('~~', node.children);
|
|
152
|
+
break;
|
|
153
|
+
case 'link':
|
|
154
|
+
{
|
|
155
|
+
this.write('[');
|
|
156
|
+
this.phrasing(node.children);
|
|
157
|
+
const link = stringifyMarkdown([
|
|
158
|
+
{
|
|
159
|
+
...node,
|
|
160
|
+
children: [
|
|
161
|
+
{
|
|
162
|
+
type: 'text',
|
|
163
|
+
value: 'label'
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
]);
|
|
168
|
+
this.write(link.slice(link.indexOf(']')).replace(/\n$/, ''));
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
case 'linkReference':
|
|
172
|
+
this.write('[');
|
|
173
|
+
this.phrasing(node.children);
|
|
174
|
+
this.write(']' + ('full' === node.referenceType ? '[' + escapeLabel(node.label ?? node.identifier) + ']' : 'collapsed' === node.referenceType ? '[]' : ''));
|
|
175
|
+
break;
|
|
176
|
+
case 'blockquote':
|
|
177
|
+
this.indented('> ', ()=>this.blocks(node.children));
|
|
178
|
+
break;
|
|
179
|
+
case 'list':
|
|
180
|
+
this.list(node);
|
|
181
|
+
break;
|
|
182
|
+
case 'footnoteDefinition':
|
|
183
|
+
this.write('[^' + escapeLabel(node.label ?? node.identifier) + ']: ');
|
|
184
|
+
this.indented(' ', ()=>this.blocks(node.children));
|
|
185
|
+
break;
|
|
186
|
+
case 'table':
|
|
187
|
+
this.table(node);
|
|
188
|
+
break;
|
|
189
|
+
default:
|
|
190
|
+
throw new Error('[SSG-MD] Unsupported mixed Markdown node: ' + node.type);
|
|
144
191
|
}
|
|
145
192
|
}
|
|
146
|
-
|
|
147
|
-
|
|
193
|
+
wrap(marker, children) {
|
|
194
|
+
this.write(marker);
|
|
195
|
+
this.phrasing(children);
|
|
196
|
+
this.write(marker);
|
|
197
|
+
}
|
|
198
|
+
list(node) {
|
|
199
|
+
node.children.forEach((item, index)=>{
|
|
200
|
+
if (index) this.write(node.spread ? '\n\n' : '\n');
|
|
201
|
+
const marker = node.ordered ? `${(node.start ?? 1) + index}. ` : '- ';
|
|
202
|
+
this.write(marker);
|
|
203
|
+
this.indented(' '.repeat(marker.length), ()=>{
|
|
204
|
+
if ('boolean' == typeof item.checked) this.write(item.checked ? '[x] ' : '[ ] ');
|
|
205
|
+
this.blocks(item.children, item.spread ? '\n\n' : '\n');
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
table(node) {
|
|
210
|
+
node.children.forEach((row, index)=>{
|
|
211
|
+
if (index) this.write('\n');
|
|
212
|
+
this.write('| ');
|
|
213
|
+
row.children.forEach((cell, column)=>{
|
|
214
|
+
if (column) this.write(' | ');
|
|
215
|
+
this.inTable = true;
|
|
216
|
+
this.phrasing(cell.children);
|
|
217
|
+
this.inTable = false;
|
|
218
|
+
});
|
|
219
|
+
this.write(' |');
|
|
220
|
+
if (!index) {
|
|
221
|
+
const alignments = node.align ?? row.children.map(()=>null);
|
|
222
|
+
this.write('\n| ' + alignments.map((align)=>'center' === align ? ':---:' : 'left' === align ? ':---' : 'right' === align ? '---:' : '---').join(' | ') + ' |');
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function inlineNode(node) {
|
|
148
228
|
return {
|
|
149
|
-
type: '
|
|
150
|
-
name:
|
|
229
|
+
type: 'mdxJsxTextElement',
|
|
230
|
+
name: 'span',
|
|
151
231
|
attributes: [],
|
|
152
|
-
|
|
232
|
+
data: {
|
|
233
|
+
_mdxExplicitJsx: true
|
|
234
|
+
},
|
|
235
|
+
children: [
|
|
236
|
+
node
|
|
237
|
+
]
|
|
153
238
|
};
|
|
154
239
|
}
|
|
240
|
+
function escapeLabel(value) {
|
|
241
|
+
return value.replace(/[\\[\]]/g, '\\$&');
|
|
242
|
+
}
|
|
243
|
+
function getComponentName(name) {
|
|
244
|
+
if (!name) return null;
|
|
245
|
+
const dot = name.indexOf('.');
|
|
246
|
+
return -1 === dot ? name : name.slice(0, dot);
|
|
247
|
+
}
|
|
155
248
|
function createTextExpression(text) {
|
|
156
249
|
const stringified = JSON.stringify(text);
|
|
157
250
|
return {
|
|
@@ -193,49 +286,59 @@ function serializeClosingTag(node) {
|
|
|
193
286
|
if (!name) return '';
|
|
194
287
|
return `</${name}>`;
|
|
195
288
|
}
|
|
196
|
-
const
|
|
289
|
+
const mdxExtension = mdxToMarkdown();
|
|
290
|
+
const markdownOptions = {
|
|
197
291
|
bullet: '-',
|
|
198
292
|
emphasis: '_',
|
|
199
293
|
fences: true,
|
|
200
294
|
incrementListMarker: true,
|
|
295
|
+
extensions: [
|
|
296
|
+
mdxExtension,
|
|
297
|
+
gfmToMarkdown()
|
|
298
|
+
],
|
|
201
299
|
handlers: {
|
|
202
300
|
mdxjsEsm: ()=>''
|
|
203
301
|
}
|
|
204
|
-
}
|
|
205
|
-
function
|
|
206
|
-
|
|
302
|
+
};
|
|
303
|
+
function stringifyMarkdown(children) {
|
|
304
|
+
return toMarkdown({
|
|
207
305
|
type: 'root',
|
|
208
|
-
children
|
|
209
|
-
|
|
210
|
-
]
|
|
211
|
-
};
|
|
212
|
-
const result = processor.stringify(tempRoot);
|
|
213
|
-
return result;
|
|
306
|
+
children
|
|
307
|
+
}, markdownOptions);
|
|
214
308
|
}
|
|
215
|
-
function
|
|
309
|
+
function prepareTree(tree) {
|
|
216
310
|
const importMap = new Map();
|
|
217
311
|
const esmNodes = new Set();
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const source = statement.source.value;
|
|
225
|
-
for (const specifier of statement.specifiers){
|
|
226
|
-
const localName = specifier.local?.name;
|
|
227
|
-
if (localName) importMap.set(localName, source);
|
|
228
|
-
}
|
|
312
|
+
const mixedNodes = new WeakSet();
|
|
313
|
+
const scan = (node)=>{
|
|
314
|
+
if ('mdxjsEsm' === node.type) {
|
|
315
|
+
esmNodes.add(node);
|
|
316
|
+
for (const statement of node.data?.estree?.body ?? [])if ('ImportDeclaration' === statement.type) for (const specifier of statement.specifiers)importMap.set(specifier.local.name, String(statement.source.value));
|
|
317
|
+
return false;
|
|
229
318
|
}
|
|
230
|
-
|
|
319
|
+
let mixed = isMdxNode(node);
|
|
320
|
+
if ('children' in node) {
|
|
321
|
+
for (const child of node.children)if (scan(child)) mixed = true;
|
|
322
|
+
}
|
|
323
|
+
if (mixed && 'root' !== node.type) mixedNodes.add(node);
|
|
324
|
+
return mixed;
|
|
325
|
+
};
|
|
326
|
+
scan(tree);
|
|
231
327
|
return {
|
|
232
328
|
importMap,
|
|
233
|
-
esmNodes
|
|
329
|
+
esmNodes,
|
|
330
|
+
mixedNodes
|
|
234
331
|
};
|
|
235
332
|
}
|
|
333
|
+
function isJsxNode(node) {
|
|
334
|
+
return 'mdxJsxFlowElement' === node.type || 'mdxJsxTextElement' === node.type;
|
|
335
|
+
}
|
|
336
|
+
function isMdxNode(node) {
|
|
337
|
+
return isJsxNode(node) || 'mdxFlowExpression' === node.type || 'mdxTextExpression' === node.type;
|
|
338
|
+
}
|
|
236
339
|
function shouldKeepJsxElement(nameField, importMap, options) {
|
|
237
340
|
const componentName = getComponentName(nameField);
|
|
238
|
-
if (!componentName) return true;
|
|
341
|
+
if (!componentName || importMap.get(componentName)?.endsWith('.mdx')) return true;
|
|
239
342
|
const { includes, excludes } = options;
|
|
240
343
|
const importSource = importMap.get(componentName);
|
|
241
344
|
if (!includes && !excludes) return true;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../t~0.js";
|
|
3
|
-
import { createHead, pathToFileURL, logger } from "../../
|
|
3
|
+
import { createHead, pathToFileURL, logger } from "../../b~0.js";
|
|
4
4
|
import { hintSSGMDFailed } from "../logger/hint.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);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../t~0.js";
|
|
3
|
-
import { logger } from "../../
|
|
3
|
+
import { logger } from "../../b~0.js";
|
|
4
4
|
import { pMap } from "../../y~0.js";
|
|
5
5
|
import { renderPage } from "./renderPage.js";
|
|
6
6
|
import { SSGConcurrency } from "../ssg/ssgEnv.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { writeFile, mkdir, rm, join, isDebugMode } from "../../
|
|
1
|
+
import { writeFile, mkdir, rm, join, isDebugMode } from "../../b~0.js";
|
|
2
2
|
import { NODE_SSG_MD_BUNDLE_FOLDER, NODE_SSG_MD_BUNDLE_NAME } from "../constants.js";
|
|
3
3
|
import { renderPages } from "./renderPages.js";
|
|
4
4
|
import { emitLlmsTxt } from "./llms/emitLlmsTxt.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHash as external_node_crypto_createHash } from "../../
|
|
1
|
+
import { createHash as external_node_crypto_createHash } from "../../b~0.js";
|
|
2
2
|
function createHash(str, length = 8) {
|
|
3
3
|
return external_node_crypto_createHash('sha256').update(str).digest('hex').slice(0, length);
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../
|
|
1
|
+
import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../b~0.js";
|
|
2
2
|
import { createError } from "./error.js";
|
|
3
3
|
import { importStatementRegex } from "../constants.js";
|
|
4
4
|
const RspackResolveFactory = core_rspack.experiments.resolver.ResolverFactory;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../t~0.js";
|
|
3
|
-
import { node_path, core_rspack, logger } from "../../
|
|
3
|
+
import { node_path, core_rspack, logger } from "../../b~0.js";
|
|
4
4
|
import { pathExists, readJson } from "./fs.js";
|
|
5
5
|
import { PACKAGE_ROOT } from "../constants.js";
|
|
6
6
|
import { hintReactVersion } from "../logger/hint.js";
|
|
@@ -54,6 +54,7 @@ async function resolveReactAlias(isSSR) {
|
|
|
54
54
|
'react',
|
|
55
55
|
'react/jsx-runtime',
|
|
56
56
|
'react/jsx-dev-runtime',
|
|
57
|
+
'react/compiler-runtime',
|
|
57
58
|
'react/package.json',
|
|
58
59
|
'react-dom',
|
|
59
60
|
'react-dom/client',
|
|
@@ -83,6 +84,7 @@ async function resolveReactAlias(isSSR) {
|
|
|
83
84
|
if (resolved.error || !resolved.path) throw Error(resolved.error);
|
|
84
85
|
alias[lib] = resolved.path;
|
|
85
86
|
} catch (e) {
|
|
87
|
+
if ('react/compiler-runtime' === lib) return;
|
|
86
88
|
if (e instanceof Error) {
|
|
87
89
|
logger.warn(`${lib} not found: \n ${picocolors_default().gray(e.toString())}`);
|
|
88
90
|
hintReactVersion();
|