@rspress/core 2.1.0-beta.1 → 2.1.0-beta.2
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/cli/index.js +2 -2
- package/dist/config/loadConfigFile.js +1 -1
- package/dist/eject-theme/components/CdnTabs/index.test.tsx +71 -0
- package/dist/eject-theme/components/CdnTabs/index.tsx +175 -0
- package/dist/eject-theme/components/DocContent/index.tsx +0 -3
- package/dist/eject-theme/components/FallbackHeading/index.tsx +6 -1
- package/dist/eject-theme/components/Link/index.tsx +9 -18
- package/dist/eject-theme/components/Link/useLinkNavigate.ts +17 -3
- package/dist/eject-theme/components/NavTitle/index.test.tsx +78 -0
- package/dist/eject-theme/components/NavTitle/index.tsx +9 -5
- package/dist/eject-theme/components/PackageManagerTabs/index.test.tsx +79 -1
- package/dist/eject-theme/components/PackageManagerTabs/index.tsx +25 -12
- package/dist/eject-theme/components/Search/NoSearchResult.scss +1 -2
- package/dist/eject-theme/components/Search/SearchPanel.scss +75 -63
- package/dist/eject-theme/components/Search/SuggestItem.scss +28 -41
- package/dist/eject-theme/components/Sidebar/SidebarItem.scss +8 -0
- package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.scss +3 -0
- package/dist/node/PluginDriver.d.ts +5 -0
- package/dist/node/PluginDriver.js +14 -5
- 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/constants.js +1 -1
- package/dist/node/eject.js +1 -1
- package/dist/node/initRsbuild.js +12 -4
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -0
- package/dist/node/mdx/remarkPlugins/link.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 +1 -1
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/runtimeModule/i18n/getI18nData.d.ts +11 -0
- package/dist/node/runtimeModule/{i18n.js → i18n/getI18nData.js} +35 -22
- package/dist/node/runtimeModule/i18n/rsbuildPlugin.d.ts +5 -0
- package/dist/node/runtimeModule/i18n/rsbuildPlugin.js +21 -0
- 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.d.ts +2 -1
- package/dist/node/runtimeModule/siteData/createSiteData.js +3 -3
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.d.ts +2 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +3 -4
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +2 -2
- package/dist/node/serve.js +1 -1
- package/dist/node/sitemap.d.ts +7 -2
- package/dist/node/sitemap.js +40 -57
- package/dist/node/ssg/alternateLinks.js +1 -1
- package/dist/node/ssg/htmlFile.js +1 -1
- package/dist/node/ssg/renderHtmlTemplate.js +1 -1
- package/dist/node/ssg/renderPage.js +1 -1
- package/dist/node/ssg/renderPageWorker.js +1 -1
- package/dist/node/ssg/renderPages.js +2 -2
- 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 +1 -1
- package/dist/node/ssg-md/renderPages.js +2 -2
- 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 +2 -2
- package/dist/{h~0.js → p~0.js} +6 -4
- package/dist/runtime/App.js +14 -10
- package/dist/runtime/BrowserOnly.d.ts +1 -1
- package/dist/runtime/BrowserOnly.js +53 -20
- package/dist/runtime/ClientApp.js +4 -0
- package/dist/runtime/NoSSR.d.ts +7 -3
- package/dist/runtime/NoSSR.js +30 -9
- package/dist/runtime/PageRoute.js +20 -8
- package/dist/runtime/index.d.ts +3 -2
- package/dist/runtime/index.js +3 -4
- package/dist/runtime/react.d.ts +5 -0
- package/dist/runtime/react.js +4 -0
- package/dist/runtime/reactDom.d.ts +6 -0
- package/dist/runtime/reactDom.js +2 -1
- package/dist/runtime/socialLinks.d.ts +1 -0
- package/dist/runtime/socialLinks.js +3 -0
- package/dist/theme/assets/bun.js +101 -0
- package/dist/theme/assets/deno.js +15 -0
- package/dist/theme/assets/jsdelivr.js +53 -0
- package/dist/theme/{components/PackageManagerTabs/icons/Npm.js → assets/npm.js} +4 -4
- package/dist/theme/{components/PackageManagerTabs/icons/Pnpm.js → assets/pnpm.js} +4 -4
- package/dist/theme/assets/unpkg.js +15 -0
- package/dist/theme/assets/yarn.js +22 -0
- package/dist/theme/components/CdnTabs/index.d.ts +10 -0
- package/dist/theme/components/CdnTabs/index.js +146 -0
- package/dist/theme/components/DocContent/index.js +1 -2
- package/dist/theme/components/FallbackHeading/index.js +1 -0
- package/dist/theme/components/Link/index.js +4 -13
- package/dist/theme/components/Link/useLinkNavigate.js +12 -4
- package/dist/theme/components/NavTitle/index.js +10 -5
- package/dist/theme/components/PackageManagerTabs/index.d.ts +2 -0
- package/dist/theme/components/PackageManagerTabs/index.js +22 -12
- package/dist/theme/components/Search/NoSearchResult.css +1 -2
- package/dist/theme/components/Search/SearchPanel.css +72 -51
- package/dist/theme/components/Search/SuggestItem.css +21 -34
- package/dist/theme/components/Sidebar/SidebarItem.css +5 -0
- package/dist/theme/components/Sidebar/SidebarSectionHeader.css +1 -0
- package/dist/theme/hooks/useDynamicToc.js +27 -34
- package/dist/theme/icons.d.ts +7 -0
- package/dist/theme/icons.js +15 -1
- package/dist/theme/index.d.ts +1 -2
- package/dist/theme/index.js +1 -2
- package/dist/theme/layout/Layout/index.js +1 -2
- package/dist/y~0.js +166 -0
- package/package.json +13 -13
- package/dist/b~0.js +0 -104
- package/dist/eject-theme/components/PackageManagerTabs/icons/Bun.tsx +0 -101
- package/dist/eject-theme/components/PackageManagerTabs/icons/Deno.tsx +0 -18
- package/dist/eject-theme/components/PackageManagerTabs/icons/Npm.tsx +0 -16
- package/dist/eject-theme/components/PackageManagerTabs/icons/Pnpm.tsx +0 -22
- package/dist/eject-theme/components/PackageManagerTabs/icons/Yarn.tsx +0 -18
- package/dist/node/runtimeModule/i18n.d.ts +0 -8
- package/dist/theme/components/PackageManagerTabs/icons/Bun.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Bun.js +0 -137
- package/dist/theme/components/PackageManagerTabs/icons/Deno.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Deno.js +0 -15
- package/dist/theme/components/PackageManagerTabs/icons/Npm.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Pnpm.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Yarn.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Yarn.js +0 -22
- package/dist/theme/logic/useScrollAfterNav.d.ts +0 -5
- package/dist/theme/logic/useScrollAfterNav.js +0 -35
- package/dist/theme/logic/useScrollReset.d.ts +0 -5
- package/dist/theme/logic/useScrollReset.js +0 -12
- package/dist/tu~0.js +0 -3
- /package/dist/node/runtimeModule/{DEFAULT_I18N_TEXT.d.ts → i18n/DEFAULT_I18N_TEXT.d.ts} +0 -0
- /package/dist/node/runtimeModule/{DEFAULT_I18N_TEXT.js → i18n/DEFAULT_I18N_TEXT.js} +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { pluginVirtualModule } from "../../../p~0.js";
|
|
2
|
+
const rsbuildPluginI18n = ({ pluginDriver })=>[
|
|
3
|
+
{
|
|
4
|
+
name: 'rspress:i18n',
|
|
5
|
+
setup (api) {
|
|
6
|
+
api.onBeforeDevCompile(({ isFirstCompile })=>{
|
|
7
|
+
if (!isFirstCompile) pluginDriver.invalidateI18nData();
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
pluginVirtualModule({
|
|
12
|
+
tempDir: '.rspress/runtime',
|
|
13
|
+
virtualModules: {
|
|
14
|
+
["virtual-i18n-text"]: async (context)=>{
|
|
15
|
+
const data = await pluginDriver.getI18nData(context);
|
|
16
|
+
return `export default ${JSON.stringify(data, null, 2)}`;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
];
|
|
21
|
+
export { rsbuildPluginI18n };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SEARCH_INDEX_NAME, groupBy } from "../../../
|
|
1
|
+
import { SEARCH_INDEX_NAME, groupBy } from "../../../p~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 "../../../p~0.js";
|
|
2
2
|
import { createPageData } from "./createPageData.js";
|
|
3
3
|
const rsbuildPluginDocVM = async ({ config, userDocRoot, routeService, pluginDriver })=>{
|
|
4
4
|
const ref = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SiteData, UserConfig } from '@rspress/shared';
|
|
2
|
-
|
|
2
|
+
import type { PluginDriver } from '../../PluginDriver.js';
|
|
3
|
+
export declare function createSiteData(userConfig: UserConfig, pluginDriver: PluginDriver): Promise<{
|
|
3
4
|
siteData: Omit<SiteData, 'root' | 'pages'>;
|
|
4
5
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getIconUrlPath } from "../../../
|
|
1
|
+
import { getIconUrlPath } from "../../../p~0.js";
|
|
2
2
|
import { normalizeThemeConfig } from "./normalizeThemeConfig.js";
|
|
3
|
-
async function createSiteData(userConfig) {
|
|
3
|
+
async function createSiteData(userConfig, pluginDriver) {
|
|
4
4
|
const tempSearchObj = Object.assign({}, userConfig.search);
|
|
5
5
|
if (tempSearchObj) tempSearchObj.searchHooks = void 0;
|
|
6
6
|
const siteData = {
|
|
@@ -13,7 +13,7 @@ async function createSiteData(userConfig) {
|
|
|
13
13
|
useTransitions: true,
|
|
14
14
|
...userConfig?.route
|
|
15
15
|
},
|
|
16
|
-
themeConfig: await normalizeThemeConfig(userConfig),
|
|
16
|
+
themeConfig: await normalizeThemeConfig(userConfig, pluginDriver),
|
|
17
17
|
lang: userConfig?.lang || '',
|
|
18
18
|
locales: userConfig?.locales || userConfig.themeConfig?.locales || [],
|
|
19
19
|
logo: userConfig?.logo || '',
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { type NormalizedDefaultThemeConfig, type UserConfig } from '@rspress/shared';
|
|
2
|
-
|
|
2
|
+
import type { PluginDriver } from '../../PluginDriver.js';
|
|
3
|
+
export declare function normalizeThemeConfig(docConfig: UserConfig, pluginDriver: PluginDriver): Promise<NormalizedDefaultThemeConfig>;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../
|
|
2
|
-
import { getI18nData } from "../i18n.js";
|
|
1
|
+
import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../p~0.js";
|
|
3
2
|
import { applyReplaceRules } from "../../utils/applyReplaceRules.js";
|
|
4
|
-
async function normalizeThemeConfig(docConfig) {
|
|
3
|
+
async function normalizeThemeConfig(docConfig, pluginDriver) {
|
|
5
4
|
const { locales: siteLocales, lang, replaceRules = [], multiVersion } = docConfig;
|
|
6
5
|
const { versions = [] } = multiVersion || {};
|
|
7
6
|
const hasMultiVersion = versions.length > 0;
|
|
8
7
|
docConfig.themeConfig = docConfig.themeConfig || {};
|
|
9
8
|
const { themeConfig } = docConfig;
|
|
10
9
|
const locales = siteLocales ?? (themeConfig?.locales || []);
|
|
11
|
-
const i18nTextData = await getI18nData(
|
|
10
|
+
const i18nTextData = await pluginDriver.getI18nData();
|
|
12
11
|
const normalizeLinkPrefix = (link, currentLang)=>{
|
|
13
12
|
const normalizedLink = slash(link);
|
|
14
13
|
if (!currentLang || !link || normalizedLink.startsWith(`/${currentLang}`) || isExternalUrl(normalizedLink) || hasMultiVersion) return normalizedLink;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isProduction, logger } from "../../../
|
|
1
|
+
import { isProduction, logger } from "../../../p~0.js";
|
|
2
2
|
import { modifyConfigWithAutoNavSide } from "../../auto-nav-sidebar/index.js";
|
|
3
3
|
import { createSiteData } from "./createSiteData.js";
|
|
4
4
|
const siteDataVMPlugin = (context)=>{
|
|
@@ -12,7 +12,7 @@ const siteDataVMPlugin = (context)=>{
|
|
|
12
12
|
} finally{
|
|
13
13
|
logger.debug(`modifyConfigWithAutoNavSide - size: ${mdFileSet.size} cost: ${performance.now() - now}ms`);
|
|
14
14
|
}
|
|
15
|
-
const { siteData } = await createSiteData(config);
|
|
15
|
+
const { siteData } = await createSiteData(config, pluginDriver);
|
|
16
16
|
return {
|
|
17
17
|
code: `export default ${JSON.stringify(siteData, null, 2)}`,
|
|
18
18
|
metaFileSet,
|
package/dist/node/serve.js
CHANGED
package/dist/node/sitemap.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
+
import { type UserConfig } from '@rspress/shared';
|
|
3
|
+
import type { RouteService } from './route/RouteService.js';
|
|
4
|
+
export declare function rsbuildPluginSitemap({ config, routeService, }: {
|
|
5
|
+
config: UserConfig;
|
|
6
|
+
routeService: Pick<RouteService, 'getRoutes'>;
|
|
7
|
+
}): RsbuildPlugin;
|
package/dist/node/sitemap.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { withSiteOrigin,
|
|
2
|
-
import { glob } from "../h~0.js";
|
|
1
|
+
import { withSiteOrigin, logger, glob, promises_stat, withBase } from "../p~0.js";
|
|
3
2
|
import { routePath2HtmlFileName } from "./ssg/htmlFile.js";
|
|
4
3
|
function ensureTrailingSlash(url) {
|
|
5
4
|
return url.endsWith('/') ? url : `${url}/`;
|
|
@@ -39,65 +38,49 @@ const generateXml = (sitemaps)=>{
|
|
|
39
38
|
logger.info(`Generate sitemap.xml for ${sitemaps.length} pages.`);
|
|
40
39
|
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
40
|
};
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
const set = new Set();
|
|
46
|
-
let resolvedSiteUrl = '';
|
|
47
|
-
let cleanUrls = false;
|
|
41
|
+
function rsbuildPluginSitemap({ config, routeService }) {
|
|
42
|
+
const options = 'object' == typeof config.sitemap ? config.sitemap : {};
|
|
43
|
+
const cleanUrls = config.route?.cleanUrls ?? false;
|
|
48
44
|
return {
|
|
49
45
|
name: 'rspress:sitemap',
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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)));
|
|
46
|
+
setup (api) {
|
|
47
|
+
api.modifyBundlerChain((_chain, { isProd, environment })=>{
|
|
48
|
+
if (!isProd || 'web' !== environment.name) return;
|
|
49
|
+
const resolvedSiteUrl = getSiteUrl(options.siteUrl, config);
|
|
50
|
+
api.processAssets({
|
|
51
|
+
stage: 'additional',
|
|
52
|
+
environments: [
|
|
53
|
+
'web'
|
|
54
|
+
]
|
|
55
|
+
}, async ({ compilation, sources })=>{
|
|
56
|
+
if (compilation.errors.length) return;
|
|
57
|
+
for (const publicDir of api.getNormalizedConfig().server.publicDir){
|
|
58
|
+
if (false === publicDir.copyOnBuild) continue;
|
|
59
|
+
const files = await glob('sitemap.xml', {
|
|
60
|
+
cwd: publicDir.name,
|
|
61
|
+
ignore: publicDir.ignore
|
|
71
62
|
});
|
|
63
|
+
if (files.length) return void logger.warn('[sitemap] Preserving public sitemap.xml.');
|
|
72
64
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
}
|
|
65
|
+
const sitemaps = [];
|
|
66
|
+
const seen = new Set();
|
|
67
|
+
for (const { routePath, absolutePath } of routeService.getRoutes()){
|
|
68
|
+
if (seen.has(routePath)) continue;
|
|
69
|
+
seen.add(routePath);
|
|
70
|
+
const pathname = cleanUrls ? routePath : `/${routePath2HtmlFileName(routePath)}`;
|
|
71
|
+
const encodedPath = pathname.split('/').map(encodeURIComponent).join('/');
|
|
72
|
+
sitemaps.push({
|
|
73
|
+
loc: `${resolvedSiteUrl.replace(/\/$/, '')}${encodedPath}`,
|
|
74
|
+
lastmod: (await promises_stat(absolutePath)).mtime.toISOString(),
|
|
75
|
+
priority: '/' === routePath ? '1.0' : options.defaultPriority ?? '0.5',
|
|
76
|
+
changefreq: options.defaultChangeFreq ?? 'monthly',
|
|
77
|
+
...options.customMaps?.[routePath] ?? {}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
compilation.emitAsset('sitemap.xml', new sources.RawSource(generateXml(sitemaps)));
|
|
81
|
+
});
|
|
82
|
+
});
|
|
100
83
|
}
|
|
101
84
|
};
|
|
102
85
|
}
|
|
103
|
-
export {
|
|
86
|
+
export { rsbuildPluginSitemap };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeHref, removeTrailingSlash, addLeadingSlash, normalizePosixPath, withSiteOrigin } from "../../
|
|
1
|
+
import { normalizeHref, removeTrailingSlash, addLeadingSlash, normalizePosixPath, withSiteOrigin } from "../../p~0.js";
|
|
2
2
|
function createAlternateLinksByRoute(routes, config) {
|
|
3
3
|
const routeGroups = new Map();
|
|
4
4
|
for (const route of routes){
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { external_node_path_resolve, relative, isAbsolute } from "../../
|
|
1
|
+
import { external_node_path_resolve, relative, isAbsolute } from "../../y~0.js";
|
|
2
2
|
const routePath2HtmlFileName = (routePath)=>{
|
|
3
3
|
let fileName = routePath;
|
|
4
4
|
fileName = fileName.endsWith('/') ? `${routePath}index.html` : `${routePath}.html`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { posix } from "../../
|
|
1
|
+
import { posix } from "../../y~0.js";
|
|
2
2
|
import { META_GENERATOR, RSPRESS_VERSION, APP_HTML_MARKER, HEAD_MARKER } from "../constants.js";
|
|
3
3
|
import { routePath2HtmlFileName } from "./htmlFile.js";
|
|
4
4
|
import { createError } from "../utils/error.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../t~0.js";
|
|
3
|
-
import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../
|
|
3
|
+
import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../y~0.js";
|
|
4
4
|
import { hintSSGFailed } from "../logger/hint.js";
|
|
5
5
|
import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
|
|
6
6
|
const picocolors = rspackRequire("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { writeFile, mkdir, dirname, workerData } from "../../4~0.js";
|
|
2
2
|
import { createError } from "../utils/error.js";
|
|
3
3
|
import { resolveHtmlFilePath } from "./htmlFile.js";
|
|
4
|
-
import { pMap } from "../../
|
|
4
|
+
import { pMap } from "../../y~0.js";
|
|
5
5
|
import { renderPage } from "./renderPage.js";
|
|
6
6
|
const params = workerData?.[1]?.params;
|
|
7
7
|
if (!params) throw createError('SSG Worker Thread workerData params missing');
|
|
@@ -1,11 +1,11 @@
|
|
|
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 "../../p~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";
|
|
8
|
-
import { pMap } from "../../
|
|
8
|
+
import { pMap } from "../../y~0.js";
|
|
9
9
|
import { renderPage } from "./renderPage.js";
|
|
10
10
|
import { hintSSGFailed } from "../logger/hint.js";
|
|
11
11
|
import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../
|
|
1
|
+
import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../p~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 "../../p~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 "../../../p~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 "../../../p~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,6 +1,6 @@
|
|
|
1
1
|
import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../t~0.js";
|
|
3
|
-
import { createHead, pathToFileURL, logger } from "../../
|
|
3
|
+
import { createHead, pathToFileURL, logger } from "../../p~0.js";
|
|
4
4
|
import { hintSSGMDFailed } from "../logger/hint.js";
|
|
5
5
|
const picocolors = rspackRequire("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
6
6
|
var picocolors_default = /*#__PURE__*/ compatGetDefaultExport(picocolors);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../t~0.js";
|
|
3
|
-
import { logger } from "../../
|
|
4
|
-
import { pMap } from "../../
|
|
3
|
+
import { logger } from "../../p~0.js";
|
|
4
|
+
import { pMap } from "../../y~0.js";
|
|
5
5
|
import { renderPage } from "./renderPage.js";
|
|
6
6
|
import { SSGConcurrency } from "../ssg/ssgEnv.js";
|
|
7
7
|
const picocolors = rspackRequire("../../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 "../../p~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 "../../p~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 "../../p~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 "../../p~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";
|
|
@@ -95,7 +95,7 @@ async function resolveReactRenderToMarkdownAlias() {
|
|
|
95
95
|
const hasInstalled = await detectPackageMajorVersion('react-render-to-markdown');
|
|
96
96
|
if (!hasInstalled) {
|
|
97
97
|
const reactMajorVersion = await detectPackageMajorVersion('react');
|
|
98
|
-
if (reactMajorVersion && reactMajorVersion < 19) logger.warn(`You are using React ${reactMajorVersion} with \`llms: true\`. Please install \`react-render-to-markdown\` to ensure compatibility.\n\nAdd the following to your ${picocolors_default().greenBright('package.json')}:\n\n` + picocolors_default().greenBright(` "dependencies": {\n "react": "^18.3.1",\n "react-dom": "^18.3.1",\n "react-render-to-markdown": "^18.3.1"\n }\n`));
|
|
98
|
+
if (reactMajorVersion && reactMajorVersion < 19) logger.warn(`You are using React ${reactMajorVersion} with \`llms: true\`. Please install \`react-render-to-markdown@18\` to ensure compatibility.\n\nAdd the following to your ${picocolors_default().greenBright('package.json')}:\n\n` + picocolors_default().greenBright(` "dependencies": {\n "react": "^18.3.1",\n "react-dom": "^18.3.1",\n "react-render-to-markdown": "^18.3.1"\n }\n`));
|
|
99
99
|
return {};
|
|
100
100
|
}
|
|
101
101
|
const alias = {};
|
package/dist/{h~0.js → p~0.js}
RENAMED
|
@@ -1811,7 +1811,7 @@ function setDotProp(obj, keys, val) {
|
|
|
1811
1811
|
}
|
|
1812
1812
|
}
|
|
1813
1813
|
function setByType(obj, transforms) {
|
|
1814
|
-
for (const [key, transform] of Object.entries(transforms))if (transform.shouldTransform) {
|
|
1814
|
+
for (const [key, transform] of Object.entries(transforms))if (transform.shouldTransform && key in obj) {
|
|
1815
1815
|
obj[key] = [
|
|
1816
1816
|
obj[key]
|
|
1817
1817
|
].flat();
|
|
@@ -1862,14 +1862,15 @@ var Option = class {
|
|
|
1862
1862
|
else this.isBoolean = true;
|
|
1863
1863
|
}
|
|
1864
1864
|
};
|
|
1865
|
-
let runtimeProcessArgs;
|
|
1866
1865
|
let runtimeInfo;
|
|
1867
1866
|
if ("u" > typeof process) {
|
|
1868
1867
|
let runtimeName;
|
|
1869
1868
|
runtimeName = "u" > typeof Deno && "string" == typeof Deno.version?.deno ? "deno" : "u" > typeof Bun && "string" == typeof Bun.version ? "bun" : "node";
|
|
1870
1869
|
runtimeInfo = `${process.platform}-${process.arch} ${runtimeName}-${process.version}`;
|
|
1871
|
-
runtimeProcessArgs = process.argv;
|
|
1872
1870
|
} else runtimeInfo = "u" < typeof navigator ? "unknown" : `${navigator.platform} ${navigator.userAgent}`;
|
|
1871
|
+
function getRuntimeProcessArgs() {
|
|
1872
|
+
return "u" < typeof process ? void 0 : process.argv;
|
|
1873
|
+
}
|
|
1873
1874
|
var Command = class {
|
|
1874
1875
|
rawName;
|
|
1875
1876
|
description;
|
|
@@ -2096,6 +2097,7 @@ var CAC = class extends EventTarget {
|
|
|
2096
2097
|
}
|
|
2097
2098
|
parse(argv, { run = true } = {}) {
|
|
2098
2099
|
if (!argv) {
|
|
2100
|
+
const runtimeProcessArgs = getRuntimeProcessArgs();
|
|
2099
2101
|
if (!runtimeProcessArgs) throw new Error("No argv provided and runtime process argv is not available.");
|
|
2100
2102
|
argv = runtimeProcessArgs;
|
|
2101
2103
|
}
|
|
@@ -3009,7 +3011,7 @@ async function glob(globInput, options) {
|
|
|
3009
3011
|
}
|
|
3010
3012
|
export { logger } from "@rspress/shared/logger";
|
|
3011
3013
|
export { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, DEFAULT_PAGE_EXTENSIONS } from "@rspress/shared/constants";
|
|
3012
|
-
export { default as promises, mkdir, readdir as promises_readdir, rm, stat as promises_stat, writeFile } from "node:fs/promises";
|
|
3014
|
+
export { default as promises, mkdir, readFile, readdir as promises_readdir, rm, stat as promises_stat, writeFile } from "node:fs/promises";
|
|
3013
3015
|
export { createRequire } from "node:module";
|
|
3014
3016
|
export { cwd as external_node_process_cwd } from "node:process";
|
|
3015
3017
|
export { fileURLToPath, pathToFileURL } from "node:url";
|
package/dist/runtime/App.js
CHANGED
|
@@ -3,29 +3,33 @@ import { PageContext, useLocation } from "@rspress/core/runtime";
|
|
|
3
3
|
import { Layout, LlmsHint, Root, useWebMcpNavigation, useWebMcpPageList, useWebMcpPageReading, useWebMcpSiteInfo } from "@rspress/core/theme";
|
|
4
4
|
import react, { useContext } from "react";
|
|
5
5
|
import { useGlobalComponents } from "./hooks/useGlobalComponents.js";
|
|
6
|
+
const GLOBAL_COMPONENTS_KEY = 'globalUIComponents';
|
|
7
|
+
const WebMcpPageReading = import.meta.env.ENABLE_WEBMCP && import.meta.env.ENABLE_SSG_MD ? ()=>{
|
|
8
|
+
useWebMcpPageReading();
|
|
9
|
+
return null;
|
|
10
|
+
} : null;
|
|
11
|
+
const WebMCP = import.meta.env.ENABLE_WEBMCP && !import.meta.env.SSR ? ()=>{
|
|
12
|
+
useWebMcpSiteInfo();
|
|
13
|
+
useWebMcpPageList();
|
|
14
|
+
useWebMcpNavigation();
|
|
15
|
+
return WebMcpPageReading ? /*#__PURE__*/ jsx(WebMcpPageReading, {}) : null;
|
|
16
|
+
} : null;
|
|
6
17
|
function App() {
|
|
7
18
|
const globalComponents = useGlobalComponents();
|
|
8
19
|
const { data } = useContext(PageContext);
|
|
9
20
|
const location = useLocation();
|
|
10
21
|
const { search } = location;
|
|
11
|
-
|
|
12
|
-
useWebMcpSiteInfo();
|
|
13
|
-
useWebMcpPageList();
|
|
14
|
-
useWebMcpNavigation();
|
|
15
|
-
if (import.meta.env.ENABLE_SSG_MD) useWebMcpPageReading();
|
|
16
|
-
}
|
|
17
|
-
const frontmatter = data.frontmatter || {};
|
|
18
|
-
const GLOBAL_COMPONENTS_KEY = 'globalUIComponents';
|
|
19
|
-
const query = new URLSearchParams(search);
|
|
20
|
-
const hideGlobalUIComponents = false === frontmatter[GLOBAL_COMPONENTS_KEY] || "0" === query.get(GLOBAL_COMPONENTS_KEY);
|
|
22
|
+
const hideGlobalUIComponents = data?.frontmatter?.[GLOBAL_COMPONENTS_KEY] === false || Boolean(search) && "0" === new URLSearchParams(search).get(GLOBAL_COMPONENTS_KEY);
|
|
21
23
|
if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsxs(Root, {
|
|
22
24
|
children: [
|
|
25
|
+
WebMCP && /*#__PURE__*/ jsx(WebMCP, {}),
|
|
23
26
|
import.meta.env.ENABLE_LLMS_HINT && /*#__PURE__*/ jsx(LlmsHint, {}),
|
|
24
27
|
/*#__PURE__*/ jsx(Layout, {})
|
|
25
28
|
]
|
|
26
29
|
});
|
|
27
30
|
return /*#__PURE__*/ jsxs(Root, {
|
|
28
31
|
children: [
|
|
32
|
+
WebMCP && /*#__PURE__*/ jsx(WebMCP, {}),
|
|
29
33
|
import.meta.env.ENABLE_LLMS_HINT && /*#__PURE__*/ jsx(LlmsHint, {}),
|
|
30
34
|
/*#__PURE__*/ jsx(Layout, {}),
|
|
31
35
|
!hideGlobalUIComponents && globalComponents.map((componentInfo, index)=>{
|
|
@@ -3,5 +3,5 @@ export interface BrowserOnlyProps {
|
|
|
3
3
|
children: () => ReactNode | Promise<ReactNode>;
|
|
4
4
|
fallback?: ReactNode;
|
|
5
5
|
}
|
|
6
|
-
export declare function BrowserOnly(props: BrowserOnlyProps):
|
|
6
|
+
export declare function BrowserOnly(props: BrowserOnlyProps): import("react").JSX.Element;
|
|
7
7
|
export default BrowserOnly;
|
|
@@ -1,39 +1,72 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
});
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { safeUse } from "./react.js";
|
|
4
|
+
import { safeBrowserOnly } from "./reactDom.js";
|
|
5
|
+
function DeferredBrowserOnly({ source, fallback = null }) {
|
|
6
|
+
const [state, setState] = useState();
|
|
8
7
|
useEffect(()=>{
|
|
9
8
|
let isMounted = true;
|
|
10
|
-
setState(
|
|
11
|
-
|
|
12
|
-
children
|
|
13
|
-
});
|
|
14
|
-
Promise.resolve().then(()=>children()).then((content)=>{
|
|
9
|
+
setState(void 0);
|
|
10
|
+
Promise.resolve().then(()=>'function' == typeof source ? source() : source).then((content)=>{
|
|
15
11
|
if (isMounted) setState({
|
|
16
|
-
|
|
17
|
-
children,
|
|
12
|
+
source,
|
|
18
13
|
content
|
|
19
14
|
});
|
|
20
15
|
}, (error)=>{
|
|
21
16
|
if (isMounted) setState({
|
|
22
|
-
|
|
23
|
-
children,
|
|
17
|
+
source,
|
|
24
18
|
error
|
|
25
19
|
});
|
|
26
20
|
});
|
|
27
21
|
return ()=>{
|
|
28
22
|
isMounted = false;
|
|
29
23
|
};
|
|
24
|
+
}, [
|
|
25
|
+
source
|
|
26
|
+
]);
|
|
27
|
+
if (!state || state.source !== source) return fallback;
|
|
28
|
+
if ('error' in state) throw state.error;
|
|
29
|
+
return state.content;
|
|
30
|
+
}
|
|
31
|
+
function ModernBrowserOnly({ children, fallback }) {
|
|
32
|
+
safeUse(safeBrowserOnly('This content is only rendered in the browser.'));
|
|
33
|
+
const result = useMemo(()=>{
|
|
34
|
+
const content = children();
|
|
35
|
+
if (null !== content && 'object' == typeof content && 'then' in content && 'function' == typeof content.then) {
|
|
36
|
+
const promise = Promise.resolve(content);
|
|
37
|
+
promise.catch(()=>{});
|
|
38
|
+
return {
|
|
39
|
+
promise
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
content
|
|
44
|
+
};
|
|
30
45
|
}, [
|
|
31
46
|
children
|
|
32
47
|
]);
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
48
|
+
if (result.promise) return /*#__PURE__*/ jsx(DeferredBrowserOnly, {
|
|
49
|
+
source: result.promise,
|
|
50
|
+
fallback: fallback
|
|
51
|
+
});
|
|
52
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
53
|
+
children: result.content
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function BrowserOnly(props) {
|
|
57
|
+
const { fallback = null } = props;
|
|
58
|
+
if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsx(Fragment, {
|
|
59
|
+
children: fallback
|
|
60
|
+
});
|
|
61
|
+
return /*#__PURE__*/ jsx(Suspense, {
|
|
62
|
+
fallback: fallback,
|
|
63
|
+
children: 'function' == typeof safeBrowserOnly ? /*#__PURE__*/ jsx(ModernBrowserOnly, {
|
|
64
|
+
...props
|
|
65
|
+
}) : /*#__PURE__*/ jsx(DeferredBrowserOnly, {
|
|
66
|
+
source: props.children,
|
|
67
|
+
fallback: fallback
|
|
68
|
+
})
|
|
69
|
+
});
|
|
37
70
|
}
|
|
38
71
|
const runtime_BrowserOnly = BrowserOnly;
|
|
39
72
|
export default runtime_BrowserOnly;
|
|
@@ -7,6 +7,10 @@ import { PAGE_ROUTE_ID } from "./pageDataLoader.js";
|
|
|
7
7
|
import { createPageRoutes } from "./PageRoute.js";
|
|
8
8
|
const head = createHead();
|
|
9
9
|
function createClientRouter(initialPageData) {
|
|
10
|
+
if (!window.history.state?.key) window.history.replaceState({
|
|
11
|
+
...window.history.state,
|
|
12
|
+
key: Math.random().toString(36).slice(2, 10)
|
|
13
|
+
}, '');
|
|
10
14
|
return createBrowserRouter(createPageRoutes(), {
|
|
11
15
|
basename: removeTrailingSlash(withBase('/')),
|
|
12
16
|
hydrationData: initialPageData ? {
|