Skip to content
Myr

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

12 files+1342 added−29 removed

modified:deno_dist/helper/adapter/index.ts+13 added-2 removed
modified:deno_dist/jsx/index.ts+2 added-1 removed
1import { escapeToBuffer } from '../utils/html.ts'2import type { StringBuffer, HtmlEscaped, HtmlEscapedString } from '../utils/html.ts'3import type { IntrinsicElements as IntrinsicElementsDefined } from './intrinsic-elements.ts'45// eslint-disable-next-line @typescript-eslint/no-explicit-any6type Props = Record<string, any>7
3 unmodified lines
11 type Element = HtmlEscapedString12 interface ElementChildrenAttribute {13 children: Child14 }14 interface IntrinsicElements {15 interface IntrinsicElements extends IntrinsicElementsDefined {16 [tagName: string]: Props17 }18 }19}
260 unmodified lines
added:deno_dist/jsx/intrinsic-elements.ts+606 added
1/* eslint-disable @typescript-eslint/no-explicit-any */23/**4 * This code is based on React.5 * https://github.com/facebook/react6 * MIT License7 * Copyright (c) Meta Platforms, Inc. and affiliates.8 */910declare 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 }1617 interface JSXAttributes {18 dangerouslySetInnerHTML?: {19 __html: string20 }21 }2223 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 }4344 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'5455 type HTMLAttributeAnchorTarget = '_self' | '_blank' | '_parent' | '_top' | string5657 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 }6768 interface AudioHTMLAttributes extends MediaHTMLAttributes {}6970 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 }8182 interface BaseHTMLAttributes extends HTMLAttributes {83 href?: string | undefined84 target?: string | undefined85 }8687 interface BlockquoteHTMLAttributes extends HTMLAttributes {88 cite?: string | undefined89 }9091 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 }102103 interface CanvasHTMLAttributes extends HTMLAttributes {104 height?: number | string | undefined105 width?: number | string | undefined106 }107108 interface ColHTMLAttributes extends HTMLAttributes {109 span?: number | undefined110 width?: number | string | undefined111 }112113 interface ColgroupHTMLAttributes extends HTMLAttributes {114 span?: number | undefined115 }116117 interface DataHTMLAttributes extends HTMLAttributes {118 value?: string | ReadonlyArray<string> | number | undefined119 }120121 interface DetailsHTMLAttributes extends HTMLAttributes {122 open?: boolean | undefined123 }124125 interface DelHTMLAttributes extends HTMLAttributes {126 cite?: string | undefined127 dateTime?: string | undefined128 }129130 interface DialogHTMLAttributes extends HTMLAttributes {131 open?: boolean | undefined132 }133134 interface EmbedHTMLAttributes extends HTMLAttributes {135 height?: number | string | undefined136 src?: string | undefined137 type?: string | undefined138 width?: number | string | undefined139 }140141 interface FieldsetHTMLAttributes extends HTMLAttributes {142 disabled?: boolean | undefined143 form?: string | undefined144 name?: string | undefined145 }146147 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 }156157 interface HtmlHTMLAttributes extends HTMLAttributes {158 manifest?: string | undefined159 }160161 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 }174175 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 }188189 interface InsHTMLAttributes extends HTMLAttributes {190 cite?: string | undefined191 datetime?: string | undefined192 }193194 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 | string218219 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 }251252 interface KeygenHTMLAttributes extends HTMLAttributes {253 challenge?: string | undefined254 disabled?: boolean | undefined255 form?: string | undefined256 keytype?: string | undefined257 name?: string | undefined258 }259260 interface LabelHTMLAttributes extends HTMLAttributes {261 form?: string | undefined262 for?: string | undefined263 }264265 interface LiHTMLAttributes extends HTMLAttributes {266 value?: string | ReadonlyArray<string> | number | undefined267 }268269 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 }283284 interface MapHTMLAttributes extends HTMLAttributes {285 name?: string | undefined286 }287288 interface MenuHTMLAttributes extends HTMLAttributes {289 type?: string | undefined290 }291292 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 }304305 interface MetaHTMLAttributes extends HTMLAttributes {306 charset?: string | undefined307 'http-equiv'?: string | undefined308 name?: string | undefined309 media?: string | undefined310 content?: string | undefined311 }312313 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 }322323 interface QuoteHTMLAttributes extends HTMLAttributes {324 cite?: string | undefined325 }326327 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 }336337 interface OlHTMLAttributes extends HTMLAttributes {338 reversed?: boolean | undefined339 start?: number | undefined340 type?: '1' | 'a' | 'A' | 'i' | 'I' | undefined341 }342343 interface OptgroupHTMLAttributes extends HTMLAttributes {344 disabled?: boolean | undefined345 label?: string | undefined346 }347348 interface OptionHTMLAttributes extends HTMLAttributes {349 disabled?: boolean | undefined350 label?: string | undefined351 selected?: boolean | undefined352 value?: string | ReadonlyArray<string> | number | undefined353 }354355 interface OutputHTMLAttributes extends HTMLAttributes {356 form?: string | undefined357 for?: string | undefined358 name?: string | undefined359 }360361 interface ParamHTMLAttributes extends HTMLAttributes {362 name?: string | undefined363 value?: string | ReadonlyArray<string> | number | undefined364 }365366 interface ProgressHTMLAttributes extends HTMLAttributes {367 max?: number | string | undefined368 value?: string | ReadonlyArray<string> | number | undefined369 }370371 interface SlotHTMLAttributes extends HTMLAttributes {372 name?: string | undefined373 }374375 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 }385386 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 }396397 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 }406407 interface StyleHTMLAttributes extends HTMLAttributes {408 media?: string | undefined409 scoped?: boolean | undefined410 type?: string | undefined411 }412413 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 }424425 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 }441442 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 }453454 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 }462463 interface TimeHTMLAttributes extends HTMLAttributes {464 datetime?: string | undefined465 }466467 interface TrackHTMLAttributes extends HTMLAttributes {468 default?: boolean | undefined469 kind?: string | undefined470 label?: string | undefined471 src?: string | undefined472 srclang?: string | undefined473 }474475 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 }483484 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}605606export interface IntrinsicElements extends Hono.IntrinsicElements {}
modified:deno_dist/middleware/jsx-renderer/index.ts+24 added-10 removed
modified:deno_dist/context.ts+1 added-1 removed
1import type { Runtime } from './helper/adapter/index.ts'2import type { HonoRequest } from './request.ts'3import type { Env, FetchEventLike, NotFoundHandler, Input, TypedResponse } from './types.ts'4import type { CookieOptions } from './utils/cookie.ts'5import { serialize } from './utils/cookie.ts'6import type { StatusCode } from './utils/http-status.ts'7import { StreamingApi } from './utils/stream.ts'8import type { JSONValue, InterfaceToType } from './utils/types.ts'99type Runtime = 'node' | 'deno' | 'bun' | 'workerd' | 'fastly' | 'edge-light' | 'lagon' | 'other'10type HeaderRecord = Record<string, string | string[]>11type Data = string | ArrayBuffer | ReadableStream1213export interface ExecutionContext {
458 unmodified lines
modified:src/helper/adapter/index.ts+13 added-2 removed
modified:src/jsx/index.ts+2 added-1 removed
1import { escapeToBuffer } from '../utils/html'2import type { StringBuffer, HtmlEscaped, HtmlEscapedString } from '../utils/html'3import type { IntrinsicElements as IntrinsicElementsDefined } from './intrinsic-elements'45// eslint-disable-next-line @typescript-eslint/no-explicit-any6type Props = Record<string, any>7
3 unmodified lines
11 type Element = HtmlEscapedString12 interface ElementChildrenAttribute {13 children: Child14 }14 interface IntrinsicElements {15 interface IntrinsicElements extends IntrinsicElementsDefined {16 [tagName: string]: Props17 }18 }19}
260 unmodified lines
added:src/jsx/intrinsic-elements.ts+606 added
1/* eslint-disable @typescript-eslint/no-explicit-any */23/**4 * This code is based on React.5 * https://github.com/facebook/react6 * MIT License7 * Copyright (c) Meta Platforms, Inc. and affiliates.8 */910declare 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 }1617 interface JSXAttributes {18 dangerouslySetInnerHTML?: {19 __html: string20 }21 }2223 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 }4344 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'5455 type HTMLAttributeAnchorTarget = '_self' | '_blank' | '_parent' | '_top' | string5657 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 }6768 interface AudioHTMLAttributes extends MediaHTMLAttributes {}6970 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 }8182 interface BaseHTMLAttributes extends HTMLAttributes {83 href?: string | undefined84 target?: string | undefined85 }8687 interface BlockquoteHTMLAttributes extends HTMLAttributes {88 cite?: string | undefined89 }9091 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 }102103 interface CanvasHTMLAttributes extends HTMLAttributes {104 height?: number | string | undefined105 width?: number | string | undefined106 }107108 interface ColHTMLAttributes extends HTMLAttributes {109 span?: number | undefined110 width?: number | string | undefined111 }112113 interface ColgroupHTMLAttributes extends HTMLAttributes {114 span?: number | undefined115 }116117 interface DataHTMLAttributes extends HTMLAttributes {118 value?: string | ReadonlyArray<string> | number | undefined119 }120121 interface DetailsHTMLAttributes extends HTMLAttributes {122 open?: boolean | undefined123 }124125 interface DelHTMLAttributes extends HTMLAttributes {126 cite?: string | undefined127 dateTime?: string | undefined128 }129130 interface DialogHTMLAttributes extends HTMLAttributes {131 open?: boolean | undefined132 }133134 interface EmbedHTMLAttributes extends HTMLAttributes {135 height?: number | string | undefined136 src?: string | undefined137 type?: string | undefined138 width?: number | string | undefined139 }140141 interface FieldsetHTMLAttributes extends HTMLAttributes {142 disabled?: boolean | undefined143 form?: string | undefined144 name?: string | undefined145 }146147 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 }156157 interface HtmlHTMLAttributes extends HTMLAttributes {158 manifest?: string | undefined159 }160161 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 }174175 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 }188189 interface InsHTMLAttributes extends HTMLAttributes {190 cite?: string | undefined191 datetime?: string | undefined192 }193194 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 | string218219 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 }251252 interface KeygenHTMLAttributes extends HTMLAttributes {253 challenge?: string | undefined254 disabled?: boolean | undefined255 form?: string | undefined256 keytype?: string | undefined257 name?: string | undefined258 }259260 interface LabelHTMLAttributes extends HTMLAttributes {261 form?: string | undefined262 for?: string | undefined263 }264265 interface LiHTMLAttributes extends HTMLAttributes {266 value?: string | ReadonlyArray<string> | number | undefined267 }268269 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 }283284 interface MapHTMLAttributes extends HTMLAttributes {285 name?: string | undefined286 }287288 interface MenuHTMLAttributes extends HTMLAttributes {289 type?: string | undefined290 }291292 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 }304305 interface MetaHTMLAttributes extends HTMLAttributes {306 charset?: string | undefined307 'http-equiv'?: string | undefined308 name?: string | undefined309 media?: string | undefined310 content?: string | undefined311 }312313 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 }322323 interface QuoteHTMLAttributes extends HTMLAttributes {324 cite?: string | undefined325 }326327 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 }336337 interface OlHTMLAttributes extends HTMLAttributes {338 reversed?: boolean | undefined339 start?: number | undefined340 type?: '1' | 'a' | 'A' | 'i' | 'I' | undefined341 }342343 interface OptgroupHTMLAttributes extends HTMLAttributes {344 disabled?: boolean | undefined345 label?: string | undefined346 }347348 interface OptionHTMLAttributes extends HTMLAttributes {349 disabled?: boolean | undefined350 label?: string | undefined351 selected?: boolean | undefined352 value?: string | ReadonlyArray<string> | number | undefined353 }354355 interface OutputHTMLAttributes extends HTMLAttributes {356 form?: string | undefined357 for?: string | undefined358 name?: string | undefined359 }360361 interface ParamHTMLAttributes extends HTMLAttributes {362 name?: string | undefined363 value?: string | ReadonlyArray<string> | number | undefined364 }365366 interface ProgressHTMLAttributes extends HTMLAttributes {367 max?: number | string | undefined368 value?: string | ReadonlyArray<string> | number | undefined369 }370371 interface SlotHTMLAttributes extends HTMLAttributes {372 name?: string | undefined373 }374375 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 }385386 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 }396397 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 }406407 interface StyleHTMLAttributes extends HTMLAttributes {408 media?: string | undefined409 scoped?: boolean | undefined410 type?: string | undefined411 }412413 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 }424425 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 }441442 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 }453454 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 }462463 interface TimeHTMLAttributes extends HTMLAttributes {464 datetime?: string | undefined465 }466467 interface TrackHTMLAttributes extends HTMLAttributes {468 default?: boolean | undefined469 kind?: string | undefined470 label?: string | undefined471 src?: string | undefined472 srclang?: string | undefined473 }474475 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 }483484 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}605606export interface IntrinsicElements extends Hono.IntrinsicElements {}
modified:src/middleware/jsx-renderer/index.test.tsx+49 added
54 unmodified lines
55 expect(res.status).toBe(200)56 expect(await res.text()).toBe('<h1>http://localhost/</h1>')57 })5859 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 })8081 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 })107108 it('Env', async () => {109 type JSXRendererEnv = {110 Variables: {111 foo: string
40 unmodified lines
modified:src/middleware/jsx-renderer/index.ts+24 added-10 removed
8 unmodified lines
9type PropsForRenderer = [...Required<Parameters<Renderer>>] extends [unknown, infer Props]10 ? Props11 : unknown1213type RendererOptions = {14 docType?: boolean | string15}1617const 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 : ''2614 (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 }3738export 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 }4546export const useRequestContext = <
10 unmodified lines
modified:src/context.ts+1 added-1 removed
1import type { Runtime } from './helper/adapter'2import type { HonoRequest } from './request'3import type { Env, FetchEventLike, NotFoundHandler, Input, TypedResponse } from './types'4import type { CookieOptions } from './utils/cookie'5import { serialize } from './utils/cookie'6import type { StatusCode } from './utils/http-status'7import { StreamingApi } from './utils/stream'8import type { JSONValue, InterfaceToType } from './utils/types'99type Runtime = 'node' | 'deno' | 'bun' | 'workerd' | 'fastly' | 'edge-light' | 'lagon' | 'other'10type HeaderRecord = Record<string, string | string[]>11type Data = string | ArrayBuffer | ReadableStream1213export interface ExecutionContext {
458 unmodified lines
modified: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