@umijs/renderer-react 4.0.56 → 4.0.58
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/LICENSE +21 -0
- package/dist/appContext.js +4 -9
- package/dist/link.js +3 -6
- package/dist/routes.js +10 -22
- package/dist/useFetcher.js +1 -2
- package/dist/withRouter.js +0 -1
- package/package.json +9 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-present ChenCheng (sorrycc@gmail.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/dist/appContext.js
CHANGED
|
@@ -9,23 +9,18 @@ export function useAppData() {
|
|
|
9
9
|
}
|
|
10
10
|
export function useSelectedRoutes() {
|
|
11
11
|
var location = useLocation();
|
|
12
|
-
|
|
13
12
|
var _useAppData = useAppData(),
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
clientRoutes = _useAppData.clientRoutes;
|
|
14
|
+
// use `useLocation` get location without `basename`, not need `basename` param
|
|
17
15
|
var routes = matchRoutes(clientRoutes, location.pathname);
|
|
18
16
|
return routes || [];
|
|
19
17
|
}
|
|
20
18
|
export function useRouteProps() {
|
|
21
19
|
var _currentRoute$;
|
|
22
|
-
|
|
23
20
|
var currentRoute = useSelectedRoutes().slice(-1);
|
|
24
|
-
|
|
25
21
|
var _ref = ((_currentRoute$ = currentRoute[0]) === null || _currentRoute$ === void 0 ? void 0 : _currentRoute$.route) || {},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
_ = _ref.element,
|
|
23
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
29
24
|
return props;
|
|
30
25
|
}
|
|
31
26
|
export function useServerLoaderData() {
|
package/dist/link.js
CHANGED
|
@@ -6,19 +6,16 @@ import { Link } from 'react-router-dom';
|
|
|
6
6
|
import { useAppData } from "./appContext";
|
|
7
7
|
export function LinkWithPrefetch(props) {
|
|
8
8
|
var _props$to;
|
|
9
|
-
|
|
10
9
|
var prefetch = props.prefetch,
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
linkProps = _objectWithoutProperties(props, _excluded);
|
|
13
11
|
var appData = useAppData();
|
|
14
|
-
var to = typeof props.to === 'string' ? props.to : (_props$to = props.to) === null || _props$to === void 0 ? void 0 : _props$to.pathname;
|
|
12
|
+
var to = typeof props.to === 'string' ? props.to : (_props$to = props.to) === null || _props$to === void 0 ? void 0 : _props$to.pathname;
|
|
13
|
+
// compatible with old code
|
|
15
14
|
// which to might be undefined
|
|
16
|
-
|
|
17
15
|
if (!to) return null;
|
|
18
16
|
return /*#__PURE__*/React.createElement(Link, _extends({
|
|
19
17
|
onMouseEnter: function onMouseEnter() {
|
|
20
18
|
var _appData$preloadRoute;
|
|
21
|
-
|
|
22
19
|
return prefetch && to && ((_appData$preloadRoute = appData.preloadRoute) === null || _appData$preloadRoute === void 0 ? void 0 : _appData$preloadRoute.call(appData, to));
|
|
23
20
|
}
|
|
24
21
|
}, linkProps), props.children);
|
package/dist/routes.js
CHANGED
|
@@ -9,8 +9,8 @@ import { RouteContext, useRouteData } from "./routeContext";
|
|
|
9
9
|
import { useAppData } from "./appContext";
|
|
10
10
|
export function createClientRoutes(opts) {
|
|
11
11
|
var routesById = opts.routesById,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
parentId = opts.parentId,
|
|
13
|
+
routeComponents = opts.routeComponents;
|
|
14
14
|
return Object.keys(routesById).filter(function (id) {
|
|
15
15
|
return routesById[id].parentId === parentId;
|
|
16
16
|
}).map(function (id) {
|
|
@@ -32,36 +32,28 @@ export function createClientRoutes(opts) {
|
|
|
32
32
|
loadingComponent: opts.loadingComponent,
|
|
33
33
|
reactRouter5Compat: opts.reactRouter5Compat
|
|
34
34
|
});
|
|
35
|
-
|
|
36
35
|
if (children.length > 0) {
|
|
37
|
-
route.children = children;
|
|
36
|
+
route.children = children;
|
|
37
|
+
// TODO: remove me
|
|
38
38
|
// compatible with @ant-design/pro-layout
|
|
39
|
-
|
|
40
39
|
route.routes = children;
|
|
41
40
|
}
|
|
42
|
-
|
|
43
41
|
return route;
|
|
44
42
|
});
|
|
45
43
|
}
|
|
46
|
-
|
|
47
44
|
function NavigateWithParams(props) {
|
|
48
45
|
var params = useParams();
|
|
49
|
-
|
|
50
46
|
var propsWithParams = _objectSpread(_objectSpread({}, props), {}, {
|
|
51
47
|
to: generatePath(props.to, params)
|
|
52
48
|
});
|
|
53
|
-
|
|
54
49
|
return /*#__PURE__*/React.createElement(Navigate, _extends({
|
|
55
50
|
replace: true
|
|
56
51
|
}, propsWithParams));
|
|
57
52
|
}
|
|
58
|
-
|
|
59
53
|
function createClientRoute(opts) {
|
|
60
54
|
var route = opts.route;
|
|
61
|
-
|
|
62
55
|
var redirect = route.redirect,
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
props = _objectWithoutProperties(route, _excluded);
|
|
65
57
|
var Remote = opts.reactRouter5Compat ? RemoteComponentReactRouter5 : RemoteComponent;
|
|
66
58
|
return _objectSpread({
|
|
67
59
|
element: redirect ? /*#__PURE__*/React.createElement(NavigateWithParams, {
|
|
@@ -77,27 +69,24 @@ function createClientRoute(opts) {
|
|
|
77
69
|
}))
|
|
78
70
|
}, props);
|
|
79
71
|
}
|
|
80
|
-
|
|
81
72
|
function DefaultLoading() {
|
|
82
73
|
return /*#__PURE__*/React.createElement("div", null);
|
|
83
74
|
}
|
|
84
|
-
|
|
85
75
|
function RemoteComponentReactRouter5(props) {
|
|
86
76
|
var _useRouteData = useRouteData(),
|
|
87
|
-
|
|
88
|
-
|
|
77
|
+
route = _useRouteData.route;
|
|
89
78
|
var _useAppData = useAppData(),
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
79
|
+
history = _useAppData.history,
|
|
80
|
+
clientRoutes = _useAppData.clientRoutes;
|
|
93
81
|
var params = useParams();
|
|
94
82
|
var match = {
|
|
95
83
|
params: params,
|
|
96
84
|
isExact: true,
|
|
97
85
|
path: route.path,
|
|
98
86
|
url: history.location.pathname
|
|
99
|
-
};
|
|
87
|
+
};
|
|
100
88
|
|
|
89
|
+
// staticContext 没有兼容 好像没看到对应的兼容写法
|
|
101
90
|
var Component = props.loader;
|
|
102
91
|
return /*#__PURE__*/React.createElement(React.Suspense, {
|
|
103
92
|
fallback: /*#__PURE__*/React.createElement(props.loadingComponent, null)
|
|
@@ -110,7 +99,6 @@ function RemoteComponentReactRouter5(props) {
|
|
|
110
99
|
routes: clientRoutes
|
|
111
100
|
}, props.hasChildren && /*#__PURE__*/React.createElement(Outlet, null)));
|
|
112
101
|
}
|
|
113
|
-
|
|
114
102
|
function RemoteComponent(props) {
|
|
115
103
|
var Component = props.loader;
|
|
116
104
|
return /*#__PURE__*/React.createElement(React.Suspense, {
|
package/dist/useFetcher.js
CHANGED
|
@@ -2,8 +2,7 @@ import { useLocation } from 'react-router-dom';
|
|
|
2
2
|
import { useAppData } from "./appContext";
|
|
3
3
|
export function __useFetcher() {
|
|
4
4
|
var _useAppData = useAppData(),
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
preloadRoute = _useAppData.preloadRoute;
|
|
7
6
|
var location = useLocation();
|
|
8
7
|
return {
|
|
9
8
|
load: function load(path) {
|
package/dist/withRouter.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/renderer-react",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.58",
|
|
4
4
|
"description": "@umijs/renderer-react",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/renderer-react#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -15,12 +15,6 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
|
-
"scripts": {
|
|
19
|
-
"build": "umi-scripts father build",
|
|
20
|
-
"build:deps": "umi-scripts bundleDeps",
|
|
21
|
-
"dev": "umi-scripts father dev",
|
|
22
|
-
"test": "umi-scripts jest-turbo"
|
|
23
|
-
},
|
|
24
18
|
"dependencies": {
|
|
25
19
|
"@babel/runtime": "7.21.0",
|
|
26
20
|
"@loadable/component": "5.15.2",
|
|
@@ -41,5 +35,11 @@
|
|
|
41
35
|
},
|
|
42
36
|
"authors": [
|
|
43
37
|
"chencheng <sorrycc@gmail.com> (https://github.com/sorrycc)"
|
|
44
|
-
]
|
|
45
|
-
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "umi-scripts father build",
|
|
41
|
+
"build:deps": "umi-scripts bundleDeps",
|
|
42
|
+
"dev": "umi-scripts father dev",
|
|
43
|
+
"test": "umi-scripts jest-turbo"
|
|
44
|
+
}
|
|
45
|
+
}
|