@umituz/react-native-subscription 2.27.10 → 2.27.11
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.27.
|
|
3
|
+
"version": "2.27.11",
|
|
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",
|
|
@@ -74,10 +74,10 @@ export interface CreditsConfig {
|
|
|
74
74
|
creditPackageAmounts?: Record<string, number>;
|
|
75
75
|
/** Credit allocations for different subscription types (weekly, monthly, yearly) */
|
|
76
76
|
packageAllocations?: PackageAllocationMap;
|
|
77
|
-
/**
|
|
77
|
+
/** Enable free credits for new users (default: false) */
|
|
78
|
+
enableFreeCredits?: boolean;
|
|
79
|
+
/** Free credits given to new users on registration (only used when enableFreeCredits: true) */
|
|
78
80
|
freeCredits?: number;
|
|
79
|
-
/** Whether to auto-initialize free credits when user has no credits document (default: true if freeCredits > 0) */
|
|
80
|
-
autoInitializeFreeCredits?: boolean;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
export interface CreditsResult<T = UserCredits> {
|
|
@@ -115,7 +115,8 @@ export function useFreeCreditsInit(params: UseFreeCreditsInitParams): UseFreeCre
|
|
|
115
115
|
const isConfigured = isCreditsRepositoryConfigured();
|
|
116
116
|
const config = getCreditsConfig();
|
|
117
117
|
const freeCredits = config.freeCredits ?? 0;
|
|
118
|
-
|
|
118
|
+
// Free credits only enabled when explicitly set to true AND freeCredits > 0
|
|
119
|
+
const isFreeCreditsEnabled = config.enableFreeCredits === true && freeCredits > 0;
|
|
119
120
|
|
|
120
121
|
// Check if THIS user's init is in progress (shared across all hook instances)
|
|
121
122
|
const isInitializing = userId ? inProgressSet.has(userId) : false;
|
|
@@ -127,7 +128,7 @@ export function useFreeCreditsInit(params: UseFreeCreditsInitParams): UseFreeCre
|
|
|
127
128
|
isRegisteredUser &&
|
|
128
129
|
isConfigured &&
|
|
129
130
|
!hasCredits &&
|
|
130
|
-
|
|
131
|
+
isFreeCreditsEnabled &&
|
|
131
132
|
!freeCreditsInitAttempted.has(userId);
|
|
132
133
|
|
|
133
134
|
// Stable callback reference
|
|
@@ -143,12 +144,12 @@ export function useFreeCreditsInit(params: UseFreeCreditsInitParams): UseFreeCre
|
|
|
143
144
|
if (!freeCreditsInitAttempted.has(userId)) {
|
|
144
145
|
initializeFreeCreditsForUser(userId, stableOnComplete);
|
|
145
146
|
}
|
|
146
|
-
} else if (querySuccess && isAnonymous && !hasCredits &&
|
|
147
|
+
} else if (querySuccess && isAnonymous && !hasCredits && isFreeCreditsEnabled) {
|
|
147
148
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
148
149
|
console.log("[useFreeCreditsInit] Skipping - anonymous user must register first");
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
|
-
}, [needsInit, userId, querySuccess, isAnonymous, hasCredits,
|
|
152
|
+
}, [needsInit, userId, querySuccess, isAnonymous, hasCredits, isFreeCreditsEnabled, stableOnComplete]);
|
|
152
153
|
|
|
153
154
|
return {
|
|
154
155
|
isInitializing: isInitializing || needsInit,
|