@zzdadelu/schema-builder 1.0.0-alpha.73 → 1.0.0-alpha.75

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,11 @@
1
- var createIframeContent = function createIframeContent(timestamp) {
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 <!-- Shim: \u5728\u5916\u5C42 iframe \u5185\u63D0\u4F9B\u4E00\u4E2A\u4E34\u65F6\u5B89\u5168\u5B9E\u73B0\uFF0C\u907F\u514D\u7B2C\u4E09\u65B9\u5185\u8054\u811A\u672C\u7ACB\u5373\u62A5\u9519 -->\n <script>\n (function() {\n try {\n if (typeof window.getFormRenderMaterial !== 'function') {\n var __fr_q = [];\n var __fr_shim = function() {\n __fr_q.push({ args: Array.prototype.slice.call(arguments) });\n return { __esModule: true };\n };\n window.getFormRenderMaterial = __fr_shim;\n var __fr_iv = setInterval(function() {\n try {\n if (typeof window.getFormRenderMaterial === 'function' && window.getFormRenderMaterial !== __fr_shim) {\n var __real = window.getFormRenderMaterial;\n clearInterval(__fr_iv);\n setTimeout(function() {\n try {\n __fr_q.forEach(function(item) {\n try { __real.apply(null, item.args); } catch (e) {}\n });\n } catch (e) {}\n __fr_q = null;\n }, 0);\n }\n } catch (e) {}\n }, 50);\n }\n } catch (e) {}\n })();\n </script>\n\n <!-- Observer: \u76D1\u63A7\u672C iframe \u6587\u6863\u4E2D\u65B0\u589E\u7684\u5B50 iframe\uFF08\u7B2C\u4E09\u65B9 create-simulator \u53EF\u80FD\u521B\u5EFA\u7684\u5D4C\u5957 iframe\uFF09\u5E76\u5C3D\u5FEB\u4FEE\u8865 -->\n <script>\n (function() {\n var ts = ".concat(timestamp, ";\n function tryPatchChildIframe(iframeEl) {\n try {\n // \u82E5 contentWindow \u53EF\u7528\uFF0C\u7ACB\u5373\u5728\u5B50 iframe \u7684 window \u4E0A\u653E\u4E2A\u5B89\u5168\u5360\u4F4D\u51FD\u6570\n var cw = iframeEl.contentWindow;\n if (cw) {\n if (typeof cw.getFormRenderMaterial !== 'function') {\n try {\n cw.getFormRenderMaterial = function() {\n return { __esModule: true };\n };\n } catch (e) {}\n }\n }\n } catch (e) {}\n }\n\n // \u5F53\u5B50 iframe \u52A0\u8F7D\u5B8C\u6210\u540E\uFF0C\u5C1D\u8BD5\u4FEE\u8865\u5176\u5185\u90E8 script \u7684 src\uFF0C\u52A0\u65F6\u95F4\u6233\u4EE5\u907F\u514D\u7F13\u5B58\u5BFC\u81F4\u65E7\u7248\u95EE\u9898\uFF1B\u5E76\u786E\u4FDD child window \u6709 getFormRenderMaterial\n function onChildFrameLoad(iframeEl) {\n try {\n var doc = iframeEl.contentDocument || iframeEl.contentWindow && iframeEl.contentWindow.document;\n if (!doc) return;\n // \u4FEE\u8865\u53EF\u80FD\u7684\u5916\u90E8\u811A\u672C url\uFF08\u793A\u4F8B\uFF1Afr-generator / react-simulator-renderer \u7B49\uFF09\n var scripts = Array.prototype.slice.call(doc.getElementsByTagName('script'));\n scripts.forEach(function(s) {\n if (s.src && /fr-generator\\/.*index\\.js|react-simulator-renderer\\.js/.test(s.src)) {\n if (s.src.indexOf('?t=') === -1) {\n try {\n s.src = s.src + (s.src.indexOf('?') === -1 ? '?t=' + ts : '&t=' + ts);\n } catch (e) {}\n }\n }\n });\n // \u6700\u7EC8\u786E\u4FDD child window \u6709 getFormRenderMaterial\n try {\n var cw = iframeEl.contentWindow;\n if (cw && typeof cw.getFormRenderMaterial !== 'function') {\n cw.getFormRenderMaterial = function() { return { __esModule: true }; };\n }\n } catch (e) {}\n } catch (e) {}\n }\n\n var mo = new MutationObserver(function(muts) {\n muts.forEach(function(mut) {\n Array.prototype.forEach.call(mut.addedNodes || [], function(node) {\n try {\n if (node && node.tagName === 'IFRAME') {\n tryPatchChildIframe(node);\n // attach load to do more thorough patch after content is written\n node.addEventListener && node.addEventListener('load', function() {\n onChildFrameLoad(node);\n }, { once: true });\n }\n } catch (e) {}\n });\n });\n });\n\n try {\n mo.observe(document.documentElement || document.body, { childList: true, subtree: true });\n // \u5DF2\u5B58\u5728\u7684 iframe \u7ACB\u5373\u5C1D\u8BD5\u4FEE\u8865\n Array.prototype.forEach.call(document.getElementsByTagName('iframe'), function(f) {\n tryPatchChildIframe(f);\n f.addEventListener && f.addEventListener('load', function() { onChildFrameLoad(f); }, { once: true });\n });\n } catch (e) {}\n })();\n </script>\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 <!-- \u7ED9 fr-generator \u52A0\u65F6\u95F4\u6233\uFF0C\u5E2E\u52A9\u89C4\u907F\u7F13\u5B58\u5BFC\u81F4\u7684\u65E7\u7248/\u65F6\u5E8F\u95EE\u9898 -->\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 </body>\n </html>\n ");
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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 src=\"https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/react15-polyfill/0.0.1/dist/index.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js\"></script>\n <script src=\"https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js\"></script>\n <script src=\"https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/js/engine-core.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/js/engine-ext.js\"></script>\n </head>\n\n <body>\n <div id=\"lce-container\"></div>\n <script type=\"text/javascript\" src=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js\"></script>\n </body>\n </html>\n ";
3
9
  return html;
4
10
  };
5
11
  export default (function () {
@@ -7,7 +13,93 @@ export default (function () {
7
13
  iframe.width = '100%';
8
14
  iframe.height = '100%';
9
15
  iframe.frameBorder = '0';
10
- var ts = Date.now();
11
- iframe.srcdoc = createIframeContent(ts);
16
+ iframe.srcdoc = createIframeContent();
17
+
18
+ // 监听iframe加载完成
19
+ iframe.onload = function () {
20
+ console.log('1', iframe.contentWindow);
21
+ var win = iframe.contentWindow;
22
+ if (!win) return;
23
+
24
+ // 拦截低代码引擎的createSimulator函数
25
+ patchCreateSimulatorInIframe(win);
26
+ };
27
+ console.log('2', iframe.contentWindow);
12
28
  return iframe;
13
- });
29
+ });
30
+
31
+ // 在iframe内部修补createSimulator函数
32
+ function patchCreateSimulatorInIframe(iframeWindow) {
33
+ // 保存原始的createSimulator函数
34
+ var originalCreateSimulator = iframeWindow.createSimulator;
35
+ console.log('3', originalCreateSimulator);
36
+ if (originalCreateSimulator) {
37
+ iframeWindow.createSimulator = function (host, iframe, vendors) {
38
+ // 处理vendors,给JS URL添加时间戳
39
+ var processedVendors = addTimestampToVendors(vendors);
40
+ return originalCreateSimulator.call(this, host, iframe, processedVendors);
41
+ };
42
+ }
43
+
44
+ // 工具函数(同上)
45
+ function addTimestampToVendors(vendors) {
46
+ var timestamp = new Date().getTime();
47
+ return vendors.map(function (vendor) {
48
+ if (!vendor) return vendor;
49
+ if (vendor.type === 'bundle' && Array.isArray(vendor.assets)) {
50
+ return _objectSpread(_objectSpread({}, vendor), {}, {
51
+ assets: vendor.assets.map(function (asset) {
52
+ if (!asset) return asset;
53
+
54
+ // 处理字符串URL
55
+ if (typeof asset === 'string') {
56
+ return addTimestampToUrl(asset, timestamp);
57
+ }
58
+
59
+ // 处理数组(可能是URL数组)
60
+ if (Array.isArray(asset)) {
61
+ return asset.map(function (item) {
62
+ if (typeof item === 'string') {
63
+ return addTimestampToUrl(item, timestamp);
64
+ }
65
+ // 处理数组中的数组(嵌套情况)
66
+ if (Array.isArray(item)) {
67
+ return item.map(function (subItem) {
68
+ if (typeof subItem === 'string') {
69
+ return addTimestampToUrl(subItem, timestamp);
70
+ }
71
+ return subItem;
72
+ });
73
+ }
74
+ return item;
75
+ });
76
+ }
77
+
78
+ // 处理对象类型
79
+ if (_typeof(asset) === 'object') {
80
+ if (asset.type === 'jsText' || asset.type === 'cssText') {
81
+ // 内联脚本,不需要加时间戳
82
+ return asset;
83
+ }
84
+ if (asset.content && typeof asset.content === 'string') {
85
+ return _objectSpread(_objectSpread({}, asset), {}, {
86
+ content: addTimestampToUrl(asset.content, timestamp)
87
+ });
88
+ }
89
+ }
90
+ return asset;
91
+ })
92
+ });
93
+ }
94
+ return vendor;
95
+ });
96
+ }
97
+ function addTimestampToUrl(url, timestamp) {
98
+ if (!url || typeof url !== 'string') return url;
99
+
100
+ // 跳过已经有时间戳的URL
101
+ if (url.includes('t=')) return url;
102
+ var separator = url.includes('?') ? '&' : '?';
103
+ return "".concat(url).concat(separator, "t=").concat(timestamp);
104
+ }
105
+ }
@@ -4,8 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var createIframeContent = function createIframeContent(timestamp) {
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 <!-- Shim: \u5728\u5916\u5C42 iframe \u5185\u63D0\u4F9B\u4E00\u4E2A\u4E34\u65F6\u5B89\u5168\u5B9E\u73B0\uFF0C\u907F\u514D\u7B2C\u4E09\u65B9\u5185\u8054\u811A\u672C\u7ACB\u5373\u62A5\u9519 -->\n <script>\n (function() {\n try {\n if (typeof window.getFormRenderMaterial !== 'function') {\n var __fr_q = [];\n var __fr_shim = function() {\n __fr_q.push({ args: Array.prototype.slice.call(arguments) });\n return { __esModule: true };\n };\n window.getFormRenderMaterial = __fr_shim;\n var __fr_iv = setInterval(function() {\n try {\n if (typeof window.getFormRenderMaterial === 'function' && window.getFormRenderMaterial !== __fr_shim) {\n var __real = window.getFormRenderMaterial;\n clearInterval(__fr_iv);\n setTimeout(function() {\n try {\n __fr_q.forEach(function(item) {\n try { __real.apply(null, item.args); } catch (e) {}\n });\n } catch (e) {}\n __fr_q = null;\n }, 0);\n }\n } catch (e) {}\n }, 50);\n }\n } catch (e) {}\n })();\n </script>\n\n <!-- Observer: \u76D1\u63A7\u672C iframe \u6587\u6863\u4E2D\u65B0\u589E\u7684\u5B50 iframe\uFF08\u7B2C\u4E09\u65B9 create-simulator \u53EF\u80FD\u521B\u5EFA\u7684\u5D4C\u5957 iframe\uFF09\u5E76\u5C3D\u5FEB\u4FEE\u8865 -->\n <script>\n (function() {\n var ts = ".concat(timestamp, ";\n function tryPatchChildIframe(iframeEl) {\n try {\n // \u82E5 contentWindow \u53EF\u7528\uFF0C\u7ACB\u5373\u5728\u5B50 iframe \u7684 window \u4E0A\u653E\u4E2A\u5B89\u5168\u5360\u4F4D\u51FD\u6570\n var cw = iframeEl.contentWindow;\n if (cw) {\n if (typeof cw.getFormRenderMaterial !== 'function') {\n try {\n cw.getFormRenderMaterial = function() {\n return { __esModule: true };\n };\n } catch (e) {}\n }\n }\n } catch (e) {}\n }\n\n // \u5F53\u5B50 iframe \u52A0\u8F7D\u5B8C\u6210\u540E\uFF0C\u5C1D\u8BD5\u4FEE\u8865\u5176\u5185\u90E8 script \u7684 src\uFF0C\u52A0\u65F6\u95F4\u6233\u4EE5\u907F\u514D\u7F13\u5B58\u5BFC\u81F4\u65E7\u7248\u95EE\u9898\uFF1B\u5E76\u786E\u4FDD child window \u6709 getFormRenderMaterial\n function onChildFrameLoad(iframeEl) {\n try {\n var doc = iframeEl.contentDocument || iframeEl.contentWindow && iframeEl.contentWindow.document;\n if (!doc) return;\n // \u4FEE\u8865\u53EF\u80FD\u7684\u5916\u90E8\u811A\u672C url\uFF08\u793A\u4F8B\uFF1Afr-generator / react-simulator-renderer \u7B49\uFF09\n var scripts = Array.prototype.slice.call(doc.getElementsByTagName('script'));\n scripts.forEach(function(s) {\n if (s.src && /fr-generator\\/.*index\\.js|react-simulator-renderer\\.js/.test(s.src)) {\n if (s.src.indexOf('?t=') === -1) {\n try {\n s.src = s.src + (s.src.indexOf('?') === -1 ? '?t=' + ts : '&t=' + ts);\n } catch (e) {}\n }\n }\n });\n // \u6700\u7EC8\u786E\u4FDD child window \u6709 getFormRenderMaterial\n try {\n var cw = iframeEl.contentWindow;\n if (cw && typeof cw.getFormRenderMaterial !== 'function') {\n cw.getFormRenderMaterial = function() { return { __esModule: true }; };\n }\n } catch (e) {}\n } catch (e) {}\n }\n\n var mo = new MutationObserver(function(muts) {\n muts.forEach(function(mut) {\n Array.prototype.forEach.call(mut.addedNodes || [], function(node) {\n try {\n if (node && node.tagName === 'IFRAME') {\n tryPatchChildIframe(node);\n // attach load to do more thorough patch after content is written\n node.addEventListener && node.addEventListener('load', function() {\n onChildFrameLoad(node);\n }, { once: true });\n }\n } catch (e) {}\n });\n });\n });\n\n try {\n mo.observe(document.documentElement || document.body, { childList: true, subtree: true });\n // \u5DF2\u5B58\u5728\u7684 iframe \u7ACB\u5373\u5C1D\u8BD5\u4FEE\u8865\n Array.prototype.forEach.call(document.getElementsByTagName('iframe'), function(f) {\n tryPatchChildIframe(f);\n f.addEventListener && f.addEventListener('load', function() { onChildFrameLoad(f); }, { once: true });\n });\n } catch (e) {}\n })();\n </script>\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 <!-- \u7ED9 fr-generator \u52A0\u65F6\u95F4\u6233\uFF0C\u5E2E\u52A9\u89C4\u907F\u7F13\u5B58\u5BFC\u81F4\u7684\u65E7\u7248/\u65F6\u5E8F\u95EE\u9898 -->\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 </body>\n </html>\n ");
7
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
+ var createIframeContent = function createIframeContent() {
14
+ var html = "\n <html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\" />\n <title>XRender</title>\n <link rel=\"icon\" href=\"https://img.alicdn.com/tfs/TB17UtINiLaK1RjSZFxXXamPFXa-606-643.png\">\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/variables.css\" rel=\"stylesheet\" />\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/dist/next.var.min.css\" rel=\"stylesheet\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/css/engine-core.css\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/css/engine-ext.css\" />\n <link rel=\"stylesheet\" href=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/css/index.css\" />\n\n <script>\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n </script>\n \n <script src=\"https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/react15-polyfill/0.0.1/dist/index.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js\"></script>\n <script src=\"https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js\"></script>\n <script src=\"https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/js/engine-core.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/js/engine-ext.js\"></script>\n </head>\n\n <body>\n <div id=\"lce-container\"></div>\n <script type=\"text/javascript\" src=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js\"></script>\n </body>\n </html>\n ";
9
15
  return html;
10
16
  };
11
17
  var _default = exports.default = function _default() {
@@ -13,7 +19,91 @@ var _default = exports.default = function _default() {
13
19
  iframe.width = '100%';
14
20
  iframe.height = '100%';
15
21
  iframe.frameBorder = '0';
16
- var ts = Date.now();
17
- iframe.srcdoc = createIframeContent(ts);
22
+ iframe.srcdoc = createIframeContent();
23
+
24
+ // 监听iframe加载完成
25
+ iframe.onload = function () {
26
+ console.log('1', iframe.contentWindow);
27
+ var win = iframe.contentWindow;
28
+ if (!win) return;
29
+
30
+ // 拦截低代码引擎的createSimulator函数
31
+ patchCreateSimulatorInIframe(win);
32
+ };
33
+ console.log('2', iframe.contentWindow);
18
34
  return iframe;
19
- };
35
+ }; // 在iframe内部修补createSimulator函数
36
+ function patchCreateSimulatorInIframe(iframeWindow) {
37
+ // 保存原始的createSimulator函数
38
+ var originalCreateSimulator = iframeWindow.createSimulator;
39
+ console.log('3', originalCreateSimulator);
40
+ if (originalCreateSimulator) {
41
+ iframeWindow.createSimulator = function (host, iframe, vendors) {
42
+ // 处理vendors,给JS URL添加时间戳
43
+ var processedVendors = addTimestampToVendors(vendors);
44
+ return originalCreateSimulator.call(this, host, iframe, processedVendors);
45
+ };
46
+ }
47
+
48
+ // 工具函数(同上)
49
+ function addTimestampToVendors(vendors) {
50
+ var timestamp = new Date().getTime();
51
+ return vendors.map(function (vendor) {
52
+ if (!vendor) return vendor;
53
+ if (vendor.type === 'bundle' && Array.isArray(vendor.assets)) {
54
+ return _objectSpread(_objectSpread({}, vendor), {}, {
55
+ assets: vendor.assets.map(function (asset) {
56
+ if (!asset) return asset;
57
+
58
+ // 处理字符串URL
59
+ if (typeof asset === 'string') {
60
+ return addTimestampToUrl(asset, timestamp);
61
+ }
62
+
63
+ // 处理数组(可能是URL数组)
64
+ if (Array.isArray(asset)) {
65
+ return asset.map(function (item) {
66
+ if (typeof item === 'string') {
67
+ return addTimestampToUrl(item, timestamp);
68
+ }
69
+ // 处理数组中的数组(嵌套情况)
70
+ if (Array.isArray(item)) {
71
+ return item.map(function (subItem) {
72
+ if (typeof subItem === 'string') {
73
+ return addTimestampToUrl(subItem, timestamp);
74
+ }
75
+ return subItem;
76
+ });
77
+ }
78
+ return item;
79
+ });
80
+ }
81
+
82
+ // 处理对象类型
83
+ if (_typeof(asset) === 'object') {
84
+ if (asset.type === 'jsText' || asset.type === 'cssText') {
85
+ // 内联脚本,不需要加时间戳
86
+ return asset;
87
+ }
88
+ if (asset.content && typeof asset.content === 'string') {
89
+ return _objectSpread(_objectSpread({}, asset), {}, {
90
+ content: addTimestampToUrl(asset.content, timestamp)
91
+ });
92
+ }
93
+ }
94
+ return asset;
95
+ })
96
+ });
97
+ }
98
+ return vendor;
99
+ });
100
+ }
101
+ function addTimestampToUrl(url, timestamp) {
102
+ if (!url || typeof url !== 'string') return url;
103
+
104
+ // 跳过已经有时间戳的URL
105
+ if (url.includes('t=')) return url;
106
+ var separator = url.includes('?') ? '&' : '?';
107
+ return "".concat(url).concat(separator, "t=").concat(timestamp);
108
+ }
109
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzdadelu/schema-builder",
3
- "version": "1.0.0-alpha.73",
3
+ "version": "1.0.0-alpha.75",
4
4
  "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5
5
  "keywords": [
6
6
  "Form",