import { Extension, ThumbnailSize } from './utilities/constants.js'; import { Base } from './utilities/structures.js'; import { Gallery } from './gallery.js'; /** * Abstract base class for media resources providing shared dimensions. * * @abstract * @see {@link Image} * @see {@link Video} */ declare abstract class Media extends Base { /** * Width of the media in pixels. * * @type {number} * @readonly */ readonly width: number; /** * Height of the media in pixels. * * @type {number} * @readonly */ readonly height: number; } /** * Image belonging to a gallery. * * @see {@link Gallery} */ declare class Image extends Media { /** * Unique hash that identifies the image. * * @type {string} * @readonly */ readonly hash: string; /** * Original file name of the image. * * @type {string} * @readonly */ readonly name: string; /** * Whether the AVIF format is available. * * @type {boolean} * @readonly */ readonly hasAvif: boolean; /** * Whether the WebP format is available. * * @deprecated This field is always true. * @type {boolean} * @readonly */ readonly hasWebp: boolean; /** * Whether the JPEG XL format is available. * * @deprecated This field is always false. * @type {boolean} * @readonly */ readonly hasJxl: boolean; /** * Whether thumbnail variants are available for the image. * * @type {boolean} * @readonly */ readonly hasThumbnail: boolean; /** * Resolves an image URL for the specified format and optional thumbnail size. * * Only the combinations listed below are valid: * * | Thumbnail Size | Extension | Requirement (must be true) | * | :------------- | :-------- | :------------------------------- | * | *(none)* | *(all)* | `has{Extension}` | * | `Small` | *(all)* | `has{Extension}` | * | `Medium` | `Avif` | `hasThumbnail && has{Extension}` | * | `Big` | *(all)* | `hasThumbnail && has{Extension}` | * * @param {Extension} extension Desired image format. * @param {ThumbnailSize} [thumbnailSize] Optional thumbnail size. (a full-size image URL is returned if omitted) * @returns {Promise} Promise that resolves to the final image URL. * @throws {HitomiError} Thrown when the `extension` and `thumbnailSize` combination is not valid. * @see {@link hasAvif} * @see {@link hasWebp} * @see {@link hasJxl} * @see {@link hasThumbnail} */ resolveUrl(extension: Extension, thumbnailSize?: ThumbnailSize): Promise; /** * Fetches the image with the specified format and optional thumbnail size. * * The same `extension` and `thumbnailSize` restrictions as {@link resolveUrl} apply. * * @param {Extension} extension Desired image format. * @param {ThumbnailSize} [thumbnailSize] Optional thumbnail size. (a full-size image is returned if omitted) * @returns {Promise} Promise that resolves to the image as a `Buffer`. * @throws {HitomiError} Thrown when the `extension` and `thumbnailSize` combination is not valid. */ fetch(extension: Extension, thumbnailSize?: ThumbnailSize): Promise; } /** * Video belonging to a gallery. * * @see {@link Gallery} */ declare class Video extends Media { /** * File name of the video. * * @type {string} * @readonly */ readonly fileName: string; /** * URL of the video. * * @type {string} * @readonly */ readonly url: string; /** * URL of the poster (video thumbnail). * * @type {string} * @readonly */ readonly posterUrl: string; /** * Fetches the video in MP4 format. * * @returns {Promise} Promise that resolves to the video as a `Buffer`. */ fetch(): Promise; /** * Fetches the poster (video thumbnail) in WebP format. * * @returns {Promise} Promise that resolves to the poster as a `Buffer`. */ fetchPoster(): Promise; } export { Image, Video };