@buoy-gg/network 7.0.15 → 7.0.16

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 (107) hide show
  1. package/lib/commonjs/index.web.js +395 -0
  2. package/lib/commonjs/network/components/DataViewer.web.js +879 -0
  3. package/lib/commonjs/network/components/NetworkCopyScreen.web.js +48 -0
  4. package/lib/commonjs/network/components/NetworkCopySettingsView.web.js +1242 -0
  5. package/lib/commonjs/network/components/NetworkDetailScreen.web.js +101 -0
  6. package/lib/commonjs/network/components/NetworkDetailStepper.web.js +296 -0
  7. package/lib/commonjs/network/components/NetworkEventDetailView.web.js +1498 -0
  8. package/lib/commonjs/network/components/NetworkEventItemCompact.web.js +802 -0
  9. package/lib/commonjs/network/components/NetworkFilterScreen.web.js +55 -0
  10. package/lib/commonjs/network/components/NetworkFilterViewV3.web.js +1310 -0
  11. package/lib/commonjs/network/components/NetworkHeaderLive.web.js +604 -0
  12. package/lib/commonjs/network/components/NetworkListScreen.js +2 -1
  13. package/lib/commonjs/network/components/NetworkListScreen.web.js +607 -0
  14. package/lib/commonjs/network/components/NetworkModal.js +12 -3
  15. package/lib/commonjs/network/components/NetworkNumberPrompt.web.js +232 -0
  16. package/lib/commonjs/network/components/NetworkOverrideEditor.web.js +942 -0
  17. package/lib/commonjs/network/components/NetworkOverrideHeaderButton.web.js +133 -0
  18. package/lib/commonjs/network/components/NetworkOverridesButton.web.js +143 -0
  19. package/lib/commonjs/network/components/NetworkOverridesScreen.js +160 -126
  20. package/lib/commonjs/network/components/NetworkOverridesScreen.web.js +830 -0
  21. package/lib/commonjs/network/components/NetworkSavedScreen.web.js +459 -0
  22. package/lib/commonjs/network/components/response-editor/Explorer.web.js +1136 -0
  23. package/lib/commonjs/network/hooks/useNetworkEventList.js +12 -2
  24. package/lib/commonjs/network/overrides/applyToXhr.js +276 -15
  25. package/lib/commonjs/network/utils/generateNetworkCopyText.js +32 -5
  26. package/lib/commonjs/network/utils/networkEventStore.js +12 -4
  27. package/lib/commonjs/network/utils/networkListener.js +1 -16
  28. package/lib/module/index.web.js +81 -0
  29. package/lib/module/network/components/DataViewer.web.js +875 -0
  30. package/lib/module/network/components/NetworkCopyScreen.web.js +44 -0
  31. package/lib/module/network/components/NetworkCopySettingsView.web.js +1237 -0
  32. package/lib/module/network/components/NetworkDetailScreen.web.js +97 -0
  33. package/lib/module/network/components/NetworkDetailStepper.web.js +294 -0
  34. package/lib/module/network/components/NetworkEventDetailView.web.js +1496 -0
  35. package/lib/module/network/components/NetworkEventItemCompact.web.js +800 -0
  36. package/lib/module/network/components/NetworkFilterScreen.web.js +51 -0
  37. package/lib/module/network/components/NetworkFilterViewV3.web.js +1306 -0
  38. package/lib/module/network/components/NetworkHeaderLive.web.js +598 -0
  39. package/lib/module/network/components/NetworkListScreen.js +2 -1
  40. package/lib/module/network/components/NetworkListScreen.web.js +605 -0
  41. package/lib/module/network/components/NetworkModal.js +12 -3
  42. package/lib/module/network/components/NetworkNumberPrompt.web.js +230 -0
  43. package/lib/module/network/components/NetworkOverrideEditor.web.js +939 -0
  44. package/lib/module/network/components/NetworkOverrideHeaderButton.web.js +131 -0
  45. package/lib/module/network/components/NetworkOverridesButton.web.js +141 -0
  46. package/lib/module/network/components/NetworkOverridesScreen.js +161 -127
  47. package/lib/module/network/components/NetworkOverridesScreen.web.js +826 -0
  48. package/lib/module/network/components/NetworkSavedScreen.web.js +457 -0
  49. package/lib/module/network/components/response-editor/Explorer.web.js +1133 -0
  50. package/lib/module/network/hooks/useNetworkEventList.js +12 -2
  51. package/lib/module/network/overrides/applyToXhr.js +275 -15
  52. package/lib/module/network/utils/generateNetworkCopyText.js +28 -1
  53. package/lib/module/network/utils/networkEventStore.js +12 -4
  54. package/lib/module/network/utils/networkListener.js +1 -16
  55. package/lib/typescript/index.web.d.ts +56 -0
  56. package/lib/typescript/index.web.d.ts.map +1 -0
  57. package/lib/typescript/network/components/DataViewer.web.d.ts +78 -0
  58. package/lib/typescript/network/components/DataViewer.web.d.ts.map +1 -0
  59. package/lib/typescript/network/components/NetworkCopyScreen.web.d.ts +27 -0
  60. package/lib/typescript/network/components/NetworkCopyScreen.web.d.ts.map +1 -0
  61. package/lib/typescript/network/components/NetworkCopySettingsView.web.d.ts +68 -0
  62. package/lib/typescript/network/components/NetworkCopySettingsView.web.d.ts.map +1 -0
  63. package/lib/typescript/network/components/NetworkDetailScreen.web.d.ts +45 -0
  64. package/lib/typescript/network/components/NetworkDetailScreen.web.d.ts.map +1 -0
  65. package/lib/typescript/network/components/NetworkDetailStepper.web.d.ts +40 -0
  66. package/lib/typescript/network/components/NetworkDetailStepper.web.d.ts.map +1 -0
  67. package/lib/typescript/network/components/NetworkEventDetailView.web.d.ts +67 -0
  68. package/lib/typescript/network/components/NetworkEventDetailView.web.d.ts.map +1 -0
  69. package/lib/typescript/network/components/NetworkEventItemCompact.web.d.ts +58 -0
  70. package/lib/typescript/network/components/NetworkEventItemCompact.web.d.ts.map +1 -0
  71. package/lib/typescript/network/components/NetworkFilterScreen.web.d.ts +28 -0
  72. package/lib/typescript/network/components/NetworkFilterScreen.web.d.ts.map +1 -0
  73. package/lib/typescript/network/components/NetworkFilterViewV3.web.d.ts +74 -0
  74. package/lib/typescript/network/components/NetworkFilterViewV3.web.d.ts.map +1 -0
  75. package/lib/typescript/network/components/NetworkHeaderLive.web.d.ts +112 -0
  76. package/lib/typescript/network/components/NetworkHeaderLive.web.d.ts.map +1 -0
  77. package/lib/typescript/network/components/NetworkListScreen.d.ts.map +1 -1
  78. package/lib/typescript/network/components/NetworkListScreen.web.d.ts +63 -0
  79. package/lib/typescript/network/components/NetworkListScreen.web.d.ts.map +1 -0
  80. package/lib/typescript/network/components/NetworkModal.d.ts.map +1 -1
  81. package/lib/typescript/network/components/NetworkNumberPrompt.web.d.ts +38 -0
  82. package/lib/typescript/network/components/NetworkNumberPrompt.web.d.ts.map +1 -0
  83. package/lib/typescript/network/components/NetworkOverrideEditor.web.d.ts +43 -0
  84. package/lib/typescript/network/components/NetworkOverrideEditor.web.d.ts.map +1 -0
  85. package/lib/typescript/network/components/NetworkOverrideHeaderButton.web.d.ts +32 -0
  86. package/lib/typescript/network/components/NetworkOverrideHeaderButton.web.d.ts.map +1 -0
  87. package/lib/typescript/network/components/NetworkOverridesButton.web.d.ts +26 -0
  88. package/lib/typescript/network/components/NetworkOverridesButton.web.d.ts.map +1 -0
  89. package/lib/typescript/network/components/NetworkOverridesScreen.d.ts +9 -0
  90. package/lib/typescript/network/components/NetworkOverridesScreen.d.ts.map +1 -1
  91. package/lib/typescript/network/components/NetworkOverridesScreen.web.d.ts +69 -0
  92. package/lib/typescript/network/components/NetworkOverridesScreen.web.d.ts.map +1 -0
  93. package/lib/typescript/network/components/NetworkSavedScreen.web.d.ts +67 -0
  94. package/lib/typescript/network/components/NetworkSavedScreen.web.d.ts.map +1 -0
  95. package/lib/typescript/network/components/response-editor/Explorer.web.d.ts +56 -0
  96. package/lib/typescript/network/components/response-editor/Explorer.web.d.ts.map +1 -0
  97. package/lib/typescript/network/hooks/useNetworkEventList.d.ts +10 -0
  98. package/lib/typescript/network/hooks/useNetworkEventList.d.ts.map +1 -1
  99. package/lib/typescript/network/overrides/__tests__/applyToXhr.test.d.ts.map +1 -1
  100. package/lib/typescript/network/overrides/applyToXhr.d.ts +40 -14
  101. package/lib/typescript/network/overrides/applyToXhr.d.ts.map +1 -1
  102. package/lib/typescript/network/utils/generateNetworkCopyText.d.ts +34 -1
  103. package/lib/typescript/network/utils/generateNetworkCopyText.d.ts.map +1 -1
  104. package/lib/typescript/network/utils/networkEventStore.d.ts.map +1 -1
  105. package/lib/typescript/network/utils/networkListener.d.ts +0 -1
  106. package/lib/typescript/network/utils/networkListener.d.ts.map +1 -1
  107. package/package.json +2 -2
@@ -0,0 +1,800 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * NetworkEventItemCompact.web — DOM twin of NetworkEventItemCompact.tsx.
5
+ *
6
+ * Same row layout, prop contract, memoization and display logic as the native
7
+ * file: method badge + size indicators on the left, 2-line URL / GraphQL
8
+ * operation display in the middle (via the SAME pure `formatGraphQLDisplay`
9
+ * util), content-type badge + chevron on the right, absolute-positioned
10
+ * status/client chips top-right and duration/relative-time bottom-right, and
11
+ * the pinned/saved/overridden glyphs.
12
+ *
13
+ * Web consumers resolve `@buoy-gg/shared-ui` to a minimal shim (storage +
14
+ * JsModal + ignored-pattern helpers only), so the RN-only chrome the native
15
+ * row imports from shared-ui is replicated here as DOM with provenance:
16
+ * - `DevToolsCard` / `MethodBadge` / `TypeBadge` — inlined DOM twins, values
17
+ * copied from shared/src/ui/components/DevToolsCard.tsx and Badge.tsx
18
+ * (buoyColors palette inlined below).
19
+ * - `macOSColors` — inlined verbatim subset from
20
+ * shared/src/ui/gameUI/constants/macOSDesignSystemColors.ts.
21
+ * - Icons — inline lucide SVGs (shared-ui's icons are lucide re-exports,
22
+ * 24×24 viewBox, strokeWidth 2).
23
+ * - `formatBytes` / `formatDuration` — copied verbatim from
24
+ * shared/src/utils/formatting/dataFormatting.ts (not in the web shim).
25
+ * - `formatRelativeTime` — copied verbatim from
26
+ * shared/src/utils/time/formatRelativeTime.ts.
27
+ *
28
+ * Intentional deviations (all logged):
29
+ * - `useTickEveryMinute` (shared-ui TickProvider context, 5s interval as
30
+ * mounted by NetworkModal) is replaced by a module-level shared 5s interval
31
+ * hook — the shim exposes no `useTick`, and one shared timer keeps the
32
+ * native "one clock for all rows" behavior.
33
+ * - `onLongPress` (pin toggle) fires after a 500ms pointer hold — the native
34
+ * TouchableOpacity default `delayLongPress`. The click that follows a long
35
+ * press is swallowed, matching native semantics.
36
+ * - `activeOpacity={0.8}` press feedback is a pointer-driven opacity state.
37
+ * - `numberOfLines={2}` → `-webkit-line-clamp: 2`.
38
+ * - The duration/relative-time separator is two literal spaces natively;
39
+ * `white-space: pre` preserves them (HTML would collapse to one).
40
+ *
41
+ * @platform React DOM Web
42
+ */
43
+
44
+ import { memo, useEffect, useState, useRef } from "react";
45
+ import { formatGraphQLDisplay } from "../utils/formatGraphQLVariables";
46
+
47
+ // =============================
48
+ // Native palettes (provenance)
49
+ // =============================
50
+
51
+ /** macOSColors subset — shared/src/ui/gameUI/constants/macOSDesignSystemColors.ts, verbatim. */
52
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
53
+ const macOSColors = {
54
+ text: {
55
+ primary: "#F5F5F7",
56
+ secondary: "#A1A1A6",
57
+ muted: "#8E8E93"
58
+ },
59
+ semantic: {
60
+ success: "#34C759",
61
+ error: "#FF453A",
62
+ warning: "#FFEB3B",
63
+ info: "#00B8E6",
64
+ debug: "#BF5AF2"
65
+ }
66
+ };
67
+
68
+ /** buoyColors subset — shared/src/ui/gameUI/constants/gameUIColors.ts (macOS theme), verbatim. */
69
+ const buoy = {
70
+ card: "#1A1A1A",
71
+ border: "#333333",
72
+ primary: "#20C997",
73
+ // Buoy teal (success/primary are the same value)
74
+ success: "#20C997",
75
+ warning: "#FFA94D",
76
+ error: "#EF4444",
77
+ textSecondary: "#A0A0A0",
78
+ textMuted: "#888888"
79
+ };
80
+
81
+ // =============================
82
+ // Inline lucide icons (shared-ui icons are lucide re-exports)
83
+ // =============================
84
+
85
+ function Svg({
86
+ size = 14,
87
+ color = "currentColor",
88
+ children
89
+ }) {
90
+ return /*#__PURE__*/_jsx("svg", {
91
+ width: size,
92
+ height: size,
93
+ viewBox: "0 0 24 24",
94
+ fill: "none",
95
+ stroke: color,
96
+ strokeWidth: 2,
97
+ strokeLinecap: "round",
98
+ strokeLinejoin: "round",
99
+ style: {
100
+ flexShrink: 0,
101
+ display: "block"
102
+ },
103
+ children: children
104
+ });
105
+ }
106
+ const ChevronRight = p => /*#__PURE__*/_jsx(Svg, {
107
+ ...p,
108
+ children: /*#__PURE__*/_jsx("path", {
109
+ d: "m9 18 6-6-6-6"
110
+ })
111
+ });
112
+ const Upload = p => /*#__PURE__*/_jsxs(Svg, {
113
+ ...p,
114
+ children: [/*#__PURE__*/_jsx("path", {
115
+ d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"
116
+ }), /*#__PURE__*/_jsx("polyline", {
117
+ points: "17 8 12 3 7 8"
118
+ }), /*#__PURE__*/_jsx("line", {
119
+ x1: "12",
120
+ x2: "12",
121
+ y1: "3",
122
+ y2: "15"
123
+ })]
124
+ });
125
+ const Download = p => /*#__PURE__*/_jsxs(Svg, {
126
+ ...p,
127
+ children: [/*#__PURE__*/_jsx("path", {
128
+ d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"
129
+ }), /*#__PURE__*/_jsx("polyline", {
130
+ points: "7 10 12 15 17 10"
131
+ }), /*#__PURE__*/_jsx("line", {
132
+ x1: "12",
133
+ x2: "12",
134
+ y1: "15",
135
+ y2: "3"
136
+ })]
137
+ });
138
+ const Clock = p => /*#__PURE__*/_jsxs(Svg, {
139
+ ...p,
140
+ children: [/*#__PURE__*/_jsx("circle", {
141
+ cx: "12",
142
+ cy: "12",
143
+ r: "10"
144
+ }), /*#__PURE__*/_jsx("polyline", {
145
+ points: "12 6 12 12 16 14"
146
+ })]
147
+ });
148
+ const AlertCircle = p => /*#__PURE__*/_jsxs(Svg, {
149
+ ...p,
150
+ children: [/*#__PURE__*/_jsx("circle", {
151
+ cx: "12",
152
+ cy: "12",
153
+ r: "10"
154
+ }), /*#__PURE__*/_jsx("line", {
155
+ x1: "12",
156
+ x2: "12",
157
+ y1: "8",
158
+ y2: "12"
159
+ }), /*#__PURE__*/_jsx("line", {
160
+ x1: "12",
161
+ x2: "12.01",
162
+ y1: "16",
163
+ y2: "16"
164
+ })]
165
+ });
166
+ const Bookmark = p => /*#__PURE__*/_jsx(Svg, {
167
+ ...p,
168
+ children: /*#__PURE__*/_jsx("path", {
169
+ d: "m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z"
170
+ })
171
+ });
172
+ const FlaskConical = p => /*#__PURE__*/_jsxs(Svg, {
173
+ ...p,
174
+ children: [/*#__PURE__*/_jsx("path", {
175
+ d: "M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2"
176
+ }), /*#__PURE__*/_jsx("path", {
177
+ d: "M8.5 2h7"
178
+ }), /*#__PURE__*/_jsx("path", {
179
+ d: "M7 16h10"
180
+ })]
181
+ });
182
+ const Pin = p => /*#__PURE__*/_jsxs(Svg, {
183
+ ...p,
184
+ children: [/*#__PURE__*/_jsx("path", {
185
+ d: "M12 17v5"
186
+ }), /*#__PURE__*/_jsx("path", {
187
+ d: "M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1z"
188
+ })]
189
+ });
190
+
191
+ // =============================
192
+ // Shared formatters (provenance copies — not in the web shim)
193
+ // =============================
194
+
195
+ /** shared/src/utils/formatting/dataFormatting.ts — verbatim. */
196
+ function formatBytes(bytes) {
197
+ if (bytes === undefined || bytes === null) return "N/A";
198
+ if (bytes === 0) return "0 B";
199
+ const k = 1024;
200
+ const sizes = ["B", "KB", "MB", "GB", "TB"];
201
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
202
+ return `${(bytes / Math.pow(k, i)).toFixed(1)} ${sizes[i]}`;
203
+ }
204
+
205
+ /** shared/src/utils/formatting/dataFormatting.ts — verbatim. */
206
+ function formatDuration(ms) {
207
+ if (ms === undefined || ms === null) return "N/A";
208
+ if (ms < 1000) {
209
+ return `${ms}ms`;
210
+ }
211
+ if (ms < 60000) {
212
+ return `${(ms / 1000).toFixed(1)}s`;
213
+ }
214
+ if (ms < 3600000) {
215
+ const minutes = Math.floor(ms / 60000);
216
+ const seconds = Math.floor(ms % 60000 / 1000);
217
+ return seconds > 0 ? `${minutes}m ${seconds}s` : `${minutes}m`;
218
+ }
219
+ const hours = Math.floor(ms / 3600000);
220
+ const minutes = Math.floor(ms % 3600000 / 60000);
221
+ return minutes > 0 ? `${hours}h ${minutes}m` : `${hours}h`;
222
+ }
223
+
224
+ /** shared/src/utils/time/formatRelativeTime.ts — verbatim. */
225
+ function formatRelativeTime(timestamp, currentTime = Date.now()) {
226
+ const timestampMs = timestamp instanceof Date ? timestamp.getTime() : timestamp;
227
+ const seconds = Math.floor((currentTime - timestampMs) / 1000);
228
+ if (seconds < 0) {
229
+ return "just now";
230
+ }
231
+ if (seconds < 60) {
232
+ return seconds === 0 ? "just now" : `${seconds}s ago`;
233
+ }
234
+ const minutes = Math.floor(seconds / 60);
235
+ if (minutes < 60) {
236
+ return `${minutes}m ago`;
237
+ }
238
+ const hours = Math.floor(minutes / 60);
239
+ if (hours < 24) {
240
+ return `${hours}h ago`;
241
+ }
242
+ const days = Math.floor(hours / 24);
243
+ return `${days}d ago`;
244
+ }
245
+
246
+ // =============================
247
+ // Shared tick (DEVIATION: replaces shared-ui TickProvider/useTick)
248
+ // =============================
249
+
250
+ /**
251
+ * One module-level 5s clock shared by every mounted row — the same cadence the
252
+ * native rows get from NetworkModal's `TickProvider` (default `intervalMs`
253
+ * 5_000). The interval only runs while at least one row is mounted.
254
+ */
255
+ const tickListeners = new Set();
256
+ let tickInterval = null;
257
+ function subscribeTick(listener) {
258
+ tickListeners.add(listener);
259
+ if (tickInterval == null) {
260
+ tickInterval = setInterval(() => {
261
+ const now = Date.now();
262
+ tickListeners.forEach(l => l(now));
263
+ }, 5_000);
264
+ }
265
+ return () => {
266
+ tickListeners.delete(listener);
267
+ if (tickListeners.size === 0 && tickInterval != null) {
268
+ clearInterval(tickInterval);
269
+ tickInterval = null;
270
+ }
271
+ };
272
+ }
273
+ function useSharedTick() {
274
+ const [tick, setTick] = useState(() => Date.now());
275
+ useEffect(() => subscribeTick(setTick), []);
276
+ return tick;
277
+ }
278
+
279
+ // =============================
280
+ // Pure display helpers (copied verbatim from the native file)
281
+ // =============================
282
+
283
+ // Get color based on status
284
+ function getStatusColor(status, error) {
285
+ if (error) return macOSColors.semantic.error;
286
+ if (!status) return macOSColors.semantic.warning;
287
+ if (status >= 200 && status < 300) return macOSColors.semantic.success;
288
+ if (status >= 300 && status < 400) return macOSColors.semantic.info;
289
+ if (status >= 400) return macOSColors.semantic.error;
290
+ return macOSColors.text.muted;
291
+ }
292
+
293
+ // Get content type badge with color
294
+ function getContentTypeBadge(headers) {
295
+ const contentType = headers?.["content-type"] || headers?.["Content-Type"] || "";
296
+ if (contentType.includes("json")) return "JSON";
297
+ if (contentType.includes("xml")) return "XML";
298
+ if (contentType.includes("html")) return "HTML";
299
+ if (contentType.includes("text")) return "TEXT";
300
+ if (contentType.includes("image")) return "IMG";
301
+ if (contentType.includes("video")) return "VIDEO";
302
+ if (contentType.includes("audio")) return "AUDIO";
303
+ if (contentType.includes("form")) return "FORM";
304
+ return null;
305
+ }
306
+
307
+ /**
308
+ * The transport chip (`fetch` / `GQL` / `gRPC` / `XHR`), one brand colour each.
309
+ */
310
+ function getClientChipColors(requestClient) {
311
+ switch (requestClient) {
312
+ case "fetch":
313
+ return {
314
+ backgroundColor: "rgba(74, 144, 226, 0.15)",
315
+ color: "#4A90E2"
316
+ };
317
+ case "graphql":
318
+ return {
319
+ backgroundColor: "rgba(229, 53, 171, 0.15)",
320
+ color: "#E535AB"
321
+ };
322
+ case "grpc-web":
323
+ return {
324
+ backgroundColor: "rgba(16, 185, 129, 0.15)",
325
+ color: "#10B981"
326
+ };
327
+ case "xhr":
328
+ return {
329
+ backgroundColor: "rgba(245, 158, 11, 0.15)",
330
+ color: "#F59E0B"
331
+ };
332
+ default:
333
+ return {
334
+ backgroundColor: "rgba(147, 51, 234, 0.15)",
335
+ color: "#9333EA"
336
+ };
337
+ }
338
+ }
339
+
340
+ // =============================
341
+ // shared-ui DOM twins (provenance: Badge.tsx / DevToolsCard.tsx)
342
+ // =============================
343
+
344
+ /**
345
+ * MethodBadge twin — shared/src/ui/components/Badge.tsx `MethodBadge`
346
+ * (`size="small"`: 6/2 padding, 11px, weight 700, minWidth 45, `${color}15`
347
+ * fill, `${color}40` border, radius 4). METHOD_COLORS map, verbatim.
348
+ */
349
+ const METHOD_COLORS = {
350
+ GET: buoy.success,
351
+ POST: buoy.primary,
352
+ PUT: buoy.warning,
353
+ PATCH: buoy.textSecondary,
354
+ DELETE: buoy.error,
355
+ HEAD: buoy.textMuted,
356
+ OPTIONS: buoy.primary
357
+ };
358
+ function MethodBadgeWeb({
359
+ method
360
+ }) {
361
+ const color = METHOD_COLORS[method.toUpperCase()] || "#6B7280";
362
+ return /*#__PURE__*/_jsx("span", {
363
+ style: {
364
+ display: "inline-flex",
365
+ alignItems: "center",
366
+ justifyContent: "center",
367
+ minWidth: 45,
368
+ boxSizing: "border-box",
369
+ padding: "2px 6px",
370
+ fontSize: 11,
371
+ fontWeight: 700,
372
+ color,
373
+ backgroundColor: `${color}15`,
374
+ border: `1px solid ${color}40`,
375
+ borderRadius: 4
376
+ },
377
+ children: method.toUpperCase()
378
+ });
379
+ }
380
+
381
+ /**
382
+ * TypeBadge twin — shared/src/ui/components/Badge.tsx `TypeBadge`
383
+ * (`size="small"`). Content types ("JSON" etc.) are not in `getTypeColor`'s
384
+ * map, so they all resolve to `buoyColors.textMuted` — same as native.
385
+ */
386
+ function TypeBadgeWeb({
387
+ type
388
+ }) {
389
+ const color = buoy.textMuted;
390
+ return /*#__PURE__*/_jsx("span", {
391
+ style: {
392
+ display: "inline-flex",
393
+ alignItems: "center",
394
+ padding: "2px 6px",
395
+ fontSize: 11,
396
+ fontWeight: 600,
397
+ color,
398
+ backgroundColor: `${color}15`,
399
+ border: `1px solid ${color}40`,
400
+ borderRadius: 4
401
+ },
402
+ children: type
403
+ });
404
+ }
405
+
406
+ /**
407
+ * DevToolsCard twin — shared/src/ui/components/DevToolsCard.tsx. Wrapper
408
+ * margin 4px vertical (the native row overrides horizontal to 8), card =
409
+ * buoyColors.card fill, `${border}40` outline + bottom hairline, radius 8,
410
+ * padding 12, minHeight 44, activeOpacity 0.8. Long-press = 500ms pointer
411
+ * hold (TouchableOpacity default delayLongPress) — see file header.
412
+ */
413
+ function DevToolsCardWeb({
414
+ onPress,
415
+ onLongPress,
416
+ children,
417
+ contentStyle
418
+ }) {
419
+ const [pressed, setPressed] = useState(false);
420
+ const longPressTimer = useRef(null);
421
+ const longPressFired = useRef(false);
422
+ const clearTimer = () => {
423
+ if (longPressTimer.current != null) {
424
+ clearTimeout(longPressTimer.current);
425
+ longPressTimer.current = null;
426
+ }
427
+ };
428
+ return /*#__PURE__*/_jsx("div", {
429
+ style: {
430
+ margin: "4px 8px"
431
+ },
432
+ children: /*#__PURE__*/_jsx("button", {
433
+ type: "button",
434
+ onPointerDown: () => {
435
+ setPressed(true);
436
+ if (onLongPress) {
437
+ longPressFired.current = false;
438
+ clearTimer();
439
+ longPressTimer.current = setTimeout(() => {
440
+ longPressFired.current = true;
441
+ onLongPress();
442
+ }, 500);
443
+ }
444
+ },
445
+ onPointerUp: () => {
446
+ setPressed(false);
447
+ clearTimer();
448
+ },
449
+ onPointerLeave: () => {
450
+ setPressed(false);
451
+ clearTimer();
452
+ },
453
+ onPointerCancel: () => {
454
+ setPressed(false);
455
+ clearTimer();
456
+ },
457
+ onClick: () => {
458
+ // A long press toggles the pin; it must not ALSO open the detail.
459
+ if (longPressFired.current) {
460
+ longPressFired.current = false;
461
+ return;
462
+ }
463
+ onPress();
464
+ },
465
+ style: {
466
+ position: "relative",
467
+ display: "flex",
468
+ width: "100%",
469
+ boxSizing: "border-box",
470
+ backgroundColor: buoy.card,
471
+ borderRadius: 8,
472
+ border: `1px solid ${buoy.border}40`,
473
+ borderBottom: `1px solid ${buoy.border}40`,
474
+ padding: 12,
475
+ minHeight: 44,
476
+ margin: 0,
477
+ textAlign: "left",
478
+ cursor: "pointer",
479
+ fontFamily: "inherit",
480
+ color: "inherit",
481
+ userSelect: "none",
482
+ WebkitUserSelect: "none",
483
+ opacity: pressed ? 0.8 : 1,
484
+ ...contentStyle
485
+ },
486
+ children: children
487
+ })
488
+ });
489
+ }
490
+
491
+ // =============================
492
+ // Row (structure mirrors the native file 1:1)
493
+ // =============================
494
+
495
+ // Status indicator component - single responsibility
496
+ function StatusIndicator({
497
+ event,
498
+ isPending,
499
+ statusColor
500
+ }) {
501
+ if (isPending) {
502
+ return /*#__PURE__*/_jsxs("span", {
503
+ style: styles.pendingBadge,
504
+ children: [/*#__PURE__*/_jsx(Clock, {
505
+ size: 10,
506
+ color: macOSColors.semantic.warning
507
+ }), /*#__PURE__*/_jsx("span", {
508
+ style: styles.pendingText,
509
+ children: "..."
510
+ })]
511
+ });
512
+ }
513
+ if (event.error) {
514
+ return /*#__PURE__*/_jsxs("span", {
515
+ style: styles.errorBadge,
516
+ children: [/*#__PURE__*/_jsx(AlertCircle, {
517
+ size: 10,
518
+ color: macOSColors.semantic.error
519
+ }), /*#__PURE__*/_jsx("span", {
520
+ style: styles.errorText,
521
+ children: "ERR"
522
+ })]
523
+ });
524
+ }
525
+ return /*#__PURE__*/_jsx("span", {
526
+ style: styles.statusBadge,
527
+ children: /*#__PURE__*/_jsx("span", {
528
+ style: {
529
+ ...styles.statusText,
530
+ color: statusColor
531
+ },
532
+ children: String(event.status)
533
+ })
534
+ });
535
+ }
536
+
537
+ // Size indicators component - single responsibility
538
+ function SizeIndicators({
539
+ requestSize,
540
+ responseSize
541
+ }) {
542
+ if (!requestSize && !responseSize) return null;
543
+ return /*#__PURE__*/_jsxs("span", {
544
+ style: styles.sizeRow,
545
+ children: [requestSize ? /*#__PURE__*/_jsxs("span", {
546
+ style: styles.sizeItem,
547
+ children: [/*#__PURE__*/_jsx(Upload, {
548
+ size: 8,
549
+ color: macOSColors.semantic.info
550
+ }), /*#__PURE__*/_jsx("span", {
551
+ style: styles.sizeText,
552
+ children: formatBytes(requestSize)
553
+ })]
554
+ }) : null, responseSize ? /*#__PURE__*/_jsxs("span", {
555
+ style: styles.sizeItem,
556
+ children: [/*#__PURE__*/_jsx(Download, {
557
+ size: 8,
558
+ color: macOSColors.semantic.success
559
+ }), /*#__PURE__*/_jsx("span", {
560
+ style: styles.sizeText,
561
+ children: formatBytes(responseSize)
562
+ })]
563
+ }) : null]
564
+ });
565
+ }
566
+
567
+ /**
568
+ * Sole tick consumer in the row (rule2: composition over memo) — the periodic
569
+ * relative-timestamp tick re-renders ONLY this leaf, not the whole card.
570
+ */
571
+ function BottomRightTime({
572
+ timestamp,
573
+ duration
574
+ }) {
575
+ const tick = useSharedTick();
576
+ const relativeTime = formatRelativeTime(timestamp, tick);
577
+ return duration ? /*#__PURE__*/_jsxs("span", {
578
+ style: styles.bottomRightText,
579
+ children: [formatDuration(duration), " ", relativeTime]
580
+ }) : /*#__PURE__*/_jsx("span", {
581
+ style: styles.bottomRightText,
582
+ children: relativeTime
583
+ });
584
+ }
585
+ export const NetworkEventItemCompact = /*#__PURE__*/memo(function NetworkEventItemCompact({
586
+ event,
587
+ onPress,
588
+ pinned = false,
589
+ saved = false,
590
+ overridden = false,
591
+ onLongPress
592
+ }) {
593
+ const statusColor = getStatusColor(event.status, event.error);
594
+ const isPending = !event.status && !event.error;
595
+ const contentType = getContentTypeBadge(event.responseHeaders);
596
+
597
+ // Format URL for display (max 2 lines)
598
+ let displayUrl = event.path || event.url.replace(/^https?:\/\/[^/]+/, "");
599
+
600
+ // If this is a GraphQL request, show operation name with variables using
601
+ // arrow notation (same pure util as native).
602
+ if (event.requestClient === "graphql") {
603
+ if (event.operationName) {
604
+ displayUrl = formatGraphQLDisplay(event.operationName, event.graphqlVariables);
605
+ } else {
606
+ displayUrl = displayUrl.replace(/\/graphql[^?]*/, "/graphql");
607
+ }
608
+ } else if (event.operationName) {
609
+ // For non-GraphQL requests with operation names (e.g., gRPC)
610
+ displayUrl = `${displayUrl}\n(${event.operationName})`;
611
+ }
612
+ return /*#__PURE__*/_jsxs(DevToolsCardWeb, {
613
+ onPress: () => onPress(event),
614
+ onLongPress: onLongPress ? () => onLongPress(event) : undefined,
615
+ contentStyle: {
616
+ flexDirection: "row",
617
+ alignItems: "center",
618
+ borderLeft: `3px solid ${statusColor}`
619
+ },
620
+ children: [/*#__PURE__*/_jsxs("span", {
621
+ style: styles.topRightContainer,
622
+ children: [pinned ? /*#__PURE__*/_jsx(Pin, {
623
+ size: 10,
624
+ color: macOSColors.semantic.info
625
+ }) : null, saved ? /*#__PURE__*/_jsx(Bookmark, {
626
+ size: 10,
627
+ color: macOSColors.semantic.debug
628
+ }) : null, overridden || event.override ? /*#__PURE__*/_jsx(FlaskConical, {
629
+ size: 10,
630
+ color: macOSColors.semantic.warning
631
+ }) : null, /*#__PURE__*/_jsx(StatusIndicator, {
632
+ event: event,
633
+ isPending: isPending,
634
+ statusColor: statusColor
635
+ }), event.requestClient ? /*#__PURE__*/_jsx("span", {
636
+ style: {
637
+ ...styles.topRightBadge,
638
+ backgroundColor: getClientChipColors(event.requestClient).backgroundColor
639
+ },
640
+ children: /*#__PURE__*/_jsx("span", {
641
+ style: {
642
+ ...styles.clientText,
643
+ color: getClientChipColors(event.requestClient).color
644
+ },
645
+ children: event.requestClient === "graphql" ? "GQL" : event.requestClient === "grpc-web" ? "gRPC" : event.requestClient === "xhr" ? "XHR" : event.requestClient
646
+ })
647
+ }) : null]
648
+ }), /*#__PURE__*/_jsxs("span", {
649
+ style: styles.leftSection,
650
+ children: [/*#__PURE__*/_jsx(MethodBadgeWeb, {
651
+ method: event.method
652
+ }), /*#__PURE__*/_jsx(SizeIndicators, {
653
+ requestSize: event.requestSize,
654
+ responseSize: event.responseSize
655
+ })]
656
+ }), /*#__PURE__*/_jsx("span", {
657
+ style: styles.middleSection,
658
+ children: /*#__PURE__*/_jsx("span", {
659
+ style: styles.urlText,
660
+ children: displayUrl
661
+ })
662
+ }), /*#__PURE__*/_jsxs("span", {
663
+ style: styles.rightSection,
664
+ children: [contentType ? /*#__PURE__*/_jsx(TypeBadgeWeb, {
665
+ type: contentType
666
+ }) : null, /*#__PURE__*/_jsx(ChevronRight, {
667
+ size: 14,
668
+ color: macOSColors.text.muted
669
+ })]
670
+ }), /*#__PURE__*/_jsx("span", {
671
+ style: styles.bottomRightContainer,
672
+ children: /*#__PURE__*/_jsx(BottomRightTime, {
673
+ timestamp: event.timestamp,
674
+ duration: event.duration
675
+ })
676
+ })]
677
+ });
678
+ });
679
+ NetworkEventItemCompact.displayName = "NetworkEventItemCompact";
680
+
681
+ // Values mirror the native StyleSheet block 1:1.
682
+ const styles = {
683
+ leftSection: {
684
+ display: "flex",
685
+ flexDirection: "column",
686
+ marginRight: 8,
687
+ alignItems: "flex-start"
688
+ },
689
+ topRightContainer: {
690
+ position: "absolute",
691
+ top: 1,
692
+ right: 1,
693
+ display: "flex",
694
+ flexDirection: "row",
695
+ alignItems: "center",
696
+ gap: 4
697
+ },
698
+ topRightBadge: {
699
+ display: "inline-flex",
700
+ padding: "2px 4px",
701
+ borderRadius: 4
702
+ },
703
+ middleSection: {
704
+ flex: 1,
705
+ minWidth: 0,
706
+ display: "flex",
707
+ flexDirection: "column",
708
+ justifyContent: "center",
709
+ paddingRight: 8
710
+ },
711
+ urlText: {
712
+ fontSize: 12,
713
+ color: macOSColors.text.primary,
714
+ lineHeight: "16px",
715
+ fontFamily: "ui-monospace, Menlo, monospace",
716
+ display: "-webkit-box",
717
+ WebkitLineClamp: 2,
718
+ WebkitBoxOrient: "vertical",
719
+ overflow: "hidden",
720
+ whiteSpace: "pre-wrap",
721
+ wordBreak: "break-all"
722
+ },
723
+ rightSection: {
724
+ display: "flex",
725
+ flexDirection: "row",
726
+ alignItems: "center",
727
+ gap: 6
728
+ },
729
+ bottomRightContainer: {
730
+ position: "absolute",
731
+ bottom: 4,
732
+ right: 8
733
+ },
734
+ bottomRightText: {
735
+ fontSize: 9,
736
+ color: macOSColors.text.muted,
737
+ fontFamily: "ui-monospace, Menlo, monospace",
738
+ whiteSpace: "pre"
739
+ },
740
+ statusBadge: {
741
+ display: "inline-flex",
742
+ padding: "1px 4px",
743
+ borderRadius: 3
744
+ },
745
+ statusText: {
746
+ fontSize: 10,
747
+ fontWeight: 600
748
+ },
749
+ pendingBadge: {
750
+ display: "inline-flex",
751
+ flexDirection: "row",
752
+ alignItems: "center",
753
+ gap: 2,
754
+ padding: "1px 4px",
755
+ backgroundColor: macOSColors.semantic.warning + "26",
756
+ borderRadius: 3
757
+ },
758
+ pendingText: {
759
+ fontSize: 10,
760
+ color: macOSColors.semantic.warning,
761
+ fontWeight: 600
762
+ },
763
+ errorBadge: {
764
+ display: "inline-flex",
765
+ flexDirection: "row",
766
+ alignItems: "center",
767
+ gap: 2,
768
+ padding: "1px 4px",
769
+ backgroundColor: macOSColors.semantic.error + "26",
770
+ borderRadius: 3
771
+ },
772
+ errorText: {
773
+ fontSize: 10,
774
+ color: macOSColors.semantic.error,
775
+ fontWeight: 600
776
+ },
777
+ sizeRow: {
778
+ display: "flex",
779
+ flexDirection: "row",
780
+ gap: 4,
781
+ marginTop: 4
782
+ },
783
+ sizeItem: {
784
+ display: "inline-flex",
785
+ flexDirection: "row",
786
+ alignItems: "center",
787
+ gap: 2
788
+ },
789
+ sizeText: {
790
+ fontSize: 8,
791
+ color: macOSColors.text.secondary,
792
+ fontFamily: "ui-monospace, Menlo, monospace"
793
+ },
794
+ clientText: {
795
+ fontSize: 8,
796
+ fontWeight: 700,
797
+ letterSpacing: 0.3,
798
+ textTransform: "uppercase"
799
+ }
800
+ };