UNPKG

@prismicio/types-internal

Version:
253 lines (252 loc) 6.79 kB
import * as t from "io-ts"; import type { LegacyContentCtx, WithTypes } from "../../LegacyContentCtx"; export declare const ImageContentType = "ImageContent"; export declare const isImageContent: (u: unknown) => u is { origin: { id: string; url: string; width: number; height: number; }; width: number; height: number; edit: { zoom: number; crop: { x: number; y: number; }; background: string; }; } & { url?: string; credits?: string | null; alt?: string | null; provider?: string | null | undefined; } & { thumbnails?: { [x: string]: { origin: { id: string; url: string; width: number; height: number; }; width: number; height: number; edit: { zoom: number; crop: { x: number; y: number; }; background: string; }; } & { url?: string; credits?: string | null; alt?: string | null; provider?: string | null | undefined; }; }; } & { __TYPE__: "ImageContent"; }; export declare const ImageContentView: t.ExactC<t.IntersectionC<[t.TypeC<{ origin: t.ExactC<t.TypeC<{ id: t.StringC; url: t.StringC; width: t.NumberC; height: t.NumberC; }>>; width: t.NumberC; height: t.NumberC; edit: t.TypeC<{ zoom: t.NumberC; crop: t.TypeC<{ x: t.NumberC; y: t.NumberC; }>; background: t.StringC; }>; }>, t.PartialC<{ url: t.StringC; credits: t.Type<string | null, string | null, unknown>; alt: t.Type<string | null, string | null, unknown>; provider: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>; }>]>>; export declare type ImageContentView = t.TypeOf<typeof ImageContentView>; export declare const ImageLegacy: (ctx: LegacyContentCtx) => t.Type<{ origin: { id: string; url: string; width: number; height: number; }; width: number; height: number; edit: { zoom: number; crop: { x: number; y: number; }; background: string; }; } & { url?: string; credits?: string | null; alt?: string | null; provider?: string | null | undefined; } & { thumbnails?: { [x: string]: { origin: { id: string; url: string; width: number; height: number; }; width: number; height: number; edit: { zoom: number; crop: { x: number; y: number; }; background: string; }; } & { url?: string; credits?: string | null; alt?: string | null; provider?: string | null | undefined; }; }; } & { __TYPE__: "ImageContent"; }, WithTypes<{ origin: { id: string; url: string; width: number; height: number; }; width: number; height: number; edit: { zoom: number; crop: { x: number; y: number; }; background: string; }; } & { url?: string; credits?: string | null; alt?: string | null; provider?: string | null | undefined; } & { thumbnails?: { [x: string]: { origin: { id: string; url: string; width: number; height: number; }; width: number; height: number; edit: { zoom: number; crop: { x: number; y: number; }; background: string; }; } & { url?: string; credits?: string | null; alt?: string | null; provider?: string | null | undefined; }; }; }>, unknown>; export declare const ImageContent: t.IntersectionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{ origin: t.ExactC<t.TypeC<{ id: t.StringC; url: t.StringC; width: t.NumberC; height: t.NumberC; }>>; width: t.NumberC; height: t.NumberC; edit: t.TypeC<{ zoom: t.NumberC; crop: t.TypeC<{ x: t.NumberC; y: t.NumberC; }>; background: t.StringC; }>; }>, t.PartialC<{ url: t.StringC; credits: t.Type<string | null, string | null, unknown>; alt: t.Type<string | null, string | null, unknown>; provider: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>; }>]>>, t.PartialC<{ thumbnails: t.RecordC<t.StringC, t.ExactC<t.IntersectionC<[t.TypeC<{ origin: t.ExactC<t.TypeC<{ id: t.StringC; url: t.StringC; width: t.NumberC; height: t.NumberC; }>>; width: t.NumberC; height: t.NumberC; edit: t.TypeC<{ zoom: t.NumberC; crop: t.TypeC<{ x: t.NumberC; y: t.NumberC; }>; background: t.StringC; }>; }>, t.PartialC<{ url: t.StringC; credits: t.Type<string | null, string | null, unknown>; alt: t.Type<string | null, string | null, unknown>; provider: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>; }>]>>>; }>]>, t.ExactC<t.TypeC<{ __TYPE__: t.LiteralC<"ImageContent">; }>>]>; export declare type ImageContent = t.TypeOf<typeof ImageContent>; interface BuildCropUrlArgs { origin: ImageContent["origin"]; /** Image crop parameters */ croppedImage: CroppedImage; } export declare function buildCropUrl(args: BuildCropUrlArgs): string; export interface CroppedImage { zoom: number; /** X coordinate of the crop rect on the original image */ x: number; /** Y coordinate of the crop rect on the original image */ y: number; /** The width of the crop rect over the original image */ cropWidth: number; /** The height of the crop rect over the original image */ cropHeight: number; /** Final (user defined via W input) height of the image */ width: number; /** Final (user defined via H input) height of the image */ height: number; } export declare function getCroppedImage({ contentView, }: { contentView: ImageContentView; }): CroppedImage; export {};