@alicloud/alfa-react 1.3.0-canary.8 → 1.3.1-alpha.2
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 +6 -6
- package/es/app.js +47 -48
- package/es/components/ErrorBoundary/ErrorPanel.js +2 -2
- package/es/components/ErrorBoundary/index.js +15 -15
- package/es/components/Loading/Skeleton.js +2 -2
- package/es/components/Loading/Title.js +2 -2
- package/es/createAlfaApp.js +15 -95
- package/es/createAlfaWidget.js +29 -81
- package/es/createApplication.js +54 -26
- package/es/hooks/afterLoadHook.js +69 -0
- package/es/hooks/beforeResolveHook.js +55 -0
- package/es/index.js +2 -2
- package/es/types/base.js +2 -1
- package/es/utils/getConsoleConfig.js +3 -5
- package/es/version.js +1 -0
- package/es/widget/emitter.js +4 -4
- package/es/widget/getWidgetConfigById.js +5 -6
- package/es/widget/getWidgetDeps.js +5 -5
- package/es/widget.js +3 -3
- package/lib/app.d.ts +1 -1
- package/lib/app.js +45 -48
- package/lib/components/ErrorBoundary/ErrorPanel.d.ts +1 -1
- package/lib/components/ErrorBoundary/ErrorPanel.js +2 -2
- package/lib/components/ErrorBoundary/index.d.ts +7 -9
- package/lib/components/ErrorBoundary/index.js +15 -15
- package/lib/components/Loading/Skeleton.js +2 -2
- package/lib/components/Loading/Title.js +2 -2
- package/lib/createAlfaApp.d.ts +4 -0
- package/lib/createAlfaApp.js +54 -0
- package/lib/createAlfaWidget.d.ts +4 -0
- package/lib/createAlfaWidget.js +94 -0
- package/lib/createApplication.d.ts +12 -0
- package/lib/createApplication.js +161 -0
- package/lib/hooks/afterLoadHook.d.ts +3 -0
- package/lib/hooks/afterLoadHook.js +84 -0
- package/lib/hooks/beforeResolveHook.d.ts +3 -0
- package/lib/hooks/beforeResolveHook.js +69 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +6 -4
- package/lib/{base.d.ts → types/base.d.ts} +4 -1
- package/lib/{base.js → types/base.js} +3 -1
- package/lib/{types.d.ts → types/index.d.ts} +9 -8
- package/lib/{types.js → types/index.js} +0 -0
- package/lib/utils/getConsoleConfig.d.ts +21 -0
- package/lib/utils/getConsoleConfig.js +100 -0
- package/lib/{utils.d.ts → utils/index.d.ts} +0 -1
- package/lib/{utils.js → utils/index.js} +2 -8
- package/lib/version.d.ts +1 -0
- package/lib/version.js +8 -0
- package/lib/widget/emitter.d.ts +0 -1
- package/lib/widget/emitter.js +4 -4
- package/lib/widget/getWidgetConfigById.js +5 -6
- package/lib/widget/getWidgetDeps.js +4 -4
- package/lib/widget.d.ts +1 -1
- package/lib/widget.js +4 -4
- package/package.json +12 -7
- package/LICENSE +0 -21
- package/es/app/createIsomorphicMicroApp.js +0 -44
- package/es/app/getConsoleConfig.js +0 -49
- package/es/base.js +0 -26
- package/es/context.js +0 -7
- package/es/types.js +0 -1
- package/es/utils.js +0 -6
- package/lib/app/createIsomorphicMicroApp.d.ts +0 -2
- package/lib/app/createIsomorphicMicroApp.js +0 -63
- package/lib/app/getConsoleConfig.d.ts +0 -2
- package/lib/app/getConsoleConfig.js +0 -62
- package/lib/context.d.ts +0 -7
- package/lib/context.js +0 -15
package/es/createApplication.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
-
import React, {
|
|
4
|
+
import React, { useRef, useEffect, useState } from 'react';
|
|
5
5
|
import Loading from './components/Loading';
|
|
6
6
|
import { normalizeName } from './utils';
|
|
7
7
|
|
|
@@ -11,14 +11,26 @@ import { normalizeName } from './utils';
|
|
|
11
11
|
* @returns
|
|
12
12
|
*/
|
|
13
13
|
export default function createApplication(loader) {
|
|
14
|
-
function Application(props) {
|
|
14
|
+
return function Application(props) {
|
|
15
15
|
var name = props.name,
|
|
16
|
+
version = props.version,
|
|
16
17
|
manifest = props.manifest,
|
|
17
18
|
loading = props.loading,
|
|
18
19
|
sandbox = props.sandbox,
|
|
19
20
|
customProps = props.customProps,
|
|
20
21
|
className = props.className,
|
|
21
|
-
style = props.style
|
|
22
|
+
style = props.style,
|
|
23
|
+
container = props.container,
|
|
24
|
+
entry = props.entry,
|
|
25
|
+
url = props.url,
|
|
26
|
+
customLogger = props.logger,
|
|
27
|
+
deps = props.deps,
|
|
28
|
+
env = props.env,
|
|
29
|
+
beforeMount = props.beforeMount,
|
|
30
|
+
afterMount = props.afterMount,
|
|
31
|
+
beforeUnmount = props.beforeUnmount,
|
|
32
|
+
afterUnmount = props.afterUnmount,
|
|
33
|
+
beforeUpdate = props.beforeUpdate;
|
|
22
34
|
|
|
23
35
|
var _useState = useState(null),
|
|
24
36
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -30,7 +42,7 @@ export default function createApplication(loader) {
|
|
|
30
42
|
useEffect(function () {
|
|
31
43
|
// eslint-disable-next-line no-useless-catch
|
|
32
44
|
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
33
|
-
var _yield$loader$registe, App;
|
|
45
|
+
var _yield$loader$registe, App, logger;
|
|
34
46
|
|
|
35
47
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
36
48
|
while (1) {
|
|
@@ -38,49 +50,65 @@ export default function createApplication(loader) {
|
|
|
38
50
|
case 0:
|
|
39
51
|
_context.next = 2;
|
|
40
52
|
return loader.register({
|
|
53
|
+
entry: entry,
|
|
54
|
+
url: url,
|
|
41
55
|
name: name,
|
|
56
|
+
version: version,
|
|
42
57
|
manifest: manifest,
|
|
43
|
-
container: appRef.current,
|
|
58
|
+
container: container || appRef.current,
|
|
44
59
|
props: customProps,
|
|
45
|
-
sandbox: sandbox
|
|
60
|
+
sandbox: sandbox,
|
|
61
|
+
logger: customLogger,
|
|
62
|
+
deps: deps,
|
|
63
|
+
env: env,
|
|
64
|
+
beforeMount: beforeMount,
|
|
65
|
+
afterMount: afterMount,
|
|
66
|
+
beforeUnmount: beforeUnmount,
|
|
67
|
+
afterUnmount: afterUnmount,
|
|
68
|
+
beforeUpdate: beforeUpdate
|
|
46
69
|
});
|
|
47
70
|
|
|
48
71
|
case 2:
|
|
49
72
|
_yield$loader$registe = _context.sent;
|
|
50
73
|
App = _yield$loader$registe.app;
|
|
74
|
+
logger = _yield$loader$registe.logger;
|
|
51
75
|
|
|
52
76
|
if (App) {
|
|
53
|
-
_context.next =
|
|
77
|
+
_context.next = 7;
|
|
54
78
|
break;
|
|
55
79
|
}
|
|
56
80
|
|
|
57
|
-
|
|
81
|
+
return _context.abrupt("return", logger === null || logger === void 0 ? void 0 : logger.error({
|
|
82
|
+
E_MSG: 'load app failed.'
|
|
83
|
+
}));
|
|
58
84
|
|
|
59
|
-
case
|
|
60
|
-
_context.next =
|
|
85
|
+
case 7:
|
|
86
|
+
_context.next = 9;
|
|
61
87
|
return App.load();
|
|
62
88
|
|
|
63
|
-
case
|
|
89
|
+
case 9:
|
|
64
90
|
if (appRef.current) {
|
|
65
|
-
_context.next =
|
|
91
|
+
_context.next = 11;
|
|
66
92
|
break;
|
|
67
93
|
}
|
|
68
94
|
|
|
69
|
-
|
|
95
|
+
return _context.abrupt("return", logger === null || logger === void 0 ? void 0 : logger.error({
|
|
96
|
+
E_MSG: 'cannot find container.'
|
|
97
|
+
}));
|
|
70
98
|
|
|
71
|
-
case
|
|
72
|
-
_context.next =
|
|
99
|
+
case 11:
|
|
100
|
+
_context.next = 13;
|
|
73
101
|
return App.mount(appRef.current, {
|
|
74
102
|
customProps: customProps
|
|
75
103
|
});
|
|
76
104
|
|
|
77
|
-
case
|
|
105
|
+
case 13:
|
|
78
106
|
setApp(App);
|
|
79
107
|
return _context.abrupt("return", function () {
|
|
80
108
|
App && App.unmount();
|
|
81
109
|
});
|
|
82
110
|
|
|
83
|
-
case
|
|
111
|
+
case 15:
|
|
84
112
|
case "end":
|
|
85
113
|
return _context.stop();
|
|
86
114
|
}
|
|
@@ -89,25 +117,25 @@ export default function createApplication(loader) {
|
|
|
89
117
|
}))().catch(function (e) {
|
|
90
118
|
throw e;
|
|
91
119
|
});
|
|
92
|
-
}, [name, manifest, customProps, sandbox]);
|
|
120
|
+
}, [name, manifest, customProps, sandbox, entry, url, version, container, customLogger, deps, env, beforeMount, afterMount, beforeUnmount, afterUnmount, beforeUpdate]);
|
|
93
121
|
|
|
94
122
|
if (app) {
|
|
95
123
|
app.update(customProps);
|
|
96
124
|
}
|
|
97
125
|
|
|
98
|
-
|
|
99
|
-
|
|
126
|
+
if (!app) {
|
|
127
|
+
return /*#__PURE__*/React.createElement(Loading, {
|
|
100
128
|
loading: loading
|
|
101
|
-
})
|
|
102
|
-
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, sandbox && sandbox !== true && sandbox.disableFakeBody ? /*#__PURE__*/React.createElement(tagName, {
|
|
103
133
|
style: style,
|
|
104
134
|
className: className,
|
|
105
135
|
ref: appRef,
|
|
106
136
|
dataId: name
|
|
107
137
|
}) : /*#__PURE__*/React.createElement(tagName, {}, /*#__PURE__*/React.createElement('div', {
|
|
108
138
|
ref: appRef
|
|
109
|
-
})))
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return Application;
|
|
139
|
+
})));
|
|
140
|
+
};
|
|
113
141
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
|
|
6
|
+
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; }
|
|
7
|
+
|
|
8
|
+
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; }
|
|
9
|
+
|
|
10
|
+
import { getLocale } from '@alicloud/alfa-core';
|
|
11
|
+
import { getConsoleConfig } from '../utils/getConsoleConfig'; // inject consoleConfig & locales after load
|
|
12
|
+
|
|
13
|
+
function afterLoadHook(_x) {
|
|
14
|
+
return _afterLoadHook.apply(this, arguments);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function _afterLoadHook() {
|
|
18
|
+
_afterLoadHook = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(appConfig) {
|
|
19
|
+
var app, logger, defaultConsoleConfig, CONFIG_START_TIME, _yield$Promise$all$ca, _yield$Promise$all$ca2, consoleConfig, messages, CONFIG_END_TIME, i18nMessages, END_TIME;
|
|
20
|
+
|
|
21
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
22
|
+
while (1) {
|
|
23
|
+
switch (_context.prev = _context.next) {
|
|
24
|
+
case 0:
|
|
25
|
+
app = appConfig.app, logger = appConfig.logger;
|
|
26
|
+
defaultConsoleConfig = window.ALIYUN_CONSOLE_CONFIG || {};
|
|
27
|
+
CONFIG_START_TIME = Date.now();
|
|
28
|
+
_context.next = 5;
|
|
29
|
+
return Promise.all([getConsoleConfig(appConfig, defaultConsoleConfig), getLocale(appConfig)]).catch(function (e) {
|
|
30
|
+
logger === null || logger === void 0 ? void 0 : logger.error({
|
|
31
|
+
E_MSG: 'fetch config & locale error.',
|
|
32
|
+
E_STACK: e
|
|
33
|
+
});
|
|
34
|
+
return [{}, {}];
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
case 5:
|
|
38
|
+
_yield$Promise$all$ca = _context.sent;
|
|
39
|
+
_yield$Promise$all$ca2 = _slicedToArray(_yield$Promise$all$ca, 2);
|
|
40
|
+
consoleConfig = _yield$Promise$all$ca2[0];
|
|
41
|
+
messages = _yield$Promise$all$ca2[1];
|
|
42
|
+
CONFIG_END_TIME = Date.now();
|
|
43
|
+
i18nMessages = _objectSpread(_objectSpread({}, window.ALIYUN_CONSOLE_I18N_MESSAGE), messages);
|
|
44
|
+
|
|
45
|
+
if (app && app.context) {
|
|
46
|
+
app.context.window.ALIYUN_CONSOLE_CONFIG = consoleConfig;
|
|
47
|
+
app.context.window.ALIYUN_CONSOLE_I18N_MESSAGE = i18nMessages; // (app.context.history as any) = {};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
END_TIME = Date.now();
|
|
51
|
+
logger === null || logger === void 0 ? void 0 : logger.record({
|
|
52
|
+
CONFIG_START_TIME: CONFIG_START_TIME,
|
|
53
|
+
CONFIG_END_TIME: CONFIG_END_TIME,
|
|
54
|
+
END_TIME: END_TIME
|
|
55
|
+
});
|
|
56
|
+
logger === null || logger === void 0 ? void 0 : logger.send();
|
|
57
|
+
return _context.abrupt("return", appConfig);
|
|
58
|
+
|
|
59
|
+
case 16:
|
|
60
|
+
case "end":
|
|
61
|
+
return _context.stop();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}, _callee);
|
|
65
|
+
}));
|
|
66
|
+
return _afterLoadHook.apply(this, arguments);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default afterLoadHook;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import { getManifest } from '@alicloud/alfa-core';
|
|
4
|
+
import { version as LOADER_VERSION } from '../version'; // get manifest before resolve
|
|
5
|
+
// normalize name
|
|
6
|
+
|
|
7
|
+
function beforeResolveHook(_x) {
|
|
8
|
+
return _beforeResolveHook.apply(this, arguments);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function _beforeResolveHook() {
|
|
12
|
+
_beforeResolveHook = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(appConfig) {
|
|
13
|
+
var resolvedManifest, logger, START_TIME, MANIFEST_START_TIME, MANIFEST_END_TIME;
|
|
14
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
15
|
+
while (1) {
|
|
16
|
+
switch (_context.prev = _context.next) {
|
|
17
|
+
case 0:
|
|
18
|
+
resolvedManifest = appConfig.manifest;
|
|
19
|
+
logger = appConfig.logger;
|
|
20
|
+
START_TIME = Date.now();
|
|
21
|
+
MANIFEST_START_TIME = Date.now();
|
|
22
|
+
|
|
23
|
+
if (resolvedManifest) {
|
|
24
|
+
_context.next = 8;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
_context.next = 7;
|
|
29
|
+
return getManifest(appConfig);
|
|
30
|
+
|
|
31
|
+
case 7:
|
|
32
|
+
resolvedManifest = _context.sent;
|
|
33
|
+
|
|
34
|
+
case 8:
|
|
35
|
+
MANIFEST_END_TIME = Date.now();
|
|
36
|
+
logger === null || logger === void 0 ? void 0 : logger.record({
|
|
37
|
+
LOADER_VERSION: LOADER_VERSION,
|
|
38
|
+
START_TIME: START_TIME,
|
|
39
|
+
MANIFEST_START_TIME: MANIFEST_START_TIME,
|
|
40
|
+
MANIFEST_END_TIME: MANIFEST_END_TIME
|
|
41
|
+
});
|
|
42
|
+
appConfig.manifest = resolvedManifest;
|
|
43
|
+
return _context.abrupt("return", appConfig);
|
|
44
|
+
|
|
45
|
+
case 12:
|
|
46
|
+
case "end":
|
|
47
|
+
return _context.stop();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, _callee);
|
|
51
|
+
}));
|
|
52
|
+
return _beforeResolveHook.apply(this, arguments);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default beforeResolveHook;
|
package/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { default as createAlfaApp } from './createAlfaApp';
|
|
2
|
+
export { default as createAlfaWidget } from './createAlfaWidget';
|
|
3
3
|
export { eventEmitter as widgetEventEmitter } from './widget/index'; // todo
|
|
4
4
|
|
|
5
5
|
export { createEventBus, prefetch } from '@alicloud/alfa-core';
|
package/es/types/base.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
3
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
3
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
@@ -20,7 +21,7 @@ var MicroAppBase = /*#__PURE__*/function (_React$Component) {
|
|
|
20
21
|
return _super.apply(this, arguments);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
return MicroAppBase;
|
|
24
|
+
return _createClass(MicroAppBase);
|
|
24
25
|
}(React.Component);
|
|
25
26
|
|
|
26
27
|
export { MicroAppBase as default };
|
|
@@ -2,9 +2,9 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
5
|
+
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; }
|
|
6
6
|
|
|
7
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
7
|
+
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; }
|
|
8
8
|
|
|
9
9
|
import { getConfig } from '@alicloud/alfa-core';
|
|
10
10
|
import md5 from 'crypto-js/md5';
|
|
@@ -12,7 +12,6 @@ import md5 from 'crypto-js/md5';
|
|
|
12
12
|
* transform
|
|
13
13
|
* @param features
|
|
14
14
|
*/
|
|
15
|
-
//@ts-ignore
|
|
16
15
|
|
|
17
16
|
var processFeatures = function processFeatures(features) {
|
|
18
17
|
return Object.keys(features).reduce(function (newFeatures, key) {
|
|
@@ -50,8 +49,7 @@ var mergeConfigDataWithConsoleConfig = function mergeConfigDataWithConsoleConfig
|
|
|
50
49
|
|
|
51
50
|
var channel = ((_window = window) === null || _window === void 0 ? void 0 : (_window$ALIYUN_CONSOL = _window.ALIYUN_CONSOLE_CONFIG) === null || _window$ALIYUN_CONSOL === void 0 ? void 0 : _window$ALIYUN_CONSOL.CHANNEL) || 'OFFICIAL';
|
|
52
51
|
var channelLinks = ((_configData$ALL_CHANN = configData.ALL_CHANNEL_LINKS) === null || _configData$ALL_CHANN === void 0 ? void 0 : _configData$ALL_CHANN[channel]) || {};
|
|
53
|
-
var channelFeatures = ((_configData$ALL_CHANN2 = configData.ALL_CHANNEL_FEATURE_STATUS) === null || _configData$ALL_CHANN2 === void 0 ? void 0 : _configData$ALL_CHANN2[channel]) || {};
|
|
54
|
-
|
|
52
|
+
var channelFeatures = ((_configData$ALL_CHANN2 = configData.ALL_CHANNEL_FEATURE_STATUS) === null || _configData$ALL_CHANN2 === void 0 ? void 0 : _configData$ALL_CHANN2[channel]) || {};
|
|
55
53
|
var features = configData.ALL_FEATURE_STATUS || {};
|
|
56
54
|
return _objectSpread(_objectSpread({}, consoleConfig), {}, {
|
|
57
55
|
CHANNEL_LINKS: channelLinks,
|
package/es/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var version = '1.3.1-alpha.2';
|
package/es/widget/emitter.js
CHANGED
|
@@ -18,13 +18,13 @@ var WidgetEventEmitter = /*#__PURE__*/function (_EventEmitter) {
|
|
|
18
18
|
function WidgetEventEmitter() {
|
|
19
19
|
_classCallCheck(this, WidgetEventEmitter);
|
|
20
20
|
|
|
21
|
-
return _super.
|
|
22
|
-
}
|
|
23
|
-
|
|
21
|
+
return _super.apply(this, arguments);
|
|
22
|
+
}
|
|
24
23
|
|
|
25
24
|
_createClass(WidgetEventEmitter, [{
|
|
26
25
|
key: "refersh",
|
|
27
|
-
value:
|
|
26
|
+
value: // Compatible with the old api, this may get removed at sometime later.
|
|
27
|
+
function refersh(widgetId) {
|
|
28
28
|
return this.emit("".concat(widgetId, ":REFRESH"));
|
|
29
29
|
}
|
|
30
30
|
}, {
|
|
@@ -12,26 +12,25 @@ export var getWidgetConfigById = /*#__PURE__*/function () {
|
|
|
12
12
|
switch (_context.prev = _context.next) {
|
|
13
13
|
case 0:
|
|
14
14
|
env = ENV[option.env || getConsoleEnv()];
|
|
15
|
-
console.log(env.configUrl);
|
|
16
15
|
|
|
17
16
|
if (cachedConfig[option.name]) {
|
|
18
|
-
_context.next =
|
|
17
|
+
_context.next = 6;
|
|
19
18
|
break;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
_context.next =
|
|
21
|
+
_context.next = 4;
|
|
23
22
|
return axios.get(template(env.configUrl)({
|
|
24
23
|
id: option.name
|
|
25
24
|
}));
|
|
26
25
|
|
|
27
|
-
case
|
|
26
|
+
case 4:
|
|
28
27
|
resp = _context.sent;
|
|
29
28
|
cachedConfig[option.name] = resp.data;
|
|
30
29
|
|
|
31
|
-
case
|
|
30
|
+
case 6:
|
|
32
31
|
return _context.abrupt("return", cachedConfig[option.name]);
|
|
33
32
|
|
|
34
|
-
case
|
|
33
|
+
case 7:
|
|
35
34
|
case "end":
|
|
36
35
|
return _context.stop();
|
|
37
36
|
}
|
|
@@ -2,9 +2,9 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
5
|
+
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; }
|
|
6
6
|
|
|
7
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
7
|
+
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; }
|
|
8
8
|
|
|
9
9
|
import react from 'react';
|
|
10
10
|
import reactDom from 'react-dom';
|
|
@@ -12,7 +12,7 @@ import axios from 'axios';
|
|
|
12
12
|
import kebabCase from 'lodash/kebabCase';
|
|
13
13
|
import * as propTypes from 'prop-types';
|
|
14
14
|
import { loadBundle } from '@alicloud/console-os-loader';
|
|
15
|
-
import {
|
|
15
|
+
import { createCWSWidget } from '../widget';
|
|
16
16
|
import { getWidgetVersionById } from './getWidgetVersionById'; // @ts-ignore
|
|
17
17
|
|
|
18
18
|
import * as widgetUtils from '@alicloud/widget-utils-console';
|
|
@@ -32,7 +32,7 @@ var createWidget = function createWidget(option) {
|
|
|
32
32
|
|
|
33
33
|
var id = _ref.id,
|
|
34
34
|
version = _ref.version;
|
|
35
|
-
return
|
|
35
|
+
return createCWSWidget({
|
|
36
36
|
name: id,
|
|
37
37
|
version: version,
|
|
38
38
|
dependencies: option === null || option === void 0 ? void 0 : option.dependencies,
|
|
@@ -160,7 +160,7 @@ export var getWidgetDeps = /*#__PURE__*/function () {
|
|
|
160
160
|
react: react,
|
|
161
161
|
'react-dom': reactDom,
|
|
162
162
|
'prop-types': propTypes,
|
|
163
|
-
|
|
163
|
+
axios: axios
|
|
164
164
|
}, cachedRuntime[version].default), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, WIDGET_UTILS_PKG_NAME, injectedWidgetUtils), _defineProperty(_objectSpread2, '@ali/widget-utils-config', injectedWidgetUtils), _defineProperty(_objectSpread2, '@ali/widget-loader', createWidget), _objectSpread2)));
|
|
165
165
|
|
|
166
166
|
case 31:
|
package/es/widget.js
CHANGED
|
@@ -3,9 +3,9 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
3
3
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
5
|
|
|
6
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
6
|
+
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; }
|
|
7
7
|
|
|
8
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
8
|
+
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; }
|
|
9
9
|
|
|
10
10
|
import React, { lazy, Suspense } from 'react';
|
|
11
11
|
import { loadBundle } from '@alicloud/console-os-loader';
|
|
@@ -13,7 +13,7 @@ import { getWidgetVersionById, getWidgetDeps, getWidgetConfigById, eventEmitter
|
|
|
13
13
|
import ErrorBoundary from './components/ErrorBoundary';
|
|
14
14
|
import Loading from './components/Loading';
|
|
15
15
|
import { normalizeName } from './utils';
|
|
16
|
-
export function
|
|
16
|
+
export function createCWSWidget(option) {
|
|
17
17
|
var AlfaWidget = /*#__PURE__*/lazy( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
18
18
|
var url, config, _yield$getWidgetVersi, version, entryUrl, deps;
|
|
19
19
|
|
package/lib/app.d.ts
CHANGED
package/lib/app.js
CHANGED
|
@@ -31,23 +31,21 @@ var _alfaCore = require("@alicloud/alfa-core");
|
|
|
31
31
|
|
|
32
32
|
var _Loading = _interopRequireDefault(require("./components/Loading"));
|
|
33
33
|
|
|
34
|
-
var
|
|
34
|
+
var _types = require("./types");
|
|
35
35
|
|
|
36
|
-
var
|
|
36
|
+
var _ErrorBoundary = _interopRequireDefault(require("./components/ErrorBoundary"));
|
|
37
37
|
|
|
38
|
-
var
|
|
38
|
+
var _getConsoleConfig = require("./utils/getConsoleConfig");
|
|
39
39
|
|
|
40
40
|
var _utils = require("./utils");
|
|
41
41
|
|
|
42
|
-
var _types = require("./types");
|
|
43
|
-
|
|
44
42
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
45
43
|
|
|
46
44
|
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; }
|
|
47
45
|
|
|
48
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
46
|
+
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; }
|
|
49
47
|
|
|
50
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
48
|
+
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; }
|
|
51
49
|
|
|
52
50
|
var getProps = function getProps(props) {
|
|
53
51
|
var parcelProps = _objectSpread({}, props);
|
|
@@ -57,10 +55,8 @@ var getProps = function getProps(props) {
|
|
|
57
55
|
delete parcelProps.loading;
|
|
58
56
|
delete parcelProps.entry;
|
|
59
57
|
delete parcelProps.container;
|
|
60
|
-
delete parcelProps.logger;
|
|
61
|
-
|
|
62
|
-
delete parcelProps.env; // @ts-ignore
|
|
63
|
-
|
|
58
|
+
delete parcelProps.logger;
|
|
59
|
+
delete parcelProps.env;
|
|
64
60
|
delete parcelProps.dependencies;
|
|
65
61
|
return parcelProps;
|
|
66
62
|
};
|
|
@@ -71,7 +67,8 @@ var Application = function Application(props) {
|
|
|
71
67
|
loading = props.loading,
|
|
72
68
|
style = props.style,
|
|
73
69
|
className = props.className,
|
|
74
|
-
consoleConfig = props.consoleConfig
|
|
70
|
+
consoleConfig = props.consoleConfig,
|
|
71
|
+
i18nMessages = props.i18nMessages;
|
|
75
72
|
|
|
76
73
|
var _useState = (0, _react.useState)(false),
|
|
77
74
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -86,7 +83,7 @@ var Application = function Application(props) {
|
|
|
86
83
|
var appRef = (0, _react.useRef)(null);
|
|
87
84
|
(0, _react.useEffect)(function () {
|
|
88
85
|
(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
89
|
-
var
|
|
86
|
+
var App;
|
|
90
87
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
91
88
|
while (1) {
|
|
92
89
|
switch (_context.prev = _context.next) {
|
|
@@ -100,27 +97,35 @@ var Application = function Application(props) {
|
|
|
100
97
|
});
|
|
101
98
|
|
|
102
99
|
case 2:
|
|
103
|
-
|
|
100
|
+
App = _context.sent;
|
|
104
101
|
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
if (App.context && App.context) {
|
|
103
|
+
App.context.window.ALIYUN_CONSOLE_CONFIG = consoleConfig;
|
|
104
|
+
App.context.window.ALIYUN_CONSOLE_I18N_MESSAGE = i18nMessages;
|
|
108
105
|
}
|
|
109
106
|
|
|
110
107
|
_context.next = 6;
|
|
111
|
-
return
|
|
108
|
+
return App.load();
|
|
112
109
|
|
|
113
110
|
case 6:
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
if (appRef.current) {
|
|
112
|
+
_context.next = 8;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return _context.abrupt("return");
|
|
117
|
+
|
|
118
|
+
case 8:
|
|
119
|
+
_context.next = 10;
|
|
120
|
+
return App.mount(appRef.current, {
|
|
116
121
|
customProps: getProps(props)
|
|
117
122
|
});
|
|
118
123
|
|
|
119
|
-
case
|
|
124
|
+
case 10:
|
|
120
125
|
setMounted(true);
|
|
121
|
-
setApp(
|
|
126
|
+
setApp(App);
|
|
122
127
|
|
|
123
|
-
case
|
|
128
|
+
case 12:
|
|
124
129
|
case "end":
|
|
125
130
|
return _context.stop();
|
|
126
131
|
}
|
|
@@ -143,24 +148,17 @@ var Application = function Application(props) {
|
|
|
143
148
|
className: className,
|
|
144
149
|
ref: appRef,
|
|
145
150
|
dataId: name
|
|
146
|
-
}) : /*#__PURE__*/_react.default.createElement(name, {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
})
|
|
150
|
-
}));
|
|
151
|
+
}) : /*#__PURE__*/_react.default.createElement(name, {}, /*#__PURE__*/_react.default.createElement('div', {
|
|
152
|
+
ref: appRef
|
|
153
|
+
})));
|
|
151
154
|
};
|
|
152
155
|
|
|
153
156
|
function createAlfaApp(option) {
|
|
154
157
|
var name = option.name,
|
|
155
158
|
loading = option.loading,
|
|
156
159
|
manifest = option.manifest;
|
|
157
|
-
|
|
158
|
-
if ((0, _utils.isSSR)()) {
|
|
159
|
-
return (0, _createIsomorphicMicroApp.createIsomorphicAlfaApp)(option);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
160
|
var AlfaApp = /*#__PURE__*/(0, _react.lazy)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
163
|
-
var resolvedManifest, consoleConfig,
|
|
161
|
+
var resolvedManifest, consoleConfig, messages, i18nMessages, App;
|
|
164
162
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
165
163
|
while (1) {
|
|
166
164
|
switch (_context2.prev = _context2.next) {
|
|
@@ -179,35 +177,34 @@ function createAlfaApp(option) {
|
|
|
179
177
|
resolvedManifest = _context2.sent;
|
|
180
178
|
|
|
181
179
|
case 5:
|
|
182
|
-
// @ts-ignore
|
|
183
180
|
consoleConfig = window.ALIYUN_CONSOLE_CONFIG || {};
|
|
184
|
-
|
|
185
|
-
if (!option.dynamicConfig) {
|
|
186
|
-
_context2.next = 10;
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
_context2.next = 9;
|
|
181
|
+
_context2.next = 8;
|
|
191
182
|
return (0, _getConsoleConfig.getConsoleConfig)(option, consoleConfig);
|
|
192
183
|
|
|
193
|
-
case
|
|
184
|
+
case 8:
|
|
194
185
|
consoleConfig = _context2.sent;
|
|
186
|
+
_context2.next = 11;
|
|
187
|
+
return (0, _alfaCore.getLocale)(option);
|
|
188
|
+
|
|
189
|
+
case 11:
|
|
190
|
+
messages = _context2.sent;
|
|
191
|
+
i18nMessages = _objectSpread(_objectSpread({}, window.ALIYUN_CONSOLE_I18N_MESSAGE), messages);
|
|
195
192
|
|
|
196
|
-
|
|
197
|
-
AlfaApp = function AlfaApp(props) {
|
|
193
|
+
App = function App(props) {
|
|
198
194
|
return /*#__PURE__*/_react.default.createElement(Application, (0, _extends2.default)({
|
|
199
195
|
manifest: resolvedManifest
|
|
200
196
|
}, props, {
|
|
201
197
|
name: (0, _utils.normalizeName)(name),
|
|
202
|
-
consoleConfig: consoleConfig
|
|
198
|
+
consoleConfig: consoleConfig,
|
|
199
|
+
i18nMessages: i18nMessages
|
|
203
200
|
}));
|
|
204
201
|
};
|
|
205
202
|
|
|
206
203
|
return _context2.abrupt("return", {
|
|
207
|
-
default:
|
|
204
|
+
default: App
|
|
208
205
|
});
|
|
209
206
|
|
|
210
|
-
case
|
|
207
|
+
case 15:
|
|
211
208
|
case "end":
|
|
212
209
|
return _context2.stop();
|
|
213
210
|
}
|