cozy-iiif 0.8.1 → 0.9.0
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/{core-BHFaVC33.js → core-CbKbxI1_.js} +3 -3
- package/dist/helpers/index.d.ts +0 -1
- package/dist/helpers/index.js +29 -44
- package/dist/index.js +160 -152
- package/dist/level-0/index.js +2 -2
- package/dist/types.d.ts +7 -2
- package/package.json +5 -5
- package/src/Cozy.ts +27 -15
- package/src/helpers/index.ts +0 -1
- package/src/types.ts +7 -2
- package/test/Cozy.test.ts +14 -1
- package/test/fixtures.ts +3 -0
- package/dist/helpers/hydrate.d.ts +0 -2
- package/src/helpers/hydrate.ts +0 -25
- /package/dist/{p-throttle-DZE1ty58.js → p-throttle-Hk6Snhzm.js} +0 -0
|
@@ -38,7 +38,7 @@ function o(e) {
|
|
|
38
38
|
return e;
|
|
39
39
|
}
|
|
40
40
|
//#endregion
|
|
41
|
-
//#region node_modules/@iiif/parser/dist/traverse-
|
|
41
|
+
//#region node_modules/@iiif/parser/dist/traverse-Qcu6-SJ2.js
|
|
42
42
|
function s(e) {
|
|
43
43
|
return typeof e == "string" ? !1 : e && !e.type && "source" in e ? (e.type = "SpecificResource", !0) : !!e && e.type === "SpecificResource";
|
|
44
44
|
}
|
|
@@ -115,7 +115,7 @@ var d = class e {
|
|
|
115
115
|
return e.thumbnail &&= a(e.thumbnail).map((t) => this.traverseType(t, { parent: e }, this.traversals.contentResource)), e.provider &&= e.provider.map((t) => this.traverseAgent(t, e)), e;
|
|
116
116
|
}
|
|
117
117
|
traverseLinking(e) {
|
|
118
|
-
return e.seeAlso &&= a(e.seeAlso).map((t) => this.traverseType(t, { parent: e }, this.traversals.contentResource)), e.service &&= a(e.service).map((e) => this.traverseService(e)), e.services &&= a(e.services).map((t) => this.traverseService(t, e)), e.logo &&= a(e.logo).map((t) => this.traverseType(t, { parent: e }, this.traversals.contentResource)), e.homepage &&= a(e.homepage).map((t) => this.
|
|
118
|
+
return e.seeAlso &&= a(e.seeAlso).map((t) => this.traverseType(t, { parent: e }, this.traversals.contentResource)), e.service &&= a(e.service).map((e) => this.traverseService(e)), e.services &&= a(e.services).map((t) => this.traverseService(t, e)), e.logo &&= a(e.logo).map((t) => this.traverseType(t, { parent: e }, this.traversals.contentResource)), e.homepage &&= a(e.homepage).map((t) => this.traverseContentResource(t, e)), e.partOf &&= e.partOf.map((t) => typeof t == "string" || !t.type ? this.traverseType(t, { parent: e }, this.traversals.contentResource) : t.type === "Canvas" ? this.traverseType(t, { parent: e }, this.traversals.canvas) : t.type === "AnnotationCollection" ? this.traverseType(t, { parent: e }, this.traversals.annotationCollection) : t.type === "Collection" ? this.traverseType(t, { parent: e }, this.traversals.collection) : this.traverseType(t, { parent: e }, this.traversals.contentResource)), e.start && (s(e.start) ? e.start = this.traverseSpecificResource(e.start, "Canvas", e) : e.start = this.traverseType(e.start, { parent: e }, this.traversals.canvas)), e.rendering &&= e.rendering.map((t) => this.traverseType(t, { parent: e }, this.traversals.contentResource)), e.supplementary &&= e.supplementary.map((t) => this.traverseType(t, { parent: e }, this.traversals.contentResource)), e;
|
|
119
119
|
}
|
|
120
120
|
traverseCollectionItems(e) {
|
|
121
121
|
return e.items && e.items.map((e) => e.type === "Collection" ? this.traverseCollection(e) : this.traverseManifest(e)), e;
|
|
@@ -166,7 +166,7 @@ var d = class e {
|
|
|
166
166
|
return typeof e == "string" || !e || e && e.service && (e.service = a(e.service || []).map((t) => this.traverseService(t, e))), e;
|
|
167
167
|
}
|
|
168
168
|
traverseContentResource(e, t) {
|
|
169
|
-
return e.type === "Choice" && (e.items = e.items.map((t) => this.traverseContentResource(t, e))), s(e) ? this.traverseSpecificResource(e, "ContentResource") : this.traverseType(this.traverseInlineAnnotationPages(this.traverseContentResourceLinking(e)), { parent: t }, this.traversals.contentResource);
|
|
169
|
+
return e.type === "Choice" && (e.items = e.items.map((t) => this.traverseContentResource(t, e))), s(e) ? this.traverseSpecificResource(e, "ContentResource") : this.traverseType(this.traverseInlineAnnotationPages(this.traverseContentResourceLinking(this.traverseDescriptive(e))), { parent: t }, this.traversals.contentResource);
|
|
170
170
|
}
|
|
171
171
|
traverseSpecificResource(e, t, n) {
|
|
172
172
|
let r = e.source;
|
package/dist/helpers/index.d.ts
CHANGED
package/dist/helpers/index.js
CHANGED
|
@@ -1,67 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as i } from "../p-throttle-DZE1ty58.js";
|
|
1
|
+
import { t as e } from "../p-throttle-Hk6Snhzm.js";
|
|
3
2
|
//#region src/helpers/fetch-annotations.ts
|
|
4
|
-
var
|
|
3
|
+
var t = e({
|
|
5
4
|
limit: 4,
|
|
6
5
|
interval: 1e3
|
|
7
|
-
}),
|
|
6
|
+
}), n = (e, n) => {
|
|
8
7
|
if (e.items) return Promise.resolve(e.items);
|
|
9
8
|
if (e.partOf) {
|
|
10
|
-
let
|
|
11
|
-
let
|
|
12
|
-
return e.next ?
|
|
9
|
+
let i = t((e, t = []) => fetch(e).then((e) => e.json()).then((e) => {
|
|
10
|
+
let n = [...t, ...e.items || []];
|
|
11
|
+
return e.next ? i(e.next, n) : n;
|
|
13
12
|
}));
|
|
14
13
|
if (!Array.isArray(e.partOf)) throw Error("Referenced annotation collection is invalid");
|
|
15
|
-
return e.partOf.length === 0 ? (console.warn("Annotation page references 0 collections"), Promise.resolve([])) : e.partOf.reduce((e, t) => e.then((e) => typeof t.first == "string" ?
|
|
16
|
-
} else return fetch(e.id).then((e) => e.json()).then((e) => (e.items || []).filter((e) =>
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
id: a.id,
|
|
22
|
-
width: a.width,
|
|
23
|
-
height: a.height,
|
|
24
|
-
images: o,
|
|
25
|
-
annotations: a.annotations || [],
|
|
26
|
-
getImageURL: o.length > 0 ? o[0].getImageURL : () => void 0,
|
|
27
|
-
getLabel: n(a),
|
|
28
|
-
getMetadata: e(a),
|
|
29
|
-
getThumbnailURL: r(a, o)
|
|
30
|
-
};
|
|
31
|
-
}, u = [];
|
|
32
|
-
for (let e = 0; e < 256; ++e) u.push((e + 256).toString(16).slice(1));
|
|
33
|
-
function d(e, t = 0) {
|
|
34
|
-
return (u[e[t + 0]] + u[e[t + 1]] + u[e[t + 2]] + u[e[t + 3]] + "-" + u[e[t + 4]] + u[e[t + 5]] + "-" + u[e[t + 6]] + u[e[t + 7]] + "-" + u[e[t + 8]] + u[e[t + 9]] + "-" + u[e[t + 10]] + u[e[t + 11]] + u[e[t + 12]] + u[e[t + 13]] + u[e[t + 14]] + u[e[t + 15]]).toLowerCase();
|
|
14
|
+
return e.partOf.length === 0 ? (console.warn("Annotation page references 0 collections"), Promise.resolve([])) : e.partOf.reduce((e, t) => e.then((e) => typeof t.first == "string" ? i(t.first).then((t) => [...e, ...t]) : (console.warn("Unsupported `first` arg", t.first), e)), Promise.resolve([])).then((e) => e.filter((e) => r(e, n)));
|
|
15
|
+
} else return fetch(e.id).then((e) => e.json()).then((e) => (e.items || []).filter((e) => r(e, n))).catch((t) => (console.error(t), console.warn(`Could not resolve referenced annotation page: ${e.id}`), []));
|
|
16
|
+
}, r = (e, t) => !t || !e.target ? !0 : (Array.isArray(e.target) ? e.target : [e.target]).some((e) => "source" in e ? typeof e.source == "string" ? e.source === t : e.source.id === t : !0), i = (e) => "type" in e && e.type === "AnnotationPage" ? n(e) : e.annotations.reduce((t, r) => t.then((t) => n(r, e.id).then((e) => [...t, ...e])), Promise.resolve([])), a = [];
|
|
17
|
+
for (let e = 0; e < 256; ++e) a.push((e + 256).toString(16).slice(1));
|
|
18
|
+
function o(e, t = 0) {
|
|
19
|
+
return (a[e[t + 0]] + a[e[t + 1]] + a[e[t + 2]] + a[e[t + 3]] + "-" + a[e[t + 4]] + a[e[t + 5]] + "-" + a[e[t + 6]] + a[e[t + 7]] + "-" + a[e[t + 8]] + a[e[t + 9]] + "-" + a[e[t + 10]] + a[e[t + 11]] + a[e[t + 12]] + a[e[t + 13]] + a[e[t + 14]] + a[e[t + 15]]).toLowerCase();
|
|
35
20
|
}
|
|
36
21
|
//#endregion
|
|
37
22
|
//#region node_modules/uuid/dist/rng.js
|
|
38
|
-
var
|
|
39
|
-
function
|
|
40
|
-
return crypto.getRandomValues(
|
|
23
|
+
var s = /* @__PURE__ */ new Uint8Array(16);
|
|
24
|
+
function c() {
|
|
25
|
+
return crypto.getRandomValues(s);
|
|
41
26
|
}
|
|
42
27
|
//#endregion
|
|
43
28
|
//#region node_modules/uuid/dist/v4.js
|
|
44
|
-
function
|
|
45
|
-
return !t && !e && crypto.randomUUID ? crypto.randomUUID() :
|
|
29
|
+
function l(e, t, n) {
|
|
30
|
+
return !t && !e && crypto.randomUUID ? crypto.randomUUID() : u(e, t, n);
|
|
46
31
|
}
|
|
47
|
-
function
|
|
32
|
+
function u(e, t, n) {
|
|
48
33
|
e ||= {};
|
|
49
|
-
let r = e.random ?? e.rng?.() ??
|
|
34
|
+
let r = e.random ?? e.rng?.() ?? c();
|
|
50
35
|
if (r.length < 16) throw Error("Random bytes length must be >= 16");
|
|
51
36
|
if (r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, t) {
|
|
52
37
|
if (n ||= 0, n < 0 || n + 16 > t.length) throw RangeError(`UUID byte range ${n}:${n + 15} is out of buffer bounds`);
|
|
53
38
|
for (let e = 0; e < 16; ++e) t[n + e] = r[e];
|
|
54
39
|
return t;
|
|
55
40
|
}
|
|
56
|
-
return
|
|
41
|
+
return o(r);
|
|
57
42
|
}
|
|
58
43
|
//#endregion
|
|
59
44
|
//#region src/helpers/import-annotations.ts
|
|
60
|
-
var
|
|
45
|
+
var d = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = (e, t) => {
|
|
61
46
|
if (t) {
|
|
62
47
|
let n = e.annotations;
|
|
63
48
|
if (n.length > 0) {
|
|
64
|
-
let r = RegExp(`${
|
|
49
|
+
let r = RegExp(`${d(e.id)}/${d(t)}/page/p(\\d+)$`), i = n.reduce((e, t) => {
|
|
65
50
|
let n = t.id.match(r);
|
|
66
51
|
if (n && n[1]) {
|
|
67
52
|
let t = parseInt(n[1]);
|
|
@@ -70,10 +55,10 @@ var g = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), _ = (e, t) => {
|
|
|
70
55
|
}, 1);
|
|
71
56
|
return `${e.id}/${t}/annotations/page/p${i}`;
|
|
72
57
|
} else return `${e.id}/${t}/annotations/page/p1`;
|
|
73
|
-
} else return `${e.id}/annotations/page/${
|
|
74
|
-
},
|
|
58
|
+
} else return `${e.id}/annotations/page/${l()}`;
|
|
59
|
+
}, p = (e, t, n) => {
|
|
75
60
|
let r = {
|
|
76
|
-
id:
|
|
61
|
+
id: f(e, n),
|
|
77
62
|
type: "AnnotationPage",
|
|
78
63
|
items: t
|
|
79
64
|
};
|
|
@@ -91,7 +76,7 @@ var g = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), _ = (e, t) => {
|
|
|
91
76
|
getMetadata: e.getMetadata,
|
|
92
77
|
getThumbnailURL: e.getThumbnailURL
|
|
93
78
|
};
|
|
94
|
-
},
|
|
79
|
+
}, m = (e, t, n) => {
|
|
95
80
|
let r = (e) => {
|
|
96
81
|
let t = e.target;
|
|
97
82
|
if (t) return typeof t == "string" ? t.substring(0, t.indexOf("#")) : t.source;
|
|
@@ -100,7 +85,7 @@ var g = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), _ = (e, t) => {
|
|
|
100
85
|
return n ? (e[n] || (e[n] = []), e[n].push(t), e) : e;
|
|
101
86
|
}, {}), a = e.canvases.map((e) => {
|
|
102
87
|
let t = i[e.id] || [];
|
|
103
|
-
return t.length > 0 ?
|
|
88
|
+
return t.length > 0 ? p(e, t, n) : e;
|
|
104
89
|
});
|
|
105
90
|
return {
|
|
106
91
|
source: {
|
|
@@ -115,7 +100,7 @@ var g = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), _ = (e, t) => {
|
|
|
115
100
|
getMetadata: e.getMetadata,
|
|
116
101
|
getTableOfContents: e.getTableOfContents
|
|
117
102
|
};
|
|
118
|
-
},
|
|
103
|
+
}, h = (e, t, n) => e.source.type === "Canvas" ? p(e, t, n) : m(e, t, n), g = (e) => {
|
|
119
104
|
let t = e.images[0];
|
|
120
105
|
if (!t) return Promise.resolve(!1);
|
|
121
106
|
let n;
|
|
@@ -129,4 +114,4 @@ var g = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), _ = (e, t) => {
|
|
|
129
114
|
});
|
|
130
115
|
};
|
|
131
116
|
//#endregion
|
|
132
|
-
export {
|
|
117
|
+
export { i as fetchAnnotations, h as importAnnotations, g as testCORS };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as e, a as t, b as n, c as r, d as i, f as a, g as o, h as s, i as c, l, m as u, n as d, o as f, p, r as m, s as h, t as g, u as ee, v as _, y as te } from "./core-
|
|
1
|
+
import { _ as e, a as t, b as n, c as r, d as i, f as a, g as o, h as s, i as c, l, m as u, n as d, o as f, p, r as m, s as h, t as g, u as ee, v as _, y as te } from "./core-CbKbxI1_.js";
|
|
2
2
|
//#region node_modules/@iiif/parser/dist/profiles-DU_UcLCg.js
|
|
3
|
-
var ne = "http://library.stanford.edu/iiif/image-api/compliance.html#level0", re = "http://library.stanford.edu/iiif/image-api/compliance.html#level1", v = "http://library.stanford.edu/iiif/image-api/compliance.html#level2", y = "http://library.stanford.edu/iiif/image-api/conformance.html#level0", ie = "http://library.stanford.edu/iiif/image-api/conformance.html#level1", b = "http://library.stanford.edu/iiif/image-api/conformance.html#level2", ae = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0", oe = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1", x = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2", se = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level0", ce = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1", S = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2", C = "http://iiif.io/api/image/1/level0.json", w = "http://iiif.io/api/image/1/profiles/level0.json", le = "http://iiif.io/api/image/1/level1.json", ue = "http://iiif.io/api/image/1/profiles/level1.json", T = "http://iiif.io/api/image/1/level2.json", E = "http://iiif.io/api/image/1/profiles/level2.json", de = "http://iiif.io/api/image/2/level0.json", fe = "http://iiif.io/api/image/2/profiles/level0.json", pe = "http://iiif.io/api/image/2/level1.json", me = "http://iiif.io/api/image/2/profiles/level1.json", D = "http://iiif.io/api/image/2/level2.json", O = "http://iiif.io/api/image/2/profiles/level2.json", he = "level0", ge = "level1", k = "level2", _e = "http://iiif.io/api/image/2/level0",
|
|
4
|
-
|
|
3
|
+
var ne = "http://library.stanford.edu/iiif/image-api/compliance.html#level0", re = "http://library.stanford.edu/iiif/image-api/compliance.html#level1", v = "http://library.stanford.edu/iiif/image-api/compliance.html#level2", y = "http://library.stanford.edu/iiif/image-api/conformance.html#level0", ie = "http://library.stanford.edu/iiif/image-api/conformance.html#level1", b = "http://library.stanford.edu/iiif/image-api/conformance.html#level2", ae = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0", oe = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1", x = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2", se = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level0", ce = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1", S = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2", C = "http://iiif.io/api/image/1/level0.json", w = "http://iiif.io/api/image/1/profiles/level0.json", le = "http://iiif.io/api/image/1/level1.json", ue = "http://iiif.io/api/image/1/profiles/level1.json", T = "http://iiif.io/api/image/1/level2.json", E = "http://iiif.io/api/image/1/profiles/level2.json", de = "http://iiif.io/api/image/2/level0.json", fe = "http://iiif.io/api/image/2/profiles/level0.json", pe = "http://iiif.io/api/image/2/level1.json", me = "http://iiif.io/api/image/2/profiles/level1.json", D = "http://iiif.io/api/image/2/level2.json", O = "http://iiif.io/api/image/2/profiles/level2.json", he = "level0", ge = "level1", k = "level2", _e = "http://iiif.io/api/image/2/level0", ve = "http://iiif.io/api/image/2/level1", A = "http://iiif.io/api/image/2/level2", j = [
|
|
4
|
+
A,
|
|
5
5
|
v,
|
|
6
6
|
b,
|
|
7
7
|
x,
|
|
@@ -12,11 +12,11 @@ var ne = "http://library.stanford.edu/iiif/image-api/compliance.html#level0", re
|
|
|
12
12
|
O,
|
|
13
13
|
k
|
|
14
14
|
];
|
|
15
|
-
[...
|
|
16
|
-
var
|
|
15
|
+
[...j];
|
|
16
|
+
var M = [
|
|
17
17
|
_e,
|
|
18
|
+
ve,
|
|
18
19
|
A,
|
|
19
|
-
j,
|
|
20
20
|
ne,
|
|
21
21
|
re,
|
|
22
22
|
v,
|
|
@@ -44,7 +44,7 @@ var N = [
|
|
|
44
44
|
he,
|
|
45
45
|
ge,
|
|
46
46
|
k
|
|
47
|
-
],
|
|
47
|
+
], N = [
|
|
48
48
|
"sc:Collection",
|
|
49
49
|
"sc:Manifest",
|
|
50
50
|
"sc:Canvas",
|
|
@@ -57,19 +57,19 @@ var N = [
|
|
|
57
57
|
"Service",
|
|
58
58
|
"ContentResource"
|
|
59
59
|
];
|
|
60
|
-
function
|
|
60
|
+
function P(e) {
|
|
61
61
|
if (e == null) throw Error("Null or undefined is not a valid entity.");
|
|
62
62
|
if (Array.isArray(e)) throw Error("Array is not a valid entity");
|
|
63
63
|
if (typeof e != "object") throw Error(`${typeof e} is not a valid entity`);
|
|
64
64
|
if (typeof e["@type"] == "string") {
|
|
65
|
-
let t =
|
|
66
|
-
if (t !== -1) return
|
|
65
|
+
let t = N.indexOf(e["@type"]);
|
|
66
|
+
if (t !== -1) return N[t];
|
|
67
67
|
}
|
|
68
68
|
if (e.profile) return "Service";
|
|
69
69
|
if (e.format || e["@type"]) return "ContentResource";
|
|
70
70
|
throw Error("Resource type is not known");
|
|
71
71
|
}
|
|
72
|
-
var
|
|
72
|
+
var F = class e {
|
|
73
73
|
constructor(e, t = {}) {
|
|
74
74
|
n(this, "traversals", void 0), n(this, "options", void 0), this.traversals = {
|
|
75
75
|
collection: [],
|
|
@@ -209,7 +209,7 @@ var I = class e {
|
|
|
209
209
|
}
|
|
210
210
|
traverseUnknown(e) {
|
|
211
211
|
if (!e["@type"] || typeof e == "string") return e;
|
|
212
|
-
switch (
|
|
212
|
+
switch (P(e)) {
|
|
213
213
|
case "sc:Collection": return this.traverseCollection(e);
|
|
214
214
|
case "sc:Manifest": return this.traverseManifest(e);
|
|
215
215
|
case "sc:Canvas": return this.traverseCanvas(e);
|
|
@@ -260,7 +260,7 @@ var I = class e {
|
|
|
260
260
|
return n === void 0 && !this.options.allowUndefinedReturn ? e : n;
|
|
261
261
|
}, e);
|
|
262
262
|
}
|
|
263
|
-
},
|
|
263
|
+
}, ye = [
|
|
264
264
|
"http://iiif.io/api/image/2/level1",
|
|
265
265
|
"http://iiif.io/api/image/2/level2",
|
|
266
266
|
"http://library.stanford.edu/iiif/image-api/compliance.html#level1",
|
|
@@ -281,13 +281,13 @@ var I = class e {
|
|
|
281
281
|
"http://iiif.io/api/image/2/profiles/level2.json",
|
|
282
282
|
"level1",
|
|
283
283
|
"level2"
|
|
284
|
-
],
|
|
284
|
+
], I = {
|
|
285
285
|
attributionLabel: "Attribution",
|
|
286
286
|
lang: "none",
|
|
287
287
|
providerId: "http://example.org/provider",
|
|
288
288
|
providerName: ""
|
|
289
289
|
};
|
|
290
|
-
function
|
|
290
|
+
function be(e) {
|
|
291
291
|
if (typeof e == "string") return [e];
|
|
292
292
|
if (!e) return [];
|
|
293
293
|
let t = Array.isArray(e) ? e : [e], n = [];
|
|
@@ -303,9 +303,9 @@ function ye(e) {
|
|
|
303
303
|
}
|
|
304
304
|
return n;
|
|
305
305
|
}
|
|
306
|
-
function
|
|
306
|
+
function L(e, t = "none") {
|
|
307
307
|
if (!e) return { none: [""] };
|
|
308
|
-
let n =
|
|
308
|
+
let n = be(e), r = {};
|
|
309
309
|
for (let e of n) {
|
|
310
310
|
if (typeof e == "string") {
|
|
311
311
|
r[t] = r[t] ? r[t] : [], r[t].push(e || "");
|
|
@@ -320,14 +320,14 @@ function R(e, t = "none") {
|
|
|
320
320
|
}
|
|
321
321
|
return Object.keys(r).length === 0 ? { none: [""] } : r;
|
|
322
322
|
}
|
|
323
|
-
function
|
|
324
|
-
if (Array.isArray(e)) return
|
|
325
|
-
if (
|
|
326
|
-
if (
|
|
327
|
-
if (
|
|
323
|
+
function R(e) {
|
|
324
|
+
if (Array.isArray(e)) return R(e.find((e) => typeof e == "string"));
|
|
325
|
+
if (j.indexOf(e) !== -1) return "level2";
|
|
326
|
+
if (ye.indexOf(e) !== -1) return "level1";
|
|
327
|
+
if (M.indexOf(e) !== -1) return "level0";
|
|
328
328
|
if (typeof e == "string") return e;
|
|
329
329
|
}
|
|
330
|
-
function
|
|
330
|
+
function xe(e) {
|
|
331
331
|
let t = Array.isArray(e) ? e : [e];
|
|
332
332
|
for (let e of t) switch (e) {
|
|
333
333
|
case "http://iiif.io/api/image/2/context.json":
|
|
@@ -337,7 +337,7 @@ function be(e) {
|
|
|
337
337
|
case "http://iiif.io/api/annex/openannotation/context.json": return "ImageApiSelector";
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
|
-
function
|
|
340
|
+
function Se(e) {
|
|
341
341
|
switch (e) {
|
|
342
342
|
case "http://iiif.io/api/image/2/level0.json":
|
|
343
343
|
case "http://iiif.io/api/image/2/level1.json":
|
|
@@ -360,7 +360,7 @@ function xe(e) {
|
|
|
360
360
|
case "http://iiif.io/api/search/0/autocomplete": return "AutoCompleteService1";
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
|
-
function
|
|
363
|
+
function z(e) {
|
|
364
364
|
for (let t of [
|
|
365
365
|
"sc",
|
|
366
366
|
"oa",
|
|
@@ -370,7 +370,7 @@ function B(e) {
|
|
|
370
370
|
]) if (e.startsWith(`${t}:`)) return e.slice(t.length + 1);
|
|
371
371
|
return e;
|
|
372
372
|
}
|
|
373
|
-
var
|
|
373
|
+
var Ce = [
|
|
374
374
|
"Collection",
|
|
375
375
|
"Manifest",
|
|
376
376
|
"Annotation",
|
|
@@ -378,14 +378,14 @@ var Se = [
|
|
|
378
378
|
"Range",
|
|
379
379
|
"Service"
|
|
380
380
|
];
|
|
381
|
-
function
|
|
381
|
+
function B(e) {
|
|
382
382
|
let t = e["@id"] || e.id, n = e["@type"] || e.type, r = e.profile || void 0, i = e["@context"] || void 0;
|
|
383
383
|
if (r) {
|
|
384
|
-
let e =
|
|
384
|
+
let e = Se(r);
|
|
385
385
|
if (e) return e;
|
|
386
386
|
}
|
|
387
387
|
if (i) {
|
|
388
|
-
let e =
|
|
388
|
+
let e = xe(i);
|
|
389
389
|
if (e) return e;
|
|
390
390
|
}
|
|
391
391
|
if (n) {
|
|
@@ -410,7 +410,7 @@ function V(e) {
|
|
|
410
410
|
case "cnt:ContentAsText": return "TextualBody";
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
|
-
if (n &&
|
|
413
|
+
if (n && Ce.indexOf(n) !== -1) return n;
|
|
414
414
|
if (e.format) {
|
|
415
415
|
if (e.format.startsWith("image/")) return "Image";
|
|
416
416
|
if (e.format.startsWith("text/") || e.format === "application/pdf") return "Text";
|
|
@@ -418,15 +418,15 @@ function V(e) {
|
|
|
418
418
|
}
|
|
419
419
|
return t && (t.endsWith(".jpg") || t.endsWith(".png") || t.endsWith(".jpeg")) ? "Image" : n || "unknown";
|
|
420
420
|
}
|
|
421
|
-
var
|
|
422
|
-
function
|
|
423
|
-
let t = e.match(
|
|
421
|
+
var we = /^|["'\\>]http(s)?:\/\/(creativecommons.org|rightsstatements.org)\/[^"'\\<\n]+/gm;
|
|
422
|
+
function Te(e) {
|
|
423
|
+
let t = e.match(we);
|
|
424
424
|
return t ? t[0] : e;
|
|
425
425
|
}
|
|
426
|
-
function
|
|
426
|
+
function V(e, t = "Rights/License", n = "none") {
|
|
427
427
|
let r = null, i = [], a = Array.isArray(e) ? e : [e];
|
|
428
428
|
for (let e of a) {
|
|
429
|
-
let a = e ?
|
|
429
|
+
let a = e ? Te(e) : void 0;
|
|
430
430
|
if (a && (a.indexOf("creativecommons.org") !== -1 || a.indexOf("rightsstatements.org") !== -1)) {
|
|
431
431
|
r = a.startsWith("https://") ? `http://${a.slice(8)}` : a;
|
|
432
432
|
continue;
|
|
@@ -438,7 +438,7 @@ function H(e, t = "Rights/License", n = "none") {
|
|
|
438
438
|
}
|
|
439
439
|
return [r, i];
|
|
440
440
|
}
|
|
441
|
-
var
|
|
441
|
+
var Ee = [
|
|
442
442
|
"http://iiif.io/api/presentation/2/context.json",
|
|
443
443
|
"http://iiif.io/api/image/2/context.json",
|
|
444
444
|
"http://iiif.io/api/image/1/context.json",
|
|
@@ -449,32 +449,32 @@ var Te = [
|
|
|
449
449
|
"http://iiif.io/api/auth/0/context.json",
|
|
450
450
|
"http://iiif.io/api/annex/openannotation/context.json"
|
|
451
451
|
];
|
|
452
|
-
function
|
|
452
|
+
function De(e) {
|
|
453
453
|
if (e) {
|
|
454
454
|
let t = Array.isArray(e) ? e : [e], n = [];
|
|
455
|
-
for (let e of t) e === "http://iiif.io/api/presentation/2/context.json" && n.push("http://iiif.io/api/presentation/3/context.json"),
|
|
455
|
+
for (let e of t) e === "http://iiif.io/api/presentation/2/context.json" && n.push("http://iiif.io/api/presentation/3/context.json"), Ee.indexOf(e) === -1 && n.push(e);
|
|
456
456
|
if (t.length) return n.length === 1 ? n[0] : n;
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
|
-
function
|
|
459
|
+
function Oe(e) {
|
|
460
460
|
return e ? e.map((e) => ({
|
|
461
|
-
label:
|
|
462
|
-
value:
|
|
461
|
+
label: L(e.label),
|
|
462
|
+
value: L(e.value)
|
|
463
463
|
})) : [];
|
|
464
464
|
}
|
|
465
|
-
var
|
|
466
|
-
function
|
|
465
|
+
var H = 0;
|
|
466
|
+
function U(e, t) {
|
|
467
467
|
let n = encodeURI(e.id || e["@id"] || "").trim();
|
|
468
|
-
return n && t ? `${n}/${t}` : n || (
|
|
468
|
+
return n && t ? `${n}/${t}` : n || (H++, `http://example.org/${e["@type"]}${t ? `/${t}` : ""}/${H}`);
|
|
469
469
|
}
|
|
470
|
-
function
|
|
470
|
+
function W(e) {
|
|
471
471
|
let t = [...e.behavior || []];
|
|
472
472
|
e.viewingHint && t.push(e.viewingHint);
|
|
473
473
|
let n;
|
|
474
|
-
return Array.isArray(e.motivation) ? n = e.motivation.map(
|
|
475
|
-
"@context": e["@context"] ?
|
|
476
|
-
id: (e["@id"] ||
|
|
477
|
-
type:
|
|
474
|
+
return Array.isArray(e.motivation) ? n = e.motivation.map(z) : e.motivation && (n = z(e.motivation)), {
|
|
475
|
+
"@context": e["@context"] ? De(e["@context"]) : void 0,
|
|
476
|
+
id: (e["@id"] || U(e)).trim(),
|
|
477
|
+
type: B(e),
|
|
478
478
|
behavior: t.length ? t : void 0,
|
|
479
479
|
height: e.height ? e.height : void 0,
|
|
480
480
|
width: e.width ? e.width : void 0,
|
|
@@ -486,28 +486,28 @@ function G(e) {
|
|
|
486
486
|
timeMode: void 0
|
|
487
487
|
};
|
|
488
488
|
}
|
|
489
|
-
function
|
|
490
|
-
let [t, n] =
|
|
489
|
+
function G(e) {
|
|
490
|
+
let [t, n] = V(e.license), r = [...e.metadata ? Oe(e.metadata) : [], ...n];
|
|
491
491
|
return {
|
|
492
492
|
rights: t,
|
|
493
493
|
metadata: r.length ? r : void 0,
|
|
494
|
-
label: e.label ?
|
|
494
|
+
label: e.label ? L(e.label) : void 0,
|
|
495
495
|
requiredStatement: e.attribution ? {
|
|
496
|
-
label:
|
|
497
|
-
value:
|
|
496
|
+
label: L(I.attributionLabel),
|
|
497
|
+
value: L(e.attribution)
|
|
498
498
|
} : void 0,
|
|
499
499
|
navDate: e.navDate,
|
|
500
|
-
summary: e.description ?
|
|
501
|
-
thumbnail:
|
|
500
|
+
summary: e.description ? L(e.description) : void 0,
|
|
501
|
+
thumbnail: ke(e.thumbnail)
|
|
502
502
|
};
|
|
503
503
|
}
|
|
504
|
-
function
|
|
504
|
+
function ke(e) {
|
|
505
505
|
return e && (Array.isArray(e) ? e : [e]).map((e) => typeof e == "string" ? {
|
|
506
506
|
id: e,
|
|
507
507
|
type: "Image"
|
|
508
508
|
} : (e.type === "unknown" && (e.type = "Image"), e));
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function Ae(e) {
|
|
511
511
|
if (!e.within) return;
|
|
512
512
|
let t = Array.isArray(e.within) ? e.within : [e.within], n = [];
|
|
513
513
|
for (let r of t) if (typeof r == "string") {
|
|
@@ -521,21 +521,21 @@ function ke(e) {
|
|
|
521
521
|
}
|
|
522
522
|
} else r["@id"] && n.push({
|
|
523
523
|
id: r["@id"],
|
|
524
|
-
type:
|
|
524
|
+
type: B(r)
|
|
525
525
|
});
|
|
526
526
|
return n.length ? n : void 0;
|
|
527
527
|
}
|
|
528
|
-
function
|
|
528
|
+
function K(e) {
|
|
529
529
|
let t = e.related ? Array.isArray(e.related) ? e.related : [e.related] : [], n = e.contentLayer;
|
|
530
530
|
return {
|
|
531
531
|
provider: e.logo || t.length ? [{
|
|
532
|
-
id:
|
|
532
|
+
id: I.providerId,
|
|
533
533
|
type: "Agent",
|
|
534
534
|
homepage: t.length ? [t[0]] : void 0,
|
|
535
535
|
logo: e.logo ? Array.isArray(e.logo) ? e.logo : [e.logo] : void 0,
|
|
536
|
-
label:
|
|
536
|
+
label: L(I.providerName)
|
|
537
537
|
}] : void 0,
|
|
538
|
-
partOf:
|
|
538
|
+
partOf: Ae(e),
|
|
539
539
|
rendering: e.rendering,
|
|
540
540
|
seeAlso: e.seeAlso,
|
|
541
541
|
start: e.startCanvas,
|
|
@@ -543,14 +543,14 @@ function q(e) {
|
|
|
543
543
|
supplementary: n ? [n] : void 0
|
|
544
544
|
};
|
|
545
545
|
}
|
|
546
|
-
function
|
|
546
|
+
function je(e) {
|
|
547
547
|
return {
|
|
548
548
|
chars: e.chars,
|
|
549
549
|
format: e.format ? e.format : void 0,
|
|
550
550
|
language: e.language
|
|
551
551
|
};
|
|
552
552
|
}
|
|
553
|
-
function
|
|
553
|
+
function q(e, t) {
|
|
554
554
|
return e ? typeof e == "string" ? {
|
|
555
555
|
id: e,
|
|
556
556
|
type: t
|
|
@@ -562,23 +562,23 @@ function J(e, t) {
|
|
|
562
562
|
type: t
|
|
563
563
|
} : null : null;
|
|
564
564
|
}
|
|
565
|
-
function
|
|
565
|
+
function Me(e) {
|
|
566
566
|
let t = {};
|
|
567
567
|
if (e.first) {
|
|
568
|
-
let n =
|
|
568
|
+
let n = q(e.first, "Collection");
|
|
569
569
|
n && (t.first = n);
|
|
570
570
|
}
|
|
571
571
|
if ((e.total || e.total === 0) && (t.total = e.total), e.prev) {
|
|
572
|
-
let n =
|
|
572
|
+
let n = q(e.prev, "Collection");
|
|
573
573
|
n && (t.prev = n);
|
|
574
574
|
}
|
|
575
575
|
if (e.next) {
|
|
576
|
-
let n =
|
|
576
|
+
let n = q(e.next, "Collection");
|
|
577
577
|
n && (t.next = n);
|
|
578
578
|
}
|
|
579
579
|
return t;
|
|
580
580
|
}
|
|
581
|
-
function
|
|
581
|
+
function Ne(e) {
|
|
582
582
|
let t = [];
|
|
583
583
|
for (let n of e) {
|
|
584
584
|
let e = { ...n };
|
|
@@ -586,30 +586,30 @@ function Me(e) {
|
|
|
586
586
|
}
|
|
587
587
|
return t;
|
|
588
588
|
}
|
|
589
|
-
function
|
|
589
|
+
function Pe(e) {
|
|
590
590
|
return _({
|
|
591
|
+
...W(e),
|
|
591
592
|
...G(e),
|
|
592
593
|
...K(e),
|
|
593
|
-
...
|
|
594
|
-
|
|
595
|
-
items: Me(e.members)
|
|
594
|
+
...Me(e),
|
|
595
|
+
items: Ne(e.members)
|
|
596
596
|
});
|
|
597
597
|
}
|
|
598
|
-
function
|
|
598
|
+
function Fe(e) {
|
|
599
599
|
let t = [], n = [], r, i;
|
|
600
600
|
for (let a of e.sequences || []) a.canvases.length && t.push(...a.canvases), a.behavior && n.push(...a.behavior), a.viewingDirection && (i = a.viewingDirection), a.startCanvas && (r = a.startCanvas);
|
|
601
|
-
let a =
|
|
601
|
+
let a = W(e);
|
|
602
602
|
return n.length && (a.behavior ? a.behavior.push(...n) : a.behavior = n), _({
|
|
603
603
|
...a,
|
|
604
|
+
...G(e),
|
|
604
605
|
...K(e),
|
|
605
|
-
...q(e),
|
|
606
606
|
viewingDirection: i,
|
|
607
607
|
start: r,
|
|
608
608
|
items: t,
|
|
609
|
-
structures:
|
|
609
|
+
structures: Ie(e.structures)
|
|
610
610
|
});
|
|
611
611
|
}
|
|
612
|
-
function
|
|
612
|
+
function Ie(e) {
|
|
613
613
|
if (!e) return e;
|
|
614
614
|
let t = /* @__PURE__ */ new Map();
|
|
615
615
|
for (let n of e) t.set(n.id, n);
|
|
@@ -617,28 +617,28 @@ function Fe(e) {
|
|
|
617
617
|
for (let r of e) r.items &&= r.items.map((e) => typeof e == "string" ? (n.push(e), t.get(e) || e) : e && e.id ? (n.push(e.id), t.get(e.id) || e) : e);
|
|
618
618
|
return e.filter((e) => n.indexOf(e.id) === -1);
|
|
619
619
|
}
|
|
620
|
-
function
|
|
620
|
+
function Le(e) {
|
|
621
621
|
return _({
|
|
622
|
+
...W(e),
|
|
622
623
|
...G(e),
|
|
623
624
|
...K(e),
|
|
624
|
-
...q(e),
|
|
625
625
|
annotations: e.otherContent && e.otherContent.length ? e.otherContent : void 0,
|
|
626
626
|
items: e.images && e.images.length ? [{
|
|
627
|
-
id:
|
|
627
|
+
id: U(e, "annotation-page"),
|
|
628
628
|
type: "AnnotationPage",
|
|
629
629
|
items: e.images
|
|
630
630
|
}] : void 0
|
|
631
631
|
});
|
|
632
632
|
}
|
|
633
|
-
function
|
|
633
|
+
function Re(e) {
|
|
634
634
|
return _({
|
|
635
|
+
...W(e),
|
|
635
636
|
...G(e),
|
|
636
637
|
...K(e),
|
|
637
|
-
...q(e),
|
|
638
638
|
items: e.resources && e.resources.length ? e.resources : void 0
|
|
639
639
|
});
|
|
640
640
|
}
|
|
641
|
-
function
|
|
641
|
+
function ze(e) {
|
|
642
642
|
return !e.canvases || e.canvases.length === 0 ? {
|
|
643
643
|
canvases: [],
|
|
644
644
|
behavior: []
|
|
@@ -649,7 +649,7 @@ function Re(e) {
|
|
|
649
649
|
startCanvas: e.startCanvas
|
|
650
650
|
};
|
|
651
651
|
}
|
|
652
|
-
function
|
|
652
|
+
function Be(e) {
|
|
653
653
|
function t(e) {
|
|
654
654
|
if (Array.isArray(e)) {
|
|
655
655
|
if (e.length > 1) return {
|
|
@@ -674,77 +674,77 @@ function ze(e) {
|
|
|
674
674
|
return {
|
|
675
675
|
type: "SpecificResource",
|
|
676
676
|
source: t,
|
|
677
|
-
selector:
|
|
677
|
+
selector: Z(e.selector)
|
|
678
678
|
};
|
|
679
679
|
} else return encodeURI(e["@id"]).trim();
|
|
680
680
|
}
|
|
681
681
|
return _({
|
|
682
|
+
...W(e),
|
|
682
683
|
...G(e),
|
|
683
684
|
...K(e),
|
|
684
|
-
...q(e),
|
|
685
685
|
target: t(e.on),
|
|
686
|
-
body: Array.isArray(e.resource) ? e.resource.map(
|
|
686
|
+
body: Array.isArray(e.resource) ? e.resource.map(J) : J(e.resource)
|
|
687
687
|
});
|
|
688
688
|
}
|
|
689
|
-
function
|
|
690
|
-
return e.type === "Choice" ? e :
|
|
689
|
+
function J(e) {
|
|
690
|
+
return e.type === "Choice" ? e : Y(e);
|
|
691
691
|
}
|
|
692
|
-
function
|
|
692
|
+
function Y(e) {
|
|
693
693
|
let t = e;
|
|
694
694
|
return _({
|
|
695
|
+
...W(t),
|
|
695
696
|
...G(t),
|
|
696
697
|
...K(t),
|
|
697
|
-
...
|
|
698
|
-
...Ae(t)
|
|
698
|
+
...je(t)
|
|
699
699
|
});
|
|
700
700
|
}
|
|
701
|
-
function
|
|
701
|
+
function Ve(e) {
|
|
702
702
|
let t = [];
|
|
703
703
|
return e.default && e.default !== "rdf:nil" && t.push(e.default), e.item && e.item !== "rdf:nil" && t.push(...e.item), _({
|
|
704
|
+
...W(e),
|
|
704
705
|
...G(e),
|
|
705
|
-
...K(e),
|
|
706
706
|
items: t
|
|
707
707
|
});
|
|
708
708
|
}
|
|
709
|
-
function
|
|
709
|
+
function He(e) {
|
|
710
710
|
return _({
|
|
711
|
+
...W(e),
|
|
711
712
|
...G(e),
|
|
712
713
|
...K(e),
|
|
713
|
-
...q(e),
|
|
714
714
|
items: e.members
|
|
715
715
|
});
|
|
716
716
|
}
|
|
717
|
-
function
|
|
717
|
+
function Ue(e) {
|
|
718
718
|
let { "@id": t, "@type": n, "@context": r, profile: i, ...a } = e, o = {};
|
|
719
|
-
return t && (o["@id"] = t), o["@type"] =
|
|
719
|
+
return t && (o["@id"] = t), o["@type"] = B(e), o["@type"] === "unknown" && (r && r.length && (o["@context"] = r), o["@type"] = "Service"), i && (o.profile = R(i)), _({
|
|
720
720
|
...o,
|
|
721
721
|
...a
|
|
722
722
|
});
|
|
723
723
|
}
|
|
724
|
-
function
|
|
724
|
+
function We(e) {
|
|
725
725
|
return _({
|
|
726
|
+
...W(e),
|
|
726
727
|
...G(e),
|
|
727
|
-
...K(e)
|
|
728
|
-
...q(e)
|
|
728
|
+
...K(e)
|
|
729
729
|
});
|
|
730
730
|
}
|
|
731
|
-
var
|
|
732
|
-
collection: [
|
|
733
|
-
manifest: [
|
|
734
|
-
canvas: [
|
|
735
|
-
annotationList: [
|
|
736
|
-
sequence: [
|
|
737
|
-
annotation: [
|
|
738
|
-
contentResource: [
|
|
739
|
-
choice: [
|
|
740
|
-
range: [
|
|
741
|
-
service: [
|
|
742
|
-
layer: [
|
|
731
|
+
var Ge = new F({
|
|
732
|
+
collection: [Pe],
|
|
733
|
+
manifest: [Fe],
|
|
734
|
+
canvas: [Le],
|
|
735
|
+
annotationList: [Re],
|
|
736
|
+
sequence: [ze],
|
|
737
|
+
annotation: [Be],
|
|
738
|
+
contentResource: [Y],
|
|
739
|
+
choice: [Ve],
|
|
740
|
+
range: [He],
|
|
741
|
+
service: [Ue],
|
|
742
|
+
layer: [We]
|
|
743
743
|
});
|
|
744
|
-
function
|
|
745
|
-
return e && e["@context"] && (e["@context"] === "http://iiif.io/api/presentation/2/context.json" || Array.isArray(e["@context"]) && e["@context"].indexOf("http://iiif.io/api/presentation/2/context.json") !== -1 || e["@context"] === "http://www.shared-canvas.org/ns/context.json") || e["@context"] === "http://iiif.io/api/image/2/context.json" || e["@id"] && e["@type"] === "sc:Collection" || e["@id"] && e["@type"] === "sc:Manifest" ? (e["@context"] ||= "http://iiif.io/api/presentation/2/context.json",
|
|
744
|
+
function X(e) {
|
|
745
|
+
return e && e["@context"] && (e["@context"] === "http://iiif.io/api/presentation/2/context.json" || Array.isArray(e["@context"]) && e["@context"].indexOf("http://iiif.io/api/presentation/2/context.json") !== -1 || e["@context"] === "http://www.shared-canvas.org/ns/context.json") || e["@context"] === "http://iiif.io/api/image/2/context.json" || e["@id"] && e["@type"] === "sc:Collection" || e["@id"] && e["@type"] === "sc:Manifest" ? (e["@context"] ||= "http://iiif.io/api/presentation/2/context.json", Ge.traverseUnknown(e)) : e;
|
|
746
746
|
}
|
|
747
|
-
function
|
|
747
|
+
function Z(e) {
|
|
748
748
|
if ((Array.isArray(e["@type"]) && e["@type"].includes("oa:SvgSelector") || e["@type"] == "oa:SvgSelector") && ("chars" in e || "value" in e)) return {
|
|
749
749
|
type: "SvgSelector",
|
|
750
750
|
value: "chars" in e ? e.chars : e.value
|
|
@@ -753,7 +753,7 @@ function Q(e) {
|
|
|
753
753
|
type: "FragmentSelector",
|
|
754
754
|
value: e.value
|
|
755
755
|
};
|
|
756
|
-
if (e["@type"] === "oa:Choice") return [
|
|
756
|
+
if (e["@type"] === "oa:Choice") return [Z(e.default), ...(Array.isArray(e.item) ? e.item : [e.item]).map(Z)];
|
|
757
757
|
if (e["@type"] == "iiif:ImageApiSelector") return {
|
|
758
758
|
type: "ImageApiSelector",
|
|
759
759
|
region: "region" in e ? e.region : void 0,
|
|
@@ -763,7 +763,7 @@ function Q(e) {
|
|
|
763
763
|
}
|
|
764
764
|
//#endregion
|
|
765
765
|
//#region src/Cozy.ts
|
|
766
|
-
var
|
|
766
|
+
var Ke = async (e) => {
|
|
767
767
|
try {
|
|
768
768
|
new URL(e);
|
|
769
769
|
} catch {
|
|
@@ -797,7 +797,7 @@ var Ge = async (e) => {
|
|
|
797
797
|
url: e
|
|
798
798
|
};
|
|
799
799
|
try {
|
|
800
|
-
return
|
|
800
|
+
return Q(await t.json(), e);
|
|
801
801
|
} catch {
|
|
802
802
|
return {
|
|
803
803
|
type: "error",
|
|
@@ -805,7 +805,11 @@ var Ge = async (e) => {
|
|
|
805
805
|
message: "Could not parse resource"
|
|
806
806
|
};
|
|
807
807
|
}
|
|
808
|
-
},
|
|
808
|
+
}, Q = (e, t) => {
|
|
809
|
+
if (e.type === "Canvas") return {
|
|
810
|
+
type: "canvas",
|
|
811
|
+
resource: $(e)
|
|
812
|
+
};
|
|
809
813
|
let n = Array.isArray(e["@context"]) ? e["@context"].find((e) => e.includes("iiif.io/api/presentation") || e.includes("iiif.io/api/image") || e.includes("shared-canvas")) : e["@context"];
|
|
810
814
|
if (!n) return {
|
|
811
815
|
type: "error",
|
|
@@ -823,15 +827,15 @@ var Ge = async (e) => {
|
|
|
823
827
|
return s(e, "type").includes("Collection") ? {
|
|
824
828
|
type: "collection",
|
|
825
829
|
url: t || r,
|
|
826
|
-
resource:
|
|
830
|
+
resource: qe(e, i)
|
|
827
831
|
} : {
|
|
828
832
|
type: "manifest",
|
|
829
833
|
url: t || r,
|
|
830
|
-
resource:
|
|
834
|
+
resource: Je(e, i)
|
|
831
835
|
};
|
|
832
836
|
}
|
|
833
837
|
if (n.includes("image/2") || n.includes("image/3")) {
|
|
834
|
-
let n =
|
|
838
|
+
let n = Ye(e);
|
|
835
839
|
return n ? {
|
|
836
840
|
type: "iiif-image",
|
|
837
841
|
url: t || r,
|
|
@@ -847,17 +851,21 @@ var Ge = async (e) => {
|
|
|
847
851
|
code: "INVALID_MANIFEST",
|
|
848
852
|
message: "JSON resource is not a recognized IIIF format"
|
|
849
853
|
};
|
|
850
|
-
},
|
|
851
|
-
let r = (
|
|
852
|
-
let
|
|
853
|
-
return new e({
|
|
854
|
+
}, qe = (t, n) => {
|
|
855
|
+
let r = (n) => {
|
|
856
|
+
let r = [];
|
|
857
|
+
return new e({
|
|
858
|
+
collection: [(e) => e.id !== s(t, "id") && r.push(e)],
|
|
859
|
+
manifest: [(e) => r.push(e)]
|
|
860
|
+
}).traverseCollection(n), r.map((e) => ({
|
|
854
861
|
id: e.id,
|
|
855
862
|
type: e.type,
|
|
856
863
|
getLabel: p(e),
|
|
857
864
|
source: e
|
|
858
865
|
}));
|
|
859
|
-
}, i = n === 2 ?
|
|
866
|
+
}, i = n === 2 ? X(t) : t, a = r(i);
|
|
860
867
|
return {
|
|
868
|
+
type: "Collection",
|
|
861
869
|
source: i,
|
|
862
870
|
id: i.id,
|
|
863
871
|
majorVersion: n,
|
|
@@ -865,7 +873,21 @@ var Ge = async (e) => {
|
|
|
865
873
|
getLabel: p(i),
|
|
866
874
|
getMetadata: u(i)
|
|
867
875
|
};
|
|
868
|
-
},
|
|
876
|
+
}, $ = (e) => {
|
|
877
|
+
let t = d(e);
|
|
878
|
+
return {
|
|
879
|
+
source: e,
|
|
880
|
+
id: e.id,
|
|
881
|
+
width: e.width,
|
|
882
|
+
height: e.height,
|
|
883
|
+
images: t,
|
|
884
|
+
annotations: e.annotations || [],
|
|
885
|
+
getImageURL: t.length > 0 ? t[0].getImageURL : () => void 0,
|
|
886
|
+
getLabel: p(e),
|
|
887
|
+
getMetadata: u(e),
|
|
888
|
+
getThumbnailURL: m(e, t)
|
|
889
|
+
};
|
|
890
|
+
}, Je = (t, n) => {
|
|
869
891
|
let r = (t) => {
|
|
870
892
|
let n = [], r = [];
|
|
871
893
|
new e({
|
|
@@ -876,21 +898,7 @@ var Ge = async (e) => {
|
|
|
876
898
|
e.type === "Range" && r.push(e);
|
|
877
899
|
}]
|
|
878
900
|
}).traverseManifest(t);
|
|
879
|
-
let i = n.map((e) => {
|
|
880
|
-
let t = d(e);
|
|
881
|
-
return {
|
|
882
|
-
source: e,
|
|
883
|
-
id: e.id,
|
|
884
|
-
width: e.width,
|
|
885
|
-
height: e.height,
|
|
886
|
-
images: t,
|
|
887
|
-
annotations: e.annotations || [],
|
|
888
|
-
getImageURL: t.length > 0 ? t[0].getImageURL : () => void 0,
|
|
889
|
-
getLabel: p(e),
|
|
890
|
-
getMetadata: u(e),
|
|
891
|
-
getThumbnailURL: m(e, t)
|
|
892
|
-
};
|
|
893
|
-
}), a = (e) => {
|
|
901
|
+
let i = n.map($), a = (e) => {
|
|
894
902
|
let t = e.items || [], n = t.filter((e) => e.type === "Canvas").map((e) => i.find((t) => t.id === e.id)).filter(Boolean), r = t.filter((e) => e.type === "Range").map((e) => a(e)), o = [...n, ...r];
|
|
895
903
|
return {
|
|
896
904
|
source: e,
|
|
@@ -905,7 +913,7 @@ var Ge = async (e) => {
|
|
|
905
913
|
canvases: i,
|
|
906
914
|
ranges: r.map((e) => a(e))
|
|
907
915
|
};
|
|
908
|
-
}, i = n === 2 ?
|
|
916
|
+
}, i = n === 2 ? X(t) : t, { canvases: a, ranges: o } = r(i);
|
|
909
917
|
return {
|
|
910
918
|
source: i,
|
|
911
919
|
id: i.id,
|
|
@@ -916,7 +924,7 @@ var Ge = async (e) => {
|
|
|
916
924
|
getMetadata: u(i),
|
|
917
925
|
getTableOfContents: g(o)
|
|
918
926
|
};
|
|
919
|
-
},
|
|
927
|
+
}, Ye = (e) => {
|
|
920
928
|
let { width: t, height: n, format: r } = e, o = s(e, "id"), u = a(e);
|
|
921
929
|
if (u) {
|
|
922
930
|
let r = i(s(e, "id")), a = {
|
|
@@ -944,9 +952,9 @@ var Ge = async (e) => {
|
|
|
944
952
|
getImageURL: () => o,
|
|
945
953
|
getPixelSize: l(o)
|
|
946
954
|
};
|
|
947
|
-
},
|
|
948
|
-
parse:
|
|
949
|
-
parseURL:
|
|
955
|
+
}, Xe = {
|
|
956
|
+
parse: Q,
|
|
957
|
+
parseURL: Ke
|
|
950
958
|
};
|
|
951
959
|
//#endregion
|
|
952
|
-
export {
|
|
960
|
+
export { Xe as Cozy, c as getImageURL, t as getImageURLFromService, d as getImages, p as getLabel, u as getMetadata, f as getPixelSizeFromServiceUrl, s as getPropertyValue, h as getRegionURL, r as getRegionURLFromService, l as getStaticImagePixelSize, o as getStringValue, g as getTableOfContents, m as getThumbnailURL, ee as isImageService, i as normalizeServiceUrl, a as parseImageService };
|
package/dist/level-0/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as e } from "../core-
|
|
2
|
-
import { t } from "../p-throttle-
|
|
1
|
+
import { h as e } from "../core-CbKbxI1_.js";
|
|
2
|
+
import { t } from "../p-throttle-Hk6Snhzm.js";
|
|
3
3
|
//#region src/level-0/fetch-image-info.ts
|
|
4
4
|
var n = (t) => ({
|
|
5
5
|
id: e(t, "id"),
|
package/dist/types.d.ts
CHANGED
|
@@ -11,6 +11,9 @@ export type CozyParseResult = {
|
|
|
11
11
|
type: 'iiif-image';
|
|
12
12
|
url: string;
|
|
13
13
|
resource: CozyImageResource;
|
|
14
|
+
} | {
|
|
15
|
+
type: 'canvas';
|
|
16
|
+
resource: CozyCanvas;
|
|
14
17
|
} | {
|
|
15
18
|
type: 'plain-image';
|
|
16
19
|
url: string;
|
|
@@ -26,16 +29,18 @@ export interface CozyCollection {
|
|
|
26
29
|
readonly majorVersion: number;
|
|
27
30
|
readonly source: Collection;
|
|
28
31
|
readonly id: string;
|
|
32
|
+
readonly type: 'Collection';
|
|
29
33
|
readonly items: CozyCollectionItem[];
|
|
30
34
|
getLabel(locale?: string): string | undefined;
|
|
31
35
|
getMetadata(locale?: string): CozyMetadata[];
|
|
32
36
|
}
|
|
33
|
-
export interface
|
|
37
|
+
export interface CozyCollectionManifestItem {
|
|
34
38
|
readonly id: string;
|
|
35
|
-
readonly type:
|
|
39
|
+
readonly type: 'Manifest';
|
|
36
40
|
readonly source: any;
|
|
37
41
|
getLabel(locale?: string): string | undefined;
|
|
38
42
|
}
|
|
43
|
+
export type CozyCollectionItem = CozyCollectionManifestItem | CozyCollection;
|
|
39
44
|
export interface CozyManifest {
|
|
40
45
|
readonly majorVersion: number;
|
|
41
46
|
readonly source: Manifest;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-iiif",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "A developer-friendly collection of abstractions and utilities built on top of @iiif/presentation-3 and @iiif/parser",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Rainer Simon",
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"typescript": "^6.0.3",
|
|
32
|
-
"vite": "^8.
|
|
33
|
-
"vitest": "^4.1.
|
|
32
|
+
"vite": "^8.1.3",
|
|
33
|
+
"vitest": "^4.1.10"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@iiif/parser": "^2.2.
|
|
36
|
+
"@iiif/parser": "^2.2.13",
|
|
37
37
|
"@iiif/presentation-3": "^2.2.3",
|
|
38
38
|
"image-size": "^2.0.2",
|
|
39
39
|
"p-throttle": "^8.1.0",
|
|
40
|
-
"uuid": "^14.0.
|
|
40
|
+
"uuid": "^14.0.1"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/Cozy.ts
CHANGED
|
@@ -87,6 +87,12 @@ const parseURL = async (input: string): Promise<CozyParseResult> => {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
const parse = (json: any, url?: string): CozyParseResult => {
|
|
90
|
+
if (json.type === 'Canvas')
|
|
91
|
+
return {
|
|
92
|
+
type: 'canvas',
|
|
93
|
+
resource: parseCanvas(json)
|
|
94
|
+
};
|
|
95
|
+
|
|
90
96
|
const context: string = Array.isArray(json['@context'])
|
|
91
97
|
? json['@context'].find(str =>
|
|
92
98
|
str.includes('iiif.io/api/presentation') ||
|
|
@@ -158,6 +164,9 @@ const parseCollectionResource = (resource: any, majorVersion: number): CozyColle
|
|
|
158
164
|
const items: any[] = [];
|
|
159
165
|
|
|
160
166
|
const modelBuilder = new Traverse({
|
|
167
|
+
// The model builder fires on the collection ITSELF - we don't want that, but want
|
|
168
|
+
// to collect sub-collections
|
|
169
|
+
collection: [item => item.id !== getPropertyValue(resource, 'id') && items.push(item)],
|
|
161
170
|
manifest: [item => items.push(item)]
|
|
162
171
|
});
|
|
163
172
|
|
|
@@ -176,6 +185,7 @@ const parseCollectionResource = (resource: any, majorVersion: number): CozyColle
|
|
|
176
185
|
const items = parseV3(v3);
|
|
177
186
|
|
|
178
187
|
return {
|
|
188
|
+
type: 'Collection',
|
|
179
189
|
source: v3,
|
|
180
190
|
id: v3.id,
|
|
181
191
|
majorVersion,
|
|
@@ -185,6 +195,22 @@ const parseCollectionResource = (resource: any, majorVersion: number): CozyColle
|
|
|
185
195
|
};
|
|
186
196
|
}
|
|
187
197
|
|
|
198
|
+
const parseCanvas = (canvas: Canvas) => {
|
|
199
|
+
const images = getImages(canvas);
|
|
200
|
+
return {
|
|
201
|
+
source: canvas,
|
|
202
|
+
id: canvas.id,
|
|
203
|
+
width: canvas.width,
|
|
204
|
+
height: canvas.height,
|
|
205
|
+
images,
|
|
206
|
+
annotations: (canvas.annotations || []),
|
|
207
|
+
getImageURL: images.length > 0 ? images[0].getImageURL : () => undefined,
|
|
208
|
+
getLabel: getLabel(canvas),
|
|
209
|
+
getMetadata: getMetadata(canvas),
|
|
210
|
+
getThumbnailURL: getThumbnailURL(canvas, images)
|
|
211
|
+
} as CozyCanvas;
|
|
212
|
+
}
|
|
213
|
+
|
|
188
214
|
const parseManifestResource = (resource: any, majorVersion: number): CozyManifest => {
|
|
189
215
|
|
|
190
216
|
const parseV3 = (manifest: Manifest) => {
|
|
@@ -198,21 +224,7 @@ const parseManifestResource = (resource: any, majorVersion: number): CozyManifes
|
|
|
198
224
|
|
|
199
225
|
modelBuilder.traverseManifest(manifest);
|
|
200
226
|
|
|
201
|
-
const canvases = sourceCanvases.map(
|
|
202
|
-
const images = getImages(c);
|
|
203
|
-
return {
|
|
204
|
-
source: c,
|
|
205
|
-
id: c.id,
|
|
206
|
-
width: c.width,
|
|
207
|
-
height: c.height,
|
|
208
|
-
images,
|
|
209
|
-
annotations: (c.annotations || []),
|
|
210
|
-
getImageURL: images.length > 0 ? images[0].getImageURL : () => undefined,
|
|
211
|
-
getLabel: getLabel(c),
|
|
212
|
-
getMetadata: getMetadata(c),
|
|
213
|
-
getThumbnailURL: getThumbnailURL(c, images)
|
|
214
|
-
} as CozyCanvas;
|
|
215
|
-
});
|
|
227
|
+
const canvases = sourceCanvases.map(parseCanvas);
|
|
216
228
|
|
|
217
229
|
const toRange = (source: Range): CozyRange => {
|
|
218
230
|
const items = source.items || [];
|
package/src/helpers/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type CozyParseResult =
|
|
|
12
12
|
| { type: 'collection', url: string, resource: CozyCollection }
|
|
13
13
|
| { type: 'manifest'; url: string, resource: CozyManifest }
|
|
14
14
|
| { type: 'iiif-image'; url: string, resource: CozyImageResource }
|
|
15
|
+
| { type: 'canvas', resource: CozyCanvas }
|
|
15
16
|
| { type: 'plain-image'; url: string }
|
|
16
17
|
| { type: 'webpage'; url: string }
|
|
17
18
|
| {
|
|
@@ -28,6 +29,8 @@ export interface CozyCollection {
|
|
|
28
29
|
|
|
29
30
|
readonly id: string;
|
|
30
31
|
|
|
32
|
+
readonly type: 'Collection';
|
|
33
|
+
|
|
31
34
|
readonly items: CozyCollectionItem[];
|
|
32
35
|
|
|
33
36
|
getLabel(locale?: string): string | undefined;
|
|
@@ -36,11 +39,11 @@ export interface CozyCollection {
|
|
|
36
39
|
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
export interface
|
|
42
|
+
export interface CozyCollectionManifestItem {
|
|
40
43
|
|
|
41
44
|
readonly id: string;
|
|
42
45
|
|
|
43
|
-
readonly type:
|
|
46
|
+
readonly type: 'Manifest';
|
|
44
47
|
|
|
45
48
|
readonly source: any;
|
|
46
49
|
|
|
@@ -48,6 +51,8 @@ export interface CozyCollectionItem {
|
|
|
48
51
|
|
|
49
52
|
}
|
|
50
53
|
|
|
54
|
+
export type CozyCollectionItem = CozyCollectionManifestItem | CozyCollection;
|
|
55
|
+
|
|
51
56
|
export interface CozyManifest {
|
|
52
57
|
|
|
53
58
|
readonly majorVersion: number;
|
package/test/Cozy.test.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { Cozy, CozyManifest, DynamicImageServiceResource } from '../src';
|
|
2
|
+
import { Cozy, CozyCollection, CozyManifest, DynamicImageServiceResource } from '../src';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
COLLECTION,
|
|
6
|
+
NESTED_COLLECTION,
|
|
6
7
|
INFO_JSON_V3,
|
|
7
8
|
WITH_MULTI_IMAGE,
|
|
8
9
|
WITH_STRUCTURES,
|
|
@@ -14,6 +15,18 @@ describe('Cozy', () => {
|
|
|
14
15
|
it('should parse collection manifests correctly', async () => {
|
|
15
16
|
const result = await Cozy.parseURL(COLLECTION);
|
|
16
17
|
expect(result.type).toBe('collection');
|
|
18
|
+
|
|
19
|
+
const collection = (result as any).resource as CozyCollection;
|
|
20
|
+
expect(collection.items.length).toBe(16);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should parse nested collection manifests correctly', async () => {
|
|
24
|
+
const result = await Cozy.parseURL(NESTED_COLLECTION);
|
|
25
|
+
expect(result.type).toBe('collection');
|
|
26
|
+
|
|
27
|
+
const collection = (result as any).resource as CozyCollection;
|
|
28
|
+
expect(collection.items.length).toBe(7);
|
|
29
|
+
expect(collection.items.every(item => item.type === 'Collection'))
|
|
17
30
|
});
|
|
18
31
|
|
|
19
32
|
it('should parse structures in presentation manifests', async () => {
|
package/test/fixtures.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export const COLLECTION =
|
|
2
2
|
'https://www.davidrumsey.com/luna/servlet/iiif/collection/s/1k986a';
|
|
3
3
|
|
|
4
|
+
export const NESTED_COLLECTION =
|
|
5
|
+
'https://image-ub.bgo1.test.rail.uib.no/iiif/presentation/na/fragmenter/collection.json';
|
|
6
|
+
|
|
4
7
|
export const WITH_STRUCTURES =
|
|
5
8
|
'https://lib.is/IE19255085/manifest';
|
|
6
9
|
|
package/src/helpers/hydrate.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { CozyCanvas } from '../types';
|
|
2
|
-
import {
|
|
3
|
-
getImages,
|
|
4
|
-
getLabel,
|
|
5
|
-
getMetadata,
|
|
6
|
-
getThumbnailURL
|
|
7
|
-
} from '../core';
|
|
8
|
-
|
|
9
|
-
export const hydrateCanvas = (canvas: CozyCanvas): CozyCanvas => {
|
|
10
|
-
const { source } = canvas;
|
|
11
|
-
|
|
12
|
-
const images = getImages(source);
|
|
13
|
-
return {
|
|
14
|
-
source,
|
|
15
|
-
id: source.id,
|
|
16
|
-
width: source.width,
|
|
17
|
-
height: source.height,
|
|
18
|
-
images,
|
|
19
|
-
annotations: (source.annotations || []),
|
|
20
|
-
getImageURL: images.length > 0 ? images[0].getImageURL : () => undefined,
|
|
21
|
-
getLabel: getLabel(source),
|
|
22
|
-
getMetadata: getMetadata(source),
|
|
23
|
-
getThumbnailURL: getThumbnailURL(source, images)
|
|
24
|
-
} as CozyCanvas;
|
|
25
|
-
}
|
|
File without changes
|