@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,510 +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.hasPendingStandardRequest = hasPendingStandardRequest;
10
- exports.runOverride = runOverride;
11
- /**
12
- * Perform an override outcome against an XMLHttpRequest — React Native's OR a
13
- * standards (browser/webview) one.
14
- *
15
- * WHY THIS IS POSSIBLE ON RN: React Native's XMLHttpRequest
16
- * (`react-native/Libraries/Network/XMLHttpRequest.js`) is pure JavaScript.
17
- * `readyState`, `status`, `responseHeaders` and `responseURL` are plain
18
- * writable fields, and `setResponseHeaders()` / `setReadyState()` are real
19
- * methods — `setReadyState(DONE)` dispatches the correct terminal event off
20
- * internal flags (`_aborted` → abort, `_hasError` + `_timedOut` → timeout,
21
- * `_hasError` → error, otherwise load; always loadend). So a response can be
22
- * synthesized end to end without touching native code.
23
- *
24
- * WHY XHR IS THE ONLY PLACE WE HOOK ON RN:
25
- * `react-native/Libraries/Network/fetch.js` is `require('whatwg-fetch')` —
26
- * RN's `fetch` IS the polyfill over XMLHttpRequest. Overriding here therefore
27
- * covers `fetch`, `axios` and raw XHR through one code path, and the fake
28
- * response flows back up through the polyfill so the tool records it without
29
- * any extra plumbing.
30
- *
31
- * Verified field-for-field on React Native 0.81.4 and 0.85.3.
32
- *
33
- * WHY THERE IS A SECOND PATH: on a STANDARDS XMLHttpRequest (a webview port —
34
- * Tauri/Capacitor — or react-native-web) none of the RN internals exist, and
35
- * `status` / `readyState` / `response` are readonly ACCESSORS on
36
- * `XMLHttpRequest.prototype`, so plain assignment silently no-ops (or throws
37
- * in strict mode). This file used to feature-detect that and give up —
38
- * "degraded, but never broken" — which was right for react-native-web as a
39
- * by-product of an RN app, and wrong the moment the web ports made the
40
- * browser XHR a first-class target: the row got FLAGGED as overridden (the
41
- * rule matched) while the real request went out. The fix is
42
- * `runStandardOverride` below: `Object.defineProperty` INSTANCE own-properties
43
- * shadow the prototype accessors (legal on any object), and the lifecycle
44
- * events are dispatched by hand through the XHR's own EventTarget — which
45
- * fires `addEventListener` listeners AND the `onload`/`onloadend`/
46
- * `onreadystatechange` handler attributes, exactly what axios's XHR adapter
47
- * listens on.
48
- *
49
- * Several non-obvious behaviours are handled below; each one is a real bug if
50
- * you skip it, and each is commented at the line that fixes it.
51
- */
52
-
53
- const HEADERS_RECEIVED = 2;
54
- const LOADING = 3;
55
- const DONE = 4;
56
-
57
- /**
58
- * The private surface of RN's XMLHttpRequest that we drive.
59
- *
60
- * Typed explicitly rather than reached for with `any` so that if a future React
61
- * Native renames one of these, the compiler points at every use — and so the
62
- * blast radius of "we depend on RN internals" is one interface.
63
- */
64
-
65
- const internalsOf = xhr => xhr;
66
- let warnedUnsupported = false;
67
-
68
- /**
69
- * Can this XMLHttpRequest be driven through React Native's internals?
70
- *
71
- * The RN technique rests on those internals, so it is feature-detected rather
72
- * than assumed. A request that fails this check is NOT automatically a lost
73
- * cause — `canSynthesizeStandard` covers the standards XHR next.
74
- */
75
- function canSynthesize(xhr) {
76
- const internals = internalsOf(xhr);
77
- return typeof internals.setReadyState === "function" && typeof internals.setResponseHeaders === "function";
78
- }
79
-
80
- /**
81
- * Can this XMLHttpRequest be driven as a STANDARDS one?
82
- *
83
- * `dispatchEvent` is the load-bearing requirement: the whole standard path
84
- * works by defining instance own-properties and then dispatching the
85
- * lifecycle events through the XHR's own EventTarget. `removeEventListener`
86
- * rules out half-mocks that could take the branch and then leak listeners.
87
- */
88
- function canSynthesizeStandard(xhr) {
89
- return typeof xhr.addEventListener === "function" && typeof xhr.removeEventListener === "function" && typeof xhr.dispatchEvent === "function";
90
- }
91
- function warnUnsupported() {
92
- if (warnedUnsupported) return;
93
- warnedUnsupported = true;
94
- if (typeof __DEV__ !== "undefined" && __DEV__) {
95
- 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.");
96
- }
97
- }
98
-
99
- /** Synthesize a successful response. */
100
- function respond(xhr, url, outcome) {
101
- const internals = internalsOf(xhr);
102
-
103
- // `_reset()` does `delete this.responseURL`, so `'responseURL' in xhr` is
104
- // FALSE on a fresh request — and whatwg-fetch reads exactly that to populate
105
- // `Response.url` (fetch.js:558). Without this line every overridden fetch
106
- // response would silently carry `url: ""`.
107
- internals.responseURL = url;
108
- internals.status = outcome.status;
109
- // RN has no `statusText` field at all (real requests report `undefined`), so
110
- // this is a new own property. Harmless, and it makes the tool's list read
111
- // correctly instead of showing a bare number.
112
- internals.statusText = outcome.statusText;
113
- internals.setResponseHeaders?.(outcome.headers);
114
- // HEADERS_RECEIVED also stamps the interceptor's existing `_ttfb`, so an
115
- // overridden request reports its injected latency like a real one.
116
- internals.setReadyState?.(HEADERS_RECEIVED);
117
- if (internals._aborted) return;
118
-
119
- // whatwg-fetch sets `responseType = 'blob'` before every send
120
- // (fetch.js:599-606), which would make RN's `response` getter demand a native
121
- // Blob descriptor from BlobManager. But the polyfill reads the response
122
- // exactly once — `'response' in xhr ? xhr.response : xhr.responseText`
123
- // (fetch.js:559) — and never re-reads `responseType`. Handing back text is
124
- // therefore both sufficient and strictly simpler: no Blob, no FileReader, no
125
- // native round trip, and `.json()` becomes a synchronous JSON.parse.
126
- //
127
- // Assign the FIELD, not the property: the `responseType` setter throws once
128
- // `_sent` is true (XMLHttpRequest.js:215), and we set `_sent` above.
129
- internals._responseType = "text";
130
- internals._response = outcome.body;
131
- internals._cachedResponse = undefined; // force the getter to recompute
132
- internals.setReadyState?.(LOADING);
133
- if (internals._aborted) return;
134
- internals.setReadyState?.(DONE); // dispatches 'load' then 'loadend'
135
- }
136
-
137
- /** Synthesize a transport failure — offline or timeout. */
138
- function fail(xhr, outcome) {
139
- const internals = internalsOf(xhr);
140
- const timedOut = outcome.failKind === "timeout";
141
-
142
- // These two flags are the entire difference between the 'error' and
143
- // 'timeout' events — see `setReadyState` in XMLHttpRequest.js. whatwg-fetch
144
- // turns them into `TypeError: Network request failed` and
145
- // `TypeError: Network request timed out` respectively, which is exactly what
146
- // the app would see from a real dead connection.
147
- internals._hasError = true;
148
- internals._timedOut = timedOut;
149
- internals._responseType = "text";
150
- internals._response = timedOut ? "Request timed out (Buoy override)" : "Network request failed (Buoy override)";
151
- internals._cachedResponse = undefined;
152
- internals.setReadyState?.(DONE);
153
- }
154
-
155
- // ============================================================================
156
- // STANDARDS XMLHttpRequest path (webview ports / react-native-web)
157
- // ============================================================================
158
-
159
- /**
160
- * Shadow a prototype accessor with an instance own-property.
161
- *
162
- * This is the entire trick: `xhr.status = 500` silently no-ops (or throws in
163
- * strict mode) against the readonly getter on `XMLHttpRequest.prototype`, but
164
- * an own DATA property on the instance is legal and takes precedence in every
165
- * lookup. `configurable: true` so `readyState` can be redefined per
166
- * transition. Works identically against RN's plain class fields, so nothing
167
- * here is browser-only — the RN path just has a richer mechanism available.
168
- */
169
- function defineOwn(xhr, name, value) {
170
- Object.defineProperty(xhr, name, {
171
- value,
172
- configurable: true,
173
- enumerable: true,
174
- writable: false
175
- });
176
- }
177
-
178
- /**
179
- * Build a lifecycle event to dispatch by hand.
180
- *
181
- * `ProgressEvent` where the spec uses one (load/loadend/error/timeout/abort)
182
- * and the constructor exists; plain `Event` otherwise (Node test runs have no
183
- * ProgressEvent); a `{ type }` literal as the last resort for event-target
184
- * shims. Dispatching through the XHR's own EventTarget is what makes the
185
- * `onload`/`onloadend`/`onreadystatechange` handler ATTRIBUTES fire too —
186
- * they're listeners in the same list, which is exactly what axios's adapter
187
- * registers.
188
- */
189
- function makeEvent(type) {
190
- if (type !== "readystatechange" && typeof ProgressEvent === "function") {
191
- try {
192
- return new ProgressEvent(type);
193
- } catch {
194
- // fall through
195
- }
196
- }
197
- if (typeof Event === "function") {
198
- try {
199
- return new Event(type);
200
- } catch {
201
- // fall through
202
- }
203
- }
204
- return {
205
- type
206
- };
207
- }
208
- function fireEvent(xhr, type) {
209
- xhr.dispatchEvent(makeEvent(type));
210
- }
211
-
212
- /** Move the shadowed `readyState` and announce it — the interceptor's own
213
- * listener stamps TTFB off the HEADERS_RECEIVED notification, same as a real
214
- * response. */
215
- function setStandardReadyState(xhr, state) {
216
- defineOwn(xhr, "readyState", state);
217
- fireEvent(xhr, "readystatechange");
218
- }
219
-
220
- /**
221
- * `xhr.response` in the caller's requested shape.
222
- *
223
- * A standards XHR types `response` off `responseType`; axios sets it when the
224
- * caller asked for one (default '' → text). JSON is parsed (spec: null on
225
- * parse failure), arraybuffer/blob are best-effort encodings of the rule's
226
- * text body, everything else falls back to the string.
227
- */
228
- function standardResponseFor(xhr, outcome) {
229
- let responseType = "";
230
- try {
231
- responseType = xhr.responseType;
232
- } catch {
233
- // Some shims throw on access before send — treat as default text.
234
- }
235
- switch (responseType) {
236
- case "":
237
- case "text":
238
- return outcome.body;
239
- case "json":
240
- try {
241
- return JSON.parse(outcome.body);
242
- } catch {
243
- return null;
244
- }
245
- case "arraybuffer":
246
- if (typeof TextEncoder === "function") {
247
- return new TextEncoder().encode(outcome.body).buffer;
248
- }
249
- return outcome.body;
250
- case "blob":
251
- if (typeof Blob === "function") {
252
- const contentType = Object.entries(outcome.headers).find(([name]) => name.toLowerCase() === "content-type")?.[1] ?? "";
253
- return new Blob([outcome.body], {
254
- type: contentType
255
- });
256
- }
257
- return outcome.body;
258
- default:
259
- return outcome.body;
260
- }
261
- }
262
-
263
- /** Synthesize a successful response on a standards XHR. */
264
- function respondStandard(xhr, url, outcome, isAborted) {
265
- const headers = outcome.headers;
266
- // Spec shape: lowercase names, `name: value\r\n` per pair — axios splits on
267
- // newlines and trims, raw XHR users get what a real response reads like.
268
- const allHeaders = Object.entries(headers).map(([name, value]) => `${name.toLowerCase()}: ${value}\r\n`).join("");
269
- defineOwn(xhr, "getAllResponseHeaders", () => allHeaders);
270
- defineOwn(xhr, "getResponseHeader", name => {
271
- const wanted = String(name).toLowerCase();
272
- for (const [key, value] of Object.entries(headers)) {
273
- if (key.toLowerCase() === wanted) return value;
274
- }
275
- return null;
276
- });
277
- defineOwn(xhr, "responseURL", url);
278
- defineOwn(xhr, "status", outcome.status);
279
- defineOwn(xhr, "statusText", outcome.statusText);
280
- defineOwn(xhr, "response", standardResponseFor(xhr, outcome));
281
- // Own property, so it answers with the body even under a non-text
282
- // `responseType` (where the real accessor would throw). axios reads it
283
- // whenever `responseType` is '' or 'text'.
284
- defineOwn(xhr, "responseText", outcome.body);
285
- setStandardReadyState(xhr, HEADERS_RECEIVED);
286
- if (isAborted()) return;
287
- setStandardReadyState(xhr, LOADING);
288
- if (isAborted()) return;
289
- setStandardReadyState(xhr, DONE);
290
- if (isAborted()) return;
291
- fireEvent(xhr, "load");
292
- fireEvent(xhr, "loadend");
293
- }
294
-
295
- /** Synthesize a transport failure on a standards XHR — offline or timeout. */
296
- function failStandard(xhr, outcome) {
297
- // `status` stays 0 (the prototype getter's answer for a request whose real
298
- // send never ran) — exactly what a genuine network error reports. The
299
- // 'error'/'timeout' event is the entire signal; axios turns them into
300
- // ERR_NETWORK / ECONNABORTED the same way whatwg-fetch turns RN's flags
301
- // into TypeErrors.
302
- setStandardReadyState(xhr, DONE);
303
- fireEvent(xhr, outcome.failKind === "timeout" ? "timeout" : "error");
304
- fireEvent(xhr, "loadend");
305
- }
306
-
307
- /**
308
- * Apply an outcome to a standards XMLHttpRequest that has NOT been sent.
309
- *
310
- * The real `send()` is never invoked for respond/fail — the request must not
311
- * touch the network. That leaves `abort()` with nothing to do natively (per
312
- * spec, abort on a request whose send flag is unset dispatches NOTHING), so
313
- * an instance shadow gives it the in-flight behaviour the app expects:
314
- * cancel the pending outcome and dispatch abort + loadend. The shadow deletes
315
- * itself the moment it can't matter anymore — after settling, and before a
316
- * `delay` pass-through hands the request to the real network, where the
317
- * prototype `abort()` must be reachable again.
318
- */
319
- const pendingStandardRequests = new WeakMap();
320
- function hasPendingStandardRequest(xhr) {
321
- return pendingStandardRequests.has(xhr);
322
- }
323
- function runStandardOverride(xhr, url, outcome, passThrough) {
324
- const started = Date.now();
325
- const generation = {};
326
- let timer;
327
- let deadline;
328
- let settled = false;
329
- let aborted = false;
330
- let dispatched = false;
331
- let timeout = xhr.timeout;
332
- const originalAbort = xhr.abort;
333
- const originalOpen = xhr.open;
334
- const names = ['abort', 'open', 'timeout', 'readyState', 'status', 'statusText', 'response', 'responseText', 'responseURL', 'getAllResponseHeaders', 'getResponseHeader'];
335
- const descriptors = new Map(names.map(name => [name, Object.getOwnPropertyDescriptor(xhr, name)]));
336
- let prototype = Object.getPrototypeOf(xhr);
337
- let nativeTimeout;
338
- while (prototype && !nativeTimeout) {
339
- nativeTimeout = Object.getOwnPropertyDescriptor(prototype, 'timeout');
340
- prototype = Object.getPrototypeOf(prototype);
341
- }
342
- const finish = () => {
343
- settled = true;
344
- if (pendingStandardRequests.get(xhr) === generation) pendingStandardRequests.delete(xhr);
345
- clearTimeout(timer);
346
- clearTimeout(deadline);
347
- xhr.removeEventListener('loadend', finish);
348
- };
349
- const restore = () => {
350
- finish();
351
- for (const [name, descriptor] of descriptors) {
352
- if (descriptor) Object.defineProperty(xhr, name, descriptor);else delete xhr[name];
353
- }
354
- xhr.timeout = timeout;
355
- };
356
- const scheduleDeadline = () => {
357
- clearTimeout(deadline);
358
- if (dispatched) {
359
- nativeTimeout?.set?.call(xhr, timeout > 0 ? Math.max(1, timeout - (Date.now() - started)) : 0);
360
- } else if (timeout > 0) {
361
- deadline = setTimeout(() => {
362
- if (settled) return;
363
- clearTimeout(timer);
364
- failStandard(xhr, {
365
- ...outcome,
366
- kind: 'fail',
367
- failKind: 'timeout'
368
- });
369
- finish();
370
- }, Math.max(0, timeout - (Date.now() - started)));
371
- }
372
- };
373
- Object.defineProperty(xhr, 'timeout', {
374
- configurable: true,
375
- get: () => timeout,
376
- set: value => {
377
- timeout = Math.max(0, Number(value) || 0);
378
- scheduleDeadline();
379
- }
380
- });
381
- Object.defineProperty(xhr, 'open', {
382
- configurable: true,
383
- value: (...args) => {
384
- restore();
385
- return Reflect.apply(originalOpen, xhr, args);
386
- }
387
- });
388
- Object.defineProperty(xhr, 'abort', {
389
- configurable: true,
390
- value: () => {
391
- if (dispatched || settled) {
392
- restore();
393
- originalAbort.call(xhr);
394
- return;
395
- }
396
- aborted = true;
397
- clearTimeout(timer);
398
- setStandardReadyState(xhr, DONE);
399
- fireEvent(xhr, 'abort');
400
- fireEvent(xhr, 'loadend');
401
- finish();
402
- if (!pendingStandardRequests.has(xhr)) defineOwn(xhr, 'readyState', 0);
403
- }
404
- });
405
- pendingStandardRequests.set(xhr, generation);
406
- xhr.addEventListener('loadend', finish);
407
- scheduleDeadline();
408
- timer = setTimeout(() => {
409
- if (settled || aborted) return;
410
- if (outcome.kind === 'delay') {
411
- dispatched = true;
412
- scheduleDeadline();
413
- try {
414
- passThrough();
415
- } catch {
416
- failStandard(xhr, {
417
- ...outcome,
418
- kind: 'fail',
419
- failKind: 'network'
420
- });
421
- finish();
422
- }
423
- return;
424
- }
425
- if (outcome.kind === 'fail') failStandard(xhr, outcome);else respondStandard(xhr, url, outcome, () => aborted || pendingStandardRequests.get(xhr) !== generation);
426
- finish();
427
- }, outcome.delayMs);
428
- return true;
429
- }
430
-
431
- // ============================================================================
432
- // Entry point
433
- // ============================================================================
434
-
435
- /**
436
- * Apply an outcome to a request that has NOT been sent yet.
437
- *
438
- * Returns `false` when this environment can't be driven by hand, in which case
439
- * the caller must send the request normally.
440
- *
441
- * @param passThrough Sends the real request. Only used by `kind: "delay"`.
442
- */
443
- function runOverride(xhr, url, outcome, passThrough) {
444
- if (!canSynthesize(xhr)) {
445
- // Not React Native's XMLHttpRequest — a standards one (webview port,
446
- // react-native-web) is driven through instance property shadowing
447
- // instead. Order matters: RN's XHR also extends an EventTarget shim, so
448
- // the RN check must win first.
449
- if (canSynthesizeStandard(xhr)) {
450
- return runStandardOverride(xhr, url, outcome, passThrough);
451
- }
452
- warnUnsupported();
453
- return false;
454
- }
455
- const internals = internalsOf(xhr);
456
-
457
- // Claim the request as sent, for all three kinds.
458
- //
459
- // We skip RN's own `send()`, which is what normally sets this — and `abort()`
460
- // branches on it: with `_sent` false it treats the request as never started,
461
- // silently `_reset()`s, and dispatches NOTHING. The app's fetch promise would
462
- // then never settle (a hang), and for a synthesized response our own timer
463
- // would afterwards fire 'load' on a reset object, resolving a fetch the app
464
- // had already aborted. Claiming it means abort() dispatches DONE + 'abort'
465
- // and whatwg-fetch rejects with AbortError, as it should.
466
- internals._sent = true;
467
-
468
- // There is no native request to cancel until a delayed send is dispatched.
469
- internals._requestId = null;
470
- let timer = null;
471
- const onAbort = () => {
472
- xhr.removeEventListener("abort", onAbort);
473
- if (timer !== null) {
474
- clearTimeout(timer);
475
- timer = null;
476
- }
477
- };
478
- xhr.addEventListener("abort", onAbort);
479
- const fire = () => {
480
- timer = null;
481
- xhr.removeEventListener("abort", onAbort);
482
- // The real guard. `_aborted` is set unconditionally by `abort()` and
483
- // survives its `_reset()`, so this is true whether or not the 'abort' event
484
- // was ever dispatched.
485
- if (internals._aborted) return;
486
- if (outcome.kind === "delay") {
487
- // Hand the state machine back before RN's `send()` sees it: it throws
488
- // 'Request has already been sent' on a truthy `_sent`.
489
- internals._sent = false;
490
- passThrough();
491
- return;
492
- }
493
- if (outcome.kind === "fail") {
494
- fail(xhr, outcome);
495
- return;
496
- }
497
- respond(xhr, url, outcome);
498
- };
499
-
500
- // ALWAYS asynchronous, even at 0ms. Callers legitimately attach handlers
501
- // after `send()` returns (axios does), and a synchronous response would fire
502
- // 'load' before they exist.
503
- timer = setTimeout(fire, outcome.delayMs);
504
- return true;
505
- }
506
-
507
- /** Complete an already scheduled native outcome without adding another timer. */
508
- function completeNativeOverride(xhr, url, outcome) {
509
- if (outcome.kind === "fail") fail(xhr, outcome);else if (outcome.kind === "respond") respond(xhr, url, outcome);
510
- }
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)}