@rspress/core 2.0.0-alpha.11 → 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 +203 -142
- package/dist/loader.js +4 -2
- package/dist/runtime/App.js +5 -4
- package/dist/runtime/ClientApp.d.ts +2 -2
- package/dist/runtime/ClientApp.js +1 -1
- package/dist/runtime/csrClientEntry.js +13 -0
- package/dist/runtime/ssrClientEntry.d.ts +1 -0
- package/dist/runtime/ssrClientEntry.js +19 -0
- package/package.json +8 -8
- package/dist/runtime/clientEntry.js +0 -28
- /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
|
@@ -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 ?>-->';
|
|
@@ -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() {
|
|
@@ -1287,9 +1455,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
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
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) : '';
|
|
@@ -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,7 +1518,7 @@ 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
1523
|
(null == (_config_themeConfig = config.themeConfig) ? void 0 : _config_themeConfig.darkMode) !== false ? {
|
|
1351
1524
|
tag: "script",
|
|
@@ -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: {
|
|
@@ -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
|
}
|
|
@@ -1600,11 +1779,11 @@ async function dev(options) {
|
|
|
1600
1779
|
const modifiedConfig = await pluginDriver.modifyConfig();
|
|
1601
1780
|
try {
|
|
1602
1781
|
await pluginDriver.beforeBuild();
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1782
|
+
const rsbuild = await initRsbuild(docDirectory, modifiedConfig, pluginDriver, false, extraBuilderConfig);
|
|
1783
|
+
rsbuild.onDevCompileDone(async ()=>{
|
|
1605
1784
|
await pluginDriver.afterBuild();
|
|
1606
1785
|
});
|
|
1607
|
-
const { server } = await
|
|
1786
|
+
const { server } = await rsbuild.startDevServer({
|
|
1608
1787
|
getPortSilently: true
|
|
1609
1788
|
});
|
|
1610
1789
|
return server;
|
|
@@ -1613,40 +1792,6 @@ async function dev(options) {
|
|
|
1613
1792
|
await checkLanguageParity(modifiedConfig);
|
|
1614
1793
|
}
|
|
1615
1794
|
}
|
|
1616
|
-
var package_namespaceObject = JSON.parse('{"i8":"2.0.0-alpha.11"}');
|
|
1617
|
-
async function renderFrontmatterHead(route) {
|
|
1618
|
-
if (!isRouteMeta(route)) return '';
|
|
1619
|
-
const content = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(route.absolutePath, {
|
|
1620
|
-
encoding: 'utf-8'
|
|
1621
|
-
});
|
|
1622
|
-
const { frontmatter: { head } } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.loadFrontMatter)(content, route.absolutePath, '', true);
|
|
1623
|
-
if (!head || 0 === head.length) return '';
|
|
1624
|
-
return head.map(([tag, attrs])=>`<${tag} ${renderAttrs(attrs)}>`).join('');
|
|
1625
|
-
}
|
|
1626
|
-
async function renderConfigHead(config, route) {
|
|
1627
|
-
if (!isRouteMeta(route)) return '';
|
|
1628
|
-
if (!config.head || 0 === config.head.length) return '';
|
|
1629
|
-
return config.head.map((head)=>{
|
|
1630
|
-
if ('string' == typeof head) return head;
|
|
1631
|
-
if ('function' == typeof head) {
|
|
1632
|
-
const resultHead = head(route);
|
|
1633
|
-
if (!resultHead) return '';
|
|
1634
|
-
if ('string' == typeof resultHead) return resultHead;
|
|
1635
|
-
return `<${resultHead[0]} ${renderAttrs(resultHead[1])}>`;
|
|
1636
|
-
}
|
|
1637
|
-
return `<${head[0]} ${renderAttrs(head[1])}>`;
|
|
1638
|
-
}).join('');
|
|
1639
|
-
}
|
|
1640
|
-
function renderAttrs(attrs) {
|
|
1641
|
-
return Object.entries(attrs).map(([key, value])=>{
|
|
1642
|
-
if ('boolean' == typeof value) return key;
|
|
1643
|
-
if ('string' == typeof value || 'number' == typeof value) return `${key}="${value}"`;
|
|
1644
|
-
throw new Error(`Invalid value for attribute ${key}:${JSON.stringify(value)}`);
|
|
1645
|
-
}).join('');
|
|
1646
|
-
}
|
|
1647
|
-
function isRouteMeta(route) {
|
|
1648
|
-
return !!route && 'object' == typeof route && 'routePath' in route && 'absolutePath' in route;
|
|
1649
|
-
}
|
|
1650
1795
|
async function bundle(docDirectory, config, pluginDriver, enableSSG) {
|
|
1651
1796
|
try {
|
|
1652
1797
|
const rsbuild = await initRsbuild(docDirectory, config, pluginDriver, enableSSG);
|
|
@@ -1662,100 +1807,16 @@ function emptyDir(path) {
|
|
|
1662
1807
|
recursive: true
|
|
1663
1808
|
});
|
|
1664
1809
|
}
|
|
1665
|
-
async function renderPages(appDirectory, config, pluginDriver) {
|
|
1666
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info('Rendering pages...');
|
|
1667
|
-
const startTime = Date.now();
|
|
1668
|
-
const outputPath = (null == config ? void 0 : config.outDir) ?? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(appDirectory, OUTPUT_DIR);
|
|
1669
|
-
const ssrBundlePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, 'ssr', 'main.cjs');
|
|
1670
|
-
let render;
|
|
1671
|
-
try {
|
|
1672
|
-
const { default: ssrExports } = await import((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(ssrBundlePath).toString());
|
|
1673
|
-
({ render } = ssrExports);
|
|
1674
|
-
} catch (e) {
|
|
1675
|
-
if (e instanceof Error) {
|
|
1676
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(`Failed to load SSG bundle: ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(ssrBundlePath)}: ${e.message}`);
|
|
1677
|
-
hintSSGFailed();
|
|
1678
|
-
}
|
|
1679
|
-
throw e;
|
|
1680
|
-
}
|
|
1681
|
-
try {
|
|
1682
|
-
const routes = init_routeService.getRoutes();
|
|
1683
|
-
const base = (null == config ? void 0 : config.base) ?? '';
|
|
1684
|
-
const htmlTemplatePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, 'index.html');
|
|
1685
|
-
const htmlTemplate = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].readFile(htmlTemplatePath, 'utf-8');
|
|
1686
|
-
const additionalRoutes = (await pluginDriver.addSSGRoutes()).map((route)=>({
|
|
1687
|
-
routePath: (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.withBase)(route.path, base)
|
|
1688
|
-
}));
|
|
1689
|
-
const allRoutes = [
|
|
1690
|
-
...routes,
|
|
1691
|
-
...additionalRoutes
|
|
1692
|
-
];
|
|
1693
|
-
const is404RouteInRoutes = allRoutes.some((route)=>'/404' === route.routePath);
|
|
1694
|
-
if (!is404RouteInRoutes) allRoutes.push({
|
|
1695
|
-
routePath: '/404'
|
|
1696
|
-
});
|
|
1697
|
-
await Promise.all(allRoutes.filter((route)=>!route.routePath.includes(':')).map(async (route)=>{
|
|
1698
|
-
const helmetContext = new __WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__["default"].HelmetData({});
|
|
1699
|
-
const { routePath } = route;
|
|
1700
|
-
let appHtml = '';
|
|
1701
|
-
if (render) try {
|
|
1702
|
-
({ appHtml } = await render(routePath, helmetContext.context));
|
|
1703
|
-
} catch (e) {
|
|
1704
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(`Page "${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(routePath)}" SSG rendering failed.`);
|
|
1705
|
-
throw e;
|
|
1706
|
-
}
|
|
1707
|
-
const { helmet } = helmetContext.context;
|
|
1708
|
-
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, [
|
|
1709
|
-
await renderConfigHead(config, route),
|
|
1710
|
-
helmet.title.toString(),
|
|
1711
|
-
helmet.meta.toString(),
|
|
1712
|
-
helmet.link.toString(),
|
|
1713
|
-
helmet.style.toString(),
|
|
1714
|
-
helmet.script.toString(),
|
|
1715
|
-
await renderFrontmatterHead(route)
|
|
1716
|
-
].join(''));
|
|
1717
|
-
if (helmet.htmlAttributes) {
|
|
1718
|
-
var _helmet_htmlAttributes;
|
|
1719
|
-
html = html.replace(HTML_START_TAG, `${HTML_START_TAG} ${null == (_helmet_htmlAttributes = helmet.htmlAttributes) ? void 0 : _helmet_htmlAttributes.toString()}`);
|
|
1720
|
-
}
|
|
1721
|
-
if (helmet.bodyAttributes) {
|
|
1722
|
-
var _helmet_bodyAttributes;
|
|
1723
|
-
html = html.replace(BODY_START_TAG, `${BODY_START_TAG} ${null == (_helmet_bodyAttributes = helmet.bodyAttributes) ? void 0 : _helmet_bodyAttributes.toString()}`);
|
|
1724
|
-
}
|
|
1725
|
-
const normalizeHtmlFilePath = (path)=>{
|
|
1726
|
-
const normalizedBase = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.normalizeSlash)((null == config ? void 0 : config.base) || '/');
|
|
1727
|
-
if (path.endsWith('/')) return `${path}index.html`.replace(normalizedBase, '');
|
|
1728
|
-
return `${path}.html`.replace(normalizedBase, '');
|
|
1729
|
-
};
|
|
1730
|
-
const fileName = normalizeHtmlFilePath(routePath);
|
|
1731
|
-
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)), {
|
|
1732
|
-
recursive: true
|
|
1733
|
-
});
|
|
1734
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].writeFile((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, fileName), html);
|
|
1735
|
-
}));
|
|
1736
|
-
if (!(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isDebugMode)()) await emptyDir((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, 'ssr'));
|
|
1737
|
-
await emptyDir((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, 'html'));
|
|
1738
|
-
const totalTime = Date.now() - startTime;
|
|
1739
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.success(`Pages rendered in ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(totalTime)} ms.`);
|
|
1740
|
-
} catch (e) {
|
|
1741
|
-
if (e instanceof Error) {
|
|
1742
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(`Pages render error: ${e.message}`);
|
|
1743
|
-
hintSSGFailed();
|
|
1744
|
-
}
|
|
1745
|
-
throw e;
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
1810
|
async function build(options) {
|
|
1749
|
-
const { docDirectory,
|
|
1811
|
+
const { docDirectory, config } = options;
|
|
1750
1812
|
const pluginDriver = new PluginDriver(config, true);
|
|
1751
1813
|
await pluginDriver.init();
|
|
1752
1814
|
const modifiedConfig = await pluginDriver.modifyConfig();
|
|
1753
1815
|
await pluginDriver.beforeBuild();
|
|
1754
1816
|
const ssgConfig = modifiedConfig.ssg ?? true;
|
|
1755
1817
|
await emptyDir(constants_TEMP_DIR);
|
|
1756
|
-
await bundle(docDirectory, modifiedConfig, pluginDriver,
|
|
1757
|
-
if (ssgConfig)
|
|
1758
|
-
else hintSSGFalse();
|
|
1818
|
+
await bundle(docDirectory, modifiedConfig, pluginDriver, ssgConfig);
|
|
1819
|
+
if (!ssgConfig) hintSSGFalse();
|
|
1759
1820
|
await pluginDriver.afterBuild();
|
|
1760
1821
|
}
|
|
1761
1822
|
async function serve(options) {
|
|
@@ -1775,8 +1836,8 @@ async function serve(options) {
|
|
|
1775
1836
|
const pluginDriver = new PluginDriver(config, true);
|
|
1776
1837
|
await pluginDriver.init();
|
|
1777
1838
|
const modifiedConfig = await pluginDriver.modifyConfig();
|
|
1778
|
-
const
|
|
1779
|
-
return
|
|
1839
|
+
const rsbuild = await initRsbuild(config.root, modifiedConfig, pluginDriver, false);
|
|
1840
|
+
return rsbuild.preview();
|
|
1780
1841
|
}
|
|
1781
1842
|
var __webpack_exports__mergeDocConfig = __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.mergeDocConfig;
|
|
1782
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";
|
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: [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { PageData } from '@rspress/shared';
|
|
2
|
-
export declare function ClientApp({ initialPageData }: {
|
|
3
|
-
initialPageData
|
|
2
|
+
export declare function ClientApp({ initialPageData, }: {
|
|
3
|
+
initialPageData?: PageData;
|
|
4
4
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,7 +3,7 @@ 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
|
-
function ClientApp({ initialPageData }) {
|
|
6
|
+
function ClientApp({ initialPageData = null }) {
|
|
7
7
|
const [data, setData] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(initialPageData);
|
|
8
8
|
const [theme, setTheme] = (0, __WEBPACK_EXTERNAL_MODULE__theme_75e53063__.useThemeState)();
|
|
9
9
|
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.ThemeContext.Provider, {
|
|
@@ -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();
|
|
@@ -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/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": {
|
|
@@ -70,13 +70,13 @@
|
|
|
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/shared": "2.0.0-alpha.
|
|
78
|
-
"@rspress/
|
|
79
|
-
"@rspress/
|
|
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",
|
|
@@ -1,28 +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
|
-
import * as __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__ from "./initPageData.js";
|
|
6
|
-
const enableSSG = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].ssg;
|
|
7
|
-
async function renderInBrowser() {
|
|
8
|
-
const container = document.getElementById('root');
|
|
9
|
-
const initialPageData = await (0, __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__.initPageData)(window.location.pathname);
|
|
10
|
-
if (process.env.__REACT_GTE_18__) {
|
|
11
|
-
const { createRoot, hydrateRoot } = await import("react-dom/client");
|
|
12
|
-
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, {
|
|
13
|
-
initialPageData: initialPageData
|
|
14
|
-
}));
|
|
15
|
-
else createRoot(container).render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {
|
|
16
|
-
initialPageData: initialPageData
|
|
17
|
-
}));
|
|
18
|
-
} else {
|
|
19
|
-
const ReactDOM = await import("react-dom");
|
|
20
|
-
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, {
|
|
21
|
-
initialPageData: initialPageData
|
|
22
|
-
}), container);
|
|
23
|
-
else ReactDOM.render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {
|
|
24
|
-
initialPageData: initialPageData
|
|
25
|
-
}), container);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
renderInBrowser();
|
|
File without changes
|
|
File without changes
|
|
File without changes
|