@umituz/react-native-subscription 2.39.1 → 2.39.2
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-subscription",
|
|
3
|
-
"version": "2.39.
|
|
3
|
+
"version": "2.39.2",
|
|
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",
|
package/src/index.ts
CHANGED
|
@@ -60,7 +60,6 @@ export type {
|
|
|
60
60
|
SubscriptionDisplayFlags,
|
|
61
61
|
UpgradePromptConfig,
|
|
62
62
|
} from "./domains/subscription/presentation/screens/SubscriptionDetailScreen.types";
|
|
63
|
-
export * from "./domains/paywall/components/PaywallContainer";
|
|
64
63
|
export { PaywallScreen } from "./domains/paywall/components/PaywallScreen";
|
|
65
64
|
export type { PaywallScreenProps } from "./domains/paywall/components/PaywallScreen.types";
|
|
66
65
|
|
|
@@ -86,7 +85,6 @@ export { creditsQueryKeys } from "./domains/credits/presentation/creditsQueryKey
|
|
|
86
85
|
|
|
87
86
|
// Paywall Types
|
|
88
87
|
export type { PaywallTranslations, PaywallLegalUrls } from "./domains/paywall/entities/types";
|
|
89
|
-
export type { PaywallContainerProps } from "./domains/paywall/components/PaywallContainer.types";
|
|
90
88
|
|
|
91
89
|
// Purchase Loading Overlay
|
|
92
90
|
export { PurchaseLoadingOverlay } from "./domains/subscription/presentation/components/overlay/PurchaseLoadingOverlay";
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from "react";
|
|
2
|
-
import { usePaywallVisibility } from "../../subscription/presentation/usePaywallVisibility";
|
|
3
|
-
import { useSubscriptionPackages } from "../../subscription/infrastructure/hooks/useSubscriptionPackages";
|
|
4
|
-
import { createCreditAmountsFromPackages } from "../../../utils/creditMapper";
|
|
5
|
-
import { PaywallModal } from "./PaywallModal";
|
|
6
|
-
import { useAuthAwarePurchase } from "../../subscription/presentation/useAuthAwarePurchase";
|
|
7
|
-
import type { PaywallContainerProps } from "./PaywallContainer.types";
|
|
8
|
-
|
|
9
|
-
export const PaywallContainer: React.FC<PaywallContainerProps> = (props) => {
|
|
10
|
-
const {
|
|
11
|
-
translations,
|
|
12
|
-
legalUrls,
|
|
13
|
-
features,
|
|
14
|
-
heroImage,
|
|
15
|
-
bestValueIdentifier,
|
|
16
|
-
creditAmounts: providedCreditAmounts,
|
|
17
|
-
creditsLabel,
|
|
18
|
-
packageAllocations,
|
|
19
|
-
source,
|
|
20
|
-
onPurchaseSuccess,
|
|
21
|
-
onPurchaseError,
|
|
22
|
-
onAuthRequired,
|
|
23
|
-
visible,
|
|
24
|
-
onClose,
|
|
25
|
-
} = props;
|
|
26
|
-
|
|
27
|
-
const { showPaywall, closePaywall, currentSource } = usePaywallVisibility();
|
|
28
|
-
const isVisible = visible ?? showPaywall;
|
|
29
|
-
const handleClose = onClose ?? closePaywall;
|
|
30
|
-
|
|
31
|
-
if (__DEV__) {
|
|
32
|
-
console.log("[PaywallContainer] Render:", {
|
|
33
|
-
visibleProp: visible,
|
|
34
|
-
showPaywall,
|
|
35
|
-
isVisible,
|
|
36
|
-
currentSource,
|
|
37
|
-
hasTranslations: !!translations,
|
|
38
|
-
hasFeatures: !!features,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const purchaseSource = source ?? currentSource ?? "settings";
|
|
43
|
-
|
|
44
|
-
const { data: packages = [], isLoading: isLoadingPackages } = useSubscriptionPackages();
|
|
45
|
-
|
|
46
|
-
const { handlePurchase: performPurchase, handleRestore: performRestore } = useAuthAwarePurchase({
|
|
47
|
-
source: purchaseSource
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const creditAmounts = useMemo(() => {
|
|
51
|
-
if (providedCreditAmounts) return providedCreditAmounts;
|
|
52
|
-
if (!packageAllocations || packages.length === 0) return undefined;
|
|
53
|
-
return createCreditAmountsFromPackages(packages, packageAllocations);
|
|
54
|
-
}, [providedCreditAmounts, packageAllocations, packages]);
|
|
55
|
-
|
|
56
|
-
// When using credit system, only show packages that have a credit allocation.
|
|
57
|
-
const displayPackages = useMemo(() => {
|
|
58
|
-
if (!creditAmounts || Object.keys(creditAmounts).length === 0) return packages;
|
|
59
|
-
return packages.filter((pkg) => creditAmounts[pkg.product.identifier] != null);
|
|
60
|
-
}, [packages, creditAmounts]);
|
|
61
|
-
|
|
62
|
-
if (__DEV__) {
|
|
63
|
-
console.log("[PaywallContainer] Before early return:", {
|
|
64
|
-
isVisible,
|
|
65
|
-
displayPackagesCount: displayPackages.length,
|
|
66
|
-
isLoadingPackages,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (!isVisible) {
|
|
71
|
-
if (__DEV__) {
|
|
72
|
-
console.log("[PaywallContainer] Early returning (isVisible = false)");
|
|
73
|
-
}
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<PaywallModal
|
|
79
|
-
visible={isVisible}
|
|
80
|
-
onClose={handleClose}
|
|
81
|
-
translations={translations}
|
|
82
|
-
packages={displayPackages}
|
|
83
|
-
legalUrls={legalUrls}
|
|
84
|
-
features={features ? [...features] : undefined}
|
|
85
|
-
heroImage={heroImage}
|
|
86
|
-
bestValueIdentifier={bestValueIdentifier}
|
|
87
|
-
creditAmounts={creditAmounts}
|
|
88
|
-
creditsLabel={creditsLabel}
|
|
89
|
-
onPurchase={performPurchase}
|
|
90
|
-
onRestore={performRestore}
|
|
91
|
-
onPurchaseSuccess={onPurchaseSuccess}
|
|
92
|
-
onPurchaseError={onPurchaseError}
|
|
93
|
-
onAuthRequired={onAuthRequired}
|
|
94
|
-
source={purchaseSource}
|
|
95
|
-
isLoadingPackages={isLoadingPackages}
|
|
96
|
-
/>
|
|
97
|
-
);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
PaywallContainer.displayName = "PaywallContainer";
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { ImageSourcePropType } from "react-native";
|
|
2
|
-
import type { PaywallTranslations, PaywallLegalUrls, SubscriptionFeature } from "../entities/types";
|
|
3
|
-
import type { PurchaseSource } from "../../subscription/core/SubscriptionConstants";
|
|
4
|
-
import type { PackageAllocationMap } from "../../credits/core/Credits";
|
|
5
|
-
|
|
6
|
-
export interface PaywallContainerProps {
|
|
7
|
-
readonly translations: PaywallTranslations;
|
|
8
|
-
readonly legalUrls?: PaywallLegalUrls;
|
|
9
|
-
readonly features?: readonly SubscriptionFeature[];
|
|
10
|
-
readonly heroImage?: ImageSourcePropType;
|
|
11
|
-
readonly bestValueIdentifier?: string;
|
|
12
|
-
readonly creditAmounts?: Record<string, number>;
|
|
13
|
-
readonly creditsLabel?: string;
|
|
14
|
-
readonly packageAllocations?: PackageAllocationMap;
|
|
15
|
-
readonly source?: PurchaseSource;
|
|
16
|
-
readonly onPurchaseSuccess?: () => void;
|
|
17
|
-
readonly onPurchaseError?: (error: Error | string) => void;
|
|
18
|
-
readonly onAuthRequired?: () => void;
|
|
19
|
-
readonly visible?: boolean;
|
|
20
|
-
readonly onClose?: () => void;
|
|
21
|
-
}
|