@qiaopeng/tanstack-query-plus 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/dist/PersistQueryClientProvider.d.ts +22 -0
  2. package/dist/PersistQueryClientProvider.d.ts.map +1 -0
  3. package/dist/PersistQueryClientProvider.js +47 -0
  4. package/dist/components/LoadingFallback.d.ts +16 -0
  5. package/dist/components/LoadingFallback.d.ts.map +1 -0
  6. package/dist/components/LoadingFallback.js +27 -0
  7. package/dist/components/QueryErrorBoundary.d.ts +12 -0
  8. package/dist/components/QueryErrorBoundary.d.ts.map +1 -0
  9. package/dist/components/QueryErrorBoundary.js +9 -0
  10. package/dist/components/SuspenseWrapper.d.ts +14 -0
  11. package/dist/components/SuspenseWrapper.d.ts.map +1 -0
  12. package/dist/components/SuspenseWrapper.js +9 -0
  13. package/dist/components/index.d.ts +4 -0
  14. package/dist/components/index.d.ts.map +1 -0
  15. package/dist/components/index.js +3 -0
  16. package/dist/components/internal/ErrorBoundary.d.ts +26 -0
  17. package/dist/components/internal/ErrorBoundary.d.ts.map +1 -0
  18. package/dist/components/internal/ErrorBoundary.js +28 -0
  19. package/dist/core/config.d.ts +36 -0
  20. package/dist/core/config.d.ts.map +1 -0
  21. package/dist/core/config.js +213 -0
  22. package/dist/core/devtools.d.ts +14 -0
  23. package/dist/core/devtools.d.ts.map +1 -0
  24. package/dist/core/devtools.js +16 -0
  25. package/dist/core/env.d.ts +3 -0
  26. package/dist/core/env.d.ts.map +1 -0
  27. package/dist/core/env.js +2 -0
  28. package/dist/core/focusManager.d.ts +33 -0
  29. package/dist/core/focusManager.d.ts.map +1 -0
  30. package/dist/core/focusManager.js +122 -0
  31. package/dist/core/index.d.ts +6 -0
  32. package/dist/core/index.d.ts.map +1 -0
  33. package/dist/core/index.js +5 -0
  34. package/dist/core/keys.d.ts +59 -0
  35. package/dist/core/keys.d.ts.map +1 -0
  36. package/dist/core/keys.js +107 -0
  37. package/dist/core/queryOptions.d.ts +30 -0
  38. package/dist/core/queryOptions.d.ts.map +1 -0
  39. package/dist/core/queryOptions.js +30 -0
  40. package/dist/features/index.d.ts +4 -0
  41. package/dist/features/index.d.ts.map +1 -0
  42. package/dist/features/index.js +3 -0
  43. package/dist/features/offline.d.ts +48 -0
  44. package/dist/features/offline.d.ts.map +1 -0
  45. package/dist/features/offline.js +269 -0
  46. package/dist/features/persistence.d.ts +36 -0
  47. package/dist/features/persistence.d.ts.map +1 -0
  48. package/dist/features/persistence.js +175 -0
  49. package/dist/hooks/batchQueries.d.ts +128 -0
  50. package/dist/hooks/batchQueries.d.ts.map +1 -0
  51. package/dist/hooks/batchQueries.js +301 -0
  52. package/dist/hooks/index.d.ts +8 -0
  53. package/dist/hooks/index.d.ts.map +1 -0
  54. package/dist/hooks/index.js +7 -0
  55. package/dist/hooks/useFocusManager.d.ts +41 -0
  56. package/dist/hooks/useFocusManager.d.ts.map +1 -0
  57. package/dist/hooks/useFocusManager.js +109 -0
  58. package/dist/hooks/useInfiniteQuery.d.ts +58 -0
  59. package/dist/hooks/useInfiniteQuery.d.ts.map +1 -0
  60. package/dist/hooks/useInfiniteQuery.js +61 -0
  61. package/dist/hooks/useMutation.d.ts +34 -0
  62. package/dist/hooks/useMutation.d.ts.map +1 -0
  63. package/dist/hooks/useMutation.js +176 -0
  64. package/dist/hooks/usePrefetch.d.ts +54 -0
  65. package/dist/hooks/usePrefetch.d.ts.map +1 -0
  66. package/dist/hooks/usePrefetch.js +203 -0
  67. package/dist/hooks/useQuery.d.ts +5 -0
  68. package/dist/hooks/useQuery.d.ts.map +1 -0
  69. package/dist/hooks/useQuery.js +5 -0
  70. package/dist/hooks/useSuspenseQuery.d.ts +11 -0
  71. package/dist/hooks/useSuspenseQuery.d.ts.map +1 -0
  72. package/dist/hooks/useSuspenseQuery.js +19 -0
  73. package/dist/index.d.ts +8 -0
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/index.js +7 -0
  76. package/dist/types/base.d.ts +54 -0
  77. package/dist/types/base.d.ts.map +1 -0
  78. package/dist/types/base.js +26 -0
  79. package/dist/types/index.d.ts +23 -0
  80. package/dist/types/index.d.ts.map +1 -0
  81. package/dist/types/index.js +7 -0
  82. package/dist/types/infinite.d.ts +39 -0
  83. package/dist/types/infinite.d.ts.map +1 -0
  84. package/dist/types/infinite.js +1 -0
  85. package/dist/types/offline.d.ts +97 -0
  86. package/dist/types/offline.d.ts.map +1 -0
  87. package/dist/types/offline.js +8 -0
  88. package/dist/types/optimistic.d.ts +126 -0
  89. package/dist/types/optimistic.d.ts.map +1 -0
  90. package/dist/types/optimistic.js +7 -0
  91. package/dist/types/persistence.d.ts +9 -0
  92. package/dist/types/persistence.d.ts.map +1 -0
  93. package/dist/types/persistence.js +1 -0
  94. package/dist/types/selectors.d.ts +11 -0
  95. package/dist/types/selectors.d.ts.map +1 -0
  96. package/dist/types/selectors.js +1 -0
  97. package/dist/types/suspense.d.ts +67 -0
  98. package/dist/types/suspense.d.ts.map +1 -0
  99. package/dist/types/suspense.js +1 -0
  100. package/dist/utils/fieldMapper.d.ts +9 -0
  101. package/dist/utils/fieldMapper.d.ts.map +1 -0
  102. package/dist/utils/fieldMapper.js +27 -0
  103. package/dist/utils/index.d.ts +9 -0
  104. package/dist/utils/index.d.ts.map +1 -0
  105. package/dist/utils/index.js +8 -0
  106. package/dist/utils/network.d.ts +9 -0
  107. package/dist/utils/network.d.ts.map +1 -0
  108. package/dist/utils/network.js +43 -0
  109. package/dist/utils/optimisticUtils.d.ts +34 -0
  110. package/dist/utils/optimisticUtils.d.ts.map +1 -0
  111. package/dist/utils/optimisticUtils.js +76 -0
  112. package/dist/utils/placeholderData.d.ts +2 -0
  113. package/dist/utils/placeholderData.d.ts.map +1 -0
  114. package/dist/utils/placeholderData.js +1 -0
  115. package/dist/utils/prefetchManager.d.ts +111 -0
  116. package/dist/utils/prefetchManager.d.ts.map +1 -0
  117. package/dist/utils/prefetchManager.js +246 -0
  118. package/dist/utils/queryKey.d.ts +24 -0
  119. package/dist/utils/queryKey.d.ts.map +1 -0
  120. package/dist/utils/queryKey.js +77 -0
  121. package/dist/utils/selectors.d.ts +30 -0
  122. package/dist/utils/selectors.d.ts.map +1 -0
  123. package/dist/utils/selectors.js +18 -0
  124. package/dist/utils/storage.d.ts +7 -0
  125. package/dist/utils/storage.d.ts.map +1 -0
  126. package/dist/utils/storage.js +84 -0
  127. package/package.json +70 -0
@@ -0,0 +1,22 @@
1
+ import type { QueryClient } from "@tanstack/react-query";
2
+ import type { ReactNode } from "react";
3
+ export interface PersistQueryClientProviderProps {
4
+ children: ReactNode;
5
+ client: QueryClient;
6
+ cacheKey?: string;
7
+ enablePersistence?: boolean;
8
+ enableOfflineSupport?: boolean;
9
+ onPersistError?: (error: Error) => void;
10
+ onPersistRestore?: () => void;
11
+ }
12
+ export declare function PersistQueryClientProvider({ children, client, cacheKey, enablePersistence, enableOfflineSupport, onPersistError: _onPersistError, onPersistRestore }: PersistQueryClientProviderProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare function usePersistenceStatus(): {
14
+ isOnline: boolean;
15
+ isOffline: boolean;
16
+ };
17
+ export declare function usePersistenceManager(): {
18
+ clearCache: (cacheKey?: string) => void;
19
+ getOnlineStatus: () => boolean;
20
+ };
21
+ export default PersistQueryClientProvider;
22
+ //# sourceMappingURL=PersistQueryClientProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PersistQueryClientProvider.d.ts","sourceRoot":"","sources":["../src/PersistQueryClientProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOvC,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACxC,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,wBAAgB,0BAA0B,CAAC,EACzC,QAAQ,EACR,MAAM,EACN,QAAiC,EACjC,iBAAwB,EACxB,oBAA2B,EAC3B,cAAc,EAAE,eAAe,EAC/B,gBAAgB,EACjB,EAAE,+BAA+B,2CA0BjC;AAED,wBAAgB,oBAAoB;;;EASnC;AAED,wBAAgB,qBAAqB;;;EAWpC;AAED,eAAe,0BAA0B,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { QueryClientProvider } from "@tanstack/react-query";
3
+ import { PersistQueryClientProvider as TanStackPersistProvider } from "@tanstack/react-query-persist-client";
4
+ import { useEffect, useState } from "react";
5
+ import { isOnline, setupOnlineManager, subscribeToOnlineStatus } from "./features/offline.js";
6
+ import { clearCache, createPersister } from "./features/persistence.js";
7
+ export function PersistQueryClientProvider({ children, client, cacheKey = "tanstack-query-cache", enablePersistence = true, enableOfflineSupport = true, onPersistError: _onPersistError, onPersistRestore }) {
8
+ useEffect(() => {
9
+ if (enableOfflineSupport) {
10
+ setupOnlineManager();
11
+ }
12
+ }, [enableOfflineSupport]);
13
+ if (enablePersistence) {
14
+ const persister = createPersister(cacheKey);
15
+ if (!persister) {
16
+ return _jsx(QueryClientProvider, { client: client, children: children });
17
+ }
18
+ return (_jsx(TanStackPersistProvider, { client: client, persistOptions: {
19
+ persister,
20
+ maxAge: 1000 * 60 * 60 * 24
21
+ }, onSuccess: onPersistRestore, children: children }));
22
+ }
23
+ return _jsx(QueryClientProvider, { client: client, children: children });
24
+ }
25
+ export function usePersistenceStatus() {
26
+ const [online, setOnline] = useState(isOnline());
27
+ useEffect(() => {
28
+ return subscribeToOnlineStatus(setOnline);
29
+ }, []);
30
+ return {
31
+ isOnline: online,
32
+ isOffline: !online
33
+ };
34
+ }
35
+ export function usePersistenceManager() {
36
+ const clearPersistenceCache = (cacheKey = "tanstack-query-cache") => {
37
+ clearCache(cacheKey);
38
+ };
39
+ const getOnlineStatus = () => {
40
+ return isOnline();
41
+ };
42
+ return {
43
+ clearCache: clearPersistenceCache,
44
+ getOnlineStatus
45
+ };
46
+ }
47
+ export default PersistQueryClientProvider;
@@ -0,0 +1,16 @@
1
+ export declare function DefaultLoadingFallback(): import("react/jsx-runtime").JSX.Element;
2
+ export declare function TextSkeletonFallback({ lines }: {
3
+ lines?: number;
4
+ }): import("react/jsx-runtime").JSX.Element;
5
+ export declare function CardSkeletonFallback(): import("react/jsx-runtime").JSX.Element;
6
+ export declare function ListSkeletonFallback({ items }: {
7
+ items?: number;
8
+ }): import("react/jsx-runtime").JSX.Element;
9
+ export declare function PageSkeletonFallback(): import("react/jsx-runtime").JSX.Element;
10
+ export declare function SmallLoadingIndicator({ size }: {
11
+ size?: "sm" | "md" | "lg";
12
+ }): import("react/jsx-runtime").JSX.Element;
13
+ export declare function FullScreenLoading({ message }: {
14
+ message?: string;
15
+ }): import("react/jsx-runtime").JSX.Element;
16
+ //# sourceMappingURL=LoadingFallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoadingFallback.d.ts","sourceRoot":"","sources":["../../src/components/LoadingFallback.tsx"],"names":[],"mappings":"AAAA,wBAAgB,sBAAsB,4CASrC;AACD,wBAAgB,oBAAoB,CAAC,EAAE,KAAS,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,2CAWrE;AACD,wBAAgB,oBAAoB,4CAWnC;AACD,wBAAgB,oBAAoB,CAAC,EAAE,KAAS,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,2CAcrE;AACD,wBAAgB,oBAAoB,4CAyBnC;AACD,wBAAgB,qBAAqB,CAAC,EAAE,IAAW,EAAE,EAAE;IAAE,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;CAAE,2CAOnF;AACD,wBAAgB,iBAAiB,CAAC,EAAE,OAAkB,EAAE,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,2CAS7E"}
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export function DefaultLoadingFallback() {
3
+ return (_jsx("div", { className: "flex items-center justify-center p-6", children: _jsxs("div", { className: "text-center", children: [_jsx("div", { className: "w-12 h-12 mx-auto mb-3 border-4 border-primary/20 border-t-primary rounded-full animate-spin" }), _jsx("p", { className: "text-sm text-muted-foreground", children: "\u52A0\u8F7D\u4E2D..." })] }) }));
4
+ }
5
+ export function TextSkeletonFallback({ lines = 3 }) {
6
+ return (_jsx("div", { className: "space-y-3 p-4", children: Array.from({ length: lines }).map((_, i) => (_jsxs("div", { className: "animate-pulse", children: [_jsx("div", { className: "h-4 bg-input rounded w-3/4 mb-2" }), _jsx("div", { className: "h-4 bg-input rounded w-1/2" })] }, i))) }));
7
+ }
8
+ export function CardSkeletonFallback() {
9
+ return (_jsxs("div", { className: "border border-border rounded-lg p-4 animate-pulse bg-card", children: [_jsx("div", { className: "h-6 bg-input rounded w-1/2 mb-4" }), _jsxs("div", { className: "space-y-2", children: [_jsx("div", { className: "h-4 bg-input rounded" }), _jsx("div", { className: "h-4 bg-input rounded w-5/6" }), _jsx("div", { className: "h-4 bg-input rounded w-4/6" })] })] }));
10
+ }
11
+ export function ListSkeletonFallback({ items = 3 }) {
12
+ return (_jsx("div", { className: "space-y-4 p-4", children: Array.from({ length: items }).map((_, i) => (_jsxs("div", { className: "flex items-center space-x-4 animate-pulse", children: [_jsx("div", { className: "w-12 h-12 bg-input rounded-full shrink-0" }), _jsxs("div", { className: "flex-1 space-y-2", children: [_jsx("div", { className: "h-4 bg-input rounded w-3/4" }), _jsx("div", { className: "h-3 bg-input rounded w-1/2" })] })] }, i))) }));
13
+ }
14
+ export function PageSkeletonFallback() {
15
+ return (_jsxs("div", { className: "w-full p-6 space-y-6", children: [_jsxs("div", { className: "animate-pulse", children: [_jsx("div", { className: "h-8 bg-input rounded w-1/3 mb-2" }), _jsx("div", { className: "h-4 bg-input rounded w-1/2" })] }), _jsxs("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-6", children: [_jsxs("div", { className: "md:col-span-2 space-y-4", children: [_jsx(CardSkeletonFallback, {}), _jsx(CardSkeletonFallback, {})] }), _jsx("div", { className: "space-y-4", children: _jsxs("div", { className: "border border-border rounded-lg p-4 animate-pulse bg-card", children: [_jsx("div", { className: "h-4 bg-input rounded w-2/3 mb-3" }), _jsxs("div", { className: "space-y-2", children: [_jsx("div", { className: "h-3 bg-input rounded" }), _jsx("div", { className: "h-3 bg-input rounded w-5/6" }), _jsx("div", { className: "h-3 bg-input rounded w-4/6" })] })] }) })] })] }));
16
+ }
17
+ export function SmallLoadingIndicator({ size = "md" }) {
18
+ const sizeClasses = {
19
+ sm: "w-4 h-4 border-2",
20
+ md: "w-6 h-6 border-2",
21
+ lg: "w-8 h-8 border-3"
22
+ };
23
+ return _jsx("div", { className: `${sizeClasses[size]} border-primary/20 border-t-primary rounded-full animate-spin` });
24
+ }
25
+ export function FullScreenLoading({ message = "加载中..." }) {
26
+ return (_jsx("div", { className: "fixed inset-0 bg-background/90 flex items-center justify-center z-50", children: _jsxs("div", { className: "text-center", children: [_jsx("div", { className: "w-16 h-16 mx-auto mb-4 border-4 border-primary/20 border-t-primary rounded-full animate-spin" }), _jsx("p", { className: "text-lg text-foreground", children: message })] }) }));
27
+ }
@@ -0,0 +1,12 @@
1
+ import type { ReactNode } from "react";
2
+ export interface QueryErrorBoundaryProps {
3
+ children: ReactNode;
4
+ fallback?: (error: Error, resetErrorBoundary: () => void) => ReactNode;
5
+ onError?: (error: Error, errorInfo: {
6
+ componentStack: string;
7
+ }) => void;
8
+ resetKeys?: Array<string | number>;
9
+ }
10
+ export declare function QueryErrorBoundary({ children, fallback, onError, resetKeys, ...props }: QueryErrorBoundaryProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function QueryErrorFallback(error: Error, resetErrorBoundary: () => void): import("react/jsx-runtime").JSX.Element;
12
+ //# sourceMappingURL=QueryErrorBoundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueryErrorBoundary.d.ts","sourceRoot":"","sources":["../../src/components/QueryErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,IAAI,KAAK,SAAS,CAAC;IACvE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACxE,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CACpC;AAED,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,uBAAuB,2CAU/G;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,IAAI,2CAwB9E"}
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { QueryErrorResetBoundary } from "@tanstack/react-query";
3
+ import { ErrorBoundary } from "./internal/ErrorBoundary.js";
4
+ export function QueryErrorBoundary({ children, fallback, onError, resetKeys, ...props }) {
5
+ return (_jsx(QueryErrorResetBoundary, { children: ({ reset }) => (_jsx(ErrorBoundary, { fallback: fallback || QueryErrorFallback, onError: onError, onReset: reset, resetKeys: resetKeys, ...props, children: children })) }));
6
+ }
7
+ export function QueryErrorFallback(error, resetErrorBoundary) {
8
+ return (_jsx("div", { className: "flex items-center justify-center p-6", children: _jsxs("div", { className: "text-center max-w-md", children: [_jsx("div", { className: "mb-4", children: _jsx("div", { className: "w-12 h-12 mx-auto mb-3 bg-orange-100 rounded-full flex items-center justify-center", children: _jsx("svg", { className: "w-6 h-6 text-orange-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }) }) }), _jsx("h3", { className: "text-lg font-semibold text-foreground mb-2", children: "\u67E5\u8BE2\u5931\u8D25" }), _jsx("p", { className: "text-sm text-muted-foreground mb-4", children: error.message || "数据加载失败,请稍后重试" }), _jsxs("div", { className: "space-x-2", children: [_jsx("button", { onClick: resetErrorBoundary, className: "px-4 py-2 bg-primary text-primary-foreground rounded-md", children: "\u91CD\u65B0\u52A0\u8F7D" }), _jsx("button", { onClick: () => window.location.reload(), className: "px-4 py-2 bg-muted text-foreground rounded-md", children: "\u5237\u65B0\u9875\u9762" })] })] }) }));
9
+ }
@@ -0,0 +1,14 @@
1
+ import type { ReactNode } from "react";
2
+ interface SuspenseWrapperProps {
3
+ children: ReactNode;
4
+ fallback?: ReactNode;
5
+ errorFallback?: (error: Error, resetErrorBoundary: () => void) => ReactNode;
6
+ onError?: (error: Error, errorInfo: {
7
+ componentStack: string;
8
+ }) => void;
9
+ resetKeys?: Array<string | number>;
10
+ }
11
+ export declare function SuspenseWrapper({ children, fallback, errorFallback, onError, resetKeys }: SuspenseWrapperProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function QuerySuspenseWrapper({ children, fallback, errorFallback, onError, resetKeys }: SuspenseWrapperProps): import("react/jsx-runtime").JSX.Element;
13
+ export type { SuspenseWrapperProps };
14
+ //# sourceMappingURL=SuspenseWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SuspenseWrapper.d.ts","sourceRoot":"","sources":["../../src/components/SuspenseWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,IAAI,KAAK,SAAS,CAAC;IAC5E,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACxE,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CACpC;AAED,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,QAAgC,EAAE,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,oBAAoB,2CAMtI;AAED,wBAAgB,oBAAoB,CAAC,EAAE,QAAQ,EAAE,QAAsC,EAAE,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,oBAAoB,2CAMjJ;AAED,YAAY,EAAE,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Suspense } from "react";
3
+ import { QueryErrorBoundary } from "./QueryErrorBoundary.js";
4
+ export function SuspenseWrapper({ children, fallback = _jsx("div", { children: "Loading..." }), errorFallback, onError, resetKeys }) {
5
+ return (_jsx(QueryErrorBoundary, { fallback: errorFallback, onError: onError, resetKeys: resetKeys, children: _jsx(Suspense, { fallback: fallback, children: children }) }));
6
+ }
7
+ export function QuerySuspenseWrapper({ children, fallback = _jsx("div", { children: "Loading query..." }), errorFallback, onError, resetKeys }) {
8
+ return (_jsx(SuspenseWrapper, { fallback: fallback, errorFallback: errorFallback, onError: onError, resetKeys: resetKeys, children: children }));
9
+ }
@@ -0,0 +1,4 @@
1
+ export { CardSkeletonFallback, DefaultLoadingFallback, FullScreenLoading, ListSkeletonFallback, PageSkeletonFallback, SmallLoadingIndicator, TextSkeletonFallback } from "./LoadingFallback.js";
2
+ export { QueryErrorBoundary, type QueryErrorBoundaryProps } from "./QueryErrorBoundary.js";
3
+ export { SuspenseWrapper } from "./SuspenseWrapper.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { CardSkeletonFallback, DefaultLoadingFallback, FullScreenLoading, ListSkeletonFallback, PageSkeletonFallback, SmallLoadingIndicator, TextSkeletonFallback } from "./LoadingFallback.js";
2
+ export { QueryErrorBoundary } from "./QueryErrorBoundary.js";
3
+ export { SuspenseWrapper } from "./SuspenseWrapper.js";
@@ -0,0 +1,26 @@
1
+ import type { ReactNode } from "react";
2
+ import { Component } from "react";
3
+ export interface ErrorBoundaryProps {
4
+ children: ReactNode;
5
+ fallback?: (error: Error, resetErrorBoundary: () => void) => ReactNode;
6
+ onError?: (error: Error, errorInfo: {
7
+ componentStack: string;
8
+ }) => void;
9
+ onReset?: () => void;
10
+ resetKeys?: Array<string | number>;
11
+ }
12
+ interface ErrorBoundaryState {
13
+ hasError: boolean;
14
+ error?: Error;
15
+ }
16
+ export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
17
+ constructor(props: ErrorBoundaryProps);
18
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState;
19
+ componentDidCatch(error: Error, errorInfo: {
20
+ componentStack: string;
21
+ }): void;
22
+ resetErrorBoundary: () => void;
23
+ render(): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
24
+ }
25
+ export {};
26
+ //# sourceMappingURL=ErrorBoundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../../src/components/internal/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,IAAI,KAAK,SAAS,CAAC;IACvE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACxE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CACpC;AAED,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,qBAAa,aAAc,SAAQ,SAAS,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;gBACtE,KAAK,EAAE,kBAAkB;IAIrC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,kBAAkB;IAGjE,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE;IAGrE,kBAAkB,aAGhB;IACF,MAAM;CAmBP"}
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Component } from "react";
3
+ export class ErrorBoundary extends Component {
4
+ constructor(props) {
5
+ super(props);
6
+ this.resetErrorBoundary = () => {
7
+ this.props.onReset?.();
8
+ this.setState({ hasError: false, error: undefined });
9
+ };
10
+ this.state = { hasError: false };
11
+ }
12
+ static getDerivedStateFromError(error) {
13
+ return { hasError: true, error };
14
+ }
15
+ componentDidCatch(error, errorInfo) {
16
+ this.props.onError?.(error, errorInfo);
17
+ }
18
+ render() {
19
+ const { hasError, error } = this.state;
20
+ const { children, fallback } = this.props;
21
+ if (hasError && error) {
22
+ if (fallback)
23
+ return fallback(error, this.resetErrorBoundary);
24
+ return (_jsx("div", { className: "flex items-center justify-center p-6", children: _jsxs("div", { className: "text-center max-w-md", children: [_jsx("h3", { className: "text-lg font-semibold text-foreground mb-2", children: "\u53D1\u751F\u9519\u8BEF" }), _jsx("p", { className: "text-sm text-muted-foreground mb-4", children: error.message || "请稍后重试" }), _jsx("button", { onClick: this.resetErrorBoundary, className: "px-4 py-2 bg-primary text-primary-foreground rounded-md", children: "\u91CD\u8BD5" })] }) }));
25
+ }
26
+ return children;
27
+ }
28
+ }
@@ -0,0 +1,36 @@
1
+ import type { DefaultOptions } from "@tanstack/react-query";
2
+ export declare const TIME_CONSTANTS: {
3
+ readonly THIRTY_SECONDS: number;
4
+ readonly ONE_MINUTE: number;
5
+ readonly FIVE_MINUTES: number;
6
+ readonly TEN_MINUTES: number;
7
+ readonly FIFTEEN_MINUTES: number;
8
+ readonly THIRTY_MINUTES: number;
9
+ readonly ONE_HOUR: number;
10
+ readonly ONE_DAY: number;
11
+ };
12
+ export declare const DEFAULT_STALE_TIME: number;
13
+ export declare const DEFAULT_GC_TIME: number;
14
+ export declare function defaultQueryRetryStrategy(failureCount: number, error: unknown): boolean;
15
+ export declare function defaultMutationRetryStrategy(failureCount: number, error: unknown): boolean;
16
+ export declare function exponentialBackoff(attemptIndex: number): number;
17
+ export declare const DEFAULT_QUERY_CONFIG: DefaultOptions["queries"];
18
+ export declare const DEFAULT_MUTATION_CONFIG: DefaultOptions["mutations"];
19
+ export declare const GLOBAL_QUERY_CONFIG: DefaultOptions;
20
+ export declare const SMART_RETRY_MUTATION_CONFIG: DefaultOptions["mutations"];
21
+ export declare const DEVELOPMENT_CONFIG: DefaultOptions;
22
+ export declare const PRODUCTION_CONFIG: DefaultOptions;
23
+ export declare const LONG_CACHE_CONFIG: DefaultOptions;
24
+ export declare const REALTIME_CONFIG: DefaultOptions;
25
+ export declare function getConfigByEnvironment(env: "development" | "production" | "test"): DefaultOptions;
26
+ export declare function createCustomConfig(overrides: Partial<DefaultOptions>): DefaultOptions;
27
+ export declare function validateGcTime(staleTime: number, gcTime: number): {
28
+ isValid: boolean;
29
+ warning?: string;
30
+ };
31
+ export declare function validateConfig(config: DefaultOptions): {
32
+ isValid: boolean;
33
+ warnings: string[];
34
+ };
35
+ export declare function ensureBestPractices(config: DefaultOptions): DefaultOptions;
36
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,eAAO,MAAM,cAAc;;;;;;;;;CASjB,CAAC;AAEX,eAAO,MAAM,kBAAkB,QAAgC,CAAC;AAChE,eAAO,MAAM,eAAe,QAA6B,CAAC;AAO1D,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAKvF;AAED,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAK1F;AAED,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,eAAO,MAAM,oBAAoB,EAAE,cAAc,CAAC,SAAS,CAQ1D,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAAC,WAAW,CAI/D,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,cAGjC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,cAAc,CAAC,WAAW,CAInE,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,cAYhC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,cAY/B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,cAa/B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,cAW7B,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,aAAa,GAAG,YAAY,GAAG,MAAM,GAAG,cAAc,CAwBjG;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAWrF;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAQxG;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CA2B/F;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAkC1E"}
@@ -0,0 +1,213 @@
1
+ import { isProd } from "./env.js";
2
+ export const TIME_CONSTANTS = {
3
+ THIRTY_SECONDS: 30 * 1000,
4
+ ONE_MINUTE: 60 * 1000,
5
+ FIVE_MINUTES: 5 * 60 * 1000,
6
+ TEN_MINUTES: 10 * 60 * 1000,
7
+ FIFTEEN_MINUTES: 15 * 60 * 1000,
8
+ THIRTY_MINUTES: 30 * 60 * 1000,
9
+ ONE_HOUR: 60 * 60 * 1000,
10
+ ONE_DAY: 24 * 60 * 60 * 1000
11
+ };
12
+ export const DEFAULT_STALE_TIME = TIME_CONSTANTS.THIRTY_SECONDS;
13
+ export const DEFAULT_GC_TIME = TIME_CONSTANTS.TEN_MINUTES;
14
+ export function defaultQueryRetryStrategy(failureCount, error) {
15
+ const httpError = error;
16
+ if (httpError?.status && httpError.status >= 400 && httpError.status < 500)
17
+ return false;
18
+ if (httpError?.status && httpError.status >= 500)
19
+ return failureCount < 3;
20
+ return failureCount < 3;
21
+ }
22
+ export function defaultMutationRetryStrategy(failureCount, error) {
23
+ const httpError = error;
24
+ if (httpError?.status && httpError.status >= 400 && httpError.status < 500)
25
+ return false;
26
+ if (httpError?.status && httpError.status >= 500)
27
+ return failureCount < 2;
28
+ return failureCount < 2;
29
+ }
30
+ export function exponentialBackoff(attemptIndex) {
31
+ return Math.min(1000 * 2 ** attemptIndex, 30000);
32
+ }
33
+ export const DEFAULT_QUERY_CONFIG = {
34
+ staleTime: DEFAULT_STALE_TIME,
35
+ gcTime: DEFAULT_GC_TIME,
36
+ retry: defaultQueryRetryStrategy,
37
+ retryDelay: exponentialBackoff,
38
+ refetchOnWindowFocus: true,
39
+ refetchOnReconnect: true,
40
+ refetchOnMount: true
41
+ };
42
+ export const DEFAULT_MUTATION_CONFIG = {
43
+ retry: 0,
44
+ retryDelay: exponentialBackoff,
45
+ gcTime: DEFAULT_GC_TIME
46
+ };
47
+ export const GLOBAL_QUERY_CONFIG = {
48
+ queries: DEFAULT_QUERY_CONFIG,
49
+ mutations: DEFAULT_MUTATION_CONFIG
50
+ };
51
+ export const SMART_RETRY_MUTATION_CONFIG = {
52
+ retry: defaultMutationRetryStrategy,
53
+ retryDelay: exponentialBackoff,
54
+ gcTime: DEFAULT_GC_TIME
55
+ };
56
+ export const DEVELOPMENT_CONFIG = {
57
+ queries: {
58
+ ...DEFAULT_QUERY_CONFIG,
59
+ staleTime: 0,
60
+ gcTime: TIME_CONSTANTS.TEN_MINUTES,
61
+ retry: 1,
62
+ refetchOnWindowFocus: true
63
+ },
64
+ mutations: {
65
+ ...DEFAULT_MUTATION_CONFIG,
66
+ retry: 0
67
+ }
68
+ };
69
+ export const PRODUCTION_CONFIG = {
70
+ queries: {
71
+ ...DEFAULT_QUERY_CONFIG,
72
+ staleTime: TIME_CONSTANTS.TEN_MINUTES,
73
+ gcTime: TIME_CONSTANTS.THIRTY_MINUTES,
74
+ retry: 3,
75
+ refetchOnWindowFocus: true
76
+ },
77
+ mutations: {
78
+ ...DEFAULT_MUTATION_CONFIG,
79
+ retry: 0
80
+ }
81
+ };
82
+ export const LONG_CACHE_CONFIG = {
83
+ queries: {
84
+ ...DEFAULT_QUERY_CONFIG,
85
+ staleTime: TIME_CONSTANTS.FIFTEEN_MINUTES,
86
+ gcTime: TIME_CONSTANTS.ONE_HOUR,
87
+ retry: 2,
88
+ refetchOnWindowFocus: true,
89
+ refetchOnReconnect: true
90
+ },
91
+ mutations: {
92
+ ...DEFAULT_MUTATION_CONFIG,
93
+ retry: 0
94
+ }
95
+ };
96
+ export const REALTIME_CONFIG = {
97
+ queries: {
98
+ ...DEFAULT_QUERY_CONFIG,
99
+ staleTime: 0,
100
+ gcTime: TIME_CONSTANTS.ONE_MINUTE * 2,
101
+ retry: 5,
102
+ refetchOnWindowFocus: true,
103
+ refetchOnReconnect: true,
104
+ refetchInterval: TIME_CONSTANTS.THIRTY_SECONDS
105
+ },
106
+ mutations: DEFAULT_MUTATION_CONFIG
107
+ };
108
+ export function getConfigByEnvironment(env) {
109
+ switch (env) {
110
+ case "development":
111
+ return DEVELOPMENT_CONFIG;
112
+ case "production":
113
+ return PRODUCTION_CONFIG;
114
+ case "test":
115
+ return {
116
+ queries: {
117
+ ...DEFAULT_QUERY_CONFIG,
118
+ retry: 0,
119
+ staleTime: 0,
120
+ refetchOnWindowFocus: false,
121
+ refetchOnReconnect: false,
122
+ refetchOnMount: true
123
+ },
124
+ mutations: {
125
+ ...DEFAULT_MUTATION_CONFIG,
126
+ retry: 0
127
+ }
128
+ };
129
+ default:
130
+ return GLOBAL_QUERY_CONFIG;
131
+ }
132
+ }
133
+ export function createCustomConfig(overrides) {
134
+ return {
135
+ queries: {
136
+ ...DEFAULT_QUERY_CONFIG,
137
+ ...overrides.queries
138
+ },
139
+ mutations: {
140
+ ...DEFAULT_MUTATION_CONFIG,
141
+ ...overrides.mutations
142
+ }
143
+ };
144
+ }
145
+ export function validateGcTime(staleTime, gcTime) {
146
+ if (gcTime <= staleTime) {
147
+ return {
148
+ isValid: false,
149
+ warning: `gcTime (${gcTime}ms) 必须大于 staleTime (${staleTime}ms)。当前 gcTime 过小,可能导致缓存数据过早被清理。`
150
+ };
151
+ }
152
+ return { isValid: true };
153
+ }
154
+ export function validateConfig(config) {
155
+ const warnings = [];
156
+ let isValid = true;
157
+ if (config.queries) {
158
+ const staleTime = typeof config.queries.staleTime === "number" ? config.queries.staleTime : DEFAULT_STALE_TIME;
159
+ const gcTime = typeof config.queries.gcTime === "number" ? config.queries.gcTime : DEFAULT_GC_TIME;
160
+ const gcTimeValidation = validateGcTime(staleTime, gcTime);
161
+ if (!gcTimeValidation.isValid && gcTimeValidation.warning) {
162
+ warnings.push(gcTimeValidation.warning);
163
+ isValid = false;
164
+ }
165
+ else if (gcTimeValidation.warning) {
166
+ warnings.push(gcTimeValidation.warning);
167
+ }
168
+ if ("cacheTime" in config.queries) {
169
+ warnings.push("检测到已废弃的 'cacheTime' 属性。在 React Query v5 中,请使用 'gcTime' 代替。");
170
+ isValid = false;
171
+ }
172
+ if (config.queries.refetchOnWindowFocus === false) {
173
+ warnings.push("建议启用 'refetchOnWindowFocus' 以提供更好的用户体验。当用户切换回应用时,数据会自动刷新。");
174
+ }
175
+ if (typeof config.queries.retryDelay === "number") {
176
+ warnings.push("建议使用指数退避策略作为重试延迟,而不是固定延迟。例如:(attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 30000)");
177
+ }
178
+ }
179
+ return { isValid, warnings };
180
+ }
181
+ export function ensureBestPractices(config) {
182
+ const result = { ...config };
183
+ if (result.queries) {
184
+ const queries = { ...result.queries };
185
+ if ("cacheTime" in queries) {
186
+ const cacheTime = queries.cacheTime;
187
+ if (typeof cacheTime === "number" && typeof queries.gcTime !== "number") {
188
+ queries.gcTime = cacheTime;
189
+ }
190
+ delete queries.cacheTime;
191
+ if (!isProd) {
192
+ console.warn("[TanStack Query Config] 已移除废弃的 'cacheTime' 属性,改用 'gcTime'.");
193
+ }
194
+ }
195
+ const staleTime = typeof queries.staleTime === "number" ? queries.staleTime : DEFAULT_STALE_TIME;
196
+ const gcTime = typeof queries.gcTime === "number" ? queries.gcTime : DEFAULT_GC_TIME;
197
+ const validation = validateGcTime(staleTime, gcTime);
198
+ if (!validation.isValid) {
199
+ queries.gcTime = staleTime + TIME_CONSTANTS.ONE_MINUTE;
200
+ if (!isProd) {
201
+ console.warn(`[TanStack Query Config] 自动调整 gcTime 从 ${gcTime}ms 到 ${queries.gcTime}ms,以确保大于 staleTime (${staleTime}ms)。`);
202
+ }
203
+ }
204
+ if (typeof queries.retryDelay === "number" || !queries.retryDelay) {
205
+ queries.retryDelay = exponentialBackoff;
206
+ }
207
+ if (queries.refetchOnWindowFocus === undefined) {
208
+ queries.refetchOnWindowFocus = true;
209
+ }
210
+ result.queries = queries;
211
+ }
212
+ return result;
213
+ }
@@ -0,0 +1,14 @@
1
+ export { ReactQueryDevtools } from "@tanstack/react-query-devtools";
2
+ export interface DevToolsConfig {
3
+ initialIsOpen?: boolean;
4
+ position?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
5
+ enabled?: boolean;
6
+ buttonPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
7
+ panelProps?: React.ComponentProps<"div">;
8
+ closeButtonProps?: React.ComponentProps<"button">;
9
+ toggleButtonProps?: React.ComponentProps<"button">;
10
+ }
11
+ export declare const defaultDevToolsConfig: DevToolsConfig;
12
+ export declare function createDevToolsConfig(overrides?: Partial<DevToolsConfig>): DevToolsConfig;
13
+ export declare function isDevToolsEnabled(): boolean;
14
+ //# sourceMappingURL=devtools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devtools.d.ts","sourceRoot":"","sources":["../../src/core/devtools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,MAAM,WAAW,cAAc;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,cAAc,CAAC;IACrE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,cAAc,CAAC;IAC3E,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACzC,gBAAgB,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAClD,iBAAiB,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;CACpD;AAED,eAAO,MAAM,qBAAqB,EAAE,cAInC,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAKxF;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C"}
@@ -0,0 +1,16 @@
1
+ import { isProd } from "./env.js";
2
+ export { ReactQueryDevtools } from "@tanstack/react-query-devtools";
3
+ export const defaultDevToolsConfig = {
4
+ initialIsOpen: false,
5
+ position: "bottom-right",
6
+ enabled: !isProd
7
+ };
8
+ export function createDevToolsConfig(overrides) {
9
+ return {
10
+ ...defaultDevToolsConfig,
11
+ ...overrides
12
+ };
13
+ }
14
+ export function isDevToolsEnabled() {
15
+ return !isProd;
16
+ }
@@ -0,0 +1,3 @@
1
+ export declare const isProd: boolean;
2
+ export declare const isDev: boolean;
3
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/core/env.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,SAAwC,CAAC;AAC5D,eAAO,MAAM,KAAK,SAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const isProd = process.env.NODE_ENV === "production";
2
+ export const isDev = !isProd;
@@ -0,0 +1,33 @@
1
+ import type { QueryKey } from "@tanstack/react-query";
2
+ import { focusManager } from "@tanstack/react-query";
3
+ export { focusManager };
4
+ export interface FocusManagerConfig {
5
+ enabled?: boolean;
6
+ customEventListener?: (handleFocus: () => void) => () => void;
7
+ refetchOnWindowFocus?: boolean;
8
+ }
9
+ export declare function setupFocusManager(config?: FocusManagerConfig): void;
10
+ export declare function pauseFocusManager(): void;
11
+ export declare function resumeFocusManager(): void;
12
+ export declare class SmartFocusManager {
13
+ private pauseCount;
14
+ private originalFocusState;
15
+ private refetchHistory;
16
+ private serializeKey;
17
+ pause(): void;
18
+ resume(): void;
19
+ reset(): void;
20
+ destroy(): void;
21
+ shouldRefetch(queryKey: QueryKey, minInterval?: number): boolean;
22
+ clearHistory(): void;
23
+ clearHistoryByKey(queryKey: QueryKey): void;
24
+ getLastRefetchTime(queryKey: QueryKey): number | undefined;
25
+ getStats(): {
26
+ isPaused: boolean;
27
+ pauseCount: number;
28
+ isFocused: boolean;
29
+ };
30
+ }
31
+ export declare function getSmartFocusManager(): SmartFocusManager;
32
+ export declare function resetSmartFocusManager(): void;
33
+ //# sourceMappingURL=focusManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focusManager.d.ts","sourceRoot":"","sources":["../../src/core/focusManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mBAAmB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAC9D,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,kBAAuB,QA0BhE;AAED,wBAAgB,iBAAiB,SAEhC;AAED,wBAAgB,kBAAkB,SAGjC;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,kBAAkB,CAAsB;IAChD,OAAO,CAAC,cAAc,CAAkC;IACxD,OAAO,CAAC,YAAY;IAiBpB,KAAK,IAAI,IAAI;IAOb,MAAM,IAAI,IAAI;IAQd,KAAK,IAAI,IAAI;IAOb,OAAO,IAAI,IAAI;IAIf,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,GAAE,MAAa,GAAG,OAAO;IAUtE,YAAY,IAAI,IAAI;IAGpB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAI3C,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS;IAI1D,QAAQ,IAAI;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE;CAG1E;AAGD,wBAAgB,oBAAoB,IAAI,iBAAiB,CAKxD;AACD,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}