@zzdadelu/schema-builder 1.0.0-alpha.79 → 1.0.0-alpha.80
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 +32 -47
- package/lib/main.js +31 -46
- package/package.json +1 -1
package/es/main.js
CHANGED
|
@@ -5,9 +5,15 @@ 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; }
|
|
8
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; }
|
|
9
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; }
|
|
10
|
-
import React, { useEffect, useRef, useImperativeHandle, forwardRef } from 'react';
|
|
16
|
+
import React, { useEffect, useRef, useState, useImperativeHandle, forwardRef } from 'react';
|
|
11
17
|
import createIframe from './createIframe';
|
|
12
18
|
import * as defaultSetting from './settings';
|
|
13
19
|
var iframe;
|
|
@@ -16,7 +22,10 @@ var Design = function Design(props, ref) {
|
|
|
16
22
|
settings = props.settings,
|
|
17
23
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
18
24
|
var containerRef = useRef();
|
|
19
|
-
var
|
|
25
|
+
var _useState = useState(false),
|
|
26
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
27
|
+
delayDone = _useState2[0],
|
|
28
|
+
setDelayDone = _useState2[1];
|
|
20
29
|
useImperativeHandle(ref, function () {
|
|
21
30
|
return {
|
|
22
31
|
getValue: function getValue() {
|
|
@@ -34,11 +43,6 @@ var Design = function Design(props, ref) {
|
|
|
34
43
|
window.addEventListener('message', engineOnLoad);
|
|
35
44
|
return function () {
|
|
36
45
|
window.removeEventListener('message', engineOnLoad);
|
|
37
|
-
// 清除轮询定时器
|
|
38
|
-
if (pollingTimerRef.current) {
|
|
39
|
-
clearInterval(pollingTimerRef.current);
|
|
40
|
-
pollingTimerRef.current = null;
|
|
41
|
-
}
|
|
42
46
|
};
|
|
43
47
|
}, []);
|
|
44
48
|
var initIframe = function initIframe() {
|
|
@@ -46,51 +50,32 @@ var Design = function Design(props, ref) {
|
|
|
46
50
|
containerRef.current.appendChild(iframe);
|
|
47
51
|
};
|
|
48
52
|
var engineOnLoad = function engineOnLoad(event) {
|
|
49
|
-
var _iframe3;
|
|
53
|
+
var _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2;
|
|
50
54
|
if (event.data.type !== 'engine-load') {
|
|
51
55
|
return;
|
|
52
56
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// 清除之前的轮询定时器
|
|
60
|
-
if (pollingTimerRef.current) {
|
|
61
|
-
clearInterval(pollingTimerRef.current);
|
|
62
|
-
pollingTimerRef.current = null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// 设置轮询,等待 getFormRenderMaterial 方法被注入
|
|
66
|
-
var pollInterval = 50; // 每50毫秒检查一次
|
|
67
|
-
var timeout = 10000; // 10秒后超时
|
|
68
|
-
var elapsed = 0;
|
|
69
|
-
pollingTimerRef.current = setInterval(function () {
|
|
70
|
-
// 检查 getFormRenderMaterial 是否存在
|
|
71
|
-
if (iframeWindow.getFormRenderMaterial) {
|
|
72
|
-
var _iframeWindow$__FR_EN;
|
|
73
|
-
clearInterval(pollingTimerRef.current);
|
|
74
|
-
pollingTimerRef.current = null;
|
|
75
|
-
// 初始化引擎
|
|
76
|
-
(_iframeWindow$__FR_EN = iframeWindow.__FR_ENGINE__) === null || _iframeWindow$__FR_EN === void 0 ? void 0 : _iframeWindow$__FR_EN.init(_objectSpread({
|
|
77
|
-
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
78
|
-
widgets: widgets,
|
|
79
|
-
// recordEnable: true,
|
|
80
|
-
logo: {
|
|
81
|
-
title: 'XRender'
|
|
82
|
-
}
|
|
83
|
-
}, restProps));
|
|
84
|
-
} else {
|
|
85
|
-
elapsed += pollInterval;
|
|
86
|
-
if (elapsed >= timeout) {
|
|
87
|
-
clearInterval(pollingTimerRef.current);
|
|
88
|
-
pollingTimerRef.current = null;
|
|
89
|
-
console.error('getFormRenderMaterial not found after 10 seconds');
|
|
90
|
-
}
|
|
57
|
+
(_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({
|
|
58
|
+
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
59
|
+
widgets: widgets,
|
|
60
|
+
// recordEnable: true,
|
|
61
|
+
logo: {
|
|
62
|
+
title: 'XRender'
|
|
91
63
|
}
|
|
92
|
-
},
|
|
64
|
+
}, restProps));
|
|
93
65
|
};
|
|
66
|
+
useEffect(function () {
|
|
67
|
+
// 模拟 return 前的延迟
|
|
68
|
+
var timer = setTimeout(function () {
|
|
69
|
+
setDelayDone(true);
|
|
70
|
+
}, 5000); // 延迟 300ms 可自由调整
|
|
71
|
+
|
|
72
|
+
return function () {
|
|
73
|
+
return clearTimeout(timer);
|
|
74
|
+
};
|
|
75
|
+
}, []);
|
|
76
|
+
if (!delayDone) {
|
|
77
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null); // 或 <></>,或 Loading...
|
|
78
|
+
}
|
|
94
79
|
return /*#__PURE__*/React.createElement("div", {
|
|
95
80
|
ref: containerRef,
|
|
96
81
|
style: {
|
package/lib/main.js
CHANGED
|
@@ -16,6 +16,12 @@ 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; }
|
|
19
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; }
|
|
20
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; }
|
|
21
27
|
var iframe;
|
|
@@ -24,7 +30,10 @@ var Design = function Design(props, ref) {
|
|
|
24
30
|
settings = props.settings,
|
|
25
31
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
26
32
|
var containerRef = (0, _react.useRef)();
|
|
27
|
-
var
|
|
33
|
+
var _useState = (0, _react.useState)(false),
|
|
34
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
+
delayDone = _useState2[0],
|
|
36
|
+
setDelayDone = _useState2[1];
|
|
28
37
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
29
38
|
return {
|
|
30
39
|
getValue: function getValue() {
|
|
@@ -42,11 +51,6 @@ var Design = function Design(props, ref) {
|
|
|
42
51
|
window.addEventListener('message', engineOnLoad);
|
|
43
52
|
return function () {
|
|
44
53
|
window.removeEventListener('message', engineOnLoad);
|
|
45
|
-
// 清除轮询定时器
|
|
46
|
-
if (pollingTimerRef.current) {
|
|
47
|
-
clearInterval(pollingTimerRef.current);
|
|
48
|
-
pollingTimerRef.current = null;
|
|
49
|
-
}
|
|
50
54
|
};
|
|
51
55
|
}, []);
|
|
52
56
|
var initIframe = function initIframe() {
|
|
@@ -54,51 +58,32 @@ var Design = function Design(props, ref) {
|
|
|
54
58
|
containerRef.current.appendChild(iframe);
|
|
55
59
|
};
|
|
56
60
|
var engineOnLoad = function engineOnLoad(event) {
|
|
57
|
-
var _iframe3;
|
|
61
|
+
var _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2;
|
|
58
62
|
if (event.data.type !== 'engine-load') {
|
|
59
63
|
return;
|
|
60
64
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// 清除之前的轮询定时器
|
|
68
|
-
if (pollingTimerRef.current) {
|
|
69
|
-
clearInterval(pollingTimerRef.current);
|
|
70
|
-
pollingTimerRef.current = null;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// 设置轮询,等待 getFormRenderMaterial 方法被注入
|
|
74
|
-
var pollInterval = 50; // 每50毫秒检查一次
|
|
75
|
-
var timeout = 10000; // 10秒后超时
|
|
76
|
-
var elapsed = 0;
|
|
77
|
-
pollingTimerRef.current = setInterval(function () {
|
|
78
|
-
// 检查 getFormRenderMaterial 是否存在
|
|
79
|
-
if (iframeWindow.getFormRenderMaterial) {
|
|
80
|
-
var _iframeWindow$__FR_EN;
|
|
81
|
-
clearInterval(pollingTimerRef.current);
|
|
82
|
-
pollingTimerRef.current = null;
|
|
83
|
-
// 初始化引擎
|
|
84
|
-
(_iframeWindow$__FR_EN = iframeWindow.__FR_ENGINE__) === null || _iframeWindow$__FR_EN === void 0 ? void 0 : _iframeWindow$__FR_EN.init(_objectSpread({
|
|
85
|
-
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
86
|
-
widgets: widgets,
|
|
87
|
-
// recordEnable: true,
|
|
88
|
-
logo: {
|
|
89
|
-
title: 'XRender'
|
|
90
|
-
}
|
|
91
|
-
}, restProps));
|
|
92
|
-
} else {
|
|
93
|
-
elapsed += pollInterval;
|
|
94
|
-
if (elapsed >= timeout) {
|
|
95
|
-
clearInterval(pollingTimerRef.current);
|
|
96
|
-
pollingTimerRef.current = null;
|
|
97
|
-
console.error('getFormRenderMaterial not found after 10 seconds');
|
|
98
|
-
}
|
|
65
|
+
(_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({
|
|
66
|
+
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
67
|
+
widgets: widgets,
|
|
68
|
+
// recordEnable: true,
|
|
69
|
+
logo: {
|
|
70
|
+
title: 'XRender'
|
|
99
71
|
}
|
|
100
|
-
},
|
|
72
|
+
}, restProps));
|
|
101
73
|
};
|
|
74
|
+
(0, _react.useEffect)(function () {
|
|
75
|
+
// 模拟 return 前的延迟
|
|
76
|
+
var timer = setTimeout(function () {
|
|
77
|
+
setDelayDone(true);
|
|
78
|
+
}, 5000); // 延迟 300ms 可自由调整
|
|
79
|
+
|
|
80
|
+
return function () {
|
|
81
|
+
return clearTimeout(timer);
|
|
82
|
+
};
|
|
83
|
+
}, []);
|
|
84
|
+
if (!delayDone) {
|
|
85
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null); // 或 <></>,或 Loading...
|
|
86
|
+
}
|
|
102
87
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
103
88
|
ref: containerRef,
|
|
104
89
|
style: {
|