@readium/shared 2.0.0 → 2.1.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 +2277 -1487
- package/dist/index.umd.cjs +3 -3
- package/package.json +17 -16
- package/src/opds/Acquisition.ts +1 -1
- package/src/publication/BelongsTo.ts +1 -1
- package/src/publication/Contributor.ts +2 -2
- package/src/publication/GuidedNavigation.ts +1 -1
- package/src/publication/Link.ts +2 -2
- package/src/publication/LocatorCollection.ts +1 -1
- package/src/publication/Metadata.ts +9 -1
- package/src/publication/PublicationCollection.ts +3 -3
- package/src/publication/Subject.ts +1 -1
- package/src/publication/accessibility/Accessibility.ts +860 -0
- package/src/publication/accessibility/AccessibilityMetadataDisplayGuide.ts +1055 -0
- package/src/publication/accessibility/Localization.md +203 -0
- package/src/publication/accessibility/Localization.ts +115 -0
- package/src/publication/accessibility/index.ts +3 -0
- package/src/publication/accessibility/locales/en.json +231 -0
- package/src/publication/accessibility/locales/fr.json +231 -0
- package/src/publication/index.ts +1 -0
- package/src/publication/opds/Properties.ts +1 -1
- package/src/util/JSONParse.ts +1 -1
- package/types/src/publication/Metadata.d.ts +3 -0
- package/types/src/publication/accessibility/Accessibility.d.ts +321 -0
- package/types/src/publication/accessibility/Localization.d.ts +8 -0
- package/types/src/publication/index.d.ts +1 -0
|
@@ -77,7 +77,7 @@ export class Contributor {
|
|
|
77
77
|
sortAs: json.sortAs,
|
|
78
78
|
identifier: json.identifier,
|
|
79
79
|
altIdentifiers: json.altIdentifier
|
|
80
|
-
? (json.altIdentifier
|
|
80
|
+
? (Array.isArray(json.altIdentifier)
|
|
81
81
|
? new Set<AltIdentifier>(json.altIdentifier
|
|
82
82
|
.map((x: string | { value: string; scheme?: string }) => AltIdentifier.deserialize(x))
|
|
83
83
|
.filter((x: AltIdentifier | undefined): x is AltIdentifier => x !== undefined))
|
|
@@ -127,7 +127,7 @@ export class Contributors {
|
|
|
127
127
|
*/
|
|
128
128
|
public static deserialize(json: any): Contributors | undefined {
|
|
129
129
|
if (!json) return;
|
|
130
|
-
const items = json
|
|
130
|
+
const items = Array.isArray(json) ? json : [json];
|
|
131
131
|
return new Contributors(
|
|
132
132
|
items
|
|
133
133
|
.map<Contributor>(item => Contributor.deserialize(item) as Contributor)
|
|
@@ -211,7 +211,7 @@ export class GuidedNavigationObject {
|
|
|
211
211
|
* Parses a [GuidedNavigationObject] array from its RWPM JSON representation.
|
|
212
212
|
*/
|
|
213
213
|
public static deserializeArray(json: any): GuidedNavigationObject[] | undefined {
|
|
214
|
-
if (!(json
|
|
214
|
+
if (!(Array.isArray(json))) return undefined;
|
|
215
215
|
return json
|
|
216
216
|
.map<GuidedNavigationObject>((item) => GuidedNavigationObject.deserialize(item) as GuidedNavigationObject)
|
|
217
217
|
.filter((x) => x !== undefined);
|
package/src/publication/Link.ts
CHANGED
|
@@ -107,7 +107,7 @@ export class Link {
|
|
|
107
107
|
type: json.type,
|
|
108
108
|
title: json.title,
|
|
109
109
|
rels: json.rel
|
|
110
|
-
? json.rel
|
|
110
|
+
? Array.isArray(json.rel)
|
|
111
111
|
? new Set<string>(json.rel as Array<string>)
|
|
112
112
|
: new Set<string>([json.rel as string])
|
|
113
113
|
: undefined,
|
|
@@ -226,7 +226,7 @@ export class Links {
|
|
|
226
226
|
* Creates a list of [Link] from its RWPM JSON representation.
|
|
227
227
|
*/
|
|
228
228
|
public static deserialize(json: any): Links | undefined {
|
|
229
|
-
if (!(json && json
|
|
229
|
+
if (!(json && Array.isArray(json))) return;
|
|
230
230
|
return new Links(
|
|
231
231
|
json
|
|
232
232
|
.map<Link>(item => Link.deserialize(item) as Link)
|
|
@@ -102,7 +102,7 @@ export class LocatorCollection {
|
|
|
102
102
|
|
|
103
103
|
let jsonList = json.locators;
|
|
104
104
|
|
|
105
|
-
if (jsonList && jsonList
|
|
105
|
+
if (jsonList && Array.isArray(jsonList)) {
|
|
106
106
|
locators = jsonList
|
|
107
107
|
.map<Locator>(x => Locator.deserialize(x) as Locator)
|
|
108
108
|
.filter(x => x !== undefined);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Copyright
|
|
1
|
+
/* Copyright 2025 Readium Foundation. All rights reserved.
|
|
2
2
|
* Use of this source code is governed by a BSD-style license,
|
|
3
3
|
* available in the LICENSE file present in the Github repository of the project.
|
|
4
4
|
*/
|
|
@@ -16,6 +16,7 @@ import { LocalizedString } from './LocalizedString';
|
|
|
16
16
|
import { Profile } from './Profiles';
|
|
17
17
|
import { ReadingProgression } from './ReadingProgression';
|
|
18
18
|
import { Subjects } from './Subject';
|
|
19
|
+
import { Accessibility } from './accessibility/Accessibility';
|
|
19
20
|
import { TDM } from './TDM';
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -59,6 +60,7 @@ export class Metadata {
|
|
|
59
60
|
public readingProgression?: ReadingProgression;
|
|
60
61
|
public duration?: number;
|
|
61
62
|
public numberOfPages?: number;
|
|
63
|
+
public accessibility?: Accessibility;
|
|
62
64
|
public tdm?: TDM;
|
|
63
65
|
public otherMetadata?: { [key: string]: any };
|
|
64
66
|
|
|
@@ -94,6 +96,7 @@ export class Metadata {
|
|
|
94
96
|
'readingProgression',
|
|
95
97
|
'duration',
|
|
96
98
|
'numberOfPages',
|
|
99
|
+
'accessibility',
|
|
97
100
|
'tdm'
|
|
98
101
|
];
|
|
99
102
|
|
|
@@ -131,6 +134,7 @@ export class Metadata {
|
|
|
131
134
|
readingProgression?: ReadingProgression;
|
|
132
135
|
duration?: number;
|
|
133
136
|
numberOfPages?: number;
|
|
137
|
+
accessibility?: Accessibility;
|
|
134
138
|
tdm?: TDM;
|
|
135
139
|
otherMetadata?: { [key: string]: any };
|
|
136
140
|
}) {
|
|
@@ -184,6 +188,7 @@ export class Metadata {
|
|
|
184
188
|
this.readingProgression = values.readingProgression;
|
|
185
189
|
this.duration = values.duration;
|
|
186
190
|
this.numberOfPages = values.numberOfPages;
|
|
191
|
+
this.accessibility = values.accessibility;
|
|
187
192
|
this.tdm = values.tdm;
|
|
188
193
|
this.otherMetadata = values.otherMetadata;
|
|
189
194
|
}
|
|
@@ -222,6 +227,7 @@ export class Metadata {
|
|
|
222
227
|
const modified = datefromJSON(json.modified);
|
|
223
228
|
const subjects = Subjects.deserialize(json.subject);
|
|
224
229
|
const belongsTo = BelongsTo.deserialize(json.belongsTo);
|
|
230
|
+
const accessibility = Accessibility.deserialize(json.accessibility);
|
|
225
231
|
const layout = json.layout;
|
|
226
232
|
const readingProgression = json.readingProgression;
|
|
227
233
|
const duration = positiveNumberfromJSON(json.duration);
|
|
@@ -265,6 +271,7 @@ export class Metadata {
|
|
|
265
271
|
readingProgression,
|
|
266
272
|
duration,
|
|
267
273
|
numberOfPages,
|
|
274
|
+
accessibility,
|
|
268
275
|
tdm,
|
|
269
276
|
otherMetadata
|
|
270
277
|
});
|
|
@@ -308,6 +315,7 @@ export class Metadata {
|
|
|
308
315
|
if (this.duration !== undefined) json.duration = this.duration;
|
|
309
316
|
if (this.numberOfPages !== undefined)
|
|
310
317
|
json.numberOfPages = this.numberOfPages;
|
|
318
|
+
if (this.accessibility) json.accessibility = this.accessibility.serialize();
|
|
311
319
|
if (this.tdm) json.tdm = this.tdm.serialize();
|
|
312
320
|
|
|
313
321
|
if (this.otherMetadata) {
|
|
@@ -39,10 +39,10 @@ export class PublicationCollection {
|
|
|
39
39
|
let metadata: Map<string, any> | undefined;
|
|
40
40
|
let subcollections: Map<string, Array<PublicationCollection>> | undefined;
|
|
41
41
|
|
|
42
|
-
if (json
|
|
42
|
+
if (Array.isArray(json)) {
|
|
43
43
|
// Parses an array of links.
|
|
44
44
|
links = Links.deserialize(json);
|
|
45
|
-
} else if (json
|
|
45
|
+
} else if (typeof json === 'object') {
|
|
46
46
|
// Parses a sub-collection object.
|
|
47
47
|
links = Links.deserialize(json.links);
|
|
48
48
|
|
|
@@ -86,7 +86,7 @@ export class PublicationCollection {
|
|
|
86
86
|
const list = new Array<PublicationCollection>();
|
|
87
87
|
list.push(collection);
|
|
88
88
|
collections.set(role, list);
|
|
89
|
-
} else if (subJSON
|
|
89
|
+
} else if (Array.isArray(subJSON)) {
|
|
90
90
|
// Parses a list of collection objects.
|
|
91
91
|
const list = subJSON
|
|
92
92
|
.map<PublicationCollection>(
|
|
@@ -98,7 +98,7 @@ export class Subjects {
|
|
|
98
98
|
*/
|
|
99
99
|
public static deserialize(json: any): Subjects | undefined {
|
|
100
100
|
if (!json) return;
|
|
101
|
-
const items = json
|
|
101
|
+
const items = Array.isArray(json) ? json : [json];
|
|
102
102
|
return new Subjects(
|
|
103
103
|
items
|
|
104
104
|
.map<Subject>(item => Subject.deserialize(item) as Subject)
|