@dubsdotapp/expo 0.4.2 → 0.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dubsdotapp/expo",
3
- "version": "0.4.2",
3
+ "version": "0.5.1",
4
4
  "description": "React Native SDK for the Dubs betting platform",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -90,10 +90,6 @@ export function useArcadeBridge({
90
90
  const sessionTokenRef = useRef<string | null>(null);
91
91
  const gameStartTimeRef = useRef<number>(0);
92
92
 
93
- // Keep canPlay in a ref so TAP_PLAY handler always sees the latest value
94
- const canPlayRef = useRef(canPlay);
95
- canPlayRef.current = canPlay;
96
-
97
93
  const [lastResult, setLastResult] = useState<SubmitScoreResult | null>(null);
98
94
  const [bridgeLoading, setBridgeLoading] = useState(false);
99
95
 
@@ -138,13 +134,12 @@ export function useArcadeBridge({
138
134
  return; // non-JSON postMessages from the game's own code — ignore
139
135
  }
140
136
 
141
- // If dubsArcade version is present it must match — if absent, accept anyway
142
- // (backward-compat: old game builds don't include the envelope yet)
143
- if (data.dubsArcade !== undefined && data.dubsArcade !== PROTOCOL_VERSION) return;
137
+ // Only process messages from our bridge protocol
138
+ if (data.dubsArcade !== PROTOCOL_VERSION) return;
144
139
 
145
140
  switch (data.type) {
146
141
  case 'TAP_PLAY': {
147
- if (canPlayRef.current) {
142
+ if (canPlay) {
148
143
  triggerPlay();
149
144
  }
150
145
  return;
@@ -186,7 +181,7 @@ export function useArcadeBridge({
186
181
  return;
187
182
  }
188
183
  },
189
- [triggerPlay, submitScore, onScoreSubmitted, onError],
184
+ [canPlay, triggerPlay, submitScore, onScoreSubmitted, onError],
190
185
  );
191
186
 
192
187
  return { webviewRef, handleMessage, triggerPlay, lastResult, bridgeLoading };
package/src/index.ts CHANGED
@@ -129,8 +129,8 @@ export type {
129
129
  } from './hooks';
130
130
 
131
131
  // UI
132
- export { AuthGate, ConnectWalletScreen, UserProfileCard, SettingsSheet, UserProfileSheet, useDubsTheme, mergeTheme } from './ui';
133
- export type { AuthGateProps, RegistrationScreenProps, ConnectWalletScreenProps, UserProfileCardProps, SettingsSheetProps, UserProfileSheetProps, DubsTheme } from './ui';
132
+ export { AuthGate, ConnectWalletScreen, ConnectWalletButton, UserProfileCard, SettingsSheet, UserProfileSheet, useDubsTheme, mergeTheme } from './ui';
133
+ export type { AuthGateProps, RegistrationScreenProps, ConnectWalletScreenProps, ConnectWalletButtonProps, UserProfileCardProps, SettingsSheetProps, UserProfileSheetProps, DubsTheme } from './ui';
134
134
 
135
135
  // Game widgets
136
136
  export { GamePoster, LivePoolsCard, PickWinnerCard, PlayersCard, JoinGameButton, CreateCustomGameSheet, JoinGameSheet, ClaimPrizeSheet, ClaimButton, EnterArcadePoolSheet, ArcadeLeaderboardSheet } from './ui';
@@ -0,0 +1,112 @@
1
+ import React from 'react';
2
+ import {
3
+ Text,
4
+ TouchableOpacity,
5
+ ActivityIndicator,
6
+ StyleSheet,
7
+ View,
8
+ type ViewStyle,
9
+ } from 'react-native';
10
+ import { useDubsTheme } from './theme';
11
+
12
+ export interface ConnectWalletButtonProps {
13
+ /** Called when the user taps the button */
14
+ onConnect: () => void | Promise<void>;
15
+ /** Show a loading spinner while connecting */
16
+ connecting?: boolean;
17
+ /** Error message to display below the button */
18
+ error?: string | null;
19
+ /** Override accent color (e.g. from developer UI config) */
20
+ accentColor?: string;
21
+ /** Override button label. Defaults to "Connect Wallet" */
22
+ label?: string;
23
+ /** Additional style applied to the outer container */
24
+ style?: ViewStyle;
25
+ /** Additional style applied to the button itself */
26
+ buttonStyle?: ViewStyle;
27
+ }
28
+
29
+ /**
30
+ * Drop-in wallet connect button that triggers the same MWA / Phantom
31
+ * connection flow as ConnectWalletScreen, but renders as a single button
32
+ * instead of a full-screen layout.
33
+ *
34
+ * Use with `renderConnectScreen` on DubsProvider to embed the button
35
+ * inside your own custom onboarding or home screen:
36
+ *
37
+ * ```tsx
38
+ * <DubsProvider
39
+ * renderConnectScreen={({ onConnect, connecting, error }) => (
40
+ * <MyScreen>
41
+ * <ConnectWalletButton onConnect={onConnect} connecting={connecting} error={error} />
42
+ * </MyScreen>
43
+ * )}
44
+ * >
45
+ * ```
46
+ */
47
+ export function ConnectWalletButton({
48
+ onConnect,
49
+ connecting = false,
50
+ error = null,
51
+ accentColor,
52
+ label = 'Connect Wallet',
53
+ style,
54
+ buttonStyle,
55
+ }: ConnectWalletButtonProps) {
56
+ const t = useDubsTheme();
57
+ const accent = accentColor || t.accent;
58
+
59
+ return (
60
+ <View style={style}>
61
+ {error ? (
62
+ <View
63
+ style={[
64
+ styles.errorBox,
65
+ { backgroundColor: t.errorBg, borderColor: t.errorBorder },
66
+ ]}
67
+ >
68
+ <Text style={[styles.errorText, { color: t.errorText }]}>{error}</Text>
69
+ </View>
70
+ ) : null}
71
+
72
+ <TouchableOpacity
73
+ style={[styles.button, { backgroundColor: accent }, buttonStyle]}
74
+ onPress={onConnect}
75
+ disabled={connecting}
76
+ activeOpacity={0.8}
77
+ >
78
+ {connecting ? (
79
+ <ActivityIndicator color="#FFFFFF" size="small" />
80
+ ) : (
81
+ <Text style={styles.buttonText}>{label}</Text>
82
+ )}
83
+ </TouchableOpacity>
84
+ </View>
85
+ );
86
+ }
87
+
88
+ const styles = StyleSheet.create({
89
+ button: {
90
+ height: 56,
91
+ borderRadius: 16,
92
+ justifyContent: 'center',
93
+ alignItems: 'center',
94
+ paddingHorizontal: 24,
95
+ },
96
+ buttonText: {
97
+ color: '#FFFFFF',
98
+ fontSize: 18,
99
+ fontWeight: '700',
100
+ },
101
+ errorBox: {
102
+ borderWidth: 1,
103
+ borderRadius: 12,
104
+ paddingHorizontal: 16,
105
+ paddingVertical: 12,
106
+ marginBottom: 12,
107
+ },
108
+ errorText: {
109
+ fontSize: 14,
110
+ textAlign: 'center',
111
+ },
112
+ });
package/src/ui/index.ts CHANGED
@@ -2,6 +2,8 @@ export { AuthGate } from './AuthGate';
2
2
  export type { AuthGateProps, RegistrationScreenProps } from './AuthGate';
3
3
  export { ConnectWalletScreen } from './ConnectWalletScreen';
4
4
  export type { ConnectWalletScreenProps } from './ConnectWalletScreen';
5
+ export { ConnectWalletButton } from './ConnectWalletButton';
6
+ export type { ConnectWalletButtonProps } from './ConnectWalletButton';
5
7
  export { UserProfileCard } from './UserProfileCard';
6
8
  export type { UserProfileCardProps } from './UserProfileCard';
7
9
  export { SettingsSheet } from './SettingsSheet';