@alicloud/alfa-react 1.4.0-alpha.0 → 1.4.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,6 +45,10 @@ export default function createApplication(loader) {
45
45
  app = _useState2[0],
46
46
  setApp = _useState2[1];
47
47
 
48
+ var _useState3 = useState(null),
49
+ _useState4 = _slicedToArray(_useState3, 2),
50
+ setError = _useState4[1];
51
+
48
52
  var appRef = useRef(undefined);
49
53
  var tagName = normalizeName(props.name);
50
54
  var sandbox = useMemo(function () {
@@ -127,7 +131,9 @@ export default function createApplication(loader) {
127
131
  }
128
132
  }, _callee);
129
133
  }))().catch(function (e) {
130
- throw e;
134
+ setError(function () {
135
+ throw e;
136
+ });
131
137
  });
132
138
 
133
139
  return function () {
@@ -44,16 +44,46 @@ var processFeatures = function processFeatures(features) {
44
44
  }, {});
45
45
  };
46
46
 
47
+ var getRegions = function getRegions(regions) {
48
+ if (!Array.isArray(regions) && regions.region) {
49
+ return regions.region || [];
50
+ }
51
+
52
+ return [];
53
+ };
54
+
55
+ var processChannelFeatures = function processChannelFeatures(allChannelFeatures, channel) {
56
+ var channelFeatures = allChannelFeatures === null || allChannelFeatures === void 0 ? void 0 : allChannelFeatures[channel];
57
+ if (!channelFeatures) return {};
58
+ return Object.keys(channelFeatures).reduce(function (newChannelFeatures, key) {
59
+ var channelFeature = channelFeatures[key];
60
+ if (!channelFeature) return newChannelFeatures;
61
+
62
+ if (newChannelFeatures) {
63
+ var status = channelFeature.status,
64
+ attribute = channelFeature.attribute;
65
+ newChannelFeatures[key] = {
66
+ status: status,
67
+ attribute: _objectSpread(_objectSpread({}, attribute), {}, {
68
+ regions: getRegions(channelFeature.attribute.regions)
69
+ })
70
+ };
71
+ }
72
+
73
+ return newChannelFeatures;
74
+ }, {});
75
+ };
76
+
47
77
  var mergeConfigDataWithConsoleConfig = function mergeConfigDataWithConsoleConfig(configData, consoleConfig) {
48
- var _window, _window$ALIYUN_CONSOL, _configData$ALL_CHANN, _configData$ALL_CHANN2;
78
+ var _window, _window$ALIYUN_CONSOL, _configData$ALL_CHANN;
49
79
 
50
80
  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';
51
81
  var channelLinks = ((_configData$ALL_CHANN = configData.ALL_CHANNEL_LINKS) === null || _configData$ALL_CHANN === void 0 ? void 0 : _configData$ALL_CHANN[channel]) || {};
52
- var channelFeatures = ((_configData$ALL_CHANN2 = configData.ALL_CHANNEL_FEATURE_STATUS) === null || _configData$ALL_CHANN2 === void 0 ? void 0 : _configData$ALL_CHANN2[channel]) || {};
82
+ var channelFeatures = configData.ALL_CHANNEL_FEATURE_STATUS || {};
53
83
  var features = configData.ALL_FEATURE_STATUS || {};
54
84
  return _objectSpread(_objectSpread({}, consoleConfig), {}, {
55
85
  CHANNEL_LINKS: channelLinks,
56
- CHANNEL_FEATURE_STATUS: channelFeatures,
86
+ CHANNEL_FEATURE_STATUS: processChannelFeatures(channelFeatures, channel),
57
87
  FEATURE_STATUS: processFeatures(features)
58
88
  });
59
89
  };
package/es/version.js CHANGED
@@ -1 +1 @@
1
- export var version = '1.4.0-alpha.0';
1
+ export var version = '1.4.0-alpha.1';
@@ -67,6 +67,10 @@ function createApplication(loader) {
67
67
  app = _useState2[0],
68
68
  setApp = _useState2[1];
69
69
 
70
+ var _useState3 = (0, _react.useState)(null),
71
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
72
+ setError = _useState4[1];
73
+
70
74
  var appRef = (0, _react.useRef)(undefined);
71
75
  var tagName = (0, _utils.normalizeName)(props.name);
72
76
  var sandbox = (0, _react.useMemo)(function () {
@@ -149,7 +153,9 @@ function createApplication(loader) {
149
153
  }
150
154
  }, _callee);
151
155
  }))().catch(function (e) {
152
- throw e;
156
+ setError(function () {
157
+ throw e;
158
+ });
153
159
  });
154
160
  return function () {
155
161
  app && app.unmount();
@@ -1,15 +1,15 @@
1
1
  import { AlfaConfig } from '@alicloud/alfa-core';
2
2
  export declare const getConsoleConfig: (configData: AlfaConfig, consoleConfig: any) => Promise<{
3
3
  CHANNEL_LINKS: Partial<Record<string, string>>;
4
- CHANNEL_FEATURE_STATUS: Partial<Record<string, {
4
+ CHANNEL_FEATURE_STATUS: Record<string, {
5
5
  status: boolean;
6
6
  attribute: {
7
7
  customAttrs: Record<string, unknown>;
8
- regions: {
8
+ regions: string[] | {
9
9
  region: string[];
10
10
  };
11
11
  };
12
- }>>;
12
+ }>;
13
13
  FEATURE_STATUS: Partial<Record<string, boolean>>;
14
14
  fEnv?: "pre" | "local" | "prod" | "daily" | undefined;
15
15
  LOCALE?: string | undefined;
@@ -55,16 +55,46 @@ var processFeatures = function processFeatures(features) {
55
55
  }, {});
56
56
  };
57
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
+
58
88
  var mergeConfigDataWithConsoleConfig = function mergeConfigDataWithConsoleConfig(configData, consoleConfig) {
59
- var _window, _window$ALIYUN_CONSOL, _configData$ALL_CHANN, _configData$ALL_CHANN2;
89
+ var _window, _window$ALIYUN_CONSOL, _configData$ALL_CHANN;
60
90
 
61
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';
62
92
  var channelLinks = ((_configData$ALL_CHANN = configData.ALL_CHANNEL_LINKS) === null || _configData$ALL_CHANN === void 0 ? void 0 : _configData$ALL_CHANN[channel]) || {};
63
- 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 || {};
64
94
  var features = configData.ALL_FEATURE_STATUS || {};
65
95
  return _objectSpread(_objectSpread({}, consoleConfig), {}, {
66
96
  CHANNEL_LINKS: channelLinks,
67
- CHANNEL_FEATURE_STATUS: channelFeatures,
97
+ CHANNEL_FEATURE_STATUS: processChannelFeatures(channelFeatures, channel),
68
98
  FEATURE_STATUS: processFeatures(features)
69
99
  });
70
100
  };
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "1.4.0-alpha.0";
1
+ export declare const version = "1.4.0-alpha.1";
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.4.0-alpha.0';
7
+ var version = '1.4.0-alpha.1';
8
8
  exports.version = version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alicloud/alfa-react",
3
- "version": "1.4.0-alpha.0",
3
+ "version": "1.4.0-alpha.1",
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.4.0-alpha.0",
42
+ "@alicloud/alfa-core": "^1.4.0-alpha.1",
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": "9c6fffdb53e1b42c98b80e3f4eb896a3e2ee0c86"
51
+ "gitHead": "fef8fead3499a82c1878e797bcfe17bb6fdb078e"
52
52
  }