@zzdadelu/schema-builder 1.0.0-alpha.104 → 1.0.0-alpha.106
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/createIframe.js +1 -1
- package/es/main.js +30 -63
- package/lib/createIframe.js +1 -1
- package/lib/main.js +30 -63
- package/package.json +1 -1
package/es/createIframe.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var createIframeContent = function createIframeContent() {
|
|
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
|
|
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 ";
|
|
3
3
|
return html;
|
|
4
4
|
};
|
|
5
5
|
export default (function () {
|
package/es/main.js
CHANGED
|
@@ -11,7 +11,6 @@ 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;
|
|
14
|
-
var materialData = null;
|
|
15
14
|
var Design = function Design(props, ref) {
|
|
16
15
|
var widgets = props.widgets,
|
|
17
16
|
settings = props.settings,
|
|
@@ -38,78 +37,46 @@ var Design = function Design(props, ref) {
|
|
|
38
37
|
}, []);
|
|
39
38
|
var initIframe = function initIframe() {
|
|
40
39
|
iframe = createIframe();
|
|
41
|
-
|
|
42
|
-
// 监听 iframe 加载完成
|
|
43
|
-
iframe.onload = function () {
|
|
44
|
-
// 立即设置 getFormRenderMaterial 函数,防止 create-simulator 调用时报错
|
|
45
|
-
if (iframe.contentWindow) {
|
|
46
|
-
// 创建一个临时的 getFormRenderMaterial 函数
|
|
47
|
-
iframe.contentWindow.getFormRenderMaterial = function (name, packageName) {
|
|
48
|
-
console.log('getFormRenderMaterial called with:', name, packageName);
|
|
49
|
-
|
|
50
|
-
// 返回一个工厂函数
|
|
51
|
-
return function () {
|
|
52
|
-
console.log('Material factory called for:', name, packageName);
|
|
53
|
-
|
|
54
|
-
// 检查是否有缓存的物料
|
|
55
|
-
if (materialData) {
|
|
56
|
-
return materialData;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// 返回一个模拟的物料,包含必要的属性
|
|
60
|
-
return {
|
|
61
|
-
__esModule: true,
|
|
62
|
-
// 添加一些默认的组件配置
|
|
63
|
-
components: {},
|
|
64
|
-
snippets: [],
|
|
65
|
-
componentList: []
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// 发送物料数据到 iframe
|
|
71
|
-
if (widgets) {
|
|
72
|
-
materialData = widgets;
|
|
73
|
-
iframe.contentWindow.postMessage({
|
|
74
|
-
type: 'SET_FORM_RENDER_MATERIAL',
|
|
75
|
-
materialData: widgets
|
|
76
|
-
}, '*');
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
setTimeout(function () {
|
|
81
|
-
// 延迟设置物料
|
|
82
|
-
iframe.contentWindow.AliFormRenderMaterial = materialData;
|
|
83
|
-
}, 100);
|
|
84
40
|
containerRef.current.appendChild(iframe);
|
|
85
41
|
};
|
|
86
42
|
var engineOnLoad = function engineOnLoad(event) {
|
|
87
|
-
var _iframe3
|
|
43
|
+
var _iframe3;
|
|
88
44
|
if (event.data.type !== 'engine-load') {
|
|
89
45
|
return;
|
|
90
46
|
}
|
|
91
47
|
|
|
92
|
-
//
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// 再次发送物料数据,确保 fr-generator 能够收到
|
|
98
|
-
if (((_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow) && materialData) {
|
|
99
|
-
iframe.contentWindow.postMessage({
|
|
100
|
-
type: 'SET_FORM_RENDER_MATERIAL',
|
|
101
|
-
materialData: materialData
|
|
102
|
-
}, '*');
|
|
48
|
+
// --- 解决方案开始 ---
|
|
49
|
+
var iframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
|
|
50
|
+
if (!iframeWindow) {
|
|
51
|
+
console.error('Iframe window is not available.');
|
|
52
|
+
return;
|
|
103
53
|
}
|
|
104
54
|
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
55
|
+
// 定义一个检查并初始化引擎的函数
|
|
56
|
+
var _checkAndInit = function checkAndInit() {
|
|
57
|
+
// 检查关键依赖函数是否存在
|
|
58
|
+
if (typeof iframeWindow.__ReactSimulatorRenderer__.getFormRenderMaterial === 'function') {
|
|
59
|
+
var _iframeWindow$__FR_EN;
|
|
60
|
+
// ✅ 环境就绪,执行引擎初始化
|
|
61
|
+
(_iframeWindow$__FR_EN = iframeWindow.__FR_ENGINE__) === null || _iframeWindow$__FR_EN === void 0 ? void 0 : _iframeWindow$__FR_EN.init(_objectSpread({
|
|
62
|
+
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
63
|
+
widgets: widgets,
|
|
64
|
+
// recordEnable: true,
|
|
65
|
+
logo: {
|
|
66
|
+
title: 'XRender'
|
|
67
|
+
}
|
|
68
|
+
}, restProps));
|
|
69
|
+
} else {
|
|
70
|
+
// ⌛ 环境未就绪,可能是 fr-generator.js 还在加载/解析中,设置定时器重试
|
|
71
|
+
console.warn('XRender 依赖资源 getFormRenderMaterial 尚未加载完毕,正在重试...');
|
|
72
|
+
// 使用 setTimeout 进行非阻塞式轮询,避免阻塞 UI 线程
|
|
73
|
+
setTimeout(_checkAndInit, 50);
|
|
111
74
|
}
|
|
112
|
-
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// 启动检查流程
|
|
78
|
+
_checkAndInit();
|
|
79
|
+
// --- 解决方案结束 ---
|
|
113
80
|
};
|
|
114
81
|
return /*#__PURE__*/React.createElement("div", {
|
|
115
82
|
ref: containerRef,
|
package/lib/createIframe.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
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
|
|
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 ";
|
|
9
9
|
return html;
|
|
10
10
|
};
|
|
11
11
|
var _default = exports.default = function _default() {
|
package/lib/main.js
CHANGED
|
@@ -19,7 +19,6 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
19
19
|
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; }
|
|
20
20
|
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; }
|
|
21
21
|
var iframe;
|
|
22
|
-
var materialData = null;
|
|
23
22
|
var Design = function Design(props, ref) {
|
|
24
23
|
var widgets = props.widgets,
|
|
25
24
|
settings = props.settings,
|
|
@@ -46,78 +45,46 @@ var Design = function Design(props, ref) {
|
|
|
46
45
|
}, []);
|
|
47
46
|
var initIframe = function initIframe() {
|
|
48
47
|
iframe = (0, _createIframe.default)();
|
|
49
|
-
|
|
50
|
-
// 监听 iframe 加载完成
|
|
51
|
-
iframe.onload = function () {
|
|
52
|
-
// 立即设置 getFormRenderMaterial 函数,防止 create-simulator 调用时报错
|
|
53
|
-
if (iframe.contentWindow) {
|
|
54
|
-
// 创建一个临时的 getFormRenderMaterial 函数
|
|
55
|
-
iframe.contentWindow.getFormRenderMaterial = function (name, packageName) {
|
|
56
|
-
console.log('getFormRenderMaterial called with:', name, packageName);
|
|
57
|
-
|
|
58
|
-
// 返回一个工厂函数
|
|
59
|
-
return function () {
|
|
60
|
-
console.log('Material factory called for:', name, packageName);
|
|
61
|
-
|
|
62
|
-
// 检查是否有缓存的物料
|
|
63
|
-
if (materialData) {
|
|
64
|
-
return materialData;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// 返回一个模拟的物料,包含必要的属性
|
|
68
|
-
return {
|
|
69
|
-
__esModule: true,
|
|
70
|
-
// 添加一些默认的组件配置
|
|
71
|
-
components: {},
|
|
72
|
-
snippets: [],
|
|
73
|
-
componentList: []
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// 发送物料数据到 iframe
|
|
79
|
-
if (widgets) {
|
|
80
|
-
materialData = widgets;
|
|
81
|
-
iframe.contentWindow.postMessage({
|
|
82
|
-
type: 'SET_FORM_RENDER_MATERIAL',
|
|
83
|
-
materialData: widgets
|
|
84
|
-
}, '*');
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
setTimeout(function () {
|
|
89
|
-
// 延迟设置物料
|
|
90
|
-
iframe.contentWindow.AliFormRenderMaterial = materialData;
|
|
91
|
-
}, 100);
|
|
92
48
|
containerRef.current.appendChild(iframe);
|
|
93
49
|
};
|
|
94
50
|
var engineOnLoad = function engineOnLoad(event) {
|
|
95
|
-
var _iframe3
|
|
51
|
+
var _iframe3;
|
|
96
52
|
if (event.data.type !== 'engine-load') {
|
|
97
53
|
return;
|
|
98
54
|
}
|
|
99
55
|
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// 再次发送物料数据,确保 fr-generator 能够收到
|
|
106
|
-
if (((_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow) && materialData) {
|
|
107
|
-
iframe.contentWindow.postMessage({
|
|
108
|
-
type: 'SET_FORM_RENDER_MATERIAL',
|
|
109
|
-
materialData: materialData
|
|
110
|
-
}, '*');
|
|
56
|
+
// --- 解决方案开始 ---
|
|
57
|
+
var iframeWindow = (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : _iframe3.contentWindow;
|
|
58
|
+
if (!iframeWindow) {
|
|
59
|
+
console.error('Iframe window is not available.');
|
|
60
|
+
return;
|
|
111
61
|
}
|
|
112
62
|
|
|
113
|
-
//
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
63
|
+
// 定义一个检查并初始化引擎的函数
|
|
64
|
+
var _checkAndInit = function checkAndInit() {
|
|
65
|
+
// 检查关键依赖函数是否存在
|
|
66
|
+
if (typeof iframeWindow.__ReactSimulatorRenderer__.getFormRenderMaterial === 'function') {
|
|
67
|
+
var _iframeWindow$__FR_EN;
|
|
68
|
+
// ✅ 环境就绪,执行引擎初始化
|
|
69
|
+
(_iframeWindow$__FR_EN = iframeWindow.__FR_ENGINE__) === null || _iframeWindow$__FR_EN === void 0 ? void 0 : _iframeWindow$__FR_EN.init(_objectSpread({
|
|
70
|
+
settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
|
|
71
|
+
widgets: widgets,
|
|
72
|
+
// recordEnable: true,
|
|
73
|
+
logo: {
|
|
74
|
+
title: 'XRender'
|
|
75
|
+
}
|
|
76
|
+
}, restProps));
|
|
77
|
+
} else {
|
|
78
|
+
// ⌛ 环境未就绪,可能是 fr-generator.js 还在加载/解析中,设置定时器重试
|
|
79
|
+
console.warn('XRender 依赖资源 getFormRenderMaterial 尚未加载完毕,正在重试...');
|
|
80
|
+
// 使用 setTimeout 进行非阻塞式轮询,避免阻塞 UI 线程
|
|
81
|
+
setTimeout(_checkAndInit, 50);
|
|
119
82
|
}
|
|
120
|
-
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// 启动检查流程
|
|
86
|
+
_checkAndInit();
|
|
87
|
+
// --- 解决方案结束 ---
|
|
121
88
|
};
|
|
122
89
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
123
90
|
ref: containerRef,
|