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