@umituz/react-native-subscription 3.1.16 → 3.1.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-subscription",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.18",
|
|
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",
|
|
@@ -73,7 +73,8 @@ class SubscriptionManagerImpl {
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
const
|
|
76
|
+
const config = this.managerConfig!;
|
|
77
|
+
const { service, success } = await performServiceInitialization(config.config, userId);
|
|
77
78
|
this.serviceInstance = service ?? null;
|
|
78
79
|
this.ensurePackageHandlerInitialized();
|
|
79
80
|
|
|
@@ -95,11 +96,14 @@ class SubscriptionManagerImpl {
|
|
|
95
96
|
async getPackages(): Promise<PurchasesPackage[]> {
|
|
96
97
|
this.ensureConfigured();
|
|
97
98
|
this.ensurePackageHandlerInitialized();
|
|
98
|
-
|
|
99
|
+
const config = this.managerConfig!;
|
|
100
|
+
const handler = this.packageHandler!;
|
|
101
|
+
return getPackagesOperation(config, this.serviceInstance, handler);
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
async purchasePackage(pkg: PurchasesPackage, explicitUserId?: string): Promise<boolean> {
|
|
102
105
|
this.ensureConfigured();
|
|
106
|
+
const config = this.managerConfig!;
|
|
103
107
|
if (explicitUserId) {
|
|
104
108
|
await this.initialize(explicitUserId);
|
|
105
109
|
}
|
|
@@ -113,18 +117,21 @@ class SubscriptionManagerImpl {
|
|
|
113
117
|
}
|
|
114
118
|
this.ensurePackageHandlerInitialized();
|
|
115
119
|
const resolvedUserId = explicitUserId || getCurrentUserIdOrThrow(this.initCache);
|
|
116
|
-
const
|
|
120
|
+
const handler = this.packageHandler!;
|
|
121
|
+
const result = await purchasePackageOperation(pkg, config, resolvedUserId, handler);
|
|
117
122
|
return result;
|
|
118
123
|
}
|
|
119
124
|
|
|
120
125
|
async restore(explicitUserId?: string): Promise<RestoreResultInfo> {
|
|
121
126
|
this.ensureConfigured();
|
|
127
|
+
const config = this.managerConfig!;
|
|
122
128
|
if (explicitUserId) {
|
|
123
129
|
await this.initialize(explicitUserId);
|
|
124
130
|
}
|
|
125
131
|
this.ensurePackageHandlerInitialized();
|
|
126
132
|
const resolvedUserId = explicitUserId || getCurrentUserIdOrThrow(this.initCache);
|
|
127
|
-
|
|
133
|
+
const handler = this.packageHandler!;
|
|
134
|
+
return restoreOperation(config, resolvedUserId, handler);
|
|
128
135
|
}
|
|
129
136
|
|
|
130
137
|
async checkPremiumStatus(): Promise<PremiumStatus> {
|
|
@@ -148,7 +155,8 @@ class SubscriptionManagerImpl {
|
|
|
148
155
|
|
|
149
156
|
getEntitlementId(): string {
|
|
150
157
|
this.ensureConfigured();
|
|
151
|
-
|
|
158
|
+
const config = this.managerConfig!;
|
|
159
|
+
return config.config.entitlementIdentifier;
|
|
152
160
|
}
|
|
153
161
|
}
|
|
154
162
|
|
|
@@ -71,14 +71,17 @@ export const PremiumDetailsCard: React.FC<PremiumDetailsCardProps> = React.memo(
|
|
|
71
71
|
}, (prevProps, nextProps) => {
|
|
72
72
|
// PERFORMANCE: Custom comparison to prevent unnecessary re-renders
|
|
73
73
|
// Deep comparison for credits array since it's frequently updated
|
|
74
|
-
const creditsEqual = prevProps.credits === nextProps.credits ||
|
|
75
|
-
(prevProps.credits
|
|
76
|
-
prevProps.credits
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
const creditsEqual: boolean = prevProps.credits === nextProps.credits ||
|
|
75
|
+
(!!prevProps.credits && !!nextProps.credits &&
|
|
76
|
+
prevProps.credits.length === nextProps.credits.length &&
|
|
77
|
+
prevProps.credits.every((credit, i) => {
|
|
78
|
+
const nextCredit = nextProps.credits![i];
|
|
79
|
+
return nextCredit !== undefined &&
|
|
80
|
+
credit.id === nextCredit.id &&
|
|
81
|
+
credit.current === nextCredit.current &&
|
|
82
|
+
credit.total === nextCredit.total &&
|
|
83
|
+
credit.label === nextCredit.label;
|
|
84
|
+
}));
|
|
82
85
|
|
|
83
86
|
return (
|
|
84
87
|
prevProps.statusType === nextProps.statusType &&
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* - READY -> READY (stays ready, shows overlays when needed)
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { createStore,
|
|
18
|
+
import { createStore, persistentStorage } from "@umituz/react-native-design-system/storage";
|
|
19
19
|
import { subscriptionEventBus, FLOW_EVENTS } from "../../../shared/infrastructure/SubscriptionEventBus";
|
|
20
20
|
import {
|
|
21
21
|
SubscriptionFlowStatus,
|
|
@@ -29,7 +29,7 @@ export const useSubscriptionFlowStore = createStore<SubscriptionFlowState, Subsc
|
|
|
29
29
|
name: "subscription-flow-storage",
|
|
30
30
|
initialState: initialFlowState,
|
|
31
31
|
persist: true,
|
|
32
|
-
storage:
|
|
32
|
+
storage: persistentStorage,
|
|
33
33
|
onRehydrate: (state) => {
|
|
34
34
|
if (!state.isInitialized) {
|
|
35
35
|
state.setInitialized(true);
|