@zzdadelu/schema-builder 1.0.0-alpha.12 → 1.0.0-alpha.121

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 // \u8BA9 iframe \u4F7F\u7528\u7236\u7A97\u53E3\u7684 React/ReactDOM \u5B9E\u4F8B\uFF08\u4FDD\u6301\u73B0\u6709\u884C\u4E3A\uFF09\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n\n // \u987A\u5E8F\u52A0\u8F7D\u811A\u672C\u7684\u7B80\u5355\u51FD\u6570\uFF08\u53EF\u63A7\u987A\u5E8F\uFF09\n function loadScriptsSequential(urls, cb) {\n var i = 0;\n function next() {\n if (i >= urls.length) { cb && cb(); return; }\n var s = document.createElement('script');\n s.src = urls[i++];\n s.crossOrigin = 'anonymous';\n s.onload = next;\n s.onerror = function() {\n // \u5931\u8D25\u65F6\u4E5F\u7EE7\u7EED\uFF0C\u6216\u8005\u5728\u6B64\u5904\u505A\u66F4\u4E25\u683C\u7684\u9519\u8BEF\u5904\u7406\n next();\n };\n document.head.appendChild(s);\n }\n next();\n }\n\n // \u5B89\u88C5\u4E00\u4E2A\u5B89\u5168\u7684 shim\uFF1A\u5728\u771F\u5B9E\u5B9E\u73B0\u51C6\u5907\u597D\u524D\u7F13\u51B2\u8C03\u7528\n (function installGetFormRenderMaterialShim() {\n var shim = function() {\n if (window.__real_getFormRenderMaterial) {\n return window.__real_getFormRenderMaterial.apply(this, arguments);\n }\n window.__getFormRenderMaterial_queue.push(Array.prototype.slice.call(arguments));\n };\n if (!window.__getFormRenderMaterial_queue) window.__getFormRenderMaterial_queue = [];\n // \u5982\u679C\u5916\u90E8\u811A\u672C\u5DF2\u7ECF\u5B9A\u4E49\u4E86\u8FD9\u4E2A\u51FD\u6570\uFF0C\u5219\u4E0D\u8986\u76D6\u5B83\uFF08\u4F46\u6211\u4EEC\u4ECD\u4F7F\u7528\u961F\u5217\u5904\u7406\u60C5\u51B5\uFF09\n if (typeof window.getFormRenderMaterial === 'function') {\n // \u5373\u5DF2\u5B58\u5728\uFF0C\u6620\u5C04\u4E3A\u771F\u5B9E\u5B9E\u73B0\n window.__real_getFormRenderMaterial = window.getFormRenderMaterial;\n window.getFormRenderMaterial = function() {\n return window.__real_getFormRenderMaterial.apply(this, arguments);\n };\n } else {\n window.getFormRenderMaterial = shim;\n }\n\n // \u6BCF\u9694\u4E00\u6BB5\u65F6\u95F4\u68C0\u6D4B\uFF1A\u5982\u679C\u5916\u90E8\u811A\u672C\u540E\u6765\u6CE8\u518C\u4E86\u771F\u5B9E\u5B9E\u73B0\uFF0C\u7ED1\u5B9A\u5E76\u91CD\u653E\u961F\u5217\n function finalize() {\n try {\n // \u5982\u679C\u5916\u90E8\u811A\u672C\u8986\u76D6\u4E86 shim\uFF08\u5373\u73B0\u5728\u7684 getFormRenderMaterial \u4E0D\u662F shim\uFF09\n if (window.getFormRenderMaterial !== shim && typeof window.getFormRenderMaterial === 'function') {\n window.__real_getFormRenderMaterial = window.getFormRenderMaterial;\n window.getFormRenderMaterial = function() {\n return window.__real_getFormRenderMaterial.apply(this, arguments);\n };\n } else if (!window.__real_getFormRenderMaterial) {\n // \u5C1D\u8BD5\u4EE3\u7406\u7236\u7A97\u53E3\uFF08\u540C\u6E90\u60C5\u5F62\uFF09\n if (window.parent && window.parent !== window && typeof window.parent.getFormRenderMaterial === 'function') {\n window.__real_getFormRenderMaterial = function() {\n return window.parent.getFormRenderMaterial.apply(window.parent, arguments);\n };\n window.getFormRenderMaterial = function() {\n return window.__real_getFormRenderMaterial.apply(this, arguments);\n };\n }\n }\n } catch (e) {\n // \u8DE8\u57DF\u8BBF\u95EE\u6216\u5176\u5B83\u9519\u8BEF\uFF0C\u5219\u4E0D\u629B\u51FA\n }\n\n if (window.__real_getFormRenderMaterial && window.__getFormRenderMaterial_queue && window.__getFormRenderMaterial_queue.length) {\n var q = window.__getFormRenderMaterial_queue.splice(0);\n q.forEach(function(args) {\n try {\n window.getFormRenderMaterial.apply(null, args);\n } catch (err) {\n // \u5FFD\u7565\u5355\u4E2A\u91CD\u653E\u9519\u8BEF\n }\n });\n }\n\n // \u5982\u679C\u8FD8\u6CA1\u6709\u771F\u5B9E\u5B9E\u73B0\uFF0C\u7EE7\u7EED\u5C1D\u8BD5\uFF08\u76F4\u5230\u5916\u90E8\u811A\u672C\u5C31\u7EEA\uFF09\n if (!window.__real_getFormRenderMaterial) {\n setTimeout(finalize, 50);\n }\n }\n\n setTimeout(finalize, 0);\n })();\n </script>\n </head>\n <body>\n <div id=\"lce-container\"></div>\n\n <script>\n // \u8FD9\u91CC\u663E\u5F0F\u6309\u9700\u987A\u5E8F\u52A0\u8F7D\u5916\u90E8\u811A\u672C\uFF0C\u6700\u540E\u52A0\u8F7D fr-generator\n loadScriptsSequential([\n \"https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js\",\n \"https://g.alicdn.com/platform/c/react15-polyfill/0.0.1/dist/index.js\",\n \"https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js\",\n \"https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js\",\n \"https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.js\",\n \"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/js/engine-core.js\",\n \"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/js/engine-ext.js\"\n ], function() {\n // \u6240\u6709\u6838\u5FC3\u4F9D\u8D56\u52A0\u8F7D\u5B8C\uFF0C\u518D\u52A0\u8F7D fr-generator\uFF08\u4FDD\u6301\u4E4B\u524D\u7684\u884C\u4E3A\uFF09\n var s = document.createElement('script');\n s.type = 'text/javascript';\n s.src = 'https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js';\n s.onload = function() {\n // fr-generator \u52A0\u8F7D\u5B8C\u6BD5\u540E\uFF0C\u5411\u7236\u7A97\u53E3\u53D1\u5C31\u7EEA\u6D88\u606F\uFF08\u539F\u5DE5\u7A0B\u4F7F\u7528 postMessage 'engine-load'\uFF09\n try {\n parent.postMessage({ type: 'engine-load' }, '*');\n } catch (e) {}\n };\n document.body.appendChild(s);\n });\n </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
@@ -15,18 +15,18 @@ var Design = function Design(props, ref) {
15
15
  var widgets = props.widgets,
16
16
  settings = props.settings,
17
17
  restProps = _objectWithoutProperties(props, _excluded);
18
- var containerRef = useRef();
18
+ var containerRef = useRef(null);
19
+ var iframeRef = useRef(null); // 使用 ref 代替全局变量
20
+
19
21
  useImperativeHandle(ref, function () {
20
22
  return {
21
23
  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);
24
+ var _iframeRef$current, _iframeRef$current$co, _iframeRef$current$co2, _iframeRef$current$co3;
25
+ return (_iframeRef$current = iframeRef.current) === null || _iframeRef$current === void 0 ? void 0 : (_iframeRef$current$co = _iframeRef$current.contentWindow) === null || _iframeRef$current$co === void 0 ? void 0 : (_iframeRef$current$co2 = _iframeRef$current$co.__FR_ENGINE__) === null || _iframeRef$current$co2 === void 0 ? void 0 : (_iframeRef$current$co3 = _iframeRef$current$co2.exportSchema) === null || _iframeRef$current$co3 === void 0 ? void 0 : _iframeRef$current$co3.call(_iframeRef$current$co2);
26
26
  },
27
27
  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);
28
+ var _iframeRef$current2, _iframeRef$current2$c, _iframeRef$current2$c2, _iframeRef$current2$c3;
29
+ return (_iframeRef$current2 = iframeRef.current) === null || _iframeRef$current2 === void 0 ? void 0 : (_iframeRef$current2$c = _iframeRef$current2.contentWindow) === null || _iframeRef$current2$c === void 0 ? void 0 : (_iframeRef$current2$c2 = _iframeRef$current2$c.__FR_ENGINE__) === null || _iframeRef$current2$c2 === void 0 ? void 0 : (_iframeRef$current2$c3 = _iframeRef$current2$c2.importSchema) === null || _iframeRef$current2$c3 === void 0 ? void 0 : _iframeRef$current2$c3.call(_iframeRef$current2$c2, schema);
30
30
  }
31
31
  };
32
32
  });
@@ -38,17 +38,15 @@ var Design = function Design(props, ref) {
38
38
  };
39
39
  }, []);
40
40
  var initIframe = function initIframe() {
41
- console.log("开始创建 iframe");
42
41
  iframe = createIframe();
43
42
  containerRef.current.appendChild(iframe);
44
43
  };
45
44
  var engineOnLoad = function engineOnLoad(event) {
46
- var _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
45
+ var _iframe, _iframe$contentWindow, _iframe$contentWindow2;
47
46
  if (event.data.type !== 'engine-load') {
48
47
  return;
49
48
  }
50
- console.log("拿到 iframe props:", event);
51
- (_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({
49
+ (_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$contentWindow2.init(_objectSpread({
52
50
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
53
51
  widgets: widgets,
54
52
  // recordEnable: true,
@@ -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 // \u8BA9 iframe \u4F7F\u7528\u7236\u7A97\u53E3\u7684 React/ReactDOM \u5B9E\u4F8B\uFF08\u4FDD\u6301\u73B0\u6709\u884C\u4E3A\uFF09\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n\n // \u987A\u5E8F\u52A0\u8F7D\u811A\u672C\u7684\u7B80\u5355\u51FD\u6570\uFF08\u53EF\u63A7\u987A\u5E8F\uFF09\n function loadScriptsSequential(urls, cb) {\n var i = 0;\n function next() {\n if (i >= urls.length) { cb && cb(); return; }\n var s = document.createElement('script');\n s.src = urls[i++];\n s.crossOrigin = 'anonymous';\n s.onload = next;\n s.onerror = function() {\n // \u5931\u8D25\u65F6\u4E5F\u7EE7\u7EED\uFF0C\u6216\u8005\u5728\u6B64\u5904\u505A\u66F4\u4E25\u683C\u7684\u9519\u8BEF\u5904\u7406\n next();\n };\n document.head.appendChild(s);\n }\n next();\n }\n\n // \u5B89\u88C5\u4E00\u4E2A\u5B89\u5168\u7684 shim\uFF1A\u5728\u771F\u5B9E\u5B9E\u73B0\u51C6\u5907\u597D\u524D\u7F13\u51B2\u8C03\u7528\n (function installGetFormRenderMaterialShim() {\n var shim = function() {\n if (window.__real_getFormRenderMaterial) {\n return window.__real_getFormRenderMaterial.apply(this, arguments);\n }\n window.__getFormRenderMaterial_queue.push(Array.prototype.slice.call(arguments));\n };\n if (!window.__getFormRenderMaterial_queue) window.__getFormRenderMaterial_queue = [];\n // \u5982\u679C\u5916\u90E8\u811A\u672C\u5DF2\u7ECF\u5B9A\u4E49\u4E86\u8FD9\u4E2A\u51FD\u6570\uFF0C\u5219\u4E0D\u8986\u76D6\u5B83\uFF08\u4F46\u6211\u4EEC\u4ECD\u4F7F\u7528\u961F\u5217\u5904\u7406\u60C5\u51B5\uFF09\n if (typeof window.getFormRenderMaterial === 'function') {\n // \u5373\u5DF2\u5B58\u5728\uFF0C\u6620\u5C04\u4E3A\u771F\u5B9E\u5B9E\u73B0\n window.__real_getFormRenderMaterial = window.getFormRenderMaterial;\n window.getFormRenderMaterial = function() {\n return window.__real_getFormRenderMaterial.apply(this, arguments);\n };\n } else {\n window.getFormRenderMaterial = shim;\n }\n\n // \u6BCF\u9694\u4E00\u6BB5\u65F6\u95F4\u68C0\u6D4B\uFF1A\u5982\u679C\u5916\u90E8\u811A\u672C\u540E\u6765\u6CE8\u518C\u4E86\u771F\u5B9E\u5B9E\u73B0\uFF0C\u7ED1\u5B9A\u5E76\u91CD\u653E\u961F\u5217\n function finalize() {\n try {\n // \u5982\u679C\u5916\u90E8\u811A\u672C\u8986\u76D6\u4E86 shim\uFF08\u5373\u73B0\u5728\u7684 getFormRenderMaterial \u4E0D\u662F shim\uFF09\n if (window.getFormRenderMaterial !== shim && typeof window.getFormRenderMaterial === 'function') {\n window.__real_getFormRenderMaterial = window.getFormRenderMaterial;\n window.getFormRenderMaterial = function() {\n return window.__real_getFormRenderMaterial.apply(this, arguments);\n };\n } else if (!window.__real_getFormRenderMaterial) {\n // \u5C1D\u8BD5\u4EE3\u7406\u7236\u7A97\u53E3\uFF08\u540C\u6E90\u60C5\u5F62\uFF09\n if (window.parent && window.parent !== window && typeof window.parent.getFormRenderMaterial === 'function') {\n window.__real_getFormRenderMaterial = function() {\n return window.parent.getFormRenderMaterial.apply(window.parent, arguments);\n };\n window.getFormRenderMaterial = function() {\n return window.__real_getFormRenderMaterial.apply(this, arguments);\n };\n }\n }\n } catch (e) {\n // \u8DE8\u57DF\u8BBF\u95EE\u6216\u5176\u5B83\u9519\u8BEF\uFF0C\u5219\u4E0D\u629B\u51FA\n }\n\n if (window.__real_getFormRenderMaterial && window.__getFormRenderMaterial_queue && window.__getFormRenderMaterial_queue.length) {\n var q = window.__getFormRenderMaterial_queue.splice(0);\n q.forEach(function(args) {\n try {\n window.getFormRenderMaterial.apply(null, args);\n } catch (err) {\n // \u5FFD\u7565\u5355\u4E2A\u91CD\u653E\u9519\u8BEF\n }\n });\n }\n\n // \u5982\u679C\u8FD8\u6CA1\u6709\u771F\u5B9E\u5B9E\u73B0\uFF0C\u7EE7\u7EED\u5C1D\u8BD5\uFF08\u76F4\u5230\u5916\u90E8\u811A\u672C\u5C31\u7EEA\uFF09\n if (!window.__real_getFormRenderMaterial) {\n setTimeout(finalize, 50);\n }\n }\n\n setTimeout(finalize, 0);\n })();\n </script>\n </head>\n <body>\n <div id=\"lce-container\"></div>\n\n <script>\n // \u8FD9\u91CC\u663E\u5F0F\u6309\u9700\u987A\u5E8F\u52A0\u8F7D\u5916\u90E8\u811A\u672C\uFF0C\u6700\u540E\u52A0\u8F7D fr-generator\n loadScriptsSequential([\n \"https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js\",\n \"https://g.alicdn.com/platform/c/react15-polyfill/0.0.1/dist/index.js\",\n \"https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js\",\n \"https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js\",\n \"https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.js\",\n \"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/js/engine-core.js\",\n \"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/js/engine-ext.js\"\n ], function() {\n // \u6240\u6709\u6838\u5FC3\u4F9D\u8D56\u52A0\u8F7D\u5B8C\uFF0C\u518D\u52A0\u8F7D fr-generator\uFF08\u4FDD\u6301\u4E4B\u524D\u7684\u884C\u4E3A\uFF09\n var s = document.createElement('script');\n s.type = 'text/javascript';\n s.src = 'https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js';\n s.onload = function() {\n // fr-generator \u52A0\u8F7D\u5B8C\u6BD5\u540E\uFF0C\u5411\u7236\u7A97\u53E3\u53D1\u5C31\u7EEA\u6D88\u606F\uFF08\u539F\u5DE5\u7A0B\u4F7F\u7528 postMessage 'engine-load'\uFF09\n try {\n parent.postMessage({ type: 'engine-load' }, '*');\n } catch (e) {}\n };\n document.body.appendChild(s);\n });\n </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
@@ -23,18 +23,18 @@ var Design = function Design(props, ref) {
23
23
  var widgets = props.widgets,
24
24
  settings = props.settings,
25
25
  restProps = _objectWithoutProperties(props, _excluded);
26
- var containerRef = (0, _react.useRef)();
26
+ var containerRef = (0, _react.useRef)(null);
27
+ var iframeRef = (0, _react.useRef)(null); // 使用 ref 代替全局变量
28
+
27
29
  (0, _react.useImperativeHandle)(ref, function () {
28
30
  return {
29
31
  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);
32
+ var _iframeRef$current, _iframeRef$current$co, _iframeRef$current$co2, _iframeRef$current$co3;
33
+ return (_iframeRef$current = iframeRef.current) === null || _iframeRef$current === void 0 ? void 0 : (_iframeRef$current$co = _iframeRef$current.contentWindow) === null || _iframeRef$current$co === void 0 ? void 0 : (_iframeRef$current$co2 = _iframeRef$current$co.__FR_ENGINE__) === null || _iframeRef$current$co2 === void 0 ? void 0 : (_iframeRef$current$co3 = _iframeRef$current$co2.exportSchema) === null || _iframeRef$current$co3 === void 0 ? void 0 : _iframeRef$current$co3.call(_iframeRef$current$co2);
34
34
  },
35
35
  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);
36
+ var _iframeRef$current2, _iframeRef$current2$c, _iframeRef$current2$c2, _iframeRef$current2$c3;
37
+ return (_iframeRef$current2 = iframeRef.current) === null || _iframeRef$current2 === void 0 ? void 0 : (_iframeRef$current2$c = _iframeRef$current2.contentWindow) === null || _iframeRef$current2$c === void 0 ? void 0 : (_iframeRef$current2$c2 = _iframeRef$current2$c.__FR_ENGINE__) === null || _iframeRef$current2$c2 === void 0 ? void 0 : (_iframeRef$current2$c3 = _iframeRef$current2$c2.importSchema) === null || _iframeRef$current2$c3 === void 0 ? void 0 : _iframeRef$current2$c3.call(_iframeRef$current2$c2, schema);
38
38
  }
39
39
  };
40
40
  });
@@ -46,17 +46,15 @@ var Design = function Design(props, ref) {
46
46
  };
47
47
  }, []);
48
48
  var initIframe = function initIframe() {
49
- console.log("开始创建 iframe");
50
49
  iframe = (0, _createIframe.default)();
51
50
  containerRef.current.appendChild(iframe);
52
51
  };
53
52
  var engineOnLoad = function engineOnLoad(event) {
54
- var _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
53
+ var _iframe, _iframe$contentWindow, _iframe$contentWindow2;
55
54
  if (event.data.type !== 'engine-load') {
56
55
  return;
57
56
  }
58
- console.log("拿到 iframe props:", event);
59
- (_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({
57
+ (_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$contentWindow2.init(_objectSpread({
60
58
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
61
59
  widgets: widgets,
62
60
  // recordEnable: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzdadelu/schema-builder",
3
- "version": "1.0.0-alpha.12",
3
+ "version": "1.0.0-alpha.121",
4
4
  "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5
5
  "keywords": [
6
6
  "Form",
package/CHANGELOG.md DELETED
@@ -1 +0,0 @@
1
- # Change Log