import { Hono } from 'hono'; import { type HonoOptions } from 'hono/hono-base'; import { type Env, type Schema } from 'hono/types'; import { type FrameContext, type FrameImageAspectRatio, type FrameIntents } from './types.js'; export type FarcConstructorParameters = { /** * The base path for the server instance. * * @example '/api' (commonly for Vercel Serverless Functions) */ basePath?: basePath | string | undefined; /** * Location (URL or path relative to `basePath`) to redirect to when the user * is coming to the page via a browser. * * For instance, a user may reach the frame page in their * browser by clicking on the link beneath the frame on Warpcast. * We may want to redirect them to a different page (ie. a mint page, etc) * when they arrive via their browser. * * @example (Absolute Path) * Parameters: * basePath: '/api' * browserLocation: '/' * * https://example.com/api -> https://example.com/ * https://example.com/api/foo -> https://example.com/ * * @example (Absolute Path) * Parameters: * basePath: '/api' * browserLocation: '/mint' * * https://example.com/api -> https://example.com/mint * https://example.com/api/foo -> https://example.com/mint * * @example (Absolute Path with `:path` template) * Parameters * basePath: '/api' * browserLocation: '/:path' * * https://example.com/api -> https://example.com/ * https://example.com/api/foo -> https://example.com/foo * https://example.com/api/foo/bar -> https://example.com/foo/bar * * @example (Relative Path) * Parameters: * basePath: '/api' * browserLocation: './dev' * * https://example.com/api -> https://example.com/api/dev * https://example.com/api/foo -> https://example.com/api/foo/dev * * @example (URL) * Parameters: * browserLocation: 'https://google.com/:path' * * https://example.com/api -> https://google.com/api * https://example.com/api/foo -> https://google.com/api/foo */ browserLocation?: string | undefined; /** * Options to forward to the `Hono` instance. */ honoOptions?: HonoOptions | undefined; /** * Farcaster Hub API URL. * * @default 'https://api.hub.wevm.dev' */ hubApiUrl?: string | undefined; /** * Initial state for the frames. * * @example * ```ts * initialState: { * index: 0, * todos: [], * } * ``` */ initialState?: state | undefined; /** * Whether or not to verify frame data via the Farcaster Hub's `validateMessage` API. * * - When `true`, the frame will go through verification and throw an error if it fails. * - When `false`, the frame will not go through verification. * - When `undefined`, the frame will go through verification, but not throw an error if it fails. * Instead, the frame will receive `verified: false` in its context. * * @default true. */ verify?: boolean | undefined; }; export type FrameOptions = Pick; export type FrameHandlerReturnType = Pick & { /** * Path of the next frame. * * @example '/submit' */ action?: string | undefined; /** * The OG Image to render for the frame. * * @example *
Hello World
*/ image: JSX.Element; /** * The aspect ratio of the OG Image. * * @example '1:1' */ imageAspectRatio?: FrameImageAspectRatio | undefined; /** * A set of intents (ie. buttons, text inputs, etc) to render for the frame * (beneath the OG image). * * @example * intents: [ * , * , * ] */ intents?: FrameIntents | undefined; }; /** * A Farc instance. * * @param parameters - {@link FarcConstructorParameters} * @returns instance. {@link FarcBase} * * @example * ``` * import { Farc } from 'farc' * * const app = new Farc() * * app.frame('/', (context) => { * const { buttonValue, inputText, status } = context * const fruit = inputText || buttonValue * return { * image: ( *
* {fruit ? `You selected: ${fruit}` : 'Welcome!'} *
* ), * intents: [ * , * , * , * ] * } * }) * ``` */ export declare class FarcBase { _initialState: state; /** Base path of the server instance. */ basePath: string; /** URL to redirect to when the user is coming to the page via a browser. */ browserLocation: string | undefined; /** Hono instance. */ hono: Hono; /** Farcaster Hub API URL. */ hubApiUrl: string; fetch: Hono['fetch']; get: Hono['get']; post: Hono['post']; /** Whether or not frames should be verified. */ verify: boolean; constructor({ basePath, browserLocation, honoOptions, hubApiUrl, initialState, verify, }?: FarcConstructorParameters); frame(path: path, handler: (context: FrameContext) => FrameHandlerReturnType | Promise, options?: FrameOptions): void; route(path: subPath, farc: FarcBase): import("hono/hono-base").HonoBase> & schema, basePath>; } //# sourceMappingURL=farc-base.d.ts.map