//#region src/core/browser/link-check.d.ts /** A link that failed to resolve, and the page it was found on. */ interface BrokenLink { url: string; from: string; /** HTTP status, or `"error"` when the request threw (DNS/timeout/etc). */ status: number | "error"; } /** Extract resolvable, absolute link targets from an HTML string. Skips * in-page anchors and non-HTTP schemes (`mailto:`/`tel:`/`javascript:`). */ declare function extractLinks(html: string, base: string): string[]; /** An internal link that answers with a redirect, and the page that holds it. */ interface RedirectFinding { /** The URL the page links to. */ url: string; /** The page whose link it is: that's where the fix goes. */ from: string; /** The first hop's status: 301, 302, 307, or 308. */ status: number; /** Where the redirects end, or the last `Location` when they don't. */ to: string; /** Redirects before the final answer. More than one is a chain. */ hops: number; /** The final answer's status, or `"error"` when a hop failed or the chain ran too long. */ finalStatus: number | "error"; } /** Why a page's indexing directives need a look. */ type IndexingIssue = "noindex" | "canonical-off-origin" | "canonical-elsewhere"; /** A crawled page whose robots directive or canonical link keeps it out of search. */ interface IndexingFinding { url: string; issue: IndexingIssue; /** The canonical link, for the two canonical issues. */ canonical?: string; } /** A title more than one crawled page shares. */ interface DuplicateTitleFinding { title: string; pages: string[]; } /** What a page tells a crawler about itself. */ interface PageSignals { /** Every robots directive, lowercased, from the meta tag and `X-Robots-Tag`. */ robots: string[]; /** Whether a directive is `noindex` or `none`. */ noindex: boolean; /** The canonical link, absolute, when the page has one. */ canonical?: string; title?: string; description?: string; } /** * Read a page's robots directives (the `robots` meta tag and the `X-Robots-Tag` * header), its canonical link, its title, and its meta description. Pure: it * parses the HTML text, so it runs in a test or a Worker alike. */ declare function pageSignals(html: string, headers: Headers, url: string): PageSignals; interface CheckLinksOptions { /** Origin the pages are served from, for example, `https://example.com`. */ base: string; /** Page paths to start from, for example, `["/", "/docs/"]`. */ paths: string[]; /** Injectable fetch (defaults to the global). */ fetch?: typeof fetch; /** Only check links on the same origin as `base`. Default `true`. */ sameOriginOnly?: boolean; /** * Follow same-origin links from the start paths and check those pages too, * breadth-first. `maxPages` caps the pages read (the start paths included), * and `maxDepth` the links followed from a start path. Off by default: only * the start paths are read. */ crawl?: { maxPages: number; maxDepth: number; }; /** * The most requests the scan makes, counting every redirect hop. A Worker's * subrequest limit applies to a scheduled handler too, so set it below * yours; the report says when the scan stopped early. Default: no cap. */ maxRequests?: number; } /** Everything {@link crawlSite} found. */ interface CrawlReport { brokenLinks: BrokenLink[]; redirects: RedirectFinding[]; indexing: IndexingFinding[]; duplicateTitles: DuplicateTitleFinding[]; /** The pages read, in the order they were read. */ pages: string[]; /** True when `maxRequests` stopped the scan before it finished. */ truncated: boolean; } /** * Read pages and check their links, reporting what a crawler would trip on: * links that don't resolve, internal links that redirect, pages whose robots * directive or canonical keeps them out of search, and titles shared by more * than one page. Driven from a Cron Trigger, and pure `fetch` otherwise. * * Every request uses `redirect: "manual"`, and the scan follows the hops itself, * so a link that reaches a live page through a redirect still counts as * working, but shows up in `redirects` against the page that holds it. */ declare function crawlSite(options: CheckLinksOptions): Promise; /** * The broken links {@link crawlSite} finds: a link whose final answer isn't 2xx, * or a request that threw. A link that redirects to a live page isn't broken. * Each distinct target is checked once, and a start page that fails to load is * reported too. Same-origin by default so an external outage doesn't spam the * report. */ declare function checkLinks(options: CheckLinksOptions): Promise; //#endregion export { IndexingFinding as a, RedirectFinding as c, extractLinks as d, pageSignals as f, DuplicateTitleFinding as i, checkLinks as l, CheckLinksOptions as n, IndexingIssue as o, CrawlReport as r, PageSignals as s, BrokenLink as t, crawlSite as u };