@rspress/core 2.0.7 → 2.0.9
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/0~execa.js +32 -41
- package/dist/0~rslib-runtime.js +38 -0
- package/dist/0~tinypool.js +828 -0
- package/dist/{8311.js → 1688.js} +1 -7
- package/dist/{7397.js → 2240.js} +4 -2
- package/dist/{1361.js → 3294.js} +1 -1
- package/dist/{1965.js → 3425.js} +0 -1
- package/dist/740.js +2470 -0
- package/dist/8006.js +77 -0
- package/dist/8857.js +4827 -0
- package/dist/8857.js.LICENSE.txt +41 -0
- package/dist/cli/index.js +7 -3
- package/dist/config/loadConfigFile.js +1 -1
- package/dist/eject-theme/components/CodeBlock/index.scss +4 -0
- package/dist/eject-theme/components/CodeBlock/index.tsx +14 -6
- package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.scss +1 -1
- package/dist/eject-theme/components/CodeButtonGroup/index.scss +1 -1
- package/dist/eject-theme/components/DocContent/doc.scss +2 -0
- package/dist/eject-theme/components/FallbackHeading/index.tsx +1 -1
- package/dist/eject-theme/components/Link/useLinkNavigate.ts +4 -1
- package/dist/eject-theme/components/Llms/LlmsCopyButton.scss +3 -3
- package/dist/eject-theme/components/Search/SearchPanel.tsx +1 -1
- package/dist/eject-theme/components/Steps/index.scss +32 -13
- package/dist/node/PluginDriver.js +2 -2
- package/dist/node/auto-nav-sidebar/index.js +2 -2
- package/dist/node/auto-nav-sidebar/locales.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +9 -5
- package/dist/node/auto-nav-sidebar/utils.js +8 -2
- package/dist/node/auto-nav-sidebar/walk.js +2 -8
- package/dist/node/constants.js +1 -1
- package/dist/node/eject.js +14 -8
- package/dist/node/initRsbuild.js +6 -6
- package/dist/node/logger/hint.js +9 -6
- package/dist/node/mdx/options.js +15 -4
- package/dist/node/mdx/processor.js +1 -1
- package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +3 -2
- package/dist/node/mdx/rehypePlugins/shiki.d.ts +4 -1
- package/dist/node/mdx/rehypePlugins/shiki.js +5 -3
- package/dist/node/mdx/rehypePlugins/transformers/add-fold.d.ts +7 -1
- package/dist/node/mdx/rehypePlugins/transformers/add-fold.js +23 -6
- package/dist/node/mdx/rehypePlugins/transformers/index.js +6 -6
- package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
- package/dist/node/mdx/remarkPlugins/containerSyntax.js +7 -1
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +6 -2
- package/dist/node/mdx/remarkPlugins/image.d.ts +7 -2
- package/dist/node/mdx/remarkPlugins/image.js +51 -2
- package/dist/node/mdx/remarkPlugins/link.js +7 -3
- package/dist/node/mdx/remarkPlugins/toc.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 +77 -27
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/runtimeModule/i18n.js +10 -6
- 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/ssg/renderPage.js +8 -4
- package/dist/node/ssg/renderPageWorker.js +1 -1
- package/dist/node/ssg/renderPages.js +9 -5
- package/dist/node/ssg/rsbuildPluginSSG.js +20 -7
- 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 +3 -2
- package/dist/node/ssg-md/remarkSplitMdx.js +1 -1
- package/dist/node/ssg-md/renderPage.js +8 -4
- package/dist/node/ssg-md/renderPages.js +7 -3
- 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/error.js +5 -2
- package/dist/node/utils/flattenMdxContent.js +3 -2
- package/dist/node/utils/fs.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/normalizePath.js +3 -2
- package/dist/node/utils/reactAlias.js +7 -3
- package/dist/runtime/App.js +4 -1
- package/dist/runtime/hooks/useWindowSize.test.js +10 -10
- package/dist/runtime/index.d.ts +2 -1
- package/dist/runtime/index.js +2 -1
- package/dist/runtime/initPageData.d.ts +3 -0
- package/dist/runtime/initPageData.js +37 -2
- package/dist/runtime/ssrClientEntry.js +4 -2
- package/dist/theme/assets/success.js +1 -1
- package/dist/theme/assets/wrapped.js +1 -1
- package/dist/theme/components/CodeBlock/index.css +4 -0
- package/dist/theme/components/CodeBlock/index.d.ts +0 -3
- package/dist/theme/components/CodeBlock/index.js +8 -3
- package/dist/theme/components/CodeButtonGroup/CopyCodeButton.css +3 -3
- package/dist/theme/components/CodeButtonGroup/index.css +3 -3
- package/dist/theme/components/DocContent/doc.css +1 -0
- package/dist/theme/components/FallbackHeading/index.js +1 -1
- package/dist/theme/components/Link/useLinkNavigate.js +3 -2
- package/dist/theme/components/Llms/LlmsCopyButton.css +9 -9
- package/dist/theme/components/Llms/LlmsViewOptions.css +2 -2
- package/dist/theme/components/Search/SearchPanel.js +1 -1
- package/dist/theme/components/Steps/index.css +23 -12
- package/dist/theme/logic/useThemeState.js +1 -1
- package/package.json +14 -17
- package/dist/4454.js +0 -8
- package/dist/4524.js +0 -71
- package/dist/8885.js +0 -4
- package/dist/rslib-runtime.js +0 -18
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit, extractTextAndId, github_slugger, headingRank } from "../../../
|
|
1
|
+
import { visit, extractTextAndId, github_slugger, headingRank } from "../../../2240.js";
|
|
2
2
|
const rehypeHeaderAnchor = ()=>{
|
|
3
3
|
const slugger = new github_slugger();
|
|
4
4
|
return (tree)=>{
|
|
@@ -48,4 +48,5 @@ function create(node) {
|
|
|
48
48
|
]
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
var headerAnchor_collectHeaderText = void 0;
|
|
52
|
+
export { headerAnchor_collectHeaderText as collectHeaderText, rehypeHeaderAnchor };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { RehypeShikiOptions } from '@shikijs/rehype';
|
|
2
2
|
import rehypeShiki from '@shikijs/rehype';
|
|
3
|
-
declare function createRehypeShikiOptions(showLineNumbers: boolean, defaultWrapCode: boolean,
|
|
3
|
+
declare function createRehypeShikiOptions(showLineNumbers: boolean, defaultWrapCode: boolean, defaultCodeOverflow?: {
|
|
4
|
+
height?: number;
|
|
5
|
+
behavior?: 'fold' | 'scroll';
|
|
6
|
+
}, options?: Partial<RehypeShikiOptions>): RehypeShikiOptions;
|
|
4
7
|
export { createRehypeShikiOptions, rehypeShiki };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddFold, createCssVariablesTheme, transformerAddWrapCode } from "../../../
|
|
1
|
+
import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddFold, createCssVariablesTheme, transformerAddWrapCode } from "../../../2240.js";
|
|
2
2
|
const cssVariablesTheme = createCssVariablesTheme({
|
|
3
3
|
name: 'css-variables',
|
|
4
4
|
variablePrefix: '--shiki-',
|
|
5
5
|
variableDefaults: {},
|
|
6
6
|
fontStyle: true
|
|
7
7
|
});
|
|
8
|
-
function createRehypeShikiOptions(showLineNumbers, defaultWrapCode, options) {
|
|
8
|
+
function createRehypeShikiOptions(showLineNumbers, defaultWrapCode, defaultCodeOverflow, options) {
|
|
9
9
|
const { transformers = [], ...restOptions } = options || {};
|
|
10
10
|
const newTransformers = [
|
|
11
11
|
transformerAddTitle(),
|
|
@@ -16,7 +16,9 @@ function createRehypeShikiOptions(showLineNumbers, defaultWrapCode, options) {
|
|
|
16
16
|
transformerAddWrapCode({
|
|
17
17
|
defaultWrapCode
|
|
18
18
|
}),
|
|
19
|
-
transformerAddFold(
|
|
19
|
+
transformerAddFold({
|
|
20
|
+
defaultCodeOverflow
|
|
21
|
+
}),
|
|
20
22
|
...transformers
|
|
21
23
|
];
|
|
22
24
|
return {
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { ShikiTransformer } from 'shiki';
|
|
2
2
|
export declare const SHIKI_TRANSFORMER_ADD_FOLD = "shiki-transformer:add-fold";
|
|
3
|
+
export interface ITransformerAddFoldOptions {
|
|
4
|
+
defaultCodeOverflow?: {
|
|
5
|
+
height?: number;
|
|
6
|
+
behavior?: 'fold' | 'scroll';
|
|
7
|
+
};
|
|
8
|
+
}
|
|
3
9
|
/**
|
|
4
10
|
* @private compile-time only
|
|
5
11
|
*/
|
|
6
|
-
export declare function transformerAddFold(): ShikiTransformer;
|
|
12
|
+
export declare function transformerAddFold(options?: ITransformerAddFoldOptions): ShikiTransformer;
|
|
@@ -17,18 +17,35 @@ function parseHeightFromMeta(meta) {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
function transformerAddFold() {
|
|
20
|
+
function transformerAddFold(options = {}) {
|
|
21
|
+
const { defaultCodeOverflow } = options;
|
|
21
22
|
return {
|
|
22
23
|
name: SHIKI_TRANSFORMER_ADD_FOLD,
|
|
23
24
|
pre (pre) {
|
|
24
25
|
const meta = this.options.meta?.__raw;
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const metaFold = hasFoldInMeta(meta);
|
|
27
|
+
const metaHeight = parseHeightFromMeta(meta);
|
|
28
|
+
const hasExplicitMeta = void 0 !== metaFold || void 0 !== metaHeight;
|
|
29
|
+
if (hasExplicitMeta) {
|
|
30
|
+
if (metaFold) pre.properties = {
|
|
29
31
|
...pre.properties,
|
|
30
32
|
fold: true,
|
|
31
|
-
height
|
|
33
|
+
height: metaHeight ?? DEFAULT_FOLD_HEIGHT
|
|
34
|
+
};
|
|
35
|
+
else if (void 0 !== metaHeight) pre.properties = {
|
|
36
|
+
...pre.properties,
|
|
37
|
+
height: metaHeight
|
|
38
|
+
};
|
|
39
|
+
} else if (defaultCodeOverflow?.height !== void 0) {
|
|
40
|
+
const behavior = defaultCodeOverflow.behavior ?? 'scroll';
|
|
41
|
+
if ('fold' === behavior) pre.properties = {
|
|
42
|
+
...pre.properties,
|
|
43
|
+
fold: true,
|
|
44
|
+
height: defaultCodeOverflow.height
|
|
45
|
+
};
|
|
46
|
+
else pre.properties = {
|
|
47
|
+
...pre.properties,
|
|
48
|
+
height: defaultCodeOverflow.height
|
|
32
49
|
};
|
|
33
50
|
}
|
|
34
51
|
return pre;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export { SHIKI_TRANSFORMER_ADD_FOLD, transformerAddFold } from "./add-fold.js";
|
|
2
|
+
export { SHIKI_TRANSFORMER_ADD_LANG, transformerAddLang } from "./add-lang.js";
|
|
3
|
+
export { SHIKI_TRANSFORMER_ADD_LINE_NUMBERS, transformerAddLineNumbers } from "./add-line-numbers.js";
|
|
4
|
+
export { SHIKI_TRANSFORMER_ADD_TITLE, transformerAddTitle } from "./add-title.js";
|
|
5
|
+
export { SHIKI_TRANSFORMER_ADD_WRAP_CODE, transformerAddWrapCode } from "./add-wrap-code.js";
|
|
6
|
+
export { SHIKI_TRANSFORMER_META_HIGHLIGHT, transformerCompatibleMetaHighlight } from "./meta-highlight.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_path } from "../../../
|
|
1
|
+
import { node_path } from "../../../2240.js";
|
|
2
2
|
import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
|
|
3
3
|
const remarkBuiltin = ({ globalComponents })=>(tree)=>{
|
|
4
4
|
const demos = globalComponents.map((componentPath)=>{
|
|
@@ -187,4 +187,10 @@ const remarkContainerSyntax = ()=>{
|
|
|
187
187
|
tree.children.unshift(getNamedImportAstNode('Callout', CALLOUT_COMPONENT, '@theme'));
|
|
188
188
|
};
|
|
189
189
|
};
|
|
190
|
-
|
|
190
|
+
var containerSyntax_DIRECTIVE_TYPES = void 0;
|
|
191
|
+
var containerSyntax_REGEX_BEGIN = void 0;
|
|
192
|
+
var containerSyntax_REGEX_END = void 0;
|
|
193
|
+
var containerSyntax_REGEX_GH_BEGIN = void 0;
|
|
194
|
+
var containerSyntax_TITLE_REGEX_IN_MD = void 0;
|
|
195
|
+
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 };
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __webpack_require__ } from "../../../0~rslib-runtime.js";
|
|
2
|
+
import "../../../8006.js";
|
|
3
|
+
import { visit, node_path, logger, cwd, readFile } from "../../../3425.js";
|
|
2
4
|
import { createError } from "../../utils/error.js";
|
|
5
|
+
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
6
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
3
7
|
const ERROR_PREFIX = '[remarkFileCodeBlock]';
|
|
4
8
|
function parseFileFromMeta(meta) {
|
|
5
9
|
if (!meta) return '';
|
|
@@ -16,7 +20,7 @@ const remarkFileCodeBlock = ({ filepath, addDependency })=>async (tree)=>{
|
|
|
16
20
|
const { meta, value, lang } = node;
|
|
17
21
|
const file = parseFileFromMeta(meta ?? '');
|
|
18
22
|
if (!file) return;
|
|
19
|
-
const originalMetaForErrorInfo =
|
|
23
|
+
const originalMetaForErrorInfo = picocolors_default().cyan(`\`\`\`${lang} ${meta}`);
|
|
20
24
|
if (file.startsWith('./') || file.startsWith('../') || file.startsWith('<root>/')) {
|
|
21
25
|
let resolvedFilePath;
|
|
22
26
|
resolvedFilePath = file.startsWith('<root>/') ? node_path.join(cwd(), file.slice(7)) : node_path.join(node_path.dirname(filepath), file);
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { type MarkdownOptions } from '@rspress/shared';
|
|
1
2
|
import type { Root } from 'mdast';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const remarkImage:
|
|
3
|
+
import type { VFile } from 'vfile';
|
|
4
|
+
export declare const remarkImage: ({ docDirectory, remarkImageOptions, lint, }: {
|
|
5
|
+
docDirectory: string;
|
|
6
|
+
remarkImageOptions?: MarkdownOptions["image"];
|
|
7
|
+
lint?: boolean;
|
|
8
|
+
}) => (tree: Root, file: VFile) => void;
|
|
@@ -1,10 +1,56 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __webpack_require__ } from "../../../0~rslib-runtime.js";
|
|
2
|
+
import "../../../8006.js";
|
|
3
|
+
import { visit, node_path, logger, isDataUrl, existsSync, getNodeAttribute, isExternalUrl, isProduction, parseUrl } from "../../../2240.js";
|
|
4
|
+
import { createError } from "../../utils/error.js";
|
|
5
|
+
import { PUBLIC_DIR } from "../../constants.js";
|
|
2
6
|
import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
|
|
7
|
+
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
8
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
3
9
|
const normalizeImageUrl = (imageUrl)=>{
|
|
4
10
|
if (isExternalUrl(imageUrl) || imageUrl.startsWith('/')) return '';
|
|
5
11
|
return imageUrl;
|
|
6
12
|
};
|
|
7
|
-
|
|
13
|
+
function image_checkDeadImages(checkDeadImages, deadImages, file, lint) {
|
|
14
|
+
const errorInfos = [];
|
|
15
|
+
const excludes = 'object' == typeof checkDeadImages ? checkDeadImages.excludes : void 0;
|
|
16
|
+
const excludesUrl = Array.isArray(excludes) ? new Set(excludes) : void 0;
|
|
17
|
+
const excludesFn = 'function' == typeof excludes ? excludes : void 0;
|
|
18
|
+
[
|
|
19
|
+
...deadImages.entries()
|
|
20
|
+
].forEach(([imageUrl, resolvedPath])=>{
|
|
21
|
+
if (excludesUrl?.has(imageUrl)) return;
|
|
22
|
+
if (excludesFn?.(imageUrl)) return;
|
|
23
|
+
errorInfos.push([
|
|
24
|
+
imageUrl,
|
|
25
|
+
resolvedPath
|
|
26
|
+
]);
|
|
27
|
+
});
|
|
28
|
+
if (errorInfos.length > 0) {
|
|
29
|
+
const message = `Dead images found${lint ? '' : ` in ${picocolors_default().cyan(file.path)}`}:
|
|
30
|
+
${errorInfos.map(([imageUrl, resolved])=>` ${picocolors_default().green(`""`)} ${picocolors_default().gray(resolved)}`).join('\n')}`;
|
|
31
|
+
if (lint) file.message(message);
|
|
32
|
+
else {
|
|
33
|
+
logger.error(message);
|
|
34
|
+
if (isProduction()) throw createError('Dead image found');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function resolveImage(imageUrl, filePath, docDirectory, deadImages) {
|
|
39
|
+
if (!imageUrl) return;
|
|
40
|
+
if (isExternalUrl(imageUrl)) return;
|
|
41
|
+
if (isDataUrl(imageUrl)) return;
|
|
42
|
+
const { url } = parseUrl(imageUrl);
|
|
43
|
+
if (url.startsWith('/')) {
|
|
44
|
+
const resolvedPath = node_path.join(docDirectory, PUBLIC_DIR, url);
|
|
45
|
+
if (!existsSync(resolvedPath)) deadImages.set(imageUrl, resolvedPath);
|
|
46
|
+
} else {
|
|
47
|
+
const resolvedPath = node_path.resolve(node_path.dirname(filePath), url);
|
|
48
|
+
if (!existsSync(resolvedPath)) deadImages.set(imageUrl, resolvedPath);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const remarkImage = ({ docDirectory, remarkImageOptions, lint })=>(tree, file)=>{
|
|
52
|
+
const { checkDeadImages: shouldCheckDeadImages = true } = remarkImageOptions ?? {};
|
|
53
|
+
const deadImages = new Map();
|
|
8
54
|
const images = [];
|
|
9
55
|
const getMdxSrcAttribute = (tempVar)=>({
|
|
10
56
|
type: 'mdxJsxAttribute',
|
|
@@ -32,6 +78,7 @@ const remarkImage = ()=>(tree, _file)=>{
|
|
|
32
78
|
visit(tree, 'image', (node)=>{
|
|
33
79
|
const { alt, url } = node;
|
|
34
80
|
if (!url) return;
|
|
81
|
+
if (shouldCheckDeadImages) resolveImage(url, file.path, docDirectory, deadImages);
|
|
35
82
|
const imagePath = normalizeImageUrl(url);
|
|
36
83
|
if (!imagePath) return;
|
|
37
84
|
const tempVariableName = `image${images.length}`;
|
|
@@ -54,6 +101,7 @@ const remarkImage = ()=>(tree, _file)=>{
|
|
|
54
101
|
if ('mdxJsxFlowElement' !== node.type && 'mdxJsxTextElement' !== node.type || 'img' !== node.name) return;
|
|
55
102
|
const srcAttr = getNodeAttribute(node, 'src', true);
|
|
56
103
|
if ('string' != typeof srcAttr?.value) return;
|
|
104
|
+
if (shouldCheckDeadImages) resolveImage(srcAttr.value, file.path, docDirectory, deadImages);
|
|
57
105
|
const imagePath = normalizeImageUrl(srcAttr.value);
|
|
58
106
|
if (!imagePath) return;
|
|
59
107
|
const tempVariableName = `image${images.length}`;
|
|
@@ -61,5 +109,6 @@ const remarkImage = ()=>(tree, _file)=>{
|
|
|
61
109
|
images.push(getDefaultImportAstNode(tempVariableName, imagePath));
|
|
62
110
|
});
|
|
63
111
|
tree.children.unshift(...images);
|
|
112
|
+
if (shouldCheckDeadImages) image_checkDeadImages(shouldCheckDeadImages, deadImages, file, lint);
|
|
64
113
|
};
|
|
65
114
|
export { remarkImage };
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __webpack_require__ } from "../../../0~rslib-runtime.js";
|
|
2
|
+
import "../../../8006.js";
|
|
3
|
+
import { normalizeHref, node_path, addLeadingSlash, logger, visit, isExternalUrl, isProduction, parseUrl, withBase } from "../../../3425.js";
|
|
2
4
|
import { hintRelativeMarkdownLink } from "../../logger/hint.js";
|
|
3
5
|
import { createError } from "../../utils/error.js";
|
|
6
|
+
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
7
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
4
8
|
function link_checkDeadLinks(checkDeadLinks, internalLinks, file, lint) {
|
|
5
9
|
const errorInfos = [];
|
|
6
10
|
const excludes = 'object' == typeof checkDeadLinks ? checkDeadLinks.excludes : void 0;
|
|
@@ -20,8 +24,8 @@ function link_checkDeadLinks(checkDeadLinks, internalLinks, file, lint) {
|
|
|
20
24
|
});
|
|
21
25
|
if (errorInfos.length > 0) {
|
|
22
26
|
if (possibleBreakingChange) hintRelativeMarkdownLink();
|
|
23
|
-
const message = `Dead links found${lint ? '' : ` in ${
|
|
24
|
-
${errorInfos.map(([nodeUrl, link])=>` ${
|
|
27
|
+
const message = `Dead links found${lint ? '' : ` in ${picocolors_default().cyan(file.path)}`}:
|
|
28
|
+
${errorInfos.map(([nodeUrl, link])=>` ${picocolors_default().green(`"[..](${nodeUrl})"`)} ${picocolors_default().gray(link)}`).join('\n')}`;
|
|
25
29
|
if (lint) file.message(message);
|
|
26
30
|
else {
|
|
27
31
|
logger.error(message);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { github_slugger, visitChildren, extractTextAndId } from "../../../
|
|
1
|
+
import { github_slugger, visitChildren, extractTextAndId } from "../../../3294.js";
|
|
2
2
|
const extractChildText = (child)=>{
|
|
3
3
|
if ('link' === child.type) return child.children?.map(extractChildText).join('') ?? '';
|
|
4
4
|
if ('strong' === child.type) return `**${child.children?.map(extractChildText).join('') ?? ''}**`;
|
|
@@ -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 "../../740.js";
|
|
2
2
|
import { PUBLIC_DIR } from "../constants.js";
|
|
3
3
|
import { RoutePage, absolutePathToRoutePath, absolutePathToRelativePath } from "./RoutePage.js";
|
|
4
4
|
import { createError } from "../utils/error.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unified, node_path,
|
|
1
|
+
import { unified, node_path, promises, loadFrontMatter, remove, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../740.js";
|
|
2
2
|
import { applyReplaceRules } from "../utils/applyReplaceRules.js";
|
|
3
3
|
import { flattenMdxContent } from "../utils/flattenMdxContent.js";
|
|
4
4
|
import { importStatementRegex } from "../constants.js";
|
|
@@ -14,17 +14,9 @@ const remarkRemoveCodeBlocks = ()=>(tree)=>{
|
|
|
14
14
|
const remarkRemoveImages = ()=>(tree)=>{
|
|
15
15
|
remove(tree, 'image');
|
|
16
16
|
};
|
|
17
|
-
const
|
|
18
|
-
visit(tree, 'link', (node)=>{
|
|
19
|
-
node.url = '';
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
const createProcessor = (searchCodeBlocks)=>unified().use(remark_parse).use(remark_gfm).use(remarkRemoveImages).use(remarkStripLinkUrls).use(searchCodeBlocks ? [] : [
|
|
17
|
+
const createProcessor = (searchCodeBlocks)=>unified().use(remark_parse).use(remark_gfm).use(remarkRemoveImages).use(searchCodeBlocks ? [] : [
|
|
23
18
|
remarkRemoveCodeBlocks
|
|
24
|
-
])
|
|
25
|
-
bullet: '-',
|
|
26
|
-
listItemIndent: 'one'
|
|
27
|
-
});
|
|
19
|
+
]);
|
|
28
20
|
const processorWithCode = createProcessor(true);
|
|
29
21
|
const processorWithoutCode = createProcessor(false);
|
|
30
22
|
function extractTextFromNode(node) {
|
|
@@ -32,6 +24,77 @@ function extractTextFromNode(node) {
|
|
|
32
24
|
if ('children' in node && Array.isArray(node.children)) return node.children.map(extractTextFromNode).join('');
|
|
33
25
|
return '';
|
|
34
26
|
}
|
|
27
|
+
const SEARCH_SKIP_TYPES = new Set([
|
|
28
|
+
'image',
|
|
29
|
+
'imageReference',
|
|
30
|
+
'definition',
|
|
31
|
+
'footnoteDefinition',
|
|
32
|
+
'footnoteReference',
|
|
33
|
+
'html',
|
|
34
|
+
'thematicBreak',
|
|
35
|
+
'mdxJsxFlowElement',
|
|
36
|
+
'mdxJsxTextElement',
|
|
37
|
+
'mdxFlowExpression',
|
|
38
|
+
'mdxTextExpression',
|
|
39
|
+
'mdxjsEsm'
|
|
40
|
+
]);
|
|
41
|
+
const SEARCH_BLOCK_TYPES = new Set([
|
|
42
|
+
'paragraph',
|
|
43
|
+
'heading',
|
|
44
|
+
'listItem',
|
|
45
|
+
'tableRow'
|
|
46
|
+
]);
|
|
47
|
+
function extractSearchText(node, codeblocks) {
|
|
48
|
+
const { type } = node;
|
|
49
|
+
if (SEARCH_SKIP_TYPES.has(type)) return [];
|
|
50
|
+
if ('code' === type && !codeblocks) return [];
|
|
51
|
+
if ('break' === type) return [
|
|
52
|
+
'\n'
|
|
53
|
+
];
|
|
54
|
+
if ('text' === type || 'inlineCode' === type) return [
|
|
55
|
+
node.value
|
|
56
|
+
];
|
|
57
|
+
if ('code' === type) return [
|
|
58
|
+
`\n${node.value}\n`
|
|
59
|
+
];
|
|
60
|
+
const result = [];
|
|
61
|
+
if ('children' in node) for (const child of node.children)result.push(...extractSearchText(child, codeblocks));
|
|
62
|
+
if (SEARCH_BLOCK_TYPES.has(type)) result.push('\n');
|
|
63
|
+
if ('tableCell' === type) result.push('\t');
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
function buildSearchContent(tree, rawToc, codeblocks) {
|
|
67
|
+
const parts = [];
|
|
68
|
+
const headingCharIndexes = [];
|
|
69
|
+
let tocIndex = 0;
|
|
70
|
+
let contentLength = 0;
|
|
71
|
+
let skippedFirstH1 = false;
|
|
72
|
+
for (const node of tree.children){
|
|
73
|
+
if ('heading' === node.type && 1 === node.depth && !skippedFirstH1) {
|
|
74
|
+
skippedFirstH1 = true;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const text = extractSearchText(node, codeblocks).join('').replaceAll('\t\n', '\n').trim();
|
|
78
|
+
if (text) {
|
|
79
|
+
if (parts.length > 0) contentLength += 2;
|
|
80
|
+
if ('heading' === node.type && node.depth >= 2 && node.depth < 5) {
|
|
81
|
+
if (tocIndex < rawToc.length) {
|
|
82
|
+
headingCharIndexes.push(contentLength);
|
|
83
|
+
tocIndex++;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
contentLength += text.length;
|
|
87
|
+
parts.push(text);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
content: parts.join('\n\n'),
|
|
92
|
+
toc: rawToc.map((item, index)=>({
|
|
93
|
+
...item,
|
|
94
|
+
charIndex: index < headingCharIndexes.length ? headingCharIndexes[index] : -1
|
|
95
|
+
}))
|
|
96
|
+
};
|
|
97
|
+
}
|
|
35
98
|
const SKIP_NODE_TYPES = new Set([
|
|
36
99
|
'code',
|
|
37
100
|
'html',
|
|
@@ -121,21 +184,7 @@ async function getPageIndexInfoByRoute(route, options) {
|
|
|
121
184
|
}
|
|
122
185
|
};
|
|
123
186
|
const processedTree = await processor.run(tree);
|
|
124
|
-
|
|
125
|
-
if (processedContent.startsWith(`# ${title}`)) processedContent = processedContent.slice(`# ${title}`.length).trimStart();
|
|
126
|
-
const toc = rawToc.map((item)=>{
|
|
127
|
-
const match = item.id.match(/-(\d+)$/);
|
|
128
|
-
const headingPrefix = '#'.repeat(item.depth);
|
|
129
|
-
let position = -1;
|
|
130
|
-
if (match) for(let i = 0; i < Number(match[1]); i++){
|
|
131
|
-
position = processedContent.indexOf(`${headingPrefix} ${item.text}`, position + 1);
|
|
132
|
-
if (-1 === position) break;
|
|
133
|
-
}
|
|
134
|
-
return {
|
|
135
|
-
...item,
|
|
136
|
-
charIndex: processedContent.indexOf(`${headingPrefix} ${item.text}`, position + 1)
|
|
137
|
-
};
|
|
138
|
-
});
|
|
187
|
+
const { content: processedContent, toc } = buildSearchContent(processedTree, rawToc, searchCodeBlocks);
|
|
139
188
|
return {
|
|
140
189
|
...defaultIndexInfo,
|
|
141
190
|
title: frontmatter.title || title,
|
|
@@ -158,4 +207,5 @@ async function extractPageData(routeService, options) {
|
|
|
158
207
|
}));
|
|
159
208
|
return pageData;
|
|
160
209
|
}
|
|
161
|
-
|
|
210
|
+
var extractPageData_getPageIndexInfoByRoute = void 0;
|
|
211
|
+
export { extractPageData, extractPageData_getPageIndexInfoByRoute as getPageIndexInfoByRoute };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../
|
|
1
|
+
import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../740.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 [
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
2
|
+
import "../../8006.js";
|
|
3
|
+
import { external_node_module_createRequire, join, logger } from "../../740.js";
|
|
2
4
|
import { DEFAULT_I18N_TEXT } from "./DEFAULT_I18N_TEXT.js";
|
|
3
5
|
import { createError } from "../utils/error.js";
|
|
4
6
|
import { pathExists } from "../utils/fs.js";
|
|
5
|
-
const
|
|
7
|
+
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
8
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
9
|
+
const i18n_require = external_node_module_createRequire(import.meta.url);
|
|
6
10
|
const DEFAULT_I18N_SOURCE_PATH = join(process.cwd(), 'i18n.json');
|
|
7
11
|
function mergeI18nData(...sources) {
|
|
8
12
|
const result = {};
|
|
@@ -39,7 +43,7 @@ async function getI18nData(docConfig, pluginDriver) {
|
|
|
39
43
|
throw e;
|
|
40
44
|
}
|
|
41
45
|
else i18nSourceFull = mergeI18nData(i18nSourceFull, i18nSource);
|
|
42
|
-
const cyan =
|
|
46
|
+
const cyan = picocolors_default().cyan;
|
|
43
47
|
const filteredI18nSource = {};
|
|
44
48
|
for(const key in i18nSourceFull){
|
|
45
49
|
filteredI18nSource[key] = {};
|
|
@@ -50,19 +54,19 @@ async function getI18nData(docConfig, pluginDriver) {
|
|
|
50
54
|
if (enText) filteredI18nSource[key][lang] = enText;
|
|
51
55
|
else {
|
|
52
56
|
logger.error(`${logPrefix} i18n key ${cyan(key)} has no text for lang ${cyan(lang)}, and no fallback ${cyan('en')} text either.`);
|
|
53
|
-
throw createError(`i18n text missing for ${
|
|
57
|
+
throw createError(`i18n text missing for ${picocolors_default().cyan(key)}`);
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
if (logKeys.size > 0 && !logged) {
|
|
58
62
|
logger.warn(`${logPrefix} The following i18n keys are missing for some languages and have fallen back to 'en':
|
|
59
|
-
${
|
|
63
|
+
${picocolors_default().gray(JSON.stringify(Object.fromEntries([
|
|
60
64
|
...logKeys.keys()
|
|
61
65
|
].map((i)=>[
|
|
62
66
|
i,
|
|
63
67
|
'...'
|
|
64
68
|
])), null, 2))}
|
|
65
|
-
You can provide translations via ${
|
|
69
|
+
You can provide translations via ${picocolors_default().cyan('i18n.json')} file or ${picocolors_default().cyan('i18nSource')} config in rspress.config.ts`);
|
|
66
70
|
logged = true;
|
|
67
71
|
}
|
|
68
72
|
return filteredI18nSource;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SEARCH_INDEX_NAME, groupBy } from "../../../
|
|
1
|
+
import { SEARCH_INDEX_NAME, groupBy } from "../../../740.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 "../../../740.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 "../../../740.js";
|
|
2
2
|
import { normalizeThemeConfig } from "./normalizeThemeConfig.js";
|
|
3
3
|
async function createSiteData(userConfig) {
|
|
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 "../../../740.js";
|
|
2
2
|
import { getI18nData } from "../i18n.js";
|
|
3
3
|
import { applyReplaceRules } from "../../utils/applyReplaceRules.js";
|
|
4
4
|
async function normalizeThemeConfig(docConfig) {
|
package/dist/node/serve.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
2
|
+
import "../../8006.js";
|
|
3
|
+
import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../1688.js";
|
|
2
4
|
import { hintSSGFailed } from "../logger/hint.js";
|
|
3
5
|
import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
|
|
6
|
+
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
7
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
4
8
|
async function renderPage(route, htmlTemplate, configHead, ssrBundlePath) {
|
|
5
9
|
let render;
|
|
6
10
|
try {
|
|
@@ -9,7 +13,7 @@ async function renderPage(route, htmlTemplate, configHead, ssrBundlePath) {
|
|
|
9
13
|
render = ssrExports.render;
|
|
10
14
|
} catch (e) {
|
|
11
15
|
if (e instanceof Error) {
|
|
12
|
-
logger.error(`Failed to load SSG bundle: ${
|
|
16
|
+
logger.error(`Failed to load SSG bundle: ${picocolors_default().yellow(ssrBundlePath)}: ${e.message}`);
|
|
13
17
|
logger.debug(e);
|
|
14
18
|
hintSSGFailed();
|
|
15
19
|
}
|
|
@@ -22,8 +26,8 @@ async function renderPage(route, htmlTemplate, configHead, ssrBundlePath) {
|
|
|
22
26
|
({ appHtml } = await render(routePath, head));
|
|
23
27
|
} catch (e) {
|
|
24
28
|
if (e instanceof Error) {
|
|
25
|
-
logger.error(`Page "${
|
|
26
|
-
${absolutePath ?
|
|
29
|
+
logger.error(`Page "${picocolors_default().yellow(routePath)}" SSG rendering failed.
|
|
30
|
+
${absolutePath ? picocolors_default().gray(` File: ${absolutePath}\n`) : ''} ${picocolors_default().gray(e.toString())}`);
|
|
27
31
|
throw e;
|
|
28
32
|
}
|
|
29
33
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { workerData } from "../../9224.js";
|
|
2
2
|
import { createError } from "../utils/error.js";
|
|
3
|
-
import { pMap } from "../../
|
|
3
|
+
import { pMap } from "../../1688.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,10 +1,14 @@
|
|
|
1
1
|
/*! LICENSE: renderPages.js.LICENSE.txt */
|
|
2
|
-
import {
|
|
2
|
+
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
3
|
+
import "../../8006.js";
|
|
4
|
+
import { chunk, logger } from "../../740.js";
|
|
3
5
|
import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
|
|
4
|
-
import { pMap } from "../../
|
|
6
|
+
import { pMap } from "../../1688.js";
|
|
5
7
|
import { renderPage } from "./renderPage.js";
|
|
6
8
|
import { hintSSGFailed } from "../logger/hint.js";
|
|
7
9
|
import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
|
|
10
|
+
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
11
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
8
12
|
const routePath2HtmlFileName = (routePath)=>{
|
|
9
13
|
let fileName = routePath;
|
|
10
14
|
fileName = fileName.endsWith('/') ? `${routePath}index.html` : `${routePath}.html`;
|
|
@@ -36,7 +40,7 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
|
|
|
36
40
|
const MAX_DISPLAY_ROUTES = 10;
|
|
37
41
|
const displayedRoutes = csrRoutePaths.slice(0, MAX_DISPLAY_ROUTES);
|
|
38
42
|
const remainingCount = csrRoutePaths.length - MAX_DISPLAY_ROUTES;
|
|
39
|
-
logger.info(`Some routes (${
|
|
43
|
+
logger.info(`Some routes (${picocolors_default().yellow(csrRoutePaths.length)} total) are ignored in SSG and fallback to CSR via \`ssg.experimentalExcludeRoutePaths\`: ${picocolors_default().yellow(displayedRoutes.join(', '))}${remainingCount > 0 ? picocolors_default().dim(` ... and ${remainingCount} more`) : ''}`);
|
|
40
44
|
await Promise.all(promiseList);
|
|
41
45
|
routes.length = 0;
|
|
42
46
|
routes.push(...ssgRoutes);
|
|
@@ -44,7 +48,7 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
|
|
|
44
48
|
}
|
|
45
49
|
if ('object' == typeof ssg && ssg?.experimentalWorker) {
|
|
46
50
|
const numberOfThreads = getNumberOfThreads(routes.length);
|
|
47
|
-
const Tinypool = await import("tinypool").then((m)=>m.default);
|
|
51
|
+
const Tinypool = await import("../../0~tinypool.js").then((m)=>m.default);
|
|
48
52
|
const pool = new Tinypool({
|
|
49
53
|
filename: new URL('./renderPageWorker.js', import.meta.url).href,
|
|
50
54
|
concurrentTasksPerWorker: 1,
|
|
@@ -83,7 +87,7 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
|
|
|
83
87
|
concurrency: SSGConcurrency()
|
|
84
88
|
});
|
|
85
89
|
const totalTime = Date.now() - startTime;
|
|
86
|
-
logger.success(`Pages rendered in ${
|
|
90
|
+
logger.success(`Pages rendered in ${picocolors_default().yellow(totalTime)} ms.`);
|
|
87
91
|
} catch (e) {
|
|
88
92
|
if (e instanceof Error) {
|
|
89
93
|
logger.error(`Pages render error: ${e.message}`);
|