import { type SlashPathTypedFileExtension } from '../path/path'; import { type SuggestedString } from '../type'; import { type Maybe } from '../value/maybe.type'; /** * A simple mime type string with just the type/subtype and no parameters. * * I.E. "application/json" * * @semanticType * @semanticTopic string * @semanticTopic dereekb-util:mime */ export type MimeTypeWithoutParameters = string; /** * The mimetype wildcard. */ export type MimeTypeWildcard = '*'; /** * A mime type with a wildcard subtype. Has a star as the subtype. * * I.E. "application/*" * * @semanticType * @semanticTopic string * @semanticTopic dereekb-util:mime */ export type MimeTypeWithSubtypeWildcardWithoutParameters = string; /** * A mime type string that may contain additional parameters. * * I.E. "text/plain", "application/json; charset=utf-8" * * @semanticType * @semanticTopic string * @semanticTopic dereekb-util:mime */ export type ContentTypeMimeType = string; /** * Input for mimetypeForImageType(). * * This is a non-exhaustive list of common image types. */ export type ImageFileExtension = 'jpeg' | 'jpg' | 'png' | 'webp' | 'gif' | 'svg' | 'raw' | 'heif' | 'tiff'; /** * MIME type for JPEG images. */ export declare const JPEG_MIME_TYPE = "image/jpeg"; /** * Non-canonical MIME type sometimes emitted by older browsers/clients for JPEG images. */ export declare const JPG_MIME_TYPE = "image/jpg"; /** * Progressive JPEG MIME type emitted by some legacy clients (notably Internet Explorer). */ export declare const PJPEG_MIME_TYPE = "image/pjpeg"; /** * All MIME type variants that should be treated as JPEG images, including the canonical * `image/jpeg` and the non-standard `image/jpg` and `image/pjpeg` variants emitted by * some browsers/clients. */ export declare const JPEG_MIME_TYPES: readonly MimeTypeWithoutParameters[]; /** * MIME type for PNG images. */ export declare const PNG_MIME_TYPE = "image/png"; /** * MIME type for WebP images. */ export declare const WEBP_MIME_TYPE = "image/webp"; /** * MIME type for GIF images. */ export declare const GIF_MIME_TYPE = "image/gif"; /** * MIME type for HEIF images. */ export declare const HEIF_MIME_TYPE = "image/heif"; /** * MIME type for TIFF images. */ export declare const TIFF_MIME_TYPE = "image/tiff"; /** * MIME type for SVG images. */ export declare const SVG_MIME_TYPE = "image/svg+xml"; /** * MIME type for RAW images. */ export declare const RAW_MIME_TYPE = "image/raw"; /** * Maps image file extensions to their corresponding MIME types. */ export declare const IMAGE_FILE_EXTENSION_TO_MIME_TYPES_RECORD: Record; /** * Maps image MIME types back to their corresponding file extensions. */ export declare const IMAGE_MIME_TYPES_TO_FILE_EXTENSIONS_RECORD: Record; /** * Returns the MIME type for the given image file extension, or undefined if the extension is not recognized. * * @param extension - the image file extension to look up * @returns the corresponding MIME type, or undefined if the extension is not known */ export declare function mimeTypeForImageFileExtension(extension: ImageFileExtension): MimeTypeWithoutParameters; export declare function mimeTypeForImageFileExtension(extension: SlashPathTypedFileExtension): Maybe; export declare function mimeTypeForImageFileExtension(extension: Maybe): Maybe; /** * Returns the image file extension for the given MIME type, or undefined if the MIME type is not a known image type. * * @param mimeType - The MIME type to look up. * @returns The corresponding image file extension, or undefined if not recognized. */ export declare function imageFileExtensionForMimeType(mimeType: Maybe): Maybe; /** * Non-exhaustive list of common document file extensions. */ export type DocumentFileExtension = 'pdf' | 'docx' | 'xlsx' | 'txt' | 'csv' | 'html' | 'xml' | 'json' | 'yaml' | 'md'; /** * MIME type for PDF documents. */ export declare const PDF_MIME_TYPE = "application/pdf"; /** * MIME type for DOCX (Word) documents. */ export declare const DOCX_MIME_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; /** * MIME type for XLSX (Excel) spreadsheets. */ export declare const XLSX_MIME_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; /** * MIME type for plain text files. */ export declare const TXT_MIME_TYPE = "text/plain"; /** * MIME type for CSV files. */ export declare const CSV_MIME_TYPE = "text/csv"; /** * MIME type for HTML files. */ export declare const HTML_MIME_TYPE = "text/html"; /** * MIME type for XML files. */ export declare const XML_MIME_TYPE = "application/xml"; /** * MIME type for JSON files. */ export declare const JSON_MIME_TYPE = "application/json"; /** * MIME type for YAML files. */ export declare const YAML_MIME_TYPE = "application/yaml"; /** * MIME type for Markdown files. */ export declare const MARKDOWN_MIME_TYPE = "text/markdown"; /** * Maps document file extensions to their corresponding MIME types. */ export declare const DOCUMENT_FILE_EXTENSION_TO_MIME_TYPES_RECORD: Record; /** * Maps document MIME types back to their corresponding file extensions. */ export declare const DOCUMENT_MIME_TYPES_TO_FILE_EXTENSIONS_RECORD: Record; /** * Returns the mimetype for the given document file extension, or undefined if the extension is not known/recognized. * * @param extension The document file extension to get the mimetype for. * @returns The mimetype for the given document file extension, or undefined if the extension is not known. */ export declare function mimeTypeForDocumentFileExtension(extension: DocumentFileExtension): MimeTypeWithoutParameters; export declare function mimeTypeForDocumentFileExtension(extension: SlashPathTypedFileExtension): Maybe; export declare function mimeTypeForDocumentFileExtension(extension: Maybe): Maybe; /** * Returns the document file extension for the given mimetype, or undefined if the mimetype is not known/recognized. * * @param mimeType - The mimetype to get the document file extension for. * @returns The document file extension for the given mimetype, or undefined if the mimetype is not known. */ export declare function documentFileExtensionForMimeType(mimeType: Maybe): Maybe; /** * Non-exhaustive list of common application file extensions. */ export type ApplicationFileExtension = 'zip'; /** * MIME type for ZIP archive files. */ export declare const ZIP_FILE_MIME_TYPE = "application/zip"; /** * Maps application file extensions to their corresponding MIME types. */ export declare const APPLICATION_FILE_EXTENSION_TO_MIME_TYPES_RECORD: Record; /** * Maps application MIME types back to their corresponding file extensions. */ export declare const APPLICATION_MIME_TYPES_TO_FILE_EXTENSIONS_RECORD: Record; /** * Returns the mimetype for the given application file extension, or undefined if the extension is not known/recognized. * * @param extension The application file extension to get the mimetype for. * @returns The mimetype for the given application file extension, or undefined if the extension is not known. */ export declare function mimeTypeForApplicationFileExtension(extension: ApplicationFileExtension): MimeTypeWithoutParameters; export declare function mimeTypeForApplicationFileExtension(extension: SlashPathTypedFileExtension): Maybe; export declare function mimeTypeForApplicationFileExtension(extension: Maybe): Maybe; /** * Returns the application file extension for the given MIME type, or undefined if the MIME type is not a known application type. * * @param mimeType - The MIME type to look up. * @returns The corresponding application file extension, or undefined if not recognized. */ export declare function applicationFileExtensionForMimeType(mimeType: Maybe): Maybe; /** * Non-exhaustive list of common calendar file extensions. */ export type CalendarFileExtension = 'ics'; /** * MIME type for iCalendar (RFC 5545) files. */ export declare const TEXT_CALENDAR_MIME_TYPE = "text/calendar"; /** * Full Content-Type value for a published iCalendar feed. * * Calendar clients that subscribe to an .ics feed expect the charset parameter, so this * value (rather than the bare {@link TEXT_CALENDAR_MIME_TYPE}) is what belongs on the response header. */ export declare const TEXT_CALENDAR_UTF8_CONTENT_TYPE: ContentTypeMimeType; /** * Maps calendar file extensions to their corresponding MIME types. */ export declare const CALENDAR_FILE_EXTENSION_TO_MIME_TYPES_RECORD: Record; /** * Maps calendar MIME types back to their corresponding file extensions. */ export declare const CALENDAR_MIME_TYPES_TO_FILE_EXTENSIONS_RECORD: Record; /** * Returns the mimetype for the given calendar file extension, or undefined if the extension is not known/recognized. * * @param extension The calendar file extension to get the mimetype for. * @returns The mimetype for the given calendar file extension, or undefined if the extension is not known. */ export declare function mimeTypeForCalendarFileExtension(extension: CalendarFileExtension): MimeTypeWithoutParameters; export declare function mimeTypeForCalendarFileExtension(extension: SlashPathTypedFileExtension): Maybe; export declare function mimeTypeForCalendarFileExtension(extension: Maybe): Maybe; /** * Returns the calendar file extension for the given MIME type, or undefined if the MIME type is not a known calendar type. * * @param mimeType - The MIME type to look up. * @returns The corresponding calendar file extension, or undefined if not recognized. */ export declare function calendarFileExtensionForMimeType(mimeType: Maybe): Maybe; /** * List of known file extensions supported by dbx-components. * * These types are known to work with most dbx-components features related to files. */ export type DbxComponentsKnownFileExtension = ImageFileExtension | DocumentFileExtension | ApplicationFileExtension | CalendarFileExtension; /** * Returns the mimetype for the given file extension, or undefined if the extension is not known/recognized. * * @param extension The file extension to get the mimetype for. * @returns The mimetype for the given file extension, or undefined if the extension is not known. */ export declare function mimeTypeForFileExtension(extension: DbxComponentsKnownFileExtension): MimeTypeWithoutParameters; export declare function mimeTypeForFileExtension(extension: SlashPathTypedFileExtension): Maybe; export declare function mimeTypeForFileExtension(extension: Maybe): Maybe; /** * Returns the file extension for the given MIME type by checking image, document, application, and calendar types in order. * * @param mimeType - The MIME type to look up. * @returns The corresponding file extension, or undefined if the MIME type is not recognized. */ export declare function fileExtensionForMimeType(mimeType: Maybe): Maybe; /** * A `data:` URL (RFC 2397) that carries its bytes inline, e.g. `data:image/png;base64,iVBOR…`. * * @semanticType * @semanticTopic url * @semanticTopic string */ export type DataUrlString = string; /** * Input to {@link toBase64DataUrl}. */ export interface Base64DataUrlConfig { /** * The media type written after `data:` — a bare MIME type, or one carrying parameters, written as given. */ readonly mimeType: MimeTypeWithoutParameters | ContentTypeMimeType; /** * The bytes, already base64-encoded, with no `data:` prefix. */ readonly dataBase64: string; } /** * Builds the inline `data:;base64,` URL for already-encoded bytes. Always builds: an input that * is already a data URL is not detected. * * @param config - The media type and the base64 bytes. * @returns The data URL. * * @dbxUtil * @dbxUtilCategory string * @dbxUtilKind function * @dbxUtilTags string, mime, data-url, base64, url * * @example * ```ts * toBase64DataUrl({ mimeType: 'image/png', dataBase64: 'QUJD' }); // 'data:image/png;base64,QUJD' * ``` */ export declare function toBase64DataUrl(config: Base64DataUrlConfig): DataUrlString; /** * A content disposition string, which is used to determine how the browser should show the target content. * * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Disposition */ export type ContentDispositionString = SuggestedString<'inline' | 'attachment'>; /** * Whether the content disposition makes the response an attachment, which a browser downloads rather than displays — * even inside an `` or `