@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/dist/index.js
CHANGED
|
@@ -214,15 +214,15 @@ const y = class y {
|
|
|
214
214
|
};
|
|
215
215
|
y.AUDITORY = new y("auditory"), y.CHART_ON_VISUAL = new y("chartOnVisual"), y.CHEM_ON_VISUAL = new y("chemOnVisual"), y.COLOR_DEPENDENT = new y("colorDependent"), y.DIAGRAM_ON_VISUAL = new y("diagramOnVisual"), y.MATH_ON_VISUAL = new y("mathOnVisual"), y.MUSIC_ON_VISUAL = new y("musicOnVisual"), y.TACTILE = new y("tactile"), y.TEXT_ON_VISUAL = new y("textOnVisual"), y.TEXTUAL = new y("textual"), y.VISUAL = new y("visual");
|
|
216
216
|
let R = y;
|
|
217
|
-
const
|
|
217
|
+
const N = class N {
|
|
218
218
|
constructor(t) {
|
|
219
219
|
if (typeof t == "string") {
|
|
220
|
-
if (!
|
|
220
|
+
if (!N.VALID_MODES.has(t.toLowerCase()))
|
|
221
221
|
return;
|
|
222
222
|
this.value = t.toLowerCase();
|
|
223
223
|
} else {
|
|
224
224
|
const e = t.filter(
|
|
225
|
-
(i) =>
|
|
225
|
+
(i) => N.VALID_MODES.has(i.toLowerCase())
|
|
226
226
|
);
|
|
227
227
|
if (e.length === 0)
|
|
228
228
|
return;
|
|
@@ -235,11 +235,11 @@ const x = class x {
|
|
|
235
235
|
static deserialize(t) {
|
|
236
236
|
if (!t) return;
|
|
237
237
|
if (typeof t == "string")
|
|
238
|
-
return new
|
|
238
|
+
return new N(t);
|
|
239
239
|
if (!Array.isArray(t)) return;
|
|
240
|
-
const e = t.filter((i) => i ?
|
|
240
|
+
const e = t.filter((i) => i ? N.VALID_MODES.has(i.toLowerCase()) : !1);
|
|
241
241
|
if (e.length !== 0)
|
|
242
|
-
return new
|
|
242
|
+
return new N(e);
|
|
243
243
|
}
|
|
244
244
|
/**
|
|
245
245
|
* Serializes a [PrimaryAccessMode] to its RWPM JSON representation.
|
|
@@ -248,8 +248,8 @@ const x = class x {
|
|
|
248
248
|
return this.value;
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
|
-
|
|
252
|
-
let It =
|
|
251
|
+
N.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]), N.AUDITORY = new N("auditory"), N.TACTILE = new N("tactile"), N.TEXTUAL = new N("textual"), N.VISUAL = new N("visual");
|
|
252
|
+
let It = N;
|
|
253
253
|
const l = class l {
|
|
254
254
|
constructor(t) {
|
|
255
255
|
this.value = t;
|
|
@@ -1066,7 +1066,7 @@ function ct(s) {
|
|
|
1066
1066
|
function K(s) {
|
|
1067
1067
|
return isNaN(s) ? void 0 : s;
|
|
1068
1068
|
}
|
|
1069
|
-
function
|
|
1069
|
+
function O(s) {
|
|
1070
1070
|
return K(s) !== void 0 && Math.sign(s) >= 0 ? s : void 0;
|
|
1071
1071
|
}
|
|
1072
1072
|
function lt(s) {
|
|
@@ -1707,14 +1707,14 @@ class U {
|
|
|
1707
1707
|
title: t.title,
|
|
1708
1708
|
rels: t.rel ? Array.isArray(t.rel) ? new Set(t.rel) : /* @__PURE__ */ new Set([t.rel]) : void 0,
|
|
1709
1709
|
properties: D.deserialize(t.properties),
|
|
1710
|
-
height:
|
|
1711
|
-
width:
|
|
1712
|
-
size:
|
|
1713
|
-
duration:
|
|
1714
|
-
bitrate:
|
|
1710
|
+
height: O(t.height),
|
|
1711
|
+
width: O(t.width),
|
|
1712
|
+
size: O(t.size),
|
|
1713
|
+
duration: O(t.duration),
|
|
1714
|
+
bitrate: O(t.bitrate),
|
|
1715
1715
|
languages: F(t.language),
|
|
1716
|
-
alternates:
|
|
1717
|
-
children:
|
|
1716
|
+
alternates: x.deserialize(t.alternate),
|
|
1717
|
+
children: x.deserialize(t.children)
|
|
1718
1718
|
});
|
|
1719
1719
|
}
|
|
1720
1720
|
/**
|
|
@@ -1772,7 +1772,7 @@ class U {
|
|
|
1772
1772
|
});
|
|
1773
1773
|
}
|
|
1774
1774
|
}
|
|
1775
|
-
class
|
|
1775
|
+
class x {
|
|
1776
1776
|
/**
|
|
1777
1777
|
* Creates a [Links].
|
|
1778
1778
|
*/
|
|
@@ -1784,7 +1784,7 @@ class O {
|
|
|
1784
1784
|
*/
|
|
1785
1785
|
static deserialize(t) {
|
|
1786
1786
|
if (t && Array.isArray(t))
|
|
1787
|
-
return new
|
|
1787
|
+
return new x(
|
|
1788
1788
|
t.map((e) => U.deserialize(e)).filter((e) => e !== void 0)
|
|
1789
1789
|
);
|
|
1790
1790
|
}
|
|
@@ -1937,7 +1937,7 @@ class ut {
|
|
|
1937
1937
|
identifier: t.identifier,
|
|
1938
1938
|
altIdentifiers: t.altIdentifier ? Array.isArray(t.altIdentifier) ? new Set(t.altIdentifier.map((e) => Z.deserialize(e)).filter((e) => e !== void 0)) : new Set([Z.deserialize(t.altIdentifier)].filter((e) => e !== void 0)) : void 0,
|
|
1939
1939
|
roles: t.role ? new Set(F(t.role)) : void 0,
|
|
1940
|
-
links:
|
|
1940
|
+
links: x.deserialize(t.links),
|
|
1941
1941
|
position: K(t.position)
|
|
1942
1942
|
}) : void 0;
|
|
1943
1943
|
}
|
|
@@ -1949,7 +1949,7 @@ class ut {
|
|
|
1949
1949
|
return this.sortAs !== void 0 && (t.sortAs = this.sortAs.serialize()), this.identifier !== void 0 && (t.identifier = this.identifier), this.altIdentifiers && (t.altIdentifier = lt(this.altIdentifiers).map((e) => e.serialize())), this.roles && (t.role = lt(this.roles)), this.links && (t.links = this.links.serialize()), this.position !== void 0 && (t.position = this.position), t;
|
|
1950
1950
|
}
|
|
1951
1951
|
}
|
|
1952
|
-
class
|
|
1952
|
+
class L {
|
|
1953
1953
|
/**
|
|
1954
1954
|
* Creates a [Contributors] object.
|
|
1955
1955
|
*/
|
|
@@ -1963,7 +1963,7 @@ class N {
|
|
|
1963
1963
|
static deserialize(t) {
|
|
1964
1964
|
if (!t) return;
|
|
1965
1965
|
const e = Array.isArray(t) ? t : [t];
|
|
1966
|
-
return new
|
|
1966
|
+
return new L(
|
|
1967
1967
|
e.map((i) => ut.deserialize(i)).filter((i) => i !== void 0)
|
|
1968
1968
|
);
|
|
1969
1969
|
}
|
|
@@ -1986,7 +1986,7 @@ class q {
|
|
|
1986
1986
|
if (!(t && typeof t == "object")) return;
|
|
1987
1987
|
const e = /* @__PURE__ */ new Map();
|
|
1988
1988
|
return Object.entries(t).forEach(([i, r]) => {
|
|
1989
|
-
const n =
|
|
1989
|
+
const n = L.deserialize(r);
|
|
1990
1990
|
n && n.items.length > 0 && e.set(i, n);
|
|
1991
1991
|
}), new q({ items: e });
|
|
1992
1992
|
}
|
|
@@ -2023,7 +2023,7 @@ class dt {
|
|
|
2023
2023
|
sortAs: t.sortAs ? M.deserialize(t.sortAs) : void 0,
|
|
2024
2024
|
code: t.code,
|
|
2025
2025
|
scheme: t.scheme,
|
|
2026
|
-
links:
|
|
2026
|
+
links: x.deserialize(t.links)
|
|
2027
2027
|
}) : void 0;
|
|
2028
2028
|
}
|
|
2029
2029
|
/**
|
|
@@ -2092,7 +2092,7 @@ const tt = class tt {
|
|
|
2092
2092
|
*/
|
|
2093
2093
|
static deserialize(t) {
|
|
2094
2094
|
if (!(t && t.title)) return;
|
|
2095
|
-
const e = M.deserialize(t.title), i = t["@type"], r = F(t.conformsTo), n = t.identifier, a = Z.deserialize(t.altIdentifier), o = M.deserialize(t.subtitle), h = M.deserialize(t.sortAs), m =
|
|
2095
|
+
const e = M.deserialize(t.title), i = t["@type"], r = F(t.conformsTo), n = t.identifier, a = Z.deserialize(t.altIdentifier), o = M.deserialize(t.subtitle), h = M.deserialize(t.sortAs), m = L.deserialize(t.artist), p = L.deserialize(t.author), u = L.deserialize(t.colorist), g = L.deserialize(t.contributor), v = L.deserialize(t.editor), C = L.deserialize(t.illustrator), d = L.deserialize(t.inker), I = L.deserialize(t.letterer), B = L.deserialize(t.narrator), Me = L.deserialize(t.penciler), Be = L.deserialize(t.translator), Ge = F(t.language), We = t.description, He = L.deserialize(t.publisher), Fe = L.deserialize(t.imprint), _e = ct(t.published), Ve = ct(t.modified), Ye = Vt.deserialize(t.subject), $e = q.deserialize(t.belongsTo), Xe = _.deserialize(t.accessibility), Ke = t.layout, Ze = t.readingProgression, Je = O(t.duration), qe = O(t.numberOfPages), Qe = Yt.deserialize(t.tdm);
|
|
2096
2096
|
let at = Object.assign({}, t);
|
|
2097
2097
|
return tt.mappedProperties.forEach((je) => delete at[je]), Object.keys(at).length === 0 && (at = void 0), new tt({
|
|
2098
2098
|
title: e,
|
|
@@ -2242,7 +2242,7 @@ class $t {
|
|
|
2242
2242
|
static deserialize(t) {
|
|
2243
2243
|
if (t)
|
|
2244
2244
|
return new $t({
|
|
2245
|
-
links:
|
|
2245
|
+
links: x.deserialize(t.links),
|
|
2246
2246
|
guided: X.deserializeArray(t.guided)
|
|
2247
2247
|
});
|
|
2248
2248
|
}
|
|
@@ -2907,10 +2907,10 @@ class mt {
|
|
|
2907
2907
|
*/
|
|
2908
2908
|
static deserialize(t) {
|
|
2909
2909
|
if (!(t && t.cssSelector)) return;
|
|
2910
|
-
let e =
|
|
2910
|
+
let e = O(t.textNodeIndex);
|
|
2911
2911
|
if (e === void 0) return;
|
|
2912
|
-
let i =
|
|
2913
|
-
return i === void 0 && (i =
|
|
2912
|
+
let i = O(t.charOffset);
|
|
2913
|
+
return i === void 0 && (i = O(t.offset)), new mt({
|
|
2914
2914
|
cssSelector: t.cssSelector,
|
|
2915
2915
|
textNodeIndex: e,
|
|
2916
2916
|
charOffset: i
|
|
@@ -3012,7 +3012,7 @@ class Kt {
|
|
|
3012
3012
|
let e = t.currency;
|
|
3013
3013
|
if (!(e && typeof e == "string" && e.length > 0))
|
|
3014
3014
|
return;
|
|
3015
|
-
let i =
|
|
3015
|
+
let i = O(t.value);
|
|
3016
3016
|
if (i !== void 0)
|
|
3017
3017
|
return new Kt({ currency: e, value: i });
|
|
3018
3018
|
}
|
|
@@ -3061,8 +3061,8 @@ class Zt {
|
|
|
3061
3061
|
static deserialize(t) {
|
|
3062
3062
|
if (t)
|
|
3063
3063
|
return new Zt({
|
|
3064
|
-
total:
|
|
3065
|
-
position:
|
|
3064
|
+
total: O(t.total),
|
|
3065
|
+
position: O(t.position)
|
|
3066
3066
|
});
|
|
3067
3067
|
}
|
|
3068
3068
|
/**
|
|
@@ -3084,8 +3084,8 @@ class Jt {
|
|
|
3084
3084
|
static deserialize(t) {
|
|
3085
3085
|
if (t)
|
|
3086
3086
|
return new Jt({
|
|
3087
|
-
total:
|
|
3088
|
-
available:
|
|
3087
|
+
total: O(t.total),
|
|
3088
|
+
available: O(t.available)
|
|
3089
3089
|
});
|
|
3090
3090
|
}
|
|
3091
3091
|
/**
|
|
@@ -3122,7 +3122,7 @@ class qt {
|
|
|
3122
3122
|
}
|
|
3123
3123
|
}
|
|
3124
3124
|
D.prototype.getNumberOfItems = function() {
|
|
3125
|
-
return
|
|
3125
|
+
return O(this.otherProperties.numberOfItems);
|
|
3126
3126
|
};
|
|
3127
3127
|
D.prototype.getPrice = function() {
|
|
3128
3128
|
return Kt.deserialize(this.otherProperties.price);
|
|
@@ -4277,7 +4277,7 @@ class js {
|
|
|
4277
4277
|
h.length > 0 && (o = new U({
|
|
4278
4278
|
href: h[0].href,
|
|
4279
4279
|
type: h[0].type,
|
|
4280
|
-
alternates: h.length > 1 ? new
|
|
4280
|
+
alternates: h.length > 1 ? new x(h.slice(1)) : void 0
|
|
4281
4281
|
}));
|
|
4282
4282
|
}
|
|
4283
4283
|
o && (r === "AUDIO" ? this.elementRecipes.push({
|
|
@@ -4402,7 +4402,7 @@ class De {
|
|
|
4402
4402
|
* Creates a [LocatorCollection].
|
|
4403
4403
|
*/
|
|
4404
4404
|
constructor(t) {
|
|
4405
|
-
this.metadata = t.metadata ?? new At({}), this.links = t.links ?? new
|
|
4405
|
+
this.metadata = t.metadata ?? new At({}), this.links = t.links ?? new x([]), this.locators = t.locators ?? [];
|
|
4406
4406
|
}
|
|
4407
4407
|
/**
|
|
4408
4408
|
* Parses a [LocatorCollection] from its RWPM JSON representation.
|
|
@@ -4412,7 +4412,7 @@ class De {
|
|
|
4412
4412
|
let e, i = t.locators;
|
|
4413
4413
|
return i && Array.isArray(i) && (e = i.map((r) => k.deserialize(r)).filter((r) => r !== void 0)), new De({
|
|
4414
4414
|
metadata: At.deserialize(t.metadata),
|
|
4415
|
-
links:
|
|
4415
|
+
links: x.deserialize(t.links),
|
|
4416
4416
|
locators: e
|
|
4417
4417
|
});
|
|
4418
4418
|
}
|
|
@@ -4442,9 +4442,9 @@ class W {
|
|
|
4442
4442
|
if (!t) return;
|
|
4443
4443
|
let e, i, r;
|
|
4444
4444
|
if (Array.isArray(t))
|
|
4445
|
-
e =
|
|
4445
|
+
e = x.deserialize(t);
|
|
4446
4446
|
else if (typeof t == "object")
|
|
4447
|
-
e =
|
|
4447
|
+
e = x.deserialize(t.links), i = /* @__PURE__ */ new Map(), t.metadata && Object.entries(t.metadata).forEach(([n, a]) => {
|
|
4448
4448
|
i?.set(n, a);
|
|
4449
4449
|
}), r = W.deserializeCollections(t);
|
|
4450
4450
|
else
|
|
@@ -4497,7 +4497,7 @@ class W {
|
|
|
4497
4497
|
}
|
|
4498
4498
|
class Ue {
|
|
4499
4499
|
constructor(t) {
|
|
4500
|
-
this.context = t.context, this.metadata = t.metadata, this.links = t.links, this.readingOrder = t.readingOrder, this.resources = t.resources, this.toc = t.toc, this.subcollections = t.subcollections;
|
|
4500
|
+
this.context = t.context, this.metadata = t.metadata, this.links = t.links || new x([]), this.readingOrder = t.readingOrder, this.resources = t.resources, this.toc = t.toc, this.subcollections = t.subcollections;
|
|
4501
4501
|
}
|
|
4502
4502
|
/**
|
|
4503
4503
|
* Parses a [Publication] from its RWPM JSON representation.
|
|
@@ -4509,19 +4509,17 @@ class Ue {
|
|
|
4509
4509
|
if (!t) return;
|
|
4510
4510
|
const e = ft.deserialize(t.metadata);
|
|
4511
4511
|
if (!e) return;
|
|
4512
|
-
const i =
|
|
4513
|
-
if (!i) return;
|
|
4514
|
-
const r = O.deserialize(
|
|
4512
|
+
const i = x.deserialize(
|
|
4515
4513
|
t.readingOrder ? t.readingOrder : t.spine
|
|
4516
4514
|
);
|
|
4517
|
-
if (
|
|
4515
|
+
if (i)
|
|
4518
4516
|
return new Ue({
|
|
4519
4517
|
context: F(t["@context"]),
|
|
4520
4518
|
metadata: e,
|
|
4521
|
-
links:
|
|
4522
|
-
readingOrder:
|
|
4523
|
-
resources:
|
|
4524
|
-
toc:
|
|
4519
|
+
links: x.deserialize(t.links),
|
|
4520
|
+
readingOrder: i,
|
|
4521
|
+
resources: x.deserialize(t.resources),
|
|
4522
|
+
toc: x.deserialize(t.toc),
|
|
4525
4523
|
subcollections: W.deserializeCollections({
|
|
4526
4524
|
sub: t.sub
|
|
4527
4525
|
})
|
|
@@ -4532,12 +4530,12 @@ class Ue {
|
|
|
4532
4530
|
*/
|
|
4533
4531
|
serialize() {
|
|
4534
4532
|
const t = {};
|
|
4535
|
-
return this.context !== void 0 && (t["@context"] = this.context), t.metadata = this.metadata.serialize(), t.links = this.links.serialize(), t.readingOrder = this.readingOrder.serialize(), this.resources && (t.resources = this.resources.serialize()), this.toc && (t.toc = this.toc.serialize()), W.serializeCollection(t, this.subcollections), t;
|
|
4533
|
+
return this.context !== void 0 && (t["@context"] = this.context), t.metadata = this.metadata.serialize(), this.links?.items.length > 0 && (t.links = this.links.serialize()), t.readingOrder = this.readingOrder.serialize(), this.resources && (t.resources = this.resources.serialize()), this.toc && (t.toc = this.toc.serialize()), W.serializeCollection(t, this.subcollections), t;
|
|
4536
4534
|
}
|
|
4537
4535
|
/** Finds the first link with the given relation in the manifest's links. */
|
|
4538
4536
|
linkWithRel(t) {
|
|
4539
4537
|
const e = new Array();
|
|
4540
|
-
e.push(this.readingOrder), this.resources && e.push(this.resources), e.push(this.links);
|
|
4538
|
+
e.push(this.readingOrder), this.resources && e.push(this.resources), this.links && e.push(this.links);
|
|
4541
4539
|
let i;
|
|
4542
4540
|
for (const r of e)
|
|
4543
4541
|
if (i = r.findWithRel(t), i !== void 0)
|
|
@@ -4547,7 +4545,7 @@ class Ue {
|
|
|
4547
4545
|
/** Finds all the links with the given relation in the manifest's links. */
|
|
4548
4546
|
linksWithRel(t) {
|
|
4549
4547
|
const e = [];
|
|
4550
|
-
return e.push(this.readingOrder.filterByRel(t)), this.resources && e.push(this.resources.filterByRel(t)), e.push(this.links.filterByRel(t)), e.reduce((i, r) => i.concat(r), []);
|
|
4548
|
+
return e.push(this.readingOrder.filterByRel(t)), this.resources && e.push(this.resources.filterByRel(t)), this.links && e.push(this.links.filterByRel(t)), e.reduce((i, r) => i.concat(r), []);
|
|
4551
4549
|
}
|
|
4552
4550
|
/**
|
|
4553
4551
|
* Creates a new [Locator] object from a [Link] to a resource of this manifest.
|
|
@@ -4584,7 +4582,7 @@ class Ue {
|
|
|
4584
4582
|
m.push(...u);
|
|
4585
4583
|
}), m.length > 0 && (h = e(m)), h;
|
|
4586
4584
|
}, i = [];
|
|
4587
|
-
i.push(this.readingOrder), this.resources && i.push(this.resources), i.push(this.links);
|
|
4585
|
+
i.push(this.readingOrder), this.resources && i.push(this.resources), this.links && i.push(this.links);
|
|
4588
4586
|
const r = e(i);
|
|
4589
4587
|
if (r !== void 0)
|
|
4590
4588
|
return r;
|
|
@@ -4646,7 +4644,7 @@ export {
|
|
|
4646
4644
|
nr as Content,
|
|
4647
4645
|
me as ContentElement,
|
|
4648
4646
|
ut as Contributor,
|
|
4649
|
-
|
|
4647
|
+
L as Contributors,
|
|
4650
4648
|
Jt as Copies,
|
|
4651
4649
|
Ri as DefaultTextContentTokenizer,
|
|
4652
4650
|
Xt as DomRange,
|
|
@@ -4674,7 +4672,7 @@ export {
|
|
|
4674
4672
|
$ as Layout,
|
|
4675
4673
|
Wt as Legal,
|
|
4676
4674
|
U as Link,
|
|
4677
|
-
|
|
4675
|
+
x as Links,
|
|
4678
4676
|
f as Localization,
|
|
4679
4677
|
M as LocalizedString,
|
|
4680
4678
|
k as Locator,
|
|
@@ -4724,7 +4722,7 @@ export {
|
|
|
4724
4722
|
ct as datefromJSON,
|
|
4725
4723
|
rr as leadingPage,
|
|
4726
4724
|
K as numberfromJSON,
|
|
4727
|
-
|
|
4725
|
+
O as positiveNumberfromJSON,
|
|
4728
4726
|
lt as setToArray,
|
|
4729
4727
|
fe as speakableToken
|
|
4730
4728
|
};
|