@tryheliumai/paywall-sdk-react-native 0.1.26 → 0.1.27

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 (37) hide show
  1. package/lib/commonjs/handlers/revenuecat.js +146 -0
  2. package/lib/commonjs/handlers/revenuecat.js.map +1 -0
  3. package/lib/commonjs/index.js +14 -0
  4. package/lib/commonjs/index.js.map +1 -1
  5. package/lib/commonjs/native-interface.js +34 -14
  6. package/lib/commonjs/native-interface.js.map +1 -1
  7. package/lib/commonjs/types.js +27 -0
  8. package/lib/commonjs/types.js.map +1 -1
  9. package/lib/module/handlers/revenuecat.js +138 -0
  10. package/lib/module/handlers/revenuecat.js.map +1 -0
  11. package/lib/module/index.js +2 -0
  12. package/lib/module/index.js.map +1 -1
  13. package/lib/module/native-interface.js +34 -14
  14. package/lib/module/native-interface.js.map +1 -1
  15. package/lib/module/types.js +23 -0
  16. package/lib/module/types.js.map +1 -1
  17. package/lib/typescript/commonjs/src/handlers/revenuecat.d.ts +16 -0
  18. package/lib/typescript/commonjs/src/handlers/revenuecat.d.ts.map +1 -0
  19. package/lib/typescript/commonjs/src/index.d.ts +3 -1
  20. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  21. package/lib/typescript/commonjs/src/native-interface.d.ts +2 -2
  22. package/lib/typescript/commonjs/src/native-interface.d.ts.map +1 -1
  23. package/lib/typescript/commonjs/src/types.d.ts +22 -3
  24. package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
  25. package/lib/typescript/module/src/handlers/revenuecat.d.ts +16 -0
  26. package/lib/typescript/module/src/handlers/revenuecat.d.ts.map +1 -0
  27. package/lib/typescript/module/src/index.d.ts +3 -1
  28. package/lib/typescript/module/src/index.d.ts.map +1 -1
  29. package/lib/typescript/module/src/native-interface.d.ts +2 -2
  30. package/lib/typescript/module/src/native-interface.d.ts.map +1 -1
  31. package/lib/typescript/module/src/types.d.ts +22 -3
  32. package/lib/typescript/module/src/types.d.ts.map +1 -1
  33. package/package.json +4 -2
  34. package/src/handlers/revenuecat.ts +132 -0
  35. package/src/index.ts +3 -1
  36. package/src/native-interface.tsx +42 -19
  37. package/src/types.ts +42 -4
package/src/types.ts CHANGED
@@ -1,25 +1,63 @@
1
- export type HeliumTransactionStatus = 'completed' | 'failed' | 'cancelled' | 'pending' | 'restored';
1
+ export type HeliumTransactionStatus = 'purchased' | 'failed' | 'cancelled' | 'pending' | 'restored';
2
2
  export type HeliumPurchaseResult = {
3
3
  status: HeliumTransactionStatus;
4
4
  error?: string; // Optional error message
5
5
  };
6
6
  export type HeliumDownloadStatus = 'success' | 'failed' | 'inProgress' | 'notStarted';
7
7
 
8
- export interface HeliumCallbacks {
8
+ // --- Purchase Configuration Types ---
9
+
10
+ /** Interface for providing custom purchase handling logic. */
11
+ export interface CustomPurchaseCallbacks {
9
12
  makePurchase: (productId: string) => Promise<HeliumPurchaseResult>;
10
13
  restorePurchases: () => Promise<boolean>;
11
- onHeliumPaywallEvent: (event: any) => void;
14
+ /** Discriminant property to identify custom callbacks */
15
+ type: 'custom';
16
+ }
17
+
18
+ /** Configuration for using the built-in RevenueCat handler. */
19
+ export interface RevenueCatPurchaseConfig {
20
+ /** Optional RevenueCat API Key. If not provided, RevenueCat must be configured elsewhere. */
21
+ apiKey?: string;
22
+ /** Discriminant property to identify RevenueCat config */
23
+ type: 'revenuecat';
12
24
  }
13
25
 
26
+ // Union type for the purchase configuration
27
+ export type HeliumPurchaseConfig = CustomPurchaseCallbacks | RevenueCatPurchaseConfig;
28
+ // Add other config types here in the future, e.g. | StripePurchaseConfig
29
+
30
+ // Helper function for creating Custom Purchase Config
31
+ export function CustomPurchaseConfig(callbacks: {
32
+ makePurchase: (productId: string) => Promise<HeliumPurchaseResult>;
33
+ restorePurchases: () => Promise<boolean>;
34
+ }): CustomPurchaseCallbacks {
35
+ return {
36
+ type: 'custom',
37
+ makePurchase: callbacks.makePurchase,
38
+ restorePurchases: callbacks.restorePurchases,
39
+ };
40
+ }
41
+
42
+ // --- Main Helium Configuration ---
14
43
  export interface HeliumConfig {
44
+ /** Your Helium API Key */
15
45
  apiKey: string;
16
- fallbackView?: number;
46
+ /** Configuration for handling purchases. Can be custom functions or a pre-built handler config. */
47
+ purchaseConfig: HeliumPurchaseConfig;
48
+ /** Callback for receiving all Helium paywall events. */
49
+ onHeliumPaywallEvent: (event: any) => void; // Still mandatory
50
+
51
+ // Optional configurations
52
+ fallbackView?: number;
17
53
  triggers?: string[];
18
54
  customUserId?: string;
19
55
  customAPIEndpoint?: string;
20
56
  customUserTraits?: Record<string, any>;
21
57
  }
22
58
 
59
+ // --- Other Existing Types ---
60
+
23
61
  export interface HeliumUpsellViewProps {
24
62
  trigger: string;
25
63
  style?: any;