@alicloud/alfa-react 1.3.1-alpha.4 → 1.3.3
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/LICENSE +21 -0
- package/dist/index.js +6 -6
- package/es/createAlfaApp.js +0 -4
- package/es/createApplication.js +38 -17
- package/es/version.js +1 -1
- package/lib/createAlfaApp.js +0 -4
- package/lib/createApplication.js +37 -16
- package/lib/types/index.d.ts +1 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +3 -3
package/es/createAlfaApp.js
CHANGED
|
@@ -21,10 +21,6 @@ function createAlfaApp(option) {
|
|
|
21
21
|
};
|
|
22
22
|
var passedInOption = option;
|
|
23
23
|
return /*#__PURE__*/React.memo(function (props) {
|
|
24
|
-
if ('sandbox' in props) {
|
|
25
|
-
console.warn('');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
24
|
return /*#__PURE__*/React.createElement(ErrorBoundary, props, /*#__PURE__*/React.createElement(Application, _extends({}, passedInOption, {
|
|
29
25
|
sandbox: option.sandbox || props.sandbox,
|
|
30
26
|
deps: dependencies || {},
|
package/es/createApplication.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
-
|
|
6
|
+
|
|
7
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
+
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
+
|
|
11
|
+
import React, { useRef, useEffect, useState, useMemo } from 'react';
|
|
5
12
|
import Loading from './components/Loading';
|
|
6
13
|
import { normalizeName } from './utils';
|
|
7
14
|
|
|
@@ -16,7 +23,6 @@ export default function createApplication(loader) {
|
|
|
16
23
|
version = props.version,
|
|
17
24
|
manifest = props.manifest,
|
|
18
25
|
loading = props.loading,
|
|
19
|
-
sandbox = props.sandbox,
|
|
20
26
|
customProps = props.customProps,
|
|
21
27
|
className = props.className,
|
|
22
28
|
style = props.style,
|
|
@@ -30,7 +36,8 @@ export default function createApplication(loader) {
|
|
|
30
36
|
afterMount = props.afterMount,
|
|
31
37
|
beforeUnmount = props.beforeUnmount,
|
|
32
38
|
afterUnmount = props.afterUnmount,
|
|
33
|
-
beforeUpdate = props.beforeUpdate
|
|
39
|
+
beforeUpdate = props.beforeUpdate,
|
|
40
|
+
customSandbox = props.sandbox;
|
|
34
41
|
|
|
35
42
|
var _useState = useState(null),
|
|
36
43
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -39,6 +46,12 @@ export default function createApplication(loader) {
|
|
|
39
46
|
|
|
40
47
|
var appRef = useRef(null);
|
|
41
48
|
var tagName = normalizeName(props.name);
|
|
49
|
+
var sandbox = useMemo(function () {
|
|
50
|
+
return _objectSpread(_objectSpread({}, customSandbox), {}, {
|
|
51
|
+
externalsVars: [].concat(_toConsumableArray((customSandbox === null || customSandbox === void 0 ? void 0 : customSandbox.externalsVars) || []), [// global vars used in ConsoleBase.forApp
|
|
52
|
+
'_console_base_ready_'])
|
|
53
|
+
});
|
|
54
|
+
}, [customSandbox]);
|
|
42
55
|
useEffect(function () {
|
|
43
56
|
// eslint-disable-next-line no-useless-catch
|
|
44
57
|
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
@@ -48,7 +61,15 @@ export default function createApplication(loader) {
|
|
|
48
61
|
while (1) {
|
|
49
62
|
switch (_context.prev = _context.next) {
|
|
50
63
|
case 0:
|
|
51
|
-
|
|
64
|
+
if (!app) {
|
|
65
|
+
_context.next = 2;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return _context.abrupt("return");
|
|
70
|
+
|
|
71
|
+
case 2:
|
|
72
|
+
_context.next = 4;
|
|
52
73
|
return loader.register({
|
|
53
74
|
entry: entry,
|
|
54
75
|
url: url,
|
|
@@ -68,14 +89,13 @@ export default function createApplication(loader) {
|
|
|
68
89
|
beforeUpdate: beforeUpdate
|
|
69
90
|
});
|
|
70
91
|
|
|
71
|
-
case
|
|
92
|
+
case 4:
|
|
72
93
|
_yield$loader$registe = _context.sent;
|
|
73
94
|
App = _yield$loader$registe.app;
|
|
74
95
|
logger = _yield$loader$registe.logger;
|
|
75
|
-
console.log(App, '===');
|
|
76
96
|
|
|
77
97
|
if (App) {
|
|
78
|
-
_context.next =
|
|
98
|
+
_context.next = 9;
|
|
79
99
|
break;
|
|
80
100
|
}
|
|
81
101
|
|
|
@@ -83,9 +103,9 @@ export default function createApplication(loader) {
|
|
|
83
103
|
E_MSG: 'load app failed.'
|
|
84
104
|
}));
|
|
85
105
|
|
|
86
|
-
case
|
|
106
|
+
case 9:
|
|
87
107
|
if (appRef.current) {
|
|
88
|
-
_context.next =
|
|
108
|
+
_context.next = 11;
|
|
89
109
|
break;
|
|
90
110
|
}
|
|
91
111
|
|
|
@@ -93,17 +113,14 @@ export default function createApplication(loader) {
|
|
|
93
113
|
E_MSG: 'cannot find container.'
|
|
94
114
|
}));
|
|
95
115
|
|
|
96
|
-
case
|
|
97
|
-
_context.next =
|
|
116
|
+
case 11:
|
|
117
|
+
_context.next = 13;
|
|
98
118
|
return App.mount(appRef.current, {
|
|
99
119
|
customProps: customProps
|
|
100
120
|
});
|
|
101
121
|
|
|
102
|
-
case
|
|
122
|
+
case 13:
|
|
103
123
|
setApp(App);
|
|
104
|
-
return _context.abrupt("return", function () {
|
|
105
|
-
App && App.unmount();
|
|
106
|
-
});
|
|
107
124
|
|
|
108
125
|
case 14:
|
|
109
126
|
case "end":
|
|
@@ -114,7 +131,11 @@ export default function createApplication(loader) {
|
|
|
114
131
|
}))().catch(function (e) {
|
|
115
132
|
throw e;
|
|
116
133
|
});
|
|
117
|
-
|
|
134
|
+
|
|
135
|
+
return function () {
|
|
136
|
+
app && app.unmount();
|
|
137
|
+
};
|
|
138
|
+
}, [app, name, manifest, customProps, sandbox, entry, url, version, container, customLogger, deps, env, beforeMount, afterMount, beforeUnmount, afterUnmount, beforeUpdate]);
|
|
118
139
|
|
|
119
140
|
if (app) {
|
|
120
141
|
app.update(customProps);
|
|
@@ -122,7 +143,7 @@ export default function createApplication(loader) {
|
|
|
122
143
|
|
|
123
144
|
return /*#__PURE__*/React.createElement(React.Fragment, null, !app ? /*#__PURE__*/React.createElement(Loading, {
|
|
124
145
|
loading: loading
|
|
125
|
-
}) : null, sandbox && sandbox
|
|
146
|
+
}) : null, sandbox && sandbox.disableFakeBody ? /*#__PURE__*/React.createElement(tagName, {
|
|
126
147
|
style: style,
|
|
127
148
|
className: className,
|
|
128
149
|
ref: appRef,
|
package/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var version = '1.3.
|
|
1
|
+
export var version = '1.3.3';
|
package/lib/createAlfaApp.js
CHANGED
|
@@ -38,10 +38,6 @@ function createAlfaApp(option) {
|
|
|
38
38
|
};
|
|
39
39
|
var passedInOption = option;
|
|
40
40
|
return /*#__PURE__*/_react.default.memo(function (props) {
|
|
41
|
-
if ('sandbox' in props) {
|
|
42
|
-
console.warn('');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
41
|
return /*#__PURE__*/_react.default.createElement(_ErrorBoundary.default, props, /*#__PURE__*/_react.default.createElement(Application, (0, _extends2.default)({}, passedInOption, {
|
|
46
42
|
sandbox: option.sandbox || props.sandbox,
|
|
47
43
|
deps: dependencies || {},
|
package/lib/createApplication.js
CHANGED
|
@@ -13,6 +13,10 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
13
13
|
|
|
14
14
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
15
|
|
|
16
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
17
|
+
|
|
18
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
+
|
|
16
20
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
21
|
|
|
18
22
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -25,6 +29,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
25
29
|
|
|
26
30
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
31
|
|
|
32
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
33
|
+
|
|
34
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
35
|
+
|
|
28
36
|
/**
|
|
29
37
|
* container for microApp mount
|
|
30
38
|
* @param loader alfa-core loader
|
|
@@ -36,7 +44,6 @@ function createApplication(loader) {
|
|
|
36
44
|
version = props.version,
|
|
37
45
|
manifest = props.manifest,
|
|
38
46
|
loading = props.loading,
|
|
39
|
-
sandbox = props.sandbox,
|
|
40
47
|
customProps = props.customProps,
|
|
41
48
|
className = props.className,
|
|
42
49
|
style = props.style,
|
|
@@ -50,7 +57,8 @@ function createApplication(loader) {
|
|
|
50
57
|
afterMount = props.afterMount,
|
|
51
58
|
beforeUnmount = props.beforeUnmount,
|
|
52
59
|
afterUnmount = props.afterUnmount,
|
|
53
|
-
beforeUpdate = props.beforeUpdate
|
|
60
|
+
beforeUpdate = props.beforeUpdate,
|
|
61
|
+
customSandbox = props.sandbox;
|
|
54
62
|
|
|
55
63
|
var _useState = (0, _react.useState)(null),
|
|
56
64
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -59,6 +67,12 @@ function createApplication(loader) {
|
|
|
59
67
|
|
|
60
68
|
var appRef = (0, _react.useRef)(null);
|
|
61
69
|
var tagName = (0, _utils.normalizeName)(props.name);
|
|
70
|
+
var sandbox = (0, _react.useMemo)(function () {
|
|
71
|
+
return _objectSpread(_objectSpread({}, customSandbox), {}, {
|
|
72
|
+
externalsVars: [].concat((0, _toConsumableArray2.default)((customSandbox === null || customSandbox === void 0 ? void 0 : customSandbox.externalsVars) || []), [// global vars used in ConsoleBase.forApp
|
|
73
|
+
'_console_base_ready_'])
|
|
74
|
+
});
|
|
75
|
+
}, [customSandbox]);
|
|
62
76
|
(0, _react.useEffect)(function () {
|
|
63
77
|
// eslint-disable-next-line no-useless-catch
|
|
64
78
|
(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
@@ -68,7 +82,15 @@ function createApplication(loader) {
|
|
|
68
82
|
while (1) {
|
|
69
83
|
switch (_context.prev = _context.next) {
|
|
70
84
|
case 0:
|
|
71
|
-
|
|
85
|
+
if (!app) {
|
|
86
|
+
_context.next = 2;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return _context.abrupt("return");
|
|
91
|
+
|
|
92
|
+
case 2:
|
|
93
|
+
_context.next = 4;
|
|
72
94
|
return loader.register({
|
|
73
95
|
entry: entry,
|
|
74
96
|
url: url,
|
|
@@ -88,14 +110,13 @@ function createApplication(loader) {
|
|
|
88
110
|
beforeUpdate: beforeUpdate
|
|
89
111
|
});
|
|
90
112
|
|
|
91
|
-
case
|
|
113
|
+
case 4:
|
|
92
114
|
_yield$loader$registe = _context.sent;
|
|
93
115
|
App = _yield$loader$registe.app;
|
|
94
116
|
logger = _yield$loader$registe.logger;
|
|
95
|
-
console.log(App, '===');
|
|
96
117
|
|
|
97
118
|
if (App) {
|
|
98
|
-
_context.next =
|
|
119
|
+
_context.next = 9;
|
|
99
120
|
break;
|
|
100
121
|
}
|
|
101
122
|
|
|
@@ -103,9 +124,9 @@ function createApplication(loader) {
|
|
|
103
124
|
E_MSG: 'load app failed.'
|
|
104
125
|
}));
|
|
105
126
|
|
|
106
|
-
case
|
|
127
|
+
case 9:
|
|
107
128
|
if (appRef.current) {
|
|
108
|
-
_context.next =
|
|
129
|
+
_context.next = 11;
|
|
109
130
|
break;
|
|
110
131
|
}
|
|
111
132
|
|
|
@@ -113,17 +134,14 @@ function createApplication(loader) {
|
|
|
113
134
|
E_MSG: 'cannot find container.'
|
|
114
135
|
}));
|
|
115
136
|
|
|
116
|
-
case
|
|
117
|
-
_context.next =
|
|
137
|
+
case 11:
|
|
138
|
+
_context.next = 13;
|
|
118
139
|
return App.mount(appRef.current, {
|
|
119
140
|
customProps: customProps
|
|
120
141
|
});
|
|
121
142
|
|
|
122
|
-
case
|
|
143
|
+
case 13:
|
|
123
144
|
setApp(App);
|
|
124
|
-
return _context.abrupt("return", function () {
|
|
125
|
-
App && App.unmount();
|
|
126
|
-
});
|
|
127
145
|
|
|
128
146
|
case 14:
|
|
129
147
|
case "end":
|
|
@@ -134,7 +152,10 @@ function createApplication(loader) {
|
|
|
134
152
|
}))().catch(function (e) {
|
|
135
153
|
throw e;
|
|
136
154
|
});
|
|
137
|
-
|
|
155
|
+
return function () {
|
|
156
|
+
app && app.unmount();
|
|
157
|
+
};
|
|
158
|
+
}, [app, name, manifest, customProps, sandbox, entry, url, version, container, customLogger, deps, env, beforeMount, afterMount, beforeUnmount, afterUnmount, beforeUpdate]);
|
|
138
159
|
|
|
139
160
|
if (app) {
|
|
140
161
|
app.update(customProps);
|
|
@@ -142,7 +163,7 @@ function createApplication(loader) {
|
|
|
142
163
|
|
|
143
164
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !app ? /*#__PURE__*/_react.default.createElement(_Loading.default, {
|
|
144
165
|
loading: loading
|
|
145
|
-
}) : null, sandbox && sandbox
|
|
166
|
+
}) : null, sandbox && sandbox.disableFakeBody ? /*#__PURE__*/_react.default.createElement(tagName, {
|
|
146
167
|
style: style,
|
|
147
168
|
className: className,
|
|
148
169
|
ref: appRef,
|
package/lib/types/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export interface AlfaFactoryOption extends IAppConfig {
|
|
|
19
19
|
css?: Record<string, string>;
|
|
20
20
|
js?: Record<string, string>;
|
|
21
21
|
};
|
|
22
|
+
runtimeVersion?: string;
|
|
22
23
|
}
|
|
23
24
|
declare type OmitKeys = 'manifest';
|
|
24
25
|
export interface WidgetFactoryOption extends Omit<AlfaFactoryOption, OmitKeys> {
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.3.
|
|
1
|
+
export declare const version = "1.3.3";
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alicloud/alfa-react",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Alfa Framework (React Version)",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"typescript": "^3.0.3"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@alicloud/alfa-core": "^1.3.
|
|
42
|
+
"@alicloud/alfa-core": "^1.3.3",
|
|
43
43
|
"@alicloud/console-os-loader": "^1.2.3",
|
|
44
44
|
"@alicloud/widget-utils-console": "^0.1.6",
|
|
45
45
|
"classnames": "^2.2.6",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"react": "^16 | ^17"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "0ee54132107a373f2d13b548a747461aa3dcfc7c"
|
|
52
52
|
}
|