@umijs/plugins 4.0.7 → 4.0.10
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 +155 -141
- package/dist/icons.js +28 -4
- package/dist/initial-state.js +80 -54
- package/dist/layout.js +219 -215
- package/dist/locale.js +214 -192
- package/dist/mf.d.ts +2 -0
- package/dist/mf.js +197 -0
- package/dist/model.js +79 -78
- package/dist/moment2dayjs.js +102 -81
- package/dist/qiankun/constants.js +41 -8
- package/dist/qiankun/master.js +163 -121
- package/dist/qiankun/slave.js +183 -148
- package/dist/qiankun.js +46 -19
- package/dist/request.js +91 -55
- package/dist/tailwindcss.js +74 -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/localeExports.tpl +7 -3
- package/libs/qiankun/master/MicroApp.tsx +17 -12
- package/libs/qiankun/master/types.ts +1 -1
- package/libs/qiankun/slave/lifecycles.ts +15 -7
- package/package.json +6 -6
|
@@ -1,126 +1,131 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* 获取 moment 包的 locale 名称
|
|
9
|
-
* @param lang 语言
|
|
10
|
-
* @param country 国家
|
|
11
|
-
* @param resolveKey 用来resolve的key,moment 或者 dayjs,为了使 dayjs 可以替换 moment
|
|
12
|
-
*/
|
|
13
|
-
const getMomentLocale = (lang, country, resolveKey) => {
|
|
14
|
-
var _a, _b;
|
|
15
|
-
const momentLocation = require
|
|
16
|
-
.resolve(`${resolveKey}/locale/zh-cn`)
|
|
17
|
-
.replace(/zh\-cn\.js$/, '');
|
|
18
|
-
if ((0, fs_1.existsSync)((0, path_1.join)(momentLocation, `${lang}-${(_a = country === null || country === void 0 ? void 0 : country.toLocaleLowerCase) === null || _a === void 0 ? void 0 : _a.call(country)}.js`))) {
|
|
19
|
-
const momentLocale = `${lang}-${(_b = country === null || country === void 0 ? void 0 : country.toLocaleLowerCase) === null || _b === void 0 ? void 0 : _b.call(country)}`;
|
|
20
|
-
return {
|
|
21
|
-
momentLocale,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
if ((0, fs_1.existsSync)((0, path_1.join)(momentLocation, `${lang}.js`))) {
|
|
25
|
-
return {
|
|
26
|
-
momentLocale: lang,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
return { momentLocale: '' };
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
30
8
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
* @returns
|
|
39
|
-
*/
|
|
40
|
-
const modulesHasLocale = (localePath) => {
|
|
41
|
-
try {
|
|
42
|
-
require.resolve(localePath);
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
48
16
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
.filter((localePath) => modulesHasLocale(localePath));
|
|
80
|
-
return {
|
|
81
|
-
lang,
|
|
82
|
-
name,
|
|
83
|
-
// react-intl Function.supportedLocalesOf
|
|
84
|
-
// Uncaught RangeError: Incorrect locale information provided
|
|
85
|
-
locale: name.split(separator).join('-'),
|
|
86
|
-
country,
|
|
87
|
-
antdLocale,
|
|
88
|
-
paths: groups[name].map((item) => (0, plugin_utils_1.winPath)(item.path)),
|
|
89
|
-
momentLocale,
|
|
90
|
-
};
|
|
91
|
-
});
|
|
92
|
-
return Promise.all(promises);
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/localeUtils.ts
|
|
20
|
+
var localeUtils_exports = {};
|
|
21
|
+
__export(localeUtils_exports, {
|
|
22
|
+
exactLocalePaths: () => exactLocalePaths,
|
|
23
|
+
getAntdLocale: () => getAntdLocale,
|
|
24
|
+
getLocaleList: () => getLocaleList,
|
|
25
|
+
getMomentLocale: () => getMomentLocale,
|
|
26
|
+
isNeedPolyfill: () => isNeedPolyfill
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(localeUtils_exports);
|
|
29
|
+
var import_fs = require("fs");
|
|
30
|
+
var import_path = require("path");
|
|
31
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
32
|
+
var getMomentLocale = (lang, country, resolveKey) => {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
const momentLocation = require.resolve(`${resolveKey}/locale/zh-cn`).replace(/zh\-cn\.js$/, "");
|
|
35
|
+
if ((0, import_fs.existsSync)((0, import_path.join)(momentLocation, `${lang}-${(_a = country == null ? void 0 : country.toLocaleLowerCase) == null ? void 0 : _a.call(country)}.js`))) {
|
|
36
|
+
const momentLocale = `${lang}-${(_b = country == null ? void 0 : country.toLocaleLowerCase) == null ? void 0 : _b.call(country)}`;
|
|
37
|
+
return {
|
|
38
|
+
momentLocale
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if ((0, import_fs.existsSync)((0, import_path.join)(momentLocation, `${lang}.js`))) {
|
|
42
|
+
return {
|
|
43
|
+
momentLocale: lang
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return { momentLocale: "" };
|
|
93
47
|
};
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
48
|
+
var getAntdLocale = (lang, country) => `${lang}_${(country || lang).toLocaleUpperCase()}`;
|
|
49
|
+
var modulesHasLocale = (localePath) => {
|
|
50
|
+
try {
|
|
51
|
+
require.resolve(localePath);
|
|
52
|
+
return true;
|
|
53
|
+
} catch (error) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
97
56
|
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
57
|
+
var getLocaleList = async (opts) => {
|
|
58
|
+
const {
|
|
59
|
+
localeFolder,
|
|
60
|
+
separator = "-",
|
|
61
|
+
absSrcPath = "",
|
|
62
|
+
absPagesPath = "",
|
|
63
|
+
addAntdLocales,
|
|
64
|
+
resolveKey = "moment"
|
|
65
|
+
} = opts;
|
|
66
|
+
const localeFileMath = new RegExp(`^([a-z]{2})${separator}?([A-Z]{2})?.(js|json|ts)$`);
|
|
67
|
+
const localeFiles = import_plugin_utils.glob.sync("*.{ts,js,json}", {
|
|
68
|
+
cwd: (0, import_plugin_utils.winPath)((0, import_path.join)(absSrcPath, localeFolder))
|
|
69
|
+
}).map((name) => (0, import_plugin_utils.winPath)((0, import_path.join)(absSrcPath, localeFolder, name))).concat(import_plugin_utils.glob.sync(`**/${localeFolder}/*.{ts,js,json}`, {
|
|
70
|
+
cwd: absPagesPath
|
|
71
|
+
}).map((name) => (0, import_plugin_utils.winPath)((0, import_path.join)(absPagesPath, name)))).filter((p) => localeFileMath.test((0, import_path.basename)(p)) && (0, import_fs.existsSync)(p)).map((fullName) => {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
const fileName = (0, import_path.basename)(fullName);
|
|
74
|
+
const fileInfo = (_b = (_a = localeFileMath.exec(fileName)) == null ? void 0 : _a.slice(1, 3)) == null ? void 0 : _b.filter(Boolean);
|
|
75
|
+
return {
|
|
76
|
+
name: (fileInfo || []).join(separator),
|
|
77
|
+
path: fullName
|
|
119
78
|
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
79
|
+
});
|
|
80
|
+
const groups = import_plugin_utils.lodash.groupBy(localeFiles, "name");
|
|
81
|
+
const promises = Object.keys(groups).map(async (name) => {
|
|
82
|
+
const [lang, country = ""] = name.split(separator);
|
|
83
|
+
const { momentLocale } = getMomentLocale(lang, country, resolveKey);
|
|
84
|
+
const antdLocale = import_plugin_utils.lodash.uniq(await addAntdLocales({ lang, country })).filter((localePath) => modulesHasLocale(localePath));
|
|
85
|
+
return {
|
|
86
|
+
lang,
|
|
87
|
+
name,
|
|
88
|
+
locale: name.split(separator).join("-"),
|
|
89
|
+
country,
|
|
90
|
+
antdLocale,
|
|
91
|
+
paths: groups[name].map((item) => (0, import_plugin_utils.winPath)(item.path)),
|
|
92
|
+
momentLocale
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
return Promise.all(promises);
|
|
96
|
+
};
|
|
97
|
+
var exactLocalePaths = (data) => {
|
|
98
|
+
return import_plugin_utils.lodash.flatten(data.map((item) => item.paths));
|
|
99
|
+
};
|
|
100
|
+
function isNeedPolyfill(targets = {}) {
|
|
101
|
+
const polyfillTargets = {
|
|
102
|
+
ie: 10,
|
|
103
|
+
firefox: 28,
|
|
104
|
+
chrome: 23,
|
|
105
|
+
safari: 9.1,
|
|
106
|
+
opera: 12.1,
|
|
107
|
+
ios: 9.3,
|
|
108
|
+
ios_saf: 9.3,
|
|
109
|
+
operamini: Infinity,
|
|
110
|
+
op_mini: Infinity,
|
|
111
|
+
android: 4.3,
|
|
112
|
+
blackberry: Infinity,
|
|
113
|
+
operamobile: 12.1,
|
|
114
|
+
op_mob: 12.1,
|
|
115
|
+
explorermobil: 10,
|
|
116
|
+
ie_mob: 10,
|
|
117
|
+
ucandroid: Infinity
|
|
118
|
+
};
|
|
119
|
+
return Object.keys(targets).find((key) => {
|
|
120
|
+
const lowKey = key.toLocaleLowerCase();
|
|
121
|
+
return polyfillTargets[lowKey] && polyfillTargets[lowKey] >= targets[key];
|
|
122
|
+
}) !== void 0;
|
|
125
123
|
}
|
|
126
|
-
|
|
124
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
125
|
+
0 && (module.exports = {
|
|
126
|
+
exactLocalePaths,
|
|
127
|
+
getAntdLocale,
|
|
128
|
+
getLocaleList,
|
|
129
|
+
getMomentLocale,
|
|
130
|
+
isNeedPolyfill
|
|
131
|
+
});
|