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.5 to 3.0.6

797

dist/annotorious-core.es.js

@@ -27,28 +27,28 @@ var q = Object.prototype.hasOwnProperty;

}
const k = [];
const x = [];
function M(e, n = _) {
let t;
const o = /* @__PURE__ */ new Set();
function i(b) {
if (X(e, b) && (e = b, t)) {
const w = !k.length;
for (const g of o)
g[1](), k.push(g, e);
function r(v) {
if (X(e, v) && (e = v, t)) {
const w = !x.length;
for (const p of o)
p[1](), x.push(p, e);
if (w) {
for (let g = 0; g < k.length; g += 2)
k[g][0](k[g + 1]);
k.length = 0;
for (let p = 0; p < x.length; p += 2)
x[p][0](x[p + 1]);
x.length = 0;
}
}
}
function f(b) {
i(b(e));
function g(v) {
r(v(e));
}
function y(b, w = _) {
const g = [b, w];
return o.add(g), o.size === 1 && (t = n(i, f) || _), b(e), () => {
o.delete(g), o.size === 0 && t && (t(), t = null);
function m(v, w = _) {
const p = [v, w];
return o.add(p), o.size === 1 && (t = n(r, g) || _), v(e), () => {
o.delete(p), o.size === 0 && t && (t(), t = null);
};
}
return { set: i, update: f, subscribe: y };
return { set: r, update: g, subscribe: m };
}

@@ -58,7 +58,7 @@ const Ue = (e) => {

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

@@ -74,67 +74,70 @@ }), {

var Z = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE = "NONE", e))(Z || {});
const z = { selected: [] }, Te = (e, n) => {
const { subscribe: t, set: o } = M(z);
let i = n, f = z;
t((A) => f = A);
const y = () => {
I(f, z) || o(z);
}, b = () => {
var A;
return ((A = f.selected) == null ? void 0 : A.length) === 0;
}, w = (A) => {
if (b())
const z = { selected: [] }, Te = (e, n, t) => {
const { subscribe: o, set: r } = M(z);
let g = n, m = z;
o((h) => m = h);
const v = () => {
I(m, z) || r(z);
}, w = () => {
var h;
return ((h = m.selected) == null ? void 0 : h.length) === 0;
}, p = (h) => {
if (w())
return !1;
const v = typeof A == "string" ? A : A.id;
return f.selected.some((L) => L.id === v);
}, g = (A, v) => {
const L = e.getAnnotation(A);
if (!L) {
console.warn("Invalid selection: " + A);
const y = typeof h == "string" ? h : h.id;
return m.selected.some((O) => O.id === y);
}, L = (h, y) => {
const O = e.getAnnotation(h);
if (!O) {
console.warn("Invalid selection: " + h);
return;
}
switch (G(L, i)) {
switch (G(O, g, t)) {
case "EDIT":
o({ selected: [{ id: A, editable: !0 }], event: v });
r({ selected: [{ id: h, editable: !0 }], event: y });
break;
case "SELECT":
o({ selected: [{ id: A }], event: v });
r({ selected: [{ id: h }], event: y });
break;
default:
o({ selected: [], event: v });
r({ selected: [], event: y });
}
}, S = (A, v) => {
const L = Array.isArray(A) ? A : [A], O = L.map((a) => e.getAnnotation(a)).filter((a) => !!a);
o({
selected: O.map((a) => {
const u = v === void 0 ? G(a, i) === "EDIT" : v;
return { id: a.id, editable: u };
}, a = (h, y) => {
const O = Array.isArray(h) ? h : [h], d = O.map((u) => e.getAnnotation(u)).filter((u) => !!u);
r({
selected: d.map((u) => {
const s = y === void 0 ? G(u, g, t) === "EDIT" : y;
return { id: u.id, editable: s };
})
}), O.length !== L.length && console.warn("Invalid selection", A);
}, r = (A) => {
if (b())
}), d.length !== O.length && console.warn("Invalid selection", h);
}, E = (h) => {
if (w())
return !1;
const { selected: v } = f;
v.some(({ id: O }) => A.includes(O)) && o({ selected: v.filter(({ id: O }) => !A.includes(O)) });
}, E = (A) => i = A;
const { selected: y } = m;
y.some(({ id: d }) => h.includes(d)) && r({ selected: y.filter(({ id: d }) => !h.includes(d)) });
}, U = (h) => g = h;
return e.observe(
({ changes: A }) => r((A.deleted || []).map((v) => v.id))
({ changes: h }) => E((h.deleted || []).map((y) => y.id))
), {
get event() {
return f ? f.event : null;
return m ? m.event : null;
},
get selected() {
return f ? [...f.selected] : null;
return m ? [...m.selected] : null;
},
get userSelectAction() {
return i;
return g;
},
clear: y,
isEmpty: b,
isSelected: w,
setSelected: S,
setUserSelectAction: E,
subscribe: t,
userSelect: g
clear: v,
isEmpty: w,
isSelected: p,
setSelected: a,
setUserSelectAction: U,
subscribe: o,
userSelect: L
};
}, G = (e, n) => typeof n == "function" ? n(e) : n || "EDIT";
}, G = (e, n, t) => {
const o = t ? t.serialize(e) : e;
return typeof n == "function" ? n(o) : n || "EDIT";
};
var D = [];

@@ -164,3 +167,3 @@ for (var Y = 0; Y < 256; ++Y)

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

@@ -170,3 +173,3 @@ n,

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

@@ -195,6 +198,6 @@ const n = (t) => {

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

@@ -205,9 +208,9 @@ oldValue: e,

bodiesDeleted: o.length > 0 ? o : void 0,
bodiesUpdated: i.length > 0 ? i : void 0,
bodiesUpdated: r.length > 0 ? r : void 0,
targetUpdated: de(e, n) ? { oldTarget: e.target, newTarget: n.target } : void 0
};
};
var ae = /* @__PURE__ */ ((e) => (e.BODY_ONLY = "BODY_ONLY", e.TARGET_ONLY = "TARGET_ONLY", e))(ae || {}), T = /* @__PURE__ */ ((e) => (e.LOCAL = "LOCAL", e.REMOTE = "REMOTE", e.SILENT = "SILENT", e))(T || {});
const re = (e, n) => {
var f, y;
var re = /* @__PURE__ */ ((e) => (e.BODY_ONLY = "BODY_ONLY", e.TARGET_ONLY = "TARGET_ONLY", e))(re || {}), T = /* @__PURE__ */ ((e) => (e.LOCAL = "LOCAL", e.REMOTE = "REMOTE", e.SILENT = "SILENT", e))(T || {});
const ae = (e, n) => {
var g, m;
const { changes: t, origin: o } = n;

@@ -217,6 +220,6 @@ if (!(e.options.origin ? e.options.origin === o : o !== "SILENT"))

if (e.options.ignore) {
const { ignore: b } = e.options, w = (S) => S && S.length > 0;
const { ignore: v } = e.options, w = (L) => L && L.length > 0;
if (!(w(t.created) || w(t.deleted))) {
const S = (f = t.updated) == null ? void 0 : f.some((E) => w(E.bodiesCreated) || w(E.bodiesDeleted) || w(E.bodiesUpdated)), r = (y = t.updated) == null ? void 0 : y.some((E) => E.targetUpdated);
if (b === "BODY_ONLY" && S && !r || b === "TARGET_ONLY" && r && !S)
const L = (g = t.updated) == null ? void 0 : g.some((E) => w(E.bodiesCreated) || w(E.bodiesDeleted) || w(E.bodiesUpdated)), a = (m = t.updated) == null ? void 0 : m.some((E) => E.targetUpdated);
if (v === "BODY_ONLY" && L && !a || v === "TARGET_ONLY" && a && !L)
return !1;

@@ -226,29 +229,29 @@ }

if (e.options.annotations) {
const b = /* @__PURE__ */ new Set([
...(t.created || []).map((g) => g.id),
...(t.deleted || []).map((g) => g.id),
...(t.updated || []).map(({ oldValue: g }) => g.id)
const v = /* @__PURE__ */ new Set([
...(t.created || []).map((p) => p.id),
...(t.deleted || []).map((p) => p.id),
...(t.updated || []).map(({ oldValue: p }) => p.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((p) => v.has(p));
} else
return !0;
}, ce = (e, n) => {
const t = new Set((e.created || []).map((r) => r.id)), o = new Set((e.updated || []).map(({ newValue: r }) => r.id)), i = new Set((n.created || []).map((r) => r.id)), f = new Set((n.deleted || []).map((r) => r.id)), y = new Set((n.updated || []).map(({ oldValue: r }) => r.id)), b = new Set((n.updated || []).filter(({ oldValue: r }) => t.has(r.id) || o.has(r.id)).map(({ oldValue: r }) => r.id)), w = [
...(e.created || []).filter((r) => !f.has(r.id)).map((r) => y.has(r.id) ? n.updated.find(({ oldValue: E }) => E.id === r.id).newValue : r),
const t = new Set((e.created || []).map((a) => a.id)), o = new Set((e.updated || []).map(({ newValue: a }) => a.id)), r = new Set((n.created || []).map((a) => a.id)), g = new Set((n.deleted || []).map((a) => a.id)), m = new Set((n.updated || []).map(({ oldValue: a }) => a.id)), v = new Set((n.updated || []).filter(({ oldValue: a }) => t.has(a.id) || o.has(a.id)).map(({ oldValue: a }) => a.id)), w = [
...(e.created || []).filter((a) => !g.has(a.id)).map((a) => m.has(a.id) ? n.updated.find(({ oldValue: E }) => E.id === a.id).newValue : a),
...n.created || []
], g = [
...(e.deleted || []).filter((r) => !i.has(r.id)),
...(n.deleted || []).filter((r) => !t.has(r.id))
], S = [
...(e.updated || []).filter(({ newValue: r }) => !f.has(r.id)).map((r) => {
const { oldValue: E, newValue: A } = r;
if (y.has(A.id)) {
const v = n.updated.find((L) => L.oldValue.id === A.id).newValue;
return J(E, v);
], p = [
...(e.deleted || []).filter((a) => !r.has(a.id)),
...(n.deleted || []).filter((a) => !t.has(a.id))
], L = [
...(e.updated || []).filter(({ newValue: a }) => !g.has(a.id)).map((a) => {
const { oldValue: E, newValue: U } = a;
if (m.has(U.id)) {
const h = n.updated.find((y) => y.oldValue.id === U.id).newValue;
return J(E, h);
} else
return r;
return a;
}),
...(n.updated || []).filter(({ oldValue: r }) => !b.has(r.id))
...(n.updated || []).filter(({ oldValue: a }) => !v.has(a.id))
];
return { created: w, deleted: g, updated: S };
return { created: w, deleted: p, updated: L };
}, V = (e) => {

@@ -269,10 +272,10 @@ const n = e.id === void 0 ? F() : e.id;

}, le = (e) => e.id !== void 0, Re = () => {
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);
const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), t = [], o = (i, c = {}) => {
t.push({ onChange: i, options: c });
}, r = (i) => {
const c = t.findIndex((l) => l.onChange == i);
c > -1 && t.splice(c, 1);
}, f = (d, c) => {
}, g = (i, c) => {
const l = {
origin: d,
origin: i,
changes: {

@@ -285,138 +288,138 @@ created: c.created || [],

};
t.forEach((p) => {
re(p, l) && p.onChange(l);
t.forEach((f) => {
ae(f, l) && f.onChange(l);
});
}, y = (d, c = T.LOCAL) => {
if (d.id && e.get(d.id))
throw Error(`Cannot add annotation ${d.id} - exists already`);
}, m = (i, c = T.LOCAL) => {
if (i.id && e.get(i.id))
throw Error(`Cannot add annotation ${i.id} - exists already`);
{
const p = V(d);
e.set(p.id, p), p.bodies.forEach((U) => n.set(U.id, p.id)), f(c, { created: [p] });
const f = V(i);
e.set(f.id, f), f.bodies.forEach((S) => n.set(S.id, f.id)), g(c, { created: [f] });
}
}, b = (d, 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 = J(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;
}, v = (i, c) => {
const l = V(typeof i == "string" ? c : i), f = typeof i == "string" ? i : i.id, S = f && e.get(f);
if (S) {
const C = J(S, l);
return f === l.id ? e.set(f, l) : (e.delete(f), e.set(l.id, l)), S.bodies.forEach((B) => n.delete(B.id)), l.bodies.forEach((B) => n.set(B.id, l.id)), C;
} else
console.warn(`Cannot update annotation ${p} - does not exist`);
}, w = (d, c = T.LOCAL, l = T.LOCAL) => {
const p = le(c) ? l : c, U = b(d, c);
U && f(p, { updated: [U] });
}, g = (d, c = T.LOCAL) => {
const l = d.reduce((p, U) => {
const C = b(U);
return C ? [...p, C] : p;
console.warn(`Cannot update annotation ${f} - does not exist`);
}, w = (i, c = T.LOCAL, l = T.LOCAL) => {
const f = le(c) ? l : c, S = v(i, c);
S && g(f, { updated: [S] });
}, p = (i, c = T.LOCAL) => {
const l = i.reduce((f, S) => {
const C = v(S);
return C ? [...f, C] : f;
}, []);
l.length > 0 && f(c, { updated: l });
}, S = (d, c = T.LOCAL) => {
const l = e.get(d.annotation);
l.length > 0 && g(c, { updated: l });
}, L = (i, c = T.LOCAL) => {
const l = e.get(i.annotation);
if (l) {
const p = {
const f = {
...l,
bodies: [...l.bodies, d]
bodies: [...l.bodies, i]
};
e.set(l.id, p), n.set(d.id, p.id), f(c, { updated: [{
e.set(l.id, f), n.set(i.id, f.id), g(c, { updated: [{
oldValue: l,
newValue: p,
bodiesCreated: [d]
newValue: f,
bodiesCreated: [i]
}] });
} else
console.warn(`Attempt to add body to missing annotation: ${d.annotation}`);
}, r = () => [...e.values()], E = (d = T.LOCAL) => {
console.warn(`Attempt to add body to missing annotation: ${i.annotation}`);
}, a = () => [...e.values()], E = (i = T.LOCAL) => {
const c = [...e.values()];
e.clear(), n.clear(), f(d, { deleted: c });
}, A = (d, c = !0, l = T.LOCAL) => {
const p = d.map(V);
e.clear(), n.clear(), g(i, { deleted: c });
}, U = (i, c = !0, l = T.LOCAL) => {
const f = i.map(V);
if (c) {
const U = [...e.values()];
e.clear(), n.clear(), p.forEach((C) => {
const S = [...e.values()];
e.clear(), n.clear(), f.forEach((C) => {
e.set(C.id, C), C.bodies.forEach((B) => n.set(B.id, C.id));
}), f(l, { created: p, deleted: U });
}), g(l, { created: f, deleted: S });
} else {
const U = d.reduce((C, B) => {
const S = i.reduce((C, B) => {
const W = B.id && e.get(B.id);
return W ? [...C, W] : C;
}, []);
if (U.length > 0)
throw Error(`Bulk insert would overwrite the following annotations: ${U.map((C) => C.id).join(", ")}`);
p.forEach((C) => {
if (S.length > 0)
throw Error(`Bulk insert would overwrite the following annotations: ${S.map((C) => C.id).join(", ")}`);
f.forEach((C) => {
e.set(C.id, C), C.bodies.forEach((B) => n.set(B.id, C.id));
}), f(l, { created: p });
}), g(l, { created: f });
}
}, v = (d) => {
const c = typeof d == "string" ? d : d.id, l = e.get(c);
}, h = (i) => {
const c = typeof i == "string" ? i : i.id, l = e.get(c);
if (l)
return e.delete(c), l.bodies.forEach((p) => n.delete(p.id)), l;
return e.delete(c), l.bodies.forEach((f) => n.delete(f.id)), l;
console.warn(`Attempt to delete missing annotation: ${c}`);
}, L = (d, c = T.LOCAL) => {
const l = v(d);
l && f(c, { deleted: [l] });
}, O = (d, c = T.LOCAL) => {
const l = d.reduce((p, U) => {
const C = v(U);
return C ? [...p, C] : p;
}, y = (i, c = T.LOCAL) => {
const l = h(i);
l && g(c, { deleted: [l] });
}, O = (i, c = T.LOCAL) => {
const l = i.reduce((f, S) => {
const C = h(S);
return C ? [...f, C] : f;
}, []);
l.length > 0 && f(c, { deleted: l });
}, a = (d) => {
const c = e.get(d.annotation);
l.length > 0 && g(c, { deleted: l });
}, d = (i) => {
const c = e.get(i.annotation);
if (c) {
const l = c.bodies.find((p) => p.id === d.id);
const l = c.bodies.find((f) => f.id === i.id);
if (l) {
n.delete(l.id);
const p = {
const f = {
...c,
bodies: c.bodies.filter((C) => C.id !== d.id)
bodies: c.bodies.filter((C) => C.id !== i.id)
};
return e.set(c.id, p), {
return e.set(c.id, f), {
oldValue: c,
newValue: p,
newValue: f,
bodiesDeleted: [l]
};
} else
console.warn(`Attempt to delete missing body ${d.id} from annotation ${d.annotation}`);
console.warn(`Attempt to delete missing body ${i.id} from annotation ${i.annotation}`);
} else
console.warn(`Attempt to delete body from missing annotation ${d.annotation}`);
}, u = (d, c = T.LOCAL) => {
const l = a(d);
l && f(c, { updated: [l] });
}, s = (d, c = T.LOCAL) => {
const l = d.map((p) => a(p)).filter(Boolean);
l.length > 0 && f(c, { updated: l });
}, h = (d) => {
const c = e.get(d);
console.warn(`Attempt to delete body from missing annotation ${i.annotation}`);
}, u = (i, c = T.LOCAL) => {
const l = d(i);
l && g(c, { updated: [l] });
}, s = (i, c = T.LOCAL) => {
const l = i.map((f) => d(f)).filter(Boolean);
l.length > 0 && g(c, { updated: l });
}, A = (i) => {
const c = e.get(i);
return c ? { ...c } : void 0;
}, m = (d) => {
const c = n.get(d);
}, b = (i) => {
const c = n.get(i);
if (c) {
const p = h(c).bodies.find((U) => U.id === d);
if (p)
return p;
console.error(`Store integrity error: body ${d} in index, but not in annotation`);
const f = A(c).bodies.find((S) => S.id === i);
if (f)
return f;
console.error(`Store integrity error: body ${i} in index, but not in annotation`);
} else
console.warn(`Attempt to retrieve missing body: ${d}`);
}, R = (d, c) => {
if (d.annotation !== c.annotation)
console.warn(`Attempt to retrieve missing body: ${i}`);
}, R = (i, c) => {
if (i.annotation !== c.annotation)
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
const l = e.get(d.annotation);
const l = e.get(i.annotation);
if (l) {
const p = l.bodies.find((C) => C.id === d.id), U = {
const f = l.bodies.find((C) => C.id === i.id), S = {
...l,
bodies: l.bodies.map((C) => C.id === p.id ? c : C)
bodies: l.bodies.map((C) => C.id === f.id ? c : C)
};
return e.set(l.id, U), p.id !== c.id && (n.delete(p.id), n.set(c.id, U.id)), {
return e.set(l.id, S), f.id !== c.id && (n.delete(f.id), n.set(c.id, S.id)), {
oldValue: l,
newValue: U,
bodiesUpdated: [{ oldBody: p, newBody: c }]
newValue: S,
bodiesUpdated: [{ oldBody: f, newBody: c }]
};
} else
console.warn(`Attempt to add body to missing annotation ${d.annotation}`);
}, N = (d, c, l = T.LOCAL) => {
const p = R(d, c);
p && f(l, { updated: [p] });
}, x = (d, c = T.LOCAL) => {
const l = d.map((p) => R({ id: p.id, annotation: p.annotation }, p)).filter(Boolean);
f(c, { updated: l });
}, P = (d) => {
const c = e.get(d.annotation);
console.warn(`Attempt to add body to missing annotation ${i.annotation}`);
}, N = (i, c, l = T.LOCAL) => {
const f = R(i, c);
f && g(l, { updated: [f] });
}, k = (i, c = T.LOCAL) => {
const l = i.map((f) => R({ id: f.id, annotation: f.annotation }, f)).filter(Boolean);
g(c, { updated: l });
}, P = (i) => {
const c = e.get(i.annotation);
if (c) {

@@ -427,3 +430,3 @@ const l = {

...c.target,
...d
...i
}

@@ -436,33 +439,33 @@ };

oldTarget: c.target,
newTarget: d
newTarget: i
}
};
} else
console.warn(`Attempt to update target on missing annotation: ${d.annotation}`);
console.warn(`Attempt to update target on missing annotation: ${i.annotation}`);
};
return {
addAnnotation: y,
addBody: S,
all: r,
bulkAddAnnotation: A,
addAnnotation: m,
addBody: L,
all: a,
bulkAddAnnotation: U,
bulkDeleteAnnotation: O,
bulkDeleteBodies: s,
bulkUpdateAnnotation: g,
bulkUpdateBodies: x,
bulkUpdateTargets: (d, c = T.LOCAL) => {
const l = d.map((p) => P(p)).filter(Boolean);
l.length > 0 && f(c, { updated: l });
bulkUpdateAnnotation: p,
bulkUpdateBodies: k,
bulkUpdateTargets: (i, c = T.LOCAL) => {
const l = i.map((f) => P(f)).filter(Boolean);
l.length > 0 && g(c, { updated: l });
},
clear: E,
deleteAnnotation: L,
deleteAnnotation: y,
deleteBody: u,
getAnnotation: h,
getBody: m,
getAnnotation: A,
getBody: b,
observe: o,
unobserve: i,
unobserve: r,
updateAnnotation: w,
updateBody: N,
updateTarget: (d, c = T.LOCAL) => {
const l = P(d);
l && f(c, { updated: [l] });
updateTarget: (i, c = T.LOCAL) => {
const l = P(i);
l && g(c, { updated: [l] });
}

@@ -473,3 +476,3 @@ };

subscribe: (t) => {
const o = (i) => t(i.state);
const o = (r) => t(r.state);
return e.observe(o), t(e.all()), () => e.unobserve(o);

@@ -480,3 +483,3 @@ }

emit(e, ...n) {
for (let t = 0, o = this.events[e] || [], i = o.length; t < i; t++)
for (let t = 0, o = this.events[e] || [], r = o.length; t < r; t++)
o[t](...n);

@@ -489,3 +492,3 @@ },

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

@@ -496,28 +499,28 @@ }

const n = Q(), t = [];
let o = -1, i = !1, f = 0;
const y = (s) => {
if (!i) {
const { changes: h } = s, m = performance.now();
if (m - f > ue)
t.splice(o + 1), t.push(h), o = t.length - 1;
let o = -1, r = !1, g = 0;
const m = (s) => {
if (!r) {
const { changes: A } = s, b = performance.now();
if (b - g > ue)
t.splice(o + 1), t.push(A), o = t.length - 1;
else {
const R = t.length - 1;
t[R] = ce(t[R], h);
t[R] = ce(t[R], A);
}
f = m;
g = b;
}
i = !1;
r = !1;
};
e.observe(y, { origin: T.LOCAL });
const b = (s) => s && s.length > 0 && e.bulkDeleteAnnotation(s), w = (s) => s && s.length > 0 && e.bulkAddAnnotation(s, !1), g = (s) => s && s.length > 0 && e.bulkUpdateAnnotation(s.map(({ oldValue: h }) => h)), S = (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(m, { origin: T.LOCAL });
const v = (s) => s && s.length > 0 && e.bulkDeleteAnnotation(s), w = (s) => s && s.length > 0 && e.bulkAddAnnotation(s, !1), p = (s) => s && s.length > 0 && e.bulkUpdateAnnotation(s.map(({ oldValue: A }) => A)), L = (s) => s && s.length > 0 && e.bulkUpdateAnnotation(s.map(({ newValue: A }) => A)), a = (s) => s && s.length > 0 && e.bulkAddAnnotation(s, !1), E = (s) => s && s.length > 0 && e.bulkDeleteAnnotation(s);
return {
canRedo: () => t.length - 1 > o,
canUndo: () => o > -1,
destroy: () => e.unobserve(y),
on: (s, h) => n.on(s, h),
destroy: () => e.unobserve(m),
on: (s, A) => n.on(s, A),
redo: () => {
if (t.length - 1 > o) {
i = !0;
const { created: s, updated: h, deleted: m } = t[o + 1];
w(s), S(h), E(m), n.emit("redo", t[o + 1]), o += 1;
r = !0;
const { created: s, updated: A, deleted: b } = t[o + 1];
w(s), L(A), E(b), n.emit("redo", t[o + 1]), o += 1;
}

@@ -527,9 +530,9 @@ },

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

@@ -540,90 +543,90 @@ return {

};
}, ke = (e, n, t, o) => {
const { store: i, selection: f, hover: y, viewport: b } = e, w = /* @__PURE__ */ new Map();
let g = [], S, r;
const E = (a, u) => {
w.has(a) ? w.get(a).push(u) : w.set(a, [u]);
}, A = (a, u) => {
const s = w.get(a);
}, xe = (e, n, t, o) => {
const { hover: r, selection: g, store: m, viewport: v } = e, w = /* @__PURE__ */ new Map();
let p = [], L, a;
const E = (d, u) => {
w.has(d) ? w.get(d).push(u) : w.set(d, [u]);
}, U = (d, u) => {
const s = w.get(d);
if (s) {
const h = s.indexOf(u);
h !== -1 && s.splice(h, 1);
const A = s.indexOf(u);
A !== -1 && s.splice(A, 1);
}
}, v = (a, u, s) => {
w.has(a) && setTimeout(() => {
w.get(a).forEach((h) => {
}, h = (d, u, s) => {
w.has(d) && setTimeout(() => {
w.get(d).forEach((A) => {
if (t) {
const m = Array.isArray(u) ? u.map((N) => t.serialize(N)) : t.serialize(u), R = s ? s instanceof PointerEvent ? s : t.serialize(s) : void 0;
h(m, R);
const b = Array.isArray(u) ? u.map((N) => t.serialize(N)) : t.serialize(u), R = s ? s instanceof PointerEvent ? s : t.serialize(s) : void 0;
A(b, R);
} else
h(u, s);
A(u, s);
});
}, 1);
}, L = () => {
const { selected: a } = f, u = (a || []).map(({ id: s }) => i.getAnnotation(s));
}, y = () => {
const { selected: d } = g, u = (d || []).map(({ id: s }) => m.getAnnotation(s));
u.forEach((s) => {
const h = g.find((m) => m.id === s.id);
(!h || !I(h, s)) && v("updateAnnotation", s, h);
}), g = g.map((s) => {
const h = u.find(({ id: m }) => m === s.id);
return h || s;
const A = p.find((b) => b.id === s.id);
(!A || !I(A, s)) && h("updateAnnotation", s, A);
}), p = p.map((s) => {
const A = u.find(({ id: b }) => b === s.id);
return A || 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) => {
const s = i.getAnnotation(u.id);
s && !I(s, u) && v("updateAnnotation", s, u);
}), g = [];
g.subscribe(({ selected: d }) => {
if (!(p.length === 0 && d.length === 0)) {
if (p.length === 0 && d.length > 0)
p = d.map(({ id: u }) => m.getAnnotation(u));
else if (p.length > 0 && d.length === 0)
p.forEach((u) => {
const s = m.getAnnotation(u.id);
s && !I(s, u) && h("updateAnnotation", s, u);
}), p = [];
else {
const u = new Set(g.map((m) => m.id)), s = new Set(a.map(({ id: m }) => m));
g.filter((m) => !s.has(m.id)).forEach((m) => {
const R = i.getAnnotation(m.id);
R && !I(R, m) && v("updateAnnotation", R, m);
}), g = [
const u = new Set(p.map((b) => b.id)), s = new Set(d.map(({ id: b }) => b));
p.filter((b) => !s.has(b.id)).forEach((b) => {
const R = m.getAnnotation(b.id);
R && !I(R, b) && h("updateAnnotation", R, b);
}), p = [
// Remove annotations that were deselected
...g.filter((m) => s.has(m.id)),
...p.filter((b) => s.has(b.id)),
// Add editable annotations that were selected
...a.filter(({ id: m }) => !u.has(m)).map(({ id: m }) => i.getAnnotation(m))
...d.filter(({ id: b }) => !u.has(b)).map(({ id: b }) => m.getAnnotation(b))
];
}
v("selectionChanged", g);
h("selectionChanged", p);
}
}), y.subscribe((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(L, 1e3));
const { created: u, deleted: s } = a.changes;
(u || []).forEach((m) => v("createAnnotation", m)), (s || []).forEach((m) => v("deleteAnnotation", m)), (a.changes.updated || []).filter((m) => [
...m.bodiesCreated || [],
...m.bodiesDeleted || [],
...m.bodiesUpdated || []
].length > 0).forEach(({ oldValue: m, newValue: R }) => {
const N = g.find((x) => x.id === m.id) || m;
g = g.map((x) => x.id === m.id ? R : x), v("updateAnnotation", R, N);
}), r.subscribe((d) => {
!L && d ? h("mouseEnterAnnotation", m.getAnnotation(d)) : L && !d ? h("mouseLeaveAnnotation", m.getAnnotation(L)) : L && d && (h("mouseLeaveAnnotation", m.getAnnotation(L)), h("mouseEnterAnnotation", m.getAnnotation(d))), L = d;
}), v == null || v.subscribe((d) => h("viewportIntersect", d.map((u) => m.getAnnotation(u)))), m.observe((d) => {
o && (a && clearTimeout(a), a = setTimeout(y, 1e3));
const { created: u, deleted: s } = d.changes;
(u || []).forEach((b) => h("createAnnotation", b)), (s || []).forEach((b) => h("deleteAnnotation", b)), (d.changes.updated || []).filter((b) => [
...b.bodiesCreated || [],
...b.bodiesDeleted || [],
...b.bodiesUpdated || []
].length > 0).forEach(({ oldValue: b, newValue: R }) => {
const N = p.find((k) => k.id === b.id) || b;
p = p.map((k) => k.id === b.id ? R : k), h("updateAnnotation", R, N);
});
}, { origin: T.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 m = s.find((R) => R.id === h.id);
return m || h;
}, { origin: T.LOCAL }), m.observe((d) => {
if (p) {
const u = new Set(p.map((A) => A.id)), s = (d.changes.updated || []).filter(({ newValue: A }) => u.has(A.id)).map(({ newValue: A }) => A);
s.length > 0 && (p = p.map((A) => {
const b = s.find((R) => R.id === A.id);
return b || A;
}));
}
}, { origin: T.REMOTE });
const O = (a) => (u) => {
const O = (d) => (u) => {
const { updated: s } = u;
a ? (s || []).forEach((h) => v("updateAnnotation", h.oldValue, h.newValue)) : (s || []).forEach((h) => v("updateAnnotation", h.newValue, h.oldValue));
d ? (s || []).forEach((A) => h("updateAnnotation", A.oldValue, A.newValue)) : (s || []).forEach((A) => h("updateAnnotation", A.newValue, A.oldValue));
};
return n.on("undo", O(!0)), n.on("redo", O(!1)), { on: E, off: A, emit: v };
return n.on("undo", O(!0)), n.on("redo", O(!1)), { on: E, off: U, emit: h };
}, Ne = (e) => (n) => n.map((t) => e.serialize(t)), fe = (e) => (n) => n.reduce((t, o) => {
const { parsed: i, error: f } = e.parse(o);
return f ? {
const { parsed: r, error: g } = e.parse(o);
return g ? {
parsed: t.parsed,
failed: [...t.failed, o]
} : i ? {
parsed: [...t.parsed, i],
} : r ? {
parsed: [...t.parsed, r],
failed: t.failed

@@ -634,59 +637,59 @@ } : {

}, { parsed: [], failed: [] }), ze = (e, n, t) => {
const { store: o, selection: i } = e, f = (a) => {
const { store: o, selection: r } = e, g = (d) => {
if (t) {
const { parsed: u, error: s } = t.parse(a);
const { parsed: u, error: s } = t.parse(d);
u ? o.addAnnotation(u, T.REMOTE) : console.error(s);
} else
o.addAnnotation(j(a), T.REMOTE);
}, y = () => i.clear(), b = () => o.clear(), w = (a) => {
const u = o.getAnnotation(a);
o.addAnnotation(j(d), T.REMOTE);
}, m = () => r.clear(), v = () => o.clear(), w = (d) => {
const u = o.getAnnotation(d);
return t && u ? t.serialize(u) : u;
}, g = () => t ? o.all().map(t.serialize) : o.all(), S = () => {
}, p = () => t ? o.all().map(t.serialize) : o.all(), L = () => {
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 = r.selected) == null ? void 0 : s.map((A) => A.id)) || []).map((A) => o.getAnnotation(A)).filter(Boolean);
return t ? u.map(t.serialize) : u;
}, r = (a, u = !0) => fetch(a).then((s) => s.json()).then((s) => (A(s, u), s)), E = (a) => {
if (typeof a == "string") {
const u = o.getAnnotation(a);
if (o.deleteAnnotation(a), u)
}, a = (d, u = !0) => fetch(d).then((s) => s.json()).then((s) => (U(s, u), s)), E = (d) => {
if (typeof d == "string") {
const u = o.getAnnotation(d);
if (o.deleteAnnotation(d), u)
return t ? t.serialize(u) : u;
} else {
const u = t ? t.parse(a).parsed : a;
const u = t ? t.parse(d).parsed : d;
if (u)
return o.deleteAnnotation(u), a;
return o.deleteAnnotation(u), d;
}
}, A = (a, u = !0) => {
}, U = (d, u = !0) => {
if (t) {
const s = t.parseAll || fe(t), { parsed: h, failed: m } = s(a);
m.length > 0 && console.warn(`Discarded ${m.length} invalid annotations`, m), o.bulkAddAnnotation(h, u, T.REMOTE);
const s = t.parseAll || fe(t), { parsed: A, failed: b } = s(d);
b.length > 0 && console.warn(`Discarded ${b.length} invalid annotations`, b), o.bulkAddAnnotation(A, u, T.REMOTE);
} else
o.bulkAddAnnotation(a.map(j), u, T.REMOTE);
}, v = (a, u) => {
a ? i.setSelected(a, u) : i.clear();
}, L = (a) => {
i.clear(), i.setUserSelectAction(a);
}, O = (a) => {
o.bulkAddAnnotation(d.map(j), u, T.REMOTE);
}, h = (d, u) => {
d ? r.setSelected(d, u) : r.clear();
}, y = (d) => {
r.clear(), r.setUserSelectAction(d);
}, O = (d) => {
if (t) {
const u = t.parse(a).parsed, s = t.serialize(o.getAnnotation(u.id));
const u = t.parse(d).parsed, s = t.serialize(o.getAnnotation(u.id));
return o.updateAnnotation(u), s;
} else {
const u = o.getAnnotation(a.id);
return o.updateAnnotation(j(a)), u;
const u = o.getAnnotation(d.id);
return o.updateAnnotation(j(d)), u;
}
};
return {
addAnnotation: f,
cancelSelected: y,
addAnnotation: g,
cancelSelected: m,
canRedo: n.canRedo,
canUndo: n.canUndo,
clearAnnotations: b,
clearAnnotations: v,
getAnnotationById: w,
getAnnotations: g,
getSelected: S,
loadAnnotations: r,
getAnnotations: p,
getSelected: L,
loadAnnotations: a,
redo: n.redo,
removeAnnotation: E,
setAnnotations: A,
setSelected: v,
setUserSelectAction: L,
setAnnotations: U,
setSelected: h,
setUserSelectAction: y,
undo: n.undo,

@@ -697,9 +700,9 @@ updateAnnotation: O

let ge = (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);
return (f = n) => {
let y = "";
let o = (2 << Math.log(e.length - 1) / Math.LN2) - 1, r = -~(1.6 * o * n / e.length);
return (g = n) => {
let m = "";
for (; ; ) {
let b = t(i), w = i;
let v = t(r), w = r;
for (; w--; )
if (y += e[b[w] & o] || "", y.length === f) return y;
if (m += e[v[w] & o] || "", m.length === g) return m;
}

@@ -716,28 +719,28 @@ };

let t = 0;
for (let o = 0, i = n.length; o < i; o++) {
let f = n.charCodeAt(o);
t = (t << 5) - t + f, t |= 0;
for (let o = 0, r = n.length; o < r; o++) {
let g = n.charCodeAt(o);
t = (t << 5) - t + g, t |= 0;
}
return `${t}`;
}, ve = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, Ve = (e, n) => (Array.isArray(e) ? e : [e]).map((t) => {
const { id: o, type: i, purpose: f, value: y, created: b, modified: w, creator: g, ...S } = t;
const { id: o, type: r, purpose: g, value: m, created: v, modified: w, creator: p, ...L } = t;
return {
id: o || `temp-${be(t)}`,
annotation: n,
type: i,
purpose: f,
value: y,
creator: ve(g),
created: b ? new Date(b) : void 0,
type: r,
purpose: g,
value: m,
creator: ve(p),
created: v ? new Date(v) : void 0,
updated: w ? new Date(w) : void 0,
...S
...L
};
}), _e = (e) => e.map((n) => {
var b;
const { annotation: t, created: o, updated: i, ...f } = n, y = {
...f,
var v;
const { annotation: t, created: o, updated: r, ...g } = n, m = {
...g,
created: o == null ? void 0 : o.toISOString(),
modified: i == null ? void 0 : i.toISOString()
modified: r == null ? void 0 : r.toISOString()
};
return (b = y.id) != null && b.startsWith("temp-") && delete y.id, y;
return (v = m.id) != null && v.startsWith("temp-") && delete m.id, m;
}), Ee = [

@@ -765,61 +768,61 @@ "#ff7c00",

return { assignRandomColor: () => {
const o = Math.floor(Math.random() * e.length), i = e[o];
return e.splice(o, 1), i;
const o = Math.floor(Math.random() * e.length), r = e[o];
return e.splice(o, 1), r;
}, releaseColor: (o) => e.push(o) };
}, ye = () => {
const e = we();
return { addUser: (o, i) => {
const f = e.assignRandomColor();
return { addUser: (o, r) => {
const g = e.assignRandomColor();
return {
label: i.name || i.id,
avatar: i.avatar,
color: f
label: r.name || r.id,
avatar: r.avatar,
color: g
};
}, removeUser: (o) => e.releaseColor(o.appearance.color) };
}, Ce = (e, n) => e.every((t) => e.includes(t)) && n.every((t) => e.includes(t)), Ye = Ae(), je = (e = ye()) => {
const n = Q(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = (r, E) => {
if (t.has(r)) {
console.warn("Attempt to add user that is already present", r, E);
const n = Q(), t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), r = (a, E) => {
if (t.has(a)) {
console.warn("Attempt to add user that is already present", a, E);
return;
}
const A = e.addUser(r, E);
t.set(r, {
const U = e.addUser(a, E);
t.set(a, {
...E,
presenceKey: r,
appearance: A
presenceKey: a,
appearance: U
});
}, f = (r) => {
const E = t.get(r);
}, g = (a) => {
const E = t.get(a);
if (!E) {
console.warn("Attempt to remove user that is not present", r);
console.warn("Attempt to remove user that is not present", a);
return;
}
e.removeUser(E), t.delete(r);
}, y = (r) => {
const E = new Set(r.map((L) => L.presenceKey)), A = r.filter(({ presenceKey: L }) => !t.has(L)), v = Array.from(t.values()).filter((L) => !E.has(L.presenceKey));
A.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);
}), (A.length > 0 || v.length > 0) && n.emit("presence", g());
}, b = (r, E) => {
const A = t.get(r);
if (!A) {
e.removeUser(E), t.delete(a);
}, m = (a) => {
const E = new Set(a.map((y) => y.presenceKey)), U = a.filter(({ presenceKey: y }) => !t.has(y)), h = Array.from(t.values()).filter((y) => !E.has(y.presenceKey));
U.forEach(({ presenceKey: y, user: O }) => r(y, O)), h.forEach((y) => {
const { presenceKey: O } = y;
o.has(O) && n.emit("selectionChange", y, null), g(O);
}), (U.length > 0 || h.length > 0) && n.emit("presence", p());
}, v = (a, E) => {
const U = t.get(a);
if (!U) {
console.warn("Activity notification from user that is not present");
return;
}
const v = o.get(r);
(!v || !Ce(v, E)) && (o.set(r, E), n.emit("selectionChange", A, E));
}, w = (r, E) => {
const A = t.get(r);
if (!A) {
console.warn("Selection change for user that is not present", r);
const h = o.get(a);
(!h || !Ce(h, E)) && (o.set(a, E), n.emit("selectionChange", U, E));
}, w = (a, E) => {
const U = t.get(a);
if (!U) {
console.warn("Selection change for user that is not present", a);
return;
}
E ? o.set(r, E) : o.delete(r), n.emit("selectionChange", A, E);
}, g = () => [...Array.from(t.values())];
E ? o.set(a, E) : o.delete(a), n.emit("selectionChange", U, E);
}, p = () => [...Array.from(t.values())];
return {
getPresentUsers: g,
notifyActivity: b,
on: (r, E) => n.on(r, E),
syncUsers: y,
getPresentUsers: p,
notifyActivity: v,
on: (a, E) => n.on(a, E),
syncUsers: m,
updateSelection: w

@@ -829,3 +832,3 @@ };

export {
ae as Ignore,
re as Ignore,
T as Origin,

@@ -839,3 +842,3 @@ Ye as PRESENCE_KEY,

Ue as createHoverState,
ke as createLifecycleObserver,
xe as createLifecycleObserver,
je as createPresenceState,

@@ -845,3 +848,3 @@ Te as createSelectionState,

Ie as createUndoStack,
xe as createViewportState,
ke as createViewportState,
we as defaultColorProvider,

@@ -858,5 +861,5 @@ J as diffAnnotations,

_e as serializeW3CBodies,
re as shouldNotify,
ae as shouldNotify,
Be as toSvelteStore
};
//# sourceMappingURL=annotorious-core.es.js.map

@@ -5,3 +5,3 @@ import { Annotation, AnnotatorState, FormatAdapter } from '../model';

export type Lifecycle<I extends Annotation, E extends unknown> = ReturnType<typeof createLifecycleObserver<I, E>>;
export declare const createLifecycleObserver: <I extends Annotation, E extends unknown>(state: AnnotatorState<I>, undoStack: UndoStack<I>, adapter?: FormatAdapter<I, E>, autoSave?: boolean) => {
export declare const createLifecycleObserver: <I extends Annotation, E extends unknown>(state: AnnotatorState<I, E>, undoStack: UndoStack<I>, adapter?: FormatAdapter<I, E>, autoSave?: boolean) => {
on: <T extends keyof LifecycleEvents>(event: T, callback: LifecycleEvents<E>[T]) => void;

@@ -8,0 +8,0 @@ off: <T extends keyof LifecycleEvents<E>>(event: T, callback: LifecycleEvents<E>[T]) => void;

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

setUser(user: User): void;
setUserSelectAction(action: UserSelectActionExpression<I>): void;
setUserSelectAction(action: UserSelectActionExpression<E>): void;
setVisible(visible: boolean): void;

@@ -41,11 +41,11 @@ undo(): void;

off<T extends keyof LifecycleEvents<E>>(event: T, callback: LifecycleEvents<E>[T]): void;
state: AnnotatorState<I>;
state: AnnotatorState<I, E>;
}
export interface AnnotatorState<A extends Annotation> {
store: Store<A>;
selection: SelectionState<A>;
hover: HoverState<A>;
export interface AnnotatorState<I extends Annotation, E extends unknown> {
store: Store<I>;
selection: SelectionState<I, E>;
hover: HoverState<I>;
viewport: ViewportState;
}
export declare const createBaseAnnotator: <I extends Annotation, E extends unknown>(state: AnnotatorState<I>, undoStack: UndoStack<I>, adapter?: FormatAdapter<I, E>) => {
export declare const createBaseAnnotator: <I extends Annotation, E extends unknown>(state: AnnotatorState<I, E>, undoStack: UndoStack<I>, adapter?: FormatAdapter<I, E>) => {
addAnnotation: (annotation: E) => void;

@@ -64,3 +64,3 @@ cancelSelected: () => void;

setSelected: (arg?: string | string[], editable?: boolean) => void;
setUserSelectAction: (action: UserSelectActionExpression<I>) => void;
setUserSelectAction: (action: UserSelectActionExpression<E>) => void;
undo: () => void;

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

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

import { Annotation } from '../model';
import { Annotation, FormatAdapter } from '../model';
import { Store } from './Store';

@@ -11,3 +11,3 @@ export interface Selection {

}
export type SelectionState<T extends Annotation> = ReturnType<typeof createSelectionState<T>>;
export type SelectionState<I extends Annotation, E extends unknown> = ReturnType<typeof createSelectionState<I, E>>;
export declare enum UserSelectAction {

@@ -18,4 +18,4 @@ EDIT = "EDIT",// Make annotation target(s) editable on pointer select

}
export type UserSelectActionExpression<T extends Annotation> = UserSelectAction | ((a: T) => UserSelectAction);
export declare const createSelectionState: <T extends Annotation>(store: Store<T>, defaultSelectionAction?: UserSelectActionExpression<T>) => {
export type UserSelectActionExpression<T extends unknown> = UserSelectAction | ((a: T) => UserSelectAction);
export declare const createSelectionState: <I extends Annotation, E extends unknown>(store: Store<I>, defaultSelectionAction?: UserSelectActionExpression<E>, adapter?: FormatAdapter<I, E>) => {
readonly event: PointerEvent | KeyboardEvent | null | undefined;

@@ -26,12 +26,12 @@ readonly selected: {

}[] | null;
readonly userSelectAction: UserSelectActionExpression<T> | undefined;
readonly userSelectAction: UserSelectActionExpression<E> | undefined;
clear: () => void;
isEmpty: () => boolean;
isSelected: (annotationOrId: T | string) => boolean;
isSelected: (annotationOrId: I | string) => boolean;
setSelected: (idOrIds: string | string[], editable?: boolean) => void;
setUserSelectAction: (action: UserSelectActionExpression<T> | undefined) => UserSelectActionExpression<T> | undefined;
setUserSelectAction: (action: UserSelectActionExpression<E> | undefined) => UserSelectActionExpression<E> | undefined;
subscribe: (this: void, run: import('svelte/store').Subscriber<Selection>, invalidate?: import('svelte/store').Invalidator<Selection> | undefined) => import('svelte/store').Unsubscriber;
userSelect: (id: string, event?: Selection["event"]) => void;
};
export declare const onUserSelect: <T extends Annotation>(annotation: T, action?: UserSelectActionExpression<T>) => UserSelectAction;
export declare const onUserSelect: <I extends Annotation, E extends unknown>(annotation: I, action?: UserSelectActionExpression<E>, adapter?: FormatAdapter<I, E>) => UserSelectAction;
//# sourceMappingURL=Selection.d.ts.map

@@ -7,7 +7,7 @@ import { Annotation, Annotator, AnnotatorState } from '../model';

}
export interface SvelteAnnotatorState<T extends Annotation> extends AnnotatorState<T> {
store: SvelteStore<T>;
export interface SvelteAnnotatorState<I extends Annotation, E extends unknown> extends AnnotatorState<I, E> {
store: SvelteStore<I>;
}
export interface SvelteAnnotator<T extends Annotation> extends Annotator<T> {
state: SvelteAnnotatorState<T>;
export interface SvelteAnnotator<I extends Annotation, E extends unknown> extends Annotator<I, E> {
state: SvelteAnnotatorState<I, E>;
}

@@ -14,0 +14,0 @@ /**

{
"name": "@annotorious/core",
"version": "3.0.5",
"version": "3.0.6",
"description": "Annotorious core types and functions",

@@ -8,2 +8,3 @@ "author": "Rainer Simon",

"homepage": "https://annotorious.dev",
"funding": "https://steadyhq.com/rainer-simon",
"type": "module",

@@ -35,6 +36,6 @@ "repository": {

"svelte-preprocess": "^6.0.2",
"typescript": "5.5.4",
"vite": "^5.4.3",
"vite-plugin-dts": "^4.1.0",
"vitest": "^2.0.5"
"typescript": "5.6.2",
"vite": "^5.4.6",
"vite-plugin-dts": "^4.2.1",
"vitest": "^2.1.1"
},

@@ -41,0 +42,0 @@ "dependencies": {

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

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