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