@rspress/core 2.0.0-alpha.10 → 2.0.0-alpha.12
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/index.d.ts +1 -2
- package/dist/index.js +232 -174
- package/dist/loader.js +18 -16
- package/dist/runtime/App.js +5 -4
- package/dist/runtime/ClientApp.d.ts +4 -1
- package/dist/runtime/ClientApp.js +15 -24
- package/dist/runtime/csrClientEntry.js +13 -0
- package/dist/runtime/initPageData.js +2 -2
- package/dist/runtime/ssrClientEntry.d.ts +1 -0
- package/dist/runtime/ssrClientEntry.js +19 -0
- package/dist/runtime/tsconfig.js +3 -3
- package/package.json +10 -10
- package/dist/runtime/clientEntry.js +0 -18
- /package/dist/runtime/{clientEntry.d.ts → csrClientEntry.d.ts} +0 -0
- /package/dist/runtime/{ssrEntry.d.ts → ssrServerEntry.d.ts} +0 -0
- /package/dist/runtime/{ssrEntry.js → ssrServerEntry.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { mergeDocConfig } from '@rspress/shared/node-utils';
|
|
2
2
|
import type { RsbuildConfig } from '@rsbuild/core';
|
|
3
3
|
import { RsbuildInstance } from '@rsbuild/core';
|
|
4
|
-
import { UserConfig } from '@rspress/shared';
|
|
4
|
+
import type { UserConfig } from '@rspress/shared';
|
|
5
5
|
|
|
6
6
|
export declare function build(options: BuildOptions): Promise<void>;
|
|
7
7
|
|
|
8
8
|
declare interface BuildOptions {
|
|
9
|
-
appDirectory: string;
|
|
10
9
|
docDirectory: string;
|
|
11
10
|
config: UserConfig;
|
|
12
11
|
}
|
package/dist/index.js
CHANGED
|
@@ -62,9 +62,9 @@ class PluginDriver {
|
|
|
62
62
|
this.clearPlugins();
|
|
63
63
|
const config = _class_private_field_get(this, _config);
|
|
64
64
|
const themeConfig = (null == config ? void 0 : config.themeConfig) || {};
|
|
65
|
-
const enableLastUpdated = (null == themeConfig ? void 0 : themeConfig.lastUpdated) || (null == themeConfig ? void 0 : null
|
|
65
|
+
const enableLastUpdated = (null == themeConfig ? void 0 : themeConfig.lastUpdated) || (null == themeConfig ? void 0 : null == (_themeConfig_locales = themeConfig.locales) ? void 0 : _themeConfig_locales.some((locale)=>locale.lastUpdated));
|
|
66
66
|
const mediumZoomConfig = (null == config ? void 0 : config.mediumZoom) ?? true;
|
|
67
|
-
const haveNavSidebarConfig = themeConfig.nav || themeConfig.sidebar || (null
|
|
67
|
+
const haveNavSidebarConfig = themeConfig.nav || themeConfig.sidebar || (null == (_themeConfig_locales1 = themeConfig.locales) ? void 0 : null == (_themeConfig_locales_ = _themeConfig_locales1[0]) ? void 0 : _themeConfig_locales_.nav) || (null == (_themeConfig_locales2 = themeConfig.locales) ? void 0 : null == (_themeConfig_locales_1 = _themeConfig_locales2[0]) ? void 0 : _themeConfig_locales_1.sidebar);
|
|
68
68
|
if (enableLastUpdated) {
|
|
69
69
|
const { pluginLastUpdated } = await import("@rspress/plugin-last-updated");
|
|
70
70
|
this.addPlugin(pluginLastUpdated());
|
|
@@ -215,6 +215,8 @@ const pluginVirtualModule = (pluginOptions = {})=>({
|
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
});
|
|
218
|
+
var package_namespaceObject = JSON.parse('{"i8":"2.0.0-alpha.12"}');
|
|
219
|
+
const RSPRESS_VERSION = package_namespaceObject.i8;
|
|
218
220
|
const isProduction = ()=>'production' === process.env.NODE_ENV;
|
|
219
221
|
const importStatementRegex = /import\s+(.*?)\s+from\s+(['"])(.*?)(?:"|');?/gm;
|
|
220
222
|
const inlineThemeScript = `{
|
|
@@ -227,8 +229,10 @@ const inlineThemeScript = `{
|
|
|
227
229
|
}`.replace(/\n/g, ';').replace(/\s{2,}/g, '');
|
|
228
230
|
const dirname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(new URL(import.meta.url)));
|
|
229
231
|
const PACKAGE_ROOT = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dirname, '..');
|
|
230
|
-
const
|
|
231
|
-
const
|
|
232
|
+
const TEMPLATE_PATH = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'index.html');
|
|
233
|
+
const CSR_CLIENT_ENTRY = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'csrClientEntry.js');
|
|
234
|
+
const SSR_CLIENT_ENTRY = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'ssrClientEntry.js');
|
|
235
|
+
const SSR_SERVER_ENTRY = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'ssrServerEntry.js');
|
|
232
236
|
const OUTPUT_DIR = 'doc_build';
|
|
233
237
|
const APP_HTML_MARKER = '<!--<?- DOC_CONTENT ?>-->';
|
|
234
238
|
const HEAD_MARKER = '<!--<?- HEAD ?>-->';
|
|
@@ -547,7 +551,7 @@ ${routeMeta.map((route, index)=>{
|
|
|
547
551
|
RouteService_class_private_field_set(this, _include, routeOptions.include || []);
|
|
548
552
|
RouteService_class_private_field_set(this, _exclude, routeOptions.exclude || []);
|
|
549
553
|
RouteService_class_private_field_set(this, _defaultLang, (null == userConfig ? void 0 : userConfig.lang) || '');
|
|
550
|
-
RouteService_class_private_field_set(this, _langs, ((null == userConfig ? void 0 : userConfig.locales) ?? (null == userConfig ? void 0 : null
|
|
554
|
+
RouteService_class_private_field_set(this, _langs, ((null == userConfig ? void 0 : userConfig.locales) ?? (null == userConfig ? void 0 : null == (_userConfig_themeConfig = userConfig.themeConfig) ? void 0 : _userConfig_themeConfig.locales) ?? []).map((item)=>item.lang));
|
|
551
555
|
RouteService_class_private_field_set(this, _base, (null == userConfig ? void 0 : userConfig.base) || '');
|
|
552
556
|
RouteService_class_private_field_set(this, _tempDir, tempDir);
|
|
553
557
|
RouteService_class_private_field_set(this, _pluginDriver, pluginDriver);
|
|
@@ -698,7 +702,7 @@ async function flattenMdxContent(content, basePath, alias) {
|
|
|
698
702
|
}
|
|
699
703
|
const importNodes = ast.children.filter((node)=>'mdxjsEsm' === node.type).flatMap((node)=>{
|
|
700
704
|
var _node_data_estree, _node_data;
|
|
701
|
-
return (null
|
|
705
|
+
return (null == (_node_data = node.data) ? void 0 : null == (_node_data_estree = _node_data.estree) ? void 0 : _node_data_estree.body) || [];
|
|
702
706
|
}).filter((node)=>'ImportDeclaration' === node.type);
|
|
703
707
|
for (const importNode of importNodes){
|
|
704
708
|
const id = importNode.specifiers[0].local.name;
|
|
@@ -906,7 +910,7 @@ function normalizeThemeConfig(docConfig, pages = []) {
|
|
|
906
910
|
};
|
|
907
911
|
const getI18nText = (key = '', currentLang = '')=>{
|
|
908
912
|
var _i18nTextData_key;
|
|
909
|
-
const text = null
|
|
913
|
+
const text = null == (_i18nTextData_key = i18nTextData[key]) ? void 0 : _i18nTextData_key[currentLang];
|
|
910
914
|
return text || key;
|
|
911
915
|
};
|
|
912
916
|
const normalizeSidebar = (sidebar, currentLang = '')=>{
|
|
@@ -980,7 +984,7 @@ function normalizeThemeConfig(docConfig, pages = []) {
|
|
|
980
984
|
};
|
|
981
985
|
if (locales.length) themeConfig.locales = locales.map(({ lang: currentLang, label })=>{
|
|
982
986
|
var _themeConfig_locales;
|
|
983
|
-
const localeInThemeConfig = null
|
|
987
|
+
const localeInThemeConfig = null == (_themeConfig_locales = themeConfig.locales) ? void 0 : _themeConfig_locales.find((locale)=>locale.lang === currentLang);
|
|
984
988
|
return {
|
|
985
989
|
lang: currentLang,
|
|
986
990
|
label,
|
|
@@ -1019,7 +1023,7 @@ async function siteDataVMPlugin(context) {
|
|
|
1019
1023
|
const versioned = userConfig.search && 'remote' !== userConfig.search.mode && userConfig.search.versioned;
|
|
1020
1024
|
const groupedPages = (0, __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__.groupBy)(pages, (page)=>{
|
|
1021
1025
|
var _page_frontmatter;
|
|
1022
|
-
if ((null
|
|
1026
|
+
if ((null == (_page_frontmatter = page.frontmatter) ? void 0 : _page_frontmatter.pageType) === 'home') return 'noindex';
|
|
1023
1027
|
const version = versioned ? page.version : '';
|
|
1024
1028
|
const lang = page.lang || '';
|
|
1025
1029
|
return `${version}###${lang}`;
|
|
@@ -1047,13 +1051,13 @@ async function siteDataVMPlugin(context) {
|
|
|
1047
1051
|
themeConfig: normalizeThemeConfig(userConfig, pages),
|
|
1048
1052
|
base: (null == userConfig ? void 0 : userConfig.base) || '/',
|
|
1049
1053
|
lang: (null == userConfig ? void 0 : userConfig.lang) || '',
|
|
1050
|
-
locales: (null == userConfig ? void 0 : userConfig.locales) || (null
|
|
1054
|
+
locales: (null == userConfig ? void 0 : userConfig.locales) || (null == (_userConfig_themeConfig = userConfig.themeConfig) ? void 0 : _userConfig_themeConfig.locales) || [],
|
|
1051
1055
|
logo: (null == userConfig ? void 0 : userConfig.logo) || '',
|
|
1052
1056
|
logoText: (null == userConfig ? void 0 : userConfig.logoText) || '',
|
|
1053
|
-
ssg: Boolean(null == userConfig ? void 0 : userConfig.ssg) ?? true,
|
|
1057
|
+
ssg: Boolean((null == userConfig ? void 0 : userConfig.ssg) ?? true),
|
|
1054
1058
|
multiVersion: {
|
|
1055
|
-
default: (null == userConfig ? void 0 : null
|
|
1056
|
-
versions: (null == userConfig ? void 0 : null
|
|
1059
|
+
default: (null == userConfig ? void 0 : null == (_userConfig_multiVersion = userConfig.multiVersion) ? void 0 : _userConfig_multiVersion.default) || '',
|
|
1060
|
+
versions: (null == userConfig ? void 0 : null == (_userConfig_multiVersion1 = userConfig.multiVersion) ? void 0 : _userConfig_multiVersion1.versions) || []
|
|
1057
1061
|
},
|
|
1058
1062
|
search: tempSearchObj ?? {
|
|
1059
1063
|
mode: 'local'
|
|
@@ -1066,13 +1070,13 @@ async function siteDataVMPlugin(context) {
|
|
|
1066
1070
|
};
|
|
1067
1071
|
}),
|
|
1068
1072
|
markdown: {
|
|
1069
|
-
showLineNumbers: (null == userConfig ? void 0 : null
|
|
1070
|
-
defaultWrapCode: (null == userConfig ? void 0 : null
|
|
1071
|
-
codeHighlighter: (null == userConfig ? void 0 : null
|
|
1073
|
+
showLineNumbers: (null == userConfig ? void 0 : null == (_userConfig_markdown = userConfig.markdown) ? void 0 : _userConfig_markdown.showLineNumbers) ?? false,
|
|
1074
|
+
defaultWrapCode: (null == userConfig ? void 0 : null == (_userConfig_markdown1 = userConfig.markdown) ? void 0 : _userConfig_markdown1.defaultWrapCode) ?? false,
|
|
1075
|
+
codeHighlighter: (null == userConfig ? void 0 : null == (_userConfig_markdown2 = userConfig.markdown) ? void 0 : _userConfig_markdown2.codeHighlighter) || 'prism'
|
|
1072
1076
|
}
|
|
1073
1077
|
};
|
|
1074
1078
|
const { highlightLanguages: defaultLanguages = [] } = config.markdown || {};
|
|
1075
|
-
if (Array.isArray(null
|
|
1079
|
+
if (Array.isArray(null == (_siteData_pages_ = siteData.pages[0]) ? void 0 : _siteData_pages_.extraHighlightLanguages)) siteData.pages[0].extraHighlightLanguages.forEach((lang)=>highlightLanguages.add(lang));
|
|
1076
1080
|
const aliases = handleHighlightLanguages(highlightLanguages, defaultLanguages);
|
|
1077
1081
|
const sortedAliases = Object.fromEntries(Object.entries(aliases).sort());
|
|
1078
1082
|
const sortedHighlightLanguages = Array.from(highlightLanguages).sort();
|
|
@@ -1154,7 +1158,7 @@ async function writeSearchIndex(config) {
|
|
|
1154
1158
|
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].rename(source, target);
|
|
1155
1159
|
scanning = true;
|
|
1156
1160
|
}
|
|
1157
|
-
if (isProduction() && (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isSCM)() && (null == config ? void 0 : null
|
|
1161
|
+
if (isProduction() && (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isSCM)() && (null == config ? void 0 : null == (_config_search = config.search) ? void 0 : _config_search.mode) === 'remote') {
|
|
1158
1162
|
const { apiUrl, indexName } = config.search;
|
|
1159
1163
|
try {
|
|
1160
1164
|
await fetch(`${apiUrl}?index=${indexName}`, {
|
|
@@ -1174,7 +1178,7 @@ function serveSearchIndexMiddleware(config) {
|
|
|
1174
1178
|
return (req, res, next)=>{
|
|
1175
1179
|
var _req_url;
|
|
1176
1180
|
const searchIndexRequestMatch = `/${__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.SEARCH_INDEX_NAME}.`;
|
|
1177
|
-
if (null
|
|
1181
|
+
if (null == (_req_url = req.url) ? void 0 : _req_url.includes(searchIndexRequestMatch)) {
|
|
1178
1182
|
res.setHeader('Content-Type', 'application/json');
|
|
1179
1183
|
const outDir = (null == config ? void 0 : config.outDir) ?? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(process.cwd(), OUTPUT_DIR);
|
|
1180
1184
|
const searchIndexFile = req.url.split('/').pop();
|
|
@@ -1184,6 +1188,170 @@ function serveSearchIndexMiddleware(config) {
|
|
|
1184
1188
|
} else null == next || next();
|
|
1185
1189
|
};
|
|
1186
1190
|
}
|
|
1191
|
+
async function renderFrontmatterHead(route) {
|
|
1192
|
+
if (!isRouteMeta(route)) return '';
|
|
1193
|
+
const content = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(route.absolutePath, {
|
|
1194
|
+
encoding: 'utf-8'
|
|
1195
|
+
});
|
|
1196
|
+
const { frontmatter: { head } } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.loadFrontMatter)(content, route.absolutePath, '', true);
|
|
1197
|
+
if (!head || 0 === head.length) return '';
|
|
1198
|
+
return head.map(([tag, attrs])=>`<${tag} ${renderAttrs(attrs)}>`).join('');
|
|
1199
|
+
}
|
|
1200
|
+
async function renderConfigHead(config, route) {
|
|
1201
|
+
if (!isRouteMeta(route)) return '';
|
|
1202
|
+
if (!config.head || 0 === config.head.length) return '';
|
|
1203
|
+
return config.head.map((head)=>{
|
|
1204
|
+
if ('string' == typeof head) return head;
|
|
1205
|
+
if ('function' == typeof head) {
|
|
1206
|
+
const resultHead = head(route);
|
|
1207
|
+
if (!resultHead) return '';
|
|
1208
|
+
if ('string' == typeof resultHead) return resultHead;
|
|
1209
|
+
return `<${resultHead[0]} ${renderAttrs(resultHead[1])}>`;
|
|
1210
|
+
}
|
|
1211
|
+
return `<${head[0]} ${renderAttrs(head[1])}>`;
|
|
1212
|
+
}).join('');
|
|
1213
|
+
}
|
|
1214
|
+
function renderAttrs(attrs) {
|
|
1215
|
+
return Object.entries(attrs).map(([key, value])=>{
|
|
1216
|
+
if ('boolean' == typeof value) return key;
|
|
1217
|
+
if ('string' == typeof value || 'number' == typeof value) return `${key}="${value}"`;
|
|
1218
|
+
throw new Error(`Invalid value for attribute ${key}:${JSON.stringify(value)}`);
|
|
1219
|
+
}).join('');
|
|
1220
|
+
}
|
|
1221
|
+
function isRouteMeta(route) {
|
|
1222
|
+
return !!route && 'object' == typeof route && 'routePath' in route && 'absolutePath' in route;
|
|
1223
|
+
}
|
|
1224
|
+
async function renderPages(routeService, config, pluginDriver, ssrBundlePath, htmlTemplate, emitAsset) {
|
|
1225
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info('Rendering pages...');
|
|
1226
|
+
const startTime = Date.now();
|
|
1227
|
+
let render;
|
|
1228
|
+
try {
|
|
1229
|
+
const { default: ssrExports } = await import((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(ssrBundlePath).toString());
|
|
1230
|
+
({ render } = ssrExports);
|
|
1231
|
+
} catch (e) {
|
|
1232
|
+
if (e instanceof Error) {
|
|
1233
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(`Failed to load SSG bundle: ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(ssrBundlePath)}: ${e.message}`);
|
|
1234
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.debug(e);
|
|
1235
|
+
hintSSGFailed();
|
|
1236
|
+
}
|
|
1237
|
+
throw e;
|
|
1238
|
+
}
|
|
1239
|
+
try {
|
|
1240
|
+
const routes = routeService.getRoutes();
|
|
1241
|
+
const base = (null == config ? void 0 : config.base) ?? '';
|
|
1242
|
+
const additionalRoutes = (await pluginDriver.addSSGRoutes()).map((route)=>({
|
|
1243
|
+
routePath: (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.withBase)(route.path, base)
|
|
1244
|
+
}));
|
|
1245
|
+
const allRoutes = [
|
|
1246
|
+
...routes,
|
|
1247
|
+
...additionalRoutes
|
|
1248
|
+
];
|
|
1249
|
+
const is404RouteInRoutes = allRoutes.some((route)=>'/404' === route.routePath);
|
|
1250
|
+
if (!is404RouteInRoutes) allRoutes.push({
|
|
1251
|
+
routePath: '/404'
|
|
1252
|
+
});
|
|
1253
|
+
await Promise.all(allRoutes.filter((route)=>!route.routePath.includes(':')).map(async (route)=>{
|
|
1254
|
+
const helmetContext = new __WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__["default"].HelmetData({});
|
|
1255
|
+
const { routePath } = route;
|
|
1256
|
+
let appHtml = '';
|
|
1257
|
+
if (render) try {
|
|
1258
|
+
({ appHtml } = await render(routePath, helmetContext.context));
|
|
1259
|
+
} catch (e) {
|
|
1260
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(`Page "${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(routePath)}" SSG rendering failed.`);
|
|
1261
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.debug(e);
|
|
1262
|
+
throw e;
|
|
1263
|
+
}
|
|
1264
|
+
const { helmet } = helmetContext.context;
|
|
1265
|
+
let html = htmlTemplate.replace(/<title>(.*?)<\/title>/gi, '').replace(APP_HTML_MARKER, ()=>appHtml).replace(META_GENERATOR, ()=>`<meta name="generator" content="Rspress v${RSPRESS_VERSION}">`).replace(HEAD_MARKER, [
|
|
1266
|
+
await renderConfigHead(config, route),
|
|
1267
|
+
helmet.title.toString(),
|
|
1268
|
+
helmet.meta.toString(),
|
|
1269
|
+
helmet.link.toString(),
|
|
1270
|
+
helmet.style.toString(),
|
|
1271
|
+
helmet.script.toString(),
|
|
1272
|
+
await renderFrontmatterHead(route)
|
|
1273
|
+
].join(''));
|
|
1274
|
+
if (helmet.htmlAttributes) {
|
|
1275
|
+
var _helmet_htmlAttributes;
|
|
1276
|
+
html = html.replace(HTML_START_TAG, `${HTML_START_TAG} ${null == (_helmet_htmlAttributes = helmet.htmlAttributes) ? void 0 : _helmet_htmlAttributes.toString()}`);
|
|
1277
|
+
}
|
|
1278
|
+
if (helmet.bodyAttributes) {
|
|
1279
|
+
var _helmet_bodyAttributes;
|
|
1280
|
+
html = html.replace(BODY_START_TAG, `${BODY_START_TAG} ${null == (_helmet_bodyAttributes = helmet.bodyAttributes) ? void 0 : _helmet_bodyAttributes.toString()}`);
|
|
1281
|
+
}
|
|
1282
|
+
const normalizeHtmlFilePath = (path)=>{
|
|
1283
|
+
const normalizedBase = `${(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.normalizeSlash)((null == config ? void 0 : config.base) || '/')}/`;
|
|
1284
|
+
if (path.endsWith('/')) return `${path}index.html`.replace(normalizedBase, '');
|
|
1285
|
+
return `${path}.html`.replace(normalizedBase, '');
|
|
1286
|
+
};
|
|
1287
|
+
const fileName = normalizeHtmlFilePath(routePath);
|
|
1288
|
+
emitAsset(fileName, html);
|
|
1289
|
+
}));
|
|
1290
|
+
const totalTime = Date.now() - startTime;
|
|
1291
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.success(`Pages rendered in ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(totalTime)} ms.`);
|
|
1292
|
+
} catch (e) {
|
|
1293
|
+
if (e instanceof Error) {
|
|
1294
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(`Pages render error: ${e.message}`);
|
|
1295
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.debug(e);
|
|
1296
|
+
hintSSGFailed();
|
|
1297
|
+
}
|
|
1298
|
+
throw e;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
const NODE_SSR_BUNDLE_NAME = 'rspress-ssg-entry.cjs';
|
|
1302
|
+
const rsbuildPluginSSG = ({ routeService, config, pluginDriver })=>({
|
|
1303
|
+
name: 'rspress-inner-rsbuild-plugin-ssg',
|
|
1304
|
+
async setup (api) {
|
|
1305
|
+
api.onBeforeBuild(()=>{
|
|
1306
|
+
let htmlTemplate = '';
|
|
1307
|
+
const indexHtmlEmittedInWeb = new Promise((resolve, reject)=>{
|
|
1308
|
+
api.processAssets({
|
|
1309
|
+
stage: 'report',
|
|
1310
|
+
targets: [
|
|
1311
|
+
'web'
|
|
1312
|
+
]
|
|
1313
|
+
}, ({ assets, compilation })=>{
|
|
1314
|
+
for (const [assetName, assetSource] of Object.entries(assets))if ('index.html' === assetName) {
|
|
1315
|
+
htmlTemplate = assetSource.source().toString();
|
|
1316
|
+
compilation.deleteAsset(assetName);
|
|
1317
|
+
resolve();
|
|
1318
|
+
break;
|
|
1319
|
+
}
|
|
1320
|
+
reject();
|
|
1321
|
+
});
|
|
1322
|
+
}).catch(()=>{
|
|
1323
|
+
const message = 'SSG requires an `index.html` as entry, but this file is not emitted successfully in the web target.';
|
|
1324
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(message);
|
|
1325
|
+
const error = new Error(message);
|
|
1326
|
+
throw error;
|
|
1327
|
+
});
|
|
1328
|
+
api.processAssets({
|
|
1329
|
+
stage: 'optimize-transfer',
|
|
1330
|
+
targets: [
|
|
1331
|
+
'node'
|
|
1332
|
+
]
|
|
1333
|
+
}, async ({ assets, compilation, environment, compiler })=>{
|
|
1334
|
+
const distPath = environment.distPath;
|
|
1335
|
+
await (0, __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__.mkdir)(distPath, {
|
|
1336
|
+
recursive: true
|
|
1337
|
+
});
|
|
1338
|
+
let mainCjsAbsolutePath = '';
|
|
1339
|
+
for (const [assetName, assetSource] of Object.entries(assets))if (assetName.includes(NODE_SSR_BUNDLE_NAME)) {
|
|
1340
|
+
mainCjsAbsolutePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(distPath, assetName);
|
|
1341
|
+
await (0, __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__.writeFile)(mainCjsAbsolutePath, assetSource.source().toString());
|
|
1342
|
+
compilation.deleteAsset(assetName);
|
|
1343
|
+
break;
|
|
1344
|
+
}
|
|
1345
|
+
const emitAsset = (assetName, content)=>{
|
|
1346
|
+
compilation.emitAsset(assetName, new compiler.webpack.sources.RawSource(content));
|
|
1347
|
+
};
|
|
1348
|
+
await indexHtmlEmittedInWeb;
|
|
1349
|
+
await renderPages(routeService, config, pluginDriver, mainCjsAbsolutePath, htmlTemplate, emitAsset);
|
|
1350
|
+
if (!(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isDebugMode)()) await (0, __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__.rm)(mainCjsAbsolutePath);
|
|
1351
|
+
});
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
});
|
|
1187
1355
|
const { CachedInputFileSystem: detectReactVersion_CachedInputFileSystem, ResolverFactory: detectReactVersion_ResolverFactory } = __WEBPACK_EXTERNAL_MODULE_enhanced_resolve_bf4706da__["default"];
|
|
1188
1356
|
const DEFAULT_REACT_VERSION = 18;
|
|
1189
1357
|
async function detectReactVersion() {
|
|
@@ -1192,7 +1360,7 @@ async function detectReactVersion() {
|
|
|
1192
1360
|
if (await pathExists(reactPath)) {
|
|
1193
1361
|
var _reactPkg_version;
|
|
1194
1362
|
const reactPkg = await readJson(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(reactPath, 'package.json'));
|
|
1195
|
-
const version = Number(null
|
|
1363
|
+
const version = Number(null == (_reactPkg_version = reactPkg.version) ? void 0 : _reactPkg_version.split('.')[0]);
|
|
1196
1364
|
return version;
|
|
1197
1365
|
}
|
|
1198
1366
|
return DEFAULT_REACT_VERSION;
|
|
@@ -1281,18 +1449,16 @@ function getSocialIcons(socialLinks = []) {
|
|
|
1281
1449
|
}
|
|
1282
1450
|
function isPluginIncluded(config, pluginName) {
|
|
1283
1451
|
var _config_builderPlugins, _config_builderConfig_plugins, _config_builderConfig;
|
|
1284
|
-
return Boolean((null
|
|
1452
|
+
return Boolean((null == (_config_builderPlugins = config.builderPlugins) ? void 0 : _config_builderPlugins.some((plugin)=>plugin.name === pluginName)) || (null == (_config_builderConfig = config.builderConfig) ? void 0 : null == (_config_builderConfig_plugins = _config_builderConfig.plugins) ? void 0 : _config_builderConfig_plugins.some((plugin)=>plugin && plugin.name === pluginName)));
|
|
1285
1453
|
}
|
|
1286
1454
|
async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, runtimeTempDir) {
|
|
1287
1455
|
var _config_builderConfig_output, _config_builderConfig, _config_themeConfig, _config_themeConfig1;
|
|
1288
1456
|
const cwd = process.cwd();
|
|
1289
1457
|
const CUSTOM_THEME_DIR = (null == config ? void 0 : config.themeDir) ?? __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), 'theme');
|
|
1290
|
-
const
|
|
1291
|
-
const csrOutDir = baseOutDir;
|
|
1292
|
-
const ssrOutDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(baseOutDir, 'ssr');
|
|
1458
|
+
const outDir = (null == config ? void 0 : config.outDir) ?? OUTPUT_DIR;
|
|
1293
1459
|
const DEFAULT_THEME = require.resolve('@rspress/theme-default');
|
|
1294
1460
|
const base = (null == config ? void 0 : config.base) ?? '';
|
|
1295
|
-
const assetPrefix = isProduction() ? (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.removeTrailingSlash)((null == config ? void 0 : null
|
|
1461
|
+
const assetPrefix = isProduction() ? (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.removeTrailingSlash)((null == config ? void 0 : null == (_config_builderConfig = config.builderConfig) ? void 0 : null == (_config_builderConfig_output = _config_builderConfig.output) ? void 0 : _config_builderConfig_output.assetPrefix) ?? base) : '';
|
|
1296
1462
|
const reactVersion = await detectReactVersion();
|
|
1297
1463
|
const normalizeIcon = (icon)=>{
|
|
1298
1464
|
if (!icon) return;
|
|
@@ -1322,7 +1488,14 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1322
1488
|
virtualModules: {
|
|
1323
1489
|
...i18nVMPlugin(context)
|
|
1324
1490
|
}
|
|
1325
|
-
})
|
|
1491
|
+
}),
|
|
1492
|
+
...enableSSG ? [
|
|
1493
|
+
rsbuildPluginSSG({
|
|
1494
|
+
routeService,
|
|
1495
|
+
config,
|
|
1496
|
+
pluginDriver
|
|
1497
|
+
})
|
|
1498
|
+
] : []
|
|
1326
1499
|
],
|
|
1327
1500
|
server: {
|
|
1328
1501
|
port: !isProduction() && process.env.PORT ? Number(process.env.PORT) : void 0,
|
|
@@ -1345,9 +1518,9 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1345
1518
|
html: {
|
|
1346
1519
|
title: (null == config ? void 0 : config.title) ?? DEFAULT_TITLE,
|
|
1347
1520
|
favicon: normalizeIcon(null == config ? void 0 : config.icon),
|
|
1348
|
-
template:
|
|
1521
|
+
template: TEMPLATE_PATH,
|
|
1349
1522
|
tags: [
|
|
1350
|
-
(null
|
|
1523
|
+
(null == (_config_themeConfig = config.themeConfig) ? void 0 : _config_themeConfig.darkMode) !== false ? {
|
|
1351
1524
|
tag: "script",
|
|
1352
1525
|
children: inlineThemeScript,
|
|
1353
1526
|
append: false
|
|
@@ -1357,7 +1530,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1357
1530
|
output: {
|
|
1358
1531
|
assetPrefix,
|
|
1359
1532
|
distPath: {
|
|
1360
|
-
root:
|
|
1533
|
+
root: outDir
|
|
1361
1534
|
}
|
|
1362
1535
|
},
|
|
1363
1536
|
resolve: {
|
|
@@ -1382,7 +1555,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1382
1555
|
define: {
|
|
1383
1556
|
'process.env.__REACT_GTE_18__': JSON.stringify(reactVersion >= 18),
|
|
1384
1557
|
'process.env.TEST': JSON.stringify(process.env.TEST),
|
|
1385
|
-
'process.env.RSPRESS_SOCIAL_ICONS': JSON.stringify(getSocialIcons(null
|
|
1558
|
+
'process.env.RSPRESS_SOCIAL_ICONS': JSON.stringify(getSocialIcons(null == (_config_themeConfig1 = config.themeConfig) ? void 0 : _config_themeConfig1.socialLinks))
|
|
1386
1559
|
}
|
|
1387
1560
|
},
|
|
1388
1561
|
performance: {
|
|
@@ -1406,7 +1579,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1406
1579
|
const isServer = 'node' === target;
|
|
1407
1580
|
const jsModuleRule = chain.module.rule(CHAIN_ID.RULE.JS);
|
|
1408
1581
|
const swcLoaderOptions = jsModuleRule.use(CHAIN_ID.USE.SWC).get('options');
|
|
1409
|
-
const checkDeadLinks = ((null == config ? void 0 : null
|
|
1582
|
+
const checkDeadLinks = ((null == config ? void 0 : null == (_config_markdown = config.markdown) ? void 0 : _config_markdown.checkDeadLinks) && !isServer) ?? false;
|
|
1410
1583
|
chain.module.rule('MDX').type("javascript/auto").test(__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP).resolve.merge({
|
|
1411
1584
|
conditionNames: jsModuleRule.resolve.conditionNames.values(),
|
|
1412
1585
|
mainFields: jsModuleRule.resolve.mainFields.values()
|
|
@@ -1429,7 +1602,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1429
1602
|
chain.module.rule('css-virtual-module').test(/\.rspress[\\/]runtime[\\/]virtual-global-styles/).merge({
|
|
1430
1603
|
sideEffects: true
|
|
1431
1604
|
});
|
|
1432
|
-
if (isServer) chain.output.filename(
|
|
1605
|
+
if (isServer) chain.output.filename(NODE_SSR_BUNDLE_NAME);
|
|
1433
1606
|
const enableIncremental = !isProduction() && !process.env.DISABLE_RSPACK_INCREMENTAL;
|
|
1434
1607
|
if (enableIncremental) chain.merge({
|
|
1435
1608
|
experiments: {
|
|
@@ -1448,7 +1621,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1448
1621
|
},
|
|
1449
1622
|
source: {
|
|
1450
1623
|
entry: {
|
|
1451
|
-
index:
|
|
1624
|
+
index: enableSSG && isProduction() ? SSR_CLIENT_ENTRY : CSR_CLIENT_ENTRY
|
|
1452
1625
|
},
|
|
1453
1626
|
define: {
|
|
1454
1627
|
'process.env.__SSR__': JSON.stringify(false)
|
|
@@ -1457,7 +1630,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1457
1630
|
output: {
|
|
1458
1631
|
target: 'web',
|
|
1459
1632
|
distPath: {
|
|
1460
|
-
root:
|
|
1633
|
+
root: outDir
|
|
1461
1634
|
}
|
|
1462
1635
|
}
|
|
1463
1636
|
},
|
|
@@ -1469,23 +1642,29 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1469
1642
|
__VIRTUAL_ROUTES__: 'virtual-routes-ssr'
|
|
1470
1643
|
}
|
|
1471
1644
|
},
|
|
1645
|
+
tools: {
|
|
1646
|
+
rspack: {
|
|
1647
|
+
output: {
|
|
1648
|
+
asyncChunks: false
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
},
|
|
1472
1652
|
source: {
|
|
1473
1653
|
entry: {
|
|
1474
|
-
index:
|
|
1654
|
+
index: SSR_SERVER_ENTRY
|
|
1475
1655
|
},
|
|
1476
1656
|
define: {
|
|
1477
1657
|
'process.env.__SSR__': JSON.stringify(true)
|
|
1478
1658
|
}
|
|
1479
1659
|
},
|
|
1480
1660
|
performance: {
|
|
1481
|
-
printFileSize:
|
|
1661
|
+
printFileSize: {
|
|
1662
|
+
compressed: true
|
|
1663
|
+
}
|
|
1482
1664
|
},
|
|
1483
1665
|
output: {
|
|
1484
1666
|
emitAssets: false,
|
|
1485
1667
|
target: 'node',
|
|
1486
|
-
distPath: {
|
|
1487
|
-
root: ssrOutDir
|
|
1488
|
-
},
|
|
1489
1668
|
minify: false
|
|
1490
1669
|
}
|
|
1491
1670
|
}
|
|
@@ -1512,7 +1691,7 @@ async function initRsbuild(rootDir, config, pluginDriver, enableSSG, extraRsbuil
|
|
|
1512
1691
|
const { createRsbuild, mergeRsbuildConfig } = await import("@rsbuild/core");
|
|
1513
1692
|
const internalRsbuildConfig = await createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, runtimeTempDir);
|
|
1514
1693
|
const rsbuild = await createRsbuild({
|
|
1515
|
-
rsbuildConfig: mergeRsbuildConfig(internalRsbuildConfig, ...(null
|
|
1694
|
+
rsbuildConfig: mergeRsbuildConfig(internalRsbuildConfig, ...(null == (_pluginDriver_getPlugins = pluginDriver.getPlugins()) ? void 0 : _pluginDriver_getPlugins.map((plugin)=>plugin.builderConfig ?? {})) || [], (null == config ? void 0 : config.builderConfig) || {}, extraRsbuildConfig || {})
|
|
1516
1695
|
});
|
|
1517
1696
|
rsbuild.addPlugins(builderPlugins);
|
|
1518
1697
|
return rsbuild;
|
|
@@ -1565,15 +1744,12 @@ async function checkLanguageParity(config) {
|
|
|
1565
1744
|
if (!(null == config ? void 0 : config.languageParity) || false === config.languageParity.enabled) return;
|
|
1566
1745
|
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info('Checking language parity...');
|
|
1567
1746
|
const contentPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(config.root);
|
|
1568
|
-
const includedDirs = (null
|
|
1747
|
+
const includedDirs = (null == (_config_languageParity_include = config.languageParity.include) ? void 0 : _config_languageParity_include.length) ? config.languageParity.include : [
|
|
1569
1748
|
''
|
|
1570
1749
|
];
|
|
1571
1750
|
const excludedDirs = config.languageParity.exclude ?? [];
|
|
1572
|
-
const supportedLanguages = (null
|
|
1573
|
-
if (!supportedLanguages.length)
|
|
1574
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error('No supported languages found in the configuration.');
|
|
1575
|
-
return;
|
|
1576
|
-
}
|
|
1751
|
+
const supportedLanguages = (null == (_this = config.locales ?? (null == (_config_themeConfig = config.themeConfig) ? void 0 : _config_themeConfig.locales)) ? void 0 : _this.map((locale)=>locale.lang)) || [];
|
|
1752
|
+
if (!supportedLanguages.length) return void __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error('No supported languages found in the configuration.');
|
|
1577
1753
|
const missingLanguagesFile = [];
|
|
1578
1754
|
try {
|
|
1579
1755
|
for (const includedDir of includedDirs){
|
|
@@ -1603,11 +1779,11 @@ async function dev(options) {
|
|
|
1603
1779
|
const modifiedConfig = await pluginDriver.modifyConfig();
|
|
1604
1780
|
try {
|
|
1605
1781
|
await pluginDriver.beforeBuild();
|
|
1606
|
-
const
|
|
1607
|
-
|
|
1782
|
+
const rsbuild = await initRsbuild(docDirectory, modifiedConfig, pluginDriver, false, extraBuilderConfig);
|
|
1783
|
+
rsbuild.onDevCompileDone(async ()=>{
|
|
1608
1784
|
await pluginDriver.afterBuild();
|
|
1609
1785
|
});
|
|
1610
|
-
const { server } = await
|
|
1786
|
+
const { server } = await rsbuild.startDevServer({
|
|
1611
1787
|
getPortSilently: true
|
|
1612
1788
|
});
|
|
1613
1789
|
return server;
|
|
@@ -1616,40 +1792,6 @@ async function dev(options) {
|
|
|
1616
1792
|
await checkLanguageParity(modifiedConfig);
|
|
1617
1793
|
}
|
|
1618
1794
|
}
|
|
1619
|
-
var package_namespaceObject = JSON.parse('{"i8":"2.0.0-alpha.10"}');
|
|
1620
|
-
async function renderFrontmatterHead(route) {
|
|
1621
|
-
if (!isRouteMeta(route)) return '';
|
|
1622
|
-
const content = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(route.absolutePath, {
|
|
1623
|
-
encoding: 'utf-8'
|
|
1624
|
-
});
|
|
1625
|
-
const { frontmatter: { head } } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.loadFrontMatter)(content, route.absolutePath, '', true);
|
|
1626
|
-
if (!head || 0 === head.length) return '';
|
|
1627
|
-
return head.map(([tag, attrs])=>`<${tag} ${renderAttrs(attrs)}>`).join('');
|
|
1628
|
-
}
|
|
1629
|
-
async function renderConfigHead(config, route) {
|
|
1630
|
-
if (!isRouteMeta(route)) return '';
|
|
1631
|
-
if (!config.head || 0 === config.head.length) return '';
|
|
1632
|
-
return config.head.map((head)=>{
|
|
1633
|
-
if ('string' == typeof head) return head;
|
|
1634
|
-
if ('function' == typeof head) {
|
|
1635
|
-
const resultHead = head(route);
|
|
1636
|
-
if (!resultHead) return '';
|
|
1637
|
-
if ('string' == typeof resultHead) return resultHead;
|
|
1638
|
-
return `<${resultHead[0]} ${renderAttrs(resultHead[1])}>`;
|
|
1639
|
-
}
|
|
1640
|
-
return `<${head[0]} ${renderAttrs(head[1])}>`;
|
|
1641
|
-
}).join('');
|
|
1642
|
-
}
|
|
1643
|
-
function renderAttrs(attrs) {
|
|
1644
|
-
return Object.entries(attrs).map(([key, value])=>{
|
|
1645
|
-
if ('boolean' == typeof value) return key;
|
|
1646
|
-
if ('string' == typeof value || 'number' == typeof value) return `${key}="${value}"`;
|
|
1647
|
-
throw new Error(`Invalid value for attribute ${key}:${JSON.stringify(value)}`);
|
|
1648
|
-
}).join('');
|
|
1649
|
-
}
|
|
1650
|
-
function isRouteMeta(route) {
|
|
1651
|
-
return !!route && 'object' == typeof route && 'routePath' in route && 'absolutePath' in route;
|
|
1652
|
-
}
|
|
1653
1795
|
async function bundle(docDirectory, config, pluginDriver, enableSSG) {
|
|
1654
1796
|
try {
|
|
1655
1797
|
const rsbuild = await initRsbuild(docDirectory, config, pluginDriver, enableSSG);
|
|
@@ -1665,100 +1807,16 @@ function emptyDir(path) {
|
|
|
1665
1807
|
recursive: true
|
|
1666
1808
|
});
|
|
1667
1809
|
}
|
|
1668
|
-
async function renderPages(appDirectory, config, pluginDriver) {
|
|
1669
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info('Rendering pages...');
|
|
1670
|
-
const startTime = Date.now();
|
|
1671
|
-
const outputPath = (null == config ? void 0 : config.outDir) ?? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(appDirectory, OUTPUT_DIR);
|
|
1672
|
-
const ssrBundlePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, 'ssr', 'main.cjs');
|
|
1673
|
-
let render;
|
|
1674
|
-
try {
|
|
1675
|
-
const { default: ssrExports } = await import((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(ssrBundlePath).toString());
|
|
1676
|
-
({ render } = ssrExports);
|
|
1677
|
-
} catch (e) {
|
|
1678
|
-
if (e instanceof Error) {
|
|
1679
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(`Failed to load SSG bundle: ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(ssrBundlePath)}: ${e.message}`);
|
|
1680
|
-
hintSSGFailed();
|
|
1681
|
-
}
|
|
1682
|
-
throw e;
|
|
1683
|
-
}
|
|
1684
|
-
try {
|
|
1685
|
-
const routes = init_routeService.getRoutes();
|
|
1686
|
-
const base = (null == config ? void 0 : config.base) ?? '';
|
|
1687
|
-
const htmlTemplatePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, 'index.html');
|
|
1688
|
-
const htmlTemplate = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(htmlTemplatePath, 'utf-8');
|
|
1689
|
-
const additionalRoutes = (await pluginDriver.addSSGRoutes()).map((route)=>({
|
|
1690
|
-
routePath: (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.withBase)(route.path, base)
|
|
1691
|
-
}));
|
|
1692
|
-
const allRoutes = [
|
|
1693
|
-
...routes,
|
|
1694
|
-
...additionalRoutes
|
|
1695
|
-
];
|
|
1696
|
-
const is404RouteInRoutes = allRoutes.some((route)=>'/404' === route.routePath);
|
|
1697
|
-
if (!is404RouteInRoutes) allRoutes.push({
|
|
1698
|
-
routePath: '/404'
|
|
1699
|
-
});
|
|
1700
|
-
await Promise.all(allRoutes.filter((route)=>!route.routePath.includes(':')).map(async (route)=>{
|
|
1701
|
-
const helmetContext = new __WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__["default"].HelmetData({});
|
|
1702
|
-
const { routePath } = route;
|
|
1703
|
-
let appHtml = '';
|
|
1704
|
-
if (render) try {
|
|
1705
|
-
({ appHtml } = await render(routePath, helmetContext.context));
|
|
1706
|
-
} catch (e) {
|
|
1707
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(`Page "${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(routePath)}" SSG rendering failed.`);
|
|
1708
|
-
throw e;
|
|
1709
|
-
}
|
|
1710
|
-
const { helmet } = helmetContext.context;
|
|
1711
|
-
let html = htmlTemplate.replace(/<title>(.*?)<\/title>/gi, '').replace(APP_HTML_MARKER, ()=>appHtml).replace(META_GENERATOR, ()=>`<meta name="generator" content="Rspress v${package_namespaceObject.i8}">`).replace(HEAD_MARKER, [
|
|
1712
|
-
await renderConfigHead(config, route),
|
|
1713
|
-
helmet.title.toString(),
|
|
1714
|
-
helmet.meta.toString(),
|
|
1715
|
-
helmet.link.toString(),
|
|
1716
|
-
helmet.style.toString(),
|
|
1717
|
-
helmet.script.toString(),
|
|
1718
|
-
await renderFrontmatterHead(route)
|
|
1719
|
-
].join(''));
|
|
1720
|
-
if (helmet.htmlAttributes) {
|
|
1721
|
-
var _helmet_htmlAttributes;
|
|
1722
|
-
html = html.replace(HTML_START_TAG, `${HTML_START_TAG} ${null === (_helmet_htmlAttributes = helmet.htmlAttributes) || void 0 === _helmet_htmlAttributes ? void 0 : _helmet_htmlAttributes.toString()}`);
|
|
1723
|
-
}
|
|
1724
|
-
if (helmet.bodyAttributes) {
|
|
1725
|
-
var _helmet_bodyAttributes;
|
|
1726
|
-
html = html.replace(BODY_START_TAG, `${BODY_START_TAG} ${null === (_helmet_bodyAttributes = helmet.bodyAttributes) || void 0 === _helmet_bodyAttributes ? void 0 : _helmet_bodyAttributes.toString()}`);
|
|
1727
|
-
}
|
|
1728
|
-
const normalizeHtmlFilePath = (path)=>{
|
|
1729
|
-
const normalizedBase = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.normalizeSlash)((null == config ? void 0 : config.base) || '/');
|
|
1730
|
-
if (path.endsWith('/')) return `${path}index.html`.replace(normalizedBase, '');
|
|
1731
|
-
return `${path}.html`.replace(normalizedBase, '');
|
|
1732
|
-
};
|
|
1733
|
-
const fileName = normalizeHtmlFilePath(routePath);
|
|
1734
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].mkdir((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname)(fileName)), {
|
|
1735
|
-
recursive: true
|
|
1736
|
-
});
|
|
1737
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].writeFile((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, fileName), html);
|
|
1738
|
-
}));
|
|
1739
|
-
if (!(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isDebugMode)()) await emptyDir((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, 'ssr'));
|
|
1740
|
-
await emptyDir((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, 'html'));
|
|
1741
|
-
const totalTime = Date.now() - startTime;
|
|
1742
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.success(`Pages rendered in ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(totalTime)} ms.`);
|
|
1743
|
-
} catch (e) {
|
|
1744
|
-
if (e instanceof Error) {
|
|
1745
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(`Pages render error: ${e.message}`);
|
|
1746
|
-
hintSSGFailed();
|
|
1747
|
-
}
|
|
1748
|
-
throw e;
|
|
1749
|
-
}
|
|
1750
|
-
}
|
|
1751
1810
|
async function build(options) {
|
|
1752
|
-
const { docDirectory,
|
|
1811
|
+
const { docDirectory, config } = options;
|
|
1753
1812
|
const pluginDriver = new PluginDriver(config, true);
|
|
1754
1813
|
await pluginDriver.init();
|
|
1755
1814
|
const modifiedConfig = await pluginDriver.modifyConfig();
|
|
1756
1815
|
await pluginDriver.beforeBuild();
|
|
1757
1816
|
const ssgConfig = modifiedConfig.ssg ?? true;
|
|
1758
1817
|
await emptyDir(constants_TEMP_DIR);
|
|
1759
|
-
await bundle(docDirectory, modifiedConfig, pluginDriver,
|
|
1760
|
-
if (ssgConfig)
|
|
1761
|
-
else hintSSGFalse();
|
|
1818
|
+
await bundle(docDirectory, modifiedConfig, pluginDriver, ssgConfig);
|
|
1819
|
+
if (!ssgConfig) hintSSGFalse();
|
|
1762
1820
|
await pluginDriver.afterBuild();
|
|
1763
1821
|
}
|
|
1764
1822
|
async function serve(options) {
|
|
@@ -1767,8 +1825,8 @@ async function serve(options) {
|
|
|
1767
1825
|
const envPort = process.env.PORT;
|
|
1768
1826
|
const envHost = process.env.HOST;
|
|
1769
1827
|
const { builderConfig } = config;
|
|
1770
|
-
const port = Number(envPort || userPort || (null == builderConfig ? void 0 : null
|
|
1771
|
-
const host = envHost || userHost || (null == builderConfig ? void 0 : null
|
|
1828
|
+
const port = Number(envPort || userPort || (null == builderConfig ? void 0 : null == (_builderConfig_server = builderConfig.server) ? void 0 : _builderConfig_server.port) || 4173);
|
|
1829
|
+
const host = envHost || userHost || (null == builderConfig ? void 0 : null == (_builderConfig_server1 = builderConfig.server) ? void 0 : _builderConfig_server1.host) || 'localhost';
|
|
1772
1830
|
config.builderConfig = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(builderConfig, {
|
|
1773
1831
|
server: {
|
|
1774
1832
|
port,
|
|
@@ -1778,8 +1836,8 @@ async function serve(options) {
|
|
|
1778
1836
|
const pluginDriver = new PluginDriver(config, true);
|
|
1779
1837
|
await pluginDriver.init();
|
|
1780
1838
|
const modifiedConfig = await pluginDriver.modifyConfig();
|
|
1781
|
-
const
|
|
1782
|
-
return
|
|
1839
|
+
const rsbuild = await initRsbuild(config.root, modifiedConfig, pluginDriver, false);
|
|
1840
|
+
return rsbuild.preview();
|
|
1783
1841
|
}
|
|
1784
1842
|
var __webpack_exports__mergeDocConfig = __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.mergeDocConfig;
|
|
1785
1843
|
export { build, dev, serve, __webpack_exports__mergeDocConfig as mergeDocConfig };
|
package/dist/loader.js
CHANGED
|
@@ -29,8 +29,10 @@ const importStatementRegex = /import\s+(.*?)\s+from\s+(['"])(.*?)(?:"|');?/gm;
|
|
|
29
29
|
}`.replace(/\n/g, ';').replace(/\s{2,}/g, '');
|
|
30
30
|
const dirname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(new URL(import.meta.url)));
|
|
31
31
|
const PACKAGE_ROOT = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dirname, '..');
|
|
32
|
-
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, '
|
|
33
|
-
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', '
|
|
32
|
+
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'index.html');
|
|
33
|
+
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'csrClientEntry.js');
|
|
34
|
+
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'ssrClientEntry.js');
|
|
35
|
+
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'ssrServerEntry.js');
|
|
34
36
|
const TEMP_DIR = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), 'node_modules', __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.RSPRESS_TEMP_DIR);
|
|
35
37
|
var runtimeModule_RuntimeModuleID = /*#__PURE__*/ function(RuntimeModuleID) {
|
|
36
38
|
RuntimeModuleID["GlobalStyles"] = "virtual-global-styles";
|
|
@@ -101,7 +103,7 @@ async function flattenMdxContent(content, basePath, alias) {
|
|
|
101
103
|
}
|
|
102
104
|
const importNodes = ast.children.filter((node)=>'mdxjsEsm' === node.type).flatMap((node)=>{
|
|
103
105
|
var _node_data_estree, _node_data;
|
|
104
|
-
return (null
|
|
106
|
+
return (null == (_node_data = node.data) ? void 0 : null == (_node_data_estree = _node_data.estree) ? void 0 : _node_data_estree.body) || [];
|
|
105
107
|
}).filter((node)=>'ImportDeclaration' === node.type);
|
|
106
108
|
for (const importNode of importNodes){
|
|
107
109
|
const id = importNode.specifiers[0].local.name;
|
|
@@ -143,11 +145,11 @@ function normalizePath(id) {
|
|
|
143
145
|
const rehypePluginCodeMeta = ()=>(tree)=>{
|
|
144
146
|
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'element', (node)=>{
|
|
145
147
|
var _node_children_;
|
|
146
|
-
if ('pre' === node.tagName && (null
|
|
148
|
+
if ('pre' === node.tagName && (null == (_node_children_ = node.children[0]) ? void 0 : _node_children_.type) === 'element' && 'code' === node.children[0].tagName) {
|
|
147
149
|
var _codeNode_data;
|
|
148
150
|
const codeNode = node.children[0];
|
|
149
151
|
codeNode.properties ??= {};
|
|
150
|
-
codeNode.properties.meta = null
|
|
152
|
+
codeNode.properties.meta = null == (_codeNode_data = codeNode.data) ? void 0 : _codeNode_data.meta;
|
|
151
153
|
}
|
|
152
154
|
});
|
|
153
155
|
};
|
|
@@ -157,7 +159,7 @@ const rehypeHeaderAnchor = ()=>{
|
|
|
157
159
|
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'element', (node)=>{
|
|
158
160
|
var _node_properties;
|
|
159
161
|
if (!(0, __WEBPACK_EXTERNAL_MODULE_hast_util_heading_rank_cff646ba__.headingRank)(node)) return;
|
|
160
|
-
if (!(null
|
|
162
|
+
if (!(null == (_node_properties = node.properties) ? void 0 : _node_properties.id)) {
|
|
161
163
|
const [text, customId] = collectHeaderText(node);
|
|
162
164
|
node.properties ??= {};
|
|
163
165
|
node.properties.id = customId || slugger.slug(text);
|
|
@@ -261,7 +263,7 @@ const remarkCheckDeadLinks = (checkLink)=>{
|
|
|
261
263
|
if (internalLinks.has(url)) return;
|
|
262
264
|
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
|
263
265
|
var _url_split_join;
|
|
264
|
-
const { routePath: normalizeUrl } = routeService.normalizeRoutePath(null
|
|
266
|
+
const { routePath: normalizeUrl } = routeService.normalizeRoutePath(null == (_url_split_join = url.split(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep).join('/')) ? void 0 : _url_split_join.split('#')[0]);
|
|
265
267
|
internalLinks.add(normalizeUrl);
|
|
266
268
|
}
|
|
267
269
|
});
|
|
@@ -367,19 +369,19 @@ const parseToc = (tree)=>{
|
|
|
367
369
|
const text = node.children.map((child)=>{
|
|
368
370
|
if ('link' === child.type) {
|
|
369
371
|
var _child_children;
|
|
370
|
-
return null
|
|
372
|
+
return null == (_child_children = child.children) ? void 0 : _child_children.map((item)=>item.value).join('');
|
|
371
373
|
}
|
|
372
374
|
if ('strong' === child.type) {
|
|
373
375
|
var _child_children1;
|
|
374
|
-
return `**${null
|
|
376
|
+
return `**${null == (_child_children1 = child.children) ? void 0 : _child_children1.map((item)=>item.value).join('')}**`;
|
|
375
377
|
}
|
|
376
378
|
if ('emphasis' === child.type) {
|
|
377
379
|
var _child_children2;
|
|
378
|
-
return `*${null
|
|
380
|
+
return `*${null == (_child_children2 = child.children) ? void 0 : _child_children2.map((item)=>item.value).join('')}*`;
|
|
379
381
|
}
|
|
380
382
|
if ('delete' === child.type) {
|
|
381
383
|
var _child_children3;
|
|
382
|
-
return `~~${null
|
|
384
|
+
return `~~${null == (_child_children3 = child.children) ? void 0 : _child_children3.map((item)=>item.value).join('')}~~`;
|
|
383
385
|
}
|
|
384
386
|
if ('text' === child.type) {
|
|
385
387
|
const [textPart, idPart] = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.extractTextAndId)(child.value);
|
|
@@ -417,21 +419,21 @@ const remarkPluginToc = function() {
|
|
|
417
419
|
};
|
|
418
420
|
async function createMDXOptions(docDirectory, config, checkDeadLinks, routeService, filepath, pluginDriver) {
|
|
419
421
|
var _config_route;
|
|
420
|
-
const cleanUrls = (null == config ? void 0 : null
|
|
422
|
+
const cleanUrls = (null == config ? void 0 : null == (_config_route = config.route) ? void 0 : _config_route.cleanUrls) ?? false;
|
|
421
423
|
const { remarkPlugins: remarkPluginsFromConfig = [], rehypePlugins: rehypePluginsFromConfig = [], globalComponents: globalComponentsFromConfig = [] } = (null == config ? void 0 : config.markdown) || {};
|
|
422
424
|
const rspressPlugins = pluginDriver.getPlugins();
|
|
423
425
|
const remarkPluginsFromPlugins = rspressPlugins.flatMap((plugin)=>{
|
|
424
426
|
var _plugin_markdown;
|
|
425
|
-
return (null
|
|
427
|
+
return (null == (_plugin_markdown = plugin.markdown) ? void 0 : _plugin_markdown.remarkPlugins) || [];
|
|
426
428
|
});
|
|
427
429
|
const rehypePluginsFromPlugins = rspressPlugins.flatMap((plugin)=>{
|
|
428
430
|
var _plugin_markdown;
|
|
429
|
-
return (null
|
|
431
|
+
return (null == (_plugin_markdown = plugin.markdown) ? void 0 : _plugin_markdown.rehypePlugins) || [];
|
|
430
432
|
});
|
|
431
433
|
const globalComponents = [
|
|
432
434
|
...rspressPlugins.flatMap((plugin)=>{
|
|
433
435
|
var _plugin_markdown;
|
|
434
|
-
return (null
|
|
436
|
+
return (null == (_plugin_markdown = plugin.markdown) ? void 0 : _plugin_markdown.globalComponents) || [];
|
|
435
437
|
}),
|
|
436
438
|
...globalComponentsFromConfig
|
|
437
439
|
];
|
|
@@ -521,7 +523,7 @@ async function mdxLoader(source) {
|
|
|
521
523
|
const replacedContent = applyReplaceRules(flattenContent, config.replaceRules);
|
|
522
524
|
const preprocessedContent = escapeMarkdownHeadingIds(replacedContent);
|
|
523
525
|
let enableMdxRs;
|
|
524
|
-
const mdxRs = (null == config ? void 0 : null
|
|
526
|
+
const mdxRs = (null == config ? void 0 : null == (_config_markdown = config.markdown) ? void 0 : _config_markdown.mdxRs) ?? true;
|
|
525
527
|
enableMdxRs = 'object' == typeof mdxRs ? 'function' == typeof (null == mdxRs ? void 0 : mdxRs.include) ? mdxRs.include(filepath) : true : mdxRs;
|
|
526
528
|
try {
|
|
527
529
|
let compileResult;
|
package/dist/runtime/App.js
CHANGED
|
@@ -8,11 +8,7 @@ import "virtual-global-styles";
|
|
|
8
8
|
import * as __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__ from "./initPageData.js";
|
|
9
9
|
function App({ helmetContext }) {
|
|
10
10
|
const { setData: setPageData, data } = (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.DataContext);
|
|
11
|
-
const frontmatter = data.page.frontmatter || {};
|
|
12
11
|
const { pathname, search } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useLocation)();
|
|
13
|
-
const query = new URLSearchParams(search);
|
|
14
|
-
const GLOBAL_COMPONENTS_KEY = 'globalUIComponents';
|
|
15
|
-
const hideGlobalUIComponents = false === frontmatter[GLOBAL_COMPONENTS_KEY] || "0" === query.get(GLOBAL_COMPONENTS_KEY);
|
|
16
12
|
(0, __WEBPACK_EXTERNAL_MODULE_react__.useLayoutEffect)(()=>{
|
|
17
13
|
async function refetchData() {
|
|
18
14
|
try {
|
|
@@ -27,6 +23,11 @@ function App({ helmetContext }) {
|
|
|
27
23
|
pathname,
|
|
28
24
|
setPageData
|
|
29
25
|
]);
|
|
26
|
+
if (!data) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {});
|
|
27
|
+
const frontmatter = data.page.frontmatter || {};
|
|
28
|
+
const GLOBAL_COMPONENTS_KEY = 'globalUIComponents';
|
|
29
|
+
const query = new URLSearchParams(search);
|
|
30
|
+
const hideGlobalUIComponents = false === frontmatter[GLOBAL_COMPONENTS_KEY] || "0" === query.get(GLOBAL_COMPONENTS_KEY);
|
|
30
31
|
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__.HelmetProvider, {
|
|
31
32
|
context: helmetContext,
|
|
32
33
|
children: [
|
|
@@ -3,34 +3,25 @@ import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress
|
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE__theme_75e53063__ from "@theme";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__ from "./App.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const [data, setData] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(null);
|
|
6
|
+
function ClientApp({ initialPageData = null }) {
|
|
7
|
+
const [data, setData] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(initialPageData);
|
|
9
8
|
const [theme, setTheme] = (0, __WEBPACK_EXTERNAL_MODULE__theme_75e53063__.useThemeState)();
|
|
10
|
-
(0,
|
|
11
|
-
(0,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const themeValue = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
9
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.ThemeContext.Provider, {
|
|
10
|
+
value: (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
11
|
+
theme,
|
|
12
|
+
setTheme
|
|
13
|
+
}), [
|
|
16
14
|
theme,
|
|
17
15
|
setTheme
|
|
18
|
-
|
|
19
|
-
theme,
|
|
20
|
-
setTheme
|
|
21
|
-
]);
|
|
22
|
-
const dataValue = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
23
|
-
data,
|
|
24
|
-
setData
|
|
25
|
-
}), [
|
|
26
|
-
data,
|
|
27
|
-
setData
|
|
28
|
-
]);
|
|
29
|
-
if (!data) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {});
|
|
30
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.ThemeContext.Provider, {
|
|
31
|
-
value: themeValue,
|
|
16
|
+
]),
|
|
32
17
|
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.DataContext.Provider, {
|
|
33
|
-
value:
|
|
18
|
+
value: (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
19
|
+
data,
|
|
20
|
+
setData
|
|
21
|
+
}), [
|
|
22
|
+
data,
|
|
23
|
+
setData
|
|
24
|
+
]),
|
|
34
25
|
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.BrowserRouter, {
|
|
35
26
|
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.App, {})
|
|
36
27
|
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__ from "./ClientApp.js";
|
|
3
|
+
async function renderInBrowser() {
|
|
4
|
+
const container = document.getElementById('root');
|
|
5
|
+
if (process.env.__REACT_GTE_18__) {
|
|
6
|
+
const { createRoot } = await import("react-dom/client");
|
|
7
|
+
createRoot(container).render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}));
|
|
8
|
+
} else {
|
|
9
|
+
const ReactDOM = await import("react-dom");
|
|
10
|
+
ReactDOM.render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}), container);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
renderInBrowser();
|
|
@@ -12,7 +12,7 @@ async function initPageData(routePath) {
|
|
|
12
12
|
const normalize = (p)=>p.replace(/\/$/, '').toLowerCase();
|
|
13
13
|
const extractPageInfo = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].pages.find((page)=>(0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.isEqualPath)(normalize(page.routePath), normalize(matchedRoute.path)));
|
|
14
14
|
const encodedPagePath = encodeURIComponent(pagePath);
|
|
15
|
-
const meta = (null
|
|
15
|
+
const meta = (null == (_mod_default___RSPRESS_PAGE_META = mod.default.__RSPRESS_PAGE_META) ? void 0 : _mod_default___RSPRESS_PAGE_META[encodedPagePath]) || {};
|
|
16
16
|
const { toc = [], title = '', frontmatter = {}, ...rest } = __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP.test(matchedRoute.filePath) ? meta : mod;
|
|
17
17
|
return {
|
|
18
18
|
siteData: __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"],
|
|
@@ -28,7 +28,7 @@ async function initPageData(routePath) {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
let lang = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang || '';
|
|
31
|
-
let version = (null
|
|
31
|
+
let version = (null == (_siteData_multiVersion = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].multiVersion) ? void 0 : _siteData_multiVersion.default) || '';
|
|
32
32
|
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang && 'undefined' != typeof window) {
|
|
33
33
|
const path = location.pathname.replace(__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].base, '').split('/').slice(0, 2);
|
|
34
34
|
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].locales.length) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__ from "./ClientApp.js";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__ from "./initPageData.js";
|
|
4
|
+
async function renderInBrowser() {
|
|
5
|
+
const container = document.getElementById('root');
|
|
6
|
+
const initialPageData = await (0, __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__.initPageData)(window.location.pathname);
|
|
7
|
+
if (process.env.__REACT_GTE_18__) {
|
|
8
|
+
const { hydrateRoot } = await import("react-dom/client");
|
|
9
|
+
hydrateRoot(container, /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {
|
|
10
|
+
initialPageData: initialPageData
|
|
11
|
+
}));
|
|
12
|
+
} else {
|
|
13
|
+
const ReactDOM = await import("react-dom");
|
|
14
|
+
ReactDOM.hydrate(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {
|
|
15
|
+
initialPageData: initialPageData
|
|
16
|
+
}), container);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
renderInBrowser();
|
package/dist/runtime/tsconfig.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
var __webpack_exports__compilerOptions =
|
|
3
|
-
var __webpack_exports__include =
|
|
1
|
+
var tsconfig_namespaceObject = JSON.parse('{"compilerOptions":{"rootDir":".","baseUrl":".","skipLibCheck":true,"jsx":"react-jsx","esModuleInterop":true},"include":["./**/*"]}');
|
|
2
|
+
var __webpack_exports__compilerOptions = tsconfig_namespaceObject.compilerOptions;
|
|
3
|
+
var __webpack_exports__include = tsconfig_namespaceObject.include;
|
|
4
4
|
export { __webpack_exports__compilerOptions as compilerOptions, __webpack_exports__include as include };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/core",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.12",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@mdx-js/loader": "^3.1.0",
|
|
46
46
|
"@mdx-js/mdx": "^3.1.0",
|
|
47
47
|
"@mdx-js/react": "^3.1.0",
|
|
48
|
-
"@rsbuild/core": "1.3.
|
|
48
|
+
"@rsbuild/core": "1.3.6",
|
|
49
49
|
"@rsbuild/plugin-react": "~1.1.1",
|
|
50
50
|
"@rspress/mdx-rs": "0.6.6",
|
|
51
51
|
"enhanced-resolve": "5.18.1",
|
|
@@ -70,17 +70,17 @@
|
|
|
70
70
|
"unified": "^11.0.5",
|
|
71
71
|
"unist-util-visit": "^5.0.0",
|
|
72
72
|
"unist-util-visit-children": "^3.0.0",
|
|
73
|
-
"@rspress/plugin-auto-nav-sidebar": "2.0.0-alpha.
|
|
74
|
-
"@rspress/plugin-container-syntax": "2.0.0-alpha.
|
|
75
|
-
"@rspress/plugin-last-updated": "2.0.0-alpha.
|
|
76
|
-
"@rspress/
|
|
77
|
-
"@rspress/
|
|
78
|
-
"@rspress/
|
|
79
|
-
"@rspress/theme-default": "2.0.0-alpha.
|
|
73
|
+
"@rspress/plugin-auto-nav-sidebar": "2.0.0-alpha.12",
|
|
74
|
+
"@rspress/plugin-container-syntax": "2.0.0-alpha.12",
|
|
75
|
+
"@rspress/plugin-last-updated": "2.0.0-alpha.12",
|
|
76
|
+
"@rspress/runtime": "2.0.0-alpha.12",
|
|
77
|
+
"@rspress/shared": "2.0.0-alpha.12",
|
|
78
|
+
"@rspress/plugin-medium-zoom": "2.0.0-alpha.12",
|
|
79
|
+
"@rspress/theme-default": "2.0.0-alpha.12"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@microsoft/api-extractor": "^7.52.3",
|
|
83
|
-
"@rslib/core": "0.6.
|
|
83
|
+
"@rslib/core": "0.6.3",
|
|
84
84
|
"@rspress-dev/plugin-preview": "link:../plugin-preview",
|
|
85
85
|
"@types/hast": "^3.0.4",
|
|
86
86
|
"@types/html-to-text": "^9.0.4",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__ from "virtual-site-data";
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__ from "./ClientApp.js";
|
|
5
|
-
const enableSSG = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].ssg;
|
|
6
|
-
async function renderInBrowser() {
|
|
7
|
-
const container = document.getElementById('root');
|
|
8
|
-
if (process.env.__REACT_GTE_18__) {
|
|
9
|
-
const { createRoot, hydrateRoot } = await import("react-dom/client");
|
|
10
|
-
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)() && enableSSG) hydrateRoot(container, /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}));
|
|
11
|
-
else createRoot(container).render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}));
|
|
12
|
-
} else {
|
|
13
|
-
const ReactDOM = await import("react-dom");
|
|
14
|
-
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)()) ReactDOM.hydrate(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}), container);
|
|
15
|
-
else ReactDOM.render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}), container);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
renderInBrowser();
|
|
File without changes
|
|
File without changes
|
|
File without changes
|