@buoy-gg/network 7.0.41 → 7.0.42

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 (272) hide show
  1. package/README.md +11 -85
  2. package/lib/commonjs/index.js +1 -332
  3. package/lib/commonjs/index.web.js +1 -420
  4. package/lib/commonjs/network/components/DataViewer.web.js +1 -879
  5. package/lib/commonjs/network/components/NetworkCopyScreen.web.js +1 -48
  6. package/lib/commonjs/network/components/NetworkCopySettingsView.js +27 -755
  7. package/lib/commonjs/network/components/NetworkCopySettingsView.web.js +14 -1242
  8. package/lib/commonjs/network/components/NetworkDetailScreen.web.js +1 -101
  9. package/lib/commonjs/network/components/NetworkDetailStepper.js +1 -108
  10. package/lib/commonjs/network/components/NetworkDetailStepper.web.js +1 -298
  11. package/lib/commonjs/network/components/NetworkEventDetailView.js +15 -1130
  12. package/lib/commonjs/network/components/NetworkEventDetailView.web.js +15 -1484
  13. package/lib/commonjs/network/components/NetworkEventItemCompact.js +2 -401
  14. package/lib/commonjs/network/components/NetworkEventItemCompact.web.js +2 -820
  15. package/lib/commonjs/network/components/NetworkFilterScreen.web.js +1 -55
  16. package/lib/commonjs/network/components/NetworkFilterViewV3.js +1 -442
  17. package/lib/commonjs/network/components/NetworkFilterViewV3.web.js +1 -1310
  18. package/lib/commonjs/network/components/NetworkHeaderLive.js +1 -375
  19. package/lib/commonjs/network/components/NetworkHeaderLive.web.js +1 -623
  20. package/lib/commonjs/network/components/NetworkHeaderMenu.js +1 -190
  21. package/lib/commonjs/network/components/NetworkListScreen.js +1 -403
  22. package/lib/commonjs/network/components/NetworkListScreen.web.js +1 -624
  23. package/lib/commonjs/network/components/NetworkModal.js +1 -786
  24. package/lib/commonjs/network/components/NetworkNumberPrompt.js +1 -178
  25. package/lib/commonjs/network/components/NetworkNumberPrompt.web.js +1 -232
  26. package/lib/commonjs/network/components/NetworkOverrideEditor.js +1 -814
  27. package/lib/commonjs/network/components/NetworkOverrideEditor.web.js +1 -942
  28. package/lib/commonjs/network/components/NetworkOverrideHeaderButton.js +1 -107
  29. package/lib/commonjs/network/components/NetworkOverrideHeaderButton.web.js +1 -133
  30. package/lib/commonjs/network/components/NetworkOverridesButton.js +1 -90
  31. package/lib/commonjs/network/components/NetworkOverridesButton.web.js +1 -143
  32. package/lib/commonjs/network/components/NetworkOverridesScreen.js +1 -543
  33. package/lib/commonjs/network/components/NetworkOverridesScreen.web.js +1 -830
  34. package/lib/commonjs/network/components/NetworkSavedScreen.js +1 -226
  35. package/lib/commonjs/network/components/NetworkSavedScreen.web.js +1 -463
  36. package/lib/commonjs/network/components/NetworkUpgradeBanner.js +1 -76
  37. package/lib/commonjs/network/components/response-editor/Explorer.js +1 -973
  38. package/lib/commonjs/network/components/response-editor/Explorer.web.js +1 -1136
  39. package/lib/commonjs/network/components/response-editor/deleteNestedDataByPath.js +1 -56
  40. package/lib/commonjs/network/components/response-editor/editorContext.js +1 -33
  41. package/lib/commonjs/network/components/response-editor/updateNestedDataByPath.js +1 -61
  42. package/lib/commonjs/network/conditions/NetworkConditionsControl.js +1 -235
  43. package/lib/commonjs/network/conditions/NetworkConditionsControl.test.js +1 -136
  44. package/lib/commonjs/network/conditions/NetworkConditionsIcon.js +1 -33
  45. package/lib/commonjs/network/conditions/NetworkFloatingTool.js +1 -310
  46. package/lib/commonjs/network/conditions/NetworkFloatingTool.test.js +1 -219
  47. package/lib/commonjs/network/conditions/store.js +1 -75
  48. package/lib/commonjs/network/conditions/wait.js +1 -43
  49. package/lib/commonjs/network/conditions/xhr.js +1 -135
  50. package/lib/commonjs/network/hooks/useLiveNetworkEvent.js +1 -62
  51. package/lib/commonjs/network/hooks/useNetworkBadgeCounts.js +1 -83
  52. package/lib/commonjs/network/hooks/useNetworkEventList.js +1 -108
  53. package/lib/commonjs/network/hooks/useNetworkEvents.js +1 -318
  54. package/lib/commonjs/network/hooks/useNetworkHasMatches.js +1 -56
  55. package/lib/commonjs/network/hooks/useNetworkSaved.js +1 -38
  56. package/lib/commonjs/network/hooks/useNetworkSelection.js +1 -53
  57. package/lib/commonjs/network/hooks/useOverrideRules.js +1 -36
  58. package/lib/commonjs/network/hooks/useTickEveryMinute.js +1 -21
  59. package/lib/commonjs/network/overrides/applyToFetch.js +1 -80
  60. package/lib/commonjs/network/overrides/applyToXhr.js +2 -510
  61. package/lib/commonjs/network/overrides/engine.js +1 -93
  62. package/lib/commonjs/network/overrides/matchRule.js +1 -87
  63. package/lib/commonjs/network/overrides/overriddenRows.js +1 -37
  64. package/lib/commonjs/network/overrides/overrideRulesStore.js +1 -550
  65. package/lib/commonjs/network/overrides/presets.js +1 -70
  66. package/lib/commonjs/network/overrides/resolveOverride.js +1 -158
  67. package/lib/commonjs/network/overrides/types.js +1 -90
  68. package/lib/commonjs/network/sync/networkBodyResolver.js +1 -39
  69. package/lib/commonjs/network/sync/networkSyncAdapter.js +1 -882
  70. package/lib/commonjs/network/sync/overrideHonesty.release.test.js +1 -36
  71. package/lib/commonjs/network/types/index.js +1 -5
  72. package/lib/commonjs/network/utils/extractOperationName.js +1 -80
  73. package/lib/commonjs/network/utils/filterNetworkEvents.js +1 -96
  74. package/lib/commonjs/network/utils/formatGraphQLVariables.js +1 -219
  75. package/lib/commonjs/network/utils/formatting.js +1 -30
  76. package/lib/commonjs/network/utils/generateCurl.js +2 -71
  77. package/lib/commonjs/network/utils/generateNetworkCopyText.js +37 -166
  78. package/lib/commonjs/network/utils/httpCompletion.js +1 -37
  79. package/lib/commonjs/network/utils/networkEventStore.js +1 -411
  80. package/lib/commonjs/network/utils/networkListener.js +4 -1352
  81. package/lib/commonjs/network/utils/networkSavedStore.js +3 -577
  82. package/lib/commonjs/network/utils/networkSelectionStore.js +1 -193
  83. package/lib/commonjs/network/utils/realNow.js +1 -0
  84. package/lib/commonjs/network/utils/requestId.js +1 -16
  85. package/lib/commonjs/network/utils/resolveRequestUrl.js +1 -15
  86. package/lib/commonjs/network/utils/selectSavedEvents.js +1 -39
  87. package/lib/commonjs/network/utils/startNetworkCapture.js +1 -24
  88. package/lib/commonjs/network/utils/withPinnedFirst.js +1 -32
  89. package/lib/commonjs/preset.js +1 -93
  90. package/lib/module/index.js +1 -104
  91. package/lib/module/index.web.js +1 -82
  92. package/lib/module/network/components/DataViewer.web.js +1 -875
  93. package/lib/module/network/components/NetworkCopyScreen.web.js +1 -44
  94. package/lib/module/network/components/NetworkCopySettingsView.js +27 -750
  95. package/lib/module/network/components/NetworkCopySettingsView.web.js +14 -1237
  96. package/lib/module/network/components/NetworkDetailScreen.web.js +1 -97
  97. package/lib/module/network/components/NetworkDetailStepper.js +1 -104
  98. package/lib/module/network/components/NetworkDetailStepper.web.js +1 -296
  99. package/lib/module/network/components/NetworkEventDetailView.js +15 -1129
  100. package/lib/module/network/components/NetworkEventDetailView.web.js +15 -1482
  101. package/lib/module/network/components/NetworkEventItemCompact.js +2 -398
  102. package/lib/module/network/components/NetworkEventItemCompact.web.js +2 -818
  103. package/lib/module/network/components/NetworkFilterScreen.web.js +1 -51
  104. package/lib/module/network/components/NetworkFilterViewV3.js +1 -438
  105. package/lib/module/network/components/NetworkFilterViewV3.web.js +1 -1306
  106. package/lib/module/network/components/NetworkHeaderLive.js +1 -366
  107. package/lib/module/network/components/NetworkHeaderLive.web.js +1 -617
  108. package/lib/module/network/components/NetworkHeaderMenu.js +1 -184
  109. package/lib/module/network/components/NetworkListScreen.js +1 -399
  110. package/lib/module/network/components/NetworkListScreen.web.js +1 -622
  111. package/lib/module/network/components/NetworkModal.js +1 -781
  112. package/lib/module/network/components/NetworkNumberPrompt.js +1 -174
  113. package/lib/module/network/components/NetworkNumberPrompt.web.js +1 -230
  114. package/lib/module/network/components/NetworkOverrideEditor.js +1 -811
  115. package/lib/module/network/components/NetworkOverrideEditor.web.js +1 -939
  116. package/lib/module/network/components/NetworkOverrideHeaderButton.js +1 -104
  117. package/lib/module/network/components/NetworkOverrideHeaderButton.web.js +1 -131
  118. package/lib/module/network/components/NetworkOverridesButton.js +1 -87
  119. package/lib/module/network/components/NetworkOverridesButton.web.js +1 -141
  120. package/lib/module/network/components/NetworkOverridesScreen.js +1 -539
  121. package/lib/module/network/components/NetworkOverridesScreen.web.js +1 -826
  122. package/lib/module/network/components/NetworkSavedScreen.js +1 -222
  123. package/lib/module/network/components/NetworkSavedScreen.web.js +1 -461
  124. package/lib/module/network/components/NetworkUpgradeBanner.js +1 -72
  125. package/lib/module/network/components/response-editor/Explorer.js +1 -972
  126. package/lib/module/network/components/response-editor/Explorer.web.js +1 -1133
  127. package/lib/module/network/components/response-editor/deleteNestedDataByPath.js +1 -51
  128. package/lib/module/network/components/response-editor/editorContext.js +1 -29
  129. package/lib/module/network/components/response-editor/updateNestedDataByPath.js +1 -56
  130. package/lib/module/network/conditions/NetworkConditionsControl.js +1 -231
  131. package/lib/module/network/conditions/NetworkConditionsControl.test.js +1 -135
  132. package/lib/module/network/conditions/NetworkConditionsIcon.js +1 -29
  133. package/lib/module/network/conditions/NetworkFloatingTool.js +1 -304
  134. package/lib/module/network/conditions/NetworkFloatingTool.test.js +1 -218
  135. package/lib/module/network/conditions/store.js +1 -65
  136. package/lib/module/network/conditions/wait.js +1 -38
  137. package/lib/module/network/conditions/xhr.js +1 -131
  138. package/lib/module/network/hooks/useLiveNetworkEvent.js +1 -58
  139. package/lib/module/network/hooks/useNetworkBadgeCounts.js +1 -79
  140. package/lib/module/network/hooks/useNetworkEventList.js +1 -104
  141. package/lib/module/network/hooks/useNetworkEvents.js +1 -314
  142. package/lib/module/network/hooks/useNetworkHasMatches.js +1 -52
  143. package/lib/module/network/hooks/useNetworkSaved.js +1 -34
  144. package/lib/module/network/hooks/useNetworkSelection.js +1 -46
  145. package/lib/module/network/hooks/useOverrideRules.js +1 -32
  146. package/lib/module/network/hooks/useTickEveryMinute.js +1 -11
  147. package/lib/module/network/overrides/applyToFetch.js +1 -72
  148. package/lib/module/network/overrides/applyToXhr.js +2 -502
  149. package/lib/module/network/overrides/engine.js +1 -85
  150. package/lib/module/network/overrides/matchRule.js +1 -81
  151. package/lib/module/network/overrides/overriddenRows.js +1 -33
  152. package/lib/module/network/overrides/overrideRulesStore.js +1 -547
  153. package/lib/module/network/overrides/presets.js +1 -65
  154. package/lib/module/network/overrides/resolveOverride.js +1 -152
  155. package/lib/module/network/overrides/types.js +1 -86
  156. package/lib/module/network/sync/networkBodyResolver.js +1 -34
  157. package/lib/module/network/sync/networkSyncAdapter.js +1 -880
  158. package/lib/module/network/sync/overrideHonesty.release.test.js +1 -35
  159. package/lib/module/network/types/index.js +1 -3
  160. package/lib/module/network/utils/extractOperationName.js +1 -76
  161. package/lib/module/network/utils/filterNetworkEvents.js +1 -92
  162. package/lib/module/network/utils/formatGraphQLVariables.js +1 -213
  163. package/lib/module/network/utils/formatting.js +1 -9
  164. package/lib/module/network/utils/generateCurl.js +2 -67
  165. package/lib/module/network/utils/generateNetworkCopyText.js +37 -162
  166. package/lib/module/network/utils/httpCompletion.js +1 -32
  167. package/lib/module/network/utils/networkEventStore.js +1 -409
  168. package/lib/module/network/utils/networkListener.js +4 -1341
  169. package/lib/module/network/utils/networkSavedStore.js +3 -572
  170. package/lib/module/network/utils/networkSelectionStore.js +1 -188
  171. package/lib/module/network/utils/realNow.js +1 -0
  172. package/lib/module/network/utils/requestId.js +1 -12
  173. package/lib/module/network/utils/resolveRequestUrl.js +1 -11
  174. package/lib/module/network/utils/selectSavedEvents.js +1 -35
  175. package/lib/module/network/utils/startNetworkCapture.js +1 -21
  176. package/lib/module/network/utils/withPinnedFirst.js +1 -28
  177. package/lib/module/preset.js +1 -91
  178. package/lib/typescript/network/overrides/engine.d.ts +1 -1
  179. package/lib/typescript/network/overrides/matchRule.d.ts +1 -1
  180. package/lib/typescript/network/overrides/resolveOverride.d.ts +2 -2
  181. package/lib/typescript/network/overrides/types.d.ts +9 -0
  182. package/lib/typescript/network/utils/networkListener.d.ts +11 -0
  183. package/lib/typescript/network/utils/realNow.d.ts +18 -0
  184. package/lib/web/index.mjs +73 -74
  185. package/package.json +2 -2
  186. package/lib/typescript/index.d.ts.map +0 -1
  187. package/lib/typescript/index.web.d.ts.map +0 -1
  188. package/lib/typescript/network/components/DataViewer.web.d.ts.map +0 -1
  189. package/lib/typescript/network/components/NetworkCopyScreen.web.d.ts.map +0 -1
  190. package/lib/typescript/network/components/NetworkCopySettingsView.d.ts.map +0 -1
  191. package/lib/typescript/network/components/NetworkCopySettingsView.web.d.ts.map +0 -1
  192. package/lib/typescript/network/components/NetworkDetailScreen.web.d.ts.map +0 -1
  193. package/lib/typescript/network/components/NetworkDetailStepper.d.ts.map +0 -1
  194. package/lib/typescript/network/components/NetworkDetailStepper.web.d.ts.map +0 -1
  195. package/lib/typescript/network/components/NetworkEventDetailView.d.ts.map +0 -1
  196. package/lib/typescript/network/components/NetworkEventDetailView.web.d.ts.map +0 -1
  197. package/lib/typescript/network/components/NetworkEventItemCompact.d.ts.map +0 -1
  198. package/lib/typescript/network/components/NetworkEventItemCompact.web.d.ts.map +0 -1
  199. package/lib/typescript/network/components/NetworkFilterScreen.web.d.ts.map +0 -1
  200. package/lib/typescript/network/components/NetworkFilterViewV3.d.ts.map +0 -1
  201. package/lib/typescript/network/components/NetworkFilterViewV3.web.d.ts.map +0 -1
  202. package/lib/typescript/network/components/NetworkHeaderLive.d.ts.map +0 -1
  203. package/lib/typescript/network/components/NetworkHeaderLive.web.d.ts.map +0 -1
  204. package/lib/typescript/network/components/NetworkHeaderMenu.d.ts.map +0 -1
  205. package/lib/typescript/network/components/NetworkListScreen.d.ts.map +0 -1
  206. package/lib/typescript/network/components/NetworkListScreen.web.d.ts.map +0 -1
  207. package/lib/typescript/network/components/NetworkModal.d.ts.map +0 -1
  208. package/lib/typescript/network/components/NetworkNumberPrompt.d.ts.map +0 -1
  209. package/lib/typescript/network/components/NetworkNumberPrompt.web.d.ts.map +0 -1
  210. package/lib/typescript/network/components/NetworkOverrideEditor.d.ts.map +0 -1
  211. package/lib/typescript/network/components/NetworkOverrideEditor.web.d.ts.map +0 -1
  212. package/lib/typescript/network/components/NetworkOverrideHeaderButton.d.ts.map +0 -1
  213. package/lib/typescript/network/components/NetworkOverrideHeaderButton.web.d.ts.map +0 -1
  214. package/lib/typescript/network/components/NetworkOverridesButton.d.ts.map +0 -1
  215. package/lib/typescript/network/components/NetworkOverridesButton.web.d.ts.map +0 -1
  216. package/lib/typescript/network/components/NetworkOverridesScreen.d.ts.map +0 -1
  217. package/lib/typescript/network/components/NetworkOverridesScreen.web.d.ts.map +0 -1
  218. package/lib/typescript/network/components/NetworkSavedScreen.d.ts.map +0 -1
  219. package/lib/typescript/network/components/NetworkSavedScreen.web.d.ts.map +0 -1
  220. package/lib/typescript/network/components/NetworkUpgradeBanner.d.ts.map +0 -1
  221. package/lib/typescript/network/components/response-editor/Explorer.d.ts.map +0 -1
  222. package/lib/typescript/network/components/response-editor/Explorer.web.d.ts.map +0 -1
  223. package/lib/typescript/network/components/response-editor/deleteNestedDataByPath.d.ts.map +0 -1
  224. package/lib/typescript/network/components/response-editor/editorContext.d.ts.map +0 -1
  225. package/lib/typescript/network/components/response-editor/updateNestedDataByPath.d.ts.map +0 -1
  226. package/lib/typescript/network/conditions/NetworkConditionsControl.d.ts.map +0 -1
  227. package/lib/typescript/network/conditions/NetworkConditionsControl.test.d.ts.map +0 -1
  228. package/lib/typescript/network/conditions/NetworkConditionsIcon.d.ts.map +0 -1
  229. package/lib/typescript/network/conditions/NetworkFloatingTool.d.ts.map +0 -1
  230. package/lib/typescript/network/conditions/NetworkFloatingTool.test.d.ts.map +0 -1
  231. package/lib/typescript/network/conditions/store.d.ts.map +0 -1
  232. package/lib/typescript/network/conditions/wait.d.ts.map +0 -1
  233. package/lib/typescript/network/conditions/xhr.d.ts.map +0 -1
  234. package/lib/typescript/network/hooks/useLiveNetworkEvent.d.ts.map +0 -1
  235. package/lib/typescript/network/hooks/useNetworkBadgeCounts.d.ts.map +0 -1
  236. package/lib/typescript/network/hooks/useNetworkEventList.d.ts.map +0 -1
  237. package/lib/typescript/network/hooks/useNetworkEvents.d.ts.map +0 -1
  238. package/lib/typescript/network/hooks/useNetworkHasMatches.d.ts.map +0 -1
  239. package/lib/typescript/network/hooks/useNetworkSaved.d.ts.map +0 -1
  240. package/lib/typescript/network/hooks/useNetworkSelection.d.ts.map +0 -1
  241. package/lib/typescript/network/hooks/useOverrideRules.d.ts.map +0 -1
  242. package/lib/typescript/network/hooks/useTickEveryMinute.d.ts.map +0 -1
  243. package/lib/typescript/network/overrides/applyToFetch.d.ts.map +0 -1
  244. package/lib/typescript/network/overrides/applyToXhr.d.ts.map +0 -1
  245. package/lib/typescript/network/overrides/engine.d.ts.map +0 -1
  246. package/lib/typescript/network/overrides/matchRule.d.ts.map +0 -1
  247. package/lib/typescript/network/overrides/overriddenRows.d.ts.map +0 -1
  248. package/lib/typescript/network/overrides/overrideRulesStore.d.ts.map +0 -1
  249. package/lib/typescript/network/overrides/presets.d.ts.map +0 -1
  250. package/lib/typescript/network/overrides/resolveOverride.d.ts.map +0 -1
  251. package/lib/typescript/network/overrides/types.d.ts.map +0 -1
  252. package/lib/typescript/network/sync/networkBodyResolver.d.ts.map +0 -1
  253. package/lib/typescript/network/sync/networkSyncAdapter.d.ts.map +0 -1
  254. package/lib/typescript/network/sync/overrideHonesty.release.test.d.ts.map +0 -1
  255. package/lib/typescript/network/types/index.d.ts.map +0 -1
  256. package/lib/typescript/network/utils/extractOperationName.d.ts.map +0 -1
  257. package/lib/typescript/network/utils/filterNetworkEvents.d.ts.map +0 -1
  258. package/lib/typescript/network/utils/formatGraphQLVariables.d.ts.map +0 -1
  259. package/lib/typescript/network/utils/formatting.d.ts.map +0 -1
  260. package/lib/typescript/network/utils/generateCurl.d.ts.map +0 -1
  261. package/lib/typescript/network/utils/generateNetworkCopyText.d.ts.map +0 -1
  262. package/lib/typescript/network/utils/httpCompletion.d.ts.map +0 -1
  263. package/lib/typescript/network/utils/networkEventStore.d.ts.map +0 -1
  264. package/lib/typescript/network/utils/networkListener.d.ts.map +0 -1
  265. package/lib/typescript/network/utils/networkSavedStore.d.ts.map +0 -1
  266. package/lib/typescript/network/utils/networkSelectionStore.d.ts.map +0 -1
  267. package/lib/typescript/network/utils/requestId.d.ts.map +0 -1
  268. package/lib/typescript/network/utils/resolveRequestUrl.d.ts.map +0 -1
  269. package/lib/typescript/network/utils/selectSavedEvents.d.ts.map +0 -1
  270. package/lib/typescript/network/utils/startNetworkCapture.d.ts.map +0 -1
  271. package/lib/typescript/network/utils/withPinnedFirst.d.ts.map +0 -1
  272. package/lib/typescript/preset.d.ts.map +0 -1
@@ -1,811 +1 @@
1
- "use strict";
2
-
3
- import { useMemo, useState } from "react";
4
- import { ScrollView, StyleSheet, Text, TextInput, TouchableOpacity, View } from "react-native";
5
- import { ChevronDown, ChevronRight, macOSColors, useSafeAreaInsets, monoFont } from "@buoy-gg/shared-ui";
6
- import Explorer from "./response-editor/Explorer";
7
- import { ResponseEditorContext } from "./response-editor/editorContext";
8
- import { NetworkNumberPrompt } from "./NetworkNumberPrompt";
9
- import { STATUS_MAX, STATUS_MIN } from "../overrides/types";
10
-
11
- /**
12
- * The rule form — one decision, everything else out of the way.
13
- *
14
- * It used to ask for six things at equal weight (URL, method, kind, status,
15
- * body, lifetime) with three paragraphs of hint text explaining them. That's a
16
- * form, not a tool, and the hints were the tell: a control that needs a
17
- * paragraph is the wrong control.
18
- *
19
- * Two things fixed it.
20
- *
21
- * FIRST, `kind` is gone from the UI. `respond | fail | delay` is our data
22
- * model, not the developer's — nobody thinks "kind=respond, status=500", they
23
- * think "make it a 500" or "make it go offline". Folding kind + status +
24
- * failKind into a single OUTCOME list removes a section, a paragraph, and an
25
- * entire concept, and every option now says what it does without being
26
- * explained.
27
- *
28
- * SECOND, everything that arrives already correct is collapsed. A rule made
29
- * from a real request knows its URL and method, so those become one summary
30
- * line you can open if you need it. The body is prefilled and usually edited in
31
- * the response tree instead, so it collapses too. What's left on arrival is the
32
- * question actually being asked.
33
- */
34
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
35
- const METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
36
- const DELAY_PRESETS = [0, 500, 1000, 3000, 10000];
37
-
38
- /**
39
- * The single decision, ordered by how often a developer reaches for it.
40
- *
41
- * Each carries a plain-language name AND its status code: scanning for "the
42
- * auth one" shouldn't require knowing that 401 is unauthorized, and someone who
43
- * does know should be able to find 401 without reading labels.
44
- */
45
-
46
- const OUTCOMES = [{
47
- id: "500",
48
- label: "Server error",
49
- code: "500",
50
- danger: true,
51
- patch: {
52
- kind: "respond",
53
- status: 500,
54
- statusText: "Internal Server Error"
55
- }
56
- }, {
57
- id: "401",
58
- label: "Unauthorized",
59
- code: "401",
60
- danger: true,
61
- patch: {
62
- kind: "respond",
63
- status: 401,
64
- statusText: "Unauthorized"
65
- }
66
- }, {
67
- id: "404",
68
- label: "Not found",
69
- code: "404",
70
- danger: true,
71
- patch: {
72
- kind: "respond",
73
- status: 404,
74
- statusText: "Not Found"
75
- }
76
- }, {
77
- id: "403",
78
- label: "Forbidden",
79
- code: "403",
80
- danger: true,
81
- patch: {
82
- kind: "respond",
83
- status: 403,
84
- statusText: "Forbidden"
85
- }
86
- }, {
87
- id: "429",
88
- label: "Rate limited",
89
- code: "429",
90
- danger: true,
91
- patch: {
92
- kind: "respond",
93
- status: 429,
94
- statusText: "Too Many Requests"
95
- }
96
- }, {
97
- id: "503",
98
- label: "Unavailable",
99
- code: "503",
100
- danger: true,
101
- patch: {
102
- kind: "respond",
103
- status: 503,
104
- statusText: "Service Unavailable"
105
- }
106
- }, {
107
- id: "400",
108
- label: "Bad request",
109
- code: "400",
110
- danger: true,
111
- patch: {
112
- kind: "respond",
113
- status: 400,
114
- statusText: "Bad Request"
115
- }
116
- }, {
117
- id: "200",
118
- label: "Success",
119
- code: "200",
120
- patch: {
121
- kind: "respond",
122
- status: 200,
123
- statusText: "OK"
124
- }
125
- }, {
126
- id: "offline",
127
- label: "Offline",
128
- danger: true,
129
- patch: {
130
- kind: "fail",
131
- failKind: "network"
132
- }
133
- }, {
134
- id: "timeout",
135
- label: "Timeout",
136
- danger: true,
137
- patch: {
138
- kind: "fail",
139
- failKind: "timeout"
140
- }
141
- }, {
142
- id: "passthrough",
143
- label: "Real response",
144
- patch: {
145
- kind: "delay"
146
- }
147
- }];
148
- function outcomeIdFor(draft) {
149
- if (draft.kind === "delay") return "passthrough";
150
- if (draft.kind === "fail") {
151
- return draft.failKind === "timeout" ? "timeout" : "offline";
152
- }
153
- return String(draft.status ?? 200);
154
- }
155
- function OutcomeChip({
156
- outcome,
157
- active,
158
- onPress
159
- }) {
160
- const accent = outcome.danger ? macOSColors.semantic.error : macOSColors.semantic.info;
161
- return /*#__PURE__*/_jsxs(TouchableOpacity, {
162
- onPress: onPress,
163
- "sentry-label": "ignore override outcome",
164
- testID: `buoy-network-outcome-${outcome.label.toLowerCase().replace(/\s+/g, "-")}${outcome.code ? `-${outcome.code}` : ""}`,
165
- accessibilityRole: "button",
166
- accessibilityLabel: `${outcome.label}${outcome.code ? ` ${outcome.code}` : ""}`,
167
- style: [styles.outcome, active && {
168
- borderColor: accent,
169
- backgroundColor: `${accent}1F`
170
- }],
171
- children: [/*#__PURE__*/_jsx(Text, {
172
- style: [styles.outcomeLabel, active && {
173
- color: accent
174
- }],
175
- children: outcome.label
176
- }), outcome.code ? /*#__PURE__*/_jsx(Text, {
177
- style: [styles.outcomeCode, active && {
178
- color: accent
179
- }],
180
- children: outcome.code
181
- }) : null]
182
- });
183
- }
184
-
185
- /** A collapsed row that opens to reveal its controls. */
186
- function Disclosure({
187
- title,
188
- summary,
189
- open,
190
- onToggle,
191
- children
192
- }) {
193
- return /*#__PURE__*/_jsxs(View, {
194
- style: styles.disclosure,
195
- children: [/*#__PURE__*/_jsxs(TouchableOpacity, {
196
- onPress: onToggle,
197
- "sentry-label": "ignore override disclosure",
198
- testID: `buoy-network-disclosure-${title.toLowerCase().replace(/\s+/g, "-")}`,
199
- accessibilityRole: "button",
200
- accessibilityLabel: title,
201
- style: styles.disclosureHeader,
202
- children: [open ? /*#__PURE__*/_jsx(ChevronDown, {
203
- size: 12,
204
- color: macOSColors.text.muted
205
- }) : /*#__PURE__*/_jsx(ChevronRight, {
206
- size: 12,
207
- color: macOSColors.text.muted
208
- }), /*#__PURE__*/_jsx(Text, {
209
- style: styles.disclosureTitle,
210
- children: title
211
- }), summary && !open ? /*#__PURE__*/_jsx(Text, {
212
- style: styles.disclosureSummary,
213
- numberOfLines: 1,
214
- children: summary
215
- }) : null]
216
- }), open ? /*#__PURE__*/_jsx(View, {
217
- style: styles.disclosureBody,
218
- children: children
219
- }) : null]
220
- });
221
- }
222
- function Chip({
223
- label,
224
- active,
225
- onPress
226
- }) {
227
- return /*#__PURE__*/_jsx(TouchableOpacity, {
228
- onPress: onPress,
229
- "sentry-label": "ignore override chip",
230
- testID: `buoy-network-chip-${label.toLowerCase().replace(/\s+/g, "-")}`,
231
- accessibilityRole: "button",
232
- accessibilityLabel: label,
233
- style: [styles.chip, active && styles.chipActive],
234
- children: /*#__PURE__*/_jsx(Text, {
235
- style: [styles.chipText, active && styles.chipTextActive],
236
- children: label
237
- })
238
- });
239
- }
240
- export function NetworkOverrideEditor({
241
- draft,
242
- onChange,
243
- onSave,
244
- onCancel,
245
- saveLabel = "Save",
246
- applySafeAreaInset = false
247
- }) {
248
- // `minBottom` is a floor, not a preference: the dimension map can't know
249
- // about a device that ships next year, and an unmapped one falls through to
250
- // `bottom: 0`. This guarantees the buttons clear the indicator either way.
251
- const insets = useSafeAreaInsets({
252
- minBottom: 16
253
- });
254
- const bottomInset = applySafeAreaInset ? insets.bottom : 0;
255
- const patch = next => onChange({
256
- ...draft,
257
- ...next
258
- });
259
-
260
- // A rule made from a request arrives with its scope already right, so it
261
- // starts closed. A blank one has nothing to match on yet, so it starts open.
262
- const [scopeOpen, setScopeOpen] = useState(!draft.urlPattern.trim());
263
- const [bodyOpen, setBodyOpen] = useState(false);
264
- /**
265
- * The "Edit all" buffer — deliberately NOT seeded with the current body.
266
- *
267
- * Prefilling it would be the obvious thing and it's wrong twice over: a real
268
- * response is routinely hundreds of KB, which a multiline TextInput handles
269
- * badly, and you only reach for this when you intend to REPLACE the whole
270
- * thing anyway. Starting empty means paste-and-go instead of select-all-
271
- * delete-paste on a field that's fighting you.
272
- */
273
- const [pasteText, setPasteText] = useState(null);
274
- /** Which custom number the top-of-screen prompt is asking for, if any. */
275
- const [prompt, setPrompt] = useState(null);
276
- const activeOutcome = outcomeIdFor(draft);
277
- /** True when the status is a real one that no listed outcome covers. */
278
- const customStatusActive = draft.kind === "respond" && typeof draft.status === "number" && !OUTCOMES.some(outcome => outcome.code === String(draft.status));
279
- const showsBody = draft.kind === "respond";
280
- const method = draft.methods?.[0];
281
- const scopeSummary = `${method ?? "Any"} ${draft.urlPattern || "No URL yet"}`;
282
- const bodySummary = useMemo(() => {
283
- const body = (draft.body ?? "").trim();
284
- if (!body) return "Empty";
285
- const lines = body.split("\n").length;
286
- return `${lines} line${lines === 1 ? "" : "s"}`;
287
- }, [draft.body]);
288
-
289
- /**
290
- * The body as a tree, or null when it can't be one (empty, or not JSON).
291
- *
292
- * Memoized on the raw string because an override body can be large and this
293
- * would otherwise re-parse on every keystroke elsewhere in the form.
294
- */
295
- const parsedBody = useMemo(() => {
296
- const body = (draft.body ?? "").trim();
297
- if (!body) return null;
298
- try {
299
- return JSON.parse(body);
300
- } catch {
301
- return null;
302
- }
303
- }, [draft.body]);
304
- const bodyIsNonJsonText = (draft.body ?? "").trim().length > 0 && !parsedBody;
305
- const delayMs = draft.delayMs ?? 0;
306
- /** Custom fields own the value only when no preset chip already claims it. */
307
- const customDelayActive = delayMs > 0 && !DELAY_PRESETS.includes(delayMs);
308
- const customTimesActive = !draft.alternate && typeof draft.times === "number" && draft.times !== 1;
309
- return /*#__PURE__*/_jsxs(View, {
310
- style: styles.root,
311
- children: [/*#__PURE__*/_jsxs(ScrollView, {
312
- testID: "buoy-network-editor-scroll",
313
- style: styles.scroll,
314
- contentContainerStyle: styles.scrollContent,
315
- keyboardShouldPersistTaps: "handled",
316
- children: [/*#__PURE__*/_jsxs(Disclosure, {
317
- title: "Applies to",
318
- summary: scopeSummary,
319
- open: scopeOpen,
320
- onToggle: () => setScopeOpen(v => !v),
321
- children: [/*#__PURE__*/_jsx(TextInput, {
322
- style: styles.input,
323
- value: draft.urlPattern,
324
- onChangeText: urlPattern => patch({
325
- urlPattern
326
- }),
327
- testID: "buoy-network-override-pattern",
328
- accessibilityLabel: "Override URL pattern",
329
- placeholder: "https://api.example.com/v1/users*",
330
- placeholderTextColor: macOSColors.text.muted,
331
- autoCapitalize: "none",
332
- autoCorrect: false,
333
- multiline: true,
334
- "sentry-label": "ignore override url pattern"
335
- }), /*#__PURE__*/_jsxs(View, {
336
- style: styles.chipRow,
337
- children: [/*#__PURE__*/_jsx(Chip, {
338
- label: "Any",
339
- active: !method,
340
- onPress: () => patch({
341
- methods: undefined
342
- })
343
- }), METHODS.map(m => /*#__PURE__*/_jsx(Chip, {
344
- label: m,
345
- active: method === m,
346
- onPress: () => patch({
347
- methods: [m]
348
- })
349
- }, m))]
350
- })]
351
- }), /*#__PURE__*/_jsxs(View, {
352
- style: styles.outcomeGrid,
353
- children: [OUTCOMES.map(outcome => /*#__PURE__*/_jsx(OutcomeChip, {
354
- outcome: outcome,
355
- active: activeOutcome === outcome.id,
356
- onPress: () => patch(outcome.patch)
357
- }, outcome.id)), /*#__PURE__*/_jsx(TouchableOpacity, {
358
- onPress: () => setPrompt("status"),
359
- "sentry-label": "ignore custom status",
360
- accessibilityLabel: "Custom status code",
361
- style: [styles.customField, customStatusActive && styles.customFieldActive],
362
- children: /*#__PURE__*/_jsx(Text, {
363
- style: [styles.customValue, customStatusActive && styles.customInputActive],
364
- children: customStatusActive ? String(draft.status) : "Custom"
365
- })
366
- })]
367
- }), showsBody ? /*#__PURE__*/_jsx(Disclosure, {
368
- title: "Response body",
369
- summary: bodySummary,
370
- open: bodyOpen,
371
- onToggle: () => setBodyOpen(v => !v),
372
- children: pasteText !== null ?
373
- /*#__PURE__*/
374
- /* Replace-the-whole-thing mode. Starts empty — see `pasteText`. */
375
- _jsxs(_Fragment, {
376
- children: [/*#__PURE__*/_jsx(TextInput, {
377
- style: [styles.input, styles.bodyInput],
378
- value: pasteText,
379
- onChangeText: setPasteText,
380
- placeholder: "Paste a new body\u2026",
381
- placeholderTextColor: macOSColors.text.muted,
382
- autoCapitalize: "none",
383
- autoCorrect: false,
384
- autoFocus: true,
385
- multiline: true,
386
- "sentry-label": "ignore override body paste"
387
- }), /*#__PURE__*/_jsxs(View, {
388
- style: styles.inlineActions,
389
- children: [/*#__PURE__*/_jsx(TouchableOpacity, {
390
- onPress: () => setPasteText(null),
391
- "sentry-label": "ignore cancel body paste",
392
- style: styles.textButton,
393
- children: /*#__PURE__*/_jsx(Text, {
394
- style: styles.textButtonMuted,
395
- children: "Cancel"
396
- })
397
- }), /*#__PURE__*/_jsx(TouchableOpacity, {
398
- onPress: () => {
399
- const next = pasteText.trim();
400
- // Pretty-print JSON on the way in so the tree it becomes
401
- // is readable; anything else is kept exactly as pasted.
402
- try {
403
- patch({
404
- body: JSON.stringify(JSON.parse(next), null, 2)
405
- });
406
- } catch {
407
- patch({
408
- body: next
409
- });
410
- }
411
- setPasteText(null);
412
- },
413
- disabled: !pasteText.trim(),
414
- "sentry-label": "ignore apply body paste",
415
- style: styles.textButton,
416
- children: /*#__PURE__*/_jsx(Text, {
417
- style: [styles.textButtonLabel, !pasteText.trim() && styles.textButtonDisabled],
418
- children: "Replace"
419
- })
420
- })]
421
- })]
422
- }) : /*#__PURE__*/_jsxs(_Fragment, {
423
- children: [parsedBody !== null ?
424
- /*#__PURE__*/
425
- /* The SAME tree as the request detail — tap a value to edit
426
- it. Editing writes the whole document back as the rule's
427
- body, so the two surfaces behave identically. */
428
- _jsx(ResponseEditorContext.Provider, {
429
- value: {
430
- root: parsedBody,
431
- onChange: next => patch({
432
- body: JSON.stringify(next, null, 2)
433
- })
434
- },
435
- children: /*#__PURE__*/_jsx(Explorer, {
436
- editable: true,
437
- label: "",
438
- value: parsedBody,
439
- defaultExpanded: [""]
440
- })
441
- }) : /*#__PURE__*/_jsx(Text, {
442
- style: styles.emptyBody,
443
- children: bodyIsNonJsonText ? "This body isn't JSON, so there's no tree to show." : "No body yet."
444
- }), /*#__PURE__*/_jsx(TouchableOpacity, {
445
- onPress: () => setPasteText(""),
446
- "sentry-label": "ignore edit all body",
447
- style: styles.textButton,
448
- children: /*#__PURE__*/_jsx(Text, {
449
- style: styles.textButtonLabel,
450
- children: "Edit all"
451
- })
452
- })]
453
- })
454
- }) : null, /*#__PURE__*/_jsxs(View, {
455
- style: styles.field,
456
- children: [/*#__PURE__*/_jsx(Text, {
457
- style: styles.subLabel,
458
- children: "Delay"
459
- }), /*#__PURE__*/_jsxs(View, {
460
- style: styles.chipRow,
461
- children: [DELAY_PRESETS.map(ms => /*#__PURE__*/_jsx(Chip, {
462
- label: ms === 0 ? "None" : `${ms / 1000}s`,
463
- active: delayMs === ms,
464
- onPress: () => patch({
465
- delayMs: ms
466
- })
467
- }, ms)), /*#__PURE__*/_jsx(TouchableOpacity, {
468
- onPress: () => setPrompt("delay"),
469
- "sentry-label": "ignore custom delay",
470
- accessibilityLabel: "Custom delay in seconds",
471
- style: [styles.customField, customDelayActive && styles.customFieldActive],
472
- children: /*#__PURE__*/_jsx(Text, {
473
- style: [styles.customValue, customDelayActive && styles.customInputActive],
474
- children: customDelayActive ? `${delayMs / 1000}s` : "Custom"
475
- })
476
- })]
477
- })]
478
- }), /*#__PURE__*/_jsxs(View, {
479
- style: styles.field,
480
- children: [/*#__PURE__*/_jsx(Text, {
481
- style: styles.subLabel,
482
- children: "Fires"
483
- }), /*#__PURE__*/_jsx(Text, {
484
- style: styles.subHint,
485
- children: "A limited rule switches itself off once it's used up. Every other alternates forever \u2014 the first request through, the next overridden."
486
- }), /*#__PURE__*/_jsxs(View, {
487
- style: styles.chipRow,
488
- children: [/*#__PURE__*/_jsx(Chip, {
489
- label: "Always",
490
- active: !draft.alternate && draft.times == null,
491
- onPress: () => patch({
492
- alternate: false,
493
- times: null
494
- })
495
- }), /*#__PURE__*/_jsx(Chip, {
496
- label: "Once",
497
- active: !draft.alternate && draft.times === 1,
498
- onPress: () => patch({
499
- alternate: false,
500
- times: 1
501
- })
502
- }), /*#__PURE__*/_jsx(Chip, {
503
- label: "Every other",
504
- active: draft.alternate === true,
505
- onPress: () => patch({
506
- alternate: true,
507
- times: null
508
- })
509
- }), /*#__PURE__*/_jsx(TouchableOpacity, {
510
- onPress: () => {
511
- patch({
512
- alternate: false
513
- });
514
- setPrompt("times");
515
- },
516
- "sentry-label": "ignore custom times",
517
- accessibilityLabel: "Custom number of times",
518
- style: [styles.customField, customTimesActive && styles.customFieldActive],
519
- children: /*#__PURE__*/_jsx(Text, {
520
- style: [styles.customValue, customTimesActive && styles.customInputActive],
521
- children: customTimesActive ? `${draft.times}×` : "Custom"
522
- })
523
- })]
524
- })]
525
- })]
526
- }), prompt === "status" ? /*#__PURE__*/_jsx(NetworkNumberPrompt, {
527
- title: "Custom status code",
528
- hint: `${STATUS_MIN}–${STATUS_MAX}`,
529
- value: customStatusActive ? draft.status : undefined,
530
- min: STATUS_MIN,
531
- max: STATUS_MAX,
532
- onSubmit: next => {
533
- patch({
534
- kind: "respond",
535
- status: next ?? undefined,
536
- statusText: undefined
537
- });
538
- setPrompt(null);
539
- },
540
- onCancel: () => setPrompt(null)
541
- }) : null, prompt === "delay" ? /*#__PURE__*/_jsx(NetworkNumberPrompt, {
542
- title: "Custom delay",
543
- hint: "Seconds",
544
- value: customDelayActive ? delayMs / 1000 : undefined,
545
- min: 0,
546
- onSubmit: next => {
547
- patch({
548
- delayMs: next != null ? Math.round(next * 1000) : 0
549
- });
550
- setPrompt(null);
551
- },
552
- onCancel: () => setPrompt(null)
553
- }) : null, prompt === "times" ? /*#__PURE__*/_jsx(NetworkNumberPrompt, {
554
- title: "Fires how many times",
555
- hint: "Leave empty for always",
556
- value: customTimesActive ? draft.times : undefined,
557
- min: 1,
558
- onSubmit: next => {
559
- // Empty or zero means "no limit" rather than a rule that is spent
560
- // before it ever fires.
561
- patch({
562
- alternate: false,
563
- times: next && next > 0 ? next : null
564
- });
565
- setPrompt(null);
566
- },
567
- onCancel: () => setPrompt(null)
568
- }) : null, /*#__PURE__*/_jsxs(View, {
569
- style: [styles.footer, {
570
- paddingBottom: 12 + bottomInset
571
- }],
572
- children: [/*#__PURE__*/_jsx(TouchableOpacity, {
573
- onPress: onCancel,
574
- "sentry-label": "ignore cancel override",
575
- testID: "buoy-network-editor-cancel",
576
- accessibilityRole: "button",
577
- accessibilityLabel: "Cancel",
578
- style: [styles.footerButton, styles.cancelButton],
579
- children: /*#__PURE__*/_jsx(Text, {
580
- style: styles.cancelText,
581
- children: "Cancel"
582
- })
583
- }), /*#__PURE__*/_jsx(TouchableOpacity, {
584
- onPress: onSave,
585
- disabled: !draft.urlPattern.trim(),
586
- "sentry-label": "ignore save override",
587
- testID: "buoy-network-editor-save",
588
- accessibilityRole: "button",
589
- accessibilityLabel: saveLabel,
590
- style: [styles.footerButton, styles.saveButton, !draft.urlPattern.trim() && styles.saveButtonDisabled],
591
- children: /*#__PURE__*/_jsx(Text, {
592
- style: styles.saveText,
593
- children: saveLabel
594
- })
595
- })]
596
- })]
597
- });
598
- }
599
- const styles = StyleSheet.create({
600
- root: {
601
- flex: 1
602
- },
603
- scroll: {
604
- flex: 1
605
- },
606
- scrollContent: {
607
- padding: 12,
608
- paddingBottom: 24,
609
- gap: 4
610
- },
611
- field: {
612
- gap: 8,
613
- paddingVertical: 6
614
- },
615
- outcomeGrid: {
616
- flexDirection: "row",
617
- flexWrap: "wrap",
618
- gap: 6,
619
- paddingVertical: 10
620
- },
621
- outcome: {
622
- flexDirection: "row",
623
- alignItems: "center",
624
- gap: 6,
625
- paddingHorizontal: 10,
626
- paddingVertical: 9,
627
- borderRadius: 6,
628
- borderWidth: 1,
629
- borderColor: macOSColors.border.default,
630
- backgroundColor: macOSColors.background.card
631
- },
632
- outcomeLabel: {
633
- fontSize: 12,
634
- fontWeight: "600",
635
- color: macOSColors.text.primary
636
- },
637
- outcomeCode: {
638
- fontSize: 10,
639
- fontWeight: "700",
640
- color: macOSColors.text.muted
641
- },
642
- disclosure: {
643
- borderRadius: 6,
644
- borderWidth: 1,
645
- borderColor: macOSColors.border.default,
646
- backgroundColor: macOSColors.background.card,
647
- overflow: "hidden"
648
- },
649
- disclosureHeader: {
650
- flexDirection: "row",
651
- alignItems: "center",
652
- gap: 6,
653
- paddingHorizontal: 10,
654
- paddingVertical: 10
655
- },
656
- disclosureTitle: {
657
- fontSize: 12,
658
- fontWeight: "600",
659
- color: macOSColors.text.primary
660
- },
661
- disclosureSummary: {
662
- flex: 1,
663
- textAlign: "right",
664
- fontSize: 11,
665
- color: macOSColors.text.muted
666
- },
667
- disclosureBody: {
668
- paddingHorizontal: 10,
669
- paddingBottom: 10,
670
- gap: 8
671
- },
672
- input: {
673
- backgroundColor: macOSColors.background.input,
674
- borderWidth: 1,
675
- borderColor: macOSColors.border.input,
676
- borderRadius: 6,
677
- paddingHorizontal: 10,
678
- paddingVertical: 8,
679
- color: macOSColors.text.primary,
680
- fontSize: 12,
681
- fontFamily: monoFont,
682
- minHeight: 40
683
- },
684
- bodyInput: {
685
- minHeight: 140,
686
- textAlignVertical: "top"
687
- },
688
- chipRow: {
689
- flexDirection: "row",
690
- flexWrap: "wrap",
691
- gap: 6
692
- },
693
- chip: {
694
- paddingHorizontal: 10,
695
- paddingVertical: 6,
696
- borderRadius: 5,
697
- borderWidth: 1,
698
- borderColor: macOSColors.border.default,
699
- backgroundColor: macOSColors.background.base
700
- },
701
- chipActive: {
702
- borderColor: macOSColors.semantic.info,
703
- backgroundColor: `${macOSColors.semantic.info}1F`
704
- },
705
- chipText: {
706
- fontSize: 11,
707
- fontWeight: "600",
708
- color: macOSColors.text.secondary
709
- },
710
- chipTextActive: {
711
- color: macOSColors.semantic.info
712
- },
713
- customField: {
714
- flexDirection: "row",
715
- alignItems: "center",
716
- paddingHorizontal: 8,
717
- borderRadius: 5,
718
- borderWidth: 1,
719
- borderColor: macOSColors.border.default,
720
- backgroundColor: macOSColors.background.base
721
- },
722
- customFieldActive: {
723
- borderColor: macOSColors.semantic.info,
724
- backgroundColor: `${macOSColors.semantic.info}1F`
725
- },
726
- customValue: {
727
- paddingVertical: 6,
728
- fontSize: 11,
729
- fontWeight: "600",
730
- color: macOSColors.text.secondary
731
- },
732
- customInputActive: {
733
- color: macOSColors.semantic.info
734
- },
735
- subHint: {
736
- fontSize: 10,
737
- lineHeight: 14,
738
- color: macOSColors.text.muted,
739
- marginTop: -2
740
- },
741
- subLabel: {
742
- fontSize: 10,
743
- fontWeight: "700",
744
- letterSpacing: 0.6,
745
- color: macOSColors.text.muted,
746
- textTransform: "uppercase"
747
- },
748
- textButton: {
749
- alignSelf: "flex-start",
750
- paddingVertical: 4
751
- },
752
- textButtonLabel: {
753
- fontSize: 11,
754
- fontWeight: "600",
755
- color: macOSColors.semantic.info
756
- },
757
- textButtonMuted: {
758
- fontSize: 11,
759
- fontWeight: "600",
760
- color: macOSColors.text.secondary
761
- },
762
- textButtonDisabled: {
763
- opacity: 0.4
764
- },
765
- inlineActions: {
766
- flexDirection: "row",
767
- alignItems: "center",
768
- justifyContent: "space-between"
769
- },
770
- emptyBody: {
771
- fontSize: 11,
772
- color: macOSColors.text.muted,
773
- paddingVertical: 6
774
- },
775
- footer: {
776
- flexDirection: "row",
777
- gap: 8,
778
- padding: 12,
779
- borderTopWidth: 1,
780
- borderTopColor: macOSColors.border.default,
781
- backgroundColor: macOSColors.background.base
782
- },
783
- footerButton: {
784
- flex: 1,
785
- paddingVertical: 11,
786
- borderRadius: 6,
787
- alignItems: "center",
788
- borderWidth: 1
789
- },
790
- cancelButton: {
791
- borderColor: macOSColors.border.default,
792
- backgroundColor: macOSColors.background.card
793
- },
794
- cancelText: {
795
- fontSize: 12,
796
- fontWeight: "600",
797
- color: macOSColors.text.secondary
798
- },
799
- saveButton: {
800
- borderColor: macOSColors.semantic.info,
801
- backgroundColor: `${macOSColors.semantic.info}22`
802
- },
803
- saveButtonDisabled: {
804
- opacity: 0.4
805
- },
806
- saveText: {
807
- fontSize: 12,
808
- fontWeight: "700",
809
- color: macOSColors.semantic.info
810
- }
811
- });
1
+ "use strict";import{useMemo as A,useState as T}from"react";import{ScrollView as K,StyleSheet as G,Text as l,TextInput as z,TouchableOpacity as d,View as c}from"react-native";import{ChevronDown as X,ChevronRight as Y,macOSColors as r,useSafeAreaInsets as Q,monoFont as Z}from"@buoy-gg/shared-ui";import ee from"./response-editor/Explorer";import{ResponseEditorContext as te}from"./response-editor/editorContext";import{NetworkNumberPrompt as B}from"./NetworkNumberPrompt";import{STATUS_MAX as R,STATUS_MIN as D}from"../overrides/types";import{jsx as n,jsxs as i,Fragment as I}from"react/jsx-runtime";const oe=["GET","POST","PUT","PATCH","DELETE"];const L=[0,500,1e3,3e3,1e4];const O=[{id:"500",label:"Server error",code:"500",danger:true,patch:{kind:"respond",status:500,statusText:"Internal Server Error"}},{id:"401",label:"Unauthorized",code:"401",danger:true,patch:{kind:"respond",status:401,statusText:"Unauthorized"}},{id:"404",label:"Not found",code:"404",danger:true,patch:{kind:"respond",status:404,statusText:"Not Found"}},{id:"403",label:"Forbidden",code:"403",danger:true,patch:{kind:"respond",status:403,statusText:"Forbidden"}},{id:"429",label:"Rate limited",code:"429",danger:true,patch:{kind:"respond",status:429,statusText:"Too Many Requests"}},{id:"503",label:"Unavailable",code:"503",danger:true,patch:{kind:"respond",status:503,statusText:"Service Unavailable"}},{id:"400",label:"Bad request",code:"400",danger:true,patch:{kind:"respond",status:400,statusText:"Bad Request"}},{id:"200",label:"Success",code:"200",patch:{kind:"respond",status:200,statusText:"OK"}},{id:"offline",label:"Offline",danger:true,patch:{kind:"fail",failKind:"network"}},{id:"timeout",label:"Timeout",danger:true,patch:{kind:"fail",failKind:"timeout"}},{id:"passthrough",label:"Real response",patch:{kind:"delay"}}];function ne(t){if(t.kind==="delay")return"passthrough";if(t.kind==="fail"){return t.failKind==="timeout"?"timeout":"offline"}return String(t.status??200)}function re({outcome:t,active:a,onPress:u}){const p=t.danger?r.semantic.error:r.semantic.info;return i(d,{onPress:u,"sentry-label":"ignore override outcome",testID:`buoy-network-outcome-${t.label.toLowerCase().replace(/\s+/g,"-")}${t.code?`-${t.code}`:""}`,accessibilityRole:"button",accessibilityLabel:`${t.label}${t.code?` ${t.code}`:""}`,style:[e.outcome,a&&{borderColor:p,backgroundColor:`${p}1F`}],children:[n(l,{style:[e.outcomeLabel,a&&{color:p}],children:t.label}),t.code?n(l,{style:[e.outcomeCode,a&&{color:p}],children:t.code}):null]})}function F({title:t,summary:a,open:u,onToggle:p,children:g}){return i(c,{style:e.disclosure,children:[i(d,{onPress:p,"sentry-label":"ignore override disclosure",testID:`buoy-network-disclosure-${t.toLowerCase().replace(/\s+/g,"-")}`,accessibilityRole:"button",accessibilityLabel:t,style:e.disclosureHeader,children:[u?n(X,{size:12,color:r.text.muted}):n(Y,{size:12,color:r.text.muted}),n(l,{style:e.disclosureTitle,children:t}),a&&!u?n(l,{style:e.disclosureSummary,numberOfLines:1,children:a}):null]}),u?n(c,{style:e.disclosureBody,children:g}):null]})}function m({label:t,active:a,onPress:u}){return n(d,{onPress:u,"sentry-label":"ignore override chip",testID:`buoy-network-chip-${t.toLowerCase().replace(/\s+/g,"-")}`,accessibilityRole:"button",accessibilityLabel:t,style:[e.chip,a&&e.chipActive],children:n(l,{style:[e.chipText,a&&e.chipTextActive],children:t})})}export function NetworkOverrideEditor({draft:t,onChange:a,onSave:u,onCancel:p,saveLabel:g="Save",applySafeAreaInset:$=false}){const W=Q({minBottom:16});const E=$?W.bottom:0;const s=o=>a({...t,...o});const[V,H]=T(!t.urlPattern.trim());const[N,M]=T(false);const[y,f]=T(null);const[k,b]=T(null);const U=ne(t);const x=t.kind==="respond"&&typeof t.status==="number"&&!O.some(o=>o.code===String(t.status));const J=t.kind==="respond";const w=t.methods?.[0];const _=`${w??"Any"} ${t.urlPattern||"No URL yet"}`;const j=A(()=>{const o=(t.body??"").trim();if(!o)return"Empty";const P=o.split("\n").length;return`${P} line${P===1?"":"s"}`},[t.body]);const C=A(()=>{const o=(t.body??"").trim();if(!o)return null;try{return JSON.parse(o)}catch{return null}},[t.body]);const q=(t.body??"").trim().length>0&&!C;const h=t.delayMs??0;const v=h>0&&!L.includes(h);const S=!t.alternate&&typeof t.times==="number"&&t.times!==1;return i(c,{style:e.root,children:[i(K,{testID:"buoy-network-editor-scroll",style:e.scroll,contentContainerStyle:e.scrollContent,keyboardShouldPersistTaps:"handled",children:[i(F,{title:"Applies to",summary:_,open:V,onToggle:()=>H(o=>!o),children:[n(z,{style:e.input,value:t.urlPattern,onChangeText:o=>s({urlPattern:o}),testID:"buoy-network-override-pattern",accessibilityLabel:"Override URL pattern",placeholder:"https://api.example.com/v1/users*",placeholderTextColor:r.text.muted,autoCapitalize:"none",autoCorrect:false,multiline:true,"sentry-label":"ignore override url pattern"}),i(c,{style:e.chipRow,children:[n(m,{label:"Any",active:!w,onPress:()=>s({methods:void 0})}),oe.map(o=>n(m,{label:o,active:w===o,onPress:()=>s({methods:[o]})},o))]})]}),i(c,{style:e.outcomeGrid,children:[O.map(o=>n(re,{outcome:o,active:U===o.id,onPress:()=>s(o.patch)},o.id)),n(d,{onPress:()=>b("status"),"sentry-label":"ignore custom status",accessibilityLabel:"Custom status code",style:[e.customField,x&&e.customFieldActive],children:n(l,{style:[e.customValue,x&&e.customInputActive],children:x?String(t.status):"Custom"})})]}),J?n(F,{title:"Response body",summary:j,open:N,onToggle:()=>M(o=>!o),children:y!==null?i(I,{children:[n(z,{style:[e.input,e.bodyInput],value:y,onChangeText:f,placeholder:"Paste a new body\u2026",placeholderTextColor:r.text.muted,autoCapitalize:"none",autoCorrect:false,autoFocus:true,multiline:true,"sentry-label":"ignore override body paste"}),i(c,{style:e.inlineActions,children:[n(d,{onPress:()=>f(null),"sentry-label":"ignore cancel body paste",style:e.textButton,children:n(l,{style:e.textButtonMuted,children:"Cancel"})}),n(d,{onPress:()=>{const o=y.trim();try{s({body:JSON.stringify(JSON.parse(o),null,2)})}catch{s({body:o})}f(null)},disabled:!y.trim(),"sentry-label":"ignore apply body paste",style:e.textButton,children:n(l,{style:[e.textButtonLabel,!y.trim()&&e.textButtonDisabled],children:"Replace"})})]})]}):i(I,{children:[C!==null?n(te.Provider,{value:{root:C,onChange:o=>s({body:JSON.stringify(o,null,2)})},children:n(ee,{editable:true,label:"",value:C,defaultExpanded:[""]})}):n(l,{style:e.emptyBody,children:q?"This body isn't JSON, so there's no tree to show.":"No body yet."}),n(d,{onPress:()=>f(""),"sentry-label":"ignore edit all body",style:e.textButton,children:n(l,{style:e.textButtonLabel,children:"Edit all"})})]})}):null,i(c,{style:e.field,children:[n(l,{style:e.subLabel,children:"Delay"}),i(c,{style:e.chipRow,children:[L.map(o=>n(m,{label:o===0?"None":`${o/1e3}s`,active:h===o,onPress:()=>s({delayMs:o})},o)),n(d,{onPress:()=>b("delay"),"sentry-label":"ignore custom delay",accessibilityLabel:"Custom delay in seconds",style:[e.customField,v&&e.customFieldActive],children:n(l,{style:[e.customValue,v&&e.customInputActive],children:v?`${h/1e3}s`:"Custom"})})]})]}),i(c,{style:e.field,children:[n(l,{style:e.subLabel,children:"Fires"}),n(l,{style:e.subHint,children:"A limited rule switches itself off once it's used up. Every other alternates forever \u2014 the first request through, the next overridden."}),i(c,{style:e.chipRow,children:[n(m,{label:"Always",active:!t.alternate&&t.times==null,onPress:()=>s({alternate:false,times:null})}),n(m,{label:"Once",active:!t.alternate&&t.times===1,onPress:()=>s({alternate:false,times:1})}),n(m,{label:"Every other",active:t.alternate===true,onPress:()=>s({alternate:true,times:null})}),n(d,{onPress:()=>{s({alternate:false});b("times")},"sentry-label":"ignore custom times",accessibilityLabel:"Custom number of times",style:[e.customField,S&&e.customFieldActive],children:n(l,{style:[e.customValue,S&&e.customInputActive],children:S?`${t.times}\xD7`:"Custom"})})]})]})]}),k==="status"?n(B,{title:"Custom status code",hint:`${D}\u2013${R}`,value:x?t.status:void 0,min:D,max:R,onSubmit:o=>{s({kind:"respond",status:o??void 0,statusText:void 0});b(null)},onCancel:()=>b(null)}):null,k==="delay"?n(B,{title:"Custom delay",hint:"Seconds",value:v?h/1e3:void 0,min:0,onSubmit:o=>{s({delayMs:o!=null?Math.round(o*1e3):0});b(null)},onCancel:()=>b(null)}):null,k==="times"?n(B,{title:"Fires how many times",hint:"Leave empty for always",value:S?t.times:void 0,min:1,onSubmit:o=>{s({alternate:false,times:o&&o>0?o:null});b(null)},onCancel:()=>b(null)}):null,i(c,{style:[e.footer,{paddingBottom:12+E}],children:[n(d,{onPress:p,"sentry-label":"ignore cancel override",testID:"buoy-network-editor-cancel",accessibilityRole:"button",accessibilityLabel:"Cancel",style:[e.footerButton,e.cancelButton],children:n(l,{style:e.cancelText,children:"Cancel"})}),n(d,{onPress:u,disabled:!t.urlPattern.trim(),"sentry-label":"ignore save override",testID:"buoy-network-editor-save",accessibilityRole:"button",accessibilityLabel:g,style:[e.footerButton,e.saveButton,!t.urlPattern.trim()&&e.saveButtonDisabled],children:n(l,{style:e.saveText,children:g})})]})]})}const e=G.create({root:{flex:1},scroll:{flex:1},scrollContent:{padding:12,paddingBottom:24,gap:4},field:{gap:8,paddingVertical:6},outcomeGrid:{flexDirection:"row",flexWrap:"wrap",gap:6,paddingVertical:10},outcome:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:9,borderRadius:6,borderWidth:1,borderColor:r.border.default,backgroundColor:r.background.card},outcomeLabel:{fontSize:12,fontWeight:"600",color:r.text.primary},outcomeCode:{fontSize:10,fontWeight:"700",color:r.text.muted},disclosure:{borderRadius:6,borderWidth:1,borderColor:r.border.default,backgroundColor:r.background.card,overflow:"hidden"},disclosureHeader:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:10},disclosureTitle:{fontSize:12,fontWeight:"600",color:r.text.primary},disclosureSummary:{flex:1,textAlign:"right",fontSize:11,color:r.text.muted},disclosureBody:{paddingHorizontal:10,paddingBottom:10,gap:8},input:{backgroundColor:r.background.input,borderWidth:1,borderColor:r.border.input,borderRadius:6,paddingHorizontal:10,paddingVertical:8,color:r.text.primary,fontSize:12,fontFamily:Z,minHeight:40},bodyInput:{minHeight:140,textAlignVertical:"top"},chipRow:{flexDirection:"row",flexWrap:"wrap",gap:6},chip:{paddingHorizontal:10,paddingVertical:6,borderRadius:5,borderWidth:1,borderColor:r.border.default,backgroundColor:r.background.base},chipActive:{borderColor:r.semantic.info,backgroundColor:`${r.semantic.info}1F`},chipText:{fontSize:11,fontWeight:"600",color:r.text.secondary},chipTextActive:{color:r.semantic.info},customField:{flexDirection:"row",alignItems:"center",paddingHorizontal:8,borderRadius:5,borderWidth:1,borderColor:r.border.default,backgroundColor:r.background.base},customFieldActive:{borderColor:r.semantic.info,backgroundColor:`${r.semantic.info}1F`},customValue:{paddingVertical:6,fontSize:11,fontWeight:"600",color:r.text.secondary},customInputActive:{color:r.semantic.info},subHint:{fontSize:10,lineHeight:14,color:r.text.muted,marginTop:-2},subLabel:{fontSize:10,fontWeight:"700",letterSpacing:.6,color:r.text.muted,textTransform:"uppercase"},textButton:{alignSelf:"flex-start",paddingVertical:4},textButtonLabel:{fontSize:11,fontWeight:"600",color:r.semantic.info},textButtonMuted:{fontSize:11,fontWeight:"600",color:r.text.secondary},textButtonDisabled:{opacity:.4},inlineActions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},emptyBody:{fontSize:11,color:r.text.muted,paddingVertical:6},footer:{flexDirection:"row",gap:8,padding:12,borderTopWidth:1,borderTopColor:r.border.default,backgroundColor:r.background.base},footerButton:{flex:1,paddingVertical:11,borderRadius:6,alignItems:"center",borderWidth:1},cancelButton:{borderColor:r.border.default,backgroundColor:r.background.card},cancelText:{fontSize:12,fontWeight:"600",color:r.text.secondary},saveButton:{borderColor:r.semantic.info,backgroundColor:`${r.semantic.info}22`},saveButtonDisabled:{opacity:.4},saveText:{fontSize:12,fontWeight:"700",color:r.semantic.info}});