Upload folder using huggingface_hub
Browse files- 5.49.1/statustracker/index.ts +6 -0
- 5.49.1/statustracker/package.json +35 -0
- 5.49.1/statustracker/static/Loader.svelte +102 -0
- 5.49.1/statustracker/static/StreamingBar.svelte +29 -0
- 5.49.1/statustracker/static/Toast.svelte +63 -0
- 5.49.1/statustracker/static/ToastContent.svelte +353 -0
- 5.49.1/statustracker/static/index.svelte +526 -0
- 5.49.1/statustracker/static/index.ts +6 -0
- 5.49.1/statustracker/static/types.ts +29 -0
- 5.49.1/statustracker/static/utils.ts +10 -0
5.49.1/statustracker/index.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export { default as StatusTracker } from "./static/index.svelte";
|
| 2 |
+
export { default as Toast } from "./static/Toast.svelte";
|
| 3 |
+
export { default as Loader } from "./static/Loader.svelte";
|
| 4 |
+
export { default as StreamingBar } from "./static/StreamingBar.svelte";
|
| 5 |
+
export type * from "./static/types";
|
| 6 |
+
export { default } from "./static/index.svelte";
|
5.49.1/statustracker/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/statustracker",
|
| 3 |
+
"version": "0.11.1",
|
| 4 |
+
"description": "Gradio UI packages",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"main": "./index.ts",
|
| 7 |
+
"author": "",
|
| 8 |
+
"license": "ISC",
|
| 9 |
+
"main_changeset": true,
|
| 10 |
+
"exports": {
|
| 11 |
+
".": {
|
| 12 |
+
"gradio": "./index.ts",
|
| 13 |
+
"svelte": "./dist/index.js",
|
| 14 |
+
"types": "./dist/index.d.ts"
|
| 15 |
+
},
|
| 16 |
+
"./package.json": "./package.json"
|
| 17 |
+
},
|
| 18 |
+
"dependencies": {
|
| 19 |
+
"@gradio/atoms": "workspace:^",
|
| 20 |
+
"@gradio/icons": "workspace:^",
|
| 21 |
+
"@gradio/sanitize": "^0.2.0",
|
| 22 |
+
"@gradio/utils": "workspace:^"
|
| 23 |
+
},
|
| 24 |
+
"devDependencies": {
|
| 25 |
+
"@gradio/preview": "workspace:^"
|
| 26 |
+
},
|
| 27 |
+
"peerDependencies": {
|
| 28 |
+
"svelte": "^4.0.0"
|
| 29 |
+
},
|
| 30 |
+
"repository": {
|
| 31 |
+
"type": "git",
|
| 32 |
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 33 |
+
"directory": "js/statustracker"
|
| 34 |
+
}
|
| 35 |
+
}
|
5.49.1/statustracker/static/Loader.svelte
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { onMount } from "svelte";
|
| 3 |
+
import { spring } from "svelte/motion";
|
| 4 |
+
|
| 5 |
+
export let margin = true;
|
| 6 |
+
|
| 7 |
+
const top = spring([0, 0]);
|
| 8 |
+
const bottom = spring([0, 0]);
|
| 9 |
+
|
| 10 |
+
let dismounted: boolean;
|
| 11 |
+
|
| 12 |
+
async function animate(): Promise<void> {
|
| 13 |
+
await Promise.all([top.set([125, 140]), bottom.set([-125, -140])]);
|
| 14 |
+
await Promise.all([top.set([-125, 140]), bottom.set([125, -140])]);
|
| 15 |
+
await Promise.all([top.set([-125, 0]), bottom.set([125, -0])]);
|
| 16 |
+
await Promise.all([top.set([125, 0]), bottom.set([-125, 0])]);
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
async function run(): Promise<void> {
|
| 20 |
+
await animate();
|
| 21 |
+
if (!dismounted) run();
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
async function loading(): Promise<void> {
|
| 25 |
+
await Promise.all([top.set([125, 0]), bottom.set([-125, 0])]);
|
| 26 |
+
|
| 27 |
+
run();
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
onMount(() => {
|
| 31 |
+
loading();
|
| 32 |
+
return (): boolean => (dismounted = true);
|
| 33 |
+
});
|
| 34 |
+
</script>
|
| 35 |
+
|
| 36 |
+
<div class:margin>
|
| 37 |
+
<svg
|
| 38 |
+
viewBox="-1200 -1200 3000 3000"
|
| 39 |
+
fill="none"
|
| 40 |
+
xmlns="http://www.w3.org/2000/svg"
|
| 41 |
+
>
|
| 42 |
+
<g style="transform: translate({$top[0]}px, {$top[1]}px);">
|
| 43 |
+
<path
|
| 44 |
+
d="M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z"
|
| 45 |
+
fill="#FF7C00"
|
| 46 |
+
fill-opacity="0.4"
|
| 47 |
+
/>
|
| 48 |
+
<path
|
| 49 |
+
d="M509.69 139.936L254.981 279.641V361.255L509.69 221.55V139.936Z"
|
| 50 |
+
fill="#FF7C00"
|
| 51 |
+
/>
|
| 52 |
+
<path
|
| 53 |
+
d="M0.250138 139.937L254.981 279.641V361.255L0.250138 221.55V139.937Z"
|
| 54 |
+
fill="#FF7C00"
|
| 55 |
+
fill-opacity="0.4"
|
| 56 |
+
/>
|
| 57 |
+
<path
|
| 58 |
+
d="M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z"
|
| 59 |
+
fill="#FF7C00"
|
| 60 |
+
/>
|
| 61 |
+
</g>
|
| 62 |
+
<g style="transform: translate({$bottom[0]}px, {$bottom[1]}px);">
|
| 63 |
+
<path
|
| 64 |
+
d="M255.926 141.5L509.702 280.681V361.773L255.926 222.592V141.5Z"
|
| 65 |
+
fill="#FF7C00"
|
| 66 |
+
fill-opacity="0.4"
|
| 67 |
+
/>
|
| 68 |
+
<path
|
| 69 |
+
d="M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z"
|
| 70 |
+
fill="#FF7C00"
|
| 71 |
+
/>
|
| 72 |
+
<path
|
| 73 |
+
d="M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z"
|
| 74 |
+
fill="#FF7C00"
|
| 75 |
+
fill-opacity="0.4"
|
| 76 |
+
/>
|
| 77 |
+
<path
|
| 78 |
+
d="M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z"
|
| 79 |
+
fill="#FF7C00"
|
| 80 |
+
/>
|
| 81 |
+
</g>
|
| 82 |
+
</svg>
|
| 83 |
+
</div>
|
| 84 |
+
|
| 85 |
+
<style>
|
| 86 |
+
svg {
|
| 87 |
+
width: var(--size-20);
|
| 88 |
+
height: var(--size-20);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
svg path {
|
| 92 |
+
fill: var(--loader-color);
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
div {
|
| 96 |
+
z-index: var(--layer-2);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
.margin {
|
| 100 |
+
margin: var(--size-4);
|
| 101 |
+
}
|
| 102 |
+
</style>
|
5.49.1/statustracker/static/StreamingBar.svelte
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
export let time_limit: number | null;
|
| 3 |
+
</script>
|
| 4 |
+
|
| 5 |
+
{#if time_limit}
|
| 6 |
+
<div class="streaming-bar" style:animation-duration="{time_limit}s"></div>
|
| 7 |
+
{/if}
|
| 8 |
+
|
| 9 |
+
<style>
|
| 10 |
+
.streaming-bar {
|
| 11 |
+
position: absolute;
|
| 12 |
+
bottom: 0;
|
| 13 |
+
left: 0;
|
| 14 |
+
right: 0;
|
| 15 |
+
height: 4px;
|
| 16 |
+
background-color: var(--primary-600);
|
| 17 |
+
animation: countdown linear forwards;
|
| 18 |
+
z-index: 1;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
@keyframes countdown {
|
| 22 |
+
from {
|
| 23 |
+
transform: translateX(0%);
|
| 24 |
+
}
|
| 25 |
+
to {
|
| 26 |
+
transform: translateX(-100%);
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
</style>
|
5.49.1/statustracker/static/Toast.svelte
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { flip } from "svelte/animate";
|
| 3 |
+
import type { ToastMessage } from "./types";
|
| 4 |
+
import ToastContent from "./ToastContent.svelte";
|
| 5 |
+
import { spring } from "svelte/motion";
|
| 6 |
+
|
| 7 |
+
export let messages: ToastMessage[] = [];
|
| 8 |
+
const top = spring(0, { stiffness: 0.4, damping: 0.5 });
|
| 9 |
+
|
| 10 |
+
$: scroll_to_top(messages);
|
| 11 |
+
|
| 12 |
+
function scroll_to_top(_messages: ToastMessage[]): void {
|
| 13 |
+
if (_messages.length > 0) {
|
| 14 |
+
if ("parentIFrame" in window) {
|
| 15 |
+
window.parentIFrame?.getPageInfo((page_info) => {
|
| 16 |
+
if (page_info.scrollTop < page_info.offsetTop) {
|
| 17 |
+
top.set(0);
|
| 18 |
+
} else {
|
| 19 |
+
top.set(page_info.scrollTop - page_info.offsetTop);
|
| 20 |
+
}
|
| 21 |
+
});
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
</script>
|
| 26 |
+
|
| 27 |
+
<div class="toast-wrap" style="--toast-top: {$top}px;">
|
| 28 |
+
{#each messages as { type, title, message, id, duration, visible } (id)}
|
| 29 |
+
<div animate:flip={{ duration: 300 }} style:width="100%">
|
| 30 |
+
<ToastContent
|
| 31 |
+
{type}
|
| 32 |
+
{title}
|
| 33 |
+
{message}
|
| 34 |
+
{duration}
|
| 35 |
+
{visible}
|
| 36 |
+
on:close
|
| 37 |
+
{id}
|
| 38 |
+
/>
|
| 39 |
+
</div>
|
| 40 |
+
{/each}
|
| 41 |
+
</div>
|
| 42 |
+
|
| 43 |
+
<style>
|
| 44 |
+
.toast-wrap {
|
| 45 |
+
--toast-top: var(--size-4);
|
| 46 |
+
display: flex;
|
| 47 |
+
position: fixed;
|
| 48 |
+
top: calc(var(--toast-top) + var(--size-4));
|
| 49 |
+
right: var(--size-4);
|
| 50 |
+
|
| 51 |
+
flex-direction: column;
|
| 52 |
+
align-items: end;
|
| 53 |
+
gap: var(--size-2);
|
| 54 |
+
z-index: var(--layer-top);
|
| 55 |
+
width: calc(100% - var(--size-8));
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
@media (--screen-sm) {
|
| 59 |
+
.toast-wrap {
|
| 60 |
+
width: calc(var(--size-96) + var(--size-10));
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
</style>
|
5.49.1/statustracker/static/ToastContent.svelte
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { Error, Info, Warning, Success } from "@gradio/icons";
|
| 3 |
+
import { sanitize } from "@gradio/sanitize";
|
| 4 |
+
import { createEventDispatcher, onMount } from "svelte";
|
| 5 |
+
import { fade } from "svelte/transition";
|
| 6 |
+
import type { ToastMessage } from "./types";
|
| 7 |
+
|
| 8 |
+
export let title = "";
|
| 9 |
+
export let message = "";
|
| 10 |
+
export let type: ToastMessage["type"];
|
| 11 |
+
export let id: number;
|
| 12 |
+
export let duration: number | null = 10;
|
| 13 |
+
export let visible: boolean | "hidden" = true;
|
| 14 |
+
|
| 15 |
+
$: message = sanitize(message);
|
| 16 |
+
$: display = visible;
|
| 17 |
+
$: duration = duration || null;
|
| 18 |
+
|
| 19 |
+
const dispatch = createEventDispatcher();
|
| 20 |
+
|
| 21 |
+
function close_message(): void {
|
| 22 |
+
dispatch("close", id);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
onMount(() => {
|
| 26 |
+
if (duration !== null) {
|
| 27 |
+
setTimeout(() => {
|
| 28 |
+
close_message();
|
| 29 |
+
}, duration * 1000);
|
| 30 |
+
}
|
| 31 |
+
});
|
| 32 |
+
|
| 33 |
+
$: timer_animation_duration = `${duration || 0}s`;
|
| 34 |
+
</script>
|
| 35 |
+
|
| 36 |
+
<!-- TODO: fix-->
|
| 37 |
+
<!-- svelte-ignore a11y-no-noninteractive-element-interactions-->
|
| 38 |
+
<div
|
| 39 |
+
class="toast-body {type}"
|
| 40 |
+
role="alert"
|
| 41 |
+
data-testid="toast-body"
|
| 42 |
+
class:hidden={!display}
|
| 43 |
+
on:click|stopPropagation
|
| 44 |
+
on:keydown|stopPropagation
|
| 45 |
+
in:fade={{ duration: 200, delay: 100 }}
|
| 46 |
+
out:fade={{ duration: 200 }}
|
| 47 |
+
>
|
| 48 |
+
<div class="toast-icon {type}">
|
| 49 |
+
{#if type === "warning"}
|
| 50 |
+
<Warning />
|
| 51 |
+
{:else if type === "info"}
|
| 52 |
+
<Info />
|
| 53 |
+
{:else if type === "success"}
|
| 54 |
+
<Success />
|
| 55 |
+
{:else if type === "error"}
|
| 56 |
+
<Error />
|
| 57 |
+
{/if}
|
| 58 |
+
</div>
|
| 59 |
+
|
| 60 |
+
<div class="toast-details {type}">
|
| 61 |
+
<div class="toast-title {type}">{title}</div>
|
| 62 |
+
<div class="toast-text {type}">
|
| 63 |
+
{@html message}
|
| 64 |
+
</div>
|
| 65 |
+
</div>
|
| 66 |
+
|
| 67 |
+
<button
|
| 68 |
+
on:click={close_message}
|
| 69 |
+
class="toast-close {type}"
|
| 70 |
+
type="button"
|
| 71 |
+
aria-label="Close"
|
| 72 |
+
data-testid="toast-close"
|
| 73 |
+
>
|
| 74 |
+
<span aria-hidden="true">×</span>
|
| 75 |
+
</button>
|
| 76 |
+
|
| 77 |
+
<div
|
| 78 |
+
class="timer {type}"
|
| 79 |
+
style={`animation-duration: ${timer_animation_duration};`}
|
| 80 |
+
/>
|
| 81 |
+
</div>
|
| 82 |
+
|
| 83 |
+
<style>
|
| 84 |
+
.toast-body {
|
| 85 |
+
display: flex;
|
| 86 |
+
position: relative;
|
| 87 |
+
right: 0;
|
| 88 |
+
left: 0;
|
| 89 |
+
align-items: center;
|
| 90 |
+
margin: var(--size-6) var(--size-4);
|
| 91 |
+
margin: auto;
|
| 92 |
+
border-radius: var(--container-radius);
|
| 93 |
+
overflow: hidden;
|
| 94 |
+
pointer-events: auto;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
.toast-body.error {
|
| 98 |
+
border: 1px solid var(--color-red-700);
|
| 99 |
+
background: var(--color-red-50);
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
:global(.dark) .toast-body.error {
|
| 103 |
+
border: 1px solid var(--color-red-500);
|
| 104 |
+
background-color: var(--color-grey-950);
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
.toast-body.warning {
|
| 108 |
+
border: 1px solid var(--color-yellow-700);
|
| 109 |
+
background: var(--color-yellow-50);
|
| 110 |
+
}
|
| 111 |
+
:global(.dark) .toast-body.warning {
|
| 112 |
+
border: 1px solid var(--color-yellow-500);
|
| 113 |
+
background-color: var(--color-grey-950);
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
.toast-body.info {
|
| 117 |
+
border: 1px solid var(--color-grey-700);
|
| 118 |
+
background: var(--color-grey-50);
|
| 119 |
+
}
|
| 120 |
+
:global(.dark) .toast-body.info {
|
| 121 |
+
border: 1px solid var(--color-grey-500);
|
| 122 |
+
background-color: var(--color-grey-950);
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
.toast-body.success {
|
| 126 |
+
border: 1px solid var(--color-green-700);
|
| 127 |
+
background: var(--color-green-50);
|
| 128 |
+
}
|
| 129 |
+
:global(.dark) .toast-body.success {
|
| 130 |
+
border: 1px solid var(--color-green-500);
|
| 131 |
+
background-color: var(--color-grey-950);
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
.toast-title {
|
| 135 |
+
display: flex;
|
| 136 |
+
align-items: center;
|
| 137 |
+
font-weight: var(--weight-bold);
|
| 138 |
+
font-size: var(--text-lg);
|
| 139 |
+
line-height: var(--line-sm);
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
.toast-title.error {
|
| 143 |
+
color: var(--color-red-700);
|
| 144 |
+
}
|
| 145 |
+
:global(.dark) .toast-title.error {
|
| 146 |
+
color: var(--color-red-50);
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
.toast-title.warning {
|
| 150 |
+
color: var(--color-yellow-700);
|
| 151 |
+
}
|
| 152 |
+
:global(.dark) .toast-title.warning {
|
| 153 |
+
color: var(--color-yellow-50);
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
.toast-title.info {
|
| 157 |
+
color: var(--color-grey-700);
|
| 158 |
+
}
|
| 159 |
+
:global(.dark) .toast-title.info {
|
| 160 |
+
color: var(--color-grey-50);
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
.toast-title.success {
|
| 164 |
+
color: var(--color-green-700);
|
| 165 |
+
}
|
| 166 |
+
:global(.dark) .toast-title.success {
|
| 167 |
+
color: var(--color-green-50);
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
.toast-close {
|
| 171 |
+
margin: 0 var(--size-3);
|
| 172 |
+
border-radius: var(--size-3);
|
| 173 |
+
padding: 0px var(--size-1-5);
|
| 174 |
+
font-size: var(--size-5);
|
| 175 |
+
line-height: var(--size-5);
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
.toast-close.error {
|
| 179 |
+
color: var(--color-red-700);
|
| 180 |
+
}
|
| 181 |
+
:global(.dark) .toast-close.error {
|
| 182 |
+
color: var(--color-red-500);
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
.toast-close.warning {
|
| 186 |
+
color: var(--color-yellow-700);
|
| 187 |
+
}
|
| 188 |
+
:global(.dark) .toast-close.warning {
|
| 189 |
+
color: var(--color-yellow-500);
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
.toast-close.info {
|
| 193 |
+
color: var(--color-grey-700);
|
| 194 |
+
}
|
| 195 |
+
:global(.dark) .toast-close.info {
|
| 196 |
+
color: var(--color-grey-500);
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
.toast-close.success {
|
| 200 |
+
color: var(--color-green-700);
|
| 201 |
+
}
|
| 202 |
+
:global(.dark) .toast-close.success {
|
| 203 |
+
color: var(--color-green-500);
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
.toast-text {
|
| 207 |
+
font-size: var(--text-lg);
|
| 208 |
+
word-wrap: break-word;
|
| 209 |
+
overflow-wrap: break-word;
|
| 210 |
+
word-break: break-word;
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
.toast-text.error {
|
| 214 |
+
color: var(--color-red-700);
|
| 215 |
+
}
|
| 216 |
+
:global(.dark) .toast-text.error {
|
| 217 |
+
color: var(--color-red-50);
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
.toast-text.warning {
|
| 221 |
+
color: var(--color-yellow-700);
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
:global(.dark) .toast-text.warning {
|
| 225 |
+
color: var(--color-yellow-50);
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
.toast-text.info {
|
| 229 |
+
color: var(--color-grey-700);
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
:global(.dark) .toast-text.info {
|
| 233 |
+
color: var(--color-grey-50);
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
.toast-text.success {
|
| 237 |
+
color: var(--color-green-700);
|
| 238 |
+
}
|
| 239 |
+
:global(.dark) .toast-text.success {
|
| 240 |
+
color: var(--color-green-50);
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
.toast-details {
|
| 244 |
+
margin: var(--size-3) var(--size-3) var(--size-3) 0;
|
| 245 |
+
width: 100%;
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
.toast-icon {
|
| 249 |
+
display: flex;
|
| 250 |
+
position: absolute;
|
| 251 |
+
position: relative;
|
| 252 |
+
flex-shrink: 0;
|
| 253 |
+
justify-content: center;
|
| 254 |
+
align-items: center;
|
| 255 |
+
margin: var(--size-2);
|
| 256 |
+
border-radius: var(--radius-full);
|
| 257 |
+
padding: var(--size-1);
|
| 258 |
+
padding-left: calc(var(--size-1) - 1px);
|
| 259 |
+
width: 35px;
|
| 260 |
+
height: 35px;
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
.toast-icon.error {
|
| 264 |
+
color: var(--color-red-700);
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
:global(.dark) .toast-icon.error {
|
| 268 |
+
color: var(--color-red-500);
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
.toast-icon.warning {
|
| 272 |
+
color: var(--color-yellow-700);
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
:global(.dark) .toast-icon.warning {
|
| 276 |
+
color: var(--color-yellow-500);
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
.toast-icon.info {
|
| 280 |
+
color: var(--color-grey-700);
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
:global(.dark) .toast-icon.info {
|
| 284 |
+
color: var(--color-grey-500);
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
.toast-icon.success {
|
| 288 |
+
color: var(--color-green-700);
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
:global(.dark) .toast-icon.success {
|
| 292 |
+
color: var(--color-green-500);
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
@keyframes countdown {
|
| 296 |
+
from {
|
| 297 |
+
transform: scaleX(1);
|
| 298 |
+
}
|
| 299 |
+
to {
|
| 300 |
+
transform: scaleX(0);
|
| 301 |
+
}
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
.timer {
|
| 305 |
+
position: absolute;
|
| 306 |
+
bottom: 0;
|
| 307 |
+
left: 0;
|
| 308 |
+
transform-origin: 0 0;
|
| 309 |
+
animation: countdown 10s linear forwards;
|
| 310 |
+
width: 100%;
|
| 311 |
+
height: var(--size-1);
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
.timer.error {
|
| 315 |
+
background: var(--color-red-700);
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
:global(.dark) .timer.error {
|
| 319 |
+
background: var(--color-red-500);
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
.timer.warning {
|
| 323 |
+
background: var(--color-yellow-700);
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
:global(.dark) .timer.warning {
|
| 327 |
+
background: var(--color-yellow-500);
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
.timer.info {
|
| 331 |
+
background: var(--color-grey-700);
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
:global(.dark) .timer.info {
|
| 335 |
+
background: var(--color-grey-500);
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
.timer.success {
|
| 339 |
+
background: var(--color-green-700);
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
:global(.dark) .timer.success {
|
| 343 |
+
background: var(--color-green-500);
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
.hidden {
|
| 347 |
+
display: none;
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
.toast-text :global(a) {
|
| 351 |
+
text-decoration: underline;
|
| 352 |
+
}
|
| 353 |
+
</style>
|
5.49.1/statustracker/static/index.svelte
ADDED
|
@@ -0,0 +1,526 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
| 5 |
+
let items: HTMLDivElement[] = [];
|
| 6 |
+
|
| 7 |
+
let called = false;
|
| 8 |
+
|
| 9 |
+
const is_browser = typeof window !== "undefined";
|
| 10 |
+
const raf = is_browser
|
| 11 |
+
? window.requestAnimationFrame
|
| 12 |
+
: (cb: (...args: any[]) => void) => {};
|
| 13 |
+
|
| 14 |
+
async function scroll_into_view(
|
| 15 |
+
el: HTMLDivElement,
|
| 16 |
+
enable: boolean | null = true
|
| 17 |
+
): Promise<void> {
|
| 18 |
+
if (
|
| 19 |
+
window.__gradio_mode__ === "website" ||
|
| 20 |
+
(window.__gradio_mode__ !== "app" && enable !== true)
|
| 21 |
+
) {
|
| 22 |
+
return;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
items.push(el);
|
| 26 |
+
if (!called) called = true;
|
| 27 |
+
else return;
|
| 28 |
+
|
| 29 |
+
await tick();
|
| 30 |
+
|
| 31 |
+
raf(() => {
|
| 32 |
+
let min = [0, 0];
|
| 33 |
+
|
| 34 |
+
for (let i = 0; i < items.length; i++) {
|
| 35 |
+
const element = items[i];
|
| 36 |
+
|
| 37 |
+
const box = element.getBoundingClientRect();
|
| 38 |
+
if (i === 0 || box.top + window.scrollY <= min[0]) {
|
| 39 |
+
min[0] = box.top + window.scrollY;
|
| 40 |
+
min[1] = i;
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
window.scrollTo({ top: min[0] - 20, behavior: "smooth" });
|
| 45 |
+
|
| 46 |
+
called = false;
|
| 47 |
+
items = [];
|
| 48 |
+
});
|
| 49 |
+
}
|
| 50 |
+
</script>
|
| 51 |
+
|
| 52 |
+
<script lang="ts">
|
| 53 |
+
import { onDestroy } from "svelte";
|
| 54 |
+
|
| 55 |
+
import Loader from "./Loader.svelte";
|
| 56 |
+
import type { LoadingStatus } from "./types";
|
| 57 |
+
import type { I18nFormatter } from "@gradio/utils";
|
| 58 |
+
import { createEventDispatcher } from "svelte";
|
| 59 |
+
|
| 60 |
+
import { IconButton } from "@gradio/atoms";
|
| 61 |
+
import { Clear } from "@gradio/icons";
|
| 62 |
+
|
| 63 |
+
const dispatch = createEventDispatcher();
|
| 64 |
+
|
| 65 |
+
export let i18n: I18nFormatter;
|
| 66 |
+
export let eta: number | null = null;
|
| 67 |
+
export let queue_position: number | null;
|
| 68 |
+
export let queue_size: number | null;
|
| 69 |
+
export let status:
|
| 70 |
+
| "complete"
|
| 71 |
+
| "pending"
|
| 72 |
+
| "error"
|
| 73 |
+
| "generating"
|
| 74 |
+
| "streaming"
|
| 75 |
+
| null;
|
| 76 |
+
export let scroll_to_output = false;
|
| 77 |
+
export let timer = true;
|
| 78 |
+
export let show_progress: "full" | "minimal" | "hidden" = "full";
|
| 79 |
+
export let message: string | null = null;
|
| 80 |
+
export let progress: LoadingStatus["progress"] | null | undefined = null;
|
| 81 |
+
export let variant: "default" | "center" = "default";
|
| 82 |
+
export let loading_text = "Loading...";
|
| 83 |
+
export let absolute = true;
|
| 84 |
+
export let translucent = false;
|
| 85 |
+
export let border = false;
|
| 86 |
+
export let autoscroll: boolean;
|
| 87 |
+
export let validation_error: string | null = null;
|
| 88 |
+
export let show_validation_error = true;
|
| 89 |
+
|
| 90 |
+
let el: HTMLDivElement;
|
| 91 |
+
|
| 92 |
+
let _timer = false;
|
| 93 |
+
let timer_start = 0;
|
| 94 |
+
let timer_diff = 0;
|
| 95 |
+
let old_eta: number | null = null;
|
| 96 |
+
let eta_from_start: number | null = null;
|
| 97 |
+
let message_visible = false;
|
| 98 |
+
let eta_level: number | null = 0;
|
| 99 |
+
let progress_level: (number | undefined)[] | null = null;
|
| 100 |
+
let last_progress_level: number | undefined = undefined;
|
| 101 |
+
let progress_bar: HTMLElement | null = null;
|
| 102 |
+
let show_eta_bar = true;
|
| 103 |
+
|
| 104 |
+
$: eta_level =
|
| 105 |
+
eta_from_start === null || eta_from_start <= 0 || !timer_diff
|
| 106 |
+
? null
|
| 107 |
+
: Math.min(timer_diff / eta_from_start, 1);
|
| 108 |
+
$: if (progress != null) {
|
| 109 |
+
show_eta_bar = false;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
$: {
|
| 113 |
+
if (progress != null) {
|
| 114 |
+
progress_level = progress.map((p) => {
|
| 115 |
+
if (p.index != null && p.length != null) {
|
| 116 |
+
return p.index / p.length;
|
| 117 |
+
} else if (p.progress != null) {
|
| 118 |
+
return p.progress;
|
| 119 |
+
}
|
| 120 |
+
return undefined;
|
| 121 |
+
});
|
| 122 |
+
} else {
|
| 123 |
+
progress_level = null;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
if (progress_level) {
|
| 127 |
+
last_progress_level = progress_level[progress_level.length - 1];
|
| 128 |
+
if (progress_bar) {
|
| 129 |
+
if (last_progress_level === 0) {
|
| 130 |
+
progress_bar.style.transition = "0";
|
| 131 |
+
} else {
|
| 132 |
+
progress_bar.style.transition = "150ms";
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
} else {
|
| 136 |
+
last_progress_level = undefined;
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
const start_timer = (): void => {
|
| 141 |
+
eta = old_eta = formatted_eta = null;
|
| 142 |
+
timer_start = performance.now();
|
| 143 |
+
timer_diff = 0;
|
| 144 |
+
_timer = true;
|
| 145 |
+
run();
|
| 146 |
+
};
|
| 147 |
+
|
| 148 |
+
function run(): void {
|
| 149 |
+
raf(() => {
|
| 150 |
+
timer_diff = (performance.now() - timer_start) / 1000;
|
| 151 |
+
if (_timer) run();
|
| 152 |
+
});
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
function stop_timer(): void {
|
| 156 |
+
timer_diff = 0;
|
| 157 |
+
eta = old_eta = formatted_eta = null;
|
| 158 |
+
|
| 159 |
+
if (!_timer) return;
|
| 160 |
+
_timer = false;
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
onDestroy(() => {
|
| 164 |
+
if (_timer) stop_timer();
|
| 165 |
+
});
|
| 166 |
+
|
| 167 |
+
$: {
|
| 168 |
+
if (status === "pending") {
|
| 169 |
+
start_timer();
|
| 170 |
+
} else {
|
| 171 |
+
stop_timer();
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
$: el &&
|
| 176 |
+
scroll_to_output &&
|
| 177 |
+
(status === "pending" || status === "complete") &&
|
| 178 |
+
scroll_into_view(el, autoscroll);
|
| 179 |
+
|
| 180 |
+
let formatted_eta: string | null = null;
|
| 181 |
+
$: {
|
| 182 |
+
if (eta === null) {
|
| 183 |
+
eta = old_eta;
|
| 184 |
+
}
|
| 185 |
+
if (eta != null && old_eta !== eta) {
|
| 186 |
+
eta_from_start = (performance.now() - timer_start) / 1000 + eta;
|
| 187 |
+
formatted_eta = eta_from_start.toFixed(1);
|
| 188 |
+
old_eta = eta;
|
| 189 |
+
}
|
| 190 |
+
}
|
| 191 |
+
let show_message_timeout: NodeJS.Timeout | null = null;
|
| 192 |
+
function close_message(): void {
|
| 193 |
+
message_visible = false;
|
| 194 |
+
if (show_message_timeout !== null) {
|
| 195 |
+
clearTimeout(show_message_timeout);
|
| 196 |
+
}
|
| 197 |
+
}
|
| 198 |
+
$: {
|
| 199 |
+
close_message();
|
| 200 |
+
if (status === "error" && message) {
|
| 201 |
+
message_visible = true;
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
$: formatted_timer = timer_diff.toFixed(1);
|
| 205 |
+
</script>
|
| 206 |
+
|
| 207 |
+
<div
|
| 208 |
+
class="wrap {variant} {show_progress}"
|
| 209 |
+
class:hide={(!status ||
|
| 210 |
+
status === "complete" ||
|
| 211 |
+
show_progress === "hidden" ||
|
| 212 |
+
status == "streaming") &&
|
| 213 |
+
!validation_error}
|
| 214 |
+
class:translucent={(variant === "center" &&
|
| 215 |
+
(status === "pending" || status === "error")) ||
|
| 216 |
+
translucent ||
|
| 217 |
+
show_progress === "minimal" ||
|
| 218 |
+
validation_error}
|
| 219 |
+
class:generating={status === "generating" && show_progress === "full"}
|
| 220 |
+
class:border
|
| 221 |
+
style:position={absolute ? "absolute" : "static"}
|
| 222 |
+
style:padding={absolute ? "0" : "var(--size-8) 0"}
|
| 223 |
+
bind:this={el}
|
| 224 |
+
>
|
| 225 |
+
{#if validation_error && show_validation_error}
|
| 226 |
+
<div class="validation-error">
|
| 227 |
+
{validation_error}
|
| 228 |
+
<button
|
| 229 |
+
><IconButton
|
| 230 |
+
Icon={Clear}
|
| 231 |
+
label={i18n("common.clear")}
|
| 232 |
+
disabled={false}
|
| 233 |
+
size="x-small"
|
| 234 |
+
background="var(--background-fill-primary)"
|
| 235 |
+
color="var(--error-background-text)"
|
| 236 |
+
border="var(--border-color-primary)"
|
| 237 |
+
on:click={() => (validation_error = null)}
|
| 238 |
+
/></button
|
| 239 |
+
>
|
| 240 |
+
</div>
|
| 241 |
+
{/if}
|
| 242 |
+
{#if status === "pending"}
|
| 243 |
+
{#if variant === "default" && show_eta_bar && show_progress === "full"}
|
| 244 |
+
<div
|
| 245 |
+
class="eta-bar"
|
| 246 |
+
style:transform="translateX({(eta_level || 0) * 100 - 100}%)"
|
| 247 |
+
/>
|
| 248 |
+
{/if}
|
| 249 |
+
<div
|
| 250 |
+
class:meta-text-center={variant === "center"}
|
| 251 |
+
class:meta-text={variant === "default"}
|
| 252 |
+
class="progress-text"
|
| 253 |
+
>
|
| 254 |
+
{#if progress}
|
| 255 |
+
{#each progress as p}
|
| 256 |
+
{#if p.index != null}
|
| 257 |
+
{#if p.length != null}
|
| 258 |
+
{pretty_si(p.index || 0)}/{pretty_si(p.length)}
|
| 259 |
+
{:else}
|
| 260 |
+
{pretty_si(p.index || 0)}
|
| 261 |
+
{/if}
|
| 262 |
+
{p.unit} | {" "}
|
| 263 |
+
{/if}
|
| 264 |
+
{/each}
|
| 265 |
+
{:else if queue_position !== null && queue_size !== undefined && queue_position >= 0}
|
| 266 |
+
queue: {queue_position + 1}/{queue_size} |
|
| 267 |
+
{:else if queue_position === 0}
|
| 268 |
+
processing |
|
| 269 |
+
{/if}
|
| 270 |
+
|
| 271 |
+
{#if timer}
|
| 272 |
+
{formatted_timer}{eta ? `/${formatted_eta}` : ""}s
|
| 273 |
+
{/if}
|
| 274 |
+
</div>
|
| 275 |
+
|
| 276 |
+
{#if last_progress_level != null}
|
| 277 |
+
<div class="progress-level">
|
| 278 |
+
<div class="progress-level-inner">
|
| 279 |
+
{#if progress != null}
|
| 280 |
+
{#each progress as p, i}
|
| 281 |
+
{#if p.desc != null || (progress_level && progress_level[i] != null)}
|
| 282 |
+
{#if i !== 0}
|
| 283 |
+
/
|
| 284 |
+
{/if}
|
| 285 |
+
{#if p.desc != null}
|
| 286 |
+
{p.desc}
|
| 287 |
+
{/if}
|
| 288 |
+
{#if p.desc != null && progress_level && progress_level[i] != null}
|
| 289 |
+
-
|
| 290 |
+
{/if}
|
| 291 |
+
{#if progress_level != null}
|
| 292 |
+
{(100 * (progress_level[i] || 0)).toFixed(1)}%
|
| 293 |
+
{/if}
|
| 294 |
+
{/if}
|
| 295 |
+
{/each}
|
| 296 |
+
{/if}
|
| 297 |
+
</div>
|
| 298 |
+
|
| 299 |
+
<div class="progress-bar-wrap">
|
| 300 |
+
<div
|
| 301 |
+
bind:this={progress_bar}
|
| 302 |
+
class="progress-bar"
|
| 303 |
+
style:width="{last_progress_level * 100}%"
|
| 304 |
+
/>
|
| 305 |
+
</div>
|
| 306 |
+
</div>
|
| 307 |
+
{:else if show_progress === "full"}
|
| 308 |
+
<Loader margin={variant === "default"} />
|
| 309 |
+
{/if}
|
| 310 |
+
|
| 311 |
+
{#if !timer}
|
| 312 |
+
<p class="loading">{loading_text}</p>
|
| 313 |
+
<slot name="additional-loading-text" />
|
| 314 |
+
{/if}
|
| 315 |
+
{:else if status === "error"}
|
| 316 |
+
<div class="clear-status">
|
| 317 |
+
<IconButton
|
| 318 |
+
Icon={Clear}
|
| 319 |
+
label={i18n("common.clear")}
|
| 320 |
+
disabled={false}
|
| 321 |
+
on:click={() => {
|
| 322 |
+
dispatch("clear_status");
|
| 323 |
+
}}
|
| 324 |
+
/>
|
| 325 |
+
</div>
|
| 326 |
+
<span class="error">{i18n("common.error")}</span>
|
| 327 |
+
<slot name="error" />
|
| 328 |
+
{/if}
|
| 329 |
+
</div>
|
| 330 |
+
|
| 331 |
+
<style>
|
| 332 |
+
.wrap {
|
| 333 |
+
display: flex;
|
| 334 |
+
flex-direction: column;
|
| 335 |
+
justify-content: center;
|
| 336 |
+
align-items: center;
|
| 337 |
+
z-index: var(--layer-3);
|
| 338 |
+
transition: opacity 0.1s ease-in-out;
|
| 339 |
+
border-radius: var(--block-radius);
|
| 340 |
+
background: var(--block-background-fill);
|
| 341 |
+
padding: 0 var(--size-6);
|
| 342 |
+
overflow: hidden;
|
| 343 |
+
pointer-events: none;
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
.wrap.center {
|
| 347 |
+
top: 0;
|
| 348 |
+
right: 0px;
|
| 349 |
+
left: 0px;
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
.wrap.default {
|
| 353 |
+
top: 0px;
|
| 354 |
+
right: 0px;
|
| 355 |
+
bottom: 0px;
|
| 356 |
+
left: 0px;
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
.hide {
|
| 360 |
+
opacity: 0;
|
| 361 |
+
pointer-events: none;
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
.generating {
|
| 365 |
+
animation:
|
| 366 |
+
pulseStart 1s cubic-bezier(0.4, 0, 0.6, 1),
|
| 367 |
+
pulse 2s cubic-bezier(0.4, 0, 0.6, 1) 1s infinite;
|
| 368 |
+
border: 2px solid var(--color-accent);
|
| 369 |
+
background: transparent;
|
| 370 |
+
z-index: var(--layer-1);
|
| 371 |
+
pointer-events: none;
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
.translucent {
|
| 375 |
+
background: none;
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
@keyframes pulseStart {
|
| 379 |
+
0% {
|
| 380 |
+
opacity: 0;
|
| 381 |
+
}
|
| 382 |
+
100% {
|
| 383 |
+
opacity: 1;
|
| 384 |
+
}
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
@keyframes pulse {
|
| 388 |
+
0%,
|
| 389 |
+
100% {
|
| 390 |
+
opacity: 1;
|
| 391 |
+
}
|
| 392 |
+
50% {
|
| 393 |
+
opacity: 0.5;
|
| 394 |
+
}
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
.loading {
|
| 398 |
+
z-index: var(--layer-2);
|
| 399 |
+
color: var(--body-text-color);
|
| 400 |
+
}
|
| 401 |
+
.eta-bar {
|
| 402 |
+
position: absolute;
|
| 403 |
+
top: 0;
|
| 404 |
+
right: 0;
|
| 405 |
+
bottom: 0;
|
| 406 |
+
left: 0;
|
| 407 |
+
transform-origin: left;
|
| 408 |
+
opacity: 0.8;
|
| 409 |
+
z-index: var(--layer-1);
|
| 410 |
+
transition: 10ms;
|
| 411 |
+
background: var(--background-fill-secondary);
|
| 412 |
+
}
|
| 413 |
+
.progress-bar-wrap {
|
| 414 |
+
border: 1px solid var(--border-color-primary);
|
| 415 |
+
background: var(--background-fill-primary);
|
| 416 |
+
width: 55.5%;
|
| 417 |
+
height: var(--size-4);
|
| 418 |
+
}
|
| 419 |
+
.progress-bar {
|
| 420 |
+
transform-origin: left;
|
| 421 |
+
background-color: var(--loader-color);
|
| 422 |
+
width: var(--size-full);
|
| 423 |
+
height: var(--size-full);
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
.progress-level {
|
| 427 |
+
display: flex;
|
| 428 |
+
flex-direction: column;
|
| 429 |
+
align-items: center;
|
| 430 |
+
gap: 1;
|
| 431 |
+
z-index: var(--layer-2);
|
| 432 |
+
width: var(--size-full);
|
| 433 |
+
}
|
| 434 |
+
|
| 435 |
+
.progress-level-inner {
|
| 436 |
+
margin: var(--size-2) auto;
|
| 437 |
+
color: var(--body-text-color);
|
| 438 |
+
font-size: var(--text-sm);
|
| 439 |
+
font-family: var(--font-mono);
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
+
.meta-text {
|
| 443 |
+
position: absolute;
|
| 444 |
+
bottom: 0;
|
| 445 |
+
right: 0;
|
| 446 |
+
z-index: var(--layer-2);
|
| 447 |
+
padding: var(--size-1) var(--size-2);
|
| 448 |
+
font-size: var(--text-sm);
|
| 449 |
+
font-family: var(--font-mono);
|
| 450 |
+
}
|
| 451 |
+
|
| 452 |
+
.meta-text-center {
|
| 453 |
+
display: flex;
|
| 454 |
+
position: absolute;
|
| 455 |
+
top: 0;
|
| 456 |
+
right: 0;
|
| 457 |
+
justify-content: center;
|
| 458 |
+
align-items: center;
|
| 459 |
+
transform: translateY(var(--size-6));
|
| 460 |
+
z-index: var(--layer-2);
|
| 461 |
+
padding: var(--size-1) var(--size-2);
|
| 462 |
+
font-size: var(--text-sm);
|
| 463 |
+
font-family: var(--font-mono);
|
| 464 |
+
text-align: center;
|
| 465 |
+
}
|
| 466 |
+
|
| 467 |
+
.error {
|
| 468 |
+
box-shadow: var(--shadow-drop);
|
| 469 |
+
border: solid 1px var(--error-border-color);
|
| 470 |
+
border-radius: var(--radius-full);
|
| 471 |
+
background: var(--error-background-fill);
|
| 472 |
+
padding-right: var(--size-4);
|
| 473 |
+
padding-left: var(--size-4);
|
| 474 |
+
color: var(--error-text-color);
|
| 475 |
+
font-weight: var(--weight-semibold);
|
| 476 |
+
font-size: var(--text-lg);
|
| 477 |
+
line-height: var(--line-lg);
|
| 478 |
+
font-family: var(--font);
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
.validation-error {
|
| 482 |
+
pointer-events: auto;
|
| 483 |
+
color: var(--error-text-color);
|
| 484 |
+
font-weight: var(--weight-semibold);
|
| 485 |
+
font-size: var(--text-lg);
|
| 486 |
+
line-height: var(--line-lg);
|
| 487 |
+
font-family: var(--font);
|
| 488 |
+
position: absolute;
|
| 489 |
+
background: var(--error-background-fill);
|
| 490 |
+
top: 0;
|
| 491 |
+
right: 0;
|
| 492 |
+
z-index: var(--layer-3);
|
| 493 |
+
padding: var(--size-1) var(--size-2);
|
| 494 |
+
font-size: var(--text-md);
|
| 495 |
+
text-align: center;
|
| 496 |
+
border-bottom-left-radius: var(--radius-sm);
|
| 497 |
+
border-bottom: 1px solid var(--error-border-color);
|
| 498 |
+
border-left: 1px solid var(--error-border-color);
|
| 499 |
+
display: flex;
|
| 500 |
+
justify-content: space-between;
|
| 501 |
+
align-items: center;
|
| 502 |
+
gap: var(--spacing-xl);
|
| 503 |
+
}
|
| 504 |
+
|
| 505 |
+
.minimal {
|
| 506 |
+
pointer-events: none;
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
+
.minimal .progress-text {
|
| 510 |
+
background: var(--block-background-fill);
|
| 511 |
+
}
|
| 512 |
+
|
| 513 |
+
.border {
|
| 514 |
+
border: 1px solid var(--border-color-primary);
|
| 515 |
+
}
|
| 516 |
+
|
| 517 |
+
.clear-status {
|
| 518 |
+
position: absolute;
|
| 519 |
+
display: flex;
|
| 520 |
+
top: var(--size-2);
|
| 521 |
+
right: var(--size-2);
|
| 522 |
+
justify-content: flex-end;
|
| 523 |
+
gap: var(--spacing-sm);
|
| 524 |
+
z-index: var(--layer-1);
|
| 525 |
+
}
|
| 526 |
+
</style>
|
5.49.1/statustracker/static/index.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export { default as StatusTracker } from "./index.svelte";
|
| 2 |
+
export { default as Toast } from "./Toast.svelte";
|
| 3 |
+
export { default as Loader } from "./Loader.svelte";
|
| 4 |
+
export { default as StreamingBar } from "./StreamingBar.svelte";
|
| 5 |
+
export type * from "./types";
|
| 6 |
+
export { default } from "./index.svelte";
|
5.49.1/statustracker/static/types.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export interface LoadingStatus {
|
| 2 |
+
eta: number;
|
| 3 |
+
queue_position: number;
|
| 4 |
+
queue_size: number;
|
| 5 |
+
status: "pending" | "error" | "complete" | "generating" | "streaming";
|
| 6 |
+
show_progress: "full" | "minimal" | "hidden";
|
| 7 |
+
scroll_to_output: boolean;
|
| 8 |
+
visible: boolean;
|
| 9 |
+
fn_index: number;
|
| 10 |
+
message?: string;
|
| 11 |
+
progress?: {
|
| 12 |
+
progress: number | null;
|
| 13 |
+
index: number | null;
|
| 14 |
+
length: number | null;
|
| 15 |
+
unit: string | null;
|
| 16 |
+
desc: string | null;
|
| 17 |
+
}[];
|
| 18 |
+
time_limit?: number | null;
|
| 19 |
+
validation_error?: string | null;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
export interface ToastMessage {
|
| 23 |
+
type: "error" | "warning" | "info" | "success";
|
| 24 |
+
title: string;
|
| 25 |
+
message: string;
|
| 26 |
+
id: number;
|
| 27 |
+
duration: number | null;
|
| 28 |
+
visible: boolean;
|
| 29 |
+
}
|
5.49.1/statustracker/static/utils.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export function pretty_si(num: number): string {
|
| 2 |
+
let units = ["", "k", "M", "G", "T", "P", "E", "Z"];
|
| 3 |
+
let i = 0;
|
| 4 |
+
while (num > 1000 && i < units.length - 1) {
|
| 5 |
+
num /= 1000;
|
| 6 |
+
i++;
|
| 7 |
+
}
|
| 8 |
+
let unit = units[i];
|
| 9 |
+
return (Number.isInteger(num) ? num : num.toFixed(1)) + unit;
|
| 10 |
+
}
|