@annotorious/core 3.0.0-rc.14 → 3.0.0-rc.16
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/annotorious-core.es.js +128 -127
- package/dist/annotorious-core.es.js.map +1 -1
- package/dist/model/DrawingStyle.d.ts +1 -0
- package/dist/model/DrawingStyle.d.ts.map +1 -1
- package/dist/model/W3CAnnotation.d.ts +1 -0
- package/dist/model/W3CAnnotation.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -26,7 +26,7 @@ function B(e, n) {
|
|
|
26
26
|
}
|
|
27
27
|
function $() {
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function W(e, n) {
|
|
30
30
|
return e != e ? n == n : e !== n || e && typeof e == "object" || typeof e == "function";
|
|
31
31
|
}
|
|
32
32
|
const k = [];
|
|
@@ -34,11 +34,11 @@ function _(e, n = $) {
|
|
|
34
34
|
let t;
|
|
35
35
|
const o = /* @__PURE__ */ new Set();
|
|
36
36
|
function i(b) {
|
|
37
|
-
if (
|
|
38
|
-
const
|
|
37
|
+
if (W(e, b) && (e = b, t)) {
|
|
38
|
+
const w = !k.length;
|
|
39
39
|
for (const u of o)
|
|
40
40
|
u[1](), k.push(u, e);
|
|
41
|
-
if (
|
|
41
|
+
if (w) {
|
|
42
42
|
for (let u = 0; u < k.length; u += 2)
|
|
43
43
|
k[u][0](k[u + 1]);
|
|
44
44
|
k.length = 0;
|
|
@@ -48,15 +48,15 @@ function _(e, n = $) {
|
|
|
48
48
|
function h(b) {
|
|
49
49
|
i(b(e));
|
|
50
50
|
}
|
|
51
|
-
function U(b,
|
|
52
|
-
const u = [b,
|
|
51
|
+
function U(b, w = $) {
|
|
52
|
+
const u = [b, w];
|
|
53
53
|
return o.add(u), o.size === 1 && (t = n(i) || $), b(e), () => {
|
|
54
54
|
o.delete(u), o.size === 0 && t && (t(), t = null);
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
return { set: i, update: h, subscribe: U };
|
|
58
58
|
}
|
|
59
|
-
const
|
|
59
|
+
const be = (e) => {
|
|
60
60
|
const { subscribe: n, set: t } = _(null);
|
|
61
61
|
let o = null;
|
|
62
62
|
return n((i) => o = i), e.observe(({ changes: i }) => {
|
|
@@ -73,8 +73,8 @@ const Ee = (e) => {
|
|
|
73
73
|
set: t
|
|
74
74
|
};
|
|
75
75
|
};
|
|
76
|
-
var
|
|
77
|
-
const V = { selected: [] },
|
|
76
|
+
var q = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE = "NONE", e))(q || {});
|
|
77
|
+
const V = { selected: [] }, ve = (e, n = "EDIT") => {
|
|
78
78
|
const { subscribe: t, set: o } = _(V);
|
|
79
79
|
let i = V;
|
|
80
80
|
t((s) => i = s);
|
|
@@ -86,10 +86,10 @@ const V = { selected: [] }, be = (e, n = "EDIT") => {
|
|
|
86
86
|
return !1;
|
|
87
87
|
const f = typeof s == "string" ? s : s.id;
|
|
88
88
|
return i.selected.some((y) => y.id === f);
|
|
89
|
-
},
|
|
89
|
+
}, w = (s, f) => {
|
|
90
90
|
const y = e.getAnnotation(s);
|
|
91
91
|
if (y) {
|
|
92
|
-
const A =
|
|
92
|
+
const A = G(y, n);
|
|
93
93
|
o(A === "EDIT" ? { selected: [{ id: s, editable: !0 }], pointerEvent: f } : A === "SELECT" ? { selected: [{ id: s }], pointerEvent: f } : { selected: [], pointerEvent: f });
|
|
94
94
|
} else
|
|
95
95
|
console.warn("Invalid selection: " + s);
|
|
@@ -104,7 +104,7 @@ const V = { selected: [] }, be = (e, n = "EDIT") => {
|
|
|
104
104
|
};
|
|
105
105
|
return e.observe(({ changes: s }) => T(s.deleted.map((f) => f.id))), {
|
|
106
106
|
clear: h,
|
|
107
|
-
clickSelect:
|
|
107
|
+
clickSelect: w,
|
|
108
108
|
get selected() {
|
|
109
109
|
return i ? [...i.selected] : null;
|
|
110
110
|
},
|
|
@@ -116,7 +116,7 @@ const V = { selected: [] }, be = (e, n = "EDIT") => {
|
|
|
116
116
|
setSelected: u,
|
|
117
117
|
subscribe: t
|
|
118
118
|
};
|
|
119
|
-
},
|
|
119
|
+
}, G = (e, n) => typeof n == "function" ? n(e) || "EDIT" : n || "EDIT";
|
|
120
120
|
let z;
|
|
121
121
|
const H = new Uint8Array(16);
|
|
122
122
|
function F() {
|
|
@@ -146,14 +146,14 @@ function X(e, n, t) {
|
|
|
146
146
|
}
|
|
147
147
|
return J(o);
|
|
148
148
|
}
|
|
149
|
-
const
|
|
149
|
+
const Ce = (e) => {
|
|
150
150
|
const { creator: n, updatedBy: t } = e.target, o = e.bodies.reduce((i, h) => [...i, h.creator, h.updatedBy], []);
|
|
151
151
|
return [
|
|
152
152
|
n,
|
|
153
153
|
t,
|
|
154
154
|
...o
|
|
155
155
|
].filter((i) => i);
|
|
156
|
-
},
|
|
156
|
+
}, we = (e, n, t, o) => ({
|
|
157
157
|
id: X(),
|
|
158
158
|
annotation: e.id,
|
|
159
159
|
created: t || /* @__PURE__ */ new Date(),
|
|
@@ -186,9 +186,9 @@ const oe = (e, n) => {
|
|
|
186
186
|
if (!(!e.options.origin || e.options.origin === o))
|
|
187
187
|
return !1;
|
|
188
188
|
if (e.options.ignore) {
|
|
189
|
-
const { ignore: b } = e.options,
|
|
190
|
-
if (!(
|
|
191
|
-
const T = (h = t.updated) == null ? void 0 : h.some((f) =>
|
|
189
|
+
const { ignore: b } = e.options, w = (T) => (T == null ? void 0 : T.length) > 0;
|
|
190
|
+
if (!(w(t.created) || w(t.deleted))) {
|
|
191
|
+
const T = (h = t.updated) == null ? void 0 : h.some((f) => w(f.bodiesCreated) || w(f.bodiesDeleted) || w(f.bodiesUpdated)), s = (U = t.updated) == null ? void 0 : U.some((f) => f.targetUpdated);
|
|
192
192
|
if (b === "BODY_ONLY" && T && !s || b === "TARGET_ONLY" && s && !T)
|
|
193
193
|
return !1;
|
|
194
194
|
}
|
|
@@ -203,7 +203,7 @@ const oe = (e, n) => {
|
|
|
203
203
|
} else
|
|
204
204
|
return !0;
|
|
205
205
|
}, se = (e, n) => {
|
|
206
|
-
const t = new Set((e.created || []).map((s) => s.id)), o = new Set((e.updated || []).map(({ newValue: s }) => s.id)), i = new Set((n.created || []).map((s) => s.id)), h = new Set((n.deleted || []).map((s) => s.id)), U = new Set((n.updated || []).map(({ oldValue: s }) => s.id)), b = new Set((n.updated || []).filter(({ oldValue: s }) => t.has(s.id) || o.has(s.id)).map(({ oldValue: s }) => s.id)),
|
|
206
|
+
const t = new Set((e.created || []).map((s) => s.id)), o = new Set((e.updated || []).map(({ newValue: s }) => s.id)), i = new Set((n.created || []).map((s) => s.id)), h = new Set((n.deleted || []).map((s) => s.id)), U = new Set((n.updated || []).map(({ oldValue: s }) => s.id)), b = new Set((n.updated || []).filter(({ oldValue: s }) => t.has(s.id) || o.has(s.id)).map(({ oldValue: s }) => s.id)), w = [
|
|
207
207
|
...(e.created || []).filter((s) => !h.has(s.id)).map((s) => U.has(s.id) ? n.updated.find(({ oldValue: f }) => f.id === s.id).newValue : s),
|
|
208
208
|
...n.created || []
|
|
209
209
|
], u = [
|
|
@@ -220,8 +220,8 @@ const oe = (e, n) => {
|
|
|
220
220
|
}),
|
|
221
221
|
...(n.updated || []).filter(({ oldValue: s }) => !b.has(s.id))
|
|
222
222
|
];
|
|
223
|
-
return { created:
|
|
224
|
-
}, ie = (e) => e.id !== void 0,
|
|
223
|
+
return { created: w, deleted: u, updated: T };
|
|
224
|
+
}, ie = (e) => e.id !== void 0, ye = () => {
|
|
225
225
|
const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (r, l = {}) => t.push({ onChange: r, options: l }), i = (r) => {
|
|
226
226
|
const l = t.findIndex((a) => a.onChange == r);
|
|
227
227
|
l > -1 && t.splice(l, 1);
|
|
@@ -243,18 +243,18 @@ const oe = (e, n) => {
|
|
|
243
243
|
throw Error(`Cannot add annotation ${r.id} - exists already`);
|
|
244
244
|
e.set(r.id, r), r.bodies.forEach((p) => n.set(p.id, r.id)), h(l, { created: [r] });
|
|
245
245
|
}, b = (r, l) => {
|
|
246
|
-
const a = typeof r == "string" ? l : r, p = typeof r == "string" ? r : r.id,
|
|
247
|
-
if (
|
|
248
|
-
const D = M(
|
|
249
|
-
return p === a.id ? e.set(p, a) : (e.delete(p), e.set(a.id, a)),
|
|
246
|
+
const a = typeof r == "string" ? l : r, p = typeof r == "string" ? r : r.id, v = e.get(p);
|
|
247
|
+
if (v) {
|
|
248
|
+
const D = M(v, a);
|
|
249
|
+
return p === a.id ? e.set(p, a) : (e.delete(p), e.set(a.id, a)), v.bodies.forEach((x) => n.delete(x.id)), a.bodies.forEach((x) => n.set(x.id, a.id)), D;
|
|
250
250
|
} else
|
|
251
251
|
console.warn(`Cannot update annotation ${p} - does not exist`);
|
|
252
|
-
},
|
|
253
|
-
const p = ie(l) ? a : l,
|
|
254
|
-
|
|
252
|
+
}, w = (r, l = O.LOCAL, a = O.LOCAL) => {
|
|
253
|
+
const p = ie(l) ? a : l, v = b(r, l);
|
|
254
|
+
v && h(p, { updated: [v] });
|
|
255
255
|
}, u = (r, l = O.LOCAL) => {
|
|
256
|
-
const a = r.reduce((p,
|
|
257
|
-
const D = b(
|
|
256
|
+
const a = r.reduce((p, v) => {
|
|
257
|
+
const D = b(v);
|
|
258
258
|
return D ? [...p, D] : p;
|
|
259
259
|
}, []);
|
|
260
260
|
a.length > 0 && h(l, { updated: a });
|
|
@@ -278,18 +278,18 @@ const oe = (e, n) => {
|
|
|
278
278
|
}, y = (r, l = !0, a = O.LOCAL) => {
|
|
279
279
|
if (l) {
|
|
280
280
|
const p = [...e.values()];
|
|
281
|
-
e.clear(), n.clear(), r.forEach((
|
|
282
|
-
e.set(
|
|
281
|
+
e.clear(), n.clear(), r.forEach((v) => {
|
|
282
|
+
e.set(v.id, v), v.bodies.forEach((D) => n.set(D.id, v.id));
|
|
283
283
|
}), h(a, { created: r, deleted: p });
|
|
284
284
|
} else {
|
|
285
|
-
const p = r.reduce((
|
|
285
|
+
const p = r.reduce((v, D) => {
|
|
286
286
|
const x = e.get(D.id);
|
|
287
|
-
return x ? [...
|
|
287
|
+
return x ? [...v, x] : v;
|
|
288
288
|
}, []);
|
|
289
289
|
if (p.length > 0)
|
|
290
|
-
throw Error(`Bulk insert would overwrite the following annotations: ${p.map((
|
|
291
|
-
r.forEach((
|
|
292
|
-
e.set(
|
|
290
|
+
throw Error(`Bulk insert would overwrite the following annotations: ${p.map((v) => v.id).join(", ")}`);
|
|
291
|
+
r.forEach((v) => {
|
|
292
|
+
e.set(v.id, v), v.bodies.forEach((D) => n.set(D.id, v.id));
|
|
293
293
|
}), h(a, { created: r });
|
|
294
294
|
}
|
|
295
295
|
}, A = (r) => {
|
|
@@ -300,25 +300,25 @@ const oe = (e, n) => {
|
|
|
300
300
|
}, L = (r, l = O.LOCAL) => {
|
|
301
301
|
const a = A(r);
|
|
302
302
|
a && h(l, { deleted: [a] });
|
|
303
|
-
},
|
|
304
|
-
const a = r.reduce((p,
|
|
305
|
-
const D = A(
|
|
303
|
+
}, C = (r, l = O.LOCAL) => {
|
|
304
|
+
const a = r.reduce((p, v) => {
|
|
305
|
+
const D = A(v);
|
|
306
306
|
return D ? [...p, D] : p;
|
|
307
307
|
}, []);
|
|
308
308
|
a.length > 0 && h(l, { deleted: a });
|
|
309
309
|
}, c = (r, l = O.LOCAL) => {
|
|
310
310
|
const a = e.get(r.annotation);
|
|
311
311
|
if (a) {
|
|
312
|
-
const p = a.bodies.find((
|
|
312
|
+
const p = a.bodies.find((v) => v.id === r.id);
|
|
313
313
|
if (p) {
|
|
314
314
|
n.delete(p.id);
|
|
315
|
-
const
|
|
315
|
+
const v = {
|
|
316
316
|
...a,
|
|
317
317
|
bodies: a.bodies.filter((x) => x.id !== r.id)
|
|
318
318
|
};
|
|
319
|
-
e.set(a.id,
|
|
319
|
+
e.set(a.id, v), h(l, { updated: [{
|
|
320
320
|
oldValue: a,
|
|
321
|
-
newValue:
|
|
321
|
+
newValue: v,
|
|
322
322
|
bodiesDeleted: [p]
|
|
323
323
|
}] });
|
|
324
324
|
} else
|
|
@@ -331,7 +331,7 @@ const oe = (e, n) => {
|
|
|
331
331
|
}, d = (r) => {
|
|
332
332
|
const l = n.get(r);
|
|
333
333
|
if (l) {
|
|
334
|
-
const p = m(l).bodies.find((
|
|
334
|
+
const p = m(l).bodies.find((v) => v.id === r);
|
|
335
335
|
if (p)
|
|
336
336
|
return p;
|
|
337
337
|
console.error(`Store integrity error: body ${r} in index, but not in annotation`);
|
|
@@ -342,13 +342,13 @@ const oe = (e, n) => {
|
|
|
342
342
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
343
343
|
const a = e.get(r.annotation);
|
|
344
344
|
if (a) {
|
|
345
|
-
const p = a.bodies.find((D) => D.id === r.id),
|
|
345
|
+
const p = a.bodies.find((D) => D.id === r.id), v = {
|
|
346
346
|
...a,
|
|
347
347
|
bodies: a.bodies.map((D) => D.id === p.id ? l : D)
|
|
348
348
|
};
|
|
349
|
-
return e.set(a.id,
|
|
349
|
+
return e.set(a.id, v), p.id !== l.id && (n.delete(p.id), n.set(l.id, v.id)), {
|
|
350
350
|
oldValue: a,
|
|
351
|
-
newValue:
|
|
351
|
+
newValue: v,
|
|
352
352
|
bodiesUpdated: [{ oldBody: p, newBody: l }]
|
|
353
353
|
};
|
|
354
354
|
} else
|
|
@@ -385,7 +385,7 @@ const oe = (e, n) => {
|
|
|
385
385
|
addBody: T,
|
|
386
386
|
all: s,
|
|
387
387
|
bulkAddAnnotation: y,
|
|
388
|
-
bulkDeleteAnnotation:
|
|
388
|
+
bulkDeleteAnnotation: C,
|
|
389
389
|
bulkUpdateAnnotation: u,
|
|
390
390
|
bulkUpdateBodies: S,
|
|
391
391
|
bulkUpdateTargets: (r, l = O.LOCAL) => {
|
|
@@ -399,14 +399,14 @@ const oe = (e, n) => {
|
|
|
399
399
|
getBody: d,
|
|
400
400
|
observe: o,
|
|
401
401
|
unobserve: i,
|
|
402
|
-
updateAnnotation:
|
|
402
|
+
updateAnnotation: w,
|
|
403
403
|
updateBody: g,
|
|
404
404
|
updateTarget: (r, l = O.LOCAL) => {
|
|
405
405
|
const a = I(r);
|
|
406
406
|
a && h(l, { updated: [a] });
|
|
407
407
|
}
|
|
408
408
|
};
|
|
409
|
-
},
|
|
409
|
+
}, Ue = (e) => ({
|
|
410
410
|
...e,
|
|
411
411
|
subscribe: (t) => {
|
|
412
412
|
const o = (i) => t(i.state);
|
|
@@ -428,7 +428,7 @@ let P = () => ({
|
|
|
428
428
|
};
|
|
429
429
|
}
|
|
430
430
|
});
|
|
431
|
-
const de = 250,
|
|
431
|
+
const de = 250, Le = (e) => {
|
|
432
432
|
const n = P(), t = [];
|
|
433
433
|
let o = -1, i = !1, h = 0;
|
|
434
434
|
const U = (d) => {
|
|
@@ -445,7 +445,7 @@ const de = 250, Ue = (e) => {
|
|
|
445
445
|
i = !1;
|
|
446
446
|
};
|
|
447
447
|
e.observe(U, { origin: O.LOCAL });
|
|
448
|
-
const b = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkDeleteAnnotation(d),
|
|
448
|
+
const b = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkDeleteAnnotation(d), w = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkAddAnnotation(d, !1), u = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkUpdateAnnotation(d.map(({ oldValue: E }) => E)), T = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkUpdateAnnotation(d.map(({ newValue: E }) => E)), s = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkAddAnnotation(d, !1), f = (d) => (d == null ? void 0 : d.length) > 0 && e.bulkDeleteAnnotation(d);
|
|
449
449
|
return {
|
|
450
450
|
canRedo: () => t.length - 1 > o,
|
|
451
451
|
canUndo: () => o > -1,
|
|
@@ -455,7 +455,7 @@ const de = 250, Ue = (e) => {
|
|
|
455
455
|
if (t.length - 1 > o) {
|
|
456
456
|
i = !0;
|
|
457
457
|
const { created: d, updated: E, deleted: g } = t[o + 1];
|
|
458
|
-
|
|
458
|
+
w(d), T(E), f(g), n.emit("redo", t[o + 1]), o += 1;
|
|
459
459
|
}
|
|
460
460
|
},
|
|
461
461
|
undo: () => {
|
|
@@ -466,23 +466,23 @@ const de = 250, Ue = (e) => {
|
|
|
466
466
|
}
|
|
467
467
|
}
|
|
468
468
|
};
|
|
469
|
-
},
|
|
469
|
+
}, Se = () => {
|
|
470
470
|
const { subscribe: e, set: n } = _([]);
|
|
471
471
|
return {
|
|
472
472
|
subscribe: e,
|
|
473
473
|
set: n
|
|
474
474
|
};
|
|
475
|
-
},
|
|
476
|
-
const { store: i, selection: h, hover: U, viewport: b } = e,
|
|
475
|
+
}, Te = (e, n, t, o) => {
|
|
476
|
+
const { store: i, selection: h, hover: U, viewport: b } = e, w = /* @__PURE__ */ new Map();
|
|
477
477
|
let u = [], T, s;
|
|
478
478
|
const f = (c, m) => {
|
|
479
|
-
|
|
479
|
+
w.has(c) ? w.get(c).push(m) : w.set(c, [m]);
|
|
480
480
|
}, y = (c, m) => {
|
|
481
|
-
const d =
|
|
481
|
+
const d = w.get(c);
|
|
482
482
|
d && d.indexOf(m) > 0 && d.splice(d.indexOf(m), 1);
|
|
483
483
|
}, A = (c, m, d) => {
|
|
484
|
-
|
|
485
|
-
|
|
484
|
+
w.has(c) && setTimeout(() => {
|
|
485
|
+
w.get(c).forEach((E) => {
|
|
486
486
|
if (t) {
|
|
487
487
|
const g = Array.isArray(m) ? m.map((I) => t.serialize(I)) : t.serialize(m), S = d ? d instanceof PointerEvent ? d : t.serialize(d) : void 0;
|
|
488
488
|
E(g, S);
|
|
@@ -545,12 +545,12 @@ const de = 250, Ue = (e) => {
|
|
|
545
545
|
}));
|
|
546
546
|
}
|
|
547
547
|
}, { origin: O.REMOTE });
|
|
548
|
-
const
|
|
548
|
+
const C = (c) => (m) => {
|
|
549
549
|
const { created: d, deleted: E, updated: g } = m;
|
|
550
550
|
d.forEach((S) => A("createAnnotation", S)), E.forEach((S) => A("deleteAnnotation", S)), c ? g.forEach((S) => A("updateAnnotation", S.oldValue, S.newValue)) : g.forEach((S) => A("updateAnnotation", S.newValue, S.oldValue));
|
|
551
551
|
};
|
|
552
|
-
return n.on("undo",
|
|
553
|
-
},
|
|
552
|
+
return n.on("undo", C(!0)), n.on("redo", C(!1)), { on: f, off: y, emit: A };
|
|
553
|
+
}, Oe = (e) => (n) => n.map((t) => e.serialize(t)), re = (e) => (n) => n.reduce((t, o) => {
|
|
554
554
|
const { parsed: i, error: h } = e.parse(o);
|
|
555
555
|
return h ? {
|
|
556
556
|
parsed: t.parsed,
|
|
@@ -559,43 +559,43 @@ const de = 250, Ue = (e) => {
|
|
|
559
559
|
parsed: [...t.parsed, i],
|
|
560
560
|
failed: t.failed
|
|
561
561
|
};
|
|
562
|
-
}, { parsed: [], failed: [] }),
|
|
563
|
-
const { store: o, selection: i } = e, h = (
|
|
562
|
+
}, { parsed: [], failed: [] }), De = (e, n, t) => {
|
|
563
|
+
const { store: o, selection: i } = e, h = (C) => {
|
|
564
564
|
if (t) {
|
|
565
|
-
const { parsed: c, error: m } = t.parse(
|
|
565
|
+
const { parsed: c, error: m } = t.parse(C);
|
|
566
566
|
c ? o.addAnnotation(c, O.REMOTE) : console.error(m);
|
|
567
567
|
} else
|
|
568
|
-
o.addAnnotation(
|
|
569
|
-
}, U = () => i.clear(), b = () => o.clear(),
|
|
570
|
-
const c = o.getAnnotation(
|
|
568
|
+
o.addAnnotation(C, O.REMOTE);
|
|
569
|
+
}, U = () => i.clear(), b = () => o.clear(), w = (C) => {
|
|
570
|
+
const c = o.getAnnotation(C);
|
|
571
571
|
return t && c ? t.serialize(c) : c;
|
|
572
572
|
}, u = () => t ? o.all().map(t.serialize) : o.all(), T = () => {
|
|
573
573
|
var m;
|
|
574
574
|
const c = (((m = i.selected) == null ? void 0 : m.map((d) => d.id)) || []).map((d) => o.getAnnotation(d));
|
|
575
575
|
return t ? c.map(t.serialize) : c;
|
|
576
|
-
}, s = (
|
|
577
|
-
if (typeof
|
|
578
|
-
const c = o.getAnnotation(
|
|
579
|
-
return o.deleteAnnotation(
|
|
576
|
+
}, s = (C) => fetch(C).then((c) => c.json()).then((c) => (y(c), c)), f = (C) => {
|
|
577
|
+
if (typeof C == "string") {
|
|
578
|
+
const c = o.getAnnotation(C);
|
|
579
|
+
return o.deleteAnnotation(C), t ? t.serialize(c) : c;
|
|
580
580
|
} else {
|
|
581
|
-
const c = t ? t.parse(
|
|
582
|
-
return o.deleteAnnotation(c),
|
|
581
|
+
const c = t ? t.parse(C).parsed : C;
|
|
582
|
+
return o.deleteAnnotation(c), C;
|
|
583
583
|
}
|
|
584
|
-
}, y = (
|
|
584
|
+
}, y = (C) => {
|
|
585
585
|
if (t) {
|
|
586
|
-
const { parsed: c, failed: m } = re(t)(
|
|
586
|
+
const { parsed: c, failed: m } = re(t)(C);
|
|
587
587
|
m.length > 0 && console.warn(`Discarded ${m.length} invalid annotations`, m), o.bulkAddAnnotation(c, !0, O.REMOTE);
|
|
588
588
|
} else
|
|
589
|
-
o.bulkAddAnnotation(
|
|
590
|
-
}, A = (
|
|
591
|
-
|
|
592
|
-
}, L = (
|
|
589
|
+
o.bulkAddAnnotation(C, !0, O.REMOTE);
|
|
590
|
+
}, A = (C) => {
|
|
591
|
+
C ? i.setSelected(C) : i.clear();
|
|
592
|
+
}, L = (C) => {
|
|
593
593
|
if (t) {
|
|
594
|
-
const c = t.parse(
|
|
594
|
+
const c = t.parse(C).parsed, m = t.serialize(o.getAnnotation(c.id));
|
|
595
595
|
return o.updateAnnotation(c), m;
|
|
596
596
|
} else {
|
|
597
|
-
const c = o.getAnnotation(
|
|
598
|
-
return o.updateAnnotation(
|
|
597
|
+
const c = o.getAnnotation(C.id);
|
|
598
|
+
return o.updateAnnotation(C), c;
|
|
599
599
|
}
|
|
600
600
|
};
|
|
601
601
|
return {
|
|
@@ -604,7 +604,7 @@ const de = 250, Ue = (e) => {
|
|
|
604
604
|
canRedo: n.canRedo,
|
|
605
605
|
canUndo: n.canUndo,
|
|
606
606
|
clearAnnotations: b,
|
|
607
|
-
getAnnotationById:
|
|
607
|
+
getAnnotationById: w,
|
|
608
608
|
getAnnotations: u,
|
|
609
609
|
getSelected: T,
|
|
610
610
|
loadAnnotations: s,
|
|
@@ -621,14 +621,14 @@ let ae = (e) => crypto.getRandomValues(new Uint8Array(e)), ce = (e, n, t) => {
|
|
|
621
621
|
return (h = n) => {
|
|
622
622
|
let U = "";
|
|
623
623
|
for (; ; ) {
|
|
624
|
-
let b = t(i),
|
|
625
|
-
for (;
|
|
626
|
-
if (U += e[b[
|
|
624
|
+
let b = t(i), w = i;
|
|
625
|
+
for (; w--; )
|
|
626
|
+
if (U += e[b[w] & o] || "", U.length === h)
|
|
627
627
|
return U;
|
|
628
628
|
}
|
|
629
629
|
};
|
|
630
630
|
}, le = (e, n = 21) => ce(e, n, ae), ue = (e = 21) => crypto.getRandomValues(new Uint8Array(e)).reduce((n, t) => (t &= 63, t < 36 ? n += t.toString(36) : t < 62 ? n += (t - 26).toString(36).toUpperCase() : t > 62 ? n += "-" : n += "_", n), "");
|
|
631
|
-
const
|
|
631
|
+
const Re = () => ({ isGuest: !0, id: le("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), fe = (e) => {
|
|
632
632
|
const n = JSON.stringify(e);
|
|
633
633
|
let t = 0;
|
|
634
634
|
for (let o = 0, i = n.length; o < i; o++) {
|
|
@@ -636,23 +636,23 @@ const De = () => ({ isGuest: !0, id: le("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
636
636
|
t = (t << 5) - t + h, t |= 0;
|
|
637
637
|
}
|
|
638
638
|
return `${t}`;
|
|
639
|
-
},
|
|
640
|
-
const { id: o, type: i, purpose: h, value: U, created: b, creator:
|
|
639
|
+
}, pe = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, xe = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {
|
|
640
|
+
const { id: o, type: i, purpose: h, value: U, created: b, creator: w, ...u } = t;
|
|
641
641
|
return {
|
|
642
642
|
id: o || `temp-${fe(t)}`,
|
|
643
643
|
annotation: n,
|
|
644
644
|
type: i,
|
|
645
645
|
purpose: h,
|
|
646
646
|
value: U,
|
|
647
|
-
created: b,
|
|
648
|
-
creator:
|
|
647
|
+
created: b ? new Date(b) : void 0,
|
|
648
|
+
creator: pe(w),
|
|
649
649
|
...u
|
|
650
650
|
};
|
|
651
|
-
}),
|
|
651
|
+
}), Be = (e) => e.map((n) => {
|
|
652
652
|
var o;
|
|
653
653
|
const t = { ...n };
|
|
654
654
|
return delete t.annotation, (o = t.id) != null && o.startsWith("temp-") && delete t.id, t;
|
|
655
|
-
}),
|
|
655
|
+
}), he = [
|
|
656
656
|
"#ff7c00",
|
|
657
657
|
// orange
|
|
658
658
|
"#1ac938",
|
|
@@ -671,14 +671,14 @@ const De = () => ({ isGuest: !0, id: le("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
671
671
|
// cyan
|
|
672
672
|
"#023eff"
|
|
673
673
|
// blue
|
|
674
|
-
],
|
|
675
|
-
const e = [...
|
|
674
|
+
], ge = () => {
|
|
675
|
+
const e = [...he];
|
|
676
676
|
return { assignRandomColor: () => {
|
|
677
677
|
const o = Math.floor(Math.random() * e.length), i = e[o];
|
|
678
678
|
return e.splice(o, 1), i;
|
|
679
679
|
}, releaseColor: (o) => e.push(o) };
|
|
680
|
-
},
|
|
681
|
-
const e =
|
|
680
|
+
}, me = () => {
|
|
681
|
+
const e = ge();
|
|
682
682
|
return { addUser: (o, i) => {
|
|
683
683
|
const h = e.assignRandomColor();
|
|
684
684
|
return {
|
|
@@ -687,7 +687,7 @@ const De = () => ({ isGuest: !0, id: le("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
687
687
|
color: h
|
|
688
688
|
};
|
|
689
689
|
}, removeUser: (o) => e.releaseColor(o.appearance.color) };
|
|
690
|
-
},
|
|
690
|
+
}, Ae = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)), Ie = ue(), ke = (e = me()) => {
|
|
691
691
|
const n = P(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = (s, f) => {
|
|
692
692
|
if (t.has(s)) {
|
|
693
693
|
console.warn("Attempt to add user that is already present", s, f);
|
|
@@ -708,9 +708,9 @@ const De = () => ({ isGuest: !0, id: le("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
708
708
|
e.removeUser(f), t.delete(s);
|
|
709
709
|
}, U = (s) => {
|
|
710
710
|
const f = new Set(s.map((L) => L.presenceKey)), y = s.filter(({ presenceKey: L }) => !t.has(L)), A = Array.from(t.values()).filter((L) => !f.has(L.presenceKey));
|
|
711
|
-
y.forEach(({ presenceKey: L, user:
|
|
712
|
-
const { presenceKey:
|
|
713
|
-
o.has(
|
|
711
|
+
y.forEach(({ presenceKey: L, user: C }) => i(L, C)), A.forEach((L) => {
|
|
712
|
+
const { presenceKey: C } = L;
|
|
713
|
+
o.has(C) && n.emit("selectionChange", L, null), h(C);
|
|
714
714
|
}), (y.length > 0 || A.length > 0) && n.emit("presence", u());
|
|
715
715
|
}, b = (s, f) => {
|
|
716
716
|
const y = t.get(s);
|
|
@@ -719,8 +719,8 @@ const De = () => ({ isGuest: !0, id: le("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
719
719
|
return;
|
|
720
720
|
}
|
|
721
721
|
const A = o.get(s);
|
|
722
|
-
(!A || !
|
|
723
|
-
},
|
|
722
|
+
(!A || !Ae(A, f)) && (o.set(s, f), n.emit("selectionChange", y, f));
|
|
723
|
+
}, w = (s, f) => {
|
|
724
724
|
const y = t.get(s);
|
|
725
725
|
if (!y) {
|
|
726
726
|
console.warn("Selection change for user that is not present", s);
|
|
@@ -733,35 +733,36 @@ const De = () => ({ isGuest: !0, id: le("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
733
733
|
notifyActivity: b,
|
|
734
734
|
on: (s, f) => n.on(s, f),
|
|
735
735
|
syncUsers: U,
|
|
736
|
-
updateSelection:
|
|
736
|
+
updateSelection: w
|
|
737
737
|
};
|
|
738
738
|
};
|
|
739
739
|
export {
|
|
740
740
|
ne as Ignore,
|
|
741
741
|
O as Origin,
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
742
|
+
Ie as PRESENCE_KEY,
|
|
743
|
+
q as PointerSelectAction,
|
|
744
|
+
Re as createAnonymousGuest,
|
|
745
|
+
De as createBaseAnnotator,
|
|
746
|
+
we as createBody,
|
|
747
|
+
me as createDefaultAppearenceProvider,
|
|
748
|
+
be as createHoverState,
|
|
749
|
+
Te as createLifecyleObserver,
|
|
750
|
+
ke as createPresenceState,
|
|
751
|
+
ve as createSelectionState,
|
|
752
|
+
ye as createStore,
|
|
753
|
+
Le as createUndoStack,
|
|
754
|
+
Se as createViewportState,
|
|
755
|
+
ge as defaultColorProvider,
|
|
756
756
|
M as diffAnnotations,
|
|
757
|
-
|
|
757
|
+
Ce as getContributors,
|
|
758
758
|
se as mergeChanges,
|
|
759
|
-
|
|
759
|
+
G as onPointerSelect,
|
|
760
760
|
re as parseAll,
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
761
|
+
xe as parseW3CBodies,
|
|
762
|
+
pe as parseW3CUser,
|
|
763
|
+
Oe as serializeAll,
|
|
764
|
+
Be as serializeW3CBodies,
|
|
764
765
|
oe as shouldNotify,
|
|
765
|
-
|
|
766
|
+
Ue as toSvelteStore
|
|
766
767
|
};
|
|
767
768
|
//# sourceMappingURL=annotorious-core.es.js.map
|