@readium/shared 2.2.0-beta.3 → 2.2.1
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.
- package/dist/index.js +391 -377
- package/dist/index.umd.cjs +3 -3
- package/package.json +1 -1
- package/src/fetcher/Fetcher.ts +2 -2
- package/src/fetcher/HttpFetcher.ts +3 -3
- package/src/fetcher/Resource.ts +1 -1
- package/src/fetcher/index.ts +3 -3
- package/src/index.ts +4 -4
- package/src/opds/Availability.ts +1 -1
- package/src/opds/Copies.ts +1 -1
- package/src/opds/Holds.ts +1 -1
- package/src/opds/Price.ts +1 -1
- package/src/opds/index.ts +5 -5
- package/src/publication/BelongsTo.ts +1 -1
- package/src/publication/Contributor.ts +4 -4
- package/src/publication/GuidedNavigation.ts +19 -19
- package/src/publication/Link.ts +6 -6
- package/src/publication/Locator.ts +1 -1
- package/src/publication/LocatorCollection.ts +4 -4
- package/src/publication/Manifest.ts +29 -20
- package/src/publication/Metadata.ts +13 -13
- package/src/publication/Publication.ts +15 -17
- package/src/publication/PublicationCollection.ts +1 -1
- package/src/publication/ReadingProgression.ts +1 -1
- package/src/publication/Subject.ts +2 -2
- package/src/publication/accessibility/AccessibilityMetadataDisplayGuide.ts +20 -20
- package/src/publication/accessibility/Localization.ts +15 -15
- package/src/publication/accessibility/index.ts +3 -3
- package/src/publication/encryption/Properties.ts +2 -2
- package/src/publication/encryption/index.ts +2 -2
- package/src/publication/epub/Metadata.ts +3 -3
- package/src/publication/epub/Properties.ts +1 -1
- package/src/publication/epub/Publication.ts +2 -2
- package/src/publication/epub/index.ts +4 -4
- package/src/publication/html/DomRange.ts +1 -1
- package/src/publication/html/DomRangePoint.ts +1 -1
- package/src/publication/html/Locations.ts +3 -3
- package/src/publication/html/index.ts +3 -3
- package/src/publication/index.ts +24 -24
- package/src/publication/opds/Properties.ts +4 -4
- package/src/publication/opds/Publication.ts +2 -2
- package/src/publication/opds/index.ts +2 -2
- package/src/publication/services/content/Content.ts +3 -3
- package/src/publication/services/content/ContentTokenizer.ts +6 -6
- package/src/publication/services/content/Iterator.ts +2 -2
- package/src/publication/services/content/element/attributes.ts +2 -2
- package/src/publication/services/content/element/element.ts +5 -5
- package/src/publication/services/content/element/index.ts +3 -3
- package/src/publication/services/content/index.ts +5 -5
- package/src/publication/services/content/iterators/HTMLResourceContentIterator.ts +8 -8
- package/src/publication/services/content/iterators/PDFTextContentIterator.ts +21 -21
- package/src/publication/services/content/iterators/PublicationContentIterator.ts +7 -7
- package/src/publication/services/content/iterators/helpers.ts +1 -1
- package/src/publication/services/content/iterators/index.ts +3 -3
- package/src/publication/services/index.ts +2 -2
- package/src/publication/services/timeline/Timeline.ts +52 -29
- package/src/publication/services/timeline/index.ts +2 -2
- package/src/util/index.ts +5 -5
- package/src/util/mediatype/index.ts +1 -1
- package/src/util/tokenizer/TextTokenizer.ts +5 -5
- package/src/util/tokenizer/index.ts +2 -2
- package/types/src/fetcher/Fetcher.d.ts +2 -2
- package/types/src/fetcher/HttpFetcher.d.ts +3 -3
- package/types/src/fetcher/Resource.d.ts +1 -1
- package/types/src/fetcher/index.d.ts +3 -3
- package/types/src/index.d.ts +4 -4
- package/types/src/opds/index.d.ts +5 -5
- package/types/src/publication/BelongsTo.d.ts +1 -1
- package/types/src/publication/Contributor.d.ts +3 -3
- package/types/src/publication/GuidedNavigation.d.ts +1 -1
- package/types/src/publication/Link.d.ts +3 -3
- package/types/src/publication/LocatorCollection.d.ts +3 -3
- package/types/src/publication/Manifest.d.ts +6 -6
- package/types/src/publication/Metadata.d.ts +10 -10
- package/types/src/publication/Publication.d.ts +12 -13
- package/types/src/publication/PublicationCollection.d.ts +1 -1
- package/types/src/publication/ReadingProgression.d.ts +1 -1
- package/types/src/publication/Subject.d.ts +2 -2
- package/types/src/publication/accessibility/AccessibilityMetadataDisplayGuide.d.ts +2 -2
- package/types/src/publication/accessibility/index.d.ts +3 -3
- package/types/src/publication/encryption/Properties.d.ts +1 -1
- package/types/src/publication/encryption/index.d.ts +2 -2
- package/types/src/publication/epub/Metadata.d.ts +1 -1
- package/types/src/publication/epub/Publication.d.ts +1 -1
- package/types/src/publication/epub/index.d.ts +4 -4
- package/types/src/publication/html/DomRange.d.ts +1 -1
- package/types/src/publication/html/Locations.d.ts +1 -1
- package/types/src/publication/html/index.d.ts +3 -3
- package/types/src/publication/index.d.ts +24 -24
- package/types/src/publication/opds/Properties.d.ts +2 -2
- package/types/src/publication/opds/Publication.d.ts +1 -1
- package/types/src/publication/opds/index.d.ts +2 -2
- package/types/src/publication/services/content/Content.d.ts +2 -2
- package/types/src/publication/services/content/ContentTokenizer.d.ts +2 -2
- package/types/src/publication/services/content/Iterator.d.ts +1 -1
- package/types/src/publication/services/content/element/attributes.d.ts +1 -1
- package/types/src/publication/services/content/element/element.d.ts +4 -4
- package/types/src/publication/services/content/element/index.d.ts +3 -3
- package/types/src/publication/services/content/index.d.ts +5 -5
- package/types/src/publication/services/content/iterators/HTMLResourceContentIterator.d.ts +4 -4
- package/types/src/publication/services/content/iterators/PDFTextContentIterator.d.ts +3 -3
- package/types/src/publication/services/content/iterators/PublicationContentIterator.d.ts +5 -5
- package/types/src/publication/services/content/iterators/helpers.d.ts +1 -1
- package/types/src/publication/services/content/iterators/index.d.ts +3 -3
- package/types/src/publication/services/index.d.ts +2 -2
- package/types/src/publication/services/timeline/Timeline.d.ts +9 -6
- package/types/src/publication/services/timeline/index.d.ts +2 -2
- package/types/src/util/index.d.ts +5 -5
- package/types/src/util/mediatype/index.d.ts +1 -1
- package/types/src/util/tokenizer/TextTokenizer.d.ts +2 -2
- package/types/src/util/tokenizer/index.d.ts +2 -2
- package/types/test/AltIdentifier.test.d.ts +0 -1
- package/types/test/Contributor.test.d.ts +0 -1
- package/types/test/GuidedNavigation.test.d.ts +0 -1
- package/types/test/Link.test.d.ts +0 -1
- package/types/test/LocalizedString.test.d.ts +0 -1
- package/types/test/Locator.test.d.ts +0 -1
- package/types/test/LocatorCollection.test.d.ts +0 -1
- package/types/test/Manifest.test.d.ts +0 -1
- package/types/test/Metadata.test.d.ts +0 -1
- package/types/test/Properties.test.d.ts +0 -1
- package/types/test/Publication.test.d.ts +0 -1
- package/types/test/PublicationCollection.test.d.ts +0 -1
- package/types/test/Subject.test.d.ts +0 -1
- package/types/test/TDM.test.d.ts +0 -1
- package/types/test/Timeline.test.d.ts +0 -1
- package/types/test/accessibility/Accessibility.test.d.ts +0 -1
- package/types/test/accessibility/AccessibilityMetadataDisplayGuide.test.d.ts +0 -1
- package/types/test/accessibility/Localization.test.d.ts +0 -1
- package/types/test/encryption/Encryption.test.d.ts +0 -1
- package/types/test/encryption/Properties.test.d.ts +0 -1
- package/types/test/epub/MediaOverlay.test.d.ts +0 -1
- package/types/test/epub/Metadata.test.d.ts +0 -1
- package/types/test/epub/PropertiesTest.test.d.ts +0 -1
- package/types/test/epub/PublicationTest.test.d.ts +0 -1
- package/types/test/html/DomRange.test.d.ts +0 -1
- package/types/test/html/Locator.test.d.ts +0 -1
- package/types/test/opds/PropertiesTest.test.d.ts +0 -1
- package/types/test/opds/PublicationTest.test.d.ts +0 -1
- package/types/test/util/URITemplate.test.d.ts +0 -1
- package/types/test/util/mediatype/MediaType.test.d.ts +0 -1
package/package.json
CHANGED
package/src/fetcher/Fetcher.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Link } from '../publication/Link';
|
|
2
|
-
import { Fetcher } from './Fetcher';
|
|
3
|
-
import { NumberRange, Resource } from './Resource';
|
|
1
|
+
import { Link } from '../publication/Link.ts';
|
|
2
|
+
import { Fetcher } from './Fetcher.ts';
|
|
3
|
+
import { NumberRange, Resource } from './Resource.ts';
|
|
4
4
|
|
|
5
5
|
export type FetchImplementation = (
|
|
6
6
|
input: RequestInfo | URL,
|
package/src/fetcher/Resource.ts
CHANGED
package/src/fetcher/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './Fetcher';
|
|
2
|
-
export * from './HttpFetcher';
|
|
3
|
-
export * from './Resource';
|
|
1
|
+
export * from './Fetcher.ts';
|
|
2
|
+
export * from './HttpFetcher.ts';
|
|
3
|
+
export * from './Resource.ts';
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './fetcher';
|
|
2
|
-
export * from './publication';
|
|
3
|
-
export * from './opds';
|
|
4
|
-
export * from './util';
|
|
1
|
+
export * from './fetcher/index.ts';
|
|
2
|
+
export * from './publication/index.ts';
|
|
3
|
+
export * from './opds/index.ts';
|
|
4
|
+
export * from './util/index.ts';
|
package/src/opds/Availability.ts
CHANGED
package/src/opds/Copies.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* available in the LICENSE file present in the Github repository of the project.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { positiveNumberfromJSON } from '../util/JSONParse';
|
|
6
|
+
import { positiveNumberfromJSON } from '../util/JSONParse.ts';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Library-specific feature that contains information about the copies that a library has acquired.
|
package/src/opds/Holds.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* available in the LICENSE file present in the Github repository of the project.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { positiveNumberfromJSON } from '../util/JSONParse';
|
|
6
|
+
import { positiveNumberfromJSON } from '../util/JSONParse.ts';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Library-specific features when a specific book is unavailable but provides a hold list.
|
package/src/opds/Price.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* available in the LICENSE file present in the Github repository of the project.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { positiveNumberfromJSON } from '../util/JSONParse';
|
|
6
|
+
import { positiveNumberfromJSON } from '../util/JSONParse.ts';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* The price of a publication in an OPDS link.
|
package/src/opds/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './Price';
|
|
2
|
-
export * from './Acquisition';
|
|
3
|
-
export * from './Holds';
|
|
4
|
-
export * from './Copies';
|
|
5
|
-
export * from './Availability';
|
|
1
|
+
export * from './Price.ts';
|
|
2
|
+
export * from './Acquisition.ts';
|
|
3
|
+
export * from './Holds.ts';
|
|
4
|
+
export * from './Copies.ts';
|
|
5
|
+
export * from './Availability.ts';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* available in the LICENSE file present in the Github repository of the project.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Contributors as Collection } from './Contributor';
|
|
6
|
+
import { Contributors as Collection } from './Contributor.ts';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* BelongsTo Object for the Readium Web Publication Manifest.
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* available in the LICENSE file present in the Github repository of the project.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Links } from './Link';
|
|
6
|
+
import { Links } from './Link.ts';
|
|
7
7
|
import {
|
|
8
8
|
arrayfromJSONorString,
|
|
9
9
|
numberfromJSON,
|
|
10
10
|
setToArray,
|
|
11
|
-
} from '../util/JSONParse';
|
|
12
|
-
import { LocalizedString } from './LocalizedString';
|
|
13
|
-
import { AltIdentifier } from './AltIdentifier';
|
|
11
|
+
} from '../util/JSONParse.ts';
|
|
12
|
+
import { LocalizedString } from './LocalizedString.ts';
|
|
13
|
+
import { AltIdentifier } from './AltIdentifier.ts';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Contributor Object for the Readium Web Publication Manifest.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
arrayfromJSONorString,
|
|
3
3
|
setToArray,
|
|
4
|
-
} from '../util/JSONParse';
|
|
5
|
-
import { Links } from "./Link";
|
|
4
|
+
} from '../util/JSONParse.ts';
|
|
5
|
+
import { Links } from "./Link.ts";
|
|
6
6
|
|
|
7
7
|
export interface Clip {
|
|
8
8
|
audioResource: string;
|
|
@@ -49,11 +49,11 @@ export class GuidedNavigationDocument {
|
|
|
49
49
|
export class GuidedNavigationText {
|
|
50
50
|
/** Plain text content */
|
|
51
51
|
public readonly plain?: string;
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
/** SSML (Speech Synthesis Markup Language) content */
|
|
54
54
|
public readonly ssml?: string;
|
|
55
|
-
|
|
56
|
-
/**
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
57
|
* BCP 47 language tag
|
|
58
58
|
* @pattern ^((?<grandfathered>(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((?<language>([A-Za-z]{2,3}(-(?<extlang>[A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-(?<script>[A-Za-z]{4}))?(-(?<region>[A-Za-z]{2}|[0-9]{3}))?(-(?<variant>[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-(?<extension>[0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(?<privateUse>x(-[A-Za-z0-9]{1,8})+))?)|(?<privateUse2>x(-[A-Za-z0-9]{1,8})+))$
|
|
59
59
|
*/
|
|
@@ -74,11 +74,11 @@ export class GuidedNavigationText {
|
|
|
74
74
|
*/
|
|
75
75
|
public static deserialize(json: any): GuidedNavigationText | undefined {
|
|
76
76
|
if (json === undefined || json === null) return undefined;
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
if (typeof json === 'string') {
|
|
79
79
|
return new GuidedNavigationText({ plain: json });
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
// Only create if there are actual values
|
|
83
83
|
if (json.plain || json.ssml || json.language) {
|
|
84
84
|
return new GuidedNavigationText({
|
|
@@ -87,7 +87,7 @@ export class GuidedNavigationText {
|
|
|
87
87
|
language: json.language
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
|
|
91
91
|
return undefined;
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -111,32 +111,32 @@ export class GuidedNavigationText {
|
|
|
111
111
|
export class GuidedNavigationObject {
|
|
112
112
|
/** References an audio resource or a fragment of it. */
|
|
113
113
|
public readonly audioref?: string;
|
|
114
|
-
|
|
114
|
+
|
|
115
115
|
/** Items that are children of the containing Guided Navigation Object. */
|
|
116
116
|
public readonly children?: GuidedNavigationObject[];
|
|
117
|
-
|
|
117
|
+
|
|
118
118
|
/** References an image or a fragment of it. */
|
|
119
119
|
public readonly imgref?: string;
|
|
120
|
-
|
|
120
|
+
|
|
121
121
|
/** Convey the structural semantics of a publication. */
|
|
122
122
|
public readonly role?: Set<string>;
|
|
123
|
-
|
|
124
|
-
/**
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
125
|
* Indicates the heading level (1-6) for the navigation object.
|
|
126
126
|
* @minimum 1
|
|
127
127
|
* @maximum 6
|
|
128
128
|
*/
|
|
129
129
|
public readonly level?: number;
|
|
130
|
-
|
|
131
|
-
/**
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
132
|
* Textual equivalent of the resources or fragment of the resources referenced by the current Guided Navigation Object.
|
|
133
133
|
*/
|
|
134
134
|
public readonly text?: GuidedNavigationText;
|
|
135
|
-
|
|
135
|
+
|
|
136
136
|
/** References a textual resource or a fragment of it. */
|
|
137
137
|
public readonly textref?: string;
|
|
138
138
|
|
|
139
|
-
/**
|
|
139
|
+
/**
|
|
140
140
|
* Describes the image referenced by the current Guided Navigation Object.
|
|
141
141
|
* This is a GuidedNavigationObject that should not contain 'level' or 'children' properties.
|
|
142
142
|
*/
|
|
@@ -192,7 +192,7 @@ export class GuidedNavigationObject {
|
|
|
192
192
|
*/
|
|
193
193
|
public static deserialize(json: any): GuidedNavigationObject | undefined {
|
|
194
194
|
if (!json) return undefined;
|
|
195
|
-
|
|
195
|
+
|
|
196
196
|
return new GuidedNavigationObject({
|
|
197
197
|
audioref: json.audioref,
|
|
198
198
|
children: GuidedNavigationObject.deserializeArray(json.children),
|
|
@@ -207,7 +207,7 @@ export class GuidedNavigationObject {
|
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
/**
|
|
210
|
+
/**
|
|
211
211
|
* Parses a [GuidedNavigationObject] array from its RWPM JSON representation.
|
|
212
212
|
*/
|
|
213
213
|
public static deserializeArray(json: any): GuidedNavigationObject[] | undefined {
|
package/src/publication/Link.ts
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
* available in the LICENSE file present in the Github repository of the project.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { MediaType } from '../util/mediatype/MediaType';
|
|
7
|
-
import { Properties } from './Properties';
|
|
8
|
-
import { URITemplate } from '../util/URITemplate';
|
|
6
|
+
import { MediaType } from '../util/mediatype/MediaType.ts';
|
|
7
|
+
import { Properties } from './Properties.ts';
|
|
8
|
+
import { URITemplate } from '../util/URITemplate.ts';
|
|
9
9
|
import {
|
|
10
10
|
arrayfromJSONorString,
|
|
11
11
|
positiveNumberfromJSON,
|
|
12
12
|
setToArray,
|
|
13
|
-
} from '../util/JSONParse';
|
|
14
|
-
import { LocatorLocations, Locator } from './Locator';
|
|
13
|
+
} from '../util/JSONParse.ts';
|
|
14
|
+
import { LocatorLocations, Locator } from './Locator.ts';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Link Object for the Readium Web Publication Manifest.
|
|
@@ -100,7 +100,7 @@ export class Link {
|
|
|
100
100
|
*/
|
|
101
101
|
public static deserialize(json: any): Link | undefined {
|
|
102
102
|
if (!json || typeof json.href !== 'string') return;
|
|
103
|
-
|
|
103
|
+
|
|
104
104
|
return new Link({
|
|
105
105
|
href: json.href,
|
|
106
106
|
templated: json.templated,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* available in the LICENSE file present in the Github repository of the project.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { arrayfromJSONorString, numberfromJSON } from '../util/JSONParse';
|
|
6
|
+
import { arrayfromJSONorString, numberfromJSON } from '../util/JSONParse.ts';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* One or more alternative expressions of the location.
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* available in the LICENSE file present in the Github repository of the project.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { numberfromJSON } from '../util/JSONParse';
|
|
7
|
-
import { Links } from './Link';
|
|
8
|
-
import { LocalizedString } from './LocalizedString';
|
|
9
|
-
import { Locator } from './Locator';
|
|
6
|
+
import { numberfromJSON } from '../util/JSONParse.ts';
|
|
7
|
+
import { Links } from './Link.ts';
|
|
8
|
+
import { LocalizedString } from './LocalizedString.ts';
|
|
9
|
+
import { Locator } from './Locator.ts';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Holds the metadata of a `LocatorCollection`.
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* available in the LICENSE file present in the Github repository of the project.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Metadata } from './Metadata';
|
|
7
|
-
import { Link, Links } from './Link';
|
|
8
|
-
import { arrayfromJSONorString } from '../util/JSONParse';
|
|
9
|
-
import { PublicationCollection } from './PublicationCollection';
|
|
10
|
-
import { MediaType } from '../util/mediatype/MediaType';
|
|
11
|
-
import { Locator, LocatorLocations } from "./Locator";
|
|
6
|
+
import { Metadata } from './Metadata.ts';
|
|
7
|
+
import { Link, Links } from './Link.ts';
|
|
8
|
+
import { arrayfromJSONorString } from '../util/JSONParse.ts';
|
|
9
|
+
import { PublicationCollection } from './PublicationCollection.ts';
|
|
10
|
+
import { MediaType } from '../util/mediatype/MediaType.ts';
|
|
11
|
+
import { Locator, LocatorLocations } from "./Locator.ts";
|
|
12
12
|
|
|
13
13
|
/** Holds the metadata of a Readium publication, as described in
|
|
14
14
|
* the Readium Web Publication Manifest.
|
|
@@ -19,7 +19,7 @@ export class Manifest {
|
|
|
19
19
|
|
|
20
20
|
public readonly metadata: Metadata;
|
|
21
21
|
|
|
22
|
-
public readonly links
|
|
22
|
+
public readonly links?: Links;
|
|
23
23
|
|
|
24
24
|
/** Identifies a list of resources in reading order for the publication. */
|
|
25
25
|
public readonly readingOrder: Links;
|
|
@@ -35,7 +35,7 @@ export class Manifest {
|
|
|
35
35
|
constructor(values: {
|
|
36
36
|
context?: Array<string>;
|
|
37
37
|
metadata: Metadata;
|
|
38
|
-
links
|
|
38
|
+
links?: Links;
|
|
39
39
|
readingOrder: Links;
|
|
40
40
|
resources?: Links;
|
|
41
41
|
toc?: Links;
|
|
@@ -65,14 +65,18 @@ export class Manifest {
|
|
|
65
65
|
|
|
66
66
|
const links = Links.deserialize(json.links);
|
|
67
67
|
|
|
68
|
-
if (!links) return;
|
|
69
|
-
|
|
70
68
|
const readingOrder = Links.deserialize(
|
|
71
69
|
json.readingOrder ? json.readingOrder : json.spine
|
|
72
70
|
);
|
|
73
71
|
|
|
74
72
|
if (!readingOrder) return;
|
|
75
73
|
|
|
74
|
+
const knownKeys = new Set(['@context', 'metadata', 'links', 'readingOrder', 'spine', 'resources', 'toc']);
|
|
75
|
+
const remaining: Record<string, unknown> = {};
|
|
76
|
+
Object.keys(json).forEach(key => {
|
|
77
|
+
if (!knownKeys.has(key)) remaining[key] = json[key];
|
|
78
|
+
});
|
|
79
|
+
|
|
76
80
|
return new Manifest({
|
|
77
81
|
context: arrayfromJSONorString(json['@context']),
|
|
78
82
|
metadata,
|
|
@@ -80,9 +84,7 @@ export class Manifest {
|
|
|
80
84
|
readingOrder,
|
|
81
85
|
resources: Links.deserialize(json.resources),
|
|
82
86
|
toc: Links.deserialize(json.toc),
|
|
83
|
-
subcollections: PublicationCollection.deserializeCollections(
|
|
84
|
-
sub: json.sub,
|
|
85
|
-
}),
|
|
87
|
+
subcollections: PublicationCollection.deserializeCollections(remaining),
|
|
86
88
|
});
|
|
87
89
|
}
|
|
88
90
|
|
|
@@ -93,7 +95,7 @@ export class Manifest {
|
|
|
93
95
|
const json: any = {};
|
|
94
96
|
if (this.context !== undefined) json['@context'] = this.context;
|
|
95
97
|
json.metadata = this.metadata.serialize();
|
|
96
|
-
json.links = this.links.serialize();
|
|
98
|
+
if (this.links !== undefined) json.links = this.links.serialize();
|
|
97
99
|
json.readingOrder = this.readingOrder.serialize();
|
|
98
100
|
if (this.resources) json.resources = this.resources.serialize();
|
|
99
101
|
if (this.toc) json.toc = this.toc.serialize();
|
|
@@ -108,7 +110,9 @@ export class Manifest {
|
|
|
108
110
|
if (this.resources) {
|
|
109
111
|
links.push(this.resources);
|
|
110
112
|
}
|
|
111
|
-
|
|
113
|
+
if (this.links) {
|
|
114
|
+
links.push(this.links);
|
|
115
|
+
}
|
|
112
116
|
|
|
113
117
|
let result: Link | undefined;
|
|
114
118
|
|
|
@@ -129,7 +133,9 @@ export class Manifest {
|
|
|
129
133
|
if (this.resources) {
|
|
130
134
|
result.push(this.resources.filterByRel(rel));
|
|
131
135
|
}
|
|
132
|
-
|
|
136
|
+
if (this.links) {
|
|
137
|
+
result.push(this.links.filterByRel(rel));
|
|
138
|
+
}
|
|
133
139
|
|
|
134
140
|
return result.reduce((acc, val) => acc.concat(val), []);
|
|
135
141
|
}
|
|
@@ -197,7 +203,9 @@ export class Manifest {
|
|
|
197
203
|
if (this.resources) {
|
|
198
204
|
links.push(this.resources);
|
|
199
205
|
}
|
|
200
|
-
|
|
206
|
+
if (this.links) {
|
|
207
|
+
links.push(this.links);
|
|
208
|
+
}
|
|
201
209
|
|
|
202
210
|
const link = find(links);
|
|
203
211
|
|
|
@@ -218,7 +226,7 @@ export class Manifest {
|
|
|
218
226
|
* e.g. https://provider.com/pub1293/manifest.json gives https://provider.com/pub1293/
|
|
219
227
|
*/
|
|
220
228
|
public get baseURL(): string | undefined {
|
|
221
|
-
const selfLink = this.links
|
|
229
|
+
const selfLink = this.links?.items.find(
|
|
222
230
|
el => el.rels && el.rels.has('self')
|
|
223
231
|
);
|
|
224
232
|
if (selfLink) {
|
|
@@ -242,10 +250,11 @@ export class Manifest {
|
|
|
242
250
|
* Sets the URL where this [Publication]'s RWPM manifest is served.
|
|
243
251
|
*/
|
|
244
252
|
public setSelfLink(href: string): void {
|
|
245
|
-
this.links.
|
|
253
|
+
if (!this.links) (this as any).links = new Links([]);
|
|
254
|
+
this.links!.items = this.links!.items.filter(
|
|
246
255
|
x => x.rels === undefined || !x.rels?.has('self')
|
|
247
256
|
);
|
|
248
|
-
this.links
|
|
257
|
+
this.links!.items.push(
|
|
249
258
|
new Link({
|
|
250
259
|
href,
|
|
251
260
|
type: MediaType.READIUM_WEBPUB_MANIFEST.string,
|
|
@@ -7,17 +7,17 @@ import {
|
|
|
7
7
|
arrayfromJSONorString,
|
|
8
8
|
datefromJSON,
|
|
9
9
|
positiveNumberfromJSON,
|
|
10
|
-
} from '../util/JSONParse';
|
|
11
|
-
import { AltIdentifier } from './AltIdentifier';
|
|
12
|
-
import { BelongsTo } from './BelongsTo';
|
|
13
|
-
import { Contributors } from './Contributor';
|
|
14
|
-
import { Layout } from './Layout';
|
|
15
|
-
import { LocalizedString } from './LocalizedString';
|
|
16
|
-
import { Profile } from './Profiles';
|
|
17
|
-
import { ReadingProgression } from './ReadingProgression';
|
|
18
|
-
import { Subjects } from './Subject';
|
|
19
|
-
import { Accessibility } from './accessibility/Accessibility';
|
|
20
|
-
import { TDM } from './TDM';
|
|
10
|
+
} from '../util/JSONParse.ts';
|
|
11
|
+
import { AltIdentifier } from './AltIdentifier.ts';
|
|
12
|
+
import { BelongsTo } from './BelongsTo.ts';
|
|
13
|
+
import { Contributors } from './Contributor.ts';
|
|
14
|
+
import { Layout } from './Layout.ts';
|
|
15
|
+
import { LocalizedString } from './LocalizedString.ts';
|
|
16
|
+
import { Profile } from './Profiles.ts';
|
|
17
|
+
import { ReadingProgression } from './ReadingProgression.ts';
|
|
18
|
+
import { Subjects } from './Subject.ts';
|
|
19
|
+
import { Accessibility } from './accessibility/Accessibility.ts';
|
|
20
|
+
import { TDM } from './TDM.ts';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* https://readium.org/webpub-manifest/schema/metadata.schema.json
|
|
@@ -328,13 +328,13 @@ export class Metadata {
|
|
|
328
328
|
|
|
329
329
|
/**
|
|
330
330
|
* Computes a [Layout] using the [conformsTo] profile and layout property.
|
|
331
|
-
*
|
|
331
|
+
*
|
|
332
332
|
* Special cases:
|
|
333
333
|
* - EPUB profile defaults to reflowable if layout is not present
|
|
334
334
|
* - Divina profile defaults to fixed if layout is not present
|
|
335
335
|
* - Layout is ignored for audiobook and PDF profiles
|
|
336
336
|
* - Layout is ignored if set to reflowable on a Divina profile
|
|
337
|
-
*
|
|
337
|
+
*
|
|
338
338
|
* Note: Stops at the first matching profile.
|
|
339
339
|
*/
|
|
340
340
|
public get effectiveLayout(): Layout | null {
|
|
@@ -3,17 +3,16 @@
|
|
|
3
3
|
* available in the LICENSE file present in the Github repository of the project.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Link, Links } from './Link';
|
|
7
|
-
import { Locator } from './Locator';
|
|
8
|
-
import { Manifest } from './Manifest';
|
|
9
|
-
import { Metadata } from './Metadata';
|
|
10
|
-
import { EmptyFetcher, Fetcher } from '../fetcher/Fetcher';
|
|
11
|
-
import { PublicationCollection } from './PublicationCollection';
|
|
12
|
-
import { Resource } from '../fetcher/Resource';
|
|
13
|
-
import { GuidedNavigationDocument } from "./GuidedNavigation";
|
|
14
|
-
import { URITemplate } from "../util";
|
|
15
|
-
import {
|
|
16
|
-
import { Timeline } from './services/timeline/Timeline';
|
|
6
|
+
import { Link, Links } from './Link.ts';
|
|
7
|
+
import { Locator } from './Locator.ts';
|
|
8
|
+
import { Manifest } from './Manifest.ts';
|
|
9
|
+
import { Metadata } from './Metadata.ts';
|
|
10
|
+
import { EmptyFetcher, Fetcher } from '../fetcher/Fetcher.ts';
|
|
11
|
+
import { PublicationCollection } from './PublicationCollection.ts';
|
|
12
|
+
import { Resource } from '../fetcher/Resource.ts';
|
|
13
|
+
import { GuidedNavigationDocument } from "./GuidedNavigation.ts";
|
|
14
|
+
import { MediaType, URITemplate } from "../util/index.ts";
|
|
15
|
+
import { Timeline } from './services/timeline/Timeline.ts';
|
|
17
16
|
|
|
18
17
|
export type ServiceFactory = () => null;
|
|
19
18
|
|
|
@@ -27,7 +26,7 @@ export class Publication {
|
|
|
27
26
|
// Shortcuts to manifest properties
|
|
28
27
|
public readonly context?: Array<string>;
|
|
29
28
|
public readonly metadata: Metadata;
|
|
30
|
-
public readonly links
|
|
29
|
+
public readonly links?: Links;
|
|
31
30
|
/** Identifies a list of resources in reading order for the publication. */
|
|
32
31
|
public readonly readingOrder: Links;
|
|
33
32
|
/** Identifies resources that are necessary for rendering the publication. */
|
|
@@ -51,8 +50,7 @@ export class Publication {
|
|
|
51
50
|
|
|
52
51
|
/**
|
|
53
52
|
* Returns the publication's timeline, built from its reading order and table of contents.
|
|
54
|
-
*
|
|
55
|
-
* with a specific configuration (e.g. a depth limit).
|
|
53
|
+
* The result is cached after the first call.
|
|
56
54
|
*/
|
|
57
55
|
public get timeline(): Timeline {
|
|
58
56
|
if (!this._timeline) this._timeline = Timeline.build(this);
|
|
@@ -95,7 +93,7 @@ export class Publication {
|
|
|
95
93
|
/**
|
|
96
94
|
* Gets the cover image for the publication.
|
|
97
95
|
* First looks for rel='cover' in links/resources/readingOrder,
|
|
98
|
-
* then falls back to any image (JPEG, PNG, GIF, AVIF, SVG)
|
|
96
|
+
* then falls back to any image (JPEG, PNG, GIF, AVIF, SVG).
|
|
99
97
|
*/
|
|
100
98
|
public getCover(): Link | undefined {
|
|
101
99
|
const locations = [
|
|
@@ -123,7 +121,7 @@ export class Publication {
|
|
|
123
121
|
}
|
|
124
122
|
|
|
125
123
|
public async positionsFromManifest(): Promise<Locator[]> {
|
|
126
|
-
const positionListLink = this.manifest.links
|
|
124
|
+
const positionListLink = this.manifest.links?.findWithMediaType(
|
|
127
125
|
'application/vnd.readium.position-list+json'
|
|
128
126
|
);
|
|
129
127
|
if (positionListLink === undefined) return [];
|
|
@@ -154,7 +152,7 @@ export class Publication {
|
|
|
154
152
|
|
|
155
153
|
if(!guidedNavigationLink) {
|
|
156
154
|
// Still unable to find a guided navigation link, try to use the manifest's global document
|
|
157
|
-
guidedNavigationLink = this.manifest.links
|
|
155
|
+
guidedNavigationLink = this.manifest.links?.findWithMediaType(
|
|
158
156
|
'application/guided-navigation+json'
|
|
159
157
|
);
|
|
160
158
|
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* available in the LICENSE file present in the Github repository of the project.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Links } from './Link';
|
|
7
|
-
import { LocalizedString } from './LocalizedString';
|
|
6
|
+
import { Links } from './Link.ts';
|
|
7
|
+
import { LocalizedString } from './LocalizedString.ts';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* https://github.com/readium/webpub-manifest/tree/master/contexts/default#subjects
|