@umituz/react-native-subscription 2.14.99 → 2.14.101

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 (98) hide show
  1. package/README.md +211 -394
  2. package/package.json +3 -3
  3. package/src/application/README.md +46 -225
  4. package/src/application/ports/README.md +42 -97
  5. package/src/domain/README.md +36 -384
  6. package/src/domain/constants/README.md +0 -56
  7. package/src/domain/entities/README.md +43 -169
  8. package/src/domain/entities/SubscriptionStatus.ts +1 -1
  9. package/src/domain/errors/README.md +33 -287
  10. package/src/domain/value-objects/README.md +43 -179
  11. package/src/domains/README.md +50 -238
  12. package/src/domains/README.md.bak +274 -0
  13. package/src/domains/config/README.md +93 -383
  14. package/src/domains/config/domain/README.md +23 -376
  15. package/src/domains/config/domain/entities/README.md +34 -343
  16. package/src/domains/paywall/README.md +99 -369
  17. package/src/domains/paywall/components/README.md +34 -178
  18. package/src/domains/paywall/entities/README.md +34 -193
  19. package/src/domains/paywall/hooks/README.md +34 -122
  20. package/src/domains/wallet/README.md +34 -275
  21. package/src/domains/wallet/README.md.bak +209 -0
  22. package/src/domains/wallet/domain/README.md +34 -101
  23. package/src/domains/wallet/domain/entities/README.md +34 -115
  24. package/src/domains/wallet/domain/errors/README.md +34 -151
  25. package/src/domains/wallet/infrastructure/README.md +34 -89
  26. package/src/domains/wallet/presentation/components/README.md +34 -224
  27. package/src/domains/wallet/presentation/components/TransactionItem.tsx +1 -1
  28. package/src/domains/wallet/presentation/hooks/README.md +34 -248
  29. package/src/infrastructure/README.md +37 -496
  30. package/src/infrastructure/mappers/README.md +0 -13
  31. package/src/infrastructure/repositories/README.md +74 -360
  32. package/src/infrastructure/services/ActivationHandler.ts +1 -1
  33. package/src/infrastructure/services/README.md +95 -370
  34. package/src/infrastructure/services/SubscriptionService.ts +1 -1
  35. package/src/presentation/README.md +123 -408
  36. package/src/presentation/README.md.bak +172 -0
  37. package/src/presentation/components/README.md +151 -179
  38. package/src/presentation/components/README.md.bak +217 -0
  39. package/src/presentation/components/details/CreditRow.md +65 -310
  40. package/src/presentation/components/details/DetailRow.md +63 -255
  41. package/src/presentation/components/details/PremiumDetailsCard.md +65 -238
  42. package/src/presentation/components/details/PremiumStatusBadge.md +64 -239
  43. package/src/presentation/components/details/README.md +97 -447
  44. package/src/presentation/components/feedback/PaywallFeedbackModal.md +63 -287
  45. package/src/presentation/components/feedback/README.md +97 -445
  46. package/src/presentation/components/paywall/PaywallModal.md +66 -416
  47. package/src/presentation/components/paywall/README.md +50 -186
  48. package/src/presentation/components/sections/README.md +97 -466
  49. package/src/presentation/components/sections/SubscriptionSection.md +92 -244
  50. package/src/presentation/hooks/README.md +154 -741
  51. package/src/presentation/hooks/useAuthAwarePurchase.md +58 -325
  52. package/src/presentation/hooks/useAuthGate.md +61 -375
  53. package/src/presentation/hooks/useAuthSubscriptionSync.md +66 -370
  54. package/src/presentation/hooks/useCreditChecker.md +73 -378
  55. package/src/presentation/hooks/useCredits.md +74 -313
  56. package/src/presentation/hooks/useCredits.md.bak +231 -0
  57. package/src/presentation/hooks/useCreditsGate.md +66 -318
  58. package/src/presentation/hooks/useDeductCredit.md +0 -76
  59. package/src/presentation/hooks/useDeductCredit.ts +1 -1
  60. package/src/presentation/hooks/useDevTestCallbacks.md +63 -394
  61. package/src/presentation/hooks/useFeatureGate.md +105 -150
  62. package/src/presentation/hooks/useFeatureGate.md.bak +284 -0
  63. package/src/presentation/hooks/useInitializeCredits.md +64 -430
  64. package/src/presentation/hooks/usePaywall.md +61 -306
  65. package/src/presentation/hooks/usePaywallOperations.md +64 -458
  66. package/src/presentation/hooks/usePaywallVisibility.md +67 -316
  67. package/src/presentation/hooks/usePremium.md +84 -226
  68. package/src/presentation/hooks/usePremiumGate.md +60 -395
  69. package/src/presentation/hooks/usePremiumWithCredits.md +64 -401
  70. package/src/presentation/hooks/useSubscription.md +66 -422
  71. package/src/presentation/hooks/useSubscriptionDetails.md +65 -410
  72. package/src/presentation/hooks/useSubscriptionGate.md +80 -164
  73. package/src/presentation/hooks/useSubscriptionSettingsConfig.md +66 -346
  74. package/src/presentation/hooks/useSubscriptionStatus.md +66 -396
  75. package/src/presentation/hooks/useUserTier.md +63 -328
  76. package/src/presentation/hooks/useUserTierWithRepository.md +64 -424
  77. package/src/presentation/screens/README.md +48 -190
  78. package/src/presentation/types/README.md +0 -16
  79. package/src/presentation/utils/README.md +0 -21
  80. package/src/presentation/utils/subscriptionDateUtils.ts +1 -1
  81. package/src/revenuecat/README.md +99 -518
  82. package/src/revenuecat/application/README.md +35 -150
  83. package/src/revenuecat/application/ports/README.md +34 -162
  84. package/src/revenuecat/domain/README.md +42 -141
  85. package/src/revenuecat/domain/constants/README.md +34 -176
  86. package/src/revenuecat/domain/entities/README.md +34 -374
  87. package/src/revenuecat/domain/errors/README.md +47 -191
  88. package/src/revenuecat/domain/types/README.md +34 -366
  89. package/src/revenuecat/domain/value-objects/README.md +34 -434
  90. package/src/revenuecat/infrastructure/README.md +34 -43
  91. package/src/revenuecat/infrastructure/config/README.md +32 -23
  92. package/src/revenuecat/infrastructure/handlers/README.md +34 -211
  93. package/src/revenuecat/infrastructure/managers/README.md +34 -42
  94. package/src/revenuecat/infrastructure/services/README.md +35 -318
  95. package/src/revenuecat/infrastructure/utils/README.md +34 -375
  96. package/src/revenuecat/presentation/README.md +34 -176
  97. package/src/revenuecat/presentation/hooks/README.md +29 -35
  98. package/src/utils/README.md +38 -525
@@ -2,343 +2,94 @@
2
2
 
3
3
  Simple global state management for paywall visibility using external store.
4
4
 
5
- ## Import
5
+ ## Location
6
6
 
7
- ```typescript
8
- import {
9
- usePaywallVisibility,
10
- paywallControl
11
- } from '@umituz/react-native-subscription';
12
- ```
7
+ **Import Path**: `@umituz/react-native-subscription`
13
8
 
14
- ## Signature
9
+ **File**: `src/presentation/hooks/usePaywallVisibility.ts`
15
10
 
16
- ```typescript
17
- function usePaywallVisibility(): {
18
- showPaywall: boolean;
19
- setShowPaywall: (visible: boolean) => void;
20
- openPaywall: () => void;
21
- closePaywall: () => void;
22
- }
11
+ **Type**: Hook
23
12
 
24
- // Direct control (non-React contexts)
25
- paywallControl: {
26
- open: () => void;
27
- close: () => void;
28
- isOpen: () => boolean;
29
- }
30
- ```
13
+ ## Strategy
31
14
 
32
- ## Returns
15
+ ### Global Paywall State Management
33
16
 
34
- | Property | Type | Description |
35
- |----------|------|-------------|
36
- | `showPaywall` | `boolean` | Current visibility state |
37
- | `setShowPaywall` | `(visible) => void` | Set visibility state |
38
- | `openPaywall` | `() => void` | Open paywall |
39
- | `closePaywall` | `() => void` | Close paywall |
17
+ 1. **External Store**: Use Zustand or similar for global state
18
+ 2. **Visibility Control**: Simple boolean for show/hide
19
+ 3. **Global Access**: Available from any component
20
+ 4. **Direct Control**: Provide paywallControl for non-React contexts
21
+ 5. **Single Instance**: One paywall modal at app root
22
+ 6. **State Persistence**: Maintain visibility across component unmounts
40
23
 
41
- ## Basic Usage
24
+ ### Integration Points
42
25
 
43
- ```typescript
44
- function PaywallModal() {
45
- const { showPaywall, closePaywall } = usePaywallVisibility();
26
+ - **App Root**: Paywall modal should be placed at app root
27
+ - **Any Component**: Can trigger paywall from anywhere
28
+ - **Deep Links**: Can open paywall from URLs
29
+ - **Push Notifications**: Can open paywall from notifications
30
+ - **usePremium**: For conditional display based on status
46
31
 
47
- if (!showPaywall) return null;
32
+ ## Restrictions
48
33
 
49
- return (
50
- <Modal visible={showPaywall} onRequestClose={closePaywall}>
51
- <PaywallContent onClose={closePaywall} />
52
- </Modal>
53
- );
54
- }
55
- ```
34
+ ### REQUIRED
56
35
 
57
- ## Advanced Usage
36
+ - **Single Modal**: MUST place paywall modal once at app root
37
+ - **Close Handler**: MUST provide close button in paywall
38
+ - **Premium Check**: SHOULD hide paywall when user becomes premium
39
+ - **Back Handler**: SHOULD handle Android back button
58
40
 
59
- ### With App Root Setup
41
+ ### PROHIBITED
60
42
 
61
- ```typescript
62
- function App() {
63
- return (
64
- <>
65
- <YourAppNavigation />
66
- <PaywallModal />
67
- </>
68
- );
69
- }
43
+ - **NEVER** place multiple paywall modals in component tree
44
+ - **NEVER** manage visibility locally (use this hook instead)
45
+ - **DO NOT** show paywall too frequently
46
+ - **DO NOT** trap users without exit option
70
47
 
71
- function PaywallModal() {
72
- const { showPaywall, closePaywall } = usePaywallVisibility();
48
+ ### CRITICAL SAFETY
73
49
 
74
- return (
75
- <Modal visible={showPaywall} animationType="slide">
76
- <PaywallScreen onClose={closePaywall} />
77
- </Modal>
78
- );
79
- }
80
- ```
50
+ - **ALWAYS** provide close button
51
+ - **NEVER** trap users in paywall
52
+ - **MUST** handle back button on Android
53
+ - **ALWAYS** hide paywall after successful purchase
81
54
 
82
- ### With Trigger Button
55
+ ## AI Agent Guidelines
83
56
 
84
- ```typescript
85
- function PremiumFeature() {
86
- const { openPaywall } = usePaywallVisibility();
57
+ ### When Implementing Paywall Visibility
87
58
 
88
- return (
89
- <Button
90
- onPress={openPaywall}
91
- title="Upgrade to Premium"
92
- />
93
- );
94
- }
95
- ```
59
+ 1. **Always** place paywall modal once at app root
60
+ 2. **Always** provide close button
61
+ 3. **Always** use openPaywall/closePaywall functions
62
+ 4. **Always** hide paywall after successful purchase
63
+ 5. **Never** manage visibility locally in components
96
64
 
97
- ### With Direct Control (Non-React)
65
+ ### Integration Checklist
98
66
 
99
- ```typescript
100
- // In app initializer or non-React code
101
- import { paywallControl } from '@umituz/react-native-subscription';
67
+ - [ ] Import from correct path: `@umituz/react-native-subscription`
68
+ - [ ] Place paywall modal once at app root
69
+ - [ ] Use openPaywall to show paywall
70
+ - [ ] Use closePaywall to hide paywall
71
+ - [ ] Provide close button in paywall
72
+ - [ ] Handle Android back button
73
+ - [ ] Hide paywall when user becomes premium
74
+ - [ ] Test paywall opens from any component
75
+ - [ ] Test paywallControl for non-React contexts
76
+ - [ ] Test deep link integration
102
77
 
103
- function showPaywallFromDeepLink(url: URL) {
104
- if (url.pathname === '/upgrade') {
105
- paywallControl.open();
106
- }
107
- }
78
+ ### Common Patterns
108
79
 
109
- function checkAndShowPaywall() {
110
- if (!paywallControl.isOpen()) {
111
- paywallControl.open();
112
- }
113
- }
114
- ```
80
+ 1. **App Root Setup**: Single modal instance at app root
81
+ 2. **Trigger Button**: Any component can open paywall
82
+ 3. **Direct Control**: Use paywallControl in non-React code
83
+ 4. **Conditional Display**: Auto-show based on user status
84
+ 5. **History/Navigation**: Handle navigation with paywall
85
+ 6. **Timeout/Auto-Close**: Auto-close after timeout
86
+ 7. **Deep Links**: Open from URL schemes
115
87
 
116
- ### With Conditional Display
88
+ ## Related Documentation
117
89
 
118
- ```typescript
119
- function ConditionalPaywall() {
120
- const { showPaywall, openPaywall, closePaywall } = usePaywallVisibility();
121
- const { isPremium } = usePremium();
122
-
123
- useEffect(() => {
124
- // Auto-show paywall for free users on certain screens
125
- if (!isPremium && someCondition) {
126
- openPaywall();
127
- }
128
- }, [isPremium]);
129
-
130
- if (isPremium) return null; // Don't show for premium users
131
-
132
- return (
133
- <Modal visible={showPaywall}>
134
- <PaywallContent onClose={closePaywall} />
135
- </Modal>
136
- );
137
- }
138
- ```
139
-
140
- ### With History/Navigation
141
-
142
- ```typescript
143
- function PaywallWithHistory() {
144
- const { showPaywall, closePaywall, openPaywall } = usePaywallVisibility();
145
- const navigation = useNavigation();
146
-
147
- useEffect(() => {
148
- const unsubscribe = navigation.addListener('focus', () => {
149
- // Show paywall when returning to certain screens
150
- if (shouldShowPaywall()) {
151
- openPaywall();
152
- }
153
- });
154
-
155
- return unsubscribe;
156
- }, [navigation]);
157
-
158
- const handleClose = () => {
159
- closePaywall();
160
- navigation.goBack();
161
- };
162
-
163
- return (
164
- <Modal visible={showPaywall}>
165
- <PaywallContent onClose={handleClose} />
166
- </Modal>
167
- );
168
- }
169
- ```
170
-
171
- ## Examples
172
-
173
- ### Global Paywall System
174
-
175
- ```typescript
176
- // App.tsx
177
- function App() {
178
- return (
179
- <PaywallProvider>
180
- <Navigation />
181
- <GlobalPaywall />
182
- </PaywallProvider>
183
- );
184
- }
185
-
186
- // components/GlobalPaywall.tsx
187
- function GlobalPaywall() {
188
- const { showPaywall, closePaywall } = usePaywallVisibility();
189
-
190
- return (
191
- <Modal visible={showPaywall} animationType="slide">
192
- <PaywallScreen onClose={closePaywall} />
193
- </Modal>
194
- );
195
- }
196
-
197
- // Any component can trigger the paywall
198
- function UpgradeButton() {
199
- const { openPaywall } = usePaywallVisibility();
200
- return <Button onPress={openPaywall} title="Upgrade" />;
201
- }
202
- ```
203
-
204
- ### With Context Integration
205
-
206
- ```typescript
207
- function PaywallWithContext() {
208
- const { showPaywall, closePaywall, setShowPaywall } = usePaywallVisibility();
209
- const { isPremium } = usePremium();
210
-
211
- // Close paywall when user becomes premium
212
- useEffect(() => {
213
- if (isPremium && showPaywall) {
214
- setShowPaywall(false);
215
- }
216
- }, [isPremium, showPaywall]);
217
-
218
- if (isPremium) return null;
219
-
220
- return (
221
- <Modal visible={showPaywall}>
222
- <PaywallScreen onClose={closePaywall} />
223
- </Modal>
224
- );
225
- }
226
- ```
227
-
228
- ### With Timeout/Auto-Close
229
-
230
- ```typescript
231
- function TimedPaywall() {
232
- const { showPaywall, closePaywall } = usePaywallVisibility();
233
-
234
- useEffect(() => {
235
- if (!showPaywall) return;
236
-
237
- // Auto-close after 30 seconds
238
- const timer = setTimeout(() => {
239
- closePaywall();
240
- }, 30000);
241
-
242
- return () => clearTimeout(timer);
243
- }, [showPaywall, closePaywall]);
244
-
245
- return (
246
- <Modal visible={showPaywall}>
247
- <PaywallContent onClose={closePaywall} />
248
- </Modal>
249
- );
250
- }
251
- ```
252
-
253
- ### With Back Handler
254
-
255
- ```typescript
256
- function PaywallWithBackHandler() {
257
- const { showPaywall, closePaywall } = usePaywallVisibility();
258
-
259
- useBackHandler(showPaywall, () => {
260
- closePaywall();
261
- return true; // Prevent default back behavior
262
- });
263
-
264
- return (
265
- <Modal visible={showPaywall}>
266
- <PaywallContent onClose={closePaywall} />
267
- </Modal>
268
- );
269
- }
270
- ```
271
-
272
- ### From Deep Link
273
-
274
- ```typescript
275
- // Deep link handler
276
- import { paywallControl } from '@umituz/react-native-subscription';
277
- import { Linking } from 'react-native';
278
-
279
- Linking.addEventListener('url', ({ url }) => {
280
- const parsed = new URL(url);
281
-
282
- if (parsed.pathname === '/upgrade') {
283
- paywallControl.open();
284
- }
285
-
286
- if (parsed.searchParams.get('show_paywall') === 'true') {
287
- paywallControl.open();
288
- }
289
- });
290
- ```
291
-
292
- ### From Push Notification
293
-
294
- ```typescript
295
- // Push notification handler
296
- import { paywallControl } from '@umituz/react-native-subscription';
297
- import messaging from '@react-native-firebase/messaging';
298
-
299
- messaging().onNotificationOpenedApp((remoteMessage) => {
300
- if (remoteMessage.data?.type === 'paywall') {
301
- paywallControl.open();
302
- }
303
- });
304
-
305
- // Or when app is in background
306
- messaging().setBackgroundMessageHandler(async (remoteMessage) => {
307
- if (remoteMessage.data?.show_paywall) {
308
- // Store flag to show paywall when app opens
309
- AsyncStorage.setItem('pending_paywall', 'true');
310
- }
311
- });
312
-
313
- // Then in your app
314
- useEffect(() => {
315
- AsyncStorage.getItem('pending_paywall').then((value) => {
316
- if (value === 'true') {
317
- paywallControl.open();
318
- AsyncStorage.removeItem('pending_paywall');
319
- }
320
- });
321
- }, []);
322
- ```
323
-
324
- ## Best Practices
325
-
326
- 1. **Single modal instance** - Place paywall once at app root
327
- 2. **Global access** - Use `paywallControl` for non-React contexts
328
- 3. **Clean close** - Always provide close button
329
- 4. **Back handler** - Handle Android back button
330
- 5. **State persistence** - Don't rely on component state
331
- 6. **Auto-close for premium** - Hide when user subscribes
332
- 7. **Deeplink support** - Open from URLs and notifications
333
-
334
- ## Related Hooks
335
-
336
- - **usePaywallOperations** - For paywall purchase operations
337
- - **usePremium** - For subscription status
338
- - **usePaywall** - For complete paywall management
339
-
340
- ## See Also
341
-
342
- - [Paywall Screen](../screens/README.md)
343
- - [Paywall Components](../components/paywall/README.md)
344
- - [Modal Integration](../../../docs/MODAL_INTEGRATION.md)
90
+ - **usePaywallOperations**: For paywall purchase operations
91
+ - **usePremium**: For subscription status
92
+ - **usePaywall**: For complete paywall management
93
+ - **Paywall Screen**: `src/presentation/screens/README.md`
94
+ - **Paywall Components**: `src/presentation/components/paywall/README.md`
95
+ - **Modal Integration**: `src/docs/MODAL_INTEGRATION.md`