import type { HTMLBundle } from "bun";
import { existsSync, statSync, watch, type FSWatcher } from "node:fs";
import { relative, resolve, sep } from "node:path";
import { escape, forget, scan, type Output, type Site, type Spec } from "./ssg/build.ts";
import { clean, find, lost, reply, type } from "./serve.ts";
/* OPTIONS */
export type Entry = { route: string; file: string };
export type Mount = [string, string];
export type Options = {
html?: (site: Site) => Entry[];
scripts?: (site: Site) => Entry[];
disk?: (site: Site) => Mount[];
watch?: string[];
extra?: (site: Site, path: string) => Promise | Response | null;
line?: (site: Site) => string;
};
/* STATE */
type Held = { runs: number; watchers: FSWatcher[]; timer: ReturnType | null };
const held = ((globalThis as unknown as { __dev?: Held }).__dev ??= { runs: 0, watchers: [], timer: null });
const HOT = process.execArgv.includes("--hot");
const HTML = { "content-type": "text/html; charset=utf-8" };
/* OVERLAY */
const SNIPPET = ``;
const inject = (html: string) => (html.includes("