@onekeyfe/cross-inpage-provider-core 0.0.4 → 0.0.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.
@@ -4,10 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fakeLogger = exports.appDebugLogger = exports.fakeDebugLogger = void 0;
7
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
8
7
  // @ts-ignore
9
8
  const debug_1 = __importDefault(require("./debug"));
9
+ // enable debugLogger:
10
+ // localStorage.setItem('$$ONEKEY_DEBUG_LOGGER', '*');
10
11
  const fakeLogger = {
12
+ // @ts-ignore
13
+ _isFakeLogger: true,
11
14
  log: (...args) => undefined,
12
15
  warn: (...args) => undefined,
13
16
  error: (...args) => undefined,
@@ -48,18 +51,28 @@ class FakeDebugLogger {
48
51
  class AppDebugLogger extends FakeDebugLogger {
49
52
  constructor() {
50
53
  super();
54
+ this._debugInstanceCreatedMap = {};
51
55
  void (0, debug_1.default)().then((debug) => (this._debug = debug));
52
56
  }
53
57
  _createDebugInstance(name) {
58
+ if (this._debugInstanceCreatedMap[name]) {
59
+ return;
60
+ }
61
+ this._debugInstanceCreatedMap[name] = true;
54
62
  if (name && this._debug && typeof this._debug === 'function') {
55
63
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment
56
- const _instance = this._debug(name);
57
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
64
+ const _debugLog = this._debug(name);
65
+ // @ts-ignore
66
+ const _originLog = this[name];
58
67
  // @ts-ignore
59
68
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment
60
69
  this[name] = (...args) => {
61
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
62
- _instance(...args);
70
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
71
+ _debugLog(...args);
72
+ if (_originLog && typeof _originLog === 'function') {
73
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
74
+ _originLog(...args);
75
+ }
63
76
  };
64
77
  }
65
78
  }
package/dist/loggers.js CHANGED
@@ -1,7 +1,10 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
1
  // @ts-ignore
3
2
  import createDebugAsync from './debug';
3
+ // enable debugLogger:
4
+ // localStorage.setItem('$$ONEKEY_DEBUG_LOGGER', '*');
4
5
  const fakeLogger = {
6
+ // @ts-ignore
7
+ _isFakeLogger: true,
5
8
  log: (...args) => undefined,
6
9
  warn: (...args) => undefined,
7
10
  error: (...args) => undefined,
@@ -41,18 +44,28 @@ class FakeDebugLogger {
41
44
  class AppDebugLogger extends FakeDebugLogger {
42
45
  constructor() {
43
46
  super();
47
+ this._debugInstanceCreatedMap = {};
44
48
  void createDebugAsync().then((debug) => (this._debug = debug));
45
49
  }
46
50
  _createDebugInstance(name) {
51
+ if (this._debugInstanceCreatedMap[name]) {
52
+ return;
53
+ }
54
+ this._debugInstanceCreatedMap[name] = true;
47
55
  if (name && this._debug && typeof this._debug === 'function') {
48
56
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment
49
- const _instance = this._debug(name);
50
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
57
+ const _debugLog = this._debug(name);
58
+ // @ts-ignore
59
+ const _originLog = this[name];
51
60
  // @ts-ignore
52
61
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment
53
62
  this[name] = (...args) => {
54
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
55
- _instance(...args);
63
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
64
+ _debugLog(...args);
65
+ if (_originLog && typeof _originLog === 'function') {
66
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
67
+ _originLog(...args);
68
+ }
56
69
  };
57
70
  }
58
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/cross-inpage-provider-core",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "keywords": [
5
5
  "cross-inpage-provider"
6
6
  ],
@@ -28,11 +28,11 @@
28
28
  "start": "tsc --watch"
29
29
  },
30
30
  "dependencies": {
31
- "@onekeyfe/cross-inpage-provider-errors": "^0.0.4",
32
- "@onekeyfe/cross-inpage-provider-types": "^0.0.4",
31
+ "@onekeyfe/cross-inpage-provider-errors": "^0.0.5",
32
+ "@onekeyfe/cross-inpage-provider-types": "^0.0.5",
33
33
  "eventemitter3": "^4.0.7",
34
34
  "lodash": "^4.17.21",
35
35
  "ms": "^2.1.3"
36
36
  },
37
- "gitHead": "d47447804157874b2607aea82f92ff3a132c5e67"
37
+ "gitHead": "fc053fe3c2920fca734addae381339a29a09b716"
38
38
  }