/** * @traffical/svelte - Hooks * * Svelte 5 hooks for parameter resolution and decision tracking. * Uses $state with event-driven recomputation for cross-package reactivity. * * IMPORTANT — Reactivity & Destructuring: * `params` is returned as a deep $state proxy. Destructuring it is safe: * const { params } = useTraffical({ defaults: { ... } }); * {params['my.key']} // reactive ✅ * * `decision`, `ready`, `error` are primitives/objects behind getters. * Access them through the returned object for reactivity: * const t = useTraffical({ defaults: { ... } }); * {t.ready} // reactive ✅ * {t.decision} // reactive ✅ */ import type { ParameterValue, TrackEventMap } from "@traffical/core"; import type { TrafficalPlugin, TrafficalClient } from "@traffical/js-client"; import type { UseTrafficalOptions, UseTrafficalResult, TrackRewardOptions } from "./types.js"; /** * Primary hook for Traffical parameter resolution and decision tracking. * * Returns reactive values that automatically update when the config bundle changes. * On first render, returns defaults immediately (no blocking). * When the config bundle loads, recomputes and returns resolved values. * * @example * ```svelte * * * * ``` * * @example * ```svelte * * * {#if t.ready} * * {/if} * ``` * * @example * ```svelte * * ``` */ export declare function useTraffical, TEvents extends TrackEventMap = TrackEventMap>(options: UseTrafficalOptions): UseTrafficalResult; /** * Hook to track user events. * * @example * ```svelte * * ``` */ export declare function useTrafficalTrack(): { >(options: { event: E; properties?: TEvents[E]; decisionId?: string; }): void; }; /** * @deprecated Use useTrafficalTrack() instead. * * Hook to track rewards (conversions, revenue, etc.). * * @example * ```svelte * * ``` */ export declare function useTrafficalReward(): (options: TrackRewardOptions) => void; /** * Hook to access the Traffical client directly. * * @example * ```svelte * * ``` */ export declare function useTrafficalClient(): { readonly client: TrafficalClient | null; readonly ready: boolean; readonly error: Error | null; }; /** * Hook to access a registered plugin by name. * Plugins are registered at initialization and don't change at runtime. * * @example * ```svelte * * ``` */ export declare function useTrafficalPlugin(name: string): T | undefined; //# sourceMappingURL=hooks.svelte.d.ts.map