@rspress/core 2.0.0-alpha.7 → 2.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +89 -44
- package/dist/runtime/App.d.ts +0 -6
- package/dist/runtime/App.js +3 -63
- package/dist/runtime/ClientApp.d.ts +1 -0
- package/dist/runtime/ClientApp.js +40 -0
- package/dist/runtime/clientEntry.js +6 -40
- package/dist/runtime/initPageData.d.ts +3 -0
- package/dist/runtime/initPageData.js +59 -0
- package/dist/runtime/ssrEntry.js +2 -1
- package/package.json +31 -30
package/dist/index.js
CHANGED
|
@@ -6,13 +6,12 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/
|
|
|
6
6
|
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
7
7
|
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__ from "@rsbuild/plugin-react";
|
|
8
8
|
import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
|
|
9
|
-
import * as
|
|
9
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__ from "@rspress/shared/logger";
|
|
10
10
|
import * as __WEBPACK_EXTERNAL_MODULE_picocolors__ from "picocolors";
|
|
11
11
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__ from "@rspress/shared/constants";
|
|
12
12
|
import * as __WEBPACK_EXTERNAL_MODULE_tinyglobby__ from "tinyglobby";
|
|
13
13
|
import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
|
|
14
14
|
import * as __WEBPACK_EXTERNAL_MODULE_rspack_plugin_virtual_module_609978fd__ from "rspack-plugin-virtual-module";
|
|
15
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__ from "@rspress/shared/logger";
|
|
16
15
|
import * as __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__ from "lodash-es";
|
|
17
16
|
import * as __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__ from "node:crypto";
|
|
18
17
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_mdx_rs_d2f3021f__ from "@rspress/mdx-rs";
|
|
@@ -23,6 +22,7 @@ import * as __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__ from "@mdx-js/mdx";
|
|
|
23
22
|
import * as __WEBPACK_EXTERNAL_MODULE_enhanced_resolve_bf4706da__ from "enhanced-resolve";
|
|
24
23
|
import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
|
|
25
24
|
import * as __WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__ from "react-helmet-async";
|
|
25
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
|
|
26
26
|
export * from "@rspress/shared";
|
|
27
27
|
function _check_private_redeclaration(obj, privateCollection) {
|
|
28
28
|
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
@@ -184,6 +184,37 @@ class PluginDriver {
|
|
|
184
184
|
_class_private_field_set(this, _plugins, []);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
+
const PLUGIN_VIRTUAL_MODULE_NAME = 'rsbuild:virtual-module';
|
|
188
|
+
const pluginVirtualModule = (pluginOptions = {})=>({
|
|
189
|
+
name: PLUGIN_VIRTUAL_MODULE_NAME,
|
|
190
|
+
async setup (api) {
|
|
191
|
+
const TEMP_DIR = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(process.cwd(), 'node_modules/.rsbuild-virtual-module');
|
|
192
|
+
const { virtualModules = {} } = pluginOptions;
|
|
193
|
+
const virtualFileAbsolutePaths = Object.keys(virtualModules).map((i)=>{
|
|
194
|
+
let absolutePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(TEMP_DIR, i);
|
|
195
|
+
if (!(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.extname)(absolutePath)) absolutePath = `${absolutePath}.js`;
|
|
196
|
+
return [
|
|
197
|
+
i,
|
|
198
|
+
absolutePath
|
|
199
|
+
];
|
|
200
|
+
});
|
|
201
|
+
api.onBeforeCreateCompiler(async ()=>{
|
|
202
|
+
await (0, __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__.mkdir)(TEMP_DIR, {
|
|
203
|
+
recursive: true
|
|
204
|
+
});
|
|
205
|
+
await Promise.all(virtualFileAbsolutePaths.map(([_, absolutePath])=>(0, __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__.writeFile)(absolutePath, '', 'utf-8')));
|
|
206
|
+
});
|
|
207
|
+
api.modifyBundlerChain((chain)=>{
|
|
208
|
+
chain.resolve.alias.merge(Object.fromEntries(virtualFileAbsolutePaths));
|
|
209
|
+
});
|
|
210
|
+
for (const [moduleName, absolutePath] of virtualFileAbsolutePaths){
|
|
211
|
+
const handler = virtualModules[moduleName];
|
|
212
|
+
if (handler) api.transform({
|
|
213
|
+
test: absolutePath
|
|
214
|
+
}, handler);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
});
|
|
187
218
|
const isProduction = ()=>'production' === process.env.NODE_ENV;
|
|
188
219
|
const importStatementRegex = /import\s+(.*?)\s+from\s+(['"])(.*?)(?:"|');?/gm;
|
|
189
220
|
const inlineThemeScript = `{
|
|
@@ -206,7 +237,7 @@ const HTML_START_TAG = '<html';
|
|
|
206
237
|
const BODY_START_TAG = '<body';
|
|
207
238
|
const DEFAULT_TITLE = 'Rspress';
|
|
208
239
|
const PUBLIC_DIR = 'public';
|
|
209
|
-
const
|
|
240
|
+
const constants_TEMP_DIR = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), 'node_modules', __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.RSPRESS_TEMP_DIR);
|
|
210
241
|
async function pathExists(path) {
|
|
211
242
|
try {
|
|
212
243
|
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].access(path);
|
|
@@ -219,7 +250,7 @@ async function readJson(path) {
|
|
|
219
250
|
const raw = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(path, 'utf8');
|
|
220
251
|
return JSON.parse(raw);
|
|
221
252
|
}
|
|
222
|
-
const THEME_DEFAULT_EXPORT_PATTERN = /export
|
|
253
|
+
const THEME_DEFAULT_EXPORT_PATTERN = /export\s+default\s+\{/;
|
|
223
254
|
async function hintThemeBreakingChange(customThemeDir) {
|
|
224
255
|
const fileList = [
|
|
225
256
|
'index.ts',
|
|
@@ -238,13 +269,14 @@ async function hintThemeBreakingChange(customThemeDir) {
|
|
|
238
269
|
break;
|
|
239
270
|
}
|
|
240
271
|
}
|
|
241
|
-
if (useDefaultExportFilePath)
|
|
272
|
+
if (useDefaultExportFilePath) __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.warn(`[Rspress v2] Breaking Change: The "theme/index.tsx" is now using named export instead of default export, please update ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].greenBright(useDefaultExportFilePath)} (https://github.com/web-infra-dev/rspress/discussions/1891#discussioncomment-12422737).\n`, __WEBPACK_EXTERNAL_MODULE_picocolors__["default"].redBright(`
|
|
242
273
|
- import Theme from '@rspress/theme-default';
|
|
243
274
|
- export default {
|
|
244
275
|
- ...Theme,
|
|
245
276
|
- Layout,
|
|
246
277
|
- };
|
|
247
|
-
- export * from 'rspress/theme';`) + __WEBPACK_EXTERNAL_MODULE_picocolors__["default"].
|
|
278
|
+
- export * from 'rspress/theme';`) + __WEBPACK_EXTERNAL_MODULE_picocolors__["default"].greenBright(`
|
|
279
|
+
+ import { Layout } from '@rspress/theme-default';
|
|
248
280
|
|
|
249
281
|
+ export { Layout };
|
|
250
282
|
+ export * from 'rspress/theme';
|
|
@@ -575,25 +607,6 @@ const Props_${index++} = ${JSON.stringify(source[1])};\n`;
|
|
|
575
607
|
[runtimeModule_RuntimeModuleID.GlobalComponents]: moduleContent
|
|
576
608
|
};
|
|
577
609
|
}
|
|
578
|
-
const DEFAULT_I18N_SOURCE = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(process.cwd(), 'i18n.json');
|
|
579
|
-
function getI18nData(docConfig) {
|
|
580
|
-
const { i18nSourcePath = DEFAULT_I18N_SOURCE } = docConfig;
|
|
581
|
-
try {
|
|
582
|
-
delete require.cache[i18nSourcePath];
|
|
583
|
-
const i18nSource = require(i18nSourcePath);
|
|
584
|
-
return i18nSource;
|
|
585
|
-
} catch (e) {
|
|
586
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.debug('getI18nData Failed: \n', e);
|
|
587
|
-
return {};
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
function i18nVMPlugin(context) {
|
|
591
|
-
const { config } = context;
|
|
592
|
-
const i18nData = getI18nData(config);
|
|
593
|
-
return {
|
|
594
|
-
[runtimeModule_RuntimeModuleID.I18nText]: `export default ${JSON.stringify(i18nData, null, 2)}`
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
610
|
async function routeVMPlugin(context) {
|
|
598
611
|
const { routeService, isSSR } = context;
|
|
599
612
|
if (!isSSR) return {
|
|
@@ -847,6 +860,29 @@ function handleHighlightLanguages(highlightLanguages, defaultLanguages) {
|
|
|
847
860
|
}
|
|
848
861
|
return aliases;
|
|
849
862
|
}
|
|
863
|
+
const DEFAULT_I18N_SOURCE = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(process.cwd(), 'i18n.json');
|
|
864
|
+
function getI18nData(docConfig) {
|
|
865
|
+
const { i18nSourcePath = DEFAULT_I18N_SOURCE } = docConfig;
|
|
866
|
+
try {
|
|
867
|
+
delete require.cache[i18nSourcePath];
|
|
868
|
+
const i18nSource = require(i18nSourcePath);
|
|
869
|
+
return i18nSource;
|
|
870
|
+
} catch (e) {
|
|
871
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.debug('getI18nData Failed: \n', e);
|
|
872
|
+
return {};
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
function i18nVMPlugin(context) {
|
|
876
|
+
const { config } = context;
|
|
877
|
+
return {
|
|
878
|
+
[runtimeModule_RuntimeModuleID.I18nText]: ({ addDependency, addMissingDependency })=>{
|
|
879
|
+
addDependency(config.i18nSourcePath || DEFAULT_I18N_SOURCE);
|
|
880
|
+
addMissingDependency(config.i18nSourcePath || DEFAULT_I18N_SOURCE);
|
|
881
|
+
const i18nData = getI18nData(config);
|
|
882
|
+
return `export default ${JSON.stringify(i18nData, null, 2)}`;
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
}
|
|
850
886
|
function normalizeThemeConfig(docConfig, pages = []) {
|
|
851
887
|
const { locales: siteLocales, base = '', lang, replaceRules = [], multiVersion } = docConfig;
|
|
852
888
|
const { versions = [] } = multiVersion || {};
|
|
@@ -989,10 +1025,10 @@ async function siteDataVMPlugin(context) {
|
|
|
989
1025
|
const [version, lang] = group.split('###');
|
|
990
1026
|
const indexVersion = version ? `.${version.replace('.', '_')}` : '';
|
|
991
1027
|
const indexLang = lang ? `.${lang}` : '';
|
|
992
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].mkdir(
|
|
1028
|
+
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].mkdir(constants_TEMP_DIR, {
|
|
993
1029
|
recursive: true
|
|
994
1030
|
});
|
|
995
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].writeFile(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(
|
|
1031
|
+
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].writeFile(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(constants_TEMP_DIR, `${__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.SEARCH_INDEX_NAME}${indexVersion}${indexLang}.${indexHash}.json`), stringifiedIndex);
|
|
996
1032
|
}));
|
|
997
1033
|
await Promise.all(pages.map(async (pageData)=>pluginDriver.extendPageData(pageData)));
|
|
998
1034
|
const siteData = {
|
|
@@ -1048,7 +1084,6 @@ const runtimeModuleFactory = [
|
|
|
1048
1084
|
siteDataVMPlugin,
|
|
1049
1085
|
globalUIComponentsVMPlugin,
|
|
1050
1086
|
globalStylesVMPlugin,
|
|
1051
|
-
i18nVMPlugin,
|
|
1052
1087
|
searchHookVMPlugin
|
|
1053
1088
|
];
|
|
1054
1089
|
function rsbuildPluginDocVM(factoryContext) {
|
|
@@ -1094,7 +1129,7 @@ async function writeSearchIndex(config) {
|
|
|
1094
1129
|
var _config_search;
|
|
1095
1130
|
if ((null == config ? void 0 : config.search) === false) return;
|
|
1096
1131
|
const cwd = process.cwd();
|
|
1097
|
-
const searchIndexFiles = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readdir(
|
|
1132
|
+
const searchIndexFiles = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readdir(constants_TEMP_DIR);
|
|
1098
1133
|
const outDir = (null == config ? void 0 : config.outDir) ?? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(cwd, OUTPUT_DIR);
|
|
1099
1134
|
const targetDir = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outDir, 'static');
|
|
1100
1135
|
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].mkdir(targetDir, {
|
|
@@ -1104,9 +1139,9 @@ async function writeSearchIndex(config) {
|
|
|
1104
1139
|
let scanning = false;
|
|
1105
1140
|
for (const searchIndexFile of searchIndexFiles){
|
|
1106
1141
|
if (!searchIndexFile.includes(__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.SEARCH_INDEX_NAME) || !searchIndexFile.endsWith('.json')) continue;
|
|
1107
|
-
const source = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(
|
|
1142
|
+
const source = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(constants_TEMP_DIR, searchIndexFile);
|
|
1108
1143
|
const target = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(targetDir, searchIndexFile);
|
|
1109
|
-
const searchIndex = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(
|
|
1144
|
+
const searchIndex = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(constants_TEMP_DIR, searchIndexFile), 'utf-8');
|
|
1110
1145
|
searchIndexData = `${searchIndexData.slice(0, -1)}${scanning ? ',' : ''}${searchIndex.slice(1)}`;
|
|
1111
1146
|
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].rename(source, target);
|
|
1112
1147
|
scanning = true;
|
|
@@ -1262,17 +1297,23 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1262
1297
|
resolveReactAlias(reactVersion, false),
|
|
1263
1298
|
enableSSG ? resolveReactAlias(reactVersion, true) : Promise.resolve({})
|
|
1264
1299
|
]);
|
|
1300
|
+
const context = {
|
|
1301
|
+
userDocRoot,
|
|
1302
|
+
config,
|
|
1303
|
+
runtimeTempDir,
|
|
1304
|
+
routeService,
|
|
1305
|
+
pluginDriver
|
|
1306
|
+
};
|
|
1265
1307
|
return {
|
|
1266
1308
|
plugins: [
|
|
1267
1309
|
...isPluginIncluded(config, __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__.PLUGIN_REACT_NAME) ? [] : [
|
|
1268
1310
|
(0, __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__.pluginReact)()
|
|
1269
1311
|
],
|
|
1270
|
-
rsbuildPluginDocVM(
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
pluginDriver
|
|
1312
|
+
rsbuildPluginDocVM(context),
|
|
1313
|
+
pluginVirtualModule({
|
|
1314
|
+
virtualModules: {
|
|
1315
|
+
...i18nVMPlugin(context)
|
|
1316
|
+
}
|
|
1276
1317
|
})
|
|
1277
1318
|
],
|
|
1278
1319
|
server: {
|
|
@@ -1567,7 +1608,7 @@ async function dev(options) {
|
|
|
1567
1608
|
await checkLanguageParity(modifiedConfig);
|
|
1568
1609
|
}
|
|
1569
1610
|
}
|
|
1570
|
-
var package_namespaceObject = JSON.parse('{"i8":"2.0.0-alpha.
|
|
1611
|
+
var package_namespaceObject = JSON.parse('{"i8":"2.0.0-alpha.9"}');
|
|
1571
1612
|
async function renderFrontmatterHead(route) {
|
|
1572
1613
|
if (!isRouteMeta(route)) return '';
|
|
1573
1614
|
const content = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(route.absolutePath, {
|
|
@@ -1601,6 +1642,9 @@ function renderAttrs(attrs) {
|
|
|
1601
1642
|
function isRouteMeta(route) {
|
|
1602
1643
|
return !!route && 'object' == typeof route && 'routePath' in route && 'absolutePath' in route;
|
|
1603
1644
|
}
|
|
1645
|
+
function isCSRFallback(ssgConfig) {
|
|
1646
|
+
return 'object' == typeof ssgConfig && 'csr' === ssgConfig.fallback;
|
|
1647
|
+
}
|
|
1604
1648
|
async function bundle(docDirectory, config, pluginDriver, enableSSG) {
|
|
1605
1649
|
try {
|
|
1606
1650
|
const rsbuild = await initRsbuild(docDirectory, config, pluginDriver, enableSSG);
|
|
@@ -1627,12 +1671,13 @@ async function renderPages(appDirectory, config, pluginDriver, ssgConfig) {
|
|
|
1627
1671
|
const { default: ssrExports } = await import((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(ssrBundlePath).toString());
|
|
1628
1672
|
({ render } = ssrExports);
|
|
1629
1673
|
} catch (e) {
|
|
1630
|
-
if (
|
|
1674
|
+
if (isCSRFallback(ssgConfig)) {
|
|
1675
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(e);
|
|
1676
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.warn(`Failed to load SSG bundle: ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(ssrBundlePath)}, fallback to CSR.`);
|
|
1677
|
+
} else {
|
|
1631
1678
|
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(`Failed to load SSG bundle: ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(ssrBundlePath)}.`);
|
|
1632
1679
|
throw e;
|
|
1633
1680
|
}
|
|
1634
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(e);
|
|
1635
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.warn(`Failed to load SSG bundle: ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(ssrBundlePath)}, fallback to CSR.`);
|
|
1636
1681
|
}
|
|
1637
1682
|
const routes = init_routeService.getRoutes();
|
|
1638
1683
|
const base = (null == config ? void 0 : config.base) ?? '';
|
|
@@ -1656,11 +1701,11 @@ async function renderPages(appDirectory, config, pluginDriver, ssgConfig) {
|
|
|
1656
1701
|
if (render) try {
|
|
1657
1702
|
({ appHtml } = await render(routePath, helmetContext.context));
|
|
1658
1703
|
} catch (e) {
|
|
1659
|
-
if (
|
|
1704
|
+
if (isCSRFallback(ssgConfig)) __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.warn(`Page "${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(routePath)}" SSG rendering error, fallback to CSR.`, e);
|
|
1705
|
+
else {
|
|
1660
1706
|
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(`Page "${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(routePath)}" SSG rendering failed.`);
|
|
1661
1707
|
throw e;
|
|
1662
1708
|
}
|
|
1663
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.warn(`Page "${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(routePath)}" SSG rendering error, fallback to CSR.`, e);
|
|
1664
1709
|
}
|
|
1665
1710
|
const { helmet } = helmetContext.context;
|
|
1666
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, [
|
|
@@ -1707,7 +1752,7 @@ async function build(options) {
|
|
|
1707
1752
|
const modifiedConfig = await pluginDriver.modifyConfig();
|
|
1708
1753
|
await pluginDriver.beforeBuild();
|
|
1709
1754
|
const ssgConfig = modifiedConfig.ssg ?? true;
|
|
1710
|
-
await emptyDir(
|
|
1755
|
+
await emptyDir(constants_TEMP_DIR);
|
|
1711
1756
|
await bundle(docDirectory, modifiedConfig, pluginDriver, Boolean(ssgConfig));
|
|
1712
1757
|
await renderPages(appDirectory, modifiedConfig, pluginDriver, ssgConfig);
|
|
1713
1758
|
await pluginDriver.afterBuild();
|
package/dist/runtime/App.d.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import { type PageData } from '@rspress/shared';
|
|
2
1
|
import 'virtual-global-styles';
|
|
3
|
-
export declare enum QueryStatus {
|
|
4
|
-
Show = "1",
|
|
5
|
-
Hide = "0"
|
|
6
|
-
}
|
|
7
|
-
export declare function initPageData(routePath: string): Promise<PageData>;
|
|
8
2
|
export declare function App({ helmetContext }: {
|
|
9
3
|
helmetContext?: object;
|
|
10
4
|
}): import("react/jsx-runtime").JSX.Element;
|
package/dist/runtime/App.js
CHANGED
|
@@ -1,71 +1,11 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress/runtime";
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
|
|
4
3
|
import * as __WEBPACK_EXTERNAL_MODULE__theme_75e53063__ from "@theme";
|
|
5
4
|
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
6
5
|
import * as __WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__ from "react-helmet-async";
|
|
7
6
|
import * as __WEBPACK_EXTERNAL_MODULE_virtual_global_components_43dbb356__ from "virtual-global-components";
|
|
8
|
-
import * as __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__ from "virtual-site-data";
|
|
9
7
|
import "virtual-global-styles";
|
|
10
|
-
|
|
11
|
-
QueryStatus["Show"] = "1";
|
|
12
|
-
QueryStatus["Hide"] = "0";
|
|
13
|
-
return QueryStatus;
|
|
14
|
-
}({});
|
|
15
|
-
async function initPageData(routePath) {
|
|
16
|
-
var _siteData_multiVersion;
|
|
17
|
-
const matchedRoute = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.pathnameToRouteService)(routePath);
|
|
18
|
-
if (matchedRoute) {
|
|
19
|
-
var _mod_default___RSPRESS_PAGE_META;
|
|
20
|
-
const mod = await matchedRoute.preload();
|
|
21
|
-
const pagePath = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.cleanUrl)(matchedRoute.filePath);
|
|
22
|
-
const normalize = (p)=>p.replace(/\/$/, '').toLowerCase();
|
|
23
|
-
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)));
|
|
24
|
-
const encodedPagePath = encodeURIComponent(pagePath);
|
|
25
|
-
const meta = (null === (_mod_default___RSPRESS_PAGE_META = mod.default.__RSPRESS_PAGE_META) || void 0 === _mod_default___RSPRESS_PAGE_META ? void 0 : _mod_default___RSPRESS_PAGE_META[encodedPagePath]) || {};
|
|
26
|
-
const { toc = [], title = '', frontmatter = {}, ...rest } = __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP.test(matchedRoute.filePath) ? meta : mod;
|
|
27
|
-
return {
|
|
28
|
-
siteData: __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"],
|
|
29
|
-
page: {
|
|
30
|
-
...rest,
|
|
31
|
-
pagePath,
|
|
32
|
-
...extractPageInfo,
|
|
33
|
-
pageType: (null == frontmatter ? void 0 : frontmatter.pageType) || 'doc',
|
|
34
|
-
title,
|
|
35
|
-
frontmatter,
|
|
36
|
-
toc
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
let lang = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang || '';
|
|
41
|
-
let version = (null === (_siteData_multiVersion = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].multiVersion) || void 0 === _siteData_multiVersion ? void 0 : _siteData_multiVersion.default) || '';
|
|
42
|
-
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang && 'undefined' != typeof window) {
|
|
43
|
-
const path = location.pathname.replace(__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].base, '').split('/').slice(0, 2);
|
|
44
|
-
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].locales.length) {
|
|
45
|
-
const result = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].locales.find(({ lang })=>path.includes(lang));
|
|
46
|
-
if (result) lang = result.lang;
|
|
47
|
-
}
|
|
48
|
-
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].multiVersion.versions) {
|
|
49
|
-
const result = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].multiVersion.versions.find((version)=>path.includes(version));
|
|
50
|
-
if (result) version = result;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
siteData: __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"],
|
|
55
|
-
page: {
|
|
56
|
-
pagePath: '',
|
|
57
|
-
pageType: '404',
|
|
58
|
-
routePath: '/404',
|
|
59
|
-
lang,
|
|
60
|
-
frontmatter: {},
|
|
61
|
-
title: '404',
|
|
62
|
-
toc: [],
|
|
63
|
-
version,
|
|
64
|
-
_filepath: '',
|
|
65
|
-
_relativePath: ''
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
}
|
|
8
|
+
import * as __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__ from "./initPageData.js";
|
|
69
9
|
function App({ helmetContext }) {
|
|
70
10
|
const { setData: setPageData, data } = (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.DataContext);
|
|
71
11
|
const frontmatter = data.page.frontmatter || {};
|
|
@@ -76,7 +16,7 @@ function App({ helmetContext }) {
|
|
|
76
16
|
(0, __WEBPACK_EXTERNAL_MODULE_react__.useLayoutEffect)(()=>{
|
|
77
17
|
async function refetchData() {
|
|
78
18
|
try {
|
|
79
|
-
const pageData = await initPageData(pathname);
|
|
19
|
+
const pageData = await (0, __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__.initPageData)(pathname);
|
|
80
20
|
null == setPageData || setPageData(pageData);
|
|
81
21
|
} catch (e) {
|
|
82
22
|
console.log(e);
|
|
@@ -106,4 +46,4 @@ function App({ helmetContext }) {
|
|
|
106
46
|
]
|
|
107
47
|
});
|
|
108
48
|
}
|
|
109
|
-
export { App
|
|
49
|
+
export { App };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ClientApp(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress/runtime";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__theme_75e53063__ from "@theme";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__ from "./App.js";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__ from "./initPageData.js";
|
|
7
|
+
function ClientApp() {
|
|
8
|
+
const [data, setData] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(null);
|
|
9
|
+
const [theme, setTheme] = (0, __WEBPACK_EXTERNAL_MODULE__theme_75e53063__.useThemeState)();
|
|
10
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
11
|
+
(0, __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__.initPageData)(window.location.pathname).then((pageData)=>{
|
|
12
|
+
setData(pageData);
|
|
13
|
+
});
|
|
14
|
+
}, []);
|
|
15
|
+
const themeValue = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
16
|
+
theme,
|
|
17
|
+
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,
|
|
32
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.DataContext.Provider, {
|
|
33
|
+
value: dataValue,
|
|
34
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.BrowserRouter, {
|
|
35
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.App, {})
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export { ClientApp };
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_react_dom_7136dc57__ from "react-dom";
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE_react_dom_client_76b1397c__ from "react-dom/client";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress/runtime";
|
|
5
4
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
|
|
6
|
-
import * as __WEBPACK_EXTERNAL_MODULE__theme_75e53063__ from "@theme";
|
|
7
|
-
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
8
5
|
import * as __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__ from "virtual-site-data";
|
|
9
|
-
import * as
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__ from "./ClientApp.js";
|
|
10
7
|
var __webpack_modules__ = {
|
|
11
8
|
"react-dom": function(module) {
|
|
12
9
|
module.exports = __WEBPACK_EXTERNAL_MODULE_react_dom_7136dc57__;
|
|
@@ -28,46 +25,15 @@ function __webpack_require__(moduleId) {
|
|
|
28
25
|
const enableSSG = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].ssg;
|
|
29
26
|
async function renderInBrowser() {
|
|
30
27
|
const container = document.getElementById('root');
|
|
31
|
-
const enhancedApp = async ()=>{
|
|
32
|
-
const initialPageData = await (0, __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.initPageData)(window.location.pathname);
|
|
33
|
-
return function() {
|
|
34
|
-
const [data, setData] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(initialPageData);
|
|
35
|
-
const [theme, setTheme] = (0, __WEBPACK_EXTERNAL_MODULE__theme_75e53063__.useThemeState)();
|
|
36
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.ThemeContext.Provider, {
|
|
37
|
-
value: (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
38
|
-
theme,
|
|
39
|
-
setTheme
|
|
40
|
-
}), [
|
|
41
|
-
theme,
|
|
42
|
-
setTheme
|
|
43
|
-
]),
|
|
44
|
-
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.DataContext.Provider, {
|
|
45
|
-
value: (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
46
|
-
data,
|
|
47
|
-
setData
|
|
48
|
-
}), [
|
|
49
|
-
data,
|
|
50
|
-
setData
|
|
51
|
-
]),
|
|
52
|
-
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.BrowserRouter, {
|
|
53
|
-
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.App, {})
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
const RootApp = await enhancedApp();
|
|
60
28
|
if (process.env.__REACT_GTE_18__) {
|
|
61
29
|
const { createRoot, hydrateRoot } = __webpack_require__("react-dom/client");
|
|
62
|
-
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)() && enableSSG) hydrateRoot(container, /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(
|
|
63
|
-
else createRoot(container).render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(
|
|
30
|
+
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, {}));
|
|
31
|
+
else createRoot(container).render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}));
|
|
64
32
|
} else {
|
|
65
33
|
const ReactDOM = __webpack_require__("react-dom");
|
|
66
|
-
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)()) ReactDOM.hydrate(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(
|
|
67
|
-
else ReactDOM.render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(
|
|
34
|
+
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);
|
|
35
|
+
else ReactDOM.render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}), container);
|
|
68
36
|
}
|
|
69
37
|
}
|
|
70
|
-
renderInBrowser()
|
|
71
|
-
(0, __WEBPACK_EXTERNAL_MODULE__theme_75e53063__.setup)();
|
|
72
|
-
});
|
|
38
|
+
renderInBrowser();
|
|
73
39
|
export { renderInBrowser };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress/runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
|
|
3
|
+
import "virtual-global-styles";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__ from "virtual-site-data";
|
|
5
|
+
async function initPageData(routePath) {
|
|
6
|
+
var _siteData_multiVersion;
|
|
7
|
+
const matchedRoute = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.pathnameToRouteService)(routePath);
|
|
8
|
+
if (matchedRoute) {
|
|
9
|
+
var _mod_default___RSPRESS_PAGE_META;
|
|
10
|
+
const mod = await matchedRoute.preload();
|
|
11
|
+
const pagePath = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.cleanUrl)(matchedRoute.filePath);
|
|
12
|
+
const normalize = (p)=>p.replace(/\/$/, '').toLowerCase();
|
|
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
|
+
const encodedPagePath = encodeURIComponent(pagePath);
|
|
15
|
+
const meta = (null === (_mod_default___RSPRESS_PAGE_META = mod.default.__RSPRESS_PAGE_META) || void 0 === _mod_default___RSPRESS_PAGE_META ? void 0 : _mod_default___RSPRESS_PAGE_META[encodedPagePath]) || {};
|
|
16
|
+
const { toc = [], title = '', frontmatter = {}, ...rest } = __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP.test(matchedRoute.filePath) ? meta : mod;
|
|
17
|
+
return {
|
|
18
|
+
siteData: __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"],
|
|
19
|
+
page: {
|
|
20
|
+
...rest,
|
|
21
|
+
pagePath,
|
|
22
|
+
...extractPageInfo,
|
|
23
|
+
pageType: (null == frontmatter ? void 0 : frontmatter.pageType) || 'doc',
|
|
24
|
+
title,
|
|
25
|
+
frontmatter,
|
|
26
|
+
toc
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
let lang = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang || '';
|
|
31
|
+
let version = (null === (_siteData_multiVersion = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].multiVersion) || void 0 === _siteData_multiVersion ? void 0 : _siteData_multiVersion.default) || '';
|
|
32
|
+
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang && 'undefined' != typeof window) {
|
|
33
|
+
const path = location.pathname.replace(__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].base, '').split('/').slice(0, 2);
|
|
34
|
+
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].locales.length) {
|
|
35
|
+
const result = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].locales.find(({ lang })=>path.includes(lang));
|
|
36
|
+
if (result) lang = result.lang;
|
|
37
|
+
}
|
|
38
|
+
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].multiVersion.versions) {
|
|
39
|
+
const result = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].multiVersion.versions.find((version)=>path.includes(version));
|
|
40
|
+
if (result) version = result;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
siteData: __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"],
|
|
45
|
+
page: {
|
|
46
|
+
pagePath: '',
|
|
47
|
+
pageType: '404',
|
|
48
|
+
routePath: '/404',
|
|
49
|
+
lang,
|
|
50
|
+
frontmatter: {},
|
|
51
|
+
title: '404',
|
|
52
|
+
toc: [],
|
|
53
|
+
version,
|
|
54
|
+
_filepath: '',
|
|
55
|
+
_relativePath: ''
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export { initPageData };
|
package/dist/runtime/ssrEntry.js
CHANGED
|
@@ -3,10 +3,11 @@ import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress
|
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_server_673c713a__ from "@rspress/runtime/server";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE_react_dom_server_98c38d5c__ from "react-dom/server";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__ from "./App.js";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__ from "./initPageData.js";
|
|
6
7
|
import * as __WEBPACK_EXTERNAL_MODULE_virtual_routes_ssr_f802e6e5__ from "virtual-routes-ssr";
|
|
7
8
|
const DEFAULT_THEME = 'light';
|
|
8
9
|
async function render(pagePath, helmetContext) {
|
|
9
|
-
const initialPageData = await (0,
|
|
10
|
+
const initialPageData = await (0, __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__.initPageData)(pagePath);
|
|
10
11
|
const appHtml = (0, __WEBPACK_EXTERNAL_MODULE_react_dom_server_98c38d5c__.renderToString)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.ThemeContext.Provider, {
|
|
11
12
|
value: {
|
|
12
13
|
theme: DEFAULT_THEME
|
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.9",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -42,20 +42,20 @@
|
|
|
42
42
|
"theme.ts"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@mdx-js/loader": "
|
|
46
|
-
"@mdx-js/mdx": "
|
|
47
|
-
"@mdx-js/react": "
|
|
48
|
-
"@rsbuild/core": "1.
|
|
45
|
+
"@mdx-js/loader": "^3.1.0",
|
|
46
|
+
"@mdx-js/mdx": "^3.1.0",
|
|
47
|
+
"@mdx-js/react": "^3.1.0",
|
|
48
|
+
"@rsbuild/core": "1.3.4",
|
|
49
49
|
"@rsbuild/plugin-react": "~1.1.1",
|
|
50
50
|
"@rspress/mdx-rs": "0.6.6",
|
|
51
51
|
"enhanced-resolve": "5.18.1",
|
|
52
52
|
"github-slugger": "^2.0.0",
|
|
53
53
|
"hast-util-from-html": "^2.0.3",
|
|
54
|
-
"hast-util-heading-rank": "^
|
|
54
|
+
"hast-util-heading-rank": "^3.0.0",
|
|
55
55
|
"html-to-text": "^9.0.5",
|
|
56
56
|
"htmr": "^1.0.2",
|
|
57
57
|
"lodash-es": "^4.17.21",
|
|
58
|
-
"mdast-util-mdxjs-esm": "^
|
|
58
|
+
"mdast-util-mdxjs-esm": "^2.0.1",
|
|
59
59
|
"picocolors": "^1.1.1",
|
|
60
60
|
"react": "^18.3.1",
|
|
61
61
|
"react-dom": "^18.3.1",
|
|
@@ -63,41 +63,42 @@
|
|
|
63
63
|
"react-lazy-with-preload": "^2.2.1",
|
|
64
64
|
"react-syntax-highlighter": "^15.6.1",
|
|
65
65
|
"rehype-external-links": "^3.0.0",
|
|
66
|
-
"remark": "^
|
|
67
|
-
"remark-gfm": "
|
|
66
|
+
"remark": "^15.0.1",
|
|
67
|
+
"remark-gfm": "^4.0.1",
|
|
68
68
|
"rspack-plugin-virtual-module": "0.1.13",
|
|
69
69
|
"tinyglobby": "^0.2.12",
|
|
70
|
-
"unified": "^
|
|
71
|
-
"unist-util-visit": "^
|
|
72
|
-
"unist-util-visit-children": "^
|
|
73
|
-
"@rspress/plugin-auto-nav-sidebar": "2.0.0-alpha.
|
|
74
|
-
"@rspress/plugin-container-syntax": "2.0.0-alpha.
|
|
75
|
-
"@rspress/plugin-
|
|
76
|
-
"@rspress/
|
|
77
|
-
"@rspress/
|
|
78
|
-
"@rspress/shared": "2.0.0-alpha.
|
|
79
|
-
"@rspress/theme-default": "2.0.0-alpha.
|
|
70
|
+
"unified": "^11.0.5",
|
|
71
|
+
"unist-util-visit": "^5.0.0",
|
|
72
|
+
"unist-util-visit-children": "^3.0.0",
|
|
73
|
+
"@rspress/plugin-auto-nav-sidebar": "2.0.0-alpha.9",
|
|
74
|
+
"@rspress/plugin-container-syntax": "2.0.0-alpha.9",
|
|
75
|
+
"@rspress/plugin-last-updated": "2.0.0-alpha.9",
|
|
76
|
+
"@rspress/runtime": "2.0.0-alpha.9",
|
|
77
|
+
"@rspress/plugin-medium-zoom": "2.0.0-alpha.9",
|
|
78
|
+
"@rspress/shared": "2.0.0-alpha.9",
|
|
79
|
+
"@rspress/theme-default": "2.0.0-alpha.9"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@microsoft/api-extractor": "^7.52.
|
|
83
|
-
"@rslib/core": "0.
|
|
82
|
+
"@microsoft/api-extractor": "^7.52.3",
|
|
83
|
+
"@rslib/core": "0.6.1",
|
|
84
84
|
"@rspress-dev/plugin-preview": "link:../plugin-preview",
|
|
85
|
-
"@types/hast": "^
|
|
85
|
+
"@types/hast": "^3.0.4",
|
|
86
86
|
"@types/html-to-text": "^9.0.4",
|
|
87
87
|
"@types/jest": "~29.5.14",
|
|
88
88
|
"@types/lodash-es": "^4.17.12",
|
|
89
|
-
"@types/mdast": "^
|
|
89
|
+
"@types/mdast": "^4.0.4",
|
|
90
90
|
"@types/node": "^18.11.17",
|
|
91
|
-
"@types/react": "^18.3.
|
|
92
|
-
"@types/react-dom": "^18.3.
|
|
91
|
+
"@types/react": "^18.3.20",
|
|
92
|
+
"@types/react-dom": "^18.3.6",
|
|
93
93
|
"memfs": "^4.17.0",
|
|
94
94
|
"postcss": "8.5.3",
|
|
95
|
-
"rehype-stringify": "^
|
|
96
|
-
"remark-mdx": "
|
|
97
|
-
"remark-parse": "^
|
|
98
|
-
"remark-rehype": "^
|
|
99
|
-
"remark-stringify": "^
|
|
95
|
+
"rehype-stringify": "^10.0.1",
|
|
96
|
+
"remark-mdx": "^3.1.0",
|
|
97
|
+
"remark-parse": "^11.0.0",
|
|
98
|
+
"remark-rehype": "^11.1.2",
|
|
99
|
+
"remark-stringify": "^11.0.0",
|
|
100
100
|
"rimraf": "^6.0.1",
|
|
101
|
+
"rsbuild-plugin-virtual-module": "0.1.1",
|
|
101
102
|
"tailwindcss": "^3.4.17",
|
|
102
103
|
"typescript": "^5.8.2",
|
|
103
104
|
"vfile": "^5.3.7",
|