@rspress/core 1.41.0 → 1.41.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/193.js +12 -0
- package/dist/index.d.ts +39 -31
- package/dist/index.js +1702 -2175
- package/dist/loader.d.ts +78 -70
- package/dist/loader.js +550 -682
- package/dist/runtime/App.js +106 -132
- package/dist/runtime/clientEntry.js +71 -54
- package/dist/runtime/ssrEntry.js +30 -19
- package/dist/runtime/tsconfig.js +4 -0
- package/package.json +16 -18
- package/src/runtime/App.tsx +5 -2
- package/dist/index.js.map +0 -1
- package/dist/loader.js.map +0 -1
- package/dist/runtime/tsconfig.json +0 -10
- package/loader.cjs +0 -8
package/dist/runtime/App.js
CHANGED
|
@@ -1,139 +1,113 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
MDX_REGEXP,
|
|
11
|
-
cleanUrl
|
|
12
|
-
} from "@rspress/shared";
|
|
13
|
-
import Theme from "@theme";
|
|
14
|
-
import React, { useContext, useLayoutEffect } from "react";
|
|
15
|
-
import { HelmetProvider } from "react-helmet-async";
|
|
16
|
-
import globalComponents from "virtual-global-components";
|
|
17
|
-
import siteData from "virtual-site-data";
|
|
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__rspress_shared_baa012d0__ from "@rspress/shared";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__theme_75e53063__ from "@theme";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__ from "react-helmet-async";
|
|
7
|
+
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";
|
|
18
9
|
import "virtual-global-styles";
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
10
|
+
var App_rslib_entry_QueryStatus = /*#__PURE__*/ function(QueryStatus) {
|
|
11
|
+
QueryStatus["Show"] = "1";
|
|
12
|
+
QueryStatus["Hide"] = "0";
|
|
13
|
+
return QueryStatus;
|
|
14
|
+
}({});
|
|
24
15
|
async function initPageData(routePath) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
pageType: frontmatter?.pageType || "doc",
|
|
53
|
-
title,
|
|
54
|
-
frontmatter,
|
|
55
|
-
toc
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
let lang = siteData.lang || "";
|
|
60
|
-
let version = siteData.multiVersion?.default || "";
|
|
61
|
-
if (siteData.lang && typeof window !== "undefined") {
|
|
62
|
-
const path = location.pathname.replace(siteData.base, "").split("/").slice(0, 2);
|
|
63
|
-
if (siteData.locales.length) {
|
|
64
|
-
const result = siteData.locales.find(({ lang: lang2 }) => path.includes(lang2));
|
|
65
|
-
if (result) {
|
|
66
|
-
lang = result.lang;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (siteData.multiVersion.versions) {
|
|
70
|
-
const result = siteData.multiVersion.versions.find(
|
|
71
|
-
(version2) => path.includes(version2)
|
|
72
|
-
);
|
|
73
|
-
if (result) {
|
|
74
|
-
version = result;
|
|
75
|
-
}
|
|
16
|
+
var _siteData_multiVersion;
|
|
17
|
+
const { routes } = process.env.__SSR__ ? await import("virtual-routes-ssr") : await import("virtual-routes");
|
|
18
|
+
const matched = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.matchRoutes)(routes, routePath);
|
|
19
|
+
if (matched) {
|
|
20
|
+
var _mod_default___RSPRESS_PAGE_META;
|
|
21
|
+
const matchedRoute = matched[0].route;
|
|
22
|
+
const mod = await matchedRoute.preload();
|
|
23
|
+
const pagePath = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.cleanUrl)(matched[0].route.filePath);
|
|
24
|
+
const extractPageInfo = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].pages.find((page)=>{
|
|
25
|
+
const normalize = (p)=>p.replace(/\/$/, '').toLowerCase();
|
|
26
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.isEqualPath)(normalize(page.routePath), normalize(routePath));
|
|
27
|
+
});
|
|
28
|
+
const encodedPagePath = encodeURIComponent(pagePath);
|
|
29
|
+
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]) || {};
|
|
30
|
+
const { toc = [], title = '', frontmatter = {}, ...rest } = __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_REGEXP.test(matchedRoute.filePath) ? meta : mod;
|
|
31
|
+
return {
|
|
32
|
+
siteData: __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"],
|
|
33
|
+
page: {
|
|
34
|
+
...rest,
|
|
35
|
+
pagePath,
|
|
36
|
+
...extractPageInfo,
|
|
37
|
+
pageType: (null == frontmatter ? void 0 : frontmatter.pageType) || 'doc',
|
|
38
|
+
title,
|
|
39
|
+
frontmatter,
|
|
40
|
+
toc
|
|
41
|
+
}
|
|
42
|
+
};
|
|
76
43
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
_filepath: "",
|
|
90
|
-
_relativePath: ""
|
|
44
|
+
let lang = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang || '';
|
|
45
|
+
let version = (null === (_siteData_multiVersion = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].multiVersion) || void 0 === _siteData_multiVersion ? void 0 : _siteData_multiVersion.default) || '';
|
|
46
|
+
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang && 'undefined' != typeof window) {
|
|
47
|
+
const path = location.pathname.replace(__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].base, '').split('/').slice(0, 2);
|
|
48
|
+
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].locales.length) {
|
|
49
|
+
const result = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].locales.find(({ lang })=>path.includes(lang));
|
|
50
|
+
if (result) lang = result.lang;
|
|
51
|
+
}
|
|
52
|
+
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].multiVersion.versions) {
|
|
53
|
+
const result = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].multiVersion.versions.find((version)=>path.includes(version));
|
|
54
|
+
if (result) version = result;
|
|
55
|
+
}
|
|
91
56
|
}
|
|
92
|
-
|
|
57
|
+
return {
|
|
58
|
+
siteData: __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"],
|
|
59
|
+
page: {
|
|
60
|
+
pagePath: '',
|
|
61
|
+
pageType: '404',
|
|
62
|
+
routePath: '/404',
|
|
63
|
+
lang,
|
|
64
|
+
frontmatter: {},
|
|
65
|
+
title: '404',
|
|
66
|
+
toc: [],
|
|
67
|
+
version,
|
|
68
|
+
_filepath: '',
|
|
69
|
+
_relativePath: ''
|
|
70
|
+
}
|
|
71
|
+
};
|
|
93
72
|
}
|
|
94
73
|
function App({ helmetContext }) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
})
|
|
133
|
-
] });
|
|
74
|
+
const { setData: setPageData, data } = (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.DataContext);
|
|
75
|
+
const frontmatter = data.page.frontmatter || {};
|
|
76
|
+
const { pathname, search } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useLocation)();
|
|
77
|
+
const query = new URLSearchParams(search);
|
|
78
|
+
const GLOBAL_COMPONENTS_KEY = 'globalUIComponents';
|
|
79
|
+
const hideGlobalUIComponents = false === frontmatter[GLOBAL_COMPONENTS_KEY] || "0" === query.get(GLOBAL_COMPONENTS_KEY);
|
|
80
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useLayoutEffect)(()=>{
|
|
81
|
+
async function refetchData() {
|
|
82
|
+
try {
|
|
83
|
+
const pageData = await initPageData((0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.normalizeRoutePath)(pathname));
|
|
84
|
+
setPageData(pageData);
|
|
85
|
+
} catch (e) {
|
|
86
|
+
console.log(e);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
refetchData();
|
|
90
|
+
}, [
|
|
91
|
+
pathname,
|
|
92
|
+
setPageData
|
|
93
|
+
]);
|
|
94
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__.HelmetProvider, {
|
|
95
|
+
context: helmetContext,
|
|
96
|
+
children: [
|
|
97
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__theme_75e53063__["default"].Layout, {}),
|
|
98
|
+
!hideGlobalUIComponents && __WEBPACK_EXTERNAL_MODULE_virtual_global_components_43dbb356__["default"].map((componentInfo, index)=>{
|
|
99
|
+
if (Array.isArray(componentInfo)) {
|
|
100
|
+
const [component, props] = componentInfo;
|
|
101
|
+
return /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(component, {
|
|
102
|
+
key: index,
|
|
103
|
+
...props
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(componentInfo, {
|
|
107
|
+
key: index
|
|
108
|
+
});
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
});
|
|
134
112
|
}
|
|
135
|
-
export {
|
|
136
|
-
App,
|
|
137
|
-
QueryStatus,
|
|
138
|
-
initPageData
|
|
139
|
-
};
|
|
113
|
+
export { App, App_rslib_entry_QueryStatus as QueryStatus, initPageData };
|
|
@@ -1,60 +1,77 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__theme_75e53063__ from "@theme";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_dom_7136dc57__ from "react-dom";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_dom_client_76b1397c__ from "react-dom/client";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress/runtime";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
|
|
7
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
8
|
+
import * as __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__ from "virtual-site-data";
|
|
9
|
+
import * as __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__ from "./App.js";
|
|
10
|
+
var __webpack_modules__ = {
|
|
11
|
+
"@theme": function(module) {
|
|
12
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__theme_75e53063__;
|
|
13
|
+
},
|
|
14
|
+
"react-dom": function(module) {
|
|
15
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_react_dom_7136dc57__;
|
|
16
|
+
},
|
|
17
|
+
"react-dom/client": function(module) {
|
|
18
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_react_dom_client_76b1397c__;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var __webpack_module_cache__ = {};
|
|
22
|
+
function __webpack_require__(moduleId) {
|
|
23
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
24
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
25
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
26
|
+
exports: {}
|
|
27
|
+
};
|
|
28
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
29
|
+
return module.exports;
|
|
30
|
+
}
|
|
31
|
+
const enableSSG = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].ssg;
|
|
32
|
+
const { default: Theme, useThemeState } = __webpack_require__("@theme");
|
|
14
33
|
async function renderInBrowser() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const container = document.getElementById('root');
|
|
35
|
+
const enhancedApp = async ()=>{
|
|
36
|
+
const initialPageData = await (0, __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.initPageData)((0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.normalizeRoutePath)(window.location.pathname));
|
|
37
|
+
return function() {
|
|
38
|
+
const [data, setData] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(initialPageData);
|
|
39
|
+
const [theme, setTheme] = useThemeState();
|
|
40
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.ThemeContext.Provider, {
|
|
41
|
+
value: (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
42
|
+
theme,
|
|
43
|
+
setTheme
|
|
44
|
+
}), [
|
|
45
|
+
theme,
|
|
46
|
+
setTheme
|
|
47
|
+
]),
|
|
48
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.DataContext.Provider, {
|
|
49
|
+
value: (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
50
|
+
data,
|
|
51
|
+
setData
|
|
52
|
+
}), [
|
|
53
|
+
data,
|
|
54
|
+
setData
|
|
55
|
+
]),
|
|
56
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.BrowserRouter, {
|
|
57
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.App, {})
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
};
|
|
36
62
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
hydrateRoot(container, /* @__PURE__ */ jsx(RootApp, {}));
|
|
63
|
+
const RootApp = await enhancedApp();
|
|
64
|
+
if (process.env.__REACT_GTE_18__) {
|
|
65
|
+
const { createRoot, hydrateRoot } = __webpack_require__("react-dom/client");
|
|
66
|
+
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)() && enableSSG) hydrateRoot(container, /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(RootApp, {}));
|
|
67
|
+
else createRoot(container).render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(RootApp, {}));
|
|
43
68
|
} else {
|
|
44
|
-
|
|
69
|
+
const ReactDOM = __webpack_require__("react-dom");
|
|
70
|
+
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)()) ReactDOM.hydrate(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(RootApp, {}), container);
|
|
71
|
+
else ReactDOM.render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(RootApp, {}), container);
|
|
45
72
|
}
|
|
46
|
-
} else {
|
|
47
|
-
const ReactDOM = require("react-dom");
|
|
48
|
-
if (isProduction()) {
|
|
49
|
-
ReactDOM.hydrate(/* @__PURE__ */ jsx(RootApp, {}), container);
|
|
50
|
-
} else {
|
|
51
|
-
ReactDOM.render(/* @__PURE__ */ jsx(RootApp, {}), container);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
73
|
}
|
|
55
|
-
renderInBrowser().then(()
|
|
56
|
-
|
|
74
|
+
renderInBrowser().then(()=>{
|
|
75
|
+
Theme.setup();
|
|
57
76
|
});
|
|
58
|
-
export {
|
|
59
|
-
renderInBrowser
|
|
60
|
-
};
|
|
77
|
+
export { renderInBrowser };
|
package/dist/runtime/ssrEntry.js
CHANGED
|
@@ -1,21 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
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__rspress_runtime_server_673c713a__ from "@rspress/runtime/server";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_dom_server_98c38d5c__ from "react-dom/server";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__ from "./App.js";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE_virtual_routes_ssr_f802e6e5__ from "virtual-routes-ssr";
|
|
7
|
+
const DEFAULT_THEME = 'light';
|
|
7
8
|
async function render(pagePath, helmetContext) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
const initialPageData = await (0, __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.initPageData)(pagePath);
|
|
10
|
+
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
|
+
value: {
|
|
12
|
+
theme: DEFAULT_THEME
|
|
13
|
+
},
|
|
14
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.DataContext.Provider, {
|
|
15
|
+
value: {
|
|
16
|
+
data: initialPageData
|
|
17
|
+
},
|
|
18
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_server_673c713a__.StaticRouter, {
|
|
19
|
+
location: pagePath,
|
|
20
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.App, {
|
|
21
|
+
helmetContext: helmetContext
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
}));
|
|
26
|
+
return {
|
|
27
|
+
appHtml,
|
|
28
|
+
pageData: initialPageData
|
|
29
|
+
};
|
|
16
30
|
}
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
render,
|
|
20
|
-
routes
|
|
21
|
-
};
|
|
31
|
+
var __webpack_exports__routes = __WEBPACK_EXTERNAL_MODULE_virtual_routes_ssr_f802e6e5__.routes;
|
|
32
|
+
export { render, __webpack_exports__routes as routes };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var tsconfig_rslib_entry_namespaceObject = JSON.parse('{"compilerOptions":{"rootDir":".","baseUrl":".","skipLibCheck":true,"jsx":"react-jsx","esModuleInterop":true},"include":["./**/*"]}');
|
|
2
|
+
var __webpack_exports__compilerOptions = tsconfig_rslib_entry_namespaceObject.compilerOptions;
|
|
3
|
+
var __webpack_exports__include = tsconfig_rslib_entry_namespaceObject.include;
|
|
4
|
+
export { __webpack_exports__compilerOptions as compilerOptions, __webpack_exports__include as include };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/core",
|
|
3
|
-
"version": "1.41.
|
|
3
|
+
"version": "1.41.2",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -44,9 +44,7 @@
|
|
|
44
44
|
"src/shared",
|
|
45
45
|
"index.html",
|
|
46
46
|
"runtime.ts",
|
|
47
|
-
"theme.ts"
|
|
48
|
-
"loader.cjs",
|
|
49
|
-
"compiled"
|
|
47
|
+
"theme.ts"
|
|
50
48
|
],
|
|
51
49
|
"dependencies": {
|
|
52
50
|
"@mdx-js/loader": "2.3.0",
|
|
@@ -66,6 +64,7 @@
|
|
|
66
64
|
"lodash-es": "^4.17.21",
|
|
67
65
|
"mdast-util-mdxjs-esm": "^1.3.1",
|
|
68
66
|
"memfs": "^4.17.0",
|
|
67
|
+
"picocolors": "^1.1.1",
|
|
69
68
|
"react": "^18.3.1",
|
|
70
69
|
"react-dom": "^18.3.1",
|
|
71
70
|
"react-helmet-async": "^1.3.0",
|
|
@@ -79,17 +78,18 @@
|
|
|
79
78
|
"unified": "^10.1.2",
|
|
80
79
|
"unist-util-visit": "^4.1.2",
|
|
81
80
|
"unist-util-visit-children": "^3.0.0",
|
|
82
|
-
"@rspress/plugin-
|
|
83
|
-
"@rspress/plugin-
|
|
84
|
-
"@rspress/plugin-last-updated": "1.41.
|
|
85
|
-
"@rspress/
|
|
86
|
-
"@rspress/
|
|
87
|
-
"@rspress/
|
|
88
|
-
"@rspress/
|
|
81
|
+
"@rspress/plugin-auto-nav-sidebar": "1.41.2",
|
|
82
|
+
"@rspress/plugin-container-syntax": "1.41.2",
|
|
83
|
+
"@rspress/plugin-last-updated": "1.41.2",
|
|
84
|
+
"@rspress/runtime": "1.41.2",
|
|
85
|
+
"@rspress/plugin-medium-zoom": "1.41.2",
|
|
86
|
+
"@rspress/theme-default": "1.41.2",
|
|
87
|
+
"@rspress/shared": "1.41.2"
|
|
89
88
|
},
|
|
90
89
|
"devDependencies": {
|
|
91
|
-
"@
|
|
90
|
+
"@microsoft/api-extractor": "^7.49.2",
|
|
92
91
|
"@modern-js/tsconfig": "2.64.0",
|
|
92
|
+
"@rslib/core": "0.4.1",
|
|
93
93
|
"@types/hast": "3.0.4",
|
|
94
94
|
"@types/html-to-text": "^9.0.4",
|
|
95
95
|
"@types/jest": "~29.5.14",
|
|
@@ -104,8 +104,7 @@
|
|
|
104
104
|
"remark-rehype": "^10.1.0",
|
|
105
105
|
"rimraf": "^3.0.2",
|
|
106
106
|
"tailwindcss": "^3.4.17",
|
|
107
|
-
"typescript": "^5.5.3"
|
|
108
|
-
"vitest": "2.1.9"
|
|
107
|
+
"typescript": "^5.5.3"
|
|
109
108
|
},
|
|
110
109
|
"engines": {
|
|
111
110
|
"node": ">=14.17.6"
|
|
@@ -117,9 +116,8 @@
|
|
|
117
116
|
},
|
|
118
117
|
"jsnext:source": "./src/index.ts",
|
|
119
118
|
"scripts": {
|
|
120
|
-
"build": "
|
|
121
|
-
"dev": "
|
|
122
|
-
"reset": "rimraf ./**/node_modules"
|
|
123
|
-
"test": "vitest run --passWithNoTests"
|
|
119
|
+
"build": "rslib build",
|
|
120
|
+
"dev": "rslib build -w",
|
|
121
|
+
"reset": "rimraf ./**/node_modules"
|
|
124
122
|
}
|
|
125
123
|
}
|
package/src/runtime/App.tsx
CHANGED
|
@@ -32,8 +32,11 @@ type PageMeta = {
|
|
|
32
32
|
|
|
33
33
|
export async function initPageData(routePath: string): Promise<PageData> {
|
|
34
34
|
const { routes } = process.env.__SSR__
|
|
35
|
-
?
|
|
36
|
-
|
|
35
|
+
? // biome-ignore format: Biome format will add an extra comma.
|
|
36
|
+
((await import('virtual-routes-ssr')) as typeof import(
|
|
37
|
+
'virtual-routes-ssr'
|
|
38
|
+
))
|
|
39
|
+
: ((await import('virtual-routes')) as typeof import('virtual-routes'));
|
|
37
40
|
const matched = matchRoutes(routes, routePath)!;
|
|
38
41
|
if (matched) {
|
|
39
42
|
// Preload route component
|