@umituz/react-native-subscription 2.12.16 → 2.12.18

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 (48) hide show
  1. package/package.json +14 -7
  2. package/src/application/ports/ISubscriptionRepository.ts +1 -1
  3. package/src/application/ports/ISubscriptionService.ts +1 -1
  4. package/src/domain/value-objects/SubscriptionConfig.ts +1 -1
  5. package/src/domains/paywall/components/CreditCard.tsx +5 -2
  6. package/src/domains/paywall/components/FeatureList.tsx +1 -1
  7. package/src/domains/paywall/components/PaywallModal.tsx +7 -3
  8. package/src/domains/paywall/components/PaywallTabBar.tsx +1 -1
  9. package/src/domains/paywall/components/PlanCard.tsx +3 -1
  10. package/src/domains/paywall/entities/types.ts +1 -0
  11. package/src/index.ts +55 -53
  12. package/src/infrastructure/repositories/CreditsRepository.ts +3 -3
  13. package/src/infrastructure/repositories/CreditsRepositoryProvider.ts +2 -2
  14. package/src/infrastructure/services/ActivationHandler.ts +3 -3
  15. package/src/infrastructure/services/CreditsInitializer.ts +1 -1
  16. package/src/infrastructure/services/SubscriptionService.ts +6 -6
  17. package/src/presentation/components/details/PremiumDetailsCard.tsx +19 -48
  18. package/src/presentation/components/details/PremiumDetailsCardTypes.ts +5 -3
  19. package/src/presentation/components/details/PremiumStatusBadge.tsx +9 -9
  20. package/src/presentation/hooks/useCreditChecker.ts +3 -3
  21. package/src/presentation/hooks/useCredits.ts +2 -2
  22. package/src/presentation/hooks/useDeductCredit.ts +2 -2
  23. package/src/presentation/hooks/useDevTestCallbacks.ts +143 -0
  24. package/src/presentation/hooks/usePremiumWithConfig.ts +2 -2
  25. package/src/presentation/hooks/useSubscription.ts +3 -3
  26. package/src/presentation/hooks/useSubscriptionDetails.ts +2 -2
  27. package/src/presentation/hooks/useUserTier.ts +2 -2
  28. package/src/presentation/hooks/useUserTierWithRepository.ts +1 -1
  29. package/src/presentation/screens/SubscriptionDetailScreen.tsx +12 -11
  30. package/src/presentation/screens/components/CreditItem.tsx +8 -11
  31. package/src/presentation/screens/components/SubscriptionActions.tsx +10 -22
  32. package/src/presentation/screens/components/SubscriptionHeader.tsx +22 -22
  33. package/src/revenuecat/infrastructure/handlers/PackageHandler.ts +2 -2
  34. package/src/revenuecat/infrastructure/managers/SubscriptionManager.ts +7 -7
  35. package/src/revenuecat/infrastructure/services/CustomerInfoListenerManager.ts +2 -2
  36. package/src/revenuecat/infrastructure/services/PurchaseHandler.ts +5 -5
  37. package/src/revenuecat/infrastructure/services/RestoreHandler.ts +5 -5
  38. package/src/revenuecat/infrastructure/services/RevenueCatInitializer.ts +4 -4
  39. package/src/revenuecat/infrastructure/services/RevenueCatService.ts +3 -3
  40. package/src/revenuecat/infrastructure/services/ServiceStateManager.ts +2 -2
  41. package/src/revenuecat/infrastructure/utils/ApiKeyResolver.ts +1 -1
  42. package/src/revenuecat/infrastructure/utils/ExpirationDateCalculator.ts +1 -1
  43. package/src/revenuecat/infrastructure/utils/PremiumStatusSyncer.ts +2 -2
  44. package/src/revenuecat/presentation/hooks/useInitializeSubscription.ts +1 -1
  45. package/src/revenuecat/presentation/hooks/usePurchasePackage.ts +1 -1
  46. package/src/revenuecat/presentation/hooks/useRestorePurchase.ts +1 -1
  47. package/src/revenuecat/presentation/hooks/useRevenueCat.ts +2 -2
  48. package/src/revenuecat/presentation/hooks/useSubscriptionPackages.ts +1 -1
@@ -4,8 +4,8 @@
4
4
  */
5
5
 
6
6
  import React from "react";
7
- import { View, Text, StyleSheet } from "react-native";
8
- import { useAppDesignTokens } from "@umituz/react-native-design-system";
7
+ import { View, StyleSheet } from "react-native";
8
+ import { useAppDesignTokens, AtomicText } from "@umituz/react-native-design-system";
9
9
  import {
10
10
  PremiumStatusBadge,
11
11
  type SubscriptionStatusType,
@@ -13,13 +13,14 @@ import {
13
13
 
14
14
  interface SubscriptionHeaderTranslations {
15
15
  title: string;
16
- statusLabel?: string;
17
- statusActive?: string;
18
- statusExpired?: string;
19
- statusFree?: string;
20
- expiresLabel?: string;
21
- purchasedLabel?: string;
22
- lifetimeLabel?: string;
16
+ statusLabel: string;
17
+ statusActive: string;
18
+ statusExpired: string;
19
+ statusFree: string;
20
+ statusCanceled: string;
21
+ expiresLabel: string;
22
+ purchasedLabel: string;
23
+ lifetimeLabel: string;
23
24
  }
24
25
 
25
26
  interface SubscriptionHeaderProps {
@@ -50,14 +51,15 @@ export const SubscriptionHeader: React.FC<SubscriptionHeaderProps> = ({
50
51
  return (
51
52
  <View style={[styles.container, { backgroundColor: tokens.colors.surface }]}>
52
53
  <View style={styles.header}>
53
- <Text style={[styles.title, { color: tokens.colors.textPrimary }]}>
54
+ <AtomicText type="headlineSmall" style={[styles.title, { color: tokens.colors.textPrimary }]}>
54
55
  {translations.title}
55
- </Text>
56
+ </AtomicText>
56
57
  <PremiumStatusBadge
57
58
  status={statusType}
58
59
  activeLabel={translations.statusActive}
59
60
  expiredLabel={translations.statusExpired}
60
61
  noneLabel={translations.statusFree}
62
+ canceledLabel={translations.statusCanceled}
61
63
  />
62
64
  </View>
63
65
 
@@ -65,15 +67,15 @@ export const SubscriptionHeader: React.FC<SubscriptionHeaderProps> = ({
65
67
  <View style={styles.details}>
66
68
  {isLifetime ? (
67
69
  <DetailRow
68
- label={translations.statusLabel || "Subscription"}
69
- value={translations.lifetimeLabel || "Lifetime Access"}
70
+ label={translations.statusLabel}
71
+ value={translations.lifetimeLabel}
70
72
  tokens={tokens}
71
73
  />
72
74
  ) : (
73
75
  <>
74
76
  {expirationDate && (
75
77
  <DetailRow
76
- label={translations.expiresLabel || "Expires"}
78
+ label={translations.expiresLabel}
77
79
  value={expirationDate}
78
80
  highlight={showExpiring}
79
81
  tokens={tokens}
@@ -81,7 +83,7 @@ export const SubscriptionHeader: React.FC<SubscriptionHeaderProps> = ({
81
83
  )}
82
84
  {purchaseDate && (
83
85
  <DetailRow
84
- label={translations.purchasedLabel || "Purchased"}
86
+ label={translations.purchasedLabel}
85
87
  value={purchaseDate}
86
88
  tokens={tokens}
87
89
  />
@@ -108,17 +110,18 @@ const DetailRow: React.FC<DetailRowProps> = ({
108
110
  tokens,
109
111
  }) => (
110
112
  <View style={styles.row}>
111
- <Text style={[styles.label, { color: tokens.colors.textSecondary }]}>
113
+ <AtomicText type="bodyMedium" style={[styles.label, { color: tokens.colors.textSecondary }]}>
112
114
  {label}
113
- </Text>
114
- <Text
115
+ </AtomicText>
116
+ <AtomicText
117
+ type="bodyMedium"
115
118
  style={[
116
119
  styles.value,
117
120
  { color: highlight ? tokens.colors.warning : tokens.colors.textPrimary },
118
121
  ]}
119
122
  >
120
123
  {value}
121
- </Text>
124
+ </AtomicText>
122
125
  </View>
123
126
  );
124
127
 
@@ -134,7 +137,6 @@ const styles = StyleSheet.create({
134
137
  alignItems: "center",
135
138
  },
136
139
  title: {
137
- fontSize: 24,
138
140
  fontWeight: "700",
139
141
  },
140
142
  details: {
@@ -147,10 +149,8 @@ const styles = StyleSheet.create({
147
149
  alignItems: "center",
148
150
  },
149
151
  label: {
150
- fontSize: 15,
151
152
  },
152
153
  value: {
153
- fontSize: 15,
154
154
  fontWeight: "600",
155
155
  },
156
156
  });
@@ -4,8 +4,8 @@
4
4
  */
5
5
 
6
6
  import type { PurchasesPackage } from "react-native-purchases";
7
- import type { IRevenueCatService } from "../../application/ports/IRevenueCatService";
8
- import { getPremiumEntitlement } from "../../domain/types/RevenueCatTypes";
7
+ import type { IRevenueCatService } from "@revenuecat/application/ports/IRevenueCatService";
8
+ import { getPremiumEntitlement } from "@revenuecat/domain/types/RevenueCatTypes";
9
9
  import {
10
10
  trackPackageError,
11
11
  addPackageBreadcrumb,
@@ -5,13 +5,13 @@
5
5
  */
6
6
 
7
7
  import type { PurchasesPackage } from "react-native-purchases";
8
- import type { RevenueCatConfig } from "../../domain/value-objects/RevenueCatConfig";
9
- import type { IRevenueCatService } from "../../application/ports/IRevenueCatService";
10
- import { initializeRevenueCatService, getRevenueCatService } from "../services/RevenueCatService";
11
- import { UserIdProvider } from "../utils/UserIdProvider";
12
- import { InitializationCache } from "../utils/InitializationCache";
13
- import { PackageHandler } from "../handlers/PackageHandler";
14
- import type { PremiumStatus } from "../handlers/PackageHandler";
8
+ import type { RevenueCatConfig } from "@revenuecat/domain/value-objects/RevenueCatConfig";
9
+ import type { IRevenueCatService } from "@revenuecat/application/ports/IRevenueCatService";
10
+ import { initializeRevenueCatService, getRevenueCatService } from "@revenuecat/infrastructure/services/RevenueCatService";
11
+ import { UserIdProvider } from "@revenuecat/infrastructure/utils/UserIdProvider";
12
+ import { InitializationCache } from "@revenuecat/infrastructure/utils/InitializationCache";
13
+ import { PackageHandler } from "@revenuecat/infrastructure/handlers/PackageHandler";
14
+ import type { PremiumStatus } from "@revenuecat/infrastructure/handlers/PackageHandler";
15
15
  import {
16
16
  trackPackageError,
17
17
  addPackageBreadcrumb,
@@ -7,8 +7,8 @@ import Purchases, {
7
7
  type CustomerInfo,
8
8
  type CustomerInfoUpdateListener,
9
9
  } from "react-native-purchases";
10
- import type { RevenueCatConfig } from "../../domain/value-objects/RevenueCatConfig";
11
- import { syncPremiumStatus } from "../utils/PremiumStatusSyncer";
10
+ import type { RevenueCatConfig } from "@revenuecat/domain/value-objects/RevenueCatConfig";
11
+ import { syncPremiumStatus } from "@revenuecat/infrastructure/utils/PremiumStatusSyncer";
12
12
  import { addPackageBreadcrumb } from "@umituz/react-native-sentry";
13
13
 
14
14
  export class CustomerInfoListenerManager {
@@ -4,20 +4,20 @@
4
4
  */
5
5
 
6
6
  import Purchases, { type PurchasesPackage } from "react-native-purchases";
7
- import type { PurchaseResult } from "../../application/ports/IRevenueCatService";
7
+ import type { PurchaseResult } from "@revenuecat/application/ports/IRevenueCatService";
8
8
  import {
9
9
  RevenueCatPurchaseError,
10
10
  RevenueCatInitializationError,
11
- } from "../../domain/errors/RevenueCatError";
12
- import type { RevenueCatConfig } from "../../domain/value-objects/RevenueCatConfig";
11
+ } from "@revenuecat/domain/errors/RevenueCatError";
12
+ import type { RevenueCatConfig } from "@revenuecat/domain/value-objects/RevenueCatConfig";
13
13
  import {
14
14
  isUserCancelledError,
15
15
  getErrorMessage,
16
- } from "../../domain/types/RevenueCatTypes";
16
+ } from "@revenuecat/domain/types/RevenueCatTypes";
17
17
  import {
18
18
  syncPremiumStatus,
19
19
  notifyPurchaseCompleted,
20
- } from "../utils/PremiumStatusSyncer";
20
+ } from "@revenuecat/infrastructure/utils/PremiumStatusSyncer";
21
21
  import {
22
22
  trackPackageError,
23
23
  addPackageBreadcrumb,
@@ -4,17 +4,17 @@
4
4
  */
5
5
 
6
6
  import Purchases from "react-native-purchases";
7
- import type { RestoreResult } from "../../application/ports/IRevenueCatService";
7
+ import type { RestoreResult } from "@revenuecat/application/ports/IRevenueCatService";
8
8
  import {
9
9
  RevenueCatRestoreError,
10
10
  RevenueCatInitializationError,
11
- } from "../../domain/errors/RevenueCatError";
12
- import type { RevenueCatConfig } from "../../domain/value-objects/RevenueCatConfig";
13
- import { getErrorMessage } from "../../domain/types/RevenueCatTypes";
11
+ } from "@revenuecat/domain/errors/RevenueCatError";
12
+ import type { RevenueCatConfig } from "@revenuecat/domain/value-objects/RevenueCatConfig";
13
+ import { getErrorMessage } from "@revenuecat/domain/types/RevenueCatTypes";
14
14
  import {
15
15
  syncPremiumStatus,
16
16
  notifyRestoreCompleted,
17
- } from "../utils/PremiumStatusSyncer";
17
+ } from "@revenuecat/infrastructure/utils/PremiumStatusSyncer";
18
18
  import {
19
19
  trackPackageError,
20
20
  addPackageBreadcrumb,
@@ -4,10 +4,10 @@
4
4
  */
5
5
 
6
6
  import Purchases from "react-native-purchases";
7
- import type { InitializeResult } from "../../application/ports/IRevenueCatService";
8
- import type { RevenueCatConfig } from "../../domain/value-objects/RevenueCatConfig";
9
- import { getErrorMessage } from "../../domain/types/RevenueCatTypes";
10
- import { resolveApiKey } from "../utils/ApiKeyResolver";
7
+ import type { InitializeResult } from "@revenuecat/application/ports/IRevenueCatService";
8
+ import type { RevenueCatConfig } from "@revenuecat/domain/value-objects/RevenueCatConfig";
9
+ import { getErrorMessage } from "@revenuecat/domain/types/RevenueCatTypes";
10
+ import { resolveApiKey } from "@revenuecat/infrastructure/utils/ApiKeyResolver";
11
11
  import {
12
12
  trackPackageError,
13
13
  addPackageBreadcrumb,
@@ -10,9 +10,9 @@ import type {
10
10
  InitializeResult,
11
11
  PurchaseResult,
12
12
  RestoreResult,
13
- } from "../../application/ports/IRevenueCatService";
14
- import type { RevenueCatConfig } from "../../domain/value-objects/RevenueCatConfig";
15
- import { resolveApiKey } from "../utils/ApiKeyResolver";
13
+ } from "@revenuecat/application/ports/IRevenueCatService";
14
+ import type { RevenueCatConfig } from "@revenuecat/domain/value-objects/RevenueCatConfig";
15
+ import { resolveApiKey } from "@revenuecat/infrastructure/utils/ApiKeyResolver";
16
16
  import { initializeSDK } from "./RevenueCatInitializer";
17
17
  import { fetchOfferings } from "./OfferingsFetcher";
18
18
  import { handlePurchase } from "./PurchaseHandler";
@@ -3,8 +3,8 @@
3
3
  * Manages RevenueCat service state
4
4
  */
5
5
 
6
- import type { RevenueCatConfig } from "../../domain/value-objects/RevenueCatConfig";
7
- import { isExpoGo, isDevelopment } from "../utils/ExpoGoDetector";
6
+ import type { RevenueCatConfig } from "@revenuecat/domain/value-objects/RevenueCatConfig";
7
+ import { isExpoGo, isDevelopment } from "@revenuecat/infrastructure/utils/ExpoGoDetector";
8
8
 
9
9
  export class ServiceStateManager {
10
10
  private isInitializedFlag: boolean = false;
@@ -4,7 +4,7 @@
4
4
  * NOTE: Main app is responsible for resolving platform-specific keys
5
5
  */
6
6
 
7
- import type { RevenueCatConfig } from "../../domain/value-objects/RevenueCatConfig";
7
+ import type { RevenueCatConfig } from "@revenuecat/domain/value-objects/RevenueCatConfig";
8
8
  import { isExpoGo, isProductionBuild } from "./ExpoGoDetector";
9
9
 
10
10
  /**
@@ -3,7 +3,7 @@
3
3
  * Handles RevenueCat expiration date extraction
4
4
  */
5
5
 
6
- import type { RevenueCatEntitlement } from "../../domain/types/RevenueCatTypes";
6
+ import type { RevenueCatEntitlement } from "@revenuecat/domain/types/RevenueCatTypes";
7
7
 
8
8
  export function getExpirationDate(
9
9
  entitlement: RevenueCatEntitlement | null
@@ -4,8 +4,8 @@
4
4
  */
5
5
 
6
6
  import type { CustomerInfo } from "react-native-purchases";
7
- import type { RevenueCatConfig } from "../../domain/value-objects/RevenueCatConfig";
8
- import { getPremiumEntitlement } from "../../domain/types/RevenueCatTypes";
7
+ import type { RevenueCatConfig } from "@revenuecat/domain/value-objects/RevenueCatConfig";
8
+ import { getPremiumEntitlement } from "@revenuecat/domain/types/RevenueCatTypes";
9
9
  import { getExpirationDate } from "./ExpirationDateCalculator";
10
10
  import {
11
11
  trackPackageError,
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { useMutation, useQueryClient } from "@tanstack/react-query";
7
- import { SubscriptionManager } from "../../infrastructure/managers/SubscriptionManager";
7
+ import { SubscriptionManager } from "@revenuecat/infrastructure/managers/SubscriptionManager";
8
8
  import {
9
9
  trackPackageError,
10
10
  addPackageBreadcrumb,
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { useMutation, useQueryClient } from "@tanstack/react-query";
7
7
  import type { PurchasesPackage } from "react-native-purchases";
8
- import { SubscriptionManager } from "../../infrastructure/managers/SubscriptionManager";
8
+ import { SubscriptionManager } from "@revenuecat/infrastructure/managers/SubscriptionManager";
9
9
  import {
10
10
  trackPackageError,
11
11
  addPackageBreadcrumb,
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { useMutation, useQueryClient } from "@tanstack/react-query";
7
- import { SubscriptionManager } from "../../infrastructure/managers/SubscriptionManager";
7
+ import { SubscriptionManager } from "@revenuecat/infrastructure/managers/SubscriptionManager";
8
8
  import {
9
9
  trackPackageError,
10
10
  addPackageBreadcrumb,
@@ -5,8 +5,8 @@
5
5
 
6
6
  import { useState, useCallback } from "react";
7
7
  import type { PurchasesOffering, PurchasesPackage } from "react-native-purchases";
8
- import { getRevenueCatService } from "../../infrastructure/services/RevenueCatService";
9
- import type { PurchaseResult, RestoreResult } from "../../application/ports/IRevenueCatService";
8
+ import { getRevenueCatService } from "@revenuecat/infrastructure/services/RevenueCatService";
9
+ import type { PurchaseResult, RestoreResult } from "@revenuecat/application/ports/IRevenueCatService";
10
10
 
11
11
  export interface UseRevenueCatResult {
12
12
  /** Current offering */
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { useQuery } from "@tanstack/react-query";
7
- import { SubscriptionManager } from "../../infrastructure/managers/SubscriptionManager";
7
+ import { SubscriptionManager } from "@revenuecat/infrastructure/managers/SubscriptionManager";
8
8
  import { addPackageBreadcrumb } from "@umituz/react-native-sentry";
9
9
  import {
10
10
  SUBSCRIPTION_QUERY_KEYS,