@glodon-aiot/dataset-annotation 3.19.1 → 3.19.2-alpha.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.
@@ -1,44 +1,44 @@
1
- var Qt = Object.defineProperty, Vt = Object.defineProperties;
2
- var te = Object.getOwnPropertyDescriptors;
1
+ var Vt = Object.defineProperty, te = Object.defineProperties;
2
+ var ee = Object.getOwnPropertyDescriptors;
3
3
  var wt = Object.getOwnPropertySymbols;
4
- var ee = Object.prototype.hasOwnProperty, oe = Object.prototype.propertyIsEnumerable;
5
- var Ot = (i, g, d) => g in i ? Qt(i, g, { enumerable: !0, configurable: !0, writable: !0, value: d }) : i[g] = d, it = (i, g) => {
4
+ var oe = Object.prototype.hasOwnProperty, re = Object.prototype.propertyIsEnumerable;
5
+ var Ot = (i, g, d) => g in i ? Vt(i, g, { enumerable: !0, configurable: !0, writable: !0, value: d }) : i[g] = d, it = (i, g) => {
6
6
  for (var d in g || (g = {}))
7
- ee.call(g, d) && Ot(i, d, g[d]);
7
+ oe.call(g, d) && Ot(i, d, g[d]);
8
8
  if (wt)
9
9
  for (var d of wt(g))
10
- oe.call(g, d) && Ot(i, d, g[d]);
10
+ re.call(g, d) && Ot(i, d, g[d]);
11
11
  return i;
12
- }, _t = (i, g) => Vt(i, te(g));
12
+ }, _t = (i, g) => te(i, ee(g));
13
13
  import { jsxs as Lt, jsx as L } from "react/jsx-runtime";
14
- import re, { useRef as T, useState as S, useCallback as w, useEffect as E, useImperativeHandle as ne } from "react";
14
+ import ne, { useRef as T, useState as S, useCallback as w, useEffect as E, useImperativeHandle as se } from "react";
15
15
  import { fabric as W } from "fabric";
16
16
  import { useKeyPress as Z } from "ahooks";
17
- import se from "classnames";
17
+ import ie from "classnames";
18
18
  import "./style.less.mjs";
19
- import ie from "../components/Toolbar.mjs";
20
- import { useOCRLoadingIcon as ce } from "./hooks/useOCRLoadingIcon.mjs";
21
- import { useRegionNameText as ae } from "./hooks/useRegionNameText.mjs";
22
- import { useCropRegionImage as fe } from "./hooks/useCropRegionImage.mjs";
23
- import { useDrawingMode as ue } from "./hooks/useDrawingMode.mjs";
24
- import { useRegionLoader as le } from "./hooks/useRegionLoader.mjs";
25
- import { useCanvasSetup as me } from "./hooks/useCanvasSetup.mjs";
26
- import { useTextLayouts as de } from "./hooks/useTextLayouts.mjs";
27
- import { useRegionUpdate as he } from "./hooks/useRegionUpdate.mjs";
28
- import { useCanvasDrag as ge } from "./hooks/useCanvasDrag.mjs";
29
- import { useRegionSelection as Re } from "./hooks/useRegionSelection.mjs";
30
- import { useOCRRecognition as pe } from "./hooks/useOCRRecognition.mjs";
31
- import { useDeleteRegion as Ee } from "./hooks/useDeleteRegion.mjs";
32
- import { useDeleteControl as Te } from "./hooks/useDeleteControl.mjs";
33
- import { useOCRControl as Ce } from "./hooks/useOCRControl.mjs";
34
- import { useCanvasZoom as ve } from "./hooks/useCanvasZoom.mjs";
35
- import { useRegionHover as Ie } from "./hooks/useRegionHover.mjs";
36
- import { useRegionBoundaryCheck as ke } from "./hooks/useRegionBoundaryCheck.mjs";
37
- import { useAIButtonHover as Ae } from "./hooks/useAIButtonHover.mjs";
38
- import Ne from "../components/AIErrorTooltip/index.mjs";
39
- import { canvasToImageCoords as Se, imageToCanvasCoords as xe } from "./utils/coordinateUtils.mjs";
40
- import { REGION_NAME_PREFIX as we, DEFAULT_REGION_NAME as Oe, ZOOM_PRECISION_ERROR as _e, TEXT_LAYOUT_RECT_FILL_COLOR as Le, TEXT_LAYOUT_RECT_STROKE_COLOR as ye, TRANSPARENT_FILL as yt, SELECTED_RECT_FILL_COLOR as Me, RECT_STROKE_COLOR as Mt, BASE_STROKE_WIDTH as ct, ACTIVE_RECT_STROKE_COLOR as De } from "../constants.mjs";
41
- const be = re.forwardRef(({
19
+ import ce from "../components/Toolbar.mjs";
20
+ import { useOCRLoadingIcon as ae } from "./hooks/useOCRLoadingIcon.mjs";
21
+ import { useRegionNameText as fe } from "./hooks/useRegionNameText.mjs";
22
+ import { useCropRegionImage as ue } from "./hooks/useCropRegionImage.mjs";
23
+ import { useDrawingMode as le } from "./hooks/useDrawingMode.mjs";
24
+ import { useRegionLoader as me } from "./hooks/useRegionLoader.mjs";
25
+ import { useCanvasSetup as de } from "./hooks/useCanvasSetup.mjs";
26
+ import { useTextLayouts as he } from "./hooks/useTextLayouts.mjs";
27
+ import { useRegionUpdate as ge } from "./hooks/useRegionUpdate.mjs";
28
+ import { useCanvasDrag as Re } from "./hooks/useCanvasDrag.mjs";
29
+ import { useRegionSelection as pe } from "./hooks/useRegionSelection.mjs";
30
+ import { useOCRRecognition as Ee } from "./hooks/useOCRRecognition.mjs";
31
+ import { useDeleteRegion as Te } from "./hooks/useDeleteRegion.mjs";
32
+ import { useDeleteControl as Ce } from "./hooks/useDeleteControl.mjs";
33
+ import { useOCRControl as ve } from "./hooks/useOCRControl.mjs";
34
+ import { useCanvasZoom as Ie } from "./hooks/useCanvasZoom.mjs";
35
+ import { useRegionHover as ke } from "./hooks/useRegionHover.mjs";
36
+ import { useRegionBoundaryCheck as Ae } from "./hooks/useRegionBoundaryCheck.mjs";
37
+ import { useAIButtonHover as Ne } from "./hooks/useAIButtonHover.mjs";
38
+ import Se from "../components/AIErrorTooltip/index.mjs";
39
+ import { canvasToImageCoords as xe, imageToCanvasCoords as we } from "./utils/coordinateUtils.mjs";
40
+ import { REGION_NAME_PREFIX as Oe, DEFAULT_REGION_NAME as _e, ZOOM_PRECISION_ERROR as Le, TEXT_LAYOUT_RECT_FILL_COLOR as ye, TEXT_LAYOUT_RECT_STROKE_COLOR as Me, TRANSPARENT_FILL as yt, SELECTED_RECT_FILL_COLOR as De, RECT_STROKE_COLOR as Mt, BASE_STROKE_WIDTH as ct, ACTIVE_RECT_STROKE_COLOR as be } from "../constants.mjs";
41
+ const Pe = ne.forwardRef(({
42
42
  sample: i,
43
43
  labelDefinitions: g,
44
44
  labels: d,
@@ -51,13 +51,14 @@ const be = re.forwardRef(({
51
51
  onClearActive: Q,
52
52
  selectedRegion: C,
53
53
  onAppendTextToActive: Pt,
54
- readOnly: h
55
- }, Ut) => {
54
+ readOnly: h,
55
+ hideDrawRect: Ut
56
+ }, Wt) => {
56
57
  var Nt, St;
57
- const ft = T(null), v = T(null), [Wt, Xt] = S(!0), [t, jt] = S(), [y, Ft] = S(), [I, ut] = S(1), [N, X] = S(h || !1), [k, _] = S(!1), [V, Bt] = S({
58
+ const ft = T(null), v = T(null), [Xt, jt] = S(!0), [t, Ft] = S(), [y, Bt] = S(), [I, ut] = S(1), [N, X] = S(h || !1), [k, _] = S(!1), [V, Ht] = S({
58
59
  left: 0,
59
60
  top: 0
60
- }), [Ht, lt] = S(!1), [tt, mt] = S(null), j = T({
61
+ }), [Zt, lt] = S(!1), [tt, mt] = S(null), j = T({
61
62
  left: 0,
62
63
  top: 0
63
64
  }), dt = T({
@@ -67,12 +68,12 @@ const be = re.forwardRef(({
67
68
  width: 0,
68
69
  height: 0
69
70
  }), Et = T(!1), {
70
- updateOCRLoadingIcon: Pe,
71
+ updateOCRLoadingIcon: Ue,
71
72
  ocrLoadingIconMapRef: M
72
- } = ce(t), {
73
+ } = ae(t), {
73
74
  updateRegionNameText: z,
74
75
  regionNameTextMapRef: A
75
- } = ae(t), et = fe(i == null ? void 0 : i.fileUrl), Zt = w((o) => {
76
+ } = fe(t), et = ue(i == null ? void 0 : i.fileUrl), Yt = w((o) => {
76
77
  t && (A.current.forEach((e, r) => {
77
78
  const n = r.left || 0, u = r.top || 0;
78
79
  e.set({
@@ -88,7 +89,7 @@ const be = re.forwardRef(({
88
89
  }), t.renderAll());
89
90
  }, [t]), {
90
91
  updateCanvas: F
91
- } = me({
92
+ } = de({
92
93
  sample: i,
93
94
  image: y,
94
95
  onImageLoad: Dt,
@@ -99,39 +100,39 @@ const be = re.forwardRef(({
99
100
  bgImageSizeRef: dt,
100
101
  rectMapRef: c,
101
102
  updateTextLayersRef: ht,
102
- onRectPositionUpdated: Zt,
103
- setCanvas: jt,
104
- setImage: Ft,
103
+ onRectPositionUpdated: Yt,
104
+ setCanvas: Ft,
105
+ setImage: Bt,
105
106
  setScale: ut,
106
- setBgImagePosition: Bt,
107
- setLoading: Xt
108
- }), Yt = w(() => {
107
+ setBgImagePosition: Ht,
108
+ setLoading: jt
109
+ }), zt = w(() => {
109
110
  const o = Array.from(c.current.values());
110
111
  o.forEach((e, r) => {
111
- e.name = `${we}${r + 1}`;
112
+ e.name = `${Oe}${r + 1}`;
112
113
  }), c.current.forEach((e, r) => {
113
114
  const n = A.current.get(r);
114
- n && (n.set("text", e.name || Oe), t == null || t.renderAll());
115
+ n && (n.set("text", e.name || _e), t == null || t.renderAll());
115
116
  }), O && O(o);
116
117
  }, [O, t]), {
117
- zoom: zt
118
- } = ve({
118
+ zoom: Kt
119
+ } = Ie({
119
120
  canvas: t,
120
121
  setScale: ut,
121
122
  isZoomingRef: Et
122
123
  }), B = w(
123
- (o, e) => Se(o, e, t, y, j),
124
+ (o, e) => xe(o, e, t, y, j),
124
125
  [t, y, V]
125
126
  // 添加 bgImagePosition 作为依赖,确保在图片位置更新后函数能正确工作
126
127
  ), K = w(
127
- (o, e) => xe(o, e, t, j),
128
+ (o, e) => we(o, e, t, j),
128
129
  [t, V]
129
130
  // 添加 bgImagePosition 作为依赖,确保在图片位置更新后函数能正确工作
130
131
  ), {
131
132
  updateTextLayers: $,
132
133
  textLayersMapRef: m,
133
134
  textLayoutContentMapRef: G
134
- } = de({
135
+ } = he({
135
136
  canvas: t,
136
137
  imageToCanvasCoords: K,
137
138
  activeLabelValue: R,
@@ -143,7 +144,7 @@ const be = re.forwardRef(({
143
144
  performOCR: q,
144
145
  ocrRecognizingRef: Ct,
145
146
  ocrErrorRef: ot
146
- } = pe({
147
+ } = Ee({
147
148
  ocrRecognize: bt,
148
149
  onChange: O,
149
150
  updateTextLayers: $,
@@ -153,7 +154,7 @@ const be = re.forwardRef(({
153
154
  textLayoutContentMapRef: G
154
155
  }), {
155
156
  updateRegionShapeAndImage: vt
156
- } = he({
157
+ } = ge({
157
158
  canvas: t,
158
159
  image: y,
159
160
  draggable: N,
@@ -169,7 +170,7 @@ const be = re.forwardRef(({
169
170
  ocrLoadingIconMapRef: M
170
171
  }), {
171
172
  setupBoundaryCheck: It
172
- } = ke({
173
+ } = Ae({
173
174
  canvas: t,
174
175
  image: y,
175
176
  canvasToImageCoords: B,
@@ -204,7 +205,7 @@ const be = re.forwardRef(({
204
205
  return;
205
206
  if (t) {
206
207
  const s = t.getZoom();
207
- if (Math.abs(s - I) > _e)
208
+ if (Math.abs(s - I) > Le)
208
209
  return;
209
210
  }
210
211
  const e = v.current.offsetWidth, r = v.current.offsetHeight, n = Y.current.width, u = Y.current.height;
@@ -244,9 +245,9 @@ const be = re.forwardRef(({
244
245
  }), m.current.forEach((r) => {
245
246
  r.forEach((n) => {
246
247
  n.set({
247
- fill: Le,
248
+ fill: ye,
248
249
  // 确保填充色被保留
249
- stroke: ye,
250
+ stroke: Me,
250
251
  // 确保边框色被保留
251
252
  strokeWidth: o,
252
253
  // 根据缩放调整边框宽度,保持视觉一致
@@ -289,7 +290,7 @@ const be = re.forwardRef(({
289
290
  }
290
291
  }
291
292
  }), t.renderAll();
292
- }, [t, I]), ge({
293
+ }, [t, I]), Re({
293
294
  canvas: t,
294
295
  draggable: N,
295
296
  drawingMode: k,
@@ -297,11 +298,11 @@ const be = re.forwardRef(({
297
298
  });
298
299
  const {
299
300
  performDelete: D,
300
- deleteDirectly: Kt
301
- } = Ee({
301
+ deleteDirectly: $t
302
+ } = Te({
302
303
  canvas: t,
303
304
  onRegionChange: J,
304
- updateRegionNames: Yt,
305
+ updateRegionNames: zt,
305
306
  rectMapRef: c,
306
307
  textLayersMapRef: m,
307
308
  textLayoutContentMapRef: G,
@@ -316,44 +317,44 @@ const be = re.forwardRef(({
316
317
  r.id === o && (e = n);
317
318
  }), e && D(e);
318
319
  }, [t, D]);
319
- const $t = w((o) => {
320
+ const Gt = w((o) => {
320
321
  if (!t)
321
322
  return;
322
323
  let e = null;
323
324
  c.current.forEach((r) => {
324
325
  r.id === o && (e = r);
325
326
  }), e && q(e);
326
- }, [t, q]), Gt = w((o) => {
327
+ }, [t, q]), qt = w((o) => {
327
328
  if (!t)
328
329
  return;
329
330
  const e = c.current.get(o);
330
331
  e && q(e);
331
332
  }, [t, q]);
332
- ne(Ut, () => ({
333
- performOCRById: $t,
333
+ se(Wt, () => ({
334
+ performOCRById: Gt,
334
335
  ocrRecognizingRef: Ct,
335
336
  ocrErrorRef: ot
336
337
  }));
337
338
  const {
338
339
  createDeleteControl: rt
339
- } = Te({
340
+ } = Ce({
340
341
  performDelete: D
341
342
  }), {
342
343
  createOCRControl: nt
343
- } = Ce({
344
- performOCR: Gt,
344
+ } = ve({
345
+ performOCR: qt,
345
346
  ocrRecognizingRef: Ct,
346
347
  ocrErrorRef: ot,
347
348
  rectMapRef: c
348
349
  });
349
- Re({
350
+ pe({
350
351
  canvas: t,
351
352
  onRegionSelect: at,
352
353
  createDeleteControl: rt,
353
354
  createOCRControl: nt,
354
355
  textLayersMapRef: m,
355
356
  rectMapRef: c
356
- }), Ae({
357
+ }), Ne({
357
358
  canvas: t,
358
359
  ocrErrorRef: ot,
359
360
  rectMapRef: c,
@@ -374,7 +375,7 @@ const be = re.forwardRef(({
374
375
  });
375
376
  const {
376
377
  stopDraw: b
377
- } = ue({
378
+ } = le({
378
379
  canvas: t,
379
380
  drawingMode: k,
380
381
  draggable: N,
@@ -418,7 +419,7 @@ const be = re.forwardRef(({
418
419
  return o(), t.on("object:added", o), () => {
419
420
  t.off("object:added", o);
420
421
  };
421
- }, [t, h]), le({
422
+ }, [t, h]), me({
422
423
  canvas: t,
423
424
  sample: i,
424
425
  image: y,
@@ -452,7 +453,7 @@ const be = re.forwardRef(({
452
453
  c.current.forEach((a, l) => {
453
454
  r.has(a.id) && !n.has(a.id) && s.push(l);
454
455
  }), s.forEach((a) => {
455
- Kt(a);
456
+ $t(a);
456
457
  });
457
458
  }
458
459
  if (kt.current = e, !d || d.length === 0)
@@ -471,7 +472,7 @@ const be = re.forwardRef(({
471
472
  });
472
473
  (f.name !== s.name || f.content !== s.content || f.image !== s.image || f.textLayouts !== s.textLayouts) && (c.current.set(a, f), f.name !== s.name && z(a, f), u = !0);
473
474
  }), u && (t == null || t.renderAll());
474
- }, [d, t, z, D]), Ie({
475
+ }, [d, t, z, D]), ke({
475
476
  canvas: t,
476
477
  drawingMode: k,
477
478
  draggable: N,
@@ -512,7 +513,7 @@ const be = re.forwardRef(({
512
513
  });
513
514
  const u = t.getZoom(), s = ct / u, a = r;
514
515
  a.set({
515
- fill: Me,
516
+ fill: De,
516
517
  // 选中时添加填充色
517
518
  stroke: Mt,
518
519
  // 选中时取消高亮,使用普通边框颜色
@@ -550,7 +551,7 @@ const be = re.forwardRef(({
550
551
  });
551
552
  return;
552
553
  }
553
- const H = f.stroke, st = p ? De : Mt;
554
+ const H = f.stroke, st = p ? be : Mt;
554
555
  H !== st && (f.set({
555
556
  stroke: st,
556
557
  strokeWidth: s,
@@ -614,9 +615,9 @@ const be = re.forwardRef(({
614
615
  exactMatch: !1
615
616
  // 允许大小写
616
617
  });
617
- const qt = () => {
618
+ const Jt = () => {
618
619
  h || (k && (_(!1), b()), X(!N));
619
- }, Jt = () => {
620
+ }, Qt = () => {
620
621
  h || (N && X(!1), _(!k));
621
622
  };
622
623
  return E(() => () => {
@@ -628,26 +629,27 @@ const be = re.forwardRef(({
628
629
  display: "flex",
629
630
  position: "relative"
630
631
  },
631
- children: [Wt && /* @__PURE__ */ L("div", {
632
+ children: [Xt && /* @__PURE__ */ L("div", {
632
633
  className: "vlm-loading-overlay",
633
634
  children: /* @__PURE__ */ L("div", {
634
635
  className: "vlm-loading-spinner"
635
636
  })
636
637
  }), /* @__PURE__ */ L("div", {
637
638
  className: "vlm-marker-toolbar",
638
- children: /* @__PURE__ */ L(ie, {
639
+ children: /* @__PURE__ */ L(ce, {
639
640
  drawingMode: k,
640
641
  draggable: N,
641
642
  scale: I,
642
- onToggleDrawingMode: Jt,
643
- onToggleDrag: qt,
644
- onZoom: zt,
643
+ onToggleDrawingMode: Qt,
644
+ onToggleDrag: Jt,
645
+ onZoom: Kt,
645
646
  onFitToScreen: F,
646
- readOnly: h
647
+ readOnly: h,
648
+ hideDrawRect: Ut
647
649
  })
648
650
  }), /* @__PURE__ */ Lt("div", {
649
651
  ref: v,
650
- className: se({
652
+ className: ie({
651
653
  "vlm-label-maker-wrap": !0,
652
654
  draggable: N
653
655
  }),
@@ -664,15 +666,15 @@ const be = re.forwardRef(({
664
666
  }), /* @__PURE__ */ L("canvas", {
665
667
  className: "vlm-label-maker-canvas",
666
668
  ref: ft
667
- }), tt && /* @__PURE__ */ L(Ne, {
668
- visible: Ht,
669
+ }), tt && /* @__PURE__ */ L(Se, {
670
+ visible: Zt,
669
671
  x: tt.x,
670
672
  y: tt.y
671
673
  })]
672
674
  })]
673
675
  });
674
676
  });
675
- be.displayName = "VLMLabelMaker";
677
+ Pe.displayName = "VLMLabelMaker";
676
678
  export {
677
- be as default
679
+ Pe as default
678
680
  };
@@ -1,11 +1,11 @@
1
- import { jsxs as t, Fragment as f, jsx as o } from "react/jsx-runtime";
2
- import { Space as s, Divider as u } from "antd";
3
- import d from "./RectangleButton.mjs";
4
- import v from "./DragButton.mjs";
5
- import C from "./ZoomControls.mjs";
6
- import g from "./FitToScreenButton.mjs";
1
+ import { jsxs as t, Fragment as s, jsx as o } from "react/jsx-runtime";
2
+ import { Space as u, Divider as d } from "antd";
3
+ import v from "./RectangleButton.mjs";
4
+ import C from "./DragButton.mjs";
5
+ import g from "./ZoomControls.mjs";
6
+ import h from "./FitToScreenButton.mjs";
7
7
  import { ZOOM_STEP as i } from "../constants.mjs";
8
- const Z = ({
8
+ const j = ({
9
9
  drawingMode: e,
10
10
  draggable: n,
11
11
  scale: m,
@@ -13,28 +13,29 @@ const Z = ({
13
13
  onToggleDrag: a,
14
14
  onZoom: r,
15
15
  onFitToScreen: l,
16
- readOnly: p
17
- }) => /* @__PURE__ */ t(s, {
16
+ readOnly: p,
17
+ hideDrawRect: f
18
+ }) => /* @__PURE__ */ t(u, {
18
19
  direction: "vertical",
19
20
  size: 16,
20
- children: [!p && /* @__PURE__ */ t(f, {
21
- children: [/* @__PURE__ */ o(d, {
21
+ children: [!p && /* @__PURE__ */ t(s, {
22
+ children: [!f && /* @__PURE__ */ o(v, {
22
23
  active: e,
23
24
  onClick: c
24
- }), /* @__PURE__ */ o(v, {
25
+ }), /* @__PURE__ */ o(C, {
25
26
  active: n,
26
27
  onClick: a
27
- }), /* @__PURE__ */ o(u, {
28
+ }), /* @__PURE__ */ o(d, {
28
29
  type: "horizontal"
29
30
  })]
30
- }), /* @__PURE__ */ o(C, {
31
+ }), /* @__PURE__ */ o(g, {
31
32
  scale: m,
32
33
  onZoomIn: () => r(-i),
33
34
  onZoomOut: () => r(i)
34
- }), /* @__PURE__ */ o(g, {
35
+ }), /* @__PURE__ */ o(h, {
35
36
  onClick: l
36
37
  })]
37
38
  });
38
39
  export {
39
- Z as default
40
+ j as default
40
41
  };