@buoy-gg/react-query 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 (244) hide show
  1. package/README.md +11 -69
  2. package/lib/commonjs/checkPeer.js +1 -0
  3. package/lib/commonjs/checkPeer.web.js +1 -0
  4. package/lib/commonjs/index.js +1 -736
  5. package/lib/commonjs/preset.js +1 -243
  6. package/lib/commonjs/react-query/components/DataEditorMode.js +1 -317
  7. package/lib/commonjs/react-query/components/FilterStatusBadge.js +1 -55
  8. package/lib/commonjs/react-query/components/MutationBrowserMode.js +1 -52
  9. package/lib/commonjs/react-query/components/MutationEditorMode.js +1 -276
  10. package/lib/commonjs/react-query/components/QueryBrowserMode.js +1 -99
  11. package/lib/commonjs/react-query/components/QueryDebugInfo.js +1 -107
  12. package/lib/commonjs/react-query/components/QueryFilterViewV3.js +1 -224
  13. package/lib/commonjs/react-query/components/QuerySelector.js +1 -209
  14. package/lib/commonjs/react-query/components/ReactQueryDevToolsModal.js +1 -91
  15. package/lib/commonjs/react-query/components/ReactQuerySection.js +1 -47
  16. package/lib/commonjs/react-query/components/ReactQueryTracker.js +1 -38
  17. package/lib/commonjs/react-query/components/WifiToggle.js +1 -51
  18. package/lib/commonjs/react-query/components/modals/DataEditorModal.js +1 -103
  19. package/lib/commonjs/react-query/components/modals/MutationBrowserFooter.js +1 -61
  20. package/lib/commonjs/react-query/components/modals/MutationBrowserModal.js +1 -164
  21. package/lib/commonjs/react-query/components/modals/MutationEditorModal.js +1 -106
  22. package/lib/commonjs/react-query/components/modals/QueryBrowserFooter.js +1 -56
  23. package/lib/commonjs/react-query/components/modals/QueryBrowserModal.js +1 -254
  24. package/lib/commonjs/react-query/components/modals/ReactQueryModal.js +1 -83
  25. package/lib/commonjs/react-query/components/modals/ReactQueryModalHeader.js +1 -194
  26. package/lib/commonjs/react-query/components/modals/SwipeIndicator.js +1 -204
  27. package/lib/commonjs/react-query/components/query-browser/ActionButton.js +1 -100
  28. package/lib/commonjs/react-query/components/query-browser/ClearCacheButton.js +1 -53
  29. package/lib/commonjs/react-query/components/query-browser/Explorer.js +1 -75
  30. package/lib/commonjs/react-query/components/query-browser/MutationButton.js +1 -190
  31. package/lib/commonjs/react-query/components/query-browser/MutationDetails.js +1 -124
  32. package/lib/commonjs/react-query/components/query-browser/MutationDetailsChips.js +1 -68
  33. package/lib/commonjs/react-query/components/query-browser/MutationInformation.js +1 -118
  34. package/lib/commonjs/react-query/components/query-browser/MutationStatusCount.js +1 -84
  35. package/lib/commonjs/react-query/components/query-browser/MutationsList.js +1 -220
  36. package/lib/commonjs/react-query/components/query-browser/NetworkToggleButton.js +1 -54
  37. package/lib/commonjs/react-query/components/query-browser/QueryActions.js +1 -124
  38. package/lib/commonjs/react-query/components/query-browser/QueryBrowser.js +1 -181
  39. package/lib/commonjs/react-query/components/query-browser/QueryDetails.js +1 -141
  40. package/lib/commonjs/react-query/components/query-browser/QueryDetailsChip.js +1 -78
  41. package/lib/commonjs/react-query/components/query-browser/QueryInformation.js +1 -95
  42. package/lib/commonjs/react-query/components/query-browser/QueryRow.js +1 -96
  43. package/lib/commonjs/react-query/components/query-browser/QueryStatus.js +1 -167
  44. package/lib/commonjs/react-query/components/query-browser/QueryStatusCount.js +1 -100
  45. package/lib/commonjs/react-query/components/query-browser/StorageStatusCount.js +1 -61
  46. package/lib/commonjs/react-query/components/query-browser/index.js +1 -170
  47. package/lib/commonjs/react-query/components/query-browser/svgs.js +1 -72
  48. package/lib/commonjs/react-query/hooks/useActionButtons.js +1 -51
  49. package/lib/commonjs/react-query/hooks/useAllMutations.js +1 -85
  50. package/lib/commonjs/react-query/hooks/useAllQueries.js +1 -117
  51. package/lib/commonjs/react-query/hooks/useModalManager.js +1 -178
  52. package/lib/commonjs/react-query/hooks/useModalPersistence.js +1 -71
  53. package/lib/commonjs/react-query/hooks/useMutationActionButtons.js +1 -21
  54. package/lib/commonjs/react-query/hooks/useQueryStatusCounts.js +1 -114
  55. package/lib/commonjs/react-query/hooks/useReactQueryState.js +1 -24
  56. package/lib/commonjs/react-query/hooks/useSelectedMutation.js +1 -30
  57. package/lib/commonjs/react-query/hooks/useSelectedQuery.js +1 -96
  58. package/lib/commonjs/react-query/hooks/useStorageQueryCounts.js +1 -28
  59. package/lib/commonjs/react-query/hooks/useWifiState.js +1 -67
  60. package/lib/commonjs/react-query/stores/reactQueryEventStore.js +1 -302
  61. package/lib/commonjs/react-query/sync/dehydrate.js +1 -166
  62. package/lib/commonjs/react-query/sync/reactQuerySyncAdapter.js +1 -593
  63. package/lib/commonjs/react-query/sync/snapshotProvider.js +1 -289
  64. package/lib/commonjs/react-query/sync/useReactQuerySyncAdapter.js +1 -34
  65. package/lib/commonjs/react-query/types/types.js +1 -14
  66. package/lib/commonjs/react-query/utils/actions/deleteItem.js +1 -23
  67. package/lib/commonjs/react-query/utils/actions/emitDevToolsEvent.js +1 -40
  68. package/lib/commonjs/react-query/utils/actions/invalidate.js +1 -15
  69. package/lib/commonjs/react-query/utils/actions/refetch.js +1 -17
  70. package/lib/commonjs/react-query/utils/actions/remove.js +1 -15
  71. package/lib/commonjs/react-query/utils/actions/reset.js +1 -17
  72. package/lib/commonjs/react-query/utils/actions/triggerError.js +1 -33
  73. package/lib/commonjs/react-query/utils/actions/triggerLoading.js +1 -54
  74. package/lib/commonjs/react-query/utils/deleteNestedDataByPath.js +1 -56
  75. package/lib/commonjs/react-query/utils/getQueryStatusColor.js +1 -16
  76. package/lib/commonjs/react-query/utils/getQueryStatusLabel.js +1 -23
  77. package/lib/commonjs/react-query/utils/getStorageQueryCounts.js +1 -35
  78. package/lib/commonjs/react-query/utils/modalStorageOperations.js +1 -127
  79. package/lib/commonjs/react-query/utils/storageQueryUtils.js +1 -149
  80. package/lib/commonjs/react-query/utils/testIDs.js +1 -61
  81. package/lib/commonjs/react-query/utils/updateNestedDataByPath.js +1 -61
  82. package/lib/module/checkPeer.js +1 -0
  83. package/lib/module/checkPeer.web.js +1 -0
  84. package/lib/module/index.js +1 -135
  85. package/lib/module/preset.js +1 -239
  86. package/lib/module/react-query/components/DataEditorMode.js +1 -311
  87. package/lib/module/react-query/components/FilterStatusBadge.js +1 -51
  88. package/lib/module/react-query/components/MutationBrowserMode.js +1 -47
  89. package/lib/module/react-query/components/MutationEditorMode.js +1 -270
  90. package/lib/module/react-query/components/QueryBrowserMode.js +1 -94
  91. package/lib/module/react-query/components/QueryDebugInfo.js +1 -104
  92. package/lib/module/react-query/components/QueryFilterViewV3.js +1 -221
  93. package/lib/module/react-query/components/QuerySelector.js +1 -205
  94. package/lib/module/react-query/components/ReactQueryDevToolsModal.js +1 -87
  95. package/lib/module/react-query/components/ReactQuerySection.js +1 -43
  96. package/lib/module/react-query/components/ReactQueryTracker.js +1 -35
  97. package/lib/module/react-query/components/WifiToggle.js +1 -48
  98. package/lib/module/react-query/components/modals/DataEditorModal.js +1 -99
  99. package/lib/module/react-query/components/modals/MutationBrowserFooter.js +1 -56
  100. package/lib/module/react-query/components/modals/MutationBrowserModal.js +1 -161
  101. package/lib/module/react-query/components/modals/MutationEditorModal.js +1 -102
  102. package/lib/module/react-query/components/modals/QueryBrowserFooter.js +1 -51
  103. package/lib/module/react-query/components/modals/QueryBrowserModal.js +1 -250
  104. package/lib/module/react-query/components/modals/ReactQueryModal.js +1 -79
  105. package/lib/module/react-query/components/modals/ReactQueryModalHeader.js +1 -190
  106. package/lib/module/react-query/components/modals/SwipeIndicator.js +1 -201
  107. package/lib/module/react-query/components/query-browser/ActionButton.js +1 -96
  108. package/lib/module/react-query/components/query-browser/ClearCacheButton.js +1 -49
  109. package/lib/module/react-query/components/query-browser/Explorer.js +1 -70
  110. package/lib/module/react-query/components/query-browser/MutationButton.js +1 -186
  111. package/lib/module/react-query/components/query-browser/MutationDetails.js +1 -119
  112. package/lib/module/react-query/components/query-browser/MutationDetailsChips.js +1 -64
  113. package/lib/module/react-query/components/query-browser/MutationInformation.js +1 -113
  114. package/lib/module/react-query/components/query-browser/MutationStatusCount.js +1 -79
  115. package/lib/module/react-query/components/query-browser/MutationsList.js +1 -215
  116. package/lib/module/react-query/components/query-browser/NetworkToggleButton.js +1 -50
  117. package/lib/module/react-query/components/query-browser/QueryActions.js +1 -119
  118. package/lib/module/react-query/components/query-browser/QueryBrowser.js +1 -176
  119. package/lib/module/react-query/components/query-browser/QueryDetails.js +1 -136
  120. package/lib/module/react-query/components/query-browser/QueryDetailsChip.js +1 -74
  121. package/lib/module/react-query/components/query-browser/QueryInformation.js +1 -90
  122. package/lib/module/react-query/components/query-browser/QueryRow.js +1 -92
  123. package/lib/module/react-query/components/query-browser/QueryStatus.js +1 -163
  124. package/lib/module/react-query/components/query-browser/QueryStatusCount.js +1 -95
  125. package/lib/module/react-query/components/query-browser/StorageStatusCount.js +1 -56
  126. package/lib/module/react-query/components/query-browser/index.js +1 -22
  127. package/lib/module/react-query/components/query-browser/svgs.js +1 -64
  128. package/lib/module/react-query/hooks/useActionButtons.js +1 -46
  129. package/lib/module/react-query/hooks/useAllMutations.js +1 -82
  130. package/lib/module/react-query/hooks/useAllQueries.js +1 -114
  131. package/lib/module/react-query/hooks/useModalManager.js +1 -175
  132. package/lib/module/react-query/hooks/useModalPersistence.js +1 -67
  133. package/lib/module/react-query/hooks/useMutationActionButtons.js +1 -17
  134. package/lib/module/react-query/hooks/useQueryStatusCounts.js +1 -112
  135. package/lib/module/react-query/hooks/useReactQueryState.js +1 -20
  136. package/lib/module/react-query/hooks/useSelectedMutation.js +1 -27
  137. package/lib/module/react-query/hooks/useSelectedQuery.js +1 -92
  138. package/lib/module/react-query/hooks/useStorageQueryCounts.js +1 -25
  139. package/lib/module/react-query/hooks/useWifiState.js +1 -64
  140. package/lib/module/react-query/stores/reactQueryEventStore.js +1 -293
  141. package/lib/module/react-query/sync/dehydrate.js +1 -156
  142. package/lib/module/react-query/sync/reactQuerySyncAdapter.js +1 -589
  143. package/lib/module/react-query/sync/snapshotProvider.js +1 -284
  144. package/lib/module/react-query/sync/useReactQuerySyncAdapter.js +1 -31
  145. package/lib/module/react-query/types/types.js +1 -10
  146. package/lib/module/react-query/utils/actions/deleteItem.js +1 -19
  147. package/lib/module/react-query/utils/actions/emitDevToolsEvent.js +1 -36
  148. package/lib/module/react-query/utils/actions/invalidate.js +1 -11
  149. package/lib/module/react-query/utils/actions/refetch.js +1 -13
  150. package/lib/module/react-query/utils/actions/remove.js +1 -11
  151. package/lib/module/react-query/utils/actions/reset.js +1 -13
  152. package/lib/module/react-query/utils/actions/triggerError.js +1 -29
  153. package/lib/module/react-query/utils/actions/triggerLoading.js +1 -50
  154. package/lib/module/react-query/utils/deleteNestedDataByPath.js +1 -51
  155. package/lib/module/react-query/utils/getQueryStatusColor.js +1 -12
  156. package/lib/module/react-query/utils/getQueryStatusLabel.js +1 -19
  157. package/lib/module/react-query/utils/getStorageQueryCounts.js +1 -31
  158. package/lib/module/react-query/utils/modalStorageOperations.js +1 -117
  159. package/lib/module/react-query/utils/storageQueryUtils.js +1 -140
  160. package/lib/module/react-query/utils/testIDs.js +1 -54
  161. package/lib/module/react-query/utils/updateNestedDataByPath.js +1 -56
  162. package/lib/typescript/checkPeer.d.ts +1 -0
  163. package/lib/typescript/checkPeer.web.d.ts +2 -0
  164. package/lib/typescript/index.d.ts +1 -0
  165. package/lib/web/index.mjs +11 -0
  166. package/package.json +36 -12
  167. package/lib/typescript/index.d.ts.map +0 -1
  168. package/lib/typescript/preset.d.ts.map +0 -1
  169. package/lib/typescript/react-query/components/DataEditorMode.d.ts.map +0 -1
  170. package/lib/typescript/react-query/components/FilterStatusBadge.d.ts.map +0 -1
  171. package/lib/typescript/react-query/components/MutationBrowserMode.d.ts.map +0 -1
  172. package/lib/typescript/react-query/components/MutationEditorMode.d.ts.map +0 -1
  173. package/lib/typescript/react-query/components/QueryBrowserMode.d.ts.map +0 -1
  174. package/lib/typescript/react-query/components/QueryDebugInfo.d.ts.map +0 -1
  175. package/lib/typescript/react-query/components/QueryFilterViewV3.d.ts.map +0 -1
  176. package/lib/typescript/react-query/components/QuerySelector.d.ts.map +0 -1
  177. package/lib/typescript/react-query/components/ReactQueryDevToolsModal.d.ts.map +0 -1
  178. package/lib/typescript/react-query/components/ReactQuerySection.d.ts.map +0 -1
  179. package/lib/typescript/react-query/components/ReactQueryTracker.d.ts.map +0 -1
  180. package/lib/typescript/react-query/components/WifiToggle.d.ts.map +0 -1
  181. package/lib/typescript/react-query/components/modals/DataEditorModal.d.ts.map +0 -1
  182. package/lib/typescript/react-query/components/modals/MutationBrowserFooter.d.ts.map +0 -1
  183. package/lib/typescript/react-query/components/modals/MutationBrowserModal.d.ts.map +0 -1
  184. package/lib/typescript/react-query/components/modals/MutationEditorModal.d.ts.map +0 -1
  185. package/lib/typescript/react-query/components/modals/QueryBrowserFooter.d.ts.map +0 -1
  186. package/lib/typescript/react-query/components/modals/QueryBrowserModal.d.ts.map +0 -1
  187. package/lib/typescript/react-query/components/modals/ReactQueryModal.d.ts.map +0 -1
  188. package/lib/typescript/react-query/components/modals/ReactQueryModalHeader.d.ts.map +0 -1
  189. package/lib/typescript/react-query/components/modals/SwipeIndicator.d.ts.map +0 -1
  190. package/lib/typescript/react-query/components/query-browser/ActionButton.d.ts.map +0 -1
  191. package/lib/typescript/react-query/components/query-browser/ClearCacheButton.d.ts.map +0 -1
  192. package/lib/typescript/react-query/components/query-browser/Explorer.d.ts.map +0 -1
  193. package/lib/typescript/react-query/components/query-browser/MutationButton.d.ts.map +0 -1
  194. package/lib/typescript/react-query/components/query-browser/MutationDetails.d.ts.map +0 -1
  195. package/lib/typescript/react-query/components/query-browser/MutationDetailsChips.d.ts.map +0 -1
  196. package/lib/typescript/react-query/components/query-browser/MutationInformation.d.ts.map +0 -1
  197. package/lib/typescript/react-query/components/query-browser/MutationStatusCount.d.ts.map +0 -1
  198. package/lib/typescript/react-query/components/query-browser/MutationsList.d.ts.map +0 -1
  199. package/lib/typescript/react-query/components/query-browser/NetworkToggleButton.d.ts.map +0 -1
  200. package/lib/typescript/react-query/components/query-browser/QueryActions.d.ts.map +0 -1
  201. package/lib/typescript/react-query/components/query-browser/QueryBrowser.d.ts.map +0 -1
  202. package/lib/typescript/react-query/components/query-browser/QueryDetails.d.ts.map +0 -1
  203. package/lib/typescript/react-query/components/query-browser/QueryDetailsChip.d.ts.map +0 -1
  204. package/lib/typescript/react-query/components/query-browser/QueryInformation.d.ts.map +0 -1
  205. package/lib/typescript/react-query/components/query-browser/QueryRow.d.ts.map +0 -1
  206. package/lib/typescript/react-query/components/query-browser/QueryStatus.d.ts.map +0 -1
  207. package/lib/typescript/react-query/components/query-browser/QueryStatusCount.d.ts.map +0 -1
  208. package/lib/typescript/react-query/components/query-browser/StorageStatusCount.d.ts.map +0 -1
  209. package/lib/typescript/react-query/components/query-browser/index.d.ts.map +0 -1
  210. package/lib/typescript/react-query/components/query-browser/svgs.d.ts.map +0 -1
  211. package/lib/typescript/react-query/hooks/useActionButtons.d.ts.map +0 -1
  212. package/lib/typescript/react-query/hooks/useAllMutations.d.ts.map +0 -1
  213. package/lib/typescript/react-query/hooks/useAllQueries.d.ts.map +0 -1
  214. package/lib/typescript/react-query/hooks/useModalManager.d.ts.map +0 -1
  215. package/lib/typescript/react-query/hooks/useModalPersistence.d.ts.map +0 -1
  216. package/lib/typescript/react-query/hooks/useMutationActionButtons.d.ts.map +0 -1
  217. package/lib/typescript/react-query/hooks/useQueryStatusCounts.d.ts.map +0 -1
  218. package/lib/typescript/react-query/hooks/useReactQueryState.d.ts.map +0 -1
  219. package/lib/typescript/react-query/hooks/useSelectedMutation.d.ts.map +0 -1
  220. package/lib/typescript/react-query/hooks/useSelectedQuery.d.ts.map +0 -1
  221. package/lib/typescript/react-query/hooks/useStorageQueryCounts.d.ts.map +0 -1
  222. package/lib/typescript/react-query/hooks/useWifiState.d.ts.map +0 -1
  223. package/lib/typescript/react-query/stores/reactQueryEventStore.d.ts.map +0 -1
  224. package/lib/typescript/react-query/sync/dehydrate.d.ts.map +0 -1
  225. package/lib/typescript/react-query/sync/reactQuerySyncAdapter.d.ts.map +0 -1
  226. package/lib/typescript/react-query/sync/snapshotProvider.d.ts.map +0 -1
  227. package/lib/typescript/react-query/sync/useReactQuerySyncAdapter.d.ts.map +0 -1
  228. package/lib/typescript/react-query/types/types.d.ts.map +0 -1
  229. package/lib/typescript/react-query/utils/actions/deleteItem.d.ts.map +0 -1
  230. package/lib/typescript/react-query/utils/actions/emitDevToolsEvent.d.ts.map +0 -1
  231. package/lib/typescript/react-query/utils/actions/invalidate.d.ts.map +0 -1
  232. package/lib/typescript/react-query/utils/actions/refetch.d.ts.map +0 -1
  233. package/lib/typescript/react-query/utils/actions/remove.d.ts.map +0 -1
  234. package/lib/typescript/react-query/utils/actions/reset.d.ts.map +0 -1
  235. package/lib/typescript/react-query/utils/actions/triggerError.d.ts.map +0 -1
  236. package/lib/typescript/react-query/utils/actions/triggerLoading.d.ts.map +0 -1
  237. package/lib/typescript/react-query/utils/deleteNestedDataByPath.d.ts.map +0 -1
  238. package/lib/typescript/react-query/utils/getQueryStatusColor.d.ts.map +0 -1
  239. package/lib/typescript/react-query/utils/getQueryStatusLabel.d.ts.map +0 -1
  240. package/lib/typescript/react-query/utils/getStorageQueryCounts.d.ts.map +0 -1
  241. package/lib/typescript/react-query/utils/modalStorageOperations.d.ts.map +0 -1
  242. package/lib/typescript/react-query/utils/storageQueryUtils.d.ts.map +0 -1
  243. package/lib/typescript/react-query/utils/testIDs.d.ts.map +0 -1
  244. package/lib/typescript/react-query/utils/updateNestedDataByPath.d.ts.map +0 -1
@@ -1,64 +1 @@
1
- "use strict";
2
-
3
- import { useEffect, useState, useRef } from "react";
4
- import { onlineManager } from "@tanstack/react-query";
5
- import { devToolsStorageKeys, persistentStorage } from "@buoy-gg/shared-ui";
6
-
7
- /**
8
- * Synchronizes a local Wi-Fi toggle with React Query's `onlineManager`, persisting the selection
9
- * so developers can simulate offline mode across reloads.
10
- */
11
- export function useWifiState() {
12
- const [isOnline, setIsOnline] = useState(() => onlineManager.isOnline());
13
- const hasLoadedPersistedState = useRef(false);
14
-
15
- // Load persisted WiFi state on mount
16
- useEffect(() => {
17
- if (hasLoadedPersistedState.current) return;
18
- const loadPersistedState = async () => {
19
- try {
20
- const savedState = await persistentStorage.getItem(devToolsStorageKeys.settings.wifiEnabled());
21
- if (savedState !== null) {
22
- const isEnabled = savedState === "true";
23
- setIsOnline(isEnabled);
24
- onlineManager.setOnline(isEnabled);
25
- }
26
- hasLoadedPersistedState.current = true;
27
- } catch (error) {
28
- // Failed to load WiFi state
29
- }
30
- };
31
- loadPersistedState();
32
- }, []);
33
-
34
- // Save WiFi state when it changes
35
- const saveWifiState = async enabled => {
36
- try {
37
- await persistentStorage.setItem(devToolsStorageKeys.settings.wifiEnabled(), enabled.toString());
38
- } catch (error) {
39
- // Failed to save WiFi state
40
- }
41
- };
42
- const handleWifiToggle = () => {
43
- const newOnlineState = !isOnline;
44
- setIsOnline(newOnlineState);
45
- onlineManager.setOnline(newOnlineState);
46
- saveWifiState(newOnlineState);
47
- };
48
-
49
- // Listen to online manager changes to keep state in sync
50
- useEffect(() => {
51
- const unsubscribe = onlineManager.subscribe(online => {
52
- setIsOnline(online);
53
- // Only save if we've already loaded the persisted state to avoid overwriting on mount
54
- if (hasLoadedPersistedState.current) {
55
- saveWifiState(online);
56
- }
57
- });
58
- return unsubscribe;
59
- }, []);
60
- return {
61
- isOnline,
62
- handleWifiToggle
63
- };
64
- }
1
+ "use strict";import{useEffect as c,useState as d,useRef as S}from"react";import{onlineManager as s}from"@tanstack/react-query";import{devToolsStorageKeys as u,persistentStorage as f}from"@buoy-gg/shared-ui";export function useWifiState(){const[i,n]=d(()=>s.isOnline());const r=S(false);c(()=>{if(r.current)return;const t=async()=>{try{const e=await f.getItem(u.settings.wifiEnabled());if(e!==null){const o=e==="true";n(o);s.setOnline(o)}r.current=true}catch(e){}};t()},[]);const a=async t=>{try{await f.setItem(u.settings.wifiEnabled(),t.toString())}catch(e){}};const l=()=>{const t=!i;n(t);s.setOnline(t);a(t)};c(()=>{const t=s.subscribe(e=>{n(e);if(r.current){a(e)}});return t},[]);return{isOnline:i,handleWifiToggle:l}}
@@ -1,293 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * React Query Event Store
5
- *
6
- * Bridges React Query's cache subscription system to a simple pub/sub pattern
7
- * that can be consumed by the unified Events DevTools.
8
- *
9
- * Usage:
10
- * 1. In your app, call setQueryClient(queryClient) to connect
11
- * 2. The store will emit events for query/mutation state changes
12
- * 3. The Events DevTools subscribes to these events
13
- */
14
-
15
- import { ChangeLog } from "@buoy-gg/shared-ui";
16
- import { isStorageQuery } from "../utils/storageQueryUtils";
17
-
18
- /**
19
- * React Query event types for the unified timeline
20
- */
21
-
22
- /**
23
- * Unified React Query event for the timeline
24
- */
25
-
26
- let eventIdCounter = 0;
27
- function generateEventId() {
28
- return `rq-${Date.now()}-${++eventIdCounter}`;
29
- }
30
- class ReactQueryEventStore extends ChangeLog {
31
- queryClient = null;
32
- queryUnsubscribe = null;
33
- mutationUnsubscribe = null;
34
- constructor() {
35
- super({
36
- max: 200
37
- });
38
- }
39
-
40
- // Track fetch start times for duration calculation
41
- fetchStartTimes = new Map();
42
- mutationStartTimes = new Map();
43
-
44
- // Track last known states to detect transitions
45
- lastQueryStates = new Map();
46
- lastMutationStates = new Map();
47
-
48
- /**
49
- * Connect a QueryClient to the store
50
- * Call this in your app after creating the QueryClient
51
- */
52
- setQueryClient(queryClient) {
53
- // Cleanup previous connection
54
- this.disconnect();
55
- this.queryClient = queryClient;
56
-
57
- // Subscribe to query cache
58
- this.queryUnsubscribe = queryClient.getQueryCache().subscribe(event => {
59
- if (event.type === "updated" && event.query) {
60
- this.handleQueryUpdate(event.query);
61
- }
62
- });
63
-
64
- // Subscribe to mutation cache
65
- this.mutationUnsubscribe = queryClient.getMutationCache().subscribe(event => {
66
- if (event.type === "updated" && event.mutation) {
67
- this.handleMutationUpdate(event.mutation);
68
- }
69
- });
70
- }
71
-
72
- /**
73
- * Disconnect from the QueryClient
74
- */
75
- disconnect() {
76
- if (this.queryUnsubscribe) {
77
- this.queryUnsubscribe();
78
- this.queryUnsubscribe = null;
79
- }
80
- if (this.mutationUnsubscribe) {
81
- this.mutationUnsubscribe();
82
- this.mutationUnsubscribe = null;
83
- }
84
- this.queryClient = null;
85
- this.lastQueryStates.clear();
86
- this.lastMutationStates.clear();
87
- this.fetchStartTimes.clear();
88
- this.mutationStartTimes.clear();
89
- }
90
-
91
- /**
92
- * Handle query state updates and emit appropriate events
93
- */
94
- handleQueryUpdate(query) {
95
- // Skip storage queries (internal to the devtools)
96
- if (isStorageQuery(query.queryKey)) {
97
- return;
98
- }
99
- const queryHash = query.queryHash;
100
- const currentState = {
101
- fetchStatus: query.state.fetchStatus,
102
- status: query.state.status
103
- };
104
- const lastState = this.lastQueryStates.get(queryHash);
105
-
106
- // Detect state transitions
107
- if (!lastState) {
108
- // New query - if it's fetching, emit fetch start
109
- if (currentState.fetchStatus === "fetching") {
110
- this.fetchStartTimes.set(queryHash, Date.now());
111
- this.addEvent({
112
- id: generateEventId(),
113
- type: "query-fetch-start",
114
- timestamp: Date.now(),
115
- queryKey: query.queryKey,
116
- queryHash,
117
- query
118
- });
119
- }
120
- } else {
121
- // Existing query - check for transitions
122
- const wasFetching = lastState.fetchStatus === "fetching";
123
- const isFetching = currentState.fetchStatus === "fetching";
124
-
125
- // Started fetching
126
- if (!wasFetching && isFetching) {
127
- this.fetchStartTimes.set(queryHash, Date.now());
128
- this.addEvent({
129
- id: generateEventId(),
130
- type: "query-fetch-start",
131
- timestamp: Date.now(),
132
- queryKey: query.queryKey,
133
- queryHash,
134
- query
135
- });
136
- }
137
-
138
- // Finished fetching
139
- if (wasFetching && !isFetching) {
140
- const startTime = this.fetchStartTimes.get(queryHash);
141
- const duration = startTime ? Date.now() - startTime : undefined;
142
- this.fetchStartTimes.delete(queryHash);
143
- if (currentState.status === "error") {
144
- this.addEvent({
145
- id: generateEventId(),
146
- type: "query-fetch-error",
147
- timestamp: Date.now(),
148
- queryKey: query.queryKey,
149
- queryHash,
150
- queryError: query.state.error,
151
- duration,
152
- query
153
- });
154
- } else {
155
- this.addEvent({
156
- id: generateEventId(),
157
- type: "query-fetch-success",
158
- timestamp: Date.now(),
159
- queryKey: query.queryKey,
160
- queryHash,
161
- queryData: query.state.data,
162
- duration,
163
- query
164
- });
165
- }
166
- }
167
-
168
- // Query was invalidated
169
- if (!lastState.status && query.state.isInvalidated) {
170
- this.addEvent({
171
- id: generateEventId(),
172
- type: "query-invalidated",
173
- timestamp: Date.now(),
174
- queryKey: query.queryKey,
175
- queryHash,
176
- query
177
- });
178
- }
179
- }
180
-
181
- // Update last known state
182
- this.lastQueryStates.set(queryHash, currentState);
183
- }
184
-
185
- /**
186
- * Handle mutation state updates and emit appropriate events
187
- */
188
- handleMutationUpdate(mutation) {
189
- const mutationId = mutation.mutationId;
190
- const currentStatus = mutation.state.status;
191
- const lastStatus = this.lastMutationStates.get(mutationId);
192
- if (lastStatus !== currentStatus) {
193
- // Status changed
194
- if (currentStatus === "pending" && lastStatus !== "pending") {
195
- // Mutation started
196
- this.mutationStartTimes.set(mutationId, Date.now());
197
- this.addEvent({
198
- id: generateEventId(),
199
- type: "mutation-start",
200
- timestamp: Date.now(),
201
- mutationId,
202
- mutationKey: mutation.options.mutationKey,
203
- mutationVariables: mutation.state.variables,
204
- mutation
205
- });
206
- } else if (currentStatus === "success" && lastStatus === "pending") {
207
- // Mutation succeeded
208
- const startTime = this.mutationStartTimes.get(mutationId);
209
- const duration = startTime ? Date.now() - startTime : undefined;
210
- this.mutationStartTimes.delete(mutationId);
211
- this.addEvent({
212
- id: generateEventId(),
213
- type: "mutation-success",
214
- timestamp: Date.now(),
215
- mutationId,
216
- mutationKey: mutation.options.mutationKey,
217
- mutationVariables: mutation.state.variables,
218
- mutationData: mutation.state.data,
219
- duration,
220
- mutation
221
- });
222
- } else if (currentStatus === "error" && lastStatus === "pending") {
223
- // Mutation failed
224
- const startTime = this.mutationStartTimes.get(mutationId);
225
- const duration = startTime ? Date.now() - startTime : undefined;
226
- this.mutationStartTimes.delete(mutationId);
227
- this.addEvent({
228
- id: generateEventId(),
229
- type: "mutation-error",
230
- timestamp: Date.now(),
231
- mutationId,
232
- mutationKey: mutation.options.mutationKey,
233
- mutationVariables: mutation.state.variables,
234
- mutationError: mutation.state.error,
235
- duration,
236
- mutation
237
- });
238
- }
239
- }
240
-
241
- // Update last known status
242
- this.lastMutationStates.set(mutationId, currentStatus);
243
- }
244
-
245
- /**
246
- * Add an event to the store
247
- */
248
- addEvent(event) {
249
- this.record(event);
250
- }
251
-
252
- /**
253
- * Get all events
254
- */
255
- getEvents() {
256
- return this.items;
257
- }
258
-
259
- /**
260
- * Subscribe to event changes
261
- */
262
- subscribe(listener) {
263
- const unsubscribe = super.subscribe(listener);
264
- // Immediately call with current events
265
- listener(this.items);
266
- return unsubscribe;
267
- }
268
-
269
- /**
270
- * Clear all events
271
- */
272
- clearEvents() {
273
- this.clear();
274
- }
275
-
276
- /**
277
- * Check if connected to a QueryClient
278
- */
279
- isConnected() {
280
- return this.queryClient !== null;
281
- }
282
- }
283
-
284
- // Singleton instance
285
- export const reactQueryEventStore = new ReactQueryEventStore();
286
-
287
- // Convenience exports
288
- export const setQueryClient = queryClient => reactQueryEventStore.setQueryClient(queryClient);
289
- export const disconnectQueryClient = () => reactQueryEventStore.disconnect();
290
- export const getReactQueryEvents = () => reactQueryEventStore.getEvents();
291
- export const subscribeToReactQueryEvents = listener => reactQueryEventStore.subscribe(listener);
292
- export const clearReactQueryEvents = () => reactQueryEventStore.clearEvents();
293
- export const isReactQueryConnected = () => reactQueryEventStore.isConnected();
1
+ "use strict";import{ChangeLog as d}from"@buoy-gg/shared-ui";import{isStorageQuery as h}from"../utils/storageQueryUtils";let l=0;function n(){return`rq-${Date.now()}-${++l}`}class y extends d{queryClient=null;queryUnsubscribe=null;mutationUnsubscribe=null;constructor(){super({max:200})}fetchStartTimes=new Map;mutationStartTimes=new Map;lastQueryStates=new Map;lastMutationStates=new Map;setQueryClient(t){this.disconnect();this.queryClient=t;this.queryUnsubscribe=t.getQueryCache().subscribe(e=>{if(e.type==="updated"&&e.query){this.handleQueryUpdate(e.query)}});this.mutationUnsubscribe=t.getMutationCache().subscribe(e=>{if(e.type==="updated"&&e.mutation){this.handleMutationUpdate(e.mutation)}})}disconnect(){if(this.queryUnsubscribe){this.queryUnsubscribe();this.queryUnsubscribe=null}if(this.mutationUnsubscribe){this.mutationUnsubscribe();this.mutationUnsubscribe=null}this.queryClient=null;this.lastQueryStates.clear();this.lastMutationStates.clear();this.fetchStartTimes.clear();this.mutationStartTimes.clear()}handleQueryUpdate(t){if(h(t.queryKey)){return}const e=t.queryHash;const s={fetchStatus:t.state.fetchStatus,status:t.state.status};const a=this.lastQueryStates.get(e);if(!a){if(s.fetchStatus==="fetching"){this.fetchStartTimes.set(e,Date.now());this.addEvent({id:n(),type:"query-fetch-start",timestamp:Date.now(),queryKey:t.queryKey,queryHash:e,query:t})}}else{const i=a.fetchStatus==="fetching";const r=s.fetchStatus==="fetching";if(!i&&r){this.fetchStartTimes.set(e,Date.now());this.addEvent({id:n(),type:"query-fetch-start",timestamp:Date.now(),queryKey:t.queryKey,queryHash:e,query:t})}if(i&&!r){const o=this.fetchStartTimes.get(e);const c=o?Date.now()-o:void 0;this.fetchStartTimes.delete(e);if(s.status==="error"){this.addEvent({id:n(),type:"query-fetch-error",timestamp:Date.now(),queryKey:t.queryKey,queryHash:e,queryError:t.state.error,duration:c,query:t})}else{this.addEvent({id:n(),type:"query-fetch-success",timestamp:Date.now(),queryKey:t.queryKey,queryHash:e,queryData:t.state.data,duration:c,query:t})}}if(!a.status&&t.state.isInvalidated){this.addEvent({id:n(),type:"query-invalidated",timestamp:Date.now(),queryKey:t.queryKey,queryHash:e,query:t})}}this.lastQueryStates.set(e,s)}handleMutationUpdate(t){const e=t.mutationId;const s=t.state.status;const a=this.lastMutationStates.get(e);if(a!==s){if(s==="pending"&&a!=="pending"){this.mutationStartTimes.set(e,Date.now());this.addEvent({id:n(),type:"mutation-start",timestamp:Date.now(),mutationId:e,mutationKey:t.options.mutationKey,mutationVariables:t.state.variables,mutation:t})}else if(s==="success"&&a==="pending"){const i=this.mutationStartTimes.get(e);const r=i?Date.now()-i:void 0;this.mutationStartTimes.delete(e);this.addEvent({id:n(),type:"mutation-success",timestamp:Date.now(),mutationId:e,mutationKey:t.options.mutationKey,mutationVariables:t.state.variables,mutationData:t.state.data,duration:r,mutation:t})}else if(s==="error"&&a==="pending"){const i=this.mutationStartTimes.get(e);const r=i?Date.now()-i:void 0;this.mutationStartTimes.delete(e);this.addEvent({id:n(),type:"mutation-error",timestamp:Date.now(),mutationId:e,mutationKey:t.options.mutationKey,mutationVariables:t.state.variables,mutationError:t.state.error,duration:r,mutation:t})}}this.lastMutationStates.set(e,s)}addEvent(t){this.record(t)}getEvents(){return this.items}subscribe(t){const e=super.subscribe(t);t(this.items);return e}clearEvents(){this.clear()}isConnected(){return this.queryClient!==null}}export const reactQueryEventStore=new y;export const setQueryClient=u=>reactQueryEventStore.setQueryClient(u);export const disconnectQueryClient=()=>reactQueryEventStore.disconnect();export const getReactQueryEvents=()=>reactQueryEventStore.getEvents();export const subscribeToReactQueryEvents=u=>reactQueryEventStore.subscribe(u);export const clearReactQueryEvents=()=>reactQueryEventStore.clearEvents();export const isReactQueryConnected=()=>reactQueryEventStore.isConnected();
@@ -1,156 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * Dehydration for external sync — ported from buoy-desktop's
5
- * react-query-external-sync/hydration.ts so the desktop dashboard can
6
- * hydrate an identical mirror of the device's QueryClient.
7
- */
8
-
9
- import { isJsonSerializable, isOverWireBudget } from "@buoy-gg/shared-ui";
10
-
11
- /**
12
- * Sentinel used in WIRE-FORM snapshots in place of oversized query/mutation
13
- * data. Same hazard as redux/zustand: a single cached payload can exceed the
14
- * 2MB emit budget (dashboard goes stale) or freeze JSON.stringify. Dashboards
15
- * fetch the real value via `getQueryData`.
16
- */
17
- export const DATA_ON_DEVICE = Object.freeze({
18
- __buoyDataOnDevice: true,
19
- note: "Query data stays on the device — fetched on demand via getQueryData."
20
- });
21
-
22
- /** Sentinel when JSON.stringify throws (circular refs, bigint, …). */
23
- export const UNSERIALIZABLE_DATA = Object.freeze({
24
- __buoyUnserializable: true,
25
- note: "Query data is not JSON-serializable (circular or bigint) and stayed on the device."
26
- });
27
-
28
- /** Keep small payloads inline; strip anything over this (same as network bodies). */
29
- export const SNAPSHOT_DATA_INLINE_LIMIT = 16 * 1024;
30
- export const MAX_QUERY_DETAIL_BYTES = 8 * 1024 * 1024;
31
- export function isDataOnDeviceMarker(value) {
32
- return !!value && typeof value === "object" && value.__buoyDataOnDevice === true;
33
- }
34
- export function isUnserializableMarker(value) {
35
- return !!value && typeof value === "object" && value.__buoyUnserializable === true;
36
- }
37
- export function isWireDataMarker(value) {
38
- return isDataOnDeviceMarker(value) || isUnserializableMarker(value);
39
- }
40
-
41
- /** Replace unserializable / oversized values with a wire marker. */
42
- export function toWireData(value) {
43
- if (value === undefined) return undefined;
44
- if (!isOverWireBudget(value, SNAPSHOT_DATA_INLINE_LIMIT)) return value;
45
- // Distinguish "too big to send" from "cannot be sent at all" — the dashboard
46
- // offers a fetch for the first and must not for the second.
47
- return isJsonSerializable(value) ? DATA_ON_DEVICE : UNSERIALIZABLE_DATA;
48
- }
49
-
50
- /**
51
- * Query/mutation `error` (and `fetchFailureReason` / `failureReason`) often
52
- * hold the live Axios/fetch error: `request` points at XHR (cyclic),
53
- * `response.data` is the same fat body we already stripped from `state.data`.
54
- * Spreading `query.state` left that copy on the wire after capping data.
55
- * The dashboard only reads `error.message`.
56
- */
57
- export function toWireError(value) {
58
- if (value == null) return value;
59
- if (typeof value === "object") {
60
- const err = value;
61
- const name = typeof err.name === "string" ? err.name : undefined;
62
- const message = typeof err.message === "string" ? err.message : undefined;
63
- if (name !== undefined || message !== undefined) {
64
- return toWireData({
65
- ...(name !== undefined ? {
66
- name
67
- } : {}),
68
- ...(message !== undefined ? {
69
- message
70
- } : {})
71
- });
72
- }
73
- }
74
- return toWireData(value);
75
- }
76
-
77
- /** Cap an on-demand detail payload (action result, not the per-tick snapshot). */
78
- export function capQueryDetail(value) {
79
- if (!isOverWireBudget(value, MAX_QUERY_DETAIL_BYTES)) return value;
80
- if (!isJsonSerializable(value)) return UNSERIALIZABLE_DATA;
81
- return {
82
- __buoyTruncated: true,
83
- note: `Exceeds the ${MAX_QUERY_DETAIL_BYTES / (1024 * 1024)}MB detail limit — inspect it on-device.`
84
- };
85
- }
86
- export function dehydrateQueryClient(client) {
87
- const mutations = client.getMutationCache().getAll().map(mutation => dehydrateMutation(mutation));
88
- const queries = client.getQueryCache().getAll().map(query => dehydrateQuery(query));
89
- return {
90
- mutations,
91
- queries
92
- };
93
- }
94
- function dehydrateMutation(mutation) {
95
- const state = mutation.state;
96
- return {
97
- mutationId: mutation.mutationId,
98
- mutationKey: mutation.options.mutationKey,
99
- state: {
100
- ...state,
101
- data: toWireData(state.data),
102
- variables: toWireData(state.variables),
103
- error: toWireError(state.error),
104
- failureReason: toWireError(state.failureReason)
105
- },
106
- ...(mutation.options.scope && {
107
- scope: mutation.options.scope
108
- }),
109
- ...(mutation.meta && {
110
- meta: toWireData(mutation.meta)
111
- })
112
- };
113
- }
114
- function toWireObserverOptions(options) {
115
- // queryFn / select / persister are functions. initialData and
116
- // placeholderData are often the SAME fat tree as state.data (apps seed
117
- // the cache with it). Capping state.data still left those copies on the
118
- // wire and dropped the Query panel.
119
- const {
120
- queryFn: _queryFn,
121
- select: _select,
122
- persister: _persister,
123
- initialData: _initialData,
124
- placeholderData: _placeholderData,
125
- ...light
126
- } = options;
127
- return {
128
- ...light,
129
- queryFn: undefined,
130
- ...(options.meta ? {
131
- meta: toWireData(options.meta)
132
- } : {})
133
- };
134
- }
135
- function dehydrateQuery(query) {
136
- const observerStates = query.observers.map(observer => ({
137
- queryHash: query.queryHash,
138
- options: toWireObserverOptions(observer.options)
139
- }));
140
- return {
141
- state: {
142
- ...query.state,
143
- ...(query.state.data !== undefined && {
144
- data: toWireData(query.state.data)
145
- }),
146
- error: toWireError(query.state.error),
147
- fetchFailureReason: toWireError(query.state.fetchFailureReason)
148
- },
149
- queryKey: query.queryKey,
150
- queryHash: query.queryHash,
151
- ...(query.meta && {
152
- meta: toWireData(query.meta)
153
- }),
154
- observers: observerStates
155
- };
156
- }
1
+ "use strict";import{isJsonSerializable as a,isOverWireBudget as i}from"@buoy-gg/shared-ui";export const DATA_ON_DEVICE=Object.freeze({__buoyDataOnDevice:true,note:"Query data stays on the device \u2014 fetched on demand via getQueryData."});export const UNSERIALIZABLE_DATA=Object.freeze({__buoyUnserializable:true,note:"Query data is not JSON-serializable (circular or bigint) and stayed on the device."});export const SNAPSHOT_DATA_INLINE_LIMIT=16*1024;export const MAX_QUERY_DETAIL_BYTES=8*1024*1024;export function isDataOnDeviceMarker(e){return!!e&&typeof e==="object"&&e.__buoyDataOnDevice===true}export function isUnserializableMarker(e){return!!e&&typeof e==="object"&&e.__buoyUnserializable===true}export function isWireDataMarker(e){return isDataOnDeviceMarker(e)||isUnserializableMarker(e)}export function toWireData(e){if(e===void 0)return void 0;if(!i(e,SNAPSHOT_DATA_INLINE_LIMIT))return e;return a(e)?DATA_ON_DEVICE:UNSERIALIZABLE_DATA}export function toWireError(e){if(e==null)return e;if(typeof e==="object"){const t=e;const r=typeof t.name==="string"?t.name:void 0;const n=typeof t.message==="string"?t.message:void 0;if(r!==void 0||n!==void 0){return toWireData({...r!==void 0?{name:r}:{},...n!==void 0?{message:n}:{}})}}return toWireData(e)}export function capQueryDetail(e){if(!i(e,MAX_QUERY_DETAIL_BYTES))return e;if(!a(e))return UNSERIALIZABLE_DATA;return{__buoyTruncated:true,note:`Exceeds the ${MAX_QUERY_DETAIL_BYTES/(1024*1024)}MB detail limit \u2014 inspect it on-device.`}}export function dehydrateQueryClient(e){const t=e.getMutationCache().getAll().map(n=>s(n));const r=e.getQueryCache().getAll().map(n=>d(n));return{mutations:t,queries:r}}function s(e){const t=e.state;return{mutationId:e.mutationId,mutationKey:e.options.mutationKey,state:{...t,data:toWireData(t.data),variables:toWireData(t.variables),error:toWireError(t.error),failureReason:toWireError(t.failureReason)},...e.options.scope&&{scope:e.options.scope},...e.meta&&{meta:toWireData(e.meta)}}}function c(e){const{queryFn:t,select:r,persister:n,initialData:u,placeholderData:f,...o}=e;return{...o,queryFn:void 0,...e.meta?{meta:toWireData(e.meta)}:{}}}function d(e){const t=e.observers.map(r=>({queryHash:e.queryHash,options:c(r.options)}));return{state:{...e.state,...e.state.data!==void 0&&{data:toWireData(e.state.data)},error:toWireError(e.state.error),fetchFailureReason:toWireError(e.state.fetchFailureReason)},queryKey:e.queryKey,queryHash:e.queryHash,...e.meta&&{meta:toWireData(e.meta)},observers:t}}