@umijs/plugins 4.0.6 → 4.0.9
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/access.js +69 -53
- package/dist/analytics.js +62 -41
- package/dist/antd.js +139 -123
- package/dist/dva.js +133 -142
- package/dist/icons.js +28 -4
- package/dist/initial-state.js +71 -54
- package/dist/layout.js +201 -209
- package/dist/locale.js +214 -192
- package/dist/model.js +79 -78
- package/dist/moment2dayjs.js +102 -81
- package/dist/qiankun/constants.js +41 -8
- package/dist/qiankun/master.js +147 -121
- package/dist/qiankun/slave.js +160 -150
- package/dist/qiankun.js +46 -19
- package/dist/request.js +87 -56
- package/dist/tailwindcss.js +70 -49
- package/dist/unocss.js +57 -37
- package/dist/utils/astUtils.js +38 -34
- package/dist/utils/localeUtils.js +125 -120
- package/dist/utils/modelUtils.js +216 -237
- package/dist/utils/resolveProjectDep.js +36 -13
- package/dist/utils/withTmpPath.js +31 -9
- package/libs/locale/SelectLang.tpl +1 -1
- package/libs/locale/localeExports.tpl +4 -3
- package/libs/qiankun/master/MicroApp.tsx +17 -12
- package/libs/qiankun/slave/lifecycles.ts +20 -6
- package/package.json +6 -6
|
@@ -88,9 +88,16 @@ export const MicroApp = forwardRef(
|
|
|
88
88
|
...propsFromParams
|
|
89
89
|
} = componentProps;
|
|
90
90
|
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
// ref: https://github.com/umijs/plugins/pull/866
|
|
92
|
+
// name 跟 appNameKeyAlias 这两个 key 同时存在时,优先使用 name,避免对存量应用造成 breaking change。
|
|
93
|
+
// 比如 appNameKeyAlias 配置是 id,但之前 id 正好作为普通的 props 使用过,如 <MicroApp name="app" id="123" />
|
|
94
|
+
// 正常场景会优先匹配 appNameKeyAlias 对应的字段,fallback 到 name,避免对已经使用 <MicroApp name="app" /> 的应用造成影响
|
|
95
|
+
const name =
|
|
96
|
+
componentProps.name && componentProps[appNameKeyAlias]
|
|
97
|
+
? componentProps.name
|
|
98
|
+
: componentProps[appNameKeyAlias] || componentProps.name;
|
|
99
|
+
const isCurrentApp = (app: any) =>
|
|
100
|
+
app[appNameKeyAlias] === name || app.name === name;
|
|
94
101
|
|
|
95
102
|
const [loading, setLoading] = useState(true);
|
|
96
103
|
const [error, setError] = useState<any>(null);
|
|
@@ -143,13 +150,6 @@ export const MicroApp = forwardRef(
|
|
|
143
150
|
setComponentError(null);
|
|
144
151
|
setLoading(true);
|
|
145
152
|
const configuration = {
|
|
146
|
-
fetch(url) {
|
|
147
|
-
return window.fetch(url, {
|
|
148
|
-
headers: {
|
|
149
|
-
accept: 'text/html',
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
},
|
|
153
153
|
globalContext: window,
|
|
154
154
|
...globalSettings,
|
|
155
155
|
...settingsFromProps,
|
|
@@ -178,11 +178,16 @@ export const MicroApp = forwardRef(
|
|
|
178
178
|
if (noneMounted) {
|
|
179
179
|
if (Array.isArray(prefetch)) {
|
|
180
180
|
const specialPrefetchApps = apps.filter(
|
|
181
|
-
(app) =>
|
|
181
|
+
(app) =>
|
|
182
|
+
!isCurrentApp(app) &&
|
|
183
|
+
(prefetch.indexOf(app[appNameKeyAlias]) !== -1 ||
|
|
184
|
+
prefetch.indexOf(app.name) !== -1),
|
|
182
185
|
);
|
|
183
186
|
prefetchApps(specialPrefetchApps, configuration);
|
|
184
187
|
} else {
|
|
185
|
-
const otherNotMountedApps = apps.filter(
|
|
188
|
+
const otherNotMountedApps = apps.filter(
|
|
189
|
+
(app) => !isCurrentApp(app),
|
|
190
|
+
);
|
|
186
191
|
prefetchApps(otherNotMountedApps, configuration);
|
|
187
192
|
}
|
|
188
193
|
noneMounted = false;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import { getPluginManager } from '@@/core/plugin';
|
|
3
3
|
import ReactDOM from 'react-dom';
|
|
4
|
-
import { ApplyPluginsType } from 'umi';
|
|
4
|
+
import { ApplyPluginsType, __getRoot } from 'umi';
|
|
5
5
|
import { setModelState } from './qiankunModel';
|
|
6
6
|
|
|
7
7
|
const noop = () => {};
|
|
@@ -73,6 +73,8 @@ export function genMount(mountElementId: string) {
|
|
|
73
73
|
await slaveRuntime.mount(props);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
const { type, ...historyOpts } = props?.history || {};
|
|
77
|
+
|
|
76
78
|
// 更新 clientRender 配置
|
|
77
79
|
const clientRenderOpts = {
|
|
78
80
|
// 默认开启
|
|
@@ -95,6 +97,10 @@ export function genMount(mountElementId: string) {
|
|
|
95
97
|
|
|
96
98
|
basename: props.base,
|
|
97
99
|
|
|
100
|
+
// 支持 MicroAppWithMemoHistory 需要
|
|
101
|
+
historyType: type,
|
|
102
|
+
historyOpts: historyOpts,
|
|
103
|
+
|
|
98
104
|
// 当存在同一个 umi 子应用在同一个页面被多实例渲染的场景时(比如一个页面里,同时展示了这个子应用的多个路由页面)
|
|
99
105
|
// mount 钩子会被调用多次,但是具体什么时候对应的实例开始 render 则是不定的,即它调用 applyPlugins('modifyClientRenderOpts') 的时机是不确定的
|
|
100
106
|
// 为了保证每次 applyPlugins('modifyClientRenderOpts') 调用是生成正确的 history,我们需要这里通过闭包上下文维持 mount 调用时的一些配置信息
|
|
@@ -143,12 +149,20 @@ export function genUpdate() {
|
|
|
143
149
|
|
|
144
150
|
export function genUnmount(mountElementId: string) {
|
|
145
151
|
return async (props: any) => {
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (
|
|
150
|
-
|
|
152
|
+
const root = __getRoot();
|
|
153
|
+
|
|
154
|
+
// support react 18 unmount
|
|
155
|
+
if (typeof root?.unmount === 'function') {
|
|
156
|
+
root.unmount();
|
|
157
|
+
} else {
|
|
158
|
+
const container = props?.container
|
|
159
|
+
? props.container.querySelector(`#${mountElementId}`)
|
|
160
|
+
: document.getElementById(mountElementId);
|
|
161
|
+
if (container) {
|
|
162
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
163
|
+
}
|
|
151
164
|
}
|
|
165
|
+
|
|
152
166
|
const slaveRuntime = await getSlaveRuntime();
|
|
153
167
|
if (slaveRuntime.unmount) await slaveRuntime.unmount(props);
|
|
154
168
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.9",
|
|
4
4
|
"description": "@umijs/plugins",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/plugins#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -16,16 +16,16 @@
|
|
|
16
16
|
"libs"
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
|
-
"build": "
|
|
19
|
+
"build": "umi-scripts father build",
|
|
20
20
|
"build:deps": "umi-scripts bundleDeps",
|
|
21
|
-
"dev": "
|
|
21
|
+
"dev": "umi-scripts father dev",
|
|
22
22
|
"test": "umi-scripts jest-turbo"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ahooksjs/use-request": "^2.0.0",
|
|
26
26
|
"@ant-design/icons": "^4.7.0",
|
|
27
|
-
"@ant-design/pro-layout": "^7.0.1-beta.
|
|
28
|
-
"@umijs/bundler-utils": "4.0.
|
|
27
|
+
"@ant-design/pro-layout": "^7.0.1-beta.28",
|
|
28
|
+
"@umijs/bundler-utils": "4.0.9",
|
|
29
29
|
"antd-dayjs-webpack-plugin": "^1.0.6",
|
|
30
30
|
"axios": "^0.27.2",
|
|
31
31
|
"babel-plugin-import": "^1.13.5",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"warning": "^4.0.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"umi": "4.0.
|
|
47
|
+
"umi": "4.0.9"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|