@zzdadelu/schema-builder 1.0.0-alpha.13 → 1.0.0-alpha.131

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
+ import * as defaultSetting from './settings';
1
2
  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 // \u5171\u4EAB\u7236\u7A97\u53E3\u7684 React/ReactDOM\uFF08\u4FDD\u6301\u539F\u884C\u4E3A\uFF09\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n\n // \u53EF\u63A7\u987A\u5E8F\u52A0\u8F7D\u811A\u672C\uFF08\u5728\u6DFB\u52A0\u4E4B\u524D\u68C0\u67E5\u5168\u5C40\u4EE5\u907F\u514D\u91CD\u590D\u52A0\u8F7D\uFF09\n function loadScriptsSequential(urls, cb) {\n var i = 0;\n function next() {\n if (i >= urls.length) { cb && cb(); return; }\n var url = urls[i++];\n // \u5982\u679C\u5E93\u5DF2\u5B58\u5728\u4E8E\u5168\u5C40\uFF0C\u5219\u8DF3\u8FC7\u52A0\u8F7D\uFF08\u907F\u514D\u91CD\u590D\u6CE8\u518C\uFF09\n try {\n if (url.indexOf('engine-core') !== -1 && window.AliLowCodeEngine) return next();\n if (url.indexOf('engine-ext') !== -1 && window.AliLowCodeEngineExt) return next();\n if (url.indexOf('fr-generator') !== -1 && window.__FR_GENERATOR_LOADED__) return next();\n } catch (e) {}\n var s = document.createElement('script');\n s.src = url;\n s.crossOrigin = 'anonymous';\n s.onload = next;\n s.onerror = function() { next(); };\n document.head.appendChild(s);\n }\n next();\n }\n\n // \u66F4\u7A33\u5065\u7684 getFormRenderMaterial \u4EE3\u7406\uFF1A\u4F7F\u7528 defineProperty \u62E6\u622A\u8D4B\u503C\u5E76\u7F13\u5B58\u8C03\u7528\u961F\u5217\n (function installGetFormRenderMaterialProxy() {\n if (window.__getFormRenderMaterial_installed) return;\n window.__getFormRenderMaterial_installed = true;\n window.__getFormRenderMaterial_queue = [];\n\n Object.defineProperty(window, 'getFormRenderMaterial', {\n configurable: true,\n enumerable: true,\n get: function() {\n if (window.__real_getFormRenderMaterial) return window.__real_getFormRenderMaterial;\n // \u8FD4\u56DE\u4E00\u4E2A\u4E34\u65F6\u51FD\u6570\uFF0C\u628A\u8C03\u7528\u53C2\u6570\u5165\u961F\n return function() {\n window.__getFormRenderMaterial_queue.push(Array.prototype.slice.call(arguments));\n };\n },\n set: function(val) {\n // \u53EA\u6709\u51FD\u6570\u624D\u89C6\u4E3A\u771F\u5B9E\u5B9E\u73B0\uFF1B\u5426\u5219\u5FFD\u7565\u8D4B\u503C\u5E76\u8BB0\u5F55\u8B66\u544A\n if (typeof val === 'function') {\n window.__real_getFormRenderMaterial = val;\n // \u628A\u961F\u5217\u91CC\u7684\u8C03\u7528\u91CD\u653E\u5230\u771F\u5B9E\u5B9E\u73B0\u4E0A\n var q = window.__getFormRenderMaterial_queue.splice(0);\n q.forEach(function(args) {\n try { window.__real_getFormRenderMaterial.apply(null, args); } catch (e) {}\n });\n // \u4E3A\u6027\u80FD\uFF0C\u628A window.getFormRenderMaterial \u76F4\u63A5\u5B9A\u4E49\u4E3A\u771F\u5B9E\u51FD\u6570\uFF08\u53EF\u88AB\u540E\u7EED\u8986\u76D6\uFF09\n try {\n Object.defineProperty(window, 'getFormRenderMaterial', {\n value: window.__real_getFormRenderMaterial,\n writable: true,\n configurable: true\n });\n } catch (e) {}\n } else {\n console.warn('Ignored non-function assignment to window.getFormRenderMaterial:', val);\n }\n }\n });\n\n // \u5982\u679C\u7236\u7A97\u53E3\uFF08\u540C\u6E90\uFF09\u5DF2\u6709\u5B9E\u73B0\uFF0C\u5219\u4EE3\u7406\u7ED9\u7236\u7A97\u53E3\n try {\n setTimeout(function tryProxyParent() {\n try {\n if (window.parent && window.parent !== window && typeof window.parent.getFormRenderMaterial === 'function') {\n window.getFormRenderMaterial = function() {\n return window.parent.getFormRenderMaterial.apply(window.parent, arguments);\n };\n }\n } catch (e) {}\n }, 0);\n } catch (e) {}\n })();\n </script>\n </head>\n <body>\n <div id=\"lce-container\"></div>\n\n <script>\n // \u987A\u5E8F\u52A0\u8F7D\uFF1A\u5728\u52A0\u8F7D\u5B8C\u6210\u540E\u518D\u52A0\u8F7D fr-generator\uFF1Bfr-generator \u52A0\u8F7D\u540E\u6807\u8BB0\u5E76 postMessage \u7ED9\u7236\u7A97\u53E3\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 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 try {\n window.__FR_GENERATOR_LOADED__ = true;\n parent.postMessage({ type: 'engine-load' }, '*');\n } catch (e) {}\n };\n s.onerror = function() {\n try { parent.postMessage({ type: 'engine-load' }, '*'); } catch(e) {}\n };\n document.body.appendChild(s);\n });\n </script>\n \n </body>\n </html>\n ";
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 </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
4
  return html;
4
5
  };
5
6
  export default (function () {
@@ -8,5 +9,11 @@ export default (function () {
8
9
  iframe.height = '100%';
9
10
  iframe.frameBorder = '0';
10
11
  iframe.srcdoc = createIframeContent();
12
+ // 关键修复:将 material 加载函数注入到设计器 iframe 的 window 中
13
+ if (iframe.contentWindow) {
14
+ iframe.contentWindow.getFormRenderMaterial = function () {
15
+ return defaultSetting;
16
+ };
17
+ }
11
18
  return iframe;
12
19
  });
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,17 +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
41
  };
45
42
  var engineOnLoad = function engineOnLoad(event) {
46
- var _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
43
+ var _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2;
47
44
  if (event.data.type !== 'engine-load') {
48
45
  return;
49
46
  }
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({
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({
52
48
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
53
49
  widgets: widgets,
54
50
  // recordEnable: true,
@@ -1,11 +1,14 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = void 0;
8
+ var defaultSetting = _interopRequireWildcard(require("./settings"));
9
+ 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); }
7
10
  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 // \u5171\u4EAB\u7236\u7A97\u53E3\u7684 React/ReactDOM\uFF08\u4FDD\u6301\u539F\u884C\u4E3A\uFF09\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n\n // \u53EF\u63A7\u987A\u5E8F\u52A0\u8F7D\u811A\u672C\uFF08\u5728\u6DFB\u52A0\u4E4B\u524D\u68C0\u67E5\u5168\u5C40\u4EE5\u907F\u514D\u91CD\u590D\u52A0\u8F7D\uFF09\n function loadScriptsSequential(urls, cb) {\n var i = 0;\n function next() {\n if (i >= urls.length) { cb && cb(); return; }\n var url = urls[i++];\n // \u5982\u679C\u5E93\u5DF2\u5B58\u5728\u4E8E\u5168\u5C40\uFF0C\u5219\u8DF3\u8FC7\u52A0\u8F7D\uFF08\u907F\u514D\u91CD\u590D\u6CE8\u518C\uFF09\n try {\n if (url.indexOf('engine-core') !== -1 && window.AliLowCodeEngine) return next();\n if (url.indexOf('engine-ext') !== -1 && window.AliLowCodeEngineExt) return next();\n if (url.indexOf('fr-generator') !== -1 && window.__FR_GENERATOR_LOADED__) return next();\n } catch (e) {}\n var s = document.createElement('script');\n s.src = url;\n s.crossOrigin = 'anonymous';\n s.onload = next;\n s.onerror = function() { next(); };\n document.head.appendChild(s);\n }\n next();\n }\n\n // \u66F4\u7A33\u5065\u7684 getFormRenderMaterial \u4EE3\u7406\uFF1A\u4F7F\u7528 defineProperty \u62E6\u622A\u8D4B\u503C\u5E76\u7F13\u5B58\u8C03\u7528\u961F\u5217\n (function installGetFormRenderMaterialProxy() {\n if (window.__getFormRenderMaterial_installed) return;\n window.__getFormRenderMaterial_installed = true;\n window.__getFormRenderMaterial_queue = [];\n\n Object.defineProperty(window, 'getFormRenderMaterial', {\n configurable: true,\n enumerable: true,\n get: function() {\n if (window.__real_getFormRenderMaterial) return window.__real_getFormRenderMaterial;\n // \u8FD4\u56DE\u4E00\u4E2A\u4E34\u65F6\u51FD\u6570\uFF0C\u628A\u8C03\u7528\u53C2\u6570\u5165\u961F\n return function() {\n window.__getFormRenderMaterial_queue.push(Array.prototype.slice.call(arguments));\n };\n },\n set: function(val) {\n // \u53EA\u6709\u51FD\u6570\u624D\u89C6\u4E3A\u771F\u5B9E\u5B9E\u73B0\uFF1B\u5426\u5219\u5FFD\u7565\u8D4B\u503C\u5E76\u8BB0\u5F55\u8B66\u544A\n if (typeof val === 'function') {\n window.__real_getFormRenderMaterial = val;\n // \u628A\u961F\u5217\u91CC\u7684\u8C03\u7528\u91CD\u653E\u5230\u771F\u5B9E\u5B9E\u73B0\u4E0A\n var q = window.__getFormRenderMaterial_queue.splice(0);\n q.forEach(function(args) {\n try { window.__real_getFormRenderMaterial.apply(null, args); } catch (e) {}\n });\n // \u4E3A\u6027\u80FD\uFF0C\u628A window.getFormRenderMaterial \u76F4\u63A5\u5B9A\u4E49\u4E3A\u771F\u5B9E\u51FD\u6570\uFF08\u53EF\u88AB\u540E\u7EED\u8986\u76D6\uFF09\n try {\n Object.defineProperty(window, 'getFormRenderMaterial', {\n value: window.__real_getFormRenderMaterial,\n writable: true,\n configurable: true\n });\n } catch (e) {}\n } else {\n console.warn('Ignored non-function assignment to window.getFormRenderMaterial:', val);\n }\n }\n });\n\n // \u5982\u679C\u7236\u7A97\u53E3\uFF08\u540C\u6E90\uFF09\u5DF2\u6709\u5B9E\u73B0\uFF0C\u5219\u4EE3\u7406\u7ED9\u7236\u7A97\u53E3\n try {\n setTimeout(function tryProxyParent() {\n try {\n if (window.parent && window.parent !== window && typeof window.parent.getFormRenderMaterial === 'function') {\n window.getFormRenderMaterial = function() {\n return window.parent.getFormRenderMaterial.apply(window.parent, arguments);\n };\n }\n } catch (e) {}\n }, 0);\n } catch (e) {}\n })();\n </script>\n </head>\n <body>\n <div id=\"lce-container\"></div>\n\n <script>\n // \u987A\u5E8F\u52A0\u8F7D\uFF1A\u5728\u52A0\u8F7D\u5B8C\u6210\u540E\u518D\u52A0\u8F7D fr-generator\uFF1Bfr-generator \u52A0\u8F7D\u540E\u6807\u8BB0\u5E76 postMessage \u7ED9\u7236\u7A97\u53E3\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 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 try {\n window.__FR_GENERATOR_LOADED__ = true;\n parent.postMessage({ type: 'engine-load' }, '*');\n } catch (e) {}\n };\n s.onerror = function() {\n try { parent.postMessage({ type: 'engine-load' }, '*'); } catch(e) {}\n };\n document.body.appendChild(s);\n });\n </script>\n \n </body>\n </html>\n ";
11
+ 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
12
  return html;
10
13
  };
11
14
  var _default = exports.default = function _default() {
@@ -14,5 +17,11 @@ var _default = exports.default = function _default() {
14
17
  iframe.height = '100%';
15
18
  iframe.frameBorder = '0';
16
19
  iframe.srcdoc = createIframeContent();
20
+ // 关键修复:将 material 加载函数注入到设计器 iframe 的 window 中
21
+ if (iframe.contentWindow) {
22
+ iframe.contentWindow.getFormRenderMaterial = function () {
23
+ return defaultSetting;
24
+ };
25
+ }
17
26
  return iframe;
18
27
  };
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,17 +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
49
  };
53
50
  var engineOnLoad = function engineOnLoad(event) {
54
- var _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
51
+ var _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2;
55
52
  if (event.data.type !== 'engine-load') {
56
53
  return;
57
54
  }
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({
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({
60
56
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
61
57
  widgets: widgets,
62
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.13",
3
+ "version": "1.0.0-alpha.131",
4
4
  "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5
5
  "keywords": [
6
6
  "Form",
@@ -22,9 +22,11 @@
22
22
  "license": "MIT",
23
23
  "main": "lib/index.js",
24
24
  "module": "es/index.js",
25
+ "unpkg": "dist/index.min.js",
25
26
  "files": [
26
27
  "es",
27
28
  "lib",
29
+ "dist",
28
30
  "package.json"
29
31
  ],
30
32
  "scripts": {
package/CHANGELOG.md DELETED
@@ -1 +0,0 @@
1
- # Change Log