Skip to content

Commit

Permalink
feat: support new unstable api in debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkvasnicak committed Oct 25, 2024
1 parent a3d27be commit cea73a7
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 109 deletions.
7 changes: 7 additions & 0 deletions .changeset/twenty-pugs-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"frames.js": patch
"@frames.js/debugger": patch
"@frames.js/render": patch
---

feat: multi specification support
13 changes: 2 additions & 11 deletions packages/debugger/app/components/action-debugger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {
} from "@/components/ui/hover-card";
import { cn } from "@/lib/utils";
import {
type FarcasterFrameContext,
type FrameActionBodyPayload,
OnComposeFormActionFuncReturnType,
defaultTheme,
} from "@frames.js/render";
Expand All @@ -33,7 +31,6 @@ import { Button } from "../../@/components/ui/button";
import { FrameDebugger } from "./frame-debugger";
import IconByName from "./octicons";
import { MockHubActionContext } from "../utils/mock-hub-utils";
import { useFrame } from "@frames.js/render/use-frame";
import { WithTooltip } from "./with-tooltip";
import { useToast } from "@/components/ui/use-toast";
import type { CastActionDefinitionResponse } from "../frames/route";
Expand All @@ -42,7 +39,7 @@ import { AwaitableController } from "../lib/awaitable-controller";
import type { ComposerActionFormResponse } from "frames.js/types";
import { CastComposer, CastComposerRef } from "./cast-composer";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import type { FarcasterSigner } from "@frames.js/render/identity/farcaster";
import { useFrame } from "@frames.js/render/unstable-use-frame";

type FrameDebuggerFramePropertiesTableRowsProps = {
actionMetadataItem: CastActionDefinitionResponse;
Expand Down Expand Up @@ -177,13 +174,7 @@ function ShortenedText({

type ActionDebuggerProps = {
actionMetadataItem: CastActionDefinitionResponse;
farcasterFrameConfig: Parameters<
typeof useFrame<
FarcasterSigner | null,
FrameActionBodyPayload,
FarcasterFrameContext
>
>[0];
farcasterFrameConfig: Parameters<typeof useFrame>[0];
refreshUrl: (arg0?: string) => void;
mockHubContext?: Partial<MockHubActionContext>;
setMockHubContext?: Dispatch<SetStateAction<Partial<MockHubActionContext>>>;
Expand Down
18 changes: 3 additions & 15 deletions packages/debugger/app/components/cast-composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
ExternalLinkIcon,
} from "lucide-react";
import IconByName from "./octicons";
import { useFrame } from "@frames.js/render/use-frame";
import { WithTooltip } from "./with-tooltip";
import type {
FarcasterFrameContext,
Expand All @@ -23,17 +22,12 @@ import { useToast } from "@/components/ui/use-toast";
import { ToastAction } from "@radix-ui/react-toast";
import Link from "next/link";
import type { FarcasterSigner } from "@frames.js/render/identity/farcaster";
import { useFrame } from "@frames.js/render/unstable-use-frame";

type CastComposerProps = {
composerAction: Partial<ComposerActionResponse>;
onComposerActionClick: (state: ComposerActionState) => any;
farcasterFrameConfig: Parameters<
typeof useFrame<
FarcasterSigner | null,
FrameActionBodyPayload,
FarcasterFrameContext
>
>[0];
farcasterFrameConfig: Parameters<typeof useFrame>[0];
};

export type CastComposerRef = {
Expand Down Expand Up @@ -119,13 +113,7 @@ export const CastComposer = React.forwardRef<
CastComposer.displayName = "CastComposer";

type CastEmbedPreviewProps = {
farcasterFrameConfig: Parameters<
typeof useFrame<
FarcasterSigner | null,
FrameActionBodyPayload,
FarcasterFrameContext
>
>[0];
farcasterFrameConfig: Parameters<typeof useFrame>[0];
url: string;
onRemove: () => void;
};
Expand Down
13 changes: 6 additions & 7 deletions packages/debugger/app/components/frame-debugger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import type { AnonymousSigner } from "@frames.js/render/identity/anonymous";
import type { LensSigner } from "@frames.js/render/identity/lens";
import type { FarcasterSigner } from "@frames.js/render/identity/farcaster";
import type { XmtpSigner } from "@frames.js/render/identity/xmtp";
import type { UseFrameReturnValue } from "@frames.js/render/unstable-use-frame";

type FrameDiagnosticsProps = {
stackItem: FramesStackItem;
Expand Down Expand Up @@ -160,8 +161,8 @@ function FrameDiagnostics({ stackItem }: FrameDiagnosticsProps) {
{stackItem.speed > 5
? `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`
: stackItem.speed > 4
? `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`
: `${stackItem.speed} seconds`}
? `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`
: `${stackItem.speed} seconds`}
</TableCell>
</TableRow>
{properties.validProperties.map(([propertyKey, value]) => {
Expand Down Expand Up @@ -282,9 +283,7 @@ const FramesRequestCardContentIcon: React.FC<{

const FramesRequestCardContent: React.FC<{
stack: FramesStack;
fetchFrame: FrameState<
FarcasterSigner | XmtpSigner | LensSigner | AnonymousSigner | null
>["fetchFrame"];
fetchFrame: UseFrameReturnValue["fetchFrame"];
}> = ({ fetchFrame, stack }) => {
return stack.map((frameStackItem, i) => {
return (
Expand Down Expand Up @@ -369,10 +368,10 @@ type FrameDebuggerSharedProps = {
type FrameDebuggerProps = FrameDebuggerSharedProps &
(
| {
useFrameHook: () => FrameState<any, any>;
useFrameHook: () => UseFrameReturnValue;
}
| {
frameState: FrameState<any, any>;
frameState: UseFrameReturnValue;
}
);

Expand Down
Loading

0 comments on commit cea73a7

Please sign in to comment.