New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

maniiifest

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maniiifest

Typesafe IIIF presentation v3 manifest and collection parsing without external dependencies

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
143
320.59%
Maintainers
1
Weekly downloads
 
Created
Source

Maniiifest

A TypeScript library for working with IIIF Presentation API 3.0 manifests, collections, and W3C web annotations.

A typechecker/validator built using maniiifest is available online here.

Install

npm install maniiifest

Quick start

import { Maniiifest } from 'maniiifest';

const response = await fetch('https://iiif.wellcomecollection.org/presentation/b19974760');
const data = await response.json();
const parser = new Maniiifest(data);

// Get top-level properties
console.log(parser.getCollectionId());
console.log(parser.getCollectionLabel());

// Iterate over nested items
for (const manifest of parser.iterateCollectionManifest()) {
    console.log(manifest);
}

Constructor

The Maniiifest constructor parses IIIF Manifests and Collections:

const parser = new Maniiifest(data);

For W3C annotation types, use the dedicated static methods or classes:

import { Maniiifest, ManiiifestAnnotation, ManiiifestAnnotationPage, ManiiifestAnnotationCollection } from 'maniiifest';

// Via static factory methods
const annotation = Maniiifest.parseAnnotation(data);
const page = Maniiifest.parseAnnotationPage(data);
const annoCollection = Maniiifest.parseAnnotationCollection(data);

// Or via direct constructors
const annotation2 = new ManiiifestAnnotation(data);
const page2 = new ManiiifestAnnotationPage(data);
const annoCollection2 = new ManiiifestAnnotationCollection(data);

Getters and iterators

Every method is either a getter that returns a single value (or null) or an iterator (generator) that you loop over with for...of.

The naming convention tells you what it does:

PatternReturnsExample
get<Resource><Property>()value or nullgetManifestLabel()
iterate<Resource><Item>()generatoriterateManifestCanvas()

Manifest

const parser = new Maniiifest(manifest);

parser.getManifestId();
parser.getManifestLabel();
parser.getManifestSummary();
parser.getManifestRights();
parser.getManifestRequiredStatement();

for (const canvas of parser.iterateManifestCanvas()) { /* ... */ }
for (const meta of parser.iterateManifestMetadata()) { /* ... */ }
for (const anno of parser.iterateManifestCanvasAnnotation()) { /* ... */ }
for (const range of parser.iterateManifestRange()) { /* ... */ }

Canvas and range properties are accessible through the manifest:

// Canvas-level iteration
for (const label of parser.iterateManifestCanvasLabel()) { /* ... */ }
for (const thumb of parser.iterateManifestCanvasThumbnail()) { /* ... */ }
for (const meta of parser.iterateManifestCanvasMetadata()) { /* ... */ }
for (const rendering of parser.iterateManifestCanvasRendering()) { /* ... */ }
for (const seeAlso of parser.iterateManifestCanvasSeeAlso()) { /* ... */ }
for (const service of parser.iterateManifestCanvasService()) { /* ... */ }

// Range-level iteration (structures / table of contents)
for (const label of parser.iterateManifestRangeLabel()) { /* ... */ }
for (const item of parser.iterateManifestRangeItem()) { /* ... */ }
for (const rendering of parser.iterateManifestRangeRendering()) { /* ... */ }
for (const anno of parser.iterateManifestRangeAnnotation()) { /* ... */ }

Collection

const parser = new Maniiifest(collection);

parser.getCollectionId();
parser.getCollectionLabel();
parser.getCollectionSummary();
parser.getCollectionRights();
parser.getCollectionNavDate();
parser.getCollectionNavPlace();

for (const manifest of parser.iterateCollectionManifest()) { /* ... */ }
for (const nested of parser.iterateCollectionCollection()) { /* ... */ }
for (const meta of parser.iterateCollectionMetadata()) { /* ... */ }
for (const rendering of parser.iterateCollectionRendering()) { /* ... */ }
for (const seeAlso of parser.iterateCollectionSeeAlso()) { /* ... */ }
for (const behavior of parser.iterateCollectionBehavior()) { /* ... */ }
for (const partOf of parser.iterateCollectionPartOf()) { /* ... */ }

Annotation

const parser = Maniiifest.parseAnnotation(annotation);

parser.getAnnotationId();
parser.getAnnotationBody();
parser.getAnnotationTarget();
parser.getAnnotationMotivation();
parser.getAnnotationCreator();
parser.getAnnotationCreated();
parser.getAnnotationModified();

for (const body of parser.iterateAnnotationTextualBody()) { /* ... */ }
for (const body of parser.iterateAnnotationResourceBody()) { /* ... */ }
for (const target of parser.iterateAnnotationTarget()) { /* ... */ }
for (const feature of parser.iterateAnnotationFeature()) { /* ... */ }
for (const coords of parser.iterateAnnotationGeometryPointCoordinates()) { /* ... */ }

Annotation Page

const parser = Maniiifest.parseAnnotationPage(page);

parser.getAnnotationPageId();
parser.getAnnotationPagePartOf();
parser.getAnnotationPageLabel();
parser.getAnnotationPageNext();
parser.getAnnotationPageStartIndex();
for (const anno of parser.iterateAnnotationPageAnnotation()) { /* ... */ }
for (const body of parser.iterateAnnotationPageAnnotationTextualBody()) { /* ... */ }
for (const ref of parser.iterateAnnotationPageAnnotationCanvasRef()) { /* ... */ }

Annotation Collection

const parser = Maniiifest.parseAnnotationCollection(collection);

parser.getAnnotationCollectionId();
parser.getAnnotationCollectionLabel();
parser.getAnnotationCollectionTotal();
parser.getAnnotationCollectionFirst();
parser.getAnnotationCollectionLast();

for (const anno of parser.iterateAnnotationCollectionAnnotation()) { /* ... */ }

Full API docs: jptmoore.github.io/maniiifest

Types

The library exports TypeScript types that match real IIIF JSON structure:

import { Maniiifest } from 'maniiifest';
import type { Manifest, Canvas, Annotation, Label, Metadata, Service } from 'maniiifest';

const response = await fetch('https://example.org/iiif/manifest.json');
const manifest: Manifest = await response.json();

console.log(manifest.id);
console.log(manifest.label);

for (const item of manifest.metadata ?? []) {
    const meta: Metadata = item;
    console.log(meta.label, '->', meta.value);
}

A full list of exported types is in the generated src/iiif-types.ts file.

More examples

More examples can be found here.

Scripts

  • npm run build: Compile TypeScript to dist/.
  • npm run test: Run the tests using Jest.
  • npm start: Run the example script.
  • npm run compilespec: Recompile specification.ts from the ATD spec and regenerate iiif-types.ts. Requires atdts. Only needed when specification.atd changes.
  • npm run generate-docs: Generate documentation using TypeDoc.

License

This project is licensed under the MIT License.

Keywords

IIIF

FAQs

Package last updated on 09 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts