@umijs/plugins 4.0.69 → 4.0.71

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/antd.js CHANGED
@@ -53,6 +53,7 @@ var antd_default = (api) => {
53
53
  antdVersion = require(`${pkgPath}/package.json`).version;
54
54
  } catch (e) {
55
55
  }
56
+ const isV5 = antdVersion.startsWith("5");
56
57
  const appComponentAvailable = import_plugin_utils.semver.gte(antdVersion, "5.1.0");
57
58
  const appConfigAvailable = import_plugin_utils.semver.gte(antdVersion, "5.3.0");
58
59
  const day2MomentAvailable = import_plugin_utils.semver.gte(antdVersion, "5.0.0");
@@ -72,7 +73,8 @@ var antd_default = (api) => {
72
73
  // Only antd@5.1.0 is supported
73
74
  appConfig: zod.record(zod.any()).describe("Only antd@5.1.0 is supported"),
74
75
  // DatePicker & Calendar use moment version
75
- momentPicker: zod.boolean().describe("Only antd@5.x is supported")
76
+ momentPicker: zod.boolean().describe("Only antd@5.x is supported"),
77
+ styleProvider: zod.record(zod.any())
76
78
  }).deepPartial();
77
79
  }
78
80
  },
@@ -167,7 +169,7 @@ var antd_default = (api) => {
167
169
  return memo;
168
170
  });
169
171
  api.addExtraBabelPlugins(() => {
170
- const style = antdVersion.startsWith("5") ? false : api.config.antd.style || "less";
172
+ const style = isV5 ? false : api.config.antd.style || "less";
171
173
  return api.config.antd.import && !api.appData.vite ? [
172
174
  [
173
175
  require.resolve("babel-plugin-import"),
@@ -183,13 +185,38 @@ var antd_default = (api) => {
183
185
  ] : [];
184
186
  });
185
187
  api.onGenerateFiles(() => {
188
+ var _a;
186
189
  const withConfigProvider = !!api.config.antd.configProvider;
187
190
  const withAppConfig = appConfigAvailable && !!api.config.antd.appConfig;
191
+ const styleProvider = api.config.antd.styleProvider;
192
+ const ieTarget = !!((_a = api.config.targets) == null ? void 0 : _a.ie) || !!api.config.legacy;
193
+ let styleProviderConfig = false;
194
+ if (isV5 && (ieTarget || styleProvider)) {
195
+ const cssinjs = (0, import_resolveProjectDep.resolveProjectDep)({
196
+ pkg: api.pkg,
197
+ cwd: api.cwd,
198
+ dep: "@ant-design/cssinjs"
199
+ }) || (0, import_path.dirname)(require.resolve("@ant-design/cssinjs/package.json"));
200
+ if (cssinjs) {
201
+ styleProviderConfig = {
202
+ cssinjs
203
+ };
204
+ if (ieTarget) {
205
+ styleProviderConfig.hashPriority = "high";
206
+ styleProviderConfig.legacyTransformer = true;
207
+ }
208
+ styleProviderConfig = {
209
+ ...styleProviderConfig,
210
+ ...styleProvider
211
+ };
212
+ }
213
+ }
188
214
  api.writeTmpFile({
189
215
  path: `runtime.tsx`,
190
216
  context: {
191
217
  configProvider: withConfigProvider && JSON.stringify(api.config.antd.configProvider),
192
- appConfig: appComponentAvailable && JSON.stringify(api.config.antd.appConfig)
218
+ appConfig: appComponentAvailable && JSON.stringify(api.config.antd.appConfig),
219
+ styleProvider: styleProviderConfig
193
220
  },
194
221
  tplPath: (0, import_plugin_utils.winPath)((0, import_path.join)(ANTD_TEMPLATES_DIR, "runtime.ts.tpl"))
195
222
  });
package/dist/dva.js CHANGED
@@ -42,7 +42,7 @@ var import_plugin_utils = require("umi/plugin-utils");
42
42
  var import_modelUtils = require("./utils/modelUtils");
43
43
  var import_withTmpPath = require("./utils/withTmpPath");
44
44
  var dva_default = (api) => {
45
- const pkgPath = (0, import_path.join)(__dirname, "../libs/dva.ts");
45
+ const pkgPath = (0, import_path.join)(__dirname, "../libs/dva.tsx");
46
46
  api.describe({
47
47
  config: {
48
48
  schema({ zod }) {
@@ -68,7 +68,7 @@ var dva_default = (api) => {
68
68
  return memo;
69
69
  });
70
70
  api.onGenerateFiles((args) => {
71
- var _a, _b, _c, _d, _e, _f;
71
+ var _a, _b, _c, _d, _e, _f, _g;
72
72
  const models = args.isFirstTime ? api.appData.pluginDva.models : getAllModels(api);
73
73
  api.writeTmpFile({
74
74
  path: "models.ts",
@@ -214,7 +214,7 @@ interface EffectsCommandMap {
214
214
  interface Action<T = any> {
215
215
  type: T
216
216
  }
217
- export type Reducer<S = any, A extends Action = AnyAction> = (prevState: S, action: A) => S;
217
+ export type Reducer<S = any, A extends Action = AnyAction> = (prevState: S, action: A) => ${((_g = api.config.dva) == null ? void 0 : _g.immer) ? "S | void" : "S"};
218
218
  export type Effect = (action: AnyAction, effects: EffectsCommandMap) => void;
219
219
  type EffectType = 'takeEvery' | 'takeLatest' | 'watcher' | 'throttle';
220
220
  type EffectWithType = [Effect, { type: EffectType }];
package/dist/layout.js CHANGED
@@ -251,7 +251,17 @@ const { formatMessage } = useIntl();
251
251
  }
252
252
  return defaultDom;
253
253
  }}
254
- itemRender={(route) => <Link to={route.path}>{route.breadcrumbName}</Link>}
254
+ itemRender={(route, _, routes) => {
255
+ const { breadcrumbName, title, path } = route;
256
+ const label = title || breadcrumbName
257
+ const last = routes[routes.length - 1]
258
+ if (last) {
259
+ if (last.path === path || last.linkPath === path) {
260
+ return <span>{label}</span>;
261
+ }
262
+ }
263
+ return <Link to={path}>{label}</Link>;
264
+ }}
255
265
  disableContentMargin
256
266
  fixSiderbar
257
267
  fixedHeader
package/dist/locale.js CHANGED
@@ -108,7 +108,7 @@ var locale_default = (api) => {
108
108
  });
109
109
  };
110
110
  api.onGenerateFiles(async () => {
111
- var _a, _b, _c, _d;
111
+ var _a, _b, _c;
112
112
  const localeTpl = (0, import_fs.readFileSync)(
113
113
  (0, import_path.join)(LOCALE_TEMPLATES_DIR, "locale.tpl"),
114
114
  "utf-8"
@@ -139,7 +139,7 @@ var locale_default = (api) => {
139
139
  }
140
140
  }
141
141
  let DefaultAntdLocales = [];
142
- if (!antdLocales.length && ((_c = api.config.locale) == null ? void 0 : _c.antd)) {
142
+ if (!antdLocales.length && antd) {
143
143
  const [lang, country = ""] = defaultLocale.split(baseSeparator);
144
144
  DefaultAntdLocales = import_plugin_utils.lodash.uniq(
145
145
  await addAntdLocales({
@@ -218,7 +218,7 @@ var locale_default = (api) => {
218
218
  Antd: !!antd,
219
219
  LocaleList: localeList,
220
220
  ShowSelectLang: localeList.length > 1 && !!antd,
221
- antdFiles: ((_d = api.config) == null ? void 0 : _d.ssr) ? "lib" : "es"
221
+ antdFiles: ((_c = api.config) == null ? void 0 : _c.ssr) ? "lib" : "es"
222
222
  })
223
223
  });
224
224
  api.writeTmpFile({
package/libs/dva.tsx ADDED
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ // @ts-ignore
3
+ import { create, saga, utils } from 'dva-core';
4
+ import {
5
+ connect,
6
+ Provider,
7
+ useDispatch,
8
+ useSelector,
9
+ useStore,
10
+ } from 'react-redux';
11
+ export { bindActionCreators } from 'redux';
12
+ export { create, saga, utils };
13
+ export { connect, Provider, useDispatch, useSelector, useStore };
14
+
15
+ export default function dva(opts: any) {
16
+ const app = create(opts, {
17
+ initialReducer: {},
18
+ setupApp() {},
19
+ });
20
+ const oldAppStart = app.start;
21
+ app.router = router;
22
+ app.start = start;
23
+ return app;
24
+
25
+ function router(router: any) {
26
+ app._router = router;
27
+ }
28
+
29
+ function start(elem: any) {
30
+ // old dva.start() supports passing arguments
31
+ if (typeof elem !== 'undefined') {
32
+ throw new Error('dva.start() should not be called with any arguments.');
33
+ }
34
+ if (!app._store) {
35
+ oldAppStart.call(app);
36
+ }
37
+ const store = app._store;
38
+ const router = app._router;
39
+ return (extraProps: any) => {
40
+ return (
41
+ <Provider store={store}>{router({ app, ...extraProps })}</Provider>
42
+ );
43
+ };
44
+ }
45
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.0.69",
3
+ "version": "4.0.71",
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",
@@ -19,6 +19,7 @@
19
19
  "dependencies": {
20
20
  "@ahooksjs/use-request": "^2.0.0",
21
21
  "@ant-design/antd-theme-variable": "^1.0.0",
22
+ "@ant-design/cssinjs": "^1.9.1",
22
23
  "@ant-design/icons": "^4.7.0",
23
24
  "@ant-design/moment-webpack-plugin": "^0.0.3",
24
25
  "@ant-design/pro-components": "^2.0.1",
@@ -43,12 +44,12 @@
43
44
  "styled-components": "6.0.0-rc.0",
44
45
  "tslib": "^2",
45
46
  "warning": "^4.0.3",
46
- "@umijs/bundler-utils": "4.0.69",
47
- "@umijs/valtio": "1.0.3"
47
+ "@umijs/valtio": "1.0.3",
48
+ "@umijs/bundler-utils": "4.0.71"
48
49
  },
49
50
  "devDependencies": {
50
51
  "antd": "^4.24.1",
51
- "umi": "4.0.69"
52
+ "umi": "4.0.71"
52
53
  },
53
54
  "publishConfig": {
54
55
  "access": "public"
@@ -11,6 +11,14 @@ import {
11
11
  notification,
12
12
  } from 'antd';
13
13
  import { ApplyPluginsType } from 'umi';
14
+ {{#styleProvider}}
15
+ import {
16
+ StyleProvider,
17
+ {{#styleProvider.legacyTransformer}}
18
+ legacyLogicalPropertiesTransformer
19
+ {{/styleProvider.legacyTransformer}}
20
+ } from '{{{styleProvider.cssinjs}}}';
21
+ {{/styleProvider}}
14
22
  import { getPluginManager } from '../core/plugin';
15
23
 
16
24
  let cacheAntdConfig = null;
@@ -58,9 +66,32 @@ export function rootContainer(rawContainer) {
58
66
  iconPrefixCls: finalConfigProvider.iconPrefixCls,
59
67
  });
60
68
  };
69
+
70
+ if (finalConfigProvider.theme) {
71
+ // Pass config theme to static method
72
+ ConfigProvider.config({
73
+ theme: finalConfigProvider.theme,
74
+ });
75
+ }
76
+
61
77
  container = <ConfigProvider {...finalConfigProvider}>{container}</ConfigProvider>;
62
78
  {{/configProvider}}
63
79
 
80
+ {{#styleProvider}}
81
+ container = (
82
+ <StyleProvider
83
+ {{#styleProvider.hashPriority}}
84
+ hashPriority="{{{styleProviderConfig.hashPriority}}}"
85
+ {{/styleProvider.hashPriority}}
86
+ {{#styleProvider.legacyTransformer}}
87
+ transformers={[legacyLogicalPropertiesTransformer]}
88
+ {{/styleProvider.legacyTransformer}}
89
+ >
90
+ {container}
91
+ </StyleProvider>
92
+ );
93
+ {{/styleProvider}}
94
+
64
95
  return container;
65
96
  }
66
97
 
@@ -90,8 +90,8 @@ export const addLocale = (
90
90
  ? Object.assign({}, localeInfo[name].messages, messages)
91
91
  : messages;
92
92
 
93
-
94
- const { momentLocale, antd } = extraLocales || {};
93
+ // 用户只是追加 messages 时,extraLocales 可选
94
+ const { momentLocale = localeInfo[name]?.momentLocale, antd = localeInfo[name]?.antd } = extraLocales || {};
95
95
  const locale = name.split('{{BaseSeparator}}')?.join('-')
96
96
  localeInfo[name] = {
97
97
  messages: mergeMessages,
package/libs/dva.ts DELETED
@@ -1,10 +0,0 @@
1
- // @ts-ignore
2
- export { create, saga, utils } from 'dva-core';
3
- export {
4
- connect,
5
- Provider,
6
- useDispatch,
7
- useSelector,
8
- useStore,
9
- } from 'react-redux';
10
- export { bindActionCreators } from 'redux';