@alicloud/alfa-react 1.3.4 → 1.4.0-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.
@@ -13,8 +13,6 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
13
13
 
14
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
15
 
16
- var _alfaCore = require("@alicloud/alfa-core");
17
-
18
16
  var _md = _interopRequireDefault(require("crypto-js/md5"));
19
17
 
20
18
  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; }
@@ -26,12 +24,13 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
26
24
  * @param features
27
25
  */
28
26
  var processFeatures = function processFeatures(features) {
27
+ if (!features) return {};
29
28
  return Object.keys(features).reduce(function (newFeatures, key) {
30
29
  var _ALIYUN_CONSOLE_CONFI;
31
30
 
32
- var feature = features[key];
31
+ var feature = features === null || features === void 0 ? void 0 : features[key];
33
32
  if (!feature) return newFeatures;
34
- var uid = ((_ALIYUN_CONSOLE_CONFI = window.ALIYUN_CONSOLE_CONFIG) === null || _ALIYUN_CONSOLE_CONFI === void 0 ? void 0 : _ALIYUN_CONSOLE_CONFI.CURRENT_PK) || '';
33
+ var uid = ((_ALIYUN_CONSOLE_CONFI = window.ALIYUN_CONSOLE_CONFIG) === null || _ALIYUN_CONSOLE_CONFI === void 0 ? void 0 : _ALIYUN_CONSOLE_CONFI.MAIN_ACCOUNT_PK) || '';
35
34
  var md5Uid = (0, _md.default)(uid).toString();
36
35
  var enableBlockList = feature.enableBlockList,
37
36
  enableSampling = feature.enableSampling,
@@ -56,35 +55,59 @@ var processFeatures = function processFeatures(features) {
56
55
  }, {});
57
56
  };
58
57
 
58
+ var getRegions = function getRegions(regions) {
59
+ if (!Array.isArray(regions) && regions.region) {
60
+ return regions.region || [];
61
+ }
62
+
63
+ return [];
64
+ };
65
+
66
+ var processChannelFeatures = function processChannelFeatures(allChannelFeatures, channel) {
67
+ var channelFeatures = allChannelFeatures === null || allChannelFeatures === void 0 ? void 0 : allChannelFeatures[channel];
68
+ if (!channelFeatures) return {};
69
+ return Object.keys(channelFeatures).reduce(function (newChannelFeatures, key) {
70
+ var channelFeature = channelFeatures[key];
71
+ if (!channelFeature) return newChannelFeatures;
72
+
73
+ if (newChannelFeatures) {
74
+ var status = channelFeature.status,
75
+ attribute = channelFeature.attribute;
76
+ newChannelFeatures[key] = {
77
+ status: status,
78
+ attribute: _objectSpread(_objectSpread({}, attribute), {}, {
79
+ regions: getRegions(channelFeature.attribute.regions)
80
+ })
81
+ };
82
+ }
83
+
84
+ return newChannelFeatures;
85
+ }, {});
86
+ };
87
+
59
88
  var mergeConfigDataWithConsoleConfig = function mergeConfigDataWithConsoleConfig(configData, consoleConfig) {
60
- var _window, _window$ALIYUN_CONSOL, _configData$ALL_CHANN, _configData$ALL_CHANN2;
89
+ var _window, _window$ALIYUN_CONSOL, _configData$ALL_CHANN;
61
90
 
62
91
  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';
63
92
  var channelLinks = ((_configData$ALL_CHANN = configData.ALL_CHANNEL_LINKS) === null || _configData$ALL_CHANN === void 0 ? void 0 : _configData$ALL_CHANN[channel]) || {};
64
- var channelFeatures = ((_configData$ALL_CHANN2 = configData.ALL_CHANNEL_FEATURE_STATUS) === null || _configData$ALL_CHANN2 === void 0 ? void 0 : _configData$ALL_CHANN2[channel]) || {};
93
+ var channelFeatures = configData.ALL_CHANNEL_FEATURE_STATUS || {};
65
94
  var features = configData.ALL_FEATURE_STATUS || {};
66
95
  return _objectSpread(_objectSpread({}, consoleConfig), {}, {
67
96
  CHANNEL_LINKS: channelLinks,
68
- CHANNEL_FEATURE_STATUS: channelFeatures,
97
+ CHANNEL_FEATURE_STATUS: processChannelFeatures(channelFeatures, channel),
69
98
  FEATURE_STATUS: processFeatures(features)
70
99
  });
71
100
  };
72
101
 
73
102
  var getConsoleConfig = /*#__PURE__*/function () {
74
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(config, consoleConfig) {
75
- var configData;
103
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(configData, consoleConfig) {
76
104
  return _regenerator.default.wrap(function _callee$(_context) {
77
105
  while (1) {
78
106
  switch (_context.prev = _context.next) {
79
107
  case 0:
80
- _context.next = 2;
81
- return (0, _alfaCore.getConfig)(config);
82
-
83
- case 2:
84
- configData = _context.sent;
85
108
  return _context.abrupt("return", mergeConfigDataWithConsoleConfig(configData, consoleConfig));
86
109
 
87
- case 4:
110
+ case 1:
88
111
  case "end":
89
112
  return _context.stop();
90
113
  }
@@ -0,0 +1,2 @@
1
+ import { AlfaConfig, IWin } from '@alicloud/alfa-core';
2
+ export declare const getConsoleGlobal: (configData: AlfaConfig, global: IWin['ALIYUN_CONSOLE_GLOBAL']) => Promise<{}>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.getConsoleGlobal = void 0;
9
+
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
+
16
+ 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; }
17
+
18
+ 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; }
19
+
20
+ var getConsoleGlobal = /*#__PURE__*/function () {
21
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(configData, global) {
22
+ return _regenerator.default.wrap(function _callee$(_context) {
23
+ while (1) {
24
+ switch (_context.prev = _context.next) {
25
+ case 0:
26
+ return _context.abrupt("return", _objectSpread(_objectSpread({}, global), configData === null || configData === void 0 ? void 0 : configData.GLOBAL_DATA));
27
+
28
+ case 1:
29
+ case "end":
30
+ return _context.stop();
31
+ }
32
+ }
33
+ }, _callee);
34
+ }));
35
+
36
+ return function getConsoleGlobal(_x, _x2) {
37
+ return _ref.apply(this, arguments);
38
+ };
39
+ }();
40
+
41
+ exports.getConsoleGlobal = getConsoleGlobal;
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "1.3.4";
1
+ export declare const version = "1.4.0-alpha.2";
package/lib/version.js CHANGED
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = void 0;
7
- var version = '1.3.4';
7
+ var version = '1.4.0-alpha.2';
8
8
  exports.version = version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alicloud/alfa-react",
3
- "version": "1.3.4",
3
+ "version": "1.4.0-alpha.2",
4
4
  "description": "Alfa Framework (React Version)",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -39,7 +39,7 @@
39
39
  "typescript": "^3.0.3"
40
40
  },
41
41
  "dependencies": {
42
- "@alicloud/alfa-core": "^1.3.3",
42
+ "@alicloud/alfa-core": "^1.4.0-alpha.2",
43
43
  "@alicloud/console-os-loader": "^1.2.3",
44
44
  "@alicloud/widget-utils-console": "^0.1.6",
45
45
  "classnames": "^2.2.6",
@@ -48,5 +48,5 @@
48
48
  "peerDependencies": {
49
49
  "react": "^16 | ^17"
50
50
  },
51
- "gitHead": "226b5899f3fc8b7929a7606f4ac6e7c7ec7cfdb7"
51
+ "gitHead": "5c0d708d90ac6720e85148496c2eca87fb5c6078"
52
52
  }