@readium/shared
Version:
Shared models to be used across other Readium projects and implementations in Typescript
54 lines (53 loc) • 2.37 kB
TypeScript
import { Link, Links } from './Link';
import { Locator } from './Locator';
import { Manifest } from './Manifest';
import { Metadata } from './Metadata';
import { Fetcher } from '../fetcher/Fetcher';
import { PublicationCollection } from './PublicationCollection';
import { Resource } from '../fetcher/Resource';
import { GuidedNavigationDocument } from "./GuidedNavigation";
export type ServiceFactory = () => null;
/** Shared model for a Readium Publication. */
export declare class Publication {
/** The manifest holding the publication metadata extracted from the publication file */
manifest: Manifest;
private readonly fetcher;
readonly context?: Array<string>;
readonly metadata: Metadata;
readonly links: Links;
/** Identifies a list of resources in reading order for the publication. */
readonly readingOrder: Links;
/** Identifies resources that are necessary for rendering the publication. */
readonly resources?: Links;
/** Identifies the collection that contains a table of contents. */
readonly toc?: Links;
/** Identifies the collection that contains sub collections. */
readonly subcollections?: Map<string, Array<PublicationCollection>>;
constructor(values: {
manifest: Manifest;
fetcher?: Fetcher;
});
/** The URL where this publication is served, computed from the `Link` with `self` relation.
* e.g. https://provider.com/pub1293/manifest.json gives https://provider.com/pub1293/
*/
get baseURL(): string | undefined;
/** Finds the first Link having the given `href` in the publication's links. */
linkWithHref(href: string): Link | undefined;
/**
* Returns the [links] of the first child [PublicationCollection] with the given role, or an
* empty list.
*/
linksWithRole(role: string): Links | undefined;
/** Finds all the links with the given relation in the publication's links. */
linksWithRel(rel: string): Array<Link>;
/**
* Finds the first [Link] having the given [rel] in the publications's links.
*/
linkWithRel(rel: string): Link | undefined;
positionsFromManifest(): Promise<Locator[]>;
guideForLink(link: Link): Promise<GuidedNavigationDocument | undefined>;
/**
* Returns the resource targeted by the given non-templated [link].
*/
get(link: Link): Resource;
}