/** * Injected Dependencies Module * * This module provides a mechanism to inject dependencies (hooks and configuration) into the shared library * to avoid React context duplication issues when using CJS builds in Vite consumers. * * IMPORTANT: Consumers MUST call `injectDependencies()` before using any hooks from this library: * * ```typescript * import { injectDependencies } from '@levr/shared/react'; * import { usePrivy, useIdentityToken, useUser } from '@privy-io/react-auth'; * import { useQuery } from '@tanstack/react-query'; * import { LevrEnv } from '@levr/shared/core'; * * // Call this once in your app initialization (e.g., in your root component or main.tsx) * injectDependencies({ usePrivy, useIdentityToken, useUser, useQuery, levrEnv: LevrEnv.TESTNET }); * ``` * * After injection, all hooks from this library will use the consumer's live React context and configuration. */ import { useIdentityToken, usePrivy, useUser } from "@privy-io/react-auth"; import type { useMutation, useQuery } from "@tanstack/react-query"; import { LevrEnv } from "../core"; export interface InjectedDependencies { usePrivy: typeof usePrivy; useIdentityToken: typeof useIdentityToken; useUser: typeof useUser; useQuery: typeof useQuery; useMutation: typeof useMutation; wagmi?: typeof import("wagmi"); levrEnv: LevrEnv; } /** * Inject the dependencies from the consumer application. * * This function MUST be called once before using any hooks from this library. * It allows the shared library to use the consumer's React context and configuration * instead of creating its own, which would cause context duplication issues. * * @param dependencies - Object containing the required hooks and configuration from the consumer * @throws {Error} If dependencies have already been injected (to prevent accidental re-injection) * * @example * ```typescript * import { injectDependencies } from '@levr/shared/react'; * import { usePrivy, useIdentityToken, useUser } from '@privy-io/react-auth'; * import { useQuery } from '@tanstack/react-query'; * import { LevrEnv } from '@levr/shared/core'; * * injectDependencies({ usePrivy, useIdentityToken, useUser, useQuery, levrEnv: LevrEnv.TESTNET }); * ``` */ export declare function injectDependencies(dependencies: InjectedDependencies): void; /** * Get the injected dependencies. * * This function is used internally by the library's hooks to access the consumer's * dependencies (hooks and configuration). It will throw an error if dependencies have not been injected yet. * * @returns The injected dependencies object * @throws {Error} If dependencies have not been injected via `injectDependencies()` * * @internal */ export declare function getDependencies(): InjectedDependencies; /** * Reset injected dependencies (primarily for testing purposes). * * @internal */ export declare function resetInjectedDependencies(): void;