cozy-iiif 0.4.1 → 0.4.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 +219 -192
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import { imageSize as
|
2
|
-
import { g, a as
|
3
|
-
import { c as
|
4
|
-
var
|
1
|
+
import { imageSize as le } from "image-size";
|
2
|
+
import { g, a as k, b as S } from "./resource-DS2brz47.js";
|
3
|
+
import { c as Qt } from "./resource-DS2brz47.js";
|
4
|
+
var pe = "http://library.stanford.edu/iiif/image-api/compliance.html#level0", ve = "http://library.stanford.edu/iiif/image-api/compliance.html#level1", F = "http://library.stanford.edu/iiif/image-api/compliance.html#level2", he = "http://library.stanford.edu/iiif/image-api/conformance.html#level0", ue = "http://library.stanford.edu/iiif/image-api/conformance.html#level1", W = "http://library.stanford.edu/iiif/image-api/conformance.html#level2", fe = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0", me = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1", z = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2", ge = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level0", de = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1", H = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2", ye = "http://iiif.io/api/image/1/level0.json", Ae = "http://iiif.io/api/image/1/profiles/level0.json", Ce = "http://iiif.io/api/image/1/level1.json", be = "http://iiif.io/api/image/1/profiles/level1.json", J = "http://iiif.io/api/image/1/level2.json", G = "http://iiif.io/api/image/1/profiles/level2.json", Re = "http://iiif.io/api/image/2/level0.json", Le = "http://iiif.io/api/image/2/profiles/level0.json", we = "http://iiif.io/api/image/2/level1.json", Ie = "http://iiif.io/api/image/2/profiles/level1.json", K = "http://iiif.io/api/image/2/level2.json", Q = "http://iiif.io/api/image/2/profiles/level2.json", Se = "level0", xe = "level1", X = "level2", Te = "http://iiif.io/api/image/2/level0", Me = "http://iiif.io/api/image/2/level1", Y = "http://iiif.io/api/image/2/level2", $e = [Y, F, W, z, H, J, G, K, Q, X], je = [Te, Me, Y, pe, ve, F, he, ue, W, fe, me, z, ge, de, H, ye, Ae, Ce, be, J, G, Re, Le, we, Ie, K, Q, Se, xe, X], ke = je;
|
5
5
|
function d(t) {
|
6
6
|
for (let e in t) (typeof t[e] > "u" || t[e] === null) && delete t[e];
|
7
7
|
return t;
|
@@ -9,35 +9,35 @@ function d(t) {
|
|
9
9
|
function w(t) {
|
10
10
|
return Array.isArray(t) ? t : t ? [t] : [];
|
11
11
|
}
|
12
|
-
var
|
13
|
-
function
|
12
|
+
var Pe = Object.defineProperty, Oe = (t, e, r) => e in t ? Pe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, R = (t, e, r) => (Oe(t, typeof e != "symbol" ? e + "" : e, r), r), E = ["sc:Collection", "sc:Manifest", "sc:Canvas", "sc:AnnotationList", "oa:Annotation", "sc:Range", "sc:Layer", "sc:Sequence", "oa:Choice", "Service", "ContentResource"];
|
13
|
+
function Ue(t) {
|
14
14
|
if (typeof t > "u" || t === null) throw new Error("Null or undefined is not a valid entity.");
|
15
15
|
if (Array.isArray(t)) throw new Error("Array is not a valid entity");
|
16
16
|
if (typeof t != "object") throw new Error(`${typeof t} is not a valid entity`);
|
17
17
|
if (typeof t["@type"] == "string") {
|
18
|
-
let e =
|
19
|
-
if (e !== -1) return
|
18
|
+
let e = E.indexOf(t["@type"]);
|
19
|
+
if (e !== -1) return E[e];
|
20
20
|
}
|
21
21
|
if (t.profile) return "Service";
|
22
22
|
if (t.format || t["@type"]) return "ContentResource";
|
23
23
|
throw new Error("Resource type is not known");
|
24
24
|
}
|
25
|
-
var
|
25
|
+
var De = class Z {
|
26
26
|
constructor(e, r = {}) {
|
27
27
|
R(this, "traversals"), R(this, "options"), this.traversals = { collection: [], manifest: [], canvas: [], annotationList: [], sequence: [], annotation: [], contentResource: [], choice: [], range: [], service: [], layer: [], ...e }, this.options = { convertPropsToArray: !0, mergeMemberProperties: !0, allowUndefinedReturn: !1, ...r };
|
28
28
|
}
|
29
29
|
static all(e) {
|
30
|
-
return new
|
30
|
+
return new Z({ collection: [e], manifest: [e], canvas: [e], annotationList: [e], sequence: [e], annotation: [e], contentResource: [e], choice: [e], range: [e], service: [e], layer: [e] });
|
31
31
|
}
|
32
32
|
traverseCollection(e) {
|
33
33
|
return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseCollectionItems(e))), this.traversals.collection);
|
34
34
|
}
|
35
35
|
traverseCollectionItems(e) {
|
36
36
|
if (this.options.mergeMemberProperties) {
|
37
|
-
let r = [...(e.manifests || []).map((
|
38
|
-
delete e.collections, delete e.manifests, e.members =
|
37
|
+
let r = [...(e.manifests || []).map((n) => typeof n == "string" ? { "@id": n, "@type": "sc:Manifest" } : n), ...(e.collections || []).map((n) => typeof n == "string" ? { "@id": n, "@type": "sc:Collection" } : n), ...e.members || []], i = [], s = r.filter((n) => i.includes(n["@id"]) ? !1 : (i.push(n["@id"]), !0));
|
38
|
+
delete e.collections, delete e.manifests, e.members = s;
|
39
39
|
}
|
40
|
-
return e.manifests && (e.manifests = e.manifests.map((r) => this.traverseManifest(typeof r == "string" ? { "@id": r, "@type": "sc:Manifest" } : r))), e.collections && (e.collections = e.collections.map((r) => this.traverseCollection(typeof r == "string" ? { "@id": r, "@type": "sc:Collection" } : r))), e.members && (e.members = e.members.map((r) => typeof r == "string" ? r : this.traverseUnknown(r))), e;
|
40
|
+
return e.manifests && (e.manifests = e.manifests.map((r) => this.traverseManifest(typeof r == "string" ? { "@id": r, "@type": "sc:Manifest" } : r))), e.collections && (e.collections = e.collections.map((r) => this.traverseCollection(typeof r == "string" ? { "@id": r, "@type": "sc:Collection" } : r))), e.members && (e.members = e.members.map((r) => typeof r == "string" ? r : r["@type"] === "sc:Collection" ? this.traverseCollection(r) : r["@type"] === "sc:Manifest" ? this.traverseManifest(r) : this.traverseUnknown(r))), e;
|
41
41
|
}
|
42
42
|
traverseManifest(e) {
|
43
43
|
return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseManifestItems(e))), this.traversals.manifest);
|
@@ -100,7 +100,7 @@ var Ue = class Y {
|
|
100
100
|
}
|
101
101
|
traverseUnknown(e) {
|
102
102
|
if (!e["@type"] || typeof e == "string") return e;
|
103
|
-
switch (
|
103
|
+
switch (Ue(e)) {
|
104
104
|
case "sc:Collection":
|
105
105
|
return this.traverseCollection(e);
|
106
106
|
case "sc:Manifest":
|
@@ -153,8 +153,8 @@ var Ue = class Y {
|
|
153
153
|
return typeof n > "u" && !this.options.allowUndefinedReturn ? i : n;
|
154
154
|
}, e);
|
155
155
|
}
|
156
|
-
},
|
157
|
-
function
|
156
|
+
}, Ne = "http://library.stanford.edu/iiif/image-api/compliance.html#level1", Ee = "http://library.stanford.edu/iiif/image-api/compliance.html#level2", _e = "http://library.stanford.edu/iiif/image-api/conformance.html#level1", qe = "http://library.stanford.edu/iiif/image-api/conformance.html#level2", Be = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1", Ve = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2", Fe = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1", We = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2", ze = "http://iiif.io/api/image/1/level1.json", He = "http://iiif.io/api/image/1/profiles/level1.json", Je = "http://iiif.io/api/image/1/level2.json", Ge = "http://iiif.io/api/image/1/profiles/level2.json", Ke = "http://iiif.io/api/image/2/level1.json", Qe = "http://iiif.io/api/image/2/profiles/level1.json", Xe = "http://iiif.io/api/image/2/level2.json", Ye = "http://iiif.io/api/image/2/profiles/level2.json", Ze = "level1", et = "level2", tt = "http://iiif.io/api/image/2/level1", rt = "http://iiif.io/api/image/2/level2", it = [tt, rt, Ne, Ee, _e, qe, Be, Ve, Fe, We, ze, He, Je, Ge, Ke, Qe, Xe, Ye, Ze, et], P = { attributionLabel: "Attribution", providerId: "http://example.org/provider", providerName: "" };
|
157
|
+
function st(t) {
|
158
158
|
if (typeof t == "string") return [t];
|
159
159
|
if (!t) return [];
|
160
160
|
let e = Array.isArray(t) ? t : [t], r = [];
|
@@ -169,7 +169,7 @@ function it(t) {
|
|
169
169
|
}
|
170
170
|
function I(t, e = "none") {
|
171
171
|
if (!t) return { none: [""] };
|
172
|
-
let r =
|
172
|
+
let r = st(t), i = {};
|
173
173
|
for (let s of r) {
|
174
174
|
if (typeof s == "string") {
|
175
175
|
i[e] = i[e] ? i[e] : [], i[e].push(s || "");
|
@@ -184,14 +184,14 @@ function I(t, e = "none") {
|
|
184
184
|
}
|
185
185
|
return Object.keys(i).length === 0 ? { none: [""] } : i;
|
186
186
|
}
|
187
|
-
function
|
188
|
-
if (Array.isArray(t)) return
|
187
|
+
function ee(t) {
|
188
|
+
if (Array.isArray(t)) return ee(t.find((e) => typeof e == "string"));
|
189
189
|
if ($e.indexOf(t) !== -1) return "level2";
|
190
|
-
if (
|
191
|
-
if (
|
190
|
+
if (it.indexOf(t) !== -1) return "level1";
|
191
|
+
if (ke.indexOf(t) !== -1) return "level0";
|
192
192
|
if (typeof t == "string") return t;
|
193
193
|
}
|
194
|
-
function
|
194
|
+
function nt(t) {
|
195
195
|
let e = Array.isArray(t) ? t : [t];
|
196
196
|
for (let r of e) switch (r) {
|
197
197
|
case "http://iiif.io/api/image/2/context.json":
|
@@ -204,7 +204,7 @@ function st(t) {
|
|
204
204
|
return "ImageApiSelector";
|
205
205
|
}
|
206
206
|
}
|
207
|
-
function
|
207
|
+
function at(t) {
|
208
208
|
switch (t) {
|
209
209
|
case "http://iiif.io/api/image/2/level0.json":
|
210
210
|
case "http://iiif.io/api/image/2/level1.json":
|
@@ -233,19 +233,19 @@ function nt(t) {
|
|
233
233
|
return "AutoCompleteService1";
|
234
234
|
}
|
235
235
|
}
|
236
|
-
function
|
236
|
+
function _(t) {
|
237
237
|
for (let e of ["sc", "oa", "dcterms", "dctypes", "iiif"]) if (t.startsWith(`${e}:`)) return t.slice(e.length + 1);
|
238
238
|
return t;
|
239
239
|
}
|
240
|
-
var
|
241
|
-
function
|
240
|
+
var ot = ["Collection", "Manifest", "Annotation", "AnnotationPage", "Range", "Service"];
|
241
|
+
function D(t) {
|
242
242
|
let e = t["@id"] || t.id, r = t["@type"] || t.type, i = t.profile || void 0, s = t["@context"] || void 0;
|
243
243
|
if (i) {
|
244
|
-
let n =
|
244
|
+
let n = at(i);
|
245
245
|
if (n) return n;
|
246
246
|
}
|
247
247
|
if (s) {
|
248
|
-
let n =
|
248
|
+
let n = nt(s);
|
249
249
|
if (n) return n;
|
250
250
|
}
|
251
251
|
if (r) {
|
@@ -267,7 +267,7 @@ function U(t) {
|
|
267
267
|
return "TextualBody";
|
268
268
|
}
|
269
269
|
}
|
270
|
-
if (r &&
|
270
|
+
if (r && ot.indexOf(r) !== -1) return r;
|
271
271
|
if (t.format) {
|
272
272
|
if (t.format.startsWith("image/")) return "Image";
|
273
273
|
if (t.format.startsWith("text/") || t.format === "application/pdf") return "Text";
|
@@ -275,15 +275,15 @@ function U(t) {
|
|
275
275
|
}
|
276
276
|
return e && (e.endsWith(".jpg") || e.endsWith(".png") || e.endsWith(".jpeg")) ? "Image" : r || "unknown";
|
277
277
|
}
|
278
|
-
var
|
279
|
-
function
|
280
|
-
let e = t.match(
|
278
|
+
var ct = /http(s)?:\/\/(creativecommons.org|rightsstatements.org)[^"'\\<\n]+/gm;
|
279
|
+
function lt(t) {
|
280
|
+
let e = t.match(ct);
|
281
281
|
return e ? e[0] : t;
|
282
282
|
}
|
283
|
-
function
|
283
|
+
function pt(t, e = "Rights/License", r = "none") {
|
284
284
|
let i = null, s = [], n = Array.isArray(t) ? t : [t];
|
285
|
-
for (let
|
286
|
-
let c =
|
285
|
+
for (let a of n) {
|
286
|
+
let c = a ? lt(a) : void 0;
|
287
287
|
if (c && (c.indexOf("creativecommons.org") !== -1 || c.indexOf("rightsstatements.org") !== -1)) {
|
288
288
|
c.startsWith("https://") ? i = `http://${c.slice(8)}` : i = c;
|
289
289
|
continue;
|
@@ -292,19 +292,19 @@ function lt(t, e = "Rights/License", r = "none") {
|
|
292
292
|
}
|
293
293
|
return [i, s];
|
294
294
|
}
|
295
|
-
var
|
296
|
-
function
|
295
|
+
var vt = ["http://iiif.io/api/presentation/2/context.json", "http://iiif.io/api/image/2/context.json", "http://iiif.io/api/image/1/context.json", "http://library.stanford.edu/iiif/image-api/1.1/context.json", "http://iiif.io/api/search/1/context.json", "http://iiif.io/api/search/0/context.json", "http://iiif.io/api/auth/1/context.json", "http://iiif.io/api/auth/0/context.json", "http://iiif.io/api/annex/openannotation/context.json"];
|
296
|
+
function ht(t) {
|
297
297
|
if (t) {
|
298
298
|
let e = Array.isArray(t) ? t : [t], r = [];
|
299
|
-
for (let i of e) i === "http://iiif.io/api/presentation/2/context.json" && r.push("http://iiif.io/api/presentation/3/context.json"),
|
299
|
+
for (let i of e) i === "http://iiif.io/api/presentation/2/context.json" && r.push("http://iiif.io/api/presentation/3/context.json"), vt.indexOf(i) === -1 && r.push(i);
|
300
300
|
if (e.length) return r.length === 1 ? r[0] : r;
|
301
301
|
}
|
302
302
|
}
|
303
|
-
function
|
303
|
+
function ut(t) {
|
304
304
|
return t ? t.map((e) => ({ label: I(e.label), value: I(e.value) })) : [];
|
305
305
|
}
|
306
306
|
var q = 0;
|
307
|
-
function
|
307
|
+
function te(t, e) {
|
308
308
|
let r = encodeURI(t.id || t["@id"] || "").trim();
|
309
309
|
return r && e ? `${r}/${e}` : r || (q++, `http://example.org/${t["@type"]}${e ? `/${e}` : ""}/${q}`);
|
310
310
|
}
|
@@ -312,16 +312,16 @@ function C(t) {
|
|
312
312
|
let e = [...t.behavior || []];
|
313
313
|
t.viewingHint && e.push(t.viewingHint);
|
314
314
|
let r;
|
315
|
-
return Array.isArray(t.motivation) ? r = t.motivation.map(
|
315
|
+
return Array.isArray(t.motivation) ? r = t.motivation.map(_) : t.motivation && (r = _(t.motivation)), { "@context": t["@context"] ? ht(t["@context"]) : void 0, id: (t["@id"] || te(t)).trim(), type: D(t), behavior: e.length ? e : void 0, height: t.height ? t.height : void 0, width: t.width ? t.width : void 0, motivation: r, viewingDirection: t.viewingDirection, profile: t.profile, format: t.format ? t.format : void 0, duration: void 0, timeMode: void 0 };
|
316
316
|
}
|
317
317
|
function b(t) {
|
318
|
-
let [e, r] =
|
319
|
-
return { rights: e, metadata: i.length ? i : void 0, label: t.label ? I(t.label) : void 0, requiredStatement: t.attribution ? { label: I(
|
318
|
+
let [e, r] = pt(t.license), i = [...t.metadata ? ut(t.metadata) : [], ...r];
|
319
|
+
return { rights: e, metadata: i.length ? i : void 0, label: t.label ? I(t.label) : void 0, requiredStatement: t.attribution ? { label: I(P.attributionLabel), value: I(t.attribution) } : void 0, navDate: t.navDate, summary: t.description ? I(t.description) : void 0, thumbnail: ft(t.thumbnail) };
|
320
320
|
}
|
321
|
-
function
|
321
|
+
function ft(t) {
|
322
322
|
return t && (Array.isArray(t) ? t : [t]).map((e) => typeof e == "string" ? { id: e, type: "Image" } : (e.type === "unknown" && (e.type = "Image"), e));
|
323
323
|
}
|
324
|
-
function
|
324
|
+
function mt(t) {
|
325
325
|
if (!t.within) return;
|
326
326
|
let e = Array.isArray(t.within) ? t.within : [t.within], r = [];
|
327
327
|
for (let i of e) if (typeof i == "string") {
|
@@ -330,26 +330,53 @@ function ft(t) {
|
|
330
330
|
r.push({ id: i, type: "Collection" });
|
331
331
|
break;
|
332
332
|
}
|
333
|
-
} else i["@id"] && r.push({ id: i["@id"], type:
|
333
|
+
} else i["@id"] && r.push({ id: i["@id"], type: D(i) });
|
334
334
|
return r.length ? r : void 0;
|
335
335
|
}
|
336
336
|
function L(t) {
|
337
337
|
let e = t.related ? Array.isArray(t.related) ? t.related : [t.related] : [], r = t.contentLayer;
|
338
|
-
return { provider: t.logo || e.length ? [{ id:
|
338
|
+
return { provider: t.logo || e.length ? [{ id: P.providerId, type: "Agent", homepage: e.length ? [e[0]] : void 0, logo: t.logo ? Array.isArray(t.logo) ? t.logo : [t.logo] : void 0, label: I(P.providerName) }] : void 0, partOf: mt(t), rendering: t.rendering, seeAlso: t.seeAlso, start: t.startCanvas, service: t.service ? w(t.service) : void 0, supplementary: r ? [r] : void 0 };
|
339
339
|
}
|
340
|
-
function
|
340
|
+
function gt(t) {
|
341
341
|
return { chars: t.chars, format: t.format ? t.format : void 0, language: t.language };
|
342
342
|
}
|
343
|
-
function
|
344
|
-
return
|
343
|
+
function $(t, e) {
|
344
|
+
return t ? typeof t == "string" ? { id: t, type: e } : typeof (t == null ? void 0 : t["@id"]) == "string" ? { id: t["@id"], type: e } : typeof t.id == "string" ? { id: t.id, type: e } : null : null;
|
345
345
|
}
|
346
346
|
function dt(t) {
|
347
|
-
let e =
|
348
|
-
|
349
|
-
|
350
|
-
|
347
|
+
let e = {};
|
348
|
+
if (t.first) {
|
349
|
+
let r = $(t.first, "Collection");
|
350
|
+
r && (e.first = r);
|
351
|
+
}
|
352
|
+
if ((t.total || t.total === 0) && (e.total = t.total), t.prev) {
|
353
|
+
let r = $(t.prev, "Collection");
|
354
|
+
r && (e.prev = r);
|
355
|
+
}
|
356
|
+
if (t.next) {
|
357
|
+
let r = $(t.next, "Collection");
|
358
|
+
r && (e.next = r);
|
359
|
+
}
|
360
|
+
return e;
|
351
361
|
}
|
352
362
|
function yt(t) {
|
363
|
+
let e = [];
|
364
|
+
for (let r of t) {
|
365
|
+
let i = { ...r };
|
366
|
+
i.items && i.items.length === 0 && delete i.items, e.push(i);
|
367
|
+
}
|
368
|
+
return e;
|
369
|
+
}
|
370
|
+
function At(t) {
|
371
|
+
return d({ ...C(t), ...b(t), ...L(t), ...dt(t), items: yt(t.members) });
|
372
|
+
}
|
373
|
+
function Ct(t) {
|
374
|
+
let e = [], r = [], i, s;
|
375
|
+
for (let a of t.sequences || []) a.canvases.length && e.push(...a.canvases), a.behavior && r.push(...a.behavior), a.viewingDirection && (s = a.viewingDirection), a.startCanvas && (i = a.startCanvas);
|
376
|
+
let n = C(t);
|
377
|
+
return r.length && (n.behavior ? n.behavior.push(...r) : n.behavior = r), d({ ...n, ...b(t), ...L(t), viewingDirection: s, start: i, items: e, structures: bt(t.structures) });
|
378
|
+
}
|
379
|
+
function bt(t) {
|
353
380
|
if (!t) return t;
|
354
381
|
let e = /* @__PURE__ */ new Map();
|
355
382
|
for (let i of t) e.set(i.id, i);
|
@@ -360,16 +387,16 @@ function yt(t) {
|
|
360
387
|
}
|
361
388
|
return t.filter((i) => r.indexOf(i.id) === -1);
|
362
389
|
}
|
363
|
-
function
|
364
|
-
return d({ ...C(t), ...b(t), ...L(t), annotations: t.otherContent && t.otherContent.length ? t.otherContent : void 0, items: t.images && t.images.length ? [{ id:
|
390
|
+
function Rt(t) {
|
391
|
+
return d({ ...C(t), ...b(t), ...L(t), annotations: t.otherContent && t.otherContent.length ? t.otherContent : void 0, items: t.images && t.images.length ? [{ id: te(t, "annotation-page"), type: "AnnotationPage", items: t.images }] : void 0 });
|
365
392
|
}
|
366
|
-
function
|
393
|
+
function Lt(t) {
|
367
394
|
return d({ ...C(t), ...b(t), ...L(t), items: t.resources && t.resources.length ? t.resources : void 0 });
|
368
395
|
}
|
369
|
-
function
|
370
|
-
return !t.canvases || t.canvases.length === 0 ? { canvases: [], behavior: [] } : { canvases: t.canvases, behavior: t.viewingHint ? [t.viewingHint] : [], startCanvas: t.startCanvas };
|
396
|
+
function wt(t) {
|
397
|
+
return !t.canvases || t.canvases.length === 0 ? { canvases: [], behavior: [] } : { canvases: t.canvases, behavior: t.viewingHint ? [t.viewingHint] : [], viewingDirection: t.viewingDirection, startCanvas: t.startCanvas };
|
371
398
|
}
|
372
|
-
function
|
399
|
+
function It(t) {
|
373
400
|
function e(r) {
|
374
401
|
if (Array.isArray(r)) {
|
375
402
|
if (r.length > 1) return { type: "List", items: r.map(e) };
|
@@ -382,51 +409,51 @@ function Rt(t) {
|
|
382
409
|
else if (r.full["@type"] === "dctypes:Image") i = { id: r.full["@id"], type: "Image" };
|
383
410
|
else if (r.full["@type"] === "sc:Canvas") i = { id: r.full["@id"], type: "Canvas" };
|
384
411
|
else throw new Error(`Unsupported source type on annotation: ${r.full["@type"]}`);
|
385
|
-
return { type: "SpecificResource", source: i, selector:
|
412
|
+
return { type: "SpecificResource", source: i, selector: O(r.selector) };
|
386
413
|
} else return encodeURI(r["@id"]).trim();
|
387
414
|
}
|
388
|
-
return d({ ...C(t), ...b(t), ...L(t), target: e(t.on), body: Array.isArray(t.resource) ? t.resource.map(
|
415
|
+
return d({ ...C(t), ...b(t), ...L(t), target: e(t.on), body: Array.isArray(t.resource) ? t.resource.map(B) : B(t.resource) });
|
389
416
|
}
|
390
|
-
function
|
391
|
-
return t.type === "Choice" ? t :
|
417
|
+
function B(t) {
|
418
|
+
return t.type === "Choice" ? t : re(t);
|
392
419
|
}
|
393
|
-
function
|
420
|
+
function re(t) {
|
394
421
|
let e = t;
|
395
|
-
return d({ ...C(e), ...b(e), ...L(e), ...
|
422
|
+
return d({ ...C(e), ...b(e), ...L(e), ...gt(e) });
|
396
423
|
}
|
397
|
-
function
|
424
|
+
function St(t) {
|
398
425
|
let e = [];
|
399
426
|
return t.default && t.default !== "rdf:nil" && e.push(t.default), t.item && t.item !== "rdf:nil" && e.push(...t.item), d({ ...C(t), ...b(t), items: e });
|
400
427
|
}
|
401
|
-
function
|
428
|
+
function xt(t) {
|
402
429
|
return d({ ...C(t), ...b(t), ...L(t), items: t.members });
|
403
430
|
}
|
404
|
-
function
|
405
|
-
let { "@id": e, "@type": r, "@context": i, profile: s, ...n } = t,
|
406
|
-
return e && (
|
431
|
+
function Tt(t) {
|
432
|
+
let { "@id": e, "@type": r, "@context": i, profile: s, ...n } = t, a = {};
|
433
|
+
return e && (a["@id"] = e), a["@type"] = D(t), a["@type"] === "unknown" && (i && i.length && (a["@context"] = i), a["@type"] = "Service"), s && (a.profile = ee(s)), d({ ...a, ...n });
|
407
434
|
}
|
408
|
-
function
|
435
|
+
function Mt(t) {
|
409
436
|
return d({ ...C(t), ...b(t), ...L(t) });
|
410
437
|
}
|
411
|
-
var
|
412
|
-
function
|
413
|
-
return t && t["@context"] && (t["@context"] === "http://iiif.io/api/presentation/2/context.json" || t["@context"].indexOf("http://iiif.io/api/presentation/2/context.json") !== -1 || t["@context"] === "http://www.shared-canvas.org/ns/context.json") || t["@context"] === "http://iiif.io/api/image/2/context.json" ?
|
438
|
+
var $t = new De({ collection: [At], manifest: [Ct], canvas: [Rt], annotationList: [Lt], sequence: [wt], annotation: [It], contentResource: [re], choice: [St], range: [xt], service: [Tt], layer: [Mt] });
|
439
|
+
function ie(t) {
|
440
|
+
return t && t["@context"] && (t["@context"] === "http://iiif.io/api/presentation/2/context.json" || t["@context"].indexOf("http://iiif.io/api/presentation/2/context.json") !== -1 || t["@context"] === "http://www.shared-canvas.org/ns/context.json") || t["@context"] === "http://iiif.io/api/image/2/context.json" || t["@id"] && t["@type"] === "sc:Collection" || t["@id"] && t["@type"] === "sc:Manifest" ? (t["@context"] || (t["@context"] = "http://iiif.io/api/presentation/2/context.json"), $t.traverseUnknown(t)) : t;
|
414
441
|
}
|
415
|
-
function
|
442
|
+
function O(t) {
|
416
443
|
if ((Array.isArray(t["@type"]) && t["@type"].includes("oa:SvgSelector") || t["@type"] == "oa:SvgSelector") && ("chars" in t || "value" in t)) return { type: "SvgSelector", value: "chars" in t ? t.chars : t.value };
|
417
444
|
if (t["@type"] === "oa:FragmentSelector") return { type: "FragmentSelector", value: t.value };
|
418
|
-
if (t["@type"] === "oa:Choice") return [
|
445
|
+
if (t["@type"] === "oa:Choice") return [O(t.default), ...(Array.isArray(t.item) ? t.item : [t.item]).map(O)];
|
419
446
|
if (t["@type"] == "iiif:ImageApiSelector") return { type: "ImageApiSelector", region: "region" in t ? t.region : void 0, rotation: "rotation" in t ? t.rotation : void 0 };
|
420
447
|
throw new Error(`Unsupported selector type: ${t["@type"]}`);
|
421
448
|
}
|
422
|
-
function
|
449
|
+
function j(t) {
|
423
450
|
return typeof t == "string" ? !1 : t && !t.type && "source" in t ? (t.type = "SpecificResource", !0) : !!t && t.type === "SpecificResource";
|
424
451
|
}
|
425
452
|
function x(...t) {
|
426
453
|
return (e) => t.reduce((r, i) => i(r), e);
|
427
454
|
}
|
428
|
-
var
|
429
|
-
function
|
455
|
+
var V = ["Collection", "Manifest", "Canvas", "AnnotationPage", "AnnotationCollection", "Annotation", "ContentResource", "Range", "Service", "Selector", "Agent"];
|
456
|
+
function jt(t, e) {
|
430
457
|
if (typeof t > "u" || t === null) throw new Error("Null or undefined is not a valid entity.");
|
431
458
|
if (Array.isArray(t)) throw new Error("Array is not a valid entity");
|
432
459
|
if (typeof t != "object") {
|
@@ -434,30 +461,30 @@ function Tt(t, e) {
|
|
434
461
|
throw new Error(`${typeof t} is not a valid entity`);
|
435
462
|
}
|
436
463
|
if (typeof t.type == "string") {
|
437
|
-
let r =
|
438
|
-
if (r !== -1) return
|
464
|
+
let r = V.indexOf(t.type);
|
465
|
+
if (r !== -1) return V[r];
|
439
466
|
}
|
440
467
|
if (t.profile) return "Service";
|
441
468
|
throw new Error("Resource type is not known");
|
442
469
|
}
|
443
|
-
var
|
470
|
+
var N = class se {
|
444
471
|
constructor(e, r = {}) {
|
445
|
-
R(this, "traversals"), R(this, "options"), R(this, "_traverseManifest", x(this.traverseManifestItems.bind(this), this.traverseLinking.bind(this), this.traverseDescriptive.bind(this), this.traverseLinkedCanvases.bind(this), this.traverseManifestStructures.bind(this), this.traverseInlineAnnotationPages.bind(this))), R(this, "_traverseCanvas", x(this.traverseCanvasItems.bind(this), this.traverseLinking.bind(this), this.traverseDescriptive.bind(this), this.traverseLinkedCanvases.bind(this), this.traverseInlineAnnotationPages.bind(this))), R(this, "_traverseAnnotationPage", x(this.traverseAnnotationPageItems.bind(this), this.traverseLinking.bind(this), this.traverseDescriptive.bind(this))), R(this, "_traverseRange", x(this.traverseRangeRanges.bind(this), this.traverseLinking.bind(this), this.traverseDescriptive.bind(this), this.traverseLinkedCanvases.bind(this))), this.traversals = { collection: [], manifest: [], canvas: [], annotationCollection: [], annotationPage: [], annotation: [], contentResource: [], choice: [], range: [], service: [], agent: [], specificResource: [], geoJson: [], ...e }, this.options = { allowUndefinedReturn: !1, ...r };
|
472
|
+
R(this, "traversals"), R(this, "options"), R(this, "_traverseManifest", x(this.traverseManifestItems.bind(this), this.traverseNavPlace.bind(this), this.traverseLinking.bind(this), this.traverseDescriptive.bind(this), this.traverseLinkedCanvases.bind(this), this.traverseManifestStructures.bind(this), this.traverseInlineAnnotationPages.bind(this))), R(this, "_traverseCanvas", x(this.traverseCanvasItems.bind(this), this.traverseLinking.bind(this), this.traverseDescriptive.bind(this), this.traverseLinkedCanvases.bind(this), this.traverseInlineAnnotationPages.bind(this))), R(this, "_traverseAnnotationPage", x(this.traverseAnnotationPageItems.bind(this), this.traverseLinking.bind(this), this.traverseDescriptive.bind(this))), R(this, "_traverseRange", x(this.traverseRangeRanges.bind(this), this.traverseLinking.bind(this), this.traverseDescriptive.bind(this), this.traverseLinkedCanvases.bind(this))), this.traversals = { collection: [], manifest: [], canvas: [], annotationCollection: [], annotationPage: [], annotation: [], contentResource: [], choice: [], range: [], service: [], agent: [], specificResource: [], geoJson: [], ...e }, this.options = { allowUndefinedReturn: !1, ...r };
|
446
473
|
}
|
447
474
|
static all(e) {
|
448
|
-
return new
|
475
|
+
return new se({ collection: [e], manifest: [e], canvas: [e], annotationCollection: [e], annotationPage: [e], annotation: [e], contentResource: [e], choice: [e], range: [e], service: [e], geoJson: [e], specificResource: [e], agent: [e] });
|
449
476
|
}
|
450
477
|
traverseDescriptive(e) {
|
451
478
|
return e.thumbnail && (e.thumbnail = w(e.thumbnail).map((r) => this.traverseType(r, { parent: e }, this.traversals.contentResource))), e.provider && (e.provider = e.provider.map((r) => this.traverseAgent(r, e))), e;
|
452
479
|
}
|
453
480
|
traverseLinking(e) {
|
454
|
-
return e.seeAlso && (e.seeAlso = e.seeAlso.map((r) => this.traverseType(r, { parent: e }, this.traversals.contentResource))), e.service && (e.service = w(e.service).map((r) => this.traverseService(r))), e.services && (e.services = w(e.services).map((r) => this.traverseService(r, e))), e.logo && (e.logo = e.logo.map((r) => this.traverseType(r, { parent: e }, this.traversals.contentResource))), e.homepage && (e.homepage = w(e.homepage).map((r) => this.traverseType(r, { parent: e }, this.traversals.contentResource))), e.partOf && (e.partOf = e.partOf.map((r) => typeof r == "string" || !r.type ? this.traverseType(r, { parent: e }, this.traversals.contentResource) : r.type === "Canvas" ? this.traverseType(r, { parent: e }, this.traversals.canvas) : r.type === "AnnotationCollection" ? this.traverseType(r, { parent: e }, this.traversals.annotationCollection) : r.type === "Collection" ? this.traverseType(r, { parent: e }, this.traversals.collection) : this.traverseType(r, { parent: e }, this.traversals.contentResource))), e.start && (
|
481
|
+
return e.seeAlso && (e.seeAlso = e.seeAlso.map((r) => this.traverseType(r, { parent: e }, this.traversals.contentResource))), e.service && (e.service = w(e.service).map((r) => this.traverseService(r))), e.services && (e.services = w(e.services).map((r) => this.traverseService(r, e))), e.logo && (e.logo = e.logo.map((r) => this.traverseType(r, { parent: e }, this.traversals.contentResource))), e.homepage && (e.homepage = w(e.homepage).map((r) => this.traverseType(r, { parent: e }, this.traversals.contentResource))), e.partOf && (e.partOf = e.partOf.map((r) => typeof r == "string" || !r.type ? this.traverseType(r, { parent: e }, this.traversals.contentResource) : r.type === "Canvas" ? this.traverseType(r, { parent: e }, this.traversals.canvas) : r.type === "AnnotationCollection" ? this.traverseType(r, { parent: e }, this.traversals.annotationCollection) : r.type === "Collection" ? this.traverseType(r, { parent: e }, this.traversals.collection) : this.traverseType(r, { parent: e }, this.traversals.contentResource))), e.start && (j(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 = e.rendering.map((r) => this.traverseType(r, { parent: e }, this.traversals.contentResource))), e.supplementary && (e.supplementary = e.supplementary.map((r) => this.traverseType(r, { parent: e }, this.traversals.contentResource))), e;
|
455
482
|
}
|
456
483
|
traverseCollectionItems(e) {
|
457
484
|
return e.items && e.items.map((r) => r.type === "Collection" ? this.traverseCollection(r) : this.traverseManifest(r)), e;
|
458
485
|
}
|
459
486
|
traverseCollection(e, r) {
|
460
|
-
return this.traverseType(this.traverseDescriptive(this.traverseInlineAnnotationPages(this.traverseLinking(this.traverseLinkedCanvases(this.traverseCollectionItems(e))))), { parent: r }, this.traversals.collection);
|
487
|
+
return this.traverseType(this.traverseDescriptive(this.traverseNavPlace(this.traverseInlineAnnotationPages(this.traverseLinking(this.traverseLinkedCanvases(this.traverseCollectionItems(e)))))), { parent: r }, this.traversals.collection);
|
461
488
|
}
|
462
489
|
traverseGeoJson(e, r) {
|
463
490
|
return this.traverseType(e, { parent: r }, this.traversals.geoJson);
|
@@ -502,14 +529,14 @@ var D = class ie {
|
|
502
529
|
return typeof e == "string" || !e || e && e.service && (e.service = w(e.service || []).map((r) => this.traverseService(r, e))), e;
|
503
530
|
}
|
504
531
|
traverseContentResource(e, r) {
|
505
|
-
return e.type === "Choice" && (e.items = e.items.map((i) => this.traverseContentResource(i, e))),
|
532
|
+
return e.type === "Choice" && (e.items = e.items.map((i) => this.traverseContentResource(i, e))), j(e) ? this.traverseSpecificResource(e, "ContentResource") : this.traverseType(this.traverseInlineAnnotationPages(this.traverseContentResourceLinking(e)), { parent: r }, this.traversals.contentResource);
|
506
533
|
}
|
507
534
|
traverseSpecificResource(e, r, i) {
|
508
535
|
let s = e.source;
|
509
536
|
return typeof e.source == "string" && (s = { id: e.source, type: r || "unknown" }), this.traverseType({ ...e, source: r === "Canvas" || s.type === "Canvas" ? this.traverseType(s, { parent: i }, this.traversals.canvas) : r === "ContentResource" ? this.traverseContentResource(s, { parent: i }) : this.traverseUnknown(s, { parent: i, typeHint: r }) }, { parent: i }, this.traversals.specificResource);
|
510
537
|
}
|
511
538
|
traverseRangeRanges(e) {
|
512
|
-
return e.items && (e.items = e.items.map((r) => typeof r == "string" ? this.traverseCanvas({ id: r, type: "Canvas" }, e) :
|
539
|
+
return e.items && (e.items = e.items.map((r) => typeof r == "string" ? this.traverseCanvas({ id: r, type: "Canvas" }, e) : j(r) ? this.traverseSpecificResource(r, "Canvas", e) : r.type === "Manifest" ? this.traverseManifest(r, e) : this.traverseRange(r, e))), e;
|
513
540
|
}
|
514
541
|
traverseRange(e, r) {
|
515
542
|
return this.traverseType(this._traverseRange(e), { parent: r }, this.traversals.range);
|
@@ -519,8 +546,8 @@ var D = class ie {
|
|
519
546
|
}
|
520
547
|
traverseType(e, r, i) {
|
521
548
|
return i.reduce((s, n) => {
|
522
|
-
let
|
523
|
-
return typeof
|
549
|
+
let a = n(s, r);
|
550
|
+
return typeof a > "u" && !this.options.allowUndefinedReturn ? s : a;
|
524
551
|
}, e);
|
525
552
|
}
|
526
553
|
traverseService(e, r) {
|
@@ -528,7 +555,7 @@ var D = class ie {
|
|
528
555
|
return i && i.service && (i.service = w(i.service).map((s) => this.traverseService(s))), this.traverseType(i, { parent: r }, this.traversals.service);
|
529
556
|
}
|
530
557
|
traverseUnknown(e, { parent: r, typeHint: i } = {}) {
|
531
|
-
let s =
|
558
|
+
let s = jt(e, i);
|
532
559
|
switch (s) {
|
533
560
|
case "Collection":
|
534
561
|
return this.traverseCollection(e, r);
|
@@ -553,88 +580,88 @@ var D = class ie {
|
|
553
580
|
}
|
554
581
|
}
|
555
582
|
};
|
556
|
-
const
|
583
|
+
const ne = (t) => g(t, "type").startsWith("ImageService") || t.profile && t.profile.toString().includes("iiif.io/api/image/"), ae = (t) => {
|
557
584
|
const e = g(t, "type"), r = g(t, "context");
|
558
585
|
if (e === "ImageService2" || r != null && r.includes("image/2")) {
|
559
586
|
const i = t, s = ["level0", "level1", "level2"];
|
560
|
-
return { majorVersion: 2, profileLevel: (Array.isArray(i.profile) ? i.profile : [i.profile]).map((c) => s.findIndex((
|
587
|
+
return { majorVersion: 2, profileLevel: (Array.isArray(i.profile) ? i.profile : [i.profile]).map((c) => s.findIndex((o) => c.toString().includes(o))).filter((c) => c > -1).sort((c, o) => o - c)[0] };
|
561
588
|
} else if (e || r)
|
562
589
|
return { majorVersion: 3, profileLevel: parseInt(t.profile) };
|
563
|
-
},
|
590
|
+
}, U = (t, e, r) => {
|
564
591
|
const i = g(t, "id"), s = t.profile || "";
|
565
592
|
if (typeof s == "string" && (s.includes("level0") || s.includes("level:0"))) {
|
566
593
|
if ("sizes" in t && Array.isArray(t.sizes)) {
|
567
|
-
const
|
568
|
-
if (
|
569
|
-
return `${i}/full/${
|
594
|
+
const a = t.sizes.sort((c, o) => o.width * o.height - c.width * c.height).filter((c) => c.width * c.height >= e * r)[0];
|
595
|
+
if (a)
|
596
|
+
return `${i}/full/${a.width},${a.height}/0/default.jpg`;
|
570
597
|
}
|
571
598
|
return `${i}/full/full/0/default.jpg`;
|
572
599
|
}
|
573
600
|
return `${i}/full/!${e},${r}/0/default.jpg`;
|
574
|
-
},
|
601
|
+
}, kt = (t, e, r = { minSize: 400 }) => {
|
575
602
|
const i = g(t, "id"), s = t.profile || "";
|
576
603
|
if (typeof s == "string" && (s.includes("level0") || s.includes("level:0"))) {
|
577
604
|
console.warn(`Level 0 image service does not support custom region URLs: ${i}`);
|
578
605
|
return;
|
579
606
|
}
|
580
|
-
const { x:
|
607
|
+
const { x: a, y: c, w: o, h: p } = e, { minSize: u = 400, maxSize: v } = r, m = o / p, l = m < 1;
|
581
608
|
let f = Math.ceil(l ? u / m : u), h = Math.ceil(l ? u : u / m);
|
582
609
|
v && (h > v || f > v) && (l ? (f = Math.min(f, v), h = Math.ceil(f * m)) : (h = Math.min(h, v), f = Math.ceil(h / m)));
|
583
|
-
const y = `${Math.round(
|
610
|
+
const y = `${Math.round(a)},${Math.round(c)},${Math.round(o)},${Math.round(p)}`;
|
584
611
|
return `${i}/${y}/!${h},${f}/0/default.jpg`;
|
585
|
-
},
|
612
|
+
}, Pt = (t) => (e, r = { minSize: 400 }) => {
|
586
613
|
if (t.type === "dynamic")
|
587
|
-
return
|
614
|
+
return kt(t.service, e, r);
|
588
615
|
console.error("Level 0 or static image canvas: unsupported");
|
589
|
-
},
|
616
|
+
}, Ot = (t, e = []) => (r = 400) => {
|
590
617
|
const { width: i, height: s } = t;
|
591
618
|
if (!i || !s) return;
|
592
|
-
const n = i / s,
|
619
|
+
const n = i / s, a = n < 1, c = Math.ceil(a ? r / n : r), o = Math.ceil(a ? r : r / n);
|
593
620
|
if (t.thumbnail && t.thumbnail.length > 0) {
|
594
621
|
const p = t.thumbnail[0];
|
595
622
|
if ("service" in p && Array.isArray(p.service)) {
|
596
|
-
const u = p.service.find((v) =>
|
623
|
+
const u = p.service.find((v) => ne(v));
|
597
624
|
if (u)
|
598
|
-
return
|
625
|
+
return U(u, o, c);
|
599
626
|
}
|
600
627
|
if ("id" in p) return p.id;
|
601
628
|
}
|
602
629
|
for (const p of e) {
|
603
630
|
if (p.type === "dynamic" || p.type === "level0")
|
604
|
-
return
|
631
|
+
return U(p.service, o, c);
|
605
632
|
if (p.type === "static")
|
606
633
|
return p.url;
|
607
634
|
}
|
608
|
-
},
|
635
|
+
}, oe = (t) => t.endsWith("/info.json") ? t : `${t.endsWith("/") ? t : `${t}/`}info.json`, Ut = (t, e, r) => (i = 800) => {
|
609
636
|
if (!t || !e) return;
|
610
|
-
const s = t / e, n = s < 1,
|
611
|
-
return
|
612
|
-
},
|
637
|
+
const s = t / e, n = s < 1, a = Math.ceil(n ? i / s : i), c = Math.ceil(n ? i : i / s);
|
638
|
+
return U(r, c, a);
|
639
|
+
}, Dt = (t) => () => fetch(t).then((e) => e.json()).then((e) => {
|
613
640
|
const r = e.width, i = e.height;
|
614
641
|
return r !== void 0 && i !== void 0 ? { width: r, height: i } : void 0;
|
615
|
-
}),
|
642
|
+
}), Nt = (t) => () => {
|
616
643
|
const e = typeof window < "u";
|
617
644
|
return fetch(t).then((r) => r.blob()).then((r) => e ? createImageBitmap(r).then((i) => {
|
618
645
|
const { width: s, height: n } = i;
|
619
646
|
return i.close(), { width: s, height: n };
|
620
|
-
}) : r.arrayBuffer().then((i) =>
|
621
|
-
},
|
622
|
-
const { format: e, height: r, width: i } = t, s = g(t, "id"), n = (t.service || []).find(
|
623
|
-
if (n &&
|
624
|
-
const c =
|
647
|
+
}) : r.arrayBuffer().then((i) => le(new Uint8Array(i))));
|
648
|
+
}, Et = (t) => {
|
649
|
+
const { format: e, height: r, width: i } = t, s = g(t, "id"), n = (t.service || []).find(ne), a = n ? ae(n) : void 0;
|
650
|
+
if (n && a) {
|
651
|
+
const c = oe(g(n, "id")), o = {
|
625
652
|
source: t,
|
626
|
-
type:
|
653
|
+
type: a.profileLevel === 0 ? "level0" : "dynamic",
|
627
654
|
service: n,
|
628
655
|
width: i,
|
629
656
|
height: r,
|
630
|
-
majorVersion:
|
657
|
+
majorVersion: a.majorVersion,
|
631
658
|
serviceUrl: c,
|
632
|
-
getImageURL:
|
633
|
-
getPixelSize:
|
659
|
+
getImageURL: Ut(i, r, n),
|
660
|
+
getPixelSize: Dt(c)
|
634
661
|
};
|
635
|
-
return
|
636
|
-
...
|
637
|
-
getRegionURL:
|
662
|
+
return a.profileLevel === 0 ? o : {
|
663
|
+
...o,
|
664
|
+
getRegionURL: Pt(o)
|
638
665
|
};
|
639
666
|
} else
|
640
667
|
return {
|
@@ -645,32 +672,32 @@ const se = (t) => g(t, "type").startsWith("ImageService") || t.profile && t.prof
|
|
645
672
|
url: s,
|
646
673
|
format: e,
|
647
674
|
getImageURL: () => s,
|
648
|
-
getPixelSize:
|
675
|
+
getPixelSize: Nt(s)
|
649
676
|
};
|
650
|
-
},
|
677
|
+
}, _t = (t) => {
|
651
678
|
const e = [];
|
652
|
-
return new
|
679
|
+
return new N({
|
653
680
|
annotation: [(i) => {
|
654
681
|
if (i.motivation === "painting" || !i.motivation) {
|
655
|
-
const n = (i.body ? Array.isArray(i.body) ? i.body : [i.body] : []).filter((
|
656
|
-
e.push(...n.map((
|
682
|
+
const n = (i.body ? Array.isArray(i.body) ? i.body : [i.body] : []).filter((a) => a.type === "Image");
|
683
|
+
e.push(...n.map((a) => Et(a)));
|
657
684
|
}
|
658
685
|
}]
|
659
686
|
}).traverseCanvas(t), e;
|
660
|
-
},
|
661
|
-
const e = /* @__PURE__ */ new Map(), r = (
|
687
|
+
}, qt = (t) => () => {
|
688
|
+
const e = /* @__PURE__ */ new Map(), r = (o, p, u = 0) => {
|
662
689
|
const v = {
|
663
|
-
id:
|
690
|
+
id: o.id,
|
664
691
|
type: "range",
|
665
|
-
source:
|
692
|
+
source: o,
|
666
693
|
children: [],
|
667
694
|
navItems: [],
|
668
695
|
navSections: [],
|
669
696
|
parent: p,
|
670
697
|
level: u,
|
671
|
-
getLabel:
|
698
|
+
getLabel: o.getLabel
|
672
699
|
};
|
673
|
-
|
700
|
+
o.items && o.items.length > 0 && o.items.forEach((h) => {
|
674
701
|
if (h.source.type === "Range") {
|
675
702
|
const T = r(h, v, u + 1);
|
676
703
|
v.children.push(T);
|
@@ -692,19 +719,19 @@ const se = (t) => g(t, "type").startsWith("ImageService") || t.profile && t.prof
|
|
692
719
|
const m = v.children.map((h) => h.type === "canvas" ? h.source : h.children.length === 1 && h.children[0].type === "canvas" ? h.children[0].source : h.source), l = m.filter((h) => h.source.type === "Canvas"), f = m.filter((h) => h.source.type === "Range");
|
693
720
|
return v.navItems.push(...l), v.navSections.push(...f), e.set(v.id, v), v;
|
694
721
|
};
|
695
|
-
return { root: t.filter((
|
722
|
+
return { root: t.filter((o) => {
|
696
723
|
var p;
|
697
|
-
return (p =
|
698
|
-
}).map((
|
724
|
+
return (p = o.source.behavior) == null ? void 0 : p.includes("top");
|
725
|
+
}).map((o) => r(o, void 0)), enumerateNodes: (o) => {
|
699
726
|
const p = Array.from(e.values());
|
700
|
-
return
|
701
|
-
}, getBreadcrumbs: (
|
702
|
-
const p = e.get(
|
727
|
+
return o ? p.filter((u) => u.type === o) : p;
|
728
|
+
}, getBreadcrumbs: (o) => {
|
729
|
+
const p = e.get(o);
|
703
730
|
if (!p) return [];
|
704
731
|
const u = (v, m = []) => v.parent ? u(v.parent, [v, ...m]) : [v, ...m];
|
705
732
|
return u(p);
|
706
|
-
}, getNode: (
|
707
|
-
},
|
733
|
+
}, getNode: (o) => e.get(o) };
|
734
|
+
}, Bt = async (t) => {
|
708
735
|
try {
|
709
736
|
new URL(t);
|
710
737
|
} catch {
|
@@ -742,7 +769,7 @@ const se = (t) => g(t, "type").startsWith("ImageService") || t.profile && t.prof
|
|
742
769
|
};
|
743
770
|
try {
|
744
771
|
const i = await e.json();
|
745
|
-
return
|
772
|
+
return ce(i, t);
|
746
773
|
} catch {
|
747
774
|
return {
|
748
775
|
type: "error",
|
@@ -750,8 +777,8 @@ const se = (t) => g(t, "type").startsWith("ImageService") || t.profile && t.prof
|
|
750
777
|
message: "Could not parse resource"
|
751
778
|
};
|
752
779
|
}
|
753
|
-
},
|
754
|
-
const r = Array.isArray(t["@context"]) ? t["@context"].find((s) => s.includes("iiif.io/api/")) : t["@context"];
|
780
|
+
}, ce = (t, e) => {
|
781
|
+
const r = Array.isArray(t["@context"]) ? t["@context"].find((s) => s.includes("iiif.io/api/presentation") || s.includes("iiif.io/api/image")) : t["@context"];
|
755
782
|
if (!r)
|
756
783
|
return {
|
757
784
|
type: "error",
|
@@ -770,15 +797,15 @@ const se = (t) => g(t, "type").startsWith("ImageService") || t.profile && t.prof
|
|
770
797
|
return g(t, "type").includes("Collection") ? {
|
771
798
|
type: "collection",
|
772
799
|
url: e || i,
|
773
|
-
resource:
|
800
|
+
resource: Vt(t, s)
|
774
801
|
} : {
|
775
802
|
type: "manifest",
|
776
803
|
url: e || i,
|
777
|
-
resource:
|
804
|
+
resource: Ft(t, s)
|
778
805
|
};
|
779
806
|
}
|
780
807
|
if (r.includes("image/2") || r.includes("image/3")) {
|
781
|
-
const s =
|
808
|
+
const s = Wt(t);
|
782
809
|
return s ? {
|
783
810
|
type: "iiif-image",
|
784
811
|
url: e || i,
|
@@ -794,39 +821,39 @@ const se = (t) => g(t, "type").startsWith("ImageService") || t.profile && t.prof
|
|
794
821
|
code: "INVALID_MANIFEST",
|
795
822
|
message: "JSON resource is not a recognized IIIF format"
|
796
823
|
};
|
797
|
-
},
|
824
|
+
}, Vt = (t, e) => {
|
798
825
|
const r = (n) => {
|
799
|
-
const
|
800
|
-
return new
|
801
|
-
manifest: [(
|
802
|
-
}).traverseCollection(n),
|
803
|
-
id:
|
804
|
-
type:
|
805
|
-
getLabel: S(
|
806
|
-
source:
|
826
|
+
const a = [];
|
827
|
+
return new N({
|
828
|
+
manifest: [(o) => a.push(o)]
|
829
|
+
}).traverseCollection(n), a.map((o) => ({
|
830
|
+
id: o.id,
|
831
|
+
type: o.type,
|
832
|
+
getLabel: S(o),
|
833
|
+
source: o
|
807
834
|
}));
|
808
|
-
}, i = e === 2 ?
|
835
|
+
}, i = e === 2 ? ie(t) : t, s = r(i);
|
809
836
|
return {
|
810
837
|
source: i,
|
811
838
|
id: i.id,
|
812
839
|
majorVersion: e,
|
813
840
|
items: s,
|
814
841
|
getLabel: S(i),
|
815
|
-
getMetadata:
|
842
|
+
getMetadata: k(i)
|
816
843
|
};
|
817
|
-
},
|
818
|
-
const r = (
|
819
|
-
const c = [],
|
820
|
-
new
|
844
|
+
}, Ft = (t, e) => {
|
845
|
+
const r = (a) => {
|
846
|
+
const c = [], o = [];
|
847
|
+
new N({
|
821
848
|
canvas: [(l) => {
|
822
849
|
l.items && c.push(l);
|
823
850
|
}],
|
824
851
|
range: [(l) => {
|
825
|
-
l.type === "Range" &&
|
852
|
+
l.type === "Range" && o.push(l);
|
826
853
|
}]
|
827
|
-
}).traverseManifest(
|
854
|
+
}).traverseManifest(a);
|
828
855
|
const u = c.map((l) => {
|
829
|
-
const f =
|
856
|
+
const f = _t(l);
|
830
857
|
return {
|
831
858
|
source: l,
|
832
859
|
id: l.id,
|
@@ -837,23 +864,23 @@ const se = (t) => g(t, "type").startsWith("ImageService") || t.profile && t.prof
|
|
837
864
|
getImageURL: f.length > 0 ? f[0].getImageURL : () => {
|
838
865
|
},
|
839
866
|
getLabel: S(l),
|
840
|
-
getMetadata:
|
841
|
-
getThumbnailURL:
|
867
|
+
getMetadata: k(l),
|
868
|
+
getThumbnailURL: Ot(l, f)
|
842
869
|
};
|
843
870
|
}), v = (l) => {
|
844
|
-
const f = l.items || [], h = f.filter((A) => A.type === "Canvas").map((A) => u.find((
|
871
|
+
const f = l.items || [], h = f.filter((A) => A.type === "Canvas").map((A) => u.find((M) => M.id === A.id)).filter(Boolean), y = f.filter((A) => A.type === "Range").map((A) => v(A)), T = [...h, ...y];
|
845
872
|
return {
|
846
873
|
source: l,
|
847
874
|
id: l.id,
|
848
875
|
// Maintain original order
|
849
|
-
items: f.map((A) => T.find((
|
876
|
+
items: f.map((A) => T.find((M) => M.id === A.id)),
|
850
877
|
canvases: h,
|
851
878
|
ranges: y,
|
852
879
|
getLabel: S(l)
|
853
880
|
};
|
854
|
-
}, m =
|
881
|
+
}, m = o.map((l) => v(l));
|
855
882
|
return { canvases: u, ranges: m };
|
856
|
-
}, i = e === 2 ?
|
883
|
+
}, i = e === 2 ? ie(t) : t, { canvases: s, ranges: n } = r(i);
|
857
884
|
return {
|
858
885
|
source: i,
|
859
886
|
id: i.id,
|
@@ -861,11 +888,11 @@ const se = (t) => g(t, "type").startsWith("ImageService") || t.profile && t.prof
|
|
861
888
|
canvases: s,
|
862
889
|
structure: n,
|
863
890
|
getLabel: S(i),
|
864
|
-
getMetadata:
|
865
|
-
getTableOfContents:
|
891
|
+
getMetadata: k(i),
|
892
|
+
getTableOfContents: qt(n)
|
866
893
|
};
|
867
|
-
},
|
868
|
-
const { width: e, height: r } = t, i =
|
894
|
+
}, Wt = (t) => {
|
895
|
+
const { width: e, height: r } = t, i = ae(t);
|
869
896
|
if (i)
|
870
897
|
return {
|
871
898
|
type: i.profileLevel === 0 ? "level0" : "dynamic",
|
@@ -873,22 +900,22 @@ const se = (t) => g(t, "type").startsWith("ImageService") || t.profile && t.prof
|
|
873
900
|
width: e,
|
874
901
|
height: r,
|
875
902
|
majorVersion: i.majorVersion,
|
876
|
-
serviceUrl:
|
903
|
+
serviceUrl: oe(g(t, "id"))
|
877
904
|
};
|
878
|
-
},
|
905
|
+
}, Jt = { parse: ce, parseURL: Bt };
|
879
906
|
export {
|
880
|
-
|
881
|
-
|
882
|
-
|
907
|
+
Jt as Cozy,
|
908
|
+
U as getImageURLFromService,
|
909
|
+
_t as getImages,
|
883
910
|
S as getLabel,
|
884
|
-
|
911
|
+
k as getMetadata,
|
885
912
|
g as getPropertyValue,
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
913
|
+
Pt as getRegionURL,
|
914
|
+
kt as getRegionURLFromService,
|
915
|
+
Qt as getStringValue,
|
916
|
+
qt as getTableOfContents,
|
917
|
+
Ot as getThumbnailURL,
|
918
|
+
ne as isImageService,
|
919
|
+
oe as normalizeServiceUrl,
|
920
|
+
ae as parseImageService
|
894
921
|
};
|
package/package.json
CHANGED