@readium/shared
Version:
Shared models to be used across other Readium projects and implementations in Typescript
102 lines (101 loc) • 3.31 kB
TypeScript
/**
* One or more alternative expressions of the location.
* https://github.com/readium/architecture/tree/master/models/locators#the-location-object
*/
export declare class LocatorLocations {
/** Contains one or more fragment in the resource referenced by the `Locator`. */
readonly fragments: Array<string>;
/** Progression in the resource expressed as a percentage (between 0 and 1). */
readonly progression?: number;
/** Progression in the publication expressed as a percentage (between 0 and 1). */
readonly totalProgression?: number;
/** An index in the publication (>= 1).*/
readonly position?: number;
/** Additional locations for extensions. */
readonly otherLocations?: Map<string, any>;
/**
* Creates a [Locations].
*/
constructor(values: {
fragments?: Array<string>;
progression?: number;
totalProgression?: number;
position?: number;
otherLocations?: Map<string, any>;
});
/**
* Parses a [Locations] from its RWPM JSON representation.
*/
static deserialize(json: any): LocatorLocations | undefined;
/**
* Serializes a [Locations] to its RWPM JSON representation.
*/
serialize(): any;
}
export declare class LocatorText {
readonly after?: string;
readonly before?: string;
readonly highlight?: string;
/**
* Creates a [Text].
*/
constructor(values: {
after?: string;
before?: string;
highlight?: string;
});
/**
* Parses a [Locations] from its RWPM JSON representation.
*/
static deserialize(json: any): LocatorText | undefined;
/**
* Serializes a [Locations] to its RWPM JSON representation.
*/
serialize(): any;
}
/**
* Provides a precise location in a publication in a format that can be stored and shared.
*
* There are many different use cases for locators:
* - getting back to the last position in a publication
* - bookmarks
* - highlights & annotations
* - search results
* - human-readable (and shareable) reference in a publication
*
* https://github.com/readium/architecture/tree/master/locators
*/
export declare class Locator {
/** The URI of the resource that the Locator Object points to. */
readonly href: string;
/** The media type of the resource that the Locator Object points to. */
readonly type: string;
/** The title of the chapter or section which is more relevant in the context of this locator. */
readonly title?: string;
/** One or more alternative expressions of the location. */
readonly locations: LocatorLocations;
/** Textual context of the locator. */
readonly text?: LocatorText;
/**
* Creates a [Locator].
*/
constructor(values: {
href: string;
type: string;
title?: string;
locations?: LocatorLocations;
text?: LocatorText;
});
/**
* Parses a [Link] from its RWPM JSON representation.
*/
static deserialize(json: any): Locator | undefined;
/**
* Serializes a [Link] to its RWPM JSON representation.
*/
serialize(): any;
/**
* Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
*/
copyWithLocations(values: any): Locator;
}