@umijs/plugins 4.0.0-rc.12 → 4.0.0-rc.15

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 CHANGED
@@ -1,14 +1,9 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
4
  };
11
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = __importDefault(require("fs"));
12
7
  const path_1 = require("path");
13
8
  const withTmpPath_1 = require("./utils/withTmpPath");
14
9
  exports.default = (api) => {
@@ -20,19 +15,29 @@ exports.default = (api) => {
20
15
  },
21
16
  enableBy: api.EnableBy.config,
22
17
  });
23
- api.onGenerateFiles(() => __awaiter(void 0, void 0, void 0, function* () {
18
+ api.onGenerateFiles(async () => {
19
+ // allow enable access without access file
20
+ const hasAccessFile = ['js', 'jsx', 'ts', 'tsx'].some((ext) => fs_1.default.existsSync((0, path_1.join)(api.paths.absSrcPath, `access.${ext}`)));
24
21
  // runtime.tsx
25
22
  api.writeTmpFile({
26
23
  path: 'runtime.tsx',
27
24
  content: `
28
- import React from 'react';
29
- import accessFactory from '@/access';
25
+ import React from 'react';${hasAccessFile
26
+ ? `
27
+ import accessFactory from '@/access'
30
28
  import { useModel } from '@@/plugin-model';
29
+ `
30
+ : ''}
31
31
  import { AccessContext } from './context';
32
32
 
33
- function Provider(props) {
33
+ function Provider(props) {${hasAccessFile
34
+ ? `
34
35
  const { initialState } = useModel('@@initialState');
35
36
  const access = React.useMemo(() => accessFactory(initialState), [initialState]);
37
+ `
38
+ : `
39
+ const access = {};
40
+ `}
36
41
  return (
37
42
  <AccessContext.Provider value={access}>
38
43
  { props.children }
@@ -123,7 +128,7 @@ import React from 'react';
123
128
  export const AccessContext = React.createContext<any>(null);
124
129
  `,
125
130
  });
126
- }));
131
+ });
127
132
  api.addRuntimePlugin(() => {
128
133
  return [(0, withTmpPath_1.withTmpPath)({ api, path: 'runtime.tsx' })];
129
134
  });
package/dist/antd.js CHANGED
@@ -57,12 +57,18 @@ exports.default = (api) => {
57
57
  // dark mode & compact mode
58
58
  if (memo.antd.dark || memo.antd.compact) {
59
59
  const { getThemeVariables } = require('antd/dist/theme');
60
- memo.theme = Object.assign(Object.assign({}, getThemeVariables(memo.antd)), memo.theme);
60
+ memo.theme = {
61
+ ...getThemeVariables(memo.antd),
62
+ ...memo.theme,
63
+ };
61
64
  }
62
65
  return memo;
63
66
  });
64
67
  api.modifyConfig((memo) => {
65
- memo.theme = Object.assign({ 'root-entry-name': 'default' }, memo.theme);
68
+ memo.theme = {
69
+ 'root-entry-name': 'default',
70
+ ...memo.theme,
71
+ };
66
72
  return memo;
67
73
  });
68
74
  // babel-plugin-import
@@ -77,6 +83,7 @@ exports.default = (api) => {
77
83
  libraryDirectory: 'es',
78
84
  style: style === 'less' ? true : 'css',
79
85
  },
86
+ 'antd',
80
87
  ],
81
88
  ]
82
89
  : [];
@@ -88,6 +95,7 @@ exports.default = (api) => {
88
95
  api.writeTmpFile({
89
96
  path: `runtime.tsx`,
90
97
  content: plugin_utils_1.Mustache.render(`
98
+ import React from 'react';
91
99
  import { ConfigProvider, Modal, message, notification } from 'antd';
92
100
 
93
101
  export function rootContainer(container) {
package/dist/dva.js CHANGED
@@ -25,11 +25,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.getAllModels = exports.getModelUtil = void 0;
27
27
  const t = __importStar(require("@umijs/bundler-utils/compiled/babel/types"));
28
+ const utils_1 = require("@umijs/utils");
28
29
  const path_1 = require("path");
29
30
  const plugin_utils_1 = require("umi/plugin-utils");
30
31
  const modelUtils_1 = require("./utils/modelUtils");
31
32
  const withTmpPath_1 = require("./utils/withTmpPath");
32
- const utils_1 = require("@umijs/utils");
33
33
  exports.default = (api) => {
34
34
  const pkgPath = (0, path_1.join)(__dirname, '../libs/dva.ts');
35
35
  api.describe({
@@ -80,15 +80,22 @@ import dvaImmer, { enableES5, enableAllPlugins } from '${(0, utils_1.winPath)(re
80
80
  `
81
81
  : ''}
82
82
  import React, { useRef } from 'react';
83
- import { history } from 'umi';
83
+ import { history, ApplyPluginsType, useAppData } from 'umi';
84
84
  import { models } from './models';
85
85
 
86
86
  export function RootContainer(props: any) {
87
+ const { pluginManager } = useAppData();
87
88
  const app = useRef<any>();
89
+ const runtimeDva = pluginManager.applyPlugins({
90
+ key: 'dva',
91
+ type: ApplyPluginsType.modify,
92
+ initialValue: {},
93
+ });
88
94
  if (!app.current) {
89
95
  app.current = create(
90
96
  {
91
97
  history,
98
+ ...(runtimeDva.config || {}),
92
99
  },
93
100
  {
94
101
  initialReducer: {},
@@ -139,6 +146,7 @@ export { connect, useDispatch, useStore, useSelector } from 'dva';`,
139
146
  api.addRuntimePlugin(() => {
140
147
  return [(0, withTmpPath_1.withTmpPath)({ api, path: 'runtime.tsx' })];
141
148
  });
149
+ api.addRuntimePluginKey(() => ['dva']);
142
150
  // dva list model
143
151
  api.registerCommand({
144
152
  name: 'dva',
@@ -172,6 +180,7 @@ function getModelUtil(api) {
172
180
  exports.getModelUtil = getModelUtil;
173
181
  function getAllModels(api) {
174
182
  return getModelUtil(api).getAllModels({
183
+ extraModelsPre: [],
175
184
  extraModels: [...(api.config.dva.extraModels || [])],
176
185
  });
177
186
  }
@@ -13,7 +13,7 @@ exports.default = (api) => {
13
13
  enableBy: api.EnableBy.config,
14
14
  });
15
15
  api.register({
16
- key: 'addExtraModels',
16
+ key: 'addExtraModelsPre',
17
17
  fn: () => [(0, withTmpPath_1.withTmpPath)({ api, path: '@@initialState.ts' })],
18
18
  });
19
19
  api.addRuntimePluginKey(() => ['getInitialState']);
@@ -107,7 +107,7 @@ export default () => ({ loading: false, refresh: () => {} })
107
107
  content: `
108
108
  import React from 'react';
109
109
  import Provider from './Provider';
110
- export function innerProvider(container) {
110
+ export function dataflowProvider(container) {
111
111
  return <Provider>{ container }</Provider>;
112
112
  }
113
113
  `,
package/dist/locale.js CHANGED
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.packageNormalize = void 0;
13
4
  const fs_1 = require("fs");
@@ -58,9 +49,9 @@ exports.default = (api) => {
58
49
  },
59
50
  ]
60
51
  : []);
61
- const addAntdLocales = (args) => __awaiter(void 0, void 0, void 0, function* () {
52
+ const addAntdLocales = async (args) => {
62
53
  var _a;
63
- return yield api.applyPlugins({
54
+ return await api.applyPlugins({
64
55
  key: 'addAntdLocales',
65
56
  type: api.ApplyPluginsType.add,
66
57
  initialValue: [
@@ -68,29 +59,32 @@ exports.default = (api) => {
68
59
  ],
69
60
  args,
70
61
  });
71
- });
72
- const getList = (resolveKey) => __awaiter(void 0, void 0, void 0, function* () {
73
- var _b;
62
+ };
63
+ const getList = async (resolveKey) => {
64
+ var _a;
74
65
  const { paths } = api;
75
66
  return (0, localeUtils_1.getLocaleList)({
76
67
  localeFolder: 'locales',
77
- separator: (_b = api.config.locale) === null || _b === void 0 ? void 0 : _b.baseSeparator,
68
+ separator: (_a = api.config.locale) === null || _a === void 0 ? void 0 : _a.baseSeparator,
78
69
  absSrcPath: paths.absSrcPath,
79
70
  absPagesPath: paths.absPagesPath,
80
71
  addAntdLocales,
81
72
  resolveKey,
82
73
  });
83
- });
84
- api.onGenerateFiles(() => __awaiter(void 0, void 0, void 0, function* () {
85
- var _c, _d, _e, _f;
74
+ };
75
+ api.onGenerateFiles(async () => {
76
+ var _a, _b, _c, _d;
86
77
  const localeTpl = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../libs/locale/locale.tpl'), 'utf-8');
87
78
  // moment2dayjs
88
79
  const resolveKey = api.config.moment2dayjs ? 'dayjs' : 'moment';
89
80
  const momentPkgPath = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve(`${resolveKey}/package.json`)));
90
81
  const EventEmitterPkg = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('event-emitter/package')));
91
- const { baseSeparator, baseNavigator, antd, title, useLocalStorage } = Object.assign(Object.assign({}, defaultConfig), api.config.locale);
92
- const defaultLocale = ((_c = api.config.locale) === null || _c === void 0 ? void 0 : _c.default) || `zh${baseSeparator}CN`;
93
- const localeList = yield getList(resolveKey);
82
+ const { baseSeparator, baseNavigator, antd, title, useLocalStorage } = {
83
+ ...defaultConfig,
84
+ ...api.config.locale,
85
+ };
86
+ const defaultLocale = ((_a = api.config.locale) === null || _a === void 0 ? void 0 : _a.default) || `zh${baseSeparator}CN`;
87
+ const localeList = await getList(resolveKey);
94
88
  const momentLocales = localeList
95
89
  .map(({ momentLocale }) => momentLocale)
96
90
  .filter((locale) => locale);
@@ -100,7 +94,7 @@ exports.default = (api) => {
100
94
  let MomentLocales = momentLocales;
101
95
  let DefaultMomentLocale = '';
102
96
  // set moment default accounding to locale.default
103
- if (!MomentLocales.length && ((_d = api.config.locale) === null || _d === void 0 ? void 0 : _d.default)) {
97
+ if (!MomentLocales.length && ((_b = api.config.locale) === null || _b === void 0 ? void 0 : _b.default)) {
104
98
  const [lang, country = ''] = defaultLocale.split(baseSeparator);
105
99
  const { momentLocale } = (0, localeUtils_1.getMomentLocale)(lang, country, resolveKey);
106
100
  if (momentLocale) {
@@ -110,9 +104,9 @@ exports.default = (api) => {
110
104
  }
111
105
  let DefaultAntdLocales = [];
112
106
  // set antd default locale
113
- if (!antdLocales.length && ((_e = api.config.locale) === null || _e === void 0 ? void 0 : _e.antd)) {
107
+ if (!antdLocales.length && ((_c = api.config.locale) === null || _c === void 0 ? void 0 : _c.antd)) {
114
108
  const [lang, country = ''] = defaultLocale.split(baseSeparator);
115
- DefaultAntdLocales = plugin_utils_1.lodash.uniq(yield addAntdLocales({
109
+ DefaultAntdLocales = plugin_utils_1.lodash.uniq(await addAntdLocales({
116
110
  lang,
117
111
  country,
118
112
  }));
@@ -148,16 +142,20 @@ exports.default = (api) => {
148
142
  UseLocalStorage: !!useLocalStorage,
149
143
  LocaleDir: localeDirName,
150
144
  ExistLocaleDir: (0, fs_1.existsSync)(localeDirPath),
151
- LocaleList: localeList.map((locale) => (Object.assign(Object.assign({}, locale), { antdLocale: locale.antdLocale.map((antdLocale, index) => ({
145
+ LocaleList: localeList.map((locale) => ({
146
+ ...locale,
147
+ antdLocale: locale.antdLocale.map((antdLocale, index) => ({
152
148
  locale: antdLocale,
153
149
  index: index,
154
- })), paths: locale.paths.map((path, index) => ({
150
+ })),
151
+ paths: locale.paths.map((path, index) => ({
155
152
  path,
156
153
  index,
157
- })) }))),
154
+ })),
155
+ })),
158
156
  Antd: !!antd,
159
157
  DefaultLocale: JSON.stringify(defaultLocale),
160
- warningPkgPath: (0, plugin_utils_1.winPath)(require.resolve('warning/package')),
158
+ warningPkgPath: (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('warning/package'))),
161
159
  reactIntlPkgPath,
162
160
  }),
163
161
  });
@@ -177,25 +175,25 @@ exports.default = (api) => {
177
175
  Antd: !!antd,
178
176
  LocaleList: localeList,
179
177
  ShowSelectLang: localeList.length > 1 && !!antd,
180
- antdFiles: ((_f = api.config) === null || _f === void 0 ? void 0 : _f.ssr) ? 'lib' : 'es',
178
+ antdFiles: ((_d = api.config) === null || _d === void 0 ? void 0 : _d.ssr) ? 'lib' : 'es',
181
179
  }),
182
180
  });
183
181
  // index.ts
184
182
  api.writeTmpFile({
185
183
  path: 'index.ts',
186
184
  content: `
187
- export { setLocale, getLocale, useIntl, formatMessage, FormattedMessage } from './localeExports.ts';
185
+ export { setLocale, getLocale, useIntl, injectIntl, formatMessage, FormattedMessage } from './localeExports.ts';
188
186
  export { SelectLang } from './SelectLang.tsx';
189
187
  `,
190
188
  });
191
- }));
189
+ });
192
190
  // Runtime Plugin
193
191
  api.addRuntimePlugin(() => [(0, withTmpPath_1.withTmpPath)({ api, path: 'runtime.tsx' })]);
194
192
  api.addRuntimePluginKey(() => ['locale']);
195
193
  // watch locale files
196
- api.addTmpGenerateWatcherPaths(() => __awaiter(void 0, void 0, void 0, function* () {
194
+ api.addTmpGenerateWatcherPaths(async () => {
197
195
  const resolveKey = api.config.moment2dayjs ? 'dayjs' : 'moment';
198
- const localeList = yield getList(resolveKey);
196
+ const localeList = await getList(resolveKey);
199
197
  return (0, localeUtils_1.exactLocalePaths)(localeList);
200
- }));
198
+ });
201
199
  };
package/dist/model.js CHANGED
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
25
  Object.defineProperty(exports, "__esModule", { value: true });
35
26
  const t = __importStar(require("@umijs/bundler-utils/compiled/babel/types"));
36
27
  const fs_1 = require("fs");
@@ -49,17 +40,17 @@ exports.default = (api) => {
49
40
  },
50
41
  enableBy: api.EnableBy.config,
51
42
  });
52
- api.modifyAppData((memo) => __awaiter(void 0, void 0, void 0, function* () {
53
- const models = yield getAllModels(api);
43
+ api.modifyAppData(async (memo) => {
44
+ const models = await getAllModels(api);
54
45
  memo.pluginModel = {
55
46
  models,
56
47
  };
57
48
  return memo;
58
- }));
59
- api.onGenerateFiles((args) => __awaiter(void 0, void 0, void 0, function* () {
49
+ });
50
+ api.onGenerateFiles(async (args) => {
60
51
  const models = args.isFirstTime
61
52
  ? api.appData.pluginModel.models
62
- : yield getAllModels(api);
53
+ : await getAllModels(api);
63
54
  // model.ts
64
55
  api.writeTmpFile({
65
56
  path: 'model.ts',
@@ -94,7 +85,7 @@ export function dataflowProvider(container, opts) {
94
85
  }
95
86
  `,
96
87
  });
97
- }));
88
+ });
98
89
  api.addTmpGenerateWatcherPaths(() => {
99
90
  return [(0, path_1.join)(api.paths.absSrcPath, 'models')];
100
91
  });
@@ -102,19 +93,26 @@ export function dataflowProvider(container, opts) {
102
93
  return [(0, withTmpPath_1.withTmpPath)({ api, path: 'runtime.tsx' })];
103
94
  });
104
95
  };
105
- function getAllModels(api) {
106
- return __awaiter(this, void 0, void 0, function* () {
107
- const extraModels = yield api.applyPlugins({
108
- key: 'addExtraModels',
109
- type: api.ApplyPluginsType.add,
110
- initialValue: [],
111
- });
112
- return new modelUtils_1.ModelUtils(api, {
113
- astTest({ node }) {
114
- return t.isArrowFunctionExpression(node) || t.isFunctionDeclaration(node);
115
- },
116
- }).getAllModels({
117
- extraModels: [...extraModels, ...(api.config.model.extraModels || [])],
118
- });
96
+ async function getAllModels(api) {
97
+ const extraModelsPre = await api.applyPlugins({
98
+ key: 'addExtraModelsPre',
99
+ type: api.ApplyPluginsType.add,
100
+ initialValue: [],
101
+ });
102
+ const extraModels = await api.applyPlugins({
103
+ key: 'addExtraModels',
104
+ type: api.ApplyPluginsType.add,
105
+ initialValue: [],
106
+ });
107
+ return new modelUtils_1.ModelUtils(api, {
108
+ astTest({ node }) {
109
+ return t.isArrowFunctionExpression(node) || t.isFunctionDeclaration(node);
110
+ },
111
+ }).getAllModels({
112
+ extraModelsPre: [
113
+ ...extraModelsPre,
114
+ ...(api.config.model.extraModelsPre || []),
115
+ ],
116
+ extraModels: [...extraModels, ...(api.config.model.extraModels || [])],
119
117
  });
120
118
  }
@@ -23,7 +23,17 @@ exports.default = (api) => {
23
23
  api.addRuntimePlugin(() => {
24
24
  return [(0, withTmpPath_1.withTmpPath)({ api, path: 'masterRuntimePlugin.tsx' })];
25
25
  });
26
- api.modifyDefaultConfig((config) => (Object.assign(Object.assign({}, config), { mountElementId: constants_1.defaultMasterRootId, qiankun: Object.assign(Object.assign({}, config.qiankun), { master: Object.assign(Object.assign({}, JSON.parse(process.env.INITIAL_QIANKUN_MASTER_OPTIONS || '{}')), (config.qiankun || {}).master) }) })));
26
+ api.modifyDefaultConfig((config) => ({
27
+ ...config,
28
+ mountElementId: constants_1.defaultMasterRootId,
29
+ qiankun: {
30
+ ...config.qiankun,
31
+ master: {
32
+ ...JSON.parse(process.env.INITIAL_QIANKUN_MASTER_OPTIONS || '{}'),
33
+ ...(config.qiankun || {}).master,
34
+ },
35
+ },
36
+ }));
27
37
  // TODO: modify routes
28
38
  api.modifyRoutes((memo) => {
29
39
  Object.keys(memo).forEach((id) => {
@@ -65,7 +75,11 @@ exports.default = (api) => {
65
75
  api.writeTmpFile({
66
76
  path: 'masterOptions.ts',
67
77
  content: `
68
- let options = ${JSON.stringify(Object.assign({ masterHistoryType: ((_a = api.config.history) === null || _a === void 0 ? void 0 : _a.type) || constants_1.defaultHistoryType, base: api.config.base || '/' }, api.config.qiankun.master))};
78
+ let options = ${JSON.stringify({
79
+ masterHistoryType: ((_a = api.config.history) === null || _a === void 0 ? void 0 : _a.type) || constants_1.defaultHistoryType,
80
+ base: api.config.base || '/',
81
+ ...api.config.qiankun.master,
82
+ })};
69
83
  export const getMasterOptions = () => options;
70
84
  export const setMasterOptions = (newOpts) => options = ({ ...options, ...newOpts });
71
85
  `,
@@ -110,5 +124,11 @@ export const setMasterOptions = (newOpts) => options = ({ ...options, ...newOpts
110
124
  });
111
125
  }
112
126
  });
127
+ api.writeTmpFile({
128
+ path: 'index.ts',
129
+ content: `
130
+ export { MicroApp } from './MicroApp';
131
+ `,
132
+ });
113
133
  });
114
134
  };
@@ -36,10 +36,20 @@ exports.default = (api) => {
36
36
  });
37
37
  api.modifyDefaultConfig((memo) => {
38
38
  var _a, _b, _c, _d;
39
- const initialSlaveOptions = Object.assign(Object.assign({ devSourceMap: true }, JSON.parse(process.env.INITIAL_QIANKUN_SLAVE_OPTIONS || '{}')), (memo.qiankun || {}).slave);
40
- const modifiedDefaultConfig = Object.assign(Object.assign({}, memo), {
39
+ const initialSlaveOptions = {
40
+ devSourceMap: true,
41
+ ...JSON.parse(process.env.INITIAL_QIANKUN_SLAVE_OPTIONS || '{}'),
42
+ ...(memo.qiankun || {}).slave,
43
+ };
44
+ const modifiedDefaultConfig = {
45
+ ...memo,
41
46
  // 默认开启 runtimePublicPath,避免出现 dynamic import 场景子应用资源地址出问题
42
- runtimePublicPath: true, qiankun: Object.assign(Object.assign({}, memo.qiankun), { slave: initialSlaveOptions }) });
47
+ runtimePublicPath: true,
48
+ qiankun: {
49
+ ...memo.qiankun,
50
+ slave: initialSlaveOptions,
51
+ },
52
+ };
43
53
  const shouldNotModifyDefaultBase = (_c = (_b = (_a = api.userConfig.qiankun) === null || _a === void 0 ? void 0 : _a.slave) === null || _b === void 0 ? void 0 : _b.shouldNotModifyDefaultBase) !== null && _c !== void 0 ? _c : initialSlaveOptions.shouldNotModifyDefaultBase;
44
54
  const historyType = ((_d = api.userConfig.history) === null || _d === void 0 ? void 0 : _d.type) || 'browser';
45
55
  if (!shouldNotModifyDefaultBase && historyType !== 'hash') {
@@ -52,8 +62,11 @@ exports.default = (api) => {
52
62
  var _a, _b;
53
63
  // mfsu 场景默认给子应用增加 mfName 配置,从而避免冲突
54
64
  if (config.mfsu !== false) {
55
- config.mfsu = Object.assign(Object.assign({}, config.mfsu), { mfName: ((_a = config.mfsu) === null || _a === void 0 ? void 0 : _a.mfName) ||
56
- `mf_${(_b = api.pkg.name) === null || _b === void 0 ? void 0 : _b.replace(/^@/, '').replace(/\W/g, '_')}` });
65
+ config.mfsu = {
66
+ ...config.mfsu,
67
+ mfName: ((_a = config.mfsu) === null || _a === void 0 ? void 0 : _a.mfName) ||
68
+ `mf_${(_b = api.pkg.name) === null || _b === void 0 ? void 0 : _b.replace(/^@/, '').replace(/\W/g, '_')}`,
69
+ };
57
70
  }
58
71
  return config;
59
72
  });
@@ -129,11 +142,17 @@ if (!window.__POWERED_BY_QIANKUN__) {
129
142
  path: file.replace(/\.tpl$/, ''),
130
143
  content: getFileContent(file)
131
144
  .replace('__USE_MODEL__', api.isPluginEnable('model')
132
- ? `import { useModel } from '@@/plugin/model'`
145
+ ? `import { useModel } from '@@/plugin-model'`
133
146
  : `const useModel = null;`)
134
147
  .replace(/from 'qiankun'/g, `from '${(0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('qiankun/package')))}'`)
135
148
  .replace(/from 'lodash\//g, `from '${(0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('lodash/package')))}/`),
136
149
  });
137
150
  });
151
+ api.writeTmpFile({
152
+ path: 'index.ts',
153
+ content: `
154
+ export { connectMaster } from './connectMaster';
155
+ `,
156
+ });
138
157
  });
139
158
  };
package/dist/request.js CHANGED
@@ -7,7 +7,12 @@ exports.default = (api) => {
7
7
  key: 'request',
8
8
  config: {
9
9
  schema: (joi) => {
10
- return joi.object();
10
+ return joi.object({
11
+ dataField: joi
12
+ .string()
13
+ .pattern(/^[a-zA-Z]*$/)
14
+ .allow(''),
15
+ });
11
16
  },
12
17
  },
13
18
  enableBy: api.EnableBy.config,
@@ -20,7 +25,6 @@ import axios, {
20
25
  type AxiosResponse,
21
26
  } from '{{{axiosPath}}}';
22
27
  import useUmiRequest, { UseRequestProvider } from '{{{umiRequestPath}}}';
23
- import { message, notification } from '{{{antdPkg}}}';
24
28
  import { ApplyPluginsType } from 'umi';
25
29
  import { getPluginManager } from '../core/plugin';
26
30
 
@@ -81,7 +85,7 @@ function useRequest<Item = any, U extends Item = any>(
81
85
  ): PaginatedResult<Item>;
82
86
  function useRequest(service: any, options: any = {}) {
83
87
  return useUmiRequest(service, {
84
- formatResult: result => result?.data,
88
+ formatResult: {{{formatResult}}},
85
89
  requestMethod: (requestOptions: any) => {
86
90
  if (typeof requestOptions === 'string') {
87
91
  return request(requestOptions);
@@ -96,114 +100,49 @@ function useRequest(service: any, options: any = {}) {
96
100
  });
97
101
  }
98
102
 
99
- export interface RequestConfig extends AxiosRequestConfig {
100
- errorConfig?: {
101
- errorPage?: string;
102
- adaptor?: IAdaptor; // adaptor 用以用户将不满足接口的后端数据修改成 errorInfo
103
- errorHandler?: IErrorHandler;
104
- defaultNoneResponseErrorMessage?: string;
105
- defaultRequestErrorMessage?: string;
106
- };
107
- formatResultAdaptor?: IFormatResultAdaptor;
108
- }
109
-
110
- export enum ErrorShowType {
111
- SILENT = 0,
112
- WARN_MESSAGE = 1,
113
- ERROR_MESSAGE = 2,
114
- NOTIFICATION = 3,
115
- REDIRECT = 9,
116
- }
117
-
118
- export interface IErrorInfo {
119
- success: boolean;
120
- data?: any;
121
- errorCode?: string;
122
- errorMessage?: string;
123
- showType?: ErrorShowType;
124
- traceId?: string;
125
- host?: string;
103
+ // request 方法 opts 参数的接口
104
+ interface IRequestOptions extends AxiosRequestConfig {
105
+ skipErrorHandler?: boolean;
106
+ requestInterceptors?: IRequestInterceptorTuple[];
107
+ responseInterceptors?: IResponseInterceptorTuple[];
126
108
  [key: string]: any;
127
109
  }
128
- // resData 其实就是 response.data, response 则是 axios 的响应对象
129
- interface IAdaptor {
130
- (resData: any, response: AxiosResponse): IErrorInfo;
110
+
111
+ interface IRequestOptionsWithResponse extends IRequestOptions {
112
+ getResponse: true;
131
113
  }
132
114
 
133
- export interface RequestError extends Error {
134
- data?: any;
135
- info?: IErrorInfo;
115
+ interface IRequestOptionsWithoutResponse extends IRequestOptions{
116
+ getResponse: false;
136
117
  }
137
118
 
138
- interface IRequest {
139
- (
140
- url: string,
141
- opts: AxiosRequestConfig & { skipErrorHandler?: boolean },
142
- ): Promise<AxiosResponse<any, any>>;
119
+ interface IRequest{
120
+ <T = any>(url: string, opts: IRequestOptionsWithResponse): Promise<AxiosResponse<T>>;
121
+ <T = any>(url: string, opts: IRequestOptionsWithoutResponse): Promise<T>;
122
+ <T = any>(url: string, opts: IRequestOptions): Promise<T>; // getResponse 默认是 false, 因此不提供该参数时,只返回 data
123
+ <T = any>(url: string): Promise<T>; // 不提供 opts 时,默认使用 'GET' method,并且默认返回 data
143
124
  }
144
125
 
145
126
  interface IErrorHandler {
146
- (error: RequestError, opts: AxiosRequestConfig & { skipErrorHandler?: boolean }, config: RequestConfig): void;
127
+ (error: RequestError, opts: IRequestOptions): void;
147
128
  }
129
+ type IRequestInterceptorAxios = (config: RequestOptions) => RequestOptions;
130
+ type IRequestInterceptorUmiRequest = (url: string, config : RequestOptions) => { url: string, options: RequestOptions };
131
+ type IRequestInterceptor = IRequestInterceptorAxios;
132
+ type IErrorInterceptor = (error: Error) => Promise<Error>;
133
+ type IResponseInterceptor = <T = any>(response : AxiosResponse<T>) => AxiosResponse<T> ;
134
+ type IRequestInterceptorTuple = [IRequestInterceptor , IErrorInterceptor] | [ IRequestInterceptor ] | IRequestInterceptor
135
+ type IResponseInterceptorTuple = [IResponseInterceptor, IErrorInterceptor] | [IResponseInterceptor] | IResponseInterceptor
148
136
 
149
- interface IFormatResultAdaptor {
150
- (res: AxiosResponse): any;
137
+ export interface RequestConfig extends AxiosRequestConfig {
138
+ errorConfig?: {
139
+ errorHandler?: IErrorHandler;
140
+ errorThrower?: <T = any>( res: T ) => void
141
+ };
142
+ requestInterceptors?: IRequestInterceptorTuple[];
143
+ responseInterceptors?: IResponseInterceptorTuple[];
151
144
  }
152
145
 
153
- const defaultErrorHandler: IErrorHandler = (error, opts, config) => {
154
- if (opts?.skipErrorHandler) throw error;
155
- const { errorConfig } = config;
156
- if (error.response) {
157
- // 请求成功发出且服务器也响应了状态码,但状态代码超出了 2xx 的范围 或者 成功响应,success字段为false 由我们抛出的错误
158
- let errorInfo: IErrorInfo | undefined;
159
- // 不是我们的错误
160
- if(error.name === 'ResponseError'){
161
- const adaptor: IAdaptor =
162
- errorConfig?.adaptor || ((errorData) => errorData);
163
- errorInfo = adaptor(error.response.data, error.response);
164
- error.info = errorInfo;
165
- error.data = error.response.data;
166
- }
167
- errorInfo = error.info;
168
- if (errorInfo) {
169
- const { errorMessage, errorCode } = errorInfo;
170
- switch (errorInfo.showType) {
171
- case ErrorShowType.SILENT:
172
- // do nothong
173
- break;
174
- case ErrorShowType.WARN_MESSAGE:
175
- message.warn(errorMessage);
176
- break;
177
- case ErrorShowType.ERROR_MESSAGE:
178
- message.error(errorMessage);
179
- break;
180
- case ErrorShowType.NOTIFICATION:
181
- notification.open({ description: errorMessage, message: errorCode });
182
- break;
183
- case ErrorShowType.REDIRECT:
184
- // TODO: redirect
185
- break;
186
- default:
187
- message.error(errorMessage);
188
- }
189
- }
190
- } else if (error.request) {
191
- // 请求已经成功发起,但没有收到响应
192
- // \`error.request\` 在浏览器中是 XMLHttpRequest 的实例,
193
- // 而在node.js中是 http.ClientRequest 的实例
194
- message.error(
195
- errorConfig?.defaultNoneResponseErrorMessage ||
196
- 'None response! Please retry.',
197
- );
198
- } else {
199
- // 发送请求时出了点问题
200
- message.error(
201
- errorConfig?.defaultRequestErrorMessage || 'Request error, please retry.',
202
- );
203
- }
204
- throw error;
205
- };
206
-
207
146
  let requestInstance: AxiosInstance;
208
147
  let config: RequestConfig;
209
148
  const getConfig = (): RequestConfig => {
@@ -215,51 +154,112 @@ const getConfig = (): RequestConfig => {
215
154
  });
216
155
  return config;
217
156
  };
157
+
218
158
  const getRequestInstance = (): AxiosInstance => {
219
159
  if (requestInstance) return requestInstance;
220
160
  const config = getConfig();
221
161
  requestInstance = axios.create(config);
222
162
 
163
+ config?.requestInterceptors?.forEach((interceptor) => {
164
+ if(interceptor instanceof Array){
165
+ requestInstance.interceptors.request.use((config) => {
166
+ const { url } = config;
167
+ if(interceptor[0].length === 2){
168
+ const { url: newUrl, options } = interceptor[0](url, config);
169
+ return { ...options, url: newUrl };
170
+ }
171
+ return interceptor[0](config);
172
+ }, interceptor[1]);
173
+ } else {
174
+ requestInstance.interceptors.request.use((config) => {
175
+ const { url } = config;
176
+ if(interceptor.length === 2){
177
+ const { url: newUrl, options } = interceptor(url, config);
178
+ return { ...options, url: newUrl };
179
+ }
180
+ return interceptor(config);
181
+ })
182
+ }
183
+ });
184
+
185
+ config?.responseInterceptors?.forEach((interceptor) => {
186
+ interceptor instanceof Array ?
187
+ requestInstance.interceptors.response.use(interceptor[0], interceptor[1]):
188
+ requestInstance.interceptors.response.use(interceptor);
189
+ });
190
+
223
191
  // 当响应的数据 success 是 false 的时候,抛出 error 以供 errorHandler 处理。
224
192
  requestInstance.interceptors.response.use((response)=>{
225
- const {data} = response;
226
- const adaptor = config?.errorConfig?.adaptor || ((resData) => resData);
227
- const errorInfo = adaptor(data,response);
228
- if(errorInfo.success === false){
229
- const error: RequestError = new Error(errorInfo.errorMessage);
230
- error.name = 'BizError';
231
- error.data = data;
232
- error.info = errorInfo;
233
- error.response = response;
234
- throw error;
193
+ const { data } = response;
194
+ if(config?.errorConfig?.errorThrower){
195
+ config.errorConfig.errorThrower(data);
235
196
  }
236
197
  return response;
237
198
  })
238
199
  return requestInstance;
239
200
  };
240
201
 
241
- const request: IRequest = (url, opts) => {
202
+ const request: IRequest = (url: string, opts: any = { method: 'GET' }) => {
242
203
  const requestInstance = getRequestInstance();
243
204
  const config = getConfig();
244
- return new Promise((resolve, reject) => {
205
+ const { getResponse = false, requestInterceptors, responseInterceptors } = opts;
206
+ const requestInterceptorsToEject = requestInterceptors?.map((interceptor) => {
207
+ if(interceptor instanceof Array){
208
+ return requestInstance.interceptors.request.use((config) => {
209
+ const { url } = config;
210
+ if(interceptor[0].length === 2){
211
+ const { url: newUrl, options } = interceptor[0](url, config);
212
+ return { ...options, url: newUrl };
213
+ }
214
+ return interceptor[0](config);
215
+ }, interceptor[1]);
216
+ } else {
217
+ return requestInstance.interceptors.request.use((config) => {
218
+ const { url } = config;
219
+ if(interceptor.length === 2){
220
+ const { url: newUrl, options } = interceptor(url, config);
221
+ return { ...options, url: newUrl };
222
+ }
223
+ return interceptor(config);
224
+ })
225
+ }
226
+ });
227
+ const responseInterceptorsToEject = responseInterceptors?.map((interceptor) => {
228
+ return interceptor instanceof Array ?
229
+ requestInstance.interceptors.response.use(interceptor[0], interceptor[1]):
230
+ requestInstance.interceptors.response.use(interceptor);
231
+ });
232
+ return new Promise((resolve, reject)=>{
245
233
  requestInstance
246
- .request({ ...opts, url })
247
- .then((res) => {
248
- const formatResultAdaptor =
249
- config?.formatResultAdaptor || ((res) => res.data);
250
- resolve(formatResultAdaptor(res));
234
+ .request({...opts, url})
235
+ .then((res)=>{
236
+ requestInterceptorsToEject?.forEach((interceptor) => {
237
+ requestInstance.interceptors.request.eject(interceptor);
238
+ });
239
+ responseInterceptorsToEject?.forEach((interceptor) => {
240
+ requestInstance.interceptors.response.eject(interceptor);
241
+ });
242
+ resolve(getResponse ? res : res.data);
251
243
  })
252
- .catch((error) => {
244
+ .catch((error)=>{
245
+ requestInterceptorsToEject?.forEach((interceptor) => {
246
+ requestInstance.interceptors.request.eject(interceptor);
247
+ });
248
+ responseInterceptorsToEject?.forEach((interceptor) => {
249
+ requestInstance.interceptors.response.eject(interceptor);
250
+ });
253
251
  try {
254
252
  const handler =
255
- config.errorConfig?.errorHandler || defaultErrorHandler;
256
- handler(error, opts, config);
253
+ config.errorConfig?.errorHandler;
254
+ if(handler)
255
+ handler(error, opts, config);
257
256
  } catch (e) {
258
257
  reject(e);
259
258
  }
260
- });
261
- });
262
- };
259
+ reject(error);
260
+ })
261
+ })
262
+ }
263
263
 
264
264
  export {
265
265
  useRequest,
@@ -279,18 +279,24 @@ export type {
279
279
  var _a;
280
280
  const umiRequestPath = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('@ahooksjs/use-request/package.json')));
281
281
  const axiosPath = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('axios/package.json')));
282
- const antdPkg = (0, plugin_utils_1.winPath)(
283
- // use path from antd plugin first
284
- ((_a = api.appData.antd) === null || _a === void 0 ? void 0 : _a.pkgPath) ||
285
- (0, path_1.dirname)(require.resolve('antd/package.json')));
282
+ let dataField = (_a = api.config.request) === null || _a === void 0 ? void 0 : _a.dataField;
283
+ if (dataField === undefined)
284
+ dataField = 'data';
285
+ const formatResult = dataField === '' ? `result => result` : `result => result?.${dataField}`;
286
286
  api.writeTmpFile({
287
287
  path: 'request.ts',
288
288
  content: plugin_utils_1.Mustache.render(requestTpl, {
289
289
  umiRequestPath,
290
290
  axiosPath,
291
- antdPkg,
291
+ formatResult,
292
292
  }),
293
293
  });
294
+ api.writeTmpFile({
295
+ path: 'types.d.ts',
296
+ content: `
297
+ export type { RequestConfig } from './request';
298
+ `,
299
+ });
294
300
  api.writeTmpFile({
295
301
  path: 'index.ts',
296
302
  content: `
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.isNeedPolyfill = exports.exactLocalePaths = exports.getLocaleList = exports.getAntdLocale = exports.getMomentLocale = void 0;
13
4
  const fs_1 = require("fs");
@@ -55,7 +46,7 @@ const modulesHasLocale = (localePath) => {
55
46
  return false;
56
47
  }
57
48
  };
58
- const getLocaleList = (opts) => __awaiter(void 0, void 0, void 0, function* () {
49
+ const getLocaleList = async (opts) => {
59
50
  const { localeFolder, separator = '-', absSrcPath = '', absPagesPath = '', addAntdLocales, resolveKey = 'moment', } = opts;
60
51
  const localeFileMath = new RegExp(`^([a-z]{2})${separator}?([A-Z]{2})?\.(js|json|ts)$`);
61
52
  const localeFiles = plugin_utils_1.glob
@@ -80,11 +71,11 @@ const getLocaleList = (opts) => __awaiter(void 0, void 0, void 0, function* () {
80
71
  };
81
72
  });
82
73
  const groups = plugin_utils_1.lodash.groupBy(localeFiles, 'name');
83
- const promises = Object.keys(groups).map((name) => __awaiter(void 0, void 0, void 0, function* () {
74
+ const promises = Object.keys(groups).map(async (name) => {
84
75
  const [lang, country = ''] = name.split(separator);
85
76
  const { momentLocale } = (0, exports.getMomentLocale)(lang, country, resolveKey);
86
77
  const antdLocale = plugin_utils_1.lodash
87
- .uniq(yield addAntdLocales({ lang, country }))
78
+ .uniq(await addAntdLocales({ lang, country }))
88
79
  .filter((localePath) => modulesHasLocale(localePath));
89
80
  return {
90
81
  lang,
@@ -97,9 +88,9 @@ const getLocaleList = (opts) => __awaiter(void 0, void 0, void 0, function* () {
97
88
  paths: groups[name].map((item) => (0, plugin_utils_1.winPath)(item.path)),
98
89
  momentLocale,
99
90
  };
100
- }));
91
+ });
101
92
  return Promise.all(promises);
102
- });
93
+ };
103
94
  exports.getLocaleList = getLocaleList;
104
95
  const exactLocalePaths = (data) => {
105
96
  return plugin_utils_1.lodash.flatten(data.map((item) => item.paths));
@@ -20,6 +20,7 @@ export declare class ModelUtils {
20
20
  count: number;
21
21
  constructor(api: IApi | null, opts: IOpts);
22
22
  getAllModels(opts: {
23
+ extraModelsPre: string[];
23
24
  extraModels: string[];
24
25
  }): Model[];
25
26
  getModels(opts: {
@@ -62,6 +62,7 @@ class ModelUtils {
62
62
  // reset count
63
63
  this.count = 1;
64
64
  return [
65
+ ...opts.extraModelsPre,
65
66
  ...this.getModels({
66
67
  base: (0, path_1.join)(this.api.paths.absSrcPath, 'models'),
67
68
  pattern: '**/*.{ts,tsx,js,jsx}',
@@ -139,6 +139,13 @@ export const MicroApp = forwardRef(
139
139
  setComponentError(null);
140
140
  setLoading(true);
141
141
  const configuration = {
142
+ fetch(url) {
143
+ return window.fetch(url, {
144
+ headers: {
145
+ accept: 'text/html',
146
+ },
147
+ });
148
+ },
142
149
  globalContext: window,
143
150
  ...globalSettings,
144
151
  ...settingsFromProps,
@@ -1,5 +1,4 @@
1
1
  // @ts-nocheck
2
- /* eslint-disable */
3
2
  __USE_MODEL__;
4
3
  import React from 'react';
5
4
 
@@ -1,5 +1,4 @@
1
1
  // @ts-nocheck
2
- /* eslint-disable */
3
2
  import { getPluginManager } from '@@/core/plugin';
4
3
  import ReactDOM from 'react-dom';
5
4
  import { ApplyPluginsType } from 'umi';
@@ -22,7 +21,7 @@ let render = noop;
22
21
  let hasMountedAtLeastOnce = false;
23
22
 
24
23
  export default () => defer.promise;
25
- export const clientRenderOptsStack: any[] = [];
24
+ export const contextOptsStack: any[] = [];
26
25
 
27
26
  // function normalizeHistory(
28
27
  // history?: 'string' | Record<string, any>,
@@ -79,10 +78,7 @@ export function genMount(mountElementId: string) {
79
78
  // 默认开启
80
79
  // 如果需要手动控制 loading,通过主应用配置 props.autoSetLoading false 可以关闭
81
80
  callback: () => {
82
- if (
83
- props?.autoSetLoading &&
84
- typeof props?.setLoading === 'function'
85
- ) {
81
+ if (props.autoSetLoading && typeof props.setLoading === 'function') {
86
82
  props.setLoading(false);
87
83
  }
88
84
 
@@ -94,9 +90,11 @@ export function genMount(mountElementId: string) {
94
90
  // 支持通过 props 注入 container 来限定子应用 mountElementId 的查找范围
95
91
  // 避免多个子应用出现在同一主应用时出现 mount 冲突
96
92
  rootElement:
97
- props?.container?.querySelector(`#${mountElementId}`) ||
93
+ props.container?.querySelector(`#${mountElementId}`) ||
98
94
  mountElementId,
99
95
 
96
+ basename: props.base,
97
+
100
98
  // 当存在同一个 umi 子应用在同一个页面被多实例渲染的场景时(比如一个页面里,同时展示了这个子应用的多个路由页面)
101
99
  // mount 钩子会被调用多次,但是具体什么时候对应的实例开始 render 则是不定的,即它调用 applyPlugins('modifyClientRenderOpts') 的时机是不确定的
102
100
  // 为了保证每次 applyPlugins('modifyClientRenderOpts') 调用是生成正确的 history,我们需要这里通过闭包上下文维持 mount 调用时的一些配置信息
@@ -111,7 +109,7 @@ export function genMount(mountElementId: string) {
111
109
  // },
112
110
  };
113
111
 
114
- clientRenderOptsStack.push(clientRenderOpts);
112
+ contextOptsStack.push(clientRenderOpts);
115
113
  }
116
114
 
117
115
  // 第一次 mount defer 被 resolve 后umi 会自动触发 render,非第一次 mount 则需手动触发
@@ -1,5 +1,4 @@
1
1
  // @ts-nocheck
2
- /* eslint-disable */
3
2
  import { useState } from 'react';
4
3
 
5
4
  let initState: any;
@@ -1,21 +1,15 @@
1
1
  // @ts-nocheck
2
- /* eslint-disable */
3
- import qiankunRender from './lifecycles';
2
+ import qiankunRender, { contextOptsStack } from './lifecycles';
4
3
 
5
4
  export function render(oldRender: any) {
6
5
  return qiankunRender().then(oldRender);
7
6
  }
8
7
 
9
- // export function modifyClientRenderOpts(memo: any) {
10
- // // 每次应用 render 的时候会调 modifyClientRenderOpts,这时尝试从队列中取 render 的配置
11
- // const clientRenderOpts = clientRenderOptsStack.shift();
12
- // if (clientRenderOpts) {
13
- // const history = clientRenderOpts.getHistory();
14
- // delete clientRenderOpts.getHistory;
15
- // clientRenderOpts.history = history;
16
- // }
17
- // return {
18
- // ...memo,
19
- // ...clientRenderOpts,
20
- // };
21
- // }
8
+ export function modifyContextOpts(memo: any) {
9
+ // 每次应用 render 的时候会调 modifyClientRenderOpts,这时尝试从队列中取 render 的配置
10
+ const clientRenderOpts = contextOptsStack.shift();
11
+ return {
12
+ ...memo,
13
+ ...clientRenderOpts,
14
+ };
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.0.0-rc.12",
3
+ "version": "4.0.0-rc.15",
4
4
  "description": "@umijs/plugins",
5
5
  "homepage": "https://github.com/umijs/umi-next/tree/master/packages/plugins#readme",
6
6
  "bugs": "https://github.com/umijs/umi-next/issues",
@@ -17,15 +17,15 @@
17
17
  ],
18
18
  "scripts": {
19
19
  "build": "pnpm tsc",
20
- "build:deps": "pnpm esno ../../scripts/bundleDeps.ts",
20
+ "build:deps": "umi-scripts bundleDeps",
21
21
  "dev": "pnpm build -- --watch",
22
- "test": "jest -c ../../jest.turbo.config.ts"
22
+ "test": "umi-scripts jest-turbo"
23
23
  },
24
24
  "dependencies": {
25
25
  "@ahooksjs/use-request": "^2.0.0",
26
26
  "@ant-design/icons": "^4.7.0",
27
- "@ant-design/pro-layout": "^6.34.9",
28
- "@umijs/bundler-utils": "4.0.0-rc.12",
27
+ "@ant-design/pro-layout": "^6.35.1",
28
+ "@umijs/bundler-utils": "4.0.0-rc.15",
29
29
  "antd-dayjs-webpack-plugin": "^1.0.6",
30
30
  "axios": "^0.26.1",
31
31
  "babel-plugin-import": "^1.13.3",
@@ -36,15 +36,15 @@
36
36
  "event-emitter": "~0.3.5",
37
37
  "fast-deep-equal": "3.1.3",
38
38
  "lodash": "^4.17.21",
39
- "moment": "^2.29.2",
39
+ "moment": "^2.29.3",
40
40
  "qiankun": "^2.7.0",
41
41
  "react-intl": "3.12.1",
42
- "react-redux": "^7.2.8",
43
- "redux": "^4.1.2",
42
+ "react-redux": "^8.0.0",
43
+ "redux": "^4.2.0",
44
44
  "warning": "^4.0.3"
45
45
  },
46
46
  "devDependencies": {
47
- "umi": "4.0.0-rc.12"
47
+ "umi": "4.0.0-rc.15"
48
48
  },
49
49
  "publishConfig": {
50
50
  "access": "public"