@tenthbilling/paywall 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +6 -2
- package/dist/components/Badge.d.ts +8 -0
- package/dist/components/Badge.js +14 -0
- package/dist/components/Button.d.ts +17 -0
- package/dist/components/Button.js +60 -0
- package/dist/components/Card.d.ts +13 -0
- package/dist/components/Card.js +29 -0
- package/dist/components/CloseButton.d.ts +10 -0
- package/dist/components/CloseButton.js +21 -0
- package/dist/components/ComparisonTable.d.ts +20 -0
- package/dist/components/ComparisonTable.js +43 -0
- package/dist/components/CreditPackOption.d.ts +16 -0
- package/dist/components/CreditPackOption.js +38 -0
- package/dist/components/FeatureList.d.ts +14 -0
- package/dist/components/FeatureList.js +15 -0
- package/dist/components/PaywallFooter.d.ts +17 -0
- package/dist/components/PaywallFooter.js +46 -0
- package/dist/components/PaywallOption.d.ts +26 -0
- package/dist/components/PaywallOption.js +41 -0
- package/dist/components/Radio.d.ts +8 -0
- package/dist/components/Radio.js +21 -0
- package/dist/components/RadioGroup.d.ts +23 -0
- package/dist/components/RadioGroup.js +42 -0
- package/dist/components/Text.d.ts +10 -0
- package/dist/components/Text.js +8 -0
- package/dist/components/TextField.d.ts +19 -0
- package/dist/components/TextField.js +38 -0
- package/dist/components/dimensions.d.ts +29 -0
- package/dist/components/dimensions.js +21 -0
- package/dist/components/icons.d.ts +7 -0
- package/dist/components/icons.js +15 -0
- package/dist/controller.d.ts +97 -0
- package/dist/controller.js +1 -0
- package/dist/format.d.ts +5 -0
- package/dist/format.js +3 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +26 -0
- package/dist/paywall/PaywallScaffold.d.ts +52 -0
- package/dist/paywall/PaywallScaffold.js +42 -0
- package/dist/paywall/PaywallView.d.ts +38 -0
- package/dist/paywall/PaywallView.js +219 -0
- package/dist/paywall/copy.d.ts +36 -0
- package/dist/paywall/copy.js +90 -0
- package/dist/paywall/price.d.ts +38 -0
- package/dist/paywall/price.js +124 -0
- package/dist/paywall/selection.d.ts +17 -0
- package/dist/paywall/selection.js +13 -0
- package/dist/paywall/slots.d.ts +46 -0
- package/dist/paywall/slots.js +1 -0
- package/dist/paywall/strings.d.ts +13 -0
- package/dist/paywall/strings.js +10 -0
- package/dist/paywall/templates.d.ts +31 -0
- package/dist/paywall/templates.js +60 -0
- package/dist/paywall/theme.d.ts +41 -0
- package/dist/paywall/theme.js +104 -0
- package/dist/paywall/url.d.ts +22 -0
- package/dist/paywall/url.js +48 -0
- package/dist/schema/config.d.ts +264 -0
- package/dist/schema/config.js +149 -0
- package/dist/schema/defaults.d.ts +2 -0
- package/dist/schema/defaults.js +20 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +2 -0
- package/dist/theme.d.ts +14 -0
- package/dist/theme.js +14 -0
- package/package.json +66 -3
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { Badge } from '../components/Badge';
|
|
4
|
+
import { ComparisonTable } from '../components/ComparisonTable';
|
|
5
|
+
import { CreditPackOption } from '../components/CreditPackOption';
|
|
6
|
+
import { PaywallOption } from '../components/PaywallOption';
|
|
7
|
+
import { RadioGroup, useRadioGroup } from '../components/RadioGroup';
|
|
8
|
+
import { Text } from '../components/Text';
|
|
9
|
+
import { useTheme } from '../theme';
|
|
10
|
+
import { optionDetail, optionPrice } from './copy';
|
|
11
|
+
import { PaywallScaffold } from './PaywallScaffold';
|
|
12
|
+
import { badgedProductKey, defaultProductKey } from './selection';
|
|
13
|
+
export function visibleProducts(template, products) {
|
|
14
|
+
if (template !== 'hero')
|
|
15
|
+
return products;
|
|
16
|
+
const key = defaultProductKey(products);
|
|
17
|
+
return products.filter((p) => p.key === key);
|
|
18
|
+
}
|
|
19
|
+
function ProductOptions({ products, selected, select, locale, slots, layout, label, }) {
|
|
20
|
+
const { space } = useTheme();
|
|
21
|
+
const keys = products.map((p) => p.key);
|
|
22
|
+
const selectedKey = selected?.key ?? null;
|
|
23
|
+
const radio = useRadioGroup(keys, selectedKey, select);
|
|
24
|
+
const badged = badgedProductKey(products);
|
|
25
|
+
const Card = slots?.productCard;
|
|
26
|
+
return (_jsx(RadioGroup, { label: label, style: layout === 'grid'
|
|
27
|
+
? { flexDirection: 'row', flexWrap: 'wrap', gap: space[3] }
|
|
28
|
+
: { gap: space[3] }, children: products.map((product) => {
|
|
29
|
+
const isSelected = product.key === selectedKey;
|
|
30
|
+
const onSelect = () => select(product.key);
|
|
31
|
+
if (Card) {
|
|
32
|
+
return (_jsx(View, { style: layout === 'grid' ? { flexBasis: '45%', flexGrow: 1 } : null, children: _jsx(Card, { product: product, selected: isSelected, select: onSelect }) }, product.key));
|
|
33
|
+
}
|
|
34
|
+
return layout === 'grid' ? (_jsx(View, { style: { flexBasis: '45%', flexGrow: 1 }, children: _jsx(CreditPackOption, { product: product, selected: isSelected, onSelect: onSelect, locale: locale, showBadge: product.key === badged, radio: radio(product.key) }) }, product.key)) : (_jsx(PaywallOption, { product: product, selected: isSelected, onSelect: onSelect, locale: locale, showBadge: product.key === badged, radio: radio(product.key) }, product.key));
|
|
35
|
+
}) }));
|
|
36
|
+
}
|
|
37
|
+
export function TiersTemplate(props) {
|
|
38
|
+
return (_jsx(PaywallScaffold, { ...props, children: _jsx(ProductOptions, { ...props, layout: "rows", label: "Choose a plan" }) }));
|
|
39
|
+
}
|
|
40
|
+
export function HeroTemplate(props) {
|
|
41
|
+
const { space } = useTheme();
|
|
42
|
+
const product = props.selected;
|
|
43
|
+
const Card = props.slots?.productCard;
|
|
44
|
+
const detail = product ? optionDetail(product, props.locale) : null;
|
|
45
|
+
return (_jsx(PaywallScaffold, { ...props, showHeroImage: true, children: product ? (Card ? (_jsx(Card, { product: product, selected: true, select: () => props.select(product.key) })) : (_jsxs(View, { style: { gap: space[1], alignItems: 'center' }, children: [product.badge ? _jsx(Badge, { label: product.badge }) : null, _jsx(Text, { variant: "body", style: { textAlign: 'center' }, children: product.name }), _jsx(Text, { variant: "figureLg", style: { textAlign: 'center' }, children: optionPrice(product) }), detail ? (_jsx(Text, { variant: "bodySm", color: "inkMuted", style: { textAlign: 'center' }, children: detail })) : null] }))) : null }));
|
|
46
|
+
}
|
|
47
|
+
export function ComparisonTemplate(props) {
|
|
48
|
+
const { space } = useTheme();
|
|
49
|
+
const rows = props.copy.comparison ?? [];
|
|
50
|
+
return (_jsx(PaywallScaffold, { ...props, children: _jsxs(View, { style: { gap: space[4] }, children: [_jsx(ComparisonTable, { rows: rows, products: props.products, selectedKey: props.selected?.key ?? null }), _jsx(ProductOptions, { ...props, layout: "rows", label: "Choose a plan" })] }) }));
|
|
51
|
+
}
|
|
52
|
+
export function CreditsTemplate(props) {
|
|
53
|
+
return (_jsx(PaywallScaffold, { ...props, showHeroImage: true, children: _jsx(ProductOptions, { ...props, layout: "grid", label: "Choose a credit pack" }) }));
|
|
54
|
+
}
|
|
55
|
+
export const PAYWALL_TEMPLATES = {
|
|
56
|
+
hero: HeroTemplate,
|
|
57
|
+
tiers: TiersTemplate,
|
|
58
|
+
comparison: ComparisonTemplate,
|
|
59
|
+
credits: CreditsTemplate,
|
|
60
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type Theme, type ThemeName } from '@tenthbilling/design';
|
|
2
|
+
import type { PaywallTheme } from '../schema/config';
|
|
3
|
+
/** A resolved theme plus anything the dashboard should tell the tenant about their colors. */
|
|
4
|
+
export interface ResolvedPaywallTheme extends Theme {
|
|
5
|
+
warnings: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
/** Theme overrides a developer passes as a prop: the same shape as `config.theme`. */
|
|
8
|
+
export type PaywallThemeOverrides = PaywallTheme;
|
|
9
|
+
/** Mixes `from` toward `to` by `t` (0–1), per RGB channel, rounded. Deterministic. */
|
|
10
|
+
export declare function mixHex(from: string, to: string, t: number): string;
|
|
11
|
+
/**
|
|
12
|
+
* Derives brand-hover from brand. Light theme: 20% toward `ink` (darker, like the token pair
|
|
13
|
+
* #0f5257 → #0a3f43). Dark theme: 20% toward white (lighter, like #5cbcb6 → #7dcdc8). If that
|
|
14
|
+
* direction would leave on-brand text under 4.5:1 on the hover fill (a pale brand with dark text
|
|
15
|
+
* in light, a deep brand with white text in dark), it mixes the other way instead (toward white in
|
|
16
|
+
* light, toward black in dark), so the hover state never costs legibility.
|
|
17
|
+
*/
|
|
18
|
+
export declare function deriveBrandHover(brand: string, onBrand: string, scheme: Theme): string;
|
|
19
|
+
/**
|
|
20
|
+
* The color scheme a paywall renders in: the prop's `color_scheme`, else the config's, else
|
|
21
|
+
* `system`, which follows the host app (`useColorScheme()`; anything but `dark` is light).
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveColorScheme(config: PaywallTheme | undefined, overrides: PaywallThemeOverrides | undefined, host: string | null | undefined): ThemeName;
|
|
24
|
+
/**
|
|
25
|
+
* Applies a tenant's paywall theme (and a developer's prop overrides, which win) to `base`, the
|
|
26
|
+
* design-system theme for the chosen scheme (`themes.light` or `themes.dark`).
|
|
27
|
+
*
|
|
28
|
+
* - `brand` replaces brand. `on-brand` is computed with `onColorFor` (white or #13201f, whichever
|
|
29
|
+
* reaches 4.5:1); if neither does, the token's on-brand is kept and a warning is added.
|
|
30
|
+
* - `brand_hover` replaces brand-hover; without it, brand-hover is derived (`deriveBrandHover`).
|
|
31
|
+
* - `surface_raised` replaces surface-raised, unless ink, ink-muted or line-strong would stop
|
|
32
|
+
* reading on it (4.5:1 for text, 3:1 for control borders); then it's ignored with a warning,
|
|
33
|
+
* so a theme can't hide the price, the Restore link or the legal links.
|
|
34
|
+
* - `display_font` replaces the fontFamily of the display styles (display-xl, display, heading-1,
|
|
35
|
+
* heading-2). The app must have loaded the font; otherwise the platform falls back.
|
|
36
|
+
*
|
|
37
|
+
* Invalid values (not 6-digit hex, a font name outside the schema's characters) are ignored with
|
|
38
|
+
* a warning, never thrown on: prop overrides aren't schema-validated. Every other token is left
|
|
39
|
+
* exactly as the design system defines it.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolvePaywallTheme(base: Theme, config?: PaywallTheme, overrides?: PaywallThemeOverrides): ResolvedPaywallTheme;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { contrastRatio, onColorFor } from '@tenthbilling/design';
|
|
2
|
+
const HEX = /^#[0-9a-fA-F]{6}$/;
|
|
3
|
+
const FONT = /^[A-Za-z0-9 _-]{1,64}$/;
|
|
4
|
+
const TEXT_CONTRAST = 4.5;
|
|
5
|
+
const CONTROL_CONTRAST = 3;
|
|
6
|
+
const HOVER_MIX = 0.2;
|
|
7
|
+
function rgb(hex) {
|
|
8
|
+
const n = parseInt(hex.slice(1), 16);
|
|
9
|
+
return [(n >> 16) & 255, (n >> 8) & 255, n & 255];
|
|
10
|
+
}
|
|
11
|
+
function toHex([r, g, b]) {
|
|
12
|
+
return `#${[r, g, b].map((c) => c.toString(16).padStart(2, '0')).join('')}`;
|
|
13
|
+
}
|
|
14
|
+
export function mixHex(from, to, t) {
|
|
15
|
+
const a = rgb(from);
|
|
16
|
+
const b = rgb(to);
|
|
17
|
+
return toHex([0, 1, 2].map((i) => Math.round(a[i] + (b[i] - a[i]) * t)));
|
|
18
|
+
}
|
|
19
|
+
const WHITE = toHex([255, 255, 255]);
|
|
20
|
+
const BLACK = toHex([0, 0, 0]);
|
|
21
|
+
export function deriveBrandHover(brand, onBrand, scheme) {
|
|
22
|
+
const darken = scheme.name === 'light' ? scheme.colors.ink : BLACK;
|
|
23
|
+
const [first, second] = scheme.name === 'light' ? [darken, WHITE] : [WHITE, darken];
|
|
24
|
+
const primary = mixHex(brand, first, HOVER_MIX);
|
|
25
|
+
if (contrastRatio(primary, onBrand) >= TEXT_CONTRAST)
|
|
26
|
+
return primary;
|
|
27
|
+
const other = mixHex(brand, second, HOVER_MIX);
|
|
28
|
+
return contrastRatio(other, onBrand) >= contrastRatio(primary, onBrand) ? other : primary;
|
|
29
|
+
}
|
|
30
|
+
function color(value, label, warnings) {
|
|
31
|
+
if (value === undefined)
|
|
32
|
+
return undefined;
|
|
33
|
+
if (HEX.test(value))
|
|
34
|
+
return value.toLowerCase();
|
|
35
|
+
warnings.push(`The ${label} color isn't a 6-digit hex color such as #0f5257, so it's ignored.`);
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
export function resolveColorScheme(config, overrides, host) {
|
|
39
|
+
const pref = overrides?.color_scheme ?? config?.color_scheme ?? 'system';
|
|
40
|
+
if (pref === 'light' || pref === 'dark')
|
|
41
|
+
return pref;
|
|
42
|
+
return host === 'dark' ? 'dark' : 'light';
|
|
43
|
+
}
|
|
44
|
+
export function resolvePaywallTheme(base, config, overrides) {
|
|
45
|
+
const warnings = [];
|
|
46
|
+
const scheme = base.name;
|
|
47
|
+
const cfg = config?.[scheme];
|
|
48
|
+
const prop = overrides?.[scheme];
|
|
49
|
+
const colors = { ...base.colors };
|
|
50
|
+
const surface = color(prop?.surface_raised ?? cfg?.surface_raised, 'surface', warnings);
|
|
51
|
+
if (surface) {
|
|
52
|
+
const fails = contrastRatio(colors.ink, surface) < TEXT_CONTRAST ||
|
|
53
|
+
contrastRatio(colors.inkMuted, surface) < TEXT_CONTRAST ||
|
|
54
|
+
contrastRatio(colors.lineStrong, surface) < CONTROL_CONTRAST;
|
|
55
|
+
if (fails) {
|
|
56
|
+
warnings.push(`Text and borders don't reach the required contrast on the surface color ${surface}, so the default surface is kept.`);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
colors.surfaceRaised = surface;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const brand = color(prop?.brand ?? cfg?.brand, 'brand', warnings);
|
|
63
|
+
const hover = color(prop?.brand_hover ?? cfg?.brand_hover, 'brand hover', warnings);
|
|
64
|
+
if (brand) {
|
|
65
|
+
colors.brand = brand;
|
|
66
|
+
const onBrand = onColorFor(brand);
|
|
67
|
+
if (onBrand) {
|
|
68
|
+
colors.onBrand = onBrand;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
warnings.push(`Text on the brand color ${brand} can't reach 4.5:1 contrast with white or near-black, so the default on-brand color is kept. Choose a darker or lighter brand color.`);
|
|
72
|
+
}
|
|
73
|
+
if (contrastRatio(brand, colors.surfaceRaised) < CONTROL_CONTRAST) {
|
|
74
|
+
warnings.push(`The brand color ${brand} is under 3:1 contrast with the paywall surface, so the selected option's border is hard to see.`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (hover) {
|
|
78
|
+
colors.brandHover = hover;
|
|
79
|
+
}
|
|
80
|
+
else if (brand) {
|
|
81
|
+
colors.brandHover = deriveBrandHover(brand, colors.onBrand, base);
|
|
82
|
+
}
|
|
83
|
+
if ((brand || hover) && contrastRatio(colors.brandHover, colors.onBrand) < TEXT_CONTRAST) {
|
|
84
|
+
warnings.push(`Text on the brand hover color ${colors.brandHover} is under 4.5:1 contrast. Choose a brand hover color closer to the brand color.`);
|
|
85
|
+
}
|
|
86
|
+
let typography = base.typography;
|
|
87
|
+
const font = overrides?.display_font ?? config?.display_font;
|
|
88
|
+
if (font !== undefined) {
|
|
89
|
+
if (FONT.test(font)) {
|
|
90
|
+
const family = font;
|
|
91
|
+
typography = {
|
|
92
|
+
...base.typography,
|
|
93
|
+
displayXl: { ...base.typography.displayXl, fontFamily: family },
|
|
94
|
+
display: { ...base.typography.display, fontFamily: family },
|
|
95
|
+
heading1: { ...base.typography.heading1, fontFamily: family },
|
|
96
|
+
heading2: { ...base.typography.heading2, fontFamily: family },
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
warnings.push("The display font name can only contain letters, digits, spaces, '_' and '-', so it's ignored.");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return { ...base, colors, typography, warnings };
|
|
104
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** The URL if it's https with a host and no credentials; null otherwise. Never throws. */
|
|
2
|
+
export declare function safeHttpsUrl(value: unknown): string | null;
|
|
3
|
+
/**
|
|
4
|
+
* Preview only (the dashboard's editor): supplies the URL for an image a draft uses, which isn't
|
|
5
|
+
* public yet, typically an object URL for bytes the editor fetched with its session.
|
|
6
|
+
*/
|
|
7
|
+
export type PaywallAssetResolver = (id: string) => string | null | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* A `blob:` object URL whose creator is an http(s) page; null otherwise. Object URLs only ever
|
|
10
|
+
* name bytes the host page itself created, so they can't point anywhere else. Never throws.
|
|
11
|
+
*/
|
|
12
|
+
export declare function safeBlobUrl(value: unknown): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* The URL `resolve` gives for a config's asset id, if it's https or a page-created `blob:` URL.
|
|
15
|
+
* Never throws, even if `resolve` does.
|
|
16
|
+
*/
|
|
17
|
+
export declare function previewAssetUrl(resolve: PaywallAssetResolver, id: string | undefined): string | null;
|
|
18
|
+
/**
|
|
19
|
+
* The URL of a paywall asset, only when the config's asset id is one of the controller's own
|
|
20
|
+
* assets (an own property, never inherited) and that URL is https.
|
|
21
|
+
*/
|
|
22
|
+
export declare function assetUrl(assets: Readonly<Record<string, string>>, id: string | undefined): string | null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export function safeHttpsUrl(value) {
|
|
2
|
+
if (typeof value !== 'string' || value.length > 2048)
|
|
3
|
+
return null;
|
|
4
|
+
try {
|
|
5
|
+
const u = new URL(value);
|
|
6
|
+
if (u.protocol !== 'https:' || u.username || u.password || !u.hostname)
|
|
7
|
+
return null;
|
|
8
|
+
return u.href;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function safeBlobUrl(value) {
|
|
15
|
+
if (typeof value !== 'string' || value.length > 2048 || !value.startsWith('blob:'))
|
|
16
|
+
return null;
|
|
17
|
+
try {
|
|
18
|
+
const u = new URL(value);
|
|
19
|
+
if (u.protocol !== 'blob:')
|
|
20
|
+
return null;
|
|
21
|
+
const inner = new URL(u.pathname);
|
|
22
|
+
if (inner.protocol !== 'https:' && inner.protocol !== 'http:')
|
|
23
|
+
return null;
|
|
24
|
+
if (inner.username || inner.password || !inner.hostname)
|
|
25
|
+
return null;
|
|
26
|
+
return u.href;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function previewAssetUrl(resolve, id) {
|
|
33
|
+
if (!id)
|
|
34
|
+
return null;
|
|
35
|
+
let value;
|
|
36
|
+
try {
|
|
37
|
+
value = resolve(id);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return safeHttpsUrl(value) ?? safeBlobUrl(value);
|
|
43
|
+
}
|
|
44
|
+
export function assetUrl(assets, id) {
|
|
45
|
+
if (!id || !Object.prototype.hasOwnProperty.call(assets, id))
|
|
46
|
+
return null;
|
|
47
|
+
return safeHttpsUrl(assets[id]);
|
|
48
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* The highest config schema version this package understands. The SDK sends it to the API as
|
|
4
|
+
* `paywall_schema`, and the API serves the newest published config at or below it.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PAYWALL_SCHEMA_VERSION = 1;
|
|
7
|
+
/** Largest serialized config the API accepts, in bytes. */
|
|
8
|
+
export declare const MAX_PAYWALL_CONFIG_BYTES: number;
|
|
9
|
+
/** Display text: no `<`, `>` or control characters, no leading or trailing spaces. Rejected, never rewritten. */
|
|
10
|
+
export declare const paywallText: (max: number) => z.ZodString;
|
|
11
|
+
/** An https URL with no credentials (never javascript:, data: or file:). */
|
|
12
|
+
export declare const httpsUrl: z.ZodString;
|
|
13
|
+
/** A 6-digit hex color, such as #0f5257. */
|
|
14
|
+
export declare const hexColor: z.ZodString;
|
|
15
|
+
/** A paywall asset uploaded to Tenth (raster image), by id. */
|
|
16
|
+
export declare const assetId: z.ZodUUID;
|
|
17
|
+
/** BCP 47 language tag, kept simple: `en`, `en-US`, `pt-BR`, `zh-Hant`. */
|
|
18
|
+
export declare const localeTag: z.ZodString;
|
|
19
|
+
export declare const TEMPLATES: readonly ["hero", "tiers", "comparison", "credits"];
|
|
20
|
+
export type PaywallTemplate = (typeof TEMPLATES)[number];
|
|
21
|
+
/** Lucide icons a feature row may name. A fixed list, so a config can't reference anything else. */
|
|
22
|
+
export declare const FEATURE_ICONS: readonly ["check", "sparkles", "zap", "shield-check", "cloud", "download", "infinity", "lock-open", "star", "users", "clock", "gift"];
|
|
23
|
+
export declare const paywallTheme: z.ZodObject<{
|
|
24
|
+
light: z.ZodOptional<z.ZodObject<{
|
|
25
|
+
brand: z.ZodOptional<z.ZodString>;
|
|
26
|
+
brand_hover: z.ZodOptional<z.ZodString>;
|
|
27
|
+
surface_raised: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strict>>;
|
|
29
|
+
dark: z.ZodOptional<z.ZodObject<{
|
|
30
|
+
brand: z.ZodOptional<z.ZodString>;
|
|
31
|
+
brand_hover: z.ZodOptional<z.ZodString>;
|
|
32
|
+
surface_raised: z.ZodOptional<z.ZodString>;
|
|
33
|
+
}, z.core.$strict>>;
|
|
34
|
+
display_font: z.ZodOptional<z.ZodString>;
|
|
35
|
+
color_scheme: z.ZodOptional<z.ZodEnum<{
|
|
36
|
+
light: "light";
|
|
37
|
+
dark: "dark";
|
|
38
|
+
system: "system";
|
|
39
|
+
}>>;
|
|
40
|
+
}, z.core.$strict>;
|
|
41
|
+
declare const localizedCopy: z.ZodObject<{
|
|
42
|
+
title: z.ZodString;
|
|
43
|
+
subtitle: z.ZodOptional<z.ZodString>;
|
|
44
|
+
features: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
45
|
+
text: z.ZodString;
|
|
46
|
+
icon: z.ZodOptional<z.ZodEnum<{
|
|
47
|
+
check: "check";
|
|
48
|
+
sparkles: "sparkles";
|
|
49
|
+
zap: "zap";
|
|
50
|
+
"shield-check": "shield-check";
|
|
51
|
+
cloud: "cloud";
|
|
52
|
+
download: "download";
|
|
53
|
+
infinity: "infinity";
|
|
54
|
+
"lock-open": "lock-open";
|
|
55
|
+
star: "star";
|
|
56
|
+
users: "users";
|
|
57
|
+
clock: "clock";
|
|
58
|
+
gift: "gift";
|
|
59
|
+
}>>;
|
|
60
|
+
}, z.core.$strict>>>;
|
|
61
|
+
cta: z.ZodOptional<z.ZodString>;
|
|
62
|
+
footnote: z.ZodOptional<z.ZodString>;
|
|
63
|
+
comparison: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
64
|
+
label: z.ZodString;
|
|
65
|
+
values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
|
|
66
|
+
}, z.core.$strict>>>;
|
|
67
|
+
}, z.core.$strict>;
|
|
68
|
+
export declare const paywallCopy: z.ZodObject<{
|
|
69
|
+
default_locale: z.ZodString;
|
|
70
|
+
locales: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
71
|
+
title: z.ZodString;
|
|
72
|
+
subtitle: z.ZodOptional<z.ZodString>;
|
|
73
|
+
features: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
74
|
+
text: z.ZodString;
|
|
75
|
+
icon: z.ZodOptional<z.ZodEnum<{
|
|
76
|
+
check: "check";
|
|
77
|
+
sparkles: "sparkles";
|
|
78
|
+
zap: "zap";
|
|
79
|
+
"shield-check": "shield-check";
|
|
80
|
+
cloud: "cloud";
|
|
81
|
+
download: "download";
|
|
82
|
+
infinity: "infinity";
|
|
83
|
+
"lock-open": "lock-open";
|
|
84
|
+
star: "star";
|
|
85
|
+
users: "users";
|
|
86
|
+
clock: "clock";
|
|
87
|
+
gift: "gift";
|
|
88
|
+
}>>;
|
|
89
|
+
}, z.core.$strict>>>;
|
|
90
|
+
cta: z.ZodOptional<z.ZodString>;
|
|
91
|
+
footnote: z.ZodOptional<z.ZodString>;
|
|
92
|
+
comparison: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
93
|
+
label: z.ZodString;
|
|
94
|
+
values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
|
|
95
|
+
}, z.core.$strict>>>;
|
|
96
|
+
}, z.core.$strict>>;
|
|
97
|
+
}, z.core.$strict>;
|
|
98
|
+
export declare const paywallLayout: z.ZodObject<{
|
|
99
|
+
hero_image: z.ZodOptional<z.ZodUUID>;
|
|
100
|
+
close_button: z.ZodOptional<z.ZodBoolean>;
|
|
101
|
+
restore_button: z.ZodOptional<z.ZodBoolean>;
|
|
102
|
+
terms_url: z.ZodOptional<z.ZodString>;
|
|
103
|
+
privacy_url: z.ZodOptional<z.ZodString>;
|
|
104
|
+
}, z.core.$strict>;
|
|
105
|
+
export declare const paywallConfig: z.ZodObject<{
|
|
106
|
+
schema_version: z.ZodLiteral<1>;
|
|
107
|
+
template: z.ZodEnum<{
|
|
108
|
+
hero: "hero";
|
|
109
|
+
tiers: "tiers";
|
|
110
|
+
comparison: "comparison";
|
|
111
|
+
credits: "credits";
|
|
112
|
+
}>;
|
|
113
|
+
theme: z.ZodObject<{
|
|
114
|
+
light: z.ZodOptional<z.ZodObject<{
|
|
115
|
+
brand: z.ZodOptional<z.ZodString>;
|
|
116
|
+
brand_hover: z.ZodOptional<z.ZodString>;
|
|
117
|
+
surface_raised: z.ZodOptional<z.ZodString>;
|
|
118
|
+
}, z.core.$strict>>;
|
|
119
|
+
dark: z.ZodOptional<z.ZodObject<{
|
|
120
|
+
brand: z.ZodOptional<z.ZodString>;
|
|
121
|
+
brand_hover: z.ZodOptional<z.ZodString>;
|
|
122
|
+
surface_raised: z.ZodOptional<z.ZodString>;
|
|
123
|
+
}, z.core.$strict>>;
|
|
124
|
+
display_font: z.ZodOptional<z.ZodString>;
|
|
125
|
+
color_scheme: z.ZodOptional<z.ZodEnum<{
|
|
126
|
+
light: "light";
|
|
127
|
+
dark: "dark";
|
|
128
|
+
system: "system";
|
|
129
|
+
}>>;
|
|
130
|
+
}, z.core.$strict>;
|
|
131
|
+
copy: z.ZodObject<{
|
|
132
|
+
default_locale: z.ZodString;
|
|
133
|
+
locales: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
134
|
+
title: z.ZodString;
|
|
135
|
+
subtitle: z.ZodOptional<z.ZodString>;
|
|
136
|
+
features: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
137
|
+
text: z.ZodString;
|
|
138
|
+
icon: z.ZodOptional<z.ZodEnum<{
|
|
139
|
+
check: "check";
|
|
140
|
+
sparkles: "sparkles";
|
|
141
|
+
zap: "zap";
|
|
142
|
+
"shield-check": "shield-check";
|
|
143
|
+
cloud: "cloud";
|
|
144
|
+
download: "download";
|
|
145
|
+
infinity: "infinity";
|
|
146
|
+
"lock-open": "lock-open";
|
|
147
|
+
star: "star";
|
|
148
|
+
users: "users";
|
|
149
|
+
clock: "clock";
|
|
150
|
+
gift: "gift";
|
|
151
|
+
}>>;
|
|
152
|
+
}, z.core.$strict>>>;
|
|
153
|
+
cta: z.ZodOptional<z.ZodString>;
|
|
154
|
+
footnote: z.ZodOptional<z.ZodString>;
|
|
155
|
+
comparison: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
156
|
+
label: z.ZodString;
|
|
157
|
+
values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
|
|
158
|
+
}, z.core.$strict>>>;
|
|
159
|
+
}, z.core.$strict>>;
|
|
160
|
+
}, z.core.$strict>;
|
|
161
|
+
layout: z.ZodObject<{
|
|
162
|
+
hero_image: z.ZodOptional<z.ZodUUID>;
|
|
163
|
+
close_button: z.ZodOptional<z.ZodBoolean>;
|
|
164
|
+
restore_button: z.ZodOptional<z.ZodBoolean>;
|
|
165
|
+
terms_url: z.ZodOptional<z.ZodString>;
|
|
166
|
+
privacy_url: z.ZodOptional<z.ZodString>;
|
|
167
|
+
}, z.core.$strict>;
|
|
168
|
+
}, z.core.$strict>;
|
|
169
|
+
export type PaywallTheme = z.infer<typeof paywallTheme>;
|
|
170
|
+
export type PaywallCopy = z.infer<typeof paywallCopy>;
|
|
171
|
+
export type PaywallLocalizedCopy = z.infer<typeof localizedCopy>;
|
|
172
|
+
export type PaywallLayout = z.infer<typeof paywallLayout>;
|
|
173
|
+
export type PaywallConfig = z.infer<typeof paywallConfig>;
|
|
174
|
+
export type FeatureIcon = (typeof FEATURE_ICONS)[number];
|
|
175
|
+
/**
|
|
176
|
+
* A published config as the API serves it inside an offering: the config plus where its assets
|
|
177
|
+
* live. Asset URLs are built by the API on its own origin from asset ids, never taken from config.
|
|
178
|
+
*/
|
|
179
|
+
export declare const servedPaywall: z.ZodObject<{
|
|
180
|
+
id: z.ZodUUID;
|
|
181
|
+
version: z.ZodNumber;
|
|
182
|
+
config: z.ZodObject<{
|
|
183
|
+
schema_version: z.ZodLiteral<1>;
|
|
184
|
+
template: z.ZodEnum<{
|
|
185
|
+
hero: "hero";
|
|
186
|
+
tiers: "tiers";
|
|
187
|
+
comparison: "comparison";
|
|
188
|
+
credits: "credits";
|
|
189
|
+
}>;
|
|
190
|
+
theme: z.ZodObject<{
|
|
191
|
+
light: z.ZodOptional<z.ZodObject<{
|
|
192
|
+
brand: z.ZodOptional<z.ZodString>;
|
|
193
|
+
brand_hover: z.ZodOptional<z.ZodString>;
|
|
194
|
+
surface_raised: z.ZodOptional<z.ZodString>;
|
|
195
|
+
}, z.core.$strict>>;
|
|
196
|
+
dark: z.ZodOptional<z.ZodObject<{
|
|
197
|
+
brand: z.ZodOptional<z.ZodString>;
|
|
198
|
+
brand_hover: z.ZodOptional<z.ZodString>;
|
|
199
|
+
surface_raised: z.ZodOptional<z.ZodString>;
|
|
200
|
+
}, z.core.$strict>>;
|
|
201
|
+
display_font: z.ZodOptional<z.ZodString>;
|
|
202
|
+
color_scheme: z.ZodOptional<z.ZodEnum<{
|
|
203
|
+
light: "light";
|
|
204
|
+
dark: "dark";
|
|
205
|
+
system: "system";
|
|
206
|
+
}>>;
|
|
207
|
+
}, z.core.$strict>;
|
|
208
|
+
copy: z.ZodObject<{
|
|
209
|
+
default_locale: z.ZodString;
|
|
210
|
+
locales: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
211
|
+
title: z.ZodString;
|
|
212
|
+
subtitle: z.ZodOptional<z.ZodString>;
|
|
213
|
+
features: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
214
|
+
text: z.ZodString;
|
|
215
|
+
icon: z.ZodOptional<z.ZodEnum<{
|
|
216
|
+
check: "check";
|
|
217
|
+
sparkles: "sparkles";
|
|
218
|
+
zap: "zap";
|
|
219
|
+
"shield-check": "shield-check";
|
|
220
|
+
cloud: "cloud";
|
|
221
|
+
download: "download";
|
|
222
|
+
infinity: "infinity";
|
|
223
|
+
"lock-open": "lock-open";
|
|
224
|
+
star: "star";
|
|
225
|
+
users: "users";
|
|
226
|
+
clock: "clock";
|
|
227
|
+
gift: "gift";
|
|
228
|
+
}>>;
|
|
229
|
+
}, z.core.$strict>>>;
|
|
230
|
+
cta: z.ZodOptional<z.ZodString>;
|
|
231
|
+
footnote: z.ZodOptional<z.ZodString>;
|
|
232
|
+
comparison: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
233
|
+
label: z.ZodString;
|
|
234
|
+
values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
|
|
235
|
+
}, z.core.$strict>>>;
|
|
236
|
+
}, z.core.$strict>>;
|
|
237
|
+
}, z.core.$strict>;
|
|
238
|
+
layout: z.ZodObject<{
|
|
239
|
+
hero_image: z.ZodOptional<z.ZodUUID>;
|
|
240
|
+
close_button: z.ZodOptional<z.ZodBoolean>;
|
|
241
|
+
restore_button: z.ZodOptional<z.ZodBoolean>;
|
|
242
|
+
terms_url: z.ZodOptional<z.ZodString>;
|
|
243
|
+
privacy_url: z.ZodOptional<z.ZodString>;
|
|
244
|
+
}, z.core.$strict>;
|
|
245
|
+
}, z.core.$strict>;
|
|
246
|
+
assets: z.ZodRecord<z.ZodUUID, z.ZodString>;
|
|
247
|
+
}, z.core.$strict>;
|
|
248
|
+
export type ServedPaywall = z.infer<typeof servedPaywall>;
|
|
249
|
+
/**
|
|
250
|
+
* Parses a served paywall. Returns null for anything this SDK can't render safely (a newer
|
|
251
|
+
* schema, an invalid field, an asset URL off the API's origin), so callers use the default.
|
|
252
|
+
*/
|
|
253
|
+
export declare function parseServedPaywall(input: unknown, apiOrigin: string): ServedPaywall | null;
|
|
254
|
+
/** Validates a config for storage (the API's write path). Also enforces the size limit. */
|
|
255
|
+
export declare function validatePaywallConfig(input: unknown): {
|
|
256
|
+
ok: true;
|
|
257
|
+
config: PaywallConfig;
|
|
258
|
+
} | {
|
|
259
|
+
ok: false;
|
|
260
|
+
issues: z.core.$ZodIssue[];
|
|
261
|
+
};
|
|
262
|
+
/** Every asset id a config references. */
|
|
263
|
+
export declare function referencedAssets(config: PaywallConfig): string[];
|
|
264
|
+
export {};
|