@buoy-gg/network 1.7.2

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 (67) hide show
  1. package/README.md +381 -0
  2. package/lib/commonjs/index.js +34 -0
  3. package/lib/commonjs/network/components/NetworkCopySettingsView.js +867 -0
  4. package/lib/commonjs/network/components/NetworkEventDetailView.js +837 -0
  5. package/lib/commonjs/network/components/NetworkEventItemCompact.js +323 -0
  6. package/lib/commonjs/network/components/NetworkFilterViewV3.js +297 -0
  7. package/lib/commonjs/network/components/NetworkModal.js +937 -0
  8. package/lib/commonjs/network/hooks/useNetworkEvents.js +320 -0
  9. package/lib/commonjs/network/hooks/useTickEveryMinute.js +34 -0
  10. package/lib/commonjs/network/index.js +102 -0
  11. package/lib/commonjs/network/types/index.js +1 -0
  12. package/lib/commonjs/network/utils/extractOperationName.js +80 -0
  13. package/lib/commonjs/network/utils/formatGraphQLVariables.js +219 -0
  14. package/lib/commonjs/network/utils/formatting.js +30 -0
  15. package/lib/commonjs/network/utils/networkEventStore.js +269 -0
  16. package/lib/commonjs/network/utils/networkListener.js +801 -0
  17. package/lib/commonjs/package.json +1 -0
  18. package/lib/commonjs/preset.js +83 -0
  19. package/lib/module/index.js +7 -0
  20. package/lib/module/network/components/NetworkCopySettingsView.js +862 -0
  21. package/lib/module/network/components/NetworkEventDetailView.js +834 -0
  22. package/lib/module/network/components/NetworkEventItemCompact.js +320 -0
  23. package/lib/module/network/components/NetworkFilterViewV3.js +293 -0
  24. package/lib/module/network/components/NetworkModal.js +933 -0
  25. package/lib/module/network/hooks/useNetworkEvents.js +316 -0
  26. package/lib/module/network/hooks/useTickEveryMinute.js +29 -0
  27. package/lib/module/network/index.js +20 -0
  28. package/lib/module/network/types/index.js +1 -0
  29. package/lib/module/network/utils/extractOperationName.js +76 -0
  30. package/lib/module/network/utils/formatGraphQLVariables.js +213 -0
  31. package/lib/module/network/utils/formatting.js +9 -0
  32. package/lib/module/network/utils/networkEventStore.js +265 -0
  33. package/lib/module/network/utils/networkListener.js +791 -0
  34. package/lib/module/preset.js +79 -0
  35. package/lib/typescript/index.d.ts +3 -0
  36. package/lib/typescript/index.d.ts.map +1 -0
  37. package/lib/typescript/network/components/NetworkCopySettingsView.d.ts +26 -0
  38. package/lib/typescript/network/components/NetworkCopySettingsView.d.ts.map +1 -0
  39. package/lib/typescript/network/components/NetworkEventDetailView.d.ts +13 -0
  40. package/lib/typescript/network/components/NetworkEventDetailView.d.ts.map +1 -0
  41. package/lib/typescript/network/components/NetworkEventItemCompact.d.ts +12 -0
  42. package/lib/typescript/network/components/NetworkEventItemCompact.d.ts.map +1 -0
  43. package/lib/typescript/network/components/NetworkFilterViewV3.d.ts +22 -0
  44. package/lib/typescript/network/components/NetworkFilterViewV3.d.ts.map +1 -0
  45. package/lib/typescript/network/components/NetworkModal.d.ts +14 -0
  46. package/lib/typescript/network/components/NetworkModal.d.ts.map +1 -0
  47. package/lib/typescript/network/hooks/useNetworkEvents.d.ts +72 -0
  48. package/lib/typescript/network/hooks/useNetworkEvents.d.ts.map +1 -0
  49. package/lib/typescript/network/hooks/useTickEveryMinute.d.ts +9 -0
  50. package/lib/typescript/network/hooks/useTickEveryMinute.d.ts.map +1 -0
  51. package/lib/typescript/network/index.d.ts +12 -0
  52. package/lib/typescript/network/index.d.ts.map +1 -0
  53. package/lib/typescript/network/types/index.d.ts +88 -0
  54. package/lib/typescript/network/types/index.d.ts.map +1 -0
  55. package/lib/typescript/network/utils/extractOperationName.d.ts +41 -0
  56. package/lib/typescript/network/utils/extractOperationName.d.ts.map +1 -0
  57. package/lib/typescript/network/utils/formatGraphQLVariables.d.ts +79 -0
  58. package/lib/typescript/network/utils/formatGraphQLVariables.d.ts.map +1 -0
  59. package/lib/typescript/network/utils/formatting.d.ts +6 -0
  60. package/lib/typescript/network/utils/formatting.d.ts.map +1 -0
  61. package/lib/typescript/network/utils/networkEventStore.d.ts +81 -0
  62. package/lib/typescript/network/utils/networkEventStore.d.ts.map +1 -0
  63. package/lib/typescript/network/utils/networkListener.d.ts +191 -0
  64. package/lib/typescript/network/utils/networkListener.d.ts.map +1 -0
  65. package/lib/typescript/preset.d.ts +76 -0
  66. package/lib/typescript/preset.d.ts.map +1 -0
  67. package/package.json +69 -0
package/README.md ADDED
@@ -0,0 +1,381 @@
1
+ # @buoy/network
2
+
3
+ [![npm](https://img.shields.io/npm/v/@buoy%2Fnetwork)](https://www.npmjs.com/package/@buoy/network)
4
+
5
+ Network request monitoring and inspection tool for React Native development.
6
+
7
+ ## Features
8
+
9
+ - **Live Network Monitoring**: Track all fetch and XMLHttpRequest calls in real-time
10
+ - **Request/Response Inspection**: View detailed information about headers, payloads, and responses
11
+ - **Filtering**: Filter requests by status code, HTTP method, or URL pattern
12
+ - **Timing Information**: See request duration and timing details
13
+ - **Search**: Search through captured network events
14
+ - **Pause/Resume**: Control when to capture network events
15
+ - **Clear History**: Clear captured events when needed
16
+ - **Beautiful UI**: Modern, game-themed interface matching other React Buoy tools
17
+
18
+ ## Installation
19
+
20
+ This package is part of the React Buoy monorepo and is automatically available to other packages and the example app.
21
+
22
+ For external projects:
23
+
24
+ ```bash
25
+ npm install @buoy/network
26
+ # or
27
+ pnpm add @buoy/network
28
+ # or
29
+ yarn add @buoy/network
30
+ ```
31
+
32
+ ## Quick Start
33
+
34
+ ### Simplest Setup - Just 1 Line!
35
+
36
+ **Import the preset and add it to your tools array. Done!**
37
+
38
+ ```typescript
39
+ import { networkToolPreset } from '@buoy/network';
40
+ import { FloatingDevTools } from '@buoy/core';
41
+
42
+ const installedApps = [
43
+ networkToolPreset, // That's it! One line.
44
+ // ...your other tools
45
+ ];
46
+
47
+ function App() {
48
+ return (
49
+ <FloatingDevTools
50
+ apps={installedApps}
51
+ environment="local"
52
+ userRole="admin"
53
+ />
54
+ );
55
+ }
56
+ ```
57
+
58
+ **Done!** The preset automatically:
59
+ - ✅ Monitors all network requests
60
+ - ✅ Intercepts fetch and XMLHttpRequest
61
+ - ✅ Provides filtering and search
62
+ - ✅ No configuration required
63
+
64
+ ### Custom Configuration
65
+
66
+ If you want to customize the appearance or behavior:
67
+
68
+ ```typescript
69
+ import { createNetworkTool } from '@buoy/network';
70
+
71
+ const myNetworkTool = createNetworkTool({
72
+ name: "REQUESTS",
73
+ colorPreset: "purple",
74
+ enableSharedModalDimensions: true,
75
+ });
76
+
77
+ const installedApps = [
78
+ myNetworkTool,
79
+ // ...other tools
80
+ ];
81
+ ```
82
+
83
+ ### Alternative: Manual Setup
84
+
85
+ If you're not using FloatingDevTools or want more control:
86
+
87
+ ```typescript
88
+ import { NetworkModal } from '@buoy/network';
89
+
90
+ function App() {
91
+ const [showNetwork, setShowNetwork] = useState(false);
92
+
93
+ return (
94
+ <>
95
+ <Button onPress={() => setShowNetwork(true)}>
96
+ Open Network Monitor
97
+ </Button>
98
+
99
+ <NetworkModal
100
+ visible={showNetwork}
101
+ onClose={() => setShowNetwork(false)}
102
+ />
103
+ </>
104
+ );
105
+ }
106
+ ```
107
+
108
+ ## API Reference
109
+
110
+ ### Presets
111
+
112
+ #### `networkToolPreset`
113
+
114
+ Pre-configured network monitoring tool ready to use with FloatingDevTools.
115
+
116
+ **Example:**
117
+ ```typescript
118
+ import { networkToolPreset } from '@buoy/network';
119
+
120
+ const installedApps = [networkToolPreset];
121
+ ```
122
+
123
+ #### `createNetworkTool(options?)`
124
+
125
+ Create a custom network monitoring tool configuration.
126
+
127
+ **Options:**
128
+ ```typescript
129
+ {
130
+ /** Tool name (default: "NET") */
131
+ name?: string;
132
+ /** Tool description */
133
+ description?: string;
134
+ /** Icon color preset (default: "cyan") */
135
+ colorPreset?: "orange" | "cyan" | "purple" | "pink" | "yellow" | "green";
136
+ /** Custom tool ID (default: "network") */
137
+ id?: string;
138
+ /** Enable shared modal dimensions */
139
+ enableSharedModalDimensions?: boolean;
140
+ }
141
+ ```
142
+
143
+ **Example:**
144
+ ```typescript
145
+ import { createNetworkTool } from '@buoy/network';
146
+
147
+ const myNetworkTool = createNetworkTool({
148
+ name: "API CALLS",
149
+ colorPreset: "green",
150
+ enableSharedModalDimensions: true,
151
+ });
152
+ ```
153
+
154
+ ### Components
155
+
156
+ #### `NetworkModal`
157
+
158
+ Main modal component for monitoring network requests.
159
+
160
+ **Props:**
161
+ ```typescript
162
+ interface NetworkModalProps {
163
+ /** Whether the modal is visible */
164
+ visible: boolean;
165
+ /** Callback when modal is closed */
166
+ onClose: () => void;
167
+ /** Optional back button handler */
168
+ onBack?: () => void;
169
+ /** Whether to use shared modal dimensions */
170
+ enableSharedModalDimensions?: boolean;
171
+ }
172
+ ```
173
+
174
+ **Example:**
175
+ ```typescript
176
+ <NetworkModal
177
+ visible={isVisible}
178
+ onClose={handleClose}
179
+ enableSharedModalDimensions={true}
180
+ />
181
+ ```
182
+
183
+ ### Hooks
184
+
185
+ #### `useNetworkEvents()`
186
+
187
+ Access the list of captured network events and control functions.
188
+
189
+ **Returns:**
190
+ ```typescript
191
+ {
192
+ /** Array of captured network events */
193
+ events: NetworkEvent[];
194
+ /** Whether interception is enabled */
195
+ isEnabled: boolean;
196
+ /** Enable network interception */
197
+ enable: () => void;
198
+ /** Disable network interception */
199
+ disable: () => void;
200
+ /** Clear all captured events */
201
+ clear: () => void;
202
+ }
203
+ ```
204
+
205
+ **Example:**
206
+ ```typescript
207
+ import { useNetworkEvents } from '@buoy/network';
208
+
209
+ function MyComponent() {
210
+ const { events, isEnabled, enable, disable, clear } = useNetworkEvents();
211
+
212
+ return (
213
+ <View>
214
+ <Text>Captured {events.length} requests</Text>
215
+ <Button onPress={isEnabled ? disable : enable}>
216
+ {isEnabled ? 'Pause' : 'Resume'}
217
+ </Button>
218
+ <Button onPress={clear}>Clear</Button>
219
+ </View>
220
+ );
221
+ }
222
+ ```
223
+
224
+ ### Types
225
+
226
+ #### `NetworkEvent`
227
+
228
+ ```typescript
229
+ interface NetworkEvent {
230
+ /** Unique event ID */
231
+ id: string;
232
+ /** Request URL */
233
+ url: string;
234
+ /** HTTP method */
235
+ method: string;
236
+ /** HTTP status code */
237
+ status?: number;
238
+ /** Request headers */
239
+ requestHeaders?: Record<string, string>;
240
+ /** Response headers */
241
+ responseHeaders?: Record<string, string>;
242
+ /** Request body */
243
+ requestBody?: any;
244
+ /** Response body */
245
+ responseBody?: any;
246
+ /** Request start timestamp */
247
+ startTime: number;
248
+ /** Request end timestamp */
249
+ endTime?: number;
250
+ /** Request duration in ms */
251
+ duration?: number;
252
+ /** Error message if request failed */
253
+ error?: string;
254
+ }
255
+ ```
256
+
257
+ ## Use Cases
258
+
259
+ ### API Debugging
260
+
261
+ Monitor all API calls to your backend:
262
+
263
+ ```typescript
264
+ import { networkToolPreset } from '@buoy/network';
265
+
266
+ // Add to your dev tools
267
+ const installedApps = [networkToolPreset];
268
+
269
+ // Now you can:
270
+ // - See all API requests in real-time
271
+ // - Inspect request/response payloads
272
+ // - Check response times
273
+ // - Debug failed requests
274
+ ```
275
+
276
+ ### Performance Monitoring
277
+
278
+ Track slow network requests:
279
+
280
+ ```typescript
281
+ import { useNetworkEvents } from '@buoy/network';
282
+
283
+ function PerformanceMonitor() {
284
+ const { events } = useNetworkEvents();
285
+
286
+ const slowRequests = events.filter(e => e.duration && e.duration > 1000);
287
+
288
+ return (
289
+ <View>
290
+ <Text>Slow Requests: {slowRequests.length}</Text>
291
+ {slowRequests.map(req => (
292
+ <Text key={req.id}>
293
+ {req.url} took {req.duration}ms
294
+ </Text>
295
+ ))}
296
+ </View>
297
+ );
298
+ }
299
+ ```
300
+
301
+ ### Request Filtering
302
+
303
+ Filter requests by specific criteria:
304
+
305
+ ```typescript
306
+ // In the Network Modal UI:
307
+ // - Filter by status code (200, 404, 500, etc.)
308
+ // - Filter by HTTP method (GET, POST, PUT, DELETE)
309
+ // - Search by URL pattern
310
+ // - Filter by success/error state
311
+ ```
312
+
313
+ ## Features in Detail
314
+
315
+ ### Network Interception
316
+
317
+ The package automatically intercepts:
318
+ - `fetch()` calls
319
+ - `XMLHttpRequest` calls
320
+ - All HTTP methods (GET, POST, PUT, DELETE, PATCH, etc.)
321
+
322
+ ### Request Details
323
+
324
+ For each request, you can view:
325
+ - Full URL and query parameters
326
+ - HTTP method and status code
327
+ - Request and response headers
328
+ - Request and response bodies
329
+ - Timing information (duration, timestamps)
330
+ - Error details if the request failed
331
+
332
+ ### Filtering & Search
333
+
334
+ - **By Status**: Filter by HTTP status codes
335
+ - **By Method**: Filter by HTTP method
336
+ - **By URL**: Search through request URLs
337
+ - **By State**: Filter successful, pending, or failed requests
338
+
339
+ ### Performance Tracking
340
+
341
+ - View request duration
342
+ - Identify slow requests
343
+ - Monitor request timing
344
+ - Track request count
345
+
346
+ ## Dependencies
347
+
348
+ - `@buoy/shared-ui` - Common UI components and utilities
349
+ - React and React Native (peer dependencies)
350
+
351
+ ## Development
352
+
353
+ ### Building
354
+
355
+ ```bash
356
+ pnpm build
357
+ ```
358
+
359
+ ### Type Checking
360
+
361
+ ```bash
362
+ pnpm typecheck
363
+ ```
364
+
365
+ ### Clean Build
366
+
367
+ ```bash
368
+ pnpm clean
369
+ ```
370
+
371
+ ## License
372
+
373
+ MIT
374
+
375
+ ## Contributing
376
+
377
+ See the main repository [CONTRIBUTING.md](../../CONTRIBUTING.md) for contribution guidelines.
378
+
379
+ ## Support
380
+
381
+ For issues and feature requests, please visit the [GitHub repository](https://github.com/LovesWorking/react-native-buoy/issues).
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ networkToolPreset: true,
8
+ createNetworkTool: true
9
+ };
10
+ Object.defineProperty(exports, "createNetworkTool", {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _preset.createNetworkTool;
14
+ }
15
+ });
16
+ Object.defineProperty(exports, "networkToolPreset", {
17
+ enumerable: true,
18
+ get: function () {
19
+ return _preset.networkToolPreset;
20
+ }
21
+ });
22
+ var _preset = require("./preset");
23
+ var _network = require("./network");
24
+ Object.keys(_network).forEach(function (key) {
25
+ if (key === "default" || key === "__esModule") return;
26
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
27
+ if (key in exports && exports[key] === _network[key]) return;
28
+ Object.defineProperty(exports, key, {
29
+ enumerable: true,
30
+ get: function () {
31
+ return _network[key];
32
+ }
33
+ });
34
+ });