@umijs/plugins 4.6.2 → 4.6.3

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 CHANGED
@@ -266,8 +266,7 @@ 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)
270
- return true;
269
+ if (api == null ? void 0 : api.config.dva.skipModelValidate) return true;
271
270
  return content.startsWith("// @dva-model");
272
271
  },
273
272
  astTest({ node, content }) {
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, exports] = await (0, import_bundler_utils.parseModule)({ content, path: entry });
144
+ const [_imports, exports2] = await (0, import_bundler_utils.parseModule)({ content, path: entry });
145
145
  const mfEntryContent = [];
146
146
  let hasDefaultExport = false;
147
- if (exports.length) {
147
+ if (exports2.length) {
148
148
  mfEntryContent.push(
149
149
  `const umiExports = await import('${(0, import_plugin_utils.winPath)(entry)}')`
150
150
  );
151
- for (const exportName of exports) {
151
+ for (const exportName of exports2) {
152
152
  if (exportName === "default") {
153
153
  hasDefaultExport = true;
154
154
  mfEntryContent.push(`export default umiExports.${exportName}`);
@@ -101,8 +101,8 @@ var master_default = (api) => {
101
101
  api.register({
102
102
  key: "addExtraModels",
103
103
  fn() {
104
- const { path, exports } = api.appData.appJS || {};
105
- return path && exports.includes(import_constants.MODEL_EXPORT_NAME) ? [
104
+ const { path, exports: exports2 } = api.appData.appJS || {};
105
+ return path && exports2.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,8 +326,7 @@ 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)
330
- dataField = "data";
329
+ if (dataField === void 0) dataField = "data";
331
330
  const isEmpty = dataField === "";
332
331
  const formatResult = isEmpty ? `result => result` : `result => result?.${dataField}`;
333
332
  const resultDataType = isEmpty ? dataField : `${dataField}?: T;`;
package/dist/unocss.js CHANGED
@@ -40,8 +40,7 @@ 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)
44
- return;
43
+ if (process.env.IS_UMI_BUILD_WORKER) return;
45
44
  if (!(0, import_fs.existsSync)((0, import_path.join)(api.paths.cwd, "unocss.config.ts")))
46
45
  api.logger.warn(
47
46
  "请在项目目录中添加 unocss.config.ts 文件,并配置需要的 unocss presets,否则插件将没有效果!"
@@ -66,6 +66,11 @@ 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;
69
74
  constructor(file, absSrcPath, sort, id) {
70
75
  let namespace;
71
76
  let exportName;
@@ -106,10 +111,11 @@ var Model = class {
106
111
  return [...deps];
107
112
  }
108
113
  };
109
- var _ModelUtils = class {
114
+ var ModelUtils = class _ModelUtils {
115
+ api;
116
+ opts = {};
117
+ count = 1;
110
118
  constructor(api, opts) {
111
- this.opts = {};
112
- this.count = 1;
113
119
  this.api = api;
114
120
  this.opts = opts;
115
121
  }
@@ -156,10 +162,8 @@ var _ModelUtils = class {
156
162
  cwd: opts.base,
157
163
  absolute: true
158
164
  }).map(import_plugin_utils.winPath).filter((file) => {
159
- if (/\.d.ts$/.test(file))
160
- return false;
161
- if (/\.(test|e2e|spec).([jt])sx?$/.test(file))
162
- return false;
165
+ if (/\.d.ts$/.test(file)) return false;
166
+ if (/\.(test|e2e|spec).([jt])sx?$/.test(file)) return false;
163
167
  const content = (0, import_fs.readFileSync)(file, "utf-8");
164
168
  return this.isModelValid({ content, file });
165
169
  });
@@ -204,6 +208,57 @@ var _ModelUtils = class {
204
208
  });
205
209
  return ret;
206
210
  }
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
+ };
207
262
  static getModelsContent(models) {
208
263
  const imports = [];
209
264
  const modelProps = [];
@@ -233,58 +288,6 @@ ${modelProps.join("\n")}
233
288
  } as const`;
234
289
  }
235
290
  };
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
- };
288
291
  // Annotate the CommonJS export names for ESM import in node:
289
292
  0 && (module.exports = {
290
293
  Model,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.6.2",
3
+ "version": "4.6.3",
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/bundler-utils": "4.6.2",
48
+ "@umijs/bundler-utils": "4.6.3",
49
49
  "@umijs/valtio": "1.0.4"
50
50
  },
51
51
  "devDependencies": {
52
52
  "antd": "^4.24.1",
53
- "umi": "4.6.2"
53
+ "umi": "4.6.3"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public"