@readium/shared 2.1.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 +1992 -2614
- package/dist/index.umd.cjs +3 -3
- package/package.json +16 -17
- 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/PublicationCollection.ts +3 -3
- package/src/publication/Subject.ts +1 -1
- package/src/publication/opds/Properties.ts +1 -1
- package/src/util/JSONParse.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@readium/shared",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shared models to be used across other Readium projects and implementations in Typescript",
|
|
6
6
|
"author": "readium",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"types": "./types/src/index.d.ts",
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|
|
34
|
+
"types": "./types/src/index.d.ts",
|
|
34
35
|
"import": "./dist/index.js",
|
|
35
|
-
"require": "./dist/index.umd.cjs"
|
|
36
|
-
"types": "./types/src/index.d.ts"
|
|
36
|
+
"require": "./dist/index.umd.cjs"
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"files": [
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
"dev": "vite",
|
|
49
49
|
"build": "tsc && vite build",
|
|
50
50
|
"update-accessibility-locales": "node update-accessibility-locales.mjs",
|
|
51
|
-
"postinstall": "npm run update-accessibility-locales",
|
|
52
51
|
"test": "jest",
|
|
53
52
|
"size": "size-limit"
|
|
54
53
|
},
|
|
@@ -59,18 +58,18 @@
|
|
|
59
58
|
}
|
|
60
59
|
],
|
|
61
60
|
"devDependencies": {
|
|
62
|
-
"@babel/core": "^7.
|
|
63
|
-
"@babel/preset-env": "^7.
|
|
64
|
-
"@babel/preset-typescript": "^7.
|
|
65
|
-
"@size-limit/file": "^11.
|
|
66
|
-
"@types/jest": "^
|
|
67
|
-
"babel-jest": "^
|
|
68
|
-
"css-selector-generator": "^3.6.
|
|
69
|
-
"jest": "^
|
|
70
|
-
"size-limit": "^11.
|
|
71
|
-
"ts-jest": "^29.
|
|
72
|
-
"tslib": "^2.
|
|
73
|
-
"typescript": "^5.
|
|
74
|
-
"vite": "^
|
|
61
|
+
"@babel/core": "^7.28.3",
|
|
62
|
+
"@babel/preset-env": "^7.28.3",
|
|
63
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
64
|
+
"@size-limit/file": "^11.2.0",
|
|
65
|
+
"@types/jest": "^30.0.0",
|
|
66
|
+
"babel-jest": "^30.1.1",
|
|
67
|
+
"css-selector-generator": "^3.6.9",
|
|
68
|
+
"jest": "^30.1.1",
|
|
69
|
+
"size-limit": "^11.2.0",
|
|
70
|
+
"ts-jest": "^29.4.1",
|
|
71
|
+
"tslib": "^2.8.1",
|
|
72
|
+
"typescript": "^5.9.2",
|
|
73
|
+
"vite": "^7.1.5"
|
|
75
74
|
}
|
|
76
75
|
}
|
package/src/opds/Acquisition.ts
CHANGED
|
@@ -35,7 +35,7 @@ export class Acquisition {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
public static deserializeArray(json: any): Array<Acquisition> | undefined {
|
|
38
|
-
if (!(json
|
|
38
|
+
if (!(Array.isArray(json))) return;
|
|
39
39
|
return json
|
|
40
40
|
.map<Acquisition>(item => Acquisition.deserialize(item) as Acquisition)
|
|
41
41
|
.filter(x => x !== undefined);
|
|
@@ -25,7 +25,7 @@ export class BelongsTo {
|
|
|
25
25
|
* Parses a [BelongsTo] from its RWPM JSON representation.
|
|
26
26
|
*/
|
|
27
27
|
public static deserialize(json: any): BelongsTo | undefined {
|
|
28
|
-
if (!(json && json
|
|
28
|
+
if (!(json && typeof json === 'object')) return;
|
|
29
29
|
|
|
30
30
|
const items = new Map<string, Collection>();
|
|
31
31
|
Object.entries(json).forEach(([key, value]) => {
|
|
@@ -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);
|
|
@@ -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)
|
|
@@ -61,7 +61,7 @@ Properties.prototype.getIndirectAcquisitions = function():
|
|
|
61
61
|
| Array<Acquisition>
|
|
62
62
|
| undefined {
|
|
63
63
|
const json = this.otherProperties['indirectAcquisition'];
|
|
64
|
-
if (!(json && json
|
|
64
|
+
if (!(json && Array.isArray(json))) return;
|
|
65
65
|
return json
|
|
66
66
|
.map<Acquisition>(item => Acquisition.deserialize(item) as Acquisition)
|
|
67
67
|
.filter(x => x !== undefined);
|
package/src/util/JSONParse.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Parses the given array (or undefined it it's not an array) */
|
|
2
2
|
export function arrayfromJSON(json: any): Array<any> | undefined {
|
|
3
|
-
return json && json
|
|
3
|
+
return json && Array.isArray(json) ? json : undefined;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
export function arrayfromJSONorString(json: any): Array<any> | undefined {
|