@umijs/plugins 4.0.0-canary.20220718.2 → 4.0.0-canary.20220729.1
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.d.ts +0 -1
- package/dist/access.js +69 -53
- package/dist/analytics.d.ts +0 -1
- package/dist/analytics.js +62 -41
- package/dist/antd.d.ts +0 -1
- package/dist/antd.js +139 -123
- package/dist/dva.d.ts +0 -1
- package/dist/dva.js +133 -142
- package/dist/icons.d.ts +0 -1
- package/dist/icons.js +28 -4
- package/dist/initial-state.d.ts +0 -1
- package/dist/initial-state.js +71 -54
- package/dist/layout.d.ts +0 -1
- package/dist/layout.js +205 -214
- package/dist/locale.d.ts +0 -1
- package/dist/locale.js +214 -192
- package/dist/mf.d.ts +2 -0
- package/dist/mf.js +197 -0
- package/dist/model.d.ts +0 -1
- package/dist/model.js +79 -78
- package/dist/moment2dayjs.d.ts +0 -1
- package/dist/moment2dayjs.js +102 -81
- package/dist/qiankun/constants.d.ts +0 -1
- package/dist/qiankun/constants.js +41 -8
- package/dist/qiankun/master.d.ts +0 -1
- package/dist/qiankun/master.js +147 -121
- package/dist/qiankun/slave.d.ts +0 -1
- package/dist/qiankun/slave.js +160 -150
- package/dist/qiankun.d.ts +0 -1
- package/dist/qiankun.js +46 -19
- package/dist/request.d.ts +0 -1
- package/dist/request.js +79 -55
- package/dist/tailwindcss.d.ts +0 -1
- package/dist/tailwindcss.js +70 -49
- package/dist/unocss.d.ts +0 -1
- package/dist/unocss.js +57 -37
- package/dist/utils/astUtils.d.ts +0 -1
- package/dist/utils/astUtils.js +38 -34
- package/dist/utils/localeUtils.d.ts +0 -1
- package/dist/utils/localeUtils.js +125 -120
- package/dist/utils/modelUtils.d.ts +0 -1
- package/dist/utils/modelUtils.js +216 -237
- package/dist/utils/resolveProjectDep.d.ts +0 -1
- package/dist/utils/resolveProjectDep.js +36 -13
- package/dist/utils/withTmpPath.d.ts +0 -1
- package/dist/utils/withTmpPath.js +31 -9
- package/libs/locale/localeExports.tpl +7 -3
- package/libs/qiankun/master/MicroApp.tsx +8 -2
- package/libs/qiankun/slave/lifecycles.ts +15 -7
- package/package.json +6 -6
- package/dist/access.d.ts.map +0 -1
- package/dist/analytics.d.ts.map +0 -1
- package/dist/antd.d.ts.map +0 -1
- package/dist/dva.d.ts.map +0 -1
- package/dist/icons.d.ts.map +0 -1
- package/dist/initial-state.d.ts.map +0 -1
- package/dist/layout.d.ts.map +0 -1
- package/dist/locale.d.ts.map +0 -1
- package/dist/model.d.ts.map +0 -1
- package/dist/moment2dayjs.d.ts.map +0 -1
- package/dist/qiankun/constants.d.ts.map +0 -1
- package/dist/qiankun/master.d.ts.map +0 -1
- package/dist/qiankun/slave.d.ts.map +0 -1
- package/dist/qiankun.d.ts.map +0 -1
- package/dist/request.d.ts.map +0 -1
- package/dist/tailwindcss.d.ts.map +0 -1
- package/dist/unocss.d.ts.map +0 -1
- package/dist/utils/astUtils.d.ts.map +0 -1
- package/dist/utils/localeUtils.d.ts.map +0 -1
- package/dist/utils/modelUtils.d.ts.map +0 -1
- package/dist/utils/resolveProjectDep.d.ts.map +0 -1
- package/dist/utils/withTmpPath.d.ts.map +0 -1
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.d.ts
CHANGED
package/dist/request.js
CHANGED
|
@@ -1,24 +1,46 @@
|
|
|
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_plugin_utils = require("umi/plugin-utils");
|
|
30
|
+
var request_default = (api) => {
|
|
31
|
+
api.describe({
|
|
32
|
+
key: "request",
|
|
33
|
+
config: {
|
|
34
|
+
schema: (Joi) => {
|
|
35
|
+
return Joi.alternatives().try(Joi.object({
|
|
36
|
+
dataField: Joi.string().pattern(/^[a-zA-Z]*$/).allow("")
|
|
37
|
+
}), Joi.boolean().invalid(true));
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
enableBy: api.EnableBy.config
|
|
41
|
+
});
|
|
42
|
+
api.addRuntimePluginKey(() => ["request"]);
|
|
43
|
+
const requestTpl = `
|
|
22
44
|
import axios, {
|
|
23
45
|
type AxiosInstance,
|
|
24
46
|
type AxiosRequestConfig,
|
|
@@ -101,7 +123,7 @@ function useRequest(service: any, options: any = {}) {
|
|
|
101
123
|
});
|
|
102
124
|
}
|
|
103
125
|
|
|
104
|
-
// request
|
|
126
|
+
// request \u65B9\u6CD5 opts \u53C2\u6570\u7684\u63A5\u53E3
|
|
105
127
|
interface IRequestOptions extends AxiosRequestConfig {
|
|
106
128
|
skipErrorHandler?: boolean;
|
|
107
129
|
requestInterceptors?: IRequestInterceptorTuple[];
|
|
@@ -120,8 +142,8 @@ interface IRequestOptionsWithoutResponse extends IRequestOptions{
|
|
|
120
142
|
interface IRequest{
|
|
121
143
|
<T = any>(url: string, opts: IRequestOptionsWithResponse): Promise<AxiosResponse<T>>;
|
|
122
144
|
<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>; //
|
|
145
|
+
<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
|
|
146
|
+
<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
147
|
}
|
|
126
148
|
|
|
127
149
|
type RequestError = AxiosError | Error
|
|
@@ -131,7 +153,7 @@ interface IErrorHandler {
|
|
|
131
153
|
}
|
|
132
154
|
type IRequestInterceptorAxios = (config: RequestOptions) => RequestOptions;
|
|
133
155
|
type IRequestInterceptorUmiRequest = (url: string, config : RequestOptions) => { url: string, options: RequestOptions };
|
|
134
|
-
type IRequestInterceptor = IRequestInterceptorAxios;
|
|
156
|
+
type IRequestInterceptor = IRequestInterceptorAxios | IRequestInterceptorUmiRequest;
|
|
135
157
|
type IErrorInterceptor = (error: Error) => Promise<Error>;
|
|
136
158
|
type IResponseInterceptor = <T = any>(response : AxiosResponse<T>) => AxiosResponse<T> ;
|
|
137
159
|
type IRequestInterceptorTuple = [IRequestInterceptor , IErrorInterceptor] | [ IRequestInterceptor ] | IRequestInterceptor
|
|
@@ -191,7 +213,7 @@ const getRequestInstance = (): AxiosInstance => {
|
|
|
191
213
|
requestInstance.interceptors.response.use(interceptor);
|
|
192
214
|
});
|
|
193
215
|
|
|
194
|
-
//
|
|
216
|
+
// \u5F53\u54CD\u5E94\u7684\u6570\u636E success \u662F false \u7684\u65F6\u5019\uFF0C\u629B\u51FA error \u4EE5\u4F9B errorHandler \u5904\u7406\u3002
|
|
195
217
|
requestInstance.interceptors.response.use((response) => {
|
|
196
218
|
const { data } = response;
|
|
197
219
|
if(data?.success === false && config?.errorConfig?.errorThrower){
|
|
@@ -283,44 +305,46 @@ export type {
|
|
|
283
305
|
};
|
|
284
306
|
|
|
285
307
|
`;
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
export type {
|
|
306
|
-
RequestConfig,
|
|
308
|
+
api.onGenerateFiles(() => {
|
|
309
|
+
var _a;
|
|
310
|
+
const umiRequestPath = (0, import_plugin_utils.winPath)((0, import_path.dirname)(require.resolve("@ahooksjs/use-request/package.json")));
|
|
311
|
+
const axiosPath = (0, import_plugin_utils.winPath)((0, import_path.dirname)(require.resolve("axios/package.json")));
|
|
312
|
+
let dataField = (_a = api.config.request) == null ? void 0 : _a.dataField;
|
|
313
|
+
if (dataField === void 0)
|
|
314
|
+
dataField = "data";
|
|
315
|
+
const formatResult = dataField === "" ? `result => result` : `result => result?.${dataField}`;
|
|
316
|
+
api.writeTmpFile({
|
|
317
|
+
path: "request.ts",
|
|
318
|
+
content: import_plugin_utils.Mustache.render(requestTpl, {
|
|
319
|
+
umiRequestPath,
|
|
320
|
+
axiosPath,
|
|
321
|
+
formatResult
|
|
322
|
+
})
|
|
323
|
+
});
|
|
324
|
+
api.writeTmpFile({
|
|
325
|
+
path: "types.d.ts",
|
|
326
|
+
content: `
|
|
327
|
+
export type {
|
|
328
|
+
RequestConfig,
|
|
307
329
|
AxiosInstance,
|
|
308
330
|
AxiosRequestConfig,
|
|
309
|
-
AxiosResponse,
|
|
331
|
+
AxiosResponse,
|
|
310
332
|
AxiosError,
|
|
311
333
|
RequestError,
|
|
312
334
|
ResponseInterceptor } from './request';
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
335
|
+
`
|
|
336
|
+
});
|
|
337
|
+
api.writeTmpFile({
|
|
338
|
+
path: "index.ts",
|
|
339
|
+
content: `
|
|
318
340
|
export {
|
|
319
341
|
useRequest,
|
|
320
342
|
UseRequestProvider,
|
|
321
343
|
request,
|
|
322
344
|
} from './request';
|
|
323
|
-
|
|
324
|
-
});
|
|
345
|
+
`
|
|
325
346
|
});
|
|
347
|
+
});
|
|
326
348
|
};
|
|
349
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
350
|
+
0 && (module.exports = {});
|
package/dist/tailwindcss.d.ts
CHANGED
package/dist/tailwindcss.js
CHANGED
|
@@ -1,52 +1,73 @@
|
|
|
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
|
+
return new Promise((resolve) => {
|
|
44
|
+
tailwind = (0, import_plugin_utils.crossSpawn)(`${binPath}`, [
|
|
45
|
+
"-i",
|
|
46
|
+
inputPath,
|
|
47
|
+
"-o",
|
|
48
|
+
generatedPath,
|
|
49
|
+
api.env === "development" ? "--watch" : ""
|
|
50
|
+
], {
|
|
51
|
+
stdio: "inherit"
|
|
52
|
+
});
|
|
53
|
+
tailwind.on("error", (m) => {
|
|
54
|
+
api.logger.error("tailwindcss service encounter an error: " + m);
|
|
55
|
+
});
|
|
56
|
+
if (api.env === "production") {
|
|
57
|
+
tailwind.on("exit", () => {
|
|
58
|
+
api.logger.info("tailwindcss service exited");
|
|
59
|
+
resolve();
|
|
45
60
|
});
|
|
61
|
+
} else {
|
|
62
|
+
api.logger.info("tailwindcss service started");
|
|
63
|
+
resolve();
|
|
64
|
+
}
|
|
46
65
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
66
|
+
});
|
|
67
|
+
api.addEntryImports(() => {
|
|
68
|
+
const generatedPath = (0, import_plugin_utils.winPath)((0, import_path.join)(api.paths.absTmpPath, outputPath));
|
|
69
|
+
return [{ source: generatedPath }];
|
|
70
|
+
});
|
|
52
71
|
};
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {});
|
package/dist/unocss.d.ts
CHANGED
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.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import * as Babel from '@umijs/bundler-utils/compiled/babel/core';
|
|
2
2
|
import * as t from '@umijs/bundler-utils/compiled/babel/types';
|
|
3
3
|
export declare function getIdentifierDeclaration(node: t.Node, path: Babel.NodePath): Babel.types.Node;
|
|
4
|
-
//# sourceMappingURL=astUtils.d.ts.map
|
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
|
+
});
|
|
@@ -31,4 +31,3 @@ export interface IGetLocaleFileListResult {
|
|
|
31
31
|
export declare const getLocaleList: (opts: IGetLocaleFileListOpts) => Promise<IGetLocaleFileListResult[]>;
|
|
32
32
|
export declare const exactLocalePaths: (data: IGetLocaleFileListResult[]) => string[];
|
|
33
33
|
export declare function isNeedPolyfill(targets?: {}): boolean;
|
|
34
|
-
//# sourceMappingURL=localeUtils.d.ts.map
|