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

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,7 @@
1
+ // createIframe.ts
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 // \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 ";
3
+ var timestamp = new Date().getTime();
4
+ 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>\n // \u5168\u9762\u7684 DOM \u62E6\u622A\u65B9\u6848\n (function() {\n console.log('\u542F\u52A8\u5168\u9762\u7684 DOM \u62E6\u622A\u65B9\u6848...');\n \n const targetResources = [\n 'react-simulator-renderer',\n 'moment.min.js',\n 'lodash.min.js',\n 'antd.min.js',\n 'next.min.js',\n 'index.umd.min.js',\n 'ant-design-icons-cdn',\n 'lowcode-react-simulator-renderer',\n 'alicdn.com/t/font_'\n ];\n \n // \u5224\u65AD\u662F\u5426\u76EE\u6807\u8D44\u6E90\n function isTargetResource(url) {\n return targetResources.some(resource => url.includes(resource));\n }\n \n // \u6DFB\u52A0\u65F6\u95F4\u6233\n function addTimestamp(url) {\n if (!url) return url;\n if (url.includes('t=')) return url;\n const separator = url.includes('?') ? '&' : '?';\n return url + separator + 't=' + Date.now();\n }\n \n // 1. \u62E6\u622A XMLHttpRequest\n if (window.XMLHttpRequest) {\n console.log('11111');\n\n const OriginalXHR = window.XMLHttpRequest;\n window.XMLHttpRequest = function() {\n const xhr = new OriginalXHR();\n const originalOpen = xhr.open;\n \n xhr.open = function(method, url, async, user, password) {\n if (isTargetResource(url)) {\n const modifiedUrl = addTimestamp(url);\n console.log('\u62E6\u622A XHR \u8BF7\u6C42:', url, '->', modifiedUrl);\n url = modifiedUrl;\n }\n return originalOpen.call(this, method, url, async, user, password);\n };\n \n return xhr;\n };\n }\n \n // 2. \u62E6\u622A fetch\n if (window.fetch) {\n console.log('22222');\n\n const originalFetch = window.fetch;\n window.fetch = function(input, init) {\n let url = typeof input === 'string' ? input : input.url;\n \n if (isTargetResource(url)) {\n const modifiedUrl = addTimestamp(url);\n console.log('\u62E6\u622A fetch \u8BF7\u6C42:', url, '->', modifiedUrl);\n \n if (typeof input === 'string') {\n input = modifiedUrl;\n } else {\n input = new Request(modifiedUrl, input);\n }\n }\n \n return originalFetch.call(this, input, init);\n };\n }\n \n // 3. \u62E6\u622A\u52A8\u6001\u5BFC\u5165\n if (window.importScripts) {\n console.log('333333');\n const originalImportScripts = window.importScripts;\n window.importScripts = function(...urls) {\n const modifiedUrls = urls.map(url => {\n if (isTargetResource(url)) {\n return addTimestamp(url);\n }\n return url;\n });\n console.log('\u62E6\u622A importScripts:', urls, '->', modifiedUrls);\n return originalImportScripts.apply(this, modifiedUrls);\n };\n }\n \n // 4. \u62E6\u622A createElement\n const originalCreateElement = document.createElement;\n document.createElement = function(tagName, options) {\n console.log('44444', tagName, options);\n const element = originalCreateElement.call(this, tagName, options);\n \n if (tagName.toLowerCase() === 'script') {\n // \u62E6\u622A src \u5C5E\u6027\n const descriptor = Object.getOwnPropertyDescriptor(element, 'src');\n if (descriptor && descriptor.set) {\n Object.defineProperty(element, 'src', {\n set: function(value) {\n if (isTargetResource(value)) {\n value = addTimestamp(value);\n console.log('\u521B\u5EFA script \u65F6\u4FEE\u6539 src:', value);\n }\n descriptor.set.call(this, value);\n },\n get: descriptor.get,\n configurable: true\n });\n }\n \n // \u62E6\u622A setAttribute\n const originalSetAttribute = element.setAttribute;\n element.setAttribute = function(name, value) {\n if (name === 'src' && isTargetResource(value)) {\n value = addTimestamp(value);\n console.log('\u521B\u5EFA script \u65F6\u4FEE\u6539 setAttribute:', value);\n }\n return originalSetAttribute.call(this, name, value);\n };\n }\n \n return element;\n };\n \n // 5. \u62E6\u622A appendChild\n const originalAppendChild = Node.prototype.appendChild;\n Node.prototype.appendChild = function(child) {\n if (child.tagName === 'SCRIPT' && child.src) {\n if (isTargetResource(child.src) && !child.src.includes('t=')) {\n const modifiedSrc = addTimestamp(child.src);\n console.log('appendChild \u65F6\u4FEE\u6539 script src:', child.src, '->', modifiedSrc);\n \n // \u521B\u5EFA\u65B0\u7684 script \u5143\u7D20\n const newScript = document.createElement('script');\n for (let attr of child.attributes) {\n if (attr.name === 'src') {\n newScript.src = modifiedSrc;\n } else {\n newScript.setAttribute(attr.name, attr.value);\n }\n }\n \n if (child.textContent) {\n newScript.textContent = child.textContent;\n }\n \n // \u590D\u5236\u4E8B\u4EF6\u76D1\u542C\u5668\uFF08\u5C3D\u53EF\u80FD\uFF09\n newScript.onload = child.onload;\n newScript.onerror = child.onerror;\n \n // \u66FF\u6362\u5143\u7D20\n return originalAppendChild.call(this, newScript);\n }\n }\n return originalAppendChild.call(this, child);\n };\n \n // 6. \u62E6\u622A insertBefore\n const originalInsertBefore = Node.prototype.insertBefore;\n Node.prototype.insertBefore = function(child, ref) {\n if (child.tagName === 'SCRIPT' && child.src) {\n if (isTargetResource(child.src) && !child.src.includes('t=')) {\n const modifiedSrc = addTimestamp(child.src);\n console.log('insertBefore \u65F6\u4FEE\u6539 script src:', child.src, '->', modifiedSrc);\n \n // \u521B\u5EFA\u65B0\u7684 script \u5143\u7D20\n const newScript = document.createElement('script');\n for (let attr of child.attributes) {\n if (attr.name === 'src') {\n newScript.src = modifiedSrc;\n } else {\n newScript.setAttribute(attr.name, attr.value);\n }\n }\n \n if (child.textContent) {\n newScript.textContent = child.textContent;\n }\n \n newScript.onload = child.onload;\n newScript.onerror = child.onerror;\n \n // \u66FF\u6362\u5143\u7D20\n return originalInsertBefore.call(this, newScript, ref);\n }\n }\n return originalInsertBefore.call(this, child, ref);\n };\n \n // 7. \u76D1\u542C\u7F51\u7EDC\u8BF7\u6C42\n if (window.performance && performance.getEntriesByType) {\n // \u76D1\u63A7\u5DF2\u7ECF\u52A0\u8F7D\u7684\u8D44\u6E90\n const resources = performance.getEntriesByType('resource');\n resources.forEach(resource => {\n if (resource.initiatorType === 'script' && isTargetResource(resource.name)) {\n console.log('\u5DF2\u52A0\u8F7D\u7684\u811A\u672C:', resource.name);\n }\n });\n }\n \n // 8. \u76D1\u63A7\u672A\u6765\u7684\u8D44\u6E90\u52A0\u8F7D\n if ('PerformanceObserver' in window) {\n const observer = new PerformanceObserver((list) => {\n list.getEntries().forEach(entry => {\n if (entry.initiatorType === 'script' && isTargetResource(entry.name)) {\n console.log('\u65B0\u811A\u672C\u52A0\u8F7D:', entry.name);\n \n // \u68C0\u67E5\u662F\u5426\u6709\u65F6\u95F4\u6233\n if (entry.name.includes('t=')) {\n console.log('\u2713 \u811A\u672C\u5305\u542B\u65F6\u95F4\u6233');\n } else {\n console.warn('\u2717 \u811A\u672C\u7F3A\u5C11\u65F6\u95F4\u6233');\n }\n }\n });\n });\n \n observer.observe({ entryTypes: ['resource'] });\n }\n \n console.log('\u5168\u9762\u7684 DOM \u62E6\u622A\u65B9\u6848\u5DF2\u542F\u52A8');\n })();\n </script>\n </head>\n\n <body>\n <div id=\"lce-container\"></div>\n \n <!-- \u52A0\u8F7D\u57FA\u7840\u5E93 -->\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 <!-- fr-generator -->\n <script type=\"text/javascript\" src=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js?t=".concat(timestamp, "\"></script>\n \n <!-- \u989D\u5916\u7684\u9A8C\u8BC1\u811A\u672C -->\n <script>\n // \u9A8C\u8BC1\u62E6\u622A\u662F\u5426\u6210\u529F\n window.addEventListener('load', () => {\n console.log('\u9875\u9762\u52A0\u8F7D\u5B8C\u6210\uFF0C\u68C0\u67E5\u6240\u6709\u811A\u672C...');\n \n const allScripts = document.querySelectorAll('script[src]');\n console.log(`\u603B\u5171 ${allScripts.length} \u4E2A\u811A\u672C`);\n \n let interceptedCount = 0;\n allScripts.forEach((script, index) => {\n const src = script.src;\n const hasTimestamp = src.includes('t=');\n \n console.log(`\u811A\u672C ${index}: ${hasTimestamp ? '\u2713' : '\u2717'} ${src}`);\n \n if (hasTimestamp) {\n interceptedCount++;\n }\n });\n \n console.log(`\u6210\u529F\u62E6\u622A: ${interceptedCount}/${allScripts.length}`);\n });\n </script>\n </body>\n </html>\n ");
3
5
  return html;
4
6
  };
5
7
  export default (function () {
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,20 +36,41 @@ 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, _outerIframeWindow$__;
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
+ var outerIframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
48
+ if (!outerIframeWindow) return;
49
+
50
+ // 尝试监听外层 iframe 内部文档的变化
51
+ var innerDoc = outerIframeWindow.document;
52
+ if (!innerDoc) return;
53
+
54
+ // 创建一个 MutationObserver 来监听外层 iframe 内部 iframe 的创建
55
+ var innerObserver = new MutationObserver(function (mutations) {
56
+ console.log('检测到内层 iframe 被添加......');
57
+ mutations.forEach(function (mutation) {
58
+ mutation.addedNodes.forEach(function (node) {
59
+ console.log('检测到内层 iframe 被添加', node);
60
+ });
61
+ });
62
+ });
63
+
64
+ // 开始观察外层 iframe 内部 body 的变化
65
+ innerObserver.observe(innerDoc, {
66
+ childList: true,
67
+ subtree: true
68
+ });
69
+
70
+ // 初始化 __FR_ENGINE__
71
+ (_outerIframeWindow$__ = outerIframeWindow.__FR_ENGINE__) === null || _outerIframeWindow$__ === void 0 ? void 0 : _outerIframeWindow$__.init(_objectSpread({
52
72
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
53
73
  widgets: widgets,
54
- // recordEnable: true,
55
74
  logo: {
56
75
  title: 'XRender'
57
76
  }
@@ -4,8 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ // createIframe.ts
7
8
  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 ";
9
+ var timestamp = new Date().getTime();
10
+ 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>\n // \u5168\u9762\u7684 DOM \u62E6\u622A\u65B9\u6848\n (function() {\n console.log('\u542F\u52A8\u5168\u9762\u7684 DOM \u62E6\u622A\u65B9\u6848...');\n \n const targetResources = [\n 'react-simulator-renderer',\n 'moment.min.js',\n 'lodash.min.js',\n 'antd.min.js',\n 'next.min.js',\n 'index.umd.min.js',\n 'ant-design-icons-cdn',\n 'lowcode-react-simulator-renderer',\n 'alicdn.com/t/font_'\n ];\n \n // \u5224\u65AD\u662F\u5426\u76EE\u6807\u8D44\u6E90\n function isTargetResource(url) {\n return targetResources.some(resource => url.includes(resource));\n }\n \n // \u6DFB\u52A0\u65F6\u95F4\u6233\n function addTimestamp(url) {\n if (!url) return url;\n if (url.includes('t=')) return url;\n const separator = url.includes('?') ? '&' : '?';\n return url + separator + 't=' + Date.now();\n }\n \n // 1. \u62E6\u622A XMLHttpRequest\n if (window.XMLHttpRequest) {\n console.log('11111');\n\n const OriginalXHR = window.XMLHttpRequest;\n window.XMLHttpRequest = function() {\n const xhr = new OriginalXHR();\n const originalOpen = xhr.open;\n \n xhr.open = function(method, url, async, user, password) {\n if (isTargetResource(url)) {\n const modifiedUrl = addTimestamp(url);\n console.log('\u62E6\u622A XHR \u8BF7\u6C42:', url, '->', modifiedUrl);\n url = modifiedUrl;\n }\n return originalOpen.call(this, method, url, async, user, password);\n };\n \n return xhr;\n };\n }\n \n // 2. \u62E6\u622A fetch\n if (window.fetch) {\n console.log('22222');\n\n const originalFetch = window.fetch;\n window.fetch = function(input, init) {\n let url = typeof input === 'string' ? input : input.url;\n \n if (isTargetResource(url)) {\n const modifiedUrl = addTimestamp(url);\n console.log('\u62E6\u622A fetch \u8BF7\u6C42:', url, '->', modifiedUrl);\n \n if (typeof input === 'string') {\n input = modifiedUrl;\n } else {\n input = new Request(modifiedUrl, input);\n }\n }\n \n return originalFetch.call(this, input, init);\n };\n }\n \n // 3. \u62E6\u622A\u52A8\u6001\u5BFC\u5165\n if (window.importScripts) {\n console.log('333333');\n const originalImportScripts = window.importScripts;\n window.importScripts = function(...urls) {\n const modifiedUrls = urls.map(url => {\n if (isTargetResource(url)) {\n return addTimestamp(url);\n }\n return url;\n });\n console.log('\u62E6\u622A importScripts:', urls, '->', modifiedUrls);\n return originalImportScripts.apply(this, modifiedUrls);\n };\n }\n \n // 4. \u62E6\u622A createElement\n const originalCreateElement = document.createElement;\n document.createElement = function(tagName, options) {\n console.log('44444', tagName, options);\n const element = originalCreateElement.call(this, tagName, options);\n \n if (tagName.toLowerCase() === 'script') {\n // \u62E6\u622A src \u5C5E\u6027\n const descriptor = Object.getOwnPropertyDescriptor(element, 'src');\n if (descriptor && descriptor.set) {\n Object.defineProperty(element, 'src', {\n set: function(value) {\n if (isTargetResource(value)) {\n value = addTimestamp(value);\n console.log('\u521B\u5EFA script \u65F6\u4FEE\u6539 src:', value);\n }\n descriptor.set.call(this, value);\n },\n get: descriptor.get,\n configurable: true\n });\n }\n \n // \u62E6\u622A setAttribute\n const originalSetAttribute = element.setAttribute;\n element.setAttribute = function(name, value) {\n if (name === 'src' && isTargetResource(value)) {\n value = addTimestamp(value);\n console.log('\u521B\u5EFA script \u65F6\u4FEE\u6539 setAttribute:', value);\n }\n return originalSetAttribute.call(this, name, value);\n };\n }\n \n return element;\n };\n \n // 5. \u62E6\u622A appendChild\n const originalAppendChild = Node.prototype.appendChild;\n Node.prototype.appendChild = function(child) {\n if (child.tagName === 'SCRIPT' && child.src) {\n if (isTargetResource(child.src) && !child.src.includes('t=')) {\n const modifiedSrc = addTimestamp(child.src);\n console.log('appendChild \u65F6\u4FEE\u6539 script src:', child.src, '->', modifiedSrc);\n \n // \u521B\u5EFA\u65B0\u7684 script \u5143\u7D20\n const newScript = document.createElement('script');\n for (let attr of child.attributes) {\n if (attr.name === 'src') {\n newScript.src = modifiedSrc;\n } else {\n newScript.setAttribute(attr.name, attr.value);\n }\n }\n \n if (child.textContent) {\n newScript.textContent = child.textContent;\n }\n \n // \u590D\u5236\u4E8B\u4EF6\u76D1\u542C\u5668\uFF08\u5C3D\u53EF\u80FD\uFF09\n newScript.onload = child.onload;\n newScript.onerror = child.onerror;\n \n // \u66FF\u6362\u5143\u7D20\n return originalAppendChild.call(this, newScript);\n }\n }\n return originalAppendChild.call(this, child);\n };\n \n // 6. \u62E6\u622A insertBefore\n const originalInsertBefore = Node.prototype.insertBefore;\n Node.prototype.insertBefore = function(child, ref) {\n if (child.tagName === 'SCRIPT' && child.src) {\n if (isTargetResource(child.src) && !child.src.includes('t=')) {\n const modifiedSrc = addTimestamp(child.src);\n console.log('insertBefore \u65F6\u4FEE\u6539 script src:', child.src, '->', modifiedSrc);\n \n // \u521B\u5EFA\u65B0\u7684 script \u5143\u7D20\n const newScript = document.createElement('script');\n for (let attr of child.attributes) {\n if (attr.name === 'src') {\n newScript.src = modifiedSrc;\n } else {\n newScript.setAttribute(attr.name, attr.value);\n }\n }\n \n if (child.textContent) {\n newScript.textContent = child.textContent;\n }\n \n newScript.onload = child.onload;\n newScript.onerror = child.onerror;\n \n // \u66FF\u6362\u5143\u7D20\n return originalInsertBefore.call(this, newScript, ref);\n }\n }\n return originalInsertBefore.call(this, child, ref);\n };\n \n // 7. \u76D1\u542C\u7F51\u7EDC\u8BF7\u6C42\n if (window.performance && performance.getEntriesByType) {\n // \u76D1\u63A7\u5DF2\u7ECF\u52A0\u8F7D\u7684\u8D44\u6E90\n const resources = performance.getEntriesByType('resource');\n resources.forEach(resource => {\n if (resource.initiatorType === 'script' && isTargetResource(resource.name)) {\n console.log('\u5DF2\u52A0\u8F7D\u7684\u811A\u672C:', resource.name);\n }\n });\n }\n \n // 8. \u76D1\u63A7\u672A\u6765\u7684\u8D44\u6E90\u52A0\u8F7D\n if ('PerformanceObserver' in window) {\n const observer = new PerformanceObserver((list) => {\n list.getEntries().forEach(entry => {\n if (entry.initiatorType === 'script' && isTargetResource(entry.name)) {\n console.log('\u65B0\u811A\u672C\u52A0\u8F7D:', entry.name);\n \n // \u68C0\u67E5\u662F\u5426\u6709\u65F6\u95F4\u6233\n if (entry.name.includes('t=')) {\n console.log('\u2713 \u811A\u672C\u5305\u542B\u65F6\u95F4\u6233');\n } else {\n console.warn('\u2717 \u811A\u672C\u7F3A\u5C11\u65F6\u95F4\u6233');\n }\n }\n });\n });\n \n observer.observe({ entryTypes: ['resource'] });\n }\n \n console.log('\u5168\u9762\u7684 DOM \u62E6\u622A\u65B9\u6848\u5DF2\u542F\u52A8');\n })();\n </script>\n </head>\n\n <body>\n <div id=\"lce-container\"></div>\n \n <!-- \u52A0\u8F7D\u57FA\u7840\u5E93 -->\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 <!-- fr-generator -->\n <script type=\"text/javascript\" src=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js?t=".concat(timestamp, "\"></script>\n \n <!-- \u989D\u5916\u7684\u9A8C\u8BC1\u811A\u672C -->\n <script>\n // \u9A8C\u8BC1\u62E6\u622A\u662F\u5426\u6210\u529F\n window.addEventListener('load', () => {\n console.log('\u9875\u9762\u52A0\u8F7D\u5B8C\u6210\uFF0C\u68C0\u67E5\u6240\u6709\u811A\u672C...');\n \n const allScripts = document.querySelectorAll('script[src]');\n console.log(`\u603B\u5171 ${allScripts.length} \u4E2A\u811A\u672C`);\n \n let interceptedCount = 0;\n allScripts.forEach((script, index) => {\n const src = script.src;\n const hasTimestamp = src.includes('t=');\n \n console.log(`\u811A\u672C ${index}: ${hasTimestamp ? '\u2713' : '\u2717'} ${src}`);\n \n if (hasTimestamp) {\n interceptedCount++;\n }\n });\n \n console.log(`\u6210\u529F\u62E6\u622A: ${interceptedCount}/${allScripts.length}`);\n });\n </script>\n </body>\n </html>\n ");
9
11
  return html;
10
12
  };
11
13
  var _default = exports.default = function _default() {
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,20 +44,41 @@ 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, _outerIframeWindow$__;
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
+ var outerIframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
56
+ if (!outerIframeWindow) return;
57
+
58
+ // 尝试监听外层 iframe 内部文档的变化
59
+ var innerDoc = outerIframeWindow.document;
60
+ if (!innerDoc) return;
61
+
62
+ // 创建一个 MutationObserver 来监听外层 iframe 内部 iframe 的创建
63
+ var innerObserver = new MutationObserver(function (mutations) {
64
+ console.log('检测到内层 iframe 被添加......');
65
+ mutations.forEach(function (mutation) {
66
+ mutation.addedNodes.forEach(function (node) {
67
+ console.log('检测到内层 iframe 被添加', node);
68
+ });
69
+ });
70
+ });
71
+
72
+ // 开始观察外层 iframe 内部 body 的变化
73
+ innerObserver.observe(innerDoc, {
74
+ childList: true,
75
+ subtree: true
76
+ });
77
+
78
+ // 初始化 __FR_ENGINE__
79
+ (_outerIframeWindow$__ = outerIframeWindow.__FR_ENGINE__) === null || _outerIframeWindow$__ === void 0 ? void 0 : _outerIframeWindow$__.init(_objectSpread({
60
80
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
61
81
  widgets: widgets,
62
- // recordEnable: true,
63
82
  logo: {
64
83
  title: 'XRender'
65
84
  }
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.120",
4
4
  "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5
5
  "keywords": [
6
6
  "Form",