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.
Files changed (67) hide show
  1. package/CHANGELOG.md +15 -6
  2. package/CLAUDE.md +0 -5
  3. package/CONTRIBUTING.md +3 -4
  4. package/build/ExpoIap.types.d.ts +13 -9
  5. package/build/ExpoIap.types.d.ts.map +1 -1
  6. package/build/ExpoIap.types.js.map +1 -1
  7. package/build/helpers/subscription.d.ts.map +1 -1
  8. package/build/helpers/subscription.js +3 -6
  9. package/build/helpers/subscription.js.map +1 -1
  10. package/build/index.d.ts +6 -6
  11. package/build/index.d.ts.map +1 -1
  12. package/build/index.js.map +1 -1
  13. package/build/modules/android.d.ts.map +1 -1
  14. package/build/modules/android.js.map +1 -1
  15. package/build/modules/ios.d.ts +8 -8
  16. package/build/modules/ios.d.ts.map +1 -1
  17. package/build/modules/ios.js +3 -3
  18. package/build/modules/ios.js.map +1 -1
  19. package/build/types/ExpoIapAndroid.types.d.ts +2 -2
  20. package/build/types/ExpoIapAndroid.types.d.ts.map +1 -1
  21. package/build/types/ExpoIapAndroid.types.js.map +1 -1
  22. package/build/types/ExpoIapIOS.types.d.ts +3 -3
  23. package/build/types/ExpoIapIOS.types.d.ts.map +1 -1
  24. package/build/types/ExpoIapIOS.types.js.map +1 -1
  25. package/build/useIAP.d.ts +6 -6
  26. package/build/useIAP.d.ts.map +1 -1
  27. package/build/useIAP.js.map +1 -1
  28. package/bun.lock +122 -456
  29. package/coverage/clover.xml +601 -0
  30. package/coverage/coverage-final.json +9 -0
  31. package/coverage/lcov-report/base.css +224 -0
  32. package/coverage/lcov-report/block-navigation.js +87 -0
  33. package/coverage/lcov-report/favicon.png +0 -0
  34. package/coverage/lcov-report/index.html +176 -0
  35. package/coverage/lcov-report/prettify.css +1 -0
  36. package/coverage/lcov-report/prettify.js +2 -0
  37. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  38. package/coverage/lcov-report/sorter.js +210 -0
  39. package/coverage/lcov-report/src/ExpoIap.types.ts.html +1243 -0
  40. package/coverage/lcov-report/src/helpers/index.html +116 -0
  41. package/coverage/lcov-report/src/helpers/subscription.ts.html +430 -0
  42. package/coverage/lcov-report/src/index.html +146 -0
  43. package/coverage/lcov-report/src/index.ts.html +2227 -0
  44. package/coverage/lcov-report/src/modules/android.ts.html +469 -0
  45. package/coverage/lcov-report/src/modules/index.html +131 -0
  46. package/coverage/lcov-report/src/modules/ios.ts.html +1411 -0
  47. package/coverage/lcov-report/src/types/ExpoIapAndroid.types.ts.html +487 -0
  48. package/coverage/lcov-report/src/types/index.html +116 -0
  49. package/coverage/lcov-report/src/useIap.ts.html +1483 -0
  50. package/coverage/lcov-report/src/utils/errorMapping.ts.html +349 -0
  51. package/coverage/lcov-report/src/utils/index.html +116 -0
  52. package/coverage/lcov.info +1115 -0
  53. package/ios/expoiap.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  54. package/ios/expoiap.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  55. package/jest.config.js +14 -17
  56. package/package.json +1 -1
  57. package/plugin/build/withIAP.js +26 -3
  58. package/plugin/src/withIAP.ts +35 -3
  59. package/plugin/tsconfig.tsbuildinfo +1 -1
  60. package/src/ExpoIap.types.ts +15 -16
  61. package/src/helpers/subscription.ts +21 -28
  62. package/src/index.ts +16 -21
  63. package/src/modules/android.ts +7 -7
  64. package/src/modules/ios.ts +13 -15
  65. package/src/types/ExpoIapAndroid.types.ts +3 -4
  66. package/src/types/ExpoIapIOS.types.ts +4 -3
  67. 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: 'ios';
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: 'ios';
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: 'ios';
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: ProductPurchase[];
43
+ promotedProductsIOS: Purchase[];
46
44
  promotedProductIdIOS?: string;
47
45
  subscriptions: SubscriptionProduct[];
48
- purchaseHistories: ProductPurchase[];
49
- availablePurchases: ProductPurchase[];
50
- currentPurchase?: ProductPurchase;
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: ProductPurchase | SubscriptionPurchase,
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<ProductPurchase[]>([]);
112
+ const [promotedProductsIOS] = useState<Purchase[]>([]);
115
113
  const [subscriptions, setSubscriptions] = useState<SubscriptionProduct[]>([]);
116
- const [purchaseHistories, setPurchaseHistories] = useState<ProductPurchase[]>(
114
+ const [purchaseHistories, setPurchaseHistories] = useState<Purchase[]>(
117
115
  [],
118
116
  );
119
117
  const [availablePurchases, setAvailablePurchases] = useState<
120
- ProductPurchase[]
118
+ Purchase[]
121
119
  >([]);
122
- const [currentPurchase, setCurrentPurchase] = useState<ProductPurchase>();
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: ProductPurchase;
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 | SubscriptionPurchase) => {
383
+ async (purchase: Purchase) => {
386
384
  setCurrentPurchaseError(undefined);
387
385
  setCurrentPurchase(purchase);
388
386