@zzdadelu/schema-builder 1.0.0-alpha.107 → 1.0.0-alpha.109

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 +9 -14
  2. package/lib/main.js +9 -14
  3. package/package.json +1 -1
package/es/main.js CHANGED
@@ -47,16 +47,15 @@ var Design = function Design(props, ref) {
47
47
 
48
48
  // --- 解决方案开始 ---
49
49
  var iframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
50
- if (!iframeWindow) {
51
- console.error('Iframe window is not available.');
50
+ var iframeDoc = iframeWindow === null || iframeWindow === void 0 ? void 0 : iframeWindow.document;
51
+ if (!iframeWindow || !iframeDoc) {
52
+ console.error('Iframe 窗口或文档引用丢失。');
52
53
  return;
53
54
  }
54
-
55
- // 定义一个检查并初始化引擎的函数
56
55
  var _checkAndInit = function checkAndInit() {
57
- var _iframeWindow$__React;
58
- // 检查关键依赖函数是否存在
59
- if (typeof (iframeWindow === null || iframeWindow === void 0 ? void 0 : (_iframeWindow$__React = iframeWindow.__ReactSimulatorRenderer__) === null || _iframeWindow$__React === void 0 ? void 0 : _iframeWindow$__React.getFormRenderMaterial) === 'function') {
56
+ // 检查条件:文档状态和函数存在性
57
+ if ((iframeDoc.readyState === 'complete' || iframeDoc.readyState === 'interactive') && typeof iframeWindow.getFormRenderMaterial === 'function' // 确认无命名空间
58
+ ) {
60
59
  var _iframeWindow$__FR_EN;
61
60
  // ✅ 环境就绪,执行引擎初始化
62
61
  (_iframeWindow$__FR_EN = iframeWindow.__FR_ENGINE__) === null || _iframeWindow$__FR_EN === void 0 ? void 0 : _iframeWindow$__FR_EN.init(_objectSpread({
@@ -68,16 +67,12 @@ var Design = function Design(props, ref) {
68
67
  }
69
68
  }, restProps));
70
69
  } else {
71
- // ⌛ 环境未就绪,可能是 fr-generator.js 还在加载/解析中,设置定时器重试
72
- console.warn('XRender 依赖资源 getFormRenderMaterial 尚未加载完毕,正在重试...');
73
- // 使用 setTimeout 进行非阻塞式轮询,避免阻塞 UI 线程
70
+ // ⌛ 继续等待
71
+ console.warn('XRender 依赖资源 getFormRenderMaterial 尚未加载完毕,文档状态:', iframeDoc.readyState, '正在重试...');
74
72
  setTimeout(_checkAndInit, 50);
75
73
  }
76
74
  };
77
-
78
- // 启动检查流程
79
- // checkAndInit();
80
- // --- 解决方案结束 ---
75
+ _checkAndInit();
81
76
  };
82
77
  return /*#__PURE__*/React.createElement("div", {
83
78
  ref: containerRef,
package/lib/main.js CHANGED
@@ -55,16 +55,15 @@ var Design = function Design(props, ref) {
55
55
 
56
56
  // --- 解决方案开始 ---
57
57
  var iframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
58
- if (!iframeWindow) {
59
- console.error('Iframe window is not available.');
58
+ var iframeDoc = iframeWindow === null || iframeWindow === void 0 ? void 0 : iframeWindow.document;
59
+ if (!iframeWindow || !iframeDoc) {
60
+ console.error('Iframe 窗口或文档引用丢失。');
60
61
  return;
61
62
  }
62
-
63
- // 定义一个检查并初始化引擎的函数
64
63
  var _checkAndInit = function checkAndInit() {
65
- var _iframeWindow$__React;
66
- // 检查关键依赖函数是否存在
67
- if (typeof (iframeWindow === null || iframeWindow === void 0 ? void 0 : (_iframeWindow$__React = iframeWindow.__ReactSimulatorRenderer__) === null || _iframeWindow$__React === void 0 ? void 0 : _iframeWindow$__React.getFormRenderMaterial) === 'function') {
64
+ // 检查条件:文档状态和函数存在性
65
+ if ((iframeDoc.readyState === 'complete' || iframeDoc.readyState === 'interactive') && typeof iframeWindow.getFormRenderMaterial === 'function' // 确认无命名空间
66
+ ) {
68
67
  var _iframeWindow$__FR_EN;
69
68
  // ✅ 环境就绪,执行引擎初始化
70
69
  (_iframeWindow$__FR_EN = iframeWindow.__FR_ENGINE__) === null || _iframeWindow$__FR_EN === void 0 ? void 0 : _iframeWindow$__FR_EN.init(_objectSpread({
@@ -76,16 +75,12 @@ var Design = function Design(props, ref) {
76
75
  }
77
76
  }, restProps));
78
77
  } else {
79
- // ⌛ 环境未就绪,可能是 fr-generator.js 还在加载/解析中,设置定时器重试
80
- console.warn('XRender 依赖资源 getFormRenderMaterial 尚未加载完毕,正在重试...');
81
- // 使用 setTimeout 进行非阻塞式轮询,避免阻塞 UI 线程
78
+ // ⌛ 继续等待
79
+ console.warn('XRender 依赖资源 getFormRenderMaterial 尚未加载完毕,文档状态:', iframeDoc.readyState, '正在重试...');
82
80
  setTimeout(_checkAndInit, 50);
83
81
  }
84
82
  };
85
-
86
- // 启动检查流程
87
- // checkAndInit();
88
- // --- 解决方案结束 ---
83
+ _checkAndInit();
89
84
  };
90
85
  return /*#__PURE__*/_react.default.createElement("div", {
91
86
  ref: containerRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzdadelu/schema-builder",
3
- "version": "1.0.0-alpha.107",
3
+ "version": "1.0.0-alpha.109",
4
4
  "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5
5
  "keywords": [
6
6
  "Form",