@zzdadelu/schema-builder 1.0.0-alpha.54 → 1.0.0-alpha.55
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 +28 -155
- package/lib/main.js +27 -154
- package/package.json +1 -1
package/es/main.js
CHANGED
|
@@ -5,187 +5,60 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
6
6
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
7
7
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
9
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
14
8
|
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
9
|
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
|
|
10
|
+
import React, { useEffect, useRef, useImperativeHandle, forwardRef } from 'react';
|
|
17
11
|
import createIframe from './createIframe';
|
|
18
12
|
import * as defaultSetting from './settings';
|
|
13
|
+
var iframe;
|
|
19
14
|
var Design = function Design(props, ref) {
|
|
20
15
|
var widgets = props.widgets,
|
|
21
16
|
settings = props.settings,
|
|
22
17
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
23
|
-
var containerRef = useRef(
|
|
24
|
-
var iframeRef;
|
|
25
|
-
var _useState = useState(true),
|
|
26
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
27
|
-
loading = _useState2[0],
|
|
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;
|
|
18
|
+
var containerRef = useRef();
|
|
34
19
|
useImperativeHandle(ref, function () {
|
|
35
20
|
return {
|
|
36
21
|
getValue: function getValue() {
|
|
37
|
-
var
|
|
38
|
-
return (
|
|
22
|
+
var _iframe, _iframe$contentWindow, _iframe$contentWindow2, _iframe$contentWindow3;
|
|
23
|
+
return (_iframe = iframe) === null || _iframe === void 0 ? void 0 : (_iframe$contentWindow = _iframe.contentWindow) === null || _iframe$contentWindow === void 0 ? void 0 : (_iframe$contentWindow2 = _iframe$contentWindow.__FR_ENGINE__) === null || _iframe$contentWindow2 === void 0 ? void 0 : (_iframe$contentWindow3 = _iframe$contentWindow2.exportSchema) === null || _iframe$contentWindow3 === void 0 ? void 0 : _iframe$contentWindow3.call(_iframe$contentWindow2);
|
|
39
24
|
},
|
|
40
25
|
setValue: function setValue(schema) {
|
|
41
|
-
var
|
|
42
|
-
return (
|
|
43
|
-
},
|
|
44
|
-
reload: function reload() {
|
|
45
|
-
setRetryCount(0);
|
|
46
|
-
cleanupIframe();
|
|
47
|
-
initIframe();
|
|
26
|
+
var _iframe2, _iframe2$contentWindo, _iframe2$contentWindo2, _iframe2$contentWindo3;
|
|
27
|
+
return (_iframe2 = iframe) === null || _iframe2 === void 0 ? void 0 : (_iframe2$contentWindo = _iframe2.contentWindow) === null || _iframe2$contentWindo === void 0 ? void 0 : (_iframe2$contentWindo2 = _iframe2$contentWindo.__FR_ENGINE__) === null || _iframe2$contentWindo2 === void 0 ? void 0 : (_iframe2$contentWindo3 = _iframe2$contentWindo2.importSchema) === null || _iframe2$contentWindo3 === void 0 ? void 0 : _iframe2$contentWindo3.call(_iframe2$contentWindo2, schema);
|
|
48
28
|
}
|
|
49
29
|
};
|
|
50
30
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
containerRef.current.removeChild(iframeRef.current);
|
|
55
|
-
} catch (e) {
|
|
56
|
-
// 忽略错误
|
|
57
|
-
}
|
|
58
|
-
iframeRef.current = null;
|
|
59
|
-
}
|
|
60
|
-
}, []);
|
|
61
|
-
var initIframe = useCallback(function () {
|
|
62
|
-
console.log('[SchemaBuilder] Initializing iframe, retry:', retryCount);
|
|
63
|
-
|
|
64
|
-
// 清理旧的 iframe
|
|
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;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// 创建新的 iframe
|
|
75
|
-
var iframe = createIframe();
|
|
76
|
-
iframeRef.current = iframe;
|
|
77
|
-
|
|
78
|
-
// 添加错误处理
|
|
79
|
-
iframe.onerror = function (e) {
|
|
80
|
-
console.error('[SchemaBuilder] Iframe error:', e);
|
|
81
|
-
};
|
|
82
|
-
iframe.onload = function () {
|
|
83
|
-
console.log('[SchemaBuilder] Iframe loaded');
|
|
84
|
-
setLoading(false);
|
|
85
|
-
};
|
|
86
|
-
|
|
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 () {
|
|
103
|
-
if (iframe && (!iframe.contentWindow || !iframe.contentDocument)) {
|
|
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
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}, 10000);
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
initIframe();
|
|
33
|
+
window.addEventListener('message', engineOnLoad);
|
|
114
34
|
return function () {
|
|
115
|
-
|
|
35
|
+
window.removeEventListener('message', engineOnLoad);
|
|
116
36
|
};
|
|
117
|
-
}, [
|
|
118
|
-
var
|
|
37
|
+
}, []);
|
|
38
|
+
var initIframe = function initIframe() {
|
|
39
|
+
iframe = createIframe();
|
|
40
|
+
containerRef.current.appendChild(iframe);
|
|
41
|
+
};
|
|
42
|
+
var engineOnLoad = function engineOnLoad(event) {
|
|
43
|
+
var _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2;
|
|
119
44
|
if (event.data.type !== 'engine-load') {
|
|
120
45
|
return;
|
|
121
46
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
129
|
-
widgets: widgets,
|
|
130
|
-
logo: {
|
|
131
|
-
title: 'XRender'
|
|
132
|
-
}
|
|
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();
|
|
143
|
-
}
|
|
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
|
-
}
|
|
47
|
+
(_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : (_iframe3$contentWindo = _iframe3.contentWindow) === null || _iframe3$contentWindo === void 0 ? void 0 : (_iframe3$contentWindo2 = _iframe3$contentWindo.__FR_ENGINE__) === null || _iframe3$contentWindo2 === void 0 ? void 0 : _iframe3$contentWindo2.init(_objectSpread({
|
|
48
|
+
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
49
|
+
widgets: widgets,
|
|
50
|
+
// recordEnable: true,
|
|
51
|
+
logo: {
|
|
52
|
+
title: 'XRender'
|
|
154
53
|
}
|
|
155
|
-
},
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
initIframe();
|
|
159
|
-
window.addEventListener('message', handleMessage);
|
|
160
|
-
return function () {
|
|
161
|
-
window.removeEventListener('message', handleMessage);
|
|
162
|
-
cleanupIframe();
|
|
163
|
-
};
|
|
164
|
-
}, [initIframe, handleMessage, cleanupIframe]);
|
|
165
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, loading && /*#__PURE__*/React.createElement("div", {
|
|
166
|
-
style: {
|
|
167
|
-
position: 'absolute',
|
|
168
|
-
top: 0,
|
|
169
|
-
left: 0,
|
|
170
|
-
right: 0,
|
|
171
|
-
bottom: 0,
|
|
172
|
-
display: 'flex',
|
|
173
|
-
alignItems: 'center',
|
|
174
|
-
justifyContent: 'center',
|
|
175
|
-
backgroundColor: 'rgba(255, 255, 255, 0.8)',
|
|
176
|
-
zIndex: 10
|
|
177
|
-
}
|
|
178
|
-
}, /*#__PURE__*/React.createElement("div", null, "\u52A0\u8F7D\u8868\u5355\u8BBE\u8BA1\u5668...", retryCount > 0 && /*#__PURE__*/React.createElement("div", {
|
|
179
|
-
style: {
|
|
180
|
-
fontSize: '12px',
|
|
181
|
-
color: '#666'
|
|
182
|
-
}
|
|
183
|
-
}, "\u91CD\u8BD5 ", retryCount, "/", MAX_RETRIES))), /*#__PURE__*/React.createElement("div", {
|
|
54
|
+
}, restProps));
|
|
55
|
+
};
|
|
56
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
184
57
|
ref: containerRef,
|
|
185
58
|
style: {
|
|
186
59
|
width: '100%',
|
|
187
60
|
height: '100%'
|
|
188
61
|
}
|
|
189
|
-
})
|
|
62
|
+
});
|
|
190
63
|
};
|
|
191
64
|
export default /*#__PURE__*/forwardRef(Design);
|
package/lib/main.js
CHANGED
|
@@ -16,184 +16,57 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
16
16
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
17
17
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
18
18
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
20
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
21
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
22
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
23
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
24
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
25
19
|
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
20
|
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; }
|
|
21
|
+
var iframe;
|
|
27
22
|
var Design = function Design(props, ref) {
|
|
28
23
|
var widgets = props.widgets,
|
|
29
24
|
settings = props.settings,
|
|
30
25
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
31
|
-
var containerRef = (0, _react.useRef)(
|
|
32
|
-
var iframeRef;
|
|
33
|
-
var _useState = (0, _react.useState)(true),
|
|
34
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
-
loading = _useState2[0],
|
|
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;
|
|
26
|
+
var containerRef = (0, _react.useRef)();
|
|
42
27
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
43
28
|
return {
|
|
44
29
|
getValue: function getValue() {
|
|
45
|
-
var
|
|
46
|
-
return (
|
|
30
|
+
var _iframe, _iframe$contentWindow, _iframe$contentWindow2, _iframe$contentWindow3;
|
|
31
|
+
return (_iframe = iframe) === null || _iframe === void 0 ? void 0 : (_iframe$contentWindow = _iframe.contentWindow) === null || _iframe$contentWindow === void 0 ? void 0 : (_iframe$contentWindow2 = _iframe$contentWindow.__FR_ENGINE__) === null || _iframe$contentWindow2 === void 0 ? void 0 : (_iframe$contentWindow3 = _iframe$contentWindow2.exportSchema) === null || _iframe$contentWindow3 === void 0 ? void 0 : _iframe$contentWindow3.call(_iframe$contentWindow2);
|
|
47
32
|
},
|
|
48
33
|
setValue: function setValue(schema) {
|
|
49
|
-
var
|
|
50
|
-
return (
|
|
51
|
-
},
|
|
52
|
-
reload: function reload() {
|
|
53
|
-
setRetryCount(0);
|
|
54
|
-
cleanupIframe();
|
|
55
|
-
initIframe();
|
|
34
|
+
var _iframe2, _iframe2$contentWindo, _iframe2$contentWindo2, _iframe2$contentWindo3;
|
|
35
|
+
return (_iframe2 = iframe) === null || _iframe2 === void 0 ? void 0 : (_iframe2$contentWindo = _iframe2.contentWindow) === null || _iframe2$contentWindo === void 0 ? void 0 : (_iframe2$contentWindo2 = _iframe2$contentWindo.__FR_ENGINE__) === null || _iframe2$contentWindo2 === void 0 ? void 0 : (_iframe2$contentWindo3 = _iframe2$contentWindo2.importSchema) === null || _iframe2$contentWindo3 === void 0 ? void 0 : _iframe2$contentWindo3.call(_iframe2$contentWindo2, schema);
|
|
56
36
|
}
|
|
57
37
|
};
|
|
58
38
|
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
containerRef.current.removeChild(iframeRef.current);
|
|
63
|
-
} catch (e) {
|
|
64
|
-
// 忽略错误
|
|
65
|
-
}
|
|
66
|
-
iframeRef.current = null;
|
|
67
|
-
}
|
|
68
|
-
}, []);
|
|
69
|
-
var initIframe = (0, _react.useCallback)(function () {
|
|
70
|
-
console.log('[SchemaBuilder] Initializing iframe, retry:', retryCount);
|
|
71
|
-
|
|
72
|
-
// 清理旧的 iframe
|
|
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;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// 创建新的 iframe
|
|
83
|
-
var iframe = (0, _createIframe.default)();
|
|
84
|
-
iframeRef.current = iframe;
|
|
85
|
-
|
|
86
|
-
// 添加错误处理
|
|
87
|
-
iframe.onerror = function (e) {
|
|
88
|
-
console.error('[SchemaBuilder] Iframe error:', e);
|
|
89
|
-
};
|
|
90
|
-
iframe.onload = function () {
|
|
91
|
-
console.log('[SchemaBuilder] Iframe loaded');
|
|
92
|
-
setLoading(false);
|
|
93
|
-
};
|
|
94
|
-
|
|
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 () {
|
|
111
|
-
if (iframe && (!iframe.contentWindow || !iframe.contentDocument)) {
|
|
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
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}, 10000);
|
|
39
|
+
(0, _react.useEffect)(function () {
|
|
40
|
+
initIframe();
|
|
41
|
+
window.addEventListener('message', engineOnLoad);
|
|
122
42
|
return function () {
|
|
123
|
-
|
|
43
|
+
window.removeEventListener('message', engineOnLoad);
|
|
124
44
|
};
|
|
125
|
-
}, [
|
|
126
|
-
var
|
|
45
|
+
}, []);
|
|
46
|
+
var initIframe = function initIframe() {
|
|
47
|
+
iframe = (0, _createIframe.default)();
|
|
48
|
+
containerRef.current.appendChild(iframe);
|
|
49
|
+
};
|
|
50
|
+
var engineOnLoad = function engineOnLoad(event) {
|
|
51
|
+
var _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2;
|
|
127
52
|
if (event.data.type !== 'engine-load') {
|
|
128
53
|
return;
|
|
129
54
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
137
|
-
widgets: widgets,
|
|
138
|
-
logo: {
|
|
139
|
-
title: 'XRender'
|
|
140
|
-
}
|
|
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();
|
|
151
|
-
}
|
|
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
|
-
}
|
|
55
|
+
(_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : (_iframe3$contentWindo = _iframe3.contentWindow) === null || _iframe3$contentWindo === void 0 ? void 0 : (_iframe3$contentWindo2 = _iframe3$contentWindo.__FR_ENGINE__) === null || _iframe3$contentWindo2 === void 0 ? void 0 : _iframe3$contentWindo2.init(_objectSpread({
|
|
56
|
+
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
57
|
+
widgets: widgets,
|
|
58
|
+
// recordEnable: true,
|
|
59
|
+
logo: {
|
|
60
|
+
title: 'XRender'
|
|
162
61
|
}
|
|
163
|
-
},
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
initIframe();
|
|
167
|
-
window.addEventListener('message', handleMessage);
|
|
168
|
-
return function () {
|
|
169
|
-
window.removeEventListener('message', handleMessage);
|
|
170
|
-
cleanupIframe();
|
|
171
|
-
};
|
|
172
|
-
}, [initIframe, handleMessage, cleanupIframe]);
|
|
173
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, loading && /*#__PURE__*/_react.default.createElement("div", {
|
|
174
|
-
style: {
|
|
175
|
-
position: 'absolute',
|
|
176
|
-
top: 0,
|
|
177
|
-
left: 0,
|
|
178
|
-
right: 0,
|
|
179
|
-
bottom: 0,
|
|
180
|
-
display: 'flex',
|
|
181
|
-
alignItems: 'center',
|
|
182
|
-
justifyContent: 'center',
|
|
183
|
-
backgroundColor: 'rgba(255, 255, 255, 0.8)',
|
|
184
|
-
zIndex: 10
|
|
185
|
-
}
|
|
186
|
-
}, /*#__PURE__*/_react.default.createElement("div", null, "\u52A0\u8F7D\u8868\u5355\u8BBE\u8BA1\u5668...", retryCount > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
187
|
-
style: {
|
|
188
|
-
fontSize: '12px',
|
|
189
|
-
color: '#666'
|
|
190
|
-
}
|
|
191
|
-
}, "\u91CD\u8BD5 ", retryCount, "/", MAX_RETRIES))), /*#__PURE__*/_react.default.createElement("div", {
|
|
62
|
+
}, restProps));
|
|
63
|
+
};
|
|
64
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
192
65
|
ref: containerRef,
|
|
193
66
|
style: {
|
|
194
67
|
width: '100%',
|
|
195
68
|
height: '100%'
|
|
196
69
|
}
|
|
197
|
-
})
|
|
70
|
+
});
|
|
198
71
|
};
|
|
199
72
|
var _default = exports.default = /*#__PURE__*/(0, _react.forwardRef)(Design);
|