@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/model.js CHANGED
@@ -1,62 +1,61 @@
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
- const t = __importStar(require("@umijs/bundler-utils/compiled/babel/types"));
27
- const fs_1 = require("fs");
28
- const path_1 = require("path");
29
- const plugin_utils_1 = require("umi/plugin-utils");
30
- const modelUtils_1 = require("./utils/modelUtils");
31
- const withTmpPath_1 = require("./utils/withTmpPath");
32
- exports.default = (api) => {
33
- api.describe({
34
- config: {
35
- schema(Joi) {
36
- return Joi.object({
37
- extraModels: Joi.array().items(Joi.string()),
38
- });
39
- },
40
- },
41
- enableBy: api.EnableBy.config,
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/model.ts
23
+ var model_exports = {};
24
+ __export(model_exports, {
25
+ default: () => model_default
26
+ });
27
+ module.exports = __toCommonJS(model_exports);
28
+ var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
29
+ var import_fs = require("fs");
30
+ var import_path = require("path");
31
+ var import_plugin_utils = require("umi/plugin-utils");
32
+ var import_modelUtils = require("./utils/modelUtils");
33
+ var import_withTmpPath = require("./utils/withTmpPath");
34
+ var model_default = (api) => {
35
+ api.describe({
36
+ config: {
37
+ schema(Joi) {
38
+ return Joi.alternatives().try(Joi.object({
39
+ extraModels: Joi.array().items(Joi.string())
40
+ }), Joi.boolean().invalid(true));
41
+ }
42
+ },
43
+ enableBy: api.EnableBy.config
44
+ });
45
+ api.onGenerateFiles(async () => {
46
+ const models = await getAllModels(api);
47
+ api.writeTmpFile({
48
+ path: "model.ts",
49
+ content: import_modelUtils.ModelUtils.getModelsContent(models)
50
+ });
51
+ const indexContent = (0, import_fs.readFileSync)((0, import_path.join)(__dirname, "../libs/model.tsx"), "utf-8").replace("fast-deep-equal", (0, import_plugin_utils.winPath)(require.resolve("fast-deep-equal")));
52
+ api.writeTmpFile({
53
+ path: "index.tsx",
54
+ content: indexContent
42
55
  });
43
- api.onGenerateFiles(async () => {
44
- const models = await getAllModels(api);
45
- // model.ts
46
- api.writeTmpFile({
47
- path: 'model.ts',
48
- content: modelUtils_1.ModelUtils.getModelsContent(models),
49
- });
50
- // index.tsx
51
- const indexContent = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../libs/model.tsx'), 'utf-8').replace('fast-deep-equal', (0, plugin_utils_1.winPath)(require.resolve('fast-deep-equal')));
52
- api.writeTmpFile({
53
- path: 'index.tsx',
54
- content: indexContent,
55
- });
56
- // runtime.tsx
57
- api.writeTmpFile({
58
- path: 'runtime.tsx',
59
- content: `
56
+ api.writeTmpFile({
57
+ path: "runtime.tsx",
58
+ content: `
60
59
  import React from 'react';
61
60
  import { Provider } from './';
62
61
  import { models as rawModels } from './model';
@@ -74,28 +73,30 @@ function ProviderWrapper(props: any) {
74
73
  export function dataflowProvider(container, opts) {
75
74
  return <ProviderWrapper {...opts}>{ container }</ProviderWrapper>;
76
75
  }
77
- `,
78
- });
79
- });
80
- api.addTmpGenerateWatcherPaths(() => {
81
- return [(0, path_1.join)(api.paths.absSrcPath, 'models')];
82
- });
83
- api.addRuntimePlugin(() => {
84
- return [(0, withTmpPath_1.withTmpPath)({ api, path: 'runtime.tsx' })];
76
+ `
85
77
  });
78
+ });
79
+ api.addTmpGenerateWatcherPaths(() => {
80
+ return [(0, import_path.join)(api.paths.absSrcPath, "models")];
81
+ });
82
+ api.addRuntimePlugin(() => {
83
+ return [(0, import_withTmpPath.withTmpPath)({ api, path: "runtime.tsx" })];
84
+ });
86
85
  };
87
86
  async function getAllModels(api) {
88
- const extraModels = await api.applyPlugins({
89
- key: 'addExtraModels',
90
- type: api.ApplyPluginsType.add,
91
- initialValue: [],
92
- });
93
- return new modelUtils_1.ModelUtils(api, {
94
- astTest({ node }) {
95
- return t.isArrowFunctionExpression(node) || t.isFunctionDeclaration(node);
96
- },
97
- }).getAllModels({
98
- sort: {},
99
- extraModels: [...extraModels, ...(api.config.model.extraModels || [])],
100
- });
87
+ const extraModels = await api.applyPlugins({
88
+ key: "addExtraModels",
89
+ type: api.ApplyPluginsType.add,
90
+ initialValue: []
91
+ });
92
+ return new import_modelUtils.ModelUtils(api, {
93
+ astTest({ node }) {
94
+ return t.isArrowFunctionExpression(node) || t.isFunctionDeclaration(node);
95
+ }
96
+ }).getAllModels({
97
+ sort: {},
98
+ extraModels: [...extraModels, ...api.config.model.extraModels || []]
99
+ });
101
100
  }
101
+ // Annotate the CommonJS export names for ESM import in node:
102
+ 0 && (module.exports = {});
@@ -1,73 +1,92 @@
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
- /*
6
- As long as moment2dayjs is registered, moment will be replaced by dayjs.
7
- The presets that can adapt to antd is registered by default.
8
- When the user configures preset and plugins at the same time, we will merge them.
9
- */
10
- exports.default = (api) => {
11
- api.describe({
12
- key: 'moment2dayjs',
13
- config: {
14
- schema(joi) {
15
- return joi.object({
16
- preset: joi.string(),
17
- plugins: joi.array(),
18
- });
19
- },
20
- },
21
- enableBy: api.EnableBy.config,
22
- });
23
- const presets = {
24
- antd: [
25
- 'isSameOrBefore',
26
- 'isSameOrAfter',
27
- 'advancedFormat',
28
- 'customParseFormat',
29
- 'weekday',
30
- 'weekYear',
31
- 'weekOfYear',
32
- 'isMoment',
33
- 'localeData',
34
- 'localizedFormat',
35
- ],
36
- antdv3: [
37
- 'isSameOrBefore',
38
- 'isSameOrAfter',
39
- 'advancedFormat',
40
- 'customParseFormat',
41
- 'weekday',
42
- 'weekYear',
43
- 'weekOfYear',
44
- 'isMoment',
45
- 'localeData',
46
- 'localizedFormat',
47
- 'badMutable',
48
- ],
49
- };
50
- const getDayjsPlugins = (api) => {
51
- let { preset = 'antd', plugins = [] } = api.config.moment2dayjs || {};
52
- switch (preset) {
53
- case 'antd':
54
- return Array.from(new Set(presets['antd'].concat(plugins)));
55
- case 'antdv3':
56
- return Array.from(new Set(presets['antdv3'].concat(plugins)));
57
- case 'none':
58
- return [].concat(plugins);
59
- default:
60
- return [];
61
- }
62
- };
63
- // replace moment
64
- api.modifyConfig((memo) => {
65
- memo.alias.moment = (0, path_1.dirname)(require.resolve('dayjs/package.json'));
66
- return memo;
67
- });
68
- api.onGenerateFiles(() => {
69
- const plugins = getDayjsPlugins(api);
70
- const runtimeTpl = `
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/moment2dayjs.ts
23
+ var moment2dayjs_exports = {};
24
+ __export(moment2dayjs_exports, {
25
+ default: () => moment2dayjs_default
26
+ });
27
+ module.exports = __toCommonJS(moment2dayjs_exports);
28
+ var import_path = require("path");
29
+ var import_plugin_utils = require("umi/plugin-utils");
30
+ var moment2dayjs_default = (api) => {
31
+ api.describe({
32
+ key: "moment2dayjs",
33
+ config: {
34
+ schema(Joi) {
35
+ return Joi.alternatives().try(Joi.object({
36
+ preset: Joi.string(),
37
+ plugins: Joi.array()
38
+ }), Joi.boolean().invalid(true));
39
+ }
40
+ },
41
+ enableBy: api.EnableBy.config
42
+ });
43
+ const presets = {
44
+ antd: [
45
+ "isSameOrBefore",
46
+ "isSameOrAfter",
47
+ "advancedFormat",
48
+ "customParseFormat",
49
+ "weekday",
50
+ "weekYear",
51
+ "weekOfYear",
52
+ "isMoment",
53
+ "localeData",
54
+ "localizedFormat"
55
+ ],
56
+ antdv3: [
57
+ "isSameOrBefore",
58
+ "isSameOrAfter",
59
+ "advancedFormat",
60
+ "customParseFormat",
61
+ "weekday",
62
+ "weekYear",
63
+ "weekOfYear",
64
+ "isMoment",
65
+ "localeData",
66
+ "localizedFormat",
67
+ "badMutable"
68
+ ]
69
+ };
70
+ const getDayjsPlugins = (api2) => {
71
+ let { preset = "antd", plugins = [] } = api2.config.moment2dayjs || {};
72
+ switch (preset) {
73
+ case "antd":
74
+ return Array.from(new Set(presets["antd"].concat(plugins)));
75
+ case "antdv3":
76
+ return Array.from(new Set(presets["antdv3"].concat(plugins)));
77
+ case "none":
78
+ return [].concat(plugins);
79
+ default:
80
+ return [];
81
+ }
82
+ };
83
+ api.modifyConfig((memo) => {
84
+ memo.alias.moment = (0, import_path.dirname)(require.resolve("dayjs/package.json"));
85
+ return memo;
86
+ });
87
+ api.onGenerateFiles(() => {
88
+ const plugins = getDayjsPlugins(api);
89
+ const runtimeTpl = `
71
90
  import dayjs from '{{{dayjsPath}}}';
72
91
  import antdPlugin from '{{{dayjsAntdPluginPath}}}';
73
92
 
@@ -81,16 +100,18 @@ dayjs.extend({{.}});
81
100
 
82
101
  dayjs.extend(antdPlugin);
83
102
  `;
84
- const dayjsAntdPluginPath = (0, plugin_utils_1.winPath)(require.resolve('antd-dayjs-webpack-plugin/src/antd-plugin'));
85
- const dayjsPath = (0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('dayjs/package.json')));
86
- api.writeTmpFile({
87
- path: 'runtime.tsx',
88
- content: plugin_utils_1.Mustache.render(runtimeTpl, {
89
- plugins,
90
- dayjsPath,
91
- dayjsAntdPluginPath,
92
- }),
93
- });
103
+ const dayjsAntdPluginPath = (0, import_plugin_utils.winPath)(require.resolve("antd-dayjs-webpack-plugin/src/antd-plugin"));
104
+ const dayjsPath = (0, import_plugin_utils.winPath)((0, import_path.dirname)(require.resolve("dayjs/package.json")));
105
+ api.writeTmpFile({
106
+ path: "runtime.tsx",
107
+ content: import_plugin_utils.Mustache.render(runtimeTpl, {
108
+ plugins,
109
+ dayjsPath,
110
+ dayjsAntdPluginPath
111
+ })
94
112
  });
95
- api.addEntryCodeAhead(() => [`import './plugin-moment2dayjs/runtime.tsx'`]);
113
+ });
114
+ api.addEntryCodeAhead(() => [`import './plugin-moment2dayjs/runtime.tsx'`]);
96
115
  };
116
+ // Annotate the CommonJS export names for ESM import in node:
117
+ 0 && (module.exports = {});
@@ -1,8 +1,41 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MODEL_EXPORT_NAME = exports.qiankunStateFromMasterModelNamespace = exports.qiankunStateForSlaveModelNamespace = exports.defaultHistoryType = exports.defaultMasterRootId = void 0;
4
- exports.defaultMasterRootId = 'root-master';
5
- exports.defaultHistoryType = 'browser';
6
- exports.qiankunStateForSlaveModelNamespace = '@@qiankunStateForSlave';
7
- exports.qiankunStateFromMasterModelNamespace = '@@qiankunStateFromMaster';
8
- exports.MODEL_EXPORT_NAME = 'useQiankunStateForSlave';
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/qiankun/constants.ts
20
+ var constants_exports = {};
21
+ __export(constants_exports, {
22
+ MODEL_EXPORT_NAME: () => MODEL_EXPORT_NAME,
23
+ defaultHistoryType: () => defaultHistoryType,
24
+ defaultMasterRootId: () => defaultMasterRootId,
25
+ qiankunStateForSlaveModelNamespace: () => qiankunStateForSlaveModelNamespace,
26
+ qiankunStateFromMasterModelNamespace: () => qiankunStateFromMasterModelNamespace
27
+ });
28
+ module.exports = __toCommonJS(constants_exports);
29
+ var defaultMasterRootId = "root-master";
30
+ var defaultHistoryType = "browser";
31
+ var qiankunStateForSlaveModelNamespace = "@@qiankunStateForSlave";
32
+ var qiankunStateFromMasterModelNamespace = "@@qiankunStateFromMaster";
33
+ var MODEL_EXPORT_NAME = "useQiankunStateForSlave";
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ MODEL_EXPORT_NAME,
37
+ defaultHistoryType,
38
+ defaultMasterRootId,
39
+ qiankunStateForSlaveModelNamespace,
40
+ qiankunStateFromMasterModelNamespace
41
+ });