react-native-xenon 0.1.0 → 0.2.0

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.
Files changed (132) hide show
  1. package/README.md +5 -5
  2. package/lib/commonjs/hooks/useConsoleInterceptor.js +3 -4
  3. package/lib/commonjs/hooks/useConsoleInterceptor.js.map +1 -1
  4. package/lib/commonjs/hooks/useNetworkInterceptor.js +26 -22
  5. package/lib/commonjs/hooks/useNetworkInterceptor.js.map +1 -1
  6. package/lib/commonjs/interceptors/FetchInterceptor.js +5 -2
  7. package/lib/commonjs/interceptors/FetchInterceptor.js.map +1 -1
  8. package/lib/commonjs/interceptors/WebSocketInterceptor.js +11 -4
  9. package/lib/commonjs/interceptors/WebSocketInterceptor.js.map +1 -1
  10. package/lib/commonjs/interceptors/XHRInterceptor.js +4 -1
  11. package/lib/commonjs/interceptors/XHRInterceptor.js.map +1 -1
  12. package/lib/commonjs/types/index.js +8 -8
  13. package/lib/commonjs/types/index.js.map +1 -1
  14. package/lib/commonjs/ui/Xenon.js +7 -5
  15. package/lib/commonjs/ui/Xenon.js.map +1 -1
  16. package/lib/commonjs/ui/components/details/NetworkRequestDetails.js +8 -5
  17. package/lib/commonjs/ui/components/details/NetworkRequestDetails.js.map +1 -1
  18. package/lib/commonjs/ui/components/headers/NetworkPanelHeader.js +11 -2
  19. package/lib/commonjs/ui/components/headers/NetworkPanelHeader.js.map +1 -1
  20. package/lib/commonjs/ui/components/index.js +2 -2
  21. package/lib/commonjs/ui/components/index.js.map +1 -1
  22. package/lib/commonjs/ui/components/items/NetworkPanelItem.js +12 -4
  23. package/lib/commonjs/ui/components/items/NetworkPanelItem.js.map +1 -1
  24. package/lib/commonjs/ui/components/panels/NetworkPanel.js +2 -1
  25. package/lib/commonjs/ui/components/panels/NetworkPanel.js.map +1 -1
  26. package/lib/commonjs/utils.js +7 -5
  27. package/lib/commonjs/utils.js.map +1 -1
  28. package/lib/module/hooks/useConsoleInterceptor.js +3 -4
  29. package/lib/module/hooks/useConsoleInterceptor.js.map +1 -1
  30. package/lib/module/hooks/useNetworkInterceptor.js +15 -11
  31. package/lib/module/hooks/useNetworkInterceptor.js.map +1 -1
  32. package/lib/module/interceptors/FetchInterceptor.js +6 -3
  33. package/lib/module/interceptors/FetchInterceptor.js.map +1 -1
  34. package/lib/module/interceptors/WebSocketInterceptor.js +11 -4
  35. package/lib/module/interceptors/WebSocketInterceptor.js.map +1 -1
  36. package/lib/module/interceptors/XHRInterceptor.js +4 -1
  37. package/lib/module/interceptors/XHRInterceptor.js.map +1 -1
  38. package/lib/module/types/index.js +1 -1
  39. package/lib/module/types/index.js.map +1 -1
  40. package/lib/module/ui/Xenon.js +7 -5
  41. package/lib/module/ui/Xenon.js.map +1 -1
  42. package/lib/module/ui/components/details/NetworkRequestDetails.js +9 -6
  43. package/lib/module/ui/components/details/NetworkRequestDetails.js.map +1 -1
  44. package/lib/module/ui/components/headers/NetworkPanelHeader.js +11 -2
  45. package/lib/module/ui/components/headers/NetworkPanelHeader.js.map +1 -1
  46. package/lib/module/ui/components/index.js +2 -2
  47. package/lib/module/ui/components/index.js.map +1 -1
  48. package/lib/module/ui/components/items/NetworkPanelItem.js +13 -5
  49. package/lib/module/ui/components/items/NetworkPanelItem.js.map +1 -1
  50. package/lib/module/ui/components/panels/NetworkPanel.js +2 -1
  51. package/lib/module/ui/components/panels/NetworkPanel.js.map +1 -1
  52. package/lib/module/utils.js +3 -2
  53. package/lib/module/utils.js.map +1 -1
  54. package/lib/typescript/commonjs/src/contexts/MainContext.d.ts +1 -1
  55. package/lib/typescript/commonjs/src/contexts/MainContext.d.ts.map +1 -1
  56. package/lib/typescript/commonjs/src/hooks/useConsoleInterceptor.d.ts +2 -2
  57. package/lib/typescript/commonjs/src/hooks/useConsoleInterceptor.d.ts.map +1 -1
  58. package/lib/typescript/commonjs/src/hooks/useNetworkInterceptor.d.ts +2 -2
  59. package/lib/typescript/commonjs/src/hooks/useNetworkInterceptor.d.ts.map +1 -1
  60. package/lib/typescript/commonjs/src/interceptors/FetchInterceptor.d.ts.map +1 -1
  61. package/lib/typescript/commonjs/src/interceptors/HttpInterceptor.d.ts +1 -1
  62. package/lib/typescript/commonjs/src/interceptors/WebSocketInterceptor.d.ts +3 -2
  63. package/lib/typescript/commonjs/src/interceptors/WebSocketInterceptor.d.ts.map +1 -1
  64. package/lib/typescript/commonjs/src/interceptors/XHRInterceptor.d.ts.map +1 -1
  65. package/lib/typescript/commonjs/src/types/common.d.ts +2 -0
  66. package/lib/typescript/commonjs/src/types/common.d.ts.map +1 -1
  67. package/lib/typescript/commonjs/src/types/http.d.ts +1 -2
  68. package/lib/typescript/commonjs/src/types/http.d.ts.map +1 -1
  69. package/lib/typescript/commonjs/src/types/index.d.ts +1 -1
  70. package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -1
  71. package/lib/typescript/commonjs/src/types/websocket.d.ts +6 -7
  72. package/lib/typescript/commonjs/src/types/websocket.d.ts.map +1 -1
  73. package/lib/typescript/commonjs/src/ui/Xenon.d.ts +2 -2
  74. package/lib/typescript/commonjs/src/ui/Xenon.d.ts.map +1 -1
  75. package/lib/typescript/commonjs/src/ui/components/details/NetworkRequestDetails.d.ts.map +1 -1
  76. package/lib/typescript/commonjs/src/ui/components/headers/NetworkPanelHeader.d.ts.map +1 -1
  77. package/lib/typescript/commonjs/src/ui/components/index.d.ts +2 -2
  78. package/lib/typescript/commonjs/src/ui/components/index.d.ts.map +1 -1
  79. package/lib/typescript/commonjs/src/ui/components/items/NetworkPanelItem.d.ts +5 -4
  80. package/lib/typescript/commonjs/src/ui/components/items/NetworkPanelItem.d.ts.map +1 -1
  81. package/lib/typescript/commonjs/src/ui/components/panels/NetworkPanel.d.ts.map +1 -1
  82. package/lib/typescript/commonjs/src/utils.d.ts +3 -2
  83. package/lib/typescript/commonjs/src/utils.d.ts.map +1 -1
  84. package/lib/typescript/module/src/contexts/MainContext.d.ts +1 -1
  85. package/lib/typescript/module/src/contexts/MainContext.d.ts.map +1 -1
  86. package/lib/typescript/module/src/hooks/useConsoleInterceptor.d.ts +2 -2
  87. package/lib/typescript/module/src/hooks/useConsoleInterceptor.d.ts.map +1 -1
  88. package/lib/typescript/module/src/hooks/useNetworkInterceptor.d.ts +2 -2
  89. package/lib/typescript/module/src/hooks/useNetworkInterceptor.d.ts.map +1 -1
  90. package/lib/typescript/module/src/interceptors/FetchInterceptor.d.ts.map +1 -1
  91. package/lib/typescript/module/src/interceptors/HttpInterceptor.d.ts +1 -1
  92. package/lib/typescript/module/src/interceptors/WebSocketInterceptor.d.ts +3 -2
  93. package/lib/typescript/module/src/interceptors/WebSocketInterceptor.d.ts.map +1 -1
  94. package/lib/typescript/module/src/interceptors/XHRInterceptor.d.ts.map +1 -1
  95. package/lib/typescript/module/src/types/common.d.ts +2 -0
  96. package/lib/typescript/module/src/types/common.d.ts.map +1 -1
  97. package/lib/typescript/module/src/types/http.d.ts +1 -2
  98. package/lib/typescript/module/src/types/http.d.ts.map +1 -1
  99. package/lib/typescript/module/src/types/index.d.ts +1 -1
  100. package/lib/typescript/module/src/types/index.d.ts.map +1 -1
  101. package/lib/typescript/module/src/types/websocket.d.ts +6 -7
  102. package/lib/typescript/module/src/types/websocket.d.ts.map +1 -1
  103. package/lib/typescript/module/src/ui/Xenon.d.ts +2 -2
  104. package/lib/typescript/module/src/ui/Xenon.d.ts.map +1 -1
  105. package/lib/typescript/module/src/ui/components/details/NetworkRequestDetails.d.ts.map +1 -1
  106. package/lib/typescript/module/src/ui/components/headers/NetworkPanelHeader.d.ts.map +1 -1
  107. package/lib/typescript/module/src/ui/components/index.d.ts +2 -2
  108. package/lib/typescript/module/src/ui/components/index.d.ts.map +1 -1
  109. package/lib/typescript/module/src/ui/components/items/NetworkPanelItem.d.ts +5 -4
  110. package/lib/typescript/module/src/ui/components/items/NetworkPanelItem.d.ts.map +1 -1
  111. package/lib/typescript/module/src/ui/components/panels/NetworkPanel.d.ts.map +1 -1
  112. package/lib/typescript/module/src/utils.d.ts +3 -2
  113. package/lib/typescript/module/src/utils.d.ts.map +1 -1
  114. package/package.json +1 -1
  115. package/src/contexts/MainContext.ts +1 -1
  116. package/src/global.d.ts +4 -4
  117. package/src/hooks/useConsoleInterceptor.ts +2 -4
  118. package/src/hooks/useNetworkInterceptor.ts +16 -10
  119. package/src/interceptors/FetchInterceptor.ts +6 -2
  120. package/src/interceptors/WebSocketInterceptor.ts +13 -4
  121. package/src/interceptors/XHRInterceptor.ts +6 -0
  122. package/src/types/common.ts +2 -0
  123. package/src/types/http.ts +1 -1
  124. package/src/types/index.ts +1 -1
  125. package/src/types/websocket.ts +6 -11
  126. package/src/ui/Xenon.tsx +9 -7
  127. package/src/ui/components/details/NetworkRequestDetails.tsx +19 -8
  128. package/src/ui/components/headers/NetworkPanelHeader.tsx +10 -2
  129. package/src/ui/components/index.ts +2 -2
  130. package/src/ui/components/items/NetworkPanelItem.tsx +25 -8
  131. package/src/ui/components/panels/NetworkPanel.tsx +2 -1
  132. package/src/utils.ts +5 -2
@@ -2,8 +2,9 @@ import type { HttpRequest } from './types';
2
2
  export declare const limitChar: (value: any, limit?: number) => string;
3
3
  export declare const getHttpInterceptorId: () => string;
4
4
  export declare const keyValueToString: (key: string, value: any) => string;
5
- export declare const formatMethod: (method?: string) => string;
6
- export declare const formatStatusCode: (statusCode?: number) => string;
5
+ export declare const formatRequestMethod: (method?: string) => string;
6
+ export declare const formatRequestDuration: (duration?: number) => string;
7
+ export declare const formatRequestStatusCode: (statusCode?: number) => string;
7
8
  export declare const formatLogMessage: (type: string, values: any[]) => string;
8
9
  export declare const convertToCurl: (method: HttpRequest["method"], url: HttpRequest["url"], headers: HttpRequest["requestHeaders"], body: HttpRequest["body"]) => string;
9
10
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,SAAS,UAAW,GAAG,2BAMnC,CAAC;AAEF,eAAO,MAAM,oBAAoB,cAIhC,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAS,MAAM,SAAS,GAAG,KAAG,MAC1B,CAAC;AAElC,eAAO,MAAM,YAAY,YAAa,MAAM,WAAoB,CAAC;AAEjE,eAAO,MAAM,gBAAgB,gBAAiB,MAAM,WAAiC,CAAC;AAEtF,eAAO,MAAM,gBAAgB,SAAU,MAAM,UAAU,GAAG,EAAE,WAQ3D,CAAC;AAEF,eAAO,MAAM,aAAa,WAChB,WAAW,CAAC,QAAQ,CAAC,OACxB,WAAW,CAAC,KAAK,CAAC,WACd,WAAW,CAAC,gBAAgB,CAAC,QAChC,WAAW,CAAC,MAAM,CAAC,WAgB1B,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,SAAS,UAAW,GAAG,2BAMnC,CAAC;AAEF,eAAO,MAAM,oBAAoB,cAIhC,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAS,MAAM,SAAS,GAAG,KAAG,MAC1B,CAAC;AAElC,eAAO,MAAM,mBAAmB,YAAa,MAAM,WAAoB,CAAC;AAExE,eAAO,MAAM,qBAAqB,cAAe,MAAM,WACf,CAAC;AAEzC,eAAO,MAAM,uBAAuB,gBAAiB,MAAM,WAAiC,CAAC;AAE7F,eAAO,MAAM,gBAAgB,SAAU,MAAM,UAAU,GAAG,EAAE,WAQ3D,CAAC;AAEF,eAAO,MAAM,aAAa,WAChB,WAAW,CAAC,QAAQ,CAAC,OACxB,WAAW,CAAC,KAAK,CAAC,WACd,WAAW,CAAC,gBAAgB,CAAC,QAChC,WAAW,CAAC,MAAM,CAAC,WAgB1B,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { type MutableRefObject } from 'react';
2
2
  import type { useConsoleInterceptor, useNetworkInterceptor } from '../hooks';
3
- import type { HttpRequest, DebuggerPanel, DebuggerPosition, DebuggerVisibility, LogMessage, SetState, WebSocketRequest } from '../types';
3
+ import type { DebuggerPanel, DebuggerPosition, DebuggerVisibility, HttpRequest, LogMessage, SetState, WebSocketRequest } from '../types';
4
4
  export interface MainContextValue {
5
5
  debuggerVisibility: DebuggerVisibility;
6
6
  setDebuggerVisibility: SetState<DebuggerVisibility>;
@@ -1 +1 @@
1
- {"version":3,"file":"MainContext.d.ts","sourceRoot":"","sources":["../../../../../src/contexts/MainContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,QAAQ,EACR,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,qBAAqB,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IACpD,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,mBAAmB,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IAChD,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,gBAAgB,EAAE,QAAQ,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IACjD,kBAAkB,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;IAC7D,cAAc,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;IACzD,WAAW,EAAE,gBAAgB,CACzB;QAAE,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,UAAU,CAAA;KAAE,GACvC;QAAE,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,gBAAgB,CAA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AkB,EAAE,MAAM,CAAC;CAC5B;AAED,QAAA,MAAM,WAAW,kDAA+C,CAAC;AAEjE,eAAe,WAAW,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import type { LogMessage } from '../types';
2
2
  interface ConsoleInterceptorParams {
3
- autoEnabled?: boolean;
3
+ autoEnabled: boolean;
4
4
  }
5
- export default function useConsoleInterceptor(params: ConsoleInterceptorParams): {
5
+ export default function useConsoleInterceptor({ autoEnabled }: ConsoleInterceptorParams): {
6
6
  isInterceptorEnabled: boolean;
7
7
  enableInterception: () => void;
8
8
  disableInterception: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"useConsoleInterceptor.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/useConsoleInterceptor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,UAAU,wBAAwB;IAChC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,MAAM,EAAE,wBAAwB;;;;;;EAgD7E"}
1
+ {"version":3,"file":"useConsoleInterceptor.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/useConsoleInterceptor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,UAAU,wBAAwB;IAChC,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAAE,WAAW,EAAE,EAAE,wBAAwB;;;;;;EA8CtF"}
@@ -1,7 +1,7 @@
1
1
  interface NetworkInterceptorParams {
2
- autoEnabled?: boolean;
2
+ autoEnabled: boolean;
3
3
  }
4
- export default function useNetworkInterceptor(params?: NetworkInterceptorParams): {
4
+ export default function useNetworkInterceptor({ autoEnabled }: NetworkInterceptorParams): {
5
5
  isInterceptorEnabled: boolean;
6
6
  enableInterception: () => void;
7
7
  disableInterception: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"useNetworkInterceptor.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/useNetworkInterceptor.ts"],"names":[],"mappings":"AAyBA,UAAU,wBAAwB;IAChC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAQD,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,MAAM,CAAC,EAAE,wBAAwB;;;;;;EAmO9E"}
1
+ {"version":3,"file":"useNetworkInterceptor.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/useNetworkInterceptor.ts"],"names":[],"mappings":"AAwBA,UAAU,wBAAwB;IAChC,WAAW,EAAE,OAAO,CAAC;CACtB;AAMD,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAAE,WAAW,EAAE,EAAE,wBAAwB;;;;;;EA4OtF"}
@@ -1 +1 @@
1
- {"version":3,"file":"FetchInterceptor.d.ts","sourceRoot":"","sources":["../../../../../src/interceptors/FetchInterceptor.ts"],"names":[],"mappings":"AAGA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAIhD,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,eAAe;IAC3D,MAAM,CAAC,QAAQ,mBAA0B;IAEzC,OAAO;IAIP,kBAAkB;IA8GlB,mBAAmB;CASpB"}
1
+ {"version":3,"file":"FetchInterceptor.d.ts","sourceRoot":"","sources":["../../../../../src/interceptors/FetchInterceptor.ts"],"names":[],"mappings":"AAGA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAIhD,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,eAAe;IAC3D,MAAM,CAAC,QAAQ,mBAA0B;IAEzC,OAAO;IAIP,kBAAkB;IAkHlB,mBAAmB;CASpB"}
@@ -16,7 +16,7 @@ export default abstract class HttpInterceptor extends NetworkInterceptor {
16
16
  requestHeaderCallback: ((id: import("../types").ID, header: string, value: string) => void) | undefined;
17
17
  sendCallback: ((id: import("../types").ID, data?: any) => void) | undefined;
18
18
  headerReceivedCallback: ((id: import("../types").ID, responseContentType: string | undefined, responseSize: number | undefined, responseHeaders: string) => void) | undefined;
19
- responseCallback: ((id: import("../types").ID, status: number | undefined, timeout: number | undefined, response: any, responseURL: string | undefined, responseType: string | undefined) => void) | undefined;
19
+ responseCallback: ((id: import("../types").ID, status: number | undefined, timeout: number | undefined, duration: number, response: any, responseURL: string | undefined, responseType: string | undefined) => void) | undefined;
20
20
  };
21
21
  protected clearCallbacks(): void;
22
22
  }
@@ -17,14 +17,15 @@ export default class WebSocketInterceptor extends NetworkInterceptor {
17
17
  setOnErrorCallback(callback: typeof this.onErrorCallback): this;
18
18
  setOnCloseCallback(callback: typeof this.onCloseCallback): this;
19
19
  protected getCallbacks(): {
20
- connectCallback: ((uri: import("../types").WebSocketRequest["uri"], protocols?: import("../types").WebSocketRequest["protocols"], options?: import("../types").WebSocketRequest["options"], socketId?: number) => void) | undefined;
20
+ connectCallback: ((url: string, protocols?: import("../types").WebSocketRequest["protocols"], options?: import("../types").WebSocketRequest["options"], socketId?: number) => void) | undefined;
21
21
  sendCallback: ((data: string, socketId: number) => void) | undefined;
22
- closeCallback: ((code: import("../types").WebSocketRequest["status"], reason: import("../types").WebSocketRequest["closeReason"], socketId: number) => void) | undefined;
22
+ closeCallback: ((code: number, reason: string, socketId: number) => void) | undefined;
23
23
  arrayBufferToString: (data?: string) => string;
24
24
  };
25
25
  protected clearCallbacks(): void;
26
26
  private eventEmitter;
27
27
  private subscriptions;
28
+ private timeStart;
28
29
  private arrayBufferToString;
29
30
  private registerEvents;
30
31
  private unregisterEvents;
@@ -1 +1 @@
1
- {"version":3,"file":"WebSocketInterceptor.d.ts","sourceRoot":"","sources":["../../../../../src/interceptors/WebSocketInterceptor.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAO1D,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,kBAAkB;IAClE,MAAM,CAAC,QAAQ,uBAA8B;IAE7C,OAAO;IAIP,OAAO,CA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nD,OAAO,CAAC,aAAa,CAAgC;IACrD,OAAO,CAAC,cAAc,CAAiC;IACvD,OAAO,CAAC,iBAAiB,CAAoC;IAC7D,OAAO,CAAC,eAAe,CAAkC;IACzD,OAAO,CAAC,eAAe,CAAkC;IAEzD,kBAAkB,CAAC,QAAQ,EAAE,OAAO,IAAI,CAAC,eAAe;IAKxD,eAAe,CAAC,QAAQ,EAAE,OAAO,IAAI,CAAC,YAAY;IAKlD,gBAAgB,CAAC,QAAQ,EAAE,OAAO,IAAI,CAAC,aAAa;IAKpD,iBAAiB,CAAC,QAAQ,EAAE,OAAO,IAAI,CAAC,cAAc;IAKtD,oBAAoB,CAAC,QAAQ,EAAE,OAAO,IAAI,CAAC,iBAAiB;IAK5D,kBAAkB,CAAC,QAAQ,EAAE,OAAO,IAAI,CAAC,eAAe;IAKxD,kBAAkB,CAAC,QAAQ,EAAE,OAAO,IAAI,CAAC,eAAe;IAKxD,SAAS,CAAC,YAAY;;;;qCA4Ba,MAAM;;IAdzC,SAAS,CAAC,cAAc,IAAI,IAAI;IAUhC,OAAO,CAAC,YAAY,CAAmC;IACvD,OAAO,CAAC,aAAa,CAA6B;IAClD,OAAO,CAAC,SAAS,CAAkC;IAEnD,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,cAAc;IA2BtB,OAAO,CAAC,gBAAgB;IAMxB,kBAAkB,IAAI,IAAI;IAwC1B,mBAAmB,IAAI,IAAI;CAc5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"XHRInterceptor.d.ts","sourceRoot":"","sources":["../../../../../src/interceptors/XHRInterceptor.ts"],"names":[],"mappings":"AAEA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAMhD,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,eAAe;IACzD,MAAM,CAAC,QAAQ,iBAAwB;IAEvC,OAAO;IAIP,kBAAkB;IAsElB,mBAAmB;CAWpB"}
1
+ {"version":3,"file":"XHRInterceptor.d.ts","sourceRoot":"","sources":["../../../../../src/interceptors/XHRInterceptor.ts"],"names":[],"mappings":"AAEA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAMhD,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,eAAe;IACzD,MAAM,CAAC,QAAQ,iBAAwB;IAEvC,OAAO;IAIP,kBAAkB;IA4ElB,mBAAmB;CAWpB"}
@@ -10,7 +10,9 @@ export declare enum DebuggerPanel {
10
10
  }
11
11
  export type ID = string | undefined;
12
12
  export interface NetworkRequest {
13
+ url: string;
13
14
  status?: number;
15
+ duration?: number;
14
16
  }
15
17
  export type DebuggerVisibility = 'hidden' | 'bubble' | 'panel';
16
18
  export type DebuggerPosition = 'top' | 'bottom';
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/types/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEtD,oBAAY,WAAW;IACrB,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,EAAE,OAAO;CACV;AAED,oBAAY,aAAa;IACvB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED,MAAM,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC;AAEpC,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE/D,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEhD,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAEtD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,uBAAuB,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/types/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEtD,oBAAY,WAAW;IACrB,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,EAAE,OAAO;CACV;AAED,oBAAY,aAAa;IACvB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED,MAAM,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC;AAEpC,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE/D,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEhD,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAEtD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,uBAAuB,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC"}
@@ -2,7 +2,6 @@ import type { ID, NetworkRequest, NetworkType } from './common';
2
2
  export interface HttpRequest extends NetworkRequest {
3
3
  type: NetworkType.Fetch | NetworkType.XHR;
4
4
  method: string;
5
- url: string;
6
5
  requestHeaders?: Record<string, string>;
7
6
  requestHeadersString?: string;
8
7
  body?: any;
@@ -17,5 +16,5 @@ export type HttpOpenCallback = ((id: ID, type: HttpRequest['type'], method: stri
17
16
  export type HttpRequestHeaderCallback = ((id: ID, header: string, value: string) => void) | null;
18
17
  export type HttpSendCallback = ((id: ID, data?: any) => void) | null;
19
18
  export type HttpHeaderReceivedCallback = ((id: ID, responseContentType: string | undefined, responseSize: number | undefined, responseHeaders: string) => void) | null;
20
- export type HttpResponseCallback = ((id: ID, status: number | undefined, timeout: number | undefined, response: any, responseURL: string | undefined, responseType: string | undefined) => void) | null;
19
+ export type HttpResponseCallback = ((id: ID, status: number | undefined, timeout: number | undefined, duration: number, response: any, responseURL: string | undefined, responseType: string | undefined) => void) | null;
21
20
  //# sourceMappingURL=http.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/types/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEhE,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD,IAAI,EAAE,WAAW,CAAC,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,gBAAgB,GACxB,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC,GAC1E,IAAI,CAAC;AAET,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;AAEjG,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,CA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AE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC,GAC1E,IAAI,CAAC;AAET,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;AAEjG,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;AAErE,MAAM,MAAM,0BAA0B,GAClC,CAAC,CACC,EAAE,EAAE,EAAE,EACN,mBAAmB,EAAE,MAAM,GAAG,SAAS,EACvC,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,eAAe,EAAE,MAAM,KACpB,IAAI,CAAC,GACV,IAAI,CAAC;AAET,MAAM,MAAM,oBAAoB,GAC5B,CAAC,CACC,EAAE,EAAE,EAAE,EACN,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,GAAG,EACb,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,YAAY,EAAE,MAAM,GAAG,SAAS,KAC7B,IAAI,CAAC,GACV,IAAI,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export * from './common';
2
- export * from './http';
3
2
  export * from './console';
3
+ export * from './http';
4
4
  export * from './websocket';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
@@ -1,14 +1,13 @@
1
1
  import type { NetworkRequest, NetworkType } from './common';
2
2
  export interface WebSocketRequest extends NetworkRequest {
3
3
  type: NetworkType.WS;
4
- uri: string;
5
- protocols?: string | string[] | null;
4
+ protocols?: string | string[];
6
5
  options?: {
7
6
  headers: {
8
7
  [headerName: string]: string;
9
8
  };
10
9
  [optionName: string]: any;
11
- } | null;
10
+ };
12
11
  messages?: string;
13
12
  closeReason?: string;
14
13
  serverError?: {
@@ -19,11 +18,11 @@ export interface WebSocketRequest extends NetworkRequest {
19
18
  reason?: string;
20
19
  };
21
20
  }
22
- export type WebSocketConnectCallback = ((uri: WebSocketRequest['uri'], protocols?: WebSocketRequest['protocols'], options?: WebSocketRequest['options'], socketId?: number) => void) | null;
21
+ export type WebSocketConnectCallback = ((url: string, protocols?: WebSocketRequest['protocols'], options?: WebSocketRequest['options'], socketId?: number) => void) | null;
23
22
  export type WebSocketSendCallback = ((data: string, socketId: number) => void) | null;
24
- export type WebSocketCloseCallback = ((code: WebSocketRequest['status'], reason: WebSocketRequest['closeReason'], socketId: number) => void) | null;
25
- export type WebSocketOnOpenCallback = ((socketId: number) => void) | null;
23
+ export type WebSocketCloseCallback = ((code: number, reason: string, socketId: number) => void) | null;
24
+ export type WebSocketOnOpenCallback = ((socketId: number, duration: number) => void) | null;
26
25
  export type WebSocketOnMessageCallback = ((socketId: number, message: any) => void) | null;
27
- export type WebSocketOnErrorCallback = ((socketId: number, data: WebSocketRequest['serverError']) => void) | null;
26
+ export type WebSocketOnErrorCallback = ((socketId: number, error: WebSocketRequest['serverError']) => void) | null;
28
27
  export type WebSocketOnCloseCallback = ((socketId: number, data: WebSocketRequest['serverClose']) => void) | null;
29
28
  //# sourceMappingURL=websocket.d.ts.map
@@ -1 +1 @@
1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
+ autoInspectNetworkEnabled?: boolean;
8
+ autoInspectConsoleEnabled?: boolean;
9
9
  bubbleSize?: number;
10
10
  }
11
11
  interface ReactNativeXenon extends XenonComponentMethods {
@@ -1 +1 @@
1
- {"version":3,"file":"Xenon.d.ts","sourceRoot":"","sources":["../../../../../src/ui/Xenon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoD,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAOnF,UAAU,qBAAqB;IAC7B,IAAI,IAAI,IAAI,CAAC;IACb,IAAI,IAAI,IAAI,CAAC;CACd;AAED,UAAU,mBAAmB;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,gBAAiB,SAAQ,qBAAqB;IACtD,SAAS,CAAC,KAAK,EAAE,mBAAmB,GAAG,GAAG,CAAC,OAAO,CAAC;CACpD;AAsHD,QAAA,MAAM,KAAK,EAAE,gBAQZ,CAAC;AAEF,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"Xenon.d.ts","sourceRoot":"","sources":["../../../../../src/ui/Xenon.tsx"],"names":[],"mappings":"AACA,OAAO,EAAoD,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAOnF,UAAU,qBAAqB;IAC7B,IAAI,IAAI,IAAI,CAAC;IACb,IAAI,IAAI,IAAI,CAAC;CACd;AAED,UAAU,mBAAmB;IAC3B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,gBAAiB,SAAQ,qBAAqB;IACtD,SAAS,CAAC,KAAK,EAAE,mBAAmB,GAAG,GAAG,CAAC,OAAO,CAAC;CACpD;AAuHD,QAAA,MAAM,KAAK,EAAE,gBAQZ,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkRequestDetails.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/details/NetworkRequestDetails.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAKxB,UAAU,0BAA0B;IAClC,IAAI,EAAE,WAAW,GAAG,gBAAgB,CAAC;CACtC;AAED,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAAE,IAAI,EAAE,EAAE,0BAA0B,2CAsGjF"}
1
+ {"version":3,"file":"NetworkRequestDetails.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/details/NetworkRequestDetails.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAWxB,UAAU,0BAA0B;IAClC,IAAI,EAAE,WAAW,GAAG,gBAAgB,CAAC;CACtC;AAED,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAAE,IAAI,EAAE,EAAE,0BAA0B,2CA2GjF"}
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkPanelHeader.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/headers/NetworkPanelHeader.tsx"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,kBAAkB,4CA0BzC"}
1
+ {"version":3,"file":"NetworkPanelHeader.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/headers/NetworkPanelHeader.tsx"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,kBAAkB,4CAkCzC"}
@@ -1,6 +1,6 @@
1
1
  export { default as Bubble } from './bubble/Bubble';
2
+ export { default as DetailsViewer } from './details/DetailsViewer';
2
3
  export { default as DebuggerHeader } from './headers/DebuggerHeader';
3
- export { default as NetworkPanel } from './panels/NetworkPanel';
4
4
  export { default as ConsolePanel } from './panels/ConsolePanel';
5
- export { default as DetailsViewer } from './details/DetailsViewer';
5
+ export { default as NetworkPanel } from './panels/NetworkPanel';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1,10 +1,11 @@
1
- import type { HttpRequest, WebSocketRequest } from '../../../types';
1
+ import type { HttpRequest, NetworkRequest } from '../../../types';
2
2
  interface NetworkPanelItemProps {
3
- name: HttpRequest['url'] | WebSocketRequest['uri'];
4
3
  method?: HttpRequest['method'];
5
- status?: HttpRequest['status'] | WebSocketRequest['status'];
4
+ name: NetworkRequest['url'];
5
+ duration?: NetworkRequest['duration'];
6
+ status?: NetworkRequest['status'];
6
7
  onPress: () => void;
7
8
  }
8
- export default function NetworkPanelItem({ name, status, method, onPress }: NetworkPanelItemProps): import("react/jsx-runtime").JSX.Element;
9
+ export default function NetworkPanelItem({ method, name, duration, status, onPress, }: NetworkPanelItemProps): import("react/jsx-runtime").JSX.Element;
9
10
  export {};
10
11
  //# sourceMappingURL=NetworkPanelItem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkPanelItem.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/items/NetworkPanelItem.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGpE,UAAU,qBAAqB;IAC7B,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACnD,MAAM,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC5D,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,qBAAqB,2CAoChG"}
1
+ {"version":3,"file":"NetworkPanelItem.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/items/NetworkPanelItem.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAOlE,UAAU,qBAAqB;IAC7B,MAAM,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC/B,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;IAC5B,QAAQ,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IACtC,MAAM,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;IAClC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,OAAO,GACR,EAAE,qBAAqB,2CA0CvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkPanel.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/panels/NetworkPanel.tsx"],"names":[],"mappings":"AAUA,MAAM,CAAC,OAAO,UAAU,YAAY,4CA0CnC"}
1
+ {"version":3,"file":"NetworkPanel.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/panels/NetworkPanel.tsx"],"names":[],"mappings":"AAUA,MAAM,CAAC,OAAO,UAAU,YAAY,4CA2CnC"}
@@ -2,8 +2,9 @@ import type { HttpRequest } from './types';
2
2
  export declare const limitChar: (value: any, limit?: number) => string;
3
3
  export declare const getHttpInterceptorId: () => string;
4
4
  export declare const keyValueToString: (key: string, value: any) => string;
5
- export declare const formatMethod: (method?: string) => string;
6
- export declare const formatStatusCode: (statusCode?: number) => string;
5
+ export declare const formatRequestMethod: (method?: string) => string;
6
+ export declare const formatRequestDuration: (duration?: number) => string;
7
+ export declare const formatRequestStatusCode: (statusCode?: number) => string;
7
8
  export declare const formatLogMessage: (type: string, values: any[]) => string;
8
9
  export declare const convertToCurl: (method: HttpRequest["method"], url: HttpRequest["url"], headers: HttpRequest["requestHeaders"], body: HttpRequest["body"]) => string;
9
10
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,SAAS,UAAW,GAAG,2BAMnC,CAAC;AAEF,eAAO,MAAM,oBAAoB,cAIhC,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAS,MAAM,SAAS,GAAG,KAAG,MAC1B,CAAC;AAElC,eAAO,MAAM,YAAY,YAAa,MAAM,WAAoB,CAAC;AAEjE,eAAO,MAAM,gBAAgB,gBAAiB,MAAM,WAAiC,CAAC;AAEtF,eAAO,MAAM,gBAAgB,SAAU,MAAM,UAAU,GAAG,EAAE,WAQ3D,CAAC;AAEF,eAAO,MAAM,aAAa,WAChB,WAAW,CAAC,QAAQ,CAAC,OACxB,WAAW,CAAC,KAAK,CAAC,WACd,WAAW,CAAC,gBAAgB,CAAC,QAChC,WAAW,CAAC,MAAM,CAAC,WAgB1B,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,SAAS,UAAW,GAAG,2BAMnC,CAAC;AAEF,eAAO,MAAM,oBAAoB,cAIhC,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAS,MAAM,SAAS,GAAG,KAAG,MAC1B,CAAC;AAElC,eAAO,MAAM,mBAAmB,YAAa,MAAM,WAAoB,CAAC;AAExE,eAAO,MAAM,qBAAqB,cAAe,MAAM,WACf,CAAC;AAEzC,eAAO,MAAM,uBAAuB,gBAAiB,MAAM,WAAiC,CAAC;AAE7F,eAAO,MAAM,gBAAgB,SAAU,MAAM,UAAU,GAAG,EAAE,WAQ3D,CAAC;AAEF,eAAO,MAAM,aAAa,WAChB,WAAW,CAAC,QAAQ,CAAC,OACxB,WAAW,CAAC,KAAK,CAAC,WACd,WAAW,CAAC,gBAAgB,CAAC,QAChC,WAAW,CAAC,MAAM,CAAC,WAgB1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-xenon",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "A comprehensive tool for analyzing HTTP(S) requests and logs in React Native apps. Designed for use across all environments, it offers an intuitive interface for efficient debugging and issue resolution.",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/commonjs/index.js",
@@ -1,10 +1,10 @@
1
1
  import { createContext, type MutableRefObject } from 'react';
2
2
  import type { useConsoleInterceptor, useNetworkInterceptor } from '../hooks';
3
3
  import type {
4
- HttpRequest,
5
4
  DebuggerPanel,
6
5
  DebuggerPosition,
7
6
  DebuggerVisibility,
7
+ HttpRequest,
8
8
  LogMessage,
9
9
  SetState,
10
10
  WebSocketRequest,
package/src/global.d.ts CHANGED
@@ -5,18 +5,18 @@ interface XMLHttpRequest {
5
5
  declare module 'react-native/Libraries/WebSocket/NativeWebSocketModule' {
6
6
  interface NativeWebSocketModule extends NativeModule {
7
7
  connect(
8
- uri: string,
9
- protocols?: string | string[] | null,
8
+ url: string,
9
+ protocols?: string | string[],
10
10
  options?: {
11
11
  headers: { [headerName: string]: string };
12
12
  [optionName: string]: any;
13
- } | null,
13
+ },
14
14
  socketId: number,
15
15
  ): void;
16
16
 
17
17
  send(data: string, socketId: number): void;
18
18
 
19
- sendBinary(data: string, socketId: number): void;
19
+ sendBinary(base64String: string, socketId: number): void;
20
20
 
21
21
  close(code: number, reason: string, socketId: number): void;
22
22
 
@@ -4,12 +4,10 @@ import { ConsoleInterceptor } from '../interceptors';
4
4
  import type { LogMessage } from '../types';
5
5
 
6
6
  interface ConsoleInterceptorParams {
7
- autoEnabled?: boolean;
7
+ autoEnabled: boolean;
8
8
  }
9
9
 
10
- export default function useConsoleInterceptor(params: ConsoleInterceptorParams) {
11
- const { autoEnabled = false } = params || {};
12
-
10
+ export default function useConsoleInterceptor({ autoEnabled }: ConsoleInterceptorParams) {
13
11
  const [isInterceptorEnabled, setIsInterceptorEnabled] = useState(autoEnabled);
14
12
 
15
13
  const [logMessages, setLogMessages] = useImmer<LogMessage[]>([]);
@@ -1,7 +1,7 @@
1
- import { enableMapSet } from 'immer';
2
1
  import { useCallback, useEffect, useState } from 'react';
3
2
  import { useImmer } from 'use-immer';
4
3
  import { NETWORK_REQUEST_HEADER } from '../constants';
4
+ import { FetchInterceptor, WebSocketInterceptor, XHRInterceptor } from '../interceptors';
5
5
  import {
6
6
  NetworkType,
7
7
  type HttpHeaderReceivedCallback,
@@ -21,20 +21,16 @@ import {
21
21
  type WebSocketSendCallback,
22
22
  } from '../types';
23
23
  import { keyValueToString } from '../utils';
24
- import { XHRInterceptor, FetchInterceptor, WebSocketInterceptor } from '../interceptors';
25
24
 
26
25
  interface NetworkInterceptorParams {
27
- autoEnabled?: boolean;
26
+ autoEnabled: boolean;
28
27
  }
29
28
 
30
29
  type NetworkRequests<T> = Map<NonNullable<ID>, T>;
31
30
 
32
- enableMapSet();
33
-
34
31
  const initRequests = new Map<NonNullable<ID>, HttpRequest & WebSocketRequest>();
35
32
 
36
- export default function useNetworkInterceptor(params?: NetworkInterceptorParams) {
37
- const { autoEnabled = false } = params || {};
33
+ export default function useNetworkInterceptor({ autoEnabled }: NetworkInterceptorParams) {
38
34
  const [isInterceptorEnabled, setIsInterceptorEnabled] = useState(autoEnabled);
39
35
 
40
36
  const [networkRequests, setNetworkRequests] = useImmer(initRequests);
@@ -116,6 +112,7 @@ export default function useNetworkInterceptor(params?: NetworkInterceptorParams)
116
112
  id,
117
113
  status,
118
114
  timeout,
115
+ duration,
119
116
  response,
120
117
  responseURL,
121
118
  responseType,
@@ -127,6 +124,7 @@ export default function useNetworkInterceptor(params?: NetworkInterceptorParams)
127
124
 
128
125
  draft.get(id)!.status = status;
129
126
  draft.get(id)!.timeout = timeout;
127
+ draft.get(id)!.duration = duration;
130
128
  draft.get(id)!.response = response;
131
129
  if (responseURL) draft.get(id)!.url = responseURL;
132
130
  draft.get(id)!.responseType = responseType;
@@ -151,12 +149,12 @@ export default function useNetworkInterceptor(params?: NetworkInterceptorParams)
151
149
  }, [setNetworkRequests]);
152
150
 
153
151
  const enableWebSocketInterception = useCallback(() => {
154
- const connectCallback: WebSocketConnectCallback = (uri, protocols, options, socketId) => {
152
+ const connectCallback: WebSocketConnectCallback = (url, protocols, options, socketId) => {
155
153
  if (typeof socketId !== 'number') return;
156
154
 
157
155
  setNetworkRequests((draft: NetworkRequests<WebSocketRequest>) => {
158
156
  draft.set(`${socketId}`, {
159
- uri,
157
+ url,
160
158
  type: NetworkType.WS,
161
159
  protocols,
162
160
  options,
@@ -186,7 +184,15 @@ export default function useNetworkInterceptor(params?: NetworkInterceptorParams)
186
184
  });
187
185
  };
188
186
 
189
- const onOpenCallback: WebSocketOnOpenCallback = () => {};
187
+ const onOpenCallback: WebSocketOnOpenCallback = (socketId, duration) => {
188
+ if (typeof socketId !== 'number') return;
189
+
190
+ setNetworkRequests((draft: NetworkRequests<WebSocketRequest>) => {
191
+ if (!draft.get(`${socketId}`)) return draft;
192
+
193
+ draft.get(`${socketId}`)!.duration = duration;
194
+ });
195
+ };
190
196
 
191
197
  const onMessageCallback: WebSocketOnMessageCallback = (socketId, message) => {
192
198
  if (typeof socketId !== 'number') return;
@@ -1,6 +1,6 @@
1
1
  import { NETWORK_REQUEST_HEADER } from '../constants';
2
2
  import { NetworkType } from '../types';
3
- import { keyValueToString, formatMethod, getHttpInterceptorId } from '../utils';
3
+ import { formatRequestMethod, getHttpInterceptorId, keyValueToString } from '../utils';
4
4
  import HttpInterceptor from './HttpInterceptor';
5
5
 
6
6
  const originalFetch = global.fetch;
@@ -33,7 +33,7 @@ export default class FetchInterceptor extends HttpInterceptor {
33
33
  const requestInit: RequestInit = { ...init, headers: requestHeaders };
34
34
 
35
35
  //#region open
36
- const method = formatMethod(init?.method);
36
+ const method = formatRequestMethod(init?.method);
37
37
 
38
38
  let url: string;
39
39
 
@@ -76,11 +76,13 @@ export default class FetchInterceptor extends HttpInterceptor {
76
76
  //#endregion
77
77
 
78
78
  //#region send
79
+ const timeStart = Date.now();
79
80
  sendCallback?.(interceptionId, init?.body ?? null);
80
81
  //#endregion
81
82
 
82
83
  const response = await originalFetch.call(this, input, requestInit);
83
84
 
85
+ const timeEnd = Date.now();
84
86
  const clonedResponse = response.clone();
85
87
  const clonedResponseHeaders = clonedResponse.headers;
86
88
 
@@ -105,11 +107,13 @@ export default class FetchInterceptor extends HttpInterceptor {
105
107
 
106
108
  //#region response
107
109
  const responseBody: string | null = await clonedResponse.text().catch(() => null);
110
+ const duration = timeEnd - timeStart;
108
111
 
109
112
  responseCallback?.(
110
113
  interceptionId,
111
114
  clonedResponse.status,
112
115
  0,
116
+ duration,
113
117
  responseBody,
114
118
  clonedResponse.url,
115
119
  clonedResponse.type,
@@ -92,6 +92,7 @@ export default class WebSocketInterceptor extends NetworkInterceptor {
92
92
 
93
93
  private eventEmitter: NativeEventEmitter | null = null;
94
94
  private subscriptions: EmitterSubscription[] = [];
95
+ private timeStart: Map<number, number> = new Map();
95
96
 
96
97
  private arrayBufferToString(data?: string) {
97
98
  try {
@@ -112,7 +113,12 @@ export default class WebSocketInterceptor extends NetworkInterceptor {
112
113
 
113
114
  this.subscriptions = [
114
115
  this.eventEmitter.addListener('websocketOpen', ev => {
115
- this.onOpenCallback?.(ev.id);
116
+ const timeStart = this.timeStart.get(ev.id);
117
+ const timeEnd = Date.now();
118
+ const duration = timeEnd - (timeStart ?? 0);
119
+ this.timeStart.delete(ev.id);
120
+
121
+ this.onOpenCallback?.(ev.id, duration);
116
122
  }),
117
123
  this.eventEmitter.addListener('websocketMessage', ev => {
118
124
  this.onMessageCallback?.(
@@ -145,9 +151,12 @@ export default class WebSocketInterceptor extends NetworkInterceptor {
145
151
  const { connectCallback, sendCallback, closeCallback, arrayBufferToString } =
146
152
  this.getCallbacks();
147
153
 
154
+ const timeStart = this.timeStart;
148
155
  NativeWebSocketModule.connect = function (...args) {
149
156
  connectCallback?.(...args);
150
157
 
158
+ timeStart.set(args[3], Date.now());
159
+
151
160
  originalWebSocketConnect.call(this, ...args);
152
161
  };
153
162
 
@@ -157,10 +166,10 @@ export default class WebSocketInterceptor extends NetworkInterceptor {
157
166
  originalWebSocketSend.call(this, ...args);
158
167
  };
159
168
 
160
- NativeWebSocketModule.sendBinary = function (data, socketId) {
161
- sendCallback?.(arrayBufferToString(data), socketId);
169
+ NativeWebSocketModule.sendBinary = function (base64String, socketId) {
170
+ sendCallback?.(arrayBufferToString(base64String), socketId);
162
171
 
163
- originalWebSocketSendBinary.call(this, data, socketId);
172
+ originalWebSocketSendBinary.call(this, base64String, socketId);
164
173
  };
165
174
 
166
175
  NativeWebSocketModule.close = function (code, reason, socketId) {
@@ -43,6 +43,8 @@ export default class XHRInterceptor extends HttpInterceptor {
43
43
  XMLHttpRequest.prototype.send = function (data) {
44
44
  sendCallback?.(this._interceptionId, data);
45
45
 
46
+ const timeStart = Date.now();
47
+
46
48
  this.addEventListener?.('readystatechange', () => {
47
49
  if (!isInterceptorEnabled()) return;
48
50
 
@@ -66,10 +68,14 @@ export default class XHRInterceptor extends HttpInterceptor {
66
68
  }
67
69
 
68
70
  if (this.readyState === this.DONE) {
71
+ const timeEnd = Date.now();
72
+ const duration = timeEnd - timeStart;
73
+
69
74
  responseCallback?.(
70
75
  this._interceptionId,
71
76
  this.status,
72
77
  this.timeout,
78
+ duration,
73
79
  this.response,
74
80
  this.responseURL,
75
81
  this.responseType,
@@ -14,7 +14,9 @@ export enum DebuggerPanel {
14
14
  export type ID = string | undefined;
15
15
 
16
16
  export interface NetworkRequest {
17
+ url: string;
17
18
  status?: number;
19
+ duration?: number;
18
20
  }
19
21
 
20
22
  export type DebuggerVisibility = 'hidden' | 'bubble' | 'panel';
package/src/types/http.ts CHANGED
@@ -3,7 +3,6 @@ import type { ID, NetworkRequest, NetworkType } from './common';
3
3
  export interface HttpRequest extends NetworkRequest {
4
4
  type: NetworkType.Fetch | NetworkType.XHR;
5
5
  method: string;
6
- url: string;
7
6
  requestHeaders?: Record<string, string>;
8
7
  requestHeadersString?: string;
9
8
  body?: any;
@@ -37,6 +36,7 @@ export type HttpResponseCallback =
37
36
  id: ID,
38
37
  status: number | undefined,
39
38
  timeout: number | undefined,
39
+ duration: number,
40
40
  response: any,
41
41
  responseURL: string | undefined,
42
42
  responseType: string | undefined,
@@ -1,4 +1,4 @@
1
1
  export * from './common';
2
- export * from './http';
3
2
  export * from './console';
3
+ export * from './http';
4
4
  export * from './websocket';