import { type Schema } from 'hono' import { routes as devRoutes } from './dev/routes.js' import { FrogBase, type FrogConstructorParameters } from './frog-base.js' import type { Env } from './types/env.js' /** * A Frog instance. * * @param parameters - {@link FrogConstructorParameters} * @returns instance. {@link FrogBase} * * @example * ``` * import { Frog } from 'frog' * * const app = new Frog() * * app.frame('/', (c) => { * const { buttonValue, inputText, status } = c * const fruit = inputText || buttonValue * return c.res({ * image: ( *
* {fruit ? `You selected: ${fruit}` : 'Welcome!'} *
* ), * intents: [ * , * , * , * ] * }) * }) * ``` */ export class Frog< env extends Env = Env, schema extends Schema = {}, basePath extends string = '/', // _state = env['State'], > extends FrogBase { constructor(params: FrogConstructorParameters = {}) { super(params as any) const frame = this.frame this.frame = (path: string, ...args: any[]) => { ;(frame as any)(path, ...args) if (this.dev?.enabled ?? true) devRoutes(this, path) return this } } }