gradio-pr-bot commited on
Commit
7b497b6
·
verified ·
1 Parent(s): 3e00d35

Upload folder using huggingface_hub

Browse files
6.16.0/statustracker/index.ts ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
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";
7
+ export { LoadingStatus } from "./static/state.svelte.js";
6.16.0/statustracker/package.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/statustracker",
3
+ "version": "0.14.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": "^5.48.0"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/gradio-app/gradio.git",
33
+ "directory": "js/statustracker"
34
+ }
35
+ }
6.16.0/statustracker/static/Loader.svelte ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { spring } from "svelte/motion";
3
+
4
+ interface Props {
5
+ margin?: boolean;
6
+ }
7
+
8
+ let { margin = true }: Props = $props();
9
+
10
+ const top = spring([0, 0]);
11
+ const bottom = spring([0, 0]);
12
+
13
+ let dismounted = $state(false);
14
+
15
+ async function animate(): Promise<void> {
16
+ await Promise.all([top.set([125, 140]), bottom.set([-125, -140])]);
17
+ await Promise.all([top.set([-125, 140]), bottom.set([125, -140])]);
18
+ await Promise.all([top.set([-125, 0]), bottom.set([125, -0])]);
19
+ await Promise.all([top.set([125, 0]), bottom.set([-125, 0])]);
20
+ }
21
+
22
+ async function run(): Promise<void> {
23
+ await animate();
24
+ if (!dismounted) run();
25
+ }
26
+
27
+ async function loading(): Promise<void> {
28
+ await Promise.all([top.set([125, 0]), bottom.set([-125, 0])]);
29
+
30
+ run();
31
+ }
32
+
33
+ $effect(() => {
34
+ loading();
35
+ return () => {
36
+ dismounted = true;
37
+ };
38
+ });
39
+ </script>
40
+
41
+ <div class:margin>
42
+ <svg
43
+ viewBox="-1200 -1200 3000 3000"
44
+ fill="none"
45
+ xmlns="http://www.w3.org/2000/svg"
46
+ >
47
+ <g style="transform: translate({$top[0]}px, {$top[1]}px);">
48
+ <path
49
+ d="M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z"
50
+ fill="#FF7C00"
51
+ fill-opacity="0.4"
52
+ />
53
+ <path
54
+ d="M509.69 139.936L254.981 279.641V361.255L509.69 221.55V139.936Z"
55
+ fill="#FF7C00"
56
+ />
57
+ <path
58
+ d="M0.250138 139.937L254.981 279.641V361.255L0.250138 221.55V139.937Z"
59
+ fill="#FF7C00"
60
+ fill-opacity="0.4"
61
+ />
62
+ <path
63
+ d="M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z"
64
+ fill="#FF7C00"
65
+ />
66
+ </g>
67
+ <g style="transform: translate({$bottom[0]}px, {$bottom[1]}px);">
68
+ <path
69
+ d="M255.926 141.5L509.702 280.681V361.773L255.926 222.592V141.5Z"
70
+ fill="#FF7C00"
71
+ fill-opacity="0.4"
72
+ />
73
+ <path
74
+ d="M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z"
75
+ fill="#FF7C00"
76
+ />
77
+ <path
78
+ d="M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z"
79
+ fill="#FF7C00"
80
+ fill-opacity="0.4"
81
+ />
82
+ <path
83
+ d="M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z"
84
+ fill="#FF7C00"
85
+ />
86
+ </g>
87
+ </svg>
88
+ </div>
89
+
90
+ <style>
91
+ svg {
92
+ width: var(--size-20);
93
+ height: var(--size-20);
94
+ }
95
+
96
+ svg path {
97
+ fill: var(--loader-color);
98
+ }
99
+
100
+ div {
101
+ z-index: var(--layer-2);
102
+ }
103
+
104
+ .margin {
105
+ margin: var(--size-4);
106
+ }
107
+ </style>
6.16.0/statustracker/static/StreamingBar.svelte ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ interface Props {
3
+ time_limit: number | null;
4
+ }
5
+
6
+ let { time_limit }: Props = $props();
7
+ </script>
8
+
9
+ {#if time_limit}
10
+ <div class="streaming-bar" style:animation-duration="{time_limit}s"></div>
11
+ {/if}
12
+
13
+ <style>
14
+ .streaming-bar {
15
+ position: absolute;
16
+ bottom: 0;
17
+ left: 0;
18
+ right: 0;
19
+ height: 4px;
20
+ background-color: var(--primary-600);
21
+ animation: countdown linear forwards;
22
+ z-index: 1;
23
+ }
24
+
25
+ @keyframes countdown {
26
+ from {
27
+ transform: translateX(0%);
28
+ }
29
+ to {
30
+ transform: translateX(-100%);
31
+ }
32
+ }
33
+ </style>
6.16.0/statustracker/static/Toast.svelte ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { ToastMessage, GroupedToastMessage } from "./types";
3
+ import ToastContent from "./ToastContent.svelte";
4
+ import { spring } from "svelte/motion";
5
+
6
+ interface Props {
7
+ messages?: ToastMessage[];
8
+ on_close: (id: number) => void;
9
+ }
10
+
11
+ let { messages = [], on_close }: Props = $props();
12
+ const top = spring(0, { stiffness: 0.4, damping: 0.5 });
13
+
14
+ let grouped_messages: GroupedToastMessage[] = $state([]);
15
+
16
+ $effect(() => {
17
+ scroll_to_top(messages);
18
+ });
19
+
20
+ $effect(() => {
21
+ grouped_messages = group_messages(messages);
22
+ });
23
+
24
+ function group_messages(msgs: ToastMessage[]): GroupedToastMessage[] {
25
+ const groups = new Map<string, GroupedToastMessage>();
26
+
27
+ msgs.forEach((msg) => {
28
+ const key = msg.type;
29
+ if (!groups.has(key)) {
30
+ groups.set(key, {
31
+ type: msg.type,
32
+ messages: [],
33
+ expanded: true
34
+ });
35
+ }
36
+ groups.get(key)!.messages.push(msg);
37
+ });
38
+
39
+ return Array.from(groups.values());
40
+ }
41
+
42
+ function scroll_to_top(_messages: ToastMessage[]): void {
43
+ if (_messages.length > 0) {
44
+ if ("parentIFrame" in window) {
45
+ window.parentIFrame?.getPageInfo((page_info) => {
46
+ if (page_info.scrollTop < page_info.offsetTop) {
47
+ top.set(0);
48
+ } else {
49
+ top.set(page_info.scrollTop - page_info.offsetTop);
50
+ }
51
+ });
52
+ }
53
+ }
54
+ }
55
+
56
+ function toggle_group(type: string): void {
57
+ grouped_messages = grouped_messages.map((group) => {
58
+ if (group.type === type) {
59
+ return { ...group, expanded: !group.expanded };
60
+ }
61
+ return group;
62
+ });
63
+ }
64
+ </script>
65
+
66
+ <div class="toast-wrap" style="--toast-top: {$top}px;">
67
+ {#each grouped_messages as group (group.type)}
68
+ <div class="toast-item">
69
+ <ToastContent
70
+ type={group.type}
71
+ messages={group.messages}
72
+ expanded={group.expanded}
73
+ ontoggle={() => toggle_group(group.type)}
74
+ onclose={(id) => on_close(id)}
75
+ />
76
+ </div>
77
+ {/each}
78
+ </div>
79
+
80
+ <style>
81
+ .toast-wrap {
82
+ --toast-top: var(--size-4);
83
+ display: flex;
84
+ position: fixed;
85
+ top: calc(var(--toast-top) + var(--size-3));
86
+ flex-direction: column;
87
+ gap: var(--size-2);
88
+ z-index: var(--layer-top);
89
+ right: var(--size-3);
90
+ left: var(--size-3);
91
+ align-items: end;
92
+ max-width: none;
93
+ }
94
+
95
+ .toast-item {
96
+ width: 100%;
97
+ }
98
+
99
+ @media (min-width: 640px) {
100
+ .toast-wrap {
101
+ left: auto;
102
+ width: calc(var(--size-96) + var(--size-10));
103
+ }
104
+ }
105
+ </style>
6.16.0/statustracker/static/ToastContent.svelte ADDED
@@ -0,0 +1,396 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Error, Info, Warning, Success, ChevronDown } from "@gradio/icons";
3
+ import { sanitize } from "@gradio/sanitize";
4
+ import { fade, slide } from "svelte/transition";
5
+ import type { ToastMessage } from "./types";
6
+
7
+ interface Props {
8
+ type: ToastMessage["type"];
9
+ messages?: ToastMessage[];
10
+ expanded?: boolean;
11
+ ontoggle?: () => void;
12
+ onclose?: (id: number) => void;
13
+ }
14
+
15
+ let {
16
+ type,
17
+ messages = [],
18
+ expanded = true,
19
+ ontoggle,
20
+ onclose
21
+ }: Props = $props();
22
+
23
+ let touch_start_x = $state(0);
24
+ let touch_start_y = $state(0);
25
+ let offset_x = $state(0);
26
+ let is_dragging = $state(false);
27
+ let toast_element: HTMLElement;
28
+
29
+ const default_messages: Record<ToastMessage["type"], string> = {
30
+ error: "An error occurred.",
31
+ warning: "Warning.",
32
+ success: "Success.",
33
+ info: "Info."
34
+ };
35
+
36
+ let count = $derived(messages.length);
37
+ let first_message = $derived(messages[0]);
38
+ let type_label = $derived(type.charAt(0).toUpperCase() + type.slice(1));
39
+ let has_duration = $derived(first_message?.duration !== null);
40
+ let timer_duration = $derived(
41
+ has_duration ? `${first_message.duration}s` : "0s"
42
+ );
43
+
44
+ function handle_toggle(): void {
45
+ ontoggle?.();
46
+ }
47
+
48
+ function close_all(): void {
49
+ messages.forEach((msg) => {
50
+ onclose?.(msg.id);
51
+ });
52
+ }
53
+
54
+ function handle_touch_start(e: TouchEvent): void {
55
+ touch_start_x = e.touches[0].clientX;
56
+ touch_start_y = e.touches[0].clientY;
57
+ is_dragging = true;
58
+ }
59
+
60
+ function handle_touch_move(e: TouchEvent): void {
61
+ if (!is_dragging) return;
62
+
63
+ const touch_x = e.touches[0].clientX;
64
+ const touch_y = e.touches[0].clientY;
65
+ const delta_x = touch_x - touch_start_x;
66
+ const delta_y = touch_y - touch_start_y;
67
+
68
+ if (Math.abs(delta_x) > Math.abs(delta_y) && Math.abs(delta_x) > 10) {
69
+ e.preventDefault();
70
+ offset_x = delta_x;
71
+ }
72
+ }
73
+
74
+ function handle_touch_end(): void {
75
+ if (!is_dragging) return;
76
+
77
+ if (Math.abs(offset_x) > 100) {
78
+ close_all();
79
+ } else {
80
+ offset_x = 0;
81
+ }
82
+
83
+ is_dragging = false;
84
+ }
85
+
86
+ $effect(() => {
87
+ if (has_duration && messages.length === 1) {
88
+ setTimeout(close_all, first_message.duration! * 1000);
89
+ }
90
+ });
91
+ </script>
92
+
93
+ <div
94
+ bind:this={toast_element}
95
+ class="toast-body {type}"
96
+ role="status"
97
+ aria-live="polite"
98
+ data-testid="toast-body"
99
+ ontouchstart={handle_touch_start}
100
+ ontouchmove={handle_touch_move}
101
+ ontouchend={handle_touch_end}
102
+ in:fade={{ duration: 200, delay: 100 }}
103
+ out:fade={{ duration: 200 }}
104
+ style="transform: translateX({offset_x}px); opacity: {1 -
105
+ Math.abs(offset_x) / 300};"
106
+ >
107
+ <div
108
+ class="toast-header"
109
+ onclick={handle_toggle}
110
+ role="button"
111
+ tabindex="0"
112
+ onkeydown={(e) => {
113
+ if (e.key === "Enter" || e.key === " ") {
114
+ handle_toggle();
115
+ }
116
+ }}
117
+ >
118
+ <div class="toast-icon {type}">
119
+ {#if type === "warning"}
120
+ <Warning />
121
+ {:else if type === "info"}
122
+ <Info />
123
+ {:else if type === "success"}
124
+ <Success />
125
+ {:else if type === "error"}
126
+ <Error />
127
+ {/if}
128
+ </div>
129
+
130
+ <div class="toast-title-row">
131
+ <span class="toast-title {type}">
132
+ {type_label}
133
+ {#if count > 1}
134
+ <span class="toast-count">({count})</span>
135
+ {/if}
136
+ </span>
137
+ <div class="chevron" class:expanded class:visible={count > 0}>
138
+ <ChevronDown />
139
+ </div>
140
+ </div>
141
+
142
+ <button
143
+ onclick={(e) => {
144
+ e.stopPropagation();
145
+ close_all();
146
+ }}
147
+ class="toast-close {type}"
148
+ type="button"
149
+ aria-label="Close"
150
+ data-testid="toast-close"
151
+ >
152
+ <span aria-hidden="true">&#215;</span>
153
+ </button>
154
+ </div>
155
+
156
+ {#if expanded}
157
+ <div class="toast-messages" transition:slide={{ duration: 200 }}>
158
+ {#each messages as message, i (message.id)}
159
+ <div class="toast-message-item {type}">
160
+ <div class="toast-message-text {type}" data-testid="toast-text">
161
+ {@html sanitize(message.message || default_messages[type])}
162
+ </div>
163
+ </div>
164
+ {#if i < messages.length - 1}
165
+ <div class="toast-separator" />
166
+ {/if}
167
+ {/each}
168
+ </div>
169
+ {/if}
170
+
171
+ {#if has_duration}
172
+ <div class="timer {type}" style="animation-duration: {timer_duration}" />
173
+ {/if}
174
+ </div>
175
+
176
+ <!-- s-csdrBJqpTpqa -->
177
+ <style>
178
+ .toast-body {
179
+ display: flex;
180
+ flex-direction: column;
181
+ position: relative;
182
+ right: 0;
183
+ left: 0;
184
+ margin: auto;
185
+ border-radius: var(--radius-sm);
186
+ overflow: hidden;
187
+ pointer-events: auto;
188
+ background: var(--background-fill-secondary);
189
+ border: 1px solid var(--border-color-primary);
190
+ box-shadow: var(--shadow-drop);
191
+ touch-action: pan-y;
192
+ user-select: none;
193
+ }
194
+
195
+ :global(.dark) .toast-body {
196
+ background: var(--background-fill-primary);
197
+ }
198
+
199
+ .toast-body.error {
200
+ --toast-color: var(--color-red-700);
201
+ }
202
+
203
+ .toast-body.warning {
204
+ --toast-color: var(--color-yellow-700);
205
+ }
206
+
207
+ .toast-body.info {
208
+ --toast-color: var(--color-grey-700);
209
+ }
210
+
211
+ .toast-body.success {
212
+ --toast-color: var(--color-green-700);
213
+ }
214
+
215
+ :global(.dark) .toast-body.error {
216
+ --toast-color: var(--color-red-500);
217
+ }
218
+
219
+ :global(.dark) .toast-body.warning {
220
+ --toast-color: var(--color-yellow-500);
221
+ }
222
+
223
+ :global(.dark) .toast-body.info {
224
+ --toast-color: var(--color-grey-500);
225
+ }
226
+
227
+ :global(.dark) .toast-body.success {
228
+ --toast-color: var(--color-green-500);
229
+ }
230
+
231
+ .toast-header {
232
+ display: flex;
233
+ align-items: center;
234
+ padding: var(--size-3) var(--size-3);
235
+ cursor: pointer;
236
+ }
237
+
238
+ .toast-header:hover {
239
+ opacity: 0.9;
240
+ }
241
+
242
+ .toast-title-row {
243
+ flex: 1;
244
+ display: flex;
245
+ align-items: center;
246
+ gap: var(--size-2);
247
+ }
248
+
249
+ .chevron {
250
+ display: flex;
251
+ align-items: center;
252
+ width: var(--size-4);
253
+ height: var(--size-4);
254
+ transition: transform 0.2s ease;
255
+ opacity: 0.6;
256
+ }
257
+
258
+ .chevron.visible {
259
+ opacity: 1;
260
+ }
261
+
262
+ .chevron.expanded {
263
+ transform: rotate(180deg);
264
+ }
265
+
266
+ .toast-title {
267
+ display: flex;
268
+ align-items: center;
269
+ font-weight: var(--weight-bold);
270
+ font-size: var(--text-lg);
271
+ line-height: var(--line-sm);
272
+ }
273
+
274
+ .toast-count {
275
+ margin-left: var(--size-1);
276
+ font-weight: var(--weight-semibold);
277
+ }
278
+
279
+ .toast-close {
280
+ margin: 0 var(--size-1);
281
+ border-radius: var(--radius-lg);
282
+ padding: var(--size-1);
283
+ font-size: var(--text-xl);
284
+ line-height: 1;
285
+ background: transparent;
286
+ border: none;
287
+ cursor: pointer;
288
+ transition: all 0.2s ease;
289
+ display: flex;
290
+ align-items: center;
291
+ justify-content: center;
292
+ width: var(--size-7);
293
+ height: var(--size-7);
294
+ opacity: 0.6;
295
+ flex-shrink: 0;
296
+ }
297
+
298
+ .toast-close:hover {
299
+ opacity: 1;
300
+ transform: scale(1.1);
301
+ }
302
+
303
+ .toast-close:active {
304
+ transform: scale(0.95);
305
+ }
306
+
307
+ .toast-close {
308
+ color: var(--body-text-color);
309
+ }
310
+
311
+ .toast-icon {
312
+ display: flex;
313
+ position: relative;
314
+ flex-shrink: 0;
315
+ justify-content: center;
316
+ align-items: center;
317
+ margin-right: var(--size-2);
318
+ border-radius: var(--radius-full);
319
+ padding: var(--size-1-5);
320
+ width: var(--size-8);
321
+ height: var(--size-8);
322
+ }
323
+
324
+ .toast-icon {
325
+ color: var(--toast-color);
326
+ }
327
+
328
+ .toast-messages {
329
+ display: flex;
330
+ flex-direction: column;
331
+ gap: var(--size-2);
332
+ padding: 0 var(--size-3) var(--size-2) var(--size-3);
333
+ }
334
+
335
+ .toast-message-item {
336
+ padding: var(--size-1-5) var(--size-1-5) var(--size-1-5) var(--size-1-5);
337
+ border-radius: var(--radius-lg);
338
+ }
339
+
340
+ .toast-separator {
341
+ height: 1px;
342
+ background: var(--border-color-primary);
343
+ margin: 0;
344
+ }
345
+
346
+ .toast-message-text {
347
+ font-size: var(--text-md);
348
+ line-height: 1.5;
349
+ word-wrap: break-word;
350
+ overflow-wrap: break-word;
351
+ word-break: break-word;
352
+ color: var(--body-text-color);
353
+ }
354
+
355
+ .toast-message-text :global(a) {
356
+ text-decoration: underline;
357
+ }
358
+
359
+ @keyframes countdown {
360
+ from {
361
+ transform: scaleX(1);
362
+ }
363
+ to {
364
+ transform: scaleX(0);
365
+ }
366
+ }
367
+
368
+ .timer {
369
+ position: absolute;
370
+ bottom: 0;
371
+ left: 0;
372
+ transform-origin: 0 0;
373
+ animation: countdown 10s linear forwards;
374
+ width: 100%;
375
+ height: var(--size-1);
376
+ }
377
+
378
+ .timer {
379
+ background: var(--toast-color);
380
+ }
381
+
382
+ @media (max-width: 640px) {
383
+ .toast-header {
384
+ padding: var(--size-2) var(--size-2);
385
+ }
386
+
387
+ .toast-messages {
388
+ gap: var(--size-1);
389
+ padding: 0 var(--size-2) var(--size-1-5) var(--size-2);
390
+ }
391
+
392
+ .toast-message-item {
393
+ padding: 0 var(--size-1) var(--size-1) var(--size-1);
394
+ }
395
+ }
396
+ </style>
6.16.0/statustracker/static/index.svelte ADDED
@@ -0,0 +1,680 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script context="module" lang="ts">
2
+ import { tick, untrack } from "svelte";
3
+ import { pretty_si } from "./utils";
4
+
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
+ const shown_cache_indicator_keys = new Set<string>();
14
+
15
+ async function scroll_into_view(
16
+ el: HTMLDivElement,
17
+ enable: boolean | null = true
18
+ ): Promise<void> {
19
+ if (
20
+ window.__gradio_mode__ === "website" ||
21
+ (window.__gradio_mode__ !== "app" && enable !== true)
22
+ ) {
23
+ return;
24
+ }
25
+
26
+ items.push(el);
27
+ if (!called) called = true;
28
+ else return;
29
+
30
+ await tick();
31
+
32
+ raf(() => {
33
+ let min = [0, 0];
34
+
35
+ for (let i = 0; i < items.length; i++) {
36
+ const element = items[i];
37
+
38
+ const box = element.getBoundingClientRect();
39
+ if (i === 0 || box.top + window.scrollY <= min[0]) {
40
+ min[0] = box.top + window.scrollY;
41
+ min[1] = i;
42
+ }
43
+ }
44
+
45
+ window.scrollTo({ top: min[0] - 20, behavior: "smooth" });
46
+
47
+ called = false;
48
+ items = [];
49
+ });
50
+ }
51
+ </script>
52
+
53
+ <script lang="ts">
54
+ import Loader from "./Loader.svelte";
55
+ import type { LoadingStatus } from "./types";
56
+ import type { I18nFormatter } from "@gradio/utils";
57
+
58
+ import { IconButton } from "@gradio/atoms";
59
+ import { Clear } from "@gradio/icons";
60
+
61
+ interface Props {
62
+ i18n: I18nFormatter;
63
+ eta?: number | null;
64
+ queue_position: number | null;
65
+ queue_size: number | null;
66
+ component_id?: number | null;
67
+ fn_index?: number | null;
68
+ status:
69
+ | "complete"
70
+ | "pending"
71
+ | "error"
72
+ | "generating"
73
+ | "streaming"
74
+ | null;
75
+ scroll_to_output?: boolean;
76
+ timer?: boolean;
77
+ show_progress?: "full" | "minimal" | "hidden";
78
+ message?: string | null;
79
+ progress?: LoadingStatus["progress"] | null | undefined;
80
+ variant?: "default" | "center";
81
+ loading_text?: string;
82
+ absolute?: boolean;
83
+ translucent?: boolean;
84
+ border?: boolean;
85
+ autoscroll: boolean;
86
+ validation_error?: string | null;
87
+ show_validation_error?: boolean;
88
+ type?: "input" | "output" | null;
89
+ on_clear_status?: () => void;
90
+ used_cache?: "full" | "partial" | null;
91
+ cache_duration?: number | null;
92
+ avg_time?: number | null;
93
+ cache_event_id?: number | null;
94
+ }
95
+
96
+ interface ProgressLevel {
97
+ progress_level: (number | undefined)[] | null;
98
+ last_progress_level: number | undefined;
99
+ progress_bar_transition: string;
100
+ }
101
+
102
+ let {
103
+ i18n,
104
+ eta = null,
105
+ queue_position,
106
+ queue_size,
107
+ component_id = null,
108
+ fn_index = null,
109
+ status,
110
+ scroll_to_output = false,
111
+ timer = true,
112
+ show_progress = "full",
113
+ message = null,
114
+ progress = null,
115
+ variant = "default",
116
+ loading_text = "Loading...",
117
+ absolute = true,
118
+ translucent = false,
119
+ border = false,
120
+ autoscroll,
121
+ validation_error = null,
122
+ show_validation_error = true,
123
+ type = null,
124
+ on_clear_status,
125
+ used_cache = null,
126
+ cache_duration = null,
127
+ avg_time = null,
128
+ cache_event_id = null
129
+ }: Props = $props();
130
+
131
+ let el: HTMLDivElement;
132
+
133
+ let _timer = false;
134
+ let timer_start = $state(0);
135
+ let old_eta = $state<number | null>(null);
136
+ let eta_from_start = $state<number | null>(null);
137
+ let message_visible = $state(false);
138
+ let formatted_eta = $state<string | null>(null);
139
+ let show_message_timeout = $state<NodeJS.Timeout | null>(null);
140
+ let show_cache_indicator = $state(false);
141
+ let cache_indicator_fading = $state(false);
142
+ let cache_display_time = $state<string | null>(null);
143
+ let cache_display_avg = $state<string | null>(null);
144
+ let cache_indicator_label = $state("from cache");
145
+ let show_cache_avg = $state(false);
146
+ let cache_timeout: ReturnType<typeof setTimeout> | null = null;
147
+ let cache_fade_timeout: ReturnType<typeof setTimeout> | null = null;
148
+ let last_cache_indicator_key: string | null = null;
149
+
150
+ function hide_cache_indicator(): void {
151
+ if (cache_timeout) clearTimeout(cache_timeout);
152
+ if (cache_fade_timeout) clearTimeout(cache_fade_timeout);
153
+ cache_timeout = null;
154
+ cache_fade_timeout = null;
155
+ show_cache_indicator = false;
156
+ cache_indicator_fading = false;
157
+ }
158
+
159
+ const should_hide = $derived(
160
+ !(show_validation_error && validation_error) &&
161
+ (type === "input" ||
162
+ !status ||
163
+ status === "complete" ||
164
+ show_progress === "hidden" ||
165
+ status == "streaming")
166
+ );
167
+
168
+ let timer_diff = $state(0);
169
+
170
+ const eta_level = $derived(
171
+ eta_from_start === null || eta_from_start <= 0 || !timer_diff
172
+ ? 0
173
+ : Math.min(timer_diff / eta_from_start, 1)
174
+ );
175
+
176
+ const formatted_timer = $derived(timer_diff.toFixed(1));
177
+
178
+ let show_eta_bar = $derived(progress != null ? false : true);
179
+ let effective_eta = $derived(eta ?? old_eta);
180
+
181
+ function run(): void {
182
+ raf(() => {
183
+ timer_diff = (performance.now() - timer_start) / 1000;
184
+ if (_timer) run();
185
+ });
186
+ }
187
+
188
+ let progress_level = $derived.by<ProgressLevel>(() => {
189
+ let _progress_level: (number | undefined)[] | null = null;
190
+ if (progress != null) {
191
+ _progress_level = progress.map((p) => {
192
+ if (p.index != null && p.length != null) {
193
+ return p.index / p.length;
194
+ } else if (p.progress != null) {
195
+ return p.progress;
196
+ }
197
+ return undefined;
198
+ });
199
+ } else {
200
+ _progress_level = null;
201
+ }
202
+
203
+ let _last_progress_level: number | undefined;
204
+ let transition = "";
205
+ if (_progress_level) {
206
+ _last_progress_level = _progress_level[_progress_level.length - 1];
207
+
208
+ if (_last_progress_level === 0) {
209
+ transition = "0";
210
+ } else {
211
+ transition = "150ms";
212
+ }
213
+ } else {
214
+ _last_progress_level = undefined;
215
+ }
216
+
217
+ return {
218
+ progress_level: _progress_level,
219
+ last_progress_level: _last_progress_level,
220
+ progress_bar_transition: transition
221
+ };
222
+ });
223
+
224
+ function start_timer(): void {
225
+ if (_timer) return;
226
+
227
+ old_eta = formatted_eta = null;
228
+ timer_start = performance.now();
229
+
230
+ _timer = true;
231
+ run();
232
+ }
233
+
234
+ function stop_timer(): void {
235
+ old_eta = formatted_eta = null;
236
+ if (!_timer) return;
237
+ _timer = false;
238
+ }
239
+
240
+ $effect(() => {
241
+ if (status === "pending") {
242
+ start_timer();
243
+ } else {
244
+ untrack(() => {
245
+ stop_timer();
246
+ });
247
+ }
248
+ });
249
+
250
+ $effect(() => {
251
+ if (
252
+ el &&
253
+ scroll_to_output &&
254
+ (status === "pending" || status === "complete")
255
+ ) {
256
+ scroll_into_view(el, autoscroll);
257
+ }
258
+ });
259
+
260
+ $effect(() => {
261
+ if (effective_eta != null && old_eta !== effective_eta) {
262
+ eta_from_start = (performance.now() - timer_start) / 1000 + effective_eta;
263
+ formatted_eta = eta_from_start.toFixed(1);
264
+ old_eta = effective_eta;
265
+ }
266
+ });
267
+
268
+ function close_message(): void {
269
+ message_visible = false;
270
+ if (show_message_timeout !== null) {
271
+ clearTimeout(show_message_timeout);
272
+ }
273
+ }
274
+
275
+ $effect(() => {
276
+ untrack(() => {
277
+ close_message();
278
+ });
279
+
280
+ if (status === "error" && message) {
281
+ message_visible = true;
282
+ }
283
+ });
284
+
285
+ $effect(() => {
286
+ if (
287
+ status === "complete" &&
288
+ type === "output" &&
289
+ used_cache &&
290
+ cache_duration != null
291
+ ) {
292
+ const cache_indicator_key =
293
+ cache_event_id == null
294
+ ? null
295
+ : `${component_id ?? fn_index ?? "unknown"}:${fn_index ?? "unknown"}:${cache_event_id}`;
296
+ if (
297
+ cache_indicator_key === last_cache_indicator_key ||
298
+ (cache_indicator_key != null &&
299
+ shown_cache_indicator_keys.has(cache_indicator_key))
300
+ ) {
301
+ return;
302
+ }
303
+ last_cache_indicator_key = cache_indicator_key;
304
+ if (cache_indicator_key != null) {
305
+ shown_cache_indicator_keys.add(cache_indicator_key);
306
+ }
307
+ cache_display_time = cache_duration.toFixed(1);
308
+ cache_indicator_label =
309
+ used_cache === "full" ? "from cache" : "used cache";
310
+ show_cache_avg =
311
+ avg_time != null && avg_time > cache_duration && avg_time > 0;
312
+ cache_display_avg = show_cache_avg ? avg_time!.toFixed(1) : null;
313
+ show_cache_indicator = true;
314
+ cache_indicator_fading = false;
315
+
316
+ if (cache_timeout) clearTimeout(cache_timeout);
317
+ if (cache_fade_timeout) clearTimeout(cache_fade_timeout);
318
+ cache_timeout = setTimeout(() => {
319
+ cache_indicator_fading = true;
320
+ cache_fade_timeout = setTimeout(() => {
321
+ show_cache_indicator = false;
322
+ cache_indicator_fading = false;
323
+ }, 500);
324
+ }, 1750);
325
+ } else if (type === "output" && !used_cache) {
326
+ hide_cache_indicator();
327
+ }
328
+ });
329
+ </script>
330
+
331
+ <div
332
+ class="wrap {variant} {show_progress}"
333
+ class:no-click={validation_error && show_validation_error}
334
+ class:hide={should_hide}
335
+ class:translucent={(variant === "center" &&
336
+ (status === "pending" || status === "error")) ||
337
+ translucent ||
338
+ show_progress === "minimal" ||
339
+ validation_error}
340
+ class:generating={status === "generating" && show_progress === "full"}
341
+ class:border
342
+ style:position={absolute ? "absolute" : "static"}
343
+ style:padding={absolute ? "0" : "var(--size-8) 0"}
344
+ data-testid="status-tracker"
345
+ bind:this={el}
346
+ >
347
+ {#if validation_error && show_validation_error}
348
+ <div class="validation-error">
349
+ {validation_error}
350
+ <button
351
+ ><IconButton
352
+ Icon={Clear}
353
+ label={i18n ? i18n("common.clear") : "Clear"}
354
+ disabled={false}
355
+ size="x-small"
356
+ background="var(--background-fill-primary)"
357
+ color="var(--error-background-text)"
358
+ border="var(--border-color-primary)"
359
+ onclick={() => (validation_error = null)}
360
+ /></button
361
+ >
362
+ </div>
363
+ {/if}
364
+ {#if status === "pending"}
365
+ {#if variant === "default" && show_eta_bar && show_progress === "full"}
366
+ <div
367
+ class="eta-bar"
368
+ style:transform="translateX({(eta_level || 0) * 100 - 100}%)"
369
+ />
370
+ {/if}
371
+ <div
372
+ class:meta-text-center={variant === "center"}
373
+ class:meta-text={variant === "default"}
374
+ class="progress-text"
375
+ >
376
+ {#if progress}
377
+ {#each progress as p}
378
+ {#if p.index != null}
379
+ {#if p.length != null}
380
+ {pretty_si(p.index || 0)}/{pretty_si(p.length)}
381
+ {:else}
382
+ {pretty_si(p.index || 0)}
383
+ {/if}
384
+ {p.unit} | {" "}
385
+ {/if}
386
+ {/each}
387
+ {:else if queue_position !== null && queue_size !== undefined && queue_position >= 0}
388
+ queue: {queue_position + 1}/{queue_size} |
389
+ {:else if queue_position === 0}
390
+ processing |
391
+ {/if}
392
+
393
+ {#if timer}
394
+ {formatted_timer}{eta ? `/${formatted_eta}` : ""}s
395
+ {/if}
396
+ </div>
397
+
398
+ {#if progress_level.last_progress_level != null}
399
+ <div class="progress-level">
400
+ <div class="progress-level-inner">
401
+ {#if progress != null}
402
+ {#each progress as p, i}
403
+ {#if p.desc != null || (progress_level.progress_level && progress_level.progress_level[i] != null)}
404
+ {#if i !== 0}
405
+ &nbsp;/
406
+ {/if}
407
+ {#if p.desc != null}
408
+ {p.desc}
409
+ {/if}
410
+ {#if p.desc != null && progress_level.progress_level && progress_level.progress_level[i] != null}
411
+ -
412
+ {/if}
413
+ {#if progress_level.progress_level != null}
414
+ {(100 * (progress_level.progress_level[i] || 0)).toFixed(1)}%
415
+ {/if}
416
+ {/if}
417
+ {/each}
418
+ {/if}
419
+ </div>
420
+
421
+ <div class="progress-bar-wrap">
422
+ <div
423
+ class="progress-bar"
424
+ style:width="{progress_level.last_progress_level * 100}%"
425
+ style:transition={progress_level.progress_bar_transition}
426
+ />
427
+ </div>
428
+ </div>
429
+ {:else if show_progress === "full"}
430
+ <Loader margin={variant === "default"} />
431
+ {/if}
432
+
433
+ {#if !timer}
434
+ <p class="loading">{loading_text}</p>
435
+ <slot name="additional-loading-text" />
436
+ {/if}
437
+ {:else if status === "error"}
438
+ <div class="clear-status">
439
+ <IconButton
440
+ Icon={Clear}
441
+ label={i18n("common.clear")}
442
+ disabled={false}
443
+ on:click={() => {
444
+ on_clear_status?.();
445
+ }}
446
+ />
447
+ </div>
448
+ <span class="error">{i18n("common.error")}</span>
449
+ <slot name="error" />
450
+ {/if}
451
+ </div>
452
+
453
+ {#if show_cache_indicator}
454
+ <div
455
+ class="cache-indicator"
456
+ class:fade-out={cache_indicator_fading}
457
+ style:position={absolute ? "absolute" : "static"}
458
+ >
459
+ &#9889; {cache_indicator_label}: {#if show_cache_avg}~{cache_display_avg}s
460
+ &rarr;&nbsp;
461
+ {/if}{cache_display_time}s
462
+ </div>
463
+ {/if}
464
+
465
+ <style>
466
+ .wrap {
467
+ display: flex;
468
+ flex-direction: column;
469
+ justify-content: center;
470
+ align-items: center;
471
+ z-index: var(--layer-3);
472
+ transition: opacity 0.1s ease-in-out;
473
+ border-radius: var(--block-radius);
474
+ background: var(--block-background-fill);
475
+ padding: 0 var(--size-6);
476
+ overflow: hidden;
477
+ }
478
+ .no-click {
479
+ pointer-events: none;
480
+ }
481
+
482
+ .wrap.center {
483
+ top: 0;
484
+ right: 0px;
485
+ left: 0px;
486
+ }
487
+
488
+ .wrap.default {
489
+ top: 0px;
490
+ right: 0px;
491
+ bottom: 0px;
492
+ left: 0px;
493
+ }
494
+
495
+ .hide {
496
+ opacity: 0;
497
+ pointer-events: none;
498
+ }
499
+
500
+ .generating {
501
+ animation:
502
+ pulseStart 1s cubic-bezier(0.4, 0, 0.6, 1),
503
+ pulse 2s cubic-bezier(0.4, 0, 0.6, 1) 1s infinite;
504
+ border: 2px solid var(--color-accent);
505
+ background: transparent;
506
+ z-index: var(--layer-1);
507
+ pointer-events: none;
508
+ }
509
+
510
+ .translucent {
511
+ background: none;
512
+ }
513
+
514
+ @keyframes pulseStart {
515
+ 0% {
516
+ opacity: 0;
517
+ }
518
+ 100% {
519
+ opacity: 1;
520
+ }
521
+ }
522
+
523
+ @keyframes pulse {
524
+ 0%,
525
+ 100% {
526
+ opacity: 1;
527
+ }
528
+ 50% {
529
+ opacity: 0.5;
530
+ }
531
+ }
532
+
533
+ .loading {
534
+ z-index: var(--layer-2);
535
+ color: var(--body-text-color);
536
+ }
537
+ .eta-bar {
538
+ position: absolute;
539
+ top: 0;
540
+ right: 0;
541
+ bottom: 0;
542
+ left: 0;
543
+ transform-origin: left;
544
+ opacity: 0.8;
545
+ z-index: var(--layer-1);
546
+ transition: 10ms;
547
+ background: var(--background-fill-secondary);
548
+ }
549
+ .progress-bar-wrap {
550
+ border: 1px solid var(--border-color-primary);
551
+ background: var(--background-fill-primary);
552
+ width: 55.5%;
553
+ height: var(--size-4);
554
+ }
555
+ .progress-bar {
556
+ transform-origin: left;
557
+ background-color: var(--loader-color);
558
+ width: var(--size-full);
559
+ height: var(--size-full);
560
+ }
561
+
562
+ .progress-level {
563
+ display: flex;
564
+ flex-direction: column;
565
+ align-items: center;
566
+ gap: 1;
567
+ z-index: var(--layer-2);
568
+ width: var(--size-full);
569
+ }
570
+
571
+ .progress-level-inner {
572
+ margin: var(--size-2) auto;
573
+ color: var(--body-text-color);
574
+ font-size: var(--text-sm);
575
+ font-family: var(--font-mono);
576
+ }
577
+
578
+ .meta-text {
579
+ position: absolute;
580
+ bottom: 0;
581
+ right: 0;
582
+ z-index: var(--layer-2);
583
+ padding: var(--size-1) var(--size-2);
584
+ font-size: var(--text-sm);
585
+ font-family: var(--font-mono);
586
+ }
587
+
588
+ .meta-text-center {
589
+ display: flex;
590
+ position: absolute;
591
+ top: 0;
592
+ right: 0;
593
+ justify-content: center;
594
+ align-items: center;
595
+ transform: translateY(var(--size-6));
596
+ z-index: var(--layer-2);
597
+ padding: var(--size-1) var(--size-2);
598
+ font-size: var(--text-sm);
599
+ font-family: var(--font-mono);
600
+ text-align: center;
601
+ }
602
+
603
+ .error {
604
+ box-shadow: var(--shadow-drop);
605
+ border: solid 1px var(--error-border-color);
606
+ border-radius: var(--radius-full);
607
+ background: var(--error-background-fill);
608
+ padding-right: var(--size-4);
609
+ padding-left: var(--size-4);
610
+ color: var(--error-text-color);
611
+ font-weight: var(--weight-semibold);
612
+ font-size: var(--text-lg);
613
+ line-height: var(--line-lg);
614
+ font-family: var(--font);
615
+ }
616
+
617
+ .validation-error {
618
+ pointer-events: auto;
619
+ color: var(--error-text-color);
620
+ font-weight: var(--weight-semibold);
621
+ font-size: var(--text-lg);
622
+ line-height: var(--line-lg);
623
+ font-family: var(--font);
624
+ position: absolute;
625
+ background: var(--error-background-fill);
626
+ top: 0;
627
+ right: 0;
628
+ z-index: var(--layer-3);
629
+ padding: var(--size-1) var(--size-2);
630
+ font-size: var(--text-md);
631
+ text-align: center;
632
+ border-bottom-left-radius: var(--radius-sm);
633
+ border-bottom: 1px solid var(--error-border-color);
634
+ border-left: 1px solid var(--error-border-color);
635
+ display: flex;
636
+ justify-content: space-between;
637
+ align-items: center;
638
+ gap: var(--spacing-xl);
639
+ }
640
+
641
+ .minimal {
642
+ pointer-events: none;
643
+ }
644
+
645
+ .minimal .progress-text {
646
+ background: var(--block-background-fill);
647
+ }
648
+
649
+ .border {
650
+ border: 1px solid var(--border-color-primary);
651
+ }
652
+
653
+ .clear-status {
654
+ position: absolute;
655
+ display: flex;
656
+ top: var(--size-2);
657
+ right: var(--size-2);
658
+ justify-content: flex-end;
659
+ gap: var(--spacing-sm);
660
+ z-index: var(--layer-1);
661
+ }
662
+
663
+ .cache-indicator {
664
+ position: absolute;
665
+ bottom: 0;
666
+ right: 0;
667
+ z-index: var(--layer-2);
668
+ padding: var(--size-1) var(--size-2);
669
+ font-size: var(--text-sm);
670
+ font-family: var(--font-mono);
671
+ pointer-events: none;
672
+ background: var(--block-background-fill);
673
+ opacity: 1;
674
+ transition: opacity 0.5s ease-out;
675
+ }
676
+
677
+ .cache-indicator.fade-out {
678
+ opacity: 0;
679
+ }
680
+ </style>
6.16.0/statustracker/static/index.ts ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
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 {
6
+ ILoadingStatus,
7
+ LoadingStatusArgs,
8
+ GroupedToastMessage,
9
+ ToastMessage
10
+ } from "./types";
11
+ export { default } from "./index.svelte";
6.16.0/statustracker/static/state.svelte.ts ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { ILoadingStatus, LoadingStatusArgs } from "./types.js";
2
+
3
+ export class LoadingStatus {
4
+ current: Record<string, ILoadingStatus> = {};
5
+ fn_outputs: Record<number, number[]> = {};
6
+ fn_inputs: Record<number, number[]> = {};
7
+ pending_outputs = new Map<number, number>();
8
+ fn_status: Record<number, ILoadingStatus["status"]> = {};
9
+ show_progress: Record<number, "full" | "minimal" | "hidden"> = {};
10
+ cache_event_id = 0;
11
+
12
+ register(
13
+ dependency_id: number,
14
+ outputs: number[],
15
+ inputs: number[],
16
+ show_progress: "full" | "minimal" | "hidden"
17
+ ): void {
18
+ this.fn_outputs[dependency_id] = outputs;
19
+ this.fn_inputs[dependency_id] = inputs;
20
+ this.show_progress[dependency_id] = show_progress;
21
+ }
22
+
23
+ clear(id: number): void {
24
+ if (id in this.current) {
25
+ //@ts-ignore
26
+ this.current[id] = {};
27
+ }
28
+ }
29
+
30
+ update(args: LoadingStatusArgs): void {
31
+ for (const [id, current] of Object.entries(this.current)) {
32
+ if (current.fn_index !== args.fn_index) {
33
+ this.current[id] = {
34
+ ...current,
35
+ used_cache: null,
36
+ cache_duration: null,
37
+ avg_time: null,
38
+ cache_event_id: null
39
+ };
40
+ }
41
+ }
42
+
43
+ const cache_event_id = args.used_cache ? ++this.cache_event_id : null;
44
+ const updates = this.resolve_args(args);
45
+
46
+ updates.forEach(
47
+ ({
48
+ id,
49
+ queue_position,
50
+ queue_size,
51
+ eta,
52
+ status,
53
+ message,
54
+ progress,
55
+ stream_state,
56
+ time_limit,
57
+ type,
58
+ used_cache,
59
+ cache_duration,
60
+ avg_time
61
+ }) => {
62
+ this.current[id] = {
63
+ queue: args.queue || false,
64
+ queue_size: queue_size,
65
+ queue_position: queue_position,
66
+ eta: eta,
67
+ component_id: Number(id),
68
+ stream_state: stream_state,
69
+ message: message,
70
+ progress: progress || undefined,
71
+ status,
72
+ fn_index: args.fn_index,
73
+ time_limit,
74
+ type,
75
+ show_progress: this.show_progress[args.fn_index],
76
+ used_cache,
77
+ cache_duration,
78
+ avg_time,
79
+ cache_event_id
80
+ };
81
+ }
82
+ );
83
+ }
84
+
85
+ set_status(id: number, status: ILoadingStatus["status"]): void {
86
+ this.current[id].status = status;
87
+ }
88
+
89
+ resolve_args(args: LoadingStatusArgs) {
90
+ const {
91
+ fn_index,
92
+ status,
93
+ size = undefined,
94
+ position = null,
95
+ eta = null,
96
+ message = null,
97
+ stream_state = null,
98
+ time_limit = null,
99
+ progress_data = null,
100
+ used_cache = null,
101
+ cache_duration = null,
102
+ avg_time = null
103
+ } = args;
104
+
105
+ const outputs = this.fn_outputs[fn_index];
106
+ const last_status = this.fn_status[fn_index];
107
+ const inputs = this.fn_inputs[fn_index];
108
+
109
+ const all_ids = outputs.concat(inputs);
110
+
111
+ // from (pending -> error) | complete - decrement pending count
112
+ return all_ids
113
+ .map((id) => {
114
+ let new_status: ILoadingStatus["status"];
115
+
116
+ const pending_count = this.pending_outputs.get(id) || 0;
117
+
118
+ // from (pending -> error) | complete - decrement pending count
119
+ if (last_status === "pending" && status !== "pending") {
120
+ let new_count = pending_count - 1;
121
+
122
+ this.pending_outputs.set(id, new_count < 0 ? 0 : new_count);
123
+
124
+ new_status = new_count > 0 ? "pending" : status;
125
+
126
+ // from pending -> pending - do nothing
127
+ } else if (last_status === "pending" && status === "pending") {
128
+ new_status = "pending";
129
+
130
+ // (error | complete) -> pending - - increment pending count
131
+ } else if (last_status !== "pending" && status === "pending") {
132
+ new_status = "pending";
133
+ this.pending_outputs.set(id, pending_count + 1);
134
+ } else {
135
+ new_status = status;
136
+ }
137
+
138
+ // We update the status tracker only for input components of streaming events
139
+ // or for outputs of the dependency
140
+ const type = (
141
+ inputs.includes(id) && stream_state
142
+ ? "input"
143
+ : outputs.includes(id)
144
+ ? "output"
145
+ : "skip"
146
+ ) as "input" | "output" | "skip";
147
+
148
+ return {
149
+ id,
150
+ queue_position: position,
151
+ queue_size: size,
152
+ eta: eta,
153
+ status: new_status,
154
+ message: message,
155
+ progress: progress_data,
156
+ stream_state: stream_state,
157
+ time_limit,
158
+ type: type,
159
+ used_cache,
160
+ cache_duration,
161
+ avg_time
162
+ };
163
+ })
164
+ .filter((update) => update.type !== "skip");
165
+ }
166
+ }
6.16.0/statustracker/static/types.ts ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export interface ILoadingStatus {
2
+ eta: number | null;
3
+ status: "pending" | "error" | "complete" | "generating" | "streaming";
4
+ queue: boolean;
5
+ queue_position: number | null;
6
+ queue_size?: number;
7
+ component_id?: number;
8
+ fn_index: number;
9
+ message?: string | null;
10
+ scroll_to_output?: boolean;
11
+ show_progress?: "full" | "minimal" | "hidden";
12
+ time_limit?: number | null | undefined;
13
+ progress?: {
14
+ progress: number | null;
15
+ index: number | null;
16
+ length: number | null;
17
+ unit: string | null;
18
+ desc: string | null;
19
+ }[];
20
+ validation_error?: string | null;
21
+ type: "input" | "output";
22
+ stream_state: "open" | "closed" | "waiting" | null;
23
+ used_cache?: "full" | "partial" | null;
24
+ cache_duration?: number | null;
25
+ avg_time?: number | null;
26
+ cache_event_id?: number | null;
27
+ }
28
+
29
+ export interface LoadingStatusArgs {
30
+ fn_index: ILoadingStatus["fn_index"];
31
+ status: ILoadingStatus["status"];
32
+ queue?: ILoadingStatus["queue"];
33
+ size?: ILoadingStatus["queue_size"];
34
+ position?: ILoadingStatus["queue_position"];
35
+ eta?: ILoadingStatus["eta"];
36
+ message?: ILoadingStatus["message"];
37
+ progress_data?: ILoadingStatus["progress"];
38
+ time_limit?: ILoadingStatus["time_limit"];
39
+ type?: "input" | "output";
40
+ stream_state: "open" | "closed" | "waiting" | null;
41
+ validation_error?: string;
42
+ show_validation_error?: boolean;
43
+ used_cache?: "full" | "partial" | null;
44
+ cache_duration?: number | null;
45
+ avg_time?: number | null;
46
+ }
47
+
48
+ export interface ToastMessage {
49
+ type: "error" | "warning" | "info" | "success";
50
+ title: string;
51
+ message: string;
52
+ id: number;
53
+ duration: number | null;
54
+ visible: boolean;
55
+ }
56
+
57
+ export interface GroupedToastMessage {
58
+ type: "error" | "warning" | "info" | "success";
59
+ messages: ToastMessage[];
60
+ expanded: boolean;
61
+ }
6.16.0/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
+ }