@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,56 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.deleteNestedDataByPath = void 0;
7
- /**
8
- * Deletes nested data by path
9
- *
10
- * @param {unknown} oldData Data to be updated
11
- * @param {Array<string>} deletePath Path to the data to be deleted
12
- * @returns newData without the deleted items by path
13
- */
14
- const deleteNestedDataByPath = (oldData, deletePath) => {
15
- if (oldData instanceof Map) {
16
- const newData = new Map(oldData);
17
- if (deletePath.length === 1) {
18
- newData.delete(deletePath[0]);
19
- return newData;
20
- }
21
- const [head, ...tail] = deletePath;
22
- newData.set(head, deleteNestedDataByPath(newData.get(head), tail));
23
- return newData;
24
- }
25
- if (oldData instanceof Set) {
26
- const setAsArray = deleteNestedDataByPath(Array.from(oldData), deletePath);
27
- return new Set(setAsArray);
28
- }
29
- if (Array.isArray(oldData)) {
30
- const newData = [...oldData];
31
- if (deletePath.length === 1) {
32
- return newData.filter((_, idx) => idx.toString() !== deletePath[0]);
33
- }
34
- const [head, ...tail] = deletePath;
35
-
36
- // @ts-expect-error NAS
37
- newData[head] = deleteNestedDataByPath(newData[head], tail);
38
- return newData;
39
- }
40
- if (oldData instanceof Object) {
41
- const newData = {
42
- ...oldData
43
- };
44
- if (deletePath.length === 1) {
45
- // @ts-expect-error NAS
46
- delete newData[deletePath[0]];
47
- return newData;
48
- }
49
- const [head, ...tail] = deletePath;
50
- // @ts-expect-error NAS
51
- newData[head] = deleteNestedDataByPath(newData[head], tail);
52
- return newData;
53
- }
54
- return oldData;
55
- };
56
- exports.deleteNestedDataByPath = deleteNestedDataByPath;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.deleteNestedDataByPath=void 0;const deleteNestedDataByPath=(t,r)=>{if(t instanceof Map){const e=new Map(t);if(r.length===1){e.delete(r[0]);return e}const[n,...s]=r;e.set(n,deleteNestedDataByPath(e.get(n),s));return e}if(t instanceof Set){const e=deleteNestedDataByPath(Array.from(t),r);return new Set(e)}if(Array.isArray(t)){const e=[...t];if(r.length===1){return e.filter((c,i)=>i.toString()!==r[0])}const[n,...s]=r;e[n]=deleteNestedDataByPath(e[n],s);return e}if(t instanceof Object){const e={...t};if(r.length===1){delete e[r[0]];return e}const[n,...s]=r;e[n]=deleteNestedDataByPath(e[n],s);return e}return t};exports.deleteNestedDataByPath=deleteNestedDataByPath;
@@ -1,33 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ResponseEditorContext = void 0;
7
- exports.useResponseEditor = useResponseEditor;
8
- var _react = require("react");
9
- /**
10
- * What the ported Explorer needs in place of React Query's cache.
11
- *
12
- * In the original, every edit ends at
13
- * `queryClient.setQueryData(activeQuery.queryKey, newData)` and `activeQuery`
14
- * doubles as the "is this editable" gate — so the whole tree is wired to one
15
- * specific store. Here that becomes two values in context: the ROOT document
16
- * (every op rebuilds the whole thing from the root, so each row needs it) and a
17
- * single `onChange`.
18
- *
19
- * Context rather than props because Explorer recurses per node and already
20
- * threads `activeQuery` down every level; swapping one drilled prop for another
21
- * would have meant the same plumbing at every call site, and a row deep in a
22
- * response is exactly where you don't want a missed prop.
23
- */
24
-
25
- const ResponseEditorContext = exports.ResponseEditorContext = /*#__PURE__*/(0, _react.createContext)(null);
26
-
27
- /**
28
- * Null outside a provider, which is how the tree stays READ-ONLY by default —
29
- * the same role `activeQuery === undefined` played in the original.
30
- */
31
- function useResponseEditor() {
32
- return (0, _react.useContext)(ResponseEditorContext);
33
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ResponseEditorContext=void 0;exports.useResponseEditor=useResponseEditor;var _react=require("react");const ResponseEditorContext=exports.ResponseEditorContext=(0,_react.createContext)(null);function useResponseEditor(){return(0,_react.useContext)(ResponseEditorContext)}
@@ -1,61 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.updateNestedDataByPath = void 0;
7
- /**
8
- * updates nested data by path
9
- *
10
- * @param {JsonValue} oldData Data to be updated
11
- * @param {Array<string>} updatePath Path to the data to be updated
12
- * @param {JsonValue} value New value
13
- */
14
- const updateNestedDataByPath = (oldData, updatePath, value) => {
15
- if (updatePath.length === 0) {
16
- return value;
17
- }
18
- if (oldData instanceof Map) {
19
- const newData = new Map(oldData);
20
- if (updatePath.length === 1) {
21
- newData.set(updatePath[0], value);
22
- return newData;
23
- }
24
- const [head, ...tail] = updatePath;
25
- const currentValue = newData.get(head);
26
- newData.set(head, updateNestedDataByPath(currentValue ?? null, tail, value));
27
- return newData;
28
- }
29
- if (oldData instanceof Set) {
30
- const setAsArray = updateNestedDataByPath(Array.from(oldData), updatePath, value);
31
- return new Set(Array.isArray(setAsArray) ? setAsArray : []);
32
- }
33
- if (Array.isArray(oldData)) {
34
- const newData = [...oldData];
35
- if (updatePath.length === 1) {
36
- // @ts-expect-error NAS
37
- newData[updatePath[0]] = value;
38
- return newData;
39
- }
40
- const [head, ...tail] = updatePath;
41
- // @ts-expect-error NAS
42
- newData[head] = updateNestedDataByPath(newData[head], tail, value);
43
- return newData;
44
- }
45
- if (oldData instanceof Object) {
46
- const newData = {
47
- ...oldData
48
- };
49
- if (updatePath.length === 1) {
50
- // @ts-expect-error NAS
51
- newData[updatePath[0]] = value;
52
- return newData;
53
- }
54
- const [head, ...tail] = updatePath;
55
- // @ts-expect-error NAS
56
- newData[head] = updateNestedDataByPath(newData[head], tail, value);
57
- return newData;
58
- }
59
- return oldData;
60
- };
61
- exports.updateNestedDataByPath = updateNestedDataByPath;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.updateNestedDataByPath=void 0;const updateNestedDataByPath=(n,e,t)=>{if(e.length===0){return t}if(n instanceof Map){const r=new Map(n);if(e.length===1){r.set(e[0],t);return r}const[s,...i]=e;const c=r.get(s);r.set(s,updateNestedDataByPath(c??null,i,t));return r}if(n instanceof Set){const r=updateNestedDataByPath(Array.from(n),e,t);return new Set(Array.isArray(r)?r:[])}if(Array.isArray(n)){const r=[...n];if(e.length===1){r[e[0]]=t;return r}const[s,...i]=e;r[s]=updateNestedDataByPath(r[s],i,t);return r}if(n instanceof Object){const r={...n};if(e.length===1){r[e[0]]=t;return r}const[s,...i]=e;r[s]=updateNestedDataByPath(r[s],i,t);return r}return n};exports.updateNestedDataByPath=updateNestedDataByPath;
@@ -1,235 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.NetworkConditionsControl = NetworkConditionsControl;
7
- var _react = require("react");
8
- var _reactNative = require("react-native");
9
- var _sharedUi = require("@buoy-gg/shared-ui");
10
- var _store = require("./store");
11
- var _jsxRuntime = require("react/jsx-runtime");
12
- const options = [{
13
- profile: "normal",
14
- label: "No throttling"
15
- }, {
16
- profile: "slow",
17
- label: "Slow"
18
- }, {
19
- profile: "verySlow",
20
- label: "Very slow"
21
- }, {
22
- profile: "offline",
23
- label: "Offline"
24
- }];
25
- const summaries = {
26
- normal: "No added delay",
27
- slow: "+500 ms before each new request",
28
- verySlow: "+2 seconds before each new request",
29
- offline: "New requests fail before sending"
30
- };
31
- function NetworkConditionsControl({
32
- remote
33
- }) {
34
- const local = (0, _react.useSyncExternalStore)(_store.subscribeNetworkConditions, _store.getNetworkCondition, _store.getNetworkCondition);
35
- const localAvailable = (0, _react.useSyncExternalStore)(_store.subscribeNetworkConditions, _store.conditionsCanApply, _store.conditionsCanApply);
36
- const [expanded, setExpanded] = (0, _react.useState)(false);
37
- const [error, setError] = (0, _react.useState)();
38
- const [pending, setPending] = (0, _react.useState)(false);
39
- const busy = (0, _react.useRef)(false);
40
- const mounted = (0, _react.useRef)(true);
41
- (0, _react.useEffect)(() => {
42
- mounted.current = true;
43
- return () => {
44
- mounted.current = false;
45
- };
46
- }, []);
47
- const profile = remote ? remote.profile : local;
48
- const available = remote ? remote.available : localAvailable;
49
- const active = profile !== null && profile !== "normal";
50
- const tint = profile === "offline" ? _sharedUi.night.color.danger : active ? _sharedUi.night.color.warning : _sharedUi.night.color.accent;
51
- async function select(value) {
52
- if (!available || busy.current) return;
53
- if (value === profile) {
54
- setExpanded(false);
55
- return;
56
- }
57
- busy.current = true;
58
- setPending(true);
59
- setError(undefined);
60
- try {
61
- if (remote) await remote.onChange(value);else (0, _store.setNetworkCondition)(value);
62
- if (mounted.current) setExpanded(false);
63
- } catch (failure) {
64
- if (mounted.current) setError(failure instanceof Error ? failure.message : String(failure));
65
- } finally {
66
- busy.current = false;
67
- if (mounted.current) setPending(false);
68
- }
69
- }
70
- const label = options.find(option => option.profile === profile)?.label ?? "Unavailable";
71
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
72
- style: styles.container,
73
- testID: "buoy-network-throttling-screen",
74
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
75
- style: styles.heading,
76
- children: "Connection profile"
77
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
78
- testID: "buoy-network-conditions",
79
- accessibilityRole: "button",
80
- accessibilityLabel: `Network throttling: ${label}`,
81
- accessibilityState: {
82
- expanded,
83
- disabled: !available || pending
84
- },
85
- disabled: !available || pending,
86
- onPress: () => setExpanded(value => !value),
87
- style: [styles.dropdown, expanded && styles.dropdownOpen, !available && styles.disabled],
88
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
89
- style: [styles.value, active && {
90
- color: tint
91
- }],
92
- children: label
93
- }), pending ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
94
- size: "small",
95
- color: _sharedUi.night.color.textSecondary
96
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.ChevronDown, {
97
- size: 16,
98
- color: _sharedUi.night.color.textSecondary
99
- })]
100
- }), expanded && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
101
- accessibilityRole: "radiogroup",
102
- accessibilityLabel: "Connection profile",
103
- style: styles.options,
104
- children: options.map(option => {
105
- const selected = profile === option.profile;
106
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
107
- testID: `buoy-network-condition-${option.profile}`,
108
- accessibilityRole: "radio",
109
- accessibilityLabel: option.label,
110
- accessibilityState: {
111
- checked: selected,
112
- disabled: !available || pending
113
- },
114
- disabled: !available || pending,
115
- onPress: () => void select(option.profile),
116
- style: [styles.option, selected && styles.selected],
117
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
118
- style: styles.optionBody,
119
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
120
- style: [styles.optionTitle, selected && {
121
- color: tint
122
- }],
123
- children: option.label
124
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
125
- style: styles.caption,
126
- children: summaries[option.profile]
127
- })]
128
- }), selected && /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.Check, {
129
- size: 16,
130
- color: tint
131
- })]
132
- }, option.profile);
133
- })
134
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
135
- style: styles.caption,
136
- accessibilityLiveRegion: "polite",
137
- children: pending ? "Applying to device…" : !available ? remote ? "Conditions unavailable on this device" : "Requires a signed-in account and a development build" : profile ? summaries[profile] : "Waiting for device status"
138
- }), !!error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
139
- accessibilityRole: "alert",
140
- style: styles.error,
141
- children: error
142
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
143
- style: styles.help,
144
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
145
- style: styles.heading,
146
- children: "How it works"
147
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
148
- style: styles.caption,
149
- children: "Affects new HTTP requests through global fetch and XHR. Slow adds a wait before sending; download speed stays unchanged."
150
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
151
- style: styles.caption,
152
- children: "Stays active when you close this tool or pause capture. Choose No throttling to stop. Reloading the app resets it."
153
- })]
154
- })]
155
- });
156
- }
157
- const styles = _reactNative.StyleSheet.create({
158
- container: {
159
- padding: _sharedUi.night.gutter,
160
- gap: 10
161
- },
162
- heading: {
163
- fontSize: _sharedUi.night.font.caption,
164
- fontWeight: "600",
165
- color: _sharedUi.night.color.textSecondary
166
- },
167
- dropdown: {
168
- flexDirection: "row",
169
- alignItems: "center",
170
- justifyContent: "space-between",
171
- gap: 12,
172
- minHeight: 44,
173
- paddingHorizontal: 12,
174
- paddingVertical: 10,
175
- borderRadius: _sharedUi.night.radius.segment,
176
- borderWidth: 1,
177
- borderColor: _sharedUi.night.color.separator,
178
- backgroundColor: _sharedUi.night.color.surfaceElevated
179
- },
180
- dropdownOpen: {
181
- borderColor: _sharedUi.night.color.accentBorderStrong
182
- },
183
- value: {
184
- flex: 1,
185
- fontSize: _sharedUi.night.font.body,
186
- color: _sharedUi.night.color.text
187
- },
188
- options: {
189
- padding: 4,
190
- borderRadius: _sharedUi.night.radius.row,
191
- borderWidth: 1,
192
- borderColor: _sharedUi.night.color.border,
193
- backgroundColor: _sharedUi.night.color.surface
194
- },
195
- option: {
196
- flexDirection: "row",
197
- alignItems: "center",
198
- gap: 12,
199
- minHeight: 54,
200
- padding: 10,
201
- borderRadius: _sharedUi.night.radius.segment
202
- },
203
- optionBody: {
204
- flex: 1,
205
- gap: 4
206
- },
207
- optionTitle: {
208
- fontSize: _sharedUi.night.font.caption,
209
- fontWeight: "600",
210
- color: _sharedUi.night.color.text
211
- },
212
- selected: {
213
- backgroundColor: _sharedUi.night.color.surfaceElevated
214
- },
215
- disabled: {
216
- opacity: 0.45
217
- },
218
- caption: {
219
- fontSize: _sharedUi.night.font.caption,
220
- lineHeight: 19,
221
- color: _sharedUi.night.color.textSecondary
222
- },
223
- help: {
224
- marginTop: 14,
225
- paddingTop: 16,
226
- gap: 10,
227
- borderTopWidth: 1,
228
- borderTopColor: _sharedUi.night.color.separator
229
- },
230
- error: {
231
- fontSize: _sharedUi.night.font.caption,
232
- lineHeight: 18,
233
- color: _sharedUi.night.color.danger
234
- }
235
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.NetworkConditionsControl=NetworkConditionsControl;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _store=require("./store");var _jsxRuntime=require("react/jsx-runtime");const options=[{profile:"normal",label:"No throttling"},{profile:"slow",label:"Slow"},{profile:"verySlow",label:"Very slow"},{profile:"offline",label:"Offline"}];const summaries={normal:"No added delay",slow:"+500 ms before each new request",verySlow:"+2 seconds before each new request",offline:"New requests fail before sending"};function NetworkConditionsControl({remote:i}){const b=(0,_react.useSyncExternalStore)(_store.subscribeNetworkConditions,_store.getNetworkCondition,_store.getNetworkCondition);const y=(0,_react.useSyncExternalStore)(_store.subscribeNetworkConditions,_store.conditionsCanApply,_store.conditionsCanApply);const[s,a]=(0,_react.useState)(false);const[g,u]=(0,_react.useState)();const[r,h]=(0,_react.useState)(false);const c=(0,_react.useRef)(false);const l=(0,_react.useRef)(true);(0,_react.useEffect)(()=>{l.current=true;return()=>{l.current=false}},[]);const t=i?i.profile:b;const n=i?i.available:y;const f=t!==null&&t!=="normal";const d=t==="offline"?_sharedUi.night.color.danger:f?_sharedUi.night.color.warning:_sharedUi.night.color.accent;async function x(e){if(!n||c.current)return;if(e===t){a(false);return}c.current=true;h(true);u(void 0);try{if(i)await i.onChange(e);else(0,_store.setNetworkCondition)(e);if(l.current)a(false)}catch(o){if(l.current)u(o instanceof Error?o.message:String(o))}finally{c.current=false;if(l.current)h(false)}}const p=options.find(e=>e.profile===t)?.label??"Unavailable";return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,testID:"buoy-network-throttling-screen",children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.heading,children:"Connection profile"}),(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:"buoy-network-conditions",accessibilityRole:"button",accessibilityLabel:`Network throttling: ${p}`,accessibilityState:{expanded:s,disabled:!n||r},disabled:!n||r,onPress:()=>a(e=>!e),style:[styles.dropdown,s&&styles.dropdownOpen,!n&&styles.disabled],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.value,f&&{color:d}],children:p}),r?(0,_jsxRuntime.jsx)(_reactNative.ActivityIndicator,{size:"small",color:_sharedUi.night.color.textSecondary}):(0,_jsxRuntime.jsx)(_sharedUi.ChevronDown,{size:16,color:_sharedUi.night.color.textSecondary})]}),s&&(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"radiogroup",accessibilityLabel:"Connection profile",style:styles.options,children:options.map(e=>{const o=t===e.profile;return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:`buoy-network-condition-${e.profile}`,accessibilityRole:"radio",accessibilityLabel:e.label,accessibilityState:{checked:o,disabled:!n||r},disabled:!n||r,onPress:()=>void x(e.profile),style:[styles.option,o&&styles.selected],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.optionBody,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.optionTitle,o&&{color:d}],children:e.label}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.caption,children:summaries[e.profile]})]}),o&&(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:16,color:d})]},e.profile)})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.caption,accessibilityLiveRegion:"polite",children:r?"Applying to device\u2026":!n?i?"Conditions unavailable on this device":"Requires a signed-in account and a development build":t?summaries[t]:"Waiting for device status"}),!!g&&(0,_jsxRuntime.jsx)(_reactNative.Text,{accessibilityRole:"alert",style:styles.error,children:g}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.help,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.heading,children:"How it works"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.caption,children:"Affects new HTTP requests through global fetch and XHR. Slow adds a wait before sending; download speed stays unchanged."}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.caption,children:"Stays active when you close this tool or pause capture. Choose No throttling to stop. Reloading the app resets it."})]})]})}const styles=_reactNative.StyleSheet.create({container:{padding:_sharedUi.night.gutter,gap:10},heading:{fontSize:_sharedUi.night.font.caption,fontWeight:"600",color:_sharedUi.night.color.textSecondary},dropdown:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:44,paddingHorizontal:12,paddingVertical:10,borderRadius:_sharedUi.night.radius.segment,borderWidth:1,borderColor:_sharedUi.night.color.separator,backgroundColor:_sharedUi.night.color.surfaceElevated},dropdownOpen:{borderColor:_sharedUi.night.color.accentBorderStrong},value:{flex:1,fontSize:_sharedUi.night.font.body,color:_sharedUi.night.color.text},options:{padding:4,borderRadius:_sharedUi.night.radius.row,borderWidth:1,borderColor:_sharedUi.night.color.border,backgroundColor:_sharedUi.night.color.surface},option:{flexDirection:"row",alignItems:"center",gap:12,minHeight:54,padding:10,borderRadius:_sharedUi.night.radius.segment},optionBody:{flex:1,gap:4},optionTitle:{fontSize:_sharedUi.night.font.caption,fontWeight:"600",color:_sharedUi.night.color.text},selected:{backgroundColor:_sharedUi.night.color.surfaceElevated},disabled:{opacity:.45},caption:{fontSize:_sharedUi.night.font.caption,lineHeight:19,color:_sharedUi.night.color.textSecondary},help:{marginTop:14,paddingTop:16,gap:10,borderTopWidth:1,borderTopColor:_sharedUi.night.color.separator},error:{fontSize:_sharedUi.night.font.caption,lineHeight:18,color:_sharedUi.night.color.danger}});
@@ -1,136 +1 @@
1
- "use strict";
2
-
3
- var _react = require("react");
4
- var _client = require("react-dom/client");
5
- var _vitest = require("vitest");
6
- var _NetworkConditionsControl = require("./NetworkConditionsControl");
7
- // @vitest-environment jsdom
8
-
9
- _vitest.vi.mock("@buoy-gg/shared-ui", async () => ({
10
- ChevronDown: () => null,
11
- Check: () => null,
12
- night: (await _vitest.vi.importActual("../../../../shared/src/ui/night/nightTheme")).night
13
- }));
14
- _vitest.vi.mock("react-native", () => ({
15
- StyleSheet: {
16
- create: value => value
17
- },
18
- View: ({
19
- children
20
- }) => /*#__PURE__*/(0, _react.createElement)("div", null, children),
21
- Text: ({
22
- children
23
- }) => /*#__PURE__*/(0, _react.createElement)("span", null, children),
24
- ActivityIndicator: () => /*#__PURE__*/(0, _react.createElement)("span", null, "pending"),
25
- TouchableOpacity: ({
26
- children,
27
- onPress,
28
- disabled,
29
- accessibilityLabel,
30
- accessibilityState,
31
- testID
32
- }) => /*#__PURE__*/(0, _react.createElement)("button", {
33
- onClick: onPress,
34
- disabled,
35
- "aria-label": accessibilityLabel,
36
- "aria-checked": accessibilityState?.checked,
37
- "data-testid": testID
38
- }, children)
39
- }));
40
- _vitest.vi.mock("./store", () => ({
41
- NETWORK_CONDITIONS: {
42
- normal: {
43
- label: "Normal"
44
- },
45
- slow: {
46
- label: "Slow"
47
- },
48
- verySlow: {
49
- label: "Very slow"
50
- },
51
- offline: {
52
- label: "Offline"
53
- }
54
- },
55
- getNetworkCondition: () => "normal",
56
- conditionsCanApply: () => true,
57
- subscribeNetworkConditions: () => () => {},
58
- setNetworkCondition: _vitest.vi.fn()
59
- }));
60
- let root;
61
- let container;
62
- (0, _vitest.beforeEach)(() => {
63
- globalThis.IS_REACT_ACT_ENVIRONMENT = true;
64
- container = document.createElement("div");
65
- root = (0, _client.createRoot)(container);
66
- });
67
- (0, _vitest.afterEach)(() => (0, _react.act)(() => root.unmount()));
68
- const button = profile => container.querySelector(`[data-testid="buoy-network-condition-${profile}"]`);
69
- function render(remote) {
70
- (0, _react.act)(() => root.render(/*#__PURE__*/(0, _react.createElement)(_NetworkConditionsControl.NetworkConditionsControl, {
71
- remote
72
- })));
73
- }
74
- const dropdown = () => container.querySelector('[data-testid="buoy-network-conditions"]');
75
- const open = () => (0, _react.act)(() => dropdown().click());
76
- (0, _vitest.it)("defaults to a closed No throttling dropdown and closes when the current option is chosen", () => {
77
- const onChange = _vitest.vi.fn();
78
- render({
79
- profile: "normal",
80
- available: true,
81
- onChange
82
- });
83
- (0, _vitest.expect)(dropdown().textContent).toBe("No throttling");
84
- (0, _vitest.expect)(button("normal")).toBeNull();
85
- open();
86
- (0, _vitest.expect)(["normal", "slow", "verySlow", "offline"].every(value => !!button(value))).toBe(true);
87
- (0, _react.act)(() => button("normal").click());
88
- (0, _vitest.expect)(button("normal")).toBeNull();
89
- (0, _vitest.expect)(onChange).not.toHaveBeenCalled();
90
- });
91
- (0, _vitest.it)("blocks duplicate remote changes and waits for the device profile before selecting it", async () => {
92
- let finish;
93
- const onChange = _vitest.vi.fn(() => new Promise(resolve => {
94
- finish = resolve;
95
- }));
96
- render({
97
- profile: "normal",
98
- available: true,
99
- onChange
100
- });
101
- open();
102
- (0, _react.act)(() => button("slow").click());
103
- (0, _vitest.expect)(button("offline").disabled).toBe(true);
104
- (0, _vitest.expect)(button("normal").getAttribute("aria-checked")).toBe("true");
105
- (0, _react.act)(() => button("offline").click());
106
- (0, _vitest.expect)(onChange).toHaveBeenCalledExactlyOnceWith("slow");
107
- await (0, _react.act)(async () => finish());
108
- render({
109
- profile: "slow",
110
- available: true,
111
- onChange
112
- });
113
- (0, _vitest.expect)(dropdown().textContent).toBe("Slow");
114
- (0, _vitest.expect)(button("slow")).toBeNull();
115
- open();
116
- (0, _vitest.expect)(button("slow").getAttribute("aria-checked")).toBe("true");
117
- });
118
- (0, _vitest.it)("reports a remote error, permits retry, and disables unavailable devices", async () => {
119
- const onChange = _vitest.vi.fn().mockRejectedValue(new Error("Device disconnected"));
120
- render({
121
- profile: "normal",
122
- available: true,
123
- onChange
124
- });
125
- open();
126
- await (0, _react.act)(async () => button("offline").click());
127
- (0, _vitest.expect)(container.textContent).toContain("Device disconnected");
128
- (0, _vitest.expect)(button("offline").disabled).toBe(false);
129
- render({
130
- profile: null,
131
- available: false,
132
- onChange
133
- });
134
- (0, _vitest.expect)(button("normal").disabled).toBe(true);
135
- (0, _vitest.expect)(container.textContent).toContain("Conditions unavailable on this device");
136
- });
1
+ "use strict";var _react=require("react");var _client=require("react-dom/client");var _vitest=require("vitest");var _NetworkConditionsControl=require("./NetworkConditionsControl");_vitest.vi.mock("@buoy-gg/shared-ui",async()=>({ChevronDown:()=>null,Check:()=>null,night:(await _vitest.vi.importActual("../../../../shared/src/ui/night/nightTheme")).night}));_vitest.vi.mock("react-native",()=>({StyleSheet:{create:e=>e},View:({children:e})=>(0,_react.createElement)("div",null,e),Text:({children:e})=>(0,_react.createElement)("span",null,e),ActivityIndicator:()=>(0,_react.createElement)("span",null,"pending"),TouchableOpacity:({children:e,onPress:t,disabled:o,accessibilityLabel:n,accessibilityState:a,testID:l})=>(0,_react.createElement)("button",{onClick:t,disabled:o,"aria-label":n,"aria-checked":a?.checked,"data-testid":l},e)}));_vitest.vi.mock("./store",()=>({NETWORK_CONDITIONS:{normal:{label:"Normal"},slow:{label:"Slow"},verySlow:{label:"Very slow"},offline:{label:"Offline"}},getNetworkCondition:()=>"normal",conditionsCanApply:()=>true,subscribeNetworkConditions:()=>()=>{},setNetworkCondition:_vitest.vi.fn()}));let root;let container;(0,_vitest.beforeEach)(()=>{globalThis.IS_REACT_ACT_ENVIRONMENT=true;container=document.createElement("div");root=(0,_client.createRoot)(container)});(0,_vitest.afterEach)(()=>(0,_react.act)(()=>root.unmount()));const button=e=>container.querySelector(`[data-testid="buoy-network-condition-${e}"]`);function render(e){(0,_react.act)(()=>root.render((0,_react.createElement)(_NetworkConditionsControl.NetworkConditionsControl,{remote:e})))}const dropdown=()=>container.querySelector('[data-testid="buoy-network-conditions"]');const open=()=>(0,_react.act)(()=>dropdown().click());(0,_vitest.it)("defaults to a closed No throttling dropdown and closes when the current option is chosen",()=>{const e=_vitest.vi.fn();render({profile:"normal",available:true,onChange:e});(0,_vitest.expect)(dropdown().textContent).toBe("No throttling");(0,_vitest.expect)(button("normal")).toBeNull();open();(0,_vitest.expect)(["normal","slow","verySlow","offline"].every(t=>!!button(t))).toBe(true);(0,_react.act)(()=>button("normal").click());(0,_vitest.expect)(button("normal")).toBeNull();(0,_vitest.expect)(e).not.toHaveBeenCalled()});(0,_vitest.it)("blocks duplicate remote changes and waits for the device profile before selecting it",async()=>{let e;const t=_vitest.vi.fn(()=>new Promise(o=>{e=o}));render({profile:"normal",available:true,onChange:t});open();(0,_react.act)(()=>button("slow").click());(0,_vitest.expect)(button("offline").disabled).toBe(true);(0,_vitest.expect)(button("normal").getAttribute("aria-checked")).toBe("true");(0,_react.act)(()=>button("offline").click());(0,_vitest.expect)(t).toHaveBeenCalledExactlyOnceWith("slow");await(0,_react.act)(async()=>e());render({profile:"slow",available:true,onChange:t});(0,_vitest.expect)(dropdown().textContent).toBe("Slow");(0,_vitest.expect)(button("slow")).toBeNull();open();(0,_vitest.expect)(button("slow").getAttribute("aria-checked")).toBe("true")});(0,_vitest.it)("reports a remote error, permits retry, and disables unavailable devices",async()=>{const e=_vitest.vi.fn().mockRejectedValue(new Error("Device disconnected"));render({profile:"normal",available:true,onChange:e});open();await(0,_react.act)(async()=>button("offline").click());(0,_vitest.expect)(container.textContent).toContain("Device disconnected");(0,_vitest.expect)(button("offline").disabled).toBe(false);render({profile:null,available:false,onChange:e});(0,_vitest.expect)(button("normal").disabled).toBe(true);(0,_vitest.expect)(container.textContent).toContain("Conditions unavailable on this device")});
@@ -1,33 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.NetworkConditionsIcon = NetworkConditionsIcon;
7
- var _react = require("react");
8
- var _reactNative = require("react-native");
9
- var _sharedUi = require("@buoy-gg/shared-ui");
10
- var _store = require("./store");
11
- var _jsxRuntime = require("react/jsx-runtime");
12
- function NetworkConditionsIcon({
13
- size
14
- }) {
15
- const profile = (0, _react.useSyncExternalStore)(_store.subscribeNetworkConditions, _store.getNetworkCondition, _store.getNetworkCondition);
16
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
17
- accessibilityLabel: profile === "normal" ? "Network" : `Network: ${_store.NETWORK_CONDITIONS[profile].label}`,
18
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.NetworkIcon, {
19
- size: size
20
- }), profile !== "normal" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
21
- testID: "buoy-network-condition-indicator",
22
- style: {
23
- position: "absolute",
24
- top: -6,
25
- right: -8,
26
- color: "#FFCC66",
27
- fontSize: 10,
28
- fontWeight: "700"
29
- },
30
- children: profile === "offline" ? "OFF" : `+${_store.NETWORK_CONDITIONS[profile].delayMs}`
31
- })]
32
- });
33
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.NetworkConditionsIcon=NetworkConditionsIcon;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _store=require("./store");var _jsxRuntime=require("react/jsx-runtime");function NetworkConditionsIcon({size:r}){const e=(0,_react.useSyncExternalStore)(_store.subscribeNetworkConditions,_store.getNetworkCondition,_store.getNetworkCondition);return(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityLabel:e==="normal"?"Network":`Network: ${_store.NETWORK_CONDITIONS[e].label}`,children:[(0,_jsxRuntime.jsx)(_sharedUi.NetworkIcon,{size:r}),e!=="normal"&&(0,_jsxRuntime.jsx)(_reactNative.Text,{testID:"buoy-network-condition-indicator",style:{position:"absolute",top:-6,right:-8,color:"#FFCC66",fontSize:10,fontWeight:"700"},children:e==="offline"?"OFF":`+${_store.NETWORK_CONDITIONS[e].delayMs}`})]})}