@dubsdotapp/expo 0.4.1 → 0.5.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 +54 -2
- package/dist/index.d.ts +54 -2
- package/dist/index.js +516 -452
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +485 -417
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/useArcadeBridge.ts +3 -2
- package/src/index.ts +2 -2
- package/src/ui/AuthGate.tsx +27 -0
- package/src/ui/ConnectWalletButton.tsx +107 -0
- package/src/ui/index.ts +3 -1
package/package.json
CHANGED
|
@@ -138,8 +138,9 @@ export function useArcadeBridge({
|
|
|
138
138
|
return; // non-JSON postMessages from the game's own code — ignore
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
//
|
|
142
|
-
|
|
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;
|
|
143
144
|
|
|
144
145
|
switch (data.type) {
|
|
145
146
|
case 'TAP_PLAY': {
|
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, AuthGateConnectWalletProps, 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';
|
package/src/ui/AuthGate.tsx
CHANGED
|
@@ -31,6 +31,15 @@ export interface RegistrationScreenProps {
|
|
|
31
31
|
client: DubsClient;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
export interface ConnectWalletScreenProps {
|
|
35
|
+
/** Call this to trigger the wallet connection flow */
|
|
36
|
+
onConnect: () => void;
|
|
37
|
+
/** True while the wallet is connecting/signing */
|
|
38
|
+
connecting: boolean;
|
|
39
|
+
/** Error from a failed connection attempt */
|
|
40
|
+
error: Error | null;
|
|
41
|
+
}
|
|
42
|
+
|
|
34
43
|
export interface AuthGateProps {
|
|
35
44
|
children: React.ReactNode;
|
|
36
45
|
onSaveToken: (token: string | null) => void | Promise<void>;
|
|
@@ -38,6 +47,12 @@ export interface AuthGateProps {
|
|
|
38
47
|
renderLoading?: (status: AuthStatus) => React.ReactNode;
|
|
39
48
|
renderError?: (error: Error, retry: () => void) => React.ReactNode;
|
|
40
49
|
renderRegistration?: (props: RegistrationScreenProps) => React.ReactNode;
|
|
50
|
+
/**
|
|
51
|
+
* Render your own connect-wallet screen.
|
|
52
|
+
* Receives { onConnect, connecting, error }.
|
|
53
|
+
* If omitted, the default ConnectWalletScreen is shown.
|
|
54
|
+
*/
|
|
55
|
+
renderConnectWallet?: (props: ConnectWalletScreenProps) => React.ReactNode;
|
|
41
56
|
appName?: string;
|
|
42
57
|
/** Override accent color for registration screens (from developer UI config) */
|
|
43
58
|
accentColor?: string;
|
|
@@ -52,6 +67,7 @@ export function AuthGate({
|
|
|
52
67
|
renderLoading,
|
|
53
68
|
renderError,
|
|
54
69
|
renderRegistration,
|
|
70
|
+
renderConnectWallet,
|
|
55
71
|
appName = 'Dubs',
|
|
56
72
|
accentColor,
|
|
57
73
|
}: AuthGateProps) {
|
|
@@ -162,6 +178,17 @@ export function AuthGate({
|
|
|
162
178
|
return <DefaultErrorScreen error={auth.error} onRetry={retry} appName={appName} accentColor={accentColor} />;
|
|
163
179
|
}
|
|
164
180
|
|
|
181
|
+
// idle = waiting for user to connect — show connect wallet screen
|
|
182
|
+
if (auth.status === 'idle') {
|
|
183
|
+
const connectProps: ConnectWalletScreenProps = {
|
|
184
|
+
onConnect: auth.authenticate,
|
|
185
|
+
connecting: false,
|
|
186
|
+
error: null,
|
|
187
|
+
};
|
|
188
|
+
if (renderConnectWallet) return <>{renderConnectWallet(connectProps)}</>;
|
|
189
|
+
// Fall through to default loading (existing behaviour if no renderConnectWallet)
|
|
190
|
+
}
|
|
191
|
+
|
|
165
192
|
if (renderLoading) return <>{renderLoading(auth.status)}</>;
|
|
166
193
|
return <DefaultLoadingScreen status={auth.status} appName={appName} accentColor={accentColor} />;
|
|
167
194
|
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
TouchableOpacity,
|
|
4
|
+
Text,
|
|
5
|
+
ActivityIndicator,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
View,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import { useAuth } from '../hooks/useAuth';
|
|
10
|
+
import { useDubsTheme } from './theme';
|
|
11
|
+
|
|
12
|
+
export interface ConnectWalletButtonProps {
|
|
13
|
+
/** Button label. Defaults to "Connect Wallet" */
|
|
14
|
+
label?: string;
|
|
15
|
+
/** Override accent/background color */
|
|
16
|
+
accentColor?: string;
|
|
17
|
+
/** Override text color. Defaults to #000 */
|
|
18
|
+
textColor?: string;
|
|
19
|
+
/** Override border radius */
|
|
20
|
+
borderRadius?: number;
|
|
21
|
+
/** Override padding vertical */
|
|
22
|
+
paddingVertical?: number;
|
|
23
|
+
/** Override font size */
|
|
24
|
+
fontSize?: number;
|
|
25
|
+
/** Full width. Defaults to true */
|
|
26
|
+
fullWidth?: boolean;
|
|
27
|
+
/** Called after authenticate() is triggered (not after it completes) */
|
|
28
|
+
onPress?: () => void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* ConnectWalletButton
|
|
33
|
+
*
|
|
34
|
+
* A minimal, customisable button that fires useAuth().authenticate().
|
|
35
|
+
* Use this when you want to own the connect-wallet screen UI (e.g. inside
|
|
36
|
+
* your own onboarding) but still hand off the wallet picker, signing, and
|
|
37
|
+
* registration flow to the SDK.
|
|
38
|
+
*
|
|
39
|
+
* The SDK will handle everything after this tap:
|
|
40
|
+
* wallet picker → sign message → (registration/avatar if new user) → authenticated
|
|
41
|
+
*
|
|
42
|
+
* Example:
|
|
43
|
+
* <ConnectWalletButton
|
|
44
|
+
* label="Let's go"
|
|
45
|
+
* accentColor="#22C55E"
|
|
46
|
+
* textColor="#000"
|
|
47
|
+
* />
|
|
48
|
+
*/
|
|
49
|
+
export function ConnectWalletButton({
|
|
50
|
+
label = 'Connect Wallet',
|
|
51
|
+
accentColor,
|
|
52
|
+
textColor = '#000000',
|
|
53
|
+
borderRadius = 16,
|
|
54
|
+
paddingVertical = 16,
|
|
55
|
+
fontSize = 17,
|
|
56
|
+
fullWidth = true,
|
|
57
|
+
onPress,
|
|
58
|
+
}: ConnectWalletButtonProps) {
|
|
59
|
+
const t = useDubsTheme();
|
|
60
|
+
const { authenticate, status } = useAuth();
|
|
61
|
+
|
|
62
|
+
const connecting = status === 'authenticating' || status === 'signing' || status === 'verifying';
|
|
63
|
+
const accent = accentColor || t.accent;
|
|
64
|
+
|
|
65
|
+
const handlePress = () => {
|
|
66
|
+
onPress?.();
|
|
67
|
+
authenticate();
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<TouchableOpacity
|
|
72
|
+
onPress={handlePress}
|
|
73
|
+
disabled={connecting}
|
|
74
|
+
activeOpacity={0.85}
|
|
75
|
+
style={[
|
|
76
|
+
styles.btn,
|
|
77
|
+
{
|
|
78
|
+
backgroundColor: accent,
|
|
79
|
+
borderRadius,
|
|
80
|
+
paddingVertical,
|
|
81
|
+
width: fullWidth ? '100%' : undefined,
|
|
82
|
+
opacity: connecting ? 0.8 : 1,
|
|
83
|
+
},
|
|
84
|
+
]}
|
|
85
|
+
>
|
|
86
|
+
{connecting ? (
|
|
87
|
+
<ActivityIndicator color={textColor} size="small" />
|
|
88
|
+
) : (
|
|
89
|
+
<Text style={[styles.label, { color: textColor, fontSize }]}>
|
|
90
|
+
{label}
|
|
91
|
+
</Text>
|
|
92
|
+
)}
|
|
93
|
+
</TouchableOpacity>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const styles = StyleSheet.create({
|
|
98
|
+
btn: {
|
|
99
|
+
alignItems: 'center',
|
|
100
|
+
justifyContent: 'center',
|
|
101
|
+
paddingHorizontal: 24,
|
|
102
|
+
},
|
|
103
|
+
label: {
|
|
104
|
+
fontWeight: '800',
|
|
105
|
+
letterSpacing: -0.2,
|
|
106
|
+
},
|
|
107
|
+
});
|
package/src/ui/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { AuthGate } from './AuthGate';
|
|
2
|
-
export type { AuthGateProps, RegistrationScreenProps } from './AuthGate';
|
|
2
|
+
export type { AuthGateProps, RegistrationScreenProps, ConnectWalletScreenProps as AuthGateConnectWalletProps } 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';
|