UNPKG

@readium/shared

Version:

Shared models to be used across other Readium projects and implementations in Typescript

149 lines (148 loc) 6.25 kB
type ParametersMap = { [param: string]: string; }; /** Represents a string media type. * `MediaType` handles: * - components parsing – eg. type, subtype and parameters, * - media types comparison. */ export declare class MediaType { /** The type component, e.g. `application` in `application/epub+zip`. */ type: string; /** The subtype component, e.g. `epub+zip` in `application/epub+zip`. */ subtype: string; /** The parameters in the media type, such as `charset=utf-8`. */ parameters: ParametersMap; /** The string representation of this media type. */ string: string; /** Encoding as declared in the `charset` parameter, if there's any. */ encoding?: string; /** A human readable name identifying the media type, which may be presented to the user. */ name?: string; /** The default file extension to use for this media type. */ fileExtension?: string; /** Creates a MediaType object. */ constructor(values: { mediaType: string; name?: string; fileExtension?: string; }); static parse(values: { mediaType: string; name?: string; fileExtension?: string; }): MediaType; /** Structured syntax suffix, e.g. `+zip` in `application/epub+zip`. * Gives a hint on the underlying structure of this media type. * See. https://tools.ietf.org/html/rfc6838#section-4.2.8 */ get structuredSyntaxSuffix(): string | undefined; /** Parameter values might or might not be case-sensitive, depending on the semantics of * the parameter name. * https://tools.ietf.org/html/rfc2616#section-3.7 * * The character set names may be up to 40 characters taken from the printable characters * of US-ASCII. However, no distinction is made between use of upper and lower case * letters. * https://www.iana.org/assignments/character-sets/character-sets.xhtml */ get charset(): string | undefined; /** Returns whether the given `other` media type is included in this media type. * For example, `text/html` contains `text/html;charset=utf-8`. * - `other` must match the parameters in the `parameters` property, but extra parameters * are ignored. * - Order of parameters is ignored. * - Wildcards are supported, meaning that `image/*` contains `image/png` */ contains(other: MediaType | string): boolean; /** Returns whether this media type and `other` are the same, ignoring parameters that * are not in both media types. * For example, `text/html` matches `text/html;charset=utf-8`, but `text/html;charset=ascii` * doesn't. This is basically like `contains`, but working in both direction. */ matches(other: MediaType | string): boolean; /** * Returns whether this media type matches any of the [others] media types. */ matchesAny(...others: MediaType[] | string[]): boolean; /** Checks the MediaType equals another one (comparing their string) */ equals(other: MediaType): boolean; /** Returns whether this media type is structured as a ZIP archive. */ get isZIP(): boolean; /** Returns whether this media type is structured as a JSON file. */ get isJSON(): boolean; /** Returns whether this media type is of an OPDS feed. */ get isOPDS(): boolean; /** Returns whether this media type is of an HTML document. */ get isHTML(): boolean; /** Returns whether this media type is of a bitmap image, so excluding vectorial formats. */ get isBitmap(): boolean; /** Returns whether this media type is of an audio clip. */ get isAudio(): boolean; /** Returns whether this media type is of a video clip. */ get isVideo(): boolean; /** Returns whether this media type is of a Readium Web Publication Manifest. */ get isRWPM(): boolean; /** Returns whether this media type is of a publication file. */ get isPublication(): boolean; static get AAC(): MediaType; static get ACSM(): MediaType; static get AIFF(): MediaType; static get AVI(): MediaType; static get BINARY(): MediaType; static get BMP(): MediaType; static get CBZ(): MediaType; static get CSS(): MediaType; static get DIVINA(): MediaType; static get DIVINA_MANIFEST(): MediaType; static get EPUB(): MediaType; static get GIF(): MediaType; static get GZ(): MediaType; static get HTML(): MediaType; static get JAVASCRIPT(): MediaType; static get JPEG(): MediaType; static get JSON(): MediaType; static get LCP_LICENSE_DOCUMENT(): MediaType; static get LCP_PROTECTED_AUDIOBOOK(): MediaType; static get LCP_PROTECTED_PDF(): MediaType; static get LCP_STATUS_DOCUMENT(): MediaType; static get LPF(): MediaType; static get MP3(): MediaType; static get MPEG(): MediaType; static get NCX(): MediaType; static get OGG(): MediaType; static get OGV(): MediaType; static get OPDS1(): MediaType; static get OPDS1_ENTRY(): MediaType; static get OPDS2(): MediaType; static get OPDS2_PUBLICATION(): MediaType; static get OPDS_AUTHENTICATION(): MediaType; static get OPUS(): MediaType; static get OTF(): MediaType; static get PDF(): MediaType; static get PNG(): MediaType; static get READIUM_AUDIOBOOK(): MediaType; static get READIUM_AUDIOBOOK_MANIFEST(): MediaType; static get READIUM_CONTENT_DOCUMENT(): MediaType; static get READIUM_GUIDED_NAVIGATION_DOCUMENT(): MediaType; static get READIUM_POSITION_LIST(): MediaType; static get READIUM_WEBPUB(): MediaType; static get READIUM_WEBPUB_MANIFEST(): MediaType; static get SMIL(): MediaType; static get SVG(): MediaType; static get TEXT(): MediaType; static get TIFF(): MediaType; static get TTF(): MediaType; static get W3C_WPUB_MANIFEST(): MediaType; static get WAV(): MediaType; static get WEBM_AUDIO(): MediaType; static get WEBM_VIDEO(): MediaType; static get WEBP(): MediaType; static get WOFF(): MediaType; static get WOFF2(): MediaType; static get XHTML(): MediaType; static get XML(): MediaType; static get ZAB(): MediaType; static get ZIP(): MediaType; } export {};