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.0-rc.27 to 3.0.0-rc.28

541

dist/annotorious-core.es.js

@@ -1,2 +0,2 @@

var j = Object.prototype.hasOwnProperty;
var M = Object.prototype.hasOwnProperty;
function B(e, n) {

@@ -20,3 +20,3 @@ var t, o;

for (t in e)
if (j.call(e, t) && ++o && !j.call(n, t) || !(t in n) || !B(e[t], n[t]))
if (M.call(e, t) && ++o && !M.call(n, t) || !(t in n) || !B(e[t], n[t]))
return !1;

@@ -30,15 +30,15 @@ return Object.keys(n).length === o;

}
function q(e, n) {
function H(e, n) {
return e != e ? n == n : e !== n || e && typeof e == "object" || typeof e == "function";
}
const k = [];
function _(e, n = z) {
function Y(e, n = z) {
let t;
const o = /* @__PURE__ */ new Set();
function i(b) {
if (q(e, b) && (e = b, t)) {
const v = !k.length;
if (H(e, b) && (e = b, t)) {
const y = !k.length;
for (const u of o)
u[1](), k.push(u, e);
if (v) {
if (y) {
for (let u = 0; u < k.length; u += 2)

@@ -53,4 +53,4 @@ k[u][0](k[u + 1]);

}
function w(b, v = z) {
const u = [b, v];
function w(b, y = z) {
const u = [b, y];
return o.add(u), o.size === 1 && (t = n(i, p) || z), b(e), () => {

@@ -62,4 +62,4 @@ o.delete(u), o.size === 0 && t && (t(), t = null);

}
const we = (e) => {
const { subscribe: n, set: t } = _();
const Ce = (e) => {
const { subscribe: n, set: t } = Y();
let o;

@@ -80,5 +80,5 @@ return n((i) => o = i), e.observe(({ changes: i }) => {

};
var G = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE = "NONE", e))(G || {});
const V = { selected: [] }, Ce = (e, n = "EDIT") => {
const { subscribe: t, set: o } = _(V);
var F = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE = "NONE", e))(F || {});
const V = { selected: [] }, Le = (e, n = "EDIT") => {
const { subscribe: t, set: o } = Y(V);
let i = V;

@@ -94,12 +94,17 @@ t((s) => i = s);

return i.selected.some((L) => L.id === h);
}, v = (s, h) => {
}, y = (s, h) => {
const L = e.getAnnotation(s);
if (L) {
const E = H(L, n);
o(E === "EDIT" ? { selected: [{ id: s, editable: !0 }], pointerEvent: h } : E === "SELECT" ? { selected: [{ id: s }], pointerEvent: h } : { selected: [], pointerEvent: h });
const v = P(L, n);
o(v === "EDIT" ? { selected: [{ id: s, editable: !0 }], pointerEvent: h } : v === "SELECT" ? { selected: [{ id: s }], pointerEvent: h } : { selected: [], pointerEvent: h });
} else
console.warn("Invalid selection: " + s);
}, u = (s, h = !0) => {
const L = Array.isArray(s) ? s : [s], E = L.map((S) => e.getAnnotation(S)).filter(Boolean);
o({ selected: E.map(({ id: S }) => ({ id: S, editable: h })) }), E.length !== L.length && console.warn("Invalid selection", s);
}, u = (s, h) => {
const L = Array.isArray(s) ? s : [s], v = L.map((S) => e.getAnnotation(S)).filter(Boolean);
o({
selected: v.map((S) => {
const E = h === void 0 ? P(S, n) === "EDIT" : h;
return { id: S.id, editable: E };
})
}), v.length !== L.length && console.warn("Invalid selection", s);
}, U = (s) => {

@@ -109,7 +114,7 @@ if (i.selected.length === 0)

const { selected: h } = i;
h.filter(({ id: E }) => s.includes(E)).length > 0 && o({ selected: h.filter(({ id: E }) => !s.includes(E)) });
h.filter(({ id: v }) => s.includes(v)).length > 0 && o({ selected: h.filter(({ id: v }) => !s.includes(v)) });
};
return e.observe(({ changes: s }) => U((s.deleted || []).map((h) => h.id))), {
clear: p,
clickSelect: v,
clickSelect: y,
get selected() {

@@ -126,27 +131,27 @@ return i ? [...i.selected] : null;

};
}, H = (e, n) => typeof n == "function" ? n(e) || "EDIT" : n || "EDIT";
let $;
const F = new Uint8Array(16);
function J() {
}, P = (e, n) => typeof n == "function" ? n(e) || "EDIT" : n || "EDIT";
var D = [];
for (var _ = 0; _ < 256; ++_)
D.push((_ + 256).toString(16).slice(1));
function J(e, n = 0) {
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();
}
var $, Q = new Uint8Array(16);
function X() {
if (!$ && ($ = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !$))
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
return $(F);
return $(Q);
}
const D = [];
for (let e = 0; e < 256; ++e)
D.push((e + 256).toString(16).slice(1));
function Q(e, n = 0) {
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]];
}
const X = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), M = {
randomUUID: X
var Z = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
const W = {
randomUUID: Z
};
function Z(e, n, t) {
if (M.randomUUID && !n && !e)
return M.randomUUID();
function K(e, n, t) {
if (W.randomUUID && !n && !e)
return W.randomUUID();
e = e || {};
const o = e.random || (e.rng || J)();
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Q(o);
var o = e.random || (e.rng || X)();
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, J(o);
}
const Le = (e) => {
const Ue = (e) => {
const { creator: n, updatedBy: t } = e.target, o = e.bodies.reduce((i, p) => [...i, p.creator, p.updatedBy].filter(Boolean), []);

@@ -158,4 +163,4 @@ return [

].filter((i) => i);
}, Ue = (e, n, t, o) => ({
id: Z(),
}, Se = (e, n, t, o) => ({
id: K(),
annotation: e.id,

@@ -165,13 +170,13 @@ created: t || /* @__PURE__ */ new Date(),

...n
}), K = (e, n) => {
}), ee = (e, n) => {
const t = new Set(e.bodies.map((o) => o.id));
return n.bodies.filter((o) => !t.has(o.id));
}, ee = (e, n) => {
}, te = (e, n) => {
const t = new Set(n.bodies.map((o) => o.id));
return e.bodies.filter((o) => !t.has(o.id));
}, te = (e, n) => n.bodies.map((t) => {
}, ne = (e, n) => n.bodies.map((t) => {
const o = e.bodies.find((i) => i.id === t.id);
return { newBody: t, oldBody: o && !B(o, t) ? o : void 0 };
}).filter(({ oldBody: t }) => t).map(({ oldBody: t, newBody: o }) => ({ oldBody: t, newBody: o })), ne = (e, n) => !B(e.target, n.target), P = (e, n) => {
const t = K(e, n), o = ee(e, n), i = te(e, n);
}).filter(({ oldBody: t }) => t).map(({ oldBody: t, newBody: o }) => ({ oldBody: t, newBody: o })), oe = (e, n) => !B(e.target, n.target), q = (e, n) => {
const t = ee(e, n), o = te(e, n), i = ne(e, n);
return {

@@ -183,7 +188,7 @@ oldValue: e,

bodiesUpdated: i.length > 0 ? i : void 0,
targetUpdated: ne(e, n) ? { oldTarget: e.target, newTarget: n.target } : void 0
targetUpdated: oe(e, n) ? { oldTarget: e.target, newTarget: n.target } : void 0
};
};
var oe = /* @__PURE__ */ ((e) => (e.BODY_ONLY = "BODY_ONLY", e.TARGET_ONLY = "TARGET_ONLY", e))(oe || {}), O = /* @__PURE__ */ ((e) => (e.LOCAL = "LOCAL", e.REMOTE = "REMOTE", e))(O || {});
const se = (e, n) => {
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 || {});
const ie = (e, n) => {
var p, w;

@@ -194,5 +199,5 @@ const { changes: t, origin: o } = n;

if (e.options.ignore) {
const { ignore: b } = e.options, v = (U) => U && U.length > 0;
if (!(v(t.created) || v(t.deleted))) {
const U = (p = t.updated) == null ? void 0 : p.some((h) => v(h.bodiesCreated) || v(h.bodiesDeleted) || v(h.bodiesUpdated)), s = (w = t.updated) == null ? void 0 : w.some((h) => h.targetUpdated);
const { ignore: b } = e.options, y = (U) => U && U.length > 0;
if (!(y(t.created) || y(t.deleted))) {
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);
if (b === "BODY_ONLY" && U && !s || b === "TARGET_ONLY" && s && !U)

@@ -211,4 +216,4 @@ return !1;

return !0;
}, ie = (e, n) => {
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)), v = [
}, de = (e, n) => {
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 = [
...(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),

@@ -223,4 +228,4 @@ ...n.created || []

if (w.has(L.id)) {
const E = n.updated.find((S) => S.oldValue.id === L.id).newValue;
return P(h, E);
const v = n.updated.find((S) => S.oldValue.id === L.id).newValue;
return q(h, v);
} else

@@ -231,14 +236,14 @@ return s;

];
return { created: v, deleted: u, updated: U };
}, de = (e) => e.id !== void 0, Se = () => {
const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (d, r = {}) => t.push({ onChange: d, options: r }), i = (d) => {
const r = t.findIndex((c) => c.onChange == d);
r > -1 && t.splice(r, 1);
}, p = (d, r) => {
return { created: y, deleted: u, updated: U };
}, re = (e) => e.id !== void 0, Oe = () => {
const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (d, a = {}) => t.push({ onChange: d, options: a }), i = (d) => {
const a = t.findIndex((c) => c.onChange == d);
a > -1 && t.splice(a, 1);
}, p = (d, a) => {
const c = {
origin: d,
changes: {
created: r.created || [],
updated: r.updated || [],
deleted: r.deleted || []
created: a.created || [],
updated: a.updated || [],
deleted: a.deleted || []
},

@@ -248,19 +253,19 @@ state: [...e.values()]

t.forEach((f) => {
se(f, c) && f.onChange(c);
ie(f, c) && f.onChange(c);
});
}, w = (d, r = O.LOCAL) => {
}, w = (d, a = O.LOCAL) => {
if (e.get(d.id))
throw Error(`Cannot add annotation ${d.id} - exists already`);
e.set(d.id, d), d.bodies.forEach((f) => n.set(f.id, d.id)), p(r, { created: [d] });
}, b = (d, r) => {
const c = typeof d == "string" ? r : d, f = typeof d == "string" ? d : d.id, C = e.get(f);
e.set(d.id, d), d.bodies.forEach((f) => n.set(f.id, d.id)), p(a, { created: [d] });
}, b = (d, a) => {
const c = typeof d == "string" ? a : d, f = typeof d == "string" ? d : d.id, C = e.get(f);
if (C) {
const T = P(C, c);
const T = q(C, c);
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;
} else
console.warn(`Cannot update annotation ${f} - does not exist`);
}, v = (d, r = O.LOCAL, c = O.LOCAL) => {
const f = de(r) ? c : r, C = b(d, r);
}, y = (d, a = O.LOCAL, c = O.LOCAL) => {
const f = re(a) ? c : a, C = b(d, a);
C && p(f, { updated: [C] });
}, u = (d, r = O.LOCAL) => {
}, u = (d, a = O.LOCAL) => {
const c = d.reduce((f, C) => {

@@ -270,4 +275,4 @@ const T = b(C);

}, []);
c.length > 0 && p(r, { updated: c });
}, U = (d, r = O.LOCAL) => {
c.length > 0 && p(a, { updated: c });
}, U = (d, a = O.LOCAL) => {
const c = e.get(d.annotation);

@@ -279,3 +284,3 @@ if (c) {

};
e.set(c.id, f), n.set(d.id, f.id), p(r, { updated: [{
e.set(c.id, f), n.set(d.id, f.id), p(a, { updated: [{
oldValue: c,

@@ -288,6 +293,6 @@ newValue: f,

}, s = () => [...e.values()], h = (d = O.LOCAL) => {
const r = [...e.values()];
e.clear(), n.clear(), p(d, { deleted: r });
}, L = (d, r = !0, c = O.LOCAL) => {
if (r) {
const a = [...e.values()];
e.clear(), n.clear(), p(d, { deleted: a });
}, L = (d, a = !0, c = O.LOCAL) => {
if (a) {
const f = [...e.values()];

@@ -308,28 +313,28 @@ e.clear(), n.clear(), d.forEach((C) => {

}
}, E = (d) => {
const r = typeof d == "string" ? d : d.id, c = e.get(r);
}, v = (d) => {
const a = typeof d == "string" ? d : d.id, c = e.get(a);
if (c)
return e.delete(r), c.bodies.forEach((f) => n.delete(f.id)), c;
console.warn(`Attempt to delete missing annotation: ${r}`);
}, S = (d, r = O.LOCAL) => {
const c = E(d);
c && p(r, { deleted: [c] });
}, y = (d, r = O.LOCAL) => {
return e.delete(a), c.bodies.forEach((f) => n.delete(f.id)), c;
console.warn(`Attempt to delete missing annotation: ${a}`);
}, S = (d, a = O.LOCAL) => {
const c = v(d);
c && p(a, { deleted: [c] });
}, E = (d, a = O.LOCAL) => {
const c = d.reduce((f, C) => {
const T = E(C);
const T = v(C);
return T ? [...f, T] : f;
}, []);
c.length > 0 && p(r, { deleted: c });
c.length > 0 && p(a, { deleted: c });
}, l = (d) => {
const r = e.get(d.annotation);
if (r) {
const c = r.bodies.find((f) => f.id === d.id);
const a = e.get(d.annotation);
if (a) {
const c = a.bodies.find((f) => f.id === d.id);
if (c) {
n.delete(c.id);
const f = {
...r,
bodies: r.bodies.filter((T) => T.id !== d.id)
...a,
bodies: a.bodies.filter((T) => T.id !== d.id)
};
return e.set(r.id, f), {
oldValue: r,
return e.set(a.id, f), {
oldValue: a,
newValue: f,

@@ -342,15 +347,15 @@ bodiesDeleted: [c]

console.warn(`Attempt to delete body from missing annotation ${d.annotation}`);
}, g = (d, r = O.LOCAL) => {
}, g = (d, a = O.LOCAL) => {
const c = l(d);
c && p(r, { updated: [c] });
}, a = (d, r = O.LOCAL) => {
c && p(a, { updated: [c] });
}, r = (d, a = O.LOCAL) => {
const c = d.map((f) => l(f)).filter(Boolean);
c.length > 0 && p(r, { updated: c });
c.length > 0 && p(a, { updated: c });
}, A = (d) => {
const r = e.get(d);
return r ? { ...r } : void 0;
const a = e.get(d);
return a ? { ...a } : void 0;
}, m = (d) => {
const r = n.get(d);
if (r) {
const f = A(r).bodies.find((C) => C.id === d);
const a = n.get(d);
if (a) {
const f = A(a).bodies.find((C) => C.id === d);
if (f)

@@ -361,4 +366,4 @@ return f;

console.warn(`Attempt to retrieve missing body: ${d}`);
}, R = (d, r) => {
if (d.annotation !== r.annotation)
}, R = (d, a) => {
if (d.annotation !== a.annotation)
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";

@@ -369,32 +374,32 @@ const c = e.get(d.annotation);

...c,
bodies: c.bodies.map((T) => T.id === f.id ? r : T)
bodies: c.bodies.map((T) => T.id === f.id ? a : T)
};
return e.set(c.id, C), f.id !== r.id && (n.delete(f.id), n.set(r.id, C.id)), {
return e.set(c.id, C), f.id !== a.id && (n.delete(f.id), n.set(a.id, C.id)), {
oldValue: c,
newValue: C,
bodiesUpdated: [{ oldBody: f, newBody: r }]
bodiesUpdated: [{ oldBody: f, newBody: a }]
};
} else
console.warn(`Attempt to add body to missing annotation ${d.annotation}`);
}, N = (d, r, c = O.LOCAL) => {
const f = R(d, r);
}, N = (d, a, c = O.LOCAL) => {
const f = R(d, a);
f && p(c, { updated: [f] });
}, x = (d, r = O.LOCAL) => {
}, x = (d, a = O.LOCAL) => {
const c = d.map((f) => R({ id: f.id, annotation: f.annotation }, f)).filter(Boolean);
p(r, { updated: c });
}, Y = (d) => {
const r = e.get(d.annotation);
if (r) {
p(a, { updated: c });
}, j = (d) => {
const a = e.get(d.annotation);
if (a) {
const c = {
...r,
...a,
target: {
...r.target,
...a.target,
...d
}
};
return e.set(r.id, c), {
oldValue: r,
return e.set(a.id, c), {
oldValue: a,
newValue: c,
targetUpdated: {
oldTarget: r.target,
oldTarget: a.target,
newTarget: d

@@ -411,9 +416,9 @@ }

bulkAddAnnotation: L,
bulkDeleteAnnotation: y,
bulkDeleteBodies: a,
bulkDeleteAnnotation: E,
bulkDeleteBodies: r,
bulkUpdateAnnotation: u,
bulkUpdateBodies: x,
bulkUpdateTargets: (d, r = O.LOCAL) => {
const c = d.map((f) => Y(f)).filter(Boolean);
c.length > 0 && p(r, { updated: c });
bulkUpdateTargets: (d, a = O.LOCAL) => {
const c = d.map((f) => j(f)).filter(Boolean);
c.length > 0 && p(a, { updated: c });
},

@@ -427,10 +432,10 @@ clear: h,

unobserve: i,
updateAnnotation: v,
updateAnnotation: y,
updateBody: N,
updateTarget: (d, r = O.LOCAL) => {
const c = Y(d);
c && p(r, { updated: [c] });
updateTarget: (d, a = O.LOCAL) => {
const c = j(d);
c && p(a, { updated: [c] });
}
};
}, Oe = (e) => ({
}, Te = (e) => ({
...e,

@@ -442,3 +447,3 @@ subscribe: (t) => {

});
let W = () => ({
let G = () => ({
emit(e, ...n) {

@@ -457,8 +462,8 @@ for (let t = 0, o = this.events[e] || [], i = o.length; t < i; t++)

});
const ae = 250, Te = (e) => {
const n = W(), t = [];
const ae = 250, De = (e) => {
const n = G(), t = [];
let o = -1, i = !1, p = 0;
const w = (a) => {
const w = (r) => {
if (!i) {
const { changes: A } = a, m = performance.now();
const { changes: A } = r, m = performance.now();
if (m - p > ae)

@@ -468,3 +473,3 @@ t.splice(o + 1), t.push(A), o = t.length - 1;

const R = t.length - 1;
t[R] = ie(t[R], A);
t[R] = de(t[R], A);
}

@@ -476,3 +481,3 @@ p = m;

e.observe(w, { origin: O.LOCAL });
const b = (a) => a && a.length > 0 && e.bulkDeleteAnnotation(a), v = (a) => a && a.length > 0 && e.bulkAddAnnotation(a, !1), u = (a) => a && a.length > 0 && e.bulkUpdateAnnotation(a.map(({ oldValue: A }) => A)), U = (a) => a && a.length > 0 && e.bulkUpdateAnnotation(a.map(({ newValue: A }) => A)), s = (a) => a && a.length > 0 && e.bulkAddAnnotation(a, !1), h = (a) => a && a.length > 0 && e.bulkDeleteAnnotation(a);
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);
return {

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

destroy: () => e.unobserve(w),
on: (a, A) => n.on(a, A),
on: (r, A) => n.on(r, A),
redo: () => {
if (t.length - 1 > o) {
i = !0;
const { created: a, updated: A, deleted: m } = t[o + 1];
v(a), U(A), h(m), n.emit("redo", t[o + 1]), o += 1;
const { created: r, updated: A, deleted: m } = t[o + 1];
y(r), U(A), h(m), n.emit("redo", t[o + 1]), o += 1;
}

@@ -494,9 +499,9 @@ },

i = !0;
const { created: a, updated: A, deleted: m } = t[o];
b(a), u(A), s(m), n.emit("undo", t[o]), o -= 1;
const { created: r, updated: A, deleted: m } = t[o];
b(r), u(A), s(m), n.emit("undo", t[o]), o -= 1;
}
}
};
}, De = () => {
const { subscribe: e, set: n } = _([]);
}, Re = () => {
const { subscribe: e, set: n } = Y([]);
return {

@@ -506,28 +511,28 @@ subscribe: e,

};
}, Re = (e, n, t, o) => {
const { store: i, selection: p, hover: w, viewport: b } = e, v = /* @__PURE__ */ new Map();
}, Be = (e, n, t, o) => {
const { store: i, selection: p, hover: w, viewport: b } = e, y = /* @__PURE__ */ new Map();
let u = [], U, s;
const h = (l, g) => {
v.has(l) ? v.get(l).push(g) : v.set(l, [g]);
y.has(l) ? y.get(l).push(g) : y.set(l, [g]);
}, L = (l, g) => {
const a = v.get(l);
a && a.indexOf(g) > 0 && a.splice(a.indexOf(g), 1);
}, E = (l, g, a) => {
v.has(l) && setTimeout(() => {
v.get(l).forEach((A) => {
const r = y.get(l);
r && r.indexOf(g) > 0 && r.splice(r.indexOf(g), 1);
}, v = (l, g, r) => {
y.has(l) && setTimeout(() => {
y.get(l).forEach((A) => {
if (t) {
const m = Array.isArray(g) ? g.map((N) => t.serialize(N)) : t.serialize(g), R = a ? a instanceof PointerEvent ? a : t.serialize(a) : void 0;
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;
A(m, R);
} else
A(g, a);
A(g, r);
});
}, 1);
}, S = () => {
const { selected: l } = p, g = (l || []).map(({ id: a }) => i.getAnnotation(a));
g.forEach((a) => {
const A = u.find((m) => m.id === a.id);
(!A || !B(A, a)) && E("updateAnnotation", a, A);
}), u = u.map((a) => {
const A = g.find(({ id: m }) => m === a.id);
return A || a;
const { selected: l } = p, g = (l || []).map(({ id: r }) => i.getAnnotation(r));
g.forEach((r) => {
const A = u.find((m) => m.id === r.id);
(!A || !B(A, r)) && v("updateAnnotation", r, A);
}), u = u.map((r) => {
const A = g.find(({ id: m }) => m === r.id);
return A || r;
});

@@ -541,13 +546,13 @@ };

u.forEach((g) => {
const a = i.getAnnotation(g.id);
a && !B(a, g) && E("updateAnnotation", a, g);
const r = i.getAnnotation(g.id);
r && !B(r, g) && v("updateAnnotation", r, g);
}), u = [];
else {
const g = new Set(u.map((m) => m.id)), a = new Set(l.map(({ id: m }) => m));
u.filter((m) => !a.has(m.id)).forEach((m) => {
const g = new Set(u.map((m) => m.id)), r = new Set(l.map(({ id: m }) => m));
u.filter((m) => !r.has(m.id)).forEach((m) => {
const R = i.getAnnotation(m.id);
R && !B(R, m) && E("updateAnnotation", R, m);
R && !B(R, m) && v("updateAnnotation", R, m);
}), u = [
// Remove annotations that were deselected
...u.filter((m) => a.has(m.id)),
...u.filter((m) => r.has(m.id)),
// Add editable annotations that were selected

@@ -557,10 +562,10 @@ ...l.filter(({ id: m }) => !g.has(m)).map(({ id: m }) => i.getAnnotation(m))

}
E("selectionChanged", u);
v("selectionChanged", u);
}
}), w.subscribe((l) => {
!U && l ? E("mouseEnterAnnotation", i.getAnnotation(l)) : U && !l ? E("mouseLeaveAnnotation", i.getAnnotation(U)) : U && l && (E("mouseLeaveAnnotation", i.getAnnotation(U)), E("mouseEnterAnnotation", i.getAnnotation(l))), U = l;
}), b == null || b.subscribe((l) => E("viewportIntersect", l.map((g) => i.getAnnotation(g)))), i.observe((l) => {
!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;
}), b == null || b.subscribe((l) => v("viewportIntersect", l.map((g) => i.getAnnotation(g)))), i.observe((l) => {
o && (s && clearTimeout(s), s = setTimeout(S, 1e3));
const { created: g, deleted: a } = l.changes;
(g || []).forEach((m) => E("createAnnotation", m)), (a || []).forEach((m) => E("deleteAnnotation", m)), (l.changes.updated || []).filter((m) => [
const { created: g, deleted: r } = l.changes;
(g || []).forEach((m) => v("createAnnotation", m)), (r || []).forEach((m) => v("deleteAnnotation", m)), (l.changes.updated || []).filter((m) => [
...m.bodiesCreated || [],

@@ -571,9 +576,9 @@ ...m.bodiesDeleted || [],

const N = u.find((x) => x.id === m.id) || m;
u = u.map((x) => x.id === m.id ? R : x), E("updateAnnotation", R, N);
u = u.map((x) => x.id === m.id ? R : x), v("updateAnnotation", R, N);
});
}, { origin: O.LOCAL }), i.observe((l) => {
if (u) {
const g = new Set(u.map((A) => A.id)), a = (l.changes.updated || []).filter(({ newValue: A }) => g.has(A.id)).map(({ newValue: A }) => A);
a.length > 0 && (u = u.map((A) => {
const m = a.find((R) => R.id === A.id);
const g = new Set(u.map((A) => A.id)), r = (l.changes.updated || []).filter(({ newValue: A }) => g.has(A.id)).map(({ newValue: A }) => A);
r.length > 0 && (u = u.map((A) => {
const m = r.find((R) => R.id === A.id);
return m || A;

@@ -583,8 +588,8 @@ }));

}, { origin: O.REMOTE });
const y = (l) => (g) => {
const { updated: a } = g;
l ? (a || []).forEach((A) => E("updateAnnotation", A.oldValue, A.newValue)) : (a || []).forEach((A) => E("updateAnnotation", A.newValue, A.oldValue));
const E = (l) => (g) => {
const { updated: r } = g;
l ? (r || []).forEach((A) => v("updateAnnotation", A.oldValue, A.newValue)) : (r || []).forEach((A) => v("updateAnnotation", A.newValue, A.oldValue));
};
return n.on("undo", y(!0)), n.on("redo", y(!1)), { on: h, off: L, emit: E };
}, Be = (e) => (n) => n.map((t) => e.serialize(t)), re = (e) => (n) => n.reduce((t, o) => {
return n.on("undo", E(!0)), n.on("redo", E(!1)), { on: h, off: L, emit: v };
}, xe = (e) => (n) => n.map((t) => e.serialize(t)), ce = (e) => (n) => n.reduce((t, o) => {
const { parsed: i, error: p } = e.parse(o);

@@ -600,41 +605,41 @@ return p ? {

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

@@ -648,3 +653,3 @@ };

clearAnnotations: b,
getAnnotationById: v,
getAnnotationById: y,
getAnnotations: u,

@@ -656,8 +661,8 @@ getSelected: U,

setAnnotations: L,
setSelected: E,
setSelected: v,
undo: n.undo,
updateAnnotation: S
};
}, ce = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
let le = (e) => crypto.getRandomValues(new Uint8Array(e)), ue = (e, n, t) => {
}, le = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
let ue = (e) => crypto.getRandomValues(new Uint8Array(e)), fe = (e, n, t) => {
let o = (2 << Math.log(e.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * n / e.length);

@@ -667,15 +672,15 @@ return (p = n) => {

for (; ; ) {
let b = t(i), v = i;
for (; v--; )
if (w += e[b[v] & o] || "", w.length === p)
let b = t(i), y = i;
for (; y--; )
if (w += e[b[y] & o] || "", w.length === p)
return w;
}
};
}, fe = (e, n = 21) => ue(e, n, le), pe = (e = 21) => {
}, pe = (e, n = 21) => fe(e, n, ue), he = (e = 21) => {
let n = "", t = crypto.getRandomValues(new Uint8Array(e));
for (; e--; )
n += ce[t[e] & 63];
n += le[t[e] & 63];
return n;
};
const Ie = () => ({ isGuest: !0, id: fe("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), he = (e) => {
const ke = () => ({ isGuest: !0, id: pe("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), ge = (e) => {
const n = JSON.stringify(e);

@@ -688,6 +693,6 @@ let t = 0;

return `${t}`;
}, ge = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, ke = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {
const { id: o, type: i, purpose: p, value: w, created: b, modified: v, creator: u, ...U } = t;
}, me = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, Ne = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {
const { id: o, type: i, purpose: p, value: w, created: b, modified: y, creator: u, ...U } = t;
return {
id: o || `temp-${he(t)}`,
id: o || `temp-${ge(t)}`,
annotation: n,

@@ -697,8 +702,8 @@ type: i,

value: w,
creator: ge(u),
creator: me(u),
created: b ? new Date(b) : void 0,
updated: v ? new Date(v) : void 0,
updated: y ? new Date(y) : void 0,
...U
};
}), Ne = (e) => e.map((n) => {
}), $e = (e) => e.map((n) => {
var b;

@@ -711,3 +716,3 @@ const { annotation: t, created: o, updated: i, ...p } = n, w = {

return (b = w.id) != null && b.startsWith("temp-") && delete w.id, w;
}), me = [
}), Ae = [
"#ff7c00",

@@ -731,4 +736,4 @@ // orange

// blue
], Ae = () => {
const e = [...me];
], be = () => {
const e = [...Ae];
return { assignRandomColor: () => {

@@ -738,4 +743,4 @@ const o = Math.floor(Math.random() * e.length), i = e[o];

}, releaseColor: (o) => e.push(o) };
}, be = () => {
const e = Ae();
}, ve = () => {
const e = be();
return { addUser: (o, i) => {

@@ -749,4 +754,4 @@ const p = e.assignRandomColor();

}, removeUser: (o) => e.releaseColor(o.appearance.color) };
}, Ee = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)), $e = pe(), ze = (e = be()) => {
const n = W(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = (s, h) => {
}, Ee = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)), ze = he(), Ve = (e = ve()) => {
const n = G(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = (s, h) => {
if (t.has(s)) {

@@ -770,7 +775,7 @@ console.warn("Attempt to add user that is already present", s, h);

}, w = (s) => {
const h = new Set(s.map((S) => S.presenceKey)), L = s.filter(({ presenceKey: S }) => !t.has(S)), E = Array.from(t.values()).filter((S) => !h.has(S.presenceKey));
L.forEach(({ presenceKey: S, user: y }) => i(S, y)), E.forEach((S) => {
const { presenceKey: y } = S;
o.has(y) && n.emit("selectionChange", S, null), p(y);
}), (L.length > 0 || E.length > 0) && n.emit("presence", u());
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));
L.forEach(({ presenceKey: S, user: E }) => i(S, E)), v.forEach((S) => {
const { presenceKey: E } = S;
o.has(E) && n.emit("selectionChange", S, null), p(E);
}), (L.length > 0 || v.length > 0) && n.emit("presence", u());
}, b = (s, h) => {

@@ -782,5 +787,5 @@ const L = t.get(s);

}
const E = o.get(s);
(!E || !Ee(E, h)) && (o.set(s, h), n.emit("selectionChange", L, h));
}, v = (s, h) => {
const v = o.get(s);
(!v || !Ee(v, h)) && (o.set(s, h), n.emit("selectionChange", L, h));
}, y = (s, h) => {
const L = t.get(s);

@@ -798,34 +803,34 @@ if (!L) {

syncUsers: w,
updateSelection: v
updateSelection: y
};
};
export {
oe as Ignore,
se as Ignore,
O as Origin,
$e as PRESENCE_KEY,
G as PointerSelectAction,
Ie as createAnonymousGuest,
xe as createBaseAnnotator,
Ue as createBody,
be as createDefaultAppearenceProvider,
we as createHoverState,
Re as createLifecyleObserver,
ze as createPresenceState,
Ce as createSelectionState,
Se as createStore,
Te as createUndoStack,
De as createViewportState,
Ae as defaultColorProvider,
P as diffAnnotations,
Le as getContributors,
ie as mergeChanges,
H as onPointerSelect,
re as parseAll,
ke as parseW3CBodies,
ge as parseW3CUser,
Be as serializeAll,
Ne as serializeW3CBodies,
se as shouldNotify,
Oe as toSvelteStore
ze as PRESENCE_KEY,
F as PointerSelectAction,
ke as createAnonymousGuest,
Ie as createBaseAnnotator,
Se as createBody,
ve as createDefaultAppearenceProvider,
Ce as createHoverState,
Be as createLifecyleObserver,
Ve as createPresenceState,
Le as createSelectionState,
Oe as createStore,
De as createUndoStack,
Re as createViewportState,
be as defaultColorProvider,
q as diffAnnotations,
Ue as getContributors,
de as mergeChanges,
P as onPointerSelect,
ce as parseAll,
Ne as parseW3CBodies,
me as parseW3CUser,
xe as serializeAll,
$e as serializeW3CBodies,
ie as shouldNotify,
Te as toSvelteStore
};
//# sourceMappingURL=annotorious-core.es.js.map

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

setPresenceProvider?(provider: PresenceProvider): void;
setSelected(arg?: string | string[]): void;
setSelected(arg?: string | string[], editable?: boolean): void;
setStyle(style: DrawingStyleExpression<I> | undefined): void;

@@ -62,3 +62,3 @@ setUser(user: User): void;

setAnnotations: (annotations: E[], replace?: boolean) => void;
setSelected: (arg?: string | string[]) => void;
setSelected: (arg?: string | string[], editable?: boolean) => void;
undo: () => void;

@@ -65,0 +65,0 @@ updateAnnotation: (updated: E) => E;

{
"name": "@annotorious/core",
"version": "3.0.0-rc.27",
"version": "3.0.0-rc.28",
"description": "Annotorious core types and functions",

@@ -28,10 +28,10 @@ "author": "Rainer Simon",

"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"@tsconfig/svelte": "^5.0.4",
"@types/deep-equal": "^1.0.4",
"@types/uuid": "^9.0.8",
"svelte": "^4.2.17",
"svelte": "^4.2.18",
"svelte-preprocess": "^5.1.4",
"typescript": "^5.4.5",
"vite": "^5.2.11",
"vite": "^5.2.13",
"vite-plugin-dts": "^3.9.1",

@@ -44,4 +44,4 @@ "vitest": "^1.6.0"

"nanoid": "^5.0.7",
"uuid": "^9.0.1"
"uuid": "^10.0.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