/** A service that makes the short link of `url`; `signal` aborts the request when it takes too long */ export type ShortlinkProvider = (url: string, signal: AbortSignal) => Promise; /** A built-in service */ export type ShortlinkServiceName = 'dagd' | 'clck'; /** Options of a request, see `ShortlinkOptions` */ export interface ShortenOptions { service: ShortlinkServiceName | ShortlinkProvider; timeout: number; } /** A failure with a message for the user, in English: the plugin translates the known ones */ export declare class ShortlinkError extends Error { name: string; } /** Messages of the plugin's own failures, also used as translation keys */ export declare const MESSAGES: { readonly invalid: "Only http:// and https:// links can be shortened"; readonly unavailable: "The link shortening service is not available"; readonly timeout: "The link shortening service did not answer in time"; readonly answer: "The link shortening service gave an unexpected answer"; }; /** Hosts of the short links of the built-in services */ export declare const SHORT_HOSTS: string[]; type Fetch = typeof fetch; /** `url` is an absolute http:// or https:// link */ export declare function isHttpUrl(url: string): boolean; /** `url` is already a short link of a built-in service */ export declare function isShortUrl(url: string): boolean; /** * Makes the short link of `url` with the service of `options`. * * Throws a {@link ShortlinkError} with a message for the user: the text of the service's error, or one of * {@link MESSAGES} when the link is not http(s), the service cannot be reached (also when the browser blocks the * answer for lack of CORS headers), does not answer within `timeout` milliseconds or answers with something that is * not a link. */ export declare function shorten(url: string, options: ShortenOptions, fetcher?: Fetch): Promise; export {};