@glodon-aiot/dataset-annotation 3.22.4 → 3.23.0-alpha.3
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.
- package/dist/es/components/DetectionAnnotation/components/ImageDetail/index.mjs +93 -95
- package/dist/es/components/DetectionAnnotation/components/ImageModal/index.mjs +94 -85
- package/dist/es/components/DetectionAnnotation/components/Labels/index.mjs +148 -119
- package/dist/es/components/DetectionAnnotation/hooks/useSamplePreload.mjs +40 -0
- package/dist/es/components/DetectionAnnotation/index.mjs +466 -433
- package/dist/es/components/DetectionAnnotation/utils/imagePreloader.mjs +71 -0
- package/dist/es/index.mjs +1 -1
- package/dist/es/utils/formatCount.mjs +12 -0
- package/dist/lib/index.js +4 -4
- package/dist/src/components/DetectionAnnotation/components/ImageDetail/index.d.ts +1 -1
- package/dist/src/components/DetectionAnnotation/components/ImageModal/index.d.ts +3 -0
- package/dist/src/components/DetectionAnnotation/components/Labels/index.d.ts +2 -0
- package/dist/src/utils/formatCount.d.ts +9 -0
- package/package.json +2 -2
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var n = Object.defineProperty;
|
|
2
|
+
var a = (i, s, e) => s in i ? n(i, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[s] = e;
|
|
3
|
+
var o = (i, s, e) => (a(i, typeof s != "symbol" ? s + "" : s, e), e);
|
|
4
|
+
const d = 3, l = 2, r = 8, p = 2;
|
|
5
|
+
class u {
|
|
6
|
+
constructor() {
|
|
7
|
+
/** 已加载完成的图片,插入顺序即淘汰顺序 */
|
|
8
|
+
o(this, "cache", /* @__PURE__ */ new Map());
|
|
9
|
+
/** 待加载队列,每次窗口滑动整体替换 */
|
|
10
|
+
o(this, "queue", []);
|
|
11
|
+
o(this, "loading", /* @__PURE__ */ new Set());
|
|
12
|
+
o(this, "disposed", !1);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 替换待加载队列。已缓存或正在加载的 url 会被跳过,
|
|
16
|
+
* 上一轮尚未开始的目标会被丢弃,避免过期窗口占用并发额度。
|
|
17
|
+
*/
|
|
18
|
+
setTargets(s) {
|
|
19
|
+
this.disposed || (this.queue = Array.from(new Set(s)).filter((e) => !!e && !this.cache.has(e) && !this.loading.has(e)), this.pump());
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 清理不在 keep 列表内的缓存,并把剩余条目裁剪到上限以内。
|
|
23
|
+
*/
|
|
24
|
+
pruneExcept(s) {
|
|
25
|
+
const e = new Set(s.filter(Boolean));
|
|
26
|
+
for (this.cache.forEach((t, h) => {
|
|
27
|
+
e.has(h) || this.cache.delete(h);
|
|
28
|
+
}); this.cache.size > 8; ) {
|
|
29
|
+
const t = this.cache.keys().next();
|
|
30
|
+
if (t.done)
|
|
31
|
+
break;
|
|
32
|
+
this.cache.delete(t.value);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 释放全部缓存并放弃后续预加载。进行中的请求不主动中断
|
|
37
|
+
* (给 Image 赋空 src 在部分浏览器会退化成对当前页面地址的请求),
|
|
38
|
+
* 它们完成后由 disposed 标记丢弃结果,只留下已预热的浏览器缓存。
|
|
39
|
+
*/
|
|
40
|
+
dispose() {
|
|
41
|
+
this.disposed = !0, this.queue = [], this.cache.clear();
|
|
42
|
+
}
|
|
43
|
+
pump() {
|
|
44
|
+
for (; !this.disposed && this.loading.size < 2 && this.queue.length; )
|
|
45
|
+
this.load(this.queue.shift());
|
|
46
|
+
}
|
|
47
|
+
load(s) {
|
|
48
|
+
this.loading.add(s);
|
|
49
|
+
const e = new Image();
|
|
50
|
+
e.crossOrigin = "anonymous";
|
|
51
|
+
const t = () => {
|
|
52
|
+
this.loading.delete(s), this.pump();
|
|
53
|
+
};
|
|
54
|
+
e.onload = () => {
|
|
55
|
+
if (e.onload = null, e.onerror = null, this.disposed) {
|
|
56
|
+
t();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this.cache.set(s, e), typeof e.decode == "function" ? e.decode().then(t, t) : t();
|
|
60
|
+
}, e.onerror = () => {
|
|
61
|
+
e.onload = null, e.onerror = null, t();
|
|
62
|
+
}, e.src = s;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
u as ImagePreloader,
|
|
67
|
+
l as PRELOAD_BACKWARD,
|
|
68
|
+
p as PRELOAD_CONCURRENCY,
|
|
69
|
+
d as PRELOAD_FORWARD,
|
|
70
|
+
r as PRELOAD_MAX_CACHE
|
|
71
|
+
};
|