@umijs/plugins 4.0.0-beta.14 → 4.0.0-beta.18
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/antd.js +2 -2
- package/dist/dva.js +3 -4
- package/dist/layout.js +30 -5
- package/dist/locale.js +2 -2
- package/dist/qiankun/master.js +2 -4
- package/dist/qiankun/slave.js +2 -3
- package/dist/request.js +9 -5
- package/dist/tailwindcss.d.ts +3 -0
- package/dist/tailwindcss.js +38 -0
- package/dist/unocss.d.ts +3 -0
- package/dist/unocss.js +57 -0
- package/libs/qiankun/master/masterRuntimePlugin.tsx +2 -5
- package/package.json +3 -3
package/dist/antd.js
CHANGED
|
@@ -52,7 +52,7 @@ exports.default = (api) => {
|
|
|
52
52
|
// babel-plugin-import
|
|
53
53
|
api.addExtraBabelPlugins(() => {
|
|
54
54
|
const style = api.config.antd.style || 'less';
|
|
55
|
-
return api.config.antd.import
|
|
55
|
+
return api.config.antd.import && !api.appData.vite
|
|
56
56
|
? [
|
|
57
57
|
[
|
|
58
58
|
require.resolve('babel-plugin-import'),
|
|
@@ -102,7 +102,7 @@ export function rootContainer(container) {
|
|
|
102
102
|
// import antd style if antd.import is not configured
|
|
103
103
|
api.addEntryImportsAhead(() => {
|
|
104
104
|
const style = api.config.antd.style || 'less';
|
|
105
|
-
return api.config.antd.import
|
|
105
|
+
return api.config.antd.import && !api.appData.vite
|
|
106
106
|
? []
|
|
107
107
|
: [
|
|
108
108
|
{
|
package/dist/dva.js
CHANGED
|
@@ -67,16 +67,15 @@ exports.default = (api) => {
|
|
|
67
67
|
// aliased to @umijs/plugins/templates/dva
|
|
68
68
|
import { create, Provider } from 'dva';
|
|
69
69
|
import React, { useRef } from 'react';
|
|
70
|
-
import {
|
|
70
|
+
import { history } from 'umi';
|
|
71
71
|
import { models } from './models';
|
|
72
72
|
|
|
73
73
|
export function RootContainer(props: any) {
|
|
74
|
-
const { navigator } = useAppData();
|
|
75
74
|
const app = useRef<any>();
|
|
76
75
|
if (!app.current) {
|
|
77
76
|
app.current = create(
|
|
78
77
|
{
|
|
79
|
-
history
|
|
78
|
+
history,
|
|
80
79
|
},
|
|
81
80
|
{
|
|
82
81
|
initialReducer: {},
|
|
@@ -84,7 +83,7 @@ export function RootContainer(props: any) {
|
|
|
84
83
|
return [...middlewares];
|
|
85
84
|
},
|
|
86
85
|
setupApp(app: IDvaApp) {
|
|
87
|
-
app._history =
|
|
86
|
+
app._history = history;
|
|
88
87
|
},
|
|
89
88
|
},
|
|
90
89
|
);
|
package/dist/layout.js
CHANGED
|
@@ -74,6 +74,13 @@ ${hasInitialStatePlugin
|
|
|
74
74
|
? `import { useModel } from '@@/plugin-model';`
|
|
75
75
|
: 'const useModel = null;'}
|
|
76
76
|
|
|
77
|
+
${api.config.locale
|
|
78
|
+
? `
|
|
79
|
+
import { useIntl } from '@@/plugin-locale';
|
|
80
|
+
`.trim()
|
|
81
|
+
: ''}
|
|
82
|
+
|
|
83
|
+
|
|
77
84
|
export default () => {
|
|
78
85
|
const location = useLocation();
|
|
79
86
|
const navigate = useNavigate();
|
|
@@ -85,16 +92,26 @@ export default () => {
|
|
|
85
92
|
};
|
|
86
93
|
const { initialState, loading, setInitialState } = initialInfo;
|
|
87
94
|
const userConfig = ${JSON.stringify(api.config.layout, null, 2)};
|
|
95
|
+
${api.config.locale
|
|
96
|
+
? `
|
|
97
|
+
const { formatMessage } = useIntl();
|
|
98
|
+
`.trim()
|
|
99
|
+
: 'const formatMessage = undefined;'}
|
|
88
100
|
const runtimeConfig = pluginManager.applyPlugins({
|
|
89
101
|
key: 'layout',
|
|
90
102
|
type: 'modify',
|
|
91
|
-
initialValue: {
|
|
103
|
+
initialValue: {
|
|
104
|
+
...initialInfo
|
|
105
|
+
},
|
|
92
106
|
});
|
|
107
|
+
const route = clientRoutes.filter(r => {
|
|
108
|
+
return r.id === 'ant-design-pro-layout';
|
|
109
|
+
})[0];
|
|
93
110
|
return (
|
|
94
111
|
<ProLayout
|
|
95
|
-
route={
|
|
112
|
+
route={route}
|
|
96
113
|
location={location}
|
|
97
|
-
title={userConfig.
|
|
114
|
+
title={userConfig.title || 'plugin-layout'}
|
|
98
115
|
navTheme="dark"
|
|
99
116
|
siderWidth={256}
|
|
100
117
|
onMenuHeaderClick={(e) => {
|
|
@@ -102,6 +119,7 @@ export default () => {
|
|
|
102
119
|
e.preventDefault();
|
|
103
120
|
navigate('/');
|
|
104
121
|
}}
|
|
122
|
+
formatMessage={userConfig.formatMessage || formatMessage}
|
|
105
123
|
menu={{ locale: userConfig.locale }}
|
|
106
124
|
logo={Logo}
|
|
107
125
|
menuItemRender={(menuItemProps, defaultDom) => {
|
|
@@ -154,9 +172,13 @@ export default () => {
|
|
|
154
172
|
const { icon } = api.appData.routes[id];
|
|
155
173
|
if (icon) {
|
|
156
174
|
const upperIcon = plugin_utils_1.lodash.upperFirst(plugin_utils_1.lodash.camelCase(icon));
|
|
175
|
+
(0, assert_1.default)(
|
|
157
176
|
// @ts-ignore
|
|
158
|
-
|
|
159
|
-
|
|
177
|
+
allIcons[upperIcon] || allIcons[`${upperIcon}Outlined`], `Icon ${upperIcon} is not found`);
|
|
178
|
+
// @ts-ignore
|
|
179
|
+
if (allIcons[upperIcon]) {
|
|
180
|
+
memo[upperIcon] = true;
|
|
181
|
+
}
|
|
160
182
|
// @ts-ignore
|
|
161
183
|
if (allIcons[`${upperIcon}Outlined`]) {
|
|
162
184
|
memo[`${upperIcon}Outlined`] = true;
|
|
@@ -448,6 +470,9 @@ export default LogoIcon;
|
|
|
448
470
|
{
|
|
449
471
|
id: 'ant-design-pro-layout',
|
|
450
472
|
file: (0, withTmpPath_1.withTmpPath)({ api, path: 'Layout.tsx' }),
|
|
473
|
+
test: (route) => {
|
|
474
|
+
return route.layout !== false;
|
|
475
|
+
},
|
|
451
476
|
},
|
|
452
477
|
];
|
|
453
478
|
});
|
package/dist/locale.js
CHANGED
|
@@ -186,8 +186,8 @@ exports.default = (api) => {
|
|
|
186
186
|
api.writeTmpFile({
|
|
187
187
|
path: 'index.ts',
|
|
188
188
|
content: `
|
|
189
|
-
export
|
|
190
|
-
export
|
|
189
|
+
export { useIntl, formatMessage, FormattedMessage } from './localeExports.ts';
|
|
190
|
+
export { SelectLang } from './SelectLang.tsx';
|
|
191
191
|
`,
|
|
192
192
|
});
|
|
193
193
|
}));
|
package/dist/qiankun/master.js
CHANGED
|
@@ -22,9 +22,7 @@ exports.default = (api) => {
|
|
|
22
22
|
api.addRuntimePlugin(() => {
|
|
23
23
|
return [(0, withTmpPath_1.withTmpPath)({ api, path: 'masterRuntimePlugin.tsx' })];
|
|
24
24
|
});
|
|
25
|
-
api.modifyDefaultConfig((config) => (Object.assign(Object.assign({}, config), {
|
|
26
|
-
// TODO: support mountElementId
|
|
27
|
-
mountElementId: constants_1.defaultMasterRootId, qiankun: Object.assign(Object.assign({}, config.qiankun), { master: Object.assign(Object.assign({}, JSON.parse(process.env.INITIAL_QIANKUN_MASTER_OPTIONS || '{}')), (config.qiankun || {}).master) }) })));
|
|
25
|
+
api.modifyDefaultConfig((config) => (Object.assign(Object.assign({}, config), { mountElementId: constants_1.defaultMasterRootId, qiankun: Object.assign(Object.assign({}, config.qiankun), { master: Object.assign(Object.assign({}, JSON.parse(process.env.INITIAL_QIANKUN_MASTER_OPTIONS || '{}')), (config.qiankun || {}).master) }) })));
|
|
28
26
|
// TODO: modify routes
|
|
29
27
|
api.modifyRoutes((memo) => {
|
|
30
28
|
Object.keys(memo).forEach((id) => {
|
|
@@ -50,7 +48,7 @@ exports.default = (api) => {
|
|
|
50
48
|
api.register({
|
|
51
49
|
key: 'addExtraModels',
|
|
52
50
|
fn() {
|
|
53
|
-
const
|
|
51
|
+
const { path, exports } = api.appData.appJS || {};
|
|
54
52
|
return path && exports.includes(constants_1.MODEL_EXPORT_NAME)
|
|
55
53
|
? [
|
|
56
54
|
`${path}#{"namespace":"${constants_1.qiankunStateForSlaveModelNamespace}","exportName":"${constants_1.MODEL_EXPORT_NAME}"}`,
|
package/dist/qiankun/slave.js
CHANGED
|
@@ -38,7 +38,6 @@ exports.default = (api) => {
|
|
|
38
38
|
const initialSlaveOptions = Object.assign(Object.assign({ devSourceMap: true }, JSON.parse(process.env.INITIAL_QIANKUN_SLAVE_OPTIONS || '{}')), (memo.qiankun || {}).slave);
|
|
39
39
|
const modifiedDefaultConfig = Object.assign(Object.assign({}, memo), {
|
|
40
40
|
// 默认开启 runtimePublicPath,避免出现 dynamic import 场景子应用资源地址出问题
|
|
41
|
-
// TODO: runtimePublicPath
|
|
42
41
|
runtimePublicPath: true,
|
|
43
42
|
// TODO: runtimeHistory
|
|
44
43
|
runtimeHistory: {}, qiankun: Object.assign(Object.assign({}, memo.qiankun), { slave: initialSlaveOptions }) });
|
|
@@ -84,8 +83,8 @@ exports.default = (api) => {
|
|
|
84
83
|
$('script').each((_, el) => {
|
|
85
84
|
var _a;
|
|
86
85
|
const scriptEl = $(el);
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
86
|
+
const umiEntry = /\/?umi(\.\w+)?\.js$/g;
|
|
87
|
+
if (umiEntry.test((_a = scriptEl.attr('src')) !== null && _a !== void 0 ? _a : '')) {
|
|
89
88
|
scriptEl.attr('entry', '');
|
|
90
89
|
}
|
|
91
90
|
});
|
package/dist/request.js
CHANGED
|
@@ -15,9 +15,9 @@ exports.default = (api) => {
|
|
|
15
15
|
api.addRuntimePluginKey(() => ['request']);
|
|
16
16
|
const requestTpl = `
|
|
17
17
|
import axios, {
|
|
18
|
-
AxiosInstance,
|
|
19
|
-
AxiosRequestConfig,
|
|
20
|
-
AxiosResponse,
|
|
18
|
+
type AxiosInstance,
|
|
19
|
+
type AxiosRequestConfig,
|
|
20
|
+
type AxiosResponse,
|
|
21
21
|
} from '{{{axiosPath}}}';
|
|
22
22
|
import useUmiRequest, { UseRequestProvider } from '{{{umiRequestPath}}}';
|
|
23
23
|
import { message, notification } from '{{{antdPkg}}}';
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
PaginatedOptionsWithFormat,
|
|
40
40
|
PaginatedParams,
|
|
41
41
|
PaginatedResult,
|
|
42
|
-
} from '{{{umiRequestPath}}}/
|
|
42
|
+
} from '{{{umiRequestPath}}}/es/types';
|
|
43
43
|
|
|
44
44
|
type ResultWithData< T = any > = { data?: T; [key: string]: any };
|
|
45
45
|
|
|
@@ -290,7 +290,11 @@ export {
|
|
|
290
290
|
api.writeTmpFile({
|
|
291
291
|
path: 'index.ts',
|
|
292
292
|
content: `
|
|
293
|
-
export
|
|
293
|
+
export {
|
|
294
|
+
useRequest,
|
|
295
|
+
UseRequestProvider,
|
|
296
|
+
request,
|
|
297
|
+
} from './request';
|
|
294
298
|
`,
|
|
295
299
|
});
|
|
296
300
|
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
const child_process_1 = require("child_process");
|
|
23
|
+
const path = __importStar(require("path"));
|
|
24
|
+
exports.default = (api) => {
|
|
25
|
+
api.describe({ key: 'tailwindcss' });
|
|
26
|
+
api.onStart(() => {
|
|
27
|
+
const inputPath = path.resolve(api.cwd, 'tailwind.css');
|
|
28
|
+
const generatedPath = path.resolve(api.paths.absTmpPath, 'tailwind.css');
|
|
29
|
+
const binPath = path.resolve(api.cwd, 'node_modules/.bin/tailwind');
|
|
30
|
+
/** 透过子进程建立 tailwindcss 服务,将生成的 css 写入 generatedPath */
|
|
31
|
+
const tailwind = (0, child_process_1.exec)(`${binPath} -i ${inputPath} -o ${generatedPath} --watch`, { cwd: api.cwd });
|
|
32
|
+
tailwind.on('error', (m) => {
|
|
33
|
+
api.logger.error('tailwindcss service encounter an error: ' + m);
|
|
34
|
+
});
|
|
35
|
+
/** 将生成的 css 文件加入到 import 中 */
|
|
36
|
+
api.addEntryImports(() => [{ source: generatedPath }]);
|
|
37
|
+
});
|
|
38
|
+
};
|
package/dist/unocss.d.ts
ADDED
package/dist/unocss.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const utils_1 = require("@umijs/utils");
|
|
26
|
+
const child_process_1 = require("child_process");
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
const path_1 = __importDefault(require("path"));
|
|
29
|
+
exports.default = (api) => {
|
|
30
|
+
api.describe({
|
|
31
|
+
key: 'unocss',
|
|
32
|
+
config: {
|
|
33
|
+
schema(Joi) {
|
|
34
|
+
return Joi.object({
|
|
35
|
+
watch: Joi.array(),
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
enableBy: api.EnableBy.config,
|
|
40
|
+
});
|
|
41
|
+
api.onStart(() => {
|
|
42
|
+
/** 由于 @unocss/cli 对设置文件进行了检查,因此加入需要 unocss.config.ts 设置的提示
|
|
43
|
+
* https://github.com/antfu/unocss/blob/main/packages/cli/src/index.ts#L93 */
|
|
44
|
+
if (!fs.existsSync(path_1.default.resolve(api.paths.cwd, 'unocss.config.ts')))
|
|
45
|
+
utils_1.logger.warn('请在项目目录中添加 unocss.config.ts 文件,并配置需要的 unocss presets,否则插件将没有效果!');
|
|
46
|
+
const generatedPath = path_1.default.resolve(api.paths.absTmpPath, 'uno.css');
|
|
47
|
+
const binPath = path_1.default.resolve(api.cwd, 'node_modules/.bin/unocss');
|
|
48
|
+
const watchDirs = api.config.unocss.watch;
|
|
49
|
+
/** 透过子进程建立 unocss 服务,将生成的 css 写入 generatedPath */
|
|
50
|
+
const unocss = (0, child_process_1.exec)(`${binPath} ${watchDirs.join(' ')} --out-file ${generatedPath} --watch`, { cwd: api.cwd });
|
|
51
|
+
unocss.on('error', (m) => {
|
|
52
|
+
api.logger.error('unocss service encounter an error: ' + m);
|
|
53
|
+
});
|
|
54
|
+
/** 将生成的 css 文件加入到 import 中 */
|
|
55
|
+
api.addEntryImports(() => [{ source: generatedPath }]);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
@@ -46,10 +46,7 @@ function patchMicroAppRouteComponent(routes: any[]) {
|
|
|
46
46
|
if (rootRoutes) {
|
|
47
47
|
const { routeBindingAlias, base, masterHistoryType } =
|
|
48
48
|
getMasterOptions() as MasterOptions;
|
|
49
|
-
|
|
50
|
-
(r) => !r.insert,
|
|
51
|
-
);
|
|
52
|
-
microAppAttachedRoutes.reverse().forEach((microAppRoute) => {
|
|
49
|
+
microAppRuntimeRoutes.reverse().forEach((microAppRoute) => {
|
|
53
50
|
const patchRoute = (route: any) => {
|
|
54
51
|
patchMicroAppRoute(route, getMicroAppRouteComponent, {
|
|
55
52
|
base,
|
|
@@ -62,7 +59,7 @@ function patchMicroAppRouteComponent(routes: any[]) {
|
|
|
62
59
|
};
|
|
63
60
|
|
|
64
61
|
patchRoute(microAppRoute);
|
|
65
|
-
rootRoutes.unshift(microAppRoute);
|
|
62
|
+
!microAppRoute.insert && rootRoutes.unshift(microAppRoute);
|
|
66
63
|
});
|
|
67
64
|
}
|
|
68
65
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.18",
|
|
4
4
|
"description": "@umijs/plugins",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/plugins#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@ahooksjs/use-request": "^2.0.0",
|
|
25
25
|
"@ant-design/icons": "^4.7.0",
|
|
26
26
|
"@ant-design/pro-layout": "^6.31.7",
|
|
27
|
-
"@umijs/bundler-utils": "4.0.0-beta.
|
|
27
|
+
"@umijs/bundler-utils": "4.0.0-beta.18",
|
|
28
28
|
"antd": "^4.17.3",
|
|
29
29
|
"antd-dayjs-webpack-plugin": "^1.0.6",
|
|
30
30
|
"axios": "^0.24.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"warning": "^4.0.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"umi": "4.0.0-beta.
|
|
45
|
+
"umi": "4.0.0-beta.18"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|