import type { SdkWebViewLoadState } from '@dynamic-labs/types'; import { Core } from '../../client/core'; import { WebViewLoadOptions } from '../webViewLoadOptions'; import { WebViewLoadEvent } from '../webViewLoadTypes'; import { WebViewLoadAdapter } from './webViewLoadAdapter'; export declare const DEFAULT_PAGE_LOAD_TIMEOUT_MS = 20000; export declare const DEFAULT_SDK_READY_TIMEOUT_MS = 20000; export type CreateWebViewLoadControllerArgs = WebViewLoadOptions & { core: Core; /** The base webview URL; environmentId and start time get appended. */ webviewUrl: string; adapter: WebViewLoadAdapter; /** * Source of randomness for the retry-backoff jitter. This is * non-cryptographic backoff jitter only (it spreads reload storms across * devices and is never used for anything security-relevant). Injectable * so tests can make the backoff deterministic. Defaults to `Math.random`. */ random?: () => number; /** Wall-clock source. Defaults to `Date.now`. */ now?: () => number; }; export type WebViewLoadController = { /** Feed a machine event (lifecycle callbacks, native errors, ...). */ dispatch: (event: WebViewLoadEvent) => void; /** Current public projection of the load state. */ getState: () => SdkWebViewLoadState; /** Subscribe to public-state changes. Returns an unsubscribe. */ onStateChanged: (callback: (state: SdkWebViewLoadState) => void) => () => void; /** * Customer-facing retry. Resolves with the public projection on the next * transition to `ready` or `failed` (the state tells the caller which), * or immediately when there is nothing to retry. */ retry: () => Promise; /** Build the initial URL and kick off the first load attempt. */ start: () => void; /** Clear all timers and subscriptions; late callbacks become no-ops. */ teardown: () => void; }; /** * The imperative shell around `transitionWebViewLoadState`: holds the * current machine state, executes the effects each transition requests * (timers, loads, telemetry, terminal errors) and exposes the public * projection consumed by `client.sdk.loadState`. * * All decisions live in the pure machine — this shell only translates * effects into the real world and feeds external signals back in as events. */ export declare const createWebViewLoadController: ({ adapter, core, firstAttemptPageLoadTimeoutMs, maxAttempts, now, pageLoadTimeoutMs, random, sdkReadyTimeoutMs, webviewUrl, }: CreateWebViewLoadControllerArgs) => WebViewLoadController;