@gradio/core 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/dist/src/Blocks.svelte +59 -42
- package/dist/src/Login.svelte +13 -13
- package/dist/src/Login.svelte.d.ts +1 -0
- package/dist/src/api_docs/Settings.svelte +21 -22
- package/dist/src/api_docs/Settings.svelte.d.ts +6 -21
- package/dist/src/api_docs/SettingsBanner.svelte +2 -4
- package/dist/src/api_docs/SettingsBanner.svelte.d.ts +5 -20
- package/dist/src/dependency.d.ts +10 -6
- package/dist/src/dependency.js +12 -1
- package/dist/src/init.svelte.d.ts +7 -3
- package/dist/src/init.svelte.js +180 -40
- package/dist/src/types.d.ts +2 -0
- package/package.json +34 -34
- package/src/Blocks.svelte +59 -42
- package/src/Login.svelte +13 -13
- package/src/api_docs/Settings.svelte +21 -22
- package/src/api_docs/SettingsBanner.svelte +2 -4
- package/src/dependency.ts +46 -24
- package/src/init.svelte.ts +221 -60
- package/src/init.test.ts +1 -1
- package/src/types.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,36 @@
|
|
|
1
1
|
# @gradio/core
|
|
2
|
+
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- [#12515](https://github.com/gradio-app/gradio/pull/12515) [`0892c29`](https://github.com/gradio-app/gradio/commit/0892c297b35742ed5cabf64d0846fd36ae02ecea) - Fix plot Rendering + visibility bug. Thanks @freddyaboulton!
|
|
8
|
+
- [#12493](https://github.com/gradio-app/gradio/pull/12493) [`8a6cff6`](https://github.com/gradio-app/gradio/commit/8a6cff6738d09a6e708fc6351d806967fa82ca91) - Fix bug where cancelling an events shows an error in the UI. Thanks @freddyaboulton!
|
|
9
|
+
- [#12518](https://github.com/gradio-app/gradio/pull/12518) [`e8efab2`](https://github.com/gradio-app/gradio/commit/e8efab2cb19860146cec7946e77b34a599ad6258) - Fix Settings. Thanks @freddyaboulton!
|
|
10
|
+
- [#12491](https://github.com/gradio-app/gradio/pull/12491) [`4f6327b`](https://github.com/gradio-app/gradio/commit/4f6327be6815fc8d574b60272b02915c75359ace) - Load visible components in 6.0. Thanks @freddyaboulton!
|
|
11
|
+
|
|
12
|
+
### Dependency updates
|
|
13
|
+
|
|
14
|
+
- @gradio/button@0.6.0
|
|
15
|
+
- @gradio/dropdown@0.10.7
|
|
16
|
+
- @gradio/textbox@0.12.1
|
|
17
|
+
- @gradio/tabs@0.5.3
|
|
18
|
+
- @gradio/tabitem@0.6.3
|
|
19
|
+
- @gradio/audio@0.21.0
|
|
20
|
+
- @gradio/video@0.18.0
|
|
21
|
+
- @gradio/checkbox@0.5.1
|
|
22
|
+
|
|
23
|
+
## 1.0.1
|
|
24
|
+
|
|
25
|
+
### Fixes
|
|
26
|
+
|
|
27
|
+
- [#12416](https://github.com/gradio-app/gradio/pull/12416) [`7e867fd`](https://github.com/gradio-app/gradio/commit/7e867fde9070849fb474a08544c72f2522a9cbe9) - Fix custom components for gradio 6. Thanks @pngwn!
|
|
28
|
+
- [#12461](https://github.com/gradio-app/gradio/pull/12461) [`9a86e80`](https://github.com/gradio-app/gradio/commit/9a86e8064787029bc20b086c6f3191879f786e0f) - Fix Login Gradio 6. Thanks @freddyaboulton!
|
|
29
|
+
|
|
30
|
+
### Dependency updates
|
|
31
|
+
|
|
32
|
+
- @gradio/utils@0.10.4
|
|
33
|
+
|
|
2
34
|
## 1.0.0
|
|
3
35
|
|
|
4
36
|
### Features
|
package/dist/src/Blocks.svelte
CHANGED
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
import * as screen_recorder from "./screen_recorder";
|
|
41
41
|
|
|
42
42
|
import { DependencyManager } from "./dependency";
|
|
43
|
-
|
|
44
43
|
let {
|
|
45
44
|
root,
|
|
46
45
|
components,
|
|
@@ -105,27 +104,6 @@
|
|
|
105
104
|
}
|
|
106
105
|
});
|
|
107
106
|
|
|
108
|
-
let app_tree = new AppTree(
|
|
109
|
-
components,
|
|
110
|
-
layout,
|
|
111
|
-
dependencies,
|
|
112
|
-
{
|
|
113
|
-
root,
|
|
114
|
-
theme: theme_mode,
|
|
115
|
-
version,
|
|
116
|
-
api_prefix,
|
|
117
|
-
max_file_size,
|
|
118
|
-
autoscroll
|
|
119
|
-
},
|
|
120
|
-
app,
|
|
121
|
-
$reactive_formatter
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
setContext(GRADIO_ROOT, {
|
|
125
|
-
register: app_tree.register_component.bind(app_tree),
|
|
126
|
-
dispatcher: gradio_event_dispatcher
|
|
127
|
-
});
|
|
128
|
-
|
|
129
107
|
let messages: (ToastMessage & { fn_index: number })[] = $state([]);
|
|
130
108
|
|
|
131
109
|
function gradio_event_dispatcher(
|
|
@@ -138,11 +116,17 @@
|
|
|
138
116
|
// trigger_share(title, description);
|
|
139
117
|
// TODO: lets combine all of the into a log type with levels
|
|
140
118
|
} else if (event === "error") {
|
|
141
|
-
new_message("Error", data, -1, event, 10, true);
|
|
119
|
+
new_message("Error", data as string, -1, event, 10, true);
|
|
142
120
|
} else if (event === "warning") {
|
|
143
|
-
new_message("Warning", data, -1, event, 10, true);
|
|
121
|
+
new_message("Warning", data as string, -1, event, 10, true);
|
|
144
122
|
} else if (event === "info") {
|
|
145
|
-
new_message("Info", data, -1, event, 10, true);
|
|
123
|
+
new_message("Info", data as string, -1, event, 10, true);
|
|
124
|
+
} else if (event === "gradio_expand" || event === "gradio_tab_select") {
|
|
125
|
+
const id_ =
|
|
126
|
+
event === "gradio_expand"
|
|
127
|
+
? id
|
|
128
|
+
: (data as { component_id: number }).component_id;
|
|
129
|
+
app_tree.render_previously_invisible_children(id_);
|
|
146
130
|
} else if (event == "clear_status") {
|
|
147
131
|
app_tree.update_state(
|
|
148
132
|
id,
|
|
@@ -163,7 +147,7 @@
|
|
|
163
147
|
// so we need to pull out the correct id here.
|
|
164
148
|
if (event === "select" && id in app_tree.initial_tabs) {
|
|
165
149
|
// this is the id of the selected tab
|
|
166
|
-
id = data.id;
|
|
150
|
+
id = (data as { id: number }).id;
|
|
167
151
|
}
|
|
168
152
|
dep_manager.dispatch({
|
|
169
153
|
type: "event",
|
|
@@ -174,6 +158,28 @@
|
|
|
174
158
|
}
|
|
175
159
|
}
|
|
176
160
|
|
|
161
|
+
let app_tree = new AppTree(
|
|
162
|
+
components,
|
|
163
|
+
layout,
|
|
164
|
+
dependencies,
|
|
165
|
+
{
|
|
166
|
+
root,
|
|
167
|
+
theme: theme_mode,
|
|
168
|
+
version,
|
|
169
|
+
api_prefix,
|
|
170
|
+
max_file_size,
|
|
171
|
+
autoscroll
|
|
172
|
+
},
|
|
173
|
+
app,
|
|
174
|
+
$reactive_formatter,
|
|
175
|
+
gradio_event_dispatcher
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
setContext(GRADIO_ROOT, {
|
|
179
|
+
register: app_tree.register_component.bind(app_tree),
|
|
180
|
+
dispatcher: gradio_event_dispatcher
|
|
181
|
+
});
|
|
182
|
+
|
|
177
183
|
let api_calls: Payload[] = $state([]);
|
|
178
184
|
let last_api_call: Payload | null = $state(null);
|
|
179
185
|
// We need a callback to add to api_calls from the DependencyManager
|
|
@@ -239,8 +245,8 @@
|
|
|
239
245
|
if (!ApiDocs || !ApiRecorder) {
|
|
240
246
|
const api_docs_module = await import("./api_docs/ApiDocs.svelte");
|
|
241
247
|
const api_recorder_module = await import("./api_docs/ApiRecorder.svelte");
|
|
242
|
-
if (!ApiDocs) ApiDocs = api_docs_module
|
|
243
|
-
if (!ApiRecorder) ApiRecorder = api_recorder_module
|
|
248
|
+
if (!ApiDocs) ApiDocs = api_docs_module?.default;
|
|
249
|
+
if (!ApiRecorder) ApiRecorder = api_recorder_module?.default;
|
|
244
250
|
}
|
|
245
251
|
}
|
|
246
252
|
|
|
@@ -323,8 +329,10 @@
|
|
|
323
329
|
|
|
324
330
|
const MESSAGE_QUOTE_RE = /^'([^]+)'$/;
|
|
325
331
|
|
|
326
|
-
const DUPLICATE_MESSAGE = $
|
|
327
|
-
const MOBILE_QUEUE_WARNING = $
|
|
332
|
+
const DUPLICATE_MESSAGE = $reactive_formatter("blocks.long_requests_queue");
|
|
333
|
+
const MOBILE_QUEUE_WARNING = $reactive_formatter(
|
|
334
|
+
"blocks.connection_can_break"
|
|
335
|
+
);
|
|
328
336
|
const LOST_CONNECTION_MESSAGE =
|
|
329
337
|
"Connection to the server was lost. Attempting reconnection...";
|
|
330
338
|
const CHANGED_CONNECTION_MESSAGE =
|
|
@@ -332,7 +340,9 @@
|
|
|
332
340
|
const RECONNECTION_MESSAGE = "Connection re-established.";
|
|
333
341
|
const SESSION_NOT_FOUND_MESSAGE =
|
|
334
342
|
"Session not found - this is likely because the machine you were connected to has changed. <a href=''>Refresh the page</a> to continue.";
|
|
335
|
-
const WAITING_FOR_INPUTS_MESSAGE = $
|
|
343
|
+
const WAITING_FOR_INPUTS_MESSAGE = $reactive_formatter(
|
|
344
|
+
"blocks.waiting_for_inputs"
|
|
345
|
+
);
|
|
336
346
|
const SHOW_DUPLICATE_MESSAGE_ON_ETA = 15;
|
|
337
347
|
const SHOW_MOBILE_QUEUE_WARNING_ON_ETA = 10;
|
|
338
348
|
let is_mobile_device = false;
|
|
@@ -441,11 +451,11 @@
|
|
|
441
451
|
class="show-api"
|
|
442
452
|
>
|
|
443
453
|
{#if app.config?.mcp_server}
|
|
444
|
-
{$
|
|
454
|
+
{$reactive_formatter("errors.use_via_api_or_mcp")}
|
|
445
455
|
{:else}
|
|
446
|
-
{$
|
|
456
|
+
{$reactive_formatter("errors.use_via_api")}
|
|
447
457
|
{/if}
|
|
448
|
-
<img src={api_logo} alt={$
|
|
458
|
+
<img src={api_logo} alt={$reactive_formatter("common.logo")} />
|
|
449
459
|
</button>
|
|
450
460
|
{/if}
|
|
451
461
|
{#if footer_links.includes("gradio")}
|
|
@@ -456,8 +466,8 @@
|
|
|
456
466
|
target="_blank"
|
|
457
467
|
rel="noreferrer"
|
|
458
468
|
>
|
|
459
|
-
{$
|
|
460
|
-
<img src={logo} alt={$
|
|
469
|
+
{$reactive_formatter("common.built_with_gradio")}
|
|
470
|
+
<img src={logo} alt={$reactive_formatter("common.logo")} />
|
|
461
471
|
</a>
|
|
462
472
|
{/if}
|
|
463
473
|
<button
|
|
@@ -467,8 +477,11 @@
|
|
|
467
477
|
}}
|
|
468
478
|
class="record"
|
|
469
479
|
>
|
|
470
|
-
{$
|
|
471
|
-
<img
|
|
480
|
+
{$reactive_formatter("common.stop_recording")}
|
|
481
|
+
<img
|
|
482
|
+
src={record_stop}
|
|
483
|
+
alt={$reactive_formatter("common.stop_recording")}
|
|
484
|
+
/>
|
|
472
485
|
</button>
|
|
473
486
|
<div class="divider">·</div>
|
|
474
487
|
{#if footer_links.includes("settings")}
|
|
@@ -482,8 +495,11 @@
|
|
|
482
495
|
}}
|
|
483
496
|
class="settings"
|
|
484
497
|
>
|
|
485
|
-
{$
|
|
486
|
-
<img
|
|
498
|
+
{$reactive_formatter("common.settings")}
|
|
499
|
+
<img
|
|
500
|
+
src={settings_logo}
|
|
501
|
+
alt={$reactive_formatter("common.settings")}
|
|
502
|
+
/>
|
|
487
503
|
</button>
|
|
488
504
|
{/if}
|
|
489
505
|
</footer>
|
|
@@ -553,15 +569,16 @@
|
|
|
553
569
|
this={Settings}
|
|
554
570
|
bind:allow_zoom
|
|
555
571
|
bind:allow_video_trim
|
|
556
|
-
|
|
572
|
+
onclose={() => {
|
|
557
573
|
set_settings_visible(false);
|
|
558
574
|
}}
|
|
559
|
-
|
|
575
|
+
start_recording={() => {
|
|
560
576
|
screen_recording();
|
|
561
577
|
}}
|
|
562
578
|
pwa_enabled={app.config.pwa}
|
|
563
579
|
{root}
|
|
564
580
|
{space_id}
|
|
581
|
+
i18n={$reactive_formatter}
|
|
565
582
|
/>
|
|
566
583
|
</div>
|
|
567
584
|
</div>
|
package/dist/src/Login.svelte
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
2
|
+
import { BaseForm } from "@gradio/form";
|
|
3
3
|
import { BaseTextbox as Textbox } from "@gradio/textbox";
|
|
4
4
|
import { BaseButton } from "@gradio/button";
|
|
5
|
-
import
|
|
5
|
+
import { BaseColumn } from "@gradio/column";
|
|
6
6
|
import { Block } from "@gradio/atoms";
|
|
7
|
-
import { _ } from "svelte-i18n";
|
|
8
7
|
export let root: string;
|
|
9
8
|
export let auth_message: string | null;
|
|
10
9
|
export let app_mode: boolean;
|
|
11
10
|
export let space_id: string | null;
|
|
11
|
+
export let i18n: (s: string) => string;
|
|
12
12
|
|
|
13
13
|
let username = "";
|
|
14
14
|
let password = "";
|
|
@@ -34,23 +34,23 @@
|
|
|
34
34
|
</script>
|
|
35
35
|
|
|
36
36
|
<div class="wrap" class:min-h-screen={app_mode}>
|
|
37
|
-
<
|
|
38
|
-
<h2>{
|
|
37
|
+
<BaseColumn variant="panel" min_width={480}>
|
|
38
|
+
<h2>{i18n("login.login")}</h2>
|
|
39
39
|
{#if auth_message}
|
|
40
40
|
<p class="auth">{@html auth_message}</p>
|
|
41
41
|
{/if}
|
|
42
42
|
{#if space_id}
|
|
43
43
|
<p class="auth">
|
|
44
|
-
{
|
|
44
|
+
{i18n("login.enable_cookies")}
|
|
45
45
|
</p>
|
|
46
46
|
{/if}
|
|
47
47
|
{#if incorrect_credentials}
|
|
48
|
-
<p class="creds">{
|
|
48
|
+
<p class="creds">{i18n("login.incorrect_credentials")}</p>
|
|
49
49
|
{/if}
|
|
50
|
-
<
|
|
50
|
+
<BaseForm>
|
|
51
51
|
<Block>
|
|
52
52
|
<Textbox
|
|
53
|
-
label={
|
|
53
|
+
label={i18n("login.username")}
|
|
54
54
|
lines={1}
|
|
55
55
|
show_label={true}
|
|
56
56
|
max_lines={1}
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
|
|
62
62
|
<Block>
|
|
63
63
|
<Textbox
|
|
64
|
-
label={
|
|
64
|
+
label={i18n("login.password")}
|
|
65
65
|
lines={1}
|
|
66
66
|
show_label={true}
|
|
67
67
|
max_lines={1}
|
|
@@ -70,12 +70,12 @@
|
|
|
70
70
|
bind:value={password}
|
|
71
71
|
/>
|
|
72
72
|
</Block>
|
|
73
|
-
</
|
|
73
|
+
</BaseForm>
|
|
74
74
|
|
|
75
75
|
<BaseButton size="lg" variant="primary" on:click={submit}
|
|
76
|
-
>{
|
|
76
|
+
>{i18n("login.login")}</BaseButton
|
|
77
77
|
>
|
|
78
|
-
</
|
|
78
|
+
</BaseColumn>
|
|
79
79
|
</div>
|
|
80
80
|
|
|
81
81
|
<style>
|
|
@@ -7,17 +7,18 @@
|
|
|
7
7
|
import { language_choices, changeLocale } from "../i18n";
|
|
8
8
|
import { locale, _ } from "svelte-i18n";
|
|
9
9
|
import record from "./img/record.svg";
|
|
10
|
-
import { createEventDispatcher } from "svelte";
|
|
11
10
|
|
|
12
11
|
let {
|
|
13
12
|
root,
|
|
14
13
|
space_id,
|
|
15
14
|
pwa_enabled,
|
|
16
15
|
allow_zoom = $bindable(),
|
|
17
|
-
allow_video_trim = $bindable()
|
|
16
|
+
allow_video_trim = $bindable(),
|
|
17
|
+
onclose,
|
|
18
|
+
start_recording,
|
|
19
|
+
i18n
|
|
18
20
|
} = $props();
|
|
19
21
|
|
|
20
|
-
const dispatch = createEventDispatcher();
|
|
21
22
|
if (root === "") {
|
|
22
23
|
root = location.protocol + "//" + location.host + location.pathname;
|
|
23
24
|
}
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
url.searchParams.set("__theme", theme);
|
|
35
36
|
current_theme = theme;
|
|
36
37
|
}
|
|
38
|
+
url.searchParams.delete("view");
|
|
37
39
|
window.location.href = url.toString();
|
|
38
40
|
}
|
|
39
41
|
|
|
@@ -59,8 +61,8 @@
|
|
|
59
61
|
}
|
|
60
62
|
});
|
|
61
63
|
|
|
62
|
-
function handleLanguageChange(
|
|
63
|
-
const new_locale =
|
|
64
|
+
function handleLanguageChange(value: string): void {
|
|
65
|
+
const new_locale = value;
|
|
64
66
|
changeLocale(new_locale);
|
|
65
67
|
}
|
|
66
68
|
|
|
@@ -74,54 +76,51 @@
|
|
|
74
76
|
</script>
|
|
75
77
|
|
|
76
78
|
<div class="banner-wrap">
|
|
77
|
-
<SettingsBanner
|
|
79
|
+
<SettingsBanner onclose={() => onclose()} {root} />
|
|
78
80
|
</div>
|
|
79
81
|
{#if space_id === null}
|
|
80
82
|
<!-- on Spaces, the theme is set in HF settings -->
|
|
81
83
|
<div class="banner-wrap">
|
|
82
|
-
<h2>{
|
|
83
|
-
<
|
|
84
|
+
<h2>{i18n("common.display_theme")}</h2>
|
|
85
|
+
<ul class="padded theme-buttons">
|
|
84
86
|
<li
|
|
85
87
|
class="theme-button {current_theme === 'light'
|
|
86
88
|
? 'current-theme'
|
|
87
89
|
: 'inactive-theme'}"
|
|
88
|
-
on:click={() => setTheme("light")}
|
|
89
90
|
>
|
|
90
|
-
<button>☀︎ Light</button>
|
|
91
|
+
<button on:click={() => setTheme("light")}>☀︎ Light</button>
|
|
91
92
|
</li>
|
|
92
93
|
<li
|
|
93
94
|
class="theme-button {current_theme === 'dark'
|
|
94
95
|
? 'current-theme'
|
|
95
96
|
: 'inactive-theme'}"
|
|
96
|
-
on:click={() => setTheme("dark")}
|
|
97
97
|
>
|
|
98
|
-
<button>⏾ Dark</button>
|
|
98
|
+
<button on:click={() => setTheme("dark")}>⏾ Dark</button>
|
|
99
99
|
</li>
|
|
100
100
|
<li
|
|
101
101
|
class="theme-button {current_theme === 'system'
|
|
102
102
|
? 'current-theme'
|
|
103
103
|
: 'inactive-theme'}"
|
|
104
|
-
on:click={() => setTheme("system")}
|
|
105
104
|
>
|
|
106
|
-
<button>🖥︎ System</button>
|
|
105
|
+
<button on:click={() => setTheme("system")}>🖥︎ System</button>
|
|
107
106
|
</li>
|
|
108
|
-
</
|
|
107
|
+
</ul>
|
|
109
108
|
</div>
|
|
110
109
|
{/if}
|
|
111
110
|
<div class="banner-wrap">
|
|
112
|
-
<h2>{
|
|
111
|
+
<h2>{i18n("common.language")}</h2>
|
|
113
112
|
<p class="padded">
|
|
114
113
|
<Dropdown
|
|
115
114
|
label="Language"
|
|
116
115
|
choices={language_choices}
|
|
117
116
|
show_label={false}
|
|
118
|
-
value={current_locale}
|
|
119
|
-
|
|
117
|
+
bind:value={current_locale}
|
|
118
|
+
on_change={() => handleLanguageChange(current_locale)}
|
|
120
119
|
/>
|
|
121
120
|
</p>
|
|
122
121
|
</div>
|
|
123
122
|
<div class="banner-wrap">
|
|
124
|
-
<h2>{
|
|
123
|
+
<h2>{i18n("common.pwa")}</h2>
|
|
125
124
|
<p class="padded">
|
|
126
125
|
{#if pwa_enabled}
|
|
127
126
|
You can install this app as a Progressive Web App on your device. Visit <a
|
|
@@ -135,7 +134,7 @@
|
|
|
135
134
|
</p>
|
|
136
135
|
</div>
|
|
137
136
|
<div class="banner-wrap">
|
|
138
|
-
<h2>{
|
|
137
|
+
<h2>{i18n("common.screen_studio")} <span class="beta-tag">beta</span></h2>
|
|
139
138
|
<p class="padded">
|
|
140
139
|
Screen Studio allows you to record your screen and generates a video of your
|
|
141
140
|
app with automatically adding zoom in and zoom out effects as well as
|
|
@@ -164,8 +163,8 @@
|
|
|
164
163
|
<button
|
|
165
164
|
class="record-button"
|
|
166
165
|
on:click={() => {
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
onclose?.();
|
|
167
|
+
start_recording?.();
|
|
169
168
|
}}
|
|
170
169
|
>
|
|
171
170
|
<img src={record} alt="Start Recording" />
|
|
@@ -1,27 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
-
$$bindings?: Bindings;
|
|
4
|
-
} & Exports;
|
|
5
|
-
(internal: unknown, props: Props & {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const Settings: $$__sveltets_2_IsomorphicComponent<{
|
|
1
|
+
declare const Settings: import("svelte").Component<{
|
|
15
2
|
root: any;
|
|
16
3
|
space_id: any;
|
|
17
4
|
pwa_enabled: any;
|
|
18
5
|
allow_zoom?: any;
|
|
19
6
|
allow_video_trim?: any;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
}, {}, {}, "allow_zoom" | "allow_video_trim">;
|
|
26
|
-
type Settings = InstanceType<typeof Settings>;
|
|
7
|
+
onclose: any;
|
|
8
|
+
start_recording: any;
|
|
9
|
+
i18n: any;
|
|
10
|
+
}, {}, "allow_zoom" | "allow_video_trim">;
|
|
11
|
+
type Settings = ReturnType<typeof Settings>;
|
|
27
12
|
export default Settings;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { createEventDispatcher } from "svelte";
|
|
3
2
|
import { _ } from "svelte-i18n";
|
|
4
3
|
import settings_logo from "./img/settings-logo.svg";
|
|
5
4
|
import Clear from "./img/clear.svelte";
|
|
6
5
|
import { setupi18n } from "../i18n";
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
let { root, onclose }: { root: string; onclose?: () => void } = $props();
|
|
9
8
|
|
|
10
|
-
const dispatch = createEventDispatcher();
|
|
11
9
|
setupi18n();
|
|
12
10
|
</script>
|
|
13
11
|
|
|
@@ -21,7 +19,7 @@
|
|
|
21
19
|
</div>
|
|
22
20
|
</h2>
|
|
23
21
|
|
|
24
|
-
<button on:click={() =>
|
|
22
|
+
<button on:click={() => onclose?.()}>
|
|
25
23
|
<Clear />
|
|
26
24
|
</button>
|
|
27
25
|
|
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
-
$$bindings?: Bindings;
|
|
4
|
-
} & Exports;
|
|
5
|
-
(internal: unknown, props: Props & {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const SettingsBanner: $$__sveltets_2_IsomorphicComponent<{
|
|
1
|
+
type $$ComponentProps = {
|
|
15
2
|
root: string;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}, {}, {}, string>;
|
|
21
|
-
type SettingsBanner = InstanceType<typeof SettingsBanner>;
|
|
3
|
+
onclose?: () => void;
|
|
4
|
+
};
|
|
5
|
+
declare const SettingsBanner: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
6
|
+
type SettingsBanner = ReturnType<typeof SettingsBanner>;
|
|
22
7
|
export default SettingsBanner;
|
package/dist/src/dependency.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ComponentMeta, Dependency as IDependency, LayoutNode, Payload } fr
|
|
|
2
2
|
import { Client, type client_return } from "@gradio/client";
|
|
3
3
|
import { LoadingStatus } from "@gradio/statustracker";
|
|
4
4
|
import type { ToastMessage } from "@gradio/statustracker";
|
|
5
|
-
import type { StatusMessage } from "@gradio/client";
|
|
5
|
+
import type { StatusMessage, LogMessage } from "@gradio/client";
|
|
6
6
|
/**
|
|
7
7
|
* A dependency as used by the frontend
|
|
8
8
|
* This class represents a discrete dependency that can be triggered by an event
|
|
@@ -58,6 +58,10 @@ interface DispatchEvent {
|
|
|
58
58
|
target_id?: number;
|
|
59
59
|
event_data: unknown;
|
|
60
60
|
}
|
|
61
|
+
type UpdateStateCallback = (id: number, state: Record<string, unknown>, check_visibility?: boolean) => Promise<void>;
|
|
62
|
+
type GetStateCallback = (id: number) => Promise<Record<string, unknown> | null>;
|
|
63
|
+
type RerenderCallback = (components: ComponentMeta[], layout: LayoutNode) => void;
|
|
64
|
+
type LogCallback = (title: string, message: string, fn_index: number, type: ToastMessage["type"], duration?: number | null, visible?: boolean) => void;
|
|
61
65
|
/**
|
|
62
66
|
* Manages all dependencies for an app acting as a bridge between app state and Dependencies
|
|
63
67
|
* Responsible for registering dependencies and dispatching events to them
|
|
@@ -77,13 +81,13 @@ export declare class DependencyManager {
|
|
|
77
81
|
client: Client;
|
|
78
82
|
queue: Set<number>;
|
|
79
83
|
add_to_api_calls: (payload: Payload) => void;
|
|
80
|
-
update_state_cb:
|
|
81
|
-
get_state_cb:
|
|
82
|
-
rerender_cb:
|
|
83
|
-
log_cb:
|
|
84
|
+
update_state_cb: UpdateStateCallback;
|
|
85
|
+
get_state_cb: GetStateCallback;
|
|
86
|
+
rerender_cb: RerenderCallback;
|
|
87
|
+
log_cb: LogCallback;
|
|
84
88
|
loading_stati: LoadingStatus;
|
|
85
89
|
constructor(dependencies: IDependency[], client: Client, update_state_cb: (id: number, state: Record<string, unknown>, check_visibility?: boolean) => Promise<void>, get_state_cb: (id: number) => Promise<Record<string, unknown> | null>, rerender_cb: (components: ComponentMeta[], layout: LayoutNode) => void, log_cb: (title: string, message: string, fn_index: number, type: ToastMessage["type"], duration?: number | null, visible?: boolean) => void, add_to_api_calls: (payload: Payload) => void);
|
|
86
|
-
reload(dependencies: IDependency[], update_state:
|
|
90
|
+
reload(dependencies: IDependency[], update_state: UpdateStateCallback, get_state: GetStateCallback, rerender: RerenderCallback, client: Client): void;
|
|
87
91
|
register_loading_stati(deps: Map<number, Dependency>): void;
|
|
88
92
|
clear_loading_status(component_id: number): void;
|
|
89
93
|
update_loading_stati_state(): Promise<void>;
|
package/dist/src/dependency.js
CHANGED
|
@@ -125,6 +125,7 @@ export class DependencyManager {
|
|
|
125
125
|
this.update_state_cb = update_state_cb;
|
|
126
126
|
this.get_state_cb = get_state_cb;
|
|
127
127
|
this.rerender_cb = rerender_cb;
|
|
128
|
+
this.client = client;
|
|
128
129
|
this.reload(dependencies, update_state_cb, get_state_cb, rerender_cb, client);
|
|
129
130
|
}
|
|
130
131
|
reload(dependencies, update_state, get_state, rerender, client) {
|
|
@@ -344,7 +345,9 @@ export class DependencyManager {
|
|
|
344
345
|
return;
|
|
345
346
|
}
|
|
346
347
|
const _message = result?.message?.replace(MESSAGE_QUOTE_RE, (_, b) => b);
|
|
347
|
-
this.log_cb(
|
|
348
|
+
this.log_cb(
|
|
349
|
+
//@ts-ignore
|
|
350
|
+
result?._title ?? "Error", _message || "", fn_index, "error", status.duration, status.visible);
|
|
348
351
|
throw new Error("Dependency function failed");
|
|
349
352
|
}
|
|
350
353
|
else {
|
|
@@ -555,6 +558,14 @@ export class DependencyManager {
|
|
|
555
558
|
const submission = this.submissions.get(id);
|
|
556
559
|
if (submission) {
|
|
557
560
|
await submission.cancel();
|
|
561
|
+
this.loading_stati.update({
|
|
562
|
+
status: "complete",
|
|
563
|
+
fn_index: id,
|
|
564
|
+
eta: 0,
|
|
565
|
+
queue: false,
|
|
566
|
+
stream_state: null
|
|
567
|
+
});
|
|
568
|
+
this.update_loading_stati_state();
|
|
558
569
|
this.submissions.delete(id);
|
|
559
570
|
}
|
|
560
571
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentMeta, ProcessedComponentMeta, LayoutNode, Dependency, AppConfig, ServerFunctions } from "./types";
|
|
2
|
-
import type
|
|
2
|
+
import { type SharedProps } from "@gradio/utils";
|
|
3
3
|
import { Client } from "@gradio/client";
|
|
4
4
|
type client_return = Awaited<ReturnType<typeof Client.connect>>;
|
|
5
5
|
type set_data_type = (data: Record<string, unknown>) => void;
|
|
@@ -13,6 +13,7 @@ type Tab = {
|
|
|
13
13
|
elem_id: string | undefined;
|
|
14
14
|
scale: number | null;
|
|
15
15
|
order?: number;
|
|
16
|
+
component_id: number;
|
|
16
17
|
};
|
|
17
18
|
export declare class AppTree {
|
|
18
19
|
#private;
|
|
@@ -21,14 +22,15 @@ export declare class AppTree {
|
|
|
21
22
|
client: client_return;
|
|
22
23
|
/** the root node of the processed layout tree */
|
|
23
24
|
root: ProcessedComponentMeta | undefined;
|
|
25
|
+
root_untracked: ProcessedComponentMeta;
|
|
24
26
|
component_ids: number[];
|
|
25
27
|
initial_tabs: Record<number, Tab[]>;
|
|
26
28
|
components_to_register: Set<number>;
|
|
27
29
|
ready: Promise<void>;
|
|
28
30
|
ready_resolve: () => void;
|
|
29
31
|
resolved: boolean;
|
|
30
|
-
constructor(components: ComponentMeta[], layout: LayoutNode, dependencies: Dependency[], config: AppConfig, app: client_return, reactive_formatter: (str: string) => string);
|
|
31
|
-
reload(components: ComponentMeta[], layout: LayoutNode, dependencies: Dependency[], config: AppConfig): void;
|
|
32
|
+
constructor(components: ComponentMeta[], layout: LayoutNode, dependencies: Dependency[], config: Omit<AppConfig, "api_url">, app: client_return, reactive_formatter: (str: string) => string, event_dispatcher: (id: number, event: string, data: unknown) => void);
|
|
33
|
+
reload(components: ComponentMeta[], layout: LayoutNode, dependencies: Dependency[], config: Omit<AppConfig, "api_url">): void;
|
|
32
34
|
/**
|
|
33
35
|
* Registers a component with its ID and data callbacks
|
|
34
36
|
* @param id the ID of the component
|
|
@@ -59,6 +61,7 @@ export declare class AppTree {
|
|
|
59
61
|
*/
|
|
60
62
|
create_node(opts: LayoutNode, component_map: Map<number, ComponentMeta>, root?: boolean, reactive_formatter?: (str: string) => string): ProcessedComponentMeta;
|
|
61
63
|
rerender(components: ComponentMeta[], layout: LayoutNode): void;
|
|
64
|
+
update_visibility(node: ProcessedComponentMeta, new_state: any): Promise<void>;
|
|
62
65
|
update_state(id: number, new_state: Partial<SharedProps> & Record<string, unknown>, check_visibility?: boolean): Promise<void>;
|
|
63
66
|
/**
|
|
64
67
|
* Gets the current state of a component by its ID
|
|
@@ -66,6 +69,7 @@ export declare class AppTree {
|
|
|
66
69
|
* @returns the current state of the component, or null if not found
|
|
67
70
|
*/
|
|
68
71
|
get_state(id: number): Promise<Record<string, unknown> | null>;
|
|
72
|
+
render_previously_invisible_children(id: number): Promise<void>;
|
|
69
73
|
}
|
|
70
74
|
/**
|
|
71
75
|
* Process the server function names and return a dictionary of functions
|