@annotorious/plugin-segment-anything 0.1.15 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as R, c as r, a as k,
|
|
1
|
+
import { m as R, c as r, a as k, M as C, j as T, g as H, W, b as O, v as V } from "./get-image-bounds-CnOHKy6k.js";
|
|
2
2
|
const L = (n, a, d = {}) => {
|
|
3
3
|
if (!Number.isFinite(a))
|
|
4
4
|
throw new TypeError("Expected `wait` to be a finite number");
|
|
@@ -47,8 +47,8 @@ const z = (n, a, d) => {
|
|
|
47
47
|
let f = o.get(h).rows;
|
|
48
48
|
f > v && (v = f, c = h);
|
|
49
49
|
}
|
|
50
|
-
let
|
|
51
|
-
r.approxPolyDP(
|
|
50
|
+
let S = o.get(c), A = 5e-3 * r.arcLength(S, !0), x = new r.Mat();
|
|
51
|
+
r.approxPolyDP(S, x, A, !0);
|
|
52
52
|
let p = [];
|
|
53
53
|
for (let h = 0; h < x.rows; h++)
|
|
54
54
|
p.push([
|
|
@@ -56,7 +56,7 @@ const z = (n, a, d) => {
|
|
|
56
56
|
x.data32S[h * 2 + 1] * d
|
|
57
57
|
]);
|
|
58
58
|
const w = k(p), E = {
|
|
59
|
-
type:
|
|
59
|
+
type: T.POLYGON,
|
|
60
60
|
geometry: {
|
|
61
61
|
bounds: C(w),
|
|
62
62
|
points: w
|
|
@@ -68,7 +68,7 @@ const z = (n, a, d) => {
|
|
|
68
68
|
}, N = (n) => new Promise((a, d) => {
|
|
69
69
|
const t = new Image();
|
|
70
70
|
t.crossOrigin = "anonymous", t.onload = () => {
|
|
71
|
-
const { bounds: e, scale: s } =
|
|
71
|
+
const { bounds: e, scale: s } = H(
|
|
72
72
|
{ h: t.naturalHeight, w: t.naturalWidth },
|
|
73
73
|
{ h: 1024, w: 1024 }
|
|
74
74
|
), o = document.createElement("canvas");
|
|
@@ -86,7 +86,7 @@ const z = (n, a, d) => {
|
|
|
86
86
|
}, t.onerror = (e) => {
|
|
87
87
|
d(e);
|
|
88
88
|
}, t.src = n.src;
|
|
89
|
-
}), P = window.devicePixelRatio || 1,
|
|
89
|
+
}), P = window.devicePixelRatio || 1, Y = (n, a, d) => {
|
|
90
90
|
const t = document.createElement("canvas");
|
|
91
91
|
t.setAttribute("class", "a9s-sam-input-markers"), t.width = P * n.offsetWidth, t.height = P * n.offsetHeight;
|
|
92
92
|
const e = t.getContext("2d");
|
|
@@ -104,7 +104,7 @@ const z = (n, a, d) => {
|
|
|
104
104
|
s(), l.include.forEach((u) => o(u, "#33ff33")), l.exclude.forEach((u) => o(u, "#ff3333"));
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
|
-
},
|
|
107
|
+
}, q = (n, a) => {
|
|
108
108
|
if (!(n == null ? void 0 : n.querySelector("img"))) return;
|
|
109
109
|
let t = !0;
|
|
110
110
|
return {
|
|
@@ -124,7 +124,7 @@ const z = (n, a, d) => {
|
|
|
124
124
|
t = o, o || (i = n.querySelector(".a9s-sam-preview")) == null || i.remove();
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
|
-
},
|
|
127
|
+
}, D = (n, a = {}) => {
|
|
128
128
|
let d = !1, t;
|
|
129
129
|
const e = n.element;
|
|
130
130
|
let s = {
|
|
@@ -133,30 +133,30 @@ const z = (n, a, d) => {
|
|
|
133
133
|
};
|
|
134
134
|
const o = e == null ? void 0 : e.querySelector("img");
|
|
135
135
|
if (!o) return;
|
|
136
|
-
const i = new
|
|
136
|
+
const i = new W();
|
|
137
137
|
let l = null, u = null, y, c;
|
|
138
138
|
const v = () => {
|
|
139
139
|
!l || !u || (d ? (e.addEventListener("pointermove", l), e.addEventListener("pointerdown", u)) : (e.removeEventListener("pointermove", l), e.removeEventListener("pointerdown", u)));
|
|
140
|
-
},
|
|
140
|
+
}, S = L((p) => {
|
|
141
141
|
i.postMessage({ type: "decode_preview", point: p });
|
|
142
142
|
}, 1);
|
|
143
143
|
return N(o).then(({ canvas: p, bounds: w, scale: E }) => {
|
|
144
144
|
const h = (f) => {
|
|
145
|
-
const m = o.naturalWidth / (E * o.offsetWidth), g = o.naturalHeight / (E * o.offsetHeight), { offsetX: b, offsetY:
|
|
145
|
+
const m = o.naturalWidth / (E * o.offsetWidth), g = o.naturalHeight / (E * o.offsetHeight), { offsetX: b, offsetY: M } = f, _ = b * m + w.x, I = M * g + w.y;
|
|
146
146
|
return { x: _, y: I };
|
|
147
147
|
};
|
|
148
148
|
l = (f) => {
|
|
149
149
|
if (s.include.length + s.exclude.length > 0) return;
|
|
150
150
|
const { x: m, y: g } = h(f);
|
|
151
|
-
|
|
151
|
+
S({ x: m, y: g });
|
|
152
152
|
}, u = (f) => {
|
|
153
153
|
const { x: m, y: g } = h(f);
|
|
154
154
|
f.shiftKey ? s.exclude.push({ x: m, y: g }) : s.include.push({ x: m, y: g }), c == null || c.setVisible(!1), y == null || y.setInput(s), i.postMessage({ type: "decode", input: s });
|
|
155
|
-
}, c =
|
|
155
|
+
}, c = q(n.element, w), y = Y(n.element, w, E), i.onmessage = (f) => {
|
|
156
156
|
const { type: m } = f.data;
|
|
157
157
|
if (m === "init_success") {
|
|
158
158
|
console.log("[annotorious-sam] Encoding image...");
|
|
159
|
-
const g =
|
|
159
|
+
const g = O(p);
|
|
160
160
|
i.postMessage({ type: "encode", data: g });
|
|
161
161
|
} else if (m === "encode_success")
|
|
162
162
|
console.log("[annotorious-sam] Encoding complete"), v();
|
|
@@ -172,8 +172,8 @@ const z = (n, a, d) => {
|
|
|
172
172
|
creator: { id: "rainer" },
|
|
173
173
|
created: /* @__PURE__ */ new Date()
|
|
174
174
|
}
|
|
175
|
-
}, { store:
|
|
176
|
-
|
|
175
|
+
}, { store: M, selection: _ } = n.state;
|
|
176
|
+
M.getAnnotation(t) ? M.updateAnnotation(t, b) : M.addAnnotation(b);
|
|
177
177
|
}
|
|
178
178
|
}, i.postMessage({ type: "init" });
|
|
179
179
|
}), {
|
|
@@ -186,6 +186,6 @@ const z = (n, a, d) => {
|
|
|
186
186
|
};
|
|
187
187
|
};
|
|
188
188
|
export {
|
|
189
|
-
|
|
189
|
+
D as mountPlugin
|
|
190
190
|
};
|
|
191
191
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as ne, a as Be, d as Oe,
|
|
1
|
+
import { c as ne, a as Be, d as Oe, M as Ae, j as Me, f as He, s as Ie, g as Le, m as ze, W as ke, b as Ne, v as be } from "../get-image-bounds-CnOHKy6k.js";
|
|
2
2
|
const Ue = (G) => {
|
|
3
3
|
const C = ne.imread(G), e = new ne.Mat(), t = new ne.MatVector(), n = new ne.Mat();
|
|
4
4
|
ne.cvtColor(C, e, ne.COLOR_RGBA2GRAY);
|
|
@@ -2372,23 +2372,23 @@ function Ve() {
|
|
|
2372
2372
|
}
|
|
2373
2373
|
}
|
|
2374
2374
|
e.MouseTracker.gesturePointVelocityTracker = /* @__PURE__ */ function() {
|
|
2375
|
-
var p = [], c = 0, g = 0, w = function(K,
|
|
2376
|
-
return K.hash.toString() +
|
|
2375
|
+
var p = [], c = 0, g = 0, w = function(K, H) {
|
|
2376
|
+
return K.hash.toString() + H.type + H.id.toString();
|
|
2377
2377
|
}, S = function() {
|
|
2378
|
-
var K,
|
|
2379
|
-
for (Pe = de - g, g = de, K = 0; K <
|
|
2378
|
+
var K, H = p.length, ae, re, de = e.now(), Pe, Re, Ce;
|
|
2379
|
+
for (Pe = de - g, g = de, K = 0; K < H; K++)
|
|
2380
2380
|
ae = p[K], re = ae.gPoint, re.direction = Math.atan2(re.currentPos.y - ae.lastPos.y, re.currentPos.x - ae.lastPos.x), Re = ae.lastPos.distanceTo(re.currentPos), ae.lastPos = re.currentPos, Ce = 1e3 * Re / (Pe + 1), re.speed = 0.75 * Ce + 0.25 * re.speed;
|
|
2381
|
-
}, D = function(K,
|
|
2382
|
-
var ae = w(K,
|
|
2381
|
+
}, D = function(K, H) {
|
|
2382
|
+
var ae = w(K, H);
|
|
2383
2383
|
p.push(
|
|
2384
2384
|
{
|
|
2385
2385
|
guid: ae,
|
|
2386
|
-
gPoint:
|
|
2387
|
-
lastPos:
|
|
2386
|
+
gPoint: H,
|
|
2387
|
+
lastPos: H.currentPos
|
|
2388
2388
|
}
|
|
2389
2389
|
), p.length === 1 && (g = e.now(), c = window.setInterval(S, 50));
|
|
2390
|
-
},
|
|
2391
|
-
var ae = w(K,
|
|
2390
|
+
}, M = function(K, H) {
|
|
2391
|
+
var ae = w(K, H), re, de = p.length;
|
|
2392
2392
|
for (re = 0; re < de; re++)
|
|
2393
2393
|
if (p[re].guid === ae) {
|
|
2394
2394
|
p.splice(re, 1), de--, de === 0 && window.clearInterval(c);
|
|
@@ -2397,7 +2397,7 @@ function Ve() {
|
|
|
2397
2397
|
};
|
|
2398
2398
|
return {
|
|
2399
2399
|
addPoint: D,
|
|
2400
|
-
removePoint:
|
|
2400
|
+
removePoint: M
|
|
2401
2401
|
};
|
|
2402
2402
|
}(), e.MouseTracker.captureElement = document, e.MouseTracker.wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : (
|
|
2403
2403
|
// Modern browsers support 'wheel'
|
|
@@ -2499,13 +2499,13 @@ function Ve() {
|
|
|
2499
2499
|
}
|
|
2500
2500
|
};
|
|
2501
2501
|
function r(p) {
|
|
2502
|
-
var c = t[p.hash], g, w, S, D,
|
|
2502
|
+
var c = t[p.hash], g, w, S, D, M, K = c.activePointersLists.length;
|
|
2503
2503
|
for (g = 0; g < K; g++)
|
|
2504
2504
|
if (S = c.activePointersLists[g], S.getLength() > 0) {
|
|
2505
|
-
for (
|
|
2506
|
-
|
|
2507
|
-
for (w = 0; w <
|
|
2508
|
-
ce(p, S,
|
|
2505
|
+
for (M = [], D = S.asArray(), w = 0; w < D.length; w++)
|
|
2506
|
+
M.push(D[w]);
|
|
2507
|
+
for (w = 0; w < M.length; w++)
|
|
2508
|
+
ce(p, S, M[w]);
|
|
2509
2509
|
}
|
|
2510
2510
|
for (g = 0; g < K; g++)
|
|
2511
2511
|
c.activePointersLists.pop();
|
|
@@ -2817,8 +2817,8 @@ function Ve() {
|
|
|
2817
2817
|
m(p, w), c.target === p.element && _(p, g, !1), w.stopPropagation && e.stopEvent(c);
|
|
2818
2818
|
}
|
|
2819
2819
|
function V(p, c) {
|
|
2820
|
-
var g, w, S = c.changedTouches.length, D,
|
|
2821
|
-
g = e.now(),
|
|
2820
|
+
var g, w, S = c.changedTouches.length, D, M = p.getActivePointersListByType("touch");
|
|
2821
|
+
g = e.now(), M.getLength() > c.touches.length - S && e.console.warn("Tracked touch contact count doesn't match event.touches.length");
|
|
2822
2822
|
var K = {
|
|
2823
2823
|
originalEvent: c,
|
|
2824
2824
|
eventType: "pointerdown",
|
|
@@ -2830,7 +2830,7 @@ function Ve() {
|
|
|
2830
2830
|
id: c.changedTouches[w].identifier,
|
|
2831
2831
|
type: "touch",
|
|
2832
2832
|
// Simulate isPrimary
|
|
2833
|
-
isPrimary:
|
|
2833
|
+
isPrimary: M.getLength() === 0,
|
|
2834
2834
|
currentPos: y(c.changedTouches[w]),
|
|
2835
2835
|
currentTime: g
|
|
2836
2836
|
}, b(p, K, D), N(p, K, D, 0), _(p, D, !0);
|
|
@@ -2839,38 +2839,38 @@ function Ve() {
|
|
|
2839
2839
|
function k(p, c) {
|
|
2840
2840
|
var g, w, S = c.changedTouches.length, D;
|
|
2841
2841
|
g = e.now();
|
|
2842
|
-
var
|
|
2842
|
+
var M = {
|
|
2843
2843
|
originalEvent: c,
|
|
2844
2844
|
eventType: "pointerup",
|
|
2845
2845
|
pointerType: "touch",
|
|
2846
2846
|
isEmulated: !1
|
|
2847
2847
|
};
|
|
2848
|
-
for (m(p,
|
|
2848
|
+
for (m(p, M), w = 0; w < S; w++)
|
|
2849
2849
|
D = {
|
|
2850
2850
|
id: c.changedTouches[w].identifier,
|
|
2851
2851
|
type: "touch",
|
|
2852
2852
|
currentPos: y(c.changedTouches[w]),
|
|
2853
2853
|
currentTime: g
|
|
2854
|
-
}, Y(p,
|
|
2855
|
-
|
|
2854
|
+
}, Y(p, M, D, 0), _(p, D, !1), F(p, M, D);
|
|
2855
|
+
M.preventDefault && !M.defaultPrevented && e.cancelEvent(c), M.stopPropagation && e.stopEvent(c);
|
|
2856
2856
|
}
|
|
2857
2857
|
function X(p, c) {
|
|
2858
2858
|
var g, w, S = c.changedTouches.length, D;
|
|
2859
2859
|
g = e.now();
|
|
2860
|
-
var
|
|
2860
|
+
var M = {
|
|
2861
2861
|
originalEvent: c,
|
|
2862
2862
|
eventType: "pointermove",
|
|
2863
2863
|
pointerType: "touch",
|
|
2864
2864
|
isEmulated: !1
|
|
2865
2865
|
};
|
|
2866
|
-
for (m(p,
|
|
2866
|
+
for (m(p, M), w = 0; w < S; w++)
|
|
2867
2867
|
D = {
|
|
2868
2868
|
id: c.changedTouches[w].identifier,
|
|
2869
2869
|
type: "touch",
|
|
2870
2870
|
currentPos: y(c.changedTouches[w]),
|
|
2871
2871
|
currentTime: g
|
|
2872
|
-
}, $(p,
|
|
2873
|
-
|
|
2872
|
+
}, $(p, M, D);
|
|
2873
|
+
M.preventDefault && !M.defaultPrevented && e.cancelEvent(c), M.stopPropagation && e.stopEvent(c);
|
|
2874
2874
|
}
|
|
2875
2875
|
function te(p, c) {
|
|
2876
2876
|
var g = c.changedTouches.length, w, S, D = {
|
|
@@ -3171,7 +3171,7 @@ function Ve() {
|
|
|
3171
3171
|
});
|
|
3172
3172
|
}
|
|
3173
3173
|
function N(p, c, g, w) {
|
|
3174
|
-
var S = t[p.hash], D = p.getActivePointersListByType(g.type),
|
|
3174
|
+
var S = t[p.hash], D = p.getActivePointersListByType(g.type), M;
|
|
3175
3175
|
if (typeof c.originalEvent.buttons < "u" ? D.buttons = c.originalEvent.buttons : w === 0 ? D.buttons |= 1 : w === 1 ? D.buttons |= 4 : w === 2 ? D.buttons |= 2 : w === 3 ? D.buttons |= 8 : w === 4 ? D.buttons |= 16 : w === 5 && (D.buttons |= 32), w !== 0) {
|
|
3176
3176
|
c.shouldCapture = !1, c.shouldReleaseCapture = !1, p.nonPrimaryPressHandler && !c.preventGesture && !c.defaultPrevented && (c.preventDefault = !0, p.nonPrimaryPressHandler(
|
|
3177
3177
|
{
|
|
@@ -3187,7 +3187,7 @@ function Ve() {
|
|
|
3187
3187
|
));
|
|
3188
3188
|
return;
|
|
3189
3189
|
}
|
|
3190
|
-
|
|
3190
|
+
M = D.getById(g.id), M ? (M.insideElementPressed = !0, M.insideElement = !0, M.originalTarget = c.originalEvent.target, M.contactPos = g.currentPos, M.contactTime = g.currentTime, M.lastPos = M.currentPos, M.lastTime = M.currentTime, M.currentPos = g.currentPos, M.currentTime = g.currentTime, g = M) : (g.captured = !1, g.insideElementPressed = !0, g.insideElement = !0, g.originalTarget = c.originalEvent.target, pe(D, g)), D.addContact(), !c.preventGesture && !c.defaultPrevented ? (c.shouldCapture = !0, c.shouldReleaseCapture = !1, c.preventDefault = !0, (p.dragHandler || p.dragEndHandler || p.pinchHandler) && e.MouseTracker.gesturePointVelocityTracker.addPoint(p, g), D.contacts === 1 ? p.pressHandler && !c.preventGesture && p.pressHandler(
|
|
3191
3191
|
{
|
|
3192
3192
|
eventSource: p,
|
|
3193
3193
|
pointerType: g.type,
|
|
@@ -3200,7 +3200,7 @@ function Ve() {
|
|
|
3200
3200
|
) : D.contacts === 2 && p.pinchHandler && g.type === "touch" && (S.pinchGPoints = D.asArray(), S.lastPinchDist = S.currentPinchDist = S.pinchGPoints[0].currentPos.distanceTo(S.pinchGPoints[1].currentPos), S.lastPinchCenter = S.currentPinchCenter = E(S.pinchGPoints[0].currentPos, S.pinchGPoints[1].currentPos))) : (c.shouldCapture = !1, c.shouldReleaseCapture = !1);
|
|
3201
3201
|
}
|
|
3202
3202
|
function Y(p, c, g, w) {
|
|
3203
|
-
var S = t[p.hash], D = p.getActivePointersListByType(g.type),
|
|
3203
|
+
var S = t[p.hash], D = p.getActivePointersListByType(g.type), M, K, H, ae = !1, re;
|
|
3204
3204
|
if (typeof c.originalEvent.buttons < "u" ? D.buttons = c.originalEvent.buttons : w === 0 ? D.buttons ^= -2 : w === 1 ? D.buttons ^= -5 : w === 2 ? D.buttons ^= -3 : w === 3 ? D.buttons ^= -9 : w === 4 ? D.buttons ^= -17 : w === 5 && (D.buttons ^= -33), c.shouldCapture = !1, w !== 0) {
|
|
3205
3205
|
c.shouldReleaseCapture = !1, p.nonPrimaryReleaseHandler && !c.preventGesture && !c.defaultPrevented && (c.preventDefault = !0, p.nonPrimaryReleaseHandler(
|
|
3206
3206
|
{
|
|
@@ -3216,70 +3216,70 @@ function Ve() {
|
|
|
3216
3216
|
));
|
|
3217
3217
|
return;
|
|
3218
3218
|
}
|
|
3219
|
-
|
|
3219
|
+
H = D.getById(g.id), H ? (D.removeContact(), H.captured && (ae = !0), H.lastPos = H.currentPos, H.lastTime = H.currentTime, H.currentPos = g.currentPos, H.currentTime = g.currentTime, H.insideElement || ce(p, D, H), M = H.currentPos, K = H.currentTime) : (g.captured = !1, g.insideElementPressed = !1, g.insideElement = !0, pe(D, g), H = g), !c.preventGesture && !c.defaultPrevented && (ae ? (c.shouldReleaseCapture = !0, c.preventDefault = !0, (p.dragHandler || p.dragEndHandler || p.pinchHandler) && e.MouseTracker.gesturePointVelocityTracker.removePoint(p, H), D.contacts === 0 ? (p.releaseHandler && M && p.releaseHandler(
|
|
3220
3220
|
{
|
|
3221
3221
|
eventSource: p,
|
|
3222
|
-
pointerType:
|
|
3223
|
-
position: x(
|
|
3222
|
+
pointerType: H.type,
|
|
3223
|
+
position: x(M, p.element),
|
|
3224
3224
|
buttons: D.buttons,
|
|
3225
|
-
insideElementPressed:
|
|
3226
|
-
insideElementReleased:
|
|
3227
|
-
isTouchEvent:
|
|
3225
|
+
insideElementPressed: H.insideElementPressed,
|
|
3226
|
+
insideElementReleased: H.insideElement,
|
|
3227
|
+
isTouchEvent: H.type === "touch",
|
|
3228
3228
|
originalEvent: c.originalEvent,
|
|
3229
3229
|
userData: p.userData
|
|
3230
3230
|
}
|
|
3231
3231
|
), p.dragEndHandler && S.sentDragEvent && p.dragEndHandler(
|
|
3232
3232
|
{
|
|
3233
3233
|
eventSource: p,
|
|
3234
|
-
pointerType:
|
|
3235
|
-
position: x(
|
|
3236
|
-
speed:
|
|
3237
|
-
direction:
|
|
3234
|
+
pointerType: H.type,
|
|
3235
|
+
position: x(H.currentPos, p.element),
|
|
3236
|
+
speed: H.speed,
|
|
3237
|
+
direction: H.direction,
|
|
3238
3238
|
shift: c.originalEvent.shiftKey,
|
|
3239
|
-
isTouchEvent:
|
|
3239
|
+
isTouchEvent: H.type === "touch",
|
|
3240
3240
|
originalEvent: c.originalEvent,
|
|
3241
3241
|
userData: p.userData
|
|
3242
3242
|
}
|
|
3243
|
-
), S.sentDragEvent = !1, (p.clickHandler || p.dblClickHandler) &&
|
|
3243
|
+
), S.sentDragEvent = !1, (p.clickHandler || p.dblClickHandler) && H.insideElement && (re = K - H.contactTime <= p.clickTimeThreshold && H.contactPos.distanceTo(M) <= p.clickDistThreshold, p.clickHandler && p.clickHandler(
|
|
3244
3244
|
{
|
|
3245
3245
|
eventSource: p,
|
|
3246
|
-
pointerType:
|
|
3247
|
-
position: x(
|
|
3246
|
+
pointerType: H.type,
|
|
3247
|
+
position: x(H.currentPos, p.element),
|
|
3248
3248
|
quick: re,
|
|
3249
3249
|
shift: c.originalEvent.shiftKey,
|
|
3250
|
-
isTouchEvent:
|
|
3250
|
+
isTouchEvent: H.type === "touch",
|
|
3251
3251
|
originalEvent: c.originalEvent,
|
|
3252
|
-
originalTarget:
|
|
3252
|
+
originalTarget: H.originalTarget,
|
|
3253
3253
|
userData: p.userData
|
|
3254
3254
|
}
|
|
3255
|
-
), p.dblClickHandler && re && (D.clicks++, D.clicks === 1 ? (S.lastClickPos =
|
|
3255
|
+
), p.dblClickHandler && re && (D.clicks++, D.clicks === 1 ? (S.lastClickPos = M, S.dblClickTimeOut = setTimeout(function() {
|
|
3256
3256
|
D.clicks = 0;
|
|
3257
|
-
}, p.dblClickTimeThreshold)) : D.clicks === 2 && (clearTimeout(S.dblClickTimeOut), D.clicks = 0, S.lastClickPos.distanceTo(
|
|
3257
|
+
}, p.dblClickTimeThreshold)) : D.clicks === 2 && (clearTimeout(S.dblClickTimeOut), D.clicks = 0, S.lastClickPos.distanceTo(M) <= p.dblClickDistThreshold && p.dblClickHandler(
|
|
3258
3258
|
{
|
|
3259
3259
|
eventSource: p,
|
|
3260
|
-
pointerType:
|
|
3261
|
-
position: x(
|
|
3260
|
+
pointerType: H.type,
|
|
3261
|
+
position: x(H.currentPos, p.element),
|
|
3262
3262
|
shift: c.originalEvent.shiftKey,
|
|
3263
|
-
isTouchEvent:
|
|
3263
|
+
isTouchEvent: H.type === "touch",
|
|
3264
3264
|
originalEvent: c.originalEvent,
|
|
3265
3265
|
userData: p.userData
|
|
3266
3266
|
}
|
|
3267
|
-
), S.lastClickPos = null)))) : D.contacts === 2 && p.pinchHandler &&
|
|
3267
|
+
), S.lastClickPos = null)))) : D.contacts === 2 && p.pinchHandler && H.type === "touch" && (S.pinchGPoints = D.asArray(), S.lastPinchDist = S.currentPinchDist = S.pinchGPoints[0].currentPos.distanceTo(S.pinchGPoints[1].currentPos), S.lastPinchCenter = S.currentPinchCenter = E(S.pinchGPoints[0].currentPos, S.pinchGPoints[1].currentPos))) : (c.shouldReleaseCapture = !1, p.releaseHandler && M && (p.releaseHandler(
|
|
3268
3268
|
{
|
|
3269
3269
|
eventSource: p,
|
|
3270
|
-
pointerType:
|
|
3271
|
-
position: x(
|
|
3270
|
+
pointerType: H.type,
|
|
3271
|
+
position: x(M, p.element),
|
|
3272
3272
|
buttons: D.buttons,
|
|
3273
|
-
insideElementPressed:
|
|
3274
|
-
insideElementReleased:
|
|
3275
|
-
isTouchEvent:
|
|
3273
|
+
insideElementPressed: H.insideElementPressed,
|
|
3274
|
+
insideElementReleased: H.insideElement,
|
|
3275
|
+
isTouchEvent: H.type === "touch",
|
|
3276
3276
|
originalEvent: c.originalEvent,
|
|
3277
3277
|
userData: p.userData
|
|
3278
3278
|
}
|
|
3279
3279
|
), c.preventDefault = !0)));
|
|
3280
3280
|
}
|
|
3281
3281
|
function $(p, c, g) {
|
|
3282
|
-
var w = t[p.hash], S = p.getActivePointersListByType(g.type), D,
|
|
3282
|
+
var w = t[p.hash], S = p.getActivePointersListByType(g.type), D, M, K;
|
|
3283
3283
|
if (typeof c.originalEvent.buttons < "u" && (S.buttons = c.originalEvent.buttons), D = S.getById(g.id), D)
|
|
3284
3284
|
D.lastPos = D.currentPos, D.lastTime = D.currentTime, D.currentPos = g.currentPos, D.currentTime = g.currentTime;
|
|
3285
3285
|
else
|
|
@@ -3320,13 +3320,13 @@ function Ve() {
|
|
|
3320
3320
|
originalEvent: c.originalEvent,
|
|
3321
3321
|
userData: p.userData
|
|
3322
3322
|
}
|
|
3323
|
-
), c.preventDefault = !0, w.sentDragEvent = !0)) : S.contacts === 2 && (p.moveHandler && (
|
|
3323
|
+
), c.preventDefault = !0, w.sentDragEvent = !0)) : S.contacts === 2 && (p.moveHandler && (M = S.asArray(), p.moveHandler(
|
|
3324
3324
|
{
|
|
3325
3325
|
eventSource: p,
|
|
3326
|
-
pointerType:
|
|
3327
|
-
position: x(E(
|
|
3326
|
+
pointerType: M[0].type,
|
|
3327
|
+
position: x(E(M[0].currentPos, M[1].currentPos), p.element),
|
|
3328
3328
|
buttons: S.buttons,
|
|
3329
|
-
isTouchEvent:
|
|
3329
|
+
isTouchEvent: M[0].type === "touch",
|
|
3330
3330
|
originalEvent: c.originalEvent,
|
|
3331
3331
|
userData: p.userData
|
|
3332
3332
|
}
|
|
@@ -12443,7 +12443,7 @@ function Ve() {
|
|
|
12443
12443
|
var je = Ve();
|
|
12444
12444
|
const Ze = /* @__PURE__ */ Oe(je), qe = (G, C = [255, 255, 255, 255], e = [0, 0, 0, 255]) => {
|
|
12445
12445
|
const t = G.masks, [n, i, r, s] = t.dims, o = G.iou_predictions.cpuData, a = o.indexOf(Math.max(...o));
|
|
12446
|
-
return
|
|
12446
|
+
return He(
|
|
12447
12447
|
Ie(t, a),
|
|
12448
12448
|
r,
|
|
12449
12449
|
s,
|
|
@@ -12465,7 +12465,7 @@ const Ze = /* @__PURE__ */ Oe(je), qe = (G, C = [255, 255, 255, 255], e = [0, 0,
|
|
|
12465
12465
|
const y = t.viewport.pointFromPixel(new Ze.Point(v[0], v[1])), { x: T, y: x } = t.viewport.viewportToImageCoordinates(y.x, y.y);
|
|
12466
12466
|
return [T, x];
|
|
12467
12467
|
}), f = {
|
|
12468
|
-
type:
|
|
12468
|
+
type: Me.POLYGON,
|
|
12469
12469
|
geometry: {
|
|
12470
12470
|
bounds: Ae(d),
|
|
12471
12471
|
points: d
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@annotorious/plugin-segment-anything",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "A smart polygon selection tool based on SegmentAnything 2",
|
|
5
5
|
"author": "Rainer Simon",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
"./annotorious-plugin-smart-tools.css": "./dist/annotorious-plugin-sam.css"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@types/node": "^22.13.
|
|
36
|
+
"@types/node": "^22.13.14",
|
|
37
37
|
"@types/openseadragon": "^3.0.10",
|
|
38
38
|
"typescript": "^5.8.2",
|
|
39
|
-
"vite": "^6.2.
|
|
39
|
+
"vite": "^6.2.3",
|
|
40
40
|
"vite-plugin-dts": "^4.5.3",
|
|
41
41
|
"vite-plugin-static-copy": "^2.3.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@annotorious/annotorious": "^3.
|
|
45
|
-
"@annotorious/openseadragon": "^3.
|
|
44
|
+
"@annotorious/annotorious": "^3.3.3",
|
|
45
|
+
"@annotorious/openseadragon": "^3.3.3",
|
|
46
46
|
"openseadragon": "^4.0.0 || ^5.0.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|