@glodon-aiot/dataset-annotation 3.25.1-alpha.2 → 3.25.1-alpha.4

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 (39) hide show
  1. package/dist/es/_virtual/_commonjsHelpers.mjs +8 -0
  2. package/dist/es/_virtual/dayjs.min.mjs +4 -0
  3. package/dist/es/components/OCRImageViewer/index.mjs +130 -117
  4. package/dist/es/components/VersionCompare/VersionCompareSelectModal/index.mjs +121 -0
  5. package/dist/es/components/VersionCompare/adapter.mjs +215 -0
  6. package/dist/es/components/VersionCompare/components/DataChangeStatsCard.mjs +68 -0
  7. package/dist/es/components/VersionCompare/components/DiffValue.mjs +31 -0
  8. package/dist/es/components/VersionCompare/components/LabelComparisonCard.mjs +130 -0
  9. package/dist/es/components/VersionCompare/components/ModifiedSampleCompareModal.mjs +207 -0
  10. package/dist/es/components/VersionCompare/components/SampleChangeDetailsCard.mjs +167 -0
  11. package/dist/es/components/VersionCompare/components/SingleSampleDetailModal.mjs +165 -0
  12. package/dist/es/components/VersionCompare/components/VersionCompareHeader.mjs +114 -0
  13. package/dist/es/components/VersionCompare/components/VersionOverviewCard.mjs +70 -0
  14. package/dist/es/components/VersionCompare/index.mjs +416 -0
  15. package/dist/es/components/VersionCompare/mock.mjs +571 -0
  16. package/dist/es/components/VersionCompare/style.less.mjs +4 -0
  17. package/dist/es/components/VersionCompare/utils/labelColors.mjs +45 -0
  18. package/dist/es/createDatasetVersionCompare/index.mjs +124 -0
  19. package/dist/es/index.mjs +21 -15
  20. package/dist/es/node_modules/dayjs/dayjs.min.mjs +324 -0
  21. package/dist/lib/index.js +37 -4
  22. package/dist/src/components/OCRImageViewer/index.d.ts +1 -0
  23. package/dist/src/components/VersionCompare/VersionCompareSelectModal/index.d.ts +16 -0
  24. package/dist/src/components/VersionCompare/adapter.d.ts +50 -0
  25. package/dist/src/components/VersionCompare/components/DataChangeStatsCard.d.ts +9 -0
  26. package/dist/src/components/VersionCompare/components/DiffValue.d.ts +23 -0
  27. package/dist/src/components/VersionCompare/components/LabelComparisonCard.d.ts +12 -0
  28. package/dist/src/components/VersionCompare/components/ModifiedSampleCompareModal.d.ts +48 -0
  29. package/dist/src/components/VersionCompare/components/SampleChangeDetailsCard.d.ts +21 -0
  30. package/dist/src/components/VersionCompare/components/SingleSampleDetailModal.d.ts +46 -0
  31. package/dist/src/components/VersionCompare/components/VersionCompareHeader.d.ts +13 -0
  32. package/dist/src/components/VersionCompare/components/VersionOverviewCard.d.ts +9 -0
  33. package/dist/src/components/VersionCompare/index.d.ts +34 -0
  34. package/dist/src/components/VersionCompare/mock.d.ts +25 -0
  35. package/dist/src/components/VersionCompare/types.d.ts +75 -0
  36. package/dist/src/components/VersionCompare/utils/labelColors.d.ts +13 -0
  37. package/dist/src/createDatasetVersionCompare/index.d.ts +26 -0
  38. package/dist/src/index.d.ts +6 -0
  39. package/package.json +2 -2
@@ -0,0 +1,416 @@
1
+ var j = (ne, K, c) => new Promise((R, S) => {
2
+ var z = (d) => {
3
+ try {
4
+ B(c.next(d));
5
+ } catch (q) {
6
+ S(q);
7
+ }
8
+ }, L = (d) => {
9
+ try {
10
+ B(c.throw(d));
11
+ } catch (q) {
12
+ S(q);
13
+ }
14
+ }, B = (d) => d.done ? R(d.value) : Promise.resolve(d.value).then(z, L);
15
+ B((c = c.apply(ne, K)).next());
16
+ });
17
+ import { jsx as h, jsxs as me } from "react/jsx-runtime";
18
+ import { useContext as Ye, useState as i, useRef as P, useEffect as E, useCallback as oe } from "react";
19
+ import { message as ae, ConfigProvider as Ze, Spin as Je } from "antd";
20
+ import Qe from "antd/es/locale/zh_CN";
21
+ import Xe from "../../DatasetContext/index.mjs";
22
+ import et from "./components/VersionCompareHeader.mjs";
23
+ import tt from "./components/VersionOverviewCard.mjs";
24
+ import rt from "./components/DataChangeStatsCard.mjs";
25
+ import ot from "./components/LabelComparisonCard.mjs";
26
+ import at from "./components/SampleChangeDetailsCard.mjs";
27
+ import nt from "./components/SingleSampleDetailModal.mjs";
28
+ import lt from "./components/ModifiedSampleCompareModal.mjs";
29
+ import st from "./VersionCompareSelectModal/index.mjs";
30
+ import { PRELOAD_FORWARD as it, PRELOAD_BACKWARD as ct, ImagePreloader as dt } from "../DetectionAnnotation/utils/imagePreloader.mjs";
31
+ import { scrollSampleIntoView as pt } from "../../utils/scrollSampleIntoView.mjs";
32
+ import { fetchVersionCompareSummaryWithAdapter as ft, fetchVersionCompareSamplesWithAdapter as ut } from "./adapter.mjs";
33
+ import { adaptVersionCompareSampleItem as zt, adaptVersionCompareSamples as Lt, adaptVersionCompareSummary as Bt, formatCompareTimestamp as qt } from "./adapter.mjs";
34
+ import "./style.less.mjs";
35
+ import "@glodon-aiot/apis";
36
+ const gt = 20, yt = (ne) => {
37
+ var Pe, Ae, Oe;
38
+ const K = Ye(Xe), {
39
+ datasetId: c,
40
+ baseVersionId: R,
41
+ targetVersionId: S,
42
+ datasetName: z,
43
+ markType: L,
44
+ ocrMarkTmpl: B,
45
+ cvforceDatahub: d = (Pe = K.services) == null ? void 0 : Pe.cvforceDatahub,
46
+ imgProxy: q,
47
+ versions: ze,
48
+ showBreadcrumb: Le = !0,
49
+ useMock: k = !1,
50
+ fallbackToMockOnError: $ = !1,
51
+ mockScene: le,
52
+ onBack: Be,
53
+ onVersionsChange: se,
54
+ onSampleClick: ie
55
+ } = ne, [f, he] = i(R), [u, Ce] = i(S), [e, qe] = i(null), [Fe, be] = i(!1), [ce, de] = i(null), [s, Ie] = i("added"), [C, We] = i([]), [G, _e] = i(0), [M, Y] = i(1), [b, Se] = i(gt), [w, Me] = i(!1), [He, pe] = i(!1), [ve, Z] = i(!1), [Te, J] = i(!1), [n, v] = i(-1), [Ve, fe] = i(!1), Q = P(null), A = P(0), F = P(0), O = P(!1), T = P(void 0), W = P(!1), X = P(null);
56
+ E(() => {
57
+ he(R);
58
+ }, [R]), E(() => {
59
+ Ce(S);
60
+ }, [S]);
61
+ const _ = le != null ? le : L === "ocr" ? "ocr" : L === "detection" ? "detection" : void 0, Ne = oe((t, o, g) => j(void 0, null, function* () {
62
+ if (!c || !t || !o)
63
+ return null;
64
+ const a = ++A.current;
65
+ be(!0), de(null);
66
+ try {
67
+ const l = yield ft(c, {
68
+ baseVersionId: t,
69
+ targetVersionId: o
70
+ }, {
71
+ cvforceDatahub: d,
72
+ useMock: k,
73
+ fallbackToMockOnError: $,
74
+ mockScene: _,
75
+ mockDatasetName: z,
76
+ onAsyncTaskProgress: (r) => {
77
+ a === A.current && de(r);
78
+ },
79
+ signal: g
80
+ });
81
+ return a !== A.current ? null : (qe(l), de(null), l);
82
+ } catch (l) {
83
+ return (l == null ? void 0 : l.name) === "AbortError" || a === A.current && ae.error((l == null ? void 0 : l.message) || "获取版本对比概览失败"), null;
84
+ } finally {
85
+ a === A.current && be(!1);
86
+ }
87
+ }), [c, d, k, $, _, z]), D = oe((t) => j(void 0, null, function* () {
88
+ const {
89
+ baseId: o,
90
+ targetId: g,
91
+ changeType: a,
92
+ page: l,
93
+ size: r,
94
+ colorMap: m,
95
+ selectPosition: I
96
+ } = t;
97
+ if (!c || !o || !g)
98
+ return null;
99
+ const N = ++F.current;
100
+ Me(!0);
101
+ try {
102
+ const p = yield ut(c, {
103
+ baseVersionId: o,
104
+ targetVersionId: g,
105
+ changeType: a,
106
+ pageNo: l,
107
+ pageSize: r
108
+ }, m, {
109
+ cvforceDatahub: d,
110
+ useMock: k,
111
+ fallbackToMockOnError: $,
112
+ mockScene: _
113
+ });
114
+ return N !== F.current ? null : (We(p.items), _e(p.total), Y(p.pageNo), Se(p.pageSize), I === "first" ? v(p.items.length > 0 ? 0 : -1) : I === "last" && v(p.items.length > 0 ? p.items.length - 1 : -1), p);
115
+ } catch (p) {
116
+ return N === F.current && ae.error((p == null ? void 0 : p.message) || "获取版本对比样本列表失败"), null;
117
+ } finally {
118
+ N === F.current && Me(!1);
119
+ }
120
+ }), [c, d, k, $, _]);
121
+ E(() => {
122
+ if (f !== R || u !== S) {
123
+ A.current += 1, F.current += 1;
124
+ return;
125
+ }
126
+ const t = new AbortController();
127
+ return Ie("added"), Y(1), Z(!1), J(!1), v(-1), Ne(f, u, t.signal).then((o) => {
128
+ !o || t.signal.aborted || D({
129
+ baseId: f,
130
+ targetId: u,
131
+ changeType: "added",
132
+ page: 1,
133
+ size: b,
134
+ colorMap: o.labelColorMap
135
+ });
136
+ }), () => {
137
+ t.abort();
138
+ };
139
+ }, [c, f, u, R, S, _, Ne]);
140
+ const je = (t) => {
141
+ Ie(t), Y(1), Z(!1), J(!1), v(-1), D({
142
+ baseId: f,
143
+ targetId: u,
144
+ changeType: t,
145
+ page: 1,
146
+ size: b,
147
+ colorMap: e == null ? void 0 : e.labelColorMap
148
+ });
149
+ }, Ke = (t, o) => {
150
+ Y(t), Se(o), v(-1), D({
151
+ baseId: f,
152
+ targetId: u,
153
+ changeType: s,
154
+ page: t,
155
+ size: o,
156
+ colorMap: e == null ? void 0 : e.labelColorMap
157
+ });
158
+ }, $e = (t, o) => {
159
+ W.current = !1, v(o), s === "modified" ? J(!0) : Z(!0), ie == null || ie(t, o, s);
160
+ }, ue = n >= 0 ? (M - 1) * b + n : -1, ee = ue > 0, te = ue >= 0 && ue < G - 1, V = n >= 0 && n < C.length ? C[n] : void 0, H = ve || Te;
161
+ E(() => {
162
+ if (H && V && n >= 0) {
163
+ const t = s === "deleted" && V.baseSample || V.sample;
164
+ X.current = {
165
+ id: (t == null ? void 0 : t.id) || V.fileKey,
166
+ index: n
167
+ };
168
+ return;
169
+ }
170
+ if (!H && X.current) {
171
+ const t = X.current, o = W.current;
172
+ if (X.current = null, W.current = !1, fe(!1), !o)
173
+ return;
174
+ const g = requestAnimationFrame(() => {
175
+ var r;
176
+ let a = Q.current, l = null;
177
+ for (; a && a !== document.body && a !== document.documentElement; ) {
178
+ const {
179
+ overflowY: m
180
+ } = window.getComputedStyle(a);
181
+ if ((m === "auto" || m === "scroll" || m === "overlay") && a.scrollHeight > a.clientHeight) {
182
+ l = a;
183
+ break;
184
+ }
185
+ a = a.parentElement;
186
+ }
187
+ if (l)
188
+ pt(l, t.id, t.index);
189
+ else if (Q.current) {
190
+ const m = Array.from(Q.current.querySelectorAll("[data-sample-id]")), I = (r = m.find((N) => N.dataset.sampleId === String(t.id))) != null ? r : m[t.index];
191
+ I == null || I.scrollIntoView({
192
+ block: "center"
193
+ });
194
+ }
195
+ });
196
+ return () => cancelAnimationFrame(g);
197
+ }
198
+ }, [H, V, n, s]), E(() => {
199
+ var l;
200
+ if (!H) {
201
+ (l = T.current) == null || l.dispose(), T.current = void 0;
202
+ return;
203
+ }
204
+ if (!Ve || n < 0)
205
+ return;
206
+ const t = (r) => {
207
+ var I, N, p, xe, ye, Ue;
208
+ if (!r)
209
+ return [];
210
+ if (s === "modified")
211
+ return [((I = r.baseSample) == null ? void 0 : I.fileUrl) || ((N = r.baseSample) == null ? void 0 : N.thumbnailUrl) || "", ((p = r.sample) == null ? void 0 : p.fileUrl) || ((xe = r.sample) == null ? void 0 : xe.thumbnailUrl) || ""].filter(Boolean);
212
+ if (s === "deleted") {
213
+ const U = r.baseSample || r.sample, Ee = (U == null ? void 0 : U.fileUrl) || (U == null ? void 0 : U.thumbnailUrl) || "";
214
+ return Ee ? [Ee] : [];
215
+ }
216
+ const m = ((ye = r.sample) == null ? void 0 : ye.fileUrl) || ((Ue = r.sample) == null ? void 0 : Ue.thumbnailUrl) || "";
217
+ return m ? [m] : [];
218
+ }, o = t(C[n]);
219
+ if (!o.length)
220
+ return;
221
+ const g = [], a = (r) => {
222
+ r < 0 || r >= C.length || g.push(...t(C[r]));
223
+ };
224
+ for (let r = 1; r <= it; r++)
225
+ a(n + r);
226
+ for (let r = 1; r <= ct; r++)
227
+ a(n - r);
228
+ T.current || (T.current = new dt()), T.current.pruneExcept([...o, ...g]), T.current.setTargets(g);
229
+ }, [H, Ve, n, C, s]), E(() => () => {
230
+ var t;
231
+ (t = T.current) == null || t.dispose(), T.current = void 0;
232
+ }, []);
233
+ const Re = oe(() => j(void 0, null, function* () {
234
+ if (!(w || O.current)) {
235
+ if (!ee) {
236
+ ae.error("已经是第一个了");
237
+ return;
238
+ }
239
+ if (W.current = !0, n > 0) {
240
+ v((t) => t - 1);
241
+ return;
242
+ }
243
+ if (M > 1) {
244
+ O.current = !0;
245
+ try {
246
+ yield D({
247
+ baseId: f,
248
+ targetId: u,
249
+ changeType: s,
250
+ page: M - 1,
251
+ size: b,
252
+ colorMap: e == null ? void 0 : e.labelColorMap,
253
+ selectPosition: "last"
254
+ });
255
+ } finally {
256
+ O.current = !1;
257
+ }
258
+ }
259
+ }
260
+ }), [ee, w, n, M, b, D, f, u, s, e == null ? void 0 : e.labelColorMap]), ke = oe(() => j(void 0, null, function* () {
261
+ if (!(w || O.current)) {
262
+ if (!te) {
263
+ ae.error("已经是最后一个了");
264
+ return;
265
+ }
266
+ if (W.current = !0, n + 1 < C.length) {
267
+ v((t) => t + 1);
268
+ return;
269
+ }
270
+ if ((M - 1) * b + n + 1 < G) {
271
+ O.current = !0;
272
+ try {
273
+ yield D({
274
+ baseId: f,
275
+ targetId: u,
276
+ changeType: s,
277
+ page: M + 1,
278
+ size: b,
279
+ colorMap: e == null ? void 0 : e.labelColorMap,
280
+ selectPosition: "first"
281
+ });
282
+ } finally {
283
+ O.current = !1;
284
+ }
285
+ }
286
+ }
287
+ }), [te, w, n, C.length, M, b, G, D, f, u, s, e == null ? void 0 : e.labelColorMap]), Ge = (t, o, g, a) => {
288
+ pe(!1), he(t), Ce(o), se == null || se(t, o, g, a);
289
+ }, we = z || (e == null ? void 0 : e.datasetName) || ((Ae = K.dataset) == null ? void 0 : Ae.name) || "-", De = L || (e == null ? void 0 : e.markType) || "detection", ge = B || (e == null ? void 0 : e.ocrMarkTmpl), re = (Oe = e == null ? void 0 : e.isOcrDetection) != null ? Oe : De === "ocr" && (!ge || ge === "DetectionOCR"), x = (e == null ? void 0 : e.baseVersionNo) || f || "-", y = (e == null ? void 0 : e.targetVersionNo) || u || "-";
290
+ return /* @__PURE__ */ h(Ze, {
291
+ locale: Qe,
292
+ children: /* @__PURE__ */ me("div", {
293
+ className: "dataset-version-compare-page",
294
+ ref: Q,
295
+ children: [/* @__PURE__ */ h(et, {
296
+ datasetName: we,
297
+ baseVersionNo: x,
298
+ targetVersionNo: y,
299
+ formattedCompareTime: (e == null ? void 0 : e.formattedCompareTime) || "-",
300
+ showBreadcrumb: Le,
301
+ onBack: Be,
302
+ onReselect: () => pe(!0)
303
+ }), /* @__PURE__ */ h("div", {
304
+ className: "vc-content-scroll",
305
+ children: /* @__PURE__ */ h(Je, {
306
+ spinning: Fe,
307
+ tip: ce ? `正在计算版本对比结果${ce.progress !== void 0 ? ` (${ce.progress}%)` : "..."}` : "正在加载对比数据...",
308
+ children: /* @__PURE__ */ me("div", {
309
+ className: "vc-content-body",
310
+ children: [/* @__PURE__ */ me("div", {
311
+ className: "vc-top-cards-row",
312
+ children: [/* @__PURE__ */ h(tt, {
313
+ baseVersionNo: x,
314
+ targetVersionNo: y,
315
+ rows: (e == null ? void 0 : e.overviewRows) || []
316
+ }), /* @__PURE__ */ h(rt, {
317
+ baseVersionNo: x,
318
+ targetVersionNo: y,
319
+ changeStats: (e == null ? void 0 : e.changeStats) || {
320
+ addedCount: 0,
321
+ deletedCount: 0,
322
+ modifiedCount: 0,
323
+ unchangedCount: 0
324
+ }
325
+ })]
326
+ }), /* @__PURE__ */ h(ot, {
327
+ markType: De,
328
+ ocrMarkTmpl: ge,
329
+ isOcrDetection: re,
330
+ baseVersionNo: x,
331
+ targetVersionNo: y,
332
+ labelComparisons: (e == null ? void 0 : e.labelComparisons) || []
333
+ }), /* @__PURE__ */ h(at, {
334
+ baseVersionNo: x,
335
+ targetVersionNo: y,
336
+ isOcrDetection: re,
337
+ changeStats: (e == null ? void 0 : e.changeStats) || {
338
+ addedCount: 0,
339
+ deletedCount: 0,
340
+ modifiedCount: 0,
341
+ unchangedCount: 0
342
+ },
343
+ activeTab: s,
344
+ items: C,
345
+ total: G,
346
+ pageNo: M,
347
+ pageSize: b,
348
+ loading: w,
349
+ imgProxy: q,
350
+ onTabChange: je,
351
+ onPageChange: Ke,
352
+ onSampleClick: $e
353
+ })]
354
+ })
355
+ })
356
+ }), /* @__PURE__ */ h(nt, {
357
+ open: ve && s !== "modified",
358
+ onCancel: () => Z(!1),
359
+ item: V,
360
+ changeType: s,
361
+ isOcrDetection: re,
362
+ datasetId: c,
363
+ baseVersionId: f,
364
+ targetVersionId: u,
365
+ labelColorMap: e == null ? void 0 : e.labelColorMap,
366
+ canPrev: ee,
367
+ canNext: te,
368
+ switching: w,
369
+ onPrev: Re,
370
+ onNext: ke,
371
+ onImageReadyChange: fe,
372
+ cvforceDatahub: d,
373
+ useMock: k
374
+ }), /* @__PURE__ */ h(lt, {
375
+ open: Te && s === "modified",
376
+ onCancel: () => J(!1),
377
+ item: V,
378
+ isOcrDetection: re,
379
+ datasetId: c,
380
+ baseVersionId: f,
381
+ baseVersionNo: x,
382
+ targetVersionId: u,
383
+ targetVersionNo: y,
384
+ labelColorMap: e == null ? void 0 : e.labelColorMap,
385
+ canPrev: ee,
386
+ canNext: te,
387
+ switching: w,
388
+ onPrev: Re,
389
+ onNext: ke,
390
+ onImageReadyChange: fe,
391
+ cvforceDatahub: d,
392
+ useMock: k
393
+ }), /* @__PURE__ */ h(st, {
394
+ open: He,
395
+ datasetId: c,
396
+ datasetName: we,
397
+ initialBaseVersionId: f,
398
+ initialTargetVersionId: u,
399
+ versions: ze,
400
+ cvforceDatahub: d,
401
+ useMock: k,
402
+ onCancel: () => pe(!1),
403
+ onConfirm: Ge
404
+ })]
405
+ })
406
+ });
407
+ };
408
+ export {
409
+ zt as adaptVersionCompareSampleItem,
410
+ Lt as adaptVersionCompareSamples,
411
+ Bt as adaptVersionCompareSummary,
412
+ yt as default,
413
+ ut as fetchVersionCompareSamplesWithAdapter,
414
+ ft as fetchVersionCompareSummaryWithAdapter,
415
+ qt as formatCompareTimestamp
416
+ };