@readium/shared 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/LICENSE +28 -0
  2. package/README.MD +27 -0
  3. package/dist/index.js +2536 -0
  4. package/dist/index.umd.cjs +2 -0
  5. package/package.json +73 -0
  6. package/src/fetcher/Fetcher.ts +37 -0
  7. package/src/fetcher/HttpFetcher.ts +122 -0
  8. package/src/fetcher/Resource.ts +37 -0
  9. package/src/fetcher/index.ts +2 -0
  10. package/src/index.ts +4 -0
  11. package/src/opds/Acquisition.ts +54 -0
  12. package/src/opds/Availability.ts +61 -0
  13. package/src/opds/Copies.ts +43 -0
  14. package/src/opds/Holds.ts +43 -0
  15. package/src/opds/Price.ts +51 -0
  16. package/src/opds/index.ts +5 -0
  17. package/src/publication/BelongsTo.ts +51 -0
  18. package/src/publication/Contributor.ts +129 -0
  19. package/src/publication/GuidedNavigation.ts +176 -0
  20. package/src/publication/Link.ts +332 -0
  21. package/src/publication/LocalizedString.ts +74 -0
  22. package/src/publication/Locator.ts +225 -0
  23. package/src/publication/LocatorCollection.ts +133 -0
  24. package/src/publication/Manifest.ts +256 -0
  25. package/src/publication/Metadata.ts +329 -0
  26. package/src/publication/Properties.ts +44 -0
  27. package/src/publication/Publication.ts +148 -0
  28. package/src/publication/PublicationCollection.ts +144 -0
  29. package/src/publication/ReadingProgression.ts +28 -0
  30. package/src/publication/Subject.ts +115 -0
  31. package/src/publication/encryption/Encryption.ts +68 -0
  32. package/src/publication/encryption/Properties.ts +20 -0
  33. package/src/publication/encryption/index.ts +2 -0
  34. package/src/publication/epub/EPUBLayout.ts +10 -0
  35. package/src/publication/epub/Presentation.ts +16 -0
  36. package/src/publication/epub/Properties.ts +28 -0
  37. package/src/publication/epub/Publication.ts +51 -0
  38. package/src/publication/epub/index.ts +4 -0
  39. package/src/publication/html/DomRange.ts +63 -0
  40. package/src/publication/html/DomRangePoint.ts +64 -0
  41. package/src/publication/html/Locations.ts +129 -0
  42. package/src/publication/html/index.ts +3 -0
  43. package/src/publication/index.ts +19 -0
  44. package/src/publication/opds/Properties.ts +84 -0
  45. package/src/publication/opds/Publication.ts +14 -0
  46. package/src/publication/opds/index.ts +2 -0
  47. package/src/publication/presentation/Metadata.ts +19 -0
  48. package/src/publication/presentation/Presentation.ts +155 -0
  49. package/src/publication/presentation/Properties.ts +70 -0
  50. package/src/publication/presentation/index.ts +3 -0
  51. package/src/publication/services/content/Content.ts +36 -0
  52. package/src/publication/services/content/ContentTokenizer.ts +62 -0
  53. package/src/publication/services/content/Iterator.ts +46 -0
  54. package/src/publication/services/content/element/attributes.ts +44 -0
  55. package/src/publication/services/content/element/element.ts +118 -0
  56. package/src/publication/services/content/element/index.ts +3 -0
  57. package/src/publication/services/content/element/text_role.ts +60 -0
  58. package/src/publication/services/content/index.ts +5 -0
  59. package/src/publication/services/content/iterators/HTMLResourceContentIterator.ts +571 -0
  60. package/src/publication/services/content/iterators/PDFTextContentIterator.ts +184 -0
  61. package/src/publication/services/content/iterators/PublicationContentIterator.ts +144 -0
  62. package/src/publication/services/content/iterators/helpers.ts +146 -0
  63. package/src/publication/services/content/iterators/index.ts +3 -0
  64. package/src/publication/services/index.ts +1 -0
  65. package/src/util/JSONParse.ts +31 -0
  66. package/src/util/Language.ts +5 -0
  67. package/src/util/URITemplate.ts +83 -0
  68. package/src/util/index.ts +5 -0
  69. package/src/util/mediatype/MediaType.ts +563 -0
  70. package/src/util/mediatype/index.ts +1 -0
  71. package/src/util/tokenizer/TextTokenizer.ts +126 -0
  72. package/src/util/tokenizer/Tokenizer.ts +8 -0
  73. package/src/util/tokenizer/index.ts +2 -0
  74. package/src/util/tokenizer/tokenize-english/README.md +7 -0
  75. package/src/util/tokenizer/tokenize-english/abbreviations.js +52 -0
  76. package/src/util/tokenizer/tokenize-english/index.d.ts +3 -0
  77. package/src/util/tokenizer/tokenize-english/index.js +243 -0
  78. package/src/util/tokenizer/tokenize-english/utils.js +16 -0
  79. package/src/util/tokenizer/tokenize-text/README.MD +6 -0
  80. package/src/util/tokenizer/tokenize-text/index.d.ts +52 -0
  81. package/src/util/tokenizer/tokenize-text/index.js +256 -0
  82. package/src/util/tokenizer/tokenize-text/tokens.js +100 -0
  83. package/types/src/fetcher/Fetcher.d.ts +27 -0
  84. package/types/src/fetcher/HttpFetcher.d.ts +28 -0
  85. package/types/src/fetcher/Resource.d.ts +15 -0
  86. package/types/src/fetcher/index.d.ts +2 -0
  87. package/types/src/index.d.ts +4 -0
  88. package/types/src/opds/Acquisition.d.ts +26 -0
  89. package/types/src/opds/Availability.d.ts +32 -0
  90. package/types/src/opds/Copies.d.ts +22 -0
  91. package/types/src/opds/Holds.d.ts +22 -0
  92. package/types/src/opds/Price.d.ts +29 -0
  93. package/types/src/opds/index.d.ts +5 -0
  94. package/types/src/publication/BelongsTo.d.ts +23 -0
  95. package/types/src/publication/Contributor.d.ts +60 -0
  96. package/types/src/publication/GuidedNavigation.d.ts +70 -0
  97. package/types/src/publication/Link.d.ts +128 -0
  98. package/types/src/publication/LocalizedString.d.ts +48 -0
  99. package/types/src/publication/Locator.d.ts +101 -0
  100. package/types/src/publication/LocatorCollection.d.ts +54 -0
  101. package/types/src/publication/Manifest.d.ts +59 -0
  102. package/types/src/publication/Metadata.d.ts +101 -0
  103. package/types/src/publication/Properties.d.ts +28 -0
  104. package/types/src/publication/Publication.d.ts +53 -0
  105. package/types/src/publication/PublicationCollection.d.ts +34 -0
  106. package/types/src/publication/ReadingProgression.d.ts +9 -0
  107. package/types/src/publication/Subject.d.ts +56 -0
  108. package/types/src/publication/encryption/Encryption.d.ts +33 -0
  109. package/types/src/publication/encryption/Properties.d.ts +10 -0
  110. package/types/src/publication/encryption/index.d.ts +2 -0
  111. package/types/src/publication/epub/EPUBLayout.d.ts +5 -0
  112. package/types/src/publication/epub/Presentation.d.ts +7 -0
  113. package/types/src/publication/epub/Properties.d.ts +14 -0
  114. package/types/src/publication/epub/Publication.d.ts +19 -0
  115. package/types/src/publication/epub/index.d.ts +4 -0
  116. package/types/src/publication/html/DomRange.d.ts +40 -0
  117. package/types/src/publication/html/DomRangePoint.d.ts +36 -0
  118. package/types/src/publication/html/Locations.d.ts +45 -0
  119. package/types/src/publication/html/index.d.ts +3 -0
  120. package/types/src/publication/index.d.ts +19 -0
  121. package/types/src/publication/opds/Properties.d.ts +38 -0
  122. package/types/src/publication/opds/Publication.d.ts +6 -0
  123. package/types/src/publication/opds/index.d.ts +2 -0
  124. package/types/src/publication/presentation/Metadata.d.ts +6 -0
  125. package/types/src/publication/presentation/Presentation.d.ts +95 -0
  126. package/types/src/publication/presentation/Properties.d.ts +32 -0
  127. package/types/src/publication/presentation/index.d.ts +3 -0
  128. package/types/src/publication/services/content/Content.d.ts +20 -0
  129. package/types/src/publication/services/content/ContentTokenizer.d.ts +19 -0
  130. package/types/src/publication/services/content/Iterator.d.ts +38 -0
  131. package/types/src/publication/services/content/element/attributes.d.ts +31 -0
  132. package/types/src/publication/services/content/element/element.d.ts +107 -0
  133. package/types/src/publication/services/content/element/index.d.ts +3 -0
  134. package/types/src/publication/services/content/element/text_role.d.ts +53 -0
  135. package/types/src/publication/services/content/index.d.ts +5 -0
  136. package/types/src/publication/services/content/iterators/HTMLResourceContentIterator.d.ts +30 -0
  137. package/types/src/publication/services/content/iterators/PDFTextContentIterator.d.ts +60 -0
  138. package/types/src/publication/services/content/iterators/PublicationContentIterator.d.ts +59 -0
  139. package/types/src/publication/services/content/iterators/helpers.d.ts +10 -0
  140. package/types/src/publication/services/content/iterators/index.d.ts +3 -0
  141. package/types/src/publication/services/index.d.ts +1 -0
  142. package/types/src/util/JSONParse.d.ts +11 -0
  143. package/types/src/util/Language.d.ts +1 -0
  144. package/types/src/util/URITemplate.d.ts +24 -0
  145. package/types/src/util/index.d.ts +5 -0
  146. package/types/src/util/mediatype/MediaType.d.ts +148 -0
  147. package/types/src/util/mediatype/index.d.ts +1 -0
  148. package/types/src/util/tokenizer/TextTokenizer.d.ts +39 -0
  149. package/types/src/util/tokenizer/Tokenizer.d.ts +6 -0
  150. package/types/src/util/tokenizer/index.d.ts +2 -0
@@ -0,0 +1,101 @@
1
+ /**
2
+ * One or more alternative expressions of the location.
3
+ * https://github.com/readium/architecture/tree/master/models/locators#the-location-object
4
+ */
5
+ export declare class LocatorLocations {
6
+ /** Contains one or more fragment in the resource referenced by the `Locator`. */
7
+ readonly fragments: Array<string>;
8
+ /** Progression in the resource expressed as a percentage (between 0 and 1). */
9
+ readonly progression?: number;
10
+ /** Progression in the publication expressed as a percentage (between 0 and 1). */
11
+ readonly totalProgression?: number;
12
+ /** An index in the publication (>= 1).*/
13
+ readonly position?: number;
14
+ /** Additional locations for extensions. */
15
+ readonly otherLocations?: Map<string, any>;
16
+ /**
17
+ * Creates a [Locations].
18
+ */
19
+ constructor(values: {
20
+ fragments?: Array<string>;
21
+ progression?: number;
22
+ totalProgression?: number;
23
+ position?: number;
24
+ otherLocations?: Map<string, any>;
25
+ });
26
+ /**
27
+ * Parses a [Locations] from its RWPM JSON representation.
28
+ */
29
+ static deserialize(json: any): LocatorLocations | undefined;
30
+ /**
31
+ * Serializes a [Locations] to its RWPM JSON representation.
32
+ */
33
+ serialize(): any;
34
+ }
35
+ export declare class LocatorText {
36
+ readonly after?: string;
37
+ readonly before?: string;
38
+ readonly highlight?: string;
39
+ /**
40
+ * Creates a [Text].
41
+ */
42
+ constructor(values: {
43
+ after?: string;
44
+ before?: string;
45
+ highlight?: string;
46
+ });
47
+ /**
48
+ * Parses a [Locations] from its RWPM JSON representation.
49
+ */
50
+ static deserialize(json: any): LocatorText | undefined;
51
+ /**
52
+ * Serializes a [Locations] to its RWPM JSON representation.
53
+ */
54
+ serialize(): any;
55
+ }
56
+ /**
57
+ * Provides a precise location in a publication in a format that can be stored and shared.
58
+ *
59
+ * There are many different use cases for locators:
60
+ * - getting back to the last position in a publication
61
+ * - bookmarks
62
+ * - highlights & annotations
63
+ * - search results
64
+ * - human-readable (and shareable) reference in a publication
65
+ *
66
+ * https://github.com/readium/architecture/tree/master/locators
67
+ */
68
+ export declare class Locator {
69
+ /** The URI of the resource that the Locator Object points to. */
70
+ readonly href: string;
71
+ /** The media type of the resource that the Locator Object points to. */
72
+ readonly type: string;
73
+ /** The title of the chapter or section which is more relevant in the context of this locator. */
74
+ readonly title?: string;
75
+ /** One or more alternative expressions of the location. */
76
+ readonly locations: LocatorLocations;
77
+ /** Textual context of the locator. */
78
+ readonly text?: LocatorText;
79
+ /**
80
+ * Creates a [Locator].
81
+ */
82
+ constructor(values: {
83
+ href: string;
84
+ type: string;
85
+ title?: string;
86
+ locations?: LocatorLocations;
87
+ text?: LocatorText;
88
+ });
89
+ /**
90
+ * Parses a [Link] from its RWPM JSON representation.
91
+ */
92
+ static deserialize(json: any): Locator | undefined;
93
+ /**
94
+ * Serializes a [Link] to its RWPM JSON representation.
95
+ */
96
+ serialize(): any;
97
+ /**
98
+ * Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
99
+ */
100
+ copyWithLocations(values: any): Locator;
101
+ }
@@ -0,0 +1,54 @@
1
+ import { Links } from './Link';
2
+ import { LocalizedString } from './LocalizedString';
3
+ import { Locator } from './Locator';
4
+ /**
5
+ * Holds the metadata of a `LocatorCollection`.
6
+ */
7
+ export declare class LocatorCollectionMetadata {
8
+ title?: LocalizedString;
9
+ /** numberOfItems Indicates the total number of locators in the collection. */
10
+ numberOfItems?: number;
11
+ otherMetadata?: Map<string, any>;
12
+ /**
13
+ * Creates a [LocatorMetadata].
14
+ */
15
+ constructor(values: {
16
+ title?: LocalizedString;
17
+ numberOfItems?: number;
18
+ otherMetadata?: Map<string, any>;
19
+ });
20
+ /**
21
+ * Parses a [LocatorMetadata] from its RWPM JSON representation.
22
+ */
23
+ static deserialize(json: any): LocatorCollectionMetadata | undefined;
24
+ /**
25
+ * Serializes a [LocatorMetadata] to its RWPM JSON representation.
26
+ */
27
+ serialize(): any;
28
+ }
29
+ /**
30
+ * Represents a sequential list of `Locator` objects.
31
+ *
32
+ * For example, a search result or a list of positions.
33
+ */
34
+ export declare class LocatorCollection {
35
+ metadata: LocatorCollectionMetadata;
36
+ links: Links;
37
+ locators: Array<Locator>;
38
+ /**
39
+ * Creates a [LocatorCollection].
40
+ */
41
+ constructor(values: {
42
+ metadata?: LocatorCollectionMetadata;
43
+ links?: Links;
44
+ locators?: Array<Locator>;
45
+ });
46
+ /**
47
+ * Parses a [LocatorCollection] from its RWPM JSON representation.
48
+ */
49
+ static deserialize(json: any): LocatorCollection | undefined;
50
+ /**
51
+ * Serializes a [LocatorCollection] to its RWPM JSON representation.
52
+ */
53
+ serialize(): any;
54
+ }
@@ -0,0 +1,59 @@
1
+ import { Metadata } from './Metadata';
2
+ import { Link, Links } from './Link';
3
+ import { PublicationCollection } from './PublicationCollection';
4
+ import { Locator } from "./Locator";
5
+ /** Holds the metadata of a Readium publication, as described in
6
+ * the Readium Web Publication Manifest.
7
+ * See. https://readium.org/webpub-manifest/
8
+ */
9
+ export declare class Manifest {
10
+ readonly context?: Array<string>;
11
+ readonly metadata: Metadata;
12
+ readonly links: Links;
13
+ /** Identifies a list of resources in reading order for the publication. */
14
+ readonly readingOrder: Links;
15
+ /** Identifies resources that are necessary for rendering the publication. */
16
+ readonly resources?: Links;
17
+ /** Identifies the collection that contains a table of contents. */
18
+ readonly tableOfContents?: Links;
19
+ readonly subcollections?: Map<string, Array<PublicationCollection>>;
20
+ constructor(values: {
21
+ context?: Array<string>;
22
+ metadata: Metadata;
23
+ links: Links;
24
+ readingOrder: Links;
25
+ resources?: Links;
26
+ tableOfContents?: Links;
27
+ subcollections?: Map<string, Array<PublicationCollection>>;
28
+ });
29
+ /**
30
+ * Parses a [Publication] from its RWPM JSON representation.
31
+ *
32
+ * https://readium.org/webpub-manifest/
33
+ * https://readium.org/webpub-manifest/schema/publication.schema.json
34
+ */
35
+ static deserialize(json: any): Manifest | undefined;
36
+ /**
37
+ * Serializes a [Publication] to its RWPM JSON representation.
38
+ */
39
+ serialize(): any;
40
+ /** Finds the first link with the given relation in the manifest's links. */
41
+ linkWithRel(rel: string): Link | undefined;
42
+ /** Finds all the links with the given relation in the manifest's links. */
43
+ linksWithRel(rel: string): Array<Link>;
44
+ /**
45
+ * Creates a new [Locator] object from a [Link] to a resource of this manifest.
46
+ * Returns null if the resource is not found in this manifest.
47
+ */
48
+ locatorFromLink(link: Link): Locator | undefined;
49
+ /** Finds the first Link having the given `href` in the publication's links. */
50
+ linkWithHref(href: string): Link | undefined;
51
+ /** The URL where this publication is served, computed from the `Link` with `self` relation.
52
+ * e.g. https://provider.com/pub1293/manifest.json gives https://provider.com/pub1293/
53
+ */
54
+ get baseURL(): string | undefined;
55
+ /**
56
+ * Sets the URL where this [Publication]'s RWPM manifest is served.
57
+ */
58
+ setSelfLink(href: string): void;
59
+ }
@@ -0,0 +1,101 @@
1
+ import { BelongsTo } from './BelongsTo';
2
+ import { Contributors } from './Contributor';
3
+ import { LocalizedString } from './LocalizedString';
4
+ import { ReadingProgression } from './ReadingProgression';
5
+ import { Subjects } from './Subject';
6
+ /**
7
+ * https://readium.org/webpub-manifest/schema/metadata.schema.json
8
+ *
9
+ * readingProgression : This contains the reading progression as declared in the
10
+ * publication, so it might be [auto]. To lay out the content, use [effectiveReadingProgression]
11
+ * to get the calculated reading progression from the declared direction and the language.
12
+ * otherMetadata Additional metadata for extensions, as a JSON dictionary.
13
+ */
14
+ export declare class Metadata {
15
+ title: LocalizedString;
16
+ typeUri?: string;
17
+ identifier?: string;
18
+ subtitle?: LocalizedString;
19
+ sortAs?: LocalizedString;
20
+ artists?: Contributors;
21
+ authors?: Contributors;
22
+ colorists?: Contributors;
23
+ contributors?: Contributors;
24
+ editors?: Contributors;
25
+ illustrators?: Contributors;
26
+ inkers?: Contributors;
27
+ letterers?: Contributors;
28
+ narrators?: Contributors;
29
+ pencilers?: Contributors;
30
+ translators?: Contributors;
31
+ languages?: Array<string>;
32
+ description?: string;
33
+ publishers?: Contributors;
34
+ imprints?: Contributors;
35
+ published?: Date;
36
+ modified?: Date;
37
+ subjects?: Subjects;
38
+ belongsTo?: BelongsTo;
39
+ belongsToCollections?: Contributors;
40
+ belongsToSeries?: Contributors;
41
+ readingProgression?: ReadingProgression;
42
+ duration?: number;
43
+ numberOfPages?: number;
44
+ otherMetadata?: {
45
+ [key: string]: any;
46
+ };
47
+ /**All metadata not in otherMetadata */
48
+ private static readonly mappedProperties;
49
+ /** Creates [Metadata] object */
50
+ constructor(values: {
51
+ title: LocalizedString;
52
+ typeUri?: string;
53
+ identifier?: string;
54
+ subtitle?: LocalizedString;
55
+ sortAs?: LocalizedString;
56
+ artists?: Contributors;
57
+ authors?: Contributors;
58
+ colorists?: Contributors;
59
+ contributors?: Contributors;
60
+ editors?: Contributors;
61
+ illustrators?: Contributors;
62
+ inkers?: Contributors;
63
+ letterers?: Contributors;
64
+ narrators?: Contributors;
65
+ pencilers?: Contributors;
66
+ translators?: Contributors;
67
+ languages?: Array<string>;
68
+ description?: string;
69
+ publishers?: Contributors;
70
+ imprints?: Contributors;
71
+ published?: Date;
72
+ modified?: Date;
73
+ subjects?: Subjects;
74
+ belongsTo?: BelongsTo;
75
+ belongsToCollections?: Contributors;
76
+ belongsToSeries?: Contributors;
77
+ readingProgression?: ReadingProgression;
78
+ duration?: number;
79
+ numberOfPages?: number;
80
+ otherMetadata?: {
81
+ [key: string]: any;
82
+ };
83
+ });
84
+ /**
85
+ * Parses a [Metadata] from its RWPM JSON representation.
86
+ *
87
+ * If the metadata can't be parsed, a warning will be logged with [warnings].
88
+ */
89
+ static deserialize(json: any): Metadata | undefined;
90
+ /**
91
+ * Serializes a [Metadata] to its RWPM JSON representation.
92
+ */
93
+ serialize(): any;
94
+ /**
95
+ * Computes a [ReadingProgression] when the value of [readingProgression] is set to
96
+ * auto, using the publication language.
97
+ *
98
+ * See this issue for more details: https://github.com/readium/architecture/issues/113
99
+ */
100
+ get effectiveReadingProgression(): ReadingProgression;
101
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Properties associated to the linked resource.
3
+ *
4
+ * This is opened for extensions.
5
+ * https://readium.org/webpub-manifest/schema/link.schema.json
6
+ */
7
+ export declare class Properties {
8
+ otherProperties: {
9
+ [key: string]: any;
10
+ };
11
+ constructor(values: {
12
+ [key: string]: any;
13
+ });
14
+ /**
15
+ * Creates a [Properties] from its RWPM JSON representation.
16
+ */
17
+ static deserialize(json: any): Properties | undefined;
18
+ /**
19
+ * Serializes a [Properties] to its RWPM JSON representation.
20
+ */
21
+ serialize(): any;
22
+ /**
23
+ * Makes a copy of this [Properties] after merging in the given additional other [properties].
24
+ */
25
+ add(properties: {
26
+ [key: string]: any;
27
+ }): Properties;
28
+ }
@@ -0,0 +1,53 @@
1
+ import { Link, Links } from './Link';
2
+ import { Locator } from './Locator';
3
+ import { Manifest } from './Manifest';
4
+ import { Metadata } from './Metadata';
5
+ import { Fetcher } from '../fetcher/Fetcher';
6
+ import { PublicationCollection } from './PublicationCollection';
7
+ import { Resource } from '../fetcher/Resource';
8
+ import { GuidedNavigationDocument } from "./GuidedNavigation";
9
+ export type ServiceFactory = () => null;
10
+ /** Shared model for a Readium Publication. */
11
+ export declare class Publication {
12
+ /** The manifest holding the publication metadata extracted from the publication file */
13
+ manifest: Manifest;
14
+ private readonly fetcher;
15
+ readonly context?: Array<string>;
16
+ readonly metadata: Metadata;
17
+ readonly links: Links;
18
+ /** Identifies a list of resources in reading order for the publication. */
19
+ readonly readingOrder: Links;
20
+ /** Identifies resources that are necessary for rendering the publication. */
21
+ readonly resources?: Links;
22
+ /** Identifies the collection that contains a table of contents. */
23
+ readonly tableOfContents?: Links;
24
+ /** Identifies the collection that contains sub collections. */
25
+ readonly subcollections?: Map<string, Array<PublicationCollection>>;
26
+ constructor(values: {
27
+ manifest: Manifest;
28
+ fetcher?: Fetcher;
29
+ });
30
+ /** The URL where this publication is served, computed from the `Link` with `self` relation.
31
+ * e.g. https://provider.com/pub1293/manifest.json gives https://provider.com/pub1293/
32
+ */
33
+ get baseURL(): string | undefined;
34
+ /** Finds the first Link having the given `href` in the publication's links. */
35
+ linkWithHref(href: string): Link | undefined;
36
+ /**
37
+ * Returns the [links] of the first child [PublicationCollection] with the given role, or an
38
+ * empty list.
39
+ */
40
+ linksWithRole(role: string): Links | undefined;
41
+ /** Finds all the links with the given relation in the publication's links. */
42
+ linksWithRel(rel: string): Array<Link>;
43
+ /**
44
+ * Finds the first [Link] having the given [rel] in the publications's links.
45
+ */
46
+ linkWithRel(rel: string): Link | undefined;
47
+ positionsFromManifest(): Promise<Locator[]>;
48
+ guideForLink(link: Link): Promise<GuidedNavigationDocument | undefined>;
49
+ /**
50
+ * Returns the resource targeted by the given non-templated [link].
51
+ */
52
+ get(link: Link): Resource;
53
+ }
@@ -0,0 +1,34 @@
1
+ import { Links } from './Link';
2
+ /**
3
+ * Core Collection Model
4
+ *
5
+ * https://readium.org/webpub-manifest/schema/subcollection.schema.json
6
+ * Can be used as extension point in the Readium Web Publication Manifest.
7
+ */
8
+ export declare class PublicationCollection {
9
+ metadata?: Map<string, any>;
10
+ links: Links;
11
+ subcollections?: Map<string, Array<PublicationCollection>>;
12
+ /**
13
+ * Creates a [PublicationCollection].
14
+ */
15
+ constructor(values: {
16
+ metadata?: Map<string, any>;
17
+ links: Links;
18
+ subcollections?: Map<string, Array<PublicationCollection>>;
19
+ });
20
+ /**
21
+ * Parses a [PublicationCollection] from its RWPM JSON representation.
22
+ */
23
+ static deserialize(json: any): PublicationCollection | undefined;
24
+ /**
25
+ * Parses a map of [PublicationCollection] indexed by their roles from its RWPM JSON representation.
26
+ *
27
+ */
28
+ static deserializeCollections(json: any): Map<string, Array<PublicationCollection>> | undefined;
29
+ /**
30
+ * Serializes a [PublicationCollection] to its RWPM JSON representation.
31
+ */
32
+ serialize(): any;
33
+ static serializeCollection(json: any, subcollections?: Map<string, Array<PublicationCollection>>): void;
34
+ }
@@ -0,0 +1,9 @@
1
+ import { Page } from './presentation/Presentation';
2
+ export declare enum ReadingProgression {
3
+ auto = "auto",
4
+ btt = "btt",
5
+ ltr = "ltr",
6
+ rtl = "rtl",
7
+ ttb = "ttb"
8
+ }
9
+ export declare function leadingPage(readingProgression: ReadingProgression): Page;
@@ -0,0 +1,56 @@
1
+ import { Links } from './Link';
2
+ import { LocalizedString } from './LocalizedString';
3
+ /**
4
+ * https://github.com/readium/webpub-manifest/tree/master/contexts/default#subjects
5
+ */
6
+ export declare class Subject {
7
+ /** Subject name. */
8
+ readonly name: LocalizedString;
9
+ /** Provides a string that a machine can sort. */
10
+ readonly sortAs?: string;
11
+ /** EPUB 3.1 opf:term. */
12
+ readonly code?: string;
13
+ /** EPUB 3.1 opf:authority. */
14
+ readonly scheme?: string;
15
+ /** PUsed to retrieve similar publications for the given subjects. */
16
+ readonly links?: Links;
17
+ /** Creates a [Subject]. */
18
+ constructor(values: {
19
+ name: LocalizedString;
20
+ sortAs?: string;
21
+ code?: string;
22
+ scheme?: string;
23
+ links?: Links;
24
+ });
25
+ /**
26
+ * Parses a [Subject] from its RWPM JSON representation.
27
+ *
28
+ * A [Subject] can be parsed from a single string, or a full-fledged object.
29
+ */
30
+ static deserialize(json: any): Subject | undefined;
31
+ /**
32
+ * Serializes a [Subject] to its RWPM JSON representation.
33
+ */
34
+ serialize(): any;
35
+ }
36
+ /**
37
+ * https://github.com/readium/webpub-manifest/blob/master/schema/subject.schema.json
38
+ *
39
+ * Collection of [Subject]
40
+ */
41
+ export declare class Subjects {
42
+ /**
43
+ * Array of [Subject] items.
44
+ */
45
+ readonly items: Array<Subject>;
46
+ /** Creates an Array of [Subject]. */
47
+ constructor(items: Array<Subject>);
48
+ /**
49
+ * Parses a [Subjects] from its RWPM JSON representation.
50
+ */
51
+ static deserialize(json: any): Subjects | undefined;
52
+ /**
53
+ * Serializes a [Subjects] to its RWPM JSON representation.
54
+ */
55
+ serialize(): any;
56
+ }
@@ -0,0 +1,33 @@
1
+ /** Indicates that a resource is encrypted/obfuscated and provides relevant information
2
+ * for decryption.
3
+ */
4
+ export declare class Encryption {
5
+ /** Identifies the algorithm used to encrypt the resource. */
6
+ readonly algorithm: string;
7
+ /** Compression method used on the resource. */
8
+ readonly compression?: string;
9
+ /** Original length of the resource in bytes before compression and/or encryption. */
10
+ readonly originalLength?: number;
11
+ /** Identifies the encryption profile used to encrypt the resource. */
12
+ readonly profile?: string;
13
+ /** Identifies the encryption scheme used to encrypt the resource. */
14
+ readonly scheme?: string;
15
+ /**
16
+ * Creates a [Encryption].
17
+ */
18
+ constructor(values: {
19
+ algorithm: string;
20
+ compression?: string;
21
+ originalLength?: number;
22
+ profile?: string;
23
+ scheme?: string;
24
+ });
25
+ /**
26
+ * Parses a [Encryption] from its RWPM JSON representation.
27
+ */
28
+ static deserialize(json: any): Encryption | undefined;
29
+ /**
30
+ * Serializes a [Encryption] to its RWPM JSON representation.
31
+ */
32
+ serialize(): any;
33
+ }
@@ -0,0 +1,10 @@
1
+ import { Encryption } from './Encryption';
2
+ declare module '../Properties' {
3
+ interface Properties {
4
+ /**
5
+ * Indicates that a resource is encrypted/obfuscated and provides relevant information for
6
+ * decryption.
7
+ */
8
+ encryption: Encryption | undefined;
9
+ }
10
+ }
@@ -0,0 +1,2 @@
1
+ export * from './Encryption';
2
+ export * from './Properties';
@@ -0,0 +1,5 @@
1
+ /** Hint about the nature of the layout for the linked resources. */
2
+ export declare enum EPUBLayout {
3
+ fixed = "fixed",
4
+ reflowable = "reflowable"
5
+ }
@@ -0,0 +1,7 @@
1
+ import { Link } from '../Link';
2
+ import { EPUBLayout } from './EPUBLayout';
3
+ declare module '../presentation/Presentation' {
4
+ interface Presentation {
5
+ layoutOf(link: Link): EPUBLayout;
6
+ }
7
+ }
@@ -0,0 +1,14 @@
1
+ import { EPUBLayout } from './EPUBLayout';
2
+ declare module '../Properties' {
3
+ interface Properties {
4
+ /**
5
+ * Identifies content contained in the linked resource, that cannot be strictly identified using a
6
+ * media type.
7
+ */
8
+ getContains(): Set<string> | undefined;
9
+ /**
10
+ * Hints how the layout of the resource should be presented.
11
+ */
12
+ getLayout(): EPUBLayout | undefined;
13
+ }
14
+ }
@@ -0,0 +1,19 @@
1
+ import { Links } from '../Link';
2
+ declare module '../Publication' {
3
+ interface Publication {
4
+ /**
5
+ * Provides navigation to positions in the Publication content that correspond to the locations of
6
+ * page boundaries present in a print source being represented by this EPUB Publication.
7
+ */
8
+ getPageList(): Links | undefined;
9
+ /**
10
+ * Identifies fundamental structural components of the publication in order to enable Reading
11
+ * Systems to provide the User efficient access to them.
12
+ */
13
+ getLandmarks(): Links | undefined;
14
+ getListOfAudioClips(): Links | undefined;
15
+ getListOfIllustrations(): Links | undefined;
16
+ getListOfTables(): Links | undefined;
17
+ getListOfVideoClips(): Links | undefined;
18
+ }
19
+ }
@@ -0,0 +1,4 @@
1
+ export * from './EPUBLayout';
2
+ export * from './Presentation';
3
+ export * from './Properties';
4
+ export * from './Publication';
@@ -0,0 +1,40 @@
1
+ import { DomRangePoint } from './DomRangePoint';
2
+ /**
3
+ * This construct enables a serializable representation of a DOM Range.
4
+ *
5
+ * In a DOM Range object, the startContainer + startOffset tuple represents the [start] boundary
6
+ * point. Similarly, the the endContainer + endOffset tuple represents the [end] boundary point.
7
+ * In both cases, the start/endContainer property is a pointer to either a DOM text node, or a DOM
8
+ * element (this typically depends on the mechanism from which the DOM Range instance originates,
9
+ * for example when obtaining the currently-selected document fragment using the `window.selection`
10
+ * API). In the case of a DOM text node, the start/endOffset corresponds to a position within the
11
+ * character data. In the case of a DOM element node, the start/endOffset corresponds to a position
12
+ * that designates a child text node.
13
+ *
14
+ * Note that [end] field is optional. When only the start field is specified, the domRange object
15
+ * represents a "collapsed" range that has identical [start] and [end] boundary points.
16
+ *
17
+ * https://github.com/readium/architecture/blob/master/models/locators/extensions/html.md#the-domrange-object
18
+ *
19
+ */
20
+ export declare class DomRange {
21
+ /** A serializable representation of the "start" boundary point of the DOM Range. */
22
+ start: DomRangePoint;
23
+ /** A serializable representation of the "end" boundary point of the DOM Range. */
24
+ end?: DomRangePoint;
25
+ /**
26
+ * Creates a [DomRange].
27
+ */
28
+ constructor(values: {
29
+ start: DomRangePoint;
30
+ end?: DomRangePoint;
31
+ });
32
+ /**
33
+ * Parses a [DomRange] from its RWPM JSON representation.
34
+ */
35
+ static deserialize(json: any): DomRange | undefined;
36
+ /**
37
+ * Serializes a [DomRange] to its RWPM JSON representation.
38
+ */
39
+ serialize(): any;
40
+ }