New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@annotorious/core

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@annotorious/core - npm Package Compare versions

Comparing version 3.0.6 to 3.0.7

477

dist/annotorious-core.es.js

@@ -24,3 +24,3 @@ var q = Object.prototype.hasOwnProperty;

}
function X(e, n) {
function Z(e, n) {
return e != e ? n == n : e !== n || e && typeof e == "object" || typeof e == "function";

@@ -32,10 +32,10 @@ }

const o = /* @__PURE__ */ new Set();
function r(v) {
if (X(e, v) && (e = v, t)) {
function d(v) {
if (Z(e, v) && (e = v, t)) {
const w = !x.length;
for (const p of o)
p[1](), x.push(p, e);
for (const g of o)
g[1](), x.push(g, e);
if (w) {
for (let p = 0; p < x.length; p += 2)
x[p][0](x[p + 1]);
for (let g = 0; g < x.length; g += 2)
x[g][0](x[g + 1]);
x.length = 0;

@@ -45,12 +45,12 @@ }

}
function g(v) {
r(v(e));
function p(v) {
d(v(e));
}
function m(v, w = _) {
const p = [v, w];
return o.add(p), o.size === 1 && (t = n(r, g) || _), v(e), () => {
o.delete(p), o.size === 0 && t && (t(), t = null);
const g = [v, w];
return o.add(g), o.size === 1 && (t = n(d, p) || _), v(e), () => {
o.delete(g), o.size === 0 && t && (t(), t = null);
};
}
return { set: r, update: g, subscribe: m };
return { set: d, update: p, subscribe: m };
}

@@ -60,6 +60,6 @@ const Ue = (e) => {

let o;
return n((r) => o = r), e.observe(({ changes: r }) => {
return n((d) => o = d), e.observe(({ changes: d }) => {
if (o) {
(r.deleted || []).some((v) => v.id === o) && t(void 0);
const m = (r.updated || []).find(({ oldValue: v }) => v.id === o);
(d.deleted || []).some((v) => v.id === o) && t(void 0);
const m = (d.updated || []).find(({ oldValue: v }) => v.id === o);
m && t(m.newValue.id);

@@ -75,18 +75,18 @@ }

};
var Z = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE = "NONE", e))(Z || {});
var F = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE = "NONE", e))(F || {});
const z = { selected: [] }, Te = (e, n, t) => {
const { subscribe: o, set: r } = M(z);
let g = n, m = z;
const { subscribe: o, set: d } = M(z);
let p = n, m = z;
o((h) => m = h);
const v = () => {
I(m, z) || r(z);
I(m, z) || d(z);
}, w = () => {
var h;
return ((h = m.selected) == null ? void 0 : h.length) === 0;
}, p = (h) => {
}, g = (h) => {
if (w())
return !1;
const y = typeof h == "string" ? h : h.id;
return m.selected.some((O) => O.id === y);
}, L = (h, y) => {
const C = typeof h == "string" ? h : h.id;
return m.selected.some((O) => O.id === C);
}, L = (h, C) => {
const O = e.getAnnotation(h);

@@ -97,28 +97,28 @@ if (!O) {

}
switch (G(O, g, t)) {
switch (G(O, p, t)) {
case "EDIT":
r({ selected: [{ id: h, editable: !0 }], event: y });
d({ selected: [{ id: h, editable: !0 }], event: C });
break;
case "SELECT":
r({ selected: [{ id: h }], event: y });
d({ selected: [{ id: h }], event: C });
break;
default:
r({ selected: [], event: y });
d({ selected: [], event: C });
}
}, a = (h, y) => {
const O = Array.isArray(h) ? h : [h], d = O.map((u) => e.getAnnotation(u)).filter((u) => !!u);
r({
selected: d.map((u) => {
const s = y === void 0 ? G(u, g, t) === "EDIT" : y;
}, a = (h, C) => {
const O = Array.isArray(h) ? h : [h], r = O.map((u) => e.getAnnotation(u)).filter((u) => !!u);
d({
selected: r.map((u) => {
const s = C === void 0 ? G(u, p, t) === "EDIT" : C;
return { id: u.id, editable: s };
})
}), d.length !== O.length && console.warn("Invalid selection", h);
}), r.length !== O.length && console.warn("Invalid selection", h);
}, E = (h) => {
if (w())
return !1;
const { selected: y } = m;
y.some(({ id: d }) => h.includes(d)) && r({ selected: y.filter(({ id: d }) => !h.includes(d)) });
}, U = (h) => g = h;
const { selected: C } = m;
C.some(({ id: r }) => h.includes(r)) && d({ selected: C.filter(({ id: r }) => !h.includes(r)) });
}, U = (h) => p = h;
return e.observe(
({ changes: h }) => E((h.deleted || []).map((y) => y.id))
({ changes: h }) => E((h.deleted || []).map((C) => C.id))
), {

@@ -132,7 +132,7 @@ get event() {

get userSelectAction() {
return g;
return p;
},
clear: v,
isEmpty: w,
isSelected: p,
isSelected: g,
setSelected: a,

@@ -163,3 +163,3 @@ setUserSelectAction: U,

};
function F(e, n, t) {
function J(e, n, t) {
if (H.randomUUID && !n && !e)

@@ -172,3 +172,3 @@ return H.randomUUID();

const Oe = (e) => {
const { creator: n, updatedBy: t } = e.target, o = e.bodies.reduce((r, g) => [...r, g.creator, g.updatedBy].filter(Boolean), []);
const { creator: n, updatedBy: t } = e.target, o = e.bodies.reduce((d, p) => [...d, p.creator, p.updatedBy].filter(Boolean), []);
return [

@@ -178,3 +178,3 @@ n,

...o
].filter((r) => r);
].filter((d) => d);
}, j = (e) => {

@@ -191,3 +191,3 @@ const n = (t) => {

}, De = (e, n, t, o) => ({
id: F(),
id: J(),
annotation: typeof e == "string" ? e : e.id,

@@ -204,6 +204,6 @@ created: t || /* @__PURE__ */ new Date(),

}, ie = (e, n) => n.bodies.map((t) => {
const o = e.bodies.find((r) => r.id === t.id);
const o = e.bodies.find((d) => d.id === t.id);
return { newBody: t, oldBody: o && !I(o, t) ? o : void 0 };
}).filter(({ oldBody: t }) => t).map(({ oldBody: t, newBody: o }) => ({ oldBody: t, newBody: o })), de = (e, n) => !I(e.target, n.target), J = (e, n) => {
const t = oe(e, n), o = se(e, n), r = ie(e, n);
}).filter(({ oldBody: t }) => t).map(({ oldBody: t, newBody: o }) => ({ oldBody: t, newBody: o })), de = (e, n) => !I(e.target, n.target), Q = (e, n) => {
const t = oe(e, n), o = se(e, n), d = ie(e, n);
return {

@@ -214,3 +214,3 @@ oldValue: e,

bodiesDeleted: o.length > 0 ? o : void 0,
bodiesUpdated: r.length > 0 ? r : void 0,
bodiesUpdated: d.length > 0 ? d : void 0,
targetUpdated: de(e, n) ? { oldTarget: e.target, newTarget: n.target } : void 0

@@ -221,3 +221,3 @@ };

const ae = (e, n) => {
var g, m;
var p, m;
const { changes: t, origin: o } = n;

@@ -229,3 +229,3 @@ if (!(e.options.origin ? e.options.origin === o : o !== "SILENT"))

if (!(w(t.created) || w(t.deleted))) {
const L = (g = t.updated) == null ? void 0 : g.some((E) => w(E.bodiesCreated) || w(E.bodiesDeleted) || w(E.bodiesUpdated)), a = (m = t.updated) == null ? void 0 : m.some((E) => E.targetUpdated);
const L = (p = t.updated) == null ? void 0 : p.some((E) => w(E.bodiesCreated) || w(E.bodiesDeleted) || w(E.bodiesUpdated)), a = (m = t.updated) == null ? void 0 : m.some((E) => E.targetUpdated);
if (v === "BODY_ONLY" && L && !a || v === "TARGET_ONLY" && a && !L)

@@ -237,22 +237,22 @@ return !1;

const v = /* @__PURE__ */ new Set([
...(t.created || []).map((p) => p.id),
...(t.deleted || []).map((p) => p.id),
...(t.updated || []).map(({ oldValue: p }) => p.id)
...(t.created || []).map((g) => g.id),
...(t.deleted || []).map((g) => g.id),
...(t.updated || []).map(({ oldValue: g }) => g.id)
]);
return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((p) => v.has(p));
return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((g) => v.has(g));
} else
return !0;
}, ce = (e, n) => {
const t = new Set((e.created || []).map((a) => a.id)), o = new Set((e.updated || []).map(({ newValue: a }) => a.id)), r = new Set((n.created || []).map((a) => a.id)), g = new Set((n.deleted || []).map((a) => a.id)), m = new Set((n.updated || []).map(({ oldValue: a }) => a.id)), v = new Set((n.updated || []).filter(({ oldValue: a }) => t.has(a.id) || o.has(a.id)).map(({ oldValue: a }) => a.id)), w = [
...(e.created || []).filter((a) => !g.has(a.id)).map((a) => m.has(a.id) ? n.updated.find(({ oldValue: E }) => E.id === a.id).newValue : a),
const t = new Set((e.created || []).map((a) => a.id)), o = new Set((e.updated || []).map(({ newValue: a }) => a.id)), d = new Set((n.created || []).map((a) => a.id)), p = new Set((n.deleted || []).map((a) => a.id)), m = new Set((n.updated || []).map(({ oldValue: a }) => a.id)), v = new Set((n.updated || []).filter(({ oldValue: a }) => t.has(a.id) || o.has(a.id)).map(({ oldValue: a }) => a.id)), w = [
...(e.created || []).filter((a) => !p.has(a.id)).map((a) => m.has(a.id) ? n.updated.find(({ oldValue: E }) => E.id === a.id).newValue : a),
...n.created || []
], p = [
...(e.deleted || []).filter((a) => !r.has(a.id)),
], g = [
...(e.deleted || []).filter((a) => !d.has(a.id)),
...(n.deleted || []).filter((a) => !t.has(a.id))
], L = [
...(e.updated || []).filter(({ newValue: a }) => !g.has(a.id)).map((a) => {
...(e.updated || []).filter(({ newValue: a }) => !p.has(a.id)).map((a) => {
const { oldValue: E, newValue: U } = a;
if (m.has(U.id)) {
const h = n.updated.find((y) => y.oldValue.id === U.id).newValue;
return J(E, h);
const h = n.updated.find((C) => C.oldValue.id === U.id).newValue;
return Q(E, h);
} else

@@ -263,5 +263,5 @@ return a;

];
return { created: w, deleted: p, updated: L };
return { created: w, deleted: g, updated: L };
}, V = (e) => {
const n = e.id === void 0 ? F() : e.id;
const n = e.id === void 0 ? J() : e.id;
return {

@@ -282,6 +282,6 @@ ...e,

t.push({ onChange: i, options: c });
}, r = (i) => {
}, d = (i) => {
const c = t.findIndex((l) => l.onChange == i);
c > -1 && t.splice(c, 1);
}, g = (i, c) => {
}, p = (i, c) => {
const l = {

@@ -304,3 +304,3 @@ origin: i,

const f = V(i);
e.set(f.id, f), f.bodies.forEach((S) => n.set(S.id, f.id)), g(c, { created: [f] });
e.set(f.id, f), f.bodies.forEach((S) => n.set(S.id, f.id)), p(c, { created: [f] });
}

@@ -310,4 +310,4 @@ }, v = (i, c) => {

if (S) {
const C = J(S, l);
return f === l.id ? e.set(f, l) : (e.delete(f), e.set(l.id, l)), S.bodies.forEach((B) => n.delete(B.id)), l.bodies.forEach((B) => n.set(B.id, l.id)), C;
const y = Q(S, l);
return f === l.id ? e.set(f, l) : (e.delete(f), e.set(l.id, l)), S.bodies.forEach((B) => n.delete(B.id)), l.bodies.forEach((B) => n.set(B.id, l.id)), y;
} else

@@ -317,9 +317,9 @@ console.warn(`Cannot update annotation ${f} - does not exist`);

const f = le(c) ? l : c, S = v(i, c);
S && g(f, { updated: [S] });
}, p = (i, c = T.LOCAL) => {
S && p(f, { updated: [S] });
}, g = (i, c = T.LOCAL) => {
const l = i.reduce((f, S) => {
const C = v(S);
return C ? [...f, C] : f;
const y = v(S);
return y ? [...f, y] : f;
}, []);
l.length > 0 && g(c, { updated: l });
l.length > 0 && p(c, { updated: l });
}, L = (i, c = T.LOCAL) => {

@@ -332,3 +332,3 @@ const l = e.get(i.annotation);

};
e.set(l.id, f), n.set(i.id, f.id), g(c, { updated: [{
e.set(l.id, f), n.set(i.id, f.id), p(c, { updated: [{
oldValue: l,

@@ -342,3 +342,3 @@ newValue: f,

const c = [...e.values()];
e.clear(), n.clear(), g(i, { deleted: c });
e.clear(), n.clear(), p(i, { deleted: c });
}, U = (i, c = !0, l = T.LOCAL) => {

@@ -348,15 +348,15 @@ const f = i.map(V);

const S = [...e.values()];
e.clear(), n.clear(), f.forEach((C) => {
e.set(C.id, C), C.bodies.forEach((B) => n.set(B.id, C.id));
}), g(l, { created: f, deleted: S });
e.clear(), n.clear(), f.forEach((y) => {
e.set(y.id, y), y.bodies.forEach((B) => n.set(B.id, y.id));
}), p(l, { created: f, deleted: S });
} else {
const S = i.reduce((C, B) => {
const S = i.reduce((y, B) => {
const W = B.id && e.get(B.id);
return W ? [...C, W] : C;
return W ? [...y, W] : y;
}, []);
if (S.length > 0)
throw Error(`Bulk insert would overwrite the following annotations: ${S.map((C) => C.id).join(", ")}`);
f.forEach((C) => {
e.set(C.id, C), C.bodies.forEach((B) => n.set(B.id, C.id));
}), g(l, { created: f });
throw Error(`Bulk insert would overwrite the following annotations: ${S.map((y) => y.id).join(", ")}`);
f.forEach((y) => {
e.set(y.id, y), y.bodies.forEach((B) => n.set(B.id, y.id));
}), p(l, { created: f });
}

@@ -368,12 +368,12 @@ }, h = (i) => {

console.warn(`Attempt to delete missing annotation: ${c}`);
}, y = (i, c = T.LOCAL) => {
}, C = (i, c = T.LOCAL) => {
const l = h(i);
l && g(c, { deleted: [l] });
l && p(c, { deleted: [l] });
}, O = (i, c = T.LOCAL) => {
const l = i.reduce((f, S) => {
const C = h(S);
return C ? [...f, C] : f;
const y = h(S);
return y ? [...f, y] : f;
}, []);
l.length > 0 && g(c, { deleted: l });
}, d = (i) => {
l.length > 0 && p(c, { deleted: l });
}, r = (i) => {
const c = e.get(i.annotation);

@@ -386,3 +386,3 @@ if (c) {

...c,
bodies: c.bodies.filter((C) => C.id !== i.id)
bodies: c.bodies.filter((y) => y.id !== i.id)
};

@@ -399,7 +399,7 @@ return e.set(c.id, f), {

}, u = (i, c = T.LOCAL) => {
const l = d(i);
l && g(c, { updated: [l] });
const l = r(i);
l && p(c, { updated: [l] });
}, s = (i, c = T.LOCAL) => {
const l = i.map((f) => d(f)).filter(Boolean);
l.length > 0 && g(c, { updated: l });
const l = i.map((f) => r(f)).filter(Boolean);
l.length > 0 && p(c, { updated: l });
}, A = (i) => {

@@ -422,5 +422,5 @@ const c = e.get(i);

if (l) {
const f = l.bodies.find((C) => C.id === i.id), S = {
const f = l.bodies.find((y) => y.id === i.id), S = {
...l,
bodies: l.bodies.map((C) => C.id === f.id ? c : C)
bodies: l.bodies.map((y) => y.id === f.id ? c : y)
};

@@ -436,6 +436,6 @@ return e.set(l.id, S), f.id !== c.id && (n.delete(f.id), n.set(c.id, S.id)), {

const f = R(i, c);
f && g(l, { updated: [f] });
f && p(l, { updated: [f] });
}, k = (i, c = T.LOCAL) => {
const l = i.map((f) => R({ id: f.id, annotation: f.annotation }, f)).filter(Boolean);
g(c, { updated: l });
p(c, { updated: l });
}, P = (i) => {

@@ -469,10 +469,10 @@ const c = e.get(i.annotation);

bulkDeleteBodies: s,
bulkUpdateAnnotation: p,
bulkUpdateAnnotation: g,
bulkUpdateBodies: k,
bulkUpdateTargets: (i, c = T.LOCAL) => {
const l = i.map((f) => P(f)).filter(Boolean);
l.length > 0 && g(c, { updated: l });
l.length > 0 && p(c, { updated: l });
},
clear: E,
deleteAnnotation: y,
deleteAnnotation: C,
deleteBody: u,

@@ -482,3 +482,3 @@ getAnnotation: A,

observe: o,
unobserve: r,
unobserve: d,
updateAnnotation: w,

@@ -488,3 +488,3 @@ updateBody: N,

const l = P(i);
l && g(c, { updated: [l] });
l && p(c, { updated: [l] });
}

@@ -495,9 +495,9 @@ };

subscribe: (t) => {
const o = (r) => t(r.state);
const o = (d) => t(d.state);
return e.observe(o), t(e.all()), () => e.unobserve(o);
}
});
let Q = () => ({
let X = () => ({
emit(e, ...n) {
for (let t = 0, o = this.events[e] || [], r = o.length; t < r; t++)
for (let t = 0, o = this.events[e] || [], d = o.length; t < d; t++)
o[t](...n);

@@ -510,3 +510,3 @@ },

var o;
this.events[e] = (o = this.events[e]) == null ? void 0 : o.filter((r) => n !== r);
this.events[e] = (o = this.events[e]) == null ? void 0 : o.filter((d) => n !== d);
};

@@ -516,8 +516,8 @@ }

const ue = 250, Ie = (e) => {
const n = Q(), t = [];
let o = -1, r = !1, g = 0;
const n = X(), t = [];
let o = -1, d = !1, p = 0;
const m = (s) => {
if (!r) {
if (!d) {
const { changes: A } = s, b = performance.now();
if (b - g > ue)
if (b - p > ue)
t.splice(o + 1), t.push(A), o = t.length - 1;

@@ -528,8 +528,8 @@ else {

}
g = b;
p = b;
}
r = !1;
d = !1;
};
e.observe(m, { origin: T.LOCAL });
const v = (s) => s && s.length > 0 && e.bulkDeleteAnnotation(s), w = (s) => s && s.length > 0 && e.bulkAddAnnotation(s, !1), p = (s) => s && s.length > 0 && e.bulkUpdateAnnotation(s.map(({ oldValue: A }) => A)), L = (s) => s && s.length > 0 && e.bulkUpdateAnnotation(s.map(({ newValue: A }) => A)), a = (s) => s && s.length > 0 && e.bulkAddAnnotation(s, !1), E = (s) => s && s.length > 0 && e.bulkDeleteAnnotation(s);
const v = (s) => s && s.length > 0 && e.bulkDeleteAnnotation(s), w = (s) => s && s.length > 0 && e.bulkAddAnnotation(s, !1), g = (s) => s && s.length > 0 && e.bulkUpdateAnnotation(s.map(({ oldValue: A }) => A)), L = (s) => s && s.length > 0 && e.bulkUpdateAnnotation(s.map(({ newValue: A }) => A)), a = (s) => s && s.length > 0 && e.bulkAddAnnotation(s, !1), E = (s) => s && s.length > 0 && e.bulkDeleteAnnotation(s);
return {

@@ -542,3 +542,3 @@ canRedo: () => t.length - 1 > o,

if (t.length - 1 > o) {
r = !0;
d = !0;
const { created: s, updated: A, deleted: b } = t[o + 1];

@@ -550,5 +550,5 @@ w(s), L(A), E(b), n.emit("redo", t[o + 1]), o += 1;

if (o > -1) {
r = !0;
d = !0;
const { created: s, updated: A, deleted: b } = t[o];
v(s), p(A), a(b), n.emit("undo", t[o]), o -= 1;
v(s), g(A), a(b), n.emit("undo", t[o]), o -= 1;
}

@@ -564,8 +564,8 @@ }

}, xe = (e, n, t, o) => {
const { hover: r, selection: g, store: m, viewport: v } = e, w = /* @__PURE__ */ new Map();
let p = [], L, a;
const E = (d, u) => {
w.has(d) ? w.get(d).push(u) : w.set(d, [u]);
}, U = (d, u) => {
const s = w.get(d);
const { hover: d, selection: p, store: m, viewport: v } = e, w = /* @__PURE__ */ new Map();
let g = [], L, a;
const E = (r, u) => {
w.has(r) ? w.get(r).push(u) : w.set(r, [u]);
}, U = (r, u) => {
const s = w.get(r);
if (s) {

@@ -575,5 +575,5 @@ const A = s.indexOf(u);

}
}, h = (d, u, s) => {
w.has(d) && setTimeout(() => {
w.get(d).forEach((A) => {
}, h = (r, u, s) => {
w.has(r) && setTimeout(() => {
w.get(r).forEach((A) => {
if (t) {

@@ -586,8 +586,8 @@ const b = Array.isArray(u) ? u.map((N) => t.serialize(N)) : t.serialize(u), R = s ? s instanceof PointerEvent ? s : t.serialize(s) : void 0;

}, 1);
}, y = () => {
const { selected: d } = g, u = (d || []).map(({ id: s }) => m.getAnnotation(s));
}, C = () => {
const { selected: r } = p, u = (r || []).map(({ id: s }) => m.getAnnotation(s));
u.forEach((s) => {
const A = p.find((b) => b.id === s.id);
const A = g.find((b) => b.id === s.id);
(!A || !I(A, s)) && h("updateAnnotation", s, A);
}), p = p.map((s) => {
}), g = g.map((s) => {
const A = u.find(({ id: b }) => b === s.id);

@@ -597,31 +597,31 @@ return A || s;

};
g.subscribe(({ selected: d }) => {
if (!(p.length === 0 && d.length === 0)) {
if (p.length === 0 && d.length > 0)
p = d.map(({ id: u }) => m.getAnnotation(u));
else if (p.length > 0 && d.length === 0)
p.forEach((u) => {
p.subscribe(({ selected: r }) => {
if (!(g.length === 0 && r.length === 0)) {
if (g.length === 0 && r.length > 0)
g = r.map(({ id: u }) => m.getAnnotation(u));
else if (g.length > 0 && r.length === 0)
g.forEach((u) => {
const s = m.getAnnotation(u.id);
s && !I(s, u) && h("updateAnnotation", s, u);
}), p = [];
}), g = [];
else {
const u = new Set(p.map((b) => b.id)), s = new Set(d.map(({ id: b }) => b));
p.filter((b) => !s.has(b.id)).forEach((b) => {
const u = new Set(g.map((b) => b.id)), s = new Set(r.map(({ id: b }) => b));
g.filter((b) => !s.has(b.id)).forEach((b) => {
const R = m.getAnnotation(b.id);
R && !I(R, b) && h("updateAnnotation", R, b);
}), p = [
}), g = [
// Remove annotations that were deselected
...p.filter((b) => s.has(b.id)),
...g.filter((b) => s.has(b.id)),
// Add editable annotations that were selected
...d.filter(({ id: b }) => !u.has(b)).map(({ id: b }) => m.getAnnotation(b))
...r.filter(({ id: b }) => !u.has(b)).map(({ id: b }) => m.getAnnotation(b))
];
}
h("selectionChanged", p);
h("selectionChanged", g);
}
}), r.subscribe((d) => {
!L && d ? h("mouseEnterAnnotation", m.getAnnotation(d)) : L && !d ? h("mouseLeaveAnnotation", m.getAnnotation(L)) : L && d && (h("mouseLeaveAnnotation", m.getAnnotation(L)), h("mouseEnterAnnotation", m.getAnnotation(d))), L = d;
}), v == null || v.subscribe((d) => h("viewportIntersect", d.map((u) => m.getAnnotation(u)))), m.observe((d) => {
o && (a && clearTimeout(a), a = setTimeout(y, 1e3));
const { created: u, deleted: s } = d.changes;
(u || []).forEach((b) => h("createAnnotation", b)), (s || []).forEach((b) => h("deleteAnnotation", b)), (d.changes.updated || []).filter((b) => [
}), d.subscribe((r) => {
!L && r ? h("mouseEnterAnnotation", m.getAnnotation(r)) : L && !r ? h("mouseLeaveAnnotation", m.getAnnotation(L)) : L && r && (h("mouseLeaveAnnotation", m.getAnnotation(L)), h("mouseEnterAnnotation", m.getAnnotation(r))), L = r;
}), v == null || v.subscribe((r) => h("viewportIntersect", r.map((u) => m.getAnnotation(u)))), m.observe((r) => {
o && (a && clearTimeout(a), a = setTimeout(C, 1e3));
const { created: u, deleted: s } = r.changes;
(u || []).forEach((b) => h("createAnnotation", b)), (s || []).forEach((b) => h("deleteAnnotation", b)), (r.changes.updated || []).filter((b) => [
...b.bodiesCreated || [],

@@ -631,9 +631,9 @@ ...b.bodiesDeleted || [],

].length > 0).forEach(({ oldValue: b, newValue: R }) => {
const N = p.find((k) => k.id === b.id) || b;
p = p.map((k) => k.id === b.id ? R : k), h("updateAnnotation", R, N);
const N = g.find((k) => k.id === b.id) || b;
g = g.map((k) => k.id === b.id ? R : k), h("updateAnnotation", R, N);
});
}, { origin: T.LOCAL }), m.observe((d) => {
if (p) {
const u = new Set(p.map((A) => A.id)), s = (d.changes.updated || []).filter(({ newValue: A }) => u.has(A.id)).map(({ newValue: A }) => A);
s.length > 0 && (p = p.map((A) => {
}, { origin: T.LOCAL }), m.observe((r) => {
if (g) {
const u = new Set(g.map((A) => A.id)), s = (r.changes.updated || []).filter(({ newValue: A }) => u.has(A.id)).map(({ newValue: A }) => A);
s.length > 0 && (g = g.map((A) => {
const b = s.find((R) => R.id === A.id);

@@ -644,14 +644,14 @@ return b || A;

}, { origin: T.REMOTE });
const O = (d) => (u) => {
const O = (r) => (u) => {
const { updated: s } = u;
d ? (s || []).forEach((A) => h("updateAnnotation", A.oldValue, A.newValue)) : (s || []).forEach((A) => h("updateAnnotation", A.newValue, A.oldValue));
r ? (s || []).forEach((A) => h("updateAnnotation", A.oldValue, A.newValue)) : (s || []).forEach((A) => h("updateAnnotation", A.newValue, A.oldValue));
};
return n.on("undo", O(!0)), n.on("redo", O(!1)), { on: E, off: U, emit: h };
}, Ne = (e) => (n) => n.map((t) => e.serialize(t)), fe = (e) => (n) => n.reduce((t, o) => {
const { parsed: r, error: g } = e.parse(o);
return g ? {
const { parsed: d, error: p } = e.parse(o);
return p ? {
parsed: t.parsed,
failed: [...t.failed, o]
} : r ? {
parsed: [...t.parsed, r],
} : d ? {
parsed: [...t.parsed, d],
failed: t.failed

@@ -662,46 +662,46 @@ } : {

}, { parsed: [], failed: [] }), ze = (e, n, t) => {
const { store: o, selection: r } = e, g = (d) => {
const { store: o, selection: d } = e, p = (r) => {
if (t) {
const { parsed: u, error: s } = t.parse(d);
const { parsed: u, error: s } = t.parse(r);
u ? o.addAnnotation(u, T.REMOTE) : console.error(s);
} else
o.addAnnotation(j(d), T.REMOTE);
}, m = () => r.clear(), v = () => o.clear(), w = (d) => {
const u = o.getAnnotation(d);
o.addAnnotation(j(r), T.REMOTE);
}, m = () => d.clear(), v = () => o.clear(), w = (r) => {
const u = o.getAnnotation(r);
return t && u ? t.serialize(u) : u;
}, p = () => t ? o.all().map(t.serialize) : o.all(), L = () => {
}, g = () => t ? o.all().map(t.serialize) : o.all(), L = () => {
var s;
const u = (((s = r.selected) == null ? void 0 : s.map((A) => A.id)) || []).map((A) => o.getAnnotation(A)).filter(Boolean);
const u = (((s = d.selected) == null ? void 0 : s.map((A) => A.id)) || []).map((A) => o.getAnnotation(A)).filter(Boolean);
return t ? u.map(t.serialize) : u;
}, a = (d, u = !0) => fetch(d).then((s) => s.json()).then((s) => (U(s, u), s)), E = (d) => {
if (typeof d == "string") {
const u = o.getAnnotation(d);
if (o.deleteAnnotation(d), u)
}, a = (r, u = !0) => fetch(r).then((s) => s.json()).then((s) => (U(s, u), s)), E = (r) => {
if (typeof r == "string") {
const u = o.getAnnotation(r);
if (o.deleteAnnotation(r), u)
return t ? t.serialize(u) : u;
} else {
const u = t ? t.parse(d).parsed : d;
const u = t ? t.parse(r).parsed : r;
if (u)
return o.deleteAnnotation(u), d;
return o.deleteAnnotation(u), r;
}
}, U = (d, u = !0) => {
}, U = (r, u = !0) => {
if (t) {
const s = t.parseAll || fe(t), { parsed: A, failed: b } = s(d);
const s = t.parseAll || fe(t), { parsed: A, failed: b } = s(r);
b.length > 0 && console.warn(`Discarded ${b.length} invalid annotations`, b), o.bulkAddAnnotation(A, u, T.REMOTE);
} else
o.bulkAddAnnotation(d.map(j), u, T.REMOTE);
}, h = (d, u) => {
d ? r.setSelected(d, u) : r.clear();
}, y = (d) => {
r.clear(), r.setUserSelectAction(d);
}, O = (d) => {
o.bulkAddAnnotation(r.map(j), u, T.REMOTE);
}, h = (r, u) => {
r ? d.setSelected(r, u) : d.clear();
}, C = (r) => {
d.clear(), d.setUserSelectAction(r);
}, O = (r) => {
if (t) {
const u = t.parse(d).parsed, s = t.serialize(o.getAnnotation(u.id));
const u = t.parse(r).parsed, s = t.serialize(o.getAnnotation(u.id));
return o.updateAnnotation(u), s;
} else {
const u = o.getAnnotation(d.id);
return o.updateAnnotation(j(d)), u;
const u = o.getAnnotation(r.id);
return o.updateAnnotation(j(r)), u;
}
};
return {
addAnnotation: g,
addAnnotation: p,
cancelSelected: m,

@@ -712,3 +712,3 @@ canRedo: n.canRedo,

getAnnotationById: w,
getAnnotations: p,
getAnnotations: g,
getSelected: L,

@@ -720,15 +720,24 @@ loadAnnotations: a,

setSelected: h,
setUserSelectAction: y,
setUserSelectAction: C,
undo: n.undo,
updateAnnotation: O
};
}, $e = (e, n, t) => typeof n == "function" ? n(e, t) : n, Ve = (e, n) => typeof e != "function" && typeof n != "function" ? {
...e || {},
...n || {}
} : (t, o) => {
const d = typeof e == "function" ? e(t, o) : e, p = typeof n == "function" ? n(t, o) : n;
return {
...d || {},
...p || {}
};
}, pe = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
let ge = (e) => crypto.getRandomValues(new Uint8Array(e)), he = (e, n, t) => {
let o = (2 << Math.log(e.length - 1) / Math.LN2) - 1, r = -~(1.6 * o * n / e.length);
return (g = n) => {
let o = (2 << Math.log(e.length - 1) / Math.LN2) - 1, d = -~(1.6 * o * n / e.length);
return (p = n) => {
let m = "";
for (; ; ) {
let v = t(r), w = r;
let v = t(d), w = d;
for (; w--; )
if (m += e[v[w] & o] || "", m.length === g) return m;
if (m += e[v[w] & o] || "", m.length === p) return m;
}

@@ -742,19 +751,19 @@ };

};
const $e = () => ({ isGuest: !0, id: me("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), be = (e) => {
const _e = () => ({ isGuest: !0, id: me("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), be = (e) => {
const n = JSON.stringify(e);
let t = 0;
for (let o = 0, r = n.length; o < r; o++) {
let g = n.charCodeAt(o);
t = (t << 5) - t + g, t |= 0;
for (let o = 0, d = n.length; o < d; o++) {
let p = n.charCodeAt(o);
t = (t << 5) - t + p, t |= 0;
}
return `${t}`;
}, ve = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, Ve = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {
const { id: o, type: r, purpose: g, value: m, created: v, modified: w, creator: p, ...L } = t;
}, ve = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, Ye = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {
const { id: o, type: d, purpose: p, value: m, created: v, modified: w, creator: g, ...L } = t;
return {
id: o || `temp-${be(t)}`,
annotation: n,
type: r,
purpose: g,
type: d,
purpose: p,
value: m,
creator: ve(p),
creator: ve(g),
created: v ? new Date(v) : void 0,

@@ -764,8 +773,8 @@ updated: w ? new Date(w) : void 0,

};
}), _e = (e) => e.map((n) => {
}), je = (e) => e.map((n) => {
var v;
const { annotation: t, created: o, updated: r, ...g } = n, m = {
...g,
const { annotation: t, created: o, updated: d, ...p } = n, m = {
...p,
created: o == null ? void 0 : o.toISOString(),
modified: r == null ? void 0 : r.toISOString()
modified: d == null ? void 0 : d.toISOString()
};

@@ -795,17 +804,17 @@ return (v = m.id) != null && v.startsWith("temp-") && delete m.id, m;

return { assignRandomColor: () => {
const o = Math.floor(Math.random() * e.length), r = e[o];
return e.splice(o, 1), r;
const o = Math.floor(Math.random() * e.length), d = e[o];
return e.splice(o, 1), d;
}, releaseColor: (o) => e.push(o) };
}, ye = () => {
}, Ce = () => {
const e = we();
return { addUser: (o, r) => {
const g = e.assignRandomColor();
return { addUser: (o, d) => {
const p = e.assignRandomColor();
return {
label: r.name || r.id,
avatar: r.avatar,
color: g
label: d.name || d.id,
avatar: d.avatar,
color: p
};
}, removeUser: (o) => e.releaseColor(o.appearance.color) };
}, Ce = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)), Ye = Ae(), je = (e = ye()) => {
const n = Q(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), r = (a, E) => {
}, ye = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)), Me = Ae(), Pe = (e = Ce()) => {
const n = X(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), d = (a, E) => {
if (t.has(a)) {

@@ -821,3 +830,3 @@ console.warn("Attempt to add user that is already present", a, E);

});
}, g = (a) => {
}, p = (a) => {
const E = t.get(a);

@@ -830,7 +839,7 @@ if (!E) {

}, m = (a) => {
const E = new Set(a.map((y) => y.presenceKey)), U = a.filter(({ presenceKey: y }) => !t.has(y)), h = Array.from(t.values()).filter((y) => !E.has(y.presenceKey));
U.forEach(({ presenceKey: y, user: O }) => r(y, O)), h.forEach((y) => {
const { presenceKey: O } = y;
o.has(O) && n.emit("selectionChange", y, null), g(O);
}), (U.length > 0 || h.length > 0) && n.emit("presence", p());
const E = new Set(a.map((C) => C.presenceKey)), U = a.filter(({ presenceKey: C }) => !t.has(C)), h = Array.from(t.values()).filter((C) => !E.has(C.presenceKey));
U.forEach(({ presenceKey: C, user: O }) => d(C, O)), h.forEach((C) => {
const { presenceKey: O } = C;
o.has(O) && n.emit("selectionChange", C, null), p(O);
}), (U.length > 0 || h.length > 0) && n.emit("presence", g());
}, v = (a, E) => {

@@ -843,3 +852,3 @@ const U = t.get(a);

const h = o.get(a);
(!h || !Ce(h, E)) && (o.set(a, E), n.emit("selectionChange", U, E));
(!h || !ye(h, E)) && (o.set(a, E), n.emit("selectionChange", U, E));
}, w = (a, E) => {

@@ -852,5 +861,5 @@ const U = t.get(a);

E ? o.set(a, E) : o.delete(a), n.emit("selectionChange", U, E);
}, p = () => [...Array.from(t.values())];
}, g = () => [...Array.from(t.values())];
return {
getPresentUsers: p,
getPresentUsers: g,
notifyActivity: v,

@@ -865,11 +874,13 @@ on: (a, E) => n.on(a, E),

T as Origin,
Ye as PRESENCE_KEY,
Z as UserSelectAction,
$e as createAnonymousGuest,
Me as PRESENCE_KEY,
F as UserSelectAction,
Ve as chainStyles,
$e as computeStyle,
_e as createAnonymousGuest,
ze as createBaseAnnotator,
De as createBody,
ye as createDefaultAppearanceProvider,
Ce as createDefaultAppearanceProvider,
Ue as createHoverState,
xe as createLifecycleObserver,
je as createPresenceState,
Pe as createPresenceState,
Te as createSelectionState,

@@ -880,3 +891,3 @@ Re as createStore,

we as defaultColorProvider,
J as diffAnnotations,
Q as diffAnnotations,
Oe as getContributors,

@@ -886,7 +897,7 @@ ce as mergeChanges,

fe as parseAll,
Ve as parseW3CBodies,
Ye as parseW3CBodies,
ve as parseW3CUser,
j as reviveDates,
Ne as serializeAll,
_e as serializeW3CBodies,
je as serializeW3CBodies,
ae as shouldNotify,

@@ -893,0 +904,0 @@ Be as toSvelteStore

@@ -15,3 +15,18 @@ import { Annotation } from './Annotation';

export type DrawingStyleExpression<T extends Annotation = Annotation> = DrawingStyle | ((annotation: T, state?: AnnotationState) => DrawingStyle | undefined);
/** Utility functions **/
export declare const computeStyle: <T extends Annotation = Annotation>(annotation: T, style: DrawingStyleExpression<T>, state?: AnnotationState) => DrawingStyle | undefined;
export declare const chainStyles: <T extends Annotation = Annotation>(applyFirst: DrawingStyleExpression<T>, applySecond: DrawingStyleExpression<T>) => ((a: T, state: AnnotationState) => {
fill?: Color;
fillOpacity?: number;
stroke?: Color;
strokeOpacity?: number;
strokeWidth?: number;
}) | {
fill?: Color;
fillOpacity?: number;
stroke?: Color;
strokeOpacity?: number;
strokeWidth?: number;
};
export {};
//# sourceMappingURL=DrawingStyle.d.ts.map
{
"name": "@annotorious/core",
"version": "3.0.6",
"version": "3.0.7",
"description": "Annotorious core types and functions",

@@ -5,0 +5,0 @@ "author": "Rainer Simon",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc