@alicloud/alfa-react 1.4.39 → 1.4.40
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/es/components/ErrorBoundary/ErrorPanel.js +0 -2
- package/es/components/ErrorBoundary/index.js +7 -19
- package/es/components/Loading/Paragraph.js +9 -25
- package/es/components/Loading/Skeleton.js +14 -46
- package/es/components/Loading/Title.js +3 -8
- package/es/components/Loading/index.js +0 -2
- package/es/createAlfaApp.js +6 -10
- package/es/createAlfaWidget.js +16 -28
- package/es/createApplication.js +143 -189
- package/es/hooks/beforeLoadHook.js +60 -81
- package/es/hooks/beforeResolveHook.js +24 -29
- package/es/index.js +2 -2
- package/es/types/base.js +0 -9
- package/es/utils/counter.js +1 -3
- package/es/utils/getConsoleConfig.js +13 -32
- package/es/utils/getConsoleGlobal.js +6 -13
- package/es/utils/index.js +2 -1
- package/es/version.js +1 -1
- package/es/widget/emitter.js +2 -11
- package/es/widget/env.js +2 -4
- package/es/widget/getWidgetConfigById.js +19 -27
- package/es/widget/getWidgetDeps.js +104 -130
- package/es/widget/getWidgetVersionById.js +79 -106
- package/es/widget.js +45 -58
- package/lib/addGlobalRequestInterceptor.js +0 -2
- package/lib/components/ErrorBoundary/ErrorPanel.js +0 -5
- package/lib/components/ErrorBoundary/index.js +7 -25
- package/lib/components/Loading/Paragraph.js +9 -32
- package/lib/components/Loading/Skeleton.js +14 -60
- package/lib/components/Loading/Title.js +3 -14
- package/lib/components/Loading/index.js +0 -6
- package/lib/createAlfaApp.js +6 -24
- package/lib/createAlfaWidget.js +16 -45
- package/lib/createApplication.js +143 -200
- package/lib/hooks/beforeLoadHook.js +60 -88
- package/lib/hooks/beforeResolveHook.js +21 -33
- package/lib/index.js +0 -9
- package/lib/types/base.js +0 -14
- package/lib/utils/counter.js +1 -4
- package/lib/utils/getConsoleConfig.js +12 -37
- package/lib/utils/getConsoleGlobal.js +6 -18
- package/lib/utils/index.js +2 -5
- package/lib/version.js +1 -1
- package/lib/widget/emitter.js +2 -16
- package/lib/widget/env.js +2 -6
- package/lib/widget/getWidgetConfigById.js +19 -36
- package/lib/widget/getWidgetDeps.js +103 -146
- package/lib/widget/getWidgetVersionById.js +79 -113
- package/lib/widget/index.js +0 -8
- package/lib/widget.js +45 -72
- package/package.json +22 -19
- package/types/components/ErrorBoundary/index.d.ts +1 -1
- package/types/components/Loading/Paragraph.d.ts +2 -2
- package/types/components/Loading/Skeleton.d.ts +2 -2
- package/types/components/Loading/Title.d.ts +2 -2
- package/types/components/Loading/index.d.ts +1 -1
- package/types/createAlfaApp.d.ts +3 -3
- package/types/createAlfaWidget.d.ts +3 -3
- package/types/createApplication.d.ts +2 -2
- package/types/types/index.d.ts +5 -5
- package/types/utils/getConsoleConfig.d.ts +4 -2
- package/types/utils/getConsoleGlobal.d.ts +3 -1
- package/types/version.d.ts +1 -1
- package/types/widget/getWidgetDeps.d.ts +1 -1
- package/types/widget.d.ts +2 -2
- package/dist/index.js +0 -21
- package/es/app.js +0 -194
- package/es/hooks/afterLoadHook.js +0 -69
- package/lib/app.d.ts +0 -3
- package/lib/app.js +0 -223
- package/lib/components/ErrorBoundary/ErrorPanel.d.ts +0 -6
- package/lib/components/ErrorBoundary/index.d.ts +0 -17
- package/lib/components/Loading/Paragraph.d.ts +0 -14
- package/lib/components/Loading/Skeleton.d.ts +0 -19
- package/lib/components/Loading/Title.d.ts +0 -8
- package/lib/components/Loading/index.d.ts +0 -4
- package/lib/components/Loading/style.d.ts +0 -2
- package/lib/createAlfaApp.d.ts +0 -7
- package/lib/createAlfaWidget.d.ts +0 -4
- package/lib/createApplication.d.ts +0 -12
- package/lib/hooks/afterLoadHook.d.ts +0 -3
- package/lib/hooks/afterLoadHook.js +0 -84
- package/lib/hooks/beforeLoadHook.d.ts +0 -3
- package/lib/hooks/beforeResolveHook.d.ts +0 -3
- package/lib/index.d.ts +0 -4
- package/lib/types/base.d.ts +0 -11
- package/lib/types/index.d.ts +0 -91
- package/lib/utils/getConsoleConfig.d.ts +0 -1
- package/lib/utils/getConsoleGlobal.d.ts +0 -1
- package/lib/utils/index.d.ts +0 -1
- package/lib/version.d.ts +0 -1
- package/lib/widget/emitter.d.ts +0 -8
- package/lib/widget/env.d.ts +0 -4
- package/lib/widget/getWidgetConfigById.d.ts +0 -2
- package/lib/widget/getWidgetDeps.d.ts +0 -2
- package/lib/widget/getWidgetVersionById.d.ts +0 -6
- package/lib/widget/index.d.ts +0 -4
- package/lib/widget.d.ts +0 -2
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
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
|
-
|
|
5
4
|
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
|
-
|
|
7
5
|
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
|
-
|
|
9
6
|
import react from 'react';
|
|
10
7
|
import reactDom from 'react-dom';
|
|
11
8
|
import axios from 'axios';
|
|
@@ -13,25 +10,22 @@ import kebabCase from 'lodash/kebabCase';
|
|
|
13
10
|
import * as propTypes from 'prop-types';
|
|
14
11
|
import { loadBundle } from '@alicloud/console-os-loader';
|
|
15
12
|
import { createCWSWidget } from '../widget';
|
|
16
|
-
import { getWidgetVersionById } from './getWidgetVersionById';
|
|
17
|
-
|
|
13
|
+
import { getWidgetVersionById } from './getWidgetVersionById';
|
|
14
|
+
// @ts-ignore
|
|
18
15
|
import * as widgetUtils from '@alicloud/widget-utils-console';
|
|
19
16
|
var cachedRuntime = {};
|
|
20
17
|
var cachedMessage = null;
|
|
21
18
|
var WIDGET_RUNTIME_ID = '@ali/widget-wind-runtime';
|
|
22
19
|
var WIDGET_WIND_MESSAGE_ID = '@ali/wind-messages';
|
|
23
20
|
var WIDGET_UTILS_PKG_NAME = '@ali/widget-utils-console';
|
|
24
|
-
|
|
25
21
|
var createDynamicWindStylePrefix = function createDynamicWindStylePrefix(windRuntimeVersion) {
|
|
26
22
|
return 'v'.concat(windRuntimeVersion.split('.').join('-'), '-');
|
|
27
23
|
};
|
|
28
|
-
|
|
29
24
|
var createWidget = function createWidget(option) {
|
|
30
25
|
return function (_ref) {
|
|
31
26
|
var _option$windRuntime;
|
|
32
|
-
|
|
33
27
|
var id = _ref.id,
|
|
34
|
-
|
|
28
|
+
version = _ref.version;
|
|
35
29
|
return createCWSWidget({
|
|
36
30
|
name: id,
|
|
37
31
|
version: version,
|
|
@@ -40,139 +34,119 @@ var createWidget = function createWidget(option) {
|
|
|
40
34
|
});
|
|
41
35
|
};
|
|
42
36
|
};
|
|
43
|
-
|
|
44
37
|
export var getWidgetDeps = /*#__PURE__*/function () {
|
|
45
38
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(config, option) {
|
|
46
39
|
var _objectSpread2;
|
|
47
|
-
|
|
48
40
|
var _yield$getWidgetVersi, _yield$getWidgetVersi2, entryUrl, version, _yield$getWidgetVersi3, _yield$getWidgetVersi4, messageVersion, resp, _yield$getWidgetVersi5, oldVersion, components, injectedWidgetUtils;
|
|
49
|
-
|
|
50
41
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
51
|
-
while (1) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
_yield$getWidgetVersi4 = _yield$getWidgetVersi3.version;
|
|
74
|
-
messageVersion = _yield$getWidgetVersi4 === void 0 ? '0.0.8' : _yield$getWidgetVersi4;
|
|
75
|
-
|
|
76
|
-
if (cachedMessage) {
|
|
77
|
-
_context.next = 21;
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
_context.prev = 12;
|
|
82
|
-
_context.next = 15;
|
|
83
|
-
return axios.get("https://g.alicdn.com/one-mcms/wind-v2/".concat(messageVersion, "/wind-v2_").concat((widgetUtils.getLocale() || 'en-US').toLowerCase(), ".json"));
|
|
84
|
-
|
|
85
|
-
case 15:
|
|
86
|
-
resp = _context.sent;
|
|
87
|
-
cachedMessage = resp.data;
|
|
42
|
+
while (1) switch (_context.prev = _context.next) {
|
|
43
|
+
case 0:
|
|
44
|
+
_context.next = 2;
|
|
45
|
+
return getWidgetVersionById({
|
|
46
|
+
name: WIDGET_RUNTIME_ID,
|
|
47
|
+
version: (option === null || option === void 0 ? void 0 : option.runtimeVersion) || '1.x'
|
|
48
|
+
});
|
|
49
|
+
case 2:
|
|
50
|
+
_yield$getWidgetVersi = _context.sent;
|
|
51
|
+
_yield$getWidgetVersi2 = _yield$getWidgetVersi.entryUrl;
|
|
52
|
+
entryUrl = _yield$getWidgetVersi2 === void 0 ? '' : _yield$getWidgetVersi2;
|
|
53
|
+
version = _yield$getWidgetVersi.version;
|
|
54
|
+
_context.next = 8;
|
|
55
|
+
return getWidgetVersionById({
|
|
56
|
+
name: WIDGET_WIND_MESSAGE_ID,
|
|
57
|
+
version: '0.x'
|
|
58
|
+
});
|
|
59
|
+
case 8:
|
|
60
|
+
_yield$getWidgetVersi3 = _context.sent;
|
|
61
|
+
_yield$getWidgetVersi4 = _yield$getWidgetVersi3.version;
|
|
62
|
+
messageVersion = _yield$getWidgetVersi4 === void 0 ? '0.0.8' : _yield$getWidgetVersi4;
|
|
63
|
+
if (cachedMessage) {
|
|
88
64
|
_context.next = 21;
|
|
89
65
|
break;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
xmlrequest: true,
|
|
121
|
-
transform: function transform(source) {
|
|
122
|
-
if (oldVersion !== version) {
|
|
123
|
-
return source.replace(/aliyun-widget-/g, createDynamicWindStylePrefix(version));
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return source;
|
|
127
|
-
},
|
|
128
|
-
context: {
|
|
129
|
-
window: window,
|
|
130
|
-
location: location,
|
|
131
|
-
history: history,
|
|
132
|
-
document: document
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
case 28:
|
|
137
|
-
cachedRuntime[version] = _context.sent;
|
|
138
|
-
components = cachedRuntime[version].default['@ali/wind'];
|
|
139
|
-
Object.keys(components).forEach(function (key) {
|
|
140
|
-
cachedRuntime[version].default["@ali/wind/lib/".concat(kebabCase(key).toLowerCase())] = components[key];
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
case 31:
|
|
144
|
-
injectedWidgetUtils = _objectSpread(_objectSpread({}, widgetUtils), {}, {
|
|
145
|
-
getChannelLink: widgetUtils.channelLinkFactory(function () {
|
|
146
|
-
return config.links[widgetUtils.getChannel() || 'OFFICIAL'];
|
|
147
|
-
}),
|
|
148
|
-
getChannelFeature: widgetUtils.channelFeatureFactory(function () {
|
|
149
|
-
return config.features[widgetUtils.getChannel() || 'OFFICIAL'];
|
|
150
|
-
}),
|
|
151
|
-
getLocale: function getLocale() {
|
|
152
|
-
return widgetUtils.getLocale() || 'en-US';
|
|
153
|
-
},
|
|
154
|
-
getWidgetI18nMessages: function getWidgetI18nMessages() {
|
|
155
|
-
return _objectSpread(_objectSpread({}, cachedMessage), ((config.locales || {})[widgetUtils.getLocale() || 'en-US'] || {}).messages || {});
|
|
156
|
-
},
|
|
157
|
-
getStylePrefixForWindComponent: function getStylePrefixForWindComponent() {
|
|
158
|
-
return oldVersion === version ? 'aliyun-widget-' : createDynamicWindStylePrefix(version);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
return _context.abrupt("return", _objectSpread(_objectSpread({
|
|
66
|
+
}
|
|
67
|
+
_context.prev = 12;
|
|
68
|
+
_context.next = 15;
|
|
69
|
+
return axios.get("https://g.alicdn.com/one-mcms/wind-v2/".concat(messageVersion, "/wind-v2_").concat((widgetUtils.getLocale() || 'en-US').toLowerCase(), ".json"));
|
|
70
|
+
case 15:
|
|
71
|
+
resp = _context.sent;
|
|
72
|
+
cachedMessage = resp.data;
|
|
73
|
+
_context.next = 21;
|
|
74
|
+
break;
|
|
75
|
+
case 19:
|
|
76
|
+
_context.prev = 19;
|
|
77
|
+
_context.t0 = _context["catch"](12);
|
|
78
|
+
case 21:
|
|
79
|
+
_context.next = 23;
|
|
80
|
+
return getWidgetVersionById({
|
|
81
|
+
name: WIDGET_RUNTIME_ID,
|
|
82
|
+
version: '1.x'
|
|
83
|
+
});
|
|
84
|
+
case 23:
|
|
85
|
+
_yield$getWidgetVersi5 = _context.sent;
|
|
86
|
+
oldVersion = _yield$getWidgetVersi5.version;
|
|
87
|
+
if (cachedRuntime[version]) {
|
|
88
|
+
_context.next = 31;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
_context.next = 28;
|
|
92
|
+
return loadBundle({
|
|
93
|
+
id: WIDGET_RUNTIME_ID,
|
|
94
|
+
url: entryUrl,
|
|
95
|
+
deps: {
|
|
162
96
|
react: react,
|
|
163
97
|
'react-dom': reactDom,
|
|
164
|
-
'prop-types': propTypes
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
98
|
+
'prop-types': propTypes
|
|
99
|
+
},
|
|
100
|
+
xmlrequest: true,
|
|
101
|
+
transform: function transform(source) {
|
|
102
|
+
if (oldVersion !== version) {
|
|
103
|
+
return source.replace(/aliyun-widget-/g, createDynamicWindStylePrefix(version));
|
|
104
|
+
}
|
|
105
|
+
return source;
|
|
106
|
+
},
|
|
107
|
+
context: {
|
|
108
|
+
window: window,
|
|
109
|
+
location: location,
|
|
110
|
+
history: history,
|
|
111
|
+
document: document
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
case 28:
|
|
115
|
+
cachedRuntime[version] = _context.sent;
|
|
116
|
+
components = cachedRuntime[version].default['@ali/wind'];
|
|
117
|
+
Object.keys(components).forEach(function (key) {
|
|
118
|
+
cachedRuntime[version].default["@ali/wind/lib/".concat(kebabCase(key).toLowerCase())] = components[key];
|
|
119
|
+
});
|
|
120
|
+
case 31:
|
|
121
|
+
injectedWidgetUtils = _objectSpread(_objectSpread({}, widgetUtils), {}, {
|
|
122
|
+
getChannelLink: widgetUtils.channelLinkFactory(function () {
|
|
123
|
+
return config.links[widgetUtils.getChannel() || 'OFFICIAL'];
|
|
124
|
+
}),
|
|
125
|
+
getChannelFeature: widgetUtils.channelFeatureFactory(function () {
|
|
126
|
+
return config.features[widgetUtils.getChannel() || 'OFFICIAL'];
|
|
127
|
+
}),
|
|
128
|
+
getLocale: function getLocale() {
|
|
129
|
+
return widgetUtils.getLocale() || 'en-US';
|
|
130
|
+
},
|
|
131
|
+
getWidgetI18nMessages: function getWidgetI18nMessages() {
|
|
132
|
+
return _objectSpread(_objectSpread({}, cachedMessage), ((config.locales || {})[widgetUtils.getLocale() || 'en-US'] || {}).messages || {});
|
|
133
|
+
},
|
|
134
|
+
getStylePrefixForWindComponent: function getStylePrefixForWindComponent() {
|
|
135
|
+
return oldVersion === version ? 'aliyun-widget-' : createDynamicWindStylePrefix(version);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
return _context.abrupt("return", _objectSpread(_objectSpread({
|
|
139
|
+
react: react,
|
|
140
|
+
'react-dom': reactDom,
|
|
141
|
+
'prop-types': propTypes,
|
|
142
|
+
axios: axios
|
|
143
|
+
}, 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)));
|
|
144
|
+
case 33:
|
|
145
|
+
case "end":
|
|
146
|
+
return _context.stop();
|
|
172
147
|
}
|
|
173
148
|
}, _callee, null, [[12, 19]]);
|
|
174
149
|
}));
|
|
175
|
-
|
|
176
150
|
return function getWidgetDeps(_x, _x2) {
|
|
177
151
|
return _ref2.apply(this, arguments);
|
|
178
152
|
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
-
|
|
3
2
|
var _ALIYUN_CONSOLE_CONFI;
|
|
4
|
-
|
|
5
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
4
|
import template from 'lodash/template';
|
|
7
5
|
import { request } from '@alicloud/alfa-core';
|
|
@@ -9,7 +7,6 @@ import { ENV, DIS_ENV, getConsoleEnv } from './env';
|
|
|
9
7
|
export var cachedRelease = null;
|
|
10
8
|
var WIDGET_ENTRY_URL = 'https://g.alicdn.com/${id}/${version}/index.js';
|
|
11
9
|
var uid = (_ALIYUN_CONSOLE_CONFI = window.ALIYUN_CONSOLE_CONFIG) === null || _ALIYUN_CONSOLE_CONFI === void 0 ? void 0 : _ALIYUN_CONSOLE_CONFI.MAIN_ACCOUNT_PK;
|
|
12
|
-
|
|
13
10
|
var normalizeEntryUrl = function normalizeEntryUrl(id, version, resourceUrl) {
|
|
14
11
|
if (!version) throw new Error('No Version for Widget');
|
|
15
12
|
var gitRepoId = id.replace('@ali/', '').replace('widget-', 'widget/');
|
|
@@ -18,118 +15,94 @@ var normalizeEntryUrl = function normalizeEntryUrl(id, version, resourceUrl) {
|
|
|
18
15
|
version: version
|
|
19
16
|
});
|
|
20
17
|
};
|
|
21
|
-
|
|
22
18
|
export var getWidgetVersionById = /*#__PURE__*/function () {
|
|
23
19
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(option) {
|
|
24
20
|
var _release$distTags, _release$distTags2, _release$nextVersion;
|
|
25
|
-
|
|
26
21
|
var name, _option$central, central, env, Release, version, entryUrl, _resp, _cachedRelease$option, _cachedRelease$option2, latestVersion, _nextVersion, gray, resp, release, nextVersion, sampling;
|
|
27
|
-
|
|
28
22
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
29
|
-
while (1) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (!(!resp || !resp.data)) {
|
|
100
|
-
_context.next = 24;
|
|
101
|
-
break;
|
|
23
|
+
while (1) switch (_context.prev = _context.next) {
|
|
24
|
+
case 0:
|
|
25
|
+
name = option.name, _option$central = option.central, central = _option$central === void 0 ? true : _option$central, env = option.env;
|
|
26
|
+
Release = central ? ENV[env || getConsoleEnv()] : DIS_ENV[env || getConsoleEnv()];
|
|
27
|
+
if (option.version) {
|
|
28
|
+
_context.next = 4;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
throw new Error('No Version for Widget');
|
|
32
|
+
case 4:
|
|
33
|
+
if (option.version.endsWith('.x')) {
|
|
34
|
+
_context.next = 6;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
return _context.abrupt("return", {
|
|
38
|
+
version: option.version,
|
|
39
|
+
entryUrl: normalizeEntryUrl(option.name, option.version, Release.resourceUrl || WIDGET_ENTRY_URL)
|
|
40
|
+
});
|
|
41
|
+
case 6:
|
|
42
|
+
if (!central) {
|
|
43
|
+
_context.next = 12;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
if (cachedRelease) {
|
|
47
|
+
_context.next = 12;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
_context.next = 10;
|
|
51
|
+
return request.get(Release.releaseUrl);
|
|
52
|
+
case 10:
|
|
53
|
+
_resp = _context.sent;
|
|
54
|
+
if (_resp && _resp.data) {
|
|
55
|
+
cachedRelease = _resp.data;
|
|
56
|
+
}
|
|
57
|
+
case 12:
|
|
58
|
+
if (!cachedRelease) {
|
|
59
|
+
_context.next = 19;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
latestVersion = cachedRelease[option.name][option.version].latest;
|
|
63
|
+
_nextVersion = (_cachedRelease$option = cachedRelease[option.name][option.version].next) === null || _cachedRelease$option === void 0 ? void 0 : _cachedRelease$option.version;
|
|
64
|
+
gray = (_cachedRelease$option2 = cachedRelease[option.name][option.version].next) === null || _cachedRelease$option2 === void 0 ? void 0 : _cachedRelease$option2.gray;
|
|
65
|
+
version = uid && Number(uid.substring(uid.length - 2)) < gray ? _nextVersion : latestVersion;
|
|
66
|
+
entryUrl = normalizeEntryUrl(option.name, version, Release.resourceUrl || WIDGET_ENTRY_URL);
|
|
67
|
+
return _context.abrupt("return", {
|
|
68
|
+
version: version,
|
|
69
|
+
entryUrl: entryUrl
|
|
70
|
+
});
|
|
71
|
+
case 19:
|
|
72
|
+
_context.next = 21;
|
|
73
|
+
return request.get(template(Release.releaseUrl)({
|
|
74
|
+
id: name
|
|
75
|
+
}));
|
|
76
|
+
case 21:
|
|
77
|
+
resp = _context.sent;
|
|
78
|
+
if (!(!resp || !resp.data)) {
|
|
79
|
+
_context.next = 24;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
throw new Error('Cannot get Release');
|
|
83
|
+
case 24:
|
|
84
|
+
release = resp.data;
|
|
85
|
+
nextVersion = (_release$distTags = release['dist-tags']) === null || _release$distTags === void 0 ? void 0 : _release$distTags["".concat(option.version, "-next")];
|
|
86
|
+
version = (_release$distTags2 = release['dist-tags']) === null || _release$distTags2 === void 0 ? void 0 : _release$distTags2[option.version];
|
|
87
|
+
|
|
88
|
+
// has gray version
|
|
89
|
+
if (nextVersion && release !== null && release !== void 0 && (_release$nextVersion = release['next-versions']) !== null && _release$nextVersion !== void 0 && _release$nextVersion[nextVersion] && uid) {
|
|
90
|
+
sampling = release['next-versions'][nextVersion].featureStatus.sampling || 0;
|
|
91
|
+
if (sampling * 100 > Number(uid.substring(uid.length - 2))) {
|
|
92
|
+
version = nextVersion;
|
|
102
93
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
sampling = release['next-versions'][nextVersion].featureStatus.sampling || 0;
|
|
113
|
-
|
|
114
|
-
if (sampling * 100 > Number(uid.substring(uid.length - 2))) {
|
|
115
|
-
version = nextVersion;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
entryUrl = normalizeEntryUrl(option.name, version, Release.resourceUrl || WIDGET_ENTRY_URL);
|
|
120
|
-
return _context.abrupt("return", {
|
|
121
|
-
version: version,
|
|
122
|
-
entryUrl: entryUrl
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
case 30:
|
|
126
|
-
case "end":
|
|
127
|
-
return _context.stop();
|
|
128
|
-
}
|
|
94
|
+
}
|
|
95
|
+
entryUrl = normalizeEntryUrl(option.name, version, Release.resourceUrl || WIDGET_ENTRY_URL);
|
|
96
|
+
return _context.abrupt("return", {
|
|
97
|
+
version: version,
|
|
98
|
+
entryUrl: entryUrl
|
|
99
|
+
});
|
|
100
|
+
case 30:
|
|
101
|
+
case "end":
|
|
102
|
+
return _context.stop();
|
|
129
103
|
}
|
|
130
104
|
}, _callee);
|
|
131
105
|
}));
|
|
132
|
-
|
|
133
106
|
return function getWidgetVersionById(_x) {
|
|
134
107
|
return _ref.apply(this, arguments);
|
|
135
108
|
};
|
package/es/widget.js
CHANGED
|
@@ -2,11 +2,8 @@ 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
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
-
|
|
6
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; }
|
|
7
|
-
|
|
8
6
|
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
7
|
import React, { lazy, Suspense } from 'react';
|
|
11
8
|
import { loadBundle } from '@alicloud/console-os-loader';
|
|
12
9
|
import { getWidgetVersionById, getWidgetDeps, getWidgetConfigById, eventEmitter } from './widget/index';
|
|
@@ -16,63 +13,53 @@ import { normalizeName } from './utils';
|
|
|
16
13
|
export function createCWSWidget(option) {
|
|
17
14
|
var AlfaWidget = /*#__PURE__*/lazy( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
18
15
|
var url, config, _yield$getWidgetVersi, version, entryUrl, deps;
|
|
19
|
-
|
|
20
16
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
21
|
-
while (1) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
while (1) switch (_context.prev = _context.next) {
|
|
18
|
+
case 0:
|
|
19
|
+
url = option.url;
|
|
20
|
+
config = {
|
|
21
|
+
links: {},
|
|
22
|
+
features: {},
|
|
23
|
+
locales: {},
|
|
24
|
+
conf: {}
|
|
25
|
+
};
|
|
26
|
+
if (url) {
|
|
27
|
+
_context.next = 12;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
_context.next = 5;
|
|
31
|
+
return getWidgetVersionById(option);
|
|
32
|
+
case 5:
|
|
33
|
+
_yield$getWidgetVersi = _context.sent;
|
|
34
|
+
version = _yield$getWidgetVersi.version;
|
|
35
|
+
entryUrl = _yield$getWidgetVersi.entryUrl;
|
|
36
|
+
url = entryUrl;
|
|
37
|
+
_context.next = 11;
|
|
38
|
+
return getWidgetConfigById(_objectSpread(_objectSpread({}, option), {}, {
|
|
39
|
+
version: version
|
|
40
|
+
}));
|
|
41
|
+
case 11:
|
|
42
|
+
config = _context.sent;
|
|
43
|
+
case 12:
|
|
44
|
+
_context.next = 14;
|
|
45
|
+
return getWidgetDeps(config, option);
|
|
46
|
+
case 14:
|
|
47
|
+
deps = _context.sent;
|
|
48
|
+
return _context.abrupt("return", loadBundle({
|
|
49
|
+
id: normalizeName(option.name),
|
|
50
|
+
url: (option.url || url || '').replace('index.js', option !== null && option !== void 0 && option.alfaLoader ? 'index.alfa.js' : 'index.js'),
|
|
51
|
+
deps: _objectSpread(_objectSpread({}, deps), option.dependencies),
|
|
52
|
+
xmlrequest: !option.alfaLoader,
|
|
53
|
+
context: {
|
|
54
|
+
window: window,
|
|
55
|
+
location: location,
|
|
56
|
+
history: history,
|
|
57
|
+
document: document
|
|
35
58
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
case 5:
|
|
41
|
-
_yield$getWidgetVersi = _context.sent;
|
|
42
|
-
version = _yield$getWidgetVersi.version;
|
|
43
|
-
entryUrl = _yield$getWidgetVersi.entryUrl;
|
|
44
|
-
url = entryUrl;
|
|
45
|
-
_context.next = 11;
|
|
46
|
-
return getWidgetConfigById(_objectSpread(_objectSpread({}, option), {}, {
|
|
47
|
-
version: version
|
|
48
|
-
}));
|
|
49
|
-
|
|
50
|
-
case 11:
|
|
51
|
-
config = _context.sent;
|
|
52
|
-
|
|
53
|
-
case 12:
|
|
54
|
-
_context.next = 14;
|
|
55
|
-
return getWidgetDeps(config, option);
|
|
56
|
-
|
|
57
|
-
case 14:
|
|
58
|
-
deps = _context.sent;
|
|
59
|
-
return _context.abrupt("return", loadBundle({
|
|
60
|
-
id: normalizeName(option.name),
|
|
61
|
-
url: (option.url || url || '').replace('index.js', option !== null && option !== void 0 && option.alfaLoader ? 'index.alfa.js' : 'index.js'),
|
|
62
|
-
deps: _objectSpread(_objectSpread({}, deps), option.dependencies),
|
|
63
|
-
xmlrequest: !option.alfaLoader,
|
|
64
|
-
context: {
|
|
65
|
-
window: window,
|
|
66
|
-
location: location,
|
|
67
|
-
history: history,
|
|
68
|
-
document: document
|
|
69
|
-
}
|
|
70
|
-
}));
|
|
71
|
-
|
|
72
|
-
case 16:
|
|
73
|
-
case "end":
|
|
74
|
-
return _context.stop();
|
|
75
|
-
}
|
|
59
|
+
}));
|
|
60
|
+
case 16:
|
|
61
|
+
case "end":
|
|
62
|
+
return _context.stop();
|
|
76
63
|
}
|
|
77
64
|
}, _callee);
|
|
78
65
|
})));
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = addGlobalRequestInterceptor;
|
|
7
|
-
|
|
8
7
|
var _alfaCore = require("@alicloud/alfa-core");
|
|
9
|
-
|
|
10
8
|
function addGlobalRequestInterceptor(interceptor) {
|
|
11
9
|
(0, _alfaCore.addRequestInterceptor)(interceptor);
|
|
12
10
|
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var padding = 24;
|
|
13
10
|
var containerBackground = '#fcebea';
|
|
14
11
|
var containerStyle = {
|
|
@@ -21,7 +18,6 @@ var commonErrorStyle = {
|
|
|
21
18
|
color: '#d93026',
|
|
22
19
|
fontSize: 14
|
|
23
20
|
};
|
|
24
|
-
|
|
25
21
|
var ErrorPanel = function ErrorPanel(props) {
|
|
26
22
|
var error = props.error;
|
|
27
23
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -34,6 +30,5 @@ var ErrorPanel = function ErrorPanel(props) {
|
|
|
34
30
|
}
|
|
35
31
|
}, error === null || error === void 0 ? void 0 : error.stack));
|
|
36
32
|
};
|
|
37
|
-
|
|
38
33
|
var _default = ErrorPanel;
|
|
39
34
|
exports.default = _default;
|