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