react-native-revnix 1.4.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 +766 -0
- package/dist/blocks/background.d.ts +101 -0
- package/dist/blocks/background.js +165 -0
- package/dist/blocks/color.d.ts +88 -0
- package/dist/blocks/color.js +329 -0
- package/dist/blocks/locale.d.ts +42 -0
- package/dist/blocks/locale.js +263 -0
- package/dist/blocks/selection.d.ts +49 -0
- package/dist/blocks/selection.js +109 -0
- package/dist/blocks/style.d.ts +93 -0
- package/dist/blocks/style.js +365 -0
- package/dist/blocks/tags.d.ts +12 -0
- package/dist/blocks/tags.js +121 -0
- package/dist/blocks/types.d.ts +301 -0
- package/dist/blocks/types.js +44 -0
- package/dist/client.d.ts +402 -0
- package/dist/client.js +1653 -0
- package/dist/device.d.ts +29 -0
- package/dist/device.js +137 -0
- package/dist/errors.d.ts +39 -0
- package/dist/errors.js +68 -0
- package/dist/esm/blocks/background.js +160 -0
- package/dist/esm/blocks/color.js +318 -0
- package/dist/esm/blocks/locale.js +255 -0
- package/dist/esm/blocks/selection.js +100 -0
- package/dist/esm/blocks/style.js +356 -0
- package/dist/esm/blocks/tags.js +117 -0
- package/dist/esm/blocks/types.js +40 -0
- package/dist/esm/client.js +1649 -0
- package/dist/esm/device.js +130 -0
- package/dist/esm/errors.js +59 -0
- package/dist/esm/iap.js +101 -0
- package/dist/esm/implicit.js +63 -0
- package/dist/esm/index.js +29 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/storage.js +78 -0
- package/dist/esm/types.js +4 -0
- package/dist/esm/ui/RevnixBlockPaywall.js +706 -0
- package/dist/esm/ui/RevnixPaywall.js +890 -0
- package/dist/esm/ui/index.js +6 -0
- package/dist/esm/version.js +4 -0
- package/dist/iap.d.ts +20 -0
- package/dist/iap.js +104 -0
- package/dist/implicit.d.ts +69 -0
- package/dist/implicit.js +67 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +50 -0
- package/dist/storage.d.ts +14 -0
- package/dist/storage.js +85 -0
- package/dist/types.d.ts +463 -0
- package/dist/types.js +5 -0
- package/dist/ui/RevnixBlockPaywall.d.ts +96 -0
- package/dist/ui/RevnixBlockPaywall.js +742 -0
- package/dist/ui/RevnixPaywall.d.ts +148 -0
- package/dist/ui/RevnixPaywall.js +927 -0
- package/dist/ui/index.d.ts +7 -0
- package/dist/ui/index.js +25 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +7 -0
- package/package.json +79 -0
- package/src/blocks/background.ts +232 -0
- package/src/blocks/color.ts +352 -0
- package/src/blocks/locale.ts +271 -0
- package/src/blocks/paywall-background-wire.json +12 -0
- package/src/blocks/paywall-selection-wire.json +149 -0
- package/src/blocks/selection.ts +161 -0
- package/src/blocks/style.ts +411 -0
- package/src/blocks/tags.ts +125 -0
- package/src/blocks/types.ts +352 -0
- package/src/client.ts +1993 -0
- package/src/device.ts +146 -0
- package/src/errors.ts +69 -0
- package/src/iap.ts +137 -0
- package/src/implicit.ts +129 -0
- package/src/index.ts +82 -0
- package/src/storage.ts +92 -0
- package/src/types.ts +528 -0
- package/src/ui/RevnixBlockPaywall.tsx +1423 -0
- package/src/ui/RevnixPaywall.tsx +1542 -0
- package/src/ui/index.ts +43 -0
- package/src/version.ts +4 -0
- package/ui.d.ts +1 -0
- package/ui.js +5 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type StyleProp, type ViewStyle } from "react-native";
|
|
3
|
+
import type { PaywallConfig, PaywallInteraction, PaywallPurchaseOutcome } from "../types.js";
|
|
4
|
+
import type { FontFamilyMap } from "../blocks/style.js";
|
|
5
|
+
import { type RevnixBlurComponent, type RevnixGradientComponent } from "./RevnixBlockPaywall.js";
|
|
6
|
+
/** One purchasable row. `priceLabel` must come from the store (localized). */
|
|
7
|
+
export interface RevnixPaywallPackage {
|
|
8
|
+
packageId: string;
|
|
9
|
+
title: string;
|
|
10
|
+
priceLabel: string;
|
|
11
|
+
/** Renewal cycle ("monthly", "annual", …) from the catalog product. Only
|
|
12
|
+
* designed (block) paywalls read it, to resolve the {period},
|
|
13
|
+
* {period_short}, {price_per_month} and {save_percent} tags — a tag with
|
|
14
|
+
* no cycle behind it renders as written rather than guessed. */
|
|
15
|
+
period?: string;
|
|
16
|
+
/** Price in minor units, for the same per-month and saving maths. */
|
|
17
|
+
amountMinor?: number;
|
|
18
|
+
/** ISO currency of `amountMinor`. */
|
|
19
|
+
currency?: string;
|
|
20
|
+
/** REV-263: the catalog product behind this package. Only telemetry reads
|
|
21
|
+
* it — a `selected` or `purchase_started` report names the plan the way
|
|
22
|
+
* the rest of the ledger does. Optional: without it the interaction is
|
|
23
|
+
* still reported, just with no plan attached (the package id would be
|
|
24
|
+
* worse — it would look like a product that does not exist). */
|
|
25
|
+
productId?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Colors the paywall renders with. Defaults mirror the dashboard preview
|
|
28
|
+
* chrome (a fixed dark screen) — override to match the host app's theme. */
|
|
29
|
+
export interface RevnixPaywallTheme {
|
|
30
|
+
background: string;
|
|
31
|
+
textPrimary: string;
|
|
32
|
+
textSecondary: string;
|
|
33
|
+
textFaint: string;
|
|
34
|
+
border: string;
|
|
35
|
+
/** Text color on accent-filled surfaces (CTA, badge). */
|
|
36
|
+
accentInk: string;
|
|
37
|
+
}
|
|
38
|
+
export declare const DEFAULT_PAYWALL_THEME: RevnixPaywallTheme;
|
|
39
|
+
/** Base theme when the dashboard config sets `mode: "light"`. Keep in
|
|
40
|
+
* lockstep with the builder preview (PaywallPhonePreview SCREEN_PALETTES). */
|
|
41
|
+
export declare const LIGHT_PAYWALL_THEME: RevnixPaywallTheme;
|
|
42
|
+
export interface RevnixPaywallProps {
|
|
43
|
+
config: PaywallConfig;
|
|
44
|
+
packages: RevnixPaywallPackage[];
|
|
45
|
+
/** Called with the selected packageId when the CTA is pressed.
|
|
46
|
+
*
|
|
47
|
+
* REV-263: passing `client` reports `paywall.purchase_started` the moment
|
|
48
|
+
* this fires. The OUTCOME is yours — only the host performs the store
|
|
49
|
+
* call — so to have the paywall report it too, return it (or a promise of
|
|
50
|
+
* it): `cancelled` becomes `paywall.purchase_abandoned`, `failed` becomes
|
|
51
|
+
* `paywall.purchase_failed`, and a promise that REJECTS is reported as a
|
|
52
|
+
* failure carrying the error's message. Returning nothing keeps today's
|
|
53
|
+
* behavior exactly — the start is reported, the outcome is not, and you
|
|
54
|
+
* can still report it yourself with `client.logPaywallEvent`. */
|
|
55
|
+
onPurchase: (packageId: string) => void | PaywallPurchaseOutcome | Promise<PaywallPurchaseOutcome | void>;
|
|
56
|
+
/** Controlled selection; omit to let the paywall manage it (initial
|
|
57
|
+
* selection is the config's highlight package, else the first package). */
|
|
58
|
+
selectedPackageId?: string;
|
|
59
|
+
onSelectPackage?: (packageId: string) => void;
|
|
60
|
+
/** Renders a spinner in the CTA and disables purchasing. */
|
|
61
|
+
loading?: boolean;
|
|
62
|
+
onRestore?: () => void;
|
|
63
|
+
onTerms?: () => void;
|
|
64
|
+
onPrivacy?: () => void;
|
|
65
|
+
/** Called when the customer dismisses the paywall (REV-252) — either by
|
|
66
|
+
* tapping an element the design marks as the close, or by the close button
|
|
67
|
+
* the renderer supplies when the design authors none.
|
|
68
|
+
*
|
|
69
|
+
* Dismissal is the HOST's to perform: the paywall does not unmount itself,
|
|
70
|
+
* because only the host knows whether that means popping a screen, closing
|
|
71
|
+
* a modal, or advancing onboarding. Omit it and no close is drawn at all —
|
|
72
|
+
* a paywall with a dead close button is worse than one without.
|
|
73
|
+
*
|
|
74
|
+
* Passing `client` as well reports `paywall.closed` against this display's
|
|
75
|
+
* own view id, so the close pairs with its paywall.viewed. */
|
|
76
|
+
onClose?: () => void;
|
|
77
|
+
theme?: Partial<RevnixPaywallTheme>;
|
|
78
|
+
style?: StyleProp<ViewStyle>;
|
|
79
|
+
/** When given, the paywall reports one paywall.viewed per mount (REV-094)
|
|
80
|
+
* — the analytics funnel's "Paywall displayed" stage. Structural typing
|
|
81
|
+
* keeps this entrypoint free of a hard client import. */
|
|
82
|
+
client?: {
|
|
83
|
+
logPaywallShown: (options?: {
|
|
84
|
+
placementKey?: string;
|
|
85
|
+
paywallId?: string;
|
|
86
|
+
}) => string | void;
|
|
87
|
+
/** Older clients predate close reporting; the paywall still closes. */
|
|
88
|
+
logPaywallClosed?: (viewId: string, options?: {
|
|
89
|
+
placementKey?: string;
|
|
90
|
+
paywallId?: string;
|
|
91
|
+
}) => void;
|
|
92
|
+
/** Where a designed paywall reports a paint string it could not read.
|
|
93
|
+
* Optional for the same reason: a client that predates it still renders,
|
|
94
|
+
* it just reports nothing. */
|
|
95
|
+
reportRenderDiagnostic?: (message: string) => void;
|
|
96
|
+
/** REV-263: the interaction vocabulary. Optional so a host on an older
|
|
97
|
+
* client still renders and still reports views — it just reports none of
|
|
98
|
+
* the six. */
|
|
99
|
+
logPaywallEvent?: (event: PaywallInteraction, viewId: string, options?: {
|
|
100
|
+
placementKey?: string;
|
|
101
|
+
paywallId?: string;
|
|
102
|
+
productId?: string;
|
|
103
|
+
code?: string;
|
|
104
|
+
message?: string;
|
|
105
|
+
eventId?: string;
|
|
106
|
+
}) => void;
|
|
107
|
+
};
|
|
108
|
+
/** Placement/paywall attribution attached to the view report. */
|
|
109
|
+
placementKey?: string;
|
|
110
|
+
paywallId?: string;
|
|
111
|
+
/** Opt out of the automatic view report while still passing `client`. */
|
|
112
|
+
disableViewTracking?: boolean;
|
|
113
|
+
/** Renders the CSS gradients a designed (block) paywall may use. Pass the
|
|
114
|
+
* app's own `LinearGradient` (expo-linear-gradient or
|
|
115
|
+
* react-native-linear-gradient). Without it a gradient paints as the
|
|
116
|
+
* design's ground color. Ignored by the classic layouts. */
|
|
117
|
+
gradient?: RevnixGradientComponent;
|
|
118
|
+
/** Renders a blurred background photo on a designed paywall. RN has no
|
|
119
|
+
* blur primitive, so pass the app's own (`expo-blur`'s `BlurView`, or
|
|
120
|
+
* `@react-native-community/blur`). Without it a blurred background photo
|
|
121
|
+
* renders sharp. Ignored by the classic layouts. */
|
|
122
|
+
blur?: RevnixBlurComponent;
|
|
123
|
+
/** Design font family → the face(s) the app has registered, for designed
|
|
124
|
+
* paywalls. Either one family for every weight, or a weight → family table.
|
|
125
|
+
* RN cannot load a font by name at runtime, so an unmapped face renders in
|
|
126
|
+
* the system font. */
|
|
127
|
+
fontFamilyMap?: FontFamilyMap;
|
|
128
|
+
/** Reports a paint string the designed renderer could not read, or a
|
|
129
|
+
* gradient it flattened for want of a `gradient` component.
|
|
130
|
+
*
|
|
131
|
+
* Local only: nothing is sent anywhere. Passing `client` routes the same
|
|
132
|
+
* reports to that client's own `onDiagnostic`, so most apps need neither —
|
|
133
|
+
* this is for a host that renders a paywall without a client. */
|
|
134
|
+
onDiagnostic?: (message: string) => void;
|
|
135
|
+
/** REV-271: which language to draw a DESIGNED paywall's copy in. Omitted,
|
|
136
|
+
* the device's own is detected — which is what makes the paywall match the
|
|
137
|
+
* rest of the app on a phone with no in-app language switch. Pass one when
|
|
138
|
+
* the app HAS such a switch, so the paywall follows the app rather than the
|
|
139
|
+
* OS: a user reading the app in Spanish on an English phone must not be
|
|
140
|
+
* handed an English paywall. A paywall with no translations ignores this,
|
|
141
|
+
* and any string the chosen language does not translate falls back to the
|
|
142
|
+
* authored copy rather than rendering blank.
|
|
143
|
+
*
|
|
144
|
+
* Only designed (block) paywalls are localized; the classic template
|
|
145
|
+
* layouts below render `config`'s own copy whatever this says. */
|
|
146
|
+
locale?: string;
|
|
147
|
+
}
|
|
148
|
+
export declare function RevnixPaywall(props: RevnixPaywallProps): React.JSX.Element;
|