@zzdadelu/schema-builder 1.0.0-alpha.104 → 1.0.0-alpha.105

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
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 // \u8BBE\u7F6E\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 React.PropTypes = window.parent.PropTypes;\n window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;\n \n // \u9884\u5B9A\u4E49 getFormRenderMaterial \u51FD\u6570\n (function() {\n // \u5B58\u50A8\u5B9E\u9645\u7684\u7269\u6599\u6570\u636E\n window.__FR_MATERIAL_DATA__ = {};\n window.__FR_MATERIAL_FUNCTION = null;\n \n // \u5B9A\u4E49 getFormRenderMaterial \u51FD\u6570\n window.getFormRenderMaterial = function(name, packageName) {\n // \u5982\u679C\u5DF2\u7ECF\u8BBE\u7F6E\u4E86\u5B9E\u9645\u7684\u51FD\u6570\uFF0C\u5C31\u8C03\u7528\u5B83\n if (window.__FR_MATERIAL_FUNCTION) {\n return window.__FR_MATERIAL_FUNCTION(name, packageName);\n }\n \n // \u5426\u5219\u8FD4\u56DE\u4E00\u4E2A\u5DE5\u5382\u51FD\u6570\uFF0C\u8FD9\u4E2A\u5DE5\u5382\u51FD\u6570\u8FD4\u56DE\u5B9E\u9645\u7684\u7269\u6599\u6570\u636E\n return function() {\n // \u68C0\u67E5\u662F\u5426\u5DF2\u7ECF\u6709\u7269\u6599\u6570\u636E\n var materialKey = name + '_' + packageName;\n if (window.__FR_MATERIAL_DATA__[materialKey]) {\n return window.__FR_MATERIAL_DATA__[materialKey];\n }\n \n // \u8FD4\u56DE\u4E00\u4E2A\u7A7A\u5BF9\u8C61\uFF0C\u907F\u514D\u62A5\u9519\n console.warn('FormRender material not ready yet for:', name, packageName);\n return {};\n };\n };\n \n // \u63D0\u4F9B\u4E00\u4E2A\u65B9\u6CD5\u8BA9\u5916\u90E8\u8BBE\u7F6E\u7269\u6599\u6570\u636E\n window.__setFormRenderMaterial = function(data) {\n if (typeof data === 'function') {\n window.__FR_MATERIAL_FUNCTION = data;\n } else if (typeof data === 'object') {\n window.__FR_MATERIAL_DATA__ = Object.assign({}, window.__FR_MATERIAL_DATA__, data);\n }\n };\n \n // \u76D1\u542C\u6765\u81EA\u7236\u7A97\u53E3\u7684\u6D88\u606F\uFF0C\u8BBE\u7F6E\u7269\u6599\u6570\u636E\n window.addEventListener('message', function(event) {\n if (event.data && event.data.type === 'SET_FORM_RENDER_MATERIAL') {\n window.__setFormRenderMaterial(event.data.materialData);\n }\n });\n })();\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 ";
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
3
  return html;
4
4
  };
5
5
  export default (function () {
package/es/main.js CHANGED
@@ -11,7 +11,6 @@ import React, { useEffect, useRef, useImperativeHandle, forwardRef } from 'react
11
11
  import createIframe from './createIframe';
12
12
  import * as defaultSetting from './settings';
13
13
  var iframe;
14
- var materialData = null;
15
14
  var Design = function Design(props, ref) {
16
15
  var widgets = props.widgets,
17
16
  settings = props.settings,
@@ -38,78 +37,46 @@ var Design = function Design(props, ref) {
38
37
  }, []);
39
38
  var initIframe = function initIframe() {
40
39
  iframe = createIframe();
41
-
42
- // 监听 iframe 加载完成
43
- iframe.onload = function () {
44
- // 立即设置 getFormRenderMaterial 函数,防止 create-simulator 调用时报错
45
- if (iframe.contentWindow) {
46
- // 创建一个临时的 getFormRenderMaterial 函数
47
- iframe.contentWindow.getFormRenderMaterial = function (name, packageName) {
48
- console.log('getFormRenderMaterial called with:', name, packageName);
49
-
50
- // 返回一个工厂函数
51
- return function () {
52
- console.log('Material factory called for:', name, packageName);
53
-
54
- // 检查是否有缓存的物料
55
- if (materialData) {
56
- return materialData;
57
- }
58
-
59
- // 返回一个模拟的物料,包含必要的属性
60
- return {
61
- __esModule: true,
62
- // 添加一些默认的组件配置
63
- components: {},
64
- snippets: [],
65
- componentList: []
66
- };
67
- };
68
- };
69
-
70
- // 发送物料数据到 iframe
71
- if (widgets) {
72
- materialData = widgets;
73
- iframe.contentWindow.postMessage({
74
- type: 'SET_FORM_RENDER_MATERIAL',
75
- materialData: widgets
76
- }, '*');
77
- }
78
- }
79
- };
80
- setTimeout(function () {
81
- // 延迟设置物料
82
- iframe.contentWindow.AliFormRenderMaterial = materialData;
83
- }, 100);
84
40
  containerRef.current.appendChild(iframe);
85
41
  };
86
42
  var engineOnLoad = function engineOnLoad(event) {
87
- var _iframe3, _iframe4, _iframe4$contentWindo, _iframe4$contentWindo2;
43
+ var _iframe3;
88
44
  if (event.data.type !== 'engine-load') {
89
45
  return;
90
46
  }
91
47
 
92
- // 确保物料数据已经准备好
93
- if (!materialData && widgets) {
94
- materialData = widgets;
95
- }
96
-
97
- // 再次发送物料数据,确保 fr-generator 能够收到
98
- if (((_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow) && materialData) {
99
- iframe.contentWindow.postMessage({
100
- type: 'SET_FORM_RENDER_MATERIAL',
101
- materialData: materialData
102
- }, '*');
48
+ // --- 解决方案开始 ---
49
+ var iframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
50
+ if (!iframeWindow) {
51
+ console.error('Iframe window is not available.');
52
+ return;
103
53
  }
104
54
 
105
- // 初始化引擎
106
- (_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({
107
- settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
108
- widgets: materialData || widgets,
109
- logo: {
110
- title: 'XRender'
55
+ // 定义一个检查并初始化引擎的函数
56
+ var _checkAndInit = function checkAndInit() {
57
+ // 检查关键依赖函数是否存在
58
+ if (typeof iframeWindow.getFormRenderMaterial === 'function') {
59
+ var _iframeWindow$__FR_EN;
60
+ // ✅ 环境就绪,执行引擎初始化
61
+ (_iframeWindow$__FR_EN = iframeWindow.__FR_ENGINE__) === null || _iframeWindow$__FR_EN === void 0 ? void 0 : _iframeWindow$__FR_EN.init(_objectSpread({
62
+ settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
63
+ widgets: widgets,
64
+ // recordEnable: true,
65
+ logo: {
66
+ title: 'XRender'
67
+ }
68
+ }, restProps));
69
+ } else {
70
+ // ⌛ 环境未就绪,可能是 fr-generator.js 还在加载/解析中,设置定时器重试
71
+ console.warn('XRender 依赖资源 getFormRenderMaterial 尚未加载完毕,正在重试...');
72
+ // 使用 setTimeout 进行非阻塞式轮询,避免阻塞 UI 线程
73
+ setTimeout(_checkAndInit, 50);
111
74
  }
112
- }, restProps));
75
+ };
76
+
77
+ // 启动检查流程
78
+ _checkAndInit();
79
+ // --- 解决方案结束 ---
113
80
  };
114
81
  return /*#__PURE__*/React.createElement("div", {
115
82
  ref: containerRef,
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
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 // \u8BBE\u7F6E\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 React.PropTypes = window.parent.PropTypes;\n window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;\n \n // \u9884\u5B9A\u4E49 getFormRenderMaterial \u51FD\u6570\n (function() {\n // \u5B58\u50A8\u5B9E\u9645\u7684\u7269\u6599\u6570\u636E\n window.__FR_MATERIAL_DATA__ = {};\n window.__FR_MATERIAL_FUNCTION = null;\n \n // \u5B9A\u4E49 getFormRenderMaterial \u51FD\u6570\n window.getFormRenderMaterial = function(name, packageName) {\n // \u5982\u679C\u5DF2\u7ECF\u8BBE\u7F6E\u4E86\u5B9E\u9645\u7684\u51FD\u6570\uFF0C\u5C31\u8C03\u7528\u5B83\n if (window.__FR_MATERIAL_FUNCTION) {\n return window.__FR_MATERIAL_FUNCTION(name, packageName);\n }\n \n // \u5426\u5219\u8FD4\u56DE\u4E00\u4E2A\u5DE5\u5382\u51FD\u6570\uFF0C\u8FD9\u4E2A\u5DE5\u5382\u51FD\u6570\u8FD4\u56DE\u5B9E\u9645\u7684\u7269\u6599\u6570\u636E\n return function() {\n // \u68C0\u67E5\u662F\u5426\u5DF2\u7ECF\u6709\u7269\u6599\u6570\u636E\n var materialKey = name + '_' + packageName;\n if (window.__FR_MATERIAL_DATA__[materialKey]) {\n return window.__FR_MATERIAL_DATA__[materialKey];\n }\n \n // \u8FD4\u56DE\u4E00\u4E2A\u7A7A\u5BF9\u8C61\uFF0C\u907F\u514D\u62A5\u9519\n console.warn('FormRender material not ready yet for:', name, packageName);\n return {};\n };\n };\n \n // \u63D0\u4F9B\u4E00\u4E2A\u65B9\u6CD5\u8BA9\u5916\u90E8\u8BBE\u7F6E\u7269\u6599\u6570\u636E\n window.__setFormRenderMaterial = function(data) {\n if (typeof data === 'function') {\n window.__FR_MATERIAL_FUNCTION = data;\n } else if (typeof data === 'object') {\n window.__FR_MATERIAL_DATA__ = Object.assign({}, window.__FR_MATERIAL_DATA__, data);\n }\n };\n \n // \u76D1\u542C\u6765\u81EA\u7236\u7A97\u53E3\u7684\u6D88\u606F\uFF0C\u8BBE\u7F6E\u7269\u6599\u6570\u636E\n window.addEventListener('message', function(event) {\n if (event.data && event.data.type === 'SET_FORM_RENDER_MATERIAL') {\n window.__setFormRenderMaterial(event.data.materialData);\n }\n });\n })();\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 ";
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
9
  return html;
10
10
  };
11
11
  var _default = exports.default = function _default() {
package/lib/main.js CHANGED
@@ -19,7 +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
- var materialData = null;
23
22
  var Design = function Design(props, ref) {
24
23
  var widgets = props.widgets,
25
24
  settings = props.settings,
@@ -46,78 +45,46 @@ var Design = function Design(props, ref) {
46
45
  }, []);
47
46
  var initIframe = function initIframe() {
48
47
  iframe = (0, _createIframe.default)();
49
-
50
- // 监听 iframe 加载完成
51
- iframe.onload = function () {
52
- // 立即设置 getFormRenderMaterial 函数,防止 create-simulator 调用时报错
53
- if (iframe.contentWindow) {
54
- // 创建一个临时的 getFormRenderMaterial 函数
55
- iframe.contentWindow.getFormRenderMaterial = function (name, packageName) {
56
- console.log('getFormRenderMaterial called with:', name, packageName);
57
-
58
- // 返回一个工厂函数
59
- return function () {
60
- console.log('Material factory called for:', name, packageName);
61
-
62
- // 检查是否有缓存的物料
63
- if (materialData) {
64
- return materialData;
65
- }
66
-
67
- // 返回一个模拟的物料,包含必要的属性
68
- return {
69
- __esModule: true,
70
- // 添加一些默认的组件配置
71
- components: {},
72
- snippets: [],
73
- componentList: []
74
- };
75
- };
76
- };
77
-
78
- // 发送物料数据到 iframe
79
- if (widgets) {
80
- materialData = widgets;
81
- iframe.contentWindow.postMessage({
82
- type: 'SET_FORM_RENDER_MATERIAL',
83
- materialData: widgets
84
- }, '*');
85
- }
86
- }
87
- };
88
- setTimeout(function () {
89
- // 延迟设置物料
90
- iframe.contentWindow.AliFormRenderMaterial = materialData;
91
- }, 100);
92
48
  containerRef.current.appendChild(iframe);
93
49
  };
94
50
  var engineOnLoad = function engineOnLoad(event) {
95
- var _iframe3, _iframe4, _iframe4$contentWindo, _iframe4$contentWindo2;
51
+ var _iframe3;
96
52
  if (event.data.type !== 'engine-load') {
97
53
  return;
98
54
  }
99
55
 
100
- // 确保物料数据已经准备好
101
- if (!materialData && widgets) {
102
- materialData = widgets;
103
- }
104
-
105
- // 再次发送物料数据,确保 fr-generator 能够收到
106
- if (((_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow) && materialData) {
107
- iframe.contentWindow.postMessage({
108
- type: 'SET_FORM_RENDER_MATERIAL',
109
- materialData: materialData
110
- }, '*');
56
+ // --- 解决方案开始 ---
57
+ var iframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
58
+ if (!iframeWindow) {
59
+ console.error('Iframe window is not available.');
60
+ return;
111
61
  }
112
62
 
113
- // 初始化引擎
114
- (_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({
115
- settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
116
- widgets: materialData || widgets,
117
- logo: {
118
- title: 'XRender'
63
+ // 定义一个检查并初始化引擎的函数
64
+ var _checkAndInit = function checkAndInit() {
65
+ // 检查关键依赖函数是否存在
66
+ if (typeof iframeWindow.getFormRenderMaterial === 'function') {
67
+ var _iframeWindow$__FR_EN;
68
+ // ✅ 环境就绪,执行引擎初始化
69
+ (_iframeWindow$__FR_EN = iframeWindow.__FR_ENGINE__) === null || _iframeWindow$__FR_EN === void 0 ? void 0 : _iframeWindow$__FR_EN.init(_objectSpread({
70
+ settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
71
+ widgets: widgets,
72
+ // recordEnable: true,
73
+ logo: {
74
+ title: 'XRender'
75
+ }
76
+ }, restProps));
77
+ } else {
78
+ // ⌛ 环境未就绪,可能是 fr-generator.js 还在加载/解析中,设置定时器重试
79
+ console.warn('XRender 依赖资源 getFormRenderMaterial 尚未加载完毕,正在重试...');
80
+ // 使用 setTimeout 进行非阻塞式轮询,避免阻塞 UI 线程
81
+ setTimeout(_checkAndInit, 50);
119
82
  }
120
- }, restProps));
83
+ };
84
+
85
+ // 启动检查流程
86
+ _checkAndInit();
87
+ // --- 解决方案结束 ---
121
88
  };
122
89
  return /*#__PURE__*/_react.default.createElement("div", {
123
90
  ref: containerRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzdadelu/schema-builder",
3
- "version": "1.0.0-alpha.104",
3
+ "version": "1.0.0-alpha.105",
4
4
  "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5
5
  "keywords": [
6
6
  "Form",