@alicloud/alfa-react 1.7.1-alpha.2 → 1.7.1-beta.1
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/.storybook/main.ts +49 -0
- package/.storybook/preview.ts +14 -0
- package/es/components/ErrorBoundary/index.js +7 -9
- package/es/components/Loading/Paragraph.js +6 -8
- package/es/components/Loading/Skeleton.js +8 -10
- package/es/components/Loading/Title.js +2 -2
- package/es/createAlfaApp.js +4 -4
- package/es/createAlfaWidget.js +8 -8
- package/es/createApplication.js +43 -33
- package/es/loaders/beforeLoadHook.js +13 -13
- package/es/loaders/beforeResolveHook.js +5 -5
- package/es/schedule.js +1 -2
- package/es/types/base.js +5 -6
- package/es/utils/getConsoleConfig.js +4 -4
- package/es/utils/getConsoleGlobal.js +4 -4
- package/es/version.js +1 -1
- package/es/widget/emitter.js +6 -8
- package/es/widget/getWidgetConfigById.js +8 -8
- package/es/widget/getWidgetDeps.js +28 -29
- package/es/widget/getWidgetVersionById.js +19 -19
- package/es/widget.js +13 -13
- package/lib/components/ErrorBoundary/ErrorPanel.js +1 -2
- package/lib/components/ErrorBoundary/index.js +9 -12
- package/lib/components/Loading/Paragraph.js +8 -12
- package/lib/components/Loading/Skeleton.js +10 -14
- package/lib/components/Loading/Title.js +4 -6
- package/lib/components/Loading/style.js +1 -2
- package/lib/createAlfaApp.js +6 -8
- package/lib/createAlfaWidget.js +10 -12
- package/lib/createApplication.js +44 -35
- package/lib/index.js +1 -2
- package/lib/loaders/beforeLoadHook.js +14 -15
- package/lib/loaders/beforeResolveHook.js +6 -7
- package/lib/schedule.js +3 -5
- package/lib/types/base.js +7 -9
- package/lib/utils/counter.js +2 -3
- package/lib/utils/getConsoleConfig.js +6 -7
- package/lib/utils/getConsoleGlobal.js +6 -7
- package/lib/utils/index.js +11 -21
- package/lib/version.js +1 -2
- package/lib/widget/emitter.js +7 -10
- package/lib/widget/env.js +4 -7
- package/lib/widget/getWidgetConfigById.js +11 -12
- package/lib/widget/getWidgetDeps.js +32 -35
- package/lib/widget/getWidgetVersionById.js +24 -26
- package/lib/widget.js +14 -15
- package/package.json +27 -13
- package/scripts/postinstall.js +95 -0
- package/types/components/ErrorBoundary/index.d.ts +4 -3
- package/types/components/Loading/Paragraph.d.ts +1 -1
- package/types/components/Loading/Skeleton.d.ts +2 -2
- package/types/components/Loading/Title.d.ts +2 -1
- package/types/components/Loading/index.d.ts +1 -1
- package/types/createAlfaApp.d.ts +3 -5
- package/types/createApplication.d.ts +2 -1
- package/types/types/index.d.ts +6 -3
- package/types/utils/getConsoleConfig.d.ts +1 -0
- package/types/version.d.ts +1 -1
- package/types/widget.d.ts +3 -2
- package/es/hooks/beforeLoadHook.js +0 -82
- package/es/hooks/beforeResolveHook.js +0 -41
- package/lib/hooks/beforeLoadHook.js +0 -90
- package/lib/hooks/beforeResolveHook.js +0 -48
- package/types/hooks/beforeLoadHook.d.ts +0 -7
- package/types/hooks/beforeResolveHook.d.ts +0 -3
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { NodePackageImporter } from 'sass';
|
|
2
|
+
import { mergeConfig } from 'vite';
|
|
3
|
+
import type { StorybookConfig } from '@storybook/react-vite';
|
|
4
|
+
import { nodePolyfills } from 'vite-plugin-node-polyfills'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const config: StorybookConfig = {
|
|
8
|
+
stories: ['../stories/*.@(js|jsx|mjs|ts|tsx)'],
|
|
9
|
+
addons: [
|
|
10
|
+
'@storybook/addon-onboarding',
|
|
11
|
+
'@storybook/addon-links',
|
|
12
|
+
'@storybook/addon-essentials',
|
|
13
|
+
'@chromatic-com/storybook',
|
|
14
|
+
'@storybook/addon-interactions',
|
|
15
|
+
],
|
|
16
|
+
framework: {
|
|
17
|
+
name: '@storybook/react-vite',
|
|
18
|
+
options: {
|
|
19
|
+
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
typescript: {
|
|
23
|
+
// Enables the `react-docgen-typescript` parser.
|
|
24
|
+
// See https://storybook.js.org/docs/api/main-config/main-config-typescript for more information about this option.
|
|
25
|
+
reactDocgen: 'react-docgen-typescript',
|
|
26
|
+
},
|
|
27
|
+
async viteFinal(config) {
|
|
28
|
+
return mergeConfig(config, {
|
|
29
|
+
// Add dependencies to pre-optimization
|
|
30
|
+
resolve: {
|
|
31
|
+
alias: {}
|
|
32
|
+
},
|
|
33
|
+
define: {
|
|
34
|
+
'process.env': JSON.stringify({}),
|
|
35
|
+
},
|
|
36
|
+
plugins: [nodePolyfills()],
|
|
37
|
+
css: {
|
|
38
|
+
preprocessorOptions: {
|
|
39
|
+
scss: {
|
|
40
|
+
api: "modern-compiler",
|
|
41
|
+
importers: [new NodePackageImporter()],
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default config;
|
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
3
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
5
4
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
6
|
-
|
|
7
|
-
function
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
7
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import isFunction from 'lodash
|
|
9
|
+
import { isFunction } from 'lodash-es';
|
|
10
10
|
import ErrorPanel from './ErrorPanel';
|
|
11
11
|
var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
12
|
-
_inherits(ErrorBoundary, _React$Component);
|
|
13
|
-
var _super = _createSuper(ErrorBoundary);
|
|
14
12
|
function ErrorBoundary(props) {
|
|
15
13
|
var _this;
|
|
16
14
|
_classCallCheck(this, ErrorBoundary);
|
|
17
|
-
_this =
|
|
15
|
+
_this = _callSuper(this, ErrorBoundary, [props]);
|
|
18
16
|
_this.state = {
|
|
19
17
|
hasError: false,
|
|
20
18
|
error: undefined
|
|
21
19
|
};
|
|
22
20
|
return _this;
|
|
23
21
|
}
|
|
24
|
-
|
|
22
|
+
_inherits(ErrorBoundary, _React$Component);
|
|
23
|
+
return _createClass(ErrorBoundary, [{
|
|
25
24
|
key: "componentDidCatch",
|
|
26
25
|
value: function componentDidCatch(error, errorInfo) {
|
|
27
26
|
var _window, _window$__bl, _window2, _window2$__bl;
|
|
@@ -59,6 +58,5 @@ var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
|
59
58
|
return this.props.children;
|
|
60
59
|
}
|
|
61
60
|
}]);
|
|
62
|
-
return ErrorBoundary;
|
|
63
61
|
}(React.Component);
|
|
64
62
|
export default ErrorBoundary;
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
6
5
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
7
|
-
|
|
8
|
-
function
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
8
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
9
|
import * as React from 'react';
|
|
10
10
|
import classNames from 'classnames';
|
|
11
11
|
var Paragraph = /*#__PURE__*/function (_React$Component) {
|
|
12
|
-
_inherits(Paragraph, _React$Component);
|
|
13
|
-
var _super = _createSuper(Paragraph);
|
|
14
12
|
function Paragraph() {
|
|
15
13
|
_classCallCheck(this, Paragraph);
|
|
16
|
-
return
|
|
14
|
+
return _callSuper(this, Paragraph, arguments);
|
|
17
15
|
}
|
|
18
|
-
|
|
16
|
+
_inherits(Paragraph, _React$Component);
|
|
17
|
+
return _createClass(Paragraph, [{
|
|
19
18
|
key: "getWidth",
|
|
20
19
|
value: function getWidth(index) {
|
|
21
20
|
var _this$props = this.props,
|
|
@@ -58,6 +57,5 @@ var Paragraph = /*#__PURE__*/function (_React$Component) {
|
|
|
58
57
|
}, rowList);
|
|
59
58
|
}
|
|
60
59
|
}]);
|
|
61
|
-
return Paragraph;
|
|
62
60
|
}(React.Component);
|
|
63
61
|
export default Paragraph;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
6
5
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
7
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
8
|
-
function ownKeys(
|
|
9
|
-
function _objectSpread(
|
|
10
|
-
function
|
|
11
|
-
function _isNativeReflectConstruct() {
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
11
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
12
12
|
import * as React from 'react';
|
|
13
13
|
import classNames from 'classnames';
|
|
14
14
|
import Title from './Title';
|
|
@@ -45,15 +45,13 @@ function getParagraphBasicProps(hasTitle) {
|
|
|
45
45
|
return basicProps;
|
|
46
46
|
}
|
|
47
47
|
var Skeleton = /*#__PURE__*/function (_React$Component) {
|
|
48
|
-
_inherits(Skeleton, _React$Component);
|
|
49
|
-
var _super = _createSuper(Skeleton);
|
|
50
48
|
function Skeleton() {
|
|
51
49
|
var _this;
|
|
52
50
|
_classCallCheck(this, Skeleton);
|
|
53
51
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
54
52
|
args[_key] = arguments[_key];
|
|
55
53
|
}
|
|
56
|
-
_this =
|
|
54
|
+
_this = _callSuper(this, Skeleton, [].concat(args));
|
|
57
55
|
_this.renderSkeleton = function () {
|
|
58
56
|
var _this$props = _this.props,
|
|
59
57
|
_this$props$prefixCls = _this$props.prefixCls,
|
|
@@ -99,7 +97,8 @@ var Skeleton = /*#__PURE__*/function (_React$Component) {
|
|
|
99
97
|
};
|
|
100
98
|
return _this;
|
|
101
99
|
}
|
|
102
|
-
|
|
100
|
+
_inherits(Skeleton, _React$Component);
|
|
101
|
+
return _createClass(Skeleton, [{
|
|
103
102
|
key: "componentDidMount",
|
|
104
103
|
value: function componentDidMount() {
|
|
105
104
|
var id = '-os-skeleton-style';
|
|
@@ -117,7 +116,6 @@ var Skeleton = /*#__PURE__*/function (_React$Component) {
|
|
|
117
116
|
return this.renderSkeleton();
|
|
118
117
|
}
|
|
119
118
|
}]);
|
|
120
|
-
return Skeleton;
|
|
121
119
|
}(React.Component);
|
|
122
120
|
Skeleton.defaultProps = {
|
|
123
121
|
title: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
function ownKeys(
|
|
3
|
-
function _objectSpread(
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
var Title = function Title(_ref) {
|
package/es/createAlfaApp.js
CHANGED
|
@@ -2,8 +2,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
-
function ownKeys(
|
|
6
|
-
function _objectSpread(
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
import React, { useMemo } from 'react';
|
|
8
8
|
import { BaseLoader } from '@alicloud/alfa-core';
|
|
9
9
|
import ErrorBoundary from './components/ErrorBoundary';
|
|
@@ -35,8 +35,8 @@ function createAlfaApp(option) {
|
|
|
35
35
|
dynamicConfig: typeof dynamicConfig === 'boolean' ? dynamicConfig : !manifest
|
|
36
36
|
}));
|
|
37
37
|
preLoader = /*#__PURE__*/function () {
|
|
38
|
-
var _ref2 = _asyncToGenerator(
|
|
39
|
-
return _regeneratorRuntime.wrap(function
|
|
38
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
39
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
40
40
|
while (1) switch (_context.prev = _context.next) {
|
|
41
41
|
case 0:
|
|
42
42
|
return _context.abrupt("return", p);
|
package/es/createAlfaWidget.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
3
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
-
function ownKeys(
|
|
5
|
-
function _objectSpread(
|
|
4
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
6
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
7
|
import React, { useMemo } from 'react';
|
|
8
8
|
import LazyLoad from 'react-lazyload';
|
|
@@ -18,10 +18,10 @@ import { IS_SSR } from './utils';
|
|
|
18
18
|
var loader = BaseLoader.create();
|
|
19
19
|
loader.beforeResolve.use(beforeResolveHook);
|
|
20
20
|
loader.beforeLoad.use(beforeLoadHook);
|
|
21
|
-
loader.beforeLoad.use(
|
|
22
|
-
var _ref = _asyncToGenerator(
|
|
21
|
+
loader.beforeLoad.use(/*#__PURE__*/function () {
|
|
22
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(appConfig) {
|
|
23
23
|
var app;
|
|
24
|
-
return _regeneratorRuntime.wrap(function
|
|
24
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
25
25
|
while (1) switch (_context.prev = _context.next) {
|
|
26
26
|
case 0:
|
|
27
27
|
app = appConfig.app;
|
|
@@ -30,7 +30,7 @@ loader.beforeLoad.use( /*#__PURE__*/function () {
|
|
|
30
30
|
app.context.history = {};
|
|
31
31
|
}
|
|
32
32
|
return _context.abrupt("return", appConfig);
|
|
33
|
-
case
|
|
33
|
+
case 1:
|
|
34
34
|
case "end":
|
|
35
35
|
return _context.stop();
|
|
36
36
|
}
|
|
@@ -68,8 +68,8 @@ function createAlfaWidget(option) {
|
|
|
68
68
|
dynamicConfig: typeof dynamicConfig === 'boolean' ? dynamicConfig : !manifest
|
|
69
69
|
}));
|
|
70
70
|
preLoader = /*#__PURE__*/function () {
|
|
71
|
-
var _ref3 = _asyncToGenerator(
|
|
72
|
-
return _regeneratorRuntime.wrap(function
|
|
71
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
72
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
73
73
|
while (1) switch (_context2.prev = _context2.next) {
|
|
74
74
|
case 0:
|
|
75
75
|
return _context2.abrupt("return", p);
|
package/es/createApplication.js
CHANGED
|
@@ -3,8 +3,8 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
|
-
function ownKeys(
|
|
7
|
-
function _objectSpread(
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
8
|
import React, { useRef, useEffect, useState, useMemo, useContext, useCallback } from 'react';
|
|
9
9
|
import { createEventBus } from '@alicloud/alfa-core';
|
|
10
10
|
import { ConsoleRegion, ConsoleResourceGroup, ConsoleContext } from '@alicloud/xconsole-context';
|
|
@@ -58,6 +58,7 @@ export default function createApplication(loader) {
|
|
|
58
58
|
basename = props.basename,
|
|
59
59
|
channel = props.channel,
|
|
60
60
|
delayPromise = props.delayPromise,
|
|
61
|
+
forceLog = props.forceLog,
|
|
61
62
|
preLoader = props.preLoader;
|
|
62
63
|
var handleExternalLink = customProps.handleExternalLink;
|
|
63
64
|
var _useState = useState(null),
|
|
@@ -83,6 +84,7 @@ export default function createApplication(loader) {
|
|
|
83
84
|
preLoader: preLoader,
|
|
84
85
|
container: container
|
|
85
86
|
});
|
|
87
|
+
var mountedApp = useRef(false);
|
|
86
88
|
var onSyncHistory = useCallbackRef(props.onSyncHistory || function () {});
|
|
87
89
|
$syncHistory.current = syncHistory;
|
|
88
90
|
$basename.current = basename;
|
|
@@ -224,42 +226,42 @@ export default function createApplication(loader) {
|
|
|
224
226
|
|
|
225
227
|
// 受控模式下,返回不会触发子应用内的路由更新,需要主动通知
|
|
226
228
|
if ($syncHistory.current) window.addEventListener('popstate', updateAppHistory);
|
|
227
|
-
_asyncToGenerator(
|
|
229
|
+
_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
228
230
|
var _app$context$updateBo, _app$context, _app$context$baseFram;
|
|
229
|
-
var fakeBody, _ref2, app, logger, realVersion, _ref3, path, frameWindow;
|
|
230
|
-
return _regeneratorRuntime.wrap(function
|
|
231
|
+
var fakeBody, _ref2, app, logger, realVersion, _ref3, path, frameWindow, _t;
|
|
232
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
231
233
|
while (1) switch (_context.prev = _context.next) {
|
|
232
234
|
case 0:
|
|
233
235
|
countRegister(memoOptions.name);
|
|
234
236
|
fakeBody = getFakeBody();
|
|
235
237
|
if (!initOptions.current.delayPromise) {
|
|
236
|
-
_context.next =
|
|
238
|
+
_context.next = 1;
|
|
237
239
|
break;
|
|
238
240
|
}
|
|
239
|
-
_context.next =
|
|
241
|
+
_context.next = 1;
|
|
240
242
|
return initOptions.current.delayPromise;
|
|
241
|
-
case
|
|
243
|
+
case 1:
|
|
242
244
|
if (!initOptions.current.preLoader) {
|
|
243
|
-
_context.next =
|
|
245
|
+
_context.next = 3;
|
|
244
246
|
break;
|
|
245
247
|
}
|
|
246
|
-
_context.next =
|
|
248
|
+
_context.next = 2;
|
|
247
249
|
return initOptions.current.preLoader(_objectSpread(_objectSpread({}, memoOptions), {}, {
|
|
248
250
|
container: fakeBody
|
|
249
251
|
}));
|
|
250
|
-
case
|
|
251
|
-
|
|
252
|
-
_context.next =
|
|
252
|
+
case 2:
|
|
253
|
+
_t = _context.sent;
|
|
254
|
+
_context.next = 5;
|
|
253
255
|
break;
|
|
254
|
-
case
|
|
255
|
-
_context.next =
|
|
256
|
+
case 3:
|
|
257
|
+
_context.next = 4;
|
|
256
258
|
return loader.register(_objectSpread(_objectSpread({}, memoOptions), {}, {
|
|
257
259
|
container: fakeBody
|
|
258
260
|
}));
|
|
259
|
-
case
|
|
260
|
-
|
|
261
|
-
case
|
|
262
|
-
_ref2 =
|
|
261
|
+
case 4:
|
|
262
|
+
_t = _context.sent;
|
|
263
|
+
case 5:
|
|
264
|
+
_ref2 = _t;
|
|
263
265
|
app = _ref2.app;
|
|
264
266
|
logger = _ref2.logger;
|
|
265
267
|
realVersion = _ref2.version;
|
|
@@ -268,29 +270,31 @@ export default function createApplication(loader) {
|
|
|
268
270
|
|
|
269
271
|
// container has been unmounted
|
|
270
272
|
if (!isUnmounted) {
|
|
271
|
-
_context.next =
|
|
273
|
+
_context.next = 6;
|
|
272
274
|
break;
|
|
273
275
|
}
|
|
274
276
|
return _context.abrupt("return");
|
|
275
|
-
case
|
|
277
|
+
case 6:
|
|
276
278
|
if (app) {
|
|
277
|
-
_context.next =
|
|
279
|
+
_context.next = 7;
|
|
278
280
|
break;
|
|
279
281
|
}
|
|
280
282
|
return _context.abrupt("return", (logger === null || logger === void 0 ? void 0 : logger.error) && logger.error({
|
|
281
283
|
E_CODE: 'RuntimeError',
|
|
282
|
-
E_MSG: 'load app failed.'
|
|
284
|
+
E_MSG: 'load app failed.',
|
|
285
|
+
__force_log__: forceLog
|
|
283
286
|
}));
|
|
284
|
-
case
|
|
287
|
+
case 7:
|
|
285
288
|
if (appRef.current) {
|
|
286
|
-
_context.next =
|
|
289
|
+
_context.next = 8;
|
|
287
290
|
break;
|
|
288
291
|
}
|
|
289
292
|
return _context.abrupt("return", (logger === null || logger === void 0 ? void 0 : logger.error) && logger.error({
|
|
290
293
|
E_CODE: 'RuntimeError',
|
|
291
|
-
E_MSG: 'cannot find container.'
|
|
294
|
+
E_MSG: 'cannot find container.',
|
|
295
|
+
__force_log__: forceLog
|
|
292
296
|
}));
|
|
293
|
-
case
|
|
297
|
+
case 8:
|
|
294
298
|
// update body in sandbox context
|
|
295
299
|
(_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 : fakeBody);
|
|
296
300
|
_ref3 = memoOptions.props, path = _ref3.path;
|
|
@@ -327,16 +331,17 @@ export default function createApplication(loader) {
|
|
|
327
331
|
window.history.go(n);
|
|
328
332
|
});
|
|
329
333
|
}
|
|
330
|
-
(logger === null || logger === void 0 ? void 0 : logger.record) &&
|
|
334
|
+
(logger === null || logger === void 0 ? void 0 : logger.record) && logger.record({
|
|
331
335
|
REQUEST_VERSION: memoOptions.version,
|
|
332
336
|
RESPONSE_VERSION: realVersion,
|
|
333
|
-
END_TIME: Date.now()
|
|
334
|
-
|
|
335
|
-
|
|
337
|
+
END_TIME: Date.now(),
|
|
338
|
+
__force_log__: forceLog
|
|
339
|
+
});
|
|
340
|
+
(logger === null || logger === void 0 ? void 0 : logger.send) && logger.send();
|
|
336
341
|
|
|
337
342
|
// just run once
|
|
338
343
|
setAppInstance(app);
|
|
339
|
-
case
|
|
344
|
+
case 9:
|
|
340
345
|
case "end":
|
|
341
346
|
return _context.stop();
|
|
342
347
|
}
|
|
@@ -384,6 +389,10 @@ export default function createApplication(loader) {
|
|
|
384
389
|
var _appInstance$context$;
|
|
385
390
|
if (isUnmounted) return;
|
|
386
391
|
|
|
392
|
+
// 保持 path 的路由同步,请勿删除
|
|
393
|
+
appInstance.update(customProps);
|
|
394
|
+
mountedApp.current = true;
|
|
395
|
+
|
|
387
396
|
// 每次挂载后检查是否还有 lazyload 组件未加载
|
|
388
397
|
setTimeout(function () {
|
|
389
398
|
forceCheck();
|
|
@@ -402,9 +411,10 @@ export default function createApplication(loader) {
|
|
|
402
411
|
return function () {
|
|
403
412
|
isUnmounted = true;
|
|
404
413
|
appInstance.unmount();
|
|
414
|
+
mountedApp.current = false;
|
|
405
415
|
};
|
|
406
416
|
}, [appInstance, getFakeBody]);
|
|
407
|
-
if (appInstance) {
|
|
417
|
+
if (appInstance && mountedApp.current) {
|
|
408
418
|
appInstance.update(customProps);
|
|
409
419
|
}
|
|
410
420
|
var dataAttrs = {
|
|
@@ -2,8 +2,8 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
-
function ownKeys(
|
|
6
|
-
function _objectSpread(
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
import { getConfig, getI18nMessages } from '@alicloud/alfa-core';
|
|
8
8
|
import { getConsoleConfig } from '../utils/getConsoleConfig';
|
|
9
9
|
import { getConsoleGlobal } from '../utils/getConsoleGlobal';
|
|
@@ -12,9 +12,9 @@ function afterLoadHook(_x) {
|
|
|
12
12
|
return _afterLoadHook.apply(this, arguments);
|
|
13
13
|
}
|
|
14
14
|
function _afterLoadHook() {
|
|
15
|
-
_afterLoadHook = _asyncToGenerator(
|
|
15
|
+
_afterLoadHook = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(appConfig) {
|
|
16
16
|
var app, logger, sandbox, dynamicConfig, channel, defaultConsoleConfig, defaultConsoleGlobal, CONFIG_START_TIME, CONFIG_END_TIME, configData, _yield$Promise$all, _yield$Promise$all2, consoleConfig, consoleGlobal, messages, i18nMessages, overrides;
|
|
17
|
-
return _regeneratorRuntime.wrap(function
|
|
17
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
18
18
|
while (1) switch (_context.prev = _context.next) {
|
|
19
19
|
case 0:
|
|
20
20
|
app = appConfig.app, logger = appConfig.logger, sandbox = appConfig.sandbox, dynamicConfig = appConfig.dynamicConfig, channel = appConfig.channel;
|
|
@@ -23,16 +23,16 @@ function _afterLoadHook() {
|
|
|
23
23
|
CONFIG_START_TIME = Date.now();
|
|
24
24
|
CONFIG_END_TIME = Date.now();
|
|
25
25
|
if (!dynamicConfig) {
|
|
26
|
-
_context.next =
|
|
26
|
+
_context.next = 3;
|
|
27
27
|
break;
|
|
28
28
|
}
|
|
29
|
-
_context.next =
|
|
29
|
+
_context.next = 1;
|
|
30
30
|
return getConfig(appConfig);
|
|
31
|
-
case
|
|
31
|
+
case 1:
|
|
32
32
|
configData = _context.sent;
|
|
33
|
-
_context.next =
|
|
33
|
+
_context.next = 2;
|
|
34
34
|
return Promise.all([getConsoleConfig(configData, defaultConsoleConfig, channel), getConsoleGlobal(configData, defaultConsoleGlobal), getI18nMessages(appConfig)]);
|
|
35
|
-
case
|
|
35
|
+
case 2:
|
|
36
36
|
_yield$Promise$all = _context.sent;
|
|
37
37
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
|
|
38
38
|
consoleConfig = _yield$Promise$all2[0];
|
|
@@ -46,16 +46,16 @@ function _afterLoadHook() {
|
|
|
46
46
|
app.context.window.ALIYUN_CONSOLE_I18N_MESSAGE = i18nMessages;
|
|
47
47
|
app.context.window.ALIYUN_WIND_MESSAGE = window.ALIYUN_WIND_MESSAGE;
|
|
48
48
|
}
|
|
49
|
-
_context.next =
|
|
49
|
+
_context.next = 4;
|
|
50
50
|
break;
|
|
51
|
-
case
|
|
51
|
+
case 3:
|
|
52
52
|
if (app !== null && app !== void 0 && app.context && !(sandbox !== null && sandbox !== void 0 && sandbox.disable)) {
|
|
53
53
|
app.context.window.ALIYUN_CONSOLE_CONFIG = defaultConsoleConfig;
|
|
54
54
|
app.context.window.ALIYUN_CONSOLE_GLOBAL = defaultConsoleGlobal;
|
|
55
55
|
app.context.window.ALIYUN_CONSOLE_I18N_MESSAGE = window.ALIYUN_CONSOLE_I18N_MESSAGE;
|
|
56
56
|
app.context.window.ALIYUN_WIND_MESSAGE = window.ALIYUN_WIND_MESSAGE;
|
|
57
57
|
}
|
|
58
|
-
case
|
|
58
|
+
case 4:
|
|
59
59
|
overrides = sandbox === null || sandbox === void 0 ? void 0 : sandbox.overrideGlobalVars;
|
|
60
60
|
if (overrides && app) {
|
|
61
61
|
Object.entries(overrides).forEach(function (_ref) {
|
|
@@ -71,7 +71,7 @@ function _afterLoadHook() {
|
|
|
71
71
|
COST: CONFIG_END_TIME - CONFIG_START_TIME
|
|
72
72
|
});
|
|
73
73
|
return _context.abrupt("return", appConfig);
|
|
74
|
-
case
|
|
74
|
+
case 5:
|
|
75
75
|
case "end":
|
|
76
76
|
return _context.stop();
|
|
77
77
|
}
|
|
@@ -9,17 +9,17 @@ function beforeResolveHook(_x) {
|
|
|
9
9
|
return _beforeResolveHook.apply(this, arguments);
|
|
10
10
|
}
|
|
11
11
|
function _beforeResolveHook() {
|
|
12
|
-
_beforeResolveHook = _asyncToGenerator(
|
|
12
|
+
_beforeResolveHook = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(appConfig) {
|
|
13
13
|
var logger, START_TIME, MANIFEST_START_TIME, resolvedManifest, MANIFEST_END_TIME;
|
|
14
|
-
return _regeneratorRuntime.wrap(function
|
|
14
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
15
15
|
while (1) switch (_context.prev = _context.next) {
|
|
16
16
|
case 0:
|
|
17
17
|
logger = appConfig.logger;
|
|
18
18
|
START_TIME = Date.now();
|
|
19
19
|
MANIFEST_START_TIME = Date.now();
|
|
20
|
-
_context.next =
|
|
20
|
+
_context.next = 1;
|
|
21
21
|
return getManifest(appConfig);
|
|
22
|
-
case
|
|
22
|
+
case 1:
|
|
23
23
|
resolvedManifest = _context.sent;
|
|
24
24
|
MANIFEST_END_TIME = Date.now();
|
|
25
25
|
(logger === null || logger === void 0 ? void 0 : logger.record) && logger.record({
|
|
@@ -30,7 +30,7 @@ function _beforeResolveHook() {
|
|
|
30
30
|
});
|
|
31
31
|
appConfig.manifest = resolvedManifest;
|
|
32
32
|
return _context.abrupt("return", appConfig);
|
|
33
|
-
case
|
|
33
|
+
case 2:
|
|
34
34
|
case "end":
|
|
35
35
|
return _context.stop();
|
|
36
36
|
}
|
package/es/schedule.js
CHANGED
|
@@ -7,7 +7,7 @@ export var Schedule = /*#__PURE__*/function () {
|
|
|
7
7
|
this.running = [];
|
|
8
8
|
this.delaying = [];
|
|
9
9
|
}
|
|
10
|
-
_createClass(Schedule, [{
|
|
10
|
+
return _createClass(Schedule, [{
|
|
11
11
|
key: "push",
|
|
12
12
|
value: function push(priority, task) {
|
|
13
13
|
var _this = this;
|
|
@@ -37,5 +37,4 @@ export var Schedule = /*#__PURE__*/function () {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}]);
|
|
40
|
-
return Schedule;
|
|
41
40
|
}();
|
package/es/types/base.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
3
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
5
4
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
6
|
-
|
|
7
|
-
function
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
7
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
8
8
|
import React from 'react';
|
|
9
9
|
var MicroAppBase = /*#__PURE__*/function (_React$Component) {
|
|
10
|
-
_inherits(MicroAppBase, _React$Component);
|
|
11
|
-
var _super = _createSuper(MicroAppBase);
|
|
12
10
|
function MicroAppBase() {
|
|
13
11
|
_classCallCheck(this, MicroAppBase);
|
|
14
|
-
return
|
|
12
|
+
return _callSuper(this, MicroAppBase, arguments);
|
|
15
13
|
}
|
|
14
|
+
_inherits(MicroAppBase, _React$Component);
|
|
16
15
|
return _createClass(MicroAppBase);
|
|
17
16
|
}(React.Component);
|
|
18
17
|
export { MicroAppBase as default };
|