@umijs/plugins 4.6.1 → 4.6.2
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/dva.js +2 -1
- package/dist/layout.js +9 -4
- package/dist/mf.js +3 -3
- package/dist/qiankun/master.js +2 -2
- package/dist/request.js +2 -1
- package/dist/unocss.js +2 -1
- package/dist/utils/modelUtils.js +59 -62
- package/package.json +4 -4
package/dist/dva.js
CHANGED
|
@@ -266,7 +266,8 @@ export interface DvaModel<T, E = EffectsMapObject, R = ReducersMapObject<T>> {
|
|
|
266
266
|
function getModelUtil(api) {
|
|
267
267
|
return new import_modelUtils.ModelUtils(api, {
|
|
268
268
|
contentTest(content) {
|
|
269
|
-
if (api == null ? void 0 : api.config.dva.skipModelValidate)
|
|
269
|
+
if (api == null ? void 0 : api.config.dva.skipModelValidate)
|
|
270
|
+
return true;
|
|
270
271
|
return content.startsWith("// @dva-model");
|
|
271
272
|
},
|
|
272
273
|
astTest({ node, content }) {
|
package/dist/layout.js
CHANGED
|
@@ -66,8 +66,13 @@ var layout_default = (api) => {
|
|
|
66
66
|
} catch (e) {
|
|
67
67
|
}
|
|
68
68
|
const packageName = api.pkg.name || "plugin-layout";
|
|
69
|
-
const
|
|
70
|
-
|
|
69
|
+
const isModern = import_plugin_utils.semver.satisfies(
|
|
70
|
+
antdVersion,
|
|
71
|
+
"^5.0.0 || ^6.0.0",
|
|
72
|
+
// 两者都还在维护周期中,允许使用预发布版本. eg. 6.1.0-alpha.0
|
|
73
|
+
{ includePrerelease: true }
|
|
74
|
+
);
|
|
75
|
+
const layoutFile = isModern ? "Layout.css" : "Layout.less";
|
|
71
76
|
api.describe({
|
|
72
77
|
key: "layout",
|
|
73
78
|
config: {
|
|
@@ -547,8 +552,8 @@ export function getRightRenderContent (opts: {
|
|
|
547
552
|
api.writeTmpFile({
|
|
548
553
|
path: layoutFile,
|
|
549
554
|
content: `
|
|
550
|
-
${// antd@5里面没有这个样式了
|
|
551
|
-
|
|
555
|
+
${// antd@5、@6 里面没有这个样式了
|
|
556
|
+
isModern ? "" : "@import '~antd/es/style/themes/default.less';"}
|
|
552
557
|
@media screen and (max-width: 480px) {
|
|
553
558
|
/* 在小屏幕的时候可以有更好的体验 */
|
|
554
559
|
.umi-plugin-layout-container {
|
package/dist/mf.js
CHANGED
|
@@ -141,14 +141,14 @@ function mf(api) {
|
|
|
141
141
|
(0, import_path.join)(api.paths.absTmpPath, "umi.ts"),
|
|
142
142
|
"utf-8"
|
|
143
143
|
);
|
|
144
|
-
const [_imports,
|
|
144
|
+
const [_imports, exports] = await (0, import_bundler_utils.parseModule)({ content, path: entry });
|
|
145
145
|
const mfEntryContent = [];
|
|
146
146
|
let hasDefaultExport = false;
|
|
147
|
-
if (
|
|
147
|
+
if (exports.length) {
|
|
148
148
|
mfEntryContent.push(
|
|
149
149
|
`const umiExports = await import('${(0, import_plugin_utils.winPath)(entry)}')`
|
|
150
150
|
);
|
|
151
|
-
for (const exportName of
|
|
151
|
+
for (const exportName of exports) {
|
|
152
152
|
if (exportName === "default") {
|
|
153
153
|
hasDefaultExport = true;
|
|
154
154
|
mfEntryContent.push(`export default umiExports.${exportName}`);
|
package/dist/qiankun/master.js
CHANGED
|
@@ -101,8 +101,8 @@ var master_default = (api) => {
|
|
|
101
101
|
api.register({
|
|
102
102
|
key: "addExtraModels",
|
|
103
103
|
fn() {
|
|
104
|
-
const { path, exports
|
|
105
|
-
return path &&
|
|
104
|
+
const { path, exports } = api.appData.appJS || {};
|
|
105
|
+
return path && exports.includes(import_constants.MODEL_EXPORT_NAME) ? [
|
|
106
106
|
`${path}#{"namespace":"${import_constants.qiankunStateForSlaveModelNamespace}","exportName":"${import_constants.MODEL_EXPORT_NAME}"}`
|
|
107
107
|
] : [];
|
|
108
108
|
}
|
package/dist/request.js
CHANGED
|
@@ -326,7 +326,8 @@ export type {
|
|
|
326
326
|
);
|
|
327
327
|
const axiosPath = (0, import_plugin_utils.winPath)((0, import_path.dirname)(require.resolve("axios/package.json")));
|
|
328
328
|
let dataField = (_a = api.config.request) == null ? void 0 : _a.dataField;
|
|
329
|
-
if (dataField === void 0)
|
|
329
|
+
if (dataField === void 0)
|
|
330
|
+
dataField = "data";
|
|
330
331
|
const isEmpty = dataField === "";
|
|
331
332
|
const formatResult = isEmpty ? `result => result` : `result => result?.${dataField}`;
|
|
332
333
|
const resultDataType = isEmpty ? dataField : `${dataField}?: T;`;
|
package/dist/unocss.js
CHANGED
|
@@ -40,7 +40,8 @@ var unocss_default = (api) => {
|
|
|
40
40
|
});
|
|
41
41
|
const outputPath = "uno.css";
|
|
42
42
|
api.onBeforeCompiler(async () => {
|
|
43
|
-
if (process.env.IS_UMI_BUILD_WORKER)
|
|
43
|
+
if (process.env.IS_UMI_BUILD_WORKER)
|
|
44
|
+
return;
|
|
44
45
|
if (!(0, import_fs.existsSync)((0, import_path.join)(api.paths.cwd, "unocss.config.ts")))
|
|
45
46
|
api.logger.warn(
|
|
46
47
|
"请在项目目录中添加 unocss.config.ts 文件,并配置需要的 unocss presets,否则插件将没有效果!"
|
package/dist/utils/modelUtils.js
CHANGED
|
@@ -66,11 +66,6 @@ function getNamespace(absFilePath, absSrcPath) {
|
|
|
66
66
|
return [...validDirs, normalizedFile].join(".");
|
|
67
67
|
}
|
|
68
68
|
var Model = class {
|
|
69
|
-
file;
|
|
70
|
-
namespace;
|
|
71
|
-
id;
|
|
72
|
-
exportName;
|
|
73
|
-
deps;
|
|
74
69
|
constructor(file, absSrcPath, sort, id) {
|
|
75
70
|
let namespace;
|
|
76
71
|
let exportName;
|
|
@@ -111,11 +106,10 @@ var Model = class {
|
|
|
111
106
|
return [...deps];
|
|
112
107
|
}
|
|
113
108
|
};
|
|
114
|
-
var
|
|
115
|
-
api;
|
|
116
|
-
opts = {};
|
|
117
|
-
count = 1;
|
|
109
|
+
var _ModelUtils = class {
|
|
118
110
|
constructor(api, opts) {
|
|
111
|
+
this.opts = {};
|
|
112
|
+
this.count = 1;
|
|
119
113
|
this.api = api;
|
|
120
114
|
this.opts = opts;
|
|
121
115
|
}
|
|
@@ -162,8 +156,10 @@ var ModelUtils = class _ModelUtils {
|
|
|
162
156
|
cwd: opts.base,
|
|
163
157
|
absolute: true
|
|
164
158
|
}).map(import_plugin_utils.winPath).filter((file) => {
|
|
165
|
-
if (/\.d.ts$/.test(file))
|
|
166
|
-
|
|
159
|
+
if (/\.d.ts$/.test(file))
|
|
160
|
+
return false;
|
|
161
|
+
if (/\.(test|e2e|spec).([jt])sx?$/.test(file))
|
|
162
|
+
return false;
|
|
167
163
|
const content = (0, import_fs.readFileSync)(file, "utf-8");
|
|
168
164
|
return this.isModelValid({ content, file });
|
|
169
165
|
});
|
|
@@ -208,57 +204,6 @@ var ModelUtils = class _ModelUtils {
|
|
|
208
204
|
});
|
|
209
205
|
return ret;
|
|
210
206
|
}
|
|
211
|
-
// https://github.com/umijs/umi/issues/9837
|
|
212
|
-
static topologicalSort = (models) => {
|
|
213
|
-
const graph = [];
|
|
214
|
-
const namespaceToNode = {};
|
|
215
|
-
models.forEach((model, index) => {
|
|
216
|
-
const node = {
|
|
217
|
-
namespace: model.namespace,
|
|
218
|
-
deps: model.deps,
|
|
219
|
-
index,
|
|
220
|
-
in: 0,
|
|
221
|
-
childs: []
|
|
222
|
-
};
|
|
223
|
-
if (namespaceToNode[model.namespace]) {
|
|
224
|
-
throw new Error(`Duplicate namespace in models: ${model.namespace}`);
|
|
225
|
-
}
|
|
226
|
-
namespaceToNode[model.namespace] = node;
|
|
227
|
-
graph.push(node);
|
|
228
|
-
});
|
|
229
|
-
graph.forEach((node) => {
|
|
230
|
-
node.deps.forEach((dep) => {
|
|
231
|
-
const depNode = namespaceToNode[dep];
|
|
232
|
-
if (!depNode) {
|
|
233
|
-
throw new Error(`Model namespace not found: ${dep}`);
|
|
234
|
-
}
|
|
235
|
-
depNode.childs.push(node);
|
|
236
|
-
node.in++;
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
const queue = [];
|
|
240
|
-
while (true) {
|
|
241
|
-
const zeronode = graph.find((n) => {
|
|
242
|
-
return n && n.in === 0;
|
|
243
|
-
});
|
|
244
|
-
if (!zeronode) {
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
queue.push(zeronode.namespace);
|
|
248
|
-
zeronode.childs.forEach((child) => {
|
|
249
|
-
child.in--;
|
|
250
|
-
});
|
|
251
|
-
zeronode.childs = [];
|
|
252
|
-
delete graph[zeronode.index];
|
|
253
|
-
}
|
|
254
|
-
const leftNodes = graph.filter(Boolean);
|
|
255
|
-
if (leftNodes.length > 0) {
|
|
256
|
-
throw new Error(
|
|
257
|
-
`Circle dependency detected in models: ${leftNodes.map((m) => import_plugin_utils.chalk.red(m.namespace)).join(", ")}`
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
return queue;
|
|
261
|
-
};
|
|
262
207
|
static getModelsContent(models) {
|
|
263
208
|
const imports = [];
|
|
264
209
|
const modelProps = [];
|
|
@@ -288,6 +233,58 @@ ${modelProps.join("\n")}
|
|
|
288
233
|
} as const`;
|
|
289
234
|
}
|
|
290
235
|
};
|
|
236
|
+
var ModelUtils = _ModelUtils;
|
|
237
|
+
// https://github.com/umijs/umi/issues/9837
|
|
238
|
+
ModelUtils.topologicalSort = (models) => {
|
|
239
|
+
const graph = [];
|
|
240
|
+
const namespaceToNode = {};
|
|
241
|
+
models.forEach((model, index) => {
|
|
242
|
+
const node = {
|
|
243
|
+
namespace: model.namespace,
|
|
244
|
+
deps: model.deps,
|
|
245
|
+
index,
|
|
246
|
+
in: 0,
|
|
247
|
+
childs: []
|
|
248
|
+
};
|
|
249
|
+
if (namespaceToNode[model.namespace]) {
|
|
250
|
+
throw new Error(`Duplicate namespace in models: ${model.namespace}`);
|
|
251
|
+
}
|
|
252
|
+
namespaceToNode[model.namespace] = node;
|
|
253
|
+
graph.push(node);
|
|
254
|
+
});
|
|
255
|
+
graph.forEach((node) => {
|
|
256
|
+
node.deps.forEach((dep) => {
|
|
257
|
+
const depNode = namespaceToNode[dep];
|
|
258
|
+
if (!depNode) {
|
|
259
|
+
throw new Error(`Model namespace not found: ${dep}`);
|
|
260
|
+
}
|
|
261
|
+
depNode.childs.push(node);
|
|
262
|
+
node.in++;
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
const queue = [];
|
|
266
|
+
while (true) {
|
|
267
|
+
const zeronode = graph.find((n) => {
|
|
268
|
+
return n && n.in === 0;
|
|
269
|
+
});
|
|
270
|
+
if (!zeronode) {
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
queue.push(zeronode.namespace);
|
|
274
|
+
zeronode.childs.forEach((child) => {
|
|
275
|
+
child.in--;
|
|
276
|
+
});
|
|
277
|
+
zeronode.childs = [];
|
|
278
|
+
delete graph[zeronode.index];
|
|
279
|
+
}
|
|
280
|
+
const leftNodes = graph.filter(Boolean);
|
|
281
|
+
if (leftNodes.length > 0) {
|
|
282
|
+
throw new Error(
|
|
283
|
+
`Circle dependency detected in models: ${leftNodes.map((m) => import_plugin_utils.chalk.red(m.namespace)).join(", ")}`
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
return queue;
|
|
287
|
+
};
|
|
291
288
|
// Annotate the CommonJS export names for ESM import in node:
|
|
292
289
|
0 && (module.exports = {
|
|
293
290
|
Model,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.2",
|
|
4
4
|
"description": "@umijs/plugins",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/plugins#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"styled-components": "6.1.1",
|
|
46
46
|
"tslib": "^2",
|
|
47
47
|
"warning": "^4.0.3",
|
|
48
|
-
"@umijs/
|
|
49
|
-
"@umijs/
|
|
48
|
+
"@umijs/bundler-utils": "4.6.2",
|
|
49
|
+
"@umijs/valtio": "1.0.4"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"antd": "^4.24.1",
|
|
53
|
-
"umi": "4.6.
|
|
53
|
+
"umi": "4.6.2"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|