Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit e423905

Browse files
committed
Add HTMLRewriterHandlers type
1 parent f6e4a4e commit e423905

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

server/html.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
import { concat } from "https://deno.land/[email protected]/bytes/mod.ts";
2-
import type { Comment, DocumentEnd, Element } from "https://deno.land/x/[email protected]/types.d.ts";
2+
import type { Comment, DocumentEnd, Element, TextChunk } from "https://deno.land/x/[email protected]/types.d.ts";
33
import initLolHtml, { HTMLRewriter } from "https://deno.land/x/[email protected]/mod.js";
44
import decodeLolHtmlWasm from "https://deno.land/x/[email protected]/wasm.js";
55
import util from "../lib/util.ts";
66
import { applyImportMap, getAlephPkgUri, getDeploymentId, toLocalPath } from "./helpers.ts";
77
import type { ImportMap } from "./types.ts";
88

9+
// init lol-html wasm
910
await initLolHtml(decodeLolHtmlWasm());
1011

12+
export type HTMLRewriterHandlers = {
13+
element?: (element: Element) => void;
14+
comments?: (element: Comment) => void;
15+
text?: (text: TextChunk) => void;
16+
};
17+
1118
type LoadOptions = {
1219
isDev: boolean;
1320
importMap: ImportMap;
1421
ssr?: { suspense?: boolean };
1522
hmrWebSocketUrl?: string;
1623
};
1724

18-
// laod the `index.html`
25+
// load and fix the `index.html`
1926
// - fix relative url to absolute url of `src` and `href`
2027
// - add `./framework/core/hmr.ts` when in `development` mode
2128
// - add `./framework/core/nomodule.ts`
@@ -238,4 +245,4 @@ export function parseHtmlLinks(html: string | Uint8Array): Promise<string[]> {
238245
});
239246
}
240247

241-
export { Comment, Element, HTMLRewriter };
248+
export { Element, HTMLRewriter };

0 commit comments

Comments
 (0)