@sudobility/subscription_lib 0.0.1 → 0.0.3
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/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/service.d.ts +13 -2
- package/dist/core/service.d.ts.map +1 -1
- package/dist/core/service.js +38 -17
- package/dist/core/singleton.d.ts +30 -0
- package/dist/core/singleton.d.ts.map +1 -1
- package/dist/core/singleton.js +63 -0
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useSubscribable.d.ts +13 -1
- package/dist/hooks/useSubscribable.d.ts.map +1 -1
- package/dist/hooks/useSubscribable.js +31 -7
- package/dist/hooks/useSubscriptionForPeriod.d.ts +8 -1
- package/dist/hooks/useSubscriptionForPeriod.d.ts.map +1 -1
- package/dist/hooks/useSubscriptionForPeriod.js +9 -3
- package/dist/hooks/useSubscriptionPeriods.d.ts +8 -1
- package/dist/hooks/useSubscriptionPeriods.d.ts.map +1 -1
- package/dist/hooks/useSubscriptionPeriods.js +9 -3
- package/dist/hooks/useSubscriptions.d.ts +16 -2
- package/dist/hooks/useSubscriptions.d.ts.map +1 -1
- package/dist/hooks/useSubscriptions.js +28 -3
- package/dist/hooks/useUserSubscription.d.ts +18 -1
- package/dist/hooks/useUserSubscription.d.ts.map +1 -1
- package/dist/hooks/useUserSubscription.js +30 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/types/adapter.d.ts +8 -0
- package/dist/types/adapter.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Core Exports
|
|
3
3
|
*/
|
|
4
4
|
export { SubscriptionService, type SubscriptionServiceConfig } from './service';
|
|
5
|
-
export { initializeSubscription, getSubscriptionInstance, isSubscriptionInitialized, resetSubscription, refreshSubscription, type SubscriptionConfig, } from './singleton';
|
|
5
|
+
export { initializeSubscription, getSubscriptionInstance, isSubscriptionInitialized, resetSubscription, refreshSubscription, setSubscriptionUserId, getSubscriptionUserId, onSubscriptionUserIdChange, type SubscriptionConfig, } from './singleton';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,KAAK,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAEhF,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,KAAK,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAEhF,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC"}
|
package/dist/core/index.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Core Exports
|
|
3
3
|
*/
|
|
4
4
|
export { SubscriptionService } from './service';
|
|
5
|
-
export { initializeSubscription, getSubscriptionInstance, isSubscriptionInitialized, resetSubscription, refreshSubscription, } from './singleton';
|
|
5
|
+
export { initializeSubscription, getSubscriptionInstance, isSubscriptionInitialized, resetSubscription, refreshSubscription, setSubscriptionUserId, getSubscriptionUserId, onSubscriptionUserIdChange, } from './singleton';
|
package/dist/core/service.d.ts
CHANGED
|
@@ -22,15 +22,21 @@ export declare class SubscriptionService {
|
|
|
22
22
|
private freeTier;
|
|
23
23
|
private offersCache;
|
|
24
24
|
private currentSubscription;
|
|
25
|
-
private
|
|
25
|
+
private loadOfferingsPromise;
|
|
26
26
|
private isLoadingCustomerInfo;
|
|
27
27
|
constructor(config: SubscriptionServiceConfig);
|
|
28
28
|
/**
|
|
29
|
-
* Load offerings from RevenueCat
|
|
29
|
+
* Load offerings from RevenueCat.
|
|
30
|
+
* Multiple concurrent calls will share the same promise.
|
|
31
|
+
* If already loaded, returns immediately.
|
|
30
32
|
*/
|
|
31
33
|
loadOfferings(params?: {
|
|
32
34
|
currency?: string;
|
|
33
35
|
}): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Internal method to actually load offerings
|
|
38
|
+
*/
|
|
39
|
+
private doLoadOfferings;
|
|
34
40
|
/**
|
|
35
41
|
* Load customer info from RevenueCat
|
|
36
42
|
*/
|
|
@@ -67,6 +73,11 @@ export declare class SubscriptionService {
|
|
|
67
73
|
* Check if customer info is loaded
|
|
68
74
|
*/
|
|
69
75
|
hasLoadedCustomerInfo(): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Clear customer info cache (e.g., when user changes).
|
|
78
|
+
* Offerings cache is preserved since products don't change with user.
|
|
79
|
+
*/
|
|
80
|
+
clearCustomerInfo(): void;
|
|
70
81
|
private parseOffering;
|
|
71
82
|
private parsePackage;
|
|
72
83
|
private extractEntitlementsFromMetadata;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/core/service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAGV,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EAEpB,MAAM,uBAAuB,CAA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;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI;IAInD;;OAEG;IACH,WAAW,IAAI,MAAM,EAAE;IAIvB;;OAEG;IACH,sBAAsB,IAAI,mBAAmB,GAAG,IAAI;IAIpD;;OAEG;IACH,kBAAkB,IAAI,mBAAmB;IASzC;;OAEG;IACH,iBAAiB,IAAI,cAAc;IAInC;;OAEG;IACG,QAAQ,CACZ,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IASjC;;OAEG;IACH,kBAAkB,IAAI,OAAO;IAI7B;;OAEG;IACH,qBAAqB,IAAI,OAAO;IAIhC;;;OAGG;IACH,iBAAiB,IAAI,IAAI;IAQzB,OAAO,CAAC,aAAa;IAsBrB,OAAO,CAAC,YAAY;IAgCpB,OAAO,CAAC,+BAA+B;CA6BxC"}
|
package/dist/core/service.js
CHANGED
|
@@ -33,11 +33,11 @@ export class SubscriptionService {
|
|
|
33
33
|
writable: true,
|
|
34
34
|
value: null
|
|
35
35
|
});
|
|
36
|
-
Object.defineProperty(this, "
|
|
36
|
+
Object.defineProperty(this, "loadOfferingsPromise", {
|
|
37
37
|
enumerable: true,
|
|
38
38
|
configurable: true,
|
|
39
39
|
writable: true,
|
|
40
|
-
value:
|
|
40
|
+
value: null
|
|
41
41
|
});
|
|
42
42
|
Object.defineProperty(this, "isLoadingCustomerInfo", {
|
|
43
43
|
enumerable: true,
|
|
@@ -52,27 +52,41 @@ export class SubscriptionService {
|
|
|
52
52
|
// Data Loading
|
|
53
53
|
// ---------------------------------------------------------------------------
|
|
54
54
|
/**
|
|
55
|
-
* Load offerings from RevenueCat
|
|
55
|
+
* Load offerings from RevenueCat.
|
|
56
|
+
* Multiple concurrent calls will share the same promise.
|
|
57
|
+
* If already loaded, returns immediately.
|
|
56
58
|
*/
|
|
57
59
|
async loadOfferings(params) {
|
|
58
|
-
|
|
60
|
+
// If already loaded, don't reload
|
|
61
|
+
if (this.offersCache.size > 0) {
|
|
59
62
|
return;
|
|
60
|
-
|
|
63
|
+
}
|
|
64
|
+
// If already loading, wait for that load to complete
|
|
65
|
+
if (this.loadOfferingsPromise) {
|
|
66
|
+
return this.loadOfferingsPromise;
|
|
67
|
+
}
|
|
68
|
+
// Start loading
|
|
69
|
+
this.loadOfferingsPromise = this.doLoadOfferings(params);
|
|
61
70
|
try {
|
|
62
|
-
|
|
63
|
-
this.offersCache.clear();
|
|
64
|
-
for (const [offerId, offering] of Object.entries(offerings.all)) {
|
|
65
|
-
const parsedOffer = this.parseOffering(offerId, offering);
|
|
66
|
-
this.offersCache.set(offerId, parsedOffer);
|
|
67
|
-
}
|
|
68
|
-
// Also add current offering as 'default' if available
|
|
69
|
-
if (offerings.current && !this.offersCache.has('default')) {
|
|
70
|
-
const parsedOffer = this.parseOffering('default', offerings.current);
|
|
71
|
-
this.offersCache.set('default', parsedOffer);
|
|
72
|
-
}
|
|
71
|
+
await this.loadOfferingsPromise;
|
|
73
72
|
}
|
|
74
73
|
finally {
|
|
75
|
-
this.
|
|
74
|
+
this.loadOfferingsPromise = null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Internal method to actually load offerings
|
|
79
|
+
*/
|
|
80
|
+
async doLoadOfferings(params) {
|
|
81
|
+
const offerings = await this.adapter.getOfferings(params);
|
|
82
|
+
for (const [offerId, offering] of Object.entries(offerings.all)) {
|
|
83
|
+
const parsedOffer = this.parseOffering(offerId, offering);
|
|
84
|
+
this.offersCache.set(offerId, parsedOffer);
|
|
85
|
+
}
|
|
86
|
+
// Also add current offering as 'default' if available
|
|
87
|
+
if (offerings.current && !this.offersCache.has('default')) {
|
|
88
|
+
const parsedOffer = this.parseOffering('default', offerings.current);
|
|
89
|
+
this.offersCache.set('default', parsedOffer);
|
|
76
90
|
}
|
|
77
91
|
}
|
|
78
92
|
/**
|
|
@@ -183,6 +197,13 @@ export class SubscriptionService {
|
|
|
183
197
|
hasLoadedCustomerInfo() {
|
|
184
198
|
return this.currentSubscription !== null;
|
|
185
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Clear customer info cache (e.g., when user changes).
|
|
202
|
+
* Offerings cache is preserved since products don't change with user.
|
|
203
|
+
*/
|
|
204
|
+
clearCustomerInfo() {
|
|
205
|
+
this.currentSubscription = null;
|
|
206
|
+
}
|
|
186
207
|
// ---------------------------------------------------------------------------
|
|
187
208
|
// Private Helpers
|
|
188
209
|
// ---------------------------------------------------------------------------
|
package/dist/core/singleton.d.ts
CHANGED
|
@@ -62,4 +62,34 @@ export declare function resetSubscription(): void;
|
|
|
62
62
|
* ```
|
|
63
63
|
*/
|
|
64
64
|
export declare function refreshSubscription(): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Set the user ID for the subscription service.
|
|
67
|
+
* This will re-initialize RevenueCat with the new user and reload customer info.
|
|
68
|
+
* Offerings (product catalog) are preserved since they don't change with user.
|
|
69
|
+
*
|
|
70
|
+
* @param userId User identifier, or undefined to clear (logout)
|
|
71
|
+
* @param email Optional email for the user
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* import { setSubscriptionUserId } from '@sudobility/subscription_lib';
|
|
76
|
+
*
|
|
77
|
+
* // On login
|
|
78
|
+
* await setSubscriptionUserId(user.uid, user.email);
|
|
79
|
+
*
|
|
80
|
+
* // On logout
|
|
81
|
+
* await setSubscriptionUserId(undefined);
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare function setSubscriptionUserId(userId: string | undefined, email?: string): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Get the current user ID
|
|
87
|
+
*/
|
|
88
|
+
export declare function getSubscriptionUserId(): string | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Subscribe to user ID changes
|
|
91
|
+
* @param listener Callback to invoke when user ID changes
|
|
92
|
+
* @returns Unsubscribe function
|
|
93
|
+
*/
|
|
94
|
+
export declare function onSubscriptionUserIdChange(listener: () => void): () => void;
|
|
65
95
|
//# sourceMappingURL=singleton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../../src/core/singleton.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,wCAAwC;IACxC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,8BAA8B;IAC9B,QAAQ,EAAE,cAAc,CAAC;CAC1B;
|
|
1
|
+
{"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../../src/core/singleton.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,wCAAwC;IACxC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,8BAA8B;IAC9B,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAOD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAMvE;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,mBAAmB,CAO7D;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,OAAO,CAEnD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAKzD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAuBf;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,SAAS,CAE1D;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAQ3E"}
|
package/dist/core/singleton.js
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { SubscriptionService } from './service';
|
|
7
7
|
let instance = null;
|
|
8
|
+
let currentAdapter = null;
|
|
9
|
+
let currentUserId = undefined;
|
|
10
|
+
const userIdChangeListeners = [];
|
|
8
11
|
/**
|
|
9
12
|
* Initialize the subscription singleton
|
|
10
13
|
*
|
|
@@ -24,6 +27,7 @@ let instance = null;
|
|
|
24
27
|
* ```
|
|
25
28
|
*/
|
|
26
29
|
export function initializeSubscription(config) {
|
|
30
|
+
currentAdapter = config.adapter;
|
|
27
31
|
instance = new SubscriptionService({
|
|
28
32
|
adapter: config.adapter,
|
|
29
33
|
freeTier: config.freeTier,
|
|
@@ -71,3 +75,62 @@ export async function refreshSubscription() {
|
|
|
71
75
|
}
|
|
72
76
|
await Promise.all([instance.loadOfferings(), instance.loadCustomerInfo()]);
|
|
73
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Set the user ID for the subscription service.
|
|
80
|
+
* This will re-initialize RevenueCat with the new user and reload customer info.
|
|
81
|
+
* Offerings (product catalog) are preserved since they don't change with user.
|
|
82
|
+
*
|
|
83
|
+
* @param userId User identifier, or undefined to clear (logout)
|
|
84
|
+
* @param email Optional email for the user
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* import { setSubscriptionUserId } from '@sudobility/subscription_lib';
|
|
89
|
+
*
|
|
90
|
+
* // On login
|
|
91
|
+
* await setSubscriptionUserId(user.uid, user.email);
|
|
92
|
+
*
|
|
93
|
+
* // On logout
|
|
94
|
+
* await setSubscriptionUserId(undefined);
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export async function setSubscriptionUserId(userId, email) {
|
|
98
|
+
// Skip if same user
|
|
99
|
+
if (currentUserId === userId) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
console.log('[subscription_lib] Setting user ID:', { userId, email });
|
|
103
|
+
currentUserId = userId;
|
|
104
|
+
// Call adapter's setUserId if available
|
|
105
|
+
if (currentAdapter?.setUserId) {
|
|
106
|
+
await currentAdapter.setUserId(userId, email);
|
|
107
|
+
}
|
|
108
|
+
// Clear only customer info cache (preserve offerings)
|
|
109
|
+
if (instance) {
|
|
110
|
+
instance.clearCustomerInfo();
|
|
111
|
+
}
|
|
112
|
+
// Notify listeners (so they can reload customer info)
|
|
113
|
+
for (const listener of userIdChangeListeners) {
|
|
114
|
+
listener();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get the current user ID
|
|
119
|
+
*/
|
|
120
|
+
export function getSubscriptionUserId() {
|
|
121
|
+
return currentUserId;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Subscribe to user ID changes
|
|
125
|
+
* @param listener Callback to invoke when user ID changes
|
|
126
|
+
* @returns Unsubscribe function
|
|
127
|
+
*/
|
|
128
|
+
export function onSubscriptionUserIdChange(listener) {
|
|
129
|
+
userIdChangeListeners.push(listener);
|
|
130
|
+
return () => {
|
|
131
|
+
const index = userIdChangeListeners.indexOf(listener);
|
|
132
|
+
if (index >= 0) {
|
|
133
|
+
userIdChangeListeners.splice(index, 1);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hook Exports
|
|
3
3
|
*/
|
|
4
|
-
export { useSubscriptions, type UseSubscriptionsResult, } from './useSubscriptions';
|
|
5
|
-
export { useUserSubscription, type UseUserSubscriptionResult, } from './useUserSubscription';
|
|
4
|
+
export { useSubscriptions, type UseSubscriptionsResult, type UseSubscriptionsOptions, } from './useSubscriptions';
|
|
5
|
+
export { useUserSubscription, type UseUserSubscriptionResult, type UseUserSubscriptionOptions, } from './useUserSubscription';
|
|
6
6
|
export { useSubscriptionPeriods, type UseSubscriptionPeriodsResult, } from './useSubscriptionPeriods';
|
|
7
7
|
export { useSubscriptionForPeriod, type UseSubscriptionForPeriodResult, } from './useSubscriptionForPeriod';
|
|
8
|
-
export { useSubscribable, type UseSubscribableResult } from './useSubscribable';
|
|
8
|
+
export { useSubscribable, type UseSubscribableResult, type UseSubscribableOptions, } from './useSubscribable';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,gBAAgB,EAChB,KAAK,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,gBAAgB,EAChB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,GAC7B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,mBAAmB,EACnB,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,GAChC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,sBAAsB,EACtB,KAAK,4BAA4B,GAClC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,wBAAwB,EACxB,KAAK,8BAA8B,GACpC,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,mBAAmB,CAAC"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -5,4 +5,4 @@ export { useSubscriptions, } from './useSubscriptions';
|
|
|
5
5
|
export { useUserSubscription, } from './useUserSubscription';
|
|
6
6
|
export { useSubscriptionPeriods, } from './useSubscriptionPeriods';
|
|
7
7
|
export { useSubscriptionForPeriod, } from './useSubscriptionForPeriod';
|
|
8
|
-
export { useSubscribable } from './useSubscribable';
|
|
8
|
+
export { useSubscribable, } from './useSubscribable';
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Get packages that the user can subscribe to or upgrade to.
|
|
5
5
|
*/
|
|
6
|
+
import { type UseSubscriptionsOptions } from './useSubscriptions';
|
|
6
7
|
/**
|
|
7
8
|
* Result of useSubscribable hook
|
|
8
9
|
*/
|
|
@@ -14,6 +15,10 @@ export interface UseSubscribableResult {
|
|
|
14
15
|
/** Error if loading failed */
|
|
15
16
|
error: Error | null;
|
|
16
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Options for useSubscribable hook
|
|
20
|
+
*/
|
|
21
|
+
export type UseSubscribableOptions = UseSubscriptionsOptions;
|
|
17
22
|
/**
|
|
18
23
|
* Hook to get packages that the user can subscribe to or upgrade to
|
|
19
24
|
*
|
|
@@ -26,11 +31,18 @@ export interface UseSubscribableResult {
|
|
|
26
31
|
* - Level is determined by price comparison within the same period
|
|
27
32
|
*
|
|
28
33
|
* @param offerId Offer identifier
|
|
34
|
+
* @param options Optional configuration including userId
|
|
29
35
|
* @returns List of subscribable package IDs
|
|
30
36
|
*
|
|
31
37
|
* @example
|
|
32
38
|
* ```typescript
|
|
33
39
|
* const { subscribablePackageIds } = useSubscribable('default');
|
|
40
|
+
*
|
|
41
|
+
* // With user ID
|
|
42
|
+
* const { subscribablePackageIds } = useSubscribable('default', {
|
|
43
|
+
* userId: user?.uid,
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
34
46
|
* const { packages } = useSubscriptionForPeriod('default', 'monthly');
|
|
35
47
|
*
|
|
36
48
|
* return (
|
|
@@ -46,5 +58,5 @@ export interface UseSubscribableResult {
|
|
|
46
58
|
* );
|
|
47
59
|
* ```
|
|
48
60
|
*/
|
|
49
|
-
export declare function useSubscribable(offerId: string): UseSubscribableResult;
|
|
61
|
+
export declare function useSubscribable(offerId: string, options?: UseSubscribableOptions): UseSubscribableResult;
|
|
50
62
|
//# sourceMappingURL=useSubscribable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSubscribable.d.ts","sourceRoot":"","sources":["../../src/hooks/useSubscribable.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"useSubscribable.d.ts","sourceRoot":"","sources":["../../src/hooks/useSubscribable.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAC;AAQ5B;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,yDAAyD;IACzD,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,mCAAmC;IACnC,SAAS,EAAE,OAAO,CAAC;IACnB,8BAA8B;IAC9B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,sBAAsB,GAC/B,qBAAqB,CAkFvB"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Get packages that the user can subscribe to or upgrade to.
|
|
5
5
|
*/
|
|
6
6
|
import { useMemo } from 'react';
|
|
7
|
-
import { useSubscriptions } from './useSubscriptions';
|
|
7
|
+
import { useSubscriptions, } from './useSubscriptions';
|
|
8
8
|
import { useUserSubscription } from './useUserSubscription';
|
|
9
9
|
import { findUpgradeablePackages } from '../utils/level-calculator';
|
|
10
10
|
import { getSubscriptionInstance, isSubscriptionInitialized, } from '../core/singleton';
|
|
@@ -20,11 +20,18 @@ import { getSubscriptionInstance, isSubscriptionInitialized, } from '../core/sin
|
|
|
20
20
|
* - Level is determined by price comparison within the same period
|
|
21
21
|
*
|
|
22
22
|
* @param offerId Offer identifier
|
|
23
|
+
* @param options Optional configuration including userId
|
|
23
24
|
* @returns List of subscribable package IDs
|
|
24
25
|
*
|
|
25
26
|
* @example
|
|
26
27
|
* ```typescript
|
|
27
28
|
* const { subscribablePackageIds } = useSubscribable('default');
|
|
29
|
+
*
|
|
30
|
+
* // With user ID
|
|
31
|
+
* const { subscribablePackageIds } = useSubscribable('default', {
|
|
32
|
+
* userId: user?.uid,
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
28
35
|
* const { packages } = useSubscriptionForPeriod('default', 'monthly');
|
|
29
36
|
*
|
|
30
37
|
* return (
|
|
@@ -40,13 +47,22 @@ import { getSubscriptionInstance, isSubscriptionInitialized, } from '../core/sin
|
|
|
40
47
|
* );
|
|
41
48
|
* ```
|
|
42
49
|
*/
|
|
43
|
-
export function useSubscribable(offerId) {
|
|
44
|
-
const { offer, isLoading: loadingOffer, error: offerError, } = useSubscriptions(offerId);
|
|
45
|
-
const { subscription, isLoading: loadingSub, error: subError, } = useUserSubscription();
|
|
50
|
+
export function useSubscribable(offerId, options) {
|
|
51
|
+
const { offer, isLoading: loadingOffer, error: offerError, } = useSubscriptions(offerId, options);
|
|
52
|
+
const { subscription, isLoading: loadingSub, error: subError, } = useUserSubscription(options);
|
|
46
53
|
const isLoading = loadingOffer || loadingSub;
|
|
47
54
|
const error = offerError || subError;
|
|
48
55
|
const subscribablePackageIds = useMemo(() => {
|
|
56
|
+
console.log('[useSubscribable] Computing subscribablePackageIds:', {
|
|
57
|
+
offerId,
|
|
58
|
+
hasOffer: !!offer,
|
|
59
|
+
offerPackageCount: offer?.packages.length ?? 0,
|
|
60
|
+
offerPackageIds: offer?.packages.map(p => p.packageId),
|
|
61
|
+
subscription,
|
|
62
|
+
isSubscriptionInitialized: isSubscriptionInitialized(),
|
|
63
|
+
});
|
|
49
64
|
if (!offer) {
|
|
65
|
+
console.log('[useSubscribable] No offer, returning empty array');
|
|
50
66
|
return [];
|
|
51
67
|
}
|
|
52
68
|
// Get all packages including free tier
|
|
@@ -55,14 +71,18 @@ export function useSubscribable(offerId) {
|
|
|
55
71
|
if (isSubscriptionInitialized()) {
|
|
56
72
|
const service = getSubscriptionInstance();
|
|
57
73
|
const freeTier = service.getFreeTierPackage();
|
|
74
|
+
console.log('[useSubscribable] Free tier:', freeTier);
|
|
58
75
|
// Only add if not already in the list
|
|
59
76
|
if (!allPackages.some(p => p.packageId === freeTier.packageId)) {
|
|
60
77
|
allPackages = [freeTier, ...allPackages];
|
|
61
78
|
}
|
|
62
79
|
}
|
|
80
|
+
console.log('[useSubscribable] All packages:', allPackages.map(p => p.packageId));
|
|
63
81
|
// No subscription or inactive = all packages subscribable
|
|
64
82
|
if (!subscription || !subscription.isActive) {
|
|
65
|
-
|
|
83
|
+
const result = allPackages.map(p => p.packageId);
|
|
84
|
+
console.log('[useSubscribable] No active subscription, returning all:', result);
|
|
85
|
+
return result;
|
|
66
86
|
}
|
|
67
87
|
// Pass both packageId and productId for matching
|
|
68
88
|
const current = {
|
|
@@ -71,10 +91,14 @@ export function useSubscribable(offerId) {
|
|
|
71
91
|
};
|
|
72
92
|
// If we don't know the current package or product, return all (shouldn't happen)
|
|
73
93
|
if (!current.packageId && !current.productId) {
|
|
74
|
-
|
|
94
|
+
const result = allPackages.map(p => p.packageId);
|
|
95
|
+
console.log('[useSubscribable] No current package/product, returning all:', result);
|
|
96
|
+
return result;
|
|
75
97
|
}
|
|
76
98
|
// Calculate upgradeable packages
|
|
77
|
-
|
|
99
|
+
const result = findUpgradeablePackages(current, allPackages);
|
|
100
|
+
console.log('[useSubscribable] Upgradeable packages:', result);
|
|
101
|
+
return result;
|
|
78
102
|
}, [offer, subscription]);
|
|
79
103
|
return { subscribablePackageIds, isLoading, error };
|
|
80
104
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { SubscriptionPackage } from '../types/subscription';
|
|
7
7
|
import type { SubscriptionPeriod } from '../types/period';
|
|
8
|
+
import { type UseSubscriptionsOptions } from './useSubscriptions';
|
|
8
9
|
/**
|
|
9
10
|
* Result of useSubscriptionForPeriod hook
|
|
10
11
|
*/
|
|
@@ -25,12 +26,18 @@ export interface UseSubscriptionForPeriodResult {
|
|
|
25
26
|
*
|
|
26
27
|
* @param offerId Offer identifier
|
|
27
28
|
* @param period Billing period to filter by
|
|
29
|
+
* @param options Optional configuration including userId
|
|
28
30
|
* @returns Filtered and sorted packages
|
|
29
31
|
*
|
|
30
32
|
* @example
|
|
31
33
|
* ```typescript
|
|
32
34
|
* const { packages, isLoading } = useSubscriptionForPeriod('default', 'monthly');
|
|
33
35
|
*
|
|
36
|
+
* // With user ID
|
|
37
|
+
* const { packages, isLoading } = useSubscriptionForPeriod('default', 'monthly', {
|
|
38
|
+
* userId: user?.uid,
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
34
41
|
* return (
|
|
35
42
|
* <div className="grid">
|
|
36
43
|
* {packages.map(pkg => (
|
|
@@ -44,5 +51,5 @@ export interface UseSubscriptionForPeriodResult {
|
|
|
44
51
|
* );
|
|
45
52
|
* ```
|
|
46
53
|
*/
|
|
47
|
-
export declare function useSubscriptionForPeriod(offerId: string, period: SubscriptionPeriod): UseSubscriptionForPeriodResult;
|
|
54
|
+
export declare function useSubscriptionForPeriod(offerId: string, period: SubscriptionPeriod, options?: UseSubscriptionsOptions): UseSubscriptionForPeriodResult;
|
|
48
55
|
//# sourceMappingURL=useSubscriptionForPeriod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSubscriptionForPeriod.d.ts","sourceRoot":"","sources":["../../src/hooks/useSubscriptionForPeriod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"useSubscriptionForPeriod.d.ts","sourceRoot":"","sources":["../../src/hooks/useSubscriptionForPeriod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAC;AAM5B;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,qFAAqF;IACrF,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,mCAAmC;IACnC,SAAS,EAAE,OAAO,CAAC;IACnB,8BAA8B;IAC9B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,kBAAkB,EAC1B,OAAO,CAAC,EAAE,uBAAuB,GAChC,8BAA8B,CA6BhC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Get packages filtered by billing period, sorted by price.
|
|
5
5
|
*/
|
|
6
6
|
import { useMemo } from 'react';
|
|
7
|
-
import { useSubscriptions } from './useSubscriptions';
|
|
7
|
+
import { useSubscriptions, } from './useSubscriptions';
|
|
8
8
|
import { getSubscriptionInstance, isSubscriptionInitialized, } from '../core/singleton';
|
|
9
9
|
/**
|
|
10
10
|
* Hook to get packages filtered by billing period
|
|
@@ -15,12 +15,18 @@ import { getSubscriptionInstance, isSubscriptionInitialized, } from '../core/sin
|
|
|
15
15
|
*
|
|
16
16
|
* @param offerId Offer identifier
|
|
17
17
|
* @param period Billing period to filter by
|
|
18
|
+
* @param options Optional configuration including userId
|
|
18
19
|
* @returns Filtered and sorted packages
|
|
19
20
|
*
|
|
20
21
|
* @example
|
|
21
22
|
* ```typescript
|
|
22
23
|
* const { packages, isLoading } = useSubscriptionForPeriod('default', 'monthly');
|
|
23
24
|
*
|
|
25
|
+
* // With user ID
|
|
26
|
+
* const { packages, isLoading } = useSubscriptionForPeriod('default', 'monthly', {
|
|
27
|
+
* userId: user?.uid,
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
24
30
|
* return (
|
|
25
31
|
* <div className="grid">
|
|
26
32
|
* {packages.map(pkg => (
|
|
@@ -34,8 +40,8 @@ import { getSubscriptionInstance, isSubscriptionInitialized, } from '../core/sin
|
|
|
34
40
|
* );
|
|
35
41
|
* ```
|
|
36
42
|
*/
|
|
37
|
-
export function useSubscriptionForPeriod(offerId, period) {
|
|
38
|
-
const { offer, isLoading, error } = useSubscriptions(offerId);
|
|
43
|
+
export function useSubscriptionForPeriod(offerId, period, options) {
|
|
44
|
+
const { offer, isLoading, error } = useSubscriptions(offerId, options);
|
|
39
45
|
const packages = useMemo(() => {
|
|
40
46
|
if (!offer)
|
|
41
47
|
return [];
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Extract unique billing periods from an offer's packages.
|
|
5
5
|
*/
|
|
6
6
|
import type { SubscriptionPeriod } from '../types/period';
|
|
7
|
+
import { type UseSubscriptionsOptions } from './useSubscriptions';
|
|
7
8
|
/**
|
|
8
9
|
* Result of useSubscriptionPeriods hook
|
|
9
10
|
*/
|
|
@@ -19,12 +20,18 @@ export interface UseSubscriptionPeriodsResult {
|
|
|
19
20
|
* Hook to get available billing periods from an offer
|
|
20
21
|
*
|
|
21
22
|
* @param offerId Offer identifier
|
|
23
|
+
* @param options Optional configuration including userId
|
|
22
24
|
* @returns Available periods, sorted from shortest to longest
|
|
23
25
|
*
|
|
24
26
|
* @example
|
|
25
27
|
* ```typescript
|
|
26
28
|
* const { periods, isLoading } = useSubscriptionPeriods('default');
|
|
27
29
|
*
|
|
30
|
+
* // With user ID
|
|
31
|
+
* const { periods, isLoading } = useSubscriptionPeriods('default', {
|
|
32
|
+
* userId: user?.uid,
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
28
35
|
* return (
|
|
29
36
|
* <SegmentedControl
|
|
30
37
|
* options={periods.map(p => ({ value: p, label: capitalize(p) }))}
|
|
@@ -34,5 +41,5 @@ export interface UseSubscriptionPeriodsResult {
|
|
|
34
41
|
* );
|
|
35
42
|
* ```
|
|
36
43
|
*/
|
|
37
|
-
export declare function useSubscriptionPeriods(offerId: string): UseSubscriptionPeriodsResult;
|
|
44
|
+
export declare function useSubscriptionPeriods(offerId: string, options?: UseSubscriptionsOptions): UseSubscriptionPeriodsResult;
|
|
38
45
|
//# sourceMappingURL=useSubscriptionPeriods.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSubscriptionPeriods.d.ts","sourceRoot":"","sources":["../../src/hooks/useSubscriptionPeriods.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"useSubscriptionPeriods.d.ts","sourceRoot":"","sources":["../../src/hooks/useSubscriptionPeriods.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,kFAAkF;IAClF,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,mCAAmC;IACnC,SAAS,EAAE,OAAO,CAAC;IACnB,8BAA8B;IAC9B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,uBAAuB,GAChC,4BAA4B,CAoB9B"}
|
|
@@ -5,17 +5,23 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { useMemo } from 'react';
|
|
7
7
|
import { ALL_PERIODS } from '../types/period';
|
|
8
|
-
import { useSubscriptions } from './useSubscriptions';
|
|
8
|
+
import { useSubscriptions, } from './useSubscriptions';
|
|
9
9
|
/**
|
|
10
10
|
* Hook to get available billing periods from an offer
|
|
11
11
|
*
|
|
12
12
|
* @param offerId Offer identifier
|
|
13
|
+
* @param options Optional configuration including userId
|
|
13
14
|
* @returns Available periods, sorted from shortest to longest
|
|
14
15
|
*
|
|
15
16
|
* @example
|
|
16
17
|
* ```typescript
|
|
17
18
|
* const { periods, isLoading } = useSubscriptionPeriods('default');
|
|
18
19
|
*
|
|
20
|
+
* // With user ID
|
|
21
|
+
* const { periods, isLoading } = useSubscriptionPeriods('default', {
|
|
22
|
+
* userId: user?.uid,
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
19
25
|
* return (
|
|
20
26
|
* <SegmentedControl
|
|
21
27
|
* options={periods.map(p => ({ value: p, label: capitalize(p) }))}
|
|
@@ -25,8 +31,8 @@ import { useSubscriptions } from './useSubscriptions';
|
|
|
25
31
|
* );
|
|
26
32
|
* ```
|
|
27
33
|
*/
|
|
28
|
-
export function useSubscriptionPeriods(offerId) {
|
|
29
|
-
const { offer, isLoading, error } = useSubscriptions(offerId);
|
|
34
|
+
export function useSubscriptionPeriods(offerId, options) {
|
|
35
|
+
const { offer, isLoading, error } = useSubscriptions(offerId, options);
|
|
30
36
|
const periods = useMemo(() => {
|
|
31
37
|
if (!offer)
|
|
32
38
|
return [];
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* useSubscriptions Hook
|
|
3
3
|
*
|
|
4
4
|
* Fetch and manage subscription offer data.
|
|
5
|
+
* Note: Offerings (product catalog) don't change with user,
|
|
6
|
+
* so this hook doesn't reload when user changes.
|
|
5
7
|
*/
|
|
6
8
|
import type { SubscriptionOffer } from '../types/subscription';
|
|
7
9
|
/**
|
|
@@ -18,9 +20,21 @@ export interface UseSubscriptionsResult {
|
|
|
18
20
|
refetch: () => Promise<void>;
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
21
|
-
*
|
|
23
|
+
* Options for useSubscriptions hook
|
|
24
|
+
* Note: userId is accepted for API consistency but offerings don't change with user.
|
|
25
|
+
*/
|
|
26
|
+
export interface UseSubscriptionsOptions {
|
|
27
|
+
/** Optional user ID (accepted for API consistency, but offerings don't change with user) */
|
|
28
|
+
userId?: string;
|
|
29
|
+
/** Optional email for the user */
|
|
30
|
+
userEmail?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Hook to get subscription offer data (product catalog).
|
|
34
|
+
* Note: Offerings don't change with user, so this hook doesn't need userId.
|
|
22
35
|
*
|
|
23
36
|
* @param offerId Offer identifier to fetch
|
|
37
|
+
* @param _options Optional configuration (userId accepted but not used - offerings are user-independent)
|
|
24
38
|
* @returns Offer data, loading state, and error
|
|
25
39
|
*
|
|
26
40
|
* @example
|
|
@@ -39,5 +53,5 @@ export interface UseSubscriptionsResult {
|
|
|
39
53
|
* );
|
|
40
54
|
* ```
|
|
41
55
|
*/
|
|
42
|
-
export declare function useSubscriptions(offerId: string): UseSubscriptionsResult;
|
|
56
|
+
export declare function useSubscriptions(offerId: string, _options?: UseSubscriptionsOptions): UseSubscriptionsResult;
|
|
43
57
|
//# sourceMappingURL=useSubscriptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSubscriptions.d.ts","sourceRoot":"","sources":["../../src/hooks/useSubscriptions.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"useSubscriptions.d.ts","sourceRoot":"","sources":["../../src/hooks/useSubscriptions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAM/D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,wDAAwD;IACxD,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAChC,mCAAmC;IACnC,SAAS,EAAE,OAAO,CAAC;IACnB,8BAA8B;IAC9B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,gCAAgC;IAChC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,4FAA4F;IAC5F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,uBAAuB,GACjC,sBAAsB,CA4ExB"}
|
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
* useSubscriptions Hook
|
|
3
3
|
*
|
|
4
4
|
* Fetch and manage subscription offer data.
|
|
5
|
+
* Note: Offerings (product catalog) don't change with user,
|
|
6
|
+
* so this hook doesn't reload when user changes.
|
|
5
7
|
*/
|
|
6
8
|
import { useCallback, useEffect, useState } from 'react';
|
|
7
9
|
import { getSubscriptionInstance, isSubscriptionInitialized, } from '../core/singleton';
|
|
8
10
|
/**
|
|
9
|
-
* Hook to get subscription offer data
|
|
11
|
+
* Hook to get subscription offer data (product catalog).
|
|
12
|
+
* Note: Offerings don't change with user, so this hook doesn't need userId.
|
|
10
13
|
*
|
|
11
14
|
* @param offerId Offer identifier to fetch
|
|
15
|
+
* @param _options Optional configuration (userId accepted but not used - offerings are user-independent)
|
|
12
16
|
* @returns Offer data, loading state, and error
|
|
13
17
|
*
|
|
14
18
|
* @example
|
|
@@ -27,34 +31,55 @@ import { getSubscriptionInstance, isSubscriptionInitialized, } from '../core/sin
|
|
|
27
31
|
* );
|
|
28
32
|
* ```
|
|
29
33
|
*/
|
|
30
|
-
export function useSubscriptions(offerId) {
|
|
34
|
+
export function useSubscriptions(offerId, _options) {
|
|
31
35
|
const [offer, setOffer] = useState(null);
|
|
32
36
|
const [isLoading, setIsLoading] = useState(true);
|
|
33
37
|
const [error, setError] = useState(null);
|
|
34
38
|
const loadData = useCallback(async () => {
|
|
35
39
|
if (!isSubscriptionInitialized()) {
|
|
40
|
+
console.log('[useSubscriptions] Subscription not initialized');
|
|
36
41
|
setError(new Error('Subscription not initialized'));
|
|
37
42
|
setIsLoading(false);
|
|
38
43
|
return;
|
|
39
44
|
}
|
|
40
45
|
const service = getSubscriptionInstance();
|
|
46
|
+
// If we already have this offer cached, use it without refetching
|
|
47
|
+
const cachedOffer = service.getOffer(offerId);
|
|
48
|
+
if (cachedOffer) {
|
|
49
|
+
console.log('[useSubscriptions] Using cached offer:', {
|
|
50
|
+
offerId,
|
|
51
|
+
packageCount: cachedOffer.packages.length,
|
|
52
|
+
});
|
|
53
|
+
setOffer(cachedOffer);
|
|
54
|
+
setIsLoading(false);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
41
57
|
try {
|
|
42
58
|
setIsLoading(true);
|
|
43
59
|
setError(null);
|
|
44
|
-
// Load offerings if not already loaded
|
|
60
|
+
// Load offerings only if not already loaded
|
|
45
61
|
if (!service.hasLoadedOfferings()) {
|
|
62
|
+
console.log('[useSubscriptions] Loading offerings...');
|
|
46
63
|
await service.loadOfferings();
|
|
64
|
+
console.log('[useSubscriptions] Offerings loaded');
|
|
47
65
|
}
|
|
48
66
|
const loadedOffer = service.getOffer(offerId);
|
|
67
|
+
console.log('[useSubscriptions] Got offer:', {
|
|
68
|
+
offerId,
|
|
69
|
+
hasOffer: !!loadedOffer,
|
|
70
|
+
packageCount: loadedOffer?.packages.length,
|
|
71
|
+
});
|
|
49
72
|
setOffer(loadedOffer);
|
|
50
73
|
}
|
|
51
74
|
catch (err) {
|
|
75
|
+
console.error('[useSubscriptions] Error loading offer:', err);
|
|
52
76
|
setError(err instanceof Error ? err : new Error('Failed to load offer'));
|
|
53
77
|
}
|
|
54
78
|
finally {
|
|
55
79
|
setIsLoading(false);
|
|
56
80
|
}
|
|
57
81
|
}, [offerId]);
|
|
82
|
+
// Load data on mount only - offerings don't change with user
|
|
58
83
|
useEffect(() => {
|
|
59
84
|
loadData();
|
|
60
85
|
}, [loadData]);
|
|
@@ -17,15 +17,32 @@ export interface UseUserSubscriptionResult {
|
|
|
17
17
|
/** Manually refetch the data */
|
|
18
18
|
refetch: () => Promise<void>;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for useUserSubscription hook
|
|
22
|
+
*/
|
|
23
|
+
export interface UseUserSubscriptionOptions {
|
|
24
|
+
/** Optional user ID. When provided, sets the subscription user and reloads on change. */
|
|
25
|
+
userId?: string;
|
|
26
|
+
/** Optional email for the user */
|
|
27
|
+
userEmail?: string;
|
|
28
|
+
}
|
|
20
29
|
/**
|
|
21
30
|
* Hook to get current user's subscription status
|
|
22
31
|
*
|
|
32
|
+
* @param options Optional configuration including userId
|
|
23
33
|
* @returns Current subscription data, loading state, and error
|
|
24
34
|
*
|
|
25
35
|
* @example
|
|
26
36
|
* ```typescript
|
|
37
|
+
* // Without user ID (anonymous or use existing)
|
|
27
38
|
* const { subscription, isLoading } = useUserSubscription();
|
|
28
39
|
*
|
|
40
|
+
* // With user ID (will re-initialize when user changes)
|
|
41
|
+
* const { subscription, isLoading } = useUserSubscription({
|
|
42
|
+
* userId: user?.uid,
|
|
43
|
+
* userEmail: user?.email,
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
29
46
|
* if (isLoading) return <Spinner />;
|
|
30
47
|
*
|
|
31
48
|
* if (subscription?.isActive) {
|
|
@@ -35,5 +52,5 @@ export interface UseUserSubscriptionResult {
|
|
|
35
52
|
* }
|
|
36
53
|
* ```
|
|
37
54
|
*/
|
|
38
|
-
export declare function useUserSubscription(): UseUserSubscriptionResult;
|
|
55
|
+
export declare function useUserSubscription(options?: UseUserSubscriptionOptions): UseUserSubscriptionResult;
|
|
39
56
|
//# sourceMappingURL=useUserSubscription.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUserSubscription.d.ts","sourceRoot":"","sources":["../../src/hooks/useUserSubscription.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"useUserSubscription.d.ts","sourceRoot":"","sources":["../../src/hooks/useUserSubscription.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AASjE;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,iDAAiD;IACjD,YAAY,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACzC,mCAAmC;IACnC,SAAS,EAAE,OAAO,CAAC;IACnB,8BAA8B;IAC9B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,gCAAgC;IAChC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,yFAAyF;IACzF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,CAAC,EAAE,0BAA0B,GACnC,yBAAyB,CAsF3B"}
|
|
@@ -4,16 +4,24 @@
|
|
|
4
4
|
* Fetch and manage current user's subscription status.
|
|
5
5
|
*/
|
|
6
6
|
import { useCallback, useEffect, useState } from 'react';
|
|
7
|
-
import { getSubscriptionInstance, isSubscriptionInitialized, } from '../core/singleton';
|
|
7
|
+
import { getSubscriptionInstance, getSubscriptionUserId, isSubscriptionInitialized, onSubscriptionUserIdChange, setSubscriptionUserId, } from '../core/singleton';
|
|
8
8
|
/**
|
|
9
9
|
* Hook to get current user's subscription status
|
|
10
10
|
*
|
|
11
|
+
* @param options Optional configuration including userId
|
|
11
12
|
* @returns Current subscription data, loading state, and error
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
15
|
* ```typescript
|
|
16
|
+
* // Without user ID (anonymous or use existing)
|
|
15
17
|
* const { subscription, isLoading } = useUserSubscription();
|
|
16
18
|
*
|
|
19
|
+
* // With user ID (will re-initialize when user changes)
|
|
20
|
+
* const { subscription, isLoading } = useUserSubscription({
|
|
21
|
+
* userId: user?.uid,
|
|
22
|
+
* userEmail: user?.email,
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
17
25
|
* if (isLoading) return <Spinner />;
|
|
18
26
|
*
|
|
19
27
|
* if (subscription?.isActive) {
|
|
@@ -23,10 +31,23 @@ import { getSubscriptionInstance, isSubscriptionInitialized, } from '../core/sin
|
|
|
23
31
|
* }
|
|
24
32
|
* ```
|
|
25
33
|
*/
|
|
26
|
-
export function useUserSubscription() {
|
|
34
|
+
export function useUserSubscription(options) {
|
|
35
|
+
const { userId, userEmail } = options ?? {};
|
|
27
36
|
const [subscription, setSubscription] = useState(null);
|
|
28
37
|
const [isLoading, setIsLoading] = useState(true);
|
|
29
38
|
const [error, setError] = useState(null);
|
|
39
|
+
// Handle user ID changes
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const currentLibUserId = getSubscriptionUserId();
|
|
42
|
+
// Only update if userId is explicitly provided and different
|
|
43
|
+
if (userId !== undefined && userId !== currentLibUserId) {
|
|
44
|
+
console.log('[useUserSubscription] User ID changed, updating subscription user:', {
|
|
45
|
+
from: currentLibUserId,
|
|
46
|
+
to: userId,
|
|
47
|
+
});
|
|
48
|
+
setSubscriptionUserId(userId, userEmail);
|
|
49
|
+
}
|
|
50
|
+
}, [userId, userEmail]);
|
|
30
51
|
const loadData = useCallback(async () => {
|
|
31
52
|
if (!isSubscriptionInitialized()) {
|
|
32
53
|
setError(new Error('Subscription not initialized'));
|
|
@@ -51,8 +72,15 @@ export function useUserSubscription() {
|
|
|
51
72
|
setIsLoading(false);
|
|
52
73
|
}
|
|
53
74
|
}, []);
|
|
75
|
+
// Load data on mount and when userId changes
|
|
54
76
|
useEffect(() => {
|
|
55
77
|
loadData();
|
|
78
|
+
// Subscribe to user ID changes to reload
|
|
79
|
+
const unsubscribe = onSubscriptionUserIdChange(() => {
|
|
80
|
+
console.log('[useUserSubscription] User ID changed, reloading...');
|
|
81
|
+
loadData();
|
|
82
|
+
});
|
|
83
|
+
return unsubscribe;
|
|
56
84
|
}, [loadData]);
|
|
57
85
|
const refetch = useCallback(async () => {
|
|
58
86
|
if (!isSubscriptionInitialized())
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Cross-platform subscription management library with RevenueCat adapter pattern.
|
|
5
5
|
* Works with both React (web) and React Native.
|
|
6
6
|
*/
|
|
7
|
-
export { initializeSubscription, getSubscriptionInstance, isSubscriptionInitialized, resetSubscription, refreshSubscription, SubscriptionService, type SubscriptionConfig, type SubscriptionServiceConfig, } from './core';
|
|
8
|
-
export { useSubscriptions, useUserSubscription, useSubscriptionPeriods, useSubscriptionForPeriod, useSubscribable, type UseSubscriptionsResult, type UseUserSubscriptionResult, type UseSubscriptionPeriodsResult, type UseSubscriptionForPeriodResult, type UseSubscribableResult, } from './hooks';
|
|
7
|
+
export { initializeSubscription, getSubscriptionInstance, isSubscriptionInitialized, resetSubscription, refreshSubscription, setSubscriptionUserId, getSubscriptionUserId, onSubscriptionUserIdChange, SubscriptionService, type SubscriptionConfig, type SubscriptionServiceConfig, } from './core';
|
|
8
|
+
export { useSubscriptions, useUserSubscription, useSubscriptionPeriods, useSubscriptionForPeriod, useSubscribable, type UseSubscriptionsResult, type UseSubscriptionsOptions, type UseUserSubscriptionResult, type UseUserSubscriptionOptions, type UseSubscriptionPeriodsResult, type UseSubscriptionForPeriodResult, type UseSubscribableResult, type UseSubscribableOptions, } from './hooks';
|
|
9
9
|
export type { SubscriptionAdapter, AdapterOfferings, AdapterOffering, AdapterPackage, AdapterProduct, AdapterSubscriptionOption, AdapterPricingPhase, AdapterCustomerInfo, AdapterEntitlementInfo, AdapterPurchaseParams, AdapterPurchaseResult, SubscriptionProduct, SubscriptionPackage, SubscriptionOffer, CurrentSubscription, FreeTierConfig, PackageWithLevel, SubscriptionPeriod, } from './types';
|
|
10
10
|
export { PERIOD_RANKS, ALL_PERIODS } from './types';
|
|
11
11
|
export { parseISO8601Period, getPeriodRank, comparePeriods, isPeriodGreaterOrEqual, calculatePackageLevels, addLevelsToPackages, getPackageLevel, findUpgradeablePackages, } from './utils';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,GAC/B,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EACxB,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,8BAA8B,EACnC,KAAK,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,GAC/B,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EACxB,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EACjC,KAAK,8BAA8B,EACnC,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,SAAS,CAAC;AAGjB,YAAY,EAEV,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EAErB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAEhB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGpD,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,eAAe,EACf,uBAAuB,GACxB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Works with both React (web) and React Native.
|
|
6
6
|
*/
|
|
7
7
|
// Core
|
|
8
|
-
export { initializeSubscription, getSubscriptionInstance, isSubscriptionInitialized, resetSubscription, refreshSubscription, SubscriptionService, } from './core';
|
|
8
|
+
export { initializeSubscription, getSubscriptionInstance, isSubscriptionInitialized, resetSubscription, refreshSubscription, setSubscriptionUserId, getSubscriptionUserId, onSubscriptionUserIdChange, SubscriptionService, } from './core';
|
|
9
9
|
// Hooks
|
|
10
10
|
export { useSubscriptions, useUserSubscription, useSubscriptionPeriods, useSubscriptionForPeriod, useSubscribable, } from './hooks';
|
|
11
11
|
export { PERIOD_RANKS, ALL_PERIODS } from './types';
|
package/dist/types/adapter.d.ts
CHANGED
|
@@ -145,5 +145,13 @@ export interface SubscriptionAdapter {
|
|
|
145
145
|
* @param params Purchase parameters
|
|
146
146
|
*/
|
|
147
147
|
purchase(params: AdapterPurchaseParams): Promise<AdapterPurchaseResult>;
|
|
148
|
+
/**
|
|
149
|
+
* Set the user ID for the subscription service.
|
|
150
|
+
* Pass undefined to clear the user (logout).
|
|
151
|
+
* The adapter should re-initialize RevenueCat with the new user.
|
|
152
|
+
* @param userId User identifier, or undefined to clear
|
|
153
|
+
* @param email Optional email for the user
|
|
154
|
+
*/
|
|
155
|
+
setUserId?(userId: string | undefined, email?: string): Promise<void>;
|
|
148
156
|
}
|
|
149
157
|
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/types/adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,uDAAuD;IACvD,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,iEAAiE;IACjE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,mDAAmD;IACnD,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,gDAAgD;IAChD,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAClC,uDAAuD;IACvD,UAAU,EAAE,mBAAmB,GAAG,IAAI,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,WAAW,EAA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