@glodon-aiot/dataset-annotation 3.13.0-alpha.29 → 3.14.0-alpha.30

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.
Files changed (33) hide show
  1. package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +151 -135
  2. package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +244 -218
  3. package/dist/es/components/VLMAnnotation/RegionItem.mjs +135 -59
  4. package/dist/es/components/VLMAnnotation/TextAnnotationPanel.mjs +73 -62
  5. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.mjs +55 -40
  6. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +291 -162
  7. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.mjs +100 -0
  8. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.mjs +88 -55
  9. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.mjs +103 -0
  10. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.mjs +123 -91
  11. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +42 -39
  12. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.mjs +55 -60
  13. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/ai.svg.mjs +4 -0
  14. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/error.svg.mjs +4 -0
  15. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/loading.svg.mjs +4 -0
  16. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/star.svg.mjs +4 -0
  17. package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +512 -387
  18. package/dist/es/components/VLMAnnotation/constants.mjs +39 -32
  19. package/dist/es/components/VLMAnnotation/index.mjs +187 -150
  20. package/dist/es/index.mjs +1 -1
  21. package/dist/lib/index.js +4 -4
  22. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.d.ts +1 -0
  23. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +3 -1
  24. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.d.ts +16 -0
  25. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.d.ts +3 -2
  26. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.d.ts +31 -0
  27. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.d.ts +5 -1
  28. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.d.ts +2 -1
  29. package/dist/src/components/VLMAnnotation/VLMLabelMaker/index.d.ts +2 -2
  30. package/dist/src/components/VLMAnnotation/constants.d.ts +19 -3
  31. package/dist/src/components/VLMAnnotation/index.d.ts +1 -1
  32. package/dist/src/components/VLMAnnotation/types.d.ts +15 -0
  33. package/package.json +2 -2
@@ -1,68 +1,101 @@
1
- var N = (i, l, s) => new Promise((f, o) => {
2
- var c = (t) => {
1
+ var F = (f, m, i) => new Promise((s, n) => {
2
+ var S = (r) => {
3
3
  try {
4
- d(s.next(t));
5
- } catch (n) {
6
- o(n);
4
+ c(i.next(r));
5
+ } catch (u) {
6
+ n(u);
7
7
  }
8
- }, m = (t) => {
8
+ }, y = (r) => {
9
9
  try {
10
- d(s.throw(t));
11
- } catch (n) {
12
- o(n);
10
+ c(i.throw(r));
11
+ } catch (u) {
12
+ n(u);
13
13
  }
14
- }, d = (t) => t.done ? f(t.value) : Promise.resolve(t.value).then(c, m);
15
- d((s = s.apply(i, l)).next());
14
+ }, c = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(S, y);
15
+ c((i = i.apply(f, m)).next());
16
16
  });
17
- import { useRef as k, useCallback as R } from "react";
18
- const G = ({
19
- ocrRecognize: i,
20
- onChange: l,
21
- updateTextLayers: s,
22
- canvas: f,
23
- updateOCRLoadingIcon: o,
24
- rectMapRef: c,
25
- textLayersMapRef: m,
26
- textLayoutContentMapRef: d
17
+ import { useRef as k, useCallback as N } from "react";
18
+ const H = ({
19
+ ocrRecognize: f,
20
+ onChange: m,
21
+ updateTextLayers: i,
22
+ canvas: s,
23
+ rectMapRef: n,
24
+ textLayersMapRef: S,
25
+ textLayoutContentMapRef: y
27
26
  }) => {
28
- const t = k(/* @__PURE__ */ new Set()), n = k(/* @__PURE__ */ new Map());
29
- return {
30
- performOCRIfNeeded: R((e, a) => N(void 0, null, function* () {
31
- var x;
32
- if (a !== "create" && a !== "update" || !i || !e.image)
27
+ const c = k(/* @__PURE__ */ new Set()), r = k(/* @__PURE__ */ new Set()), u = k(/* @__PURE__ */ new Map()), v = N((e, o) => F(void 0, null, function* () {
28
+ var t;
29
+ if (o !== "create" && o !== "update" || !f || !e.image)
30
+ return;
31
+ const l = (t = Array.from(n.current.entries()).find(([, d]) => d.id === e.id)) == null ? void 0 : t[0];
32
+ if (!l)
33
+ return;
34
+ const A = S.current.get(l);
35
+ A && s && (A.forEach((d) => {
36
+ d.off("mousedown"), d.off("mouseover"), d.off("mouseout"), y.current.delete(d), s.remove(d);
37
+ }), S.current.delete(l), s.renderAll());
38
+ const q = n.current.get(l);
39
+ q && q.textLayouts && delete q.textLayouts;
40
+ const a = (u.current.get(e.id) || 0) + 1;
41
+ u.current.set(e.id, a), r.current.delete(e.id), c.current.add(e.id);
42
+ try {
43
+ const d = yield f(e.image);
44
+ if (u.current.get(e.id) !== a)
45
+ return;
46
+ c.current.delete(e.id), r.current.delete(e.id);
47
+ const E = n.current.get(l);
48
+ if (E && u.current.get(e.id) === a && (E.textLayouts = d, i(l, E), m)) {
49
+ const B = Array.from(n.current.values());
50
+ m(B);
51
+ }
52
+ } catch (d) {
53
+ if (u.current.get(e.id) !== a)
33
54
  return;
34
- const u = (x = Array.from(c.current.entries()).find(([, r]) => r.id === e.id)) == null ? void 0 : x[0];
35
- if (!u)
55
+ c.current.delete(e.id), r.current.add(e.id), console.error("Failed to perform OCR recognition:", d);
56
+ }
57
+ }), [f, m, i, s, n, S, y]), x = N((e) => F(void 0, null, function* () {
58
+ var a;
59
+ if (!f || !e.image)
60
+ return;
61
+ const o = (a = Array.from(n.current.entries()).find(([, t]) => t.id === e.id)) == null ? void 0 : a[0];
62
+ if (!o)
63
+ return;
64
+ const l = S.current.get(o);
65
+ l && s && (l.forEach((t) => {
66
+ t.off("mousedown"), t.off("mouseover"), t.off("mouseout"), y.current.delete(t), s.remove(t);
67
+ }), S.current.delete(o), s.renderAll());
68
+ const A = n.current.get(o);
69
+ A && A.textLayouts && delete A.textLayouts;
70
+ const q = (u.current.get(e.id) || 0) + 1;
71
+ u.current.set(e.id, q), r.current.delete(e.id), c.current.add(e.id);
72
+ try {
73
+ const t = yield f(e.image);
74
+ if (u.current.get(e.id) !== q)
36
75
  return;
37
- const w = m.current.get(u);
38
- w && f && (w.forEach((r) => {
39
- r.off("mousedown"), r.off("mouseover"), r.off("mouseout"), d.current.delete(r), f.remove(r);
40
- }), m.current.delete(u), f.renderAll());
41
- const S = c.current.get(u);
42
- S && S.textLayouts && delete S.textLayouts;
43
- const q = (n.current.get(e.id) || 0) + 1;
44
- n.current.set(e.id, q), t.current.add(e.id);
45
- const A = c.current.get(u);
46
- A && o(u, A, !0);
47
- try {
48
- const r = yield i(e.image);
49
- if (n.current.get(e.id) !== q)
50
- return;
51
- t.current.delete(e.id), o(u, e, !1);
52
- const y = c.current.get(u);
53
- if (y && n.current.get(e.id) === q && (y.textLayouts = r, s(u, y), l)) {
54
- const F = Array.from(c.current.values());
55
- l(F);
56
- }
57
- } catch (r) {
58
- if (n.current.get(e.id) !== q)
59
- return;
60
- t.current.delete(e.id), o(u, e, !1), console.error("Failed to perform OCR recognition:", r);
76
+ if (!t || !Array.isArray(t)) {
77
+ c.current.delete(e.id), r.current.add(e.id), console.error("OCR returned invalid result:", t);
78
+ return;
79
+ }
80
+ c.current.delete(e.id), r.current.delete(e.id);
81
+ const w = n.current.get(o);
82
+ if (w && u.current.get(e.id) === q && (w.textLayouts = t, i(o, w), m)) {
83
+ const I = Array.from(n.current.values());
84
+ m(I);
61
85
  }
62
- }), [i, l, s, f, o, c, m, d]),
63
- ocrRecognizingRef: t
86
+ } catch (t) {
87
+ if (u.current.get(e.id) !== q)
88
+ return;
89
+ c.current.delete(e.id), r.current.add(e.id), console.error("Failed to perform OCR recognition:", t);
90
+ }
91
+ }), [f, m, i, s, n, S, y]);
92
+ return {
93
+ performOCRIfNeeded: v,
94
+ performOCR: x,
95
+ ocrRecognizingRef: c,
96
+ ocrErrorRef: r
64
97
  };
65
98
  };
66
99
  export {
67
- G as useOCRRecognition
100
+ H as useOCRRecognition
68
101
  };
@@ -0,0 +1,103 @@
1
+ import { useCallback as q, useEffect as D } from "react";
2
+ const G = ({
3
+ canvas: n,
4
+ image: y,
5
+ canvasToImageCoords: S,
6
+ imageToCanvasCoords: b,
7
+ bgImagePositionRef: k,
8
+ bgImageSizeRef: A,
9
+ regionNameTextMapRef: Y
10
+ }) => {
11
+ const O = q((h) => {
12
+ if (!n || !y)
13
+ return;
14
+ const r = y.getElement();
15
+ if (!(r != null && r.width) || !(r != null && r.height))
16
+ return;
17
+ const i = r.width, u = r.height, d = (w) => {
18
+ const t = h, g = t.left || 0, p = t.top || 0, a = t.getScaledWidth(), m = t.getScaledHeight(), l = S(g, p);
19
+ let e = l.x, o = l.y, c = a, s = m;
20
+ const W = e, H = o;
21
+ if (e < 0 && (e = 0), o < 0 && (o = 0), e + c > i && (e = i - c), o + s > u && (o = u - s), c <= 0 || s <= 0)
22
+ return;
23
+ const L = b(e, o);
24
+ (e !== W || o !== H) && t.set({
25
+ left: L.x,
26
+ top: L.y
27
+ });
28
+ const Z = Y.current.get(t);
29
+ if (Z) {
30
+ const f = n.getZoom(), x = t.left || 0, X = t.top || 0;
31
+ Z.set({
32
+ left: x,
33
+ top: X,
34
+ scaleX: 1 / f,
35
+ scaleY: 1 / f
36
+ }), n.renderAll();
37
+ }
38
+ }, M = (w) => {
39
+ const t = h, g = t.left || 0, p = t.top || 0, a = t.getScaledWidth(), m = t.getScaledHeight(), l = S(g, p);
40
+ let e = l.x, o = l.y, c = a, s = m;
41
+ e < 0 && (c = c + e, e = 0), o < 0 && (s = s + o, o = 0), e + c > i && (c = i - e), o + s > u && (s = u - o), c = Math.max(1, c), s = Math.max(1, s);
42
+ const W = Math.abs(c - a) > 1e-3, H = Math.abs(s - m) > 1e-3, L = Math.abs(e - l.x) > 1e-3, Z = Math.abs(o - l.y) > 1e-3;
43
+ if (W || H || L || Z) {
44
+ const f = b(e, o), x = t.width || 1, X = t.height || 1, B = W ? Math.max(0.01, c / x) : t.scaleX || 1, U = H ? Math.max(0.01, s / X) : t.scaleY || 1;
45
+ t.set({
46
+ left: f.x,
47
+ top: f.y,
48
+ scaleX: B,
49
+ scaleY: U
50
+ });
51
+ const C = Y.current.get(t);
52
+ if (C) {
53
+ const T = n.getZoom(), _ = t.left || 0, j = t.top || 0;
54
+ C.set({
55
+ left: _,
56
+ top: j,
57
+ scaleX: 1 / T,
58
+ scaleY: 1 / T
59
+ }), n.renderAll();
60
+ }
61
+ } else {
62
+ const f = Y.current.get(t);
63
+ if (f) {
64
+ const x = n.getZoom(), X = t.left || 0, B = t.top || 0;
65
+ f.set({
66
+ left: X,
67
+ top: B,
68
+ scaleX: 1 / x,
69
+ scaleY: 1 / x
70
+ }), n.renderAll();
71
+ }
72
+ }
73
+ };
74
+ return h.on("moving", d), h.on("scaling", M), () => {
75
+ h.off("moving", d), h.off("scaling", M);
76
+ };
77
+ }, [n, y, S, b, Y]);
78
+ return D(() => {
79
+ if (!n || !y)
80
+ return;
81
+ const h = (r) => {
82
+ const i = n, u = i == null ? void 0 : i._currentTransform;
83
+ if (!u)
84
+ return;
85
+ const d = u.action;
86
+ if (!d || d !== "move" && !d.startsWith("scale"))
87
+ return;
88
+ const M = n.getPointer(r.e), w = M.x, t = M.y, g = k.current.left, p = k.current.top, a = g + A.current.width, m = p + A.current.height;
89
+ if (w < g || w > a || t < p || t > m) {
90
+ const e = i == null ? void 0 : i._onMouseUp;
91
+ typeof e == "function" && e(r.e);
92
+ }
93
+ };
94
+ return n.on("mouse:move", h), () => {
95
+ n.off("mouse:move", h);
96
+ };
97
+ }, [n, y, k, A]), {
98
+ setupBoundaryCheck: O
99
+ };
100
+ };
101
+ export {
102
+ G as useRegionBoundaryCheck
103
+ };
@@ -1,61 +1,65 @@
1
- var X = Object.defineProperty;
2
- var F = Object.getOwnPropertySymbols;
3
- var b = Object.prototype.hasOwnProperty, j = Object.prototype.propertyIsEnumerable;
4
- var K = (e, t, s) => t in e ? X(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, Z = (e, t) => {
5
- for (var s in t || (t = {}))
6
- b.call(t, s) && K(e, s, t[s]);
7
- if (F)
8
- for (var s of F(t))
9
- j.call(t, s) && K(e, s, t[s]);
10
- return e;
1
+ var B = Object.defineProperty;
2
+ var H = Object.getOwnPropertySymbols;
3
+ var C = Object.prototype.hasOwnProperty, D = Object.prototype.propertyIsEnumerable;
4
+ var X = (o, t, n) => t in o ? B(o, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[t] = n, P = (o, t) => {
5
+ for (var n in t || (t = {}))
6
+ C.call(t, n) && X(o, n, t[n]);
7
+ if (H)
8
+ for (var n of H(t))
9
+ D.call(t, n) && X(o, n, t[n]);
10
+ return o;
11
11
  };
12
- import { useEffect as q } from "react";
13
- import { fabric as N } from "fabric";
14
- import { TRANSPARENT_FILL as P, RECT_STROKE_COLOR as B, BASE_STROKE_WIDTH as G, REGION_NAME_PREFIX as H } from "../../constants.mjs";
15
- const z = ({
16
- canvas: e,
12
+ import { useEffect as O } from "react";
13
+ import { fabric as j } from "fabric";
14
+ import { TRANSPARENT_FILL as q, RECT_STROKE_COLOR as J, BASE_STROKE_WIDTH as Q, REGION_NAME_PREFIX as V } from "../../constants.mjs";
15
+ const a = ({
16
+ canvas: o,
17
17
  sample: t,
18
- image: s,
19
- bgImagePosition: O,
20
- canvasInitializedRef: $,
21
- bgImagePositionRef: w,
18
+ image: n,
19
+ bgImagePosition: Y,
20
+ canvasInitializedRef: v,
21
+ bgImagePositionRef: m,
22
22
  sampleRef: y,
23
- labelsLoadedRef: d,
24
- rectMapRef: f,
25
- textLayersMapRef: S,
26
- textLayoutContentMapRef: A,
27
- regionNameTextMapRef: C,
28
- ocrLoadingIconMapRef: _,
29
- imageToCanvasCoords: x,
30
- updateRegionShapeAndImage: E,
31
- createDeleteControl: m,
32
- updateRegionNameText: W,
33
- updateTextLayers: U
23
+ labelsLoadedRef: E,
24
+ rectMapRef: u,
25
+ textLayersMapRef: _,
26
+ textLayoutContentMapRef: G,
27
+ regionNameTextMapRef: x,
28
+ ocrLoadingIconMapRef: F,
29
+ imageToCanvasCoords: A,
30
+ updateRegionShapeAndImage: k,
31
+ createDeleteControl: W,
32
+ createOCRControl: U,
33
+ updateRegionNameText: Z,
34
+ updateTextLayers: $,
35
+ setupBoundaryCheck: K,
36
+ cropRegionImage: N,
37
+ onChange: w
34
38
  }) => {
35
- q(() => {
36
- if (!e || !(t != null && t.labels) || !s || !$.current || w.current.left === 0 && w.current.top === 0)
39
+ O(() => {
40
+ if (!o || !(t != null && t.labels) || !n || !v.current || m.current.left === 0 && m.current.top === 0)
37
41
  return;
38
- y.current !== t ? (y.current = t, d.current = !1, f.current.forEach((o, n) => {
39
- const l = S.current.get(n);
40
- l && (l.forEach((r) => {
41
- r.off("mousedown"), r.off("mouseover"), r.off("mouseout"), A.current.delete(r), e.remove(r);
42
- }), S.current.delete(n));
43
- const u = C.current.get(n);
44
- u && (n.off("moved"), n.off("modified"), e.remove(u), C.current.delete(n));
45
- const i = _.current.get(n);
46
- i && (e.remove(i), _.current.delete(n)), e.remove(n);
47
- }), f.current.clear(), t.labels.forEach((o, n) => {
48
- if (o.shape.name !== "rect")
42
+ y.current !== t ? (y.current = t, E.current = !1, u.current.forEach((i, s) => {
43
+ const f = _.current.get(s);
44
+ f && (f.forEach((e) => {
45
+ e.off("mousedown"), e.off("mouseover"), e.off("mouseout"), G.current.delete(e), o.remove(e);
46
+ }), _.current.delete(s));
47
+ const h = x.current.get(s);
48
+ h && (s.off("moved"), s.off("modified"), o.remove(h), x.current.delete(s));
49
+ const d = F.current.get(s);
50
+ d && (o.remove(d), F.current.delete(s)), o.remove(s);
51
+ }), u.current.clear(), t.labels.forEach((i, s) => {
52
+ if (i.shape.name !== "rect")
49
53
  return;
50
- const l = x(o.shape.x, o.shape.y), u = e.getZoom(), i = G / u, r = new N.Rect({
51
- left: l.x,
52
- top: l.y,
53
- width: o.shape.width,
54
- height: o.shape.height,
55
- fill: P,
54
+ const f = A(i.shape.x, i.shape.y), h = o.getZoom(), d = Q / h, e = new j.Rect({
55
+ left: f.x,
56
+ top: f.y,
57
+ width: i.shape.width,
58
+ height: i.shape.height,
59
+ fill: q,
56
60
  // 无填充色
57
- stroke: B,
58
- strokeWidth: i,
61
+ stroke: J,
62
+ strokeWidth: d,
59
63
  strokeUniform: !0,
60
64
  // 边框宽度不受缩放影响
61
65
  selectable: !0,
@@ -66,30 +70,42 @@ const z = ({
66
70
  // 锁定旋转
67
71
  lockUniScaling: !1,
68
72
  // 允许非等比缩放,控制点跟随鼠标
73
+ lockScalingFlip: !0,
74
+ // 禁止缩放时翻转
69
75
  objectCaching: !1,
70
76
  // 禁用缓存,避免缩放时边框变虚
71
77
  statefullCache: !1,
72
78
  noScaleCache: !1
73
79
  });
74
- r.on("modified", () => {
75
- E(r);
76
- }), r.on("moved", () => {
77
- E(r);
78
- }), e.add(r), r.controls.deleteControl = m();
79
- const h = Z({}, o);
80
- h.name || (h.name = `${H}${n + 1}`), f.current.set(r, h), W(r, h), h.textLayouts && h.textLayouts.length > 0 && U(r, h);
81
- }), d.current = !0, e.renderAll()) : !d.current && t.labels.length > 0 && (t.labels.forEach((o, n) => {
82
- if (o.shape.name !== "rect" || Array.from(f.current.values()).find((k) => k.shape.x === o.shape.x && k.shape.y === o.shape.y && k.shape.width === o.shape.width && k.shape.height === o.shape.height))
80
+ e.on("modified", () => {
81
+ k(e);
82
+ }), e.on("moved", () => {
83
+ k(e);
84
+ }), o.add(e), K(e), e.controls.deleteControl = W(), e.controls.ocrControl = U();
85
+ const r = P({}, i);
86
+ r.name || (r.name = `${V}${s + 1}`), u.current.set(e, r), Z(e, r), r.textLayouts && r.textLayouts.length > 0 && $(e, r), r.image || N(r).then((c) => {
87
+ if (c) {
88
+ const l = u.current.get(e);
89
+ if (l && (l.image = c, w)) {
90
+ const S = Array.from(u.current.values());
91
+ w(S);
92
+ }
93
+ }
94
+ }).catch((c) => {
95
+ console.error("Failed to crop region image:", c);
96
+ });
97
+ }), E.current = !0, o.renderAll()) : !E.current && t.labels.length > 0 && (t.labels.forEach((i, s) => {
98
+ if (i.shape.name !== "rect" || Array.from(u.current.values()).find((l) => l.shape.x === i.shape.x && l.shape.y === i.shape.y && l.shape.width === i.shape.width && l.shape.height === i.shape.height))
83
99
  return;
84
- const u = x(o.shape.x, o.shape.y), i = e.getZoom(), r = G / i, h = new N.Rect({
85
- left: u.x,
86
- top: u.y,
87
- width: o.shape.width,
88
- height: o.shape.height,
89
- fill: P,
100
+ const h = A(i.shape.x, i.shape.y), d = o.getZoom(), e = Q / d, r = new j.Rect({
101
+ left: h.x,
102
+ top: h.y,
103
+ width: i.shape.width,
104
+ height: i.shape.height,
105
+ fill: q,
90
106
  // 无填充色
91
- stroke: B,
92
- strokeWidth: r,
107
+ stroke: J,
108
+ strokeWidth: e,
93
109
  strokeUniform: !0,
94
110
  // 边框宽度不受缩放影响
95
111
  selectable: !0,
@@ -100,42 +116,58 @@ const z = ({
100
116
  // 锁定旋转
101
117
  lockUniScaling: !1,
102
118
  // 允许非等比缩放,控制点跟随鼠标
119
+ lockScalingFlip: !0,
120
+ // 禁止缩放时翻转
103
121
  objectCaching: !1,
104
122
  // 禁用缓存,避免缩放时边框变虚
105
123
  statefullCache: !1,
106
124
  noScaleCache: !1
107
125
  });
108
- h.on("modified", () => {
109
- E(h);
110
- }), h.on("moved", () => {
111
- E(h);
112
- }), e.add(h), h.controls.deleteControl = m();
113
- const c = Z({}, o);
114
- c.name || (c.name = `${H}${n + 1}`), f.current.set(h, c), W(h, c), c.textLayouts && c.textLayouts.length > 0 && U(h, c);
115
- }), d.current = !0, e.renderAll());
126
+ r.on("modified", () => {
127
+ k(r);
128
+ }), r.on("moved", () => {
129
+ k(r);
130
+ }), o.add(r), K(r), r.controls.deleteControl = W(), r.controls.ocrControl = U();
131
+ const c = P({}, i);
132
+ c.name || (c.name = `${V}${s + 1}`), u.current.set(r, c), Z(r, c), c.textLayouts && c.textLayouts.length > 0 && $(r, c), c.image || N(c).then((l) => {
133
+ if (l) {
134
+ const S = u.current.get(r);
135
+ if (S && (S.image = l, w)) {
136
+ const z = Array.from(u.current.values());
137
+ w(z);
138
+ }
139
+ }
140
+ }).catch((l) => {
141
+ console.error("Failed to crop region image:", l);
142
+ });
143
+ }), E.current = !0, o.renderAll());
116
144
  }, [
117
- e,
145
+ o,
118
146
  t,
119
147
  t == null ? void 0 : t.labels,
120
- s,
121
- O,
148
+ n,
149
+ Y,
150
+ N,
151
+ w,
122
152
  // 添加 bgImagePosition 作为依赖,确保在位置设置后触发加载
123
- x,
124
- E,
125
- U,
153
+ A,
154
+ k,
155
+ $,
156
+ Z,
126
157
  W,
158
+ U,
159
+ v,
127
160
  m,
128
- $,
129
- w,
130
161
  y,
131
- d,
132
- f,
133
- S,
134
- A,
135
- C,
136
- _
162
+ E,
163
+ u,
164
+ _,
165
+ G,
166
+ x,
167
+ F,
168
+ K
137
169
  ]);
138
170
  };
139
171
  export {
140
- z as useRegionLoader
172
+ a as useRegionLoader
141
173
  };