@ahoo-wang/fetcher-react 3.3.6 → 3.3.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/README.md +76 -2
- package/README.zh-CN.md +44 -2
- package/dist/eventbus/index.d.ts +2 -0
- package/dist/eventbus/index.d.ts.map +1 -0
- package/dist/eventbus/useEventSubscription.d.ts +76 -0
- package/dist/eventbus/useEventSubscription.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +240 -217
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -1
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/core/useMounted.ts","../src/core/useLatest.ts","../src/core/usePromiseState.ts","../src/core/useRequestId.ts","../src/core/useExecutePromise.ts","../src/core/useRefs.ts","../src/core/useDebouncedCallback.ts","../src/core/useDebouncedExecutePromise.ts","../src/core/useForceUpdate.ts","../src/storage/useKeyStorage.ts","../src/storage/useImmerKeyStorage.ts","../src/fetcher/useFetcher.ts","../src/fetcher/useDebouncedFetcher.ts","../src/wow/useQuery.ts","../src/wow/usePagedQuery.ts","../src/wow/useSingleQuery.ts","../src/wow/useCountQuery.ts","../src/wow/useListQuery.ts","../src/wow/useListStreamQuery.ts","../src/wow/debounce/useDebouncedQuery.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 { 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 { 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 */\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';\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 onAbort = options?.onAbort;\n const handleOnAbort = useCallback(async () => {\n // Call onAbort callback when automatically cancelling previous request\n try {\n await onAbort?.();\n } catch (callbackError) {\n console.warn('useExecutePromise onAbort callback error:', callbackError);\n }\n }, [onAbort]);\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 { 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 */\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 const timeoutRef = useRef<ReturnType<typeof setTimeout> | undefined>(\n undefined,\n );\n const hasLeadingCalledRef = useRef(false);\n const latestCallback = useLatest(callback);\n const latestOptions = useLatest(options);\n\n const isPending = useCallback(() => {\n return timeoutRef.current !== undefined;\n }, []);\n\n // Function to cancel any pending debounced execution\n const cancel = useCallback(() => {\n if (timeoutRef.current !== undefined) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = undefined;\n }\n }, []);\n\n // Cleanup timeout on component unmount to prevent memory leaks\n useEffect(() => {\n return () => {\n cancel();\n };\n }, [cancel]);\n\n // The debounced function that can be called\n const run = useCallback(\n (...args: Parameters<T>) => {\n const { leading = false, trailing = true, delay } = latestOptions.current;\n // Cancel any existing timeout to reset the debounce timer\n cancel();\n\n // Determine if we should call the function immediately (leading edge)\n const shouldCallLeading = leading && !hasLeadingCalledRef.current;\n\n if (shouldCallLeading) {\n latestCallback.current(...args);\n hasLeadingCalledRef.current = true;\n }\n\n // Schedule the trailing edge execution if enabled\n if (trailing) {\n timeoutRef.current = setTimeout(() => {\n // Only call on trailing edge if not already called on leading edge\n // Use ref value instead of closure value to avoid stale closures\n if (!hasLeadingCalledRef.current) {\n latestCallback.current(...args);\n }\n // Reset leading flag and timeout reference after execution\n hasLeadingCalledRef.current = false;\n timeoutRef.current = undefined;\n }, delay);\n }\n },\n [latestCallback, latestOptions, cancel],\n );\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 {\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 { 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, 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 {\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 {\n useExecutePromise,\n useLatest,\n UseExecutePromiseReturn,\n UseExecutePromiseOptions,\n PromiseSupplier,\n} from '../core';\nimport { useCallback, useMemo, useEffect, useRef } from 'react';\nimport { AttributesCapable, FetcherError } from '@ahoo-wang/fetcher';\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 AttributesCapable,\n AutoExecuteCapable {\n /** The initial query parameters */\n initialQuery: Q;\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<Q, R, E = FetcherError>\n extends UseExecutePromiseReturn<R, E> {\n /**\n * Get the current query parameters\n */\n getQuery: () => Q;\n /** Function to update the query parameters */\n setQuery: (query: Q) => void;\n /** Function to execute the query with current parameters */\n execute: () => Promise<void>;\n}\n\n/* eslint-disable react-hooks/preserve-manual-memoization */\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 latestOptions = useLatest(options);\n const {\n loading,\n result,\n error,\n status,\n execute: promiseExecutor,\n reset,\n abort,\n } = useExecutePromise<R, E>(latestOptions.current);\n const queryRef = useRef(options.initialQuery);\n\n const queryExecutor: PromiseSupplier<R> = useCallback(\n async (abortController: AbortController): Promise<R> => {\n return latestOptions.current.execute(\n queryRef.current,\n latestOptions.current.attributes,\n abortController,\n );\n },\n [queryRef, latestOptions],\n );\n\n const execute = useCallback(() => {\n return promiseExecutor(queryExecutor);\n }, [promiseExecutor, queryExecutor]);\n const getQuery = useCallback(() => {\n return queryRef.current;\n }, [queryRef]);\n const setQuery = useCallback(\n (query: Q) => {\n queryRef.current = query;\n if (latestOptions.current.autoExecute) {\n execute();\n }\n },\n [queryRef, latestOptions, execute],\n );\n\n useEffect(() => {\n if (latestOptions.current.autoExecute) {\n execute();\n }\n }, [latestOptions, execute]);\n\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n execute,\n reset,\n abort,\n getQuery,\n setQuery,\n }),\n [loading, result, error, status, execute, reset, abort, getQuery, setQuery],\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 './useQuery';\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 './useQuery';\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 { Condition } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useQuery, UseQueryOptions, UseQueryReturn } from './useQuery';\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 './useQuery';\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 './useQuery';\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 { FetcherError } from '@ahoo-wang/fetcher';\nimport { useQuery, UseQueryOptions, UseQueryReturn } from '../useQuery';\nimport {\n DebounceCapable,\n useDebouncedCallback,\n UseDebouncedCallbackReturn,\n} from '../../core';\nimport { useMemo } from 'react';\n\n/**\n * Options for the useDebouncedQuery hook, extending UseQueryOptions with debouncing capabilities.\n * @template Q - The query type\n * @template R - The result type\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseDebouncedQueryOptions<Q, R, E = FetcherError>\n extends UseQueryOptions<Q, R, E>,\n DebounceCapable {}\n\n/**\n * Return type for the useDebouncedQuery hook, including query state and debounced execution methods.\n * @template Q - The query type\n * @template R - The result type\n * @template E - The error type, 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 * A React hook that provides debounced query execution, combining the useQuery hook with debouncing functionality\n * to prevent excessive API calls during rapid query changes.\n *\n * @template Q - The query type\n * @template R - The result type\n * @template E - The error type, defaults to FetcherError\n * @param options - Configuration options for the query and debouncing behavior, including debounce settings\n * @returns An object containing query state (loading, result, error, status) and debounced execution methods (run, cancel, isPending)\n *\n * @example\n * ```typescript\n * const { loading, result, error, run, cancel, isPending } = useDebouncedQuery({\n * url: '/api/search',\n * debounce: 300,\n * });\n *\n * // Trigger debounced query\n * run({ q: 'search term' });\n *\n * // Cancel pending debounced query\n * cancel();\n * ```\n *\n * @throws {FetcherError} When the underlying query execution fails\n */\nexport function useDebouncedQuery<Q, R, E = FetcherError>(\n options: UseDebouncedQueryOptions<Q, R, E>,\n): UseDebouncedQueryReturn<Q, R, E> {\n const {\n loading,\n result,\n error,\n status,\n execute,\n reset,\n abort,\n getQuery,\n setQuery,\n } = useQuery(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 reset,\n abort,\n getQuery,\n setQuery,\n run,\n cancel,\n isPending,\n }),\n [\n loading,\n result,\n error,\n status,\n reset,\n abort,\n getQuery,\n setQuery,\n run,\n cancel,\n isPending,\n ],\n );\n}\n"],"names":["useMounted","$","_c","isMountedRef","useRef","t0","Symbol","for","current","isMountedFn","t1","t2","useEffect","useLatest","value","ref","PromiseStatus","IDLE","LOADING","SUCCESS","ERROR","usePromiseState","options","status","setStatus","useState","initialStatus","result","setResult","undefined","error","setError","isMounted","latestOptions","setLoadingFn","useCallback","setSuccessFn","onSuccess","callbackError","console","warn","setErrorFn","onError","setIdleFn","useMemo","loading","setLoading","setSuccess","setIdle","useRequestId","requestIdRef","generate","requestId","isLatest","t3","invalidate","t4","reset","t5","useExecutePromise","abortControllerRef","propagateError","onAbort","handleOnAbort","execute","input","abort","abortController","AbortController","currentRequestId","data","err","Error","name","useRefs","refs","Map","get","key","set","has","deleteFn","delete","clear","keys","values","entries","iterator","register","instance","size","useDebouncedCallback","callback","leading","trailing","timeoutRef","hasLeadingCalledRef","latestCallback","isPending","clearTimeout","cancel","args","t6","t7","delay","setTimeout","run","useDebouncedExecutePromise","debounce","useForceUpdate","forceUpdate","useReducer","_temp","x","useKeyStorage","keyStorage","defaultValue","addListener","nameGenerator","handle","subscribe","storedValue","getSnapshot","useSyncExternalStore","value_0","setValue","remove","useImmerKeyStorage","updater","nextValue","produce","updateImmer","useFetcher","fetcher","fetcherRegistrar","default","promiseExecutor","exchange","setExchange","getFetcher","currentFetcher","request","exchange_0","extractResult","resetFn","abortFn","useDebouncedFetcher","useQuery","queryRef","initialQuery","queryExecutor","attributes","getQuery","setQuery","query","autoExecute","usePagedQuery","useSingleQuery","useCountQuery","useListQuery","useListStreamQuery","useDebouncedQuery"],"mappings":"wmBAuCO,SAAAA,GAAA,CAAA,MAAAC,EAAAC,EAA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AAA7B,KAAAuJ,EAAAvJ,KAAAiG,EAAAjG,KAAA4C,EAAA5C,KAAAwD,EAAAxD,KAAA0B,EAAA1B,KAAAyG,EAAAzG,KAAAwJ,EAAAxJ,MAAAsB,EAAAtB,MAAAI,GAAAA,EAAAJ,EAAA,EAAA,EAZMI,CAYN,CA/BE4J,EAAAA,GAAAA"}
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/core/useMounted.ts","../src/core/useLatest.ts","../src/core/usePromiseState.ts","../src/core/useRequestId.ts","../src/core/useExecutePromise.ts","../src/core/useRefs.ts","../src/core/useDebouncedCallback.ts","../src/core/useDebouncedExecutePromise.ts","../src/core/useForceUpdate.ts","../src/storage/useKeyStorage.ts","../src/storage/useImmerKeyStorage.ts","../src/fetcher/useFetcher.ts","../src/fetcher/useDebouncedFetcher.ts","../src/wow/useQuery.ts","../src/wow/usePagedQuery.ts","../src/wow/useSingleQuery.ts","../src/wow/useCountQuery.ts","../src/wow/useListQuery.ts","../src/wow/useListStreamQuery.ts","../src/wow/debounce/useDebouncedQuery.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 { 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 { 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 */\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';\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 onAbort = options?.onAbort;\n const handleOnAbort = useCallback(async () => {\n // Call onAbort callback when automatically cancelling previous request\n try {\n await onAbort?.();\n } catch (callbackError) {\n console.warn('useExecutePromise onAbort callback error:', callbackError);\n }\n }, [onAbort]);\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 { 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 */\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 const timeoutRef = useRef<ReturnType<typeof setTimeout> | undefined>(\n undefined,\n );\n const hasLeadingCalledRef = useRef(false);\n const latestCallback = useLatest(callback);\n const latestOptions = useLatest(options);\n\n const isPending = useCallback(() => {\n return timeoutRef.current !== undefined;\n }, []);\n\n // Function to cancel any pending debounced execution\n const cancel = useCallback(() => {\n if (timeoutRef.current !== undefined) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = undefined;\n }\n }, []);\n\n // Cleanup timeout on component unmount to prevent memory leaks\n useEffect(() => {\n return () => {\n cancel();\n };\n }, [cancel]);\n\n // The debounced function that can be called\n const run = useCallback(\n (...args: Parameters<T>) => {\n const { leading = false, trailing = true, delay } = latestOptions.current;\n // Cancel any existing timeout to reset the debounce timer\n cancel();\n\n // Determine if we should call the function immediately (leading edge)\n const shouldCallLeading = leading && !hasLeadingCalledRef.current;\n\n if (shouldCallLeading) {\n latestCallback.current(...args);\n hasLeadingCalledRef.current = true;\n }\n\n // Schedule the trailing edge execution if enabled\n if (trailing) {\n timeoutRef.current = setTimeout(() => {\n // Only call on trailing edge if not already called on leading edge\n // Use ref value instead of closure value to avoid stale closures\n if (!hasLeadingCalledRef.current) {\n latestCallback.current(...args);\n }\n // Reset leading flag and timeout reference after execution\n hasLeadingCalledRef.current = false;\n timeoutRef.current = undefined;\n }, delay);\n }\n },\n [latestCallback, latestOptions, cancel],\n );\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 {\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 { 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, 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 {\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 {\n useExecutePromise,\n useLatest,\n UseExecutePromiseReturn,\n UseExecutePromiseOptions,\n PromiseSupplier,\n} from '../core';\nimport { useCallback, useMemo, useEffect, useRef } from 'react';\nimport { AttributesCapable, FetcherError } from '@ahoo-wang/fetcher';\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 AttributesCapable,\n AutoExecuteCapable {\n /** The initial query parameters */\n initialQuery: Q;\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<Q, R, E = FetcherError>\n extends UseExecutePromiseReturn<R, E> {\n /**\n * Get the current query parameters\n */\n getQuery: () => Q;\n /** Function to update the query parameters */\n setQuery: (query: Q) => void;\n /** Function to execute the query with current parameters */\n execute: () => Promise<void>;\n}\n\n/* eslint-disable react-hooks/preserve-manual-memoization */\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 latestOptions = useLatest(options);\n const {\n loading,\n result,\n error,\n status,\n execute: promiseExecutor,\n reset,\n abort,\n } = useExecutePromise<R, E>(latestOptions.current);\n const queryRef = useRef(options.initialQuery);\n\n const queryExecutor: PromiseSupplier<R> = useCallback(\n async (abortController: AbortController): Promise<R> => {\n return latestOptions.current.execute(\n queryRef.current,\n latestOptions.current.attributes,\n abortController,\n );\n },\n [queryRef, latestOptions],\n );\n\n const execute = useCallback(() => {\n return promiseExecutor(queryExecutor);\n }, [promiseExecutor, queryExecutor]);\n const getQuery = useCallback(() => {\n return queryRef.current;\n }, [queryRef]);\n const setQuery = useCallback(\n (query: Q) => {\n queryRef.current = query;\n if (latestOptions.current.autoExecute) {\n execute();\n }\n },\n [queryRef, latestOptions, execute],\n );\n\n useEffect(() => {\n if (latestOptions.current.autoExecute) {\n execute();\n }\n }, [latestOptions, execute]);\n\n return useMemo(\n () => ({\n loading,\n result,\n error,\n status,\n execute,\n reset,\n abort,\n getQuery,\n setQuery,\n }),\n [loading, result, error, status, execute, reset, abort, getQuery, setQuery],\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 './useQuery';\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 './useQuery';\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 { Condition } from '@ahoo-wang/fetcher-wow';\nimport { FetcherError } from '@ahoo-wang/fetcher';\nimport { useQuery, UseQueryOptions, UseQueryReturn } from './useQuery';\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 './useQuery';\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 './useQuery';\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 { FetcherError } from '@ahoo-wang/fetcher';\nimport { useQuery, UseQueryOptions, UseQueryReturn } from '../useQuery';\nimport {\n DebounceCapable,\n useDebouncedCallback,\n UseDebouncedCallbackReturn,\n} from '../../core';\nimport { useMemo } from 'react';\n\n/**\n * Options for the useDebouncedQuery hook, extending UseQueryOptions with debouncing capabilities.\n * @template Q - The query type\n * @template R - The result type\n * @template E - The error type, defaults to FetcherError\n */\nexport interface UseDebouncedQueryOptions<Q, R, E = FetcherError>\n extends UseQueryOptions<Q, R, E>,\n DebounceCapable {}\n\n/**\n * Return type for the useDebouncedQuery hook, including query state and debounced execution methods.\n * @template Q - The query type\n * @template R - The result type\n * @template E - The error type, 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 * A React hook that provides debounced query execution, combining the useQuery hook with debouncing functionality\n * to prevent excessive API calls during rapid query changes.\n *\n * @template Q - The query type\n * @template R - The result type\n * @template E - The error type, defaults to FetcherError\n * @param options - Configuration options for the query and debouncing behavior, including debounce settings\n * @returns An object containing query state (loading, result, error, status) and debounced execution methods (run, cancel, isPending)\n *\n * @example\n * ```typescript\n * const { loading, result, error, run, cancel, isPending } = useDebouncedQuery({\n * url: '/api/search',\n * debounce: 300,\n * });\n *\n * // Trigger debounced query\n * run({ q: 'search term' });\n *\n * // Cancel pending debounced query\n * cancel();\n * ```\n *\n * @throws {FetcherError} When the underlying query execution fails\n */\nexport function useDebouncedQuery<Q, R, E = FetcherError>(\n options: UseDebouncedQueryOptions<Q, R, E>,\n): UseDebouncedQueryReturn<Q, R, E> {\n const {\n loading,\n result,\n error,\n status,\n execute,\n reset,\n abort,\n getQuery,\n setQuery,\n } = useQuery(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 reset,\n abort,\n getQuery,\n setQuery,\n run,\n cancel,\n isPending,\n }),\n [\n loading,\n result,\n error,\n status,\n reset,\n abort,\n getQuery,\n setQuery,\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 { 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":["useMounted","$","_c","isMountedRef","useRef","t0","Symbol","for","current","isMountedFn","t1","t2","useEffect","useLatest","value","ref","PromiseStatus","IDLE","LOADING","SUCCESS","ERROR","usePromiseState","options","status","setStatus","useState","initialStatus","result","setResult","undefined","error","setError","isMounted","latestOptions","setLoadingFn","useCallback","setSuccessFn","onSuccess","callbackError","console","warn","setErrorFn","onError","setIdleFn","useMemo","loading","setLoading","setSuccess","setIdle","useRequestId","requestIdRef","generate","requestId","isLatest","t3","invalidate","t4","reset","t5","useExecutePromise","abortControllerRef","propagateError","onAbort","handleOnAbort","execute","input","abort","abortController","AbortController","currentRequestId","data","err","Error","name","useRefs","refs","Map","get","key","set","has","deleteFn","delete","clear","keys","values","entries","iterator","register","instance","size","useDebouncedCallback","callback","leading","trailing","timeoutRef","hasLeadingCalledRef","latestCallback","isPending","clearTimeout","cancel","args","t6","t7","delay","setTimeout","run","useDebouncedExecutePromise","debounce","useForceUpdate","forceUpdate","useReducer","_temp","x","useKeyStorage","keyStorage","defaultValue","addListener","nameGenerator","handle","subscribe","storedValue","getSnapshot","useSyncExternalStore","value_0","setValue","remove","useImmerKeyStorage","updater","nextValue","produce","updateImmer","useFetcher","fetcher","fetcherRegistrar","default","promiseExecutor","exchange","setExchange","getFetcher","currentFetcher","request","exchange_0","extractResult","resetFn","abortFn","useDebouncedFetcher","useQuery","queryRef","initialQuery","queryExecutor","attributes","getQuery","setQuery","query","autoExecute","usePagedQuery","useSingleQuery","useCountQuery","useListQuery","useListStreamQuery","useDebouncedQuery","useEventSubscription","bus","handler","on","off","unsubscribe"],"mappings":"wmBAuCO,SAAAA,GAAA,CAAA,MAAAC,EAAAC,EAAAA,EAAA,CAAA,EACLC,EAAqBC,EAAAA,OAAO,EAAK,EAAE,IAAAC,EAAAJ,EAAA,CAAA,IAAAK,OAAAC,IAAA,2BAAA,GACHF,EAAAA,EAAAA,IAAMF,EAAYK,QAAlBH,MAA0BJ,KAAAI,GAAAA,EAAAJ,EAAA,CAAA,EAA1D,MAAAQ,EAAoBJ,EAA4C,IAAAK,EAAAC,EAAA,OAAAV,EAAA,CAAA,IAAAK,OAAAC,IAAA,2BAAA,GACtDG,EAAAA,EAAAA,KACRP,EAAYK,QAAW,GAChB,IAAA,CACLL,EAAYK,QAAW,EAAH,GAHdE,MAKPC,EAAA,CAAA,EAAEV,KAAAS,EAAAT,KAAAU,IAAAD,EAAAT,EAAA,CAAA,EAAAU,EAAAV,EAAA,CAAA,GALLW,EAAAA,UAAUF,EAKPC,CAAE,EAEEF,CAAW,CAVbT,EAAAA,EAAAA,cCMA,SAASa,EAAaC,EAAwB,CACnD,MAAMC,EAAMX,EAAAA,OAAOU,CAAK,EAExBC,OAAAA,EAAIP,QAAUM,EACPC,CACT,CALgBF,EAAAA,EAAAA,aCxBT,IAAKG,GAAAA,IACVC,EAAAA,KAAO,OACPC,EAAAA,QAAU,UACVC,EAAAA,QAAU,UACVC,EAAAA,MAAQ,QAJEJ,IAAAA,GAAAA,CAAAA,CAAAA,EA6FL,SAASK,EACdC,EAC6B,CA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,CAAA,IAAAkK,GAAAlK,OAAAmK,GAETzJ,EAAAA,EAAAA,KACQwJ,EAAGE,GAAID,CAAO,GAE5B7H,QAAOC,KACL,kDAAkD4H,EAAO3F,IAAK,EAChE,EAEK,IAAA,CACL0F,EAAGG,IAAKF,EAAO3F,IAAK,CAAC,GARf9D,MAUP2C,EAAA,CAAC6G,EAAKC,CAAO,EAACnK,KAAAkK,EAAAlK,KAAAmK,EAAAnK,KAAAU,EAAAV,KAAAqD,IAAA3C,EAAAV,EAAA,CAAA,EAAAqD,EAAArD,EAAA,CAAA,GAVjBW,EAAAA,UAAUD,EAUP2C,CAAc,EAAC,IAAAE,EAAA,OAAAvD,EAAA,EAAA,IAAAuH,GAAAvH,QAAAsK,GAEX/G,EAAA,CAAAgE,UAAAA,EAAA+C,YAAAA,CAAAA,EAGNtK,MAAAuH,EAAAvH,MAAAsK,EAAAtK,MAAAuD,GAAAA,EAAAvD,EAAA,EAAA,EAHMuD,CAGN,CA3BI0G,EAAAA,GAAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahoo-wang/fetcher-react",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.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",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"typescript": "^5.9.3",
|
|
63
63
|
"typescript-eslint": "^8.48.1",
|
|
64
64
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
65
|
+
"eslint-plugin-react-compiler": "^19.1.0-rc.2",
|
|
65
66
|
"unplugin-dts": "1.0.0-beta.6",
|
|
66
67
|
"vite": "^7.2.6",
|
|
67
68
|
"vite-bundle-analyzer": "^1.2.3",
|