@alicloud/alfa-core 1.5.11 → 1.5.12-beta.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.
- package/es/index.js +1 -1
- package/es/utils/env.js +18 -2
- package/es/utils/index.js +3 -2
- package/es/utils/interceptors/index.js +1 -0
- package/es/utils/interceptors/requestInterceptor.js +25 -9
- package/es/utils/interceptors/responseInterceptor.js +14 -3
- package/es/utils/logger.js +2 -2
- package/lib/index.js +7 -0
- package/lib/utils/env.js +18 -2
- package/lib/utils/index.js +3 -2
- package/lib/utils/interceptors/index.js +7 -0
- package/lib/utils/interceptors/requestInterceptor.js +26 -9
- package/lib/utils/interceptors/responseInterceptor.js +14 -3
- package/lib/utils/logger.js +2 -2
- package/package.json +2 -2
- package/types/index.d.ts +1 -1
- package/types/utils/interceptors/index.d.ts +1 -0
- package/types/utils/interceptors/requestInterceptor.d.ts +1 -0
package/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createMicroApp } from './createMicroApp';
|
|
2
|
-
export { addRequestInterceptor } from './utils/interceptors';
|
|
2
|
+
export { addRequestInterceptor, normalizeCdnUrl } from './utils/interceptors';
|
|
3
3
|
export { getRelease } from './utils/getRelease';
|
|
4
4
|
export { getManifest } from './utils/getManifest';
|
|
5
5
|
export { getConfig, getConfigV2 } from './utils/getConfig';
|
package/es/utils/env.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
// 无预发环境的域名后缀(一国一云及类似环境)
|
|
2
|
+
var noPrepubDomains = ['idptcloud01.com', 'idptcloud01-inc.com', 'uscloud.alibaba', 'idptcloud03.alibaba', 'idptcloud03-inc.alibaba'];
|
|
3
|
+
var isNoPrepubDomain = function isNoPrepubDomain() {
|
|
4
|
+
try {
|
|
5
|
+
return noPrepubDomains.some(function (domain) {
|
|
6
|
+
return location.hostname.endsWith(domain);
|
|
7
|
+
});
|
|
8
|
+
} catch (e) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
1
13
|
/**
|
|
2
14
|
* get alfa env
|
|
3
15
|
* @returns
|
|
@@ -11,7 +23,11 @@ export var getEnv = function getEnv(value) {
|
|
|
11
23
|
return 'local';
|
|
12
24
|
}
|
|
13
25
|
}
|
|
26
|
+
var env = ((_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';
|
|
14
27
|
|
|
15
|
-
//
|
|
16
|
-
|
|
28
|
+
// 无预发环境的域名强制使用 prod
|
|
29
|
+
if ((env === 'pre' || env === 'daily') && isNoPrepubDomain()) {
|
|
30
|
+
return 'prod';
|
|
31
|
+
}
|
|
32
|
+
return env;
|
|
17
33
|
};
|
package/es/utils/index.js
CHANGED
|
@@ -76,8 +76,9 @@ export var getRelativePath = function getRelativePath(from, to, base) {
|
|
|
76
76
|
toHost = _URL2.host,
|
|
77
77
|
toPath = _URL2.pathname;
|
|
78
78
|
|
|
79
|
-
//
|
|
80
|
-
|
|
79
|
+
// g.xxx and dev.g.xxx / dev-g.xxx regarded as same host
|
|
80
|
+
var isSameHost = fromHost === toHost || /^dev[.-]g\./.test(fromHost) && toHost === fromHost.replace(/^dev[.-]g\./, 'g.');
|
|
81
|
+
if (!isSameHost) return to;
|
|
81
82
|
var fromParts = trimArray(fromPath.split('/'));
|
|
82
83
|
var toParts = trimArray(toPath.split('/'));
|
|
83
84
|
var length = Math.min(fromParts.length, toParts.length);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
-
var
|
|
2
|
+
var _ALIYUN_CONSOLE_CONFI;
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
// 支持的主权云 CDN Host
|
|
5
|
-
|
|
6
|
-
var whiteList = ['idptcloud01cdn.com', ((_window$ALIYUN_CONSOL = window.ALIYUN_CONSOLE_CONFIG) === null || _window$ALIYUN_CONSOL === void 0 ? void 0 : _window$ALIYUN_CONSOL.MAIN_RESOURCE_CDN) || 'alicdn.com'];
|
|
5
|
+
var whiteList = ['idptcloud01cdn.com', 'uscasset.alibaba', 'idptcloud03asset.alibaba', ((_ALIYUN_CONSOLE_CONFI = window.ALIYUN_CONSOLE_CONFIG) === null || _ALIYUN_CONSOLE_CONFI === void 0 ? void 0 : _ALIYUN_CONSOLE_CONFI.MAIN_RESOURCE_CDN) || 'alicdn.com'];
|
|
7
6
|
var win = window;
|
|
8
7
|
|
|
8
|
+
// 无预发环境的 CDN 域名(一国一云及类似环境)
|
|
9
|
+
var noPrepubCdnHosts = ['idptcloud01cdn.com', 'uscasset.alibaba', 'idptcloud03asset.alibaba'];
|
|
10
|
+
|
|
9
11
|
// 兼容非公有云环境,用于替换请求的 hostname
|
|
10
12
|
var getCurrentCdnHost = function getCurrentCdnHost() {
|
|
11
13
|
try {
|
|
@@ -24,6 +26,8 @@ var getCurrentCdnHost = function getCurrentCdnHost() {
|
|
|
24
26
|
var _URL = new URL(scriptUrl),
|
|
25
27
|
hostname = _URL.hostname;
|
|
26
28
|
var parts = hostname.split('.');
|
|
29
|
+
|
|
30
|
+
// 支持 .com 和 .alibaba 等多种顶级域名:取最后两段作为 CDN host
|
|
27
31
|
var _currentCdnHost = parts.length > 2 ? parts.slice(-2).join('.') : hostname;
|
|
28
32
|
if (!win.__alfa_cdn_host__) {
|
|
29
33
|
win.__alfa_cdn_host__ = _currentCdnHost;
|
|
@@ -37,6 +41,22 @@ var currentCdnHost = getCurrentCdnHost();
|
|
|
37
41
|
|
|
38
42
|
// 如果 host 被 o2 插件替换,则可以被用来判断是否需要替换 cdnHost
|
|
39
43
|
var gCdnHost = '//g.alicdn.com/';
|
|
44
|
+
var noDevGCdnPattern = /dev\.g\.(idptcloud01cdn\.com|uscasset\.alibaba|idptcloud03asset\.alibaba)/g;
|
|
45
|
+
export var normalizeCdnUrl = function normalizeCdnUrl(url) {
|
|
46
|
+
var isSupportedCdnHost = currentCdnHost && currentCdnHost !== 'alicdn.com' && (whiteList.includes(currentCdnHost) || gCdnHost.includes(currentCdnHost));
|
|
47
|
+
if (isSupportedCdnHost) {
|
|
48
|
+
return url.replace(/\.alicdn\.com/g, ".".concat(currentCdnHost))
|
|
49
|
+
// 预发域名也需替换(非公有云无独立预发域名)
|
|
50
|
+
.replace(/\.aliyun-inc\.com/g, ".".concat(currentCdnHost))
|
|
51
|
+
// 非公有云下无 cws2
|
|
52
|
+
.replace('cws2.', 'cws.')
|
|
53
|
+
// 无预发环境时使用 Release 路径
|
|
54
|
+
.replace(/\/Prepub\//g, noPrepubCdnHosts.includes(currentCdnHost) ? '/Release/' : '/Prepub/')
|
|
55
|
+
// 这些域名无 dev.g 子域名
|
|
56
|
+
.replace(noDevGCdnPattern, 'dev-g.$1');
|
|
57
|
+
}
|
|
58
|
+
return url;
|
|
59
|
+
};
|
|
40
60
|
|
|
41
61
|
// 根据不同环境替换 cdn 的域名
|
|
42
62
|
export default function requestInterceptor(_x) {
|
|
@@ -47,12 +67,8 @@ function _requestInterceptor() {
|
|
|
47
67
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
48
68
|
while (1) switch (_context.prev = _context.next) {
|
|
49
69
|
case 0:
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
if (config.url) {
|
|
53
|
-
config.url = config.url.replace(new RegExp('.alicdn.com'), ".".concat(currentCdnHost)).replace('cws2.', 'cws.') // 非公有云下无 cws2
|
|
54
|
-
.replace('dev.g.idptcloud01cdn.com', 'dev-g.idptcloud01cdn.com'); // idptcloud01cdn 无 dev.g 子域名
|
|
55
|
-
}
|
|
70
|
+
if (config.url) {
|
|
71
|
+
config.url = normalizeCdnUrl(config.url);
|
|
56
72
|
}
|
|
57
73
|
return _context.abrupt("return", config);
|
|
58
74
|
case 1:
|
|
@@ -65,6 +65,9 @@ function isLegal(url, data) {
|
|
|
65
65
|
return false;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
// 无 cws2 fallback 的 CDN 域名(一国一云及类似环境)
|
|
69
|
+
var noCws2FallbackHosts = ['idptcloud01cdn.com', 'uscasset.alibaba', 'idptcloud03asset.alibaba'];
|
|
70
|
+
|
|
68
71
|
// check response content after networkErrorInterceptor
|
|
69
72
|
// if it legal, cache it
|
|
70
73
|
// if it is illegal, fallback cws.alicdn.com to cws2.alicdn.com.
|
|
@@ -73,7 +76,7 @@ export default function responseInterceptor(_x) {
|
|
|
73
76
|
}
|
|
74
77
|
function _responseInterceptor() {
|
|
75
78
|
_responseInterceptor = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(response) {
|
|
76
|
-
var data, config, url, newResponse, error;
|
|
79
|
+
var data, config, url, shouldSkipFallback, newResponse, error;
|
|
77
80
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
78
81
|
while (1) switch (_context.prev = _context.next) {
|
|
79
82
|
case 0:
|
|
@@ -85,8 +88,16 @@ function _responseInterceptor() {
|
|
|
85
88
|
}
|
|
86
89
|
return _context.abrupt("return", response);
|
|
87
90
|
case 1:
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
// 非公有云域名(.alibaba 等)没有 cws2 fallback,直接跳过
|
|
92
|
+
shouldSkipFallback = url && noCws2FallbackHosts.some(function (host) {
|
|
93
|
+
return url.includes(host);
|
|
94
|
+
});
|
|
95
|
+
if (shouldSkipFallback) {
|
|
96
|
+
_context.next = 3;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
config.url = url === null || url === void 0 ? void 0 : url.replace(/:\/\/cws\.([a-z0-9-]+\.(?:com|alibaba))\//, function (match, p1) {
|
|
100
|
+
return "://cws2.".concat(p1, "/");
|
|
90
101
|
});
|
|
91
102
|
_context.next = 2;
|
|
92
103
|
return axios(config);
|
package/es/utils/logger.js
CHANGED
|
@@ -80,8 +80,8 @@ var Logger = /*#__PURE__*/function () {
|
|
|
80
80
|
value: function track(method, topic, params) {
|
|
81
81
|
var data = this.mergeData(params);
|
|
82
82
|
|
|
83
|
-
// 国内站、国际站、idpt
|
|
84
|
-
if (!['aliyun.com', 'alibabacloud.com', 'aliyun-inc.com', 'alibaba-inc.com', 'idptcloud01.com', 'idptcloud01-inc.com'].find(function (domain) {
|
|
83
|
+
// 国内站、国际站、idpt、一国一云允许上报
|
|
84
|
+
if (!['aliyun.com', 'alibabacloud.com', 'aliyun-inc.com', 'alibaba-inc.com', 'idptcloud01.com', 'idptcloud01-inc.com', 'uscloud.alibaba', 'idptcloud03.alibaba', 'idptcloud03-inc.alibaba'].find(function (domain) {
|
|
85
85
|
return location.hostname.endsWith(domain);
|
|
86
86
|
})) return false;
|
|
87
87
|
|
package/lib/index.js
CHANGED
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
var _exportNames = {
|
|
8
8
|
createMicroApp: true,
|
|
9
9
|
addRequestInterceptor: true,
|
|
10
|
+
normalizeCdnUrl: true,
|
|
10
11
|
getRelease: true,
|
|
11
12
|
getManifest: true,
|
|
12
13
|
getConfig: true,
|
|
@@ -106,6 +107,12 @@ Object.defineProperty(exports, "loadExposedModule", {
|
|
|
106
107
|
return _consoleOsKernal.loadExposedModule;
|
|
107
108
|
}
|
|
108
109
|
});
|
|
110
|
+
Object.defineProperty(exports, "normalizeCdnUrl", {
|
|
111
|
+
enumerable: true,
|
|
112
|
+
get: function get() {
|
|
113
|
+
return _interceptors.normalizeCdnUrl;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
109
116
|
Object.defineProperty(exports, "prefetch", {
|
|
110
117
|
enumerable: true,
|
|
111
118
|
get: function get() {
|
package/lib/utils/env.js
CHANGED
|
@@ -4,6 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getEnv = void 0;
|
|
7
|
+
// 无预发环境的域名后缀(一国一云及类似环境)
|
|
8
|
+
var noPrepubDomains = ['idptcloud01.com', 'idptcloud01-inc.com', 'uscloud.alibaba', 'idptcloud03.alibaba', 'idptcloud03-inc.alibaba'];
|
|
9
|
+
var isNoPrepubDomain = function isNoPrepubDomain() {
|
|
10
|
+
try {
|
|
11
|
+
return noPrepubDomains.some(function (domain) {
|
|
12
|
+
return location.hostname.endsWith(domain);
|
|
13
|
+
});
|
|
14
|
+
} catch (e) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
7
19
|
/**
|
|
8
20
|
* get alfa env
|
|
9
21
|
* @returns
|
|
@@ -17,7 +29,11 @@ var getEnv = exports.getEnv = function getEnv(value) {
|
|
|
17
29
|
return 'local';
|
|
18
30
|
}
|
|
19
31
|
}
|
|
32
|
+
var env = ((_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';
|
|
20
33
|
|
|
21
|
-
//
|
|
22
|
-
|
|
34
|
+
// 无预发环境的域名强制使用 prod
|
|
35
|
+
if ((env === 'pre' || env === 'daily') && isNoPrepubDomain()) {
|
|
36
|
+
return 'prod';
|
|
37
|
+
}
|
|
38
|
+
return env;
|
|
23
39
|
};
|
package/lib/utils/index.js
CHANGED
|
@@ -106,8 +106,9 @@ var getRelativePath = exports.getRelativePath = function getRelativePath(from, t
|
|
|
106
106
|
toHost = _URL2.host,
|
|
107
107
|
toPath = _URL2.pathname;
|
|
108
108
|
|
|
109
|
-
//
|
|
110
|
-
|
|
109
|
+
// g.xxx and dev.g.xxx / dev-g.xxx regarded as same host
|
|
110
|
+
var isSameHost = fromHost === toHost || /^dev[.-]g\./.test(fromHost) && toHost === fromHost.replace(/^dev[.-]g\./, 'g.');
|
|
111
|
+
if (!isSameHost) return to;
|
|
111
112
|
var fromParts = trimArray(fromPath.split('/'));
|
|
112
113
|
var toParts = trimArray(toPath.split('/'));
|
|
113
114
|
var length = Math.min(fromParts.length, toParts.length);
|
|
@@ -5,7 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.addRequestInterceptor = void 0;
|
|
8
|
+
Object.defineProperty(exports, "normalizeCdnUrl", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _requestInterceptor.normalizeCdnUrl;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
8
14
|
var _request = _interopRequireDefault(require("../request"));
|
|
15
|
+
var _requestInterceptor = require("./requestInterceptor");
|
|
9
16
|
var addRequestInterceptor = exports.addRequestInterceptor = function addRequestInterceptor(fn) {
|
|
10
17
|
var interceptor = function interceptor(config) {
|
|
11
18
|
try {
|
|
@@ -5,14 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = requestInterceptor;
|
|
8
|
+
exports.normalizeCdnUrl = void 0;
|
|
8
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var
|
|
11
|
+
var _ALIYUN_CONSOLE_CONFI;
|
|
11
12
|
// 支持的主权云 CDN Host
|
|
12
|
-
|
|
13
|
-
var whiteList = ['idptcloud01cdn.com', ((_window$ALIYUN_CONSOL = window.ALIYUN_CONSOLE_CONFIG) === null || _window$ALIYUN_CONSOL === void 0 ? void 0 : _window$ALIYUN_CONSOL.MAIN_RESOURCE_CDN) || 'alicdn.com'];
|
|
13
|
+
var whiteList = ['idptcloud01cdn.com', 'uscasset.alibaba', 'idptcloud03asset.alibaba', ((_ALIYUN_CONSOLE_CONFI = window.ALIYUN_CONSOLE_CONFIG) === null || _ALIYUN_CONSOLE_CONFI === void 0 ? void 0 : _ALIYUN_CONSOLE_CONFI.MAIN_RESOURCE_CDN) || 'alicdn.com'];
|
|
14
14
|
var win = window;
|
|
15
15
|
|
|
16
|
+
// 无预发环境的 CDN 域名(一国一云及类似环境)
|
|
17
|
+
var noPrepubCdnHosts = ['idptcloud01cdn.com', 'uscasset.alibaba', 'idptcloud03asset.alibaba'];
|
|
18
|
+
|
|
16
19
|
// 兼容非公有云环境,用于替换请求的 hostname
|
|
17
20
|
var getCurrentCdnHost = function getCurrentCdnHost() {
|
|
18
21
|
try {
|
|
@@ -31,6 +34,8 @@ var getCurrentCdnHost = function getCurrentCdnHost() {
|
|
|
31
34
|
var _URL = new URL(scriptUrl),
|
|
32
35
|
hostname = _URL.hostname;
|
|
33
36
|
var parts = hostname.split('.');
|
|
37
|
+
|
|
38
|
+
// 支持 .com 和 .alibaba 等多种顶级域名:取最后两段作为 CDN host
|
|
34
39
|
var _currentCdnHost = parts.length > 2 ? parts.slice(-2).join('.') : hostname;
|
|
35
40
|
if (!win.__alfa_cdn_host__) {
|
|
36
41
|
win.__alfa_cdn_host__ = _currentCdnHost;
|
|
@@ -44,6 +49,22 @@ var currentCdnHost = getCurrentCdnHost();
|
|
|
44
49
|
|
|
45
50
|
// 如果 host 被 o2 插件替换,则可以被用来判断是否需要替换 cdnHost
|
|
46
51
|
var gCdnHost = '//g.alicdn.com/';
|
|
52
|
+
var noDevGCdnPattern = /dev\.g\.(idptcloud01cdn\.com|uscasset\.alibaba|idptcloud03asset\.alibaba)/g;
|
|
53
|
+
var normalizeCdnUrl = exports.normalizeCdnUrl = function normalizeCdnUrl(url) {
|
|
54
|
+
var isSupportedCdnHost = currentCdnHost && currentCdnHost !== 'alicdn.com' && (whiteList.includes(currentCdnHost) || gCdnHost.includes(currentCdnHost));
|
|
55
|
+
if (isSupportedCdnHost) {
|
|
56
|
+
return url.replace(/\.alicdn\.com/g, ".".concat(currentCdnHost))
|
|
57
|
+
// 预发域名也需替换(非公有云无独立预发域名)
|
|
58
|
+
.replace(/\.aliyun-inc\.com/g, ".".concat(currentCdnHost))
|
|
59
|
+
// 非公有云下无 cws2
|
|
60
|
+
.replace('cws2.', 'cws.')
|
|
61
|
+
// 无预发环境时使用 Release 路径
|
|
62
|
+
.replace(/\/Prepub\//g, noPrepubCdnHosts.includes(currentCdnHost) ? '/Release/' : '/Prepub/')
|
|
63
|
+
// 这些域名无 dev.g 子域名
|
|
64
|
+
.replace(noDevGCdnPattern, 'dev-g.$1');
|
|
65
|
+
}
|
|
66
|
+
return url;
|
|
67
|
+
};
|
|
47
68
|
|
|
48
69
|
// 根据不同环境替换 cdn 的域名
|
|
49
70
|
function requestInterceptor(_x) {
|
|
@@ -54,12 +75,8 @@ function _requestInterceptor() {
|
|
|
54
75
|
return _regenerator.default.wrap(function (_context) {
|
|
55
76
|
while (1) switch (_context.prev = _context.next) {
|
|
56
77
|
case 0:
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
if (config.url) {
|
|
60
|
-
config.url = config.url.replace(new RegExp('.alicdn.com'), ".".concat(currentCdnHost)).replace('cws2.', 'cws.') // 非公有云下无 cws2
|
|
61
|
-
.replace('dev.g.idptcloud01cdn.com', 'dev-g.idptcloud01cdn.com'); // idptcloud01cdn 无 dev.g 子域名
|
|
62
|
-
}
|
|
78
|
+
if (config.url) {
|
|
79
|
+
config.url = normalizeCdnUrl(config.url);
|
|
63
80
|
}
|
|
64
81
|
return _context.abrupt("return", config);
|
|
65
82
|
case 1:
|
|
@@ -72,6 +72,9 @@ function isLegal(url, data) {
|
|
|
72
72
|
return false;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
// 无 cws2 fallback 的 CDN 域名(一国一云及类似环境)
|
|
76
|
+
var noCws2FallbackHosts = ['idptcloud01cdn.com', 'uscasset.alibaba', 'idptcloud03asset.alibaba'];
|
|
77
|
+
|
|
75
78
|
// check response content after networkErrorInterceptor
|
|
76
79
|
// if it legal, cache it
|
|
77
80
|
// if it is illegal, fallback cws.alicdn.com to cws2.alicdn.com.
|
|
@@ -80,7 +83,7 @@ function responseInterceptor(_x) {
|
|
|
80
83
|
}
|
|
81
84
|
function _responseInterceptor() {
|
|
82
85
|
_responseInterceptor = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(response) {
|
|
83
|
-
var data, config, url, newResponse, error;
|
|
86
|
+
var data, config, url, shouldSkipFallback, newResponse, error;
|
|
84
87
|
return _regenerator.default.wrap(function (_context) {
|
|
85
88
|
while (1) switch (_context.prev = _context.next) {
|
|
86
89
|
case 0:
|
|
@@ -92,8 +95,16 @@ function _responseInterceptor() {
|
|
|
92
95
|
}
|
|
93
96
|
return _context.abrupt("return", response);
|
|
94
97
|
case 1:
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
// 非公有云域名(.alibaba 等)没有 cws2 fallback,直接跳过
|
|
99
|
+
shouldSkipFallback = url && noCws2FallbackHosts.some(function (host) {
|
|
100
|
+
return url.includes(host);
|
|
101
|
+
});
|
|
102
|
+
if (shouldSkipFallback) {
|
|
103
|
+
_context.next = 3;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
config.url = url === null || url === void 0 ? void 0 : url.replace(/:\/\/cws\.([a-z0-9-]+\.(?:com|alibaba))\//, function (match, p1) {
|
|
107
|
+
return "://cws2.".concat(p1, "/");
|
|
97
108
|
});
|
|
98
109
|
_context.next = 2;
|
|
99
110
|
return (0, _axios.default)(config);
|
package/lib/utils/logger.js
CHANGED
|
@@ -87,8 +87,8 @@ var Logger = exports.default = /*#__PURE__*/function () {
|
|
|
87
87
|
value: function track(method, topic, params) {
|
|
88
88
|
var data = this.mergeData(params);
|
|
89
89
|
|
|
90
|
-
// 国内站、国际站、idpt
|
|
91
|
-
if (!['aliyun.com', 'alibabacloud.com', 'aliyun-inc.com', 'alibaba-inc.com', 'idptcloud01.com', 'idptcloud01-inc.com'].find(function (domain) {
|
|
90
|
+
// 国内站、国际站、idpt、一国一云允许上报
|
|
91
|
+
if (!['aliyun.com', 'alibabacloud.com', 'aliyun-inc.com', 'alibaba-inc.com', 'idptcloud01.com', 'idptcloud01-inc.com', 'uscloud.alibaba', 'idptcloud03.alibaba', 'idptcloud03-inc.alibaba'].find(function (domain) {
|
|
92
92
|
return location.hostname.endsWith(domain);
|
|
93
93
|
})) return false;
|
|
94
94
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alicloud/alfa-core",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.12-beta.2",
|
|
4
4
|
"description": "MicroFront End SDK for alicloud",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"crypto-js": "^4.1.1",
|
|
34
34
|
"qs": "^6.14.0",
|
|
35
35
|
"tslib": "^2.4.0",
|
|
36
|
-
"@alicloud/console-os-kernal": "^1.4.
|
|
36
|
+
"@alicloud/console-os-kernal": "^1.4.40-beta.2"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "npm run babel && npm run babel:esm && npm run types",
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createMicroApp } from './createMicroApp';
|
|
2
|
-
export { addRequestInterceptor } from './utils/interceptors';
|
|
2
|
+
export { addRequestInterceptor, normalizeCdnUrl } from './utils/interceptors';
|
|
3
3
|
export { getRelease } from './utils/getRelease';
|
|
4
4
|
export { getManifest } from './utils/getManifest';
|
|
5
5
|
export { getConfig, getConfigV2 } from './utils/getConfig';
|