Skip to content
Myr

fix(html): Remove circular dependencies in `hono/html` (#2143)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* refactor: Refactor helper/html and utils/html to remove circular dependencies * chore: denoify * chore: reformat code * chore: denoify

authored by javascripter · committed by GitHub · parent f2ec8d4 · Browse files · 4 files+20 added−30 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+20 added−30 removed

  • other:+20 added−30 removed

4 files+20 added−30 removed

modified:deno_dist/helper/html/index.ts+3 added-14 removed
modified:deno_dist/utils/html.ts+7 added-1 removed
modified:src/helper/html/index.ts+3 added-14 removed
1import { escapeToBuffer, stringBufferToString } from '../../utils/html'2import type {3 StringBuffer,4 HtmlEscaped,5 HtmlEscapedString,6 HtmlEscapedCallback,7} from '../../utils/html'1import { escapeToBuffer, stringBufferToString, raw } from '../../utils/html'2import type { StringBuffer, HtmlEscaped, HtmlEscapedString } from '../../utils/html'39export const raw = (value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString => {10 const escapedString = new String(value) as HtmlEscapedString11 escapedString.isEscaped = true12 escapedString.callbacks = callbacks4export { raw }514 return escapedString15}166export const html = (7 strings: TemplateStringsArray,8 ...values: unknown[]9): HtmlEscapedString | Promise<HtmlEscapedString> => {
35 unmodified lines
modified:src/utils/html.ts+7 added-1 removed
29 unmodified lines
30 * ]31 */32export type StringBuffer = (string | Promise<string>)[]3334import { raw } from '../helper/html'34export const raw = (value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString => {35 const escapedString = new String(value) as HtmlEscapedString36 escapedString.isEscaped = true37 escapedString.callbacks = callbacks3839 return escapedString40}4142// The `escapeToBuffer` implementation is based on code from the MIT licensed `react-dom` package.43// https://github.com/facebook/react/blob/main/packages/react-dom-bindings/src/server/escapeTextForBrowser.js4445const escapeRe = /[&<>'"]/
105 unmodified lines