@easy-editor/react-renderer 0.0.18 → 1.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 (50) hide show
  1. package/README.md +12 -1
  2. package/dist/adapter/index.d.ts +17 -0
  3. package/dist/{renderer-core/base.d.ts → base.d.ts} +2 -2
  4. package/dist/component.d.ts +2 -0
  5. package/dist/components/FaultComponent.d.ts +4 -0
  6. package/dist/components/NotFoundComponent.d.ts +4 -0
  7. package/dist/{renderer-core/hoc → hoc}/leaf.d.ts +2 -1
  8. package/dist/{cjs/index.js → index.cjs} +406 -1894
  9. package/dist/index.d.ts +10 -3
  10. package/dist/index.js +353 -1823
  11. package/dist/page.d.ts +2 -0
  12. package/dist/renderer.d.ts +2 -0
  13. package/dist/setting-renderer/context.d.ts +8 -0
  14. package/dist/setting-renderer/index.d.ts +8 -0
  15. package/dist/types.d.ts +7 -0
  16. package/dist/utils/index.d.ts +2 -0
  17. package/dist/utils/is.d.ts +3 -0
  18. package/package.json +15 -20
  19. package/dist/cjs/index.development.js +0 -4013
  20. package/dist/cjs/index.development.js.map +0 -1
  21. package/dist/cjs/index.js.map +0 -1
  22. package/dist/cjs/index.production.js +0 -4013
  23. package/dist/cjs/index.production.js.map +0 -1
  24. package/dist/configure-renderer/context.d.ts +0 -13
  25. package/dist/configure-renderer/index.d.ts +0 -10
  26. package/dist/esm/index.development.js +0 -3977
  27. package/dist/esm/index.development.js.map +0 -1
  28. package/dist/esm/index.js +0 -3977
  29. package/dist/esm/index.js.map +0 -1
  30. package/dist/esm/index.production.js +0 -3977
  31. package/dist/esm/index.production.js.map +0 -1
  32. package/dist/renderer-core/adapter/index.d.ts +0 -17
  33. package/dist/renderer-core/component.d.ts +0 -2
  34. package/dist/renderer-core/components/FaultComponent.d.ts +0 -7
  35. package/dist/renderer-core/components/NotFoundComponent.d.ts +0 -7
  36. package/dist/renderer-core/index.d.ts +0 -9
  37. package/dist/renderer-core/page.d.ts +0 -2
  38. package/dist/renderer-core/renderer.d.ts +0 -2
  39. package/dist/renderer-core/types.d.ts +0 -202
  40. package/dist/renderer-core/utils/classnames.d.ts +0 -1
  41. package/dist/renderer-core/utils/common.d.ts +0 -59
  42. package/dist/renderer-core/utils/data-helper.d.ts +0 -83
  43. package/dist/renderer-core/utils/index.d.ts +0 -4
  44. package/dist/renderer-core/utils/logger.d.ts +0 -5
  45. package/dist/renderer-core/utils/request.d.ts +0 -43
  46. /package/dist/{renderer-core/context.d.ts → context.d.ts} +0 -0
  47. /package/dist/{renderer-core/hoc → hoc}/comp.d.ts +0 -0
  48. /package/dist/{renderer-core/hoc → hoc}/index.d.ts +0 -0
  49. /package/dist/{configure-renderer → setting-renderer}/SettingSetter.d.ts +0 -0
  50. /package/dist/{renderer-core/utils → utils}/hoc.d.ts +0 -0
@@ -1,3977 +0,0 @@
1
- import { observer } from 'mobx-react';
2
- import { createContext, useContext, useMemo, Component, forwardRef, createElement, PureComponent } from 'react';
3
- import { isSetterConfig, isJSExpression, isJSFunction, createLogger, DESIGNER_EVENT, TRANSFORM_STAGE, logger as logger$1 } from '@easy-editor/core';
4
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
-
6
- const SettingRendererContext = /*#__PURE__*/createContext({});
7
- const useSettingRendererContext = () => {
8
- try {
9
- return useContext(SettingRendererContext);
10
- } catch (error) {
11
- console.warn('useSettingRendererContext must be used within a SettingRendererContextProvider');
12
- }
13
- return {};
14
- };
15
-
16
- const getSetterInfo = field => {
17
- const {
18
- extraProps,
19
- setter
20
- } = field;
21
- const {
22
- defaultValue
23
- } = extraProps;
24
- let setterProps = {};
25
- let setterType;
26
- let initialValue = null;
27
- if (isSetterConfig(setter)) {
28
- setterType = setter.componentName;
29
- if (setter.props) {
30
- setterProps = setter.props;
31
- if (typeof setterProps === 'function') {
32
- setterProps = setterProps(field);
33
- }
34
- }
35
- if (setter.defaultValue != null) {
36
- initialValue = setter.defaultValue;
37
- }
38
- } else if (setter) {
39
- setterType = setter;
40
- }
41
- if (defaultValue != null && !('defaultValue' in setterProps)) {
42
- setterProps.defaultValue = defaultValue;
43
- if (initialValue == null) {
44
- initialValue = defaultValue;
45
- }
46
- }
47
- if (field.valueState === -1) {
48
- setterProps.multiValue = true;
49
- }
50
-
51
- // 根据是否支持变量配置做相应的更改
52
- const supportVariable = field.extraProps?.supportVariable;
53
- const isUseVariableSetter = supportVariable;
54
- if (isUseVariableSetter === false) {
55
- return {
56
- setterProps,
57
- initialValue,
58
- setterType
59
- };
60
- }
61
- return {
62
- setterProps,
63
- setterType,
64
- initialValue
65
- };
66
- };
67
- const SettingSetter = observer(({
68
- field,
69
- children
70
- }) => {
71
- const {
72
- setterManager
73
- } = useSettingRendererContext();
74
- const {
75
- extraProps
76
- } = field;
77
- const visible = extraProps?.condition && typeof extraProps.condition === 'function' ? extraProps.condition(field) !== false : true;
78
- if (!visible) {
79
- return null;
80
- }
81
- const {
82
- setterProps = {},
83
- setterType,
84
- initialValue = null
85
- } = getSetterInfo(field);
86
- const onChange = extraProps?.onChange;
87
- const value = field.valueState === -1 ? null : field.getValue();
88
- const {
89
- component: SetterComponent,
90
- props: mixedSetterProps
91
- } = setterManager.createSetterContent(setterType, setterProps);
92
- return /*#__PURE__*/jsx(SetterComponent, {
93
- field: field,
94
- selected: field.top?.getNode(),
95
- initialValue: initialValue,
96
- value: value,
97
- onChange: newVal => {
98
- field.setValue(newVal);
99
- onChange?.(field, newVal);
100
- },
101
- onInitial: () => {
102
- if (initialValue == null) {
103
- return;
104
- }
105
- const value = typeof initialValue === 'function' ? initialValue(field) : initialValue;
106
- field.setValue(value, true);
107
- },
108
- removeProp: () => {
109
- if (field.name) {
110
- field.parent.clearPropValue(field.name);
111
- }
112
- },
113
- ...mixedSetterProps,
114
- children: children
115
- }, field.id);
116
- });
117
-
118
- const SettingFieldItem = observer(({
119
- field
120
- }) => {
121
- const {
122
- customFieldItem
123
- } = useSettingRendererContext();
124
- if (customFieldItem) {
125
- return customFieldItem(field, /*#__PURE__*/jsx(SettingSetter, {
126
- field: field
127
- }));
128
- }
129
- return /*#__PURE__*/jsxs("div", {
130
- className: "space-y-2",
131
- children: [/*#__PURE__*/jsx("label", {
132
- htmlFor: field.id,
133
- className: "block text-sm font-medium text-gray-700",
134
- children: field.title
135
- }), /*#__PURE__*/jsx(SettingSetter, {
136
- field: field
137
- })]
138
- });
139
- });
140
- const SettingFieldGroup = observer(({
141
- field
142
- }) => {
143
- const {
144
- customFieldGroup
145
- } = useSettingRendererContext();
146
- if (customFieldGroup) {
147
- return customFieldGroup(field, /*#__PURE__*/jsx(SettingSetter, {
148
- field: field,
149
- children: field.items?.map(item => /*#__PURE__*/jsx(SettingFieldView, {
150
- field: item
151
- }, item.id))
152
- }));
153
- }
154
-
155
- // 如果 field 没有 setter,则理解为其 父级 field 的 items 数据
156
- if (!field.setter) {
157
- return field.items?.map(item => /*#__PURE__*/jsx(SettingFieldView, {
158
- field: item
159
- }, item.id));
160
- }
161
- return /*#__PURE__*/jsx(SettingSetter, {
162
- field: field,
163
- children: field.items?.map(item => /*#__PURE__*/jsx(SettingFieldView, {
164
- field: item
165
- }, item.id))
166
- });
167
- });
168
- const SettingFieldView = ({
169
- field
170
- }) => {
171
- if (field.isGroup) {
172
- return /*#__PURE__*/jsx(SettingFieldGroup, {
173
- field: field
174
- }, field.id);
175
- } else {
176
- return /*#__PURE__*/jsx(SettingFieldItem, {
177
- field: field
178
- }, field.id);
179
- }
180
- };
181
- const SettingRender = observer(props => {
182
- const {
183
- editor,
184
- customFieldItem,
185
- customFieldGroup
186
- } = props;
187
- const designer = editor.get('designer');
188
- const setterManager = editor.get('setterManager');
189
- const {
190
- settingsManager
191
- } = designer;
192
- const {
193
- settings
194
- } = settingsManager;
195
- const items = settings?.items;
196
- const ctx = useMemo(() => {
197
- const ctx = {};
198
- ctx.setterManager = setterManager;
199
- ctx.settingsManager = settingsManager;
200
- ctx.customFieldItem = customFieldItem;
201
- ctx.customFieldGroup = customFieldGroup;
202
- return ctx;
203
- }, [setterManager, settingsManager, customFieldItem, customFieldGroup]);
204
- if (!settings) {
205
- // 未选中节点,提示选中 或者 显示根节点设置
206
- return /*#__PURE__*/jsx("div", {
207
- className: "lc-settings-main",
208
- children: /*#__PURE__*/jsx("div", {
209
- className: "lc-settings-notice",
210
- children: /*#__PURE__*/jsx("p", {
211
- children: "Please select a node in canvas"
212
- })
213
- })
214
- });
215
- }
216
-
217
- // 当节点被锁定,且未开启锁定后容器可设置属性
218
- if (settings.isLocked) {
219
- return /*#__PURE__*/jsx("div", {
220
- className: "lc-settings-main",
221
- children: /*#__PURE__*/jsx("div", {
222
- className: "lc-settings-notice",
223
- children: /*#__PURE__*/jsx("p", {
224
- children: "Current node is locked"
225
- })
226
- })
227
- });
228
- }
229
- if (Array.isArray(settings.items) && settings.items.length === 0) {
230
- return /*#__PURE__*/jsx("div", {
231
- className: "lc-settings-main",
232
- children: /*#__PURE__*/jsx("div", {
233
- className: "lc-settings-notice",
234
- children: /*#__PURE__*/jsx("p", {
235
- children: "No config found for this type of component"
236
- })
237
- })
238
- });
239
- }
240
- if (!settings.isSameComponent) {
241
- // TODO: future support 获取设置项交集编辑
242
- return /*#__PURE__*/jsx("div", {
243
- className: "lc-settings-main",
244
- children: /*#__PURE__*/jsx("div", {
245
- className: "lc-settings-notice",
246
- children: /*#__PURE__*/jsx("p", {
247
- children: "Please select same kind of components"
248
- })
249
- })
250
- });
251
- }
252
- return /*#__PURE__*/jsx(SettingRendererContext.Provider, {
253
- value: ctx,
254
- children: items?.map(item => /*#__PURE__*/jsx(SettingFieldView, {
255
- field: item
256
- }, item.id))
257
- });
258
- });
259
-
260
- class Adapter {
261
- renderers = {};
262
- setRenderers(renderers) {
263
- this.renderers = renderers;
264
- }
265
- setBaseRenderer(BaseRenderer) {
266
- this.renderers.BaseRenderer = BaseRenderer;
267
- }
268
- setPageRenderer(PageRenderer) {
269
- this.renderers.PageRenderer = PageRenderer;
270
- }
271
- setComponentRenderer(ComponentRenderer) {
272
- this.renderers.ComponentRenderer = ComponentRenderer;
273
- }
274
- getRenderers() {
275
- return this.renderers || {};
276
- }
277
- }
278
- const adapter = new Adapter();
279
-
280
- var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
281
-
282
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
283
- var root = freeGlobal || freeSelf || Function('return this')();
284
-
285
- var Symbol = root.Symbol;
286
-
287
- var objectProto$c = Object.prototype;
288
- var hasOwnProperty$a = objectProto$c.hasOwnProperty;
289
- var nativeObjectToString$1 = objectProto$c.toString;
290
- var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
291
- function getRawTag(value) {
292
- var isOwn = hasOwnProperty$a.call(value, symToStringTag$1),
293
- tag = value[symToStringTag$1];
294
- try {
295
- value[symToStringTag$1] = undefined;
296
- var unmasked = true;
297
- } catch (e) {}
298
- var result = nativeObjectToString$1.call(value);
299
- if (unmasked) {
300
- if (isOwn) {
301
- value[symToStringTag$1] = tag;
302
- } else {
303
- delete value[symToStringTag$1];
304
- }
305
- }
306
- return result;
307
- }
308
-
309
- var objectProto$b = Object.prototype;
310
- var nativeObjectToString = objectProto$b.toString;
311
- function objectToString(value) {
312
- return nativeObjectToString.call(value);
313
- }
314
-
315
- var nullTag = '[object Null]',
316
- undefinedTag = '[object Undefined]';
317
- var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
318
- function baseGetTag(value) {
319
- if (value == null) {
320
- return value === undefined ? undefinedTag : nullTag;
321
- }
322
- return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
323
- }
324
-
325
- function isObjectLike(value) {
326
- return value != null && typeof value == 'object';
327
- }
328
-
329
- var symbolTag = '[object Symbol]';
330
- function isSymbol(value) {
331
- return typeof value == 'symbol' || isObjectLike(value) && baseGetTag(value) == symbolTag;
332
- }
333
-
334
- var isArray = Array.isArray;
335
-
336
- var reWhitespace = /\s/;
337
- function trimmedEndIndex(string) {
338
- var index = string.length;
339
- while (index-- && reWhitespace.test(string.charAt(index))) {}
340
- return index;
341
- }
342
-
343
- var reTrimStart = /^\s+/;
344
- function baseTrim(string) {
345
- return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') : string;
346
- }
347
-
348
- function isObject$1(value) {
349
- var type = typeof value;
350
- return value != null && (type == 'object' || type == 'function');
351
- }
352
-
353
- var NAN = 0 / 0;
354
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
355
- var reIsBinary = /^0b[01]+$/i;
356
- var reIsOctal = /^0o[0-7]+$/i;
357
- var freeParseInt = parseInt;
358
- function toNumber(value) {
359
- if (typeof value == 'number') {
360
- return value;
361
- }
362
- if (isSymbol(value)) {
363
- return NAN;
364
- }
365
- if (isObject$1(value)) {
366
- var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
367
- value = isObject$1(other) ? other + '' : other;
368
- }
369
- if (typeof value != 'string') {
370
- return value === 0 ? value : +value;
371
- }
372
- value = baseTrim(value);
373
- var isBinary = reIsBinary.test(value);
374
- return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
375
- }
376
-
377
- function identity(value) {
378
- return value;
379
- }
380
-
381
- var asyncTag = '[object AsyncFunction]',
382
- funcTag$1 = '[object Function]',
383
- genTag = '[object GeneratorFunction]',
384
- proxyTag = '[object Proxy]';
385
- function isFunction(value) {
386
- if (!isObject$1(value)) {
387
- return false;
388
- }
389
- var tag = baseGetTag(value);
390
- return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
391
- }
392
-
393
- var coreJsData = root['__core-js_shared__'];
394
-
395
- var maskSrcKey = function () {
396
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
397
- return uid ? 'Symbol(src)_1.' + uid : '';
398
- }();
399
- function isMasked(func) {
400
- return !!maskSrcKey && maskSrcKey in func;
401
- }
402
-
403
- var funcProto$2 = Function.prototype;
404
- var funcToString$2 = funcProto$2.toString;
405
- function toSource(func) {
406
- if (func != null) {
407
- try {
408
- return funcToString$2.call(func);
409
- } catch (e) {}
410
- try {
411
- return func + '';
412
- } catch (e) {}
413
- }
414
- return '';
415
- }
416
-
417
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
418
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
419
- var funcProto$1 = Function.prototype,
420
- objectProto$a = Object.prototype;
421
- var funcToString$1 = funcProto$1.toString;
422
- var hasOwnProperty$9 = objectProto$a.hasOwnProperty;
423
- var reIsNative = RegExp('^' + funcToString$1.call(hasOwnProperty$9).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
424
- function baseIsNative(value) {
425
- if (!isObject$1(value) || isMasked(value)) {
426
- return false;
427
- }
428
- var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
429
- return pattern.test(toSource(value));
430
- }
431
-
432
- function getValue$1(object, key) {
433
- return object == null ? undefined : object[key];
434
- }
435
-
436
- function getNative(object, key) {
437
- var value = getValue$1(object, key);
438
- return baseIsNative(value) ? value : undefined;
439
- }
440
-
441
- var WeakMap = getNative(root, 'WeakMap');
442
-
443
- var objectCreate = Object.create;
444
- var baseCreate = function () {
445
- function object() {}
446
- return function (proto) {
447
- if (!isObject$1(proto)) {
448
- return {};
449
- }
450
- if (objectCreate) {
451
- return objectCreate(proto);
452
- }
453
- object.prototype = proto;
454
- var result = new object();
455
- object.prototype = undefined;
456
- return result;
457
- };
458
- }();
459
-
460
- function apply(func, thisArg, args) {
461
- switch (args.length) {
462
- case 0:
463
- return func.call(thisArg);
464
- case 1:
465
- return func.call(thisArg, args[0]);
466
- case 2:
467
- return func.call(thisArg, args[0], args[1]);
468
- case 3:
469
- return func.call(thisArg, args[0], args[1], args[2]);
470
- }
471
- return func.apply(thisArg, args);
472
- }
473
-
474
- function copyArray(source, array) {
475
- var index = -1,
476
- length = source.length;
477
- array || (array = Array(length));
478
- while (++index < length) {
479
- array[index] = source[index];
480
- }
481
- return array;
482
- }
483
-
484
- var HOT_COUNT = 800,
485
- HOT_SPAN = 16;
486
- var nativeNow = Date.now;
487
- function shortOut(func) {
488
- var count = 0,
489
- lastCalled = 0;
490
- return function () {
491
- var stamp = nativeNow(),
492
- remaining = HOT_SPAN - (stamp - lastCalled);
493
- lastCalled = stamp;
494
- if (remaining > 0) {
495
- if (++count >= HOT_COUNT) {
496
- return arguments[0];
497
- }
498
- } else {
499
- count = 0;
500
- }
501
- return func.apply(undefined, arguments);
502
- };
503
- }
504
-
505
- function constant(value) {
506
- return function () {
507
- return value;
508
- };
509
- }
510
-
511
- var defineProperty = function () {
512
- try {
513
- var func = getNative(Object, 'defineProperty');
514
- func({}, '', {});
515
- return func;
516
- } catch (e) {}
517
- }();
518
-
519
- var baseSetToString = !defineProperty ? identity : function (func, string) {
520
- return defineProperty(func, 'toString', {
521
- 'configurable': true,
522
- 'enumerable': false,
523
- 'value': constant(string),
524
- 'writable': true
525
- });
526
- };
527
-
528
- var setToString = shortOut(baseSetToString);
529
-
530
- function arrayEach(array, iteratee) {
531
- var index = -1,
532
- length = array == null ? 0 : array.length;
533
- while (++index < length) {
534
- if (iteratee(array[index], index, array) === false) {
535
- break;
536
- }
537
- }
538
- return array;
539
- }
540
-
541
- var MAX_SAFE_INTEGER$1 = 9007199254740991;
542
- var reIsUint = /^(?:0|[1-9]\d*)$/;
543
- function isIndex(value, length) {
544
- var type = typeof value;
545
- length = length == null ? MAX_SAFE_INTEGER$1 : length;
546
- return !!length && (type == 'number' || type != 'symbol' && reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
547
- }
548
-
549
- function baseAssignValue(object, key, value) {
550
- if (key == '__proto__' && defineProperty) {
551
- defineProperty(object, key, {
552
- 'configurable': true,
553
- 'enumerable': true,
554
- 'value': value,
555
- 'writable': true
556
- });
557
- } else {
558
- object[key] = value;
559
- }
560
- }
561
-
562
- function eq(value, other) {
563
- return value === other || value !== value && other !== other;
564
- }
565
-
566
- var objectProto$9 = Object.prototype;
567
- var hasOwnProperty$8 = objectProto$9.hasOwnProperty;
568
- function assignValue(object, key, value) {
569
- var objValue = object[key];
570
- if (!(hasOwnProperty$8.call(object, key) && eq(objValue, value)) || value === undefined && !(key in object)) {
571
- baseAssignValue(object, key, value);
572
- }
573
- }
574
-
575
- function copyObject(source, props, object, customizer) {
576
- var isNew = !object;
577
- object || (object = {});
578
- var index = -1,
579
- length = props.length;
580
- while (++index < length) {
581
- var key = props[index];
582
- var newValue = undefined;
583
- if (newValue === undefined) {
584
- newValue = source[key];
585
- }
586
- if (isNew) {
587
- baseAssignValue(object, key, newValue);
588
- } else {
589
- assignValue(object, key, newValue);
590
- }
591
- }
592
- return object;
593
- }
594
-
595
- var nativeMax$1 = Math.max;
596
- function overRest(func, start, transform) {
597
- start = nativeMax$1(start === undefined ? func.length - 1 : start, 0);
598
- return function () {
599
- var args = arguments,
600
- index = -1,
601
- length = nativeMax$1(args.length - start, 0),
602
- array = Array(length);
603
- while (++index < length) {
604
- array[index] = args[start + index];
605
- }
606
- index = -1;
607
- var otherArgs = Array(start + 1);
608
- while (++index < start) {
609
- otherArgs[index] = args[index];
610
- }
611
- otherArgs[start] = transform(array);
612
- return apply(func, this, otherArgs);
613
- };
614
- }
615
-
616
- function baseRest(func, start) {
617
- return setToString(overRest(func, start, identity), func + '');
618
- }
619
-
620
- var MAX_SAFE_INTEGER = 9007199254740991;
621
- function isLength(value) {
622
- return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
623
- }
624
-
625
- function isArrayLike(value) {
626
- return value != null && isLength(value.length) && !isFunction(value);
627
- }
628
-
629
- function isIterateeCall(value, index, object) {
630
- if (!isObject$1(object)) {
631
- return false;
632
- }
633
- var type = typeof index;
634
- if (type == 'number' ? isArrayLike(object) && isIndex(index, object.length) : type == 'string' && index in object) {
635
- return eq(object[index], value);
636
- }
637
- return false;
638
- }
639
-
640
- function createAssigner(assigner) {
641
- return baseRest(function (object, sources) {
642
- var index = -1,
643
- length = sources.length,
644
- customizer = length > 1 ? sources[length - 1] : undefined,
645
- guard = length > 2 ? sources[2] : undefined;
646
- customizer = assigner.length > 3 && typeof customizer == 'function' ? (length--, customizer) : undefined;
647
- if (guard && isIterateeCall(sources[0], sources[1], guard)) {
648
- customizer = length < 3 ? undefined : customizer;
649
- length = 1;
650
- }
651
- object = Object(object);
652
- while (++index < length) {
653
- var source = sources[index];
654
- if (source) {
655
- assigner(object, source, index, customizer);
656
- }
657
- }
658
- return object;
659
- });
660
- }
661
-
662
- var objectProto$8 = Object.prototype;
663
- function isPrototype(value) {
664
- var Ctor = value && value.constructor,
665
- proto = typeof Ctor == 'function' && Ctor.prototype || objectProto$8;
666
- return value === proto;
667
- }
668
-
669
- function baseTimes(n, iteratee) {
670
- var index = -1,
671
- result = Array(n);
672
- while (++index < n) {
673
- result[index] = iteratee(index);
674
- }
675
- return result;
676
- }
677
-
678
- var argsTag$1 = '[object Arguments]';
679
- function baseIsArguments(value) {
680
- return isObjectLike(value) && baseGetTag(value) == argsTag$1;
681
- }
682
-
683
- var objectProto$7 = Object.prototype;
684
- var hasOwnProperty$7 = objectProto$7.hasOwnProperty;
685
- var propertyIsEnumerable = objectProto$7.propertyIsEnumerable;
686
- var isArguments = baseIsArguments(function () {
687
- return arguments;
688
- }()) ? baseIsArguments : function (value) {
689
- return isObjectLike(value) && hasOwnProperty$7.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
690
- };
691
-
692
- function stubFalse() {
693
- return false;
694
- }
695
-
696
- var freeExports$2 = typeof exports == 'object' && exports && !exports.nodeType && exports;
697
- var freeModule$2 = freeExports$2 && typeof module == 'object' && module && !module.nodeType && module;
698
- var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
699
- var Buffer$1 = moduleExports$2 ? root.Buffer : undefined;
700
- var nativeIsBuffer = Buffer$1 ? Buffer$1.isBuffer : undefined;
701
- var isBuffer = nativeIsBuffer || stubFalse;
702
-
703
- var argsTag = '[object Arguments]',
704
- arrayTag = '[object Array]',
705
- boolTag = '[object Boolean]',
706
- dateTag = '[object Date]',
707
- errorTag = '[object Error]',
708
- funcTag = '[object Function]',
709
- mapTag$2 = '[object Map]',
710
- numberTag = '[object Number]',
711
- objectTag$2 = '[object Object]',
712
- regexpTag = '[object RegExp]',
713
- setTag$2 = '[object Set]',
714
- stringTag = '[object String]',
715
- weakMapTag$1 = '[object WeakMap]';
716
- var arrayBufferTag = '[object ArrayBuffer]',
717
- dataViewTag$1 = '[object DataView]',
718
- float32Tag = '[object Float32Array]',
719
- float64Tag = '[object Float64Array]',
720
- int8Tag = '[object Int8Array]',
721
- int16Tag = '[object Int16Array]',
722
- int32Tag = '[object Int32Array]',
723
- uint8Tag = '[object Uint8Array]',
724
- uint8ClampedTag = '[object Uint8ClampedArray]',
725
- uint16Tag = '[object Uint16Array]',
726
- uint32Tag = '[object Uint32Array]';
727
- var typedArrayTags = {};
728
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
729
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag] = typedArrayTags[objectTag$2] = typedArrayTags[regexpTag] = typedArrayTags[setTag$2] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag$1] = false;
730
- function baseIsTypedArray(value) {
731
- return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
732
- }
733
-
734
- function baseUnary(func) {
735
- return function (value) {
736
- return func(value);
737
- };
738
- }
739
-
740
- var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
741
- var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
742
- var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
743
- var freeProcess = moduleExports$1 && freeGlobal.process;
744
- var nodeUtil = function () {
745
- try {
746
- var types = freeModule$1 && freeModule$1.require && freeModule$1.require('util').types;
747
- if (types) {
748
- return types;
749
- }
750
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
751
- } catch (e) {}
752
- }();
753
-
754
- var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
755
- var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
756
-
757
- var objectProto$6 = Object.prototype;
758
- var hasOwnProperty$6 = objectProto$6.hasOwnProperty;
759
- function arrayLikeKeys(value, inherited) {
760
- var isArr = isArray(value),
761
- isArg = !isArr && isArguments(value),
762
- isBuff = !isArr && !isArg && isBuffer(value),
763
- isType = !isArr && !isArg && !isBuff && isTypedArray(value),
764
- skipIndexes = isArr || isArg || isBuff || isType,
765
- result = skipIndexes ? baseTimes(value.length, String) : [],
766
- length = result.length;
767
- for (var key in value) {
768
- if ((inherited || hasOwnProperty$6.call(value, key)) && !(skipIndexes && (
769
- key == 'length' ||
770
- isBuff && (key == 'offset' || key == 'parent') ||
771
- isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') ||
772
- isIndex(key, length)))) {
773
- result.push(key);
774
- }
775
- }
776
- return result;
777
- }
778
-
779
- function overArg(func, transform) {
780
- return function (arg) {
781
- return func(transform(arg));
782
- };
783
- }
784
-
785
- var nativeKeys = overArg(Object.keys, Object);
786
-
787
- var objectProto$5 = Object.prototype;
788
- var hasOwnProperty$5 = objectProto$5.hasOwnProperty;
789
- function baseKeys(object) {
790
- if (!isPrototype(object)) {
791
- return nativeKeys(object);
792
- }
793
- var result = [];
794
- for (var key in Object(object)) {
795
- if (hasOwnProperty$5.call(object, key) && key != 'constructor') {
796
- result.push(key);
797
- }
798
- }
799
- return result;
800
- }
801
-
802
- function keys(object) {
803
- return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
804
- }
805
-
806
- function nativeKeysIn(object) {
807
- var result = [];
808
- if (object != null) {
809
- for (var key in Object(object)) {
810
- result.push(key);
811
- }
812
- }
813
- return result;
814
- }
815
-
816
- var objectProto$4 = Object.prototype;
817
- var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
818
- function baseKeysIn(object) {
819
- if (!isObject$1(object)) {
820
- return nativeKeysIn(object);
821
- }
822
- var isProto = isPrototype(object),
823
- result = [];
824
- for (var key in object) {
825
- if (!(key == 'constructor' && (isProto || !hasOwnProperty$4.call(object, key)))) {
826
- result.push(key);
827
- }
828
- }
829
- return result;
830
- }
831
-
832
- function keysIn(object) {
833
- return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
834
- }
835
-
836
- var nativeCreate = getNative(Object, 'create');
837
-
838
- function hashClear() {
839
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
840
- this.size = 0;
841
- }
842
-
843
- function hashDelete(key) {
844
- var result = this.has(key) && delete this.__data__[key];
845
- this.size -= result ? 1 : 0;
846
- return result;
847
- }
848
-
849
- var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
850
- var objectProto$3 = Object.prototype;
851
- var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
852
- function hashGet(key) {
853
- var data = this.__data__;
854
- if (nativeCreate) {
855
- var result = data[key];
856
- return result === HASH_UNDEFINED$1 ? undefined : result;
857
- }
858
- return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
859
- }
860
-
861
- var objectProto$2 = Object.prototype;
862
- var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
863
- function hashHas(key) {
864
- var data = this.__data__;
865
- return nativeCreate ? data[key] !== undefined : hasOwnProperty$2.call(data, key);
866
- }
867
-
868
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
869
- function hashSet(key, value) {
870
- var data = this.__data__;
871
- this.size += this.has(key) ? 0 : 1;
872
- data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
873
- return this;
874
- }
875
-
876
- function Hash(entries) {
877
- var index = -1,
878
- length = entries == null ? 0 : entries.length;
879
- this.clear();
880
- while (++index < length) {
881
- var entry = entries[index];
882
- this.set(entry[0], entry[1]);
883
- }
884
- }
885
- Hash.prototype.clear = hashClear;
886
- Hash.prototype['delete'] = hashDelete;
887
- Hash.prototype.get = hashGet;
888
- Hash.prototype.has = hashHas;
889
- Hash.prototype.set = hashSet;
890
-
891
- function listCacheClear() {
892
- this.__data__ = [];
893
- this.size = 0;
894
- }
895
-
896
- function assocIndexOf(array, key) {
897
- var length = array.length;
898
- while (length--) {
899
- if (eq(array[length][0], key)) {
900
- return length;
901
- }
902
- }
903
- return -1;
904
- }
905
-
906
- var arrayProto = Array.prototype;
907
- var splice = arrayProto.splice;
908
- function listCacheDelete(key) {
909
- var data = this.__data__,
910
- index = assocIndexOf(data, key);
911
- if (index < 0) {
912
- return false;
913
- }
914
- var lastIndex = data.length - 1;
915
- if (index == lastIndex) {
916
- data.pop();
917
- } else {
918
- splice.call(data, index, 1);
919
- }
920
- --this.size;
921
- return true;
922
- }
923
-
924
- function listCacheGet(key) {
925
- var data = this.__data__,
926
- index = assocIndexOf(data, key);
927
- return index < 0 ? undefined : data[index][1];
928
- }
929
-
930
- function listCacheHas(key) {
931
- return assocIndexOf(this.__data__, key) > -1;
932
- }
933
-
934
- function listCacheSet(key, value) {
935
- var data = this.__data__,
936
- index = assocIndexOf(data, key);
937
- if (index < 0) {
938
- ++this.size;
939
- data.push([key, value]);
940
- } else {
941
- data[index][1] = value;
942
- }
943
- return this;
944
- }
945
-
946
- function ListCache(entries) {
947
- var index = -1,
948
- length = entries == null ? 0 : entries.length;
949
- this.clear();
950
- while (++index < length) {
951
- var entry = entries[index];
952
- this.set(entry[0], entry[1]);
953
- }
954
- }
955
- ListCache.prototype.clear = listCacheClear;
956
- ListCache.prototype['delete'] = listCacheDelete;
957
- ListCache.prototype.get = listCacheGet;
958
- ListCache.prototype.has = listCacheHas;
959
- ListCache.prototype.set = listCacheSet;
960
-
961
- var Map$1 = getNative(root, 'Map');
962
-
963
- function mapCacheClear() {
964
- this.size = 0;
965
- this.__data__ = {
966
- 'hash': new Hash(),
967
- 'map': new (Map$1 || ListCache)(),
968
- 'string': new Hash()
969
- };
970
- }
971
-
972
- function isKeyable(value) {
973
- var type = typeof value;
974
- return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
975
- }
976
-
977
- function getMapData(map, key) {
978
- var data = map.__data__;
979
- return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
980
- }
981
-
982
- function mapCacheDelete(key) {
983
- var result = getMapData(this, key)['delete'](key);
984
- this.size -= result ? 1 : 0;
985
- return result;
986
- }
987
-
988
- function mapCacheGet(key) {
989
- return getMapData(this, key).get(key);
990
- }
991
-
992
- function mapCacheHas(key) {
993
- return getMapData(this, key).has(key);
994
- }
995
-
996
- function mapCacheSet(key, value) {
997
- var data = getMapData(this, key),
998
- size = data.size;
999
- data.set(key, value);
1000
- this.size += data.size == size ? 0 : 1;
1001
- return this;
1002
- }
1003
-
1004
- function MapCache(entries) {
1005
- var index = -1,
1006
- length = entries == null ? 0 : entries.length;
1007
- this.clear();
1008
- while (++index < length) {
1009
- var entry = entries[index];
1010
- this.set(entry[0], entry[1]);
1011
- }
1012
- }
1013
- MapCache.prototype.clear = mapCacheClear;
1014
- MapCache.prototype['delete'] = mapCacheDelete;
1015
- MapCache.prototype.get = mapCacheGet;
1016
- MapCache.prototype.has = mapCacheHas;
1017
- MapCache.prototype.set = mapCacheSet;
1018
-
1019
- var getPrototype = overArg(Object.getPrototypeOf, Object);
1020
-
1021
- var objectTag$1 = '[object Object]';
1022
- var funcProto = Function.prototype,
1023
- objectProto$1 = Object.prototype;
1024
- var funcToString = funcProto.toString;
1025
- var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
1026
- var objectCtorString = funcToString.call(Object);
1027
- function isPlainObject(value) {
1028
- if (!isObjectLike(value) || baseGetTag(value) != objectTag$1) {
1029
- return false;
1030
- }
1031
- var proto = getPrototype(value);
1032
- if (proto === null) {
1033
- return true;
1034
- }
1035
- var Ctor = hasOwnProperty$1.call(proto, 'constructor') && proto.constructor;
1036
- return typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
1037
- }
1038
-
1039
- function stackClear() {
1040
- this.__data__ = new ListCache();
1041
- this.size = 0;
1042
- }
1043
-
1044
- function stackDelete(key) {
1045
- var data = this.__data__,
1046
- result = data['delete'](key);
1047
- this.size = data.size;
1048
- return result;
1049
- }
1050
-
1051
- function stackGet(key) {
1052
- return this.__data__.get(key);
1053
- }
1054
-
1055
- function stackHas(key) {
1056
- return this.__data__.has(key);
1057
- }
1058
-
1059
- var LARGE_ARRAY_SIZE = 200;
1060
- function stackSet(key, value) {
1061
- var data = this.__data__;
1062
- if (data instanceof ListCache) {
1063
- var pairs = data.__data__;
1064
- if (!Map$1 || pairs.length < LARGE_ARRAY_SIZE - 1) {
1065
- pairs.push([key, value]);
1066
- this.size = ++data.size;
1067
- return this;
1068
- }
1069
- data = this.__data__ = new MapCache(pairs);
1070
- }
1071
- data.set(key, value);
1072
- this.size = data.size;
1073
- return this;
1074
- }
1075
-
1076
- function Stack(entries) {
1077
- var data = this.__data__ = new ListCache(entries);
1078
- this.size = data.size;
1079
- }
1080
- Stack.prototype.clear = stackClear;
1081
- Stack.prototype['delete'] = stackDelete;
1082
- Stack.prototype.get = stackGet;
1083
- Stack.prototype.has = stackHas;
1084
- Stack.prototype.set = stackSet;
1085
-
1086
- var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
1087
- var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
1088
- var moduleExports = freeModule && freeModule.exports === freeExports;
1089
- var Buffer = moduleExports ? root.Buffer : undefined;
1090
- Buffer ? Buffer.allocUnsafe : undefined;
1091
- function cloneBuffer(buffer, isDeep) {
1092
- {
1093
- return buffer.slice();
1094
- }
1095
- }
1096
-
1097
- var DataView = getNative(root, 'DataView');
1098
-
1099
- var Promise$1 = getNative(root, 'Promise');
1100
-
1101
- var Set = getNative(root, 'Set');
1102
-
1103
- var mapTag$1 = '[object Map]',
1104
- objectTag = '[object Object]',
1105
- promiseTag = '[object Promise]',
1106
- setTag$1 = '[object Set]',
1107
- weakMapTag = '[object WeakMap]';
1108
- var dataViewTag = '[object DataView]';
1109
- var dataViewCtorString = toSource(DataView),
1110
- mapCtorString = toSource(Map$1),
1111
- promiseCtorString = toSource(Promise$1),
1112
- setCtorString = toSource(Set),
1113
- weakMapCtorString = toSource(WeakMap);
1114
- var getTag = baseGetTag;
1115
- if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map$1 && getTag(new Map$1()) != mapTag$1 || Promise$1 && getTag(Promise$1.resolve()) != promiseTag || Set && getTag(new Set()) != setTag$1 || WeakMap && getTag(new WeakMap()) != weakMapTag) {
1116
- getTag = function (value) {
1117
- var result = baseGetTag(value),
1118
- Ctor = result == objectTag ? value.constructor : undefined,
1119
- ctorString = Ctor ? toSource(Ctor) : '';
1120
- if (ctorString) {
1121
- switch (ctorString) {
1122
- case dataViewCtorString:
1123
- return dataViewTag;
1124
- case mapCtorString:
1125
- return mapTag$1;
1126
- case promiseCtorString:
1127
- return promiseTag;
1128
- case setCtorString:
1129
- return setTag$1;
1130
- case weakMapCtorString:
1131
- return weakMapTag;
1132
- }
1133
- }
1134
- return result;
1135
- };
1136
- }
1137
-
1138
- var Uint8Array = root.Uint8Array;
1139
-
1140
- function cloneArrayBuffer(arrayBuffer) {
1141
- var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
1142
- new Uint8Array(result).set(new Uint8Array(arrayBuffer));
1143
- return result;
1144
- }
1145
-
1146
- function cloneTypedArray(typedArray, isDeep) {
1147
- var buffer = cloneArrayBuffer(typedArray.buffer) ;
1148
- return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
1149
- }
1150
-
1151
- function initCloneObject(object) {
1152
- return typeof object.constructor == 'function' && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};
1153
- }
1154
-
1155
- function createBaseFor(fromRight) {
1156
- return function (object, iteratee, keysFunc) {
1157
- var index = -1,
1158
- iterable = Object(object),
1159
- props = keysFunc(object),
1160
- length = props.length;
1161
- while (length--) {
1162
- var key = props[++index];
1163
- if (iteratee(iterable[key], key, iterable) === false) {
1164
- break;
1165
- }
1166
- }
1167
- return object;
1168
- };
1169
- }
1170
-
1171
- var baseFor = createBaseFor();
1172
-
1173
- function baseForOwn(object, iteratee) {
1174
- return object && baseFor(object, iteratee, keys);
1175
- }
1176
-
1177
- function createBaseEach(eachFunc, fromRight) {
1178
- return function (collection, iteratee) {
1179
- if (collection == null) {
1180
- return collection;
1181
- }
1182
- if (!isArrayLike(collection)) {
1183
- return eachFunc(collection, iteratee);
1184
- }
1185
- var length = collection.length,
1186
- index = -1,
1187
- iterable = Object(collection);
1188
- while (++index < length) {
1189
- if (iteratee(iterable[index], index, iterable) === false) {
1190
- break;
1191
- }
1192
- }
1193
- return collection;
1194
- };
1195
- }
1196
-
1197
- var baseEach = createBaseEach(baseForOwn);
1198
-
1199
- var now = function () {
1200
- return root.Date.now();
1201
- };
1202
-
1203
- var FUNC_ERROR_TEXT = 'Expected a function';
1204
- var nativeMax = Math.max,
1205
- nativeMin = Math.min;
1206
- function debounce(func, wait, options) {
1207
- var lastArgs,
1208
- lastThis,
1209
- maxWait,
1210
- result,
1211
- timerId,
1212
- lastCallTime,
1213
- lastInvokeTime = 0,
1214
- leading = false,
1215
- maxing = false,
1216
- trailing = true;
1217
- if (typeof func != 'function') {
1218
- throw new TypeError(FUNC_ERROR_TEXT);
1219
- }
1220
- wait = toNumber(wait) || 0;
1221
- if (isObject$1(options)) {
1222
- leading = !!options.leading;
1223
- maxing = 'maxWait' in options;
1224
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
1225
- trailing = 'trailing' in options ? !!options.trailing : trailing;
1226
- }
1227
- function invokeFunc(time) {
1228
- var args = lastArgs,
1229
- thisArg = lastThis;
1230
- lastArgs = lastThis = undefined;
1231
- lastInvokeTime = time;
1232
- result = func.apply(thisArg, args);
1233
- return result;
1234
- }
1235
- function leadingEdge(time) {
1236
- lastInvokeTime = time;
1237
- timerId = setTimeout(timerExpired, wait);
1238
- return leading ? invokeFunc(time) : result;
1239
- }
1240
- function remainingWait(time) {
1241
- var timeSinceLastCall = time - lastCallTime,
1242
- timeSinceLastInvoke = time - lastInvokeTime,
1243
- timeWaiting = wait - timeSinceLastCall;
1244
- return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
1245
- }
1246
- function shouldInvoke(time) {
1247
- var timeSinceLastCall = time - lastCallTime,
1248
- timeSinceLastInvoke = time - lastInvokeTime;
1249
- return lastCallTime === undefined || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
1250
- }
1251
- function timerExpired() {
1252
- var time = now();
1253
- if (shouldInvoke(time)) {
1254
- return trailingEdge(time);
1255
- }
1256
- timerId = setTimeout(timerExpired, remainingWait(time));
1257
- }
1258
- function trailingEdge(time) {
1259
- timerId = undefined;
1260
- if (trailing && lastArgs) {
1261
- return invokeFunc(time);
1262
- }
1263
- lastArgs = lastThis = undefined;
1264
- return result;
1265
- }
1266
- function cancel() {
1267
- if (timerId !== undefined) {
1268
- clearTimeout(timerId);
1269
- }
1270
- lastInvokeTime = 0;
1271
- lastArgs = lastCallTime = lastThis = timerId = undefined;
1272
- }
1273
- function flush() {
1274
- return timerId === undefined ? result : trailingEdge(now());
1275
- }
1276
- function debounced() {
1277
- var time = now(),
1278
- isInvoking = shouldInvoke(time);
1279
- lastArgs = arguments;
1280
- lastThis = this;
1281
- lastCallTime = time;
1282
- if (isInvoking) {
1283
- if (timerId === undefined) {
1284
- return leadingEdge(lastCallTime);
1285
- }
1286
- if (maxing) {
1287
- clearTimeout(timerId);
1288
- timerId = setTimeout(timerExpired, wait);
1289
- return invokeFunc(lastCallTime);
1290
- }
1291
- }
1292
- if (timerId === undefined) {
1293
- timerId = setTimeout(timerExpired, wait);
1294
- }
1295
- return result;
1296
- }
1297
- debounced.cancel = cancel;
1298
- debounced.flush = flush;
1299
- return debounced;
1300
- }
1301
-
1302
- function assignMergeValue(object, key, value) {
1303
- if (value !== undefined && !eq(object[key], value) || value === undefined && !(key in object)) {
1304
- baseAssignValue(object, key, value);
1305
- }
1306
- }
1307
-
1308
- function isArrayLikeObject(value) {
1309
- return isObjectLike(value) && isArrayLike(value);
1310
- }
1311
-
1312
- function safeGet(object, key) {
1313
- if (key === 'constructor' && typeof object[key] === 'function') {
1314
- return;
1315
- }
1316
- if (key == '__proto__') {
1317
- return;
1318
- }
1319
- return object[key];
1320
- }
1321
-
1322
- function toPlainObject(value) {
1323
- return copyObject(value, keysIn(value));
1324
- }
1325
-
1326
- function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
1327
- var objValue = safeGet(object, key),
1328
- srcValue = safeGet(source, key),
1329
- stacked = stack.get(srcValue);
1330
- if (stacked) {
1331
- assignMergeValue(object, key, stacked);
1332
- return;
1333
- }
1334
- var newValue = customizer ? customizer(objValue, srcValue, key + '', object, source, stack) : undefined;
1335
- var isCommon = newValue === undefined;
1336
- if (isCommon) {
1337
- var isArr = isArray(srcValue),
1338
- isBuff = !isArr && isBuffer(srcValue),
1339
- isTyped = !isArr && !isBuff && isTypedArray(srcValue);
1340
- newValue = srcValue;
1341
- if (isArr || isBuff || isTyped) {
1342
- if (isArray(objValue)) {
1343
- newValue = objValue;
1344
- } else if (isArrayLikeObject(objValue)) {
1345
- newValue = copyArray(objValue);
1346
- } else if (isBuff) {
1347
- isCommon = false;
1348
- newValue = cloneBuffer(srcValue);
1349
- } else if (isTyped) {
1350
- isCommon = false;
1351
- newValue = cloneTypedArray(srcValue);
1352
- } else {
1353
- newValue = [];
1354
- }
1355
- } else if (isPlainObject(srcValue) || isArguments(srcValue)) {
1356
- newValue = objValue;
1357
- if (isArguments(objValue)) {
1358
- newValue = toPlainObject(objValue);
1359
- } else if (!isObject$1(objValue) || isFunction(objValue)) {
1360
- newValue = initCloneObject(srcValue);
1361
- }
1362
- } else {
1363
- isCommon = false;
1364
- }
1365
- }
1366
- if (isCommon) {
1367
- stack.set(srcValue, newValue);
1368
- mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
1369
- stack['delete'](srcValue);
1370
- }
1371
- assignMergeValue(object, key, newValue);
1372
- }
1373
-
1374
- function baseMerge(object, source, srcIndex, customizer, stack) {
1375
- if (object === source) {
1376
- return;
1377
- }
1378
- baseFor(source, function (srcValue, key) {
1379
- stack || (stack = new Stack());
1380
- if (isObject$1(srcValue)) {
1381
- baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
1382
- } else {
1383
- var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + '', object, source, stack) : undefined;
1384
- if (newValue === undefined) {
1385
- newValue = srcValue;
1386
- }
1387
- assignMergeValue(object, key, newValue);
1388
- }
1389
- }, keysIn);
1390
- }
1391
-
1392
- function castFunction(value) {
1393
- return typeof value == 'function' ? value : identity;
1394
- }
1395
-
1396
- function forEach(collection, iteratee) {
1397
- var func = isArray(collection) ? arrayEach : baseEach;
1398
- return func(collection, castFunction(iteratee));
1399
- }
1400
-
1401
- var mapTag = '[object Map]',
1402
- setTag = '[object Set]';
1403
- var objectProto = Object.prototype;
1404
- var hasOwnProperty = objectProto.hasOwnProperty;
1405
- function isEmpty(value) {
1406
- if (value == null) {
1407
- return true;
1408
- }
1409
- if (isArrayLike(value) && (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || isBuffer(value) || isTypedArray(value) || isArguments(value))) {
1410
- return !value.length;
1411
- }
1412
- var tag = getTag(value);
1413
- if (tag == mapTag || tag == setTag) {
1414
- return !value.size;
1415
- }
1416
- if (isPrototype(value)) {
1417
- return !baseKeys(value).length;
1418
- }
1419
- for (var key in value) {
1420
- if (hasOwnProperty.call(value, key)) {
1421
- return false;
1422
- }
1423
- }
1424
- return true;
1425
- }
1426
-
1427
- var merge = createAssigner(function (object, source, srcIndex) {
1428
- baseMerge(object, source, srcIndex);
1429
- });
1430
-
1431
- let RuntimeDataSourceStatus = /*#__PURE__*/function (RuntimeDataSourceStatus) {
1432
- RuntimeDataSourceStatus["Initial"] = "init";
1433
- RuntimeDataSourceStatus["Loading"] = "loading";
1434
- RuntimeDataSourceStatus["Loaded"] = "loaded";
1435
- RuntimeDataSourceStatus["Error"] = "error";
1436
- return RuntimeDataSourceStatus;
1437
- }({});
1438
-
1439
- class RuntimeDataSourceItem {
1440
- _data;
1441
- _error;
1442
- _status = RuntimeDataSourceStatus.Initial;
1443
- _dataSourceConfig;
1444
- _request;
1445
- _context;
1446
- _options;
1447
- constructor(dataSourceConfig, request, context) {
1448
- this._dataSourceConfig = dataSourceConfig;
1449
- this._request = request;
1450
- this._context = context;
1451
- }
1452
- get data() {
1453
- return this._data;
1454
- }
1455
- get error() {
1456
- return this._error;
1457
- }
1458
- get status() {
1459
- return this._status;
1460
- }
1461
- get isLoading() {
1462
- return this._status === RuntimeDataSourceStatus.Loading;
1463
- }
1464
- async load(params) {
1465
- if (!this._dataSourceConfig) return;
1466
- if (!this._request) {
1467
- this._error = new Error(`no ${this._dataSourceConfig.type} handler provide`);
1468
- this._status = RuntimeDataSourceStatus.Error;
1469
- throw this._error;
1470
- }
1471
- if (this._dataSourceConfig.type === 'urlParams') {
1472
- const response = await this._request(this._context);
1473
- this._context.setState({
1474
- [this._dataSourceConfig.id]: response
1475
- });
1476
- this._data = response;
1477
- this._status = RuntimeDataSourceStatus.Loaded;
1478
- return response;
1479
- }
1480
- if (!this._dataSourceConfig.options) {
1481
- throw new Error(`${this._dataSourceConfig.id} has no options`);
1482
- }
1483
- if (typeof this._dataSourceConfig.options === 'function') {
1484
- this._options = this._dataSourceConfig.options();
1485
- }
1486
- if (!this._options) {
1487
- throw new Error(`${this._dataSourceConfig.id} options transform error`);
1488
- }
1489
- let shouldFetch = true;
1490
- let fetchOptions = this._options;
1491
- if (params) {
1492
- fetchOptions.params = merge(fetchOptions.params, params);
1493
- }
1494
- if (this._dataSourceConfig.shouldFetch) {
1495
- if (typeof this._dataSourceConfig.shouldFetch === 'function') {
1496
- shouldFetch = this._dataSourceConfig.shouldFetch(fetchOptions);
1497
- } else if (typeof this._dataSourceConfig.shouldFetch === 'boolean') {
1498
- shouldFetch = this._dataSourceConfig.shouldFetch;
1499
- }
1500
- }
1501
- if (!shouldFetch) {
1502
- this._status = RuntimeDataSourceStatus.Error;
1503
- this._error = new Error(`the ${this._dataSourceConfig.id} request should not fetch, please check the condition`);
1504
- console.warn(this.error);
1505
- return;
1506
- }
1507
- if (this._dataSourceConfig.willFetch) {
1508
- try {
1509
- fetchOptions = await this._dataSourceConfig.willFetch(this._options);
1510
- } catch (error) {
1511
- console.error(error);
1512
- }
1513
- }
1514
- const dataHandler = this._dataSourceConfig.dataHandler;
1515
- const {
1516
- errorHandler
1517
- } = this._dataSourceConfig;
1518
- try {
1519
- this._status = RuntimeDataSourceStatus.Loading;
1520
- const result = await this._request(fetchOptions, this._context).then(dataHandler, errorHandler);
1521
- this._data = result;
1522
- this._status = RuntimeDataSourceStatus.Loaded;
1523
- this._context.setState({
1524
- UNSTABLE_dataSourceUpdatedAt: Date.now(),
1525
- [this._dataSourceConfig.id]: result
1526
- });
1527
- return this._data;
1528
- } catch (error) {
1529
- this._error = error;
1530
- this._status = RuntimeDataSourceStatus.Error;
1531
- this._context.setState({
1532
- UNSTABLE_dataSourceUpdatedAt: Date.now(),
1533
- [`UNSTABLE_${this._dataSourceConfig.id}_error`]: error
1534
- });
1535
- throw error;
1536
- }
1537
- }
1538
- }
1539
-
1540
- const defaultDataHandler = async response => response.data;
1541
- const defaultWillFetch = options => options;
1542
- const getRequestHandler = (ds, requestHandlersMap) => {
1543
- if (ds.type === 'custom') {
1544
- return ds.requestHandler;
1545
- }
1546
- return requestHandlersMap[ds.type || 'fetch'];
1547
- };
1548
- const promiseSettled = (Promise.allSettled ? Promise.allSettled.bind(Promise) : null) || (promises => {
1549
- return Promise.all(promises.map(p => {
1550
- return p.then(v => ({
1551
- status: 'fulfilled',
1552
- value: v
1553
- })).catch(e => ({
1554
- status: 'rejected',
1555
- reason: e
1556
- }));
1557
- }));
1558
- });
1559
-
1560
- function isObject(obj) {
1561
- return Object.prototype.toString.call(obj).indexOf('Object') !== -1;
1562
- }
1563
- const transformExpression = (code, context) => {
1564
- if (code === undefined) {
1565
- return () => {};
1566
- }
1567
- if (code === '') {
1568
- return () => '';
1569
- }
1570
- try {
1571
- return new Function(`return (${code})`).call(context);
1572
- } catch (error) {
1573
- console.error(`transformExpression error, code is ${code}, context is ${context}, error is ${error}`);
1574
- }
1575
- };
1576
- const transformFunction = (code, context) => {
1577
- if (code === undefined) {
1578
- return () => {};
1579
- }
1580
- if (code === '') {
1581
- return () => '';
1582
- }
1583
- try {
1584
- return new Function(`return (${code})`).call(context).bind(context);
1585
- } catch (error) {
1586
- console.error(`transformFunction error, code is ${code}, context is ${context}, error is ${error}`);
1587
- }
1588
- };
1589
- const transformBoolStr = str => {
1590
- return str !== 'false';
1591
- };
1592
- const getRuntimeJsValue = (value, context) => {
1593
- if (!['JSExpression', 'JSFunction'].includes(value.type)) {
1594
- console.error(`translate error, value is ${JSON.stringify(value)}`);
1595
- return '';
1596
- }
1597
- const code = value.compiled || value.value;
1598
- return value.type === 'JSFunction' ? transformFunction(code, context) : transformExpression(code, context);
1599
- };
1600
- const getRuntimeBaseValue = (type, value) => {
1601
- switch (type) {
1602
- case 'string':
1603
- return `${value}`;
1604
- case 'boolean':
1605
- return typeof value === 'string' ? transformBoolStr(value) : !!value;
1606
- case 'number':
1607
- return Number(value);
1608
- default:
1609
- return value;
1610
- }
1611
- };
1612
- const getRuntimeValueFromConfig = (type, value, context) => {
1613
- if (value === undefined) {
1614
- return undefined;
1615
- }
1616
- if (isJSExpression(value) || isJSFunction(value)) {
1617
- return getRuntimeBaseValue(type, getRuntimeJsValue(value, context));
1618
- }
1619
- return value;
1620
- };
1621
- const buildJsonObj = (params, context) => {
1622
- if (isJSExpression(params)) {
1623
- return transformExpression(params.value, context);
1624
- } else if (isObject(params)) {
1625
- const newParams = {};
1626
- for (const [name, param] of Object.entries(params)) {
1627
- if (isJSExpression(param)) {
1628
- newParams[name] = transformExpression(param?.value, context);
1629
- } else if (isObject(param)) {
1630
- newParams[name] = buildJsonObj(param, context);
1631
- } else {
1632
- newParams[name] = param;
1633
- }
1634
- }
1635
- return newParams;
1636
- }
1637
- return params;
1638
- };
1639
- const buildShouldFetch = (ds, context) => {
1640
- if (!ds.options || !ds.shouldFetch) {
1641
- return true;
1642
- }
1643
- if (isJSExpression(ds.shouldFetch) || isJSFunction(ds.shouldFetch)) {
1644
- return getRuntimeJsValue(ds.shouldFetch, context);
1645
- }
1646
- return getRuntimeBaseValue('boolean', ds.shouldFetch);
1647
- };
1648
- const buildOptions = (ds, context) => {
1649
- const {
1650
- options
1651
- } = ds;
1652
- if (!options) return undefined;
1653
- return () => {
1654
- const fetchOptions = {
1655
- uri: '',
1656
- params: {},
1657
- method: 'GET',
1658
- isCors: true,
1659
- timeout: 5000,
1660
- headers: undefined,
1661
- v: '1.0'
1662
- };
1663
- Object.keys(options).forEach(key => {
1664
- switch (key) {
1665
- case 'uri':
1666
- fetchOptions.uri = getRuntimeValueFromConfig('string', options.uri, context);
1667
- break;
1668
- case 'params':
1669
- fetchOptions.params = buildJsonObj(options.params, context);
1670
- break;
1671
- case 'method':
1672
- fetchOptions.method = getRuntimeValueFromConfig('string', options.method, context);
1673
- break;
1674
- case 'isCors':
1675
- fetchOptions.isCors = getRuntimeValueFromConfig('boolean', options.isCors, context);
1676
- break;
1677
- case 'timeout':
1678
- fetchOptions.timeout = getRuntimeValueFromConfig('number', options.timeout, context);
1679
- break;
1680
- case 'headers':
1681
- fetchOptions.headers = buildJsonObj(options.headers, context);
1682
- break;
1683
- case 'v':
1684
- fetchOptions.v = getRuntimeValueFromConfig('string', options.v, context);
1685
- break;
1686
- default:
1687
- fetchOptions[key] = getRuntimeValueFromConfig('unknown', options[key], context);
1688
- }
1689
- });
1690
- return fetchOptions;
1691
- };
1692
- };
1693
-
1694
- const adapt2Runtime = (dataSource, context, extraConfig) => {
1695
- const {
1696
- list: interpretConfigList,
1697
- dataHandler: interpretDataHandler
1698
- } = dataSource;
1699
- const dataHandler = interpretDataHandler ? getRuntimeJsValue(interpretDataHandler, context) : undefined;
1700
- if (!interpretConfigList || !interpretConfigList.length) {
1701
- return {
1702
- list: [],
1703
- dataHandler
1704
- };
1705
- }
1706
- const list = interpretConfigList.map(el => {
1707
- const {
1708
- defaultDataHandler: customDataHandler
1709
- } = extraConfig;
1710
- const finalDataHandler = customDataHandler || defaultDataHandler;
1711
- return {
1712
- id: el.id,
1713
- isInit: getRuntimeValueFromConfig('boolean', el.isInit, context),
1714
- isSync: getRuntimeValueFromConfig('boolean', el.isSync, context),
1715
- type: el.type || 'fetch',
1716
- willFetch: el.willFetch ? getRuntimeJsValue(el.willFetch, context) : defaultWillFetch,
1717
- shouldFetch: buildShouldFetch(el, context),
1718
- dataHandler: el.dataHandler ? getRuntimeJsValue(el.dataHandler, context) : finalDataHandler,
1719
- errorHandler: el.errorHandler ? getRuntimeJsValue(el.errorHandler, context) : undefined,
1720
- requestHandler: el.requestHandler ? getRuntimeJsValue(el.requestHandler, context) : undefined,
1721
- options: buildOptions(el, context)
1722
- };
1723
- });
1724
- return {
1725
- list,
1726
- dataHandler
1727
- };
1728
- };
1729
-
1730
- const reloadDataSourceFactory = (dataSource, dataSourceMap, dataHandler) => {
1731
- return async () => {
1732
- const allAsyncLoadings = [];
1733
- dataSource.list.filter(el => el.type === 'urlParams' && isInit(el)).forEach(el => {
1734
- dataSourceMap[el.id].load();
1735
- });
1736
- const remainRuntimeDataSourceList = dataSource.list.filter(el => el.type !== 'urlParams');
1737
- for (const ds of remainRuntimeDataSourceList) {
1738
- if (!ds.options) {
1739
- continue;
1740
- }
1741
- if (
1742
- isInit(ds) && !ds.isSync) {
1743
- allAsyncLoadings.push(dataSourceMap[ds.id].load());
1744
- }
1745
- }
1746
- for (const ds of remainRuntimeDataSourceList) {
1747
- if (!ds.options) {
1748
- continue;
1749
- }
1750
- if (
1751
- isInit(ds) && ds.isSync) {
1752
- try {
1753
- await dataSourceMap[ds.id].load();
1754
- } catch (e) {
1755
- console.error(e);
1756
- }
1757
- }
1758
- }
1759
- await promiseSettled(allAsyncLoadings);
1760
- if (dataHandler) {
1761
- dataHandler(dataSourceMap);
1762
- }
1763
- };
1764
- };
1765
- function isInit(ds) {
1766
- return typeof ds.isInit === 'function' ? ds.isInit() : ds.isInit ?? true;
1767
- }
1768
-
1769
- var createDataSourceEngine = (dataSource, context, extraConfig = {
1770
- requestHandlersMap: {}
1771
- }) => {
1772
- const {
1773
- requestHandlersMap
1774
- } = extraConfig;
1775
- const runtimeDataSource = adapt2Runtime(dataSource, context, {
1776
- defaultDataHandler: extraConfig.defaultDataHandler
1777
- });
1778
- const dataSourceMap = runtimeDataSource.list.reduce((prev, current) => {
1779
- prev[current.id] = new RuntimeDataSourceItem(current, getRequestHandler(current, requestHandlersMap), context);
1780
- return prev;
1781
- }, {});
1782
- return {
1783
- dataSourceMap,
1784
- reloadDataSource: reloadDataSourceFactory(runtimeDataSource, dataSourceMap, runtimeDataSource.dataHandler)
1785
- };
1786
- };
1787
-
1788
- const RendererContext = /*#__PURE__*/createContext({});
1789
- const useRendererContext = () => {
1790
- try {
1791
- return useContext(RendererContext);
1792
- } catch (error) {
1793
- console.warn('useRendererContext must be used within a RendererContextProvider');
1794
- }
1795
- return {};
1796
- };
1797
- function contextFactory() {
1798
- let context = window.__appContext;
1799
- if (!context) {
1800
- context = /*#__PURE__*/createContext({});
1801
- window.__appContext = context;
1802
- }
1803
- return context;
1804
- }
1805
-
1806
- const classnames = (...args) => {
1807
- return args.filter(Boolean).join(' ');
1808
- };
1809
-
1810
- const logger = createLogger('Renderer');
1811
-
1812
- const PropTypes2 = true;
1813
- function inSameDomain() {
1814
- try {
1815
- return window.parent !== window && window.parent.location.host === window.location.host;
1816
- } catch (e) {
1817
- return false;
1818
- }
1819
- }
1820
- function getFileCssName(fileName) {
1821
- if (!fileName) {
1822
- return;
1823
- }
1824
- const name = fileName.replace(/([A-Z])/g, '-$1').toLowerCase();
1825
- return `lce-${name}`.split('-').filter(p => !!p).join('-');
1826
- }
1827
- const isSchema = schema => {
1828
- if (!schema) {
1829
- return false;
1830
- }
1831
- if (schema.componentName === 'Leaf' || schema.componentName === 'Slot') {
1832
- return true;
1833
- }
1834
- if (Array.isArray(schema)) {
1835
- return schema.every(item => isSchema(item));
1836
- }
1837
- const isValidProps = props => {
1838
- if (!props) {
1839
- return false;
1840
- }
1841
- return typeof schema.props === 'object' && !Array.isArray(props);
1842
- };
1843
- return !!(schema.componentName && isValidProps(schema.props));
1844
- };
1845
- const getValue = (obj, path, defaultValue = {}) => {
1846
- if (Array.isArray(obj)) {
1847
- return defaultValue;
1848
- }
1849
- if (!obj || typeof obj !== 'object') {
1850
- return defaultValue;
1851
- }
1852
- const res = path.split('.').reduce((pre, cur) => {
1853
- return pre && pre[cur];
1854
- }, obj);
1855
- if (res === undefined) {
1856
- return defaultValue;
1857
- }
1858
- return res;
1859
- };
1860
- function transformArrayToMap(arr, key, overwrite = true) {
1861
- if (!arr || !Array.isArray(arr)) {
1862
- return {};
1863
- }
1864
- const res = {};
1865
- arr.forEach(item => {
1866
- const curKey = item[key];
1867
- if (item[key] === undefined) {
1868
- return;
1869
- }
1870
- if (res[curKey] && !overwrite) {
1871
- return;
1872
- }
1873
- res[curKey] = item;
1874
- });
1875
- return res;
1876
- }
1877
- const parseData = (schema, self, options = {}) => {
1878
- if (isJSExpression(schema)) {
1879
- return parseExpression({
1880
- str: schema,
1881
- self,
1882
- thisRequired: true,
1883
- logScope: options.logScope
1884
- });
1885
- }
1886
- if (typeof schema === 'string') {
1887
- return schema.trim();
1888
- } else if (Array.isArray(schema)) {
1889
- return schema.map(item => parseData(item, self, options));
1890
- } else if (typeof schema === 'function') {
1891
- return schema.bind(self);
1892
- } else if (typeof schema === 'object') {
1893
- if (!schema) {
1894
- return schema;
1895
- }
1896
- const res = {};
1897
- Object.entries(schema).forEach(([key, val]) => {
1898
- if (key.startsWith('__')) {
1899
- return;
1900
- }
1901
- res[key] = parseData(val, self, options);
1902
- });
1903
- return res;
1904
- }
1905
- return schema;
1906
- };
1907
- const isUseLoop = (loop, isDesignMode) => {
1908
- if (!isDesignMode) {
1909
- return true;
1910
- }
1911
- if (!Array.isArray(loop)) {
1912
- return false;
1913
- }
1914
- return loop.length > 0;
1915
- };
1916
- function checkPropTypes(value, name, rule, componentName) {
1917
- let ruleFunction = rule;
1918
- if (typeof rule === 'string') {
1919
- ruleFunction = new Function(`"use strict"; const PropTypes = arguments[0]; return ${rule}`)(PropTypes2);
1920
- }
1921
- if (!ruleFunction || typeof ruleFunction !== 'function') {
1922
- logger.warn('checkPropTypes should have a function type rule argument');
1923
- return true;
1924
- }
1925
- const err = ruleFunction({
1926
- [name]: value
1927
- }, name, componentName, 'prop', null
1928
- );
1929
- if (err) {
1930
- logger.warn(err);
1931
- }
1932
- return !err;
1933
- }
1934
- function transformStringToFunction(str) {
1935
- if (typeof str !== 'string') {
1936
- return str;
1937
- }
1938
- if (inSameDomain() && window.parent.__newFunc) {
1939
- return window.parent.__newFunc(`"use strict"; return ${str}`)();
1940
- } else {
1941
- return new Function(`"use strict"; return ${str}`)();
1942
- }
1943
- }
1944
- function parseExpression(a, b, c = false) {
1945
- let str;
1946
- let self;
1947
- let thisRequired;
1948
- let logScope;
1949
- if (typeof a === 'object' && b === undefined) {
1950
- str = a.str;
1951
- self = a.self;
1952
- thisRequired = a.thisRequired;
1953
- logScope = a.logScope;
1954
- } else {
1955
- str = a;
1956
- self = b;
1957
- thisRequired = c;
1958
- }
1959
- try {
1960
- const contextArr = ['"use strict";', 'var __self = arguments[0];'];
1961
- contextArr.push('return ');
1962
- let tarStr;
1963
- tarStr = (str.value || '').trim();
1964
- tarStr = tarStr.replace(/this(\W|$)/g, (_a, b) => `__self${b}`);
1965
- tarStr = contextArr.join('\n') + tarStr;
1966
- if (inSameDomain() && window.parent.__newFunc) {
1967
- return window.parent.__newFunc(tarStr)(self);
1968
- }
1969
- const code = `with(${thisRequired ? '{}' : '$scope || {}'}) { ${tarStr} }`;
1970
- return new Function('$scope', code)(self);
1971
- } catch (err) {
1972
- logger.error(`${logScope || ''} parseExpression.error`, err, str, self?.__self ?? self);
1973
- return undefined;
1974
- }
1975
- }
1976
- function parseThisRequiredExpression(str, self) {
1977
- return parseExpression(str, self, true);
1978
- }
1979
- function isString(str) {
1980
- return {}.toString.call(str) === '[object String]';
1981
- }
1982
- function capitalizeFirstLetter(word) {
1983
- if (!word || !isString(word) || word.length === 0) {
1984
- return word;
1985
- }
1986
- return word[0].toUpperCase() + word.slice(1);
1987
- }
1988
- const isReactClass = obj => {
1989
- return obj && obj.prototype && (obj.prototype.isReactComponent || obj.prototype instanceof Component);
1990
- };
1991
- function isReactComponent(obj) {
1992
- return obj && (isReactClass(obj) || typeof obj === 'function');
1993
- }
1994
- function serializeParams(obj) {
1995
- const result = [];
1996
- forEach(obj, (val, key) => {
1997
- if (val === null || val === undefined || val === '') {
1998
- return;
1999
- }
2000
- if (typeof val === 'object') {
2001
- result.push(`${key}=${encodeURIComponent(JSON.stringify(val))}`);
2002
- } else {
2003
- result.push(`${key}=${encodeURIComponent(val)}`);
2004
- }
2005
- });
2006
- return result.join('&');
2007
- }
2008
-
2009
- const excludePropertyNames = ['$$typeof', 'render', 'defaultProps', 'props', 'length', 'prototype', 'name', 'caller', 'callee', 'arguments'];
2010
- const cloneEnumerableProperty = (target, origin, excludes = excludePropertyNames) => {
2011
- const compExtraPropertyNames = Object.keys(origin).filter(d => !excludes.includes(d));
2012
- compExtraPropertyNames.forEach(d => {
2013
- target[d] = origin[d];
2014
- });
2015
- return target;
2016
- };
2017
- const createForwardRefHocElement = (Wrapper, Comp) => {
2018
- const WrapperComponent = cloneEnumerableProperty(/*#__PURE__*/forwardRef((props, ref) => {
2019
- return /*#__PURE__*/createElement(Wrapper, {
2020
- ...props,
2021
- forwardRef: ref
2022
- });
2023
- }), Comp);
2024
- WrapperComponent.displayName = Comp.displayName;
2025
- return WrapperComponent;
2026
- };
2027
-
2028
- const patchDidCatch = (Comp, {
2029
- baseRenderer
2030
- }) => {
2031
- if (Comp.patchedCatch) {
2032
- return;
2033
- }
2034
- Comp.patchedCatch = true;
2035
- const originalDidCatch = Comp.prototype.componentDidCatch;
2036
- Comp.prototype.componentDidCatch = function didCatch(error, errorInfo) {
2037
- this.setState({
2038
- engineRenderError: true,
2039
- error
2040
- });
2041
- if (originalDidCatch && typeof originalDidCatch === 'function') {
2042
- originalDidCatch.call(this, error, errorInfo);
2043
- }
2044
- };
2045
- const {
2046
- engine
2047
- } = baseRenderer.context;
2048
- const originRender = Comp.prototype.render;
2049
- Comp.prototype.render = function () {
2050
- if (this.state && this.state.engineRenderError) {
2051
- this.state.engineRenderError = false;
2052
- return engine.createElement(engine.getFaultComponent(), {
2053
- ...this.props,
2054
- error: this.state.error,
2055
- componentName: this.props._componentName
2056
- });
2057
- }
2058
- return originRender.call(this);
2059
- };
2060
- if (!(Comp.prototype instanceof PureComponent)) {
2061
- const originShouldComponentUpdate = Comp.prototype.shouldComponentUpdate;
2062
- Comp.prototype.shouldComponentUpdate = function (nextProps, nextState) {
2063
- if (nextState && nextState.engineRenderError) {
2064
- return true;
2065
- }
2066
- return originShouldComponentUpdate ? originShouldComponentUpdate.call(this, nextProps, nextState) : true;
2067
- };
2068
- }
2069
- };
2070
- const cache$1 = new Map();
2071
- const compWrapper = (Comp, info) => {
2072
- if (Comp?.prototype?.isReactComponent || Comp?.prototype instanceof Component) {
2073
- patchDidCatch(Comp, info);
2074
- return Comp;
2075
- }
2076
- if (info.schema.id && cache$1.has(info.schema.id) && cache$1.get(info.schema.id)?.Comp === Comp) {
2077
- return cache$1.get(info.schema.id)?.WrapperComponent;
2078
- }
2079
- class Wrapper extends Component {
2080
- static displayName = Comp.displayName;
2081
- render() {
2082
- const {
2083
- forwardRef,
2084
- ...rest
2085
- } = this.props;
2086
- // @ts-ignore
2087
- return /*#__PURE__*/createElement(Comp, {
2088
- ...rest,
2089
- ref: forwardRef
2090
- });
2091
- }
2092
- }
2093
- patchDidCatch(Wrapper, info);
2094
- const WrapperComponent = createForwardRefHocElement(Wrapper, Comp);
2095
- info.schema.id && cache$1.set(info.schema.id, {
2096
- WrapperComponent,
2097
- Comp
2098
- });
2099
- return WrapperComponent;
2100
- };
2101
-
2102
- var RerenderType = /*#__PURE__*/function (RerenderType) {
2103
- RerenderType["All"] = "All";
2104
- RerenderType["ChildChanged"] = "ChildChanged";
2105
- RerenderType["PropsChanged"] = "PropsChanged";
2106
- RerenderType["VisibleChanged"] = "VisibleChanged";
2107
- RerenderType["MinimalRenderUnit"] = "MinimalRenderUnit";
2108
- return RerenderType;
2109
- }(RerenderType || {}); // 缓存 Leaf 层组件,防止重新渲染问题
2110
- class LeafCache {
2111
- /** 组件缓存 */
2112
- component = new Map();
2113
-
2114
- /**
2115
- * 状态缓存,场景:属性变化后,改组件被销毁,state 为空,没有展示修改后的属性
2116
- */
2117
- state = new Map();
2118
-
2119
- /**
2120
- * 订阅事件缓存,导致 rerender 的订阅事件
2121
- */
2122
- event = new Map();
2123
- ref = new Map();
2124
- constructor(documentId, device) {
2125
- this.documentId = documentId;
2126
- this.device = device;
2127
- }
2128
- }
2129
- let cache;
2130
-
2131
- /** 部分没有渲染的 node 节点进行兜底处理 or 渲染方式没有渲染 LeafWrapper */
2132
- const initRerenderEvent = ({
2133
- schema,
2134
- container,
2135
- getNode
2136
- }) => {
2137
- const leaf = getNode?.(schema.id);
2138
- if (!leaf || cache.event.get(schema.id)?.clear || leaf === cache.event.get(schema.id)) {
2139
- return;
2140
- }
2141
- cache.event.get(schema.id)?.dispose.forEach(disposeFn => disposeFn && disposeFn());
2142
- const debounceRerender = debounce(() => {
2143
- container.rerender();
2144
- }, 20);
2145
- cache.event.set(schema.id, {
2146
- clear: false,
2147
- leaf,
2148
- dispose: [leaf?.onPropChange?.(() => {
2149
- if (!container.autoRepaintNode) {
2150
- return;
2151
- }
2152
- logger.log(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onPropsChange make rerender`);
2153
- debounceRerender();
2154
- }), leaf?.onChildrenChange?.(() => {
2155
- if (!container.autoRepaintNode) {
2156
- return;
2157
- }
2158
- logger.log(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onChildrenChange make rerender`);
2159
- debounceRerender();
2160
- }), leaf?.onVisibleChange?.(() => {
2161
- if (!container.autoRepaintNode) {
2162
- return;
2163
- }
2164
- logger.log(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onVisibleChange make rerender`);
2165
- debounceRerender();
2166
- })]
2167
- });
2168
- };
2169
-
2170
- /** 渲染的 node 节点全局注册事件清除 */
2171
- const clearRerenderEvent = id => {
2172
- if (cache.event.get(id)?.clear) {
2173
- return;
2174
- }
2175
- cache.event.get(id)?.dispose?.forEach(disposeFn => disposeFn && disposeFn());
2176
- cache.event.set(id, {
2177
- clear: true,
2178
- dispose: []
2179
- });
2180
- };
2181
-
2182
- // 给每个组件包裹一个 HOC Leaf,支持组件内部属性变化,自响应渲染
2183
- const leafWrapper = (Comp, {
2184
- schema,
2185
- baseRenderer,
2186
- componentInfo,
2187
- scope
2188
- }) => {
2189
- const {
2190
- __getComponentProps: getProps,
2191
- __getSchemaChildrenVirtualDom: getChildren,
2192
- __parseData
2193
- } = baseRenderer;
2194
- const {
2195
- engine
2196
- } = baseRenderer.context;
2197
- const host = baseRenderer.props?.__host;
2198
- const curDocumentId = baseRenderer.props?.documentId ?? '';
2199
- const curDevice = baseRenderer.props?.device ?? '';
2200
- const getNode = baseRenderer.props?.getNode;
2201
- const container = baseRenderer.props?.__container;
2202
- const setSchemaChangedSymbol = baseRenderer.props?.setSchemaChangedSymbol;
2203
- const designer = host?.designer;
2204
- const componentCacheId = schema.id;
2205
- if (!cache || curDocumentId && curDocumentId !== cache.documentId || curDevice && curDevice !== cache.device) {
2206
- cache?.event.forEach(event => {
2207
- event.dispose?.forEach(disposeFn => disposeFn && disposeFn());
2208
- });
2209
- cache = new LeafCache(curDocumentId, curDevice);
2210
- }
2211
-
2212
- // if (!isReactComponent(Comp)) {
2213
- // logger.error(`${schema.componentName} component may be has errors: `, Comp)
2214
- // }
2215
-
2216
- initRerenderEvent({
2217
- schema,
2218
- container,
2219
- getNode
2220
- });
2221
- if (curDocumentId && cache.component.has(componentCacheId) && cache.component.get(componentCacheId).Comp === Comp) {
2222
- return cache.component.get(componentCacheId).LeafWrapper;
2223
- }
2224
- class LeafHoc extends Component {
2225
- recordInfo = {};
2226
- curEventLeaf;
2227
- static displayName = schema.componentName;
2228
- disposeFunctions = [];
2229
- __component_tag = 'leafWrapper';
2230
- renderUnitInfo;
2231
-
2232
- // 最小渲染单元做防抖处理
2233
- makeUnitRenderDebounced = debounce(() => {
2234
- this.beforeRender(RerenderType.MinimalRenderUnit);
2235
- const schema = this.leaf?.export?.(TRANSFORM_STAGE.RENDER);
2236
- if (!schema) {
2237
- return;
2238
- }
2239
- const nextProps = getProps(schema, scope, Comp, componentInfo);
2240
- const children = getChildren(schema, scope, Comp);
2241
- const nextState = {
2242
- nodeProps: nextProps,
2243
- nodeChildren: children,
2244
- childrenInState: true
2245
- };
2246
- if ('children' in nextProps) {
2247
- nextState.nodeChildren = nextProps.children;
2248
- }
2249
- logger.log(`${this.leaf?.componentName}(${this.leaf?.id}) MinimalRenderUnit Render!`);
2250
- this.setState(nextState);
2251
- }, 20);
2252
- constructor(props) {
2253
- super(props);
2254
- // 监听以下事件,当变化时更新自己
2255
- logger.log(`${schema.componentName}[${this.leaf?.id}] leaf render in SimulatorRendererView`);
2256
- componentCacheId && clearRerenderEvent(componentCacheId);
2257
- this.curEventLeaf = this.leaf;
2258
- cache.ref.set(componentCacheId, {
2259
- makeUnitRender: this.makeUnitRender
2260
- });
2261
- let cacheState = cache.state.get(componentCacheId);
2262
- if (!cacheState || cacheState.__tag !== props.__tag) {
2263
- cacheState = this.getDefaultState(props);
2264
- }
2265
- this.state = cacheState;
2266
- }
2267
- recordTime = () => {
2268
- if (!this.recordInfo.startTime) {
2269
- return;
2270
- }
2271
- const endTime = Date.now();
2272
- const nodeCount = host?.designer?.currentDocument?.getNodeCount?.();
2273
- const componentName = this.recordInfo.node?.componentName || this.leaf?.componentName || 'UnknownComponent';
2274
- designer?.postEvent(DESIGNER_EVENT.NODE_RENDER, {
2275
- componentName,
2276
- time: endTime - this.recordInfo.startTime,
2277
- type: this.recordInfo.type,
2278
- nodeCount
2279
- });
2280
- this.recordInfo.startTime = null;
2281
- };
2282
- makeUnitRender = () => {
2283
- this.makeUnitRenderDebounced();
2284
- };
2285
- get autoRepaintNode() {
2286
- return container?.autoRepaintNode;
2287
- }
2288
- componentDidUpdate() {
2289
- this.recordTime();
2290
- }
2291
- componentDidMount() {
2292
- const _leaf = this.leaf;
2293
- this.initOnPropsChangeEvent(_leaf);
2294
- this.initOnChildrenChangeEvent(_leaf);
2295
- this.initOnVisibleChangeEvent(_leaf);
2296
- this.recordTime();
2297
- }
2298
- getDefaultState(nextProps) {
2299
- const {
2300
- hidden = false,
2301
- condition = true
2302
- } = nextProps.__inner__ || this.leaf?.export?.(TRANSFORM_STAGE.RENDER) || {};
2303
- return {
2304
- nodeChildren: null,
2305
- childrenInState: false,
2306
- visible: !hidden,
2307
- condition: __parseData?.(condition, scope),
2308
- nodeCacheProps: {},
2309
- nodeProps: {}
2310
- };
2311
- }
2312
- setState(state) {
2313
- cache.state.set(componentCacheId, {
2314
- ...this.state,
2315
- ...state,
2316
- __tag: this.props.__tag
2317
- });
2318
- super.setState(state);
2319
- }
2320
-
2321
- /** 由于内部属性变化,在触发渲染前,会执行该函数 */
2322
- beforeRender(type, node) {
2323
- this.recordInfo.startTime = Date.now();
2324
- this.recordInfo.type = type;
2325
- this.recordInfo.node = node;
2326
- setSchemaChangedSymbol?.(true);
2327
- }
2328
- judgeMiniUnitRender() {
2329
- if (!this.renderUnitInfo) {
2330
- this.getRenderUnitInfo();
2331
- }
2332
- const renderUnitInfo = this.renderUnitInfo || {
2333
- singleRender: true
2334
- };
2335
- if (renderUnitInfo.singleRender) {
2336
- return;
2337
- }
2338
- const ref = cache.ref.get(renderUnitInfo.minimalUnitId);
2339
- if (!ref) {
2340
- logger.log('Cant find minimalRenderUnit ref! This make rerender!');
2341
- container?.rerender();
2342
- return;
2343
- }
2344
- logger.log(`${this.leaf?.componentName}(${this.leaf?.id}) need render, make its minimalRenderUnit ${renderUnitInfo.minimalUnitName}(${renderUnitInfo.minimalUnitId})`);
2345
- ref.makeUnitRender();
2346
- }
2347
- getRenderUnitInfo(leaf = this.leaf) {
2348
- // leaf 在低代码组件中存在 mock 的情况,退出最小渲染单元判断
2349
- if (!leaf || typeof leaf.isRoot !== 'function') {
2350
- return;
2351
- }
2352
- if (leaf.isRoot) {
2353
- this.renderUnitInfo = {
2354
- singleRender: true,
2355
- ...(this.renderUnitInfo || {})
2356
- };
2357
- }
2358
- if (leaf.componentMeta.isMinimalRenderUnit) {
2359
- this.renderUnitInfo = {
2360
- minimalUnitId: leaf.id,
2361
- minimalUnitName: leaf.componentName,
2362
- singleRender: false
2363
- };
2364
- }
2365
- if (leaf.hasLoop()) {
2366
- // 含有循环配置的元素,父元素是最小渲染单元
2367
- this.renderUnitInfo = {
2368
- minimalUnitId: leaf?.parent?.id,
2369
- minimalUnitName: leaf?.parent?.componentName,
2370
- singleRender: false
2371
- };
2372
- }
2373
- if (leaf.parent) {
2374
- this.getRenderUnitInfo(leaf.parent);
2375
- }
2376
- }
2377
- UNSAFE_componentWillReceiveProps(nextProps) {
2378
- const {
2379
- componentId
2380
- } = nextProps;
2381
- if (nextProps.__tag === this.props.__tag) {
2382
- return null;
2383
- }
2384
- const _leaf = getNode?.(componentId);
2385
- if (_leaf && this.curEventLeaf && _leaf !== this.curEventLeaf) {
2386
- this.disposeFunctions.forEach(fn => fn());
2387
- this.disposeFunctions = [];
2388
- this.initOnChildrenChangeEvent(_leaf);
2389
- this.initOnPropsChangeEvent(_leaf);
2390
- this.initOnVisibleChangeEvent(_leaf);
2391
- this.curEventLeaf = _leaf;
2392
- }
2393
- const {
2394
- visible,
2395
- ...resetState
2396
- } = this.getDefaultState(nextProps);
2397
- this.setState(resetState);
2398
- }
2399
-
2400
- /** 监听参数变化 */
2401
- initOnPropsChangeEvent(leaf = this.leaf) {
2402
- // const handlePropsChange = debounce((propChangeInfo: PropChangeInfo) => {
2403
- const handlePropsChange = debounce(propChangeInfo => {
2404
- const {
2405
- key,
2406
- newValue = null
2407
- } = propChangeInfo;
2408
- const node = leaf;
2409
- if (key === '___condition___') {
2410
- const {
2411
- condition = true
2412
- } = this.leaf?.export(TRANSFORM_STAGE.RENDER) || {};
2413
- const conditionValue = __parseData?.(condition, scope);
2414
- logger.log(`key is ___condition___, change condition value to [${condition}]`);
2415
- // 条件表达式改变
2416
- this.setState({
2417
- condition: conditionValue
2418
- });
2419
- return;
2420
- }
2421
-
2422
- // 如果循坏条件变化,从根节点重新渲染
2423
- // 目前多层循坏无法判断需要从哪一层开始渲染,故先粗暴解决
2424
- if (key === '___loop___') {
2425
- logger.log('key is ___loop___, render a page!');
2426
- container?.rerender();
2427
- // 由于 scope 变化,需要清空缓存,使用新的 scope
2428
- cache.component.delete(componentCacheId);
2429
- return;
2430
- }
2431
- this.beforeRender(RerenderType.PropsChanged);
2432
- const {
2433
- state
2434
- } = this;
2435
- const {
2436
- nodeCacheProps
2437
- } = state;
2438
- const nodeProps = getProps(node?.export?.(TRANSFORM_STAGE.RENDER), scope, Comp, componentInfo);
2439
- if (key && !(key in nodeProps) && key in this.props) {
2440
- // 当 key 在 this.props 中时,且不存在在计算值中,需要用 newValue 覆盖掉 this.props 的取值
2441
- nodeCacheProps[key] = newValue;
2442
- }
2443
- logger.log(`${leaf?.componentName}[${this.leaf?.id}] component trigger onPropsChange!`, nodeProps, nodeCacheProps, key, newValue);
2444
- this.setState('children' in nodeProps ? {
2445
- nodeChildren: nodeProps.children,
2446
- nodeProps,
2447
- childrenInState: true,
2448
- nodeCacheProps
2449
- } : {
2450
- nodeProps,
2451
- nodeCacheProps
2452
- });
2453
- this.judgeMiniUnitRender();
2454
- });
2455
- // const dispose = leaf?.onPropChange?.((propChangeInfo: IPublicTypePropChangeOptions) => {
2456
- const dispose = leaf?.onPropChange?.(propChangeInfo => {
2457
- if (!this.autoRepaintNode) {
2458
- return;
2459
- }
2460
- handlePropsChange(propChangeInfo);
2461
- });
2462
- dispose && this.disposeFunctions.push(dispose);
2463
- }
2464
-
2465
- /**
2466
- * 监听显隐变化
2467
- */
2468
- initOnVisibleChangeEvent(leaf = this.leaf) {
2469
- const dispose = leaf?.onVisibleChange?.(flag => {
2470
- if (!this.autoRepaintNode) {
2471
- return;
2472
- }
2473
- if (this.state.visible === flag) {
2474
- return;
2475
- }
2476
- logger.log(`${leaf?.componentName}[${this.leaf?.id}] component trigger onVisibleChange(${flag}) event`);
2477
- this.beforeRender(RerenderType.VisibleChanged);
2478
- this.setState({
2479
- visible: flag
2480
- });
2481
- this.judgeMiniUnitRender();
2482
- });
2483
- dispose && this.disposeFunctions.push(dispose);
2484
- }
2485
-
2486
- /**
2487
- * 监听子元素变化(拖拽,删除...)
2488
- */
2489
- initOnChildrenChangeEvent(leaf = this.leaf) {
2490
- const dispose = leaf?.onChildrenChange?.(param => {
2491
- if (!this.autoRepaintNode) {
2492
- return;
2493
- }
2494
- const {
2495
- type,
2496
- node
2497
- } = param || {};
2498
- this.beforeRender(`${RerenderType.ChildChanged}-${type}`, node);
2499
- // TODO: 缓存同级其他元素的 children。
2500
- // 缓存二级 children Next 查询筛选组件有问题
2501
- // 缓存一级 children Next Tab 组件有问题
2502
- const nextChild = getChildren(leaf?.export?.(TRANSFORM_STAGE.RENDER), scope, Comp);
2503
- logger.log(`${schema.componentName}[${this.leaf?.id}] component trigger onChildrenChange event`, nextChild);
2504
- this.setState({
2505
- nodeChildren: nextChild,
2506
- childrenInState: true
2507
- });
2508
- this.judgeMiniUnitRender();
2509
- });
2510
- dispose && this.disposeFunctions.push(dispose);
2511
- }
2512
- componentWillUnmount() {
2513
- this.disposeFunctions.forEach(fn => fn());
2514
- }
2515
- get hasChildren() {
2516
- if (!this.state.childrenInState) {
2517
- return 'children' in this.props;
2518
- }
2519
- return true;
2520
- }
2521
- get children() {
2522
- if (this.state.childrenInState) {
2523
- return this.state.nodeChildren;
2524
- }
2525
- if (this.props.children && !Array.isArray(this.props.children)) {
2526
- return [this.props.children];
2527
- }
2528
- if (this.props.children && this.props.children.length) {
2529
- return this.props.children;
2530
- }
2531
- return this.props.children;
2532
- }
2533
- get leaf() {
2534
- // if (this.props._leaf?.isMock) {
2535
- // // 低代码组件作为一个整体更新,其内部的组件不需要监听相关事件
2536
- // return undefined
2537
- // }
2538
-
2539
- return getNode?.(componentCacheId);
2540
- }
2541
- render() {
2542
- if (!this.state.visible || !this.state.condition) {
2543
- return null;
2544
- }
2545
- const {
2546
- forwardRef,
2547
- ...rest
2548
- } = this.props;
2549
- const compProps = {
2550
- ...rest,
2551
- ...(this.state.nodeCacheProps || {}),
2552
- ...(this.state.nodeProps || {}),
2553
- children: [],
2554
- __id: this.leaf?.id,
2555
- ref: forwardRef
2556
- };
2557
- delete compProps.__inner__;
2558
- if (this.hasChildren) {
2559
- return engine.createElement(Comp, compProps, this.children);
2560
- }
2561
- return engine.createElement(Comp, compProps);
2562
- }
2563
- }
2564
- const LeafWrapper = createForwardRefHocElement(LeafHoc, Comp);
2565
- cache.component.set(componentCacheId, {
2566
- LeafWrapper,
2567
- Comp
2568
- });
2569
- return LeafWrapper;
2570
- };
2571
-
2572
- function buildUrl(dataAPI, params) {
2573
- const paramStr = serializeParams(params);
2574
- if (paramStr) {
2575
- return dataAPI.indexOf('?') > 0 ? `${dataAPI}&${paramStr}` : `${dataAPI}?${paramStr}`;
2576
- }
2577
- return dataAPI;
2578
- }
2579
- function get(dataAPI, params = {}, headers = {}, otherProps = {}) {
2580
- const processedHeaders = {
2581
- Accept: 'application/json',
2582
- ...headers
2583
- };
2584
- const url = buildUrl(dataAPI, params);
2585
- return request(url, 'GET', null, processedHeaders, otherProps);
2586
- }
2587
- function post(dataAPI, params = {}, headers = {}, otherProps = {}) {
2588
- const processedHeaders = {
2589
- Accept: 'application/json',
2590
- 'Content-Type': 'application/x-www-form-urlencoded',
2591
- ...headers
2592
- };
2593
- const body = processedHeaders['Content-Type'].indexOf('application/json') > -1 || Array.isArray(params) ? JSON.stringify(params) : serializeParams(params);
2594
- return request(dataAPI, 'POST', body, processedHeaders, otherProps);
2595
- }
2596
- function request(dataAPI, method = 'GET', data, headers = {}, otherProps = {}) {
2597
- let processedHeaders = headers || {};
2598
- let payload = data;
2599
- if (method === 'PUT' || method === 'DELETE') {
2600
- processedHeaders = {
2601
- Accept: 'application/json',
2602
- 'Content-Type': 'application/json',
2603
- ...processedHeaders
2604
- };
2605
- payload = JSON.stringify(payload || {});
2606
- }
2607
- return new Promise((resolve, reject) => {
2608
- if (otherProps.timeout) {
2609
- setTimeout(() => {
2610
- reject(new Error('timeout'));
2611
- }, otherProps.timeout);
2612
- }
2613
- fetch(dataAPI, {
2614
- method,
2615
- credentials: 'include',
2616
- headers: processedHeaders,
2617
- body: payload,
2618
- ...otherProps
2619
- }).then(response => {
2620
- switch (response.status) {
2621
- case 200:
2622
- case 201:
2623
- case 202:
2624
- return response.json();
2625
- case 204:
2626
- if (method === 'DELETE') {
2627
- return {
2628
- success: true
2629
- };
2630
- } else {
2631
- return {
2632
- __success: false,
2633
- code: response.status
2634
- };
2635
- }
2636
- case 400:
2637
- case 401:
2638
- case 403:
2639
- case 404:
2640
- case 406:
2641
- case 410:
2642
- case 422:
2643
- case 500:
2644
- return response.json().then(res => {
2645
- return {
2646
- __success: false,
2647
- code: response.status,
2648
- data: res
2649
- };
2650
- }).catch(() => {
2651
- return {
2652
- __success: false,
2653
- code: response.status
2654
- };
2655
- });
2656
- }
2657
- return null;
2658
- }).then(json => {
2659
- if (!json) {
2660
- reject(json);
2661
- return;
2662
- }
2663
- if (json.__success !== false) {
2664
- resolve(json);
2665
- } else {
2666
- delete json.__success;
2667
- reject(json);
2668
- }
2669
- }).catch(err => {
2670
- reject(err);
2671
- });
2672
- });
2673
- }
2674
-
2675
- const DS_STATUS = {
2676
- INIT: 'init',
2677
- LOADING: 'loading',
2678
- LOADED: 'loaded',
2679
- ERROR: 'error'
2680
- };
2681
- function doRequest(type, options) {
2682
- let {
2683
- uri,
2684
- url,
2685
- method = 'GET',
2686
- headers,
2687
- params,
2688
- ...otherProps
2689
- } = options;
2690
- otherProps = otherProps || {};
2691
- if (type === 'fetch') {
2692
- switch (method.toUpperCase()) {
2693
- case 'GET':
2694
- return get(uri, params, headers, otherProps);
2695
- case 'POST':
2696
- return post(uri, params, headers, otherProps);
2697
- default:
2698
- return request(uri, method, params, headers, otherProps);
2699
- }
2700
- }
2701
- logger.log(`Engine default dataSource does not support type:[${type}] dataSource request!`, options);
2702
- }
2703
- class DataHelper {
2704
- host;
2705
- config;
2706
- parser;
2707
- ajaxList;
2708
- dataHandler;
2709
- ajaxMap;
2710
- dataSourceMap;
2711
- appHelper;
2712
- constructor(comp, config, appHelper, parser) {
2713
- this.host = comp;
2714
- this.config = config || {};
2715
- this.parser = parser;
2716
- this.ajaxList = config?.list || [];
2717
- this.ajaxMap = transformArrayToMap(this.ajaxList, 'id');
2718
- this.dataSourceMap = this.generateDataSourceMap();
2719
- this.appHelper = appHelper;
2720
- this.dataHandler = config?.dataHandler ? parseExpression(config?.dataHandler, comp, true) : undefined;
2721
- }
2722
- updateConfig(config = {}) {
2723
- this.config = config;
2724
- this.ajaxList = config?.list || [];
2725
- const ajaxMap = transformArrayToMap(this.ajaxList, 'id');
2726
- Object.keys(this.ajaxMap).forEach(key => {
2727
- if (!ajaxMap[key]) {
2728
- delete this.dataSourceMap[key];
2729
- }
2730
- });
2731
- this.ajaxMap = ajaxMap;
2732
- this.ajaxList.forEach(item => {
2733
- if (!this.dataSourceMap[item.id]) {
2734
- this.dataSourceMap[item.id] = {
2735
- status: DS_STATUS.INIT,
2736
- load: (...args) => {
2737
- return this.getDataSource(item.id, ...args);
2738
- }
2739
- };
2740
- }
2741
- });
2742
- return this.dataSourceMap;
2743
- }
2744
- generateDataSourceMap() {
2745
- const res = {};
2746
- this.ajaxList.forEach(item => {
2747
- res[item.id] = {
2748
- status: DS_STATUS.INIT,
2749
- load: (...args) => {
2750
- return this.getDataSource(item.id, ...args);
2751
- }
2752
- };
2753
- });
2754
- return res;
2755
- }
2756
- updateDataSourceMap(id, data, error) {
2757
- this.dataSourceMap[id].error = error || undefined;
2758
- this.dataSourceMap[id].data = data;
2759
- this.dataSourceMap[id].status = error ? DS_STATUS.ERROR : DS_STATUS.LOADED;
2760
- }
2761
- getInitDataSourseConfigs() {
2762
- const initConfigs = this.parser(this.ajaxList).filter(item => {
2763
- if (item.isInit === true) {
2764
- this.dataSourceMap[item.id].status = DS_STATUS.LOADING;
2765
- return true;
2766
- }
2767
- return false;
2768
- });
2769
- return initConfigs;
2770
- }
2771
- getInitData() {
2772
- const initSyncData = this.getInitDataSourseConfigs();
2773
- return this.asyncDataHandler(initSyncData).then(res => {
2774
- const {
2775
- dataHandler
2776
- } = this.config;
2777
- return this.handleData(null, dataHandler, res, null);
2778
- });
2779
- }
2780
- async reloadDataSource() {
2781
- const dataSourceMap = await this.getInitData();
2782
- if (isEmpty(dataSourceMap)) {
2783
- return;
2784
- }
2785
- this.host.setState(dataSourceMap);
2786
- if (this.dataHandler) {
2787
- this.dataHandler(dataSourceMap);
2788
- }
2789
- }
2790
- getDataSource(id, params, otherOptions, callback) {
2791
- const req = this.parser(this.ajaxMap[id]);
2792
- const options = req.options || {};
2793
- let callbackFn = callback;
2794
- let otherOptionsObj = otherOptions;
2795
- if (typeof otherOptions === 'function') {
2796
- callbackFn = otherOptions;
2797
- otherOptionsObj = {};
2798
- }
2799
- const {
2800
- headers,
2801
- ...otherProps
2802
- } = otherOptionsObj || {};
2803
- if (!req) {
2804
- logger.warn(`getDataSource API named ${id} not exist`);
2805
- return;
2806
- }
2807
- return this.asyncDataHandler([{
2808
- ...req,
2809
- options: {
2810
- ...options,
2811
- params: Array.isArray(options.params) || Array.isArray(params) ? params || options.params : {
2812
- ...options.params,
2813
- ...params
2814
- },
2815
- headers: {
2816
- ...options.headers,
2817
- ...headers
2818
- },
2819
- ...otherProps
2820
- }
2821
- }]).then(res => {
2822
- try {
2823
- callbackFn && callbackFn(res && res[id]);
2824
- } catch (e) {
2825
- logger.error('load请求回调函数报错', e);
2826
- }
2827
- return res && res[id];
2828
- }).catch(err => {
2829
- try {
2830
- callbackFn && callbackFn(null, err);
2831
- } catch (e) {
2832
- logger.error('load请求回调函数报错', e);
2833
- }
2834
- return err;
2835
- });
2836
- }
2837
- asyncDataHandler(asyncDataList) {
2838
- return new Promise((resolve, reject) => {
2839
- const allReq = [];
2840
- asyncDataList.forEach(req => {
2841
- const {
2842
- id,
2843
- type
2844
- } = req;
2845
- if (!id || !type || type === 'legao') {
2846
- return;
2847
- }
2848
- allReq.push(req);
2849
- });
2850
- if (allReq.length === 0) {
2851
- resolve({});
2852
- }
2853
- const res = {};
2854
- Promise.all(allReq.map(item => {
2855
- return new Promise(innerResolve => {
2856
- const {
2857
- type,
2858
- id,
2859
- dataHandler,
2860
- options
2861
- } = item;
2862
- const fetchHandler = (data, error) => {
2863
- res[id] = this.handleData(id, dataHandler, data, error);
2864
- this.updateDataSourceMap(id, res[id], error);
2865
- innerResolve({});
2866
- };
2867
- const doFetch = (innerType, innerOptions) => {
2868
- doRequest(innerType, innerOptions)?.then(data => {
2869
- fetchHandler(data, undefined);
2870
- }).catch(err => {
2871
- fetchHandler(undefined, err);
2872
- });
2873
- };
2874
- this.dataSourceMap[id].status = DS_STATUS.LOADING;
2875
- doFetch(type, options);
2876
- });
2877
- })).then(() => {
2878
- resolve(res);
2879
- }).catch(e => {
2880
- reject(e);
2881
- });
2882
- });
2883
- }
2884
- handleData(id, dataHandler, data, error) {
2885
- let dataHandlerFun = dataHandler;
2886
- if (isJSFunction(dataHandler)) {
2887
- dataHandlerFun = transformStringToFunction(dataHandler.value);
2888
- }
2889
- if (!dataHandlerFun || typeof dataHandlerFun !== 'function') {
2890
- return data;
2891
- }
2892
- try {
2893
- return dataHandlerFun.call(this.host, data, error);
2894
- } catch (e) {
2895
- if (id) {
2896
- logger.error(`[${id}]单个请求数据处理函数运行出错`, e);
2897
- } else {
2898
- logger.error('请求数据处理函数运行出错', e);
2899
- }
2900
- }
2901
- }
2902
- }
2903
-
2904
- function executeLifeCycleMethod(context, schema, method, args) {
2905
- if (!context || !isSchema(schema) || !method) {
2906
- return;
2907
- }
2908
- const lifeCycleMethods = getValue(schema, 'lifeCycles', {});
2909
- let fn = lifeCycleMethods[method];
2910
- if (!fn) {
2911
- return;
2912
- }
2913
-
2914
- // TODO: cache
2915
- if (isJSExpression(fn) || isJSFunction(fn)) {
2916
- fn = parseExpression(fn, context, true);
2917
- }
2918
- if (typeof fn !== 'function') {
2919
- logger.error(`生命周期${method}类型不符`, fn);
2920
- return;
2921
- }
2922
- try {
2923
- return fn.apply(context, args);
2924
- } catch (e) {
2925
- logger.error(`[${schema.componentName}]生命周期${method}出错`, e);
2926
- }
2927
- }
2928
-
2929
- /**
2930
- * get children from a node schema
2931
- */
2932
- function getSchemaChildren(schema) {
2933
- if (!schema) {
2934
- return;
2935
- }
2936
- return schema.children;
2937
- }
2938
- function baseRendererFactory() {
2939
- const {
2940
- BaseRenderer: customBaseRenderer
2941
- } = adapter.getRenderers();
2942
- if (customBaseRenderer) {
2943
- return customBaseRenderer;
2944
- }
2945
- const DEFAULT_LOOP_ARG_ITEM = 'item';
2946
- const DEFAULT_LOOP_ARG_INDEX = 'index';
2947
- // const scopeIdx = 0
2948
-
2949
- return class BaseRenderer extends Component {
2950
- static displayName = 'BaseRenderer';
2951
- static defaultProps = {
2952
- __schema: {}
2953
- };
2954
- static contextType = RendererContext;
2955
- dataSourceMap = {};
2956
- __namespace = 'base';
2957
- __compScopes = {};
2958
- __instanceMap = {};
2959
- __dataHelper;
2960
-
2961
- /**
2962
- * keep track of customMethods added to this context
2963
- *
2964
- * @type {any}
2965
- */
2966
- __customMethodsList = [];
2967
- __parseExpression;
2968
- __ref;
2969
-
2970
- /**
2971
- * reference of style element contains schema.css
2972
- *
2973
- * @type {any}
2974
- */
2975
- __styleElement;
2976
- constructor(props) {
2977
- super(props);
2978
- this.__parseExpression = (str, self) => {
2979
- return parseExpression({
2980
- str,
2981
- self,
2982
- logScope: props.componentName
2983
- });
2984
- };
2985
- this.__beforeInit(props);
2986
- this.__init(props);
2987
- this.__afterInit(props);
2988
- logger.log(`constructor - ${props?.__schema?.fileName}`);
2989
- }
2990
- __beforeInit(props) {}
2991
- __init(props) {
2992
- this.__compScopes = {};
2993
- this.__instanceMap = {};
2994
- this.__bindCustomMethods(props);
2995
- }
2996
- __afterInit(props) {}
2997
- static getDerivedStateFromProps(props, state) {
2998
- const result = executeLifeCycleMethod(this, props?.__schema, 'getDerivedStateFromProps', [props, state]);
2999
- return result === undefined ? null : result;
3000
- }
3001
- async getSnapshotBeforeUpdate(...args) {
3002
- this.__executeLifeCycleMethod('getSnapshotBeforeUpdate', args);
3003
- logger.log(`getSnapshotBeforeUpdate - ${this.props?.__schema?.componentName}`);
3004
- }
3005
- async componentDidMount(...args) {
3006
- this.reloadDataSource();
3007
- this.__executeLifeCycleMethod('componentDidMount', args);
3008
- logger.log(`componentDidMount - ${this.props?.__schema?.componentName}`);
3009
- }
3010
- async componentDidUpdate(...args) {
3011
- this.__executeLifeCycleMethod('componentDidUpdate', args);
3012
- logger.log(`componentDidUpdate - ${this.props.__schema.componentName}`);
3013
- }
3014
- async componentWillUnmount(...args) {
3015
- this.__executeLifeCycleMethod('componentWillUnmount', args);
3016
- logger.log(`componentWillUnmount - ${this.props?.__schema?.componentName}`);
3017
- }
3018
- async componentDidCatch(...args) {
3019
- this.__executeLifeCycleMethod('componentDidCatch', args);
3020
- logger.warn(args);
3021
- }
3022
- reloadDataSource = () => new Promise((resolve, reject) => {
3023
- logger.log('reload data source');
3024
- if (!this.__dataHelper) {
3025
- return resolve({});
3026
- }
3027
- this.__dataHelper.getInitData().then(res => {
3028
- if (isEmpty(res)) {
3029
- this.forceUpdate();
3030
- return resolve({});
3031
- }
3032
- this.setState(res, resolve);
3033
- }).catch(err => {
3034
- reject(err);
3035
- });
3036
- });
3037
- shouldComponentUpdate() {
3038
- if (this.props.getSchemaChangedSymbol?.() && this.props.__container?.rerender) {
3039
- this.props.__container?.rerender();
3040
- return false;
3041
- }
3042
- return true;
3043
- }
3044
- forceUpdate() {
3045
- if (this.shouldComponentUpdate()) {
3046
- super.forceUpdate();
3047
- }
3048
- }
3049
-
3050
- /**
3051
- * execute method in schema.lifeCycles
3052
- */
3053
- __executeLifeCycleMethod = (method, args) => {
3054
- // 跳过 construct 的执行
3055
- if (this.context) {
3056
- const {
3057
- engine
3058
- } = this.context;
3059
- if (!engine.props.excuteLifeCycleInDesignMode) {
3060
- return;
3061
- }
3062
- }
3063
- executeLifeCycleMethod(this, this.props.__schema, method, args);
3064
- };
3065
-
3066
- /**
3067
- * this method is for legacy purpose only, which used _ prefix instead of __ as private for some historical reasons
3068
- */
3069
- __getComponentView = () => {
3070
- const {
3071
- __components,
3072
- __schema
3073
- } = this.props;
3074
- if (!__components) {
3075
- return;
3076
- }
3077
- return __components[__schema.componentName];
3078
- };
3079
- __bindCustomMethods = props => {
3080
- const {
3081
- __schema
3082
- } = props;
3083
- const customMethodsList = Object.keys(__schema.methods || {}) || [];
3084
- (this.__customMethodsList || []).forEach(item => {
3085
- if (!customMethodsList.includes(item)) {
3086
- delete this[item];
3087
- }
3088
- });
3089
- this.__customMethodsList = customMethodsList;
3090
- forEach(__schema.methods, (val, key) => {
3091
- let value = val;
3092
- if (isJSExpression(value) || isJSFunction(value)) {
3093
- value = this.__parseExpression(value, this);
3094
- }
3095
- if (typeof value !== 'function') {
3096
- logger.error(`custom method ${key} can not be parsed to a valid function`, value);
3097
- return;
3098
- }
3099
- this[key] = value.bind(this);
3100
- });
3101
- };
3102
- __generateCtx = ctx => {
3103
- const {
3104
- pageContext,
3105
- compContext
3106
- } = this.context;
3107
- const obj = {
3108
- page: pageContext,
3109
- component: compContext,
3110
- ...ctx
3111
- };
3112
- forEach(obj, (val, key) => {
3113
- this[key] = val;
3114
- });
3115
- };
3116
- __parseData = (data, ctx) => {
3117
- const {
3118
- __ctx,
3119
- componentName
3120
- } = this.props;
3121
- return parseData(data, ctx || __ctx || this, {
3122
- logScope: componentName
3123
- });
3124
- };
3125
- __initDataSource = props => {
3126
- if (!props) {
3127
- return;
3128
- }
3129
- const schema = props.__schema || {};
3130
- const defaultDataSource = {
3131
- list: []
3132
- };
3133
- const dataSource = schema.dataSource || defaultDataSource;
3134
- // requestHandlersMap 存在才走数据源引擎方案
3135
- // TODO: 下面if else 抽成独立函数
3136
- const useDataSourceEngine = !!props.__appHelper?.requestHandlersMap;
3137
- if (useDataSourceEngine) {
3138
- this.__dataHelper = {
3139
- updateConfig: updateDataSource => {
3140
- const {
3141
- dataSourceMap,
3142
- reloadDataSource
3143
- } = createDataSourceEngine(updateDataSource ?? {}, this, props.__appHelper?.requestHandlersMap ? {
3144
- requestHandlersMap: props.__appHelper.requestHandlersMap
3145
- } : undefined);
3146
- this.reloadDataSource = () => new Promise(resolve => {
3147
- logger.log('reload data source');
3148
- reloadDataSource().then(() => {
3149
- resolve({});
3150
- });
3151
- });
3152
- return dataSourceMap;
3153
- }
3154
- };
3155
- this.dataSourceMap = this.__dataHelper.updateConfig(dataSource);
3156
- } else {
3157
- const appHelper = props.__appHelper || {};
3158
- this.__dataHelper = new DataHelper(this, dataSource, appHelper, config => this.__parseData(config));
3159
- this.dataSourceMap = this.__dataHelper.dataSourceMap;
3160
- this.reloadDataSource = () => new Promise(resolve => {
3161
- logger.log('reload data source');
3162
- this.__dataHelper.reloadDataSource().then(() => {
3163
- resolve({});
3164
- });
3165
- });
3166
- }
3167
- };
3168
-
3169
- /**
3170
- * write props.__schema.css to document as a style element,
3171
- * which will be added once and only once.
3172
- * @PRIVATE
3173
- */
3174
- __writeCss = props => {
3175
- const css = getValue(props.__schema, 'css', '');
3176
- logger.log('create this.styleElement with css', css);
3177
- let style = this.__styleElement;
3178
- if (!this.__styleElement) {
3179
- style = document.createElement('style');
3180
- style.type = 'text/css';
3181
- style.setAttribute('from', 'style-sheet');
3182
- const head = document.head || document.getElementsByTagName('head')[0];
3183
- head.appendChild(style);
3184
- this.__styleElement = style;
3185
- logger.log('this.styleElement is created', this.__styleElement);
3186
- }
3187
- if (style.innerHTML === css) {
3188
- return;
3189
- }
3190
- style.innerHTML = css;
3191
- };
3192
- __render = () => {
3193
- const schema = this.props.__schema;
3194
- this.__executeLifeCycleMethod('render');
3195
- this.__writeCss(this.props);
3196
- const {
3197
- engine
3198
- } = this.context;
3199
- if (engine) {
3200
- engine.props?.onCompGetCtx?.(schema, this);
3201
- // 画布场景才需要每次渲染bind自定义方法
3202
- if (this.__designModeIsDesign) {
3203
- this.__bindCustomMethods(this.props);
3204
- this.dataSourceMap = this.__dataHelper?.updateConfig(schema.dataSource);
3205
- }
3206
- }
3207
- };
3208
- __getRef = ref => {
3209
- const {
3210
- engine
3211
- } = this.context;
3212
- const {
3213
- __schema
3214
- } = this.props;
3215
- // ref && engine?.props?.onCompGetRef(__schema, ref)
3216
- // TODO: 只在 ref 存在执行,会影响 documentInstance 的卸载
3217
- engine.props?.onCompGetRef?.(__schema, ref);
3218
- this.__ref = ref;
3219
- };
3220
- __createDom = () => {
3221
- const {
3222
- __schema,
3223
- __ctx
3224
- } = this.props;
3225
- // merge defaultProps
3226
- const scopeProps = {
3227
- ...__schema.defaultProps,
3228
- ...this.props
3229
- };
3230
- const scope = {
3231
- props: scopeProps
3232
- };
3233
- scope.__proto__ = __ctx || this;
3234
- const _children = getSchemaChildren(__schema);
3235
- const Comp = this.__getComponentView();
3236
- if (!Comp) {
3237
- logger.log(`${__schema.componentName} is invalid!`);
3238
- }
3239
- const parentNodeInfo = {
3240
- schema: __schema,
3241
- Comp: this.__getHOCWrappedComponent(Comp, {
3242
- schema: __schema,
3243
- scope
3244
- })
3245
- };
3246
- return this.__createVirtualDom(_children, scope, parentNodeInfo);
3247
- };
3248
-
3249
- /**
3250
- * 将模型结构转换成react Element
3251
- * @param originalSchema schema
3252
- * @param originalScope scope
3253
- * @param parentInfo 父组件的信息,包含schema和Comp
3254
- * @param idx 为循环渲染的循环Index
3255
- */
3256
- __createVirtualDom = (originalSchema, originalScope, parentInfo, idx = '') => {
3257
- if (originalSchema === null || originalSchema === undefined) {
3258
- return null;
3259
- }
3260
- const scope = originalScope;
3261
- const schema = originalSchema;
3262
- const {
3263
- engine
3264
- } = this.context || {};
3265
- if (!engine) {
3266
- logger.log('this.context.engine is invalid!');
3267
- return null;
3268
- }
3269
- try {
3270
- const {
3271
- __appHelper: appHelper,
3272
- __components: components = {}
3273
- } = this.props || {};
3274
- if (isJSExpression(schema)) {
3275
- return this.__parseExpression(schema, scope);
3276
- }
3277
- if (typeof schema === 'string') {
3278
- return schema;
3279
- }
3280
- if (typeof schema === 'number' || typeof schema === 'boolean') {
3281
- return String(schema);
3282
- }
3283
- if (Array.isArray(schema)) {
3284
- if (schema.length === 1) {
3285
- return this.__createVirtualDom(schema[0], scope, parentInfo);
3286
- }
3287
- return schema.map((item, idy) => this.__createVirtualDom(item, scope, parentInfo, item?.__ctx?.lceKey ? '' : String(idy)));
3288
- }
3289
- if (schema.$$typeof) {
3290
- return schema;
3291
- }
3292
- if (!schema.componentName) {
3293
- logger.error('The componentName in the schema is invalid, please check the schema: ', schema);
3294
- return;
3295
- }
3296
- if (!isSchema(schema)) {
3297
- return null;
3298
- }
3299
- let Comp = components[schema.componentName] || this.props.__container?.components?.[schema.componentName];
3300
-
3301
- // 容器类组件的上下文通过props传递,避免context传递带来的嵌套问题
3302
- const otherProps = isSchema(schema) ? {
3303
- __schema: schema,
3304
- __appHelper: appHelper,
3305
- __components: components
3306
- } : {};
3307
- if (!Comp) {
3308
- logger.error(`${schema.componentName} component is not found in components list! component list is:`, components || this.props.__container?.components);
3309
- return engine.createElement(engine.getNotFoundComponent(), {
3310
- componentName: schema.componentName,
3311
- componentId: schema.id,
3312
- enableStrictNotFoundMode: engine.props.enableStrictNotFoundMode,
3313
- ref: ref => {
3314
- ref && engine.props?.onCompGetRef?.(schema, ref);
3315
- }
3316
- }, this.__getSchemaChildrenVirtualDom(schema, scope, Comp));
3317
- }
3318
- if (schema.loop != null) {
3319
- const loop = this.__parseData(schema.loop, scope);
3320
- if (Array.isArray(loop) && loop.length === 0) return null;
3321
- const useLoop = isUseLoop(loop, this.__designModeIsDesign);
3322
- if (useLoop) {
3323
- return this.__createLoopVirtualDom({
3324
- ...schema,
3325
- loop
3326
- }, scope, parentInfo, idx);
3327
- }
3328
- }
3329
- const condition = schema.condition == null ? true : this.__parseData(schema.condition, scope);
3330
-
3331
- // DesignMode 为 design 情况下,需要进入 leaf Hoc,进行相关事件注册
3332
- const displayInHook = this.__designModeIsDesign;
3333
- if (!condition && !displayInHook) {
3334
- return null;
3335
- }
3336
-
3337
- // TODO: scope
3338
- // let scopeKey = ''
3339
- // // 判断组件是否需要生成scope,且只生成一次,挂在this.__compScopes上
3340
- // if (Comp.generateScope) {
3341
- // const key = this.__parseExpression(schema.props?.key, scope)
3342
- // if (key) {
3343
- // // 如果组件自己设置key则使用组件自己的key
3344
- // scopeKey = key
3345
- // } else if (schema.__ctx) {
3346
- // // 需要判断循环的情况
3347
- // scopeKey = schema.__ctx.lceKey + (idx !== undefined ? `_${idx}` : '')
3348
- // } else {
3349
- // // 在生产环境schema没有__ctx上下文,需要手动生成一个lceKey
3350
- // schema.__ctx = {
3351
- // lceKey: `lce${++scopeIdx}`,
3352
- // }
3353
- // scopeKey = schema.__ctx.lceKey
3354
- // }
3355
- // if (!this.__compScopes[scopeKey]) {
3356
- // this.__compScopes[scopeKey] = Comp.generateScope(this, schema)
3357
- // }
3358
- // }
3359
- // // 如果组件有设置scope,需要为组件生成一个新的scope上下文
3360
- // if (scopeKey && this.__compScopes[scopeKey]) {
3361
- // const compSelf = { ...this.__compScopes[scopeKey] }
3362
- // compSelf.__proto__ = scope
3363
- // scope = compSelf
3364
- // }
3365
-
3366
- if (engine.props?.designMode) {
3367
- otherProps.__designMode = engine.props.designMode;
3368
- }
3369
- if (this.__designModeIsDesign) {
3370
- otherProps.__tag = Math.random();
3371
- }
3372
- const componentInfo = {};
3373
- const props = this.__getComponentProps(schema, scope, Comp, {
3374
- ...componentInfo,
3375
- props: transformArrayToMap(componentInfo.props, 'name')
3376
- }) || {};
3377
- Comp = this.__getHOCWrappedComponent(Comp, {
3378
- schema,
3379
- componentInfo,
3380
- baseRenderer: this,
3381
- scope
3382
- });
3383
- otherProps.ref = ref => {
3384
- this.$(schema.id || props.ref, ref); // 收集ref
3385
- const refProps = props.ref;
3386
- if (refProps && typeof refProps === 'string') {
3387
- this[refProps] = ref;
3388
- }
3389
- ref && engine.props?.onCompGetRef?.(schema, ref);
3390
- };
3391
-
3392
- // scope需要传入到组件上
3393
- // if (scopeKey && this.__compScopes[scopeKey]) {
3394
- // props.__scope = this.__compScopes[scopeKey]
3395
- // }
3396
- if (schema?.__ctx?.lceKey) {
3397
- if (!isSchema(schema)) {
3398
- engine.props?.onCompGetCtx?.(schema, scope);
3399
- }
3400
- props.key = props.key || `${schema.__ctx.lceKey}_${schema.__ctx.idx || 0}_${idx !== undefined ? idx : ''}`;
3401
- } else if ((typeof idx === 'number' || typeof idx === 'string') && !props.key) {
3402
- // 仅当循环场景走这里
3403
- props.key = idx;
3404
- }
3405
- props.__id = schema.id;
3406
- if (!props.key) {
3407
- props.key = props.__id;
3408
- }
3409
- return engine.createElement(Comp, {
3410
- ...props,
3411
- ...otherProps,
3412
- // TODO: 看看这里需要怎么处理简洁
3413
- __inner__: {
3414
- hidden: schema.hidden,
3415
- condition
3416
- }
3417
- }, this.__getSchemaChildrenVirtualDom(schema, scope, Comp, condition));
3418
- } catch (e) {
3419
- return engine.createElement(engine.getFaultComponent(), {
3420
- error: e,
3421
- schema,
3422
- self: scope,
3423
- parentInfo,
3424
- idx
3425
- });
3426
- }
3427
- };
3428
-
3429
- /**
3430
- * get Component HOCs
3431
- *
3432
- * @readonly
3433
- * @type {ComponentConstruct[]}
3434
- */
3435
- get __componentHOCs() {
3436
- if (this.__designModeIsDesign) {
3437
- return [leafWrapper, compWrapper];
3438
- }
3439
- return [compWrapper];
3440
- }
3441
- __getSchemaChildrenVirtualDom = (schema, scope, Comp, condition = true) => {
3442
- let children = condition ? getSchemaChildren(schema) : null;
3443
- const result = [];
3444
- if (children) {
3445
- if (!Array.isArray(children)) {
3446
- children = [children];
3447
- }
3448
- children.forEach(child => {
3449
- const childVirtualDom = this.__createVirtualDom(isJSExpression(child) ? this.__parseExpression(child, scope) : child, scope, {
3450
- schema,
3451
- Comp
3452
- });
3453
- result.push(childVirtualDom);
3454
- });
3455
- }
3456
- if (result && result.length > 0) {
3457
- return result;
3458
- }
3459
- return null;
3460
- };
3461
- __getComponentProps = (schema, scope, Comp, componentInfo) => {
3462
- if (!schema) {
3463
- return {};
3464
- }
3465
- return this.__parseProps(schema?.props, scope, '', {
3466
- schema,
3467
- Comp,
3468
- componentInfo: {
3469
- ...(componentInfo || {}),
3470
- props: transformArrayToMap((componentInfo || {}).props, 'name')
3471
- }
3472
- }) || {};
3473
- };
3474
- __createLoopVirtualDom = (schema, scope, parentInfo, idx) => {
3475
- // TODO
3476
- // if (isSchema(schema)) {
3477
- // logger.warn('file type not support Loop')
3478
- // return null
3479
- // }
3480
- if (!Array.isArray(schema.loop)) {
3481
- return null;
3482
- }
3483
- const itemArg = schema.loopArgs && schema.loopArgs[0] || DEFAULT_LOOP_ARG_ITEM;
3484
- const indexArg = schema.loopArgs && schema.loopArgs[1] || DEFAULT_LOOP_ARG_INDEX;
3485
- const {
3486
- loop
3487
- } = schema;
3488
- return loop.map((item, i) => {
3489
- const loopSelf = {
3490
- [itemArg]: item,
3491
- [indexArg]: i
3492
- };
3493
- loopSelf.__proto__ = scope;
3494
- return this.__createVirtualDom({
3495
- ...schema,
3496
- loop: undefined,
3497
- props: {
3498
- ...schema.props,
3499
- // 循环下 key 不能为常量,这样会造成 key 值重复,渲染异常
3500
- key: isJSExpression(schema.props?.key) ? schema.props?.key : null
3501
- }
3502
- }, loopSelf, parentInfo, idx ? `${idx}_${i}` : i);
3503
- });
3504
- };
3505
- get __designModeIsDesign() {
3506
- const {
3507
- engine
3508
- } = this.context || {};
3509
- return engine?.props?.designMode === 'design';
3510
- }
3511
- __parseProps = (originalProps, scope, path, info) => {
3512
- let props = originalProps;
3513
- const {
3514
- schema,
3515
- Comp,
3516
- componentInfo = {}
3517
- } = info;
3518
- const propInfo = getValue(componentInfo.props, path);
3519
- // FIXME: 将这行逻辑外置,解耦,线上环境不要验证参数,调试环境可以有,通过传参自定义
3520
- const propType = propInfo?.extra?.propType;
3521
- const checkProps = value => {
3522
- if (!propType) {
3523
- return value;
3524
- }
3525
- return checkPropTypes(value, path, propType, componentInfo.name) ? value : undefined;
3526
- };
3527
- const parseReactNode = (data, params) => {
3528
- if (isEmpty(params)) {
3529
- const virtualDom = this.__createVirtualDom(data, scope, {
3530
- schema,
3531
- Comp
3532
- });
3533
- return checkProps(virtualDom);
3534
- }
3535
- return checkProps((...argValues) => {
3536
- const args = {};
3537
- if (Array.isArray(params) && params.length) {
3538
- params.forEach((item, idx) => {
3539
- if (typeof item === 'string') {
3540
- args[item] = argValues[idx];
3541
- } else if (item && typeof item === 'object') {
3542
- args[item.name] = argValues[idx];
3543
- }
3544
- });
3545
- }
3546
- args.__proto__ = scope;
3547
- return scope.__createVirtualDom(data, args, {
3548
- schema,
3549
- Comp
3550
- });
3551
- });
3552
- };
3553
- if (isJSExpression(props)) {
3554
- props = this.__parseExpression(props, scope);
3555
- // 只有当变量解析出来为模型结构的时候才会继续解析
3556
- if (!isSchema(props)) {
3557
- return checkProps(props);
3558
- }
3559
- }
3560
- if (isJSFunction(props)) {
3561
- props = transformStringToFunction(props.value);
3562
- }
3563
-
3564
- // 兼容通过componentInfo判断的情况
3565
- if (isSchema(props)) {
3566
- const isReactNodeFunction = !!(propInfo?.type === 'ReactNode' && propInfo?.props?.type === 'function');
3567
- const isMixinReactNodeFunction = !!(propInfo?.type === 'Mixin' && propInfo?.props?.types?.indexOf('ReactNode') > -1 && propInfo?.props?.reactNodeProps?.type === 'function');
3568
- let params = null;
3569
- if (isReactNodeFunction) {
3570
- params = propInfo?.props?.params;
3571
- } else if (isMixinReactNodeFunction) {
3572
- params = propInfo?.props?.reactNodeProps?.params;
3573
- }
3574
- return parseReactNode(props, params);
3575
- }
3576
- if (Array.isArray(props)) {
3577
- return checkProps(props.map((item, idx) => this.__parseProps(item, scope, path ? `${path}.${idx}` : `${idx}`, info)));
3578
- }
3579
- if (typeof props === 'function') {
3580
- return checkProps(props.bind(scope));
3581
- }
3582
- if (props && typeof props === 'object') {
3583
- if (props.$$typeof) {
3584
- return checkProps(props);
3585
- }
3586
- const res = {};
3587
- forEach(props, (val, key) => {
3588
- if (key.startsWith('__')) {
3589
- res[key] = val;
3590
- return;
3591
- }
3592
- res[key] = this.__parseProps(val, scope, path ? `${path}.${key}` : key, info);
3593
- });
3594
- return checkProps(res);
3595
- }
3596
- return checkProps(props);
3597
- };
3598
- $(id, instance) {
3599
- this.__instanceMap = this.__instanceMap || {};
3600
- if (!id || typeof id !== 'string') {
3601
- return this.__instanceMap;
3602
- }
3603
- if (instance) {
3604
- this.__instanceMap[id] = instance;
3605
- }
3606
- return this.__instanceMap[id];
3607
- }
3608
- __renderContextProvider = (customProps, children) => {
3609
- return /*#__PURE__*/jsx(RendererContext.Provider, {
3610
- value: {
3611
- ...this.context,
3612
- blockContext: this,
3613
- ...(customProps || {})
3614
- },
3615
- children: children || this.__createDom()
3616
- });
3617
- };
3618
- __renderContextConsumer = children => {
3619
- return /*#__PURE__*/jsx(RendererContext.Consumer, {
3620
- children: children
3621
- });
3622
- };
3623
- __getHOCWrappedComponent(OriginalComp, info) {
3624
- let Comp = OriginalComp;
3625
- this.__componentHOCs.forEach(ComponentConstruct => {
3626
- Comp = ComponentConstruct(Comp, {
3627
- componentInfo: {},
3628
- baseRenderer: this,
3629
- ...info
3630
- });
3631
- });
3632
- return Comp;
3633
- }
3634
- __renderComp(OriginalComp, ctxProps) {
3635
- let Comp = OriginalComp;
3636
- const {
3637
- __schema,
3638
- __ctx
3639
- } = this.props;
3640
- const scope = {};
3641
- scope.__proto__ = __ctx || this;
3642
- Comp = this.__getHOCWrappedComponent(Comp, {
3643
- schema: __schema,
3644
- scope
3645
- });
3646
- const data = this.__parseProps(__schema?.props, scope, '', {
3647
- schema: __schema,
3648
- Comp,
3649
- componentInfo: {}
3650
- });
3651
- const {
3652
- className
3653
- } = data;
3654
- const otherProps = {};
3655
- const {
3656
- engine
3657
- } = this.context || {};
3658
- if (!engine) {
3659
- return null;
3660
- }
3661
- if (this.__designModeIsDesign) {
3662
- otherProps.__tag = Math.random();
3663
- }
3664
- const child = engine.createElement(Comp, {
3665
- ...data,
3666
- ...this.props,
3667
- ref: this.__getRef,
3668
- className: classnames(__schema?.fileName && getFileCssName(__schema.fileName), className, this.props.className),
3669
- __id: __schema?.id,
3670
- ...otherProps
3671
- }, this.__createDom());
3672
- return this.__renderContextProvider(ctxProps, child);
3673
- }
3674
- __renderContent(children) {
3675
- const {
3676
- __schema
3677
- } = this.props;
3678
- const parsedProps = this.__parseData(__schema.props);
3679
- const className = classnames(`lce-${this.__namespace}`, __schema?.fileName && getFileCssName(__schema.fileName), parsedProps.className, this.props.className);
3680
- const style = {
3681
- ...(parsedProps.style || {}),
3682
- ...(typeof this.props.style === 'object' ? this.props.style : {})
3683
- };
3684
- const id = this.props.id || parsedProps.id;
3685
- return /*#__PURE__*/jsx("div", {
3686
- ref: this.__getRef,
3687
- className: className,
3688
- id: id,
3689
- style: style,
3690
- children: children
3691
- });
3692
- }
3693
- __checkSchema = (schema, originalExtraComponents = []) => {
3694
- let extraComponents = originalExtraComponents;
3695
- if (typeof extraComponents === 'string') {
3696
- extraComponents = [extraComponents];
3697
- }
3698
-
3699
- // const builtin = capitalizeFirstLetter(this.__namespace)
3700
- // const componentNames = [builtin, ...extraComponents]
3701
- const componentNames = [...Object.keys(this.props.__components), ...extraComponents];
3702
- return !isSchema(schema) || !componentNames.includes(schema?.componentName ?? '');
3703
- };
3704
- get appHelper() {
3705
- return this.props.__appHelper;
3706
- }
3707
- get requestHandlersMap() {
3708
- return this.appHelper?.requestHandlersMap;
3709
- }
3710
- get utils() {
3711
- return this.appHelper?.utils;
3712
- }
3713
- get constants() {
3714
- return this.appHelper?.constants;
3715
- }
3716
-
3717
- // render() {
3718
- // return null
3719
- // }
3720
- };
3721
- }
3722
-
3723
- function componentRendererFactory() {
3724
- const BaseRenderer = baseRendererFactory();
3725
- return class CompRenderer extends BaseRenderer {
3726
- static displayName = 'CompRenderer';
3727
- __namespace = 'component';
3728
- __afterInit(props, ...rest) {
3729
- this.__generateCtx({
3730
- component: this
3731
- });
3732
- const schema = props.__schema || {};
3733
- this.state = this.__parseData(schema.state || {});
3734
- this.__initDataSource(props);
3735
- this.__executeLifeCycleMethod('constructor', [props, ...rest]);
3736
- }
3737
- render() {
3738
- const {
3739
- __schema
3740
- } = this.props;
3741
- if (this.__checkSchema(__schema)) {
3742
- return '自定义组件 schema 结构异常!';
3743
- }
3744
- logger.log(`${CompRenderer.displayName} render - ${__schema.componentName}`);
3745
- this.__generateCtx({
3746
- component: this
3747
- });
3748
- this.__render();
3749
- const noContainer = this.__parseData(__schema.props?.noContainer);
3750
- this.__bindCustomMethods(this.props);
3751
- if (noContainer) {
3752
- return this.__renderContextProvider({
3753
- compContext: this
3754
- });
3755
- }
3756
- const Comp = this.__getComponentView();
3757
- if (!Comp) {
3758
- return this.__renderContent(this.__renderContextProvider({
3759
- compContext: this
3760
- }));
3761
- }
3762
- return this.__renderComp(Comp, {
3763
- compContext: this
3764
- });
3765
- }
3766
- };
3767
- }
3768
-
3769
- function pageRendererFactory() {
3770
- const BaseRenderer = baseRendererFactory();
3771
- return class PageRenderer extends BaseRenderer {
3772
- static displayName = 'PageRenderer';
3773
- __namespace = 'page';
3774
- __afterInit(props, ...rest) {
3775
- const schema = props.__schema || {};
3776
- this.state = this.__parseData(schema.state || {});
3777
- this.__initDataSource(props);
3778
- this.__executeLifeCycleMethod('constructor', [props, ...rest]);
3779
- }
3780
- async componentDidUpdate(prevProps, _prevState, snapshot) {
3781
- const {
3782
- __ctx
3783
- } = this.props;
3784
- // 当编排的时候修改 schema.state 值,需要将最新 schema.state 值 setState
3785
- if (JSON.stringify(prevProps.__schema.state) !== JSON.stringify(this.props.__schema.state)) {
3786
- const newState = this.__parseData(this.props.__schema.state, __ctx);
3787
- this.setState(newState);
3788
- }
3789
- super.componentDidUpdate?.(prevProps, _prevState, snapshot);
3790
- }
3791
- setState(state, callback) {
3792
- logger.log('page set state', state);
3793
- super.setState(state, callback);
3794
- }
3795
- render() {
3796
- const {
3797
- __schema
3798
- } = this.props;
3799
- if (this.__checkSchema(__schema)) {
3800
- return '页面schema结构异常!';
3801
- }
3802
- logger.log(`${PageRenderer.displayName} render - ${__schema.componentName}`);
3803
- this.__bindCustomMethods(this.props);
3804
- this.__initDataSource(this.props);
3805
- this.__generateCtx({
3806
- page: this
3807
- });
3808
- this.__render();
3809
- const Comp = this.__getComponentView();
3810
- if (!Comp) {
3811
- return this.__renderContent(this.__renderContextProvider({
3812
- pageContext: this
3813
- }));
3814
- }
3815
- return this.__renderComp(Comp, {
3816
- pageContext: this
3817
- });
3818
- }
3819
- };
3820
- }
3821
-
3822
- const FaultComponent = ({
3823
- componentName = '',
3824
- error
3825
- }) => {
3826
- logger.error(`${componentName} 组件渲染异常, 异常原因: ${error?.message || error || '未知'}`);
3827
- return /*#__PURE__*/jsxs("div", {
3828
- role: "alert",
3829
- "aria-label": `${componentName} 组件渲染异常`,
3830
- style: {
3831
- width: '100%',
3832
- height: '50px',
3833
- lineHeight: '50px',
3834
- textAlign: 'center',
3835
- fontSize: '15px',
3836
- color: '#ef4444',
3837
- border: '2px solid #ef4444'
3838
- },
3839
- children: [componentName, " \u7EC4\u4EF6\u6E32\u67D3\u5F02\u5E38\uFF0C\u8BF7\u67E5\u770B\u63A7\u5236\u53F0\u65E5\u5FD7"]
3840
- });
3841
- };
3842
-
3843
- const NotFoundComponent = ({
3844
- componentName = '',
3845
- enableStrictNotFoundMode,
3846
- children
3847
- }) => {
3848
- logger.warn(`Component ${componentName} not found`);
3849
- if (enableStrictNotFoundMode) {
3850
- return /*#__PURE__*/jsx(Fragment, {
3851
- children: `${componentName} Component Not Found`
3852
- });
3853
- }
3854
- return /*#__PURE__*/jsx("div", {
3855
- role: "alert",
3856
- "aria-label": `${componentName} component not found`,
3857
- style: {
3858
- width: '100%',
3859
- height: '50px',
3860
- lineHeight: '50px',
3861
- textAlign: 'center',
3862
- fontSize: '15px',
3863
- color: '#eab308',
3864
- border: '2px solid #eab308'
3865
- },
3866
- children: `${componentName} Component Not Found`
3867
- });
3868
- };
3869
-
3870
- function rendererFactory() {
3871
- const RENDERER_COMPS = adapter.getRenderers();
3872
- return class Renderer extends Component {
3873
- static displayName = 'Renderer';
3874
- state = {};
3875
- __ref;
3876
- static defaultProps = {
3877
- appHelper: undefined,
3878
- components: {},
3879
- designMode: 'live',
3880
- suspended: false,
3881
- schema: {},
3882
- onCompGetRef: () => {},
3883
- onCompGetCtx: () => {},
3884
- excuteLifeCycleInDesignMode: false
3885
- };
3886
- constructor(props) {
3887
- super(props);
3888
- this.state = {};
3889
- logger$1.log(`entry.constructor - ${props?.schema?.componentName}`);
3890
- }
3891
- async componentDidMount() {
3892
- logger$1.log(`entry.componentDidMount - ${this.props.schema && this.props.schema.componentName}`);
3893
- }
3894
- async componentDidUpdate() {
3895
- logger$1.log(`entry.componentDidUpdate - ${this.props?.schema?.componentName}`);
3896
- }
3897
- async componentWillUnmount() {
3898
- logger$1.log(`entry.componentWillUnmount - ${this.props?.schema?.componentName}`);
3899
- }
3900
- componentDidCatch(error) {
3901
- this.state.engineRenderError = true;
3902
- this.state.error = error;
3903
- }
3904
- shouldComponentUpdate(nextProps) {
3905
- return !nextProps.suspended;
3906
- }
3907
- __getRef = ref => {
3908
- this.__ref = ref;
3909
- if (ref) {
3910
- this.props.onCompGetRef?.(this.props.schema, ref);
3911
- }
3912
- };
3913
- isValidComponent(SetComponent) {
3914
- return SetComponent;
3915
- }
3916
- createElement(SetComponent, props, children) {
3917
- return (this.props.customCreateElement || createElement)(SetComponent, props, children);
3918
- }
3919
- getNotFoundComponent() {
3920
- return this.props.notFoundComponent || NotFoundComponent;
3921
- }
3922
- getFaultComponent() {
3923
- return this.props.faultComponent || FaultComponent;
3924
- }
3925
- render() {
3926
- const {
3927
- schema,
3928
- designMode,
3929
- appHelper,
3930
- components
3931
- } = this.props;
3932
- if (isEmpty(schema)) {
3933
- return null;
3934
- }
3935
- if (!isSchema(schema)) {
3936
- logger$1.error('The root component name needs to be one of Page、Block、Component, please check the schema: ', schema);
3937
- return '模型结构异常';
3938
- }
3939
- logger$1.log('entry.render');
3940
- const allComponents = {
3941
- ...components,
3942
- ...RENDERER_COMPS
3943
- };
3944
- // TODO: 默认最顶层使用 PageRenderer
3945
- const Comp = allComponents.PageRenderer;
3946
- if (this.state && this.state.engineRenderError) {
3947
- return /*#__PURE__*/createElement(this.getFaultComponent(), {
3948
- componentName: schema.componentName,
3949
- error: this.state.error
3950
- });
3951
- }
3952
- if (!Comp) {
3953
- return null;
3954
- }
3955
- return /*#__PURE__*/jsx(RendererContext.Provider, {
3956
- value: {
3957
- appHelper,
3958
- components: allComponents,
3959
- engine: this
3960
- },
3961
- children: /*#__PURE__*/jsx(Comp, {
3962
- // ref={this.__getRef}
3963
- __appHelper: appHelper,
3964
- __components: allComponents,
3965
- __schema: schema,
3966
- __designMode: designMode,
3967
- ...this.props
3968
- }, schema.__ctx && `${schema.__ctx.lceKey}_${schema.__ctx.idx || '0'}`)
3969
- });
3970
- }
3971
- };
3972
- }
3973
-
3974
- const DEV = '_EASY_EDITOR_DEV_';
3975
-
3976
- export { DEV, RendererContext, SettingFieldView, SettingRender, adapter, baseRendererFactory, capitalizeFirstLetter, checkPropTypes, classnames, cloneEnumerableProperty, compWrapper, componentRendererFactory, contextFactory, createForwardRefHocElement, executeLifeCycleMethod, getFileCssName, getSchemaChildren, getValue, inSameDomain, isReactClass, isReactComponent, isSchema, isString, isUseLoop, leafWrapper, logger, pageRendererFactory, parseData, parseExpression, parseThisRequiredExpression, rendererFactory, serializeParams, transformArrayToMap, transformStringToFunction, useRendererContext };
3977
- //# sourceMappingURL=index.production.js.map