@rozenite/network-activity-plugin 1.0.0-alpha.9 → 1.1.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 (113) hide show
  1. package/README.md +2 -0
  2. package/dist/App.html +2 -2
  3. package/dist/assets/{App-DoHQsY5s.css → App-BrSkOkws.css} +223 -2
  4. package/dist/assets/{App-CA1Fbh0I.js → App-Kyi7zHUX.js} +8188 -2671
  5. package/dist/react-native.cjs +4 -1
  6. package/dist/react-native.js +4 -1
  7. package/dist/rozenite.json +1 -1
  8. package/dist/src/react-native/config.d.ts +20 -0
  9. package/dist/src/react-native/http/overrides-registry.d.ts +6 -0
  10. package/dist/src/react-native/http/xhr-interceptor.d.ts +7 -1
  11. package/dist/src/react-native/sse/sse-interceptor.d.ts +2 -2
  12. package/dist/src/react-native/useNetworkActivityDevTools.d.ts +2 -1
  13. package/dist/src/react-native/utils/getBlobName.d.ts +35 -0
  14. package/dist/src/react-native/utils/getFormDataEntries.d.ts +18 -0
  15. package/dist/src/shared/client.d.ts +55 -4
  16. package/dist/src/shared/sse-events.d.ts +4 -1
  17. package/dist/src/ui/components/Button.d.ts +2 -2
  18. package/dist/src/ui/components/CodeBlock.d.ts +3 -0
  19. package/dist/src/ui/components/CodeEditor.d.ts +5 -0
  20. package/dist/src/ui/components/CookieCard.d.ts +7 -0
  21. package/dist/src/ui/components/CopyRequestDropdown.d.ts +7 -0
  22. package/dist/src/ui/components/DropdownMenu.d.ts +27 -0
  23. package/dist/src/ui/components/FilterBar.d.ts +10 -0
  24. package/dist/src/ui/components/JsonTreeCopyableItem.d.ts +1 -1
  25. package/dist/src/ui/components/KeyValueGrid.d.ts +13 -0
  26. package/dist/src/ui/components/OverrideResponse.d.ts +8 -0
  27. package/dist/src/ui/components/RequestBody.d.ts +6 -0
  28. package/dist/src/ui/components/RequestList.d.ts +9 -4
  29. package/dist/src/ui/components/ScrollArea.d.ts +3 -2
  30. package/dist/src/ui/components/Section.d.ts +8 -0
  31. package/dist/src/ui/components/Separator.d.ts +2 -1
  32. package/dist/src/ui/components/Tabs.d.ts +7 -0
  33. package/dist/src/ui/state/hooks.d.ts +4 -0
  34. package/dist/src/ui/state/model.d.ts +22 -7
  35. package/dist/src/ui/state/store.d.ts +27 -3
  36. package/dist/src/ui/utils/checkRequestBodyBinary.d.ts +2 -0
  37. package/dist/src/ui/utils/escapeShellArg.d.ts +1 -0
  38. package/dist/src/ui/utils/generateCurlCommand.d.ts +2 -0
  39. package/dist/src/ui/utils/generateFetchCall.d.ts +2 -0
  40. package/dist/src/ui/utils/generateMultipartBody.d.ts +4 -0
  41. package/dist/src/utils/applyReactNativeRequestHeadersLogic.d.ts +7 -0
  42. package/dist/src/utils/applyReactNativeResponseHeadersLogic.d.ts +9 -0
  43. package/dist/src/utils/cookieParser.d.ts +6 -0
  44. package/dist/src/utils/getContentTypeMimeType.d.ts +2 -0
  45. package/dist/src/utils/getHttpHeader.d.ts +5 -0
  46. package/dist/src/utils/getHttpHeaderValueAsString.d.ts +11 -0
  47. package/dist/src/utils/getStringSizeInBytes.d.ts +1 -0
  48. package/dist/src/utils/inferContentTypeFromPostData.d.ts +2 -0
  49. package/dist/src/utils/safeStringify.d.ts +1 -0
  50. package/dist/src/utils/typeChecks.d.ts +9 -0
  51. package/dist/useNetworkActivityDevTools.cjs +337 -24
  52. package/dist/useNetworkActivityDevTools.js +338 -25
  53. package/package.json +7 -4
  54. package/react-native.ts +6 -1
  55. package/src/react-native/config.ts +43 -0
  56. package/src/react-native/http/network-inspector.ts +190 -8
  57. package/src/react-native/http/overrides-registry.ts +32 -0
  58. package/src/react-native/http/xhr-interceptor.ts +19 -2
  59. package/src/react-native/sse/sse-inspector.ts +27 -5
  60. package/src/react-native/sse/sse-interceptor.ts +26 -8
  61. package/src/react-native/useNetworkActivityDevTools.ts +86 -8
  62. package/src/react-native/utils/getBlobName.ts +45 -0
  63. package/src/react-native/utils/getFormDataEntries.ts +32 -0
  64. package/src/react-native/utils.ts +3 -3
  65. package/src/shared/client.ts +81 -4
  66. package/src/shared/sse-events.ts +4 -1
  67. package/src/ui/components/Button.tsx +1 -0
  68. package/src/ui/components/CodeBlock.tsx +19 -0
  69. package/src/ui/components/CodeEditor.tsx +26 -0
  70. package/src/ui/components/CookieCard.tsx +64 -0
  71. package/src/ui/components/CopyRequestDropdown.tsx +95 -0
  72. package/src/ui/components/DropdownMenu.tsx +206 -0
  73. package/src/ui/components/FilterBar.tsx +117 -0
  74. package/src/ui/components/Input.tsx +1 -1
  75. package/src/ui/components/JsonTree.tsx +10 -3
  76. package/src/ui/components/JsonTreeCopyableItem.tsx +14 -10
  77. package/src/ui/components/KeyValueGrid.tsx +51 -0
  78. package/src/ui/components/OverrideResponse.tsx +132 -0
  79. package/src/ui/components/RequestBody.tsx +86 -0
  80. package/src/ui/components/RequestList.tsx +74 -14
  81. package/src/ui/components/ScrollArea.tsx +1 -0
  82. package/src/ui/components/Section.tsx +46 -0
  83. package/src/ui/components/SidePanel.tsx +15 -5
  84. package/src/ui/components/Toolbar.tsx +3 -2
  85. package/src/ui/globals.css +4 -0
  86. package/src/ui/hooks/useCopyToClipboard.ts +2 -2
  87. package/src/ui/state/derived.ts +2 -0
  88. package/src/ui/state/hooks.ts +8 -0
  89. package/src/ui/state/model.ts +28 -7
  90. package/src/ui/state/store.ts +640 -500
  91. package/src/ui/tabs/CookiesTab.tsx +60 -263
  92. package/src/ui/tabs/HeadersTab.tsx +78 -89
  93. package/src/ui/tabs/RequestTab.tsx +58 -46
  94. package/src/ui/tabs/ResponseTab.tsx +98 -67
  95. package/src/ui/tabs/SSEMessagesTab.tsx +50 -39
  96. package/src/ui/utils/checkRequestBodyBinary.ts +7 -0
  97. package/src/ui/utils/escapeShellArg.ts +12 -0
  98. package/src/ui/utils/generateCurlCommand.ts +83 -0
  99. package/src/ui/utils/generateFetchCall.ts +64 -0
  100. package/src/ui/utils/generateMultipartBody.ts +19 -0
  101. package/src/ui/views/InspectorView.tsx +15 -3
  102. package/src/utils/applyReactNativeRequestHeadersLogic.ts +30 -0
  103. package/src/utils/applyReactNativeResponseHeadersLogic.ts +28 -0
  104. package/src/utils/cookieParser.ts +126 -0
  105. package/src/utils/getContentTypeMimeType.ts +17 -0
  106. package/src/utils/getHttpHeader.ts +17 -0
  107. package/src/utils/getHttpHeaderValueAsString.ts +13 -0
  108. package/src/utils/getStringSizeInBytes.ts +3 -0
  109. package/src/utils/inferContentTypeFromPostData.ts +9 -0
  110. package/src/utils/safeStringify.ts +7 -0
  111. package/src/utils/typeChecks.ts +27 -0
  112. package/dist/src/ui/utils/getHttpHeaderValue.d.ts +0 -2
  113. package/src/ui/utils/getHttpHeaderValue.ts +0 -14
@@ -10,6 +10,7 @@ import { X } from 'lucide-react';
10
10
  import {
11
11
  useNetworkActivityActions,
12
12
  useNetworkActivityStore,
13
+ useOverrides,
13
14
  useSelectedRequest,
14
15
  } from '../state/hooks';
15
16
  import { NetworkEntry as OldNetworkEntry } from '../types';
@@ -85,6 +86,7 @@ export const SidePanel = () => {
85
86
  const actions = useNetworkActivityActions();
86
87
  const selectedRequest = useSelectedRequest();
87
88
  const client = useNetworkActivityStore((state) => state._client);
89
+ const overrides = useOverrides();
88
90
 
89
91
  const onClose = (): void => {
90
92
  actions.setSelectedRequest(null);
@@ -128,6 +130,9 @@ export const SidePanel = () => {
128
130
  legacyNetworkEntries.set(legacyEntry.requestId, legacyEntry);
129
131
  }
130
132
 
133
+ const override = legacyEntry !== null ? overrides.get(legacyEntry.url) : null;
134
+ const hasResponseOverride = override && override.body ? true : false;
135
+
131
136
  const getTabsListTriggers = () => {
132
137
  if (httpDetails) {
133
138
  return (
@@ -149,6 +154,9 @@ export const SidePanel = () => {
149
154
  className="data-[state=active]:bg-gray-700"
150
155
  >
151
156
  Response
157
+ {hasResponseOverride && (
158
+ <span className="w-2 h-2 rounded-full bg-violet-300 ms-2 inline-block"></span>
159
+ )}
152
160
  </TabsTrigger>
153
161
  <TabsTrigger
154
162
  value="cookies"
@@ -278,16 +286,18 @@ export const SidePanel = () => {
278
286
  <div className="w-1/2 flex flex-col bg-gray-900">
279
287
  {/* Side Panel Header */}
280
288
  <div className="flex items-center justify-between p-3 border-b border-gray-700 bg-gray-800">
281
- <div className="flex items-center gap-2">
289
+ <div className="flex items-center gap-2 min-w-0 flex-1">
282
290
  <div
283
- className={`w-3 h-3 rounded-full ${getTypeColor(
291
+ className={`w-3 h-3 rounded-full flex-shrink-0 ${getTypeColor(
284
292
  selectedRequest.type
285
293
  )}`}
286
294
  ></div>
287
- <span className="font-medium">{requestName}</span>
295
+ <span className="font-medium truncate">{requestName}</span>
288
296
  <Badge
289
297
  variant="outline"
290
- className={`${getStatusColor(requestStatus)} border-current`}
298
+ className={`${getStatusColor(
299
+ requestStatus
300
+ )} border-current flex-shrink-0`}
291
301
  >
292
302
  {requestStatus}
293
303
  </Badge>
@@ -296,7 +306,7 @@ export const SidePanel = () => {
296
306
  variant="ghost"
297
307
  size="sm"
298
308
  onClick={onClose}
299
- className="h-6 w-6 p-0 text-gray-400 hover:text-blue-400"
309
+ className="h-6 w-6 p-0 text-gray-400 hover:text-blue-400 flex-shrink-0 ml-2"
300
310
  >
301
311
  <X className="h-4 w-4" />
302
312
  </Button>
@@ -25,11 +25,12 @@ export const Toolbar = () => {
25
25
  ? 'text-red-400 hover:text-red-300'
26
26
  : 'text-gray-400 hover:text-blue-400'
27
27
  }`}
28
+ title={isRecording ? 'Stop recording' : 'Start recording'}
28
29
  >
29
30
  {isRecording ? (
30
- <Circle className="h-4 w-4 fill-current" />
31
+ <Square className="h-4 w-4 fill-current" />
31
32
  ) : (
32
- <Square className="h-4 w-4" />
33
+ <Circle className="h-4 w-4 fill-current" />
33
34
  )}
34
35
  </Button>
35
36
  <Button
@@ -6,6 +6,10 @@
6
6
  .text-balance {
7
7
  text-wrap: balance;
8
8
  }
9
+
10
+ .wrap-anywhere {
11
+ overflow-wrap: anywhere;
12
+ }
9
13
  }
10
14
 
11
15
  @layer base {
@@ -14,9 +14,9 @@ export function useCopyToClipboard() {
14
14
  const copy = useCallback(async (value: string) => {
15
15
  try {
16
16
  await copyToClipboard(value);
17
-
17
+
18
18
  setIsCopied(true);
19
-
19
+
20
20
  clearTimeout(timeoutRef.current);
21
21
  timeoutRef.current = setTimeout(() => setIsCopied(false), 1000);
22
22
  } catch (error) {
@@ -24,6 +24,7 @@ export const getProcessedRequests = memoize((state: NetworkActivityState) => {
24
24
  size: httpEntry.size,
25
25
  method: httpEntry.request.method,
26
26
  httpStatus: httpEntry.response?.status,
27
+ progress: httpEntry.progress,
27
28
  });
28
29
  } else if (entry.type === 'websocket') {
29
30
  const wsEntry = entry as WebSocketNetworkEntry;
@@ -81,6 +82,7 @@ export const getRequestSummary = (
81
82
  size: httpEntry.size,
82
83
  method: httpEntry.request.method,
83
84
  httpStatus: httpEntry.response?.status || 0,
85
+ progress: httpEntry.progress,
84
86
  };
85
87
  } else if (entry.type === 'websocket') {
86
88
  const wsEntry = entry as WebSocketNetworkEntry;
@@ -42,3 +42,11 @@ export const useWebSocketMessages = (requestId: string) => {
42
42
  (state) => state.websocketMessages.get(requestId) || []
43
43
  );
44
44
  };
45
+
46
+ export const useOverrides = () => {
47
+ return useNetworkActivityStore((state) => state.overrides);
48
+ };
49
+
50
+ export const useClientUISettings = () => {
51
+ return useNetworkActivityStore((state) => state.clientUISettings);
52
+ };
@@ -1,4 +1,9 @@
1
- import { Initiator, ResourceType } from '../../shared/client';
1
+ import {
2
+ Initiator,
3
+ ResourceType,
4
+ HttpHeaders,
5
+ RequestPostData,
6
+ } from '../../shared/client';
2
7
 
3
8
  export type RequestId = string;
4
9
  export type Timestamp = number;
@@ -8,7 +13,12 @@ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD';
8
13
  export type NetworkEntryType = 'http' | 'websocket' | 'sse';
9
14
 
10
15
  /* HTTP */
11
- export type HttpData = {
16
+ export type HttpRequestData = {
17
+ type: string;
18
+ data: NonNullable<RequestPostData>;
19
+ };
20
+
21
+ export type HttpResponseData = {
12
22
  type: string;
13
23
  data: string;
14
24
  };
@@ -16,19 +26,19 @@ export type HttpData = {
16
26
  export type HttpRequest = {
17
27
  url: string;
18
28
  method: HttpMethod;
19
- headers: Record<string, string>;
20
- body?: HttpData;
29
+ headers: HttpHeaders;
30
+ body?: HttpRequestData;
21
31
  };
22
32
 
23
33
  export type HttpResponse = {
24
34
  url: string;
25
35
  status: number;
26
36
  statusText: string;
27
- headers: Record<string, string>;
37
+ headers: HttpHeaders;
28
38
  contentType: string;
29
39
  size: number;
30
40
  responseTime: Timestamp;
31
- body?: HttpData;
41
+ body?: HttpResponseData;
32
42
  };
33
43
 
34
44
  export type HttpStatus = 'pending' | 'loading' | 'finished' | 'failed';
@@ -48,11 +58,17 @@ export type HttpNetworkEntry = {
48
58
  size?: number;
49
59
  initiator?: Initiator;
50
60
  resourceType?: ResourceType;
61
+ progress?: {
62
+ loaded: number;
63
+ total: number;
64
+ lengthComputable: boolean;
65
+ };
51
66
  };
52
67
 
53
68
  /* SSE */
54
69
  export type SSEMessage = {
55
70
  id: string;
71
+ type: string;
56
72
  data: string;
57
73
  timestamp: Timestamp;
58
74
  };
@@ -123,7 +139,12 @@ export type ProcessedRequest = {
123
139
  status: HttpStatus | WebSocketStatus | SSEStatus;
124
140
  timestamp: Timestamp;
125
141
  duration?: number;
126
- size?: number;
142
+ size: number | null;
127
143
  method: HttpMethod | 'WS' | 'SSE';
128
144
  httpStatus?: number;
145
+ progress?: {
146
+ loaded: number;
147
+ total: number;
148
+ lengthComputable: boolean;
149
+ };
129
150
  };