@umijs/plugins 4.0.0-rc.14 → 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/access.js +2 -11
- package/dist/antd.js +8 -2
- package/dist/dva.js +1 -0
- package/dist/initial-state.js +1 -1
- package/dist/layout.js +1 -1
- package/dist/locale.js +30 -32
- package/dist/model.js +27 -29
- package/dist/qiankun/master.js +16 -2
- package/dist/qiankun/slave.js +18 -5
- package/dist/request.js +6 -4
- package/dist/utils/localeUtils.js +5 -14
- package/dist/utils/modelUtils.d.ts +1 -0
- package/dist/utils/modelUtils.js +1 -0
- package/libs/qiankun/master/MicroApp.tsx +7 -0
- package/libs/qiankun/slave/connectMaster.tsx +0 -1
- package/libs/qiankun/slave/lifecycles.ts +6 -8
- package/libs/qiankun/slave/qiankunModel.ts +0 -1
- package/libs/qiankun/slave/slaveRuntimePlugin.ts +9 -15
- package/package.json +3 -3
package/dist/access.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -24,7 +15,7 @@ exports.default = (api) => {
|
|
|
24
15
|
},
|
|
25
16
|
enableBy: api.EnableBy.config,
|
|
26
17
|
});
|
|
27
|
-
api.onGenerateFiles(() =>
|
|
18
|
+
api.onGenerateFiles(async () => {
|
|
28
19
|
// allow enable access without access file
|
|
29
20
|
const hasAccessFile = ['js', 'jsx', 'ts', 'tsx'].some((ext) => fs_1.default.existsSync((0, path_1.join)(api.paths.absSrcPath, `access.${ext}`)));
|
|
30
21
|
// runtime.tsx
|
|
@@ -137,7 +128,7 @@ import React from 'react';
|
|
|
137
128
|
export const AccessContext = React.createContext<any>(null);
|
|
138
129
|
`,
|
|
139
130
|
});
|
|
140
|
-
})
|
|
131
|
+
});
|
|
141
132
|
api.addRuntimePlugin(() => {
|
|
142
133
|
return [(0, withTmpPath_1.withTmpPath)({ api, path: 'runtime.tsx' })];
|
|
143
134
|
});
|
package/dist/antd.js
CHANGED
|
@@ -57,12 +57,18 @@ exports.default = (api) => {
|
|
|
57
57
|
// dark mode & compact mode
|
|
58
58
|
if (memo.antd.dark || memo.antd.compact) {
|
|
59
59
|
const { getThemeVariables } = require('antd/dist/theme');
|
|
60
|
-
memo.theme =
|
|
60
|
+
memo.theme = {
|
|
61
|
+
...getThemeVariables(memo.antd),
|
|
62
|
+
...memo.theme,
|
|
63
|
+
};
|
|
61
64
|
}
|
|
62
65
|
return memo;
|
|
63
66
|
});
|
|
64
67
|
api.modifyConfig((memo) => {
|
|
65
|
-
memo.theme =
|
|
68
|
+
memo.theme = {
|
|
69
|
+
'root-entry-name': 'default',
|
|
70
|
+
...memo.theme,
|
|
71
|
+
};
|
|
66
72
|
return memo;
|
|
67
73
|
});
|
|
68
74
|
// babel-plugin-import
|
package/dist/dva.js
CHANGED
package/dist/initial-state.js
CHANGED
|
@@ -13,7 +13,7 @@ exports.default = (api) => {
|
|
|
13
13
|
enableBy: api.EnableBy.config,
|
|
14
14
|
});
|
|
15
15
|
api.register({
|
|
16
|
-
key: '
|
|
16
|
+
key: 'addExtraModelsPre',
|
|
17
17
|
fn: () => [(0, withTmpPath_1.withTmpPath)({ api, path: '@@initialState.ts' })],
|
|
18
18
|
});
|
|
19
19
|
api.addRuntimePluginKey(() => ['getInitialState']);
|
package/dist/layout.js
CHANGED
package/dist/locale.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.packageNormalize = void 0;
|
|
13
4
|
const fs_1 = require("fs");
|
|
@@ -58,9 +49,9 @@ exports.default = (api) => {
|
|
|
58
49
|
},
|
|
59
50
|
]
|
|
60
51
|
: []);
|
|
61
|
-
const addAntdLocales = (args) =>
|
|
52
|
+
const addAntdLocales = async (args) => {
|
|
62
53
|
var _a;
|
|
63
|
-
return
|
|
54
|
+
return await api.applyPlugins({
|
|
64
55
|
key: 'addAntdLocales',
|
|
65
56
|
type: api.ApplyPluginsType.add,
|
|
66
57
|
initialValue: [
|
|
@@ -68,29 +59,32 @@ exports.default = (api) => {
|
|
|
68
59
|
],
|
|
69
60
|
args,
|
|
70
61
|
});
|
|
71
|
-
}
|
|
72
|
-
const getList = (resolveKey) =>
|
|
73
|
-
var
|
|
62
|
+
};
|
|
63
|
+
const getList = async (resolveKey) => {
|
|
64
|
+
var _a;
|
|
74
65
|
const { paths } = api;
|
|
75
66
|
return (0, localeUtils_1.getLocaleList)({
|
|
76
67
|
localeFolder: 'locales',
|
|
77
|
-
separator: (
|
|
68
|
+
separator: (_a = api.config.locale) === null || _a === void 0 ? void 0 : _a.baseSeparator,
|
|
78
69
|
absSrcPath: paths.absSrcPath,
|
|
79
70
|
absPagesPath: paths.absPagesPath,
|
|
80
71
|
addAntdLocales,
|
|
81
72
|
resolveKey,
|
|
82
73
|
});
|
|
83
|
-
}
|
|
84
|
-
api.onGenerateFiles(() =>
|
|
85
|
-
var
|
|
74
|
+
};
|
|
75
|
+
api.onGenerateFiles(async () => {
|
|
76
|
+
var _a, _b, _c, _d;
|
|
86
77
|
const localeTpl = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../libs/locale/locale.tpl'), 'utf-8');
|
|
87
78
|
// moment2dayjs
|
|
88
79
|
const resolveKey = api.config.moment2dayjs ? 'dayjs' : 'moment';
|
|
89
80
|
const momentPkgPath = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve(`${resolveKey}/package.json`)));
|
|
90
81
|
const EventEmitterPkg = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('event-emitter/package')));
|
|
91
|
-
const { baseSeparator, baseNavigator, antd, title, useLocalStorage } =
|
|
92
|
-
|
|
93
|
-
|
|
82
|
+
const { baseSeparator, baseNavigator, antd, title, useLocalStorage } = {
|
|
83
|
+
...defaultConfig,
|
|
84
|
+
...api.config.locale,
|
|
85
|
+
};
|
|
86
|
+
const defaultLocale = ((_a = api.config.locale) === null || _a === void 0 ? void 0 : _a.default) || `zh${baseSeparator}CN`;
|
|
87
|
+
const localeList = await getList(resolveKey);
|
|
94
88
|
const momentLocales = localeList
|
|
95
89
|
.map(({ momentLocale }) => momentLocale)
|
|
96
90
|
.filter((locale) => locale);
|
|
@@ -100,7 +94,7 @@ exports.default = (api) => {
|
|
|
100
94
|
let MomentLocales = momentLocales;
|
|
101
95
|
let DefaultMomentLocale = '';
|
|
102
96
|
// set moment default accounding to locale.default
|
|
103
|
-
if (!MomentLocales.length && ((
|
|
97
|
+
if (!MomentLocales.length && ((_b = api.config.locale) === null || _b === void 0 ? void 0 : _b.default)) {
|
|
104
98
|
const [lang, country = ''] = defaultLocale.split(baseSeparator);
|
|
105
99
|
const { momentLocale } = (0, localeUtils_1.getMomentLocale)(lang, country, resolveKey);
|
|
106
100
|
if (momentLocale) {
|
|
@@ -110,9 +104,9 @@ exports.default = (api) => {
|
|
|
110
104
|
}
|
|
111
105
|
let DefaultAntdLocales = [];
|
|
112
106
|
// set antd default locale
|
|
113
|
-
if (!antdLocales.length && ((
|
|
107
|
+
if (!antdLocales.length && ((_c = api.config.locale) === null || _c === void 0 ? void 0 : _c.antd)) {
|
|
114
108
|
const [lang, country = ''] = defaultLocale.split(baseSeparator);
|
|
115
|
-
DefaultAntdLocales = plugin_utils_1.lodash.uniq(
|
|
109
|
+
DefaultAntdLocales = plugin_utils_1.lodash.uniq(await addAntdLocales({
|
|
116
110
|
lang,
|
|
117
111
|
country,
|
|
118
112
|
}));
|
|
@@ -148,13 +142,17 @@ exports.default = (api) => {
|
|
|
148
142
|
UseLocalStorage: !!useLocalStorage,
|
|
149
143
|
LocaleDir: localeDirName,
|
|
150
144
|
ExistLocaleDir: (0, fs_1.existsSync)(localeDirPath),
|
|
151
|
-
LocaleList: localeList.map((locale) => (
|
|
145
|
+
LocaleList: localeList.map((locale) => ({
|
|
146
|
+
...locale,
|
|
147
|
+
antdLocale: locale.antdLocale.map((antdLocale, index) => ({
|
|
152
148
|
locale: antdLocale,
|
|
153
149
|
index: index,
|
|
154
|
-
})),
|
|
150
|
+
})),
|
|
151
|
+
paths: locale.paths.map((path, index) => ({
|
|
155
152
|
path,
|
|
156
153
|
index,
|
|
157
|
-
}))
|
|
154
|
+
})),
|
|
155
|
+
})),
|
|
158
156
|
Antd: !!antd,
|
|
159
157
|
DefaultLocale: JSON.stringify(defaultLocale),
|
|
160
158
|
warningPkgPath: (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('warning/package'))),
|
|
@@ -177,7 +175,7 @@ exports.default = (api) => {
|
|
|
177
175
|
Antd: !!antd,
|
|
178
176
|
LocaleList: localeList,
|
|
179
177
|
ShowSelectLang: localeList.length > 1 && !!antd,
|
|
180
|
-
antdFiles: ((
|
|
178
|
+
antdFiles: ((_d = api.config) === null || _d === void 0 ? void 0 : _d.ssr) ? 'lib' : 'es',
|
|
181
179
|
}),
|
|
182
180
|
});
|
|
183
181
|
// index.ts
|
|
@@ -188,14 +186,14 @@ export { setLocale, getLocale, useIntl, injectIntl, formatMessage, FormattedMess
|
|
|
188
186
|
export { SelectLang } from './SelectLang.tsx';
|
|
189
187
|
`,
|
|
190
188
|
});
|
|
191
|
-
})
|
|
189
|
+
});
|
|
192
190
|
// Runtime Plugin
|
|
193
191
|
api.addRuntimePlugin(() => [(0, withTmpPath_1.withTmpPath)({ api, path: 'runtime.tsx' })]);
|
|
194
192
|
api.addRuntimePluginKey(() => ['locale']);
|
|
195
193
|
// watch locale files
|
|
196
|
-
api.addTmpGenerateWatcherPaths(() =>
|
|
194
|
+
api.addTmpGenerateWatcherPaths(async () => {
|
|
197
195
|
const resolveKey = api.config.moment2dayjs ? 'dayjs' : 'moment';
|
|
198
|
-
const localeList =
|
|
196
|
+
const localeList = await getList(resolveKey);
|
|
199
197
|
return (0, localeUtils_1.exactLocalePaths)(localeList);
|
|
200
|
-
})
|
|
198
|
+
});
|
|
201
199
|
};
|
package/dist/model.js
CHANGED
|
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
26
|
const t = __importStar(require("@umijs/bundler-utils/compiled/babel/types"));
|
|
36
27
|
const fs_1 = require("fs");
|
|
@@ -49,17 +40,17 @@ exports.default = (api) => {
|
|
|
49
40
|
},
|
|
50
41
|
enableBy: api.EnableBy.config,
|
|
51
42
|
});
|
|
52
|
-
api.modifyAppData((memo) =>
|
|
53
|
-
const models =
|
|
43
|
+
api.modifyAppData(async (memo) => {
|
|
44
|
+
const models = await getAllModels(api);
|
|
54
45
|
memo.pluginModel = {
|
|
55
46
|
models,
|
|
56
47
|
};
|
|
57
48
|
return memo;
|
|
58
|
-
})
|
|
59
|
-
api.onGenerateFiles((args) =>
|
|
49
|
+
});
|
|
50
|
+
api.onGenerateFiles(async (args) => {
|
|
60
51
|
const models = args.isFirstTime
|
|
61
52
|
? api.appData.pluginModel.models
|
|
62
|
-
:
|
|
53
|
+
: await getAllModels(api);
|
|
63
54
|
// model.ts
|
|
64
55
|
api.writeTmpFile({
|
|
65
56
|
path: 'model.ts',
|
|
@@ -94,7 +85,7 @@ export function dataflowProvider(container, opts) {
|
|
|
94
85
|
}
|
|
95
86
|
`,
|
|
96
87
|
});
|
|
97
|
-
})
|
|
88
|
+
});
|
|
98
89
|
api.addTmpGenerateWatcherPaths(() => {
|
|
99
90
|
return [(0, path_1.join)(api.paths.absSrcPath, 'models')];
|
|
100
91
|
});
|
|
@@ -102,19 +93,26 @@ export function dataflowProvider(container, opts) {
|
|
|
102
93
|
return [(0, withTmpPath_1.withTmpPath)({ api, path: 'runtime.tsx' })];
|
|
103
94
|
});
|
|
104
95
|
};
|
|
105
|
-
function getAllModels(api) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
96
|
+
async function getAllModels(api) {
|
|
97
|
+
const extraModelsPre = await api.applyPlugins({
|
|
98
|
+
key: 'addExtraModelsPre',
|
|
99
|
+
type: api.ApplyPluginsType.add,
|
|
100
|
+
initialValue: [],
|
|
101
|
+
});
|
|
102
|
+
const extraModels = await api.applyPlugins({
|
|
103
|
+
key: 'addExtraModels',
|
|
104
|
+
type: api.ApplyPluginsType.add,
|
|
105
|
+
initialValue: [],
|
|
106
|
+
});
|
|
107
|
+
return new modelUtils_1.ModelUtils(api, {
|
|
108
|
+
astTest({ node }) {
|
|
109
|
+
return t.isArrowFunctionExpression(node) || t.isFunctionDeclaration(node);
|
|
110
|
+
},
|
|
111
|
+
}).getAllModels({
|
|
112
|
+
extraModelsPre: [
|
|
113
|
+
...extraModelsPre,
|
|
114
|
+
...(api.config.model.extraModelsPre || []),
|
|
115
|
+
],
|
|
116
|
+
extraModels: [...extraModels, ...(api.config.model.extraModels || [])],
|
|
119
117
|
});
|
|
120
118
|
}
|
package/dist/qiankun/master.js
CHANGED
|
@@ -23,7 +23,17 @@ exports.default = (api) => {
|
|
|
23
23
|
api.addRuntimePlugin(() => {
|
|
24
24
|
return [(0, withTmpPath_1.withTmpPath)({ api, path: 'masterRuntimePlugin.tsx' })];
|
|
25
25
|
});
|
|
26
|
-
api.modifyDefaultConfig((config) => (
|
|
26
|
+
api.modifyDefaultConfig((config) => ({
|
|
27
|
+
...config,
|
|
28
|
+
mountElementId: constants_1.defaultMasterRootId,
|
|
29
|
+
qiankun: {
|
|
30
|
+
...config.qiankun,
|
|
31
|
+
master: {
|
|
32
|
+
...JSON.parse(process.env.INITIAL_QIANKUN_MASTER_OPTIONS || '{}'),
|
|
33
|
+
...(config.qiankun || {}).master,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
}));
|
|
27
37
|
// TODO: modify routes
|
|
28
38
|
api.modifyRoutes((memo) => {
|
|
29
39
|
Object.keys(memo).forEach((id) => {
|
|
@@ -65,7 +75,11 @@ exports.default = (api) => {
|
|
|
65
75
|
api.writeTmpFile({
|
|
66
76
|
path: 'masterOptions.ts',
|
|
67
77
|
content: `
|
|
68
|
-
let options = ${JSON.stringify(
|
|
78
|
+
let options = ${JSON.stringify({
|
|
79
|
+
masterHistoryType: ((_a = api.config.history) === null || _a === void 0 ? void 0 : _a.type) || constants_1.defaultHistoryType,
|
|
80
|
+
base: api.config.base || '/',
|
|
81
|
+
...api.config.qiankun.master,
|
|
82
|
+
})};
|
|
69
83
|
export const getMasterOptions = () => options;
|
|
70
84
|
export const setMasterOptions = (newOpts) => options = ({ ...options, ...newOpts });
|
|
71
85
|
`,
|
package/dist/qiankun/slave.js
CHANGED
|
@@ -36,10 +36,20 @@ exports.default = (api) => {
|
|
|
36
36
|
});
|
|
37
37
|
api.modifyDefaultConfig((memo) => {
|
|
38
38
|
var _a, _b, _c, _d;
|
|
39
|
-
const initialSlaveOptions =
|
|
40
|
-
|
|
39
|
+
const initialSlaveOptions = {
|
|
40
|
+
devSourceMap: true,
|
|
41
|
+
...JSON.parse(process.env.INITIAL_QIANKUN_SLAVE_OPTIONS || '{}'),
|
|
42
|
+
...(memo.qiankun || {}).slave,
|
|
43
|
+
};
|
|
44
|
+
const modifiedDefaultConfig = {
|
|
45
|
+
...memo,
|
|
41
46
|
// 默认开启 runtimePublicPath,避免出现 dynamic import 场景子应用资源地址出问题
|
|
42
|
-
runtimePublicPath: true,
|
|
47
|
+
runtimePublicPath: true,
|
|
48
|
+
qiankun: {
|
|
49
|
+
...memo.qiankun,
|
|
50
|
+
slave: initialSlaveOptions,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
43
53
|
const shouldNotModifyDefaultBase = (_c = (_b = (_a = api.userConfig.qiankun) === null || _a === void 0 ? void 0 : _a.slave) === null || _b === void 0 ? void 0 : _b.shouldNotModifyDefaultBase) !== null && _c !== void 0 ? _c : initialSlaveOptions.shouldNotModifyDefaultBase;
|
|
44
54
|
const historyType = ((_d = api.userConfig.history) === null || _d === void 0 ? void 0 : _d.type) || 'browser';
|
|
45
55
|
if (!shouldNotModifyDefaultBase && historyType !== 'hash') {
|
|
@@ -52,8 +62,11 @@ exports.default = (api) => {
|
|
|
52
62
|
var _a, _b;
|
|
53
63
|
// mfsu 场景默认给子应用增加 mfName 配置,从而避免冲突
|
|
54
64
|
if (config.mfsu !== false) {
|
|
55
|
-
config.mfsu =
|
|
56
|
-
|
|
65
|
+
config.mfsu = {
|
|
66
|
+
...config.mfsu,
|
|
67
|
+
mfName: ((_a = config.mfsu) === null || _a === void 0 ? void 0 : _a.mfName) ||
|
|
68
|
+
`mf_${(_b = api.pkg.name) === null || _b === void 0 ? void 0 : _b.replace(/^@/, '').replace(/\W/g, '_')}`,
|
|
69
|
+
};
|
|
57
70
|
}
|
|
58
71
|
return config;
|
|
59
72
|
});
|
package/dist/request.js
CHANGED
|
@@ -291,6 +291,12 @@ export type {
|
|
|
291
291
|
formatResult,
|
|
292
292
|
}),
|
|
293
293
|
});
|
|
294
|
+
api.writeTmpFile({
|
|
295
|
+
path: 'types.d.ts',
|
|
296
|
+
content: `
|
|
297
|
+
export type { RequestConfig } from './request';
|
|
298
|
+
`,
|
|
299
|
+
});
|
|
294
300
|
api.writeTmpFile({
|
|
295
301
|
path: 'index.ts',
|
|
296
302
|
content: `
|
|
@@ -299,10 +305,6 @@ export {
|
|
|
299
305
|
UseRequestProvider,
|
|
300
306
|
request,
|
|
301
307
|
} from './request';
|
|
302
|
-
|
|
303
|
-
export type {
|
|
304
|
-
RequestConfig
|
|
305
|
-
} from './request';
|
|
306
308
|
`,
|
|
307
309
|
});
|
|
308
310
|
});
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.isNeedPolyfill = exports.exactLocalePaths = exports.getLocaleList = exports.getAntdLocale = exports.getMomentLocale = void 0;
|
|
13
4
|
const fs_1 = require("fs");
|
|
@@ -55,7 +46,7 @@ const modulesHasLocale = (localePath) => {
|
|
|
55
46
|
return false;
|
|
56
47
|
}
|
|
57
48
|
};
|
|
58
|
-
const getLocaleList = (opts) =>
|
|
49
|
+
const getLocaleList = async (opts) => {
|
|
59
50
|
const { localeFolder, separator = '-', absSrcPath = '', absPagesPath = '', addAntdLocales, resolveKey = 'moment', } = opts;
|
|
60
51
|
const localeFileMath = new RegExp(`^([a-z]{2})${separator}?([A-Z]{2})?\.(js|json|ts)$`);
|
|
61
52
|
const localeFiles = plugin_utils_1.glob
|
|
@@ -80,11 +71,11 @@ const getLocaleList = (opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
80
71
|
};
|
|
81
72
|
});
|
|
82
73
|
const groups = plugin_utils_1.lodash.groupBy(localeFiles, 'name');
|
|
83
|
-
const promises = Object.keys(groups).map((name) =>
|
|
74
|
+
const promises = Object.keys(groups).map(async (name) => {
|
|
84
75
|
const [lang, country = ''] = name.split(separator);
|
|
85
76
|
const { momentLocale } = (0, exports.getMomentLocale)(lang, country, resolveKey);
|
|
86
77
|
const antdLocale = plugin_utils_1.lodash
|
|
87
|
-
.uniq(
|
|
78
|
+
.uniq(await addAntdLocales({ lang, country }))
|
|
88
79
|
.filter((localePath) => modulesHasLocale(localePath));
|
|
89
80
|
return {
|
|
90
81
|
lang,
|
|
@@ -97,9 +88,9 @@ const getLocaleList = (opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
97
88
|
paths: groups[name].map((item) => (0, plugin_utils_1.winPath)(item.path)),
|
|
98
89
|
momentLocale,
|
|
99
90
|
};
|
|
100
|
-
})
|
|
91
|
+
});
|
|
101
92
|
return Promise.all(promises);
|
|
102
|
-
}
|
|
93
|
+
};
|
|
103
94
|
exports.getLocaleList = getLocaleList;
|
|
104
95
|
const exactLocalePaths = (data) => {
|
|
105
96
|
return plugin_utils_1.lodash.flatten(data.map((item) => item.paths));
|
package/dist/utils/modelUtils.js
CHANGED
|
@@ -139,6 +139,13 @@ export const MicroApp = forwardRef(
|
|
|
139
139
|
setComponentError(null);
|
|
140
140
|
setLoading(true);
|
|
141
141
|
const configuration = {
|
|
142
|
+
fetch(url) {
|
|
143
|
+
return window.fetch(url, {
|
|
144
|
+
headers: {
|
|
145
|
+
accept: 'text/html',
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
},
|
|
142
149
|
globalContext: window,
|
|
143
150
|
...globalSettings,
|
|
144
151
|
...settingsFromProps,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
/* eslint-disable */
|
|
3
2
|
import { getPluginManager } from '@@/core/plugin';
|
|
4
3
|
import ReactDOM from 'react-dom';
|
|
5
4
|
import { ApplyPluginsType } from 'umi';
|
|
@@ -22,7 +21,7 @@ let render = noop;
|
|
|
22
21
|
let hasMountedAtLeastOnce = false;
|
|
23
22
|
|
|
24
23
|
export default () => defer.promise;
|
|
25
|
-
export const
|
|
24
|
+
export const contextOptsStack: any[] = [];
|
|
26
25
|
|
|
27
26
|
// function normalizeHistory(
|
|
28
27
|
// history?: 'string' | Record<string, any>,
|
|
@@ -79,10 +78,7 @@ export function genMount(mountElementId: string) {
|
|
|
79
78
|
// 默认开启
|
|
80
79
|
// 如果需要手动控制 loading,通过主应用配置 props.autoSetLoading false 可以关闭
|
|
81
80
|
callback: () => {
|
|
82
|
-
if (
|
|
83
|
-
props?.autoSetLoading &&
|
|
84
|
-
typeof props?.setLoading === 'function'
|
|
85
|
-
) {
|
|
81
|
+
if (props.autoSetLoading && typeof props.setLoading === 'function') {
|
|
86
82
|
props.setLoading(false);
|
|
87
83
|
}
|
|
88
84
|
|
|
@@ -94,9 +90,11 @@ export function genMount(mountElementId: string) {
|
|
|
94
90
|
// 支持通过 props 注入 container 来限定子应用 mountElementId 的查找范围
|
|
95
91
|
// 避免多个子应用出现在同一主应用时出现 mount 冲突
|
|
96
92
|
rootElement:
|
|
97
|
-
props
|
|
93
|
+
props.container?.querySelector(`#${mountElementId}`) ||
|
|
98
94
|
mountElementId,
|
|
99
95
|
|
|
96
|
+
basename: props.base,
|
|
97
|
+
|
|
100
98
|
// 当存在同一个 umi 子应用在同一个页面被多实例渲染的场景时(比如一个页面里,同时展示了这个子应用的多个路由页面)
|
|
101
99
|
// mount 钩子会被调用多次,但是具体什么时候对应的实例开始 render 则是不定的,即它调用 applyPlugins('modifyClientRenderOpts') 的时机是不确定的
|
|
102
100
|
// 为了保证每次 applyPlugins('modifyClientRenderOpts') 调用是生成正确的 history,我们需要这里通过闭包上下文维持 mount 调用时的一些配置信息
|
|
@@ -111,7 +109,7 @@ export function genMount(mountElementId: string) {
|
|
|
111
109
|
// },
|
|
112
110
|
};
|
|
113
111
|
|
|
114
|
-
|
|
112
|
+
contextOptsStack.push(clientRenderOpts);
|
|
115
113
|
}
|
|
116
114
|
|
|
117
115
|
// 第一次 mount defer 被 resolve 后umi 会自动触发 render,非第一次 mount 则需手动触发
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
|
|
3
|
-
import qiankunRender from './lifecycles';
|
|
2
|
+
import qiankunRender, { contextOptsStack } from './lifecycles';
|
|
4
3
|
|
|
5
4
|
export function render(oldRender: any) {
|
|
6
5
|
return qiankunRender().then(oldRender);
|
|
7
6
|
}
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// return {
|
|
18
|
-
// ...memo,
|
|
19
|
-
// ...clientRenderOpts,
|
|
20
|
-
// };
|
|
21
|
-
// }
|
|
8
|
+
export function modifyContextOpts(memo: any) {
|
|
9
|
+
// 每次应用 render 的时候会调 modifyClientRenderOpts,这时尝试从队列中取 render 的配置
|
|
10
|
+
const clientRenderOpts = contextOptsStack.shift();
|
|
11
|
+
return {
|
|
12
|
+
...memo,
|
|
13
|
+
...clientRenderOpts,
|
|
14
|
+
};
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.15",
|
|
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",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@ahooksjs/use-request": "^2.0.0",
|
|
26
26
|
"@ant-design/icons": "^4.7.0",
|
|
27
27
|
"@ant-design/pro-layout": "^6.35.1",
|
|
28
|
-
"@umijs/bundler-utils": "4.0.0-rc.
|
|
28
|
+
"@umijs/bundler-utils": "4.0.0-rc.15",
|
|
29
29
|
"antd-dayjs-webpack-plugin": "^1.0.6",
|
|
30
30
|
"axios": "^0.26.1",
|
|
31
31
|
"babel-plugin-import": "^1.13.3",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"warning": "^4.0.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"umi": "4.0.0-rc.
|
|
47
|
+
"umi": "4.0.0-rc.15"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|