@zhubangyun/lowcode-core 1.1.0

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 (107) hide show
  1. package/es/components/layout/index.d.ts +34 -0
  2. package/es/components/layout/index.js +63 -0
  3. package/es/components/layout/index.less +20 -0
  4. package/es/components/schema-render/components/assets.d.ts +32 -0
  5. package/es/components/schema-render/components/assets.js +53 -0
  6. package/es/components/schema-render/components/demo-schema.d.ts +85 -0
  7. package/es/components/schema-render/components/demo-schema.js +107 -0
  8. package/es/components/schema-render/components/schema-render-base.d.ts +43 -0
  9. package/es/components/schema-render/components/schema-render-base.js +142 -0
  10. package/es/components/schema-render/components/schema-render-layout.d.ts +6 -0
  11. package/es/components/schema-render/components/schema-render-layout.js +46 -0
  12. package/es/components/schema-render/index.d.ts +31 -0
  13. package/es/components/schema-render/index.js +46 -0
  14. package/es/components/typing.d.ts +3 -0
  15. package/es/components/typing.js +12 -0
  16. package/es/index.d.ts +7 -0
  17. package/es/index.js +7 -0
  18. package/es/pages/data/assets.d.ts +32 -0
  19. package/es/pages/data/assets.js +53 -0
  20. package/es/pages/data/schema.d.ts +50 -0
  21. package/es/pages/data/schema.js +49 -0
  22. package/es/pages/index.d.ts +1 -0
  23. package/es/pages/index.js +31 -0
  24. package/es/pages/index.less +0 -0
  25. package/es/style.js +6 -0
  26. package/es/utils/api/index.d.ts +1 -0
  27. package/es/utils/api/index.js +12 -0
  28. package/es/utils/common/ClientCache.d.ts +36 -0
  29. package/es/utils/common/ClientCache.js +120 -0
  30. package/es/utils/common/FormDataHandler.d.ts +45 -0
  31. package/es/utils/common/FormDataHandler.js +410 -0
  32. package/es/utils/common/LoadPlugins.d.ts +1 -0
  33. package/es/utils/common/LoadPlugins.js +158 -0
  34. package/es/utils/common/ProcessHandler.d.ts +30 -0
  35. package/es/utils/common/ProcessHandler.js +303 -0
  36. package/es/utils/common/Request.d.ts +2 -0
  37. package/es/utils/common/Request.js +20 -0
  38. package/es/utils/common/RestApi.d.ts +80 -0
  39. package/es/utils/common/RestApi.js +226 -0
  40. package/es/utils/common/RestFormApi.d.ts +12 -0
  41. package/es/utils/common/RestFormApi.js +158 -0
  42. package/es/utils/common/SubFormInstance.d.ts +26 -0
  43. package/es/utils/common/SubFormInstance.js +100 -0
  44. package/es/utils/common/UserInfo.d.ts +9 -0
  45. package/es/utils/common/UserInfo.js +19 -0
  46. package/es/utils/common/index.d.ts +7 -0
  47. package/es/utils/common/index.js +39 -0
  48. package/es/utils/index.d.ts +17 -0
  49. package/es/utils/index.js +11 -0
  50. package/es/utils/lowcode/index.d.ts +1 -0
  51. package/es/utils/lowcode/index.js +1 -0
  52. package/es/utils/lowcode/parseAssets.d.ts +3 -0
  53. package/es/utils/lowcode/parseAssets.js +185 -0
  54. package/lib/components/layout/index.d.ts +34 -0
  55. package/lib/components/layout/index.js +69 -0
  56. package/lib/components/layout/index.less +20 -0
  57. package/lib/components/schema-render/components/assets.d.ts +32 -0
  58. package/lib/components/schema-render/components/assets.js +57 -0
  59. package/lib/components/schema-render/components/demo-schema.d.ts +85 -0
  60. package/lib/components/schema-render/components/demo-schema.js +111 -0
  61. package/lib/components/schema-render/components/schema-render-base.d.ts +43 -0
  62. package/lib/components/schema-render/components/schema-render-base.js +149 -0
  63. package/lib/components/schema-render/components/schema-render-layout.d.ts +6 -0
  64. package/lib/components/schema-render/components/schema-render-layout.js +51 -0
  65. package/lib/components/schema-render/index.d.ts +31 -0
  66. package/lib/components/schema-render/index.js +53 -0
  67. package/lib/components/typing.d.ts +3 -0
  68. package/lib/components/typing.js +17 -0
  69. package/lib/index.d.ts +7 -0
  70. package/lib/index.js +15 -0
  71. package/lib/pages/data/assets.d.ts +32 -0
  72. package/lib/pages/data/assets.js +57 -0
  73. package/lib/pages/data/schema.d.ts +50 -0
  74. package/lib/pages/data/schema.js +53 -0
  75. package/lib/pages/index.d.ts +1 -0
  76. package/lib/pages/index.js +34 -0
  77. package/lib/pages/index.less +0 -0
  78. package/lib/style.js +6 -0
  79. package/lib/utils/api/index.d.ts +1 -0
  80. package/lib/utils/api/index.js +17 -0
  81. package/lib/utils/common/ClientCache.d.ts +36 -0
  82. package/lib/utils/common/ClientCache.js +125 -0
  83. package/lib/utils/common/FormDataHandler.d.ts +45 -0
  84. package/lib/utils/common/FormDataHandler.js +416 -0
  85. package/lib/utils/common/LoadPlugins.d.ts +1 -0
  86. package/lib/utils/common/LoadPlugins.js +163 -0
  87. package/lib/utils/common/ProcessHandler.d.ts +30 -0
  88. package/lib/utils/common/ProcessHandler.js +308 -0
  89. package/lib/utils/common/Request.d.ts +2 -0
  90. package/lib/utils/common/Request.js +25 -0
  91. package/lib/utils/common/RestApi.d.ts +80 -0
  92. package/lib/utils/common/RestApi.js +230 -0
  93. package/lib/utils/common/RestFormApi.d.ts +12 -0
  94. package/lib/utils/common/RestFormApi.js +163 -0
  95. package/lib/utils/common/SubFormInstance.d.ts +26 -0
  96. package/lib/utils/common/SubFormInstance.js +105 -0
  97. package/lib/utils/common/UserInfo.d.ts +9 -0
  98. package/lib/utils/common/UserInfo.js +24 -0
  99. package/lib/utils/common/index.d.ts +7 -0
  100. package/lib/utils/common/index.js +48 -0
  101. package/lib/utils/index.d.ts +17 -0
  102. package/lib/utils/index.js +34 -0
  103. package/lib/utils/lowcode/index.d.ts +1 -0
  104. package/lib/utils/lowcode/index.js +6 -0
  105. package/lib/utils/lowcode/parseAssets.d.ts +3 -0
  106. package/lib/utils/lowcode/parseAssets.js +192 -0
  107. package/package.json +65 -0
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports.RestFormApi = void 0;
6
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
7
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
8
+ var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
9
+ var _RestApi2 = require("./RestApi");
10
+ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
11
+ function RestFormApi(formName, options) {
12
+ var _this;
13
+ _this = _RestApi.call(this, "forms/" + formName, options) || this;
14
+ _this.initialized = false;
15
+ _this.schema = void 0;
16
+ return _this;
17
+ }
18
+ (0, _inheritsLoose2["default"])(RestFormApi, _RestApi);
19
+ var _proto = RestFormApi.prototype;
20
+ _proto.initialize = /*#__PURE__*/function () {
21
+ var _initialize = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
22
+ return _regenerator["default"].wrap(function _callee$(_context) {
23
+ while (1) switch (_context.prev = _context.next) {
24
+ case 0:
25
+ if (this.initialized) {
26
+ _context.next = 8;
27
+ break;
28
+ }
29
+ _context.prev = 1;
30
+ //this.schema = await schemaCache.get(super.uri)
31
+ /* this.schema = await PageUtils.schemaCache.lazyGet(this.title);
32
+ this.handler = new FormDataHandler(this.schema);*/
33
+ this.initialized = true;
34
+ _context.next = 8;
35
+ break;
36
+ case 5:
37
+ _context.prev = 5;
38
+ _context.t0 = _context["catch"](1);
39
+ throw _context.t0;
40
+ case 8:
41
+ return _context.abrupt("return", this.initialized);
42
+ case 9:
43
+ case "end":
44
+ return _context.stop();
45
+ }
46
+ }, _callee, this, [[1, 5]]);
47
+ }));
48
+ function initialize() {
49
+ return _initialize.apply(this, arguments);
50
+ }
51
+ return initialize;
52
+ }();
53
+ _proto.search = /*#__PURE__*/function () {
54
+ var _search = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(params, page, pageSize) {
55
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
56
+ while (1) switch (_context2.prev = _context2.next) {
57
+ case 0:
58
+ if (params === void 0) {
59
+ params = {};
60
+ }
61
+ if (page === void 0) {
62
+ page = 1;
63
+ }
64
+ if (pageSize === void 0) {
65
+ pageSize = 20;
66
+ }
67
+ _context2.next = 5;
68
+ return this.initialize();
69
+ case 5:
70
+ return _context2.abrupt("return", _RestApi.prototype.search.call(this, params, page, pageSize));
71
+ case 6:
72
+ case "end":
73
+ return _context2.stop();
74
+ }
75
+ }, _callee2, this);
76
+ }));
77
+ function search(_x, _x2, _x3) {
78
+ return _search.apply(this, arguments);
79
+ }
80
+ return search;
81
+ }();
82
+ _proto.getById = /*#__PURE__*/function () {
83
+ var _getById = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(id, options) {
84
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
85
+ while (1) switch (_context3.prev = _context3.next) {
86
+ case 0:
87
+ _context3.next = 2;
88
+ return this.initialize();
89
+ case 2:
90
+ return _context3.abrupt("return", _RestApi.prototype.getById.call(this, id, options));
91
+ case 3:
92
+ case "end":
93
+ return _context3.stop();
94
+ }
95
+ }, _callee3, this);
96
+ }));
97
+ function getById(_x4, _x5) {
98
+ return _getById.apply(this, arguments);
99
+ }
100
+ return getById;
101
+ }();
102
+ _proto.create = /*#__PURE__*/function () {
103
+ var _create = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(data, options) {
104
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
105
+ while (1) switch (_context4.prev = _context4.next) {
106
+ case 0:
107
+ _context4.next = 2;
108
+ return this.initialize();
109
+ case 2:
110
+ return _context4.abrupt("return", _RestApi.prototype.create.call(this, data, options));
111
+ case 3:
112
+ case "end":
113
+ return _context4.stop();
114
+ }
115
+ }, _callee4, this);
116
+ }));
117
+ function create(_x6, _x7) {
118
+ return _create.apply(this, arguments);
119
+ }
120
+ return create;
121
+ }();
122
+ _proto.update = /*#__PURE__*/function () {
123
+ var _update = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(id, data, options) {
124
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
125
+ while (1) switch (_context5.prev = _context5.next) {
126
+ case 0:
127
+ _context5.next = 2;
128
+ return this.initialize();
129
+ case 2:
130
+ return _context5.abrupt("return", _RestApi.prototype.update.call(this, id, data, options));
131
+ case 3:
132
+ case "end":
133
+ return _context5.stop();
134
+ }
135
+ }, _callee5, this);
136
+ }));
137
+ function update(_x8, _x9, _x10) {
138
+ return _update.apply(this, arguments);
139
+ }
140
+ return update;
141
+ }();
142
+ _proto.deleteById = /*#__PURE__*/function () {
143
+ var _deleteById = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(id, options) {
144
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
145
+ while (1) switch (_context6.prev = _context6.next) {
146
+ case 0:
147
+ _context6.next = 2;
148
+ return this.initialize();
149
+ case 2:
150
+ return _context6.abrupt("return", _RestApi.prototype.deleteById.call(this, id, options));
151
+ case 3:
152
+ case "end":
153
+ return _context6.stop();
154
+ }
155
+ }, _callee6, this);
156
+ }));
157
+ function deleteById(_x11, _x12) {
158
+ return _deleteById.apply(this, arguments);
159
+ }
160
+ return deleteById;
161
+ }();
162
+ return RestFormApi;
163
+ }(_RestApi2.RestApi);
@@ -0,0 +1,26 @@
1
+ import { FormInstance } from "antd/lib";
2
+ import { NamePath, StoreValue } from "antd/es/form/interface";
3
+ declare type NamePaths = (string | number)[];
4
+ export declare class SubFormInstance implements FormInstance {
5
+ parentForm: FormInstance;
6
+ namePath: NamePaths;
7
+ constructor(form: FormInstance, namePath: NamePaths);
8
+ overwritePathName(name: NamePath): any[];
9
+ overwriteFields(fields: any[]): any[];
10
+ getFieldError(name: NamePath): string[];
11
+ getFieldValue(name: NamePath): StoreValue;
12
+ getFieldWarning(name: NamePath): string[];
13
+ getFieldsError(nameList: NamePath[] | undefined): any[];
14
+ getFieldsValue(nameList?: NamePath[] | true, filterFunc?: (meta: any) => boolean): any;
15
+ isFieldTouched(name: NamePath): boolean;
16
+ isFieldValidating(name: NamePath): boolean;
17
+ isFieldsTouched(): boolean;
18
+ isFieldsValidating(nameList: NamePath[]): boolean;
19
+ resetFields(fields: NamePath[] | undefined): void;
20
+ setFieldValue(name: NamePath, value: any): void;
21
+ setFields(fields: any[]): void;
22
+ setFieldsValue(values: any): void;
23
+ submit(): void;
24
+ validateFields(nameList: NamePath[] | undefined): Promise<any>;
25
+ }
26
+ export {};
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports.SubFormInstance = void 0;
6
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
7
+ var SubFormInstance = exports.SubFormInstance = /*#__PURE__*/function () {
8
+ function SubFormInstance(form, namePath) {
9
+ this.parentForm = void 0;
10
+ this.namePath = void 0;
11
+ this.parentForm = form;
12
+ this.namePath = namePath;
13
+ }
14
+ var _proto = SubFormInstance.prototype;
15
+ _proto.overwritePathName = function overwritePathName(name) {
16
+ if (Array.isArray(name)) {
17
+ return [].concat(this.namePath, name);
18
+ } else {
19
+ return [].concat(this.namePath, [name]);
20
+ }
21
+ };
22
+ _proto.overwriteFields = function overwriteFields(fields) {
23
+ var _this = this;
24
+ return fields === null || fields === void 0 ? void 0 : fields.map(function (field) {
25
+ return (0, _extends2["default"])({}, field, {
26
+ name: _this.overwritePathName(field.name)
27
+ });
28
+ });
29
+ };
30
+ _proto.getFieldError = function getFieldError(name) {
31
+ return this.parentForm.getFieldError(this.overwritePathName(name));
32
+ };
33
+ _proto.getFieldValue = function getFieldValue(name) {
34
+ return this.parentForm.getFieldValue(this.overwritePathName(name));
35
+ };
36
+ _proto.getFieldWarning = function getFieldWarning(name) {
37
+ return this.parentForm.getFieldWarning(this.overwritePathName(name));
38
+ }
39
+
40
+ // @ts-ignore
41
+ ;
42
+ _proto.getFieldsError = function getFieldsError(nameList) {
43
+ var _this2 = this;
44
+ return this.parentForm.getFieldsError(nameList === null || nameList === void 0 ? void 0 : nameList.map(function (name) {
45
+ return _this2.overwritePathName(name);
46
+ }));
47
+ }
48
+
49
+ // @ts-ignore
50
+ ;
51
+ _proto.getFieldsValue = function getFieldsValue(nameList, filterFunc) {
52
+ var values = (0, _extends2["default"])({}, this.parentForm.getFieldValue(this.namePath));
53
+ values.parent = this.parentForm.getFieldsValue(true);
54
+ return values;
55
+ };
56
+ _proto.isFieldTouched = function isFieldTouched(name) {
57
+ return this.parentForm.isFieldTouched(this.overwritePathName(name));
58
+ };
59
+ _proto.isFieldValidating = function isFieldValidating(name) {
60
+ return this.parentForm.isFieldValidating(this.overwritePathName(name));
61
+ };
62
+ _proto.isFieldsTouched = function isFieldsTouched() {
63
+ return this.parentForm.isFieldsTouched();
64
+ };
65
+ // @ts-ignore
66
+ _proto.isFieldsValidating = function isFieldsValidating(nameList) {
67
+ var _this3 = this;
68
+ return this.parentForm.isFieldsValidating(nameList.map(function (name) {
69
+ return _this3.overwritePathName(name);
70
+ }));
71
+ };
72
+ _proto.resetFields = function resetFields(fields) {
73
+ if (Array.isArray(fields)) {
74
+ // @ts-ignore
75
+ this.parentForm.resetFields(this.overwriteFields(fields));
76
+ } else {
77
+ this.parentForm.resetFields();
78
+ }
79
+ };
80
+ _proto.setFieldValue = function setFieldValue(name, value) {
81
+ return this.parentForm.setFieldValue(this.overwritePathName(name), value);
82
+ };
83
+ _proto.setFields = function setFields(fields) {
84
+ this.parentForm.setFields(this.overwriteFields(fields));
85
+ };
86
+ _proto.setFieldsValue = function setFieldsValue(values) {
87
+ var _this4 = this;
88
+ if (!values) return;
89
+ //删除父值
90
+ delete values.parent;
91
+ Object.keys(values).forEach(function (name) {
92
+ return _this4.parentForm.setFieldValue(_this4.overwritePathName(name), values[name]);
93
+ });
94
+ };
95
+ _proto.submit = function submit() {
96
+ this.parentForm.submit();
97
+ }
98
+
99
+ // @ts-ignore
100
+ ;
101
+ _proto.validateFields = function validateFields(nameList) {
102
+ return this.parentForm.validateFields(nameList);
103
+ };
104
+ return SubFormInstance;
105
+ }();
@@ -0,0 +1,9 @@
1
+ export interface UserInfo {
2
+ userId: string;
3
+ userName: string;
4
+ staffId: string;
5
+ staffName: string;
6
+ roleIds: string[];
7
+ deptIds: string[];
8
+ }
9
+ export declare function loadUserInfo(): Promise<UserInfo>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports.loadUserInfo = loadUserInfo;
6
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
7
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
8
+ function loadUserInfo() {
9
+ return _loadUserInfo.apply(this, arguments);
10
+ }
11
+ function _loadUserInfo() {
12
+ _loadUserInfo = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
13
+ return _regenerator["default"].wrap(function _callee$(_context) {
14
+ while (1) switch (_context.prev = _context.next) {
15
+ case 0:
16
+ return _context.abrupt("return", {});
17
+ case 1:
18
+ case "end":
19
+ return _context.stop();
20
+ }
21
+ }, _callee);
22
+ }));
23
+ return _loadUserInfo.apply(this, arguments);
24
+ }
@@ -0,0 +1,7 @@
1
+ import { ClientCache } from "./ClientCache";
2
+ export { RestApi } from "./RestApi";
3
+ export { RestFormApi } from "./RestFormApi";
4
+ export { ClientCache } from "./ClientCache";
5
+ export { loadPlugins } from "./LoadPlugins";
6
+ export declare function uuid(prefix?: string, separator?: string): string;
7
+ export declare const schemaCache: ClientCache;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports.schemaCache = exports.loadPlugins = exports.RestFormApi = exports.RestApi = void 0;
6
+ exports.uuid = uuid;
7
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
8
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
9
+ var _uuid = require("uuid");
10
+ var _ClientCache = require("./ClientCache");
11
+ exports.ClientCache = _ClientCache.ClientCache;
12
+ var _api = require("../api");
13
+ var _RestApi = require("./RestApi");
14
+ exports.RestApi = _RestApi.RestApi;
15
+ var _RestFormApi = require("./RestFormApi");
16
+ exports.RestFormApi = _RestFormApi.RestFormApi;
17
+ var _LoadPlugins = require("./LoadPlugins");
18
+ exports.loadPlugins = _LoadPlugins.loadPlugins;
19
+ function uuid(prefix, separator) {
20
+ return [prefix, separator, (0, _uuid.v4)()].filter(function (v) {
21
+ return !!v;
22
+ }).join("");
23
+ }
24
+ var schemaCache = exports.schemaCache = new _ClientCache.ClientCache({
25
+ name: "schema",
26
+ loadData: function () {
27
+ var _loadData = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(name) {
28
+ var res;
29
+ return _regenerator["default"].wrap(function _callee$(_context) {
30
+ while (1) switch (_context.prev = _context.next) {
31
+ case 0:
32
+ _context.next = 2;
33
+ return _api.request.get("schemas/" + name + ".json");
34
+ case 2:
35
+ res = _context.sent;
36
+ return _context.abrupt("return", res.data);
37
+ case 4:
38
+ case "end":
39
+ return _context.stop();
40
+ }
41
+ }, _callee);
42
+ }));
43
+ function loadData(_x) {
44
+ return _loadData.apply(this, arguments);
45
+ }
46
+ return loadData;
47
+ }()
48
+ });
@@ -0,0 +1,17 @@
1
+ export * from "./api";
2
+ export * from "./common";
3
+ export * from "./lowcode";
4
+ import * as common from "./common";
5
+ import * as api from "./api";
6
+ import * as lowcode from "./lowcode";
7
+ declare const _default: {
8
+ uuid(prefix?: string, separator?: string): string;
9
+ RestApi: typeof common.RestApi;
10
+ RestFormApi: typeof common.RestFormApi;
11
+ ClientCache: typeof common.ClientCache;
12
+ loadPlugins: typeof common.loadPlugins;
13
+ schemaCache: common.ClientCache;
14
+ api: typeof api;
15
+ lowcode: typeof lowcode;
16
+ };
17
+ export default _default;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ var _exportNames = {};
6
+ exports["default"] = void 0;
7
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
+ var api = _interopRequireWildcard(require("./api"));
9
+ Object.keys(api).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
12
+ if (key in exports && exports[key] === api[key]) return;
13
+ exports[key] = api[key];
14
+ });
15
+ var common = _interopRequireWildcard(require("./common"));
16
+ Object.keys(common).forEach(function (key) {
17
+ if (key === "default" || key === "__esModule") return;
18
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
19
+ if (key in exports && exports[key] === common[key]) return;
20
+ exports[key] = common[key];
21
+ });
22
+ var lowcode = _interopRequireWildcard(require("./lowcode"));
23
+ Object.keys(lowcode).forEach(function (key) {
24
+ if (key === "default" || key === "__esModule") return;
25
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
26
+ if (key in exports && exports[key] === lowcode[key]) return;
27
+ exports[key] = lowcode[key];
28
+ });
29
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
30
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
31
+ var _default = exports["default"] = (0, _extends2["default"])({
32
+ api: api,
33
+ lowcode: lowcode
34
+ }, common);
@@ -0,0 +1 @@
1
+ export { parseAssets } from "./parseAssets";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.parseAssets = void 0;
5
+ var _parseAssets = require("./parseAssets");
6
+ exports.parseAssets = _parseAssets.parseAssets;
@@ -0,0 +1,3 @@
1
+ export declare function parseAssets(assets: any): Promise<{
2
+ components: any;
3
+ }>;
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports.parseAssets = parseAssets;
6
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
7
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
10
+ var _lowcodeUtils = require("@zhubangyun/lowcode-utils");
11
+ var _lowcodeRendererCore = _interopRequireDefault(require("@zhubangyun/lowcode-renderer-core"));
12
+ var _react = _interopRequireWildcard(require("react"));
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
15
+ function genLowcodeComp(schema, components) {
16
+ return /*#__PURE__*/function (_React$Component) {
17
+ function LowcodeComp() {
18
+ return _React$Component.apply(this, arguments) || this;
19
+ }
20
+ (0, _inheritsLoose2["default"])(LowcodeComp, _React$Component);
21
+ var _proto = LowcodeComp.prototype;
22
+ _proto.render = function render() {
23
+ return /*#__PURE__*/(0, _react.createElement)(_lowcodeRendererCore["default"], (0, _extends2["default"])({}, this.props, {
24
+ schema: schema,
25
+ components: components,
26
+ designMode: ''
27
+ }));
28
+ };
29
+ return LowcodeComp;
30
+ }(_react["default"].Component);
31
+ }
32
+ function parseAssets(_x) {
33
+ return _parseAssets.apply(this, arguments);
34
+ }
35
+ function _parseAssets() {
36
+ _parseAssets = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(assets) {
37
+ var rawComponents, packages, libraryAsset, libraryMap, packagesMap, assetLoader, newComponents, componentDescriptions, remoteComponentDescriptions, lowcodeComponentsArray, proCodeComponentsMap, genLowCodeComponentsMap, components, lowCodeComponents;
38
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
39
+ while (1) switch (_context2.prev = _context2.next) {
40
+ case 0:
41
+ genLowCodeComponentsMap = function _genLowCodeComponents(components) {
42
+ var lowcodeComponentsMap = {};
43
+ lowcodeComponentsArray.forEach(function (lowcode) {
44
+ var _lowcode$reference, _packagesMap$id;
45
+ var id = (_lowcode$reference = lowcode.reference) === null || _lowcode$reference === void 0 ? void 0 : _lowcode$reference.id;
46
+ var schema = (_packagesMap$id = packagesMap[id]) === null || _packagesMap$id === void 0 ? void 0 : _packagesMap$id.schema;
47
+ lowcodeComponentsMap[lowcode.componentName] = genLowcodeComp(schema, (0, _extends2["default"])({}, components, lowcodeComponentsMap));
48
+ });
49
+ return lowcodeComponentsMap;
50
+ };
51
+ rawComponents = assets.components, packages = assets.packages;
52
+ libraryAsset = [];
53
+ libraryMap = {};
54
+ packagesMap = {};
55
+ packages.forEach(function (pkg) {
56
+ var _package = pkg["package"],
57
+ library = pkg.library,
58
+ urls = pkg.urls,
59
+ renderUrls = pkg.renderUrls,
60
+ id = pkg.id;
61
+ if (_package) {
62
+ libraryMap[id || _package] = library;
63
+ }
64
+ packagesMap[id || _package] = pkg;
65
+ if (renderUrls) {
66
+ libraryAsset.push(renderUrls);
67
+ } else if (urls) {
68
+ libraryAsset.push(urls);
69
+ }
70
+ });
71
+ assetLoader = new _lowcodeUtils.AssetLoader();
72
+ _context2.next = 9;
73
+ return assetLoader.load(libraryAsset);
74
+ case 9:
75
+ newComponents = rawComponents;
76
+ if (!(rawComponents && rawComponents.length)) {
77
+ _context2.next = 18;
78
+ break;
79
+ }
80
+ componentDescriptions = [];
81
+ remoteComponentDescriptions = [];
82
+ rawComponents.forEach(function (component) {
83
+ if (!component) {
84
+ return;
85
+ }
86
+ if (component.exportName && component.url) {
87
+ remoteComponentDescriptions.push(component);
88
+ } else {
89
+ componentDescriptions.push(component);
90
+ }
91
+ });
92
+ newComponents = [].concat(componentDescriptions);
93
+
94
+ // 如果有远程组件描述协议,则自动加载并补充到资产包中,同时出发 designer.incrementalAssetsReady 通知组件面板更新数据
95
+ if (!(remoteComponentDescriptions && remoteComponentDescriptions.length)) {
96
+ _context2.next = 18;
97
+ break;
98
+ }
99
+ _context2.next = 18;
100
+ return Promise.all(remoteComponentDescriptions.map( /*#__PURE__*/function () {
101
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(component) {
102
+ var exportName, url, npm, setAssetsComponent, setArrayAssets;
103
+ return _regenerator["default"].wrap(function _callee$(_context) {
104
+ while (1) switch (_context.prev = _context.next) {
105
+ case 0:
106
+ setArrayAssets = function _setArrayAssets(value, preExportName, preSubName) {
107
+ if (preExportName === void 0) {
108
+ preExportName = '';
109
+ }
110
+ if (preSubName === void 0) {
111
+ preSubName = '';
112
+ }
113
+ value.forEach(function (d, i) {
114
+ var exportName = [preExportName, i.toString()].filter(function (d) {
115
+ return !!d;
116
+ }).join('.');
117
+ var subName = [preSubName, i.toString()].filter(function (d) {
118
+ return !!d;
119
+ }).join('.');
120
+ Array.isArray(d) ? setArrayAssets(d, exportName, subName) : setAssetsComponent(d, {
121
+ exportName: exportName,
122
+ subName: subName
123
+ });
124
+ });
125
+ };
126
+ setAssetsComponent = function _setAssetsComponent(component, extraNpmInfo) {
127
+ if (extraNpmInfo === void 0) {
128
+ extraNpmInfo = {};
129
+ }
130
+ var components = component.components;
131
+ if (Array.isArray(components)) {
132
+ components.forEach(function (d) {
133
+ newComponents = newComponents.concat((0, _extends2["default"])({
134
+ npm: (0, _extends2["default"])({}, npm, extraNpmInfo)
135
+ }, d) || []);
136
+ });
137
+ return;
138
+ }
139
+ newComponents = newComponents.concat((0, _extends2["default"])({
140
+ npm: (0, _extends2["default"])({}, npm, extraNpmInfo)
141
+ }, component.components) || []);
142
+ // assets.componentList = assets.componentList.concat(component.componentList || []);
143
+ };
144
+ exportName = component.exportName, url = component.url, npm = component.npm;
145
+ _context.next = 5;
146
+ return new _lowcodeUtils.AssetLoader().load(url);
147
+ case 5:
148
+ if (window[exportName]) {
149
+ if (Array.isArray(window[exportName])) {
150
+ setArrayAssets(window[exportName]);
151
+ } else {
152
+ setAssetsComponent(window[exportName]);
153
+ }
154
+ }
155
+ return _context.abrupt("return", window[exportName]);
156
+ case 7:
157
+ case "end":
158
+ return _context.stop();
159
+ }
160
+ }, _callee);
161
+ }));
162
+ return function (_x2) {
163
+ return _ref.apply(this, arguments);
164
+ };
165
+ }()));
166
+ case 18:
167
+ lowcodeComponentsArray = [];
168
+ proCodeComponentsMap = newComponents.reduce(function (acc, cur) {
169
+ if ((cur.devMode || '').toLowerCase() === 'lowcode') {
170
+ lowcodeComponentsArray.push(cur);
171
+ } else {
172
+ acc[cur.componentName] = (0, _extends2["default"])({}, cur.reference || cur.npm, {
173
+ componentName: cur.componentName
174
+ });
175
+ }
176
+ return acc;
177
+ }, {});
178
+ components = (0, _lowcodeUtils.buildComponents)(libraryMap, proCodeComponentsMap, function (schema) {
179
+ return null;
180
+ });
181
+ lowCodeComponents = genLowCodeComponentsMap(components);
182
+ return _context2.abrupt("return", {
183
+ components: (0, _extends2["default"])({}, components, lowCodeComponents)
184
+ });
185
+ case 23:
186
+ case "end":
187
+ return _context2.stop();
188
+ }
189
+ }, _callee2);
190
+ }));
191
+ return _parseAssets.apply(this, arguments);
192
+ }