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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,5 @@
1
- // createIframe.ts
2
1
  var createIframeContent = function createIframeContent() {
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 ");
2
+ var html = "\n <html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\" />\n <title>XRender</title>\n <link rel=\"icon\" href=\"https://img.alicdn.com/tfs/TB17UtINiLaK1RjSZFxXXamPFXa-606-643.png\">\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/variables.css\" rel=\"stylesheet\" />\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/dist/next.var.min.css\" rel=\"stylesheet\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/css/engine-core.css\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/css/engine-ext.css\" />\n <link rel=\"stylesheet\" href=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/css/index.css\" />\n\n <script>\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n </script>\n \n <script src=\"https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/react15-polyfill/0.0.1/dist/index.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js\"></script>\n <script src=\"https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js\"></script>\n <script src=\"https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/js/engine-core.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/js/engine-ext.js\"></script>\n </head>\n\n <body>\n <div id=\"lce-container\"></div>\n <script type=\"text/javascript\" src=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js\"></script>\n </body>\n </html>\n ";
5
3
  return html;
6
4
  };
7
5
  export default (function () {
package/es/main.js CHANGED
@@ -15,16 +15,18 @@ var Design = function Design(props, ref) {
15
15
  var widgets = props.widgets,
16
16
  settings = props.settings,
17
17
  restProps = _objectWithoutProperties(props, _excluded);
18
- var containerRef = useRef();
18
+ var containerRef = useRef(null);
19
+ var iframeRef = useRef(null); // 使用 ref 代替全局变量
20
+
19
21
  useImperativeHandle(ref, function () {
20
22
  return {
21
23
  getValue: function getValue() {
22
- var _iframe, _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);
24
+ var _iframeRef$current, _iframeRef$current$co, _iframeRef$current$co2, _iframeRef$current$co3;
25
+ return (_iframeRef$current = iframeRef.current) === null || _iframeRef$current === void 0 ? void 0 : (_iframeRef$current$co = _iframeRef$current.contentWindow) === null || _iframeRef$current$co === void 0 ? void 0 : (_iframeRef$current$co2 = _iframeRef$current$co.__FR_ENGINE__) === null || _iframeRef$current$co2 === void 0 ? void 0 : (_iframeRef$current$co3 = _iframeRef$current$co2.exportSchema) === null || _iframeRef$current$co3 === void 0 ? void 0 : _iframeRef$current$co3.call(_iframeRef$current$co2);
24
26
  },
25
27
  setValue: function setValue(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);
28
+ var _iframeRef$current2, _iframeRef$current2$c, _iframeRef$current2$c2, _iframeRef$current2$c3;
29
+ return (_iframeRef$current2 = iframeRef.current) === null || _iframeRef$current2 === void 0 ? void 0 : (_iframeRef$current2$c = _iframeRef$current2.contentWindow) === null || _iframeRef$current2$c === void 0 ? void 0 : (_iframeRef$current2$c2 = _iframeRef$current2$c.__FR_ENGINE__) === null || _iframeRef$current2$c2 === void 0 ? void 0 : (_iframeRef$current2$c3 = _iframeRef$current2$c2.importSchema) === null || _iframeRef$current2$c3 === void 0 ? void 0 : _iframeRef$current2$c3.call(_iframeRef$current2$c2, schema);
28
30
  }
29
31
  };
30
32
  });
@@ -40,37 +42,14 @@ var Design = function Design(props, ref) {
40
42
  containerRef.current.appendChild(iframe);
41
43
  };
42
44
  var engineOnLoad = function engineOnLoad(event) {
43
- var _iframe3, _outerIframeWindow$__;
45
+ var _iframe, _iframe$contentWindow, _iframe$contentWindow2;
44
46
  if (event.data.type !== 'engine-load') {
45
47
  return;
46
48
  }
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({
49
+ (_iframe = iframe) === null || _iframe === void 0 ? void 0 : (_iframe$contentWindow = _iframe.contentWindow) === null || _iframe$contentWindow === void 0 ? void 0 : (_iframe$contentWindow2 = _iframe$contentWindow.__FR_ENGINE__) === null || _iframe$contentWindow2 === void 0 ? void 0 : _iframe$contentWindow2.init(_objectSpread({
72
50
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
73
51
  widgets: widgets,
52
+ // recordEnable: true,
74
53
  logo: {
75
54
  title: 'XRender'
76
55
  }
@@ -4,10 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- // createIframe.ts
8
7
  var createIframeContent = function createIframeContent() {
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 ");
8
+ var html = "\n <html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\" />\n <title>XRender</title>\n <link rel=\"icon\" href=\"https://img.alicdn.com/tfs/TB17UtINiLaK1RjSZFxXXamPFXa-606-643.png\">\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/variables.css\" rel=\"stylesheet\" />\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/dist/next.var.min.css\" rel=\"stylesheet\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/css/engine-core.css\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/css/engine-ext.css\" />\n <link rel=\"stylesheet\" href=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/css/index.css\" />\n\n <script>\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n </script>\n \n <script src=\"https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/react15-polyfill/0.0.1/dist/index.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js\"></script>\n <script src=\"https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js\"></script>\n <script src=\"https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/js/engine-core.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/js/engine-ext.js\"></script>\n </head>\n\n <body>\n <div id=\"lce-container\"></div>\n <script type=\"text/javascript\" src=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js\"></script>\n </body>\n </html>\n ";
11
9
  return html;
12
10
  };
13
11
  var _default = exports.default = function _default() {
package/lib/main.js CHANGED
@@ -23,16 +23,18 @@ var Design = function Design(props, ref) {
23
23
  var widgets = props.widgets,
24
24
  settings = props.settings,
25
25
  restProps = _objectWithoutProperties(props, _excluded);
26
- var containerRef = (0, _react.useRef)();
26
+ var containerRef = (0, _react.useRef)(null);
27
+ var iframeRef = (0, _react.useRef)(null); // 使用 ref 代替全局变量
28
+
27
29
  (0, _react.useImperativeHandle)(ref, function () {
28
30
  return {
29
31
  getValue: function getValue() {
30
- var _iframe, _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);
32
+ var _iframeRef$current, _iframeRef$current$co, _iframeRef$current$co2, _iframeRef$current$co3;
33
+ return (_iframeRef$current = iframeRef.current) === null || _iframeRef$current === void 0 ? void 0 : (_iframeRef$current$co = _iframeRef$current.contentWindow) === null || _iframeRef$current$co === void 0 ? void 0 : (_iframeRef$current$co2 = _iframeRef$current$co.__FR_ENGINE__) === null || _iframeRef$current$co2 === void 0 ? void 0 : (_iframeRef$current$co3 = _iframeRef$current$co2.exportSchema) === null || _iframeRef$current$co3 === void 0 ? void 0 : _iframeRef$current$co3.call(_iframeRef$current$co2);
32
34
  },
33
35
  setValue: function setValue(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);
36
+ var _iframeRef$current2, _iframeRef$current2$c, _iframeRef$current2$c2, _iframeRef$current2$c3;
37
+ return (_iframeRef$current2 = iframeRef.current) === null || _iframeRef$current2 === void 0 ? void 0 : (_iframeRef$current2$c = _iframeRef$current2.contentWindow) === null || _iframeRef$current2$c === void 0 ? void 0 : (_iframeRef$current2$c2 = _iframeRef$current2$c.__FR_ENGINE__) === null || _iframeRef$current2$c2 === void 0 ? void 0 : (_iframeRef$current2$c3 = _iframeRef$current2$c2.importSchema) === null || _iframeRef$current2$c3 === void 0 ? void 0 : _iframeRef$current2$c3.call(_iframeRef$current2$c2, schema);
36
38
  }
37
39
  };
38
40
  });
@@ -48,37 +50,14 @@ var Design = function Design(props, ref) {
48
50
  containerRef.current.appendChild(iframe);
49
51
  };
50
52
  var engineOnLoad = function engineOnLoad(event) {
51
- var _iframe3, _outerIframeWindow$__;
53
+ var _iframe, _iframe$contentWindow, _iframe$contentWindow2;
52
54
  if (event.data.type !== 'engine-load') {
53
55
  return;
54
56
  }
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({
57
+ (_iframe = iframe) === null || _iframe === void 0 ? void 0 : (_iframe$contentWindow = _iframe.contentWindow) === null || _iframe$contentWindow === void 0 ? void 0 : (_iframe$contentWindow2 = _iframe$contentWindow.__FR_ENGINE__) === null || _iframe$contentWindow2 === void 0 ? void 0 : _iframe$contentWindow2.init(_objectSpread({
80
58
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
81
59
  widgets: widgets,
60
+ // recordEnable: true,
82
61
  logo: {
83
62
  title: 'XRender'
84
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzdadelu/schema-builder",
3
- "version": "1.0.0-alpha.120",
3
+ "version": "1.0.0-alpha.121",
4
4
  "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5
5
  "keywords": [
6
6
  "Form",
package/CHANGELOG.md DELETED
@@ -1 +0,0 @@
1
- # Change Log