cozy-iiif
Version:
A developer-friendly collection of abstractions and utilities built on top of @iiif/presentation-3 and @iiif/parser
25 lines (23 loc) • 640 B
text/typescript
import type { CozyCanvas } from '../types';
import {
getImages,
getLabel,
getMetadata,
getThumbnailURL
} from '../core';
export const hydrateCanvas = (canvas: CozyCanvas): CozyCanvas => {
const { source } = canvas;
const images = getImages(source);
return {
source,
id: source.id,
width: source.width,
height: source.height,
images,
annotations: (source.annotations || []),
getImageURL: images.length > 0 ? images[0].getImageURL : () => undefined,
getLabel: getLabel(source),
getMetadata: getMetadata(source),
getThumbnailURL: getThumbnailURL(source, images)
} as CozyCanvas;
}