triiiceratops 0.20.0 → 0.20.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/{annotationAdapter-B3K4C32n.js → annotationAdapter-D1CVThou.js} +82 -82
- package/dist/{index-B8dWrK0B.js → index-Da-IQTm1.js} +3245 -3084
- package/dist/{index-CGjR0-hX.js → index-Dt5nnlV1.js} +51 -50
- package/dist/plugins/pdf-export/PdfExportController.svelte +10 -1
- package/dist/plugins/pdf-export/PdfExportController.svelte.d.ts +5 -1
- package/dist/plugins/pdf-export/exportPdf.d.ts +15 -1
- package/dist/plugins/pdf-export/exportPdf.js +159 -25
- package/dist/plugins/pdf-export/exportPdf.test.js +413 -2
- package/dist/plugins/pdf-export/index.d.ts +6 -2
- package/dist/plugins/pdf-export.js +1 -1
- package/dist/triiiceratops-bundle.js +1 -1
- package/dist/utils/resolveCanvasImage.d.ts +2 -1
- package/dist/utils/resolveCanvasImage.js +8 -1
- package/dist/utils/resolveCanvasImage.test.js +5 -0
- package/package.json +1 -1
|
@@ -12,19 +12,19 @@ function k(e, t = 200) {
|
|
|
12
12
|
try {
|
|
13
13
|
let n = ((i = e.getImages) == null ? void 0 : i.call(e)) || [];
|
|
14
14
|
if ((!n || !n.length) && e.getContent && (n = e.getContent()), n && n.length > 0) {
|
|
15
|
-
const
|
|
16
|
-
let u =
|
|
17
|
-
if (!u &&
|
|
18
|
-
const
|
|
19
|
-
if ((f == null ? void 0 : f.type) === "Choice" || (f == null ? void 0 : f.type) === "oa:Choice" ||
|
|
15
|
+
const l = n[0];
|
|
16
|
+
let u = l.getResource ? l.getResource() : null;
|
|
17
|
+
if (!u && l.getBody) {
|
|
18
|
+
const o = l.getBody(), f = ((s = l.__jsonld) == null ? void 0 : s.body) || l.body;
|
|
19
|
+
if ((f == null ? void 0 : f.type) === "Choice" || (f == null ? void 0 : f.type) === "oa:Choice" || o && !Array.isArray(o) && (o.type === "Choice" || o.type === "oa:Choice")) {
|
|
20
20
|
let y = [];
|
|
21
|
-
Array.isArray(
|
|
22
|
-
} else Array.isArray(
|
|
21
|
+
Array.isArray(o) ? y = o : o && (o.items || o.item) ? y = o.items || o.item : f && (f.items || f.item) && (y = f.items || f.item), y.length > 0 && (u = y[0]);
|
|
22
|
+
} else Array.isArray(o) && o.length > 0 ? u = o[0] : o && (u = o);
|
|
23
23
|
}
|
|
24
24
|
if (u && !u.id && !u.__jsonld && (!u.getServices || u.getServices().length === 0) && (u = null), !u) {
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
let f =
|
|
25
|
+
const o = l.__jsonld || l;
|
|
26
|
+
if (o.body) {
|
|
27
|
+
let f = o.body;
|
|
28
28
|
(f.type === "Choice" || f.type === "oa:Choice") && (f = (f.items || f.item || [])[0] || null), u = Array.isArray(f) ? f[0] : f;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -53,7 +53,7 @@ function k(e, t = 200) {
|
|
|
53
53
|
}
|
|
54
54
|
if (r = u.id || u["@id"] || u.__jsonld && (u.__jsonld.id || u.__jsonld["@id"]) || "", !r) {
|
|
55
55
|
let c = null;
|
|
56
|
-
if (
|
|
56
|
+
if (l.__jsonld && l.__jsonld.body ? c = l.__jsonld.body : l.body && (c = l.body), c) {
|
|
57
57
|
let y = Array.isArray(c) ? c[0] : c;
|
|
58
58
|
(y.type === "Choice" || y.type === "oa:Choice") && (y = (y.items || y.item || [])[0] || y), r = y.id || y["@id"] || "";
|
|
59
59
|
}
|
|
@@ -78,14 +78,14 @@ function P(e) {
|
|
|
78
78
|
if ((!t || !t.length) && e.getContent && (t = e.getContent()), !t || !t.length) return [];
|
|
79
79
|
for (const s of t) {
|
|
80
80
|
if (!s) continue;
|
|
81
|
-
const n = s.getBody ? s.getBody() : s.body || s.resource,
|
|
82
|
-
if ((
|
|
81
|
+
const n = s.getBody ? s.getBody() : s.body || s.resource, l = ((i = s.__jsonld) == null ? void 0 : i.body) || s.body;
|
|
82
|
+
if ((l == null ? void 0 : l.type) === "Choice" || (l == null ? void 0 : l.type) === "oa:Choice" || n && !Array.isArray(n) && (n.type === "Choice" || n.type === "oa:Choice")) {
|
|
83
83
|
if (Array.isArray(n))
|
|
84
84
|
return n;
|
|
85
85
|
if (n && (n.items || n.item))
|
|
86
86
|
return n.items || n.item;
|
|
87
|
-
if (
|
|
88
|
-
return
|
|
87
|
+
if (l && (l.items || l.item))
|
|
88
|
+
return l.items || l.item;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
return [];
|
|
@@ -99,20 +99,20 @@ function C({
|
|
|
99
99
|
}) {
|
|
100
100
|
if (!t) return [];
|
|
101
101
|
if (r < 0 || r >= e.length) return [];
|
|
102
|
-
const n = [],
|
|
103
|
-
if (!
|
|
102
|
+
const n = [], l = e[r];
|
|
103
|
+
if (!l) return n;
|
|
104
104
|
if (i !== "paged" || r < s)
|
|
105
105
|
return n.push({
|
|
106
106
|
canvasId: t,
|
|
107
|
-
canvas:
|
|
107
|
+
canvas: l
|
|
108
108
|
}), n;
|
|
109
|
-
const
|
|
109
|
+
const o = (r - s) % 2 === 0 ? r : r - 1, f = e[o], c = a(f);
|
|
110
110
|
if (!f || !c) return n;
|
|
111
111
|
n.push({
|
|
112
112
|
canvasId: c,
|
|
113
113
|
canvas: f
|
|
114
114
|
});
|
|
115
|
-
const y = e[
|
|
115
|
+
const y = e[o + 1], g = a(y);
|
|
116
116
|
return y && g && n.push({
|
|
117
117
|
canvasId: g,
|
|
118
118
|
canvas: y
|
|
@@ -125,7 +125,7 @@ function Q({
|
|
|
125
125
|
viewingMode: i,
|
|
126
126
|
pagedOffset: s,
|
|
127
127
|
viewingDirection: n,
|
|
128
|
-
getSelectedChoice:
|
|
128
|
+
getSelectedChoice: l
|
|
129
129
|
}) {
|
|
130
130
|
const u = C({
|
|
131
131
|
canvases: e,
|
|
@@ -135,18 +135,18 @@ function Q({
|
|
|
135
135
|
pagedOffset: s
|
|
136
136
|
});
|
|
137
137
|
if (!u.length) return [];
|
|
138
|
-
const
|
|
138
|
+
const o = i === "paged" && n === "right-to-left", f = {};
|
|
139
139
|
if (i === "paged" && u.length === 2) {
|
|
140
140
|
const [c, y] = u;
|
|
141
|
-
f[c.canvasId] =
|
|
141
|
+
f[c.canvasId] = o ? "right" : "left", f[y.canvasId] = o ? "left" : "right";
|
|
142
142
|
} else
|
|
143
|
-
f[u[0].canvasId] =
|
|
143
|
+
f[u[0].canvasId] = o ? "right" : "left";
|
|
144
144
|
return u.map(({ canvasId: c, canvas: y }) => {
|
|
145
145
|
const g = P(y);
|
|
146
146
|
return g.length ? {
|
|
147
147
|
canvasId: c,
|
|
148
148
|
choices: g,
|
|
149
|
-
selectedChoiceId:
|
|
149
|
+
selectedChoiceId: l(c),
|
|
150
150
|
side: f[c] ?? "left"
|
|
151
151
|
} : null;
|
|
152
152
|
}).filter((c) => c !== null);
|
|
@@ -169,29 +169,29 @@ function T(e) {
|
|
|
169
169
|
let t = ((r = e.getImages) == null ? void 0 : r.call(e)) || [];
|
|
170
170
|
return (!t || !t.length) && e.getContent && (t = e.getContent()), t || [];
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function $(e) {
|
|
173
173
|
const t = (e == null ? void 0 : e.__jsonld) || e;
|
|
174
174
|
return !!(e && (e.id || e["@id"] || t != null && t.service || t != null && t.id || t != null && t["@id"]));
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function N(e, t, r) {
|
|
177
177
|
var s;
|
|
178
178
|
let i = e.getResource ? e.getResource() : null;
|
|
179
179
|
if (!i && e.getBody) {
|
|
180
|
-
const n = e.getBody(),
|
|
181
|
-
if (F(n,
|
|
182
|
-
const u = v(n,
|
|
183
|
-
i = (
|
|
180
|
+
const n = e.getBody(), l = ((s = e.__jsonld) == null ? void 0 : s.body) || e.body;
|
|
181
|
+
if (F(n, l)) {
|
|
182
|
+
const u = v(n, l), o = r == null ? void 0 : r(t);
|
|
183
|
+
i = (o ? u.find((c) => p(c) === o) : null) || u[0] || null;
|
|
184
184
|
} else Array.isArray(n) && n.length > 0 ? i = n[0] : n && (i = n);
|
|
185
185
|
}
|
|
186
|
-
if (i &&
|
|
186
|
+
if (i && !$(i) && (i = null), !i) {
|
|
187
187
|
const n = e.__jsonld || e;
|
|
188
188
|
if (n.body) {
|
|
189
|
-
let
|
|
190
|
-
if (
|
|
191
|
-
const u =
|
|
192
|
-
|
|
189
|
+
let l = n.body;
|
|
190
|
+
if (l.type === "Choice" || l.type === "oa:Choice") {
|
|
191
|
+
const u = l.items || l.item || [], o = r == null ? void 0 : r(t);
|
|
192
|
+
l = (o ? u.find((c) => p(c) === o) : null) || u[0] || null;
|
|
193
193
|
}
|
|
194
|
-
i = Array.isArray(
|
|
194
|
+
i = Array.isArray(l) ? l[0] : l;
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
return i;
|
|
@@ -199,12 +199,12 @@ function R(e, t, r) {
|
|
|
199
199
|
function S(e) {
|
|
200
200
|
return typeof e == "string" ? /^https?:\/\/iiif\.io\/api\/image\//.test(e) || e === "level0" || e === "level1" || e === "level2" : Array.isArray(e) ? e.some((t) => S(t)) : !1;
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function R(e) {
|
|
203
203
|
return typeof e == "string" ? e || null : Array.isArray(e) && e.find(
|
|
204
204
|
(r) => typeof r == "string"
|
|
205
205
|
) || null;
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function w(e) {
|
|
208
208
|
let t = [];
|
|
209
209
|
const r = (e == null ? void 0 : e.__jsonld) || e;
|
|
210
210
|
return r != null && r.service && (t = Array.isArray(r.service) ? r.service : [r.service]), !t.length && (e != null && e.getServices) && (t = e.getServices()), t.length && t.find((i) => {
|
|
@@ -212,14 +212,14 @@ function L(e) {
|
|
|
212
212
|
return s === "ImageService1" || s === "ImageService2" || s === "ImageService3" || S(n);
|
|
213
213
|
}) || null;
|
|
214
214
|
}
|
|
215
|
-
function
|
|
216
|
-
const t =
|
|
215
|
+
function L(e) {
|
|
216
|
+
const t = w(e), r = p(t), i = t ? t.getProfile ? t.getProfile() : t.profile || "" : null;
|
|
217
217
|
return {
|
|
218
218
|
serviceId: r ? I(r) : null,
|
|
219
|
-
serviceProfile:
|
|
219
|
+
serviceProfile: R(i)
|
|
220
220
|
};
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function V(e) {
|
|
223
223
|
if (!e || !e.includes("/iiif/"))
|
|
224
224
|
return null;
|
|
225
225
|
const t = e.split("/"), r = t.findIndex(
|
|
@@ -228,12 +228,12 @@ function q(e) {
|
|
|
228
228
|
return r > 0 ? t.slice(0, r).join("/") : null;
|
|
229
229
|
}
|
|
230
230
|
function Z(e, t) {
|
|
231
|
-
var n,
|
|
231
|
+
var n, l, u;
|
|
232
232
|
const r = t === void 0 ? "Untitled canvas" : `Canvas ${t + 1}`;
|
|
233
233
|
try {
|
|
234
|
-
const
|
|
235
|
-
if (Array.isArray(
|
|
236
|
-
return ((
|
|
234
|
+
const o = (n = e.getLabel) == null ? void 0 : n.call(e);
|
|
235
|
+
if (Array.isArray(o) && o.length > 0)
|
|
236
|
+
return ((l = o[0]) == null ? void 0 : l.value) || r;
|
|
237
237
|
} catch {
|
|
238
238
|
}
|
|
239
239
|
const i = e.label || ((u = e.__jsonld) == null ? void 0 : u.label);
|
|
@@ -242,31 +242,31 @@ function Z(e, t) {
|
|
|
242
242
|
const s = (i == null ? void 0 : i.none) || (i == null ? void 0 : i.en);
|
|
243
243
|
return Array.isArray(s) && s.length > 0 ? s[0] : r;
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function q(e) {
|
|
246
246
|
var t, r;
|
|
247
247
|
return p(e) || ((t = e == null ? void 0 : e.getCanvasId) == null ? void 0 : t.call(e)) || ((r = e == null ? void 0 : e.getId) == null ? void 0 : r.call(e)) || "";
|
|
248
248
|
}
|
|
249
249
|
function O(e, t = {}) {
|
|
250
|
-
const r =
|
|
250
|
+
const r = q(e);
|
|
251
251
|
if (!r)
|
|
252
252
|
return null;
|
|
253
253
|
const i = T(e);
|
|
254
254
|
if (!i.length)
|
|
255
255
|
return null;
|
|
256
|
-
const s = i[0], n =
|
|
256
|
+
const s = i[0], n = N(
|
|
257
257
|
s,
|
|
258
258
|
r,
|
|
259
259
|
t.getSelectedChoice
|
|
260
260
|
);
|
|
261
261
|
if (!n)
|
|
262
262
|
return null;
|
|
263
|
-
const
|
|
263
|
+
const l = p(n), u = L(n), o = u.serviceId || V(l);
|
|
264
264
|
return {
|
|
265
265
|
canvasId: r,
|
|
266
266
|
annotation: s,
|
|
267
267
|
resource: n,
|
|
268
|
-
resourceId:
|
|
269
|
-
serviceId:
|
|
268
|
+
resourceId: l,
|
|
269
|
+
serviceId: o,
|
|
270
270
|
serviceProfile: u.serviceProfile
|
|
271
271
|
};
|
|
272
272
|
}
|
|
@@ -277,8 +277,8 @@ function E(e, t = {}) {
|
|
|
277
277
|
function B(e, t = {
|
|
278
278
|
width: 1600
|
|
279
279
|
}) {
|
|
280
|
-
const r = I(e), i = t.quality || "default", s = t.format || "jpg"
|
|
281
|
-
return `${r}/full/${
|
|
280
|
+
const r = I(e), i = t.quality || "default", s = t.format || "jpg", n = typeof t.width == "number" ? Math.max(1, Math.round(t.width)) : null, l = typeof t.height == "number" ? Math.max(1, Math.round(t.height)) : null, u = n ? `${n},` : `,${l || 1600}`;
|
|
281
|
+
return `${r}/full/${u}/0/${i}.${s}`;
|
|
282
282
|
}
|
|
283
283
|
function J({
|
|
284
284
|
canvases: e,
|
|
@@ -290,15 +290,15 @@ function J({
|
|
|
290
290
|
}) {
|
|
291
291
|
if (!e.length || t < 0 || !e[t])
|
|
292
292
|
return null;
|
|
293
|
-
let
|
|
294
|
-
i === "continuous" ?
|
|
293
|
+
let l = [e[t]];
|
|
294
|
+
i === "continuous" ? l = e : i === "paged" && (l = C({
|
|
295
295
|
canvases: e,
|
|
296
296
|
currentCanvasId: r,
|
|
297
297
|
currentCanvasIndex: t,
|
|
298
298
|
viewingMode: i,
|
|
299
299
|
pagedOffset: s
|
|
300
|
-
}).map(({ canvas:
|
|
301
|
-
const u =
|
|
300
|
+
}).map(({ canvas: o }) => o));
|
|
301
|
+
const u = l.map((o) => E(o, { getSelectedChoice: n })).filter((o) => o !== null);
|
|
302
302
|
return u.length ? u : null;
|
|
303
303
|
}
|
|
304
304
|
function j(e) {
|
|
@@ -319,7 +319,7 @@ function d(e) {
|
|
|
319
319
|
function G(e) {
|
|
320
320
|
const t = H(e);
|
|
321
321
|
if (t)
|
|
322
|
-
return
|
|
322
|
+
return M(t);
|
|
323
323
|
const r = U(e);
|
|
324
324
|
return r ? {
|
|
325
325
|
type: "RECTANGLE",
|
|
@@ -360,35 +360,35 @@ function _(e) {
|
|
|
360
360
|
}
|
|
361
361
|
return (t == null ? void 0 : t.type) === "SvgSelector" && t.value ? t.value : ((r = t == null ? void 0 : t.item) == null ? void 0 : r.type) === "SvgSelector" && t.item.value ? t.item.value : null;
|
|
362
362
|
}
|
|
363
|
-
function
|
|
363
|
+
function M(e) {
|
|
364
364
|
try {
|
|
365
365
|
const r = new DOMParser().parseFromString(e, "image/svg+xml");
|
|
366
366
|
if (r.documentElement.nodeName === "parsererror")
|
|
367
367
|
return console.warn("Failed to parse SVG selector:", e), null;
|
|
368
368
|
const i = [], s = r.querySelectorAll("polygon");
|
|
369
|
-
for (const
|
|
370
|
-
const f =
|
|
369
|
+
for (const o of s) {
|
|
370
|
+
const f = o.getAttribute("points");
|
|
371
371
|
if (f) {
|
|
372
|
-
const c =
|
|
372
|
+
const c = z(f);
|
|
373
373
|
i.push(...c);
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
const n = r.querySelectorAll("path");
|
|
377
|
-
for (const
|
|
378
|
-
const f =
|
|
377
|
+
for (const o of n) {
|
|
378
|
+
const f = o.getAttribute("d");
|
|
379
379
|
if (f) {
|
|
380
|
-
const c =
|
|
380
|
+
const c = D(f);
|
|
381
381
|
i.push(...c);
|
|
382
382
|
}
|
|
383
383
|
}
|
|
384
|
-
const
|
|
385
|
-
for (const
|
|
386
|
-
const f = parseFloat(
|
|
384
|
+
const l = r.querySelectorAll("circle");
|
|
385
|
+
for (const o of l) {
|
|
386
|
+
const f = parseFloat(o.getAttribute("cx") || "0"), c = parseFloat(o.getAttribute("cy") || "0"), y = parseFloat(o.getAttribute("r") || "0"), g = X(f, c, y);
|
|
387
387
|
i.push(...g);
|
|
388
388
|
}
|
|
389
389
|
const u = r.querySelectorAll("rect");
|
|
390
|
-
for (const
|
|
391
|
-
const f = parseFloat(
|
|
390
|
+
for (const o of u) {
|
|
391
|
+
const f = parseFloat(o.getAttribute("x") || "0"), c = parseFloat(o.getAttribute("y") || "0"), y = parseFloat(o.getAttribute("width") || "0"), g = parseFloat(o.getAttribute("height") || "0");
|
|
392
392
|
i.push([f, c], [f + y, c], [f + y, c + g], [f, c + g]);
|
|
393
393
|
}
|
|
394
394
|
return i.length === 0 ? null : {
|
|
@@ -399,15 +399,15 @@ function D(e) {
|
|
|
399
399
|
return console.warn("Failed to convert SVG to polygon:", t), null;
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
|
-
function
|
|
402
|
+
function z(e) {
|
|
403
403
|
const t = [], r = e.trim().split(/\s+/);
|
|
404
404
|
for (const i of r) {
|
|
405
|
-
const [s, n] = i.split(",").map((
|
|
405
|
+
const [s, n] = i.split(",").map((l) => parseFloat(l));
|
|
406
406
|
!isNaN(s) && !isNaN(n) && t.push([s, n]);
|
|
407
407
|
}
|
|
408
408
|
return t;
|
|
409
409
|
}
|
|
410
|
-
function
|
|
410
|
+
function D(e) {
|
|
411
411
|
const t = [], r = /[ML]\s*([\d.]+)[,\s]+([\d.]+)/g;
|
|
412
412
|
let i;
|
|
413
413
|
for (; (i = r.exec(e)) !== null; ) {
|
|
@@ -416,11 +416,11 @@ function z(e) {
|
|
|
416
416
|
}
|
|
417
417
|
return t;
|
|
418
418
|
}
|
|
419
|
-
function
|
|
419
|
+
function X(e, t, r, i = 8) {
|
|
420
420
|
const s = [];
|
|
421
421
|
for (let n = 0; n < i; n++) {
|
|
422
|
-
const
|
|
423
|
-
s.push([u,
|
|
422
|
+
const l = n / i * Math.PI * 2, u = e + r * Math.cos(l), o = t + r * Math.sin(l);
|
|
423
|
+
s.push([u, o]);
|
|
424
424
|
}
|
|
425
425
|
return s;
|
|
426
426
|
}
|
|
@@ -475,12 +475,12 @@ function W(e) {
|
|
|
475
475
|
for (const s of i) {
|
|
476
476
|
const n = s.getValue ? s.getValue() : "";
|
|
477
477
|
if (n) {
|
|
478
|
-
const
|
|
478
|
+
const l = s.getFormat ? s.getFormat() : "", u = s.getPurpose ? s.getPurpose() : void 0;
|
|
479
479
|
t.push({
|
|
480
480
|
value: n,
|
|
481
|
-
isHtml:
|
|
481
|
+
isHtml: l === "text/html" || l === "application/html",
|
|
482
482
|
purpose: u,
|
|
483
|
-
format:
|
|
483
|
+
format: l
|
|
484
484
|
});
|
|
485
485
|
}
|
|
486
486
|
}
|
|
@@ -534,7 +534,7 @@ export {
|
|
|
534
534
|
Y as c,
|
|
535
535
|
Z as d,
|
|
536
536
|
W as e,
|
|
537
|
-
|
|
537
|
+
q as f,
|
|
538
538
|
k as g,
|
|
539
539
|
B as h,
|
|
540
540
|
ee as p,
|