@@ -22,6 +22,7 @@ import {
2222 CollapsedFrameUI ,
2323 defaultTheme ,
2424} from "@frames.js/render" ;
25+ import { getFrameParseResultFromStackItemBySpecifications } from "@frames.js/render/helpers" ;
2526import { FrameImageNext } from "@frames.js/render/next" ;
2627import { Table , TableBody , TableCell , TableRow } from "@/components/table" ;
2728import {
@@ -59,21 +60,18 @@ import { urlSearchParamsToObject } from "../utils/url-search-params-to-object";
5960import { FrameUI } from "./frame-ui" ;
6061import { useToast } from "@/components/ui/use-toast" ;
6162import { ToastAction } from "@/components/ui/toast" ;
62- import type { AnonymousSigner } from "@frames.js/render/identity/anonymous" ;
63- import type { LensSigner } from "@frames.js/render/identity/lens" ;
64- import type { FarcasterSigner } from "@frames.js/render/identity/farcaster" ;
65- import type { XmtpSigner } from "@frames.js/render/identity/xmtp" ;
6663
6764type FrameDiagnosticsProps = {
6865 stackItem : FramesStackItem ;
66+ specification : SupportedParsingSpecification ;
6967} ;
7068
7169function isPropertyExperimental ( [ key , value ] : [ string , string ] ) {
7270 // tx is experimental
7371 return false ;
7472}
7573
76- function FrameDiagnostics ( { stackItem } : FrameDiagnosticsProps ) {
74+ function FrameDiagnostics ( { stackItem, specification } : FrameDiagnosticsProps ) {
7775 const properties = useMemo ( ( ) => {
7876 /** tuple of key and value */
7977 const validProperties : [ string , string ] [ ] = [ ] ;
@@ -97,7 +95,9 @@ function FrameDiagnostics({ stackItem }: FrameDiagnosticsProps) {
9795 return { validProperties, invalidProperties, isValid : true } ;
9896 }
9997
100- const result = stackItem . frameResult ;
98+ const result = getFrameParseResultFromStackItemBySpecifications ( stackItem , [
99+ specification ,
100+ ] ) ;
101101
102102 // we need to check validation errors first because getFrame incorrectly return a value for a key even if it's invalid
103103 for ( const [ key , reports ] of Object . entries ( result . reports ) ) {
@@ -160,8 +160,8 @@ function FrameDiagnostics({ stackItem }: FrameDiagnosticsProps) {
160160 { stackItem . speed > 5
161161 ? `Request took more than 5s (${ stackItem . speed } seconds). This may be normal: first request will take longer in development (as next.js builds), but in production, clients will timeout requests after 5s`
162162 : stackItem . speed > 4
163- ? `Warning: Request took more than 4s (${ stackItem . speed } seconds). Requests will fail at 5s. This may be normal: first request will take longer in development (as next.js builds), but in production, if there's variance here, requests could fail in production if over 5s`
164- : `${ stackItem . speed } seconds` }
163+ ? `Warning: Request took more than 4s (${ stackItem . speed } seconds). Requests will fail at 5s. This may be normal: first request will take longer in development (as next.js builds), but in production, if there's variance here, requests could fail in production if over 5s`
164+ : `${ stackItem . speed } seconds` }
165165 </ TableCell >
166166 </ TableRow >
167167 { properties . validProperties . map ( ( [ propertyKey , value ] ) => {
@@ -248,7 +248,8 @@ function ShortenedText({
248248
249249const FramesRequestCardContentIcon : React . FC < {
250250 stackItem : FramesStackItem ;
251- } > = ( { stackItem } ) => {
251+ specification : SupportedParsingSpecification ;
252+ } > = ( { stackItem, specification } ) => {
252253 if ( stackItem . status === "pending" ) {
253254 return < LoaderIcon className = "animate-spin" size = { 20 } /> ;
254255 }
@@ -269,11 +270,15 @@ const FramesRequestCardContentIcon: React.FC<{
269270 return < ExternalLinkIcon size = { 20 } color = "green" /> ;
270271 }
271272
272- if ( stackItem . frameResult ?. status === "failure" ) {
273+ const result = getFrameParseResultFromStackItemBySpecifications ( stackItem , [
274+ specification ,
275+ ] ) ;
276+
277+ if ( result . status === "failure" ) {
273278 return < XCircle size = { 20 } color = "red" /> ;
274279 }
275280
276- if ( hasWarnings ( stackItem . frameResult . reports ) ) {
281+ if ( hasWarnings ( result . reports ) ) {
277282 return < AlertTriangle size = { 20 } color = "orange" /> ;
278283 }
279284
@@ -282,10 +287,9 @@ const FramesRequestCardContentIcon: React.FC<{
282287
283288const FramesRequestCardContent : React . FC < {
284289 stack : FramesStack ;
285- fetchFrame : FrameState <
286- FarcasterSigner | XmtpSigner | LensSigner | AnonymousSigner | null
287- > [ "fetchFrame" ] ;
288- } > = ( { fetchFrame, stack } ) => {
290+ fetchFrame : FrameState [ "fetchFrame" ] ;
291+ specification : SupportedParsingSpecification ;
292+ } > = ( { fetchFrame, specification, stack } ) => {
289293 return stack . map ( ( frameStackItem , i ) => {
290294 return (
291295 < button
@@ -312,7 +316,8 @@ const FramesRequestCardContent: React.FC<{
312316 < span className = "ml-auto" >
313317 < FramesRequestCardContentIcon
314318 stackItem = { frameStackItem }
315- > </ FramesRequestCardContentIcon >
319+ specification = { specification }
320+ />
316321 </ span >
317322 </ span >
318323 < span className = "flex flex-row w-full" >
@@ -369,10 +374,10 @@ type FrameDebuggerSharedProps = {
369374type FrameDebuggerProps = FrameDebuggerSharedProps &
370375 (
371376 | {
372- useFrameHook : ( ) => FrameState < any , any > ;
377+ useFrameHook : ( ) => FrameState ;
373378 }
374379 | {
375- frameState : FrameState < any , any > ;
380+ frameState : FrameState ;
376381 }
377382 ) ;
378383
@@ -478,10 +483,16 @@ export const FrameDebugger = React.forwardRef<
478483 [ toast , showConsole ]
479484 ) ;
480485
486+ const currentParseResult =
487+ currentFrameStackItem && currentFrameStackItem . status === "done"
488+ ? getFrameParseResultFromStackItemBySpecifications (
489+ currentFrameStackItem ,
490+ [ specification ]
491+ )
492+ : undefined ;
493+
481494 const isImageDebuggingAvailable =
482- currentFrameStackItem &&
483- "frameResult" in currentFrameStackItem &&
484- ! ! currentFrameStackItem . frameResult . framesDebugInfo ?. image ;
495+ currentParseResult ?. framesDebugInfo ?. image ;
485496
486497 return (
487498 < div className = "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-[300px_500px_1fr] p-4 gap-4 bg-slate-50 max-w-full w-full" >
@@ -541,6 +552,7 @@ export const FrameDebugger = React.forwardRef<
541552 < FramesRequestCardContent
542553 fetchFrame = { frameState . fetchFrame }
543554 stack = { frameState . framesStack }
555+ specification = { specification }
544556 > </ FramesRequestCardContent >
545557 </ CardContent >
546558 </ Card >
@@ -621,8 +633,11 @@ export const FrameDebugger = React.forwardRef<
621633 ) }
622634 < div className = "space-y-1" >
623635 { currentFrameStackItem ?. status === "done" &&
624- currentFrameStackItem . frameResult . frame . buttons
625- ?. filter (
636+ getFrameParseResultFromStackItemBySpecifications (
637+ currentFrameStackItem ,
638+ [ specification ]
639+ )
640+ . frame . buttons ?. filter (
626641 ( button ) =>
627642 button . target ?. startsWith (
628643 "https://warpcast.com/~/add-cast-action"
@@ -685,7 +700,8 @@ export const FrameDebugger = React.forwardRef<
685700 < TabsContent className = "overflow-y-auto" value = "diagnostics" >
686701 < FrameDiagnostics
687702 stackItem = { currentFrameStackItem }
688- > </ FrameDiagnostics >
703+ specification = { specification }
704+ />
689705 </ TabsContent >
690706 < TabsContent
691707 className = "overflow-y-auto"
@@ -719,15 +735,15 @@ export const FrameDebugger = React.forwardRef<
719735 < button
720736 className = "underline"
721737 onClick = { ( ) => {
722- if ( ! currentFrameStackItem ) {
723- return ;
724- }
738+ const frame =
739+ getFrameParseResultFromStackItemBySpecifications (
740+ currentFrameStackItem ,
741+ [ specification ]
742+ ) . frame ;
725743
726744 // Copy the text inside the text field
727745 navigator . clipboard . writeText (
728- getFrameHtmlHead (
729- currentFrameStackItem . frameResult . frame
730- )
746+ getFrameHtmlHead ( frame )
731747 ) ;
732748 setCopySuccess ( true ) ;
733749 } }
@@ -748,7 +764,10 @@ export const FrameDebugger = React.forwardRef<
748764 "sourceFrame" in currentFrameStackItem . request &&
749765 currentFrameStackItem . request . sourceFrame
750766 ? currentFrameStackItem . request . sourceFrame
751- : currentFrameStackItem . frameResult . frame
767+ : getFrameParseResultFromStackItemBySpecifications (
768+ currentFrameStackItem ,
769+ [ specification ]
770+ ) . frame
752771 )
753772 . split ( "<meta" )
754773 . filter ( ( t ) => ! ! t )
0 commit comments