Files
SnowLuma/.pnpm-store/v11/files/7a/28b45b26cd4ccf955a3ed097617a6aa3a5a2419ecf30e987cd2fc9ce3869c44125c6ca1752f41d76ceb3ebd431da69b4a89bdd310a168e4a03e2259121bc4e
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

47 lines
1.8 KiB
Plaintext

//#region src/utils/html.d.ts
/**
* @module
* HTML utility.
*/
export declare const HtmlEscapedCallbackPhase: {
readonly Stringify: 1;
readonly BeforeStream: 2;
readonly Stream: 3;
};
type HtmlEscapedCallbackOpts = {
buffer?: [string];
phase: (typeof HtmlEscapedCallbackPhase)[keyof typeof HtmlEscapedCallbackPhase];
context: Readonly<object>;
};
export type HtmlEscapedCallback = (opts: HtmlEscapedCallbackOpts) => Promise<string> | undefined;
export type HtmlEscaped = {
isEscaped: true;
callbacks?: HtmlEscapedCallback[];
};
export type HtmlEscapedString = string & HtmlEscaped;
/**
* StringBuffer contains string and Promise<string> alternately
* The length of the array will be odd, the odd numbered element will be a string,
* and the even numbered element will be a Promise<string>.
* When concatenating into a single string, it must be processed from the tail.
* @example
* [
* 'framework.',
* Promise.resolve('ultra fast'),
* 'a ',
* Promise.resolve('is '),
* 'Hono',
* ]
*/
export type StringBuffer = (string | Promise<string>)[];
export type StringBufferWithCallbacks = StringBuffer & {
callbacks: HtmlEscapedCallback[];
};
export declare const raw: (value: unknown, callbacks?: HtmlEscapedCallback[]) => HtmlEscapedString;
export declare const stringBufferToString: (buffer: StringBuffer, callbacks: HtmlEscapedCallback[] | undefined) => Promise<HtmlEscapedString>;
export declare const escapeToBuffer: (str: string, buffer: StringBuffer) => void;
export declare const resolveCallbackSync: (str: string | HtmlEscapedString) => string;
export declare const resolveCallback: (str: string | HtmlEscapedString | Promise<string>, phase: (typeof HtmlEscapedCallbackPhase)[keyof typeof HtmlEscapedCallbackPhase], preserveCallbacks: boolean, context: object, buffer?: [string]) => Promise<string>;
//#endregion
export {};