@zzdadelu/schema-builder 1.0.0-alpha.52 → 1.0.0-alpha.54
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/es/main.js +105 -88
- package/lib/main.js +104 -87
- package/package.json +1 -1
package/es/main.js
CHANGED
|
@@ -13,68 +13,67 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
13
13
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
14
14
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
15
15
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
16
|
-
import React, { useEffect, useRef, useImperativeHandle, forwardRef, useState } from 'react';
|
|
16
|
+
import React, { useEffect, useRef, useImperativeHandle, forwardRef, useState, useCallback } from 'react';
|
|
17
17
|
import createIframe from './createIframe';
|
|
18
18
|
import * as defaultSetting from './settings';
|
|
19
|
-
var iframe;
|
|
20
|
-
var retryCount = 0;
|
|
21
|
-
var MAX_RETRIES = 3;
|
|
22
19
|
var Design = function Design(props, ref) {
|
|
23
20
|
var widgets = props.widgets,
|
|
24
21
|
settings = props.settings,
|
|
25
22
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
26
|
-
var containerRef = useRef();
|
|
23
|
+
var containerRef = useRef(null);
|
|
24
|
+
var iframeRef;
|
|
27
25
|
var _useState = useState(true),
|
|
28
26
|
_useState2 = _slicedToArray(_useState, 2),
|
|
29
27
|
loading = _useState2[0],
|
|
30
28
|
setLoading = _useState2[1];
|
|
29
|
+
var _useState3 = useState(0),
|
|
30
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
31
|
+
retryCount = _useState4[0],
|
|
32
|
+
setRetryCount = _useState4[1];
|
|
33
|
+
var MAX_RETRIES = 3;
|
|
31
34
|
useImperativeHandle(ref, function () {
|
|
32
35
|
return {
|
|
33
36
|
getValue: function getValue() {
|
|
34
|
-
var
|
|
35
|
-
return (
|
|
37
|
+
var _iframeRef$current, _iframeRef$current$co, _iframeRef$current$co2, _iframeRef$current$co3;
|
|
38
|
+
return (_iframeRef$current = iframeRef.current) === null || _iframeRef$current === void 0 ? void 0 : (_iframeRef$current$co = _iframeRef$current.contentWindow) === null || _iframeRef$current$co === void 0 ? void 0 : (_iframeRef$current$co2 = _iframeRef$current$co.__FR_ENGINE__) === null || _iframeRef$current$co2 === void 0 ? void 0 : (_iframeRef$current$co3 = _iframeRef$current$co2.exportSchema) === null || _iframeRef$current$co3 === void 0 ? void 0 : _iframeRef$current$co3.call(_iframeRef$current$co2);
|
|
36
39
|
},
|
|
37
40
|
setValue: function setValue(schema) {
|
|
38
|
-
var
|
|
39
|
-
return (
|
|
41
|
+
var _iframeRef$current2, _iframeRef$current2$c, _iframeRef$current2$c2, _iframeRef$current2$c3;
|
|
42
|
+
return (_iframeRef$current2 = iframeRef.current) === null || _iframeRef$current2 === void 0 ? void 0 : (_iframeRef$current2$c = _iframeRef$current2.contentWindow) === null || _iframeRef$current2$c === void 0 ? void 0 : (_iframeRef$current2$c2 = _iframeRef$current2$c.__FR_ENGINE__) === null || _iframeRef$current2$c2 === void 0 ? void 0 : (_iframeRef$current2$c3 = _iframeRef$current2$c2.importSchema) === null || _iframeRef$current2$c3 === void 0 ? void 0 : _iframeRef$current2$c3.call(_iframeRef$current2$c2, schema);
|
|
40
43
|
},
|
|
41
44
|
reload: function reload() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
retryCount = 0;
|
|
46
|
-
initIframe();
|
|
47
|
-
}
|
|
45
|
+
setRetryCount(0);
|
|
46
|
+
cleanupIframe();
|
|
47
|
+
initIframe();
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (iframe && containerRef.current) {
|
|
58
|
-
try {
|
|
59
|
-
containerRef.current.removeChild(iframe);
|
|
60
|
-
} catch (e) {}
|
|
61
|
-
iframe = null;
|
|
51
|
+
var cleanupIframe = useCallback(function () {
|
|
52
|
+
if (iframeRef.current && containerRef.current) {
|
|
53
|
+
try {
|
|
54
|
+
containerRef.current.removeChild(iframeRef.current);
|
|
55
|
+
} catch (e) {
|
|
56
|
+
// 忽略错误
|
|
62
57
|
}
|
|
63
|
-
|
|
58
|
+
iframeRef.current = null;
|
|
59
|
+
}
|
|
64
60
|
}, []);
|
|
65
|
-
var initIframe = function
|
|
61
|
+
var initIframe = useCallback(function () {
|
|
66
62
|
console.log('[SchemaBuilder] Initializing iframe, retry:', retryCount);
|
|
67
63
|
|
|
68
64
|
// 清理旧的 iframe
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
cleanupIframe();
|
|
66
|
+
|
|
67
|
+
// 确保容器存在
|
|
68
|
+
if (!containerRef.current) {
|
|
69
|
+
console.error('[SchemaBuilder] Container ref is null, delaying iframe creation');
|
|
70
|
+
setTimeout(initIframe, 100);
|
|
71
|
+
return;
|
|
74
72
|
}
|
|
75
73
|
|
|
76
74
|
// 创建新的 iframe
|
|
77
|
-
iframe = createIframe();
|
|
75
|
+
var iframe = createIframe();
|
|
76
|
+
iframeRef.current = iframe;
|
|
78
77
|
|
|
79
78
|
// 添加错误处理
|
|
80
79
|
iframe.onerror = function (e) {
|
|
@@ -84,67 +83,85 @@ var Design = function Design(props, ref) {
|
|
|
84
83
|
console.log('[SchemaBuilder] Iframe loaded');
|
|
85
84
|
setLoading(false);
|
|
86
85
|
};
|
|
87
|
-
containerRef.current.appendChild(iframe);
|
|
88
86
|
|
|
89
|
-
//
|
|
90
|
-
|
|
87
|
+
// 添加到容器
|
|
88
|
+
try {
|
|
89
|
+
containerRef.current.appendChild(iframe);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error('[SchemaBuilder] Failed to append iframe:', error);
|
|
92
|
+
if (retryCount < MAX_RETRIES) {
|
|
93
|
+
setRetryCount(function (prev) {
|
|
94
|
+
return prev + 1;
|
|
95
|
+
});
|
|
96
|
+
setTimeout(initIframe, 1000);
|
|
97
|
+
}
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 设置超时检查
|
|
102
|
+
var timeoutId = setTimeout(function () {
|
|
91
103
|
if (iframe && (!iframe.contentWindow || !iframe.contentDocument)) {
|
|
92
|
-
console.warn('[SchemaBuilder] Iframe load timeout
|
|
93
|
-
|
|
104
|
+
console.warn('[SchemaBuilder] Iframe load timeout');
|
|
105
|
+
if (retryCount < MAX_RETRIES) {
|
|
106
|
+
setRetryCount(function (prev) {
|
|
107
|
+
return prev + 1;
|
|
108
|
+
});
|
|
109
|
+
cleanupIframe();
|
|
110
|
+
initIframe();
|
|
111
|
+
}
|
|
94
112
|
}
|
|
95
113
|
}, 10000);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
console.error('[SchemaBuilder] Max retries reached');
|
|
114
|
+
return function () {
|
|
115
|
+
return clearTimeout(timeoutId);
|
|
116
|
+
};
|
|
117
|
+
}, [cleanupIframe, retryCount]);
|
|
118
|
+
var handleMessage = useCallback(function (event) {
|
|
119
|
+
if (event.data.type !== 'engine-load') {
|
|
120
|
+
return;
|
|
104
121
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
console.error('[SchemaBuilder] getFormRenderMaterial check failed, retrying...');
|
|
116
|
-
setTimeout(retryIframe, 500);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// 延迟初始化以确保所有资源就绪
|
|
121
|
-
setTimeout(function () {
|
|
122
|
-
try {
|
|
123
|
-
var _iframe3, _iframe3$contentWindo;
|
|
124
|
-
if ((_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : (_iframe3$contentWindo = _iframe3.contentWindow) === null || _iframe3$contentWindo === void 0 ? void 0 : _iframe3$contentWindo.__FR_ENGINE__) {
|
|
125
|
-
iframe.contentWindow.__FR_ENGINE__.init(_objectSpread({
|
|
126
|
-
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
127
|
-
widgets: widgets,
|
|
128
|
-
logo: {
|
|
129
|
-
title: 'XRender'
|
|
130
|
-
}
|
|
131
|
-
}, restProps));
|
|
132
|
-
console.log('[SchemaBuilder] Engine initialized successfully');
|
|
133
|
-
} else {
|
|
134
|
-
console.error('[SchemaBuilder] __FR_ENGINE__ not found in iframe');
|
|
135
|
-
retryIframe();
|
|
122
|
+
console.log('[SchemaBuilder] Engine loaded');
|
|
123
|
+
setTimeout(function () {
|
|
124
|
+
try {
|
|
125
|
+
var _iframeRef$current3, _iframeRef$current3$c;
|
|
126
|
+
if ((_iframeRef$current3 = iframeRef.current) === null || _iframeRef$current3 === void 0 ? void 0 : (_iframeRef$current3$c = _iframeRef$current3.contentWindow) === null || _iframeRef$current3$c === void 0 ? void 0 : _iframeRef$current3$c.__FR_ENGINE__) {
|
|
127
|
+
iframeRef.current.contentWindow.__FR_ENGINE__.init(_objectSpread({
|
|
128
|
+
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
129
|
+
widgets: widgets,
|
|
130
|
+
logo: {
|
|
131
|
+
title: 'XRender'
|
|
136
132
|
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
133
|
+
}, restProps));
|
|
134
|
+
console.log('[SchemaBuilder] Engine initialized successfully');
|
|
135
|
+
} else {
|
|
136
|
+
console.error('[SchemaBuilder] __FR_ENGINE__ not found in iframe');
|
|
137
|
+
if (retryCount < MAX_RETRIES) {
|
|
138
|
+
setRetryCount(function (prev) {
|
|
139
|
+
return prev + 1;
|
|
140
|
+
});
|
|
141
|
+
cleanupIframe();
|
|
142
|
+
initIframe();
|
|
140
143
|
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
144
|
+
}
|
|
145
|
+
} catch (error) {
|
|
146
|
+
console.error('[SchemaBuilder] Error initializing engine:', error);
|
|
147
|
+
if (retryCount < MAX_RETRIES) {
|
|
148
|
+
setRetryCount(function (prev) {
|
|
149
|
+
return prev + 1;
|
|
150
|
+
});
|
|
151
|
+
cleanupIframe();
|
|
152
|
+
initIframe();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}, 500);
|
|
156
|
+
}, [cleanupIframe, initIframe, retryCount, settings, widgets, restProps]);
|
|
157
|
+
useEffect(function () {
|
|
158
|
+
initIframe();
|
|
159
|
+
window.addEventListener('message', handleMessage);
|
|
160
|
+
return function () {
|
|
161
|
+
window.removeEventListener('message', handleMessage);
|
|
162
|
+
cleanupIframe();
|
|
163
|
+
};
|
|
164
|
+
}, [initIframe, handleMessage, cleanupIframe]);
|
|
148
165
|
return /*#__PURE__*/React.createElement(React.Fragment, null, loading && /*#__PURE__*/React.createElement("div", {
|
|
149
166
|
style: {
|
|
150
167
|
position: 'absolute',
|
package/lib/main.js
CHANGED
|
@@ -24,65 +24,64 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
24
24
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
25
25
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
26
26
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
27
|
-
var iframe;
|
|
28
|
-
var retryCount = 0;
|
|
29
|
-
var MAX_RETRIES = 3;
|
|
30
27
|
var Design = function Design(props, ref) {
|
|
31
28
|
var widgets = props.widgets,
|
|
32
29
|
settings = props.settings,
|
|
33
30
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
34
|
-
var containerRef = (0, _react.useRef)();
|
|
31
|
+
var containerRef = (0, _react.useRef)(null);
|
|
32
|
+
var iframeRef;
|
|
35
33
|
var _useState = (0, _react.useState)(true),
|
|
36
34
|
_useState2 = _slicedToArray(_useState, 2),
|
|
37
35
|
loading = _useState2[0],
|
|
38
36
|
setLoading = _useState2[1];
|
|
37
|
+
var _useState3 = (0, _react.useState)(0),
|
|
38
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
39
|
+
retryCount = _useState4[0],
|
|
40
|
+
setRetryCount = _useState4[1];
|
|
41
|
+
var MAX_RETRIES = 3;
|
|
39
42
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
40
43
|
return {
|
|
41
44
|
getValue: function getValue() {
|
|
42
|
-
var
|
|
43
|
-
return (
|
|
45
|
+
var _iframeRef$current, _iframeRef$current$co, _iframeRef$current$co2, _iframeRef$current$co3;
|
|
46
|
+
return (_iframeRef$current = iframeRef.current) === null || _iframeRef$current === void 0 ? void 0 : (_iframeRef$current$co = _iframeRef$current.contentWindow) === null || _iframeRef$current$co === void 0 ? void 0 : (_iframeRef$current$co2 = _iframeRef$current$co.__FR_ENGINE__) === null || _iframeRef$current$co2 === void 0 ? void 0 : (_iframeRef$current$co3 = _iframeRef$current$co2.exportSchema) === null || _iframeRef$current$co3 === void 0 ? void 0 : _iframeRef$current$co3.call(_iframeRef$current$co2);
|
|
44
47
|
},
|
|
45
48
|
setValue: function setValue(schema) {
|
|
46
|
-
var
|
|
47
|
-
return (
|
|
49
|
+
var _iframeRef$current2, _iframeRef$current2$c, _iframeRef$current2$c2, _iframeRef$current2$c3;
|
|
50
|
+
return (_iframeRef$current2 = iframeRef.current) === null || _iframeRef$current2 === void 0 ? void 0 : (_iframeRef$current2$c = _iframeRef$current2.contentWindow) === null || _iframeRef$current2$c === void 0 ? void 0 : (_iframeRef$current2$c2 = _iframeRef$current2$c.__FR_ENGINE__) === null || _iframeRef$current2$c2 === void 0 ? void 0 : (_iframeRef$current2$c3 = _iframeRef$current2$c2.importSchema) === null || _iframeRef$current2$c3 === void 0 ? void 0 : _iframeRef$current2$c3.call(_iframeRef$current2$c2, schema);
|
|
48
51
|
},
|
|
49
52
|
reload: function reload() {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
retryCount = 0;
|
|
54
|
-
initIframe();
|
|
55
|
-
}
|
|
53
|
+
setRetryCount(0);
|
|
54
|
+
cleanupIframe();
|
|
55
|
+
initIframe();
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
});
|
|
59
|
-
(0, _react.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (iframe && containerRef.current) {
|
|
66
|
-
try {
|
|
67
|
-
containerRef.current.removeChild(iframe);
|
|
68
|
-
} catch (e) {}
|
|
69
|
-
iframe = null;
|
|
59
|
+
var cleanupIframe = (0, _react.useCallback)(function () {
|
|
60
|
+
if (iframeRef.current && containerRef.current) {
|
|
61
|
+
try {
|
|
62
|
+
containerRef.current.removeChild(iframeRef.current);
|
|
63
|
+
} catch (e) {
|
|
64
|
+
// 忽略错误
|
|
70
65
|
}
|
|
71
|
-
|
|
66
|
+
iframeRef.current = null;
|
|
67
|
+
}
|
|
72
68
|
}, []);
|
|
73
|
-
var initIframe = function
|
|
69
|
+
var initIframe = (0, _react.useCallback)(function () {
|
|
74
70
|
console.log('[SchemaBuilder] Initializing iframe, retry:', retryCount);
|
|
75
71
|
|
|
76
72
|
// 清理旧的 iframe
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
cleanupIframe();
|
|
74
|
+
|
|
75
|
+
// 确保容器存在
|
|
76
|
+
if (!containerRef.current) {
|
|
77
|
+
console.error('[SchemaBuilder] Container ref is null, delaying iframe creation');
|
|
78
|
+
setTimeout(initIframe, 100);
|
|
79
|
+
return;
|
|
82
80
|
}
|
|
83
81
|
|
|
84
82
|
// 创建新的 iframe
|
|
85
|
-
iframe = (0, _createIframe.default)();
|
|
83
|
+
var iframe = (0, _createIframe.default)();
|
|
84
|
+
iframeRef.current = iframe;
|
|
86
85
|
|
|
87
86
|
// 添加错误处理
|
|
88
87
|
iframe.onerror = function (e) {
|
|
@@ -92,67 +91,85 @@ var Design = function Design(props, ref) {
|
|
|
92
91
|
console.log('[SchemaBuilder] Iframe loaded');
|
|
93
92
|
setLoading(false);
|
|
94
93
|
};
|
|
95
|
-
containerRef.current.appendChild(iframe);
|
|
96
94
|
|
|
97
|
-
//
|
|
98
|
-
|
|
95
|
+
// 添加到容器
|
|
96
|
+
try {
|
|
97
|
+
containerRef.current.appendChild(iframe);
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error('[SchemaBuilder] Failed to append iframe:', error);
|
|
100
|
+
if (retryCount < MAX_RETRIES) {
|
|
101
|
+
setRetryCount(function (prev) {
|
|
102
|
+
return prev + 1;
|
|
103
|
+
});
|
|
104
|
+
setTimeout(initIframe, 1000);
|
|
105
|
+
}
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// 设置超时检查
|
|
110
|
+
var timeoutId = setTimeout(function () {
|
|
99
111
|
if (iframe && (!iframe.contentWindow || !iframe.contentDocument)) {
|
|
100
|
-
console.warn('[SchemaBuilder] Iframe load timeout
|
|
101
|
-
|
|
112
|
+
console.warn('[SchemaBuilder] Iframe load timeout');
|
|
113
|
+
if (retryCount < MAX_RETRIES) {
|
|
114
|
+
setRetryCount(function (prev) {
|
|
115
|
+
return prev + 1;
|
|
116
|
+
});
|
|
117
|
+
cleanupIframe();
|
|
118
|
+
initIframe();
|
|
119
|
+
}
|
|
102
120
|
}
|
|
103
121
|
}, 10000);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
console.error('[SchemaBuilder] Max retries reached');
|
|
122
|
+
return function () {
|
|
123
|
+
return clearTimeout(timeoutId);
|
|
124
|
+
};
|
|
125
|
+
}, [cleanupIframe, retryCount]);
|
|
126
|
+
var handleMessage = (0, _react.useCallback)(function (event) {
|
|
127
|
+
if (event.data.type !== 'engine-load') {
|
|
128
|
+
return;
|
|
112
129
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
console.error('[SchemaBuilder] getFormRenderMaterial check failed, retrying...');
|
|
124
|
-
setTimeout(retryIframe, 500);
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// 延迟初始化以确保所有资源就绪
|
|
129
|
-
setTimeout(function () {
|
|
130
|
-
try {
|
|
131
|
-
var _iframe3, _iframe3$contentWindo;
|
|
132
|
-
if ((_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : (_iframe3$contentWindo = _iframe3.contentWindow) === null || _iframe3$contentWindo === void 0 ? void 0 : _iframe3$contentWindo.__FR_ENGINE__) {
|
|
133
|
-
iframe.contentWindow.__FR_ENGINE__.init(_objectSpread({
|
|
134
|
-
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
135
|
-
widgets: widgets,
|
|
136
|
-
logo: {
|
|
137
|
-
title: 'XRender'
|
|
138
|
-
}
|
|
139
|
-
}, restProps));
|
|
140
|
-
console.log('[SchemaBuilder] Engine initialized successfully');
|
|
141
|
-
} else {
|
|
142
|
-
console.error('[SchemaBuilder] __FR_ENGINE__ not found in iframe');
|
|
143
|
-
retryIframe();
|
|
130
|
+
console.log('[SchemaBuilder] Engine loaded');
|
|
131
|
+
setTimeout(function () {
|
|
132
|
+
try {
|
|
133
|
+
var _iframeRef$current3, _iframeRef$current3$c;
|
|
134
|
+
if ((_iframeRef$current3 = iframeRef.current) === null || _iframeRef$current3 === void 0 ? void 0 : (_iframeRef$current3$c = _iframeRef$current3.contentWindow) === null || _iframeRef$current3$c === void 0 ? void 0 : _iframeRef$current3$c.__FR_ENGINE__) {
|
|
135
|
+
iframeRef.current.contentWindow.__FR_ENGINE__.init(_objectSpread({
|
|
136
|
+
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
137
|
+
widgets: widgets,
|
|
138
|
+
logo: {
|
|
139
|
+
title: 'XRender'
|
|
144
140
|
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
141
|
+
}, restProps));
|
|
142
|
+
console.log('[SchemaBuilder] Engine initialized successfully');
|
|
143
|
+
} else {
|
|
144
|
+
console.error('[SchemaBuilder] __FR_ENGINE__ not found in iframe');
|
|
145
|
+
if (retryCount < MAX_RETRIES) {
|
|
146
|
+
setRetryCount(function (prev) {
|
|
147
|
+
return prev + 1;
|
|
148
|
+
});
|
|
149
|
+
cleanupIframe();
|
|
150
|
+
initIframe();
|
|
148
151
|
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
152
|
+
}
|
|
153
|
+
} catch (error) {
|
|
154
|
+
console.error('[SchemaBuilder] Error initializing engine:', error);
|
|
155
|
+
if (retryCount < MAX_RETRIES) {
|
|
156
|
+
setRetryCount(function (prev) {
|
|
157
|
+
return prev + 1;
|
|
158
|
+
});
|
|
159
|
+
cleanupIframe();
|
|
160
|
+
initIframe();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}, 500);
|
|
164
|
+
}, [cleanupIframe, initIframe, retryCount, settings, widgets, restProps]);
|
|
165
|
+
(0, _react.useEffect)(function () {
|
|
166
|
+
initIframe();
|
|
167
|
+
window.addEventListener('message', handleMessage);
|
|
168
|
+
return function () {
|
|
169
|
+
window.removeEventListener('message', handleMessage);
|
|
170
|
+
cleanupIframe();
|
|
171
|
+
};
|
|
172
|
+
}, [initIframe, handleMessage, cleanupIframe]);
|
|
156
173
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, loading && /*#__PURE__*/_react.default.createElement("div", {
|
|
157
174
|
style: {
|
|
158
175
|
position: 'absolute',
|