@annotorious/core 3.0.0-rc.26 → 3.0.0-rc.28
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var M = Object.prototype.hasOwnProperty;
|
|
2
2
|
function B(e, n) {
|
|
3
3
|
var t, o;
|
|
4
4
|
if (e === n)
|
|
@@ -17,7 +17,7 @@ function B(e, n) {
|
|
|
17
17
|
if (!t || typeof e == "object") {
|
|
18
18
|
o = 0;
|
|
19
19
|
for (t in e)
|
|
20
|
-
if (
|
|
20
|
+
if (M.call(e, t) && ++o && !M.call(n, t) || !(t in n) || !B(e[t], n[t]))
|
|
21
21
|
return !1;
|
|
22
22
|
return Object.keys(n).length === o;
|
|
23
23
|
}
|
|
@@ -26,19 +26,19 @@ function B(e, n) {
|
|
|
26
26
|
}
|
|
27
27
|
function z() {
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function H(e, n) {
|
|
30
30
|
return e != e ? n == n : e !== n || e && typeof e == "object" || typeof e == "function";
|
|
31
31
|
}
|
|
32
32
|
const k = [];
|
|
33
|
-
function
|
|
33
|
+
function Y(e, n = z) {
|
|
34
34
|
let t;
|
|
35
35
|
const o = /* @__PURE__ */ new Set();
|
|
36
36
|
function i(b) {
|
|
37
|
-
if (
|
|
38
|
-
const
|
|
37
|
+
if (H(e, b) && (e = b, t)) {
|
|
38
|
+
const y = !k.length;
|
|
39
39
|
for (const u of o)
|
|
40
40
|
u[1](), k.push(u, e);
|
|
41
|
-
if (
|
|
41
|
+
if (y) {
|
|
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,16 +48,16 @@ function _(e, n = z) {
|
|
|
48
48
|
function p(b) {
|
|
49
49
|
i(b(e));
|
|
50
50
|
}
|
|
51
|
-
function w(b,
|
|
52
|
-
const u = [b,
|
|
51
|
+
function w(b, y = z) {
|
|
52
|
+
const u = [b, y];
|
|
53
53
|
return o.add(u), o.size === 1 && (t = n(i, p) || z), b(e), () => {
|
|
54
54
|
o.delete(u), o.size === 0 && t && (t(), t = null);
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
return { set: i, update: p, subscribe: w };
|
|
58
58
|
}
|
|
59
|
-
const
|
|
60
|
-
const { subscribe: n, set: t } =
|
|
59
|
+
const Ce = (e) => {
|
|
60
|
+
const { subscribe: n, set: t } = Y();
|
|
61
61
|
let o;
|
|
62
62
|
return n((i) => o = i), e.observe(({ changes: i }) => {
|
|
63
63
|
if (o) {
|
|
@@ -73,9 +73,9 @@ const we = (e) => {
|
|
|
73
73
|
set: t
|
|
74
74
|
};
|
|
75
75
|
};
|
|
76
|
-
var
|
|
77
|
-
const V = { selected: [] },
|
|
78
|
-
const { subscribe: t, set: o } =
|
|
76
|
+
var F = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE = "NONE", e))(F || {});
|
|
77
|
+
const V = { selected: [] }, Le = (e, n = "EDIT") => {
|
|
78
|
+
const { subscribe: t, set: o } = Y(V);
|
|
79
79
|
let i = V;
|
|
80
80
|
t((s) => i = s);
|
|
81
81
|
const p = () => o(V), w = () => {
|
|
@@ -86,25 +86,30 @@ const V = { selected: [] }, Ce = (e, n = "EDIT") => {
|
|
|
86
86
|
return !1;
|
|
87
87
|
const h = typeof s == "string" ? s : s.id;
|
|
88
88
|
return i.selected.some((L) => L.id === h);
|
|
89
|
-
},
|
|
89
|
+
}, y = (s, h) => {
|
|
90
90
|
const L = e.getAnnotation(s);
|
|
91
91
|
if (L) {
|
|
92
|
-
const
|
|
93
|
-
o(
|
|
92
|
+
const v = P(L, n);
|
|
93
|
+
o(v === "EDIT" ? { selected: [{ id: s, editable: !0 }], pointerEvent: h } : v === "SELECT" ? { selected: [{ id: s }], pointerEvent: h } : { selected: [], pointerEvent: h });
|
|
94
94
|
} else
|
|
95
95
|
console.warn("Invalid selection: " + s);
|
|
96
|
-
}, u = (s, h
|
|
97
|
-
const L = Array.isArray(s) ? s : [s],
|
|
98
|
-
o({
|
|
96
|
+
}, u = (s, h) => {
|
|
97
|
+
const L = Array.isArray(s) ? s : [s], v = L.map((S) => e.getAnnotation(S)).filter(Boolean);
|
|
98
|
+
o({
|
|
99
|
+
selected: v.map((S) => {
|
|
100
|
+
const E = h === void 0 ? P(S, n) === "EDIT" : h;
|
|
101
|
+
return { id: S.id, editable: E };
|
|
102
|
+
})
|
|
103
|
+
}), v.length !== L.length && console.warn("Invalid selection", s);
|
|
99
104
|
}, U = (s) => {
|
|
100
105
|
if (i.selected.length === 0)
|
|
101
106
|
return !1;
|
|
102
107
|
const { selected: h } = i;
|
|
103
|
-
h.filter(({ id:
|
|
108
|
+
h.filter(({ id: v }) => s.includes(v)).length > 0 && o({ selected: h.filter(({ id: v }) => !s.includes(v)) });
|
|
104
109
|
};
|
|
105
110
|
return e.observe(({ changes: s }) => U((s.deleted || []).map((h) => h.id))), {
|
|
106
111
|
clear: p,
|
|
107
|
-
clickSelect:
|
|
112
|
+
clickSelect: y,
|
|
108
113
|
get selected() {
|
|
109
114
|
return i ? [...i.selected] : null;
|
|
110
115
|
},
|
|
@@ -116,73 +121,73 @@ const V = { selected: [] }, Ce = (e, n = "EDIT") => {
|
|
|
116
121
|
setSelected: u,
|
|
117
122
|
subscribe: t
|
|
118
123
|
};
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
124
|
+
}, P = (e, n) => typeof n == "function" ? n(e) || "EDIT" : n || "EDIT";
|
|
125
|
+
var D = [];
|
|
126
|
+
for (var _ = 0; _ < 256; ++_)
|
|
127
|
+
D.push((_ + 256).toString(16).slice(1));
|
|
128
|
+
function J(e, n = 0) {
|
|
129
|
+
return (D[e[n + 0]] + D[e[n + 1]] + D[e[n + 2]] + D[e[n + 3]] + "-" + D[e[n + 4]] + D[e[n + 5]] + "-" + D[e[n + 6]] + D[e[n + 7]] + "-" + D[e[n + 8]] + D[e[n + 9]] + "-" + D[e[n + 10]] + D[e[n + 11]] + D[e[n + 12]] + D[e[n + 13]] + D[e[n + 14]] + D[e[n + 15]]).toLowerCase();
|
|
130
|
+
}
|
|
131
|
+
var $, Q = new Uint8Array(16);
|
|
132
|
+
function X() {
|
|
123
133
|
if (!$ && ($ = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !$))
|
|
124
134
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
125
|
-
return $(
|
|
126
|
-
}
|
|
127
|
-
const D = [];
|
|
128
|
-
for (let e = 0; e < 256; ++e)
|
|
129
|
-
D.push((e + 256).toString(16).slice(1));
|
|
130
|
-
function Q(e, n = 0) {
|
|
131
|
-
return D[e[n + 0]] + D[e[n + 1]] + D[e[n + 2]] + D[e[n + 3]] + "-" + D[e[n + 4]] + D[e[n + 5]] + "-" + D[e[n + 6]] + D[e[n + 7]] + "-" + D[e[n + 8]] + D[e[n + 9]] + "-" + D[e[n + 10]] + D[e[n + 11]] + D[e[n + 12]] + D[e[n + 13]] + D[e[n + 14]] + D[e[n + 15]];
|
|
135
|
+
return $(Q);
|
|
132
136
|
}
|
|
133
|
-
|
|
134
|
-
|
|
137
|
+
var Z = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
138
|
+
const W = {
|
|
139
|
+
randomUUID: Z
|
|
135
140
|
};
|
|
136
|
-
function
|
|
137
|
-
if (
|
|
138
|
-
return
|
|
141
|
+
function K(e, n, t) {
|
|
142
|
+
if (W.randomUUID && !n && !e)
|
|
143
|
+
return W.randomUUID();
|
|
139
144
|
e = e || {};
|
|
140
|
-
|
|
141
|
-
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128,
|
|
145
|
+
var o = e.random || (e.rng || X)();
|
|
146
|
+
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, J(o);
|
|
142
147
|
}
|
|
143
|
-
const
|
|
148
|
+
const Ue = (e) => {
|
|
144
149
|
const { creator: n, updatedBy: t } = e.target, o = e.bodies.reduce((i, p) => [...i, p.creator, p.updatedBy].filter(Boolean), []);
|
|
145
150
|
return [
|
|
146
151
|
n,
|
|
147
152
|
t,
|
|
148
153
|
...o
|
|
149
154
|
].filter((i) => i);
|
|
150
|
-
},
|
|
151
|
-
id:
|
|
155
|
+
}, Se = (e, n, t, o) => ({
|
|
156
|
+
id: K(),
|
|
152
157
|
annotation: e.id,
|
|
153
158
|
created: t || /* @__PURE__ */ new Date(),
|
|
154
159
|
creator: o,
|
|
155
160
|
...n
|
|
156
|
-
}),
|
|
161
|
+
}), ee = (e, n) => {
|
|
157
162
|
const t = new Set(e.bodies.map((o) => o.id));
|
|
158
163
|
return n.bodies.filter((o) => !t.has(o.id));
|
|
159
|
-
},
|
|
164
|
+
}, te = (e, n) => {
|
|
160
165
|
const t = new Set(n.bodies.map((o) => o.id));
|
|
161
166
|
return e.bodies.filter((o) => !t.has(o.id));
|
|
162
|
-
},
|
|
167
|
+
}, ne = (e, n) => n.bodies.map((t) => {
|
|
163
168
|
const o = e.bodies.find((i) => i.id === t.id);
|
|
164
169
|
return { newBody: t, oldBody: o && !B(o, t) ? o : void 0 };
|
|
165
|
-
}).filter(({ oldBody: t }) => t).map(({ oldBody: t, newBody: o }) => ({ oldBody: t, newBody: o })),
|
|
166
|
-
const t =
|
|
170
|
+
}).filter(({ oldBody: t }) => t).map(({ oldBody: t, newBody: o }) => ({ oldBody: t, newBody: o })), oe = (e, n) => !B(e.target, n.target), q = (e, n) => {
|
|
171
|
+
const t = ee(e, n), o = te(e, n), i = ne(e, n);
|
|
167
172
|
return {
|
|
168
173
|
oldValue: e,
|
|
169
174
|
newValue: n,
|
|
170
175
|
bodiesCreated: t.length > 0 ? t : void 0,
|
|
171
176
|
bodiesDeleted: o.length > 0 ? o : void 0,
|
|
172
177
|
bodiesUpdated: i.length > 0 ? i : void 0,
|
|
173
|
-
targetUpdated:
|
|
178
|
+
targetUpdated: oe(e, n) ? { oldTarget: e.target, newTarget: n.target } : void 0
|
|
174
179
|
};
|
|
175
180
|
};
|
|
176
|
-
var
|
|
177
|
-
const
|
|
181
|
+
var se = /* @__PURE__ */ ((e) => (e.BODY_ONLY = "BODY_ONLY", e.TARGET_ONLY = "TARGET_ONLY", e))(se || {}), O = /* @__PURE__ */ ((e) => (e.LOCAL = "LOCAL", e.REMOTE = "REMOTE", e))(O || {});
|
|
182
|
+
const ie = (e, n) => {
|
|
178
183
|
var p, w;
|
|
179
184
|
const { changes: t, origin: o } = n;
|
|
180
185
|
if (!(!e.options.origin || e.options.origin === o))
|
|
181
186
|
return !1;
|
|
182
187
|
if (e.options.ignore) {
|
|
183
|
-
const { ignore: b } = e.options,
|
|
184
|
-
if (!(
|
|
185
|
-
const U = (p = t.updated) == null ? void 0 : p.some((h) =>
|
|
188
|
+
const { ignore: b } = e.options, y = (U) => U && U.length > 0;
|
|
189
|
+
if (!(y(t.created) || y(t.deleted))) {
|
|
190
|
+
const U = (p = t.updated) == null ? void 0 : p.some((h) => y(h.bodiesCreated) || y(h.bodiesDeleted) || y(h.bodiesUpdated)), s = (w = t.updated) == null ? void 0 : w.some((h) => h.targetUpdated);
|
|
186
191
|
if (b === "BODY_ONLY" && U && !s || b === "TARGET_ONLY" && s && !U)
|
|
187
192
|
return !1;
|
|
188
193
|
}
|
|
@@ -196,8 +201,8 @@ const se = (e, n) => {
|
|
|
196
201
|
return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((u) => b.has(u));
|
|
197
202
|
} else
|
|
198
203
|
return !0;
|
|
199
|
-
},
|
|
200
|
-
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)), p = new Set((n.deleted || []).map((s) => s.id)), w = 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)),
|
|
204
|
+
}, de = (e, n) => {
|
|
205
|
+
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)), p = new Set((n.deleted || []).map((s) => s.id)), w = 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)), y = [
|
|
201
206
|
...(e.created || []).filter((s) => !p.has(s.id)).map((s) => w.has(s.id) ? n.updated.find(({ oldValue: h }) => h.id === s.id).newValue : s),
|
|
202
207
|
...n.created || []
|
|
203
208
|
], u = [
|
|
@@ -207,59 +212,59 @@ const se = (e, n) => {
|
|
|
207
212
|
...(e.updated || []).filter(({ newValue: s }) => !p.has(s.id)).map((s) => {
|
|
208
213
|
const { oldValue: h, newValue: L } = s;
|
|
209
214
|
if (w.has(L.id)) {
|
|
210
|
-
const
|
|
211
|
-
return
|
|
215
|
+
const v = n.updated.find((S) => S.oldValue.id === L.id).newValue;
|
|
216
|
+
return q(h, v);
|
|
212
217
|
} else
|
|
213
218
|
return s;
|
|
214
219
|
}),
|
|
215
220
|
...(n.updated || []).filter(({ oldValue: s }) => !b.has(s.id))
|
|
216
221
|
];
|
|
217
|
-
return { created:
|
|
218
|
-
},
|
|
219
|
-
const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (d,
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
}, p = (d,
|
|
222
|
+
return { created: y, deleted: u, updated: U };
|
|
223
|
+
}, re = (e) => e.id !== void 0, Oe = () => {
|
|
224
|
+
const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (d, a = {}) => t.push({ onChange: d, options: a }), i = (d) => {
|
|
225
|
+
const a = t.findIndex((c) => c.onChange == d);
|
|
226
|
+
a > -1 && t.splice(a, 1);
|
|
227
|
+
}, p = (d, a) => {
|
|
223
228
|
const c = {
|
|
224
229
|
origin: d,
|
|
225
230
|
changes: {
|
|
226
|
-
created:
|
|
227
|
-
updated:
|
|
228
|
-
deleted:
|
|
231
|
+
created: a.created || [],
|
|
232
|
+
updated: a.updated || [],
|
|
233
|
+
deleted: a.deleted || []
|
|
229
234
|
},
|
|
230
235
|
state: [...e.values()]
|
|
231
236
|
};
|
|
232
237
|
t.forEach((f) => {
|
|
233
|
-
|
|
238
|
+
ie(f, c) && f.onChange(c);
|
|
234
239
|
});
|
|
235
|
-
}, w = (d,
|
|
240
|
+
}, w = (d, a = O.LOCAL) => {
|
|
236
241
|
if (e.get(d.id))
|
|
237
242
|
throw Error(`Cannot add annotation ${d.id} - exists already`);
|
|
238
|
-
e.set(d.id, d), d.bodies.forEach((f) => n.set(f.id, d.id)), p(
|
|
239
|
-
}, b = (d,
|
|
240
|
-
const c = typeof d == "string" ?
|
|
243
|
+
e.set(d.id, d), d.bodies.forEach((f) => n.set(f.id, d.id)), p(a, { created: [d] });
|
|
244
|
+
}, b = (d, a) => {
|
|
245
|
+
const c = typeof d == "string" ? a : d, f = typeof d == "string" ? d : d.id, C = e.get(f);
|
|
241
246
|
if (C) {
|
|
242
|
-
const T =
|
|
247
|
+
const T = q(C, c);
|
|
243
248
|
return f === c.id ? e.set(f, c) : (e.delete(f), e.set(c.id, c)), C.bodies.forEach((I) => n.delete(I.id)), c.bodies.forEach((I) => n.set(I.id, c.id)), T;
|
|
244
249
|
} else
|
|
245
250
|
console.warn(`Cannot update annotation ${f} - does not exist`);
|
|
246
|
-
},
|
|
247
|
-
const f =
|
|
251
|
+
}, y = (d, a = O.LOCAL, c = O.LOCAL) => {
|
|
252
|
+
const f = re(a) ? c : a, C = b(d, a);
|
|
248
253
|
C && p(f, { updated: [C] });
|
|
249
|
-
}, u = (d,
|
|
254
|
+
}, u = (d, a = O.LOCAL) => {
|
|
250
255
|
const c = d.reduce((f, C) => {
|
|
251
256
|
const T = b(C);
|
|
252
257
|
return T ? [...f, T] : f;
|
|
253
258
|
}, []);
|
|
254
|
-
c.length > 0 && p(
|
|
255
|
-
}, U = (d,
|
|
259
|
+
c.length > 0 && p(a, { updated: c });
|
|
260
|
+
}, U = (d, a = O.LOCAL) => {
|
|
256
261
|
const c = e.get(d.annotation);
|
|
257
262
|
if (c) {
|
|
258
263
|
const f = {
|
|
259
264
|
...c,
|
|
260
265
|
bodies: [...c.bodies, d]
|
|
261
266
|
};
|
|
262
|
-
e.set(c.id, f), n.set(d.id, f.id), p(
|
|
267
|
+
e.set(c.id, f), n.set(d.id, f.id), p(a, { updated: [{
|
|
263
268
|
oldValue: c,
|
|
264
269
|
newValue: f,
|
|
265
270
|
bodiesCreated: [d]
|
|
@@ -267,10 +272,10 @@ const se = (e, n) => {
|
|
|
267
272
|
} else
|
|
268
273
|
console.warn(`Attempt to add body to missing annotation: ${d.annotation}`);
|
|
269
274
|
}, s = () => [...e.values()], h = (d = O.LOCAL) => {
|
|
270
|
-
const
|
|
271
|
-
e.clear(), n.clear(), p(d, { deleted:
|
|
272
|
-
}, L = (d,
|
|
273
|
-
if (
|
|
275
|
+
const a = [...e.values()];
|
|
276
|
+
e.clear(), n.clear(), p(d, { deleted: a });
|
|
277
|
+
}, L = (d, a = !0, c = O.LOCAL) => {
|
|
278
|
+
if (a) {
|
|
274
279
|
const f = [...e.values()];
|
|
275
280
|
e.clear(), n.clear(), d.forEach((C) => {
|
|
276
281
|
e.set(C.id, C), C.bodies.forEach((T) => n.set(T.id, C.id));
|
|
@@ -286,32 +291,32 @@ const se = (e, n) => {
|
|
|
286
291
|
e.set(C.id, C), C.bodies.forEach((T) => n.set(T.id, C.id));
|
|
287
292
|
}), p(c, { created: d });
|
|
288
293
|
}
|
|
289
|
-
},
|
|
290
|
-
const
|
|
294
|
+
}, v = (d) => {
|
|
295
|
+
const a = typeof d == "string" ? d : d.id, c = e.get(a);
|
|
291
296
|
if (c)
|
|
292
|
-
return e.delete(
|
|
293
|
-
console.warn(`Attempt to delete missing annotation: ${
|
|
294
|
-
}, S = (d,
|
|
295
|
-
const c =
|
|
296
|
-
c && p(
|
|
297
|
-
},
|
|
297
|
+
return e.delete(a), c.bodies.forEach((f) => n.delete(f.id)), c;
|
|
298
|
+
console.warn(`Attempt to delete missing annotation: ${a}`);
|
|
299
|
+
}, S = (d, a = O.LOCAL) => {
|
|
300
|
+
const c = v(d);
|
|
301
|
+
c && p(a, { deleted: [c] });
|
|
302
|
+
}, E = (d, a = O.LOCAL) => {
|
|
298
303
|
const c = d.reduce((f, C) => {
|
|
299
|
-
const T =
|
|
304
|
+
const T = v(C);
|
|
300
305
|
return T ? [...f, T] : f;
|
|
301
306
|
}, []);
|
|
302
|
-
c.length > 0 && p(
|
|
307
|
+
c.length > 0 && p(a, { deleted: c });
|
|
303
308
|
}, l = (d) => {
|
|
304
|
-
const
|
|
305
|
-
if (
|
|
306
|
-
const c =
|
|
309
|
+
const a = e.get(d.annotation);
|
|
310
|
+
if (a) {
|
|
311
|
+
const c = a.bodies.find((f) => f.id === d.id);
|
|
307
312
|
if (c) {
|
|
308
313
|
n.delete(c.id);
|
|
309
314
|
const f = {
|
|
310
|
-
...
|
|
311
|
-
bodies:
|
|
315
|
+
...a,
|
|
316
|
+
bodies: a.bodies.filter((T) => T.id !== d.id)
|
|
312
317
|
};
|
|
313
|
-
return e.set(
|
|
314
|
-
oldValue:
|
|
318
|
+
return e.set(a.id, f), {
|
|
319
|
+
oldValue: a,
|
|
315
320
|
newValue: f,
|
|
316
321
|
bodiesDeleted: [c]
|
|
317
322
|
};
|
|
@@ -319,61 +324,61 @@ const se = (e, n) => {
|
|
|
319
324
|
console.warn(`Attempt to delete missing body ${d.id} from annotation ${d.annotation}`);
|
|
320
325
|
} else
|
|
321
326
|
console.warn(`Attempt to delete body from missing annotation ${d.annotation}`);
|
|
322
|
-
}, g = (d,
|
|
327
|
+
}, g = (d, a = O.LOCAL) => {
|
|
323
328
|
const c = l(d);
|
|
324
|
-
c && p(
|
|
325
|
-
},
|
|
329
|
+
c && p(a, { updated: [c] });
|
|
330
|
+
}, r = (d, a = O.LOCAL) => {
|
|
326
331
|
const c = d.map((f) => l(f)).filter(Boolean);
|
|
327
|
-
c.length > 0 && p(
|
|
332
|
+
c.length > 0 && p(a, { updated: c });
|
|
328
333
|
}, A = (d) => {
|
|
329
|
-
const
|
|
330
|
-
return
|
|
334
|
+
const a = e.get(d);
|
|
335
|
+
return a ? { ...a } : void 0;
|
|
331
336
|
}, m = (d) => {
|
|
332
|
-
const
|
|
333
|
-
if (
|
|
334
|
-
const f = A(
|
|
337
|
+
const a = n.get(d);
|
|
338
|
+
if (a) {
|
|
339
|
+
const f = A(a).bodies.find((C) => C.id === d);
|
|
335
340
|
if (f)
|
|
336
341
|
return f;
|
|
337
342
|
console.error(`Store integrity error: body ${d} in index, but not in annotation`);
|
|
338
343
|
} else
|
|
339
344
|
console.warn(`Attempt to retrieve missing body: ${d}`);
|
|
340
|
-
}, R = (d,
|
|
341
|
-
if (d.annotation !==
|
|
345
|
+
}, R = (d, a) => {
|
|
346
|
+
if (d.annotation !== a.annotation)
|
|
342
347
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
343
348
|
const c = e.get(d.annotation);
|
|
344
349
|
if (c) {
|
|
345
350
|
const f = c.bodies.find((T) => T.id === d.id), C = {
|
|
346
351
|
...c,
|
|
347
|
-
bodies: c.bodies.map((T) => T.id === f.id ?
|
|
352
|
+
bodies: c.bodies.map((T) => T.id === f.id ? a : T)
|
|
348
353
|
};
|
|
349
|
-
return e.set(c.id, C), f.id !==
|
|
354
|
+
return e.set(c.id, C), f.id !== a.id && (n.delete(f.id), n.set(a.id, C.id)), {
|
|
350
355
|
oldValue: c,
|
|
351
356
|
newValue: C,
|
|
352
|
-
bodiesUpdated: [{ oldBody: f, newBody:
|
|
357
|
+
bodiesUpdated: [{ oldBody: f, newBody: a }]
|
|
353
358
|
};
|
|
354
359
|
} else
|
|
355
360
|
console.warn(`Attempt to add body to missing annotation ${d.annotation}`);
|
|
356
|
-
}, N = (d,
|
|
357
|
-
const f = R(d,
|
|
361
|
+
}, N = (d, a, c = O.LOCAL) => {
|
|
362
|
+
const f = R(d, a);
|
|
358
363
|
f && p(c, { updated: [f] });
|
|
359
|
-
}, x = (d,
|
|
364
|
+
}, x = (d, a = O.LOCAL) => {
|
|
360
365
|
const c = d.map((f) => R({ id: f.id, annotation: f.annotation }, f)).filter(Boolean);
|
|
361
|
-
p(
|
|
362
|
-
},
|
|
363
|
-
const
|
|
364
|
-
if (
|
|
366
|
+
p(a, { updated: c });
|
|
367
|
+
}, j = (d) => {
|
|
368
|
+
const a = e.get(d.annotation);
|
|
369
|
+
if (a) {
|
|
365
370
|
const c = {
|
|
366
|
-
...
|
|
371
|
+
...a,
|
|
367
372
|
target: {
|
|
368
|
-
...
|
|
373
|
+
...a.target,
|
|
369
374
|
...d
|
|
370
375
|
}
|
|
371
376
|
};
|
|
372
|
-
return e.set(
|
|
373
|
-
oldValue:
|
|
377
|
+
return e.set(a.id, c), {
|
|
378
|
+
oldValue: a,
|
|
374
379
|
newValue: c,
|
|
375
380
|
targetUpdated: {
|
|
376
|
-
oldTarget:
|
|
381
|
+
oldTarget: a.target,
|
|
377
382
|
newTarget: d
|
|
378
383
|
}
|
|
379
384
|
};
|
|
@@ -385,13 +390,13 @@ const se = (e, n) => {
|
|
|
385
390
|
addBody: U,
|
|
386
391
|
all: s,
|
|
387
392
|
bulkAddAnnotation: L,
|
|
388
|
-
bulkDeleteAnnotation:
|
|
389
|
-
bulkDeleteBodies:
|
|
393
|
+
bulkDeleteAnnotation: E,
|
|
394
|
+
bulkDeleteBodies: r,
|
|
390
395
|
bulkUpdateAnnotation: u,
|
|
391
396
|
bulkUpdateBodies: x,
|
|
392
|
-
bulkUpdateTargets: (d,
|
|
393
|
-
const c = d.map((f) =>
|
|
394
|
-
c.length > 0 && p(
|
|
397
|
+
bulkUpdateTargets: (d, a = O.LOCAL) => {
|
|
398
|
+
const c = d.map((f) => j(f)).filter(Boolean);
|
|
399
|
+
c.length > 0 && p(a, { updated: c });
|
|
395
400
|
},
|
|
396
401
|
clear: h,
|
|
397
402
|
deleteAnnotation: S,
|
|
@@ -400,21 +405,21 @@ const se = (e, n) => {
|
|
|
400
405
|
getBody: m,
|
|
401
406
|
observe: o,
|
|
402
407
|
unobserve: i,
|
|
403
|
-
updateAnnotation:
|
|
408
|
+
updateAnnotation: y,
|
|
404
409
|
updateBody: N,
|
|
405
|
-
updateTarget: (d,
|
|
406
|
-
const c =
|
|
407
|
-
c && p(
|
|
410
|
+
updateTarget: (d, a = O.LOCAL) => {
|
|
411
|
+
const c = j(d);
|
|
412
|
+
c && p(a, { updated: [c] });
|
|
408
413
|
}
|
|
409
414
|
};
|
|
410
|
-
},
|
|
415
|
+
}, Te = (e) => ({
|
|
411
416
|
...e,
|
|
412
417
|
subscribe: (t) => {
|
|
413
418
|
const o = (i) => t(i.state);
|
|
414
419
|
return e.observe(o), t(e.all()), () => e.unobserve(o);
|
|
415
420
|
}
|
|
416
421
|
});
|
|
417
|
-
let
|
|
422
|
+
let G = () => ({
|
|
418
423
|
emit(e, ...n) {
|
|
419
424
|
for (let t = 0, o = this.events[e] || [], i = o.length; t < i; t++)
|
|
420
425
|
o[t](...n);
|
|
@@ -428,76 +433,76 @@ let W = () => ({
|
|
|
428
433
|
};
|
|
429
434
|
}
|
|
430
435
|
});
|
|
431
|
-
const ae = 250,
|
|
432
|
-
const n =
|
|
436
|
+
const ae = 250, De = (e) => {
|
|
437
|
+
const n = G(), t = [];
|
|
433
438
|
let o = -1, i = !1, p = 0;
|
|
434
|
-
const w = (
|
|
439
|
+
const w = (r) => {
|
|
435
440
|
if (!i) {
|
|
436
|
-
const { changes: A } =
|
|
441
|
+
const { changes: A } = r, m = performance.now();
|
|
437
442
|
if (m - p > ae)
|
|
438
443
|
t.splice(o + 1), t.push(A), o = t.length - 1;
|
|
439
444
|
else {
|
|
440
445
|
const R = t.length - 1;
|
|
441
|
-
t[R] =
|
|
446
|
+
t[R] = de(t[R], A);
|
|
442
447
|
}
|
|
443
448
|
p = m;
|
|
444
449
|
}
|
|
445
450
|
i = !1;
|
|
446
451
|
};
|
|
447
452
|
e.observe(w, { origin: O.LOCAL });
|
|
448
|
-
const b = (
|
|
453
|
+
const b = (r) => r && r.length > 0 && e.bulkDeleteAnnotation(r), y = (r) => r && r.length > 0 && e.bulkAddAnnotation(r, !1), u = (r) => r && r.length > 0 && e.bulkUpdateAnnotation(r.map(({ oldValue: A }) => A)), U = (r) => r && r.length > 0 && e.bulkUpdateAnnotation(r.map(({ newValue: A }) => A)), s = (r) => r && r.length > 0 && e.bulkAddAnnotation(r, !1), h = (r) => r && r.length > 0 && e.bulkDeleteAnnotation(r);
|
|
449
454
|
return {
|
|
450
455
|
canRedo: () => t.length - 1 > o,
|
|
451
456
|
canUndo: () => o > -1,
|
|
452
457
|
destroy: () => e.unobserve(w),
|
|
453
|
-
on: (
|
|
458
|
+
on: (r, A) => n.on(r, A),
|
|
454
459
|
redo: () => {
|
|
455
460
|
if (t.length - 1 > o) {
|
|
456
461
|
i = !0;
|
|
457
|
-
const { created:
|
|
458
|
-
|
|
462
|
+
const { created: r, updated: A, deleted: m } = t[o + 1];
|
|
463
|
+
y(r), U(A), h(m), n.emit("redo", t[o + 1]), o += 1;
|
|
459
464
|
}
|
|
460
465
|
},
|
|
461
466
|
undo: () => {
|
|
462
467
|
if (o > -1) {
|
|
463
468
|
i = !0;
|
|
464
|
-
const { created:
|
|
465
|
-
b(
|
|
469
|
+
const { created: r, updated: A, deleted: m } = t[o];
|
|
470
|
+
b(r), u(A), s(m), n.emit("undo", t[o]), o -= 1;
|
|
466
471
|
}
|
|
467
472
|
}
|
|
468
473
|
};
|
|
469
|
-
},
|
|
470
|
-
const { subscribe: e, set: n } =
|
|
474
|
+
}, Re = () => {
|
|
475
|
+
const { subscribe: e, set: n } = Y([]);
|
|
471
476
|
return {
|
|
472
477
|
subscribe: e,
|
|
473
478
|
set: n
|
|
474
479
|
};
|
|
475
|
-
},
|
|
476
|
-
const { store: i, selection: p, hover: w, viewport: b } = e,
|
|
480
|
+
}, Be = (e, n, t, o) => {
|
|
481
|
+
const { store: i, selection: p, hover: w, viewport: b } = e, y = /* @__PURE__ */ new Map();
|
|
477
482
|
let u = [], U, s;
|
|
478
483
|
const h = (l, g) => {
|
|
479
|
-
|
|
484
|
+
y.has(l) ? y.get(l).push(g) : y.set(l, [g]);
|
|
480
485
|
}, L = (l, g) => {
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
},
|
|
484
|
-
|
|
485
|
-
|
|
486
|
+
const r = y.get(l);
|
|
487
|
+
r && r.indexOf(g) > 0 && r.splice(r.indexOf(g), 1);
|
|
488
|
+
}, v = (l, g, r) => {
|
|
489
|
+
y.has(l) && setTimeout(() => {
|
|
490
|
+
y.get(l).forEach((A) => {
|
|
486
491
|
if (t) {
|
|
487
|
-
const m = Array.isArray(g) ? g.map((N) => t.serialize(N)) : t.serialize(g), R =
|
|
492
|
+
const m = Array.isArray(g) ? g.map((N) => t.serialize(N)) : t.serialize(g), R = r ? r instanceof PointerEvent ? r : t.serialize(r) : void 0;
|
|
488
493
|
A(m, R);
|
|
489
494
|
} else
|
|
490
|
-
A(g,
|
|
495
|
+
A(g, r);
|
|
491
496
|
});
|
|
492
497
|
}, 1);
|
|
493
498
|
}, S = () => {
|
|
494
|
-
const { selected: l } = p, g = (l || []).map(({ id:
|
|
495
|
-
g.forEach((
|
|
496
|
-
const A = u.find((m) => m.id ===
|
|
497
|
-
(!A || !B(A,
|
|
498
|
-
}), u = u.map((
|
|
499
|
-
const A = g.find(({ id: m }) => m ===
|
|
500
|
-
return A ||
|
|
499
|
+
const { selected: l } = p, g = (l || []).map(({ id: r }) => i.getAnnotation(r));
|
|
500
|
+
g.forEach((r) => {
|
|
501
|
+
const A = u.find((m) => m.id === r.id);
|
|
502
|
+
(!A || !B(A, r)) && v("updateAnnotation", r, A);
|
|
503
|
+
}), u = u.map((r) => {
|
|
504
|
+
const A = g.find(({ id: m }) => m === r.id);
|
|
505
|
+
return A || r;
|
|
501
506
|
});
|
|
502
507
|
};
|
|
503
508
|
p.subscribe(({ selected: l }) => {
|
|
@@ -506,51 +511,51 @@ const ae = 250, Te = (e) => {
|
|
|
506
511
|
u = l.map(({ id: g }) => i.getAnnotation(g));
|
|
507
512
|
else if (u.length > 0 && l.length === 0)
|
|
508
513
|
u.forEach((g) => {
|
|
509
|
-
const
|
|
510
|
-
|
|
514
|
+
const r = i.getAnnotation(g.id);
|
|
515
|
+
r && !B(r, g) && v("updateAnnotation", r, g);
|
|
511
516
|
}), u = [];
|
|
512
517
|
else {
|
|
513
|
-
const g = new Set(u.map((m) => m.id)),
|
|
514
|
-
u.filter((m) => !
|
|
518
|
+
const g = new Set(u.map((m) => m.id)), r = new Set(l.map(({ id: m }) => m));
|
|
519
|
+
u.filter((m) => !r.has(m.id)).forEach((m) => {
|
|
515
520
|
const R = i.getAnnotation(m.id);
|
|
516
|
-
R && !B(R, m) &&
|
|
521
|
+
R && !B(R, m) && v("updateAnnotation", R, m);
|
|
517
522
|
}), u = [
|
|
518
523
|
// Remove annotations that were deselected
|
|
519
|
-
...u.filter((m) =>
|
|
524
|
+
...u.filter((m) => r.has(m.id)),
|
|
520
525
|
// Add editable annotations that were selected
|
|
521
526
|
...l.filter(({ id: m }) => !g.has(m)).map(({ id: m }) => i.getAnnotation(m))
|
|
522
527
|
];
|
|
523
528
|
}
|
|
524
|
-
|
|
529
|
+
v("selectionChanged", u);
|
|
525
530
|
}
|
|
526
531
|
}), w.subscribe((l) => {
|
|
527
|
-
!U && l ?
|
|
528
|
-
}), b == null || b.subscribe((l) =>
|
|
532
|
+
!U && l ? v("mouseEnterAnnotation", i.getAnnotation(l)) : U && !l ? v("mouseLeaveAnnotation", i.getAnnotation(U)) : U && l && (v("mouseLeaveAnnotation", i.getAnnotation(U)), v("mouseEnterAnnotation", i.getAnnotation(l))), U = l;
|
|
533
|
+
}), b == null || b.subscribe((l) => v("viewportIntersect", l.map((g) => i.getAnnotation(g)))), i.observe((l) => {
|
|
529
534
|
o && (s && clearTimeout(s), s = setTimeout(S, 1e3));
|
|
530
|
-
const { created: g, deleted:
|
|
531
|
-
(g || []).forEach((m) =>
|
|
535
|
+
const { created: g, deleted: r } = l.changes;
|
|
536
|
+
(g || []).forEach((m) => v("createAnnotation", m)), (r || []).forEach((m) => v("deleteAnnotation", m)), (l.changes.updated || []).filter((m) => [
|
|
532
537
|
...m.bodiesCreated || [],
|
|
533
538
|
...m.bodiesDeleted || [],
|
|
534
539
|
...m.bodiesUpdated || []
|
|
535
540
|
].length > 0).forEach(({ oldValue: m, newValue: R }) => {
|
|
536
541
|
const N = u.find((x) => x.id === m.id) || m;
|
|
537
|
-
u = u.map((x) => x.id === m.id ? R : x),
|
|
542
|
+
u = u.map((x) => x.id === m.id ? R : x), v("updateAnnotation", R, N);
|
|
538
543
|
});
|
|
539
544
|
}, { origin: O.LOCAL }), i.observe((l) => {
|
|
540
545
|
if (u) {
|
|
541
|
-
const g = new Set(u.map((A) => A.id)),
|
|
542
|
-
|
|
543
|
-
const m =
|
|
546
|
+
const g = new Set(u.map((A) => A.id)), r = (l.changes.updated || []).filter(({ newValue: A }) => g.has(A.id)).map(({ newValue: A }) => A);
|
|
547
|
+
r.length > 0 && (u = u.map((A) => {
|
|
548
|
+
const m = r.find((R) => R.id === A.id);
|
|
544
549
|
return m || A;
|
|
545
550
|
}));
|
|
546
551
|
}
|
|
547
552
|
}, { origin: O.REMOTE });
|
|
548
|
-
const
|
|
549
|
-
const { updated:
|
|
550
|
-
l ? (
|
|
553
|
+
const E = (l) => (g) => {
|
|
554
|
+
const { updated: r } = g;
|
|
555
|
+
l ? (r || []).forEach((A) => v("updateAnnotation", A.oldValue, A.newValue)) : (r || []).forEach((A) => v("updateAnnotation", A.newValue, A.oldValue));
|
|
551
556
|
};
|
|
552
|
-
return n.on("undo",
|
|
553
|
-
},
|
|
557
|
+
return n.on("undo", E(!0)), n.on("redo", E(!1)), { on: h, off: L, emit: v };
|
|
558
|
+
}, xe = (e) => (n) => n.map((t) => e.serialize(t)), ce = (e) => (n) => n.reduce((t, o) => {
|
|
554
559
|
const { parsed: i, error: p } = e.parse(o);
|
|
555
560
|
return p ? {
|
|
556
561
|
parsed: t.parsed,
|
|
@@ -561,45 +566,45 @@ const ae = 250, Te = (e) => {
|
|
|
561
566
|
} : {
|
|
562
567
|
...t
|
|
563
568
|
};
|
|
564
|
-
}, { parsed: [], failed: [] }),
|
|
565
|
-
const { store: o, selection: i } = e, p = (
|
|
569
|
+
}, { parsed: [], failed: [] }), Ie = (e, n, t) => {
|
|
570
|
+
const { store: o, selection: i } = e, p = (E) => {
|
|
566
571
|
if (t) {
|
|
567
|
-
const { parsed: l, error: g } = t.parse(
|
|
572
|
+
const { parsed: l, error: g } = t.parse(E);
|
|
568
573
|
l ? o.addAnnotation(l, O.REMOTE) : console.error(g);
|
|
569
574
|
} else
|
|
570
|
-
o.addAnnotation(
|
|
571
|
-
}, w = () => i.clear(), b = () => o.clear(),
|
|
572
|
-
const l = o.getAnnotation(
|
|
575
|
+
o.addAnnotation(E, O.REMOTE);
|
|
576
|
+
}, w = () => i.clear(), b = () => o.clear(), y = (E) => {
|
|
577
|
+
const l = o.getAnnotation(E);
|
|
573
578
|
return t && l ? t.serialize(l) : l;
|
|
574
579
|
}, u = () => t ? o.all().map(t.serialize) : o.all(), U = () => {
|
|
575
580
|
var g;
|
|
576
|
-
const l = (((g = i.selected) == null ? void 0 : g.map((
|
|
581
|
+
const l = (((g = i.selected) == null ? void 0 : g.map((r) => r.id)) || []).map((r) => o.getAnnotation(r)).filter(Boolean);
|
|
577
582
|
return t ? l.map(t.serialize) : l;
|
|
578
|
-
}, s = (
|
|
579
|
-
if (typeof
|
|
580
|
-
const l = o.getAnnotation(
|
|
581
|
-
if (o.deleteAnnotation(
|
|
583
|
+
}, s = (E, l = !0) => fetch(E).then((g) => g.json()).then((g) => (L(g, l), g)), h = (E) => {
|
|
584
|
+
if (typeof E == "string") {
|
|
585
|
+
const l = o.getAnnotation(E);
|
|
586
|
+
if (o.deleteAnnotation(E), l)
|
|
582
587
|
return t ? t.serialize(l) : l;
|
|
583
588
|
} else {
|
|
584
|
-
const l = t ? t.parse(
|
|
589
|
+
const l = t ? t.parse(E).parsed : E;
|
|
585
590
|
if (l)
|
|
586
|
-
return o.deleteAnnotation(l),
|
|
591
|
+
return o.deleteAnnotation(l), E;
|
|
587
592
|
}
|
|
588
|
-
}, L = (
|
|
593
|
+
}, L = (E, l = !0) => {
|
|
589
594
|
if (t) {
|
|
590
|
-
const { parsed: g, failed:
|
|
591
|
-
|
|
595
|
+
const { parsed: g, failed: r } = ce(t)(E);
|
|
596
|
+
r.length > 0 && console.warn(`Discarded ${r.length} invalid annotations`, r), o.bulkAddAnnotation(g, l, O.REMOTE);
|
|
592
597
|
} else
|
|
593
|
-
o.bulkAddAnnotation(
|
|
594
|
-
},
|
|
595
|
-
|
|
596
|
-
}, S = (
|
|
598
|
+
o.bulkAddAnnotation(E, l, O.REMOTE);
|
|
599
|
+
}, v = (E, l) => {
|
|
600
|
+
E ? i.setSelected(E, l) : i.clear();
|
|
601
|
+
}, S = (E) => {
|
|
597
602
|
if (t) {
|
|
598
|
-
const l = t.parse(
|
|
603
|
+
const l = t.parse(E).parsed, g = t.serialize(o.getAnnotation(l.id));
|
|
599
604
|
return o.updateAnnotation(l), g;
|
|
600
605
|
} else {
|
|
601
|
-
const l = o.getAnnotation(
|
|
602
|
-
return o.updateAnnotation(
|
|
606
|
+
const l = o.getAnnotation(E.id);
|
|
607
|
+
return o.updateAnnotation(E), l;
|
|
603
608
|
}
|
|
604
609
|
};
|
|
605
610
|
return {
|
|
@@ -608,36 +613,36 @@ const ae = 250, Te = (e) => {
|
|
|
608
613
|
canRedo: n.canRedo,
|
|
609
614
|
canUndo: n.canUndo,
|
|
610
615
|
clearAnnotations: b,
|
|
611
|
-
getAnnotationById:
|
|
616
|
+
getAnnotationById: y,
|
|
612
617
|
getAnnotations: u,
|
|
613
618
|
getSelected: U,
|
|
614
619
|
loadAnnotations: s,
|
|
615
620
|
redo: n.redo,
|
|
616
621
|
removeAnnotation: h,
|
|
617
622
|
setAnnotations: L,
|
|
618
|
-
setSelected:
|
|
623
|
+
setSelected: v,
|
|
619
624
|
undo: n.undo,
|
|
620
625
|
updateAnnotation: S
|
|
621
626
|
};
|
|
622
|
-
},
|
|
623
|
-
let
|
|
627
|
+
}, le = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
628
|
+
let ue = (e) => crypto.getRandomValues(new Uint8Array(e)), fe = (e, n, t) => {
|
|
624
629
|
let o = (2 << Math.log(e.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * n / e.length);
|
|
625
630
|
return (p = n) => {
|
|
626
631
|
let w = "";
|
|
627
632
|
for (; ; ) {
|
|
628
|
-
let b = t(i),
|
|
629
|
-
for (;
|
|
630
|
-
if (w += e[b[
|
|
633
|
+
let b = t(i), y = i;
|
|
634
|
+
for (; y--; )
|
|
635
|
+
if (w += e[b[y] & o] || "", w.length === p)
|
|
631
636
|
return w;
|
|
632
637
|
}
|
|
633
638
|
};
|
|
634
|
-
},
|
|
639
|
+
}, pe = (e, n = 21) => fe(e, n, ue), he = (e = 21) => {
|
|
635
640
|
let n = "", t = crypto.getRandomValues(new Uint8Array(e));
|
|
636
641
|
for (; e--; )
|
|
637
|
-
n +=
|
|
642
|
+
n += le[t[e] & 63];
|
|
638
643
|
return n;
|
|
639
644
|
};
|
|
640
|
-
const
|
|
645
|
+
const ke = () => ({ isGuest: !0, id: pe("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), ge = (e) => {
|
|
641
646
|
const n = JSON.stringify(e);
|
|
642
647
|
let t = 0;
|
|
643
648
|
for (let o = 0, i = n.length; o < i; o++) {
|
|
@@ -645,20 +650,20 @@ const Ie = () => ({ isGuest: !0, id: fe("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
645
650
|
t = (t << 5) - t + p, t |= 0;
|
|
646
651
|
}
|
|
647
652
|
return `${t}`;
|
|
648
|
-
},
|
|
649
|
-
const { id: o, type: i, purpose: p, value: w, created: b, modified:
|
|
653
|
+
}, me = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, Ne = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {
|
|
654
|
+
const { id: o, type: i, purpose: p, value: w, created: b, modified: y, creator: u, ...U } = t;
|
|
650
655
|
return {
|
|
651
|
-
id: o || `temp-${
|
|
656
|
+
id: o || `temp-${ge(t)}`,
|
|
652
657
|
annotation: n,
|
|
653
658
|
type: i,
|
|
654
659
|
purpose: p,
|
|
655
660
|
value: w,
|
|
656
|
-
creator:
|
|
661
|
+
creator: me(u),
|
|
657
662
|
created: b ? new Date(b) : void 0,
|
|
658
|
-
updated:
|
|
663
|
+
updated: y ? new Date(y) : void 0,
|
|
659
664
|
...U
|
|
660
665
|
};
|
|
661
|
-
}),
|
|
666
|
+
}), $e = (e) => e.map((n) => {
|
|
662
667
|
var b;
|
|
663
668
|
const { annotation: t, created: o, updated: i, ...p } = n, w = {
|
|
664
669
|
...p,
|
|
@@ -666,7 +671,7 @@ const Ie = () => ({ isGuest: !0, id: fe("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
666
671
|
modified: i == null ? void 0 : i.toISOString()
|
|
667
672
|
};
|
|
668
673
|
return (b = w.id) != null && b.startsWith("temp-") && delete w.id, w;
|
|
669
|
-
}),
|
|
674
|
+
}), Ae = [
|
|
670
675
|
"#ff7c00",
|
|
671
676
|
// orange
|
|
672
677
|
"#1ac938",
|
|
@@ -685,14 +690,14 @@ const Ie = () => ({ isGuest: !0, id: fe("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
685
690
|
// cyan
|
|
686
691
|
"#023eff"
|
|
687
692
|
// blue
|
|
688
|
-
],
|
|
689
|
-
const e = [...
|
|
693
|
+
], be = () => {
|
|
694
|
+
const e = [...Ae];
|
|
690
695
|
return { assignRandomColor: () => {
|
|
691
696
|
const o = Math.floor(Math.random() * e.length), i = e[o];
|
|
692
697
|
return e.splice(o, 1), i;
|
|
693
698
|
}, releaseColor: (o) => e.push(o) };
|
|
694
|
-
},
|
|
695
|
-
const e =
|
|
699
|
+
}, ve = () => {
|
|
700
|
+
const e = be();
|
|
696
701
|
return { addUser: (o, i) => {
|
|
697
702
|
const p = e.assignRandomColor();
|
|
698
703
|
return {
|
|
@@ -701,8 +706,8 @@ const Ie = () => ({ isGuest: !0, id: fe("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
701
706
|
color: p
|
|
702
707
|
};
|
|
703
708
|
}, removeUser: (o) => e.releaseColor(o.appearance.color) };
|
|
704
|
-
}, Ee = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)),
|
|
705
|
-
const n =
|
|
709
|
+
}, Ee = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)), ze = he(), Ve = (e = ve()) => {
|
|
710
|
+
const n = G(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = (s, h) => {
|
|
706
711
|
if (t.has(s)) {
|
|
707
712
|
console.warn("Attempt to add user that is already present", s, h);
|
|
708
713
|
return;
|
|
@@ -721,20 +726,20 @@ const Ie = () => ({ isGuest: !0, id: fe("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
721
726
|
}
|
|
722
727
|
e.removeUser(h), t.delete(s);
|
|
723
728
|
}, w = (s) => {
|
|
724
|
-
const h = new Set(s.map((S) => S.presenceKey)), L = s.filter(({ presenceKey: S }) => !t.has(S)),
|
|
725
|
-
L.forEach(({ presenceKey: S, user:
|
|
726
|
-
const { presenceKey:
|
|
727
|
-
o.has(
|
|
728
|
-
}), (L.length > 0 ||
|
|
729
|
+
const h = new Set(s.map((S) => S.presenceKey)), L = s.filter(({ presenceKey: S }) => !t.has(S)), v = Array.from(t.values()).filter((S) => !h.has(S.presenceKey));
|
|
730
|
+
L.forEach(({ presenceKey: S, user: E }) => i(S, E)), v.forEach((S) => {
|
|
731
|
+
const { presenceKey: E } = S;
|
|
732
|
+
o.has(E) && n.emit("selectionChange", S, null), p(E);
|
|
733
|
+
}), (L.length > 0 || v.length > 0) && n.emit("presence", u());
|
|
729
734
|
}, b = (s, h) => {
|
|
730
735
|
const L = t.get(s);
|
|
731
736
|
if (!L) {
|
|
732
737
|
console.warn("Activity notification from user that is not present");
|
|
733
738
|
return;
|
|
734
739
|
}
|
|
735
|
-
const
|
|
736
|
-
(!
|
|
737
|
-
},
|
|
740
|
+
const v = o.get(s);
|
|
741
|
+
(!v || !Ee(v, h)) && (o.set(s, h), n.emit("selectionChange", L, h));
|
|
742
|
+
}, y = (s, h) => {
|
|
738
743
|
const L = t.get(s);
|
|
739
744
|
if (!L) {
|
|
740
745
|
console.warn("Selection change for user that is not present", s);
|
|
@@ -747,36 +752,36 @@ const Ie = () => ({ isGuest: !0, id: fe("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
747
752
|
notifyActivity: b,
|
|
748
753
|
on: (s, h) => n.on(s, h),
|
|
749
754
|
syncUsers: w,
|
|
750
|
-
updateSelection:
|
|
755
|
+
updateSelection: y
|
|
751
756
|
};
|
|
752
757
|
};
|
|
753
758
|
export {
|
|
754
|
-
|
|
759
|
+
se as Ignore,
|
|
755
760
|
O as Origin,
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
761
|
+
ze as PRESENCE_KEY,
|
|
762
|
+
F as PointerSelectAction,
|
|
763
|
+
ke as createAnonymousGuest,
|
|
764
|
+
Ie as createBaseAnnotator,
|
|
765
|
+
Se as createBody,
|
|
766
|
+
ve as createDefaultAppearenceProvider,
|
|
767
|
+
Ce as createHoverState,
|
|
768
|
+
Be as createLifecyleObserver,
|
|
769
|
+
Ve as createPresenceState,
|
|
770
|
+
Le as createSelectionState,
|
|
771
|
+
Oe as createStore,
|
|
772
|
+
De as createUndoStack,
|
|
773
|
+
Re as createViewportState,
|
|
774
|
+
be as defaultColorProvider,
|
|
775
|
+
q as diffAnnotations,
|
|
776
|
+
Ue as getContributors,
|
|
777
|
+
de as mergeChanges,
|
|
778
|
+
P as onPointerSelect,
|
|
779
|
+
ce as parseAll,
|
|
780
|
+
Ne as parseW3CBodies,
|
|
781
|
+
me as parseW3CUser,
|
|
782
|
+
xe as serializeAll,
|
|
783
|
+
$e as serializeW3CBodies,
|
|
784
|
+
ie as shouldNotify,
|
|
785
|
+
Te as toSvelteStore
|
|
781
786
|
};
|
|
782
787
|
//# sourceMappingURL=annotorious-core.es.js.map
|