@glodon-aiot/dataset-annotation 3.14.0-alpha.32 → 3.15.0-alpha.1

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 (114) hide show
  1. package/dist/es/DatasetContext/index.mjs +3 -6
  2. package/dist/es/components/DetectionAnnotation/components/ImageDetail/index.mjs +91 -94
  3. package/dist/es/components/DetectionAnnotation/components/LabelMaker/Drawable.mjs +28 -37
  4. package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +101 -145
  5. package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +195 -256
  6. package/dist/es/components/DetectionAnnotation/index.mjs +424 -456
  7. package/dist/es/components/Iconfont/index.mjs +2 -2
  8. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/index.mjs +1 -1
  9. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/index.mjs +1 -1
  10. package/dist/es/components/OcrAnnotation/OcrModal/index.mjs +45 -43
  11. package/dist/es/components/PicZipImportModal/index.mjs +293 -308
  12. package/dist/es/components/PreLabelOCR/index.mjs +1 -1
  13. package/dist/es/constant.mjs +3 -3
  14. package/dist/es/featuresConfig.mjs +9 -13
  15. package/dist/es/index.mjs +7 -11
  16. package/dist/lib/index.js +3 -4
  17. package/dist/src/DatasetContext/index.d.ts +0 -2
  18. package/dist/src/components/DetectionAnnotation/components/ImageDetail/index.d.ts +0 -1
  19. package/dist/src/constant.d.ts +1 -1
  20. package/dist/src/featuresConfig.d.ts +0 -4
  21. package/dist/src/index.d.ts +0 -3
  22. package/package.json +2 -2
  23. package/dist/es/components/DetectionAnnotation/components/ImageModal/index.mjs +0 -129
  24. package/dist/es/components/DetectionAnnotation/components/ImageModal/style.less.mjs +0 -4
  25. package/dist/es/components/PicZipImportModal/config.mjs +0 -47
  26. package/dist/es/components/PicZipImportModal/pic_vlm_json_zip.svg.mjs +0 -4
  27. package/dist/es/components/PicZipImportModal/pic_vlm_zip.svg.mjs +0 -4
  28. package/dist/es/components/VLMAnnotation/RegionItem.mjs +0 -170
  29. package/dist/es/components/VLMAnnotation/TextAnnotationPanel.mjs +0 -94
  30. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.mjs +0 -116
  31. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasSetup.mjs +0 -115
  32. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasZoom.mjs +0 -42
  33. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCropRegionImage.mjs +0 -55
  34. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteControl.mjs +0 -51
  35. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.mjs +0 -62
  36. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +0 -421
  37. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.mjs +0 -100
  38. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRLoadingIcon.mjs +0 -106
  39. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.mjs +0 -101
  40. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.mjs +0 -103
  41. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionHover.mjs +0 -38
  42. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.mjs +0 -173
  43. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionNameText.mjs +0 -72
  44. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +0 -116
  45. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.mjs +0 -98
  46. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useTextLayouts.mjs +0 -156
  47. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/ai.svg.mjs +0 -4
  48. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/del.png.mjs +0 -4
  49. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/error.svg.mjs +0 -4
  50. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/loading.svg.mjs +0 -4
  51. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/star.svg.mjs +0 -4
  52. package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +0 -651
  53. package/dist/es/components/VLMAnnotation/VLMLabelMaker/style.less.mjs +0 -4
  54. package/dist/es/components/VLMAnnotation/VLMLabelMaker/utils/coordinateUtils.mjs +0 -33
  55. package/dist/es/components/VLMAnnotation/components/DragButton.mjs +0 -18
  56. package/dist/es/components/VLMAnnotation/components/FitToScreenButton.mjs +0 -16
  57. package/dist/es/components/VLMAnnotation/components/RectangleButton.mjs +0 -30
  58. package/dist/es/components/VLMAnnotation/components/Toolbar.mjs +0 -40
  59. package/dist/es/components/VLMAnnotation/components/ZoomControls.mjs +0 -44
  60. package/dist/es/components/VLMAnnotation/constants.mjs +0 -57
  61. package/dist/es/components/VLMAnnotation/index.mjs +0 -279
  62. package/dist/es/components/VLMAnnotation/style.less.mjs +0 -4
  63. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/index.mjs +0 -343
  64. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/style.less.mjs +0 -4
  65. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.mjs +0 -240
  66. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/index.mjs +0 -201
  67. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/style.less.mjs +0 -4
  68. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/index.mjs +0 -455
  69. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/style.less.mjs +0 -4
  70. package/dist/es/components/VLMAnnotationDetail/VlmModal/index.mjs +0 -149
  71. package/dist/es/components/VLMAnnotationDetail/VlmModal/style.less.mjs +0 -4
  72. package/dist/es/components/VLMAnnotationDetail/index.mjs +0 -449
  73. package/dist/es/components/VLMAnnotationDetail/style.less.mjs +0 -4
  74. package/dist/es/createVlmtasetAnnotation/index.mjs +0 -131
  75. package/dist/src/components/DetectionAnnotation/components/ImageModal/index.d.ts +0 -34
  76. package/dist/src/components/Iconfont/font_4439177_tgvowh6bmlb.d.ts +0 -0
  77. package/dist/src/components/PicZipImportModal/config.d.ts +0 -23
  78. package/dist/src/components/VLMAnnotation/ImageAnnotationDebugger.d.ts +0 -4
  79. package/dist/src/components/VLMAnnotation/RegionItem.d.ts +0 -4
  80. package/dist/src/components/VLMAnnotation/TextAnnotationPanel.d.ts +0 -4
  81. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.d.ts +0 -13
  82. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasSetup.d.ts +0 -38
  83. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasZoom.d.ts +0 -18
  84. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCropRegionImage.d.ts +0 -7
  85. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteControl.d.ts +0 -13
  86. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.d.ts +0 -22
  87. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +0 -34
  88. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.d.ts +0 -16
  89. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRLoadingIcon.d.ts +0 -11
  90. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.d.ts +0 -29
  91. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.d.ts +0 -31
  92. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionHover.d.ts +0 -13
  93. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.d.ts +0 -41
  94. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionNameText.d.ts +0 -12
  95. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.d.ts +0 -16
  96. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.d.ts +0 -32
  97. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useTextLayouts.d.ts +0 -25
  98. package/dist/src/components/VLMAnnotation/VLMLabelMaker/index.d.ts +0 -4
  99. package/dist/src/components/VLMAnnotation/VLMLabelMaker/utils/coordinateUtils.d.ts +0 -32
  100. package/dist/src/components/VLMAnnotation/components/DragButton.d.ts +0 -7
  101. package/dist/src/components/VLMAnnotation/components/FitToScreenButton.d.ts +0 -6
  102. package/dist/src/components/VLMAnnotation/components/RectangleButton.d.ts +0 -7
  103. package/dist/src/components/VLMAnnotation/components/Toolbar.d.ts +0 -4
  104. package/dist/src/components/VLMAnnotation/components/ZoomControls.d.ts +0 -4
  105. package/dist/src/components/VLMAnnotation/constants.d.ts +0 -113
  106. package/dist/src/components/VLMAnnotation/index.d.ts +0 -6
  107. package/dist/src/components/VLMAnnotation/types.d.ts +0 -187
  108. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/index.d.ts +0 -14
  109. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.d.ts +0 -12
  110. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/index.d.ts +0 -12
  111. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/index.d.ts +0 -12
  112. package/dist/src/components/VLMAnnotationDetail/VlmModal/index.d.ts +0 -17
  113. package/dist/src/components/VLMAnnotationDetail/index.d.ts +0 -6
  114. package/dist/src/createVlmtasetAnnotation/index.d.ts +0 -16
@@ -1,651 +0,0 @@
1
- var Ke = Object.defineProperty, $e = Object.defineProperties;
2
- var Ge = Object.getOwnPropertyDescriptors;
3
- var Se = Object.getOwnPropertySymbols;
4
- var qe = Object.prototype.hasOwnProperty, Je = Object.prototype.propertyIsEnumerable;
5
- var Ae = (c, g, l) => g in c ? Ke(c, g, { enumerable: !0, configurable: !0, writable: !0, value: l }) : c[g] = l, ne = (c, g) => {
6
- for (var l in g || (g = {}))
7
- qe.call(g, l) && Ae(c, l, g[l]);
8
- if (Se)
9
- for (var l of Se(g))
10
- Je.call(g, l) && Ae(c, l, g[l]);
11
- return c;
12
- }, we = (c, g) => $e(c, Ge(g));
13
- import { jsxs as Oe, jsx as b } from "react/jsx-runtime";
14
- import Qe, { useRef as C, useState as x, useCallback as w, useEffect as p, useImperativeHandle as Ve } from "react";
15
- import { fabric as P } from "fabric";
16
- import { useKeyPress as Y } from "ahooks";
17
- import et from "classnames";
18
- import "./style.less.mjs";
19
- import tt from "../components/Toolbar.mjs";
20
- import { useOCRLoadingIcon as ot } from "./hooks/useOCRLoadingIcon.mjs";
21
- import { useRegionNameText as rt } from "./hooks/useRegionNameText.mjs";
22
- import { useCropRegionImage as nt } from "./hooks/useCropRegionImage.mjs";
23
- import { useDrawingMode as st } from "./hooks/useDrawingMode.mjs";
24
- import { useRegionLoader as ct } from "./hooks/useRegionLoader.mjs";
25
- import { useCanvasSetup as it } from "./hooks/useCanvasSetup.mjs";
26
- import { useTextLayouts as at } from "./hooks/useTextLayouts.mjs";
27
- import { useRegionUpdate as ft } from "./hooks/useRegionUpdate.mjs";
28
- import { useCanvasDrag as ut } from "./hooks/useCanvasDrag.mjs";
29
- import { useRegionSelection as dt } from "./hooks/useRegionSelection.mjs";
30
- import { useOCRRecognition as mt } from "./hooks/useOCRRecognition.mjs";
31
- import { useDeleteRegion as lt } from "./hooks/useDeleteRegion.mjs";
32
- import { useDeleteControl as ht } from "./hooks/useDeleteControl.mjs";
33
- import { useOCRControl as gt } from "./hooks/useOCRControl.mjs";
34
- import { useCanvasZoom as Rt } from "./hooks/useCanvasZoom.mjs";
35
- import { useRegionHover as Et } from "./hooks/useRegionHover.mjs";
36
- import { useRegionBoundaryCheck as pt } from "./hooks/useRegionBoundaryCheck.mjs";
37
- import { canvasToImageCoords as Ct, imageToCanvasCoords as Tt } from "./utils/coordinateUtils.mjs";
38
- import { REGION_NAME_PREFIX as vt, DEFAULT_REGION_NAME as It, ZOOM_PRECISION_ERROR as kt, TEXT_LAYOUT_RECT_FILL_COLOR as Nt, TEXT_LAYOUT_RECT_STROKE_COLOR as St, TRANSPARENT_FILL as _e, SELECTED_RECT_FILL_COLOR as At, BASE_STROKE_WIDTH as se, ACTIVE_RECT_STROKE_COLOR as wt, RECT_STROKE_COLOR as Ot } from "../constants.mjs";
39
- const _t = Qe.forwardRef(({
40
- sample: c,
41
- labelDefinitions: g,
42
- labels: l,
43
- onImageLoad: xe,
44
- onChange: O,
45
- onRegionSelect: ce,
46
- onRegionChange: J,
47
- ocrRecognize: Le,
48
- activeLabelValue: R,
49
- onClearActive: Q,
50
- selectedRegion: T,
51
- onAppendTextToActive: Me,
52
- readOnly: h
53
- }, De) => {
54
- var Ie, ke;
55
- const ie = C(null), k = C(null), [ye, Ue] = x(!0), [e, We] = x(), [L, be] = x(), [v, ae] = x(1), [N, j] = x(h || !1), [I, _] = x(!1), [V, Pe] = x({
56
- left: 0,
57
- top: 0
58
- }), F = C({
59
- left: 0,
60
- top: 0
61
- }), fe = C({
62
- width: 0,
63
- height: 0
64
- }), i = C(/* @__PURE__ */ new Map()), ue = C(null), de = C(void 0), me = C(!1), le = C(!1), z = C({
65
- width: 0,
66
- height: 0
67
- }), he = C(!1), {
68
- updateOCRLoadingIcon: xt,
69
- ocrLoadingIconMapRef: M
70
- } = ot(e), {
71
- updateRegionNameText: B,
72
- regionNameTextMapRef: S
73
- } = rt(e), ee = nt(c == null ? void 0 : c.fileUrl), je = w((o) => {
74
- e && (S.current.forEach((t, r) => {
75
- const n = r.left || 0, m = r.top || 0;
76
- t.set({
77
- left: n,
78
- // 与标注框左边对齐
79
- top: m,
80
- // 下边缘与标注框上边缘对齐(因为 originY 是 'bottom')
81
- scaleX: 1 / o,
82
- // 反向缩放,抵消画布缩放
83
- scaleY: 1 / o
84
- // 反向缩放,抵消画布缩放
85
- });
86
- }), e.renderAll());
87
- }, [e]), {
88
- updateCanvas: X
89
- } = it({
90
- sample: c,
91
- image: L,
92
- onImageLoad: xe,
93
- canvasRef: ie,
94
- containerRef: k,
95
- canvasInitializedRef: me,
96
- bgImagePositionRef: F,
97
- bgImageSizeRef: fe,
98
- rectMapRef: i,
99
- updateTextLayersRef: ue,
100
- onRectPositionUpdated: je,
101
- setCanvas: We,
102
- setImage: be,
103
- setScale: ae,
104
- setBgImagePosition: Pe,
105
- setLoading: Ue
106
- }), Fe = w(() => {
107
- const o = Array.from(i.current.values());
108
- o.forEach((t, r) => {
109
- t.name = `${vt}${r + 1}`;
110
- }), i.current.forEach((t, r) => {
111
- const n = S.current.get(r);
112
- n && (n.set("text", t.name || It), e == null || e.renderAll());
113
- }), O && O(o);
114
- }, [O, e]), {
115
- zoom: Xe
116
- } = Rt({
117
- canvas: e,
118
- setScale: ae,
119
- isZoomingRef: he
120
- }), Z = w(
121
- (o, t) => Ct(o, t, e, L, F),
122
- [e, L, V]
123
- // 添加 bgImagePosition 作为依赖,确保在图片位置更新后函数能正确工作
124
- ), K = w(
125
- (o, t) => Tt(o, t, e, F),
126
- [e, V]
127
- // 添加 bgImagePosition 作为依赖,确保在图片位置更新后函数能正确工作
128
- ), {
129
- updateTextLayers: $,
130
- textLayersMapRef: d,
131
- textLayoutContentMapRef: G
132
- } = at({
133
- canvas: e,
134
- imageToCanvasCoords: K,
135
- activeLabelValue: R,
136
- onAppendTextToActive: Me
137
- });
138
- ue.current = $;
139
- const {
140
- performOCRIfNeeded: ge,
141
- performOCR: q,
142
- ocrRecognizingRef: Re,
143
- ocrErrorRef: Ee
144
- } = mt({
145
- ocrRecognize: Le,
146
- onChange: O,
147
- updateTextLayers: $,
148
- canvas: e,
149
- rectMapRef: i,
150
- textLayersMapRef: d,
151
- textLayoutContentMapRef: G
152
- }), {
153
- updateRegionShapeAndImage: pe
154
- } = ft({
155
- canvas: e,
156
- image: L,
157
- draggable: N,
158
- canvasToImageCoords: Z,
159
- imageToCanvasCoords: K,
160
- cropRegionImage: ee,
161
- onChange: O,
162
- onRegionChange: J,
163
- performOCRIfNeeded: ge,
164
- updateTextLayers: $,
165
- rectMapRef: i,
166
- regionNameTextMapRef: S,
167
- ocrLoadingIconMapRef: M
168
- }), {
169
- setupBoundaryCheck: Ce
170
- } = pt({
171
- canvas: e,
172
- image: L,
173
- canvasToImageCoords: Z,
174
- imageToCanvasCoords: K,
175
- bgImagePositionRef: F,
176
- bgImageSizeRef: fe,
177
- regionNameTextMapRef: S
178
- });
179
- p(() => {
180
- X();
181
- }, [X]), p(() => {
182
- e && (d.current.forEach((o) => {
183
- o.forEach((t) => {
184
- t.off("mousedown"), t.off("mouseover"), t.off("mouseout"), e.remove(t), G.current.delete(t);
185
- });
186
- }), d.current.clear(), S.current.forEach((o) => {
187
- e.remove(o);
188
- }), S.current.clear(), M.current.forEach((o) => {
189
- e.remove(o);
190
- }), M.current.clear(), i.current.forEach((o, t) => {
191
- t.off("modified"), t.off("moved"), e.remove(t);
192
- }), i.current.clear(), le.current = !1, de.current = void 0, e.renderAll());
193
- }, [e, c == null ? void 0 : c.id]), p(() => {
194
- if (!k.current)
195
- return;
196
- z.current = {
197
- width: k.current.offsetWidth,
198
- height: k.current.offsetHeight
199
- };
200
- const o = new ResizeObserver(() => {
201
- if (!k.current || he.current)
202
- return;
203
- if (e) {
204
- const s = e.getZoom();
205
- if (Math.abs(s - v) > kt)
206
- return;
207
- }
208
- const t = k.current.offsetWidth, r = k.current.offsetHeight, n = z.current.width, m = z.current.height;
209
- (t !== n || r !== m) && (z.current = {
210
- width: t,
211
- height: r
212
- }, X());
213
- });
214
- return o.observe(k.current), () => {
215
- o.disconnect();
216
- };
217
- }, [X, e, v]), Y("ctrl", () => {
218
- h || (I && (_(!1), y()), j(!0));
219
- }, {
220
- events: ["keydown"]
221
- }), Y("ctrl", () => {
222
- h || j(!1);
223
- }, {
224
- events: ["keyup"]
225
- }), p(() => {
226
- if (!e)
227
- return;
228
- const o = se / v, t = /* @__PURE__ */ new Set();
229
- d.current.forEach((r) => {
230
- r.forEach((n) => {
231
- t.add(n);
232
- });
233
- }), e.getObjects().forEach((r) => {
234
- r instanceof P.Rect && !t.has(r) && r.set({
235
- strokeWidth: o,
236
- strokeUniform: !0,
237
- objectCaching: !1,
238
- // 禁用缓存,避免缩放时边框变虚
239
- statefullCache: !1,
240
- noScaleCache: !1
241
- });
242
- }), d.current.forEach((r) => {
243
- r.forEach((n) => {
244
- n.set({
245
- fill: Nt,
246
- // 确保填充色被保留
247
- stroke: St,
248
- // 确保边框色被保留
249
- strokeWidth: o,
250
- // 根据缩放调整边框宽度,保持视觉一致
251
- strokeUniform: !0,
252
- // 确保边框宽度随缩放调整
253
- objectCaching: !1,
254
- statefullCache: !1,
255
- noScaleCache: !1
256
- });
257
- });
258
- }), S.current.forEach((r, n) => {
259
- const m = n.left || 0, s = n.top || 0;
260
- r.set({
261
- left: m,
262
- // 与标注框左边对齐
263
- top: s,
264
- // 下边缘与标注框上边缘对齐(因为 originY 是 'bottom')
265
- scaleX: 1 / v,
266
- // 反向缩放,抵消画布缩放
267
- scaleY: 1 / v
268
- // 反向缩放,抵消画布缩放
269
- });
270
- const a = M.current.get(n);
271
- if (a) {
272
- const u = n.getScaledWidth();
273
- n.getScaledHeight(), a.set({
274
- left: m,
275
- // top 位置由动画控制,这里不更新
276
- scaleX: 1 / v,
277
- // 反向缩放,抵消画布缩放,保持固定视觉粗细
278
- scaleY: 1 / v
279
- // 反向缩放,抵消画布缩放,保持固定视觉粗细
280
- });
281
- const f = a.getObjects();
282
- if (f && f.length > 0) {
283
- const E = u * v;
284
- f.forEach((A) => {
285
- A instanceof P.Rect && A.set("width", E);
286
- });
287
- }
288
- }
289
- }), e.renderAll();
290
- }, [e, v]), ut({
291
- canvas: e,
292
- draggable: N,
293
- drawingMode: I,
294
- textLayersMapRef: d
295
- });
296
- const {
297
- performDelete: D,
298
- deleteDirectly: Ze
299
- } = lt({
300
- canvas: e,
301
- onRegionChange: J,
302
- updateRegionNames: Fe,
303
- rectMapRef: i,
304
- textLayersMapRef: d,
305
- textLayoutContentMapRef: G,
306
- regionNameTextMapRef: S,
307
- ocrLoadingIconMapRef: M
308
- });
309
- w((o) => {
310
- if (!e)
311
- return;
312
- let t = null;
313
- i.current.forEach((r, n) => {
314
- r.id === o && (t = n);
315
- }), t && D(t);
316
- }, [e, D]);
317
- const He = w((o) => {
318
- if (!e)
319
- return;
320
- let t = null;
321
- i.current.forEach((r) => {
322
- r.id === o && (t = r);
323
- }), t && q(t);
324
- }, [e, q]), Ye = w((o) => {
325
- if (!e)
326
- return;
327
- const t = i.current.get(o);
328
- t && q(t);
329
- }, [e, q]);
330
- Ve(De, () => ({
331
- performOCRById: He,
332
- ocrRecognizingRef: Re,
333
- ocrErrorRef: Ee
334
- }));
335
- const {
336
- createDeleteControl: te
337
- } = ht({
338
- performDelete: D
339
- }), {
340
- createOCRControl: oe
341
- } = gt({
342
- performOCR: Ye,
343
- ocrRecognizingRef: Re,
344
- ocrErrorRef: Ee,
345
- rectMapRef: i
346
- });
347
- dt({
348
- canvas: e,
349
- onRegionSelect: ce,
350
- createDeleteControl: te,
351
- createOCRControl: oe,
352
- textLayersMapRef: d,
353
- rectMapRef: i
354
- });
355
- const {
356
- stopDraw: y
357
- } = st({
358
- canvas: e,
359
- drawingMode: I,
360
- draggable: N,
361
- setDrawingMode: _,
362
- canvasToImageCoords: Z,
363
- labelDefinitions: g,
364
- onChange: O,
365
- cropRegionImage: ee,
366
- updateRegionShapeAndImage: pe,
367
- performOCRIfNeeded: ge,
368
- createDeleteControl: te,
369
- createOCRControl: oe,
370
- updateRegionNameText: B,
371
- onRegionChange: J,
372
- onRegionSelect: ce,
373
- rectMapRef: i,
374
- textLayersMapRef: d,
375
- setupBoundaryCheck: Ce
376
- });
377
- p(() => {
378
- R && (_(!1), y());
379
- }, [R, y]), p(() => {
380
- h && (j(!0), _(!1), y());
381
- }, [h, y]), p(() => {
382
- if (!e)
383
- return;
384
- const o = () => {
385
- e.getObjects().forEach((t) => {
386
- t instanceof P.Rect && t.selectable && (t.set({
387
- lockMovementX: h,
388
- lockMovementY: h,
389
- lockScalingX: h,
390
- lockScalingY: h,
391
- hasControls: !h
392
- // 在只读模式下,如果有 activeLabelValue,我们可能希望它保持选中状态
393
- // 但不允许用户通过点击来取消选中或选中其他(这个由 canvas.selection 控制)
394
- }), h && t.controls);
395
- }), e.requestRenderAll();
396
- };
397
- return o(), e.on("object:added", o), () => {
398
- e.off("object:added", o);
399
- };
400
- }, [e, h]), ct({
401
- canvas: e,
402
- sample: c,
403
- image: L,
404
- bgImagePosition: V,
405
- canvasInitializedRef: me,
406
- bgImagePositionRef: F,
407
- sampleRef: de,
408
- labelsLoadedRef: le,
409
- rectMapRef: i,
410
- textLayersMapRef: d,
411
- textLayoutContentMapRef: G,
412
- regionNameTextMapRef: S,
413
- ocrLoadingIconMapRef: M,
414
- imageToCanvasCoords: K,
415
- updateRegionShapeAndImage: pe,
416
- createDeleteControl: te,
417
- createOCRControl: oe,
418
- updateRegionNameText: B,
419
- updateTextLayers: $,
420
- setupBoundaryCheck: Ce,
421
- cropRegionImage: ee,
422
- onChange: O
423
- });
424
- const Te = C([]);
425
- p(() => {
426
- if (!e)
427
- return;
428
- const o = Te.current, t = l != null ? l : [], r = new Set(o.map((s) => s.id)), n = new Set(t.map((s) => s.id));
429
- if (t.length < o.length) {
430
- const s = [];
431
- i.current.forEach((a, u) => {
432
- r.has(a.id) && !n.has(a.id) && s.push(u);
433
- }), s.forEach((a) => {
434
- Ze(a);
435
- });
436
- }
437
- if (Te.current = t, !l || l.length === 0)
438
- return;
439
- let m = !1;
440
- i.current.forEach((s, a) => {
441
- var E, A;
442
- const u = l.find((H) => H.id === s.id);
443
- if (!u)
444
- return;
445
- const f = we(ne(ne({}, s), u), {
446
- // Keep shape from canvas to avoid desync
447
- shape: s.shape,
448
- image: (E = u.image) != null ? E : s.image,
449
- textLayouts: (A = u.textLayouts) != null ? A : s.textLayouts
450
- });
451
- (f.name !== s.name || f.content !== s.content || f.image !== s.image || f.textLayouts !== s.textLayouts) && (i.current.set(a, f), f.name !== s.name && B(a, f), m = !0);
452
- }), m && (e == null || e.renderAll());
453
- }, [l, e, B, D]), Et({
454
- canvas: e,
455
- drawingMode: I,
456
- draggable: N,
457
- textLayersMapRef: d
458
- }), p(() => {
459
- if (e)
460
- if (T === null) {
461
- const o = /* @__PURE__ */ new Set();
462
- d.current.forEach((r) => {
463
- r.forEach((n) => {
464
- o.add(n);
465
- });
466
- }), e.getObjects().forEach((r) => {
467
- r instanceof P.Rect && !o.has(r) && r.set({
468
- fill: _e
469
- // 移除填充色
470
- });
471
- }), e.getActiveObject() && (e.discardActiveObject(), e.renderAll());
472
- } else {
473
- const o = e.getActiveObject(), t = o ? i.current.get(o) : null;
474
- if ((t == null ? void 0 : t.id) === (T == null ? void 0 : T.id))
475
- return;
476
- if (T) {
477
- let r = null;
478
- if (i.current.forEach((n, m) => {
479
- n.id === T.id && (r = m);
480
- }), r) {
481
- const n = /* @__PURE__ */ new Set();
482
- d.current.forEach((u) => {
483
- u.forEach((f) => {
484
- n.add(f);
485
- });
486
- }), e.getObjects().forEach((u) => {
487
- u instanceof P.Rect && !n.has(u) && u.set({
488
- fill: _e
489
- // 移除填充色
490
- });
491
- });
492
- const m = e.getZoom(), s = se / m, a = r;
493
- a.set({
494
- fill: At,
495
- // 选中时添加填充色
496
- strokeUniform: !0,
497
- strokeWidth: s,
498
- objectCaching: !1,
499
- statefullCache: !1,
500
- noScaleCache: !1
501
- }), e.setActiveObject(a), e.renderAll();
502
- }
503
- }
504
- }
505
- }, [e, T, i, d]), p(() => {
506
- var a;
507
- if (!e)
508
- return;
509
- const o = (a = R == null ? void 0 : R.region) == null ? void 0 : a.id, t = T == null ? void 0 : T.id, r = /* @__PURE__ */ new Set();
510
- d.current.forEach((u) => {
511
- u.forEach((f) => {
512
- r.add(f);
513
- });
514
- });
515
- let n = !1;
516
- const m = e.getZoom(), s = se / m;
517
- i.current.forEach((u, f) => {
518
- if (r.has(f))
519
- return;
520
- const E = o === u.id;
521
- if (t === u.id) {
522
- const W = d.current.get(f);
523
- W && W.length > 0 && W.forEach((Ne) => {
524
- Ne.visible !== E && (Ne.set({
525
- visible: E
526
- }), n = !0);
527
- });
528
- return;
529
- }
530
- const H = f.stroke, re = E ? wt : Ot;
531
- H !== re && (f.set({
532
- stroke: re,
533
- strokeWidth: s,
534
- strokeUniform: !0
535
- }), n = !0);
536
- const U = d.current.get(f);
537
- U && U.length > 0 && U.forEach((W) => {
538
- W.visible !== E && (W.set({
539
- visible: E
540
- }), n = !0);
541
- });
542
- }), n && e.renderAll();
543
- }, [e, R, T, d, i]), p(() => {
544
- var n, m;
545
- if (!e)
546
- return;
547
- const o = (n = R == null ? void 0 : R.region) == null ? void 0 : n.id;
548
- if (!o)
549
- return;
550
- let t = null;
551
- if (i.current.forEach((s, a) => {
552
- s.id === o && (t = a);
553
- }), !t)
554
- return;
555
- t.bringToFront(), ((m = d.current.get(t)) != null ? m : []).forEach((s) => {
556
- s.bringToFront();
557
- }), e.renderAll();
558
- }, [e, R, i, d]), p(() => {
559
- if (!e || !R || !Q)
560
- return;
561
- const o = (t) => {
562
- var U;
563
- if (I)
564
- return;
565
- const r = (U = t.e) == null ? void 0 : U.target;
566
- if ((r == null ? void 0 : r.tagName) === "INPUT" || (r == null ? void 0 : r.tagName) === "TEXTAREA")
567
- return;
568
- const n = e.getPointer(t.e), m = n.x, s = n.y, a = Z(m, s), u = R.region, {
569
- x: f,
570
- y: E,
571
- width: A,
572
- height: H
573
- } = u.shape;
574
- a.x >= f && a.x <= f + A && a.y >= E && a.y <= E + H || Q();
575
- };
576
- return e.on("mouse:down", o), () => {
577
- e.off("mouse:down", o);
578
- };
579
- }, [e, R, Q, Z, I]);
580
- const ve = w((o) => {
581
- const t = o.target;
582
- if ((t == null ? void 0 : t.tagName) === "INPUT" || (t == null ? void 0 : t.tagName) === "TEXTAREA" || !e || h)
583
- return;
584
- const r = e.getActiveObject();
585
- !r || !(r instanceof P.Rect) || D(r);
586
- }, [e, D]);
587
- Y("Delete", ve), Y("Backspace", ve), Y("r", (o) => {
588
- const t = o.target;
589
- (t == null ? void 0 : t.tagName) === "INPUT" || (t == null ? void 0 : t.tagName) === "TEXTAREA" || t != null && t.isContentEditable || h || !I && !N && _(!0);
590
- }, {
591
- exactMatch: !1
592
- // 允许大小写
593
- });
594
- const ze = () => {
595
- h || (I && (_(!1), y()), j(!N));
596
- }, Be = () => {
597
- h || (N && j(!1), _(!I));
598
- };
599
- return p(() => () => {
600
- e && e.dispose();
601
- }, []), /* @__PURE__ */ Oe("div", {
602
- style: {
603
- width: "100%",
604
- height: "100%",
605
- display: "flex",
606
- position: "relative"
607
- },
608
- children: [ye && /* @__PURE__ */ b("div", {
609
- className: "vlm-loading-overlay",
610
- children: /* @__PURE__ */ b("div", {
611
- className: "vlm-loading-spinner"
612
- })
613
- }), /* @__PURE__ */ b("div", {
614
- className: "vlm-marker-toolbar",
615
- children: /* @__PURE__ */ b(tt, {
616
- drawingMode: I,
617
- draggable: N,
618
- scale: v,
619
- onToggleDrawingMode: Be,
620
- onToggleDrag: ze,
621
- onZoom: Xe,
622
- onFitToScreen: X,
623
- readOnly: h
624
- })
625
- }), /* @__PURE__ */ Oe("div", {
626
- ref: k,
627
- className: et({
628
- "vlm-label-maker-wrap": !0,
629
- draggable: N
630
- }),
631
- onContextMenu: (o) => {
632
- o.preventDefault();
633
- },
634
- style: {
635
- flex: 1,
636
- position: "relative"
637
- },
638
- children: [(((Ie = c == null ? void 0 : c.sampleFileName) == null ? void 0 : Ie.originalName) || ((ke = c == null ? void 0 : c.sampleFileName) == null ? void 0 : ke.name)) && /* @__PURE__ */ b("div", {
639
- className: "vlm-image-name",
640
- children: c.sampleFileName.originalName || c.sampleFileName.name
641
- }), /* @__PURE__ */ b("canvas", {
642
- className: "vlm-label-maker-canvas",
643
- ref: ie
644
- })]
645
- })]
646
- });
647
- });
648
- _t.displayName = "VLMLabelMaker";
649
- export {
650
- _t as default
651
- };
@@ -1,4 +0,0 @@
1
- const t = "";
2
- export {
3
- t as default
4
- };
@@ -1,33 +0,0 @@
1
- const u = (c, e, o, r, n) => {
2
- if (!o || !r)
3
- return {
4
- x: 0,
5
- y: 0
6
- };
7
- const t = r.getElement();
8
- if (!(t != null && t.width) || !(t != null && t.height))
9
- return {
10
- x: 0,
11
- y: 0
12
- };
13
- const s = c - n.current.left, a = e - n.current.top;
14
- return {
15
- x: s,
16
- y: a
17
- };
18
- }, x = (c, e, o, r) => {
19
- if (!o)
20
- return {
21
- x: 0,
22
- y: 0
23
- };
24
- const n = c + r.current.left, t = e + r.current.top;
25
- return {
26
- x: n,
27
- y: t
28
- };
29
- };
30
- export {
31
- u as canvasToImageCoords,
32
- x as imageToCanvasCoords
33
- };
@@ -1,18 +0,0 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { Tooltip as e, Button as i } from "antd";
3
- import { DragOutlined as a } from "@ant-design/icons";
4
- const c = ({
5
- active: r,
6
- onClick: o
7
- }) => /* @__PURE__ */ t(e, {
8
- title: "拖动-按住ctrl",
9
- placement: "right",
10
- children: /* @__PURE__ */ t(i, {
11
- icon: /* @__PURE__ */ t(a, {}),
12
- className: r ? "active" : "",
13
- onClick: o
14
- })
15
- });
16
- export {
17
- c as default
18
- };