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

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,15 +1,12 @@
1
- // 创建一个新的 iframe 加载器:iframeLoaderEnhanced.ts
2
- export var createFixedIframe = function createFixedIframe(widgets) {
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 ";
3
+ return html;
4
+ };
5
+ export default (function () {
3
6
  var iframe = document.createElement('iframe');
4
7
  iframe.width = '100%';
5
8
  iframe.height = '100%';
6
9
  iframe.frameBorder = '0';
7
- var timestamp = Date.now();
8
- var cacheBuster = "?t=".concat(timestamp);
9
-
10
- // 将 widgets 转换为 JSON 字符串用于注入
11
- var widgetsJson = JSON.stringify(widgets || {});
12
- var html = "<!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>XRender</title>\n <link rel=\"icon\" href=\"https://img.alicdn.com/tfs/TB17UtINiLaK1RjSZFxXXamPFXa-606-643.png\">\n \n <!-- \u6837\u5F0F -->\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/variables.css".concat(cacheBuster, "\" rel=\"stylesheet\">\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/dist/next.var.min.css").concat(cacheBuster, "\" rel=\"stylesheet\">\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/css/engine-core.css").concat(cacheBuster, "\">\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/css/engine-ext.css").concat(cacheBuster, "\">\n <link rel=\"stylesheet\" href=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/css/index.css").concat(cacheBuster, "\">\n \n <script>\n // \u6838\u5FC3\u4FEE\u590D\uFF1A\u5B8C\u5168\u63A5\u7BA1 polling \u673A\u5236\n (function() {\n // \u5B58\u50A8\u539F\u59CB\u7684 polling \u65B9\u6CD5\n var originalPolling = null;\n \n // \u5B9A\u4E49\u6211\u4EEC\u81EA\u5DF1\u7684 polling \u5B9E\u73B0\n var fixedPolling = function(t) {\n console.log('Fixed polling called with data:', t ? 'has data' : 'no data');\n \n // \u76F4\u63A5\u8BBE\u7F6E getFormRenderMaterial\uFF0C\u4E0D\u4F9D\u8D56\u4E8E\u67E5\u627E iframe\n window.getFormRenderMaterial = function() {\n console.log('Fixed getFormRenderMaterial called');\n // \u8FD4\u56DE\u5B9E\u9645\u7684 widgets \u6570\u636E\n var widgetsData = window.__WIDGETS_DATA__ || t || {};\n return Object.assign({__esModule: true}, widgetsData, {});\n };\n \n // \u786E\u4FDD\u65B9\u6CD5\u5DF2\u8BBE\u7F6E\n console.log('getFormRenderMaterial set:', !!window.getFormRenderMaterial);\n \n // \u5982\u679C\u6709\u539F\u59CB polling\uFF0C\u4E5F\u8C03\u7528\u5B83\uFF08\u5982\u679C\u5B83\u5B58\u5728\uFF09\n if (originalPolling) {\n try {\n originalPolling.call(this, t);\n } catch(e) {\n console.error('Original polling failed:', e);\n }\n }\n \n // \u6807\u8BB0 polling \u5B8C\u6210\n window.__POLLING_COMPLETE__ = true;\n };\n \n // \u62E6\u622A fr-generator \u7684 polling \u65B9\u6CD5\n var interceptPolling = function() {\n if (window.__FR_ENGINE__ && typeof window.__FR_ENGINE__.polling === 'function') {\n originalPolling = window.__FR_ENGINE__.polling;\n window.__FR_ENGINE__.polling = fixedPolling;\n console.log('Successfully intercepted polling method');\n return true;\n }\n return false;\n };\n \n // \u7ACB\u5373\u5C1D\u8BD5\u62E6\u622A\n if (!interceptPolling()) {\n // \u5982\u679C fr-generator \u8FD8\u6CA1\u52A0\u8F7D\uFF0C\u8BBE\u7F6E\u4E00\u4E2A\u76D1\u542C\u5668\n var checkInterval = setInterval(function() {\n if (interceptPolling()) {\n clearInterval(checkInterval);\n console.log('Polling interception complete');\n }\n }, 100);\n \n // \u6700\u591A\u68C0\u67E5 5 \u79D2\n setTimeout(function() {\n clearInterval(checkInterval);\n }, 5000);\n }\n \n // \u6CE8\u5165 widgets \u6570\u636E\n window.__WIDGETS_DATA__ = ").concat(widgetsJson, ";\n \n // \u8BBE\u7F6E\u5176\u4ED6\u5FC5\u8981\u7684\u5168\u5C40\u53D8\u91CF\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n window.__is_simulator_env__ = true;\n window.PropTypes = window.parent.PropTypes;\n window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;\n \n // \u9884\u5B9A\u4E49 getFormRenderMaterial \u4F5C\u4E3A\u540E\u5907\n window.getFormRenderMaterial = window.getFormRenderMaterial || function() {\n console.log('Fallback getFormRenderMaterial called');\n return Object.assign({__esModule: true}, window.__WIDGETS_DATA__ || {});\n };\n })();\n </script>\n </head>\n <body>\n <div id=\"lce-container\"></div>\n \n <!-- \u52A0\u8F7D\u6240\u6709\u811A\u672C -->\n <script src=\"https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js").concat(cacheBuster, "\"></script>\n <script src=\"https://g.alicdn.com/platform/c/react15-polyfill/0.0.1/dist/index.js").concat(cacheBuster, "\"></script>\n <script src=\"https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js").concat(cacheBuster, "\"></script>\n <script src=\"https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js").concat(cacheBuster, "\"></script>\n <script src=\"https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.js").concat(cacheBuster, "\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/js/engine-core.js").concat(cacheBuster, "\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/js/engine-ext.js").concat(cacheBuster, "\"></script>\n <script type=\"text/javascript\" src=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js").concat(cacheBuster, "\"></script>\n \n <script>\n // \u786E\u4FDD\u5728 iframe \u52A0\u8F7D\u5B8C\u6210\u540E\u901A\u77E5\u7236\u7A97\u53E3\n window.addEventListener('load', function() {\n console.log('iframe fully loaded, polling status:', window.__POLLING_COMPLETE__);\n \n // \u518D\u6B21\u786E\u4FDD getFormRenderMaterial \u5B58\u5728\n if (!window.getFormRenderMaterial) {\n console.warn('getFormRenderMaterial still missing, setting emergency fallback');\n window.getFormRenderMaterial = function() {\n return {};\n };\n }\n \n // \u901A\u77E5\u7236\u7A97\u53E3 iframe \u5DF2\u51C6\u5907\u5C31\u7EEA\n setTimeout(function() {\n window.parent.postMessage({ type: 'iframe-ready' }, '*');\n window.parent.postMessage({ type: 'engine-load' }, '*');\n }, 300);\n });\n </script>\n </body>\n </html>");
13
- iframe.srcdoc = html;
10
+ iframe.srcdoc = createIframeContent();
14
11
  return iframe;
15
- };
12
+ });
package/es/main.js CHANGED
@@ -9,8 +9,10 @@ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, 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
11
  import * as defaultSetting from './settings';
12
- import { createFixedIframe } from './createIframe';
12
+ import createIframe from './createIframe';
13
13
  var iframe;
14
+
15
+ // 修改 main.ts,在父窗口中直接注入 getFormRenderMaterial
14
16
  var Design = function Design(props, ref) {
15
17
  var widgets = props.widgets,
16
18
  settings = props.settings,
@@ -29,25 +31,77 @@ var Design = function Design(props, ref) {
29
31
  };
30
32
  });
31
33
  useEffect(function () {
32
- window.addEventListener('message', engineOnLoad);
33
34
  initIframe();
35
+ 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);
34
49
  return function () {
35
50
  window.removeEventListener('message', engineOnLoad);
51
+ clearInterval(checkInterval);
36
52
  };
37
53
  }, []);
38
54
  var initIframe = function initIframe() {
39
- iframe = createFixedIframe;
55
+ iframe = createIframe();
40
56
  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
+ };
41
85
  };
42
86
  var engineOnLoad = function engineOnLoad(event) {
43
- var _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2;
87
+ var _iframe4, _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
44
88
  if (event.data.type !== 'engine-load') {
45
89
  return;
46
90
  }
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({
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({
48
103
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
49
104
  widgets: widgets,
50
- // recordEnable: true,
51
105
  logo: {
52
106
  title: 'XRender'
53
107
  }
@@ -3,19 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createFixedIframe = void 0;
7
- // 创建一个新的 iframe 加载器:iframeLoaderEnhanced.ts
8
- var createFixedIframe = exports.createFixedIframe = function createFixedIframe(widgets) {
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 ";
9
+ return html;
10
+ };
11
+ var _default = exports.default = function _default() {
9
12
  var iframe = document.createElement('iframe');
10
13
  iframe.width = '100%';
11
14
  iframe.height = '100%';
12
15
  iframe.frameBorder = '0';
13
- var timestamp = Date.now();
14
- var cacheBuster = "?t=".concat(timestamp);
15
-
16
- // 将 widgets 转换为 JSON 字符串用于注入
17
- var widgetsJson = JSON.stringify(widgets || {});
18
- var html = "<!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>XRender</title>\n <link rel=\"icon\" href=\"https://img.alicdn.com/tfs/TB17UtINiLaK1RjSZFxXXamPFXa-606-643.png\">\n \n <!-- \u6837\u5F0F -->\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/variables.css".concat(cacheBuster, "\" rel=\"stylesheet\">\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/dist/next.var.min.css").concat(cacheBuster, "\" rel=\"stylesheet\">\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/css/engine-core.css").concat(cacheBuster, "\">\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/css/engine-ext.css").concat(cacheBuster, "\">\n <link rel=\"stylesheet\" href=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/css/index.css").concat(cacheBuster, "\">\n \n <script>\n // \u6838\u5FC3\u4FEE\u590D\uFF1A\u5B8C\u5168\u63A5\u7BA1 polling \u673A\u5236\n (function() {\n // \u5B58\u50A8\u539F\u59CB\u7684 polling \u65B9\u6CD5\n var originalPolling = null;\n \n // \u5B9A\u4E49\u6211\u4EEC\u81EA\u5DF1\u7684 polling \u5B9E\u73B0\n var fixedPolling = function(t) {\n console.log('Fixed polling called with data:', t ? 'has data' : 'no data');\n \n // \u76F4\u63A5\u8BBE\u7F6E getFormRenderMaterial\uFF0C\u4E0D\u4F9D\u8D56\u4E8E\u67E5\u627E iframe\n window.getFormRenderMaterial = function() {\n console.log('Fixed getFormRenderMaterial called');\n // \u8FD4\u56DE\u5B9E\u9645\u7684 widgets \u6570\u636E\n var widgetsData = window.__WIDGETS_DATA__ || t || {};\n return Object.assign({__esModule: true}, widgetsData, {});\n };\n \n // \u786E\u4FDD\u65B9\u6CD5\u5DF2\u8BBE\u7F6E\n console.log('getFormRenderMaterial set:', !!window.getFormRenderMaterial);\n \n // \u5982\u679C\u6709\u539F\u59CB polling\uFF0C\u4E5F\u8C03\u7528\u5B83\uFF08\u5982\u679C\u5B83\u5B58\u5728\uFF09\n if (originalPolling) {\n try {\n originalPolling.call(this, t);\n } catch(e) {\n console.error('Original polling failed:', e);\n }\n }\n \n // \u6807\u8BB0 polling \u5B8C\u6210\n window.__POLLING_COMPLETE__ = true;\n };\n \n // \u62E6\u622A fr-generator \u7684 polling \u65B9\u6CD5\n var interceptPolling = function() {\n if (window.__FR_ENGINE__ && typeof window.__FR_ENGINE__.polling === 'function') {\n originalPolling = window.__FR_ENGINE__.polling;\n window.__FR_ENGINE__.polling = fixedPolling;\n console.log('Successfully intercepted polling method');\n return true;\n }\n return false;\n };\n \n // \u7ACB\u5373\u5C1D\u8BD5\u62E6\u622A\n if (!interceptPolling()) {\n // \u5982\u679C fr-generator \u8FD8\u6CA1\u52A0\u8F7D\uFF0C\u8BBE\u7F6E\u4E00\u4E2A\u76D1\u542C\u5668\n var checkInterval = setInterval(function() {\n if (interceptPolling()) {\n clearInterval(checkInterval);\n console.log('Polling interception complete');\n }\n }, 100);\n \n // \u6700\u591A\u68C0\u67E5 5 \u79D2\n setTimeout(function() {\n clearInterval(checkInterval);\n }, 5000);\n }\n \n // \u6CE8\u5165 widgets \u6570\u636E\n window.__WIDGETS_DATA__ = ").concat(widgetsJson, ";\n \n // \u8BBE\u7F6E\u5176\u4ED6\u5FC5\u8981\u7684\u5168\u5C40\u53D8\u91CF\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n window.__is_simulator_env__ = true;\n window.PropTypes = window.parent.PropTypes;\n window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;\n \n // \u9884\u5B9A\u4E49 getFormRenderMaterial \u4F5C\u4E3A\u540E\u5907\n window.getFormRenderMaterial = window.getFormRenderMaterial || function() {\n console.log('Fallback getFormRenderMaterial called');\n return Object.assign({__esModule: true}, window.__WIDGETS_DATA__ || {});\n };\n })();\n </script>\n </head>\n <body>\n <div id=\"lce-container\"></div>\n \n <!-- \u52A0\u8F7D\u6240\u6709\u811A\u672C -->\n <script src=\"https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js").concat(cacheBuster, "\"></script>\n <script src=\"https://g.alicdn.com/platform/c/react15-polyfill/0.0.1/dist/index.js").concat(cacheBuster, "\"></script>\n <script src=\"https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js").concat(cacheBuster, "\"></script>\n <script src=\"https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js").concat(cacheBuster, "\"></script>\n <script src=\"https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.js").concat(cacheBuster, "\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/js/engine-core.js").concat(cacheBuster, "\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/js/engine-ext.js").concat(cacheBuster, "\"></script>\n <script type=\"text/javascript\" src=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js").concat(cacheBuster, "\"></script>\n \n <script>\n // \u786E\u4FDD\u5728 iframe \u52A0\u8F7D\u5B8C\u6210\u540E\u901A\u77E5\u7236\u7A97\u53E3\n window.addEventListener('load', function() {\n console.log('iframe fully loaded, polling status:', window.__POLLING_COMPLETE__);\n \n // \u518D\u6B21\u786E\u4FDD getFormRenderMaterial \u5B58\u5728\n if (!window.getFormRenderMaterial) {\n console.warn('getFormRenderMaterial still missing, setting emergency fallback');\n window.getFormRenderMaterial = function() {\n return {};\n };\n }\n \n // \u901A\u77E5\u7236\u7A97\u53E3 iframe \u5DF2\u51C6\u5907\u5C31\u7EEA\n setTimeout(function() {\n window.parent.postMessage({ type: 'iframe-ready' }, '*');\n window.parent.postMessage({ type: 'engine-load' }, '*');\n }, 300);\n });\n </script>\n </body>\n </html>");
19
- iframe.srcdoc = html;
16
+ iframe.srcdoc = createIframeContent();
20
17
  return iframe;
21
18
  };
package/lib/main.js CHANGED
@@ -7,8 +7,9 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var defaultSetting = _interopRequireWildcard(require("./settings"));
10
- var _createIframe = require("./createIframe");
10
+ var _createIframe = _interopRequireDefault(require("./createIframe"));
11
11
  var _excluded = ["widgets", "settings"];
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
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); }
13
14
  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; }
14
15
  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; }
@@ -18,6 +19,8 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
18
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; }
19
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; }
20
21
  var iframe;
22
+
23
+ // 修改 main.ts,在父窗口中直接注入 getFormRenderMaterial
21
24
  var Design = function Design(props, ref) {
22
25
  var widgets = props.widgets,
23
26
  settings = props.settings,
@@ -36,25 +39,77 @@ var Design = function Design(props, ref) {
36
39
  };
37
40
  });
38
41
  (0, _react.useEffect)(function () {
39
- window.addEventListener('message', engineOnLoad);
40
42
  initIframe();
43
+ 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
57
  return function () {
42
58
  window.removeEventListener('message', engineOnLoad);
59
+ clearInterval(checkInterval);
43
60
  };
44
61
  }, []);
45
62
  var initIframe = function initIframe() {
46
- iframe = _createIframe.createFixedIframe;
63
+ iframe = (0, _createIframe.default)();
47
64
  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
+ };
48
93
  };
49
94
  var engineOnLoad = function engineOnLoad(event) {
50
- var _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2;
95
+ var _iframe4, _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
51
96
  if (event.data.type !== 'engine-load') {
52
97
  return;
53
98
  }
54
- (_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({
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
111
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
56
112
  widgets: widgets,
57
- // recordEnable: true,
58
113
  logo: {
59
114
  title: 'XRender'
60
115
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzdadelu/schema-builder",
3
- "version": "1.0.0-alpha.70",
3
+ "version": "1.0.0-alpha.71",
4
4
  "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5
5
  "keywords": [
6
6
  "Form",