@umijs/renderer-react 4.0.20 → 4.0.21
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/link.js +3 -6
- package/dist/server.js +40 -51
- package/package.json +1 -1
package/dist/link.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Link } from 'react-router-dom';
|
|
4
4
|
import { useAppData } from "./appContext";
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
5
|
export function LinkWithPrefetch(props) {
|
|
7
6
|
var appData = useAppData();
|
|
8
7
|
var to = typeof props.to === 'string' ? props.to : props.to.pathname;
|
|
9
|
-
return /*#__PURE__*/
|
|
8
|
+
return /*#__PURE__*/React.createElement(Link, _extends({
|
|
10
9
|
onMouseEnter: function onMouseEnter() {
|
|
11
10
|
var _appData$preloadRoute;
|
|
12
11
|
|
|
13
12
|
return props.prefetch && to && ((_appData$preloadRoute = appData.preloadRoute) === null || _appData$preloadRoute === void 0 ? void 0 : _appData$preloadRoute.call(appData, to));
|
|
14
13
|
}
|
|
15
|
-
}, props),
|
|
16
|
-
children: props.children
|
|
17
|
-
}));
|
|
14
|
+
}, props), props.children);
|
|
18
15
|
}
|
package/dist/server.js
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/regeneratorRuntime";
|
|
1
2
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
3
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { StaticRouter } from 'react-router-dom/server';
|
|
6
6
|
import { AppContext } from "./appContext";
|
|
7
7
|
import { Routes } from "./browser";
|
|
8
8
|
import { createClientRoutes } from "./routes";
|
|
9
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
9
|
// Get the root React component for ReactDOMServer.renderToString
|
|
12
10
|
export function getClientRootComponent(_x) {
|
|
13
11
|
return _getClientRootComponent.apply(this, arguments);
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
function _getClientRootComponent() {
|
|
17
|
-
_getClientRootComponent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(opts) {
|
|
15
|
+
_getClientRootComponent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(opts) {
|
|
18
16
|
var basename, components, clientRoutes, rootContainer, _i, _arr, key;
|
|
19
17
|
|
|
20
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
21
19
|
while (1) {
|
|
22
20
|
switch (_context.prev = _context.next) {
|
|
23
21
|
case 0:
|
|
@@ -27,11 +25,10 @@ function _getClientRootComponent() {
|
|
|
27
25
|
routesById: opts.routes,
|
|
28
26
|
routeComponents: components
|
|
29
27
|
});
|
|
30
|
-
rootContainer = /*#__PURE__*/
|
|
28
|
+
rootContainer = /*#__PURE__*/React.createElement(StaticRouter, {
|
|
31
29
|
basename: basename,
|
|
32
|
-
location: opts.location
|
|
33
|
-
|
|
34
|
-
});
|
|
30
|
+
location: opts.location
|
|
31
|
+
}, /*#__PURE__*/React.createElement(Routes, null));
|
|
35
32
|
|
|
36
33
|
for (_i = 0, _arr = [// Lowest to the highest priority
|
|
37
34
|
'innerProvider', 'i18nProvider', 'accessProvider', 'dataflowProvider', 'outerProvider', 'rootContainer']; _i < _arr.length; _i++) {
|
|
@@ -44,22 +41,20 @@ function _getClientRootComponent() {
|
|
|
44
41
|
});
|
|
45
42
|
}
|
|
46
43
|
|
|
47
|
-
return _context.abrupt("return", /*#__PURE__*/
|
|
44
|
+
return _context.abrupt("return", /*#__PURE__*/React.createElement(Html, {
|
|
48
45
|
loaderData: opts.loaderData,
|
|
49
|
-
manifest: opts.manifest
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
})
|
|
62
|
-
}));
|
|
46
|
+
manifest: opts.manifest
|
|
47
|
+
}, /*#__PURE__*/React.createElement(AppContext.Provider, {
|
|
48
|
+
value: {
|
|
49
|
+
routes: opts.routes,
|
|
50
|
+
routeComponents: opts.routeComponents,
|
|
51
|
+
clientRoutes: clientRoutes,
|
|
52
|
+
pluginManager: opts.pluginManager,
|
|
53
|
+
basename: basename,
|
|
54
|
+
clientLoaderData: {},
|
|
55
|
+
serverLoaderData: opts.loaderData
|
|
56
|
+
}
|
|
57
|
+
}, rootContainer)));
|
|
63
58
|
|
|
64
59
|
case 6:
|
|
65
60
|
case "end":
|
|
@@ -77,31 +72,25 @@ function Html(_ref) {
|
|
|
77
72
|
manifest = _ref.manifest;
|
|
78
73
|
// TODO: 处理 head 标签,比如 favicon.ico 的一致性
|
|
79
74
|
// TODO: root 支持配置
|
|
80
|
-
return /*#__PURE__*/
|
|
81
|
-
lang: "en"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
dangerouslySetInnerHTML: {
|
|
102
|
-
__html: "window.__UMI_LOADER_DATA__ = ".concat(JSON.stringify(loaderData))
|
|
103
|
-
}
|
|
104
|
-
})]
|
|
105
|
-
})]
|
|
106
|
-
});
|
|
75
|
+
return /*#__PURE__*/React.createElement("html", {
|
|
76
|
+
lang: "en"
|
|
77
|
+
}, /*#__PURE__*/React.createElement("head", null, /*#__PURE__*/React.createElement("meta", {
|
|
78
|
+
charSet: "utf-8"
|
|
79
|
+
}), /*#__PURE__*/React.createElement("meta", {
|
|
80
|
+
name: "viewport",
|
|
81
|
+
content: "width=device-width, initial-scale=1"
|
|
82
|
+
}), manifest.assets['umi.css'] && /*#__PURE__*/React.createElement("link", {
|
|
83
|
+
rel: "stylesheet",
|
|
84
|
+
href: manifest.assets['umi.css']
|
|
85
|
+
})), /*#__PURE__*/React.createElement("body", null, /*#__PURE__*/React.createElement("noscript", {
|
|
86
|
+
dangerouslySetInnerHTML: {
|
|
87
|
+
__html: "<b>Enable JavaScript to run this app.</b>"
|
|
88
|
+
}
|
|
89
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
90
|
+
id: "root"
|
|
91
|
+
}, children), /*#__PURE__*/React.createElement("script", {
|
|
92
|
+
dangerouslySetInnerHTML: {
|
|
93
|
+
__html: "window.__UMI_LOADER_DATA__ = ".concat(JSON.stringify(loaderData))
|
|
94
|
+
}
|
|
95
|
+
})));
|
|
107
96
|
}
|
package/package.json
CHANGED