@umijs/plugins 4.0.7 → 4.0.10
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 +69 -53
- package/dist/analytics.js +62 -41
- package/dist/antd.js +139 -123
- package/dist/dva.js +155 -141
- package/dist/icons.js +28 -4
- package/dist/initial-state.js +80 -54
- package/dist/layout.js +219 -215
- package/dist/locale.js +214 -192
- package/dist/mf.d.ts +2 -0
- package/dist/mf.js +197 -0
- package/dist/model.js +79 -78
- package/dist/moment2dayjs.js +102 -81
- package/dist/qiankun/constants.js +41 -8
- package/dist/qiankun/master.js +163 -121
- package/dist/qiankun/slave.js +183 -148
- package/dist/qiankun.js +46 -19
- package/dist/request.js +91 -55
- package/dist/tailwindcss.js +74 -49
- package/dist/unocss.js +57 -37
- package/dist/utils/astUtils.js +38 -34
- package/dist/utils/localeUtils.js +125 -120
- package/dist/utils/modelUtils.js +216 -237
- package/dist/utils/resolveProjectDep.js +36 -13
- package/dist/utils/withTmpPath.js +31 -9
- package/libs/locale/localeExports.tpl +7 -3
- package/libs/qiankun/master/MicroApp.tsx +17 -12
- package/libs/qiankun/master/types.ts +1 -1
- package/libs/qiankun/slave/lifecycles.ts +15 -7
- package/package.json +6 -6
package/dist/qiankun.js
CHANGED
|
@@ -1,20 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
externalQiankun: joi.boolean(),
|
|
11
|
-
});
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
api.addRuntimePluginKey(() => ['qiankun']);
|
|
16
|
-
api.registerPlugins([
|
|
17
|
-
require.resolve('./qiankun/master'),
|
|
18
|
-
require.resolve('./qiankun/slave'),
|
|
19
|
-
]);
|
|
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 });
|
|
20
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/qiankun.ts
|
|
23
|
+
var qiankun_exports = {};
|
|
24
|
+
__export(qiankun_exports, {
|
|
25
|
+
default: () => qiankun_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(qiankun_exports);
|
|
28
|
+
var qiankun_default = (api) => {
|
|
29
|
+
api.describe({
|
|
30
|
+
config: {
|
|
31
|
+
schema(Joi) {
|
|
32
|
+
return Joi.alternatives().try(Joi.object().keys({
|
|
33
|
+
slave: Joi.object(),
|
|
34
|
+
master: Joi.object(),
|
|
35
|
+
externalQiankun: Joi.boolean()
|
|
36
|
+
}), Joi.boolean().invalid(true));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
api.addRuntimePluginKey(() => ["qiankun"]);
|
|
41
|
+
api.registerPlugins([
|
|
42
|
+
require.resolve("./qiankun/master"),
|
|
43
|
+
require.resolve("./qiankun/slave")
|
|
44
|
+
]);
|
|
45
|
+
};
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {});
|
package/dist/request.js
CHANGED
|
@@ -1,24 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/request.ts
|
|
23
|
+
var request_exports = {};
|
|
24
|
+
__export(request_exports, {
|
|
25
|
+
default: () => request_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(request_exports);
|
|
28
|
+
var import_path = require("path");
|
|
29
|
+
var import_umi = require("umi");
|
|
30
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
31
|
+
var request_default = (api) => {
|
|
32
|
+
api.describe({
|
|
33
|
+
key: "request",
|
|
34
|
+
config: {
|
|
35
|
+
schema: (Joi) => {
|
|
36
|
+
return Joi.alternatives().try(Joi.object({
|
|
37
|
+
dataField: Joi.string().pattern(/^[a-zA-Z]*$/).allow("")
|
|
38
|
+
}), Joi.boolean().invalid(true));
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
enableBy: api.EnableBy.config
|
|
42
|
+
});
|
|
43
|
+
api.addRuntimePluginKey(() => ["request"]);
|
|
44
|
+
const requestTpl = `
|
|
22
45
|
import axios, {
|
|
23
46
|
type AxiosInstance,
|
|
24
47
|
type AxiosRequestConfig,
|
|
@@ -101,7 +124,7 @@ function useRequest(service: any, options: any = {}) {
|
|
|
101
124
|
});
|
|
102
125
|
}
|
|
103
126
|
|
|
104
|
-
// request
|
|
127
|
+
// request \u65B9\u6CD5 opts \u53C2\u6570\u7684\u63A5\u53E3
|
|
105
128
|
interface IRequestOptions extends AxiosRequestConfig {
|
|
106
129
|
skipErrorHandler?: boolean;
|
|
107
130
|
requestInterceptors?: IRequestInterceptorTuple[];
|
|
@@ -120,8 +143,8 @@ interface IRequestOptionsWithoutResponse extends IRequestOptions{
|
|
|
120
143
|
interface IRequest{
|
|
121
144
|
<T = any>(url: string, opts: IRequestOptionsWithResponse): Promise<AxiosResponse<T>>;
|
|
122
145
|
<T = any>(url: string, opts: IRequestOptionsWithoutResponse): Promise<T>;
|
|
123
|
-
<T = any>(url: string, opts: IRequestOptions): Promise<T>; // getResponse
|
|
124
|
-
<T = any>(url: string): Promise<T>; //
|
|
146
|
+
<T = any>(url: string, opts: IRequestOptions): Promise<T>; // getResponse \u9ED8\u8BA4\u662F false\uFF0C \u56E0\u6B64\u4E0D\u63D0\u4F9B\u8BE5\u53C2\u6570\u65F6\uFF0C\u53EA\u8FD4\u56DE data
|
|
147
|
+
<T = any>(url: string): Promise<T>; // \u4E0D\u63D0\u4F9B opts \u65F6\uFF0C\u9ED8\u8BA4\u4F7F\u7528 'GET' method\uFF0C\u5E76\u4E14\u9ED8\u8BA4\u8FD4\u56DE data
|
|
125
148
|
}
|
|
126
149
|
|
|
127
150
|
type RequestError = AxiosError | Error
|
|
@@ -131,7 +154,7 @@ interface IErrorHandler {
|
|
|
131
154
|
}
|
|
132
155
|
type IRequestInterceptorAxios = (config: RequestOptions) => RequestOptions;
|
|
133
156
|
type IRequestInterceptorUmiRequest = (url: string, config : RequestOptions) => { url: string, options: RequestOptions };
|
|
134
|
-
type IRequestInterceptor = IRequestInterceptorAxios;
|
|
157
|
+
type IRequestInterceptor = IRequestInterceptorAxios | IRequestInterceptorUmiRequest;
|
|
135
158
|
type IErrorInterceptor = (error: Error) => Promise<Error>;
|
|
136
159
|
type IResponseInterceptor = <T = any>(response : AxiosResponse<T>) => AxiosResponse<T> ;
|
|
137
160
|
type IRequestInterceptorTuple = [IRequestInterceptor , IErrorInterceptor] | [ IRequestInterceptor ] | IRequestInterceptor
|
|
@@ -191,7 +214,7 @@ const getRequestInstance = (): AxiosInstance => {
|
|
|
191
214
|
requestInstance.interceptors.response.use(interceptor);
|
|
192
215
|
});
|
|
193
216
|
|
|
194
|
-
//
|
|
217
|
+
// \u5F53\u54CD\u5E94\u7684\u6570\u636E success \u662F false \u7684\u65F6\u5019\uFF0C\u629B\u51FA error \u4EE5\u4F9B errorHandler \u5904\u7406\u3002
|
|
195
218
|
requestInstance.interceptors.response.use((response) => {
|
|
196
219
|
const { data } = response;
|
|
197
220
|
if(data?.success === false && config?.errorConfig?.errorThrower){
|
|
@@ -275,50 +298,63 @@ export type {
|
|
|
275
298
|
AxiosInstance,
|
|
276
299
|
AxiosRequestConfig,
|
|
277
300
|
AxiosResponse,
|
|
301
|
+
AxiosError,
|
|
302
|
+
RequestError,
|
|
278
303
|
IResponseInterceptor as ResponseInterceptor,
|
|
279
304
|
IRequestOptions as RequestOptions,
|
|
280
305
|
IRequest as Request,
|
|
281
306
|
};
|
|
282
307
|
|
|
283
308
|
`;
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
export type {
|
|
304
|
-
RequestConfig,
|
|
309
|
+
api.onGenerateFiles(() => {
|
|
310
|
+
var _a;
|
|
311
|
+
const umiRequestPath = (0, import_plugin_utils.winPath)((0, import_path.dirname)(require.resolve("@ahooksjs/use-request/package.json")));
|
|
312
|
+
const axiosPath = (0, import_plugin_utils.winPath)((0, import_path.dirname)(require.resolve("axios/package.json")));
|
|
313
|
+
let dataField = (_a = api.config.request) == null ? void 0 : _a.dataField;
|
|
314
|
+
if (dataField === void 0)
|
|
315
|
+
dataField = "data";
|
|
316
|
+
const formatResult = dataField === "" ? `result => result` : `result => result?.${dataField}`;
|
|
317
|
+
api.writeTmpFile({
|
|
318
|
+
path: "request.ts",
|
|
319
|
+
content: import_plugin_utils.Mustache.render(requestTpl, {
|
|
320
|
+
umiRequestPath,
|
|
321
|
+
axiosPath,
|
|
322
|
+
formatResult
|
|
323
|
+
})
|
|
324
|
+
});
|
|
325
|
+
api.writeTmpFile({
|
|
326
|
+
path: "types.d.ts",
|
|
327
|
+
content: `
|
|
328
|
+
export type {
|
|
329
|
+
RequestConfig,
|
|
305
330
|
AxiosInstance,
|
|
306
331
|
AxiosRequestConfig,
|
|
307
|
-
AxiosResponse,
|
|
332
|
+
AxiosResponse,
|
|
308
333
|
AxiosError,
|
|
309
334
|
RequestError,
|
|
310
335
|
ResponseInterceptor } from './request';
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
336
|
+
`
|
|
337
|
+
});
|
|
338
|
+
api.writeTmpFile({
|
|
339
|
+
path: "index.ts",
|
|
340
|
+
content: `
|
|
316
341
|
export {
|
|
317
342
|
useRequest,
|
|
318
343
|
UseRequestProvider,
|
|
319
344
|
request,
|
|
320
345
|
} from './request';
|
|
321
|
-
|
|
322
|
-
});
|
|
346
|
+
`
|
|
323
347
|
});
|
|
348
|
+
api.writeTmpFile({
|
|
349
|
+
path: import_umi.RUNTIME_TYPE_FILE_NAME,
|
|
350
|
+
content: `
|
|
351
|
+
import type { RequestConfig } from './types.d'
|
|
352
|
+
export type IRuntimeConfig = {
|
|
353
|
+
request?: RequestConfig
|
|
354
|
+
};
|
|
355
|
+
`
|
|
356
|
+
});
|
|
357
|
+
});
|
|
324
358
|
};
|
|
359
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
360
|
+
0 && (module.exports = {});
|
package/dist/tailwindcss.js
CHANGED
|
@@ -1,52 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/tailwindcss.ts
|
|
20
|
+
var tailwindcss_exports = {};
|
|
21
|
+
__export(tailwindcss_exports, {
|
|
22
|
+
default: () => tailwindcss_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(tailwindcss_exports);
|
|
25
|
+
var import_path = require("path");
|
|
26
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
27
|
+
var tailwindcss_default = (api) => {
|
|
28
|
+
api.describe({
|
|
29
|
+
key: "tailwindcss",
|
|
30
|
+
config: {
|
|
31
|
+
schema(Joi) {
|
|
32
|
+
return Joi.alternatives().try(Joi.object(), Joi.boolean().invalid(true));
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
enableBy: api.EnableBy.config
|
|
36
|
+
});
|
|
37
|
+
let tailwind = null;
|
|
38
|
+
const outputPath = "plugin-tailwindcss/tailwind.css";
|
|
39
|
+
api.onBeforeCompiler(() => {
|
|
40
|
+
const inputPath = (0, import_path.join)(api.cwd, "tailwind.css");
|
|
41
|
+
const generatedPath = (0, import_path.join)(api.paths.absTmpPath, outputPath);
|
|
42
|
+
const binPath = (0, import_path.join)(api.cwd, "node_modules/.bin/tailwind");
|
|
43
|
+
const configPath = (0, import_path.join)(process.env.APP_ROOT || api.cwd, "tailwind.config.js");
|
|
44
|
+
return new Promise((resolve) => {
|
|
45
|
+
tailwind = (0, import_plugin_utils.crossSpawn)(`${binPath}`, [
|
|
46
|
+
"-c",
|
|
47
|
+
configPath,
|
|
48
|
+
"-i",
|
|
49
|
+
inputPath,
|
|
50
|
+
"-o",
|
|
51
|
+
generatedPath,
|
|
52
|
+
api.env === "development" ? "--watch" : ""
|
|
53
|
+
], {
|
|
54
|
+
stdio: "inherit",
|
|
55
|
+
cwd: process.env.APP_ROOT || api.cwd
|
|
56
|
+
});
|
|
57
|
+
tailwind.on("error", (m) => {
|
|
58
|
+
api.logger.error("tailwindcss service encounter an error: " + m);
|
|
59
|
+
});
|
|
60
|
+
if (api.env === "production") {
|
|
61
|
+
tailwind.on("exit", () => {
|
|
62
|
+
api.logger.info("tailwindcss service exited");
|
|
63
|
+
resolve();
|
|
45
64
|
});
|
|
65
|
+
} else {
|
|
66
|
+
api.logger.info("tailwindcss service started");
|
|
67
|
+
resolve();
|
|
68
|
+
}
|
|
46
69
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
70
|
+
});
|
|
71
|
+
api.addEntryImports(() => {
|
|
72
|
+
const generatedPath = (0, import_plugin_utils.winPath)((0, import_path.join)(api.paths.absTmpPath, outputPath));
|
|
73
|
+
return [{ source: generatedPath }];
|
|
74
|
+
});
|
|
52
75
|
};
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {});
|
package/dist/unocss.js
CHANGED
|
@@ -1,39 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/unocss.ts
|
|
20
|
+
var unocss_exports = {};
|
|
21
|
+
__export(unocss_exports, {
|
|
22
|
+
default: () => unocss_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(unocss_exports);
|
|
25
|
+
var import_child_process = require("child_process");
|
|
26
|
+
var import_fs = require("fs");
|
|
27
|
+
var import_path = require("path");
|
|
28
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
29
|
+
var unocss_default = (api) => {
|
|
30
|
+
api.describe({
|
|
31
|
+
key: "unocss",
|
|
32
|
+
config: {
|
|
33
|
+
schema(Joi) {
|
|
34
|
+
return Joi.alternatives().try(Joi.object({
|
|
35
|
+
watch: Joi.array()
|
|
36
|
+
}), Joi.boolean().invalid(true));
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
enableBy: api.EnableBy.config
|
|
40
|
+
});
|
|
41
|
+
const outputPath = "uno.css";
|
|
42
|
+
api.onBeforeCompiler(() => {
|
|
43
|
+
if (!(0, import_fs.existsSync)((0, import_path.join)(api.paths.cwd, "unocss.config.ts")))
|
|
44
|
+
api.logger.warn("\u8BF7\u5728\u9879\u76EE\u76EE\u5F55\u4E2D\u6DFB\u52A0 unocss.config.ts \u6587\u4EF6\uFF0C\u5E76\u914D\u7F6E\u9700\u8981\u7684 unocss presets\uFF0C\u5426\u5219\u63D2\u4EF6\u5C06\u6CA1\u6709\u6548\u679C\uFF01");
|
|
45
|
+
const generatedPath = (0, import_path.join)(api.paths.absTmpPath, outputPath);
|
|
46
|
+
const binPath = (0, import_path.join)(api.cwd, "node_modules/.bin/unocss");
|
|
47
|
+
const watchDirs = api.config.unocss.watch;
|
|
48
|
+
const unocss = (0, import_child_process.exec)(`${binPath} ${watchDirs.join(" ")} --out-file ${generatedPath} ${api.env === "development" ? "--watch" : ""}`, { cwd: api.cwd });
|
|
49
|
+
unocss.on("error", (m) => {
|
|
50
|
+
api.logger.error("unocss service encounter an error: " + m);
|
|
38
51
|
});
|
|
52
|
+
});
|
|
53
|
+
api.addEntryImports(() => {
|
|
54
|
+
const generatedPath = (0, import_plugin_utils.winPath)((0, import_path.join)(api.paths.absTmpPath, outputPath));
|
|
55
|
+
return [{ source: generatedPath }];
|
|
56
|
+
});
|
|
39
57
|
};
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {});
|
package/dist/utils/astUtils.js
CHANGED
|
@@ -1,38 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
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;
|
|
24
18
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/utils/astUtils.ts
|
|
23
|
+
var astUtils_exports = {};
|
|
24
|
+
__export(astUtils_exports, {
|
|
25
|
+
getIdentifierDeclaration: () => getIdentifierDeclaration
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(astUtils_exports);
|
|
28
|
+
var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
|
|
28
29
|
function getIdentifierDeclaration(node, path) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
return bindingNode;
|
|
30
|
+
if (t.isIdentifier(node) && path.scope.hasBinding(node.name)) {
|
|
31
|
+
let bindingNode = path.scope.getBinding(node.name).path.node;
|
|
32
|
+
if (t.isVariableDeclarator(bindingNode)) {
|
|
33
|
+
bindingNode = bindingNode.init;
|
|
35
34
|
}
|
|
36
|
-
return
|
|
35
|
+
return bindingNode;
|
|
36
|
+
}
|
|
37
|
+
return node;
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
getIdentifierDeclaration
|
|
42
|
+
});
|