@umituz/react-native-subscription 3.0.0 → 3.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.
- package/package.json +1 -1
- package/src/domains/paywall/components/PaywallScreen.renderItem.tsx +1 -1
- package/src/domains/paywall/components/PaywallScreen.tsx +1 -8
- package/src/domains/subscription/presentation/components/ManagedSubscriptionFlow.states.tsx +9 -9
- package/src/domains/subscription/presentation/components/ManagedSubscriptionFlow.tsx +3 -3
- package/src/domains/subscription/presentation/components/feedback/PaywallFeedbackScreen.parts.tsx +1 -2
- package/src/domains/subscription/presentation/components/feedback/PaywallFeedbackScreen.tsx +2 -2
- package/src/domains/subscription/presentation/providers/SubscriptionFlowProvider.tsx +3 -5
- package/src/domains/subscription/presentation/useSubscriptionFlow.ts +4 -1
- package/src/exports/analytics.ts +10 -45
- package/src/exports/experimental.ts +5 -86
- package/src/exports/onboarding.ts +7 -24
- package/src/exports/wallet.ts +10 -13
- package/src/index.components.ts +40 -0
- package/src/index.constants.ts +71 -0
- package/src/index.hooks.ts +37 -0
- package/src/index.infrastructure.ts +81 -0
- package/src/index.ts +14 -252
- package/src/domains/paywall/hooks/usePaywallOrchestrator.ts +0 -166
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-subscription",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Complete subscription management with RevenueCat, paywall UI, and credits system for React Native apps",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
|
-
import { View
|
|
7
|
+
import { View } from "react-native";
|
|
8
8
|
import type { ImageSourcePropType } from "react-native";
|
|
9
9
|
import { AtomicText, AtomicIcon } from "@umituz/react-native-design-system/atoms";
|
|
10
10
|
import { Image } from "expo-image";
|
|
@@ -75,7 +75,6 @@ export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) =>
|
|
|
75
75
|
selectedPlanId,
|
|
76
76
|
setSelectedPlanId,
|
|
77
77
|
isProcessing,
|
|
78
|
-
handlePurchase,
|
|
79
78
|
handleRestore,
|
|
80
79
|
resetState
|
|
81
80
|
} = usePaywallActions({
|
|
@@ -228,14 +227,8 @@ export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) =>
|
|
|
228
227
|
translations={translations}
|
|
229
228
|
legalUrls={legalUrls}
|
|
230
229
|
isProcessing={isProcessing}
|
|
231
|
-
selectedPlanId={selectedPlanId}
|
|
232
|
-
packages={packages}
|
|
233
|
-
onPurchase={handlePurchase}
|
|
234
230
|
onRestore={handleRestore}
|
|
235
|
-
|
|
236
|
-
insets={insets}
|
|
237
|
-
tokens={tokens}
|
|
238
|
-
styles={styles}
|
|
231
|
+
onLegalClick={handleLegalUrl}
|
|
239
232
|
/>
|
|
240
233
|
</View>
|
|
241
234
|
);
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
|
-
import type {
|
|
7
|
+
import type { PurchasesPackage } from "react-native-purchases";
|
|
8
|
+
import type { UserCredits } from "../../../credits/core/Credits";
|
|
8
9
|
import { SplashScreen } from "@umituz/react-native-design-system/molecules";
|
|
9
10
|
import { OnboardingScreen } from "@umituz/react-native-design-system/onboarding";
|
|
10
|
-
import { useSubscriptionFlowStore } from "../useSubscriptionFlow";
|
|
11
11
|
import type { ManagedSubscriptionFlowProps } from "./ManagedSubscriptionFlow";
|
|
12
12
|
import { PaywallScreen } from "../../../paywall/components/PaywallScreen";
|
|
13
13
|
import { PaywallFeedbackScreen } from "./feedback/PaywallFeedbackScreen";
|
|
@@ -57,12 +57,12 @@ export const OnboardingState: React.FC<OnboardingStateProps> = ({ config, onComp
|
|
|
57
57
|
|
|
58
58
|
interface PaywallStateProps {
|
|
59
59
|
config: ManagedSubscriptionFlowProps["paywall"];
|
|
60
|
-
packages:
|
|
60
|
+
packages: PurchasesPackage[];
|
|
61
61
|
isPremium: boolean;
|
|
62
|
-
credits:
|
|
62
|
+
credits: UserCredits | null;
|
|
63
63
|
isSyncing: boolean;
|
|
64
|
-
onPurchase: (
|
|
65
|
-
onRestore: () => Promise<
|
|
64
|
+
onPurchase: (pkg: PurchasesPackage) => Promise<boolean>;
|
|
65
|
+
onRestore: () => Promise<boolean>;
|
|
66
66
|
onClose: (purchased: boolean) => void;
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -78,9 +78,9 @@ export const PaywallState: React.FC<PaywallStateProps> = ({
|
|
|
78
78
|
}) => {
|
|
79
79
|
const [purchaseSuccessful, setPurchaseSuccessful] = React.useState(false);
|
|
80
80
|
|
|
81
|
-
const handlePurchase = async (
|
|
82
|
-
const result = await onPurchase(
|
|
83
|
-
if (result
|
|
81
|
+
const handlePurchase = async (pkg: PurchasesPackage) => {
|
|
82
|
+
const result = await onPurchase(pkg);
|
|
83
|
+
if (result) {
|
|
84
84
|
setPurchaseSuccessful(true);
|
|
85
85
|
}
|
|
86
86
|
return result;
|
|
@@ -91,7 +91,7 @@ const ManagedSubscriptionFlowInner: React.FC<ManagedSubscriptionFlowProps> = ({
|
|
|
91
91
|
const status = useSubscriptionFlowStatus();
|
|
92
92
|
|
|
93
93
|
// Premium hooks
|
|
94
|
-
const { isPremium, isSyncing, credits
|
|
94
|
+
const { isPremium, isSyncing, credits } = usePremiumStatus();
|
|
95
95
|
const { packages } = usePremiumPackages();
|
|
96
96
|
const { purchasePackage, restorePurchase } = usePremiumActions();
|
|
97
97
|
|
|
@@ -108,7 +108,7 @@ const ManagedSubscriptionFlowInner: React.FC<ManagedSubscriptionFlowProps> = ({
|
|
|
108
108
|
// ========================================================================
|
|
109
109
|
|
|
110
110
|
useEffect(() => {
|
|
111
|
-
if (status === SubscriptionFlowStatus.CHECK_PREMIUM && !
|
|
111
|
+
if (status === SubscriptionFlowStatus.CHECK_PREMIUM && !isSyncing) {
|
|
112
112
|
const paywallShown = useSubscriptionFlowStore.getState().paywallShown;
|
|
113
113
|
|
|
114
114
|
if (isPremium) {
|
|
@@ -119,7 +119,7 @@ const ManagedSubscriptionFlowInner: React.FC<ManagedSubscriptionFlowProps> = ({
|
|
|
119
119
|
completePaywall(false);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
}, [status, isPremium,
|
|
122
|
+
}, [status, isPremium, isSyncing, showPaywall, completePaywall]);
|
|
123
123
|
|
|
124
124
|
useEffect(() => {
|
|
125
125
|
if (status === SubscriptionFlowStatus.READY && showFeedback) {
|
package/src/domains/subscription/presentation/components/feedback/PaywallFeedbackScreen.parts.tsx
CHANGED
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
|
-
import { View, TouchableOpacity
|
|
7
|
+
import { View, TouchableOpacity } from "react-native";
|
|
8
8
|
import { AtomicText, AtomicIcon } from "@umituz/react-native-design-system/atoms";
|
|
9
|
-
import { useSafeAreaInsets } from "@umituz/react-native-design-system/safe-area";
|
|
10
9
|
import { FeedbackOption } from "./FeedbackOption";
|
|
11
10
|
import type { PaywallFeedbackTranslations } from "./PaywallFeedbackScreen.types";
|
|
12
11
|
|
|
@@ -38,7 +38,7 @@ export const PaywallFeedbackScreen: React.FC<PaywallFeedbackScreenProps> = React
|
|
|
38
38
|
canSubmit,
|
|
39
39
|
} = usePaywallFeedback({ onSubmit, onClose });
|
|
40
40
|
|
|
41
|
-
const screenStyles = useMemo(() => createScreenStyles(
|
|
41
|
+
const screenStyles = useMemo(() => createScreenStyles(), []);
|
|
42
42
|
|
|
43
43
|
return (
|
|
44
44
|
<View style={[screenStyles.container, { backgroundColor: 'white', opacity: 1 }]}>
|
|
@@ -96,7 +96,7 @@ PaywallFeedbackScreen.displayName = "PaywallFeedbackScreen";
|
|
|
96
96
|
// STYLES
|
|
97
97
|
// ============================================================================
|
|
98
98
|
|
|
99
|
-
const createScreenStyles = (
|
|
99
|
+
const createScreenStyles = () => ({
|
|
100
100
|
container: {
|
|
101
101
|
flex: 1,
|
|
102
102
|
},
|
|
@@ -16,7 +16,6 @@ export const SubscriptionFlowProvider: React.FC<{ children: React.ReactNode }> =
|
|
|
16
16
|
// Selectors for stable references and only what we need
|
|
17
17
|
const isInitialized = useSubscriptionFlowStore((state) => state.isInitialized);
|
|
18
18
|
const isOnboardingComplete = useSubscriptionFlowStore((state) => state.isOnboardingComplete);
|
|
19
|
-
const showPostOnboardingPaywall = useSubscriptionFlowStore((state) => state.showPostOnboardingPaywall);
|
|
20
19
|
const status = useSubscriptionFlowStore((state) => state.status);
|
|
21
20
|
const setInitialized = useSubscriptionFlowStore((state) => state.setInitialized);
|
|
22
21
|
const setStatus = useSubscriptionFlowStore((state) => state.setStatus);
|
|
@@ -49,7 +48,6 @@ export const SubscriptionFlowProvider: React.FC<{ children: React.ReactNode }> =
|
|
|
49
48
|
console.log('[SubscriptionFlowProvider] 🧠 Calculating Status Transition', {
|
|
50
49
|
isInitialized,
|
|
51
50
|
isOnboardingComplete,
|
|
52
|
-
showPostOnboardingPaywall,
|
|
53
51
|
currentStatus: status
|
|
54
52
|
});
|
|
55
53
|
}
|
|
@@ -60,8 +58,9 @@ export const SubscriptionFlowProvider: React.FC<{ children: React.ReactNode }> =
|
|
|
60
58
|
nextStatus = SubscriptionFlowStatus.INITIALIZING;
|
|
61
59
|
} else if (!isOnboardingComplete) {
|
|
62
60
|
nextStatus = SubscriptionFlowStatus.ONBOARDING;
|
|
63
|
-
} else
|
|
64
|
-
|
|
61
|
+
} else {
|
|
62
|
+
// Onboarding complete - let ManagedSubscriptionFlow handle CHECK_PREMIUM
|
|
63
|
+
nextStatus = SubscriptionFlowStatus.CHECK_PREMIUM;
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
if (nextStatus !== status) {
|
|
@@ -71,7 +70,6 @@ export const SubscriptionFlowProvider: React.FC<{ children: React.ReactNode }> =
|
|
|
71
70
|
}, [
|
|
72
71
|
isInitialized,
|
|
73
72
|
isOnboardingComplete,
|
|
74
|
-
showPostOnboardingPaywall,
|
|
75
73
|
status,
|
|
76
74
|
setStatus
|
|
77
75
|
]);
|
|
@@ -50,7 +50,6 @@ export interface SubscriptionFlowState {
|
|
|
50
50
|
export interface SubscriptionFlowActions {
|
|
51
51
|
// Flow actions
|
|
52
52
|
completeOnboarding: () => void;
|
|
53
|
-
checkPremiumStatus: () => void;
|
|
54
53
|
showPaywall: () => void;
|
|
55
54
|
completePaywall: (purchased: boolean) => void;
|
|
56
55
|
showFeedbackScreen: () => void;
|
|
@@ -62,6 +61,10 @@ export interface SubscriptionFlowActions {
|
|
|
62
61
|
// Sync actions
|
|
63
62
|
setSyncStatus: (status: SyncStatus, error?: string | null) => void;
|
|
64
63
|
|
|
64
|
+
// State setters (for internal use)
|
|
65
|
+
setInitialized: (initialized: boolean) => void;
|
|
66
|
+
setStatus: (status: SubscriptionFlowStatus) => void;
|
|
67
|
+
|
|
65
68
|
// Reset
|
|
66
69
|
resetFlow: () => void;
|
|
67
70
|
}
|
package/src/exports/analytics.ts
CHANGED
|
@@ -1,53 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SUBSCRIPTION ANALYTICS (Optional)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* NOTE: Analytics features coming soon
|
|
5
|
+
* This is a placeholder for future subscription analytics
|
|
5
6
|
*
|
|
6
7
|
* @example
|
|
7
|
-
* import { SubscriptionAnalytics
|
|
8
|
+
* // Future: import { SubscriptionAnalytics } from '@umituz/react-native-subscription/exports/analytics';
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
ConversionFunnelData,
|
|
16
|
-
} from '../../presentation/hooks/analytics/useSubscriptionAnalytics.types';
|
|
11
|
+
// Reserved for future analytics features
|
|
12
|
+
// For now, use your own analytics solution with our hooks:
|
|
13
|
+
// - usePremiumStatus
|
|
14
|
+
// - useSubscriptionStatus
|
|
15
|
+
// - usePaywallVisibility
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
export type {
|
|
21
|
-
PaywallAnalyticsData,
|
|
22
|
-
PaywallImpressionData,
|
|
23
|
-
PaywallConversionData,
|
|
24
|
-
} from '../../domains/paywall/hooks/usePaywallAnalytics.types';
|
|
25
|
-
|
|
26
|
-
// Revenue Analytics
|
|
27
|
-
export { useRevenueAnalytics } from '../../domains/subscription/presentation/hooks/useRevenueAnalytics';
|
|
28
|
-
export type {
|
|
29
|
-
RevenueAnalyticsData,
|
|
30
|
-
RevenueMetrics,
|
|
31
|
-
ARPUData,
|
|
32
|
-
LTVData,
|
|
33
|
-
} from '../../domains/subscription/presentation/hooks/useRevenueAnalytics.types';
|
|
34
|
-
|
|
35
|
-
// Churn Analytics
|
|
36
|
-
export { useChurnAnalytics } from '../../domains/subscription/presentation/hooks/useChurnAnalytics';
|
|
37
|
-
export type {
|
|
38
|
-
ChurnAnalyticsData,
|
|
39
|
-
ChurnRiskData,
|
|
40
|
-
RetentionData,
|
|
41
|
-
} from '../../domains/subscription/presentation/hooks/useChurnAnalytics.types';
|
|
42
|
-
|
|
43
|
-
// Analytics Helpers
|
|
44
|
-
export {
|
|
45
|
-
trackSubscriptionEvent,
|
|
46
|
-
trackPaywallEvent,
|
|
47
|
-
trackRevenueEvent,
|
|
48
|
-
} from '../../utils/analyticsHelpers';
|
|
49
|
-
export type {
|
|
50
|
-
SubscriptionEventType,
|
|
51
|
-
PaywallEventType,
|
|
52
|
-
RevenueEventType,
|
|
53
|
-
} from '../../utils/analyticsHelpers.types';
|
|
17
|
+
export { useSubscriptionStatus } from '../domains/subscription/presentation/useSubscriptionStatus';
|
|
18
|
+
export { usePremiumStatus } from '../domains/subscription/presentation/usePremiumStatus';
|
|
@@ -1,93 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* EXPERIMENTAL Features (Beta)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* NOTE: Experimental features coming soon
|
|
5
|
+
* This is a placeholder for future beta features
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
* import { AIUpsell
|
|
8
|
+
* // Future: import { AIUpsell } from '@umituz/react-native-subscription/exports/experimental';
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
//
|
|
12
|
-
// AI-
|
|
13
|
-
// ============================================================================
|
|
14
|
-
|
|
15
|
-
// AI-Powered Upsell Recommendations
|
|
16
|
-
export { useAIUpsellRecommendations } from '../../domains/paywall/experimental/useAIUpsellRecommendations';
|
|
17
|
-
export type {
|
|
18
|
-
AIUpsellData,
|
|
19
|
-
UpsellRecommendation,
|
|
20
|
-
UpsellStrategy,
|
|
21
|
-
} from '../../domains/paywall/experimental/useAIUpsellRecommendations.types';
|
|
22
|
-
|
|
23
|
-
// Smart Paywall (Dynamic pricing based on user behavior)
|
|
24
|
-
export { SmartPaywall } from '../../domains/paywall/experimental/SmartPaywall';
|
|
25
|
-
export type {
|
|
26
|
-
SmartPaywallProps,
|
|
27
|
-
SmartPaywallConfig,
|
|
28
|
-
} from '../../domains/paywall/experimental/SmartPaywall.types';
|
|
29
|
-
|
|
30
|
-
// ============================================================================
|
|
31
|
-
// EXPERIMENTAL COMPONENTS
|
|
32
|
-
// ============================================================================
|
|
33
|
-
|
|
34
|
-
// Interactive Pricing Tiers
|
|
35
|
-
export { InteractivePricingTiers } from '../../domains/paywall/experimental/InteractivePricingTiers';
|
|
36
|
-
export type {
|
|
37
|
-
InteractivePricingTiersProps,
|
|
38
|
-
PricingTierConfig,
|
|
39
|
-
} from '../../domains/paywall/experimental/InteractivePricingTiers.types';
|
|
40
|
-
|
|
41
|
-
// Gamified Paywall (Rewards for engagement)
|
|
42
|
-
export { GamifiedPaywall } from '../../domains/paywall/experimental/GamifiedPaywall';
|
|
43
|
-
export type {
|
|
44
|
-
GamifiedPaywallProps,
|
|
45
|
-
GamificationConfig,
|
|
46
|
-
RewardConfig,
|
|
47
|
-
} from '../../domains/paywall/experimental/GamifiedPaywall.types';
|
|
48
|
-
|
|
49
|
-
// ============================================================================
|
|
50
|
-
// EXPERIMENTAL HOOKS
|
|
51
|
-
// ============================================================================
|
|
52
|
-
|
|
53
|
-
// Predictive Churn Prevention
|
|
54
|
-
export { usePredictiveChurnPrevention } from '../../domains/subscription/presentation/experimental/usePredictiveChurnPrevention';
|
|
55
|
-
export type {
|
|
56
|
-
ChurnPredictionData,
|
|
57
|
-
ChurnPreventionAction,
|
|
58
|
-
InterventionStrategy,
|
|
59
|
-
} from '../../domains/subscription/presentation/experimental/usePredictiveChurnPrevention.types';
|
|
60
|
-
|
|
61
|
-
// Dynamic Offer Generator
|
|
62
|
-
export { useDynamicOfferGenerator } from '../../domains/paywall/experimental/useDynamicOfferGenerator';
|
|
63
|
-
export type {
|
|
64
|
-
DynamicOfferData,
|
|
65
|
-
OfferConfig,
|
|
66
|
-
OfferStrategy,
|
|
67
|
-
} from '../../domains/paywall/experimental/useDynamicOfferGenerator.types';
|
|
68
|
-
|
|
69
|
-
// ============================================================================
|
|
70
|
-
// EXPERIMENTAL UTILS
|
|
71
|
-
// ============================================================================
|
|
72
|
-
|
|
73
|
-
// Behavioral Segmentation
|
|
74
|
-
export {
|
|
75
|
-
segmentUsersByBehavior,
|
|
76
|
-
getUserBehaviorScore,
|
|
77
|
-
} from '../../utils/experimental/behavioralSegmentation';
|
|
78
|
-
export type {
|
|
79
|
-
UserBehavior,
|
|
80
|
-
BehaviorSegment,
|
|
81
|
-
BehaviorScore,
|
|
82
|
-
} from '../../utils/experimental/behavioralSegmentation.types';
|
|
83
|
-
|
|
84
|
-
// Price Optimization
|
|
85
|
-
export {
|
|
86
|
-
optimizePriceForUser,
|
|
87
|
-
getOptimalPricePoint,
|
|
88
|
-
} from '../../utils/experimental/priceOptimization';
|
|
89
|
-
export type {
|
|
90
|
-
PriceOptimizationData,
|
|
91
|
-
PricePoint,
|
|
92
|
-
OptimizationStrategy,
|
|
93
|
-
} from '../../utils/experimental/priceOptimization.types';
|
|
11
|
+
// Reserved for future experimental features
|
|
12
|
+
// Check back later for AI-powered features, smart paywalls, etc.
|
|
@@ -4,31 +4,14 @@
|
|
|
4
4
|
* Advanced onboarding utilities for custom flows
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
|
-
* import {
|
|
7
|
+
* import { useOnboardingProgress } from '@umituz/react-native-subscription/exports/onboarding';
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
export type { OnboardingProgressData } from '../../domains/subscription/presentation/hooks/useOnboardingProgress.types';
|
|
10
|
+
// NOTE: These are placeholder exports for future onboarding features
|
|
11
|
+
// Currently, onboarding is handled by ManagedSubscriptionFlow core
|
|
13
12
|
|
|
14
|
-
//
|
|
15
|
-
export {
|
|
16
|
-
export type {
|
|
17
|
-
OnboardingEvent,
|
|
18
|
-
OnboardingAnalyticsData,
|
|
19
|
-
} from '../../presentation/hooks/onboarding/useOnboardingAnalytics.types';
|
|
13
|
+
// Re-export core onboarding types
|
|
14
|
+
export { SubscriptionFlowStatus } from '../domains/subscription/presentation/useSubscriptionFlow';
|
|
20
15
|
|
|
21
|
-
// Onboarding
|
|
22
|
-
|
|
23
|
-
export type {
|
|
24
|
-
OnboardingCompletionData,
|
|
25
|
-
OnboardingCompletionOptions,
|
|
26
|
-
} from '../../presentation/hooks/onboarding/useOnboardingCompletion.types';
|
|
27
|
-
|
|
28
|
-
// Onboarding Utils
|
|
29
|
-
export {
|
|
30
|
-
calculateOnboardingProgress,
|
|
31
|
-
isOnboardingComplete,
|
|
32
|
-
getOnboardingStep,
|
|
33
|
-
} from '../../utils/onboardingUtils';
|
|
34
|
-
export type { OnboardingStep } from '../../utils/onboardingUtils.types';
|
|
16
|
+
// Onboarding is part of ManagedSubscriptionFlow core
|
|
17
|
+
// This file is reserved for future advanced onboarding utilities
|
package/src/exports/wallet.ts
CHANGED
|
@@ -10,26 +10,23 @@
|
|
|
10
10
|
// Wallet Screen
|
|
11
11
|
export {
|
|
12
12
|
WalletScreen as WalletScreenContainer,
|
|
13
|
-
} from '
|
|
13
|
+
} from '../domains/wallet/presentation/screens/WalletScreen';
|
|
14
14
|
|
|
15
15
|
export type {
|
|
16
16
|
WalletScreenProps,
|
|
17
17
|
WalletScreenTranslations,
|
|
18
|
-
} from '
|
|
18
|
+
} from '../domains/wallet/presentation/screens/WalletScreen.types';
|
|
19
19
|
|
|
20
20
|
// Wallet Hooks
|
|
21
|
-
export { useWallet } from '
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
export { useTransactionHistory } from '../../domains/wallet/presentation/hooks/useTransactionHistory';
|
|
25
|
-
export type { TransactionHistoryResult } from '../../domains/wallet/presentation/hooks/useTransactionHistory';
|
|
21
|
+
export { useWallet } from '../domains/wallet/presentation/hooks/useWallet';
|
|
22
|
+
export { useTransactionHistory } from '../domains/wallet/presentation/hooks/useTransactionHistory';
|
|
26
23
|
|
|
27
24
|
// Wallet Components
|
|
28
|
-
export { BalanceCard } from '
|
|
29
|
-
export type { BalanceCardProps } from '
|
|
25
|
+
export { BalanceCard } from '../domains/wallet/presentation/components/BalanceCard';
|
|
26
|
+
export type { BalanceCardProps } from '../domains/wallet/presentation/components/BalanceCard.types';
|
|
30
27
|
|
|
31
|
-
export { TransactionList } from '
|
|
32
|
-
export type { TransactionListProps } from '
|
|
28
|
+
export { TransactionList } from '../domains/wallet/presentation/components/TransactionList';
|
|
29
|
+
export type { TransactionListProps } from '../domains/wallet/presentation/components/TransactionList.types';
|
|
33
30
|
|
|
34
|
-
export { TransactionItem } from '
|
|
35
|
-
export type { TransactionItemProps } from '
|
|
31
|
+
export { TransactionItem } from '../domains/wallet/presentation/components/TransactionItem';
|
|
32
|
+
export type { TransactionItemProps } from '../domains/wallet/presentation/components/TransactionItem.types';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CORE Exports - Components
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Subscription Components
|
|
6
|
+
export { PremiumDetailsCard } from "./domains/subscription/presentation/components/details/PremiumDetailsCard";
|
|
7
|
+
export type {
|
|
8
|
+
PremiumDetailsTranslations,
|
|
9
|
+
PremiumDetailsCardProps,
|
|
10
|
+
} from "./domains/subscription/presentation/components/details/PremiumDetailsCardTypes";
|
|
11
|
+
|
|
12
|
+
export { PremiumStatusBadge } from "./domains/subscription/presentation/components/details/PremiumStatusBadge";
|
|
13
|
+
export type { PremiumStatusBadgeProps } from "./domains/subscription/presentation/components/details/PremiumStatusBadge.types";
|
|
14
|
+
|
|
15
|
+
export { SubscriptionSection } from "./domains/subscription/presentation/components/sections/SubscriptionSection";
|
|
16
|
+
export type { SubscriptionSectionProps } from "./domains/subscription/presentation/components/sections/SubscriptionSection.types";
|
|
17
|
+
|
|
18
|
+
export { PaywallFeedbackScreen } from "./domains/subscription/presentation/components/feedback/PaywallFeedbackScreen";
|
|
19
|
+
export type { PaywallFeedbackScreenProps } from "./domains/subscription/presentation/components/feedback/PaywallFeedbackScreen.types";
|
|
20
|
+
|
|
21
|
+
// Subscription Screens
|
|
22
|
+
export type {
|
|
23
|
+
SubscriptionDetailConfig,
|
|
24
|
+
SubscriptionDetailTranslations,
|
|
25
|
+
SubscriptionDisplayFlags,
|
|
26
|
+
UpgradePromptConfig,
|
|
27
|
+
} from "./domains/subscription/presentation/screens/SubscriptionDetailScreen.types";
|
|
28
|
+
|
|
29
|
+
export { SubscriptionDetailScreen } from "./domains/subscription/presentation/screens/SubscriptionDetailScreen";
|
|
30
|
+
export type { SubscriptionDetailScreenProps } from "./domains/subscription/presentation/screens/SubscriptionDetailScreen.types";
|
|
31
|
+
|
|
32
|
+
// Paywall Components
|
|
33
|
+
export { PaywallScreen } from "./domains/paywall/components/PaywallScreen";
|
|
34
|
+
export type { PaywallScreenProps } from "./domains/paywall/components/PaywallScreen.types";
|
|
35
|
+
|
|
36
|
+
// Root Flow Components
|
|
37
|
+
export { ManagedSubscriptionFlow } from "./domains/subscription/presentation/components/ManagedSubscriptionFlow";
|
|
38
|
+
export type { ManagedSubscriptionFlowProps } from "./domains/subscription/presentation/components/ManagedSubscriptionFlow";
|
|
39
|
+
export { SubscriptionFlowStatus } from "./domains/subscription/presentation/useSubscriptionFlow";
|
|
40
|
+
export { SubscriptionFlowProvider, useSubscriptionFlowStatus } from "./domains/subscription/presentation/providers/SubscriptionFlowProvider";
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CORE Exports - Constants & Types
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Constants & Types
|
|
6
|
+
export {
|
|
7
|
+
USER_TIER,
|
|
8
|
+
SUBSCRIPTION_STATUS,
|
|
9
|
+
PERIOD_TYPE,
|
|
10
|
+
PACKAGE_TYPE,
|
|
11
|
+
PLATFORM,
|
|
12
|
+
PURCHASE_SOURCE,
|
|
13
|
+
PURCHASE_TYPE,
|
|
14
|
+
ANONYMOUS_CACHE_KEY,
|
|
15
|
+
} from "./domains/subscription/core/SubscriptionConstants";
|
|
16
|
+
|
|
17
|
+
export type {
|
|
18
|
+
UserTierType,
|
|
19
|
+
SubscriptionStatusType,
|
|
20
|
+
PeriodType,
|
|
21
|
+
PackageType,
|
|
22
|
+
Platform,
|
|
23
|
+
PurchaseSource,
|
|
24
|
+
PurchaseType,
|
|
25
|
+
} from "./domains/subscription/core/SubscriptionConstants";
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
createDefaultSubscriptionStatus,
|
|
29
|
+
isSubscriptionValid,
|
|
30
|
+
resolveSubscriptionStatus,
|
|
31
|
+
} from "./domains/subscription/core/SubscriptionStatus";
|
|
32
|
+
export type { SubscriptionStatus, StatusResolverInput } from "./domains/subscription/core/SubscriptionStatus";
|
|
33
|
+
|
|
34
|
+
// Domain Events
|
|
35
|
+
export { SUBSCRIPTION_EVENTS } from "./domains/subscription/core/events/SubscriptionEvents";
|
|
36
|
+
export type { SubscriptionEventType, SyncStatusChangedEvent } from "./domains/subscription/core/events/SubscriptionEvents";
|
|
37
|
+
export type { PurchaseCompletedEvent, RenewalDetectedEvent, PremiumStatusChangedEvent } from "./domains/subscription/core/SubscriptionEvents";
|
|
38
|
+
export { FLOW_EVENTS } from "./domains/subscription/core/events/FlowEvents";
|
|
39
|
+
export type { FlowEventType, OnboardingCompletedEvent, PaywallShownEvent, PaywallClosedEvent } from "./domains/subscription/core/events/FlowEvents";
|
|
40
|
+
|
|
41
|
+
export type { SubscriptionMetadata } from "./domains/subscription/core/types/SubscriptionMetadata";
|
|
42
|
+
export type { PremiumStatus as PremiumStatusMetadata } from "./domains/subscription/core/types/PremiumStatus";
|
|
43
|
+
export type { CreditInfo } from "./domains/subscription/core/types/CreditInfo";
|
|
44
|
+
|
|
45
|
+
// Credits Types
|
|
46
|
+
export type {
|
|
47
|
+
CreditType,
|
|
48
|
+
UserCredits,
|
|
49
|
+
CreditsConfig,
|
|
50
|
+
CreditsResult,
|
|
51
|
+
DeductCreditsResult,
|
|
52
|
+
} from "./domains/credits/core/Credits";
|
|
53
|
+
|
|
54
|
+
// Paywall Types
|
|
55
|
+
export type { PaywallTranslations, PaywallLegalUrls, SubscriptionFeature } from "./domains/paywall/entities/types";
|
|
56
|
+
|
|
57
|
+
// Application Layer - Ports
|
|
58
|
+
export type { ISubscriptionRepository } from "./shared/application/ports/ISubscriptionRepository";
|
|
59
|
+
export type { IRevenueCatService } from "./shared/application/ports/IRevenueCatService";
|
|
60
|
+
|
|
61
|
+
// Result Pattern
|
|
62
|
+
export {
|
|
63
|
+
success,
|
|
64
|
+
failure,
|
|
65
|
+
isSuccess,
|
|
66
|
+
isFailure,
|
|
67
|
+
unwrap,
|
|
68
|
+
unwrapOr,
|
|
69
|
+
tryCatch,
|
|
70
|
+
} from "./shared/utils/Result";
|
|
71
|
+
export type { Result, Success, Failure } from "./shared/utils/Result";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CORE Exports - Hooks
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Subscription Hooks
|
|
6
|
+
export { useAuthAwarePurchase } from "./domains/subscription/presentation/useAuthAwarePurchase";
|
|
7
|
+
export { useFeatureGate } from "./domains/subscription/presentation/useFeatureGate";
|
|
8
|
+
export { usePaywallVisibility, paywallControl } from "./domains/subscription/presentation/usePaywallVisibility";
|
|
9
|
+
export { usePremiumStatus } from "./domains/subscription/presentation/usePremiumStatus";
|
|
10
|
+
export { usePremiumPackages } from "./domains/subscription/presentation/usePremiumPackages";
|
|
11
|
+
export { usePremiumActions } from "./domains/subscription/presentation/usePremiumActions";
|
|
12
|
+
export { useSubscriptionFlowStore } from "./domains/subscription/presentation/useSubscriptionFlow";
|
|
13
|
+
export { useSubscriptionStatus } from "./domains/subscription/presentation/useSubscriptionStatus";
|
|
14
|
+
|
|
15
|
+
// Hook Types
|
|
16
|
+
export type { PremiumStatus } from "./domains/subscription/presentation/usePremiumStatus";
|
|
17
|
+
export type { PremiumPackages } from "./domains/subscription/presentation/usePremiumPackages";
|
|
18
|
+
export type { PremiumActions } from "./domains/subscription/presentation/usePremiumActions";
|
|
19
|
+
export type { SubscriptionFlowState, SubscriptionFlowActions, SubscriptionFlowStore } from "./domains/subscription/presentation/useSubscriptionFlow";
|
|
20
|
+
export type { SubscriptionStatusResult } from "./domains/subscription/presentation/useSubscriptionStatus.types";
|
|
21
|
+
|
|
22
|
+
// Credits Hooks
|
|
23
|
+
export { useCredits } from "./domains/credits/presentation/useCredits";
|
|
24
|
+
export { useDeductCredit } from "./domains/credits/presentation/deduct-credit/useDeductCredit";
|
|
25
|
+
|
|
26
|
+
// Feedback Hooks
|
|
27
|
+
export { usePaywallFeedback } from "./presentation/hooks/feedback/usePaywallFeedback";
|
|
28
|
+
export {
|
|
29
|
+
usePaywallFeedbackSubmit,
|
|
30
|
+
useSettingsFeedbackSubmit,
|
|
31
|
+
} from "./presentation/hooks/feedback/useFeedbackSubmit";
|
|
32
|
+
|
|
33
|
+
export type {
|
|
34
|
+
UsePaywallFeedbackSubmitOptions,
|
|
35
|
+
SettingsFeedbackData,
|
|
36
|
+
UseSettingsFeedbackSubmitOptions,
|
|
37
|
+
} from "./presentation/hooks/feedback/useFeedbackSubmit";
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CORE Exports - Infrastructure & Utils
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Infrastructure Layer - Core Services
|
|
6
|
+
export { initializeSubscription } from "./domains/subscription/application/initializer/SubscriptionInitializer";
|
|
7
|
+
export type { SubscriptionInitConfig, CreditPackageConfig } from "./domains/subscription/application/SubscriptionInitializerTypes";
|
|
8
|
+
|
|
9
|
+
export { CreditsRepository } from "./domains/credits/infrastructure/CreditsRepository";
|
|
10
|
+
export {
|
|
11
|
+
configureCreditsRepository,
|
|
12
|
+
getCreditsRepository,
|
|
13
|
+
getCreditsConfig,
|
|
14
|
+
isCreditsRepositoryConfigured
|
|
15
|
+
} from "./domains/credits/infrastructure/CreditsRepositoryManager";
|
|
16
|
+
|
|
17
|
+
export { CreditLimitService, calculateCreditLimit } from "./domains/credits/domain/services/CreditLimitService";
|
|
18
|
+
|
|
19
|
+
// Utils
|
|
20
|
+
export {
|
|
21
|
+
getCreditAllocation,
|
|
22
|
+
createCreditAmountsFromPackages,
|
|
23
|
+
} from "./utils/creditMapper";
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
isCreditPackage,
|
|
27
|
+
detectPackageType,
|
|
28
|
+
} from "./utils/packageTypeDetector";
|
|
29
|
+
export type { SubscriptionPackageType } from "./utils/packageTypeDetector";
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
formatPrice,
|
|
33
|
+
getBillingPeriodSuffix,
|
|
34
|
+
formatPriceWithPeriod,
|
|
35
|
+
} from "./utils/priceUtils";
|
|
36
|
+
|
|
37
|
+
export type { UserTierInfo, PremiumStatusFetcher } from "./utils/types";
|
|
38
|
+
|
|
39
|
+
export type { DateLike } from "./utils/dateUtils.core";
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
isNow,
|
|
43
|
+
isPast,
|
|
44
|
+
isFuture,
|
|
45
|
+
isValidDate,
|
|
46
|
+
toSafeDate,
|
|
47
|
+
formatISO,
|
|
48
|
+
now,
|
|
49
|
+
} from "./utils/dateUtils.core";
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
daysBetween,
|
|
53
|
+
daysUntil,
|
|
54
|
+
isSameDay,
|
|
55
|
+
isToday,
|
|
56
|
+
} from "./utils/dateUtils.compare";
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
formatRelative,
|
|
60
|
+
formatShort,
|
|
61
|
+
formatLong,
|
|
62
|
+
} from "./utils/dateUtils.format";
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
addDays,
|
|
66
|
+
addMonths,
|
|
67
|
+
addYears,
|
|
68
|
+
} from "./utils/dateUtils.math";
|
|
69
|
+
|
|
70
|
+
export { getAppVersion, validatePlatform } from "./utils/appUtils";
|
|
71
|
+
|
|
72
|
+
export { toDate, toISOString, toTimestamp, getCurrentISOString } from "./shared/utils/dateConverter";
|
|
73
|
+
|
|
74
|
+
export { createPaywallTranslations, createFeedbackTranslations } from "./domains/paywall/utils/paywallTranslationUtils";
|
|
75
|
+
|
|
76
|
+
// Init Module
|
|
77
|
+
export {
|
|
78
|
+
createSubscriptionInitModule,
|
|
79
|
+
cleanupSubscriptionModule,
|
|
80
|
+
type SubscriptionInitModuleConfig,
|
|
81
|
+
} from './init';
|
package/src/index.ts
CHANGED
|
@@ -1,256 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @umituz/react-native-subscription
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Complete subscription management with RevenueCat, paywall UI, and credits system
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Core features
|
|
8
|
+
* import { usePremiumStatus, ManagedSubscriptionFlow } from '@umituz/react-native-subscription';
|
|
9
|
+
*
|
|
10
|
+
* // Optional wallet
|
|
11
|
+
* import { WalletScreen } from '@umituz/react-native-subscription/exports/wallet';
|
|
6
12
|
*/
|
|
7
13
|
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
USER_TIER,
|
|
14
|
-
SUBSCRIPTION_STATUS,
|
|
15
|
-
PERIOD_TYPE,
|
|
16
|
-
PACKAGE_TYPE,
|
|
17
|
-
PLATFORM,
|
|
18
|
-
PURCHASE_SOURCE,
|
|
19
|
-
PURCHASE_TYPE,
|
|
20
|
-
ANONYMOUS_CACHE_KEY,
|
|
21
|
-
} from "./domains/subscription/core/SubscriptionConstants";
|
|
22
|
-
|
|
23
|
-
export type {
|
|
24
|
-
UserTierType,
|
|
25
|
-
SubscriptionStatusType,
|
|
26
|
-
PeriodType,
|
|
27
|
-
PackageType,
|
|
28
|
-
Platform,
|
|
29
|
-
PurchaseSource,
|
|
30
|
-
PurchaseType,
|
|
31
|
-
} from "./domains/subscription/core/SubscriptionConstants";
|
|
32
|
-
|
|
33
|
-
export {
|
|
34
|
-
createDefaultSubscriptionStatus,
|
|
35
|
-
isSubscriptionValid,
|
|
36
|
-
resolveSubscriptionStatus,
|
|
37
|
-
} from "./domains/subscription/core/SubscriptionStatus";
|
|
38
|
-
export type { SubscriptionStatus, StatusResolverInput } from "./domains/subscription/core/SubscriptionStatus";
|
|
39
|
-
|
|
40
|
-
// ============================================================================
|
|
41
|
-
// DOMAIN EVENTS
|
|
42
|
-
// ============================================================================
|
|
43
|
-
|
|
44
|
-
export { SUBSCRIPTION_EVENTS } from "./domains/subscription/core/events/SubscriptionEvents";
|
|
45
|
-
export type { SubscriptionEventType, SyncStatusChangedEvent } from "./domains/subscription/core/events/SubscriptionEvents";
|
|
46
|
-
export type { PurchaseCompletedEvent, RenewalDetectedEvent, PremiumStatusChangedEvent } from "./domains/subscription/core/SubscriptionEvents";
|
|
47
|
-
export { FLOW_EVENTS } from "./domains/subscription/core/events/FlowEvents";
|
|
48
|
-
export type { FlowEventType, OnboardingCompletedEvent, PaywallShownEvent, PaywallClosedEvent } from "./domains/subscription/core/events/FlowEvents";
|
|
49
|
-
|
|
50
|
-
export type { SubscriptionMetadata } from "./domains/subscription/core/types/SubscriptionMetadata";
|
|
51
|
-
export type { PremiumStatus as PremiumStatusMetadata } from "./domains/subscription/core/types/PremiumStatus";
|
|
52
|
-
export type { CreditInfo } from "./domains/subscription/core/types/CreditInfo";
|
|
53
|
-
|
|
54
|
-
// ============================================================================
|
|
55
|
-
// CREDITS TYPES (Core credits, wallet is separate)
|
|
56
|
-
// ============================================================================
|
|
57
|
-
|
|
58
|
-
export type {
|
|
59
|
-
CreditType,
|
|
60
|
-
UserCredits,
|
|
61
|
-
CreditsConfig,
|
|
62
|
-
CreditsResult,
|
|
63
|
-
DeductCreditsResult,
|
|
64
|
-
} from "./domains/credits/core/Credits";
|
|
65
|
-
|
|
66
|
-
// ============================================================================
|
|
67
|
-
// PAYWALL TYPES
|
|
68
|
-
// ============================================================================
|
|
69
|
-
|
|
70
|
-
export type { PaywallTranslations, PaywallLegalUrls, SubscriptionFeature } from "./domains/paywall/entities/types";
|
|
71
|
-
|
|
72
|
-
// ============================================================================
|
|
73
|
-
// APPLICATION LAYER - Ports
|
|
74
|
-
// ============================================================================
|
|
75
|
-
|
|
76
|
-
export type { ISubscriptionRepository } from "./shared/application/ports/ISubscriptionRepository";
|
|
77
|
-
export type { IRevenueCatService } from "./shared/application/ports/IRevenueCatService";
|
|
78
|
-
|
|
79
|
-
// ============================================================================
|
|
80
|
-
// RESULT PATTERN
|
|
81
|
-
// ============================================================================
|
|
82
|
-
|
|
83
|
-
export {
|
|
84
|
-
success,
|
|
85
|
-
failure,
|
|
86
|
-
isSuccess,
|
|
87
|
-
isFailure,
|
|
88
|
-
unwrap,
|
|
89
|
-
unwrapOr,
|
|
90
|
-
tryCatch,
|
|
91
|
-
} from "./shared/utils/Result";
|
|
92
|
-
export type { Result, Success, Failure } from "./shared/utils/Result";
|
|
93
|
-
|
|
94
|
-
// ============================================================================
|
|
95
|
-
// INFRASTRUCTURE LAYER - Core Services (No wallet)
|
|
96
|
-
// ============================================================================
|
|
97
|
-
|
|
98
|
-
export { initializeSubscription } from "./domains/subscription/application/initializer/SubscriptionInitializer";
|
|
99
|
-
export type { SubscriptionInitConfig, CreditPackageConfig } from "./domains/subscription/application/SubscriptionInitializerTypes";
|
|
100
|
-
|
|
101
|
-
export { CreditsRepository } from "./domains/credits/infrastructure/CreditsRepository";
|
|
102
|
-
export {
|
|
103
|
-
configureCreditsRepository,
|
|
104
|
-
getCreditsRepository,
|
|
105
|
-
getCreditsConfig,
|
|
106
|
-
isCreditsRepositoryConfigured
|
|
107
|
-
} from "./domains/credits/infrastructure/CreditsRepositoryManager";
|
|
108
|
-
|
|
109
|
-
export { CreditLimitService, calculateCreditLimit } from "./domains/credits/domain/services/CreditLimitService";
|
|
110
|
-
|
|
111
|
-
// ============================================================================
|
|
112
|
-
// PRESENTATION LAYER - Hooks (Core)
|
|
113
|
-
// ============================================================================
|
|
114
|
-
|
|
115
|
-
export { useAuthAwarePurchase } from "./domains/subscription/presentation/useAuthAwarePurchase";
|
|
116
|
-
export { useCredits } from "./domains/credits/presentation/useCredits";
|
|
117
|
-
export { useDeductCredit } from "./domains/credits/presentation/deduct-credit/useDeductCredit";
|
|
118
|
-
export { useFeatureGate } from "./domains/subscription/presentation/useFeatureGate";
|
|
119
|
-
export { usePaywallVisibility, paywallControl } from "./domains/subscription/presentation/usePaywallVisibility";
|
|
120
|
-
export { usePremiumStatus } from "./domains/subscription/presentation/usePremiumStatus";
|
|
121
|
-
export { usePremiumPackages } from "./domains/subscription/presentation/usePremiumPackages";
|
|
122
|
-
export { usePremiumActions } from "./domains/subscription/presentation/usePremiumActions";
|
|
123
|
-
export { useSubscriptionFlowStore } from "./domains/subscription/presentation/useSubscriptionFlow";
|
|
124
|
-
export type { SubscriptionFlowState, SubscriptionFlowActions, SubscriptionFlowStore } from "./domains/subscription/presentation/useSubscriptionFlow";
|
|
125
|
-
export { useSubscriptionStatus } from "./domains/subscription/presentation/useSubscriptionStatus";
|
|
126
|
-
export type { SubscriptionStatusResult } from "./domains/subscription/presentation/useSubscriptionStatus.types";
|
|
127
|
-
|
|
128
|
-
export type { PremiumStatus } from "./domains/subscription/presentation/usePremiumStatus";
|
|
129
|
-
export type { PremiumPackages } from "./domains/subscription/presentation/usePremiumPackages";
|
|
130
|
-
export type { PremiumActions } from "./domains/subscription/presentation/usePremiumActions";
|
|
131
|
-
|
|
132
|
-
export { usePaywallFeedback } from "./presentation/hooks/feedback/usePaywallFeedback";
|
|
133
|
-
export {
|
|
134
|
-
usePaywallFeedbackSubmit,
|
|
135
|
-
useSettingsFeedbackSubmit,
|
|
136
|
-
} from "./presentation/hooks/feedback/useFeedbackSubmit";
|
|
137
|
-
|
|
138
|
-
export type {
|
|
139
|
-
UsePaywallFeedbackSubmitOptions,
|
|
140
|
-
SettingsFeedbackData,
|
|
141
|
-
UseSettingsFeedbackSubmitOptions,
|
|
142
|
-
} from "./presentation/hooks/feedback/useFeedbackSubmit";
|
|
143
|
-
|
|
144
|
-
// ============================================================================
|
|
145
|
-
// PRESENTATION LAYER - Components (Core - No wallet)
|
|
146
|
-
// ============================================================================
|
|
147
|
-
|
|
148
|
-
export { PremiumDetailsCard } from "./domains/subscription/presentation/components/details/PremiumDetailsCard";
|
|
149
|
-
export type {
|
|
150
|
-
PremiumDetailsTranslations,
|
|
151
|
-
PremiumDetailsCardProps,
|
|
152
|
-
} from "./domains/subscription/presentation/components/details/PremiumDetailsCardTypes";
|
|
153
|
-
|
|
154
|
-
export { PremiumStatusBadge } from "./domains/subscription/presentation/components/details/PremiumStatusBadge";
|
|
155
|
-
export type { PremiumStatusBadgeProps } from "./domains/subscription/presentation/components/details/PremiumStatusBadge.types";
|
|
156
|
-
|
|
157
|
-
export { SubscriptionSection } from "./domains/subscription/presentation/components/sections/SubscriptionSection";
|
|
158
|
-
export type { SubscriptionSectionProps } from "./domains/subscription/presentation/components/sections/SubscriptionSection.types";
|
|
159
|
-
|
|
160
|
-
export { PaywallFeedbackScreen } from "./domains/subscription/presentation/components/feedback/PaywallFeedbackScreen";
|
|
161
|
-
export type { PaywallFeedbackScreenProps } from "./domains/subscription/presentation/components/feedback/PaywallFeedbackScreen.types";
|
|
162
|
-
|
|
163
|
-
export type {
|
|
164
|
-
SubscriptionDetailConfig,
|
|
165
|
-
SubscriptionDetailTranslations,
|
|
166
|
-
SubscriptionDisplayFlags,
|
|
167
|
-
UpgradePromptConfig,
|
|
168
|
-
} from "./domains/subscription/presentation/screens/SubscriptionDetailScreen.types";
|
|
169
|
-
|
|
170
|
-
export { SubscriptionDetailScreen } from "./domains/subscription/presentation/screens/SubscriptionDetailScreen";
|
|
171
|
-
export type { SubscriptionDetailScreenProps } from "./domains/subscription/presentation/screens/SubscriptionDetailScreen.types";
|
|
172
|
-
|
|
173
|
-
export { PaywallScreen } from "./domains/paywall/components/PaywallScreen";
|
|
174
|
-
export type { PaywallScreenProps } from "./domains/paywall/components/PaywallScreen.types";
|
|
175
|
-
|
|
176
|
-
export { usePaywallOrchestrator } from "./domains/paywall/hooks/usePaywallOrchestrator";
|
|
177
|
-
export type { PaywallOrchestratorOptions } from "./domains/paywall/hooks/usePaywallOrchestrator";
|
|
178
|
-
|
|
179
|
-
// ============================================================================
|
|
180
|
-
// ROOT FLOW COMPONENTS
|
|
181
|
-
// ============================================================================
|
|
182
|
-
|
|
183
|
-
export { ManagedSubscriptionFlow } from "./domains/subscription/presentation/components/ManagedSubscriptionFlow";
|
|
184
|
-
export type { ManagedSubscriptionFlowProps } from "./domains/subscription/presentation/components/ManagedSubscriptionFlow";
|
|
185
|
-
export { SubscriptionFlowStatus } from "./domains/subscription/presentation/useSubscriptionFlow";
|
|
186
|
-
export { SubscriptionFlowProvider, useSubscriptionFlowStatus } from "./domains/subscription/presentation/providers/SubscriptionFlowProvider";
|
|
187
|
-
|
|
188
|
-
// ============================================================================
|
|
189
|
-
// UTILS (Core)
|
|
190
|
-
// ============================================================================
|
|
191
|
-
|
|
192
|
-
export {
|
|
193
|
-
getCreditAllocation,
|
|
194
|
-
createCreditAmountsFromPackages,
|
|
195
|
-
} from "./utils/creditMapper";
|
|
196
|
-
|
|
197
|
-
export {
|
|
198
|
-
isCreditPackage,
|
|
199
|
-
detectPackageType,
|
|
200
|
-
} from "./utils/packageTypeDetector";
|
|
201
|
-
export type { SubscriptionPackageType } from "./utils/packageTypeDetector";
|
|
202
|
-
|
|
203
|
-
export {
|
|
204
|
-
formatPrice,
|
|
205
|
-
getBillingPeriodSuffix,
|
|
206
|
-
formatPriceWithPeriod,
|
|
207
|
-
} from "./utils/priceUtils";
|
|
208
|
-
|
|
209
|
-
export type { UserTierInfo, PremiumStatusFetcher } from "./utils/types";
|
|
210
|
-
|
|
211
|
-
export type { DateLike } from "./utils/dateUtils.core";
|
|
212
|
-
|
|
213
|
-
export {
|
|
214
|
-
isNow,
|
|
215
|
-
isPast,
|
|
216
|
-
isFuture,
|
|
217
|
-
isValidDate,
|
|
218
|
-
toSafeDate,
|
|
219
|
-
formatISO,
|
|
220
|
-
now,
|
|
221
|
-
} from "./utils/dateUtils.core";
|
|
222
|
-
|
|
223
|
-
export {
|
|
224
|
-
daysBetween,
|
|
225
|
-
daysUntil,
|
|
226
|
-
isSameDay,
|
|
227
|
-
isToday,
|
|
228
|
-
} from "./utils/dateUtils.compare";
|
|
229
|
-
|
|
230
|
-
export {
|
|
231
|
-
formatRelative,
|
|
232
|
-
formatShort,
|
|
233
|
-
formatLong,
|
|
234
|
-
} from "./utils/dateUtils.format";
|
|
235
|
-
|
|
236
|
-
export {
|
|
237
|
-
addDays,
|
|
238
|
-
addMonths,
|
|
239
|
-
addYears,
|
|
240
|
-
} from "./utils/dateUtils.math";
|
|
241
|
-
|
|
242
|
-
export { getAppVersion, validatePlatform } from "./utils/appUtils";
|
|
243
|
-
|
|
244
|
-
export { toDate, toISOString, toTimestamp, getCurrentISOString } from "./shared/utils/dateConverter";
|
|
245
|
-
|
|
246
|
-
export { createPaywallTranslations, createFeedbackTranslations } from "./domains/paywall/utils/paywallTranslationUtils";
|
|
247
|
-
|
|
248
|
-
// ============================================================================
|
|
249
|
-
// INIT MODULE
|
|
250
|
-
// ============================================================================
|
|
251
|
-
|
|
252
|
-
export {
|
|
253
|
-
createSubscriptionInitModule,
|
|
254
|
-
cleanupSubscriptionModule,
|
|
255
|
-
type SubscriptionInitModuleConfig,
|
|
256
|
-
} from './init';
|
|
14
|
+
// Re-export from categorized files for better organization
|
|
15
|
+
export * from './index.constants';
|
|
16
|
+
export * from './index.hooks';
|
|
17
|
+
export * from './index.components';
|
|
18
|
+
export * from './index.infrastructure';
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
import type { NavigationProp } from "@react-navigation/native";
|
|
3
|
-
import type { ImageSourcePropType } from "react-native";
|
|
4
|
-
import { usePremiumStatus } from "../../subscription/presentation/usePremiumStatus";
|
|
5
|
-
import { usePremiumPackages } from "../../subscription/presentation/usePremiumPackages";
|
|
6
|
-
import { usePremiumActions } from "../../subscription/presentation/usePremiumActions";
|
|
7
|
-
import { useSubscriptionFlowStore } from "../../subscription/presentation/useSubscriptionFlow";
|
|
8
|
-
import { usePaywallVisibility } from "../../subscription/presentation/usePaywallVisibility";
|
|
9
|
-
import { PaywallTranslations, PaywallLegalUrls, SubscriptionFeature } from "../entities/types";
|
|
10
|
-
|
|
11
|
-
export interface PaywallOrchestratorOptions {
|
|
12
|
-
navigation: NavigationProp<any>;
|
|
13
|
-
translations: PaywallTranslations;
|
|
14
|
-
features: SubscriptionFeature[];
|
|
15
|
-
legalUrls: PaywallLegalUrls;
|
|
16
|
-
heroImage: ImageSourcePropType;
|
|
17
|
-
isNavReady?: boolean;
|
|
18
|
-
isLocalizationReady?: boolean;
|
|
19
|
-
bestValueIdentifier?: string;
|
|
20
|
-
creditsLabel?: string;
|
|
21
|
-
/** Disable manual navigation (used when paywall is rendered inline) */
|
|
22
|
-
disableNavigation?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function usePaywallOrchestrator({
|
|
26
|
-
navigation,
|
|
27
|
-
translations,
|
|
28
|
-
features,
|
|
29
|
-
legalUrls,
|
|
30
|
-
heroImage,
|
|
31
|
-
isNavReady = true,
|
|
32
|
-
isLocalizationReady = true,
|
|
33
|
-
bestValueIdentifier = "yearly",
|
|
34
|
-
creditsLabel,
|
|
35
|
-
disableNavigation = false,
|
|
36
|
-
}: PaywallOrchestratorOptions) {
|
|
37
|
-
const { isPremium, isSyncing, credits } = usePremiumStatus();
|
|
38
|
-
const { packages } = usePremiumPackages();
|
|
39
|
-
const { purchasePackage, restorePurchase } = usePremiumActions();
|
|
40
|
-
|
|
41
|
-
const isOnboardingComplete = useSubscriptionFlowStore((state) => state.isOnboardingComplete);
|
|
42
|
-
const showPostOnboardingPaywall = useSubscriptionFlowStore((state) => state.showPostOnboardingPaywall);
|
|
43
|
-
const paywallShown = useSubscriptionFlowStore((state) => state.paywallShown);
|
|
44
|
-
const isAuthModalOpen = useSubscriptionFlowStore((state) => state.isAuthModalOpen);
|
|
45
|
-
const showFeedback = useSubscriptionFlowStore((state) => state.showFeedback);
|
|
46
|
-
const markPaywallShown = useSubscriptionFlowStore((state) => state.markPaywallShown);
|
|
47
|
-
const closePostOnboardingPaywall = useSubscriptionFlowStore((state) => state.closePostOnboardingPaywall);
|
|
48
|
-
const setShowFeedback = useSubscriptionFlowStore((state) => state.setShowFeedback);
|
|
49
|
-
|
|
50
|
-
const { showPaywall, closePaywall } = usePaywallVisibility();
|
|
51
|
-
const hasNavigatedRef = useRef(false);
|
|
52
|
-
|
|
53
|
-
const handleClose = () => {
|
|
54
|
-
closePaywall();
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
if (!isNavReady || !isLocalizationReady) return;
|
|
59
|
-
|
|
60
|
-
const shouldShowPostOnboarding =
|
|
61
|
-
isOnboardingComplete &&
|
|
62
|
-
showPostOnboardingPaywall &&
|
|
63
|
-
!paywallShown &&
|
|
64
|
-
!isAuthModalOpen &&
|
|
65
|
-
!isPremium;
|
|
66
|
-
|
|
67
|
-
const shouldShowManual = showPaywall && !isPremium && !isAuthModalOpen;
|
|
68
|
-
|
|
69
|
-
if (shouldShowPostOnboarding || shouldShowManual) {
|
|
70
|
-
if (hasNavigatedRef.current) return;
|
|
71
|
-
hasNavigatedRef.current = true;
|
|
72
|
-
|
|
73
|
-
// Skip navigation if disabled (paywall rendered inline)
|
|
74
|
-
if (disableNavigation) {
|
|
75
|
-
if (__DEV__) {
|
|
76
|
-
console.log('[usePaywallOrchestrator] ⏭️ Skipping navigation (disableNavigation=true)', {
|
|
77
|
-
source: shouldShowPostOnboarding ? "onboarding" : "manual",
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (shouldShowPostOnboarding) {
|
|
82
|
-
markPaywallShown();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (showPaywall) {
|
|
86
|
-
closePaywall();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (__DEV__) console.log('[usePaywallOrchestrator] 🚀 Navigating to Paywall', {
|
|
93
|
-
source: shouldShowPostOnboarding ? "onboarding" : "manual",
|
|
94
|
-
packagesCount: packages.length
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
navigation.navigate("PaywallScreen", {
|
|
98
|
-
translations,
|
|
99
|
-
legalUrls,
|
|
100
|
-
features,
|
|
101
|
-
bestValueIdentifier,
|
|
102
|
-
creditsLabel,
|
|
103
|
-
heroImage,
|
|
104
|
-
source: shouldShowPostOnboarding ? "onboarding" : "manual",
|
|
105
|
-
packages,
|
|
106
|
-
isPremium,
|
|
107
|
-
credits,
|
|
108
|
-
isSyncing,
|
|
109
|
-
onPurchase: purchasePackage,
|
|
110
|
-
onRestore: restorePurchase,
|
|
111
|
-
onClose: handleClose,
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
if (shouldShowPostOnboarding) {
|
|
115
|
-
markPaywallShown();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (showPaywall) {
|
|
119
|
-
closePaywall();
|
|
120
|
-
}
|
|
121
|
-
} else {
|
|
122
|
-
hasNavigatedRef.current = false;
|
|
123
|
-
}
|
|
124
|
-
}, [
|
|
125
|
-
isNavReady,
|
|
126
|
-
isLocalizationReady,
|
|
127
|
-
isOnboardingComplete,
|
|
128
|
-
showPostOnboardingPaywall,
|
|
129
|
-
paywallShown,
|
|
130
|
-
isAuthModalOpen,
|
|
131
|
-
isPremium,
|
|
132
|
-
showPaywall,
|
|
133
|
-
navigation,
|
|
134
|
-
translations,
|
|
135
|
-
legalUrls,
|
|
136
|
-
features,
|
|
137
|
-
heroImage,
|
|
138
|
-
packages,
|
|
139
|
-
markPaywallShown,
|
|
140
|
-
closePaywall,
|
|
141
|
-
bestValueIdentifier,
|
|
142
|
-
creditsLabel,
|
|
143
|
-
credits,
|
|
144
|
-
isSyncing,
|
|
145
|
-
purchasePackage,
|
|
146
|
-
restorePurchase,
|
|
147
|
-
handleClose,
|
|
148
|
-
disableNavigation,
|
|
149
|
-
]);
|
|
150
|
-
|
|
151
|
-
const completeOnboarding = useSubscriptionFlowStore((state) => state.completeOnboarding);
|
|
152
|
-
|
|
153
|
-
return {
|
|
154
|
-
flowState: {
|
|
155
|
-
isOnboardingComplete,
|
|
156
|
-
showPostOnboardingPaywall,
|
|
157
|
-
paywallShown,
|
|
158
|
-
isAuthModalOpen,
|
|
159
|
-
showFeedback
|
|
160
|
-
},
|
|
161
|
-
markPaywallShown,
|
|
162
|
-
closePostOnboardingPaywall,
|
|
163
|
-
completeOnboarding,
|
|
164
|
-
setShowFeedback
|
|
165
|
-
};
|
|
166
|
-
}
|