@umijs/plugins 4.0.42 → 4.0.43
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 +12 -4
- package/dist/analytics.js +17 -11
- package/dist/antd.js +33 -16
- package/dist/dva.js +15 -7
- package/dist/initial-state.js +6 -3
- package/dist/layout.js +20 -12
- package/dist/locale.js +57 -26
- package/dist/mf.js +40 -16
- package/dist/model.js +14 -5
- package/dist/moment2dayjs.js +14 -6
- package/dist/qiankun/master.js +24 -5
- package/dist/qiankun/slave.js +101 -62
- package/dist/qiankun.js +12 -6
- package/dist/{icons.d.ts → react-query.d.ts} +0 -0
- package/dist/react-query.js +153 -0
- package/dist/request.js +17 -9
- package/dist/styled-components.js +4 -1
- package/dist/tailwindcss.js +24 -14
- package/dist/unocss.js +13 -5
- package/dist/utils/astUtils.js +4 -1
- package/dist/utils/localeUtils.js +11 -5
- package/dist/utils/modelUtils.js +34 -12
- package/dist/utils/resolveProjectDep.js +5 -3
- package/dist/utils/withTmpPath.js +7 -1
- package/dist/valtio.js +7 -2
- package/libs/qiankun/master/MicroApp.tsx +12 -0
- package/libs/qiankun/master/masterRuntimePlugin.tsx +10 -0
- package/libs/qiankun/master/routeUtils.ts +26 -0
- package/libs/qiankun/slave/MicroAppLink.tsx +122 -0
- package/libs/qiankun/slave/constants.ts +5 -0
- package/package.json +12 -9
- package/dist/icons.js +0 -29
package/dist/moment2dayjs.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/moment2dayjs.ts
|
|
@@ -32,10 +35,13 @@ var moment2dayjs_default = (api) => {
|
|
|
32
35
|
key: "moment2dayjs",
|
|
33
36
|
config: {
|
|
34
37
|
schema(Joi) {
|
|
35
|
-
return Joi.alternatives().try(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
return Joi.alternatives().try(
|
|
39
|
+
Joi.object({
|
|
40
|
+
preset: Joi.string(),
|
|
41
|
+
plugins: Joi.array()
|
|
42
|
+
}),
|
|
43
|
+
Joi.boolean().invalid(true)
|
|
44
|
+
);
|
|
39
45
|
}
|
|
40
46
|
},
|
|
41
47
|
enableBy: api.EnableBy.config
|
|
@@ -100,7 +106,9 @@ dayjs.extend({{.}});
|
|
|
100
106
|
|
|
101
107
|
dayjs.extend(antdPlugin);
|
|
102
108
|
`;
|
|
103
|
-
const dayjsAntdPluginPath = (0, import_plugin_utils.winPath)(
|
|
109
|
+
const dayjsAntdPluginPath = (0, import_plugin_utils.winPath)(
|
|
110
|
+
require.resolve("antd-dayjs-webpack-plugin/src/antd-plugin")
|
|
111
|
+
);
|
|
104
112
|
const dayjsPath = (0, import_plugin_utils.winPath)((0, import_path.dirname)(require.resolve("dayjs/package.json")));
|
|
105
113
|
api.writeTmpFile({
|
|
106
114
|
path: "runtime.tsx",
|
package/dist/qiankun/master.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/qiankun/master.ts
|
|
@@ -68,7 +71,10 @@ var master_default = (api) => {
|
|
|
68
71
|
const base = api.config.base || "/";
|
|
69
72
|
const masterHistoryType = ((_a = api.config.history) == null ? void 0 : _a.type) || "browser";
|
|
70
73
|
const routeProps = route.microAppProps || {};
|
|
71
|
-
const normalizedRouteProps = JSON.stringify(routeProps).replace(
|
|
74
|
+
const normalizedRouteProps = JSON.stringify(routeProps).replace(
|
|
75
|
+
/"/g,
|
|
76
|
+
"'"
|
|
77
|
+
);
|
|
72
78
|
route.file = `(async () => {
|
|
73
79
|
const { getMicroAppRouteComponent } = await import('@@/plugin-qiankun-master/getMicroAppRouteComponent');
|
|
74
80
|
return getMicroAppRouteComponent({ appName: '${appName}', base: '${base}', routePath: '${route.path}', masterHistoryType: '${masterHistoryType}', routeProps: ${normalizedRouteProps} })
|
|
@@ -88,7 +94,10 @@ var master_default = (api) => {
|
|
|
88
94
|
}
|
|
89
95
|
});
|
|
90
96
|
function getFileContent(file) {
|
|
91
|
-
return (0, import_fs.readFileSync)(
|
|
97
|
+
return (0, import_fs.readFileSync)(
|
|
98
|
+
(0, import_path.join)(__dirname, "../../libs/qiankun/master", file),
|
|
99
|
+
"utf-8"
|
|
100
|
+
);
|
|
92
101
|
}
|
|
93
102
|
api.onGenerateFiles(() => {
|
|
94
103
|
var _a;
|
|
@@ -127,6 +136,7 @@ export const setMasterOptions = (newOpts) => options = ({ ...options, ...newOpts
|
|
|
127
136
|
"common.ts",
|
|
128
137
|
"constants.ts",
|
|
129
138
|
"types.ts",
|
|
139
|
+
"routeUtils.ts",
|
|
130
140
|
"masterRuntimePlugin.tsx",
|
|
131
141
|
"getMicroAppRouteComponent.tsx.tpl",
|
|
132
142
|
"ErrorBoundary.tsx",
|
|
@@ -145,11 +155,20 @@ export const setMasterOptions = (newOpts) => options = ({ ...options, ...newOpts
|
|
|
145
155
|
} else {
|
|
146
156
|
let content = getFileContent(file);
|
|
147
157
|
if (!api.config.qiankun.externalQiankun) {
|
|
148
|
-
content = content.replace(
|
|
158
|
+
content = content.replace(
|
|
159
|
+
/from 'qiankun'/g,
|
|
160
|
+
`from '${(0, import_plugin_utils.winPath)((0, import_path.dirname)(require.resolve("qiankun/package")))}'`
|
|
161
|
+
);
|
|
149
162
|
}
|
|
150
163
|
api.writeTmpFile({
|
|
151
164
|
path: file.replace(/\.tpl$/, ""),
|
|
152
|
-
content: content.replace(
|
|
165
|
+
content: content.replace(
|
|
166
|
+
"__USE_MODEL__",
|
|
167
|
+
api.isPluginEnable("model") ? `import { useModel } from '@@/plugin-model'` : `const useModel = null;`
|
|
168
|
+
).replace(
|
|
169
|
+
/from 'lodash\//g,
|
|
170
|
+
`from '${(0, import_plugin_utils.winPath)((0, import_path.dirname)(require.resolve("lodash/package")))}/`
|
|
171
|
+
)
|
|
153
172
|
});
|
|
154
173
|
}
|
|
155
174
|
});
|
package/dist/qiankun/slave.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/qiankun/slave.ts
|
|
@@ -42,29 +45,34 @@ function getCurrentLocalDevServerEntry(api, req) {
|
|
|
42
45
|
}
|
|
43
46
|
function handleOriginalHtml(api, microAppEntry, originalHtml) {
|
|
44
47
|
const appName = api.pkg.name;
|
|
45
|
-
(0, import_assert.default)(
|
|
48
|
+
(0, import_assert.default)(
|
|
49
|
+
appName,
|
|
50
|
+
"[@umijs/plugin-qiankun]: You should have name in package.json"
|
|
51
|
+
);
|
|
46
52
|
const $ = import_utils.cheerio.load(originalHtml);
|
|
47
|
-
$("head").prepend(
|
|
53
|
+
$("head").prepend(
|
|
54
|
+
`<script>window.__QIANKUN_DEVELOPMENT__=true<\/script>
|
|
48
55
|
<script type="extra-qiankun-config">${JSON.stringify({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
master: {
|
|
57
|
+
apps: [
|
|
58
|
+
{
|
|
59
|
+
name: appName,
|
|
60
|
+
entry: microAppEntry,
|
|
61
|
+
extraSource: microAppEntry
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
routes: [
|
|
65
|
+
{
|
|
66
|
+
microApp: appName,
|
|
67
|
+
name: appName,
|
|
68
|
+
path: "/" + appName,
|
|
69
|
+
extraSource: microAppEntry
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
prefetch: false
|
|
73
|
+
}
|
|
74
|
+
})}<\/script>`
|
|
75
|
+
);
|
|
68
76
|
return api.applyPlugins({
|
|
69
77
|
key: "modifyMasterHTML",
|
|
70
78
|
type: api.ApplyPluginsType.modify,
|
|
@@ -160,7 +168,9 @@ export interface IRuntimeConfig {
|
|
|
160
168
|
api.chainWebpack((config) => {
|
|
161
169
|
(0, import_assert.default)(api.pkg.name, "You should have name in package.json.");
|
|
162
170
|
const { shouldNotAddLibraryChunkName } = (api.config.qiankun || {}).slave;
|
|
163
|
-
config.output.libraryTarget("umd").library(
|
|
171
|
+
config.output.libraryTarget("umd").library(
|
|
172
|
+
shouldNotAddLibraryChunkName ? api.pkg.name : `${api.pkg.name}-[name]`
|
|
173
|
+
);
|
|
164
174
|
return config;
|
|
165
175
|
});
|
|
166
176
|
api.modifyHTML(($) => {
|
|
@@ -193,25 +203,40 @@ if (!window.__POWERED_BY_QIANKUN__) {
|
|
|
193
203
|
`
|
|
194
204
|
]);
|
|
195
205
|
function getFileContent(file) {
|
|
196
|
-
return (0, import_fs.readFileSync)(
|
|
206
|
+
return (0, import_fs.readFileSync)(
|
|
207
|
+
(0, import_path.join)(__dirname, "../../libs/qiankun/slave", file),
|
|
208
|
+
"utf-8"
|
|
209
|
+
);
|
|
197
210
|
}
|
|
198
211
|
api.onGenerateFiles({
|
|
199
212
|
fn() {
|
|
200
213
|
[
|
|
214
|
+
"constants.ts",
|
|
201
215
|
"qiankunModel.ts",
|
|
202
216
|
"connectMaster.tsx",
|
|
217
|
+
"MicroAppLink.tsx",
|
|
203
218
|
"slaveRuntimePlugin.ts",
|
|
204
219
|
"lifecycles.ts"
|
|
205
220
|
].forEach((file) => {
|
|
206
221
|
api.writeTmpFile({
|
|
207
222
|
path: file.replace(/\.tpl$/, ""),
|
|
208
|
-
content: getFileContent(file).replace(
|
|
223
|
+
content: getFileContent(file).replace(
|
|
224
|
+
"__USE_MODEL__",
|
|
225
|
+
api.isPluginEnable("model") ? `import { useModel } from '@@/plugin-model'` : `const useModel = null;`
|
|
226
|
+
).replace(
|
|
227
|
+
/from 'qiankun'/g,
|
|
228
|
+
`from '${(0, import_plugin_utils.winPath)((0, import_path.dirname)(require.resolve("qiankun/package")))}'`
|
|
229
|
+
).replace(
|
|
230
|
+
/from 'lodash\//g,
|
|
231
|
+
`from '${(0, import_plugin_utils.winPath)((0, import_path.dirname)(require.resolve("lodash/package")))}/`
|
|
232
|
+
)
|
|
209
233
|
});
|
|
210
234
|
});
|
|
211
235
|
api.writeTmpFile({
|
|
212
236
|
path: "index.ts",
|
|
213
237
|
content: `
|
|
214
238
|
export { connectMaster } from './connectMaster';
|
|
239
|
+
export { MicroAppLink } from './MicroAppLink';
|
|
215
240
|
`
|
|
216
241
|
});
|
|
217
242
|
},
|
|
@@ -232,45 +257,59 @@ export { connectMaster } from './connectMaster';
|
|
|
232
257
|
key: "onLocalProxyStart",
|
|
233
258
|
type: api.ApplyPluginsType.event
|
|
234
259
|
});
|
|
235
|
-
return (0, import_http_proxy_middleware.createProxyMiddleware)(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
260
|
+
return (0, import_http_proxy_middleware.createProxyMiddleware)(
|
|
261
|
+
(pathname) => pathname !== "/local-dev-server",
|
|
262
|
+
{
|
|
263
|
+
target: masterEntry,
|
|
264
|
+
secure: false,
|
|
265
|
+
ignorePath: false,
|
|
266
|
+
followRedirects: false,
|
|
267
|
+
changeOrigin: true,
|
|
268
|
+
selfHandleResponse: true,
|
|
269
|
+
onProxyReq(proxyReq) {
|
|
270
|
+
api.applyPlugins({
|
|
271
|
+
key: "onLocalProxyReq",
|
|
272
|
+
type: api.ApplyPluginsType.event,
|
|
273
|
+
sync: true,
|
|
274
|
+
args: proxyReq
|
|
275
|
+
});
|
|
276
|
+
},
|
|
277
|
+
onProxyRes: (0, import_http_proxy_middleware.responseInterceptor)(
|
|
278
|
+
async (responseBuffer, proxyRes, req2, res2) => {
|
|
279
|
+
var _a2;
|
|
280
|
+
if (proxyRes.statusCode === 302) {
|
|
281
|
+
const hostname = req2.hostname;
|
|
282
|
+
const port = process.env.PORT || ((_a2 = api.appData) == null ? void 0 : _a2.port);
|
|
283
|
+
const goto = `${hostname}:${port}`;
|
|
284
|
+
const redirectUrl = proxyRes.headers.location.replace(
|
|
285
|
+
encodeURIComponent(new URL(masterEntry).hostname),
|
|
286
|
+
encodeURIComponent(goto)
|
|
287
|
+
) || masterEntry;
|
|
288
|
+
const redirectMessage = `[@umijs/plugin-qiankun]: redirect to ${redirectUrl}`;
|
|
289
|
+
api.logger.info(redirectMessage);
|
|
290
|
+
res2.statusCode = 302;
|
|
291
|
+
res2.setHeader("location", redirectUrl);
|
|
292
|
+
return redirectMessage;
|
|
293
|
+
}
|
|
294
|
+
const microAppEntry = getCurrentLocalDevServerEntry(api, req2);
|
|
295
|
+
const originalHtml = responseBuffer.toString("utf8");
|
|
296
|
+
const html = handleOriginalHtml(
|
|
297
|
+
api,
|
|
298
|
+
microAppEntry,
|
|
299
|
+
originalHtml
|
|
300
|
+
);
|
|
301
|
+
return html;
|
|
302
|
+
}
|
|
303
|
+
),
|
|
304
|
+
onError(err, _, res2) {
|
|
305
|
+
api.logger.error(err);
|
|
306
|
+
res2.set("content-type", "text/plain; charset=UTF-8");
|
|
307
|
+
res2.end(
|
|
308
|
+
`[@umijs/plugin-qiankun] 代理到 ${masterEntry} 时出错了,请尝试 ${masterEntry} 是否是可以正常访问的,然后重新启动项目试试。(注意如果出现跨域问题,请修改本地 host ,通过一个和主应用相同的一级域名的域名来访问 127.0.0.1)`
|
|
309
|
+
);
|
|
262
310
|
}
|
|
263
|
-
const microAppEntry = getCurrentLocalDevServerEntry(api, req2);
|
|
264
|
-
const originalHtml = responseBuffer.toString("utf8");
|
|
265
|
-
const html = handleOriginalHtml(api, microAppEntry, originalHtml);
|
|
266
|
-
return html;
|
|
267
|
-
}),
|
|
268
|
-
onError(err, _, res2) {
|
|
269
|
-
api.logger.error(err);
|
|
270
|
-
res2.set("content-type", "text/plain; charset=UTF-8");
|
|
271
|
-
res2.end(`[@umijs/plugin-qiankun] \u4EE3\u7406\u5230 ${masterEntry} \u65F6\u51FA\u9519\u4E86\uFF0C\u8BF7\u5C1D\u8BD5 ${masterEntry} \u662F\u5426\u662F\u53EF\u4EE5\u6B63\u5E38\u8BBF\u95EE\u7684\uFF0C\u7136\u540E\u91CD\u65B0\u542F\u52A8\u9879\u76EE\u8BD5\u8BD5\u3002(\u6CE8\u610F\u5982\u679C\u51FA\u73B0\u8DE8\u57DF\u95EE\u9898\uFF0C\u8BF7\u4FEE\u6539\u672C\u5730 host \uFF0C\u901A\u8FC7\u4E00\u4E2A\u548C\u4E3B\u5E94\u7528\u76F8\u540C\u7684\u4E00\u7EA7\u57DF\u540D\u7684\u57DF\u540D\u6765\u8BBF\u95EE 127.0.0.1)`);
|
|
272
311
|
}
|
|
273
|
-
|
|
312
|
+
)(req, res, next);
|
|
274
313
|
}
|
|
275
314
|
return next();
|
|
276
315
|
};
|
package/dist/qiankun.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/qiankun.ts
|
|
@@ -29,11 +32,14 @@ var qiankun_default = (api) => {
|
|
|
29
32
|
api.describe({
|
|
30
33
|
config: {
|
|
31
34
|
schema(Joi) {
|
|
32
|
-
return Joi.alternatives().try(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
return Joi.alternatives().try(
|
|
36
|
+
Joi.object().keys({
|
|
37
|
+
slave: Joi.object(),
|
|
38
|
+
master: Joi.object(),
|
|
39
|
+
externalQiankun: Joi.boolean()
|
|
40
|
+
}),
|
|
41
|
+
Joi.boolean().invalid(true)
|
|
42
|
+
);
|
|
37
43
|
}
|
|
38
44
|
}
|
|
39
45
|
});
|
|
File without changes
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
|
|
25
|
+
// src/react-query.ts
|
|
26
|
+
var react_query_exports = {};
|
|
27
|
+
__export(react_query_exports, {
|
|
28
|
+
default: () => react_query_default
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(react_query_exports);
|
|
31
|
+
var import_path = require("path");
|
|
32
|
+
var import_resolveProjectDep = require("./utils/resolveProjectDep");
|
|
33
|
+
var import_withTmpPath = require("./utils/withTmpPath");
|
|
34
|
+
var react_query_default = (api) => {
|
|
35
|
+
api.describe({
|
|
36
|
+
key: "reactQuery",
|
|
37
|
+
config: {
|
|
38
|
+
schema(Joi) {
|
|
39
|
+
return Joi.object({
|
|
40
|
+
devtool: Joi.alternatives(Joi.object(), Joi.boolean()),
|
|
41
|
+
queryClient: Joi.alternatives(Joi.object(), Joi.boolean())
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
enableBy: api.EnableBy.config
|
|
46
|
+
});
|
|
47
|
+
let pkgPath;
|
|
48
|
+
const defaultPkgPath = (0, import_path.dirname)(
|
|
49
|
+
require.resolve("@tanstack/react-query/package.json")
|
|
50
|
+
);
|
|
51
|
+
const devtoolPkgPath = (0, import_path.dirname)(
|
|
52
|
+
require.resolve("@tanstack/react-query-devtools/package.json")
|
|
53
|
+
);
|
|
54
|
+
try {
|
|
55
|
+
pkgPath = (0, import_resolveProjectDep.resolveProjectDep)({
|
|
56
|
+
pkg: api.pkg,
|
|
57
|
+
cwd: api.cwd,
|
|
58
|
+
dep: "@tanstack/react-query"
|
|
59
|
+
}) || defaultPkgPath;
|
|
60
|
+
} catch (e) {
|
|
61
|
+
throw new Error(`[reactQuery] package resolve failed, ${e.message}`);
|
|
62
|
+
}
|
|
63
|
+
api.onStart(() => {
|
|
64
|
+
if (pkgPath !== defaultPkgPath) {
|
|
65
|
+
api.logger.info(`[reactQuery] use local package ${pkgPath}`);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
api.addRuntimePlugin(() => {
|
|
69
|
+
return [(0, import_withTmpPath.withTmpPath)({ api, path: "runtime.tsx" })];
|
|
70
|
+
});
|
|
71
|
+
api.addRuntimePluginKey(() => {
|
|
72
|
+
return ["reactQuery"];
|
|
73
|
+
});
|
|
74
|
+
api.onGenerateFiles(() => {
|
|
75
|
+
var _a;
|
|
76
|
+
const enableDevTools = api.config.reactQuery.devtool !== false;
|
|
77
|
+
const enableQueryClient = api.config.reactQuery.queryClient !== false;
|
|
78
|
+
const reactQueryRuntimeCode = ((_a = api.appData.appJS) == null ? void 0 : _a.exports.includes(
|
|
79
|
+
"reactQuery"
|
|
80
|
+
)) ? `import { reactQuery as reactQueryConfig } from '@/app';` : `const reactQueryConfig = {};`;
|
|
81
|
+
api.writeTmpFile({
|
|
82
|
+
path: "runtime.tsx",
|
|
83
|
+
content: enableQueryClient ? `
|
|
84
|
+
import { defaultContext, QueryClient, QueryClientProvider } from '${pkgPath}';
|
|
85
|
+
import { ReactQueryDevtools } from '${devtoolPkgPath}';
|
|
86
|
+
${reactQueryRuntimeCode}
|
|
87
|
+
const client = new QueryClient(reactQueryConfig.queryClient || {});
|
|
88
|
+
export function rootContainer(container) {
|
|
89
|
+
return (
|
|
90
|
+
<QueryClientProvider client={client} context={defaultContext}>
|
|
91
|
+
{container}
|
|
92
|
+
${enableDevTools ? "<ReactQueryDevtools context={defaultContext} initialIsOpen={false} {...(reactQueryConfig.devtool || {})} />" : ""}
|
|
93
|
+
</QueryClientProvider>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
` : ""
|
|
97
|
+
});
|
|
98
|
+
api.writeTmpFile({
|
|
99
|
+
path: "index.tsx",
|
|
100
|
+
content: `
|
|
101
|
+
export {
|
|
102
|
+
// from @tanstack/query-core
|
|
103
|
+
QueryClient,
|
|
104
|
+
MutationObserver,
|
|
105
|
+
MutationCache,
|
|
106
|
+
InfiniteQueryObserver,
|
|
107
|
+
QueriesObserver,
|
|
108
|
+
QueryObserver,
|
|
109
|
+
QueryCache,
|
|
110
|
+
// from @tanstack/react-query
|
|
111
|
+
useIsRestoring,
|
|
112
|
+
IsRestoringProvider,
|
|
113
|
+
useInfiniteQuery,
|
|
114
|
+
useIsMutating,
|
|
115
|
+
useIsFetching,
|
|
116
|
+
useMutation,
|
|
117
|
+
useQueries,
|
|
118
|
+
useQuery,
|
|
119
|
+
QueryClientProvider,
|
|
120
|
+
useQueryClient,
|
|
121
|
+
QueryErrorResetBoundary,
|
|
122
|
+
useQueryErrorResetBoundary,
|
|
123
|
+
} from '${pkgPath}';
|
|
124
|
+
`
|
|
125
|
+
});
|
|
126
|
+
api.writeTmpFile({
|
|
127
|
+
path: "types.d.ts",
|
|
128
|
+
content: `
|
|
129
|
+
export type {
|
|
130
|
+
// from @tanstack/query-core
|
|
131
|
+
Query, QueryState, Mutation,
|
|
132
|
+
// from @tanstack/react-query
|
|
133
|
+
QueriesResults,
|
|
134
|
+
QueriesOptions,
|
|
135
|
+
QueryErrorResetBoundaryProps,
|
|
136
|
+
QueryClientProviderProps,
|
|
137
|
+
ContextOptions as QueryContextOptions,
|
|
138
|
+
UseQueryOptions,
|
|
139
|
+
UseBaseQueryOptions,
|
|
140
|
+
UseQueryResult,
|
|
141
|
+
UseBaseQueryResult,
|
|
142
|
+
UseInfiniteQueryOptions,
|
|
143
|
+
UseMutationResult,
|
|
144
|
+
UseMutateFunction,
|
|
145
|
+
UseMutateAsyncFunction,
|
|
146
|
+
UseBaseMutationResult,
|
|
147
|
+
} from '${pkgPath}';
|
|
148
|
+
`
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
153
|
+
0 && (module.exports = {});
|
package/dist/request.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/request.ts
|
|
@@ -33,9 +36,12 @@ var request_default = (api) => {
|
|
|
33
36
|
key: "request",
|
|
34
37
|
config: {
|
|
35
38
|
schema: (Joi) => {
|
|
36
|
-
return Joi.alternatives().try(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
return Joi.alternatives().try(
|
|
40
|
+
Joi.object({
|
|
41
|
+
dataField: Joi.string().pattern(/^[a-zA-Z]*$/).allow("")
|
|
42
|
+
}),
|
|
43
|
+
Joi.boolean().invalid(true)
|
|
44
|
+
);
|
|
39
45
|
}
|
|
40
46
|
},
|
|
41
47
|
enableBy: api.EnableBy.config
|
|
@@ -124,7 +130,7 @@ function useRequest(service: any, options: any = {}) {
|
|
|
124
130
|
});
|
|
125
131
|
}
|
|
126
132
|
|
|
127
|
-
// request
|
|
133
|
+
// request 方法 opts 参数的接口
|
|
128
134
|
interface IRequestOptions extends AxiosRequestConfig {
|
|
129
135
|
skipErrorHandler?: boolean;
|
|
130
136
|
requestInterceptors?: IRequestInterceptorTuple[];
|
|
@@ -143,8 +149,8 @@ interface IRequestOptionsWithoutResponse extends IRequestOptions{
|
|
|
143
149
|
interface IRequest{
|
|
144
150
|
<T = any>(url: string, opts: IRequestOptionsWithResponse): Promise<AxiosResponse<T>>;
|
|
145
151
|
<T = any>(url: string, opts: IRequestOptionsWithoutResponse): Promise<T>;
|
|
146
|
-
<T = any>(url: string, opts: IRequestOptions): Promise<T>; // getResponse
|
|
147
|
-
<T = any>(url: string): Promise<T>; //
|
|
152
|
+
<T = any>(url: string, opts: IRequestOptions): Promise<T>; // getResponse 默认是 false, 因此不提供该参数时,只返回 data
|
|
153
|
+
<T = any>(url: string): Promise<T>; // 不提供 opts 时,默认使用 'GET' method,并且默认返回 data
|
|
148
154
|
}
|
|
149
155
|
|
|
150
156
|
type RequestError = AxiosError | Error
|
|
@@ -214,7 +220,7 @@ const getRequestInstance = (): AxiosInstance => {
|
|
|
214
220
|
requestInstance.interceptors.response.use(interceptor);
|
|
215
221
|
});
|
|
216
222
|
|
|
217
|
-
//
|
|
223
|
+
// 当响应的数据 success 是 false 的时候,抛出 error 以供 errorHandler 处理。
|
|
218
224
|
requestInstance.interceptors.response.use((response) => {
|
|
219
225
|
const { data } = response;
|
|
220
226
|
if(data?.success === false && config?.errorConfig?.errorThrower){
|
|
@@ -308,7 +314,9 @@ export type {
|
|
|
308
314
|
`;
|
|
309
315
|
api.onGenerateFiles(() => {
|
|
310
316
|
var _a;
|
|
311
|
-
const umiRequestPath = (0, import_plugin_utils.winPath)(
|
|
317
|
+
const umiRequestPath = (0, import_plugin_utils.winPath)(
|
|
318
|
+
(0, import_path.dirname)(require.resolve("@ahooksjs/use-request/package.json"))
|
|
319
|
+
);
|
|
312
320
|
const axiosPath = (0, import_plugin_utils.winPath)((0, import_path.dirname)(require.resolve("axios/package.json")));
|
|
313
321
|
let dataField = (_a = api.config.request) == null ? void 0 : _a.dataField;
|
|
314
322
|
if (dataField === void 0)
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/styled-components.ts
|
package/dist/tailwindcss.js
CHANGED
|
@@ -29,7 +29,10 @@ var tailwindcss_default = (api) => {
|
|
|
29
29
|
key: "tailwindcss",
|
|
30
30
|
config: {
|
|
31
31
|
schema(Joi) {
|
|
32
|
-
return Joi.alternatives().try(
|
|
32
|
+
return Joi.alternatives().try(
|
|
33
|
+
Joi.object(),
|
|
34
|
+
Joi.boolean().invalid(true)
|
|
35
|
+
);
|
|
33
36
|
}
|
|
34
37
|
},
|
|
35
38
|
enableBy: api.EnableBy.config
|
|
@@ -40,23 +43,30 @@ var tailwindcss_default = (api) => {
|
|
|
40
43
|
const inputPath = (0, import_path.join)(api.cwd, "tailwind.css");
|
|
41
44
|
const generatedPath = (0, import_path.join)(api.paths.absTmpPath, outputPath);
|
|
42
45
|
const binPath = getTailwindBinPath({ cwd: api.cwd });
|
|
43
|
-
const configPath = (0, import_path.join)(
|
|
46
|
+
const configPath = (0, import_path.join)(
|
|
47
|
+
process.env.APP_ROOT || api.cwd,
|
|
48
|
+
"tailwind.config.js"
|
|
49
|
+
);
|
|
44
50
|
if (process.env.IS_UMI_BUILD_WORKER) {
|
|
45
51
|
return;
|
|
46
52
|
}
|
|
47
53
|
return new Promise((resolve) => {
|
|
48
|
-
tailwind = (0, import_plugin_utils.crossSpawn)(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
tailwind = (0, import_plugin_utils.crossSpawn)(
|
|
55
|
+
`${binPath}`,
|
|
56
|
+
[
|
|
57
|
+
"-c",
|
|
58
|
+
configPath,
|
|
59
|
+
"-i",
|
|
60
|
+
inputPath,
|
|
61
|
+
"-o",
|
|
62
|
+
generatedPath,
|
|
63
|
+
api.env === "development" ? "--watch" : ""
|
|
64
|
+
],
|
|
65
|
+
{
|
|
66
|
+
stdio: "inherit",
|
|
67
|
+
cwd: process.env.APP_ROOT || api.cwd
|
|
68
|
+
}
|
|
69
|
+
);
|
|
60
70
|
tailwind.on("error", (m) => {
|
|
61
71
|
api.logger.error("tailwindcss service encounter an error: " + m);
|
|
62
72
|
});
|