UNPKG

@namiml/web-sdk

Version:

Nami Web SDK makes subscriptions & in-app purchases easy, with powerful built-in paywalls and A/B testing

70 lines (69 loc) 2.8 kB
import { type NamiFlowEventHandler, type NamiFlowHandoffStepHandler } from "../../types/flow"; import { NamiFlow } from "./NamiFlow"; import type { NamiFlowCampaign } from '../../types/externals/campaign'; import { NamiPaywallLaunchContext } from '../../types/externals/paywall'; import { PaywallComponent } from "../../components/Paywall"; export declare class NamiFlowManager { private static _instance; static get instance(): NamiFlowManager; currentFlow?: NamiFlow; flowOpen: boolean; private lastAnimatedFlowProgress; private navGraphCache; private constructor(); handoffStepHandler?: NamiFlowHandoffStepHandler; static registerStepHandoff(handoffStepHandler?: NamiFlowHandoffStepHandler): void; eventHandler?: NamiFlowEventHandler; static registerEventHandler(eventHandler: NamiFlowEventHandler): void; static resume(): void; static finish(): void; static pause(): void; static isFlowOpen(): boolean; presentFlow(campaign: NamiFlowCampaign, paywall: PaywallComponent, context?: NamiPaywallLaunchContext): NamiFlow; finishFlow(): void; /** * Gets the last animated progress for a component by ID * @param key Component ID * @returns Last animated progress value (0-1), or 0 if not found */ getLastAnimatedFlowProgress(key: string): number; /** * Sets the last animated progress for a component by ID * Only stores if there's an active flow * @param key Component ID * @param value Progress value (0-1) */ setLastAnimatedFlowProgress(key: string, value: number): void; /** * Gets the current flow progress based on screen steps * @param key Component ID (for compatibility) * @returns Progress as a percentage (0-1) */ getCurrentFlowProgress(key?: string): number; /** * Find the first screen that has branching (multiple forward navigation targets) */ private findBranchPoint; /** * Calculate progress for flows with branching (supports 2+ branches) */ private calculateBranchingProgress; /** * Count how many screens are forward-reachable from the current step * Only counts screens with higher indices (true forward navigation) */ private countForwardScreens; /** * Checks if a screen has branching navigation (2 or more forward targets) * Supports any number of branches: 2, 3, 4, etc. */ private hasBranching; /** * Build navigation graph from flow steps * Maps each step ID to its possible navigation targets */ private buildNavGraph; static getLastAnimatedFlowProgress(key: string): number; static setLastAnimatedFlowProgress(key: string, value: number): void; static getCurrentFlowProgress(key?: string): number; }