@zzdadelu/schema-builder 1.0.0-alpha.17 → 1.0.0-alpha.18
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 +12 -16
- package/lib/main.js +11 -15
- package/package.json +1 -1
package/es/main.js
CHANGED
|
@@ -7,7 +7,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
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
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; }
|
|
9
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; }
|
|
10
|
-
import React, { useEffect, useRef, useImperativeHandle, forwardRef } from 'react';
|
|
10
|
+
import React, { useEffect, useRef, useImperativeHandle, forwardRef, useCallback } from 'react';
|
|
11
11
|
import createIframe from './createIframe';
|
|
12
12
|
import * as defaultSetting from './settings';
|
|
13
13
|
var iframe;
|
|
@@ -30,33 +30,29 @@ var Design = function Design(props, ref) {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
});
|
|
33
|
-
useEffect(function () {
|
|
34
|
-
window.addEventListener('message', engineOnLoad);
|
|
35
|
-
initIframe();
|
|
36
|
-
return function () {
|
|
37
|
-
window.removeEventListener('message', engineOnLoad);
|
|
38
|
-
};
|
|
39
|
-
}, []);
|
|
40
33
|
var initIframe = function initIframe() {
|
|
41
34
|
console.log("开始创建 iframe");
|
|
42
35
|
iframe = createIframe();
|
|
43
36
|
containerRef.current.appendChild(iframe);
|
|
44
37
|
};
|
|
45
|
-
var engineOnLoad = function
|
|
46
|
-
var _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
|
|
47
|
-
if (event.data.type !== 'engine-load')
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
console.log("拿到 iframe props:", event);
|
|
38
|
+
var engineOnLoad = useCallback(function (event) {
|
|
39
|
+
var _event$data, _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
|
|
40
|
+
if (((_event$data = event.data) === null || _event$data === void 0 ? void 0 : _event$data.type) !== 'engine-load') return;
|
|
51
41
|
(_iframe5 = iframe) === null || _iframe5 === void 0 ? void 0 : (_iframe5$contentWindo = _iframe5.contentWindow) === null || _iframe5$contentWindo === void 0 ? void 0 : (_iframe5$contentWindo2 = _iframe5$contentWindo.__FR_ENGINE__) === null || _iframe5$contentWindo2 === void 0 ? void 0 : _iframe5$contentWindo2.init(_objectSpread({
|
|
52
42
|
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
53
43
|
widgets: widgets,
|
|
54
|
-
// recordEnable: true,
|
|
55
44
|
logo: {
|
|
56
45
|
title: 'XRender'
|
|
57
46
|
}
|
|
58
47
|
}, restProps));
|
|
59
|
-
};
|
|
48
|
+
}, [settings, widgets, restProps]);
|
|
49
|
+
useEffect(function () {
|
|
50
|
+
window.addEventListener('message', engineOnLoad);
|
|
51
|
+
initIframe();
|
|
52
|
+
return function () {
|
|
53
|
+
window.removeEventListener('message', engineOnLoad);
|
|
54
|
+
};
|
|
55
|
+
}, [engineOnLoad]);
|
|
60
56
|
return /*#__PURE__*/React.createElement("div", {
|
|
61
57
|
ref: containerRef,
|
|
62
58
|
style: {
|
package/lib/main.js
CHANGED
|
@@ -38,33 +38,29 @@ var Design = function Design(props, ref) {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
});
|
|
41
|
-
(0, _react.useEffect)(function () {
|
|
42
|
-
window.addEventListener('message', engineOnLoad);
|
|
43
|
-
initIframe();
|
|
44
|
-
return function () {
|
|
45
|
-
window.removeEventListener('message', engineOnLoad);
|
|
46
|
-
};
|
|
47
|
-
}, []);
|
|
48
41
|
var initIframe = function initIframe() {
|
|
49
42
|
console.log("开始创建 iframe");
|
|
50
43
|
iframe = (0, _createIframe.default)();
|
|
51
44
|
containerRef.current.appendChild(iframe);
|
|
52
45
|
};
|
|
53
|
-
var engineOnLoad = function
|
|
54
|
-
var _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
|
|
55
|
-
if (event.data.type !== 'engine-load')
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
console.log("拿到 iframe props:", event);
|
|
46
|
+
var engineOnLoad = (0, _react.useCallback)(function (event) {
|
|
47
|
+
var _event$data, _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
|
|
48
|
+
if (((_event$data = event.data) === null || _event$data === void 0 ? void 0 : _event$data.type) !== 'engine-load') return;
|
|
59
49
|
(_iframe5 = iframe) === null || _iframe5 === void 0 ? void 0 : (_iframe5$contentWindo = _iframe5.contentWindow) === null || _iframe5$contentWindo === void 0 ? void 0 : (_iframe5$contentWindo2 = _iframe5$contentWindo.__FR_ENGINE__) === null || _iframe5$contentWindo2 === void 0 ? void 0 : _iframe5$contentWindo2.init(_objectSpread({
|
|
60
50
|
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
61
51
|
widgets: widgets,
|
|
62
|
-
// recordEnable: true,
|
|
63
52
|
logo: {
|
|
64
53
|
title: 'XRender'
|
|
65
54
|
}
|
|
66
55
|
}, restProps));
|
|
67
|
-
};
|
|
56
|
+
}, [settings, widgets, restProps]);
|
|
57
|
+
(0, _react.useEffect)(function () {
|
|
58
|
+
window.addEventListener('message', engineOnLoad);
|
|
59
|
+
initIframe();
|
|
60
|
+
return function () {
|
|
61
|
+
window.removeEventListener('message', engineOnLoad);
|
|
62
|
+
};
|
|
63
|
+
}, [engineOnLoad]);
|
|
68
64
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
69
65
|
ref: containerRef,
|
|
70
66
|
style: {
|