@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
package/dist/utils/modelUtils.js
CHANGED
|
@@ -1,251 +1,230 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
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 });
|
|
24
10
|
};
|
|
25
|
-
var
|
|
26
|
-
|
|
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;
|
|
27
18
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
+
// src/utils/modelUtils.ts
|
|
23
|
+
var modelUtils_exports = {};
|
|
24
|
+
__export(modelUtils_exports, {
|
|
25
|
+
Model: () => Model,
|
|
26
|
+
ModelUtils: () => ModelUtils,
|
|
27
|
+
getNamespace: () => getNamespace
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(modelUtils_exports);
|
|
30
|
+
var parser = __toESM(require("@umijs/bundler-utils/compiled/babel/parser"));
|
|
31
|
+
var import_traverse = __toESM(require("@umijs/bundler-utils/compiled/babel/traverse"));
|
|
32
|
+
var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
|
|
33
|
+
var import_esbuild = require("@umijs/bundler-utils/compiled/esbuild");
|
|
34
|
+
var import_fs = require("fs");
|
|
35
|
+
var import_path = require("path");
|
|
36
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
37
|
+
var import_astUtils = require("./astUtils");
|
|
38
38
|
function getNamespace(absFilePath, absSrcPath) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
return [...validDirs, normalizedFile].join('.');
|
|
39
|
+
const relPath = (0, import_plugin_utils.winPath)((0, import_path.relative)((0, import_plugin_utils.winPath)(absSrcPath), (0, import_plugin_utils.winPath)(absFilePath)));
|
|
40
|
+
const parts = relPath.split("/");
|
|
41
|
+
const dirs = parts.slice(0, -1);
|
|
42
|
+
const file = parts[parts.length - 1];
|
|
43
|
+
const validDirs = dirs.filter((dir) => !["src", "pages", "models"].includes(dir));
|
|
44
|
+
let normalizedFile = file;
|
|
45
|
+
normalizedFile = (0, import_path.basename)(file, (0, import_path.extname)(file));
|
|
46
|
+
if (normalizedFile.endsWith(".model")) {
|
|
47
|
+
normalizedFile = normalizedFile.split(".").slice(0, -1).join(".");
|
|
48
|
+
}
|
|
49
|
+
return [...validDirs, normalizedFile].join(".");
|
|
52
50
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
exportName = metaObj.exportName;
|
|
63
|
-
}
|
|
64
|
-
this.file = _file;
|
|
65
|
-
this.id = `model_${id}`;
|
|
66
|
-
this.namespace = namespace || getNamespace(_file, absSrcPath);
|
|
67
|
-
this.exportName = exportName || 'default';
|
|
68
|
-
this.deps = sort ? this.findDeps(sort) : [];
|
|
51
|
+
var Model = class {
|
|
52
|
+
constructor(file, absSrcPath, sort, id) {
|
|
53
|
+
let namespace;
|
|
54
|
+
let exportName;
|
|
55
|
+
const [_file, meta] = file.split("#");
|
|
56
|
+
if (meta) {
|
|
57
|
+
const metaObj = JSON.parse(meta);
|
|
58
|
+
namespace = metaObj.namespace;
|
|
59
|
+
exportName = metaObj.exportName;
|
|
69
60
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
61
|
+
this.file = _file;
|
|
62
|
+
this.id = `model_${id}`;
|
|
63
|
+
this.namespace = namespace || getNamespace(_file, absSrcPath);
|
|
64
|
+
this.exportName = exportName || "default";
|
|
65
|
+
this.deps = sort ? this.findDeps(sort) : [];
|
|
66
|
+
}
|
|
67
|
+
findDeps(sort) {
|
|
68
|
+
const content = (0, import_fs.readFileSync)(this.file, "utf-8");
|
|
69
|
+
const loader = (0, import_path.extname)(this.file).slice(1);
|
|
70
|
+
const result = (0, import_esbuild.transformSync)(content, {
|
|
71
|
+
loader,
|
|
72
|
+
sourcemap: false,
|
|
73
|
+
minify: false
|
|
74
|
+
});
|
|
75
|
+
const deps = /* @__PURE__ */ new Set();
|
|
76
|
+
const ast = parser.parse(result.code, {
|
|
77
|
+
sourceType: "module",
|
|
78
|
+
sourceFilename: this.file,
|
|
79
|
+
plugins: []
|
|
80
|
+
});
|
|
81
|
+
sort;
|
|
82
|
+
(0, import_traverse.default)(ast, {
|
|
83
|
+
CallExpression: (path) => {
|
|
84
|
+
if (t.isIdentifier(path.node.callee, { name: "useModel" }) && t.isStringLiteral(path.node.arguments[0])) {
|
|
85
|
+
deps.add(path.node.arguments[0].value);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return [...deps];
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
var ModelUtils = class {
|
|
93
|
+
constructor(api, opts) {
|
|
94
|
+
this.opts = {};
|
|
95
|
+
this.count = 1;
|
|
96
|
+
this.api = api;
|
|
97
|
+
this.opts = opts;
|
|
98
|
+
}
|
|
99
|
+
getAllModels(opts) {
|
|
100
|
+
this.count = 1;
|
|
101
|
+
const models = [
|
|
102
|
+
...this.getModels({
|
|
103
|
+
base: (0, import_path.join)(this.api.paths.absSrcPath, "models"),
|
|
104
|
+
pattern: "**/*.{ts,tsx,js,jsx}"
|
|
105
|
+
}),
|
|
106
|
+
...this.getModels({
|
|
107
|
+
base: (0, import_path.join)(this.api.paths.absPagesPath),
|
|
108
|
+
pattern: "**/models/**/*.{ts,tsx,js,jsx}"
|
|
109
|
+
}),
|
|
110
|
+
...this.getModels({
|
|
111
|
+
base: (0, import_path.join)(this.api.paths.absPagesPath),
|
|
112
|
+
pattern: "**/model.{ts,tsx,js,jsx}"
|
|
113
|
+
}),
|
|
114
|
+
...opts.extraModels
|
|
115
|
+
].map((file) => {
|
|
116
|
+
return new Model(file, this.api.paths.absSrcPath, opts.sort, this.count++);
|
|
117
|
+
});
|
|
118
|
+
const namespaces = models.map((model) => model.namespace);
|
|
119
|
+
if (new Set(namespaces).size !== namespaces.length) {
|
|
120
|
+
throw new Error(`Duplicate namespace in models: ${namespaces.sort().join(", ")}`);
|
|
98
121
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
constructor(api, opts) {
|
|
103
|
-
this.opts = {};
|
|
104
|
-
this.count = 1;
|
|
105
|
-
this.api = api;
|
|
106
|
-
this.opts = opts;
|
|
122
|
+
if (opts.sort) {
|
|
123
|
+
const namespaces2 = this.getSortedNamespaces(models);
|
|
124
|
+
models.sort((a, b) => namespaces2.indexOf(a.namespace) - namespaces2.indexOf(b.namespace));
|
|
107
125
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
...opts.extraModels,
|
|
125
|
-
].map((file) => {
|
|
126
|
-
return new Model(file, this.api.paths.absSrcPath, opts.sort, this.count++);
|
|
127
|
-
});
|
|
128
|
-
// check duplicate
|
|
129
|
-
const namespaces = models.map((model) => model.namespace);
|
|
130
|
-
if (new Set(namespaces).size !== namespaces.length) {
|
|
131
|
-
throw new Error(`Duplicate namespace in models: ${namespaces.sort().join(', ')}`);
|
|
126
|
+
return models;
|
|
127
|
+
}
|
|
128
|
+
getSortedNamespaces(models) {
|
|
129
|
+
let final = [];
|
|
130
|
+
models.forEach((model, index) => {
|
|
131
|
+
const { deps, namespace } = model;
|
|
132
|
+
if (deps && deps.length) {
|
|
133
|
+
const itemGroup = [...deps, namespace];
|
|
134
|
+
const cannotUse = [namespace];
|
|
135
|
+
for (let i = 0; i <= index; i += 1) {
|
|
136
|
+
if (models[i].deps.filter((v) => cannotUse.includes(v)).length) {
|
|
137
|
+
if (!cannotUse.includes(models[i].namespace)) {
|
|
138
|
+
cannotUse.push(models[i].namespace);
|
|
139
|
+
i = -1;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
132
142
|
}
|
|
133
|
-
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
-
models.sort((a, b) => namespaces.indexOf(a.namespace) - namespaces.indexOf(b.namespace));
|
|
143
|
+
const errorList = deps.filter((v) => cannotUse.includes(v));
|
|
144
|
+
if (errorList.length) {
|
|
145
|
+
throw Error(`Circular dependencies: ${namespace} can't use ${errorList.join(", ")}`);
|
|
137
146
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (deps && deps.length) {
|
|
145
|
-
const itemGroup = [...deps, namespace];
|
|
146
|
-
const cannotUse = [namespace];
|
|
147
|
-
for (let i = 0; i <= index; i += 1) {
|
|
148
|
-
if (models[i].deps.filter((v) => cannotUse.includes(v)).length) {
|
|
149
|
-
if (!cannotUse.includes(models[i].namespace)) {
|
|
150
|
-
cannotUse.push(models[i].namespace);
|
|
151
|
-
i = -1;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
const errorList = deps.filter((v) => cannotUse.includes(v));
|
|
156
|
-
if (errorList.length) {
|
|
157
|
-
throw Error(`Circular dependencies: ${namespace} can't use ${errorList.join(', ')}`);
|
|
158
|
-
}
|
|
159
|
-
const intersection = final.filter((v) => itemGroup.includes(v));
|
|
160
|
-
if (intersection.length) {
|
|
161
|
-
// first intersection
|
|
162
|
-
const finalIndex = final.indexOf(intersection[0]);
|
|
163
|
-
// replace with groupItem
|
|
164
|
-
final = final
|
|
165
|
-
.slice(0, finalIndex)
|
|
166
|
-
.concat(itemGroup)
|
|
167
|
-
.concat(final.slice(finalIndex + 1));
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
final.push(...itemGroup);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (!final.includes(namespace)) {
|
|
174
|
-
// first occurrence append to the end
|
|
175
|
-
final.push(namespace);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
return [...new Set(final)];
|
|
179
|
-
}
|
|
180
|
-
getModels(opts) {
|
|
181
|
-
return plugin_utils_1.glob
|
|
182
|
-
.sync(opts.pattern || '**/*.{ts,js}', {
|
|
183
|
-
cwd: opts.base,
|
|
184
|
-
absolute: true,
|
|
185
|
-
})
|
|
186
|
-
.map(plugin_utils_1.winPath)
|
|
187
|
-
.filter((file) => {
|
|
188
|
-
if (/\.d.ts$/.test(file))
|
|
189
|
-
return false;
|
|
190
|
-
if (/\.(test|e2e|spec).([jt])sx?$/.test(file))
|
|
191
|
-
return false;
|
|
192
|
-
const content = (0, fs_1.readFileSync)(file, 'utf-8');
|
|
193
|
-
return this.isModelValid({ content, file });
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
isModelValid(opts) {
|
|
197
|
-
const { file, content } = opts;
|
|
198
|
-
if (this.opts.contentTest && this.opts.contentTest(content)) {
|
|
199
|
-
return true;
|
|
147
|
+
const intersection = final.filter((v) => itemGroup.includes(v));
|
|
148
|
+
if (intersection.length) {
|
|
149
|
+
const finalIndex = final.indexOf(intersection[0]);
|
|
150
|
+
final = final.slice(0, finalIndex).concat(itemGroup).concat(final.slice(finalIndex + 1));
|
|
151
|
+
} else {
|
|
152
|
+
final.push(...itemGroup);
|
|
200
153
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
return ret;
|
|
154
|
+
}
|
|
155
|
+
if (!final.includes(namespace)) {
|
|
156
|
+
final.push(namespace);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
return [...new Set(final)];
|
|
160
|
+
}
|
|
161
|
+
getModels(opts) {
|
|
162
|
+
return import_plugin_utils.glob.sync(opts.pattern || "**/*.{ts,js}", {
|
|
163
|
+
cwd: opts.base,
|
|
164
|
+
absolute: true
|
|
165
|
+
}).map(import_plugin_utils.winPath).filter((file) => {
|
|
166
|
+
if (/\.d.ts$/.test(file))
|
|
167
|
+
return false;
|
|
168
|
+
if (/\.(test|e2e|spec).([jt])sx?$/.test(file))
|
|
169
|
+
return false;
|
|
170
|
+
const content = (0, import_fs.readFileSync)(file, "utf-8");
|
|
171
|
+
return this.isModelValid({ content, file });
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
isModelValid(opts) {
|
|
175
|
+
const { file, content } = opts;
|
|
176
|
+
if (this.opts.contentTest && this.opts.contentTest(content)) {
|
|
177
|
+
return true;
|
|
226
178
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
179
|
+
const loader = (0, import_path.extname)(file).slice(1);
|
|
180
|
+
const result = (0, import_esbuild.transformSync)(content, {
|
|
181
|
+
loader,
|
|
182
|
+
sourcemap: false,
|
|
183
|
+
minify: false
|
|
184
|
+
});
|
|
185
|
+
let ret = false;
|
|
186
|
+
const ast = parser.parse(result.code, {
|
|
187
|
+
sourceType: "module",
|
|
188
|
+
sourceFilename: file,
|
|
189
|
+
plugins: []
|
|
190
|
+
});
|
|
191
|
+
(0, import_traverse.default)(ast, {
|
|
192
|
+
ExportDefaultDeclaration: (path) => {
|
|
193
|
+
let node = path.node.declaration;
|
|
194
|
+
node = (0, import_astUtils.getIdentifierDeclaration)(node, path);
|
|
195
|
+
if (this.opts.astTest && this.opts.astTest({ node, content })) {
|
|
196
|
+
ret = true;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
return ret;
|
|
201
|
+
}
|
|
202
|
+
static getModelsContent(models) {
|
|
203
|
+
const imports = [];
|
|
204
|
+
const modelProps = [];
|
|
205
|
+
models.forEach((model) => {
|
|
206
|
+
const fileWithoutExt = (0, import_plugin_utils.winPath)((0, import_path.format)({
|
|
207
|
+
dir: (0, import_path.dirname)(model.file),
|
|
208
|
+
base: (0, import_path.basename)(model.file, (0, import_path.extname)(model.file))
|
|
209
|
+
}));
|
|
210
|
+
if (model.exportName !== "default") {
|
|
211
|
+
imports.push(`import { ${model.exportName} as ${model.id} } from '${fileWithoutExt}';`);
|
|
212
|
+
} else {
|
|
213
|
+
imports.push(`import ${model.id} from '${fileWithoutExt}';`);
|
|
214
|
+
}
|
|
215
|
+
modelProps.push(`${model.id}: { namespace: '${model.namespace}', model: ${model.id} },`);
|
|
216
|
+
});
|
|
217
|
+
return `
|
|
218
|
+
${imports.join("\n")}
|
|
245
219
|
|
|
246
220
|
export const models = {
|
|
247
|
-
${modelProps.join(
|
|
221
|
+
${modelProps.join("\n")}
|
|
248
222
|
} as const`;
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
226
|
+
0 && (module.exports = {
|
|
227
|
+
Model,
|
|
228
|
+
ModelUtils,
|
|
229
|
+
getNamespace
|
|
230
|
+
});
|
|
@@ -1,15 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
// src/utils/resolveProjectDep.ts
|
|
20
|
+
var resolveProjectDep_exports = {};
|
|
21
|
+
__export(resolveProjectDep_exports, {
|
|
22
|
+
resolveProjectDep: () => resolveProjectDep
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(resolveProjectDep_exports);
|
|
25
|
+
var import_path = require("path");
|
|
26
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
6
27
|
function resolveProjectDep(opts) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
28
|
+
var _a, _b;
|
|
29
|
+
if (((_a = opts.pkg.dependencies) == null ? void 0 : _a[opts.dep]) || ((_b = opts.pkg.devDependencies) == null ? void 0 : _b[opts.dep])) {
|
|
30
|
+
return (0, import_path.dirname)(import_plugin_utils.resolve.sync(`${opts.dep}/package.json`, {
|
|
31
|
+
basedir: opts.cwd
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
14
34
|
}
|
|
15
|
-
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
resolveProjectDep
|
|
38
|
+
});
|
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
// src/utils/withTmpPath.ts
|
|
20
|
+
var withTmpPath_exports = {};
|
|
21
|
+
__export(withTmpPath_exports, {
|
|
22
|
+
withTmpPath: () => withTmpPath
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(withTmpPath_exports);
|
|
25
|
+
var import_path = require("path");
|
|
26
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
6
27
|
function withTmpPath(opts) {
|
|
7
|
-
|
|
8
|
-
? `plugin-${opts.api.plugin.key}`
|
|
9
|
-
: '', opts.path));
|
|
28
|
+
return (0, import_plugin_utils.winPath)((0, import_path.join)(opts.api.paths.absTmpPath, opts.api.plugin.key && !opts.noPluginDir ? `plugin-${opts.api.plugin.key}` : "", opts.path));
|
|
10
29
|
}
|
|
11
|
-
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
withTmpPath
|
|
33
|
+
});
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
IntlShape,
|
|
4
4
|
MessageDescriptor,
|
|
5
5
|
} from '{{{ reactIntlPkgPath }}}';
|
|
6
|
-
import { ApplyPluginsType } from 'umi';
|
|
7
6
|
import { getPluginManager } from '../core/plugin';
|
|
8
7
|
import EventEmitter from '{{{EventEmitterPkg}}}';
|
|
9
8
|
// @ts-ignore
|
|
@@ -153,7 +152,8 @@ export const setIntl = (locale: string) => {
|
|
|
153
152
|
export const getLocale = () => {
|
|
154
153
|
const runtimeLocale = getPluginManager().applyPlugins({
|
|
155
154
|
key: 'locale',
|
|
156
|
-
|
|
155
|
+
// workaround: 不使用 ApplyPluginsType.modify 是为了避免循环依赖,与 fast-refresh 一起用时会有问题
|
|
156
|
+
type: 'modify',
|
|
157
157
|
initialValue: {},
|
|
158
158
|
});
|
|
159
159
|
// runtime getLocale for user define
|
|
@@ -201,7 +201,8 @@ export const setLocale = (lang: string, realReload: boolean = true) => {
|
|
|
201
201
|
//const { pluginManager } = useAppContext();
|
|
202
202
|
//const runtimeLocale = pluginManagerapplyPlugins({
|
|
203
203
|
// key: 'locale',
|
|
204
|
-
//
|
|
204
|
+
// workaround: 不使用 ApplyPluginsType.modify 是为了避免循环依赖,与 fast-refresh 一起用时会有问题
|
|
205
|
+
// type: 'modify',
|
|
205
206
|
// initialValue: {},
|
|
206
207
|
//});
|
|
207
208
|
|
|
@@ -261,6 +262,9 @@ http://j.mp/37Fkd5Q
|
|
|
261
262
|
);
|
|
262
263
|
firstWaring = false;
|
|
263
264
|
}
|
|
265
|
+
if (!g_intl) {
|
|
266
|
+
setIntl(getLocale());
|
|
267
|
+
}
|
|
264
268
|
return g_intl.formatMessage(descriptor, values);
|
|
265
269
|
};
|
|
266
270
|
|