@buoy-gg/network 7.0.40 → 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 (275) hide show
  1. package/README.md +11 -79
  2. package/lib/commonjs/index.js +1 -325
  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 -404
  22. package/lib/commonjs/network/components/NetworkListScreen.web.js +1 -625
  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 -110
  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 -453
  61. package/lib/commonjs/network/overrides/engine.js +1 -93
  62. package/lib/commonjs/network/overrides/matchRule.js +1 -81
  63. package/lib/commonjs/network/overrides/overriddenRows.js +1 -0
  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 -393
  80. package/lib/commonjs/network/utils/networkListener.js +4 -1259
  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 -0
  85. package/lib/commonjs/network/utils/resolveRequestUrl.js +1 -0
  86. package/lib/commonjs/network/utils/selectSavedEvents.js +1 -39
  87. package/lib/commonjs/network/utils/startNetworkCapture.js +1 -0
  88. package/lib/commonjs/network/utils/withPinnedFirst.js +1 -32
  89. package/lib/commonjs/preset.js +1 -102
  90. package/lib/module/index.js +1 -103
  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 -400
  110. package/lib/module/network/components/NetworkListScreen.web.js +1 -623
  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 -106
  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 -446
  149. package/lib/module/network/overrides/engine.js +1 -85
  150. package/lib/module/network/overrides/matchRule.js +1 -75
  151. package/lib/module/network/overrides/overriddenRows.js +1 -0
  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 -391
  168. package/lib/module/network/utils/networkListener.js +4 -1249
  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 -0
  173. package/lib/module/network/utils/resolveRequestUrl.js +1 -0
  174. package/lib/module/network/utils/selectSavedEvents.js +1 -35
  175. package/lib/module/network/utils/startNetworkCapture.js +1 -0
  176. package/lib/module/network/utils/withPinnedFirst.js +1 -28
  177. package/lib/module/preset.js +1 -100
  178. package/lib/typescript/index.d.ts +1 -0
  179. package/lib/typescript/network/overrides/applyToXhr.d.ts +1 -0
  180. package/lib/typescript/network/overrides/engine.d.ts +1 -1
  181. package/lib/typescript/network/overrides/matchRule.d.ts +1 -1
  182. package/lib/typescript/network/overrides/overriddenRows.d.ts +16 -0
  183. package/lib/typescript/network/overrides/resolveOverride.d.ts +2 -2
  184. package/lib/typescript/network/overrides/types.d.ts +9 -0
  185. package/lib/typescript/network/utils/networkListener.d.ts +14 -4
  186. package/lib/typescript/network/utils/networkSavedStore.d.ts +4 -4
  187. package/lib/typescript/network/utils/realNow.d.ts +18 -0
  188. package/lib/typescript/network/utils/requestId.d.ts +2 -0
  189. package/lib/typescript/network/utils/resolveRequestUrl.d.ts +3 -0
  190. package/lib/typescript/network/utils/startNetworkCapture.d.ts +6 -0
  191. package/lib/web/index.mjs +145 -0
  192. package/package.json +32 -10
  193. package/lib/typescript/index.d.ts.map +0 -1
  194. package/lib/typescript/index.web.d.ts.map +0 -1
  195. package/lib/typescript/network/components/DataViewer.web.d.ts.map +0 -1
  196. package/lib/typescript/network/components/NetworkCopyScreen.web.d.ts.map +0 -1
  197. package/lib/typescript/network/components/NetworkCopySettingsView.d.ts.map +0 -1
  198. package/lib/typescript/network/components/NetworkCopySettingsView.web.d.ts.map +0 -1
  199. package/lib/typescript/network/components/NetworkDetailScreen.web.d.ts.map +0 -1
  200. package/lib/typescript/network/components/NetworkDetailStepper.d.ts.map +0 -1
  201. package/lib/typescript/network/components/NetworkDetailStepper.web.d.ts.map +0 -1
  202. package/lib/typescript/network/components/NetworkEventDetailView.d.ts.map +0 -1
  203. package/lib/typescript/network/components/NetworkEventDetailView.web.d.ts.map +0 -1
  204. package/lib/typescript/network/components/NetworkEventItemCompact.d.ts.map +0 -1
  205. package/lib/typescript/network/components/NetworkEventItemCompact.web.d.ts.map +0 -1
  206. package/lib/typescript/network/components/NetworkFilterScreen.web.d.ts.map +0 -1
  207. package/lib/typescript/network/components/NetworkFilterViewV3.d.ts.map +0 -1
  208. package/lib/typescript/network/components/NetworkFilterViewV3.web.d.ts.map +0 -1
  209. package/lib/typescript/network/components/NetworkHeaderLive.d.ts.map +0 -1
  210. package/lib/typescript/network/components/NetworkHeaderLive.web.d.ts.map +0 -1
  211. package/lib/typescript/network/components/NetworkHeaderMenu.d.ts.map +0 -1
  212. package/lib/typescript/network/components/NetworkListScreen.d.ts.map +0 -1
  213. package/lib/typescript/network/components/NetworkListScreen.web.d.ts.map +0 -1
  214. package/lib/typescript/network/components/NetworkModal.d.ts.map +0 -1
  215. package/lib/typescript/network/components/NetworkNumberPrompt.d.ts.map +0 -1
  216. package/lib/typescript/network/components/NetworkNumberPrompt.web.d.ts.map +0 -1
  217. package/lib/typescript/network/components/NetworkOverrideEditor.d.ts.map +0 -1
  218. package/lib/typescript/network/components/NetworkOverrideEditor.web.d.ts.map +0 -1
  219. package/lib/typescript/network/components/NetworkOverrideHeaderButton.d.ts.map +0 -1
  220. package/lib/typescript/network/components/NetworkOverrideHeaderButton.web.d.ts.map +0 -1
  221. package/lib/typescript/network/components/NetworkOverridesButton.d.ts.map +0 -1
  222. package/lib/typescript/network/components/NetworkOverridesButton.web.d.ts.map +0 -1
  223. package/lib/typescript/network/components/NetworkOverridesScreen.d.ts.map +0 -1
  224. package/lib/typescript/network/components/NetworkOverridesScreen.web.d.ts.map +0 -1
  225. package/lib/typescript/network/components/NetworkSavedScreen.d.ts.map +0 -1
  226. package/lib/typescript/network/components/NetworkSavedScreen.web.d.ts.map +0 -1
  227. package/lib/typescript/network/components/NetworkUpgradeBanner.d.ts.map +0 -1
  228. package/lib/typescript/network/components/response-editor/Explorer.d.ts.map +0 -1
  229. package/lib/typescript/network/components/response-editor/Explorer.web.d.ts.map +0 -1
  230. package/lib/typescript/network/components/response-editor/deleteNestedDataByPath.d.ts.map +0 -1
  231. package/lib/typescript/network/components/response-editor/editorContext.d.ts.map +0 -1
  232. package/lib/typescript/network/components/response-editor/updateNestedDataByPath.d.ts.map +0 -1
  233. package/lib/typescript/network/conditions/NetworkConditionsControl.d.ts.map +0 -1
  234. package/lib/typescript/network/conditions/NetworkConditionsControl.test.d.ts.map +0 -1
  235. package/lib/typescript/network/conditions/NetworkConditionsIcon.d.ts.map +0 -1
  236. package/lib/typescript/network/conditions/NetworkFloatingTool.d.ts.map +0 -1
  237. package/lib/typescript/network/conditions/NetworkFloatingTool.test.d.ts.map +0 -1
  238. package/lib/typescript/network/conditions/store.d.ts.map +0 -1
  239. package/lib/typescript/network/conditions/wait.d.ts.map +0 -1
  240. package/lib/typescript/network/conditions/xhr.d.ts.map +0 -1
  241. package/lib/typescript/network/hooks/useLiveNetworkEvent.d.ts.map +0 -1
  242. package/lib/typescript/network/hooks/useNetworkBadgeCounts.d.ts.map +0 -1
  243. package/lib/typescript/network/hooks/useNetworkEventList.d.ts.map +0 -1
  244. package/lib/typescript/network/hooks/useNetworkEvents.d.ts.map +0 -1
  245. package/lib/typescript/network/hooks/useNetworkHasMatches.d.ts.map +0 -1
  246. package/lib/typescript/network/hooks/useNetworkSaved.d.ts.map +0 -1
  247. package/lib/typescript/network/hooks/useNetworkSelection.d.ts.map +0 -1
  248. package/lib/typescript/network/hooks/useOverrideRules.d.ts.map +0 -1
  249. package/lib/typescript/network/hooks/useTickEveryMinute.d.ts.map +0 -1
  250. package/lib/typescript/network/overrides/applyToFetch.d.ts.map +0 -1
  251. package/lib/typescript/network/overrides/applyToXhr.d.ts.map +0 -1
  252. package/lib/typescript/network/overrides/engine.d.ts.map +0 -1
  253. package/lib/typescript/network/overrides/matchRule.d.ts.map +0 -1
  254. package/lib/typescript/network/overrides/overrideRulesStore.d.ts.map +0 -1
  255. package/lib/typescript/network/overrides/presets.d.ts.map +0 -1
  256. package/lib/typescript/network/overrides/resolveOverride.d.ts.map +0 -1
  257. package/lib/typescript/network/overrides/types.d.ts.map +0 -1
  258. package/lib/typescript/network/sync/networkBodyResolver.d.ts.map +0 -1
  259. package/lib/typescript/network/sync/networkSyncAdapter.d.ts.map +0 -1
  260. package/lib/typescript/network/sync/overrideHonesty.release.test.d.ts.map +0 -1
  261. package/lib/typescript/network/types/index.d.ts.map +0 -1
  262. package/lib/typescript/network/utils/extractOperationName.d.ts.map +0 -1
  263. package/lib/typescript/network/utils/filterNetworkEvents.d.ts.map +0 -1
  264. package/lib/typescript/network/utils/formatGraphQLVariables.d.ts.map +0 -1
  265. package/lib/typescript/network/utils/formatting.d.ts.map +0 -1
  266. package/lib/typescript/network/utils/generateCurl.d.ts.map +0 -1
  267. package/lib/typescript/network/utils/generateNetworkCopyText.d.ts.map +0 -1
  268. package/lib/typescript/network/utils/httpCompletion.d.ts.map +0 -1
  269. package/lib/typescript/network/utils/networkEventStore.d.ts.map +0 -1
  270. package/lib/typescript/network/utils/networkListener.d.ts.map +0 -1
  271. package/lib/typescript/network/utils/networkSavedStore.d.ts.map +0 -1
  272. package/lib/typescript/network/utils/networkSelectionStore.d.ts.map +0 -1
  273. package/lib/typescript/network/utils/selectSavedEvents.d.ts.map +0 -1
  274. package/lib/typescript/network/utils/withPinnedFirst.d.ts.map +0 -1
  275. package/lib/typescript/preset.d.ts.map +0 -1
@@ -1,453 +1,2 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.canSynthesize = canSynthesize;
7
- exports.canSynthesizeStandard = canSynthesizeStandard;
8
- exports.completeNativeOverride = completeNativeOverride;
9
- exports.runOverride = runOverride;
10
- /**
11
- * Perform an override outcome against an XMLHttpRequest — React Native's OR a
12
- * standards (browser/webview) one.
13
- *
14
- * WHY THIS IS POSSIBLE ON RN: React Native's XMLHttpRequest
15
- * (`react-native/Libraries/Network/XMLHttpRequest.js`) is pure JavaScript.
16
- * `readyState`, `status`, `responseHeaders` and `responseURL` are plain
17
- * writable fields, and `setResponseHeaders()` / `setReadyState()` are real
18
- * methods — `setReadyState(DONE)` dispatches the correct terminal event off
19
- * internal flags (`_aborted` → abort, `_hasError` + `_timedOut` → timeout,
20
- * `_hasError` → error, otherwise load; always loadend). So a response can be
21
- * synthesized end to end without touching native code.
22
- *
23
- * WHY XHR IS THE ONLY PLACE WE HOOK ON RN:
24
- * `react-native/Libraries/Network/fetch.js` is `require('whatwg-fetch')` —
25
- * RN's `fetch` IS the polyfill over XMLHttpRequest. Overriding here therefore
26
- * covers `fetch`, `axios` and raw XHR through one code path, and the fake
27
- * response flows back up through the polyfill so the tool records it without
28
- * any extra plumbing.
29
- *
30
- * Verified field-for-field on React Native 0.81.4 and 0.85.3.
31
- *
32
- * WHY THERE IS A SECOND PATH: on a STANDARDS XMLHttpRequest (a webview port —
33
- * Tauri/Capacitor — or react-native-web) none of the RN internals exist, and
34
- * `status` / `readyState` / `response` are readonly ACCESSORS on
35
- * `XMLHttpRequest.prototype`, so plain assignment silently no-ops (or throws
36
- * in strict mode). This file used to feature-detect that and give up —
37
- * "degraded, but never broken" — which was right for react-native-web as a
38
- * by-product of an RN app, and wrong the moment the web ports made the
39
- * browser XHR a first-class target: the row got FLAGGED as overridden (the
40
- * rule matched) while the real request went out. The fix is
41
- * `runStandardOverride` below: `Object.defineProperty` INSTANCE own-properties
42
- * shadow the prototype accessors (legal on any object), and the lifecycle
43
- * events are dispatched by hand through the XHR's own EventTarget — which
44
- * fires `addEventListener` listeners AND the `onload`/`onloadend`/
45
- * `onreadystatechange` handler attributes, exactly what axios's XHR adapter
46
- * listens on.
47
- *
48
- * Several non-obvious behaviours are handled below; each one is a real bug if
49
- * you skip it, and each is commented at the line that fixes it.
50
- */
51
-
52
- const HEADERS_RECEIVED = 2;
53
- const LOADING = 3;
54
- const DONE = 4;
55
-
56
- /**
57
- * The private surface of RN's XMLHttpRequest that we drive.
58
- *
59
- * Typed explicitly rather than reached for with `any` so that if a future React
60
- * Native renames one of these, the compiler points at every use — and so the
61
- * blast radius of "we depend on RN internals" is one interface.
62
- */
63
-
64
- const internalsOf = xhr => xhr;
65
- let warnedUnsupported = false;
66
-
67
- /**
68
- * Can this XMLHttpRequest be driven through React Native's internals?
69
- *
70
- * The RN technique rests on those internals, so it is feature-detected rather
71
- * than assumed. A request that fails this check is NOT automatically a lost
72
- * cause — `canSynthesizeStandard` covers the standards XHR next.
73
- */
74
- function canSynthesize(xhr) {
75
- const internals = internalsOf(xhr);
76
- return typeof internals.setReadyState === "function" && typeof internals.setResponseHeaders === "function";
77
- }
78
-
79
- /**
80
- * Can this XMLHttpRequest be driven as a STANDARDS one?
81
- *
82
- * `dispatchEvent` is the load-bearing requirement: the whole standard path
83
- * works by defining instance own-properties and then dispatching the
84
- * lifecycle events through the XHR's own EventTarget. `removeEventListener`
85
- * rules out half-mocks that could take the branch and then leak listeners.
86
- */
87
- function canSynthesizeStandard(xhr) {
88
- return typeof xhr.addEventListener === "function" && typeof xhr.removeEventListener === "function" && typeof xhr.dispatchEvent === "function";
89
- }
90
- function warnUnsupported() {
91
- if (warnedUnsupported) return;
92
- warnedUnsupported = true;
93
- if (typeof __DEV__ !== "undefined" && __DEV__) {
94
- console.warn("[Buoy] Network overrides need an XMLHttpRequest they can drive (React " + "Native's, or a standards EventTarget one) and this environment " + "provides neither — requests will run normally.");
95
- }
96
- }
97
-
98
- /** Synthesize a successful response. */
99
- function respond(xhr, url, outcome) {
100
- const internals = internalsOf(xhr);
101
-
102
- // `_reset()` does `delete this.responseURL`, so `'responseURL' in xhr` is
103
- // FALSE on a fresh request — and whatwg-fetch reads exactly that to populate
104
- // `Response.url` (fetch.js:558). Without this line every overridden fetch
105
- // response would silently carry `url: ""`.
106
- internals.responseURL = url;
107
- internals.status = outcome.status;
108
- // RN has no `statusText` field at all (real requests report `undefined`), so
109
- // this is a new own property. Harmless, and it makes the tool's list read
110
- // correctly instead of showing a bare number.
111
- internals.statusText = outcome.statusText;
112
- internals.setResponseHeaders?.(outcome.headers);
113
- // HEADERS_RECEIVED also stamps the interceptor's existing `_ttfb`, so an
114
- // overridden request reports its injected latency like a real one.
115
- internals.setReadyState?.(HEADERS_RECEIVED);
116
- if (internals._aborted) return;
117
-
118
- // whatwg-fetch sets `responseType = 'blob'` before every send
119
- // (fetch.js:599-606), which would make RN's `response` getter demand a native
120
- // Blob descriptor from BlobManager. But the polyfill reads the response
121
- // exactly once — `'response' in xhr ? xhr.response : xhr.responseText`
122
- // (fetch.js:559) — and never re-reads `responseType`. Handing back text is
123
- // therefore both sufficient and strictly simpler: no Blob, no FileReader, no
124
- // native round trip, and `.json()` becomes a synchronous JSON.parse.
125
- //
126
- // Assign the FIELD, not the property: the `responseType` setter throws once
127
- // `_sent` is true (XMLHttpRequest.js:215), and we set `_sent` above.
128
- internals._responseType = "text";
129
- internals._response = outcome.body;
130
- internals._cachedResponse = undefined; // force the getter to recompute
131
- internals.setReadyState?.(LOADING);
132
- if (internals._aborted) return;
133
- internals.setReadyState?.(DONE); // dispatches 'load' then 'loadend'
134
- }
135
-
136
- /** Synthesize a transport failure — offline or timeout. */
137
- function fail(xhr, outcome) {
138
- const internals = internalsOf(xhr);
139
- const timedOut = outcome.failKind === "timeout";
140
-
141
- // These two flags are the entire difference between the 'error' and
142
- // 'timeout' events — see `setReadyState` in XMLHttpRequest.js. whatwg-fetch
143
- // turns them into `TypeError: Network request failed` and
144
- // `TypeError: Network request timed out` respectively, which is exactly what
145
- // the app would see from a real dead connection.
146
- internals._hasError = true;
147
- internals._timedOut = timedOut;
148
- internals._responseType = "text";
149
- internals._response = timedOut ? "Request timed out (Buoy override)" : "Network request failed (Buoy override)";
150
- internals._cachedResponse = undefined;
151
- internals.setReadyState?.(DONE);
152
- }
153
-
154
- // ============================================================================
155
- // STANDARDS XMLHttpRequest path (webview ports / react-native-web)
156
- // ============================================================================
157
-
158
- /**
159
- * Shadow a prototype accessor with an instance own-property.
160
- *
161
- * This is the entire trick: `xhr.status = 500` silently no-ops (or throws in
162
- * strict mode) against the readonly getter on `XMLHttpRequest.prototype`, but
163
- * an own DATA property on the instance is legal and takes precedence in every
164
- * lookup. `configurable: true` so `readyState` can be redefined per
165
- * transition. Works identically against RN's plain class fields, so nothing
166
- * here is browser-only — the RN path just has a richer mechanism available.
167
- */
168
- function defineOwn(xhr, name, value) {
169
- Object.defineProperty(xhr, name, {
170
- value,
171
- configurable: true,
172
- enumerable: true,
173
- writable: false
174
- });
175
- }
176
-
177
- /**
178
- * Build a lifecycle event to dispatch by hand.
179
- *
180
- * `ProgressEvent` where the spec uses one (load/loadend/error/timeout/abort)
181
- * and the constructor exists; plain `Event` otherwise (Node test runs have no
182
- * ProgressEvent); a `{ type }` literal as the last resort for event-target
183
- * shims. Dispatching through the XHR's own EventTarget is what makes the
184
- * `onload`/`onloadend`/`onreadystatechange` handler ATTRIBUTES fire too —
185
- * they're listeners in the same list, which is exactly what axios's adapter
186
- * registers.
187
- */
188
- function makeEvent(type) {
189
- if (type !== "readystatechange" && typeof ProgressEvent === "function") {
190
- try {
191
- return new ProgressEvent(type);
192
- } catch {
193
- // fall through
194
- }
195
- }
196
- if (typeof Event === "function") {
197
- try {
198
- return new Event(type);
199
- } catch {
200
- // fall through
201
- }
202
- }
203
- return {
204
- type
205
- };
206
- }
207
- function fireEvent(xhr, type) {
208
- xhr.dispatchEvent(makeEvent(type));
209
- }
210
-
211
- /** Move the shadowed `readyState` and announce it — the interceptor's own
212
- * listener stamps TTFB off the HEADERS_RECEIVED notification, same as a real
213
- * response. */
214
- function setStandardReadyState(xhr, state) {
215
- defineOwn(xhr, "readyState", state);
216
- fireEvent(xhr, "readystatechange");
217
- }
218
-
219
- /**
220
- * `xhr.response` in the caller's requested shape.
221
- *
222
- * A standards XHR types `response` off `responseType`; axios sets it when the
223
- * caller asked for one (default '' → text). JSON is parsed (spec: null on
224
- * parse failure), arraybuffer/blob are best-effort encodings of the rule's
225
- * text body, everything else falls back to the string.
226
- */
227
- function standardResponseFor(xhr, outcome) {
228
- let responseType = "";
229
- try {
230
- responseType = xhr.responseType;
231
- } catch {
232
- // Some shims throw on access before send — treat as default text.
233
- }
234
- switch (responseType) {
235
- case "":
236
- case "text":
237
- return outcome.body;
238
- case "json":
239
- try {
240
- return JSON.parse(outcome.body);
241
- } catch {
242
- return null;
243
- }
244
- case "arraybuffer":
245
- if (typeof TextEncoder === "function") {
246
- return new TextEncoder().encode(outcome.body).buffer;
247
- }
248
- return outcome.body;
249
- case "blob":
250
- if (typeof Blob === "function") {
251
- const contentType = Object.entries(outcome.headers).find(([name]) => name.toLowerCase() === "content-type")?.[1] ?? "";
252
- return new Blob([outcome.body], {
253
- type: contentType
254
- });
255
- }
256
- return outcome.body;
257
- default:
258
- return outcome.body;
259
- }
260
- }
261
-
262
- /** Synthesize a successful response on a standards XHR. */
263
- function respondStandard(xhr, url, outcome, isAborted) {
264
- const headers = outcome.headers;
265
- // Spec shape: lowercase names, `name: value\r\n` per pair — axios splits on
266
- // newlines and trims, raw XHR users get what a real response reads like.
267
- const allHeaders = Object.entries(headers).map(([name, value]) => `${name.toLowerCase()}: ${value}\r\n`).join("");
268
- defineOwn(xhr, "getAllResponseHeaders", () => allHeaders);
269
- defineOwn(xhr, "getResponseHeader", name => {
270
- const wanted = String(name).toLowerCase();
271
- for (const [key, value] of Object.entries(headers)) {
272
- if (key.toLowerCase() === wanted) return value;
273
- }
274
- return null;
275
- });
276
- defineOwn(xhr, "responseURL", url);
277
- defineOwn(xhr, "status", outcome.status);
278
- defineOwn(xhr, "statusText", outcome.statusText);
279
- defineOwn(xhr, "response", standardResponseFor(xhr, outcome));
280
- // Own property, so it answers with the body even under a non-text
281
- // `responseType` (where the real accessor would throw). axios reads it
282
- // whenever `responseType` is '' or 'text'.
283
- defineOwn(xhr, "responseText", outcome.body);
284
- setStandardReadyState(xhr, HEADERS_RECEIVED);
285
- if (isAborted()) return;
286
- setStandardReadyState(xhr, LOADING);
287
- if (isAborted()) return;
288
- setStandardReadyState(xhr, DONE);
289
- fireEvent(xhr, "load");
290
- fireEvent(xhr, "loadend");
291
- }
292
-
293
- /** Synthesize a transport failure on a standards XHR — offline or timeout. */
294
- function failStandard(xhr, outcome) {
295
- // `status` stays 0 (the prototype getter's answer for a request whose real
296
- // send never ran) — exactly what a genuine network error reports. The
297
- // 'error'/'timeout' event is the entire signal; axios turns them into
298
- // ERR_NETWORK / ECONNABORTED the same way whatwg-fetch turns RN's flags
299
- // into TypeErrors.
300
- setStandardReadyState(xhr, DONE);
301
- fireEvent(xhr, outcome.failKind === "timeout" ? "timeout" : "error");
302
- fireEvent(xhr, "loadend");
303
- }
304
-
305
- /**
306
- * Apply an outcome to a standards XMLHttpRequest that has NOT been sent.
307
- *
308
- * The real `send()` is never invoked for respond/fail — the request must not
309
- * touch the network. That leaves `abort()` with nothing to do natively (per
310
- * spec, abort on a request whose send flag is unset dispatches NOTHING), so
311
- * an instance shadow gives it the in-flight behaviour the app expects:
312
- * cancel the pending outcome and dispatch abort + loadend. The shadow deletes
313
- * itself the moment it can't matter anymore — after settling, and before a
314
- * `delay` pass-through hands the request to the real network, where the
315
- * prototype `abort()` must be reachable again.
316
- */
317
- function runStandardOverride(xhr, url, outcome, passThrough) {
318
- let timer = null;
319
- let aborted = false;
320
- let settled = false;
321
- const restoreAbort = () => {
322
- try {
323
- delete xhr.abort;
324
- } catch {
325
- // Non-configurable shadow can't happen (we define it configurable), but
326
- // never let cleanup throw into app code.
327
- }
328
- };
329
- Object.defineProperty(xhr, "abort", {
330
- configurable: true,
331
- writable: true,
332
- value: () => {
333
- if (settled || aborted) return;
334
- aborted = true;
335
- settled = true;
336
- if (timer !== null) {
337
- clearTimeout(timer);
338
- timer = null;
339
- }
340
- restoreAbort();
341
- // The in-flight abort sequence: DONE, then 'abort', then 'loadend' —
342
- // whatwg's request-error steps, which is also what RN's setReadyState
343
- // dispatches off `_aborted`.
344
- setStandardReadyState(xhr, DONE);
345
- fireEvent(xhr, "abort");
346
- fireEvent(xhr, "loadend");
347
- }
348
- });
349
- const fire = () => {
350
- timer = null;
351
- if (aborted) return;
352
- if (outcome.kind === "delay") {
353
- // The real request is about to be genuinely in flight — put the
354
- // prototype `abort()` back FIRST so cancelling reaches the network.
355
- restoreAbort();
356
- passThrough();
357
- return;
358
- }
359
- if (outcome.kind === "fail") {
360
- failStandard(xhr, outcome);
361
- } else {
362
- respondStandard(xhr, url, outcome, () => aborted);
363
- }
364
- settled = true;
365
- restoreAbort();
366
- };
367
-
368
- // ALWAYS asynchronous, even at 0ms — same contract as the RN path: callers
369
- // legitimately attach handlers after `send()` returns (axios does).
370
- timer = setTimeout(fire, outcome.delayMs);
371
- return true;
372
- }
373
-
374
- // ============================================================================
375
- // Entry point
376
- // ============================================================================
377
-
378
- /**
379
- * Apply an outcome to a request that has NOT been sent yet.
380
- *
381
- * Returns `false` when this environment can't be driven by hand, in which case
382
- * the caller must send the request normally.
383
- *
384
- * @param passThrough Sends the real request. Only used by `kind: "delay"`.
385
- */
386
- function runOverride(xhr, url, outcome, passThrough) {
387
- if (!canSynthesize(xhr)) {
388
- // Not React Native's XMLHttpRequest — a standards one (webview port,
389
- // react-native-web) is driven through instance property shadowing
390
- // instead. Order matters: RN's XHR also extends an EventTarget shim, so
391
- // the RN check must win first.
392
- if (canSynthesizeStandard(xhr)) {
393
- return runStandardOverride(xhr, url, outcome, passThrough);
394
- }
395
- warnUnsupported();
396
- return false;
397
- }
398
- const internals = internalsOf(xhr);
399
-
400
- // Claim the request as sent, for all three kinds.
401
- //
402
- // We skip RN's own `send()`, which is what normally sets this — and `abort()`
403
- // branches on it: with `_sent` false it treats the request as never started,
404
- // silently `_reset()`s, and dispatches NOTHING. The app's fetch promise would
405
- // then never settle (a hang), and for a synthesized response our own timer
406
- // would afterwards fire 'load' on a reset object, resolving a fetch the app
407
- // had already aborted. Claiming it means abort() dispatches DONE + 'abort'
408
- // and whatwg-fetch rejects with AbortError, as it should.
409
- internals._sent = true;
410
-
411
- // There is no native request to cancel until a delayed send is dispatched.
412
- internals._requestId = null;
413
- let timer = null;
414
- const onAbort = () => {
415
- xhr.removeEventListener("abort", onAbort);
416
- if (timer !== null) {
417
- clearTimeout(timer);
418
- timer = null;
419
- }
420
- };
421
- xhr.addEventListener("abort", onAbort);
422
- const fire = () => {
423
- timer = null;
424
- xhr.removeEventListener("abort", onAbort);
425
- // The real guard. `_aborted` is set unconditionally by `abort()` and
426
- // survives its `_reset()`, so this is true whether or not the 'abort' event
427
- // was ever dispatched.
428
- if (internals._aborted) return;
429
- if (outcome.kind === "delay") {
430
- // Hand the state machine back before RN's `send()` sees it: it throws
431
- // 'Request has already been sent' on a truthy `_sent`.
432
- internals._sent = false;
433
- passThrough();
434
- return;
435
- }
436
- if (outcome.kind === "fail") {
437
- fail(xhr, outcome);
438
- return;
439
- }
440
- respond(xhr, url, outcome);
441
- };
442
-
443
- // ALWAYS asynchronous, even at 0ms. Callers legitimately attach handlers
444
- // after `send()` returns (axios does), and a synchronous response would fire
445
- // 'load' before they exist.
446
- timer = setTimeout(fire, outcome.delayMs);
447
- return true;
448
- }
449
-
450
- /** Complete an already scheduled native outcome without adding another timer. */
451
- function completeNativeOverride(xhr, url, outcome) {
452
- if (outcome.kind === "fail") fail(xhr, outcome);else if (outcome.kind === "respond") respond(xhr, url, outcome);
453
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.canSynthesize=canSynthesize;exports.canSynthesizeStandard=canSynthesizeStandard;exports.completeNativeOverride=completeNativeOverride;exports.hasPendingStandardRequest=hasPendingStandardRequest;exports.runOverride=runOverride;var _realNow=require("../utils/realNow");const HEADERS_RECEIVED=2;const LOADING=3;const DONE=4;const internalsOf=e=>e;let warnedUnsupported=false;function canSynthesize(e){const n=internalsOf(e);return typeof n.setReadyState==="function"&&typeof n.setResponseHeaders==="function"}function canSynthesizeStandard(e){return typeof e.addEventListener==="function"&&typeof e.removeEventListener==="function"&&typeof e.dispatchEvent==="function"}function warnUnsupported(){if(warnedUnsupported)return;warnedUnsupported=true;if(typeof __DEV__!=="undefined"&&__DEV__){console.warn("[Buoy] Network overrides need an XMLHttpRequest they can drive (React Native's, or a standards EventTarget one) and this environment provides neither \u2014 requests will run normally.")}}function respond(e,n,t){const r=internalsOf(e);r.responseURL=n;r.status=t.status;r.statusText=t.statusText;r.setResponseHeaders?.(t.headers);r.setReadyState?.(HEADERS_RECEIVED);if(r._aborted)return;r._responseType="text";r._response=t.body;r._cachedResponse=void 0;r.setReadyState?.(LOADING);if(r._aborted)return;r.setReadyState?.(DONE)}function fail(e,n){const t=internalsOf(e);const r=n.failKind==="timeout";t._hasError=true;t._timedOut=r;t._responseType="text";t._response=r?"Request timed out (Buoy override)":"Network request failed (Buoy override)";t._cachedResponse=void 0;t.setReadyState?.(DONE)}function defineOwn(e,n,t){Object.defineProperty(e,n,{value:t,configurable:true,enumerable:true,writable:false})}function makeEvent(e){if(e!=="readystatechange"&&typeof ProgressEvent==="function"){try{return new ProgressEvent(e)}catch{}}if(typeof Event==="function"){try{return new Event(e)}catch{}}return{type:e}}function fireEvent(e,n){e.dispatchEvent(makeEvent(n))}function setStandardReadyState(e,n){defineOwn(e,"readyState",n);fireEvent(e,"readystatechange")}function standardResponseFor(e,n){let t="";try{t=e.responseType}catch{}switch(t){case"":case"text":return n.body;case"json":try{return JSON.parse(n.body)}catch{return null}case"arraybuffer":if(typeof TextEncoder==="function"){return new TextEncoder().encode(n.body).buffer}return n.body;case"blob":if(typeof Blob==="function"){const r=Object.entries(n.headers).find(([s])=>s.toLowerCase()==="content-type")?.[1]??"";return new Blob([n.body],{type:r})}return n.body;default:return n.body}}function respondStandard(e,n,t,r){const s=t.headers;const i=Object.entries(s).map(([a,o])=>`${a.toLowerCase()}: ${o}\r
2
+ `).join("");defineOwn(e,"getAllResponseHeaders",()=>i);defineOwn(e,"getResponseHeader",a=>{const o=String(a).toLowerCase();for(const[f,c]of Object.entries(s)){if(f.toLowerCase()===o)return c}return null});defineOwn(e,"responseURL",n);defineOwn(e,"status",t.status);defineOwn(e,"statusText",t.statusText);defineOwn(e,"response",standardResponseFor(e,t));defineOwn(e,"responseText",t.body);setStandardReadyState(e,HEADERS_RECEIVED);if(r())return;setStandardReadyState(e,LOADING);if(r())return;setStandardReadyState(e,DONE);if(r())return;fireEvent(e,"load");fireEvent(e,"loadend")}function failStandard(e,n){setStandardReadyState(e,DONE);fireEvent(e,n.failKind==="timeout"?"timeout":"error");fireEvent(e,"loadend")}const pendingStandardRequests=new WeakMap;function hasPendingStandardRequest(e){return pendingStandardRequests.has(e)}function runStandardOverride(e,n,t,r){const s=(0,_realNow.realNow)();const i={};let a;let o;let f=false;let c=false;let y=false;let u=e.timeout;const E=e.abort;const R=e.open;const g=["abort","open","timeout","readyState","status","statusText","response","responseText","responseURL","getAllResponseHeaders","getResponseHeader"];const S=new Map(g.map(d=>[d,Object.getOwnPropertyDescriptor(e,d)]));let p=Object.getPrototypeOf(e);let b;while(p&&!b){b=Object.getOwnPropertyDescriptor(p,"timeout");p=Object.getPrototypeOf(p)}const l=()=>{f=true;if(pendingStandardRequests.get(e)===i)pendingStandardRequests.delete(e);clearTimeout(a);(0,_realNow.realClearTimeout)(o);e.removeEventListener("loadend",l)};const O=()=>{l();for(const[d,w]of S){if(w)Object.defineProperty(e,d,w);else delete e[d]}e.timeout=u};const v=()=>{(0,_realNow.realClearTimeout)(o);if(y){b?.set?.call(e,u>0?Math.max(1,u-((0,_realNow.realNow)()-s)):0)}else if(u>0){o=(0,_realNow.realSetTimeout)(()=>{if(f)return;clearTimeout(a);failStandard(e,{...t,kind:"fail",failKind:"timeout"});l()},Math.max(0,u-((0,_realNow.realNow)()-s)))}};Object.defineProperty(e,"timeout",{configurable:true,get:()=>u,set:d=>{u=Math.max(0,Number(d)||0);v()}});Object.defineProperty(e,"open",{configurable:true,value:(...d)=>{O();return Reflect.apply(R,e,d)}});Object.defineProperty(e,"abort",{configurable:true,value:()=>{if(y||f){O();E.call(e);return}c=true;clearTimeout(a);setStandardReadyState(e,DONE);fireEvent(e,"abort");fireEvent(e,"loadend");l();if(!pendingStandardRequests.has(e))defineOwn(e,"readyState",0)}});pendingStandardRequests.set(e,i);e.addEventListener("loadend",l);v();a=setTimeout(()=>{if(f||c)return;if(t.kind==="delay"){y=true;v();try{r()}catch{failStandard(e,{...t,kind:"fail",failKind:"network"});l()}return}if(t.kind==="fail")failStandard(e,t);else respondStandard(e,n,t,()=>c||pendingStandardRequests.get(e)!==i);l()},t.delayMs);return true}function runOverride(e,n,t,r){if(!canSynthesize(e)){if(canSynthesizeStandard(e)){return runStandardOverride(e,n,t,r)}warnUnsupported();return false}const s=internalsOf(e);s._sent=true;s._requestId=null;let i=null;const a=()=>{e.removeEventListener("abort",a);if(i!==null){clearTimeout(i);i=null}};e.addEventListener("abort",a);const o=()=>{i=null;e.removeEventListener("abort",a);if(s._aborted)return;if(t.kind==="delay"){s._sent=false;r();return}if(t.kind==="fail"){fail(e,t);return}respond(e,n,t)};i=setTimeout(o,t.delayMs);return true}function completeNativeOverride(e,n,t){if(t.kind==="fail")fail(e,t);else if(t.kind==="respond")respond(e,n,t)}
@@ -1,93 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.OVERRIDES_INACTIVE_REASON = void 0;
7
- exports.inspectEngine = inspectEngine;
8
- exports.overrideForRequest = overrideForRequest;
9
- exports.overridesCanApply = overridesCanApply;
10
- exports.setOverrideHooks = setOverrideHooks;
11
- var _sharedUi = require("@buoy-gg/shared-ui");
12
- var _resolveOverride = require("./resolveOverride");
13
- /**
14
- * The seam between the interceptor and the rule store.
15
- *
16
- * It exists to keep the import graph acyclic: `networkListener` needs rules,
17
- * and the rule store needs the listener (to keep the swizzle installed while a
18
- * rule is active). Rather than have them import each other, the store REGISTERS
19
- * itself here and the listener asks here. Both sides import only this leaf.
20
- *
21
- * It's also the single place the production gate lives — see `overrideForRequest`.
22
- */
23
-
24
- let hooks = null;
25
- function setOverrideHooks(next) {
26
- hooks = next;
27
- }
28
-
29
- /**
30
- * Whether a rule stored right now could ever be applied to a request.
31
- *
32
- * `overrideForRequest` refuses in a release build, but every WRITE path
33
- * (`upsertOverrideRule`, `setOverrideRuleEnabled`, `setOverridesEnabled`) still
34
- * succeeds and still persists, so a remote caller was told `{ok: true}` for a
35
- * rule that would never fire. That is fine for a human looking at the Network
36
- * tool — they can see nothing is happening — and actively harmful for a remote
37
- * driver relaying "done" to a QA tester, who then files a bug against data that
38
- * was never actually faked.
39
- *
40
- * So the same gate is readable here and stamped onto those receipts. One
41
- * predicate, one truth, at the same single entry point.
42
- */
43
- function overridesCanApply() {
44
- // `__DEV__` is undefined outside React Native (unit tests, the desktop
45
- // bundle); only an explicit `false` — a real release build — disables it.
46
- return (0, _sharedUi.hasAccountAccess)() && !(typeof __DEV__ !== "undefined" && !__DEV__);
47
- }
48
-
49
- /** Why overrides are inert, for a caller that has to explain it to a person. */
50
- const OVERRIDES_INACTIVE_REASON = exports.OVERRIDES_INACTIVE_REASON = "Response overrides never apply in a release build — the rule is saved but will not affect any request.";
51
-
52
- /**
53
- * Diagnostics for the sync adapter's `debugOverrides` action.
54
- *
55
- * Reads the engine's own view of the world — crucially `hooks`, which is
56
- * MODULE state here: if the interceptor and the rule store ever ended up with
57
- * separate copies of this file, this is the only place that shows it.
58
- */
59
- function inspectEngine(url, method) {
60
- return {
61
- hooksInstalled: hooks !== null,
62
- devFlag: typeof __DEV__ === "undefined" ? "undefined" : __DEV__,
63
- ruleCount: hooks ? hooks.getRules().length : 0,
64
- // Non-recording probe — a diagnostic must not burn a rule's `times` budget
65
- // or nudge an alternating rule's phase.
66
- matches: hooks ? (0, _resolveOverride.findMatchingRule)(url, method, hooks.getRules()) !== null : false
67
- };
68
- }
69
-
70
- /**
71
- * Resolve an override for one outgoing request, recording the hit.
72
- *
73
- * NEVER ACTIVE IN A PRODUCTION BUILD. A shipped app that synthesizes 500s or
74
- * silently swallows requests is a catastrophe of a different order than a
75
- * broken dev tool, so the gate is here — at the single entry point — rather
76
- * than trusted to every call site.
77
- */
78
- function overrideForRequest(url, method) {
79
- if (!hooks) return null;
80
- if (!overridesCanApply()) return null;
81
- const rules = hooks.getRules();
82
- if (rules.length === 0) return null;
83
- const rule = (0, _resolveOverride.findMatchingRule)(url, method, rules);
84
- if (!rule) return null;
85
-
86
- // Phase is read BEFORE the match is recorded, so a fresh alternating rule
87
- // (`seen === 0`) lets this first request through and takes the next one.
88
- const applies = (0, _resolveOverride.shouldApply)(rule);
89
- hooks.recordMatch(rule.id);
90
- if (!applies) return null;
91
- hooks.recordHit(rule.id);
92
- return (0, _resolveOverride.toOutcome)(rule);
93
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.OVERRIDES_INACTIVE_REASON=void 0;exports.inspectEngine=inspectEngine;exports.overrideForRequest=overrideForRequest;exports.overridesCanApply=overridesCanApply;exports.setOverrideHooks=setOverrideHooks;var _sharedUi=require("@buoy-gg/shared-ui");var _resolveOverride=require("./resolveOverride");let hooks=null;function setOverrideHooks(e){hooks=e}function overridesCanApply(){return(0,_sharedUi.hasAccountAccess)()&&!(typeof __DEV__!=="undefined"&&!__DEV__)}const OVERRIDES_INACTIVE_REASON=exports.OVERRIDES_INACTIVE_REASON="Response overrides never apply in a release build \u2014 the rule is saved but will not affect any request.";function inspectEngine(e,n){return{hooksInstalled:hooks!==null,devFlag:typeof __DEV__==="undefined"?"undefined":__DEV__,ruleCount:hooks?hooks.getRules().length:0,matches:hooks?(0,_resolveOverride.findMatchingRule)(e,n,hooks.getRules())!==null:false}}function overrideForRequest(e,n,s){if(!hooks)return null;if(!overridesCanApply())return null;const t=hooks.getRules();if(t.length===0)return null;const r=(0,_resolveOverride.findMatchingRule)(e,n,t,s);if(!r)return null;const u=(0,_resolveOverride.shouldApply)(r);hooks.recordMatch(r.id);if(!u)return null;hooks.recordHit(r.id);return(0,_resolveOverride.toOutcome)(r)}
@@ -1,81 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.compilePattern = compilePattern;
7
- exports.escapeRegex = escapeRegex;
8
- exports.ruleMatches = ruleMatches;
9
- /**
10
- * Glob matching for override rules — a faithful port of Chrome DevTools'.
11
- *
12
- * Ported from `NetworkPersistenceManager.ts:1051` + `StringUtilities.ts:9` in
13
- * the devtools-frontend source. Ported rather than reinvented on purpose: `*`
14
- * globs are the syntax developers already have in their fingers from Chrome's
15
- * "Override headers" `applyTo` field, and a pattern that behaves differently
16
- * here than it does in the browser would be a quiet trap.
17
- */
18
-
19
- /**
20
- * Chrome's escape set, character for character.
21
- *
22
- * `*` is deliberately ABSENT — it survives escaping so it can become `.*`
23
- * below. Everything else that means something to a regex is neutered.
24
- */
25
- const SPECIAL_CHARACTERS = "[]{}()\\.^$+|-,?";
26
-
27
- /**
28
- * Escape a glob into regex source: neutralize regex metacharacters, then
29
- * promote `*` to `.*`.
30
- *
31
- * `split`/`join` rather than `replaceAll` — same result, no reliance on how
32
- * complete a given Hermes build's ES2021 surface is.
33
- */
34
- function escapeRegex(pattern) {
35
- let result = "";
36
- for (let i = 0; i < pattern.length; i++) {
37
- const char = pattern.charAt(i);
38
- if (SPECIAL_CHARACTERS.indexOf(char) !== -1) {
39
- result += "\\";
40
- }
41
- result += char;
42
- }
43
- return result.split("*").join(".*");
44
- }
45
-
46
- /**
47
- * Compiled patterns, cached by source.
48
- *
49
- * `resolveOverride` runs on EVERY request the app makes, against every rule.
50
- * Recompiling a RegExp per request per rule is pure waste in the one place
51
- * this feature is allowed to cost nothing.
52
- */
53
- const compiled = new Map();
54
- function compilePattern(pattern) {
55
- const cached = compiled.get(pattern);
56
- if (cached) return cached;
57
- // Anchored, like Chrome's `^${...}$` — a pattern describes the whole URL, so
58
- // `pokeapi.co` matches nothing and `*pokeapi.co*` matches everything on that
59
- // host. Predictable beats clever; the rule editor writes full URLs for you.
60
- const regex = new RegExp(`^${escapeRegex(pattern)}$`);
61
- // Unbounded growth isn't possible in practice (patterns come from a capped
62
- // rule list), but a user editing a pattern character by character churns
63
- // entries, so keep the cache from becoming a leak.
64
- if (compiled.size > 200) compiled.clear();
65
- compiled.set(pattern, regex);
66
- return regex;
67
- }
68
-
69
- /** Does this rule apply to this request? Ignores `enabled` — callers check it. */
70
- function ruleMatches(rule, url, method) {
71
- if (rule.methods && rule.methods.length > 0) {
72
- if (!rule.methods.includes(method.toUpperCase())) return false;
73
- }
74
- try {
75
- return compilePattern(rule.urlPattern).test(url);
76
- } catch {
77
- // A pattern that can't compile matches nothing rather than throwing inside
78
- // the app's `send()`. The rule editor validates; this is the backstop.
79
- return false;
80
- }
81
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.compilePattern=compilePattern;exports.escapeRegex=escapeRegex;exports.ruleMatches=ruleMatches;const SPECIAL_CHARACTERS="[]{}()\\.^$+|-,?";function escapeRegex(e){let r="";for(let s=0;s<e.length;s++){const t=e.charAt(s);if(SPECIAL_CHARACTERS.indexOf(t)!==-1){r+="\\"}r+=t}return r.split("*").join(".*")}const compiled=new Map;function compilePattern(e){const r=compiled.get(e);if(r)return r;const s=e.startsWith("/")?`[a-zA-Z][a-zA-Z0-9+.-]*://[^/]*${escapeRegex(e)}`:escapeRegex(e);const t=new RegExp(`^${s}$`);if(compiled.size>200)compiled.clear();compiled.set(e,t);return t}function hasHeader(e,r){if(!e)return false;const s=r.toLowerCase();for(const t of Object.keys(e)){if(t.toLowerCase()===s&&e[t]!==void 0&&e[t]!=="")return true}return false}function ruleMatches(e,r,s,t){if(e.methods&&e.methods.length>0){if(!e.methods.includes(s.toUpperCase()))return false}if(e.requireHeader&&!hasHeader(t,e.requireHeader))return false;try{return compilePattern(e.urlPattern).test(r)}catch{return false}}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.overriddenEvents=overriddenEvents;var _matchRule=require("./matchRule");function overriddenEvents(n,d){if(d.length===0)return[];const o=new Set(d.map(t=>t.id));const i=new Set;for(const t of d){let r;for(const e of n){if(e.override&&o.has(e.override.ruleId)){i.add(e.id);continue}if(!(0,_matchRule.ruleMatches)(t,e.url,String(e.method||"GET"),e.requestHeaders))continue;if(e.timestamp>=t.createdAt)i.add(e.id);else if(!r||e.timestamp>r.timestamp)r=e}if(r)i.add(r.id)}return n.filter(t=>i.has(t.id))}