@umijs/renderer-react 4.0.0-rc.12 → 4.0.0-rc.15
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 +10 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/routes.js +9 -14
- package/package.json +6 -5
package/dist/browser.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
// compatible with < react@18 in @umijs/preset-umi/src/features/react
|
|
3
|
+
import ReactDOM from 'react-dom/client';
|
|
3
4
|
import { Router, useRoutes } from 'react-router-dom';
|
|
4
5
|
import { AppContext, useAppData } from './appContext';
|
|
5
6
|
import { createClientRoutes } from './routes';
|
|
@@ -40,6 +41,13 @@ export function renderClient(opts) {
|
|
|
40
41
|
routeComponents: opts.routeComponents,
|
|
41
42
|
loadingComponent: opts.loadingComponent,
|
|
42
43
|
});
|
|
44
|
+
opts.pluginManager.applyPlugins({
|
|
45
|
+
key: 'patchClientRoutes',
|
|
46
|
+
type: 'event',
|
|
47
|
+
args: {
|
|
48
|
+
routes: clientRoutes,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
43
51
|
let rootContainer = (React.createElement(BrowserRoutes, { basename: basename, pluginManager: opts.pluginManager, routes: opts.routes, clientRoutes: clientRoutes, history: opts.history },
|
|
44
52
|
React.createElement(Routes, null)));
|
|
45
53
|
for (const key of [
|
|
@@ -66,12 +74,11 @@ export function renderClient(opts) {
|
|
|
66
74
|
rootElement: opts.rootElement,
|
|
67
75
|
basename,
|
|
68
76
|
} }, rootContainer));
|
|
69
|
-
// @ts-ignore
|
|
70
77
|
if (ReactDOM.createRoot) {
|
|
71
|
-
// @ts-ignore
|
|
72
78
|
ReactDOM.createRoot(rootElement).render(browser);
|
|
73
79
|
}
|
|
74
80
|
else {
|
|
81
|
+
// @ts-ignore
|
|
75
82
|
ReactDOM.render(browser, rootElement);
|
|
76
83
|
}
|
|
77
84
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createBrowserHistory, createHashHistory, createMemoryHistory, History, } from 'history';
|
|
2
|
-
export { createSearchParams, Link, matchPath, matchRoutes, NavLink, Outlet, useLocation, useMatch, useNavigate, useOutlet, useParams, useResolvedPath, useRoutes, useSearchParams, } from 'react-router-dom';
|
|
2
|
+
export { createSearchParams, Link, matchPath, matchRoutes, Navigate, NavLink, Outlet, useLocation, useMatch, useNavigate, useOutlet, useParams, useResolvedPath, useRoutes, useSearchParams, } from 'react-router-dom';
|
|
3
3
|
export { useAppData } from './appContext';
|
|
4
4
|
export { renderClient } from './browser';
|
|
5
5
|
export { useRouteData } from './routeContext';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createBrowserHistory, createHashHistory, createMemoryHistory, } from 'history';
|
|
2
|
-
export { createSearchParams, Link, matchPath, matchRoutes, NavLink, Outlet, useLocation, useMatch, useNavigate, useOutlet, useParams, useResolvedPath, useRoutes, useSearchParams, } from 'react-router-dom';
|
|
2
|
+
export { createSearchParams, Link, matchPath, matchRoutes, Navigate, NavLink, Outlet, useLocation, useMatch, useNavigate, useOutlet, useParams, useResolvedPath, useRoutes, useSearchParams, } from 'react-router-dom';
|
|
3
3
|
export { useAppData } from './appContext';
|
|
4
4
|
export { renderClient } from './browser';
|
|
5
5
|
export { useRouteData } from './routeContext';
|
package/dist/routes.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
// @ts-ignore
|
|
13
2
|
import loadable from '@loadable/component';
|
|
14
3
|
import React from 'react';
|
|
@@ -43,11 +32,17 @@ export function createClientRoutes(opts) {
|
|
|
43
32
|
}
|
|
44
33
|
export function createClientRoute(opts) {
|
|
45
34
|
const { route } = opts;
|
|
46
|
-
const { id, path, index, redirect
|
|
47
|
-
return
|
|
35
|
+
const { id, path, index, redirect, ...props } = route;
|
|
36
|
+
return {
|
|
37
|
+
id: id,
|
|
38
|
+
path: path,
|
|
39
|
+
index: index,
|
|
40
|
+
element: redirect ? (React.createElement(Navigate, { to: redirect })) : (React.createElement(RouteContext.Provider, { value: {
|
|
48
41
|
route: opts.route,
|
|
49
42
|
} },
|
|
50
|
-
React.createElement(RemoteComponent, { loader: opts.routeComponent, loadingComponent: opts.loadingComponent || DefaultLoading })))
|
|
43
|
+
React.createElement(RemoteComponent, { loader: opts.routeComponent, loadingComponent: opts.loadingComponent || DefaultLoading }))),
|
|
44
|
+
...props,
|
|
45
|
+
};
|
|
51
46
|
}
|
|
52
47
|
function DefaultLoading() {
|
|
53
48
|
return React.createElement("div", null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/renderer-react",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.15",
|
|
4
4
|
"description": "@umijs/renderer-react",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/renderer-react#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "pnpm tsc",
|
|
20
|
-
"build:deps": "
|
|
21
|
-
"dev": "pnpm build -- --watch"
|
|
20
|
+
"build:deps": "umi-scripts bundleDeps",
|
|
21
|
+
"dev": "pnpm build -- --watch",
|
|
22
|
+
"test": "umi-scripts jest-turbo"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
25
|
"@loadable/component": "5.15.2",
|
|
@@ -26,8 +27,8 @@
|
|
|
26
27
|
"react-router-dom": "6.3.0"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
|
-
"react": "
|
|
30
|
-
"react-dom": "
|
|
30
|
+
"react": "18.1.0",
|
|
31
|
+
"react-dom": "18.1.0"
|
|
31
32
|
},
|
|
32
33
|
"peerDependencies": {
|
|
33
34
|
"react": ">=16.8",
|