@umijs/plugins 4.0.57 → 4.0.59
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/LICENSE +21 -0
- package/dist/antd.js +50 -42
- package/libs/locale/SelectLang.tpl +1 -0
- package/package.json +13 -13
- package/tpls/antd-runtime.ts.tpl +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-present ChenCheng (sorrycc@gmail.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/dist/antd.js
CHANGED
|
@@ -50,6 +50,8 @@ var antd_default = (api) => {
|
|
|
50
50
|
antdVersion = require(`${pkgPath}/package.json`).version;
|
|
51
51
|
} catch (e) {
|
|
52
52
|
}
|
|
53
|
+
const appComponentAvailable = import_plugin_utils.semver.gte(antdVersion, "5.1.0");
|
|
54
|
+
const appConfigAvailable = import_plugin_utils.semver.gte(antdVersion, "5.3.0");
|
|
53
55
|
api.describe({
|
|
54
56
|
config: {
|
|
55
57
|
schema(Joi) {
|
|
@@ -63,7 +65,9 @@ var antd_default = (api) => {
|
|
|
63
65
|
import: Joi.boolean(),
|
|
64
66
|
// less or css, default less
|
|
65
67
|
style: Joi.string().allow("less", "css"),
|
|
66
|
-
theme: Joi.object()
|
|
68
|
+
theme: Joi.object(),
|
|
69
|
+
// Only antd@5.1.0 is supported
|
|
70
|
+
appConfig: Joi.object()
|
|
67
71
|
}),
|
|
68
72
|
Joi.boolean().invalid(true)
|
|
69
73
|
);
|
|
@@ -136,6 +140,18 @@ var antd_default = (api) => {
|
|
|
136
140
|
antd.theme
|
|
137
141
|
);
|
|
138
142
|
}
|
|
143
|
+
if (antd.appConfig) {
|
|
144
|
+
if (!appComponentAvailable) {
|
|
145
|
+
delete antd.appConfig;
|
|
146
|
+
api.logger.warn(
|
|
147
|
+
`antd.appConfig is only available in version 5.1.0 and above, but you are using version ${antdVersion}`
|
|
148
|
+
);
|
|
149
|
+
} else if (!appConfigAvailable && Object.keys(antd.appConfig).length > 0) {
|
|
150
|
+
api.logger.warn(
|
|
151
|
+
`versions [5.1.0 ~ 5.3.0) only allows antd.appConfig to be set to \`{}\``
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
139
155
|
return memo;
|
|
140
156
|
});
|
|
141
157
|
api.addExtraBabelPlugins(() => {
|
|
@@ -155,55 +171,44 @@ var antd_default = (api) => {
|
|
|
155
171
|
] : [];
|
|
156
172
|
});
|
|
157
173
|
api.onGenerateFiles(() => {
|
|
158
|
-
|
|
159
|
-
|
|
174
|
+
const withConfigProvider = !!api.config.antd.configProvider;
|
|
175
|
+
const withAppConfig = appConfigAvailable && !!api.config.antd.appConfig;
|
|
160
176
|
api.writeTmpFile({
|
|
161
177
|
path: `runtime.tsx`,
|
|
178
|
+
context: {
|
|
179
|
+
configProvider: withConfigProvider && JSON.stringify(api.config.antd.configProvider),
|
|
180
|
+
appConfig: appComponentAvailable && JSON.stringify(api.config.antd.appConfig)
|
|
181
|
+
},
|
|
182
|
+
tplPath: (0, import_path.join)(__dirname, "../tpls/antd-runtime.ts.tpl")
|
|
183
|
+
});
|
|
184
|
+
api.writeTmpFile({
|
|
185
|
+
path: "types.d.ts",
|
|
162
186
|
content: import_plugin_utils.Mustache.render(
|
|
163
187
|
`
|
|
164
|
-
|
|
165
|
-
import {
|
|
166
|
-
|
|
167
|
-
|
|
188
|
+
{{#withConfigProvider}}
|
|
189
|
+
import type { ConfigProviderProps } from 'antd/es/config-provider';
|
|
190
|
+
{{/withConfigProvider}}
|
|
191
|
+
{{#withAppConfig}}
|
|
192
|
+
import type { AppConfig } from 'antd/es/app/context';
|
|
193
|
+
{{/withAppConfig}}
|
|
168
194
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
prefixCls: \`\${finalConfig.prefixCls}-message\`
|
|
181
|
-
});
|
|
182
|
-
notification.config({
|
|
183
|
-
prefixCls: \`\${finalConfig.prefixCls}-notification\`
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
if (finalConfig.iconPrefixCls) {
|
|
187
|
-
// Icons in message need to set iconPrefixCls via ConfigProvider.config()
|
|
188
|
-
ConfigProvider.config({
|
|
189
|
-
iconPrefixCls: finalConfig.iconPrefixCls,
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
return <ConfigProvider {...finalConfig}>{container}</ConfigProvider>;
|
|
193
|
-
}
|
|
194
|
-
`.trim(),
|
|
195
|
+
type Prettify<T> = {
|
|
196
|
+
[K in keyof T]: T[K];
|
|
197
|
+
} & {};
|
|
198
|
+
|
|
199
|
+
type AntdConfig = Prettify<{}
|
|
200
|
+
{{#withConfigProvider}} & ConfigProviderProps{{/withConfigProvider}}
|
|
201
|
+
{{#withAppConfig}} & { appConfig: AppConfig }{{/withAppConfig}}
|
|
202
|
+
>;
|
|
203
|
+
|
|
204
|
+
export type RuntimeAntdConfig = (memo: AntdConfig) => AntdConfig;
|
|
205
|
+
`.trim(),
|
|
195
206
|
{
|
|
196
|
-
|
|
207
|
+
withConfigProvider,
|
|
208
|
+
withAppConfig
|
|
197
209
|
}
|
|
198
210
|
)
|
|
199
211
|
});
|
|
200
|
-
api.writeTmpFile({
|
|
201
|
-
path: "types.d.ts",
|
|
202
|
-
content: `
|
|
203
|
-
import type { ConfigProviderProps } from 'antd/es/config-provider';
|
|
204
|
-
export type RuntimeAntdConfig = (memo: ConfigProviderProps) => ConfigProviderProps;
|
|
205
|
-
`
|
|
206
|
-
});
|
|
207
212
|
api.writeTmpFile({
|
|
208
213
|
path: import_umi.RUNTIME_TYPE_FILE_NAME,
|
|
209
214
|
content: `
|
|
@@ -215,7 +220,10 @@ export type IRuntimeConfig = {
|
|
|
215
220
|
});
|
|
216
221
|
});
|
|
217
222
|
api.addRuntimePlugin(() => {
|
|
218
|
-
|
|
223
|
+
if (api.config.antd.configProvider || appComponentAvailable && api.config.antd.appConfig) {
|
|
224
|
+
return [(0, import_withTmpPath.withTmpPath)({ api, path: "runtime.tsx" })];
|
|
225
|
+
}
|
|
226
|
+
return [];
|
|
219
227
|
});
|
|
220
228
|
api.addEntryImportsAhead(() => {
|
|
221
229
|
const style = api.config.antd.style || "less";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.59",
|
|
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,12 +16,6 @@
|
|
|
16
16
|
"libs",
|
|
17
17
|
"tpls"
|
|
18
18
|
],
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "umi-scripts father build",
|
|
21
|
-
"build:deps": "umi-scripts bundleDeps",
|
|
22
|
-
"dev": "umi-scripts father dev",
|
|
23
|
-
"test": "umi-scripts jest-turbo"
|
|
24
|
-
},
|
|
25
19
|
"dependencies": {
|
|
26
20
|
"@ahooksjs/use-request": "^2.0.0",
|
|
27
21
|
"@ant-design/antd-theme-variable": "^1.0.0",
|
|
@@ -29,8 +23,6 @@
|
|
|
29
23
|
"@ant-design/pro-components": "^2.0.1",
|
|
30
24
|
"@tanstack/react-query": "^4.24.10",
|
|
31
25
|
"@tanstack/react-query-devtools": "^4.24.10",
|
|
32
|
-
"@umijs/bundler-utils": "4.0.57",
|
|
33
|
-
"@umijs/valtio": "^1.0.3",
|
|
34
26
|
"antd-dayjs-webpack-plugin": "^1.0.6",
|
|
35
27
|
"axios": "^0.27.2",
|
|
36
28
|
"babel-plugin-import": "^1.13.6",
|
|
@@ -49,16 +41,24 @@
|
|
|
49
41
|
"redux": "^4.2.1",
|
|
50
42
|
"styled-components": "6.0.0-beta.9",
|
|
51
43
|
"tslib": "^2",
|
|
52
|
-
"warning": "^4.0.3"
|
|
44
|
+
"warning": "^4.0.3",
|
|
45
|
+
"@umijs/bundler-utils": "4.0.59",
|
|
46
|
+
"@umijs/valtio": "1.0.3"
|
|
53
47
|
},
|
|
54
48
|
"devDependencies": {
|
|
55
49
|
"antd": "^4.24.1",
|
|
56
|
-
"umi": "4.0.
|
|
50
|
+
"umi": "4.0.59"
|
|
57
51
|
},
|
|
58
52
|
"publishConfig": {
|
|
59
53
|
"access": "public"
|
|
60
54
|
},
|
|
61
55
|
"authors": [
|
|
62
56
|
"chencheng <sorrycc@gmail.com> (https://github.com/sorrycc)"
|
|
63
|
-
]
|
|
64
|
-
|
|
57
|
+
],
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "umi-scripts father build",
|
|
60
|
+
"build:deps": "umi-scripts bundleDeps",
|
|
61
|
+
"dev": "umi-scripts father dev",
|
|
62
|
+
"test": "umi-scripts jest-turbo"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Modal,
|
|
4
|
+
{{#configProvider}}
|
|
5
|
+
ConfigProvider,
|
|
6
|
+
{{/configProvider}}
|
|
7
|
+
{{#appConfig}}
|
|
8
|
+
App,
|
|
9
|
+
{{/appConfig}}
|
|
10
|
+
message,
|
|
11
|
+
notification,
|
|
12
|
+
} from 'antd';
|
|
13
|
+
import { ApplyPluginsType } from 'umi';
|
|
14
|
+
import { getPluginManager } from '../core/plugin';
|
|
15
|
+
|
|
16
|
+
export function rootContainer(rawContainer) {
|
|
17
|
+
const {
|
|
18
|
+
appConfig: finalAppConfig = {},
|
|
19
|
+
...finalConfigProvider
|
|
20
|
+
} = getPluginManager().applyPlugins({
|
|
21
|
+
key: 'antd',
|
|
22
|
+
type: ApplyPluginsType.modify,
|
|
23
|
+
initialValue: {
|
|
24
|
+
{{#configProvider}}
|
|
25
|
+
...{{{configProvider}}},
|
|
26
|
+
{{/configProvider}}
|
|
27
|
+
{{#appConfig}}
|
|
28
|
+
appConfig: {{{appConfig}}},
|
|
29
|
+
{{/appConfig}}
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
let container = rawContainer;
|
|
34
|
+
|
|
35
|
+
{{#appConfig}}
|
|
36
|
+
// The App component should be under ConfigProvider
|
|
37
|
+
container = <App {...finalAppConfig}>{container}</App>;
|
|
38
|
+
{{/appConfig}}
|
|
39
|
+
|
|
40
|
+
{{#configProvider}}
|
|
41
|
+
if (finalConfigProvider.prefixCls) {
|
|
42
|
+
Modal.config({
|
|
43
|
+
rootPrefixCls: finalConfigProvider.prefixCls
|
|
44
|
+
});
|
|
45
|
+
message.config({
|
|
46
|
+
prefixCls: `${finalConfigProvider.prefixCls}-message`
|
|
47
|
+
});
|
|
48
|
+
notification.config({
|
|
49
|
+
prefixCls: `${finalConfigProvider.prefixCls}-notification`
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (finalConfigProvider.iconPrefixCls) {
|
|
54
|
+
// Icons in message need to set iconPrefixCls via ConfigProvider.config()
|
|
55
|
+
ConfigProvider.config({
|
|
56
|
+
iconPrefixCls: finalConfigProvider.iconPrefixCls,
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
container = <ConfigProvider {...finalConfigProvider}>{container}</ConfigProvider>;
|
|
60
|
+
{{/configProvider}}
|
|
61
|
+
|
|
62
|
+
return container;
|
|
63
|
+
}
|