@wutiange/log-listener-plugin 1.2.3 → 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
@@ -0,0 +1,129 @@
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const FileReader_1 = __importDefault(require("react-native/Libraries/Blob/FileReader"));
|
16
|
+
const fromEntries_1 = __importDefault(require("./utils/fromEntries"));
|
17
|
+
class NetworkRequestInfo {
|
18
|
+
constructor(id, type, method, url) {
|
19
|
+
this.id = '';
|
20
|
+
this.type = '';
|
21
|
+
this.url = '';
|
22
|
+
this.status = -1;
|
23
|
+
this.dataSent = '';
|
24
|
+
this.responseContentType = '';
|
25
|
+
this.responseSize = 0;
|
26
|
+
this.requestHeaders = {};
|
27
|
+
this.responseHeaders = {};
|
28
|
+
this.response = '';
|
29
|
+
this.responseURL = '';
|
30
|
+
this.responseType = '';
|
31
|
+
this.timeout = 0;
|
32
|
+
this.closeReason = '';
|
33
|
+
this.messages = '';
|
34
|
+
this.serverClose = undefined;
|
35
|
+
this.serverError = undefined;
|
36
|
+
this.startTime = 0;
|
37
|
+
this.endTime = 0;
|
38
|
+
this.updatedAt = 0;
|
39
|
+
this.id = id;
|
40
|
+
this.type = type;
|
41
|
+
this.method = method;
|
42
|
+
this.url = url;
|
43
|
+
this.updatedAt = Date.now();
|
44
|
+
}
|
45
|
+
get duration() {
|
46
|
+
return this.endTime - this.startTime;
|
47
|
+
}
|
48
|
+
get curlRequest() {
|
49
|
+
let headersPart = this.requestHeaders &&
|
50
|
+
Object.entries(this.requestHeaders)
|
51
|
+
.map(([key, value]) => `'${key}: ${this.escapeQuotes(value)}'`)
|
52
|
+
.join(' -H ');
|
53
|
+
headersPart = headersPart ? `-H ${headersPart}` : '';
|
54
|
+
const body = this.dataSent && this.escapeQuotes(this.dataSent);
|
55
|
+
const methodPart = this.method !== 'GET' ? `-X${this.method.toUpperCase()}` : '';
|
56
|
+
const bodyPart = body ? `-d '${body}'` : '';
|
57
|
+
const parts = ['curl', methodPart, headersPart, bodyPart, `'${this.url}'`];
|
58
|
+
return parts.filter(Boolean).join(' ');
|
59
|
+
}
|
60
|
+
update(values) {
|
61
|
+
Object.assign(this, values);
|
62
|
+
if (values.dataSent) {
|
63
|
+
const data = this.parseData(values.dataSent);
|
64
|
+
this.gqlOperation = data === null || data === void 0 ? void 0 : data.operationName;
|
65
|
+
}
|
66
|
+
this.updatedAt = Date.now();
|
67
|
+
}
|
68
|
+
escapeQuotes(value) {
|
69
|
+
var _a;
|
70
|
+
return (_a = value.replace) === null || _a === void 0 ? void 0 : _a.call(value, /'/g, "\\'");
|
71
|
+
}
|
72
|
+
parseData(data) {
|
73
|
+
var _a;
|
74
|
+
try {
|
75
|
+
if ((_a = data === null || data === void 0 ? void 0 : data._parts) === null || _a === void 0 ? void 0 : _a.length) {
|
76
|
+
return (0, fromEntries_1.default)(data === null || data === void 0 ? void 0 : data._parts);
|
77
|
+
}
|
78
|
+
return JSON.parse(data);
|
79
|
+
}
|
80
|
+
catch (e) {
|
81
|
+
return { data };
|
82
|
+
}
|
83
|
+
}
|
84
|
+
stringifyFormat(data) {
|
85
|
+
return JSON.stringify(this.parseData(data), null, 2);
|
86
|
+
}
|
87
|
+
toRow() {
|
88
|
+
return {
|
89
|
+
url: this.url,
|
90
|
+
gqlOperation: this.gqlOperation,
|
91
|
+
id: this.id,
|
92
|
+
method: this.method,
|
93
|
+
status: this.status,
|
94
|
+
duration: this.duration,
|
95
|
+
startTime: this.startTime,
|
96
|
+
};
|
97
|
+
}
|
98
|
+
getRequestBody(replaceEscaped = false) {
|
99
|
+
const body = this.stringifyFormat(this.dataSent);
|
100
|
+
if (replaceEscaped) {
|
101
|
+
return body.replace(/\\n/g, '\n').replace(/\\"/g, '"');
|
102
|
+
}
|
103
|
+
return body;
|
104
|
+
}
|
105
|
+
parseResponseBlob() {
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
107
|
+
const blobReader = new FileReader_1.default();
|
108
|
+
blobReader.readAsText(this.response);
|
109
|
+
return yield new Promise((resolve, reject) => {
|
110
|
+
const handleError = () => reject(blobReader.error);
|
111
|
+
blobReader.addEventListener('load', () => {
|
112
|
+
resolve(blobReader.result);
|
113
|
+
});
|
114
|
+
blobReader.addEventListener('error', handleError);
|
115
|
+
blobReader.addEventListener('abort', handleError);
|
116
|
+
});
|
117
|
+
});
|
118
|
+
}
|
119
|
+
getResponseBody() {
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
121
|
+
const body = yield (this.responseType !== 'blob'
|
122
|
+
? this.response
|
123
|
+
: this.parseResponseBlob());
|
124
|
+
return this.stringifyFormat(body);
|
125
|
+
});
|
126
|
+
}
|
127
|
+
}
|
128
|
+
exports.default = NetworkRequestInfo;
|
129
|
+
//# sourceMappingURL=NetworkRequestInfo.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"NetworkRequestInfo.js","sourceRoot":"","sources":["../../../packages/network-logger/NetworkRequestInfo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,wFAAoE;AAEpE,sEAA8C;AAE9C,MAAqB,kBAAkB;IAwBrC,YAAY,EAAU,EAAE,IAAY,EAAE,MAAqB,EAAE,GAAW;QAvBxE,OAAE,GAAG,EAAE,CAAC;QACR,SAAI,GAAG,EAAE,CAAC;QACV,QAAG,GAAG,EAAE,CAAC;QAET,WAAM,GAAW,CAAC,CAAC,CAAC;QACpB,aAAQ,GAAG,EAAE,CAAC;Q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,EAAE,GAAG,EAAE;oBACvC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBAC7B,CAAC,CAAC,CAAC;gBACH,UAAU,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;gBAClD,UAAU,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YACpD,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;IAEK,eAAe;;YACnB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,KAAK,MAAM;gBAC9C,CAAC,CAAC,IAAI,CAAC,QAAQ;gBACf,CAAC,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;YAE9B,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;KAAA;CACF;AA/HD,qCA+HC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../packages/network-logger/constant.ts"],"names":[],"mappings":";;;AACa,QAAA,mBAAmB,GAAW,GAAG,CAAC;AAClC,QAAA,mBAAmB,GAAW,EAAE,CAAC"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import NetworkRequestInfo from './NetworkRequestInfo';
|
2
|
+
export type Headers = {
|
3
|
+
[header: string]: string;
|
4
|
+
};
|
5
|
+
export type RequestMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
6
|
+
export type StartNetworkLoggingOptions = {
|
7
|
+
maxRequests?: number;
|
8
|
+
ignoredHosts?: string[];
|
9
|
+
ignoredUrls?: string[];
|
10
|
+
ignoredPatterns?: RegExp[];
|
11
|
+
forceEnable?: boolean;
|
12
|
+
refreshRate?: number;
|
13
|
+
};
|
14
|
+
export type NetworkRequestInfoRow = Pick<NetworkRequestInfo, 'url' | 'gqlOperation' | 'id' | 'method' | 'status' | 'duration' | 'startTime'>;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../packages/network-logger/types.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
function debounce(func, wait, immediate = false) {
|
4
|
+
let timeout;
|
5
|
+
return function () {
|
6
|
+
const args = arguments;
|
7
|
+
clearTimeout(timeout);
|
8
|
+
if (immediate && !timeout) {
|
9
|
+
func.apply(this, args);
|
10
|
+
}
|
11
|
+
timeout = setTimeout(function () {
|
12
|
+
timeout = undefined;
|
13
|
+
if (!immediate) {
|
14
|
+
func.apply(this, args);
|
15
|
+
}
|
16
|
+
}, wait);
|
17
|
+
};
|
18
|
+
}
|
19
|
+
exports.default = debounce;
|
20
|
+
//# sourceMappingURL=debounce.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"debounce.js","sourceRoot":"","sources":["../../../../packages/network-logger/utils/debounce.ts"],"names":[],"mappings":";;AACA,SAAS,QAAQ,CAAC,IAAc,EAAE,IAAY,EAAE,YAAqB,KAAK;IACxE,IAAI,OAAkD,CAAC;IACvD,OAAO;QACL,MAAM,IAAI,GAAG,SAAS,CAAC;QACvB,YAAY,CAAC,OAAO,CAAC,CAAC;QAEtB,IAAI,SAAS,IAAI,CAAC,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACzB,CAAC;QACD,OAAO,GAAG,UAAU,CAAC;YACnB,OAAO,GAAG,SAAS,CAAC;YAEpB,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACzB,CAAC;QACH,CAAC,EAAE,IAAI,CAAC,CAAC;IACX,CAAC,CAAC;AACJ,CAAC;AAED,kBAAe,QAAQ,CAAC"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const extractHost = (url) => {
|
4
|
+
var _a, _b;
|
5
|
+
const host = ((_b = (_a = url.split('//')[1]) === null || _a === void 0 ? void 0 : _a.split(':')[0]) === null || _b === void 0 ? void 0 : _b.split('/')[0]) || undefined;
|
6
|
+
return host;
|
7
|
+
};
|
8
|
+
exports.default = extractHost;
|
9
|
+
//# sourceMappingURL=extractHost.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"extractHost.js","sourceRoot":"","sources":["../../../../packages/network-logger/utils/extractHost.ts"],"names":[],"mappings":";;AAAA,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE;;IAClC,MAAM,IAAI,GAAG,CAAA,MAAA,MAAA,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,0CAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,0CAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,KAAI,SAAS,CAAC;IAE3E,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,kBAAe,WAAW,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"fromEntries.js","sourceRoot":"","sources":["../../../../packages/network-logger/utils/fromEntries.ts"],"names":[],"mappings":";;AAAA,MAAM,WAAW,GAAG,CAAC,GAAU,EAAE,EAAE,CACjC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;IACzB,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,OAAO,GAAG,CAAC;AACb,CAAC,EAAE,EAAE,CAAC,CAAC;AAET,kBAAe,WAAW,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const warn: (message: string) => void;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../packages/network-logger/utils/logger.ts"],"names":[],"mappings":";;;AAAO,MAAM,IAAI,GAAG,CAAC,OAAe,EAAE,EAAE,CACtC,OAAO,CAAC,IAAI,CAAC,gCAAgC,OAAO,EAAE,CAAC,CAAC;AAD7C,QAAA,IAAI,QACyC"}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import NetworkRequestInfo from "../packages/network-logger/NetworkRequestInfo";
|
2
|
+
declare class CompatibilityManager {
|
3
|
+
private static requestInfoObj;
|
4
|
+
static interceptionToNetwork(data: NetworkRequestInfo[]): Promise<({
|
5
|
+
headers: import("../packages/network-logger/types").Headers;
|
6
|
+
body: string;
|
7
|
+
requestId: string;
|
8
|
+
statusCode: number;
|
9
|
+
endTime: number;
|
10
|
+
url?: undefined;
|
11
|
+
id?: undefined;
|
12
|
+
method?: undefined;
|
13
|
+
createTime?: undefined;
|
14
|
+
} | {
|
15
|
+
url: string;
|
16
|
+
id: string;
|
17
|
+
method: import("../packages/network-logger/types").RequestMethod;
|
18
|
+
headers: import("../packages/network-logger/types").Headers;
|
19
|
+
body: string;
|
20
|
+
createTime: number;
|
21
|
+
requestId?: undefined;
|
22
|
+
statusCode?: undefined;
|
23
|
+
endTime?: undefined;
|
24
|
+
})[]>;
|
25
|
+
private static asyncSwapSendArr;
|
26
|
+
}
|
27
|
+
export default CompatibilityManager;
|
@@ -0,0 +1,74 @@
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
class CompatibilityManager {
|
13
|
+
static interceptionToNetwork(data) {
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
15
|
+
const tempWillSendArr = [];
|
16
|
+
if (Object.keys(CompatibilityManager.requestInfoObj).length === 0) {
|
17
|
+
CompatibilityManager.requestInfoObj = data.reduce((e, c) => {
|
18
|
+
if (c.endTime) {
|
19
|
+
return e;
|
20
|
+
}
|
21
|
+
return Object.assign(Object.assign({}, e), { [c.id]: c });
|
22
|
+
}, {});
|
23
|
+
tempWillSendArr.concat(data);
|
24
|
+
}
|
25
|
+
else {
|
26
|
+
data.forEach(e => {
|
27
|
+
const tempObj = CompatibilityManager.requestInfoObj;
|
28
|
+
if (!(e.id in tempObj)) {
|
29
|
+
tempWillSendArr.push(e);
|
30
|
+
if (!e.endTime) {
|
31
|
+
CompatibilityManager.requestInfoObj[e.id] = e;
|
32
|
+
}
|
33
|
+
return;
|
34
|
+
}
|
35
|
+
if (e.id in tempObj && e.endTime) {
|
36
|
+
tempWillSendArr.push(e);
|
37
|
+
delete CompatibilityManager.requestInfoObj[e.id];
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
});
|
41
|
+
}
|
42
|
+
return CompatibilityManager.asyncSwapSendArr(tempWillSendArr);
|
43
|
+
});
|
44
|
+
}
|
45
|
+
static asyncSwapSendArr(data) {
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
47
|
+
const asyncTempArr = yield Promise.all(data.map((e) => __awaiter(this, void 0, void 0, function* () {
|
48
|
+
if (e.endTime) {
|
49
|
+
return {
|
50
|
+
headers: e.responseHeaders,
|
51
|
+
body: yield e.getResponseBody(),
|
52
|
+
requestId: e.id,
|
53
|
+
statusCode: e.status,
|
54
|
+
endTime: e.endTime,
|
55
|
+
};
|
56
|
+
}
|
57
|
+
else {
|
58
|
+
return {
|
59
|
+
url: e.url,
|
60
|
+
id: e.id,
|
61
|
+
method: e.method,
|
62
|
+
headers: e.requestHeaders,
|
63
|
+
body: e.getRequestBody(),
|
64
|
+
createTime: e.startTime,
|
65
|
+
};
|
66
|
+
}
|
67
|
+
})));
|
68
|
+
return asyncTempArr;
|
69
|
+
});
|
70
|
+
}
|
71
|
+
}
|
72
|
+
CompatibilityManager.requestInfoObj = {};
|
73
|
+
exports.default = CompatibilityManager;
|
74
|
+
//# sourceMappingURL=CompatibilityManager.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"CompatibilityManager.js","sourceRoot":"","sources":["../../src/CompatibilityManager.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA,MAAM,oBAAoB;IAExB,MAAM,CAAO,qBAAqB,CAAC,IAA0B;;YAC3D,MAAM,eAAe,GAAyB,EAAE,CAAA;YAChD,IAAI,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAClE,oBAAoB,CAAC,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;oBACzD,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;wBACd,OAAO,CAAC,CAAA;oBACV,CAAC;oBACD,uCAAW,CAAC,KAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAC;gBAC1B,CAAC,EAAE,EAAE,CAAC,CAAA;gBACN,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YAC9B,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;oBACf,MAAM,OAAO,GAAG,oBAAoB,CAAC,cAAc,CAAA;oBACnD,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,EAAE,CAAC;wBACvB,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;wBACvB,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;4BACf,oBAAoB,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,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A"}
|
@@ -0,0 +1 @@
|
|
1
|
+
import '../../console';
|
@@ -3,8 +3,8 @@ 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
|
-
require("
|
7
|
-
const index_1 = __importDefault(require("
|
6
|
+
require("../../console");
|
7
|
+
const index_1 = __importDefault(require("../../index"));
|
8
8
|
describe("重写日志", () => {
|
9
9
|
it("log 没有提前设置 url", () => {
|
10
10
|
console.log("log 是否正常打印");
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"console.test.js","sourceRoot":"","sources":["../../../src/__tests__/console.test.ts"],"names":[],"mappings":";;;;;AAAA,yBAAsB;AACtB,wDAAgC;AAChC,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IACpB,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE;QACxB,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QACzB,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;QACvB,eAAM,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAA;QAC3C,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QACzB,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACd,eAAM,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAA;QAC3C,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;QAC3B,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;QACf,eAAM,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAA;QAC3C,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;QAC7B,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":";;;;AAAa,KAAqB,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,EAA9D,WAAG,UAAE,YAAI,UAAE,aAAK,SAA+C;AAGhE,QAAA,SAAS,GAAG,MAAM,CAAC,KAAqB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,20 @@
|
|
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 index_1 = __importDefault(require("./index"));
|
7
|
+
const common = require('./common');
|
8
|
+
console.log = (...data) => {
|
9
|
+
index_1.default.log(...data);
|
10
|
+
common.log(...data);
|
11
|
+
};
|
12
|
+
console.warn = (...data) => {
|
13
|
+
index_1.default.warn(...data);
|
14
|
+
common.warn(...data);
|
15
|
+
};
|
16
|
+
console.error = (...data) => {
|
17
|
+
index_1.default.error(...data);
|
18
|
+
common.error(...data);
|
19
|
+
};
|
20
|
+
//# sourceMappingURL=console.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"console.js","sourceRoot":"","sources":["../../src/console.ts"],"names":[],"mappings":";;;;;AAKA,oDAA6B;AAC7B,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,OAAO,CAAC,GAAG,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;IAC/B,eAAM,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,eAAM,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,eAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;IACtB,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;AACxB,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,48 @@
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const index_1 = __importDefault(require("./index"));
|
16
|
+
const utils_1 = require("./utils");
|
17
|
+
const common = require('./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);
|
29
|
+
}
|
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());
|
37
|
+
}
|
38
|
+
return response;
|
39
|
+
}
|
40
|
+
catch (error) {
|
41
|
+
isFetchFinished = true;
|
42
|
+
if (!isTimeout) {
|
43
|
+
index_1.default.resResponseError(uniqueId);
|
44
|
+
}
|
45
|
+
throw new Error(error);
|
46
|
+
}
|
47
|
+
});
|
48
|
+
//# sourceMappingURL=fetch.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/fetch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,oDAA6B;AAC7B,mCAA8B;AAE9B,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEnC,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"}
|
@@ -0,0 +1,8 @@
|
|
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 logPlugin_1 = __importDefault(require("./logPlugin"));
|
7
|
+
exports.default = logPlugin_1.default;
|
8
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,4DAAoC;AAEpC,kBAAe,mBAAS,CAAC"}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
declare class LogPlugin {
|
2
|
+
private server;
|
3
|
+
private baseData;
|
4
|
+
private timeout;
|
5
|
+
private networkLogger;
|
6
|
+
private host;
|
7
|
+
private isAuto;
|
8
|
+
auto(): void;
|
9
|
+
unAuto(): void;
|
10
|
+
startRecordLog(): void;
|
11
|
+
stopRecordLog(): void;
|
12
|
+
startRecordNetwork(): void;
|
13
|
+
setBaseUrl(url: string): void;
|
14
|
+
setTimeout(timeout: number): void;
|
15
|
+
getTimeout(): number;
|
16
|
+
setBaseData(data?: Record<string, any>): void;
|
17
|
+
private _log;
|
18
|
+
tag(tag: string, ...data: any[]): void;
|
19
|
+
log(...data: any[]): void;
|
20
|
+
warn(...data: any[]): void;
|
21
|
+
error(...data: any[]): void;
|
22
|
+
uniqueReq(uniqueId: string | undefined, input: RequestInfo | URL, init?: RequestInit): Promise<string>;
|
23
|
+
private _res;
|
24
|
+
resTimeout(uniqueId: string): Promise<string>;
|
25
|
+
resResponseError(uniqueId: string): Promise<string>;
|
26
|
+
uniqueRes(uniqueId: string, response?: Response): Promise<string>;
|
27
|
+
req(input: RequestInfo | URL, init?: RequestInit): Promise<string>;
|
28
|
+
res(id: number, response?: Response): Promise<string>;
|
29
|
+
}
|
30
|
+
declare const logPlugin: LogPlugin;
|
31
|
+
export { LogPlugin };
|
32
|
+
export default logPlugin;
|