/** * Platform abstraction layer for React Native compatibility. * * This module provides interfaces and default (web) implementations for * browser-specific APIs that are unavailable in React Native: * - Storage (localStorage / sessionStorage) * - TextEncoder * - Base-64 (btoa / atob) * - SubtleCrypto (crypto.subtle.digest) * - DOM helpers (document.*, requestAnimationFrame) * - Location (window.location.origin) * - UserAgent (navigator.userAgent) * * React Native consumers call `setPlatform(adapter)` once at startup to * supply their own implementations (e.g. AsyncStorage-backed storage, * expo-crypto, react-native-get-random-values, etc.). * * Web consumers don't need to do anything — the defaults use the browser APIs. */ export interface StorageAdapter { getItem(key: string): string | null; setItem(key: string, value: string): void; removeItem(key: string): void; } export interface PlatformAdapter { /** Persistent storage (replaces localStorage). */ storage: StorageAdapter; /** Session-scoped storage (replaces sessionStorage). */ sessionStorage: StorageAdapter; /** UTF-8 text → bytes. */ textEncode(input: string): Uint8Array; /** Base-64 decode → string of char codes. */ atob(input: string): string; /** String of char codes → base-64. */ btoa(input: string): string; /** SHA-256 hash, returns ArrayBuffer. */ sha256(data: Uint8Array): Promise; /** navigator.userAgent equivalent (empty string if unavailable). */ getUserAgent(): string; /** window.location.origin equivalent (undefined if unavailable). */ getLocationOrigin(): string | undefined; /** Whether the runtime has a DOM (i.e. we're in a browser, not RN). */ hasDOM: boolean; } /** * Override the platform adapter (call once at app startup in React Native). * * Must be called **before** `init()`. Can only be called once — subsequent * calls throw to prevent accidental mid-session storage swaps. * * ```ts * import { setPlatform } from '@pooflabs/web'; * import AsyncStorage from '@react-native-async-storage/async-storage'; * * // Create a synchronous wrapper around AsyncStorage for the adapter * // (see docs for a full example). * setPlatform({ storage: myStorage, ... }); * ``` */ export declare function setPlatform(adapter: Partial): void; /** Get the current platform adapter. */ export declare function getPlatform(): PlatformAdapter; /** * Detect mobile device even when Chrome "Request Desktop Site" is active. * * Desktop mode on Android strips "Android" and "Mobile" from the UA, leaving * something like "Linux x86_64 …". The fallback detects this by looking for * touch capability + small viewport + a UA that doesn't belong to a known * desktop OS (ChromeOS, Windows, macOS). */ export declare function detectMobile(): boolean; /** * Detect Android, including desktop-mode Chrome and Seeker/Saga in-app browsers. */ export declare function detectAndroid(): boolean; /** * Reset the platform to web defaults and clear the configured flag. * **For testing only** — not exported from the public API. * @internal */ export declare function _resetPlatformForTesting(): void;