UNPKG

react-native-devtools-sync

Version:

A tool for syncing React Query state to an external Dev Tools

96 lines (95 loc) 3.12 kB
import { QueryClient } from "@tanstack/react-query"; import { PlatformOS } from "./platformUtils"; /** * Network monitoring options */ export interface NetworkMonitoringOptions { /** * Enable fetch API monitoring * @default false */ fetch?: boolean; /** * Enable XMLHttpRequest monitoring * @default false */ xhr?: boolean; /** * Enable WebSocket monitoring * @default false */ websocket?: boolean; } /** * Expo DevTools options */ export interface ExpoDevToolsOptions { /** * Enable Expo DevTools integration * @default false */ enabled?: boolean; } interface useSyncQueriesExternalProps { /** * React Query client instance * Optional: If not provided, React Query specific functionality will be disabled */ queryClient?: QueryClient; deviceName: string; /** * A unique identifier for this device that persists across app restarts. * This is crucial for proper device tracking, especially if you have multiple devices of the same type. * If you only have one iOS and one Android device, you can use 'ios' and 'android'. * For multiple devices of the same type, ensure this ID is unique and persistent. */ deviceId: string; extraDeviceInfo?: Record<string, string>; socketURL: string; platform: PlatformOS; /** * Enable/disable logging for debugging purposes * @default false */ enableLogs?: boolean; /** * Optional storage implementation for storage viewer integration * Can be AsyncStorage from @react-native-async-storage/async-storage or any custom implementation * that follows the same interface */ storage?: { getAllKeys: () => Promise<readonly string[]>; getItem: (key: string) => Promise<string | null>; setItem: (key: string, value: string) => Promise<void>; removeItem: (key: string) => Promise<void>; clear: () => Promise<void>; }; /** * Network monitoring options * Configure which network request types to monitor * @default undefined (no monitoring) */ networkMonitoring?: NetworkMonitoringOptions; /** * Expo DevTools options * Configure Expo DevTools integration * @default undefined (no Expo DevTools integration) */ expoDevTools?: ExpoDevToolsOptions; } /** * Hook used by mobile devices to sync query state with the external dashboard * * Handles: * - Connection to the socket server * - Responding to dashboard requests * - Processing query actions from the dashboard * - Sending query state updates to the dashboard */ export declare function useSyncQueriesExternal({ queryClient, deviceName, socketURL, extraDeviceInfo, platform, deviceId, enableLogs, storage, networkMonitoring, }: useSyncQueriesExternalProps): { connect: () => void; disconnect: () => void; isConnected: boolean; socket: import("socket.io-client").Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap>; }; export {};