@zzdadelu/schema-builder 1.0.0-alpha.35 → 1.0.0-alpha.37

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.
Files changed (3) hide show
  1. package/es/main.js +50 -38
  2. package/lib/main.js +49 -37
  3. 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, useLayoutEffect } from 'react';
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,31 @@ var Design = function Design(props, ref) {
58
83
  title: 'XRender'
59
84
  }
60
85
  }, restProps));
61
- };
62
- var modifyIframeContent = function modifyIframeContent() {
63
- var iframe = document.getElementsByTagName("iframe")[0];
64
- console.log(' modifyIframeContent iframe', iframe);
65
-
66
- // Check if iframe exists and load the document
67
- if (iframe) {
68
- iframe.onload = function () {
69
- var iframeDoc = iframe.contentDocument;
70
- console.log('modifyIframe iframeDoc', iframeDoc);
71
- if (iframeDoc) {
72
- var iframe2 = iframeDoc === null || iframeDoc === void 0 ? void 0 : iframeDoc.getElementsByTagName("iframe")[0];
73
- var iframeDoc2 = iframe2 === null || iframe2 === void 0 ? void 0 : iframe2.contentDocument;
74
- console.log('modifyIframe iframeDoc2', iframeDoc2);
75
- if (iframeDoc2) {
76
- // Find and replace the target script
77
- var scripts = iframeDoc2.querySelectorAll('script');
78
- var targetScript = Array.from(scripts).find(function (script) {
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
+ console.log('XRender iframe', iframe);
88
+ var iframeDoc = iframe.contentDocument;
89
+ console.log(' XRender modifyIframe iframeDoc', iframeDoc);
90
+ if (iframeDoc) {
91
+ var iframe2 = iframeDoc === null || iframeDoc === void 0 ? void 0 : iframeDoc.getElementsByTagName("iframe")[0];
92
+ var iframeDoc2 = iframe2 === null || iframe2 === void 0 ? void 0 : iframe2.contentDocument;
93
+ console.log(' XRender modifyIframe iframeDoc2', iframeDoc2);
94
+ if (iframeDoc2) {
95
+ // Find and replace the target script
96
+ var scripts = iframeDoc2.querySelectorAll('script');
97
+ var targetScript = Array.from(scripts).find(function (script) {
98
+ return script.src === 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js';
99
+ });
100
+ if (targetScript) {
101
+ targetScript.remove();
102
+ // Create new script with timestamp
103
+ var newScript = iframeDoc2.createElement('script');
104
+ newScript.src = 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js?t=' + new Date().getTime();
105
+ iframeDoc2.body.appendChild(newScript);
89
106
  }
90
107
  }
91
- };
92
- }
108
+ }
109
+ };
93
110
  };
94
-
95
- // 使用 useLayoutEffect 确保修改发生在渲染前
96
- useLayoutEffect(function () {
97
- modifyIframeContent();
98
- }, []);
99
111
  return /*#__PURE__*/React.createElement("div", {
100
112
  ref: containerRef,
101
113
  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,31 @@ var Design = function Design(props, ref) {
66
91
  title: 'XRender'
67
92
  }
68
93
  }, restProps));
69
- };
70
- var modifyIframeContent = function modifyIframeContent() {
71
- var iframe = document.getElementsByTagName("iframe")[0];
72
- console.log(' modifyIframeContent iframe', iframe);
73
-
74
- // Check if iframe exists and load the document
75
- if (iframe) {
76
- iframe.onload = function () {
77
- var iframeDoc = iframe.contentDocument;
78
- console.log('modifyIframe iframeDoc', iframeDoc);
79
- if (iframeDoc) {
80
- var iframe2 = iframeDoc === null || iframeDoc === void 0 ? void 0 : iframeDoc.getElementsByTagName("iframe")[0];
81
- var iframeDoc2 = iframe2 === null || iframe2 === void 0 ? void 0 : iframe2.contentDocument;
82
- console.log('modifyIframe iframeDoc2', iframeDoc2);
83
- if (iframeDoc2) {
84
- // Find and replace the target script
85
- var scripts = iframeDoc2.querySelectorAll('script');
86
- var targetScript = Array.from(scripts).find(function (script) {
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
+ console.log('XRender iframe', iframe);
96
+ var iframeDoc = iframe.contentDocument;
97
+ console.log(' XRender modifyIframe iframeDoc', iframeDoc);
98
+ if (iframeDoc) {
99
+ var iframe2 = iframeDoc === null || iframeDoc === void 0 ? void 0 : iframeDoc.getElementsByTagName("iframe")[0];
100
+ var iframeDoc2 = iframe2 === null || iframe2 === void 0 ? void 0 : iframe2.contentDocument;
101
+ console.log(' XRender modifyIframe iframeDoc2', iframeDoc2);
102
+ if (iframeDoc2) {
103
+ // Find and replace the target script
104
+ var scripts = iframeDoc2.querySelectorAll('script');
105
+ var targetScript = Array.from(scripts).find(function (script) {
106
+ return script.src === 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js';
107
+ });
108
+ if (targetScript) {
109
+ targetScript.remove();
110
+ // Create new script with timestamp
111
+ var newScript = iframeDoc2.createElement('script');
112
+ newScript.src = 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js?t=' + new Date().getTime();
113
+ iframeDoc2.body.appendChild(newScript);
97
114
  }
98
115
  }
99
- };
100
- }
116
+ }
117
+ };
101
118
  };
102
-
103
- // 使用 useLayoutEffect 确保修改发生在渲染前
104
- (0, _react.useLayoutEffect)(function () {
105
- modifyIframeContent();
106
- }, []);
107
119
  return /*#__PURE__*/_react.default.createElement("div", {
108
120
  ref: containerRef,
109
121
  style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzdadelu/schema-builder",
3
- "version": "1.0.0-alpha.35",
3
+ "version": "1.0.0-alpha.37",
4
4
  "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5
5
  "keywords": [
6
6
  "Form",