@glodon-aiot/dataset-annotation 3.25.1-alpha.6 → 3.25.1-alpha.7

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.
@@ -9,8 +9,8 @@ var Ye = Math.pow, ke = (r, m, s) => m in r ? De(r, m, { enumerable: !0, configu
9
9
  for (var s of fe(m))
10
10
  Ee.call(m, s) && ke(r, s, m[s]);
11
11
  return r;
12
- }, re = (r, m) => Re(r, Ue(m));
13
- var he = (r, m) => {
12
+ }, ie = (r, m) => Re(r, Ue(m));
13
+ var me = (r, m) => {
14
14
  var s = {};
15
15
  for (var p in r)
16
16
  Ce.call(r, p) && m.indexOf(p) < 0 && (s[p] = r[p]);
@@ -23,7 +23,7 @@ import { jsx as T, jsxs as Xe } from "react/jsx-runtime";
23
23
  import { useState as U, useEffect as j } from "react";
24
24
  import { fabric as P } from "fabric";
25
25
  import { useKeyPress as le } from "ahooks";
26
- import { Spin as $e, Space as Ie, Radio as me, Tooltip as ie, Button as de } from "antd";
26
+ import { Spin as $e, Space as Ie, Radio as pe, Tooltip as ne, Button as de } from "antd";
27
27
  import Me from "react-dom";
28
28
  import "./style.less.mjs";
29
29
  import je from "./images/delete.png.mjs";
@@ -59,14 +59,14 @@ function Oe(r, m) {
59
59
  const I = r.getZoom(), h = r.viewportTransform ? r.viewportTransform[4] / I : 0, O = r.viewportTransform ? r.viewportTransform[5] / I : 0, A = (e.e.offsetX > r.getWidth() ? r.getWidth() / I : e.e.offsetX / I) - h, B = (e.e.offsetY > r.getHeight() ? r.getHeight() / I : e.e.offsetY / I) - O;
60
60
  if (a = Math.abs(A - p), g = Math.abs(B - s), a === 0 || g === 0)
61
61
  return;
62
- const k = s > B ? B : s, Z = p > A ? A : p, C = a, N = g, W = [{
62
+ const k = s > B ? B : s, Z = p > A ? A : p, E = a, N = g, W = [{
63
63
  x: Z,
64
64
  y: k
65
65
  }, {
66
- x: Z + C,
66
+ x: Z + E,
67
67
  y: k
68
68
  }, {
69
- x: Z + C,
69
+ x: Z + E,
70
70
  y: k + N
71
71
  }, {
72
72
  x: Z,
@@ -81,13 +81,13 @@ function Oe(r, m) {
81
81
  e.target;
82
82
  });
83
83
  }
84
- function pe(r, m, s) {
84
+ function ae(r, m, s) {
85
85
  const p = {
86
86
  type: "roof",
87
87
  background: "",
88
88
  border: ""
89
89
  };
90
- let a, g = [], f = [], b = [], X = [], e = 0, I = null, h, O, A, B = !1, k, Z, C;
90
+ let a, g = [], f = [], b = [], X = [], e = 0, I = null, h, O, A, B = !1, k, Z, E;
91
91
  const N = r.getZoom(), W = 2 / N, J = [7 / N, 10 / N];
92
92
  r.on("mouse:down", (l) => {
93
93
  var K;
@@ -175,7 +175,7 @@ function pe(r, m, s) {
175
175
  stroke: "#508BEE",
176
176
  left: l,
177
177
  top: u
178
- }), L(), m && m(I, C)) : pe(r, m, 4);
178
+ }), L(), m && m(I, E)) : ae(r, m, 4);
179
179
  }, G = (l) => {
180
180
  let u = 999999;
181
181
  for (let w = 0; w < e; w++)
@@ -266,13 +266,13 @@ const ue = (r) => {
266
266
  I();
267
267
  }
268
268
  }, I = () => {
269
- var Z, C, N, W;
269
+ var Z, E, N, W;
270
270
  if (!f || !X || !a)
271
271
  return;
272
272
  const h = X.getObjects().find((J) => J.type === "rect");
273
273
  if (!h)
274
274
  return;
275
- const O = h.height ? h.height : void 0, A = h.width ? h.width : void 0, B = ((Z = f.aCoords) == null ? void 0 : Z.tl.y) !== void 0 && O !== void 0 && h.scaleY ? ((C = f.aCoords) == null ? void 0 : C.tl.y) - O / a.getZoom() : void 0, k = ((N = f.aCoords) == null ? void 0 : N.tl.x) !== void 0 ? (W = f.aCoords) == null ? void 0 : W.tl.x : void 0;
275
+ const O = h.height ? h.height : void 0, A = h.width ? h.width : void 0, B = ((Z = f.aCoords) == null ? void 0 : Z.tl.y) !== void 0 && O !== void 0 && h.scaleY ? ((E = f.aCoords) == null ? void 0 : E.tl.y) - O / a.getZoom() : void 0, k = ((N = f.aCoords) == null ? void 0 : N.tl.x) !== void 0 ? (W = f.aCoords) == null ? void 0 : W.tl.x : void 0;
276
276
  X.set({
277
277
  top: B,
278
278
  left: k,
@@ -301,7 +301,7 @@ const ue = (r) => {
301
301
  onChange: a,
302
302
  disabled: g,
303
303
  renderLabelItem: f
304
- } = r, [b, X] = U(!0), [e, I] = U(), [h, O] = U({}), [A, B] = U({}), [k, Z] = U(), [C, N] = U({
304
+ } = r, [b, X] = U(!0), [e, I] = U(), [h, O] = U({}), [A, B] = U({}), [k, Z] = U(), [E, N] = U({
305
305
  left: 0,
306
306
  top: 0
307
307
  }), [W, J] = U([1, 1]), [x, L] = U(), [d, G] = U(null), [oe, Q] = U(), [y, l] = U([]), [u, w] = U(!0), [S, D] = U(), [z, q] = U("rect"), [K, F] = U(g || !1);
@@ -315,9 +315,9 @@ const ue = (r) => {
315
315
  uuid: t,
316
316
  box: o,
317
317
  words: c,
318
- type: E,
318
+ type: C,
319
319
  catagoryId: Y
320
- } = R, $ = he(R, [
320
+ } = R, $ = me(R, [
321
321
  "uuid",
322
322
  "box",
323
323
  "words",
@@ -326,20 +326,20 @@ const ue = (r) => {
326
326
  ]);
327
327
  return V({
328
328
  uuid: n.uuid,
329
- box: ((M = n.box) == null ? void 0 : M.map((H) => [H[0] + C.left, H[1] + C.top])) || [],
329
+ box: ((M = n.box) == null ? void 0 : M.map((H) => [H[0] + E.left, H[1] + E.top])) || [],
330
330
  words: n.words,
331
331
  type: (v = n.type) == null ? void 0 : v.toLowerCase(),
332
332
  catagoryId: n.catagoryId
333
333
  }, $);
334
334
  }));
335
- }, [p, C]), j(() => {
335
+ }, [p, E]), j(() => {
336
336
  if (e && u) {
337
337
  const i = e.getActiveObject();
338
338
  if (i) {
339
339
  i === (x == null ? void 0 : x.polygon) && (e == null || e.remove(x == null ? void 0 : x.text), L(void 0)), e.remove(i), e.renderAll();
340
340
  const n = y.findIndex((t) => h[t.uuid] === i);
341
- n > -1 && (h[y[n].uuid] && (e == null || e.remove(h[y[n].uuid])), y.splice(n, 1), l([...y]), a([...y.map((t) => re(V({}, t), {
342
- box: t.box.map((o) => [o[0] - C.left, o[1] - C.top])
341
+ n > -1 && (h[y[n].uuid] && (e == null || e.remove(h[y[n].uuid])), y.splice(n, 1), l([...y]), a([...y.map((t) => ie(V({}, t), {
342
+ box: t.box.map((o) => [o[0] - E.left, o[1] - E.top])
343
343
  }))]));
344
344
  } else
345
345
  console.log("no active object", e.selection), e.discardActiveObject(), e.requestRenderAll();
@@ -385,9 +385,9 @@ const ue = (r) => {
385
385
  const i = k == null ? void 0 : k.getElement();
386
386
  if (!(i != null && i.width) || !(i != null && i.height))
387
387
  return;
388
- const n = i.width / i.height, t = s.parentElement.offsetWidth, o = s.parentElement.offsetHeight, c = t / i.width, E = o / i.height;
388
+ const n = i.width / i.height, t = s.parentElement.offsetWidth, o = s.parentElement.offsetHeight, c = t / i.width, C = o / i.height;
389
389
  let Y = [t, o];
390
- c > E ? Y = [o * n, o] : Y = [t, t / n];
390
+ c > C ? Y = [o * n, o] : Y = [t, t / n];
391
391
  const $ = Y[0] / i.width, R = Y[1] / i.height, M = Math.min($, R);
392
392
  J([M, M]);
393
393
  const v = new P.Canvas(s, {
@@ -396,7 +396,7 @@ const ue = (r) => {
396
396
  height: o
397
397
  });
398
398
  if (v == null || v.setZoom(M), v == null || v.renderAll(), v && k) {
399
- const se = (t - Y[0]) / M / 2, ae = (o - Y[1]) / M / 2;
399
+ const re = (t - Y[0]) / M / 2, he = (o - Y[1]) / M / 2;
400
400
  v.setBackgroundImage(
401
401
  k,
402
402
  v.renderAll.bind(v),
@@ -404,12 +404,12 @@ const ue = (r) => {
404
404
  {
405
405
  originX: "left",
406
406
  originY: "top",
407
- left: se,
408
- top: ae
407
+ left: re,
408
+ top: he
409
409
  }
410
410
  ), N({
411
- left: se,
412
- top: ae
411
+ left: re,
412
+ top: he
413
413
  }), G(null), l((H = p == null ? void 0 : p.filter((ee) => !!ee)) == null ? void 0 : H.map((ee) => {
414
414
  var xe, we;
415
415
  const ye = ee, {
@@ -418,7 +418,7 @@ const ue = (r) => {
418
418
  words: _e,
419
419
  type: Je,
420
420
  catagoryId: Qe
421
- } = ye, Ze = he(ye, [
421
+ } = ye, Ze = me(ye, [
422
422
  "uuid",
423
423
  "box",
424
424
  "words",
@@ -427,7 +427,7 @@ const ue = (r) => {
427
427
  ]);
428
428
  return V({
429
429
  uuid: ee.uuid,
430
- box: ((xe = ee.box) == null ? void 0 : xe.map((be) => [be[0] + C.left, be[1] + C.top])) || [],
430
+ box: ((xe = ee.box) == null ? void 0 : xe.map((be) => [be[0] + re, be[1] + he])) || [],
431
431
  words: ee.words,
432
432
  type: (we = ee.type) == null ? void 0 : we.toLowerCase(),
433
433
  catagoryId: ee.catagoryId
@@ -437,19 +437,19 @@ const ue = (r) => {
437
437
  }, [k]), j(() => {
438
438
  b || !e || (ce(e, y, oe), F((i) => (i ? e.getObjects().forEach((n) => n.set("evented", !1)) : e.getObjects().forEach((n) => n.set("evented", !0)), i)));
439
439
  }, [y, e, oe, b]), j(() => {
440
- oe || a([...y.map((i) => re(V({}, i), {
441
- box: i.box.map((n) => [n[0] - C.left, n[1] - C.top])
440
+ oe || a([...y.map((i) => ie(V({}, i), {
441
+ box: i.box.map((n) => [n[0] - E.left, n[1] - E.top])
442
442
  }))]);
443
443
  }, [oe]);
444
444
  const ce = (i, n, t = "") => {
445
445
  O((o) => {
446
446
  if (n == null || n.map((c) => {
447
447
  var $, R;
448
- const [E, Y] = qe(($ = c.box) == null ? void 0 : $.map((M) => ({
448
+ const [C, Y] = qe(($ = c.box) == null ? void 0 : $.map((M) => ({
449
449
  x: M[0],
450
450
  y: M[1]
451
451
  })), ((R = c.type) == null ? void 0 : R.toLowerCase()) === "key" ? [255, 193, 0] : [80, 139, 238], i, f ? () => (console.log(c), f(c)) : void 0);
452
- o[c.uuid] ? He(i, o[c.uuid], E, A[c.uuid]) : E.canvas !== i && (i.add(E), i.add(Y)), o[c.uuid] = E, O(() => o), A[c.uuid] = Y, B(() => A);
452
+ o[c.uuid] ? He(i, o[c.uuid], C, A[c.uuid]) : C.canvas !== i && (i.add(C), i.add(Y)), o[c.uuid] = C, O(() => o), A[c.uuid] = Y, B(() => A);
453
453
  }), t && (!d || d !== i.getActiveObject()))
454
454
  try {
455
455
  i == null || i.setActiveObject(o[t]), G(o[t]);
@@ -462,17 +462,17 @@ const ue = (r) => {
462
462
  j(() => {
463
463
  const n = document.createElement("img");
464
464
  n.src = je, n.setAttribute("style", "background: rgba(0, 0, 0, 0.45)");
465
- function t(c, E, Y, $, R) {
466
- c.save(), c.translate(E, Y), c.rotate(P.util.degreesToRadians(R.angle)), c.beginPath(), c.arc(0, 0, 12, 0, 2 * Math.PI), c.fillStyle = "rgba(0, 0, 0, 0.45)", c.fill(), c.strokeStyle = "rgba(0, 0, 0, 0)", c.stroke(), c.drawImage(n, -24 / 2, -24 / 2, 24, 24), c.restore();
465
+ function t(c, C, Y, $, R) {
466
+ c.save(), c.translate(C, Y), c.rotate(P.util.degreesToRadians(R.angle)), c.beginPath(), c.arc(0, 0, 12, 0, 2 * Math.PI), c.fillStyle = "rgba(0, 0, 0, 0.45)", c.fill(), c.strokeStyle = "rgba(0, 0, 0, 0)", c.stroke(), c.drawImage(n, -24 / 2, -24 / 2, 24, 24), c.restore();
467
467
  }
468
- const o = (c, E, Y, $) => {
468
+ const o = (c, C, Y, $) => {
469
469
  var M;
470
- const R = E.target;
470
+ const R = C.target;
471
471
  if (R) {
472
472
  R === (x == null ? void 0 : x.polygon) && L(void 0), e == null || e.remove(R), e == null || e.renderAll();
473
473
  const v = y.findIndex((H) => h[H.uuid].left === R.left && h[H.uuid].top === R.top);
474
- console.log(e), v > -1 && (h[y[v].uuid] && (e == null || e.remove(h[y[v].uuid]), (M = A[y[v].uuid]) == null || M.remove()), y.splice(v, 1), a([...y.map((H) => re(V({}, H), {
475
- box: H.box.map((se) => [se[0] - C.left, se[1] - C.top])
474
+ console.log(e), v > -1 && (h[y[v].uuid] && (e == null || e.remove(h[y[v].uuid]), (M = A[y[v].uuid]) == null || M.remove()), y.splice(v, 1), a([...y.map((H) => ie(V({}, H), {
475
+ box: H.box.map((re) => [re[0] - E.left, re[1] - E.top])
476
476
  }))]));
477
477
  }
478
478
  return !1;
@@ -500,11 +500,11 @@ const ue = (r) => {
500
500
  uuid: x.uuid,
501
501
  box: ((i = x.polygon.points) == null ? void 0 : i.map((t) => [t.x, t.y])) || [],
502
502
  words: x.value || ""
503
- }]), a([...y.map((t) => re(V({}, t), {
504
- box: t.box.map((o) => [o[0] - C.left, o[1] - C.top])
503
+ }]), a([...y.map((t) => ie(V({}, t), {
504
+ box: t.box.map((o) => [o[0] - E.left, o[1] - E.top])
505
505
  })), {
506
506
  uuid: x.uuid,
507
- box: ((n = x.polygon.points) == null ? void 0 : n.map((t) => [t.x - C.left, t.y - C.top])) || [],
507
+ box: ((n = x.polygon.points) == null ? void 0 : n.map((t) => [t.x - E.left, t.y - E.top])) || [],
508
508
  words: x.value || ""
509
509
  }]), e == null || e.remove(x.text), e == null || e.remove(x.polygon), L(void 0), Q(x.uuid));
510
510
  }, [x]);
@@ -529,33 +529,33 @@ const ue = (r) => {
529
529
  return;
530
530
  }
531
531
  console.log("evented", !0, e.getObjects()), e.getObjects().forEach((c) => c.set("evented", !0)), e.defaultCursor = "default", e.setCursor("default");
532
- const i = (c, E) => {
532
+ const i = (c, C) => {
533
533
  x && (e == null || e.remove(x.text), e == null || e.remove(x.polygon)), L({
534
534
  polygon: c,
535
- text: E,
535
+ text: C,
536
536
  uuid: Te()
537
537
  });
538
538
  };
539
- z === "rect" ? Oe(e, i) : z === "quadri" && pe(e, i, 4);
539
+ z === "rect" ? Oe(e, i) : z === "quadri" && ae(e, i, 4);
540
540
  const n = (c) => {
541
541
  var Y;
542
542
  G(e.getActiveObject());
543
- const E = e.getActiveObject();
544
- E == null || E.set({
543
+ const C = e.getActiveObject();
544
+ C == null || C.set({
545
545
  borderColor: "#508BEE",
546
546
  cornerColor: "white",
547
547
  cornerSize: 7,
548
548
  transparentCorners: !1,
549
549
  cornerStrokeColor: "#508BEE"
550
550
  }), (Y = Object.keys(h)) == null || Y.map(($) => {
551
- E === h[$] && Q($);
551
+ C === h[$] && Q($);
552
552
  });
553
553
  }, t = (c) => {
554
554
  var Y;
555
555
  ue(e), G(e.getActiveObject());
556
- const E = e.getActiveObject();
556
+ const C = e.getActiveObject();
557
557
  (Y = Object.keys(h)) == null || Y.map(($) => {
558
- E === h[$] && Q($);
558
+ C === h[$] && Q($);
559
559
  });
560
560
  }, o = () => {
561
561
  G(null), Q(void 0);
@@ -588,11 +588,11 @@ const ue = (r) => {
588
588
  const o = y.findIndex((c) => c.uuid === t);
589
589
  if (o > -1) {
590
590
  const c = ve(i);
591
- y[o].box = (c == null ? void 0 : c.map((E) => [E.x, E.y])) || [];
591
+ y[o].box = (c == null ? void 0 : c.map((C) => [C.x, C.y])) || [];
592
592
  }
593
593
  }
594
- }), l([...y]), a([...y.map((t) => re(V({}, t), {
595
- box: t.box.map((o) => [o[0] - C.left < 1e-11 ? 0 : o[0] - C.left, o[1] - C.top < 1e-11 ? 0 : o[1] - C.top])
594
+ }), l([...y]), a([...y.map((t) => ie(V({}, t), {
595
+ box: t.box.map((o) => [o[0] - E.left < 1e-11 ? 0 : o[0] - E.left, o[1] - E.top < 1e-11 ? 0 : o[1] - E.top])
596
596
  }))]);
597
597
  }), d == null || d.on("moving", (i) => {
598
598
  var t;
@@ -601,8 +601,8 @@ const ue = (r) => {
601
601
  const n = d;
602
602
  e.getZoom(), (t = Object.keys(h)) == null || t.map((o) => {
603
603
  if (n === h[o]) {
604
- const c = y.findIndex((Y) => Y.uuid === o), E = ve(n);
605
- y[c].box = (E == null ? void 0 : E.map((Y) => [Y.x, Y.y])) || [];
604
+ const c = y.findIndex((Y) => Y.uuid === o), C = ve(n);
605
+ y[c].box = (C == null ? void 0 : C.map((Y) => [Y.x, Y.y])) || [];
606
606
  }
607
607
  });
608
608
  }), () => {
@@ -618,12 +618,12 @@ const ue = (r) => {
618
618
  uuid: Te()
619
619
  });
620
620
  };
621
- ue(e), z === "rect" ? Oe(e, i) : z === "quadri" && pe(e, i, 4);
621
+ ue(e), z === "rect" ? Oe(e, i) : z === "quadri" && ae(e, i, 4);
622
622
  }
623
- d == null || d.on("moving", ne), d == null || d.on("scaling", ne), d == null || d.on("rotating", ne), d == null || d.on("skewing", ne), d == null || d.on("resizing", ne);
623
+ d == null || d.on("moving", se), d == null || d.on("scaling", se), d == null || d.on("rotating", se), d == null || d.on("skewing", se), d == null || d.on("resizing", se);
624
624
  }
625
625
  }, [d, z]);
626
- const ne = (i) => {
626
+ const se = (i) => {
627
627
  ze(i);
628
628
  }, ze = (i) => {
629
629
  if (!e)
@@ -692,27 +692,27 @@ const ue = (r) => {
692
692
  children: /* @__PURE__ */ Xe(Ie, {
693
693
  direction: "vertical",
694
694
  size: 16,
695
- children: [!g && /* @__PURE__ */ T(me.Group, {
695
+ children: [!g && /* @__PURE__ */ T(pe.Group, {
696
696
  value: z,
697
697
  buttonStyle: "solid",
698
698
  onChange: (i) => q(i.target.value),
699
699
  children: /* @__PURE__ */ Xe(Ie, {
700
700
  direction: "vertical",
701
701
  size: 16,
702
- children: [/* @__PURE__ */ T(ie, {
702
+ children: [/* @__PURE__ */ T(ne, {
703
703
  title: "矩形标注",
704
704
  placement: "right",
705
- children: /* @__PURE__ */ T(me.Button, {
705
+ children: /* @__PURE__ */ T(pe.Button, {
706
706
  value: "rect",
707
707
  type: "icon",
708
708
  children: /* @__PURE__ */ T(Ae, {
709
709
  type: "icon-biaozhu-juxingkuang"
710
710
  })
711
711
  })
712
- }), /* @__PURE__ */ T(ie, {
712
+ }), /* @__PURE__ */ T(ne, {
713
713
  title: "四边形标注",
714
714
  placement: "right",
715
- children: /* @__PURE__ */ T(me.Button, {
715
+ children: /* @__PURE__ */ T(pe.Button, {
716
716
  value: "quadri",
717
717
  children: /* @__PURE__ */ T(Ae, {
718
718
  type: "icon-biaozhu-sibianxing"
@@ -720,7 +720,7 @@ const ue = (r) => {
720
720
  })
721
721
  })]
722
722
  })
723
- }), /* @__PURE__ */ T(ie, {
723
+ }), /* @__PURE__ */ T(ne, {
724
724
  title: "放大-鼠标滚轮前滑",
725
725
  placement: "right",
726
726
  children: /* @__PURE__ */ T(de, {
@@ -729,7 +729,7 @@ const ue = (r) => {
729
729
  ge(-100);
730
730
  }
731
731
  })
732
- }), /* @__PURE__ */ T(ie, {
732
+ }), /* @__PURE__ */ T(ne, {
733
733
  title: "缩小-鼠标滚轮后滑",
734
734
  placement: "right",
735
735
  children: /* @__PURE__ */ T(de, {
@@ -738,7 +738,7 @@ const ue = (r) => {
738
738
  ge(100);
739
739
  }
740
740
  })
741
- }), !g && /* @__PURE__ */ T(ie, {
741
+ }), !g && /* @__PURE__ */ T(ne, {
742
742
  title: "拖动-按住ctrl",
743
743
  placement: "right",
744
744
  children: /* @__PURE__ */ T(de, {
@@ -746,7 +746,7 @@ const ue = (r) => {
746
746
  className: K ? "active" : "",
747
747
  onClick: Be
748
748
  })
749
- }), !g && /* @__PURE__ */ T(ie, {
749
+ }), !g && /* @__PURE__ */ T(ne, {
750
750
  title: "一键清空全部标注",
751
751
  placement: "right",
752
752
  children: /* @__PURE__ */ T(de, {