@alicloud/alfa-core 1.5.2 → 1.5.4

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.
@@ -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
  }
@@ -81,7 +81,7 @@ var Logger = /*#__PURE__*/function () {
81
81
  })) return false;
82
82
 
83
83
  // do not track during development
84
- if (this.context.ENV !== 'prod') {
84
+ if (this.context.ENV !== 'prod' && !(params !== null && params !== void 0 && params.__force_log__)) {
85
85
  console[method](topic, data);
86
86
  return;
87
87
  }
@@ -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
  }
@@ -88,7 +88,7 @@ var Logger = exports.default = /*#__PURE__*/function () {
88
88
  })) return false;
89
89
 
90
90
  // do not track during development
91
- if (this.context.ENV !== 'prod') {
91
+ if (this.context.ENV !== 'prod' && !(params !== null && params !== void 0 && params.__force_log__)) {
92
92
  console[method](topic, data);
93
93
  return;
94
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alicloud/alfa-core",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "description": "MicroFront End SDK for alicloud",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -1,6 +1,7 @@
1
1
  import { AlfaLogger } from '../types';
2
2
  interface Params {
3
3
  [key: string]: string | number | boolean | undefined;
4
+ __force_log__?: boolean;
4
5
  }
5
6
  export default class Logger implements AlfaLogger {
6
7
  cache: Params;