gradio-pr-bot commited on
Commit
8404e8a
·
verified ·
1 Parent(s): d6f6ac0

Upload folder using huggingface_hub

Browse files
6.6.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.6.0/statustracker/package.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/statustracker",
3
+ "version": "0.12.4",
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.6.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.6.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.6.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.6.0/statustracker/static/ToastContent.svelte ADDED
@@ -0,0 +1,389 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ let count = $derived(messages.length);
30
+ let first_message = $derived(messages[0]);
31
+ let type_label = $derived(type.charAt(0).toUpperCase() + type.slice(1));
32
+ let has_duration = $derived(first_message?.duration !== null);
33
+ let timer_duration = $derived(
34
+ has_duration ? `${first_message.duration}s` : "0s"
35
+ );
36
+
37
+ function handle_toggle(): void {
38
+ ontoggle?.();
39
+ }
40
+
41
+ function close_all(): void {
42
+ messages.forEach((msg) => {
43
+ onclose?.(msg.id);
44
+ });
45
+ }
46
+
47
+ function handle_touch_start(e: TouchEvent): void {
48
+ touch_start_x = e.touches[0].clientX;
49
+ touch_start_y = e.touches[0].clientY;
50
+ is_dragging = true;
51
+ }
52
+
53
+ function handle_touch_move(e: TouchEvent): void {
54
+ if (!is_dragging) return;
55
+
56
+ const touch_x = e.touches[0].clientX;
57
+ const touch_y = e.touches[0].clientY;
58
+ const delta_x = touch_x - touch_start_x;
59
+ const delta_y = touch_y - touch_start_y;
60
+
61
+ if (Math.abs(delta_x) > Math.abs(delta_y) && Math.abs(delta_x) > 10) {
62
+ e.preventDefault();
63
+ offset_x = delta_x;
64
+ }
65
+ }
66
+
67
+ function handle_touch_end(): void {
68
+ if (!is_dragging) return;
69
+
70
+ if (Math.abs(offset_x) > 100) {
71
+ close_all();
72
+ } else {
73
+ offset_x = 0;
74
+ }
75
+
76
+ is_dragging = false;
77
+ }
78
+
79
+ $effect(() => {
80
+ if (has_duration && messages.length === 1) {
81
+ setTimeout(close_all, first_message.duration! * 1000);
82
+ }
83
+ });
84
+ </script>
85
+
86
+ <div
87
+ bind:this={toast_element}
88
+ class="toast-body {type}"
89
+ role="status"
90
+ aria-live="polite"
91
+ data-testid="toast-body"
92
+ ontouchstart={handle_touch_start}
93
+ ontouchmove={handle_touch_move}
94
+ ontouchend={handle_touch_end}
95
+ in:fade={{ duration: 200, delay: 100 }}
96
+ out:fade={{ duration: 200 }}
97
+ style="transform: translateX({offset_x}px); opacity: {1 -
98
+ Math.abs(offset_x) / 300};"
99
+ >
100
+ <div
101
+ class="toast-header"
102
+ onclick={handle_toggle}
103
+ role="button"
104
+ tabindex="0"
105
+ onkeydown={(e) => {
106
+ if (e.key === "Enter" || e.key === " ") {
107
+ handle_toggle();
108
+ }
109
+ }}
110
+ >
111
+ <div class="toast-icon {type}">
112
+ {#if type === "warning"}
113
+ <Warning />
114
+ {:else if type === "info"}
115
+ <Info />
116
+ {:else if type === "success"}
117
+ <Success />
118
+ {:else if type === "error"}
119
+ <Error />
120
+ {/if}
121
+ </div>
122
+
123
+ <div class="toast-title-row">
124
+ <span class="toast-title {type}">
125
+ {type_label}
126
+ {#if count > 1}
127
+ <span class="toast-count">({count})</span>
128
+ {/if}
129
+ </span>
130
+ <div class="chevron" class:expanded class:visible={count > 0}>
131
+ <ChevronDown />
132
+ </div>
133
+ </div>
134
+
135
+ <button
136
+ onclick={(e) => {
137
+ e.stopPropagation();
138
+ close_all();
139
+ }}
140
+ class="toast-close {type}"
141
+ type="button"
142
+ aria-label="Close"
143
+ data-testid="toast-close"
144
+ >
145
+ <span aria-hidden="true">&#215;</span>
146
+ </button>
147
+ </div>
148
+
149
+ {#if expanded}
150
+ <div class="toast-messages" transition:slide={{ duration: 200 }}>
151
+ {#each messages as message, i (message.id)}
152
+ <div class="toast-message-item {type}">
153
+ <div class="toast-message-text {type}" data-testid="toast-text">
154
+ {@html sanitize(message.message)}
155
+ </div>
156
+ </div>
157
+ {#if i < messages.length - 1}
158
+ <div class="toast-separator" />
159
+ {/if}
160
+ {/each}
161
+ </div>
162
+ {/if}
163
+
164
+ {#if has_duration}
165
+ <div class="timer {type}" style="animation-duration: {timer_duration}" />
166
+ {/if}
167
+ </div>
168
+
169
+ <!-- s-csdrBJqpTpqa -->
170
+ <style>
171
+ .toast-body {
172
+ display: flex;
173
+ flex-direction: column;
174
+ position: relative;
175
+ right: 0;
176
+ left: 0;
177
+ margin: auto;
178
+ border-radius: var(--radius-sm);
179
+ overflow: hidden;
180
+ pointer-events: auto;
181
+ background: var(--background-fill-secondary);
182
+ border: 1px solid var(--border-color-primary);
183
+ box-shadow: var(--shadow-drop);
184
+ touch-action: pan-y;
185
+ user-select: none;
186
+ }
187
+
188
+ :global(.dark) .toast-body {
189
+ background: var(--background-fill-primary);
190
+ }
191
+
192
+ .toast-body.error {
193
+ --toast-color: var(--color-red-700);
194
+ }
195
+
196
+ .toast-body.warning {
197
+ --toast-color: var(--color-yellow-700);
198
+ }
199
+
200
+ .toast-body.info {
201
+ --toast-color: var(--color-grey-700);
202
+ }
203
+
204
+ .toast-body.success {
205
+ --toast-color: var(--color-green-700);
206
+ }
207
+
208
+ :global(.dark) .toast-body.error {
209
+ --toast-color: var(--color-red-500);
210
+ }
211
+
212
+ :global(.dark) .toast-body.warning {
213
+ --toast-color: var(--color-yellow-500);
214
+ }
215
+
216
+ :global(.dark) .toast-body.info {
217
+ --toast-color: var(--color-grey-500);
218
+ }
219
+
220
+ :global(.dark) .toast-body.success {
221
+ --toast-color: var(--color-green-500);
222
+ }
223
+
224
+ .toast-header {
225
+ display: flex;
226
+ align-items: center;
227
+ padding: var(--size-3) var(--size-3);
228
+ cursor: pointer;
229
+ }
230
+
231
+ .toast-header:hover {
232
+ opacity: 0.9;
233
+ }
234
+
235
+ .toast-title-row {
236
+ flex: 1;
237
+ display: flex;
238
+ align-items: center;
239
+ gap: var(--size-2);
240
+ }
241
+
242
+ .chevron {
243
+ display: flex;
244
+ align-items: center;
245
+ width: var(--size-4);
246
+ height: var(--size-4);
247
+ transition: transform 0.2s ease;
248
+ opacity: 0.6;
249
+ }
250
+
251
+ .chevron.visible {
252
+ opacity: 1;
253
+ }
254
+
255
+ .chevron.expanded {
256
+ transform: rotate(180deg);
257
+ }
258
+
259
+ .toast-title {
260
+ display: flex;
261
+ align-items: center;
262
+ font-weight: var(--weight-bold);
263
+ font-size: var(--text-lg);
264
+ line-height: var(--line-sm);
265
+ }
266
+
267
+ .toast-count {
268
+ margin-left: var(--size-1);
269
+ font-weight: var(--weight-semibold);
270
+ }
271
+
272
+ .toast-close {
273
+ margin: 0 var(--size-1);
274
+ border-radius: var(--radius-lg);
275
+ padding: var(--size-1);
276
+ font-size: var(--text-xl);
277
+ line-height: 1;
278
+ background: transparent;
279
+ border: none;
280
+ cursor: pointer;
281
+ transition: all 0.2s ease;
282
+ display: flex;
283
+ align-items: center;
284
+ justify-content: center;
285
+ width: var(--size-7);
286
+ height: var(--size-7);
287
+ opacity: 0.6;
288
+ flex-shrink: 0;
289
+ }
290
+
291
+ .toast-close:hover {
292
+ opacity: 1;
293
+ transform: scale(1.1);
294
+ }
295
+
296
+ .toast-close:active {
297
+ transform: scale(0.95);
298
+ }
299
+
300
+ .toast-close {
301
+ color: var(--body-text-color);
302
+ }
303
+
304
+ .toast-icon {
305
+ display: flex;
306
+ position: relative;
307
+ flex-shrink: 0;
308
+ justify-content: center;
309
+ align-items: center;
310
+ margin-right: var(--size-2);
311
+ border-radius: var(--radius-full);
312
+ padding: var(--size-1-5);
313
+ width: var(--size-8);
314
+ height: var(--size-8);
315
+ }
316
+
317
+ .toast-icon {
318
+ color: var(--toast-color);
319
+ }
320
+
321
+ .toast-messages {
322
+ display: flex;
323
+ flex-direction: column;
324
+ gap: var(--size-2);
325
+ padding: 0 var(--size-3) var(--size-2) var(--size-3);
326
+ }
327
+
328
+ .toast-message-item {
329
+ padding: var(--size-1-5) var(--size-1-5) var(--size-1-5) var(--size-1-5);
330
+ border-radius: var(--radius-lg);
331
+ }
332
+
333
+ .toast-separator {
334
+ height: 1px;
335
+ background: var(--border-color-primary);
336
+ margin: 0;
337
+ }
338
+
339
+ .toast-message-text {
340
+ font-size: var(--text-md);
341
+ line-height: 1.5;
342
+ word-wrap: break-word;
343
+ overflow-wrap: break-word;
344
+ word-break: break-word;
345
+ color: var(--body-text-color);
346
+ }
347
+
348
+ .toast-message-text :global(a) {
349
+ text-decoration: underline;
350
+ }
351
+
352
+ @keyframes countdown {
353
+ from {
354
+ transform: scaleX(1);
355
+ }
356
+ to {
357
+ transform: scaleX(0);
358
+ }
359
+ }
360
+
361
+ .timer {
362
+ position: absolute;
363
+ bottom: 0;
364
+ left: 0;
365
+ transform-origin: 0 0;
366
+ animation: countdown 10s linear forwards;
367
+ width: 100%;
368
+ height: var(--size-1);
369
+ }
370
+
371
+ .timer {
372
+ background: var(--toast-color);
373
+ }
374
+
375
+ @media (max-width: 640px) {
376
+ .toast-header {
377
+ padding: var(--size-2) var(--size-2);
378
+ }
379
+
380
+ .toast-messages {
381
+ gap: var(--size-1);
382
+ padding: 0 var(--size-2) var(--size-1-5) var(--size-2);
383
+ }
384
+
385
+ .toast-message-item {
386
+ padding: 0 var(--size-1) var(--size-1) var(--size-1);
387
+ }
388
+ }
389
+ </style>
6.6.0/statustracker/static/index.svelte ADDED
@@ -0,0 +1,576 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
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 Loader from "./Loader.svelte";
54
+ import type { LoadingStatus } from "./types";
55
+ import type { I18nFormatter } from "@gradio/utils";
56
+
57
+ import { IconButton } from "@gradio/atoms";
58
+ import { Clear } from "@gradio/icons";
59
+
60
+ interface Props {
61
+ i18n: I18nFormatter;
62
+ eta?: number | null;
63
+ queue_position: number | null;
64
+ queue_size: number | null;
65
+ status:
66
+ | "complete"
67
+ | "pending"
68
+ | "error"
69
+ | "generating"
70
+ | "streaming"
71
+ | null;
72
+ scroll_to_output?: boolean;
73
+ timer?: boolean;
74
+ show_progress?: "full" | "minimal" | "hidden";
75
+ message?: string | null;
76
+ progress?: LoadingStatus["progress"] | null | undefined;
77
+ variant?: "default" | "center";
78
+ loading_text?: string;
79
+ absolute?: boolean;
80
+ translucent?: boolean;
81
+ border?: boolean;
82
+ autoscroll: boolean;
83
+ validation_error?: string | null;
84
+ show_validation_error?: boolean;
85
+ type?: "input" | "output" | null;
86
+ on_clear_status?: () => void;
87
+ }
88
+
89
+ interface ProgressLevel {
90
+ progress_level: (number | undefined)[] | null;
91
+ last_progress_level: number | undefined;
92
+ progress_bar_transition: string;
93
+ }
94
+
95
+ let {
96
+ i18n,
97
+ eta = null,
98
+ queue_position,
99
+ queue_size,
100
+ status,
101
+ scroll_to_output = false,
102
+ timer = true,
103
+ show_progress = "full",
104
+ message = null,
105
+ progress = null,
106
+ variant = "default",
107
+ loading_text = "Loading...",
108
+ absolute = true,
109
+ translucent = false,
110
+ border = false,
111
+ autoscroll,
112
+ validation_error = null,
113
+ show_validation_error = true,
114
+ type = null,
115
+ on_clear_status
116
+ }: Props = $props();
117
+
118
+ let el: HTMLDivElement;
119
+
120
+ let _timer = false;
121
+ let timer_start = $state(0);
122
+ let old_eta = $state<number | null>(null);
123
+ let eta_from_start = $state<number | null>(null);
124
+ let message_visible = $state(false);
125
+ let formatted_eta = $state<string | null>(null);
126
+ let show_message_timeout = $state<NodeJS.Timeout | null>(null);
127
+
128
+ const should_hide = $derived(
129
+ type === "input" ||
130
+ !status ||
131
+ status === "complete" ||
132
+ show_progress === "hidden" ||
133
+ status == "streaming" ||
134
+ !!(show_validation_error && validation_error)
135
+ );
136
+
137
+ let timer_diff = $state(0);
138
+
139
+ const eta_level = $derived(
140
+ eta_from_start === null || eta_from_start <= 0 || !timer_diff
141
+ ? 0
142
+ : Math.min(timer_diff / eta_from_start, 1)
143
+ );
144
+
145
+ const formatted_timer = $derived(timer_diff.toFixed(1));
146
+
147
+ let show_eta_bar = $derived(progress != null ? false : true);
148
+
149
+ function run(): void {
150
+ raf(() => {
151
+ timer_diff = (performance.now() - timer_start) / 1000;
152
+ if (_timer) run();
153
+ });
154
+ }
155
+
156
+ let progress_level = $derived.by<ProgressLevel>(() => {
157
+ let _progress_level: (number | undefined)[] | null = null;
158
+ if (progress != null) {
159
+ _progress_level = progress.map((p) => {
160
+ if (p.index != null && p.length != null) {
161
+ return p.index / p.length;
162
+ } else if (p.progress != null) {
163
+ return p.progress;
164
+ }
165
+ return undefined;
166
+ });
167
+ } else {
168
+ _progress_level = null;
169
+ }
170
+
171
+ let _last_progress_level: number | undefined;
172
+ let transition = "";
173
+ if (_progress_level) {
174
+ _last_progress_level = _progress_level[_progress_level.length - 1];
175
+
176
+ if (_last_progress_level === 0) {
177
+ transition = "0";
178
+ } else {
179
+ transition = "150ms";
180
+ }
181
+ } else {
182
+ _last_progress_level = undefined;
183
+ }
184
+
185
+ return {
186
+ progress_level: _progress_level,
187
+ last_progress_level: _last_progress_level,
188
+ progress_bar_transition: transition
189
+ };
190
+ });
191
+
192
+ function start_timer(): void {
193
+ if (_timer) return;
194
+
195
+ old_eta = formatted_eta = null;
196
+ timer_start = performance.now();
197
+
198
+ _timer = true;
199
+ run();
200
+ }
201
+
202
+ function stop_timer(): void {
203
+ old_eta = formatted_eta = null;
204
+ if (!_timer) return;
205
+ _timer = false;
206
+ }
207
+
208
+ $effect(() => {
209
+ if (status === "pending") {
210
+ start_timer();
211
+ } else {
212
+ untrack(() => {
213
+ stop_timer();
214
+ });
215
+ }
216
+ });
217
+
218
+ $effect(() => {
219
+ if (
220
+ el &&
221
+ scroll_to_output &&
222
+ (status === "pending" || status === "complete")
223
+ ) {
224
+ scroll_into_view(el, autoscroll);
225
+ }
226
+ });
227
+
228
+ $effect(() => {
229
+ if (eta === null) {
230
+ eta = old_eta;
231
+ }
232
+ if (eta != null && old_eta !== eta) {
233
+ eta_from_start = (performance.now() - timer_start) / 1000 + eta;
234
+ formatted_eta = eta_from_start.toFixed(1);
235
+ old_eta = eta;
236
+ }
237
+ });
238
+
239
+ function close_message(): void {
240
+ message_visible = false;
241
+ if (show_message_timeout !== null) {
242
+ clearTimeout(show_message_timeout);
243
+ }
244
+ }
245
+
246
+ $effect(() => {
247
+ untrack(() => {
248
+ close_message();
249
+ });
250
+
251
+ if (status === "error" && message) {
252
+ message_visible = true;
253
+ }
254
+ });
255
+ </script>
256
+
257
+ <div
258
+ class="wrap {variant} {show_progress}"
259
+ class:no-click={validation_error && show_validation_error}
260
+ class:hide={should_hide}
261
+ class:translucent={(variant === "center" &&
262
+ (status === "pending" || status === "error")) ||
263
+ translucent ||
264
+ show_progress === "minimal" ||
265
+ validation_error}
266
+ class:generating={status === "generating" && show_progress === "full"}
267
+ class:border
268
+ style:position={absolute ? "absolute" : "static"}
269
+ style:padding={absolute ? "0" : "var(--size-8) 0"}
270
+ data-testid="status-tracker"
271
+ bind:this={el}
272
+ >
273
+ {#if validation_error && show_validation_error}
274
+ <div class="validation-error">
275
+ {validation_error}
276
+ <button
277
+ ><IconButton
278
+ Icon={Clear}
279
+ label={i18n ? i18n("common.clear") : "Clear"}
280
+ disabled={false}
281
+ size="x-small"
282
+ background="var(--background-fill-primary)"
283
+ color="var(--error-background-text)"
284
+ border="var(--border-color-primary)"
285
+ onclick={() => (validation_error = null)}
286
+ /></button
287
+ >
288
+ </div>
289
+ {/if}
290
+ {#if status === "pending"}
291
+ {#if variant === "default" && show_eta_bar && show_progress === "full"}
292
+ <div
293
+ class="eta-bar"
294
+ style:transform="translateX({(eta_level || 0) * 100 - 100}%)"
295
+ />
296
+ {/if}
297
+ <div
298
+ class:meta-text-center={variant === "center"}
299
+ class:meta-text={variant === "default"}
300
+ class="progress-text"
301
+ >
302
+ {#if progress}
303
+ {#each progress as p}
304
+ {#if p.index != null}
305
+ {#if p.length != null}
306
+ {pretty_si(p.index || 0)}/{pretty_si(p.length)}
307
+ {:else}
308
+ {pretty_si(p.index || 0)}
309
+ {/if}
310
+ {p.unit} | {" "}
311
+ {/if}
312
+ {/each}
313
+ {:else if queue_position !== null && queue_size !== undefined && queue_position >= 0}
314
+ queue: {queue_position + 1}/{queue_size} |
315
+ {:else if queue_position === 0}
316
+ processing |
317
+ {/if}
318
+
319
+ {#if timer}
320
+ {formatted_timer}{eta ? `/${formatted_eta}` : ""}s
321
+ {/if}
322
+ </div>
323
+
324
+ {#if progress_level.last_progress_level != null}
325
+ <div class="progress-level">
326
+ <div class="progress-level-inner">
327
+ {#if progress != null}
328
+ {#each progress as p, i}
329
+ {#if p.desc != null || (progress_level.progress_level && progress_level.progress_level[i] != null)}
330
+ {#if i !== 0}
331
+ &nbsp;/
332
+ {/if}
333
+ {#if p.desc != null}
334
+ {p.desc}
335
+ {/if}
336
+ {#if p.desc != null && progress_level.progress_level && progress_level.progress_level[i] != null}
337
+ -
338
+ {/if}
339
+ {#if progress_level.progress_level != null}
340
+ {(100 * (progress_level.progress_level[i] || 0)).toFixed(1)}%
341
+ {/if}
342
+ {/if}
343
+ {/each}
344
+ {/if}
345
+ </div>
346
+
347
+ <div class="progress-bar-wrap">
348
+ <div
349
+ class="progress-bar"
350
+ style:width="{progress_level.last_progress_level * 100}%"
351
+ style:transition={progress_level.progress_bar_transition}
352
+ />
353
+ </div>
354
+ </div>
355
+ {:else if show_progress === "full"}
356
+ <Loader margin={variant === "default"} />
357
+ {/if}
358
+
359
+ {#if !timer}
360
+ <p class="loading">{loading_text}</p>
361
+ <slot name="additional-loading-text" />
362
+ {/if}
363
+ {:else if status === "error"}
364
+ <div class="clear-status">
365
+ <IconButton
366
+ Icon={Clear}
367
+ label={i18n("common.clear")}
368
+ disabled={false}
369
+ on:click={() => {
370
+ on_clear_status?.();
371
+ }}
372
+ />
373
+ </div>
374
+ <span class="error">{i18n("common.error")}</span>
375
+ <slot name="error" />
376
+ {/if}
377
+ </div>
378
+
379
+ <style>
380
+ .wrap {
381
+ display: flex;
382
+ flex-direction: column;
383
+ justify-content: center;
384
+ align-items: center;
385
+ z-index: var(--layer-3);
386
+ transition: opacity 0.1s ease-in-out;
387
+ border-radius: var(--block-radius);
388
+ background: var(--block-background-fill);
389
+ padding: 0 var(--size-6);
390
+ overflow: hidden;
391
+ }
392
+ .no-click {
393
+ pointer-events: none;
394
+ }
395
+
396
+ .wrap.center {
397
+ top: 0;
398
+ right: 0px;
399
+ left: 0px;
400
+ }
401
+
402
+ .wrap.default {
403
+ top: 0px;
404
+ right: 0px;
405
+ bottom: 0px;
406
+ left: 0px;
407
+ }
408
+
409
+ .hide {
410
+ opacity: 0;
411
+ pointer-events: none;
412
+ }
413
+
414
+ .generating {
415
+ animation:
416
+ pulseStart 1s cubic-bezier(0.4, 0, 0.6, 1),
417
+ pulse 2s cubic-bezier(0.4, 0, 0.6, 1) 1s infinite;
418
+ border: 2px solid var(--color-accent);
419
+ background: transparent;
420
+ z-index: var(--layer-1);
421
+ pointer-events: none;
422
+ }
423
+
424
+ .translucent {
425
+ background: none;
426
+ }
427
+
428
+ @keyframes pulseStart {
429
+ 0% {
430
+ opacity: 0;
431
+ }
432
+ 100% {
433
+ opacity: 1;
434
+ }
435
+ }
436
+
437
+ @keyframes pulse {
438
+ 0%,
439
+ 100% {
440
+ opacity: 1;
441
+ }
442
+ 50% {
443
+ opacity: 0.5;
444
+ }
445
+ }
446
+
447
+ .loading {
448
+ z-index: var(--layer-2);
449
+ color: var(--body-text-color);
450
+ }
451
+ .eta-bar {
452
+ position: absolute;
453
+ top: 0;
454
+ right: 0;
455
+ bottom: 0;
456
+ left: 0;
457
+ transform-origin: left;
458
+ opacity: 0.8;
459
+ z-index: var(--layer-1);
460
+ transition: 10ms;
461
+ background: var(--background-fill-secondary);
462
+ }
463
+ .progress-bar-wrap {
464
+ border: 1px solid var(--border-color-primary);
465
+ background: var(--background-fill-primary);
466
+ width: 55.5%;
467
+ height: var(--size-4);
468
+ }
469
+ .progress-bar {
470
+ transform-origin: left;
471
+ background-color: var(--loader-color);
472
+ width: var(--size-full);
473
+ height: var(--size-full);
474
+ }
475
+
476
+ .progress-level {
477
+ display: flex;
478
+ flex-direction: column;
479
+ align-items: center;
480
+ gap: 1;
481
+ z-index: var(--layer-2);
482
+ width: var(--size-full);
483
+ }
484
+
485
+ .progress-level-inner {
486
+ margin: var(--size-2) auto;
487
+ color: var(--body-text-color);
488
+ font-size: var(--text-sm);
489
+ font-family: var(--font-mono);
490
+ }
491
+
492
+ .meta-text {
493
+ position: absolute;
494
+ bottom: 0;
495
+ right: 0;
496
+ z-index: var(--layer-2);
497
+ padding: var(--size-1) var(--size-2);
498
+ font-size: var(--text-sm);
499
+ font-family: var(--font-mono);
500
+ }
501
+
502
+ .meta-text-center {
503
+ display: flex;
504
+ position: absolute;
505
+ top: 0;
506
+ right: 0;
507
+ justify-content: center;
508
+ align-items: center;
509
+ transform: translateY(var(--size-6));
510
+ z-index: var(--layer-2);
511
+ padding: var(--size-1) var(--size-2);
512
+ font-size: var(--text-sm);
513
+ font-family: var(--font-mono);
514
+ text-align: center;
515
+ }
516
+
517
+ .error {
518
+ box-shadow: var(--shadow-drop);
519
+ border: solid 1px var(--error-border-color);
520
+ border-radius: var(--radius-full);
521
+ background: var(--error-background-fill);
522
+ padding-right: var(--size-4);
523
+ padding-left: var(--size-4);
524
+ color: var(--error-text-color);
525
+ font-weight: var(--weight-semibold);
526
+ font-size: var(--text-lg);
527
+ line-height: var(--line-lg);
528
+ font-family: var(--font);
529
+ }
530
+
531
+ .validation-error {
532
+ pointer-events: auto;
533
+ color: var(--error-text-color);
534
+ font-weight: var(--weight-semibold);
535
+ font-size: var(--text-lg);
536
+ line-height: var(--line-lg);
537
+ font-family: var(--font);
538
+ position: absolute;
539
+ background: var(--error-background-fill);
540
+ top: 0;
541
+ right: 0;
542
+ z-index: var(--layer-3);
543
+ padding: var(--size-1) var(--size-2);
544
+ font-size: var(--text-md);
545
+ text-align: center;
546
+ border-bottom-left-radius: var(--radius-sm);
547
+ border-bottom: 1px solid var(--error-border-color);
548
+ border-left: 1px solid var(--error-border-color);
549
+ display: flex;
550
+ justify-content: space-between;
551
+ align-items: center;
552
+ gap: var(--spacing-xl);
553
+ }
554
+
555
+ .minimal {
556
+ pointer-events: none;
557
+ }
558
+
559
+ .minimal .progress-text {
560
+ background: var(--block-background-fill);
561
+ }
562
+
563
+ .border {
564
+ border: 1px solid var(--border-color-primary);
565
+ }
566
+
567
+ .clear-status {
568
+ position: absolute;
569
+ display: flex;
570
+ top: var(--size-2);
571
+ right: var(--size-2);
572
+ justify-content: flex-end;
573
+ gap: var(--spacing-sm);
574
+ z-index: var(--layer-1);
575
+ }
576
+ </style>
6.6.0/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";
6.6.0/statustracker/static/state.svelte.ts ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
11
+ register(
12
+ dependency_id: number,
13
+ outputs: number[],
14
+ inputs: number[],
15
+ show_progress: "full" | "minimal" | "hidden"
16
+ ): void {
17
+ this.fn_outputs[dependency_id] = outputs;
18
+ this.fn_inputs[dependency_id] = inputs;
19
+ this.show_progress[dependency_id] = show_progress;
20
+ }
21
+
22
+ clear(id: number): void {
23
+ if (id in this.current) {
24
+ //@ts-ignore
25
+ this.current[id] = {};
26
+ }
27
+ }
28
+
29
+ update(args: LoadingStatusArgs): void {
30
+ const updates = this.resolve_args(args);
31
+
32
+ updates.forEach(
33
+ ({
34
+ id,
35
+ queue_position,
36
+ queue_size,
37
+ eta,
38
+ status,
39
+ message,
40
+ progress,
41
+ stream_state,
42
+ time_limit,
43
+ type
44
+ }) => {
45
+ this.current[id] = {
46
+ queue: args.queue || false,
47
+ queue_size: queue_size,
48
+ queue_position: queue_position,
49
+ eta: eta,
50
+ stream_state: stream_state,
51
+ message: message,
52
+ progress: progress || undefined,
53
+ status,
54
+ fn_index: args.fn_index,
55
+ time_limit,
56
+ type,
57
+ show_progress: this.show_progress[args.fn_index]
58
+ };
59
+ }
60
+ );
61
+ }
62
+
63
+ set_status(id: number, status: ILoadingStatus["status"]): void {
64
+ this.current[id].status = status;
65
+ }
66
+
67
+ resolve_args(args: LoadingStatusArgs) {
68
+ const {
69
+ fn_index,
70
+ status,
71
+ size = undefined,
72
+ position = null,
73
+ eta = null,
74
+ message = null,
75
+ stream_state = null,
76
+ time_limit = null,
77
+ progress_data = null
78
+ } = args;
79
+
80
+ const outputs = this.fn_outputs[fn_index];
81
+ const last_status = this.fn_status[fn_index];
82
+ const inputs = this.fn_inputs[fn_index];
83
+
84
+ const all_ids = outputs.concat(inputs);
85
+
86
+ // from (pending -> error) | complete - decrement pending count
87
+ return all_ids
88
+ .map((id) => {
89
+ let new_status: ILoadingStatus["status"];
90
+
91
+ const pending_count = this.pending_outputs.get(id) || 0;
92
+
93
+ // from (pending -> error) | complete - decrement pending count
94
+ if (last_status === "pending" && status !== "pending") {
95
+ let new_count = pending_count - 1;
96
+
97
+ this.pending_outputs.set(id, new_count < 0 ? 0 : new_count);
98
+
99
+ new_status = new_count > 0 ? "pending" : status;
100
+
101
+ // from pending -> pending - do nothing
102
+ } else if (last_status === "pending" && status === "pending") {
103
+ new_status = "pending";
104
+
105
+ // (error | complete) -> pending - - increment pending count
106
+ } else if (last_status !== "pending" && status === "pending") {
107
+ new_status = "pending";
108
+ this.pending_outputs.set(id, pending_count + 1);
109
+ } else {
110
+ new_status = status;
111
+ }
112
+
113
+ // We update the status tracker only for input components of streaming events
114
+ // or for outputs of the dependency
115
+ const type = (
116
+ inputs.includes(id) && stream_state
117
+ ? "input"
118
+ : outputs.includes(id)
119
+ ? "output"
120
+ : "skip"
121
+ ) as "input" | "output" | "skip";
122
+
123
+ return {
124
+ id,
125
+ queue_position: position,
126
+ queue_size: size,
127
+ eta: eta,
128
+ status: new_status,
129
+ message: message,
130
+ progress: progress_data,
131
+ stream_state: stream_state,
132
+ time_limit,
133
+ type: type
134
+ };
135
+ })
136
+ .filter((update) => update.type !== "skip");
137
+ }
138
+ }
6.6.0/statustracker/static/types.ts ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ fn_index: number;
8
+ message?: string | null;
9
+ scroll_to_output?: boolean;
10
+ show_progress?: "full" | "minimal" | "hidden";
11
+ time_limit?: number | null | undefined;
12
+ progress?: {
13
+ progress: number | null;
14
+ index: number | null;
15
+ length: number | null;
16
+ unit: string | null;
17
+ desc: string | null;
18
+ }[];
19
+ validation_error?: string | null;
20
+ type: "input" | "output";
21
+ stream_state: "open" | "closed" | "waiting" | null;
22
+ }
23
+
24
+ export interface LoadingStatusArgs {
25
+ fn_index: ILoadingStatus["fn_index"];
26
+ status: ILoadingStatus["status"];
27
+ queue?: ILoadingStatus["queue"];
28
+ size?: ILoadingStatus["queue_size"];
29
+ position?: ILoadingStatus["queue_position"];
30
+ eta?: ILoadingStatus["eta"];
31
+ message?: ILoadingStatus["message"];
32
+ progress_data?: ILoadingStatus["progress"];
33
+ time_limit?: ILoadingStatus["time_limit"];
34
+ type?: "input" | "output";
35
+ stream_state: "open" | "closed" | "waiting" | null;
36
+ validation_error?: string;
37
+ show_validation_error?: boolean;
38
+ }
39
+
40
+ export interface ToastMessage {
41
+ type: "error" | "warning" | "info" | "success";
42
+ title: string;
43
+ message: string;
44
+ id: number;
45
+ duration: number | null;
46
+ visible: boolean;
47
+ }
48
+
49
+ export interface GroupedToastMessage {
50
+ type: "error" | "warning" | "info" | "success";
51
+ messages: ToastMessage[];
52
+ expanded: boolean;
53
+ }
6.6.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
+ }