@alicloud/alfa-core 1.5.3 → 1.5.5

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.
@@ -129,7 +129,7 @@ export var getConfigV2 = /*#__PURE__*/function () {
129
129
  _context2.prev = 15;
130
130
  _context2.t0 = _context2["catch"](8);
131
131
  case 17:
132
- return _context2.abrupt("return", currentConfig);
132
+ return _context2.abrupt("return", undefined);
133
133
  case 18:
134
134
  case "end":
135
135
  return _context2.stop();
@@ -1,15 +1,26 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  var whiteList = ['alicdn.com', 'idptcloud01cdn.com'];
4
+ var win = window;
4
5
 
5
6
  // 兼容非公有云环境
6
7
  var getCurrentCdnHost = function getCurrentCdnHost() {
7
8
  try {
8
9
  var _document$currentScri;
10
+ // 逻辑上所有的微应用 cdn 都是同一个 host,所以可以复用同一个全局变量
11
+ if (win.__alfa_cdn_host__) {
12
+ return win.__alfa_cdn_host__;
13
+ }
14
+
15
+ // document.currentScript 可能为 null
9
16
  var _URL = new URL(((_document$currentScri = document.currentScript) === null || _document$currentScri === void 0 ? void 0 : _document$currentScri.src) || ''),
10
17
  hostname = _URL.hostname;
11
18
  var parts = hostname.split('.');
12
- return parts.length > 2 ? parts.slice(-2).join('.') : hostname;
19
+ var _currentCdnHost = parts.length > 2 ? parts.slice(-2).join('.') : hostname;
20
+ if (!win.__alfa_cdn_host__) {
21
+ win.__alfa_cdn_host__ = _currentCdnHost;
22
+ }
23
+ return _currentCdnHost;
13
24
  } catch (e) {
14
25
  return undefined;
15
26
  }
@@ -136,7 +136,7 @@ var getConfigV2 = exports.getConfigV2 = /*#__PURE__*/function () {
136
136
  _context2.prev = 15;
137
137
  _context2.t0 = _context2["catch"](8);
138
138
  case 17:
139
- return _context2.abrupt("return", currentConfig);
139
+ return _context2.abrupt("return", undefined);
140
140
  case 18:
141
141
  case "end":
142
142
  return _context2.stop();
@@ -8,15 +8,26 @@ exports.default = requestInterceptor;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
10
  var whiteList = ['alicdn.com', 'idptcloud01cdn.com'];
11
+ var win = window;
11
12
 
12
13
  // 兼容非公有云环境
13
14
  var getCurrentCdnHost = function getCurrentCdnHost() {
14
15
  try {
15
16
  var _document$currentScri;
17
+ // 逻辑上所有的微应用 cdn 都是同一个 host,所以可以复用同一个全局变量
18
+ if (win.__alfa_cdn_host__) {
19
+ return win.__alfa_cdn_host__;
20
+ }
21
+
22
+ // document.currentScript 可能为 null
16
23
  var _URL = new URL(((_document$currentScri = document.currentScript) === null || _document$currentScri === void 0 ? void 0 : _document$currentScri.src) || ''),
17
24
  hostname = _URL.hostname;
18
25
  var parts = hostname.split('.');
19
- return parts.length > 2 ? parts.slice(-2).join('.') : hostname;
26
+ var _currentCdnHost = parts.length > 2 ? parts.slice(-2).join('.') : hostname;
27
+ if (!win.__alfa_cdn_host__) {
28
+ win.__alfa_cdn_host__ = _currentCdnHost;
29
+ }
30
+ return _currentCdnHost;
20
31
  } catch (e) {
21
32
  return undefined;
22
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alicloud/alfa-core",
3
- "version": "1.5.3",
3
+ "version": "1.5.5",
4
4
  "description": "MicroFront End SDK for alicloud",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -31,4 +31,4 @@ export declare const getConfigV2: (config: IAppConfig) => Promise<{
31
31
  APP_ID?: string | undefined;
32
32
  }>;
33
33
  ALIYUN_CONSOLE_GLOBAL: Record<string, any>;
34
- }>;
34
+ } | undefined>;