@umijs/renderer-react 4.0.0-canary.20230223.1 → 4.0.0-canary.20230227.1
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/browser.js +59 -86
- package/dist/link.js +3 -6
- package/dist/routes.js +10 -22
- package/dist/server.js +45 -50
- package/dist/useFetcher.js +1 -2
- package/dist/withRouter.js +0 -1
- package/package.json +2 -2
package/dist/browser.js
CHANGED
|
@@ -1,36 +1,34 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
4
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
|
-
import React, { useCallback, useEffect, useLayoutEffect, useState } from 'react';
|
|
6
|
-
|
|
4
|
+
import React, { useCallback, useEffect, useLayoutEffect, useState } from 'react';
|
|
5
|
+
// compatible with < react@18 in @umijs/preset-umi/src/features/react
|
|
7
6
|
import { HelmetProvider } from 'react-helmet-async';
|
|
8
7
|
import ReactDOM from 'react-dom/client';
|
|
9
8
|
import { matchRoutes, Router, useRoutes } from 'react-router-dom';
|
|
10
9
|
import { AppContext, useAppData } from "./appContext";
|
|
11
10
|
import { createClientRoutes } from "./routes";
|
|
12
|
-
var root = null;
|
|
11
|
+
var root = null;
|
|
13
12
|
|
|
13
|
+
// react 18 some scenarios need unmount such as micro app
|
|
14
14
|
export function __getRoot() {
|
|
15
15
|
return root;
|
|
16
16
|
}
|
|
17
|
+
|
|
17
18
|
/**
|
|
18
19
|
* 这个组件的功能是 history 发生改变的时候重新触发渲染
|
|
19
20
|
* @param props
|
|
20
21
|
* @returns
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
23
|
function BrowserRoutes(props) {
|
|
24
24
|
var history = props.history;
|
|
25
|
-
|
|
26
25
|
var _React$useState = React.useState({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
action: history.action,
|
|
27
|
+
location: history.location
|
|
28
|
+
}),
|
|
29
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
30
|
+
state = _React$useState2[0],
|
|
31
|
+
setState = _React$useState2[1];
|
|
34
32
|
useLayoutEffect(function () {
|
|
35
33
|
return history.listen(setState);
|
|
36
34
|
}, [history]);
|
|
@@ -48,7 +46,6 @@ function BrowserRoutes(props) {
|
|
|
48
46
|
}
|
|
49
47
|
});
|
|
50
48
|
}
|
|
51
|
-
|
|
52
49
|
history.listen(onRouteChange);
|
|
53
50
|
onRouteChange({
|
|
54
51
|
location: state.location,
|
|
@@ -61,13 +58,12 @@ function BrowserRoutes(props) {
|
|
|
61
58
|
basename: props.basename
|
|
62
59
|
}, props.children);
|
|
63
60
|
}
|
|
64
|
-
|
|
65
61
|
export function Routes() {
|
|
66
62
|
var _useAppData = useAppData(),
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
clientRoutes = _useAppData.clientRoutes;
|
|
69
64
|
return useRoutes(clientRoutes);
|
|
70
65
|
}
|
|
66
|
+
|
|
71
67
|
/**
|
|
72
68
|
* umi 渲染需要的配置,在node端调用的哦
|
|
73
69
|
*/
|
|
@@ -75,15 +71,16 @@ export function Routes() {
|
|
|
75
71
|
/**
|
|
76
72
|
* umi max 所需要的所有插件列表,用于获取provide
|
|
77
73
|
*/
|
|
78
|
-
var UMI_CLIENT_RENDER_REACT_PLUGIN_LIST = [
|
|
74
|
+
var UMI_CLIENT_RENDER_REACT_PLUGIN_LIST = [
|
|
75
|
+
// Lowest to the highest priority
|
|
79
76
|
'innerProvider', 'i18nProvider', 'accessProvider', 'dataflowProvider', 'outerProvider', 'rootContainer'];
|
|
77
|
+
|
|
80
78
|
/**
|
|
81
79
|
*
|
|
82
80
|
* @param {RenderClientOpts} opts - 插件相关的配置
|
|
83
81
|
* @param {React.ReactElement} routesElement 需要渲染的 routers,为了方便测试注入才导出
|
|
84
82
|
* @returns @returns A function that returns a React component.
|
|
85
83
|
*/
|
|
86
|
-
|
|
87
84
|
var getBrowser = function getBrowser(opts, routesElement) {
|
|
88
85
|
var basename = opts.basename || '/';
|
|
89
86
|
var clientRoutes = createClientRoutes({
|
|
@@ -105,67 +102,54 @@ var getBrowser = function getBrowser(opts, routesElement) {
|
|
|
105
102
|
routes: opts.routes,
|
|
106
103
|
clientRoutes: clientRoutes,
|
|
107
104
|
history: opts.history
|
|
108
|
-
}, routesElement);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
rootContainer
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
plugin: opts.pluginManager
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* umi 增加完 Provide 的 react dom,可以直接交给 react-dom 渲染
|
|
129
|
-
* @returns {React.ReactElement}
|
|
130
|
-
*/
|
|
131
|
-
|
|
132
|
-
} catch (err) {
|
|
133
|
-
_iterator.e(err);
|
|
134
|
-
} finally {
|
|
135
|
-
_iterator.f();
|
|
105
|
+
}, routesElement);
|
|
106
|
+
|
|
107
|
+
// 加载所有需要的插件
|
|
108
|
+
for (var _i = 0, _UMI_CLIENT_RENDER_RE = UMI_CLIENT_RENDER_REACT_PLUGIN_LIST; _i < _UMI_CLIENT_RENDER_RE.length; _i++) {
|
|
109
|
+
var key = _UMI_CLIENT_RENDER_RE[_i];
|
|
110
|
+
rootContainer = opts.pluginManager.applyPlugins({
|
|
111
|
+
type: 'modify',
|
|
112
|
+
key: key,
|
|
113
|
+
initialValue: rootContainer,
|
|
114
|
+
args: {
|
|
115
|
+
routes: opts.routes,
|
|
116
|
+
history: opts.history,
|
|
117
|
+
plugin: opts.pluginManager
|
|
118
|
+
}
|
|
119
|
+
});
|
|
136
120
|
}
|
|
137
121
|
|
|
122
|
+
/**
|
|
123
|
+
* umi 增加完 Provide 的 react dom,可以直接交给 react-dom 渲染
|
|
124
|
+
* @returns {React.ReactElement}
|
|
125
|
+
*/
|
|
138
126
|
var Browser = function Browser() {
|
|
139
127
|
var _useState = useState({}),
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
128
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
129
|
+
clientLoaderData = _useState2[0],
|
|
130
|
+
setClientLoaderData = _useState2[1];
|
|
131
|
+
var _useState3 = useState(
|
|
132
|
+
// @ts-ignore
|
|
133
|
+
window.__UMI_LOADER_DATA__ || {}),
|
|
134
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
135
|
+
serverLoaderData = _useState4[0],
|
|
136
|
+
setServerLoaderData = _useState4[1];
|
|
150
137
|
var handleRouteChange = useCallback(function (id, isFirst) {
|
|
151
138
|
var _matchRoutes;
|
|
152
|
-
|
|
153
139
|
// Patched routes has to id
|
|
154
|
-
var matchedRouteIds = (((_matchRoutes = matchRoutes(clientRoutes, id, basename)) === null || _matchRoutes === void 0 ? void 0 : _matchRoutes.map(
|
|
140
|
+
var matchedRouteIds = (((_matchRoutes = matchRoutes(clientRoutes, id, basename)) === null || _matchRoutes === void 0 ? void 0 : _matchRoutes.map(
|
|
141
|
+
// @ts-ignore
|
|
155
142
|
function (route) {
|
|
156
143
|
return route.route.id;
|
|
157
144
|
})) || []).filter(Boolean);
|
|
158
145
|
matchedRouteIds.forEach(function (id) {
|
|
159
146
|
var _opts$routes$id, _opts$routes$id2;
|
|
160
|
-
|
|
161
147
|
// preload
|
|
162
148
|
// @ts-ignore
|
|
163
149
|
var manifest = window.__umi_manifest__;
|
|
164
|
-
|
|
165
150
|
if (manifest) {
|
|
166
151
|
var routeIdReplaced = id.replace(/[\/\-]/g, '_');
|
|
167
152
|
var preloadId = "preload-".concat(routeIdReplaced, ".js");
|
|
168
|
-
|
|
169
153
|
if (!document.getElementById(preloadId)) {
|
|
170
154
|
var keys = Object.keys(manifest).filter(function (k) {
|
|
171
155
|
return k.startsWith(routeIdReplaced + '.');
|
|
@@ -174,32 +158,28 @@ var getBrowser = function getBrowser(opts, routesElement) {
|
|
|
174
158
|
if (!/\.(js|css)$/.test(key)) {
|
|
175
159
|
throw Error("preload not support ".concat(key, " file"));
|
|
176
160
|
}
|
|
177
|
-
|
|
178
161
|
var file = manifest[key];
|
|
179
162
|
var link = document.createElement('link');
|
|
180
163
|
link.rel = 'preload';
|
|
181
164
|
link.as = 'style';
|
|
182
|
-
|
|
183
165
|
if (key.endsWith('.js')) {
|
|
184
166
|
link.as = 'script';
|
|
185
167
|
link.id = preloadId;
|
|
186
|
-
}
|
|
168
|
+
}
|
|
169
|
+
// publicPath already in the manifest,
|
|
187
170
|
// but if runtimePublicPath is true, we need to replace it
|
|
188
|
-
|
|
189
|
-
|
|
190
171
|
if (opts.runtimePublicPath) {
|
|
191
|
-
file = file.replace(new RegExp("^".concat(opts.publicPath)),
|
|
172
|
+
file = file.replace(new RegExp("^".concat(opts.publicPath)),
|
|
173
|
+
// @ts-ignore
|
|
192
174
|
window.publicPath);
|
|
193
175
|
}
|
|
194
|
-
|
|
195
176
|
link.href = file;
|
|
196
177
|
document.head.appendChild(link);
|
|
197
178
|
});
|
|
198
179
|
}
|
|
199
|
-
}
|
|
180
|
+
}
|
|
181
|
+
// server loader
|
|
200
182
|
// use ?. since routes patched with patchClientRoutes is not exists in opts.routes
|
|
201
|
-
|
|
202
|
-
|
|
203
183
|
if (!isFirst && (_opts$routes$id = opts.routes[id]) !== null && _opts$routes$id !== void 0 && _opts$routes$id.hasServerLoader) {
|
|
204
184
|
fetch('/__serverLoader?route=' + id).then(function (d) {
|
|
205
185
|
return d.json();
|
|
@@ -213,12 +193,10 @@ var getBrowser = function getBrowser(opts, routesElement) {
|
|
|
213
193
|
});
|
|
214
194
|
});
|
|
215
195
|
}).catch(console.error);
|
|
216
|
-
}
|
|
196
|
+
}
|
|
197
|
+
// client loader
|
|
217
198
|
// onPatchClientRoutes 添加的 route 在 opts.routes 里是不存在的
|
|
218
|
-
|
|
219
|
-
|
|
220
199
|
var clientLoader = (_opts$routes$id2 = opts.routes[id]) === null || _opts$routes$id2 === void 0 ? void 0 : _opts$routes$id2.clientLoader;
|
|
221
|
-
|
|
222
200
|
if (clientLoader && !clientLoaderData[id]) {
|
|
223
201
|
clientLoader().then(function (data) {
|
|
224
202
|
setClientLoaderData(function (d) {
|
|
@@ -254,33 +232,28 @@ var getBrowser = function getBrowser(opts, routesElement) {
|
|
|
254
232
|
}
|
|
255
233
|
}, rootContainer));
|
|
256
234
|
};
|
|
257
|
-
|
|
258
235
|
return Browser;
|
|
259
236
|
};
|
|
237
|
+
|
|
260
238
|
/**
|
|
261
239
|
* 执行 react dom 的 render 方法
|
|
262
240
|
* @param {RenderClientOpts} opts - 插件相关的配置
|
|
263
241
|
* @returns void
|
|
264
242
|
*/
|
|
265
|
-
|
|
266
|
-
|
|
267
243
|
export function renderClient(opts) {
|
|
268
244
|
var rootElement = opts.rootElement || document.getElementById('root');
|
|
269
|
-
var Browser = getBrowser(opts, /*#__PURE__*/React.createElement(Routes, null));
|
|
270
|
-
|
|
245
|
+
var Browser = getBrowser(opts, /*#__PURE__*/React.createElement(Routes, null));
|
|
246
|
+
// 为了测试,直接返回组件
|
|
271
247
|
if (opts.components) return Browser;
|
|
272
|
-
|
|
273
248
|
if (opts.hydrate) {
|
|
274
249
|
ReactDOM.hydrateRoot(rootElement, /*#__PURE__*/React.createElement(Browser, null));
|
|
275
250
|
return;
|
|
276
251
|
}
|
|
277
|
-
|
|
278
252
|
if (ReactDOM.createRoot) {
|
|
279
253
|
root = ReactDOM.createRoot(rootElement);
|
|
280
254
|
root.render( /*#__PURE__*/React.createElement(Browser, null));
|
|
281
255
|
return;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
|
|
256
|
+
}
|
|
257
|
+
// @ts-ignore
|
|
285
258
|
ReactDOM.render( /*#__PURE__*/React.createElement(Browser, null), rootElement);
|
|
286
259
|
}
|
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/server.js
CHANGED
|
@@ -8,77 +8,72 @@ import { AppContext } from "./appContext";
|
|
|
8
8
|
import { Routes } from "./browser";
|
|
9
9
|
import { createClientRoutes } from "./routes";
|
|
10
10
|
// store helmet data
|
|
11
|
-
var helmetContext = {};
|
|
11
|
+
var helmetContext = {};
|
|
12
12
|
|
|
13
|
+
// get helmet context
|
|
13
14
|
export function getHelmetContext() {
|
|
14
15
|
return helmetContext;
|
|
15
|
-
}
|
|
16
|
+
}
|
|
16
17
|
|
|
18
|
+
// Get the root React component for ReactDOMServer.renderToString
|
|
17
19
|
export function getClientRootComponent(_x) {
|
|
18
20
|
return _getClientRootComponent.apply(this, arguments);
|
|
19
21
|
}
|
|
20
|
-
|
|
21
22
|
function _getClientRootComponent() {
|
|
22
23
|
_getClientRootComponent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(opts) {
|
|
23
24
|
var basename, components, clientRoutes, rootContainer, _i, _arr, key;
|
|
24
|
-
|
|
25
25
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
26
|
-
while (1) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
while (1) switch (_context.prev = _context.next) {
|
|
27
|
+
case 0:
|
|
28
|
+
basename = '/';
|
|
29
|
+
components = _objectSpread({}, opts.routeComponents);
|
|
30
|
+
clientRoutes = createClientRoutes({
|
|
31
|
+
routesById: opts.routes,
|
|
32
|
+
routeComponents: components
|
|
33
|
+
});
|
|
34
|
+
rootContainer = /*#__PURE__*/React.createElement(StaticRouter, {
|
|
35
|
+
basename: basename,
|
|
36
|
+
location: opts.location
|
|
37
|
+
}, /*#__PURE__*/React.createElement(Routes, null));
|
|
38
|
+
for (_i = 0, _arr = [
|
|
39
|
+
// Lowest to the highest priority
|
|
40
|
+
'innerProvider', 'i18nProvider', 'accessProvider', 'dataflowProvider', 'outerProvider', 'rootContainer']; _i < _arr.length; _i++) {
|
|
41
|
+
key = _arr[_i];
|
|
42
|
+
rootContainer = opts.pluginManager.applyPlugins({
|
|
43
|
+
type: 'modify',
|
|
44
|
+
key: key,
|
|
45
|
+
initialValue: rootContainer,
|
|
46
|
+
args: {}
|
|
34
47
|
});
|
|
35
|
-
|
|
48
|
+
}
|
|
49
|
+
return _context.abrupt("return", /*#__PURE__*/React.createElement(Html, {
|
|
50
|
+
loaderData: opts.loaderData,
|
|
51
|
+
manifest: opts.manifest
|
|
52
|
+
}, /*#__PURE__*/React.createElement(HelmetProvider, {
|
|
53
|
+
context: helmetContext
|
|
54
|
+
}, /*#__PURE__*/React.createElement(AppContext.Provider, {
|
|
55
|
+
value: {
|
|
56
|
+
routes: opts.routes,
|
|
57
|
+
routeComponents: opts.routeComponents,
|
|
58
|
+
clientRoutes: clientRoutes,
|
|
59
|
+
pluginManager: opts.pluginManager,
|
|
36
60
|
basename: basename,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
for (_i = 0, _arr = [// Lowest to the highest priority
|
|
41
|
-
'innerProvider', 'i18nProvider', 'accessProvider', 'dataflowProvider', 'outerProvider', 'rootContainer']; _i < _arr.length; _i++) {
|
|
42
|
-
key = _arr[_i];
|
|
43
|
-
rootContainer = opts.pluginManager.applyPlugins({
|
|
44
|
-
type: 'modify',
|
|
45
|
-
key: key,
|
|
46
|
-
initialValue: rootContainer,
|
|
47
|
-
args: {}
|
|
48
|
-
});
|
|
61
|
+
clientLoaderData: {},
|
|
62
|
+
serverLoaderData: opts.loaderData
|
|
49
63
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}, /*#__PURE__*/React.createElement(HelmetProvider, {
|
|
55
|
-
context: helmetContext
|
|
56
|
-
}, /*#__PURE__*/React.createElement(AppContext.Provider, {
|
|
57
|
-
value: {
|
|
58
|
-
routes: opts.routes,
|
|
59
|
-
routeComponents: opts.routeComponents,
|
|
60
|
-
clientRoutes: clientRoutes,
|
|
61
|
-
pluginManager: opts.pluginManager,
|
|
62
|
-
basename: basename,
|
|
63
|
-
clientLoaderData: {},
|
|
64
|
-
serverLoaderData: opts.loaderData
|
|
65
|
-
}
|
|
66
|
-
}, rootContainer))));
|
|
67
|
-
|
|
68
|
-
case 6:
|
|
69
|
-
case "end":
|
|
70
|
-
return _context.stop();
|
|
71
|
-
}
|
|
64
|
+
}, rootContainer))));
|
|
65
|
+
case 6:
|
|
66
|
+
case "end":
|
|
67
|
+
return _context.stop();
|
|
72
68
|
}
|
|
73
69
|
}, _callee);
|
|
74
70
|
}));
|
|
75
71
|
return _getClientRootComponent.apply(this, arguments);
|
|
76
72
|
}
|
|
77
|
-
|
|
78
73
|
function Html(_ref) {
|
|
79
74
|
var children = _ref.children,
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
loaderData = _ref.loaderData,
|
|
76
|
+
manifest = _ref.manifest;
|
|
82
77
|
// TODO: 处理 head 标签,比如 favicon.ico 的一致性
|
|
83
78
|
// TODO: root 支持配置
|
|
84
79
|
return /*#__PURE__*/React.createElement("html", {
|
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.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.20230227.1",
|
|
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",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"test": "umi-scripts jest-turbo"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@babel/runtime": "7.
|
|
25
|
+
"@babel/runtime": "7.21.0",
|
|
26
26
|
"@loadable/component": "5.15.2",
|
|
27
27
|
"history": "5.3.0",
|
|
28
28
|
"react-helmet-async": "1.3.0",
|