@zzdadelu/schema-builder 1.0.0-alpha.44 → 1.0.0-alpha.46

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,6 @@
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 <meta http-equiv=\"Cache-Control\" content=\"no-cache, no-store, must-revalidate\">\n <meta http-equiv=\"Pragma\" content=\"no-cache\">\n <meta http-equiv=\"Expires\" content=\"0\">\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 // \u5173\u952E\u70B91: \u5728\u811A\u672C\u52A0\u8F7D\u524D\u5C31\u5B9A\u4E49\u51FD\u6570\u5360\u4F4D\u7B26\n window.getFormRenderMaterial = window.getFormRenderMaterial || function() {\n console.warn('getFormRenderMaterial placeholder called, waiting for real function...');\n return null;\n };\n \n // \u5173\u952E\u70B92: \u76D1\u542C\u51FD\u6570\u5B9A\u4E49\n let originalDefineProperty = Object.defineProperty;\n Object.defineProperty = function(obj, prop, descriptor) {\n if (prop === 'getFormRenderMaterial' && obj === window) {\n console.log('getFormRenderMaterial is being defined...');\n \n // \u4FEE\u6539getter/setter\u4EE5\u786E\u4FDD\u51FD\u6570\u53EF\u7528\n if (descriptor.get) {\n const originalGetter = descriptor.get;\n descriptor.get = function() {\n const result = originalGetter.call(this);\n console.log('getFormRenderMaterial getter called, returning:', typeof result);\n return result;\n };\n }\n \n if (descriptor.set) {\n const originalSetter = descriptor.set;\n descriptor.set = function(value) {\n console.log('getFormRenderMaterial setter called with:', typeof value);\n originalSetter.call(this, value);\n \n // \u51FD\u6570\u8BBE\u7F6E\u540E\u901A\u77E5\u7236\u7A97\u53E3\n try {\n window.parent.postMessage({\n type: 'getFormRenderMaterial-ready',\n ready: true,\n timestamp: Date.now()\n }, '*');\n } catch(e) {}\n };\n }\n }\n return originalDefineProperty.call(this, obj, prop, descriptor);\n };\n \n // \u5173\u952E\u70B93: \u8BBE\u7F6E\u5171\u4EAB\u5BF9\u8C61\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n \n // \u5173\u952E\u70B94: \u6DFB\u52A0\u91CD\u8BD5\u673A\u5236\n window.retryLoadScript = function(url, maxRetries = 3) {\n return new Promise((resolve, reject) => {\n let retryCount = 0;\n \n const loadScript = () => {\n const script = document.createElement('script');\n script.src = url + (url.includes('?') ? '&' : '?') + 't=' + Date.now();\n script.onload = () => {\n console.log('Script loaded successfully:', url);\n resolve();\n };\n script.onerror = () => {\n retryCount++;\n if (retryCount < maxRetries) {\n console.warn(`Failed to load ${url}, retrying (${retryCount}/${maxRetries})...`);\n setTimeout(loadScript, 1000 * retryCount);\n } else {\n console.error(`Failed to load ${url} after ${maxRetries} attempts`);\n reject(new Error(`Failed to load ${url}`));\n }\n }\n document.head.appendChild(script);\n };\n \n loadScript();\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\n <body>\n <div id=\"lce-container\"></div>\n \n <!-- \u5173\u952E\u70B95: \u52A8\u6001\u52A0\u8F7Dfr-generator\u5E76\u6DFB\u52A0\u91CD\u8BD5 -->\n <script>\n (function() {\n const maxRetries = 3;\n let currentRetry = 0;\n \n function loadFrGenerator() {\n currentRetry++;\n const script = document.createElement('script');\n const url = 'https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js';\n script.src = url + '?t=' + Date.now() + '&retry=' + currentRetry;\n script.type = 'text/javascript';\n \n script.onload = function() {\n console.log('fr-generator loaded successfully, attempt', currentRetry);\n \n // \u7B49\u5F85\u4E00\u6BB5\u65F6\u95F4\u540E\u68C0\u67E5\u51FD\u6570\u662F\u5426\u5DF2\u5B9A\u4E49\n setTimeout(() => {\n if (typeof window.getFormRenderMaterial === 'function') {\n console.log('\u2713 getFormRenderMaterial is now available');\n \n // \u901A\u77E5\u7236\u7A97\u53E3\n try {\n window.parent.postMessage({\n type: 'fr-generator-loaded',\n success: true,\n hasFunction: true,\n timestamp: Date.now()\n }, '*');\n } catch(e) {}\n \n // \u68C0\u67E5\u662F\u5426\u8FD8\u6709\u5176\u4ED6\u9700\u8981\u7684\u51FD\u6570\n if (window.__FR_ENGINE__) {\n console.log('\u2713 __FR_ENGINE__ is available');\n }\n } else {\n console.warn('getFormRenderMaterial still not a function after fr-generator loaded');\n \n // \u5982\u679C\u662F\u6700\u540E\u4E00\u6B21\u5C1D\u8BD5\uFF0C\u521B\u5EFA\u5E94\u6025\u51FD\u6570\n if (currentRetry >= maxRetries) {\n console.warn('Creating emergency fallback function');\n window.getFormRenderMaterial = function() {\n console.warn('Using emergency fallback for getFormRenderMaterial');\n return {};\n };\n } else {\n // \u91CD\u8BD5\n console.warn('Retrying fr-generator load...');\n setTimeout(loadFrGenerator, 1000);\n }\n }\n }, 500);\n };\n \n script.onerror = function() {\n console.error('Failed to load fr-generator, attempt', currentRetry);\n \n if (currentRetry < maxRetries) {\n console.warn('Retrying in 1 second...');\n setTimeout(loadFrGenerator, 1000);\n } else {\n console.error('Max retries reached for fr-generator');\n \n // \u521B\u5EFA\u7D27\u6025\u56DE\u9000\u51FD\u6570\n window.getFormRenderMaterial = function() {\n console.error('Using emergency fallback after max retries');\n return {};\n };\n \n // \u901A\u77E5\u7236\u7A97\u53E3\u52A0\u8F7D\u5931\u8D25\n try {\n window.parent.postMessage({\n type: 'fr-generator-error',\n error: 'Max retries reached',\n timestamp: Date.now()\n }, '*');\n } catch(e) {}\n }\n };\n \n document.body.appendChild(script);\n }\n \n // \u5EF6\u8FDF\u52A0\u8F7D\uFF0C\u786E\u4FDD\u5176\u4ED6\u811A\u672C\u5148\u6267\u884C\n setTimeout(loadFrGenerator, 100);\n })();\n </script>\n \n <!-- \u5173\u952E\u70B96: \u6700\u7EC8\u68C0\u67E5 -->\n <script>\n // \u5728\u9875\u9762\u5B8C\u5168\u52A0\u8F7D\u540E\u505A\u6700\u7EC8\u68C0\u67E5\n window.addEventListener('load', function() {\n setTimeout(() => {\n console.log('Final check - getFormRenderMaterial:', typeof window.getFormRenderMaterial);\n console.log('Final check - __FR_ENGINE__:', !!window.__FR_ENGINE__);\n \n if (typeof window.getFormRenderMaterial !== 'function') {\n console.error('FINAL WARNING: getFormRenderMaterial is not a function!');\n \n // \u5C1D\u8BD5\u91CD\u65B0\u52A0\u8F7D\u5173\u952E\u8D44\u6E90\n const scripts = document.querySelectorAll('script[src*=\"fr-generator\"]');\n if (scripts.length > 0) {\n const script = scripts[0];\n const newScript = document.createElement('script');\n newScript.src = script.src.split('?')[0] + '?emergency=' + Date.now();\n newScript.onload = function() {\n console.log('Emergency script loaded');\n };\n document.body.appendChild(newScript);\n }\n }\n }, 2000);\n });\n </script>\n </body>\n </html>\n ";
2
+ var timestamp = Date.now();
3
+ 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 <!-- \u5C06fr-generator\u811A\u672C\u653E\u5728head\u4E2D\uFF0C\u5E76\u4F7F\u7528defer\u5C5E\u6027\uFF0C\u786E\u4FDD\u5728body\u4E2D\u7684\u811A\u672C\u4E4B\u524D\u6267\u884C -->\n <script defer type=\"text/javascript\" src=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js?t=".concat(timestamp, "\"></script>\n </head>\n\n <body>\n <div id=\"lce-container\"></div>\n </body>\n </html>\n ");
3
4
  return html;
4
5
  };
5
6
  export default (function () {
@@ -7,36 +8,6 @@ export default (function () {
7
8
  iframe.width = '100%';
8
9
  iframe.height = '100%';
9
10
  iframe.frameBorder = '0';
10
-
11
- // 使用唯一ID,避免缓存问题
12
- var iframeId = 'xrender-iframe-' + Date.now() + '-' + Math.random().toString(36).substr(2, 9);
13
- iframe.id = iframeId;
14
- iframe.name = iframeId;
15
-
16
- // 添加加载状态监听
17
- iframe.onload = function () {
18
- console.log('Iframe loaded:', iframeId);
19
-
20
- // 给iframe内部脚本一些时间执行
21
- setTimeout(function () {
22
- try {
23
- // 尝试访问iframe内容
24
- var iframeWindow = iframe.contentWindow;
25
- if (iframeWindow) {
26
- console.log('Iframe contentWindow is accessible', iframeWindow);
27
- }
28
- } catch (e) {
29
- console.error('Error accessing iframe content:', e);
30
- }
31
- }, 1000);
32
- };
33
- iframe.onerror = function (error) {
34
- console.error('Iframe load error:', error);
35
- };
36
-
37
- // 使用srcdoc,但添加时间戳避免缓存
38
- var timestamp = Date.now();
39
- var htmlContent = createIframeContent();
40
- iframe.srcdoc = htmlContent;
11
+ iframe.srcdoc = createIframeContent();
41
12
  return iframe;
42
13
  });
package/es/main.js CHANGED
@@ -19,14 +19,12 @@ var Design = function Design(props, ref) {
19
19
  useImperativeHandle(ref, function () {
20
20
  return {
21
21
  getValue: function getValue() {
22
- var _iframe, _iframe2, _iframe2$contentWindo, _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2, _iframe3$contentWindo3;
23
- console.log("contentWindow", (_iframe = iframe) === null || _iframe === void 0 ? void 0 : _iframe.contentWindow);
24
- console.log("__FR_ENGINE__", (_iframe2 = iframe) === null || _iframe2 === void 0 ? void 0 : (_iframe2$contentWindo = _iframe2.contentWindow) === null || _iframe2$contentWindo === void 0 ? void 0 : _iframe2$contentWindo.__FR_ENGINE__);
25
- return (_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$contentWindo3 = _iframe3$contentWindo2.exportSchema) === null || _iframe3$contentWindo3 === void 0 ? void 0 : _iframe3$contentWindo3.call(_iframe3$contentWindo2);
22
+ var _iframe, _iframe$contentWindow, _iframe$contentWindow2, _iframe$contentWindow3;
23
+ return (_iframe = iframe) === null || _iframe === void 0 ? void 0 : (_iframe$contentWindow = _iframe.contentWindow) === null || _iframe$contentWindow === void 0 ? void 0 : (_iframe$contentWindow2 = _iframe$contentWindow.__FR_ENGINE__) === null || _iframe$contentWindow2 === void 0 ? void 0 : (_iframe$contentWindow3 = _iframe$contentWindow2.exportSchema) === null || _iframe$contentWindow3 === void 0 ? void 0 : _iframe$contentWindow3.call(_iframe$contentWindow2);
26
24
  },
27
25
  setValue: function setValue(schema) {
28
- var _iframe4, _iframe4$contentWindo, _iframe4$contentWindo2, _iframe4$contentWindo3;
29
- return (_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$contentWindo3 = _iframe4$contentWindo2.importSchema) === null || _iframe4$contentWindo3 === void 0 ? void 0 : _iframe4$contentWindo3.call(_iframe4$contentWindo2, schema);
26
+ var _iframe2, _iframe2$contentWindo, _iframe2$contentWindo2, _iframe2$contentWindo3;
27
+ return (_iframe2 = iframe) === null || _iframe2 === void 0 ? void 0 : (_iframe2$contentWindo = _iframe2.contentWindow) === null || _iframe2$contentWindo === void 0 ? void 0 : (_iframe2$contentWindo2 = _iframe2$contentWindo.__FR_ENGINE__) === null || _iframe2$contentWindo2 === void 0 ? void 0 : (_iframe2$contentWindo3 = _iframe2$contentWindo2.importSchema) === null || _iframe2$contentWindo3 === void 0 ? void 0 : _iframe2$contentWindo3.call(_iframe2$contentWindo2, schema);
30
28
  }
31
29
  };
32
30
  });
@@ -38,18 +36,15 @@ var Design = function Design(props, ref) {
38
36
  };
39
37
  }, []);
40
38
  var initIframe = function initIframe() {
41
- console.log("开始创建 iframe");
42
39
  iframe = createIframe();
43
40
  containerRef.current.appendChild(iframe);
44
- console.log("iframe 创建完成:", containerRef, iframe);
45
41
  };
46
42
  var engineOnLoad = function engineOnLoad(event) {
47
- var _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
43
+ var _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2;
48
44
  if (event.data.type !== 'engine-load') {
49
45
  return;
50
46
  }
51
- console.log("拿到 iframe props:", event);
52
- (_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({
53
48
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
54
49
  widgets: widgets,
55
50
  // recordEnable: true,
@@ -5,7 +5,8 @@ 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 <meta http-equiv=\"Cache-Control\" content=\"no-cache, no-store, must-revalidate\">\n <meta http-equiv=\"Pragma\" content=\"no-cache\">\n <meta http-equiv=\"Expires\" content=\"0\">\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 // \u5173\u952E\u70B91: \u5728\u811A\u672C\u52A0\u8F7D\u524D\u5C31\u5B9A\u4E49\u51FD\u6570\u5360\u4F4D\u7B26\n window.getFormRenderMaterial = window.getFormRenderMaterial || function() {\n console.warn('getFormRenderMaterial placeholder called, waiting for real function...');\n return null;\n };\n \n // \u5173\u952E\u70B92: \u76D1\u542C\u51FD\u6570\u5B9A\u4E49\n let originalDefineProperty = Object.defineProperty;\n Object.defineProperty = function(obj, prop, descriptor) {\n if (prop === 'getFormRenderMaterial' && obj === window) {\n console.log('getFormRenderMaterial is being defined...');\n \n // \u4FEE\u6539getter/setter\u4EE5\u786E\u4FDD\u51FD\u6570\u53EF\u7528\n if (descriptor.get) {\n const originalGetter = descriptor.get;\n descriptor.get = function() {\n const result = originalGetter.call(this);\n console.log('getFormRenderMaterial getter called, returning:', typeof result);\n return result;\n };\n }\n \n if (descriptor.set) {\n const originalSetter = descriptor.set;\n descriptor.set = function(value) {\n console.log('getFormRenderMaterial setter called with:', typeof value);\n originalSetter.call(this, value);\n \n // \u51FD\u6570\u8BBE\u7F6E\u540E\u901A\u77E5\u7236\u7A97\u53E3\n try {\n window.parent.postMessage({\n type: 'getFormRenderMaterial-ready',\n ready: true,\n timestamp: Date.now()\n }, '*');\n } catch(e) {}\n };\n }\n }\n return originalDefineProperty.call(this, obj, prop, descriptor);\n };\n \n // \u5173\u952E\u70B93: \u8BBE\u7F6E\u5171\u4EAB\u5BF9\u8C61\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n \n // \u5173\u952E\u70B94: \u6DFB\u52A0\u91CD\u8BD5\u673A\u5236\n window.retryLoadScript = function(url, maxRetries = 3) {\n return new Promise((resolve, reject) => {\n let retryCount = 0;\n \n const loadScript = () => {\n const script = document.createElement('script');\n script.src = url + (url.includes('?') ? '&' : '?') + 't=' + Date.now();\n script.onload = () => {\n console.log('Script loaded successfully:', url);\n resolve();\n };\n script.onerror = () => {\n retryCount++;\n if (retryCount < maxRetries) {\n console.warn(`Failed to load ${url}, retrying (${retryCount}/${maxRetries})...`);\n setTimeout(loadScript, 1000 * retryCount);\n } else {\n console.error(`Failed to load ${url} after ${maxRetries} attempts`);\n reject(new Error(`Failed to load ${url}`));\n }\n }\n document.head.appendChild(script);\n };\n \n loadScript();\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\n <body>\n <div id=\"lce-container\"></div>\n \n <!-- \u5173\u952E\u70B95: \u52A8\u6001\u52A0\u8F7Dfr-generator\u5E76\u6DFB\u52A0\u91CD\u8BD5 -->\n <script>\n (function() {\n const maxRetries = 3;\n let currentRetry = 0;\n \n function loadFrGenerator() {\n currentRetry++;\n const script = document.createElement('script');\n const url = 'https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js';\n script.src = url + '?t=' + Date.now() + '&retry=' + currentRetry;\n script.type = 'text/javascript';\n \n script.onload = function() {\n console.log('fr-generator loaded successfully, attempt', currentRetry);\n \n // \u7B49\u5F85\u4E00\u6BB5\u65F6\u95F4\u540E\u68C0\u67E5\u51FD\u6570\u662F\u5426\u5DF2\u5B9A\u4E49\n setTimeout(() => {\n if (typeof window.getFormRenderMaterial === 'function') {\n console.log('\u2713 getFormRenderMaterial is now available');\n \n // \u901A\u77E5\u7236\u7A97\u53E3\n try {\n window.parent.postMessage({\n type: 'fr-generator-loaded',\n success: true,\n hasFunction: true,\n timestamp: Date.now()\n }, '*');\n } catch(e) {}\n \n // \u68C0\u67E5\u662F\u5426\u8FD8\u6709\u5176\u4ED6\u9700\u8981\u7684\u51FD\u6570\n if (window.__FR_ENGINE__) {\n console.log('\u2713 __FR_ENGINE__ is available');\n }\n } else {\n console.warn('getFormRenderMaterial still not a function after fr-generator loaded');\n \n // \u5982\u679C\u662F\u6700\u540E\u4E00\u6B21\u5C1D\u8BD5\uFF0C\u521B\u5EFA\u5E94\u6025\u51FD\u6570\n if (currentRetry >= maxRetries) {\n console.warn('Creating emergency fallback function');\n window.getFormRenderMaterial = function() {\n console.warn('Using emergency fallback for getFormRenderMaterial');\n return {};\n };\n } else {\n // \u91CD\u8BD5\n console.warn('Retrying fr-generator load...');\n setTimeout(loadFrGenerator, 1000);\n }\n }\n }, 500);\n };\n \n script.onerror = function() {\n console.error('Failed to load fr-generator, attempt', currentRetry);\n \n if (currentRetry < maxRetries) {\n console.warn('Retrying in 1 second...');\n setTimeout(loadFrGenerator, 1000);\n } else {\n console.error('Max retries reached for fr-generator');\n \n // \u521B\u5EFA\u7D27\u6025\u56DE\u9000\u51FD\u6570\n window.getFormRenderMaterial = function() {\n console.error('Using emergency fallback after max retries');\n return {};\n };\n \n // \u901A\u77E5\u7236\u7A97\u53E3\u52A0\u8F7D\u5931\u8D25\n try {\n window.parent.postMessage({\n type: 'fr-generator-error',\n error: 'Max retries reached',\n timestamp: Date.now()\n }, '*');\n } catch(e) {}\n }\n };\n \n document.body.appendChild(script);\n }\n \n // \u5EF6\u8FDF\u52A0\u8F7D\uFF0C\u786E\u4FDD\u5176\u4ED6\u811A\u672C\u5148\u6267\u884C\n setTimeout(loadFrGenerator, 100);\n })();\n </script>\n \n <!-- \u5173\u952E\u70B96: \u6700\u7EC8\u68C0\u67E5 -->\n <script>\n // \u5728\u9875\u9762\u5B8C\u5168\u52A0\u8F7D\u540E\u505A\u6700\u7EC8\u68C0\u67E5\n window.addEventListener('load', function() {\n setTimeout(() => {\n console.log('Final check - getFormRenderMaterial:', typeof window.getFormRenderMaterial);\n console.log('Final check - __FR_ENGINE__:', !!window.__FR_ENGINE__);\n \n if (typeof window.getFormRenderMaterial !== 'function') {\n console.error('FINAL WARNING: getFormRenderMaterial is not a function!');\n \n // \u5C1D\u8BD5\u91CD\u65B0\u52A0\u8F7D\u5173\u952E\u8D44\u6E90\n const scripts = document.querySelectorAll('script[src*=\"fr-generator\"]');\n if (scripts.length > 0) {\n const script = scripts[0];\n const newScript = document.createElement('script');\n newScript.src = script.src.split('?')[0] + '?emergency=' + Date.now();\n newScript.onload = function() {\n console.log('Emergency script loaded');\n };\n document.body.appendChild(newScript);\n }\n }\n }, 2000);\n });\n </script>\n </body>\n </html>\n ";
8
+ var timestamp = Date.now();
9
+ 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 <!-- \u5C06fr-generator\u811A\u672C\u653E\u5728head\u4E2D\uFF0C\u5E76\u4F7F\u7528defer\u5C5E\u6027\uFF0C\u786E\u4FDD\u5728body\u4E2D\u7684\u811A\u672C\u4E4B\u524D\u6267\u884C -->\n <script defer type=\"text/javascript\" src=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js?t=".concat(timestamp, "\"></script>\n </head>\n\n <body>\n <div id=\"lce-container\"></div>\n </body>\n </html>\n ");
9
10
  return html;
10
11
  };
11
12
  var _default = exports.default = function _default() {
@@ -13,36 +14,6 @@ var _default = exports.default = function _default() {
13
14
  iframe.width = '100%';
14
15
  iframe.height = '100%';
15
16
  iframe.frameBorder = '0';
16
-
17
- // 使用唯一ID,避免缓存问题
18
- var iframeId = 'xrender-iframe-' + Date.now() + '-' + Math.random().toString(36).substr(2, 9);
19
- iframe.id = iframeId;
20
- iframe.name = iframeId;
21
-
22
- // 添加加载状态监听
23
- iframe.onload = function () {
24
- console.log('Iframe loaded:', iframeId);
25
-
26
- // 给iframe内部脚本一些时间执行
27
- setTimeout(function () {
28
- try {
29
- // 尝试访问iframe内容
30
- var iframeWindow = iframe.contentWindow;
31
- if (iframeWindow) {
32
- console.log('Iframe contentWindow is accessible', iframeWindow);
33
- }
34
- } catch (e) {
35
- console.error('Error accessing iframe content:', e);
36
- }
37
- }, 1000);
38
- };
39
- iframe.onerror = function (error) {
40
- console.error('Iframe load error:', error);
41
- };
42
-
43
- // 使用srcdoc,但添加时间戳避免缓存
44
- var timestamp = Date.now();
45
- var htmlContent = createIframeContent();
46
- iframe.srcdoc = htmlContent;
17
+ iframe.srcdoc = createIframeContent();
47
18
  return iframe;
48
19
  };
package/lib/main.js CHANGED
@@ -27,14 +27,12 @@ var Design = function Design(props, ref) {
27
27
  (0, _react.useImperativeHandle)(ref, function () {
28
28
  return {
29
29
  getValue: function getValue() {
30
- var _iframe, _iframe2, _iframe2$contentWindo, _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2, _iframe3$contentWindo3;
31
- console.log("contentWindow", (_iframe = iframe) === null || _iframe === void 0 ? void 0 : _iframe.contentWindow);
32
- console.log("__FR_ENGINE__", (_iframe2 = iframe) === null || _iframe2 === void 0 ? void 0 : (_iframe2$contentWindo = _iframe2.contentWindow) === null || _iframe2$contentWindo === void 0 ? void 0 : _iframe2$contentWindo.__FR_ENGINE__);
33
- return (_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$contentWindo3 = _iframe3$contentWindo2.exportSchema) === null || _iframe3$contentWindo3 === void 0 ? void 0 : _iframe3$contentWindo3.call(_iframe3$contentWindo2);
30
+ var _iframe, _iframe$contentWindow, _iframe$contentWindow2, _iframe$contentWindow3;
31
+ return (_iframe = iframe) === null || _iframe === void 0 ? void 0 : (_iframe$contentWindow = _iframe.contentWindow) === null || _iframe$contentWindow === void 0 ? void 0 : (_iframe$contentWindow2 = _iframe$contentWindow.__FR_ENGINE__) === null || _iframe$contentWindow2 === void 0 ? void 0 : (_iframe$contentWindow3 = _iframe$contentWindow2.exportSchema) === null || _iframe$contentWindow3 === void 0 ? void 0 : _iframe$contentWindow3.call(_iframe$contentWindow2);
34
32
  },
35
33
  setValue: function setValue(schema) {
36
- var _iframe4, _iframe4$contentWindo, _iframe4$contentWindo2, _iframe4$contentWindo3;
37
- return (_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$contentWindo3 = _iframe4$contentWindo2.importSchema) === null || _iframe4$contentWindo3 === void 0 ? void 0 : _iframe4$contentWindo3.call(_iframe4$contentWindo2, schema);
34
+ var _iframe2, _iframe2$contentWindo, _iframe2$contentWindo2, _iframe2$contentWindo3;
35
+ return (_iframe2 = iframe) === null || _iframe2 === void 0 ? void 0 : (_iframe2$contentWindo = _iframe2.contentWindow) === null || _iframe2$contentWindo === void 0 ? void 0 : (_iframe2$contentWindo2 = _iframe2$contentWindo.__FR_ENGINE__) === null || _iframe2$contentWindo2 === void 0 ? void 0 : (_iframe2$contentWindo3 = _iframe2$contentWindo2.importSchema) === null || _iframe2$contentWindo3 === void 0 ? void 0 : _iframe2$contentWindo3.call(_iframe2$contentWindo2, schema);
38
36
  }
39
37
  };
40
38
  });
@@ -46,18 +44,15 @@ var Design = function Design(props, ref) {
46
44
  };
47
45
  }, []);
48
46
  var initIframe = function initIframe() {
49
- console.log("开始创建 iframe");
50
47
  iframe = (0, _createIframe.default)();
51
48
  containerRef.current.appendChild(iframe);
52
- console.log("iframe 创建完成:", containerRef, iframe);
53
49
  };
54
50
  var engineOnLoad = function engineOnLoad(event) {
55
- var _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
51
+ var _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2;
56
52
  if (event.data.type !== 'engine-load') {
57
53
  return;
58
54
  }
59
- console.log("拿到 iframe props:", event);
60
- (_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({
61
56
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
62
57
  widgets: widgets,
63
58
  // recordEnable: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzdadelu/schema-builder",
3
- "version": "1.0.0-alpha.44",
3
+ "version": "1.0.0-alpha.46",
4
4
  "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5
5
  "keywords": [
6
6
  "Form",