@rspress/core 2.0.23 → 2.1.0-beta.1
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/b~0.js +1 -3
- package/dist/cli/index.js +1 -1
- package/dist/{common-Qw-RoVFD.js → common-Bo3KCGim.js} +4 -1
- package/dist/config/loadConfigFile.js +1 -1
- package/dist/eject-theme/components/Link/getHref.ts +1 -0
- package/dist/eject-theme/components/Link/index.tsx +0 -3
- package/dist/eject-theme/components/Link/useLinkNavigate.ts +29 -54
- package/dist/eject-theme/components/Search/logic/providers/LocalProvider.ts +4 -1
- package/dist/eject-theme/components/Search/useSearchPanel.ts +103 -36
- package/dist/eject-theme/components/SocialLinks/GithubStars.test.tsx +4 -1
- package/dist/eject-theme/components/SocialLinks/GithubStars.tsx +1 -1
- package/dist/entry/worker.js +1 -1
- package/dist/{a~0.js → h~0.js} +18 -15
- package/dist/index.d.ts +1 -1
- package/dist/node/PluginDriver.js +8 -2
- 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 +8 -4
- package/dist/node/llms.d.ts +1 -1
- package/dist/node/llms.js +2 -2
- package/dist/node/logger/hint.d.ts +1 -0
- package/dist/node/logger/hint.js +8 -2
- package/dist/node/route/RoutePage.js +1 -1
- package/dist/node/route/RouteService.js +1 -1
- 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 +28 -0
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +28 -0
- package/dist/node/runtimeModule/i18n.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 +2 -2
- 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.d.ts +2 -0
- package/dist/node/sitemap.js +103 -0
- package/dist/node/ssg/alternateLinks.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/renderPage.js +5 -4
- 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 +5 -2
- package/dist/runtime/App.js +12 -25
- package/dist/runtime/ClientApp.d.ts +3 -2
- package/dist/runtime/ClientApp.js +27 -21
- package/dist/runtime/ErrorRoute.d.ts +1 -0
- package/dist/runtime/ErrorRoute.js +30 -0
- package/dist/runtime/PageRoute.d.ts +2 -0
- package/dist/runtime/PageRoute.js +58 -0
- package/dist/runtime/createServerRouter.d.ts +4 -0
- package/dist/runtime/createServerRouter.js +17 -0
- package/dist/runtime/csrClientEntry.js +5 -2
- package/dist/runtime/hooks/useWebMcp.d.ts +36 -0
- package/dist/runtime/hooks/useWebMcp.js +80 -0
- package/dist/runtime/index.d.ts +3 -1
- package/dist/runtime/index.js +3 -1
- package/dist/runtime/initPageData.d.ts +0 -3
- package/dist/runtime/initPageData.js +9 -45
- package/dist/runtime/pageDataLoader.d.ts +11 -0
- package/dist/runtime/pageDataLoader.js +7 -0
- package/dist/runtime/ssrClientEntry.js +14 -6
- package/dist/runtime/ssrMdServerEntry.js +10 -21
- package/dist/runtime/ssrServerEntry.js +10 -21
- package/dist/static/assets/package.json +58 -0
- package/dist/theme/components/Link/index.js +0 -4
- package/dist/theme/components/Link/useLinkNavigate.d.ts +2 -2
- package/dist/theme/components/Link/useLinkNavigate.js +13 -35
- package/dist/theme/components/Search/logic/providers/LocalProvider.js +4 -1
- package/dist/theme/components/Search/useSearchPanel.js +74 -26
- package/dist/theme/components/SocialLinks/GithubStars.js +1 -1
- package/dist/theme/hooks/useWebMcpNavigation.d.ts +6 -0
- package/dist/theme/hooks/useWebMcpNavigation.js +123 -0
- package/dist/theme/hooks/useWebMcpPageList.d.ts +6 -0
- package/dist/theme/hooks/useWebMcpPageList.js +25 -0
- package/dist/theme/hooks/useWebMcpPageReading.d.ts +7 -0
- package/dist/theme/hooks/useWebMcpPageReading.js +23 -0
- package/dist/theme/hooks/useWebMcpSiteInfo.d.ts +6 -0
- package/dist/theme/hooks/useWebMcpSiteInfo.js +22 -0
- package/dist/theme/index.d.ts +5 -0
- package/dist/theme/index.js +5 -0
- package/dist/theme/layout/ErrorLayout/index.css +52 -0
- package/dist/theme/layout/ErrorLayout/index.d.ts +8 -0
- package/dist/theme/layout/ErrorLayout/index.js +76 -0
- package/dist/theme/webMcp/tools.d.ts +56 -0
- package/dist/theme/webMcp/tools.js +122 -0
- package/dist/theme/webMcp/types.d.ts +35 -0
- package/dist/theme/webMcp/types.js +0 -0
- package/dist/tinypool~0.js +19 -49
- package/dist/tu~0.js +3 -0
- package/package.json +12 -12
package/dist/node/logger/hint.js
CHANGED
|
@@ -63,7 +63,13 @@ let isSSGFailedLogged = false;
|
|
|
63
63
|
function hintSSGFailed() {
|
|
64
64
|
if (isSSGFailedLogged) return;
|
|
65
65
|
isSSGFailedLogged = true;
|
|
66
|
-
logger.info("[Rspress v2]
|
|
66
|
+
logger.info("[Rspress v2] SSG requires the source code to support SSR. If the code is not compatible with SSR, the build process will fail. You can try:\n 1. Fix code to make it SSR-compatible.\n 2. Set `ssg: false` to disable SSG if the code is difficult to fix.");
|
|
67
|
+
}
|
|
68
|
+
let isSSGMDFailedLogged = false;
|
|
69
|
+
function hintSSGMDFailed() {
|
|
70
|
+
if (isSSGMDFailedLogged) return;
|
|
71
|
+
isSSGMDFailedLogged = true;
|
|
72
|
+
logger.info("[Rspress v2] SSG-MD requires the source code to support SSR. If the code is not compatible with SSR, Markdown rendering will fail. You can try:\n 1. Fix code to make it SSR-compatible.\n 2. Set `llms: false` and use @rspress/plugin-llms to generate Markdown, llms.txt, and llms-full.txt without SSR: https://rspress.rs/plugin/official-plugins/llms");
|
|
67
73
|
}
|
|
68
74
|
function hintSSGFalse() {
|
|
69
75
|
logger.info('`ssg: false` detected, SSG will be disabled.');
|
|
@@ -92,4 +98,4 @@ function hintRelativeMarkdownLink() {
|
|
|
92
98
|
isLogged = true;
|
|
93
99
|
logger.info('[Rspress v2] Markdown links without "./" prefix are now relative links, e.g: [](guide/getting-started) is equal to [](./guide/getting-started). You can rewrite it to [](/guide/getting-started) to always use absolute links, or use [](./getting-started.md)');
|
|
94
100
|
}
|
|
95
|
-
export { hintBuilderPluginsBreakingChange, hintNavJsonChangeThenPanic, hintReactVersion, hintRelativeMarkdownLink, hintSSGFailed, hintSSGFalse, hintThemeBreakingChange };
|
|
101
|
+
export { hintBuilderPluginsBreakingChange, hintNavJsonChangeThenPanic, hintReactVersion, hintRelativeMarkdownLink, hintSSGFailed, hintSSGFalse, hintSSGMDFailed, hintThemeBreakingChange };
|
|
@@ -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 "../../h~0.js";
|
|
2
2
|
import { RoutePage, absolutePathToRoutePath, absolutePathToRelativePath } from "./RoutePage.js";
|
|
3
3
|
import { createError } from "../utils/error.js";
|
|
4
4
|
import { getRouteChunkName } from "./routeChunkAssets.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unified, node_path, promises, loadFrontMatter, extractTextAndId, remark_gfm, remark_parse, MDX_OR_MD_REGEXP } from "../../
|
|
1
|
+
import { unified, node_path, promises, loadFrontMatter, extractTextAndId, remark_gfm, remark_parse, MDX_OR_MD_REGEXP } from "../../h~0.js";
|
|
2
2
|
import { applyReplaceRules } from "../utils/applyReplaceRules.js";
|
|
3
3
|
import { flattenMdxContent } from "../utils/flattenMdxContent.js";
|
|
4
4
|
import { importStatementRegex } from "../constants.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../
|
|
1
|
+
import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../h~0.js";
|
|
2
2
|
const getRoutePathParts = (relativePath, lang, version, langs, versions)=>{
|
|
3
3
|
const [versionPart, langPart, purePath] = splitRoutePathParts(relativePath, lang, version, langs, versions);
|
|
4
4
|
return [
|
|
@@ -181,6 +181,34 @@ export declare const DEFAULT_I18N_TEXT: {
|
|
|
181
181
|
readonly ko: '홈으로 이동';
|
|
182
182
|
readonly ru: 'Вернуться на главную';
|
|
183
183
|
};
|
|
184
|
+
readonly errorTitleText: {
|
|
185
|
+
readonly en: 'Something went wrong';
|
|
186
|
+
readonly zh: '页面出了点问题';
|
|
187
|
+
readonly ja: 'エラーが発生しました';
|
|
188
|
+
readonly ko: '문제가 발생했습니다';
|
|
189
|
+
readonly ru: 'Что-то пошло не так';
|
|
190
|
+
};
|
|
191
|
+
readonly errorDescriptionText: {
|
|
192
|
+
readonly en: 'This page could not be loaded. Try reloading it or return to the home page.';
|
|
193
|
+
readonly zh: '页面未能正常加载,请尝试重新加载,或返回首页。';
|
|
194
|
+
readonly ja: 'ページを読み込めませんでした。再読み込みするか、ホームに戻ってください。';
|
|
195
|
+
readonly ko: '페이지를 불러올 수 없습니다. 새로고침하거나 홈으로 돌아가세요.';
|
|
196
|
+
readonly ru: 'Не удалось загрузить страницу. Попробуйте обновить её или вернуться на главную.';
|
|
197
|
+
};
|
|
198
|
+
readonly reloadPageText: {
|
|
199
|
+
readonly en: 'Reload page';
|
|
200
|
+
readonly zh: '重新加载';
|
|
201
|
+
readonly ja: '再読み込み';
|
|
202
|
+
readonly ko: '새로고침';
|
|
203
|
+
readonly ru: 'Обновить страницу';
|
|
204
|
+
};
|
|
205
|
+
readonly errorDetailsText: {
|
|
206
|
+
readonly en: 'Error details';
|
|
207
|
+
readonly zh: '错误详情';
|
|
208
|
+
readonly ja: 'エラーの詳細';
|
|
209
|
+
readonly ko: '오류 세부 정보';
|
|
210
|
+
readonly ru: 'Подробности ошибки';
|
|
211
|
+
};
|
|
184
212
|
readonly promptCopyText: {
|
|
185
213
|
readonly en: 'Copy Prompt';
|
|
186
214
|
readonly zh: '复制 Prompt';
|
|
@@ -181,6 +181,34 @@ const DEFAULT_I18N_TEXT = {
|
|
|
181
181
|
ko: '홈으로 이동',
|
|
182
182
|
ru: 'Вернуться на главную'
|
|
183
183
|
},
|
|
184
|
+
errorTitleText: {
|
|
185
|
+
en: 'Something went wrong',
|
|
186
|
+
zh: '页面出了点问题',
|
|
187
|
+
ja: 'エラーが発生しました',
|
|
188
|
+
ko: '문제가 발생했습니다',
|
|
189
|
+
ru: 'Что-то пошло не так'
|
|
190
|
+
},
|
|
191
|
+
errorDescriptionText: {
|
|
192
|
+
en: 'This page could not be loaded. Try reloading it or return to the home page.',
|
|
193
|
+
zh: '页面未能正常加载,请尝试重新加载,或返回首页。',
|
|
194
|
+
ja: 'ページを読み込めませんでした。再読み込みするか、ホームに戻ってください。',
|
|
195
|
+
ko: '페이지를 불러올 수 없습니다. 새로고침하거나 홈으로 돌아가세요.',
|
|
196
|
+
ru: 'Не удалось загрузить страницу. Попробуйте обновить её или вернуться на главную.'
|
|
197
|
+
},
|
|
198
|
+
reloadPageText: {
|
|
199
|
+
en: 'Reload page',
|
|
200
|
+
zh: '重新加载',
|
|
201
|
+
ja: '再読み込み',
|
|
202
|
+
ko: '새로고침',
|
|
203
|
+
ru: 'Обновить страницу'
|
|
204
|
+
},
|
|
205
|
+
errorDetailsText: {
|
|
206
|
+
en: 'Error details',
|
|
207
|
+
zh: '错误详情',
|
|
208
|
+
ja: 'エラーの詳細',
|
|
209
|
+
ko: '오류 세부 정보',
|
|
210
|
+
ru: 'Подробности ошибки'
|
|
211
|
+
},
|
|
184
212
|
promptCopyText: {
|
|
185
213
|
en: 'Copy Prompt',
|
|
186
214
|
zh: '复制 Prompt',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../t~0.js";
|
|
3
|
-
import { createRequire, join, logger } from "../../
|
|
3
|
+
import { createRequire, join, logger } from "../../h~0.js";
|
|
4
4
|
import { DEFAULT_I18N_TEXT } from "./DEFAULT_I18N_TEXT.js";
|
|
5
5
|
import { createError } from "../utils/error.js";
|
|
6
6
|
import { pathExists } from "../utils/fs.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SEARCH_INDEX_NAME, groupBy } from "../../../
|
|
1
|
+
import { SEARCH_INDEX_NAME, groupBy } from "../../../h~0.js";
|
|
2
2
|
import { extractPageData } from "../../route/extractPageData.js";
|
|
3
3
|
import { createHash } from "../../utils/createHash.js";
|
|
4
4
|
function deletePrivateField(obj) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger, pluginVirtualModule } from "../../../
|
|
1
|
+
import { logger, pluginVirtualModule } from "../../../h~0.js";
|
|
2
2
|
import { createPageData } from "./createPageData.js";
|
|
3
3
|
const rsbuildPluginDocVM = async ({ config, userDocRoot, routeService, pluginDriver })=>{
|
|
4
4
|
const ref = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { node_path } from "../../
|
|
1
|
+
import { node_path } from "../../h~0.js";
|
|
2
2
|
const searchHookVMPlugin = (context)=>({
|
|
3
3
|
["virtual-search-hooks"]: ()=>{
|
|
4
4
|
const { config } = context;
|
|
5
|
-
let content = 'export
|
|
5
|
+
let content = 'export {};';
|
|
6
6
|
const searchHooks = 'object' == typeof config.search && config.search?.searchHooks;
|
|
7
7
|
if (searchHooks) content = `export * from ${JSON.stringify(node_path.posix.normalize(searchHooks))}`;
|
|
8
8
|
return content;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getIconUrlPath } from "../../../
|
|
1
|
+
import { getIconUrlPath } from "../../../h~0.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 "../../../h~0.js";
|
|
2
2
|
import { getI18nData } from "../i18n.js";
|
|
3
3
|
import { applyReplaceRules } from "../../utils/applyReplaceRules.js";
|
|
4
4
|
async function normalizeThemeConfig(docConfig) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isProduction, logger } from "../../../
|
|
1
|
+
import { isProduction, logger } from "../../../h~0.js";
|
|
2
2
|
import { modifyConfigWithAutoNavSide } from "../../auto-nav-sidebar/index.js";
|
|
3
3
|
import { createSiteData } from "./createSiteData.js";
|
|
4
4
|
const siteDataVMPlugin = (context)=>{
|
package/dist/node/serve.js
CHANGED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { withSiteOrigin, stat, logger, withBase } from "../tu~0.js";
|
|
2
|
+
import { glob } from "../h~0.js";
|
|
3
|
+
import { routePath2HtmlFileName } from "./ssg/htmlFile.js";
|
|
4
|
+
function ensureTrailingSlash(url) {
|
|
5
|
+
return url.endsWith('/') ? url : `${url}/`;
|
|
6
|
+
}
|
|
7
|
+
function normalizeSiteUrl(siteUrl) {
|
|
8
|
+
try {
|
|
9
|
+
const url = new URL(siteUrl);
|
|
10
|
+
if (![
|
|
11
|
+
'http:',
|
|
12
|
+
'https:'
|
|
13
|
+
].includes(url.protocol) || url.href.includes('?') || url.href.includes('#')) throw new Error('Expected an HTTP(S) URL without a query or fragment.');
|
|
14
|
+
url.pathname = ensureTrailingSlash(url.pathname);
|
|
15
|
+
return url.href;
|
|
16
|
+
} catch {
|
|
17
|
+
throw new Error('[sitemap] `sitemap.siteUrl` must be an absolute HTTP(S) URL without a query or fragment, such as `https://example.com/base/`.');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function getSiteUrl(siteUrl, config) {
|
|
21
|
+
if (siteUrl) return normalizeSiteUrl(siteUrl);
|
|
22
|
+
const base = withBase('/', config.base ?? '/');
|
|
23
|
+
try {
|
|
24
|
+
return config.siteOrigin ? withSiteOrigin(base, config.siteOrigin) : encodeURI(base);
|
|
25
|
+
} catch {
|
|
26
|
+
throw new Error('[sitemap] `siteOrigin` in rspress.config.ts must be a valid absolute URL origin with protocol, such as `https://example.com`.');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const generateNode = (sitemap)=>{
|
|
30
|
+
let result = '<url>';
|
|
31
|
+
for (const [tag, value] of Object.entries(sitemap)){
|
|
32
|
+
const escaped = String(value).replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"').replaceAll("'", ''');
|
|
33
|
+
result += `<${tag}>${escaped}</${tag}>`;
|
|
34
|
+
}
|
|
35
|
+
result += '</url>';
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
const generateXml = (sitemaps)=>{
|
|
39
|
+
logger.info(`Generate sitemap.xml for ${sitemaps.length} pages.`);
|
|
40
|
+
return `<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">${sitemaps.reduce((node, sitemap)=>node + generateNode(sitemap), '')}</urlset>`;
|
|
41
|
+
};
|
|
42
|
+
function pluginSitemap() {
|
|
43
|
+
let options;
|
|
44
|
+
const sitemaps = [];
|
|
45
|
+
const set = new Set();
|
|
46
|
+
let resolvedSiteUrl = '';
|
|
47
|
+
let cleanUrls = false;
|
|
48
|
+
return {
|
|
49
|
+
name: 'rspress:sitemap',
|
|
50
|
+
builderConfig: {
|
|
51
|
+
plugins: [
|
|
52
|
+
{
|
|
53
|
+
name: 'rspress:sitemap-output',
|
|
54
|
+
setup (api) {
|
|
55
|
+
api.processAssets({
|
|
56
|
+
stage: 'additional',
|
|
57
|
+
environments: [
|
|
58
|
+
'web'
|
|
59
|
+
]
|
|
60
|
+
}, async ({ compilation, sources })=>{
|
|
61
|
+
if (!options || compilation.errors.length) return;
|
|
62
|
+
for (const publicDir of api.getNormalizedConfig().server.publicDir){
|
|
63
|
+
if (false === publicDir.copyOnBuild) continue;
|
|
64
|
+
const files = await glob('sitemap.xml', {
|
|
65
|
+
cwd: publicDir.name,
|
|
66
|
+
ignore: publicDir.ignore
|
|
67
|
+
});
|
|
68
|
+
if (files.length) return void logger.warn('[sitemap] Preserving public sitemap.xml.');
|
|
69
|
+
}
|
|
70
|
+
compilation.emitAsset('sitemap.xml', new sources.RawSource(generateXml(sitemaps)));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
beforeBuild (config, isProd) {
|
|
77
|
+
sitemaps.length = 0;
|
|
78
|
+
set.clear();
|
|
79
|
+
options = isProd && config.sitemap ? 'object' == typeof config.sitemap ? config.sitemap : {} : void 0;
|
|
80
|
+
if (options) {
|
|
81
|
+
resolvedSiteUrl = getSiteUrl(options.siteUrl, config);
|
|
82
|
+
cleanUrls = config.route?.cleanUrls ?? false;
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
async extendPageData (pageData, isProd) {
|
|
86
|
+
if (isProd && options) {
|
|
87
|
+
if (!set.has(pageData.routePath)) {
|
|
88
|
+
set.add(pageData.routePath);
|
|
89
|
+
const pathname = cleanUrls ? pageData.routePath : `/${routePath2HtmlFileName(pageData.routePath)}`;
|
|
90
|
+
const encodedPath = pathname.split('/').map(encodeURIComponent).join('/');
|
|
91
|
+
sitemaps.push({
|
|
92
|
+
loc: `${resolvedSiteUrl.replace(/\/$/, '')}${encodedPath}`,
|
|
93
|
+
lastmod: (await stat(pageData._filepath)).mtime.toISOString(),
|
|
94
|
+
priority: '/' === pageData.routePath ? '1.0' : options.defaultPriority ?? '0.5',
|
|
95
|
+
changefreq: options.defaultChangeFreq ?? 'monthly',
|
|
96
|
+
...options.customMaps?.[pageData.routePath] ?? {}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export { pluginSitemap };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeHref, removeTrailingSlash, addLeadingSlash, normalizePosixPath, withSiteOrigin } from "../../
|
|
1
|
+
import { normalizeHref, removeTrailingSlash, addLeadingSlash, normalizePosixPath, withSiteOrigin } from "../../h~0.js";
|
|
2
2
|
function createAlternateLinksByRoute(routes, config) {
|
|
3
3
|
const routeGroups = new Map();
|
|
4
4
|
for (const route of routes){
|
|
@@ -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 "../../h~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 "../../h~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 "../../h~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 "../../../h~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 "../../../h~0.js";
|
|
2
2
|
import { extractInfoFromFrontmatterWithAbsolutePath } from "../../auto-nav-sidebar/utils.js";
|
|
3
3
|
function routePathToMdPath(routePath, base, siteOrigin) {
|
|
4
4
|
let url = routePath;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../t~0.js";
|
|
3
|
-
import { createHead, pathToFileURL, logger } from "../../
|
|
4
|
-
import {
|
|
3
|
+
import { createHead, pathToFileURL, logger } from "../../h~0.js";
|
|
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);
|
|
7
7
|
async function renderPage(route, ssrBundlePath) {
|
|
@@ -12,9 +12,9 @@ async function renderPage(route, ssrBundlePath) {
|
|
|
12
12
|
render = ssrExports.render;
|
|
13
13
|
} catch (e) {
|
|
14
14
|
if (e instanceof Error) {
|
|
15
|
-
logger.error(`Failed to load SSG bundle: ${picocolors_default().yellow(ssrBundlePath)}: ${e.message}`);
|
|
15
|
+
logger.error(`Failed to load SSG-MD bundle: ${picocolors_default().yellow(ssrBundlePath)}: ${e.message}`);
|
|
16
16
|
logger.debug(e);
|
|
17
|
-
|
|
17
|
+
hintSSGMDFailed();
|
|
18
18
|
}
|
|
19
19
|
throw e;
|
|
20
20
|
}
|
|
@@ -27,6 +27,7 @@ async function renderPage(route, ssrBundlePath) {
|
|
|
27
27
|
if (e instanceof Error) {
|
|
28
28
|
logger.error(`Page "${picocolors_default().yellow(routePath)}" SSG-MD rendering failed.
|
|
29
29
|
${absolutePath ? picocolors_default().gray(` File: ${absolutePath}\n`) : ''} ${picocolors_default().gray(e.toString())}`);
|
|
30
|
+
hintSSGMDFailed();
|
|
30
31
|
throw e;
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -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 "../../h~0.js";
|
|
4
4
|
import { pMap } from "../../b~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 "../../h~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 "../../h~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 "../../h~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 "../../h~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";
|
|
@@ -36,8 +36,11 @@ async function resolveReactRouterDomAlias() {
|
|
|
36
36
|
const resolved = await resolver.async(basedir, 'react-router-dom/package.json');
|
|
37
37
|
if (resolved.error) throw Error(resolved.error);
|
|
38
38
|
if (!resolved.path) throw Error("'react-router-dom' resolved to empty path");
|
|
39
|
+
const packageRoot = node_path.dirname(resolved.path);
|
|
40
|
+
const { version } = await readJson(resolved.path);
|
|
39
41
|
return {
|
|
40
|
-
'react-router-dom':
|
|
42
|
+
'react-router-dom': packageRoot,
|
|
43
|
+
'virtual-react-router-server': version.startsWith('6.') ? node_path.join(packageRoot, 'server.mjs') : packageRoot
|
|
41
44
|
};
|
|
42
45
|
} catch (e) {
|
|
43
46
|
logger.warn('react-router-dom not found: \n', e);
|
package/dist/runtime/App.js
CHANGED
|
@@ -1,32 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { PageContext, useLocation } from "@rspress/core/runtime";
|
|
3
|
-
import { Layout, Root } from "@rspress/core/theme";
|
|
4
|
-
import {
|
|
5
|
-
import react, { useContext, useLayoutEffect } from "react";
|
|
3
|
+
import { Layout, LlmsHint, Root, useWebMcpNavigation, useWebMcpPageList, useWebMcpPageReading, useWebMcpSiteInfo } from "@rspress/core/theme";
|
|
4
|
+
import react, { useContext } from "react";
|
|
6
5
|
import { useGlobalComponents } from "./hooks/useGlobalComponents.js";
|
|
7
|
-
import { consumeCachedPageData, initPageData, setCurrentPageData } from "./initPageData.js";
|
|
8
6
|
function App() {
|
|
9
7
|
const globalComponents = useGlobalComponents();
|
|
10
|
-
const {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
setPageData?.(pageData);
|
|
20
|
-
} catch (e) {
|
|
21
|
-
console.log(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
refetchData();
|
|
25
|
-
}, [
|
|
26
|
-
pathname,
|
|
27
|
-
setPageData
|
|
28
|
-
]);
|
|
29
|
-
if (!data) return /*#__PURE__*/ jsx(Fragment, {});
|
|
8
|
+
const { data } = useContext(PageContext);
|
|
9
|
+
const location = useLocation();
|
|
10
|
+
const { search } = location;
|
|
11
|
+
if (import.meta.env.ENABLE_WEBMCP && !import.meta.env.SSR) {
|
|
12
|
+
useWebMcpSiteInfo();
|
|
13
|
+
useWebMcpPageList();
|
|
14
|
+
useWebMcpNavigation();
|
|
15
|
+
if (import.meta.env.ENABLE_SSG_MD) useWebMcpPageReading();
|
|
16
|
+
}
|
|
30
17
|
const frontmatter = data.frontmatter || {};
|
|
31
18
|
const GLOBAL_COMPONENTS_KEY = 'globalUIComponents';
|
|
32
19
|
const query = new URLSearchParams(search);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Page } from './initPageData.js';
|
|
2
|
-
export declare function
|
|
3
|
-
|
|
2
|
+
export declare function createClientRouter(initialPageData?: Page): import("react-router-dom").DataRouter;
|
|
3
|
+
export declare function ClientApp({ router, }: {
|
|
4
|
+
router: ReturnType<typeof createClientRouter>;
|
|
4
5
|
}): import("react").JSX.Element;
|
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { RouterProvider, ThemeContext, createBrowserRouter, removeTrailingSlash, useSite, withBase } from "@rspress/core/runtime";
|
|
3
3
|
import { useThemeState } from "@rspress/core/theme";
|
|
4
4
|
import { UnheadProvider, createHead } from "@unhead/react/client";
|
|
5
|
-
import { useMemo
|
|
6
|
-
import {
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
import { PAGE_ROUTE_ID } from "./pageDataLoader.js";
|
|
7
|
+
import { createPageRoutes } from "./PageRoute.js";
|
|
7
8
|
const head = createHead();
|
|
8
|
-
function
|
|
9
|
-
|
|
9
|
+
function createClientRouter(initialPageData) {
|
|
10
|
+
return createBrowserRouter(createPageRoutes(), {
|
|
11
|
+
basename: removeTrailingSlash(withBase('/')),
|
|
12
|
+
hydrationData: initialPageData ? {
|
|
13
|
+
loaderData: {
|
|
14
|
+
[PAGE_ROUTE_ID]: initialPageData
|
|
15
|
+
}
|
|
16
|
+
} : void 0
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function ClientApp({ router }) {
|
|
10
20
|
const [theme, setTheme] = useThemeState();
|
|
11
21
|
const { site } = useSite();
|
|
22
|
+
const transitionOptions = {
|
|
23
|
+
useTransitions: site.route.useTransitions,
|
|
24
|
+
future: {
|
|
25
|
+
v7_startTransition: site.route.useTransitions
|
|
26
|
+
}
|
|
27
|
+
};
|
|
12
28
|
return /*#__PURE__*/ jsx(ThemeContext.Provider, {
|
|
13
29
|
value: useMemo(()=>({
|
|
14
30
|
theme,
|
|
@@ -17,23 +33,13 @@ function ClientApp({ initialPageData = null }) {
|
|
|
17
33
|
theme,
|
|
18
34
|
setTheme
|
|
19
35
|
]),
|
|
20
|
-
children: /*#__PURE__*/ jsx(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
data,
|
|
26
|
-
setData
|
|
27
|
-
]),
|
|
28
|
-
children: /*#__PURE__*/ jsx(BrowserRouter, {
|
|
29
|
-
basename: removeTrailingSlash(withBase('/')),
|
|
30
|
-
useTransitions: site.route.useTransitions,
|
|
31
|
-
children: /*#__PURE__*/ jsx(UnheadProvider, {
|
|
32
|
-
head: head,
|
|
33
|
-
children: /*#__PURE__*/ jsx(App, {})
|
|
34
|
-
})
|
|
36
|
+
children: /*#__PURE__*/ jsx(UnheadProvider, {
|
|
37
|
+
head: head,
|
|
38
|
+
children: /*#__PURE__*/ jsx(RouterProvider, {
|
|
39
|
+
router: router,
|
|
40
|
+
...transitionOptions
|
|
35
41
|
})
|
|
36
42
|
})
|
|
37
43
|
});
|
|
38
44
|
}
|
|
39
|
-
export { ClientApp };
|
|
45
|
+
export { ClientApp, createClientRouter };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ErrorRoute(): import("react").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ErrorLayout } from "@rspress/core/theme";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import { useLocation, useRouteError } from "react-router-dom";
|
|
5
|
+
import { useSite } from "./hooks/useSite.js";
|
|
6
|
+
import { withBase } from "./utils.js";
|
|
7
|
+
function ErrorRoute() {
|
|
8
|
+
const error = useRouteError();
|
|
9
|
+
const { pathname } = useLocation();
|
|
10
|
+
const { site } = useSite();
|
|
11
|
+
const segments = pathname.split('/').filter(Boolean);
|
|
12
|
+
const version = site.multiVersion.versions.find((v)=>v === segments[0]);
|
|
13
|
+
const lang = site.locales.find((locale)=>locale.lang === segments[version ? 1 : 0])?.lang || site.lang;
|
|
14
|
+
const prefix = [
|
|
15
|
+
version !== site.multiVersion.default ? version : void 0,
|
|
16
|
+
lang !== site.lang ? lang : void 0
|
|
17
|
+
].filter(Boolean);
|
|
18
|
+
const homeHref = withBase(prefix.length ? `/${prefix.join('/')}/` : '/');
|
|
19
|
+
useEffect(()=>{
|
|
20
|
+
console.error('[rspress] Failed to render page:', error);
|
|
21
|
+
}, [
|
|
22
|
+
error
|
|
23
|
+
]);
|
|
24
|
+
return /*#__PURE__*/ jsx(ErrorLayout, {
|
|
25
|
+
error: error,
|
|
26
|
+
lang: lang,
|
|
27
|
+
homeHref: homeHref
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export { ErrorRoute };
|