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.15 to 3.0.16

958

dist/annotorious-core.es.js

@@ -1,62 +0,62 @@

var W = Object.prototype.hasOwnProperty;
function x(e, n) {
var t, o;
if (e === n) return !0;
if (e && n && (t = e.constructor) === n.constructor) {
if (t === Date) return e.getTime() === n.getTime();
if (t === RegExp) return e.toString() === n.toString();
if (t === Array) {
if ((o = e.length) === n.length)
for (; o-- && x(e[o], n[o]); ) ;
var M = Object.prototype.hasOwnProperty;
function k(e, t) {
var n, o;
if (e === t) return !0;
if (e && t && (n = e.constructor) === t.constructor) {
if (n === Date) return e.getTime() === t.getTime();
if (n === RegExp) return e.toString() === t.toString();
if (n === Array) {
if ((o = e.length) === t.length)
for (; o-- && k(e[o], t[o]); ) ;
return o === -1;
}
if (!t || typeof e == "object") {
if (!n || typeof e == "object") {
o = 0;
for (t in e)
if (W.call(e, t) && ++o && !W.call(n, t) || !(t in n) || !x(e[t], n[t])) return !1;
return Object.keys(n).length === o;
for (n in e)
if (M.call(e, n) && ++o && !M.call(t, n) || !(n in t) || !k(e[n], t[n])) return !1;
return Object.keys(t).length === o;
}
}
return e !== e && n !== n;
return e !== e && t !== t;
}
function V() {
}
function X(e, n) {
return e != e ? n == n : e !== n || e && typeof e == "object" || typeof e == "function";
function X(e, t) {
return e != e ? t == t : e !== t || e && typeof e == "object" || typeof e == "function";
}
const I = [];
function j(e, n = V) {
let t;
const N = [];
function j(e, t = V) {
let n;
const o = /* @__PURE__ */ new Set();
function a(v) {
if (X(e, v) && (e = v, t)) {
const w = !I.length;
for (const h of o)
h[1](), I.push(h, e);
function s(b) {
if (X(e, b) && (e = b, n)) {
const w = !N.length;
for (const m of o)
m[1](), N.push(m, e);
if (w) {
for (let h = 0; h < I.length; h += 2)
I[h][0](I[h + 1]);
I.length = 0;
for (let m = 0; m < N.length; m += 2)
N[m][0](N[m + 1]);
N.length = 0;
}
}
}
function p(v) {
a(v(e));
function f(b) {
s(b(e));
}
function A(v, w = V) {
const h = [v, w];
return o.add(h), o.size === 1 && (t = n(a, p) || V), v(e), () => {
o.delete(h), o.size === 0 && t && (t(), t = null);
function A(b, w = V) {
const m = [b, w];
return o.add(m), o.size === 1 && (n = t(s, f) || V), b(e), () => {
o.delete(m), o.size === 0 && n && (n(), n = null);
};
}
return { set: a, update: p, subscribe: A };
return { set: s, update: f, subscribe: A };
}
const Se = (e) => {
const { subscribe: n, set: t } = j();
const Ue = (e) => {
const { subscribe: t, set: n } = j();
let o;
return n((a) => o = a), e.observe(({ changes: a }) => {
return t((s) => o = s), e.observe(({ changes: s }) => {
if (o) {
(a.deleted || []).some((v) => v.id === o) && t(void 0);
const A = (a.updated || []).find(({ oldValue: v }) => v.id === o);
A && t(A.newValue.id);
(s.deleted || []).some((b) => b.id === o) && n(void 0);
const A = (s.updated || []).find(({ oldValue: b }) => b.id === o);
A && n(A.newValue.id);
}

@@ -67,57 +67,57 @@ }), {

},
subscribe: n,
set: t
subscribe: t,
set: n
};
};
var Z = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE = "NONE", e))(Z || {});
const z = { selected: [] }, Ue = (e, n, t) => {
const { subscribe: o, set: a } = j(z);
let p = n, A = z;
o((g) => A = g);
const v = () => {
x(A, z) || a(z);
const z = { selected: [] }, Se = (e, t, n) => {
const { subscribe: o, set: s } = j(z);
let f = t, A = z;
o((h) => A = h);
const b = () => {
k(A, z) || s(z);
}, w = () => {
var g;
return ((g = A.selected) == null ? void 0 : g.length) === 0;
}, h = (g) => {
var h;
return ((h = A.selected) == null ? void 0 : h.length) === 0;
}, m = (h) => {
if (w())
return !1;
const C = typeof g == "string" ? g : g.id;
return A.selected.some((U) => U.id === C);
}, L = (g, C) => {
let U;
if (Array.isArray(g)) {
if (U = g.map((i) => e.getAnnotation(i)).filter(Boolean), U.length < g.length) {
console.warn("Invalid selection: " + g.filter((i) => !U.some((s) => s.id === i)));
const y = typeof h == "string" ? h : h.id;
return A.selected.some((D) => D.id === y);
}, U = (h, y) => {
let D;
if (Array.isArray(h)) {
if (D = h.map((i) => e.getAnnotation(i)).filter(Boolean), D.length < h.length) {
console.warn("Invalid selection: " + h.filter((i) => !D.some((p) => p.id === i)));
return;
}
} else {
const i = e.getAnnotation(g);
const i = e.getAnnotation(h);
if (!i) {
console.warn("Invalid selection: " + g);
console.warn("Invalid selection: " + h);
return;
}
U = [i];
D = [i];
}
const r = U.reduce((i, s) => {
const m = q(s, p, t);
return m === "EDIT" ? [...i, { id: s.id, editable: !0 }] : m === "SELECT" ? [...i, { id: s.id }] : i;
const a = D.reduce((i, p) => {
const v = W(p, f, n);
return v === "EDIT" ? [...i, { id: p.id, editable: !0 }] : v === "SELECT" ? [...i, { id: p.id }] : i;
}, []);
a({ selected: r, event: C });
}, c = (g, C) => {
const U = Array.isArray(g) ? g : [g], r = U.map((i) => e.getAnnotation(i)).filter((i) => !!i);
a({
selected: r.map((i) => {
const s = C === void 0 ? q(i, p, t) === "EDIT" : C;
return { id: i.id, editable: s };
s({ selected: a, event: y });
}, c = (h, y) => {
const D = Array.isArray(h) ? h : [h], a = D.map((i) => e.getAnnotation(i)).filter((i) => !!i);
s({
selected: a.map((i) => {
const p = y === void 0 ? W(i, f, n) === "EDIT" : y;
return { id: i.id, editable: p };
})
}), r.length !== U.length && console.warn("Invalid selection", g);
}, E = (g) => {
}), a.length !== D.length && console.warn("Invalid selection", h);
}, E = (h) => {
if (w())
return !1;
const { selected: C } = A;
C.some(({ id: r }) => g.includes(r)) && a({ selected: C.filter(({ id: r }) => !g.includes(r)) });
}, T = (g) => p = g;
const { selected: y } = A;
y.some(({ id: a }) => h.includes(a)) && s({ selected: y.filter(({ id: a }) => !h.includes(a)) });
}, T = (h) => f = h;
return e.observe(
({ changes: g }) => E((g.deleted || []).map((C) => C.id))
({ changes: h }) => E((h.deleted || []).map((y) => y.id))
), {

@@ -131,20 +131,20 @@ get event() {

get userSelectAction() {
return p;
return f;
},
clear: v,
clear: b,
isEmpty: w,
isSelected: h,
isSelected: m,
setSelected: c,
setUserSelectAction: T,
subscribe: o,
userSelect: L
userSelect: U
};
}, q = (e, n, t) => {
const o = t ? t.serialize(e) : e;
return typeof n == "function" ? n(o) : n || "EDIT";
}, O = [];
}, W = (e, t, n) => {
const o = n ? n.serialize(e) : e;
return typeof t == "function" ? t(o) : t || "EDIT";
}, R = [];
for (let e = 0; e < 256; ++e)
O.push((e + 256).toString(16).slice(1));
function F(e, n = 0) {
return (O[e[n + 0]] + O[e[n + 1]] + O[e[n + 2]] + O[e[n + 3]] + "-" + O[e[n + 4]] + O[e[n + 5]] + "-" + O[e[n + 6]] + O[e[n + 7]] + "-" + O[e[n + 8]] + O[e[n + 9]] + "-" + O[e[n + 10]] + O[e[n + 11]] + O[e[n + 12]] + O[e[n + 13]] + O[e[n + 14]] + O[e[n + 15]]).toLowerCase();
R.push((e + 256).toString(16).slice(1));
function F(e, t = 0) {
return (R[e[t + 0]] + R[e[t + 1]] + R[e[t + 2]] + R[e[t + 3]] + "-" + R[e[t + 4]] + R[e[t + 5]] + "-" + R[e[t + 6]] + R[e[t + 7]] + "-" + R[e[t + 8]] + R[e[t + 9]] + "-" + R[e[t + 10]] + R[e[t + 11]] + R[e[t + 12]] + R[e[t + 13]] + R[e[t + 14]] + R[e[t + 15]]).toLowerCase();
}

@@ -161,6 +161,6 @@ let _;

}
const te = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), G = { randomUUID: te };
function H(e, n, t) {
if (G.randomUUID && !n && !e)
return G.randomUUID();
const te = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), q = { randomUUID: te };
function G(e, t, n) {
if (q.randomUUID && !t && !e)
return q.randomUUID();
e = e || {};

@@ -171,55 +171,55 @@ const o = e.random || (e.rng || ee)();

const Te = (e) => {
const { creator: n, updatedBy: t } = e.target, o = e.bodies.reduce((a, p) => [...a, p.creator, p.updatedBy].filter(Boolean), []);
const { creator: t, updatedBy: n } = e.target, o = e.bodies.reduce((s, f) => [...s, f.creator, f.updatedBy].filter(Boolean), []);
return [
t,
n,
t,
...o
].filter((a) => a);
].filter((s) => s);
}, Y = (e) => {
const n = (t) => {
const o = { ...t };
return t.created && typeof t.created == "string" && (o.created = new Date(t.created)), t.updated && typeof t.updated == "string" && (o.updated = new Date(t.updated)), o;
const t = (n) => {
const o = { ...n };
return n.created && typeof n.created == "string" && (o.created = new Date(n.created)), n.updated && typeof n.updated == "string" && (o.updated = new Date(n.updated)), o;
};
return {
...e,
bodies: (e.bodies || []).map(n),
target: n(e.target)
bodies: (e.bodies || []).map(t),
target: t(e.target)
};
}, De = (e, n, t, o) => ({
id: H(),
}, De = (e, t, n, o) => ({
id: G(),
annotation: typeof e == "string" ? e : e.id,
created: t || /* @__PURE__ */ new Date(),
created: n || /* @__PURE__ */ new Date(),
creator: o,
...n
}), ne = (e, n) => {
const t = new Set(e.bodies.map((o) => o.id));
return n.bodies.filter((o) => !t.has(o.id));
}, oe = (e, n) => {
const t = new Set(n.bodies.map((o) => o.id));
return e.bodies.filter((o) => !t.has(o.id));
}, se = (e, n) => n.bodies.map((t) => {
const o = e.bodies.find((a) => a.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), J = (e, n) => {
const t = ne(e, n), o = oe(e, n), a = se(e, n);
...t
}), ne = (e, t) => {
const n = new Set(e.bodies.map((o) => o.id));
return t.bodies.filter((o) => !n.has(o.id));
}, oe = (e, t) => {
const n = new Set(t.bodies.map((o) => o.id));
return e.bodies.filter((o) => !n.has(o.id));
}, se = (e, t) => t.bodies.map((n) => {
const o = e.bodies.find((s) => s.id === n.id);
return { newBody: n, oldBody: o && !k(o, n) ? o : void 0 };
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), ie = (e, t) => !k(e.target, t.target), J = (e, t) => {
const n = ne(e, t), o = oe(e, t), s = se(e, t);
return {
oldValue: e,
newValue: n,
bodiesCreated: t.length > 0 ? t : void 0,
newValue: t,
bodiesCreated: n.length > 0 ? n : void 0,
bodiesDeleted: o.length > 0 ? o : void 0,
bodiesUpdated: a.length > 0 ? a : void 0,
targetUpdated: ie(e, n) ? { oldTarget: e.target, newTarget: n.target } : void 0
bodiesUpdated: s.length > 0 ? s : void 0,
targetUpdated: ie(e, t) ? { oldTarget: e.target, newTarget: t.target } : void 0
};
};
var de = /* @__PURE__ */ ((e) => (e.BODY_ONLY = "BODY_ONLY", e.TARGET_ONLY = "TARGET_ONLY", e))(de || {}), D = /* @__PURE__ */ ((e) => (e.LOCAL = "LOCAL", e.REMOTE = "REMOTE", e.SILENT = "SILENT", e))(D || {});
const re = (e, n) => {
var p, A;
const { changes: t, origin: o } = n;
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.SILENT = "SILENT", e))(O || {});
const re = (e, t) => {
var f, A;
const { changes: n, origin: o } = t;
if (!(e.options.origin ? e.options.origin === o : o !== "SILENT"))
return !1;
if (e.options.ignore) {
const { ignore: v } = e.options, w = (L) => L && L.length > 0;
if (!(w(t.created) || w(t.deleted))) {
const L = (p = t.updated) == null ? void 0 : p.some((E) => w(E.bodiesCreated) || w(E.bodiesDeleted) || w(E.bodiesUpdated)), c = (A = t.updated) == null ? void 0 : A.some((E) => E.targetUpdated);
if (v === "BODY_ONLY" && L && !c || v === "TARGET_ONLY" && c && !L)
const { ignore: b } = e.options, w = (U) => U && U.length > 0;
if (!(w(n.created) || w(n.deleted))) {
const U = (f = n.updated) == null ? void 0 : f.some((E) => w(E.bodiesCreated) || w(E.bodiesDeleted) || w(E.bodiesUpdated)), c = (A = n.updated) == null ? void 0 : A.some((E) => E.targetUpdated);
if (b === "BODY_ONLY" && U && !c || b === "TARGET_ONLY" && c && !U)
return !1;

@@ -229,50 +229,50 @@ }

if (e.options.annotations) {
const v = /* @__PURE__ */ new Set([
...(t.created || []).map((h) => h.id),
...(t.deleted || []).map((h) => h.id),
...(t.updated || []).map(({ oldValue: h }) => h.id)
const b = /* @__PURE__ */ new Set([
...(n.created || []).map((m) => m.id),
...(n.deleted || []).map((m) => m.id),
...(n.updated || []).map(({ oldValue: m }) => m.id)
]);
return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((h) => v.has(h));
return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((m) => b.has(m));
} else
return !0;
}, ae = (e, n) => {
const t = new Set((e.created || []).map((c) => c.id)), o = new Set((e.updated || []).map(({ newValue: c }) => c.id)), a = new Set((n.created || []).map((c) => c.id)), p = new Set((n.deleted || []).map((c) => c.id)), A = new Set((n.updated || []).map(({ oldValue: c }) => c.id)), v = new Set((n.updated || []).filter(({ oldValue: c }) => t.has(c.id) || o.has(c.id)).map(({ oldValue: c }) => c.id)), w = [
...(e.created || []).filter((c) => !p.has(c.id)).map((c) => A.has(c.id) ? n.updated.find(({ oldValue: E }) => E.id === c.id).newValue : c),
...n.created || []
], h = [
...(e.deleted || []).filter((c) => !a.has(c.id)),
...(n.deleted || []).filter((c) => !t.has(c.id))
], L = [
...(e.updated || []).filter(({ newValue: c }) => !p.has(c.id)).map((c) => {
}, ae = (e, t) => {
const n = new Set((e.created || []).map((c) => c.id)), o = new Set((e.updated || []).map(({ newValue: c }) => c.id)), s = new Set((t.created || []).map((c) => c.id)), f = new Set((t.deleted || []).map((c) => c.id)), A = new Set((t.updated || []).map(({ oldValue: c }) => c.id)), b = new Set((t.updated || []).filter(({ oldValue: c }) => n.has(c.id) || o.has(c.id)).map(({ oldValue: c }) => c.id)), w = [
...(e.created || []).filter((c) => !f.has(c.id)).map((c) => A.has(c.id) ? t.updated.find(({ oldValue: E }) => E.id === c.id).newValue : c),
...t.created || []
], m = [
...(e.deleted || []).filter((c) => !s.has(c.id)),
...(t.deleted || []).filter((c) => !n.has(c.id))
], U = [
...(e.updated || []).filter(({ newValue: c }) => !f.has(c.id)).map((c) => {
const { oldValue: E, newValue: T } = c;
if (A.has(T.id)) {
const g = n.updated.find((C) => C.oldValue.id === T.id).newValue;
return J(E, g);
const h = t.updated.find((y) => y.oldValue.id === T.id).newValue;
return J(E, h);
} else
return c;
}),
...(n.updated || []).filter(({ oldValue: c }) => !v.has(c.id))
...(t.updated || []).filter(({ oldValue: c }) => !b.has(c.id))
];
return { created: w, deleted: h, updated: L };
return { created: w, deleted: m, updated: U };
}, $ = (e) => {
const n = e.id === void 0 ? H() : e.id;
const t = e.id === void 0 ? G() : e.id;
return {
...e,
id: n,
bodies: e.bodies === void 0 ? [] : e.bodies.map((t) => ({
...t,
annotation: n
id: t,
bodies: e.bodies === void 0 ? [] : e.bodies.map((n) => ({
...n,
annotation: t
})),
target: {
...e.target,
annotation: n
annotation: t
}
};
}, ce = (e) => e.id !== void 0, Oe = () => {
const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (d, l = {}) => {
t.push({ onChange: d, options: l });
}, a = (d) => {
const l = t.findIndex((u) => u.onChange == d);
l > -1 && t.splice(l, 1);
}, p = (d, l) => {
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = [], o = (d, l = {}) => {
n.push({ onChange: d, options: l });
}, s = (d) => {
const l = n.findIndex((u) => u.onChange == d);
l > -1 && n.splice(l, 1);
}, f = (d, l) => {
const u = {

@@ -287,38 +287,38 @@ origin: d,

};
t.forEach((f) => {
re(f, u) && f.onChange(u);
n.forEach((g) => {
re(g, u) && g.onChange(u);
});
}, A = (d, l = D.LOCAL) => {
}, A = (d, l = O.LOCAL) => {
if (d.id && e.get(d.id))
throw Error(`Cannot add annotation ${d.id} - exists already`);
{
const f = $(d);
e.set(f.id, f), f.bodies.forEach((S) => n.set(S.id, f.id)), p(l, { created: [f] });
const g = $(d);
e.set(g.id, g), g.bodies.forEach((S) => t.set(S.id, g.id)), f(l, { created: [g] });
}
}, v = (d, l) => {
const u = $(typeof d == "string" ? l : d), f = typeof d == "string" ? d : d.id, S = f && e.get(f);
}, b = (d, l) => {
const u = $(typeof d == "string" ? l : d), g = typeof d == "string" ? d : d.id, S = g && e.get(g);
if (S) {
const y = J(S, u);
return f === u.id ? e.set(f, u) : (e.delete(f), e.set(u.id, u)), S.bodies.forEach((B) => n.delete(B.id)), u.bodies.forEach((B) => n.set(B.id, u.id)), y;
const C = J(S, u);
return g === u.id ? e.set(g, u) : (e.delete(g), e.set(u.id, u)), S.bodies.forEach((x) => t.delete(x.id)), u.bodies.forEach((x) => t.set(x.id, u.id)), C;
} else
console.warn(`Cannot update annotation ${f} - does not exist`);
}, w = (d, l = D.LOCAL, u = D.LOCAL) => {
const f = ce(l) ? u : l, S = v(d, l);
S && p(f, { updated: [S] });
}, h = (d, l = D.LOCAL) => {
const u = d.reduce((f, S) => {
const y = v(S);
return y ? [...f, y] : f;
console.warn(`Cannot update annotation ${g} - does not exist`);
}, w = (d, l = O.LOCAL, u = O.LOCAL) => {
const g = ce(l) ? u : l, S = b(d, l);
S && f(g, { updated: [S] });
}, m = (d, l = O.LOCAL) => {
const u = d.reduce((g, S) => {
const C = b(S);
return C ? [...g, C] : g;
}, []);
u.length > 0 && p(l, { updated: u });
}, L = (d, l = D.LOCAL) => {
u.length > 0 && f(l, { updated: u });
}, U = (d, l = O.LOCAL) => {
const u = e.get(d.annotation);
if (u) {
const f = {
const g = {
...u,
bodies: [...u.bodies, d]
};
e.set(u.id, f), n.set(d.id, f.id), p(l, { updated: [{
e.set(u.id, g), t.set(d.id, g.id), f(l, { updated: [{
oldValue: u,
newValue: f,
newValue: g,
bodiesCreated: [d]

@@ -328,50 +328,50 @@ }] });

console.warn(`Attempt to add body to missing annotation: ${d.annotation}`);
}, c = () => [...e.values()], E = (d = D.LOCAL) => {
}, c = () => [...e.values()], E = (d = O.LOCAL) => {
const l = [...e.values()];
e.clear(), n.clear(), p(d, { deleted: l });
}, T = (d, l = !0, u = D.LOCAL) => {
const f = d.map($);
e.clear(), t.clear(), f(d, { deleted: l });
}, T = (d, l = !0, u = O.LOCAL) => {
const g = d.map($);
if (l) {
const S = [...e.values()];
e.clear(), n.clear(), f.forEach((y) => {
e.set(y.id, y), y.bodies.forEach((B) => n.set(B.id, y.id));
}), p(u, { created: f, deleted: S });
e.clear(), t.clear(), g.forEach((C) => {
e.set(C.id, C), C.bodies.forEach((x) => t.set(x.id, C.id));
}), f(u, { created: g, deleted: S });
} else {
const S = d.reduce((y, B) => {
const M = B.id && e.get(B.id);
return M ? [...y, M] : y;
const S = d.reduce((C, x) => {
const H = x.id && e.get(x.id);
return H ? [...C, H] : C;
}, []);
if (S.length > 0)
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(u, { created: f });
throw Error(`Bulk insert would overwrite the following annotations: ${S.map((C) => C.id).join(", ")}`);
g.forEach((C) => {
e.set(C.id, C), C.bodies.forEach((x) => t.set(x.id, C.id));
}), f(u, { created: g });
}
}, g = (d) => {
}, h = (d) => {
const l = typeof d == "string" ? d : d.id, u = e.get(l);
if (u)
return e.delete(l), u.bodies.forEach((f) => n.delete(f.id)), u;
return e.delete(l), u.bodies.forEach((g) => t.delete(g.id)), u;
console.warn(`Attempt to delete missing annotation: ${l}`);
}, C = (d, l = D.LOCAL) => {
const u = g(d);
u && p(l, { deleted: [u] });
}, U = (d, l = D.LOCAL) => {
const u = d.reduce((f, S) => {
const y = g(S);
return y ? [...f, y] : f;
}, y = (d, l = O.LOCAL) => {
const u = h(d);
u && f(l, { deleted: [u] });
}, D = (d, l = O.LOCAL) => {
const u = d.reduce((g, S) => {
const C = h(S);
return C ? [...g, C] : g;
}, []);
u.length > 0 && p(l, { deleted: u });
}, r = (d) => {
u.length > 0 && f(l, { deleted: u });
}, a = (d) => {
const l = e.get(d.annotation);
if (l) {
const u = l.bodies.find((f) => f.id === d.id);
const u = l.bodies.find((g) => g.id === d.id);
if (u) {
n.delete(u.id);
const f = {
t.delete(u.id);
const g = {
...l,
bodies: l.bodies.filter((y) => y.id !== d.id)
bodies: l.bodies.filter((C) => C.id !== d.id)
};
return e.set(l.id, f), {
return e.set(l.id, g), {
oldValue: l,
newValue: f,
newValue: g,
bodiesDeleted: [u]

@@ -383,21 +383,21 @@ };

console.warn(`Attempt to delete body from missing annotation ${d.annotation}`);
}, i = (d, l = D.LOCAL) => {
const u = r(d);
u && p(l, { updated: [u] });
}, s = (d, l = D.LOCAL) => {
const u = d.map((f) => r(f)).filter(Boolean);
u.length > 0 && p(l, { updated: u });
}, m = (d) => {
}, i = (d, l = O.LOCAL) => {
const u = a(d);
u && f(l, { updated: [u] });
}, p = (d, l = O.LOCAL) => {
const u = d.map((g) => a(g)).filter(Boolean);
u.length > 0 && f(l, { updated: u });
}, v = (d) => {
const l = e.get(d);
return l ? { ...l } : void 0;
}, b = (d) => {
const l = n.get(d);
}, r = (d) => {
const l = t.get(d);
if (l) {
const f = m(l).bodies.find((S) => S.id === d);
if (f)
return f;
const g = v(l).bodies.find((S) => S.id === d);
if (g)
return g;
console.error(`Store integrity error: body ${d} in index, but not in annotation`);
} else
console.warn(`Attempt to retrieve missing body: ${d}`);
}, R = (d, l) => {
}, L = (d, l) => {
if (d.annotation !== l.annotation)

@@ -407,19 +407,19 @@ throw "Annotation integrity violation: annotation ID must be the same when updating bodies";

if (u) {
const f = u.bodies.find((y) => y.id === d.id), S = {
const g = u.bodies.find((C) => C.id === d.id), S = {
...u,
bodies: u.bodies.map((y) => y.id === f.id ? l : y)
bodies: u.bodies.map((C) => C.id === g.id ? l : C)
};
return e.set(u.id, S), f.id !== l.id && (n.delete(f.id), n.set(l.id, S.id)), {
return e.set(u.id, S), g.id !== l.id && (t.delete(g.id), t.set(l.id, S.id)), {
oldValue: u,
newValue: S,
bodiesUpdated: [{ oldBody: f, newBody: l }]
bodiesUpdated: [{ oldBody: g, newBody: l }]
};
} else
console.warn(`Attempt to add body to missing annotation ${d.annotation}`);
}, N = (d, l, u = D.LOCAL) => {
const f = R(d, l);
f && p(u, { updated: [f] });
}, k = (d, l = D.LOCAL) => {
const u = d.map((f) => R({ id: f.id, annotation: f.annotation }, f)).filter(Boolean);
p(l, { updated: u });
}, B = (d, l, u = O.LOCAL) => {
const g = L(d, l);
g && f(u, { updated: [g] });
}, I = (d, l = O.LOCAL) => {
const u = d.map((g) => L({ id: g.id, annotation: g.annotation }, g)).filter(Boolean);
f(l, { updated: u });
}, P = (d) => {

@@ -448,25 +448,25 @@ const l = e.get(d.annotation);

addAnnotation: A,
addBody: L,
addBody: U,
all: c,
bulkAddAnnotation: T,
bulkDeleteAnnotation: U,
bulkDeleteBodies: s,
bulkUpdateAnnotation: h,
bulkUpdateBodies: k,
bulkUpdateTargets: (d, l = D.LOCAL) => {
const u = d.map((f) => P(f)).filter(Boolean);
u.length > 0 && p(l, { updated: u });
bulkDeleteAnnotation: D,
bulkDeleteBodies: p,
bulkUpdateAnnotation: m,
bulkUpdateBodies: I,
bulkUpdateTargets: (d, l = O.LOCAL) => {
const u = d.map((g) => P(g)).filter(Boolean);
u.length > 0 && f(l, { updated: u });
},
clear: E,
deleteAnnotation: C,
deleteAnnotation: y,
deleteBody: i,
getAnnotation: m,
getBody: b,
getAnnotation: v,
getBody: r,
observe: o,
unobserve: a,
unobserve: s,
updateAnnotation: w,
updateBody: N,
updateTarget: (d, l = D.LOCAL) => {
updateBody: B,
updateTarget: (d, l = O.LOCAL) => {
const u = P(d);
u && p(l, { updated: [u] });
u && f(l, { updated: [u] });
}

@@ -476,56 +476,57 @@ };

...e,
subscribe: (t) => {
const o = (a) => t(a.state);
return e.observe(o), t(e.all()), () => e.unobserve(o);
subscribe: (n) => {
const o = (s) => n(s.state);
return e.observe(o), n(e.all()), () => e.unobserve(o);
}
});
let Q = () => ({
emit(e, ...n) {
for (let t = this.events[e] || [], o = 0, a = t.length; o < a; o++)
t[o](...n);
emit(e, ...t) {
for (let n = this.events[e] || [], o = 0, s = n.length; o < s; o++)
n[o](...t);
},
events: {},
on(e, n) {
var t;
return ((t = this.events)[e] || (t[e] = [])).push(n), () => {
on(e, t) {
var n;
return ((n = this.events)[e] || (n[e] = [])).push(t), () => {
var o;
this.events[e] = (o = this.events[e]) == null ? void 0 : o.filter((a) => n !== a);
this.events[e] = (o = this.events[e]) == null ? void 0 : o.filter((s) => t !== s);
};
}
});
const le = 250, Be = (e) => {
const n = Q(), t = [];
let o = -1, a = !1, p = 0;
const A = (s) => {
if (!a) {
const { changes: m } = s, b = performance.now();
if (b - p > le)
t.splice(o + 1), t.push(m), o = t.length - 1;
const le = 250, Be = (e, t) => {
const n = Q(), o = t || [];
let s = -1, f = !1, A = 0;
const b = (r) => {
if (!f) {
const { changes: L } = r, B = performance.now();
if (B - A > le)
o.splice(s + 1), o.push(L), s = o.length - 1;
else {
const R = t.length - 1;
t[R] = ae(t[R], m);
const I = o.length - 1;
o[I] = ae(o[I], L);
}
p = b;
A = B;
}
a = !1;
f = !1;
};
e.observe(A, { origin: D.LOCAL });
const v = (s) => s && s.length > 0 && e.bulkDeleteAnnotation(s), w = (s) => s && s.length > 0 && e.bulkAddAnnotation(s, !1), h = (s) => s && s.length > 0 && e.bulkUpdateAnnotation(s.map(({ oldValue: m }) => m)), L = (s) => s && s.length > 0 && e.bulkUpdateAnnotation(s.map(({ newValue: m }) => m)), c = (s) => s && s.length > 0 && e.bulkAddAnnotation(s, !1), E = (s) => s && s.length > 0 && e.bulkDeleteAnnotation(s);
e.observe(b, { origin: O.LOCAL });
const w = (r) => r && r.length > 0 && e.bulkDeleteAnnotation(r), m = (r) => r && r.length > 0 && e.bulkAddAnnotation(r, !1), U = (r) => r && r.length > 0 && e.bulkUpdateAnnotation(r.map(({ oldValue: L }) => L)), c = (r) => r && r.length > 0 && e.bulkUpdateAnnotation(r.map(({ newValue: L }) => L)), E = (r) => r && r.length > 0 && e.bulkAddAnnotation(r, !1), T = (r) => r && r.length > 0 && e.bulkDeleteAnnotation(r);
return {
canRedo: () => t.length - 1 > o,
canUndo: () => o > -1,
destroy: () => e.unobserve(A),
on: (s, m) => n.on(s, m),
canRedo: () => o.length - 1 > s,
canUndo: () => s > -1,
destroy: () => e.unobserve(b),
getHistory: () => [...o],
on: (r, L) => n.on(r, L),
redo: () => {
if (t.length - 1 > o) {
a = !0;
const { created: s, updated: m, deleted: b } = t[o + 1];
w(s), L(m), E(b), n.emit("redo", t[o + 1]), o += 1;
if (o.length - 1 > s) {
f = !0;
const { created: r, updated: L, deleted: B } = o[s + 1];
m(r), c(L), T(B), n.emit("redo", o[s + 1]), s += 1;
}
},
undo: () => {
if (o > -1) {
a = !0;
const { created: s, updated: m, deleted: b } = t[o];
v(s), h(m), c(b), n.emit("undo", t[o]), o -= 1;
if (s > -1) {
f = !0;
const { created: r, updated: L, deleted: B } = o[s];
w(r), U(L), E(B), n.emit("undo", o[s]), s -= 1;
}

@@ -535,215 +536,216 @@ }

}, xe = () => {
const { subscribe: e, set: n } = j([]);
const { subscribe: e, set: t } = j([]);
return {
subscribe: e,
set: n
set: t
};
}, ke = (e, n, t, o) => {
const { hover: a, selection: p, store: A, viewport: v } = e, w = /* @__PURE__ */ new Map();
let h = [], L, c;
const E = (r, i) => {
w.has(r) ? w.get(r).push(i) : w.set(r, [i]);
}, T = (r, i) => {
const s = w.get(r);
if (s) {
const m = s.indexOf(i);
m !== -1 && s.splice(m, 1);
}, Ie = (e, t, n, o) => {
const { hover: s, selection: f, store: A, viewport: b } = e, w = /* @__PURE__ */ new Map();
let m = [], U, c;
const E = (a, i) => {
w.has(a) ? w.get(a).push(i) : w.set(a, [i]);
}, T = (a, i) => {
const p = w.get(a);
if (p) {
const v = p.indexOf(i);
v !== -1 && p.splice(v, 1);
}
}, g = (r, i, s) => {
w.has(r) && setTimeout(() => {
w.get(r).forEach((m) => {
if (t) {
const b = Array.isArray(i) ? i.map((N) => t.serialize(N)) : t.serialize(i), R = s ? s instanceof PointerEvent ? s : t.serialize(s) : void 0;
m(b, R);
}, h = (a, i, p) => {
w.has(a) && setTimeout(() => {
w.get(a).forEach((v) => {
if (n) {
const r = Array.isArray(i) ? i.map((B) => n.serialize(B)) : n.serialize(i), L = p ? p instanceof PointerEvent ? p : n.serialize(p) : void 0;
v(r, L);
} else
m(i, s);
v(i, p);
});
}, 1);
}, C = () => {
const { selected: r } = p, i = (r || []).map(({ id: s }) => A.getAnnotation(s));
i.forEach((s) => {
const m = h.find((b) => b.id === s.id);
(!m || !x(m, s)) && g("updateAnnotation", s, m);
}), h = h.map((s) => {
const m = i.find(({ id: b }) => b === s.id);
return m || s;
}, y = () => {
const { selected: a } = f, i = (a || []).map(({ id: p }) => A.getAnnotation(p));
i.forEach((p) => {
const v = m.find((r) => r.id === p.id);
(!v || !k(v, p)) && h("updateAnnotation", p, v);
}), m = m.map((p) => {
const v = i.find(({ id: r }) => r === p.id);
return v || p;
});
};
p.subscribe(({ selected: r }) => {
if (!(h.length === 0 && r.length === 0)) {
if (h.length === 0 && r.length > 0)
h = r.map(({ id: i }) => A.getAnnotation(i));
else if (h.length > 0 && r.length === 0)
h.forEach((i) => {
const s = A.getAnnotation(i.id);
s && !x(s, i) && g("updateAnnotation", s, i);
}), h = [];
f.subscribe(({ selected: a }) => {
if (!(m.length === 0 && a.length === 0)) {
if (m.length === 0 && a.length > 0)
m = a.map(({ id: i }) => A.getAnnotation(i));
else if (m.length > 0 && a.length === 0)
m.forEach((i) => {
const p = A.getAnnotation(i.id);
p && !k(p, i) && h("updateAnnotation", p, i);
}), m = [];
else {
const i = new Set(h.map((b) => b.id)), s = new Set(r.map(({ id: b }) => b));
h.filter((b) => !s.has(b.id)).forEach((b) => {
const R = A.getAnnotation(b.id);
R && !x(R, b) && g("updateAnnotation", R, b);
}), h = [
const i = new Set(m.map((r) => r.id)), p = new Set(a.map(({ id: r }) => r));
m.filter((r) => !p.has(r.id)).forEach((r) => {
const L = A.getAnnotation(r.id);
L && !k(L, r) && h("updateAnnotation", L, r);
}), m = [
// Remove annotations that were deselected
...h.filter((b) => s.has(b.id)),
...m.filter((r) => p.has(r.id)),
// Add editable annotations that were selected
...r.filter(({ id: b }) => !i.has(b)).map(({ id: b }) => A.getAnnotation(b))
...a.filter(({ id: r }) => !i.has(r)).map(({ id: r }) => A.getAnnotation(r))
];
}
g("selectionChanged", h);
h("selectionChanged", m);
}
}), a.subscribe((r) => {
!L && r ? g("mouseEnterAnnotation", A.getAnnotation(r)) : L && !r ? g("mouseLeaveAnnotation", A.getAnnotation(L)) : L && r && (g("mouseLeaveAnnotation", A.getAnnotation(L)), g("mouseEnterAnnotation", A.getAnnotation(r))), L = r;
}), v == null || v.subscribe((r) => g("viewportIntersect", r.map((i) => A.getAnnotation(i)))), A.observe((r) => {
o && (c && clearTimeout(c), c = setTimeout(C, 1e3));
const { created: i, deleted: s } = r.changes;
(i || []).forEach((b) => g("createAnnotation", b)), (s || []).forEach((b) => g("deleteAnnotation", b)), (r.changes.updated || []).filter((b) => [
...b.bodiesCreated || [],
...b.bodiesDeleted || [],
...b.bodiesUpdated || []
].length > 0).forEach(({ oldValue: b, newValue: R }) => {
const N = h.find((k) => k.id === b.id) || b;
h = h.map((k) => k.id === b.id ? R : k), g("updateAnnotation", R, N);
}), s.subscribe((a) => {
!U && a ? h("mouseEnterAnnotation", A.getAnnotation(a)) : U && !a ? h("mouseLeaveAnnotation", A.getAnnotation(U)) : U && a && (h("mouseLeaveAnnotation", A.getAnnotation(U)), h("mouseEnterAnnotation", A.getAnnotation(a))), U = a;
}), b == null || b.subscribe((a) => h("viewportIntersect", a.map((i) => A.getAnnotation(i)))), A.observe((a) => {
o && (c && clearTimeout(c), c = setTimeout(y, 1e3));
const { created: i, deleted: p } = a.changes;
(i || []).forEach((r) => h("createAnnotation", r)), (p || []).forEach((r) => h("deleteAnnotation", r)), (a.changes.updated || []).filter((r) => [
...r.bodiesCreated || [],
...r.bodiesDeleted || [],
...r.bodiesUpdated || []
].length > 0).forEach(({ oldValue: r, newValue: L }) => {
const B = m.find((I) => I.id === r.id) || r;
m = m.map((I) => I.id === r.id ? L : I), h("updateAnnotation", L, B);
});
}, { origin: D.LOCAL }), A.observe((r) => {
if (h) {
const i = new Set(h.map((m) => m.id)), s = (r.changes.updated || []).filter(({ newValue: m }) => i.has(m.id)).map(({ newValue: m }) => m);
s.length > 0 && (h = h.map((m) => {
const b = s.find((R) => R.id === m.id);
return b || m;
}, { origin: O.LOCAL }), A.observe((a) => {
if (m) {
const i = new Set(m.map((v) => v.id)), p = (a.changes.updated || []).filter(({ newValue: v }) => i.has(v.id)).map(({ newValue: v }) => v);
p.length > 0 && (m = m.map((v) => {
const r = p.find((L) => L.id === v.id);
return r || v;
}));
}
}, { origin: D.REMOTE });
const U = (r) => (i) => {
const { updated: s } = i;
r ? (s || []).forEach((m) => g("updateAnnotation", m.oldValue, m.newValue)) : (s || []).forEach((m) => g("updateAnnotation", m.newValue, m.oldValue));
}, { origin: O.REMOTE });
const D = (a) => (i) => {
const { updated: p } = i;
a ? (p || []).forEach((v) => h("updateAnnotation", v.oldValue, v.newValue)) : (p || []).forEach((v) => h("updateAnnotation", v.newValue, v.oldValue));
};
return n.on("undo", U(!0)), n.on("redo", U(!1)), { on: E, off: T, emit: g };
}, Ie = (e) => (n) => n.map((t) => e.serialize(t)), ue = (e) => (n) => n.reduce((t, o) => {
const { parsed: a, error: p } = e.parse(o);
return p ? {
parsed: t.parsed,
failed: [...t.failed, o]
} : a ? {
parsed: [...t.parsed, a],
failed: t.failed
return t.on("undo", D(!0)), t.on("redo", D(!1)), { on: E, off: T, emit: h };
}, ke = (e) => (t) => t.map((n) => e.serialize(n)), ue = (e) => (t) => t.reduce((n, o) => {
const { parsed: s, error: f } = e.parse(o);
return f ? {
parsed: n.parsed,
failed: [...n.failed, o]
} : s ? {
parsed: [...n.parsed, s],
failed: n.failed
} : {
...t
...n
};
}, { parsed: [], failed: [] }), Ne = (e, n, t) => {
const { store: o, selection: a } = e, p = (r) => {
if (t) {
const { parsed: i, error: s } = t.parse(r);
i ? o.addAnnotation(i, D.REMOTE) : console.error(s);
}, { parsed: [], failed: [] }), Ne = (e, t, n) => {
const { store: o, selection: s } = e, f = (a) => {
if (n) {
const { parsed: i, error: p } = n.parse(a);
i ? o.addAnnotation(i, O.REMOTE) : console.error(p);
} else
o.addAnnotation(Y(r), D.REMOTE);
}, A = () => a.clear(), v = () => o.clear(), w = (r) => {
const i = o.getAnnotation(r);
return t && i ? t.serialize(i) : i;
}, h = () => t ? o.all().map(t.serialize) : o.all(), L = () => {
var s;
const i = (((s = a.selected) == null ? void 0 : s.map((m) => m.id)) || []).map((m) => o.getAnnotation(m)).filter(Boolean);
return t ? i.map(t.serialize) : i;
}, c = (r, i = !0) => fetch(r).then((s) => s.json()).then((s) => (T(s, i), s)), E = (r) => {
if (typeof r == "string") {
const i = o.getAnnotation(r);
if (o.deleteAnnotation(r), i)
return t ? t.serialize(i) : i;
o.addAnnotation(Y(a), O.REMOTE);
}, A = () => s.clear(), b = () => o.clear(), w = (a) => {
const i = o.getAnnotation(a);
return n && i ? n.serialize(i) : i;
}, m = () => n ? o.all().map(n.serialize) : o.all(), U = () => {
var p;
const i = (((p = s.selected) == null ? void 0 : p.map((v) => v.id)) || []).map((v) => o.getAnnotation(v)).filter(Boolean);
return n ? i.map(n.serialize) : i;
}, c = (a, i = !0) => fetch(a).then((p) => p.json()).then((p) => (T(p, i), p)), E = (a) => {
if (typeof a == "string") {
const i = o.getAnnotation(a);
if (o.deleteAnnotation(a), i)
return n ? n.serialize(i) : i;
} else {
const i = t ? t.parse(r).parsed : r;
const i = n ? n.parse(a).parsed : a;
if (i)
return o.deleteAnnotation(i), r;
return o.deleteAnnotation(i), a;
}
}, T = (r, i = !0) => {
if (t) {
const s = t.parseAll || ue(t), { parsed: m, failed: b } = s(r);
b.length > 0 && console.warn(`Discarded ${b.length} invalid annotations`, b), o.bulkAddAnnotation(m, i, D.REMOTE);
}, T = (a, i = !0) => {
if (n) {
const p = n.parseAll || ue(n), { parsed: v, failed: r } = p(a);
r.length > 0 && console.warn(`Discarded ${r.length} invalid annotations`, r), o.bulkAddAnnotation(v, i, O.REMOTE);
} else
o.bulkAddAnnotation(r.map(Y), i, D.REMOTE);
}, g = (r, i) => {
r ? a.setSelected(r, i) : a.clear();
}, C = (r) => {
a.clear(), a.setUserSelectAction(r);
}, U = (r) => {
if (t) {
const i = t.parse(r).parsed, s = t.serialize(o.getAnnotation(i.id));
return o.updateAnnotation(i), s;
o.bulkAddAnnotation(a.map(Y), i, O.REMOTE);
}, h = (a, i) => {
a ? s.setSelected(a, i) : s.clear();
}, y = (a) => {
s.clear(), s.setUserSelectAction(a);
}, D = (a) => {
if (n) {
const i = n.parse(a).parsed, p = n.serialize(o.getAnnotation(i.id));
return o.updateAnnotation(i), p;
} else {
const i = o.getAnnotation(r.id);
return o.updateAnnotation(Y(r)), i;
const i = o.getAnnotation(a.id);
return o.updateAnnotation(Y(a)), i;
}
};
return {
addAnnotation: p,
addAnnotation: f,
cancelSelected: A,
canRedo: n.canRedo,
canUndo: n.canUndo,
clearAnnotations: v,
canRedo: t.canRedo,
canUndo: t.canUndo,
clearAnnotations: b,
getAnnotationById: w,
getAnnotations: h,
getSelected: L,
getAnnotations: m,
getHistory: t.getHistory,
getSelected: U,
loadAnnotations: c,
redo: n.redo,
redo: t.redo,
removeAnnotation: E,
setAnnotations: T,
setSelected: g,
setUserSelectAction: C,
undo: n.undo,
updateAnnotation: U
setSelected: h,
setUserSelectAction: y,
undo: t.undo,
updateAnnotation: D
};
}, ze = (e, n, t) => typeof n == "function" ? n(e, t) : n, $e = (e, n) => typeof e != "function" && typeof n != "function" ? {
}, ze = (e, t, n) => typeof t == "function" ? t(e, n) : t, $e = (e, t) => typeof e != "function" && typeof t != "function" ? {
...e || {},
...n || {}
} : (t, o) => {
const a = typeof e == "function" ? e(t, o) : e, p = typeof n == "function" ? n(t, o) : n;
...t || {}
} : (n, o) => {
const s = typeof e == "function" ? e(n, o) : e, f = typeof t == "function" ? t(n, o) : t;
return {
...a || {},
...p || {}
...s || {},
...f || {}
};
}, fe = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
let pe = (e) => crypto.getRandomValues(new Uint8Array(e)), ge = (e, n, t) => {
let o = (2 << Math.log2(e.length - 1)) - 1, a = -~(1.6 * o * n / e.length);
return (p = n) => {
let pe = (e) => crypto.getRandomValues(new Uint8Array(e)), ge = (e, t, n) => {
let o = (2 << Math.log2(e.length - 1)) - 1, s = -~(1.6 * o * t / e.length);
return (f = t) => {
let A = "";
for (; ; ) {
let v = t(a), w = a | 0;
let b = n(s), w = s | 0;
for (; w--; )
if (A += e[v[w] & o] || "", A.length >= p) return A;
if (A += e[b[w] & o] || "", A.length >= f) return A;
}
};
}, he = (e, n = 21) => ge(e, n | 0, pe), me = (e = 21) => {
let n = "", t = crypto.getRandomValues(new Uint8Array(e |= 0));
}, he = (e, t = 21) => ge(e, t | 0, pe), me = (e = 21) => {
let t = "", n = crypto.getRandomValues(new Uint8Array(e |= 0));
for (; e--; )
n += fe[t[e] & 63];
return n;
t += fe[n[e] & 63];
return t;
};
const Ve = () => ({ isGuest: !0, id: he("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Ae = (e) => {
const n = JSON.stringify(e);
let t = 0;
for (let o = 0, a = n.length; o < a; o++) {
let p = n.charCodeAt(o);
t = (t << 5) - t + p, t |= 0;
const t = JSON.stringify(e);
let n = 0;
for (let o = 0, s = t.length; o < s; o++) {
let f = t.charCodeAt(o);
n = (n << 5) - n + f, n |= 0;
}
return `${t}`;
}, be = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, _e = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {
const { id: o, type: a, purpose: p, value: A, created: v, modified: w, creator: h, ...L } = t;
return `${n}`;
}, be = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, _e = (e, t) => (Array.isArray(e) ? e : [e]).map((n) => {
const { id: o, type: s, purpose: f, value: A, created: b, modified: w, creator: m, ...U } = n;
return {
id: o || `temp-${Ae(t)}`,
annotation: n,
type: a,
purpose: p,
id: o || `temp-${Ae(n)}`,
annotation: t,
type: s,
purpose: f,
value: A,
creator: be(h),
created: v ? new Date(v) : void 0,
creator: be(m),
created: b ? new Date(b) : void 0,
updated: w ? new Date(w) : void 0,
...L
...U
};
}), Ye = (e) => e.map((n) => {
var v;
const { annotation: t, created: o, updated: a, ...p } = n, A = {
...p,
}), Ye = (e) => e.map((t) => {
var b;
const { annotation: n, created: o, updated: s, ...f } = t, A = {
...f,
created: o == null ? void 0 : o.toISOString(),
modified: a == null ? void 0 : a.toISOString()
modified: s == null ? void 0 : s.toISOString()
};
return (v = A.id) != null && v.startsWith("temp-") && delete A.id, A;
return (b = A.id) != null && b.startsWith("temp-") && delete A.id, A;
}), ve = [

@@ -771,18 +773,18 @@ "#ff7c00",

return { assignRandomColor: () => {
const o = Math.floor(Math.random() * e.length), a = e[o];
return e.splice(o, 1), a;
const o = Math.floor(Math.random() * e.length), s = e[o];
return e.splice(o, 1), s;
}, releaseColor: (o) => e.push(o) };
}, we = () => {
const e = Ee();
return { addUser: (o, a) => {
const p = e.assignRandomColor();
return { addUser: (o, s) => {
const f = e.assignRandomColor();
return {
label: a.name || a.id,
avatar: a.avatar,
color: p
label: s.name || s.id,
avatar: s.avatar,
color: f
};
}, removeUser: (o) => e.releaseColor(o.appearance.color) };
}, Ce = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)), je = me(), Pe = (e = we()) => {
const n = Q(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), a = (c, E) => {
if (t.has(c)) {
}, ye = (e, t) => e.every((n) => e.includes(n)) && t.every((n) => e.includes(n)), je = me(), Pe = (e = we()) => {
const t = Q(), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = (c, E) => {
if (n.has(c)) {
console.warn("Attempt to add user that is already present", c, E);

@@ -792,3 +794,3 @@ return;

const T = e.addUser(c, E);
t.set(c, {
n.set(c, {
...E,

@@ -798,4 +800,4 @@ presenceKey: c,

});
}, p = (c) => {
const E = t.get(c);
}, f = (c) => {
const E = n.get(c);
if (!E) {

@@ -805,11 +807,11 @@ console.warn("Attempt to remove user that is not present", c);

}
e.removeUser(E), t.delete(c);
e.removeUser(E), n.delete(c);
}, A = (c) => {
const E = new Set(c.map((C) => C.presenceKey)), T = c.filter(({ presenceKey: C }) => !t.has(C)), g = Array.from(t.values()).filter((C) => !E.has(C.presenceKey));
T.forEach(({ presenceKey: C, user: U }) => a(C, U)), g.forEach((C) => {
const { presenceKey: U } = C;
o.has(U) && n.emit("selectionChange", C, null), p(U);
}), (T.length > 0 || g.length > 0) && n.emit("presence", h());
}, v = (c, E) => {
const T = t.get(c);
const E = new Set(c.map((y) => y.presenceKey)), T = c.filter(({ presenceKey: y }) => !n.has(y)), h = Array.from(n.values()).filter((y) => !E.has(y.presenceKey));
T.forEach(({ presenceKey: y, user: D }) => s(y, D)), h.forEach((y) => {
const { presenceKey: D } = y;
o.has(D) && t.emit("selectionChange", y, null), f(D);
}), (T.length > 0 || h.length > 0) && t.emit("presence", m());
}, b = (c, E) => {
const T = n.get(c);
if (!T) {

@@ -819,6 +821,6 @@ console.warn("Activity notification from user that is not present");

}
const g = o.get(c);
(!g || !Ce(g, E)) && (o.set(c, E), n.emit("selectionChange", T, E));
const h = o.get(c);
(!h || !ye(h, E)) && (o.set(c, E), t.emit("selectionChange", T, E));
}, w = (c, E) => {
const T = t.get(c);
const T = n.get(c);
if (!T) {

@@ -828,8 +830,8 @@ console.warn("Selection change for user that is not present", c);

}
E ? o.set(c, E) : o.delete(c), n.emit("selectionChange", T, E);
}, h = () => [...Array.from(t.values())];
E ? o.set(c, E) : o.delete(c), t.emit("selectionChange", T, E);
}, m = () => [...Array.from(n.values())];
return {
getPresentUsers: h,
notifyActivity: v,
on: (c, E) => n.on(c, E),
getPresentUsers: m,
notifyActivity: b,
on: (c, E) => t.on(c, E),
syncUsers: A,

@@ -841,3 +843,3 @@ updateSelection: w

de as Ignore,
D as Origin,
O as Origin,
je as PRESENCE_KEY,

@@ -851,6 +853,6 @@ Z as UserSelectAction,

we as createDefaultAppearanceProvider,
Se as createHoverState,
ke as createLifecycleObserver,
Ue as createHoverState,
Ie as createLifecycleObserver,
Pe as createPresenceState,
Ue as createSelectionState,
Se as createSelectionState,
Oe as createStore,

@@ -863,3 +865,3 @@ Be as createUndoStack,

ae as mergeChanges,
q as onUserSelect,
W as onUserSelect,
ue as parseAll,

@@ -869,3 +871,3 @@ _e as parseW3CBodies,

Y as reviveDates,
Ie as serializeAll,
ke as serializeAll,
Ye as serializeW3CBodies,

@@ -872,0 +874,0 @@ re as shouldNotify,

import { Annotation } from './Annotation';
import { User } from './User';
import { PresenceProvider } from '../presence';
import { HoverState, SelectionState, Store, UndoStack, UserSelectActionExpression, ViewportState } from '../state';
import { ChangeSet, HoverState, SelectionState, Store, UndoStack, UserSelectActionExpression, ViewportState } from '../state';
import { LifecycleEvents } from '../lifecycle';

@@ -23,2 +23,3 @@ import { FormatAdapter } from './FormatAdapter';

getAnnotations(): E[];
getHistory(): ChangeSet<I>[];
getSelected(): E[];

@@ -57,2 +58,3 @@ getUser(): User;

getAnnotations: () => E[];
getHistory: () => ChangeSet<I>[];
getSelected: () => E[];

@@ -59,0 +61,0 @@ loadAnnotations: (url: string, replace?: boolean) => Promise<any>;

@@ -9,2 +9,3 @@ import { Unsubscribe } from 'nanoevents';

destroy(): void;
getHistory(): ChangeSet<T>[];
on<E extends keyof UndoStackEvents<T>>(event: E, callback: UndoStackEvents<T>[E]): Unsubscribe;

@@ -18,3 +19,3 @@ undo(): void;

}
export declare const createUndoStack: <T extends Annotation>(store: Store<T>) => UndoStack<T>;
export declare const createUndoStack: <T extends Annotation>(store: Store<T>, history?: ChangeSet<T>[]) => UndoStack<T>;
//# sourceMappingURL=UndoStack.d.ts.map

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

*/
export declare const reviveDates: <A extends Annotation>(annotation: A) => A;
export declare const reviveDates: <A extends Annotation = Annotation>(annotation: any) => A;
/**

@@ -15,0 +15,0 @@ * Shorthand/helper.

{
"name": "@annotorious/core",
"version": "3.0.15",
"version": "3.0.16",
"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

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