cozy-iiif 0.6.3 → 0.7.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/Cozy.d.ts +1 -1
- package/dist/core/canvas.d.ts +2 -2
- package/dist/core/image-service.d.ts +2 -2
- package/dist/core/manifest.d.ts +1 -1
- package/dist/core/resource.d.ts +2 -2
- package/dist/helpers/fetch-annotations.d.ts +2 -2
- package/dist/helpers/import-annotations.d.ts +2 -2
- package/dist/helpers/index.js +28 -29
- package/dist/helpers/test-cors.d.ts +1 -1
- package/dist/index-B2EdkMiz.js +156 -0
- package/dist/index.js +66 -79
- package/dist/level-0/crop-region.d.ts +1 -1
- package/dist/level-0/fetch-image-info.d.ts +2 -2
- package/dist/level-0/get-thumbnail.d.ts +2 -2
- package/dist/level-0/index.js +1 -1
- package/dist/level-0/throttled-loader.d.ts +1 -1
- package/dist/types.d.ts +2 -2
- package/package.json +5 -5
- package/src/types.ts +1 -1
- package/tsconfig.json +4 -0
- package/vite.config.ts +0 -2
- package/dist/index-CNJsBGB0.js +0 -156
package/dist/Cozy.d.ts
CHANGED
package/dist/core/canvas.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Canvas } from '@iiif/presentation-3';
|
|
2
|
-
import { CozyImageResource } from '../types';
|
|
1
|
+
import type { Canvas } from '@iiif/presentation-3';
|
|
2
|
+
import type { CozyImageResource } from '../types';
|
|
3
3
|
export declare const getThumbnailURL: (canvas: Canvas, images?: CozyImageResource[]) => (minSize?: number) => string | undefined;
|
|
4
4
|
export declare const getImages: (canvas: Canvas) => CozyImageResource[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ImageService2, ImageService3, Service } from '@iiif/presentation-3';
|
|
2
|
-
import { Bounds, CozyImageResource, GetRegionURLOpts } from '../types';
|
|
1
|
+
import type { ImageService2, ImageService3, Service } from '@iiif/presentation-3';
|
|
2
|
+
import type { Bounds, CozyImageResource, GetRegionURLOpts } from '../types';
|
|
3
3
|
type ImageService = ImageService2 | ImageService3;
|
|
4
4
|
export declare const normalizeServiceUrl: (url: string) => string;
|
|
5
5
|
export declare const isImageService: (data: any) => data is ImageService;
|
package/dist/core/manifest.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CozyRange, CozyTOC } from '../types';
|
|
1
|
+
import type { CozyRange, CozyTOC } from '../types';
|
|
2
2
|
export declare const getTableOfContents: (ranges: CozyRange[]) => () => CozyTOC;
|
package/dist/core/resource.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InternationalString } from '@iiif/presentation-3';
|
|
2
|
-
import { CozyMetadata } from '../types';
|
|
1
|
+
import type { InternationalString } from '@iiif/presentation-3';
|
|
2
|
+
import type { CozyMetadata } from '../types';
|
|
3
3
|
export declare const getPropertyValue: <T extends unknown = any>(data: any, name: string) => T;
|
|
4
4
|
export declare const getStringValue: (propertyValue: string | InternationalString, locale?: string) => string | undefined;
|
|
5
5
|
export declare const getLabel: (data: any) => (locale?: string) => string | undefined;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Annotation, AnnotationPage } from '@iiif/presentation-3';
|
|
2
|
-
import { CozyCanvas } from '../types';
|
|
1
|
+
import type { Annotation, AnnotationPage } from '@iiif/presentation-3';
|
|
2
|
+
import type { CozyCanvas } from '../types';
|
|
3
3
|
export declare const fetchAnnotations: (arg: CozyCanvas | AnnotationPage) => Promise<Annotation[]>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Annotation } from '@iiif/presentation-3';
|
|
2
|
-
import { CozyCanvas, CozyManifest } from '../types';
|
|
1
|
+
import type { Annotation } from '@iiif/presentation-3';
|
|
2
|
+
import type { CozyCanvas, CozyManifest } from '../types';
|
|
3
3
|
export declare const importAnnotations: <T extends CozyManifest | CozyCanvas>(resource: T, annotations: Annotation[], namespace?: string) => T extends CozyCanvas ? CozyCanvas : CozyManifest;
|
package/dist/helpers/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as f } from "../index-
|
|
1
|
+
import { p as f } from "../index-B2EdkMiz.js";
|
|
2
2
|
const y = f({
|
|
3
3
|
limit: 4,
|
|
4
4
|
interval: 1e3
|
|
@@ -6,15 +6,15 @@ const y = f({
|
|
|
6
6
|
if (t.items)
|
|
7
7
|
return Promise.resolve(t.items);
|
|
8
8
|
if (t.partOf) {
|
|
9
|
-
const r = y((n,
|
|
10
|
-
const
|
|
11
|
-
return s.next ? r(s.next,
|
|
9
|
+
const r = y((n, i = []) => fetch(n).then((s) => s.json()).then((s) => {
|
|
10
|
+
const o = [...i, ...s.items || []];
|
|
11
|
+
return s.next ? r(s.next, o) : o;
|
|
12
12
|
}));
|
|
13
13
|
if (!Array.isArray(t.partOf)) throw new Error("Referenced annotation collection is invalid");
|
|
14
|
-
return t.partOf.length === 0 ? (console.warn("Annotation page references 0 collections"), Promise.resolve([])) : t.partOf.reduce((n,
|
|
14
|
+
return t.partOf.length === 0 ? (console.warn("Annotation page references 0 collections"), Promise.resolve([])) : t.partOf.reduce((n, i) => n.then((s) => typeof i.first == "string" ? r(i.first).then((o) => [...s, ...o]) : (console.warn("Unsupported `first` arg", i.first), s)), Promise.resolve([])).then((n) => n.filter((i) => p(i, e)));
|
|
15
15
|
} else
|
|
16
|
-
return fetch(t.id).then((r) => r.json()).then((r) => (r.items || []).filter((n) =>
|
|
17
|
-
},
|
|
16
|
+
return fetch(t.id).then((r) => r.json()).then((r) => (r.items || []).filter((n) => p(n, e))).catch((r) => (console.error(r), console.warn(`Could not resolve referenced annotation page: ${t.id}`), []));
|
|
17
|
+
}, p = (t, e) => !e || !t.target ? !0 : (Array.isArray(t.target) ? t.target : [t.target]).some((n) => "source" in n ? typeof n.source == "string" ? n.source === e : n.source.id === e : !0), T = (t) => "type" in t && t.type === "AnnotationPage" ? g(t) : t.annotations.reduce((e, r) => e.then((n) => g(r, t.id).then((i) => [...n, ...i])), Promise.resolve([])), u = [];
|
|
18
18
|
for (let t = 0; t < 256; ++t)
|
|
19
19
|
u.push((t + 256).toString(16).slice(1));
|
|
20
20
|
function b(t, e = 0) {
|
|
@@ -30,36 +30,35 @@ function U() {
|
|
|
30
30
|
}
|
|
31
31
|
return d(w);
|
|
32
32
|
}
|
|
33
|
-
const x = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto),
|
|
33
|
+
const x = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), h = { randomUUID: x };
|
|
34
34
|
function A(t, e, r) {
|
|
35
|
-
var o;
|
|
36
35
|
t = t || {};
|
|
37
|
-
const n = t.random ??
|
|
36
|
+
const n = t.random ?? t.rng?.() ?? U();
|
|
38
37
|
if (n.length < 16)
|
|
39
38
|
throw new Error("Random bytes length must be >= 16");
|
|
40
39
|
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, b(n);
|
|
41
40
|
}
|
|
42
41
|
function R(t, e, r) {
|
|
43
|
-
return
|
|
42
|
+
return h.randomUUID && !t ? h.randomUUID() : A(t);
|
|
44
43
|
}
|
|
45
|
-
const
|
|
44
|
+
const a = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), $ = (t, e) => {
|
|
46
45
|
if (e) {
|
|
47
46
|
const r = t.annotations;
|
|
48
47
|
if (r.length > 0) {
|
|
49
|
-
const n = new RegExp(`${
|
|
50
|
-
const c =
|
|
48
|
+
const n = new RegExp(`${a(t.id)}/${a(e)}/page/p(\\d+)$`), i = r.reduce((s, o) => {
|
|
49
|
+
const c = o.id.match(n);
|
|
51
50
|
if (c && c[1]) {
|
|
52
51
|
const l = parseInt(c[1]);
|
|
53
52
|
return Math.max(s, l);
|
|
54
53
|
} else
|
|
55
54
|
return s;
|
|
56
55
|
}, 1);
|
|
57
|
-
return `${t.id}/${e}/annotations/page/p${
|
|
56
|
+
return `${t.id}/${e}/annotations/page/p${i}`;
|
|
58
57
|
} else
|
|
59
58
|
return `${t.id}/${e}/annotations/page/p1`;
|
|
60
59
|
} else
|
|
61
60
|
return `${t.id}/annotations/page/${R()}`;
|
|
62
|
-
},
|
|
61
|
+
}, m = (t, e, r) => {
|
|
63
62
|
const n = {
|
|
64
63
|
id: $(t, r),
|
|
65
64
|
type: "AnnotationPage",
|
|
@@ -80,21 +79,21 @@ const m = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), $ = (t, e) => {
|
|
|
80
79
|
getThumbnailURL: t.getThumbnailURL
|
|
81
80
|
};
|
|
82
81
|
}, O = (t, e, r) => {
|
|
83
|
-
const n = (
|
|
84
|
-
const c =
|
|
82
|
+
const n = (o) => {
|
|
83
|
+
const c = o.target;
|
|
85
84
|
if (c)
|
|
86
85
|
return typeof c == "string" ? c.substring(0, c.indexOf("#")) : c.source;
|
|
87
|
-
},
|
|
86
|
+
}, i = e.reduce((o, c) => {
|
|
88
87
|
const l = n(c);
|
|
89
|
-
return l && (
|
|
90
|
-
}, {}), s = t.canvases.map((
|
|
91
|
-
const c = o
|
|
92
|
-
return c.length > 0 ?
|
|
88
|
+
return l && (o[l] || (o[l] = []), o[l].push(c)), o;
|
|
89
|
+
}, {}), s = t.canvases.map((o) => {
|
|
90
|
+
const c = i[o.id] || [];
|
|
91
|
+
return c.length > 0 ? m(o, c, r) : o;
|
|
93
92
|
});
|
|
94
93
|
return {
|
|
95
94
|
source: {
|
|
96
95
|
...t.source,
|
|
97
|
-
items: s.map((
|
|
96
|
+
items: s.map((o) => o.source)
|
|
98
97
|
},
|
|
99
98
|
id: t.id,
|
|
100
99
|
majorVersion: t.majorVersion,
|
|
@@ -104,18 +103,18 @@ const m = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), $ = (t, e) => {
|
|
|
104
103
|
getMetadata: t.getMetadata,
|
|
105
104
|
getTableOfContents: t.getTableOfContents
|
|
106
105
|
};
|
|
107
|
-
}, I = (t, e, r) => t.source.type === "Canvas" ?
|
|
106
|
+
}, I = (t, e, r) => t.source.type === "Canvas" ? m(t, e, r) : O(t, e, r), L = (t) => {
|
|
108
107
|
const e = t.images[0];
|
|
109
108
|
if (!e) return Promise.resolve(!1);
|
|
110
109
|
let r;
|
|
111
110
|
return e.type === "static" ? r = e.url : r = e.getImageURL(100), new Promise((n) => {
|
|
112
|
-
const
|
|
111
|
+
const i = new Image();
|
|
113
112
|
let s = !1;
|
|
114
|
-
|
|
113
|
+
i.onload = () => {
|
|
115
114
|
s = !0, n(!0);
|
|
116
|
-
},
|
|
115
|
+
}, i.onerror = () => {
|
|
117
116
|
n(!1);
|
|
118
|
-
}, setTimeout(() => n(s), 5e3),
|
|
117
|
+
}, setTimeout(() => n(s), 5e3), i.crossOrigin = "anonymous", i.src = r;
|
|
119
118
|
});
|
|
120
119
|
};
|
|
121
120
|
export {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CozyCanvas } from '../types';
|
|
1
|
+
import type { CozyCanvas } from '../types';
|
|
2
2
|
export declare const testCORS: (canvas: CozyCanvas) => Promise<boolean>;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
const g = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), W = new FinalizationRegistry(({ signalWeakRef: a, weakReference: r }) => {
|
|
2
|
+
const l = a.deref();
|
|
3
|
+
if (!l)
|
|
4
|
+
return;
|
|
5
|
+
const o = y.get(l);
|
|
6
|
+
o && (o.throttleds.delete(r), o.throttleds.size === 0 && (l.removeEventListener("abort", o.listener), y.delete(l)));
|
|
7
|
+
});
|
|
8
|
+
function z({ limit: a, interval: r, strict: l, signal: o, onDelay: R, weight: h }) {
|
|
9
|
+
if (!Number.isFinite(a))
|
|
10
|
+
throw new TypeError("Expected `limit` to be a finite number");
|
|
11
|
+
if (!Number.isFinite(r))
|
|
12
|
+
throw new TypeError("Expected `interval` to be a finite number");
|
|
13
|
+
if (a < 0)
|
|
14
|
+
throw new TypeError("Expected `limit` to be >= 0");
|
|
15
|
+
if (r < 0)
|
|
16
|
+
throw new TypeError("Expected `interval` to be >= 0");
|
|
17
|
+
if (h !== void 0 && typeof h != "function")
|
|
18
|
+
throw new TypeError("Expected `weight` to be a function");
|
|
19
|
+
if (h && r === 0)
|
|
20
|
+
throw new TypeError("The `weight` option cannot be used with `interval` of 0");
|
|
21
|
+
const e = {
|
|
22
|
+
queue: /* @__PURE__ */ new Map(),
|
|
23
|
+
strictTicks: [],
|
|
24
|
+
// Track windowed algorithm state so it can be reset on abort
|
|
25
|
+
currentTick: 0,
|
|
26
|
+
activeWeight: 0
|
|
27
|
+
}, x = Math.max(a, 1), b = (i) => {
|
|
28
|
+
if (e.strictTicks.length === 0 || i.time >= e.strictTicks.at(-1).time)
|
|
29
|
+
e.strictTicks.push(i);
|
|
30
|
+
else {
|
|
31
|
+
const t = e.strictTicks.findIndex((c) => c.time > i.time);
|
|
32
|
+
e.strictTicks.splice(t, 0, i);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
function M(i) {
|
|
36
|
+
const t = Date.now();
|
|
37
|
+
return t - e.currentTick > r ? (e.activeWeight = i, e.currentTick = t, 0) : (e.activeWeight + i <= a ? e.activeWeight += i : (e.currentTick += r, e.activeWeight = i), e.currentTick - t);
|
|
38
|
+
}
|
|
39
|
+
function D(i) {
|
|
40
|
+
const t = Date.now();
|
|
41
|
+
if (e.strictTicks.length > 0 && t - e.strictTicks.at(-1).time > r && (e.strictTicks.length = 0), h) {
|
|
42
|
+
for (; e.strictTicks.length > 0 && t - e.strictTicks[0].time >= r; )
|
|
43
|
+
e.strictTicks.shift();
|
|
44
|
+
const m = (s) => {
|
|
45
|
+
let k = 0;
|
|
46
|
+
for (const E of e.strictTicks)
|
|
47
|
+
E.time <= s && s - E.time < r && (k += E.weight);
|
|
48
|
+
return k;
|
|
49
|
+
};
|
|
50
|
+
if (m(t) + i <= a)
|
|
51
|
+
return b({ time: t, weight: i }), { delay: 0 };
|
|
52
|
+
let f = t;
|
|
53
|
+
for (; m(f) + i > a; ) {
|
|
54
|
+
const s = e.strictTicks.find(
|
|
55
|
+
(k) => k.time <= f && f - k.time < r
|
|
56
|
+
);
|
|
57
|
+
if (!s)
|
|
58
|
+
break;
|
|
59
|
+
f = s.time + r;
|
|
60
|
+
}
|
|
61
|
+
const p = { time: f, weight: i };
|
|
62
|
+
return b(p), { delay: Math.max(0, f - t), tickRecord: p };
|
|
63
|
+
}
|
|
64
|
+
if (e.strictTicks.length < x)
|
|
65
|
+
return e.strictTicks.push({ time: t, weight: i }), { delay: 0 };
|
|
66
|
+
const c = e.strictTicks[0].time, d = e.strictTicks.at(-1).time, w = c + r, u = r > 0 ? Math.ceil(r / x) : 0, n = w <= d ? d + u : w;
|
|
67
|
+
e.strictTicks.shift();
|
|
68
|
+
const T = { time: n, weight: i };
|
|
69
|
+
return e.strictTicks.push(T), { delay: Math.max(0, n - t), tickRecord: T };
|
|
70
|
+
}
|
|
71
|
+
const I = l ? D : M;
|
|
72
|
+
return (i) => {
|
|
73
|
+
const t = function(...c) {
|
|
74
|
+
if (!t.isEnabled)
|
|
75
|
+
return (async () => i.apply(this, c))();
|
|
76
|
+
let d;
|
|
77
|
+
return new Promise((w, u) => {
|
|
78
|
+
let n = 1;
|
|
79
|
+
if (h) {
|
|
80
|
+
try {
|
|
81
|
+
n = h(...c);
|
|
82
|
+
} catch (s) {
|
|
83
|
+
u(s);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (!Number.isFinite(n) || n < 0) {
|
|
87
|
+
u(new TypeError("Expected `weight` to be a finite non-negative number"));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (n > a) {
|
|
91
|
+
u(new TypeError(`Expected \`weight\` (${n}) to be <= \`limit\` (${a})`));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const T = I(n), m = l ? T.delay : T, f = l ? T.tickRecord : void 0, p = () => {
|
|
96
|
+
if (f) {
|
|
97
|
+
const s = Date.now();
|
|
98
|
+
if (h && f.time !== s) {
|
|
99
|
+
f.time = s;
|
|
100
|
+
const k = e.strictTicks.indexOf(f);
|
|
101
|
+
e.strictTicks.splice(k, 1), b(f);
|
|
102
|
+
} else
|
|
103
|
+
f.time = s;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
w(i.apply(this, c));
|
|
107
|
+
} catch (s) {
|
|
108
|
+
u(s);
|
|
109
|
+
}
|
|
110
|
+
e.queue.delete(d);
|
|
111
|
+
};
|
|
112
|
+
if (m > 0) {
|
|
113
|
+
d = setTimeout(p, m), e.queue.set(d, u);
|
|
114
|
+
try {
|
|
115
|
+
R?.(...c);
|
|
116
|
+
} catch {
|
|
117
|
+
}
|
|
118
|
+
} else
|
|
119
|
+
p();
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
if (o?.throwIfAborted(), o) {
|
|
123
|
+
let c = y.get(o);
|
|
124
|
+
c || (c = {
|
|
125
|
+
throttleds: /* @__PURE__ */ new Set(),
|
|
126
|
+
listener: null
|
|
127
|
+
}, c.listener = () => {
|
|
128
|
+
for (const w of c.throttleds) {
|
|
129
|
+
const u = w.deref();
|
|
130
|
+
if (!u)
|
|
131
|
+
continue;
|
|
132
|
+
const n = g.get(u);
|
|
133
|
+
if (n) {
|
|
134
|
+
for (const T of n.queue.keys())
|
|
135
|
+
clearTimeout(T), n.queue.get(T)(o.reason);
|
|
136
|
+
n.queue.clear(), n.strictTicks.length = 0, n.currentTick = 0, n.activeWeight = 0;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
y.delete(o);
|
|
140
|
+
}, y.set(o, c), o.addEventListener("abort", c.listener, { once: !0 }));
|
|
141
|
+
const d = new WeakRef(t);
|
|
142
|
+
c.throttleds.add(d), W.register(t, {
|
|
143
|
+
signalWeakRef: new WeakRef(o),
|
|
144
|
+
weakReference: d
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return t.isEnabled = !0, Object.defineProperty(t, "queueSize", {
|
|
148
|
+
get() {
|
|
149
|
+
return e.queue.size;
|
|
150
|
+
}
|
|
151
|
+
}), g.set(t, e), t;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
export {
|
|
155
|
+
z as p
|
|
156
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -62,10 +62,10 @@ var N = class F {
|
|
|
62
62
|
return new F({ collection: [t], manifest: [t], canvas: [t], annotationCollection: [t], annotationPage: [t], annotation: [t], contentResource: [t], choice: [t], range: [t], service: [t], geoJson: [t], specificResource: [t], agent: [t] });
|
|
63
63
|
}
|
|
64
64
|
traverseDescriptive(t) {
|
|
65
|
-
return t.thumbnail
|
|
65
|
+
return t.thumbnail &&= C(t.thumbnail).map((r) => this.traverseType(r, { parent: t }, this.traversals.contentResource)), t.provider &&= t.provider.map((r) => this.traverseAgent(r, t)), t;
|
|
66
66
|
}
|
|
67
67
|
traverseLinking(t) {
|
|
68
|
-
return t.seeAlso
|
|
68
|
+
return t.seeAlso &&= C(t.seeAlso).map((r) => this.traverseType(r, { parent: t }, this.traversals.contentResource)), t.service &&= C(t.service).map((r) => this.traverseService(r)), t.services &&= C(t.services).map((r) => this.traverseService(r, t)), t.logo &&= C(t.logo).map((r) => this.traverseType(r, { parent: t }, this.traversals.contentResource)), t.homepage &&= C(t.homepage).map((r) => this.traverseType(r, { parent: t }, this.traversals.contentResource)), t.partOf &&= t.partOf.map((r) => typeof r == "string" || !r.type ? this.traverseType(r, { parent: t }, this.traversals.contentResource) : r.type === "Canvas" ? this.traverseType(r, { parent: t }, this.traversals.canvas) : r.type === "AnnotationCollection" ? this.traverseType(r, { parent: t }, this.traversals.annotationCollection) : r.type === "Collection" ? this.traverseType(r, { parent: t }, this.traversals.collection) : this.traverseType(r, { parent: t }, this.traversals.contentResource)), t.start && (j(t.start) ? t.start = this.traverseSpecificResource(t.start, "Canvas", t) : t.start = this.traverseType(t.start, { parent: t }, this.traversals.canvas)), t.rendering &&= t.rendering.map((r) => this.traverseType(r, { parent: t }, this.traversals.contentResource)), t.supplementary &&= t.supplementary.map((r) => this.traverseType(r, { parent: t }, this.traversals.contentResource)), t;
|
|
69
69
|
}
|
|
70
70
|
traverseCollectionItems(t) {
|
|
71
71
|
return t.items && t.items.map((r) => r.type === "Collection" ? this.traverseCollection(r) : this.traverseManifest(r)), t;
|
|
@@ -77,13 +77,13 @@ var N = class F {
|
|
|
77
77
|
return this.traverseType(t, { parent: r }, this.traversals.geoJson);
|
|
78
78
|
}
|
|
79
79
|
traverseNavPlace(t) {
|
|
80
|
-
return t.navPlace
|
|
80
|
+
return t.navPlace &&= this.traverseGeoJson(t.navPlace, t), t;
|
|
81
81
|
}
|
|
82
82
|
traverseManifestItems(t) {
|
|
83
|
-
return t.items
|
|
83
|
+
return t.items &&= t.items.map((r) => this.traverseCanvas(r)), t;
|
|
84
84
|
}
|
|
85
85
|
traverseManifestStructures(t) {
|
|
86
|
-
return t.structures
|
|
86
|
+
return t.structures &&= t.structures.map((r) => this.traverseRange(r)), t;
|
|
87
87
|
}
|
|
88
88
|
traverseManifest(t, r) {
|
|
89
89
|
return this.traverseType(this._traverseManifest(t), { parent: r }, this.traversals.manifest);
|
|
@@ -92,22 +92,22 @@ var N = class F {
|
|
|
92
92
|
return t.items = (t.items || []).map((r) => this.traverseAnnotationPage(r, t)), t;
|
|
93
93
|
}
|
|
94
94
|
traverseInlineAnnotationPages(t) {
|
|
95
|
-
return typeof t == "string" || !t ||
|
|
95
|
+
return typeof t == "string" || !t || (t.annotations &&= t.annotations.map((r) => this.traverseAnnotationPage(r, t))), t;
|
|
96
96
|
}
|
|
97
97
|
traverseCanvas(t, r) {
|
|
98
98
|
return this.traverseType(this._traverseCanvas(t), { parent: r }, this.traversals.canvas);
|
|
99
99
|
}
|
|
100
100
|
traverseAnnotationPageItems(t) {
|
|
101
|
-
return t.items
|
|
101
|
+
return t.items &&= t.items.map((r) => this.traverseAnnotation(r, t)), t;
|
|
102
102
|
}
|
|
103
103
|
traverseAnnotationPage(t, r) {
|
|
104
104
|
return this.traverseType(this._traverseAnnotationPage(t), { parent: r }, this.traversals.annotationPage);
|
|
105
105
|
}
|
|
106
106
|
traverseAnnotationBody(t) {
|
|
107
|
-
return Array.isArray(t.body) ? t.body = t.body.map((r) => this.traverseContentResource(r, t)) : t.body
|
|
107
|
+
return Array.isArray(t.body) ? t.body = t.body.map((r) => this.traverseContentResource(r, t)) : t.body &&= this.traverseContentResource(t.body, t), t;
|
|
108
108
|
}
|
|
109
109
|
traverseLinkedCanvases(t) {
|
|
110
|
-
return t.placeholderCanvas
|
|
110
|
+
return t.placeholderCanvas &&= this.traverseCanvas(t.placeholderCanvas), t.accompanyingCanvas &&= this.traverseCanvas(t.accompanyingCanvas), t;
|
|
111
111
|
}
|
|
112
112
|
traverseAnnotation(t, r) {
|
|
113
113
|
return this.traverseType(this.traverseLinking(this.traverseAnnotationBody(this.traverseDescriptive(t))), { parent: r }, this.traversals.annotation);
|
|
@@ -123,7 +123,7 @@ var N = class F {
|
|
|
123
123
|
return typeof t.source == "string" && (n = { id: t.source, type: r || "unknown" }), this.traverseType({ ...t, source: r === "Canvas" || n.type === "Canvas" ? this.traverseType(n, { parent: i }, this.traversals.canvas) : r === "ContentResource" ? this.traverseContentResource(n, { parent: i }) : this.traverseUnknown(n, { parent: i, typeHint: r }) }, { parent: i }, this.traversals.specificResource);
|
|
124
124
|
}
|
|
125
125
|
traverseRangeRanges(t) {
|
|
126
|
-
return t.items
|
|
126
|
+
return t.items &&= t.items.map((r) => typeof r == "string" ? this.traverseCanvas({ id: r, type: "Canvas" }, t) : j(r) ? this.traverseSpecificResource(r, "Canvas", t) : r.type === "Manifest" ? this.traverseManifest(r, t) : this.traverseRange(r, t)), t;
|
|
127
127
|
}
|
|
128
128
|
traverseRange(t, r) {
|
|
129
129
|
return this.traverseType(this._traverseRange(t), { parent: r }, this.traversals.range);
|
|
@@ -195,25 +195,25 @@ var Bt = class et {
|
|
|
195
195
|
let r = [...(t.manifests || []).map((s) => typeof s == "string" ? { "@id": s, "@type": "sc:Manifest" } : s), ...(t.collections || []).map((s) => typeof s == "string" ? { "@id": s, "@type": "sc:Collection" } : s), ...t.members || []], i = [], n = r.filter((s) => i.includes(s["@id"]) ? !1 : (i.push(s["@id"]), !0));
|
|
196
196
|
delete t.collections, delete t.manifests, t.members = n;
|
|
197
197
|
}
|
|
198
|
-
return t.manifests
|
|
198
|
+
return t.manifests &&= t.manifests.map((r) => this.traverseManifest(typeof r == "string" ? { "@id": r, "@type": "sc:Manifest" } : r)), t.collections &&= t.collections.map((r) => this.traverseCollection(typeof r == "string" ? { "@id": r, "@type": "sc:Collection" } : r)), t.members &&= t.members.map((r) => typeof r == "string" ? r : r["@type"] === "sc:Collection" ? this.traverseCollection(r) : r["@type"] === "sc:Manifest" ? this.traverseManifest(r) : this.traverseUnknown(r)), t;
|
|
199
199
|
}
|
|
200
200
|
traverseManifest(t) {
|
|
201
201
|
return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseManifestItems(t))), this.traversals.manifest);
|
|
202
202
|
}
|
|
203
203
|
traverseManifestItems(t) {
|
|
204
|
-
return t.sequences
|
|
204
|
+
return t.sequences &&= t.sequences.map((r) => this.traverseSequence(r)), t.structures &&= t.structures.map((r) => this.traverseRange(r)), t;
|
|
205
205
|
}
|
|
206
206
|
traverseSequence(t) {
|
|
207
207
|
return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseSequenceItems(t))), this.traversals.sequence);
|
|
208
208
|
}
|
|
209
209
|
traverseSequenceItems(t) {
|
|
210
|
-
return t.canvases
|
|
210
|
+
return t.canvases &&= t.canvases.map((r) => this.traverseCanvas(r)), t;
|
|
211
211
|
}
|
|
212
212
|
traverseCanvas(t) {
|
|
213
213
|
return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseCanvasItems(t))), this.traversals.canvas);
|
|
214
214
|
}
|
|
215
215
|
traverseCanvasItems(t) {
|
|
216
|
-
return t.images
|
|
216
|
+
return t.images &&= t.images.map((r) => (r.on && r["@type"] !== "oa:Annotation" && r["@type"] !== "Annotation" && (r["@type"] = "oa:Annotation"), this.traverseAnnotation(r))), t.otherContent &&= t.otherContent.map((r) => this.traverseAnnotationList(r)), t;
|
|
217
217
|
}
|
|
218
218
|
traverseRange(t) {
|
|
219
219
|
return t["@type"] !== "sc:Range" && (t["@type"] = "sc:Range"), this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseRangeItems(t))), this.traversals.range);
|
|
@@ -230,7 +230,7 @@ var Bt = class et {
|
|
|
230
230
|
return this.traverseType(this.traverseDescriptive(this.traverseAnnotationListItems(r)), this.traversals.annotationList);
|
|
231
231
|
}
|
|
232
232
|
traverseAnnotationListItems(t) {
|
|
233
|
-
return t.resources
|
|
233
|
+
return t.resources &&= t.resources.map((r) => this.traverseAnnotation(r)), t;
|
|
234
234
|
}
|
|
235
235
|
traverseAnnotation(t) {
|
|
236
236
|
return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseAnnotationItems(t))), this.traversals.annotation);
|
|
@@ -242,7 +242,7 @@ var Bt = class et {
|
|
|
242
242
|
return this.traverseType(this.traverseLinking(this.traverseLayerItems(t)), this.traversals.layer);
|
|
243
243
|
}
|
|
244
244
|
traverseLayerItems(t) {
|
|
245
|
-
return t.otherContent
|
|
245
|
+
return t.otherContent &&= t.otherContent.map((r) => this.traverseAnnotationList(r)), t;
|
|
246
246
|
}
|
|
247
247
|
traverseChoice(t) {
|
|
248
248
|
return this.traverseType(this.traverseChoiceItems(t), this.traversals.choice);
|
|
@@ -290,7 +290,7 @@ var Bt = class et {
|
|
|
290
290
|
return !r && !this.options.convertPropsToArray ? n[0] : n;
|
|
291
291
|
}
|
|
292
292
|
traverseDescriptive(t) {
|
|
293
|
-
return t.thumbnail
|
|
293
|
+
return t.thumbnail &&= this.traverseImageResource(t.thumbnail), t.logo &&= this.traverseImageResource(t.logo), t;
|
|
294
294
|
}
|
|
295
295
|
traverseOneOrMoreServices(t) {
|
|
296
296
|
let r = Array.isArray(t), i = Array.isArray(t) ? t : [t], n = [];
|
|
@@ -298,7 +298,7 @@ var Bt = class et {
|
|
|
298
298
|
return !r && !this.options.convertPropsToArray ? n[0] : n;
|
|
299
299
|
}
|
|
300
300
|
traverseLinking(t) {
|
|
301
|
-
return t.related
|
|
301
|
+
return t.related &&= this.traverseOneOrManyType(t.related, this.traversals.contentResource), t.rendering &&= this.traverseOneOrManyType(t.rendering, this.traversals.contentResource), t.service &&= this.traverseOneOrMoreServices(t.service), t.seeAlso &&= this.traverseOneOrManyType(t.seeAlso, this.traversals.contentResource), t.within && (typeof t.within == "string" || (t.within = this.traverseOneOrManyType(t.within, this.traversals.contentResource))), t.startCanvas && (typeof t.startCanvas == "string" ? t.startCanvas = this.traverseType({ "@id": t.startCanvas, "@type": "sc:Canvas" }, this.traversals.canvas) : t.startCanvas && this.traverseType(t.startCanvas, this.traversals.canvas)), t.contentLayer && (typeof t.contentLayer == "string" ? t.contentLayer = this.traverseLayer({ "@id": t.contentLayer, "@type": "sc:Layer" }) : t.contentLayer = this.traverseLayer(t.contentLayer)), t;
|
|
302
302
|
}
|
|
303
303
|
traverseOneOrManyType(t, r) {
|
|
304
304
|
if (!Array.isArray(t)) if (this.options.convertPropsToArray) t = [t];
|
|
@@ -484,13 +484,7 @@ function te(e) {
|
|
|
484
484
|
function ee(e) {
|
|
485
485
|
if (!e.within) return;
|
|
486
486
|
let t = Array.isArray(e.within) ? e.within : [e.within], r = [];
|
|
487
|
-
for (let i of t)
|
|
488
|
-
if (i) switch (e["@type"]) {
|
|
489
|
-
case "sc:Manifest":
|
|
490
|
-
r.push({ id: i, type: "Collection" });
|
|
491
|
-
break;
|
|
492
|
-
}
|
|
493
|
-
} else i["@id"] && r.push({ id: i["@id"], type: E(i) });
|
|
487
|
+
for (let i of t) typeof i == "string" ? i && e["@type"] === "sc:Manifest" && r.push({ id: i, type: "Collection" }) : i["@id"] && r.push({ id: i["@id"], type: E(i) });
|
|
494
488
|
return r.length ? r : void 0;
|
|
495
489
|
}
|
|
496
490
|
function I(e) {
|
|
@@ -501,7 +495,7 @@ function re(e) {
|
|
|
501
495
|
return { chars: e.chars, format: e.format ? e.format : void 0, language: e.language };
|
|
502
496
|
}
|
|
503
497
|
function P(e, t) {
|
|
504
|
-
return e ? typeof e == "string" ? { id: e, type: t } : typeof
|
|
498
|
+
return e ? typeof e == "string" ? { id: e, type: t } : typeof e?.["@id"] == "string" ? { id: e["@id"], type: t } : typeof e.id == "string" ? { id: e.id, type: t } : null : null;
|
|
505
499
|
}
|
|
506
500
|
function ie(e) {
|
|
507
501
|
let t = {};
|
|
@@ -597,7 +591,7 @@ function ge(e) {
|
|
|
597
591
|
}
|
|
598
592
|
const me = new Bt({ collection: [se], manifest: [ae], canvas: [ce], annotationList: [le], sequence: [pe], annotation: [ve], contentResource: [nt], choice: [he], range: [ue], service: [fe], layer: [ge] });
|
|
599
593
|
function st(e) {
|
|
600
|
-
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"]
|
|
594
|
+
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", me.traverseUnknown(e)) : e;
|
|
601
595
|
}
|
|
602
596
|
function O(e) {
|
|
603
597
|
if ((Array.isArray(e["@type"]) && e["@type"].includes("oa:SvgSelector") || e["@type"] == "oa:SvgSelector") && ("chars" in e || "value" in e)) return { type: "SvgSelector", value: "chars" in e ? e.chars : e.value };
|
|
@@ -606,12 +600,9 @@ function O(e) {
|
|
|
606
600
|
if (e["@type"] == "iiif:ImageApiSelector") return { type: "ImageApiSelector", region: "region" in e ? e.region : void 0, rotation: "rotation" in e ? e.rotation : void 0 };
|
|
607
601
|
throw Error(`Unsupported selector type: ${e["@type"]}`);
|
|
608
602
|
}
|
|
609
|
-
const at = (e) => e.endsWith("/info.json") ? e : `${e.endsWith("/") ? e : `${e}/`}info.json`, ot = (e) => {
|
|
610
|
-
var r;
|
|
611
|
-
return y(e, "type").startsWith("ImageService") || ((r = e.profile) == null ? void 0 : r.toString().includes("iiif.io/api/image/"));
|
|
612
|
-
}, ct = (e) => {
|
|
603
|
+
const at = (e) => e.endsWith("/info.json") ? e : `${e.endsWith("/") ? e : `${e}/`}info.json`, ot = (e) => y(e, "type").startsWith("ImageService") || e.profile?.toString().includes("iiif.io/api/image/"), ct = (e) => {
|
|
613
604
|
const t = y(e, "type"), r = y(e, "context");
|
|
614
|
-
if (t === "ImageService2" || r
|
|
605
|
+
if (t === "ImageService2" || r?.includes("image/2")) {
|
|
615
606
|
const n = y(e, "profile"), s = ["level0", "level1", "level2"];
|
|
616
607
|
return { majorVersion: 2, profileLevel: (Array.isArray(n) ? n : n ? [n] : []).map((p) => s.findIndex((o) => p.toString().includes(o))).filter((p) => p > -1).sort((p, o) => o - p)[0] };
|
|
617
608
|
} else if (t || r)
|
|
@@ -639,11 +630,11 @@ const at = (e) => e.endsWith("/info.json") ? e : `${e.endsWith("/") ? e : `${e}/
|
|
|
639
630
|
console.warn(`Level 0 image service does not support custom region URLs: ${n}`);
|
|
640
631
|
return;
|
|
641
632
|
}
|
|
642
|
-
const { x: c, y: p, w: o, h:
|
|
643
|
-
let
|
|
644
|
-
|
|
645
|
-
const d = `${Math.round(c)},${Math.round(p)},${Math.round(o)},${Math.round(
|
|
646
|
-
return `${n}/${d}/!${m},${
|
|
633
|
+
const { x: c, y: p, w: o, h: f } = t, { minSize: h = 400, maxSize: u } = i, g = r % 180 !== 0 ? f / o : o / f, L = g < 1;
|
|
634
|
+
let v = Math.ceil(L ? h / g : h), m = Math.ceil(L ? h : h / g);
|
|
635
|
+
u && (m > u || v > u) && (L ? (v = Math.min(v, u), m = Math.ceil(v * g)) : (m = Math.min(m, u), v = Math.ceil(m / g)));
|
|
636
|
+
const d = `${Math.round(c)},${Math.round(p)},${Math.round(o)},${Math.round(f)}`;
|
|
637
|
+
return `${n}/${d}/!${m},${v}/${r}/default.jpg`;
|
|
647
638
|
}, pt = (e) => (t, r = 0, i = { minSize: 400 }) => {
|
|
648
639
|
if (e.type === "dynamic")
|
|
649
640
|
return de(e.service, t, r, i);
|
|
@@ -662,9 +653,9 @@ const at = (e) => e.endsWith("/info.json") ? e : `${e.endsWith("/") ? e : `${e}/
|
|
|
662
653
|
if (e.thumbnail && e.thumbnail.length > 0) {
|
|
663
654
|
const o = e.thumbnail[0];
|
|
664
655
|
if ("service" in o && Array.isArray(o.service)) {
|
|
665
|
-
const
|
|
666
|
-
if (
|
|
667
|
-
return D(
|
|
656
|
+
const f = o.service.find((h) => ot(h));
|
|
657
|
+
if (f)
|
|
658
|
+
return D(f, p, c);
|
|
668
659
|
}
|
|
669
660
|
if ("id" in o) return o.id;
|
|
670
661
|
}
|
|
@@ -714,57 +705,53 @@ const at = (e) => e.endsWith("/info.json") ? e : `${e.endsWith("/") ? e : `${e}/
|
|
|
714
705
|
}]
|
|
715
706
|
}).traverseCanvas(e), t;
|
|
716
707
|
}, be = (e) => () => {
|
|
717
|
-
const t = /* @__PURE__ */ new Map(), r = (o,
|
|
718
|
-
const
|
|
708
|
+
const t = /* @__PURE__ */ new Map(), r = (o, f, h = 0) => {
|
|
709
|
+
const u = {
|
|
719
710
|
id: o.id,
|
|
720
711
|
type: "range",
|
|
721
712
|
source: o,
|
|
722
713
|
children: [],
|
|
723
714
|
navItems: [],
|
|
724
715
|
navSections: [],
|
|
725
|
-
parent:
|
|
726
|
-
level:
|
|
716
|
+
parent: f,
|
|
717
|
+
level: h,
|
|
727
718
|
getLabel: o.getLabel
|
|
728
719
|
};
|
|
729
|
-
o.items && o.items.length > 0 && o.items.forEach((
|
|
730
|
-
if (
|
|
731
|
-
const d = r(
|
|
732
|
-
|
|
720
|
+
o.items && o.items.length > 0 && o.items.forEach((v) => {
|
|
721
|
+
if (v.source.type === "Range") {
|
|
722
|
+
const d = r(v, u, h + 1);
|
|
723
|
+
u.children.push(d);
|
|
733
724
|
} else {
|
|
734
725
|
const m = {
|
|
735
|
-
id:
|
|
726
|
+
id: v.id,
|
|
736
727
|
type: "canvas",
|
|
737
|
-
source:
|
|
728
|
+
source: v,
|
|
738
729
|
children: [],
|
|
739
730
|
navItems: [],
|
|
740
731
|
navSections: [],
|
|
741
|
-
parent:
|
|
742
|
-
level:
|
|
743
|
-
getLabel:
|
|
732
|
+
parent: u,
|
|
733
|
+
level: h + 1,
|
|
734
|
+
getLabel: v.getLabel
|
|
744
735
|
};
|
|
745
|
-
|
|
736
|
+
u.children.push(m), t.set(m.id, m);
|
|
746
737
|
}
|
|
747
738
|
});
|
|
748
|
-
const l =
|
|
749
|
-
return
|
|
739
|
+
const l = u.children.map((v) => v.type === "canvas" ? v.source : v.children.length === 1 && v.children[0].type === "canvas" ? v.children[0].source : v.source), g = l.filter((v) => v.source.type === "Canvas"), L = l.filter((v) => v.source.type === "Range");
|
|
740
|
+
return u.navItems.push(...g), u.navSections.push(...L), t.set(u.id, u), u;
|
|
750
741
|
};
|
|
751
|
-
return { root: e.filter((o) => {
|
|
752
|
-
|
|
753
|
-
return
|
|
754
|
-
}).map((o) => r(o, void 0)), enumerateNodes: (o) => {
|
|
755
|
-
const u = Array.from(t.values());
|
|
756
|
-
return o ? u.filter((f) => f.type === o) : u;
|
|
742
|
+
return { root: e.filter((o) => o.source.behavior?.includes("top")).map((o) => r(o, void 0)), enumerateNodes: (o) => {
|
|
743
|
+
const f = Array.from(t.values());
|
|
744
|
+
return o ? f.filter((h) => h.type === o) : f;
|
|
757
745
|
}, getBreadcrumbs: (o) => {
|
|
758
|
-
const
|
|
759
|
-
if (!
|
|
760
|
-
const
|
|
761
|
-
return f
|
|
746
|
+
const f = t.get(o);
|
|
747
|
+
if (!f) return [];
|
|
748
|
+
const h = (u, l = []) => u.parent ? h(u.parent, [u, ...l]) : [u, ...l];
|
|
749
|
+
return h(f);
|
|
762
750
|
}, getNavParent: (o) => {
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
return f.children.length === 1 && f.children[0].type === "canvas" ? ((l = f.parent) == null ? void 0 : l.type) === "range" ? f.parent.source : void 0 : f.source;
|
|
751
|
+
const f = t.get(o);
|
|
752
|
+
if (!f || f.type !== "canvas" || f.parent?.type !== "range") return;
|
|
753
|
+
const { parent: h } = f;
|
|
754
|
+
return h.children.length === 1 && h.children[0].type === "canvas" ? h.parent?.type === "range" ? h.parent.source : void 0 : h.source;
|
|
768
755
|
}, getNode: (o) => t.get(o) };
|
|
769
756
|
}, Re = async (e) => {
|
|
770
757
|
try {
|
|
@@ -792,12 +779,12 @@ const at = (e) => e.endsWith("/info.json") ? e : `${e.endsWith("/") ? e : `${e}/
|
|
|
792
779
|
};
|
|
793
780
|
}
|
|
794
781
|
const r = t.headers.get("content-type");
|
|
795
|
-
if (r
|
|
782
|
+
if (r?.startsWith("image/"))
|
|
796
783
|
return {
|
|
797
784
|
type: "plain-image",
|
|
798
785
|
url: e
|
|
799
786
|
};
|
|
800
|
-
if (r
|
|
787
|
+
if (r?.includes("text/html"))
|
|
801
788
|
return {
|
|
802
789
|
type: "webpage",
|
|
803
790
|
url: e
|
|
@@ -887,7 +874,7 @@ const at = (e) => e.endsWith("/info.json") ? e : `${e.endsWith("/") ? e : `${e}/
|
|
|
887
874
|
l.type === "Range" && p.push(l);
|
|
888
875
|
}]
|
|
889
876
|
}).traverseManifest(a);
|
|
890
|
-
const
|
|
877
|
+
const f = c.map((l) => {
|
|
891
878
|
const g = Ce(l);
|
|
892
879
|
return {
|
|
893
880
|
source: l,
|
|
@@ -902,19 +889,19 @@ const at = (e) => e.endsWith("/info.json") ? e : `${e.endsWith("/") ? e : `${e}/
|
|
|
902
889
|
getMetadata: k(l),
|
|
903
890
|
getThumbnailURL: ye(l, g)
|
|
904
891
|
};
|
|
905
|
-
}),
|
|
906
|
-
const g = l.items || [], L = g.filter((d) => d.type === "Canvas").map((d) =>
|
|
892
|
+
}), h = (l) => {
|
|
893
|
+
const g = l.items || [], L = g.filter((d) => d.type === "Canvas").map((d) => f.find((M) => M.id === d.id)).filter(Boolean), v = g.filter((d) => d.type === "Range").map((d) => h(d)), m = [...L, ...v];
|
|
907
894
|
return {
|
|
908
895
|
source: l,
|
|
909
896
|
id: l.id,
|
|
910
897
|
// Maintain original order
|
|
911
898
|
items: g.map((d) => m.find((M) => M.id === d.id)),
|
|
912
899
|
canvases: L,
|
|
913
|
-
ranges:
|
|
900
|
+
ranges: v,
|
|
914
901
|
getLabel: x(l)
|
|
915
902
|
};
|
|
916
|
-
},
|
|
917
|
-
return { canvases:
|
|
903
|
+
}, u = p.map((l) => h(l));
|
|
904
|
+
return { canvases: f, ranges: u };
|
|
918
905
|
}, i = t === 2 ? st(e) : e, { canvases: n, ranges: s } = r(i);
|
|
919
906
|
return {
|
|
920
907
|
source: i,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Bounds, Level0ImageServiceResource } from '../types';
|
|
1
|
+
import type { Bounds, Level0ImageServiceResource } from '../types';
|
|
2
2
|
export declare const cropRegion: (resource: Level0ImageServiceResource, bounds: Bounds) => Promise<Blob>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Level0ImageServiceResource } from '../types';
|
|
2
|
-
import { ImageInfo } from './types';
|
|
1
|
+
import type { Level0ImageServiceResource } from '../types';
|
|
2
|
+
import type { ImageInfo } from './types';
|
|
3
3
|
export declare const fetchImageInfo: (resource: Level0ImageServiceResource) => Promise<ImageInfo>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Level0ImageServiceResource } from '../types';
|
|
2
|
-
import { Size } from './types';
|
|
1
|
+
import type { Level0ImageServiceResource } from '../types';
|
|
2
|
+
import type { Size } from './types';
|
|
3
3
|
export declare const getThumbnail: (resource: Level0ImageServiceResource, minSize?: Partial<Size>) => Promise<Blob>;
|
package/dist/level-0/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { g as p } from "../resource-DS2brz47.js";
|
|
2
2
|
import "image-size";
|
|
3
|
-
import { p as M } from "../index-
|
|
3
|
+
import { p as M } from "../index-B2EdkMiz.js";
|
|
4
4
|
const T = (t) => ({ id: p(t, "id"), ...t }), u = (t) => fetch(t.serviceUrl).then((e) => e.json()).then(T), C = () => {
|
|
5
5
|
let t = {
|
|
6
6
|
limit: 5,
|
|
@@ -2,6 +2,6 @@ interface ThrottledLoaderOpts {
|
|
|
2
2
|
callsPerSecond?: number;
|
|
3
3
|
}
|
|
4
4
|
export declare const getThrottledLoader: (opts?: ThrottledLoaderOpts) => {
|
|
5
|
-
loadImage: import(
|
|
5
|
+
loadImage: import("p-throttle").ThrottledFunction<(url: string) => Promise<HTMLImageElement>>;
|
|
6
6
|
};
|
|
7
7
|
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnnotationPage, Canvas, Collection, IIIFExternalWebResource, Manifest, Range, Service } from '@iiif/presentation-3';
|
|
1
|
+
import type { AnnotationPage, Canvas, Collection, IIIFExternalWebResource, Manifest, Range, Service } from '@iiif/presentation-3';
|
|
2
2
|
export type CozyParseResult = {
|
|
3
3
|
type: 'collection';
|
|
4
4
|
url: string;
|
|
@@ -110,7 +110,7 @@ export interface DynamicImageServiceResource extends BaseImageResource {
|
|
|
110
110
|
readonly service: Service;
|
|
111
111
|
readonly serviceUrl: string;
|
|
112
112
|
readonly majorVersion: number;
|
|
113
|
-
getRegionURL(bounds: Bounds, opts?: GetRegionURLOpts): string;
|
|
113
|
+
getRegionURL(bounds: Bounds, rotation?: number, opts?: GetRegionURLOpts): string;
|
|
114
114
|
}
|
|
115
115
|
export interface Level0ImageServiceResource extends BaseImageResource {
|
|
116
116
|
readonly type: 'level0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-iiif",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.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",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"main": "dist/index.js",
|
|
20
20
|
"types": "dist/index.d.ts",
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "vite build",
|
|
22
|
+
"build": "vite build && tsc --emitDeclarationOnly",
|
|
23
23
|
"test": "vitest"
|
|
24
24
|
},
|
|
25
25
|
"exports": {
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"./level-0": "./dist/level-0/index.js"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"
|
|
32
|
-
"vite
|
|
33
|
-
"vitest": "^
|
|
31
|
+
"typescript": "^5.9.3",
|
|
32
|
+
"vite": "^7.3.1",
|
|
33
|
+
"vitest": "^4.0.18"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@iiif/parser": "^2.2.9",
|
package/src/types.ts
CHANGED
|
@@ -194,7 +194,7 @@ export interface DynamicImageServiceResource extends BaseImageResource {
|
|
|
194
194
|
|
|
195
195
|
readonly majorVersion: number;
|
|
196
196
|
|
|
197
|
-
getRegionURL(bounds: Bounds, opts?: GetRegionURLOpts): string;
|
|
197
|
+
getRegionURL(bounds: Bounds, rotation?: number, opts?: GetRegionURLOpts): string;
|
|
198
198
|
|
|
199
199
|
}
|
|
200
200
|
|
package/tsconfig.json
CHANGED
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"allowJs": true,
|
|
4
4
|
"allowSyntheticDefaultImports": true,
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"declarationDir": "dist",
|
|
7
|
+
"emitDeclarationOnly": true,
|
|
5
8
|
"esModuleInterop": true,
|
|
6
9
|
"module": "ESNext",
|
|
7
10
|
"moduleResolution": "Bundler",
|
|
8
11
|
"noFallthroughCasesInSwitch": true,
|
|
9
12
|
"noUnusedLocals": false,
|
|
10
13
|
"noUnusedParameters": false,
|
|
14
|
+
"rootDir": "src",
|
|
11
15
|
"skipLibCheck": true,
|
|
12
16
|
"strict": true,
|
|
13
17
|
"target": "ES2020",
|
package/vite.config.ts
CHANGED
package/dist/index-CNJsBGB0.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
const g = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), z = new FinalizationRegistry(({ signalWeakRef: u, weakReference: r }) => {
|
|
2
|
-
const h = u.deref();
|
|
3
|
-
if (!h)
|
|
4
|
-
return;
|
|
5
|
-
const s = y.get(h);
|
|
6
|
-
s && (s.throttleds.delete(r), s.throttleds.size === 0 && (h.removeEventListener("abort", s.listener), y.delete(h)));
|
|
7
|
-
});
|
|
8
|
-
function S({ limit: u, interval: r, strict: h, signal: s, onDelay: b, weight: k }) {
|
|
9
|
-
if (!Number.isFinite(u))
|
|
10
|
-
throw new TypeError("Expected `limit` to be a finite number");
|
|
11
|
-
if (!Number.isFinite(r))
|
|
12
|
-
throw new TypeError("Expected `interval` to be a finite number");
|
|
13
|
-
if (u < 0)
|
|
14
|
-
throw new TypeError("Expected `limit` to be >= 0");
|
|
15
|
-
if (r < 0)
|
|
16
|
-
throw new TypeError("Expected `interval` to be >= 0");
|
|
17
|
-
if (k !== void 0 && typeof k != "function")
|
|
18
|
-
throw new TypeError("Expected `weight` to be a function");
|
|
19
|
-
if (k && r === 0)
|
|
20
|
-
throw new TypeError("The `weight` option cannot be used with `interval` of 0");
|
|
21
|
-
const t = {
|
|
22
|
-
queue: /* @__PURE__ */ new Map(),
|
|
23
|
-
strictTicks: [],
|
|
24
|
-
// Track windowed algorithm state so it can be reset on abort
|
|
25
|
-
currentTick: 0,
|
|
26
|
-
activeWeight: 0
|
|
27
|
-
}, R = Math.max(u, 1), E = (i) => {
|
|
28
|
-
if (t.strictTicks.length === 0 || i.time >= t.strictTicks.at(-1).time)
|
|
29
|
-
t.strictTicks.push(i);
|
|
30
|
-
else {
|
|
31
|
-
const e = t.strictTicks.findIndex((n) => n.time > i.time);
|
|
32
|
-
t.strictTicks.splice(e, 0, i);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
function M(i) {
|
|
36
|
-
const e = Date.now();
|
|
37
|
-
return e - t.currentTick > r ? (t.activeWeight = i, t.currentTick = e, 0) : (t.activeWeight + i <= u ? t.activeWeight += i : (t.currentTick += r, t.activeWeight = i), t.currentTick - e);
|
|
38
|
-
}
|
|
39
|
-
function I(i) {
|
|
40
|
-
const e = Date.now();
|
|
41
|
-
if (t.strictTicks.length > 0 && e - t.strictTicks.at(-1).time > r && (t.strictTicks.length = 0), k) {
|
|
42
|
-
for (; t.strictTicks.length > 0 && e - t.strictTicks[0].time >= r; )
|
|
43
|
-
t.strictTicks.shift();
|
|
44
|
-
const m = (o) => {
|
|
45
|
-
let w = 0;
|
|
46
|
-
for (const x of t.strictTicks)
|
|
47
|
-
x.time <= o && o - x.time < r && (w += x.weight);
|
|
48
|
-
return w;
|
|
49
|
-
};
|
|
50
|
-
if (m(e) + i <= u)
|
|
51
|
-
return E({ time: e, weight: i }), { delay: 0 };
|
|
52
|
-
let f = e;
|
|
53
|
-
for (; m(f) + i > u; ) {
|
|
54
|
-
const o = t.strictTicks.find(
|
|
55
|
-
(w) => w.time <= f && f - w.time < r
|
|
56
|
-
);
|
|
57
|
-
if (!o)
|
|
58
|
-
break;
|
|
59
|
-
f = o.time + r;
|
|
60
|
-
}
|
|
61
|
-
const p = { time: f, weight: i };
|
|
62
|
-
return E(p), { delay: Math.max(0, f - e), tickRecord: p };
|
|
63
|
-
}
|
|
64
|
-
if (t.strictTicks.length < R)
|
|
65
|
-
return t.strictTicks.push({ time: e, weight: i }), { delay: 0 };
|
|
66
|
-
const n = t.strictTicks[0].time, a = t.strictTicks.at(-1).time, l = n + r, d = r > 0 ? Math.ceil(r / R) : 0, c = l <= a ? a + d : l;
|
|
67
|
-
t.strictTicks.shift();
|
|
68
|
-
const T = { time: c, weight: i };
|
|
69
|
-
return t.strictTicks.push(T), { delay: Math.max(0, c - e), tickRecord: T };
|
|
70
|
-
}
|
|
71
|
-
const W = h ? I : M;
|
|
72
|
-
return (i) => {
|
|
73
|
-
const e = function(...n) {
|
|
74
|
-
if (!e.isEnabled)
|
|
75
|
-
return (async () => i.apply(this, n))();
|
|
76
|
-
let a;
|
|
77
|
-
return new Promise((l, d) => {
|
|
78
|
-
let c = 1;
|
|
79
|
-
if (k) {
|
|
80
|
-
try {
|
|
81
|
-
c = k(...n);
|
|
82
|
-
} catch (o) {
|
|
83
|
-
d(o);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (!Number.isFinite(c) || c < 0) {
|
|
87
|
-
d(new TypeError("Expected `weight` to be a finite non-negative number"));
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
if (c > u) {
|
|
91
|
-
d(new TypeError(`Expected \`weight\` (${c}) to be <= \`limit\` (${u})`));
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
const T = W(c), m = h ? T.delay : T, f = h ? T.tickRecord : void 0, p = () => {
|
|
96
|
-
if (f) {
|
|
97
|
-
const o = Date.now();
|
|
98
|
-
if (k && f.time !== o) {
|
|
99
|
-
f.time = o;
|
|
100
|
-
const w = t.strictTicks.indexOf(f);
|
|
101
|
-
t.strictTicks.splice(w, 1), E(f);
|
|
102
|
-
} else
|
|
103
|
-
f.time = o;
|
|
104
|
-
}
|
|
105
|
-
try {
|
|
106
|
-
l(i.apply(this, n));
|
|
107
|
-
} catch (o) {
|
|
108
|
-
d(o);
|
|
109
|
-
}
|
|
110
|
-
t.queue.delete(a);
|
|
111
|
-
};
|
|
112
|
-
if (m > 0) {
|
|
113
|
-
a = setTimeout(p, m), t.queue.set(a, d);
|
|
114
|
-
try {
|
|
115
|
-
b == null || b(...n);
|
|
116
|
-
} catch {
|
|
117
|
-
}
|
|
118
|
-
} else
|
|
119
|
-
p();
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
if (s == null || s.throwIfAborted(), s) {
|
|
123
|
-
let n = y.get(s);
|
|
124
|
-
n || (n = {
|
|
125
|
-
throttleds: /* @__PURE__ */ new Set(),
|
|
126
|
-
listener: null
|
|
127
|
-
}, n.listener = () => {
|
|
128
|
-
for (const l of n.throttleds) {
|
|
129
|
-
const d = l.deref();
|
|
130
|
-
if (!d)
|
|
131
|
-
continue;
|
|
132
|
-
const c = g.get(d);
|
|
133
|
-
if (c) {
|
|
134
|
-
for (const T of c.queue.keys())
|
|
135
|
-
clearTimeout(T), c.queue.get(T)(s.reason);
|
|
136
|
-
c.queue.clear(), c.strictTicks.length = 0, c.currentTick = 0, c.activeWeight = 0;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
y.delete(s);
|
|
140
|
-
}, y.set(s, n), s.addEventListener("abort", n.listener, { once: !0 }));
|
|
141
|
-
const a = new WeakRef(e);
|
|
142
|
-
n.throttleds.add(a), z.register(e, {
|
|
143
|
-
signalWeakRef: new WeakRef(s),
|
|
144
|
-
weakReference: a
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
return e.isEnabled = !0, Object.defineProperty(e, "queueSize", {
|
|
148
|
-
get() {
|
|
149
|
-
return t.queue.size;
|
|
150
|
-
}
|
|
151
|
-
}), g.set(e, t), e;
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
export {
|
|
155
|
-
S as p
|
|
156
|
-
};
|