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.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +766 -0
  3. package/dist/blocks/background.d.ts +101 -0
  4. package/dist/blocks/background.js +165 -0
  5. package/dist/blocks/color.d.ts +88 -0
  6. package/dist/blocks/color.js +329 -0
  7. package/dist/blocks/locale.d.ts +42 -0
  8. package/dist/blocks/locale.js +263 -0
  9. package/dist/blocks/selection.d.ts +49 -0
  10. package/dist/blocks/selection.js +109 -0
  11. package/dist/blocks/style.d.ts +93 -0
  12. package/dist/blocks/style.js +365 -0
  13. package/dist/blocks/tags.d.ts +12 -0
  14. package/dist/blocks/tags.js +121 -0
  15. package/dist/blocks/types.d.ts +301 -0
  16. package/dist/blocks/types.js +44 -0
  17. package/dist/client.d.ts +402 -0
  18. package/dist/client.js +1653 -0
  19. package/dist/device.d.ts +29 -0
  20. package/dist/device.js +137 -0
  21. package/dist/errors.d.ts +39 -0
  22. package/dist/errors.js +68 -0
  23. package/dist/esm/blocks/background.js +160 -0
  24. package/dist/esm/blocks/color.js +318 -0
  25. package/dist/esm/blocks/locale.js +255 -0
  26. package/dist/esm/blocks/selection.js +100 -0
  27. package/dist/esm/blocks/style.js +356 -0
  28. package/dist/esm/blocks/tags.js +117 -0
  29. package/dist/esm/blocks/types.js +40 -0
  30. package/dist/esm/client.js +1649 -0
  31. package/dist/esm/device.js +130 -0
  32. package/dist/esm/errors.js +59 -0
  33. package/dist/esm/iap.js +101 -0
  34. package/dist/esm/implicit.js +63 -0
  35. package/dist/esm/index.js +29 -0
  36. package/dist/esm/package.json +1 -0
  37. package/dist/esm/storage.js +78 -0
  38. package/dist/esm/types.js +4 -0
  39. package/dist/esm/ui/RevnixBlockPaywall.js +706 -0
  40. package/dist/esm/ui/RevnixPaywall.js +890 -0
  41. package/dist/esm/ui/index.js +6 -0
  42. package/dist/esm/version.js +4 -0
  43. package/dist/iap.d.ts +20 -0
  44. package/dist/iap.js +104 -0
  45. package/dist/implicit.d.ts +69 -0
  46. package/dist/implicit.js +67 -0
  47. package/dist/index.d.ts +18 -0
  48. package/dist/index.js +50 -0
  49. package/dist/storage.d.ts +14 -0
  50. package/dist/storage.js +85 -0
  51. package/dist/types.d.ts +463 -0
  52. package/dist/types.js +5 -0
  53. package/dist/ui/RevnixBlockPaywall.d.ts +96 -0
  54. package/dist/ui/RevnixBlockPaywall.js +742 -0
  55. package/dist/ui/RevnixPaywall.d.ts +148 -0
  56. package/dist/ui/RevnixPaywall.js +927 -0
  57. package/dist/ui/index.d.ts +7 -0
  58. package/dist/ui/index.js +25 -0
  59. package/dist/version.d.ts +1 -0
  60. package/dist/version.js +7 -0
  61. package/package.json +79 -0
  62. package/src/blocks/background.ts +232 -0
  63. package/src/blocks/color.ts +352 -0
  64. package/src/blocks/locale.ts +271 -0
  65. package/src/blocks/paywall-background-wire.json +12 -0
  66. package/src/blocks/paywall-selection-wire.json +149 -0
  67. package/src/blocks/selection.ts +161 -0
  68. package/src/blocks/style.ts +411 -0
  69. package/src/blocks/tags.ts +125 -0
  70. package/src/blocks/types.ts +352 -0
  71. package/src/client.ts +1993 -0
  72. package/src/device.ts +146 -0
  73. package/src/errors.ts +69 -0
  74. package/src/iap.ts +137 -0
  75. package/src/implicit.ts +129 -0
  76. package/src/index.ts +82 -0
  77. package/src/storage.ts +92 -0
  78. package/src/types.ts +528 -0
  79. package/src/ui/RevnixBlockPaywall.tsx +1423 -0
  80. package/src/ui/RevnixPaywall.tsx +1542 -0
  81. package/src/ui/index.ts +43 -0
  82. package/src/version.ts +4 -0
  83. package/ui.d.ts +1 -0
  84. 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;