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