@umijs/plugins 4.0.62 → 4.0.63

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
@@ -38,11 +38,8 @@ var import_withTmpPath = require("./utils/withTmpPath");
38
38
  var access_default = (api) => {
39
39
  api.describe({
40
40
  config: {
41
- schema(Joi) {
42
- return Joi.alternatives().try(
43
- Joi.object(),
44
- Joi.boolean().invalid(true)
45
- );
41
+ schema({ zod }) {
42
+ return zod.record(zod.any());
46
43
  }
47
44
  },
48
45
  enableBy: api.EnableBy.config
package/dist/analytics.js CHANGED
@@ -31,15 +31,12 @@ var analytics_default = (api) => {
31
31
  api.describe({
32
32
  key: "analytics",
33
33
  config: {
34
- schema(Joi) {
35
- return Joi.alternatives().try(
36
- Joi.object({
37
- baidu: Joi.string(),
38
- ga: Joi.string(),
39
- ga_v2: Joi.string()
40
- }),
41
- Joi.boolean().invalid(true)
42
- );
34
+ schema({ zod }) {
35
+ return zod.object({
36
+ baidu: zod.string(),
37
+ ga: zod.string(),
38
+ ga_v2: zod.string()
39
+ }).partial();
43
40
  },
44
41
  onChange: api.ConfigChangeType.reload
45
42
  },
package/dist/antd.js CHANGED
@@ -54,23 +54,20 @@ var antd_default = (api) => {
54
54
  const appConfigAvailable = import_plugin_utils.semver.gte(antdVersion, "5.3.0");
55
55
  api.describe({
56
56
  config: {
57
- schema(Joi) {
58
- return Joi.alternatives().try(
59
- Joi.object({
60
- configProvider: Joi.object(),
61
- // themes
62
- dark: Joi.boolean(),
63
- compact: Joi.boolean(),
64
- // babel-plugin-import
65
- import: Joi.boolean(),
66
- // less or css, default less
67
- style: Joi.string().allow("less", "css"),
68
- theme: Joi.object(),
69
- // Only antd@5.1.0 is supported
70
- appConfig: Joi.object()
71
- }),
72
- Joi.boolean().invalid(true)
73
- );
57
+ schema({ zod }) {
58
+ return zod.object({
59
+ configProvider: zod.record(zod.any()),
60
+ // themes
61
+ dark: zod.boolean(),
62
+ compact: zod.boolean(),
63
+ // babel-plugin-import
64
+ import: zod.boolean(),
65
+ // less or css, default less
66
+ style: zod.enum(["less", "css"]).describe("less or css, default less"),
67
+ theme: zod.record(zod.any()),
68
+ // Only antd@5.1.0 is supported
69
+ appConfig: zod.record(zod.any()).describe("Only antd@5.1.0 is supported")
70
+ }).deepPartial();
74
71
  }
75
72
  },
76
73
  enableBy({ userConfig }) {
package/dist/confetti.js CHANGED
@@ -45,8 +45,8 @@ var confetti_default = (api) => {
45
45
  api.describe({
46
46
  key: "confetti",
47
47
  config: {
48
- schema(joi) {
49
- return joi.object();
48
+ schema({ zod }) {
49
+ return zod.object({});
50
50
  }
51
51
  },
52
52
  enableBy: api.EnableBy.config
package/dist/dva.js CHANGED
@@ -45,15 +45,12 @@ var dva_default = (api) => {
45
45
  const pkgPath = (0, import_path.join)(__dirname, "../libs/dva.ts");
46
46
  api.describe({
47
47
  config: {
48
- schema(Joi) {
49
- return Joi.alternatives().try(
50
- Joi.object({
51
- extraModels: Joi.array().items(Joi.string()),
52
- immer: Joi.object(),
53
- skipModelValidate: Joi.boolean()
54
- }),
55
- Joi.boolean().invalid(true)
56
- );
48
+ schema({ zod }) {
49
+ return zod.object({
50
+ extraModels: zod.array(zod.string()),
51
+ immer: zod.record(zod.any()),
52
+ skipModelValidate: zod.boolean()
53
+ }).deepPartial();
57
54
  }
58
55
  },
59
56
  enableBy: api.EnableBy.config
@@ -27,13 +27,10 @@ var import_withTmpPath = require("./utils/withTmpPath");
27
27
  var initial_state_default = (api) => {
28
28
  api.describe({
29
29
  config: {
30
- schema(Joi) {
31
- return Joi.alternatives().try(
32
- Joi.object({
33
- loading: Joi.string()
34
- }),
35
- Joi.boolean().invalid(true)
36
- );
30
+ schema({ zod }) {
31
+ return zod.object({
32
+ loading: zod.string()
33
+ }).partial();
37
34
  }
38
35
  },
39
36
  enableBy: api.EnableBy.config
package/dist/layout.js CHANGED
@@ -66,11 +66,8 @@ var layout_default = (api) => {
66
66
  api.describe({
67
67
  key: "layout",
68
68
  config: {
69
- schema(Joi) {
70
- return Joi.alternatives().try(
71
- Joi.object(),
72
- Joi.boolean().invalid(true)
73
- );
69
+ schema({ zod }) {
70
+ return zod.record(zod.any());
74
71
  },
75
72
  onChange: api.ConfigChangeType.regenerateTmpFiles
76
73
  },
package/dist/locale.js CHANGED
@@ -35,6 +35,7 @@ __export(locale_exports, {
35
35
  module.exports = __toCommonJS(locale_exports);
36
36
  var import_fs = require("fs");
37
37
  var import_path = require("path");
38
+ var import_umi = require("umi");
38
39
  var import_plugin_utils = require("umi/plugin-utils");
39
40
  var import_localeUtils = require("./utils/localeUtils");
40
41
  var import_withTmpPath = require("./utils/withTmpPath");
@@ -55,18 +56,15 @@ var locale_default = (api) => {
55
56
  api.describe({
56
57
  key: "locale",
57
58
  config: {
58
- schema(Joi) {
59
- return Joi.alternatives().try(
60
- Joi.object({
61
- default: Joi.string(),
62
- useLocalStorage: Joi.boolean(),
63
- baseNavigator: Joi.boolean(),
64
- title: Joi.boolean(),
65
- antd: Joi.boolean(),
66
- baseSeparator: Joi.string()
67
- }),
68
- Joi.boolean().invalid(true)
69
- );
59
+ schema({ zod }) {
60
+ return zod.object({
61
+ default: zod.string(),
62
+ useLocalStorage: zod.boolean(),
63
+ baseNavigator: zod.boolean(),
64
+ title: zod.boolean(),
65
+ antd: zod.boolean(),
66
+ baseSeparator: zod.string()
67
+ }).partial();
70
68
  }
71
69
  },
72
70
  enableBy: api.EnableBy.config
@@ -228,6 +226,21 @@ export { addLocale, setLocale, getLocale, getIntl, useIntl, injectIntl, formatMe
228
226
  export { SelectLang } from './SelectLang';
229
227
  `
230
228
  });
229
+ api.writeTmpFile({
230
+ path: import_umi.RUNTIME_TYPE_FILE_NAME,
231
+ content: `
232
+ import {
233
+ IntlCache,
234
+ createIntl,
235
+ } from '${reactIntlPkgPath}';
236
+ type OptionalIntlConfig = Omit<Parameters<typeof createIntl>[0], 'locale' | 'defaultLocale'>;
237
+ export interface IRuntimeConfig {
238
+ locale?: {
239
+ getLocale?: () => string;
240
+ cache?: IntlCache;
241
+ } & OptionalIntlConfig;
242
+ };`
243
+ });
231
244
  });
232
245
  api.addRuntimePlugin(() => [(0, import_withTmpPath.withTmpPath)({ api, path: "runtime.tsx" })]);
233
246
  api.addRuntimePluginKey(() => ["locale"]);
package/dist/mf.js CHANGED
@@ -33,21 +33,22 @@ function mf(api) {
33
33
  api.describe({
34
34
  key: "mf",
35
35
  config: {
36
- schema(Joi) {
37
- return Joi.object({
38
- name: Joi.string(),
39
- remotes: Joi.array().items(
40
- Joi.object({
41
- aliasName: Joi.string(),
42
- name: Joi.string().required(),
43
- entry: Joi.string(),
44
- entries: Joi.object(),
45
- keyResolver: Joi.string()
36
+ schema({ zod }) {
37
+ return zod.object({
38
+ name: zod.string(),
39
+ remotes: zod.array(
40
+ zod.object({
41
+ aliasName: zod.string().optional(),
42
+ // string 上没有 required
43
+ name: zod.string(),
44
+ entry: zod.string().optional(),
45
+ entries: zod.object({}).optional(),
46
+ keyResolver: zod.string().optional()
46
47
  })
47
48
  ),
48
- shared: Joi.object(),
49
- library: Joi.object()
50
- });
49
+ shared: zod.record(zod.any()),
50
+ library: zod.record(zod.any())
51
+ }).partial();
51
52
  }
52
53
  },
53
54
  enableBy: api.EnableBy.config
package/dist/model.js CHANGED
@@ -41,13 +41,10 @@ var import_withTmpPath = require("./utils/withTmpPath");
41
41
  var model_default = (api) => {
42
42
  api.describe({
43
43
  config: {
44
- schema(Joi) {
45
- return Joi.alternatives().try(
46
- Joi.object({
47
- extraModels: Joi.array().items(Joi.string())
48
- }),
49
- Joi.boolean().invalid(true)
50
- );
44
+ schema({ zod }) {
45
+ return zod.object({
46
+ extraModels: zod.array(zod.string())
47
+ }).partial();
51
48
  }
52
49
  },
53
50
  enableBy: api.EnableBy.config
@@ -38,15 +38,12 @@ var moment2dayjs_default = (api) => {
38
38
  api.describe({
39
39
  key: "moment2dayjs",
40
40
  config: {
41
- schema(Joi) {
42
- return Joi.alternatives().try(
43
- Joi.object({
44
- preset: Joi.string(),
45
- // 'antd' | 'antdv3 | 'none'
46
- plugins: Joi.array()
47
- }),
48
- Joi.boolean().invalid(true)
49
- );
41
+ schema({ zod }) {
42
+ return zod.object({
43
+ preset: zod.enum(["antd", "antdv3", "none"]),
44
+ // 'antd' | 'antdv3 | 'none'
45
+ plugins: zod.array(zod.string())
46
+ }).partial();
50
47
  }
51
48
  },
52
49
  enableBy: api.EnableBy.config
package/dist/qiankun.js CHANGED
@@ -35,15 +35,12 @@ module.exports = __toCommonJS(qiankun_exports);
35
35
  var qiankun_default = (api) => {
36
36
  api.describe({
37
37
  config: {
38
- schema(Joi) {
39
- return Joi.alternatives().try(
40
- Joi.object().keys({
41
- slave: Joi.object(),
42
- master: Joi.object(),
43
- externalQiankun: Joi.boolean()
44
- }),
45
- Joi.boolean().invalid(true)
46
- );
38
+ schema({ zod }) {
39
+ return zod.object({
40
+ slave: zod.record(zod.any()),
41
+ master: zod.record(zod.any()),
42
+ externalQiankun: zod.boolean()
43
+ }).deepPartial();
47
44
  }
48
45
  }
49
46
  });
@@ -40,11 +40,11 @@ var react_query_default = (api) => {
40
40
  api.describe({
41
41
  key: "reactQuery",
42
42
  config: {
43
- schema(Joi) {
44
- return Joi.object({
45
- devtool: Joi.alternatives(Joi.object(), Joi.boolean()),
46
- queryClient: Joi.alternatives(Joi.object(), Joi.boolean())
47
- });
43
+ schema({ zod }) {
44
+ return zod.object({
45
+ devtool: zod.union([zod.record(zod.any()), zod.boolean()]),
46
+ queryClient: zod.union([zod.record(zod.any()), zod.boolean()])
47
+ }).deepPartial();
48
48
  }
49
49
  },
50
50
  enableBy: api.EnableBy.config
package/dist/request.js CHANGED
@@ -39,16 +39,11 @@ var request_default = (api) => {
39
39
  api.describe({
40
40
  key: "request",
41
41
  config: {
42
- schema: (Joi) => {
43
- return Joi.alternatives().try(
44
- Joi.object({
45
- dataField: Joi.alternatives().try(
46
- Joi.string().allow(""),
47
- Joi.string()
48
- )
49
- }),
50
- Joi.boolean().invalid(true)
51
- );
42
+ schema: ({ zod }) => {
43
+ return zod.object({
44
+ // TODO: '' | string 没有找到对应的写法
45
+ dataField: zod.string()
46
+ }).partial();
52
47
  }
53
48
  },
54
49
  enableBy: api.EnableBy.config
@@ -39,9 +39,9 @@ var styled_components_default = (api) => {
39
39
  api.describe({
40
40
  key: "styledComponents",
41
41
  config: {
42
- schema(Joi) {
43
- return Joi.object({
44
- babelPlugin: Joi.object()
42
+ schema({ zod }) {
43
+ return zod.object({
44
+ babelPlugin: zod.record(zod.any()).optional()
45
45
  });
46
46
  }
47
47
  },
@@ -28,11 +28,8 @@ var tailwindcss_default = (api) => {
28
28
  api.describe({
29
29
  key: "tailwindcss",
30
30
  config: {
31
- schema(Joi) {
32
- return Joi.alternatives().try(
33
- Joi.object(),
34
- Joi.boolean().invalid(true)
35
- );
31
+ schema({ zod }) {
32
+ return zod.record(zod.any());
36
33
  }
37
34
  },
38
35
  enableBy: api.EnableBy.config
package/dist/unocss.js CHANGED
@@ -30,13 +30,10 @@ var unocss_default = (api) => {
30
30
  api.describe({
31
31
  key: "unocss",
32
32
  config: {
33
- schema(Joi) {
34
- return Joi.alternatives().try(
35
- Joi.object({
36
- watch: Joi.array()
37
- }),
38
- Joi.boolean().invalid(true)
39
- );
33
+ schema({ zod }) {
34
+ return zod.object({
35
+ watch: zod.array(zod.any())
36
+ });
40
37
  }
41
38
  },
42
39
  enableBy: api.EnableBy.config
package/dist/valtio.js CHANGED
@@ -38,8 +38,8 @@ var valtio_default = (api) => {
38
38
  api.describe({
39
39
  key: "valtio",
40
40
  config: {
41
- schema(joi) {
42
- return joi.object();
41
+ schema({ zod }) {
42
+ return zod.object({});
43
43
  }
44
44
  },
45
45
  enableBy: api.EnableBy.config
@@ -105,6 +105,20 @@ export const addLocale = (
105
105
  }
106
106
  };
107
107
 
108
+ const applyRuntimeLocalePlugin = (initialValue: any) => {
109
+ return getPluginManager().applyPlugins({
110
+ key: 'locale',
111
+ type: 'modify',
112
+ initialValue
113
+ });
114
+ }
115
+
116
+ const _createIntl = (locale: string) => {
117
+ const runtimeLocale = applyRuntimeLocalePlugin(localeInfo[locale]);
118
+ const { cache, ...config } = runtimeLocale;
119
+ return createIntl(config, cache);
120
+ }
121
+
108
122
  /**
109
123
  * 获取当前的 intl 对象,可以在 node 中使用
110
124
  * @param locale 需要切换的语言类型
@@ -120,7 +134,7 @@ export const getIntl = (locale?: string, changeIntl?: boolean) => {
120
134
  if (!locale) locale = getLocale();
121
135
  // 如果存在于 localeInfo 中
122
136
  if (locale&&localeInfo[locale]) {
123
- return createIntl(localeInfo[locale]);
137
+ return _createIntl(locale);
124
138
  }
125
139
  {{#ExistLocaleDir}}
126
140
  // 不存在需要一个报错提醒
@@ -130,12 +144,14 @@ export const getIntl = (locale?: string, changeIntl?: boolean) => {
130
144
  );
131
145
  {{/ExistLocaleDir}}
132
146
  // 使用 zh-CN
133
- if (localeInfo[{{{ DefaultLocale }}}]) return createIntl(localeInfo[{{{ DefaultLocale }}}]);
147
+ if (localeInfo[{{{ DefaultLocale }}}]) {
148
+ return _createIntl({{{ DefaultLocale }}});
149
+ }
134
150
 
135
151
  // 如果还没有,返回一个空的
136
152
  return createIntl({
137
153
  locale: {{{ DefaultLocale }}},
138
- messages: {},
154
+ messages: {}
139
155
  });
140
156
  };
141
157
 
@@ -152,12 +168,7 @@ export const setIntl = (locale: string) => {
152
168
  * @returns string
153
169
  */
154
170
  export const getLocale = () => {
155
- const runtimeLocale = getPluginManager().applyPlugins({
156
- key: 'locale',
157
- // workaround: 不使用 ApplyPluginsType.modify 是为了避免循环依赖,与 fast-refresh 一起用时会有问题
158
- type: 'modify',
159
- initialValue: {},
160
- });
171
+ const runtimeLocale = applyRuntimeLocalePlugin({});
161
172
  // runtime getLocale for user define
162
173
  if (typeof runtimeLocale?.getLocale === 'function') {
163
174
  return runtimeLocale.getLocale();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.0.62",
3
+ "version": "4.0.63",
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",
@@ -42,12 +42,12 @@
42
42
  "styled-components": "6.0.0-beta.9",
43
43
  "tslib": "^2",
44
44
  "warning": "^4.0.3",
45
- "@umijs/bundler-utils": "4.0.62",
45
+ "@umijs/bundler-utils": "4.0.63",
46
46
  "@umijs/valtio": "1.0.3"
47
47
  },
48
48
  "devDependencies": {
49
49
  "antd": "^4.24.1",
50
- "umi": "4.0.62"
50
+ "umi": "4.0.63"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"