@readium/shared 2.2.0-alpha.1 → 2.2.0-alpha.2
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 +53 -55
- package/dist/index.umd.cjs +3 -3
- package/package.json +1 -1
- package/src/publication/Manifest.ts +13 -11
- package/types/src/publication/Manifest.d.ts +1 -1
package/package.json
CHANGED
|
@@ -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;
|
|
@@ -43,7 +43,7 @@ export class Manifest {
|
|
|
43
43
|
}) {
|
|
44
44
|
this.context = values.context;
|
|
45
45
|
this.metadata = values.metadata;
|
|
46
|
-
this.links = values.links;
|
|
46
|
+
this.links = values.links || new Links([]);
|
|
47
47
|
this.readingOrder = values.readingOrder;
|
|
48
48
|
this.resources = values.resources;
|
|
49
49
|
this.toc = values.toc;
|
|
@@ -63,10 +63,6 @@ export class Manifest {
|
|
|
63
63
|
|
|
64
64
|
if (!metadata) return;
|
|
65
65
|
|
|
66
|
-
const links = Links.deserialize(json.links);
|
|
67
|
-
|
|
68
|
-
if (!links) return;
|
|
69
|
-
|
|
70
66
|
const readingOrder = Links.deserialize(
|
|
71
67
|
json.readingOrder ? json.readingOrder : json.spine
|
|
72
68
|
);
|
|
@@ -76,7 +72,7 @@ export class Manifest {
|
|
|
76
72
|
return new Manifest({
|
|
77
73
|
context: arrayfromJSONorString(json['@context']),
|
|
78
74
|
metadata,
|
|
79
|
-
links,
|
|
75
|
+
links: Links.deserialize(json.links),
|
|
80
76
|
readingOrder,
|
|
81
77
|
resources: Links.deserialize(json.resources),
|
|
82
78
|
toc: Links.deserialize(json.toc),
|
|
@@ -93,7 +89,7 @@ export class Manifest {
|
|
|
93
89
|
const json: any = {};
|
|
94
90
|
if (this.context !== undefined) json['@context'] = this.context;
|
|
95
91
|
json.metadata = this.metadata.serialize();
|
|
96
|
-
json.links = this.links.serialize();
|
|
92
|
+
if (this.links?.items.length > 0) json.links = this.links.serialize();
|
|
97
93
|
json.readingOrder = this.readingOrder.serialize();
|
|
98
94
|
if (this.resources) json.resources = this.resources.serialize();
|
|
99
95
|
if (this.toc) json.toc = this.toc.serialize();
|
|
@@ -108,7 +104,9 @@ export class Manifest {
|
|
|
108
104
|
if (this.resources) {
|
|
109
105
|
links.push(this.resources);
|
|
110
106
|
}
|
|
111
|
-
|
|
107
|
+
if(this.links) {
|
|
108
|
+
links.push(this.links);
|
|
109
|
+
}
|
|
112
110
|
|
|
113
111
|
let result: Link | undefined;
|
|
114
112
|
|
|
@@ -129,7 +127,9 @@ export class Manifest {
|
|
|
129
127
|
if (this.resources) {
|
|
130
128
|
result.push(this.resources.filterByRel(rel));
|
|
131
129
|
}
|
|
132
|
-
|
|
130
|
+
if(this.links) {
|
|
131
|
+
result.push(this.links.filterByRel(rel));
|
|
132
|
+
}
|
|
133
133
|
|
|
134
134
|
return result.reduce((acc, val) => acc.concat(val), []);
|
|
135
135
|
}
|
|
@@ -197,7 +197,9 @@ export class Manifest {
|
|
|
197
197
|
if (this.resources) {
|
|
198
198
|
links.push(this.resources);
|
|
199
199
|
}
|
|
200
|
-
|
|
200
|
+
if(this.links) {
|
|
201
|
+
links.push(this.links);
|
|
202
|
+
}
|
|
201
203
|
|
|
202
204
|
const link = find(links);
|
|
203
205
|
|