@alicloud/alfa-react 1.4.15 → 1.4.18
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/dist/index.js +1 -1
- package/es/createApplication.js +38 -15
- package/es/utils/getConsoleConfig.js +6 -2
- package/es/version.js +1 -1
- package/lib/createApplication.js +38 -15
- package/lib/utils/getConsoleConfig.js +6 -2
- package/lib/version.js +1 -1
- package/package.json +2 -2
- package/types/version.d.ts +1 -1
package/es/createApplication.js
CHANGED
|
@@ -43,8 +43,8 @@ export default function createApplication(loader) {
|
|
|
43
43
|
|
|
44
44
|
var _useState = useState(null),
|
|
45
45
|
_useState2 = _slicedToArray(_useState, 2),
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
appInstance = _useState2[0],
|
|
47
|
+
setAppInstance = _useState2[1];
|
|
48
48
|
|
|
49
49
|
var _useState3 = useState(null),
|
|
50
50
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
@@ -53,13 +53,26 @@ export default function createApplication(loader) {
|
|
|
53
53
|
var appRef = useRef(undefined);
|
|
54
54
|
var tagName = normalizeName(props.name);
|
|
55
55
|
var sandbox = useMemo(function () {
|
|
56
|
+
var _UA_Opt, _RISK_INFO, _um;
|
|
57
|
+
|
|
58
|
+
var aliyunExternalsVars = [];
|
|
59
|
+
|
|
60
|
+
if ((_UA_Opt = window.UA_Opt) !== null && _UA_Opt !== void 0 && _UA_Opt.LogVal) {
|
|
61
|
+
var _UA_Opt2;
|
|
62
|
+
|
|
63
|
+
aliyunExternalsVars.push('UA_Opt');
|
|
64
|
+
aliyunExternalsVars.push((_UA_Opt2 = window.UA_Opt) === null || _UA_Opt2 === void 0 ? void 0 : _UA_Opt2.LogVal);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if ((_RISK_INFO = window.RISK_INFO) !== null && _RISK_INFO !== void 0 && _RISK_INFO.UMID) aliyunExternalsVars.push('RISK_INFO');
|
|
68
|
+
if ((_um = window.um) !== null && _um !== void 0 && _um.getToken) aliyunExternalsVars.push('um');
|
|
56
69
|
return _objectSpread(_objectSpread({}, customSandbox), {}, {
|
|
57
70
|
// allowResources: [
|
|
58
71
|
// ...(customSandbox?.allowResources || []),
|
|
59
72
|
// /^https?:\/\/at\.alicdn\.com\//,
|
|
60
73
|
// ],
|
|
61
74
|
externalsVars: [].concat(_toConsumableArray((customSandbox === null || customSandbox === void 0 ? void 0 : customSandbox.externalsVars) || []), [// global vars used in ConsoleBase.forApp
|
|
62
|
-
'_console_base_ready_'])
|
|
75
|
+
'_console_base_ready_'], aliyunExternalsVars)
|
|
63
76
|
});
|
|
64
77
|
}, [customSandbox]);
|
|
65
78
|
var memoOptions = useMemo(function () {
|
|
@@ -86,6 +99,7 @@ export default function createApplication(loader) {
|
|
|
86
99
|
};
|
|
87
100
|
}, []);
|
|
88
101
|
useEffect(function () {
|
|
102
|
+
var isUnmounted = false;
|
|
89
103
|
var App;
|
|
90
104
|
|
|
91
105
|
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
@@ -106,21 +120,29 @@ export default function createApplication(loader) {
|
|
|
106
120
|
_yield$loader$registe = _context.sent;
|
|
107
121
|
app = _yield$loader$registe.app;
|
|
108
122
|
logger = _yield$loader$registe.logger;
|
|
109
|
-
App = app;
|
|
123
|
+
App = app; // container has been unmounted
|
|
110
124
|
|
|
111
|
-
if (
|
|
125
|
+
if (!isUnmounted) {
|
|
112
126
|
_context.next = 8;
|
|
113
127
|
break;
|
|
114
128
|
}
|
|
115
129
|
|
|
130
|
+
return _context.abrupt("return");
|
|
131
|
+
|
|
132
|
+
case 8:
|
|
133
|
+
if (app) {
|
|
134
|
+
_context.next = 10;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
|
|
116
138
|
return _context.abrupt("return", (logger === null || logger === void 0 ? void 0 : logger.error) && logger.error({
|
|
117
139
|
E_CODE: 'RuntimeError',
|
|
118
140
|
E_MSG: 'load app failed.'
|
|
119
141
|
}));
|
|
120
142
|
|
|
121
|
-
case
|
|
143
|
+
case 10:
|
|
122
144
|
if (appRef.current) {
|
|
123
|
-
_context.next =
|
|
145
|
+
_context.next = 12;
|
|
124
146
|
break;
|
|
125
147
|
}
|
|
126
148
|
|
|
@@ -129,18 +151,18 @@ export default function createApplication(loader) {
|
|
|
129
151
|
E_MSG: 'cannot find container.'
|
|
130
152
|
}));
|
|
131
153
|
|
|
132
|
-
case
|
|
154
|
+
case 12:
|
|
133
155
|
// update body in sandbox context
|
|
134
156
|
(_app$context$updateBo = (_app$context = app.context).updateBody) === null || _app$context$updateBo === void 0 ? void 0 : _app$context$updateBo.call(_app$context, memoOptions.sandbox.disableFakeBody ? document.body : appRef.current);
|
|
135
|
-
_context.next =
|
|
157
|
+
_context.next = 15;
|
|
136
158
|
return app.mount(appRef.current, {
|
|
137
159
|
customProps: customProps
|
|
138
160
|
});
|
|
139
161
|
|
|
140
|
-
case
|
|
141
|
-
|
|
162
|
+
case 15:
|
|
163
|
+
setAppInstance(app);
|
|
142
164
|
|
|
143
|
-
case
|
|
165
|
+
case 16:
|
|
144
166
|
case "end":
|
|
145
167
|
return _context.stop();
|
|
146
168
|
}
|
|
@@ -153,12 +175,13 @@ export default function createApplication(loader) {
|
|
|
153
175
|
});
|
|
154
176
|
|
|
155
177
|
return function () {
|
|
178
|
+
isUnmounted = true;
|
|
156
179
|
App && App.unmount();
|
|
157
180
|
};
|
|
158
181
|
}, [memoOptions]);
|
|
159
182
|
|
|
160
|
-
if (
|
|
161
|
-
|
|
183
|
+
if (appInstance) {
|
|
184
|
+
appInstance.update(customProps);
|
|
162
185
|
}
|
|
163
186
|
|
|
164
187
|
var dataAttrs = {
|
|
@@ -166,7 +189,7 @@ export default function createApplication(loader) {
|
|
|
166
189
|
'data-version': version,
|
|
167
190
|
'data-loader': loaderVersion
|
|
168
191
|
};
|
|
169
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, !
|
|
192
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, !appInstance ? /*#__PURE__*/React.createElement(Loading, {
|
|
170
193
|
loading: loading
|
|
171
194
|
}) : null, sandbox && sandbox.disableFakeBody ? /*#__PURE__*/React.createElement(tagName, _objectSpread({
|
|
172
195
|
style: style,
|
|
@@ -34,8 +34,12 @@ var processFeatures = function processFeatures(features) {
|
|
|
34
34
|
newFeatures[key] = true;
|
|
35
35
|
} else if (enableSampling) {
|
|
36
36
|
var gray = uid.substring(uid.length - 2);
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
|
|
38
|
+
if (Number(gray) >= (sampling !== null && sampling !== void 0 ? sampling : 0) * 100 || sampling === 0) {
|
|
39
|
+
newFeatures[key] = false;
|
|
40
|
+
} else {
|
|
41
|
+
newFeatures[key] = true;
|
|
42
|
+
}
|
|
39
43
|
} else {
|
|
40
44
|
newFeatures[key] = false;
|
|
41
45
|
}
|
package/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var version = '1.4.
|
|
1
|
+
export var version = '1.4.18';
|
package/lib/createApplication.js
CHANGED
|
@@ -65,8 +65,8 @@ function createApplication(loader) {
|
|
|
65
65
|
|
|
66
66
|
var _useState = (0, _react.useState)(null),
|
|
67
67
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
appInstance = _useState2[0],
|
|
69
|
+
setAppInstance = _useState2[1];
|
|
70
70
|
|
|
71
71
|
var _useState3 = (0, _react.useState)(null),
|
|
72
72
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
@@ -75,13 +75,26 @@ function createApplication(loader) {
|
|
|
75
75
|
var appRef = (0, _react.useRef)(undefined);
|
|
76
76
|
var tagName = (0, _utils.normalizeName)(props.name);
|
|
77
77
|
var sandbox = (0, _react.useMemo)(function () {
|
|
78
|
+
var _UA_Opt, _RISK_INFO, _um;
|
|
79
|
+
|
|
80
|
+
var aliyunExternalsVars = [];
|
|
81
|
+
|
|
82
|
+
if ((_UA_Opt = window.UA_Opt) !== null && _UA_Opt !== void 0 && _UA_Opt.LogVal) {
|
|
83
|
+
var _UA_Opt2;
|
|
84
|
+
|
|
85
|
+
aliyunExternalsVars.push('UA_Opt');
|
|
86
|
+
aliyunExternalsVars.push((_UA_Opt2 = window.UA_Opt) === null || _UA_Opt2 === void 0 ? void 0 : _UA_Opt2.LogVal);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if ((_RISK_INFO = window.RISK_INFO) !== null && _RISK_INFO !== void 0 && _RISK_INFO.UMID) aliyunExternalsVars.push('RISK_INFO');
|
|
90
|
+
if ((_um = window.um) !== null && _um !== void 0 && _um.getToken) aliyunExternalsVars.push('um');
|
|
78
91
|
return _objectSpread(_objectSpread({}, customSandbox), {}, {
|
|
79
92
|
// allowResources: [
|
|
80
93
|
// ...(customSandbox?.allowResources || []),
|
|
81
94
|
// /^https?:\/\/at\.alicdn\.com\//,
|
|
82
95
|
// ],
|
|
83
96
|
externalsVars: [].concat((0, _toConsumableArray2.default)((customSandbox === null || customSandbox === void 0 ? void 0 : customSandbox.externalsVars) || []), [// global vars used in ConsoleBase.forApp
|
|
84
|
-
'_console_base_ready_'])
|
|
97
|
+
'_console_base_ready_'], aliyunExternalsVars)
|
|
85
98
|
});
|
|
86
99
|
}, [customSandbox]);
|
|
87
100
|
var memoOptions = (0, _react.useMemo)(function () {
|
|
@@ -108,6 +121,7 @@ function createApplication(loader) {
|
|
|
108
121
|
};
|
|
109
122
|
}, []);
|
|
110
123
|
(0, _react.useEffect)(function () {
|
|
124
|
+
var isUnmounted = false;
|
|
111
125
|
var App;
|
|
112
126
|
(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
113
127
|
var _app$context$updateBo, _app$context;
|
|
@@ -127,21 +141,29 @@ function createApplication(loader) {
|
|
|
127
141
|
_yield$loader$registe = _context.sent;
|
|
128
142
|
app = _yield$loader$registe.app;
|
|
129
143
|
logger = _yield$loader$registe.logger;
|
|
130
|
-
App = app;
|
|
144
|
+
App = app; // container has been unmounted
|
|
131
145
|
|
|
132
|
-
if (
|
|
146
|
+
if (!isUnmounted) {
|
|
133
147
|
_context.next = 8;
|
|
134
148
|
break;
|
|
135
149
|
}
|
|
136
150
|
|
|
151
|
+
return _context.abrupt("return");
|
|
152
|
+
|
|
153
|
+
case 8:
|
|
154
|
+
if (app) {
|
|
155
|
+
_context.next = 10;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
|
|
137
159
|
return _context.abrupt("return", (logger === null || logger === void 0 ? void 0 : logger.error) && logger.error({
|
|
138
160
|
E_CODE: 'RuntimeError',
|
|
139
161
|
E_MSG: 'load app failed.'
|
|
140
162
|
}));
|
|
141
163
|
|
|
142
|
-
case
|
|
164
|
+
case 10:
|
|
143
165
|
if (appRef.current) {
|
|
144
|
-
_context.next =
|
|
166
|
+
_context.next = 12;
|
|
145
167
|
break;
|
|
146
168
|
}
|
|
147
169
|
|
|
@@ -150,18 +172,18 @@ function createApplication(loader) {
|
|
|
150
172
|
E_MSG: 'cannot find container.'
|
|
151
173
|
}));
|
|
152
174
|
|
|
153
|
-
case
|
|
175
|
+
case 12:
|
|
154
176
|
// update body in sandbox context
|
|
155
177
|
(_app$context$updateBo = (_app$context = app.context).updateBody) === null || _app$context$updateBo === void 0 ? void 0 : _app$context$updateBo.call(_app$context, memoOptions.sandbox.disableFakeBody ? document.body : appRef.current);
|
|
156
|
-
_context.next =
|
|
178
|
+
_context.next = 15;
|
|
157
179
|
return app.mount(appRef.current, {
|
|
158
180
|
customProps: customProps
|
|
159
181
|
});
|
|
160
182
|
|
|
161
|
-
case
|
|
162
|
-
|
|
183
|
+
case 15:
|
|
184
|
+
setAppInstance(app);
|
|
163
185
|
|
|
164
|
-
case
|
|
186
|
+
case 16:
|
|
165
187
|
case "end":
|
|
166
188
|
return _context.stop();
|
|
167
189
|
}
|
|
@@ -173,12 +195,13 @@ function createApplication(loader) {
|
|
|
173
195
|
});
|
|
174
196
|
});
|
|
175
197
|
return function () {
|
|
198
|
+
isUnmounted = true;
|
|
176
199
|
App && App.unmount();
|
|
177
200
|
};
|
|
178
201
|
}, [memoOptions]);
|
|
179
202
|
|
|
180
|
-
if (
|
|
181
|
-
|
|
203
|
+
if (appInstance) {
|
|
204
|
+
appInstance.update(customProps);
|
|
182
205
|
}
|
|
183
206
|
|
|
184
207
|
var dataAttrs = {
|
|
@@ -186,7 +209,7 @@ function createApplication(loader) {
|
|
|
186
209
|
'data-version': version,
|
|
187
210
|
'data-loader': _version.version
|
|
188
211
|
};
|
|
189
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !
|
|
212
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !appInstance ? /*#__PURE__*/_react.default.createElement(_Loading.default, {
|
|
190
213
|
loading: loading
|
|
191
214
|
}) : null, sandbox && sandbox.disableFakeBody ? /*#__PURE__*/_react.default.createElement(tagName, _objectSpread({
|
|
192
215
|
style: style,
|
|
@@ -45,8 +45,12 @@ var processFeatures = function processFeatures(features) {
|
|
|
45
45
|
newFeatures[key] = true;
|
|
46
46
|
} else if (enableSampling) {
|
|
47
47
|
var gray = uid.substring(uid.length - 2);
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
|
|
49
|
+
if (Number(gray) >= (sampling !== null && sampling !== void 0 ? sampling : 0) * 100 || sampling === 0) {
|
|
50
|
+
newFeatures[key] = false;
|
|
51
|
+
} else {
|
|
52
|
+
newFeatures[key] = true;
|
|
53
|
+
}
|
|
50
54
|
} else {
|
|
51
55
|
newFeatures[key] = false;
|
|
52
56
|
}
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alicloud/alfa-react",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.18",
|
|
4
4
|
"description": "Alfa Framework (React Version)",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"react": "^16 | ^17"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "db8e327b03e92de9a4d1670080866d488095e3b1"
|
|
55
55
|
}
|
package/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.4.
|
|
1
|
+
export declare const version = "1.4.18";
|