freddyaboulton HF Staff commited on
Commit
0e24121
·
verified ·
1 Parent(s): e192d6c

Upload folder using huggingface_hub

Browse files
6.0.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.0.0/statustracker/package.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/statustracker",
3
+ "version": "0.12.0",
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.43.4"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/gradio-app/gradio.git",
33
+ "directory": "js/statustracker"
34
+ }
35
+ }
6.0.0/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>
6.0.0/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>
6.0.0/statustracker/static/Toast.svelte ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ export let messages: ToastMessage[] = [];
7
+ export let on_close: (id: number) => void;
8
+ const top = spring(0, { stiffness: 0.4, damping: 0.5 });
9
+
10
+ let grouped_messages: GroupedToastMessage[] = [];
11
+
12
+ $: scroll_to_top(messages);
13
+ $: grouped_messages = group_messages(messages);
14
+
15
+ function group_messages(msgs: ToastMessage[]): GroupedToastMessage[] {
16
+ const groups = new Map<string, GroupedToastMessage>();
17
+
18
+ msgs.forEach((msg) => {
19
+ const key = msg.type;
20
+ if (!groups.has(key)) {
21
+ groups.set(key, {
22
+ type: msg.type,
23
+ messages: [],
24
+ expanded: true
25
+ });
26
+ }
27
+ groups.get(key)!.messages.push(msg);
28
+ });
29
+
30
+ return Array.from(groups.values());
31
+ }
32
+
33
+ function scroll_to_top(_messages: ToastMessage[]): void {
34
+ if (_messages.length > 0) {
35
+ if ("parentIFrame" in window) {
36
+ window.parentIFrame?.getPageInfo((page_info) => {
37
+ if (page_info.scrollTop < page_info.offsetTop) {
38
+ top.set(0);
39
+ } else {
40
+ top.set(page_info.scrollTop - page_info.offsetTop);
41
+ }
42
+ });
43
+ }
44
+ }
45
+ }
46
+
47
+ function toggle_group(type: string): void {
48
+ grouped_messages = grouped_messages.map((group) => {
49
+ if (group.type === type) {
50
+ return { ...group, expanded: !group.expanded };
51
+ }
52
+ return group;
53
+ });
54
+ }
55
+ </script>
56
+
57
+ <div class="toast-wrap" style="--toast-top: {$top}px;">
58
+ {#each grouped_messages as group (group.type)}
59
+ <div class="toast-item">
60
+ <ToastContent
61
+ type={group.type}
62
+ messages={group.messages}
63
+ expanded={group.expanded}
64
+ on:toggle={() => toggle_group(group.type)}
65
+ on:close={(e) => on_close(e.detail)}
66
+ />
67
+ </div>
68
+ {/each}
69
+ </div>
70
+
71
+ <style>
72
+ .toast-wrap {
73
+ --toast-top: var(--size-4);
74
+ display: flex;
75
+ position: fixed;
76
+ top: calc(var(--toast-top) + var(--size-3));
77
+ flex-direction: column;
78
+ gap: var(--size-2);
79
+ z-index: var(--layer-top);
80
+ right: var(--size-3);
81
+ left: var(--size-3);
82
+ align-items: end;
83
+ max-width: none;
84
+ }
85
+
86
+ .toast-item {
87
+ width: 100%;
88
+ }
89
+
90
+ @media (min-width: 640px) {
91
+ .toast-wrap {
92
+ left: auto;
93
+ width: calc(var(--size-96) + var(--size-10));
94
+ }
95
+ }
96
+ </style>
6.0.0/statustracker/static/ToastContent.svelte ADDED
@@ -0,0 +1,375 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Error, Info, Warning, Success, ChevronDown } from "@gradio/icons";
3
+ import { sanitize } from "@gradio/sanitize";
4
+ import { createEventDispatcher, onMount } from "svelte";
5
+ import { fade, slide } from "svelte/transition";
6
+ import type { ToastMessage } from "./types";
7
+
8
+ export let type: ToastMessage["type"];
9
+ export let messages: ToastMessage[] = [];
10
+ export let expanded = true;
11
+
12
+ const dispatch = createEventDispatcher();
13
+
14
+ let touch_start_x = 0;
15
+ let touch_start_y = 0;
16
+ let offset_x = 0;
17
+ let is_dragging = false;
18
+ let toast_element: HTMLElement;
19
+
20
+ $: count = messages.length;
21
+ $: first_message = messages[0];
22
+ $: type_label = type.charAt(0).toUpperCase() + type.slice(1);
23
+ $: has_duration = first_message?.duration !== null;
24
+ $: timer_duration = has_duration ? `${first_message.duration}s` : "0s";
25
+
26
+ function handle_toggle(): void {
27
+ dispatch("toggle");
28
+ }
29
+
30
+ function close_all(): void {
31
+ messages.forEach((msg) => {
32
+ dispatch("close", msg.id);
33
+ });
34
+ }
35
+
36
+ function handle_touch_start(e: TouchEvent): void {
37
+ touch_start_x = e.touches[0].clientX;
38
+ touch_start_y = e.touches[0].clientY;
39
+ is_dragging = true;
40
+ }
41
+
42
+ function handle_touch_move(e: TouchEvent): void {
43
+ if (!is_dragging) return;
44
+
45
+ const touch_x = e.touches[0].clientX;
46
+ const touch_y = e.touches[0].clientY;
47
+ const delta_x = touch_x - touch_start_x;
48
+ const delta_y = touch_y - touch_start_y;
49
+
50
+ if (Math.abs(delta_x) > Math.abs(delta_y) && Math.abs(delta_x) > 10) {
51
+ e.preventDefault();
52
+ offset_x = delta_x;
53
+ }
54
+ }
55
+
56
+ function handle_touch_end(): void {
57
+ if (!is_dragging) return;
58
+
59
+ if (Math.abs(offset_x) > 100) {
60
+ close_all();
61
+ } else {
62
+ offset_x = 0;
63
+ }
64
+
65
+ is_dragging = false;
66
+ }
67
+
68
+ onMount(() => {
69
+ if (has_duration && messages.length === 1) {
70
+ setTimeout(close_all, first_message.duration! * 1000);
71
+ }
72
+ });
73
+ </script>
74
+
75
+ <div
76
+ bind:this={toast_element}
77
+ class="toast-body {type}"
78
+ role="status"
79
+ aria-live="polite"
80
+ data-testid="toast-body"
81
+ on:touchstart={handle_touch_start}
82
+ on:touchmove={handle_touch_move}
83
+ on:touchend={handle_touch_end}
84
+ in:fade={{ duration: 200, delay: 100 }}
85
+ out:fade={{ duration: 200 }}
86
+ style="transform: translateX({offset_x}px); opacity: {1 -
87
+ Math.abs(offset_x) / 300};"
88
+ >
89
+ <div
90
+ class="toast-header"
91
+ on:click={handle_toggle}
92
+ role="button"
93
+ tabindex="0"
94
+ on:keydown={(e) => {
95
+ if (e.key === "Enter" || e.key === " ") {
96
+ handle_toggle();
97
+ }
98
+ }}
99
+ >
100
+ <div class="toast-icon {type}">
101
+ {#if type === "warning"}
102
+ <Warning />
103
+ {:else if type === "info"}
104
+ <Info />
105
+ {:else if type === "success"}
106
+ <Success />
107
+ {:else if type === "error"}
108
+ <Error />
109
+ {/if}
110
+ </div>
111
+
112
+ <div class="toast-title-row">
113
+ <span class="toast-title {type}">
114
+ {type_label}
115
+ {#if count > 1}
116
+ <span class="toast-count">({count})</span>
117
+ {/if}
118
+ </span>
119
+ <div class="chevron" class:expanded class:visible={count > 0}>
120
+ <ChevronDown />
121
+ </div>
122
+ </div>
123
+
124
+ <button
125
+ on:click|stopPropagation={close_all}
126
+ class="toast-close {type}"
127
+ type="button"
128
+ aria-label="Close"
129
+ data-testid="toast-close"
130
+ >
131
+ <span aria-hidden="true">&#215;</span>
132
+ </button>
133
+ </div>
134
+
135
+ {#if expanded}
136
+ <div class="toast-messages" transition:slide={{ duration: 200 }}>
137
+ {#each messages as message, i (message.id)}
138
+ <div class="toast-message-item {type}">
139
+ <div class="toast-message-text {type}" data-testid="toast-text">
140
+ {@html sanitize(message.message)}
141
+ </div>
142
+ </div>
143
+ {#if i < messages.length - 1}
144
+ <div class="toast-separator" />
145
+ {/if}
146
+ {/each}
147
+ </div>
148
+ {/if}
149
+
150
+ {#if has_duration}
151
+ <div class="timer {type}" style="animation-duration: {timer_duration}" />
152
+ {/if}
153
+ </div>
154
+
155
+ <!-- s-csdrBJqpTpqa -->
156
+ <style>
157
+ .toast-body {
158
+ display: flex;
159
+ flex-direction: column;
160
+ position: relative;
161
+ right: 0;
162
+ left: 0;
163
+ margin: auto;
164
+ border-radius: var(--radius-sm);
165
+ overflow: hidden;
166
+ pointer-events: auto;
167
+ background: var(--background-fill-secondary);
168
+ border: 1px solid var(--border-color-primary);
169
+ box-shadow: var(--shadow-drop);
170
+ touch-action: pan-y;
171
+ user-select: none;
172
+ }
173
+
174
+ :global(.dark) .toast-body {
175
+ background: var(--background-fill-primary);
176
+ }
177
+
178
+ .toast-body.error {
179
+ --toast-color: var(--color-red-700);
180
+ }
181
+
182
+ .toast-body.warning {
183
+ --toast-color: var(--color-yellow-700);
184
+ }
185
+
186
+ .toast-body.info {
187
+ --toast-color: var(--color-grey-700);
188
+ }
189
+
190
+ .toast-body.success {
191
+ --toast-color: var(--color-green-700);
192
+ }
193
+
194
+ :global(.dark) .toast-body.error {
195
+ --toast-color: var(--color-red-500);
196
+ }
197
+
198
+ :global(.dark) .toast-body.warning {
199
+ --toast-color: var(--color-yellow-500);
200
+ }
201
+
202
+ :global(.dark) .toast-body.info {
203
+ --toast-color: var(--color-grey-500);
204
+ }
205
+
206
+ :global(.dark) .toast-body.success {
207
+ --toast-color: var(--color-green-500);
208
+ }
209
+
210
+ .toast-header {
211
+ display: flex;
212
+ align-items: center;
213
+ padding: var(--size-3) var(--size-3);
214
+ cursor: pointer;
215
+ }
216
+
217
+ .toast-header:hover {
218
+ opacity: 0.9;
219
+ }
220
+
221
+ .toast-title-row {
222
+ flex: 1;
223
+ display: flex;
224
+ align-items: center;
225
+ gap: var(--size-2);
226
+ }
227
+
228
+ .chevron {
229
+ display: flex;
230
+ align-items: center;
231
+ width: var(--size-4);
232
+ height: var(--size-4);
233
+ transition: transform 0.2s ease;
234
+ opacity: 0.6;
235
+ }
236
+
237
+ .chevron.visible {
238
+ opacity: 1;
239
+ }
240
+
241
+ .chevron.expanded {
242
+ transform: rotate(180deg);
243
+ }
244
+
245
+ .toast-title {
246
+ display: flex;
247
+ align-items: center;
248
+ font-weight: var(--weight-bold);
249
+ font-size: var(--text-lg);
250
+ line-height: var(--line-sm);
251
+ }
252
+
253
+ .toast-count {
254
+ margin-left: var(--size-1);
255
+ font-weight: var(--weight-semibold);
256
+ }
257
+
258
+ .toast-close {
259
+ margin: 0 var(--size-1);
260
+ border-radius: var(--radius-lg);
261
+ padding: var(--size-1);
262
+ font-size: var(--text-xl);
263
+ line-height: 1;
264
+ background: transparent;
265
+ border: none;
266
+ cursor: pointer;
267
+ transition: all 0.2s ease;
268
+ display: flex;
269
+ align-items: center;
270
+ justify-content: center;
271
+ width: var(--size-7);
272
+ height: var(--size-7);
273
+ opacity: 0.6;
274
+ flex-shrink: 0;
275
+ }
276
+
277
+ .toast-close:hover {
278
+ opacity: 1;
279
+ transform: scale(1.1);
280
+ }
281
+
282
+ .toast-close:active {
283
+ transform: scale(0.95);
284
+ }
285
+
286
+ .toast-close {
287
+ color: var(--body-text-color);
288
+ }
289
+
290
+ .toast-icon {
291
+ display: flex;
292
+ position: relative;
293
+ flex-shrink: 0;
294
+ justify-content: center;
295
+ align-items: center;
296
+ margin-right: var(--size-2);
297
+ border-radius: var(--radius-full);
298
+ padding: var(--size-1-5);
299
+ width: var(--size-8);
300
+ height: var(--size-8);
301
+ }
302
+
303
+ .toast-icon {
304
+ color: var(--toast-color);
305
+ }
306
+
307
+ .toast-messages {
308
+ display: flex;
309
+ flex-direction: column;
310
+ gap: var(--size-2);
311
+ padding: 0 var(--size-3) var(--size-2) var(--size-3);
312
+ }
313
+
314
+ .toast-message-item {
315
+ padding: var(--size-1-5) var(--size-1-5) var(--size-1-5) var(--size-1-5);
316
+ border-radius: var(--radius-lg);
317
+ }
318
+
319
+ .toast-separator {
320
+ height: 1px;
321
+ background: var(--border-color-primary);
322
+ margin: 0;
323
+ }
324
+
325
+ .toast-message-text {
326
+ font-size: var(--text-md);
327
+ line-height: 1.5;
328
+ word-wrap: break-word;
329
+ overflow-wrap: break-word;
330
+ word-break: break-word;
331
+ color: var(--body-text-color);
332
+ }
333
+
334
+ .toast-message-text :global(a) {
335
+ text-decoration: underline;
336
+ }
337
+
338
+ @keyframes countdown {
339
+ from {
340
+ transform: scaleX(1);
341
+ }
342
+ to {
343
+ transform: scaleX(0);
344
+ }
345
+ }
346
+
347
+ .timer {
348
+ position: absolute;
349
+ bottom: 0;
350
+ left: 0;
351
+ transform-origin: 0 0;
352
+ animation: countdown 10s linear forwards;
353
+ width: 100%;
354
+ height: var(--size-1);
355
+ }
356
+
357
+ .timer {
358
+ background: var(--toast-color);
359
+ }
360
+
361
+ @media (max-width: 640px) {
362
+ .toast-header {
363
+ padding: var(--size-2) var(--size-2);
364
+ }
365
+
366
+ .toast-messages {
367
+ gap: var(--size-1);
368
+ padding: 0 var(--size-2) var(--size-1-5) var(--size-2);
369
+ }
370
+
371
+ .toast-message-item {
372
+ padding: 0 var(--size-1) var(--size-1) var(--size-1);
373
+ }
374
+ }
375
+ </style>
6.0.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
+ on:click={() => (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.0.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.0.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.0.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.0.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
+ }