@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.
Files changed (72) hide show
  1. package/dist/access.d.ts +0 -1
  2. package/dist/access.js +69 -53
  3. package/dist/analytics.d.ts +0 -1
  4. package/dist/analytics.js +62 -41
  5. package/dist/antd.d.ts +0 -1
  6. package/dist/antd.js +139 -123
  7. package/dist/dva.d.ts +0 -1
  8. package/dist/dva.js +133 -142
  9. package/dist/icons.d.ts +0 -1
  10. package/dist/icons.js +28 -4
  11. package/dist/initial-state.d.ts +0 -1
  12. package/dist/initial-state.js +71 -54
  13. package/dist/layout.d.ts +0 -1
  14. package/dist/layout.js +205 -214
  15. package/dist/locale.d.ts +0 -1
  16. package/dist/locale.js +214 -192
  17. package/dist/mf.d.ts +2 -0
  18. package/dist/mf.js +197 -0
  19. package/dist/model.d.ts +0 -1
  20. package/dist/model.js +79 -78
  21. package/dist/moment2dayjs.d.ts +0 -1
  22. package/dist/moment2dayjs.js +102 -81
  23. package/dist/qiankun/constants.d.ts +0 -1
  24. package/dist/qiankun/constants.js +41 -8
  25. package/dist/qiankun/master.d.ts +0 -1
  26. package/dist/qiankun/master.js +147 -121
  27. package/dist/qiankun/slave.d.ts +0 -1
  28. package/dist/qiankun/slave.js +160 -150
  29. package/dist/qiankun.d.ts +0 -1
  30. package/dist/qiankun.js +46 -19
  31. package/dist/request.d.ts +0 -1
  32. package/dist/request.js +79 -55
  33. package/dist/tailwindcss.d.ts +0 -1
  34. package/dist/tailwindcss.js +70 -49
  35. package/dist/unocss.d.ts +0 -1
  36. package/dist/unocss.js +57 -37
  37. package/dist/utils/astUtils.d.ts +0 -1
  38. package/dist/utils/astUtils.js +38 -34
  39. package/dist/utils/localeUtils.d.ts +0 -1
  40. package/dist/utils/localeUtils.js +125 -120
  41. package/dist/utils/modelUtils.d.ts +0 -1
  42. package/dist/utils/modelUtils.js +216 -237
  43. package/dist/utils/resolveProjectDep.d.ts +0 -1
  44. package/dist/utils/resolveProjectDep.js +36 -13
  45. package/dist/utils/withTmpPath.d.ts +0 -1
  46. package/dist/utils/withTmpPath.js +31 -9
  47. package/libs/locale/localeExports.tpl +7 -3
  48. package/libs/qiankun/master/MicroApp.tsx +8 -2
  49. package/libs/qiankun/slave/lifecycles.ts +15 -7
  50. package/package.json +6 -6
  51. package/dist/access.d.ts.map +0 -1
  52. package/dist/analytics.d.ts.map +0 -1
  53. package/dist/antd.d.ts.map +0 -1
  54. package/dist/dva.d.ts.map +0 -1
  55. package/dist/icons.d.ts.map +0 -1
  56. package/dist/initial-state.d.ts.map +0 -1
  57. package/dist/layout.d.ts.map +0 -1
  58. package/dist/locale.d.ts.map +0 -1
  59. package/dist/model.d.ts.map +0 -1
  60. package/dist/moment2dayjs.d.ts.map +0 -1
  61. package/dist/qiankun/constants.d.ts.map +0 -1
  62. package/dist/qiankun/master.d.ts.map +0 -1
  63. package/dist/qiankun/slave.d.ts.map +0 -1
  64. package/dist/qiankun.d.ts.map +0 -1
  65. package/dist/request.d.ts.map +0 -1
  66. package/dist/tailwindcss.d.ts.map +0 -1
  67. package/dist/unocss.d.ts.map +0 -1
  68. package/dist/utils/astUtils.d.ts.map +0 -1
  69. package/dist/utils/localeUtils.d.ts.map +0 -1
  70. package/dist/utils/modelUtils.d.ts.map +0 -1
  71. package/dist/utils/resolveProjectDep.d.ts.map +0 -1
  72. package/dist/utils/withTmpPath.d.ts.map +0 -1
package/dist/qiankun.js CHANGED
@@ -1,20 +1,47 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = (api) => {
4
- api.describe({
5
- config: {
6
- schema(joi) {
7
- return joi.object().keys({
8
- slave: joi.object(),
9
- master: joi.object(),
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
@@ -1,4 +1,3 @@
1
1
  import { IApi } from 'umi';
2
2
  declare const _default: (api: IApi) => void;
3
3
  export default _default;
4
- //# sourceMappingURL=request.d.ts.map
package/dist/request.js CHANGED
@@ -1,24 +1,46 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const path_1 = require("path");
4
- const plugin_utils_1 = require("umi/plugin-utils");
5
- exports.default = (api) => {
6
- api.describe({
7
- key: 'request',
8
- config: {
9
- schema: (joi) => {
10
- return joi.object({
11
- dataField: joi
12
- .string()
13
- .pattern(/^[a-zA-Z]*$/)
14
- .allow(''),
15
- });
16
- },
17
- },
18
- enableBy: api.EnableBy.config,
19
- });
20
- api.addRuntimePluginKey(() => ['request']);
21
- const requestTpl = `
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 方法 opts 参数的接口
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 默认是 false 因此不提供该参数时,只返回 data
124
- <T = any>(url: string): Promise<T>; // 不提供 opts 时,默认使用 'GET' method,并且默认返回 data
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
- // 当响应的数据 success false 的时候,抛出 error 以供 errorHandler 处理。
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
- api.onGenerateFiles(() => {
287
- var _a;
288
- const umiRequestPath = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('@ahooksjs/use-request/package.json')));
289
- const axiosPath = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('axios/package.json')));
290
- let dataField = (_a = api.config.request) === null || _a === void 0 ? void 0 : _a.dataField;
291
- if (dataField === undefined)
292
- dataField = 'data';
293
- const formatResult = dataField === '' ? `result => result` : `result => result?.${dataField}`;
294
- api.writeTmpFile({
295
- path: 'request.ts',
296
- content: plugin_utils_1.Mustache.render(requestTpl, {
297
- umiRequestPath,
298
- axiosPath,
299
- formatResult,
300
- }),
301
- });
302
- api.writeTmpFile({
303
- path: 'types.d.ts',
304
- content: `
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
- api.writeTmpFile({
316
- path: 'index.ts',
317
- content: `
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 = {});
@@ -1,4 +1,3 @@
1
1
  import { IApi } from 'umi';
2
2
  declare const _default: (api: IApi) => void;
3
3
  export default _default;
4
- //# sourceMappingURL=tailwindcss.d.ts.map
@@ -1,52 +1,73 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const path_1 = require("path");
4
- const plugin_utils_1 = require("umi/plugin-utils");
5
- exports.default = (api) => {
6
- api.describe({
7
- key: 'tailwindcss',
8
- config: {
9
- schema(Joi) {
10
- return Joi.object();
11
- },
12
- },
13
- enableBy: api.EnableBy.config,
14
- });
15
- let tailwind = null;
16
- const outputPath = 'plugin-tailwindcss/tailwind.css';
17
- api.onBeforeCompiler(() => {
18
- const inputPath = (0, path_1.join)(api.cwd, 'tailwind.css');
19
- const generatedPath = (0, path_1.join)(api.paths.absTmpPath, outputPath);
20
- const binPath = (0, path_1.join)(api.cwd, 'node_modules/.bin/tailwind');
21
- return new Promise((resolve) => {
22
- /** 透过子进程建立 tailwindcss 服务,将生成的 css 写入 generatedPath */
23
- tailwind = (0, plugin_utils_1.crossSpawn)(`${binPath}`, [
24
- '-i',
25
- inputPath,
26
- '-o',
27
- generatedPath,
28
- api.env === 'development' ? '--watch' : '',
29
- ], {
30
- stdio: 'inherit',
31
- });
32
- tailwind.on('error', (m) => {
33
- api.logger.error('tailwindcss service encounter an error: ' + m);
34
- });
35
- if (api.env === 'production') {
36
- tailwind.on('exit', () => {
37
- api.logger.info('tailwindcss service exited');
38
- resolve();
39
- });
40
- }
41
- else {
42
- api.logger.info('tailwindcss service started');
43
- resolve();
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
- /** 将生成的 css 文件加入到 import 中 */
48
- api.addEntryImports(() => {
49
- const generatedPath = (0, plugin_utils_1.winPath)((0, path_1.join)(api.paths.absTmpPath, outputPath));
50
- return [{ source: generatedPath }];
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
@@ -1,4 +1,3 @@
1
1
  import { IApi } from 'umi';
2
2
  declare const _default: (api: IApi) => void;
3
3
  export default _default;
4
- //# sourceMappingURL=unocss.d.ts.map
package/dist/unocss.js CHANGED
@@ -1,39 +1,59 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const child_process_1 = require("child_process");
4
- const fs_1 = require("fs");
5
- const path_1 = require("path");
6
- const plugin_utils_1 = require("umi/plugin-utils");
7
- exports.default = (api) => {
8
- api.describe({
9
- key: 'unocss',
10
- config: {
11
- schema(Joi) {
12
- return Joi.object({
13
- watch: Joi.array(),
14
- });
15
- },
16
- },
17
- enableBy: api.EnableBy.config,
18
- });
19
- const outputPath = 'uno.css';
20
- api.onBeforeCompiler(() => {
21
- /** 由于 @unocss/cli 对设置文件进行了检查,因此加入需要 unocss.config.ts 设置的提示
22
- * https://github.com/antfu/unocss/blob/main/packages/cli/src/index.ts#L93 */
23
- if (!(0, fs_1.existsSync)((0, path_1.join)(api.paths.cwd, 'unocss.config.ts')))
24
- api.logger.warn('请在项目目录中添加 unocss.config.ts 文件,并配置需要的 unocss presets,否则插件将没有效果!');
25
- const generatedPath = (0, path_1.join)(api.paths.absTmpPath, outputPath);
26
- const binPath = (0, path_1.join)(api.cwd, 'node_modules/.bin/unocss');
27
- const watchDirs = api.config.unocss.watch;
28
- /** 透过子进程建立 unocss 服务,将生成的 css 写入 generatedPath */
29
- const unocss = (0, child_process_1.exec)(`${binPath} ${watchDirs.join(' ')} --out-file ${generatedPath} ${api.env === 'development' ? '--watch' : ''}`, { cwd: api.cwd });
30
- unocss.on('error', (m) => {
31
- api.logger.error('unocss service encounter an error: ' + m);
32
- });
33
- });
34
- /** 将生成的 css 文件加入到 import 中 */
35
- api.addEntryImports(() => {
36
- const generatedPath = (0, plugin_utils_1.winPath)((0, path_1.join)(api.paths.absTmpPath, outputPath));
37
- return [{ source: generatedPath }];
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 = {});
@@ -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
@@ -1,38 +1,42 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
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
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getIdentifierDeclaration = void 0;
27
- const t = __importStar(require("@umijs/bundler-utils/compiled/babel/types"));
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
- if (t.isIdentifier(node) && path.scope.hasBinding(node.name)) {
30
- let bindingNode = path.scope.getBinding(node.name).path.node;
31
- if (t.isVariableDeclarator(bindingNode)) {
32
- bindingNode = bindingNode.init;
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 node;
35
+ return bindingNode;
36
+ }
37
+ return node;
37
38
  }
38
- exports.getIdentifierDeclaration = getIdentifierDeclaration;
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