@ridwan-retainer/paywall 0.1.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 (116) hide show
  1. package/README.md +64 -0
  2. package/dist/__mocks__/async-storage.d.ts +12 -0
  3. package/dist/__mocks__/async-storage.d.ts.map +1 -0
  4. package/dist/__mocks__/async-storage.js +14 -0
  5. package/dist/__mocks__/react-native-purchases-ui.d.ts +17 -0
  6. package/dist/__mocks__/react-native-purchases-ui.d.ts.map +1 -0
  7. package/dist/__mocks__/react-native-purchases-ui.js +16 -0
  8. package/dist/__mocks__/react-native-purchases.d.ts +22 -0
  9. package/dist/__mocks__/react-native-purchases.d.ts.map +1 -0
  10. package/dist/__mocks__/react-native-purchases.js +25 -0
  11. package/dist/components/Paywall.d.ts +13 -0
  12. package/dist/components/Paywall.d.ts.map +1 -0
  13. package/dist/components/Paywall.js +18 -0
  14. package/dist/components/PaywallFooter.d.ts +13 -0
  15. package/dist/components/PaywallFooter.d.ts.map +1 -0
  16. package/dist/components/PaywallFooter.js +60 -0
  17. package/dist/components/PaywallGate.d.ts +12 -0
  18. package/dist/components/PaywallGate.d.ts.map +1 -0
  19. package/dist/components/PaywallGate.js +66 -0
  20. package/dist/components/PurchaseButton.d.ts +13 -0
  21. package/dist/components/PurchaseButton.d.ts.map +1 -0
  22. package/dist/components/PurchaseButton.js +30 -0
  23. package/dist/components/RestoreButton.d.ts +16 -0
  24. package/dist/components/RestoreButton.d.ts.map +1 -0
  25. package/dist/components/RestoreButton.js +35 -0
  26. package/dist/components/SubscriptionGate.d.ts +14 -0
  27. package/dist/components/SubscriptionGate.d.ts.map +1 -0
  28. package/dist/components/SubscriptionGate.js +22 -0
  29. package/dist/config/RevenueCatConfig.d.ts +4 -0
  30. package/dist/config/RevenueCatConfig.d.ts.map +1 -0
  31. package/dist/config/RevenueCatConfig.js +61 -0
  32. package/dist/config/environment.d.ts +3 -0
  33. package/dist/config/environment.d.ts.map +1 -0
  34. package/dist/config/environment.js +16 -0
  35. package/dist/config/types.d.ts +16 -0
  36. package/dist/config/types.d.ts.map +1 -0
  37. package/dist/config/types.js +2 -0
  38. package/dist/entitlements/CustomerInfoManager.d.ts +14 -0
  39. package/dist/entitlements/CustomerInfoManager.d.ts.map +1 -0
  40. package/dist/entitlements/CustomerInfoManager.js +59 -0
  41. package/dist/entitlements/EntitlementCache.d.ts +5 -0
  42. package/dist/entitlements/EntitlementCache.d.ts.map +1 -0
  43. package/dist/entitlements/EntitlementCache.js +39 -0
  44. package/dist/entitlements/subscriptionUtils.d.ts +10 -0
  45. package/dist/entitlements/subscriptionUtils.d.ts.map +1 -0
  46. package/dist/entitlements/subscriptionUtils.js +34 -0
  47. package/dist/entitlements/types.d.ts +13 -0
  48. package/dist/entitlements/types.d.ts.map +1 -0
  49. package/dist/entitlements/types.js +2 -0
  50. package/dist/hooks/useCurrentOffering.d.ts +11 -0
  51. package/dist/hooks/useCurrentOffering.d.ts.map +1 -0
  52. package/dist/hooks/useCurrentOffering.js +46 -0
  53. package/dist/hooks/useCustomerInfo.d.ts +8 -0
  54. package/dist/hooks/useCustomerInfo.d.ts.map +1 -0
  55. package/dist/hooks/useCustomerInfo.js +34 -0
  56. package/dist/hooks/useEntitlement.d.ts +10 -0
  57. package/dist/hooks/useEntitlement.d.ts.map +1 -0
  58. package/dist/hooks/useEntitlement.js +48 -0
  59. package/dist/hooks/useOfferings.d.ts +9 -0
  60. package/dist/hooks/useOfferings.d.ts.map +1 -0
  61. package/dist/hooks/useOfferings.js +58 -0
  62. package/dist/hooks/usePaywall.d.ts +6 -0
  63. package/dist/hooks/usePaywall.d.ts.map +1 -0
  64. package/dist/hooks/usePaywall.js +23 -0
  65. package/dist/hooks/usePurchase.d.ts +14 -0
  66. package/dist/hooks/usePurchase.d.ts.map +1 -0
  67. package/dist/hooks/usePurchase.js +48 -0
  68. package/dist/hooks/useRestorePurchases.d.ts +14 -0
  69. package/dist/hooks/useRestorePurchases.d.ts.map +1 -0
  70. package/dist/hooks/useRestorePurchases.js +48 -0
  71. package/dist/hooks/useRevenueCatInitialization.d.ts +5 -0
  72. package/dist/hooks/useRevenueCatInitialization.d.ts.map +1 -0
  73. package/dist/hooks/useRevenueCatInitialization.js +44 -0
  74. package/dist/index.d.ts +38 -0
  75. package/dist/index.d.ts.map +1 -0
  76. package/dist/index.js +86 -0
  77. package/dist/offerings/OfferingsManager.d.ts +12 -0
  78. package/dist/offerings/OfferingsManager.d.ts.map +1 -0
  79. package/dist/offerings/OfferingsManager.js +44 -0
  80. package/dist/offerings/packageUtils.d.ts +11 -0
  81. package/dist/offerings/packageUtils.d.ts.map +1 -0
  82. package/dist/offerings/packageUtils.js +44 -0
  83. package/dist/offerings/types.d.ts +8 -0
  84. package/dist/offerings/types.d.ts.map +1 -0
  85. package/dist/offerings/types.js +2 -0
  86. package/dist/paywall/PaywallController.d.ts +21 -0
  87. package/dist/paywall/PaywallController.d.ts.map +1 -0
  88. package/dist/paywall/PaywallController.js +61 -0
  89. package/dist/paywall/types.d.ts +60 -0
  90. package/dist/paywall/types.d.ts.map +1 -0
  91. package/dist/paywall/types.js +10 -0
  92. package/dist/purchase/PurchaseManager.d.ts +10 -0
  93. package/dist/purchase/PurchaseManager.d.ts.map +1 -0
  94. package/dist/purchase/PurchaseManager.js +45 -0
  95. package/dist/purchase/errorHandling.d.ts +5 -0
  96. package/dist/purchase/errorHandling.d.ts.map +1 -0
  97. package/dist/purchase/errorHandling.js +36 -0
  98. package/dist/purchase/purchaseCache.d.ts +19 -0
  99. package/dist/purchase/purchaseCache.d.ts.map +1 -0
  100. package/dist/purchase/purchaseCache.js +57 -0
  101. package/dist/purchase/types.d.ts +23 -0
  102. package/dist/purchase/types.d.ts.map +1 -0
  103. package/dist/purchase/types.js +11 -0
  104. package/dist/restore/RestoreManager.d.ts +26 -0
  105. package/dist/restore/RestoreManager.d.ts.map +1 -0
  106. package/dist/restore/RestoreManager.js +72 -0
  107. package/dist/restore/autoRestore.d.ts +13 -0
  108. package/dist/restore/autoRestore.d.ts.map +1 -0
  109. package/dist/restore/autoRestore.js +37 -0
  110. package/dist/restore/errorHandling.d.ts +10 -0
  111. package/dist/restore/errorHandling.d.ts.map +1 -0
  112. package/dist/restore/errorHandling.js +30 -0
  113. package/dist/restore/types.d.ts +22 -0
  114. package/dist/restore/types.d.ts.map +1 -0
  115. package/dist/restore/types.js +11 -0
  116. package/package.json +60 -0
@@ -0,0 +1,16 @@
1
+ export interface RevenueCatConfig {
2
+ apiKey: string;
3
+ appUserID?: string;
4
+ observerMode?: boolean;
5
+ useAmazon?: boolean;
6
+ }
7
+ export interface PlatformConfig {
8
+ iosApiKey: string;
9
+ androidApiKey: string;
10
+ }
11
+ export interface GlobalWithProcess {
12
+ process?: {
13
+ env?: Record<string, string | undefined>;
14
+ };
15
+ }
16
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE;QACR,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;KAC1C,CAAC;CACH"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ import type { CustomerInfo, PurchasesEntitlementInfo } from './types';
2
+ export declare class CustomerInfoManager {
3
+ private cachedCustomerInfo;
4
+ private lastFetchTime;
5
+ private readonly CACHE_DURATION;
6
+ getCustomerInfo(forceRefresh?: boolean): Promise<CustomerInfo>;
7
+ hasEntitlement(entitlementId: string): Promise<boolean>;
8
+ getEntitlement(entitlementId: string): Promise<PurchasesEntitlementInfo | null>;
9
+ hasAnyActiveEntitlement(): Promise<boolean>;
10
+ clearCache(): void;
11
+ getCachedCustomerInfo(): CustomerInfo | null;
12
+ }
13
+ export declare const customerInfoManager: CustomerInfoManager;
14
+ //# sourceMappingURL=CustomerInfoManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomerInfoManager.d.ts","sourceRoot":"","sources":["../../src/entitlements/CustomerInfoManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEtE,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,kBAAkB,CAA6B;IACvD,OAAO,CAAC,aAAa,CAAa;IAClC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAG1C,eAAe,CAAC,YAAY,GAAE,OAAe,GAAG,OAAO,CAAC,YAAY,CAAC;IAiBrE,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOvD,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC;IAM/E,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC;IAMjD,UAAU,IAAI,IAAI;IAMlB,qBAAqB,IAAI,YAAY,GAAG,IAAI;CAU7C;AAGD,eAAO,MAAM,mBAAmB,qBAA4B,CAAC"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.customerInfoManager = exports.CustomerInfoManager = void 0;
7
+ const react_native_purchases_1 = __importDefault(require("react-native-purchases"));
8
+ class CustomerInfoManager {
9
+ constructor() {
10
+ this.cachedCustomerInfo = null;
11
+ this.lastFetchTime = 0;
12
+ this.CACHE_DURATION = 5 * 60 * 1000; // 5 minutes
13
+ }
14
+ // Get customer info (subscription status, entitlements, etc.) - SDK caches automatically
15
+ async getCustomerInfo(forceRefresh = false) {
16
+ const now = Date.now();
17
+ const cacheExpired = now - this.lastFetchTime > this.CACHE_DURATION;
18
+ if (this.cachedCustomerInfo && !cacheExpired && !forceRefresh) {
19
+ return this.cachedCustomerInfo;
20
+ }
21
+ const customerInfo = await react_native_purchases_1.default.getCustomerInfo();
22
+ this.cachedCustomerInfo = customerInfo;
23
+ this.lastFetchTime = now;
24
+ return customerInfo;
25
+ }
26
+ // Check if user has specific entitlement (check entitlements.active[id])
27
+ async hasEntitlement(entitlementId) {
28
+ const customerInfo = await this.getCustomerInfo();
29
+ const entitlement = customerInfo.entitlements.active[entitlementId];
30
+ return entitlement?.isActive === true;
31
+ }
32
+ // Get specific entitlement info
33
+ async getEntitlement(entitlementId) {
34
+ const customerInfo = await this.getCustomerInfo();
35
+ return customerInfo.entitlements.active[entitlementId] || null;
36
+ }
37
+ // Check if user has any active entitlements
38
+ async hasAnyActiveEntitlement() {
39
+ const customerInfo = await this.getCustomerInfo();
40
+ return Object.keys(customerInfo.entitlements.active).length > 0;
41
+ }
42
+ // Clear cached customer info (call after purchases, restores, or sign-in)
43
+ clearCache() {
44
+ this.cachedCustomerInfo = null;
45
+ this.lastFetchTime = 0;
46
+ }
47
+ // Get cached customer info without network request
48
+ getCachedCustomerInfo() {
49
+ const now = Date.now();
50
+ const cacheExpired = now - this.lastFetchTime > this.CACHE_DURATION;
51
+ if (this.cachedCustomerInfo && !cacheExpired) {
52
+ return this.cachedCustomerInfo;
53
+ }
54
+ return null;
55
+ }
56
+ }
57
+ exports.CustomerInfoManager = CustomerInfoManager;
58
+ // Singleton instance
59
+ exports.customerInfoManager = new CustomerInfoManager();
@@ -0,0 +1,5 @@
1
+ import type { CustomerInfo } from './types';
2
+ export declare function cacheCustomerInfo(customerInfo: CustomerInfo): Promise<void>;
3
+ export declare function getCachedCustomerInfo(): Promise<CustomerInfo | null>;
4
+ export declare function clearCustomerInfoCache(): Promise<void>;
5
+ //# sourceMappingURL=EntitlementCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntitlementCache.d.ts","sourceRoot":"","sources":["../../src/entitlements/EntitlementCache.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAK5C,wBAAsB,iBAAiB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAMjF;AAGD,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAQ1E;AAGD,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC,CAM5D"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.cacheCustomerInfo = cacheCustomerInfo;
7
+ exports.getCachedCustomerInfo = getCachedCustomerInfo;
8
+ exports.clearCustomerInfoCache = clearCustomerInfoCache;
9
+ const async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
10
+ const CACHE_KEY = '@paywall/customer-info';
11
+ // Cache CustomerInfo locally for offline entitlement checks
12
+ async function cacheCustomerInfo(customerInfo) {
13
+ try {
14
+ await async_storage_1.default.setItem(CACHE_KEY, JSON.stringify(customerInfo));
15
+ }
16
+ catch (error) {
17
+ console.warn('[EntitlementCache] Failed to cache customer info:', error);
18
+ }
19
+ }
20
+ // Get cached CustomerInfo for offline use
21
+ async function getCachedCustomerInfo() {
22
+ try {
23
+ const cached = await async_storage_1.default.getItem(CACHE_KEY);
24
+ return cached ? JSON.parse(cached) : null;
25
+ }
26
+ catch (error) {
27
+ console.warn('[EntitlementCache] Failed to get cached customer info:', error);
28
+ return null;
29
+ }
30
+ }
31
+ // Clear cached CustomerInfo
32
+ async function clearCustomerInfoCache() {
33
+ try {
34
+ await async_storage_1.default.removeItem(CACHE_KEY);
35
+ }
36
+ catch (error) {
37
+ console.warn('[EntitlementCache] Failed to clear customer info cache:', error);
38
+ }
39
+ }
@@ -0,0 +1,10 @@
1
+ import type { CustomerInfo, PurchasesEntitlementInfo } from './types';
2
+ export declare function isSubscribed(customerInfo: CustomerInfo): boolean;
3
+ export declare function getActiveEntitlements(customerInfo: CustomerInfo): string[];
4
+ export declare function willRenew(entitlement: PurchasesEntitlementInfo): boolean;
5
+ export declare function getExpirationDate(entitlement: PurchasesEntitlementInfo): Date | null;
6
+ export declare function isInTrialPeriod(entitlement: PurchasesEntitlementInfo): boolean;
7
+ export declare function isInGracePeriod(entitlement: PurchasesEntitlementInfo): boolean;
8
+ export declare function hasBillingIssue(entitlement: PurchasesEntitlementInfo): boolean;
9
+ export declare function getProductIdentifier(entitlement: PurchasesEntitlementInfo): string;
10
+ //# sourceMappingURL=subscriptionUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriptionUtils.d.ts","sourceRoot":"","sources":["../../src/entitlements/subscriptionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEtE,wBAAgB,YAAY,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAEhE;AAED,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,EAAE,CAE1E;AAED,wBAAgB,SAAS,CAAC,WAAW,EAAE,wBAAwB,GAAG,OAAO,CAExE;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,wBAAwB,GAAG,IAAI,GAAG,IAAI,CAEpF;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,wBAAwB,GAAG,OAAO,CAE9E;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,wBAAwB,GAAG,OAAO,CAE9E;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,wBAAwB,GAAG,OAAO,CAE9E;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,wBAAwB,GAAG,MAAM,CAElF"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSubscribed = isSubscribed;
4
+ exports.getActiveEntitlements = getActiveEntitlements;
5
+ exports.willRenew = willRenew;
6
+ exports.getExpirationDate = getExpirationDate;
7
+ exports.isInTrialPeriod = isInTrialPeriod;
8
+ exports.isInGracePeriod = isInGracePeriod;
9
+ exports.hasBillingIssue = hasBillingIssue;
10
+ exports.getProductIdentifier = getProductIdentifier;
11
+ function isSubscribed(customerInfo) {
12
+ return Object.keys(customerInfo.entitlements.active).length > 0;
13
+ }
14
+ function getActiveEntitlements(customerInfo) {
15
+ return Object.keys(customerInfo.entitlements.active);
16
+ }
17
+ function willRenew(entitlement) {
18
+ return entitlement.willRenew;
19
+ }
20
+ function getExpirationDate(entitlement) {
21
+ return entitlement.expirationDate ? new Date(entitlement.expirationDate) : null;
22
+ }
23
+ function isInTrialPeriod(entitlement) {
24
+ return entitlement.periodType === 'TRIAL';
25
+ }
26
+ function isInGracePeriod(entitlement) {
27
+ return entitlement.periodType === 'INTRO';
28
+ }
29
+ function hasBillingIssue(entitlement) {
30
+ return entitlement.billingIssueDetectedAt !== null;
31
+ }
32
+ function getProductIdentifier(entitlement) {
33
+ return entitlement.productIdentifier;
34
+ }
@@ -0,0 +1,13 @@
1
+ import type { CustomerInfo, PurchasesEntitlementInfos, PurchasesEntitlementInfo } from 'react-native-purchases';
2
+ export type { CustomerInfo, PurchasesEntitlementInfos, PurchasesEntitlementInfo };
3
+ export interface EntitlementCheckResult {
4
+ hasEntitlement: boolean;
5
+ entitlementInfo: PurchasesEntitlementInfo | null;
6
+ }
7
+ export interface CustomerInfoState {
8
+ customerInfo: CustomerInfo | null;
9
+ isLoading: boolean;
10
+ error: Error | null;
11
+ lastUpdated: number;
12
+ }
13
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/entitlements/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAGhC,YAAY,EACV,YAAY,EACZ,yBAAyB,EACzB,wBAAwB,EACzB,CAAC;AAEF,MAAM,WAAW,sBAAsB;IACrC,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,wBAAwB,GAAG,IAAI,CAAC;CAClD;AAED,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ import type { PurchasesOffering } from '../offerings/types';
2
+ export declare function useCurrentOffering(): {
3
+ offering: PurchasesOffering | null;
4
+ packages: import("@revenuecat/purchases-typescript-internal/dist/offerings").PurchasesPackage[];
5
+ monthlyPackage: import("@revenuecat/purchases-typescript-internal/dist/offerings").PurchasesPackage | null;
6
+ annualPackage: import("@revenuecat/purchases-typescript-internal/dist/offerings").PurchasesPackage | null;
7
+ lifetimePackage: import("@revenuecat/purchases-typescript-internal/dist/offerings").PurchasesPackage | null;
8
+ isLoading: boolean;
9
+ error: Error | null;
10
+ };
11
+ //# sourceMappingURL=useCurrentOffering.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCurrentOffering.d.ts","sourceRoot":"","sources":["../../src/hooks/useCurrentOffering.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,wBAAgB,kBAAkB;;;;;;;;EA6CjC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCurrentOffering = useCurrentOffering;
4
+ const react_1 = require("react");
5
+ const OfferingsManager_1 = require("../offerings/OfferingsManager");
6
+ function useCurrentOffering() {
7
+ const [offering, setOffering] = (0, react_1.useState)(null);
8
+ const [isLoading, setIsLoading] = (0, react_1.useState)(true);
9
+ const [error, setError] = (0, react_1.useState)(null);
10
+ (0, react_1.useEffect)(() => {
11
+ let mounted = true;
12
+ async function fetchCurrentOffering() {
13
+ try {
14
+ setIsLoading(true);
15
+ setError(null);
16
+ const result = await OfferingsManager_1.offeringsManager.getCurrentOffering();
17
+ if (mounted) {
18
+ setOffering(result);
19
+ }
20
+ }
21
+ catch (err) {
22
+ if (mounted) {
23
+ setError(err instanceof Error ? err : new Error('Failed to fetch current offering'));
24
+ }
25
+ }
26
+ finally {
27
+ if (mounted) {
28
+ setIsLoading(false);
29
+ }
30
+ }
31
+ }
32
+ fetchCurrentOffering();
33
+ return () => {
34
+ mounted = false;
35
+ };
36
+ }, []);
37
+ return {
38
+ offering,
39
+ packages: offering?.availablePackages || [],
40
+ monthlyPackage: offering?.monthly || null,
41
+ annualPackage: offering?.annual || null,
42
+ lifetimePackage: offering?.lifetime || null,
43
+ isLoading,
44
+ error,
45
+ };
46
+ }
@@ -0,0 +1,8 @@
1
+ import type { CustomerInfo } from '../entitlements/types';
2
+ export declare function useCustomerInfo(): {
3
+ customerInfo: CustomerInfo | null;
4
+ isLoading: boolean;
5
+ error: Error | null;
6
+ refetch: () => Promise<void>;
7
+ };
8
+ //# sourceMappingURL=useCustomerInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCustomerInfo.d.ts","sourceRoot":"","sources":["../../src/hooks/useCustomerInfo.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG1D,wBAAgB,eAAe;;;;;EA+B9B"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCustomerInfo = useCustomerInfo;
4
+ const react_1 = require("react");
5
+ const CustomerInfoManager_1 = require("../entitlements/CustomerInfoManager");
6
+ function useCustomerInfo() {
7
+ const [customerInfo, setCustomerInfo] = (0, react_1.useState)(null);
8
+ const [isLoading, setIsLoading] = (0, react_1.useState)(true);
9
+ const [error, setError] = (0, react_1.useState)(null);
10
+ const fetchCustomerInfo = (0, react_1.useCallback)(async (forceRefresh = false) => {
11
+ try {
12
+ setIsLoading(true);
13
+ setError(null);
14
+ const info = await CustomerInfoManager_1.customerInfoManager.getCustomerInfo(forceRefresh);
15
+ setCustomerInfo(info);
16
+ }
17
+ catch (err) {
18
+ setError(err instanceof Error ? err : new Error('Failed to fetch customer info'));
19
+ }
20
+ finally {
21
+ setIsLoading(false);
22
+ }
23
+ }, []);
24
+ (0, react_1.useEffect)(() => {
25
+ fetchCustomerInfo();
26
+ }, [fetchCustomerInfo]);
27
+ const refetch = () => fetchCustomerInfo(true);
28
+ return {
29
+ customerInfo,
30
+ isLoading,
31
+ error,
32
+ refetch,
33
+ };
34
+ }
@@ -0,0 +1,10 @@
1
+ import type { PurchasesEntitlementInfo } from '../entitlements/types';
2
+ export declare function useEntitlement(entitlementId: string): {
3
+ hasEntitlement: boolean;
4
+ entitlementInfo: PurchasesEntitlementInfo | null;
5
+ isActive: boolean;
6
+ expirationDate: string | null;
7
+ isLoading: boolean;
8
+ error: Error | null;
9
+ };
10
+ //# sourceMappingURL=useEntitlement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEntitlement.d.ts","sourceRoot":"","sources":["../../src/hooks/useEntitlement.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAGtE,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM;;;;;;;EA+CnD"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useEntitlement = useEntitlement;
4
+ const react_1 = require("react");
5
+ const CustomerInfoManager_1 = require("../entitlements/CustomerInfoManager");
6
+ function useEntitlement(entitlementId) {
7
+ const [hasEntitlement, setHasEntitlement] = (0, react_1.useState)(false);
8
+ const [entitlementInfo, setEntitlementInfo] = (0, react_1.useState)(null);
9
+ const [isLoading, setIsLoading] = (0, react_1.useState)(true);
10
+ const [error, setError] = (0, react_1.useState)(null);
11
+ (0, react_1.useEffect)(() => {
12
+ let mounted = true;
13
+ async function checkEntitlement() {
14
+ try {
15
+ setIsLoading(true);
16
+ setError(null);
17
+ const hasAccess = await CustomerInfoManager_1.customerInfoManager.hasEntitlement(entitlementId);
18
+ const info = await CustomerInfoManager_1.customerInfoManager.getEntitlement(entitlementId);
19
+ if (mounted) {
20
+ setHasEntitlement(hasAccess);
21
+ setEntitlementInfo(info);
22
+ }
23
+ }
24
+ catch (err) {
25
+ if (mounted) {
26
+ setError(err instanceof Error ? err : new Error('Failed to check entitlement'));
27
+ }
28
+ }
29
+ finally {
30
+ if (mounted) {
31
+ setIsLoading(false);
32
+ }
33
+ }
34
+ }
35
+ checkEntitlement();
36
+ return () => {
37
+ mounted = false;
38
+ };
39
+ }, [entitlementId]);
40
+ return {
41
+ hasEntitlement,
42
+ entitlementInfo,
43
+ isActive: entitlementInfo?.isActive || false,
44
+ expirationDate: entitlementInfo?.expirationDate || null,
45
+ isLoading,
46
+ error,
47
+ };
48
+ }
@@ -0,0 +1,9 @@
1
+ import type { PurchasesOfferings } from '../offerings/types';
2
+ export declare function useOfferings(): {
3
+ offerings: PurchasesOfferings | null;
4
+ currentOffering: import("@revenuecat/purchases-typescript-internal/dist/offerings").PurchasesOffering | null;
5
+ isLoading: boolean;
6
+ error: Error | null;
7
+ refetch: () => Promise<void>;
8
+ };
9
+ //# sourceMappingURL=useOfferings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOfferings.d.ts","sourceRoot":"","sources":["../../src/hooks/useOfferings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAG7D,wBAAgB,YAAY;;;;;;EAwD3B"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useOfferings = useOfferings;
4
+ const react_1 = require("react");
5
+ const OfferingsManager_1 = require("../offerings/OfferingsManager");
6
+ function useOfferings() {
7
+ const [offerings, setOfferings] = (0, react_1.useState)(null);
8
+ const [isLoading, setIsLoading] = (0, react_1.useState)(true);
9
+ const [error, setError] = (0, react_1.useState)(null);
10
+ (0, react_1.useEffect)(() => {
11
+ let mounted = true;
12
+ async function fetchOfferings() {
13
+ try {
14
+ setIsLoading(true);
15
+ setError(null);
16
+ const result = await OfferingsManager_1.offeringsManager.getOfferings();
17
+ if (mounted) {
18
+ setOfferings(result);
19
+ }
20
+ }
21
+ catch (err) {
22
+ if (mounted) {
23
+ setError(err instanceof Error ? err : new Error('Failed to fetch offerings'));
24
+ }
25
+ }
26
+ finally {
27
+ if (mounted) {
28
+ setIsLoading(false);
29
+ }
30
+ }
31
+ }
32
+ fetchOfferings();
33
+ return () => {
34
+ mounted = false;
35
+ };
36
+ }, []);
37
+ const refetch = async () => {
38
+ try {
39
+ setIsLoading(true);
40
+ setError(null);
41
+ const result = await OfferingsManager_1.offeringsManager.getOfferings(true);
42
+ setOfferings(result);
43
+ }
44
+ catch (err) {
45
+ setError(err instanceof Error ? err : new Error('Failed to fetch offerings'));
46
+ }
47
+ finally {
48
+ setIsLoading(false);
49
+ }
50
+ };
51
+ return {
52
+ offerings,
53
+ currentOffering: offerings?.current || null,
54
+ isLoading,
55
+ error,
56
+ refetch,
57
+ };
58
+ }
@@ -0,0 +1,6 @@
1
+ import type { PaywallOptions, PaywallResult } from '../paywall/types';
2
+ export declare function usePaywall(): {
3
+ presentIfNeeded: (entitlementId: string, options?: PaywallOptions) => Promise<PaywallResult>;
4
+ present: (options?: PaywallOptions) => Promise<PaywallResult>;
5
+ };
6
+ //# sourceMappingURL=usePaywall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePaywall.d.ts","sourceRoot":"","sources":["../../src/hooks/usePaywall.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtE,wBAAgB,UAAU;qCAKA,MAAM,YAAY,cAAc,KAAG,OAAO,CAAC,aAAa,CAAC;wBAU9D,cAAc,KAAG,OAAO,CAAC,aAAa,CAAC;EAU3D"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePaywall = usePaywall;
4
+ const react_1 = require("react");
5
+ const PaywallController_1 = require("../paywall/PaywallController");
6
+ function usePaywall() {
7
+ /**
8
+ * Present paywall if user lacks entitlement
9
+ */
10
+ const presentIfNeeded = (0, react_1.useCallback)(async (entitlementId, options) => {
11
+ return PaywallController_1.paywallController.presentPaywallIfNeeded(entitlementId, options);
12
+ }, []);
13
+ /**
14
+ * Present paywall unconditionally
15
+ */
16
+ const present = (0, react_1.useCallback)(async (options) => {
17
+ return PaywallController_1.paywallController.presentPaywall(options);
18
+ }, []);
19
+ return {
20
+ presentIfNeeded,
21
+ present,
22
+ };
23
+ }
@@ -0,0 +1,14 @@
1
+ import type { PurchasesPackage, CustomerInfo } from 'react-native-purchases';
2
+ import { PurchaseState, type PurchaseError } from '../purchase/types';
3
+ export declare function usePurchase(): {
4
+ purchase: (pkg: PurchasesPackage) => Promise<import("../purchase/types").PurchaseResult>;
5
+ reset: () => void;
6
+ state: PurchaseState;
7
+ isPurchasing: boolean;
8
+ isSuccess: boolean;
9
+ isError: boolean;
10
+ isCancelled: boolean;
11
+ error: PurchaseError | null;
12
+ customerInfo: CustomerInfo | null;
13
+ };
14
+ //# sourceMappingURL=usePurchase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePurchase.d.ts","sourceRoot":"","sources":["../../src/hooks/usePurchase.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE7E,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEtE,wBAAgB,WAAW;oBAKgB,gBAAgB;;;;;;;;;EA0C1D"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePurchase = usePurchase;
4
+ const react_1 = require("react");
5
+ const PurchaseManager_1 = require("../purchase/PurchaseManager");
6
+ const types_1 = require("../purchase/types");
7
+ function usePurchase() {
8
+ const [state, setState] = (0, react_1.useState)(types_1.PurchaseState.IDLE);
9
+ const [error, setError] = (0, react_1.useState)(null);
10
+ const [customerInfo, setCustomerInfo] = (0, react_1.useState)(null);
11
+ const purchase = (0, react_1.useCallback)(async (pkg) => {
12
+ try {
13
+ setState(types_1.PurchaseState.PURCHASING);
14
+ setError(null);
15
+ const result = await PurchaseManager_1.purchaseManager.purchasePackage(pkg);
16
+ setState(types_1.PurchaseState.SUCCESS);
17
+ setCustomerInfo(result.customerInfo);
18
+ return result;
19
+ }
20
+ catch (err) {
21
+ const purchaseError = err;
22
+ if (purchaseError.userCancelled) {
23
+ setState(types_1.PurchaseState.CANCELLED);
24
+ }
25
+ else {
26
+ setState(types_1.PurchaseState.ERROR);
27
+ setError(purchaseError);
28
+ }
29
+ throw purchaseError;
30
+ }
31
+ }, []);
32
+ const reset = (0, react_1.useCallback)(() => {
33
+ setState(types_1.PurchaseState.IDLE);
34
+ setError(null);
35
+ setCustomerInfo(null);
36
+ }, []);
37
+ return {
38
+ purchase,
39
+ reset,
40
+ state,
41
+ isPurchasing: state === types_1.PurchaseState.PURCHASING,
42
+ isSuccess: state === types_1.PurchaseState.SUCCESS,
43
+ isError: state === types_1.PurchaseState.ERROR,
44
+ isCancelled: state === types_1.PurchaseState.CANCELLED,
45
+ error,
46
+ customerInfo,
47
+ };
48
+ }
@@ -0,0 +1,14 @@
1
+ import type { CustomerInfo } from 'react-native-purchases';
2
+ import { RestoreState, type RestoreError } from '../restore/types';
3
+ export declare function useRestorePurchases(): {
4
+ restore: () => Promise<import("../restore/types").RestoreResult>;
5
+ reset: () => void;
6
+ state: RestoreState;
7
+ isRestoring: boolean;
8
+ isSuccess: boolean;
9
+ isError: boolean;
10
+ noPurchases: boolean;
11
+ error: RestoreError | null;
12
+ customerInfo: CustomerInfo | null;
13
+ };
14
+ //# sourceMappingURL=useRestorePurchases.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRestorePurchases.d.ts","sourceRoot":"","sources":["../../src/hooks/useRestorePurchases.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEnE,wBAAgB,mBAAmB;;;;;;;;;;EA6ClC"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useRestorePurchases = useRestorePurchases;
4
+ const react_1 = require("react");
5
+ const RestoreManager_1 = require("../restore/RestoreManager");
6
+ const types_1 = require("../restore/types");
7
+ function useRestorePurchases() {
8
+ const [state, setState] = (0, react_1.useState)(types_1.RestoreState.IDLE);
9
+ const [error, setError] = (0, react_1.useState)(null);
10
+ const [customerInfo, setCustomerInfo] = (0, react_1.useState)(null);
11
+ const restore = (0, react_1.useCallback)(async () => {
12
+ try {
13
+ setState(types_1.RestoreState.RESTORING);
14
+ setError(null);
15
+ const result = await RestoreManager_1.restoreManager.restorePurchases();
16
+ if (result.entitlementsRestored) {
17
+ setState(types_1.RestoreState.SUCCESS);
18
+ setCustomerInfo(result.customerInfo);
19
+ }
20
+ else {
21
+ setState(types_1.RestoreState.NO_PURCHASES);
22
+ setCustomerInfo(result.customerInfo);
23
+ }
24
+ return result;
25
+ }
26
+ catch (err) {
27
+ setState(types_1.RestoreState.ERROR);
28
+ setError(err);
29
+ throw err;
30
+ }
31
+ }, []);
32
+ const reset = (0, react_1.useCallback)(() => {
33
+ setState(types_1.RestoreState.IDLE);
34
+ setError(null);
35
+ setCustomerInfo(null);
36
+ }, []);
37
+ return {
38
+ restore,
39
+ reset,
40
+ state,
41
+ isRestoring: state === types_1.RestoreState.RESTORING,
42
+ isSuccess: state === types_1.RestoreState.SUCCESS,
43
+ isError: state === types_1.RestoreState.ERROR,
44
+ noPurchases: state === types_1.RestoreState.NO_PURCHASES,
45
+ error,
46
+ customerInfo,
47
+ };
48
+ }