@zzdadelu/schema-builder 1.0.0-alpha.2 → 1.0.0-alpha.21
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.
- package/es/createIframe.js +1 -1
- package/es/main.js +12 -8
- package/lib/createIframe.js +1 -1
- package/lib/main.js +12 -8
- package/package.json +1 -1
package/es/createIframe.js
CHANGED
|
@@ -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 window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n </script>\n \n <script
|
|
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 // ---- \u5B89\u5168\u4EE3\u7406\uFF1A\u786E\u4FDD getFormRenderMaterial \u8C03\u7528\u4E0D\u4F1A\u76F4\u63A5\u629B\u5F02\u5E38 ----\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 return function() {\n window.__getFormRenderMaterial_queue.push(Array.prototype.slice.call(arguments));\n };\n },\n set: function(val) {\n if (typeof val === 'function') {\n window.__real_getFormRenderMaterial = val;\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 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 // \u5C1D\u8BD5\u4EE3\u7406\u7236\u7A97\u53E3\uFF08\u540C\u6E90\u60C5\u51B5\u4E0B\uFF09\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\n // ---- \u987A\u5E8F\u52A0\u8F7D\u811A\u672C\u7684\u5E2E\u52A9\u51FD\u6570 ----\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 try {\n if (url.indexOf('engine-core') !== -1 && window.AliLowCodeEngine) return next();\n if (url.indexOf('engine-ext') !== -1 && window.AliLowCodeEngineExt) 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 // ---- \u5F3A\u5236\u4ECE\u7F51\u7EDC\u62C9\u53D6\u811A\u672C\u5E76\u6CE8\u5165\uFF08fetch + blob\uFF09\uFF0C\u5931\u8D25\u65F6\u56DE\u9000\u5230\u5E26\u65F6\u95F4\u6233\u7684\u666E\u901A\u52A0\u8F7D ----\n function injectScriptFromNetwork(url, onload, onerror) {\n // \u4F7F\u7528 fetch \u5F3A\u5236\u4E0D\u8D70\u7F13\u5B58\uFF08no-store\uFF09\uFF0C\u9700\u8981 CDN \u652F\u6301 CORS\n try {\n fetch(url, { cache: 'no-store', mode: 'cors' })\n .then(function(resp) {\n if (!resp.ok) throw new Error('fetch failed ' + resp.status);\n return resp.text();\n })\n .then(function(code) {\n var blob = new Blob([code], { type: 'text/javascript' });\n var blobUrl = URL.createObjectURL(blob);\n var s = document.createElement('script');\n s.src = blobUrl;\n s.onload = function() {\n URL.revokeObjectURL(blobUrl);\n onload && onload();\n };\n s.onerror = function(e) {\n URL.revokeObjectURL(blobUrl);\n (onerror && onerror(e));\n };\n document.head.appendChild(s);\n })\n .catch(function(err) {\n // fetch \u5931\u8D25\uFF08\u53EF\u80FD CORS\uFF09\uFF0C\u56DE\u9000\u5230\u5E26\u65F6\u95F4\u6233\u7684\u666E\u901A\u811A\u672C\u52A0\u8F7D\n var fallback = url + '?t=' + Date.now();\n var s2 = document.createElement('script');\n s2.src = fallback;\n s2.crossOrigin = 'anonymous';\n s2.onload = function() { onload && onload(); };\n s2.onerror = function(e) { onerror && onerror(e); };\n document.head.appendChild(s2);\n });\n } catch (e) {\n // \u73AF\u5883\u4E0D\u652F\u6301 fetch\uFF0C\u76F4\u63A5\u56DE\u9000\u5230\u5E26\u65F6\u95F4\u6233\n var s3 = document.createElement('script');\n s3.src = url + '?t=' + Date.now();\n s3.crossOrigin = 'anonymous';\n s3.onload = function() { onload && onload(); };\n s3.onerror = function(e) { onerror && onerror(e); };\n document.head.appendChild(s3);\n }\n }\n </script>\n </head>\n <body>\n <div id=\"lce-container\"></div>\n\n <script>\n // \u5148\u987A\u5E8F\u52A0\u8F7D\u901A\u7528\u4F9D\u8D56\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 // \u5728\u6838\u5FC3\u4F9D\u8D56\u5C31\u7EEA\u540E\uFF0C\u5F3A\u5236\u4ECE\u7F51\u7EDC\u62C9\u53D6 react-simulator-renderer\uFF08\u907F\u514D\u4F7F\u7528\u7F13\u5B58\uFF09\n var rendererUrl = 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js';\n injectScriptFromNetwork(rendererUrl, function() {\n // renderer \u6CE8\u5165\u6210\u529F\u540E\u518D\u6CE8\u5165 fr-generator\uFF0C\u4FDD\u8BC1\u52A0\u8F7D\u987A\u5E8F\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 }, function(err) {\n // renderer \u6CE8\u5165\u5931\u8D25\uFF08fetch+blob \u6216\u5E26 timestamp \u7684\u56DE\u9000\u90FD\u5931\u8D25\uFF09\uFF0C\u4ECD\u7136\u5C1D\u8BD5\u52A0\u8F7D fr-generator\uFF08\u964D\u7EA7\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 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 });\n </script>\n </body>\n </html>\n ";
|
|
3
3
|
return html;
|
|
4
4
|
};
|
|
5
5
|
export default (function () {
|
package/es/main.js
CHANGED
|
@@ -19,32 +19,36 @@ var Design = function Design(props, ref) {
|
|
|
19
19
|
useImperativeHandle(ref, function () {
|
|
20
20
|
return {
|
|
21
21
|
getValue: function getValue() {
|
|
22
|
-
var _iframe,
|
|
23
|
-
|
|
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
26
|
},
|
|
25
27
|
setValue: function setValue(schema) {
|
|
26
|
-
var
|
|
27
|
-
return (
|
|
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
30
|
}
|
|
29
31
|
};
|
|
30
32
|
});
|
|
31
33
|
useEffect(function () {
|
|
32
34
|
initIframe();
|
|
33
|
-
window.addEventListener('
|
|
35
|
+
window.addEventListener('load', engineOnLoad);
|
|
34
36
|
return function () {
|
|
35
|
-
window.removeEventListener('
|
|
37
|
+
window.removeEventListener('load', engineOnLoad);
|
|
36
38
|
};
|
|
37
39
|
}, []);
|
|
38
40
|
var initIframe = function initIframe() {
|
|
41
|
+
console.log("开始创建 iframe");
|
|
39
42
|
iframe = createIframe();
|
|
40
43
|
containerRef.current.appendChild(iframe);
|
|
41
44
|
};
|
|
42
45
|
var engineOnLoad = function engineOnLoad(event) {
|
|
43
|
-
var
|
|
46
|
+
var _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
|
|
44
47
|
if (event.data.type !== 'engine-load') {
|
|
45
48
|
return;
|
|
46
49
|
}
|
|
47
|
-
(
|
|
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({
|
|
48
52
|
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
49
53
|
widgets: widgets,
|
|
50
54
|
// recordEnable: true,
|
package/lib/createIframe.js
CHANGED
|
@@ -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 window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n </script>\n \n <script
|
|
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 // ---- \u5B89\u5168\u4EE3\u7406\uFF1A\u786E\u4FDD getFormRenderMaterial \u8C03\u7528\u4E0D\u4F1A\u76F4\u63A5\u629B\u5F02\u5E38 ----\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 return function() {\n window.__getFormRenderMaterial_queue.push(Array.prototype.slice.call(arguments));\n };\n },\n set: function(val) {\n if (typeof val === 'function') {\n window.__real_getFormRenderMaterial = val;\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 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 // \u5C1D\u8BD5\u4EE3\u7406\u7236\u7A97\u53E3\uFF08\u540C\u6E90\u60C5\u51B5\u4E0B\uFF09\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\n // ---- \u987A\u5E8F\u52A0\u8F7D\u811A\u672C\u7684\u5E2E\u52A9\u51FD\u6570 ----\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 try {\n if (url.indexOf('engine-core') !== -1 && window.AliLowCodeEngine) return next();\n if (url.indexOf('engine-ext') !== -1 && window.AliLowCodeEngineExt) 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 // ---- \u5F3A\u5236\u4ECE\u7F51\u7EDC\u62C9\u53D6\u811A\u672C\u5E76\u6CE8\u5165\uFF08fetch + blob\uFF09\uFF0C\u5931\u8D25\u65F6\u56DE\u9000\u5230\u5E26\u65F6\u95F4\u6233\u7684\u666E\u901A\u52A0\u8F7D ----\n function injectScriptFromNetwork(url, onload, onerror) {\n // \u4F7F\u7528 fetch \u5F3A\u5236\u4E0D\u8D70\u7F13\u5B58\uFF08no-store\uFF09\uFF0C\u9700\u8981 CDN \u652F\u6301 CORS\n try {\n fetch(url, { cache: 'no-store', mode: 'cors' })\n .then(function(resp) {\n if (!resp.ok) throw new Error('fetch failed ' + resp.status);\n return resp.text();\n })\n .then(function(code) {\n var blob = new Blob([code], { type: 'text/javascript' });\n var blobUrl = URL.createObjectURL(blob);\n var s = document.createElement('script');\n s.src = blobUrl;\n s.onload = function() {\n URL.revokeObjectURL(blobUrl);\n onload && onload();\n };\n s.onerror = function(e) {\n URL.revokeObjectURL(blobUrl);\n (onerror && onerror(e));\n };\n document.head.appendChild(s);\n })\n .catch(function(err) {\n // fetch \u5931\u8D25\uFF08\u53EF\u80FD CORS\uFF09\uFF0C\u56DE\u9000\u5230\u5E26\u65F6\u95F4\u6233\u7684\u666E\u901A\u811A\u672C\u52A0\u8F7D\n var fallback = url + '?t=' + Date.now();\n var s2 = document.createElement('script');\n s2.src = fallback;\n s2.crossOrigin = 'anonymous';\n s2.onload = function() { onload && onload(); };\n s2.onerror = function(e) { onerror && onerror(e); };\n document.head.appendChild(s2);\n });\n } catch (e) {\n // \u73AF\u5883\u4E0D\u652F\u6301 fetch\uFF0C\u76F4\u63A5\u56DE\u9000\u5230\u5E26\u65F6\u95F4\u6233\n var s3 = document.createElement('script');\n s3.src = url + '?t=' + Date.now();\n s3.crossOrigin = 'anonymous';\n s3.onload = function() { onload && onload(); };\n s3.onerror = function(e) { onerror && onerror(e); };\n document.head.appendChild(s3);\n }\n }\n </script>\n </head>\n <body>\n <div id=\"lce-container\"></div>\n\n <script>\n // \u5148\u987A\u5E8F\u52A0\u8F7D\u901A\u7528\u4F9D\u8D56\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 // \u5728\u6838\u5FC3\u4F9D\u8D56\u5C31\u7EEA\u540E\uFF0C\u5F3A\u5236\u4ECE\u7F51\u7EDC\u62C9\u53D6 react-simulator-renderer\uFF08\u907F\u514D\u4F7F\u7528\u7F13\u5B58\uFF09\n var rendererUrl = 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js';\n injectScriptFromNetwork(rendererUrl, function() {\n // renderer \u6CE8\u5165\u6210\u529F\u540E\u518D\u6CE8\u5165 fr-generator\uFF0C\u4FDD\u8BC1\u52A0\u8F7D\u987A\u5E8F\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 }, function(err) {\n // renderer \u6CE8\u5165\u5931\u8D25\uFF08fetch+blob \u6216\u5E26 timestamp \u7684\u56DE\u9000\u90FD\u5931\u8D25\uFF09\uFF0C\u4ECD\u7136\u5C1D\u8BD5\u52A0\u8F7D fr-generator\uFF08\u964D\u7EA7\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 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 });\n </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
|
@@ -27,32 +27,36 @@ var Design = function Design(props, ref) {
|
|
|
27
27
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
28
28
|
return {
|
|
29
29
|
getValue: function getValue() {
|
|
30
|
-
var _iframe,
|
|
31
|
-
|
|
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
34
|
},
|
|
33
35
|
setValue: function setValue(schema) {
|
|
34
|
-
var
|
|
35
|
-
return (
|
|
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
38
|
}
|
|
37
39
|
};
|
|
38
40
|
});
|
|
39
41
|
(0, _react.useEffect)(function () {
|
|
40
42
|
initIframe();
|
|
41
|
-
window.addEventListener('
|
|
43
|
+
window.addEventListener('load', engineOnLoad);
|
|
42
44
|
return function () {
|
|
43
|
-
window.removeEventListener('
|
|
45
|
+
window.removeEventListener('load', engineOnLoad);
|
|
44
46
|
};
|
|
45
47
|
}, []);
|
|
46
48
|
var initIframe = function initIframe() {
|
|
49
|
+
console.log("开始创建 iframe");
|
|
47
50
|
iframe = (0, _createIframe.default)();
|
|
48
51
|
containerRef.current.appendChild(iframe);
|
|
49
52
|
};
|
|
50
53
|
var engineOnLoad = function engineOnLoad(event) {
|
|
51
|
-
var
|
|
54
|
+
var _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
|
|
52
55
|
if (event.data.type !== 'engine-load') {
|
|
53
56
|
return;
|
|
54
57
|
}
|
|
55
|
-
(
|
|
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({
|
|
56
60
|
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
57
61
|
widgets: widgets,
|
|
58
62
|
// recordEnable: true,
|