@zzdadelu/schema-builder 1.0.0-alpha.71 → 1.0.0-alpha.73

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.
@@ -1,5 +1,5 @@
1
- var createIframeContent = function createIframeContent() {
2
- var html = "\n <html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\" />\n <title>XRender</title>\n <link rel=\"icon\" href=\"https://img.alicdn.com/tfs/TB17UtINiLaK1RjSZFxXXamPFXa-606-643.png\">\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/variables.css\" rel=\"stylesheet\" />\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/dist/next.var.min.css\" rel=\"stylesheet\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/css/engine-core.css\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/css/engine-ext.css\" />\n <link rel=\"stylesheet\" href=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/css/index.css\" />\n\n <script>\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n </script>\n \n <script src=\"https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/react15-polyfill/0.0.1/dist/index.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js\"></script>\n <script src=\"https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js\"></script>\n <script src=\"https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/js/engine-core.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/js/engine-ext.js\"></script>\n </head>\n\n <body>\n <div id=\"lce-container\"></div>\n <script type=\"text/javascript\" src=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js\"></script>\n </body>\n </html>\n ";
1
+ var createIframeContent = function createIframeContent(timestamp) {
2
+ var html = "\n <html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\" />\n <title>XRender</title>\n <link rel=\"icon\" href=\"https://img.alicdn.com/tfs/TB17UtINiLaK1RjSZFxXXamPFXa-606-643.png\">\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/variables.css\" rel=\"stylesheet\" />\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/dist/next.var.min.css\" rel=\"stylesheet\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/css/engine-core.css\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/css/engine-ext.css\" />\n <link rel=\"stylesheet\" href=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/css/index.css\" />\n\n <!-- Shim: \u5728\u5916\u5C42 iframe \u5185\u63D0\u4F9B\u4E00\u4E2A\u4E34\u65F6\u5B89\u5168\u5B9E\u73B0\uFF0C\u907F\u514D\u7B2C\u4E09\u65B9\u5185\u8054\u811A\u672C\u7ACB\u5373\u62A5\u9519 -->\n <script>\n (function() {\n try {\n if (typeof window.getFormRenderMaterial !== 'function') {\n var __fr_q = [];\n var __fr_shim = function() {\n __fr_q.push({ args: Array.prototype.slice.call(arguments) });\n return { __esModule: true };\n };\n window.getFormRenderMaterial = __fr_shim;\n var __fr_iv = setInterval(function() {\n try {\n if (typeof window.getFormRenderMaterial === 'function' && window.getFormRenderMaterial !== __fr_shim) {\n var __real = window.getFormRenderMaterial;\n clearInterval(__fr_iv);\n setTimeout(function() {\n try {\n __fr_q.forEach(function(item) {\n try { __real.apply(null, item.args); } catch (e) {}\n });\n } catch (e) {}\n __fr_q = null;\n }, 0);\n }\n } catch (e) {}\n }, 50);\n }\n } catch (e) {}\n })();\n </script>\n\n <!-- Observer: \u76D1\u63A7\u672C iframe \u6587\u6863\u4E2D\u65B0\u589E\u7684\u5B50 iframe\uFF08\u7B2C\u4E09\u65B9 create-simulator \u53EF\u80FD\u521B\u5EFA\u7684\u5D4C\u5957 iframe\uFF09\u5E76\u5C3D\u5FEB\u4FEE\u8865 -->\n <script>\n (function() {\n var ts = ".concat(timestamp, ";\n function tryPatchChildIframe(iframeEl) {\n try {\n // \u82E5 contentWindow \u53EF\u7528\uFF0C\u7ACB\u5373\u5728\u5B50 iframe \u7684 window \u4E0A\u653E\u4E2A\u5B89\u5168\u5360\u4F4D\u51FD\u6570\n var cw = iframeEl.contentWindow;\n if (cw) {\n if (typeof cw.getFormRenderMaterial !== 'function') {\n try {\n cw.getFormRenderMaterial = function() {\n return { __esModule: true };\n };\n } catch (e) {}\n }\n }\n } catch (e) {}\n }\n\n // \u5F53\u5B50 iframe \u52A0\u8F7D\u5B8C\u6210\u540E\uFF0C\u5C1D\u8BD5\u4FEE\u8865\u5176\u5185\u90E8 script \u7684 src\uFF0C\u52A0\u65F6\u95F4\u6233\u4EE5\u907F\u514D\u7F13\u5B58\u5BFC\u81F4\u65E7\u7248\u95EE\u9898\uFF1B\u5E76\u786E\u4FDD child window \u6709 getFormRenderMaterial\n function onChildFrameLoad(iframeEl) {\n try {\n var doc = iframeEl.contentDocument || iframeEl.contentWindow && iframeEl.contentWindow.document;\n if (!doc) return;\n // \u4FEE\u8865\u53EF\u80FD\u7684\u5916\u90E8\u811A\u672C url\uFF08\u793A\u4F8B\uFF1Afr-generator / react-simulator-renderer \u7B49\uFF09\n var scripts = Array.prototype.slice.call(doc.getElementsByTagName('script'));\n scripts.forEach(function(s) {\n if (s.src && /fr-generator\\/.*index\\.js|react-simulator-renderer\\.js/.test(s.src)) {\n if (s.src.indexOf('?t=') === -1) {\n try {\n s.src = s.src + (s.src.indexOf('?') === -1 ? '?t=' + ts : '&t=' + ts);\n } catch (e) {}\n }\n }\n });\n // \u6700\u7EC8\u786E\u4FDD child window \u6709 getFormRenderMaterial\n try {\n var cw = iframeEl.contentWindow;\n if (cw && typeof cw.getFormRenderMaterial !== 'function') {\n cw.getFormRenderMaterial = function() { return { __esModule: true }; };\n }\n } catch (e) {}\n } catch (e) {}\n }\n\n var mo = new MutationObserver(function(muts) {\n muts.forEach(function(mut) {\n Array.prototype.forEach.call(mut.addedNodes || [], function(node) {\n try {\n if (node && node.tagName === 'IFRAME') {\n tryPatchChildIframe(node);\n // attach load to do more thorough patch after content is written\n node.addEventListener && node.addEventListener('load', function() {\n onChildFrameLoad(node);\n }, { once: true });\n }\n } catch (e) {}\n });\n });\n });\n\n try {\n mo.observe(document.documentElement || document.body, { childList: true, subtree: true });\n // \u5DF2\u5B58\u5728\u7684 iframe \u7ACB\u5373\u5C1D\u8BD5\u4FEE\u8865\n Array.prototype.forEach.call(document.getElementsByTagName('iframe'), function(f) {\n tryPatchChildIframe(f);\n f.addEventListener && f.addEventListener('load', function() { onChildFrameLoad(f); }, { once: true });\n });\n } catch (e) {}\n })();\n </script>\n\n <script>\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n </script>\n\n <script src=\"https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/react15-polyfill/0.0.1/dist/index.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js\"></script>\n <script src=\"https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js\"></script>\n <script src=\"https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/js/engine-core.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/js/engine-ext.js\"></script>\n </head>\n\n <body>\n <div id=\"lce-container\"></div>\n <!-- \u7ED9 fr-generator \u52A0\u65F6\u95F4\u6233\uFF0C\u5E2E\u52A9\u89C4\u907F\u7F13\u5B58\u5BFC\u81F4\u7684\u65E7\u7248/\u65F6\u5E8F\u95EE\u9898 -->\n <script type=\"text/javascript\" src=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js?t=").concat(timestamp, "\"></script>\n </body>\n </html>\n ");
3
3
  return html;
4
4
  };
5
5
  export default (function () {
@@ -7,6 +7,7 @@ export default (function () {
7
7
  iframe.width = '100%';
8
8
  iframe.height = '100%';
9
9
  iframe.frameBorder = '0';
10
- iframe.srcdoc = createIframeContent();
10
+ var ts = Date.now();
11
+ iframe.srcdoc = createIframeContent(ts);
11
12
  return iframe;
12
13
  });
package/es/main.js CHANGED
@@ -8,11 +8,9 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
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';
11
- import * as defaultSetting from './settings';
12
11
  import createIframe from './createIframe';
12
+ import * as defaultSetting from './settings';
13
13
  var iframe;
14
-
15
- // 修改 main.ts,在父窗口中直接注入 getFormRenderMaterial
16
14
  var Design = function Design(props, ref) {
17
15
  var widgets = props.widgets,
18
16
  settings = props.settings,
@@ -31,77 +29,25 @@ var Design = function Design(props, ref) {
31
29
  };
32
30
  });
33
31
  useEffect(function () {
34
- initIframe();
35
32
  window.addEventListener('message', engineOnLoad);
36
-
37
- // 添加一个定时器,确保 getFormRenderMaterial 被正确注入
38
- var checkInterval = setInterval(function () {
39
- var _iframe3;
40
- if (((_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow) && !iframe.contentWindow.getFormRenderMaterial) {
41
- console.log('Manually injecting getFormRenderMaterial from parent');
42
- iframe.contentWindow.getFormRenderMaterial = function () {
43
- return Object.assign({
44
- __esModule: true
45
- }, widgets || {});
46
- };
47
- }
48
- }, 100);
33
+ initIframe();
49
34
  return function () {
50
35
  window.removeEventListener('message', engineOnLoad);
51
- clearInterval(checkInterval);
52
36
  };
53
37
  }, []);
54
38
  var initIframe = function initIframe() {
55
39
  iframe = createIframe();
56
40
  containerRef.current.appendChild(iframe);
57
-
58
- // 监听 iframe 的 load 事件
59
- iframe.onload = function () {
60
- console.log('iframe loaded, injecting getFormRenderMaterial');
61
-
62
- // 立即尝试注入 getFormRenderMaterial
63
- if (iframe.contentWindow) {
64
- // 方法1:直接注入
65
- iframe.contentWindow.getFormRenderMaterial = function () {
66
- console.log('Parent-injected getFormRenderMaterial called');
67
- return Object.assign({
68
- __esModule: true
69
- }, widgets || {});
70
- };
71
-
72
- // 方法2:模拟 polling 机制
73
- setTimeout(function () {
74
- if (iframe.contentWindow && !iframe.contentWindow.getFormRenderMaterial) {
75
- console.log('Fallback injection after timeout');
76
- iframe.contentWindow.getFormRenderMaterial = function () {
77
- return Object.assign({
78
- __esModule: true
79
- }, widgets || {});
80
- };
81
- }
82
- }, 500);
83
- }
84
- };
85
41
  };
86
42
  var engineOnLoad = function engineOnLoad(event) {
87
- var _iframe4, _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
43
+ var _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2;
88
44
  if (event.data.type !== 'engine-load') {
89
45
  return;
90
46
  }
91
-
92
- // 在初始化前再次确保 getFormRenderMaterial 存在
93
- var iframeWin = (_iframe4 = iframe) === null || _iframe4 === void 0 ? void 0 : _iframe4.contentWindow;
94
- if (iframeWin && !iframeWin.getFormRenderMaterial) {
95
- console.warn('getFormRenderMaterial missing before init, injecting');
96
- iframeWin.getFormRenderMaterial = function () {
97
- return Object.assign({
98
- __esModule: true
99
- }, widgets || {});
100
- };
101
- }
102
- (_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({
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({
103
48
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
104
49
  widgets: widgets,
50
+ // recordEnable: true,
105
51
  logo: {
106
52
  title: 'XRender'
107
53
  }
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var createIframeContent = function createIframeContent() {
8
- var html = "\n <html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\" />\n <title>XRender</title>\n <link rel=\"icon\" href=\"https://img.alicdn.com/tfs/TB17UtINiLaK1RjSZFxXXamPFXa-606-643.png\">\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/variables.css\" rel=\"stylesheet\" />\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/dist/next.var.min.css\" rel=\"stylesheet\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/css/engine-core.css\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/css/engine-ext.css\" />\n <link rel=\"stylesheet\" href=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/css/index.css\" />\n\n <script>\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n </script>\n \n <script src=\"https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/react15-polyfill/0.0.1/dist/index.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js\"></script>\n <script src=\"https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js\"></script>\n <script src=\"https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/js/engine-core.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/js/engine-ext.js\"></script>\n </head>\n\n <body>\n <div id=\"lce-container\"></div>\n <script type=\"text/javascript\" src=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js\"></script>\n </body>\n </html>\n ";
7
+ var createIframeContent = function createIframeContent(timestamp) {
8
+ var html = "\n <html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\" />\n <title>XRender</title>\n <link rel=\"icon\" href=\"https://img.alicdn.com/tfs/TB17UtINiLaK1RjSZFxXXamPFXa-606-643.png\">\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/variables.css\" rel=\"stylesheet\" />\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/dist/next.var.min.css\" rel=\"stylesheet\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/css/engine-core.css\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/css/engine-ext.css\" />\n <link rel=\"stylesheet\" href=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/css/index.css\" />\n\n <!-- Shim: \u5728\u5916\u5C42 iframe \u5185\u63D0\u4F9B\u4E00\u4E2A\u4E34\u65F6\u5B89\u5168\u5B9E\u73B0\uFF0C\u907F\u514D\u7B2C\u4E09\u65B9\u5185\u8054\u811A\u672C\u7ACB\u5373\u62A5\u9519 -->\n <script>\n (function() {\n try {\n if (typeof window.getFormRenderMaterial !== 'function') {\n var __fr_q = [];\n var __fr_shim = function() {\n __fr_q.push({ args: Array.prototype.slice.call(arguments) });\n return { __esModule: true };\n };\n window.getFormRenderMaterial = __fr_shim;\n var __fr_iv = setInterval(function() {\n try {\n if (typeof window.getFormRenderMaterial === 'function' && window.getFormRenderMaterial !== __fr_shim) {\n var __real = window.getFormRenderMaterial;\n clearInterval(__fr_iv);\n setTimeout(function() {\n try {\n __fr_q.forEach(function(item) {\n try { __real.apply(null, item.args); } catch (e) {}\n });\n } catch (e) {}\n __fr_q = null;\n }, 0);\n }\n } catch (e) {}\n }, 50);\n }\n } catch (e) {}\n })();\n </script>\n\n <!-- Observer: \u76D1\u63A7\u672C iframe \u6587\u6863\u4E2D\u65B0\u589E\u7684\u5B50 iframe\uFF08\u7B2C\u4E09\u65B9 create-simulator \u53EF\u80FD\u521B\u5EFA\u7684\u5D4C\u5957 iframe\uFF09\u5E76\u5C3D\u5FEB\u4FEE\u8865 -->\n <script>\n (function() {\n var ts = ".concat(timestamp, ";\n function tryPatchChildIframe(iframeEl) {\n try {\n // \u82E5 contentWindow \u53EF\u7528\uFF0C\u7ACB\u5373\u5728\u5B50 iframe \u7684 window \u4E0A\u653E\u4E2A\u5B89\u5168\u5360\u4F4D\u51FD\u6570\n var cw = iframeEl.contentWindow;\n if (cw) {\n if (typeof cw.getFormRenderMaterial !== 'function') {\n try {\n cw.getFormRenderMaterial = function() {\n return { __esModule: true };\n };\n } catch (e) {}\n }\n }\n } catch (e) {}\n }\n\n // \u5F53\u5B50 iframe \u52A0\u8F7D\u5B8C\u6210\u540E\uFF0C\u5C1D\u8BD5\u4FEE\u8865\u5176\u5185\u90E8 script \u7684 src\uFF0C\u52A0\u65F6\u95F4\u6233\u4EE5\u907F\u514D\u7F13\u5B58\u5BFC\u81F4\u65E7\u7248\u95EE\u9898\uFF1B\u5E76\u786E\u4FDD child window \u6709 getFormRenderMaterial\n function onChildFrameLoad(iframeEl) {\n try {\n var doc = iframeEl.contentDocument || iframeEl.contentWindow && iframeEl.contentWindow.document;\n if (!doc) return;\n // \u4FEE\u8865\u53EF\u80FD\u7684\u5916\u90E8\u811A\u672C url\uFF08\u793A\u4F8B\uFF1Afr-generator / react-simulator-renderer \u7B49\uFF09\n var scripts = Array.prototype.slice.call(doc.getElementsByTagName('script'));\n scripts.forEach(function(s) {\n if (s.src && /fr-generator\\/.*index\\.js|react-simulator-renderer\\.js/.test(s.src)) {\n if (s.src.indexOf('?t=') === -1) {\n try {\n s.src = s.src + (s.src.indexOf('?') === -1 ? '?t=' + ts : '&t=' + ts);\n } catch (e) {}\n }\n }\n });\n // \u6700\u7EC8\u786E\u4FDD child window \u6709 getFormRenderMaterial\n try {\n var cw = iframeEl.contentWindow;\n if (cw && typeof cw.getFormRenderMaterial !== 'function') {\n cw.getFormRenderMaterial = function() { return { __esModule: true }; };\n }\n } catch (e) {}\n } catch (e) {}\n }\n\n var mo = new MutationObserver(function(muts) {\n muts.forEach(function(mut) {\n Array.prototype.forEach.call(mut.addedNodes || [], function(node) {\n try {\n if (node && node.tagName === 'IFRAME') {\n tryPatchChildIframe(node);\n // attach load to do more thorough patch after content is written\n node.addEventListener && node.addEventListener('load', function() {\n onChildFrameLoad(node);\n }, { once: true });\n }\n } catch (e) {}\n });\n });\n });\n\n try {\n mo.observe(document.documentElement || document.body, { childList: true, subtree: true });\n // \u5DF2\u5B58\u5728\u7684 iframe \u7ACB\u5373\u5C1D\u8BD5\u4FEE\u8865\n Array.prototype.forEach.call(document.getElementsByTagName('iframe'), function(f) {\n tryPatchChildIframe(f);\n f.addEventListener && f.addEventListener('load', function() { onChildFrameLoad(f); }, { once: true });\n });\n } catch (e) {}\n })();\n </script>\n\n <script>\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n </script>\n\n <script src=\"https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/react15-polyfill/0.0.1/dist/index.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js\"></script>\n <script src=\"https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js\"></script>\n <script src=\"https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/js/engine-core.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/js/engine-ext.js\"></script>\n </head>\n\n <body>\n <div id=\"lce-container\"></div>\n <!-- \u7ED9 fr-generator \u52A0\u65F6\u95F4\u6233\uFF0C\u5E2E\u52A9\u89C4\u907F\u7F13\u5B58\u5BFC\u81F4\u7684\u65E7\u7248/\u65F6\u5E8F\u95EE\u9898 -->\n <script type=\"text/javascript\" src=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js?t=").concat(timestamp, "\"></script>\n </body>\n </html>\n ");
9
9
  return html;
10
10
  };
11
11
  var _default = exports.default = function _default() {
@@ -13,6 +13,7 @@ var _default = exports.default = function _default() {
13
13
  iframe.width = '100%';
14
14
  iframe.height = '100%';
15
15
  iframe.frameBorder = '0';
16
- iframe.srcdoc = createIframeContent();
16
+ var ts = Date.now();
17
+ iframe.srcdoc = createIframeContent(ts);
17
18
  return iframe;
18
19
  };
package/lib/main.js CHANGED
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
- var defaultSetting = _interopRequireWildcard(require("./settings"));
10
9
  var _createIframe = _interopRequireDefault(require("./createIframe"));
10
+ var defaultSetting = _interopRequireWildcard(require("./settings"));
11
11
  var _excluded = ["widgets", "settings"];
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
13
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
@@ -19,8 +19,6 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
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;
22
-
23
- // 修改 main.ts,在父窗口中直接注入 getFormRenderMaterial
24
22
  var Design = function Design(props, ref) {
25
23
  var widgets = props.widgets,
26
24
  settings = props.settings,
@@ -39,77 +37,25 @@ var Design = function Design(props, ref) {
39
37
  };
40
38
  });
41
39
  (0, _react.useEffect)(function () {
42
- initIframe();
43
40
  window.addEventListener('message', engineOnLoad);
44
-
45
- // 添加一个定时器,确保 getFormRenderMaterial 被正确注入
46
- var checkInterval = setInterval(function () {
47
- var _iframe3;
48
- if (((_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow) && !iframe.contentWindow.getFormRenderMaterial) {
49
- console.log('Manually injecting getFormRenderMaterial from parent');
50
- iframe.contentWindow.getFormRenderMaterial = function () {
51
- return Object.assign({
52
- __esModule: true
53
- }, widgets || {});
54
- };
55
- }
56
- }, 100);
41
+ initIframe();
57
42
  return function () {
58
43
  window.removeEventListener('message', engineOnLoad);
59
- clearInterval(checkInterval);
60
44
  };
61
45
  }, []);
62
46
  var initIframe = function initIframe() {
63
47
  iframe = (0, _createIframe.default)();
64
48
  containerRef.current.appendChild(iframe);
65
-
66
- // 监听 iframe 的 load 事件
67
- iframe.onload = function () {
68
- console.log('iframe loaded, injecting getFormRenderMaterial');
69
-
70
- // 立即尝试注入 getFormRenderMaterial
71
- if (iframe.contentWindow) {
72
- // 方法1:直接注入
73
- iframe.contentWindow.getFormRenderMaterial = function () {
74
- console.log('Parent-injected getFormRenderMaterial called');
75
- return Object.assign({
76
- __esModule: true
77
- }, widgets || {});
78
- };
79
-
80
- // 方法2:模拟 polling 机制
81
- setTimeout(function () {
82
- if (iframe.contentWindow && !iframe.contentWindow.getFormRenderMaterial) {
83
- console.log('Fallback injection after timeout');
84
- iframe.contentWindow.getFormRenderMaterial = function () {
85
- return Object.assign({
86
- __esModule: true
87
- }, widgets || {});
88
- };
89
- }
90
- }, 500);
91
- }
92
- };
93
49
  };
94
50
  var engineOnLoad = function engineOnLoad(event) {
95
- var _iframe4, _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
51
+ var _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2;
96
52
  if (event.data.type !== 'engine-load') {
97
53
  return;
98
54
  }
99
-
100
- // 在初始化前再次确保 getFormRenderMaterial 存在
101
- var iframeWin = (_iframe4 = iframe) === null || _iframe4 === void 0 ? void 0 : _iframe4.contentWindow;
102
- if (iframeWin && !iframeWin.getFormRenderMaterial) {
103
- console.warn('getFormRenderMaterial missing before init, injecting');
104
- iframeWin.getFormRenderMaterial = function () {
105
- return Object.assign({
106
- __esModule: true
107
- }, widgets || {});
108
- };
109
- }
110
- (_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({
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({
111
56
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
112
57
  widgets: widgets,
58
+ // recordEnable: true,
113
59
  logo: {
114
60
  title: 'XRender'
115
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzdadelu/schema-builder",
3
- "version": "1.0.0-alpha.71",
3
+ "version": "1.0.0-alpha.73",
4
4
  "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5
5
  "keywords": [
6
6
  "Form",