@rozenite/network-activity-plugin 1.0.0-alpha.1 → 1.0.0-alpha.10

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 (134) hide show
  1. package/README.md +3 -5
  2. package/dist/{panel.html → App.html} +3 -3
  3. package/dist/assets/App-CA1Fbh0I.js +25364 -0
  4. package/dist/assets/App-DoHQsY5s.css +1276 -0
  5. package/dist/event-source.cjs +22 -0
  6. package/dist/event-source.js +23 -0
  7. package/dist/react-native.cjs +8 -1
  8. package/dist/react-native.d.ts +1 -5
  9. package/dist/react-native.js +6 -171
  10. package/dist/rozenite.config.d.ts +7 -0
  11. package/dist/rozenite.json +1 -1
  12. package/dist/src/react-native/http/network-inspector.d.ts +8 -0
  13. package/dist/src/react-native/http/network-requests-registry.d.ts +6 -0
  14. package/dist/src/react-native/http/xhr-interceptor.d.ts +38 -0
  15. package/dist/src/react-native/sse/event-source.d.ts +2 -0
  16. package/dist/src/react-native/sse/sse-inspector.d.ts +9 -0
  17. package/dist/src/react-native/sse/sse-interceptor.d.ts +36 -0
  18. package/dist/src/react-native/sse/types.d.ts +6 -0
  19. package/dist/src/react-native/useNetworkActivityDevTools.d.ts +2 -0
  20. package/dist/src/react-native/utils.d.ts +6 -0
  21. package/dist/src/react-native/websocket/websocket-inspector.d.ts +9 -0
  22. package/dist/src/react-native/websocket/websocket-interceptor.d.ts +74 -0
  23. package/dist/src/shared/client.d.ts +68 -0
  24. package/dist/src/shared/sse-events.d.ts +35 -0
  25. package/dist/src/shared/websocket-events.d.ts +60 -0
  26. package/dist/src/ui/App.d.ts +1 -0
  27. package/dist/src/ui/components/Badge.d.ts +9 -0
  28. package/dist/src/ui/components/Button.d.ts +11 -0
  29. package/dist/src/ui/components/Input.d.ts +3 -0
  30. package/dist/src/ui/components/JsonTree.d.ts +5 -0
  31. package/dist/src/ui/components/JsonTreeCopyableItem.d.ts +7 -0
  32. package/dist/src/ui/components/RequestList.d.ts +25 -0
  33. package/dist/src/ui/components/ScrollArea.d.ts +4 -0
  34. package/dist/src/ui/components/Separator.d.ts +3 -0
  35. package/dist/src/ui/components/SidePanel.d.ts +1 -0
  36. package/dist/src/ui/components/Toolbar.d.ts +1 -0
  37. package/dist/src/ui/hooks/useCopyToClipboard.d.ts +4 -0
  38. package/dist/src/ui/state/derived.d.ts +5 -0
  39. package/dist/src/ui/state/hooks.d.ts +17 -0
  40. package/dist/src/ui/state/model.d.ts +98 -0
  41. package/dist/src/ui/state/store.d.ts +24 -0
  42. package/dist/src/ui/tabs/CookiesTab.d.ts +5 -0
  43. package/dist/src/ui/tabs/HeadersTab.d.ts +5 -0
  44. package/dist/src/ui/tabs/MessagesTab.d.ts +5 -0
  45. package/dist/src/ui/tabs/RequestTab.d.ts +5 -0
  46. package/dist/src/ui/tabs/ResponseTab.d.ts +6 -0
  47. package/dist/src/ui/tabs/SSEMessagesTab.d.ts +5 -0
  48. package/dist/src/ui/tabs/TimingTab.d.ts +5 -0
  49. package/dist/src/ui/types.d.ts +26 -0
  50. package/dist/src/ui/utils/assert.d.ts +1 -0
  51. package/dist/src/ui/utils/cn.d.ts +2 -0
  52. package/dist/src/ui/utils/copyToClipboard.d.ts +1 -0
  53. package/dist/src/ui/utils/getHttpHeaderValue.d.ts +2 -0
  54. package/dist/src/ui/utils/getId.d.ts +1 -0
  55. package/dist/src/ui/utils/getStatusColor.d.ts +1 -0
  56. package/dist/src/ui/views/InspectorView.d.ts +5 -0
  57. package/dist/src/ui/views/LoadingView.d.ts +1 -0
  58. package/dist/useNetworkActivityDevTools.cjs +759 -0
  59. package/dist/useNetworkActivityDevTools.js +757 -0
  60. package/package.json +31 -10
  61. package/postcss.config.js +6 -0
  62. package/project.json +12 -0
  63. package/react-native.ts +2 -1
  64. package/rozenite.config.ts +2 -2
  65. package/src/css-modules.d.ts +1 -1
  66. package/src/react-native/http/network-inspector.ts +226 -0
  67. package/src/react-native/http/network-requests-registry.ts +52 -0
  68. package/src/react-native/http/xhr-interceptor.ts +211 -0
  69. package/src/react-native/http/xml-request.d.ts +34 -0
  70. package/src/react-native/sse/event-source.ts +25 -0
  71. package/src/react-native/sse/sse-inspector.ts +117 -0
  72. package/src/react-native/sse/sse-interceptor.ts +162 -0
  73. package/src/react-native/sse/types.ts +9 -0
  74. package/src/react-native/useNetworkActivityDevTools.ts +73 -210
  75. package/src/react-native/utils.ts +43 -0
  76. package/src/react-native/websocket/websocket-inspector.ts +180 -0
  77. package/src/react-native/websocket/websocket-interceptor.d.ts +4 -0
  78. package/src/react-native/websocket/websocket-interceptor.ts +166 -0
  79. package/src/shared/client.ts +86 -0
  80. package/src/shared/sse-events.ts +44 -0
  81. package/src/shared/websocket-events.ts +79 -0
  82. package/src/ui/App.tsx +19 -0
  83. package/src/ui/components/Badge.tsx +36 -0
  84. package/src/ui/components/Button.tsx +56 -0
  85. package/src/ui/components/Input.tsx +22 -0
  86. package/src/ui/components/JsonTree.tsx +50 -0
  87. package/src/ui/components/JsonTreeCopyableItem.tsx +33 -0
  88. package/src/ui/components/RequestList.tsx +295 -0
  89. package/src/ui/components/ScrollArea.tsx +48 -0
  90. package/src/ui/components/Separator.tsx +31 -0
  91. package/src/ui/components/SidePanel.tsx +323 -0
  92. package/src/ui/components/Tabs.tsx +55 -0
  93. package/src/ui/components/Toolbar.tsx +45 -0
  94. package/src/ui/globals.css +90 -0
  95. package/src/ui/hooks/useCopyToClipboard.ts +28 -0
  96. package/src/ui/state/derived.ts +112 -0
  97. package/src/ui/state/hooks.ts +44 -0
  98. package/src/ui/state/model.ts +129 -0
  99. package/src/ui/state/store.ts +559 -0
  100. package/src/ui/tabs/CookiesTab.tsx +279 -0
  101. package/src/ui/tabs/HeadersTab.tsx +110 -0
  102. package/src/ui/tabs/MessagesTab.tsx +276 -0
  103. package/src/ui/tabs/RequestTab.tsx +69 -0
  104. package/src/ui/tabs/ResponseTab.tsx +138 -0
  105. package/src/ui/tabs/SSEMessagesTab.tsx +213 -0
  106. package/src/ui/tabs/TimingTab.tsx +60 -0
  107. package/src/ui/types.ts +34 -0
  108. package/src/ui/utils/assert.ts +5 -0
  109. package/src/ui/utils/cn.ts +6 -0
  110. package/src/ui/utils/copyToClipboard.ts +3 -0
  111. package/src/ui/utils/getHttpHeaderValue.ts +14 -0
  112. package/src/ui/utils/getId.ts +10 -0
  113. package/src/ui/utils/getStatusColor.ts +15 -0
  114. package/src/ui/views/InspectorView.tsx +53 -0
  115. package/src/ui/views/LoadingView.tsx +19 -0
  116. package/tailwind.config.ts +96 -0
  117. package/tsconfig.json +13 -6
  118. package/tsconfig.tsbuildinfo +1 -0
  119. package/vite.config.ts +13 -1
  120. package/dist/assets/panel-C5YgUUj5.js +0 -54
  121. package/dist/assets/panel-NCVczPb1.css +0 -1
  122. package/src/types/network.ts +0 -153
  123. package/src/ui/components.module.css +0 -158
  124. package/src/ui/components.tsx +0 -219
  125. package/src/ui/network-details.module.css +0 -57
  126. package/src/ui/network-details.tsx +0 -134
  127. package/src/ui/network-list.module.css +0 -122
  128. package/src/ui/network-list.tsx +0 -145
  129. package/src/ui/network-toolbar.module.css +0 -9
  130. package/src/ui/network-toolbar.tsx +0 -40
  131. package/src/ui/panel.module.css +0 -61
  132. package/src/ui/panel.tsx +0 -201
  133. package/src/ui/tanstack-query.tsx +0 -197
  134. package/src/ui/utils.ts +0 -89
@@ -0,0 +1,11 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ import * as React from 'react';
3
+ declare const buttonVariants: (props?: ({
4
+ variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
5
+ size?: "default" | "sm" | "lg" | "icon" | null | undefined;
6
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
7
+ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
8
+ asChild?: boolean;
9
+ }
10
+ declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
11
+ export { Button, buttonVariants };
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ declare const Input: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & React.RefAttributes<HTMLInputElement>>;
3
+ export { Input };
@@ -0,0 +1,5 @@
1
+ export type JsonTreeProps = {
2
+ data: unknown;
3
+ shouldExpandNodeInitially?: () => boolean;
4
+ };
5
+ export declare const JsonTree: ({ data, shouldExpandNodeInitially, }: JsonTreeProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { PropsWithChildren } from 'react';
2
+ type JsonTreeCopyableItemProps = PropsWithChildren<{
3
+ getCopyableValue: () => string;
4
+ className?: string;
5
+ }>;
6
+ export declare const JsonTreeCopyableItem: ({ children, getCopyableValue, className }: JsonTreeCopyableItemProps) => import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,25 @@
1
+ import { ProcessedRequest } from '../state/model';
2
+ import { RequestId } from '../../shared/client';
3
+ type NetworkRequest = {
4
+ id: RequestId;
5
+ name: string;
6
+ status: string | number;
7
+ method: string;
8
+ domain: string;
9
+ path: string;
10
+ size: string;
11
+ time: string;
12
+ type: string;
13
+ startTime: string;
14
+ };
15
+ declare const formatSize: (bytes: number) => string;
16
+ declare const formatDuration: (duration: number) => string;
17
+ declare const formatStartTime: (startTime: number) => string;
18
+ declare const extractDomainAndPath: (url: string) => {
19
+ domain: string;
20
+ path: string;
21
+ };
22
+ declare const generateName: (url: string) => string;
23
+ declare const processNetworkRequests: (processedRequests: ProcessedRequest[]) => NetworkRequest[];
24
+ export declare const RequestList: () => import("react/jsx-runtime").JSX.Element;
25
+ export { formatSize, formatDuration, formatStartTime, extractDomainAndPath, generateName, processNetworkRequests, };
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ declare const ScrollArea: React.ForwardRefExoticComponent<React.RefAttributes<never>>;
3
+ declare const ScrollBar: React.ForwardRefExoticComponent<React.RefAttributes<never>>;
4
+ export { ScrollArea, ScrollBar };
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ declare const Separator: React.ForwardRefExoticComponent<React.RefAttributes<never>>;
3
+ export { Separator };
@@ -0,0 +1 @@
1
+ export declare const SidePanel: () => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1 @@
1
+ export declare const Toolbar: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ export declare function useCopyToClipboard(): {
2
+ isCopied: boolean;
3
+ copy: (value: string) => Promise<void>;
4
+ };
@@ -0,0 +1,5 @@
1
+ import { NetworkActivityState } from './store';
2
+ import { ProcessedRequest } from './model';
3
+ export declare const getProcessedRequests: (obj: NetworkActivityState) => ProcessedRequest[];
4
+ export declare const getSelectedRequest: (obj: NetworkActivityState) => import('./model').NetworkEntry | null;
5
+ export declare const getRequestSummary: (requestId: string) => ((state: NetworkActivityState) => ProcessedRequest | null);
@@ -0,0 +1,17 @@
1
+ import { NetworkActivityState } from './store';
2
+ export declare const useNetworkActivityStore: <T>(selector: (state: NetworkActivityState) => T) => T;
3
+ export declare const useProcessedRequests: () => import('./model').ProcessedRequest[];
4
+ export declare const useSelectedRequest: () => import('./model').NetworkEntry | null;
5
+ export declare const useHasSelectedRequest: () => boolean;
6
+ export declare const useSelectedRequestId: () => string | null;
7
+ export declare const useIsRecording: () => boolean;
8
+ export declare const useNetworkActivityActions: () => {
9
+ setRecording: (isRecording: boolean) => void;
10
+ setSelectedRequest: (requestId: import('../../shared/client').RequestId | null) => void;
11
+ clearRequests: () => void;
12
+ };
13
+ export declare const useNetworkActivityClientManagement: () => {
14
+ setupClient: (client: import('../../shared/client').NetworkActivityDevToolsClient) => void;
15
+ cleanupClient: () => void;
16
+ };
17
+ export declare const useWebSocketMessages: (requestId: string) => import('./model').WebSocketMessage[];
@@ -0,0 +1,98 @@
1
+ import { Initiator, ResourceType } from '../../shared/client';
2
+ export type RequestId = string;
3
+ export type Timestamp = number;
4
+ export type SocketId = number;
5
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD';
6
+ export type NetworkEntryType = 'http' | 'websocket' | 'sse';
7
+ export type HttpData = {
8
+ type: string;
9
+ data: string;
10
+ };
11
+ export type HttpRequest = {
12
+ url: string;
13
+ method: HttpMethod;
14
+ headers: Record<string, string>;
15
+ body?: HttpData;
16
+ };
17
+ export type HttpResponse = {
18
+ url: string;
19
+ status: number;
20
+ statusText: string;
21
+ headers: Record<string, string>;
22
+ contentType: string;
23
+ size: number;
24
+ responseTime: Timestamp;
25
+ body?: HttpData;
26
+ };
27
+ export type HttpStatus = 'pending' | 'loading' | 'finished' | 'failed';
28
+ export type HttpNetworkEntry = {
29
+ id: RequestId;
30
+ type: 'http';
31
+ timestamp: Timestamp;
32
+ duration?: number;
33
+ request: HttpRequest;
34
+ response?: HttpResponse;
35
+ status: HttpStatus;
36
+ error?: string;
37
+ canceled?: boolean;
38
+ ttfb?: number;
39
+ size?: number;
40
+ initiator?: Initiator;
41
+ resourceType?: ResourceType;
42
+ };
43
+ export type SSEMessage = {
44
+ id: string;
45
+ data: string;
46
+ timestamp: Timestamp;
47
+ };
48
+ export type SSEStatus = 'connecting' | 'open' | 'closed' | 'error';
49
+ export type SSENetworkEntry = {
50
+ id: RequestId;
51
+ type: 'sse';
52
+ timestamp: Timestamp;
53
+ duration?: number;
54
+ request: HttpRequest;
55
+ response?: HttpResponse;
56
+ status: SSEStatus;
57
+ messages: SSEMessage[];
58
+ error?: string;
59
+ initiator?: Initiator;
60
+ resourceType?: ResourceType;
61
+ };
62
+ export type WebSocketConnection = {
63
+ url: string;
64
+ socketId: SocketId;
65
+ protocols?: string[];
66
+ options?: string[];
67
+ };
68
+ export type WebSocketMessage = {
69
+ id: string;
70
+ direction: 'sent' | 'received';
71
+ data: string;
72
+ messageType: 'text' | 'binary';
73
+ timestamp: Timestamp;
74
+ };
75
+ export type WebSocketStatus = 'connecting' | 'open' | 'closing' | 'closed' | 'error';
76
+ export type WebSocketNetworkEntry = {
77
+ id: RequestId;
78
+ type: 'websocket';
79
+ timestamp: Timestamp;
80
+ duration?: number;
81
+ connection: WebSocketConnection;
82
+ status: WebSocketStatus;
83
+ error?: string;
84
+ closeCode?: number;
85
+ closeReason?: string;
86
+ };
87
+ export type NetworkEntry = HttpNetworkEntry | WebSocketNetworkEntry | SSENetworkEntry;
88
+ export type ProcessedRequest = {
89
+ id: RequestId;
90
+ type: NetworkEntryType;
91
+ name: string;
92
+ status: HttpStatus | WebSocketStatus | SSEStatus;
93
+ timestamp: Timestamp;
94
+ duration?: number;
95
+ size?: number;
96
+ method: HttpMethod | 'WS' | 'SSE';
97
+ httpStatus?: number;
98
+ };
@@ -0,0 +1,24 @@
1
+ import { NetworkActivityDevToolsClient, NetworkActivityEventMap, RequestId } from '../../shared/client';
2
+ import { NetworkEntry, WebSocketMessage } from './model';
3
+ export interface NetworkActivityState {
4
+ isRecording: boolean;
5
+ selectedRequestId: RequestId | null;
6
+ networkEntries: Map<RequestId, NetworkEntry>;
7
+ websocketMessages: Map<RequestId, WebSocketMessage[]>;
8
+ _unsubscribeFunctions?: Array<{
9
+ remove: () => void;
10
+ }>;
11
+ _client?: NetworkActivityDevToolsClient;
12
+ actions: {
13
+ setRecording: (isRecording: boolean) => void;
14
+ setSelectedRequest: (requestId: RequestId | null) => void;
15
+ clearRequests: () => void;
16
+ };
17
+ handleEvent: <K extends keyof NetworkActivityEventMap>(eventType: K, data: NetworkActivityEventMap[K]) => void;
18
+ client: {
19
+ setupClient: (client: NetworkActivityDevToolsClient) => void;
20
+ cleanupClient: () => void;
21
+ };
22
+ }
23
+ export declare const createNetworkActivityStore: () => import('zustand').StoreApi<NetworkActivityState>;
24
+ export declare const store: import('zustand').StoreApi<NetworkActivityState>;
@@ -0,0 +1,5 @@
1
+ import { HttpNetworkEntry, SSENetworkEntry } from '../state/model';
2
+ export type CookiesTabProps = {
3
+ selectedRequest: HttpNetworkEntry | SSENetworkEntry;
4
+ };
5
+ export declare const CookiesTab: ({ selectedRequest }: CookiesTabProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { HttpNetworkEntry, SSENetworkEntry } from '../state/model';
2
+ export type HeadersTabProps = {
3
+ selectedRequest: HttpNetworkEntry | SSENetworkEntry;
4
+ };
5
+ export declare const HeadersTab: ({ selectedRequest }: HeadersTabProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { WebSocketNetworkEntry } from '../state/model';
2
+ export type MessagesTabProps = {
3
+ selectedRequest: WebSocketNetworkEntry;
4
+ };
5
+ export declare const MessagesTab: ({ selectedRequest }: MessagesTabProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { HttpNetworkEntry, SSENetworkEntry } from '../state/model';
2
+ export type RequestTabProps = {
3
+ selectedRequest: HttpNetworkEntry | SSENetworkEntry;
4
+ };
5
+ export declare const RequestTab: ({ selectedRequest }: RequestTabProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { HttpNetworkEntry } from '../state/model';
2
+ export type ResponseTabProps = {
3
+ selectedRequest: HttpNetworkEntry;
4
+ onRequestResponseBody: (requestId: string) => void;
5
+ };
6
+ export declare const ResponseTab: ({ selectedRequest, onRequestResponseBody, }: ResponseTabProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { SSENetworkEntry } from '../state/model';
2
+ export type SSEMessagesTabProps = {
3
+ selectedRequest: SSENetworkEntry;
4
+ };
5
+ export declare const SSEMessagesTab: ({ selectedRequest }: SSEMessagesTabProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { HttpNetworkEntry } from '../state/model';
2
+ export type TimingTabProps = {
3
+ selectedRequest: HttpNetworkEntry;
4
+ };
5
+ export declare const TimingTab: ({ selectedRequest }: TimingTabProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import { RequestId, Request, Response, Initiator, ResourceType, HttpHeaders } from '../shared/client';
2
+ export type NetworkEntry = {
3
+ requestId: RequestId;
4
+ url: string;
5
+ method: string;
6
+ headers: HttpHeaders;
7
+ body?: {
8
+ type: string;
9
+ data: string;
10
+ };
11
+ status: 'pending' | 'loading' | 'finished' | 'failed';
12
+ startTime: number;
13
+ endTime?: number;
14
+ duration?: number;
15
+ ttfb?: number;
16
+ type?: ResourceType;
17
+ initiator?: Initiator;
18
+ request?: Request;
19
+ response?: Response;
20
+ responseBody?: {
21
+ body: string | null;
22
+ };
23
+ error?: string;
24
+ canceled?: boolean;
25
+ size?: number;
26
+ };
@@ -0,0 +1 @@
1
+ export declare function assert(condition: boolean, message: string): asserts condition;
@@ -0,0 +1,2 @@
1
+ import { ClassValue } from 'clsx';
2
+ export declare function cn(...inputs: ClassValue[]): string;
@@ -0,0 +1 @@
1
+ export declare function copyToClipboard(text: string): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { HttpHeaders } from '../../shared/client';
2
+ export declare function getHttpHeaderValue(headers: HttpHeaders, name: string): string | undefined;
@@ -0,0 +1 @@
1
+ export declare const getId: (namespace: string) => string;
@@ -0,0 +1 @@
1
+ export declare const getStatusColor: (status: number | string) => string;
@@ -0,0 +1,5 @@
1
+ import { NetworkActivityDevToolsClient } from '../../shared/client';
2
+ export type InspectorViewProps = {
3
+ client: NetworkActivityDevToolsClient;
4
+ };
5
+ export declare const InspectorView: ({ client }: InspectorViewProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const LoadingView: () => import("react/jsx-runtime").JSX.Element;