@tryheliumai/paywall-sdk-react-native 0.2.21 → 3.0.3

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 (38) hide show
  1. package/PaywallSdkReactNative.podspec +2 -2
  2. package/ios/HeliumSwiftInterface.swift +90 -77
  3. package/ios/RCTHeliumBridge.m +1 -0
  4. package/lib/commonjs/handlers/revenuecat.js +1 -1
  5. package/lib/commonjs/handlers/revenuecat.js.map +1 -1
  6. package/lib/commonjs/index.js +0 -18
  7. package/lib/commonjs/index.js.map +1 -1
  8. package/lib/commonjs/native-interface.js +81 -165
  9. package/lib/commonjs/native-interface.js.map +1 -1
  10. package/lib/commonjs/types.js +4 -0
  11. package/lib/commonjs/types.js.map +1 -1
  12. package/lib/module/handlers/revenuecat.js +1 -1
  13. package/lib/module/handlers/revenuecat.js.map +1 -1
  14. package/lib/module/index.js +1 -1
  15. package/lib/module/index.js.map +1 -1
  16. package/lib/module/native-interface.js +81 -161
  17. package/lib/module/native-interface.js.map +1 -1
  18. package/lib/module/types.js +4 -0
  19. package/lib/module/types.js.map +1 -1
  20. package/lib/typescript/commonjs/src/handlers/revenuecat.d.ts.map +1 -1
  21. package/lib/typescript/commonjs/src/index.d.ts +2 -2
  22. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  23. package/lib/typescript/commonjs/src/native-interface.d.ts +2 -21
  24. package/lib/typescript/commonjs/src/native-interface.d.ts.map +1 -1
  25. package/lib/typescript/commonjs/src/types.d.ts +102 -3
  26. package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
  27. package/lib/typescript/module/src/handlers/revenuecat.d.ts.map +1 -1
  28. package/lib/typescript/module/src/index.d.ts +2 -2
  29. package/lib/typescript/module/src/index.d.ts.map +1 -1
  30. package/lib/typescript/module/src/native-interface.d.ts +2 -21
  31. package/lib/typescript/module/src/native-interface.d.ts.map +1 -1
  32. package/lib/typescript/module/src/types.d.ts +102 -3
  33. package/lib/typescript/module/src/types.d.ts.map +1 -1
  34. package/package.json +1 -1
  35. package/src/handlers/revenuecat.ts +0 -1
  36. package/src/index.ts +9 -3
  37. package/src/native-interface.tsx +105 -172
  38. package/src/types.ts +142 -5
package/src/types.ts CHANGED
@@ -1,9 +1,18 @@
1
- export type HeliumTransactionStatus = 'purchased' | 'failed' | 'cancelled' | 'pending' | 'restored';
1
+ export type HeliumTransactionStatus =
2
+ | 'purchased'
3
+ | 'failed'
4
+ | 'cancelled'
5
+ | 'pending'
6
+ | 'restored';
2
7
  export type HeliumPurchaseResult = {
3
8
  status: HeliumTransactionStatus;
4
9
  error?: string; // Optional error message
5
10
  };
6
- export type HeliumDownloadStatus = 'success' | 'failed' | 'inProgress' | 'notStarted';
11
+ export type HeliumDownloadStatus =
12
+ | 'success'
13
+ | 'failed'
14
+ | 'inProgress'
15
+ | 'notStarted';
7
16
 
8
17
  // --- Purchase Configuration Types ---
9
18
 
@@ -28,6 +37,133 @@ export function createCustomPurchaseConfig(callbacks: {
28
37
  };
29
38
  }
30
39
 
40
+ export type TriggerLoadingConfig = {
41
+ /** Whether to show loading state for this trigger. Set to nil to use the global `useLoadingState` setting. */
42
+ useLoadingState?: boolean;
43
+ /** Maximum seconds to show loading for this trigger. Set to nil to use the global `loadingBudget` setting. */
44
+ loadingBudget?: number;
45
+ };
46
+
47
+ export type HeliumPaywallLoadingConfig = {
48
+ /**
49
+ * Whether to show a loading state while fetching paywall configuration.
50
+ * When true, shows a loading view for up to `loadingBudget` seconds before falling back.
51
+ * Default: true
52
+ */
53
+ useLoadingState?: boolean;
54
+ /**
55
+ * Maximum time (in seconds) to show the loading state before displaying fallback.
56
+ * After this timeout, the fallback view will be shown even if the paywall is still downloading.
57
+ * Default: 2.0 seconds
58
+ */
59
+ loadingBudget?: number;
60
+ /**
61
+ * Optional per-trigger loading configuration overrides.
62
+ * Use this to customize loading behavior for specific triggers.
63
+ * Keys are trigger names, values are TriggerLoadingConfig instances.
64
+ * Example: Disable loading for "onboarding" trigger while keeping it for others.
65
+ */
66
+ perTriggerLoadingConfig?: Record<string, TriggerLoadingConfig>;
67
+ };
68
+
69
+ // Event handler types for per-presentation event handling
70
+ export interface PaywallEventHandlers {
71
+ onOpen?: (event: PaywallOpenEvent) => void;
72
+ onClose?: (event: PaywallCloseEvent) => void;
73
+ onDismissed?: (event: PaywallDismissedEvent) => void;
74
+ onPurchaseSucceeded?: (event: PurchaseSucceededEvent) => void;
75
+ }
76
+
77
+ // Typed event interfaces
78
+ export interface PaywallOpenEvent {
79
+ type: 'paywallOpen';
80
+ triggerName: string;
81
+ paywallName: string;
82
+ isSecondTry: boolean;
83
+ viewType?: 'presented' | 'embedded' | 'triggered';
84
+ }
85
+
86
+ export interface PaywallCloseEvent {
87
+ type: 'paywallClose';
88
+ triggerName: string;
89
+ paywallName: string;
90
+ isSecondTry: boolean;
91
+ }
92
+
93
+ export interface PaywallDismissedEvent {
94
+ type: 'paywallDismissed';
95
+ triggerName: string;
96
+ paywallName: string;
97
+ isSecondTry: boolean;
98
+ }
99
+
100
+ export interface PurchaseSucceededEvent {
101
+ type: 'purchaseSucceeded';
102
+ productId: string;
103
+ triggerName: string;
104
+ paywallName: string;
105
+ isSecondTry: boolean;
106
+ }
107
+
108
+ export type HeliumPaywallEvent = {
109
+ type:
110
+ | 'paywallOpen'
111
+ | 'paywallClose'
112
+ | 'paywallDismissed'
113
+ | 'paywallOpenFailed'
114
+ | 'paywallSkipped'
115
+ | 'paywallButtonPressed'
116
+ | 'productSelected'
117
+ | 'purchasePressed'
118
+ | 'purchaseSucceeded'
119
+ | 'purchaseCancelled'
120
+ | 'purchaseFailed'
121
+ | 'purchaseRestored'
122
+ | 'purchaseRestoreFailed'
123
+ | 'purchasePending'
124
+ | 'initializeStart'
125
+ | 'paywallsDownloadSuccess'
126
+ | 'paywallsDownloadError'
127
+ | 'paywallWebViewRendered';
128
+ triggerName?: string;
129
+ paywallName?: string;
130
+ /**
131
+ * @deprecated Use `paywallName` instead.
132
+ */
133
+ paywallTemplateName?: string;
134
+ productId?: string;
135
+ /**
136
+ * @deprecated Use `productId` instead.
137
+ */
138
+ productKey?: string;
139
+ ctaName?: string;
140
+ paywallDownloadTimeTakenMS?: number;
141
+ templateDownloadTimeTakenMS?: number;
142
+ imagesDownloadTimeTakenMS?: number;
143
+ stylesDownloadTimeTakenMS?: number;
144
+ fontsDownloadTimeTakenMS?: number;
145
+ bundleDownloadTimeMS?: number;
146
+ dismissAll?: boolean;
147
+ isSecondTry?: boolean;
148
+ error?: string;
149
+ /**
150
+ * @deprecated Use `error` instead.
151
+ */
152
+ errorDescription?: string;
153
+ /**
154
+ * Unix timestamp in seconds
155
+ */
156
+ timestamp?: number;
157
+ };
158
+
159
+ export type PresentUpsellParams = {
160
+ triggerName: string;
161
+ /** Optional. This will be called when paywall fails to show due to an unsuccessful paywall download or if an invalid trigger is provided. */
162
+ onFallback?: () => void;
163
+ eventHandlers?: PaywallEventHandlers;
164
+ customPaywallTraits?: Record<string, any>;
165
+ };
166
+
31
167
  // --- Main Helium Configuration ---
32
168
  export interface HeliumConfig {
33
169
  /** Your Helium API Key */
@@ -35,12 +171,13 @@ export interface HeliumConfig {
35
171
  /** Configuration for handling purchases. Can be custom functions or a pre-built handler config. */
36
172
  purchaseConfig: HeliumPurchaseConfig;
37
173
  /** Callback for receiving all Helium paywall events. */
38
- onHeliumPaywallEvent: (event: any) => void; // Still mandatory
174
+ onHeliumPaywallEvent: (event: HeliumPaywallEvent) => void;
39
175
 
40
176
  // Optional configurations
41
- fallbackView?: number;
177
+ /** Fallback bundle in the rare situation that paywall is not ready to be shown. Highly recommended. See docs at https://docs.tryhelium.com/guides/fallback-bundle#react-native */
42
178
  fallbackBundle?: object;
43
- triggers?: string[];
179
+ /** Configure loading behavior for paywalls that are mid-download. */
180
+ paywallLoadingConfig?: HeliumPaywallLoadingConfig;
44
181
  customUserId?: string;
45
182
  customAPIEndpoint?: string;
46
183
  customUserTraits?: Record<string, any>;