@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.
- package/README.md +12 -1
- package/dist/adapter/index.d.ts +17 -0
- package/dist/{renderer-core/base.d.ts → base.d.ts} +2 -2
- package/dist/component.d.ts +2 -0
- package/dist/components/FaultComponent.d.ts +4 -0
- package/dist/components/NotFoundComponent.d.ts +4 -0
- package/dist/{renderer-core/hoc → hoc}/leaf.d.ts +2 -1
- package/dist/{cjs/index.js → index.cjs} +406 -1894
- package/dist/index.d.ts +10 -3
- package/dist/index.js +353 -1823
- package/dist/page.d.ts +2 -0
- package/dist/renderer.d.ts +2 -0
- package/dist/setting-renderer/context.d.ts +8 -0
- package/dist/setting-renderer/index.d.ts +8 -0
- package/dist/types.d.ts +7 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/is.d.ts +3 -0
- package/package.json +15 -20
- package/dist/cjs/index.development.js +0 -4013
- package/dist/cjs/index.development.js.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/index.production.js +0 -4013
- package/dist/cjs/index.production.js.map +0 -1
- package/dist/configure-renderer/context.d.ts +0 -13
- package/dist/configure-renderer/index.d.ts +0 -10
- package/dist/esm/index.development.js +0 -3977
- package/dist/esm/index.development.js.map +0 -1
- package/dist/esm/index.js +0 -3977
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.production.js +0 -3977
- package/dist/esm/index.production.js.map +0 -1
- package/dist/renderer-core/adapter/index.d.ts +0 -17
- package/dist/renderer-core/component.d.ts +0 -2
- package/dist/renderer-core/components/FaultComponent.d.ts +0 -7
- package/dist/renderer-core/components/NotFoundComponent.d.ts +0 -7
- package/dist/renderer-core/index.d.ts +0 -9
- package/dist/renderer-core/page.d.ts +0 -2
- package/dist/renderer-core/renderer.d.ts +0 -2
- package/dist/renderer-core/types.d.ts +0 -202
- package/dist/renderer-core/utils/classnames.d.ts +0 -1
- package/dist/renderer-core/utils/common.d.ts +0 -59
- package/dist/renderer-core/utils/data-helper.d.ts +0 -83
- package/dist/renderer-core/utils/index.d.ts +0 -4
- package/dist/renderer-core/utils/logger.d.ts +0 -5
- package/dist/renderer-core/utils/request.d.ts +0 -43
- /package/dist/{renderer-core/context.d.ts → context.d.ts} +0 -0
- /package/dist/{renderer-core/hoc → hoc}/comp.d.ts +0 -0
- /package/dist/{renderer-core/hoc → hoc}/index.d.ts +0 -0
- /package/dist/{configure-renderer → setting-renderer}/SettingSetter.d.ts +0 -0
- /package/dist/{renderer-core/utils → utils}/hoc.d.ts +0 -0
|
@@ -1,263 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var mobxReact = require('mobx-react');
|
|
4
|
-
var react = require('react');
|
|
5
3
|
var core = require('@easy-editor/core');
|
|
4
|
+
var rendererCore = require('@easy-editor/renderer-core');
|
|
5
|
+
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
-
|
|
8
|
-
const SettingRendererContext = /*#__PURE__*/react.createContext({});
|
|
9
|
-
const useSettingRendererContext = () => {
|
|
10
|
-
try {
|
|
11
|
-
return react.useContext(SettingRendererContext);
|
|
12
|
-
} catch (error) {
|
|
13
|
-
console.warn('useSettingRendererContext must be used within a SettingRendererContextProvider');
|
|
14
|
-
}
|
|
15
|
-
return {};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const getSetterInfo = field => {
|
|
19
|
-
const {
|
|
20
|
-
extraProps,
|
|
21
|
-
setter
|
|
22
|
-
} = field;
|
|
23
|
-
const {
|
|
24
|
-
defaultValue
|
|
25
|
-
} = extraProps;
|
|
26
|
-
let setterProps = {};
|
|
27
|
-
let setterType;
|
|
28
|
-
let initialValue = null;
|
|
29
|
-
if (core.isSetterConfig(setter)) {
|
|
30
|
-
setterType = setter.componentName;
|
|
31
|
-
if (setter.props) {
|
|
32
|
-
setterProps = setter.props;
|
|
33
|
-
if (typeof setterProps === 'function') {
|
|
34
|
-
setterProps = setterProps(field);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (setter.defaultValue != null) {
|
|
38
|
-
initialValue = setter.defaultValue;
|
|
39
|
-
}
|
|
40
|
-
} else if (setter) {
|
|
41
|
-
setterType = setter;
|
|
42
|
-
}
|
|
43
|
-
if (defaultValue != null && !('defaultValue' in setterProps)) {
|
|
44
|
-
setterProps.defaultValue = defaultValue;
|
|
45
|
-
if (initialValue == null) {
|
|
46
|
-
initialValue = defaultValue;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (field.valueState === -1) {
|
|
50
|
-
setterProps.multiValue = true;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// 根据是否支持变量配置做相应的更改
|
|
54
|
-
const supportVariable = field.extraProps?.supportVariable;
|
|
55
|
-
const isUseVariableSetter = supportVariable;
|
|
56
|
-
if (isUseVariableSetter === false) {
|
|
57
|
-
return {
|
|
58
|
-
setterProps,
|
|
59
|
-
initialValue,
|
|
60
|
-
setterType
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
setterProps,
|
|
65
|
-
setterType,
|
|
66
|
-
initialValue
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
const SettingSetter = mobxReact.observer(({
|
|
70
|
-
field,
|
|
71
|
-
children
|
|
72
|
-
}) => {
|
|
73
|
-
const {
|
|
74
|
-
setterManager
|
|
75
|
-
} = useSettingRendererContext();
|
|
76
|
-
const {
|
|
77
|
-
extraProps
|
|
78
|
-
} = field;
|
|
79
|
-
const visible = extraProps?.condition && typeof extraProps.condition === 'function' ? extraProps.condition(field) !== false : true;
|
|
80
|
-
if (!visible) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
const {
|
|
84
|
-
setterProps = {},
|
|
85
|
-
setterType,
|
|
86
|
-
initialValue = null
|
|
87
|
-
} = getSetterInfo(field);
|
|
88
|
-
const onChange = extraProps?.onChange;
|
|
89
|
-
const value = field.valueState === -1 ? null : field.getValue();
|
|
90
|
-
const {
|
|
91
|
-
component: SetterComponent,
|
|
92
|
-
props: mixedSetterProps
|
|
93
|
-
} = setterManager.createSetterContent(setterType, setterProps);
|
|
94
|
-
return /*#__PURE__*/jsxRuntime.jsx(SetterComponent, {
|
|
95
|
-
field: field,
|
|
96
|
-
selected: field.top?.getNode(),
|
|
97
|
-
initialValue: initialValue,
|
|
98
|
-
value: value,
|
|
99
|
-
onChange: newVal => {
|
|
100
|
-
field.setValue(newVal);
|
|
101
|
-
onChange?.(field, newVal);
|
|
102
|
-
},
|
|
103
|
-
onInitial: () => {
|
|
104
|
-
if (initialValue == null) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
const value = typeof initialValue === 'function' ? initialValue(field) : initialValue;
|
|
108
|
-
field.setValue(value, true);
|
|
109
|
-
},
|
|
110
|
-
removeProp: () => {
|
|
111
|
-
if (field.name) {
|
|
112
|
-
field.parent.clearPropValue(field.name);
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
...mixedSetterProps,
|
|
116
|
-
children: children
|
|
117
|
-
}, field.id);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const SettingFieldItem = mobxReact.observer(({
|
|
121
|
-
field
|
|
122
|
-
}) => {
|
|
123
|
-
const {
|
|
124
|
-
customFieldItem
|
|
125
|
-
} = useSettingRendererContext();
|
|
126
|
-
if (customFieldItem) {
|
|
127
|
-
return customFieldItem(field, /*#__PURE__*/jsxRuntime.jsx(SettingSetter, {
|
|
128
|
-
field: field
|
|
129
|
-
}));
|
|
130
|
-
}
|
|
131
|
-
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
132
|
-
className: "space-y-2",
|
|
133
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("label", {
|
|
134
|
-
htmlFor: field.id,
|
|
135
|
-
className: "block text-sm font-medium text-gray-700",
|
|
136
|
-
children: field.title
|
|
137
|
-
}), /*#__PURE__*/jsxRuntime.jsx(SettingSetter, {
|
|
138
|
-
field: field
|
|
139
|
-
})]
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
const SettingFieldGroup = mobxReact.observer(({
|
|
143
|
-
field
|
|
144
|
-
}) => {
|
|
145
|
-
const {
|
|
146
|
-
customFieldGroup
|
|
147
|
-
} = useSettingRendererContext();
|
|
148
|
-
if (customFieldGroup) {
|
|
149
|
-
return customFieldGroup(field, /*#__PURE__*/jsxRuntime.jsx(SettingSetter, {
|
|
150
|
-
field: field,
|
|
151
|
-
children: field.items?.map(item => /*#__PURE__*/jsxRuntime.jsx(SettingFieldView, {
|
|
152
|
-
field: item
|
|
153
|
-
}, item.id))
|
|
154
|
-
}));
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// 如果 field 没有 setter,则理解为其 父级 field 的 items 数据
|
|
158
|
-
if (!field.setter) {
|
|
159
|
-
return field.items?.map(item => /*#__PURE__*/jsxRuntime.jsx(SettingFieldView, {
|
|
160
|
-
field: item
|
|
161
|
-
}, item.id));
|
|
162
|
-
}
|
|
163
|
-
return /*#__PURE__*/jsxRuntime.jsx(SettingSetter, {
|
|
164
|
-
field: field,
|
|
165
|
-
children: field.items?.map(item => /*#__PURE__*/jsxRuntime.jsx(SettingFieldView, {
|
|
166
|
-
field: item
|
|
167
|
-
}, item.id))
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
const SettingFieldView = ({
|
|
171
|
-
field
|
|
172
|
-
}) => {
|
|
173
|
-
if (field.isGroup) {
|
|
174
|
-
return /*#__PURE__*/jsxRuntime.jsx(SettingFieldGroup, {
|
|
175
|
-
field: field
|
|
176
|
-
}, field.id);
|
|
177
|
-
} else {
|
|
178
|
-
return /*#__PURE__*/jsxRuntime.jsx(SettingFieldItem, {
|
|
179
|
-
field: field
|
|
180
|
-
}, field.id);
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
const SettingRender = mobxReact.observer(props => {
|
|
184
|
-
const {
|
|
185
|
-
editor,
|
|
186
|
-
customFieldItem,
|
|
187
|
-
customFieldGroup
|
|
188
|
-
} = props;
|
|
189
|
-
const designer = editor.get('designer');
|
|
190
|
-
const setterManager = editor.get('setterManager');
|
|
191
|
-
const {
|
|
192
|
-
settingsManager
|
|
193
|
-
} = designer;
|
|
194
|
-
const {
|
|
195
|
-
settings
|
|
196
|
-
} = settingsManager;
|
|
197
|
-
const items = settings?.items;
|
|
198
|
-
const ctx = react.useMemo(() => {
|
|
199
|
-
const ctx = {};
|
|
200
|
-
ctx.setterManager = setterManager;
|
|
201
|
-
ctx.settingsManager = settingsManager;
|
|
202
|
-
ctx.customFieldItem = customFieldItem;
|
|
203
|
-
ctx.customFieldGroup = customFieldGroup;
|
|
204
|
-
return ctx;
|
|
205
|
-
}, [setterManager, settingsManager, customFieldItem, customFieldGroup]);
|
|
206
|
-
if (!settings) {
|
|
207
|
-
// 未选中节点,提示选中 或者 显示根节点设置
|
|
208
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
209
|
-
className: "lc-settings-main",
|
|
210
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
211
|
-
className: "lc-settings-notice",
|
|
212
|
-
children: /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
213
|
-
children: "Please select a node in canvas"
|
|
214
|
-
})
|
|
215
|
-
})
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// 当节点被锁定,且未开启锁定后容器可设置属性
|
|
220
|
-
if (settings.isLocked) {
|
|
221
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
222
|
-
className: "lc-settings-main",
|
|
223
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
224
|
-
className: "lc-settings-notice",
|
|
225
|
-
children: /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
226
|
-
children: "Current node is locked"
|
|
227
|
-
})
|
|
228
|
-
})
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
if (Array.isArray(settings.items) && settings.items.length === 0) {
|
|
232
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
233
|
-
className: "lc-settings-main",
|
|
234
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
235
|
-
className: "lc-settings-notice",
|
|
236
|
-
children: /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
237
|
-
children: "No config found for this type of component"
|
|
238
|
-
})
|
|
239
|
-
})
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
if (!settings.isSameComponent) {
|
|
243
|
-
// TODO: future support 获取设置项交集编辑
|
|
244
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
245
|
-
className: "lc-settings-main",
|
|
246
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
247
|
-
className: "lc-settings-notice",
|
|
248
|
-
children: /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
249
|
-
children: "Please select same kind of components"
|
|
250
|
-
})
|
|
251
|
-
})
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
return /*#__PURE__*/jsxRuntime.jsx(SettingRendererContext.Provider, {
|
|
255
|
-
value: ctx,
|
|
256
|
-
children: items?.map(item => /*#__PURE__*/jsxRuntime.jsx(SettingFieldView, {
|
|
257
|
-
field: item
|
|
258
|
-
}, item.id))
|
|
259
|
-
});
|
|
260
|
-
});
|
|
7
|
+
var mobxReact = require('mobx-react');
|
|
261
8
|
|
|
262
9
|
class Adapter {
|
|
263
10
|
renderers = {};
|
|
@@ -286,12 +33,12 @@ var root = freeGlobal || freeSelf || Function('return this')();
|
|
|
286
33
|
|
|
287
34
|
var Symbol = root.Symbol;
|
|
288
35
|
|
|
289
|
-
var objectProto$
|
|
290
|
-
var hasOwnProperty$
|
|
291
|
-
var nativeObjectToString$1 = objectProto$
|
|
36
|
+
var objectProto$7 = Object.prototype;
|
|
37
|
+
var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
|
|
38
|
+
var nativeObjectToString$1 = objectProto$7.toString;
|
|
292
39
|
var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
|
|
293
40
|
function getRawTag(value) {
|
|
294
|
-
var isOwn = hasOwnProperty$
|
|
41
|
+
var isOwn = hasOwnProperty$5.call(value, symToStringTag$1),
|
|
295
42
|
tag = value[symToStringTag$1];
|
|
296
43
|
try {
|
|
297
44
|
value[symToStringTag$1] = undefined;
|
|
@@ -308,8 +55,8 @@ function getRawTag(value) {
|
|
|
308
55
|
return result;
|
|
309
56
|
}
|
|
310
57
|
|
|
311
|
-
var objectProto$
|
|
312
|
-
var nativeObjectToString = objectProto$
|
|
58
|
+
var objectProto$6 = Object.prototype;
|
|
59
|
+
var nativeObjectToString = objectProto$6.toString;
|
|
313
60
|
function objectToString(value) {
|
|
314
61
|
return nativeObjectToString.call(value);
|
|
315
62
|
}
|
|
@@ -347,7 +94,7 @@ function baseTrim(string) {
|
|
|
347
94
|
return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') : string;
|
|
348
95
|
}
|
|
349
96
|
|
|
350
|
-
function isObject
|
|
97
|
+
function isObject(value) {
|
|
351
98
|
var type = typeof value;
|
|
352
99
|
return value != null && (type == 'object' || type == 'function');
|
|
353
100
|
}
|
|
@@ -364,9 +111,9 @@ function toNumber(value) {
|
|
|
364
111
|
if (isSymbol(value)) {
|
|
365
112
|
return NAN;
|
|
366
113
|
}
|
|
367
|
-
if (isObject
|
|
114
|
+
if (isObject(value)) {
|
|
368
115
|
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
|
369
|
-
value = isObject
|
|
116
|
+
value = isObject(other) ? other + '' : other;
|
|
370
117
|
}
|
|
371
118
|
if (typeof value != 'string') {
|
|
372
119
|
return value === 0 ? value : +value;
|
|
@@ -385,7 +132,7 @@ var asyncTag = '[object AsyncFunction]',
|
|
|
385
132
|
genTag = '[object GeneratorFunction]',
|
|
386
133
|
proxyTag = '[object Proxy]';
|
|
387
134
|
function isFunction(value) {
|
|
388
|
-
if (!isObject
|
|
135
|
+
if (!isObject(value)) {
|
|
389
136
|
return false;
|
|
390
137
|
}
|
|
391
138
|
var tag = baseGetTag(value);
|
|
@@ -402,12 +149,12 @@ function isMasked(func) {
|
|
|
402
149
|
return !!maskSrcKey && maskSrcKey in func;
|
|
403
150
|
}
|
|
404
151
|
|
|
405
|
-
var funcProto$
|
|
406
|
-
var funcToString$
|
|
152
|
+
var funcProto$1 = Function.prototype;
|
|
153
|
+
var funcToString$1 = funcProto$1.toString;
|
|
407
154
|
function toSource(func) {
|
|
408
155
|
if (func != null) {
|
|
409
156
|
try {
|
|
410
|
-
return funcToString$
|
|
157
|
+
return funcToString$1.call(func);
|
|
411
158
|
} catch (e) {}
|
|
412
159
|
try {
|
|
413
160
|
return func + '';
|
|
@@ -418,117 +165,30 @@ function toSource(func) {
|
|
|
418
165
|
|
|
419
166
|
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
420
167
|
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
421
|
-
var funcProto
|
|
422
|
-
objectProto$
|
|
423
|
-
var funcToString
|
|
424
|
-
var hasOwnProperty$
|
|
425
|
-
var reIsNative = RegExp('^' + funcToString
|
|
168
|
+
var funcProto = Function.prototype,
|
|
169
|
+
objectProto$5 = Object.prototype;
|
|
170
|
+
var funcToString = funcProto.toString;
|
|
171
|
+
var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
|
|
172
|
+
var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty$4).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
|
|
426
173
|
function baseIsNative(value) {
|
|
427
|
-
if (!isObject
|
|
174
|
+
if (!isObject(value) || isMasked(value)) {
|
|
428
175
|
return false;
|
|
429
176
|
}
|
|
430
177
|
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
431
178
|
return pattern.test(toSource(value));
|
|
432
179
|
}
|
|
433
180
|
|
|
434
|
-
function getValue
|
|
181
|
+
function getValue(object, key) {
|
|
435
182
|
return object == null ? undefined : object[key];
|
|
436
183
|
}
|
|
437
184
|
|
|
438
185
|
function getNative(object, key) {
|
|
439
|
-
var value = getValue
|
|
186
|
+
var value = getValue(object, key);
|
|
440
187
|
return baseIsNative(value) ? value : undefined;
|
|
441
188
|
}
|
|
442
189
|
|
|
443
190
|
var WeakMap = getNative(root, 'WeakMap');
|
|
444
191
|
|
|
445
|
-
var objectCreate = Object.create;
|
|
446
|
-
var baseCreate = function () {
|
|
447
|
-
function object() {}
|
|
448
|
-
return function (proto) {
|
|
449
|
-
if (!isObject$1(proto)) {
|
|
450
|
-
return {};
|
|
451
|
-
}
|
|
452
|
-
if (objectCreate) {
|
|
453
|
-
return objectCreate(proto);
|
|
454
|
-
}
|
|
455
|
-
object.prototype = proto;
|
|
456
|
-
var result = new object();
|
|
457
|
-
object.prototype = undefined;
|
|
458
|
-
return result;
|
|
459
|
-
};
|
|
460
|
-
}();
|
|
461
|
-
|
|
462
|
-
function apply(func, thisArg, args) {
|
|
463
|
-
switch (args.length) {
|
|
464
|
-
case 0:
|
|
465
|
-
return func.call(thisArg);
|
|
466
|
-
case 1:
|
|
467
|
-
return func.call(thisArg, args[0]);
|
|
468
|
-
case 2:
|
|
469
|
-
return func.call(thisArg, args[0], args[1]);
|
|
470
|
-
case 3:
|
|
471
|
-
return func.call(thisArg, args[0], args[1], args[2]);
|
|
472
|
-
}
|
|
473
|
-
return func.apply(thisArg, args);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
function copyArray(source, array) {
|
|
477
|
-
var index = -1,
|
|
478
|
-
length = source.length;
|
|
479
|
-
array || (array = Array(length));
|
|
480
|
-
while (++index < length) {
|
|
481
|
-
array[index] = source[index];
|
|
482
|
-
}
|
|
483
|
-
return array;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
var HOT_COUNT = 800,
|
|
487
|
-
HOT_SPAN = 16;
|
|
488
|
-
var nativeNow = Date.now;
|
|
489
|
-
function shortOut(func) {
|
|
490
|
-
var count = 0,
|
|
491
|
-
lastCalled = 0;
|
|
492
|
-
return function () {
|
|
493
|
-
var stamp = nativeNow(),
|
|
494
|
-
remaining = HOT_SPAN - (stamp - lastCalled);
|
|
495
|
-
lastCalled = stamp;
|
|
496
|
-
if (remaining > 0) {
|
|
497
|
-
if (++count >= HOT_COUNT) {
|
|
498
|
-
return arguments[0];
|
|
499
|
-
}
|
|
500
|
-
} else {
|
|
501
|
-
count = 0;
|
|
502
|
-
}
|
|
503
|
-
return func.apply(undefined, arguments);
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
function constant(value) {
|
|
508
|
-
return function () {
|
|
509
|
-
return value;
|
|
510
|
-
};
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
var defineProperty = function () {
|
|
514
|
-
try {
|
|
515
|
-
var func = getNative(Object, 'defineProperty');
|
|
516
|
-
func({}, '', {});
|
|
517
|
-
return func;
|
|
518
|
-
} catch (e) {}
|
|
519
|
-
}();
|
|
520
|
-
|
|
521
|
-
var baseSetToString = !defineProperty ? identity : function (func, string) {
|
|
522
|
-
return defineProperty(func, 'toString', {
|
|
523
|
-
'configurable': true,
|
|
524
|
-
'enumerable': false,
|
|
525
|
-
'value': constant(string),
|
|
526
|
-
'writable': true
|
|
527
|
-
});
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
var setToString = shortOut(baseSetToString);
|
|
531
|
-
|
|
532
192
|
function arrayEach(array, iteratee) {
|
|
533
193
|
var index = -1,
|
|
534
194
|
length = array == null ? 0 : array.length;
|
|
@@ -548,77 +208,6 @@ function isIndex(value, length) {
|
|
|
548
208
|
return !!length && (type == 'number' || type != 'symbol' && reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
|
|
549
209
|
}
|
|
550
210
|
|
|
551
|
-
function baseAssignValue(object, key, value) {
|
|
552
|
-
if (key == '__proto__' && defineProperty) {
|
|
553
|
-
defineProperty(object, key, {
|
|
554
|
-
'configurable': true,
|
|
555
|
-
'enumerable': true,
|
|
556
|
-
'value': value,
|
|
557
|
-
'writable': true
|
|
558
|
-
});
|
|
559
|
-
} else {
|
|
560
|
-
object[key] = value;
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
function eq(value, other) {
|
|
565
|
-
return value === other || value !== value && other !== other;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
var objectProto$9 = Object.prototype;
|
|
569
|
-
var hasOwnProperty$8 = objectProto$9.hasOwnProperty;
|
|
570
|
-
function assignValue(object, key, value) {
|
|
571
|
-
var objValue = object[key];
|
|
572
|
-
if (!(hasOwnProperty$8.call(object, key) && eq(objValue, value)) || value === undefined && !(key in object)) {
|
|
573
|
-
baseAssignValue(object, key, value);
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
function copyObject(source, props, object, customizer) {
|
|
578
|
-
var isNew = !object;
|
|
579
|
-
object || (object = {});
|
|
580
|
-
var index = -1,
|
|
581
|
-
length = props.length;
|
|
582
|
-
while (++index < length) {
|
|
583
|
-
var key = props[index];
|
|
584
|
-
var newValue = undefined;
|
|
585
|
-
if (newValue === undefined) {
|
|
586
|
-
newValue = source[key];
|
|
587
|
-
}
|
|
588
|
-
if (isNew) {
|
|
589
|
-
baseAssignValue(object, key, newValue);
|
|
590
|
-
} else {
|
|
591
|
-
assignValue(object, key, newValue);
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
return object;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
var nativeMax$1 = Math.max;
|
|
598
|
-
function overRest(func, start, transform) {
|
|
599
|
-
start = nativeMax$1(start === undefined ? func.length - 1 : start, 0);
|
|
600
|
-
return function () {
|
|
601
|
-
var args = arguments,
|
|
602
|
-
index = -1,
|
|
603
|
-
length = nativeMax$1(args.length - start, 0),
|
|
604
|
-
array = Array(length);
|
|
605
|
-
while (++index < length) {
|
|
606
|
-
array[index] = args[start + index];
|
|
607
|
-
}
|
|
608
|
-
index = -1;
|
|
609
|
-
var otherArgs = Array(start + 1);
|
|
610
|
-
while (++index < start) {
|
|
611
|
-
otherArgs[index] = args[index];
|
|
612
|
-
}
|
|
613
|
-
otherArgs[start] = transform(array);
|
|
614
|
-
return apply(func, this, otherArgs);
|
|
615
|
-
};
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
function baseRest(func, start) {
|
|
619
|
-
return setToString(overRest(func, start, identity), func + '');
|
|
620
|
-
}
|
|
621
|
-
|
|
622
211
|
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
623
212
|
function isLength(value) {
|
|
624
213
|
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
@@ -628,43 +217,10 @@ function isArrayLike(value) {
|
|
|
628
217
|
return value != null && isLength(value.length) && !isFunction(value);
|
|
629
218
|
}
|
|
630
219
|
|
|
631
|
-
|
|
632
|
-
if (!isObject$1(object)) {
|
|
633
|
-
return false;
|
|
634
|
-
}
|
|
635
|
-
var type = typeof index;
|
|
636
|
-
if (type == 'number' ? isArrayLike(object) && isIndex(index, object.length) : type == 'string' && index in object) {
|
|
637
|
-
return eq(object[index], value);
|
|
638
|
-
}
|
|
639
|
-
return false;
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
function createAssigner(assigner) {
|
|
643
|
-
return baseRest(function (object, sources) {
|
|
644
|
-
var index = -1,
|
|
645
|
-
length = sources.length,
|
|
646
|
-
customizer = length > 1 ? sources[length - 1] : undefined,
|
|
647
|
-
guard = length > 2 ? sources[2] : undefined;
|
|
648
|
-
customizer = assigner.length > 3 && typeof customizer == 'function' ? (length--, customizer) : undefined;
|
|
649
|
-
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
|
650
|
-
customizer = length < 3 ? undefined : customizer;
|
|
651
|
-
length = 1;
|
|
652
|
-
}
|
|
653
|
-
object = Object(object);
|
|
654
|
-
while (++index < length) {
|
|
655
|
-
var source = sources[index];
|
|
656
|
-
if (source) {
|
|
657
|
-
assigner(object, source, index, customizer);
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
return object;
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
var objectProto$8 = Object.prototype;
|
|
220
|
+
var objectProto$4 = Object.prototype;
|
|
665
221
|
function isPrototype(value) {
|
|
666
222
|
var Ctor = value && value.constructor,
|
|
667
|
-
proto = typeof Ctor == 'function' && Ctor.prototype || objectProto$
|
|
223
|
+
proto = typeof Ctor == 'function' && Ctor.prototype || objectProto$4;
|
|
668
224
|
return value === proto;
|
|
669
225
|
}
|
|
670
226
|
|
|
@@ -682,24 +238,24 @@ function baseIsArguments(value) {
|
|
|
682
238
|
return isObjectLike(value) && baseGetTag(value) == argsTag$1;
|
|
683
239
|
}
|
|
684
240
|
|
|
685
|
-
var objectProto$
|
|
686
|
-
var hasOwnProperty$
|
|
687
|
-
var propertyIsEnumerable = objectProto$
|
|
241
|
+
var objectProto$3 = Object.prototype;
|
|
242
|
+
var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
|
|
243
|
+
var propertyIsEnumerable = objectProto$3.propertyIsEnumerable;
|
|
688
244
|
var isArguments = baseIsArguments(function () {
|
|
689
245
|
return arguments;
|
|
690
246
|
}()) ? baseIsArguments : function (value) {
|
|
691
|
-
return isObjectLike(value) && hasOwnProperty$
|
|
247
|
+
return isObjectLike(value) && hasOwnProperty$3.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
|
|
692
248
|
};
|
|
693
249
|
|
|
694
250
|
function stubFalse() {
|
|
695
251
|
return false;
|
|
696
252
|
}
|
|
697
253
|
|
|
698
|
-
var freeExports$
|
|
699
|
-
var freeModule$
|
|
700
|
-
var moduleExports$
|
|
701
|
-
var Buffer
|
|
702
|
-
var nativeIsBuffer = Buffer
|
|
254
|
+
var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
|
255
|
+
var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
|
|
256
|
+
var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
|
|
257
|
+
var Buffer = moduleExports$1 ? root.Buffer : undefined;
|
|
258
|
+
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
|
|
703
259
|
var isBuffer = nativeIsBuffer || stubFalse;
|
|
704
260
|
|
|
705
261
|
var argsTag = '[object Arguments]',
|
|
@@ -710,7 +266,7 @@ var argsTag = '[object Arguments]',
|
|
|
710
266
|
funcTag = '[object Function]',
|
|
711
267
|
mapTag$2 = '[object Map]',
|
|
712
268
|
numberTag = '[object Number]',
|
|
713
|
-
objectTag$
|
|
269
|
+
objectTag$1 = '[object Object]',
|
|
714
270
|
regexpTag = '[object RegExp]',
|
|
715
271
|
setTag$2 = '[object Set]',
|
|
716
272
|
stringTag = '[object String]',
|
|
@@ -728,7 +284,7 @@ var arrayBufferTag = '[object ArrayBuffer]',
|
|
|
728
284
|
uint32Tag = '[object Uint32Array]';
|
|
729
285
|
var typedArrayTags = {};
|
|
730
286
|
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
|
|
731
|
-
typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag] = typedArrayTags[objectTag$
|
|
287
|
+
typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag] = typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] = typedArrayTags[setTag$2] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag$1] = false;
|
|
732
288
|
function baseIsTypedArray(value) {
|
|
733
289
|
return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
|
734
290
|
}
|
|
@@ -739,13 +295,13 @@ function baseUnary(func) {
|
|
|
739
295
|
};
|
|
740
296
|
}
|
|
741
297
|
|
|
742
|
-
var freeExports
|
|
743
|
-
var freeModule
|
|
744
|
-
var moduleExports
|
|
745
|
-
var freeProcess = moduleExports
|
|
298
|
+
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
|
299
|
+
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
|
|
300
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
301
|
+
var freeProcess = moduleExports && freeGlobal.process;
|
|
746
302
|
var nodeUtil = function () {
|
|
747
303
|
try {
|
|
748
|
-
var types = freeModule
|
|
304
|
+
var types = freeModule && freeModule.require && freeModule.require('util').types;
|
|
749
305
|
if (types) {
|
|
750
306
|
return types;
|
|
751
307
|
}
|
|
@@ -756,8 +312,8 @@ var nodeUtil = function () {
|
|
|
756
312
|
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
|
757
313
|
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
|
758
314
|
|
|
759
|
-
var objectProto$
|
|
760
|
-
var hasOwnProperty$
|
|
315
|
+
var objectProto$2 = Object.prototype;
|
|
316
|
+
var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
|
|
761
317
|
function arrayLikeKeys(value, inherited) {
|
|
762
318
|
var isArr = isArray(value),
|
|
763
319
|
isArg = !isArr && isArguments(value),
|
|
@@ -767,7 +323,7 @@ function arrayLikeKeys(value, inherited) {
|
|
|
767
323
|
result = skipIndexes ? baseTimes(value.length, String) : [],
|
|
768
324
|
length = result.length;
|
|
769
325
|
for (var key in value) {
|
|
770
|
-
if ((
|
|
326
|
+
if ((hasOwnProperty$2.call(value, key)) && !(skipIndexes && (
|
|
771
327
|
key == 'length' ||
|
|
772
328
|
isBuff && (key == 'offset' || key == 'parent') ||
|
|
773
329
|
isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') ||
|
|
@@ -786,15 +342,15 @@ function overArg(func, transform) {
|
|
|
786
342
|
|
|
787
343
|
var nativeKeys = overArg(Object.keys, Object);
|
|
788
344
|
|
|
789
|
-
var objectProto$
|
|
790
|
-
var hasOwnProperty$
|
|
345
|
+
var objectProto$1 = Object.prototype;
|
|
346
|
+
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
791
347
|
function baseKeys(object) {
|
|
792
348
|
if (!isPrototype(object)) {
|
|
793
349
|
return nativeKeys(object);
|
|
794
350
|
}
|
|
795
351
|
var result = [];
|
|
796
352
|
for (var key in Object(object)) {
|
|
797
|
-
if (hasOwnProperty$
|
|
353
|
+
if (hasOwnProperty$1.call(object, key) && key != 'constructor') {
|
|
798
354
|
result.push(key);
|
|
799
355
|
}
|
|
800
356
|
}
|
|
@@ -805,297 +361,8 @@ function keys(object) {
|
|
|
805
361
|
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
|
|
806
362
|
}
|
|
807
363
|
|
|
808
|
-
function nativeKeysIn(object) {
|
|
809
|
-
var result = [];
|
|
810
|
-
if (object != null) {
|
|
811
|
-
for (var key in Object(object)) {
|
|
812
|
-
result.push(key);
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
return result;
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
var objectProto$4 = Object.prototype;
|
|
819
|
-
var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
|
|
820
|
-
function baseKeysIn(object) {
|
|
821
|
-
if (!isObject$1(object)) {
|
|
822
|
-
return nativeKeysIn(object);
|
|
823
|
-
}
|
|
824
|
-
var isProto = isPrototype(object),
|
|
825
|
-
result = [];
|
|
826
|
-
for (var key in object) {
|
|
827
|
-
if (!(key == 'constructor' && (isProto || !hasOwnProperty$4.call(object, key)))) {
|
|
828
|
-
result.push(key);
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
return result;
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
function keysIn(object) {
|
|
835
|
-
return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
var nativeCreate = getNative(Object, 'create');
|
|
839
|
-
|
|
840
|
-
function hashClear() {
|
|
841
|
-
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|
842
|
-
this.size = 0;
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
function hashDelete(key) {
|
|
846
|
-
var result = this.has(key) && delete this.__data__[key];
|
|
847
|
-
this.size -= result ? 1 : 0;
|
|
848
|
-
return result;
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
|
|
852
|
-
var objectProto$3 = Object.prototype;
|
|
853
|
-
var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
|
|
854
|
-
function hashGet(key) {
|
|
855
|
-
var data = this.__data__;
|
|
856
|
-
if (nativeCreate) {
|
|
857
|
-
var result = data[key];
|
|
858
|
-
return result === HASH_UNDEFINED$1 ? undefined : result;
|
|
859
|
-
}
|
|
860
|
-
return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
var objectProto$2 = Object.prototype;
|
|
864
|
-
var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
|
|
865
|
-
function hashHas(key) {
|
|
866
|
-
var data = this.__data__;
|
|
867
|
-
return nativeCreate ? data[key] !== undefined : hasOwnProperty$2.call(data, key);
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|
871
|
-
function hashSet(key, value) {
|
|
872
|
-
var data = this.__data__;
|
|
873
|
-
this.size += this.has(key) ? 0 : 1;
|
|
874
|
-
data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
|
|
875
|
-
return this;
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
function Hash(entries) {
|
|
879
|
-
var index = -1,
|
|
880
|
-
length = entries == null ? 0 : entries.length;
|
|
881
|
-
this.clear();
|
|
882
|
-
while (++index < length) {
|
|
883
|
-
var entry = entries[index];
|
|
884
|
-
this.set(entry[0], entry[1]);
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
Hash.prototype.clear = hashClear;
|
|
888
|
-
Hash.prototype['delete'] = hashDelete;
|
|
889
|
-
Hash.prototype.get = hashGet;
|
|
890
|
-
Hash.prototype.has = hashHas;
|
|
891
|
-
Hash.prototype.set = hashSet;
|
|
892
|
-
|
|
893
|
-
function listCacheClear() {
|
|
894
|
-
this.__data__ = [];
|
|
895
|
-
this.size = 0;
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
function assocIndexOf(array, key) {
|
|
899
|
-
var length = array.length;
|
|
900
|
-
while (length--) {
|
|
901
|
-
if (eq(array[length][0], key)) {
|
|
902
|
-
return length;
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
return -1;
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
var arrayProto = Array.prototype;
|
|
909
|
-
var splice = arrayProto.splice;
|
|
910
|
-
function listCacheDelete(key) {
|
|
911
|
-
var data = this.__data__,
|
|
912
|
-
index = assocIndexOf(data, key);
|
|
913
|
-
if (index < 0) {
|
|
914
|
-
return false;
|
|
915
|
-
}
|
|
916
|
-
var lastIndex = data.length - 1;
|
|
917
|
-
if (index == lastIndex) {
|
|
918
|
-
data.pop();
|
|
919
|
-
} else {
|
|
920
|
-
splice.call(data, index, 1);
|
|
921
|
-
}
|
|
922
|
-
--this.size;
|
|
923
|
-
return true;
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
function listCacheGet(key) {
|
|
927
|
-
var data = this.__data__,
|
|
928
|
-
index = assocIndexOf(data, key);
|
|
929
|
-
return index < 0 ? undefined : data[index][1];
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
function listCacheHas(key) {
|
|
933
|
-
return assocIndexOf(this.__data__, key) > -1;
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
function listCacheSet(key, value) {
|
|
937
|
-
var data = this.__data__,
|
|
938
|
-
index = assocIndexOf(data, key);
|
|
939
|
-
if (index < 0) {
|
|
940
|
-
++this.size;
|
|
941
|
-
data.push([key, value]);
|
|
942
|
-
} else {
|
|
943
|
-
data[index][1] = value;
|
|
944
|
-
}
|
|
945
|
-
return this;
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
function ListCache(entries) {
|
|
949
|
-
var index = -1,
|
|
950
|
-
length = entries == null ? 0 : entries.length;
|
|
951
|
-
this.clear();
|
|
952
|
-
while (++index < length) {
|
|
953
|
-
var entry = entries[index];
|
|
954
|
-
this.set(entry[0], entry[1]);
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
ListCache.prototype.clear = listCacheClear;
|
|
958
|
-
ListCache.prototype['delete'] = listCacheDelete;
|
|
959
|
-
ListCache.prototype.get = listCacheGet;
|
|
960
|
-
ListCache.prototype.has = listCacheHas;
|
|
961
|
-
ListCache.prototype.set = listCacheSet;
|
|
962
|
-
|
|
963
364
|
var Map$1 = getNative(root, 'Map');
|
|
964
365
|
|
|
965
|
-
function mapCacheClear() {
|
|
966
|
-
this.size = 0;
|
|
967
|
-
this.__data__ = {
|
|
968
|
-
'hash': new Hash(),
|
|
969
|
-
'map': new (Map$1 || ListCache)(),
|
|
970
|
-
'string': new Hash()
|
|
971
|
-
};
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
function isKeyable(value) {
|
|
975
|
-
var type = typeof value;
|
|
976
|
-
return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
function getMapData(map, key) {
|
|
980
|
-
var data = map.__data__;
|
|
981
|
-
return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
function mapCacheDelete(key) {
|
|
985
|
-
var result = getMapData(this, key)['delete'](key);
|
|
986
|
-
this.size -= result ? 1 : 0;
|
|
987
|
-
return result;
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
function mapCacheGet(key) {
|
|
991
|
-
return getMapData(this, key).get(key);
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
function mapCacheHas(key) {
|
|
995
|
-
return getMapData(this, key).has(key);
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
function mapCacheSet(key, value) {
|
|
999
|
-
var data = getMapData(this, key),
|
|
1000
|
-
size = data.size;
|
|
1001
|
-
data.set(key, value);
|
|
1002
|
-
this.size += data.size == size ? 0 : 1;
|
|
1003
|
-
return this;
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
function MapCache(entries) {
|
|
1007
|
-
var index = -1,
|
|
1008
|
-
length = entries == null ? 0 : entries.length;
|
|
1009
|
-
this.clear();
|
|
1010
|
-
while (++index < length) {
|
|
1011
|
-
var entry = entries[index];
|
|
1012
|
-
this.set(entry[0], entry[1]);
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
MapCache.prototype.clear = mapCacheClear;
|
|
1016
|
-
MapCache.prototype['delete'] = mapCacheDelete;
|
|
1017
|
-
MapCache.prototype.get = mapCacheGet;
|
|
1018
|
-
MapCache.prototype.has = mapCacheHas;
|
|
1019
|
-
MapCache.prototype.set = mapCacheSet;
|
|
1020
|
-
|
|
1021
|
-
var getPrototype = overArg(Object.getPrototypeOf, Object);
|
|
1022
|
-
|
|
1023
|
-
var objectTag$1 = '[object Object]';
|
|
1024
|
-
var funcProto = Function.prototype,
|
|
1025
|
-
objectProto$1 = Object.prototype;
|
|
1026
|
-
var funcToString = funcProto.toString;
|
|
1027
|
-
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
1028
|
-
var objectCtorString = funcToString.call(Object);
|
|
1029
|
-
function isPlainObject(value) {
|
|
1030
|
-
if (!isObjectLike(value) || baseGetTag(value) != objectTag$1) {
|
|
1031
|
-
return false;
|
|
1032
|
-
}
|
|
1033
|
-
var proto = getPrototype(value);
|
|
1034
|
-
if (proto === null) {
|
|
1035
|
-
return true;
|
|
1036
|
-
}
|
|
1037
|
-
var Ctor = hasOwnProperty$1.call(proto, 'constructor') && proto.constructor;
|
|
1038
|
-
return typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
function stackClear() {
|
|
1042
|
-
this.__data__ = new ListCache();
|
|
1043
|
-
this.size = 0;
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
function stackDelete(key) {
|
|
1047
|
-
var data = this.__data__,
|
|
1048
|
-
result = data['delete'](key);
|
|
1049
|
-
this.size = data.size;
|
|
1050
|
-
return result;
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
function stackGet(key) {
|
|
1054
|
-
return this.__data__.get(key);
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
function stackHas(key) {
|
|
1058
|
-
return this.__data__.has(key);
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
var LARGE_ARRAY_SIZE = 200;
|
|
1062
|
-
function stackSet(key, value) {
|
|
1063
|
-
var data = this.__data__;
|
|
1064
|
-
if (data instanceof ListCache) {
|
|
1065
|
-
var pairs = data.__data__;
|
|
1066
|
-
if (!Map$1 || pairs.length < LARGE_ARRAY_SIZE - 1) {
|
|
1067
|
-
pairs.push([key, value]);
|
|
1068
|
-
this.size = ++data.size;
|
|
1069
|
-
return this;
|
|
1070
|
-
}
|
|
1071
|
-
data = this.__data__ = new MapCache(pairs);
|
|
1072
|
-
}
|
|
1073
|
-
data.set(key, value);
|
|
1074
|
-
this.size = data.size;
|
|
1075
|
-
return this;
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
function Stack(entries) {
|
|
1079
|
-
var data = this.__data__ = new ListCache(entries);
|
|
1080
|
-
this.size = data.size;
|
|
1081
|
-
}
|
|
1082
|
-
Stack.prototype.clear = stackClear;
|
|
1083
|
-
Stack.prototype['delete'] = stackDelete;
|
|
1084
|
-
Stack.prototype.get = stackGet;
|
|
1085
|
-
Stack.prototype.has = stackHas;
|
|
1086
|
-
Stack.prototype.set = stackSet;
|
|
1087
|
-
|
|
1088
|
-
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
|
1089
|
-
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
|
|
1090
|
-
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
1091
|
-
var Buffer = moduleExports ? root.Buffer : undefined;
|
|
1092
|
-
Buffer ? Buffer.allocUnsafe : undefined;
|
|
1093
|
-
function cloneBuffer(buffer, isDeep) {
|
|
1094
|
-
{
|
|
1095
|
-
return buffer.slice();
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
366
|
var DataView = getNative(root, 'DataView');
|
|
1100
367
|
|
|
1101
368
|
var Promise$1 = getNative(root, 'Promise');
|
|
@@ -1137,23 +404,6 @@ if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map$1
|
|
|
1137
404
|
};
|
|
1138
405
|
}
|
|
1139
406
|
|
|
1140
|
-
var Uint8Array = root.Uint8Array;
|
|
1141
|
-
|
|
1142
|
-
function cloneArrayBuffer(arrayBuffer) {
|
|
1143
|
-
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
|
1144
|
-
new Uint8Array(result).set(new Uint8Array(arrayBuffer));
|
|
1145
|
-
return result;
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
function cloneTypedArray(typedArray, isDeep) {
|
|
1149
|
-
var buffer = cloneArrayBuffer(typedArray.buffer) ;
|
|
1150
|
-
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
function initCloneObject(object) {
|
|
1154
|
-
return typeof object.constructor == 'function' && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
407
|
function createBaseFor(fromRight) {
|
|
1158
408
|
return function (object, iteratee, keysFunc) {
|
|
1159
409
|
var index = -1,
|
|
@@ -1220,7 +470,7 @@ function debounce(func, wait, options) {
|
|
|
1220
470
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|
1221
471
|
}
|
|
1222
472
|
wait = toNumber(wait) || 0;
|
|
1223
|
-
if (isObject
|
|
473
|
+
if (isObject(options)) {
|
|
1224
474
|
leading = !!options.leading;
|
|
1225
475
|
maxing = 'maxWait' in options;
|
|
1226
476
|
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
@@ -1286,109 +536,19 @@ function debounce(func, wait, options) {
|
|
|
1286
536
|
return leadingEdge(lastCallTime);
|
|
1287
537
|
}
|
|
1288
538
|
if (maxing) {
|
|
1289
|
-
clearTimeout(timerId);
|
|
1290
|
-
timerId = setTimeout(timerExpired, wait);
|
|
1291
|
-
return invokeFunc(lastCallTime);
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
if (timerId === undefined) {
|
|
1295
|
-
timerId = setTimeout(timerExpired, wait);
|
|
1296
|
-
}
|
|
1297
|
-
return result;
|
|
1298
|
-
}
|
|
1299
|
-
debounced.cancel = cancel;
|
|
1300
|
-
debounced.flush = flush;
|
|
1301
|
-
return debounced;
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
function assignMergeValue(object, key, value) {
|
|
1305
|
-
if (value !== undefined && !eq(object[key], value) || value === undefined && !(key in object)) {
|
|
1306
|
-
baseAssignValue(object, key, value);
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
function isArrayLikeObject(value) {
|
|
1311
|
-
return isObjectLike(value) && isArrayLike(value);
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
function safeGet(object, key) {
|
|
1315
|
-
if (key === 'constructor' && typeof object[key] === 'function') {
|
|
1316
|
-
return;
|
|
1317
|
-
}
|
|
1318
|
-
if (key == '__proto__') {
|
|
1319
|
-
return;
|
|
1320
|
-
}
|
|
1321
|
-
return object[key];
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
function toPlainObject(value) {
|
|
1325
|
-
return copyObject(value, keysIn(value));
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
|
|
1329
|
-
var objValue = safeGet(object, key),
|
|
1330
|
-
srcValue = safeGet(source, key),
|
|
1331
|
-
stacked = stack.get(srcValue);
|
|
1332
|
-
if (stacked) {
|
|
1333
|
-
assignMergeValue(object, key, stacked);
|
|
1334
|
-
return;
|
|
1335
|
-
}
|
|
1336
|
-
var newValue = customizer ? customizer(objValue, srcValue, key + '', object, source, stack) : undefined;
|
|
1337
|
-
var isCommon = newValue === undefined;
|
|
1338
|
-
if (isCommon) {
|
|
1339
|
-
var isArr = isArray(srcValue),
|
|
1340
|
-
isBuff = !isArr && isBuffer(srcValue),
|
|
1341
|
-
isTyped = !isArr && !isBuff && isTypedArray(srcValue);
|
|
1342
|
-
newValue = srcValue;
|
|
1343
|
-
if (isArr || isBuff || isTyped) {
|
|
1344
|
-
if (isArray(objValue)) {
|
|
1345
|
-
newValue = objValue;
|
|
1346
|
-
} else if (isArrayLikeObject(objValue)) {
|
|
1347
|
-
newValue = copyArray(objValue);
|
|
1348
|
-
} else if (isBuff) {
|
|
1349
|
-
isCommon = false;
|
|
1350
|
-
newValue = cloneBuffer(srcValue);
|
|
1351
|
-
} else if (isTyped) {
|
|
1352
|
-
isCommon = false;
|
|
1353
|
-
newValue = cloneTypedArray(srcValue);
|
|
1354
|
-
} else {
|
|
1355
|
-
newValue = [];
|
|
1356
|
-
}
|
|
1357
|
-
} else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
|
1358
|
-
newValue = objValue;
|
|
1359
|
-
if (isArguments(objValue)) {
|
|
1360
|
-
newValue = toPlainObject(objValue);
|
|
1361
|
-
} else if (!isObject$1(objValue) || isFunction(objValue)) {
|
|
1362
|
-
newValue = initCloneObject(srcValue);
|
|
1363
|
-
}
|
|
1364
|
-
} else {
|
|
1365
|
-
isCommon = false;
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
if (isCommon) {
|
|
1369
|
-
stack.set(srcValue, newValue);
|
|
1370
|
-
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
|
|
1371
|
-
stack['delete'](srcValue);
|
|
1372
|
-
}
|
|
1373
|
-
assignMergeValue(object, key, newValue);
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
function baseMerge(object, source, srcIndex, customizer, stack) {
|
|
1377
|
-
if (object === source) {
|
|
1378
|
-
return;
|
|
1379
|
-
}
|
|
1380
|
-
baseFor(source, function (srcValue, key) {
|
|
1381
|
-
stack || (stack = new Stack());
|
|
1382
|
-
if (isObject$1(srcValue)) {
|
|
1383
|
-
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
|
1384
|
-
} else {
|
|
1385
|
-
var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + '', object, source, stack) : undefined;
|
|
1386
|
-
if (newValue === undefined) {
|
|
1387
|
-
newValue = srcValue;
|
|
539
|
+
clearTimeout(timerId);
|
|
540
|
+
timerId = setTimeout(timerExpired, wait);
|
|
541
|
+
return invokeFunc(lastCallTime);
|
|
1388
542
|
}
|
|
1389
|
-
assignMergeValue(object, key, newValue);
|
|
1390
543
|
}
|
|
1391
|
-
|
|
544
|
+
if (timerId === undefined) {
|
|
545
|
+
timerId = setTimeout(timerExpired, wait);
|
|
546
|
+
}
|
|
547
|
+
return result;
|
|
548
|
+
}
|
|
549
|
+
debounced.cancel = cancel;
|
|
550
|
+
debounced.flush = flush;
|
|
551
|
+
return debounced;
|
|
1392
552
|
}
|
|
1393
553
|
|
|
1394
554
|
function castFunction(value) {
|
|
@@ -1426,367 +586,6 @@ function isEmpty(value) {
|
|
|
1426
586
|
return true;
|
|
1427
587
|
}
|
|
1428
588
|
|
|
1429
|
-
var merge = createAssigner(function (object, source, srcIndex) {
|
|
1430
|
-
baseMerge(object, source, srcIndex);
|
|
1431
|
-
});
|
|
1432
|
-
|
|
1433
|
-
let RuntimeDataSourceStatus = /*#__PURE__*/function (RuntimeDataSourceStatus) {
|
|
1434
|
-
RuntimeDataSourceStatus["Initial"] = "init";
|
|
1435
|
-
RuntimeDataSourceStatus["Loading"] = "loading";
|
|
1436
|
-
RuntimeDataSourceStatus["Loaded"] = "loaded";
|
|
1437
|
-
RuntimeDataSourceStatus["Error"] = "error";
|
|
1438
|
-
return RuntimeDataSourceStatus;
|
|
1439
|
-
}({});
|
|
1440
|
-
|
|
1441
|
-
class RuntimeDataSourceItem {
|
|
1442
|
-
_data;
|
|
1443
|
-
_error;
|
|
1444
|
-
_status = RuntimeDataSourceStatus.Initial;
|
|
1445
|
-
_dataSourceConfig;
|
|
1446
|
-
_request;
|
|
1447
|
-
_context;
|
|
1448
|
-
_options;
|
|
1449
|
-
constructor(dataSourceConfig, request, context) {
|
|
1450
|
-
this._dataSourceConfig = dataSourceConfig;
|
|
1451
|
-
this._request = request;
|
|
1452
|
-
this._context = context;
|
|
1453
|
-
}
|
|
1454
|
-
get data() {
|
|
1455
|
-
return this._data;
|
|
1456
|
-
}
|
|
1457
|
-
get error() {
|
|
1458
|
-
return this._error;
|
|
1459
|
-
}
|
|
1460
|
-
get status() {
|
|
1461
|
-
return this._status;
|
|
1462
|
-
}
|
|
1463
|
-
get isLoading() {
|
|
1464
|
-
return this._status === RuntimeDataSourceStatus.Loading;
|
|
1465
|
-
}
|
|
1466
|
-
async load(params) {
|
|
1467
|
-
if (!this._dataSourceConfig) return;
|
|
1468
|
-
if (!this._request) {
|
|
1469
|
-
this._error = new Error(`no ${this._dataSourceConfig.type} handler provide`);
|
|
1470
|
-
this._status = RuntimeDataSourceStatus.Error;
|
|
1471
|
-
throw this._error;
|
|
1472
|
-
}
|
|
1473
|
-
if (this._dataSourceConfig.type === 'urlParams') {
|
|
1474
|
-
const response = await this._request(this._context);
|
|
1475
|
-
this._context.setState({
|
|
1476
|
-
[this._dataSourceConfig.id]: response
|
|
1477
|
-
});
|
|
1478
|
-
this._data = response;
|
|
1479
|
-
this._status = RuntimeDataSourceStatus.Loaded;
|
|
1480
|
-
return response;
|
|
1481
|
-
}
|
|
1482
|
-
if (!this._dataSourceConfig.options) {
|
|
1483
|
-
throw new Error(`${this._dataSourceConfig.id} has no options`);
|
|
1484
|
-
}
|
|
1485
|
-
if (typeof this._dataSourceConfig.options === 'function') {
|
|
1486
|
-
this._options = this._dataSourceConfig.options();
|
|
1487
|
-
}
|
|
1488
|
-
if (!this._options) {
|
|
1489
|
-
throw new Error(`${this._dataSourceConfig.id} options transform error`);
|
|
1490
|
-
}
|
|
1491
|
-
let shouldFetch = true;
|
|
1492
|
-
let fetchOptions = this._options;
|
|
1493
|
-
if (params) {
|
|
1494
|
-
fetchOptions.params = merge(fetchOptions.params, params);
|
|
1495
|
-
}
|
|
1496
|
-
if (this._dataSourceConfig.shouldFetch) {
|
|
1497
|
-
if (typeof this._dataSourceConfig.shouldFetch === 'function') {
|
|
1498
|
-
shouldFetch = this._dataSourceConfig.shouldFetch(fetchOptions);
|
|
1499
|
-
} else if (typeof this._dataSourceConfig.shouldFetch === 'boolean') {
|
|
1500
|
-
shouldFetch = this._dataSourceConfig.shouldFetch;
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
if (!shouldFetch) {
|
|
1504
|
-
this._status = RuntimeDataSourceStatus.Error;
|
|
1505
|
-
this._error = new Error(`the ${this._dataSourceConfig.id} request should not fetch, please check the condition`);
|
|
1506
|
-
console.warn(this.error);
|
|
1507
|
-
return;
|
|
1508
|
-
}
|
|
1509
|
-
if (this._dataSourceConfig.willFetch) {
|
|
1510
|
-
try {
|
|
1511
|
-
fetchOptions = await this._dataSourceConfig.willFetch(this._options);
|
|
1512
|
-
} catch (error) {
|
|
1513
|
-
console.error(error);
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1516
|
-
const dataHandler = this._dataSourceConfig.dataHandler;
|
|
1517
|
-
const {
|
|
1518
|
-
errorHandler
|
|
1519
|
-
} = this._dataSourceConfig;
|
|
1520
|
-
try {
|
|
1521
|
-
this._status = RuntimeDataSourceStatus.Loading;
|
|
1522
|
-
const result = await this._request(fetchOptions, this._context).then(dataHandler, errorHandler);
|
|
1523
|
-
this._data = result;
|
|
1524
|
-
this._status = RuntimeDataSourceStatus.Loaded;
|
|
1525
|
-
this._context.setState({
|
|
1526
|
-
UNSTABLE_dataSourceUpdatedAt: Date.now(),
|
|
1527
|
-
[this._dataSourceConfig.id]: result
|
|
1528
|
-
});
|
|
1529
|
-
return this._data;
|
|
1530
|
-
} catch (error) {
|
|
1531
|
-
this._error = error;
|
|
1532
|
-
this._status = RuntimeDataSourceStatus.Error;
|
|
1533
|
-
this._context.setState({
|
|
1534
|
-
UNSTABLE_dataSourceUpdatedAt: Date.now(),
|
|
1535
|
-
[`UNSTABLE_${this._dataSourceConfig.id}_error`]: error
|
|
1536
|
-
});
|
|
1537
|
-
throw error;
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
}
|
|
1541
|
-
|
|
1542
|
-
const defaultDataHandler = async response => response.data;
|
|
1543
|
-
const defaultWillFetch = options => options;
|
|
1544
|
-
const getRequestHandler = (ds, requestHandlersMap) => {
|
|
1545
|
-
if (ds.type === 'custom') {
|
|
1546
|
-
return ds.requestHandler;
|
|
1547
|
-
}
|
|
1548
|
-
return requestHandlersMap[ds.type || 'fetch'];
|
|
1549
|
-
};
|
|
1550
|
-
const promiseSettled = (Promise.allSettled ? Promise.allSettled.bind(Promise) : null) || (promises => {
|
|
1551
|
-
return Promise.all(promises.map(p => {
|
|
1552
|
-
return p.then(v => ({
|
|
1553
|
-
status: 'fulfilled',
|
|
1554
|
-
value: v
|
|
1555
|
-
})).catch(e => ({
|
|
1556
|
-
status: 'rejected',
|
|
1557
|
-
reason: e
|
|
1558
|
-
}));
|
|
1559
|
-
}));
|
|
1560
|
-
});
|
|
1561
|
-
|
|
1562
|
-
function isObject(obj) {
|
|
1563
|
-
return Object.prototype.toString.call(obj).indexOf('Object') !== -1;
|
|
1564
|
-
}
|
|
1565
|
-
const transformExpression = (code, context) => {
|
|
1566
|
-
if (code === undefined) {
|
|
1567
|
-
return () => {};
|
|
1568
|
-
}
|
|
1569
|
-
if (code === '') {
|
|
1570
|
-
return () => '';
|
|
1571
|
-
}
|
|
1572
|
-
try {
|
|
1573
|
-
return new Function(`return (${code})`).call(context);
|
|
1574
|
-
} catch (error) {
|
|
1575
|
-
console.error(`transformExpression error, code is ${code}, context is ${context}, error is ${error}`);
|
|
1576
|
-
}
|
|
1577
|
-
};
|
|
1578
|
-
const transformFunction = (code, context) => {
|
|
1579
|
-
if (code === undefined) {
|
|
1580
|
-
return () => {};
|
|
1581
|
-
}
|
|
1582
|
-
if (code === '') {
|
|
1583
|
-
return () => '';
|
|
1584
|
-
}
|
|
1585
|
-
try {
|
|
1586
|
-
return new Function(`return (${code})`).call(context).bind(context);
|
|
1587
|
-
} catch (error) {
|
|
1588
|
-
console.error(`transformFunction error, code is ${code}, context is ${context}, error is ${error}`);
|
|
1589
|
-
}
|
|
1590
|
-
};
|
|
1591
|
-
const transformBoolStr = str => {
|
|
1592
|
-
return str !== 'false';
|
|
1593
|
-
};
|
|
1594
|
-
const getRuntimeJsValue = (value, context) => {
|
|
1595
|
-
if (!['JSExpression', 'JSFunction'].includes(value.type)) {
|
|
1596
|
-
console.error(`translate error, value is ${JSON.stringify(value)}`);
|
|
1597
|
-
return '';
|
|
1598
|
-
}
|
|
1599
|
-
const code = value.compiled || value.value;
|
|
1600
|
-
return value.type === 'JSFunction' ? transformFunction(code, context) : transformExpression(code, context);
|
|
1601
|
-
};
|
|
1602
|
-
const getRuntimeBaseValue = (type, value) => {
|
|
1603
|
-
switch (type) {
|
|
1604
|
-
case 'string':
|
|
1605
|
-
return `${value}`;
|
|
1606
|
-
case 'boolean':
|
|
1607
|
-
return typeof value === 'string' ? transformBoolStr(value) : !!value;
|
|
1608
|
-
case 'number':
|
|
1609
|
-
return Number(value);
|
|
1610
|
-
default:
|
|
1611
|
-
return value;
|
|
1612
|
-
}
|
|
1613
|
-
};
|
|
1614
|
-
const getRuntimeValueFromConfig = (type, value, context) => {
|
|
1615
|
-
if (value === undefined) {
|
|
1616
|
-
return undefined;
|
|
1617
|
-
}
|
|
1618
|
-
if (core.isJSExpression(value) || core.isJSFunction(value)) {
|
|
1619
|
-
return getRuntimeBaseValue(type, getRuntimeJsValue(value, context));
|
|
1620
|
-
}
|
|
1621
|
-
return value;
|
|
1622
|
-
};
|
|
1623
|
-
const buildJsonObj = (params, context) => {
|
|
1624
|
-
if (core.isJSExpression(params)) {
|
|
1625
|
-
return transformExpression(params.value, context);
|
|
1626
|
-
} else if (isObject(params)) {
|
|
1627
|
-
const newParams = {};
|
|
1628
|
-
for (const [name, param] of Object.entries(params)) {
|
|
1629
|
-
if (core.isJSExpression(param)) {
|
|
1630
|
-
newParams[name] = transformExpression(param?.value, context);
|
|
1631
|
-
} else if (isObject(param)) {
|
|
1632
|
-
newParams[name] = buildJsonObj(param, context);
|
|
1633
|
-
} else {
|
|
1634
|
-
newParams[name] = param;
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
|
-
return newParams;
|
|
1638
|
-
}
|
|
1639
|
-
return params;
|
|
1640
|
-
};
|
|
1641
|
-
const buildShouldFetch = (ds, context) => {
|
|
1642
|
-
if (!ds.options || !ds.shouldFetch) {
|
|
1643
|
-
return true;
|
|
1644
|
-
}
|
|
1645
|
-
if (core.isJSExpression(ds.shouldFetch) || core.isJSFunction(ds.shouldFetch)) {
|
|
1646
|
-
return getRuntimeJsValue(ds.shouldFetch, context);
|
|
1647
|
-
}
|
|
1648
|
-
return getRuntimeBaseValue('boolean', ds.shouldFetch);
|
|
1649
|
-
};
|
|
1650
|
-
const buildOptions = (ds, context) => {
|
|
1651
|
-
const {
|
|
1652
|
-
options
|
|
1653
|
-
} = ds;
|
|
1654
|
-
if (!options) return undefined;
|
|
1655
|
-
return () => {
|
|
1656
|
-
const fetchOptions = {
|
|
1657
|
-
uri: '',
|
|
1658
|
-
params: {},
|
|
1659
|
-
method: 'GET',
|
|
1660
|
-
isCors: true,
|
|
1661
|
-
timeout: 5000,
|
|
1662
|
-
headers: undefined,
|
|
1663
|
-
v: '1.0'
|
|
1664
|
-
};
|
|
1665
|
-
Object.keys(options).forEach(key => {
|
|
1666
|
-
switch (key) {
|
|
1667
|
-
case 'uri':
|
|
1668
|
-
fetchOptions.uri = getRuntimeValueFromConfig('string', options.uri, context);
|
|
1669
|
-
break;
|
|
1670
|
-
case 'params':
|
|
1671
|
-
fetchOptions.params = buildJsonObj(options.params, context);
|
|
1672
|
-
break;
|
|
1673
|
-
case 'method':
|
|
1674
|
-
fetchOptions.method = getRuntimeValueFromConfig('string', options.method, context);
|
|
1675
|
-
break;
|
|
1676
|
-
case 'isCors':
|
|
1677
|
-
fetchOptions.isCors = getRuntimeValueFromConfig('boolean', options.isCors, context);
|
|
1678
|
-
break;
|
|
1679
|
-
case 'timeout':
|
|
1680
|
-
fetchOptions.timeout = getRuntimeValueFromConfig('number', options.timeout, context);
|
|
1681
|
-
break;
|
|
1682
|
-
case 'headers':
|
|
1683
|
-
fetchOptions.headers = buildJsonObj(options.headers, context);
|
|
1684
|
-
break;
|
|
1685
|
-
case 'v':
|
|
1686
|
-
fetchOptions.v = getRuntimeValueFromConfig('string', options.v, context);
|
|
1687
|
-
break;
|
|
1688
|
-
default:
|
|
1689
|
-
fetchOptions[key] = getRuntimeValueFromConfig('unknown', options[key], context);
|
|
1690
|
-
}
|
|
1691
|
-
});
|
|
1692
|
-
return fetchOptions;
|
|
1693
|
-
};
|
|
1694
|
-
};
|
|
1695
|
-
|
|
1696
|
-
const adapt2Runtime = (dataSource, context, extraConfig) => {
|
|
1697
|
-
const {
|
|
1698
|
-
list: interpretConfigList,
|
|
1699
|
-
dataHandler: interpretDataHandler
|
|
1700
|
-
} = dataSource;
|
|
1701
|
-
const dataHandler = interpretDataHandler ? getRuntimeJsValue(interpretDataHandler, context) : undefined;
|
|
1702
|
-
if (!interpretConfigList || !interpretConfigList.length) {
|
|
1703
|
-
return {
|
|
1704
|
-
list: [],
|
|
1705
|
-
dataHandler
|
|
1706
|
-
};
|
|
1707
|
-
}
|
|
1708
|
-
const list = interpretConfigList.map(el => {
|
|
1709
|
-
const {
|
|
1710
|
-
defaultDataHandler: customDataHandler
|
|
1711
|
-
} = extraConfig;
|
|
1712
|
-
const finalDataHandler = customDataHandler || defaultDataHandler;
|
|
1713
|
-
return {
|
|
1714
|
-
id: el.id,
|
|
1715
|
-
isInit: getRuntimeValueFromConfig('boolean', el.isInit, context),
|
|
1716
|
-
isSync: getRuntimeValueFromConfig('boolean', el.isSync, context),
|
|
1717
|
-
type: el.type || 'fetch',
|
|
1718
|
-
willFetch: el.willFetch ? getRuntimeJsValue(el.willFetch, context) : defaultWillFetch,
|
|
1719
|
-
shouldFetch: buildShouldFetch(el, context),
|
|
1720
|
-
dataHandler: el.dataHandler ? getRuntimeJsValue(el.dataHandler, context) : finalDataHandler,
|
|
1721
|
-
errorHandler: el.errorHandler ? getRuntimeJsValue(el.errorHandler, context) : undefined,
|
|
1722
|
-
requestHandler: el.requestHandler ? getRuntimeJsValue(el.requestHandler, context) : undefined,
|
|
1723
|
-
options: buildOptions(el, context)
|
|
1724
|
-
};
|
|
1725
|
-
});
|
|
1726
|
-
return {
|
|
1727
|
-
list,
|
|
1728
|
-
dataHandler
|
|
1729
|
-
};
|
|
1730
|
-
};
|
|
1731
|
-
|
|
1732
|
-
const reloadDataSourceFactory = (dataSource, dataSourceMap, dataHandler) => {
|
|
1733
|
-
return async () => {
|
|
1734
|
-
const allAsyncLoadings = [];
|
|
1735
|
-
dataSource.list.filter(el => el.type === 'urlParams' && isInit(el)).forEach(el => {
|
|
1736
|
-
dataSourceMap[el.id].load();
|
|
1737
|
-
});
|
|
1738
|
-
const remainRuntimeDataSourceList = dataSource.list.filter(el => el.type !== 'urlParams');
|
|
1739
|
-
for (const ds of remainRuntimeDataSourceList) {
|
|
1740
|
-
if (!ds.options) {
|
|
1741
|
-
continue;
|
|
1742
|
-
}
|
|
1743
|
-
if (
|
|
1744
|
-
isInit(ds) && !ds.isSync) {
|
|
1745
|
-
allAsyncLoadings.push(dataSourceMap[ds.id].load());
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
for (const ds of remainRuntimeDataSourceList) {
|
|
1749
|
-
if (!ds.options) {
|
|
1750
|
-
continue;
|
|
1751
|
-
}
|
|
1752
|
-
if (
|
|
1753
|
-
isInit(ds) && ds.isSync) {
|
|
1754
|
-
try {
|
|
1755
|
-
await dataSourceMap[ds.id].load();
|
|
1756
|
-
} catch (e) {
|
|
1757
|
-
console.error(e);
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
}
|
|
1761
|
-
await promiseSettled(allAsyncLoadings);
|
|
1762
|
-
if (dataHandler) {
|
|
1763
|
-
dataHandler(dataSourceMap);
|
|
1764
|
-
}
|
|
1765
|
-
};
|
|
1766
|
-
};
|
|
1767
|
-
function isInit(ds) {
|
|
1768
|
-
return typeof ds.isInit === 'function' ? ds.isInit() : ds.isInit ?? true;
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1771
|
-
var createDataSourceEngine = (dataSource, context, extraConfig = {
|
|
1772
|
-
requestHandlersMap: {}
|
|
1773
|
-
}) => {
|
|
1774
|
-
const {
|
|
1775
|
-
requestHandlersMap
|
|
1776
|
-
} = extraConfig;
|
|
1777
|
-
const runtimeDataSource = adapt2Runtime(dataSource, context, {
|
|
1778
|
-
defaultDataHandler: extraConfig.defaultDataHandler
|
|
1779
|
-
});
|
|
1780
|
-
const dataSourceMap = runtimeDataSource.list.reduce((prev, current) => {
|
|
1781
|
-
prev[current.id] = new RuntimeDataSourceItem(current, getRequestHandler(current, requestHandlersMap), context);
|
|
1782
|
-
return prev;
|
|
1783
|
-
}, {});
|
|
1784
|
-
return {
|
|
1785
|
-
dataSourceMap,
|
|
1786
|
-
reloadDataSource: reloadDataSourceFactory(runtimeDataSource, dataSourceMap, runtimeDataSource.dataHandler)
|
|
1787
|
-
};
|
|
1788
|
-
};
|
|
1789
|
-
|
|
1790
589
|
const RendererContext = /*#__PURE__*/react.createContext({});
|
|
1791
590
|
const useRendererContext = () => {
|
|
1792
591
|
try {
|
|
@@ -1805,209 +604,6 @@ function contextFactory() {
|
|
|
1805
604
|
return context;
|
|
1806
605
|
}
|
|
1807
606
|
|
|
1808
|
-
const classnames = (...args) => {
|
|
1809
|
-
return args.filter(Boolean).join(' ');
|
|
1810
|
-
};
|
|
1811
|
-
|
|
1812
|
-
const logger = core.createLogger('Renderer');
|
|
1813
|
-
|
|
1814
|
-
const PropTypes2 = true;
|
|
1815
|
-
function inSameDomain() {
|
|
1816
|
-
try {
|
|
1817
|
-
return window.parent !== window && window.parent.location.host === window.location.host;
|
|
1818
|
-
} catch (e) {
|
|
1819
|
-
return false;
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
|
-
function getFileCssName(fileName) {
|
|
1823
|
-
if (!fileName) {
|
|
1824
|
-
return;
|
|
1825
|
-
}
|
|
1826
|
-
const name = fileName.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
1827
|
-
return `lce-${name}`.split('-').filter(p => !!p).join('-');
|
|
1828
|
-
}
|
|
1829
|
-
const isSchema = schema => {
|
|
1830
|
-
if (!schema) {
|
|
1831
|
-
return false;
|
|
1832
|
-
}
|
|
1833
|
-
if (schema.componentName === 'Leaf' || schema.componentName === 'Slot') {
|
|
1834
|
-
return true;
|
|
1835
|
-
}
|
|
1836
|
-
if (Array.isArray(schema)) {
|
|
1837
|
-
return schema.every(item => isSchema(item));
|
|
1838
|
-
}
|
|
1839
|
-
const isValidProps = props => {
|
|
1840
|
-
if (!props) {
|
|
1841
|
-
return false;
|
|
1842
|
-
}
|
|
1843
|
-
return typeof schema.props === 'object' && !Array.isArray(props);
|
|
1844
|
-
};
|
|
1845
|
-
return !!(schema.componentName && isValidProps(schema.props));
|
|
1846
|
-
};
|
|
1847
|
-
const getValue = (obj, path, defaultValue = {}) => {
|
|
1848
|
-
if (Array.isArray(obj)) {
|
|
1849
|
-
return defaultValue;
|
|
1850
|
-
}
|
|
1851
|
-
if (!obj || typeof obj !== 'object') {
|
|
1852
|
-
return defaultValue;
|
|
1853
|
-
}
|
|
1854
|
-
const res = path.split('.').reduce((pre, cur) => {
|
|
1855
|
-
return pre && pre[cur];
|
|
1856
|
-
}, obj);
|
|
1857
|
-
if (res === undefined) {
|
|
1858
|
-
return defaultValue;
|
|
1859
|
-
}
|
|
1860
|
-
return res;
|
|
1861
|
-
};
|
|
1862
|
-
function transformArrayToMap(arr, key, overwrite = true) {
|
|
1863
|
-
if (!arr || !Array.isArray(arr)) {
|
|
1864
|
-
return {};
|
|
1865
|
-
}
|
|
1866
|
-
const res = {};
|
|
1867
|
-
arr.forEach(item => {
|
|
1868
|
-
const curKey = item[key];
|
|
1869
|
-
if (item[key] === undefined) {
|
|
1870
|
-
return;
|
|
1871
|
-
}
|
|
1872
|
-
if (res[curKey] && !overwrite) {
|
|
1873
|
-
return;
|
|
1874
|
-
}
|
|
1875
|
-
res[curKey] = item;
|
|
1876
|
-
});
|
|
1877
|
-
return res;
|
|
1878
|
-
}
|
|
1879
|
-
const parseData = (schema, self, options = {}) => {
|
|
1880
|
-
if (core.isJSExpression(schema)) {
|
|
1881
|
-
return parseExpression({
|
|
1882
|
-
str: schema,
|
|
1883
|
-
self,
|
|
1884
|
-
thisRequired: true,
|
|
1885
|
-
logScope: options.logScope
|
|
1886
|
-
});
|
|
1887
|
-
}
|
|
1888
|
-
if (typeof schema === 'string') {
|
|
1889
|
-
return schema.trim();
|
|
1890
|
-
} else if (Array.isArray(schema)) {
|
|
1891
|
-
return schema.map(item => parseData(item, self, options));
|
|
1892
|
-
} else if (typeof schema === 'function') {
|
|
1893
|
-
return schema.bind(self);
|
|
1894
|
-
} else if (typeof schema === 'object') {
|
|
1895
|
-
if (!schema) {
|
|
1896
|
-
return schema;
|
|
1897
|
-
}
|
|
1898
|
-
const res = {};
|
|
1899
|
-
Object.entries(schema).forEach(([key, val]) => {
|
|
1900
|
-
if (key.startsWith('__')) {
|
|
1901
|
-
return;
|
|
1902
|
-
}
|
|
1903
|
-
res[key] = parseData(val, self, options);
|
|
1904
|
-
});
|
|
1905
|
-
return res;
|
|
1906
|
-
}
|
|
1907
|
-
return schema;
|
|
1908
|
-
};
|
|
1909
|
-
const isUseLoop = (loop, isDesignMode) => {
|
|
1910
|
-
if (!isDesignMode) {
|
|
1911
|
-
return true;
|
|
1912
|
-
}
|
|
1913
|
-
if (!Array.isArray(loop)) {
|
|
1914
|
-
return false;
|
|
1915
|
-
}
|
|
1916
|
-
return loop.length > 0;
|
|
1917
|
-
};
|
|
1918
|
-
function checkPropTypes(value, name, rule, componentName) {
|
|
1919
|
-
let ruleFunction = rule;
|
|
1920
|
-
if (typeof rule === 'string') {
|
|
1921
|
-
ruleFunction = new Function(`"use strict"; const PropTypes = arguments[0]; return ${rule}`)(PropTypes2);
|
|
1922
|
-
}
|
|
1923
|
-
if (!ruleFunction || typeof ruleFunction !== 'function') {
|
|
1924
|
-
logger.warn('checkPropTypes should have a function type rule argument');
|
|
1925
|
-
return true;
|
|
1926
|
-
}
|
|
1927
|
-
const err = ruleFunction({
|
|
1928
|
-
[name]: value
|
|
1929
|
-
}, name, componentName, 'prop', null
|
|
1930
|
-
);
|
|
1931
|
-
if (err) {
|
|
1932
|
-
logger.warn(err);
|
|
1933
|
-
}
|
|
1934
|
-
return !err;
|
|
1935
|
-
}
|
|
1936
|
-
function transformStringToFunction(str) {
|
|
1937
|
-
if (typeof str !== 'string') {
|
|
1938
|
-
return str;
|
|
1939
|
-
}
|
|
1940
|
-
if (inSameDomain() && window.parent.__newFunc) {
|
|
1941
|
-
return window.parent.__newFunc(`"use strict"; return ${str}`)();
|
|
1942
|
-
} else {
|
|
1943
|
-
return new Function(`"use strict"; return ${str}`)();
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
function parseExpression(a, b, c = false) {
|
|
1947
|
-
let str;
|
|
1948
|
-
let self;
|
|
1949
|
-
let thisRequired;
|
|
1950
|
-
let logScope;
|
|
1951
|
-
if (typeof a === 'object' && b === undefined) {
|
|
1952
|
-
str = a.str;
|
|
1953
|
-
self = a.self;
|
|
1954
|
-
thisRequired = a.thisRequired;
|
|
1955
|
-
logScope = a.logScope;
|
|
1956
|
-
} else {
|
|
1957
|
-
str = a;
|
|
1958
|
-
self = b;
|
|
1959
|
-
thisRequired = c;
|
|
1960
|
-
}
|
|
1961
|
-
try {
|
|
1962
|
-
const contextArr = ['"use strict";', 'var __self = arguments[0];'];
|
|
1963
|
-
contextArr.push('return ');
|
|
1964
|
-
let tarStr;
|
|
1965
|
-
tarStr = (str.value || '').trim();
|
|
1966
|
-
tarStr = tarStr.replace(/this(\W|$)/g, (_a, b) => `__self${b}`);
|
|
1967
|
-
tarStr = contextArr.join('\n') + tarStr;
|
|
1968
|
-
if (inSameDomain() && window.parent.__newFunc) {
|
|
1969
|
-
return window.parent.__newFunc(tarStr)(self);
|
|
1970
|
-
}
|
|
1971
|
-
const code = `with(${thisRequired ? '{}' : '$scope || {}'}) { ${tarStr} }`;
|
|
1972
|
-
return new Function('$scope', code)(self);
|
|
1973
|
-
} catch (err) {
|
|
1974
|
-
logger.error(`${logScope || ''} parseExpression.error`, err, str, self?.__self ?? self);
|
|
1975
|
-
return undefined;
|
|
1976
|
-
}
|
|
1977
|
-
}
|
|
1978
|
-
function parseThisRequiredExpression(str, self) {
|
|
1979
|
-
return parseExpression(str, self, true);
|
|
1980
|
-
}
|
|
1981
|
-
function isString(str) {
|
|
1982
|
-
return {}.toString.call(str) === '[object String]';
|
|
1983
|
-
}
|
|
1984
|
-
function capitalizeFirstLetter(word) {
|
|
1985
|
-
if (!word || !isString(word) || word.length === 0) {
|
|
1986
|
-
return word;
|
|
1987
|
-
}
|
|
1988
|
-
return word[0].toUpperCase() + word.slice(1);
|
|
1989
|
-
}
|
|
1990
|
-
const isReactClass = obj => {
|
|
1991
|
-
return obj && obj.prototype && (obj.prototype.isReactComponent || obj.prototype instanceof react.Component);
|
|
1992
|
-
};
|
|
1993
|
-
function isReactComponent(obj) {
|
|
1994
|
-
return obj && (isReactClass(obj) || typeof obj === 'function');
|
|
1995
|
-
}
|
|
1996
|
-
function serializeParams(obj) {
|
|
1997
|
-
const result = [];
|
|
1998
|
-
forEach(obj, (val, key) => {
|
|
1999
|
-
if (val === null || val === undefined || val === '') {
|
|
2000
|
-
return;
|
|
2001
|
-
}
|
|
2002
|
-
if (typeof val === 'object') {
|
|
2003
|
-
result.push(`${key}=${encodeURIComponent(JSON.stringify(val))}`);
|
|
2004
|
-
} else {
|
|
2005
|
-
result.push(`${key}=${encodeURIComponent(val)}`);
|
|
2006
|
-
}
|
|
2007
|
-
});
|
|
2008
|
-
return result.join('&');
|
|
2009
|
-
}
|
|
2010
|
-
|
|
2011
607
|
const excludePropertyNames = ['$$typeof', 'render', 'defaultProps', 'props', 'length', 'prototype', 'name', 'caller', 'callee', 'arguments'];
|
|
2012
608
|
const cloneEnumerableProperty = (target, origin, excludes = excludePropertyNames) => {
|
|
2013
609
|
const compExtraPropertyNames = Object.keys(origin).filter(d => !excludes.includes(d));
|
|
@@ -2027,6 +623,13 @@ const createForwardRefHocElement = (Wrapper, Comp) => {
|
|
|
2027
623
|
return WrapperComponent;
|
|
2028
624
|
};
|
|
2029
625
|
|
|
626
|
+
const isReactClass = obj => {
|
|
627
|
+
return obj && obj.prototype && (obj.prototype.isReactComponent || obj.prototype instanceof react.Component);
|
|
628
|
+
};
|
|
629
|
+
const isReactComponent = obj => {
|
|
630
|
+
return obj && (isReactClass(obj) || typeof obj === 'function');
|
|
631
|
+
};
|
|
632
|
+
|
|
2030
633
|
const patchDidCatch = (Comp, {
|
|
2031
634
|
baseRenderer
|
|
2032
635
|
}) => {
|
|
@@ -2151,19 +754,19 @@ const initRerenderEvent = ({
|
|
|
2151
754
|
if (!container.autoRepaintNode) {
|
|
2152
755
|
return;
|
|
2153
756
|
}
|
|
2154
|
-
logger.log(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onPropsChange make rerender`);
|
|
757
|
+
rendererCore.logger.log(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onPropsChange make rerender`);
|
|
2155
758
|
debounceRerender();
|
|
2156
759
|
}), leaf?.onChildrenChange?.(() => {
|
|
2157
760
|
if (!container.autoRepaintNode) {
|
|
2158
761
|
return;
|
|
2159
762
|
}
|
|
2160
|
-
logger.log(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onChildrenChange make rerender`);
|
|
763
|
+
rendererCore.logger.log(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onChildrenChange make rerender`);
|
|
2161
764
|
debounceRerender();
|
|
2162
765
|
}), leaf?.onVisibleChange?.(() => {
|
|
2163
766
|
if (!container.autoRepaintNode) {
|
|
2164
767
|
return;
|
|
2165
768
|
}
|
|
2166
|
-
logger.log(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onVisibleChange make rerender`);
|
|
769
|
+
rendererCore.logger.log(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onVisibleChange make rerender`);
|
|
2167
770
|
debounceRerender();
|
|
2168
771
|
})]
|
|
2169
772
|
});
|
|
@@ -2248,13 +851,13 @@ const leafWrapper = (Comp, {
|
|
|
2248
851
|
if ('children' in nextProps) {
|
|
2249
852
|
nextState.nodeChildren = nextProps.children;
|
|
2250
853
|
}
|
|
2251
|
-
logger.log(`${this.leaf?.componentName}(${this.leaf?.id}) MinimalRenderUnit Render!`);
|
|
854
|
+
rendererCore.logger.log(`${this.leaf?.componentName}(${this.leaf?.id}) MinimalRenderUnit Render!`);
|
|
2252
855
|
this.setState(nextState);
|
|
2253
856
|
}, 20);
|
|
2254
857
|
constructor(props) {
|
|
2255
858
|
super(props);
|
|
2256
859
|
// 监听以下事件,当变化时更新自己
|
|
2257
|
-
logger.log(`${schema.componentName}[${this.leaf?.id}] leaf render in SimulatorRendererView`);
|
|
860
|
+
rendererCore.logger.log(`${schema.componentName}[${this.leaf?.id}] leaf render in SimulatorRendererView`);
|
|
2258
861
|
componentCacheId && clearRerenderEvent(componentCacheId);
|
|
2259
862
|
this.curEventLeaf = this.leaf;
|
|
2260
863
|
cache.ref.set(componentCacheId, {
|
|
@@ -2339,11 +942,11 @@ const leafWrapper = (Comp, {
|
|
|
2339
942
|
}
|
|
2340
943
|
const ref = cache.ref.get(renderUnitInfo.minimalUnitId);
|
|
2341
944
|
if (!ref) {
|
|
2342
|
-
logger.log('Cant find minimalRenderUnit ref! This make rerender!');
|
|
945
|
+
rendererCore.logger.log('Cant find minimalRenderUnit ref! This make rerender!');
|
|
2343
946
|
container?.rerender();
|
|
2344
947
|
return;
|
|
2345
948
|
}
|
|
2346
|
-
logger.log(`${this.leaf?.componentName}(${this.leaf?.id}) need render, make its minimalRenderUnit ${renderUnitInfo.minimalUnitName}(${renderUnitInfo.minimalUnitId})`);
|
|
949
|
+
rendererCore.logger.log(`${this.leaf?.componentName}(${this.leaf?.id}) need render, make its minimalRenderUnit ${renderUnitInfo.minimalUnitName}(${renderUnitInfo.minimalUnitId})`);
|
|
2347
950
|
ref.makeUnitRender();
|
|
2348
951
|
}
|
|
2349
952
|
getRenderUnitInfo(leaf = this.leaf) {
|
|
@@ -2413,7 +1016,7 @@ const leafWrapper = (Comp, {
|
|
|
2413
1016
|
condition = true
|
|
2414
1017
|
} = this.leaf?.export(core.TRANSFORM_STAGE.RENDER) || {};
|
|
2415
1018
|
const conditionValue = __parseData?.(condition, scope);
|
|
2416
|
-
logger.log(`key is ___condition___, change condition value to [${condition}]`);
|
|
1019
|
+
rendererCore.logger.log(`key is ___condition___, change condition value to [${condition}]`);
|
|
2417
1020
|
// 条件表达式改变
|
|
2418
1021
|
this.setState({
|
|
2419
1022
|
condition: conditionValue
|
|
@@ -2424,7 +1027,7 @@ const leafWrapper = (Comp, {
|
|
|
2424
1027
|
// 如果循坏条件变化,从根节点重新渲染
|
|
2425
1028
|
// 目前多层循坏无法判断需要从哪一层开始渲染,故先粗暴解决
|
|
2426
1029
|
if (key === '___loop___') {
|
|
2427
|
-
logger.log('key is ___loop___, render a page!');
|
|
1030
|
+
rendererCore.logger.log('key is ___loop___, render a page!');
|
|
2428
1031
|
container?.rerender();
|
|
2429
1032
|
// 由于 scope 变化,需要清空缓存,使用新的 scope
|
|
2430
1033
|
cache.component.delete(componentCacheId);
|
|
@@ -2442,7 +1045,7 @@ const leafWrapper = (Comp, {
|
|
|
2442
1045
|
// 当 key 在 this.props 中时,且不存在在计算值中,需要用 newValue 覆盖掉 this.props 的取值
|
|
2443
1046
|
nodeCacheProps[key] = newValue;
|
|
2444
1047
|
}
|
|
2445
|
-
logger.log(`${leaf?.componentName}[${this.leaf?.id}] component trigger onPropsChange!`, nodeProps, nodeCacheProps, key, newValue);
|
|
1048
|
+
rendererCore.logger.log(`${leaf?.componentName}[${this.leaf?.id}] component trigger onPropsChange!`, nodeProps, nodeCacheProps, key, newValue);
|
|
2446
1049
|
this.setState('children' in nodeProps ? {
|
|
2447
1050
|
nodeChildren: nodeProps.children,
|
|
2448
1051
|
nodeProps,
|
|
@@ -2475,7 +1078,7 @@ const leafWrapper = (Comp, {
|
|
|
2475
1078
|
if (this.state.visible === flag) {
|
|
2476
1079
|
return;
|
|
2477
1080
|
}
|
|
2478
|
-
logger.log(`${leaf?.componentName}[${this.leaf?.id}] component trigger onVisibleChange(${flag}) event`);
|
|
1081
|
+
rendererCore.logger.log(`${leaf?.componentName}[${this.leaf?.id}] component trigger onVisibleChange(${flag}) event`);
|
|
2479
1082
|
this.beforeRender(RerenderType.VisibleChanged);
|
|
2480
1083
|
this.setState({
|
|
2481
1084
|
visible: flag
|
|
@@ -2502,7 +1105,7 @@ const leafWrapper = (Comp, {
|
|
|
2502
1105
|
// 缓存二级 children Next 查询筛选组件有问题
|
|
2503
1106
|
// 缓存一级 children Next Tab 组件有问题
|
|
2504
1107
|
const nextChild = getChildren(leaf?.export?.(core.TRANSFORM_STAGE.RENDER), scope, Comp);
|
|
2505
|
-
logger.log(`${schema.componentName}[${this.leaf?.id}] component trigger onChildrenChange event`, nextChild);
|
|
1108
|
+
rendererCore.logger.log(`${schema.componentName}[${this.leaf?.id}] component trigger onChildrenChange event`, nextChild);
|
|
2506
1109
|
this.setState({
|
|
2507
1110
|
nodeChildren: nextChild,
|
|
2508
1111
|
childrenInState: true
|
|
@@ -2556,7 +1159,7 @@ const leafWrapper = (Comp, {
|
|
|
2556
1159
|
__id: this.leaf?.id,
|
|
2557
1160
|
ref: forwardRef
|
|
2558
1161
|
};
|
|
2559
|
-
|
|
1162
|
+
compProps.__inner__ = undefined;
|
|
2560
1163
|
if (this.hasChildren) {
|
|
2561
1164
|
return engine.createElement(Comp, compProps, this.children);
|
|
2562
1165
|
}
|
|
@@ -2564,350 +1167,21 @@ const leafWrapper = (Comp, {
|
|
|
2564
1167
|
}
|
|
2565
1168
|
}
|
|
2566
1169
|
const LeafWrapper = createForwardRefHocElement(LeafHoc, Comp);
|
|
2567
|
-
cache.component.set(componentCacheId, {
|
|
2568
|
-
LeafWrapper,
|
|
2569
|
-
Comp
|
|
2570
|
-
});
|
|
2571
|
-
return LeafWrapper;
|
|
2572
|
-
};
|
|
2573
|
-
|
|
2574
|
-
function buildUrl(dataAPI, params) {
|
|
2575
|
-
const paramStr = serializeParams(params);
|
|
2576
|
-
if (paramStr) {
|
|
2577
|
-
return dataAPI.indexOf('?') > 0 ? `${dataAPI}&${paramStr}` : `${dataAPI}?${paramStr}`;
|
|
2578
|
-
}
|
|
2579
|
-
return dataAPI;
|
|
2580
|
-
}
|
|
2581
|
-
function get(dataAPI, params = {}, headers = {}, otherProps = {}) {
|
|
2582
|
-
const processedHeaders = {
|
|
2583
|
-
Accept: 'application/json',
|
|
2584
|
-
...headers
|
|
2585
|
-
};
|
|
2586
|
-
const url = buildUrl(dataAPI, params);
|
|
2587
|
-
return request(url, 'GET', null, processedHeaders, otherProps);
|
|
2588
|
-
}
|
|
2589
|
-
function post(dataAPI, params = {}, headers = {}, otherProps = {}) {
|
|
2590
|
-
const processedHeaders = {
|
|
2591
|
-
Accept: 'application/json',
|
|
2592
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
2593
|
-
...headers
|
|
2594
|
-
};
|
|
2595
|
-
const body = processedHeaders['Content-Type'].indexOf('application/json') > -1 || Array.isArray(params) ? JSON.stringify(params) : serializeParams(params);
|
|
2596
|
-
return request(dataAPI, 'POST', body, processedHeaders, otherProps);
|
|
2597
|
-
}
|
|
2598
|
-
function request(dataAPI, method = 'GET', data, headers = {}, otherProps = {}) {
|
|
2599
|
-
let processedHeaders = headers || {};
|
|
2600
|
-
let payload = data;
|
|
2601
|
-
if (method === 'PUT' || method === 'DELETE') {
|
|
2602
|
-
processedHeaders = {
|
|
2603
|
-
Accept: 'application/json',
|
|
2604
|
-
'Content-Type': 'application/json',
|
|
2605
|
-
...processedHeaders
|
|
2606
|
-
};
|
|
2607
|
-
payload = JSON.stringify(payload || {});
|
|
2608
|
-
}
|
|
2609
|
-
return new Promise((resolve, reject) => {
|
|
2610
|
-
if (otherProps.timeout) {
|
|
2611
|
-
setTimeout(() => {
|
|
2612
|
-
reject(new Error('timeout'));
|
|
2613
|
-
}, otherProps.timeout);
|
|
2614
|
-
}
|
|
2615
|
-
fetch(dataAPI, {
|
|
2616
|
-
method,
|
|
2617
|
-
credentials: 'include',
|
|
2618
|
-
headers: processedHeaders,
|
|
2619
|
-
body: payload,
|
|
2620
|
-
...otherProps
|
|
2621
|
-
}).then(response => {
|
|
2622
|
-
switch (response.status) {
|
|
2623
|
-
case 200:
|
|
2624
|
-
case 201:
|
|
2625
|
-
case 202:
|
|
2626
|
-
return response.json();
|
|
2627
|
-
case 204:
|
|
2628
|
-
if (method === 'DELETE') {
|
|
2629
|
-
return {
|
|
2630
|
-
success: true
|
|
2631
|
-
};
|
|
2632
|
-
} else {
|
|
2633
|
-
return {
|
|
2634
|
-
__success: false,
|
|
2635
|
-
code: response.status
|
|
2636
|
-
};
|
|
2637
|
-
}
|
|
2638
|
-
case 400:
|
|
2639
|
-
case 401:
|
|
2640
|
-
case 403:
|
|
2641
|
-
case 404:
|
|
2642
|
-
case 406:
|
|
2643
|
-
case 410:
|
|
2644
|
-
case 422:
|
|
2645
|
-
case 500:
|
|
2646
|
-
return response.json().then(res => {
|
|
2647
|
-
return {
|
|
2648
|
-
__success: false,
|
|
2649
|
-
code: response.status,
|
|
2650
|
-
data: res
|
|
2651
|
-
};
|
|
2652
|
-
}).catch(() => {
|
|
2653
|
-
return {
|
|
2654
|
-
__success: false,
|
|
2655
|
-
code: response.status
|
|
2656
|
-
};
|
|
2657
|
-
});
|
|
2658
|
-
}
|
|
2659
|
-
return null;
|
|
2660
|
-
}).then(json => {
|
|
2661
|
-
if (!json) {
|
|
2662
|
-
reject(json);
|
|
2663
|
-
return;
|
|
2664
|
-
}
|
|
2665
|
-
if (json.__success !== false) {
|
|
2666
|
-
resolve(json);
|
|
2667
|
-
} else {
|
|
2668
|
-
delete json.__success;
|
|
2669
|
-
reject(json);
|
|
2670
|
-
}
|
|
2671
|
-
}).catch(err => {
|
|
2672
|
-
reject(err);
|
|
2673
|
-
});
|
|
2674
|
-
});
|
|
2675
|
-
}
|
|
2676
|
-
|
|
2677
|
-
const DS_STATUS = {
|
|
2678
|
-
INIT: 'init',
|
|
2679
|
-
LOADING: 'loading',
|
|
2680
|
-
LOADED: 'loaded',
|
|
2681
|
-
ERROR: 'error'
|
|
2682
|
-
};
|
|
2683
|
-
function doRequest(type, options) {
|
|
2684
|
-
let {
|
|
2685
|
-
uri,
|
|
2686
|
-
url,
|
|
2687
|
-
method = 'GET',
|
|
2688
|
-
headers,
|
|
2689
|
-
params,
|
|
2690
|
-
...otherProps
|
|
2691
|
-
} = options;
|
|
2692
|
-
otherProps = otherProps || {};
|
|
2693
|
-
if (type === 'fetch') {
|
|
2694
|
-
switch (method.toUpperCase()) {
|
|
2695
|
-
case 'GET':
|
|
2696
|
-
return get(uri, params, headers, otherProps);
|
|
2697
|
-
case 'POST':
|
|
2698
|
-
return post(uri, params, headers, otherProps);
|
|
2699
|
-
default:
|
|
2700
|
-
return request(uri, method, params, headers, otherProps);
|
|
2701
|
-
}
|
|
2702
|
-
}
|
|
2703
|
-
logger.log(`Engine default dataSource does not support type:[${type}] dataSource request!`, options);
|
|
2704
|
-
}
|
|
2705
|
-
class DataHelper {
|
|
2706
|
-
host;
|
|
2707
|
-
config;
|
|
2708
|
-
parser;
|
|
2709
|
-
ajaxList;
|
|
2710
|
-
dataHandler;
|
|
2711
|
-
ajaxMap;
|
|
2712
|
-
dataSourceMap;
|
|
2713
|
-
appHelper;
|
|
2714
|
-
constructor(comp, config, appHelper, parser) {
|
|
2715
|
-
this.host = comp;
|
|
2716
|
-
this.config = config || {};
|
|
2717
|
-
this.parser = parser;
|
|
2718
|
-
this.ajaxList = config?.list || [];
|
|
2719
|
-
this.ajaxMap = transformArrayToMap(this.ajaxList, 'id');
|
|
2720
|
-
this.dataSourceMap = this.generateDataSourceMap();
|
|
2721
|
-
this.appHelper = appHelper;
|
|
2722
|
-
this.dataHandler = config?.dataHandler ? parseExpression(config?.dataHandler, comp, true) : undefined;
|
|
2723
|
-
}
|
|
2724
|
-
updateConfig(config = {}) {
|
|
2725
|
-
this.config = config;
|
|
2726
|
-
this.ajaxList = config?.list || [];
|
|
2727
|
-
const ajaxMap = transformArrayToMap(this.ajaxList, 'id');
|
|
2728
|
-
Object.keys(this.ajaxMap).forEach(key => {
|
|
2729
|
-
if (!ajaxMap[key]) {
|
|
2730
|
-
delete this.dataSourceMap[key];
|
|
2731
|
-
}
|
|
2732
|
-
});
|
|
2733
|
-
this.ajaxMap = ajaxMap;
|
|
2734
|
-
this.ajaxList.forEach(item => {
|
|
2735
|
-
if (!this.dataSourceMap[item.id]) {
|
|
2736
|
-
this.dataSourceMap[item.id] = {
|
|
2737
|
-
status: DS_STATUS.INIT,
|
|
2738
|
-
load: (...args) => {
|
|
2739
|
-
return this.getDataSource(item.id, ...args);
|
|
2740
|
-
}
|
|
2741
|
-
};
|
|
2742
|
-
}
|
|
2743
|
-
});
|
|
2744
|
-
return this.dataSourceMap;
|
|
2745
|
-
}
|
|
2746
|
-
generateDataSourceMap() {
|
|
2747
|
-
const res = {};
|
|
2748
|
-
this.ajaxList.forEach(item => {
|
|
2749
|
-
res[item.id] = {
|
|
2750
|
-
status: DS_STATUS.INIT,
|
|
2751
|
-
load: (...args) => {
|
|
2752
|
-
return this.getDataSource(item.id, ...args);
|
|
2753
|
-
}
|
|
2754
|
-
};
|
|
2755
|
-
});
|
|
2756
|
-
return res;
|
|
2757
|
-
}
|
|
2758
|
-
updateDataSourceMap(id, data, error) {
|
|
2759
|
-
this.dataSourceMap[id].error = error || undefined;
|
|
2760
|
-
this.dataSourceMap[id].data = data;
|
|
2761
|
-
this.dataSourceMap[id].status = error ? DS_STATUS.ERROR : DS_STATUS.LOADED;
|
|
2762
|
-
}
|
|
2763
|
-
getInitDataSourseConfigs() {
|
|
2764
|
-
const initConfigs = this.parser(this.ajaxList).filter(item => {
|
|
2765
|
-
if (item.isInit === true) {
|
|
2766
|
-
this.dataSourceMap[item.id].status = DS_STATUS.LOADING;
|
|
2767
|
-
return true;
|
|
2768
|
-
}
|
|
2769
|
-
return false;
|
|
2770
|
-
});
|
|
2771
|
-
return initConfigs;
|
|
2772
|
-
}
|
|
2773
|
-
getInitData() {
|
|
2774
|
-
const initSyncData = this.getInitDataSourseConfigs();
|
|
2775
|
-
return this.asyncDataHandler(initSyncData).then(res => {
|
|
2776
|
-
const {
|
|
2777
|
-
dataHandler
|
|
2778
|
-
} = this.config;
|
|
2779
|
-
return this.handleData(null, dataHandler, res, null);
|
|
2780
|
-
});
|
|
2781
|
-
}
|
|
2782
|
-
async reloadDataSource() {
|
|
2783
|
-
const dataSourceMap = await this.getInitData();
|
|
2784
|
-
if (isEmpty(dataSourceMap)) {
|
|
2785
|
-
return;
|
|
2786
|
-
}
|
|
2787
|
-
this.host.setState(dataSourceMap);
|
|
2788
|
-
if (this.dataHandler) {
|
|
2789
|
-
this.dataHandler(dataSourceMap);
|
|
2790
|
-
}
|
|
2791
|
-
}
|
|
2792
|
-
getDataSource(id, params, otherOptions, callback) {
|
|
2793
|
-
const req = this.parser(this.ajaxMap[id]);
|
|
2794
|
-
const options = req.options || {};
|
|
2795
|
-
let callbackFn = callback;
|
|
2796
|
-
let otherOptionsObj = otherOptions;
|
|
2797
|
-
if (typeof otherOptions === 'function') {
|
|
2798
|
-
callbackFn = otherOptions;
|
|
2799
|
-
otherOptionsObj = {};
|
|
2800
|
-
}
|
|
2801
|
-
const {
|
|
2802
|
-
headers,
|
|
2803
|
-
...otherProps
|
|
2804
|
-
} = otherOptionsObj || {};
|
|
2805
|
-
if (!req) {
|
|
2806
|
-
logger.warn(`getDataSource API named ${id} not exist`);
|
|
2807
|
-
return;
|
|
2808
|
-
}
|
|
2809
|
-
return this.asyncDataHandler([{
|
|
2810
|
-
...req,
|
|
2811
|
-
options: {
|
|
2812
|
-
...options,
|
|
2813
|
-
params: Array.isArray(options.params) || Array.isArray(params) ? params || options.params : {
|
|
2814
|
-
...options.params,
|
|
2815
|
-
...params
|
|
2816
|
-
},
|
|
2817
|
-
headers: {
|
|
2818
|
-
...options.headers,
|
|
2819
|
-
...headers
|
|
2820
|
-
},
|
|
2821
|
-
...otherProps
|
|
2822
|
-
}
|
|
2823
|
-
}]).then(res => {
|
|
2824
|
-
try {
|
|
2825
|
-
callbackFn && callbackFn(res && res[id]);
|
|
2826
|
-
} catch (e) {
|
|
2827
|
-
logger.error('load请求回调函数报错', e);
|
|
2828
|
-
}
|
|
2829
|
-
return res && res[id];
|
|
2830
|
-
}).catch(err => {
|
|
2831
|
-
try {
|
|
2832
|
-
callbackFn && callbackFn(null, err);
|
|
2833
|
-
} catch (e) {
|
|
2834
|
-
logger.error('load请求回调函数报错', e);
|
|
2835
|
-
}
|
|
2836
|
-
return err;
|
|
2837
|
-
});
|
|
2838
|
-
}
|
|
2839
|
-
asyncDataHandler(asyncDataList) {
|
|
2840
|
-
return new Promise((resolve, reject) => {
|
|
2841
|
-
const allReq = [];
|
|
2842
|
-
asyncDataList.forEach(req => {
|
|
2843
|
-
const {
|
|
2844
|
-
id,
|
|
2845
|
-
type
|
|
2846
|
-
} = req;
|
|
2847
|
-
if (!id || !type || type === 'legao') {
|
|
2848
|
-
return;
|
|
2849
|
-
}
|
|
2850
|
-
allReq.push(req);
|
|
2851
|
-
});
|
|
2852
|
-
if (allReq.length === 0) {
|
|
2853
|
-
resolve({});
|
|
2854
|
-
}
|
|
2855
|
-
const res = {};
|
|
2856
|
-
Promise.all(allReq.map(item => {
|
|
2857
|
-
return new Promise(innerResolve => {
|
|
2858
|
-
const {
|
|
2859
|
-
type,
|
|
2860
|
-
id,
|
|
2861
|
-
dataHandler,
|
|
2862
|
-
options
|
|
2863
|
-
} = item;
|
|
2864
|
-
const fetchHandler = (data, error) => {
|
|
2865
|
-
res[id] = this.handleData(id, dataHandler, data, error);
|
|
2866
|
-
this.updateDataSourceMap(id, res[id], error);
|
|
2867
|
-
innerResolve({});
|
|
2868
|
-
};
|
|
2869
|
-
const doFetch = (innerType, innerOptions) => {
|
|
2870
|
-
doRequest(innerType, innerOptions)?.then(data => {
|
|
2871
|
-
fetchHandler(data, undefined);
|
|
2872
|
-
}).catch(err => {
|
|
2873
|
-
fetchHandler(undefined, err);
|
|
2874
|
-
});
|
|
2875
|
-
};
|
|
2876
|
-
this.dataSourceMap[id].status = DS_STATUS.LOADING;
|
|
2877
|
-
doFetch(type, options);
|
|
2878
|
-
});
|
|
2879
|
-
})).then(() => {
|
|
2880
|
-
resolve(res);
|
|
2881
|
-
}).catch(e => {
|
|
2882
|
-
reject(e);
|
|
2883
|
-
});
|
|
2884
|
-
});
|
|
2885
|
-
}
|
|
2886
|
-
handleData(id, dataHandler, data, error) {
|
|
2887
|
-
let dataHandlerFun = dataHandler;
|
|
2888
|
-
if (core.isJSFunction(dataHandler)) {
|
|
2889
|
-
dataHandlerFun = transformStringToFunction(dataHandler.value);
|
|
2890
|
-
}
|
|
2891
|
-
if (!dataHandlerFun || typeof dataHandlerFun !== 'function') {
|
|
2892
|
-
return data;
|
|
2893
|
-
}
|
|
2894
|
-
try {
|
|
2895
|
-
return dataHandlerFun.call(this.host, data, error);
|
|
2896
|
-
} catch (e) {
|
|
2897
|
-
if (id) {
|
|
2898
|
-
logger.error(`[${id}]单个请求数据处理函数运行出错`, e);
|
|
2899
|
-
} else {
|
|
2900
|
-
logger.error('请求数据处理函数运行出错', e);
|
|
2901
|
-
}
|
|
2902
|
-
}
|
|
2903
|
-
}
|
|
2904
|
-
}
|
|
1170
|
+
cache.component.set(componentCacheId, {
|
|
1171
|
+
LeafWrapper,
|
|
1172
|
+
Comp
|
|
1173
|
+
});
|
|
1174
|
+
return LeafWrapper;
|
|
1175
|
+
};
|
|
2905
1176
|
|
|
1177
|
+
/**
|
|
1178
|
+
* execute method in schema.lifeCycles with context
|
|
1179
|
+
*/
|
|
2906
1180
|
function executeLifeCycleMethod(context, schema, method, args) {
|
|
2907
|
-
if (!context || !isSchema(schema) || !method) {
|
|
1181
|
+
if (!context || !rendererCore.isSchema(schema) || !method) {
|
|
2908
1182
|
return;
|
|
2909
1183
|
}
|
|
2910
|
-
const lifeCycleMethods = getValue(schema, 'lifeCycles', {});
|
|
1184
|
+
const lifeCycleMethods = rendererCore.getValue(schema, 'lifeCycles', {});
|
|
2911
1185
|
let fn = lifeCycleMethods[method];
|
|
2912
1186
|
if (!fn) {
|
|
2913
1187
|
return;
|
|
@@ -2915,16 +1189,16 @@ function executeLifeCycleMethod(context, schema, method, args) {
|
|
|
2915
1189
|
|
|
2916
1190
|
// TODO: cache
|
|
2917
1191
|
if (core.isJSExpression(fn) || core.isJSFunction(fn)) {
|
|
2918
|
-
fn = parseExpression(fn, context, true);
|
|
1192
|
+
fn = rendererCore.parseExpression(fn, context, true);
|
|
2919
1193
|
}
|
|
2920
1194
|
if (typeof fn !== 'function') {
|
|
2921
|
-
logger.error(`生命周期${method}类型不符`, fn);
|
|
1195
|
+
rendererCore.logger.error(`生命周期${method}类型不符`, fn);
|
|
2922
1196
|
return;
|
|
2923
1197
|
}
|
|
2924
1198
|
try {
|
|
2925
1199
|
return fn.apply(context, args);
|
|
2926
1200
|
} catch (e) {
|
|
2927
|
-
logger.error(`[${schema.componentName}]生命周期${method}出错`, e);
|
|
1201
|
+
rendererCore.logger.error(`[${schema.componentName}]生命周期${method}出错`, e);
|
|
2928
1202
|
}
|
|
2929
1203
|
}
|
|
2930
1204
|
|
|
@@ -2978,7 +1252,7 @@ function baseRendererFactory() {
|
|
|
2978
1252
|
constructor(props) {
|
|
2979
1253
|
super(props);
|
|
2980
1254
|
this.__parseExpression = (str, self) => {
|
|
2981
|
-
return parseExpression({
|
|
1255
|
+
return rendererCore.parseExpression({
|
|
2982
1256
|
str,
|
|
2983
1257
|
self,
|
|
2984
1258
|
logScope: props.componentName
|
|
@@ -2987,7 +1261,7 @@ function baseRendererFactory() {
|
|
|
2987
1261
|
this.__beforeInit(props);
|
|
2988
1262
|
this.__init(props);
|
|
2989
1263
|
this.__afterInit(props);
|
|
2990
|
-
logger.log(`constructor - ${props?.__schema?.fileName}`);
|
|
1264
|
+
rendererCore.logger.log(`constructor - ${props?.__schema?.fileName}`);
|
|
2991
1265
|
}
|
|
2992
1266
|
__beforeInit(props) {}
|
|
2993
1267
|
__init(props) {
|
|
@@ -3002,27 +1276,27 @@ function baseRendererFactory() {
|
|
|
3002
1276
|
}
|
|
3003
1277
|
async getSnapshotBeforeUpdate(...args) {
|
|
3004
1278
|
this.__executeLifeCycleMethod('getSnapshotBeforeUpdate', args);
|
|
3005
|
-
logger.log(`getSnapshotBeforeUpdate - ${this.props?.__schema?.componentName}`);
|
|
1279
|
+
rendererCore.logger.log(`getSnapshotBeforeUpdate - ${this.props?.__schema?.componentName}`);
|
|
3006
1280
|
}
|
|
3007
1281
|
async componentDidMount(...args) {
|
|
3008
1282
|
this.reloadDataSource();
|
|
3009
1283
|
this.__executeLifeCycleMethod('componentDidMount', args);
|
|
3010
|
-
logger.log(`componentDidMount - ${this.props?.__schema?.componentName}`);
|
|
1284
|
+
rendererCore.logger.log(`componentDidMount - ${this.props?.__schema?.componentName}`);
|
|
3011
1285
|
}
|
|
3012
1286
|
async componentDidUpdate(...args) {
|
|
3013
1287
|
this.__executeLifeCycleMethod('componentDidUpdate', args);
|
|
3014
|
-
logger.log(`componentDidUpdate - ${this.props.__schema.componentName}`);
|
|
1288
|
+
rendererCore.logger.log(`componentDidUpdate - ${this.props.__schema.componentName}`);
|
|
3015
1289
|
}
|
|
3016
1290
|
async componentWillUnmount(...args) {
|
|
3017
1291
|
this.__executeLifeCycleMethod('componentWillUnmount', args);
|
|
3018
|
-
logger.log(`componentWillUnmount - ${this.props?.__schema?.componentName}`);
|
|
1292
|
+
rendererCore.logger.log(`componentWillUnmount - ${this.props?.__schema?.componentName}`);
|
|
3019
1293
|
}
|
|
3020
1294
|
async componentDidCatch(...args) {
|
|
3021
1295
|
this.__executeLifeCycleMethod('componentDidCatch', args);
|
|
3022
|
-
logger.warn(args);
|
|
1296
|
+
rendererCore.logger.warn(args);
|
|
3023
1297
|
}
|
|
3024
1298
|
reloadDataSource = () => new Promise((resolve, reject) => {
|
|
3025
|
-
logger.log('reload data source');
|
|
1299
|
+
rendererCore.logger.log('reload data source');
|
|
3026
1300
|
if (!this.__dataHelper) {
|
|
3027
1301
|
return resolve({});
|
|
3028
1302
|
}
|
|
@@ -3095,7 +1369,7 @@ function baseRendererFactory() {
|
|
|
3095
1369
|
value = this.__parseExpression(value, this);
|
|
3096
1370
|
}
|
|
3097
1371
|
if (typeof value !== 'function') {
|
|
3098
|
-
logger.error(`custom method ${key} can not be parsed to a valid function`, value);
|
|
1372
|
+
rendererCore.logger.error(`custom method ${key} can not be parsed to a valid function`, value);
|
|
3099
1373
|
return;
|
|
3100
1374
|
}
|
|
3101
1375
|
this[key] = value.bind(this);
|
|
@@ -3120,7 +1394,7 @@ function baseRendererFactory() {
|
|
|
3120
1394
|
__ctx,
|
|
3121
1395
|
componentName
|
|
3122
1396
|
} = this.props;
|
|
3123
|
-
return parseData(data, ctx || __ctx || this, {
|
|
1397
|
+
return rendererCore.parseData(data, ctx || __ctx || this, {
|
|
3124
1398
|
logScope: componentName
|
|
3125
1399
|
});
|
|
3126
1400
|
};
|
|
@@ -3133,20 +1407,25 @@ function baseRendererFactory() {
|
|
|
3133
1407
|
list: []
|
|
3134
1408
|
};
|
|
3135
1409
|
const dataSource = schema.dataSource || defaultDataSource;
|
|
3136
|
-
|
|
3137
|
-
// TODO: 下面if else 抽成独立函数
|
|
3138
|
-
const useDataSourceEngine = !!props.__appHelper?.requestHandlersMap;
|
|
1410
|
+
const useDataSourceEngine = !!props.__appHelper?.dataSourceEngine;
|
|
3139
1411
|
if (useDataSourceEngine) {
|
|
1412
|
+
const dataSourceEngine = props.__appHelper?.dataSourceEngine;
|
|
1413
|
+
// TODO: 优化
|
|
1414
|
+
if (!dataSourceEngine || !dataSourceEngine.createDataSourceEngine) {
|
|
1415
|
+
rendererCore.logger.error('dataSourceEngine is not found in appHelper, please check your configuration');
|
|
1416
|
+
return;
|
|
1417
|
+
}
|
|
1418
|
+
const {
|
|
1419
|
+
createDataSourceEngine
|
|
1420
|
+
} = dataSourceEngine;
|
|
3140
1421
|
this.__dataHelper = {
|
|
3141
1422
|
updateConfig: updateDataSource => {
|
|
3142
1423
|
const {
|
|
3143
1424
|
dataSourceMap,
|
|
3144
1425
|
reloadDataSource
|
|
3145
|
-
} = createDataSourceEngine(updateDataSource ?? {}, this
|
|
3146
|
-
requestHandlersMap: props.__appHelper.requestHandlersMap
|
|
3147
|
-
} : undefined);
|
|
1426
|
+
} = createDataSourceEngine(updateDataSource ?? {}, this);
|
|
3148
1427
|
this.reloadDataSource = () => new Promise(resolve => {
|
|
3149
|
-
logger.log('reload data source');
|
|
1428
|
+
rendererCore.logger.log('reload data source');
|
|
3150
1429
|
reloadDataSource().then(() => {
|
|
3151
1430
|
resolve({});
|
|
3152
1431
|
});
|
|
@@ -3157,10 +1436,10 @@ function baseRendererFactory() {
|
|
|
3157
1436
|
this.dataSourceMap = this.__dataHelper.updateConfig(dataSource);
|
|
3158
1437
|
} else {
|
|
3159
1438
|
const appHelper = props.__appHelper || {};
|
|
3160
|
-
this.__dataHelper = new DataHelper(this, dataSource, appHelper, config => this.__parseData(config));
|
|
1439
|
+
this.__dataHelper = new rendererCore.DataHelper(this, dataSource, appHelper, config => this.__parseData(config));
|
|
3161
1440
|
this.dataSourceMap = this.__dataHelper.dataSourceMap;
|
|
3162
1441
|
this.reloadDataSource = () => new Promise(resolve => {
|
|
3163
|
-
logger.log('reload data source');
|
|
1442
|
+
rendererCore.logger.log('reload data source');
|
|
3164
1443
|
this.__dataHelper.reloadDataSource().then(() => {
|
|
3165
1444
|
resolve({});
|
|
3166
1445
|
});
|
|
@@ -3174,8 +1453,8 @@ function baseRendererFactory() {
|
|
|
3174
1453
|
* @PRIVATE
|
|
3175
1454
|
*/
|
|
3176
1455
|
__writeCss = props => {
|
|
3177
|
-
const css = getValue(props.__schema, 'css', '');
|
|
3178
|
-
logger.log('create this.styleElement with css', css);
|
|
1456
|
+
const css = rendererCore.getValue(props.__schema, 'css', '');
|
|
1457
|
+
rendererCore.logger.log('create this.styleElement with css', css);
|
|
3179
1458
|
let style = this.__styleElement;
|
|
3180
1459
|
if (!this.__styleElement) {
|
|
3181
1460
|
style = document.createElement('style');
|
|
@@ -3184,7 +1463,7 @@ function baseRendererFactory() {
|
|
|
3184
1463
|
const head = document.head || document.getElementsByTagName('head')[0];
|
|
3185
1464
|
head.appendChild(style);
|
|
3186
1465
|
this.__styleElement = style;
|
|
3187
|
-
logger.log('this.styleElement is created', this.__styleElement);
|
|
1466
|
+
rendererCore.logger.log('this.styleElement is created', this.__styleElement);
|
|
3188
1467
|
}
|
|
3189
1468
|
if (style.innerHTML === css) {
|
|
3190
1469
|
return;
|
|
@@ -3236,7 +1515,7 @@ function baseRendererFactory() {
|
|
|
3236
1515
|
const _children = getSchemaChildren(__schema);
|
|
3237
1516
|
const Comp = this.__getComponentView();
|
|
3238
1517
|
if (!Comp) {
|
|
3239
|
-
logger.log(`${__schema.componentName} is invalid!`);
|
|
1518
|
+
rendererCore.logger.log(`${__schema.componentName} is invalid!`);
|
|
3240
1519
|
}
|
|
3241
1520
|
const parentNodeInfo = {
|
|
3242
1521
|
schema: __schema,
|
|
@@ -3265,7 +1544,7 @@ function baseRendererFactory() {
|
|
|
3265
1544
|
engine
|
|
3266
1545
|
} = this.context || {};
|
|
3267
1546
|
if (!engine) {
|
|
3268
|
-
logger.log('this.context.engine is invalid!');
|
|
1547
|
+
rendererCore.logger.log('this.context.engine is invalid!');
|
|
3269
1548
|
return null;
|
|
3270
1549
|
}
|
|
3271
1550
|
try {
|
|
@@ -3292,22 +1571,22 @@ function baseRendererFactory() {
|
|
|
3292
1571
|
return schema;
|
|
3293
1572
|
}
|
|
3294
1573
|
if (!schema.componentName) {
|
|
3295
|
-
logger.error('The componentName in the schema is invalid, please check the schema: ', schema);
|
|
1574
|
+
rendererCore.logger.error('The componentName in the schema is invalid, please check the schema: ', schema);
|
|
3296
1575
|
return;
|
|
3297
1576
|
}
|
|
3298
|
-
if (!isSchema(schema)) {
|
|
1577
|
+
if (!rendererCore.isSchema(schema)) {
|
|
3299
1578
|
return null;
|
|
3300
1579
|
}
|
|
3301
1580
|
let Comp = components[schema.componentName] || this.props.__container?.components?.[schema.componentName];
|
|
3302
1581
|
|
|
3303
1582
|
// 容器类组件的上下文通过props传递,避免context传递带来的嵌套问题
|
|
3304
|
-
const otherProps = isSchema(schema) ? {
|
|
1583
|
+
const otherProps = rendererCore.isSchema(schema) ? {
|
|
3305
1584
|
__schema: schema,
|
|
3306
1585
|
__appHelper: appHelper,
|
|
3307
1586
|
__components: components
|
|
3308
1587
|
} : {};
|
|
3309
1588
|
if (!Comp) {
|
|
3310
|
-
logger.error(`${schema.componentName} component is not found in components list! component list is:`, components || this.props.__container?.components);
|
|
1589
|
+
rendererCore.logger.error(`${schema.componentName} component is not found in components list! component list is:`, components || this.props.__container?.components);
|
|
3311
1590
|
return engine.createElement(engine.getNotFoundComponent(), {
|
|
3312
1591
|
componentName: schema.componentName,
|
|
3313
1592
|
componentId: schema.id,
|
|
@@ -3320,7 +1599,7 @@ function baseRendererFactory() {
|
|
|
3320
1599
|
if (schema.loop != null) {
|
|
3321
1600
|
const loop = this.__parseData(schema.loop, scope);
|
|
3322
1601
|
if (Array.isArray(loop) && loop.length === 0) return null;
|
|
3323
|
-
const useLoop = isUseLoop(loop, this.__designModeIsDesign);
|
|
1602
|
+
const useLoop = rendererCore.isUseLoop(loop, this.__designModeIsDesign);
|
|
3324
1603
|
if (useLoop) {
|
|
3325
1604
|
return this.__createLoopVirtualDom({
|
|
3326
1605
|
...schema,
|
|
@@ -3374,7 +1653,7 @@ function baseRendererFactory() {
|
|
|
3374
1653
|
const componentInfo = {};
|
|
3375
1654
|
const props = this.__getComponentProps(schema, scope, Comp, {
|
|
3376
1655
|
...componentInfo,
|
|
3377
|
-
props: transformArrayToMap(componentInfo.props, 'name')
|
|
1656
|
+
props: rendererCore.transformArrayToMap(componentInfo.props, 'name')
|
|
3378
1657
|
}) || {};
|
|
3379
1658
|
Comp = this.__getHOCWrappedComponent(Comp, {
|
|
3380
1659
|
schema,
|
|
@@ -3396,7 +1675,7 @@ function baseRendererFactory() {
|
|
|
3396
1675
|
// props.__scope = this.__compScopes[scopeKey]
|
|
3397
1676
|
// }
|
|
3398
1677
|
if (schema?.__ctx?.lceKey) {
|
|
3399
|
-
if (!isSchema(schema)) {
|
|
1678
|
+
if (!rendererCore.isSchema(schema)) {
|
|
3400
1679
|
engine.props?.onCompGetCtx?.(schema, scope);
|
|
3401
1680
|
}
|
|
3402
1681
|
props.key = props.key || `${schema.__ctx.lceKey}_${schema.__ctx.idx || 0}_${idx !== undefined ? idx : ''}`;
|
|
@@ -3469,7 +1748,7 @@ function baseRendererFactory() {
|
|
|
3469
1748
|
Comp,
|
|
3470
1749
|
componentInfo: {
|
|
3471
1750
|
...(componentInfo || {}),
|
|
3472
|
-
props: transformArrayToMap((componentInfo || {}).props, 'name')
|
|
1751
|
+
props: rendererCore.transformArrayToMap((componentInfo || {}).props, 'name')
|
|
3473
1752
|
}
|
|
3474
1753
|
}) || {};
|
|
3475
1754
|
};
|
|
@@ -3517,14 +1796,14 @@ function baseRendererFactory() {
|
|
|
3517
1796
|
Comp,
|
|
3518
1797
|
componentInfo = {}
|
|
3519
1798
|
} = info;
|
|
3520
|
-
const propInfo = getValue(componentInfo.props, path);
|
|
1799
|
+
const propInfo = rendererCore.getValue(componentInfo.props, path);
|
|
3521
1800
|
// FIXME: 将这行逻辑外置,解耦,线上环境不要验证参数,调试环境可以有,通过传参自定义
|
|
3522
1801
|
const propType = propInfo?.extra?.propType;
|
|
3523
1802
|
const checkProps = value => {
|
|
3524
1803
|
if (!propType) {
|
|
3525
1804
|
return value;
|
|
3526
1805
|
}
|
|
3527
|
-
return checkPropTypes(value, path, propType, componentInfo.name) ? value : undefined;
|
|
1806
|
+
return rendererCore.checkPropTypes(value, path, propType, componentInfo.name) ? value : undefined;
|
|
3528
1807
|
};
|
|
3529
1808
|
const parseReactNode = (data, params) => {
|
|
3530
1809
|
if (isEmpty(params)) {
|
|
@@ -3555,16 +1834,16 @@ function baseRendererFactory() {
|
|
|
3555
1834
|
if (core.isJSExpression(props)) {
|
|
3556
1835
|
props = this.__parseExpression(props, scope);
|
|
3557
1836
|
// 只有当变量解析出来为模型结构的时候才会继续解析
|
|
3558
|
-
if (!isSchema(props)) {
|
|
1837
|
+
if (!rendererCore.isSchema(props)) {
|
|
3559
1838
|
return checkProps(props);
|
|
3560
1839
|
}
|
|
3561
1840
|
}
|
|
3562
1841
|
if (core.isJSFunction(props)) {
|
|
3563
|
-
props = transformStringToFunction(props.value);
|
|
1842
|
+
props = rendererCore.transformStringToFunction(props.value);
|
|
3564
1843
|
}
|
|
3565
1844
|
|
|
3566
1845
|
// 兼容通过componentInfo判断的情况
|
|
3567
|
-
if (isSchema(props)) {
|
|
1846
|
+
if (rendererCore.isSchema(props)) {
|
|
3568
1847
|
const isReactNodeFunction = !!(propInfo?.type === 'ReactNode' && propInfo?.props?.type === 'function');
|
|
3569
1848
|
const isMixinReactNodeFunction = !!(propInfo?.type === 'Mixin' && propInfo?.props?.types?.indexOf('ReactNode') > -1 && propInfo?.props?.reactNodeProps?.type === 'function');
|
|
3570
1849
|
let params = null;
|
|
@@ -3667,7 +1946,7 @@ function baseRendererFactory() {
|
|
|
3667
1946
|
...data,
|
|
3668
1947
|
...this.props,
|
|
3669
1948
|
ref: this.__getRef,
|
|
3670
|
-
className: classnames(__schema?.fileName && getFileCssName(__schema.fileName), className, this.props.className),
|
|
1949
|
+
className: rendererCore.classnames(__schema?.fileName && rendererCore.getFileCssName(__schema.fileName), className, this.props.className),
|
|
3671
1950
|
__id: __schema?.id,
|
|
3672
1951
|
...otherProps
|
|
3673
1952
|
}, this.__createDom());
|
|
@@ -3678,7 +1957,7 @@ function baseRendererFactory() {
|
|
|
3678
1957
|
__schema
|
|
3679
1958
|
} = this.props;
|
|
3680
1959
|
const parsedProps = this.__parseData(__schema.props);
|
|
3681
|
-
const className = classnames(`lce-${this.__namespace}`, __schema?.fileName && getFileCssName(__schema.fileName), parsedProps.className, this.props.className);
|
|
1960
|
+
const className = rendererCore.classnames(`lce-${this.__namespace}`, __schema?.fileName && rendererCore.getFileCssName(__schema.fileName), parsedProps.className, this.props.className);
|
|
3682
1961
|
const style = {
|
|
3683
1962
|
...(parsedProps.style || {}),
|
|
3684
1963
|
...(typeof this.props.style === 'object' ? this.props.style : {})
|
|
@@ -3701,13 +1980,13 @@ function baseRendererFactory() {
|
|
|
3701
1980
|
// const builtin = capitalizeFirstLetter(this.__namespace)
|
|
3702
1981
|
// const componentNames = [builtin, ...extraComponents]
|
|
3703
1982
|
const componentNames = [...Object.keys(this.props.__components), ...extraComponents];
|
|
3704
|
-
return !isSchema(schema) || !componentNames.includes(schema?.componentName ?? '');
|
|
1983
|
+
return !rendererCore.isSchema(schema) || !componentNames.includes(schema?.componentName ?? '');
|
|
3705
1984
|
};
|
|
3706
1985
|
get appHelper() {
|
|
3707
1986
|
return this.props.__appHelper;
|
|
3708
1987
|
}
|
|
3709
|
-
get
|
|
3710
|
-
return this.appHelper?.
|
|
1988
|
+
get dataSourceEngine() {
|
|
1989
|
+
return this.appHelper?.dataSourceEngine;
|
|
3711
1990
|
}
|
|
3712
1991
|
get utils() {
|
|
3713
1992
|
return this.appHelper?.utils;
|
|
@@ -3743,7 +2022,7 @@ function componentRendererFactory() {
|
|
|
3743
2022
|
if (this.__checkSchema(__schema)) {
|
|
3744
2023
|
return '自定义组件 schema 结构异常!';
|
|
3745
2024
|
}
|
|
3746
|
-
logger.log(`${CompRenderer.displayName} render - ${__schema.componentName}`);
|
|
2025
|
+
rendererCore.logger.log(`${CompRenderer.displayName} render - ${__schema.componentName}`);
|
|
3747
2026
|
this.__generateCtx({
|
|
3748
2027
|
component: this
|
|
3749
2028
|
});
|
|
@@ -3791,7 +2070,7 @@ function pageRendererFactory() {
|
|
|
3791
2070
|
super.componentDidUpdate?.(prevProps, _prevState, snapshot);
|
|
3792
2071
|
}
|
|
3793
2072
|
setState(state, callback) {
|
|
3794
|
-
logger.log('page set state', state);
|
|
2073
|
+
rendererCore.logger.log('page set state', state);
|
|
3795
2074
|
super.setState(state, callback);
|
|
3796
2075
|
}
|
|
3797
2076
|
render() {
|
|
@@ -3801,7 +2080,7 @@ function pageRendererFactory() {
|
|
|
3801
2080
|
if (this.__checkSchema(__schema)) {
|
|
3802
2081
|
return '页面schema结构异常!';
|
|
3803
2082
|
}
|
|
3804
|
-
logger.log(`${PageRenderer.displayName} render - ${__schema.componentName}`);
|
|
2083
|
+
rendererCore.logger.log(`${PageRenderer.displayName} render - ${__schema.componentName}`);
|
|
3805
2084
|
this.__bindCustomMethods(this.props);
|
|
3806
2085
|
this.__initDataSource(this.props);
|
|
3807
2086
|
this.__generateCtx({
|
|
@@ -3825,7 +2104,7 @@ const FaultComponent = ({
|
|
|
3825
2104
|
componentName = '',
|
|
3826
2105
|
error
|
|
3827
2106
|
}) => {
|
|
3828
|
-
logger.error(`${componentName} 组件渲染异常, 异常原因: ${error?.message || error || '未知'}`);
|
|
2107
|
+
rendererCore.logger.error(`${componentName} 组件渲染异常, 异常原因: ${error?.message || error || '未知'}`);
|
|
3829
2108
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
3830
2109
|
role: "alert",
|
|
3831
2110
|
"aria-label": `${componentName} 组件渲染异常`,
|
|
@@ -3847,7 +2126,7 @@ const NotFoundComponent = ({
|
|
|
3847
2126
|
enableStrictNotFoundMode,
|
|
3848
2127
|
children
|
|
3849
2128
|
}) => {
|
|
3850
|
-
logger.warn(`Component ${componentName} not found`);
|
|
2129
|
+
rendererCore.logger.warn(`Component ${componentName} not found`);
|
|
3851
2130
|
if (enableStrictNotFoundMode) {
|
|
3852
2131
|
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
3853
2132
|
children: `${componentName} Component Not Found`
|
|
@@ -3888,16 +2167,16 @@ function rendererFactory() {
|
|
|
3888
2167
|
constructor(props) {
|
|
3889
2168
|
super(props);
|
|
3890
2169
|
this.state = {};
|
|
3891
|
-
|
|
2170
|
+
rendererCore.logger.log(`entry.constructor - ${props?.schema?.componentName}`);
|
|
3892
2171
|
}
|
|
3893
2172
|
async componentDidMount() {
|
|
3894
|
-
|
|
2173
|
+
rendererCore.logger.log(`entry.componentDidMount - ${this.props.schema && this.props.schema.componentName}`);
|
|
3895
2174
|
}
|
|
3896
2175
|
async componentDidUpdate() {
|
|
3897
|
-
|
|
2176
|
+
rendererCore.logger.log(`entry.componentDidUpdate - ${this.props?.schema?.componentName}`);
|
|
3898
2177
|
}
|
|
3899
2178
|
async componentWillUnmount() {
|
|
3900
|
-
|
|
2179
|
+
rendererCore.logger.log(`entry.componentWillUnmount - ${this.props?.schema?.componentName}`);
|
|
3901
2180
|
}
|
|
3902
2181
|
componentDidCatch(error) {
|
|
3903
2182
|
this.state.engineRenderError = true;
|
|
@@ -3934,11 +2213,11 @@ function rendererFactory() {
|
|
|
3934
2213
|
if (isEmpty(schema)) {
|
|
3935
2214
|
return null;
|
|
3936
2215
|
}
|
|
3937
|
-
if (!isSchema(schema)) {
|
|
3938
|
-
|
|
2216
|
+
if (!rendererCore.isSchema(schema)) {
|
|
2217
|
+
rendererCore.logger.error('The root component name needs to be one of Page、Block、Component, please check the schema: ', schema);
|
|
3939
2218
|
return '模型结构异常';
|
|
3940
2219
|
}
|
|
3941
|
-
|
|
2220
|
+
rendererCore.logger.log('entry.render');
|
|
3942
2221
|
const allComponents = {
|
|
3943
2222
|
...components,
|
|
3944
2223
|
...RENDERER_COMPS
|
|
@@ -3973,41 +2252,274 @@ function rendererFactory() {
|
|
|
3973
2252
|
};
|
|
3974
2253
|
}
|
|
3975
2254
|
|
|
3976
|
-
const
|
|
2255
|
+
const SettingRendererContext = /*#__PURE__*/react.createContext({});
|
|
2256
|
+
const useSettingRendererContext = () => {
|
|
2257
|
+
try {
|
|
2258
|
+
return react.useContext(SettingRendererContext);
|
|
2259
|
+
} catch (error) {
|
|
2260
|
+
console.warn('useSettingRendererContext must be used within a SettingRendererContextProvider');
|
|
2261
|
+
}
|
|
2262
|
+
return {};
|
|
2263
|
+
};
|
|
2264
|
+
|
|
2265
|
+
const getSetterInfo = field => {
|
|
2266
|
+
const {
|
|
2267
|
+
extraProps,
|
|
2268
|
+
setter
|
|
2269
|
+
} = field;
|
|
2270
|
+
const {
|
|
2271
|
+
defaultValue
|
|
2272
|
+
} = extraProps;
|
|
2273
|
+
let setterProps = {};
|
|
2274
|
+
let setterType;
|
|
2275
|
+
let initialValue = null;
|
|
2276
|
+
if (core.isSetterConfig(setter)) {
|
|
2277
|
+
setterType = setter.componentName;
|
|
2278
|
+
if (setter.props) {
|
|
2279
|
+
setterProps = setter.props;
|
|
2280
|
+
if (typeof setterProps === 'function') {
|
|
2281
|
+
setterProps = setterProps(field);
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
if (setter.defaultValue != null) {
|
|
2285
|
+
initialValue = setter.defaultValue;
|
|
2286
|
+
}
|
|
2287
|
+
} else if (setter) {
|
|
2288
|
+
setterType = setter;
|
|
2289
|
+
}
|
|
2290
|
+
if (defaultValue != null && !('defaultValue' in setterProps)) {
|
|
2291
|
+
setterProps.defaultValue = defaultValue;
|
|
2292
|
+
if (initialValue == null) {
|
|
2293
|
+
initialValue = defaultValue;
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
if (field.valueState === -1) {
|
|
2297
|
+
setterProps.multiValue = true;
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
// 根据是否支持变量配置做相应的更改
|
|
2301
|
+
const supportVariable = field.extraProps?.supportVariable;
|
|
2302
|
+
const isUseVariableSetter = supportVariable;
|
|
2303
|
+
if (isUseVariableSetter === false) {
|
|
2304
|
+
return {
|
|
2305
|
+
setterProps,
|
|
2306
|
+
initialValue,
|
|
2307
|
+
setterType
|
|
2308
|
+
};
|
|
2309
|
+
}
|
|
2310
|
+
return {
|
|
2311
|
+
setterProps,
|
|
2312
|
+
setterType,
|
|
2313
|
+
initialValue
|
|
2314
|
+
};
|
|
2315
|
+
};
|
|
2316
|
+
const SettingSetter = mobxReact.observer(({
|
|
2317
|
+
field,
|
|
2318
|
+
children
|
|
2319
|
+
}) => {
|
|
2320
|
+
const {
|
|
2321
|
+
setters
|
|
2322
|
+
} = useSettingRendererContext();
|
|
2323
|
+
const {
|
|
2324
|
+
extraProps
|
|
2325
|
+
} = field;
|
|
2326
|
+
const visible = extraProps?.condition && typeof extraProps.condition === 'function' ? extraProps.condition(field) !== false : true;
|
|
2327
|
+
if (!visible) {
|
|
2328
|
+
return null;
|
|
2329
|
+
}
|
|
2330
|
+
const {
|
|
2331
|
+
setterProps = {},
|
|
2332
|
+
setterType,
|
|
2333
|
+
initialValue = null
|
|
2334
|
+
} = getSetterInfo(field);
|
|
2335
|
+
const onChange = extraProps?.onChange;
|
|
2336
|
+
const value = field.valueState === -1 ? null : field.getValue();
|
|
2337
|
+
const {
|
|
2338
|
+
component: SetterComponent,
|
|
2339
|
+
props: mixedSetterProps
|
|
2340
|
+
} = setters.createSetterContent(setterType, setterProps);
|
|
2341
|
+
return /*#__PURE__*/jsxRuntime.jsx(SetterComponent, {
|
|
2342
|
+
field: field,
|
|
2343
|
+
selected: field.top?.getNode(),
|
|
2344
|
+
initialValue: initialValue,
|
|
2345
|
+
value: value,
|
|
2346
|
+
onChange: newVal => {
|
|
2347
|
+
field.setValue(newVal);
|
|
2348
|
+
onChange?.(field, newVal);
|
|
2349
|
+
},
|
|
2350
|
+
onInitial: () => {
|
|
2351
|
+
if (initialValue == null) {
|
|
2352
|
+
return;
|
|
2353
|
+
}
|
|
2354
|
+
const value = typeof initialValue === 'function' ? initialValue(field) : initialValue;
|
|
2355
|
+
field.setValue(value, true);
|
|
2356
|
+
},
|
|
2357
|
+
removeProp: () => {
|
|
2358
|
+
if (field.name) {
|
|
2359
|
+
field.parent.clearPropValue(field.name);
|
|
2360
|
+
}
|
|
2361
|
+
},
|
|
2362
|
+
...mixedSetterProps,
|
|
2363
|
+
children: children
|
|
2364
|
+
}, field.id);
|
|
2365
|
+
});
|
|
2366
|
+
|
|
2367
|
+
const SettingFieldItem = mobxReact.observer(({
|
|
2368
|
+
field
|
|
2369
|
+
}) => {
|
|
2370
|
+
const {
|
|
2371
|
+
customFieldItem
|
|
2372
|
+
} = useSettingRendererContext();
|
|
2373
|
+
if (customFieldItem) {
|
|
2374
|
+
return customFieldItem(field, /*#__PURE__*/jsxRuntime.jsx(SettingSetter, {
|
|
2375
|
+
field: field
|
|
2376
|
+
}));
|
|
2377
|
+
}
|
|
2378
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2379
|
+
className: "space-y-2",
|
|
2380
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("label", {
|
|
2381
|
+
htmlFor: field.id,
|
|
2382
|
+
className: "block text-sm font-medium text-gray-700",
|
|
2383
|
+
children: field.title
|
|
2384
|
+
}), /*#__PURE__*/jsxRuntime.jsx(SettingSetter, {
|
|
2385
|
+
field: field
|
|
2386
|
+
})]
|
|
2387
|
+
});
|
|
2388
|
+
});
|
|
2389
|
+
const SettingFieldGroup = mobxReact.observer(({
|
|
2390
|
+
field
|
|
2391
|
+
}) => {
|
|
2392
|
+
const {
|
|
2393
|
+
customFieldGroup
|
|
2394
|
+
} = useSettingRendererContext();
|
|
2395
|
+
if (customFieldGroup) {
|
|
2396
|
+
return customFieldGroup(field, /*#__PURE__*/jsxRuntime.jsx(SettingSetter, {
|
|
2397
|
+
field: field,
|
|
2398
|
+
children: field.items?.map(item => /*#__PURE__*/jsxRuntime.jsx(SettingFieldView, {
|
|
2399
|
+
field: item
|
|
2400
|
+
}, item.id))
|
|
2401
|
+
}));
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
// 如果 field 没有 setter,则理解为其 父级 field 的 items 数据
|
|
2405
|
+
if (!field.setter) {
|
|
2406
|
+
return field.items?.map(item => /*#__PURE__*/jsxRuntime.jsx(SettingFieldView, {
|
|
2407
|
+
field: item
|
|
2408
|
+
}, item.id));
|
|
2409
|
+
}
|
|
2410
|
+
return /*#__PURE__*/jsxRuntime.jsx(SettingSetter, {
|
|
2411
|
+
field: field,
|
|
2412
|
+
children: field.items?.map(item => /*#__PURE__*/jsxRuntime.jsx(SettingFieldView, {
|
|
2413
|
+
field: item
|
|
2414
|
+
}, item.id))
|
|
2415
|
+
});
|
|
2416
|
+
});
|
|
2417
|
+
const SettingFieldView = ({
|
|
2418
|
+
field
|
|
2419
|
+
}) => {
|
|
2420
|
+
if (field.isGroup) {
|
|
2421
|
+
return /*#__PURE__*/jsxRuntime.jsx(SettingFieldGroup, {
|
|
2422
|
+
field: field
|
|
2423
|
+
}, field.id);
|
|
2424
|
+
} else {
|
|
2425
|
+
return /*#__PURE__*/jsxRuntime.jsx(SettingFieldItem, {
|
|
2426
|
+
field: field
|
|
2427
|
+
}, field.id);
|
|
2428
|
+
}
|
|
2429
|
+
};
|
|
2430
|
+
const SettingRenderer = mobxReact.observer(props => {
|
|
2431
|
+
const {
|
|
2432
|
+
designer,
|
|
2433
|
+
customFieldItem,
|
|
2434
|
+
customFieldGroup
|
|
2435
|
+
} = props;
|
|
2436
|
+
const setters = designer.editor.get('setters');
|
|
2437
|
+
const {
|
|
2438
|
+
settingsManager
|
|
2439
|
+
} = designer;
|
|
2440
|
+
const {
|
|
2441
|
+
settings
|
|
2442
|
+
} = settingsManager;
|
|
2443
|
+
const items = settings?.items;
|
|
2444
|
+
const ctx = react.useMemo(() => {
|
|
2445
|
+
const ctx = {};
|
|
2446
|
+
ctx.setters = setters;
|
|
2447
|
+
ctx.settingsManager = settingsManager;
|
|
2448
|
+
ctx.customFieldItem = customFieldItem;
|
|
2449
|
+
ctx.customFieldGroup = customFieldGroup;
|
|
2450
|
+
return ctx;
|
|
2451
|
+
}, [setters, settingsManager, customFieldItem, customFieldGroup]);
|
|
2452
|
+
if (!settings) {
|
|
2453
|
+
// 未选中节点,提示选中 或者 显示根节点设置
|
|
2454
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2455
|
+
className: "lc-settings-main",
|
|
2456
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2457
|
+
className: "lc-settings-notice",
|
|
2458
|
+
children: /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
2459
|
+
children: "Please select a node in canvas"
|
|
2460
|
+
})
|
|
2461
|
+
})
|
|
2462
|
+
});
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
// 当节点被锁定,且未开启锁定后容器可设置属性
|
|
2466
|
+
if (settings.isLocked) {
|
|
2467
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2468
|
+
className: "lc-settings-main",
|
|
2469
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2470
|
+
className: "lc-settings-notice",
|
|
2471
|
+
children: /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
2472
|
+
children: "Current node is locked"
|
|
2473
|
+
})
|
|
2474
|
+
})
|
|
2475
|
+
});
|
|
2476
|
+
}
|
|
2477
|
+
if (Array.isArray(settings.items) && settings.items.length === 0) {
|
|
2478
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2479
|
+
className: "lc-settings-main",
|
|
2480
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2481
|
+
className: "lc-settings-notice",
|
|
2482
|
+
children: /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
2483
|
+
children: "No config found for this type of component"
|
|
2484
|
+
})
|
|
2485
|
+
})
|
|
2486
|
+
});
|
|
2487
|
+
}
|
|
2488
|
+
if (!settings.isSameComponent) {
|
|
2489
|
+
// TODO: future support 获取设置项交集编辑
|
|
2490
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2491
|
+
className: "lc-settings-main",
|
|
2492
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2493
|
+
className: "lc-settings-notice",
|
|
2494
|
+
children: /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
2495
|
+
children: "Please select same kind of components"
|
|
2496
|
+
})
|
|
2497
|
+
})
|
|
2498
|
+
});
|
|
2499
|
+
}
|
|
2500
|
+
return /*#__PURE__*/jsxRuntime.jsx(SettingRendererContext.Provider, {
|
|
2501
|
+
value: ctx,
|
|
2502
|
+
children: items?.map(item => /*#__PURE__*/jsxRuntime.jsx(SettingFieldView, {
|
|
2503
|
+
field: item
|
|
2504
|
+
}, item.id))
|
|
2505
|
+
});
|
|
2506
|
+
});
|
|
3977
2507
|
|
|
3978
|
-
exports.DEV = DEV;
|
|
3979
2508
|
exports.RendererContext = RendererContext;
|
|
3980
2509
|
exports.SettingFieldView = SettingFieldView;
|
|
3981
|
-
exports.
|
|
2510
|
+
exports.SettingRenderer = SettingRenderer;
|
|
3982
2511
|
exports.adapter = adapter;
|
|
3983
2512
|
exports.baseRendererFactory = baseRendererFactory;
|
|
3984
|
-
exports.capitalizeFirstLetter = capitalizeFirstLetter;
|
|
3985
|
-
exports.checkPropTypes = checkPropTypes;
|
|
3986
|
-
exports.classnames = classnames;
|
|
3987
2513
|
exports.cloneEnumerableProperty = cloneEnumerableProperty;
|
|
3988
2514
|
exports.compWrapper = compWrapper;
|
|
3989
2515
|
exports.componentRendererFactory = componentRendererFactory;
|
|
3990
2516
|
exports.contextFactory = contextFactory;
|
|
3991
2517
|
exports.createForwardRefHocElement = createForwardRefHocElement;
|
|
3992
2518
|
exports.executeLifeCycleMethod = executeLifeCycleMethod;
|
|
3993
|
-
exports.getFileCssName = getFileCssName;
|
|
3994
2519
|
exports.getSchemaChildren = getSchemaChildren;
|
|
3995
|
-
exports.getValue = getValue;
|
|
3996
|
-
exports.inSameDomain = inSameDomain;
|
|
3997
2520
|
exports.isReactClass = isReactClass;
|
|
3998
2521
|
exports.isReactComponent = isReactComponent;
|
|
3999
|
-
exports.isSchema = isSchema;
|
|
4000
|
-
exports.isString = isString;
|
|
4001
|
-
exports.isUseLoop = isUseLoop;
|
|
4002
2522
|
exports.leafWrapper = leafWrapper;
|
|
4003
|
-
exports.logger = logger;
|
|
4004
2523
|
exports.pageRendererFactory = pageRendererFactory;
|
|
4005
|
-
exports.parseData = parseData;
|
|
4006
|
-
exports.parseExpression = parseExpression;
|
|
4007
|
-
exports.parseThisRequiredExpression = parseThisRequiredExpression;
|
|
4008
2524
|
exports.rendererFactory = rendererFactory;
|
|
4009
|
-
exports.serializeParams = serializeParams;
|
|
4010
|
-
exports.transformArrayToMap = transformArrayToMap;
|
|
4011
|
-
exports.transformStringToFunction = transformStringToFunction;
|
|
4012
2525
|
exports.useRendererContext = useRendererContext;
|
|
4013
|
-
//# sourceMappingURL=index.js.map
|