@cuipengyu5/bling-renderer-core 0.0.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 (93) hide show
  1. package/es/adapter/index.d.ts +24 -0
  2. package/es/adapter/index.js +95 -0
  3. package/es/components/Div.d.ts +2 -0
  4. package/es/components/Div.js +19 -0
  5. package/es/components/VisualDom/index.css +19 -0
  6. package/es/components/VisualDom/index.d.ts +3 -0
  7. package/es/components/VisualDom/index.js +44 -0
  8. package/es/context/index.d.ts +1 -0
  9. package/es/context/index.js +11 -0
  10. package/es/hoc/index.d.ts +7 -0
  11. package/es/hoc/index.js +90 -0
  12. package/es/hoc/leaf.d.ts +32 -0
  13. package/es/hoc/leaf.js +521 -0
  14. package/es/index.d.ts +7 -0
  15. package/es/index.js +9 -0
  16. package/es/renderer/addon.d.ts +2 -0
  17. package/es/renderer/addon.js +107 -0
  18. package/es/renderer/base.d.ts +13 -0
  19. package/es/renderer/base.js +1120 -0
  20. package/es/renderer/block.d.ts +2 -0
  21. package/es/renderer/block.js +43 -0
  22. package/es/renderer/component.d.ts +2 -0
  23. package/es/renderer/component.js +59 -0
  24. package/es/renderer/index.d.ts +8 -0
  25. package/es/renderer/index.js +8 -0
  26. package/es/renderer/page.d.ts +2 -0
  27. package/es/renderer/page.js +91 -0
  28. package/es/renderer/renderer.d.ts +2 -0
  29. package/es/renderer/renderer.js +230 -0
  30. package/es/renderer/temp.d.ts +2 -0
  31. package/es/renderer/temp.js +139 -0
  32. package/es/style.js +1 -0
  33. package/es/types/index.d.ts +275 -0
  34. package/es/types/index.js +1 -0
  35. package/es/utils/common.d.ts +119 -0
  36. package/es/utils/common.js +378 -0
  37. package/es/utils/data-helper.d.ts +74 -0
  38. package/es/utils/data-helper.js +300 -0
  39. package/es/utils/index.d.ts +3 -0
  40. package/es/utils/index.js +3 -0
  41. package/es/utils/is-use-loop.d.ts +2 -0
  42. package/es/utils/is-use-loop.js +16 -0
  43. package/es/utils/logger.d.ts +3 -0
  44. package/es/utils/logger.js +5 -0
  45. package/es/utils/request.d.ts +54 -0
  46. package/es/utils/request.js +209 -0
  47. package/lib/adapter/index.d.ts +24 -0
  48. package/lib/adapter/index.js +99 -0
  49. package/lib/components/Div.d.ts +2 -0
  50. package/lib/components/Div.js +24 -0
  51. package/lib/components/VisualDom/index.css +19 -0
  52. package/lib/components/VisualDom/index.d.ts +3 -0
  53. package/lib/components/VisualDom/index.js +49 -0
  54. package/lib/context/index.d.ts +1 -0
  55. package/lib/context/index.js +16 -0
  56. package/lib/hoc/index.d.ts +7 -0
  57. package/lib/hoc/index.js +95 -0
  58. package/lib/hoc/leaf.d.ts +32 -0
  59. package/lib/hoc/leaf.js +526 -0
  60. package/lib/index.d.ts +7 -0
  61. package/lib/index.js +34 -0
  62. package/lib/renderer/addon.d.ts +2 -0
  63. package/lib/renderer/addon.js +112 -0
  64. package/lib/renderer/base.d.ts +13 -0
  65. package/lib/renderer/base.js +1126 -0
  66. package/lib/renderer/block.d.ts +2 -0
  67. package/lib/renderer/block.js +48 -0
  68. package/lib/renderer/component.d.ts +2 -0
  69. package/lib/renderer/component.js +64 -0
  70. package/lib/renderer/index.d.ts +8 -0
  71. package/lib/renderer/index.js +18 -0
  72. package/lib/renderer/page.d.ts +2 -0
  73. package/lib/renderer/page.js +96 -0
  74. package/lib/renderer/renderer.d.ts +2 -0
  75. package/lib/renderer/renderer.js +235 -0
  76. package/lib/renderer/temp.d.ts +2 -0
  77. package/lib/renderer/temp.js +144 -0
  78. package/lib/style.js +1 -0
  79. package/lib/types/index.d.ts +275 -0
  80. package/lib/types/index.js +3 -0
  81. package/lib/utils/common.d.ts +119 -0
  82. package/lib/utils/common.js +409 -0
  83. package/lib/utils/data-helper.d.ts +74 -0
  84. package/lib/utils/data-helper.js +306 -0
  85. package/lib/utils/index.d.ts +3 -0
  86. package/lib/utils/index.js +21 -0
  87. package/lib/utils/is-use-loop.d.ts +2 -0
  88. package/lib/utils/is-use-loop.js +19 -0
  89. package/lib/utils/logger.d.ts +3 -0
  90. package/lib/utils/logger.js +9 -0
  91. package/lib/utils/request.d.ts +54 -0
  92. package/lib/utils/request.js +217 -0
  93. package/package.json +64 -0
@@ -0,0 +1,1126 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports["default"] = baseRendererFactory;
6
+ exports.executeLifeCycleMethod = executeLifeCycleMethod;
7
+ exports.getSchemaChildren = getSchemaChildren;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+ var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
14
+ var _classnames = _interopRequireDefault(require("classnames"));
15
+ var _interpret = require("@alilc/lowcode-datasource-engine/interpret");
16
+ var _lowcodeUtils = require("@alilc/lowcode-utils");
17
+ var _adapter = _interopRequireDefault(require("../adapter"));
18
+ var _Div = _interopRequireDefault(require("../components/Div"));
19
+ var _VisualDom = _interopRequireDefault(require("../components/VisualDom"));
20
+ var _context6 = _interopRequireDefault(require("../context"));
21
+ var _utils = require("../utils");
22
+ var _hoc = require("../hoc");
23
+ var _leaf = require("../hoc/leaf");
24
+ var _logger = _interopRequireDefault(require("../utils/logger"));
25
+ var _isUseLoop = _interopRequireDefault(require("../utils/is-use-loop"));
26
+ var _excluded = ["ref"];
27
+ /* eslint-disable no-console */
28
+ /* eslint-disable max-len */
29
+ /* eslint-disable react/prop-types */
30
+ /**
31
+ * execute method in schema.lifeCycles with context
32
+ * @PRIVATE
33
+ */
34
+ function executeLifeCycleMethod(context, schema, method, args, thisRequiredInJSE) {
35
+ if (!context || !(0, _utils.isSchema)(schema) || !method) {
36
+ return;
37
+ }
38
+ var lifeCycleMethods = (0, _utils.getValue)(schema, 'lifeCycles', {});
39
+ var fn = lifeCycleMethods[method];
40
+ if (!fn) {
41
+ return;
42
+ }
43
+
44
+ // TODO: cache
45
+ if ((0, _lowcodeUtils.isJSExpression)(fn) || (0, _lowcodeUtils.isJSFunction)(fn)) {
46
+ fn = thisRequiredInJSE ? (0, _utils.parseThisRequiredExpression)(fn, context) : (0, _utils.parseExpression)(fn, context);
47
+ }
48
+ if (typeof fn !== 'function') {
49
+ _logger["default"].error("\u751F\u547D\u5468\u671F" + method + "\u7C7B\u578B\u4E0D\u7B26", fn);
50
+ return;
51
+ }
52
+ try {
53
+ return fn.apply(context, args);
54
+ } catch (e) {
55
+ _logger["default"].error("[" + schema.componentName + "]\u751F\u547D\u5468\u671F" + method + "\u51FA\u9519", e);
56
+ }
57
+ }
58
+
59
+ /**
60
+ * get children from a node schema
61
+ * @PRIVATE
62
+ */
63
+ function getSchemaChildren(schema) {
64
+ if (!schema) {
65
+ return;
66
+ }
67
+ if (!schema.props) {
68
+ return schema.children;
69
+ }
70
+ if (!schema.children) {
71
+ return schema.props.children;
72
+ }
73
+ if (!schema.props.children) {
74
+ return schema.children;
75
+ }
76
+ var result = [].concat(schema.children);
77
+ if (Array.isArray(schema.props.children)) {
78
+ result = result.concat(schema.props.children);
79
+ } else {
80
+ result.push(schema.props.children);
81
+ }
82
+ return result;
83
+ }
84
+ function baseRendererFactory() {
85
+ var _BaseRenderer;
86
+ var _adapter$getRenderers = _adapter["default"].getRenderers(),
87
+ customBaseRenderer = _adapter$getRenderers.BaseRenderer;
88
+ if (customBaseRenderer) {
89
+ return customBaseRenderer;
90
+ }
91
+ var _adapter$getRuntime = _adapter["default"].getRuntime(),
92
+ Component = _adapter$getRuntime.Component,
93
+ createElement = _adapter$getRuntime.createElement;
94
+ var Div = (0, _Div["default"])();
95
+ var VisualDom = (0, _VisualDom["default"])();
96
+ var AppContext = (0, _context6["default"])();
97
+ var DESIGN_MODE = {
98
+ EXTEND: 'extend',
99
+ BORDER: 'border',
100
+ PREVIEW: 'preview'
101
+ };
102
+ var OVERLAY_LIST = ['Dialog', 'Overlay', 'Animate', 'ConfigProvider'];
103
+ var DEFAULT_LOOP_ARG_ITEM = 'item';
104
+ var DEFAULT_LOOP_ARG_INDEX = 'index';
105
+ var scopeIdx = 0;
106
+ return _BaseRenderer = /*#__PURE__*/function (_Component) {
107
+ function BaseRenderer(_props2, context) {
108
+ var _props2$__schema;
109
+ var _this;
110
+ _this = _Component.call(this, _props2, context) || this;
111
+ _this.i18n = void 0;
112
+ _this.getLocale = void 0;
113
+ _this.setLocale = void 0;
114
+ _this.dataSourceMap = {};
115
+ _this.__namespace = 'base';
116
+ _this.__compScopes = {};
117
+ _this.__instanceMap = {};
118
+ _this.__dataHelper = void 0;
119
+ /**
120
+ * keep track of customMethods added to this context
121
+ *
122
+ * @type {any}
123
+ */
124
+ _this.__customMethodsList = [];
125
+ _this.__parseExpression = void 0;
126
+ _this.__ref = void 0;
127
+ /**
128
+ * reference of style element contains schema.css
129
+ *
130
+ * @type {any}
131
+ */
132
+ _this.__styleElement = void 0;
133
+ _this.reloadDataSource = function () {
134
+ return new Promise(function (resolve, reject) {
135
+ _this.__debug('reload data source');
136
+ if (!_this.__dataHelper) {
137
+ return resolve({});
138
+ }
139
+ _this.__dataHelper.getInitData().then(function (res) {
140
+ if ((0, _utils.isEmpty)(res)) {
141
+ _this.forceUpdate();
142
+ return resolve({});
143
+ }
144
+ _this.setState(res, resolve);
145
+ })["catch"](function (err) {
146
+ reject(err);
147
+ });
148
+ });
149
+ };
150
+ /**
151
+ * execute method in schema.lifeCycles
152
+ * @PRIVATE
153
+ */
154
+ _this.__executeLifeCycleMethod = function (method, args) {
155
+ executeLifeCycleMethod(_this, _this.props.__schema, method, args, _this.props.thisRequiredInJSE);
156
+ };
157
+ /**
158
+ * this method is for legacy purpose only, which used _ prefix instead of __ as private for some historical reasons
159
+ * @LEGACY
160
+ */
161
+ _this._getComponentView = function (componentName) {
162
+ var __components = _this.props.__components;
163
+ if (!__components) {
164
+ return;
165
+ }
166
+ return __components[componentName];
167
+ };
168
+ _this.__bindCustomMethods = function (props) {
169
+ var __schema = props.__schema;
170
+ var customMethodsList = Object.keys(__schema.methods || {}) || [];
171
+ (_this.__customMethodsList || []).forEach(function (item) {
172
+ if (!customMethodsList.includes(item)) {
173
+ delete _this[item];
174
+ }
175
+ });
176
+ _this.__customMethodsList = customMethodsList;
177
+ (0, _utils.forEach)(__schema.methods, function (val, key) {
178
+ var value = val;
179
+ if ((0, _lowcodeUtils.isJSExpression)(value) || (0, _lowcodeUtils.isJSFunction)(value)) {
180
+ value = _this.__parseExpression(value, _this);
181
+ }
182
+ if (typeof value !== 'function') {
183
+ _logger["default"].error("custom method " + key + " can not be parsed to a valid function", value);
184
+ return;
185
+ }
186
+ _this[key] = value.bind(_this);
187
+ });
188
+ };
189
+ _this.__generateCtx = function (ctx) {
190
+ var _this$context = _this.context,
191
+ pageContext = _this$context.pageContext,
192
+ compContext = _this$context.compContext;
193
+ var obj = (0, _extends2["default"])({
194
+ page: pageContext,
195
+ component: compContext
196
+ }, ctx);
197
+ (0, _utils.forEach)(obj, function (val, key) {
198
+ _this[key] = val;
199
+ });
200
+ };
201
+ _this.__parseData = function (data, ctx) {
202
+ var _this$props = _this.props,
203
+ __ctx = _this$props.__ctx,
204
+ thisRequiredInJSE = _this$props.thisRequiredInJSE,
205
+ componentName = _this$props.componentName;
206
+ return (0, _utils.parseData)(data, ctx || __ctx || _this, {
207
+ thisRequiredInJSE: thisRequiredInJSE,
208
+ logScope: componentName
209
+ });
210
+ };
211
+ _this.__initDataSource = function (props) {
212
+ var _props$__appHelper;
213
+ if (!props) {
214
+ return;
215
+ }
216
+ var schema = props.__schema || {};
217
+ var defaultDataSource = {
218
+ list: []
219
+ };
220
+ var dataSource = schema.dataSource || defaultDataSource;
221
+ // requestHandlersMap 存在才走数据源引擎方案
222
+ // TODO: 下面if else 抽成独立函数
223
+ var useDataSourceEngine = !!((_props$__appHelper = props.__appHelper) !== null && _props$__appHelper !== void 0 && _props$__appHelper.requestHandlersMap);
224
+ if (useDataSourceEngine) {
225
+ _this.__dataHelper = {
226
+ updateConfig: function updateConfig(updateDataSource) {
227
+ var _createDataSourceEngi = (0, _interpret.create)(updateDataSource !== null && updateDataSource !== void 0 ? updateDataSource : {}, _this, props.__appHelper.requestHandlersMap ? {
228
+ requestHandlersMap: props.__appHelper.requestHandlersMap
229
+ } : undefined),
230
+ dataSourceMap = _createDataSourceEngi.dataSourceMap,
231
+ reloadDataSource = _createDataSourceEngi.reloadDataSource;
232
+ _this.reloadDataSource = function () {
233
+ return new Promise(function (resolve) {
234
+ _this.__debug('reload data source');
235
+ reloadDataSource().then(function () {
236
+ resolve({});
237
+ });
238
+ });
239
+ };
240
+ return dataSourceMap;
241
+ }
242
+ };
243
+ _this.dataSourceMap = _this.__dataHelper.updateConfig(dataSource);
244
+ } else {
245
+ var appHelper = props.__appHelper;
246
+ _this.__dataHelper = new _utils.DataHelper(_this, dataSource, appHelper, function (config) {
247
+ return _this.__parseData(config);
248
+ });
249
+ _this.dataSourceMap = _this.__dataHelper.dataSourceMap;
250
+ _this.reloadDataSource = function () {
251
+ return new Promise(function (resolve, reject) {
252
+ _this.__debug('reload data source');
253
+ if (!_this.__dataHelper) {
254
+ return resolve({});
255
+ }
256
+ _this.__dataHelper.getInitData().then(function (res) {
257
+ if ((0, _utils.isEmpty)(res)) {
258
+ return resolve({});
259
+ }
260
+ _this.setState(res, resolve);
261
+ })["catch"](function (err) {
262
+ reject(err);
263
+ });
264
+ });
265
+ };
266
+ }
267
+ };
268
+ /**
269
+ * init i18n apis
270
+ * @PRIVATE
271
+ */
272
+ _this.__initI18nAPIs = function () {
273
+ _this.i18n = function (key, values) {
274
+ if (values === void 0) {
275
+ values = {};
276
+ }
277
+ var _this$props2 = _this.props,
278
+ locale = _this$props2.locale,
279
+ messages = _this$props2.messages;
280
+ return (0, _utils.getI18n)(key, values, locale, messages);
281
+ };
282
+ _this.getLocale = function () {
283
+ return _this.props.locale;
284
+ };
285
+ _this.setLocale = function (loc) {
286
+ var _this$appHelper, _this$appHelper$utils, _this$appHelper$utils2;
287
+ var setLocaleFn = (_this$appHelper = _this.appHelper) === null || _this$appHelper === void 0 ? void 0 : (_this$appHelper$utils = _this$appHelper.utils) === null || _this$appHelper$utils === void 0 ? void 0 : (_this$appHelper$utils2 = _this$appHelper$utils.i18n) === null || _this$appHelper$utils2 === void 0 ? void 0 : _this$appHelper$utils2.setLocale;
288
+ if (!setLocaleFn || typeof setLocaleFn !== 'function') {
289
+ _logger["default"].warn('initI18nAPIs Failed, i18n only works when appHelper.utils.i18n.setLocale() exists');
290
+ return undefined;
291
+ }
292
+ return setLocaleFn(loc);
293
+ };
294
+ };
295
+ /**
296
+ * write props.__schema.css to document as a style element,
297
+ * which will be added once and only once.
298
+ * @PRIVATE
299
+ */
300
+ _this.__writeCss = function (props) {
301
+ var css = (0, _utils.getValue)(props.__schema, 'css', '');
302
+ _this.__debug('create this.styleElement with css', css);
303
+ var style = _this.__styleElement;
304
+ if (!_this.__styleElement) {
305
+ style = document.createElement('style');
306
+ style.type = 'text/css';
307
+ style.setAttribute('from', 'style-sheet');
308
+ var head = document.head || document.getElementsByTagName('head')[0];
309
+ head.appendChild(style);
310
+ _this.__styleElement = style;
311
+ _this.__debug('this.styleElement is created', _this.__styleElement);
312
+ }
313
+ if (style.innerHTML === css) {
314
+ return;
315
+ }
316
+ style.innerHTML = css;
317
+ };
318
+ _this.__render = function () {
319
+ var schema = _this.props.__schema;
320
+ _this.__executeLifeCycleMethod('render');
321
+ _this.__writeCss(_this.props);
322
+ var engine = _this.context.engine;
323
+ if (engine) {
324
+ engine.props.onCompGetCtx(schema, _this);
325
+ // 画布场景才需要每次渲染bind自定义方法
326
+ if (_this.__designModeIsDesign) {
327
+ var _this$__dataHelper;
328
+ _this.__bindCustomMethods(_this.props);
329
+ _this.dataSourceMap = (_this$__dataHelper = _this.__dataHelper) === null || _this$__dataHelper === void 0 ? void 0 : _this$__dataHelper.updateConfig(schema.dataSource);
330
+ }
331
+ }
332
+ };
333
+ _this.__getRef = function (ref) {
334
+ var _engine$props;
335
+ var engine = _this.context.engine;
336
+ var __schema = _this.props.__schema;
337
+ ref && (engine === null || engine === void 0 ? void 0 : (_engine$props = engine.props) === null || _engine$props === void 0 ? void 0 : _engine$props.onCompGetRef(__schema, ref));
338
+ _this.__ref = ref;
339
+ };
340
+ _this.__createDom = function () {
341
+ var _this$props3 = _this.props,
342
+ __schema = _this$props3.__schema,
343
+ __ctx = _this$props3.__ctx,
344
+ _this$props3$__compon = _this$props3.__components,
345
+ __components = _this$props3$__compon === void 0 ? {} : _this$props3$__compon;
346
+ // merge defaultProps
347
+ var scopeProps = (0, _extends2["default"])({}, __schema.defaultProps, _this.props);
348
+ var scope = {
349
+ props: scopeProps
350
+ };
351
+ scope.__proto__ = __ctx || _this;
352
+ var _children = getSchemaChildren(__schema);
353
+ var Comp = __components[__schema.componentName];
354
+ if (!Comp) {
355
+ _this.__debug(__schema.componentName + " is invalid!");
356
+ }
357
+ var parentNodeInfo = {
358
+ schema: __schema,
359
+ Comp: _this.__getHOCWrappedComponent(Comp, __schema, scope)
360
+ };
361
+ return _this.__createVirtualDom(_children, scope, parentNodeInfo);
362
+ };
363
+ /**
364
+ * 将模型结构转换成react Element
365
+ * @param originalSchema schema
366
+ * @param originalScope scope
367
+ * @param parentInfo 父组件的信息,包含schema和Comp
368
+ * @param idx 为循环渲染的循环Index
369
+ */
370
+ _this.__createVirtualDom = function (originalSchema, originalScope, parentInfo, idx) {
371
+ if (idx === void 0) {
372
+ idx = '';
373
+ }
374
+ if (originalSchema === null || originalSchema === undefined) {
375
+ return null;
376
+ }
377
+ var scope = originalScope;
378
+ var schema = originalSchema;
379
+ var _ref = _this.context || {},
380
+ engine = _ref.engine;
381
+ if (!engine) {
382
+ _this.__debug('this.context.engine is invalid!');
383
+ return null;
384
+ }
385
+ try {
386
+ var _schema$props, _this$props$__contain, _this$props$__contain2, _engine$props3, _schema, _schema$__ctx;
387
+ var _ref2 = _this.props || {},
388
+ appHelper = _ref2.__appHelper,
389
+ _ref2$__components = _ref2.__components,
390
+ components = _ref2$__components === void 0 ? {} : _ref2$__components;
391
+ if ((0, _lowcodeUtils.isJSExpression)(schema)) {
392
+ return _this.__parseExpression(schema, scope);
393
+ }
394
+ if ((0, _lowcodeUtils.isI18nData)(schema)) {
395
+ return (0, _utils.parseI18n)(schema, scope);
396
+ }
397
+ if ((0, _utils.isJSSlot)(schema)) {
398
+ return _this.__createVirtualDom(schema.value, scope, parentInfo);
399
+ }
400
+ if (typeof schema === 'string') {
401
+ return schema;
402
+ }
403
+ if (typeof schema === 'number' || typeof schema === 'boolean') {
404
+ return String(schema);
405
+ }
406
+ if (Array.isArray(schema)) {
407
+ if (schema.length === 1) {
408
+ return _this.__createVirtualDom(schema[0], scope, parentInfo);
409
+ }
410
+ return schema.map(function (item, idy) {
411
+ var _ctx;
412
+ return _this.__createVirtualDom(item, scope, parentInfo, item !== null && item !== void 0 && (_ctx = item.__ctx) !== null && _ctx !== void 0 && _ctx.lceKey ? '' : String(idy));
413
+ });
414
+ }
415
+
416
+ // @ts-expect-error 如果直接转换好了,可以返回
417
+ if (schema.$$typeof) {
418
+ return schema;
419
+ }
420
+ var _children = getSchemaChildren(schema);
421
+ if (!schema.componentName) {
422
+ _logger["default"].error('The componentName in the schema is invalid, please check the schema: ', schema);
423
+ return;
424
+ }
425
+ // 解析占位组件
426
+ if (schema.componentName === 'Fragment' && _children) {
427
+ var tarChildren = (0, _lowcodeUtils.isJSExpression)(_children) ? _this.__parseExpression(_children, scope) : _children;
428
+ return _this.__createVirtualDom(tarChildren, scope, parentInfo);
429
+ }
430
+ if (schema.componentName === 'Text' && typeof ((_schema$props = schema.props) === null || _schema$props === void 0 ? void 0 : _schema$props.text) === 'string') {
431
+ var _schema$props2;
432
+ var text = (_schema$props2 = schema.props) === null || _schema$props2 === void 0 ? void 0 : _schema$props2.text;
433
+ schema = (0, _extends2["default"])({}, schema);
434
+ schema.children = [text];
435
+ }
436
+ if (!(0, _utils.isSchema)(schema)) {
437
+ return null;
438
+ }
439
+ var Comp = components[schema.componentName] || ((_this$props$__contain = _this.props.__container) === null || _this$props$__contain === void 0 ? void 0 : (_this$props$__contain2 = _this$props$__contain.components) === null || _this$props$__contain2 === void 0 ? void 0 : _this$props$__contain2[schema.componentName]);
440
+
441
+ // 容器类组件的上下文通过props传递,避免context传递带来的嵌套问题
442
+ var otherProps = (0, _utils.isFileSchema)(schema) ? {
443
+ __schema: schema,
444
+ __appHelper: appHelper,
445
+ __components: components
446
+ } : {};
447
+ if (!Comp) {
448
+ var _this$props$__contain3;
449
+ _logger["default"].error(schema.componentName + " component is not found in components list! component list is:", components || ((_this$props$__contain3 = _this.props.__container) === null || _this$props$__contain3 === void 0 ? void 0 : _this$props$__contain3.components));
450
+ return engine.createElement(engine.getNotFoundComponent(), {
451
+ componentName: schema.componentName,
452
+ componentId: schema.id,
453
+ enableStrictNotFoundMode: engine.props.enableStrictNotFoundMode,
454
+ ref: function ref(_ref3) {
455
+ var _engine$props2;
456
+ _ref3 && ((_engine$props2 = engine.props) === null || _engine$props2 === void 0 ? void 0 : _engine$props2.onCompGetRef(schema, _ref3));
457
+ }
458
+ }, _this.__getSchemaChildrenVirtualDom(schema, scope, Comp));
459
+ }
460
+ if (schema.loop != null) {
461
+ var loop = _this.__parseData(schema.loop, scope);
462
+ if (Array.isArray(loop) && loop.length === 0) return null;
463
+ var useLoop = (0, _isUseLoop["default"])(loop, _this.__designModeIsDesign);
464
+ if (useLoop) {
465
+ return _this.__createLoopVirtualDom((0, _extends2["default"])({}, schema, {
466
+ loop: loop
467
+ }), scope, parentInfo, idx);
468
+ }
469
+ }
470
+ var condition = schema.condition == null ? true : _this.__parseData(schema.condition, scope);
471
+
472
+ // DesignMode 为 design 情况下,需要进入 leaf Hoc,进行相关事件注册
473
+ var displayInHook = _this.__designModeIsDesign;
474
+ if (!condition && !displayInHook) {
475
+ return null;
476
+ }
477
+ var scopeKey = '';
478
+ // 判断组件是否需要生成scope,且只生成一次,挂在this.__compScopes上
479
+ if (Comp.generateScope) {
480
+ var _schema$props3;
481
+ var _key = _this.__parseExpression((_schema$props3 = schema.props) === null || _schema$props3 === void 0 ? void 0 : _schema$props3.key, scope);
482
+ if (_key) {
483
+ // 如果组件自己设置key则使用组件自己的key
484
+ scopeKey = _key;
485
+ } else if (!schema.__ctx) {
486
+ // 在生产环境schema没有__ctx上下文,需要手动生成一个lceKey
487
+ schema.__ctx = {
488
+ lceKey: "lce" + ++scopeIdx
489
+ };
490
+ scopeKey = schema.__ctx.lceKey;
491
+ } else {
492
+ // 需要判断循环的情况
493
+ scopeKey = schema.__ctx.lceKey + (idx !== undefined ? "_" + idx : '');
494
+ }
495
+ if (!_this.__compScopes[scopeKey]) {
496
+ _this.__compScopes[scopeKey] = Comp.generateScope(_this, schema);
497
+ }
498
+ }
499
+ // 如果组件有设置scope,需要为组件生成一个新的scope上下文
500
+ if (scopeKey && _this.__compScopes[scopeKey]) {
501
+ var compSelf = (0, _extends2["default"])({}, _this.__compScopes[scopeKey]);
502
+ compSelf.__proto__ = scope;
503
+ scope = compSelf;
504
+ }
505
+ if ((_engine$props3 = engine.props) !== null && _engine$props3 !== void 0 && _engine$props3.designMode) {
506
+ otherProps.__designMode = engine.props.designMode;
507
+ }
508
+ if (_this.__designModeIsDesign) {
509
+ otherProps.__tag = Math.random();
510
+ }
511
+ var componentInfo = {};
512
+ var props = _this.__getComponentProps(schema, scope, Comp, (0, _extends2["default"])({}, componentInfo, {
513
+ props: (0, _utils.transformArrayToMap)(componentInfo.props, 'name')
514
+ })) || {};
515
+ _this.__componentHOCs.forEach(function (ComponentConstruct) {
516
+ Comp = ComponentConstruct(Comp, {
517
+ schema: schema,
518
+ componentInfo: componentInfo,
519
+ baseRenderer: _this,
520
+ scope: scope
521
+ });
522
+ });
523
+ otherProps.ref = function (ref) {
524
+ var _engine$props4;
525
+ _this.$(props.fieldId || props.ref, ref); // 收集ref
526
+ var refProps = props.ref;
527
+ if (refProps && typeof refProps === 'string') {
528
+ _this[refProps] = ref;
529
+ }
530
+ ref && ((_engine$props4 = engine.props) === null || _engine$props4 === void 0 ? void 0 : _engine$props4.onCompGetRef(schema, ref));
531
+ };
532
+
533
+ // scope需要传入到组件上
534
+ if (scopeKey && _this.__compScopes[scopeKey]) {
535
+ props.__scope = _this.__compScopes[scopeKey];
536
+ }
537
+ if ((_schema = schema) !== null && _schema !== void 0 && (_schema$__ctx = _schema.__ctx) !== null && _schema$__ctx !== void 0 && _schema$__ctx.lceKey) {
538
+ if (!(0, _utils.isFileSchema)(schema)) {
539
+ var _engine$props5;
540
+ (_engine$props5 = engine.props) === null || _engine$props5 === void 0 ? void 0 : _engine$props5.onCompGetCtx(schema, scope);
541
+ }
542
+ props.key = props.key || schema.__ctx.lceKey + "_" + (schema.__ctx.idx || 0) + "_" + (idx !== undefined ? idx : '');
543
+ } else if ((typeof idx === 'number' || typeof idx === 'string') && !props.key) {
544
+ // 仅当循环场景走这里
545
+ props.key = idx;
546
+ }
547
+ props.__id = schema.id;
548
+ if (!props.key) {
549
+ props.key = props.__id;
550
+ }
551
+ var child = _this.__getSchemaChildrenVirtualDom(schema, scope, Comp, condition);
552
+ var renderComp = function renderComp(innerProps) {
553
+ return engine.createElement(Comp, innerProps, child);
554
+ };
555
+ // 设计模式下的特殊处理
556
+ if (engine && [DESIGN_MODE.EXTEND, DESIGN_MODE.BORDER].includes(engine.props.designMode)) {
557
+ // 对于overlay,dialog等组件为了使其在设计模式下显示,外层需要增加一个div容器
558
+ if (OVERLAY_LIST.includes(schema.componentName)) {
559
+ var ref = otherProps.ref,
560
+ overlayProps = (0, _objectWithoutPropertiesLoose2["default"])(otherProps, _excluded);
561
+ return createElement(Div, {
562
+ ref: ref,
563
+ __designMode: engine.props.designMode
564
+ }, renderComp((0, _extends2["default"])({}, props, overlayProps)));
565
+ }
566
+ // 虚拟dom显示
567
+ if (componentInfo !== null && componentInfo !== void 0 && componentInfo.parentRule) {
568
+ var parentList = componentInfo.parentRule.split(',');
569
+ var _parentInfo$schema = parentInfo.schema,
570
+ parentSchema = _parentInfo$schema === void 0 ? {
571
+ componentName: ''
572
+ } : _parentInfo$schema,
573
+ parentComp = parentInfo.Comp;
574
+ if (!parentList.includes(parentSchema.componentName) || parentComp !== components[parentSchema.componentName]) {
575
+ props.__componentName = schema.componentName;
576
+ Comp = VisualDom;
577
+ } else {
578
+ // 若虚拟dom在正常的渲染上下文中,就不显示设计模式了
579
+ props.__disableDesignMode = true;
580
+ }
581
+ }
582
+ }
583
+ return renderComp((0, _extends2["default"])({}, props, otherProps, {
584
+ __inner__: {
585
+ hidden: schema.hidden,
586
+ condition: condition
587
+ }
588
+ }));
589
+ } catch (e) {
590
+ return engine.createElement(engine.getFaultComponent(), {
591
+ error: e,
592
+ schema: schema,
593
+ self: scope,
594
+ parentInfo: parentInfo,
595
+ idx: idx
596
+ });
597
+ }
598
+ };
599
+ _this.__getSchemaChildrenVirtualDom = function (schema, scope, Comp, condition) {
600
+ if (condition === void 0) {
601
+ condition = true;
602
+ }
603
+ var children = condition ? getSchemaChildren(schema) : null;
604
+
605
+ // @todo 补完这里的 Element 定义 @承虎
606
+ var result = [];
607
+ if (children) {
608
+ if (!Array.isArray(children)) {
609
+ children = [children];
610
+ }
611
+ children.forEach(function (child) {
612
+ var childVirtualDom = _this.__createVirtualDom((0, _lowcodeUtils.isJSExpression)(child) ? _this.__parseExpression(child, scope) : child, scope, {
613
+ schema: schema,
614
+ Comp: Comp
615
+ });
616
+ result.push(childVirtualDom);
617
+ });
618
+ }
619
+ if (result && result.length > 0) {
620
+ return result;
621
+ }
622
+ return null;
623
+ };
624
+ _this.__getComponentProps = function (schema, scope, Comp, componentInfo) {
625
+ if (!schema) {
626
+ return {};
627
+ }
628
+ return _this.__parseProps(schema === null || schema === void 0 ? void 0 : schema.props, scope, '', {
629
+ schema: schema,
630
+ Comp: Comp,
631
+ componentInfo: (0, _extends2["default"])({}, componentInfo || {}, {
632
+ props: (0, _utils.transformArrayToMap)((componentInfo || {}).props, 'name')
633
+ })
634
+ }) || {};
635
+ };
636
+ _this.__createLoopVirtualDom = function (schema, scope, parentInfo, idx) {
637
+ if ((0, _utils.isFileSchema)(schema)) {
638
+ _logger["default"].warn('file type not support Loop');
639
+ return null;
640
+ }
641
+ if (!Array.isArray(schema.loop)) {
642
+ return null;
643
+ }
644
+ var itemArg = schema.loopArgs && schema.loopArgs[0] || DEFAULT_LOOP_ARG_ITEM;
645
+ var indexArg = schema.loopArgs && schema.loopArgs[1] || DEFAULT_LOOP_ARG_INDEX;
646
+ var loop = schema.loop;
647
+ return loop.map(function (item, i) {
648
+ var _loopSelf, _schema$props4, _schema$props5;
649
+ var loopSelf = (_loopSelf = {}, _loopSelf[itemArg] = item, _loopSelf[indexArg] = i, _loopSelf);
650
+ loopSelf.__proto__ = scope;
651
+ return _this.__createVirtualDom((0, _extends2["default"])({}, schema, {
652
+ loop: undefined,
653
+ props: (0, _extends2["default"])({}, schema.props, {
654
+ // 循环下 key 不能为常量,这样会造成 key 值重复,渲染异常
655
+ key: (0, _lowcodeUtils.isJSExpression)((_schema$props4 = schema.props) === null || _schema$props4 === void 0 ? void 0 : _schema$props4.key) ? (_schema$props5 = schema.props) === null || _schema$props5 === void 0 ? void 0 : _schema$props5.key : null
656
+ })
657
+ }), loopSelf, parentInfo, idx ? idx + "_" + i : i);
658
+ });
659
+ };
660
+ _this.__parseProps = function (originalProps, scope, path, info) {
661
+ var _propInfo$extra;
662
+ var props = originalProps;
663
+ var schema = info.schema,
664
+ Comp = info.Comp,
665
+ _info$componentInfo = info.componentInfo,
666
+ componentInfo = _info$componentInfo === void 0 ? {} : _info$componentInfo;
667
+ var propInfo = (0, _utils.getValue)(componentInfo.props, path);
668
+ // FIXME: 将这行逻辑外置,解耦,线上环境不要验证参数,调试环境可以有,通过传参自定义
669
+ var propType = propInfo === null || propInfo === void 0 ? void 0 : (_propInfo$extra = propInfo.extra) === null || _propInfo$extra === void 0 ? void 0 : _propInfo$extra.propType;
670
+ var checkProps = function checkProps(value) {
671
+ if (!propType) {
672
+ return value;
673
+ }
674
+ return (0, _lowcodeUtils.checkPropTypes)(value, path, propType, componentInfo.name) ? value : undefined;
675
+ };
676
+ var parseReactNode = function parseReactNode(data, params) {
677
+ if ((0, _utils.isEmpty)(params)) {
678
+ var virtualDom = _this.__createVirtualDom(data, scope, {
679
+ schema: schema,
680
+ Comp: Comp
681
+ });
682
+ return checkProps(virtualDom);
683
+ }
684
+ return checkProps(function () {
685
+ for (var _len = arguments.length, argValues = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
686
+ argValues[_key2] = arguments[_key2];
687
+ }
688
+ var args = {};
689
+ if (Array.isArray(params) && params.length) {
690
+ params.forEach(function (item, idx) {
691
+ if (typeof item === 'string') {
692
+ args[item] = argValues[idx];
693
+ } else if (item && typeof item === 'object') {
694
+ args[item.name] = argValues[idx];
695
+ }
696
+ });
697
+ }
698
+ args.__proto__ = scope;
699
+ return scope.__createVirtualDom(data, args, {
700
+ schema: schema,
701
+ Comp: Comp
702
+ });
703
+ });
704
+ };
705
+ if ((0, _lowcodeUtils.isJSExpression)(props)) {
706
+ props = _this.__parseExpression(props, scope);
707
+ // 只有当变量解析出来为模型结构的时候才会继续解析
708
+ if (!(0, _utils.isSchema)(props) && !(0, _utils.isJSSlot)(props)) {
709
+ return checkProps(props);
710
+ }
711
+ }
712
+ var handleI18nData = function handleI18nData(innerProps) {
713
+ return innerProps[innerProps.use || _this.getLocale && _this.getLocale() || 'zh-CN'];
714
+ };
715
+
716
+ // @LEGACY 兼容老平台设计态 i18n 数据
717
+ if ((0, _lowcodeUtils.isI18nData)(props)) {
718
+ var i18nProp = handleI18nData(props);
719
+ if (i18nProp) {
720
+ props = i18nProp;
721
+ } else {
722
+ return (0, _utils.parseI18n)(props, scope);
723
+ }
724
+ }
725
+
726
+ // @LEGACY 兼容老平台设计态的变量绑定
727
+ if ((0, _utils.isVariable)(props)) {
728
+ props = props.value;
729
+ if ((0, _lowcodeUtils.isI18nData)(props)) {
730
+ props = handleI18nData(props);
731
+ }
732
+ }
733
+ if ((0, _lowcodeUtils.isJSFunction)(props)) {
734
+ props = (0, _utils.transformStringToFunction)(props.value);
735
+ }
736
+ if ((0, _utils.isJSSlot)(props)) {
737
+ var _props3 = props,
738
+ params = _props3.params,
739
+ value = _props3.value;
740
+ if (!(0, _utils.isSchema)(value) || (0, _utils.isEmpty)(value)) {
741
+ return undefined;
742
+ }
743
+ return parseReactNode(value, params);
744
+ }
745
+
746
+ // 兼容通过componentInfo判断的情况
747
+ if ((0, _utils.isSchema)(props)) {
748
+ var _propInfo$props, _propInfo$props2, _propInfo$props2$type, _propInfo$props3, _propInfo$props3$reac;
749
+ var isReactNodeFunction = !!((propInfo === null || propInfo === void 0 ? void 0 : propInfo.type) === 'ReactNode' && (propInfo === null || propInfo === void 0 ? void 0 : (_propInfo$props = propInfo.props) === null || _propInfo$props === void 0 ? void 0 : _propInfo$props.type) === 'function');
750
+ var isMixinReactNodeFunction = !!((propInfo === null || propInfo === void 0 ? void 0 : propInfo.type) === 'Mixin' && (propInfo === null || propInfo === void 0 ? void 0 : (_propInfo$props2 = propInfo.props) === null || _propInfo$props2 === void 0 ? void 0 : (_propInfo$props2$type = _propInfo$props2.types) === null || _propInfo$props2$type === void 0 ? void 0 : _propInfo$props2$type.indexOf('ReactNode')) > -1 && (propInfo === null || propInfo === void 0 ? void 0 : (_propInfo$props3 = propInfo.props) === null || _propInfo$props3 === void 0 ? void 0 : (_propInfo$props3$reac = _propInfo$props3.reactNodeProps) === null || _propInfo$props3$reac === void 0 ? void 0 : _propInfo$props3$reac.type) === 'function');
751
+ var _params = null;
752
+ if (isReactNodeFunction) {
753
+ var _propInfo$props4;
754
+ _params = propInfo === null || propInfo === void 0 ? void 0 : (_propInfo$props4 = propInfo.props) === null || _propInfo$props4 === void 0 ? void 0 : _propInfo$props4.params;
755
+ } else if (isMixinReactNodeFunction) {
756
+ var _propInfo$props5, _propInfo$props5$reac;
757
+ _params = propInfo === null || propInfo === void 0 ? void 0 : (_propInfo$props5 = propInfo.props) === null || _propInfo$props5 === void 0 ? void 0 : (_propInfo$props5$reac = _propInfo$props5.reactNodeProps) === null || _propInfo$props5$reac === void 0 ? void 0 : _propInfo$props5$reac.params;
758
+ }
759
+ return parseReactNode(props, _params);
760
+ }
761
+ if (Array.isArray(props)) {
762
+ return checkProps(props.map(function (item, idx) {
763
+ return _this.__parseProps(item, scope, path ? path + "." + idx : "" + idx, info);
764
+ }));
765
+ }
766
+ if (typeof props === 'function') {
767
+ return checkProps(props.bind(scope));
768
+ }
769
+ if (props && typeof props === 'object') {
770
+ if (props.$$typeof) {
771
+ return checkProps(props);
772
+ }
773
+ var res = {};
774
+ (0, _utils.forEach)(props, function (val, key) {
775
+ if (key.startsWith('__')) {
776
+ res[key] = val;
777
+ return;
778
+ }
779
+ res[key] = _this.__parseProps(val, scope, path ? path + "." + key : key, info);
780
+ });
781
+ return checkProps(res);
782
+ }
783
+ return checkProps(props);
784
+ };
785
+ _this.__debug = function () {
786
+ _logger["default"].debug.apply(_logger["default"], arguments);
787
+ };
788
+ _this.__renderContextProvider = function (customProps, children) {
789
+ return createElement(AppContext.Provider, {
790
+ value: (0, _extends2["default"])({}, _this.context, {
791
+ blockContext: _this
792
+ }, customProps || {}),
793
+ children: children || _this.__createDom()
794
+ });
795
+ };
796
+ _this.__renderContextConsumer = function (children) {
797
+ return createElement(AppContext.Consumer, {}, children);
798
+ };
799
+ _this.__checkSchema = function (schema, originalExtraComponents) {
800
+ var _schema$componentName;
801
+ if (originalExtraComponents === void 0) {
802
+ originalExtraComponents = [];
803
+ }
804
+ var extraComponents = originalExtraComponents;
805
+ if (typeof extraComponents === 'string') {
806
+ extraComponents = [extraComponents];
807
+ }
808
+ var builtin = (0, _utils.capitalizeFirstLetter)(_this.__namespace);
809
+ var componentNames = [builtin].concat(extraComponents);
810
+ return !(0, _utils.isSchema)(schema) || !componentNames.includes((_schema$componentName = schema === null || schema === void 0 ? void 0 : schema.componentName) !== null && _schema$componentName !== void 0 ? _schema$componentName : '');
811
+ };
812
+ _this.context = context;
813
+ _this.__parseExpression = function (str, self) {
814
+ return (0, _utils.parseExpression)({
815
+ str: str,
816
+ self: self,
817
+ thisRequired: _props2 === null || _props2 === void 0 ? void 0 : _props2.thisRequiredInJSE,
818
+ logScope: _props2.componentName
819
+ });
820
+ };
821
+ _this.__beforeInit(_props2);
822
+ _this.__init(_props2);
823
+ _this.__afterInit(_props2);
824
+ _this.__debug("constructor - " + (_props2 === null || _props2 === void 0 ? void 0 : (_props2$__schema = _props2.__schema) === null || _props2$__schema === void 0 ? void 0 : _props2$__schema.fileName));
825
+ return _this;
826
+ }
827
+
828
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
829
+ (0, _inheritsLoose2["default"])(BaseRenderer, _Component);
830
+ var _proto = BaseRenderer.prototype;
831
+ _proto.__beforeInit = function __beforeInit(_props) {};
832
+ _proto.__init = function __init(props) {
833
+ this.__compScopes = {};
834
+ this.__instanceMap = {};
835
+ this.__bindCustomMethods(props);
836
+ this.__initI18nAPIs();
837
+ }
838
+
839
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
840
+ ;
841
+ _proto.__afterInit = function __afterInit(_props) {};
842
+ BaseRenderer.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
843
+ var result = executeLifeCycleMethod(this, props === null || props === void 0 ? void 0 : props.__schema, 'getDerivedStateFromProps', [props, state], props.thisRequiredInJSE);
844
+ return result === undefined ? null : result;
845
+ };
846
+ _proto.getSnapshotBeforeUpdate = /*#__PURE__*/function () {
847
+ var _getSnapshotBeforeUpdate = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
848
+ var _this$props4, _this$props4$__schema;
849
+ var _len2,
850
+ args,
851
+ _key3,
852
+ _args = arguments;
853
+ return _regenerator["default"].wrap(function (_context) {
854
+ while (1) switch (_context.prev = _context.next) {
855
+ case 0:
856
+ for (_len2 = _args.length, args = new Array(_len2), _key3 = 0; _key3 < _len2; _key3++) {
857
+ args[_key3] = _args[_key3];
858
+ }
859
+ this.__executeLifeCycleMethod('getSnapshotBeforeUpdate', args);
860
+ this.__debug("getSnapshotBeforeUpdate - " + ((_this$props4 = this.props) === null || _this$props4 === void 0 ? void 0 : (_this$props4$__schema = _this$props4.__schema) === null || _this$props4$__schema === void 0 ? void 0 : _this$props4$__schema.fileName));
861
+ case 1:
862
+ case "end":
863
+ return _context.stop();
864
+ }
865
+ }, _callee, this);
866
+ }));
867
+ function getSnapshotBeforeUpdate() {
868
+ return _getSnapshotBeforeUpdate.apply(this, arguments);
869
+ }
870
+ return getSnapshotBeforeUpdate;
871
+ }();
872
+ _proto.componentDidMount = /*#__PURE__*/function () {
873
+ var _componentDidMount = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
874
+ var _this$props5, _this$props5$__schema;
875
+ var _len3,
876
+ args,
877
+ _key4,
878
+ _args2 = arguments;
879
+ return _regenerator["default"].wrap(function (_context2) {
880
+ while (1) switch (_context2.prev = _context2.next) {
881
+ case 0:
882
+ this.reloadDataSource();
883
+ for (_len3 = _args2.length, args = new Array(_len3), _key4 = 0; _key4 < _len3; _key4++) {
884
+ args[_key4] = _args2[_key4];
885
+ }
886
+ this.__executeLifeCycleMethod('componentDidMount', args);
887
+ this.__debug("componentDidMount - " + ((_this$props5 = this.props) === null || _this$props5 === void 0 ? void 0 : (_this$props5$__schema = _this$props5.__schema) === null || _this$props5$__schema === void 0 ? void 0 : _this$props5$__schema.fileName));
888
+ case 1:
889
+ case "end":
890
+ return _context2.stop();
891
+ }
892
+ }, _callee2, this);
893
+ }));
894
+ function componentDidMount() {
895
+ return _componentDidMount.apply(this, arguments);
896
+ }
897
+ return componentDidMount;
898
+ }();
899
+ _proto.componentDidUpdate = /*#__PURE__*/function () {
900
+ var _componentDidUpdate = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3() {
901
+ var _len4,
902
+ args,
903
+ _key5,
904
+ _args3 = arguments;
905
+ return _regenerator["default"].wrap(function (_context3) {
906
+ while (1) switch (_context3.prev = _context3.next) {
907
+ case 0:
908
+ for (_len4 = _args3.length, args = new Array(_len4), _key5 = 0; _key5 < _len4; _key5++) {
909
+ args[_key5] = _args3[_key5];
910
+ }
911
+ this.__executeLifeCycleMethod('componentDidUpdate', args);
912
+ this.__debug("componentDidUpdate - " + this.props.__schema.fileName);
913
+ case 1:
914
+ case "end":
915
+ return _context3.stop();
916
+ }
917
+ }, _callee3, this);
918
+ }));
919
+ function componentDidUpdate() {
920
+ return _componentDidUpdate.apply(this, arguments);
921
+ }
922
+ return componentDidUpdate;
923
+ }();
924
+ _proto.componentWillUnmount = /*#__PURE__*/function () {
925
+ var _componentWillUnmount = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4() {
926
+ var _this$props6, _this$props6$__schema;
927
+ var _len5,
928
+ args,
929
+ _key6,
930
+ _args4 = arguments;
931
+ return _regenerator["default"].wrap(function (_context4) {
932
+ while (1) switch (_context4.prev = _context4.next) {
933
+ case 0:
934
+ for (_len5 = _args4.length, args = new Array(_len5), _key6 = 0; _key6 < _len5; _key6++) {
935
+ args[_key6] = _args4[_key6];
936
+ }
937
+ this.__executeLifeCycleMethod('componentWillUnmount', args);
938
+ this.__debug("componentWillUnmount - " + ((_this$props6 = this.props) === null || _this$props6 === void 0 ? void 0 : (_this$props6$__schema = _this$props6.__schema) === null || _this$props6$__schema === void 0 ? void 0 : _this$props6$__schema.fileName));
939
+ case 1:
940
+ case "end":
941
+ return _context4.stop();
942
+ }
943
+ }, _callee4, this);
944
+ }));
945
+ function componentWillUnmount() {
946
+ return _componentWillUnmount.apply(this, arguments);
947
+ }
948
+ return componentWillUnmount;
949
+ }();
950
+ _proto.componentDidCatch = /*#__PURE__*/function () {
951
+ var _componentDidCatch = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5() {
952
+ var _len6,
953
+ args,
954
+ _key7,
955
+ _args5 = arguments;
956
+ return _regenerator["default"].wrap(function (_context5) {
957
+ while (1) switch (_context5.prev = _context5.next) {
958
+ case 0:
959
+ for (_len6 = _args5.length, args = new Array(_len6), _key7 = 0; _key7 < _len6; _key7++) {
960
+ args[_key7] = _args5[_key7];
961
+ }
962
+ this.__executeLifeCycleMethod('componentDidCatch', args);
963
+ _logger["default"].warn(args);
964
+ case 1:
965
+ case "end":
966
+ return _context5.stop();
967
+ }
968
+ }, _callee5, this);
969
+ }));
970
+ function componentDidCatch() {
971
+ return _componentDidCatch.apply(this, arguments);
972
+ }
973
+ return componentDidCatch;
974
+ }();
975
+ _proto.shouldComponentUpdate = function shouldComponentUpdate() {
976
+ var _this$props$getSchema, _this$props7, _this$props$__contain4;
977
+ if ((_this$props$getSchema = (_this$props7 = this.props).getSchemaChangedSymbol) !== null && _this$props$getSchema !== void 0 && _this$props$getSchema.call(_this$props7) && (_this$props$__contain4 = this.props.__container) !== null && _this$props$__contain4 !== void 0 && _this$props$__contain4.rerender) {
978
+ var _this$props$__contain5;
979
+ (_this$props$__contain5 = this.props.__container) === null || _this$props$__contain5 === void 0 ? void 0 : _this$props$__contain5.rerender();
980
+ return false;
981
+ }
982
+ return true;
983
+ };
984
+ _proto.forceUpdate = function forceUpdate() {
985
+ if (this.shouldComponentUpdate()) {
986
+ _Component.prototype.forceUpdate.call(this);
987
+ }
988
+ };
989
+ _proto.$ = function $(filedId, instance) {
990
+ this.__instanceMap = this.__instanceMap || {};
991
+ if (!filedId || typeof filedId !== 'string') {
992
+ return this.__instanceMap;
993
+ }
994
+ if (instance) {
995
+ this.__instanceMap[filedId] = instance;
996
+ }
997
+ return this.__instanceMap[filedId];
998
+ };
999
+ _proto.__getHOCWrappedComponent = function __getHOCWrappedComponent(OriginalComp, schema, scope) {
1000
+ var _this2 = this;
1001
+ var Comp = OriginalComp;
1002
+ this.__componentHOCs.forEach(function (ComponentConstruct) {
1003
+ Comp = ComponentConstruct(Comp || Div, {
1004
+ schema: schema,
1005
+ componentInfo: {},
1006
+ baseRenderer: _this2,
1007
+ scope: scope
1008
+ });
1009
+ });
1010
+ return Comp;
1011
+ };
1012
+ _proto.__renderComp = function __renderComp(OriginalComp, ctxProps) {
1013
+ var Comp = OriginalComp;
1014
+ var _this$props8 = this.props,
1015
+ __schema = _this$props8.__schema,
1016
+ __ctx = _this$props8.__ctx;
1017
+ var scope = {};
1018
+ scope.__proto__ = __ctx || this;
1019
+ Comp = this.__getHOCWrappedComponent(Comp, __schema, scope);
1020
+ var data = this.__parseProps(__schema === null || __schema === void 0 ? void 0 : __schema.props, scope, '', {
1021
+ schema: __schema,
1022
+ Comp: Comp,
1023
+ componentInfo: {}
1024
+ });
1025
+ var className = data.className;
1026
+ var otherProps = {};
1027
+ var _ref4 = this.context || {},
1028
+ engine = _ref4.engine;
1029
+ if (!engine) {
1030
+ return null;
1031
+ }
1032
+ if (this.__designModeIsDesign) {
1033
+ otherProps.__tag = Math.random();
1034
+ }
1035
+ var child = engine.createElement(Comp, (0, _extends2["default"])({}, data, this.props, {
1036
+ ref: this.__getRef,
1037
+ className: (0, _classnames["default"])((0, _utils.getFileCssName)(__schema === null || __schema === void 0 ? void 0 : __schema.fileName), className, this.props.className),
1038
+ __id: __schema === null || __schema === void 0 ? void 0 : __schema.id
1039
+ }, otherProps), this.__createDom());
1040
+ return this.__renderContextProvider(ctxProps, child);
1041
+ };
1042
+ _proto.__renderContent = function __renderContent(children) {
1043
+ var __schema = this.props.__schema;
1044
+ var parsedProps = this.__parseData(__schema.props);
1045
+ var className = (0, _classnames["default"])("lce-" + this.__namespace, (0, _utils.getFileCssName)(__schema.fileName), parsedProps.className, this.props.className);
1046
+ var style = (0, _extends2["default"])({}, parsedProps.style || {}, typeof this.props.style === 'object' ? this.props.style : {});
1047
+ var id = this.props.id || parsedProps.id;
1048
+ return createElement('div', {
1049
+ ref: this.__getRef,
1050
+ className: className,
1051
+ id: id,
1052
+ style: style
1053
+ }, children);
1054
+ };
1055
+ _proto.render = function render() {
1056
+ return null;
1057
+ };
1058
+ return (0, _createClass2["default"])(BaseRenderer, [{
1059
+ key: "__componentHOCs",
1060
+ get:
1061
+ /**
1062
+ * get Component HOCs
1063
+ *
1064
+ * @readonly
1065
+ * @type {IComponentConstruct[]}
1066
+ */
1067
+ function get() {
1068
+ if (this.__designModeIsDesign) {
1069
+ return [_leaf.leafWrapper, _hoc.compWrapper];
1070
+ }
1071
+ return [_hoc.compWrapper];
1072
+ }
1073
+ }, {
1074
+ key: "__designModeIsDesign",
1075
+ get: function get() {
1076
+ var _engine$props6;
1077
+ var _ref5 = this.context || {},
1078
+ engine = _ref5.engine;
1079
+ return (engine === null || engine === void 0 ? void 0 : (_engine$props6 = engine.props) === null || _engine$props6 === void 0 ? void 0 : _engine$props6.designMode) === 'design';
1080
+ }
1081
+ }, {
1082
+ key: "appHelper",
1083
+ get: function get() {
1084
+ return this.props.__appHelper;
1085
+ }
1086
+ }, {
1087
+ key: "requestHandlersMap",
1088
+ get: function get() {
1089
+ var _this$appHelper2;
1090
+ return (_this$appHelper2 = this.appHelper) === null || _this$appHelper2 === void 0 ? void 0 : _this$appHelper2.requestHandlersMap;
1091
+ }
1092
+ }, {
1093
+ key: "utils",
1094
+ get: function get() {
1095
+ var _this$appHelper3;
1096
+ return (_this$appHelper3 = this.appHelper) === null || _this$appHelper3 === void 0 ? void 0 : _this$appHelper3.utils;
1097
+ }
1098
+ }, {
1099
+ key: "constants",
1100
+ get: function get() {
1101
+ var _this$appHelper4;
1102
+ return (_this$appHelper4 = this.appHelper) === null || _this$appHelper4 === void 0 ? void 0 : _this$appHelper4.constants;
1103
+ }
1104
+ }, {
1105
+ key: "history",
1106
+ get: function get() {
1107
+ var _this$appHelper5;
1108
+ return (_this$appHelper5 = this.appHelper) === null || _this$appHelper5 === void 0 ? void 0 : _this$appHelper5.history;
1109
+ }
1110
+ }, {
1111
+ key: "location",
1112
+ get: function get() {
1113
+ var _this$appHelper6;
1114
+ return (_this$appHelper6 = this.appHelper) === null || _this$appHelper6 === void 0 ? void 0 : _this$appHelper6.location;
1115
+ }
1116
+ }, {
1117
+ key: "match",
1118
+ get: function get() {
1119
+ var _this$appHelper7;
1120
+ return (_this$appHelper7 = this.appHelper) === null || _this$appHelper7 === void 0 ? void 0 : _this$appHelper7.match;
1121
+ }
1122
+ }]);
1123
+ }(Component), _BaseRenderer.displayName = 'BaseRenderer', _BaseRenderer.defaultProps = {
1124
+ __schema: {}
1125
+ }, _BaseRenderer.contextType = AppContext, _BaseRenderer;
1126
+ }