@namiml/web-sdk
Version:
Subscription monetization infrastructure — drop-in SDK with no-code paywalls, onboarding flows, A/B testing for web
76 lines (75 loc) • 4.28 kB
TypeScript
import { TBaseComponent, TComponent } from '@namiml/sdk-core';
import { TButtonContainer, TProductContainer, TResponsiveGrid, TRepeatingGrid, TTimelineRail } from "@namiml/sdk-core";
import { TConditionalComponent } from "@namiml/sdk-core";
import { TPaywallMedia } from "@namiml/sdk-core";
import { PaywallSKU } from "@namiml/sdk-core";
import { PaywallContextProvider } from "../ContextProvider";
type ReplacementsType = {
[type: string]: any extends Array<any> ? never : any;
};
export declare function interpolate<T>(value: T, replacements: ReplacementsType): T;
export declare function getInterpolatedButtonComponents(contextProvider: PaywallContextProvider, component: TButtonContainer): TComponent[];
export declare function getSkuButtonComponents(contextProvider: PaywallContextProvider, items: PaywallSKU[], component: TProductContainer, mediaList?: {
[mediaName: string]: Pick<TPaywallMedia, 'content'>;
}): [boolean, TComponent[]][];
/**
* A repeating-list section. `key` is the group key (empty string when grouping is
* inactive). `header` is null when grouping is inactive; otherwise it is the
* interpolated group-header component-list. `items` holds one component-list per repeated item.
*/
export type TRepeatingListSection = {
key: string;
header: TComponent[] | null;
items: TComponent[][];
};
/**
* Partitions a repeating grid's loop source into sections. Blocks failing any
* `loopSourceConditions` assertion are dropped first (evaluated per block, so
* `${block.*}` and `${launch.*}` smart text both resolve). With no
* `groupBy`/`groupHeaderTemplate` a single header-less section is returned; with grouping,
* one section per group key in first-appearance order. Consumed by `nami-repeating-grid`
* so headers can render as full-width rows above their group's items.
*/
export declare function getRepeatingListSections(contextProvider: PaywallContextProvider, component: TResponsiveGrid | TRepeatingGrid): TRepeatingListSection[];
/**
* Flattened view of {@link getRepeatingListSections} that interleaves header and item
* component-lists. Preserves the historical `TComponent[][]` contract used by `nami-responsive-grid`.
*/
export declare function getRepeatingListBlocks(contextProvider: PaywallContextProvider, component: TResponsiveGrid | TRepeatingGrid): TComponent[][];
export declare function conditionComponentMatches(contextProvider: PaywallContextProvider, condition: TConditionalComponent, sku?: PaywallSKU): boolean;
export declare function withOverrides<T extends TBaseComponent>(contextProvider: PaywallContextProvider, { conditionAttributes, ...component }: T, sku?: PaywallSKU): T;
export declare function valueFromSmartText<T>(contextProvider: PaywallContextProvider, value: T, sku?: PaywallSKU, block?: any): T;
export declare const totalTimeSpentOnPaywall: (contextProvider: PaywallContextProvider) => number | undefined;
export declare const rgbaToHex: (rgba?: string) => string | null;
export declare const sameColors: (color1?: string, color2?: string) => boolean;
export type TResolvedTimeline = Required<Omit<TTimelineRail, 'id' | 'namiComponentType' | 'conditionAttributes'>> & Pick<TTimelineRail, 'conditionAttributes'>;
export declare function resolveTimelineDefaults(timeline: TTimelineRail): TResolvedTimeline;
export type TTimelineDotStyle = {
dotSize: number;
dotColor: string;
dotCornerRadius: number;
dotBorderWidth: number;
dotBorderColor: string;
};
/**
* Per-group dot style: base timeline values overlaid with any conditionAttributes
* whose assertions pass for this group. `${group.key}` is pre-resolved via
* interpolate before evaluation, so the assertion values become literals and
* conditionComponentMatches evaluates them against the context state cleanly.
*/
export declare function resolveTimelineDotStyle(contextProvider: PaywallContextProvider, timeline: TTimelineRail, groupKey: string): TTimelineDotStyle;
export type TTimelineSegment = {
top: number;
height: number;
};
export declare function computeTimelineSegments(args: {
railHeight: number;
lineTopOffset: number;
lineBottomOffset: number;
dotLineSpacing: number;
dots: Array<{
centerY: number;
size: number;
}>;
}): TTimelineSegment[];
export {};