@annotorious/plugin-segment-anything 0.1.14 → 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, O as C, G as O, g as T, W as H, b as W, v as V } from "./get-image-bounds-B0QYmG5-.js";
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 M = o.get(c), A = 5e-3 * r.arcLength(M, !0), x = new r.Mat();
51
- r.approxPolyDP(M, x, A, !0);
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: O.POLYGON,
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 } = T(
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, G = (n, a, d) => {
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
- }, Y = (n, a) => {
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
- }, B = (n, a = {}) => {
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 H();
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
- }, M = L((p) => {
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: S } = f, _ = b * m + w.x, I = S * g + w.y;
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
- M({ x: m, y: g });
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 = Y(n.element, w), y = G(n.element, w, E), i.onmessage = (f) => {
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 = W(p);
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: S, selection: _ } = n.state;
176
- S.getAnnotation(t) ? S.updateAnnotation(t, b) : S.addAnnotation(b);
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
- B as mountPlugin
189
+ D as mountPlugin
190
190
  };
191
191
  //# sourceMappingURL=index.js.map