@rspress/runtime 2.0.0-beta.8 → 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/dist/Content.js +12 -4
- package/dist/route.js +2 -2
- package/package.json +3 -4
package/dist/Content.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
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";
|
2
3
|
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
3
4
|
import * as __WEBPACK_EXTERNAL_MODULE_react_router_dom_5358f3fe__ from "react-router-dom";
|
4
5
|
import * as __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__ from "virtual-site-data";
|
@@ -12,13 +13,20 @@ function TransitionContentImpl(props) {
|
|
12
13
|
const TransitionContent = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.memo)(TransitionContentImpl, (prevProps, nextProps)=>prevProps.el === nextProps.el);
|
13
14
|
const Content = ({ fallback = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {}) })=>{
|
14
15
|
const { pathname } = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom_5358f3fe__.useLocation)();
|
15
|
-
const
|
16
|
-
|
17
|
-
|
16
|
+
const matchedElement = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
|
17
|
+
const route = (0, __WEBPACK_EXTERNAL_MODULE__route_js_d0361f8a__.pathnameToRouteService)(pathname);
|
18
|
+
return route?.element;
|
19
|
+
}, [
|
20
|
+
pathname
|
21
|
+
]);
|
22
|
+
if (!matchedElement) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {});
|
23
|
+
if (!(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.inBrowser)()) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(TransitionContent, {
|
24
|
+
el: matchedElement
|
25
|
+
});
|
18
26
|
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react__.Suspense, {
|
19
27
|
fallback: fallback,
|
20
28
|
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(TransitionContent, {
|
21
|
-
el:
|
29
|
+
el: matchedElement
|
22
30
|
})
|
23
31
|
});
|
24
32
|
};
|
package/dist/route.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import * as __WEBPACK_EXTERNAL_MODULE__VIRTUAL_ROUTES__3c8bd3e0__ from "__VIRTUAL_ROUTES__";
|
2
1
|
import * as __WEBPACK_EXTERNAL_MODULE_react_router_dom_5358f3fe__ from "react-router-dom";
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_virtual_routes_98776429__ from "virtual-routes";
|
3
3
|
function normalizeRoutePath(routePath) {
|
4
4
|
return decodeURIComponent(routePath).replace(/\.html$/, '').replace(/\/index$/, '/');
|
5
5
|
}
|
@@ -7,7 +7,7 @@ const cache = new Map();
|
|
7
7
|
function pathnameToRouteService(pathname) {
|
8
8
|
const cacheItem = cache.get(pathname);
|
9
9
|
if (cacheItem) return cacheItem;
|
10
|
-
const matched = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom_5358f3fe__.matchRoutes)(
|
10
|
+
const matched = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom_5358f3fe__.matchRoutes)(__WEBPACK_EXTERNAL_MODULE_virtual_routes_98776429__.routes, normalizeRoutePath(pathname));
|
11
11
|
const route = matched?.[0]?.route;
|
12
12
|
if (route) cache.set(pathname, route);
|
13
13
|
return route;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rspress/runtime",
|
3
|
-
"version": "2.0.0-beta.
|
3
|
+
"version": "2.0.0-beta.9",
|
4
4
|
"description": "The Runtime of Rspress Documentation Framework",
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
6
6
|
"repository": {
|
@@ -15,8 +15,7 @@
|
|
15
15
|
"*.sass",
|
16
16
|
"*.scss",
|
17
17
|
"**/virtual-global-styles.js",
|
18
|
-
"virtual-global-styles"
|
19
|
-
"./src/theme-default/styles/index.ts"
|
18
|
+
"virtual-global-styles"
|
20
19
|
],
|
21
20
|
"type": "module",
|
22
21
|
"exports": {
|
@@ -40,7 +39,7 @@
|
|
40
39
|
"react": "^19.1.0",
|
41
40
|
"react-dom": "^19.1.0",
|
42
41
|
"react-router-dom": "^6.29.0",
|
43
|
-
"@rspress/shared": "2.0.0-beta.
|
42
|
+
"@rspress/shared": "2.0.0-beta.9"
|
44
43
|
},
|
45
44
|
"devDependencies": {
|
46
45
|
"@rsbuild/plugin-react": "~1.3.1",
|