@gpustack/core-ui 1.0.17 → 1.0.18
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/index.es.js +50 -44
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -2381,27 +2381,35 @@ var Ri = class {
|
|
|
2381
2381
|
totalBytes = 0;
|
|
2382
2382
|
avgSpeed = 0;
|
|
2383
2383
|
callback;
|
|
2384
|
-
encoder = new TextEncoder();
|
|
2385
2384
|
constructor(e) {
|
|
2386
2385
|
this.callback = e.callback, this.contentLength = e.contentLength ? parseInt(e.contentLength, 10) : null;
|
|
2387
2386
|
}
|
|
2388
2387
|
updateProgress(e) {
|
|
2389
|
-
this.contentLength && (this.progress +=
|
|
2388
|
+
this.contentLength && (this.progress += new TextEncoder().encode(e).length, this.percent = Math.floor(this.progress / this.contentLength * 100));
|
|
2390
2389
|
}
|
|
2391
2390
|
logSpeed(e) {
|
|
2392
2391
|
this.speedHistory.push(e), this.speedHistory.length > this.maxHistory && this.speedHistory.shift(), this.avgSpeed = this.speedHistory.reduce((e, t) => e + t, 0) / this.speedHistory.length, console.log(`瞬时均值: ${b(this.avgSpeed)}/s`);
|
|
2393
2392
|
}
|
|
2393
|
+
updateSpeed(e) {
|
|
2394
|
+
let t = performance.now(), n = (t - this.lastTime) / 1e3;
|
|
2395
|
+
if (n > .3) {
|
|
2396
|
+
let r = (this.totalBytes + e - this.lastBytes) / n;
|
|
2397
|
+
this.logSpeed(r), this.lastTime = t, this.lastBytes = this.totalBytes + e;
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2394
2400
|
add(e) {
|
|
2395
2401
|
this.buffer.push(e), this.updateProgress(e);
|
|
2396
2402
|
}
|
|
2397
|
-
flush(e) {
|
|
2403
|
+
async flush(e) {
|
|
2398
2404
|
if (this.buffer.length > 0) for (; this.buffer.length > 0;) {
|
|
2399
2405
|
let t = this.buffer.shift(), n = this.buffer.length === 0 && e;
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2406
|
+
await new Promise((e) => {
|
|
2407
|
+
this.callback(t, {
|
|
2408
|
+
isComplete: n || this.percent === 100,
|
|
2409
|
+
percent: this.percent,
|
|
2410
|
+
progress: this.progress,
|
|
2411
|
+
contentLength: this.contentLength
|
|
2412
|
+
}), e();
|
|
2405
2413
|
});
|
|
2406
2414
|
}
|
|
2407
2415
|
}
|
|
@@ -2409,65 +2417,63 @@ var Ri = class {
|
|
|
2409
2417
|
return this.buffer;
|
|
2410
2418
|
}
|
|
2411
2419
|
}, zi = () => {
|
|
2412
|
-
let { config: e } = a(), { apiBaseUrl: t } = e, n = z(null), r = z({}), i = async (e, t, n = 100) => {
|
|
2413
|
-
let r = e?.body?.getReader(),
|
|
2420
|
+
let { config: e } = a(), { apiBaseUrl: t } = e, n = z(null), r = z({}), i = z(null), o = async (e, t, n = 100) => {
|
|
2421
|
+
let r = e?.body?.getReader(), a = new TextDecoder("utf-8"), o = new Ri({
|
|
2414
2422
|
contentLength: e.headers.get("content-length"),
|
|
2415
2423
|
callback: t
|
|
2416
|
-
}),
|
|
2417
|
-
|
|
2418
|
-
|
|
2424
|
+
}), s = (0, Z.throttle)(async () => {
|
|
2425
|
+
await o.flush();
|
|
2426
|
+
}, n);
|
|
2427
|
+
i.current = s;
|
|
2428
|
+
try {
|
|
2429
|
+
for (;;) {
|
|
2430
|
+
let { done: e, value: t } = await r.read();
|
|
2419
2431
|
try {
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2432
|
+
let e = a.decode(t, { stream: !0 });
|
|
2433
|
+
o.add(e), s();
|
|
2434
|
+
} catch {}
|
|
2435
|
+
if (e) {
|
|
2436
|
+
await o.flush(!0), s.cancel(), r.releaseLock();
|
|
2437
|
+
break;
|
|
2423
2438
|
}
|
|
2424
2439
|
}
|
|
2425
|
-
}
|
|
2426
|
-
|
|
2427
|
-
let { done: e, value: t } = await r.read();
|
|
2440
|
+
} finally {
|
|
2441
|
+
s.cancel(), i.current === s && (i.current = null);
|
|
2428
2442
|
try {
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
a.add(e);
|
|
2432
|
-
}
|
|
2433
|
-
await s();
|
|
2434
|
-
} catch (e) {
|
|
2435
|
-
console.error("Error processing chunk:", e);
|
|
2436
|
-
}
|
|
2437
|
-
if (e) {
|
|
2438
|
-
c = !1, await s(), a.flush(e), r.releaseLock();
|
|
2439
|
-
break;
|
|
2440
|
-
}
|
|
2443
|
+
r.releaseLock();
|
|
2444
|
+
} catch {}
|
|
2441
2445
|
}
|
|
2442
|
-
},
|
|
2443
|
-
n.current?.abort?.(), n.current = new AbortController();
|
|
2446
|
+
}, s = async ({ url: e, handler: r, errorHandler: a, watch: s, watchable: c = !0, params: l = {} }) => {
|
|
2447
|
+
n.current?.abort?.(), i.current?.cancel?.(), i.current = null, n.current = new AbortController();
|
|
2444
2448
|
try {
|
|
2445
|
-
let
|
|
2446
|
-
...
|
|
2447
|
-
...
|
|
2449
|
+
let i = await fetch(`${t}${e}?${m.stringify({
|
|
2450
|
+
...l,
|
|
2451
|
+
...c ? { watch: s ?? !0 } : {}
|
|
2448
2452
|
})}`, {
|
|
2449
2453
|
method: "GET",
|
|
2450
2454
|
body: null,
|
|
2451
2455
|
headers: { "Content-Type": "application/octet-stream" },
|
|
2452
2456
|
signal: n.current.signal
|
|
2453
2457
|
});
|
|
2454
|
-
if (!
|
|
2455
|
-
let e = await Li(
|
|
2458
|
+
if (!i.ok) {
|
|
2459
|
+
let e = await Li(i);
|
|
2456
2460
|
a ? a(e) : r(e?.message);
|
|
2457
2461
|
return;
|
|
2458
2462
|
}
|
|
2459
|
-
await i
|
|
2460
|
-
} catch {
|
|
2463
|
+
await o(i, r);
|
|
2464
|
+
} catch (e) {
|
|
2465
|
+
e?.name !== "AbortError" && console.error("Chunk request error:", e);
|
|
2466
|
+
}
|
|
2461
2467
|
return n.current;
|
|
2462
|
-
},
|
|
2468
|
+
}, c = zt((e) => (r.current = { ...e }, s(r.current), n));
|
|
2463
2469
|
return F(() => {
|
|
2464
2470
|
let e = () => {
|
|
2465
|
-
n.current?.abort?.();
|
|
2471
|
+
n.current?.abort?.(), i.current?.cancel?.();
|
|
2466
2472
|
};
|
|
2467
2473
|
return window.addEventListener("beforeunload", e), () => {
|
|
2468
|
-
n.current?.abort?.(), window.removeEventListener("beforeunload", e);
|
|
2474
|
+
n.current?.abort?.(), i.current?.cancel?.(), window.removeEventListener("beforeunload", e);
|
|
2469
2475
|
};
|
|
2470
|
-
}, []), { setChunkFetch:
|
|
2476
|
+
}, []), { setChunkFetch: c };
|
|
2471
2477
|
}, Bi = /* @__PURE__ */ t({
|
|
2472
2478
|
StatusColorMap: () => Ui,
|
|
2473
2479
|
StatusMaps: () => Wi,
|