@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,46 +1,41 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
3
|
import { getManifest } from '@alicloud/alfa-core';
|
|
4
|
-
import { version as LOADER_VERSION } from '../version';
|
|
5
|
-
// normalize name
|
|
4
|
+
import { version as LOADER_VERSION } from '../version';
|
|
6
5
|
|
|
6
|
+
// get manifest before resolve
|
|
7
|
+
// normalize name
|
|
7
8
|
function beforeResolveHook(_x) {
|
|
8
9
|
return _beforeResolveHook.apply(this, arguments);
|
|
9
10
|
}
|
|
10
|
-
|
|
11
11
|
function _beforeResolveHook() {
|
|
12
12
|
_beforeResolveHook = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(appConfig) {
|
|
13
13
|
var logger, START_TIME, MANIFEST_START_TIME, resolvedManifest, MANIFEST_END_TIME;
|
|
14
14
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
15
|
-
while (1) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
case 10:
|
|
37
|
-
case "end":
|
|
38
|
-
return _context.stop();
|
|
39
|
-
}
|
|
15
|
+
while (1) switch (_context.prev = _context.next) {
|
|
16
|
+
case 0:
|
|
17
|
+
logger = appConfig.logger;
|
|
18
|
+
START_TIME = Date.now();
|
|
19
|
+
MANIFEST_START_TIME = Date.now();
|
|
20
|
+
_context.next = 5;
|
|
21
|
+
return getManifest(appConfig);
|
|
22
|
+
case 5:
|
|
23
|
+
resolvedManifest = _context.sent;
|
|
24
|
+
MANIFEST_END_TIME = Date.now();
|
|
25
|
+
(logger === null || logger === void 0 ? void 0 : logger.record) && logger.record({
|
|
26
|
+
LOADER_VERSION: LOADER_VERSION,
|
|
27
|
+
START_TIME: START_TIME,
|
|
28
|
+
MANIFEST_START_TIME: MANIFEST_START_TIME,
|
|
29
|
+
MANIFEST_END_TIME: MANIFEST_END_TIME
|
|
30
|
+
});
|
|
31
|
+
appConfig.manifest = resolvedManifest;
|
|
32
|
+
return _context.abrupt("return", appConfig);
|
|
33
|
+
case 10:
|
|
34
|
+
case "end":
|
|
35
|
+
return _context.stop();
|
|
40
36
|
}
|
|
41
37
|
}, _callee);
|
|
42
38
|
}));
|
|
43
39
|
return _beforeResolveHook.apply(this, arguments);
|
|
44
40
|
}
|
|
45
|
-
|
|
46
41
|
export default beforeResolveHook;
|
package/es/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { default as createAlfaApp, useAlfaApp } from './createAlfaApp';
|
|
2
2
|
export { default as createAlfaWidget, useAlfaWidget } from './createAlfaWidget';
|
|
3
3
|
export { eventEmitter as widgetEventEmitter } from './widget/index';
|
|
4
|
-
export { default as addGlobalRequestInterceptor } from './addGlobalRequestInterceptor';
|
|
5
|
-
|
|
4
|
+
export { default as addGlobalRequestInterceptor } from './addGlobalRequestInterceptor';
|
|
5
|
+
// todo
|
|
6
6
|
export { createEventBus, prefetch } from '@alicloud/alfa-core';
|
package/es/types/base.js
CHANGED
|
@@ -3,25 +3,16 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
5
5
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
6
|
-
|
|
7
6
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
-
|
|
9
7
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
10
|
-
|
|
11
8
|
import React from 'react';
|
|
12
|
-
|
|
13
9
|
var MicroAppBase = /*#__PURE__*/function (_React$Component) {
|
|
14
10
|
_inherits(MicroAppBase, _React$Component);
|
|
15
|
-
|
|
16
11
|
var _super = _createSuper(MicroAppBase);
|
|
17
|
-
|
|
18
12
|
function MicroAppBase() {
|
|
19
13
|
_classCallCheck(this, MicroAppBase);
|
|
20
|
-
|
|
21
14
|
return _super.apply(this, arguments);
|
|
22
15
|
}
|
|
23
|
-
|
|
24
16
|
return _createClass(MicroAppBase);
|
|
25
17
|
}(React.Component);
|
|
26
|
-
|
|
27
18
|
export { MicroAppBase as default };
|
package/es/utils/counter.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
var lastApp;
|
|
2
2
|
var lastTime = 0;
|
|
3
3
|
var min = 1000;
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* 计算初始化次数,并提示重复加载的应用
|
|
6
7
|
* @param appId string
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
9
|
export var countRegister = function countRegister(appId) {
|
|
10
10
|
var nowTime = Date.now();
|
|
11
|
-
|
|
12
11
|
if (lastApp === appId && lastTime && nowTime - lastTime < min) {
|
|
13
12
|
console.warn("[@alicloud/alfa-react] ".concat(appId, " \u91CD\u590D\u52A0\u8F7D\uFF0C\u8BF7\u68C0\u67E5\u4F60\u7684\u4EE3\u7801\u3002\u8BF7\u5728\u51FD\u6570\u7EC4\u4EF6\u4E2D\u4F7F\u7528 useAlfaApp \u6216 useAlfaWidget \u65B9\u6CD5\u3002"));
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
lastApp = appId;
|
|
17
15
|
lastTime = nowTime;
|
|
18
16
|
};
|
|
@@ -1,40 +1,34 @@
|
|
|
1
1
|
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
|
-
|
|
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 md5 from 'crypto-js/md5';
|
|
7
|
+
|
|
10
8
|
/**
|
|
11
9
|
* transform
|
|
12
10
|
* @param features
|
|
13
11
|
*/
|
|
14
|
-
|
|
15
12
|
var processFeatures = function processFeatures(features) {
|
|
16
13
|
if (!features) return {};
|
|
17
14
|
return Object.keys(features).reduce(function (newFeatures, key) {
|
|
18
15
|
var _ALIYUN_CONSOLE_CONFI;
|
|
19
|
-
|
|
20
16
|
var feature = features === null || features === void 0 ? void 0 : features[key];
|
|
21
17
|
if (!feature) return newFeatures;
|
|
22
18
|
var uid = ((_ALIYUN_CONSOLE_CONFI = window.ALIYUN_CONSOLE_CONFIG) === null || _ALIYUN_CONSOLE_CONFI === void 0 ? void 0 : _ALIYUN_CONSOLE_CONFI.MAIN_ACCOUNT_PK) || '';
|
|
23
19
|
var md5Uid = md5(uid).toString();
|
|
24
20
|
var enableBlockList = feature.enableBlockList,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
enableSampling = feature.enableSampling,
|
|
22
|
+
enableWhiteList = feature.enableWhiteList,
|
|
23
|
+
sampling = feature.sampling,
|
|
24
|
+
blockList = feature.blockList,
|
|
25
|
+
whiteList = feature.whiteList;
|
|
31
26
|
if (enableBlockList && blockList !== null && blockList !== void 0 && blockList.includes(md5Uid)) {
|
|
32
27
|
newFeatures[key] = false;
|
|
33
28
|
} else if (enableWhiteList && whiteList !== null && whiteList !== void 0 && whiteList.includes(md5Uid)) {
|
|
34
29
|
newFeatures[key] = true;
|
|
35
30
|
} else if (enableSampling) {
|
|
36
31
|
var gray = uid.substring(uid.length - 2);
|
|
37
|
-
|
|
38
32
|
if (Number(gray) >= (sampling !== null && sampling !== void 0 ? sampling : 0) * 100 || sampling === 0) {
|
|
39
33
|
newFeatures[key] = false;
|
|
40
34
|
} else {
|
|
@@ -43,29 +37,24 @@ var processFeatures = function processFeatures(features) {
|
|
|
43
37
|
} else {
|
|
44
38
|
newFeatures[key] = false;
|
|
45
39
|
}
|
|
46
|
-
|
|
47
40
|
return newFeatures;
|
|
48
41
|
}, {});
|
|
49
42
|
};
|
|
50
|
-
|
|
51
43
|
var getRegions = function getRegions(regions) {
|
|
52
44
|
if (!Array.isArray(regions) && regions.region) {
|
|
53
45
|
return regions.region || [];
|
|
54
46
|
}
|
|
55
|
-
|
|
56
47
|
return [];
|
|
57
48
|
};
|
|
58
|
-
|
|
59
49
|
var processChannelFeatures = function processChannelFeatures(allChannelFeatures, channel) {
|
|
60
50
|
var channelFeatures = allChannelFeatures === null || allChannelFeatures === void 0 ? void 0 : allChannelFeatures[channel];
|
|
61
51
|
if (!channelFeatures) return {};
|
|
62
52
|
return Object.keys(channelFeatures).reduce(function (newChannelFeatures, key) {
|
|
63
53
|
var channelFeature = channelFeatures[key];
|
|
64
54
|
if (!channelFeature) return newChannelFeatures;
|
|
65
|
-
|
|
66
55
|
if (newChannelFeatures) {
|
|
67
56
|
var status = channelFeature.status,
|
|
68
|
-
|
|
57
|
+
attribute = channelFeature.attribute;
|
|
69
58
|
newChannelFeatures[key] = {
|
|
70
59
|
status: status,
|
|
71
60
|
attribute: _objectSpread(_objectSpread({}, attribute), {}, {
|
|
@@ -73,14 +62,11 @@ var processChannelFeatures = function processChannelFeatures(allChannelFeatures,
|
|
|
73
62
|
})
|
|
74
63
|
};
|
|
75
64
|
}
|
|
76
|
-
|
|
77
65
|
return newChannelFeatures;
|
|
78
66
|
}, {});
|
|
79
67
|
};
|
|
80
|
-
|
|
81
68
|
var mergeConfigDataWithConsoleConfig = function mergeConfigDataWithConsoleConfig(configData, consoleConfig) {
|
|
82
69
|
var _window, _window$ALIYUN_CONSOL, _configData$ALL_CHANN;
|
|
83
|
-
|
|
84
70
|
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';
|
|
85
71
|
var channelLinks = (_configData$ALL_CHANN = configData.ALL_CHANNEL_LINKS) === null || _configData$ALL_CHANN === void 0 ? void 0 : _configData$ALL_CHANN[channel];
|
|
86
72
|
var channelFeatures = configData.ALL_CHANNEL_FEATURE_STATUS;
|
|
@@ -91,23 +77,18 @@ var mergeConfigDataWithConsoleConfig = function mergeConfigDataWithConsoleConfig
|
|
|
91
77
|
FEATURE_STATUS: _objectSpread(_objectSpread({}, consoleConfig === null || consoleConfig === void 0 ? void 0 : consoleConfig.FEATURE_STATUS), processFeatures(features))
|
|
92
78
|
});
|
|
93
79
|
};
|
|
94
|
-
|
|
95
80
|
export var getConsoleConfig = /*#__PURE__*/function () {
|
|
96
81
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(configData, consoleConfig) {
|
|
97
82
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
98
|
-
while (1) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
case "end":
|
|
105
|
-
return _context.stop();
|
|
106
|
-
}
|
|
83
|
+
while (1) switch (_context.prev = _context.next) {
|
|
84
|
+
case 0:
|
|
85
|
+
return _context.abrupt("return", mergeConfigDataWithConsoleConfig(configData, consoleConfig));
|
|
86
|
+
case 1:
|
|
87
|
+
case "end":
|
|
88
|
+
return _context.stop();
|
|
107
89
|
}
|
|
108
90
|
}, _callee);
|
|
109
91
|
}));
|
|
110
|
-
|
|
111
92
|
return function getConsoleConfig(_x, _x2) {
|
|
112
93
|
return _ref.apply(this, arguments);
|
|
113
94
|
};
|
|
@@ -1,27 +1,20 @@
|
|
|
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
|
export var getConsoleGlobal = /*#__PURE__*/function () {
|
|
10
7
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(configData, global) {
|
|
11
8
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
12
|
-
while (1) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
case "end":
|
|
19
|
-
return _context.stop();
|
|
20
|
-
}
|
|
9
|
+
while (1) switch (_context.prev = _context.next) {
|
|
10
|
+
case 0:
|
|
11
|
+
return _context.abrupt("return", _objectSpread(_objectSpread({}, global), configData === null || configData === void 0 ? void 0 : configData.GLOBAL_DATA));
|
|
12
|
+
case 1:
|
|
13
|
+
case "end":
|
|
14
|
+
return _context.stop();
|
|
21
15
|
}
|
|
22
16
|
}, _callee);
|
|
23
17
|
}));
|
|
24
|
-
|
|
25
18
|
return function getConsoleGlobal(_x, _x2) {
|
|
26
19
|
return _ref.apply(this, arguments);
|
|
27
20
|
};
|
package/es/utils/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* kernel 会为沙箱 context 注入 __IS_CONSOLE_OS_CONTEXT__
|
|
3
3
|
*/
|
|
4
|
+
|
|
4
5
|
export var normalizeName = function normalizeName(name) {
|
|
5
6
|
return name.replace(/@/g, '').replace(/\//g, '-');
|
|
6
7
|
};
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* 判断是否在沙箱环境中运行
|
|
9
11
|
*/
|
|
10
|
-
|
|
11
12
|
export var isOsContext = function isOsContext() {
|
|
12
13
|
try {
|
|
13
14
|
return context.__IS_CONSOLE_OS_CONTEXT__;
|
package/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var version = '1.4.
|
|
1
|
+
export var version = '1.4.40';
|
package/es/widget/emitter.js
CHANGED
|
@@ -3,27 +3,20 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
5
5
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
6
|
-
|
|
7
6
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
-
|
|
9
7
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
10
|
-
|
|
11
8
|
import { EventEmitter } from 'events';
|
|
12
|
-
|
|
13
9
|
var WidgetEventEmitter = /*#__PURE__*/function (_EventEmitter) {
|
|
14
10
|
_inherits(WidgetEventEmitter, _EventEmitter);
|
|
15
|
-
|
|
16
11
|
var _super = _createSuper(WidgetEventEmitter);
|
|
17
|
-
|
|
18
12
|
function WidgetEventEmitter() {
|
|
19
13
|
_classCallCheck(this, WidgetEventEmitter);
|
|
20
|
-
|
|
21
14
|
return _super.apply(this, arguments);
|
|
22
15
|
}
|
|
23
|
-
|
|
24
16
|
_createClass(WidgetEventEmitter, [{
|
|
25
17
|
key: "refersh",
|
|
26
|
-
value:
|
|
18
|
+
value:
|
|
19
|
+
// Compatible with the old api, this may get removed at sometime later.
|
|
27
20
|
function refersh(widgetId) {
|
|
28
21
|
return this.emit("".concat(widgetId, ":REFRESH"));
|
|
29
22
|
}
|
|
@@ -33,8 +26,6 @@ var WidgetEventEmitter = /*#__PURE__*/function (_EventEmitter) {
|
|
|
33
26
|
return this.emit("".concat(widgetId, ":REFRESH"));
|
|
34
27
|
}
|
|
35
28
|
}]);
|
|
36
|
-
|
|
37
29
|
return WidgetEventEmitter;
|
|
38
30
|
}(EventEmitter);
|
|
39
|
-
|
|
40
31
|
export default new WidgetEventEmitter();
|
package/es/widget/env.js
CHANGED
|
@@ -52,11 +52,9 @@ export var DIS_ENV = {
|
|
|
52
52
|
};
|
|
53
53
|
export var getConsoleEnv = function getConsoleEnv() {
|
|
54
54
|
var _window, _window$ALIYUN_CONSOL;
|
|
55
|
-
|
|
56
55
|
if (process.env.NODE_ENV === 'development') {
|
|
57
56
|
return 'local';
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
}
|
|
58
|
+
// @ts-ignore
|
|
61
59
|
return ((_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.fEnv) || 'prod';
|
|
62
60
|
};
|
|
@@ -8,36 +8,28 @@ export var getWidgetConfigById = /*#__PURE__*/function () {
|
|
|
8
8
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(option) {
|
|
9
9
|
var env, resp;
|
|
10
10
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
11
|
-
while (1) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
case 6:
|
|
31
|
-
return _context.abrupt("return", cachedConfig[option.name]);
|
|
32
|
-
|
|
33
|
-
case 7:
|
|
34
|
-
case "end":
|
|
35
|
-
return _context.stop();
|
|
36
|
-
}
|
|
11
|
+
while (1) switch (_context.prev = _context.next) {
|
|
12
|
+
case 0:
|
|
13
|
+
env = ENV[option.env || getConsoleEnv()];
|
|
14
|
+
if (cachedConfig[option.name]) {
|
|
15
|
+
_context.next = 6;
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
_context.next = 4;
|
|
19
|
+
return request.get(template(env.configUrl)({
|
|
20
|
+
id: option.name
|
|
21
|
+
}));
|
|
22
|
+
case 4:
|
|
23
|
+
resp = _context.sent;
|
|
24
|
+
cachedConfig[option.name] = resp === null || resp === void 0 ? void 0 : resp.data;
|
|
25
|
+
case 6:
|
|
26
|
+
return _context.abrupt("return", cachedConfig[option.name]);
|
|
27
|
+
case 7:
|
|
28
|
+
case "end":
|
|
29
|
+
return _context.stop();
|
|
37
30
|
}
|
|
38
31
|
}, _callee);
|
|
39
32
|
}));
|
|
40
|
-
|
|
41
33
|
return function getWidgetConfigById(_x) {
|
|
42
34
|
return _ref.apply(this, arguments);
|
|
43
35
|
};
|