@ahoo-wang/fetcher-react 3.8.5 → 3.8.8
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/dist/index.es.js +13 -13
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -18,7 +18,7 @@ function k(r, e) {
|
|
|
18
18
|
throw new Error("useDebouncedCallback: at least one of leading or trailing must be true");
|
|
19
19
|
const n = I(void 0), l = I(null), u = I(null), c = $(r), f = $(e);
|
|
20
20
|
let o;
|
|
21
|
-
t[0] === Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ s(() => {
|
|
21
|
+
t[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ s(() => {
|
|
22
22
|
n.current !== void 0 && (clearTimeout(n.current), n.current = void 0);
|
|
23
23
|
}, "t0"), t[0] = o) : o = t[0];
|
|
24
24
|
const y = o;
|
|
@@ -62,15 +62,15 @@ function k(r, e) {
|
|
|
62
62
|
}, "t4"), t[8] = m, t[9] = f, t[10] = g, t[11] = i, t[12] = E) : E = t[12];
|
|
63
63
|
const b = E;
|
|
64
64
|
let x;
|
|
65
|
-
t[13] === Symbol.for("react.memo_cache_sentinel") ? (x = /* @__PURE__ */ s(() => {
|
|
65
|
+
t[13] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (x = /* @__PURE__ */ s(() => {
|
|
66
66
|
y(), l.current = null;
|
|
67
67
|
}, "t5"), t[13] = x) : x = t[13];
|
|
68
68
|
const F = x;
|
|
69
69
|
let v;
|
|
70
|
-
t[14] === Symbol.for("react.memo_cache_sentinel") ? (v = /* @__PURE__ */ s(() => n.current !== void 0, "t6"), t[14] = v) : v = t[14];
|
|
70
|
+
t[14] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (v = /* @__PURE__ */ s(() => n.current !== void 0, "t6"), t[14] = v) : v = t[14];
|
|
71
71
|
const w = v;
|
|
72
72
|
let R, L;
|
|
73
|
-
t[15] === Symbol.for("react.memo_cache_sentinel") ? (R = /* @__PURE__ */ s(() => () => {
|
|
73
|
+
t[15] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (R = /* @__PURE__ */ s(() => () => {
|
|
74
74
|
F();
|
|
75
75
|
}, "t7"), L = [F], t[15] = R, t[16] = L) : (R = t[15], L = t[16]), C(R, L);
|
|
76
76
|
let O;
|
|
@@ -84,10 +84,10 @@ s(k, "useDebouncedCallback");
|
|
|
84
84
|
function j() {
|
|
85
85
|
const r = S(3), e = I(!1);
|
|
86
86
|
let t;
|
|
87
|
-
r[0] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ s(() => e.current, "t0"), r[0] = t) : t = r[0];
|
|
87
|
+
r[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ s(() => e.current, "t0"), r[0] = t) : t = r[0];
|
|
88
88
|
const n = t;
|
|
89
89
|
let l, u;
|
|
90
|
-
return r[1] === Symbol.for("react.memo_cache_sentinel") ? (l = /* @__PURE__ */ s(() => (e.current = !0, () => {
|
|
90
|
+
return r[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (l = /* @__PURE__ */ s(() => (e.current = !0, () => {
|
|
91
91
|
e.current = !1;
|
|
92
92
|
}), "t1"), u = [], r[1] = l, r[2] = u) : (l = r[1], u = r[2]), C(l, u), n;
|
|
93
93
|
}
|
|
@@ -147,26 +147,26 @@ s(fe, "usePromiseState");
|
|
|
147
147
|
function de() {
|
|
148
148
|
const r = S(6), e = I(0);
|
|
149
149
|
let t;
|
|
150
|
-
r[0] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ s(() => e.current = e.current + 1, "t0"), r[0] = t) : t = r[0];
|
|
150
|
+
r[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ s(() => e.current = e.current + 1, "t0"), r[0] = t) : t = r[0];
|
|
151
151
|
const n = t;
|
|
152
152
|
let l;
|
|
153
|
-
r[1] === Symbol.for("react.memo_cache_sentinel") ? (l = /* @__PURE__ */ s(() => e.current, "t1"), r[1] = l) : l = r[1];
|
|
153
|
+
r[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (l = /* @__PURE__ */ s(() => e.current, "t1"), r[1] = l) : l = r[1];
|
|
154
154
|
const u = l;
|
|
155
155
|
let c;
|
|
156
|
-
r[2] === Symbol.for("react.memo_cache_sentinel") ? (c = /* @__PURE__ */ s((m) => m === e.current, "t2"), r[2] = c) : c = r[2];
|
|
156
|
+
r[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (c = /* @__PURE__ */ s((m) => m === e.current, "t2"), r[2] = c) : c = r[2];
|
|
157
157
|
const f = c;
|
|
158
158
|
let o;
|
|
159
|
-
r[3] === Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ s(() => {
|
|
159
|
+
r[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ s(() => {
|
|
160
160
|
e.current = e.current + 1;
|
|
161
161
|
}, "t3"), r[3] = o) : o = r[3];
|
|
162
162
|
const y = o;
|
|
163
163
|
let a;
|
|
164
|
-
r[4] === Symbol.for("react.memo_cache_sentinel") ? (a = /* @__PURE__ */ s(() => {
|
|
164
|
+
r[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (a = /* @__PURE__ */ s(() => {
|
|
165
165
|
e.current = 0;
|
|
166
166
|
}, "t4"), r[4] = a) : a = r[4];
|
|
167
167
|
const i = a;
|
|
168
168
|
let d;
|
|
169
|
-
return r[5] === Symbol.for("react.memo_cache_sentinel") ? (d = {
|
|
169
|
+
return r[5] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (d = {
|
|
170
170
|
generate: n,
|
|
171
171
|
current: u,
|
|
172
172
|
isLatest: f,
|
|
@@ -431,7 +431,7 @@ function J(r) {
|
|
|
431
431
|
execute: u
|
|
432
432
|
} = r, c = l === void 0 ? !0 : l, o = I(n ?? t);
|
|
433
433
|
let y;
|
|
434
|
-
e[0] === Symbol.for("react.memo_cache_sentinel") ? (y = /* @__PURE__ */ s(() => o.current, "t1"), e[0] = y) : y = e[0];
|
|
434
|
+
e[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (y = /* @__PURE__ */ s(() => o.current, "t1"), e[0] = y) : y = e[0];
|
|
435
435
|
const a = y;
|
|
436
436
|
let i;
|
|
437
437
|
e[1] !== c || e[2] !== u ? (i = /* @__PURE__ */ s(() => {
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/core/useLatest.ts","../src/core/debounced/useDebouncedCallback.ts","../src/core/useMounted.ts","../src/core/usePromiseState.ts","../src/core/useRequestId.ts","../src/core/useExecutePromise.ts","../src/core/debounced/useDebouncedExecutePromise.ts","../src/core/debounced/useDebouncedQuery.ts","../src/core/fullscreen/utils.ts","../src/core/fullscreen/useFullscreen.ts","../src/core/useRefs.ts","../src/core/useForceUpdate.ts","../src/core/useQueryState.ts","../src/core/useQuery.ts","../src/storage/useKeyStorage.ts","../src/storage/useImmerKeyStorage.ts","../src/cosec/useSecurity.ts","../src/cosec/SecurityContext.tsx","../src/cosec/RouteGuard.tsx","../src/cosec/RefreshableRouteGuard.tsx","../src/fetcher/useFetcher.ts","../src/fetcher/debounced/useDebouncedFetcher.ts","../src/fetcher/debounced/useDebouncedFetcherQuery.ts","../src/fetcher/useFetcherQuery.ts","../src/wow/fetcher/useFetcherCountQuery.ts","../src/wow/fetcher/useFetcherListQuery.ts","../src/wow/fetcher/useFetcherListStreamQuery.ts","../src/wow/fetcher/useFetcherPagedQuery.ts","../src/wow/fetcher/useFetcherSingleQuery.ts","../src/wow/useCountQuery.ts","../src/wow/useListQuery.ts","../src/wow/useListStreamQuery.ts","../src/wow/usePagedQuery.ts","../src/wow/useSingleQuery.ts","../src/eventbus/useEventSubscription.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RefObject, useRef } from 'react';\n\n/**\n * A React hook that returns a ref containing the latest value, useful for accessing the current value in async callbacks.\n *\n * @template T - The type of the value\n * @param value - The value to track\n * @returns A ref object containing the latest value\n *\n * @example\n * ```typescript\n * import { useLatest } from '@ahoo-wang/fetcher-react';\n *\n * const MyComponent = () => {\n * const [count, setCount] = useState(0);\n * const latestCount = useLatest(count);\n *\n * const handleAsync = async () => {\n * await someAsyncOperation();\n * console.log('Latest count:', latestCount.current); // Always the latest\n * };\n *\n * return (\n * <div>\n * <p>Count: {count}</p>\n * <button onClick={() => setCount(c => c + 1)}>Increment</button>\n * <button onClick={handleAsync}>Async Log</button>\n * </div>\n * );\n * };\n * ```\n */\nexport function useLatest<T>(value: T): RefObject<T> {\n const ref = useRef(value);\n /* eslint-disable react-hooks/refs */\n ref.current = value;\n return ref;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useCallback, useRef, useEffect, useMemo } from 'react';\nimport { useLatest } from '../useLatest';\n\n/**\n * Options for configuring the debounced callback behavior.\n */\nexport interface UseDebouncedCallbackOptions {\n /** The delay in milliseconds before the callback is invoked. Must be a positive number. */\n delay: number;\n /** Whether to invoke the callback immediately on the leading edge of the timeout. Defaults to false. */\n leading?: boolean;\n /** Whether to invoke the callback on the trailing edge of the timeout. Defaults to true. */\n trailing?: boolean;\n}\n\n/**\n * Return type of the useDebouncedCallback hook.\n * @template T - The type of the original callback function.\n */\nexport interface UseDebouncedCallbackReturn<T extends (...args: any[]) => any> {\n /** Function to execute the debounced callback with the provided arguments. */\n readonly run: (...args: Parameters<T>) => void;\n /** Function to cancel any pending debounced execution. */\n readonly cancel: () => void;\n /** Function to check if a debounced execution is currently pending. */\n readonly isPending: () => boolean;\n}\n\n/**\n * A React hook that provides a debounced version of a callback function.\n * The callback will be invoked after a specified delay, with options for leading and trailing edge execution.\n * This is useful for optimizing performance in scenarios like search input handling or window resizing.\n *\n * @template T - The type of the callback function.\n * @param callback - The function to debounce. It can accept any number of arguments.\n * @param options - Configuration object for debouncing behavior.\n * @param options.delay - The delay in milliseconds before the callback is invoked. Must be a positive number.\n * @param options.leading - If true, the callback is invoked immediately on the first call, then debounced. Defaults to false.\n * @param options.trailing - If true, the callback is invoked after the delay on the last call. Defaults to true.\n * @returns An object containing:\n * - `run`: Function to execute the debounced callback with arguments.\n * - `cancel`: Function to cancel any pending debounced execution.\n * - `isPending`: Function that returns true if a debounced execution is currently pending.\n *\n * @example\n * ```typescript\n * const { run, cancel } = useDebouncedCallback(\n * (query: string) => {\n * console.log('Searching for:', query);\n * // Perform search API call\n * },\n * { delay: 300 }\n * );\n *\n * // Call the debounced function\n * run('search term');\n *\n * // Cancel if needed\n * cancel();\n * ```\n *\n * @example With leading edge execution:\n * ```typescript\n * const { run } = useDebouncedCallback(\n * () => console.log('Immediate and debounced'),\n * { delay: 500, leading: true, trailing: true }\n * );\n *\n * run(); // Logs immediately, then again after 500ms if called again\n * ```\n *\n * @throws {Error} Throws an error if both `leading` and `trailing` options are set to false, as at least one must be true for the debounce to function.\n * @throws Exceptions from the callback function itself should be handled by the caller.\n */\nexport function useDebouncedCallback<T extends (...args: any[]) => any>(\n callback: T,\n options: UseDebouncedCallbackOptions,\n): UseDebouncedCallbackReturn<T> {\n if (options.leading === false && options.trailing === false) {\n throw new Error(\n 'useDebouncedCallback: at least one of leading or trailing must be true',\n );\n }\n\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const lastArgsRef = useRef<Parameters<T> | null>(null);\n const lastInvokeTimeRef = useRef<number | null>(null);\n\n const latestCallback = useLatest(callback);\n const latestOptions = useLatest(options);\n\n const cleanTimeout = useCallback(() => {\n if (timeoutRef.current !== undefined) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = undefined;\n }\n }, []);\n\n const shouldInvoke = useCallback((time: number) => {\n if (!lastInvokeTimeRef.current) {\n return true;\n }\n const timeSinceLastInvoke = time - lastInvokeTimeRef.current;\n return timeSinceLastInvoke >= latestOptions.current.delay;\n }, [latestOptions]);\n\n const invokeCallback = useCallback((time: number, args: Parameters<T>) => {\n lastInvokeTimeRef.current = time;\n latestCallback.current(...args);\n }, [latestCallback]);\n\n const scheduleTrailing = useCallback(() => {\n timeoutRef.current = setTimeout(() => {\n if (lastArgsRef.current) {\n const trailingTime = Date.now();\n invokeCallback(trailingTime, lastArgsRef.current);\n }\n timeoutRef.current = undefined;\n }, latestOptions.current.delay);\n }, [latestOptions, invokeCallback]);\n\n const run = useCallback(\n (...args: Parameters<T>) => {\n cleanTimeout();\n const { leading = false, trailing = true } = latestOptions.current;\n lastArgsRef.current = args;\n if (trailing && !leading) {\n scheduleTrailing();\n return;\n }\n\n const currentTime = Date.now();\n const shouldCallLeading = leading && shouldInvoke(currentTime);\n if (shouldCallLeading) {\n invokeCallback(currentTime, args);\n return;\n }\n if (trailing) {\n scheduleTrailing();\n }\n },\n [latestOptions, cleanTimeout, shouldInvoke, invokeCallback, scheduleTrailing],\n );\n const cancel = useCallback(() => {\n cleanTimeout();\n lastArgsRef.current = null;\n }, [cleanTimeout]);\n const isPending = useCallback(() => {\n return timeoutRef.current !== undefined;\n }, []);\n useEffect(() => {\n return () => {\n cancel();\n };\n }, [cancel]);\n\n return useMemo(\n () => ({\n run,\n cancel,\n isPending,\n }),\n [run, cancel, isPending],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useRef, useEffect, useCallback } from 'react';\n\n/**\n * A React hook that returns a function to check if the component is mounted.\n *\n * @returns A function that returns true if the component is mounted, false otherwise\n *\n * @example\n * ```typescript\n * import { useMounted } from '@ahoo-wang/fetcher-react';\n *\n * const MyComponent = () => {\n * const isMounted = useMounted();\n *\n * useEffect(() => {\n * someAsyncOperation().then(() => {\n * if (isMounted()) {\n * setState(result);\n * }\n * });\n * }, []);\n *\n * return <div>My Component</div>;\n * };\n * ```\n */\nexport function useMounted() {\n const isMountedRef = useRef(false);\n const isMountedFn = useCallback(() => isMountedRef.current, []);\n useEffect(() => {\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n };\n }, []);\n\n return isMountedFn;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useMemo, useState } from 'react';\nimport { useMounted } from './useMounted';\nimport { useLatest } from './useLatest';\nimport { FetcherError } from '@ahoo-wang/fetcher';\n\n/**\n * Enumeration of possible promise execution states\n */\nexport enum PromiseStatus {\n IDLE = 'idle',\n LOADING = 'loading',\n SUCCESS = 'success',\n ERROR = 'error',\n}\n\nexport interface PromiseState<R, E = unknown> {\n /** Current status of the promise */\n status: PromiseStatus;\n /** Indicates if currently loading */\n loading: boolean;\n /** The result value */\n result: R | undefined;\n /** The error value */\n error: E | undefined;\n}\n\nexport interface PromiseStateCallbacks<R, E = unknown> {\n /** Callback invoked on success (can be async) */\n onSuccess?: (result: R) => void | Promise<void>;\n /** Callback invoked on error (can be async) */\n onError?: (error: E) => void | Promise<void>;\n}\n\n/**\n * Options for configuring usePromiseState behavior\n * @template R - The type of result\n *\n * @example\n * ```typescript\n * const options: UsePromiseStateOptions<string> = {\n * initialStatus: PromiseStatus.IDLE,\n * onSuccess: (result) => console.log('Success:', result),\n * onError: async (error) => {\n * await logErrorToServer(error);\n * console.error('Error:', error);\n * },\n * };\n * ```\n */\nexport interface UsePromiseStateOptions<R, E = FetcherError>\n extends PromiseStateCallbacks<R, E> {\n /** Initial status, defaults to IDLE */\n initialStatus?: PromiseStatus;\n}\n\n/**\n * Return type for usePromiseState hook\n * @template R - The type of result\n */\nexport interface UsePromiseStateReturn<R, E = FetcherError>\n extends PromiseState<R, E> {\n /** Set status to LOADING */\n setLoading: () => void;\n /** Set status to SUCCESS with result */\n setSuccess: (result: R) => Promise<void>;\n /** Set status to ERROR with error */\n setError: (error: E) => Promise<void>;\n /** Set status to IDLE */\n setIdle: () => void;\n}\n\n/**\n * A React hook for managing promise state without execution logic\n * @template R - The type of result\n * @param options - Configuration options\n * @returns State management object\n *\n * @example\n * ```typescript\n * import { usePromiseState, PromiseStatus } from '@ahoo-wang/fetcher-react';\n *\n * function MyComponent() {\n * const { status, loading, result, error, setSuccess, setError, setIdle } = usePromiseState<string>();\n *\n * const handleSuccess = () => setSuccess('Data loaded');\n * const handleError = () => setError(new Error('Failed to load'));\n *\n * return (\n * <div>\n * <button onClick={handleSuccess}>Set Success</button>\n * <button onClick={handleError}>Set Error</button>\n * <button onClick={setIdle}>Reset</button>\n * <p>Status: {status}</p>\n * {loading && <p>Loading...</p>}\n * {result && <p>Result: {result}</p>}\n * {error && <p>Error: {error.message}</p>}\n * </div>\n * );\n * }\n * ```\n */\nexport function usePromiseState<R = unknown, E = FetcherError>(\n options?: UsePromiseStateOptions<R, E>,\n): UsePromiseStateReturn<R, E> {\n const [status, setStatus] = useState<PromiseStatus>(\n options?.initialStatus ?? PromiseStatus.IDLE,\n );\n const [result, setResult] = useState<R | undefined>(undefined);\n const [error, setError] = useState<E | undefined>(undefined);\n const isMounted = useMounted();\n const latestOptions = useLatest(options);\n const setLoadingFn = useCallback(() => {\n if (isMounted()) {\n setStatus(PromiseStatus.LOADING);\n setError(undefined);\n }\n }, [isMounted]);\n\n const setSuccessFn = useCallback(\n async (result: R) => {\n if (isMounted()) {\n setResult(result);\n setStatus(PromiseStatus.SUCCESS);\n setError(undefined);\n try {\n await latestOptions.current?.onSuccess?.(result);\n } catch (callbackError) {\n // Log callback errors but don't affect state\n console.warn('PromiseState onSuccess callback error:', callbackError);\n }\n }\n },\n [isMounted, latestOptions],\n );\n\n const setErrorFn = useCallback(\n async (error: E) => {\n if (isMounted()) {\n setError(error);\n setStatus(PromiseStatus.ERROR);\n setResult(undefined);\n try {\n await latestOptions.current?.onError?.(error);\n } catch (callbackError) {\n // Log callback errors but don't affect state\n console.warn('PromiseState onError callback error:', callbackError);\n }\n }\n },\n [isMounted, latestOptions],\n );\n\n const setIdleFn = useCallback(() => {\n if (isMounted()) {\n setStatus(PromiseStatus.IDLE);\n setError(undefined);\n setResult(undefined);\n }\n }, [isMounted]);\n return useMemo(\n () => ({\n status,\n loading: status === PromiseStatus.LOADING,\n result,\n error,\n setLoading: setLoadingFn,\n setSuccess: setSuccessFn,\n setError: setErrorFn,\n setIdle: setIdleFn,\n }),\n [status, result, error, setLoadingFn, setSuccessFn, setErrorFn, setIdleFn],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useRef, useCallback, useMemo } from 'react';\n\n/**\n * Return type for useRequestId hook\n */\nexport interface UseRequestIdReturn {\n /** Generate a new request ID and get the current one */\n generate: () => number;\n /** Get the current request ID without generating a new one */\n current: () => number;\n /** Check if a given request ID is the latest */\n isLatest: (requestId: number) => boolean;\n /** Invalidate current request ID (mark as stale) */\n invalidate: () => void;\n /** Reset request ID counter */\n reset: () => void;\n}\n\n/**\n * A React hook for managing request IDs and race condition protection\n *\n * @example\n * ```typescript\n * // Basic usage\n * const requestId = useRequestId();\n *\n * const execute = async () => {\n * const id = requestId.generate();\n *\n * try {\n * const result = await someAsyncOperation();\n *\n * // Check if this is still the latest request\n * if (requestId.isLatest(id)) {\n * setState(result);\n * }\n * } catch (error) {\n * if (requestId.isLatest(id)) {\n * setError(error);\n * }\n * }\n * };\n *\n * // Manual cancellation\n * const handleCancel = () => {\n * requestId.invalidate(); // All ongoing requests will be ignored\n * };\n * ```\n *\n * @example\n * ```typescript\n * // With async operation wrapper\n * const { execute, cancel } = useAsyncOperation(async (data) => {\n * return await apiCall(data);\n * }, [requestId]);\n * ```\n */\nexport function useRequestId(): UseRequestIdReturn {\n const requestIdRef = useRef<number>(0);\n\n const generate = useCallback((): number => {\n return ++requestIdRef.current;\n }, []);\n\n const current = useCallback((): number => {\n return requestIdRef.current;\n }, []);\n\n const isLatest = useCallback((requestId: number): boolean => {\n return requestId === requestIdRef.current;\n }, []);\n\n const invalidate = useCallback((): void => {\n requestIdRef.current++;\n }, []);\n\n const reset = useCallback((): void => {\n requestIdRef.current = 0;\n }, []);\n return useMemo(() => {\n return {\n generate,\n current,\n isLatest,\n invalidate,\n reset,\n };\n }, [generate, current, isLatest, invalidate, reset]);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useMemo, useRef } from 'react';\nimport { useMounted } from './useMounted';\nimport {\n usePromiseState,\n PromiseState,\n UsePromiseStateOptions,\n} from './usePromiseState';\nimport { useRequestId } from './useRequestId';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useLatest } from './useLatest';\n\n/**\n * Configuration options for the useExecutePromise hook.\n * @template R - The type of the resolved value from the promise.\n * @template E - The type of the error value, defaults to unknown.\n */\nexport interface UseExecutePromiseOptions<R, E = unknown>\n extends UsePromiseStateOptions<R, E> {\n /**\n * Whether to propagate errors thrown by the promise.\n * If true, the execute function will throw errors.\n * If false (default), the execute function will return the error as the result instead of throwing.\n * @default false\n */\n propagateError?: boolean;\n /**\n * Callback function called when the current operation is aborted.\n * This includes both automatic cancellation (when a new operation starts) and manual abortion.\n */\n onAbort?: () => void | Promise<void>;\n}\n\n/**\n * Type definition for a function that returns a Promise with optional abort controller support.\n * This is used as input to the execute function, allowing lazy evaluation of promises.\n * The abort controller can be used to cancel the promise if needed.\n * @template R - The type of value the promise will resolve to.\n */\nexport type PromiseSupplier<R> = (\n abortController: AbortController,\n) => Promise<R>;\n\n/**\n * Interface defining the return type of the useExecutePromise hook.\n * Provides state management and control functions for asynchronous operations.\n * @template R - The type of the result value.\n * @template E - The type of the error value, defaults to FetcherError.\n */\nexport interface UseExecutePromiseReturn<R, E = FetcherError>\n extends PromiseState<R, E> {\n /**\n * Function to execute a promise supplier with automatic abort support.\n * Automatically cancels any previous ongoing request before starting a new one.\n * Manages the loading state, handles errors, and updates the result state.\n * @param input - A function that returns a Promise, optionally receiving an AbortController.\n * @throws {Error} If the component is unmounted when execute is called.\n * @throws {E} If propagateError is true and the promise rejects.\n */\n execute: (input: PromiseSupplier<R>) => Promise<void>;\n /**\n * Function to reset the state to initial values.\n * Clears loading, result, error, and sets status to idle.\n */\n reset: () => void;\n /**\n * Function to manually abort the current ongoing operation.\n * This will cancel the current promise execution and set the state to idle.\n * Safe to call even when no operation is currently running.\n */\n abort: () => void;\n}\n\n/**\n * A React hook for managing asynchronous operations with proper state handling and abort support.\n * Provides a way to execute promises while automatically managing loading states,\n * handling errors, preventing state updates on unmounted components or stale requests,\n * and supporting request cancellation through AbortController.\n *\n * Key features:\n * - Automatic request cancellation when new requests are initiated\n * - Manual abort control with dedicated abort() method\n * - AbortController integration for promise-level cancellation\n * - Race condition protection using request IDs\n * - Comprehensive state management (idle, loading, success, error)\n * - Memory leak prevention with automatic cleanup on unmount\n *\n * @template R - The type of the result value, defaults to unknown.\n * @template E - The type of the error value, defaults to FetcherError.\n * @param options - Optional configuration options for the hook behavior.\n * @returns An object containing the current promise state and control functions.\n *\n * @throws {Error} When execute is called on an unmounted component.\n * @throws {E} When propagateError is true and the executed promise rejects.\n *\n * @example\n * Basic usage with automatic abort support and onAbort callback:\n * ```typescript\n * import { useExecutePromise } from '@ahoo-wang/fetcher-react';\n *\n * function MyComponent() {\n * const { loading, result, error, execute, reset, abort } = useExecutePromise<string>({\n * onAbort: () => {\n * console.log('Request was cancelled');\n * // Handle abort (e.g., update UI, cleanup resources)\n * }\n * });\n *\n * const fetchData = async (abortController?: AbortController) => {\n * const response = await fetch('/api/data', {\n * signal: abortController?.signal,\n * });\n * return response.text();\n * };\n *\n * const handleFetch = () => {\n * execute(fetchData); // Automatically cancels previous request and calls onAbort\n * };\n *\n * const handleCancel = () => {\n * abort(); // Manually cancel current request and calls onAbort\n * };\n *\n * const handleReset = () => {\n * reset();\n * };\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * return (\n * <div>\n * <button onClick={handleFetch}>Fetch Data</button>\n * <button onClick={handleCancel} disabled={!loading}>Cancel</button>\n * <button onClick={handleReset}>Reset</button>\n * {result && <p>{result}</p>}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * Basic usage with automatic abort support:\n * ```typescript\n * import { useExecutePromise } from '@ahoo-wang/fetcher-react';\n *\n * function MyComponent() {\n * const { loading, result, error, execute, reset, abort } = useExecutePromise<string>();\n *\n * const fetchData = async (abortController?: AbortController) => {\n * const response = await fetch('/api/data', {\n * signal: abortController?.signal, // Optional: use abort signal\n * });\n * return response.text();\n * };\n *\n * const handleFetch = () => {\n * execute(fetchData); // Automatically cancels previous request\n * };\n *\n * const handleCancel = () => {\n * abort(); // Manually cancel current request\n * };\n *\n * const handleReset = () => {\n * reset();\n * };\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * return (\n * <div>\n * <button onClick={handleFetch}>Fetch Data</button>\n * <button onClick={handleCancel} disabled={!loading}>Cancel</button>\n * <button onClick={handleReset}>Reset</button>\n * {result && <p>{result}</p>}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * Using propagateError for try/catch error handling:\n * ```typescript\n * const { execute } = useExecutePromise<string>({ propagateError: true });\n *\n * const handleSubmit = async () => {\n * try {\n * const data = await execute(fetchUserData);\n * console.log('Success:', data);\n * } catch (err) {\n * console.error('Error occurred:', err);\n * }\n * };\n * ```\n *\n */\nexport function useExecutePromise<R = unknown, E = FetcherError>(\n options?: UseExecutePromiseOptions<R, E>,\n): UseExecutePromiseReturn<R, E> {\n const {\n loading,\n result,\n error,\n status,\n setLoading,\n setSuccess,\n setError,\n setIdle,\n } = usePromiseState<R, E>(options);\n const isMounted = useMounted();\n const requestId = useRequestId();\n const abortControllerRef = useRef<AbortController | undefined>(undefined);\n const propagateError = options?.propagateError;\n const onAbortRef = useLatest(options?.onAbort);\n const handleOnAbort = useCallback(async () => {\n // Call onAbort callback when automatically cancelling previous request\n try {\n await onAbortRef.current?.();\n } catch (callbackError) {\n console.warn('useExecutePromise onAbort callback error:', callbackError);\n }\n }, [onAbortRef]);\n /**\n * Execute a promise supplier with automatic abort support.\n * Automatically cancels any previous ongoing request before starting a new one.\n * Handles loading states, error propagation, and prevents updates on unmounted components.\n * @param input - A function that returns a Promise, optionally receiving an AbortController for cancellation.\n * @throws {Error} If the component is unmounted when execute is called.\n * @throws {E} If propagateError is true and the promise rejects.\n */\n const execute = useCallback(\n async (input: PromiseSupplier<R>): Promise<void> => {\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n await handleOnAbort();\n }\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n const currentRequestId = requestId.generate();\n setLoading();\n try {\n const data = await input(abortController);\n\n if (isMounted() && requestId.isLatest(currentRequestId)) {\n await setSuccess(data);\n }\n } catch (err) {\n if (err instanceof Error && err.name === 'AbortError') {\n if (isMounted()) {\n setIdle();\n }\n return;\n }\n if (isMounted() && requestId.isLatest(currentRequestId)) {\n await setError(err as E);\n }\n if (propagateError) {\n throw err;\n }\n } finally {\n if (abortControllerRef.current === abortController) {\n abortControllerRef.current = undefined;\n }\n }\n },\n [\n setLoading,\n setSuccess,\n setError,\n setIdle,\n isMounted,\n requestId,\n propagateError,\n handleOnAbort,\n ],\n );\n\n /**\n * Reset the state to initial values.\n * Clears loading, result, error, and sets status to idle.\n * Only works if the component is still mounted.\n */\n const reset = useCallback(() => {\n if (isMounted()) {\n setIdle();\n }\n }, [setIdle, isMounted]);\n\n /**\n * Manually abort the current ongoing operation.\n * This will cancel the current promise execution and set the state to idle.\n * Safe to call even when no operation is currently running.\n */\n const abort = useCallback(async () => {\n reset();\n if (!abortControllerRef.current) {\n return;\n }\n abortControllerRef.current.abort();\n abortControllerRef.current = undefined;\n await handleOnAbort();\n }, [reset, handleOnAbort]);\n\n useEffect(() => {\n return () => {\n abort();\n };\n }, [abort]);\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n execute,\n reset,\n abort,\n }),\n [loading, result, error, status, execute, reset, abort],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n useExecutePromise,\n UseExecutePromiseOptions,\n UseExecutePromiseReturn,\n} from '../useExecutePromise';\nimport {\n useDebouncedCallback,\n UseDebouncedCallbackOptions,\n UseDebouncedCallbackReturn,\n} from './useDebouncedCallback';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useMemo } from 'react';\n\n/**\n * Interface for objects that support debouncing configuration.\n * This interface defines the structure for debounce settings that can be applied\n * to promise execution to control the timing and behavior of debounced calls.\n */\nexport interface DebounceCapable {\n /**\n * Debounce options for execute calls, including delay and leading/trailing behavior.\n * Specifies how the debouncing should work, such as the delay duration and whether\n * to execute on the leading edge, trailing edge, or both.\n */\n debounce: UseDebouncedCallbackOptions;\n}\n\n/**\n * Options for configuring the useDebouncedExecutePromise hook.\n * Combines promise execution options with debouncing capabilities to provide\n * fine-grained control over asynchronous operations with rate limiting.\n *\n * @template R - The type of the promise result\n * @template E - The type of the error (defaults to unknown)\n */\nexport interface UseDebouncedExecutePromiseOptions<R, E = unknown>\n extends UseExecutePromiseOptions<R, E>,\n DebounceCapable {}\n\n/**\n * Return type for the useDebouncedExecutePromise hook.\n * Provides access to the promise execution state and debounced execution controls,\n * allowing components to trigger debounced promises and monitor their progress.\n *\n * @template R - The type of the promise result\n * @template E - The type of the error (defaults to unknown)\n */\nexport interface UseDebouncedExecutePromiseReturn<R, E = unknown>\n extends Omit<UseExecutePromiseReturn<R, E>, 'execute'>,\n UseDebouncedCallbackReturn<UseExecutePromiseReturn<R, E>['execute']> {}\n\n/**\n * A React hook that combines promise execution with debouncing functionality.\n * This hook prevents excessive API calls by debouncing the execution of promises,\n * which is particularly useful for scenarios like search inputs, form submissions,\n * or any rapid user interactions that trigger asynchronous operations.\n *\n * The hook integrates the useExecutePromise hook for promise management with\n * useDebouncedCallback for rate limiting, providing a seamless way to handle\n * debounced asynchronous operations in React components.\n *\n * @template R - The type of the promise result (defaults to unknown)\n * @template E - The type of the error (defaults to FetcherError)\n * @param options - Configuration object containing:\n * - All options from UseExecutePromiseOptions (promise execution settings)\n * - debounce: Debounce configuration including delay, leading/trailing behavior\n * @returns An object containing:\n * - loading: Boolean indicating if the promise is currently executing\n * - result: The resolved value of the promise (R)\n * - error: Any error that occurred during execution (E)\n * - status: Current execution status ('idle' | 'pending' | 'fulfilled' | 'rejected')\n * - run: Debounced function to execute the promise with provided arguments\n * - cancel: Function to cancel any pending debounced execution\n * - isPending: Boolean indicating if a debounced call is pending\n * - reset: Function to reset the hook state to initial values\n * @throws {FetcherError} When the underlying promise execution fails and no custom error handler is provided\n * @throws {Error} When invalid options are provided or debounce configuration is malformed\n *\n * @example\n * ```tsx\n * import { useDebouncedExecutePromise } from '@ahoo-wang/fetcher-react';\n *\n * function SearchComponent() {\n * const { loading, result, error, run } = useDebouncedExecutePromise({\n * debounce: { delay: 300 },\n * });\n *\n * const handleSearch = (query: string) => {\n * run(async () => {\n * const response = await fetch(`/api/search?q=${query}`);\n * return response.json();\n * });\n * };\n *\n * return (\n * <div>\n * <input onChange={(e) => handleSearch(e.target.value)} />\n * {loading && <p>Searching...</p>}\n * {result && <ul>{result.map(item => <li key={item.id}>{item.name}</li>)}</ul>}\n * {error && <p>Error: {error.message}</p>}\n * </div>\n * );\n * }\n * ```\n */\nexport function useDebouncedExecutePromise<R = unknown, E = FetcherError>(\n options: UseDebouncedExecutePromiseOptions<R, E>,\n): UseDebouncedExecutePromiseReturn<R, E> {\n const { loading, result, error, execute, reset, abort, status } =\n useExecutePromise(options);\n const { run, cancel, isPending } = useDebouncedCallback(\n execute,\n options.debounce,\n );\n\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n reset,\n abort,\n run,\n cancel,\n isPending,\n }),\n [loading, result, error, status, reset, abort, run, cancel, isPending],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useQuery, UseQueryOptions, UseQueryReturn } from '../index';\nimport {\n DebounceCapable,\n useDebouncedCallback,\n UseDebouncedCallbackReturn,\n} from '../index';\nimport { useCallback, useEffect, useMemo } from 'react';\n\n/**\n * Configuration options for the useDebouncedQuery hook\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value (defaults to FetcherError)\n */\nexport interface UseDebouncedQueryOptions<Q, R, E = FetcherError>\n extends UseQueryOptions<Q, R, E>, DebounceCapable {\n}\n\n/**\n * Return type of the useDebouncedQuery hook\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value (defaults to FetcherError)\n */\nexport interface UseDebouncedQueryReturn<Q, R, E = FetcherError>\n extends Omit<UseQueryReturn<Q, R, E>, 'execute'>,\n UseDebouncedCallbackReturn<UseQueryReturn<Q, R, E>['execute']> {\n}\n\n/**\n * A React hook for managing debounced query execution with automatic state management\n *\n * This hook combines the query functionality with debouncing to provide\n * a convenient way to execute queries with built-in debouncing to prevent excessive\n * operations during rapid query changes, such as in search inputs or dynamic filtering.\n *\n * The hook supports automatic execution on mount and when query parameters change,\n * but wraps the execution in a debounced callback to optimize performance.\n *\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value (defaults to FetcherError)\n * @param options - Configuration options for the hook\n * @returns An object containing query state, query management functions, and debounced execution controls\n *\n * @example\n * ```typescript\n * import { useDebouncedQuery } from '@ahoo-wang/fetcher-react';\n *\n * interface SearchQuery {\n * keyword: string;\n * limit: number;\n * filters?: { category?: string };\n * }\n *\n * interface SearchResult {\n * items: Array<{ id: string; title: string }>;\n * total: number;\n * }\n *\n * function SearchComponent() {\n * const {\n * loading,\n * result,\n * error,\n * run,\n * cancel,\n * isPending,\n * setQuery,\n * getQuery,\n * } = useDebouncedQuery<SearchQuery, SearchResult>({\n * initialQuery: { keyword: '', limit: 10 },\n * execute: async (query) => {\n * const response = await fetch('/api/search', {\n * method: 'POST',\n * body: JSON.stringify(query),\n * headers: { 'Content-Type': 'application/json' },\n * });\n * return response.json();\n * },\n * debounce: { delay: 300 }, // Debounce for 300ms\n * autoExecute: false,\n * });\n *\n * const handleSearch = (keyword: string) => {\n * setQuery({ keyword, limit: 10 }); // This will trigger debounced execution if autoExecute was true\n * };\n *\n * const handleManualSearch = () => {\n * run(); // Manual debounced execution with current query\n * };\n *\n * const handleCancel = () => {\n * cancel(); // Cancel any pending debounced execution\n * };\n *\n * if (loading) return <div>Searching...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <input\n * type=\"text\"\n * onChange={(e) => handleSearch(e.target.value)}\n * placeholder=\"Search...\"\n * />\n * <button onClick={handleManualSearch} disabled={isPending()}>\n * {isPending() ? 'Searching...' : 'Search'}\n * </button>\n * <button onClick={handleCancel}>Cancel</button>\n * {result && (\n * <div>\n * Found {result.total} items:\n * {result.items.map(item => (\n * <div key={item.id}>{item.title}</div>\n * ))}\n * </div>\n * )}\n * </div>\n * );\n * }\n * ```\n *\n * @throws This hook may throw exceptions related to query execution, which should be\n * handled by the caller. The execute function may throw FetcherError or other errors.\n * Invalid query parameters or execution function errors may also cause exceptions.\n */\nexport function useDebouncedQuery<Q, R, E = FetcherError>(\n options: UseDebouncedQueryOptions<Q, R, E>,\n): UseDebouncedQueryReturn<Q, R, E> {\n const originalAutoExecute = options.autoExecute;\n const debouncedExecuteOptions = {\n ...options,\n autoExecute: false,\n };\n const {\n loading,\n result,\n error,\n status,\n execute,\n reset,\n abort,\n getQuery,\n setQuery,\n } = useQuery(debouncedExecuteOptions);\n const { run, cancel, isPending } = useDebouncedCallback(\n execute,\n options.debounce,\n );\n const setQueryFn = useCallback((query: Q) => {\n setQuery(query);\n if (originalAutoExecute) {\n run();\n }\n }, [setQuery, run, originalAutoExecute]);\n useEffect(() => {\n if (originalAutoExecute) {\n run();\n }\n }, [run, originalAutoExecute]);\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n reset,\n abort,\n getQuery,\n setQuery: setQueryFn,\n run,\n cancel,\n isPending,\n }),\n [\n loading,\n result,\n error,\n status,\n reset,\n abort,\n getQuery,\n setQueryFn,\n run,\n cancel,\n isPending,\n ],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Get the current fullscreen element across different browsers.\n * @returns The fullscreen element or null if not in fullscreen.\n */\nexport function getFullscreenElement(): HTMLElement | null {\n return (\n document.fullscreenElement ||\n (document as any).webkitFullscreenElement ||\n (document as any).mozFullScreenElement ||\n (document as any).msFullscreenElement\n );\n}\n\n/**\n * Request fullscreen for a given element.\n * @param element The element to make fullscreen.\n * @throws Error if fullscreen request fails.\n */\nexport async function enterFullscreen(element: HTMLElement): Promise<void> {\n try {\n if (element.requestFullscreen) {\n await element.requestFullscreen();\n } else if ((element as any).webkitRequestFullscreen) {\n await (element as any).webkitRequestFullscreen();\n } else if ((element as any).mozRequestFullScreen) {\n await (element as any).mozRequestFullScreen();\n } else if ((element as any).msRequestFullscreen) {\n await (element as any).msRequestFullscreen();\n } else {\n throw new Error('Fullscreen API not supported');\n }\n } catch (error) {\n console.error('Failed to enter fullscreen:', error);\n throw error;\n }\n}\n\n/**\n * Exit fullscreen mode.\n * @throws Error if fullscreen exit fails.\n */\nexport async function exitFullscreen(): Promise<void> {\n try {\n if (document.exitFullscreen) {\n await document.exitFullscreen();\n } else if ((document as any).webkitExitFullscreen) {\n await (document as any).webkitExitFullscreen();\n } else if ((document as any).mozCancelFullScreen) {\n await (document as any).mozCancelFullScreen();\n } else if ((document as any).msExitFullscreen) {\n await (document as any).msExitFullscreen();\n } else {\n throw new Error('Fullscreen API not supported');\n }\n } catch (error) {\n console.error('Failed to exit fullscreen:', error);\n throw error;\n }\n}\n\n/**\n * Add fullscreen change event listeners across different browsers.\n * @param callback The callback function to execute when fullscreen changes.\n */\nexport function addFullscreenChangeListener(callback: () => void): void {\n document.addEventListener('fullscreenchange', callback);\n document.addEventListener('webkitfullscreenchange', callback);\n document.addEventListener('mozfullscreenchange', callback);\n document.addEventListener('MSFullscreenChange', callback);\n}\n\n/**\n * Remove fullscreen change event listeners across different browsers.\n * @param callback The callback function to remove.\n */\nexport function removeFullscreenChangeListener(callback: () => void): void {\n document.removeEventListener('fullscreenchange', callback);\n document.removeEventListener('webkitfullscreenchange', callback);\n document.removeEventListener('mozfullscreenchange', callback);\n document.removeEventListener('MSFullscreenChange', callback);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState, useCallback, useEffect, RefObject } from 'react';\nimport {\n getFullscreenElement,\n enterFullscreen,\n exitFullscreen,\n addFullscreenChangeListener,\n removeFullscreenChangeListener,\n} from './utils';\n\nexport interface UseFullscreenOptions {\n /**\n * Target element to make fullscreen. If not provided, uses the document root element.\n */\n target?: RefObject<HTMLElement | null>;\n /**\n * Callback when fullscreen state changes\n */\n onChange?: (isFullscreen: boolean) => void;\n}\n\nexport interface UseFullscreenReturn {\n /**\n * Whether the target element is currently in fullscreen mode\n */\n isFullscreen: boolean;\n /**\n * Toggle fullscreen mode on/off\n */\n toggle: () => Promise<void>;\n /**\n * Enter fullscreen mode\n */\n enter: () => Promise<void>;\n /**\n * Exit fullscreen mode\n */\n exit: () => Promise<void>;\n}\n\n/**\n * React hook for managing fullscreen state and actions.\n * Provides cross-browser fullscreen API support with automatic state tracking.\n */\nexport function useFullscreen(\n options: UseFullscreenOptions = {},\n): UseFullscreenReturn {\n const { target: targetRef, onChange } = options;\n\n const [isFullscreen, setIsFullscreen] = useState(false);\n\n const handleFullscreenChange = useCallback(() => {\n const fullscreenElement = getFullscreenElement();\n const newIsFullscreen =\n fullscreenElement === (targetRef?.current || document.documentElement);\n if (newIsFullscreen !== isFullscreen) {\n setIsFullscreen(newIsFullscreen);\n onChange?.(newIsFullscreen);\n }\n }, [targetRef, onChange, isFullscreen]);\n\n // Listen for fullscreen changes\n useEffect(() => {\n addFullscreenChangeListener(handleFullscreenChange);\n return () => {\n removeFullscreenChangeListener(handleFullscreenChange);\n };\n }, [handleFullscreenChange]);\n\n const enterFullscreenFn = useCallback(async () => {\n const element = targetRef?.current || document.documentElement;\n await enterFullscreen(element);\n }, [targetRef]);\n\n const exitFullscreenFn = useCallback(async () => {\n await exitFullscreen();\n }, []);\n\n const toggleFullscreenFn = useCallback(async () => {\n if (isFullscreen) {\n await exitFullscreenFn();\n } else {\n await enterFullscreenFn();\n }\n }, [isFullscreen, enterFullscreenFn, exitFullscreenFn]);\n\n return {\n isFullscreen: isFullscreen,\n toggle: toggleFullscreenFn,\n enter: enterFullscreenFn,\n exit: exitFullscreenFn,\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Key, useCallback, useEffect, useMemo, useRef } from 'react';\n\n/**\n * Return type of useRefs hook, providing Map-like interface for managing refs.\n * @template T - The type of the ref instances.\n */\nexport interface UseRefsReturn<T> extends Iterable<[Key, T]> {\n register: (key: Key) => (instance: T | null) => void;\n get: (key: Key) => T | undefined;\n set: (key: Key, value: T) => void;\n delete: (key: Key) => boolean;\n has: (key: Key) => boolean;\n clear: () => void;\n readonly size: number;\n keys: () => IterableIterator<Key>;\n values: () => IterableIterator<T>;\n entries: () => IterableIterator<[Key, T]>;\n}\n\n/**\n * A React hook for managing multiple refs with a Map-like interface.\n * Allows dynamic registration and retrieval of refs by key, with automatic cleanup on unmount.\n *\n * @template T - The type of the ref instances (e.g., HTMLElement).\n * @returns An object with Map methods and a register function for managing refs.\n *\n * @example\n * ```tsx\n * const refs = useRefs<HTMLDivElement>();\n *\n * // Register a ref\n * const refCallback = refs.register('myDiv');\n * <div ref={refCallback} />\n *\n * // Access the ref\n * const element = refs.get('myDiv');\n * ```\n */\nexport function useRefs<T>(): UseRefsReturn<T> {\n const refs = useRef(new Map<Key, T>());\n const get = useCallback((key: Key) => refs.current.get(key), []);\n const set = useCallback(\n (key: Key, value: T) => refs.current.set(key, value),\n [],\n );\n const has = useCallback((key: Key) => refs.current.has(key), []);\n const deleteFn = useCallback((key: Key) => refs.current.delete(key), []);\n const clear = useCallback(() => refs.current.clear(), []);\n const keys = useCallback(() => refs.current.keys(), []);\n const values = useCallback(() => refs.current.values(), []);\n const entries = useCallback(() => refs.current.entries(), []);\n const iterator = useCallback(() => refs.current[Symbol.iterator](), []);\n const register = useCallback((key: Key) => {\n return (instance: T | null) => {\n if (instance) {\n refs.current.set(key, instance);\n } else {\n refs.current.delete(key);\n }\n };\n }, []);\n useEffect(() => {\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n refs.current.clear();\n };\n }, []);\n return useMemo(\n () => ({\n register,\n get,\n set,\n has,\n delete: deleteFn,\n clear,\n keys,\n values,\n entries,\n get size() {\n return refs.current.size;\n },\n [Symbol.iterator]: iterator,\n }),\n [register, get, set, has, deleteFn, clear, keys, values, entries, iterator],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useReducer } from 'react';\n\n/**\n * A React hook that returns a function to force a component to re-render.\n * This is useful when you need to trigger a re-render imperatively, such as\n * when dealing with external state changes or imperative updates.\n *\n * @returns A function that when called, forces the component to re-render\n *\n * @example\n * ```typescript\n * import { useForceUpdate } from '@ahoo-wang/fetcher-react';\n *\n * const MyComponent = () => {\n * const forceUpdate = useForceUpdate();\n *\n * const handleExternalChange = () => {\n * // Some external state change that doesn't trigger React re-render\n * externalLibrary.updateSomething();\n * forceUpdate(); // Force re-render to reflect changes\n * };\n *\n * return (\n * <div>\n * <p>Component state: {someValue}</p>\n * <button onClick={handleExternalChange}>Update External State</button>\n * </div>\n * );\n * };\n * ```\n */\nexport function useForceUpdate(): () => void {\n const [, forceUpdate] = useReducer(x => x + 1, 0);\n return forceUpdate;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useRef } from 'react';\nimport { AutoExecuteCapable } from '../types';\n\nexport interface QueryOptions<Q> {\n /** The initial query parameters to be stored and managed */\n initialQuery?: Q;\n /** The current query parameters. If provided, overrides initialQuery and updates the state. */\n query?: Q;\n}\n\n/**\n * Configuration options for the useQueryState hook\n * @template Q - The type of the query parameters\n */\nexport interface UseQueryStateOptions<Q>\n extends QueryOptions<Q>, AutoExecuteCapable {\n /** Function to execute with the current query parameters. Called when autoExecute is true */\n execute: (query: Q) => Promise<void>;\n}\n\n/**\n * Return type of the useQueryState hook\n * @template Q - The type of the query parameters\n */\nexport interface UseQueryStateReturn<Q> {\n /** Function to retrieve the current query parameters */\n getQuery: () => Q | undefined;\n /** Function to update the query parameters. Triggers execution if autoExecute is true */\n setQuery: (query: Q) => void;\n}\n\n/**\n * A React hook for managing query state with automatic execution capabilities\n *\n * This hook provides a centralized way to manage query parameters, including\n * getting and setting the current query, and optionally automatically executing\n * queries when the query changes or on component mount.\n *\n * @template Q - The type of the query parameters, which can be any object type representing query data\n * @param options - Configuration options for the hook\n * @param options.initialQuery - Optional initial query parameters to be stored and managed. Used if no query is provided.\n * @param options.query - Optional current query parameters. If provided, overrides initialQuery and updates the state.\n * @param options.autoExecute - Boolean flag indicating whether to automatically execute the query on mount or when query changes. Defaults to true.\n * @param options.execute - Function to execute with the current query parameters. Called when autoExecute is true and query changes.\n * @returns An object containing functions to manage the query state\n * @returns getQuery - Function that returns the current query parameters of type Q\n * @returns setQuery - Function that updates the query parameters and triggers execution if autoExecute is enabled\n *\n * @example\n * ```typescript\n * interface UserQuery {\n * id: string;\n * name?: string;\n * }\n *\n * function UserComponent() {\n * const executeQuery = async (query: UserQuery) => {\n * // Perform query execution logic here\n * console.log('Executing query:', query);\n * };\n *\n * const { getQuery, setQuery } = useQueryState<UserQuery>({\n * initialQuery: { id: '1' },\n * autoExecute: true,\n * execute: executeQuery,\n * });\n *\n * const handleQueryChange = (newQuery: UserQuery) => {\n * setQuery(newQuery); // Will automatically execute if autoExecute is true\n * };\n *\n * const currentQuery = getQuery(); // Get current query parameters\n *\n * return (\n * <div>\n * <button onClick={() => handleQueryChange({ id: '2', name: 'John' })}>\n * Update Query\n * </button>\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * // Example with autoExecute disabled\n * const { getQuery, setQuery } = useQueryState<UserQuery>({\n * initialQuery: { id: '1' },\n * autoExecute: false,\n * execute: executeQuery,\n * });\n *\n * // Manually trigger execution\n * setQuery({ id: '2' });\n * executeQuery(getQuery());\n *\n * @throws {Error} Throws an error if neither initialQuery nor query is provided in the options.\n * @throws Exceptions may also be thrown by the execute function if it encounters errors during query execution.\n */\nexport function useQueryState<Q>(\n options: UseQueryStateOptions<Q>,\n): UseQueryStateReturn<Q> {\n const { initialQuery, query, autoExecute = true, execute } = options;\n const queryOptions = query ?? initialQuery;\n const queryRef = useRef<Q>(queryOptions);\n\n const getQuery = useCallback(() => {\n return queryRef.current;\n }, []);\n\n const executeWrapper = useCallback(() => {\n const currentQuery = getQuery();\n if (autoExecute && isValidateQuery(currentQuery)) {\n execute(currentQuery);\n }\n }, [autoExecute, execute, getQuery]);\n const setQuery = useCallback(\n (query: Q) => {\n queryRef.current = query;\n executeWrapper();\n },\n [queryRef, executeWrapper],\n );\n\n useEffect(() => {\n if (isValidateQuery(query)) {\n queryRef.current = query;\n }\n executeWrapper();\n }, [executeWrapper, query]);\n\n return { getQuery, setQuery };\n}\n\nexport function isValidateQuery<Q>(query: Q | undefined): query is Q {\n return query !== undefined;\n}","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n useExecutePromise,\n useLatest,\n UseExecutePromiseReturn,\n UseExecutePromiseOptions,\n PromiseSupplier, QueryOptions, isValidateQuery,\n} from './index';\nimport { useCallback, useMemo } from 'react';\nimport { AttributesCapable, FetcherError } from '@ahoo-wang/fetcher';\nimport { useQueryState, UseQueryStateReturn } from './useQueryState';\nimport { AutoExecuteCapable } from '../types';\n\n/**\n * Configuration options for the useQuery hook\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value\n */\nexport interface UseQueryOptions<Q, R, E = FetcherError>\n extends UseExecutePromiseOptions<R, E>,\n QueryOptions<Q>,\n AttributesCapable,\n AutoExecuteCapable {\n\n /** Function to execute the query with given parameters and optional attributes */\n execute: (\n query: Q,\n attributes?: Record<string, any>,\n abortController?: AbortController,\n ) => Promise<R>;\n}\n\n/**\n * Return type of the useQuery hook\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value\n */\nexport interface UseQueryReturn<\n Q,\n R,\n E = FetcherError,\n> extends UseExecutePromiseReturn<R, E>, UseQueryStateReturn<Q> {\n /** Function to execute the query with current parameters */\n execute: () => Promise<void>;\n}\n\n\n/**\n * A React hook for managing query-based asynchronous operations\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value\n * @param options - Configuration options for the query\n * @returns An object containing the query state and control functions\n *\n * @example\n * ```typescript\n * import { useQuery } from '@ahoo-wang/fetcher-react';\n *\n * interface UserQuery {\n * id: string;\n * }\n *\n * interface User {\n * id: string;\n * name: string;\n * }\n *\n * function UserComponent() {\n * const { loading, result, error, execute, setQuery } = useQuery<UserQuery, User>({\n * initialQuery: { id: '1' },\n * execute: async (query) => {\n * const response = await fetch(`/api/users/${query.id}`);\n * return response.json();\n * },\n * autoExecute: true,\n * });\n *\n * const handleUserChange = (userId: string) => {\n * setQuery({ id: userId }); // Automatically executes if autoExecute is true\n * };\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * return (\n * <div>\n * <button onClick={() => handleUserChange('2')}>Load User 2</button>\n * {result && <p>User: {result.name}</p>}\n * </div>\n * );\n * }\n * ```\n */\nexport function useQuery<Q, R, E = FetcherError>(\n options: UseQueryOptions<Q, R, E>,\n): UseQueryReturn<Q, R, E> {\n const latestOptionsRef = useLatest(options);\n const {\n loading,\n result,\n error,\n status,\n execute: promiseExecutor,\n reset,\n abort,\n } = useExecutePromise<R, E>(options);\n\n const execute = useCallback(\n (query: Q) => {\n const queryExecutor: PromiseSupplier<R> = async (\n abortController: AbortController,\n ): Promise<R> => {\n return latestOptionsRef.current.execute(\n query,\n latestOptionsRef.current.attributes,\n abortController,\n );\n };\n return promiseExecutor(queryExecutor);\n },\n [promiseExecutor, latestOptionsRef],\n );\n\n const { getQuery, setQuery } = useQueryState({\n initialQuery: options.initialQuery,\n query: options.query,\n autoExecute: options.autoExecute,\n execute,\n });\n\n const executeWrapper = useCallback(async () => {\n const query = getQuery();\n if (isValidateQuery(query)) {\n return await execute(query);\n }\n }, [execute, getQuery]);\n\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n execute: executeWrapper,\n reset,\n abort,\n getQuery,\n setQuery,\n }),\n [\n loading,\n result,\n error,\n status,\n executeWrapper,\n reset,\n abort,\n getQuery,\n setQuery,\n ],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useSyncExternalStore } from 'react';\nimport { KeyStorage } from '@ahoo-wang/fetcher-storage';\nimport { nameGenerator } from '@ahoo-wang/fetcher-eventbus';\n\nexport function useKeyStorage<T>(\n keyStorage: KeyStorage<T>,\n): [T | null, (value: T) => void, () => void];\n\nexport function useKeyStorage<T>(\n keyStorage: KeyStorage<T>,\n defaultValue: T,\n): [T, (value: T) => void, () => void];\n\n/**\n * A React hook that provides reactive state management for a KeyStorage instance.\n *\n * This hook creates a reactive connection to a KeyStorage instance, automatically subscribing\n * to storage changes and updating the component state when the stored value changes.\n * It leverages React's `useSyncExternalStore` for optimal performance and proper SSR support.\n *\n * The hook provides two usage patterns:\n * 1. Without a default value: Returns nullable state that reflects the storage state\n * 2. With a default value: Returns non-nullable state, using the default when storage is empty\n *\n * @template T - The type of value stored in the key storage\n * @param keyStorage - The KeyStorage instance to subscribe to and manage. This should be a\n * stable reference (useRef, memo, or module-level instance)\n * @param defaultValue - Optional default value to use when storage is empty.\n * When provided, the returned value is guaranteed to be non-null.\n * @returns A tuple containing the current stored value (or default/null), a function to update it,\n * and a function to remove the stored value.\n * The value will be null if no default is provided and storage is empty.\n * @throws {Error} Propagates errors from KeyStorage operations, such as serialization failures\n * or storage access errors that may occur during get, set, or remove operations.\n *\n * @example\n * ```typescript\n * import { useKeyStorage } from '@ahoo-wang/fetcher-react';\n * import { KeyStorage } from '@ahoo-wang/fetcher-storage';\n *\n * // Create a storage instance (typically at module level or with useRef)\n * const userStorage = new KeyStorage<string>('user');\n *\n * function UserProfile() {\n * // Without default value - can be null\n * const [userName, setUserName, removeUserName] = useKeyStorage(userStorage);\n *\n * return (\n * <div>\n * <p>Current user: {userName || 'Not logged in'}</p>\n * <button onClick={() => setUserName('John Doe')}>\n * Set User\n * </button>\n * <button onClick={removeUserName}>\n * Logout\n * </button>\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```typescript\n * // With default value - guaranteed to be non-null\n * const [theme, setTheme, resetTheme] = useKeyStorage(themeStorage, 'light');\n *\n * return (\n * <div className={theme}>\n * <button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>\n * Toggle Theme\n * </button>\n * <button onClick={resetTheme}>\n * Reset to Default\n * </button>\n * </div>\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Using with complex objects\n * const [userPrefs, setUserPrefs, clearPrefs] = useKeyStorage(preferencesStorage, {\n * theme: 'light',\n * language: 'en',\n * notifications: true\n * });\n *\n * // Update specific properties\n * const updateTheme = (newTheme: string) => {\n * setUserPrefs({ ...userPrefs, theme: newTheme });\n * };\n *\n * // Clear all preferences\n * const resetPrefs = () => clearPrefs();\n * ```\n */\nexport function useKeyStorage<T>(\n keyStorage: KeyStorage<T>,\n defaultValue?: T,\n): [T | null, (value: T) => void, () => void] {\n // Create subscription function for useSyncExternalStore\n // This function returns an unsubscribe function that will be called on cleanup\n const subscribe = useCallback(\n (callback: () => void) => {\n return keyStorage.addListener({\n name: nameGenerator.generate('useKeyStorage'), // Generate unique listener name\n handle: callback, // Callback to trigger React re-render on storage changes\n });\n },\n [keyStorage], // Recreate subscription only if keyStorage changes\n );\n\n // Create snapshot function that returns current storage state\n // This function is called by useSyncExternalStore to get the current value\n const getSnapshot = useCallback(() => {\n const storedValue = keyStorage.get();\n // Return stored value if it exists, otherwise return default value or null\n return storedValue !== null ? storedValue : (defaultValue ?? null);\n }, [keyStorage, defaultValue]); // Recreate snapshot when dependencies change\n\n // Use React's useSyncExternalStore for reactive external store connection\n // This ensures proper subscription management and SSR compatibility\n const value = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\n // Create stable setter function reference\n // This function updates the storage and triggers re-renders in subscribed components\n const setValue = useCallback(\n (value: T) => keyStorage.set(value),\n [keyStorage], // Recreate setter only if keyStorage changes\n );\n\n // Create stable remover function reference\n // This function removes the stored value and triggers re-renders\n const remove = useCallback(\n () => keyStorage.remove(),\n [keyStorage], // Recreate remover only if keyStorage changes\n );\n\n // Return tuple of current value, setter function, and remover function\n return [value, setValue, remove];\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback } from 'react';\nimport { KeyStorage } from '@ahoo-wang/fetcher-storage';\nimport { useKeyStorage } from './useKeyStorage';\nimport { produce } from 'immer';\n\nexport function useImmerKeyStorage<T>(\n keyStorage: KeyStorage<T>,\n): [T | null, (updater: (draft: T | null) => T | null | void) => void, () => void];\n\nexport function useImmerKeyStorage<T>(\n keyStorage: KeyStorage<T>,\n defaultValue: T,\n): [T, (updater: (draft: T) => T | null | void) => void, () => void];\n/**\n * A React hook that provides Immer-based immutable state management for a KeyStorage instance.\n *\n * This hook extends `useKeyStorage` by integrating Immer's `produce` function, allowing\n * developers to perform \"mutable\" updates on the stored value in an immutable way. It creates\n * a reactive connection to a KeyStorage instance, automatically subscribing to storage changes\n * and updating the component state when the stored value changes. It leverages React's\n * `useSyncExternalStore` for optimal performance and proper SSR support.\n *\n * The hook provides two usage patterns:\n * 1. Without a default value: Returns nullable state that reflects the storage state\n * 2. With a default value: Returns non-nullable state, using the default when storage is empty\n *\n * The updater function allows modifying a draft of the current value, providing an intuitive\n * mutable API while maintaining immutability under the hood.\n *\n * @template T - The type of value stored in the key storage\n * @param keyStorage - The KeyStorage instance to subscribe to and manage. This should be a\n * stable reference (useRef, memo, or module-level instance)\n * @param defaultValue - Optional default value to use when storage is empty.\n * When provided, the returned value is guaranteed to be non-null.\n * @returns A tuple containing the current stored value (or default/null), an Immer-based updater function,\n * and a function to remove the stored value.\n * The value will be null if no default is provided and storage is empty.\n * @throws {Error} Propagates errors from KeyStorage operations, such as serialization failures\n * or storage access errors that may occur during get, set, or remove operations.\n * Also propagates errors from the updater function or Immer's produce.\n *\n * @example\n * ```typescript\n * import { useImmerKeyStorage } from '@ahoo-wang/fetcher-react';\n * import { KeyStorage } from '@ahoo-wang/fetcher-storage';\n *\n * // Create a storage instance (typically at module level or with useRef)\n * const userPrefsStorage = new KeyStorage<{ theme: string; lang: string }>('user-prefs');\n *\n * function UserPreferences() {\n * // Without default value - can be null\n * const [prefs, updatePrefs, clearPrefs] = useImmerKeyStorage(userPrefsStorage);\n *\n * return (\n * <div>\n * <p>Theme: {prefs?.theme || 'default'}</p>\n * <button onClick={() => updatePrefs(draft => { draft.theme = 'dark'; })}>\n * Switch to Dark Theme\n * </button>\n * <button onClick={clearPrefs}>\n * Clear Preferences\n * </button>\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```typescript\n * // With default value - guaranteed to be non-null\n * const [settings, updateSettings, resetSettings] = useImmerKeyStorage(settingsStorage, {\n * volume: 50,\n * muted: false\n * });\n *\n * return (\n * <div>\n * <p>Volume: {settings.volume}</p>\n * <button onClick={() => updateSettings(draft => { draft.volume += 10; })}>\n * Increase Volume\n * </button>\n * <button onClick={() => updateSettings(draft => { draft.muted = !draft.muted; })}>\n * Toggle Mute\n * </button>\n * <button onClick={resetSettings}>\n * Reset to Default\n * </button>\n * </div>\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Returning a new value instead of modifying draft\n * const [counter, updateCounter, resetCounter] = useImmerKeyStorage(counterStorage, 0);\n *\n * return (\n * <div>\n * <p>Count: {counter}</p>\n * <button onClick={() => updateCounter(draft => draft + 1)}>\n * Increment\n * </button>\n * <button onClick={() => updateCounter(() => 0)}>\n * Reset to Zero\n * </button>\n * </div>\n * );\n * ```\n */\nexport function useImmerKeyStorage<T>(\n keyStorage: KeyStorage<T>,\n defaultValue?: T,\n): [\n T | null,\n (updater: (draft: T | null) => T | null | void) => void,\n () => void,\n] {\n const [value, setValue, remove] = useKeyStorage<T>(\n keyStorage,\n defaultValue as T,\n );\n const updateImmer = useCallback(\n (updater: (draft: T | null) => T | null | void) => {\n const nextValue = produce(value, updater);\n if (nextValue === null) {\n remove();\n return;\n }\n return setValue(nextValue);\n },\n [value, setValue, remove],\n );\n\n return [value, updateImmer, remove];\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback } from 'react';\nimport { useKeyStorage } from '../storage';\nimport {\n TokenStorage,\n CompositeToken,\n CoSecJwtPayload,\n} from '@ahoo-wang/fetcher-cosec';\nimport { useLatest } from '../core';\n\n/**\n * Type representing a composite token provider.\n * Can be either a direct composite token or a function that returns a promise of a composite token.\n */\ntype CompositeTokenProvider = CompositeToken | (() => Promise<CompositeToken>);\n\nexport const ANONYMOUS_USER: CoSecJwtPayload = {\n jti: '',\n sub: 'anonymous',\n iat: 0,\n exp: 0,\n};\n\n/**\n * Options for configuring the useSecurity hook.\n */\nexport interface UseSecurityOptions {\n /**\n * Callback function invoked when sign in is successful.\n * This is called after the token has been successfully stored.\n */\n onSignIn?: () => void;\n\n /**\n * Callback function invoked when sign out occurs.\n * This is called after the token has been removed.\n */\n onSignOut?: () => void;\n}\n\n/**\n * Return type for the useSecurity hook.\n */\nexport interface UseSecurityReturn {\n /**\n * The current authenticated user's JWT payload, or ANONYMOUS_USER if not authenticated.\n * Contains user information extracted from the access token.\n */\n currentUser: CoSecJwtPayload;\n\n /**\n * Boolean indicating whether the user is currently authenticated.\n * True if a valid token exists and the user is signed in, false otherwise.\n */\n authenticated: boolean;\n\n /**\n * Function to sign in with a composite token or a function that returns a promise of composite token.\n * @param compositeTokenProvider - Either a composite token containing access and refresh tokens,\n * or a function that returns a promise resolving to a composite token.\n * @returns A promise that resolves when the sign-in operation is complete.\n */\n signIn: (compositeTokenProvider: CompositeTokenProvider) => Promise<void>;\n\n /**\n * Function to sign out the current user.\n */\n signOut: () => void;\n}\n\n/**\n * Hook for managing authentication state and operations using CoSec tokens.\n *\n * This hook provides reactive access to the current user information, authentication status,\n * and methods to sign in and sign out. It integrates with the TokenStorage to persist tokens\n * and updates the state reactively when tokens change.\n *\n * @param tokenStorage - The token storage instance used to manage authentication tokens.\n * This should be a valid TokenStorage implementation that handles\n * token persistence and retrieval.\n * @param options - Optional configuration object containing lifecycle callbacks.\n * @param options.onSignIn - Callback function invoked when sign in is successful.\n * @param options.onSignOut - Callback function invoked when sign out occurs.\n * @returns An object containing:\n * - currentUser: The current authenticated user's JWT payload, or null if not authenticated.\n * - authenticated: Boolean indicating whether the user is currently authenticated.\n * - signIn: Function to authenticate with a composite token.\n * - signOut: Function to sign out the current user.\n * @throws {Error} May throw errors if tokenStorage operations fail, such as invalid tokens\n * or storage access issues (implementation dependent).\n * @example\n * ```typescript\n * import { useSecurity } from '@ahoo-wang/fetcher-react';\n * import { tokenStorage } from './tokenStorage';\n * import { useNavigate } from 'react-router-dom';\n *\n * function App() {\n * const navigate = useNavigate();\n *\n * const { currentUser, authenticated, signIn, signOut } = useSecurity(tokenStorage, {\n * onSignIn: () => {\n * // Redirect to dashboard after successful login\n * navigate('/dashboard');\n * },\n * onSignOut: () => {\n * // Redirect to login page after logout\n * navigate('/login');\n * }\n * });\n *\n * const handleSignIn = async () => {\n * // Direct token\n * await signIn(compositeToken);\n *\n * // Or async function\n * await signIn(async () => {\n * const response = await fetch('/api/auth/login', {\n * method: 'POST',\n * body: JSON.stringify({ username, password })\n * });\n * return response.json();\n * });\n * };\n *\n * if (!authenticated) {\n * return <button onClick={handleSignIn}>Sign In</button>;\n * }\n *\n * return (\n * <div>\n * <p>Welcome, {currentUser?.sub}!</p>\n * <button onClick={signOut}>Sign Out</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useSecurity(\n tokenStorage: TokenStorage,\n options: UseSecurityOptions = {},\n): UseSecurityReturn {\n // Use useKeyStorage to get reactive updates when token changes\n const [token, , remove] = useKeyStorage(tokenStorage);\n const optionsRef = useLatest(options);\n const signIn = useCallback(\n async (compositeTokenProvider: CompositeTokenProvider) => {\n const compositeToken =\n typeof compositeTokenProvider === 'function'\n ? await compositeTokenProvider()\n : compositeTokenProvider;\n tokenStorage.signIn(compositeToken);\n optionsRef.current.onSignIn?.();\n },\n [tokenStorage, optionsRef],\n );\n const signOut = useCallback(() => {\n remove();\n optionsRef.current.onSignOut?.();\n }, [remove, optionsRef]);\n\n return {\n currentUser: token?.access?.payload ?? ANONYMOUS_USER,\n authenticated: token?.authenticated ?? false,\n signIn,\n signOut,\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n useSecurity,\n UseSecurityOptions,\n UseSecurityReturn,\n} from './useSecurity';\nimport { createContext, ReactNode, useContext } from 'react';\nimport { TokenStorage } from '@ahoo-wang/fetcher-cosec';\n\n/**\n * Type alias for the security context value, representing the authentication state and methods.\n * This is equivalent to the return type of the useSecurity hook, providing reactive access to:\n * - Current authenticated user information (JWT payload)\n * - Authentication status (boolean flag)\n * - Sign-in method for authenticating users\n * - Sign-out method for clearing authentication\n *\n * Used internally by the SecurityContext to type the context value.\n */\nexport type SecurityContext = UseSecurityReturn;\n\n/**\n * React context for managing authentication state across the component tree.\n * This context enables sharing of authentication state and methods between components\n * without prop drilling. Components can access authentication data and methods through\n * the useSecurityContext hook when wrapped by the SecurityProvider.\n *\n * The context value is undefined by default, requiring components to be wrapped by\n * SecurityProvider to access authentication functionality.\n */\nexport const SecurityContext = createContext<SecurityContext | undefined>(\n undefined,\n);\n\n/**\n * Configuration options for the SecurityProvider component.\n * Extends UseSecurityOptions to include provider-specific settings like token storage and children.\n */\nexport interface SecurityContextOptions extends UseSecurityOptions {\n /**\n * The token storage instance used to manage authentication tokens.\n * This should be a valid TokenStorage implementation that handles token persistence,\n * retrieval, and lifecycle management across different storage backends (localStorage,\n * sessionStorage, memory, etc.).\n */\n tokenStorage: TokenStorage;\n\n /**\n * The child components that will have access to the security context.\n * These components can use the useSecurityContext hook to access authentication state and methods.\n */\n children: ReactNode;\n}\n\n/**\n * Provider component that supplies authentication state and methods to its child components.\n * This component wraps the application or a portion of it to provide access to authentication\n * functionality through the useSecurityContext hook. It internally uses the useSecurity hook\n * to manage authentication state and makes it available via React context.\n *\n * @param tokenStorage - The token storage instance for managing authentication tokens.\n * This should be a valid TokenStorage implementation that handles\n * token persistence, retrieval, and lifecycle management across different\n * storage backends (localStorage, sessionStorage, memory, etc.).\n * @param children - The child components that will have access to the security context.\n * These components can use the useSecurityContext hook to access authentication\n * state and methods without prop drilling.\n * @param useSecurityOptions - Optional configuration object containing lifecycle callbacks\n * for sign-in and sign-out events. Extends UseSecurityOptions interface.\n * @param useSecurityOptions.onSignIn - Callback function invoked when sign in is successful.\n * @param useSecurityOptions.onSignOut - Callback function invoked when sign out occurs.\n * @returns A React element that provides the security context to its children.\n * The context value includes currentUser, authenticated status, signIn, and signOut methods.\n * @throws {Error} May throw errors if tokenStorage operations fail during initialization,\n * such as invalid tokens or storage access issues (implementation dependent).\n * @example\n * ```tsx\n * import { SecurityProvider } from '@ahoo-wang/fetcher-react';\n * import { tokenStorage } from './tokenStorage';\n * import { useNavigate } from 'react-router-dom';\n *\n * function App() {\n * const navigate = useNavigate();\n *\n * return (\n * <SecurityProvider\n * tokenStorage={tokenStorage}\n * onSignIn={() => navigate('/dashboard')}\n * onSignOut={() => navigate('/login')}\n * >\n * <MyApp />\n * </SecurityProvider>\n * );\n * }\n * ```\n */\nexport function SecurityProvider({\n tokenStorage,\n children,\n ...useSecurityOptions\n}: SecurityContextOptions) {\n const value = useSecurity(tokenStorage, useSecurityOptions);\n return (\n <SecurityContext.Provider value={value}>\n {children}\n </SecurityContext.Provider>\n );\n}\n\n/**\n * Hook to access the security context within components wrapped by SecurityProvider.\n * This hook provides reactive access to authentication state and methods throughout the component tree.\n *\n * @returns The security context containing currentUser, authenticated status, signIn, and signOut methods.\n * @throws {Error} Throws an error if used outside of a SecurityProvider component.\n * @example\n * ```tsx\n * import { useSecurityContext } from '@ahoo-wang/fetcher-react';\n *\n * function UserProfile() {\n * const { currentUser, authenticated, signOut } = useSecurityContext();\n *\n * if (!authenticated) {\n * return <div>Please sign in</div>;\n * }\n *\n * return (\n * <div>\n * <p>Welcome, {currentUser?.sub}!</p>\n * <button onClick={signOut}>Sign Out</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useSecurityContext(): SecurityContext {\n const context = useContext(SecurityContext);\n if (!context) {\n throw new Error(\n 'useSecurityContext must be used within a SecurityProvider',\n );\n }\n return context;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ReactNode } from 'react';\nimport { useSecurityContext } from './SecurityContext';\n\n/**\n * Props for the RouteGuard component.\n */\nexport interface RouteGuardProps {\n /**\n * The content to render when the user is authenticated.\n */\n children: ReactNode;\n\n /**\n * The fallback content to render when the user is not authenticated.\n * If not provided, nothing will be rendered.\n */\n fallback?: ReactNode;\n\n /**\n * Optional redirect function to call when user is not authenticated.\n * This can be used to programmatically navigate to a login page.\n */\n onUnauthorized?: () => void;\n}\n\n/**\n * Route guard component that conditionally renders content based on authentication status.\n *\n * This component uses the SecurityContext to check if the user is authenticated.\n * If authenticated, it renders the children. If not authenticated, it renders the fallback\n * content (if provided) and optionally calls the onUnauthorized callback.\n *\n * @param children - The protected content to render when authenticated.\n * @param fallback - Optional fallback content to render when not authenticated.\n * @param onUnauthorized - Optional callback to execute when user is not authenticated.\n * @returns The children if authenticated, fallback if provided, or null otherwise.\n * @example\n * ```tsx\n * import { RouteGuard } from '@ahoo-wang/fetcher-react';\n *\n * function ProtectedPage() {\n * return (\n * <RouteGuard\n * fallback={<div>Please log in to access this page.</div>}\n * onUnauthorized={() => navigate('/login')}\n * >\n * <div>Protected content</div>\n * </RouteGuard>\n * );\n * }\n * ```\n */\nexport function RouteGuard({\n children,\n fallback,\n onUnauthorized,\n}: RouteGuardProps) {\n const { authenticated } = useSecurityContext();\n\n if (authenticated) {\n return <>{children}</>;\n }\n\n // Call onUnauthorized callback if provided\n if (onUnauthorized) {\n onUnauthorized();\n }\n\n // Return fallback if provided, otherwise return null\n return fallback;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RouteGuardProps } from './RouteGuard';\nimport { ReactNode, useCallback, useEffect } from 'react';\nimport { JwtTokenManager } from '@ahoo-wang/fetcher-cosec';\nimport { useSecurityContext } from './SecurityContext';\n\nexport interface RefreshableRouteGuardProps extends Omit<RouteGuardProps, 'onUnauthorized'> {\n refreshing?: ReactNode;\n tokenManager: JwtTokenManager;\n}\n\nexport function RefreshableRouteGuard({\n children,\n fallback,\n refreshing,\n tokenManager,\n }: RefreshableRouteGuardProps) {\n const { authenticated } = useSecurityContext();\n const refreshable = tokenManager.isRefreshNeeded && tokenManager.isRefreshable;\n const refreshToken = useCallback(async () => {\n if (refreshable) {\n try {\n await tokenManager.refresh();\n } catch (error) {\n console.error(error);\n }\n }\n }, [refreshable, tokenManager]);\n\n useEffect(() => {\n refreshToken();\n }, [refreshToken]);\n\n if (authenticated) {\n return <>{children}</>;\n }\n\n if (!refreshable) {\n return <>{fallback}</>;\n }\n const refreshingNode = refreshing ?? <p>Refreshing...</p>;\n return <>{refreshingNode}</>;\n\n}","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n fetcherRegistrar,\n FetcherCapable,\n FetchExchange,\n FetchRequest,\n getFetcher,\n RequestOptions,\n FetcherError,\n} from '@ahoo-wang/fetcher';\nimport {\n useExecutePromise,\n UseExecutePromiseOptions,\n UseExecutePromiseReturn,\n} from '../core';\nimport { useCallback, useState, useMemo } from 'react';\nimport { useLatest } from '../core';\n\n/**\n * Configuration options for the useFetcher hook.\n * Combines request configuration, fetcher selection, and promise state management options.\n *\n * @template R - The type of the expected result from the fetch operation\n * @template E - The type of error that may be thrown (defaults to FetcherError)\n */\nexport interface UseFetcherOptions<R, E = FetcherError>\n extends RequestOptions,\n FetcherCapable,\n UseExecutePromiseOptions<R, E> {}\n\n/**\n * Return type of the useFetcher hook.\n * Provides access to the current fetch state, result data, and control functions.\n *\n * @template R - The type of the expected result from the fetch operation\n * @template E - The type of error that may be thrown (defaults to FetcherError)\n */\nexport interface UseFetcherReturn<R, E = FetcherError>\n extends Omit<UseExecutePromiseReturn<R, E>, 'execute'> {\n /**\n * The FetchExchange object representing the current or most recent fetch operation.\n * Contains request/response details, timing information, and extracted data.\n * Undefined when no fetch operation has been performed.\n */\n exchange?: FetchExchange;\n\n /**\n * Function to execute a fetch request with automatic abort support.\n * Automatically cancels any ongoing request before starting a new one using AbortController.\n * The abort controller is automatically passed to the underlying fetch operation.\n *\n * @param request - The fetch request configuration including URL, method, headers, etc.\n * @returns Promise that resolves when the fetch operation completes (success or failure)\n */\n execute: (request: FetchRequest) => Promise<void>;\n}\n\n/**\n * A React hook for managing asynchronous HTTP fetch operations with comprehensive state handling,\n * race condition protection, automatic cleanup, and built-in abort support. Provides a clean interface\n * for making API calls with loading states, error handling, and request cancellation.\n *\n * Key features:\n * - Automatic request cancellation on component unmount or new requests via AbortController\n * - Race condition protection using request IDs\n * - Comprehensive state management (idle, loading, success, error)\n * - Type-safe result and error handling\n * - Integration with fetcher ecosystem for advanced features\n * - Memory leak prevention with automatic abort controller cleanup\n *\n * @template R - The type of the expected result from the fetch operation\n * @template E - The type of error that may be thrown (defaults to FetcherError)\n * @param options - Configuration options for the fetcher including request settings,\n * result extraction, error handling, and fetcher selection\n * @returns An object containing the current fetch state, result data, error information,\n * and the execute function to trigger fetch operations\n *\n * @throws {FetcherError} When the fetch operation fails due to network issues,\n * HTTP errors, or result extraction problems\n * @throws {Error} When invalid options are provided or fetcher configuration is incorrect\n *\n * @example Basic GET request with automatic abort\n * ```typescript\n * import { useFetcher } from '@ahoo-wang/fetcher-react';\n * import { ResultExtractors } from '@ahoo-wang/fetcher';\n *\n * function UserProfile({ userId }: { userId: string }) {\n * const { loading, result, error, execute } = useFetcher({\n * resultExtractor: ResultExtractors.Json,\n * });\n *\n * const fetchUser = () => {\n * execute({\n * url: `/api/users/${userId}`,\n * method: 'GET'\n * });\n * };\n *\n * // Multiple calls to fetchUser() will automatically cancel previous requests\n * // Handle loading, error, and success states in your component\n * }\n * ```\n *\n * @example POST request with error handling\n * ```typescript\n * import { useFetcher } from '@ahoo-wang/fetcher-react';\n *\n * function CreatePost() {\n * const { loading, result, error, execute } = useFetcher({\n * onSuccess: (data) => {\n * console.log('Post created:', data);\n * // Handle success (e.g., redirect, show notification)\n * },\n * onError: (error) => {\n * console.error('Failed to create post:', error);\n * // Handle error (e.g., show error message)\n * }\n * });\n *\n * const handleSubmit = (postData: { title: string; content: string }) => {\n * execute({\n * url: '/api/posts',\n * method: 'POST',\n * body: JSON.stringify(postData),\n * headers: {\n * 'Content-Type': 'application/json'\n * }\n * });\n * };\n * }\n * ```\n *\n * @example Using custom fetcher instance\n * ```typescript\n * import { useFetcher } from '@ahoo-wang/fetcher-react';\n * import { getFetcher } from '@ahoo-wang/fetcher';\n *\n * // Using a named fetcher instance\n * const customFetcher = getFetcher('my-custom-fetcher');\n *\n * function CustomApiComponent() {\n * const { loading, result, execute } = useFetcher({\n * fetcher: customFetcher,\n * });\n *\n * // All requests will use the custom fetcher configuration\n * const fetchData = () => execute({ url: '/data', method: 'GET' });\n * }\n * ```\n */\nexport function useFetcher<R, E = FetcherError>(\n options?: UseFetcherOptions<R, E>,\n): UseFetcherReturn<R, E> {\n const { fetcher = fetcherRegistrar.default } = options || {};\n const {\n loading,\n result,\n error,\n status,\n execute: promiseExecutor,\n reset,\n abort,\n } = useExecutePromise<R, E>(options);\n const [exchange, setExchange] = useState<FetchExchange | undefined>(\n undefined,\n );\n const latestOptions = useLatest(options);\n const currentFetcher = getFetcher(fetcher);\n /**\n * Execute the fetch operation with automatic abort support.\n * Cancels any ongoing fetch before starting a new one using AbortController.\n * The abort controller is automatically attached to the request for cancellation support.\n */\n const execute = useCallback(\n async (request: FetchRequest) => {\n try {\n await promiseExecutor(async abortController => {\n request.abortController = abortController;\n const exchange = await currentFetcher.exchange(\n request,\n latestOptions.current,\n );\n setExchange(exchange);\n return await exchange.extractResult<R>();\n });\n } catch (error) {\n setExchange(undefined);\n throw error;\n }\n },\n [promiseExecutor, currentFetcher, latestOptions],\n );\n\n const resetFn = useCallback(() => {\n reset();\n setExchange(undefined);\n }, [reset]);\n const abortFn = useCallback(() => {\n abort();\n setExchange(undefined);\n }, [abort]);\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n exchange,\n execute,\n reset: resetFn,\n abort: abortFn,\n }),\n [loading, result, error, status, exchange, execute, resetFn, abortFn],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useFetcher, UseFetcherOptions, UseFetcherReturn } from '../useFetcher';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport {\n DebounceCapable,\n useDebouncedCallback,\n UseDebouncedCallbackReturn,\n} from '../../core';\nimport { useMemo } from 'react';\n\n/**\n * Configuration options for the useDebouncedFetcher hook.\n * Extends UseFetcherOptions with debouncing capabilities to control the rate\n * at which fetch requests are executed.\n *\n * @template R - The type of the fetch result\n * @template E - The type of the error (defaults to FetcherError)\n */\nexport interface UseDebouncedFetcherOptions<R, E = FetcherError>\n extends UseFetcherOptions<R, E>,\n DebounceCapable {}\n\n/**\n * Return type of the useDebouncedFetcher hook.\n * Provides the same state properties as useFetcher (except execute) along with\n * debounced execution controls.\n *\n * @template R - The type of the fetch result\n * @template E - The type of the error (defaults to FetcherError)\n */\nexport interface UseDebouncedFetcherReturn<R, E = FetcherError>\n extends Omit<UseFetcherReturn<R, E>, 'execute'>,\n UseDebouncedCallbackReturn<UseFetcherReturn<R, E>['execute']> {}\n\n/**\n * A React hook that provides a debounced version of the useFetcher hook.\n * This hook wraps the fetcher's execute function with debouncing to prevent\n * excessive API calls during rapid user interactions, such as typing in a search field.\n *\n * The debouncing behavior is controlled by the `debounce` option, which specifies\n * the delay and whether to execute on the leading edge, trailing edge, or both.\n *\n * @template R - The type of the fetch result\n * @template E - The type of the error (defaults to FetcherError)\n * @param options - Configuration options including fetcher settings and debounce parameters\n * @returns An object containing the fetch state and debounced execution controls\n *\n * @throws {Error} If the debounce delay is not a positive number\n * @throws {Error} If the fetcher configuration is invalid\n *\n * @example\n * ```typescript\n * import { useDebouncedFetcher } from '@ahoo-wang/fetcher-react';\n *\n * function SearchComponent() {\n * const { loading, result, error, run, cancel, isPending } = useDebouncedFetcher<string>({\n * debounce: { delay: 300, trailing: true },\n * onSuccess: (data) => console.log('Search results:', data),\n * onError: (err) => console.error('Search failed:', err),\n * });\n *\n * const handleSearch = (query: string) => {\n * if (query.trim()) {\n * run({ url: `/api/search?q=${encodeURIComponent(query)}`, method: 'GET' });\n * } else {\n * cancel(); // Cancel any pending search\n * }\n * };\n *\n * return (\n * <div>\n * <input\n * type=\"text\"\n * placeholder=\"Search...\"\n * onChange={(e) => handleSearch(e.target.value)}\n * />\n * {isPending() && <div>Searching...</div>}\n * {loading && <div>Loading...</div>}\n * {error && <div>Error: {error.message}</div>}\n * {result && <div>Results: {result}</div>}\n * </div>\n * );\n * }\n * ```\n *\n * @example Debounced form submission\n * ```typescript\n * const { run, cancel, isPending } = useDebouncedFetcher({\n * debounce: { delay: 500, leading: false, trailing: true },\n * onSuccess: () => console.log('Form submitted successfully'),\n * });\n *\n * const handleSubmit = (formData: FormData) => {\n * run({\n * url: '/api/submit',\n * method: 'POST',\n * body: formData,\n * });\n * };\n * ```\n */\nexport function useDebouncedFetcher<R, E = FetcherError>(\n options: UseDebouncedFetcherOptions<R, E>,\n): UseDebouncedFetcherReturn<R, E> {\n const { loading, result, error, status, exchange, execute, reset, abort } =\n useFetcher<R, E>(options);\n const { run, cancel, isPending } = useDebouncedCallback(\n execute,\n options.debounce,\n );\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n exchange,\n reset,\n abort,\n run,\n cancel,\n isPending,\n }),\n [\n loading,\n result,\n error,\n status,\n exchange,\n reset,\n abort,\n run,\n cancel,\n isPending,\n ],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport {\n DebounceCapable,\n useDebouncedCallback,\n UseDebouncedCallbackReturn,\n} from '../../core';\nimport { useCallback, useEffect, useMemo } from 'react';\nimport {\n useFetcherQuery,\n UseFetcherQueryOptions,\n UseFetcherQueryReturn,\n} from '../index';\n\n/**\n * Configuration options for the useDebouncedFetcherQuery hook.\n *\n * Extends UseFetcherQueryOptions with DebounceCapable to provide debouncing functionality.\n * The hook will automatically debounce fetcher query executions to prevent excessive API calls.\n * Note that autoExecute is overridden internally to false to ensure proper debouncing behavior.\n *\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value (defaults to FetcherError)\n */\nexport interface UseDebouncedFetcherQueryOptions<Q, R, E = FetcherError>\n extends UseFetcherQueryOptions<Q, R, E>, DebounceCapable {}\n\n/**\n * Return type of the useDebouncedFetcherQuery hook.\n *\n * Omits the original 'execute' method from UseFetcherQueryReturn and replaces it with\n * debounced execution methods from UseDebouncedCallbackReturn. Uses a custom setQuery function\n * that respects the original autoExecute setting.\n *\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value (defaults to FetcherError)\n */\nexport interface UseDebouncedFetcherQueryReturn<Q, R, E = FetcherError>\n extends\n Omit<UseFetcherQueryReturn<Q, R, E>, 'execute'>,\n UseDebouncedCallbackReturn<UseFetcherQueryReturn<Q, R, E>['execute']> {}\n\n/**\n * A React hook for managing debounced query-based HTTP requests with automatic execution.\n *\n * This hook combines fetcher query functionality with debouncing to provide a convenient way to\n * make POST requests where query parameters are sent as the request body, while preventing\n * excessive API calls during rapid user interactions.\n *\n * The hook supports automatic execution on mount and when query parameters change, but wraps\n * the execution in a debounced callback to optimize performance. Internally, it overrides\n * autoExecute to false and implements custom logic to respect the original autoExecute setting.\n * When autoExecute is enabled, queries triggered by setQuery will also be debounced.\n *\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value (defaults to FetcherError)\n * @param options - Configuration options for the hook, including url, initialQuery, and debounce settings\n * @returns An object containing fetcher state, query management functions, and debounced execution controls\n *\n * @example\n * ```typescript\n * import { useDebouncedFetcherQuery } from '@ahoo-wang/fetcher-react';\n *\n * interface SearchQuery {\n * keyword: string;\n * limit: number;\n * filters?: { category?: string };\n * }\n *\n * interface SearchResult {\n * items: Array<{ id: string; title: string }>;\n * total: number;\n * }\n *\n * function SearchComponent() {\n * const {\n * loading,\n * result,\n * error,\n * run,\n * cancel,\n * isPending,\n * setQuery,\n * getQuery,\n * } = useDebouncedFetcherQuery<SearchQuery, SearchResult>({\n * url: '/api/search',\n * initialQuery: { keyword: '', limit: 10 },\n * debounce: { delay: 300 }, // Debounce for 300ms\n * autoExecute: false, // Don't execute on mount\n * });\n *\n * const handleSearch = (keyword: string) => {\n * setQuery({ keyword, limit: 10 }); // This will trigger debounced execution if autoExecute was true\n * };\n *\n * const handleManualSearch = () => {\n * run(); // Manual debounced execution with current query\n * };\n *\n * const handleCancel = () => {\n * cancel(); // Cancel any pending debounced execution\n * };\n *\n * if (loading) return <div>Searching...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <input\n * type=\"text\"\n * onChange={(e) => handleSearch(e.target.value)}\n * placeholder=\"Search...\"\n * />\n * <button onClick={handleManualSearch} disabled={isPending()}>\n * {isPending() ? 'Searching...' : 'Search'}\n * </button>\n * <button onClick={handleCancel}>Cancel</button>\n * {result && (\n * <div>\n * Found {result.total} items:\n * {result.items.map(item => (\n * <div key={item.id}>{item.title}</div>\n * ))}\n * </div>\n * )}\n * </div>\n * );\n * }\n * ```\n *\n * @throws This hook may throw exceptions related to network requests, which should be\n * handled by the caller. The underlying fetcher may throw FetcherError or other network-related errors.\n * Invalid URL or malformed request options may also cause exceptions.\n */\nexport function useDebouncedFetcherQuery<Q, R, E = FetcherError>(\n options: UseDebouncedFetcherQueryOptions<Q, R, E>,\n): UseDebouncedFetcherQueryReturn<Q, R, E> {\n const originalAutoExecute = options.autoExecute;\n const debouncedExecuteOptions = {\n ...options,\n autoExecute: false,\n };\n const {\n loading,\n result,\n error,\n status,\n execute,\n reset,\n abort,\n getQuery,\n setQuery,\n } = useFetcherQuery(debouncedExecuteOptions);\n const { run, cancel, isPending } = useDebouncedCallback(\n execute,\n options.debounce,\n );\n const setQueryFn = useCallback(\n (query: Q) => {\n setQuery(query);\n if (originalAutoExecute) {\n run();\n }\n },\n [setQuery, run, originalAutoExecute],\n );\n useEffect(() => {\n if (originalAutoExecute) {\n run();\n }\n }, [run, originalAutoExecute]);\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n reset,\n abort,\n getQuery,\n setQuery: setQueryFn,\n run,\n cancel,\n isPending,\n }),\n [\n loading,\n result,\n error,\n status,\n reset,\n abort,\n getQuery,\n setQueryFn,\n run,\n cancel,\n isPending,\n ],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useFetcher, UseFetcherOptions, UseFetcherReturn } from './index';\nimport { FetcherError, FetchRequest, JsonResultExtractor } from '@ahoo-wang/fetcher';\nimport { isValidateQuery, QueryOptions, useLatest, useQueryState, UseQueryStateReturn } from '../core';\nimport { useCallback, useMemo } from 'react';\nimport { AutoExecuteCapable } from '../types';\n\n/**\n * Configuration options for the useFetcherQuery hook\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value\n */\nexport interface UseFetcherQueryOptions<Q, R, E = FetcherError>\n extends UseFetcherOptions<R, E>, QueryOptions<Q>, AutoExecuteCapable {\n /** The URL endpoint to send the POST request to */\n url: string;\n}\n\n/**\n * Return type of the useFetcherQuery hook\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value\n */\nexport interface UseFetcherQueryReturn<Q, R, E = FetcherError>\n extends UseFetcherReturn<R, E>, UseQueryStateReturn<Q> {\n /** Function to execute the query with current parameters */\n execute: () => Promise<void>;\n}\n\n/**\n * A React hook for managing query-based HTTP requests with automatic execution\n *\n * This hook combines the fetcher functionality with query state management to provide\n * a convenient way to make POST requests where query parameters are sent as the request body.\n * It supports automatic execution on mount and when query parameters change.\n *\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value (defaults to FetcherError)\n * @param options - Configuration options for the hook\n * @returns An object containing fetcher state, query management functions, and execution controls\n *\n * @example\n * ```typescript\n * import { useFetcherQuery } from '@ahoo-wang/fetcher-react';\n *\n * interface SearchQuery {\n * keyword: string;\n * limit: number;\n * filters?: { category?: string };\n * }\n *\n * interface SearchResult {\n * items: Array<{ id: string; title: string }>;\n * total: number;\n * }\n *\n * function SearchComponent() {\n * const {\n * loading,\n * result,\n * error,\n * execute,\n * setQuery,\n * getQuery,\n * } = useFetcherQuery<SearchQuery, SearchResult>({\n * url: '/api/search',\n * initialQuery: { keyword: '', limit: 10 },\n * autoExecute: false, // Don't execute on mount\n * });\n *\n * const handleSearch = (keyword: string) => {\n * setQuery({ keyword, limit: 10 }); // This will auto-execute if autoExecute was true\n * };\n *\n * const handleManualSearch = () => {\n * execute(); // Manual execution with current query\n * };\n *\n * if (loading) return <div>Searching...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <input\n * type=\"text\"\n * onChange={(e) => handleSearch(e.target.value)}\n * placeholder=\"Search...\"\n * />\n * <button onClick={handleManualSearch}>Search</button>\n * {result && (\n * <div>\n * Found {result.total} items:\n * {result.items.map(item => (\n * <div key={item.id}>{item.title}</div>\n * ))}\n * </div>\n * )}\n * </div>\n * );\n * }\n * ```\n *\n * @throws This hook may throw exceptions related to network requests, which should be\n * handled by the caller. The execute function may throw FetcherError or other network-related errors.\n * Invalid URL or malformed request options may also cause exceptions.\n */\nexport function useFetcherQuery<Q, R, E = FetcherError>(\n options: UseFetcherQueryOptions<Q, R, E>,\n): UseFetcherQueryReturn<Q, R, E> {\n const useFetcherQueryOptions = {\n resultExtractor: JsonResultExtractor,\n ...options,\n };\n const latestOptionsRef = useLatest(useFetcherQueryOptions);\n const {\n loading,\n result,\n error,\n status,\n execute: fetcherExecute,\n reset,\n abort,\n } = useFetcher<R, E>(useFetcherQueryOptions);\n const execute = useCallback(\n (query: Q) => {\n const fetcherRequest: FetchRequest = {\n url: latestOptionsRef.current.url,\n method: 'POST',\n body: query as Record<string, any>,\n };\n return fetcherExecute(fetcherRequest);\n },\n [fetcherExecute, latestOptionsRef],\n );\n\n const { getQuery, setQuery } = useQueryState({\n initialQuery: useFetcherQueryOptions.initialQuery,\n query: useFetcherQueryOptions.query,\n autoExecute: useFetcherQueryOptions.autoExecute,\n execute,\n });\n\n const executeWrapper = useCallback(async () => {\n const query = getQuery();\n if (isValidateQuery(query)) {\n return await execute(query);\n }\n }, [execute, getQuery]);\n\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n execute: executeWrapper,\n reset,\n abort,\n getQuery,\n setQuery,\n }),\n [\n loading,\n result,\n error,\n status,\n executeWrapper,\n reset,\n abort,\n getQuery,\n setQuery,\n ],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { UseQueryReturn } from '../../core';\nimport { useFetcherQuery, UseFetcherQueryOptions } from '../../fetcher';\nimport { Condition } from '@ahoo-wang/fetcher-wow';\n\n/**\n * Options for configuring the useFetcherCountQuery hook.\n *\n * This interface extends UseFetcherQueryOptions and is specifically tailored for count queries\n * that use a Condition object to filter results and return a numeric count.\n *\n * @template FIELDS - A string union type representing the fields that can be used in the condition.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n */\nexport interface UseFetcherCountQueryOptions<\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseFetcherQueryOptions<Condition<FIELDS>, number, E> {}\n\n/**\n * Return type for the useFetcherCountQuery hook.\n *\n * This interface extends UseQueryReturn and provides the structure for the hook's return value,\n * including data (the count as a number), loading state, error state, and other query-related properties.\n *\n * @template FIELDS - A string union type representing the fields that can be used in the condition.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n */\nexport interface UseFetcherCountQueryReturn<\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<Condition<FIELDS>, number, E> {}\n\n/**\n * A React hook for performing count queries using the Fetcher library.\n *\n * This hook is designed for scenarios where you need to retrieve the count of records\n * that match a specific condition. It wraps the useFetcherQuery hook and specializes\n * it for count operations, returning a number representing the count.\n *\n * @template FIELDS - A string union type representing the fields that can be used in the condition.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n *\n * @param options - Configuration options for the count query, including the condition, fetcher instance, and other query settings.\n * @returns An object containing the query result (count as a number), loading state, error state, and utility functions.\n *\n * @throws {E} Throws an error of type E if the query fails, which could be due to network issues, invalid conditions, or server errors.\n *\n * @example\n * ```typescript\n * import { useFetcherCountQuery } from '@ahoo-wang/fetcher-react';\n * import { all } from '@ahoo-wang/fetcher-wow';\n *\n * function UserCountComponent() {\n * const { data: count, loading, error, execute } = useFetcherCountQuery({\n * url: '/api/users/count',\n * initialQuery: all(),\n * autoExecute: true,\n * });\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <div>Total active users: {count}</div>\n * <button onClick={execute}>Refresh Count</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useFetcherCountQuery<\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UseFetcherCountQueryOptions<FIELDS, E>,\n): UseFetcherCountQueryReturn<FIELDS, E> {\n return useFetcherQuery<Condition<FIELDS>, number, E>(options);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ListQuery } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { UseQueryReturn } from '../../core';\nimport { useFetcherQuery, UseFetcherQueryOptions } from '../../fetcher';\n\n/**\n * Options for the useFetcherListQuery hook.\n * Extends UseFetcherQueryOptions to provide configuration for list queries.\n *\n * @template R - The type of individual items in the result array.\n * @template FIELDS - The fields available for filtering, sorting, and pagination in the list query.\n * @template E - The error type, defaults to FetcherError.\n */\nexport interface UseFetcherListQueryOptions<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseFetcherQueryOptions<ListQuery<FIELDS>, R[], E> {}\n\n/**\n * Return type of the useFetcherListQuery hook.\n * Extends UseQueryReturn to provide state and methods for list query operations.\n *\n * @template R - The type of individual items in the result array.\n * @template FIELDS - The fields available for filtering, sorting, and pagination in the list query.\n * @template E - The error type, defaults to FetcherError.\n */\nexport interface UseFetcherListQueryReturn<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<ListQuery<FIELDS>, R[], E> {}\n\n/**\n * A React hook for executing list queries using the fetcher library within the wow framework.\n *\n * This hook is designed for fetching lists of items with support for filtering, sorting, and pagination\n * through the ListQuery type. It returns an array of results and integrates seamlessly with the fetcher\n * library for HTTP requests.\n *\n * @template R - The type of individual items in the result array (e.g., User, Product).\n * @template FIELDS - The fields available for filtering, sorting, and pagination (e.g., 'name', 'createdAt').\n * @template E - The error type, defaults to FetcherError.\n * @param options - Configuration options including URL, initial list query parameters, and execution settings.\n * @returns An object containing loading state, result array, error state, and query management functions.\n *\n * @example\n * ```typescript\n * import { useFetcherListQuery } from '@ahoo-wang/fetcher-react';\n * import { listQuery, contains, desc } from '@ahoo-wang/fetcher-wow';\n *\n * interface User {\n * id: string;\n * name: string;\n * email: string;\n * createdAt: string;\n * }\n *\n * function UserListComponent() {\n * const {\n * loading,\n * result: users,\n * error,\n * execute,\n * setQuery,\n * getQuery,\n * } = useFetcherListQuery<User, keyof User>({\n * url: '/api/users/list',\n * initialQuery: listQuery({\n * condition: contains('name', 'John'),\n * sort: [desc('createdAt')],\n * limit: 10,\n * }),\n * autoExecute: true,\n * });\n *\n * const loadMore = () => {\n * const currentQuery = getQuery();\n * setQuery({\n * ...currentQuery,\n * limit: (currentQuery.limit || 10) + 10,\n * });\n * };\n *\n * if (loading) return <div>Loading users...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <h2>Users ({users?.length || 0})</h2>\n * <ul>\n * {users?.map(user => (\n * <li key={user.id}>\n * {user.name} - {user.email}\n * </li>\n * ))}\n * </ul>\n * <button onClick={loadMore}>Load More</button>\n * <button onClick={execute}>Refresh list</button>\n * </div>\n * );\n * }\n * ```\n *\n * @throws {FetcherError} When the HTTP request fails due to network issues, invalid responses, or server errors.\n * @throws {Error} When invalid options are provided, such as malformed URLs or unsupported query parameters.\n */\nexport function useFetcherListQuery<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UseFetcherListQueryOptions<R, FIELDS, E>,\n): UseFetcherListQueryReturn<R, FIELDS, E> {\n return useFetcherQuery<ListQuery<FIELDS>, R[], E>(options);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ListQuery } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { UseQueryReturn } from '../../core';\nimport { useFetcherQuery, UseFetcherQueryOptions } from '../../fetcher';\nimport {\n JsonEventStreamResultExtractor,\n JsonServerSentEvent,\n} from '@ahoo-wang/fetcher-eventstream';\n\n/**\n * Options for configuring the useFetcherListStreamQuery hook.\n *\n * This interface extends UseFetcherQueryOptions and is specifically tailored for list stream queries\n * that use a ListQuery to filter results and return a ReadableStream of JSON server-sent events.\n *\n * @template R - The type of the resource or entity contained in each event in the stream.\n * @template FIELDS - A string union type representing the fields that can be used in the list query.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n */\nexport interface UseFetcherListStreamQueryOptions<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseFetcherQueryOptions<\n ListQuery<FIELDS>,\n ReadableStream<JsonServerSentEvent<R>>,\n E\n> {}\n\n/**\n * Return type for the useFetcherListStreamQuery hook.\n *\n * This interface extends UseQueryReturn and provides the structure for the hook's return value,\n * including data (a ReadableStream of JSON server-sent events), loading state, error state, and other query-related properties.\n *\n * @template R - The type of the resource or entity contained in each event in the stream.\n * @template FIELDS - A string union type representing the fields that can be used in the list query.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n */\nexport interface UseFetcherListStreamQueryReturn<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<\n ListQuery<FIELDS>,\n ReadableStream<JsonServerSentEvent<R>>,\n E\n> {}\n\n/**\n * A React hook for performing list stream queries using the Fetcher library with server-sent events.\n *\n * This hook is designed for scenarios where you need to retrieve a stream of data that matches a list query condition.\n * It returns a ReadableStream of JSON server-sent events, allowing for real-time data streaming.\n * The hook automatically configures the JsonEventStreamResultExtractor for proper stream handling.\n *\n * @template R - The type of the resource or entity contained in each event in the stream.\n * @template FIELDS - A string union type representing the fields that can be used in the list query.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n *\n * @param options - Configuration options for the list stream query, including the list query, fetcher instance, and other query settings.\n * @returns An object containing the query result (a ReadableStream of JSON server-sent events), loading state, error state, and utility functions.\n *\n * @throws {E} Throws an error of type E if the query fails, which could be due to network issues, invalid queries, or server errors.\n *\n * @example\n * ```typescript\n * import { useFetcherListStreamQuery } from '@ahoo-wang/fetcher-react';\n * import { listQuery, contains } from '@ahoo-wang/fetcher-wow';\n * import { JsonServerSentEvent } from '@ahoo-wang/fetcher-eventstream';\n * import { useEffect, useRef } from 'react';\n *\n * interface User {\n * id: number;\n * name: string;\n * }\n *\n * function UserStreamComponent() {\n * const { data: stream, loading, error, execute } = useFetcherListStreamQuery<User, 'id' | 'name'>({\n * url: '/api/users/stream',\n * initialQuery: listQuery({\n * condition: contains('name', 'John'),\n * limit: 10,\n * }),\n * autoExecute: true,\n * });\n *\n * const messagesRef = useRef<HTMLDivElement>(null);\n *\n * useEffect(() => {\n * if (stream) {\n * const reader = stream.getReader();\n * const readStream = async () => {\n * try {\n * while (true) {\n * const { done, value } = await reader.read();\n * if (done) break;\n * // Process the JsonServerSentEvent<User>\n * const newUser = value.data;\n * if (messagesRef.current) {\n * const div = document.createElement('div');\n * div.textContent = `New user: ${newUser.name}`;\n * messagesRef.current.appendChild(div);\n * }\n * }\n * } catch (err) {\n * console.error('Stream error:', err);\n * }\n * };\n * readStream();\n * }\n * }, [stream]);\n *\n * if (loading) return <div>Loading stream...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <div ref={messagesRef}></div>\n * <button onClick={execute}>Restart Stream</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useFetcherListStreamQuery<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UseFetcherListStreamQueryOptions<R, FIELDS, E>,\n): UseFetcherListStreamQueryReturn<R, FIELDS, E> {\n const streamOptions = {\n ...options,\n resultExtractor: JsonEventStreamResultExtractor,\n };\n return useFetcherQuery<\n ListQuery<FIELDS>,\n ReadableStream<JsonServerSentEvent<R>>,\n E\n >(streamOptions);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PagedList, PagedQuery } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { UseQueryReturn } from '../../core';\nimport { useFetcherQuery, UseFetcherQueryOptions } from '../../fetcher';\n\n/**\n * Options for configuring the useFetcherPagedQuery hook.\n *\n * This interface extends UseFetcherQueryOptions and is specifically tailored for paged queries\n * that use a PagedQuery to filter and paginate results, returning a PagedList of items.\n *\n * @template R - The type of the resource or entity contained in each item of the paged list.\n * @template FIELDS - A string union type representing the fields that can be used in the paged query.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n */\nexport interface UseFetcherPagedQueryOptions<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseFetcherQueryOptions<PagedQuery<FIELDS>, PagedList<R>, E> {}\n\n/**\n * Return type for the useFetcherPagedQuery hook.\n *\n * This interface extends UseQueryReturn and provides the structure for the hook's return value,\n * including data (a PagedList containing items and pagination metadata), loading state, error state, and other query-related properties.\n *\n * @template R - The type of the resource or entity contained in each item of the paged list.\n * @template FIELDS - A string union type representing the fields that can be used in the paged query.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n */\nexport interface UseFetcherPagedQueryReturn<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<PagedQuery<FIELDS>, PagedList<R>, E> {}\n\n/**\n * A React hook for performing paged queries using the Fetcher library.\n *\n * This hook is designed for scenarios where you need to retrieve paginated data that matches a query condition.\n * It returns a PagedList containing the items for the current page along with pagination metadata such as total count and page information.\n *\n * @template R - The type of the resource or entity contained in each item of the paged list.\n * @template FIELDS - A string union type representing the fields that can be used in the paged query.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n *\n * @param options - Configuration options for the paged query, including the paged query parameters, fetcher instance, and other query settings.\n * @returns An object containing the query result (a PagedList with items and pagination info), loading state, error state, and utility functions.\n *\n * @throws {E} Throws an error of type E if the query fails, which could be due to network issues, invalid queries, or server errors.\n *\n * @example\n * ```typescript\n * import { useFetcherPagedQuery } from '@ahoo-wang/fetcher-react';\n * import { pagedQuery, contains, pagination, desc } from '@ahoo-wang/fetcher-wow';\n *\n * interface User {\n * id: number;\n * name: string;\n * email: string;\n * }\n *\n * function UserListComponent() {\n * const {\n * data: pagedList,\n * loading,\n * error,\n * execute,\n * setQuery,\n * getQuery\n * } = useFetcherPagedQuery<User, keyof User>({\n * url: '/api/users/paged',\n * initialQuery: pagedQuery({\n * condition: contains('name', 'John'),\n * sort: [desc('createdAt')],\n * pagination: pagination({ index: 1, size: 10 })\n * }),\n * autoExecute: true,\n * });\n *\n * const goToPage = (page: number) => {\n * const currentQuery = getQuery();\n * setQuery({\n * ...currentQuery,\n * pagination: { ...currentQuery.pagination, index: page }\n * });\n * };\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <h2>Users</h2>\n * <ul>\n * {pagedList.list.map(user => (\n * <li key={user.id}>{user.name} - {user.email}</li>\n * ))}\n * </ul>\n * <div>\n * <span>Total: {pagedList.total} users</span>\n * <button onClick={() => goToPage(1)} disabled={pagedList.pagination.index === 1}>\n * First\n * </button>\n * <button onClick={() => goToPage(pagedList.pagination.index - 1)} disabled={pagedList.pagination.index === 1}>\n * Previous\n * </button>\n * <span>Page {pagedList.pagination.index}</span>\n * <button onClick={() => goToPage(pagedList.pagination.index + 1)}>\n * Next\n * </button>\n * </div>\n * </div>\n * );\n * }\n * ```\n */\nexport function useFetcherPagedQuery<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UseFetcherPagedQueryOptions<R, FIELDS, E>,\n): UseFetcherPagedQueryReturn<R, FIELDS, E> {\n return useFetcherQuery<PagedQuery<FIELDS>, PagedList<R>, E>(options);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SingleQuery } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { UseQueryReturn } from '../../core';\nimport { useFetcherQuery, UseFetcherQueryOptions } from '../../fetcher';\n\n/**\n * Configuration options for the useFetcherSingleQuery hook.\n *\n * Extends UseFetcherQueryOptions to provide configuration for single item queries.\n *\n * @template R - The type of the result item.\n * @template FIELDS - The fields available for filtering and sorting in the single query.\n * @template E - The error type, defaults to FetcherError.\n */\nexport interface UseFetcherSingleQueryOptions<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseFetcherQueryOptions<SingleQuery<FIELDS>, R, E> {}\n\n/**\n * Return type of the useFetcherSingleQuery hook.\n *\n * Extends UseQueryReturn to provide state and methods for single item query operations.\n *\n * @template R - The type of the result item.\n * @template FIELDS - The fields available for filtering and sorting in the single query.\n * @template E - The error type, defaults to FetcherError.\n */\nexport interface UseFetcherSingleQueryReturn<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<SingleQuery<FIELDS>, R, E> {}\n\n/**\n * A React hook for executing single item queries using the fetcher library within the wow framework.\n *\n * This hook is designed for fetching a single item with support for filtering and sorting\n * through the SingleQuery type. It returns a single result item and integrates seamlessly\n * with the fetcher library for HTTP requests.\n *\n * @template R - The type of the result item (e.g., User, Product).\n * @template FIELDS - The fields available for filtering and sorting (e.g., 'id', 'name', 'createdAt').\n * @template E - The error type, defaults to FetcherError.\n * @param options - Configuration options including URL, initial single query parameters, and execution settings.\n * @returns An object containing loading state, result item, error state, and query management functions.\n *\n * @example\n * ```typescript\n * import { useFetcherSingleQuery } from '@ahoo-wang/fetcher-react';\n * import { singleQuery, eq } from '@ahoo-wang/fetcher-wow';\n *\n * interface User {\n * id: string;\n * name: string;\n * email: string;\n * createdAt: string;\n * }\n *\n * function UserProfileComponent({ userId }: { userId: string }) {\n * const {\n * loading,\n * result: user,\n * error,\n * execute,\n * } = useFetcherSingleQuery<User, keyof User>({\n * url: `/api/users/${userId}`,\n * initialQuery: singleQuery({\n * condition: eq('id', userId),\n * }),\n * autoExecute: true,\n * });\n *\n * if (loading) return <div>Loading user...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (!user) return <div>User not found</div>;\n *\n * return (\n * <div>\n * <h2>{user.name}</h2>\n * <p>Email: {user.email}</p>\n * <p>Created: {user.createdAt}</p>\n * <button onClick={execute}>Refresh</button>\n * </div>\n * );\n * }\n * ```\n *\n * @throws {FetcherError} When the HTTP request fails due to network issues, invalid responses, or server errors.\n * @throws {Error} When invalid options are provided, such as malformed URLs or unsupported query parameters.\n */\nexport function useFetcherSingleQuery<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UseFetcherSingleQueryOptions<R, FIELDS, E>,\n): UseFetcherSingleQueryReturn<R, FIELDS, E> {\n return useFetcherQuery<SingleQuery<FIELDS>, R, E>(options);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Condition } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useQuery, UseQueryOptions, UseQueryReturn } from '../core';\n\n/**\n * Options for the useCountQuery hook.\n * Extends UseQueryOptions with Condition as query key and number as data type.\n * @template FIELDS - The fields type for the condition\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseCountQueryOptions<\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryOptions<Condition<FIELDS>, number, E> {}\n\n/**\n * Return type for the useCountQuery hook.\n * Extends UseQueryReturn with Condition as query key and number as data type.\n *\n * @template FIELDS - The fields type for the condition\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseCountQueryReturn<\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<Condition<FIELDS>, number, E> {}\n\n/**\n * Hook for querying count data with conditions.\n * Wraps useQuery to provide type-safe count queries.\n *\n * @template FIELDS - The fields type for the condition\n * @template E - The error type, defaults to FetcherError\n * @param options - The query options including condition and other settings\n * @returns The query result with count data\n *\n * @example\n * ```typescript\n * const { data, isLoading } = useCountQuery({\n * queryKey: [{ field: 'status', operator: 'eq', value: 'active' }],\n * queryFn: async (condition) => fetchCount(condition),\n * });\n * ```\n */\nexport function useCountQuery<FIELDS extends string = string, E = FetcherError>(\n options: UseCountQueryOptions<FIELDS, E>,\n): UseCountQueryReturn<FIELDS, E> {\n return useQuery(options);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ListQuery } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useQuery, UseQueryOptions, UseQueryReturn } from '../core';\n\n/**\n * Options for the useListQuery hook.\n * Extends UseQueryOptions with ListQuery as query key and array of results as data type.\n *\n * @template R - The type of the result items in the list\n * @template FIELDS - The fields type for the list query\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseListQueryOptions<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryOptions<ListQuery<FIELDS>, R[], E> {}\n\n/**\n * Return type for the useListQuery hook.\n * Extends UseQueryReturn with ListQuery as query key and array of results as data type.\n *\n * @template R - The type of the result items in the list\n * @template FIELDS - The fields type for the list query\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseListQueryReturn<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<ListQuery<FIELDS>, R[], E> {}\n\n/**\n * Hook for querying list data with conditions, projection, and sorting.\n * Wraps useQuery to provide type-safe list queries.\n *\n * @template R - The type of the result items in the list\n * @template FIELDS - The fields type for the list query\n * @template E - The error type, defaults to FetcherError\n * @param options - The query options including list query configuration\n * @returns The query result with list data\n *\n * @example\n * ```typescript\n * const { data, isLoading } = useListQuery<{ id: number; name: string }, 'id' | 'name'>({\n * initialQuery: {\n * condition: all(),\n * projection: { include: ['id', 'name'] },\n * sort: [{ field: 'id', direction: SortDirection.ASC }],\n * },\n * execute: async (query) => fetchListData(query),\n * });\n * ```\n */\nexport function useListQuery<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UseListQueryOptions<R, FIELDS, E>,\n): UseListQueryReturn<R, FIELDS, E> {\n return useQuery<ListQuery<FIELDS>, R[], E>(options);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ListQuery } from '@ahoo-wang/fetcher-wow';\nimport type { JsonServerSentEvent } from '@ahoo-wang/fetcher-eventstream';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useQuery, UseQueryOptions, UseQueryReturn } from '../core';\n\n/**\n * Options for the useListStreamQuery hook.\n * Extends UseQueryOptions with ListQuery as query key and stream of events as data type.\n *\n * @template R - The type of the result items in the stream events\n * @template FIELDS - The fields type for the list stream query\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseListStreamQueryOptions<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryOptions<\n ListQuery<FIELDS>,\n ReadableStream<JsonServerSentEvent<R>>,\n E\n > {}\n\n/**\n * Return type for the useListStreamQuery hook.\n * Extends UseQueryReturn with ListQuery as query key and stream of events as data type.\n *\n * @template R - The type of the result items in the stream events\n * @template FIELDS - The fields type for the list stream query\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseListStreamQueryReturn<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<\n ListQuery<FIELDS>,\n ReadableStream<JsonServerSentEvent<R>>,\n E\n > {}\n\n/**\n * Hook for querying streaming list data with conditions, projection, and sorting.\n * Wraps useQuery to provide type-safe streaming list queries.\n *\n * @template R - The type of the result items in the stream events\n * @template FIELDS - The fields type for the list stream query\n * @template E - The error type, defaults to FetcherError\n * @param options - The query options including list stream query configuration\n * @returns The query result with streaming data\n *\n * @example\n * ```typescript\n * const { data, isLoading } = useListStreamQuery<{ id: number; name: string }, 'id' | 'name'>({\n * initialQuery: {\n * condition: all(),\n * projection: { include: ['id', 'name'] },\n * sort: [{ field: 'id', direction: SortDirection.ASC }],\n * },\n * execute: async (query) => fetchStreamData(query),\n * });\n * ```\n */\nexport function useListStreamQuery<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UseListStreamQueryOptions<R, FIELDS, E>,\n): UseListStreamQueryReturn<R, FIELDS, E> {\n return useQuery<ListQuery<FIELDS>, ReadableStream<JsonServerSentEvent<R>>, E>(\n options,\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PagedList, PagedQuery } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useQuery, UseQueryOptions, UseQueryReturn } from '../core';\n\n/**\n * Options for the usePagedQuery hook.\n * Extends UseQueryOptions with PagedQuery as query key and PagedList as data type.\n *\n * @template R - The type of the result items in the paged list\n * @template FIELDS - The fields type for the paged query\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UsePagedQueryOptions<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryOptions<PagedQuery<FIELDS>, PagedList<R>, E> {}\n\n/**\n * Return type for the usePagedQuery hook.\n * Extends UseQueryReturn with PagedQuery as query key and PagedList as data type.\n *\n * @template R - The type of the result items in the paged list\n * @template FIELDS - The fields type for the paged query\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UsePagedQueryReturn<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<PagedQuery<FIELDS>, PagedList<R>, E> {}\n\n/**\n * Hook for querying paged data with conditions, projection, pagination, and sorting.\n * Wraps useQuery to provide type-safe paged queries.\n *\n * @template R - The type of the result items in the paged list\n * @template FIELDS - The fields type for the paged query\n * @template E - The error type, defaults to FetcherError\n * @param options - The query options including paged query configuration\n * @returns The query result with paged list data\n *\n * @example\n * ```typescript\n * const { data, isLoading } = usePagedQuery<{ id: number; name: string }, 'id' | 'name'>({\n * initialQuery: {\n * condition: all(),\n * pagination: { index: 1, size: 10 },\n * projection: { include: ['id', 'name'] },\n * sort: [{ field: 'id', direction: SortDirection.ASC }],\n * },\n * execute: async (query) => fetchPagedData(query),\n * });\n * ```\n */\nexport function usePagedQuery<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UsePagedQueryOptions<R, FIELDS, E>,\n): UsePagedQueryReturn<R, FIELDS, E> {\n return useQuery<PagedQuery<FIELDS>, PagedList<R>, E>(options);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SingleQuery } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useQuery, UseQueryOptions, UseQueryReturn } from '../core';\n\n/**\n * Options for the useSingleQuery hook.\n * Extends UseQueryOptions with SingleQuery as query key and custom result type.\n *\n * @template R - The result type of the query\n * @template FIELDS - The fields type for the single query\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseSingleQueryOptions<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryOptions<SingleQuery<FIELDS>, R, E> {}\n\n/**\n * Return type for the useSingleQuery hook.\n * Extends UseQueryReturn with SingleQuery as query key and custom result type.\n *\n * @template R - The result type of the query\n * @template FIELDS - The fields type for the single query\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseSingleQueryReturn<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<SingleQuery<FIELDS>, R, E> {}\n\n/**\n * Hook for querying a single item with conditions, projection, and sorting.\n * Wraps useQuery to provide type-safe single item queries.\n *\n * @template R - The result type of the query\n * @template FIELDS - The fields type for the single query\n * @template E - The error type, defaults to FetcherError\n * @param options - The query options including single query configuration\n * @returns The query result with single item data\n *\n * @example\n * ```typescript\n * const { data, isLoading } = useSingleQuery<{ id: number; name: string }, 'id' | 'name'>({\n * initialQuery: {\n * condition: all(),\n * projection: { include: ['id', 'name'] },\n * sort: [{ field: 'id', direction: SortDirection.ASC }],\n * },\n * execute: async (query) => fetchSingleItem(query),\n * });\n * ```\n */\nexport function useSingleQuery<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UseSingleQueryOptions<R, FIELDS, E>,\n): UseSingleQueryReturn<R, FIELDS, E> {\n return useQuery<SingleQuery<FIELDS>, R, E>(options);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useCallback } from 'react';\nimport { EventHandler, TypedEventBus } from '@ahoo-wang/fetcher-eventbus';\n\n/**\n * Options for the useEventSubscription hook.\n * @template EVENT - The type of events handled by the event bus.\n */\nexport interface UseEventSubscriptionOptions<EVENT> {\n /**\n * The typed event bus instance to subscribe to.\n */\n bus: TypedEventBus<EVENT>;\n /**\n * The event handler function that will be called when events are published.\n */\n handler: EventHandler<EVENT>;\n}\n\n/**\n * Return type for the useEventSubscription hook.\n */\nexport interface UseEventSubscriptionReturn {\n /**\n * Function to manually subscribe to the event bus.\n * @returns true if subscription was successful, false otherwise.\n */\n subscribe: () => boolean;\n /**\n * Function to manually unsubscribe from the event bus.\n * @returns true if unsubscription was successful, false otherwise.\n */\n unsubscribe: () => boolean;\n}\n\n/**\n * A React hook for subscribing to events from a typed event bus.\n *\n * This hook automatically subscribes to the event bus when the component mounts\n * and unsubscribes when the component unmounts. It also provides manual subscribe\n * and unsubscribe functions for additional control.\n *\n * @template EVENT - The type of events handled by the event bus. Defaults to unknown.\n * @param options - Configuration options for the subscription.\n * @param options.bus - The typed event bus instance to subscribe to.\n * @param options.handler - The event handler function that will be called when events are published.\n * @returns An object containing subscribe and unsubscribe functions.\n * @throws Will throw an error if the event bus or handler is invalid.\n *\n * @example\n * ```typescript\n * import { useEventSubscription } from '@ahoo-wang/fetcher-react';\n * import { eventBus } from './eventBus';\n *\n * function MyComponent() {\n * const { subscribe, unsubscribe } = useEventSubscription({\n * bus: eventBus,\n * handler: {\n * name: 'myEvent',\n * handle: (event) => {\n * console.log('Received event:', event);\n * }\n * }\n * });\n *\n * // The hook automatically subscribes on mount and unsubscribes on unmount\n * // You can also manually control subscription if needed\n * const handleToggleSubscription = () => {\n * if (someCondition) {\n * subscribe();\n * } else {\n * unsubscribe();\n * }\n * };\n *\n * return <div>My Component</div>;\n * }\n * ```\n */\nexport function useEventSubscription<EVENT = unknown>(\n options: UseEventSubscriptionOptions<EVENT>,\n): UseEventSubscriptionReturn {\n const { bus, handler } = options;\n const subscribe = useCallback(() => {\n return bus.on(handler);\n }, [bus, handler]);\n\n const unsubscribe = useCallback(() => {\n return bus.off(handler.name);\n }, [bus, handler]);\n\n useEffect(() => {\n const success = bus.on(handler);\n if (!success) {\n console.warn(\n `Failed to subscribe to event bus with handler: ${handler.name}`,\n );\n }\n return () => {\n bus.off(handler.name);\n };\n }, [bus, handler]);\n\n return {\n subscribe,\n unsubscribe,\n };\n}\n"],"names":["useLatest","value","ref","useRef","current","useDebouncedCallback","callback","options","$","_c","leading","trailing","Error","timeoutRef","undefined","lastArgsRef","lastInvokeTimeRef","latestCallback","latestOptions","t0","Symbol","for","clearTimeout","cleanTimeout","t1","time","delay","shouldInvoke","t2","time_0","args","invokeCallback","t3","setTimeout","trailingTime","Date","now","scheduleTrailing","t4","t5","args_0","t6","t7","currentTime","run","cancel","isPending","t8","useEffect","t9","useMounted","isMountedRef","isMountedFn","PromiseStatus","IDLE","LOADING","SUCCESS","ERROR","usePromiseState","status","setStatus","useState","initialStatus","result","setResult","error","setError","isMounted","setLoadingFn","useCallback","setSuccessFn","onSuccess","callbackError","console","warn","setErrorFn","onError","setIdleFn","useMemo","loading","setLoading","setSuccess","setIdle","useRequestId","requestIdRef","generate","requestId","isLatest","invalidate","reset","useExecutePromise","abortControllerRef","propagateError","onAbortRef","onAbort","handleOnAbort","execute","input","abort","abortController","AbortController","currentRequestId","data","err","name","useDebouncedExecutePromise","debounce","useDebouncedQuery","originalAutoExecute","autoExecute","debouncedExecuteOptions","getQuery","setQuery","useQuery","query","setQueryFn","getFullscreenElement","document","fullscreenElement","webkitFullscreenElement","mozFullScreenElement","msFullscreenElement","enterFullscreen","element","requestFullscreen","webkitRequestFullscreen","mozRequestFullScreen","msRequestFullscreen","exitFullscreen","webkitExitFullscreen","mozCancelFullScreen","msExitFullscreen","addFullscreenChangeListener","addEventListener","removeFullscreenChangeListener","removeEventListener","useFullscreen","target","targetRef","onChange","isFullscreen","setIsFullscreen","newIsFullscreen","documentElement","handleFullscreenChange","enterFullscreenFn","exitFullscreenFn","_temp","toggleFullscreenFn","toggle","enter","exit","useRefs","refs","Map","get","key","set","has","deleteFn","delete","clear","keys","values","entries","iterator","register","instance","size","useForceUpdate","forceUpdate","useReducer","x","useQueryState","initialQuery","queryRef","currentQuery","isValidateQuery","executeWrapper","query_0","latestOptionsRef","promiseExecutor","__name","attributes","useKeyStorage","keyStorage","defaultValue","addListener","nameGenerator","handle","subscribe","storedValue","getSnapshot","useSyncExternalStore","value_0","setValue","remove","useImmerKeyStorage","updater","nextValue","produce","updateImmer","ANONYMOUS_USER","jti","sub","iat","exp","useSecurity","tokenStorage","token","optionsRef","compositeTokenProvider","compositeToken","signIn","onSignIn","onSignOut","signOut","access","payload","authenticated","currentUser","SecurityContext","createContext","SecurityProvider","children","useSecurityOptions","jsx","useSecurityContext","context","useContext","RouteGuard","fallback","onUnauthorized","RefreshableRouteGuard","refreshing","tokenManager","refreshable","isRefreshNeeded","isRefreshable","refresh","refreshToken","refreshingNode","useFetcher","fetcher","fetcherRegistrar","default","exchange","setExchange","getFetcher","currentFetcher","request","exchange_0","extractResult","resetFn","abortFn","useDebouncedFetcher","useDebouncedFetcherQuery","useFetcherQuery","resultExtractor","JsonResultExtractor","useFetcherQueryOptions","fetcherExecute","fetcherRequest","url","method","body","useFetcherCountQuery","useFetcherListQuery","useFetcherListStreamQuery","JsonEventStreamResultExtractor","useFetcherPagedQuery","useFetcherSingleQuery","useCountQuery","useListQuery","useListStreamQuery","usePagedQuery","useSingleQuery","useEventSubscription","bus","handler","on","off","unsubscribe"],"mappings":";;;;;;;;;AA6CO,SAASA,EAAaC,GAAwB;AACnD,QAAMC,IAAMC,EAAOF,CAAK;AAExBC,SAAAA,EAAIE,UAAUH,GACPC;AACT;AALgBF,EAAAA,GAAAA;ACyCT,SAAAK,EAAAC,GAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,EAAA;AAIL,MAAIF,EAAOG,YAAa,MAASH,EAAOI,aAAc;AACpD,UAAM,IAAIC,MACR,wEACF;AAGF,QAAAC,IAAmBV,EAAkDW,MAAS,GAC9EC,IAAoBZ,EAA6B,IAAI,GACrDa,IAA0Bb,EAAsB,IAAI,GAEpDc,IAAuBjB,EAAUM,CAAQ,GACzCY,IAAsBlB,EAAUO,CAAO;AAAE,MAAAY;AAAA,EAAAX,EAAA,CAAA,MAAAY,OAAAC,IAAA,2BAAA,KAERF,IAAAA,gBAAAA,EAAAA,MAAA;AAC/B,IAAIN,EAAUT,YAAaU,WACzBQ,aAAaT,EAAUT,OAAQ,GAC/BS,EAAUT,UAAWU;AAAAA,EACtB,GAJ8BK,OAKhCX,OAAAW,KAAAA,IAAAX,EAAA,CAAA;AALD,QAAAe,IAAqBJ;AAKd,MAAAK;AAAA,EAAAhB,SAAAU,KAE0BM,IAAAC,gBAAAA,EAAAA,CAAAA,MAC1BT,EAAiBZ,UAGMqB,IAAOT,EAAiBZ,WACtBc,EAAad,QAAQsB,QAH1C,IAFsBD,OAMhCjB,OAAAU,GAAAV,OAAAgB,KAAAA,IAAAhB,EAAA,CAAA;AAND,QAAAmB,IAAqBH;AAMD,MAAAI;AAAA,EAAApB,SAAAS,KAEeW,IAAAA,gBAAAA,EAAAA,CAAAC,GAAAC,MAAA;AACjCd,IAAAA,EAAiBZ,UAAWqB,GAC5BR,EAAcb,QAAQ,GAAI0B,CAAI;AAAA,EAAC,GAFEF,OAGlC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AA9Q,OAAA+Q,GAAA/Q,OAAAoB,GAAApB,OAAAwB,MAAAJ,IAAApB,EAAA,CAAA,GAAAwB,IAAAxB,EAAA,CAAA,IAVjBwC,EAAUpB,GAUPI,CAAc;AAAC,MAAAM;AAAA,SAAA9B,EAAA,EAAA,MAAAsL,KAAAtL,UAAAkR,KAEXpP,IAAA;AAAA,IAAAwJ,WAAAA;AAAAA,IAAA4F,aAAAA;AAAAA,EAAAA,GAGNlR,QAAAsL,GAAAtL,QAAAkR,GAAAlR,QAAA8B,KAAAA,IAAA9B,EAAA,EAAA,GAHM8B;AAGN;AA3BI+O,EAAAA,IAAAA;"}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/core/useLatest.ts","../src/core/debounced/useDebouncedCallback.ts","../src/core/useMounted.ts","../src/core/usePromiseState.ts","../src/core/useRequestId.ts","../src/core/useExecutePromise.ts","../src/core/debounced/useDebouncedExecutePromise.ts","../src/core/debounced/useDebouncedQuery.ts","../src/core/fullscreen/utils.ts","../src/core/fullscreen/useFullscreen.ts","../src/core/useRefs.ts","../src/core/useForceUpdate.ts","../src/core/useQueryState.ts","../src/core/useQuery.ts","../src/storage/useKeyStorage.ts","../src/storage/useImmerKeyStorage.ts","../src/cosec/useSecurity.ts","../src/cosec/SecurityContext.tsx","../src/cosec/RouteGuard.tsx","../src/cosec/RefreshableRouteGuard.tsx","../src/fetcher/useFetcher.ts","../src/fetcher/debounced/useDebouncedFetcher.ts","../src/fetcher/debounced/useDebouncedFetcherQuery.ts","../src/fetcher/useFetcherQuery.ts","../src/wow/fetcher/useFetcherCountQuery.ts","../src/wow/fetcher/useFetcherListQuery.ts","../src/wow/fetcher/useFetcherListStreamQuery.ts","../src/wow/fetcher/useFetcherPagedQuery.ts","../src/wow/fetcher/useFetcherSingleQuery.ts","../src/wow/useCountQuery.ts","../src/wow/useListQuery.ts","../src/wow/useListStreamQuery.ts","../src/wow/usePagedQuery.ts","../src/wow/useSingleQuery.ts","../src/eventbus/useEventSubscription.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RefObject, useRef } from 'react';\n\n/**\n * A React hook that returns a ref containing the latest value, useful for accessing the current value in async callbacks.\n *\n * @template T - The type of the value\n * @param value - The value to track\n * @returns A ref object containing the latest value\n *\n * @example\n * ```typescript\n * import { useLatest } from '@ahoo-wang/fetcher-react';\n *\n * const MyComponent = () => {\n * const [count, setCount] = useState(0);\n * const latestCount = useLatest(count);\n *\n * const handleAsync = async () => {\n * await someAsyncOperation();\n * console.log('Latest count:', latestCount.current); // Always the latest\n * };\n *\n * return (\n * <div>\n * <p>Count: {count}</p>\n * <button onClick={() => setCount(c => c + 1)}>Increment</button>\n * <button onClick={handleAsync}>Async Log</button>\n * </div>\n * );\n * };\n * ```\n */\nexport function useLatest<T>(value: T): RefObject<T> {\n const ref = useRef(value);\n /* eslint-disable react-hooks/refs */\n ref.current = value;\n return ref;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useCallback, useRef, useEffect, useMemo } from 'react';\nimport { useLatest } from '../useLatest';\n\n/**\n * Options for configuring the debounced callback behavior.\n */\nexport interface UseDebouncedCallbackOptions {\n /** The delay in milliseconds before the callback is invoked. Must be a positive number. */\n delay: number;\n /** Whether to invoke the callback immediately on the leading edge of the timeout. Defaults to false. */\n leading?: boolean;\n /** Whether to invoke the callback on the trailing edge of the timeout. Defaults to true. */\n trailing?: boolean;\n}\n\n/**\n * Return type of the useDebouncedCallback hook.\n * @template T - The type of the original callback function.\n */\nexport interface UseDebouncedCallbackReturn<T extends (...args: any[]) => any> {\n /** Function to execute the debounced callback with the provided arguments. */\n readonly run: (...args: Parameters<T>) => void;\n /** Function to cancel any pending debounced execution. */\n readonly cancel: () => void;\n /** Function to check if a debounced execution is currently pending. */\n readonly isPending: () => boolean;\n}\n\n/**\n * A React hook that provides a debounced version of a callback function.\n * The callback will be invoked after a specified delay, with options for leading and trailing edge execution.\n * This is useful for optimizing performance in scenarios like search input handling or window resizing.\n *\n * @template T - The type of the callback function.\n * @param callback - The function to debounce. It can accept any number of arguments.\n * @param options - Configuration object for debouncing behavior.\n * @param options.delay - The delay in milliseconds before the callback is invoked. Must be a positive number.\n * @param options.leading - If true, the callback is invoked immediately on the first call, then debounced. Defaults to false.\n * @param options.trailing - If true, the callback is invoked after the delay on the last call. Defaults to true.\n * @returns An object containing:\n * - `run`: Function to execute the debounced callback with arguments.\n * - `cancel`: Function to cancel any pending debounced execution.\n * - `isPending`: Function that returns true if a debounced execution is currently pending.\n *\n * @example\n * ```typescript\n * const { run, cancel } = useDebouncedCallback(\n * (query: string) => {\n * console.log('Searching for:', query);\n * // Perform search API call\n * },\n * { delay: 300 }\n * );\n *\n * // Call the debounced function\n * run('search term');\n *\n * // Cancel if needed\n * cancel();\n * ```\n *\n * @example With leading edge execution:\n * ```typescript\n * const { run } = useDebouncedCallback(\n * () => console.log('Immediate and debounced'),\n * { delay: 500, leading: true, trailing: true }\n * );\n *\n * run(); // Logs immediately, then again after 500ms if called again\n * ```\n *\n * @throws {Error} Throws an error if both `leading` and `trailing` options are set to false, as at least one must be true for the debounce to function.\n * @throws Exceptions from the callback function itself should be handled by the caller.\n */\nexport function useDebouncedCallback<T extends (...args: any[]) => any>(\n callback: T,\n options: UseDebouncedCallbackOptions,\n): UseDebouncedCallbackReturn<T> {\n if (options.leading === false && options.trailing === false) {\n throw new Error(\n 'useDebouncedCallback: at least one of leading or trailing must be true',\n );\n }\n\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const lastArgsRef = useRef<Parameters<T> | null>(null);\n const lastInvokeTimeRef = useRef<number | null>(null);\n\n const latestCallback = useLatest(callback);\n const latestOptions = useLatest(options);\n\n const cleanTimeout = useCallback(() => {\n if (timeoutRef.current !== undefined) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = undefined;\n }\n }, []);\n\n const shouldInvoke = useCallback((time: number) => {\n if (!lastInvokeTimeRef.current) {\n return true;\n }\n const timeSinceLastInvoke = time - lastInvokeTimeRef.current;\n return timeSinceLastInvoke >= latestOptions.current.delay;\n }, [latestOptions]);\n\n const invokeCallback = useCallback((time: number, args: Parameters<T>) => {\n lastInvokeTimeRef.current = time;\n latestCallback.current(...args);\n }, [latestCallback]);\n\n const scheduleTrailing = useCallback(() => {\n timeoutRef.current = setTimeout(() => {\n if (lastArgsRef.current) {\n const trailingTime = Date.now();\n invokeCallback(trailingTime, lastArgsRef.current);\n }\n timeoutRef.current = undefined;\n }, latestOptions.current.delay);\n }, [latestOptions, invokeCallback]);\n\n const run = useCallback(\n (...args: Parameters<T>) => {\n cleanTimeout();\n const { leading = false, trailing = true } = latestOptions.current;\n lastArgsRef.current = args;\n if (trailing && !leading) {\n scheduleTrailing();\n return;\n }\n\n const currentTime = Date.now();\n const shouldCallLeading = leading && shouldInvoke(currentTime);\n if (shouldCallLeading) {\n invokeCallback(currentTime, args);\n return;\n }\n if (trailing) {\n scheduleTrailing();\n }\n },\n [latestOptions, cleanTimeout, shouldInvoke, invokeCallback, scheduleTrailing],\n );\n const cancel = useCallback(() => {\n cleanTimeout();\n lastArgsRef.current = null;\n }, [cleanTimeout]);\n const isPending = useCallback(() => {\n return timeoutRef.current !== undefined;\n }, []);\n useEffect(() => {\n return () => {\n cancel();\n };\n }, [cancel]);\n\n return useMemo(\n () => ({\n run,\n cancel,\n isPending,\n }),\n [run, cancel, isPending],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useRef, useEffect, useCallback } from 'react';\n\n/**\n * A React hook that returns a function to check if the component is mounted.\n *\n * @returns A function that returns true if the component is mounted, false otherwise\n *\n * @example\n * ```typescript\n * import { useMounted } from '@ahoo-wang/fetcher-react';\n *\n * const MyComponent = () => {\n * const isMounted = useMounted();\n *\n * useEffect(() => {\n * someAsyncOperation().then(() => {\n * if (isMounted()) {\n * setState(result);\n * }\n * });\n * }, []);\n *\n * return <div>My Component</div>;\n * };\n * ```\n */\nexport function useMounted() {\n const isMountedRef = useRef(false);\n const isMountedFn = useCallback(() => isMountedRef.current, []);\n useEffect(() => {\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n };\n }, []);\n\n return isMountedFn;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useMemo, useState } from 'react';\nimport { useMounted } from './useMounted';\nimport { useLatest } from './useLatest';\nimport { FetcherError } from '@ahoo-wang/fetcher';\n\n/**\n * Enumeration of possible promise execution states\n */\nexport enum PromiseStatus {\n IDLE = 'idle',\n LOADING = 'loading',\n SUCCESS = 'success',\n ERROR = 'error',\n}\n\nexport interface PromiseState<R, E = unknown> {\n /** Current status of the promise */\n status: PromiseStatus;\n /** Indicates if currently loading */\n loading: boolean;\n /** The result value */\n result: R | undefined;\n /** The error value */\n error: E | undefined;\n}\n\nexport interface PromiseStateCallbacks<R, E = unknown> {\n /** Callback invoked on success (can be async) */\n onSuccess?: (result: R) => void | Promise<void>;\n /** Callback invoked on error (can be async) */\n onError?: (error: E) => void | Promise<void>;\n}\n\n/**\n * Options for configuring usePromiseState behavior\n * @template R - The type of result\n *\n * @example\n * ```typescript\n * const options: UsePromiseStateOptions<string> = {\n * initialStatus: PromiseStatus.IDLE,\n * onSuccess: (result) => console.log('Success:', result),\n * onError: async (error) => {\n * await logErrorToServer(error);\n * console.error('Error:', error);\n * },\n * };\n * ```\n */\nexport interface UsePromiseStateOptions<R, E = FetcherError>\n extends PromiseStateCallbacks<R, E> {\n /** Initial status, defaults to IDLE */\n initialStatus?: PromiseStatus;\n}\n\n/**\n * Return type for usePromiseState hook\n * @template R - The type of result\n */\nexport interface UsePromiseStateReturn<R, E = FetcherError>\n extends PromiseState<R, E> {\n /** Set status to LOADING */\n setLoading: () => void;\n /** Set status to SUCCESS with result */\n setSuccess: (result: R) => Promise<void>;\n /** Set status to ERROR with error */\n setError: (error: E) => Promise<void>;\n /** Set status to IDLE */\n setIdle: () => void;\n}\n\n/**\n * A React hook for managing promise state without execution logic\n * @template R - The type of result\n * @param options - Configuration options\n * @returns State management object\n *\n * @example\n * ```typescript\n * import { usePromiseState, PromiseStatus } from '@ahoo-wang/fetcher-react';\n *\n * function MyComponent() {\n * const { status, loading, result, error, setSuccess, setError, setIdle } = usePromiseState<string>();\n *\n * const handleSuccess = () => setSuccess('Data loaded');\n * const handleError = () => setError(new Error('Failed to load'));\n *\n * return (\n * <div>\n * <button onClick={handleSuccess}>Set Success</button>\n * <button onClick={handleError}>Set Error</button>\n * <button onClick={setIdle}>Reset</button>\n * <p>Status: {status}</p>\n * {loading && <p>Loading...</p>}\n * {result && <p>Result: {result}</p>}\n * {error && <p>Error: {error.message}</p>}\n * </div>\n * );\n * }\n * ```\n */\nexport function usePromiseState<R = unknown, E = FetcherError>(\n options?: UsePromiseStateOptions<R, E>,\n): UsePromiseStateReturn<R, E> {\n const [status, setStatus] = useState<PromiseStatus>(\n options?.initialStatus ?? PromiseStatus.IDLE,\n );\n const [result, setResult] = useState<R | undefined>(undefined);\n const [error, setError] = useState<E | undefined>(undefined);\n const isMounted = useMounted();\n const latestOptions = useLatest(options);\n const setLoadingFn = useCallback(() => {\n if (isMounted()) {\n setStatus(PromiseStatus.LOADING);\n setError(undefined);\n }\n }, [isMounted]);\n\n const setSuccessFn = useCallback(\n async (result: R) => {\n if (isMounted()) {\n setResult(result);\n setStatus(PromiseStatus.SUCCESS);\n setError(undefined);\n try {\n await latestOptions.current?.onSuccess?.(result);\n } catch (callbackError) {\n // Log callback errors but don't affect state\n console.warn('PromiseState onSuccess callback error:', callbackError);\n }\n }\n },\n [isMounted, latestOptions],\n );\n\n const setErrorFn = useCallback(\n async (error: E) => {\n if (isMounted()) {\n setError(error);\n setStatus(PromiseStatus.ERROR);\n setResult(undefined);\n try {\n await latestOptions.current?.onError?.(error);\n } catch (callbackError) {\n // Log callback errors but don't affect state\n console.warn('PromiseState onError callback error:', callbackError);\n }\n }\n },\n [isMounted, latestOptions],\n );\n\n const setIdleFn = useCallback(() => {\n if (isMounted()) {\n setStatus(PromiseStatus.IDLE);\n setError(undefined);\n setResult(undefined);\n }\n }, [isMounted]);\n return useMemo(\n () => ({\n status,\n loading: status === PromiseStatus.LOADING,\n result,\n error,\n setLoading: setLoadingFn,\n setSuccess: setSuccessFn,\n setError: setErrorFn,\n setIdle: setIdleFn,\n }),\n [status, result, error, setLoadingFn, setSuccessFn, setErrorFn, setIdleFn],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useRef, useCallback, useMemo } from 'react';\n\n/**\n * Return type for useRequestId hook\n */\nexport interface UseRequestIdReturn {\n /** Generate a new request ID and get the current one */\n generate: () => number;\n /** Get the current request ID without generating a new one */\n current: () => number;\n /** Check if a given request ID is the latest */\n isLatest: (requestId: number) => boolean;\n /** Invalidate current request ID (mark as stale) */\n invalidate: () => void;\n /** Reset request ID counter */\n reset: () => void;\n}\n\n/**\n * A React hook for managing request IDs and race condition protection\n *\n * @example\n * ```typescript\n * // Basic usage\n * const requestId = useRequestId();\n *\n * const execute = async () => {\n * const id = requestId.generate();\n *\n * try {\n * const result = await someAsyncOperation();\n *\n * // Check if this is still the latest request\n * if (requestId.isLatest(id)) {\n * setState(result);\n * }\n * } catch (error) {\n * if (requestId.isLatest(id)) {\n * setError(error);\n * }\n * }\n * };\n *\n * // Manual cancellation\n * const handleCancel = () => {\n * requestId.invalidate(); // All ongoing requests will be ignored\n * };\n * ```\n *\n * @example\n * ```typescript\n * // With async operation wrapper\n * const { execute, cancel } = useAsyncOperation(async (data) => {\n * return await apiCall(data);\n * }, [requestId]);\n * ```\n */\nexport function useRequestId(): UseRequestIdReturn {\n const requestIdRef = useRef<number>(0);\n\n const generate = useCallback((): number => {\n return ++requestIdRef.current;\n }, []);\n\n const current = useCallback((): number => {\n return requestIdRef.current;\n }, []);\n\n const isLatest = useCallback((requestId: number): boolean => {\n return requestId === requestIdRef.current;\n }, []);\n\n const invalidate = useCallback((): void => {\n requestIdRef.current++;\n }, []);\n\n const reset = useCallback((): void => {\n requestIdRef.current = 0;\n }, []);\n return useMemo(() => {\n return {\n generate,\n current,\n isLatest,\n invalidate,\n reset,\n };\n }, [generate, current, isLatest, invalidate, reset]);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useMemo, useRef } from 'react';\nimport { useMounted } from './useMounted';\nimport {\n usePromiseState,\n PromiseState,\n UsePromiseStateOptions,\n} from './usePromiseState';\nimport { useRequestId } from './useRequestId';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useLatest } from './useLatest';\n\n/**\n * Configuration options for the useExecutePromise hook.\n * @template R - The type of the resolved value from the promise.\n * @template E - The type of the error value, defaults to unknown.\n */\nexport interface UseExecutePromiseOptions<R, E = unknown>\n extends UsePromiseStateOptions<R, E> {\n /**\n * Whether to propagate errors thrown by the promise.\n * If true, the execute function will throw errors.\n * If false (default), the execute function will return the error as the result instead of throwing.\n * @default false\n */\n propagateError?: boolean;\n /**\n * Callback function called when the current operation is aborted.\n * This includes both automatic cancellation (when a new operation starts) and manual abortion.\n */\n onAbort?: () => void | Promise<void>;\n}\n\n/**\n * Type definition for a function that returns a Promise with optional abort controller support.\n * This is used as input to the execute function, allowing lazy evaluation of promises.\n * The abort controller can be used to cancel the promise if needed.\n * @template R - The type of value the promise will resolve to.\n */\nexport type PromiseSupplier<R> = (\n abortController: AbortController,\n) => Promise<R>;\n\n/**\n * Interface defining the return type of the useExecutePromise hook.\n * Provides state management and control functions for asynchronous operations.\n * @template R - The type of the result value.\n * @template E - The type of the error value, defaults to FetcherError.\n */\nexport interface UseExecutePromiseReturn<R, E = FetcherError>\n extends PromiseState<R, E> {\n /**\n * Function to execute a promise supplier with automatic abort support.\n * Automatically cancels any previous ongoing request before starting a new one.\n * Manages the loading state, handles errors, and updates the result state.\n * @param input - A function that returns a Promise, optionally receiving an AbortController.\n * @throws {Error} If the component is unmounted when execute is called.\n * @throws {E} If propagateError is true and the promise rejects.\n */\n execute: (input: PromiseSupplier<R>) => Promise<void>;\n /**\n * Function to reset the state to initial values.\n * Clears loading, result, error, and sets status to idle.\n */\n reset: () => void;\n /**\n * Function to manually abort the current ongoing operation.\n * This will cancel the current promise execution and set the state to idle.\n * Safe to call even when no operation is currently running.\n */\n abort: () => void;\n}\n\n/**\n * A React hook for managing asynchronous operations with proper state handling and abort support.\n * Provides a way to execute promises while automatically managing loading states,\n * handling errors, preventing state updates on unmounted components or stale requests,\n * and supporting request cancellation through AbortController.\n *\n * Key features:\n * - Automatic request cancellation when new requests are initiated\n * - Manual abort control with dedicated abort() method\n * - AbortController integration for promise-level cancellation\n * - Race condition protection using request IDs\n * - Comprehensive state management (idle, loading, success, error)\n * - Memory leak prevention with automatic cleanup on unmount\n *\n * @template R - The type of the result value, defaults to unknown.\n * @template E - The type of the error value, defaults to FetcherError.\n * @param options - Optional configuration options for the hook behavior.\n * @returns An object containing the current promise state and control functions.\n *\n * @throws {Error} When execute is called on an unmounted component.\n * @throws {E} When propagateError is true and the executed promise rejects.\n *\n * @example\n * Basic usage with automatic abort support and onAbort callback:\n * ```typescript\n * import { useExecutePromise } from '@ahoo-wang/fetcher-react';\n *\n * function MyComponent() {\n * const { loading, result, error, execute, reset, abort } = useExecutePromise<string>({\n * onAbort: () => {\n * console.log('Request was cancelled');\n * // Handle abort (e.g., update UI, cleanup resources)\n * }\n * });\n *\n * const fetchData = async (abortController?: AbortController) => {\n * const response = await fetch('/api/data', {\n * signal: abortController?.signal,\n * });\n * return response.text();\n * };\n *\n * const handleFetch = () => {\n * execute(fetchData); // Automatically cancels previous request and calls onAbort\n * };\n *\n * const handleCancel = () => {\n * abort(); // Manually cancel current request and calls onAbort\n * };\n *\n * const handleReset = () => {\n * reset();\n * };\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * return (\n * <div>\n * <button onClick={handleFetch}>Fetch Data</button>\n * <button onClick={handleCancel} disabled={!loading}>Cancel</button>\n * <button onClick={handleReset}>Reset</button>\n * {result && <p>{result}</p>}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * Basic usage with automatic abort support:\n * ```typescript\n * import { useExecutePromise } from '@ahoo-wang/fetcher-react';\n *\n * function MyComponent() {\n * const { loading, result, error, execute, reset, abort } = useExecutePromise<string>();\n *\n * const fetchData = async (abortController?: AbortController) => {\n * const response = await fetch('/api/data', {\n * signal: abortController?.signal, // Optional: use abort signal\n * });\n * return response.text();\n * };\n *\n * const handleFetch = () => {\n * execute(fetchData); // Automatically cancels previous request\n * };\n *\n * const handleCancel = () => {\n * abort(); // Manually cancel current request\n * };\n *\n * const handleReset = () => {\n * reset();\n * };\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * return (\n * <div>\n * <button onClick={handleFetch}>Fetch Data</button>\n * <button onClick={handleCancel} disabled={!loading}>Cancel</button>\n * <button onClick={handleReset}>Reset</button>\n * {result && <p>{result}</p>}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * Using propagateError for try/catch error handling:\n * ```typescript\n * const { execute } = useExecutePromise<string>({ propagateError: true });\n *\n * const handleSubmit = async () => {\n * try {\n * const data = await execute(fetchUserData);\n * console.log('Success:', data);\n * } catch (err) {\n * console.error('Error occurred:', err);\n * }\n * };\n * ```\n *\n */\nexport function useExecutePromise<R = unknown, E = FetcherError>(\n options?: UseExecutePromiseOptions<R, E>,\n): UseExecutePromiseReturn<R, E> {\n const {\n loading,\n result,\n error,\n status,\n setLoading,\n setSuccess,\n setError,\n setIdle,\n } = usePromiseState<R, E>(options);\n const isMounted = useMounted();\n const requestId = useRequestId();\n const abortControllerRef = useRef<AbortController | undefined>(undefined);\n const propagateError = options?.propagateError;\n const onAbortRef = useLatest(options?.onAbort);\n const handleOnAbort = useCallback(async () => {\n // Call onAbort callback when automatically cancelling previous request\n try {\n await onAbortRef.current?.();\n } catch (callbackError) {\n console.warn('useExecutePromise onAbort callback error:', callbackError);\n }\n }, [onAbortRef]);\n /**\n * Execute a promise supplier with automatic abort support.\n * Automatically cancels any previous ongoing request before starting a new one.\n * Handles loading states, error propagation, and prevents updates on unmounted components.\n * @param input - A function that returns a Promise, optionally receiving an AbortController for cancellation.\n * @throws {Error} If the component is unmounted when execute is called.\n * @throws {E} If propagateError is true and the promise rejects.\n */\n const execute = useCallback(\n async (input: PromiseSupplier<R>): Promise<void> => {\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n await handleOnAbort();\n }\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n const currentRequestId = requestId.generate();\n setLoading();\n try {\n const data = await input(abortController);\n\n if (isMounted() && requestId.isLatest(currentRequestId)) {\n await setSuccess(data);\n }\n } catch (err) {\n if (err instanceof Error && err.name === 'AbortError') {\n if (isMounted()) {\n setIdle();\n }\n return;\n }\n if (isMounted() && requestId.isLatest(currentRequestId)) {\n await setError(err as E);\n }\n if (propagateError) {\n throw err;\n }\n } finally {\n if (abortControllerRef.current === abortController) {\n abortControllerRef.current = undefined;\n }\n }\n },\n [\n setLoading,\n setSuccess,\n setError,\n setIdle,\n isMounted,\n requestId,\n propagateError,\n handleOnAbort,\n ],\n );\n\n /**\n * Reset the state to initial values.\n * Clears loading, result, error, and sets status to idle.\n * Only works if the component is still mounted.\n */\n const reset = useCallback(() => {\n if (isMounted()) {\n setIdle();\n }\n }, [setIdle, isMounted]);\n\n /**\n * Manually abort the current ongoing operation.\n * This will cancel the current promise execution and set the state to idle.\n * Safe to call even when no operation is currently running.\n */\n const abort = useCallback(async () => {\n reset();\n if (!abortControllerRef.current) {\n return;\n }\n abortControllerRef.current.abort();\n abortControllerRef.current = undefined;\n await handleOnAbort();\n }, [reset, handleOnAbort]);\n\n useEffect(() => {\n return () => {\n abort();\n };\n }, [abort]);\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n execute,\n reset,\n abort,\n }),\n [loading, result, error, status, execute, reset, abort],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n useExecutePromise,\n UseExecutePromiseOptions,\n UseExecutePromiseReturn,\n} from '../useExecutePromise';\nimport {\n useDebouncedCallback,\n UseDebouncedCallbackOptions,\n UseDebouncedCallbackReturn,\n} from './useDebouncedCallback';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useMemo } from 'react';\n\n/**\n * Interface for objects that support debouncing configuration.\n * This interface defines the structure for debounce settings that can be applied\n * to promise execution to control the timing and behavior of debounced calls.\n */\nexport interface DebounceCapable {\n /**\n * Debounce options for execute calls, including delay and leading/trailing behavior.\n * Specifies how the debouncing should work, such as the delay duration and whether\n * to execute on the leading edge, trailing edge, or both.\n */\n debounce: UseDebouncedCallbackOptions;\n}\n\n/**\n * Options for configuring the useDebouncedExecutePromise hook.\n * Combines promise execution options with debouncing capabilities to provide\n * fine-grained control over asynchronous operations with rate limiting.\n *\n * @template R - The type of the promise result\n * @template E - The type of the error (defaults to unknown)\n */\nexport interface UseDebouncedExecutePromiseOptions<R, E = unknown>\n extends UseExecutePromiseOptions<R, E>,\n DebounceCapable {}\n\n/**\n * Return type for the useDebouncedExecutePromise hook.\n * Provides access to the promise execution state and debounced execution controls,\n * allowing components to trigger debounced promises and monitor their progress.\n *\n * @template R - The type of the promise result\n * @template E - The type of the error (defaults to unknown)\n */\nexport interface UseDebouncedExecutePromiseReturn<R, E = unknown>\n extends Omit<UseExecutePromiseReturn<R, E>, 'execute'>,\n UseDebouncedCallbackReturn<UseExecutePromiseReturn<R, E>['execute']> {}\n\n/**\n * A React hook that combines promise execution with debouncing functionality.\n * This hook prevents excessive API calls by debouncing the execution of promises,\n * which is particularly useful for scenarios like search inputs, form submissions,\n * or any rapid user interactions that trigger asynchronous operations.\n *\n * The hook integrates the useExecutePromise hook for promise management with\n * useDebouncedCallback for rate limiting, providing a seamless way to handle\n * debounced asynchronous operations in React components.\n *\n * @template R - The type of the promise result (defaults to unknown)\n * @template E - The type of the error (defaults to FetcherError)\n * @param options - Configuration object containing:\n * - All options from UseExecutePromiseOptions (promise execution settings)\n * - debounce: Debounce configuration including delay, leading/trailing behavior\n * @returns An object containing:\n * - loading: Boolean indicating if the promise is currently executing\n * - result: The resolved value of the promise (R)\n * - error: Any error that occurred during execution (E)\n * - status: Current execution status ('idle' | 'pending' | 'fulfilled' | 'rejected')\n * - run: Debounced function to execute the promise with provided arguments\n * - cancel: Function to cancel any pending debounced execution\n * - isPending: Boolean indicating if a debounced call is pending\n * - reset: Function to reset the hook state to initial values\n * @throws {FetcherError} When the underlying promise execution fails and no custom error handler is provided\n * @throws {Error} When invalid options are provided or debounce configuration is malformed\n *\n * @example\n * ```tsx\n * import { useDebouncedExecutePromise } from '@ahoo-wang/fetcher-react';\n *\n * function SearchComponent() {\n * const { loading, result, error, run } = useDebouncedExecutePromise({\n * debounce: { delay: 300 },\n * });\n *\n * const handleSearch = (query: string) => {\n * run(async () => {\n * const response = await fetch(`/api/search?q=${query}`);\n * return response.json();\n * });\n * };\n *\n * return (\n * <div>\n * <input onChange={(e) => handleSearch(e.target.value)} />\n * {loading && <p>Searching...</p>}\n * {result && <ul>{result.map(item => <li key={item.id}>{item.name}</li>)}</ul>}\n * {error && <p>Error: {error.message}</p>}\n * </div>\n * );\n * }\n * ```\n */\nexport function useDebouncedExecutePromise<R = unknown, E = FetcherError>(\n options: UseDebouncedExecutePromiseOptions<R, E>,\n): UseDebouncedExecutePromiseReturn<R, E> {\n const { loading, result, error, execute, reset, abort, status } =\n useExecutePromise(options);\n const { run, cancel, isPending } = useDebouncedCallback(\n execute,\n options.debounce,\n );\n\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n reset,\n abort,\n run,\n cancel,\n isPending,\n }),\n [loading, result, error, status, reset, abort, run, cancel, isPending],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useQuery, UseQueryOptions, UseQueryReturn } from '../index';\nimport {\n DebounceCapable,\n useDebouncedCallback,\n UseDebouncedCallbackReturn,\n} from '../index';\nimport { useCallback, useEffect, useMemo } from 'react';\n\n/**\n * Configuration options for the useDebouncedQuery hook\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value (defaults to FetcherError)\n */\nexport interface UseDebouncedQueryOptions<Q, R, E = FetcherError>\n extends UseQueryOptions<Q, R, E>, DebounceCapable {\n}\n\n/**\n * Return type of the useDebouncedQuery hook\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value (defaults to FetcherError)\n */\nexport interface UseDebouncedQueryReturn<Q, R, E = FetcherError>\n extends Omit<UseQueryReturn<Q, R, E>, 'execute'>,\n UseDebouncedCallbackReturn<UseQueryReturn<Q, R, E>['execute']> {\n}\n\n/**\n * A React hook for managing debounced query execution with automatic state management\n *\n * This hook combines the query functionality with debouncing to provide\n * a convenient way to execute queries with built-in debouncing to prevent excessive\n * operations during rapid query changes, such as in search inputs or dynamic filtering.\n *\n * The hook supports automatic execution on mount and when query parameters change,\n * but wraps the execution in a debounced callback to optimize performance.\n *\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value (defaults to FetcherError)\n * @param options - Configuration options for the hook\n * @returns An object containing query state, query management functions, and debounced execution controls\n *\n * @example\n * ```typescript\n * import { useDebouncedQuery } from '@ahoo-wang/fetcher-react';\n *\n * interface SearchQuery {\n * keyword: string;\n * limit: number;\n * filters?: { category?: string };\n * }\n *\n * interface SearchResult {\n * items: Array<{ id: string; title: string }>;\n * total: number;\n * }\n *\n * function SearchComponent() {\n * const {\n * loading,\n * result,\n * error,\n * run,\n * cancel,\n * isPending,\n * setQuery,\n * getQuery,\n * } = useDebouncedQuery<SearchQuery, SearchResult>({\n * initialQuery: { keyword: '', limit: 10 },\n * execute: async (query) => {\n * const response = await fetch('/api/search', {\n * method: 'POST',\n * body: JSON.stringify(query),\n * headers: { 'Content-Type': 'application/json' },\n * });\n * return response.json();\n * },\n * debounce: { delay: 300 }, // Debounce for 300ms\n * autoExecute: false,\n * });\n *\n * const handleSearch = (keyword: string) => {\n * setQuery({ keyword, limit: 10 }); // This will trigger debounced execution if autoExecute was true\n * };\n *\n * const handleManualSearch = () => {\n * run(); // Manual debounced execution with current query\n * };\n *\n * const handleCancel = () => {\n * cancel(); // Cancel any pending debounced execution\n * };\n *\n * if (loading) return <div>Searching...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <input\n * type=\"text\"\n * onChange={(e) => handleSearch(e.target.value)}\n * placeholder=\"Search...\"\n * />\n * <button onClick={handleManualSearch} disabled={isPending()}>\n * {isPending() ? 'Searching...' : 'Search'}\n * </button>\n * <button onClick={handleCancel}>Cancel</button>\n * {result && (\n * <div>\n * Found {result.total} items:\n * {result.items.map(item => (\n * <div key={item.id}>{item.title}</div>\n * ))}\n * </div>\n * )}\n * </div>\n * );\n * }\n * ```\n *\n * @throws This hook may throw exceptions related to query execution, which should be\n * handled by the caller. The execute function may throw FetcherError or other errors.\n * Invalid query parameters or execution function errors may also cause exceptions.\n */\nexport function useDebouncedQuery<Q, R, E = FetcherError>(\n options: UseDebouncedQueryOptions<Q, R, E>,\n): UseDebouncedQueryReturn<Q, R, E> {\n const originalAutoExecute = options.autoExecute;\n const debouncedExecuteOptions = {\n ...options,\n autoExecute: false,\n };\n const {\n loading,\n result,\n error,\n status,\n execute,\n reset,\n abort,\n getQuery,\n setQuery,\n } = useQuery(debouncedExecuteOptions);\n const { run, cancel, isPending } = useDebouncedCallback(\n execute,\n options.debounce,\n );\n const setQueryFn = useCallback((query: Q) => {\n setQuery(query);\n if (originalAutoExecute) {\n run();\n }\n }, [setQuery, run, originalAutoExecute]);\n useEffect(() => {\n if (originalAutoExecute) {\n run();\n }\n }, [run, originalAutoExecute]);\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n reset,\n abort,\n getQuery,\n setQuery: setQueryFn,\n run,\n cancel,\n isPending,\n }),\n [\n loading,\n result,\n error,\n status,\n reset,\n abort,\n getQuery,\n setQueryFn,\n run,\n cancel,\n isPending,\n ],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Get the current fullscreen element across different browsers.\n * @returns The fullscreen element or null if not in fullscreen.\n */\nexport function getFullscreenElement(): HTMLElement | null {\n return (\n document.fullscreenElement ||\n (document as any).webkitFullscreenElement ||\n (document as any).mozFullScreenElement ||\n (document as any).msFullscreenElement\n );\n}\n\n/**\n * Request fullscreen for a given element.\n * @param element The element to make fullscreen.\n * @throws Error if fullscreen request fails.\n */\nexport async function enterFullscreen(element: HTMLElement): Promise<void> {\n try {\n if (element.requestFullscreen) {\n await element.requestFullscreen();\n } else if ((element as any).webkitRequestFullscreen) {\n await (element as any).webkitRequestFullscreen();\n } else if ((element as any).mozRequestFullScreen) {\n await (element as any).mozRequestFullScreen();\n } else if ((element as any).msRequestFullscreen) {\n await (element as any).msRequestFullscreen();\n } else {\n throw new Error('Fullscreen API not supported');\n }\n } catch (error) {\n console.error('Failed to enter fullscreen:', error);\n throw error;\n }\n}\n\n/**\n * Exit fullscreen mode.\n * @throws Error if fullscreen exit fails.\n */\nexport async function exitFullscreen(): Promise<void> {\n try {\n if (document.exitFullscreen) {\n await document.exitFullscreen();\n } else if ((document as any).webkitExitFullscreen) {\n await (document as any).webkitExitFullscreen();\n } else if ((document as any).mozCancelFullScreen) {\n await (document as any).mozCancelFullScreen();\n } else if ((document as any).msExitFullscreen) {\n await (document as any).msExitFullscreen();\n } else {\n throw new Error('Fullscreen API not supported');\n }\n } catch (error) {\n console.error('Failed to exit fullscreen:', error);\n throw error;\n }\n}\n\n/**\n * Add fullscreen change event listeners across different browsers.\n * @param callback The callback function to execute when fullscreen changes.\n */\nexport function addFullscreenChangeListener(callback: () => void): void {\n document.addEventListener('fullscreenchange', callback);\n document.addEventListener('webkitfullscreenchange', callback);\n document.addEventListener('mozfullscreenchange', callback);\n document.addEventListener('MSFullscreenChange', callback);\n}\n\n/**\n * Remove fullscreen change event listeners across different browsers.\n * @param callback The callback function to remove.\n */\nexport function removeFullscreenChangeListener(callback: () => void): void {\n document.removeEventListener('fullscreenchange', callback);\n document.removeEventListener('webkitfullscreenchange', callback);\n document.removeEventListener('mozfullscreenchange', callback);\n document.removeEventListener('MSFullscreenChange', callback);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState, useCallback, useEffect, RefObject } from 'react';\nimport {\n getFullscreenElement,\n enterFullscreen,\n exitFullscreen,\n addFullscreenChangeListener,\n removeFullscreenChangeListener,\n} from './utils';\n\nexport interface UseFullscreenOptions {\n /**\n * Target element to make fullscreen. If not provided, uses the document root element.\n */\n target?: RefObject<HTMLElement | null>;\n /**\n * Callback when fullscreen state changes\n */\n onChange?: (isFullscreen: boolean) => void;\n}\n\nexport interface UseFullscreenReturn {\n /**\n * Whether the target element is currently in fullscreen mode\n */\n isFullscreen: boolean;\n /**\n * Toggle fullscreen mode on/off\n */\n toggle: () => Promise<void>;\n /**\n * Enter fullscreen mode\n */\n enter: () => Promise<void>;\n /**\n * Exit fullscreen mode\n */\n exit: () => Promise<void>;\n}\n\n/**\n * React hook for managing fullscreen state and actions.\n * Provides cross-browser fullscreen API support with automatic state tracking.\n */\nexport function useFullscreen(\n options: UseFullscreenOptions = {},\n): UseFullscreenReturn {\n const { target: targetRef, onChange } = options;\n\n const [isFullscreen, setIsFullscreen] = useState(false);\n\n const handleFullscreenChange = useCallback(() => {\n const fullscreenElement = getFullscreenElement();\n const newIsFullscreen =\n fullscreenElement === (targetRef?.current || document.documentElement);\n if (newIsFullscreen !== isFullscreen) {\n setIsFullscreen(newIsFullscreen);\n onChange?.(newIsFullscreen);\n }\n }, [targetRef, onChange, isFullscreen]);\n\n // Listen for fullscreen changes\n useEffect(() => {\n addFullscreenChangeListener(handleFullscreenChange);\n return () => {\n removeFullscreenChangeListener(handleFullscreenChange);\n };\n }, [handleFullscreenChange]);\n\n const enterFullscreenFn = useCallback(async () => {\n const element = targetRef?.current || document.documentElement;\n await enterFullscreen(element);\n }, [targetRef]);\n\n const exitFullscreenFn = useCallback(async () => {\n await exitFullscreen();\n }, []);\n\n const toggleFullscreenFn = useCallback(async () => {\n if (isFullscreen) {\n await exitFullscreenFn();\n } else {\n await enterFullscreenFn();\n }\n }, [isFullscreen, enterFullscreenFn, exitFullscreenFn]);\n\n return {\n isFullscreen: isFullscreen,\n toggle: toggleFullscreenFn,\n enter: enterFullscreenFn,\n exit: exitFullscreenFn,\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Key, useCallback, useEffect, useMemo, useRef } from 'react';\n\n/**\n * Return type of useRefs hook, providing Map-like interface for managing refs.\n * @template T - The type of the ref instances.\n */\nexport interface UseRefsReturn<T> extends Iterable<[Key, T]> {\n register: (key: Key) => (instance: T | null) => void;\n get: (key: Key) => T | undefined;\n set: (key: Key, value: T) => void;\n delete: (key: Key) => boolean;\n has: (key: Key) => boolean;\n clear: () => void;\n readonly size: number;\n keys: () => IterableIterator<Key>;\n values: () => IterableIterator<T>;\n entries: () => IterableIterator<[Key, T]>;\n}\n\n/**\n * A React hook for managing multiple refs with a Map-like interface.\n * Allows dynamic registration and retrieval of refs by key, with automatic cleanup on unmount.\n *\n * @template T - The type of the ref instances (e.g., HTMLElement).\n * @returns An object with Map methods and a register function for managing refs.\n *\n * @example\n * ```tsx\n * const refs = useRefs<HTMLDivElement>();\n *\n * // Register a ref\n * const refCallback = refs.register('myDiv');\n * <div ref={refCallback} />\n *\n * // Access the ref\n * const element = refs.get('myDiv');\n * ```\n */\nexport function useRefs<T>(): UseRefsReturn<T> {\n const refs = useRef(new Map<Key, T>());\n const get = useCallback((key: Key) => refs.current.get(key), []);\n const set = useCallback(\n (key: Key, value: T) => refs.current.set(key, value),\n [],\n );\n const has = useCallback((key: Key) => refs.current.has(key), []);\n const deleteFn = useCallback((key: Key) => refs.current.delete(key), []);\n const clear = useCallback(() => refs.current.clear(), []);\n const keys = useCallback(() => refs.current.keys(), []);\n const values = useCallback(() => refs.current.values(), []);\n const entries = useCallback(() => refs.current.entries(), []);\n const iterator = useCallback(() => refs.current[Symbol.iterator](), []);\n const register = useCallback((key: Key) => {\n return (instance: T | null) => {\n if (instance) {\n refs.current.set(key, instance);\n } else {\n refs.current.delete(key);\n }\n };\n }, []);\n useEffect(() => {\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n refs.current.clear();\n };\n }, []);\n return useMemo(\n () => ({\n register,\n get,\n set,\n has,\n delete: deleteFn,\n clear,\n keys,\n values,\n entries,\n get size() {\n return refs.current.size;\n },\n [Symbol.iterator]: iterator,\n }),\n [register, get, set, has, deleteFn, clear, keys, values, entries, iterator],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useReducer } from 'react';\n\n/**\n * A React hook that returns a function to force a component to re-render.\n * This is useful when you need to trigger a re-render imperatively, such as\n * when dealing with external state changes or imperative updates.\n *\n * @returns A function that when called, forces the component to re-render\n *\n * @example\n * ```typescript\n * import { useForceUpdate } from '@ahoo-wang/fetcher-react';\n *\n * const MyComponent = () => {\n * const forceUpdate = useForceUpdate();\n *\n * const handleExternalChange = () => {\n * // Some external state change that doesn't trigger React re-render\n * externalLibrary.updateSomething();\n * forceUpdate(); // Force re-render to reflect changes\n * };\n *\n * return (\n * <div>\n * <p>Component state: {someValue}</p>\n * <button onClick={handleExternalChange}>Update External State</button>\n * </div>\n * );\n * };\n * ```\n */\nexport function useForceUpdate(): () => void {\n const [, forceUpdate] = useReducer(x => x + 1, 0);\n return forceUpdate;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useRef } from 'react';\nimport { AutoExecuteCapable } from '../types';\n\nexport interface QueryOptions<Q> {\n /** The initial query parameters to be stored and managed */\n initialQuery?: Q;\n /** The current query parameters. If provided, overrides initialQuery and updates the state. */\n query?: Q;\n}\n\n/**\n * Configuration options for the useQueryState hook\n * @template Q - The type of the query parameters\n */\nexport interface UseQueryStateOptions<Q>\n extends QueryOptions<Q>, AutoExecuteCapable {\n /** Function to execute with the current query parameters. Called when autoExecute is true */\n execute: (query: Q) => Promise<void>;\n}\n\n/**\n * Return type of the useQueryState hook\n * @template Q - The type of the query parameters\n */\nexport interface UseQueryStateReturn<Q> {\n /** Function to retrieve the current query parameters */\n getQuery: () => Q | undefined;\n /** Function to update the query parameters. Triggers execution if autoExecute is true */\n setQuery: (query: Q) => void;\n}\n\n/**\n * A React hook for managing query state with automatic execution capabilities\n *\n * This hook provides a centralized way to manage query parameters, including\n * getting and setting the current query, and optionally automatically executing\n * queries when the query changes or on component mount.\n *\n * @template Q - The type of the query parameters, which can be any object type representing query data\n * @param options - Configuration options for the hook\n * @param options.initialQuery - Optional initial query parameters to be stored and managed. Used if no query is provided.\n * @param options.query - Optional current query parameters. If provided, overrides initialQuery and updates the state.\n * @param options.autoExecute - Boolean flag indicating whether to automatically execute the query on mount or when query changes. Defaults to true.\n * @param options.execute - Function to execute with the current query parameters. Called when autoExecute is true and query changes.\n * @returns An object containing functions to manage the query state\n * @returns getQuery - Function that returns the current query parameters of type Q\n * @returns setQuery - Function that updates the query parameters and triggers execution if autoExecute is enabled\n *\n * @example\n * ```typescript\n * interface UserQuery {\n * id: string;\n * name?: string;\n * }\n *\n * function UserComponent() {\n * const executeQuery = async (query: UserQuery) => {\n * // Perform query execution logic here\n * console.log('Executing query:', query);\n * };\n *\n * const { getQuery, setQuery } = useQueryState<UserQuery>({\n * initialQuery: { id: '1' },\n * autoExecute: true,\n * execute: executeQuery,\n * });\n *\n * const handleQueryChange = (newQuery: UserQuery) => {\n * setQuery(newQuery); // Will automatically execute if autoExecute is true\n * };\n *\n * const currentQuery = getQuery(); // Get current query parameters\n *\n * return (\n * <div>\n * <button onClick={() => handleQueryChange({ id: '2', name: 'John' })}>\n * Update Query\n * </button>\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * // Example with autoExecute disabled\n * const { getQuery, setQuery } = useQueryState<UserQuery>({\n * initialQuery: { id: '1' },\n * autoExecute: false,\n * execute: executeQuery,\n * });\n *\n * // Manually trigger execution\n * setQuery({ id: '2' });\n * executeQuery(getQuery());\n *\n * @throws {Error} Throws an error if neither initialQuery nor query is provided in the options.\n * @throws Exceptions may also be thrown by the execute function if it encounters errors during query execution.\n */\nexport function useQueryState<Q>(\n options: UseQueryStateOptions<Q>,\n): UseQueryStateReturn<Q> {\n const { initialQuery, query, autoExecute = true, execute } = options;\n const queryOptions = query ?? initialQuery;\n const queryRef = useRef<Q>(queryOptions);\n\n const getQuery = useCallback(() => {\n return queryRef.current;\n }, []);\n\n const executeWrapper = useCallback(() => {\n const currentQuery = getQuery();\n if (autoExecute && isValidateQuery(currentQuery)) {\n execute(currentQuery);\n }\n }, [autoExecute, execute, getQuery]);\n const setQuery = useCallback(\n (query: Q) => {\n queryRef.current = query;\n executeWrapper();\n },\n [queryRef, executeWrapper],\n );\n\n useEffect(() => {\n if (isValidateQuery(query)) {\n queryRef.current = query;\n }\n executeWrapper();\n }, [executeWrapper, query]);\n\n return { getQuery, setQuery };\n}\n\nexport function isValidateQuery<Q>(query: Q | undefined): query is Q {\n return query !== undefined;\n}","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n useExecutePromise,\n useLatest,\n UseExecutePromiseReturn,\n UseExecutePromiseOptions,\n PromiseSupplier, QueryOptions, isValidateQuery,\n} from './index';\nimport { useCallback, useMemo } from 'react';\nimport { AttributesCapable, FetcherError } from '@ahoo-wang/fetcher';\nimport { useQueryState, UseQueryStateReturn } from './useQueryState';\nimport { AutoExecuteCapable } from '../types';\n\n/**\n * Configuration options for the useQuery hook\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value\n */\nexport interface UseQueryOptions<Q, R, E = FetcherError>\n extends UseExecutePromiseOptions<R, E>,\n QueryOptions<Q>,\n AttributesCapable,\n AutoExecuteCapable {\n\n /** Function to execute the query with given parameters and optional attributes */\n execute: (\n query: Q,\n attributes?: Record<string, any>,\n abortController?: AbortController,\n ) => Promise<R>;\n}\n\n/**\n * Return type of the useQuery hook\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value\n */\nexport interface UseQueryReturn<\n Q,\n R,\n E = FetcherError,\n> extends UseExecutePromiseReturn<R, E>, UseQueryStateReturn<Q> {\n /** Function to execute the query with current parameters */\n execute: () => Promise<void>;\n}\n\n\n/**\n * A React hook for managing query-based asynchronous operations\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value\n * @param options - Configuration options for the query\n * @returns An object containing the query state and control functions\n *\n * @example\n * ```typescript\n * import { useQuery } from '@ahoo-wang/fetcher-react';\n *\n * interface UserQuery {\n * id: string;\n * }\n *\n * interface User {\n * id: string;\n * name: string;\n * }\n *\n * function UserComponent() {\n * const { loading, result, error, execute, setQuery } = useQuery<UserQuery, User>({\n * initialQuery: { id: '1' },\n * execute: async (query) => {\n * const response = await fetch(`/api/users/${query.id}`);\n * return response.json();\n * },\n * autoExecute: true,\n * });\n *\n * const handleUserChange = (userId: string) => {\n * setQuery({ id: userId }); // Automatically executes if autoExecute is true\n * };\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * return (\n * <div>\n * <button onClick={() => handleUserChange('2')}>Load User 2</button>\n * {result && <p>User: {result.name}</p>}\n * </div>\n * );\n * }\n * ```\n */\nexport function useQuery<Q, R, E = FetcherError>(\n options: UseQueryOptions<Q, R, E>,\n): UseQueryReturn<Q, R, E> {\n const latestOptionsRef = useLatest(options);\n const {\n loading,\n result,\n error,\n status,\n execute: promiseExecutor,\n reset,\n abort,\n } = useExecutePromise<R, E>(options);\n\n const execute = useCallback(\n (query: Q) => {\n const queryExecutor: PromiseSupplier<R> = async (\n abortController: AbortController,\n ): Promise<R> => {\n return latestOptionsRef.current.execute(\n query,\n latestOptionsRef.current.attributes,\n abortController,\n );\n };\n return promiseExecutor(queryExecutor);\n },\n [promiseExecutor, latestOptionsRef],\n );\n\n const { getQuery, setQuery } = useQueryState({\n initialQuery: options.initialQuery,\n query: options.query,\n autoExecute: options.autoExecute,\n execute,\n });\n\n const executeWrapper = useCallback(async () => {\n const query = getQuery();\n if (isValidateQuery(query)) {\n return await execute(query);\n }\n }, [execute, getQuery]);\n\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n execute: executeWrapper,\n reset,\n abort,\n getQuery,\n setQuery,\n }),\n [\n loading,\n result,\n error,\n status,\n executeWrapper,\n reset,\n abort,\n getQuery,\n setQuery,\n ],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useSyncExternalStore } from 'react';\nimport { KeyStorage } from '@ahoo-wang/fetcher-storage';\nimport { nameGenerator } from '@ahoo-wang/fetcher-eventbus';\n\nexport function useKeyStorage<T>(\n keyStorage: KeyStorage<T>,\n): [T | null, (value: T) => void, () => void];\n\nexport function useKeyStorage<T>(\n keyStorage: KeyStorage<T>,\n defaultValue: T,\n): [T, (value: T) => void, () => void];\n\n/**\n * A React hook that provides reactive state management for a KeyStorage instance.\n *\n * This hook creates a reactive connection to a KeyStorage instance, automatically subscribing\n * to storage changes and updating the component state when the stored value changes.\n * It leverages React's `useSyncExternalStore` for optimal performance and proper SSR support.\n *\n * The hook provides two usage patterns:\n * 1. Without a default value: Returns nullable state that reflects the storage state\n * 2. With a default value: Returns non-nullable state, using the default when storage is empty\n *\n * @template T - The type of value stored in the key storage\n * @param keyStorage - The KeyStorage instance to subscribe to and manage. This should be a\n * stable reference (useRef, memo, or module-level instance)\n * @param defaultValue - Optional default value to use when storage is empty.\n * When provided, the returned value is guaranteed to be non-null.\n * @returns A tuple containing the current stored value (or default/null), a function to update it,\n * and a function to remove the stored value.\n * The value will be null if no default is provided and storage is empty.\n * @throws {Error} Propagates errors from KeyStorage operations, such as serialization failures\n * or storage access errors that may occur during get, set, or remove operations.\n *\n * @example\n * ```typescript\n * import { useKeyStorage } from '@ahoo-wang/fetcher-react';\n * import { KeyStorage } from '@ahoo-wang/fetcher-storage';\n *\n * // Create a storage instance (typically at module level or with useRef)\n * const userStorage = new KeyStorage<string>('user');\n *\n * function UserProfile() {\n * // Without default value - can be null\n * const [userName, setUserName, removeUserName] = useKeyStorage(userStorage);\n *\n * return (\n * <div>\n * <p>Current user: {userName || 'Not logged in'}</p>\n * <button onClick={() => setUserName('John Doe')}>\n * Set User\n * </button>\n * <button onClick={removeUserName}>\n * Logout\n * </button>\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```typescript\n * // With default value - guaranteed to be non-null\n * const [theme, setTheme, resetTheme] = useKeyStorage(themeStorage, 'light');\n *\n * return (\n * <div className={theme}>\n * <button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>\n * Toggle Theme\n * </button>\n * <button onClick={resetTheme}>\n * Reset to Default\n * </button>\n * </div>\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Using with complex objects\n * const [userPrefs, setUserPrefs, clearPrefs] = useKeyStorage(preferencesStorage, {\n * theme: 'light',\n * language: 'en',\n * notifications: true\n * });\n *\n * // Update specific properties\n * const updateTheme = (newTheme: string) => {\n * setUserPrefs({ ...userPrefs, theme: newTheme });\n * };\n *\n * // Clear all preferences\n * const resetPrefs = () => clearPrefs();\n * ```\n */\nexport function useKeyStorage<T>(\n keyStorage: KeyStorage<T>,\n defaultValue?: T,\n): [T | null, (value: T) => void, () => void] {\n // Create subscription function for useSyncExternalStore\n // This function returns an unsubscribe function that will be called on cleanup\n const subscribe = useCallback(\n (callback: () => void) => {\n return keyStorage.addListener({\n name: nameGenerator.generate('useKeyStorage'), // Generate unique listener name\n handle: callback, // Callback to trigger React re-render on storage changes\n });\n },\n [keyStorage], // Recreate subscription only if keyStorage changes\n );\n\n // Create snapshot function that returns current storage state\n // This function is called by useSyncExternalStore to get the current value\n const getSnapshot = useCallback(() => {\n const storedValue = keyStorage.get();\n // Return stored value if it exists, otherwise return default value or null\n return storedValue !== null ? storedValue : (defaultValue ?? null);\n }, [keyStorage, defaultValue]); // Recreate snapshot when dependencies change\n\n // Use React's useSyncExternalStore for reactive external store connection\n // This ensures proper subscription management and SSR compatibility\n const value = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\n // Create stable setter function reference\n // This function updates the storage and triggers re-renders in subscribed components\n const setValue = useCallback(\n (value: T) => keyStorage.set(value),\n [keyStorage], // Recreate setter only if keyStorage changes\n );\n\n // Create stable remover function reference\n // This function removes the stored value and triggers re-renders\n const remove = useCallback(\n () => keyStorage.remove(),\n [keyStorage], // Recreate remover only if keyStorage changes\n );\n\n // Return tuple of current value, setter function, and remover function\n return [value, setValue, remove];\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback } from 'react';\nimport { KeyStorage } from '@ahoo-wang/fetcher-storage';\nimport { useKeyStorage } from './useKeyStorage';\nimport { produce } from 'immer';\n\nexport function useImmerKeyStorage<T>(\n keyStorage: KeyStorage<T>,\n): [T | null, (updater: (draft: T | null) => T | null | void) => void, () => void];\n\nexport function useImmerKeyStorage<T>(\n keyStorage: KeyStorage<T>,\n defaultValue: T,\n): [T, (updater: (draft: T) => T | null | void) => void, () => void];\n/**\n * A React hook that provides Immer-based immutable state management for a KeyStorage instance.\n *\n * This hook extends `useKeyStorage` by integrating Immer's `produce` function, allowing\n * developers to perform \"mutable\" updates on the stored value in an immutable way. It creates\n * a reactive connection to a KeyStorage instance, automatically subscribing to storage changes\n * and updating the component state when the stored value changes. It leverages React's\n * `useSyncExternalStore` for optimal performance and proper SSR support.\n *\n * The hook provides two usage patterns:\n * 1. Without a default value: Returns nullable state that reflects the storage state\n * 2. With a default value: Returns non-nullable state, using the default when storage is empty\n *\n * The updater function allows modifying a draft of the current value, providing an intuitive\n * mutable API while maintaining immutability under the hood.\n *\n * @template T - The type of value stored in the key storage\n * @param keyStorage - The KeyStorage instance to subscribe to and manage. This should be a\n * stable reference (useRef, memo, or module-level instance)\n * @param defaultValue - Optional default value to use when storage is empty.\n * When provided, the returned value is guaranteed to be non-null.\n * @returns A tuple containing the current stored value (or default/null), an Immer-based updater function,\n * and a function to remove the stored value.\n * The value will be null if no default is provided and storage is empty.\n * @throws {Error} Propagates errors from KeyStorage operations, such as serialization failures\n * or storage access errors that may occur during get, set, or remove operations.\n * Also propagates errors from the updater function or Immer's produce.\n *\n * @example\n * ```typescript\n * import { useImmerKeyStorage } from '@ahoo-wang/fetcher-react';\n * import { KeyStorage } from '@ahoo-wang/fetcher-storage';\n *\n * // Create a storage instance (typically at module level or with useRef)\n * const userPrefsStorage = new KeyStorage<{ theme: string; lang: string }>('user-prefs');\n *\n * function UserPreferences() {\n * // Without default value - can be null\n * const [prefs, updatePrefs, clearPrefs] = useImmerKeyStorage(userPrefsStorage);\n *\n * return (\n * <div>\n * <p>Theme: {prefs?.theme || 'default'}</p>\n * <button onClick={() => updatePrefs(draft => { draft.theme = 'dark'; })}>\n * Switch to Dark Theme\n * </button>\n * <button onClick={clearPrefs}>\n * Clear Preferences\n * </button>\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```typescript\n * // With default value - guaranteed to be non-null\n * const [settings, updateSettings, resetSettings] = useImmerKeyStorage(settingsStorage, {\n * volume: 50,\n * muted: false\n * });\n *\n * return (\n * <div>\n * <p>Volume: {settings.volume}</p>\n * <button onClick={() => updateSettings(draft => { draft.volume += 10; })}>\n * Increase Volume\n * </button>\n * <button onClick={() => updateSettings(draft => { draft.muted = !draft.muted; })}>\n * Toggle Mute\n * </button>\n * <button onClick={resetSettings}>\n * Reset to Default\n * </button>\n * </div>\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Returning a new value instead of modifying draft\n * const [counter, updateCounter, resetCounter] = useImmerKeyStorage(counterStorage, 0);\n *\n * return (\n * <div>\n * <p>Count: {counter}</p>\n * <button onClick={() => updateCounter(draft => draft + 1)}>\n * Increment\n * </button>\n * <button onClick={() => updateCounter(() => 0)}>\n * Reset to Zero\n * </button>\n * </div>\n * );\n * ```\n */\nexport function useImmerKeyStorage<T>(\n keyStorage: KeyStorage<T>,\n defaultValue?: T,\n): [\n T | null,\n (updater: (draft: T | null) => T | null | void) => void,\n () => void,\n] {\n const [value, setValue, remove] = useKeyStorage<T>(\n keyStorage,\n defaultValue as T,\n );\n const updateImmer = useCallback(\n (updater: (draft: T | null) => T | null | void) => {\n const nextValue = produce(value, updater);\n if (nextValue === null) {\n remove();\n return;\n }\n return setValue(nextValue);\n },\n [value, setValue, remove],\n );\n\n return [value, updateImmer, remove];\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback } from 'react';\nimport { useKeyStorage } from '../storage';\nimport {\n TokenStorage,\n CompositeToken,\n CoSecJwtPayload,\n} from '@ahoo-wang/fetcher-cosec';\nimport { useLatest } from '../core';\n\n/**\n * Type representing a composite token provider.\n * Can be either a direct composite token or a function that returns a promise of a composite token.\n */\ntype CompositeTokenProvider = CompositeToken | (() => Promise<CompositeToken>);\n\nexport const ANONYMOUS_USER: CoSecJwtPayload = {\n jti: '',\n sub: 'anonymous',\n iat: 0,\n exp: 0,\n};\n\n/**\n * Options for configuring the useSecurity hook.\n */\nexport interface UseSecurityOptions {\n /**\n * Callback function invoked when sign in is successful.\n * This is called after the token has been successfully stored.\n */\n onSignIn?: () => void;\n\n /**\n * Callback function invoked when sign out occurs.\n * This is called after the token has been removed.\n */\n onSignOut?: () => void;\n}\n\n/**\n * Return type for the useSecurity hook.\n */\nexport interface UseSecurityReturn {\n /**\n * The current authenticated user's JWT payload, or ANONYMOUS_USER if not authenticated.\n * Contains user information extracted from the access token.\n */\n currentUser: CoSecJwtPayload;\n\n /**\n * Boolean indicating whether the user is currently authenticated.\n * True if a valid token exists and the user is signed in, false otherwise.\n */\n authenticated: boolean;\n\n /**\n * Function to sign in with a composite token or a function that returns a promise of composite token.\n * @param compositeTokenProvider - Either a composite token containing access and refresh tokens,\n * or a function that returns a promise resolving to a composite token.\n * @returns A promise that resolves when the sign-in operation is complete.\n */\n signIn: (compositeTokenProvider: CompositeTokenProvider) => Promise<void>;\n\n /**\n * Function to sign out the current user.\n */\n signOut: () => void;\n}\n\n/**\n * Hook for managing authentication state and operations using CoSec tokens.\n *\n * This hook provides reactive access to the current user information, authentication status,\n * and methods to sign in and sign out. It integrates with the TokenStorage to persist tokens\n * and updates the state reactively when tokens change.\n *\n * @param tokenStorage - The token storage instance used to manage authentication tokens.\n * This should be a valid TokenStorage implementation that handles\n * token persistence and retrieval.\n * @param options - Optional configuration object containing lifecycle callbacks.\n * @param options.onSignIn - Callback function invoked when sign in is successful.\n * @param options.onSignOut - Callback function invoked when sign out occurs.\n * @returns An object containing:\n * - currentUser: The current authenticated user's JWT payload, or null if not authenticated.\n * - authenticated: Boolean indicating whether the user is currently authenticated.\n * - signIn: Function to authenticate with a composite token.\n * - signOut: Function to sign out the current user.\n * @throws {Error} May throw errors if tokenStorage operations fail, such as invalid tokens\n * or storage access issues (implementation dependent).\n * @example\n * ```typescript\n * import { useSecurity } from '@ahoo-wang/fetcher-react';\n * import { tokenStorage } from './tokenStorage';\n * import { useNavigate } from 'react-router-dom';\n *\n * function App() {\n * const navigate = useNavigate();\n *\n * const { currentUser, authenticated, signIn, signOut } = useSecurity(tokenStorage, {\n * onSignIn: () => {\n * // Redirect to dashboard after successful login\n * navigate('/dashboard');\n * },\n * onSignOut: () => {\n * // Redirect to login page after logout\n * navigate('/login');\n * }\n * });\n *\n * const handleSignIn = async () => {\n * // Direct token\n * await signIn(compositeToken);\n *\n * // Or async function\n * await signIn(async () => {\n * const response = await fetch('/api/auth/login', {\n * method: 'POST',\n * body: JSON.stringify({ username, password })\n * });\n * return response.json();\n * });\n * };\n *\n * if (!authenticated) {\n * return <button onClick={handleSignIn}>Sign In</button>;\n * }\n *\n * return (\n * <div>\n * <p>Welcome, {currentUser?.sub}!</p>\n * <button onClick={signOut}>Sign Out</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useSecurity(\n tokenStorage: TokenStorage,\n options: UseSecurityOptions = {},\n): UseSecurityReturn {\n // Use useKeyStorage to get reactive updates when token changes\n const [token, , remove] = useKeyStorage(tokenStorage);\n const optionsRef = useLatest(options);\n const signIn = useCallback(\n async (compositeTokenProvider: CompositeTokenProvider) => {\n const compositeToken =\n typeof compositeTokenProvider === 'function'\n ? await compositeTokenProvider()\n : compositeTokenProvider;\n tokenStorage.signIn(compositeToken);\n optionsRef.current.onSignIn?.();\n },\n [tokenStorage, optionsRef],\n );\n const signOut = useCallback(() => {\n remove();\n optionsRef.current.onSignOut?.();\n }, [remove, optionsRef]);\n\n return {\n currentUser: token?.access?.payload ?? ANONYMOUS_USER,\n authenticated: token?.authenticated ?? false,\n signIn,\n signOut,\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n useSecurity,\n UseSecurityOptions,\n UseSecurityReturn,\n} from './useSecurity';\nimport { createContext, ReactNode, useContext } from 'react';\nimport { TokenStorage } from '@ahoo-wang/fetcher-cosec';\n\n/**\n * Type alias for the security context value, representing the authentication state and methods.\n * This is equivalent to the return type of the useSecurity hook, providing reactive access to:\n * - Current authenticated user information (JWT payload)\n * - Authentication status (boolean flag)\n * - Sign-in method for authenticating users\n * - Sign-out method for clearing authentication\n *\n * Used internally by the SecurityContext to type the context value.\n */\nexport type SecurityContext = UseSecurityReturn;\n\n/**\n * React context for managing authentication state across the component tree.\n * This context enables sharing of authentication state and methods between components\n * without prop drilling. Components can access authentication data and methods through\n * the useSecurityContext hook when wrapped by the SecurityProvider.\n *\n * The context value is undefined by default, requiring components to be wrapped by\n * SecurityProvider to access authentication functionality.\n */\nexport const SecurityContext = createContext<SecurityContext | undefined>(\n undefined,\n);\n\n/**\n * Configuration options for the SecurityProvider component.\n * Extends UseSecurityOptions to include provider-specific settings like token storage and children.\n */\nexport interface SecurityContextOptions extends UseSecurityOptions {\n /**\n * The token storage instance used to manage authentication tokens.\n * This should be a valid TokenStorage implementation that handles token persistence,\n * retrieval, and lifecycle management across different storage backends (localStorage,\n * sessionStorage, memory, etc.).\n */\n tokenStorage: TokenStorage;\n\n /**\n * The child components that will have access to the security context.\n * These components can use the useSecurityContext hook to access authentication state and methods.\n */\n children: ReactNode;\n}\n\n/**\n * Provider component that supplies authentication state and methods to its child components.\n * This component wraps the application or a portion of it to provide access to authentication\n * functionality through the useSecurityContext hook. It internally uses the useSecurity hook\n * to manage authentication state and makes it available via React context.\n *\n * @param tokenStorage - The token storage instance for managing authentication tokens.\n * This should be a valid TokenStorage implementation that handles\n * token persistence, retrieval, and lifecycle management across different\n * storage backends (localStorage, sessionStorage, memory, etc.).\n * @param children - The child components that will have access to the security context.\n * These components can use the useSecurityContext hook to access authentication\n * state and methods without prop drilling.\n * @param useSecurityOptions - Optional configuration object containing lifecycle callbacks\n * for sign-in and sign-out events. Extends UseSecurityOptions interface.\n * @param useSecurityOptions.onSignIn - Callback function invoked when sign in is successful.\n * @param useSecurityOptions.onSignOut - Callback function invoked when sign out occurs.\n * @returns A React element that provides the security context to its children.\n * The context value includes currentUser, authenticated status, signIn, and signOut methods.\n * @throws {Error} May throw errors if tokenStorage operations fail during initialization,\n * such as invalid tokens or storage access issues (implementation dependent).\n * @example\n * ```tsx\n * import { SecurityProvider } from '@ahoo-wang/fetcher-react';\n * import { tokenStorage } from './tokenStorage';\n * import { useNavigate } from 'react-router-dom';\n *\n * function App() {\n * const navigate = useNavigate();\n *\n * return (\n * <SecurityProvider\n * tokenStorage={tokenStorage}\n * onSignIn={() => navigate('/dashboard')}\n * onSignOut={() => navigate('/login')}\n * >\n * <MyApp />\n * </SecurityProvider>\n * );\n * }\n * ```\n */\nexport function SecurityProvider({\n tokenStorage,\n children,\n ...useSecurityOptions\n}: SecurityContextOptions) {\n const value = useSecurity(tokenStorage, useSecurityOptions);\n return (\n <SecurityContext.Provider value={value}>\n {children}\n </SecurityContext.Provider>\n );\n}\n\n/**\n * Hook to access the security context within components wrapped by SecurityProvider.\n * This hook provides reactive access to authentication state and methods throughout the component tree.\n *\n * @returns The security context containing currentUser, authenticated status, signIn, and signOut methods.\n * @throws {Error} Throws an error if used outside of a SecurityProvider component.\n * @example\n * ```tsx\n * import { useSecurityContext } from '@ahoo-wang/fetcher-react';\n *\n * function UserProfile() {\n * const { currentUser, authenticated, signOut } = useSecurityContext();\n *\n * if (!authenticated) {\n * return <div>Please sign in</div>;\n * }\n *\n * return (\n * <div>\n * <p>Welcome, {currentUser?.sub}!</p>\n * <button onClick={signOut}>Sign Out</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useSecurityContext(): SecurityContext {\n const context = useContext(SecurityContext);\n if (!context) {\n throw new Error(\n 'useSecurityContext must be used within a SecurityProvider',\n );\n }\n return context;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ReactNode } from 'react';\nimport { useSecurityContext } from './SecurityContext';\n\n/**\n * Props for the RouteGuard component.\n */\nexport interface RouteGuardProps {\n /**\n * The content to render when the user is authenticated.\n */\n children: ReactNode;\n\n /**\n * The fallback content to render when the user is not authenticated.\n * If not provided, nothing will be rendered.\n */\n fallback?: ReactNode;\n\n /**\n * Optional redirect function to call when user is not authenticated.\n * This can be used to programmatically navigate to a login page.\n */\n onUnauthorized?: () => void;\n}\n\n/**\n * Route guard component that conditionally renders content based on authentication status.\n *\n * This component uses the SecurityContext to check if the user is authenticated.\n * If authenticated, it renders the children. If not authenticated, it renders the fallback\n * content (if provided) and optionally calls the onUnauthorized callback.\n *\n * @param children - The protected content to render when authenticated.\n * @param fallback - Optional fallback content to render when not authenticated.\n * @param onUnauthorized - Optional callback to execute when user is not authenticated.\n * @returns The children if authenticated, fallback if provided, or null otherwise.\n * @example\n * ```tsx\n * import { RouteGuard } from '@ahoo-wang/fetcher-react';\n *\n * function ProtectedPage() {\n * return (\n * <RouteGuard\n * fallback={<div>Please log in to access this page.</div>}\n * onUnauthorized={() => navigate('/login')}\n * >\n * <div>Protected content</div>\n * </RouteGuard>\n * );\n * }\n * ```\n */\nexport function RouteGuard({\n children,\n fallback,\n onUnauthorized,\n}: RouteGuardProps) {\n const { authenticated } = useSecurityContext();\n\n if (authenticated) {\n return <>{children}</>;\n }\n\n // Call onUnauthorized callback if provided\n if (onUnauthorized) {\n onUnauthorized();\n }\n\n // Return fallback if provided, otherwise return null\n return fallback;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RouteGuardProps } from './RouteGuard';\nimport { ReactNode, useCallback, useEffect } from 'react';\nimport { JwtTokenManager } from '@ahoo-wang/fetcher-cosec';\nimport { useSecurityContext } from './SecurityContext';\n\nexport interface RefreshableRouteGuardProps extends Omit<RouteGuardProps, 'onUnauthorized'> {\n refreshing?: ReactNode;\n tokenManager: JwtTokenManager;\n}\n\nexport function RefreshableRouteGuard({\n children,\n fallback,\n refreshing,\n tokenManager,\n }: RefreshableRouteGuardProps) {\n const { authenticated } = useSecurityContext();\n const refreshable = tokenManager.isRefreshNeeded && tokenManager.isRefreshable;\n const refreshToken = useCallback(async () => {\n if (refreshable) {\n try {\n await tokenManager.refresh();\n } catch (error) {\n console.error(error);\n }\n }\n }, [refreshable, tokenManager]);\n\n useEffect(() => {\n refreshToken();\n }, [refreshToken]);\n\n if (authenticated) {\n return <>{children}</>;\n }\n\n if (!refreshable) {\n return <>{fallback}</>;\n }\n const refreshingNode = refreshing ?? <p>Refreshing...</p>;\n return <>{refreshingNode}</>;\n\n}","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n fetcherRegistrar,\n FetcherCapable,\n FetchExchange,\n FetchRequest,\n getFetcher,\n RequestOptions,\n FetcherError,\n} from '@ahoo-wang/fetcher';\nimport {\n useExecutePromise,\n UseExecutePromiseOptions,\n UseExecutePromiseReturn,\n} from '../core';\nimport { useCallback, useState, useMemo } from 'react';\nimport { useLatest } from '../core';\n\n/**\n * Configuration options for the useFetcher hook.\n * Combines request configuration, fetcher selection, and promise state management options.\n *\n * @template R - The type of the expected result from the fetch operation\n * @template E - The type of error that may be thrown (defaults to FetcherError)\n */\nexport interface UseFetcherOptions<R, E = FetcherError>\n extends RequestOptions,\n FetcherCapable,\n UseExecutePromiseOptions<R, E> {}\n\n/**\n * Return type of the useFetcher hook.\n * Provides access to the current fetch state, result data, and control functions.\n *\n * @template R - The type of the expected result from the fetch operation\n * @template E - The type of error that may be thrown (defaults to FetcherError)\n */\nexport interface UseFetcherReturn<R, E = FetcherError>\n extends Omit<UseExecutePromiseReturn<R, E>, 'execute'> {\n /**\n * The FetchExchange object representing the current or most recent fetch operation.\n * Contains request/response details, timing information, and extracted data.\n * Undefined when no fetch operation has been performed.\n */\n exchange?: FetchExchange;\n\n /**\n * Function to execute a fetch request with automatic abort support.\n * Automatically cancels any ongoing request before starting a new one using AbortController.\n * The abort controller is automatically passed to the underlying fetch operation.\n *\n * @param request - The fetch request configuration including URL, method, headers, etc.\n * @returns Promise that resolves when the fetch operation completes (success or failure)\n */\n execute: (request: FetchRequest) => Promise<void>;\n}\n\n/**\n * A React hook for managing asynchronous HTTP fetch operations with comprehensive state handling,\n * race condition protection, automatic cleanup, and built-in abort support. Provides a clean interface\n * for making API calls with loading states, error handling, and request cancellation.\n *\n * Key features:\n * - Automatic request cancellation on component unmount or new requests via AbortController\n * - Race condition protection using request IDs\n * - Comprehensive state management (idle, loading, success, error)\n * - Type-safe result and error handling\n * - Integration with fetcher ecosystem for advanced features\n * - Memory leak prevention with automatic abort controller cleanup\n *\n * @template R - The type of the expected result from the fetch operation\n * @template E - The type of error that may be thrown (defaults to FetcherError)\n * @param options - Configuration options for the fetcher including request settings,\n * result extraction, error handling, and fetcher selection\n * @returns An object containing the current fetch state, result data, error information,\n * and the execute function to trigger fetch operations\n *\n * @throws {FetcherError} When the fetch operation fails due to network issues,\n * HTTP errors, or result extraction problems\n * @throws {Error} When invalid options are provided or fetcher configuration is incorrect\n *\n * @example Basic GET request with automatic abort\n * ```typescript\n * import { useFetcher } from '@ahoo-wang/fetcher-react';\n * import { ResultExtractors } from '@ahoo-wang/fetcher';\n *\n * function UserProfile({ userId }: { userId: string }) {\n * const { loading, result, error, execute } = useFetcher({\n * resultExtractor: ResultExtractors.Json,\n * });\n *\n * const fetchUser = () => {\n * execute({\n * url: `/api/users/${userId}`,\n * method: 'GET'\n * });\n * };\n *\n * // Multiple calls to fetchUser() will automatically cancel previous requests\n * // Handle loading, error, and success states in your component\n * }\n * ```\n *\n * @example POST request with error handling\n * ```typescript\n * import { useFetcher } from '@ahoo-wang/fetcher-react';\n *\n * function CreatePost() {\n * const { loading, result, error, execute } = useFetcher({\n * onSuccess: (data) => {\n * console.log('Post created:', data);\n * // Handle success (e.g., redirect, show notification)\n * },\n * onError: (error) => {\n * console.error('Failed to create post:', error);\n * // Handle error (e.g., show error message)\n * }\n * });\n *\n * const handleSubmit = (postData: { title: string; content: string }) => {\n * execute({\n * url: '/api/posts',\n * method: 'POST',\n * body: JSON.stringify(postData),\n * headers: {\n * 'Content-Type': 'application/json'\n * }\n * });\n * };\n * }\n * ```\n *\n * @example Using custom fetcher instance\n * ```typescript\n * import { useFetcher } from '@ahoo-wang/fetcher-react';\n * import { getFetcher } from '@ahoo-wang/fetcher';\n *\n * // Using a named fetcher instance\n * const customFetcher = getFetcher('my-custom-fetcher');\n *\n * function CustomApiComponent() {\n * const { loading, result, execute } = useFetcher({\n * fetcher: customFetcher,\n * });\n *\n * // All requests will use the custom fetcher configuration\n * const fetchData = () => execute({ url: '/data', method: 'GET' });\n * }\n * ```\n */\nexport function useFetcher<R, E = FetcherError>(\n options?: UseFetcherOptions<R, E>,\n): UseFetcherReturn<R, E> {\n const { fetcher = fetcherRegistrar.default } = options || {};\n const {\n loading,\n result,\n error,\n status,\n execute: promiseExecutor,\n reset,\n abort,\n } = useExecutePromise<R, E>(options);\n const [exchange, setExchange] = useState<FetchExchange | undefined>(\n undefined,\n );\n const latestOptions = useLatest(options);\n const currentFetcher = getFetcher(fetcher);\n /**\n * Execute the fetch operation with automatic abort support.\n * Cancels any ongoing fetch before starting a new one using AbortController.\n * The abort controller is automatically attached to the request for cancellation support.\n */\n const execute = useCallback(\n async (request: FetchRequest) => {\n try {\n await promiseExecutor(async abortController => {\n request.abortController = abortController;\n const exchange = await currentFetcher.exchange(\n request,\n latestOptions.current,\n );\n setExchange(exchange);\n return await exchange.extractResult<R>();\n });\n } catch (error) {\n setExchange(undefined);\n throw error;\n }\n },\n [promiseExecutor, currentFetcher, latestOptions],\n );\n\n const resetFn = useCallback(() => {\n reset();\n setExchange(undefined);\n }, [reset]);\n const abortFn = useCallback(() => {\n abort();\n setExchange(undefined);\n }, [abort]);\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n exchange,\n execute,\n reset: resetFn,\n abort: abortFn,\n }),\n [loading, result, error, status, exchange, execute, resetFn, abortFn],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useFetcher, UseFetcherOptions, UseFetcherReturn } from '../useFetcher';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport {\n DebounceCapable,\n useDebouncedCallback,\n UseDebouncedCallbackReturn,\n} from '../../core';\nimport { useMemo } from 'react';\n\n/**\n * Configuration options for the useDebouncedFetcher hook.\n * Extends UseFetcherOptions with debouncing capabilities to control the rate\n * at which fetch requests are executed.\n *\n * @template R - The type of the fetch result\n * @template E - The type of the error (defaults to FetcherError)\n */\nexport interface UseDebouncedFetcherOptions<R, E = FetcherError>\n extends UseFetcherOptions<R, E>,\n DebounceCapable {}\n\n/**\n * Return type of the useDebouncedFetcher hook.\n * Provides the same state properties as useFetcher (except execute) along with\n * debounced execution controls.\n *\n * @template R - The type of the fetch result\n * @template E - The type of the error (defaults to FetcherError)\n */\nexport interface UseDebouncedFetcherReturn<R, E = FetcherError>\n extends Omit<UseFetcherReturn<R, E>, 'execute'>,\n UseDebouncedCallbackReturn<UseFetcherReturn<R, E>['execute']> {}\n\n/**\n * A React hook that provides a debounced version of the useFetcher hook.\n * This hook wraps the fetcher's execute function with debouncing to prevent\n * excessive API calls during rapid user interactions, such as typing in a search field.\n *\n * The debouncing behavior is controlled by the `debounce` option, which specifies\n * the delay and whether to execute on the leading edge, trailing edge, or both.\n *\n * @template R - The type of the fetch result\n * @template E - The type of the error (defaults to FetcherError)\n * @param options - Configuration options including fetcher settings and debounce parameters\n * @returns An object containing the fetch state and debounced execution controls\n *\n * @throws {Error} If the debounce delay is not a positive number\n * @throws {Error} If the fetcher configuration is invalid\n *\n * @example\n * ```typescript\n * import { useDebouncedFetcher } from '@ahoo-wang/fetcher-react';\n *\n * function SearchComponent() {\n * const { loading, result, error, run, cancel, isPending } = useDebouncedFetcher<string>({\n * debounce: { delay: 300, trailing: true },\n * onSuccess: (data) => console.log('Search results:', data),\n * onError: (err) => console.error('Search failed:', err),\n * });\n *\n * const handleSearch = (query: string) => {\n * if (query.trim()) {\n * run({ url: `/api/search?q=${encodeURIComponent(query)}`, method: 'GET' });\n * } else {\n * cancel(); // Cancel any pending search\n * }\n * };\n *\n * return (\n * <div>\n * <input\n * type=\"text\"\n * placeholder=\"Search...\"\n * onChange={(e) => handleSearch(e.target.value)}\n * />\n * {isPending() && <div>Searching...</div>}\n * {loading && <div>Loading...</div>}\n * {error && <div>Error: {error.message}</div>}\n * {result && <div>Results: {result}</div>}\n * </div>\n * );\n * }\n * ```\n *\n * @example Debounced form submission\n * ```typescript\n * const { run, cancel, isPending } = useDebouncedFetcher({\n * debounce: { delay: 500, leading: false, trailing: true },\n * onSuccess: () => console.log('Form submitted successfully'),\n * });\n *\n * const handleSubmit = (formData: FormData) => {\n * run({\n * url: '/api/submit',\n * method: 'POST',\n * body: formData,\n * });\n * };\n * ```\n */\nexport function useDebouncedFetcher<R, E = FetcherError>(\n options: UseDebouncedFetcherOptions<R, E>,\n): UseDebouncedFetcherReturn<R, E> {\n const { loading, result, error, status, exchange, execute, reset, abort } =\n useFetcher<R, E>(options);\n const { run, cancel, isPending } = useDebouncedCallback(\n execute,\n options.debounce,\n );\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n exchange,\n reset,\n abort,\n run,\n cancel,\n isPending,\n }),\n [\n loading,\n result,\n error,\n status,\n exchange,\n reset,\n abort,\n run,\n cancel,\n isPending,\n ],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport {\n DebounceCapable,\n useDebouncedCallback,\n UseDebouncedCallbackReturn,\n} from '../../core';\nimport { useCallback, useEffect, useMemo } from 'react';\nimport {\n useFetcherQuery,\n UseFetcherQueryOptions,\n UseFetcherQueryReturn,\n} from '../index';\n\n/**\n * Configuration options for the useDebouncedFetcherQuery hook.\n *\n * Extends UseFetcherQueryOptions with DebounceCapable to provide debouncing functionality.\n * The hook will automatically debounce fetcher query executions to prevent excessive API calls.\n * Note that autoExecute is overridden internally to false to ensure proper debouncing behavior.\n *\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value (defaults to FetcherError)\n */\nexport interface UseDebouncedFetcherQueryOptions<Q, R, E = FetcherError>\n extends UseFetcherQueryOptions<Q, R, E>, DebounceCapable {}\n\n/**\n * Return type of the useDebouncedFetcherQuery hook.\n *\n * Omits the original 'execute' method from UseFetcherQueryReturn and replaces it with\n * debounced execution methods from UseDebouncedCallbackReturn. Uses a custom setQuery function\n * that respects the original autoExecute setting.\n *\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value (defaults to FetcherError)\n */\nexport interface UseDebouncedFetcherQueryReturn<Q, R, E = FetcherError>\n extends\n Omit<UseFetcherQueryReturn<Q, R, E>, 'execute'>,\n UseDebouncedCallbackReturn<UseFetcherQueryReturn<Q, R, E>['execute']> {}\n\n/**\n * A React hook for managing debounced query-based HTTP requests with automatic execution.\n *\n * This hook combines fetcher query functionality with debouncing to provide a convenient way to\n * make POST requests where query parameters are sent as the request body, while preventing\n * excessive API calls during rapid user interactions.\n *\n * The hook supports automatic execution on mount and when query parameters change, but wraps\n * the execution in a debounced callback to optimize performance. Internally, it overrides\n * autoExecute to false and implements custom logic to respect the original autoExecute setting.\n * When autoExecute is enabled, queries triggered by setQuery will also be debounced.\n *\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value (defaults to FetcherError)\n * @param options - Configuration options for the hook, including url, initialQuery, and debounce settings\n * @returns An object containing fetcher state, query management functions, and debounced execution controls\n *\n * @example\n * ```typescript\n * import { useDebouncedFetcherQuery } from '@ahoo-wang/fetcher-react';\n *\n * interface SearchQuery {\n * keyword: string;\n * limit: number;\n * filters?: { category?: string };\n * }\n *\n * interface SearchResult {\n * items: Array<{ id: string; title: string }>;\n * total: number;\n * }\n *\n * function SearchComponent() {\n * const {\n * loading,\n * result,\n * error,\n * run,\n * cancel,\n * isPending,\n * setQuery,\n * getQuery,\n * } = useDebouncedFetcherQuery<SearchQuery, SearchResult>({\n * url: '/api/search',\n * initialQuery: { keyword: '', limit: 10 },\n * debounce: { delay: 300 }, // Debounce for 300ms\n * autoExecute: false, // Don't execute on mount\n * });\n *\n * const handleSearch = (keyword: string) => {\n * setQuery({ keyword, limit: 10 }); // This will trigger debounced execution if autoExecute was true\n * };\n *\n * const handleManualSearch = () => {\n * run(); // Manual debounced execution with current query\n * };\n *\n * const handleCancel = () => {\n * cancel(); // Cancel any pending debounced execution\n * };\n *\n * if (loading) return <div>Searching...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <input\n * type=\"text\"\n * onChange={(e) => handleSearch(e.target.value)}\n * placeholder=\"Search...\"\n * />\n * <button onClick={handleManualSearch} disabled={isPending()}>\n * {isPending() ? 'Searching...' : 'Search'}\n * </button>\n * <button onClick={handleCancel}>Cancel</button>\n * {result && (\n * <div>\n * Found {result.total} items:\n * {result.items.map(item => (\n * <div key={item.id}>{item.title}</div>\n * ))}\n * </div>\n * )}\n * </div>\n * );\n * }\n * ```\n *\n * @throws This hook may throw exceptions related to network requests, which should be\n * handled by the caller. The underlying fetcher may throw FetcherError or other network-related errors.\n * Invalid URL or malformed request options may also cause exceptions.\n */\nexport function useDebouncedFetcherQuery<Q, R, E = FetcherError>(\n options: UseDebouncedFetcherQueryOptions<Q, R, E>,\n): UseDebouncedFetcherQueryReturn<Q, R, E> {\n const originalAutoExecute = options.autoExecute;\n const debouncedExecuteOptions = {\n ...options,\n autoExecute: false,\n };\n const {\n loading,\n result,\n error,\n status,\n execute,\n reset,\n abort,\n getQuery,\n setQuery,\n } = useFetcherQuery(debouncedExecuteOptions);\n const { run, cancel, isPending } = useDebouncedCallback(\n execute,\n options.debounce,\n );\n const setQueryFn = useCallback(\n (query: Q) => {\n setQuery(query);\n if (originalAutoExecute) {\n run();\n }\n },\n [setQuery, run, originalAutoExecute],\n );\n useEffect(() => {\n if (originalAutoExecute) {\n run();\n }\n }, [run, originalAutoExecute]);\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n reset,\n abort,\n getQuery,\n setQuery: setQueryFn,\n run,\n cancel,\n isPending,\n }),\n [\n loading,\n result,\n error,\n status,\n reset,\n abort,\n getQuery,\n setQueryFn,\n run,\n cancel,\n isPending,\n ],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useFetcher, UseFetcherOptions, UseFetcherReturn } from './index';\nimport { FetcherError, FetchRequest, JsonResultExtractor } from '@ahoo-wang/fetcher';\nimport { isValidateQuery, QueryOptions, useLatest, useQueryState, UseQueryStateReturn } from '../core';\nimport { useCallback, useMemo } from 'react';\nimport { AutoExecuteCapable } from '../types';\n\n/**\n * Configuration options for the useFetcherQuery hook\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value\n */\nexport interface UseFetcherQueryOptions<Q, R, E = FetcherError>\n extends UseFetcherOptions<R, E>, QueryOptions<Q>, AutoExecuteCapable {\n /** The URL endpoint to send the POST request to */\n url: string;\n}\n\n/**\n * Return type of the useFetcherQuery hook\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value\n */\nexport interface UseFetcherQueryReturn<Q, R, E = FetcherError>\n extends UseFetcherReturn<R, E>, UseQueryStateReturn<Q> {\n /** Function to execute the query with current parameters */\n execute: () => Promise<void>;\n}\n\n/**\n * A React hook for managing query-based HTTP requests with automatic execution\n *\n * This hook combines the fetcher functionality with query state management to provide\n * a convenient way to make POST requests where query parameters are sent as the request body.\n * It supports automatic execution on mount and when query parameters change.\n *\n * @template Q - The type of the query parameters\n * @template R - The type of the result value\n * @template E - The type of the error value (defaults to FetcherError)\n * @param options - Configuration options for the hook\n * @returns An object containing fetcher state, query management functions, and execution controls\n *\n * @example\n * ```typescript\n * import { useFetcherQuery } from '@ahoo-wang/fetcher-react';\n *\n * interface SearchQuery {\n * keyword: string;\n * limit: number;\n * filters?: { category?: string };\n * }\n *\n * interface SearchResult {\n * items: Array<{ id: string; title: string }>;\n * total: number;\n * }\n *\n * function SearchComponent() {\n * const {\n * loading,\n * result,\n * error,\n * execute,\n * setQuery,\n * getQuery,\n * } = useFetcherQuery<SearchQuery, SearchResult>({\n * url: '/api/search',\n * initialQuery: { keyword: '', limit: 10 },\n * autoExecute: false, // Don't execute on mount\n * });\n *\n * const handleSearch = (keyword: string) => {\n * setQuery({ keyword, limit: 10 }); // This will auto-execute if autoExecute was true\n * };\n *\n * const handleManualSearch = () => {\n * execute(); // Manual execution with current query\n * };\n *\n * if (loading) return <div>Searching...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <input\n * type=\"text\"\n * onChange={(e) => handleSearch(e.target.value)}\n * placeholder=\"Search...\"\n * />\n * <button onClick={handleManualSearch}>Search</button>\n * {result && (\n * <div>\n * Found {result.total} items:\n * {result.items.map(item => (\n * <div key={item.id}>{item.title}</div>\n * ))}\n * </div>\n * )}\n * </div>\n * );\n * }\n * ```\n *\n * @throws This hook may throw exceptions related to network requests, which should be\n * handled by the caller. The execute function may throw FetcherError or other network-related errors.\n * Invalid URL or malformed request options may also cause exceptions.\n */\nexport function useFetcherQuery<Q, R, E = FetcherError>(\n options: UseFetcherQueryOptions<Q, R, E>,\n): UseFetcherQueryReturn<Q, R, E> {\n const useFetcherQueryOptions = {\n resultExtractor: JsonResultExtractor,\n ...options,\n };\n const latestOptionsRef = useLatest(useFetcherQueryOptions);\n const {\n loading,\n result,\n error,\n status,\n execute: fetcherExecute,\n reset,\n abort,\n } = useFetcher<R, E>(useFetcherQueryOptions);\n const execute = useCallback(\n (query: Q) => {\n const fetcherRequest: FetchRequest = {\n url: latestOptionsRef.current.url,\n method: 'POST',\n body: query as Record<string, any>,\n };\n return fetcherExecute(fetcherRequest);\n },\n [fetcherExecute, latestOptionsRef],\n );\n\n const { getQuery, setQuery } = useQueryState({\n initialQuery: useFetcherQueryOptions.initialQuery,\n query: useFetcherQueryOptions.query,\n autoExecute: useFetcherQueryOptions.autoExecute,\n execute,\n });\n\n const executeWrapper = useCallback(async () => {\n const query = getQuery();\n if (isValidateQuery(query)) {\n return await execute(query);\n }\n }, [execute, getQuery]);\n\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n execute: executeWrapper,\n reset,\n abort,\n getQuery,\n setQuery,\n }),\n [\n loading,\n result,\n error,\n status,\n executeWrapper,\n reset,\n abort,\n getQuery,\n setQuery,\n ],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { UseQueryReturn } from '../../core';\nimport { useFetcherQuery, UseFetcherQueryOptions } from '../../fetcher';\nimport { Condition } from '@ahoo-wang/fetcher-wow';\n\n/**\n * Options for configuring the useFetcherCountQuery hook.\n *\n * This interface extends UseFetcherQueryOptions and is specifically tailored for count queries\n * that use a Condition object to filter results and return a numeric count.\n *\n * @template FIELDS - A string union type representing the fields that can be used in the condition.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n */\nexport interface UseFetcherCountQueryOptions<\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseFetcherQueryOptions<Condition<FIELDS>, number, E> {}\n\n/**\n * Return type for the useFetcherCountQuery hook.\n *\n * This interface extends UseQueryReturn and provides the structure for the hook's return value,\n * including data (the count as a number), loading state, error state, and other query-related properties.\n *\n * @template FIELDS - A string union type representing the fields that can be used in the condition.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n */\nexport interface UseFetcherCountQueryReturn<\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<Condition<FIELDS>, number, E> {}\n\n/**\n * A React hook for performing count queries using the Fetcher library.\n *\n * This hook is designed for scenarios where you need to retrieve the count of records\n * that match a specific condition. It wraps the useFetcherQuery hook and specializes\n * it for count operations, returning a number representing the count.\n *\n * @template FIELDS - A string union type representing the fields that can be used in the condition.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n *\n * @param options - Configuration options for the count query, including the condition, fetcher instance, and other query settings.\n * @returns An object containing the query result (count as a number), loading state, error state, and utility functions.\n *\n * @throws {E} Throws an error of type E if the query fails, which could be due to network issues, invalid conditions, or server errors.\n *\n * @example\n * ```typescript\n * import { useFetcherCountQuery } from '@ahoo-wang/fetcher-react';\n * import { all } from '@ahoo-wang/fetcher-wow';\n *\n * function UserCountComponent() {\n * const { data: count, loading, error, execute } = useFetcherCountQuery({\n * url: '/api/users/count',\n * initialQuery: all(),\n * autoExecute: true,\n * });\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <div>Total active users: {count}</div>\n * <button onClick={execute}>Refresh Count</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useFetcherCountQuery<\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UseFetcherCountQueryOptions<FIELDS, E>,\n): UseFetcherCountQueryReturn<FIELDS, E> {\n return useFetcherQuery<Condition<FIELDS>, number, E>(options);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ListQuery } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { UseQueryReturn } from '../../core';\nimport { useFetcherQuery, UseFetcherQueryOptions } from '../../fetcher';\n\n/**\n * Options for the useFetcherListQuery hook.\n * Extends UseFetcherQueryOptions to provide configuration for list queries.\n *\n * @template R - The type of individual items in the result array.\n * @template FIELDS - The fields available for filtering, sorting, and pagination in the list query.\n * @template E - The error type, defaults to FetcherError.\n */\nexport interface UseFetcherListQueryOptions<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseFetcherQueryOptions<ListQuery<FIELDS>, R[], E> {}\n\n/**\n * Return type of the useFetcherListQuery hook.\n * Extends UseQueryReturn to provide state and methods for list query operations.\n *\n * @template R - The type of individual items in the result array.\n * @template FIELDS - The fields available for filtering, sorting, and pagination in the list query.\n * @template E - The error type, defaults to FetcherError.\n */\nexport interface UseFetcherListQueryReturn<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<ListQuery<FIELDS>, R[], E> {}\n\n/**\n * A React hook for executing list queries using the fetcher library within the wow framework.\n *\n * This hook is designed for fetching lists of items with support for filtering, sorting, and pagination\n * through the ListQuery type. It returns an array of results and integrates seamlessly with the fetcher\n * library for HTTP requests.\n *\n * @template R - The type of individual items in the result array (e.g., User, Product).\n * @template FIELDS - The fields available for filtering, sorting, and pagination (e.g., 'name', 'createdAt').\n * @template E - The error type, defaults to FetcherError.\n * @param options - Configuration options including URL, initial list query parameters, and execution settings.\n * @returns An object containing loading state, result array, error state, and query management functions.\n *\n * @example\n * ```typescript\n * import { useFetcherListQuery } from '@ahoo-wang/fetcher-react';\n * import { listQuery, contains, desc } from '@ahoo-wang/fetcher-wow';\n *\n * interface User {\n * id: string;\n * name: string;\n * email: string;\n * createdAt: string;\n * }\n *\n * function UserListComponent() {\n * const {\n * loading,\n * result: users,\n * error,\n * execute,\n * setQuery,\n * getQuery,\n * } = useFetcherListQuery<User, keyof User>({\n * url: '/api/users/list',\n * initialQuery: listQuery({\n * condition: contains('name', 'John'),\n * sort: [desc('createdAt')],\n * limit: 10,\n * }),\n * autoExecute: true,\n * });\n *\n * const loadMore = () => {\n * const currentQuery = getQuery();\n * setQuery({\n * ...currentQuery,\n * limit: (currentQuery.limit || 10) + 10,\n * });\n * };\n *\n * if (loading) return <div>Loading users...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <h2>Users ({users?.length || 0})</h2>\n * <ul>\n * {users?.map(user => (\n * <li key={user.id}>\n * {user.name} - {user.email}\n * </li>\n * ))}\n * </ul>\n * <button onClick={loadMore}>Load More</button>\n * <button onClick={execute}>Refresh list</button>\n * </div>\n * );\n * }\n * ```\n *\n * @throws {FetcherError} When the HTTP request fails due to network issues, invalid responses, or server errors.\n * @throws {Error} When invalid options are provided, such as malformed URLs or unsupported query parameters.\n */\nexport function useFetcherListQuery<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UseFetcherListQueryOptions<R, FIELDS, E>,\n): UseFetcherListQueryReturn<R, FIELDS, E> {\n return useFetcherQuery<ListQuery<FIELDS>, R[], E>(options);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ListQuery } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { UseQueryReturn } from '../../core';\nimport { useFetcherQuery, UseFetcherQueryOptions } from '../../fetcher';\nimport {\n JsonEventStreamResultExtractor,\n JsonServerSentEvent,\n} from '@ahoo-wang/fetcher-eventstream';\n\n/**\n * Options for configuring the useFetcherListStreamQuery hook.\n *\n * This interface extends UseFetcherQueryOptions and is specifically tailored for list stream queries\n * that use a ListQuery to filter results and return a ReadableStream of JSON server-sent events.\n *\n * @template R - The type of the resource or entity contained in each event in the stream.\n * @template FIELDS - A string union type representing the fields that can be used in the list query.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n */\nexport interface UseFetcherListStreamQueryOptions<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseFetcherQueryOptions<\n ListQuery<FIELDS>,\n ReadableStream<JsonServerSentEvent<R>>,\n E\n> {}\n\n/**\n * Return type for the useFetcherListStreamQuery hook.\n *\n * This interface extends UseQueryReturn and provides the structure for the hook's return value,\n * including data (a ReadableStream of JSON server-sent events), loading state, error state, and other query-related properties.\n *\n * @template R - The type of the resource or entity contained in each event in the stream.\n * @template FIELDS - A string union type representing the fields that can be used in the list query.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n */\nexport interface UseFetcherListStreamQueryReturn<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<\n ListQuery<FIELDS>,\n ReadableStream<JsonServerSentEvent<R>>,\n E\n> {}\n\n/**\n * A React hook for performing list stream queries using the Fetcher library with server-sent events.\n *\n * This hook is designed for scenarios where you need to retrieve a stream of data that matches a list query condition.\n * It returns a ReadableStream of JSON server-sent events, allowing for real-time data streaming.\n * The hook automatically configures the JsonEventStreamResultExtractor for proper stream handling.\n *\n * @template R - The type of the resource or entity contained in each event in the stream.\n * @template FIELDS - A string union type representing the fields that can be used in the list query.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n *\n * @param options - Configuration options for the list stream query, including the list query, fetcher instance, and other query settings.\n * @returns An object containing the query result (a ReadableStream of JSON server-sent events), loading state, error state, and utility functions.\n *\n * @throws {E} Throws an error of type E if the query fails, which could be due to network issues, invalid queries, or server errors.\n *\n * @example\n * ```typescript\n * import { useFetcherListStreamQuery } from '@ahoo-wang/fetcher-react';\n * import { listQuery, contains } from '@ahoo-wang/fetcher-wow';\n * import { JsonServerSentEvent } from '@ahoo-wang/fetcher-eventstream';\n * import { useEffect, useRef } from 'react';\n *\n * interface User {\n * id: number;\n * name: string;\n * }\n *\n * function UserStreamComponent() {\n * const { data: stream, loading, error, execute } = useFetcherListStreamQuery<User, 'id' | 'name'>({\n * url: '/api/users/stream',\n * initialQuery: listQuery({\n * condition: contains('name', 'John'),\n * limit: 10,\n * }),\n * autoExecute: true,\n * });\n *\n * const messagesRef = useRef<HTMLDivElement>(null);\n *\n * useEffect(() => {\n * if (stream) {\n * const reader = stream.getReader();\n * const readStream = async () => {\n * try {\n * while (true) {\n * const { done, value } = await reader.read();\n * if (done) break;\n * // Process the JsonServerSentEvent<User>\n * const newUser = value.data;\n * if (messagesRef.current) {\n * const div = document.createElement('div');\n * div.textContent = `New user: ${newUser.name}`;\n * messagesRef.current.appendChild(div);\n * }\n * }\n * } catch (err) {\n * console.error('Stream error:', err);\n * }\n * };\n * readStream();\n * }\n * }, [stream]);\n *\n * if (loading) return <div>Loading stream...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <div ref={messagesRef}></div>\n * <button onClick={execute}>Restart Stream</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useFetcherListStreamQuery<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UseFetcherListStreamQueryOptions<R, FIELDS, E>,\n): UseFetcherListStreamQueryReturn<R, FIELDS, E> {\n const streamOptions = {\n ...options,\n resultExtractor: JsonEventStreamResultExtractor,\n };\n return useFetcherQuery<\n ListQuery<FIELDS>,\n ReadableStream<JsonServerSentEvent<R>>,\n E\n >(streamOptions);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PagedList, PagedQuery } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { UseQueryReturn } from '../../core';\nimport { useFetcherQuery, UseFetcherQueryOptions } from '../../fetcher';\n\n/**\n * Options for configuring the useFetcherPagedQuery hook.\n *\n * This interface extends UseFetcherQueryOptions and is specifically tailored for paged queries\n * that use a PagedQuery to filter and paginate results, returning a PagedList of items.\n *\n * @template R - The type of the resource or entity contained in each item of the paged list.\n * @template FIELDS - A string union type representing the fields that can be used in the paged query.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n */\nexport interface UseFetcherPagedQueryOptions<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseFetcherQueryOptions<PagedQuery<FIELDS>, PagedList<R>, E> {}\n\n/**\n * Return type for the useFetcherPagedQuery hook.\n *\n * This interface extends UseQueryReturn and provides the structure for the hook's return value,\n * including data (a PagedList containing items and pagination metadata), loading state, error state, and other query-related properties.\n *\n * @template R - The type of the resource or entity contained in each item of the paged list.\n * @template FIELDS - A string union type representing the fields that can be used in the paged query.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n */\nexport interface UseFetcherPagedQueryReturn<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<PagedQuery<FIELDS>, PagedList<R>, E> {}\n\n/**\n * A React hook for performing paged queries using the Fetcher library.\n *\n * This hook is designed for scenarios where you need to retrieve paginated data that matches a query condition.\n * It returns a PagedList containing the items for the current page along with pagination metadata such as total count and page information.\n *\n * @template R - The type of the resource or entity contained in each item of the paged list.\n * @template FIELDS - A string union type representing the fields that can be used in the paged query.\n * @template E - The type of error that may be thrown, defaults to FetcherError.\n *\n * @param options - Configuration options for the paged query, including the paged query parameters, fetcher instance, and other query settings.\n * @returns An object containing the query result (a PagedList with items and pagination info), loading state, error state, and utility functions.\n *\n * @throws {E} Throws an error of type E if the query fails, which could be due to network issues, invalid queries, or server errors.\n *\n * @example\n * ```typescript\n * import { useFetcherPagedQuery } from '@ahoo-wang/fetcher-react';\n * import { pagedQuery, contains, pagination, desc } from '@ahoo-wang/fetcher-wow';\n *\n * interface User {\n * id: number;\n * name: string;\n * email: string;\n * }\n *\n * function UserListComponent() {\n * const {\n * data: pagedList,\n * loading,\n * error,\n * execute,\n * setQuery,\n * getQuery\n * } = useFetcherPagedQuery<User, keyof User>({\n * url: '/api/users/paged',\n * initialQuery: pagedQuery({\n * condition: contains('name', 'John'),\n * sort: [desc('createdAt')],\n * pagination: pagination({ index: 1, size: 10 })\n * }),\n * autoExecute: true,\n * });\n *\n * const goToPage = (page: number) => {\n * const currentQuery = getQuery();\n * setQuery({\n * ...currentQuery,\n * pagination: { ...currentQuery.pagination, index: page }\n * });\n * };\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <h2>Users</h2>\n * <ul>\n * {pagedList.list.map(user => (\n * <li key={user.id}>{user.name} - {user.email}</li>\n * ))}\n * </ul>\n * <div>\n * <span>Total: {pagedList.total} users</span>\n * <button onClick={() => goToPage(1)} disabled={pagedList.pagination.index === 1}>\n * First\n * </button>\n * <button onClick={() => goToPage(pagedList.pagination.index - 1)} disabled={pagedList.pagination.index === 1}>\n * Previous\n * </button>\n * <span>Page {pagedList.pagination.index}</span>\n * <button onClick={() => goToPage(pagedList.pagination.index + 1)}>\n * Next\n * </button>\n * </div>\n * </div>\n * );\n * }\n * ```\n */\nexport function useFetcherPagedQuery<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UseFetcherPagedQueryOptions<R, FIELDS, E>,\n): UseFetcherPagedQueryReturn<R, FIELDS, E> {\n return useFetcherQuery<PagedQuery<FIELDS>, PagedList<R>, E>(options);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SingleQuery } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { UseQueryReturn } from '../../core';\nimport { useFetcherQuery, UseFetcherQueryOptions } from '../../fetcher';\n\n/**\n * Configuration options for the useFetcherSingleQuery hook.\n *\n * Extends UseFetcherQueryOptions to provide configuration for single item queries.\n *\n * @template R - The type of the result item.\n * @template FIELDS - The fields available for filtering and sorting in the single query.\n * @template E - The error type, defaults to FetcherError.\n */\nexport interface UseFetcherSingleQueryOptions<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseFetcherQueryOptions<SingleQuery<FIELDS>, R, E> {}\n\n/**\n * Return type of the useFetcherSingleQuery hook.\n *\n * Extends UseQueryReturn to provide state and methods for single item query operations.\n *\n * @template R - The type of the result item.\n * @template FIELDS - The fields available for filtering and sorting in the single query.\n * @template E - The error type, defaults to FetcherError.\n */\nexport interface UseFetcherSingleQueryReturn<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<SingleQuery<FIELDS>, R, E> {}\n\n/**\n * A React hook for executing single item queries using the fetcher library within the wow framework.\n *\n * This hook is designed for fetching a single item with support for filtering and sorting\n * through the SingleQuery type. It returns a single result item and integrates seamlessly\n * with the fetcher library for HTTP requests.\n *\n * @template R - The type of the result item (e.g., User, Product).\n * @template FIELDS - The fields available for filtering and sorting (e.g., 'id', 'name', 'createdAt').\n * @template E - The error type, defaults to FetcherError.\n * @param options - Configuration options including URL, initial single query parameters, and execution settings.\n * @returns An object containing loading state, result item, error state, and query management functions.\n *\n * @example\n * ```typescript\n * import { useFetcherSingleQuery } from '@ahoo-wang/fetcher-react';\n * import { singleQuery, eq } from '@ahoo-wang/fetcher-wow';\n *\n * interface User {\n * id: string;\n * name: string;\n * email: string;\n * createdAt: string;\n * }\n *\n * function UserProfileComponent({ userId }: { userId: string }) {\n * const {\n * loading,\n * result: user,\n * error,\n * execute,\n * } = useFetcherSingleQuery<User, keyof User>({\n * url: `/api/users/${userId}`,\n * initialQuery: singleQuery({\n * condition: eq('id', userId),\n * }),\n * autoExecute: true,\n * });\n *\n * if (loading) return <div>Loading user...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (!user) return <div>User not found</div>;\n *\n * return (\n * <div>\n * <h2>{user.name}</h2>\n * <p>Email: {user.email}</p>\n * <p>Created: {user.createdAt}</p>\n * <button onClick={execute}>Refresh</button>\n * </div>\n * );\n * }\n * ```\n *\n * @throws {FetcherError} When the HTTP request fails due to network issues, invalid responses, or server errors.\n * @throws {Error} When invalid options are provided, such as malformed URLs or unsupported query parameters.\n */\nexport function useFetcherSingleQuery<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UseFetcherSingleQueryOptions<R, FIELDS, E>,\n): UseFetcherSingleQueryReturn<R, FIELDS, E> {\n return useFetcherQuery<SingleQuery<FIELDS>, R, E>(options);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Condition } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useQuery, UseQueryOptions, UseQueryReturn } from '../core';\n\n/**\n * Options for the useCountQuery hook.\n * Extends UseQueryOptions with Condition as query key and number as data type.\n * @template FIELDS - The fields type for the condition\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseCountQueryOptions<\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryOptions<Condition<FIELDS>, number, E> {}\n\n/**\n * Return type for the useCountQuery hook.\n * Extends UseQueryReturn with Condition as query key and number as data type.\n *\n * @template FIELDS - The fields type for the condition\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseCountQueryReturn<\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<Condition<FIELDS>, number, E> {}\n\n/**\n * Hook for querying count data with conditions.\n * Wraps useQuery to provide type-safe count queries.\n *\n * @template FIELDS - The fields type for the condition\n * @template E - The error type, defaults to FetcherError\n * @param options - The query options including condition and other settings\n * @returns The query result with count data\n *\n * @example\n * ```typescript\n * const { data, isLoading } = useCountQuery({\n * queryKey: [{ field: 'status', operator: 'eq', value: 'active' }],\n * queryFn: async (condition) => fetchCount(condition),\n * });\n * ```\n */\nexport function useCountQuery<FIELDS extends string = string, E = FetcherError>(\n options: UseCountQueryOptions<FIELDS, E>,\n): UseCountQueryReturn<FIELDS, E> {\n return useQuery(options);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ListQuery } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useQuery, UseQueryOptions, UseQueryReturn } from '../core';\n\n/**\n * Options for the useListQuery hook.\n * Extends UseQueryOptions with ListQuery as query key and array of results as data type.\n *\n * @template R - The type of the result items in the list\n * @template FIELDS - The fields type for the list query\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseListQueryOptions<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryOptions<ListQuery<FIELDS>, R[], E> {}\n\n/**\n * Return type for the useListQuery hook.\n * Extends UseQueryReturn with ListQuery as query key and array of results as data type.\n *\n * @template R - The type of the result items in the list\n * @template FIELDS - The fields type for the list query\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseListQueryReturn<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<ListQuery<FIELDS>, R[], E> {}\n\n/**\n * Hook for querying list data with conditions, projection, and sorting.\n * Wraps useQuery to provide type-safe list queries.\n *\n * @template R - The type of the result items in the list\n * @template FIELDS - The fields type for the list query\n * @template E - The error type, defaults to FetcherError\n * @param options - The query options including list query configuration\n * @returns The query result with list data\n *\n * @example\n * ```typescript\n * const { data, isLoading } = useListQuery<{ id: number; name: string }, 'id' | 'name'>({\n * initialQuery: {\n * condition: all(),\n * projection: { include: ['id', 'name'] },\n * sort: [{ field: 'id', direction: SortDirection.ASC }],\n * },\n * execute: async (query) => fetchListData(query),\n * });\n * ```\n */\nexport function useListQuery<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UseListQueryOptions<R, FIELDS, E>,\n): UseListQueryReturn<R, FIELDS, E> {\n return useQuery<ListQuery<FIELDS>, R[], E>(options);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ListQuery } from '@ahoo-wang/fetcher-wow';\nimport type { JsonServerSentEvent } from '@ahoo-wang/fetcher-eventstream';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useQuery, UseQueryOptions, UseQueryReturn } from '../core';\n\n/**\n * Options for the useListStreamQuery hook.\n * Extends UseQueryOptions with ListQuery as query key and stream of events as data type.\n *\n * @template R - The type of the result items in the stream events\n * @template FIELDS - The fields type for the list stream query\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseListStreamQueryOptions<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryOptions<\n ListQuery<FIELDS>,\n ReadableStream<JsonServerSentEvent<R>>,\n E\n > {}\n\n/**\n * Return type for the useListStreamQuery hook.\n * Extends UseQueryReturn with ListQuery as query key and stream of events as data type.\n *\n * @template R - The type of the result items in the stream events\n * @template FIELDS - The fields type for the list stream query\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseListStreamQueryReturn<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<\n ListQuery<FIELDS>,\n ReadableStream<JsonServerSentEvent<R>>,\n E\n > {}\n\n/**\n * Hook for querying streaming list data with conditions, projection, and sorting.\n * Wraps useQuery to provide type-safe streaming list queries.\n *\n * @template R - The type of the result items in the stream events\n * @template FIELDS - The fields type for the list stream query\n * @template E - The error type, defaults to FetcherError\n * @param options - The query options including list stream query configuration\n * @returns The query result with streaming data\n *\n * @example\n * ```typescript\n * const { data, isLoading } = useListStreamQuery<{ id: number; name: string }, 'id' | 'name'>({\n * initialQuery: {\n * condition: all(),\n * projection: { include: ['id', 'name'] },\n * sort: [{ field: 'id', direction: SortDirection.ASC }],\n * },\n * execute: async (query) => fetchStreamData(query),\n * });\n * ```\n */\nexport function useListStreamQuery<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UseListStreamQueryOptions<R, FIELDS, E>,\n): UseListStreamQueryReturn<R, FIELDS, E> {\n return useQuery<ListQuery<FIELDS>, ReadableStream<JsonServerSentEvent<R>>, E>(\n options,\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PagedList, PagedQuery } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useQuery, UseQueryOptions, UseQueryReturn } from '../core';\n\n/**\n * Options for the usePagedQuery hook.\n * Extends UseQueryOptions with PagedQuery as query key and PagedList as data type.\n *\n * @template R - The type of the result items in the paged list\n * @template FIELDS - The fields type for the paged query\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UsePagedQueryOptions<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryOptions<PagedQuery<FIELDS>, PagedList<R>, E> {}\n\n/**\n * Return type for the usePagedQuery hook.\n * Extends UseQueryReturn with PagedQuery as query key and PagedList as data type.\n *\n * @template R - The type of the result items in the paged list\n * @template FIELDS - The fields type for the paged query\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UsePagedQueryReturn<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<PagedQuery<FIELDS>, PagedList<R>, E> {}\n\n/**\n * Hook for querying paged data with conditions, projection, pagination, and sorting.\n * Wraps useQuery to provide type-safe paged queries.\n *\n * @template R - The type of the result items in the paged list\n * @template FIELDS - The fields type for the paged query\n * @template E - The error type, defaults to FetcherError\n * @param options - The query options including paged query configuration\n * @returns The query result with paged list data\n *\n * @example\n * ```typescript\n * const { data, isLoading } = usePagedQuery<{ id: number; name: string }, 'id' | 'name'>({\n * initialQuery: {\n * condition: all(),\n * pagination: { index: 1, size: 10 },\n * projection: { include: ['id', 'name'] },\n * sort: [{ field: 'id', direction: SortDirection.ASC }],\n * },\n * execute: async (query) => fetchPagedData(query),\n * });\n * ```\n */\nexport function usePagedQuery<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UsePagedQueryOptions<R, FIELDS, E>,\n): UsePagedQueryReturn<R, FIELDS, E> {\n return useQuery<PagedQuery<FIELDS>, PagedList<R>, E>(options);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SingleQuery } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useQuery, UseQueryOptions, UseQueryReturn } from '../core';\n\n/**\n * Options for the useSingleQuery hook.\n * Extends UseQueryOptions with SingleQuery as query key and custom result type.\n *\n * @template R - The result type of the query\n * @template FIELDS - The fields type for the single query\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseSingleQueryOptions<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryOptions<SingleQuery<FIELDS>, R, E> {}\n\n/**\n * Return type for the useSingleQuery hook.\n * Extends UseQueryReturn with SingleQuery as query key and custom result type.\n *\n * @template R - The result type of the query\n * @template FIELDS - The fields type for the single query\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseSingleQueryReturn<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n> extends UseQueryReturn<SingleQuery<FIELDS>, R, E> {}\n\n/**\n * Hook for querying a single item with conditions, projection, and sorting.\n * Wraps useQuery to provide type-safe single item queries.\n *\n * @template R - The result type of the query\n * @template FIELDS - The fields type for the single query\n * @template E - The error type, defaults to FetcherError\n * @param options - The query options including single query configuration\n * @returns The query result with single item data\n *\n * @example\n * ```typescript\n * const { data, isLoading } = useSingleQuery<{ id: number; name: string }, 'id' | 'name'>({\n * initialQuery: {\n * condition: all(),\n * projection: { include: ['id', 'name'] },\n * sort: [{ field: 'id', direction: SortDirection.ASC }],\n * },\n * execute: async (query) => fetchSingleItem(query),\n * });\n * ```\n */\nexport function useSingleQuery<\n R,\n FIELDS extends string = string,\n E = FetcherError,\n>(\n options: UseSingleQueryOptions<R, FIELDS, E>,\n): UseSingleQueryReturn<R, FIELDS, E> {\n return useQuery<SingleQuery<FIELDS>, R, E>(options);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useCallback } from 'react';\nimport { EventHandler, TypedEventBus } from '@ahoo-wang/fetcher-eventbus';\n\n/**\n * Options for the useEventSubscription hook.\n * @template EVENT - The type of events handled by the event bus.\n */\nexport interface UseEventSubscriptionOptions<EVENT> {\n /**\n * The typed event bus instance to subscribe to.\n */\n bus: TypedEventBus<EVENT>;\n /**\n * The event handler function that will be called when events are published.\n */\n handler: EventHandler<EVENT>;\n}\n\n/**\n * Return type for the useEventSubscription hook.\n */\nexport interface UseEventSubscriptionReturn {\n /**\n * Function to manually subscribe to the event bus.\n * @returns true if subscription was successful, false otherwise.\n */\n subscribe: () => boolean;\n /**\n * Function to manually unsubscribe from the event bus.\n * @returns true if unsubscription was successful, false otherwise.\n */\n unsubscribe: () => boolean;\n}\n\n/**\n * A React hook for subscribing to events from a typed event bus.\n *\n * This hook automatically subscribes to the event bus when the component mounts\n * and unsubscribes when the component unmounts. It also provides manual subscribe\n * and unsubscribe functions for additional control.\n *\n * @template EVENT - The type of events handled by the event bus. Defaults to unknown.\n * @param options - Configuration options for the subscription.\n * @param options.bus - The typed event bus instance to subscribe to.\n * @param options.handler - The event handler function that will be called when events are published.\n * @returns An object containing subscribe and unsubscribe functions.\n * @throws Will throw an error if the event bus or handler is invalid.\n *\n * @example\n * ```typescript\n * import { useEventSubscription } from '@ahoo-wang/fetcher-react';\n * import { eventBus } from './eventBus';\n *\n * function MyComponent() {\n * const { subscribe, unsubscribe } = useEventSubscription({\n * bus: eventBus,\n * handler: {\n * name: 'myEvent',\n * handle: (event) => {\n * console.log('Received event:', event);\n * }\n * }\n * });\n *\n * // The hook automatically subscribes on mount and unsubscribes on unmount\n * // You can also manually control subscription if needed\n * const handleToggleSubscription = () => {\n * if (someCondition) {\n * subscribe();\n * } else {\n * unsubscribe();\n * }\n * };\n *\n * return <div>My Component</div>;\n * }\n * ```\n */\nexport function useEventSubscription<EVENT = unknown>(\n options: UseEventSubscriptionOptions<EVENT>,\n): UseEventSubscriptionReturn {\n const { bus, handler } = options;\n const subscribe = useCallback(() => {\n return bus.on(handler);\n }, [bus, handler]);\n\n const unsubscribe = useCallback(() => {\n return bus.off(handler.name);\n }, [bus, handler]);\n\n useEffect(() => {\n const success = bus.on(handler);\n if (!success) {\n console.warn(\n `Failed to subscribe to event bus with handler: ${handler.name}`,\n );\n }\n return () => {\n bus.off(handler.name);\n };\n }, [bus, handler]);\n\n return {\n subscribe,\n unsubscribe,\n };\n}\n"],"names":["useLatest","value","ref","useRef","current","useDebouncedCallback","callback","options","$","_c","leading","trailing","Error","timeoutRef","undefined","lastArgsRef","lastInvokeTimeRef","latestCallback","latestOptions","t0","Symbol","for","clearTimeout","cleanTimeout","t1","time","delay","shouldInvoke","t2","time_0","args","invokeCallback","t3","setTimeout","trailingTime","Date","now","scheduleTrailing","t4","t5","args_0","t6","t7","currentTime","run","cancel","isPending","t8","useEffect","t9","useMounted","isMountedRef","isMountedFn","PromiseStatus","IDLE","LOADING","SUCCESS","ERROR","usePromiseState","status","setStatus","useState","initialStatus","result","setResult","error","setError","isMounted","setLoadingFn","useCallback","setSuccessFn","onSuccess","callbackError","console","warn","setErrorFn","onError","setIdleFn","useMemo","loading","setLoading","setSuccess","setIdle","useRequestId","requestIdRef","generate","requestId","isLatest","invalidate","reset","useExecutePromise","abortControllerRef","propagateError","onAbortRef","onAbort","handleOnAbort","execute","input","abort","abortController","AbortController","currentRequestId","data","err","name","useDebouncedExecutePromise","debounce","useDebouncedQuery","originalAutoExecute","autoExecute","debouncedExecuteOptions","getQuery","setQuery","useQuery","query","setQueryFn","getFullscreenElement","document","fullscreenElement","webkitFullscreenElement","mozFullScreenElement","msFullscreenElement","enterFullscreen","element","requestFullscreen","webkitRequestFullscreen","mozRequestFullScreen","msRequestFullscreen","exitFullscreen","webkitExitFullscreen","mozCancelFullScreen","msExitFullscreen","addFullscreenChangeListener","addEventListener","removeFullscreenChangeListener","removeEventListener","useFullscreen","target","targetRef","onChange","isFullscreen","setIsFullscreen","newIsFullscreen","documentElement","handleFullscreenChange","enterFullscreenFn","exitFullscreenFn","_temp","toggleFullscreenFn","toggle","enter","exit","useRefs","refs","Map","get","key","set","has","deleteFn","delete","clear","keys","values","entries","iterator","register","instance","size","useForceUpdate","forceUpdate","useReducer","x","useQueryState","initialQuery","queryRef","currentQuery","isValidateQuery","executeWrapper","query_0","latestOptionsRef","promiseExecutor","__name","attributes","useKeyStorage","keyStorage","defaultValue","addListener","nameGenerator","handle","subscribe","storedValue","getSnapshot","useSyncExternalStore","value_0","setValue","remove","useImmerKeyStorage","updater","nextValue","produce","updateImmer","ANONYMOUS_USER","jti","sub","iat","exp","useSecurity","tokenStorage","token","optionsRef","compositeTokenProvider","compositeToken","signIn","onSignIn","onSignOut","signOut","access","payload","authenticated","currentUser","SecurityContext","createContext","SecurityProvider","children","useSecurityOptions","jsx","useSecurityContext","context","useContext","RouteGuard","fallback","onUnauthorized","RefreshableRouteGuard","refreshing","tokenManager","refreshable","isRefreshNeeded","isRefreshable","refresh","refreshToken","refreshingNode","useFetcher","fetcher","fetcherRegistrar","default","exchange","setExchange","getFetcher","currentFetcher","request","exchange_0","extractResult","resetFn","abortFn","useDebouncedFetcher","useDebouncedFetcherQuery","useFetcherQuery","resultExtractor","JsonResultExtractor","useFetcherQueryOptions","fetcherExecute","fetcherRequest","url","method","body","useFetcherCountQuery","useFetcherListQuery","useFetcherListStreamQuery","JsonEventStreamResultExtractor","useFetcherPagedQuery","useFetcherSingleQuery","useCountQuery","useListQ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q,OAAAoB,GAAApB,OAAAwB,MAAAJ,IAAApB,EAAA,CAAA,GAAAwB,IAAAxB,EAAA,CAAA,IAVjBwC,EAAUpB,GAUPI,CAAc;AAAC,MAAAM;AAAA,SAAA9B,EAAA,EAAA,MAAAsL,KAAAtL,UAAAkR,KAEXpP,IAAA;AAAA,IAAAwJ,WAAAA;AAAAA,IAAA4F,aAAAA;AAAAA,EAAAA,GAGNlR,QAAAsL,GAAAtL,QAAAkR,GAAAlR,QAAA8B,KAAAA,IAAA9B,EAAA,EAAA,GAHM8B;AAGN;AA3BI+O,EAAAA,IAAAA;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahoo-wang/fetcher-react",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.8",
|
|
4
4
|
"description": "React integration for Fetcher HTTP client. Provides React Hooks and components for seamless data fetching with automatic re-rendering and loading states.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fetch",
|