@zzdadelu/schema-builder 1.0.0-alpha.112 → 1.0.0-alpha.116

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 +31 -23
  2. package/lib/main.js +31 -23
  3. package/package.json +1 -1
package/es/main.js CHANGED
@@ -1,10 +1,10 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
1
2
  var _excluded = ["widgets", "settings"];
2
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
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; }
5
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
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); }
7
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
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
10
  import React, { useEffect, useRef, useImperativeHandle, forwardRef } from 'react';
@@ -40,33 +40,41 @@ var Design = function Design(props, ref) {
40
40
  containerRef.current.appendChild(iframe);
41
41
  };
42
42
  var engineOnLoad = function engineOnLoad(event) {
43
- var _iframe3;
43
+ var _iframe3, _outerIframeWindow$__;
44
44
  if (event.data.type !== 'engine-load') {
45
45
  return;
46
46
  }
47
+ var outerIframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
48
+ if (!outerIframeWindow) return;
47
49
 
48
- // --- 解决方案开始 ---
49
- var iframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
50
- var iframeDoc = iframeWindow === null || iframeWindow === void 0 ? void 0 : iframeWindow.document;
51
- if (!iframeWindow || !iframeDoc) {
52
- console.error('Iframe 窗口或文档引用丢失。');
53
- return;
54
- }
55
- console.error('Iframe typeof iframeWindow.getFormRenderMaterial 1', _typeof(iframeWindow.getFormRenderMaterial));
56
- setTimeout(function () {
57
- var _iframe4, _iframe4$contentWindo, _iframe4$contentWindo2;
58
- console.log('延迟结束,开始调用 __FR_ENGINE__?.init');
59
- (_iframe4 = iframe) === null || _iframe4 === void 0 ? void 0 : (_iframe4$contentWindo = _iframe4.contentWindow) === null || _iframe4$contentWindo === void 0 ? void 0 : (_iframe4$contentWindo2 = _iframe4$contentWindo.__FR_ENGINE__) === null || _iframe4$contentWindo2 === void 0 ? void 0 : _iframe4$contentWindo2.init(_objectSpread({
60
- settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
61
- widgets: widgets,
62
- // recordEnable: true,
63
- logo: {
64
- title: 'XRender'
65
- }
66
- }, restProps));
67
- }, 10000); // 200ms 是一个足够安全的时间
50
+ // 尝试监听外层 iframe 内部文档的变化
51
+ var innerDoc = outerIframeWindow.document;
52
+ if (!innerDoc) return;
68
53
 
69
- console.error('Iframe typeof iframeWindow.getFormRenderMaterial 2', _typeof(iframeWindow.getFormRenderMaterial));
54
+ // 创建一个 MutationObserver 来监听外层 iframe 内部 iframe 的创建
55
+ var innerObserver = new MutationObserver(function (mutations) {
56
+ console.log('检测到内层 iframe 被添加......');
57
+ mutations.forEach(function (mutation) {
58
+ mutation.addedNodes.forEach(function (node) {
59
+ console.log('检测到内层 iframe 被添加', node);
60
+ });
61
+ });
62
+ });
63
+
64
+ // 开始观察外层 iframe 内部 body 的变化
65
+ innerObserver.observe(innerDoc.body, {
66
+ childList: true,
67
+ subtree: true
68
+ });
69
+
70
+ // 初始化 __FR_ENGINE__
71
+ (_outerIframeWindow$__ = outerIframeWindow.__FR_ENGINE__) === null || _outerIframeWindow$__ === void 0 ? void 0 : _outerIframeWindow$__.init(_objectSpread({
72
+ settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
73
+ widgets: widgets,
74
+ logo: {
75
+ title: 'XRender'
76
+ }
77
+ }, restProps));
70
78
  };
71
79
  return /*#__PURE__*/React.createElement("div", {
72
80
  ref: containerRef,
package/lib/main.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -15,7 +16,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
15
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; }
16
17
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
17
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); }
18
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
19
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; }
20
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
21
  var iframe;
@@ -48,33 +48,41 @@ var Design = function Design(props, ref) {
48
48
  containerRef.current.appendChild(iframe);
49
49
  };
50
50
  var engineOnLoad = function engineOnLoad(event) {
51
- var _iframe3;
51
+ var _iframe3, _outerIframeWindow$__;
52
52
  if (event.data.type !== 'engine-load') {
53
53
  return;
54
54
  }
55
+ var outerIframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
56
+ if (!outerIframeWindow) return;
55
57
 
56
- // --- 解决方案开始 ---
57
- var iframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
58
- var iframeDoc = iframeWindow === null || iframeWindow === void 0 ? void 0 : iframeWindow.document;
59
- if (!iframeWindow || !iframeDoc) {
60
- console.error('Iframe 窗口或文档引用丢失。');
61
- return;
62
- }
63
- console.error('Iframe typeof iframeWindow.getFormRenderMaterial 1', _typeof(iframeWindow.getFormRenderMaterial));
64
- setTimeout(function () {
65
- var _iframe4, _iframe4$contentWindo, _iframe4$contentWindo2;
66
- console.log('延迟结束,开始调用 __FR_ENGINE__?.init');
67
- (_iframe4 = iframe) === null || _iframe4 === void 0 ? void 0 : (_iframe4$contentWindo = _iframe4.contentWindow) === null || _iframe4$contentWindo === void 0 ? void 0 : (_iframe4$contentWindo2 = _iframe4$contentWindo.__FR_ENGINE__) === null || _iframe4$contentWindo2 === void 0 ? void 0 : _iframe4$contentWindo2.init(_objectSpread({
68
- settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
69
- widgets: widgets,
70
- // recordEnable: true,
71
- logo: {
72
- title: 'XRender'
73
- }
74
- }, restProps));
75
- }, 10000); // 200ms 是一个足够安全的时间
58
+ // 尝试监听外层 iframe 内部文档的变化
59
+ var innerDoc = outerIframeWindow.document;
60
+ if (!innerDoc) return;
76
61
 
77
- console.error('Iframe typeof iframeWindow.getFormRenderMaterial 2', _typeof(iframeWindow.getFormRenderMaterial));
62
+ // 创建一个 MutationObserver 来监听外层 iframe 内部 iframe 的创建
63
+ var innerObserver = new MutationObserver(function (mutations) {
64
+ console.log('检测到内层 iframe 被添加......');
65
+ mutations.forEach(function (mutation) {
66
+ mutation.addedNodes.forEach(function (node) {
67
+ console.log('检测到内层 iframe 被添加', node);
68
+ });
69
+ });
70
+ });
71
+
72
+ // 开始观察外层 iframe 内部 body 的变化
73
+ innerObserver.observe(innerDoc.body, {
74
+ childList: true,
75
+ subtree: true
76
+ });
77
+
78
+ // 初始化 __FR_ENGINE__
79
+ (_outerIframeWindow$__ = outerIframeWindow.__FR_ENGINE__) === null || _outerIframeWindow$__ === void 0 ? void 0 : _outerIframeWindow$__.init(_objectSpread({
80
+ settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
81
+ widgets: widgets,
82
+ logo: {
83
+ title: 'XRender'
84
+ }
85
+ }, restProps));
78
86
  };
79
87
  return /*#__PURE__*/_react.default.createElement("div", {
80
88
  ref: containerRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzdadelu/schema-builder",
3
- "version": "1.0.0-alpha.112",
3
+ "version": "1.0.0-alpha.116",
4
4
  "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5
5
  "keywords": [
6
6
  "Form",