@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,289 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createQuerySnapshotProvider = createQuerySnapshotProvider;
|
|
7
|
-
exports.registerQuerySnapshotProvider = registerQuerySnapshotProvider;
|
|
8
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
9
|
-
var _dehydrate = require("./dehydrate");
|
|
10
|
-
/**
|
|
11
|
-
* Time Machine snapshot provider for React Query.
|
|
12
|
-
*
|
|
13
|
-
* Unlike the other providers this one can't register at module init — the
|
|
14
|
-
* QueryClient only exists in React context — so useReactQuerySyncAdapter
|
|
15
|
-
* (mounted app-lifetime by FloatingDevTools' auto external sync) registers
|
|
16
|
-
* it per-client via an effect.
|
|
17
|
-
*
|
|
18
|
-
* Restore is a device-safe DIFF against the live cache, NOT the desktop
|
|
19
|
-
* Hydrate: that one detaches live observers and mocks queryFns, which is
|
|
20
|
-
* fine on a mirror client and destructive in a running app. Here existing
|
|
21
|
-
* queries get `setState` (observers stay attached and are notified, keeping
|
|
22
|
-
* their real queryFns), missing ones are built into the cache, and extras
|
|
23
|
-
* are removed. Mutations aren't restorable (mutationFns can't be captured);
|
|
24
|
-
* the mutation cache is cleared instead.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/** A restored query must never claim an in-flight fetch it doesn't have. */
|
|
28
|
-
function normalizeState(state) {
|
|
29
|
-
return {
|
|
30
|
-
...state,
|
|
31
|
-
fetchStatus: "idle",
|
|
32
|
-
fetchMeta: null
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* The comparable projection of a query for previews: status/error/data ONLY.
|
|
38
|
-
* Timestamps (dataUpdatedAt etc.) are excluded — including them makes every
|
|
39
|
-
* query read as "changed" the moment anything refetches.
|
|
40
|
-
*/
|
|
41
|
-
function comparableQuery(q) {
|
|
42
|
-
return {
|
|
43
|
-
status: q.state.status,
|
|
44
|
-
error: q.state.error ?? null,
|
|
45
|
-
data: q.state.data
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function queryLabel(queryKey, queryHash) {
|
|
49
|
-
try {
|
|
50
|
-
const s = JSON.stringify(queryKey);
|
|
51
|
-
return s.length > 60 ? `${s.slice(0, 57)}…` : s;
|
|
52
|
-
} catch {
|
|
53
|
-
return queryHash;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* A query `error` (and `fetchFailureReason`) usually holds the live
|
|
59
|
-
* Axios/fetch error: `request` points at the XHR, which is cyclic and would
|
|
60
|
-
* fail the whole snapshot's serialization. Only name + message survive —
|
|
61
|
-
* that's all a restored error state needs.
|
|
62
|
-
*/
|
|
63
|
-
function toStoredError(value) {
|
|
64
|
-
if (value == null) return value ?? null;
|
|
65
|
-
if (typeof value === "object") {
|
|
66
|
-
const err = value;
|
|
67
|
-
const name = typeof err.name === "string" ? err.name : undefined;
|
|
68
|
-
const message = typeof err.message === "string" ? err.message : undefined;
|
|
69
|
-
if (name !== undefined || message !== undefined) {
|
|
70
|
-
return {
|
|
71
|
-
...(name !== undefined ? {
|
|
72
|
-
name
|
|
73
|
-
} : {}),
|
|
74
|
-
...(message !== undefined ? {
|
|
75
|
-
message
|
|
76
|
-
} : {})
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return value;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** Would the Time Machine vault be able to store this value? */
|
|
84
|
-
function isStorable(value) {
|
|
85
|
-
if (value === undefined) return true;
|
|
86
|
-
try {
|
|
87
|
-
(0, _sharedUi.superJsonSerialize)(value);
|
|
88
|
-
return true;
|
|
89
|
-
} catch {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* The queries as a SNAPSHOT sees them — raw.
|
|
96
|
-
*
|
|
97
|
-
* Deliberately NOT `dehydrateQueryClient()`: that is the WIRE form, which
|
|
98
|
-
* swaps any payload over 16KB for a `DATA_ON_DEVICE` marker so the dashboard
|
|
99
|
-
* stays inside its emit budget. Snapshots live on-device in persistentStorage
|
|
100
|
-
* with no such budget, and restoring a marker would write the placeholder
|
|
101
|
-
* object into the live cache — the app then renders `{__buoyDataOnDevice}` as
|
|
102
|
-
* if it were its data and crashes on the first field it reads.
|
|
103
|
-
*/
|
|
104
|
-
function captureQueries(client) {
|
|
105
|
-
const warnings = [];
|
|
106
|
-
const queries = [];
|
|
107
|
-
for (const query of client.getQueryCache().getAll()) {
|
|
108
|
-
const label = queryLabel(query.queryKey, query.queryHash);
|
|
109
|
-
if (!isStorable(query.state.data)) {
|
|
110
|
-
warnings.push(`query ${label}: data can't be serialized (circular reference?) — not captured`);
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
queries.push({
|
|
114
|
-
queryKey: query.queryKey,
|
|
115
|
-
queryHash: query.queryHash,
|
|
116
|
-
...(query.meta && isStorable(query.meta) ? {
|
|
117
|
-
meta: query.meta
|
|
118
|
-
} : {}),
|
|
119
|
-
state: normalizeState({
|
|
120
|
-
...query.state,
|
|
121
|
-
error: toStoredError(query.state.error),
|
|
122
|
-
fetchFailureReason: toStoredError(query.state.fetchFailureReason)
|
|
123
|
-
})
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
return {
|
|
127
|
-
queries,
|
|
128
|
-
warnings
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
function createQuerySnapshotProvider(queryClient) {
|
|
132
|
-
return {
|
|
133
|
-
id: "query",
|
|
134
|
-
label: "React Query",
|
|
135
|
-
status: () => ({
|
|
136
|
-
canCapture: true,
|
|
137
|
-
canRestore: true
|
|
138
|
-
}),
|
|
139
|
-
async capture() {
|
|
140
|
-
const {
|
|
141
|
-
queries,
|
|
142
|
-
warnings
|
|
143
|
-
} = captureQueries(queryClient);
|
|
144
|
-
const mutationCount = queryClient.getMutationCache().getAll().length;
|
|
145
|
-
if (mutationCount > 0) {
|
|
146
|
-
warnings.push(`${mutationCount} mutation(s) not captured (mutation functions cannot be restored)`);
|
|
147
|
-
}
|
|
148
|
-
return {
|
|
149
|
-
data: {
|
|
150
|
-
queries
|
|
151
|
-
},
|
|
152
|
-
warnings
|
|
153
|
-
};
|
|
154
|
-
},
|
|
155
|
-
async restore(data, options) {
|
|
156
|
-
const snapshot = data;
|
|
157
|
-
const scope = (0, _sharedUi.createRestoreScope)(options);
|
|
158
|
-
const result = (0, _sharedUi.emptyRestoreResult)();
|
|
159
|
-
if (!snapshot?.queries) {
|
|
160
|
-
return (0, _sharedUi.failedRestore)("empty query snapshot");
|
|
161
|
-
}
|
|
162
|
-
const cache = queryClient.getQueryCache();
|
|
163
|
-
const snapHashes = new Set(snapshot.queries.map(q => q.queryHash));
|
|
164
|
-
for (const snap of snapshot.queries) {
|
|
165
|
-
if (!scope.allows(snap.queryHash)) continue;
|
|
166
|
-
// Snapshots taken before the raw-capture fix hold a wire placeholder
|
|
167
|
-
// instead of the data. Writing that into the cache hands the app an
|
|
168
|
-
// object with none of its fields — leave the live query alone and say
|
|
169
|
-
// why, rather than "restoring" a value that crashes the screen.
|
|
170
|
-
if ((0, _dehydrate.isWireDataMarker)(snap.state.data)) {
|
|
171
|
-
result.skipped.push({
|
|
172
|
-
id: snap.queryHash,
|
|
173
|
-
reason: "captured as an on-device placeholder by an older Buoy — re-capture this restore point"
|
|
174
|
-
});
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
try {
|
|
178
|
-
const state = normalizeState(snap.state);
|
|
179
|
-
const existing = cache.get(snap.queryHash);
|
|
180
|
-
if (existing) {
|
|
181
|
-
// Observers stay attached (with their real queryFns) and get
|
|
182
|
-
// notified — the safe on-device path, same as triggerError's.
|
|
183
|
-
existing.setState(state);
|
|
184
|
-
} else {
|
|
185
|
-
cache.build(queryClient, {
|
|
186
|
-
queryKey: snap.queryKey,
|
|
187
|
-
queryHash: snap.queryHash,
|
|
188
|
-
...(snap.meta && {
|
|
189
|
-
meta: snap.meta
|
|
190
|
-
})
|
|
191
|
-
}, state);
|
|
192
|
-
}
|
|
193
|
-
result.applied += 1;
|
|
194
|
-
} catch (e) {
|
|
195
|
-
result.skipped.push({
|
|
196
|
-
id: snap.queryHash,
|
|
197
|
-
reason: String(e)
|
|
198
|
-
});
|
|
199
|
-
result.ok = false;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Cache entries the snapshot doesn't know about get removed; a mounted
|
|
204
|
-
// observer will rebuild + refetch its query on next interaction.
|
|
205
|
-
for (const query of cache.getAll().slice()) {
|
|
206
|
-
if (!scope.allows(query.queryHash)) continue;
|
|
207
|
-
if (!snapHashes.has(query.queryHash)) {
|
|
208
|
-
try {
|
|
209
|
-
cache.remove(query);
|
|
210
|
-
result.applied += 1;
|
|
211
|
-
} catch (e) {
|
|
212
|
-
result.skipped.push({
|
|
213
|
-
id: query.queryHash,
|
|
214
|
-
reason: String(e)
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
const mutationCount = queryClient.getMutationCache().getAll().length;
|
|
220
|
-
if (mutationCount > 0) {
|
|
221
|
-
queryClient.getMutationCache().clear();
|
|
222
|
-
result.warnings.push(`mutation cache cleared (${mutationCount} mutation(s))`);
|
|
223
|
-
}
|
|
224
|
-
const excludedWarning = scope.excludedWarning("quer(y/ies)");
|
|
225
|
-
if (excludedWarning) result.warnings.push(excludedWarning);
|
|
226
|
-
return result;
|
|
227
|
-
},
|
|
228
|
-
/** Per-query restore preview. `base` omitted = compare against live cache. */
|
|
229
|
-
async previewItems(target, base) {
|
|
230
|
-
const targetQueries = target?.queries ?? [];
|
|
231
|
-
const liveMode = base === undefined;
|
|
232
|
-
// Live side goes through the same raw capture as a snapshot would, so a
|
|
233
|
-
// big query diffs as its real value instead of a wire placeholder.
|
|
234
|
-
const baseQueries = liveMode ? captureQueries(queryClient).queries : base?.queries ?? [];
|
|
235
|
-
const baseByHash = new Map(baseQueries.map(q => [q.queryHash, q]));
|
|
236
|
-
const targetByHash = new Map(targetQueries.map(q => [q.queryHash, q]));
|
|
237
|
-
const items = [];
|
|
238
|
-
const notes = [];
|
|
239
|
-
for (const q of targetQueries) {
|
|
240
|
-
const label = queryLabel(q.queryKey, q.queryHash);
|
|
241
|
-
if ((0, _dehydrate.isWireDataMarker)(q.state.data)) {
|
|
242
|
-
items.push({
|
|
243
|
-
key: q.queryHash,
|
|
244
|
-
label,
|
|
245
|
-
verdict: "wont-apply",
|
|
246
|
-
reason: "data stayed on the device when this was captured (older Buoy) — re-capture this restore point"
|
|
247
|
-
});
|
|
248
|
-
continue;
|
|
249
|
-
}
|
|
250
|
-
const baseQ = baseByHash.get(q.queryHash);
|
|
251
|
-
items.push((0, _sharedUi.classifyPreviewItem)({
|
|
252
|
-
key: q.queryHash,
|
|
253
|
-
label,
|
|
254
|
-
oldValue: baseQ ? comparableQuery(baseQ) : undefined,
|
|
255
|
-
newValue: comparableQuery(q),
|
|
256
|
-
inOld: baseQ !== undefined,
|
|
257
|
-
inNew: true
|
|
258
|
-
}, {
|
|
259
|
-
tooLargeReason: "query data too large to render a diff — restore still applies it"
|
|
260
|
-
}));
|
|
261
|
-
}
|
|
262
|
-
for (const q of baseQueries) {
|
|
263
|
-
if (!targetByHash.has(q.queryHash)) {
|
|
264
|
-
items.push({
|
|
265
|
-
key: q.queryHash,
|
|
266
|
-
label: queryLabel(q.queryKey, q.queryHash),
|
|
267
|
-
verdict: "removed",
|
|
268
|
-
oldValue: comparableQuery(q)
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
if (liveMode) {
|
|
273
|
-
const mutationCount = queryClient.getMutationCache().getAll().length;
|
|
274
|
-
if (mutationCount > 0) {
|
|
275
|
-
notes.push(`${mutationCount} in-memory mutation record(s) will be cleared`);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
return {
|
|
279
|
-
items,
|
|
280
|
-
notes
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/** Register for one client; returns the unregister fn. Last client wins. */
|
|
287
|
-
function registerQuerySnapshotProvider(queryClient) {
|
|
288
|
-
return (0, _sharedUi.registerStateSnapshotProvider)(createQuerySnapshotProvider(queryClient));
|
|
289
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.createQuerySnapshotProvider=createQuerySnapshotProvider;exports.registerQuerySnapshotProvider=registerQuerySnapshotProvider;var _sharedUi=require("@buoy-gg/shared-ui");var _dehydrate=require("./dehydrate");function normalizeState(t){return{...t,fetchStatus:"idle",fetchMeta:null}}function comparableQuery(t){return{status:t.state.status,error:t.state.error??null,data:t.state.data}}function queryLabel(t,s){try{const a=JSON.stringify(t);return a.length>60?`${a.slice(0,57)}\u2026`:a}catch{return s}}function toStoredError(t){if(t==null)return t??null;if(typeof t==="object"){const s=t;const a=typeof s.name==="string"?s.name:void 0;const r=typeof s.message==="string"?s.message:void 0;if(a!==void 0||r!==void 0){return{...a!==void 0?{name:a}:{},...r!==void 0?{message:r}:{}}}}return t}function isStorable(t){if(t===void 0)return true;try{(0,_sharedUi.superJsonSerialize)(t);return true}catch{return false}}function captureQueries(t){const s=[];const a=[];for(const r of t.getQueryCache().getAll()){const o=queryLabel(r.queryKey,r.queryHash);if(!isStorable(r.state.data)){s.push(`query ${o}: data can't be serialized (circular reference?) \u2014 not captured`);continue}a.push({queryKey:r.queryKey,queryHash:r.queryHash,...r.meta&&isStorable(r.meta)?{meta:r.meta}:{},state:normalizeState({...r.state,error:toStoredError(r.state.error),fetchFailureReason:toStoredError(r.state.fetchFailureReason)})})}return{queries:a,warnings:s}}function createQuerySnapshotProvider(t){return{id:"query",label:"React Query",status:()=>({canCapture:true,canRestore:true}),async capture(){const{queries:s,warnings:a}=captureQueries(t);const r=t.getMutationCache().getAll().length;if(r>0){a.push(`${r} mutation(s) not captured (mutation functions cannot be restored)`)}return{data:{queries:s},warnings:a}},async restore(s,a){const r=s;const o=(0,_sharedUi.createRestoreScope)(a);const n=(0,_sharedUi.emptyRestoreResult)();if(!r?.queries){return(0,_sharedUi.failedRestore)("empty query snapshot")}const c=t.getQueryCache();const y=new Set(r.queries.map(e=>e.queryHash));for(const e of r.queries){if(!o.allows(e.queryHash))continue;if((0,_dehydrate.isWireDataMarker)(e.state.data)){n.skipped.push({id:e.queryHash,reason:"captured as an on-device placeholder by an older Buoy \u2014 re-capture this restore point"});continue}try{const u=normalizeState(e.state);const d=c.get(e.queryHash);if(d){d.setState(u)}else{c.build(t,{queryKey:e.queryKey,queryHash:e.queryHash,...e.meta&&{meta:e.meta}},u)}n.applied+=1}catch(u){n.skipped.push({id:e.queryHash,reason:String(u)});n.ok=false}}for(const e of c.getAll().slice()){if(!o.allows(e.queryHash))continue;if(!y.has(e.queryHash)){try{c.remove(e);n.applied+=1}catch(u){n.skipped.push({id:e.queryHash,reason:String(u)})}}}const i=t.getMutationCache().getAll().length;if(i>0){t.getMutationCache().clear();n.warnings.push(`mutation cache cleared (${i} mutation(s))`)}const h=o.excludedWarning("quer(y/ies)");if(h)n.warnings.push(h);return n},async previewItems(s,a){const r=s?.queries??[];const o=a===void 0;const n=o?captureQueries(t).queries:a?.queries??[];const c=new Map(n.map(e=>[e.queryHash,e]));const y=new Map(r.map(e=>[e.queryHash,e]));const i=[];const h=[];for(const e of r){const u=queryLabel(e.queryKey,e.queryHash);if((0,_dehydrate.isWireDataMarker)(e.state.data)){i.push({key:e.queryHash,label:u,verdict:"wont-apply",reason:"data stayed on the device when this was captured (older Buoy) \u2014 re-capture this restore point"});continue}const d=c.get(e.queryHash);i.push((0,_sharedUi.classifyPreviewItem)({key:e.queryHash,label:u,oldValue:d?comparableQuery(d):void 0,newValue:comparableQuery(e),inOld:d!==void 0,inNew:true},{tooLargeReason:"query data too large to render a diff \u2014 restore still applies it"}))}for(const e of n){if(!y.has(e.queryHash)){i.push({key:e.queryHash,label:queryLabel(e.queryKey,e.queryHash),verdict:"removed",oldValue:comparableQuery(e)})}}if(o){const e=t.getMutationCache().getAll().length;if(e>0){h.push(`${e} in-memory mutation record(s) will be cleared`)}}return{items:i,notes:h}}}}function registerQuerySnapshotProvider(t){return(0,_sharedUi.registerStateSnapshotProvider)(createQuerySnapshotProvider(t))}
|
|
@@ -1,34 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useReactQuerySyncAdapter = useReactQuerySyncAdapter;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _reactQuery = require("@tanstack/react-query");
|
|
9
|
-
var _reactQuerySyncAdapter = require("./reactQuerySyncAdapter");
|
|
10
|
-
var _snapshotProvider = require("./snapshotProvider");
|
|
11
|
-
/**
|
|
12
|
-
* Context-based variant of createReactQuerySyncAdapter for zero-config
|
|
13
|
-
* wiring (FloatingDevTools' auto external sync): reads the QueryClient from
|
|
14
|
-
* the surrounding QueryClientProvider. Returns null when rendered outside a
|
|
15
|
-
* provider so callers can skip registering the query tool.
|
|
16
|
-
*/
|
|
17
|
-
function useReactQuerySyncAdapter() {
|
|
18
|
-
let queryClient;
|
|
19
|
-
try {
|
|
20
|
-
// Just a context read — throws only when there is no provider above us,
|
|
21
|
-
// which never changes for a mounted tree, so hook order stays stable.
|
|
22
|
-
queryClient = (0, _reactQuery.useQueryClient)();
|
|
23
|
-
} catch {
|
|
24
|
-
queryClient = null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Register the Time Machine snapshot provider for this client — this hook
|
|
28
|
-
// is the one app-lifetime spot that actually holds the QueryClient.
|
|
29
|
-
(0, _react.useEffect)(() => {
|
|
30
|
-
if (!queryClient) return;
|
|
31
|
-
return (0, _snapshotProvider.registerQuerySnapshotProvider)(queryClient);
|
|
32
|
-
}, [queryClient]);
|
|
33
|
-
return (0, _react.useMemo)(() => queryClient ? (0, _reactQuerySyncAdapter.createReactQuerySyncAdapter)(queryClient) : null, [queryClient]);
|
|
34
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.useReactQuerySyncAdapter=useReactQuerySyncAdapter;var _react=require("react");var _reactQuery=require("@tanstack/react-query");var _reactQuerySyncAdapter=require("./reactQuerySyncAdapter");var _snapshotProvider=require("./snapshotProvider");function useReactQuerySyncAdapter(){let e;try{e=(0,_reactQuery.useQueryClient)()}catch{e=null}(0,_react.useEffect)(()=>{if(!e)return;return(0,_snapshotProvider.registerQuerySnapshotProvider)(e)},[e]);return(0,_react.useMemo)(()=>e?(0,_reactQuerySyncAdapter.createReactQuerySyncAdapter)(e):null,[e])}
|
|
@@ -1,14 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isPlainObject = isPlainObject;
|
|
7
|
-
// Shared type definitions for the dev tools
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Type guard that narrows a value to a plain object (excluding arrays, Dates, Maps, etc.).
|
|
11
|
-
*/
|
|
12
|
-
function isPlainObject(value) {
|
|
13
|
-
return value !== null && value !== undefined && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof Error) && !(value instanceof Map) && !(value instanceof Set) && !(value instanceof RegExp) && typeof value !== "function";
|
|
14
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isPlainObject=isPlainObject;function isPlainObject(t){return t!==null&&t!==void 0&&typeof t==="object"&&!Array.isArray(t)&&!(t instanceof Date)&&!(t instanceof Error)&&!(t instanceof Map)&&!(t instanceof Set)&&!(t instanceof RegExp)&&typeof t!=="function"}
|
|
@@ -1,23 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = deleteItem;
|
|
7
|
-
var _deleteNestedDataByPath = require("../deleteNestedDataByPath");
|
|
8
|
-
function deleteItem({
|
|
9
|
-
activeQuery,
|
|
10
|
-
dataPath,
|
|
11
|
-
queryClient
|
|
12
|
-
}) {
|
|
13
|
-
if (!dataPath) {
|
|
14
|
-
// Early return if path is missing
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const oldData = activeQuery.state.data;
|
|
18
|
-
const newData = (0, _deleteNestedDataByPath.deleteNestedDataByPath)(oldData, dataPath);
|
|
19
|
-
|
|
20
|
-
// Force a new object reference to ensure React detects the change
|
|
21
|
-
const forceNewReference = JSON.parse(JSON.stringify(newData));
|
|
22
|
-
queryClient.setQueryData(activeQuery.queryKey, forceNewReference);
|
|
23
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=deleteItem;var _deleteNestedDataByPath=require("../deleteNestedDataByPath");function deleteItem({activeQuery:e,dataPath:t,queryClient:a}){if(!t){return}const r=e.state.data;const s=(0,_deleteNestedDataByPath.deleteNestedDataByPath)(r,t);const d=JSON.parse(JSON.stringify(s));a.setQueryData(e.queryKey,d)}
|
|
@@ -1,40 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.emitDevToolsEvent = emitDevToolsEvent;
|
|
7
|
-
const DEV_TOOLS_EVENT = "@tanstack/query-devtools-event";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Announce a devtool action as the same DOM CustomEvent the official TanStack
|
|
11
|
-
* devtools panel emits. On the device this is a no-op (React Native has no
|
|
12
|
-
* CustomEvent), so actions stay purely local. In Buoy Desktop these components
|
|
13
|
-
* render against a mirror QueryClient hydrated from the device, and the
|
|
14
|
-
* dashboard listens for this event to forward the action over the sync
|
|
15
|
-
* protocol — without it, actions only touch the mirror and are wiped by the
|
|
16
|
-
* next device snapshot.
|
|
17
|
-
*
|
|
18
|
-
* Call BEFORE mutating the local cache: the desktop handler resolves the
|
|
19
|
-
* query by hash, so for REMOVE the query must still exist in the mirror.
|
|
20
|
-
*/
|
|
21
|
-
function emitDevToolsEvent(type, queryHash) {
|
|
22
|
-
try {
|
|
23
|
-
// globalThis === window in browsers; React Native lacks CustomEvent, so
|
|
24
|
-
// this bails out there. No DOM lib in this package's tsconfig — cast.
|
|
25
|
-
const g = globalThis;
|
|
26
|
-
if (typeof g.dispatchEvent !== "function" || typeof g.CustomEvent !== "function") {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
g.dispatchEvent(new g.CustomEvent(DEV_TOOLS_EVENT, {
|
|
30
|
-
detail: {
|
|
31
|
-
type,
|
|
32
|
-
queryHash
|
|
33
|
-
},
|
|
34
|
-
bubbles: true,
|
|
35
|
-
cancelable: true
|
|
36
|
-
}));
|
|
37
|
-
} catch {
|
|
38
|
-
// Never let event plumbing break the action itself.
|
|
39
|
-
}
|
|
40
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.emitDevToolsEvent=emitDevToolsEvent;const DEV_TOOLS_EVENT="@tanstack/query-devtools-event";function emitDevToolsEvent(e,n){try{const t=globalThis;if(typeof t.dispatchEvent!=="function"||typeof t.CustomEvent!=="function"){return}t.dispatchEvent(new t.CustomEvent(DEV_TOOLS_EVENT,{detail:{type:e,queryHash:n},bubbles:true,cancelable:true}))}catch{}}
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = invalidate;
|
|
7
|
-
var _emitDevToolsEvent = require("./emitDevToolsEvent");
|
|
8
|
-
function invalidate({
|
|
9
|
-
query,
|
|
10
|
-
queryClient
|
|
11
|
-
}) {
|
|
12
|
-
(0, _emitDevToolsEvent.emitDevToolsEvent)("INVALIDATE", query.queryHash);
|
|
13
|
-
// This matches the ACTION-INVALIDATE case from the external sync system
|
|
14
|
-
queryClient.invalidateQueries(query);
|
|
15
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=invalidate;var _emitDevToolsEvent=require("./emitDevToolsEvent");function invalidate({query:e,queryClient:t}){(0,_emitDevToolsEvent.emitDevToolsEvent)("INVALIDATE",e.queryHash);t.invalidateQueries(e)}
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = refetch;
|
|
7
|
-
var _emitDevToolsEvent = require("./emitDevToolsEvent");
|
|
8
|
-
function refetch({
|
|
9
|
-
query
|
|
10
|
-
}) {
|
|
11
|
-
(0, _emitDevToolsEvent.emitDevToolsEvent)("REFETCH", query.queryHash);
|
|
12
|
-
// This matches the ACTION-REFETCH case from the external sync system
|
|
13
|
-
const promise = query.fetch();
|
|
14
|
-
promise.catch(() => {
|
|
15
|
-
// Silently handle fetch errors
|
|
16
|
-
});
|
|
17
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=refetch;var _emitDevToolsEvent=require("./emitDevToolsEvent");function refetch({query:e}){(0,_emitDevToolsEvent.emitDevToolsEvent)("REFETCH",e.queryHash);const t=e.fetch();t.catch(()=>{})}
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = remove;
|
|
7
|
-
var _emitDevToolsEvent = require("./emitDevToolsEvent");
|
|
8
|
-
function remove({
|
|
9
|
-
query,
|
|
10
|
-
queryClient
|
|
11
|
-
}) {
|
|
12
|
-
// Emit first — the desktop bridge still needs to find this hash in the cache.
|
|
13
|
-
(0, _emitDevToolsEvent.emitDevToolsEvent)("REMOVE", query.queryHash);
|
|
14
|
-
queryClient.removeQueries(query);
|
|
15
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=remove;var _emitDevToolsEvent=require("./emitDevToolsEvent");function remove({query:e,queryClient:t}){(0,_emitDevToolsEvent.emitDevToolsEvent)("REMOVE",e.queryHash);t.removeQueries(e)}
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = reset;
|
|
7
|
-
var _emitDevToolsEvent = require("./emitDevToolsEvent");
|
|
8
|
-
function reset({
|
|
9
|
-
query,
|
|
10
|
-
queryClient
|
|
11
|
-
}) {
|
|
12
|
-
(0, _emitDevToolsEvent.emitDevToolsEvent)("RESET", query.queryHash);
|
|
13
|
-
queryClient.resetQueries({
|
|
14
|
-
queryKey: query.queryKey,
|
|
15
|
-
exact: true
|
|
16
|
-
});
|
|
17
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=reset;var _emitDevToolsEvent=require("./emitDevToolsEvent");function reset({query:e,queryClient:t}){(0,_emitDevToolsEvent.emitDevToolsEvent)("RESET",e.queryHash);t.resetQueries({queryKey:e.queryKey,exact:true})}
|
|
@@ -1,33 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = triggerError;
|
|
7
|
-
var _emitDevToolsEvent = require("./emitDevToolsEvent");
|
|
8
|
-
function triggerError({
|
|
9
|
-
query,
|
|
10
|
-
queryClient
|
|
11
|
-
}) {
|
|
12
|
-
if (query.state.status !== "error") {
|
|
13
|
-
(0, _emitDevToolsEvent.emitDevToolsEvent)("TRIGGER_ERROR", query.queryHash);
|
|
14
|
-
// --ACTION-TRIGGER-ERROR logic--
|
|
15
|
-
// This matches the ACTION-TRIGGER-ERROR case from the external sync system
|
|
16
|
-
const error = new Error("Unknown error from devtools");
|
|
17
|
-
const __previousQueryOptions = query.options;
|
|
18
|
-
query.setState({
|
|
19
|
-
status: "error",
|
|
20
|
-
error,
|
|
21
|
-
fetchMeta: {
|
|
22
|
-
...query.state.fetchMeta,
|
|
23
|
-
// @ts-expect-error This does exist
|
|
24
|
-
__previousQueryOptions
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
} else {
|
|
28
|
-
(0, _emitDevToolsEvent.emitDevToolsEvent)("RESTORE_ERROR", query.queryHash);
|
|
29
|
-
// --ACTION-RESTORE-ERROR logic--
|
|
30
|
-
// This matches the ACTION-RESTORE-ERROR case from the external sync system
|
|
31
|
-
queryClient.resetQueries(query);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=triggerError;var _emitDevToolsEvent=require("./emitDevToolsEvent");function triggerError({query:e,queryClient:t}){if(e.state.status!=="error"){(0,_emitDevToolsEvent.emitDevToolsEvent)("TRIGGER_ERROR",e.queryHash);const r=new Error("Unknown error from devtools");const o=e.options;e.setState({status:"error",error:r,fetchMeta:{...e.state.fetchMeta,__previousQueryOptions:o}})}else{(0,_emitDevToolsEvent.emitDevToolsEvent)("RESTORE_ERROR",e.queryHash);t.resetQueries(e)}}
|
|
@@ -1,54 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = triggerLoading;
|
|
7
|
-
var _emitDevToolsEvent = require("./emitDevToolsEvent");
|
|
8
|
-
function triggerLoading({
|
|
9
|
-
query
|
|
10
|
-
}) {
|
|
11
|
-
if (query.state.data === undefined) {
|
|
12
|
-
(0, _emitDevToolsEvent.emitDevToolsEvent)("RESTORE_LOADING", query.queryHash);
|
|
13
|
-
// --ACTION-RESTORE-LOADING logic--
|
|
14
|
-
// This matches the ACTION-RESTORE-LOADING case from the external sync system
|
|
15
|
-
const previousState = query.state;
|
|
16
|
-
const previousOptions = query.state.fetchMeta ? query.state.fetchMeta.__previousQueryOptions : null;
|
|
17
|
-
query.cancel({
|
|
18
|
-
silent: true
|
|
19
|
-
});
|
|
20
|
-
query.setState({
|
|
21
|
-
...previousState,
|
|
22
|
-
fetchStatus: "idle",
|
|
23
|
-
fetchMeta: null
|
|
24
|
-
});
|
|
25
|
-
if (previousOptions) {
|
|
26
|
-
query.fetch(previousOptions);
|
|
27
|
-
}
|
|
28
|
-
} else {
|
|
29
|
-
(0, _emitDevToolsEvent.emitDevToolsEvent)("TRIGGER_LOADING", query.queryHash);
|
|
30
|
-
// --ACTION-TRIGGER-LOADING logic--
|
|
31
|
-
// This matches the ACTION-TRIGGER-LOADING case from the external sync system
|
|
32
|
-
const __previousQueryOptions = query.options;
|
|
33
|
-
|
|
34
|
-
// Trigger a fetch in order to trigger suspense as well.
|
|
35
|
-
query.fetch({
|
|
36
|
-
...__previousQueryOptions,
|
|
37
|
-
queryFn: () => {
|
|
38
|
-
return new Promise(() => {
|
|
39
|
-
// Never resolve - simulates perpetual loading
|
|
40
|
-
});
|
|
41
|
-
},
|
|
42
|
-
gcTime: -1
|
|
43
|
-
});
|
|
44
|
-
query.setState({
|
|
45
|
-
data: undefined,
|
|
46
|
-
status: "pending",
|
|
47
|
-
fetchMeta: {
|
|
48
|
-
...query.state.fetchMeta,
|
|
49
|
-
// @ts-expect-error This does exist
|
|
50
|
-
__previousQueryOptions
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=triggerLoading;var _emitDevToolsEvent=require("./emitDevToolsEvent");function triggerLoading({query:t}){if(t.state.data===void 0){(0,_emitDevToolsEvent.emitDevToolsEvent)("RESTORE_LOADING",t.queryHash);const e=t.state;const s=t.state.fetchMeta?t.state.fetchMeta.__previousQueryOptions:null;t.cancel({silent:true});t.setState({...e,fetchStatus:"idle",fetchMeta:null});if(s){t.fetch(s)}}else{(0,_emitDevToolsEvent.emitDevToolsEvent)("TRIGGER_LOADING",t.queryHash);const e=t.options;t.fetch({...e,queryFn:()=>{return new Promise(()=>{})},gcTime:-1});t.setState({data:void 0,status:"pending",fetchMeta:{...t.state.fetchMeta,__previousQueryOptions:e}})}}
|
|
@@ -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,16 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getQueryStatusColor = getQueryStatusColor;
|
|
7
|
-
/**
|
|
8
|
-
* Maps a query’s runtime state to one of the predefined status color tokens used in the UI.
|
|
9
|
-
*/
|
|
10
|
-
function getQueryStatusColor({
|
|
11
|
-
queryState,
|
|
12
|
-
observerCount,
|
|
13
|
-
isStale
|
|
14
|
-
}) {
|
|
15
|
-
return queryState.fetchStatus === "fetching" ? "blue" : queryState.status === "error" ? "red" : !observerCount ? "gray" : queryState.fetchStatus === "paused" ? "purple" : isStale ? "yellow" : "green";
|
|
16
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getQueryStatusColor=getQueryStatusColor;function getQueryStatusColor({queryState:e,observerCount:t,isStale:r}){return e.fetchStatus==="fetching"?"blue":e.status==="error"?"red":!t?"gray":e.fetchStatus==="paused"?"purple":r?"yellow":"green"}
|