decord/source/modules/billing/native/hooks/useMobilePurchaseSKU.android.tsx

440 lines
15 KiB
TypeScript
Raw Normal View History

2026-09-02 09:53:35 +00:00
// Module ID: 10810
// Function ID: 10811
2026-07-24 07:16:23 +00:00
// Name: useMobilePurchaseSKU
2026-09-02 09:53:35 +00:00
// Dependencies: [5, 19, 7178, 1921, 673, 6093, 3, 10701, 5949, 695, 706, 7183, 4154, 1901, 10811, 511, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
2026-09-02 09:53:35 +00:00
// Module 10810 (useMobilePurchaseSKU)
2026-08-24 06:08:38 +00:00
import timestampDefault from "timestamp" /* 3 */;
import closure_3 from "asyncGeneratorStep" /* 5 */;
import closure_4 from "noop" /* 19 */;
2026-09-02 09:53:35 +00:00
import { useNativeCheckoutStoreOrNull as closure_5 } from "context" /* 7178 */;
import closure_6 from "mergeGuildAvatar" /* 1921 */;
import { CurrencyCodes } from "ME" /* 673 */;
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-08-24 06:08:38 +00:00
require("GPlayConnectionState").GPlayBillingResult;
let closure_9 = new timestampDefault("useMobilePurchaseSKU.android");
const tmp2 = new timestampDefault("useMobilePurchaseSKU.android");
let result = require("set").fileFinishedImporting("modules/billing/native/hooks/useMobilePurchaseSKU.android.tsx");
2026-07-20 16:05:17 +00:00
export default function useMobilePurchaseSKU(skuId) {
skuId = skuId.skuId;
2026-07-29 08:29:29 +00:00
let _require = skuId;
2026-07-20 16:05:17 +00:00
const platformSkuId = skuId.platformSkuId;
const analyticsLocations = skuId.analyticsLocations;
let analyticsLoadId = skuId.analyticsLoadId;
2026-08-24 06:08:38 +00:00
let callback = analyticsLoadId;
2026-07-20 16:05:17 +00:00
const analyticsData = skuId.analyticsData;
const onPurchaseComplete = skuId.onPurchaseComplete;
const onPurchaseError = skuId.onPurchaseError;
2026-07-23 10:11:24 +00:00
const freePurchaseCallback = skuId.freePurchaseCallback;
2026-07-20 16:05:17 +00:00
const onPurchasePending = skuId.onPurchasePending;
const giftParams = skuId.giftParams;
let flag = skuId.isFreeForStaffSelfPurchase;
if (flag === undefined) {
flag = true;
}
const orderId = skuId.orderId;
let handlePremiumPurchase;
2026-09-01 10:26:29 +00:00
closure_13 = undefined;
2026-08-24 06:08:38 +00:00
closure_14 = undefined;
closure_15 = undefined;
closure_16 = undefined;
closure_17 = undefined;
2026-07-29 08:29:29 +00:00
let flag2;
2026-08-24 06:08:38 +00:00
callback = undefined;
2026-07-20 16:05:17 +00:00
let callback1;
2026-07-23 10:11:24 +00:00
let callback2;
2026-08-28 06:19:39 +00:00
let callback3;
2026-07-23 10:11:24 +00:00
const currentUser = onPurchaseError.getCurrentUser();
2026-07-29 08:29:29 +00:00
handlePremiumPurchase = _require(analyticsLocations[7]).useHandlePremiumPurchase();
2026-09-01 10:26:29 +00:00
const tmp3 = onPurchaseComplete((setOrder) => setOrder.setOrder);
closure_13 = tmp3;
const tmp4 = onPurchaseComplete((setCheckoutSucceeded) => setCheckoutSucceeded.setCheckoutSucceeded);
2026-08-24 06:08:38 +00:00
closure_14 = tmp4;
2026-09-01 10:26:29 +00:00
const tmp5 = onPurchaseComplete((getPurchaseInFlight) => getPurchaseInFlight.getPurchaseInFlight);
2026-08-24 06:08:38 +00:00
closure_15 = tmp5;
2026-09-01 10:26:29 +00:00
const tmp6 = onPurchaseComplete((setPurchaseInFlight) => setPurchaseInFlight.setPurchaseInFlight);
2026-08-28 06:19:39 +00:00
closure_16 = tmp6;
2026-09-01 10:26:29 +00:00
let tmp7 = onPurchaseComplete((contextMetadata) => contextMetadata.contextMetadata.loadId);
const tmp8 = undefined !== currentUser && currentUser.isStaff();
closure_17 = tmp8;
2026-07-29 08:29:29 +00:00
flag2 = undefined;
2026-09-01 10:26:29 +00:00
let obj2 = _require(analyticsLocations[7]);
const tmp = analyticsLocations;
2026-07-29 08:29:29 +00:00
if (giftParams != null) {
flag2 = giftParams.isGift;
}
if (flag2 == null) {
flag2 = false;
2026-07-20 16:05:17 +00:00
}
if (null == analyticsLoadId) {
2026-09-01 10:26:29 +00:00
if (tmp7 == null) {
tmp7 = tmp9;
2026-08-25 06:04:03 +00:00
}
2026-09-01 10:26:29 +00:00
callback = tmp7;
analyticsLoadId = tmp7;
2026-07-20 16:05:17 +00:00
}
2026-09-01 10:26:29 +00:00
const items = [onPurchaseComplete, tmp4, tmp6];
2026-08-28 06:19:39 +00:00
callback = analyticsData.useCallback(() => {
2026-09-01 10:26:29 +00:00
platformSkuId(analyticsLocations[10]).unsubscribe("GPLAY_PURCHASE_VERIFIED", callback);
if (closure_16 != null) {
2026-08-28 06:19:39 +00:00
tmp2(false);
}
2026-08-24 06:08:38 +00:00
if (callback2 != null) {
callback2();
2026-07-20 16:05:17 +00:00
}
onPurchaseComplete();
}, items);
2026-09-01 10:26:29 +00:00
const items1 = [onPurchaseError, callback, tmp6];
2026-08-28 06:19:39 +00:00
callback1 = analyticsData.useCallback(() => {
2026-09-01 10:26:29 +00:00
platformSkuId(analyticsLocations[10]).unsubscribe("GPLAY_PURCHASE_VERIFIED", callback);
if (closure_16 != null) {
2026-08-28 06:19:39 +00:00
tmp2(false);
}
2026-07-20 16:05:17 +00:00
onPurchaseError();
}, items1);
2026-09-01 10:26:29 +00:00
const items2 = [onPurchaseError, tmp6];
2026-08-28 06:19:39 +00:00
callback2 = analyticsData.useCallback(() => {
2026-09-01 10:26:29 +00:00
if (closure_16 != null) {
2026-08-28 06:19:39 +00:00
tmp(false);
}
onPurchaseError();
}, items2);
2026-07-29 08:29:29 +00:00
_require = undefined;
2026-08-24 06:08:38 +00:00
_require = callback((arg0) => {
closure_0 = arg0;
c5 = 0;
c6 = 0;
c4 = 0;
2026-07-29 08:29:29 +00:00
return (function*(arg0) {
if (v0 === 2) {
v0 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp6 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-09-01 10:26:29 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
v0 = 2;
if (0 === c5) {
if (arg0 === 1) {
v0 = 3;
throw arg1;
} else if (arg0 === 2) {
v0 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
closure_2 = tmp3;
closure_1 = tmp7;
2026-07-29 08:29:29 +00:00
let lib;
if (lib.billingResult === onPurchasePending.OK) {
2026-09-01 10:26:29 +00:00
if (closure_1_16 != null) {
closure_1_16(true);
2026-08-28 06:19:39 +00:00
}
2026-07-29 08:29:29 +00:00
} else {
2026-09-01 10:26:29 +00:00
platformSkuId(analyticsLocations[10]).unsubscribe("GPLAY_PURCHASE_VERIFIED", closure_1_19);
2026-08-24 06:08:38 +00:00
if (null != closure_1_11) {
2026-09-01 10:26:29 +00:00
obj1 = { orderId: null, platformSkuId: null, skuId: null };
obj1[0] = closure_1_11;
obj1[1] = closure_1_1;
obj1[2] = lib;
giftParams.info("[handleGPlayUpdatePurchaseAction] User canceled purchase, canceling order signing", obj1);
c4 = 1;
c5 = 2;
v0 = 1;
const obj2 = { value: null, done: false };
obj2[0] = lib(analyticsLocations[11]).cancelOrderSigning(closure_1_11);
return obj2;
2026-07-29 08:29:29 +00:00
}
2026-09-01 10:26:29 +00:00
const obj11 = platformSkuId(analyticsLocations[10]);
2026-07-29 08:29:29 +00:00
}
2026-08-28 06:19:39 +00:00
closure_1_8();
2026-07-29 08:29:29 +00:00
v0 = 3;
}
2026-08-28 06:19:39 +00:00
} else if (1 === tmp7) {
c4 = 0;
closure_1 = closure_3;
2026-09-01 10:26:29 +00:00
obj1 = lib(analyticsLocations[12]);
2026-08-28 06:19:39 +00:00
const obj3 = { tags: null, extra: null };
obj3[0] = { source: "useMobilePurchaseSKU_cancelOrderSigning" };
const obj4 = { orderId: null };
obj4[0] = closure_1_11;
obj3[1] = obj4;
const result = obj1.captureBillingException(closure_1, obj3);
const obj5 = { error: null, orderId: null, skuId: null };
obj5[0] = closure_1;
obj5[1] = closure_1_11;
obj5[2] = lib;
giftParams.error("Failed to cancel order signing", obj5);
} else if (arg0 === 1) {
v0 = 3;
throw arg1;
} else if (arg0 === 2) {
2026-07-29 08:29:29 +00:00
c4 = 0;
v0 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
2026-08-28 06:19:39 +00:00
} else {
lib = arg1;
2026-09-01 10:26:29 +00:00
if (closure_1_13 != null) {
2026-08-28 06:19:39 +00:00
tmp10(lib);
}
c4 = 0;
}
2026-09-01 10:26:29 +00:00
if (closure_1_16 != null) {
closure_1_16(false);
2026-07-29 08:29:29 +00:00
}
v0();
2026-09-01 10:26:29 +00:00
} catch (tmp45) {
closure_3 = tmp45;
2026-07-29 08:29:29 +00:00
if (tmp4 === c4) {
v0 = tmp2;
2026-09-01 10:26:29 +00:00
throw tmp45;
2026-07-29 08:29:29 +00:00
} else {
c5 = tmp;
}
}
}
})();
});
2026-09-01 10:26:29 +00:00
const items3 = [callback, onPurchaseError, onPurchasePending, tmp6, orderId, tmp3, platformSkuId, skuId];
2026-08-28 06:19:39 +00:00
callback3 = analyticsData.useCallback(function() {
2026-07-29 08:29:29 +00:00
const self = this;
const apply = closure_0.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-08-28 06:19:39 +00:00
}, items3);
const items4 = [callback3, callback, callback1];
const effect = analyticsData.useEffect(() => {
2026-09-01 10:26:29 +00:00
const subscription = platformSkuId(analyticsLocations[10]).subscribe("GPLAY_UPDATE_PURCHASE_STATE", callback3);
let obj = platformSkuId(analyticsLocations[10]);
const subscription1 = platformSkuId(analyticsLocations[10]).subscribe("GPLAY_PURCHASE_VERIFIED", callback);
let obj2 = platformSkuId(analyticsLocations[10]);
const subscription2 = platformSkuId(analyticsLocations[10]).subscribe("GPLAY_PURCHASE_VERIFICATION_FAILED", callback1);
2026-07-20 16:05:17 +00:00
return () => {
2026-09-01 10:26:29 +00:00
closure_1_1(closure_1_2[10]).unsubscribe("GPLAY_UPDATE_PURCHASE_STATE", closure_22);
const obj = closure_1_1(closure_1_2[10]);
closure_1_1(closure_1_2[10]).unsubscribe("GPLAY_PURCHASE_VERIFIED", closure_19);
const obj2 = closure_1_1(closure_1_2[10]);
closure_1_1(closure_1_2[10]).unsubscribe("GPLAY_PURCHASE_VERIFICATION_FAILED", closure_20);
2026-07-20 16:05:17 +00:00
};
2026-08-28 06:19:39 +00:00
}, items4);
2026-09-01 10:26:29 +00:00
const items5 = [skuId, platformSkuId, tmp8, flag2, handlePremiumPurchase, onPurchaseComplete, onPurchaseError, freePurchaseCallback, analyticsLoadId, analyticsLocations, analyticsData, giftParams, callback2, flag, tmp4, tmp5, tmp6, orderId];
2026-08-24 06:08:38 +00:00
return analyticsData.useCallback(callback(function*() {
2026-07-29 08:29:29 +00:00
if (v02 === 2) {
v02 = 3;
HermesBuiltin.throwTypeError();
2026-08-28 06:19:39 +00:00
} else if (tmp8 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
2026-07-29 08:29:29 +00:00
} else {
2026-09-01 10:26:29 +00:00
return { value: "HermesInternal", done: null };
2026-08-28 06:19:39 +00:00
}
} else {
try {
v02 = 2;
if (0 === v0) {
if (arg0 === 1) {
v02 = 3;
throw arg1;
} else if (arg0 === 2) {
v02 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
closure_2 = tmp4;
closure_1 = tmp9;
let tmp52;
2026-09-01 10:26:29 +00:00
if (closure_1_15 != null) {
tmp52 = closure_1_15();
2026-08-28 06:19:39 +00:00
}
if (true === tmp52) {
const _Error2 = Error;
error = new Error("Purchase already in progress");
throw error;
2026-07-29 08:29:29 +00:00
} else {
2026-08-28 06:19:39 +00:00
if (obj17.isNullOrEmpty(closure_1_1)) {
const _Error = Error;
const error1 = new Error("Missing google play sku ID");
throw error1;
2026-07-29 08:29:29 +00:00
} else {
2026-08-28 06:19:39 +00:00
c4 = 1;
2026-09-01 10:26:29 +00:00
if (closure_1_16 != null) {
closure_1_16(true);
2026-08-28 06:19:39 +00:00
}
2026-09-01 10:26:29 +00:00
if (closure_1_17) {
2026-08-28 06:19:39 +00:00
if (closure_1_10) {
2026-09-01 10:26:29 +00:00
if (!closure_1_18) {
2026-08-28 06:19:39 +00:00
c4 = 3;
callback = closure_1_7;
if (closure_1_7 == null) {
2026-09-01 10:26:29 +00:00
callback = closure_1_0(closure_1_2[14]).purchaseSKU;
2026-07-29 08:29:29 +00:00
}
2026-08-28 06:19:39 +00:00
obj1 = { expectedAmount: 0, expectedCurrency: null, loadId: null };
obj1[1] = closure_1_7.USD;
2026-09-01 10:26:29 +00:00
let obj8 = closure_1_0(closure_1_2[15]);
2026-08-28 06:19:39 +00:00
obj1[2] = obj8.v4();
v0 = 4;
2026-07-29 08:29:29 +00:00
v02 = 1;
2026-08-28 06:19:39 +00:00
let obj2 = { value: null, done: false };
obj2[0] = callback("collectibles", closure_1_0, obj1);
return obj2;
2026-07-29 08:29:29 +00:00
}
}
}
2026-08-28 06:19:39 +00:00
if (null != closure_1_11) {
2026-09-01 10:26:29 +00:00
c4 = 4;
v0 = 6;
v02 = 1;
const obj3 = { value: null, done: false };
obj3[0] = closure_1_0(closure_1_2[11]).markOrderAsSigningInProgress(closure_1_11);
return obj3;
2026-08-28 06:19:39 +00:00
}
2026-07-29 08:29:29 +00:00
}
2026-09-01 10:26:29 +00:00
obj17 = closure_1_0(closure_1_2[13]);
2026-07-29 08:29:29 +00:00
}
2026-08-28 06:19:39 +00:00
}
} else if (1 === tmp9) {
c4 = 0;
closure_2 = closure_3;
if (callback3 != null) {
callback3(false);
}
throw closure_2;
} else if (2 === tmp9) {
c4 = 1;
2026-09-01 10:26:29 +00:00
if (closure_1_16 != null) {
closure_1_16(false);
2026-08-28 06:19:39 +00:00
}
throw closure_3;
} else if (3 === tmp9) {
c4 = 2;
callback = closure_3;
v02();
throw callback;
} else {
if (4 === tmp9) {
if (arg0 === 1) {
v02 = 3;
throw arg1;
} else if (arg0 === 2) {
c4 = 1;
if (callback3 != null) {
callback3(false);
2026-07-29 08:29:29 +00:00
}
2026-08-28 06:19:39 +00:00
c4 = 0;
v02 = 3;
const obj4 = { value: null, done: true };
obj4[0] = arg1;
return obj4;
} else {
if (callback2 != null) {
callback2();
2026-07-29 08:29:29 +00:00
}
2026-08-28 06:19:39 +00:00
v0();
c4 = 1;
if (callback3 != null) {
callback3(false);
}
}
} else if (5 === tmp9) {
c4 = 1;
closure_1 = closure_3;
2026-09-01 10:26:29 +00:00
obj2 = closure_1_0(closure_1_2[12]);
2026-08-28 06:19:39 +00:00
const obj5 = { tags: null, extra: null };
obj5[0] = { source: "useMobilePurchaseSKU_markSigning" };
const obj6 = { orderId: null };
obj6[0] = closure_11;
obj5[1] = obj6;
const result = obj2.captureBillingException(closure_1, obj5);
const obj7 = { error: null, skuId: null, orderId: null };
obj7[0] = closure_1;
obj7[1] = callback;
obj7[2] = closure_11;
closure_1_9.error("Failed to mark order signing-in-progress", obj7);
throw closure_1;
} else if (6 === tmp9) {
if (arg0 === 1) {
2026-07-29 08:29:29 +00:00
v02 = 3;
throw arg1;
} else if (arg0 === 2) {
c4 = 0;
v02 = 3;
2026-08-28 06:19:39 +00:00
obj8 = { value: null, done: true };
obj8[0] = arg1;
return obj8;
} else {
c4 = 1;
2026-07-29 08:29:29 +00:00
}
2026-08-28 06:19:39 +00:00
} else if (arg0 === 1) {
v02 = 3;
throw arg1;
} else if (arg0 === 2) {
2026-07-29 08:29:29 +00:00
c4 = 0;
v02 = 3;
2026-08-28 06:19:39 +00:00
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
2026-07-29 08:29:29 +00:00
}
2026-08-28 06:19:39 +00:00
c4 = 0;
v02 = 3;
2026-09-01 10:26:29 +00:00
return { value: "HermesInternal", done: null };
2026-08-28 06:19:39 +00:00
}
const obj9 = { productId: null, skuId: null, isOneTimePurchase: true, analyticsLoadId: null, analyticsLocations: null, analyticsData: null, isGift: null, giftInfoOptions: null, onPurchaseError: null };
obj9[0] = closure_1;
obj9[1] = callback;
obj9[3] = closure_3;
obj9[4] = closure_2;
obj9[5] = c4;
2026-09-01 10:26:29 +00:00
obj9[6] = closure_18;
2026-08-28 06:19:39 +00:00
let options;
if (options != null) {
options = options.options;
}
obj9[7] = options;
2026-09-01 10:26:29 +00:00
obj9[8] = closure_21;
2026-08-28 06:19:39 +00:00
v0 = 7;
v02 = 1;
const obj10 = { value: null, done: false };
obj10[0] = closure_12(obj9);
return obj10;
2026-09-01 10:26:29 +00:00
} catch (tmp88) {
closure_3 = tmp88;
2026-08-28 06:19:39 +00:00
if (tmp5 === c4) {
v02 = tmp3;
2026-09-01 10:26:29 +00:00
throw tmp88;
} else if (tmp2 === tmp90) {
2026-08-28 06:19:39 +00:00
v0 = tmp2;
2026-09-01 10:26:29 +00:00
} else if (tmp === tmp90) {
2026-08-28 06:19:39 +00:00
v0 = tmp;
2026-09-01 10:26:29 +00:00
} else if (tmp3 === tmp90) {
2026-08-28 06:19:39 +00:00
v0 = tmp3;
} else {
v0 = tmp6;
2026-07-29 08:29:29 +00:00
}
}
}
2026-08-28 06:19:39 +00:00
}), items5);
2026-07-20 16:05:17 +00:00
};