@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.
- package/lib/commonjs/handlers/revenuecat.js +146 -0
- package/lib/commonjs/handlers/revenuecat.js.map +1 -0
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native-interface.js +34 -14
- package/lib/commonjs/native-interface.js.map +1 -1
- package/lib/commonjs/types.js +27 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/handlers/revenuecat.js +138 -0
- package/lib/module/handlers/revenuecat.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/native-interface.js +34 -14
- package/lib/module/native-interface.js.map +1 -1
- package/lib/module/types.js +23 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/commonjs/src/handlers/revenuecat.d.ts +16 -0
- package/lib/typescript/commonjs/src/handlers/revenuecat.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +3 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/native-interface.d.ts +2 -2
- package/lib/typescript/commonjs/src/native-interface.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +22 -3
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/handlers/revenuecat.d.ts +16 -0
- package/lib/typescript/module/src/handlers/revenuecat.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +3 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/native-interface.d.ts +2 -2
- package/lib/typescript/module/src/native-interface.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +22 -3
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/handlers/revenuecat.ts +132 -0
- package/src/index.ts +3 -1
- package/src/native-interface.tsx +42 -19
- package/src/types.ts +42 -4
package/src/types.ts
CHANGED
|
@@ -1,25 +1,63 @@
|
|
|
1
|
-
export type HeliumTransactionStatus = '
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|