expo-iap 2.8.1 → 2.8.3-rc.1
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/CHANGELOG.md +15 -6
- package/CLAUDE.md +0 -5
- package/CONTRIBUTING.md +3 -4
- package/build/ExpoIap.types.d.ts +13 -9
- package/build/ExpoIap.types.d.ts.map +1 -1
- package/build/ExpoIap.types.js.map +1 -1
- package/build/helpers/subscription.d.ts.map +1 -1
- package/build/helpers/subscription.js +3 -6
- package/build/helpers/subscription.js.map +1 -1
- package/build/index.d.ts +6 -6
- package/build/index.d.ts.map +1 -1
- package/build/index.js.map +1 -1
- package/build/modules/android.d.ts.map +1 -1
- package/build/modules/android.js.map +1 -1
- package/build/modules/ios.d.ts +8 -8
- package/build/modules/ios.d.ts.map +1 -1
- package/build/modules/ios.js +3 -3
- package/build/modules/ios.js.map +1 -1
- package/build/types/ExpoIapAndroid.types.d.ts +2 -2
- package/build/types/ExpoIapAndroid.types.d.ts.map +1 -1
- package/build/types/ExpoIapAndroid.types.js.map +1 -1
- package/build/types/ExpoIapIOS.types.d.ts +3 -3
- package/build/types/ExpoIapIOS.types.d.ts.map +1 -1
- package/build/types/ExpoIapIOS.types.js.map +1 -1
- package/build/useIAP.d.ts +6 -6
- package/build/useIAP.d.ts.map +1 -1
- package/build/useIAP.js.map +1 -1
- package/bun.lock +122 -456
- package/coverage/clover.xml +601 -0
- package/coverage/coverage-final.json +9 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +176 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov-report/src/ExpoIap.types.ts.html +1243 -0
- package/coverage/lcov-report/src/helpers/index.html +116 -0
- package/coverage/lcov-report/src/helpers/subscription.ts.html +430 -0
- package/coverage/lcov-report/src/index.html +146 -0
- package/coverage/lcov-report/src/index.ts.html +2227 -0
- package/coverage/lcov-report/src/modules/android.ts.html +469 -0
- package/coverage/lcov-report/src/modules/index.html +131 -0
- package/coverage/lcov-report/src/modules/ios.ts.html +1411 -0
- package/coverage/lcov-report/src/types/ExpoIapAndroid.types.ts.html +487 -0
- package/coverage/lcov-report/src/types/index.html +116 -0
- package/coverage/lcov-report/src/useIap.ts.html +1483 -0
- package/coverage/lcov-report/src/utils/errorMapping.ts.html +349 -0
- package/coverage/lcov-report/src/utils/index.html +116 -0
- package/coverage/lcov.info +1115 -0
- package/ios/expoiap.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/expoiap.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/jest.config.js +14 -17
- package/package.json +1 -1
- package/plugin/build/withIAP.js +26 -3
- package/plugin/src/withIAP.ts +35 -3
- package/plugin/tsconfig.tsbuildinfo +1 -1
- package/src/ExpoIap.types.ts +15 -16
- package/src/helpers/subscription.ts +21 -28
- package/src/index.ts +16 -21
- package/src/modules/android.ts +7 -7
- package/src/modules/ios.ts +13 -15
- package/src/types/ExpoIapAndroid.types.ts +3 -4
- package/src/types/ExpoIapIOS.types.ts +4 -3
- package/src/useIAP.ts +11 -13
|
@@ -30,7 +30,7 @@ export type ProductIOS = ProductCommon & {
|
|
|
30
30
|
displayNameIOS: string;
|
|
31
31
|
isFamilyShareableIOS: boolean;
|
|
32
32
|
jsonRepresentationIOS: string;
|
|
33
|
-
platform:
|
|
33
|
+
platform: "ios";
|
|
34
34
|
subscriptionInfoIOS?: SubscriptionInfo;
|
|
35
35
|
/**
|
|
36
36
|
* @deprecated Use `displayNameIOS` instead. This field will be removed in v2.9.0.
|
|
@@ -69,7 +69,7 @@ export type ProductSubscriptionIOS = ProductIOS & {
|
|
|
69
69
|
introductoryPricePaymentModeIOS?: PaymentMode;
|
|
70
70
|
introductoryPriceNumberOfPeriodsIOS?: string;
|
|
71
71
|
introductoryPriceSubscriptionPeriodIOS?: SubscriptionIosPeriod;
|
|
72
|
-
platform:
|
|
72
|
+
platform: "ios";
|
|
73
73
|
subscriptionPeriodNumberIOS?: string;
|
|
74
74
|
subscriptionPeriodUnitIOS?: SubscriptionIosPeriod;
|
|
75
75
|
/**
|
|
@@ -140,7 +140,7 @@ export type ProductStatusIOS = {
|
|
|
140
140
|
// Legacy naming for backward compatibility
|
|
141
141
|
export type ProductPurchaseIOS = PurchaseCommon & {
|
|
142
142
|
// iOS basic fields
|
|
143
|
-
platform:
|
|
143
|
+
platform: "ios";
|
|
144
144
|
quantityIOS?: number;
|
|
145
145
|
originalTransactionDateIOS?: number;
|
|
146
146
|
originalTransactionIdentifierIOS?: string;
|
|
@@ -179,6 +179,7 @@ export type ProductPurchaseIOS = PurchaseCommon & {
|
|
|
179
179
|
// Preferred naming
|
|
180
180
|
export type PurchaseIOS = ProductPurchaseIOS;
|
|
181
181
|
|
|
182
|
+
|
|
182
183
|
export type AppTransactionIOS = {
|
|
183
184
|
appTransactionId?: string; // Only available in iOS 18.4+
|
|
184
185
|
originalPlatform?: string; // Only available in iOS 18.4+
|
package/src/useIAP.ts
CHANGED
|
@@ -29,12 +29,10 @@ import {
|
|
|
29
29
|
// Types
|
|
30
30
|
import {
|
|
31
31
|
Product,
|
|
32
|
-
ProductPurchase,
|
|
33
32
|
Purchase,
|
|
34
33
|
PurchaseError,
|
|
35
34
|
PurchaseResult,
|
|
36
35
|
SubscriptionProduct,
|
|
37
|
-
SubscriptionPurchase,
|
|
38
36
|
RequestPurchaseProps,
|
|
39
37
|
RequestSubscriptionProps,
|
|
40
38
|
} from './ExpoIap.types';
|
|
@@ -42,12 +40,12 @@ import {
|
|
|
42
40
|
type UseIap = {
|
|
43
41
|
connected: boolean;
|
|
44
42
|
products: Product[];
|
|
45
|
-
promotedProductsIOS:
|
|
43
|
+
promotedProductsIOS: Purchase[];
|
|
46
44
|
promotedProductIdIOS?: string;
|
|
47
45
|
subscriptions: SubscriptionProduct[];
|
|
48
|
-
purchaseHistories:
|
|
49
|
-
availablePurchases:
|
|
50
|
-
currentPurchase?:
|
|
46
|
+
purchaseHistories: Purchase[];
|
|
47
|
+
availablePurchases: Purchase[];
|
|
48
|
+
currentPurchase?: Purchase;
|
|
51
49
|
currentPurchaseError?: PurchaseError;
|
|
52
50
|
promotedProductIOS?: Product;
|
|
53
51
|
activeSubscriptions: ActiveSubscription[];
|
|
@@ -100,7 +98,7 @@ type UseIap = {
|
|
|
100
98
|
|
|
101
99
|
export interface UseIAPOptions {
|
|
102
100
|
onPurchaseSuccess?: (
|
|
103
|
-
purchase:
|
|
101
|
+
purchase: Purchase,
|
|
104
102
|
) => void;
|
|
105
103
|
onPurchaseError?: (error: PurchaseError) => void;
|
|
106
104
|
onSyncError?: (error: Error) => void;
|
|
@@ -111,15 +109,15 @@ export interface UseIAPOptions {
|
|
|
111
109
|
export function useIAP(options?: UseIAPOptions): UseIap {
|
|
112
110
|
const [connected, setConnected] = useState<boolean>(false);
|
|
113
111
|
const [products, setProducts] = useState<Product[]>([]);
|
|
114
|
-
const [promotedProductsIOS] = useState<
|
|
112
|
+
const [promotedProductsIOS] = useState<Purchase[]>([]);
|
|
115
113
|
const [subscriptions, setSubscriptions] = useState<SubscriptionProduct[]>([]);
|
|
116
|
-
const [purchaseHistories, setPurchaseHistories] = useState<
|
|
114
|
+
const [purchaseHistories, setPurchaseHistories] = useState<Purchase[]>(
|
|
117
115
|
[],
|
|
118
116
|
);
|
|
119
117
|
const [availablePurchases, setAvailablePurchases] = useState<
|
|
120
|
-
|
|
118
|
+
Purchase[]
|
|
121
119
|
>([]);
|
|
122
|
-
const [currentPurchase, setCurrentPurchase] = useState<
|
|
120
|
+
const [currentPurchase, setCurrentPurchase] = useState<Purchase>();
|
|
123
121
|
const [promotedProductIOS, setPromotedProductIOS] = useState<Product>();
|
|
124
122
|
const [currentPurchaseError, setCurrentPurchaseError] =
|
|
125
123
|
useState<PurchaseError>();
|
|
@@ -289,7 +287,7 @@ export function useIAP(options?: UseIAPOptions): UseIap {
|
|
|
289
287
|
purchase,
|
|
290
288
|
isConsumable,
|
|
291
289
|
}: {
|
|
292
|
-
purchase:
|
|
290
|
+
purchase: Purchase;
|
|
293
291
|
isConsumable?: boolean;
|
|
294
292
|
}): Promise<PurchaseResult | boolean> => {
|
|
295
293
|
try {
|
|
@@ -382,7 +380,7 @@ export function useIAP(options?: UseIAPOptions): UseIap {
|
|
|
382
380
|
|
|
383
381
|
if (result) {
|
|
384
382
|
subscriptionsRef.current.purchaseUpdate = purchaseUpdatedListener(
|
|
385
|
-
async (purchase: Purchase
|
|
383
|
+
async (purchase: Purchase) => {
|
|
386
384
|
setCurrentPurchaseError(undefined);
|
|
387
385
|
setCurrentPurchase(purchase);
|
|
388
386
|
|