@namiml/web-sdk
Version:
Subscription monetization infrastructure — drop-in SDK with no-code paywalls, onboarding flows, A/B testing for web
43 lines (42 loc) • 2.06 kB
TypeScript
import { ReactiveController, ReactiveControllerHost } from 'lit';
import { PaywallState, initialState } from '@namiml/sdk-core';
import type { IPaywall, NamiCampaign, NamiPaywallLaunchContext } from '@namiml/sdk-core';
export { initialState };
/**
* Web-specific extension of PaywallState that integrates with Lit's
* reactive rendering system.
*
* PaywallState (from @namiml/sdk-core) contains ALL platform-agnostic
* business logic: setPaywall, setCurrentGroupData, setFlow, setState,
* setCustomerAttribute, selectedProducts, getSelectedCampaign,
* getPaywallActionEventData, setOpenHeaderIds, setPurchase, etc.
*
* This subclass adds only web-specific concerns:
* - Lit ReactiveController integration (host.requestUpdate on state change)
* - Dynamic state getters that read from the DOM (tvQuality, viewport dims)
* - Type-safe static method overrides returning PaywallContextProvider
*/
export declare class PaywallContextProvider extends PaywallState implements ReactiveController {
host: ReactiveControllerHost | null;
static create(paywall: IPaywall, context: NamiPaywallLaunchContext, campaign: NamiCampaign): PaywallContextProvider;
static remove(provider: PaywallContextProvider): void;
static get currentProvider(): PaywallContextProvider | undefined;
constructor(paywall: IPaywall, context: NamiPaywallLaunchContext, campaign: NamiCampaign);
hostConnected(): void;
hostDisconnected(): void;
/**
* Called by PaywallState.setState() after every state mutation.
* Re-attaches DOM-dependent computed getters and triggers a Lit re-render.
*/
protected onStateChanged(): void;
/**
* Attaches computed getters to `this.state` for properties that depend
* on the browser DOM (window dimensions, device pixel ratio).
* Must be called after every setState() since setState replaces the
* state object, losing the previous getters.
*/
private defineDynamicStateProps;
private getTVQuality;
private getViewportWidth;
private getViewportHeight;
}