@zzdadelu/schema-builder 1.0.0-alpha.96 → 1.0.0-alpha.98

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.
Files changed (3) hide show
  1. package/es/main.js +22 -43
  2. package/lib/main.js +21 -42
  3. package/package.json +1 -1
package/es/main.js CHANGED
@@ -9,15 +9,9 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
9
9
  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); }
10
10
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
11
11
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
12
- function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
13
- 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."); }
14
- 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; } }
15
- 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; }
16
- 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; } }
17
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
18
12
  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; }
19
13
  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; }
20
- import React, { useEffect, useRef, useState, useImperativeHandle, forwardRef } from 'react';
14
+ import React, { useEffect, useRef, useImperativeHandle, forwardRef } from 'react';
21
15
  import createIframe from './createIframe';
22
16
  import * as defaultSetting from './settings';
23
17
  var iframe;
@@ -26,10 +20,6 @@ var Design = function Design(props, ref) {
26
20
  settings = props.settings,
27
21
  restProps = _objectWithoutProperties(props, _excluded);
28
22
  var containerRef = useRef();
29
- var _useState = useState(false),
30
- _useState2 = _slicedToArray(_useState, 2),
31
- delayDone = _useState2[0],
32
- setDelayDone = _useState2[1];
33
23
  useImperativeHandle(ref, function () {
34
24
  return {
35
25
  getValue: function getValue() {
@@ -53,10 +43,14 @@ var Design = function Design(props, ref) {
53
43
  iframe = createIframe();
54
44
  containerRef.current.appendChild(iframe);
55
45
  };
46
+ var delay = function delay(ms) {
47
+ return new Promise(function (resolve) {
48
+ return setTimeout(resolve, ms);
49
+ });
50
+ };
56
51
  var engineOnLoad = /*#__PURE__*/function () {
57
52
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(event) {
58
- var _iframe3, _iframeWindow$__FR_EN;
59
- var iframeWindow;
53
+ var _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2;
60
54
  return _regenerator().w(function (_context) {
61
55
  while (1) switch (_context.n) {
62
56
  case 0:
@@ -66,25 +60,29 @@ var Design = function Design(props, ref) {
66
60
  }
67
61
  return _context.a(2);
68
62
  case 1:
69
- iframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
70
- if (iframeWindow) {
71
- _context.n = 2;
72
- break;
73
- }
74
- return _context.a(2);
63
+ _context.n = 2;
64
+ return delay(3000);
75
65
  case 2:
76
- console.log('iframe init engine: start waiting...');
77
- console.log('iframeWindow?.AliFormRenderMaterial', iframeWindow === null || iframeWindow === void 0 ? void 0 : iframeWindow.AliFormRenderMaterial);
78
- iframeWindow === null || iframeWindow === void 0 ? void 0 : (_iframeWindow$__FR_EN = iframeWindow.__FR_ENGINE__) === null || _iframeWindow$__FR_EN === void 0 ? void 0 : _iframeWindow$__FR_EN.init(_objectSpread({
66
+ // 设置延迟,例如 2000 毫秒(2 秒)
67
+
68
+ // 初始化引擎
69
+ (_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({
79
70
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
80
71
  widgets: widgets,
81
72
  logo: {
82
73
  title: 'XRender'
83
74
  }
84
75
  }, restProps));
85
- console.log('iframeWindow?.AliFormRenderMaterial', iframeWindow === null || iframeWindow === void 0 ? void 0 : iframeWindow.AliFormRenderMaterial);
86
- console.log('iframe init engine: end init');
76
+ console.log('Engine initialization complete.');
77
+
78
+ // 在初始化后设置等待
79
+ _context.n = 3;
80
+ return delay(3000);
87
81
  case 3:
82
+ // 另一段延迟,例如 1000 毫秒(1 秒)
83
+
84
+ console.log('Post-initialization tasks completed.');
85
+ case 4:
88
86
  return _context.a(2);
89
87
  }
90
88
  }, _callee);
@@ -93,25 +91,6 @@ var Design = function Design(props, ref) {
93
91
  return _ref.apply(this, arguments);
94
92
  };
95
93
  }();
96
- useEffect(function () {
97
- // 模拟 return 前的延迟
98
- var timer = setTimeout(function () {
99
- setDelayDone(true);
100
- }, 5000); // 延迟 300ms 可自由调整
101
-
102
- return function () {
103
- return clearTimeout(timer);
104
- };
105
- }, []);
106
- if (!delayDone) {
107
- return /*#__PURE__*/React.createElement("div", {
108
- ref: containerRef,
109
- style: {
110
- width: '100%',
111
- height: '100%'
112
- }
113
- });
114
- }
115
94
  return /*#__PURE__*/React.createElement("div", {
116
95
  ref: containerRef,
117
96
  style: {
package/lib/main.js CHANGED
@@ -20,12 +20,6 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
20
20
  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); }
21
21
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
22
22
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
23
- function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
24
- 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."); }
25
- 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; } }
26
- 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; }
27
- 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; } }
28
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
29
23
  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; }
30
24
  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; }
31
25
  var iframe;
@@ -34,10 +28,6 @@ var Design = function Design(props, ref) {
34
28
  settings = props.settings,
35
29
  restProps = _objectWithoutProperties(props, _excluded);
36
30
  var containerRef = (0, _react.useRef)();
37
- var _useState = (0, _react.useState)(false),
38
- _useState2 = _slicedToArray(_useState, 2),
39
- delayDone = _useState2[0],
40
- setDelayDone = _useState2[1];
41
31
  (0, _react.useImperativeHandle)(ref, function () {
42
32
  return {
43
33
  getValue: function getValue() {
@@ -61,10 +51,14 @@ var Design = function Design(props, ref) {
61
51
  iframe = (0, _createIframe.default)();
62
52
  containerRef.current.appendChild(iframe);
63
53
  };
54
+ var delay = function delay(ms) {
55
+ return new Promise(function (resolve) {
56
+ return setTimeout(resolve, ms);
57
+ });
58
+ };
64
59
  var engineOnLoad = /*#__PURE__*/function () {
65
60
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(event) {
66
- var _iframe3, _iframeWindow$__FR_EN;
67
- var iframeWindow;
61
+ var _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2;
68
62
  return _regenerator().w(function (_context) {
69
63
  while (1) switch (_context.n) {
70
64
  case 0:
@@ -74,25 +68,29 @@ var Design = function Design(props, ref) {
74
68
  }
75
69
  return _context.a(2);
76
70
  case 1:
77
- iframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
78
- if (iframeWindow) {
79
- _context.n = 2;
80
- break;
81
- }
82
- return _context.a(2);
71
+ _context.n = 2;
72
+ return delay(3000);
83
73
  case 2:
84
- console.log('iframe init engine: start waiting...');
85
- console.log('iframeWindow?.AliFormRenderMaterial', iframeWindow === null || iframeWindow === void 0 ? void 0 : iframeWindow.AliFormRenderMaterial);
86
- iframeWindow === null || iframeWindow === void 0 ? void 0 : (_iframeWindow$__FR_EN = iframeWindow.__FR_ENGINE__) === null || _iframeWindow$__FR_EN === void 0 ? void 0 : _iframeWindow$__FR_EN.init(_objectSpread({
74
+ // 设置延迟,例如 2000 毫秒(2 秒)
75
+
76
+ // 初始化引擎
77
+ (_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({
87
78
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
88
79
  widgets: widgets,
89
80
  logo: {
90
81
  title: 'XRender'
91
82
  }
92
83
  }, restProps));
93
- console.log('iframeWindow?.AliFormRenderMaterial', iframeWindow === null || iframeWindow === void 0 ? void 0 : iframeWindow.AliFormRenderMaterial);
94
- console.log('iframe init engine: end init');
84
+ console.log('Engine initialization complete.');
85
+
86
+ // 在初始化后设置等待
87
+ _context.n = 3;
88
+ return delay(3000);
95
89
  case 3:
90
+ // 另一段延迟,例如 1000 毫秒(1 秒)
91
+
92
+ console.log('Post-initialization tasks completed.');
93
+ case 4:
96
94
  return _context.a(2);
97
95
  }
98
96
  }, _callee);
@@ -101,25 +99,6 @@ var Design = function Design(props, ref) {
101
99
  return _ref.apply(this, arguments);
102
100
  };
103
101
  }();
104
- (0, _react.useEffect)(function () {
105
- // 模拟 return 前的延迟
106
- var timer = setTimeout(function () {
107
- setDelayDone(true);
108
- }, 5000); // 延迟 300ms 可自由调整
109
-
110
- return function () {
111
- return clearTimeout(timer);
112
- };
113
- }, []);
114
- if (!delayDone) {
115
- return /*#__PURE__*/_react.default.createElement("div", {
116
- ref: containerRef,
117
- style: {
118
- width: '100%',
119
- height: '100%'
120
- }
121
- });
122
- }
123
102
  return /*#__PURE__*/_react.default.createElement("div", {
124
103
  ref: containerRef,
125
104
  style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzdadelu/schema-builder",
3
- "version": "1.0.0-alpha.96",
3
+ "version": "1.0.0-alpha.98",
4
4
  "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5
5
  "keywords": [
6
6
  "Form",