@alicloud/alfa-react 1.4.0-alpha.0 → 1.4.0-alpha.3
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/dist/index.js +6 -6
- package/es/createApplication.js +7 -1
- package/es/hooks/beforeLoadHook.js +2 -2
- package/es/utils/getConsoleConfig.js +33 -3
- package/es/version.js +1 -1
- package/lib/createApplication.js +7 -1
- package/lib/hooks/beforeLoadHook.js +1 -1
- package/lib/utils/getConsoleConfig.d.ts +3 -3
- package/lib/utils/getConsoleConfig.js +33 -3
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +3 -3
package/es/createApplication.js
CHANGED
|
@@ -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
|
-
|
|
134
|
+
setError(function () {
|
|
135
|
+
throw e;
|
|
136
|
+
});
|
|
131
137
|
});
|
|
132
138
|
|
|
133
139
|
return function () {
|
|
@@ -7,7 +7,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
7
7
|
|
|
8
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
|
-
import { getConfig,
|
|
10
|
+
import { getConfig, getI18nMessages } from '@alicloud/alfa-core';
|
|
11
11
|
import { getConsoleConfig } from '../utils/getConsoleConfig';
|
|
12
12
|
import { getConsoleGlobal } from '../utils/getConsoleGlobal'; // inject consoleConfig & locales after load
|
|
13
13
|
|
|
@@ -33,7 +33,7 @@ function _afterLoadHook() {
|
|
|
33
33
|
case 6:
|
|
34
34
|
configData = _context.sent;
|
|
35
35
|
_context.next = 9;
|
|
36
|
-
return Promise.all([getConsoleConfig(configData, defaultConsoleConfig), getConsoleGlobal(configData, defaultConsoleGlobal),
|
|
36
|
+
return Promise.all([getConsoleConfig(configData, defaultConsoleConfig), getConsoleGlobal(configData, defaultConsoleGlobal), getI18nMessages(appConfig)]);
|
|
37
37
|
|
|
38
38
|
case 9:
|
|
39
39
|
_yield$Promise$all = _context.sent;
|
|
@@ -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
|
|
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 =
|
|
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.
|
|
1
|
+
export var version = '1.4.0-alpha.3';
|
package/lib/createApplication.js
CHANGED
|
@@ -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
|
-
|
|
156
|
+
setError(function () {
|
|
157
|
+
throw e;
|
|
158
|
+
});
|
|
153
159
|
});
|
|
154
160
|
return function () {
|
|
155
161
|
app && app.unmount();
|
|
@@ -48,7 +48,7 @@ function _afterLoadHook() {
|
|
|
48
48
|
case 6:
|
|
49
49
|
configData = _context.sent;
|
|
50
50
|
_context.next = 9;
|
|
51
|
-
return Promise.all([(0, _getConsoleConfig.getConsoleConfig)(configData, defaultConsoleConfig), (0, _getConsoleGlobal.getConsoleGlobal)(configData, defaultConsoleGlobal), (0, _alfaCore.
|
|
51
|
+
return Promise.all([(0, _getConsoleConfig.getConsoleConfig)(configData, defaultConsoleConfig), (0, _getConsoleGlobal.getConsoleGlobal)(configData, defaultConsoleGlobal), (0, _alfaCore.getI18nMessages)(appConfig)]);
|
|
52
52
|
|
|
53
53
|
case 9:
|
|
54
54
|
_yield$Promise$all = _context.sent;
|
|
@@ -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:
|
|
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
|
|
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 =
|
|
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.
|
|
1
|
+
export declare const version = "1.4.0-alpha.3";
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alicloud/alfa-react",
|
|
3
|
-
"version": "1.4.0-alpha.
|
|
3
|
+
"version": "1.4.0-alpha.3",
|
|
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.
|
|
42
|
+
"@alicloud/alfa-core": "^1.4.0-alpha.3",
|
|
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": "
|
|
51
|
+
"gitHead": "e81232b14356296973770cd05e403a95209d150c"
|
|
52
52
|
}
|