@wutiange/log-listener-plugin 1.2.0 → 1.3.0-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/console.js +14 -15
- package/dist/console.js.map +1 -1
- package/dist/fetch.js +28 -28
- package/dist/fetch.js.map +1 -1
- package/dist/index.d.ts +2 -23
- package/dist/index.js +2 -117
- package/dist/index.js.map +1 -1
- package/dist/packages/network-logger/Logger.d.ts +28 -0
- package/dist/packages/network-logger/Logger.js +192 -0
- package/dist/packages/network-logger/Logger.js.map +1 -0
- package/dist/packages/network-logger/NetworkRequestInfo.d.ts +36 -0
- package/dist/packages/network-logger/NetworkRequestInfo.js +129 -0
- package/dist/packages/network-logger/NetworkRequestInfo.js.map +1 -0
- package/dist/packages/network-logger/constant.d.ts +2 -0
- package/dist/packages/network-logger/constant.js +6 -0
- package/dist/packages/network-logger/constant.js.map +1 -0
- package/dist/packages/network-logger/types.d.ts +14 -0
- package/dist/packages/network-logger/types.js +3 -0
- package/dist/packages/network-logger/types.js.map +1 -0
- package/dist/packages/network-logger/utils/debounce.d.ts +2 -0
- package/dist/packages/network-logger/utils/debounce.js +20 -0
- package/dist/packages/network-logger/utils/debounce.js.map +1 -0
- package/dist/packages/network-logger/utils/extractHost.d.ts +2 -0
- package/dist/packages/network-logger/utils/extractHost.js +9 -0
- package/dist/packages/network-logger/utils/extractHost.js.map +1 -0
- package/dist/packages/network-logger/utils/fromEntries.d.ts +2 -0
- package/dist/packages/network-logger/utils/fromEntries.js +8 -0
- package/dist/packages/network-logger/utils/fromEntries.js.map +1 -0
- package/dist/packages/network-logger/utils/logger.d.ts +1 -0
- package/dist/packages/network-logger/utils/logger.js +6 -0
- package/dist/packages/network-logger/utils/logger.js.map +1 -0
- package/dist/src/CompatibilityManager.d.ts +27 -0
- package/dist/src/CompatibilityManager.js +74 -0
- package/dist/src/CompatibilityManager.js.map +1 -0
- package/dist/src/__tests__/console.test.d.ts +1 -0
- package/dist/{__tests__ → src/__tests__}/console.test.js +2 -2
- package/dist/src/__tests__/console.test.js.map +1 -0
- package/dist/src/common.js.map +1 -0
- package/dist/src/console.d.ts +1 -0
- package/dist/src/console.js +20 -0
- package/dist/src/console.js.map +1 -0
- package/dist/src/fetch.d.ts +1 -0
- package/dist/src/fetch.js +48 -0
- package/dist/src/fetch.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +8 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/logPlugin.d.ts +32 -0
- package/dist/src/logPlugin.js +187 -0
- package/dist/src/logPlugin.js.map +1 -0
- package/dist/{server.d.ts → src/server.d.ts} +1 -1
- package/dist/{server.js → src/server.js} +14 -8
- package/dist/src/server.js.map +1 -0
- package/dist/src/utils.d.ts +3 -0
- package/dist/src/utils.js +38 -0
- package/dist/src/utils.js.map +1 -0
- package/package.json +13 -5
- package/packages/network-logger/Logger.ts +274 -0
- package/packages/network-logger/NetworkRequestInfo.ts +133 -0
- package/packages/network-logger/constant.ts +3 -0
- package/packages/network-logger/types.ts +36 -0
- package/packages/network-logger/utils/debounce.ts +21 -0
- package/packages/network-logger/utils/extractHost.ts +7 -0
- package/packages/network-logger/utils/fromEntries.ts +7 -0
- package/packages/network-logger/utils/logger.ts +2 -0
- package/src/CompatibilityManager.ts +64 -0
- package/src/__tests__/console.test.ts +2 -2
- package/src/common.ts +2 -3
- package/src/logPlugin.ts +229 -0
- package/src/server.ts +28 -23
- package/src/utils.ts +38 -0
- package/dist/__tests__/console.test.d.ts +0 -1
- package/dist/__tests__/console.test.js.map +0 -1
- package/dist/common.js.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/utils.d.ts +0 -1
- package/dist/utils.js +0 -14
- package/dist/utils.js.map +0 -1
- package/src/console.ts +0 -19
- package/src/fetch.ts +0 -35
- package/src/index.ts +0 -131
- /package/dist/{common.d.ts → src/common.d.ts} +0 -0
- /package/dist/{common.js → src/common.js} +0 -0
package/dist/console.js
CHANGED
@@ -3,19 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
});
|
6
|
+
const logPlugin_1 = __importDefault(require("./src/logPlugin"));
|
7
|
+
const common = require('./src/common');
|
8
|
+
console.log = (...data) => {
|
9
|
+
logPlugin_1.default.log(...data);
|
10
|
+
common.log(...data);
|
11
|
+
};
|
12
|
+
console.warn = (...data) => {
|
13
|
+
logPlugin_1.default.warn(...data);
|
14
|
+
common.warn(...data);
|
15
|
+
};
|
16
|
+
console.error = (...data) => {
|
17
|
+
logPlugin_1.default.error(...data);
|
18
|
+
common.error(...data);
|
19
|
+
};
|
21
20
|
//# sourceMappingURL=console.js.map
|
package/dist/console.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"console.js","sourceRoot":"","sources":["../
|
1
|
+
{"version":3,"file":"console.js","sourceRoot":"","sources":["../console.ts"],"names":[],"mappings":";;;;;AAKA,gEAAqC;AACrC,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AACvC,OAAO,CAAC,GAAG,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;IAC/B,mBAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACpB,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;AACtB,CAAC,CAAC;AAEF,OAAO,CAAC,IAAI,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;IAChC,mBAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IACrB,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AACvB,CAAC,CAAC;AAEF,OAAO,CAAC,KAAK,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;IACjC,mBAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;IACtB,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;AACxB,CAAC,CAAC"}
|
package/dist/fetch.js
CHANGED
@@ -13,36 +13,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
13
|
};
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
const index_1 = __importDefault(require("./index"));
|
16
|
-
const utils_1 = require("./utils");
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
});
|
30
|
-
}
|
31
|
-
try {
|
32
|
-
const response = yield common.tempFetch(input, init);
|
33
|
-
isFetchFinished = true;
|
34
|
-
if (response instanceof Response && !isTimeout) {
|
35
|
-
index_1.default.uniqueRes(uniqueId, response.clone());
|
16
|
+
const utils_1 = require("./src/utils");
|
17
|
+
const common = require('./src/common');
|
18
|
+
global.fetch = (input, init) => __awaiter(void 0, void 0, void 0, function* () {
|
19
|
+
const uniqueId = (Date.now() + Math.random()).toString(16);
|
20
|
+
index_1.default.uniqueReq(uniqueId, input, init);
|
21
|
+
let isFetchFinished = false;
|
22
|
+
let isTimeout = false;
|
23
|
+
const timeout = index_1.default.getTimeout();
|
24
|
+
if (timeout !== null) {
|
25
|
+
(0, utils_1.sleep)(timeout).then(() => {
|
26
|
+
if (!isFetchFinished) {
|
27
|
+
isTimeout = true;
|
28
|
+
index_1.default.resTimeout(uniqueId);
|
36
29
|
}
|
37
|
-
|
30
|
+
});
|
31
|
+
}
|
32
|
+
try {
|
33
|
+
const response = yield common.tempFetch(input, init);
|
34
|
+
isFetchFinished = true;
|
35
|
+
if (response instanceof Response && !isTimeout) {
|
36
|
+
index_1.default.uniqueRes(uniqueId, response.clone());
|
38
37
|
}
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
38
|
+
return response;
|
39
|
+
}
|
40
|
+
catch (error) {
|
41
|
+
isFetchFinished = true;
|
42
|
+
if (!isTimeout) {
|
43
|
+
index_1.default.resResponseError(uniqueId);
|
45
44
|
}
|
46
|
-
|
45
|
+
throw new Error(error);
|
46
|
+
}
|
47
47
|
});
|
48
48
|
//# sourceMappingURL=fetch.js.map
|
package/dist/fetch.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../fetch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,oDAA6B;AAC7B,uCAAkC;AAElC,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAEvC,MAAM,CAAC,KAAK,GAAG,CAAO,KAAwB,EAAE,IAAkB,EAAE,EAAE;IACpE,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC3D,eAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACxC,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,MAAM,OAAO,GAAG,eAAM,CAAC,UAAU,EAAE,CAAA;IACnC,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,IAAA,aAAK,EAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YACvB,IAAI,CAAC,eAAe,EAAE,CAAC;gBACrB,SAAS,GAAG,IAAI,CAAC;gBACjB,eAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACrD,eAAe,GAAG,IAAI,CAAC;QACvB,IAAI,QAAQ,YAAY,QAAQ,IAAI,CAAC,SAAS,EAAE,CAAC;YAC/C,eAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,eAAe,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,eAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;AACH,CAAC,CAAA,CAAC"}
|
package/dist/index.d.ts
CHANGED
@@ -1,23 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
private baseData;
|
4
|
-
private timeout;
|
5
|
-
setBaseUrl(url: string): void;
|
6
|
-
setTimeout(timeout: number): void;
|
7
|
-
getTimeout(): number;
|
8
|
-
setBaseData(data?: Record<string, any>): void;
|
9
|
-
private _log;
|
10
|
-
tag(tag: string, ...data: any[]): void;
|
11
|
-
log(...data: any[]): void;
|
12
|
-
warn(...data: any[]): void;
|
13
|
-
error(...data: any[]): void;
|
14
|
-
uniqueReq(uniqueId: string, input: RequestInfo | URL, init?: RequestInit): Promise<string>;
|
15
|
-
private _res;
|
16
|
-
resTimeout(uniqueId: string): Promise<string>;
|
17
|
-
resResponseError(uniqueId: string): Promise<string>;
|
18
|
-
uniqueRes(uniqueId: string, response?: Response): Promise<string>;
|
19
|
-
req(input: RequestInfo | URL, init?: RequestInit): Promise<string>;
|
20
|
-
res(id: number, response?: Response): Promise<string>;
|
21
|
-
}
|
22
|
-
declare const _default: Logger;
|
23
|
-
export default _default;
|
1
|
+
import logPlugin from './src/logPlugin';
|
2
|
+
export default logPlugin;
|
package/dist/index.js
CHANGED
@@ -1,123 +1,8 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
4
|
};
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const
|
16
|
-
|
17
|
-
constructor() {
|
18
|
-
this.server = null;
|
19
|
-
this.baseData = {};
|
20
|
-
this.timeout = null;
|
21
|
-
}
|
22
|
-
setBaseUrl(url) {
|
23
|
-
if (this.server) {
|
24
|
-
this.server.updateUrl(url);
|
25
|
-
}
|
26
|
-
else {
|
27
|
-
this.server = new server_1.default(url);
|
28
|
-
}
|
29
|
-
}
|
30
|
-
setTimeout(timeout) {
|
31
|
-
var _a;
|
32
|
-
if (typeof timeout === 'number') {
|
33
|
-
this.timeout = timeout;
|
34
|
-
(_a = this.server) === null || _a === void 0 ? void 0 : _a.updateTimeout(this.timeout);
|
35
|
-
}
|
36
|
-
}
|
37
|
-
getTimeout() {
|
38
|
-
if (typeof this.timeout === 'number') {
|
39
|
-
return this.timeout;
|
40
|
-
}
|
41
|
-
return null;
|
42
|
-
}
|
43
|
-
setBaseData(data = {}) {
|
44
|
-
this.baseData = data;
|
45
|
-
}
|
46
|
-
_log(level, tag, ...data) {
|
47
|
-
var _a;
|
48
|
-
const sendData = Object.assign(Object.assign({}, this.baseData), { message: data, tag, level: level !== null && level !== void 0 ? level : 'log', createTime: Date.now() });
|
49
|
-
(_a = this.server) === null || _a === void 0 ? void 0 : _a.log(sendData);
|
50
|
-
}
|
51
|
-
tag(tag, ...data) {
|
52
|
-
this._log('log', tag, ...data);
|
53
|
-
}
|
54
|
-
log(...data) {
|
55
|
-
this._log('log', 'default', ...data);
|
56
|
-
}
|
57
|
-
warn(...data) {
|
58
|
-
this._log('warn', 'default', ...data);
|
59
|
-
}
|
60
|
-
error(...data) {
|
61
|
-
this._log('error', 'default', ...data);
|
62
|
-
}
|
63
|
-
uniqueReq(uniqueId, input, init) {
|
64
|
-
var _a, _b, _c;
|
65
|
-
return __awaiter(this, void 0, void 0, function* () {
|
66
|
-
let url = null;
|
67
|
-
let method = (_a = init === null || init === void 0 ? void 0 : init.method) !== null && _a !== void 0 ? _a : 'get';
|
68
|
-
let headers = init === null || init === void 0 ? void 0 : init.headers;
|
69
|
-
let body = init === null || init === void 0 ? void 0 : init.body;
|
70
|
-
if (input instanceof Request) {
|
71
|
-
url = input.url;
|
72
|
-
method = (_b = input.method) !== null && _b !== void 0 ? _b : 'get';
|
73
|
-
headers = input.headers;
|
74
|
-
body = input.body;
|
75
|
-
}
|
76
|
-
else if (input instanceof URL) {
|
77
|
-
url = input.href;
|
78
|
-
}
|
79
|
-
else {
|
80
|
-
url = input;
|
81
|
-
}
|
82
|
-
return (_c = this.server) === null || _c === void 0 ? void 0 : _c.network(Object.assign(Object.assign({}, this.baseData), { url, id: uniqueId, method,
|
83
|
-
headers,
|
84
|
-
body, createTime: Date.now() }));
|
85
|
-
});
|
86
|
-
}
|
87
|
-
_res(uniqueId, id, response) {
|
88
|
-
var _a;
|
89
|
-
return __awaiter(this, void 0, void 0, function* () {
|
90
|
-
const body = yield response.text();
|
91
|
-
return (_a = this.server) === null || _a === void 0 ? void 0 : _a.network(Object.assign(Object.assign({}, this.baseData), { headers: (response === null || response === void 0 ? void 0 : response.headers)['map'], body, requestId: uniqueId !== null && uniqueId !== void 0 ? uniqueId : Number(id), statusCode: response === null || response === void 0 ? void 0 : response.status, endTime: Date.now() }));
|
92
|
-
});
|
93
|
-
}
|
94
|
-
resTimeout(uniqueId) {
|
95
|
-
var _a;
|
96
|
-
return __awaiter(this, void 0, void 0, function* () {
|
97
|
-
return (_a = this.server) === null || _a === void 0 ? void 0 : _a.network(Object.assign(Object.assign({}, this.baseData), { isTimeout: true, requestId: uniqueId }));
|
98
|
-
});
|
99
|
-
}
|
100
|
-
resResponseError(uniqueId) {
|
101
|
-
var _a;
|
102
|
-
return __awaiter(this, void 0, void 0, function* () {
|
103
|
-
return (_a = this.server) === null || _a === void 0 ? void 0 : _a.network(Object.assign(Object.assign({}, this.baseData), { isResponseError: true, requestId: uniqueId }));
|
104
|
-
});
|
105
|
-
}
|
106
|
-
uniqueRes(uniqueId, response) {
|
107
|
-
return __awaiter(this, void 0, void 0, function* () {
|
108
|
-
return this._res(uniqueId, undefined, response);
|
109
|
-
});
|
110
|
-
}
|
111
|
-
req(input, init) {
|
112
|
-
return __awaiter(this, void 0, void 0, function* () {
|
113
|
-
return this.uniqueReq(undefined, input, init);
|
114
|
-
});
|
115
|
-
}
|
116
|
-
res(id, response) {
|
117
|
-
return __awaiter(this, void 0, void 0, function* () {
|
118
|
-
return this._res(undefined, id, response);
|
119
|
-
});
|
120
|
-
}
|
121
|
-
}
|
122
|
-
exports.default = new Logger();
|
6
|
+
const logPlugin_1 = __importDefault(require("./src/logPlugin"));
|
7
|
+
exports.default = logPlugin_1.default;
|
123
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;AAAA,gEAAwC;AAExC,kBAAe,mBAAS,CAAC"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import NetworkRequestInfo from './NetworkRequestInfo';
|
2
|
+
import type { StartNetworkLoggingOptions } from './types';
|
3
|
+
export default class Logger {
|
4
|
+
private requests;
|
5
|
+
private xhrIdMap;
|
6
|
+
private maxRequests;
|
7
|
+
private refreshRate;
|
8
|
+
private latestRequestUpdatedAt;
|
9
|
+
private ignoredHosts;
|
10
|
+
private ignoredUrls;
|
11
|
+
private ignoredPatterns;
|
12
|
+
enabled: boolean;
|
13
|
+
paused: boolean;
|
14
|
+
callback: (_: NetworkRequestInfo[]) => void;
|
15
|
+
setCallback: (callback: any) => void;
|
16
|
+
debouncedCallback: () => void;
|
17
|
+
private getRequest;
|
18
|
+
private updateRequest;
|
19
|
+
private openCallback;
|
20
|
+
private requestHeadersCallback;
|
21
|
+
private headerReceivedCallback;
|
22
|
+
private sendCallback;
|
23
|
+
private responseCallback;
|
24
|
+
enableXHRInterception: (options?: StartNetworkLoggingOptions) => void;
|
25
|
+
getRequests: () => NetworkRequestInfo[];
|
26
|
+
clearRequests: () => void;
|
27
|
+
disableXHRInterception: () => void;
|
28
|
+
}
|
@@ -0,0 +1,192 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const XHRInterceptor_1 = __importDefault(require("react-native/Libraries/Network/XHRInterceptor"));
|
7
|
+
const NetworkRequestInfo_1 = __importDefault(require("./NetworkRequestInfo"));
|
8
|
+
const constant_1 = require("./constant");
|
9
|
+
const extractHost_1 = __importDefault(require("./utils/extractHost"));
|
10
|
+
const logger_1 = require("./utils/logger");
|
11
|
+
const debounce_1 = __importDefault(require("./utils/debounce"));
|
12
|
+
let nextXHRId = 0;
|
13
|
+
class Logger {
|
14
|
+
constructor() {
|
15
|
+
this.requests = [];
|
16
|
+
this.xhrIdMap = new Map();
|
17
|
+
this.maxRequests = constant_1.LOGGER_MAX_REQUESTS;
|
18
|
+
this.refreshRate = constant_1.LOGGER_REFRESH_RATE;
|
19
|
+
this.latestRequestUpdatedAt = 0;
|
20
|
+
this.enabled = false;
|
21
|
+
this.paused = false;
|
22
|
+
this.callback = (_) => null;
|
23
|
+
this.setCallback = (callback) => {
|
24
|
+
this.callback = callback;
|
25
|
+
};
|
26
|
+
this.debouncedCallback = (0, debounce_1.default)(() => {
|
27
|
+
if (!this.latestRequestUpdatedAt ||
|
28
|
+
this.requests.some(r => r.updatedAt > this.latestRequestUpdatedAt)) {
|
29
|
+
this.latestRequestUpdatedAt = Date.now();
|
30
|
+
this.callback([...this.requests]);
|
31
|
+
}
|
32
|
+
}, this.refreshRate);
|
33
|
+
this.getRequest = (xhrIndex) => {
|
34
|
+
if (xhrIndex === undefined) {
|
35
|
+
return undefined;
|
36
|
+
}
|
37
|
+
if (!this.xhrIdMap.has(xhrIndex)) {
|
38
|
+
return undefined;
|
39
|
+
}
|
40
|
+
const index = this.xhrIdMap.get(xhrIndex)();
|
41
|
+
return this.requests[index];
|
42
|
+
};
|
43
|
+
this.updateRequest = (index, update) => {
|
44
|
+
const networkInfo = this.getRequest(index);
|
45
|
+
if (!networkInfo) {
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
networkInfo.update(update);
|
49
|
+
};
|
50
|
+
this.openCallback = (method, url, xhr) => {
|
51
|
+
if (this.paused) {
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
if (this.ignoredHosts) {
|
55
|
+
const host = (0, extractHost_1.default)(url);
|
56
|
+
if (host && this.ignoredHosts.has(host)) {
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
if (this.ignoredUrls && this.ignoredUrls.has(url)) {
|
61
|
+
return;
|
62
|
+
}
|
63
|
+
if (this.ignoredPatterns) {
|
64
|
+
if (this.ignoredPatterns.some(pattern => pattern.test(`${method} ${url}`))) {
|
65
|
+
return;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
xhr._index = nextXHRId++;
|
69
|
+
this.xhrIdMap.set(xhr._index, () => {
|
70
|
+
return this.requests.findIndex(r => r.id === `${xhr._index}`);
|
71
|
+
});
|
72
|
+
const newRequest = new NetworkRequestInfo_1.default(`${xhr._index}`, 'XMLHttpRequest', method, url);
|
73
|
+
if (this.requests.length >= this.maxRequests) {
|
74
|
+
this.requests.pop();
|
75
|
+
}
|
76
|
+
this.requests.unshift(newRequest);
|
77
|
+
};
|
78
|
+
this.requestHeadersCallback = (header, value, xhr) => {
|
79
|
+
const networkInfo = this.getRequest(xhr._index);
|
80
|
+
if (!networkInfo) {
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
networkInfo.requestHeaders[header] = value;
|
84
|
+
};
|
85
|
+
this.headerReceivedCallback = (responseContentType, responseSize, responseHeaders, xhr) => {
|
86
|
+
this.updateRequest(xhr._index, {
|
87
|
+
responseContentType,
|
88
|
+
responseSize,
|
89
|
+
responseHeaders: xhr.responseHeaders,
|
90
|
+
});
|
91
|
+
};
|
92
|
+
this.sendCallback = (data, xhr) => {
|
93
|
+
this.updateRequest(xhr._index, {
|
94
|
+
startTime: Date.now(),
|
95
|
+
dataSent: data,
|
96
|
+
});
|
97
|
+
this.debouncedCallback();
|
98
|
+
};
|
99
|
+
this.responseCallback = (status, timeout, response, responseURL, responseType, xhr) => {
|
100
|
+
this.updateRequest(xhr._index, {
|
101
|
+
endTime: Date.now(),
|
102
|
+
status,
|
103
|
+
timeout,
|
104
|
+
response,
|
105
|
+
responseURL,
|
106
|
+
responseType,
|
107
|
+
});
|
108
|
+
this.debouncedCallback();
|
109
|
+
};
|
110
|
+
this.enableXHRInterception = (options) => {
|
111
|
+
if (this.enabled ||
|
112
|
+
(XHRInterceptor_1.default.isInterceptorEnabled() && !(options === null || options === void 0 ? void 0 : options.forceEnable))) {
|
113
|
+
if (!this.enabled) {
|
114
|
+
(0, logger_1.warn)('network interceptor has not been enabled as another interceptor is already running (e.g. another debugging program). Use option `forceEnable: true` to override this behaviour.');
|
115
|
+
}
|
116
|
+
return;
|
117
|
+
}
|
118
|
+
if ((options === null || options === void 0 ? void 0 : options.maxRequests) !== undefined) {
|
119
|
+
if (typeof options.maxRequests !== 'number' || options.maxRequests < 1) {
|
120
|
+
(0, logger_1.warn)('maxRequests must be a number greater than 0. The logger has not been started.');
|
121
|
+
return;
|
122
|
+
}
|
123
|
+
this.maxRequests = options.maxRequests;
|
124
|
+
}
|
125
|
+
if (options === null || options === void 0 ? void 0 : options.ignoredHosts) {
|
126
|
+
if (!Array.isArray(options.ignoredHosts) ||
|
127
|
+
typeof options.ignoredHosts[0] !== 'string') {
|
128
|
+
(0, logger_1.warn)('ignoredHosts must be an array of strings. The logger has not been started.');
|
129
|
+
return;
|
130
|
+
}
|
131
|
+
this.ignoredHosts = new Set(options.ignoredHosts);
|
132
|
+
}
|
133
|
+
if (options === null || options === void 0 ? void 0 : options.refreshRate) {
|
134
|
+
if (typeof options.refreshRate !== 'number' || options.refreshRate < 1) {
|
135
|
+
(0, logger_1.warn)('refreshRate must be a number greater than 0. The logger has not been started.');
|
136
|
+
return;
|
137
|
+
}
|
138
|
+
this.refreshRate = options.refreshRate;
|
139
|
+
}
|
140
|
+
if (options === null || options === void 0 ? void 0 : options.ignoredPatterns) {
|
141
|
+
this.ignoredPatterns = options.ignoredPatterns;
|
142
|
+
}
|
143
|
+
if (options === null || options === void 0 ? void 0 : options.ignoredUrls) {
|
144
|
+
if (!Array.isArray(options.ignoredUrls) ||
|
145
|
+
typeof options.ignoredUrls[0] !== 'string') {
|
146
|
+
(0, logger_1.warn)('ignoredUrls must be an array of strings. The logger has not been started.');
|
147
|
+
return;
|
148
|
+
}
|
149
|
+
this.ignoredUrls = new Set(options.ignoredUrls);
|
150
|
+
}
|
151
|
+
XHRInterceptor_1.default.setOpenCallback(this.openCallback);
|
152
|
+
XHRInterceptor_1.default.setRequestHeaderCallback(this.requestHeadersCallback);
|
153
|
+
XHRInterceptor_1.default.setHeaderReceivedCallback(this.headerReceivedCallback);
|
154
|
+
XHRInterceptor_1.default.setSendCallback(this.sendCallback);
|
155
|
+
XHRInterceptor_1.default.setResponseCallback(this.responseCallback);
|
156
|
+
XHRInterceptor_1.default.enableInterception();
|
157
|
+
this.enabled = true;
|
158
|
+
};
|
159
|
+
this.getRequests = () => {
|
160
|
+
return this.requests;
|
161
|
+
};
|
162
|
+
this.clearRequests = () => {
|
163
|
+
this.requests = [];
|
164
|
+
this.latestRequestUpdatedAt = 0;
|
165
|
+
this.debouncedCallback();
|
166
|
+
};
|
167
|
+
this.disableXHRInterception = () => {
|
168
|
+
if (!this.enabled) {
|
169
|
+
return;
|
170
|
+
}
|
171
|
+
this.clearRequests();
|
172
|
+
nextXHRId = 0;
|
173
|
+
this.enabled = false;
|
174
|
+
this.paused = false;
|
175
|
+
this.xhrIdMap.clear();
|
176
|
+
this.maxRequests = constant_1.LOGGER_MAX_REQUESTS;
|
177
|
+
this.refreshRate = constant_1.LOGGER_REFRESH_RATE;
|
178
|
+
this.ignoredHosts = undefined;
|
179
|
+
this.ignoredUrls = undefined;
|
180
|
+
this.ignoredPatterns = undefined;
|
181
|
+
const noop = () => null;
|
182
|
+
XHRInterceptor_1.default.setOpenCallback(noop);
|
183
|
+
XHRInterceptor_1.default.setRequestHeaderCallback(noop);
|
184
|
+
XHRInterceptor_1.default.setHeaderReceivedCallback(noop);
|
185
|
+
XHRInterceptor_1.default.setSendCallback(noop);
|
186
|
+
XHRInterceptor_1.default.setResponseCallback(noop);
|
187
|
+
XHRInterceptor_1.default.disableInterception();
|
188
|
+
};
|
189
|
+
}
|
190
|
+
}
|
191
|
+
exports.default = Logger;
|
192
|
+
//# sourceMappingURL=Logger.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../../packages/network-logger/Logger.ts"],"names":[],"mappings":";;;;;AACA,mGAA2E;AAC3E,8EAAsD;AAEtD,yCAAoE;AACpE,sEAA8C;AAC9C,2CAAoC;AACpC,gEAAwC;AAExC,IAAI,SAAS,GAAG,CAAC,C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C;CAAA;AAhQD,yBAgQC"}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import type { Headers, NetworkRequestInfoRow, RequestMethod } from './types';
|
2
|
+
export default class NetworkRequestInfo {
|
3
|
+
id: string;
|
4
|
+
type: string;
|
5
|
+
url: string;
|
6
|
+
method: RequestMethod;
|
7
|
+
status: number;
|
8
|
+
dataSent: string;
|
9
|
+
responseContentType: string;
|
10
|
+
responseSize: number;
|
11
|
+
requestHeaders: Headers;
|
12
|
+
responseHeaders: Headers;
|
13
|
+
response: string;
|
14
|
+
responseURL: string;
|
15
|
+
responseType: string;
|
16
|
+
timeout: number;
|
17
|
+
closeReason: string;
|
18
|
+
messages: string;
|
19
|
+
serverClose: any;
|
20
|
+
serverError: any;
|
21
|
+
startTime: number;
|
22
|
+
endTime: number;
|
23
|
+
gqlOperation?: string;
|
24
|
+
updatedAt: number;
|
25
|
+
constructor(id: string, type: string, method: RequestMethod, url: string);
|
26
|
+
get duration(): number;
|
27
|
+
get curlRequest(): string;
|
28
|
+
update(values: Partial<NetworkRequestInfo>): void;
|
29
|
+
private escapeQuotes;
|
30
|
+
private parseData;
|
31
|
+
private stringifyFormat;
|
32
|
+
toRow(): NetworkRequestInfoRow;
|
33
|
+
getRequestBody(replaceEscaped?: boolean): string;
|
34
|
+
private parseResponseBlob;
|
35
|
+
getResponseBody(): Promise<string>;
|
36
|
+
}
|