import type { Identifier } from '@atlaskit/media-client/identifier'; import type { MediaClient } from '@atlaskit/media-client/media-client'; import type { MediaTraceContext } from '@atlaskit/media-common/analytics/types'; import type { MediaType } from '@atlaskit/media-common/main-types'; import type { FileState } from '@atlaskit/media-state/file-state'; import { type MediaViewerPreloadEventPayload } from './analytics/events/operational/preload'; export type { MediaViewerPreloadEventPayload, PreloadEndedEventPayload, PreloadFailedEventPayload, } from './analytics/events/operational/preload'; export type PreloadMediaViewerOptions = { /** * Returns the media client for the image request. Only called when an image is * actually warmed, so the control arm never creates a client. */ getMediaClient: () => MediaClient; identifier: Identifier; /** Mime type of the target file, when the caller knows it. */ mimeType?: string; /** Media type of the target file. Derived from `mimeType` when omitted. */ mediaType?: MediaType; /** * File state for the target file, when the caller already has it. Used to * skip the image warm-up in the cases where `ImageViewer` would not request * the image endpoint anyway. */ fileState?: FileState; traceContext?: MediaTraceContext; /** * Receives the warm-up's operational events, for the caller to fire on the media * channel with its own analytics. Errors it throws are ignored. */ onAnalyticsEvent?: (payload: MediaViewerPreloadEventPayload) => void; }; /** * Speculatively warms what the media viewer needs to display `identifier`, so * that opening it is closer to instant. Intended to be called from a hover or * focus handler on whatever opens the viewer. * * Two things get warmed: * - the lazily loaded viewer chunks, and * - the full resolution image binary, whose in-flight request is kept in * `./warmedImages` for `ImageViewer` to take instead of issuing its own. * * The image request starts once media-client has resolved the watermark version * it carries, because the version is part of the warmed image's key. * * The image binary is only warmed when the file is known to be a non-SVG image, * because `ImageViewer` is the only viewer that makes this request. Callers that * know nothing about the file still get the chunk warm-up. * * Safe to call repeatedly and safe to call for files the user never opens: an * image already being warmed is not requested again, a failed image request is not * retried and its rejection is handled, and no image is fetched on metered or slow * connections. Failures and outcomes go to `onAnalyticsEvent`. * * This is the exposure point for the `platform_media_viewer_preload_on_hover` * experiment. Callers attach their handlers in both arms, and the exposure fires * here before the arms differ, so both arms are exposed on the same hover or focus. */ export declare const preloadMediaViewer: ({ getMediaClient, identifier, mimeType, mediaType, fileState, traceContext, onAnalyticsEvent, }: PreloadMediaViewerOptions) => void;