@rspress/core 2.0.0-beta.7 → 2.0.0-beta.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/README.md +1 -1
- package/dist/index.js +13 -21
- package/dist/loader.js +21 -12
- package/dist/runtime/ssrServerEntry.d.ts +1 -1
- package/dist/runtime/ssrServerEntry.js +2 -2
- package/package.json +10 -9
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import __rslib_shim_module__ from 'module';
|
|
2
2
|
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_plugin_container_syntax_12d3c700__ from "@rspress/plugin-container-syntax";
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
|
|
5
4
|
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
|
|
6
5
|
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
7
6
|
import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
|
|
8
7
|
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__ from "@rsbuild/plugin-react";
|
|
8
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
|
|
9
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";
|
|
@@ -50,10 +50,6 @@ class PluginDriver {
|
|
|
50
50
|
this.addPlugin(pluginMediumZoom('object' == typeof mediumZoomConfig ? mediumZoomConfig : void 0));
|
|
51
51
|
}
|
|
52
52
|
this.addPlugin((0, __WEBPACK_EXTERNAL_MODULE__rspress_plugin_container_syntax_12d3c700__.pluginContainerSyntax)());
|
|
53
|
-
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isDevDebugMode)()) {
|
|
54
|
-
const SourceBuildPlugin = await import("@rspress/theme-default/node/source-build-plugin.js").then((r)=>r.SourceBuildPlugin, ()=>null);
|
|
55
|
-
if (SourceBuildPlugin) this.addPlugin(SourceBuildPlugin());
|
|
56
|
-
}
|
|
57
53
|
const { pluginShiki } = await import("@rspress/plugin-shiki");
|
|
58
54
|
(config.plugins || []).forEach((plugin)=>{
|
|
59
55
|
this.addPlugin(plugin);
|
|
@@ -179,7 +175,7 @@ const pluginVirtualModule = (pluginOptions = {})=>({
|
|
|
179
175
|
}
|
|
180
176
|
}
|
|
181
177
|
});
|
|
182
|
-
var package_namespaceObject = JSON.parse('{"i8":"2.0.0-beta.
|
|
178
|
+
var package_namespaceObject = JSON.parse('{"i8":"2.0.0-beta.9"}');
|
|
183
179
|
const RSPRESS_VERSION = package_namespaceObject.i8;
|
|
184
180
|
const isProduction = ()=>'production' === process.env.NODE_ENV;
|
|
185
181
|
const importStatementRegex = /import\s+(.*?)\s+from\s+(['"])(.*?)(?:"|');?/gm;
|
|
@@ -467,8 +463,7 @@ function createHash(str) {
|
|
|
467
463
|
var types_RuntimeModuleID = /*#__PURE__*/ function(RuntimeModuleID) {
|
|
468
464
|
RuntimeModuleID["GlobalStyles"] = "virtual-global-styles";
|
|
469
465
|
RuntimeModuleID["GlobalComponents"] = "virtual-global-components";
|
|
470
|
-
RuntimeModuleID["
|
|
471
|
-
RuntimeModuleID["RouteForSSR"] = "virtual-routes-ssr";
|
|
466
|
+
RuntimeModuleID["Routes"] = "virtual-routes";
|
|
472
467
|
RuntimeModuleID["SiteData"] = "virtual-site-data";
|
|
473
468
|
RuntimeModuleID["SearchIndexHash"] = "virtual-search-index-hash";
|
|
474
469
|
RuntimeModuleID["I18nText"] = "virtual-i18n-text";
|
|
@@ -890,7 +885,7 @@ function rsbuildPluginDocVM(factoryContext) {
|
|
|
890
885
|
if (runtimeModule[key]) throw new Error(`The runtime module ${key} is duplicated, please check your plugin`);
|
|
891
886
|
runtimeModule[key] = modulesByPlugin[key];
|
|
892
887
|
});
|
|
893
|
-
bundlerChain.plugin('rspress-runtime-module').use(new __WEBPACK_EXTERNAL_MODULE_rspack_plugin_virtual_module_609978fd__.RspackVirtualModulePlugin(runtimeModule
|
|
888
|
+
bundlerChain.plugin('rspress-runtime-module').use(new __WEBPACK_EXTERNAL_MODULE_rspack_plugin_virtual_module_609978fd__.RspackVirtualModulePlugin(runtimeModule));
|
|
894
889
|
});
|
|
895
890
|
}
|
|
896
891
|
};
|
|
@@ -933,8 +928,7 @@ const Props_${index++} = ${JSON.stringify(source[1])};\n`;
|
|
|
933
928
|
const routeListVMPlugin = (context)=>{
|
|
934
929
|
const { routeService } = context;
|
|
935
930
|
return {
|
|
936
|
-
[types_RuntimeModuleID.
|
|
937
|
-
[types_RuntimeModuleID.RouteForSSR]: ({ environment })=>'node' === environment.name ? routeService.generateRoutesCode(true) : ''
|
|
931
|
+
[types_RuntimeModuleID.Routes]: ({ environment })=>'node' === environment.name ? routeService.generateRoutesCode(true) : routeService.generateRoutesCode(false)
|
|
938
932
|
};
|
|
939
933
|
};
|
|
940
934
|
const searchHookVMPlugin = (context)=>({
|
|
@@ -1063,9 +1057,10 @@ async function renderPages(routeService, config, pluginDriver, ssrBundlePath, ht
|
|
|
1063
1057
|
if (render) try {
|
|
1064
1058
|
({ appHtml } = await render(routePath, head));
|
|
1065
1059
|
} catch (e) {
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1060
|
+
if (e instanceof Error) {
|
|
1061
|
+
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(`Page "${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].yellow(routePath)}" SSG rendering failed.\n ${__WEBPACK_EXTERNAL_MODULE_picocolors__["default"].gray(e.toString())}`);
|
|
1062
|
+
throw e;
|
|
1063
|
+
}
|
|
1069
1064
|
}
|
|
1070
1065
|
const replacedHtmlTemplate = htmlTemplate.replace(/<title>(.*?)<\/title>/gi, '').replace(APP_HTML_MARKER, ()=>appHtml).replace(META_GENERATOR, ()=>`<meta name="generator" content="Rspress v${RSPRESS_VERSION}">`).replace(HEAD_MARKER, [
|
|
1071
1066
|
await renderConfigHead(config, route),
|
|
@@ -1275,7 +1270,7 @@ function getSocialIcons(socialLinks = []) {
|
|
|
1275
1270
|
function isPluginIncluded(config, pluginName) {
|
|
1276
1271
|
return Boolean(config.builderPlugins?.some((plugin)=>plugin.name === pluginName) || config.builderConfig?.plugins?.some((plugin)=>plugin && plugin.name === pluginName));
|
|
1277
1272
|
}
|
|
1278
|
-
async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver
|
|
1273
|
+
async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver) {
|
|
1279
1274
|
const cwd = process.cwd();
|
|
1280
1275
|
const CUSTOM_THEME_DIR = config?.themeDir ?? __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), 'theme');
|
|
1281
1276
|
const outDir = config?.outDir ?? OUTPUT_DIR;
|
|
@@ -1300,7 +1295,6 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1300
1295
|
const context = {
|
|
1301
1296
|
userDocRoot,
|
|
1302
1297
|
config,
|
|
1303
|
-
runtimeTempDir,
|
|
1304
1298
|
routeService,
|
|
1305
1299
|
pluginDriver
|
|
1306
1300
|
};
|
|
@@ -1438,8 +1432,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1438
1432
|
resolve: {
|
|
1439
1433
|
alias: {
|
|
1440
1434
|
...reactCSRAlias,
|
|
1441
|
-
...reactRouterDomAlias
|
|
1442
|
-
__VIRTUAL_ROUTES__: 'virtual-routes'
|
|
1435
|
+
...reactRouterDomAlias
|
|
1443
1436
|
}
|
|
1444
1437
|
},
|
|
1445
1438
|
source: {
|
|
@@ -1462,8 +1455,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1462
1455
|
resolve: {
|
|
1463
1456
|
alias: {
|
|
1464
1457
|
...reactSSRAlias,
|
|
1465
|
-
...reactRouterDomAlias
|
|
1466
|
-
__VIRTUAL_ROUTES__: 'virtual-routes-ssr'
|
|
1458
|
+
...reactRouterDomAlias
|
|
1467
1459
|
}
|
|
1468
1460
|
},
|
|
1469
1461
|
tools: {
|
|
@@ -1512,7 +1504,7 @@ async function initRsbuild(rootDir, config, pluginDriver, enableSSG, extraRsbuil
|
|
|
1512
1504
|
pluginDriver
|
|
1513
1505
|
});
|
|
1514
1506
|
const { createRsbuild, mergeRsbuildConfig } = await import("@rsbuild/core");
|
|
1515
|
-
const internalRsbuildConfig = await createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver
|
|
1507
|
+
const internalRsbuildConfig = await createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver);
|
|
1516
1508
|
const rsbuild = await createRsbuild({
|
|
1517
1509
|
callerName: 'rspress',
|
|
1518
1510
|
rsbuildConfig: mergeRsbuildConfig(internalRsbuildConfig, ...pluginDriver.getPlugins()?.map((plugin)=>plugin.builderConfig ?? {}) || [], config?.builderConfig || {}, extraRsbuildConfig || {})
|
package/dist/loader.js
CHANGED
|
@@ -6,10 +6,11 @@ import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__ from "@r
|
|
|
6
6
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__ from "@rspress/shared/node-utils";
|
|
7
7
|
import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
|
|
8
8
|
import * as __WEBPACK_EXTERNAL_MODULE_rehype_external_links_09bed11a__ from "rehype-external-links";
|
|
9
|
+
import * as __WEBPACK_EXTERNAL_MODULE_rehype_raw_434f4cf9__ from "rehype-raw";
|
|
9
10
|
import * as __WEBPACK_EXTERNAL_MODULE_remark_gfm_073acf21__ from "remark-gfm";
|
|
10
|
-
import * as __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__ from "unist-util-visit";
|
|
11
11
|
import * as __WEBPACK_EXTERNAL_MODULE_github_slugger_8e9a17cb__ from "github-slugger";
|
|
12
12
|
import * as __WEBPACK_EXTERNAL_MODULE_hast_util_heading_rank_cff646ba__ from "hast-util-heading-rank";
|
|
13
|
+
import * as __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__ from "unist-util-visit";
|
|
13
14
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
|
|
14
15
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__ from "@rspress/shared/constants";
|
|
15
16
|
import * as __WEBPACK_EXTERNAL_MODULE_unist_util_visit_children_71921007__ from "unist-util-visit-children";
|
|
@@ -29,15 +30,6 @@ function slash(p) {
|
|
|
29
30
|
function normalizePath(id) {
|
|
30
31
|
return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.normalize(isWindows ? slash(id) : id);
|
|
31
32
|
}
|
|
32
|
-
const rehypePluginCodeMeta = ()=>(tree)=>{
|
|
33
|
-
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'element', (node)=>{
|
|
34
|
-
if ('pre' === node.tagName && node.children[0]?.type === 'element' && 'code' === node.children[0].tagName) {
|
|
35
|
-
const codeNode = node.children[0];
|
|
36
|
-
codeNode.properties ??= {};
|
|
37
|
-
codeNode.properties.meta = codeNode.data?.meta;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
33
|
const rehypeHeaderAnchor = ()=>{
|
|
42
34
|
const slugger = new __WEBPACK_EXTERNAL_MODULE_github_slugger_8e9a17cb__["default"]();
|
|
43
35
|
return (tree)=>{
|
|
@@ -295,7 +287,16 @@ const remarkPluginToc = function() {
|
|
|
295
287
|
if (title) data.pageMeta.title = title;
|
|
296
288
|
};
|
|
297
289
|
};
|
|
290
|
+
const rehypeCodeMeta = ()=>(tree)=>{
|
|
291
|
+
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'element', (node)=>{
|
|
292
|
+
if ('pre' === node.tagName && node.children[0]?.type === 'element' && 'code' === node.children[0].tagName) {
|
|
293
|
+
const codeNode = node.children[0];
|
|
294
|
+
codeNode.properties.metastring = codeNode.data?.meta;
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
};
|
|
298
298
|
async function createMDXOptions(docDirectory, config, checkDeadLinks, routeService, filepath, pluginDriver) {
|
|
299
|
+
const format = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(filepath).slice(1);
|
|
299
300
|
const cleanUrls = config?.route?.cleanUrls ?? false;
|
|
300
301
|
const { remarkPlugins: remarkPluginsFromConfig = [], rehypePlugins: rehypePluginsFromConfig = [], globalComponents: globalComponentsFromConfig = [] } = config?.markdown || {};
|
|
301
302
|
const rspressPlugins = pluginDriver.getPlugins();
|
|
@@ -307,7 +308,7 @@ async function createMDXOptions(docDirectory, config, checkDeadLinks, routeServi
|
|
|
307
308
|
];
|
|
308
309
|
return {
|
|
309
310
|
providerImportSource: '@mdx-js/react',
|
|
310
|
-
format
|
|
311
|
+
format,
|
|
311
312
|
remarkPlugins: [
|
|
312
313
|
__WEBPACK_EXTERNAL_MODULE_remark_gfm_073acf21__["default"],
|
|
313
314
|
remarkPluginToc,
|
|
@@ -338,7 +339,15 @@ async function createMDXOptions(docDirectory, config, checkDeadLinks, routeServi
|
|
|
338
339
|
].filter(Boolean),
|
|
339
340
|
rehypePlugins: [
|
|
340
341
|
rehypeHeaderAnchor,
|
|
341
|
-
|
|
342
|
+
...'md' === format ? [
|
|
343
|
+
rehypeCodeMeta,
|
|
344
|
+
[
|
|
345
|
+
__WEBPACK_EXTERNAL_MODULE_rehype_raw_434f4cf9__["default"],
|
|
346
|
+
{
|
|
347
|
+
passThrough: __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__.nodeTypes
|
|
348
|
+
}
|
|
349
|
+
]
|
|
350
|
+
] : [],
|
|
342
351
|
[
|
|
343
352
|
__WEBPACK_EXTERNAL_MODULE_rehype_external_links_09bed11a__["default"],
|
|
344
353
|
{
|
|
@@ -5,7 +5,7 @@ import * as __WEBPACK_EXTERNAL_MODULE__unhead_react_server_7e85c952__ from "@unh
|
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE_react_dom_server_98c38d5c__ from "react-dom/server";
|
|
6
6
|
import * as __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__ from "./App.js";
|
|
7
7
|
import * as __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__ from "./initPageData.js";
|
|
8
|
-
import * as
|
|
8
|
+
import * as __WEBPACK_EXTERNAL_MODULE_virtual_routes_98776429__ from "virtual-routes";
|
|
9
9
|
const DEFAULT_THEME = 'light';
|
|
10
10
|
async function render(pagePath, head) {
|
|
11
11
|
const initialPageData = await (0, __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__.initPageData)(pagePath);
|
|
@@ -31,5 +31,5 @@ async function render(pagePath, head) {
|
|
|
31
31
|
pageData: initialPageData
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
var __webpack_exports__routes =
|
|
34
|
+
var __webpack_exports__routes = __WEBPACK_EXTERNAL_MODULE_virtual_routes_98776429__.routes;
|
|
35
35
|
export { render, __webpack_exports__routes as routes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.9",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"react-lazy-with-preload": "^2.2.1",
|
|
64
64
|
"react-router-dom": "^6.29.0",
|
|
65
65
|
"rehype-external-links": "^3.0.0",
|
|
66
|
+
"rehype-raw": "^7.0.0",
|
|
66
67
|
"remark": "^15.0.1",
|
|
67
68
|
"remark-gfm": "^4.0.1",
|
|
68
69
|
"rspack-plugin-virtual-module": "1.0.1",
|
|
@@ -70,14 +71,14 @@
|
|
|
70
71
|
"unified": "^11.0.5",
|
|
71
72
|
"unist-util-visit": "^5.0.0",
|
|
72
73
|
"unist-util-visit-children": "^3.0.0",
|
|
73
|
-
"@rspress/plugin-
|
|
74
|
-
"@rspress/plugin-
|
|
75
|
-
"@rspress/plugin-
|
|
76
|
-
"@rspress/
|
|
77
|
-
"@rspress/
|
|
78
|
-
"@rspress/
|
|
79
|
-
"@rspress/
|
|
80
|
-
"@rspress/
|
|
74
|
+
"@rspress/plugin-container-syntax": "2.0.0-beta.9",
|
|
75
|
+
"@rspress/plugin-auto-nav-sidebar": "2.0.0-beta.9",
|
|
76
|
+
"@rspress/plugin-last-updated": "2.0.0-beta.9",
|
|
77
|
+
"@rspress/plugin-medium-zoom": "2.0.0-beta.9",
|
|
78
|
+
"@rspress/runtime": "2.0.0-beta.9",
|
|
79
|
+
"@rspress/plugin-shiki": "2.0.0-beta.9",
|
|
80
|
+
"@rspress/shared": "2.0.0-beta.9",
|
|
81
|
+
"@rspress/theme-default": "2.0.0-beta.9"
|
|
81
82
|
},
|
|
82
83
|
"devDependencies": {
|
|
83
84
|
"@microsoft/api-extractor": "^7.52.8",
|