maniiifest
Version:
Typesafe IIIF presentation v3 manifest and collection parsing without external dependencies
577 lines (576 loc) • 24.8 kB
TypeScript
import type * as U from "./iiif-types";
import { ManiiifestAnnotation } from "./ManiiifestAnnotation";
import { ManiiifestAnnotationPage } from "./ManiiifestAnnotationPage";
import { ManiiifestAnnotationCollection } from "./ManiiifestAnnotationCollection";
/**
* The `Maniiifest` class provides methods to parse and manipulate IIIF Manifest and Collection resources.
* For W3C annotation types, use the dedicated parse methods:
* - `Maniiifest.parseAnnotation(data)`
* - `Maniiifest.parseAnnotationPage(data)`
* - `Maniiifest.parseAnnotationCollection(data)`
*/
export declare class Maniiifest {
private specification;
/**
* Constructs a new instance of the Maniiifest class.
*
* Parses the provided data as a IIIF Manifest or Collection.
* For annotation types, use the static parse methods instead.
*
* @param data - The data to be parsed as a Manifest or Collection.
*/
constructor(data: any);
/**
* Parses a W3C Annotation.
*/
static parseAnnotation(data: any): ManiiifestAnnotation;
/**
* Parses a W3C Annotation Page.
*/
static parseAnnotationPage(data: any): ManiiifestAnnotationPage;
/**
* Parses a W3C Annotation Collection.
*/
static parseAnnotationCollection(data: any): ManiiifestAnnotationCollection;
/**
* Yields service items from an ATD service field that may be Array or single Value.
*/
private yieldServiceItems;
/**
* Recursively traverses all Collection nodes in the tree, yielding
* whatever the extract callback produces for each collection value.
*/
private traverseCollections;
/**
* Retrieves the type of the manifest specification.
*
* @returns {string} The type of the manifest specification.
*/
getSpecificationType(): 'Manifest' | 'Collection';
/**
* Retrieves the context from the manifest specification if it is of kind 'Manifest'.
*
* @returns {U.Context | null} The context if the specification is of kind 'Manifest', otherwise null.
*/
getManifestContext(): U.Context | null;
/**
* Retrieves the manifest ID if the specification kind is 'Manifest'.
*
* @returns {U.Id | null} The manifest ID if the specification kind is 'Manifest', otherwise `null`.
*/
getManifestId(): U.Id | null;
/**
* Retrieves the label from the manifest specification if it is of kind 'Manifest'.
*
* @returns {U.Label | null} The label if the specification is of kind 'Manifest' and has a label value, otherwise null.
*/
getManifestLabel(): U.Label | null;
/**
* Retrieves the label from the manifest specification by language if it is of kind 'Manifest'.
*
* @param {string} language - The language code to retrieve the label for.
* @returns {U.LngString | null} The label for the specified language if it exists, otherwise null.
*/
getManifestLabelByLanguage(language: string): U.LngString | null;
/**
* Retrieves the summary from the manifest specification if it is of kind 'Manifest'.
*
* @returns {U.Summary | null} The summary if the specification is of kind 'Manifest' and has a summary value, otherwise null.
*/
getManifestSummary(): U.Summary | null;
/**
* Retrieves the viewing direction from the manifest specification if it is of kind 'Manifest'.
*
* @returns {U.ViewingDirection | null} The viewing direction if the specification is of kind 'Manifest' and has a viewing direction value, otherwise null.
*/
getManifestViewingDirection(): U.ViewingDirection | null;
/**
* Retrieves the navigation date from the manifest specification if it is of kind 'Manifest'.
*
* @returns {U.NavDate | null} The navigation date if the specification is of kind 'Manifest' and has a navDate value, otherwise null.
*/
getManifestNavDate(): U.NavDate | null;
/**
* Retrieves the navigation place from the manifest specification if it is of kind 'Manifest'.
*
* @returns {U.NavPlace | null} The navigation place if the specification is of kind 'Manifest' and has a navPlace value, otherwise null.
*/
getManifestNavPlace(): U.NavPlace | null;
/**
* Retrieves the rights statement from the manifest specification if it is of kind 'Manifest'.
*
* @returns {U.Rights | null} The rights statement if the specification is of kind 'Manifest' and has a rights value, otherwise null.
*/
getManifestRights(): U.Rights | null;
/**
* Retrieves the required statement from the manifest specification if it is of kind 'Manifest'.
*
* @returns {U.RequiredStatement | null} The required statement if the specification is of kind 'Manifest' and has a required statement value, otherwise null.
*/
getManifestRequiredStatement(): U.RequiredStatement | null;
/**
* Retrieves the start element from the manifest specification if it is of kind 'Manifest'.
*
* @returns {U.Start | null} The start element if the specification is of kind 'Manifest' and has a start value, otherwise null.
*/
getManifestStart(): U.Start | null;
/**
* Retrieves the service from the manifest specification if it is of kind 'Manifest'.
*
* @returns {U.Service | null} The service if the specification is of kind 'Manifest' and has a service value, otherwise null.
*/
getManifestService(): U.Service | null;
/**
* Retrieves the manifest from the manifest specification if it is of kind 'Manifest'.
*
* @returns {U.Manifest | null} The manifest if the specification is of kind 'Manifest' and has a value, otherwise null.
*/
getManifest(): U.Manifest | null;
/**
* Retrieves the collection from the manifest specification if it is of kind 'Collection'.
*
* @returns {U.Collection | null} The collection if the specification is of kind 'Collection' and has a value, otherwise null.
*/
getCollection(): U.Collection | null;
/**
* Retrieves the context from the manifest specification if it is of kind 'Collection'.
*
* @returns {U.Context | null} The context if the specification is of kind 'Collection', otherwise null.
*/
getCollectionContext(): U.Context | null;
/**
* Retrieves the collection ID from the manifest specification if it is of kind 'Collection'.
*
* @returns {U.Id | null} The collection ID if the specification is of kind 'Collection', otherwise null.
*/
getCollectionId(): U.Id | null;
/**
* Retrieves the collection label from the manifest specification if it is of kind 'Collection'.
*
* @returns {U.Label | null} The collection label if the specification is of kind 'Collection', otherwise null.
*/
getCollectionLabel(): U.Label | null;
/**
* Retrieves the label from the collection specification by language if it is of kind 'Collection'.
*
* @param {string} language - The language code to retrieve the label for.
* @returns {U.LngString | null} The label for the specified language if it exists, otherwise null.
*/
getCollectionLabelByLanguage(language: string): U.LngString | null;
/**
* Retrieves the service from the collection specification if it is of kind 'Collection'.
*
* @returns {U.Service | null} The service if the specification is of kind 'Collection' and has a service value, otherwise null.
*/
getCollectionService(): U.Service | null;
/**
* Retrieves the required statement from the collection specification if it is of kind 'Collection'.
*
* @returns {U.RequiredStatement | null} The required statement if the specification is of kind 'Collection' and has a required statement value, otherwise null.
*/
getCollectionRequiredStatement(): U.RequiredStatement | null;
/**
* Iterates over the W3C annotation elements on the canvases in the manifest.
*
* This generator function yields W3C annotation elements from the canvases in the manifest.
*
* @yields {U.Annotation} The next W3C annotation element on the canvases in the manifest.
*/
iterateManifestCanvasW3cAnnotation(): IterableIterator<U.Annotation>;
/**
* Iterates over the textual bodies of annotations in the manifest's canvases.
*
* @yields {U.AnnotationBodyTextualBody} The next textual body from a canvas annotation.
*/
iterateManifestCanvasW3cAnnotationTextualBody(): IterableIterator<U.AnnotationBodyTextualBody>;
/**
* Iterates over the W3C annotation page elements on the canvases in the manifest.
*
* This generator function yields W3C annotation page elements from the canvases in the manifest.
*
* @yields {U.AnnotationPage} The next W3C annotation page element on the canvases in the manifest.
*/
iterateManifestCanvasW3cAnnotationPage(): IterableIterator<U.AnnotationPage>;
/**
* Iterates over the annotation page elements on the canvases in the manifest.
*
* This generator function yields annotation page elements from the canvases in the manifest.
*
* @yields {U.AnnotationPage} The next annotation page element on the canvases in the manifest.
*/
iterateManifestCanvasAnnotationPage(): IterableIterator<U.AnnotationPage>;
/**
* Iterates over the annotation elements on the canvases in the manifest.
*
* This generator function yields annotation elements from the canvases in the manifest.
*
* @yields {U.Annotation} The next annotation element on the canvases in the manifest.
*/
iterateManifestCanvasAnnotation(): IterableIterator<U.Annotation>;
/**
* Iterates over the canvas elements in the manifest.
*
* This generator function yields canvas elements from the manifest.
*
* @yields {U.Canvas} The next canvas element in the manifest.
*/
iterateManifestCanvas(): IterableIterator<U.Canvas>;
/**
* Iterates over the thumbnail elements in the manifest.
*
* This generator function yields thumbnail elements from the manifest.
*
* @yields {U.Thumbnail} The next thumbnail element in the manifest.
*/
iterateManifestThumbnail(): IterableIterator<U.Thumbnail>;
/**
* Iterates over the homepage elements in the manifest.
*
* This generator function yields homepage elements from the manifest.
*
* @yields {U.Homepage} The next homepage element in the manifest.
*/
iterateManifestHomepage(): IterableIterator<U.Homepage>;
/**
* Iterates over the behavior elements in the manifest.
*
* This generator function yields behavior elements from the manifest.
*
* @yields {U.Behavior} The next behavior element in the manifest.
*/
iterateManifestBehavior(): IterableIterator<U.Behavior>;
/**
* Iterates over the providers in the manifest.
*
* This generator function yields providers from the manifest.
*
* @yields {U.Provider} The next provider in the manifest.
*/
iterateManifestProvider(): IterableIterator<U.Provider>;
/**
* Iterates over the "rendering" elements in the manifest.
*
* This generator function yields "rendering" elements from the manifest.
*
* @yields {U.Rendering} The next "rendering" element in the manifest.
*/
iterateManifestRendering(): IterableIterator<U.Rendering>;
/**
* Iterates over the "homepage" elements in the providers of the manifest.
*
* This generator function yields "homepage" elements from the providers within the manifest.
*
* @yields {U.Homepage} The next "homepage" element in the providers of the manifest.
*/
iterateManifestProviderHomepage(): IterableIterator<U.Homepage>;
/**
* Iterates over the "seeAlso" elements in the providers of the manifest.
*
* This generator function yields "seeAlso" elements from the providers within the manifest.
*
* @yields {U.SeeAlso} The next "seeAlso" element in the providers of the manifest.
*/
iterateManifestProviderSeeAlso(): IterableIterator<U.SeeAlso>;
/**
* Iterates over the metadata elements in the manifest.
*
* This generator function yields metadata elements from the manifest.
*
* @yields {U.Metadata} The next metadata element in the manifest.
*/
iterateManifestMetadata(): IterableIterator<U.Metadata>;
/**
* Iterates over the "seeAlso" elements in the manifest.
*
* This generator function yields "seeAlso" elements from the manifest.
*
* @yields {U.SeeAlso} The next "seeAlso" element in the manifest.
*/
iterateManifestSeeAlso(): IterableIterator<U.SeeAlso>;
/**
* Iterates over the "partOf" elements in the manifest.
*
* This generator function yields "partOf" elements from the manifest.
*
* @yields {U.PartOf} The next "partOf" element in the manifest.
*/
iterateManifestPartOf(): IterableIterator<U.PartOf>;
/**
* Iterates over the ranges in the manifest.
*
* This generator function yields ranges from the structures within the manifest.
*
* @yields {U.Range} The next range in the manifest.
*/
iterateManifestRange(): IterableIterator<U.Range>;
/**
* Iterates over the navigation place features in the manifest.
*
* This generator function yields features from the navigation places within the manifest.
*
* @yields {U.Feature} The next feature in the navigation places of the manifest.
*/
iterateManifestNavPlaceFeature(): IterableIterator<U.Feature>;
/**
* Iterates over the navigation place features in the manifest's canvases.
*
* This generator function yields features from the navigation places within the canvases of the manifest.
*
* @yields {U.Feature} The next feature in the navigation places of the manifest's canvases.
*/
iterateManifestCanvasNavPlaceFeature(): IterableIterator<U.Feature>;
/**
* Iterates over the range items in the manifest.
*
* This generator function yields range items from the structures within the manifest.
*
* @yields {U.RangeItems} The next range item in the manifest.
*/
iterateManifestRangeItem(): IterableIterator<U.RangeItems>;
/**
* Iterates over the collections and manifests in the specification.
*
* This generator function yields collections from the specification, recursively from nested collections,
* and manifests found within the collections.
*
* @yields {U.Collection | U.Manifest} The next collection or manifest item in the specification.
*/
iterateCollection(): IterableIterator<U.Collection | U.Manifest>;
/**
* Iterates over the collections in the specification.
*
* This generator function yields collections from the specification and recursively from nested collections.
*
* @yields {U.Collection} The next collection item in the specification.
*/
iterateCollectionCollection(): IterableIterator<U.Collection>;
/**
* Iterates over the manifests in the collection.
*
* This generator function yields manifests from the collection's manifest and recursively from nested collections.
*
* @yields {U.Manifest} The next manifest item in the collection.
*/
iterateCollectionManifest(): IterableIterator<U.Manifest>;
/**
* Iterates over the labels in the collection.
*
* This generator function yields labels from the collection's label and recursively from nested collections.
*
* @yields {U.Label} The next label item in the collection.
*/
iterateCollectionLabel(): IterableIterator<U.Label>;
/**
* Iterates over the thumbnails in the collection.
*
* This generator function yields thumbnails from the collection's thumbnail and recursively from nested collections.
*
* @yields {U.Thumbnail} The next thumbnail item in the collection.
*/
iterateCollectionThumbnail(): IterableIterator<U.Thumbnail>;
/**
* Iterates over the metadata in the collection.
*
* This generator function yields metadata from the collection's metadata and recursively from nested collections.
*
* @yields {U.Metadata} The next metadata item in the collection.
*/
iterateCollectionMetadata(): IterableIterator<U.Metadata>;
/**
* Iterates over the providers in the collection.
*
* This generator function yields providers from the collection's provider property and recursively from nested collections.
*
* @yields {U.Provider} The next provider item in the collection.
*/
iterateCollectionProvider(): IterableIterator<U.Provider>;
/**
* Iterates over the homepages in the collection.
*
* This generator function yields homepages from the collection's homepage property and recursively from nested collections.
*
* @yields {U.Homepage} The next homepage item in the collection.
*/
iterateCollectionHomepage(): IterableIterator<U.Homepage>;
/**
* Iterates over the services in the collection.
*
* This generator function yields services from the collection's service property and recursively from nested collections.
*
* @yields {U.ServiceItem} The next service item in the collection.
*/
iterateCollectionService(): IterableIterator<U.ServiceItem>;
/**
* Iterates over the services in the manifest.
*
* This generator function yields services from the service pages within the manifest.
*
* @yields {U.Service} The next service in the manifest.
*/
iterateManifestService(): IterableIterator<U.ServiceItem>;
/**
* Iterates over the services within the thumbnail services in the manifest.
*
* This generator function yields services from the service pages within the thumbnail services of the manifest.
*
* @yields {U.Service} The next service within the thumbnail services in the manifest.
*/
iterateManifestThumbnailService(): IterableIterator<U.ServiceItem>;
/**
* Iterates over the services in the manifest.
*
* This generator function yields services from the manifest's service pages.
*
* @yields {U.Service} The next service in the manifest.
*/
iterateManifestServices(): IterableIterator<U.ServiceItem>;
/**
* Iterates over the W3C annotations in the manifest.
*
* This generator function yields annotations from the manifest's annotation pages.
*
* @yields {U.Annotation} The next annotation in the manifest.
*/
iterateManifestW3cAnnotation(): IterableIterator<U.Annotation>;
/**
* Iterates over the textual bodies of annotations in the manifest.
*
* @yields {U.AnnotationBodyTextualBody} The next textual body from a manifest annotation.
*/
iterateManifestW3cAnnotationTextualBody(): IterableIterator<U.AnnotationBodyTextualBody>;
/**
* Iterates over W3C Annotation Pages in a Manifest.
*
* This generator function iterates through each annotation page present in the manifest's annotations.
* It yields each annotation page transformed by `F.writeAnnotationPageT` for further processing.
*
* @yields {IterableIterator<U.AnnotationPage>} An iterator that yields annotation pages as `U.AnnotationPage` objects.
*/
iterateManifestW3cAnnotationPage(): IterableIterator<U.AnnotationPage>;
/**
* Iterates over the labels of canvases in the manifest.
*
* @yields {U.Label} The next canvas label in the manifest.
*/
iterateManifestCanvasLabel(): IterableIterator<U.Label>;
/**
* Iterates over the metadata elements of canvases in the manifest.
*
* @yields {U.Metadata} The next canvas metadata element in the manifest.
*/
iterateManifestCanvasMetadata(): IterableIterator<U.Metadata>;
/**
* Iterates over the thumbnail elements of canvases in the manifest.
*
* @yields {U.Thumbnail} The next canvas thumbnail element in the manifest.
*/
iterateManifestCanvasThumbnail(): IterableIterator<U.Thumbnail>;
/**
* Iterates over the rendering elements of canvases in the manifest.
*
* @yields {U.Rendering} The next canvas rendering element in the manifest.
*/
iterateManifestCanvasRendering(): IterableIterator<U.Rendering>;
/**
* Iterates over the seeAlso elements of canvases in the manifest.
*
* @yields {U.SeeAlso} The next canvas seeAlso element in the manifest.
*/
iterateManifestCanvasSeeAlso(): IterableIterator<U.SeeAlso>;
/**
* Iterates over the homepage elements of canvases in the manifest.
*
* @yields {U.Homepage} The next canvas homepage element in the manifest.
*/
iterateManifestCanvasHomepage(): IterableIterator<U.Homepage>;
/**
* Iterates over the provider elements of canvases in the manifest.
*
* @yields {U.Provider} The next canvas provider element in the manifest.
*/
iterateManifestCanvasProvider(): IterableIterator<U.Provider>;
/**
* Iterates over the service elements of canvases in the manifest.
*
* @yields {U.ServiceItem} The next canvas service item in the manifest.
*/
iterateManifestCanvasService(): IterableIterator<U.ServiceItem>;
/**
* Iterates over the behavior elements of canvases in the manifest.
*
* @yields {U.Behavior} The next canvas behavior element in the manifest.
*/
iterateManifestCanvasBehavior(): IterableIterator<U.Behavior>;
/**
* Iterates over the labels of ranges in the manifest.
*
* @yields {U.Label} The next range label in the manifest.
*/
iterateManifestRangeLabel(): IterableIterator<U.Label>;
/**
* Iterates over the rendering elements of ranges in the manifest.
*
* @yields {U.Rendering} The next range rendering element in the manifest.
*/
iterateManifestRangeRendering(): IterableIterator<U.Rendering>;
/**
* Iterates over the thumbnail elements of ranges in the manifest.
*
* @yields {U.Thumbnail} The next range thumbnail element in the manifest.
*/
iterateManifestRangeThumbnail(): IterableIterator<U.Thumbnail>;
/**
* Iterates over the annotations in ranges of the manifest.
*
* @yields {U.Annotation} The next annotation in the ranges of the manifest.
*/
iterateManifestRangeAnnotation(): IterableIterator<U.Annotation>;
/**
* Retrieves the summary from the collection specification if it is of kind 'Collection'.
*
* @returns {U.Summary | null} The summary if the specification is of kind 'Collection', otherwise null.
*/
getCollectionSummary(): U.Summary | null;
/**
* Retrieves the rights statement from the collection specification if it is of kind 'Collection'.
*
* @returns {U.Rights | null} The rights statement if the specification is of kind 'Collection', otherwise null.
*/
getCollectionRights(): U.Rights | null;
/**
* Retrieves the navigation date from the collection specification if it is of kind 'Collection'.
*
* @returns {U.NavDate | null} The navigation date if the specification is of kind 'Collection', otherwise null.
*/
getCollectionNavDate(): U.NavDate | null;
/**
* Retrieves the navigation place from the collection specification if it is of kind 'Collection'.
*
* @returns {U.NavPlace | null} The navigation place if the specification is of kind 'Collection', otherwise null.
*/
getCollectionNavPlace(): U.NavPlace | null;
/**
* Iterates over the rendering elements in the collection and nested collections.
*
* @yields {U.Rendering} The next rendering element in the collection.
*/
iterateCollectionRendering(): IterableIterator<U.Rendering>;
/**
* Iterates over the seeAlso elements in the collection and nested collections.
*
* @yields {U.SeeAlso} The next seeAlso element in the collection.
*/
iterateCollectionSeeAlso(): IterableIterator<U.SeeAlso>;
/**
* Iterates over the behavior elements in the collection and nested collections.
*
* @yields {U.Behavior} The next behavior element in the collection.
*/
iterateCollectionBehavior(): IterableIterator<U.Behavior>;
/**
* Iterates over the partOf elements in the collection and nested collections.
*
* @yields {U.PartOf} The next partOf element in the collection.
*/
iterateCollectionPartOf(): IterableIterator<U.PartOf>;
}