@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.
Files changed (63) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +2 -2
  3. package/dist/server.d.ts +10 -0
  4. package/dist/server.js +45 -0
  5. package/dist/server.js.map +1 -0
  6. package/dist/src/HTTPInterceptor.d.ts +48 -0
  7. package/dist/src/HTTPInterceptor.js +202 -0
  8. package/dist/src/HTTPInterceptor.js.map +1 -0
  9. package/dist/src/logPlugin.d.ts +19 -20
  10. package/dist/src/logPlugin.js +108 -122
  11. package/dist/src/logPlugin.js.map +1 -1
  12. package/package.json +47 -47
  13. package/src/HTTPInterceptor.ts +319 -0
  14. package/src/__tests__/console.test.ts +25 -25
  15. package/src/common.ts +4 -4
  16. package/src/logPlugin.ts +238 -229
  17. package/src/server.ts +66 -66
  18. package/src/utils.ts +47 -47
  19. package/dist/packages/network-logger/Logger.d.ts +0 -28
  20. package/dist/packages/network-logger/Logger.js +0 -192
  21. package/dist/packages/network-logger/Logger.js.map +0 -1
  22. package/dist/packages/network-logger/NetworkRequestInfo.d.ts +0 -36
  23. package/dist/packages/network-logger/NetworkRequestInfo.js +0 -129
  24. package/dist/packages/network-logger/NetworkRequestInfo.js.map +0 -1
  25. package/dist/packages/network-logger/constant.d.ts +0 -2
  26. package/dist/packages/network-logger/constant.js +0 -6
  27. package/dist/packages/network-logger/constant.js.map +0 -1
  28. package/dist/packages/network-logger/types.d.ts +0 -14
  29. package/dist/packages/network-logger/types.js +0 -3
  30. package/dist/packages/network-logger/types.js.map +0 -1
  31. package/dist/packages/network-logger/utils/debounce.d.ts +0 -2
  32. package/dist/packages/network-logger/utils/debounce.js +0 -20
  33. package/dist/packages/network-logger/utils/debounce.js.map +0 -1
  34. package/dist/packages/network-logger/utils/extractHost.d.ts +0 -2
  35. package/dist/packages/network-logger/utils/extractHost.js +0 -9
  36. package/dist/packages/network-logger/utils/extractHost.js.map +0 -1
  37. package/dist/packages/network-logger/utils/fromEntries.d.ts +0 -2
  38. package/dist/packages/network-logger/utils/fromEntries.js +0 -8
  39. package/dist/packages/network-logger/utils/fromEntries.js.map +0 -1
  40. package/dist/packages/network-logger/utils/logger.d.ts +0 -1
  41. package/dist/packages/network-logger/utils/logger.js +0 -6
  42. package/dist/packages/network-logger/utils/logger.js.map +0 -1
  43. package/dist/src/CompatibilityManager.d.ts +0 -27
  44. package/dist/src/CompatibilityManager.js +0 -74
  45. package/dist/src/CompatibilityManager.js.map +0 -1
  46. package/dist/src/console.d.ts +0 -1
  47. package/dist/src/console.js +0 -20
  48. package/dist/src/console.js.map +0 -1
  49. package/dist/src/fetch.d.ts +0 -1
  50. package/dist/src/fetch.js +0 -48
  51. package/dist/src/fetch.js.map +0 -1
  52. package/dist/src/index.d.ts +0 -2
  53. package/dist/src/index.js +0 -8
  54. package/dist/src/index.js.map +0 -1
  55. package/packages/network-logger/Logger.ts +0 -274
  56. package/packages/network-logger/NetworkRequestInfo.ts +0 -133
  57. package/packages/network-logger/constant.ts +0 -3
  58. package/packages/network-logger/types.ts +0 -36
  59. package/packages/network-logger/utils/debounce.ts +0 -21
  60. package/packages/network-logger/utils/extractHost.ts +0 -7
  61. package/packages/network-logger/utils/fromEntries.ts +0 -7
  62. package/packages/network-logger/utils/logger.ts +0 -2
  63. 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