@@ -3,11 +3,7 @@ import type { FrameLaunchedInContext } from "./frame-debugger";
3
3
import { WithTooltip } from "./with-tooltip" ;
4
4
import { Loader2Icon , RefreshCwIcon } from "lucide-react" ;
5
5
import { Card , CardContent } from "@/components/ui/card" ;
6
- import {
7
- type FramePrimaryButton ,
8
- type ResolveClientFunction ,
9
- useFrameAppInIframe ,
10
- } from "@frames.js/render/use-frame-app" ;
6
+ import { useFrameAppInIframe } from "@frames.js/render/frame-app/iframe" ;
11
7
import { useCallback , useRef , useState } from "react" ;
12
8
import { useWagmiProvider } from "@frames.js/render/frame-app/provider/wagmi" ;
13
9
import { useToast } from "@/components/ui/use-toast" ;
@@ -22,12 +18,18 @@ import {
22
18
FrameAppNotificationsManagerProvider ,
23
19
useFrameAppNotificationsManager ,
24
20
} from "../providers/FrameAppNotificationsManagerProvider" ;
21
+ import { ToastAction } from "@/components/ui/toast" ;
22
+ import type {
23
+ FramePrimaryButton ,
24
+ ResolveClientFunction ,
25
+ } from "@frames.js/render/frame-app/types" ;
25
26
26
27
type TabValues = "events" | "console" | "notifications" ;
27
28
28
29
type FrameAppDebuggerProps = {
29
30
context : FrameLaunchedInContext ;
30
31
farcasterSigner : FarcasterSignerInstance ;
32
+ onClose : ( ) => void ;
31
33
} ;
32
34
33
35
// in debugger we don't want to automatically reject repeated add frame calls
@@ -48,6 +50,7 @@ const addFrameRequestsCache = new (class extends Set {
48
50
export function FrameAppDebugger ( {
49
51
context,
50
52
farcasterSigner,
53
+ onClose,
51
54
} : FrameAppDebuggerProps ) {
52
55
const farcasterSignerRef = useRef ( farcasterSigner ) ;
53
56
farcasterSignerRef . current = farcasterSigner ;
@@ -57,14 +60,16 @@ export function FrameAppDebugger({
57
60
} ) ;
58
61
const { toast } = useToast ( ) ;
59
62
const debuggerConsoleTabRef = useRef < HTMLDivElement > ( null ) ;
60
- const iframeRef = useRef < HTMLIFrameElement > ( null ) ;
63
+ const iframeRef = useRef < HTMLIFrameElement | null > ( null ) ;
61
64
const [ activeTab , setActiveTab ] = useState < TabValues > ( "notifications" ) ;
62
65
const [ isAppReady , setIsAppReady ] = useState ( false ) ;
63
66
const [ primaryButton , setPrimaryButton ] = useState < {
64
67
button : FramePrimaryButton ;
65
68
callback : ( ) => void ;
66
69
} | null > ( null ) ;
67
- const provider = useWagmiProvider ( ) ;
70
+ const provider = useWagmiProvider ( {
71
+ debug : true ,
72
+ } ) ;
68
73
const resolveClient : ResolveClientFunction = useCallback ( async ( ) => {
69
74
try {
70
75
const { manager } = await frameAppNotificationManager . promise ;
@@ -124,7 +129,18 @@ export function FrameAppDebugger({
124
129
console . info ( "sdk.actions.close() called" ) ;
125
130
toast ( {
126
131
title : "Frame app closed" ,
127
- description : "The frame app called close() action." ,
132
+ description :
133
+ "The frame app called close() action. Would you like to close it?" ,
134
+ action : (
135
+ < ToastAction
136
+ altText = "Close"
137
+ onClick = { ( ) => {
138
+ onClose ( ) ;
139
+ } }
140
+ >
141
+ Close
142
+ </ ToastAction >
143
+ ) ,
128
144
} ) ;
129
145
} ,
130
146
onOpenUrl ( url ) {
@@ -210,9 +226,6 @@ export function FrameAppDebugger({
210
226
throw e ;
211
227
}
212
228
} ,
213
- onDebugEthProviderRequest ( parameters ) {
214
- console . info ( "sdk.wallet.ethProvider.request() called" , { parameters } ) ;
215
- } ,
216
229
} ) ;
217
230
218
231
return (
@@ -253,29 +266,34 @@ export function FrameAppDebugger({
253
266
context . frame . button . action . splashBackgroundColor ,
254
267
} }
255
268
>
256
- < div className = "w-[200px] h-[200px] relative" >
257
- < Image
258
- alt = { `${ name } splash image` }
259
- src = { context . frame . button . action . splashImageUrl }
260
- width = { 200 }
261
- height = { 200 }
262
- />
263
- < div className = "absolute bottom-0 right-0" >
264
- < Loader2Icon
265
- className = "animate-spin text-primary"
266
- size = { 40 }
269
+ { context . frame . button . action . splashImageUrl && (
270
+ < div className = "w-[200px] h-[200px] relative" >
271
+ < Image
272
+ alt = { `${ name } splash image` }
273
+ src = { context . frame . button . action . splashImageUrl }
274
+ width = { 200 }
275
+ height = { 200 }
267
276
/>
277
+ < div className = "absolute bottom-0 right-0" >
278
+ < Loader2Icon
279
+ className = "animate-spin text-primary"
280
+ size = { 40 }
281
+ />
282
+ </ div >
268
283
</ div >
269
- </ div >
284
+ ) }
270
285
</ div >
271
286
) ) }
272
287
{ frameApp . status === "success" && (
273
288
< >
274
289
< iframe
275
290
className = "flex h-full w-full border rounded-lg"
276
291
sandbox = "allow-forms allow-scripts allow-same-origin"
277
- ref = { iframeRef }
278
292
{ ...frameApp . iframeProps }
293
+ ref = { ( r ) => {
294
+ frameApp . iframeProps . ref . current = r ;
295
+ iframeRef . current = r ;
296
+ } }
279
297
/>
280
298
{ ! ! primaryButton && ! primaryButton . button . hidden && (
281
299
< div className = "w-full py-1" >
0 commit comments