@umijs/plugins 4.0.5 → 4.0.8
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 +70 -54
- 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 +199 -207
- 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 +84 -53
- package/dist/tailwindcss.js +70 -49
- package/dist/unocss.js +56 -36
- 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/qiankun/master/MicroApp.tsx +9 -10
- package/libs/qiankun/slave/lifecycles.ts +6 -0
- package/package.json +5 -5
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
|
+
// 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
|
+
// 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
|
+
// 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
|
+
});
|
|
@@ -90,7 +90,8 @@ export const MicroApp = forwardRef(
|
|
|
90
90
|
|
|
91
91
|
// 优先使用 alias 名匹配,fallback 到 name 匹配
|
|
92
92
|
const name = componentProps[appNameKeyAlias] || componentProps.name;
|
|
93
|
-
const isCurrentApp = (app: any) =>
|
|
93
|
+
const isCurrentApp = (app: any) =>
|
|
94
|
+
app[appNameKeyAlias] === name || app.name === name;
|
|
94
95
|
|
|
95
96
|
const [loading, setLoading] = useState(true);
|
|
96
97
|
const [error, setError] = useState<any>(null);
|
|
@@ -143,13 +144,6 @@ export const MicroApp = forwardRef(
|
|
|
143
144
|
setComponentError(null);
|
|
144
145
|
setLoading(true);
|
|
145
146
|
const configuration = {
|
|
146
|
-
fetch(url) {
|
|
147
|
-
return window.fetch(url, {
|
|
148
|
-
headers: {
|
|
149
|
-
accept: 'text/html',
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
},
|
|
153
147
|
globalContext: window,
|
|
154
148
|
...globalSettings,
|
|
155
149
|
...settingsFromProps,
|
|
@@ -178,11 +172,16 @@ export const MicroApp = forwardRef(
|
|
|
178
172
|
if (noneMounted) {
|
|
179
173
|
if (Array.isArray(prefetch)) {
|
|
180
174
|
const specialPrefetchApps = apps.filter(
|
|
181
|
-
(app) =>
|
|
175
|
+
(app) =>
|
|
176
|
+
!isCurrentApp(app) &&
|
|
177
|
+
(prefetch.indexOf(app[appNameKeyAlias]) !== -1 ||
|
|
178
|
+
prefetch.indexOf(app.name) !== -1),
|
|
182
179
|
);
|
|
183
180
|
prefetchApps(specialPrefetchApps, configuration);
|
|
184
181
|
} else {
|
|
185
|
-
const otherNotMountedApps = apps.filter(
|
|
182
|
+
const otherNotMountedApps = apps.filter(
|
|
183
|
+
(app) => !isCurrentApp(app),
|
|
184
|
+
);
|
|
186
185
|
prefetchApps(otherNotMountedApps, configuration);
|
|
187
186
|
}
|
|
188
187
|
noneMounted = false;
|
|
@@ -73,6 +73,8 @@ export function genMount(mountElementId: string) {
|
|
|
73
73
|
await slaveRuntime.mount(props);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
const { type, ...historyOpts } = props?.history || {};
|
|
77
|
+
|
|
76
78
|
// 更新 clientRender 配置
|
|
77
79
|
const clientRenderOpts = {
|
|
78
80
|
// 默认开启
|
|
@@ -95,6 +97,10 @@ export function genMount(mountElementId: string) {
|
|
|
95
97
|
|
|
96
98
|
basename: props.base,
|
|
97
99
|
|
|
100
|
+
// 支持 MicroAppWithMemoHistory 需要
|
|
101
|
+
historyType: type,
|
|
102
|
+
historyOpts: historyOpts,
|
|
103
|
+
|
|
98
104
|
// 当存在同一个 umi 子应用在同一个页面被多实例渲染的场景时(比如一个页面里,同时展示了这个子应用的多个路由页面)
|
|
99
105
|
// mount 钩子会被调用多次,但是具体什么时候对应的实例开始 render 则是不定的,即它调用 applyPlugins('modifyClientRenderOpts') 的时机是不确定的
|
|
100
106
|
// 为了保证每次 applyPlugins('modifyClientRenderOpts') 调用是生成正确的 history,我们需要这里通过闭包上下文维持 mount 调用时的一些配置信息
|