@rspress/core 2.0.12 → 2.0.14
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 +1 -1
- package/dist/0~rslib-runtime.js +9 -5
- package/dist/{2235.js → 4942.js} +12 -9
- package/dist/{8857.js → 5580.js} +3 -3
- package/dist/6646.js +3 -0
- package/dist/{1688.js → 7261.js} +6 -1
- package/dist/{8006.js → 7986.js} +1 -6
- package/dist/cli/index.js +4 -4
- package/dist/config/loadConfigFile.js +1 -1
- package/dist/eject-theme/components/Banner/index.scss +11 -0
- package/dist/eject-theme/components/Banner/index.tsx +5 -1
- package/dist/eject-theme/components/CodeBlock/index.test.tsx +49 -0
- package/dist/eject-theme/components/CodeBlock/index.tsx +1 -1
- package/dist/eject-theme/components/CodeButtonGroup/index.tsx +5 -2
- package/dist/eject-theme/components/FallbackHeading/index.test.tsx +45 -0
- package/dist/eject-theme/components/FallbackHeading/index.tsx +1 -1
- package/dist/eject-theme/components/Link/index.tsx +6 -0
- package/dist/eject-theme/components/Link/useLinkNavigate.ts +2 -2
- package/dist/eject-theme/components/Outline/index.tsx +0 -6
- package/dist/eject-theme/components/Overview/index.test.tsx +57 -0
- package/dist/eject-theme/components/Overview/index.tsx +1 -1
- package/dist/eject-theme/components/OverviewGroup/index.test.tsx +61 -0
- package/dist/eject-theme/components/OverviewGroup/index.tsx +1 -1
- package/dist/eject-theme/components/PackageManagerTabs/index.test.tsx +54 -0
- package/dist/eject-theme/components/PackageManagerTabs/index.tsx +1 -1
- package/dist/eject-theme/components/Search/SearchPanel.tsx +1 -0
- package/dist/eject-theme/components/Search/logic/search.ts +15 -16
- package/dist/eject-theme/components/SidebarMenu/index.tsx +10 -3
- package/dist/eject-theme/components/SidebarMenu/useSidebarMenu.tsx +12 -3
- package/dist/eject-theme/components/SocialLinks/GithubStars.tsx +120 -0
- package/dist/eject-theme/components/SocialLinks/SocialLink.tsx +5 -0
- package/dist/eject-theme/components/SocialLinks/index.scss +17 -0
- package/dist/eject-theme/components/Steps/index.scss +6 -4
- package/dist/eject-theme/components/Tabs/index.test.tsx +51 -0
- package/dist/eject-theme/components/Tabs/index.tsx +1 -1
- package/dist/eject-theme/components/Tag/index.test.tsx +55 -0
- package/dist/eject-theme/components/Tag/index.tsx +19 -5
- package/dist/index.js +1 -1
- 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 +3 -4
- package/dist/node/auto-nav-sidebar/utils.js +1 -1
- package/dist/node/auto-nav-sidebar/walk.js +1 -1
- package/dist/node/constants.js +3 -3
- package/dist/node/eject.js +2 -2
- package/dist/node/initRsbuild.js +20 -14
- package/dist/node/logger/hint.js +1 -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/mdx/remarkPlugins/fileCodeBlock.js +2 -2
- package/dist/node/mdx/remarkPlugins/image.js +3 -4
- package/dist/node/mdx/remarkPlugins/link.js +2 -2
- package/dist/node/mdx/remarkPlugins/toc.js +1 -1
- package/dist/node/medium-zoom/index.js +1 -1
- package/dist/node/route/RoutePage.js +1 -1
- package/dist/node/route/RouteService.js +2 -3
- package/dist/node/route/extractPageData.js +1 -1
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +119 -112
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +7 -0
- package/dist/node/runtimeModule/i18n.js +2 -2
- 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 +33 -9
- package/dist/node/serve.js +1 -1
- package/dist/node/ssg/htmlFile.d.ts +2 -0
- package/dist/node/ssg/htmlFile.js +14 -0
- package/dist/node/ssg/renderPage.js +2 -2
- package/dist/node/ssg/renderPageWorker.d.ts +3 -6
- package/dist/node/ssg/renderPageWorker.js +24 -4
- package/dist/node/ssg/renderPages.d.ts +1 -1
- package/dist/node/ssg/renderPages.js +19 -18
- package/dist/node/ssg/rsbuildPluginSSG.js +2 -2
- 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.js +1 -1
- package/dist/node/ssg-md/renderPage.js +2 -2
- package/dist/node/ssg-md/renderPages.js +3 -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 +1 -1
- package/dist/node/utils/flattenMdxContent.js +1 -1
- package/dist/node/utils/fs.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/normalizePath.js +1 -1
- package/dist/node/utils/reactAlias.js +2 -2
- package/dist/runtime/App.js +1 -1
- package/dist/theme/components/Banner/index.css +11 -0
- package/dist/theme/components/Banner/index.js +1 -0
- package/dist/theme/components/CodeBlock/index.js +1 -1
- package/dist/theme/components/CodeButtonGroup/index.js +4 -2
- package/dist/theme/components/FallbackHeading/index.js +1 -1
- package/dist/theme/components/Link/index.js +6 -0
- package/dist/theme/components/Link/useLinkNavigate.js +2 -2
- package/dist/theme/components/Outline/index.js +1 -3
- package/dist/theme/components/Overview/index.js +1 -1
- package/dist/theme/components/OverviewGroup/index.js +1 -1
- package/dist/theme/components/PackageManagerTabs/index.js +1 -1
- package/dist/theme/components/Search/SearchPanel.js +1 -0
- package/dist/theme/components/Search/logic/search.js +12 -7
- package/dist/theme/components/SidebarMenu/index.d.ts +3 -0
- package/dist/theme/components/SidebarMenu/index.js +4 -3
- package/dist/theme/components/SidebarMenu/useSidebarMenu.d.ts +2 -1
- package/dist/theme/components/SidebarMenu/useSidebarMenu.js +7 -3
- package/dist/theme/components/SocialLinks/GithubStars.d.ts +7 -0
- package/dist/theme/components/SocialLinks/GithubStars.js +85 -0
- package/dist/theme/components/SocialLinks/SocialLink.js +5 -0
- package/dist/theme/components/SocialLinks/index.css +19 -0
- package/dist/theme/components/Steps/index.css +6 -4
- package/dist/theme/components/Tabs/index.js +1 -1
- package/dist/theme/components/Tag/index.js +9 -5
- package/dist/theme/layout/DocLayout/index.js +2 -2
- package/dist/theme/layout/HomeLayout/index.js +1 -1
- package/dist/theme/layout/Layout/index.js +1 -1
- package/package.json +13 -14
- package/dist/9224.js +0 -1
- package/dist/runtime/BrowserOnly.test.d.ts +0 -1
- /package/dist/{0~1402.js → 0~8787.js} +0 -0
- /package/dist/{3323.js → 3358.js} +0 -0
- /package/dist/{8857.js.LICENSE.txt → 5580.js.LICENSE.txt} +0 -0
- /package/dist/{3294.js → 8005.js} +0 -0
- /package/dist/{6162.js → 9283.js} +0 -0
- /package/dist/{8474.js → 9882.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getIconUrlPath } from "../../../
|
|
1
|
+
import { getIconUrlPath } from "../../../4942.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 "../../../4942.js";
|
|
2
2
|
import { getI18nData } from "../i18n.js";
|
|
3
3
|
import { applyReplaceRules } from "../../utils/applyReplaceRules.js";
|
|
4
4
|
async function normalizeThemeConfig(docConfig) {
|
|
@@ -1,23 +1,47 @@
|
|
|
1
|
-
import { logger } from "../../../
|
|
1
|
+
import { isProduction, logger } from "../../../4942.js";
|
|
2
2
|
import { modifyConfigWithAutoNavSide } from "../../auto-nav-sidebar/index.js";
|
|
3
3
|
import { createSiteData } from "./createSiteData.js";
|
|
4
4
|
const siteDataVMPlugin = (context)=>{
|
|
5
5
|
const { config, pluginDriver } = context;
|
|
6
|
+
let siteDataModulePromise;
|
|
7
|
+
const createSiteDataModule = async (metaFileSet = new Set(), mdFileSet = new Set())=>{
|
|
8
|
+
const force = !pluginDriver.haveNavSidebarConfig;
|
|
9
|
+
const now = performance.now();
|
|
10
|
+
try {
|
|
11
|
+
await modifyConfigWithAutoNavSide(config, metaFileSet, mdFileSet, force);
|
|
12
|
+
} finally{
|
|
13
|
+
logger.debug(`modifyConfigWithAutoNavSide - size: ${mdFileSet.size} cost: ${performance.now() - now}ms`);
|
|
14
|
+
}
|
|
15
|
+
const { siteData } = await createSiteData(config);
|
|
16
|
+
return {
|
|
17
|
+
code: `export default ${JSON.stringify(siteData, null, 2)}`,
|
|
18
|
+
metaFileSet,
|
|
19
|
+
mdFileSet
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const getSiteDataModule = (metaFileSet, mdFileSet)=>{
|
|
23
|
+
if (!isProduction()) return createSiteDataModule(metaFileSet, mdFileSet);
|
|
24
|
+
siteDataModulePromise ??= createSiteDataModule(metaFileSet, mdFileSet).catch((error)=>{
|
|
25
|
+
siteDataModulePromise = void 0;
|
|
26
|
+
throw error;
|
|
27
|
+
});
|
|
28
|
+
return siteDataModulePromise;
|
|
29
|
+
};
|
|
30
|
+
const addSiteDataDependencies = (addDependency, metaFileSet, mdFileSet)=>{
|
|
31
|
+
for (const metaFile of metaFileSet)addDependency(metaFile);
|
|
32
|
+
for (const mdFile of mdFileSet)addDependency(mdFile);
|
|
33
|
+
};
|
|
6
34
|
return {
|
|
7
35
|
["virtual-site-data"]: async ({ addDependency })=>{
|
|
8
|
-
const force = !pluginDriver.haveNavSidebarConfig;
|
|
9
36
|
const metaFileSet = new Set();
|
|
10
37
|
const mdFileSet = new Set();
|
|
11
|
-
|
|
38
|
+
let siteDataModule;
|
|
12
39
|
try {
|
|
13
|
-
await
|
|
40
|
+
siteDataModule = await getSiteDataModule(metaFileSet, mdFileSet);
|
|
41
|
+
return siteDataModule.code;
|
|
14
42
|
} finally{
|
|
15
|
-
|
|
16
|
-
for (const mdFile of mdFileSet)addDependency(mdFile);
|
|
17
|
-
logger.debug(`modifyConfigWithAutoNavSide - size: ${mdFileSet.size} cost: ${performance.now() - now}ms`);
|
|
43
|
+
addSiteDataDependencies(addDependency, siteDataModule?.metaFileSet ?? metaFileSet, siteDataModule?.mdFileSet ?? mdFileSet);
|
|
18
44
|
}
|
|
19
|
-
const { siteData } = await createSiteData(config);
|
|
20
|
-
return `export default ${JSON.stringify(siteData, null, 2)}`;
|
|
21
45
|
}
|
|
22
46
|
};
|
|
23
47
|
};
|
package/dist/node/serve.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { external_node_path_resolve, relative, isAbsolute } from "../../7261.js";
|
|
2
|
+
const routePath2HtmlFileName = (routePath)=>{
|
|
3
|
+
let fileName = routePath;
|
|
4
|
+
fileName = fileName.endsWith('/') ? `${routePath}index.html` : `${routePath}.html`;
|
|
5
|
+
return fileName.replace(/^\/+/, '');
|
|
6
|
+
};
|
|
7
|
+
function resolveHtmlFilePath(distPath, routePath) {
|
|
8
|
+
const distPathAbsolute = external_node_path_resolve(distPath);
|
|
9
|
+
const fileAbsolutePath = external_node_path_resolve(distPathAbsolute, routePath2HtmlFileName(routePath));
|
|
10
|
+
const relativePath = relative(distPathAbsolute, fileAbsolutePath);
|
|
11
|
+
if (relativePath.startsWith('..') || isAbsolute(relativePath)) throw new Error(`SSG route path "${routePath}" resolves outside of the output directory.`);
|
|
12
|
+
return fileAbsolutePath;
|
|
13
|
+
}
|
|
14
|
+
export { resolveHtmlFilePath, routePath2HtmlFileName };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
2
|
-
import "../../
|
|
3
|
-
import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../
|
|
2
|
+
import "../../7986.js";
|
|
3
|
+
import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../7261.js";
|
|
4
4
|
import { hintSSGFailed } from "../logger/hint.js";
|
|
5
5
|
import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
|
|
6
6
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type { RouteMeta
|
|
2
|
-
interface
|
|
1
|
+
import type { RouteMeta } from '@rspress/shared';
|
|
2
|
+
interface WorkerTask {
|
|
3
3
|
routes: RouteMeta[];
|
|
4
|
-
htmlTemplate: string;
|
|
5
|
-
head: UserConfig['head'];
|
|
6
|
-
ssrBundlePath: string;
|
|
7
4
|
}
|
|
8
|
-
declare const exportWorkerGlueFn: ({ routes }:
|
|
5
|
+
declare const exportWorkerGlueFn: ({ routes, }: WorkerTask) => Promise<string[]>;
|
|
9
6
|
export default exportWorkerGlueFn;
|
|
@@ -1,15 +1,35 @@
|
|
|
1
|
-
import { workerData } from "../../
|
|
1
|
+
import { writeFile, mkdir, dirname, workerData } from "../../6646.js";
|
|
2
2
|
import { createError } from "../utils/error.js";
|
|
3
|
-
import {
|
|
3
|
+
import { resolveHtmlFilePath } from "./htmlFile.js";
|
|
4
|
+
import { pMap } from "../../7261.js";
|
|
4
5
|
import { renderPage } from "./renderPage.js";
|
|
5
6
|
const params = workerData?.[1]?.params;
|
|
6
7
|
if (!params) throw createError('SSG Worker Thread workerData params missing');
|
|
7
|
-
const { htmlTemplate: htmlTemplate, head: head, ssrBundlePath: ssrBundlePath } = params;
|
|
8
|
-
|
|
8
|
+
const { htmlTemplate: htmlTemplate, head: head, ssrBundlePath: ssrBundlePath, distPath: distPath } = params;
|
|
9
|
+
async function writeHtmlFile(routePath, html) {
|
|
10
|
+
if (!distPath) return;
|
|
11
|
+
const fileAbsolutePath = resolveHtmlFilePath(distPath, routePath);
|
|
12
|
+
await mkdir(dirname(fileAbsolutePath), {
|
|
13
|
+
recursive: true
|
|
14
|
+
});
|
|
15
|
+
await writeFile(fileAbsolutePath, html);
|
|
16
|
+
}
|
|
17
|
+
const exportWorkerGlueFn = async ({ routes })=>{
|
|
18
|
+
if (distPath) {
|
|
19
|
+
await pMap(routes, async (route)=>{
|
|
20
|
+
const html = await renderPage(route, htmlTemplate, head, ssrBundlePath);
|
|
21
|
+
await writeHtmlFile(route.routePath, html);
|
|
22
|
+
}, {
|
|
23
|
+
concurrency: 10
|
|
24
|
+
});
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
return pMap(routes, async (route)=>{
|
|
9
28
|
const html = await renderPage(route, htmlTemplate, head, ssrBundlePath);
|
|
10
29
|
return html;
|
|
11
30
|
}, {
|
|
12
31
|
concurrency: 10
|
|
13
32
|
});
|
|
33
|
+
};
|
|
14
34
|
const renderPageWorker = exportWorkerGlueFn;
|
|
15
35
|
export default renderPageWorker;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { UserConfig } from '@rspress/shared';
|
|
2
2
|
import type { RouteService } from '../route/RouteService.js';
|
|
3
|
-
export declare function renderPages(routeService: RouteService, config: UserConfig, ssrBundlePath: string, htmlTemplate: string, emitAsset: (assetName: string, content: string | Buffer) => void): Promise<void>;
|
|
3
|
+
export declare function renderPages(routeService: RouteService, config: UserConfig, ssrBundlePath: string, htmlTemplate: string, emitAsset: (assetName: string, content: string | Buffer) => void, workerOutputDistPath?: string): Promise<void>;
|
|
4
4
|
export declare function renderCSRPages(routeService: RouteService, config: UserConfig, htmlTemplate: string, emitAsset: (assetName: string, content: string | Buffer) => void): Promise<void>;
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
/*! LICENSE: renderPages.js.LICENSE.txt */
|
|
2
2
|
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
3
|
-
import "../../
|
|
4
|
-
import { chunk, logger } from "../../
|
|
3
|
+
import "../../7986.js";
|
|
4
|
+
import { chunk, logger } from "../../4942.js";
|
|
5
5
|
import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
|
|
6
|
-
import {
|
|
6
|
+
import { routePath2HtmlFileName } from "./htmlFile.js";
|
|
7
|
+
import { pMap } from "../../7261.js";
|
|
7
8
|
import { renderPage } from "./renderPage.js";
|
|
8
9
|
import { hintSSGFailed } from "../logger/hint.js";
|
|
9
10
|
import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
|
|
10
11
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
11
12
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
12
|
-
|
|
13
|
-
let fileName = routePath;
|
|
14
|
-
fileName = fileName.endsWith('/') ? `${routePath}index.html` : `${routePath}.html`;
|
|
15
|
-
return fileName.replace(/^\/+/, '');
|
|
16
|
-
};
|
|
17
|
-
async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, emitAsset) {
|
|
18
|
-
logger.info('Rendering pages...');
|
|
13
|
+
async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, emitAsset, workerOutputDistPath) {
|
|
19
14
|
const startTime = Date.now();
|
|
20
15
|
const ssg = config.ssg ?? true;
|
|
21
16
|
try {
|
|
@@ -48,6 +43,7 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
|
|
|
48
43
|
}
|
|
49
44
|
if ('object' == typeof ssg && ssg?.experimentalWorker) {
|
|
50
45
|
const numberOfThreads = getNumberOfThreads(routes.length);
|
|
46
|
+
logger.info(`Rendering pages with experimental SSG worker (${picocolors_default().yellow(numberOfThreads)} threads)...`);
|
|
51
47
|
const Tinypool = await import("../../0~tinypool.js").then((m)=>m.default);
|
|
52
48
|
const pool = new Tinypool({
|
|
53
49
|
filename: new URL('./renderPageWorker.js', import.meta.url).href,
|
|
@@ -63,7 +59,8 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
|
|
|
63
59
|
params: {
|
|
64
60
|
htmlTemplate,
|
|
65
61
|
head: config.head,
|
|
66
|
-
ssrBundlePath
|
|
62
|
+
ssrBundlePath,
|
|
63
|
+
distPath: workerOutputDistPath
|
|
67
64
|
}
|
|
68
65
|
}
|
|
69
66
|
});
|
|
@@ -71,6 +68,7 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
|
|
|
71
68
|
const htmlList = await pool.run({
|
|
72
69
|
routes
|
|
73
70
|
});
|
|
71
|
+
if (workerOutputDistPath) return;
|
|
74
72
|
for(let i = 0; i < routes.length; i++){
|
|
75
73
|
const route = routes[i];
|
|
76
74
|
const html = htmlList[i];
|
|
@@ -79,13 +77,16 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
|
|
|
79
77
|
}
|
|
80
78
|
}));
|
|
81
79
|
await pool.destroy();
|
|
82
|
-
} else
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
} else {
|
|
81
|
+
logger.info('Rendering pages...');
|
|
82
|
+
await pMap(routes, async (route)=>{
|
|
83
|
+
const html = await renderPage(route, htmlTemplate, config.head, ssrBundlePath);
|
|
84
|
+
const fileName = routePath2HtmlFileName(route.routePath);
|
|
85
|
+
emitAsset(fileName, html);
|
|
86
|
+
}, {
|
|
87
|
+
concurrency: SSGConcurrency()
|
|
88
|
+
});
|
|
89
|
+
}
|
|
89
90
|
const totalTime = Date.now() - startTime;
|
|
90
91
|
logger.success(`Pages rendered in ${picocolors_default().yellow(totalTime)} ms.`);
|
|
91
92
|
} catch (e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../
|
|
1
|
+
import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../4942.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 })=>({
|
|
@@ -73,7 +73,7 @@ const rsbuildPluginSSG = ({ routeService, config })=>({
|
|
|
73
73
|
}));
|
|
74
74
|
await indexHtmlEmittedInWeb;
|
|
75
75
|
if (hasError) return;
|
|
76
|
-
await renderPages(routeService, config, mainCjsAbsolutePath, htmlTemplate, emitAsset);
|
|
76
|
+
await renderPages(routeService, config, mainCjsAbsolutePath, htmlTemplate, emitAsset, distPath);
|
|
77
77
|
if (!isDebugMode()) await rm(ssgFolderPath, {
|
|
78
78
|
recursive: true
|
|
79
79
|
});
|
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 "../../4942.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 "../../../4942.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, logger, withBase } from "../../../
|
|
1
|
+
import { normalizeHref, logger, withBase } from "../../../4942.js";
|
|
2
2
|
import { extractInfoFromFrontmatterWithAbsolutePath } from "../../auto-nav-sidebar/utils.js";
|
|
3
3
|
function routePathToMdPath(routePath, base) {
|
|
4
4
|
let url = routePath;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
2
|
-
import "../../
|
|
3
|
-
import { createHead, pathToFileURL, logger } from "../../
|
|
2
|
+
import "../../7986.js";
|
|
3
|
+
import { createHead, pathToFileURL, logger } from "../../4942.js";
|
|
4
4
|
import { hintSSGFailed } from "../logger/hint.js";
|
|
5
5
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
6
6
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
2
|
-
import "../../
|
|
3
|
-
import { logger } from "../../
|
|
4
|
-
import { pMap } from "../../
|
|
2
|
+
import "../../7986.js";
|
|
3
|
+
import { logger } from "../../4942.js";
|
|
4
|
+
import { pMap } from "../../7261.js";
|
|
5
5
|
import { renderPage } from "./renderPage.js";
|
|
6
6
|
import { SSGConcurrency } from "../ssg/ssgEnv.js";
|
|
7
7
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { writeFile, mkdir, rm, join, isDebugMode } from "../../
|
|
1
|
+
import { writeFile, mkdir, rm, join, isDebugMode } from "../../4942.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 "../../4942.js";
|
|
2
2
|
function createHash(str) {
|
|
3
3
|
return external_node_crypto_createHash('sha256').update(str).digest('hex').slice(0, 8);
|
|
4
4
|
}
|
package/dist/node/utils/error.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
2
|
-
import "../../
|
|
2
|
+
import "../../7986.js";
|
|
3
3
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
4
4
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
5
5
|
function createError(message, maxStackLines = 5) {
|
|
@@ -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 "../../4942.js";
|
|
2
2
|
import { createError } from "./error.js";
|
|
3
3
|
import { importStatementRegex } from "../constants.js";
|
|
4
4
|
const RspackResolveFactory = core_rspack.experiments.resolver.ResolverFactory;
|
package/dist/node/utils/fs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
2
|
-
import "../../
|
|
3
|
-
import { node_path, core_rspack, logger } from "../../
|
|
2
|
+
import "../../7986.js";
|
|
3
|
+
import { node_path, core_rspack, logger } from "../../4942.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";
|
package/dist/runtime/App.js
CHANGED
|
@@ -29,7 +29,7 @@ function App() {
|
|
|
29
29
|
const GLOBAL_COMPONENTS_KEY = 'globalUIComponents';
|
|
30
30
|
const query = new URLSearchParams(search);
|
|
31
31
|
const hideGlobalUIComponents = false === frontmatter[GLOBAL_COMPONENTS_KEY] || "0" === query.get(GLOBAL_COMPONENTS_KEY);
|
|
32
|
-
if (
|
|
32
|
+
if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsx(Root, {
|
|
33
33
|
children: /*#__PURE__*/ jsx(Layout, {})
|
|
34
34
|
});
|
|
35
35
|
return /*#__PURE__*/ jsxs(Root, {
|
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
color: #fff;
|
|
7
7
|
z-index: 999;
|
|
8
8
|
background: var(--rp-banner-background);
|
|
9
|
+
box-sizing: border-box;
|
|
9
10
|
justify-content: center;
|
|
10
11
|
align-items: center;
|
|
11
12
|
height: 36px;
|
|
13
|
+
padding: 0 3.5rem;
|
|
12
14
|
display: flex;
|
|
13
15
|
position: sticky;
|
|
14
16
|
top: 0;
|
|
@@ -17,8 +19,17 @@
|
|
|
17
19
|
|
|
18
20
|
.rp-banner__link {
|
|
19
21
|
color: #fff;
|
|
22
|
+
text-align: center;
|
|
23
|
+
text-overflow: ellipsis;
|
|
24
|
+
white-space: nowrap;
|
|
25
|
+
flex: auto;
|
|
26
|
+
min-width: 0;
|
|
27
|
+
max-width: 100%;
|
|
20
28
|
font-weight: 700;
|
|
29
|
+
line-height: 36px;
|
|
21
30
|
text-decoration: none;
|
|
31
|
+
display: block;
|
|
32
|
+
overflow: hidden;
|
|
22
33
|
}
|
|
23
34
|
|
|
24
35
|
.rp-banner__link:hover {
|
|
@@ -5,7 +5,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
|
|
5
5
|
import "./index.css";
|
|
6
6
|
const DEFAULT_FOLD_HEIGHT = 300;
|
|
7
7
|
function CodeBlock({ containerElementClassName, title, lang = 'txt', wrapCode: wrapCodeProp = false, lineNumbers: lineNumbersProp = false, fold = false, height, codeButtonGroupProps, children }) {
|
|
8
|
-
if (
|
|
8
|
+
if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsx(Fragment, {
|
|
9
9
|
children: children
|
|
10
10
|
});
|
|
11
11
|
const { wrapCode: wrapCodeState, toggleWrapCode, copyElementRef } = useCodeButtonGroup(wrapCodeProp);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useSite } from "@rspress/core/runtime";
|
|
2
|
+
import { useI18n, useSite } from "@rspress/core/runtime";
|
|
3
3
|
import { IconWrap, IconWrapped, SvgWrapper } from "@rspress/core/theme";
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import { useRef, useState } from "react";
|
|
@@ -20,6 +20,7 @@ const useCodeButtonGroup = (initialWrapCode)=>{
|
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
function CodeButtonGroup({ wrapCode, toggleWrapCode, copyElementRef, showWrapCodeButton = true, showCopyButton = true }) {
|
|
23
|
+
const t = useI18n();
|
|
23
24
|
return /*#__PURE__*/ jsx(Fragment, {
|
|
24
25
|
children: /*#__PURE__*/ jsxs("div", {
|
|
25
26
|
className: "rp-code-button-group",
|
|
@@ -27,7 +28,8 @@ function CodeButtonGroup({ wrapCode, toggleWrapCode, copyElementRef, showWrapCod
|
|
|
27
28
|
showWrapCodeButton && /*#__PURE__*/ jsxs("button", {
|
|
28
29
|
className: clsx('rp-code-button-group__button', 'rp-code-wrap-button', wrapCode && 'rp-code-wrap-button--wrapped'),
|
|
29
30
|
onClick: ()=>toggleWrapCode(),
|
|
30
|
-
title:
|
|
31
|
+
title: t('codeButtonGroupWrapButtonText'),
|
|
32
|
+
"aria-label": t('codeButtonGroupWrapButtonText'),
|
|
31
33
|
children: [
|
|
32
34
|
/*#__PURE__*/ jsx(SvgWrapper, {
|
|
33
35
|
icon: IconWrapped,
|
|
@@ -14,7 +14,7 @@ const getHeadingMap = ()=>{
|
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
function FallbackHeading({ level, title }) {
|
|
17
|
-
if (
|
|
17
|
+
if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsx(Fragment, {
|
|
18
18
|
children: `${'#'.repeat(level)} ${title}\n\n`
|
|
19
19
|
});
|
|
20
20
|
const titleSlug = title && slug(title.trim());
|
|
@@ -42,6 +42,9 @@ const Link = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
42
42
|
onMouseEnter?.(event);
|
|
43
43
|
preloadLink(removeBaseHref);
|
|
44
44
|
},
|
|
45
|
+
onTouchStart: ()=>{
|
|
46
|
+
preloadLink(removeBaseHref);
|
|
47
|
+
},
|
|
45
48
|
onClick: (e)=>{
|
|
46
49
|
onClick?.(e);
|
|
47
50
|
if (0 !== e.button || e.currentTarget.target && '_self' !== e.currentTarget.target || e.metaKey || e.shiftKey || e.altKey || e.ctrlKey) return;
|
|
@@ -59,6 +62,9 @@ const Link = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
59
62
|
onMouseEnter?.(event);
|
|
60
63
|
preloadLink(removeBaseHref);
|
|
61
64
|
},
|
|
65
|
+
onTouchStart: ()=>{
|
|
66
|
+
preloadLink(removeBaseHref);
|
|
67
|
+
},
|
|
62
68
|
onClick: (e)=>{
|
|
63
69
|
onClick?.(e);
|
|
64
70
|
if (0 !== e.button || e.currentTarget.target && '_self' !== e.currentTarget.target || e.metaKey || e.shiftKey || e.altKey || e.ctrlKey) return;
|
|
@@ -21,7 +21,7 @@ function getHref(href) {
|
|
|
21
21
|
withBaseHref: href,
|
|
22
22
|
removeBaseHref: href
|
|
23
23
|
};
|
|
24
|
-
withBaseHref = 'relative' !== linkType ||
|
|
24
|
+
withBaseHref = 'relative' !== linkType || import.meta.env.SSR ? withBase(cleanUrlByConfig(href)) : new URL(href, window.location.href).pathname;
|
|
25
25
|
const removeBaseHref = removeBase(withBaseHref);
|
|
26
26
|
return {
|
|
27
27
|
withBaseHref,
|
|
@@ -39,7 +39,7 @@ function useLinkNavigate({ startTransition } = {
|
|
|
39
39
|
if ('external' === linkType || 'hashOnly' === linkType) return void window.location.assign(href);
|
|
40
40
|
const preloadChunkThenNavigate = async ()=>{
|
|
41
41
|
const inCurrPage = isActive(removeBaseHref, currPagePathname);
|
|
42
|
-
if (!
|
|
42
|
+
if (!import.meta.env.SSR && !inCurrPage) {
|
|
43
43
|
const matchedRoute = pathnameToRouteService(removeBaseHref);
|
|
44
44
|
if (!matchedRoute) return void window.location.assign(withBaseHref);
|
|
45
45
|
{
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useI18n, useSite } from "@rspress/core/runtime";
|
|
3
|
-
import { EditLink, LlmsCopyRow, LlmsOpenRow, ReadPercent, Toc
|
|
3
|
+
import { EditLink, LlmsCopyRow, LlmsOpenRow, ReadPercent, Toc } from "@rspress/core/theme";
|
|
4
4
|
import "./index.css";
|
|
5
5
|
import { ScrollToTop } from "./ScrollToTop.js";
|
|
6
6
|
function Outline() {
|
|
7
7
|
const t = useI18n();
|
|
8
|
-
const headers = useDynamicToc();
|
|
9
8
|
const { site: { themeConfig: { enableScrollToTop = true, llmsUI } } } = useSite();
|
|
10
|
-
if (0 === headers.length) return /*#__PURE__*/ jsx(Fragment, {});
|
|
11
9
|
const placement = 'object' == typeof llmsUI ? llmsUI?.placement ?? 'title' : 'title';
|
|
12
10
|
return /*#__PURE__*/ jsxs("div", {
|
|
13
11
|
className: "rp-outline",
|
|
@@ -115,7 +115,7 @@ function Overview(props) {
|
|
|
115
115
|
query
|
|
116
116
|
]);
|
|
117
117
|
const overviewTitle = title || 'Overview';
|
|
118
|
-
if (
|
|
118
|
+
if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsxs(Fragment, {
|
|
119
119
|
children: [
|
|
120
120
|
/*#__PURE__*/ jsx(FallbackHeading, {
|
|
121
121
|
level: 1,
|
|
@@ -34,7 +34,7 @@ function OverviewGroupMarkdown({ group }) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
const OverviewGroup = ({ group })=>{
|
|
37
|
-
if (
|
|
37
|
+
if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsx(OverviewGroupMarkdown, {
|
|
38
38
|
group: group
|
|
39
39
|
});
|
|
40
40
|
const { itemsWithContent, itemsWithoutContent } = useMemo(()=>{
|
|
@@ -111,7 +111,7 @@ function PackageManagerTabs({ command, exec, dlx, additionalTabs = [] }) {
|
|
|
111
111
|
commandInfo.bun = normalizeCommand(commandInfo.bun);
|
|
112
112
|
commandInfo.deno = normalizeCommand(commandInfo.deno);
|
|
113
113
|
} else commandInfo = command;
|
|
114
|
-
if (
|
|
114
|
+
if (import.meta.env.SSG_MD) return Object.values(commandInfo).reduce((previous, current)=>{
|
|
115
115
|
const [packageManager, command] = splitTo2Parts(current);
|
|
116
116
|
return previous + `\n\`\`\`sh [${packageManager}]\n` + `${packageManager}${command}\n` + "```\n";
|
|
117
117
|
}, '');
|
|
@@ -128,13 +128,18 @@ class PageSearcher {
|
|
|
128
128
|
const statementStartIndex = byteToCharIndex(content, highlightStartIndex);
|
|
129
129
|
const statementEndIndex = byteToCharIndex(content, highlightStartIndex + THRESHOLD_CONTENT_LENGTH);
|
|
130
130
|
const statement = content.slice(statementStartIndex, statementEndIndex);
|
|
131
|
-
const highlightInfoList =
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
const highlightInfoList = [];
|
|
132
|
+
const limitIndex = highlightStartIndex + THRESHOLD_CONTENT_LENGTH;
|
|
133
|
+
for (const match of item._matchesPosition?.content || []){
|
|
134
|
+
const { start, length } = match;
|
|
135
|
+
if (start >= highlightStartIndex && start + length <= limitIndex) {
|
|
136
|
+
const startCharIndex = byteToCharIndex(content, start) - statementStartIndex + 3;
|
|
137
|
+
highlightInfoList.push({
|
|
138
|
+
start: startCharIndex,
|
|
139
|
+
length
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
138
143
|
matchedResult.push({
|
|
139
144
|
type: 'content',
|
|
140
145
|
title: item.title,
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
1
2
|
import './index.scss';
|
|
2
3
|
export declare const SidebarMenu: import("react").ForwardRefExoticComponent<{
|
|
3
4
|
isSidebarOpen: boolean;
|
|
4
5
|
onIsSidebarOpenChange: (isOpen: boolean) => void;
|
|
5
6
|
isOutlineOpen: boolean;
|
|
6
7
|
onIsOutlineOpenChange: (isOpen: boolean) => void;
|
|
8
|
+
beforeOutline?: ReactNode;
|
|
9
|
+
afterOutline?: ReactNode;
|
|
7
10
|
} & import("react").RefAttributes<unknown>>;
|