@zzdadelu/schema-builder 1.0.0-alpha.35 → 1.0.0-alpha.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/main.js +48 -38
- package/lib/main.js +47 -37
- package/package.json +1 -1
package/es/main.js
CHANGED
|
@@ -7,7 +7,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
7
7
|
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); }
|
|
8
8
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
9
9
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
10
|
-
import React, { useEffect, useRef, useImperativeHandle, forwardRef
|
|
10
|
+
import React, { useEffect, useRef, useImperativeHandle, forwardRef } from 'react';
|
|
11
11
|
import createIframe from './createIframe';
|
|
12
12
|
import * as defaultSetting from './settings';
|
|
13
13
|
var iframe;
|
|
@@ -30,6 +30,33 @@ var Design = function Design(props, ref) {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
});
|
|
33
|
+
var modifyIframeContent = function modifyIframeContent() {
|
|
34
|
+
var iframe = document.getElementsByTagName("iframe")[0];
|
|
35
|
+
if (iframe) {
|
|
36
|
+
var iframeDoc = iframe.contentDocument;
|
|
37
|
+
console.log('modifyIframe iframeDoc', iframeDoc);
|
|
38
|
+
if (iframeDoc) {
|
|
39
|
+
var iframe2 = iframeDoc === null || iframeDoc === void 0 ? void 0 : iframeDoc.getElementsByTagName("iframe")[0];
|
|
40
|
+
var iframeDoc2 = iframe2 === null || iframe2 === void 0 ? void 0 : iframe2.contentDocument;
|
|
41
|
+
console.log('modifyIframe iframeDoc2', iframeDoc2);
|
|
42
|
+
if (iframeDoc2) {
|
|
43
|
+
// Find and replace the target script
|
|
44
|
+
var scripts = iframeDoc2.querySelectorAll('script');
|
|
45
|
+
var targetScript = Array.from(scripts).find(function (script) {
|
|
46
|
+
return script.src === 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js';
|
|
47
|
+
});
|
|
48
|
+
if (targetScript) {
|
|
49
|
+
targetScript.remove();
|
|
50
|
+
|
|
51
|
+
// Create new script with timestamp
|
|
52
|
+
var newScript = iframeDoc2.createElement('script');
|
|
53
|
+
newScript.src = 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js?t=' + new Date().getTime();
|
|
54
|
+
iframeDoc2.body.appendChild(newScript);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
33
60
|
useEffect(function () {
|
|
34
61
|
initIframe();
|
|
35
62
|
window.addEventListener('message', engineOnLoad);
|
|
@@ -41,8 +68,6 @@ var Design = function Design(props, ref) {
|
|
|
41
68
|
console.log("开始创建 iframe");
|
|
42
69
|
iframe = createIframe();
|
|
43
70
|
containerRef.current.appendChild(iframe);
|
|
44
|
-
console.log("iframe appended containerRef", containerRef);
|
|
45
|
-
console.log("iframe appended ", iframe);
|
|
46
71
|
};
|
|
47
72
|
var engineOnLoad = function engineOnLoad(event) {
|
|
48
73
|
var _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
|
|
@@ -58,44 +83,29 @@ var Design = function Design(props, ref) {
|
|
|
58
83
|
title: 'XRender'
|
|
59
84
|
}
|
|
60
85
|
}, restProps));
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return script.src === 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js';
|
|
80
|
-
});
|
|
81
|
-
if (targetScript) {
|
|
82
|
-
targetScript.remove();
|
|
83
|
-
|
|
84
|
-
// Create new script with timestamp
|
|
85
|
-
var newScript = iframeDoc2.createElement('script');
|
|
86
|
-
newScript.src = 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js?t=' + new Date().getTime();
|
|
87
|
-
iframeDoc2.body.appendChild(newScript);
|
|
88
|
-
}
|
|
86
|
+
iframe.onload = function () {
|
|
87
|
+
var iframeDoc = iframe.contentDocument;
|
|
88
|
+
if (iframeDoc) {
|
|
89
|
+
var iframe2 = iframeDoc === null || iframeDoc === void 0 ? void 0 : iframeDoc.getElementsByTagName("iframe")[0];
|
|
90
|
+
var iframeDoc2 = iframe2 === null || iframe2 === void 0 ? void 0 : iframe2.contentDocument;
|
|
91
|
+
console.log(' XRender modifyIframe iframeDoc2', iframeDoc2);
|
|
92
|
+
if (iframeDoc2) {
|
|
93
|
+
// Find and replace the target script
|
|
94
|
+
var scripts = iframeDoc2.querySelectorAll('script');
|
|
95
|
+
var targetScript = Array.from(scripts).find(function (script) {
|
|
96
|
+
return script.src === 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js';
|
|
97
|
+
});
|
|
98
|
+
if (targetScript) {
|
|
99
|
+
targetScript.remove();
|
|
100
|
+
// Create new script with timestamp
|
|
101
|
+
var newScript = iframeDoc2.createElement('script');
|
|
102
|
+
newScript.src = 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js?t=' + new Date().getTime();
|
|
103
|
+
iframeDoc2.body.appendChild(newScript);
|
|
89
104
|
}
|
|
90
105
|
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
93
108
|
};
|
|
94
|
-
|
|
95
|
-
// 使用 useLayoutEffect 确保修改发生在渲染前
|
|
96
|
-
useLayoutEffect(function () {
|
|
97
|
-
modifyIframeContent();
|
|
98
|
-
}, []);
|
|
99
109
|
return /*#__PURE__*/React.createElement("div", {
|
|
100
110
|
ref: containerRef,
|
|
101
111
|
style: {
|
package/lib/main.js
CHANGED
|
@@ -38,6 +38,33 @@ var Design = function Design(props, ref) {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
});
|
|
41
|
+
var modifyIframeContent = function modifyIframeContent() {
|
|
42
|
+
var iframe = document.getElementsByTagName("iframe")[0];
|
|
43
|
+
if (iframe) {
|
|
44
|
+
var iframeDoc = iframe.contentDocument;
|
|
45
|
+
console.log('modifyIframe iframeDoc', iframeDoc);
|
|
46
|
+
if (iframeDoc) {
|
|
47
|
+
var iframe2 = iframeDoc === null || iframeDoc === void 0 ? void 0 : iframeDoc.getElementsByTagName("iframe")[0];
|
|
48
|
+
var iframeDoc2 = iframe2 === null || iframe2 === void 0 ? void 0 : iframe2.contentDocument;
|
|
49
|
+
console.log('modifyIframe iframeDoc2', iframeDoc2);
|
|
50
|
+
if (iframeDoc2) {
|
|
51
|
+
// Find and replace the target script
|
|
52
|
+
var scripts = iframeDoc2.querySelectorAll('script');
|
|
53
|
+
var targetScript = Array.from(scripts).find(function (script) {
|
|
54
|
+
return script.src === 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js';
|
|
55
|
+
});
|
|
56
|
+
if (targetScript) {
|
|
57
|
+
targetScript.remove();
|
|
58
|
+
|
|
59
|
+
// Create new script with timestamp
|
|
60
|
+
var newScript = iframeDoc2.createElement('script');
|
|
61
|
+
newScript.src = 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js?t=' + new Date().getTime();
|
|
62
|
+
iframeDoc2.body.appendChild(newScript);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
41
68
|
(0, _react.useEffect)(function () {
|
|
42
69
|
initIframe();
|
|
43
70
|
window.addEventListener('message', engineOnLoad);
|
|
@@ -49,8 +76,6 @@ var Design = function Design(props, ref) {
|
|
|
49
76
|
console.log("开始创建 iframe");
|
|
50
77
|
iframe = (0, _createIframe.default)();
|
|
51
78
|
containerRef.current.appendChild(iframe);
|
|
52
|
-
console.log("iframe appended containerRef", containerRef);
|
|
53
|
-
console.log("iframe appended ", iframe);
|
|
54
79
|
};
|
|
55
80
|
var engineOnLoad = function engineOnLoad(event) {
|
|
56
81
|
var _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
|
|
@@ -66,44 +91,29 @@ var Design = function Design(props, ref) {
|
|
|
66
91
|
title: 'XRender'
|
|
67
92
|
}
|
|
68
93
|
}, restProps));
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return script.src === 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js';
|
|
88
|
-
});
|
|
89
|
-
if (targetScript) {
|
|
90
|
-
targetScript.remove();
|
|
91
|
-
|
|
92
|
-
// Create new script with timestamp
|
|
93
|
-
var newScript = iframeDoc2.createElement('script');
|
|
94
|
-
newScript.src = 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js?t=' + new Date().getTime();
|
|
95
|
-
iframeDoc2.body.appendChild(newScript);
|
|
96
|
-
}
|
|
94
|
+
iframe.onload = function () {
|
|
95
|
+
var iframeDoc = iframe.contentDocument;
|
|
96
|
+
if (iframeDoc) {
|
|
97
|
+
var iframe2 = iframeDoc === null || iframeDoc === void 0 ? void 0 : iframeDoc.getElementsByTagName("iframe")[0];
|
|
98
|
+
var iframeDoc2 = iframe2 === null || iframe2 === void 0 ? void 0 : iframe2.contentDocument;
|
|
99
|
+
console.log(' XRender modifyIframe iframeDoc2', iframeDoc2);
|
|
100
|
+
if (iframeDoc2) {
|
|
101
|
+
// Find and replace the target script
|
|
102
|
+
var scripts = iframeDoc2.querySelectorAll('script');
|
|
103
|
+
var targetScript = Array.from(scripts).find(function (script) {
|
|
104
|
+
return script.src === 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js';
|
|
105
|
+
});
|
|
106
|
+
if (targetScript) {
|
|
107
|
+
targetScript.remove();
|
|
108
|
+
// Create new script with timestamp
|
|
109
|
+
var newScript = iframeDoc2.createElement('script');
|
|
110
|
+
newScript.src = 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js?t=' + new Date().getTime();
|
|
111
|
+
iframeDoc2.body.appendChild(newScript);
|
|
97
112
|
}
|
|
98
113
|
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
101
116
|
};
|
|
102
|
-
|
|
103
|
-
// 使用 useLayoutEffect 确保修改发生在渲染前
|
|
104
|
-
(0, _react.useLayoutEffect)(function () {
|
|
105
|
-
modifyIframeContent();
|
|
106
|
-
}, []);
|
|
107
117
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
108
118
|
ref: containerRef,
|
|
109
119
|
style: {
|