@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
package/dist/tailwindcss.js
CHANGED
|
@@ -1,52 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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 });
|
|
8
|
+
};
|
|
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;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// tailwindcss.ts
|
|
20
|
+
var tailwindcss_exports = {};
|
|
21
|
+
__export(tailwindcss_exports, {
|
|
22
|
+
default: () => tailwindcss_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(tailwindcss_exports);
|
|
25
|
+
var import_path = require("path");
|
|
26
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
27
|
+
var tailwindcss_default = (api) => {
|
|
28
|
+
api.describe({
|
|
29
|
+
key: "tailwindcss",
|
|
30
|
+
config: {
|
|
31
|
+
schema(Joi) {
|
|
32
|
+
return Joi.alternatives().try(Joi.object(), Joi.boolean().invalid(true));
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
enableBy: api.EnableBy.config
|
|
36
|
+
});
|
|
37
|
+
let tailwind = null;
|
|
38
|
+
const outputPath = "plugin-tailwindcss/tailwind.css";
|
|
39
|
+
api.onBeforeCompiler(() => {
|
|
40
|
+
const inputPath = (0, import_path.join)(api.cwd, "tailwind.css");
|
|
41
|
+
const generatedPath = (0, import_path.join)(api.paths.absTmpPath, outputPath);
|
|
42
|
+
const binPath = (0, import_path.join)(api.cwd, "node_modules/.bin/tailwind");
|
|
43
|
+
return new Promise((resolve) => {
|
|
44
|
+
tailwind = (0, import_plugin_utils.crossSpawn)(`${binPath}`, [
|
|
45
|
+
"-i",
|
|
46
|
+
inputPath,
|
|
47
|
+
"-o",
|
|
48
|
+
generatedPath,
|
|
49
|
+
api.env === "development" ? "--watch" : ""
|
|
50
|
+
], {
|
|
51
|
+
stdio: "inherit"
|
|
52
|
+
});
|
|
53
|
+
tailwind.on("error", (m) => {
|
|
54
|
+
api.logger.error("tailwindcss service encounter an error: " + m);
|
|
55
|
+
});
|
|
56
|
+
if (api.env === "production") {
|
|
57
|
+
tailwind.on("exit", () => {
|
|
58
|
+
api.logger.info("tailwindcss service exited");
|
|
59
|
+
resolve();
|
|
45
60
|
});
|
|
61
|
+
} else {
|
|
62
|
+
api.logger.info("tailwindcss service started");
|
|
63
|
+
resolve();
|
|
64
|
+
}
|
|
46
65
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
66
|
+
});
|
|
67
|
+
api.addEntryImports(() => {
|
|
68
|
+
const generatedPath = (0, import_plugin_utils.winPath)((0, import_path.join)(api.paths.absTmpPath, outputPath));
|
|
69
|
+
return [{ source: generatedPath }];
|
|
70
|
+
});
|
|
52
71
|
};
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {});
|
package/dist/unocss.js
CHANGED
|
@@ -1,39 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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 });
|
|
8
|
+
};
|
|
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;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// unocss.ts
|
|
20
|
+
var unocss_exports = {};
|
|
21
|
+
__export(unocss_exports, {
|
|
22
|
+
default: () => unocss_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(unocss_exports);
|
|
25
|
+
var import_child_process = require("child_process");
|
|
26
|
+
var import_fs = require("fs");
|
|
27
|
+
var import_path = require("path");
|
|
28
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
29
|
+
var unocss_default = (api) => {
|
|
30
|
+
api.describe({
|
|
31
|
+
key: "unocss",
|
|
32
|
+
config: {
|
|
33
|
+
schema(Joi) {
|
|
34
|
+
return Joi.alternatives().try(Joi.object({
|
|
35
|
+
watch: Joi.array()
|
|
36
|
+
}), Joi.boolean().invalid(true));
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
enableBy: api.EnableBy.config
|
|
40
|
+
});
|
|
41
|
+
const outputPath = "uno.css";
|
|
42
|
+
api.onBeforeCompiler(() => {
|
|
43
|
+
if (!(0, import_fs.existsSync)((0, import_path.join)(api.paths.cwd, "unocss.config.ts")))
|
|
44
|
+
api.logger.warn("\u8BF7\u5728\u9879\u76EE\u76EE\u5F55\u4E2D\u6DFB\u52A0 unocss.config.ts \u6587\u4EF6\uFF0C\u5E76\u914D\u7F6E\u9700\u8981\u7684 unocss presets\uFF0C\u5426\u5219\u63D2\u4EF6\u5C06\u6CA1\u6709\u6548\u679C\uFF01");
|
|
45
|
+
const generatedPath = (0, import_path.join)(api.paths.absTmpPath, outputPath);
|
|
46
|
+
const binPath = (0, import_path.join)(api.cwd, "node_modules/.bin/unocss");
|
|
47
|
+
const watchDirs = api.config.unocss.watch;
|
|
48
|
+
const unocss = (0, import_child_process.exec)(`${binPath} ${watchDirs.join(" ")} --out-file ${generatedPath} ${api.env === "development" ? "--watch" : ""}`, { cwd: api.cwd });
|
|
49
|
+
unocss.on("error", (m) => {
|
|
50
|
+
api.logger.error("unocss service encounter an error: " + m);
|
|
38
51
|
});
|
|
52
|
+
});
|
|
53
|
+
api.addEntryImports(() => {
|
|
54
|
+
const generatedPath = (0, import_plugin_utils.winPath)((0, import_path.join)(api.paths.absTmpPath, outputPath));
|
|
55
|
+
return [{ source: generatedPath }];
|
|
56
|
+
});
|
|
39
57
|
};
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {});
|
package/dist/utils/astUtils.js
CHANGED
|
@@ -1,38 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
24
18
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// astUtils.ts
|
|
23
|
+
var astUtils_exports = {};
|
|
24
|
+
__export(astUtils_exports, {
|
|
25
|
+
getIdentifierDeclaration: () => getIdentifierDeclaration
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(astUtils_exports);
|
|
28
|
+
var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
|
|
28
29
|
function getIdentifierDeclaration(node, path) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
return bindingNode;
|
|
30
|
+
if (t.isIdentifier(node) && path.scope.hasBinding(node.name)) {
|
|
31
|
+
let bindingNode = path.scope.getBinding(node.name).path.node;
|
|
32
|
+
if (t.isVariableDeclarator(bindingNode)) {
|
|
33
|
+
bindingNode = bindingNode.init;
|
|
35
34
|
}
|
|
36
|
-
return
|
|
35
|
+
return bindingNode;
|
|
36
|
+
}
|
|
37
|
+
return node;
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
getIdentifierDeclaration
|
|
42
|
+
});
|
|
@@ -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
|
+
// 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
|
+
});
|