@dubsdotapp/expo 0.3.9 → 0.4.0
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/index.d.mts +55 -1
- package/dist/index.d.ts +55 -1
- package/dist/index.js +209 -122
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +159 -73
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useArcadeBridge.ts +188 -0
- package/src/index.ts +3 -0
package/dist/index.mjs
CHANGED
|
@@ -636,7 +636,7 @@ function createSecureStoreStorage() {
|
|
|
636
636
|
}
|
|
637
637
|
|
|
638
638
|
// src/provider.tsx
|
|
639
|
-
import { createContext as createContext4, useContext as useContext4, useMemo as useMemo3, useCallback as
|
|
639
|
+
import { createContext as createContext4, useContext as useContext4, useMemo as useMemo3, useCallback as useCallback20, useState as useState22, useEffect as useEffect14 } from "react";
|
|
640
640
|
|
|
641
641
|
// src/ui/theme.ts
|
|
642
642
|
import { createContext, useContext } from "react";
|
|
@@ -1701,7 +1701,7 @@ function ManagedWalletProvider({
|
|
|
1701
1701
|
}
|
|
1702
1702
|
|
|
1703
1703
|
// src/ui/AuthGate.tsx
|
|
1704
|
-
import React2, { useState as
|
|
1704
|
+
import React2, { useState as useState21, useEffect as useEffect13, useRef as useRef6, useCallback as useCallback19 } from "react";
|
|
1705
1705
|
import {
|
|
1706
1706
|
View as View3,
|
|
1707
1707
|
Text as Text3,
|
|
@@ -2780,6 +2780,91 @@ function useArcadeCountdown(nextResolution) {
|
|
|
2780
2780
|
};
|
|
2781
2781
|
}
|
|
2782
2782
|
|
|
2783
|
+
// src/hooks/useArcadeBridge.ts
|
|
2784
|
+
import { useRef as useRef5, useState as useState20, useCallback as useCallback18 } from "react";
|
|
2785
|
+
var PROTOCOL_VERSION = "1.0";
|
|
2786
|
+
function useArcadeBridge({
|
|
2787
|
+
canPlay,
|
|
2788
|
+
startAttempt,
|
|
2789
|
+
submitScore,
|
|
2790
|
+
onScoreSubmitted,
|
|
2791
|
+
onError
|
|
2792
|
+
}) {
|
|
2793
|
+
const webviewRef = useRef5(null);
|
|
2794
|
+
const sessionTokenRef = useRef5(null);
|
|
2795
|
+
const gameStartTimeRef = useRef5(0);
|
|
2796
|
+
const [lastResult, setLastResult] = useState20(null);
|
|
2797
|
+
const [bridgeLoading, setBridgeLoading] = useState20(false);
|
|
2798
|
+
const injectSession = useCallback18((token, attemptNumber) => {
|
|
2799
|
+
webviewRef.current?.injectJavaScript(`
|
|
2800
|
+
window.ARCADE_SESSION_TOKEN = ${JSON.stringify(token)};
|
|
2801
|
+
window.ARCADE_ATTEMPT_NUMBER = ${attemptNumber};
|
|
2802
|
+
window._ARCADE_GAME_START_TIME = Date.now();
|
|
2803
|
+
window.dispatchEvent(new Event('ARCADE_START'));
|
|
2804
|
+
true;
|
|
2805
|
+
`);
|
|
2806
|
+
}, []);
|
|
2807
|
+
const triggerPlay = useCallback18(async () => {
|
|
2808
|
+
if (!canPlay) return;
|
|
2809
|
+
setBridgeLoading(true);
|
|
2810
|
+
try {
|
|
2811
|
+
const result = await startAttempt();
|
|
2812
|
+
sessionTokenRef.current = result.sessionToken;
|
|
2813
|
+
gameStartTimeRef.current = Date.now();
|
|
2814
|
+
setLastResult(null);
|
|
2815
|
+
injectSession(result.sessionToken, result.attemptNumber);
|
|
2816
|
+
} catch (err) {
|
|
2817
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
2818
|
+
onError?.(e);
|
|
2819
|
+
} finally {
|
|
2820
|
+
setBridgeLoading(false);
|
|
2821
|
+
}
|
|
2822
|
+
}, [canPlay, startAttempt, injectSession, onError]);
|
|
2823
|
+
const handleMessage = useCallback18(
|
|
2824
|
+
async (event) => {
|
|
2825
|
+
let data;
|
|
2826
|
+
try {
|
|
2827
|
+
data = JSON.parse(event.nativeEvent.data);
|
|
2828
|
+
} catch {
|
|
2829
|
+
return;
|
|
2830
|
+
}
|
|
2831
|
+
if (data.dubsArcade !== PROTOCOL_VERSION) return;
|
|
2832
|
+
switch (data.type) {
|
|
2833
|
+
case "TAP_PLAY": {
|
|
2834
|
+
if (canPlay) {
|
|
2835
|
+
triggerPlay();
|
|
2836
|
+
}
|
|
2837
|
+
return;
|
|
2838
|
+
}
|
|
2839
|
+
case "GAME_OVER": {
|
|
2840
|
+
const token = sessionTokenRef.current;
|
|
2841
|
+
if (!token) return;
|
|
2842
|
+
const score = typeof data.score === "number" ? data.score : 0;
|
|
2843
|
+
const duration = gameStartTimeRef.current > 0 ? Date.now() - gameStartTimeRef.current : typeof data.durationMs === "number" ? data.durationMs : void 0;
|
|
2844
|
+
sessionTokenRef.current = null;
|
|
2845
|
+
gameStartTimeRef.current = 0;
|
|
2846
|
+
setBridgeLoading(true);
|
|
2847
|
+
try {
|
|
2848
|
+
const result = await submitScore(token, score, duration);
|
|
2849
|
+
setLastResult(result);
|
|
2850
|
+
onScoreSubmitted?.(result);
|
|
2851
|
+
} catch (err) {
|
|
2852
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
2853
|
+
onError?.(e);
|
|
2854
|
+
} finally {
|
|
2855
|
+
setBridgeLoading(false);
|
|
2856
|
+
}
|
|
2857
|
+
return;
|
|
2858
|
+
}
|
|
2859
|
+
default:
|
|
2860
|
+
return;
|
|
2861
|
+
}
|
|
2862
|
+
},
|
|
2863
|
+
[canPlay, triggerPlay, submitScore, onScoreSubmitted, onError]
|
|
2864
|
+
);
|
|
2865
|
+
return { webviewRef, handleMessage, triggerPlay, lastResult, bridgeLoading };
|
|
2866
|
+
}
|
|
2867
|
+
|
|
2783
2868
|
// src/ui/AvatarEditor.tsx
|
|
2784
2869
|
import {
|
|
2785
2870
|
View as View2,
|
|
@@ -2947,10 +3032,10 @@ function AuthGate({
|
|
|
2947
3032
|
}) {
|
|
2948
3033
|
const { client, pushEnabled } = useDubs();
|
|
2949
3034
|
const auth = useAuth();
|
|
2950
|
-
const [phase, setPhase] =
|
|
2951
|
-
const [registrationPhase, setRegistrationPhase] =
|
|
2952
|
-
const [showPushSetup, setShowPushSetup] =
|
|
2953
|
-
const [isRestoredSession, setIsRestoredSession] =
|
|
3035
|
+
const [phase, setPhase] = useState21("init");
|
|
3036
|
+
const [registrationPhase, setRegistrationPhase] = useState21(false);
|
|
3037
|
+
const [showPushSetup, setShowPushSetup] = useState21(false);
|
|
3038
|
+
const [isRestoredSession, setIsRestoredSession] = useState21(false);
|
|
2954
3039
|
useEffect13(() => {
|
|
2955
3040
|
let cancelled = false;
|
|
2956
3041
|
(async () => {
|
|
@@ -2989,12 +3074,12 @@ function AuthGate({
|
|
|
2989
3074
|
useEffect13(() => {
|
|
2990
3075
|
if (auth.token) onSaveToken(auth.token);
|
|
2991
3076
|
}, [auth.token]);
|
|
2992
|
-
const retry =
|
|
3077
|
+
const retry = useCallback19(() => {
|
|
2993
3078
|
setRegistrationPhase(false);
|
|
2994
3079
|
auth.reset();
|
|
2995
3080
|
auth.authenticate();
|
|
2996
3081
|
}, [auth]);
|
|
2997
|
-
const handleRegister =
|
|
3082
|
+
const handleRegister = useCallback19(
|
|
2998
3083
|
(username, referralCode, avatarUrl) => {
|
|
2999
3084
|
auth.register(username, referralCode, avatarUrl);
|
|
3000
3085
|
},
|
|
@@ -3110,18 +3195,18 @@ function DefaultRegistrationScreen({
|
|
|
3110
3195
|
}) {
|
|
3111
3196
|
const t = useDubsTheme();
|
|
3112
3197
|
const accent = accentColor || t.accent;
|
|
3113
|
-
const [step, setStep] =
|
|
3114
|
-
const [avatarSeed, setAvatarSeed] =
|
|
3115
|
-
const [avatarStyle, setAvatarStyle] =
|
|
3116
|
-
const [avatarBg, setAvatarBg] =
|
|
3117
|
-
const [showStyles, setShowStyles] =
|
|
3118
|
-
const [username, setUsername] =
|
|
3119
|
-
const [referralCode, setReferralCode] =
|
|
3120
|
-
const [checking, setChecking] =
|
|
3121
|
-
const [availability, setAvailability] =
|
|
3122
|
-
const debounceRef =
|
|
3123
|
-
const fadeAnim =
|
|
3124
|
-
const slideAnim =
|
|
3198
|
+
const [step, setStep] = useState21(0);
|
|
3199
|
+
const [avatarSeed, setAvatarSeed] = useState21(generateSeed);
|
|
3200
|
+
const [avatarStyle, setAvatarStyle] = useState21("adventurer");
|
|
3201
|
+
const [avatarBg, setAvatarBg] = useState21("1a1a2e");
|
|
3202
|
+
const [showStyles, setShowStyles] = useState21(false);
|
|
3203
|
+
const [username, setUsername] = useState21("");
|
|
3204
|
+
const [referralCode, setReferralCode] = useState21("");
|
|
3205
|
+
const [checking, setChecking] = useState21(false);
|
|
3206
|
+
const [availability, setAvailability] = useState21(null);
|
|
3207
|
+
const debounceRef = useRef6(null);
|
|
3208
|
+
const fadeAnim = useRef6(new Animated.Value(1)).current;
|
|
3209
|
+
const slideAnim = useRef6(new Animated.Value(0)).current;
|
|
3125
3210
|
const avatarUrl = getAvatarUrl(avatarStyle, avatarSeed, avatarBg);
|
|
3126
3211
|
useEffect13(() => {
|
|
3127
3212
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
@@ -3146,7 +3231,7 @@ function DefaultRegistrationScreen({
|
|
|
3146
3231
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
3147
3232
|
};
|
|
3148
3233
|
}, [username, client]);
|
|
3149
|
-
const animateToStep =
|
|
3234
|
+
const animateToStep = useCallback19((newStep) => {
|
|
3150
3235
|
const dir = newStep > step ? 1 : -1;
|
|
3151
3236
|
Keyboard.dismiss();
|
|
3152
3237
|
Animated.parallel([
|
|
@@ -3385,7 +3470,7 @@ function DefaultRegistrationScreen({
|
|
|
3385
3470
|
}
|
|
3386
3471
|
function PushTokenRestorer() {
|
|
3387
3472
|
const push = usePushNotifications();
|
|
3388
|
-
const restored =
|
|
3473
|
+
const restored = useRef6(false);
|
|
3389
3474
|
useEffect13(() => {
|
|
3390
3475
|
if (restored.current) return;
|
|
3391
3476
|
restored.current = true;
|
|
@@ -3401,8 +3486,8 @@ function PushSetupScreen({
|
|
|
3401
3486
|
const t = useDubsTheme();
|
|
3402
3487
|
const accent = accentColor || t.accent;
|
|
3403
3488
|
const push = usePushNotifications();
|
|
3404
|
-
const fadeAnim =
|
|
3405
|
-
const slideAnim =
|
|
3489
|
+
const fadeAnim = useRef6(new Animated.Value(0)).current;
|
|
3490
|
+
const slideAnim = useRef6(new Animated.Value(30)).current;
|
|
3406
3491
|
useEffect13(() => {
|
|
3407
3492
|
Animated.parallel([
|
|
3408
3493
|
Animated.timing(fadeAnim, { toValue: 1, duration: 300, useNativeDriver: true }),
|
|
@@ -3563,8 +3648,8 @@ function DubsProvider({
|
|
|
3563
3648
|
const rpcUrl = rpcUrlOverride || config.rpcUrl;
|
|
3564
3649
|
const client = useMemo3(() => new DubsClient({ apiKey, baseUrl }), [apiKey, baseUrl]);
|
|
3565
3650
|
const storage = useMemo3(() => tokenStorage || createSecureStoreStorage(), [tokenStorage]);
|
|
3566
|
-
const [uiConfig, setUiConfig] =
|
|
3567
|
-
const [resolvedNetwork, setResolvedNetwork] =
|
|
3651
|
+
const [uiConfig, setUiConfig] = useState22(null);
|
|
3652
|
+
const [resolvedNetwork, setResolvedNetwork] = useState22(network);
|
|
3568
3653
|
useEffect14(() => {
|
|
3569
3654
|
client.getAppConfig().then((cfg) => {
|
|
3570
3655
|
console.log("[DubsProvider] UI config loaded:", JSON.stringify(cfg));
|
|
@@ -3657,7 +3742,7 @@ function ManagedInner({
|
|
|
3657
3742
|
children
|
|
3658
3743
|
}) {
|
|
3659
3744
|
const managedDisconnect = useDisconnect();
|
|
3660
|
-
const disconnect =
|
|
3745
|
+
const disconnect = useCallback20(async () => {
|
|
3661
3746
|
client.setToken(null);
|
|
3662
3747
|
await managedDisconnect?.();
|
|
3663
3748
|
}, [client, managedDisconnect]);
|
|
@@ -3698,7 +3783,7 @@ function ExternalWalletProvider({
|
|
|
3698
3783
|
pushEnabled,
|
|
3699
3784
|
children
|
|
3700
3785
|
}) {
|
|
3701
|
-
const disconnect =
|
|
3786
|
+
const disconnect = useCallback20(async () => {
|
|
3702
3787
|
client.setToken(null);
|
|
3703
3788
|
await storage.deleteItem(STORAGE_KEYS.JWT_TOKEN).catch(() => {
|
|
3704
3789
|
});
|
|
@@ -3961,7 +4046,7 @@ var styles4 = StyleSheet5.create({
|
|
|
3961
4046
|
});
|
|
3962
4047
|
|
|
3963
4048
|
// src/ui/UserProfileSheet.tsx
|
|
3964
|
-
import { useState as
|
|
4049
|
+
import { useState as useState23, useEffect as useEffect15, useRef as useRef7, useCallback as useCallback21, useMemo as useMemo5 } from "react";
|
|
3965
4050
|
import {
|
|
3966
4051
|
View as View6,
|
|
3967
4052
|
Text as Text6,
|
|
@@ -3992,13 +4077,13 @@ function UserProfileSheet({
|
|
|
3992
4077
|
const { client } = useDubs();
|
|
3993
4078
|
const { refreshUser } = useAuth();
|
|
3994
4079
|
const push = usePushNotifications();
|
|
3995
|
-
const overlayOpacity =
|
|
4080
|
+
const overlayOpacity = useRef7(new Animated2.Value(0)).current;
|
|
3996
4081
|
const parsed = useMemo5(() => parseAvatarUrl(user.avatar), [user.avatar]);
|
|
3997
|
-
const [avatarStyle, setAvatarStyle] =
|
|
3998
|
-
const [avatarSeed, setAvatarSeed] =
|
|
3999
|
-
const [bgColor, setBgColor] =
|
|
4000
|
-
const [saving, setSaving] =
|
|
4001
|
-
const [error, setError] =
|
|
4082
|
+
const [avatarStyle, setAvatarStyle] = useState23(parsed.style);
|
|
4083
|
+
const [avatarSeed, setAvatarSeed] = useState23(parsed.seed);
|
|
4084
|
+
const [bgColor, setBgColor] = useState23(parsed.bg);
|
|
4085
|
+
const [saving, setSaving] = useState23(false);
|
|
4086
|
+
const [error, setError] = useState23(null);
|
|
4002
4087
|
useEffect15(() => {
|
|
4003
4088
|
const p = parseAvatarUrl(user.avatar);
|
|
4004
4089
|
setAvatarStyle(p.style);
|
|
@@ -4016,7 +4101,7 @@ function UserProfileSheet({
|
|
|
4016
4101
|
if (visible) setError(null);
|
|
4017
4102
|
}, [visible]);
|
|
4018
4103
|
const currentAvatarUrl = getAvatarUrl(avatarStyle, avatarSeed, bgColor);
|
|
4019
|
-
const saveAvatar =
|
|
4104
|
+
const saveAvatar = useCallback21(async (newUrl) => {
|
|
4020
4105
|
setSaving(true);
|
|
4021
4106
|
setError(null);
|
|
4022
4107
|
try {
|
|
@@ -4029,16 +4114,16 @@ function UserProfileSheet({
|
|
|
4029
4114
|
setSaving(false);
|
|
4030
4115
|
}
|
|
4031
4116
|
}, [client, refreshUser, onAvatarUpdated]);
|
|
4032
|
-
const handleStyleChange =
|
|
4117
|
+
const handleStyleChange = useCallback21((style) => {
|
|
4033
4118
|
setAvatarStyle(style);
|
|
4034
4119
|
saveAvatar(getAvatarUrl(style, avatarSeed, bgColor));
|
|
4035
4120
|
}, [avatarSeed, bgColor, saveAvatar]);
|
|
4036
|
-
const handleShuffle =
|
|
4121
|
+
const handleShuffle = useCallback21(() => {
|
|
4037
4122
|
const newSeed = generateSeed();
|
|
4038
4123
|
setAvatarSeed(newSeed);
|
|
4039
4124
|
saveAvatar(getAvatarUrl(avatarStyle, newSeed, bgColor));
|
|
4040
4125
|
}, [avatarStyle, bgColor, saveAvatar]);
|
|
4041
|
-
const handleBgChange =
|
|
4126
|
+
const handleBgChange = useCallback21((color) => {
|
|
4042
4127
|
setBgColor(color);
|
|
4043
4128
|
saveAvatar(getAvatarUrl(avatarStyle, avatarSeed, color));
|
|
4044
4129
|
}, [avatarStyle, avatarSeed, saveAvatar]);
|
|
@@ -4318,7 +4403,7 @@ var styles5 = StyleSheet6.create({
|
|
|
4318
4403
|
});
|
|
4319
4404
|
|
|
4320
4405
|
// src/ui/game/GamePoster.tsx
|
|
4321
|
-
import { useState as
|
|
4406
|
+
import { useState as useState24 } from "react";
|
|
4322
4407
|
import { StyleSheet as StyleSheet7, View as View7, Text as Text7 } from "react-native";
|
|
4323
4408
|
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
4324
4409
|
function computeCountdown(lockTimestamp) {
|
|
@@ -4368,7 +4453,7 @@ function GamePoster({ game, ImageComponent }) {
|
|
|
4368
4453
|
] });
|
|
4369
4454
|
}
|
|
4370
4455
|
function TeamLogoInternal({ url, size, Img }) {
|
|
4371
|
-
const [failed, setFailed] =
|
|
4456
|
+
const [failed, setFailed] = useState24(false);
|
|
4372
4457
|
if (!url || failed) {
|
|
4373
4458
|
return /* @__PURE__ */ jsx9(View7, { style: [styles6.logoPlaceholder, { width: size, height: size, borderRadius: size / 2 }] });
|
|
4374
4459
|
}
|
|
@@ -4548,7 +4633,7 @@ var styles7 = StyleSheet8.create({
|
|
|
4548
4633
|
});
|
|
4549
4634
|
|
|
4550
4635
|
// src/ui/game/PickWinnerCard.tsx
|
|
4551
|
-
import { useState as
|
|
4636
|
+
import { useState as useState25, useMemo as useMemo7 } from "react";
|
|
4552
4637
|
import { StyleSheet as StyleSheet9, View as View9, Text as Text9, TouchableOpacity as TouchableOpacity6 } from "react-native";
|
|
4553
4638
|
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
4554
4639
|
function PickWinnerCard({
|
|
@@ -4619,7 +4704,7 @@ function TeamOption({
|
|
|
4619
4704
|
ImageComponent,
|
|
4620
4705
|
t
|
|
4621
4706
|
}) {
|
|
4622
|
-
const [imgFailed, setImgFailed] =
|
|
4707
|
+
const [imgFailed, setImgFailed] = useState25(false);
|
|
4623
4708
|
const Img = ImageComponent || __require("react-native").Image;
|
|
4624
4709
|
const showImage = imageUrl && !imgFailed;
|
|
4625
4710
|
return /* @__PURE__ */ jsxs9(
|
|
@@ -4660,7 +4745,7 @@ var styles8 = StyleSheet9.create({
|
|
|
4660
4745
|
});
|
|
4661
4746
|
|
|
4662
4747
|
// src/ui/game/PlayersCard.tsx
|
|
4663
|
-
import { useState as
|
|
4748
|
+
import { useState as useState26 } from "react";
|
|
4664
4749
|
import { StyleSheet as StyleSheet10, View as View10, Text as Text10 } from "react-native";
|
|
4665
4750
|
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
4666
4751
|
function truncateWallet(addr, chars) {
|
|
@@ -4709,7 +4794,7 @@ function BettorRow({
|
|
|
4709
4794
|
ImageComponent,
|
|
4710
4795
|
t
|
|
4711
4796
|
}) {
|
|
4712
|
-
const [imgFailed, setImgFailed] =
|
|
4797
|
+
const [imgFailed, setImgFailed] = useState26(false);
|
|
4713
4798
|
const Img = ImageComponent || __require("react-native").Image;
|
|
4714
4799
|
const showAvatar = bettor.avatar && !imgFailed;
|
|
4715
4800
|
return /* @__PURE__ */ jsxs10(View10, { style: [styles9.row, !isFirst && { borderTopColor: t.border, borderTopWidth: 1 }], children: [
|
|
@@ -4788,7 +4873,7 @@ var styles10 = StyleSheet11.create({
|
|
|
4788
4873
|
});
|
|
4789
4874
|
|
|
4790
4875
|
// src/ui/game/CreateCustomGameSheet.tsx
|
|
4791
|
-
import { useState as
|
|
4876
|
+
import { useState as useState27, useEffect as useEffect16, useRef as useRef8, useCallback as useCallback22 } from "react";
|
|
4792
4877
|
import {
|
|
4793
4878
|
View as View12,
|
|
4794
4879
|
Text as Text12,
|
|
@@ -4825,10 +4910,10 @@ function CreateCustomGameSheet({
|
|
|
4825
4910
|
const t = useDubsTheme();
|
|
4826
4911
|
const { wallet } = useDubs();
|
|
4827
4912
|
const mutation = useCreateCustomGame();
|
|
4828
|
-
const [selectedAmount, setSelectedAmount] =
|
|
4829
|
-
const [customAmount, setCustomAmount] =
|
|
4830
|
-
const [isCustom, setIsCustom] =
|
|
4831
|
-
const overlayOpacity =
|
|
4913
|
+
const [selectedAmount, setSelectedAmount] = useState27(null);
|
|
4914
|
+
const [customAmount, setCustomAmount] = useState27("");
|
|
4915
|
+
const [isCustom, setIsCustom] = useState27(false);
|
|
4916
|
+
const overlayOpacity = useRef8(new Animated3.Value(0)).current;
|
|
4832
4917
|
useEffect16(() => {
|
|
4833
4918
|
Animated3.timing(overlayOpacity, {
|
|
4834
4919
|
toValue: visible ? 1 : 0,
|
|
@@ -4858,18 +4943,18 @@ function CreateCustomGameSheet({
|
|
|
4858
4943
|
onError?.(mutation.error);
|
|
4859
4944
|
}
|
|
4860
4945
|
}, [mutation.status, mutation.error]);
|
|
4861
|
-
const handlePresetSelect =
|
|
4946
|
+
const handlePresetSelect = useCallback22((amount) => {
|
|
4862
4947
|
setSelectedAmount(amount);
|
|
4863
4948
|
setIsCustom(false);
|
|
4864
4949
|
setCustomAmount("");
|
|
4865
4950
|
onAmountChange?.(amount);
|
|
4866
4951
|
}, [onAmountChange]);
|
|
4867
|
-
const handleCustomSelect =
|
|
4952
|
+
const handleCustomSelect = useCallback22(() => {
|
|
4868
4953
|
setIsCustom(true);
|
|
4869
4954
|
setSelectedAmount(null);
|
|
4870
4955
|
onAmountChange?.(null);
|
|
4871
4956
|
}, [onAmountChange]);
|
|
4872
|
-
const handleCustomAmountChange =
|
|
4957
|
+
const handleCustomAmountChange = useCallback22((text) => {
|
|
4873
4958
|
const cleaned = text.replace(/[^0-9.]/g, "").replace(/(\..*?)\..*/g, "$1");
|
|
4874
4959
|
setCustomAmount(cleaned);
|
|
4875
4960
|
const parsed = parseFloat(cleaned);
|
|
@@ -4884,7 +4969,7 @@ function CreateCustomGameSheet({
|
|
|
4884
4969
|
const winnerTakes = pot * (1 - fee / 100);
|
|
4885
4970
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
4886
4971
|
const canCreate = finalAmount !== null && finalAmount > 0 && !isMutating && mutation.status !== "success";
|
|
4887
|
-
const handleCreate =
|
|
4972
|
+
const handleCreate = useCallback22(async () => {
|
|
4888
4973
|
if (!finalAmount || !wallet.publicKey) return;
|
|
4889
4974
|
try {
|
|
4890
4975
|
await mutation.execute({
|
|
@@ -5153,7 +5238,7 @@ var styles11 = StyleSheet12.create({
|
|
|
5153
5238
|
});
|
|
5154
5239
|
|
|
5155
5240
|
// src/ui/game/JoinGameSheet.tsx
|
|
5156
|
-
import { useState as
|
|
5241
|
+
import { useState as useState28, useEffect as useEffect17, useRef as useRef9, useCallback as useCallback23, useMemo as useMemo9 } from "react";
|
|
5157
5242
|
import {
|
|
5158
5243
|
View as View13,
|
|
5159
5244
|
Text as Text13,
|
|
@@ -5189,8 +5274,8 @@ function JoinGameSheet({
|
|
|
5189
5274
|
const { wallet } = useDubs();
|
|
5190
5275
|
const mutation = useJoinGame();
|
|
5191
5276
|
const isCustomGame = game.gameMode === CUSTOM_GAME_MODE;
|
|
5192
|
-
const [selectedTeam, setSelectedTeam] =
|
|
5193
|
-
const overlayOpacity =
|
|
5277
|
+
const [selectedTeam, setSelectedTeam] = useState28(null);
|
|
5278
|
+
const overlayOpacity = useRef9(new Animated4.Value(0)).current;
|
|
5194
5279
|
useEffect17(() => {
|
|
5195
5280
|
Animated4.timing(overlayOpacity, {
|
|
5196
5281
|
toValue: visible ? 1 : 0,
|
|
@@ -5243,7 +5328,7 @@ function JoinGameSheet({
|
|
|
5243
5328
|
}, [bettors, wallet.publicKey]);
|
|
5244
5329
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
5245
5330
|
const canJoin = selectedTeam !== null && !isMutating && mutation.status !== "success" && !alreadyJoined;
|
|
5246
|
-
const handleJoin =
|
|
5331
|
+
const handleJoin = useCallback23(async () => {
|
|
5247
5332
|
if (!selectedTeam || !wallet.publicKey) return;
|
|
5248
5333
|
try {
|
|
5249
5334
|
await mutation.execute({
|
|
@@ -5387,7 +5472,7 @@ function TeamButton({
|
|
|
5387
5472
|
ImageComponent,
|
|
5388
5473
|
t
|
|
5389
5474
|
}) {
|
|
5390
|
-
const [imgFailed, setImgFailed] =
|
|
5475
|
+
const [imgFailed, setImgFailed] = useState28(false);
|
|
5391
5476
|
const Img = ImageComponent || __require("react-native").Image;
|
|
5392
5477
|
const showImage = imageUrl && !imgFailed;
|
|
5393
5478
|
return /* @__PURE__ */ jsxs13(
|
|
@@ -5564,7 +5649,7 @@ var styles12 = StyleSheet13.create({
|
|
|
5564
5649
|
});
|
|
5565
5650
|
|
|
5566
5651
|
// src/ui/game/ClaimPrizeSheet.tsx
|
|
5567
|
-
import { useState as
|
|
5652
|
+
import { useState as useState29, useEffect as useEffect18, useRef as useRef10, useCallback as useCallback24 } from "react";
|
|
5568
5653
|
import {
|
|
5569
5654
|
View as View14,
|
|
5570
5655
|
Text as Text14,
|
|
@@ -5595,10 +5680,10 @@ function ClaimPrizeSheet({
|
|
|
5595
5680
|
const t = useDubsTheme();
|
|
5596
5681
|
const { wallet } = useDubs();
|
|
5597
5682
|
const mutation = useClaim();
|
|
5598
|
-
const overlayOpacity =
|
|
5599
|
-
const celebrationScale =
|
|
5600
|
-
const celebrationOpacity =
|
|
5601
|
-
const [showCelebration, setShowCelebration] =
|
|
5683
|
+
const overlayOpacity = useRef10(new Animated5.Value(0)).current;
|
|
5684
|
+
const celebrationScale = useRef10(new Animated5.Value(0)).current;
|
|
5685
|
+
const celebrationOpacity = useRef10(new Animated5.Value(0)).current;
|
|
5686
|
+
const [showCelebration, setShowCelebration] = useState29(false);
|
|
5602
5687
|
useEffect18(() => {
|
|
5603
5688
|
Animated5.timing(overlayOpacity, {
|
|
5604
5689
|
toValue: visible ? 1 : 0,
|
|
@@ -5644,7 +5729,7 @@ function ClaimPrizeSheet({
|
|
|
5644
5729
|
}, [mutation.status, mutation.error]);
|
|
5645
5730
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
5646
5731
|
const canClaim = !isMutating && mutation.status !== "success" && !!wallet.publicKey;
|
|
5647
|
-
const handleClaim =
|
|
5732
|
+
const handleClaim = useCallback24(async () => {
|
|
5648
5733
|
if (!wallet.publicKey) return;
|
|
5649
5734
|
try {
|
|
5650
5735
|
await mutation.execute({
|
|
@@ -5877,7 +5962,7 @@ var styles13 = StyleSheet14.create({
|
|
|
5877
5962
|
});
|
|
5878
5963
|
|
|
5879
5964
|
// src/ui/game/ClaimButton.tsx
|
|
5880
|
-
import { useState as
|
|
5965
|
+
import { useState as useState30, useMemo as useMemo10, useCallback as useCallback25 } from "react";
|
|
5881
5966
|
import { StyleSheet as StyleSheet15, Text as Text15, TouchableOpacity as TouchableOpacity11 } from "react-native";
|
|
5882
5967
|
import { Fragment as Fragment5, jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
5883
5968
|
function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
@@ -5885,7 +5970,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
5885
5970
|
const { wallet } = useDubs();
|
|
5886
5971
|
const game = useGame(gameId);
|
|
5887
5972
|
const claimStatus = useHasClaimed(gameId);
|
|
5888
|
-
const [sheetVisible, setSheetVisible] =
|
|
5973
|
+
const [sheetVisible, setSheetVisible] = useState30(false);
|
|
5889
5974
|
const walletAddress = wallet.publicKey?.toBase58() ?? null;
|
|
5890
5975
|
const myBet = useMemo10(() => {
|
|
5891
5976
|
if (!walletAddress || !game.data?.bettors) return null;
|
|
@@ -5896,7 +5981,7 @@ function ClaimButton({ gameId, style, onSuccess, onError }) {
|
|
|
5896
5981
|
const isWinner = isResolved && myBet != null && myBet.team === game.data?.winnerSide;
|
|
5897
5982
|
const isEligible = myBet != null && isResolved && (isWinner || isRefund);
|
|
5898
5983
|
const prizeAmount = isRefund ? myBet?.amount ?? 0 : game.data?.totalPool ?? 0;
|
|
5899
|
-
const handleSuccess =
|
|
5984
|
+
const handleSuccess = useCallback25(
|
|
5900
5985
|
(result) => {
|
|
5901
5986
|
claimStatus.refetch();
|
|
5902
5987
|
onSuccess?.(result);
|
|
@@ -5983,7 +6068,7 @@ var styles14 = StyleSheet15.create({
|
|
|
5983
6068
|
});
|
|
5984
6069
|
|
|
5985
6070
|
// src/ui/game/EnterArcadePoolSheet.tsx
|
|
5986
|
-
import { useEffect as useEffect19, useRef as
|
|
6071
|
+
import { useEffect as useEffect19, useRef as useRef11, useCallback as useCallback26 } from "react";
|
|
5987
6072
|
import {
|
|
5988
6073
|
View as View15,
|
|
5989
6074
|
Text as Text16,
|
|
@@ -6014,7 +6099,7 @@ function EnterArcadePoolSheet({
|
|
|
6014
6099
|
const t = useDubsTheme();
|
|
6015
6100
|
const { wallet } = useDubs();
|
|
6016
6101
|
const mutation = useEnterArcadePool();
|
|
6017
|
-
const overlayOpacity =
|
|
6102
|
+
const overlayOpacity = useRef11(new Animated6.Value(0)).current;
|
|
6018
6103
|
useEffect19(() => {
|
|
6019
6104
|
Animated6.timing(overlayOpacity, {
|
|
6020
6105
|
toValue: visible ? 1 : 0,
|
|
@@ -6047,7 +6132,7 @@ function EnterArcadePoolSheet({
|
|
|
6047
6132
|
const potSol = (pool.buy_in_lamports * Number(totalPlayers) / 1e9).toFixed(4);
|
|
6048
6133
|
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
6049
6134
|
const canJoin = !isMutating && mutation.status !== "success";
|
|
6050
|
-
const handleJoin =
|
|
6135
|
+
const handleJoin = useCallback26(async () => {
|
|
6051
6136
|
if (!wallet.publicKey) return;
|
|
6052
6137
|
try {
|
|
6053
6138
|
await mutation.execute(pool.id);
|
|
@@ -6198,7 +6283,7 @@ var styles15 = StyleSheet16.create({
|
|
|
6198
6283
|
});
|
|
6199
6284
|
|
|
6200
6285
|
// src/ui/game/ArcadeLeaderboardSheet.tsx
|
|
6201
|
-
import { useEffect as useEffect20, useRef as
|
|
6286
|
+
import { useEffect as useEffect20, useRef as useRef12 } from "react";
|
|
6202
6287
|
import {
|
|
6203
6288
|
View as View16,
|
|
6204
6289
|
Text as Text17,
|
|
@@ -6226,7 +6311,7 @@ function ArcadeLeaderboardSheet({
|
|
|
6226
6311
|
}) {
|
|
6227
6312
|
const t = useDubsTheme();
|
|
6228
6313
|
const { pool, leaderboard, stats, loading, refetch } = useArcadePool(poolId);
|
|
6229
|
-
const overlayOpacity =
|
|
6314
|
+
const overlayOpacity = useRef12(new Animated7.Value(0)).current;
|
|
6230
6315
|
useEffect20(() => {
|
|
6231
6316
|
Animated7.timing(overlayOpacity, {
|
|
6232
6317
|
toValue: visible ? 1 : 0,
|
|
@@ -6414,6 +6499,7 @@ export {
|
|
|
6414
6499
|
parseSolanaError,
|
|
6415
6500
|
signAndSendBase64Transaction,
|
|
6416
6501
|
useAppConfig,
|
|
6502
|
+
useArcadeBridge,
|
|
6417
6503
|
useArcadeCountdown,
|
|
6418
6504
|
useArcadeGame,
|
|
6419
6505
|
useArcadePool,
|