@umijs/renderer-react 4.3.32 → 4.3.34
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.d.ts +5 -1
- package/dist/browser.js +2 -1
- package/dist/html.d.ts +1 -1
- package/dist/link.d.ts +1 -1
- package/dist/routes.d.ts +1 -0
- package/dist/routes.js +20 -11
- package/dist/server.js +2 -1
- package/dist/types.d.ts +1 -0
- package/dist/withRouter.d.ts +1 -1
- package/package.json +1 -1
package/dist/browser.d.ts
CHANGED
|
@@ -69,6 +69,10 @@ export declare type RenderClientOpts = {
|
|
|
69
69
|
* ssr 的配置
|
|
70
70
|
*/
|
|
71
71
|
hydrate?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* ssr 是否启用流式渲染, 默认 true, 对 SEO 存在一定的负优化
|
|
74
|
+
*/
|
|
75
|
+
useStream?: boolean;
|
|
72
76
|
/**
|
|
73
77
|
* 直接返回组件,是为了方便测试
|
|
74
78
|
*/
|
|
@@ -88,4 +92,4 @@ export declare type RenderClientOpts = {
|
|
|
88
92
|
* @param {RenderClientOpts} opts - 插件相关的配置
|
|
89
93
|
* @returns void
|
|
90
94
|
*/
|
|
91
|
-
export declare function renderClient(opts: RenderClientOpts): (() => JSX.Element) | undefined;
|
|
95
|
+
export declare function renderClient(opts: RenderClientOpts): (() => React.JSX.Element) | undefined;
|
package/dist/browser.js
CHANGED
|
@@ -90,7 +90,8 @@ var getBrowser = function getBrowser(opts, routesElement) {
|
|
|
90
90
|
routesById: opts.routes,
|
|
91
91
|
routeComponents: opts.routeComponents,
|
|
92
92
|
loadingComponent: opts.loadingComponent,
|
|
93
|
-
reactRouter5Compat: opts.reactRouter5Compat
|
|
93
|
+
reactRouter5Compat: opts.reactRouter5Compat,
|
|
94
|
+
useStream: opts.useStream
|
|
94
95
|
});
|
|
95
96
|
opts.pluginManager.applyPlugins({
|
|
96
97
|
key: 'patchClientRoutes',
|
package/dist/html.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IHtmlProps } from './types';
|
|
3
|
-
export declare function Html({ children, loaderData, manifest, htmlPageOpts, __INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, mountElementId, }: React.PropsWithChildren<IHtmlProps>): JSX.Element;
|
|
3
|
+
export declare function Html({ children, loaderData, manifest, htmlPageOpts, __INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, mountElementId, }: React.PropsWithChildren<IHtmlProps>): React.JSX.Element;
|
package/dist/link.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import React, { PropsWithChildren } from 'react';
|
|
|
2
2
|
import { LinkProps } from 'react-router-dom';
|
|
3
3
|
export declare function LinkWithPrefetch(props: PropsWithChildren<{
|
|
4
4
|
prefetch?: boolean;
|
|
5
|
-
} & LinkProps & React.RefAttributes<HTMLAnchorElement>>): JSX.Element | null;
|
|
5
|
+
} & LinkProps & React.RefAttributes<HTMLAnchorElement>>): React.JSX.Element | null;
|
package/dist/routes.d.ts
CHANGED
package/dist/routes.js
CHANGED
|
@@ -10,11 +10,13 @@ import { RouteContext, useRouteData } from "./routeContext";
|
|
|
10
10
|
export function createClientRoutes(opts) {
|
|
11
11
|
var routesById = opts.routesById,
|
|
12
12
|
parentId = opts.parentId,
|
|
13
|
-
routeComponents = opts.routeComponents
|
|
13
|
+
routeComponents = opts.routeComponents,
|
|
14
|
+
_opts$useStream = opts.useStream,
|
|
15
|
+
useStream = _opts$useStream === void 0 ? true : _opts$useStream;
|
|
14
16
|
return Object.keys(routesById).filter(function (id) {
|
|
15
17
|
return routesById[id].parentId === parentId;
|
|
16
18
|
}).map(function (id) {
|
|
17
|
-
var route = createClientRoute(_objectSpread({
|
|
19
|
+
var route = createClientRoute(_objectSpread(_objectSpread({
|
|
18
20
|
route: routesById[id],
|
|
19
21
|
routeComponent: routeComponents[id],
|
|
20
22
|
loadingComponent: opts.loadingComponent,
|
|
@@ -24,13 +26,16 @@ export function createClientRoutes(opts) {
|
|
|
24
26
|
hasChildren: Object.keys(routesById).filter(function (rid) {
|
|
25
27
|
return routesById[rid].parentId === id;
|
|
26
28
|
}).length > 0
|
|
29
|
+
}), {}, {
|
|
30
|
+
useStream: useStream
|
|
27
31
|
}));
|
|
28
32
|
var children = createClientRoutes({
|
|
29
33
|
routesById: routesById,
|
|
30
34
|
routeComponents: routeComponents,
|
|
31
35
|
parentId: route.id,
|
|
32
36
|
loadingComponent: opts.loadingComponent,
|
|
33
|
-
reactRouter5Compat: opts.reactRouter5Compat
|
|
37
|
+
reactRouter5Compat: opts.reactRouter5Compat,
|
|
38
|
+
useStream: useStream
|
|
34
39
|
});
|
|
35
40
|
if (children.length > 0) {
|
|
36
41
|
route.children = children;
|
|
@@ -58,7 +63,9 @@ function NavigateWithParams(props) {
|
|
|
58
63
|
}, propsWithParams));
|
|
59
64
|
}
|
|
60
65
|
function createClientRoute(opts) {
|
|
61
|
-
var route = opts.route
|
|
66
|
+
var route = opts.route,
|
|
67
|
+
_opts$useStream2 = opts.useStream,
|
|
68
|
+
useStream = _opts$useStream2 === void 0 ? true : _opts$useStream2;
|
|
62
69
|
var redirect = route.redirect,
|
|
63
70
|
props = _objectWithoutProperties(route, _excluded);
|
|
64
71
|
var Remote = opts.reactRouter5Compat ? RemoteComponentReactRouter5 : RemoteComponent;
|
|
@@ -72,7 +79,8 @@ function createClientRoute(opts) {
|
|
|
72
79
|
}, /*#__PURE__*/React.createElement(Remote, {
|
|
73
80
|
loader: /*#__PURE__*/React.memo(opts.routeComponent),
|
|
74
81
|
loadingComponent: opts.loadingComponent || DefaultLoading,
|
|
75
|
-
hasChildren: opts.hasChildren
|
|
82
|
+
hasChildren: opts.hasChildren,
|
|
83
|
+
useStream: useStream
|
|
76
84
|
}))
|
|
77
85
|
}, props);
|
|
78
86
|
}
|
|
@@ -95,20 +103,21 @@ function RemoteComponentReactRouter5(props) {
|
|
|
95
103
|
|
|
96
104
|
// staticContext 没有兼容 好像没看到对应的兼容写法
|
|
97
105
|
var Component = props.loader;
|
|
98
|
-
|
|
99
|
-
fallback: /*#__PURE__*/React.createElement(props.loadingComponent, null)
|
|
100
|
-
}, /*#__PURE__*/React.createElement(Component, {
|
|
106
|
+
var ComponentProps = {
|
|
101
107
|
location: history.location,
|
|
102
108
|
match: match,
|
|
103
109
|
history: history,
|
|
104
110
|
params: params,
|
|
105
111
|
route: route,
|
|
106
112
|
routes: clientRoutes
|
|
107
|
-
}
|
|
113
|
+
};
|
|
114
|
+
return props.useStream ? /*#__PURE__*/React.createElement(React.Suspense, {
|
|
115
|
+
fallback: /*#__PURE__*/React.createElement(props.loadingComponent, null)
|
|
116
|
+
}, /*#__PURE__*/React.createElement(Component, ComponentProps, props.hasChildren && /*#__PURE__*/React.createElement(Outlet, null))) : /*#__PURE__*/React.createElement(Component, ComponentProps, props.hasChildren && /*#__PURE__*/React.createElement(Outlet, null));
|
|
108
117
|
}
|
|
109
118
|
function RemoteComponent(props) {
|
|
110
119
|
var Component = props.loader;
|
|
111
|
-
return /*#__PURE__*/React.createElement(React.Suspense, {
|
|
120
|
+
return props.useStream ? /*#__PURE__*/React.createElement(React.Suspense, {
|
|
112
121
|
fallback: /*#__PURE__*/React.createElement(props.loadingComponent, null)
|
|
113
|
-
}, /*#__PURE__*/React.createElement(Component, null));
|
|
122
|
+
}, /*#__PURE__*/React.createElement(Component, null)) : /*#__PURE__*/React.createElement(Component, null);
|
|
114
123
|
}
|
package/dist/server.js
CHANGED
|
@@ -21,7 +21,8 @@ function _getClientRootComponent() {
|
|
|
21
21
|
components = _objectSpread({}, opts.routeComponents); // todo 参数对齐
|
|
22
22
|
clientRoutes = createClientRoutes({
|
|
23
23
|
routesById: opts.routes,
|
|
24
|
-
routeComponents: components
|
|
24
|
+
routeComponents: components,
|
|
25
|
+
useStream: opts.useStream
|
|
25
26
|
});
|
|
26
27
|
opts.pluginManager.applyPlugins({
|
|
27
28
|
key: 'patchClientRoutes',
|
package/dist/types.d.ts
CHANGED
package/dist/withRouter.d.ts
CHANGED
|
@@ -14,4 +14,4 @@ export interface RouteComponentProps<T = ReturnType<typeof useParams>> {
|
|
|
14
14
|
params?: T;
|
|
15
15
|
navigate?: ReturnType<typeof useNavigate>;
|
|
16
16
|
}
|
|
17
|
-
export declare function withRouter<P extends RouteComponentProps<P>>(Component: React.ComponentType<P>): (props: P) => JSX.Element;
|
|
17
|
+
export declare function withRouter<P extends RouteComponentProps<P>>(Component: React.ComponentType<P>): (props: P) => React.JSX.Element;
|
package/package.json
CHANGED