@glodon-aiot/dataset-annotation 3.14.0-alpha.33 → 3.15.0-alpha.2

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