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

429 lines
15 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 10396
// Function ID: 10397
2026-07-24 07:16:23 +00:00
// Name: useMobilePurchaseSKU
2026-08-24 06:08:38 +00:00
// Dependencies: [5, 19, 7433, 1922, 676, 5325, 3, 7655, 9303, 7165, 698, 709, 7438, 4057, 1903, 7908, 514, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
2026-08-24 06:08:38 +00:00
// Module 10396 (useMobilePurchaseSKU)
import timestampDefault from "timestamp" /* 3 */;
import closure_3 from "asyncGeneratorStep" /* 5 */;
import closure_4 from "noop" /* 19 */;
import { useNativeCheckoutStoreOrNull as closure_5 } from "context" /* 7433 */;
import closure_6 from "mergeGuildAvatar" /* 1922 */;
import { CurrencyCodes } from "ME" /* 676 */;
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;
let androidShopOrdersEnabled;
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;
const currentUser = onPurchaseError.getCurrentUser();
2026-07-29 08:29:29 +00:00
handlePremiumPurchase = _require(analyticsLocations[7]).useHandlePremiumPurchase();
let obj2 = _require(analyticsLocations[7]);
let tmp = analyticsLocations;
androidShopOrdersEnabled = _require(analyticsLocations[8]).useAndroidShopOrdersEnabled({ location: "useMobilePurchaseSKU" });
2026-07-24 07:16:23 +00:00
const tmp4 = onPurchaseComplete((setOrder) => setOrder.setOrder);
2026-08-24 06:08:38 +00:00
closure_14 = tmp4;
2026-07-23 10:11:24 +00:00
const tmp5 = onPurchaseComplete((setCheckoutSucceeded) => setCheckoutSucceeded.setCheckoutSucceeded);
2026-08-24 06:08:38 +00:00
closure_15 = tmp5;
2026-07-24 07:16:23 +00:00
closure_16 = analyticsData.useRef(false);
2026-07-23 10:11:24 +00:00
const tmp6 = undefined !== currentUser && currentUser.isStaff();
2026-08-24 06:08:38 +00:00
closure_17 = tmp6;
2026-07-29 08:29:29 +00:00
const tmp7 = platformSkuId(tmp[9])(() => callback(analyticsLocations[10]).getNewAnalyticsLoadId());
flag2 = undefined;
if (giftParams != null) {
flag2 = giftParams.isGift;
}
if (flag2 == null) {
flag2 = false;
2026-07-20 16:05:17 +00:00
}
if (null == analyticsLoadId) {
2026-08-24 06:08:38 +00:00
callback = tmp7;
2026-07-20 16:05:17 +00:00
analyticsLoadId = tmp7;
}
2026-07-23 10:11:24 +00:00
const items = [onPurchaseComplete, tmp5];
2026-07-29 08:29:29 +00:00
callback = obj4.useCallback(() => {
2026-07-24 07:16:23 +00:00
platformSkuId(analyticsLocations[11]).unsubscribe("GPLAY_PURCHASE_VERIFIED", callback);
closure_16.current = false;
2026-08-24 06:08:38 +00:00
if (callback2 != null) {
callback2();
2026-07-20 16:05:17 +00:00
}
onPurchaseComplete();
}, items);
const items1 = [onPurchaseError, callback];
2026-07-29 08:29:29 +00:00
callback1 = obj4.useCallback(() => {
2026-07-24 07:16:23 +00:00
platformSkuId(analyticsLocations[11]).unsubscribe("GPLAY_PURCHASE_VERIFIED", callback);
closure_16.current = false;
2026-07-20 16:05:17 +00:00
onPurchaseError();
}, items1);
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-08-24 06:08:38 +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-08-24 06:08:38 +00:00
closure_1_8();
2026-07-29 08:29:29 +00:00
v0 = 3;
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
} else {
let obj5 = platformSkuId(analyticsLocations[11]);
2026-08-24 06:08:38 +00:00
obj5.unsubscribe("GPLAY_PURCHASE_VERIFIED", closure_1_19);
if (null != closure_1_11) {
if (closure_1_13) {
2026-07-29 08:29:29 +00:00
if (tmp58.isActivePurchase) {
if (tmp58.billingResult === tmp59.USER_CANCELED) {
2026-08-24 06:08:38 +00:00
obj1 = { orderId: null, platformSkuId: null, skuId: null };
obj1[0] = closure_1_11;
obj1[1] = closure_1_1;
2026-07-29 08:29:29 +00:00
obj1[2] = lib;
giftParams.info("[handleGPlayUpdatePurchaseAction] User canceled purchase, canceling order signing", obj1);
2026-08-24 06:08:38 +00:00
c4 = 1;
2026-07-29 08:29:29 +00:00
c5 = 2;
v0 = 1;
const obj2 = { value: null, done: false };
2026-08-24 06:08:38 +00:00
obj2[0] = lib(analyticsLocations[12]).cancelOrderSigning(closure_1_11);
2026-07-29 08:29:29 +00:00
return obj2;
}
}
}
}
}
}
} else {
if (1 === tmp7) {
c4 = 0;
2026-08-24 06:08:38 +00:00
closure_1 = closure_3;
2026-07-29 08:29:29 +00:00
obj1 = lib(analyticsLocations[13]);
const obj3 = { tags: null, extra: null };
obj3[0] = { source: "useMobilePurchaseSKU_cancelOrderSigning" };
const obj4 = { orderId: null };
2026-08-24 06:08:38 +00:00
obj4[0] = closure_1_11;
2026-07-29 08:29:29 +00:00
obj3[1] = obj4;
const result = obj1.captureBillingException(closure_1, obj3);
obj5 = { error: null, orderId: null, skuId: null };
obj5[0] = closure_1;
2026-08-24 06:08:38 +00:00
obj5[1] = closure_1_11;
2026-07-29 08:29:29 +00:00
obj5[2] = lib;
giftParams.error("Failed to cancel order signing", obj5);
} else if (arg0 === 1) {
v0 = 3;
throw arg1;
} else if (arg0 !== 2) {
lib = arg1;
2026-08-24 06:08:38 +00:00
if (closure_1_14 != null) {
2026-07-29 08:29:29 +00:00
tmp10(lib);
}
c4 = 0;
}
c4 = 0;
v0 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
}
2026-08-24 06:08:38 +00:00
closure_1_16.current = false;
2026-07-29 08:29:29 +00:00
v0();
} catch (tmp49) {
2026-08-24 06:08:38 +00:00
closure_3 = tmp49;
2026-07-29 08:29:29 +00:00
if (tmp4 === c4) {
v0 = tmp2;
throw tmp49;
} else {
c5 = tmp;
}
}
}
})();
});
2026-07-24 07:16:23 +00:00
const items2 = [callback, onPurchaseError, onPurchasePending, orderId, androidShopOrdersEnabled, tmp4, platformSkuId, skuId];
2026-07-29 08:29:29 +00:00
callback2 = obj4.useCallback(function() {
const self = this;
const apply = closure_0.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
}, items2);
2026-07-20 16:05:17 +00:00
const items3 = [callback2, callback, callback1];
2026-07-29 08:29:29 +00:00
const effect = obj4.useEffect(() => {
2026-07-24 07:16:23 +00:00
const subscription = platformSkuId(analyticsLocations[11]).subscribe("GPLAY_UPDATE_PURCHASE_STATE", callback2);
let obj = platformSkuId(analyticsLocations[11]);
const subscription1 = platformSkuId(analyticsLocations[11]).subscribe("GPLAY_PURCHASE_VERIFIED", callback);
let obj2 = platformSkuId(analyticsLocations[11]);
const subscription2 = platformSkuId(analyticsLocations[11]).subscribe("GPLAY_PURCHASE_VERIFICATION_FAILED", callback1);
2026-07-20 16:05:17 +00:00
return () => {
2026-08-24 06:08:38 +00:00
closure_1_1(closure_1_2[11]).unsubscribe("GPLAY_UPDATE_PURCHASE_STATE", closure_21);
const obj = closure_1_1(closure_1_2[11]);
closure_1_1(closure_1_2[11]).unsubscribe("GPLAY_PURCHASE_VERIFIED", closure_19);
const obj2 = closure_1_1(closure_1_2[11]);
closure_1_1(closure_1_2[11]).unsubscribe("GPLAY_PURCHASE_VERIFICATION_FAILED", closure_20);
2026-07-20 16:05:17 +00:00
};
}, items3);
2026-07-29 08:29:29 +00:00
const items4 = [skuId, platformSkuId, tmp6, flag2, handlePremiumPurchase, onPurchaseComplete, onPurchaseError, freePurchaseCallback, analyticsLoadId, analyticsLocations, analyticsData, giftParams, flag, orderId, androidShopOrdersEnabled];
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();
} else {
let tmp = arg1;
tmp = arg0;
tmp = tmp8;
tmp = globalThis;
tmp = null;
if (tmp9 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +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 {
2026-08-24 06:08:38 +00:00
closure_2 = tmp4;
closure_1 = tmp10;
tmp = closure_1_16;
if (closure_1_16.current) {
2026-07-29 08:29:29 +00:00
const _Error2 = Error;
2026-08-24 06:08:38 +00:00
error = new Error("Purchase already in progress");
2026-07-29 08:29:29 +00:00
throw error;
} else {
2026-08-24 06:08:38 +00:00
let obj7 = closure_1_0(closure_1_2[14]);
if (obj7.isNullOrEmpty(closure_1_1)) {
2026-07-29 08:29:29 +00:00
const _Error = Error;
const error1 = new Error("Missing google play sku ID");
throw error1;
} else {
2026-08-24 06:08:38 +00:00
c4 = 2;
closure_1_16.current = true;
if (closure_1_17) {
if (closure_1_10) {
if (!closure_1_18) {
2026-07-29 08:29:29 +00:00
c4 = 4;
2026-08-24 06:08:38 +00:00
callback = closure_1_7;
if (closure_1_7 == null) {
callback = closure_1_0(closure_1_2[15]).purchaseSKU;
2026-07-29 08:29:29 +00:00
}
2026-08-24 06:08:38 +00:00
obj1 = { expectedAmount: 0, expectedCurrency: null, loadId: null };
obj1[1] = closure_1_7.USD;
let obj9 = closure_1_0(closure_1_2[16]);
2026-07-29 08:29:29 +00:00
obj1[2] = obj9.v4();
v0 = 5;
v02 = 1;
let obj2 = { value: null, done: false };
2026-08-24 06:08:38 +00:00
obj2[0] = callback("collectibles", closure_1_0, obj1);
2026-07-29 08:29:29 +00:00
return obj2;
}
}
}
2026-08-24 06:08:38 +00:00
if (null != closure_1_11) {
if (closure_1_13) {
2026-07-29 08:29:29 +00:00
c4 = 5;
v0 = 7;
v02 = 1;
const obj3 = { value: null, done: false };
2026-08-24 06:08:38 +00:00
obj3[0] = closure_1_0(closure_1_2[12]).markOrderAsSigningInProgress(closure_1_11);
2026-07-29 08:29:29 +00:00
return obj3;
}
}
}
}
}
} else if (1 === tmp10) {
c4 = 0;
2026-08-24 06:08:38 +00:00
closure_1_16.current = false;
throw closure_3;
2026-07-29 08:29:29 +00:00
} else if (2 === tmp10) {
c4 = 1;
2026-08-24 06:08:38 +00:00
throw closure_3;
2026-07-29 08:29:29 +00:00
} else if (3 === tmp10) {
c4 = 2;
2026-08-24 06:08:38 +00:00
closure_1_16.current = false;
throw closure_3;
2026-07-29 08:29:29 +00:00
} else if (4 === tmp10) {
c4 = 3;
2026-08-24 06:08:38 +00:00
callback = closure_3;
2026-07-29 08:29:29 +00:00
v02();
throw callback;
} else {
if (5 === tmp10) {
if (arg0 === 1) {
v02 = 3;
throw arg1;
} else if (arg0 === 2) {
c4 = 2;
closure_16.current = false;
c4 = 0;
closure_16.current = false;
v02 = 3;
const obj4 = { value: null, done: true };
obj4[0] = arg1;
return obj4;
} else {
v0();
c4 = 2;
closure_16.current = false;
}
} else if (6 === tmp10) {
c4 = 2;
2026-08-24 06:08:38 +00:00
closure_1 = closure_3;
obj2 = closure_1_0(closure_1_2[13]);
2026-07-29 08:29:29 +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);
obj7 = { error: null, skuId: null, orderId: null };
obj7[0] = closure_1;
obj7[1] = callback;
obj7[2] = closure_11;
2026-08-24 06:08:38 +00:00
closure_1_9.error("Failed to mark order signing-in-progress", obj7);
2026-07-29 08:29:29 +00:00
throw closure_1;
} else if (7 === tmp10) {
if (arg0 === 1) {
v02 = 3;
throw arg1;
} else if (arg0 === 2) {
c4 = 0;
closure_16.current = false;
v02 = 3;
const obj8 = { value: null, done: true };
obj8[0] = arg1;
return obj8;
} else {
c4 = 2;
}
} else if (arg0 === 1) {
v02 = 3;
throw arg1;
} else if (arg0 === 2) {
c4 = 0;
tmp = closure_2;
tmp = closure_16;
closure_16.current = false;
v02 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
}
c4 = 0;
closure_16.current = false;
v02 = 3;
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
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;
2026-08-24 06:08:38 +00:00
obj9[3] = closure_3;
2026-07-29 08:29:29 +00:00
obj9[4] = closure_2;
obj9[5] = c4;
obj9[6] = closure_18;
let options;
if (options != null) {
options = options.options;
}
obj9[7] = options;
obj9[8] = v02;
v0 = 8;
v02 = 1;
const obj10 = { value: null, done: false };
obj10[0] = closure_12(obj9);
return obj10;
} catch (tmp95) {
2026-08-24 06:08:38 +00:00
closure_3 = tmp95;
2026-07-29 08:29:29 +00:00
if (tmp5 === c4) {
v02 = tmp3;
throw tmp95;
} else if (tmp2 === tmp97) {
v0 = tmp2;
} else if (tmp === tmp97) {
v0 = tmp;
} else if (tmp3 === tmp97) {
v0 = tmp3;
} else if (tmp7 === tmp97) {
v0 = tmp7;
} else {
v0 = tmp6;
}
}
}
}
}), items4);
2026-07-20 16:05:17 +00:00
};