@wutiange/log-listener-plugin 1.3.0-alpha.0 → 1.3.0-alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +201 -201
- package/README.md +2 -2
- package/dist/server.d.ts +10 -0
- package/dist/server.js +45 -0
- package/dist/server.js.map +1 -0
- package/dist/src/HTTPInterceptor.d.ts +48 -0
- package/dist/src/HTTPInterceptor.js +202 -0
- package/dist/src/HTTPInterceptor.js.map +1 -0
- package/dist/src/logPlugin.d.ts +19 -20
- package/dist/src/logPlugin.js +108 -122
- package/dist/src/logPlugin.js.map +1 -1
- package/package.json +47 -47
- package/src/HTTPInterceptor.ts +319 -0
- package/src/__tests__/console.test.ts +25 -25
- package/src/common.ts +4 -4
- package/src/logPlugin.ts +238 -229
- package/src/server.ts +66 -66
- package/src/utils.ts +47 -47
- package/dist/packages/network-logger/Logger.d.ts +0 -28
- package/dist/packages/network-logger/Logger.js +0 -192
- package/dist/packages/network-logger/Logger.js.map +0 -1
- package/dist/packages/network-logger/NetworkRequestInfo.d.ts +0 -36
- package/dist/packages/network-logger/NetworkRequestInfo.js +0 -129
- package/dist/packages/network-logger/NetworkRequestInfo.js.map +0 -1
- package/dist/packages/network-logger/constant.d.ts +0 -2
- package/dist/packages/network-logger/constant.js +0 -6
- package/dist/packages/network-logger/constant.js.map +0 -1
- package/dist/packages/network-logger/types.d.ts +0 -14
- package/dist/packages/network-logger/types.js +0 -3
- package/dist/packages/network-logger/types.js.map +0 -1
- package/dist/packages/network-logger/utils/debounce.d.ts +0 -2
- package/dist/packages/network-logger/utils/debounce.js +0 -20
- package/dist/packages/network-logger/utils/debounce.js.map +0 -1
- package/dist/packages/network-logger/utils/extractHost.d.ts +0 -2
- package/dist/packages/network-logger/utils/extractHost.js +0 -9
- package/dist/packages/network-logger/utils/extractHost.js.map +0 -1
- package/dist/packages/network-logger/utils/fromEntries.d.ts +0 -2
- package/dist/packages/network-logger/utils/fromEntries.js +0 -8
- package/dist/packages/network-logger/utils/fromEntries.js.map +0 -1
- package/dist/packages/network-logger/utils/logger.d.ts +0 -1
- package/dist/packages/network-logger/utils/logger.js +0 -6
- package/dist/packages/network-logger/utils/logger.js.map +0 -1
- package/dist/src/CompatibilityManager.d.ts +0 -27
- package/dist/src/CompatibilityManager.js +0 -74
- package/dist/src/CompatibilityManager.js.map +0 -1
- package/dist/src/console.d.ts +0 -1
- package/dist/src/console.js +0 -20
- package/dist/src/console.js.map +0 -1
- package/dist/src/fetch.d.ts +0 -1
- package/dist/src/fetch.js +0 -48
- package/dist/src/fetch.js.map +0 -1
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.js +0 -8
- package/dist/src/index.js.map +0 -1
- package/packages/network-logger/Logger.ts +0 -274
- package/packages/network-logger/NetworkRequestInfo.ts +0 -133
- package/packages/network-logger/constant.ts +0 -3
- package/packages/network-logger/types.ts +0 -36
- package/packages/network-logger/utils/debounce.ts +0 -21
- package/packages/network-logger/utils/extractHost.ts +0 -7
- package/packages/network-logger/utils/fromEntries.ts +0 -7
- package/packages/network-logger/utils/logger.ts +0 -2
- package/src/CompatibilityManager.ts +0 -64
@@ -1,64 +0,0 @@
|
|
1
|
-
import NetworkRequestInfo from "../packages/network-logger/NetworkRequestInfo";
|
2
|
-
|
3
|
-
class CompatibilityManager {
|
4
|
-
private static requestInfoObj: Record<string, NetworkRequestInfo> = {}
|
5
|
-
static async interceptionToNetwork(data: NetworkRequestInfo[]) {
|
6
|
-
const tempWillSendArr: NetworkRequestInfo[] = []
|
7
|
-
if (Object.keys(CompatibilityManager.requestInfoObj).length === 0) {
|
8
|
-
CompatibilityManager.requestInfoObj = data.reduce((e, c) => {
|
9
|
-
if (c.endTime) {
|
10
|
-
return e
|
11
|
-
}
|
12
|
-
return {...e, [c.id]: c}
|
13
|
-
}, {})
|
14
|
-
tempWillSendArr.concat(data)
|
15
|
-
} else {
|
16
|
-
data.forEach(e => {
|
17
|
-
const tempObj = CompatibilityManager.requestInfoObj
|
18
|
-
if (!(e.id in tempObj)) {
|
19
|
-
tempWillSendArr.push(e)
|
20
|
-
if (!e.endTime) {
|
21
|
-
CompatibilityManager.requestInfoObj[e.id] = e
|
22
|
-
}
|
23
|
-
return
|
24
|
-
}
|
25
|
-
if (e.id in tempObj && e.endTime) {
|
26
|
-
tempWillSendArr.push(e)
|
27
|
-
delete CompatibilityManager.requestInfoObj[e.id]
|
28
|
-
return
|
29
|
-
}
|
30
|
-
})
|
31
|
-
}
|
32
|
-
|
33
|
-
// 将要发送的数据转换成兼容的数据
|
34
|
-
return CompatibilityManager.asyncSwapSendArr(tempWillSendArr)
|
35
|
-
}
|
36
|
-
|
37
|
-
private static async asyncSwapSendArr(data: NetworkRequestInfo[]) {
|
38
|
-
const asyncTempArr = await Promise.all(data.map(async (e) => {
|
39
|
-
if (e.endTime) {
|
40
|
-
return {
|
41
|
-
headers: e.responseHeaders,
|
42
|
-
body: await e.getResponseBody(),
|
43
|
-
requestId: e.id,
|
44
|
-
statusCode: e.status,
|
45
|
-
endTime: e.endTime,
|
46
|
-
};
|
47
|
-
} else {
|
48
|
-
return {
|
49
|
-
url: e.url,
|
50
|
-
id: e.id,
|
51
|
-
method: e.method,
|
52
|
-
headers: e.requestHeaders,
|
53
|
-
body: e.getRequestBody(),
|
54
|
-
createTime: e.startTime,
|
55
|
-
};
|
56
|
-
}
|
57
|
-
}));
|
58
|
-
|
59
|
-
return asyncTempArr;
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
|
-
|
64
|
-
export default CompatibilityManager
|