@gradio/core 0.1.0-beta.1 → 0.1.0-beta.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 +66 -21
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/src/Blocks.svelte +84 -51
- package/dist/src/Blocks.svelte.d.ts +4 -0
- package/dist/src/MountComponents.svelte +12 -10
- package/dist/src/Render.svelte +14 -12
- package/dist/src/RenderComponent.svelte +2 -2
- package/dist/src/RenderComponent.svelte.d.ts +0 -2
- package/dist/src/css.js +2 -1
- package/dist/src/init.d.ts +1 -1
- package/dist/src/init.js +16 -11
- package/dist/src/lang/en.json +2 -1
- package/dist/src/types.d.ts +2 -0
- package/index.ts +1 -0
- package/package.json +54 -54
- package/src/Blocks.svelte +135 -96
- package/src/MountComponents.svelte +12 -10
- package/src/Render.svelte +16 -13
- package/src/RenderComponent.svelte +2 -2
- package/src/css.ts +1 -0
- package/src/init.ts +18 -14
- package/src/lang/en.json +2 -1
- package/src/types.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @gradio/core
|
|
2
2
|
|
|
3
|
+
## 0.1.0-beta.2
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- [#9323](https://github.com/gradio-app/gradio/pull/9323) [`06babda`](https://github.com/gradio-app/gradio/commit/06babda0395fd3fbd323c1c3cb33704ecfd6deb0) - Disable liking user message in chatbot by default but make it configurable. Thanks @freddyaboulton!
|
|
8
|
+
- [#9339](https://github.com/gradio-app/gradio/pull/9339) [`4c8c6f2`](https://github.com/gradio-app/gradio/commit/4c8c6f2fe603081941c5fdc43f48a0632b9f31ad) - Ssr part 2. Thanks @pngwn!
|
|
9
|
+
- [#9269](https://github.com/gradio-app/gradio/pull/9269) [`e05f568`](https://github.com/gradio-app/gradio/commit/e05f568f47e9fa33ef91dbbe5cc477d32762bc36) - Fix reload mode and streaming in 5.0 dev. Thanks @freddyaboulton!
|
|
10
|
+
- [#9253](https://github.com/gradio-app/gradio/pull/9253) [`99648ec`](https://github.com/gradio-app/gradio/commit/99648ec7c4443e74799941e47b0015ac9ca581e1) - Adds ability to block event trigger when file is uploading. Thanks @dawoodkhan82!
|
|
11
|
+
- [#9335](https://github.com/gradio-app/gradio/pull/9335) [`b543465`](https://github.com/gradio-app/gradio/commit/b543465d06d7d1b399c4d0755da05e022611a97f) - Remove lite/theme.css from the Git-managed file tree. Thanks @whitphx!
|
|
12
|
+
|
|
13
|
+
### Fixes
|
|
14
|
+
|
|
15
|
+
- [#9299](https://github.com/gradio-app/gradio/pull/9299) [`aa35b07`](https://github.com/gradio-app/gradio/commit/aa35b0788e613fdd45446d267513e6f94fa208ea) - Trigger state change event on iterators. Thanks @freddyaboulton!
|
|
16
|
+
|
|
17
|
+
### Dependency updates
|
|
18
|
+
|
|
19
|
+
- @gradio/atoms@0.9.0-beta.2
|
|
20
|
+
- @gradio/gallery@0.13.0-beta.2
|
|
21
|
+
- @gradio/upload@0.13.0-beta.2
|
|
22
|
+
- @gradio/wasm@0.14.0-beta.2
|
|
23
|
+
- @gradio/markdown@0.10.0-beta.2
|
|
24
|
+
- @gradio/client@1.6.0-beta.2
|
|
25
|
+
- @gradio/icons@0.8.0-beta.2
|
|
26
|
+
- @gradio/statustracker@0.8.0-beta.2
|
|
27
|
+
- @gradio/utils@0.7.0-beta.2
|
|
28
|
+
- @gradio/plot@0.6.5-beta.2
|
|
29
|
+
- @gradio/button@0.3.0-beta.2
|
|
30
|
+
- @gradio/file@0.10.0-beta.2
|
|
31
|
+
- @gradio/image@0.16.0-beta.2
|
|
32
|
+
- @gradio/video@0.11.0-beta.2
|
|
33
|
+
- @gradio/code@0.10.0-beta.2
|
|
34
|
+
- @gradio/paramviewer@0.4.22-beta.2
|
|
35
|
+
- @gradio/checkbox@0.4.0-beta.2
|
|
36
|
+
- @gradio/column@0.2.0-beta.0
|
|
37
|
+
- @gradio/textbox@0.7.0-beta.2
|
|
38
|
+
- @gradio/tabs@0.3.0-beta.2
|
|
39
|
+
|
|
3
40
|
## 0.1.0-beta.1
|
|
4
41
|
|
|
5
42
|
### Features
|
|
@@ -39,33 +76,41 @@
|
|
|
39
76
|
- [#9052](https://github.com/gradio-app/gradio/pull/9052) [`f3652eb`](https://github.com/gradio-app/gradio/commit/f3652ebe08211e12739df73c15fd97e5ff81276a) - Video gallery. Thanks @dawoodkhan82!
|
|
40
77
|
- [#8941](https://github.com/gradio-app/gradio/pull/8941) [`97a7bf6`](https://github.com/gradio-app/gradio/commit/97a7bf66a79179d1b91a3199d68e5c11216ca500) - Streaming inputs for 5.0. Thanks @freddyaboulton!
|
|
41
78
|
|
|
79
|
+
## 0.0.4
|
|
80
|
+
|
|
81
|
+
### Fixes
|
|
82
|
+
|
|
83
|
+
- [#9188](https://github.com/gradio-app/gradio/pull/9188) [`8f8e1c6`](https://github.com/gradio-app/gradio/commit/8f8e1c6a0b09b0d1985b8377d94d693cb00f8a18) - Fix multiple trigger bug when function has js. Thanks @freddyaboulton!
|
|
84
|
+
|
|
85
|
+
## 0.0.3
|
|
86
|
+
|
|
42
87
|
### Fixes
|
|
43
88
|
|
|
44
89
|
- [#9163](https://github.com/gradio-app/gradio/pull/9163) [`2b6cbf2`](https://github.com/gradio-app/gradio/commit/2b6cbf25908e42cf027324e54ef2cc0baad11a91) - fix exports and generate types. Thanks @pngwn!
|
|
45
90
|
|
|
46
91
|
### Dependency updates
|
|
47
92
|
|
|
48
|
-
- @gradio/
|
|
49
|
-
- @gradio/
|
|
50
|
-
- @gradio/
|
|
51
|
-
- @gradio/
|
|
52
|
-
- @gradio/
|
|
53
|
-
- @gradio/
|
|
54
|
-
- @gradio/
|
|
55
|
-
- @gradio/
|
|
56
|
-
- @gradio/upload@0.12.4
|
|
57
|
-
- @gradio/
|
|
58
|
-
- @gradio/
|
|
59
|
-
- @gradio/
|
|
60
|
-
- @gradio/
|
|
61
|
-
- @gradio/
|
|
62
|
-
- @gradio/
|
|
63
|
-
- @gradio/
|
|
64
|
-
- @gradio/
|
|
65
|
-
- @gradio/
|
|
66
|
-
- @gradio/
|
|
67
|
-
- @gradio/
|
|
68
|
-
- @gradio/tabs@0.2.14
|
|
93
|
+
- @gradio/code@0.9.1
|
|
94
|
+
- @gradio/paramviewer@0.4.22
|
|
95
|
+
- @gradio/utils@0.6.1
|
|
96
|
+
- @gradio/statustracker@0.7.6
|
|
97
|
+
- @gradio/atoms@0.8.1
|
|
98
|
+
- @gradio/icons@0.7.2
|
|
99
|
+
- @gradio/wasm@0.13.1
|
|
100
|
+
- @gradio/client@1.5.2
|
|
101
|
+
- @gradio/upload@0.12.4
|
|
102
|
+
- @gradio/button@0.2.51
|
|
103
|
+
- @gradio/markdown@0.9.4
|
|
104
|
+
- @gradio/gallery@0.12.2
|
|
105
|
+
- @gradio/theme@0.2.5
|
|
106
|
+
- @gradio/plot@0.6.5
|
|
107
|
+
- @gradio/textbox@0.7.0
|
|
108
|
+
- @gradio/image@0.15.1
|
|
109
|
+
- @gradio/video@0.10.4
|
|
110
|
+
- @gradio/file@0.9.4
|
|
111
|
+
- @gradio/checkbox@0.3.13
|
|
112
|
+
- @gradio/column@0.1.4
|
|
113
|
+
- @gradio/tabs@0.2.14
|
|
69
114
|
|
|
70
115
|
## 0.0.2
|
|
71
116
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/src/Blocks.svelte
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>import { tick } from "svelte";
|
|
1
|
+
<script>import { tick, onMount } from "svelte";
|
|
2
2
|
import { _ } from "svelte-i18n";
|
|
3
3
|
import { Client } from "@gradio/client";
|
|
4
4
|
import { setupi18n } from "./i18n";
|
|
@@ -28,7 +28,10 @@ export let js;
|
|
|
28
28
|
export let fill_height = false;
|
|
29
29
|
export let ready;
|
|
30
30
|
export let username;
|
|
31
|
-
|
|
31
|
+
export let api_prefix;
|
|
32
|
+
export let max_file_size;
|
|
33
|
+
export let initial_layout = void 0;
|
|
34
|
+
let {
|
|
32
35
|
layout: _layout,
|
|
33
36
|
targets,
|
|
34
37
|
update_value,
|
|
@@ -41,33 +44,37 @@ const {
|
|
|
41
44
|
create_layout,
|
|
42
45
|
rerender_layout
|
|
43
46
|
} = create_components();
|
|
47
|
+
$_layout = initial_layout;
|
|
44
48
|
$:
|
|
45
|
-
|
|
49
|
+
components, layout, dependencies, root, app, fill_height, target, run();
|
|
50
|
+
$: {
|
|
51
|
+
ready = !!$_layout;
|
|
52
|
+
}
|
|
53
|
+
async function run() {
|
|
54
|
+
await create_layout({
|
|
46
55
|
components,
|
|
47
56
|
layout,
|
|
48
57
|
dependencies,
|
|
49
|
-
root: root +
|
|
58
|
+
root: root + api_prefix,
|
|
50
59
|
app,
|
|
51
60
|
options: {
|
|
52
61
|
fill_height
|
|
53
62
|
}
|
|
54
63
|
});
|
|
55
|
-
$: {
|
|
56
|
-
ready = !!$_layout;
|
|
57
64
|
}
|
|
58
|
-
let
|
|
59
|
-
let api_docs_visible =
|
|
60
|
-
let api_recorder_visible =
|
|
65
|
+
export let search_params;
|
|
66
|
+
let api_docs_visible = search_params.get("view") === "api" && show_api;
|
|
67
|
+
let api_recorder_visible = search_params.get("view") === "api-recorder" && show_api;
|
|
61
68
|
function set_api_docs_visible(visible) {
|
|
62
69
|
api_recorder_visible = false;
|
|
63
70
|
api_docs_visible = visible;
|
|
64
|
-
let
|
|
71
|
+
let params = new URLSearchParams(window.location.search);
|
|
65
72
|
if (visible) {
|
|
66
|
-
|
|
73
|
+
params.set("view", "api");
|
|
67
74
|
} else {
|
|
68
|
-
|
|
75
|
+
params.delete("view");
|
|
69
76
|
}
|
|
70
|
-
history.replaceState(null, "", "?" +
|
|
77
|
+
history.replaceState(null, "", "?" + params.toString());
|
|
71
78
|
}
|
|
72
79
|
let api_calls = [];
|
|
73
80
|
export let render_complete = false;
|
|
@@ -124,22 +131,17 @@ export function add_new_message(message, type) {
|
|
|
124
131
|
}
|
|
125
132
|
let _error_id = -1;
|
|
126
133
|
let user_left_page = false;
|
|
127
|
-
document.addEventListener("visibilitychange", function() {
|
|
128
|
-
if (document.visibilityState === "hidden") {
|
|
129
|
-
user_left_page = true;
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
134
|
const MESSAGE_QUOTE_RE = /^'([^]+)'$/;
|
|
133
135
|
const DUPLICATE_MESSAGE = $_("blocks.long_requests_queue");
|
|
134
136
|
const MOBILE_QUEUE_WARNING = $_("blocks.connection_can_break");
|
|
135
137
|
const MOBILE_RECONNECT_MESSAGE = $_("blocks.lost_connection");
|
|
138
|
+
const WAITING_FOR_INPUTS_MESSAGE = $_("blocks.waiting_for_inputs");
|
|
136
139
|
const SHOW_DUPLICATE_MESSAGE_ON_ETA = 15;
|
|
137
140
|
const SHOW_MOBILE_QUEUE_WARNING_ON_ETA = 10;
|
|
138
|
-
|
|
139
|
-
navigator.userAgent
|
|
140
|
-
);
|
|
141
|
+
let is_mobile_device = false;
|
|
141
142
|
let showed_duplicate_message = false;
|
|
142
143
|
let showed_mobile_warning = false;
|
|
144
|
+
let inputs_waiting = [];
|
|
143
145
|
function wait_then_trigger_api_call(dep_index, trigger_id = null, event_data = null) {
|
|
144
146
|
let _unsub = () => {
|
|
145
147
|
};
|
|
@@ -165,6 +167,14 @@ async function get_component_value_or_event_data(component_id, trigger_id, event
|
|
|
165
167
|
}
|
|
166
168
|
async function trigger_api_call(dep_index, trigger_id = null, event_data = null) {
|
|
167
169
|
let dep = dependencies.find((dep2) => dep2.id === dep_index);
|
|
170
|
+
if (inputs_waiting.length > 0) {
|
|
171
|
+
for (const input of inputs_waiting) {
|
|
172
|
+
if (dep.inputs.includes(input)) {
|
|
173
|
+
add_new_message(WAITING_FOR_INPUTS_MESSAGE, "warning");
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
168
178
|
const current_status = loading_status.get_status_for_fn(dep_index);
|
|
169
179
|
messages = messages.filter(({ fn_index }) => fn_index !== dep_index);
|
|
170
180
|
if (current_status === "pending" || current_status === "generating") {
|
|
@@ -188,7 +198,7 @@ async function trigger_api_call(dep_index, trigger_id = null, event_data = null)
|
|
|
188
198
|
).then((v) => {
|
|
189
199
|
if (dep.backend_fn) {
|
|
190
200
|
payload.data = v;
|
|
191
|
-
|
|
201
|
+
trigger_prediction(dep, payload);
|
|
192
202
|
} else {
|
|
193
203
|
handle_update(v, dep_index);
|
|
194
204
|
}
|
|
@@ -203,20 +213,25 @@ async function trigger_api_call(dep_index, trigger_id = null, event_data = null)
|
|
|
203
213
|
);
|
|
204
214
|
} else {
|
|
205
215
|
if (dep.backend_fn) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
216
|
+
trigger_prediction(dep, payload);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function trigger_prediction(dep2, payload2) {
|
|
220
|
+
if (dep2.trigger_mode === "once") {
|
|
221
|
+
if (!dep2.pending_request)
|
|
222
|
+
make_prediction(payload2, dep2.connection == "stream");
|
|
223
|
+
} else if (dep2.trigger_mode === "multiple") {
|
|
224
|
+
make_prediction(payload2, dep2.connection == "stream");
|
|
225
|
+
} else if (dep2.trigger_mode === "always_last") {
|
|
226
|
+
if (!dep2.pending_request) {
|
|
227
|
+
make_prediction(payload2, dep2.connection == "stream");
|
|
228
|
+
} else {
|
|
229
|
+
dep2.final_event = payload2;
|
|
217
230
|
}
|
|
218
231
|
}
|
|
219
232
|
}
|
|
233
|
+
$:
|
|
234
|
+
console.log({ app });
|
|
220
235
|
async function make_prediction(payload2, streaming = false) {
|
|
221
236
|
if (api_recorder_visible) {
|
|
222
237
|
api_calls = [...api_calls, JSON.parse(JSON.stringify(payload2))];
|
|
@@ -231,7 +246,7 @@ async function trigger_api_call(dep_index, trigger_id = null, event_data = null)
|
|
|
231
246
|
} else if (submit_map.has(dep_index) && dep.inputs.some((id) => get_stream_state(id) === "open")) {
|
|
232
247
|
await app.post_data(
|
|
233
248
|
// @ts-ignore
|
|
234
|
-
`${app.config.root}/stream/${submit_map.get(dep_index).event_id()}`,
|
|
249
|
+
`${app.config.root + app.config.api_prefix}/stream/${submit_map.get(dep_index).event_id()}`,
|
|
235
250
|
{ ...payload2, session_hash: app.session_hash }
|
|
236
251
|
);
|
|
237
252
|
return;
|
|
@@ -273,7 +288,7 @@ async function trigger_api_call(dep_index, trigger_id = null, event_data = null)
|
|
|
273
288
|
const { data, fn_index } = message;
|
|
274
289
|
if (dep.pending_request && dep.final_event) {
|
|
275
290
|
dep.pending_request = false;
|
|
276
|
-
make_prediction(dep.final_event);
|
|
291
|
+
make_prediction(dep.final_event, dep.connection == "stream");
|
|
277
292
|
}
|
|
278
293
|
dep.pending_request = false;
|
|
279
294
|
handle_update(data, fn_index);
|
|
@@ -349,12 +364,14 @@ async function trigger_api_call(dep_index, trigger_id = null, event_data = null)
|
|
|
349
364
|
...messages
|
|
350
365
|
];
|
|
351
366
|
}
|
|
352
|
-
if (status.stage === "complete") {
|
|
367
|
+
if (status.stage === "complete" || status.stage === "generating") {
|
|
353
368
|
status.changed_state_ids?.forEach((id) => {
|
|
354
369
|
dependencies.filter((dep2) => dep2.targets.some(([_id, _2]) => _id === id)).forEach((dep2) => {
|
|
355
370
|
wait_then_trigger_api_call(dep2.id, payload2.trigger_id);
|
|
356
371
|
});
|
|
357
372
|
});
|
|
373
|
+
}
|
|
374
|
+
if (status.stage === "complete") {
|
|
358
375
|
dependencies.forEach(async (dep2) => {
|
|
359
376
|
if (dep2.trigger_after === fn_index) {
|
|
360
377
|
wait_then_trigger_api_call(dep2.id, payload2.trigger_id);
|
|
@@ -439,13 +456,19 @@ async function handle_mount() {
|
|
|
439
456
|
wait_then_trigger_api_call(dep.id);
|
|
440
457
|
}
|
|
441
458
|
});
|
|
442
|
-
if (render_complete)
|
|
459
|
+
if (!target || render_complete)
|
|
443
460
|
return;
|
|
444
461
|
target.addEventListener("prop_change", (e) => {
|
|
445
462
|
if (!isCustomEvent(e))
|
|
446
463
|
throw new Error("not a custom event");
|
|
447
464
|
const { id, prop, value } = e.detail;
|
|
448
465
|
update_value([{ id, prop, value }]);
|
|
466
|
+
if (prop === "input_ready" && value === false) {
|
|
467
|
+
inputs_waiting.push(id);
|
|
468
|
+
}
|
|
469
|
+
if (prop === "input_ready" && value === true) {
|
|
470
|
+
inputs_waiting = inputs_waiting.filter((item) => item !== id);
|
|
471
|
+
}
|
|
449
472
|
});
|
|
450
473
|
target.addEventListener("gradio", (e) => {
|
|
451
474
|
if (!isCustomEvent(e))
|
|
@@ -464,7 +487,7 @@ async function handle_mount() {
|
|
|
464
487
|
if (submit_map.has(dep_id)) {
|
|
465
488
|
app.post_data(
|
|
466
489
|
// @ts-ignore
|
|
467
|
-
`${app.config.root}/stream/${submit_map.get(dep_id).event_id()}/close`,
|
|
490
|
+
`${app.config.root + app.config.api_prefix}/stream/${submit_map.get(dep_id).event_id()}/close`,
|
|
468
491
|
{}
|
|
469
492
|
);
|
|
470
493
|
}
|
|
@@ -524,6 +547,16 @@ function set_status(statuses) {
|
|
|
524
547
|
function isCustomEvent(event) {
|
|
525
548
|
return "detail" in event;
|
|
526
549
|
}
|
|
550
|
+
onMount(() => {
|
|
551
|
+
document.addEventListener("visibilitychange", function() {
|
|
552
|
+
if (document.visibilityState === "hidden") {
|
|
553
|
+
user_left_page = true;
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
is_mobile_device = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
557
|
+
navigator.userAgent
|
|
558
|
+
);
|
|
559
|
+
});
|
|
527
560
|
</script>
|
|
528
561
|
|
|
529
562
|
<svelte:head>
|
|
@@ -534,19 +567,19 @@ function isCustomEvent(event) {
|
|
|
534
567
|
|
|
535
568
|
<div class="wrap" style:min-height={app_mode ? "100%" : "auto"}>
|
|
536
569
|
<div class="contain" style:flex-grow={app_mode ? "1" : "auto"}>
|
|
537
|
-
{#if $_layout
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
{/if}
|
|
570
|
+
<!-- {#if $_layout} -->
|
|
571
|
+
<MountComponents
|
|
572
|
+
rootNode={$_layout}
|
|
573
|
+
{root}
|
|
574
|
+
{target}
|
|
575
|
+
{theme_mode}
|
|
576
|
+
on:mount={handle_mount}
|
|
577
|
+
{version}
|
|
578
|
+
{autoscroll}
|
|
579
|
+
{max_file_size}
|
|
580
|
+
client={app}
|
|
581
|
+
/>
|
|
582
|
+
<!-- {/if} -->
|
|
550
583
|
</div>
|
|
551
584
|
|
|
552
585
|
{#if show_footer}
|
|
@@ -24,6 +24,10 @@ declare const __propDef: {
|
|
|
24
24
|
fill_height?: boolean | undefined;
|
|
25
25
|
ready: boolean;
|
|
26
26
|
username: string | null;
|
|
27
|
+
api_prefix: string;
|
|
28
|
+
max_file_size: number;
|
|
29
|
+
initial_layout?: LayoutNode | undefined;
|
|
30
|
+
search_params: URLSearchParams;
|
|
27
31
|
render_complete?: boolean | undefined;
|
|
28
32
|
add_new_message?: ((message: string, type: ToastMessage["type"]) => void) | undefined;
|
|
29
33
|
};
|
|
@@ -14,13 +14,15 @@ onMount(() => {
|
|
|
14
14
|
});
|
|
15
15
|
</script>
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
{#if rootNode}
|
|
18
|
+
<Render
|
|
19
|
+
node={rootNode}
|
|
20
|
+
{root}
|
|
21
|
+
{target}
|
|
22
|
+
{theme_mode}
|
|
23
|
+
{version}
|
|
24
|
+
{autoscroll}
|
|
25
|
+
{max_file_size}
|
|
26
|
+
{client}
|
|
27
|
+
/>
|
|
28
|
+
{/if}
|
package/dist/src/Render.svelte
CHANGED
|
@@ -25,17 +25,20 @@ onMount(() => {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
});
|
|
28
|
-
$:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
$: {
|
|
29
|
+
if (node) {
|
|
30
|
+
node.children = node.children && node.children.filter((v) => {
|
|
31
|
+
const valid_node = node.type !== "statustracker";
|
|
32
|
+
if (!valid_node) {
|
|
33
|
+
filtered_children.push(v);
|
|
34
|
+
}
|
|
35
|
+
return valid_node;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
36
39
|
setContext("BLOCK_KEY", parent);
|
|
37
40
|
$: {
|
|
38
|
-
if (node.type === "form") {
|
|
41
|
+
if (node && node.type === "form") {
|
|
39
42
|
if (node.children?.every((c) => !c.props.visible)) {
|
|
40
43
|
node.props.visible = false;
|
|
41
44
|
} else {
|
|
@@ -44,7 +47,7 @@ $: {
|
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
49
|
$:
|
|
47
|
-
|
|
50
|
+
node.props.gradio = new Gradio(
|
|
48
51
|
node.id,
|
|
49
52
|
target,
|
|
50
53
|
theme_mode,
|
|
@@ -59,7 +62,7 @@ $:
|
|
|
59
62
|
</script>
|
|
60
63
|
|
|
61
64
|
<RenderComponent
|
|
62
|
-
_id={node
|
|
65
|
+
_id={node?.id}
|
|
63
66
|
component={node.component}
|
|
64
67
|
bind:instance={node.instance}
|
|
65
68
|
bind:value={node.props.value}
|
|
@@ -70,7 +73,6 @@ $:
|
|
|
70
73
|
{...node.props}
|
|
71
74
|
{theme_mode}
|
|
72
75
|
{root}
|
|
73
|
-
gradio={gradio_class}
|
|
74
76
|
>
|
|
75
77
|
{#if node.children && node.children.length}
|
|
76
78
|
{#each node.children as _node (_node.id)}
|
|
@@ -7,7 +7,6 @@ export let target;
|
|
|
7
7
|
export let theme_mode;
|
|
8
8
|
export let instance;
|
|
9
9
|
export let value;
|
|
10
|
-
export let gradio;
|
|
11
10
|
export let elem_id;
|
|
12
11
|
export let elem_classes;
|
|
13
12
|
export let _id;
|
|
@@ -19,6 +18,8 @@ function wrap(component2) {
|
|
|
19
18
|
const props = Object.keys(instance2.$$.props);
|
|
20
19
|
function report(props2) {
|
|
21
20
|
return function(propargs) {
|
|
21
|
+
if (!target)
|
|
22
|
+
return;
|
|
22
23
|
const ev = s(_id, props2, propargs);
|
|
23
24
|
target.dispatchEvent(ev);
|
|
24
25
|
};
|
|
@@ -45,7 +46,6 @@ const _component = wrap(component);
|
|
|
45
46
|
{...$$restProps}
|
|
46
47
|
{theme_mode}
|
|
47
48
|
{root}
|
|
48
|
-
{gradio}
|
|
49
49
|
>
|
|
50
50
|
<slot />
|
|
51
51
|
</svelte:component>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { Gradio } from "./gradio_helper";
|
|
3
2
|
import type { ComponentMeta, ThemeMode } from "./types";
|
|
4
3
|
declare const __propDef: {
|
|
5
4
|
props: {
|
|
@@ -10,7 +9,6 @@ declare const __propDef: {
|
|
|
10
9
|
theme_mode: ThemeMode;
|
|
11
10
|
instance: ComponentMeta["instance"];
|
|
12
11
|
value: any;
|
|
13
|
-
gradio: Gradio;
|
|
14
12
|
elem_id: string;
|
|
15
13
|
elem_classes: string[];
|
|
16
14
|
_id: number;
|
package/dist/src/css.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
let supports_adopted_stylesheets = false;
|
|
2
|
-
if ("
|
|
2
|
+
if (typeof window !== "undefined" &&
|
|
3
|
+
"attachShadow" in Element.prototype &&
|
|
3
4
|
"adoptedStyleSheets" in Document.prototype) {
|
|
4
5
|
// Both Shadow DOM and adoptedStyleSheets are supported
|
|
5
6
|
const shadow_root_test = document
|
package/dist/src/init.d.ts
CHANGED
package/dist/src/init.js
CHANGED
|
@@ -3,6 +3,10 @@ import { load_component } from "virtual:component-loader";
|
|
|
3
3
|
import { create_loading_status_store } from "./stores";
|
|
4
4
|
import { _ } from "svelte-i18n";
|
|
5
5
|
let pending_updates = [];
|
|
6
|
+
const is_browser = typeof window !== "undefined";
|
|
7
|
+
const raf = is_browser
|
|
8
|
+
? requestAnimationFrame
|
|
9
|
+
: async (fn) => await fn();
|
|
6
10
|
/**
|
|
7
11
|
* Create a store with the layout and a map of targets
|
|
8
12
|
* @returns A store with the layout and a map of targets
|
|
@@ -21,17 +25,19 @@ export function create_components() {
|
|
|
21
25
|
let app;
|
|
22
26
|
let keyed_component_values = {};
|
|
23
27
|
let _rootNode;
|
|
24
|
-
function
|
|
28
|
+
function set_event_specific_args(dependencies) {
|
|
25
29
|
dependencies.forEach((dep) => {
|
|
26
30
|
dep.targets.forEach((target) => {
|
|
27
31
|
const instance = instance_map[target[0]];
|
|
28
|
-
if (instance && dep.
|
|
29
|
-
|
|
32
|
+
if (instance && dep.event_specific_args?.length > 0) {
|
|
33
|
+
dep.event_specific_args?.forEach((arg) => {
|
|
34
|
+
instance.props[arg] = dep[arg];
|
|
35
|
+
});
|
|
30
36
|
}
|
|
31
37
|
});
|
|
32
38
|
});
|
|
33
39
|
}
|
|
34
|
-
function create_layout({ app: _app, components, layout, dependencies, root, options }) {
|
|
40
|
+
async function create_layout({ app: _app, components, layout, dependencies, root, options }) {
|
|
35
41
|
// make sure the state is settled before proceeding
|
|
36
42
|
flush();
|
|
37
43
|
app = _app;
|
|
@@ -66,10 +72,9 @@ export function create_components() {
|
|
|
66
72
|
acc[c.id] = c;
|
|
67
73
|
return acc;
|
|
68
74
|
}, {});
|
|
69
|
-
walk_layout(layout, root)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
set_stream_every(dependencies);
|
|
75
|
+
await walk_layout(layout, root);
|
|
76
|
+
layout_store.set(_rootNode);
|
|
77
|
+
set_event_specific_args(dependencies);
|
|
73
78
|
}
|
|
74
79
|
/**
|
|
75
80
|
* Rerender the layout when the config has been modified to attach new components
|
|
@@ -118,7 +123,7 @@ export function create_components() {
|
|
|
118
123
|
walk_layout(layout, root, current_element.parent).then(() => {
|
|
119
124
|
layout_store.set(_rootNode);
|
|
120
125
|
});
|
|
121
|
-
|
|
126
|
+
set_event_specific_args(dependencies);
|
|
122
127
|
}
|
|
123
128
|
async function walk_layout(node, root, parent) {
|
|
124
129
|
const instance = instance_map[node.id];
|
|
@@ -190,7 +195,7 @@ export function create_components() {
|
|
|
190
195
|
if (!update_scheduled) {
|
|
191
196
|
update_scheduled = true;
|
|
192
197
|
update_scheduled_store.set(true);
|
|
193
|
-
|
|
198
|
+
raf(flush);
|
|
194
199
|
}
|
|
195
200
|
}
|
|
196
201
|
function get_data(id) {
|
|
@@ -231,7 +236,7 @@ export function create_components() {
|
|
|
231
236
|
set_time_limit,
|
|
232
237
|
loading_status,
|
|
233
238
|
scheduled_updates: update_scheduled_store,
|
|
234
|
-
create_layout:
|
|
239
|
+
create_layout: create_layout,
|
|
235
240
|
rerender_layout
|
|
236
241
|
};
|
|
237
242
|
}
|
package/dist/src/lang/en.json
CHANGED
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"blocks": {
|
|
23
23
|
"connection_can_break": "On mobile, the connection can break if this tab is unfocused or the device sleeps, losing your position in queue.",
|
|
24
24
|
"long_requests_queue": "There is a long queue of requests pending. Duplicate this Space to skip.",
|
|
25
|
-
"lost_connection": "Lost connection due to leaving page. Rejoining queue..."
|
|
25
|
+
"lost_connection": "Lost connection due to leaving page. Rejoining queue...",
|
|
26
|
+
"waiting_for_inputs": "Waiting for file(s) to finish uploading, please retry."
|
|
26
27
|
},
|
|
27
28
|
"checkbox": {
|
|
28
29
|
"checkbox": "Checkbox",
|
package/dist/src/types.d.ts
CHANGED