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
0
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.2 to 3.0.3

348

dist/annotorious-core.es.js
var W = Object.prototype.hasOwnProperty;
function x(e, n) {
function I(e, n) {
var t, o;

@@ -10,3 +10,3 @@ if (e === n) return !0;

if ((o = e.length) === n.length)
for (; o-- && x(e[o], n[o]); ) ;
for (; o-- && I(e[o], n[o]); ) ;
return o === -1;

@@ -17,3 +17,3 @@ }

for (t in e)
if (W.call(e, t) && ++o && !W.call(n, t) || !(t in n) || !x(e[t], n[t])) return !1;
if (W.call(e, t) && ++o && !W.call(n, t) || !(t in n) || !I(e[t], n[t])) return !1;
return Object.keys(n).length === o;

@@ -29,3 +29,3 @@ }

}
const I = [];
const k = [];
function j(e, n = _) {

@@ -36,9 +36,9 @@ let t;

if (Q(e, b) && (e = b, t)) {
const y = !I.length;
for (const g of o)
g[1](), I.push(g, e);
const y = !k.length;
for (const h of o)
h[1](), k.push(h, e);
if (y) {
for (let g = 0; g < I.length; g += 2)
I[g][0](I[g + 1]);
I.length = 0;
for (let h = 0; h < k.length; h += 2)
k[h][0](k[h + 1]);
k.length = 0;
}

@@ -51,5 +51,5 @@ }

function w(b, y = _) {
const g = [b, y];
return o.add(g), o.size === 1 && (t = n(i, f) || _), b(e), () => {
o.delete(g), o.size === 0 && t && (t(), t = null);
const h = [b, y];
return o.add(h), o.size === 1 && (t = n(i, f) || _), b(e), () => {
o.delete(h), o.size === 0 && t && (t(), t = null);
};

@@ -59,3 +59,3 @@ }

}
const Le = (e) => {
const Se = (e) => {
const { subscribe: n, set: t } = j();

@@ -78,3 +78,3 @@ let o;

var X = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE = "NONE", e))(X || {});
const z = { selected: [] }, Se = (e, n) => {
const z = { selected: [] }, Ue = (e, n) => {
const { subscribe: t, set: o } = j(z);

@@ -84,3 +84,3 @@ let i = n, f = z;

const w = () => {
x(f, z) || o(z);
I(f, z) || o(z);
}, b = () => {

@@ -93,10 +93,10 @@ var m;

const v = typeof m == "string" ? m : m.id;
return f.selected.some((U) => U.id === v);
}, g = (m, v) => {
const U = e.getAnnotation(m);
if (!U) {
return f.selected.some((L) => L.id === v);
}, h = (m, v) => {
const L = e.getAnnotation(m);
if (!L) {
console.warn("Invalid selection: " + m);
return;
}
switch (q(U, i)) {
switch (q(L, i)) {
case "EDIT":

@@ -111,10 +111,10 @@ o({ selected: [{ id: m, editable: !0 }], event: v });

}
}, L = (m, v) => {
const U = Array.isArray(m) ? m : [m], T = U.map((a) => e.getAnnotation(a)).filter((a) => !!a);
}, S = (m, v) => {
const L = Array.isArray(m) ? m : [m], O = L.map((a) => e.getAnnotation(a)).filter((a) => !!a);
o({
selected: T.map((a) => {
selected: O.map((a) => {
const u = v === void 0 ? q(a, i) === "EDIT" : v;
return { id: a.id, editable: u };
})
}), T.length !== U.length && console.warn("Invalid selection", m);
}), O.length !== L.length && console.warn("Invalid selection", m);
}, r = (m) => {

@@ -124,3 +124,3 @@ if (b())

const { selected: v } = f;
v.some(({ id: T }) => m.includes(T)) && o({ selected: v.filter(({ id: T }) => !m.includes(T)) });
v.some(({ id: O }) => m.includes(O)) && o({ selected: v.filter(({ id: O }) => !m.includes(O)) });
}, E = (m) => i = m;

@@ -142,6 +142,6 @@ return e.observe(

isSelected: y,
setSelected: L,
setSelected: S,
setUserSelectAction: E,
subscribe: t,
userSelect: g
userSelect: h
};

@@ -172,3 +172,3 @@ }, q = (e, n) => typeof n == "function" ? n(e) : n || "EDIT";

}
const Oe = (e) => {
const Te = (e) => {
const { creator: n, updatedBy: t } = e.target, o = e.bodies.reduce((i, f) => [...i, f.creator, f.updatedBy].filter(Boolean), []);

@@ -180,3 +180,3 @@ return [

].filter((i) => i);
}, Te = (e, n, t, o) => ({
}, Oe = (e, n, t, o) => ({
id: H(),

@@ -195,4 +195,4 @@ annotation: typeof e == "string" ? e : e.id,

const o = e.bodies.find((i) => i.id === t.id);
return { newBody: t, oldBody: o && !x(o, t) ? o : void 0 };
}).filter(({ oldBody: t }) => t).map(({ oldBody: t, newBody: o }) => ({ oldBody: t, newBody: o })), ie = (e, n) => !x(e.target, n.target), F = (e, n) => {
return { newBody: t, oldBody: o && !I(o, t) ? o : void 0 };
}).filter(({ oldBody: t }) => t).map(({ oldBody: t, newBody: o }) => ({ oldBody: t, newBody: o })), ie = (e, n) => !I(e.target, n.target), F = (e, n) => {
const t = ne(e, n), o = oe(e, n), i = se(e, n);

@@ -208,13 +208,13 @@ return {

};
var de = /* @__PURE__ */ ((e) => (e.BODY_ONLY = "BODY_ONLY", e.TARGET_ONLY = "TARGET_ONLY", e))(de || {}), O = /* @__PURE__ */ ((e) => (e.LOCAL = "LOCAL", e.REMOTE = "REMOTE", e))(O || {});
var de = /* @__PURE__ */ ((e) => (e.BODY_ONLY = "BODY_ONLY", e.TARGET_ONLY = "TARGET_ONLY", e))(de || {}), T = /* @__PURE__ */ ((e) => (e.LOCAL = "LOCAL", e.REMOTE = "REMOTE", e.SILENT = "SILENT", e))(T || {});
const ae = (e, n) => {
var f, w;
const { changes: t, origin: o } = n;
if (!(!e.options.origin || e.options.origin === o))
if (!(e.options.origin ? e.options.origin === o : o !== "SILENT"))
return !1;
if (e.options.ignore) {
const { ignore: b } = e.options, y = (L) => L && L.length > 0;
const { ignore: b } = e.options, y = (S) => S && S.length > 0;
if (!(y(t.created) || y(t.deleted))) {
const L = (f = t.updated) == null ? void 0 : f.some((E) => y(E.bodiesCreated) || y(E.bodiesDeleted) || y(E.bodiesUpdated)), r = (w = t.updated) == null ? void 0 : w.some((E) => E.targetUpdated);
if (b === "BODY_ONLY" && L && !r || b === "TARGET_ONLY" && r && !L)
const S = (f = t.updated) == null ? void 0 : f.some((E) => y(E.bodiesCreated) || y(E.bodiesDeleted) || y(E.bodiesUpdated)), r = (w = t.updated) == null ? void 0 : w.some((E) => E.targetUpdated);
if (b === "BODY_ONLY" && S && !r || b === "TARGET_ONLY" && r && !S)
return !1;

@@ -225,7 +225,7 @@ }

const b = /* @__PURE__ */ new Set([
...(t.created || []).map((g) => g.id),
...(t.deleted || []).map((g) => g.id),
...(t.updated || []).map(({ oldValue: g }) => g.id)
...(t.created || []).map((h) => h.id),
...(t.deleted || []).map((h) => h.id),
...(t.updated || []).map(({ oldValue: h }) => h.id)
]);
return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((g) => b.has(g));
return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((h) => b.has(h));
} else

@@ -237,10 +237,10 @@ return !0;

...n.created || []
], g = [
], h = [
...(e.deleted || []).filter((r) => !i.has(r.id)),
...(n.deleted || []).filter((r) => !t.has(r.id))
], L = [
], S = [
...(e.updated || []).filter(({ newValue: r }) => !f.has(r.id)).map((r) => {
const { oldValue: E, newValue: m } = r;
if (w.has(m.id)) {
const v = n.updated.find((U) => U.oldValue.id === m.id).newValue;
const v = n.updated.find((L) => L.oldValue.id === m.id).newValue;
return F(E, v);

@@ -252,3 +252,3 @@ } else

];
return { created: y, deleted: g, updated: L };
return { created: y, deleted: h, updated: S };
}, V = (e) => {

@@ -269,3 +269,5 @@ const n = e.id === void 0 ? H() : e.id;

}, ce = (e) => e.id !== void 0, De = () => {
const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (d, c = {}) => t.push({ onChange: d, options: c }), i = (d) => {
const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (d, c = {}) => {
t.push({ onChange: d, options: c });
}, i = (d) => {
const c = t.findIndex((l) => l.onChange == d);

@@ -286,3 +288,3 @@ c > -1 && t.splice(c, 1);

});
}, w = (d, c = O.LOCAL) => {
}, w = (d, c = T.LOCAL) => {
if (d.id && e.get(d.id))

@@ -292,21 +294,21 @@ throw Error(`Cannot add annotation ${d.id} - exists already`);

const p = V(d);
e.set(p.id, p), p.bodies.forEach((S) => n.set(S.id, p.id)), f(c, { created: [p] });
e.set(p.id, p), p.bodies.forEach((U) => n.set(U.id, p.id)), f(c, { created: [p] });
}
}, b = (d, c) => {
const l = V(typeof d == "string" ? c : d), p = typeof d == "string" ? d : d.id, S = p && e.get(p);
if (S) {
const C = F(S, l);
return p === l.id ? e.set(p, l) : (e.delete(p), 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 l = V(typeof d == "string" ? c : d), p = typeof d == "string" ? d : d.id, U = p && e.get(p);
if (U) {
const C = F(U, l);
return p === l.id ? e.set(p, l) : (e.delete(p), e.set(l.id, l)), U.bodies.forEach((B) => n.delete(B.id)), l.bodies.forEach((B) => n.set(B.id, l.id)), C;
} else
console.warn(`Cannot update annotation ${p} - does not exist`);
}, y = (d, c = O.LOCAL, l = O.LOCAL) => {
const p = ce(c) ? l : c, S = b(d, c);
S && f(p, { updated: [S] });
}, g = (d, c = O.LOCAL) => {
const l = d.reduce((p, S) => {
const C = b(S);
}, y = (d, c = T.LOCAL, l = T.LOCAL) => {
const p = ce(c) ? l : c, U = b(d, c);
U && f(p, { updated: [U] });
}, h = (d, c = T.LOCAL) => {
const l = d.reduce((p, U) => {
const C = b(U);
return C ? [...p, C] : p;
}, []);
l.length > 0 && f(c, { updated: l });
}, L = (d, c = O.LOCAL) => {
}, S = (d, c = T.LOCAL) => {
const l = e.get(d.annotation);

@@ -325,19 +327,19 @@ if (l) {

console.warn(`Attempt to add body to missing annotation: ${d.annotation}`);
}, r = () => [...e.values()], E = (d = O.LOCAL) => {
}, r = () => [...e.values()], E = (d = T.LOCAL) => {
const c = [...e.values()];
e.clear(), n.clear(), f(d, { deleted: c });
}, m = (d, c = !0, l = O.LOCAL) => {
}, m = (d, c = !0, l = T.LOCAL) => {
const p = d.map(V);
if (c) {
const S = [...e.values()];
const U = [...e.values()];
e.clear(), n.clear(), p.forEach((C) => {
e.set(C.id, C), C.bodies.forEach((B) => n.set(B.id, C.id));
}), f(l, { created: p, deleted: S });
}), f(l, { created: p, deleted: U });
} else {
const S = d.reduce((C, B) => {
const U = d.reduce((C, B) => {
const P = B.id && e.get(B.id);
return P ? [...C, P] : C;
}, []);
if (S.length > 0)
throw Error(`Bulk insert would overwrite the following annotations: ${S.map((C) => C.id).join(", ")}`);
if (U.length > 0)
throw Error(`Bulk insert would overwrite the following annotations: ${U.map((C) => C.id).join(", ")}`);
p.forEach((C) => {

@@ -352,8 +354,8 @@ e.set(C.id, C), C.bodies.forEach((B) => n.set(B.id, C.id));

console.warn(`Attempt to delete missing annotation: ${c}`);
}, U = (d, c = O.LOCAL) => {
}, L = (d, c = T.LOCAL) => {
const l = v(d);
l && f(c, { deleted: [l] });
}, T = (d, c = O.LOCAL) => {
const l = d.reduce((p, S) => {
const C = v(S);
}, O = (d, c = T.LOCAL) => {
const l = d.reduce((p, U) => {
const C = v(U);
return C ? [...p, C] : p;

@@ -381,9 +383,9 @@ }, []);

console.warn(`Attempt to delete body from missing annotation ${d.annotation}`);
}, u = (d, c = O.LOCAL) => {
}, u = (d, c = T.LOCAL) => {
const l = a(d);
l && f(c, { updated: [l] });
}, s = (d, c = O.LOCAL) => {
}, s = (d, c = T.LOCAL) => {
const l = d.map((p) => a(p)).filter(Boolean);
l.length > 0 && f(c, { updated: l });
}, h = (d) => {
}, g = (d) => {
const c = e.get(d);

@@ -394,3 +396,3 @@ return c ? { ...c } : void 0;

if (c) {
const p = h(c).bodies.find((S) => S.id === d);
const p = g(c).bodies.find((U) => U.id === d);
if (p)

@@ -406,9 +408,9 @@ return p;

if (l) {
const p = l.bodies.find((C) => C.id === d.id), S = {
const p = l.bodies.find((C) => C.id === d.id), U = {
...l,
bodies: l.bodies.map((C) => C.id === p.id ? c : C)
};
return e.set(l.id, S), p.id !== c.id && (n.delete(p.id), n.set(c.id, S.id)), {
return e.set(l.id, U), p.id !== c.id && (n.delete(p.id), n.set(c.id, U.id)), {
oldValue: l,
newValue: S,
newValue: U,
bodiesUpdated: [{ oldBody: p, newBody: c }]

@@ -418,6 +420,6 @@ };

console.warn(`Attempt to add body to missing annotation ${d.annotation}`);
}, N = (d, c, l = O.LOCAL) => {
}, N = (d, c, l = T.LOCAL) => {
const p = R(d, c);
p && f(l, { updated: [p] });
}, k = (d, c = O.LOCAL) => {
}, x = (d, c = T.LOCAL) => {
const l = d.map((p) => R({ id: p.id, annotation: p.annotation }, p)).filter(Boolean);

@@ -448,10 +450,10 @@ f(c, { updated: l });

addAnnotation: w,
addBody: L,
addBody: S,
all: r,
bulkAddAnnotation: m,
bulkDeleteAnnotation: T,
bulkDeleteAnnotation: O,
bulkDeleteBodies: s,
bulkUpdateAnnotation: g,
bulkUpdateBodies: k,
bulkUpdateTargets: (d, c = O.LOCAL) => {
bulkUpdateAnnotation: h,
bulkUpdateBodies: x,
bulkUpdateTargets: (d, c = T.LOCAL) => {
const l = d.map((p) => M(p)).filter(Boolean);

@@ -461,5 +463,5 @@ l.length > 0 && f(c, { updated: l });

clear: E,
deleteAnnotation: U,
deleteAnnotation: L,
deleteBody: u,
getAnnotation: h,
getAnnotation: g,
getBody: A,

@@ -470,3 +472,3 @@ observe: o,

updateBody: N,
updateTarget: (d, c = O.LOCAL) => {
updateTarget: (d, c = T.LOCAL) => {
const l = M(d);

@@ -502,8 +504,8 @@ l && f(c, { updated: [l] });

if (!i) {
const { changes: h } = s, A = performance.now();
const { changes: g } = s, A = performance.now();
if (A - f > le)
t.splice(o + 1), t.push(h), o = t.length - 1;
t.splice(o + 1), t.push(g), o = t.length - 1;
else {
const R = t.length - 1;
t[R] = re(t[R], h);
t[R] = re(t[R], g);
}

@@ -514,4 +516,4 @@ f = A;

};
e.observe(w, { origin: O.LOCAL });
const b = (s) => s && s.length > 0 && e.bulkDeleteAnnotation(s), y = (s) => s && s.length > 0 && e.bulkAddAnnotation(s, !1), g = (s) => s && s.length > 0 && e.bulkUpdateAnnotation(s.map(({ oldValue: h }) => h)), L = (s) => s && s.length > 0 && e.bulkUpdateAnnotation(s.map(({ newValue: h }) => h)), r = (s) => s && s.length > 0 && e.bulkAddAnnotation(s, !1), E = (s) => s && s.length > 0 && e.bulkDeleteAnnotation(s);
e.observe(w, { origin: T.LOCAL });
const b = (s) => s && s.length > 0 && e.bulkDeleteAnnotation(s), y = (s) => s && s.length > 0 && e.bulkAddAnnotation(s, !1), h = (s) => s && s.length > 0 && e.bulkUpdateAnnotation(s.map(({ oldValue: g }) => g)), S = (s) => s && s.length > 0 && e.bulkUpdateAnnotation(s.map(({ newValue: g }) => g)), r = (s) => s && s.length > 0 && e.bulkAddAnnotation(s, !1), E = (s) => s && s.length > 0 && e.bulkDeleteAnnotation(s);
return {

@@ -521,8 +523,8 @@ canRedo: () => t.length - 1 > o,

destroy: () => e.unobserve(w),
on: (s, h) => n.on(s, h),
on: (s, g) => n.on(s, g),
redo: () => {
if (t.length - 1 > o) {
i = !0;
const { created: s, updated: h, deleted: A } = t[o + 1];
y(s), L(h), E(A), n.emit("redo", t[o + 1]), o += 1;
const { created: s, updated: g, deleted: A } = t[o + 1];
y(s), S(g), E(A), n.emit("redo", t[o + 1]), o += 1;
}

@@ -533,8 +535,8 @@ },

i = !0;
const { created: s, updated: h, deleted: A } = t[o];
b(s), g(h), r(A), n.emit("undo", t[o]), o -= 1;
const { created: s, updated: g, deleted: A } = t[o];
b(s), h(g), r(A), n.emit("undo", t[o]), o -= 1;
}
}
};
}, xe = () => {
}, Ie = () => {
const { subscribe: e, set: n } = j([]);

@@ -545,5 +547,5 @@ return {

};
}, ke = (e, n, t, o) => {
}, xe = (e, n, t, o) => {
const { store: i, selection: f, hover: w, viewport: b } = e, y = /* @__PURE__ */ new Map();
let g = [], L, r;
let h = [], S, r;
const E = (a, u) => {

@@ -554,42 +556,42 @@ y.has(a) ? y.get(a).push(u) : y.set(a, [u]);

if (s) {
const h = s.indexOf(u);
h !== -1 && s.splice(h, 1);
const g = s.indexOf(u);
g !== -1 && s.splice(g, 1);
}
}, v = (a, u, s) => {
y.has(a) && setTimeout(() => {
y.get(a).forEach((h) => {
y.get(a).forEach((g) => {
if (t) {
const A = Array.isArray(u) ? u.map((N) => t.serialize(N)) : t.serialize(u), R = s ? s instanceof PointerEvent ? s : t.serialize(s) : void 0;
h(A, R);
g(A, R);
} else
h(u, s);
g(u, s);
});
}, 1);
}, U = () => {
}, L = () => {
const { selected: a } = f, u = (a || []).map(({ id: s }) => i.getAnnotation(s));
u.forEach((s) => {
const h = g.find((A) => A.id === s.id);
(!h || !x(h, s)) && v("updateAnnotation", s, h);
}), g = g.map((s) => {
const h = u.find(({ id: A }) => A === s.id);
return h || s;
const g = h.find((A) => A.id === s.id);
(!g || !I(g, s)) && v("updateAnnotation", s, g);
}), h = h.map((s) => {
const g = u.find(({ id: A }) => A === s.id);
return g || s;
});
};
f.subscribe(({ selected: a }) => {
if (!(g.length === 0 && a.length === 0)) {
if (g.length === 0 && a.length > 0)
g = a.map(({ id: u }) => i.getAnnotation(u));
else if (g.length > 0 && a.length === 0)
g.forEach((u) => {
if (!(h.length === 0 && a.length === 0)) {
if (h.length === 0 && a.length > 0)
h = a.map(({ id: u }) => i.getAnnotation(u));
else if (h.length > 0 && a.length === 0)
h.forEach((u) => {
const s = i.getAnnotation(u.id);
s && !x(s, u) && v("updateAnnotation", s, u);
}), g = [];
s && !I(s, u) && v("updateAnnotation", s, u);
}), h = [];
else {
const u = new Set(g.map((A) => A.id)), s = new Set(a.map(({ id: A }) => A));
g.filter((A) => !s.has(A.id)).forEach((A) => {
const u = new Set(h.map((A) => A.id)), s = new Set(a.map(({ id: A }) => A));
h.filter((A) => !s.has(A.id)).forEach((A) => {
const R = i.getAnnotation(A.id);
R && !x(R, A) && v("updateAnnotation", R, A);
}), g = [
R && !I(R, A) && v("updateAnnotation", R, A);
}), h = [
// Remove annotations that were deselected
...g.filter((A) => s.has(A.id)),
...h.filter((A) => s.has(A.id)),
// Add editable annotations that were selected

@@ -599,8 +601,8 @@ ...a.filter(({ id: A }) => !u.has(A)).map(({ id: A }) => i.getAnnotation(A))

}
v("selectionChanged", g);
v("selectionChanged", h);
}
}), w.subscribe((a) => {
!L && a ? v("mouseEnterAnnotation", i.getAnnotation(a)) : L && !a ? v("mouseLeaveAnnotation", i.getAnnotation(L)) : L && a && (v("mouseLeaveAnnotation", i.getAnnotation(L)), v("mouseEnterAnnotation", i.getAnnotation(a))), L = a;
!S && a ? v("mouseEnterAnnotation", i.getAnnotation(a)) : S && !a ? v("mouseLeaveAnnotation", i.getAnnotation(S)) : S && a && (v("mouseLeaveAnnotation", i.getAnnotation(S)), v("mouseEnterAnnotation", i.getAnnotation(a))), S = a;
}), b == null || b.subscribe((a) => v("viewportIntersect", a.map((u) => i.getAnnotation(u)))), i.observe((a) => {
o && (r && clearTimeout(r), r = setTimeout(U, 1e3));
o && (r && clearTimeout(r), r = setTimeout(L, 1e3));
const { created: u, deleted: s } = a.changes;

@@ -612,20 +614,20 @@ (u || []).forEach((A) => v("createAnnotation", A)), (s || []).forEach((A) => v("deleteAnnotation", A)), (a.changes.updated || []).filter((A) => [

].length > 0).forEach(({ oldValue: A, newValue: R }) => {
const N = g.find((k) => k.id === A.id) || A;
g = g.map((k) => k.id === A.id ? R : k), v("updateAnnotation", R, N);
const N = h.find((x) => x.id === A.id) || A;
h = h.map((x) => x.id === A.id ? R : x), v("updateAnnotation", R, N);
});
}, { origin: O.LOCAL }), i.observe((a) => {
if (g) {
const u = new Set(g.map((h) => h.id)), s = (a.changes.updated || []).filter(({ newValue: h }) => u.has(h.id)).map(({ newValue: h }) => h);
s.length > 0 && (g = g.map((h) => {
const A = s.find((R) => R.id === h.id);
return A || h;
}, { origin: T.LOCAL }), i.observe((a) => {
if (h) {
const u = new Set(h.map((g) => g.id)), s = (a.changes.updated || []).filter(({ newValue: g }) => u.has(g.id)).map(({ newValue: g }) => g);
s.length > 0 && (h = h.map((g) => {
const A = s.find((R) => R.id === g.id);
return A || g;
}));
}
}, { origin: O.REMOTE });
const T = (a) => (u) => {
}, { origin: T.REMOTE });
const O = (a) => (u) => {
const { updated: s } = u;
a ? (s || []).forEach((h) => v("updateAnnotation", h.oldValue, h.newValue)) : (s || []).forEach((h) => v("updateAnnotation", h.newValue, h.oldValue));
a ? (s || []).forEach((g) => v("updateAnnotation", g.oldValue, g.newValue)) : (s || []).forEach((g) => v("updateAnnotation", g.newValue, g.oldValue));
};
return n.on("undo", T(!0)), n.on("redo", T(!1)), { on: E, off: m, emit: v };
}, Ie = (e) => (n) => n.map((t) => e.serialize(t)), ue = (e) => (n) => n.reduce((t, o) => {
return n.on("undo", O(!0)), n.on("redo", O(!1)), { on: E, off: m, emit: v };
}, ke = (e) => (n) => n.map((t) => e.serialize(t)), ue = (e) => (n) => n.reduce((t, o) => {
const { parsed: i, error: f } = e.parse(o);

@@ -645,11 +647,11 @@ return f ? {

const { parsed: u, error: s } = t.parse(a);
u ? o.addAnnotation(u, O.REMOTE) : console.error(s);
u ? o.addAnnotation(u, T.REMOTE) : console.error(s);
} else
o.addAnnotation(a, O.REMOTE);
o.addAnnotation(a, T.REMOTE);
}, w = () => i.clear(), b = () => o.clear(), y = (a) => {
const u = o.getAnnotation(a);
return t && u ? t.serialize(u) : u;
}, g = () => t ? o.all().map(t.serialize) : o.all(), L = () => {
}, h = () => t ? o.all().map(t.serialize) : o.all(), S = () => {
var s;
const u = (((s = i.selected) == null ? void 0 : s.map((h) => h.id)) || []).map((h) => o.getAnnotation(h)).filter(Boolean);
const u = (((s = i.selected) == null ? void 0 : s.map((g) => g.id)) || []).map((g) => o.getAnnotation(g)).filter(Boolean);
return t ? u.map(t.serialize) : u;

@@ -668,11 +670,11 @@ }, r = (a, u = !0) => fetch(a).then((s) => s.json()).then((s) => (m(s, u), s)), E = (a) => {

if (t) {
const { parsed: s, failed: h } = ue(t)(a);
h.length > 0 && console.warn(`Discarded ${h.length} invalid annotations`, h), o.bulkAddAnnotation(s, u, O.REMOTE);
const { parsed: s, failed: g } = ue(t)(a);
g.length > 0 && console.warn(`Discarded ${g.length} invalid annotations`, g), o.bulkAddAnnotation(s, u, T.REMOTE);
} else
o.bulkAddAnnotation(a, u, O.REMOTE);
o.bulkAddAnnotation(a, u, T.REMOTE);
}, v = (a, u) => {
a ? i.setSelected(a, u) : i.clear();
}, U = (a) => {
}, L = (a) => {
i.clear(), i.setUserSelectAction(a);
}, T = (a) => {
}, O = (a) => {
if (t) {

@@ -693,4 +695,4 @@ const u = t.parse(a).parsed, s = t.serialize(o.getAnnotation(u.id));

getAnnotationById: y,
getAnnotations: g,
getSelected: L,
getAnnotations: h,
getSelected: S,
loadAnnotations: r,

@@ -701,8 +703,8 @@ redo: n.redo,

setSelected: v,
setUserSelectAction: U,
setUserSelectAction: L,
undo: n.undo,
updateAnnotation: T
updateAnnotation: O
};
}, fe = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
let pe = (e) => crypto.getRandomValues(new Uint8Array(e)), ge = (e, n, t) => {
let pe = (e) => crypto.getRandomValues(new Uint8Array(e)), he = (e, n, t) => {
let o = (2 << Math.log(e.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * n / e.length);

@@ -717,3 +719,3 @@ return (f = n) => {

};
}, he = (e, n = 21) => ge(e, n, pe), me = (e = 21) => {
}, ge = (e, n = 21) => he(e, n, pe), me = (e = 21) => {
let n = "", t = crypto.getRandomValues(new Uint8Array(e));

@@ -724,3 +726,3 @@ for (; e--; )

};
const ze = () => ({ isGuest: !0, id: he("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Ae = (e) => {
const ze = () => ({ isGuest: !0, id: ge("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Ae = (e) => {
const n = JSON.stringify(e);

@@ -734,3 +736,3 @@ let t = 0;

}, be = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, $e = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {
const { id: o, type: i, purpose: f, value: w, created: b, modified: y, creator: g, ...L } = t;
const { id: o, type: i, purpose: f, value: w, created: b, modified: y, creator: h, ...S } = t;
return {

@@ -742,6 +744,6 @@ id: o || `temp-${Ae(t)}`,

value: w,
creator: be(g),
creator: be(h),
created: b ? new Date(b) : void 0,
updated: y ? new Date(y) : void 0,
...L
...S
};

@@ -811,7 +813,7 @@ }), Ve = (e) => e.map((n) => {

}, w = (r) => {
const E = new Set(r.map((U) => U.presenceKey)), m = r.filter(({ presenceKey: U }) => !t.has(U)), v = Array.from(t.values()).filter((U) => !E.has(U.presenceKey));
m.forEach(({ presenceKey: U, user: T }) => i(U, T)), v.forEach((U) => {
const { presenceKey: T } = U;
o.has(T) && n.emit("selectionChange", U, null), f(T);
}), (m.length > 0 || v.length > 0) && n.emit("presence", g());
const E = new Set(r.map((L) => L.presenceKey)), m = r.filter(({ presenceKey: L }) => !t.has(L)), v = Array.from(t.values()).filter((L) => !E.has(L.presenceKey));
m.forEach(({ presenceKey: L, user: O }) => i(L, O)), v.forEach((L) => {
const { presenceKey: O } = L;
o.has(O) && n.emit("selectionChange", L, null), f(O);
}), (m.length > 0 || v.length > 0) && n.emit("presence", h());
}, b = (r, E) => {

@@ -832,5 +834,5 @@ const m = t.get(r);

E ? o.set(r, E) : o.delete(r), n.emit("selectionChange", m, E);
}, g = () => [...Array.from(t.values())];
}, h = () => [...Array.from(t.values())];
return {
getPresentUsers: g,
getPresentUsers: h,
notifyActivity: b,

@@ -844,3 +846,3 @@ on: (r, E) => n.on(r, E),

de as Ignore,
O as Origin,
T as Origin,
_e as PRESENCE_KEY,

@@ -850,14 +852,14 @@ X as UserSelectAction,

Ne as createBaseAnnotator,
Te as createBody,
Oe as createBody,
ye as createDefaultAppearanceProvider,
Le as createHoverState,
ke as createLifecycleObserver,
Se as createHoverState,
xe as createLifecycleObserver,
Ye as createPresenceState,
Se as createSelectionState,
Ue as createSelectionState,
De as createStore,
Be as createUndoStack,
xe as createViewportState,
Ie as createViewportState,
Ee as defaultColorProvider,
F as diffAnnotations,
Oe as getContributors,
Te as getContributors,
re as mergeChanges,

@@ -868,3 +870,3 @@ q as onUserSelect,

be as parseW3CUser,
Ie as serializeAll,
ke as serializeAll,
Ve as serializeW3CBodies,

@@ -871,0 +873,0 @@ ae as shouldNotify,

@@ -25,3 +25,3 @@ import { Annotation } from '../model';

(event: StoreChangeEvent<T>): void;
}, options?: StoreObserveOptions) => number;
}, options?: StoreObserveOptions) => void;
unobserve: (onChange: {

@@ -28,0 +28,0 @@ (event: StoreChangeEvent<T>): void;

@@ -45,6 +45,13 @@ import { Annotation, AnnotationBody, AnnotationTarget } from '../model/Annotation';

}
/** Allows the observer to listen only for events that originated locally or from a remote source **/
/**
* Allows the observer to listen only for events that originated locally or from a remote source.
*
* SILENT should be used for updates that are not supposed to trigger an event. Remember that
* with great power comes great responsibility: SILENT is really for Annotorious plugins and
* extensions ONLY.
*/
export declare enum Origin {
LOCAL = "LOCAL",
REMOTE = "REMOTE"
REMOTE = "REMOTE",
SILENT = "SILENT"
}

@@ -51,0 +58,0 @@ /** Tests if this observer should be notified about this event **/

{
"name": "@annotorious/core",
"version": "3.0.2",
"version": "3.0.3",
"description": "Annotorious core types and functions",

@@ -36,3 +36,3 @@ "author": "Rainer Simon",

"vite": "^5.4.2",
"vite-plugin-dts": "^4.0.3",
"vite-plugin-dts": "^4.1.0",
"vitest": "^2.0.5"

@@ -39,0 +39,0 @@ },

Sorry, the diff of this file is not supported yet

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