Merge pull request #1624 from honojs/next
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Next
authored by Yusuke Wada · committed by GitHub · parents 657b933, 517a6c4 · Browse files · 12 files·+1342 added−29 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
12 files+1342 added−29 removed
- tests:+49 added−0 removed
- other:+1293 added−29 removed
Provenance
- Commit
eb530cd- Tree
86c9e1b- Author
Yusuke Wada <yusuke@kamawada.com>- Committer
GitHub <noreply@github.com>- Parent 1
657b933- Parent 2
517a6c4
12 files changed+1342 added−29 removed
modified:deno_dist/helper/adapter/index.ts+13 added-2 removed
1234567891011121341415161718192010212223242530 unmodified linesimport type { Context } from '../../context.ts'
export type Runtime = | 'node' | 'deno' | 'bun' | 'workerd' | 'fastly' | 'edge-light' | 'lagon' | 'other'
export const env = <T extends Record<string, string>, C extends Context = Context<{}>>( c: C c: C, runtime?: Runtime): T & C['env'] => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const global = globalThis as any const globalEnv = global?.process?.env as T
const runtime = getRuntimeKey() runtime ??= getRuntimeKey()
const runtimeEnvHandlers: Record<string, () => T> = { bun: () => globalEnv, node: () => globalEnv,30 unmodified linesmodified:deno_dist/jsx/index.ts+2 added-1 removed
1 import { escapeToBuffer } from '../utils/html.ts'2 import type { StringBuffer, HtmlEscaped, HtmlEscapedString } from '../utils/html.ts'3+import type { IntrinsicElements as IntrinsicElementsDefined } from './intrinsic-elements.ts'4 5 // eslint-disable-next-line @typescript-eslint/no-explicit-any6 type Props = Record<string, any>7 3 unmodified lines11 type Element = HtmlEscapedString12 interface ElementChildrenAttribute {13 children: Child14 }14- interface IntrinsicElements {15+ interface IntrinsicElements extends IntrinsicElementsDefined {16 [tagName: string]: Props17 }18 }19 }260 unmodified linesadded:deno_dist/jsx/intrinsic-elements.ts+606 added
1+/* eslint-disable @typescript-eslint/no-explicit-any */2+3+/**4+ * This code is based on React.5+ * https://github.com/facebook/react6+ * MIT License7+ * Copyright (c) Meta Platforms, Inc. and affiliates.8+ */9+10+declare global {11+ // eslint-disable-next-line @typescript-eslint/no-namespace12+ namespace Hono {13+ type CrossOrigin = 'anonymous' | 'use-credentials' | '' | undefined14+ type CSSProperties = {}15+ type AnyAttributes = { [attributeName: string]: any }16+17+ interface JSXAttributes {18+ dangerouslySetInnerHTML?: {19+ __html: string20+ }21+ }22+23+ interface HTMLAttributes extends JSXAttributes, AnyAttributes {24+ accesskey?: string | undefined25+ autofocus?: boolean | undefined26+ class?: string | undefined27+ contenteditable?: boolean | 'inherit' | undefined28+ contextmenu?: string | undefined29+ dir?: string | undefined30+ draggable?: boolean | undefined31+ hidden?: boolean | undefined32+ id?: string | undefined33+ lang?: string | undefined34+ nonce?: string | undefined35+ placeholder?: string | undefined36+ slot?: string | undefined37+ spellcheck?: boolean | undefined38+ style?: CSSProperties | undefined39+ tabindex?: number | undefined40+ title?: string | undefined41+ translate?: 'yes' | 'no' | undefined42+ }43+44+ type HTMLAttributeReferrerPolicy =45+ | ''46+ | 'no-referrer'47+ | 'no-referrer-when-downgrade'48+ | 'origin'49+ | 'origin-when-cross-origin'50+ | 'same-origin'51+ | 'strict-origin'52+ | 'strict-origin-when-cross-origin'53+ | 'unsafe-url'54+55+ type HTMLAttributeAnchorTarget = '_self' | '_blank' | '_parent' | '_top' | string56+57+ interface AnchorHTMLAttributes extends HTMLAttributes {58+ download?: any59+ href?: string | undefined60+ hreflang?: string | undefined61+ media?: string | undefined62+ ping?: string | undefined63+ target?: HTMLAttributeAnchorTarget | undefined64+ type?: string | undefined65+ referrerpolicy?: HTMLAttributeReferrerPolicy | undefined66+ }67+68+ interface AudioHTMLAttributes extends MediaHTMLAttributes {}69+70+ interface AreaHTMLAttributes extends HTMLAttributes {71+ alt?: string | undefined72+ coords?: string | undefined73+ download?: any74+ href?: string | undefined75+ hreflang?: string | undefined76+ media?: string | undefined77+ referrerpolicy?: HTMLAttributeReferrerPolicy | undefined78+ shape?: string | undefined79+ target?: string | undefined80+ }81+82+ interface BaseHTMLAttributes extends HTMLAttributes {83+ href?: string | undefined84+ target?: string | undefined85+ }86+87+ interface BlockquoteHTMLAttributes extends HTMLAttributes {88+ cite?: string | undefined89+ }90+91+ interface ButtonHTMLAttributes extends HTMLAttributes {92+ disabled?: boolean | undefined93+ form?: string | undefined94+ formenctype?: string | undefined95+ formmethod?: string | undefined96+ formnovalidate?: boolean | undefined97+ formtarget?: string | undefined98+ name?: string | undefined99+ type?: 'submit' | 'reset' | 'button' | undefined100+ value?: string | ReadonlyArray<string> | number | undefined101+ }102+103+ interface CanvasHTMLAttributes extends HTMLAttributes {104+ height?: number | string | undefined105+ width?: number | string | undefined106+ }107+108+ interface ColHTMLAttributes extends HTMLAttributes {109+ span?: number | undefined110+ width?: number | string | undefined111+ }112+113+ interface ColgroupHTMLAttributes extends HTMLAttributes {114+ span?: number | undefined115+ }116+117+ interface DataHTMLAttributes extends HTMLAttributes {118+ value?: string | ReadonlyArray<string> | number | undefined119+ }120+121+ interface DetailsHTMLAttributes extends HTMLAttributes {122+ open?: boolean | undefined123+ }124+125+ interface DelHTMLAttributes extends HTMLAttributes {126+ cite?: string | undefined127+ dateTime?: string | undefined128+ }129+130+ interface DialogHTMLAttributes extends HTMLAttributes {131+ open?: boolean | undefined132+ }133+134+ interface EmbedHTMLAttributes extends HTMLAttributes {135+ height?: number | string | undefined136+ src?: string | undefined137+ type?: string | undefined138+ width?: number | string | undefined139+ }140+141+ interface FieldsetHTMLAttributes extends HTMLAttributes {142+ disabled?: boolean | undefined143+ form?: string | undefined144+ name?: string | undefined145+ }146+147+ interface FormHTMLAttributes extends HTMLAttributes {148+ 'accept-charset'?: string | undefined149+ autocomplete?: string | undefined150+ enctype?: string | undefined151+ method?: string | undefined152+ name?: string | undefined153+ novalidate?: boolean | undefined154+ target?: string | undefined155+ }156+157+ interface HtmlHTMLAttributes extends HTMLAttributes {158+ manifest?: string | undefined159+ }160+161+ interface IframeHTMLAttributes extends HTMLAttributes {162+ allow?: string | undefined163+ allowfullscreen?: boolean | undefined164+ height?: number | string | undefined165+ loading?: 'eager' | 'lazy' | undefined166+ name?: string | undefined167+ referrerpolicy?: HTMLAttributeReferrerPolicy | undefined168+ sandbox?: string | undefined169+ seamless?: boolean | undefined170+ src?: string | undefined171+ srcdoc?: string | undefined172+ width?: number | string | undefined173+ }174+175+ interface ImgHTMLAttributes extends HTMLAttributes {176+ alt?: string | undefined177+ crossorigin?: CrossOrigin178+ decoding?: 'async' | 'auto' | 'sync' | undefined179+ height?: number | string | undefined180+ loading?: 'eager' | 'lazy' | undefined181+ referrerpolicy?: HTMLAttributeReferrerPolicy | undefined182+ sizes?: string | undefined183+ src?: string | undefined184+ srcset?: string | undefined185+ usemap?: string | undefined186+ width?: number | string | undefined187+ }188+189+ interface InsHTMLAttributes extends HTMLAttributes {190+ cite?: string | undefined191+ datetime?: string | undefined192+ }193+194+ type HTMLInputTypeAttribute =195+ | 'button'196+ | 'checkbox'197+ | 'color'198+ | 'date'199+ | 'datetime-local'200+ | 'email'201+ | 'file'202+ | 'hidden'203+ | 'image'204+ | 'month'205+ | 'number'206+ | 'password'207+ | 'radio'208+ | 'range'209+ | 'reset'210+ | 'search'211+ | 'submit'212+ | 'tel'213+ | 'text'214+ | 'time'215+ | 'url'216+ | 'week'217+ | string218+219+ interface InputHTMLAttributes extends HTMLAttributes {220+ accept?: string | undefined221+ alt?: string | undefined222+ autocomplete?: string | undefined223+ capture?: boolean | 'user' | 'environment' | undefined // https://www.w3.org/TR/html-media-capture/#the-capture-attribute224+ checked?: boolean | undefined225+ disabled?: boolean | undefined226+ enterkeyhint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send' | undefined227+ form?: string | undefined228+ formenctype?: string | undefined229+ formmethod?: string | undefined230+ formnovalidate?: boolean | undefined231+ formtarget?: string | undefined232+ height?: number | string | undefined233+ list?: string | undefined234+ max?: number | string | undefined235+ maxlength?: number | undefined236+ min?: number | string | undefined237+ minlength?: number | undefined238+ multiple?: boolean | undefined239+ name?: string | undefined240+ pattern?: string | undefined241+ placeholder?: string | undefined242+ readonly?: boolean | undefined243+ required?: boolean | undefined244+ size?: number | undefined245+ src?: string | undefined246+ step?: number | string | undefined247+ type?: HTMLInputTypeAttribute | undefined248+ value?: string | ReadonlyArray<string> | number | undefined249+ width?: number | string | undefined250+ }251+252+ interface KeygenHTMLAttributes extends HTMLAttributes {253+ challenge?: string | undefined254+ disabled?: boolean | undefined255+ form?: string | undefined256+ keytype?: string | undefined257+ name?: string | undefined258+ }259+260+ interface LabelHTMLAttributes extends HTMLAttributes {261+ form?: string | undefined262+ for?: string | undefined263+ }264+265+ interface LiHTMLAttributes extends HTMLAttributes {266+ value?: string | ReadonlyArray<string> | number | undefined267+ }268+269+ interface LinkHTMLAttributes extends HTMLAttributes {270+ as?: string | undefined271+ crossorigin?: CrossOrigin272+ href?: string | undefined273+ hreflang?: string | undefined274+ integrity?: string | undefined275+ media?: string | undefined276+ imagesrcset?: string | undefined277+ imagesizes?: string | undefined278+ referrerpolicy?: HTMLAttributeReferrerPolicy | undefined279+ sizes?: string | undefined280+ type?: string | undefined281+ charSet?: string | undefined282+ }283+284+ interface MapHTMLAttributes extends HTMLAttributes {285+ name?: string | undefined286+ }287+288+ interface MenuHTMLAttributes extends HTMLAttributes {289+ type?: string | undefined290+ }291+292+ interface MediaHTMLAttributes extends HTMLAttributes {293+ autoplay?: boolean | undefined294+ controls?: boolean | undefined295+ controlslist?: string | undefined296+ crossorigin?: CrossOrigin297+ loop?: boolean | undefined298+ mediagroup?: string | undefined299+ muted?: boolean | undefined300+ playsinline?: boolean | undefined301+ preload?: string | undefined302+ src?: string | undefined303+ }304+305+ interface MetaHTMLAttributes extends HTMLAttributes {306+ charset?: string | undefined307+ 'http-equiv'?: string | undefined308+ name?: string | undefined309+ media?: string | undefined310+ content?: string | undefined311+ }312+313+ interface MeterHTMLAttributes extends HTMLAttributes {314+ form?: string | undefined315+ high?: number | undefined316+ low?: number | undefined317+ max?: number | string | undefined318+ min?: number | string | undefined319+ optimum?: number | undefined320+ value?: string | ReadonlyArray<string> | number | undefined321+ }322+323+ interface QuoteHTMLAttributes extends HTMLAttributes {324+ cite?: string | undefined325+ }326+327+ interface ObjectHTMLAttributes extends HTMLAttributes {328+ data?: string | undefined329+ form?: string | undefined330+ height?: number | string | undefined331+ name?: string | undefined332+ type?: string | undefined333+ usemap?: string | undefined334+ width?: number | string | undefined335+ }336+337+ interface OlHTMLAttributes extends HTMLAttributes {338+ reversed?: boolean | undefined339+ start?: number | undefined340+ type?: '1' | 'a' | 'A' | 'i' | 'I' | undefined341+ }342+343+ interface OptgroupHTMLAttributes extends HTMLAttributes {344+ disabled?: boolean | undefined345+ label?: string | undefined346+ }347+348+ interface OptionHTMLAttributes extends HTMLAttributes {349+ disabled?: boolean | undefined350+ label?: string | undefined351+ selected?: boolean | undefined352+ value?: string | ReadonlyArray<string> | number | undefined353+ }354+355+ interface OutputHTMLAttributes extends HTMLAttributes {356+ form?: string | undefined357+ for?: string | undefined358+ name?: string | undefined359+ }360+361+ interface ParamHTMLAttributes extends HTMLAttributes {362+ name?: string | undefined363+ value?: string | ReadonlyArray<string> | number | undefined364+ }365+366+ interface ProgressHTMLAttributes extends HTMLAttributes {367+ max?: number | string | undefined368+ value?: string | ReadonlyArray<string> | number | undefined369+ }370+371+ interface SlotHTMLAttributes extends HTMLAttributes {372+ name?: string | undefined373+ }374+375+ interface ScriptHTMLAttributes extends HTMLAttributes {376+ async?: boolean | undefined377+ crossorigin?: CrossOrigin378+ defer?: boolean | undefined379+ integrity?: string | undefined380+ nomodule?: boolean | undefined381+ referrerpolicy?: HTMLAttributeReferrerPolicy | undefined382+ src?: string | undefined383+ type?: string | undefined384+ }385+386+ interface SelectHTMLAttributes extends HTMLAttributes {387+ autocomplete?: string | undefined388+ disabled?: boolean | undefined389+ form?: string | undefined390+ multiple?: boolean | undefined391+ name?: string | undefined392+ required?: boolean | undefined393+ size?: number | undefined394+ value?: string | ReadonlyArray<string> | number | undefined395+ }396+397+ interface SourceHTMLAttributes extends HTMLAttributes {398+ height?: number | string | undefined399+ media?: string | undefined400+ sizes?: string | undefined401+ src?: string | undefined402+ srcset?: string | undefined403+ type?: string | undefined404+ width?: number | string | undefined405+ }406+407+ interface StyleHTMLAttributes extends HTMLAttributes {408+ media?: string | undefined409+ scoped?: boolean | undefined410+ type?: string | undefined411+ }412+413+ interface TableHTMLAttributes extends HTMLAttributes {414+ align?: 'left' | 'center' | 'right' | undefined415+ bgcolor?: string | undefined416+ border?: number | undefined417+ cellpadding?: number | string | undefined418+ cellspacing?: number | string | undefined419+ frame?: boolean | undefined420+ rules?: 'none' | 'groups' | 'rows' | 'columns' | 'all' | undefined421+ summary?: string | undefined422+ width?: number | string | undefined423+ }424+425+ interface TextareaHTMLAttributes extends HTMLAttributes {426+ autocomplete?: string | undefined427+ cols?: number | undefined428+ dirname?: string | undefined429+ disabled?: boolean | undefined430+ form?: string | undefined431+ maxlength?: number | undefined432+ minlength?: number | undefined433+ name?: string | undefined434+ placeholder?: string | undefined435+ readonly?: boolean | undefined436+ required?: boolean | undefined437+ rows?: number | undefined438+ value?: string | ReadonlyArray<string> | number | undefined439+ wrap?: string | undefined440+ }441+442+ interface TdHTMLAttributes extends HTMLAttributes {443+ align?: 'left' | 'center' | 'right' | 'justify' | 'char' | undefined444+ colspan?: number | undefined445+ headers?: string | undefined446+ rowspan?: number | undefined447+ scope?: string | undefined448+ abbr?: string | undefined449+ height?: number | string | undefined450+ width?: number | string | undefined451+ valign?: 'top' | 'middle' | 'bottom' | 'baseline' | undefined452+ }453+454+ interface ThHTMLAttributes extends HTMLAttributes {455+ align?: 'left' | 'center' | 'right' | 'justify' | 'char' | undefined456+ colspan?: number | undefined457+ headers?: string | undefined458+ rowspan?: number | undefined459+ scope?: string | undefined460+ abbr?: string | undefined461+ }462+463+ interface TimeHTMLAttributes extends HTMLAttributes {464+ datetime?: string | undefined465+ }466+467+ interface TrackHTMLAttributes extends HTMLAttributes {468+ default?: boolean | undefined469+ kind?: string | undefined470+ label?: string | undefined471+ src?: string | undefined472+ srclang?: string | undefined473+ }474+475+ interface VideoHTMLAttributes extends MediaHTMLAttributes {476+ height?: number | string | undefined477+ playsinline?: boolean | undefined478+ poster?: string | undefined479+ width?: number | string | undefined480+ disablePictureInPicture?: boolean | undefined481+ disableRemotePlayback?: boolean | undefined482+ }483+484+ interface IntrinsicElements {485+ a: AnchorHTMLAttributes486+ abbr: HTMLAttributes487+ address: HTMLAttributes488+ area: AreaHTMLAttributes489+ article: HTMLAttributes490+ aside: HTMLAttributes491+ audio: AudioHTMLAttributes492+ b: HTMLAttributes493+ base: BaseHTMLAttributes494+ bdi: HTMLAttributes495+ bdo: HTMLAttributes496+ big: HTMLAttributes497+ blockquote: BlockquoteHTMLAttributes498+ body: HTMLAttributes499+ br: HTMLAttributes500+ button: ButtonHTMLAttributes501+ canvas: CanvasHTMLAttributes502+ caption: HTMLAttributes503+ center: HTMLAttributes504+ cite: HTMLAttributes505+ code: HTMLAttributes506+ col: ColHTMLAttributes507+ colgroup: ColgroupHTMLAttributes508+ data: DataHTMLAttributes509+ datalist: HTMLAttributes510+ dd: HTMLAttributes511+ del: DelHTMLAttributes512+ details: DetailsHTMLAttributes513+ dfn: HTMLAttributes514+ dialog: DialogHTMLAttributes515+ div: HTMLAttributes516+ dl: HTMLAttributes517+ dt: HTMLAttributes518+ em: HTMLAttributes519+ embed: EmbedHTMLAttributes520+ fieldset: FieldsetHTMLAttributes521+ figcaption: HTMLAttributes522+ figure: HTMLAttributes523+ footer: HTMLAttributes524+ form: FormHTMLAttributes525+ h1: HTMLAttributes526+ h2: HTMLAttributes527+ h3: HTMLAttributes528+ h4: HTMLAttributes529+ h5: HTMLAttributes530+ h6: HTMLAttributes531+ head: HTMLAttributes532+ header: HTMLAttributes533+ hgroup: HTMLAttributes534+ hr: HTMLAttributes535+ html: HtmlHTMLAttributes536+ i: HTMLAttributes537+ iframe: IframeHTMLAttributes538+ img: ImgHTMLAttributes539+ input: InputHTMLAttributes540+ ins: InsHTMLAttributes541+ kbd: HTMLAttributes542+ keygen: KeygenHTMLAttributes543+ label: LabelHTMLAttributes544+ legend: HTMLAttributes545+ li: LiHTMLAttributes546+ link: LinkHTMLAttributes547+ main: HTMLAttributes548+ map: MapHTMLAttributes549+ mark: HTMLAttributes550+ menu: MenuHTMLAttributes551+ menuitem: HTMLAttributes552+ meta: MetaHTMLAttributes553+ meter: MeterHTMLAttributes554+ nav: HTMLAttributes555+ noscript: HTMLAttributes556+ object: ObjectHTMLAttributes557+ ol: OlHTMLAttributes558+ optgroup: OptgroupHTMLAttributes559+ option: OptionHTMLAttributes560+ output: OutputHTMLAttributes561+ p: HTMLAttributes562+ param: ParamHTMLAttributes563+ picture: HTMLAttributes564+ pre: HTMLAttributes565+ progress: ProgressHTMLAttributes566+ q: QuoteHTMLAttributes567+ rp: HTMLAttributes568+ rt: HTMLAttributes569+ ruby: HTMLAttributes570+ s: HTMLAttributes571+ samp: HTMLAttributes572+ search: HTMLAttributes573+ slot: SlotHTMLAttributes574+ script: ScriptHTMLAttributes575+ section: HTMLAttributes576+ select: SelectHTMLAttributes577+ small: HTMLAttributes578+ source: SourceHTMLAttributes579+ span: HTMLAttributes580+ strong: HTMLAttributes581+ style: StyleHTMLAttributes582+ sub: HTMLAttributes583+ summary: HTMLAttributes584+ sup: HTMLAttributes585+ table: TableHTMLAttributes586+ template: HTMLAttributes587+ tbody: HTMLAttributes588+ td: TdHTMLAttributes589+ textarea: TextareaHTMLAttributes590+ tfoot: HTMLAttributes591+ th: ThHTMLAttributes592+ thead: HTMLAttributes593+ time: TimeHTMLAttributes594+ title: HTMLAttributes595+ tr: HTMLAttributes596+ track: TrackHTMLAttributes597+ u: HTMLAttributes598+ ul: HTMLAttributes599+ var: HTMLAttributes600+ video: VideoHTMLAttributes601+ wbr: HTMLAttributes602+ }603+ }604+}605+606+export interface IntrinsicElements extends Hono.IntrinsicElements {}modified:deno_dist/middleware/jsx-renderer/index.ts+24 added-10 removed
8 unmodified lines9101112131415161718192021222324252614151617181920212728293031323334353637382539404128424344454610 unmodified lines8 unmodified linestype PropsForRenderer = [...Required<Parameters<Renderer>>] extends [unknown, infer Props] ? Props : unknown
type RendererOptions = { docType?: boolean | string}
const createRenderer = (c: Context, component?: FC<PropsForRenderer>, options?: RendererOptions) => (children: JSXNode, props: PropsForRenderer) => { const docType = typeof options?.docType === 'string' ? options.docType : options?.docType === true ? '<!DOCTYPE html>' : ''
(c: Context, component?: FC<PropsForRenderer>) => (children: JSXNode, props: PropsForRenderer) => /* eslint-disable @typescript-eslint/no-explicit-any */ c.html( jsx( RequestContext.Provider, { value: c }, (component ? component({ children, ...(props || {}) }) : children) as any ) as any return c.html( (docType + /* eslint-disable @typescript-eslint/no-explicit-any */ jsx( RequestContext.Provider, { value: c }, (component ? component({ children, ...(props || {}) }) : children) as any )) as any ) }
export const jsxRenderer = (component?: FC<PropsForRenderer>): MiddlewareHandler => (component?: FC<PropsForRenderer>, options?: RendererOptions): MiddlewareHandler => (c, next) => { /* eslint-disable @typescript-eslint/no-explicit-any */ c.setRenderer(createRenderer(c, component) as any) c.setRenderer(createRenderer(c, component, options) as any) return next() }
export const useRequestContext = <10 unmodified linesmodified:deno_dist/context.ts+1 added-1 removed
1+import type { Runtime } from './helper/adapter/index.ts'2 import type { HonoRequest } from './request.ts'3 import type { Env, FetchEventLike, NotFoundHandler, Input, TypedResponse } from './types.ts'4 import type { CookieOptions } from './utils/cookie.ts'5 import { serialize } from './utils/cookie.ts'6 import type { StatusCode } from './utils/http-status.ts'7 import { StreamingApi } from './utils/stream.ts'8 import type { JSONValue, InterfaceToType } from './utils/types.ts'9 9-type Runtime = 'node' | 'deno' | 'bun' | 'workerd' | 'fastly' | 'edge-light' | 'lagon' | 'other'10 type HeaderRecord = Record<string, string | string[]>11 type Data = string | ArrayBuffer | ReadableStream12 13 export interface ExecutionContext {458 unmodified linesmodified:src/helper/adapter/index.ts+13 added-2 removed
1234567891011121341415161718192010212223242530 unmodified linesimport type { Context } from '../../context'
export type Runtime = | 'node' | 'deno' | 'bun' | 'workerd' | 'fastly' | 'edge-light' | 'lagon' | 'other'
export const env = <T extends Record<string, string>, C extends Context = Context<{}>>( c: C c: C, runtime?: Runtime): T & C['env'] => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const global = globalThis as any const globalEnv = global?.process?.env as T
const runtime = getRuntimeKey() runtime ??= getRuntimeKey()
const runtimeEnvHandlers: Record<string, () => T> = { bun: () => globalEnv, node: () => globalEnv,30 unmodified linesmodified:src/jsx/index.ts+2 added-1 removed
1 import { escapeToBuffer } from '../utils/html'2 import type { StringBuffer, HtmlEscaped, HtmlEscapedString } from '../utils/html'3+import type { IntrinsicElements as IntrinsicElementsDefined } from './intrinsic-elements'4 5 // eslint-disable-next-line @typescript-eslint/no-explicit-any6 type Props = Record<string, any>7 3 unmodified lines11 type Element = HtmlEscapedString12 interface ElementChildrenAttribute {13 children: Child14 }14- interface IntrinsicElements {15+ interface IntrinsicElements extends IntrinsicElementsDefined {16 [tagName: string]: Props17 }18 }19 }260 unmodified linesadded:src/jsx/intrinsic-elements.ts+606 added
1+/* eslint-disable @typescript-eslint/no-explicit-any */2+3+/**4+ * This code is based on React.5+ * https://github.com/facebook/react6+ * MIT License7+ * Copyright (c) Meta Platforms, Inc. and affiliates.8+ */9+10+declare global {11+ // eslint-disable-next-line @typescript-eslint/no-namespace12+ namespace Hono {13+ type CrossOrigin = 'anonymous' | 'use-credentials' | '' | undefined14+ type CSSProperties = {}15+ type AnyAttributes = { [attributeName: string]: any }16+17+ interface JSXAttributes {18+ dangerouslySetInnerHTML?: {19+ __html: string20+ }21+ }22+23+ interface HTMLAttributes extends JSXAttributes, AnyAttributes {24+ accesskey?: string | undefined25+ autofocus?: boolean | undefined26+ class?: string | undefined27+ contenteditable?: boolean | 'inherit' | undefined28+ contextmenu?: string | undefined29+ dir?: string | undefined30+ draggable?: boolean | undefined31+ hidden?: boolean | undefined32+ id?: string | undefined33+ lang?: string | undefined34+ nonce?: string | undefined35+ placeholder?: string | undefined36+ slot?: string | undefined37+ spellcheck?: boolean | undefined38+ style?: CSSProperties | undefined39+ tabindex?: number | undefined40+ title?: string | undefined41+ translate?: 'yes' | 'no' | undefined42+ }43+44+ type HTMLAttributeReferrerPolicy =45+ | ''46+ | 'no-referrer'47+ | 'no-referrer-when-downgrade'48+ | 'origin'49+ | 'origin-when-cross-origin'50+ | 'same-origin'51+ | 'strict-origin'52+ | 'strict-origin-when-cross-origin'53+ | 'unsafe-url'54+55+ type HTMLAttributeAnchorTarget = '_self' | '_blank' | '_parent' | '_top' | string56+57+ interface AnchorHTMLAttributes extends HTMLAttributes {58+ download?: any59+ href?: string | undefined60+ hreflang?: string | undefined61+ media?: string | undefined62+ ping?: string | undefined63+ target?: HTMLAttributeAnchorTarget | undefined64+ type?: string | undefined65+ referrerpolicy?: HTMLAttributeReferrerPolicy | undefined66+ }67+68+ interface AudioHTMLAttributes extends MediaHTMLAttributes {}69+70+ interface AreaHTMLAttributes extends HTMLAttributes {71+ alt?: string | undefined72+ coords?: string | undefined73+ download?: any74+ href?: string | undefined75+ hreflang?: string | undefined76+ media?: string | undefined77+ referrerpolicy?: HTMLAttributeReferrerPolicy | undefined78+ shape?: string | undefined79+ target?: string | undefined80+ }81+82+ interface BaseHTMLAttributes extends HTMLAttributes {83+ href?: string | undefined84+ target?: string | undefined85+ }86+87+ interface BlockquoteHTMLAttributes extends HTMLAttributes {88+ cite?: string | undefined89+ }90+91+ interface ButtonHTMLAttributes extends HTMLAttributes {92+ disabled?: boolean | undefined93+ form?: string | undefined94+ formenctype?: string | undefined95+ formmethod?: string | undefined96+ formnovalidate?: boolean | undefined97+ formtarget?: string | undefined98+ name?: string | undefined99+ type?: 'submit' | 'reset' | 'button' | undefined100+ value?: string | ReadonlyArray<string> | number | undefined101+ }102+103+ interface CanvasHTMLAttributes extends HTMLAttributes {104+ height?: number | string | undefined105+ width?: number | string | undefined106+ }107+108+ interface ColHTMLAttributes extends HTMLAttributes {109+ span?: number | undefined110+ width?: number | string | undefined111+ }112+113+ interface ColgroupHTMLAttributes extends HTMLAttributes {114+ span?: number | undefined115+ }116+117+ interface DataHTMLAttributes extends HTMLAttributes {118+ value?: string | ReadonlyArray<string> | number | undefined119+ }120+121+ interface DetailsHTMLAttributes extends HTMLAttributes {122+ open?: boolean | undefined123+ }124+125+ interface DelHTMLAttributes extends HTMLAttributes {126+ cite?: string | undefined127+ dateTime?: string | undefined128+ }129+130+ interface DialogHTMLAttributes extends HTMLAttributes {131+ open?: boolean | undefined132+ }133+134+ interface EmbedHTMLAttributes extends HTMLAttributes {135+ height?: number | string | undefined136+ src?: string | undefined137+ type?: string | undefined138+ width?: number | string | undefined139+ }140+141+ interface FieldsetHTMLAttributes extends HTMLAttributes {142+ disabled?: boolean | undefined143+ form?: string | undefined144+ name?: string | undefined145+ }146+147+ interface FormHTMLAttributes extends HTMLAttributes {148+ 'accept-charset'?: string | undefined149+ autocomplete?: string | undefined150+ enctype?: string | undefined151+ method?: string | undefined152+ name?: string | undefined153+ novalidate?: boolean | undefined154+ target?: string | undefined155+ }156+157+ interface HtmlHTMLAttributes extends HTMLAttributes {158+ manifest?: string | undefined159+ }160+161+ interface IframeHTMLAttributes extends HTMLAttributes {162+ allow?: string | undefined163+ allowfullscreen?: boolean | undefined164+ height?: number | string | undefined165+ loading?: 'eager' | 'lazy' | undefined166+ name?: string | undefined167+ referrerpolicy?: HTMLAttributeReferrerPolicy | undefined168+ sandbox?: string | undefined169+ seamless?: boolean | undefined170+ src?: string | undefined171+ srcdoc?: string | undefined172+ width?: number | string | undefined173+ }174+175+ interface ImgHTMLAttributes extends HTMLAttributes {176+ alt?: string | undefined177+ crossorigin?: CrossOrigin178+ decoding?: 'async' | 'auto' | 'sync' | undefined179+ height?: number | string | undefined180+ loading?: 'eager' | 'lazy' | undefined181+ referrerpolicy?: HTMLAttributeReferrerPolicy | undefined182+ sizes?: string | undefined183+ src?: string | undefined184+ srcset?: string | undefined185+ usemap?: string | undefined186+ width?: number | string | undefined187+ }188+189+ interface InsHTMLAttributes extends HTMLAttributes {190+ cite?: string | undefined191+ datetime?: string | undefined192+ }193+194+ type HTMLInputTypeAttribute =195+ | 'button'196+ | 'checkbox'197+ | 'color'198+ | 'date'199+ | 'datetime-local'200+ | 'email'201+ | 'file'202+ | 'hidden'203+ | 'image'204+ | 'month'205+ | 'number'206+ | 'password'207+ | 'radio'208+ | 'range'209+ | 'reset'210+ | 'search'211+ | 'submit'212+ | 'tel'213+ | 'text'214+ | 'time'215+ | 'url'216+ | 'week'217+ | string218+219+ interface InputHTMLAttributes extends HTMLAttributes {220+ accept?: string | undefined221+ alt?: string | undefined222+ autocomplete?: string | undefined223+ capture?: boolean | 'user' | 'environment' | undefined // https://www.w3.org/TR/html-media-capture/#the-capture-attribute224+ checked?: boolean | undefined225+ disabled?: boolean | undefined226+ enterkeyhint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send' | undefined227+ form?: string | undefined228+ formenctype?: string | undefined229+ formmethod?: string | undefined230+ formnovalidate?: boolean | undefined231+ formtarget?: string | undefined232+ height?: number | string | undefined233+ list?: string | undefined234+ max?: number | string | undefined235+ maxlength?: number | undefined236+ min?: number | string | undefined237+ minlength?: number | undefined238+ multiple?: boolean | undefined239+ name?: string | undefined240+ pattern?: string | undefined241+ placeholder?: string | undefined242+ readonly?: boolean | undefined243+ required?: boolean | undefined244+ size?: number | undefined245+ src?: string | undefined246+ step?: number | string | undefined247+ type?: HTMLInputTypeAttribute | undefined248+ value?: string | ReadonlyArray<string> | number | undefined249+ width?: number | string | undefined250+ }251+252+ interface KeygenHTMLAttributes extends HTMLAttributes {253+ challenge?: string | undefined254+ disabled?: boolean | undefined255+ form?: string | undefined256+ keytype?: string | undefined257+ name?: string | undefined258+ }259+260+ interface LabelHTMLAttributes extends HTMLAttributes {261+ form?: string | undefined262+ for?: string | undefined263+ }264+265+ interface LiHTMLAttributes extends HTMLAttributes {266+ value?: string | ReadonlyArray<string> | number | undefined267+ }268+269+ interface LinkHTMLAttributes extends HTMLAttributes {270+ as?: string | undefined271+ crossorigin?: CrossOrigin272+ href?: string | undefined273+ hreflang?: string | undefined274+ integrity?: string | undefined275+ media?: string | undefined276+ imagesrcset?: string | undefined277+ imagesizes?: string | undefined278+ referrerpolicy?: HTMLAttributeReferrerPolicy | undefined279+ sizes?: string | undefined280+ type?: string | undefined281+ charSet?: string | undefined282+ }283+284+ interface MapHTMLAttributes extends HTMLAttributes {285+ name?: string | undefined286+ }287+288+ interface MenuHTMLAttributes extends HTMLAttributes {289+ type?: string | undefined290+ }291+292+ interface MediaHTMLAttributes extends HTMLAttributes {293+ autoplay?: boolean | undefined294+ controls?: boolean | undefined295+ controlslist?: string | undefined296+ crossorigin?: CrossOrigin297+ loop?: boolean | undefined298+ mediagroup?: string | undefined299+ muted?: boolean | undefined300+ playsinline?: boolean | undefined301+ preload?: string | undefined302+ src?: string | undefined303+ }304+305+ interface MetaHTMLAttributes extends HTMLAttributes {306+ charset?: string | undefined307+ 'http-equiv'?: string | undefined308+ name?: string | undefined309+ media?: string | undefined310+ content?: string | undefined311+ }312+313+ interface MeterHTMLAttributes extends HTMLAttributes {314+ form?: string | undefined315+ high?: number | undefined316+ low?: number | undefined317+ max?: number | string | undefined318+ min?: number | string | undefined319+ optimum?: number | undefined320+ value?: string | ReadonlyArray<string> | number | undefined321+ }322+323+ interface QuoteHTMLAttributes extends HTMLAttributes {324+ cite?: string | undefined325+ }326+327+ interface ObjectHTMLAttributes extends HTMLAttributes {328+ data?: string | undefined329+ form?: string | undefined330+ height?: number | string | undefined331+ name?: string | undefined332+ type?: string | undefined333+ usemap?: string | undefined334+ width?: number | string | undefined335+ }336+337+ interface OlHTMLAttributes extends HTMLAttributes {338+ reversed?: boolean | undefined339+ start?: number | undefined340+ type?: '1' | 'a' | 'A' | 'i' | 'I' | undefined341+ }342+343+ interface OptgroupHTMLAttributes extends HTMLAttributes {344+ disabled?: boolean | undefined345+ label?: string | undefined346+ }347+348+ interface OptionHTMLAttributes extends HTMLAttributes {349+ disabled?: boolean | undefined350+ label?: string | undefined351+ selected?: boolean | undefined352+ value?: string | ReadonlyArray<string> | number | undefined353+ }354+355+ interface OutputHTMLAttributes extends HTMLAttributes {356+ form?: string | undefined357+ for?: string | undefined358+ name?: string | undefined359+ }360+361+ interface ParamHTMLAttributes extends HTMLAttributes {362+ name?: string | undefined363+ value?: string | ReadonlyArray<string> | number | undefined364+ }365+366+ interface ProgressHTMLAttributes extends HTMLAttributes {367+ max?: number | string | undefined368+ value?: string | ReadonlyArray<string> | number | undefined369+ }370+371+ interface SlotHTMLAttributes extends HTMLAttributes {372+ name?: string | undefined373+ }374+375+ interface ScriptHTMLAttributes extends HTMLAttributes {376+ async?: boolean | undefined377+ crossorigin?: CrossOrigin378+ defer?: boolean | undefined379+ integrity?: string | undefined380+ nomodule?: boolean | undefined381+ referrerpolicy?: HTMLAttributeReferrerPolicy | undefined382+ src?: string | undefined383+ type?: string | undefined384+ }385+386+ interface SelectHTMLAttributes extends HTMLAttributes {387+ autocomplete?: string | undefined388+ disabled?: boolean | undefined389+ form?: string | undefined390+ multiple?: boolean | undefined391+ name?: string | undefined392+ required?: boolean | undefined393+ size?: number | undefined394+ value?: string | ReadonlyArray<string> | number | undefined395+ }396+397+ interface SourceHTMLAttributes extends HTMLAttributes {398+ height?: number | string | undefined399+ media?: string | undefined400+ sizes?: string | undefined401+ src?: string | undefined402+ srcset?: string | undefined403+ type?: string | undefined404+ width?: number | string | undefined405+ }406+407+ interface StyleHTMLAttributes extends HTMLAttributes {408+ media?: string | undefined409+ scoped?: boolean | undefined410+ type?: string | undefined411+ }412+413+ interface TableHTMLAttributes extends HTMLAttributes {414+ align?: 'left' | 'center' | 'right' | undefined415+ bgcolor?: string | undefined416+ border?: number | undefined417+ cellpadding?: number | string | undefined418+ cellspacing?: number | string | undefined419+ frame?: boolean | undefined420+ rules?: 'none' | 'groups' | 'rows' | 'columns' | 'all' | undefined421+ summary?: string | undefined422+ width?: number | string | undefined423+ }424+425+ interface TextareaHTMLAttributes extends HTMLAttributes {426+ autocomplete?: string | undefined427+ cols?: number | undefined428+ dirname?: string | undefined429+ disabled?: boolean | undefined430+ form?: string | undefined431+ maxlength?: number | undefined432+ minlength?: number | undefined433+ name?: string | undefined434+ placeholder?: string | undefined435+ readonly?: boolean | undefined436+ required?: boolean | undefined437+ rows?: number | undefined438+ value?: string | ReadonlyArray<string> | number | undefined439+ wrap?: string | undefined440+ }441+442+ interface TdHTMLAttributes extends HTMLAttributes {443+ align?: 'left' | 'center' | 'right' | 'justify' | 'char' | undefined444+ colspan?: number | undefined445+ headers?: string | undefined446+ rowspan?: number | undefined447+ scope?: string | undefined448+ abbr?: string | undefined449+ height?: number | string | undefined450+ width?: number | string | undefined451+ valign?: 'top' | 'middle' | 'bottom' | 'baseline' | undefined452+ }453+454+ interface ThHTMLAttributes extends HTMLAttributes {455+ align?: 'left' | 'center' | 'right' | 'justify' | 'char' | undefined456+ colspan?: number | undefined457+ headers?: string | undefined458+ rowspan?: number | undefined459+ scope?: string | undefined460+ abbr?: string | undefined461+ }462+463+ interface TimeHTMLAttributes extends HTMLAttributes {464+ datetime?: string | undefined465+ }466+467+ interface TrackHTMLAttributes extends HTMLAttributes {468+ default?: boolean | undefined469+ kind?: string | undefined470+ label?: string | undefined471+ src?: string | undefined472+ srclang?: string | undefined473+ }474+475+ interface VideoHTMLAttributes extends MediaHTMLAttributes {476+ height?: number | string | undefined477+ playsinline?: boolean | undefined478+ poster?: string | undefined479+ width?: number | string | undefined480+ disablePictureInPicture?: boolean | undefined481+ disableRemotePlayback?: boolean | undefined482+ }483+484+ interface IntrinsicElements {485+ a: AnchorHTMLAttributes486+ abbr: HTMLAttributes487+ address: HTMLAttributes488+ area: AreaHTMLAttributes489+ article: HTMLAttributes490+ aside: HTMLAttributes491+ audio: AudioHTMLAttributes492+ b: HTMLAttributes493+ base: BaseHTMLAttributes494+ bdi: HTMLAttributes495+ bdo: HTMLAttributes496+ big: HTMLAttributes497+ blockquote: BlockquoteHTMLAttributes498+ body: HTMLAttributes499+ br: HTMLAttributes500+ button: ButtonHTMLAttributes501+ canvas: CanvasHTMLAttributes502+ caption: HTMLAttributes503+ center: HTMLAttributes504+ cite: HTMLAttributes505+ code: HTMLAttributes506+ col: ColHTMLAttributes507+ colgroup: ColgroupHTMLAttributes508+ data: DataHTMLAttributes509+ datalist: HTMLAttributes510+ dd: HTMLAttributes511+ del: DelHTMLAttributes512+ details: DetailsHTMLAttributes513+ dfn: HTMLAttributes514+ dialog: DialogHTMLAttributes515+ div: HTMLAttributes516+ dl: HTMLAttributes517+ dt: HTMLAttributes518+ em: HTMLAttributes519+ embed: EmbedHTMLAttributes520+ fieldset: FieldsetHTMLAttributes521+ figcaption: HTMLAttributes522+ figure: HTMLAttributes523+ footer: HTMLAttributes524+ form: FormHTMLAttributes525+ h1: HTMLAttributes526+ h2: HTMLAttributes527+ h3: HTMLAttributes528+ h4: HTMLAttributes529+ h5: HTMLAttributes530+ h6: HTMLAttributes531+ head: HTMLAttributes532+ header: HTMLAttributes533+ hgroup: HTMLAttributes534+ hr: HTMLAttributes535+ html: HtmlHTMLAttributes536+ i: HTMLAttributes537+ iframe: IframeHTMLAttributes538+ img: ImgHTMLAttributes539+ input: InputHTMLAttributes540+ ins: InsHTMLAttributes541+ kbd: HTMLAttributes542+ keygen: KeygenHTMLAttributes543+ label: LabelHTMLAttributes544+ legend: HTMLAttributes545+ li: LiHTMLAttributes546+ link: LinkHTMLAttributes547+ main: HTMLAttributes548+ map: MapHTMLAttributes549+ mark: HTMLAttributes550+ menu: MenuHTMLAttributes551+ menuitem: HTMLAttributes552+ meta: MetaHTMLAttributes553+ meter: MeterHTMLAttributes554+ nav: HTMLAttributes555+ noscript: HTMLAttributes556+ object: ObjectHTMLAttributes557+ ol: OlHTMLAttributes558+ optgroup: OptgroupHTMLAttributes559+ option: OptionHTMLAttributes560+ output: OutputHTMLAttributes561+ p: HTMLAttributes562+ param: ParamHTMLAttributes563+ picture: HTMLAttributes564+ pre: HTMLAttributes565+ progress: ProgressHTMLAttributes566+ q: QuoteHTMLAttributes567+ rp: HTMLAttributes568+ rt: HTMLAttributes569+ ruby: HTMLAttributes570+ s: HTMLAttributes571+ samp: HTMLAttributes572+ search: HTMLAttributes573+ slot: SlotHTMLAttributes574+ script: ScriptHTMLAttributes575+ section: HTMLAttributes576+ select: SelectHTMLAttributes577+ small: HTMLAttributes578+ source: SourceHTMLAttributes579+ span: HTMLAttributes580+ strong: HTMLAttributes581+ style: StyleHTMLAttributes582+ sub: HTMLAttributes583+ summary: HTMLAttributes584+ sup: HTMLAttributes585+ table: TableHTMLAttributes586+ template: HTMLAttributes587+ tbody: HTMLAttributes588+ td: TdHTMLAttributes589+ textarea: TextareaHTMLAttributes590+ tfoot: HTMLAttributes591+ th: ThHTMLAttributes592+ thead: HTMLAttributes593+ time: TimeHTMLAttributes594+ title: HTMLAttributes595+ tr: HTMLAttributes596+ track: TrackHTMLAttributes597+ u: HTMLAttributes598+ ul: HTMLAttributes599+ var: HTMLAttributes600+ video: VideoHTMLAttributes601+ wbr: HTMLAttributes602+ }603+ }604+}605+606+export interface IntrinsicElements extends Hono.IntrinsicElements {}modified:src/middleware/jsx-renderer/index.test.tsx+49 added
54 unmodified lines55 expect(res.status).toBe(200)56 expect(await res.text()).toBe('<h1>http://localhost/</h1>')57 })58 59+ it('Should return a default doctype', async () => {60+ const app = new Hono()61+ app.use(62+ '*',63+ jsxRenderer(64+ ({ children }) => {65+ return (66+ <html>67+ <body>{children}</body>68+ </html>69+ )70+ },71+ { docType: true }72+ )73+ )74+ app.get('/', (c) => c.render(<h1>Hello</h1>, { title: 'Title' }))75+ const res = await app.request('/')76+ expect(res).not.toBeNull()77+ expect(res.status).toBe(200)78+ expect(await res.text()).toBe('<!DOCTYPE html><html><body><h1>Hello</h1></body></html>')79+ })80+81+ it('Should return a custom doctype', async () => {82+ const app = new Hono()83+ app.use(84+ '*',85+ jsxRenderer(86+ ({ children }) => {87+ return (88+ <html>89+ <body>{children}</body>90+ </html>91+ )92+ },93+ {94+ docType:95+ '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',96+ }97+ )98+ )99+ app.get('/', (c) => c.render(<h1>Hello</h1>, { title: 'Title' }))100+ const res = await app.request('/')101+ expect(res).not.toBeNull()102+ expect(res.status).toBe(200)103+ expect(await res.text()).toBe(104+ '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><body><h1>Hello</h1></body></html>'105+ )106+ })107+108 it('Env', async () => {109 type JSXRendererEnv = {110 Variables: {111 foo: string40 unmodified linesmodified:src/middleware/jsx-renderer/index.ts+24 added-10 removed
8 unmodified lines9 type PropsForRenderer = [...Required<Parameters<Renderer>>] extends [unknown, infer Props]10 ? Props11 : unknown12 13+type RendererOptions = {14+ docType?: boolean | string15+}16+17 const createRenderer =18+ (c: Context, component?: FC<PropsForRenderer>, options?: RendererOptions) =>19+ (children: JSXNode, props: PropsForRenderer) => {20+ const docType =21+ typeof options?.docType === 'string'22+ ? options.docType23+ : options?.docType === true24+ ? '<!DOCTYPE html>'25+ : ''26+14- (c: Context, component?: FC<PropsForRenderer>) => (children: JSXNode, props: PropsForRenderer) =>15- /* eslint-disable @typescript-eslint/no-explicit-any */16- c.html(17- jsx(18- RequestContext.Provider,19- { value: c },20- (component ? component({ children, ...(props || {}) }) : children) as any21- ) as any27+ return c.html(28+ (docType +29+ /* eslint-disable @typescript-eslint/no-explicit-any */30+ jsx(31+ RequestContext.Provider,32+ { value: c },33+ (component ? component({ children, ...(props || {}) }) : children) as any34+ )) as any35 )36+ }37 38 export const jsxRenderer =25- (component?: FC<PropsForRenderer>): MiddlewareHandler =>39+ (component?: FC<PropsForRenderer>, options?: RendererOptions): MiddlewareHandler =>40 (c, next) => {41 /* eslint-disable @typescript-eslint/no-explicit-any */28- c.setRenderer(createRenderer(c, component) as any)42+ c.setRenderer(createRenderer(c, component, options) as any)43 return next()44 }45 46 export const useRequestContext = <10 unmodified linesmodified:src/context.ts+1 added-1 removed
1+import type { Runtime } from './helper/adapter'2 import type { HonoRequest } from './request'3 import type { Env, FetchEventLike, NotFoundHandler, Input, TypedResponse } from './types'4 import type { CookieOptions } from './utils/cookie'5 import { serialize } from './utils/cookie'6 import type { StatusCode } from './utils/http-status'7 import { StreamingApi } from './utils/stream'8 import type { JSONValue, InterfaceToType } from './utils/types'9 9-type Runtime = 'node' | 'deno' | 'bun' | 'workerd' | 'fastly' | 'edge-light' | 'lagon' | 'other'10 type HeaderRecord = Record<string, string | string[]>11 type Data = string | ArrayBuffer | ReadableStream12 13 export interface ExecutionContext {458 unmodified linesmodified:package.json+1 added-1 removed
1 {2 "name": "hono",3- "version": "3.8.4",3+ "version": "3.9.0-rc.1",4 "description": "Ultrafast web framework for the Edges",5 "main": "dist/cjs/index.js",6 "type": "module",7 "module": "dist/index.js",460 unmodified lines