@umijs/plugins 4.0.89 → 4.0.90

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
@@ -61,22 +61,61 @@ var antd_default = (api) => {
61
61
  api.describe({
62
62
  config: {
63
63
  schema({ zod }) {
64
- return zod.object({
65
- configProvider: zod.record(zod.any()),
66
- // themes
64
+ const commonSchema = {
67
65
  dark: zod.boolean(),
68
66
  compact: zod.boolean(),
69
67
  // babel-plugin-import
70
68
  import: zod.boolean(),
71
69
  // less or css, default less
72
- style: zod.enum(["less", "css"]).describe("less or css, default less"),
73
- theme: zod.record(zod.any()),
74
- // Only antd@5.1.0 is supported
75
- appConfig: zod.record(zod.any()).describe("Only antd@5.1.0 is supported"),
76
- // DatePicker & Calendar use moment version
77
- momentPicker: zod.boolean().describe("Only antd@5.x is supported"),
78
- styleProvider: zod.record(zod.any())
79
- }).deepPartial();
70
+ style: zod.enum(["less", "css"]).describe("less or css, default less")
71
+ };
72
+ const createZodRecordWithSpecifiedPartial = (partial) => {
73
+ const keys = Object.keys(partial);
74
+ return zod.union([
75
+ zod.object(partial),
76
+ zod.record(zod.any()).refine((obj) => {
77
+ return !keys.some((key) => key in obj);
78
+ })
79
+ ]);
80
+ };
81
+ const createV5Schema = () => {
82
+ const componentNameSchema = zod.string().refine(
83
+ (value) => {
84
+ const firstLetter = value.slice(0, 1);
85
+ return firstLetter === firstLetter.toUpperCase();
86
+ },
87
+ {
88
+ message: "theme.components.[componentName] needs to be in PascalCase, e.g. theme.components.Button"
89
+ }
90
+ );
91
+ const themeSchema = createZodRecordWithSpecifiedPartial({
92
+ components: zod.record(componentNameSchema, zod.record(zod.any()))
93
+ });
94
+ const configProvider = createZodRecordWithSpecifiedPartial({
95
+ theme: themeSchema
96
+ });
97
+ return zod.object({
98
+ ...commonSchema,
99
+ theme: themeSchema.describe("Shortcut of `configProvider.theme`"),
100
+ appConfig: zod.record(zod.any()).describe("Only >= antd@5.1.0 is supported"),
101
+ momentPicker: zod.boolean().describe("DatePicker & Calendar use moment version"),
102
+ styleProvider: zod.record(zod.any()),
103
+ configProvider
104
+ }).deepPartial();
105
+ };
106
+ const createV4Schema = () => {
107
+ return zod.object({
108
+ ...commonSchema,
109
+ configProvider: zod.record(zod.any())
110
+ }).deepPartial();
111
+ };
112
+ if (isV5) {
113
+ return createV5Schema();
114
+ }
115
+ if (isV4) {
116
+ return createV4Schema();
117
+ }
118
+ return zod.object({});
80
119
  }
81
120
  },
82
121
  enableBy({ userConfig }) {
@@ -87,6 +87,7 @@ var react_query_default = (api) => {
87
87
  api.writeTmpFile({
88
88
  path: "runtime.tsx",
89
89
  content: enableQueryClient ? `
90
+ import React from 'react';
90
91
  import { defaultContext, QueryClient, QueryClientProvider } from '${pkgPath}';
91
92
  import { ReactQueryDevtools } from '${devtoolPkgPath}';
92
93
  ${reactQueryRuntimeCode}
@@ -120,6 +120,7 @@ export { styled, ThemeProvider, createGlobalStyle, css, keyframes, StyleSheetMan
120
120
  api.writeTmpFile({
121
121
  path: "runtime.tsx",
122
122
  content: `
123
+ import React from 'react';
123
124
  ${hasProvider ? `import { StyleSheetManager } from '${(0, import_utils.winPath)(libPath)}';` : ``}
124
125
 
125
126
  ${styledComponentsRuntimeCode}
@@ -109,7 +109,7 @@ export async function render(oldRender: typeof noop) {
109
109
  microAppRuntimeRoutes = routes;
110
110
 
111
111
  // 主应用相关的配置注册完毕后即可开启渲染
112
- oldRender();
112
+ const renderData = oldRender();
113
113
 
114
114
  // 未使用 base 配置的可以认为是路由关联或者使用标签装载的应用
115
115
  const loadableApps = apps.filter((app) => !app.base);
@@ -133,6 +133,8 @@ export async function render(oldRender: typeof noop) {
133
133
  '[plugins/qiankun] 检测到还在使用旧版配置,该配置已移除,请尽快升级到最新配置方式以获得更好的开发体验,详见 https://umijs.org/plugins/plugin-qiankun#%E5%8D%87%E7%BA%A7%E6%8C%87%E5%8D%97',
134
134
  );
135
135
  }
136
+
137
+ return renderData;
136
138
  }
137
139
 
138
140
  export function patchClientRoutes({ routes }: { routes: any[] }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.0.89",
3
+ "version": "4.0.90",
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.0.89",
48
+ "@umijs/bundler-utils": "4.0.90",
49
49
  "@umijs/valtio": "1.0.4"
50
50
  },
51
51
  "devDependencies": {
52
52
  "antd": "^4.24.1",
53
- "umi": "4.0.89"
53
+ "umi": "4.0.90"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public"