@namiml/web-sdk
Version:
Nami Web SDK makes subscriptions & in-app purchases easy, with powerful built-in paywalls and A/B testing
86 lines (85 loc) • 4.29 kB
TypeScript
import { ReactiveController, ReactiveControllerHost } from 'lit';
import { IPaywall, ISkuMenu, NamiAppSuppliedVideoDetails, TPaywallContext, TPaywallMedia } from '../types/paywall';
import { NamiProductDetails } from '../types/externals/product';
import { NamiSKU } from '../types/externals/sku';
import { NamiCampaign } from '../types/externals/campaign';
import { TDevice } from '../types/device';
import { Callback } from '../types/components/containers';
import type { NamiFlow } from '../nami/flow/NamiFlow';
import { NamiPaywallEvent, NamiPaywallLaunchContext } from '../types/externals/paywall';
import { SimpleEventTarget } from '../utils/simple-event-target';
export declare const initialState: TPaywallContext;
export declare class PaywallContextProvider extends SimpleEventTarget implements ReactiveController {
static providers: PaywallContextProvider[];
host: ReactiveControllerHost | null;
state: TPaywallContext;
subscribers: Set<Callback>;
productDetails: NamiProductDetails[];
flow?: NamiFlow;
filteredSkuMenus: ISkuMenu[];
static create(paywall: IPaywall, context: NamiPaywallLaunchContext, campaign: NamiCampaign): PaywallContextProvider;
static remove(provider: PaywallContextProvider): void;
static get currentProvider(): PaywallContextProvider | undefined;
static setCustomerAttribute(attributes: {
[key: string]: string;
}): void;
static removeCustomerAttribute(key: string): void;
static setAppSuppliedVideoDetails(details: NamiAppSuppliedVideoDetails): void;
static getSelectedPaywall(): IPaywall | undefined;
static setUserInteractionEnabled(enabled: boolean): void;
static setProductDetails(details: NamiProductDetails[]): void;
static setPurchaseInProgress(inProgress: boolean): void;
static setIsLoggedIn(isLoggedIn: boolean): void;
static setPurchase(inProgress: boolean, product?: NamiSKU): void;
static getSelectedSlideIndex(): number | undefined;
constructor(paywall: IPaywall, context: NamiPaywallLaunchContext, campaign: NamiCampaign);
subscribe(callback: Callback): Callback;
unsubscribe(callback: Callback): void;
emitEvent<T = any>(name: string, payload?: T): void;
onEvent<T = any>(name: string, handler: (payload: T) => void): () => void;
hostConnected(): void;
hostDisconnected(): void;
private defineDynamicStateProps;
private setState;
setProductDetails(details: NamiProductDetails[]): void;
getProductDetails(): NamiProductDetails[];
setCurrentGroupData(currentGroupId: string, currentGroupName: string): void;
getCurrentGroupId(): string;
getCurrentGroupName(): string;
setSelectedProducts(products: {
[currentGroupId: string]: string | null;
}): void;
selectedProducts(): {
[currentGroupId: string]: string | null;
};
setPaywall(paywall: IPaywall, context: NamiPaywallLaunchContext, campaign: NamiCampaign): void;
getSelectedPaywall(): IPaywall | undefined;
getSelectedCampaign(): NamiCampaign | undefined;
getPaywallActionEventData(): Partial<NamiPaywallEvent>;
paywallId(): string;
setCurrentPage(page: string): void;
setCustomerAttribute(attributes: {
[key: string]: string;
}): void;
removeCustomerAttribute(key: string): void;
setIsLoggedIn(isLoggedIn: boolean): void;
setMediaList(media: TPaywallMedia[]): void;
setSafeAreaTop(safeAreaTop: number): void;
setFullScreenPresentation(fullScreenPresentation: boolean): void;
setFormFactor(formFactor: TDevice): void;
getFormFactor(): TDevice;
getTVQuality(): "" | "720p" | "4K" | "1080p";
getViewportWidth(): number;
getViewportHeight(): number;
setPurchaseInProgress(inProgress: boolean): void;
setPurchase(inProgress: boolean, product?: NamiSKU): void;
setTimeSpentOnPaywall(time: number): void;
setAppSuppliedVideoDetails({ url, name }: NamiAppSuppliedVideoDetails): void;
resetAppSuppliedVideoDetails(): void;
setLaunchDetails(value: string, type?: string): void;
setOpenHeaderIds(id: string, sku?: NamiSKU): void;
getCurrentCollapsibleSku(): NamiSKU;
setFlow(flow: NamiFlow): void;
setUserInteractionEnabled(enabled: boolean): void;
setCurrentSlideIndex(index: number): void;
}