@glodon-aiot/dataset-annotation 3.9.0-beta.9 → 3.10.0-alpha.10

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 (110) hide show
  1. package/dist/dataset-annotation.js +123598 -0
  2. package/dist/dataset-annotation.umd.cjs +1017 -0
  3. package/dist/es/DatasetContext/index.mjs +6 -3
  4. package/dist/es/components/Iconfont/index.mjs +2 -2
  5. package/dist/es/components/PicZipImportModal/config.mjs +41 -0
  6. package/dist/es/components/PicZipImportModal/index.mjs +317 -301
  7. package/dist/es/components/PicZipImportModal/pic_vlm_json_zip.svg.mjs +4 -0
  8. package/dist/es/components/PicZipImportModal/pic_vlm_zip.svg.mjs +4 -0
  9. package/dist/es/components/VLMAnnotation/RegionItem.mjs +95 -0
  10. package/dist/es/components/VLMAnnotation/TextAnnotationPanel.mjs +83 -0
  11. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.mjs +75 -0
  12. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasSetup.mjs +115 -0
  13. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasZoom.mjs +42 -0
  14. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCropRegionImage.mjs +55 -0
  15. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteControl.mjs +51 -0
  16. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.mjs +47 -0
  17. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +220 -0
  18. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRLoadingIcon.mjs +106 -0
  19. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.mjs +68 -0
  20. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionHover.mjs +38 -0
  21. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.mjs +141 -0
  22. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionNameText.mjs +72 -0
  23. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +102 -0
  24. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.mjs +103 -0
  25. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useTextLayouts.mjs +156 -0
  26. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/del.png.mjs +4 -0
  27. package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +507 -0
  28. package/dist/es/components/VLMAnnotation/VLMLabelMaker/style.less.mjs +4 -0
  29. package/dist/es/components/VLMAnnotation/VLMLabelMaker/utils/coordinateUtils.mjs +33 -0
  30. package/dist/es/components/VLMAnnotation/components/DragButton.mjs +18 -0
  31. package/dist/es/components/VLMAnnotation/components/FitToScreenButton.mjs +16 -0
  32. package/dist/es/components/VLMAnnotation/components/RectangleButton.mjs +30 -0
  33. package/dist/es/components/VLMAnnotation/components/Toolbar.mjs +40 -0
  34. package/dist/es/components/VLMAnnotation/components/ZoomControls.mjs +44 -0
  35. package/dist/es/components/VLMAnnotation/constants.mjs +50 -0
  36. package/dist/es/components/VLMAnnotation/index.mjs +242 -0
  37. package/dist/es/components/VLMAnnotation/style.less.mjs +4 -0
  38. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/index.mjs +345 -0
  39. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/style.less.mjs +4 -0
  40. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.mjs +240 -0
  41. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/index.mjs +201 -0
  42. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/style.less.mjs +4 -0
  43. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/index.mjs +399 -0
  44. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/style.less.mjs +4 -0
  45. package/dist/es/components/VLMAnnotationDetail/VlmModal/index.mjs +139 -0
  46. package/dist/es/components/VLMAnnotationDetail/VlmModal/style.less.mjs +4 -0
  47. package/dist/es/components/VLMAnnotationDetail/index.mjs +446 -0
  48. package/dist/es/components/VLMAnnotationDetail/style.less.mjs +4 -0
  49. package/dist/es/constant.mjs +3 -3
  50. package/dist/es/createVlmtasetAnnotation/index.mjs +131 -0
  51. package/dist/es/featuresConfig.mjs +13 -9
  52. package/dist/es/index.mjs +11 -7
  53. package/dist/example/DatasetAnnotationDemo.d.ts +3 -0
  54. package/dist/example/DemoTabs.d.ts +3 -0
  55. package/dist/example/DetectionDatasetDemo.d.ts +5 -0
  56. package/dist/example/DetectionImageDemo.d.ts +5 -0
  57. package/dist/example/OcrDatasetDemo.d.ts +5 -0
  58. package/dist/example/OcrImageDemo.d.ts +5 -0
  59. package/dist/example/OcrkvcDatasetDemo.d.ts +5 -0
  60. package/dist/example/constant.local.d.ts +6 -0
  61. package/dist/example/index.d.ts +1 -0
  62. package/dist/lib/index.js +4 -3
  63. package/dist/src/DatasetContext/index.d.ts +2 -0
  64. package/dist/src/components/Iconfont/font_4439177_tgvowh6bmlb.d.ts +0 -0
  65. package/dist/src/components/PicZipImportModal/config.d.ts +20 -0
  66. package/dist/src/components/VLMAnnotation/ImageAnnotationDebugger.d.ts +4 -0
  67. package/dist/src/components/VLMAnnotation/RegionItem.d.ts +4 -0
  68. package/dist/src/components/VLMAnnotation/TextAnnotationPanel.d.ts +4 -0
  69. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.d.ts +12 -0
  70. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasSetup.d.ts +38 -0
  71. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasZoom.d.ts +18 -0
  72. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCropRegionImage.d.ts +7 -0
  73. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteControl.d.ts +13 -0
  74. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.d.ts +21 -0
  75. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +31 -0
  76. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRLoadingIcon.d.ts +11 -0
  77. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.d.ts +28 -0
  78. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionHover.d.ts +13 -0
  79. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.d.ts +37 -0
  80. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionNameText.d.ts +12 -0
  81. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.d.ts +15 -0
  82. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.d.ts +32 -0
  83. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useTextLayouts.d.ts +25 -0
  84. package/dist/src/components/VLMAnnotation/VLMLabelMaker/index.d.ts +4 -0
  85. package/dist/src/components/VLMAnnotation/VLMLabelMaker/utils/coordinateUtils.d.ts +32 -0
  86. package/dist/src/components/VLMAnnotation/components/DragButton.d.ts +7 -0
  87. package/dist/src/components/VLMAnnotation/components/FitToScreenButton.d.ts +6 -0
  88. package/dist/src/components/VLMAnnotation/components/RectangleButton.d.ts +7 -0
  89. package/dist/src/components/VLMAnnotation/components/Toolbar.d.ts +4 -0
  90. package/dist/src/components/VLMAnnotation/components/ZoomControls.d.ts +4 -0
  91. package/dist/src/components/VLMAnnotation/constants.d.ts +97 -0
  92. package/dist/src/components/VLMAnnotation/index.d.ts +6 -0
  93. package/dist/src/components/VLMAnnotation/types.d.ts +172 -0
  94. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/index.d.ts +14 -0
  95. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/ImageDetail/index.d.ts +16 -0
  96. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/OCRBoxMaker/LabelEditorInput.d.ts +12 -0
  97. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/OCRBoxMaker/LabelEditorItem.d.ts +21 -0
  98. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/OCRBoxMaker/LableEditor.d.ts +16 -0
  99. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/OCRBoxMaker/index.d.ts +19 -0
  100. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.d.ts +12 -0
  101. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/index.d.ts +12 -0
  102. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/index.d.ts +12 -0
  103. package/dist/src/components/VLMAnnotationDetail/VlmModal/index.d.ts +16 -0
  104. package/dist/src/components/VLMAnnotationDetail/index.d.ts +6 -0
  105. package/dist/src/constant.d.ts +1 -1
  106. package/dist/src/createVlmtasetAnnotation/index.d.ts +16 -0
  107. package/dist/src/featuresConfig.d.ts +4 -0
  108. package/dist/src/index.d.ts +3 -0
  109. package/dist/src/utils/reactCompatibility.d.ts +5 -0
  110. package/package.json +2 -2
@@ -0,0 +1,507 @@
1
+ var be = Object.defineProperty, Pe = Object.defineProperties;
2
+ var Ue = Object.getOwnPropertyDescriptors;
3
+ var de = Object.getOwnPropertySymbols;
4
+ var Xe = Object.prototype.hasOwnProperty, We = Object.prototype.propertyIsEnumerable;
5
+ var ge = (s, f, a) => f in s ? be(s, f, { enumerable: !0, configurable: !0, writable: !0, value: a }) : s[f] = a, q = (s, f) => {
6
+ for (var a in f || (f = {}))
7
+ Xe.call(f, a) && ge(s, a, f[a]);
8
+ if (de)
9
+ for (var a of de(f))
10
+ We.call(f, a) && ge(s, a, f[a]);
11
+ return s;
12
+ }, he = (s, f) => Pe(s, Ue(f));
13
+ import { jsxs as Re, jsx as M } from "react/jsx-runtime";
14
+ import { useRef as g, useState as I, useCallback as _, useEffect as h } from "react";
15
+ import { fabric as b } from "fabric";
16
+ import { useKeyPress as P } from "ahooks";
17
+ import Oe from "classnames";
18
+ import "./style.less.mjs";
19
+ import Fe from "../components/Toolbar.mjs";
20
+ import { useOCRLoadingIcon as Ye } from "./hooks/useOCRLoadingIcon.mjs";
21
+ import { useRegionNameText as je } from "./hooks/useRegionNameText.mjs";
22
+ import { useCropRegionImage as ye } from "./hooks/useCropRegionImage.mjs";
23
+ import { useDrawingMode as ze } from "./hooks/useDrawingMode.mjs";
24
+ import { useRegionLoader as He } from "./hooks/useRegionLoader.mjs";
25
+ import { useCanvasSetup as Ze } from "./hooks/useCanvasSetup.mjs";
26
+ import { useTextLayouts as Ke } from "./hooks/useTextLayouts.mjs";
27
+ import { useRegionUpdate as $e } from "./hooks/useRegionUpdate.mjs";
28
+ import { useCanvasDrag as Be } from "./hooks/useCanvasDrag.mjs";
29
+ import { useRegionSelection as Ge } from "./hooks/useRegionSelection.mjs";
30
+ import { useOCRRecognition as qe } from "./hooks/useOCRRecognition.mjs";
31
+ import { useDeleteRegion as Je } from "./hooks/useDeleteRegion.mjs";
32
+ import { useDeleteControl as Qe } from "./hooks/useDeleteControl.mjs";
33
+ import { useCanvasZoom as Ve } from "./hooks/useCanvasZoom.mjs";
34
+ import { useRegionHover as et } from "./hooks/useRegionHover.mjs";
35
+ import { canvasToImageCoords as tt, imageToCanvasCoords as ot } from "./utils/coordinateUtils.mjs";
36
+ import { REGION_NAME_PREFIX as rt, DEFAULT_REGION_NAME as nt, ZOOM_PRECISION_ERROR as st, TEXT_LAYOUT_RECT_FILL_COLOR as it, TEXT_LAYOUT_RECT_STROKE_COLOR as ct, TRANSPARENT_FILL as at, BASE_STROKE_WIDTH as ft } from "../constants.mjs";
37
+ const Wt = ({
38
+ sample: s,
39
+ labelDefinitions: f,
40
+ labels: a,
41
+ onImageLoad: pe,
42
+ onChange: A,
43
+ onRegionSelect: J,
44
+ onRegionChange: H,
45
+ ocrRecognize: ve,
46
+ activeLabelValue: E,
47
+ onClearActive: Z,
48
+ selectedRegion: Q,
49
+ onAppendTextToActive: Ee,
50
+ readOnly: c
51
+ }) => {
52
+ var ue, me;
53
+ const V = g(null), p = g(null), [Te, Ce] = I(!0), [e, Ne] = I(), [S, Ie] = I(), [R, ee] = I(1), [v, L] = I(c || !1), [T, k] = I(!1), [K, Ae] = I({
54
+ left: 0,
55
+ top: 0
56
+ }), U = g({
57
+ left: 0,
58
+ top: 0
59
+ }), ke = g({
60
+ width: 0,
61
+ height: 0
62
+ }), u = g(/* @__PURE__ */ new Map()), te = g(null), oe = g(void 0), re = g(!1), ne = g(!1), X = g({
63
+ width: 0,
64
+ height: 0
65
+ }), se = g(!1), {
66
+ updateOCRLoadingIcon: we,
67
+ ocrLoadingIconMapRef: w
68
+ } = Ye(e), {
69
+ updateRegionNameText: W,
70
+ regionNameTextMapRef: C
71
+ } = je(e), ie = ye(s == null ? void 0 : s.fileUrl), xe = _((o) => {
72
+ e && (C.current.forEach((t, r) => {
73
+ const n = r.left || 0, i = r.top || 0;
74
+ t.set({
75
+ left: n,
76
+ // 与标注框左边对齐
77
+ top: i,
78
+ // 下边缘与标注框上边缘对齐(因为 originY 是 'bottom')
79
+ scaleX: 1 / o,
80
+ // 反向缩放,抵消画布缩放
81
+ scaleY: 1 / o
82
+ // 反向缩放,抵消画布缩放
83
+ });
84
+ }), e.renderAll());
85
+ }, [e]), {
86
+ updateCanvas: D
87
+ } = Ze({
88
+ sample: s,
89
+ image: S,
90
+ onImageLoad: pe,
91
+ canvasRef: V,
92
+ containerRef: p,
93
+ canvasInitializedRef: re,
94
+ bgImagePositionRef: U,
95
+ bgImageSizeRef: ke,
96
+ rectMapRef: u,
97
+ updateTextLayersRef: te,
98
+ onRectPositionUpdated: xe,
99
+ setCanvas: Ne,
100
+ setImage: Ie,
101
+ setScale: ee,
102
+ setBgImagePosition: Ae,
103
+ setLoading: Ce
104
+ }), Me = _(() => {
105
+ const o = Array.from(u.current.values());
106
+ o.forEach((t, r) => {
107
+ t.name = `${rt}${r + 1}`;
108
+ }), u.current.forEach((t, r) => {
109
+ const n = C.current.get(r);
110
+ n && (n.set("text", t.name || nt), e == null || e.renderAll());
111
+ }), A && A(o);
112
+ }, [A, e]), {
113
+ zoom: Se
114
+ } = Ve({
115
+ canvas: e,
116
+ setScale: ee,
117
+ isZoomingRef: se
118
+ }), O = _(
119
+ (o, t) => tt(o, t, e, S, U),
120
+ [e, S, K]
121
+ // 添加 bgImagePosition 作为依赖,确保在图片位置更新后函数能正确工作
122
+ ), $ = _(
123
+ (o, t) => ot(o, t, e, U),
124
+ [e, K]
125
+ // 添加 bgImagePosition 作为依赖,确保在图片位置更新后函数能正确工作
126
+ ), {
127
+ updateTextLayers: F,
128
+ textLayersMapRef: l,
129
+ textLayoutContentMapRef: Y
130
+ } = Ke({
131
+ canvas: e,
132
+ imageToCanvasCoords: $,
133
+ activeLabelValue: E,
134
+ onAppendTextToActive: Ee
135
+ });
136
+ te.current = F;
137
+ const {
138
+ performOCRIfNeeded: ce,
139
+ ocrRecognizingRef: ut
140
+ } = qe({
141
+ ocrRecognize: ve,
142
+ onChange: A,
143
+ updateTextLayers: F,
144
+ canvas: e,
145
+ updateOCRLoadingIcon: we,
146
+ rectMapRef: u,
147
+ textLayersMapRef: l,
148
+ textLayoutContentMapRef: Y
149
+ }), {
150
+ updateRegionShapeAndImage: ae
151
+ } = $e({
152
+ canvas: e,
153
+ image: S,
154
+ draggable: v,
155
+ canvasToImageCoords: O,
156
+ imageToCanvasCoords: $,
157
+ cropRegionImage: ie,
158
+ onChange: A,
159
+ onRegionChange: H,
160
+ performOCRIfNeeded: ce,
161
+ updateTextLayers: F,
162
+ rectMapRef: u,
163
+ regionNameTextMapRef: C,
164
+ ocrLoadingIconMapRef: w
165
+ });
166
+ h(() => {
167
+ D();
168
+ }, [D]), h(() => {
169
+ e && (l.current.forEach((o) => {
170
+ o.forEach((t) => {
171
+ t.off("mousedown"), t.off("mouseover"), t.off("mouseout"), e.remove(t), Y.current.delete(t);
172
+ });
173
+ }), l.current.clear(), C.current.forEach((o) => {
174
+ e.remove(o);
175
+ }), C.current.clear(), w.current.forEach((o) => {
176
+ e.remove(o);
177
+ }), w.current.clear(), u.current.forEach((o, t) => {
178
+ t.off("modified"), t.off("moved"), e.remove(t);
179
+ }), u.current.clear(), ne.current = !1, oe.current = void 0, e.renderAll());
180
+ }, [e, s == null ? void 0 : s.id]), h(() => {
181
+ if (!p.current)
182
+ return;
183
+ X.current = {
184
+ width: p.current.offsetWidth,
185
+ height: p.current.offsetHeight
186
+ };
187
+ const o = new ResizeObserver(() => {
188
+ if (!p.current || se.current)
189
+ return;
190
+ if (e) {
191
+ const d = e.getZoom();
192
+ if (Math.abs(d - R) > st)
193
+ return;
194
+ }
195
+ const t = p.current.offsetWidth, r = p.current.offsetHeight, n = X.current.width, i = X.current.height;
196
+ (t !== n || r !== i) && (X.current = {
197
+ width: t,
198
+ height: r
199
+ }, D());
200
+ });
201
+ return o.observe(p.current), () => {
202
+ o.disconnect();
203
+ };
204
+ }, [D, e, R]), P("ctrl", () => {
205
+ c || (T && (k(!1), j()), L(!0));
206
+ }, {
207
+ events: ["keydown"]
208
+ }), P("ctrl", () => {
209
+ c || L(!1);
210
+ }, {
211
+ events: ["keyup"]
212
+ }), h(() => {
213
+ if (!e)
214
+ return;
215
+ const o = ft / R, t = /* @__PURE__ */ new Set();
216
+ l.current.forEach((r) => {
217
+ r.forEach((n) => {
218
+ t.add(n);
219
+ });
220
+ }), e.getObjects().forEach((r) => {
221
+ r instanceof b.Rect && !t.has(r) && r.set({
222
+ strokeWidth: o,
223
+ strokeUniform: !0,
224
+ objectCaching: !1,
225
+ // 禁用缓存,避免缩放时边框变虚
226
+ statefullCache: !1,
227
+ noScaleCache: !1
228
+ });
229
+ }), l.current.forEach((r) => {
230
+ r.forEach((n) => {
231
+ n.set({
232
+ fill: it,
233
+ // 确保填充色被保留
234
+ stroke: ct,
235
+ // 确保边框色被保留
236
+ strokeWidth: o,
237
+ // 根据缩放调整边框宽度,保持视觉一致
238
+ strokeUniform: !0,
239
+ // 确保边框宽度随缩放调整
240
+ objectCaching: !1,
241
+ statefullCache: !1,
242
+ noScaleCache: !1
243
+ });
244
+ });
245
+ }), C.current.forEach((r, n) => {
246
+ const i = n.left || 0, d = n.top || 0;
247
+ r.set({
248
+ left: i,
249
+ // 与标注框左边对齐
250
+ top: d,
251
+ // 下边缘与标注框上边缘对齐(因为 originY 是 'bottom')
252
+ scaleX: 1 / R,
253
+ // 反向缩放,抵消画布缩放
254
+ scaleY: 1 / R
255
+ // 反向缩放,抵消画布缩放
256
+ });
257
+ const m = w.current.get(n);
258
+ if (m) {
259
+ const N = n.getScaledWidth();
260
+ n.getScaledHeight(), m.set({
261
+ left: i,
262
+ // top 位置由动画控制,这里不更新
263
+ scaleX: 1 / R,
264
+ // 反向缩放,抵消画布缩放,保持固定视觉粗细
265
+ scaleY: 1 / R
266
+ // 反向缩放,抵消画布缩放,保持固定视觉粗细
267
+ });
268
+ const x = m.getObjects();
269
+ if (x && x.length > 0) {
270
+ const y = N * R;
271
+ x.forEach((z) => {
272
+ z instanceof b.Rect && z.set("width", y);
273
+ });
274
+ }
275
+ }
276
+ }), e.renderAll();
277
+ }, [e, R]), Be({
278
+ canvas: e,
279
+ draggable: v,
280
+ drawingMode: T
281
+ });
282
+ const {
283
+ performDelete: B
284
+ } = Je({
285
+ canvas: e,
286
+ onRegionChange: H,
287
+ updateRegionNames: Me,
288
+ rectMapRef: u,
289
+ textLayersMapRef: l,
290
+ textLayoutContentMapRef: Y,
291
+ regionNameTextMapRef: C,
292
+ ocrLoadingIconMapRef: w
293
+ }), {
294
+ createDeleteControl: G
295
+ } = Qe({
296
+ performDelete: B
297
+ });
298
+ Ge({
299
+ canvas: e,
300
+ onRegionSelect: J,
301
+ createDeleteControl: G,
302
+ textLayersMapRef: l,
303
+ rectMapRef: u
304
+ });
305
+ const {
306
+ stopDraw: j
307
+ } = ze({
308
+ canvas: e,
309
+ drawingMode: T,
310
+ draggable: v,
311
+ setDrawingMode: k,
312
+ canvasToImageCoords: O,
313
+ labelDefinitions: f,
314
+ onChange: A,
315
+ cropRegionImage: ie,
316
+ updateRegionShapeAndImage: ae,
317
+ performOCRIfNeeded: ce,
318
+ createDeleteControl: G,
319
+ updateRegionNameText: W,
320
+ onRegionChange: H,
321
+ onRegionSelect: J,
322
+ rectMapRef: u
323
+ });
324
+ h(() => {
325
+ c && (L(!0), k(!1), j());
326
+ }, [c, j]), h(() => {
327
+ if (!e)
328
+ return;
329
+ const o = () => {
330
+ e.getObjects().forEach((t) => {
331
+ t instanceof b.Rect && t.selectable && (t.set({
332
+ lockMovementX: c,
333
+ lockMovementY: c,
334
+ lockScalingX: c,
335
+ lockScalingY: c,
336
+ hasControls: !c
337
+ // 在只读模式下,如果有 activeLabelValue,我们可能希望它保持选中状态
338
+ // 但不允许用户通过点击来取消选中或选中其他(这个由 canvas.selection 控制)
339
+ }), c && t.controls);
340
+ }), e.requestRenderAll();
341
+ };
342
+ return o(), e.on("object:added", o), () => {
343
+ e.off("object:added", o);
344
+ };
345
+ }, [e, c]), He({
346
+ canvas: e,
347
+ sample: s,
348
+ image: S,
349
+ bgImagePosition: K,
350
+ canvasInitializedRef: re,
351
+ bgImagePositionRef: U,
352
+ sampleRef: oe,
353
+ labelsLoadedRef: ne,
354
+ rectMapRef: u,
355
+ textLayersMapRef: l,
356
+ textLayoutContentMapRef: Y,
357
+ regionNameTextMapRef: C,
358
+ ocrLoadingIconMapRef: w,
359
+ imageToCanvasCoords: $,
360
+ updateRegionShapeAndImage: ae,
361
+ createDeleteControl: G,
362
+ updateRegionNameText: W,
363
+ updateTextLayers: F
364
+ }), h(() => {
365
+ if (!a || a.length === 0)
366
+ return;
367
+ let o = !1;
368
+ u.current.forEach((t, r) => {
369
+ var d, m;
370
+ const n = a.find((N) => N.id === t.id);
371
+ if (!n)
372
+ return;
373
+ const i = he(q(q({}, t), n), {
374
+ // Keep shape from canvas to avoid desync
375
+ shape: t.shape,
376
+ image: (d = n.image) != null ? d : t.image,
377
+ textLayouts: (m = n.textLayouts) != null ? m : t.textLayouts
378
+ });
379
+ (i.name !== t.name || i.content !== t.content || i.image !== t.image || i.textLayouts !== t.textLayouts) && (u.current.set(r, i), i.name !== t.name && W(r, i), o = !0);
380
+ }), o && (e == null || e.renderAll());
381
+ }, [a, e, W]), et({
382
+ canvas: e,
383
+ drawingMode: T,
384
+ draggable: v,
385
+ textLayersMapRef: l
386
+ }), h(() => {
387
+ if (e && Q === null) {
388
+ const o = /* @__PURE__ */ new Set();
389
+ l.current.forEach((r) => {
390
+ r.forEach((n) => {
391
+ o.add(n);
392
+ });
393
+ }), e.getObjects().forEach((r) => {
394
+ r instanceof b.Rect && !o.has(r) && r.set({
395
+ fill: at
396
+ // 移除填充色
397
+ });
398
+ }), e.getActiveObject() && (e.discardActiveObject(), e.renderAll());
399
+ }
400
+ }, [e, Q]), h(() => {
401
+ var r;
402
+ if (!e)
403
+ return;
404
+ const o = (r = E == null ? void 0 : E.region) == null ? void 0 : r.id;
405
+ let t = !1;
406
+ l.current.forEach((n, i) => {
407
+ const d = u.current.get(i);
408
+ if (d && n.length > 0) {
409
+ const m = o === d.id;
410
+ n.forEach((N) => {
411
+ N.visible !== m && (N.set({
412
+ visible: m
413
+ }), t = !0);
414
+ });
415
+ }
416
+ }), t && e.renderAll();
417
+ }, [e, E]), h(() => {
418
+ if (!e || !E || !Z)
419
+ return;
420
+ const o = (t) => {
421
+ var le;
422
+ const r = (le = t.e) == null ? void 0 : le.target;
423
+ if ((r == null ? void 0 : r.tagName) === "INPUT" || (r == null ? void 0 : r.tagName) === "TEXTAREA")
424
+ return;
425
+ const n = e.getPointer(t.e), i = n.x, d = n.y, m = O(i, d), N = E.region, {
426
+ x,
427
+ y,
428
+ width: z,
429
+ height: _e
430
+ } = N.shape;
431
+ m.x >= x && m.x <= x + z && m.y >= y && m.y <= y + _e || Z();
432
+ };
433
+ return e.on("mouse:down", o), () => {
434
+ e.off("mouse:down", o);
435
+ };
436
+ }, [e, E, Z, O]);
437
+ const fe = _((o) => {
438
+ const t = o.target;
439
+ if ((t == null ? void 0 : t.tagName) === "INPUT" || (t == null ? void 0 : t.tagName) === "TEXTAREA" || !e || c)
440
+ return;
441
+ const r = e.getActiveObject();
442
+ !r || !(r instanceof b.Rect) || B(r);
443
+ }, [e, B]);
444
+ P("Delete", fe), P("Backspace", fe), P("r", (o) => {
445
+ const t = o.target;
446
+ (t == null ? void 0 : t.tagName) === "INPUT" || (t == null ? void 0 : t.tagName) === "TEXTAREA" || t != null && t.isContentEditable || c || !T && !v && k(!0);
447
+ }, {
448
+ exactMatch: !1
449
+ // 允许大小写
450
+ });
451
+ const Le = () => {
452
+ c || (T && (k(!1), j()), L(!v));
453
+ }, De = () => {
454
+ c || (v && L(!1), k(!T));
455
+ };
456
+ return h(() => () => {
457
+ e && e.dispose();
458
+ }, []), /* @__PURE__ */ Re("div", {
459
+ style: {
460
+ width: "100%",
461
+ height: "100%",
462
+ display: "flex",
463
+ position: "relative"
464
+ },
465
+ children: [Te && /* @__PURE__ */ M("div", {
466
+ className: "vlm-loading-overlay",
467
+ children: /* @__PURE__ */ M("div", {
468
+ className: "vlm-loading-spinner"
469
+ })
470
+ }), /* @__PURE__ */ M("div", {
471
+ className: "vlm-marker-toolbar",
472
+ children: /* @__PURE__ */ M(Fe, {
473
+ drawingMode: T,
474
+ draggable: v,
475
+ scale: R,
476
+ onToggleDrawingMode: De,
477
+ onToggleDrag: Le,
478
+ onZoom: Se,
479
+ onFitToScreen: D,
480
+ readOnly: c
481
+ })
482
+ }), /* @__PURE__ */ Re("div", {
483
+ ref: p,
484
+ className: Oe({
485
+ "vlm-label-maker-wrap": !0,
486
+ draggable: v
487
+ }),
488
+ onContextMenu: (o) => {
489
+ o.preventDefault();
490
+ },
491
+ style: {
492
+ flex: 1,
493
+ position: "relative"
494
+ },
495
+ children: [(((ue = s == null ? void 0 : s.sampleFileName) == null ? void 0 : ue.originalName) || ((me = s == null ? void 0 : s.sampleFileName) == null ? void 0 : me.name)) && /* @__PURE__ */ M("div", {
496
+ className: "vlm-image-name",
497
+ children: s.sampleFileName.originalName || s.sampleFileName.name
498
+ }), /* @__PURE__ */ M("canvas", {
499
+ className: "vlm-label-maker-canvas",
500
+ ref: V
501
+ })]
502
+ })]
503
+ });
504
+ };
505
+ export {
506
+ Wt as default
507
+ };
@@ -0,0 +1,4 @@
1
+ const t = "";
2
+ export {
3
+ t as default
4
+ };
@@ -0,0 +1,33 @@
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
+ };
@@ -0,0 +1,18 @@
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
+ };
@@ -0,0 +1,16 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { Tooltip as r, Button as e } from "antd";
3
+ import { ExpandOutlined as i } from "@ant-design/icons";
4
+ const l = ({
5
+ onClick: o
6
+ }) => /* @__PURE__ */ t(r, {
7
+ title: "适应屏幕",
8
+ placement: "right",
9
+ children: /* @__PURE__ */ t(e, {
10
+ icon: /* @__PURE__ */ t(i, {}),
11
+ onClick: o
12
+ })
13
+ });
14
+ export {
15
+ l as default
16
+ };
@@ -0,0 +1,30 @@
1
+ import { jsx as t, jsxs as i, Fragment as n } from "react/jsx-runtime";
2
+ import { Tooltip as r, Button as c } from "antd";
3
+ import l from "../../Iconfont/index.mjs";
4
+ const s = ({
5
+ active: o,
6
+ onClick: e
7
+ }) => /* @__PURE__ */ t(r, {
8
+ title: /* @__PURE__ */ i(n, {
9
+ children: [/* @__PURE__ */ t("div", {
10
+ children: "画矩形-按R键"
11
+ }), /* @__PURE__ */ t("div", {
12
+ style: {
13
+ fontSize: 14,
14
+ color: "#ff9326"
15
+ },
16
+ children: "预标注服务会按需计费!"
17
+ })]
18
+ }),
19
+ placement: "right",
20
+ children: /* @__PURE__ */ t(c, {
21
+ icon: /* @__PURE__ */ t(l, {
22
+ type: "icon-biaozhu-juxingkuang"
23
+ }),
24
+ className: o ? "active" : "",
25
+ onClick: e
26
+ })
27
+ });
28
+ export {
29
+ s as default
30
+ };
@@ -0,0 +1,40 @@
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";
7
+ import { ZOOM_STEP as i } from "../constants.mjs";
8
+ const Z = ({
9
+ drawingMode: e,
10
+ draggable: n,
11
+ scale: m,
12
+ onToggleDrawingMode: c,
13
+ onToggleDrag: a,
14
+ onZoom: r,
15
+ onFitToScreen: l,
16
+ readOnly: p
17
+ }) => /* @__PURE__ */ t(s, {
18
+ direction: "vertical",
19
+ size: 16,
20
+ children: [!p && /* @__PURE__ */ t(f, {
21
+ children: [/* @__PURE__ */ o(d, {
22
+ active: e,
23
+ onClick: c
24
+ }), /* @__PURE__ */ o(v, {
25
+ active: n,
26
+ onClick: a
27
+ }), /* @__PURE__ */ o(u, {
28
+ type: "horizontal"
29
+ })]
30
+ }), /* @__PURE__ */ o(C, {
31
+ scale: m,
32
+ onZoomIn: () => r(-i),
33
+ onZoomOut: () => r(i)
34
+ }), /* @__PURE__ */ o(g, {
35
+ onClick: l
36
+ })]
37
+ });
38
+ export {
39
+ Z as default
40
+ };
@@ -0,0 +1,44 @@
1
+ import { jsxs as t, jsx as o } from "react/jsx-runtime";
2
+ import { Space as m, Tooltip as n, Button as e } from "antd";
3
+ import { ZoomInOutlined as p, ZoomOutOutlined as s } from "@ant-design/icons";
4
+ import { MAX_ZOOM as a, MIN_ZOOM as h } from "../constants.mjs";
5
+ const Z = ({
6
+ scale: i,
7
+ onZoomIn: r,
8
+ onZoomOut: l
9
+ }) => {
10
+ const c = i >= a, d = i <= h;
11
+ return /* @__PURE__ */ t(m, {
12
+ direction: "vertical",
13
+ size: 16,
14
+ children: [/* @__PURE__ */ o(n, {
15
+ title: "放大-鼠标滚轮前滑",
16
+ placement: "right",
17
+ children: /* @__PURE__ */ o(e, {
18
+ icon: /* @__PURE__ */ o(p, {}),
19
+ onClick: r,
20
+ disabled: c
21
+ })
22
+ }), /* @__PURE__ */ t("div", {
23
+ style: {
24
+ textAlign: "center",
25
+ fontSize: 8,
26
+ color: "#666",
27
+ padding: "4px 0",
28
+ lineHeight: "32px"
29
+ },
30
+ children: [Math.round(i * 100), "%"]
31
+ }), /* @__PURE__ */ o(n, {
32
+ title: "缩小-鼠标滚轮后滑",
33
+ placement: "right",
34
+ children: /* @__PURE__ */ o(e, {
35
+ icon: /* @__PURE__ */ o(s, {}),
36
+ onClick: l,
37
+ disabled: d
38
+ })
39
+ })]
40
+ });
41
+ };
42
+ export {
43
+ Z as default
44
+ };