@gradio/core 0.16.1 → 0.18.0
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 +43 -0
- package/dist/src/Blocks.svelte +75 -4
- package/dist/src/Render.svelte +2 -2
- package/dist/src/RenderComponent.svelte +21 -1
- package/dist/src/api_docs/ApiDocs.svelte +6 -1
- package/dist/src/api_docs/Settings.svelte +74 -1
- package/dist/src/api_docs/Settings.svelte.d.ts +3 -0
- package/dist/src/api_docs/img/record-stop.svg +1 -0
- package/dist/src/api_docs/img/record.svg +1 -0
- package/dist/src/gradio_helper.d.ts +1 -11
- package/dist/src/gradio_helper.js +3 -19
- package/dist/src/i18n.d.ts +12 -5
- package/dist/src/i18n.js +93 -12
- package/dist/src/init.js +40 -20
- package/dist/src/lang/en.json +6 -1
- package/dist/src/lang/es.json +2 -1
- package/dist/src/lang/fr.json +2 -1
- package/dist/src/lang/ja.json +2 -1
- package/dist/src/lang/ko.json +2 -1
- package/dist/src/lang/lt.json +2 -1
- package/dist/src/lang/nb.json +2 -1
- package/dist/src/lang/nl.json +2 -1
- package/dist/src/lang/pl.json +2 -1
- package/dist/src/lang/pt-BR.json +1 -0
- package/dist/src/lang/pt.json +2 -1
- package/dist/src/lang/ro.json +2 -1
- package/dist/src/lang/ru.json +2 -1
- package/dist/src/lang/sv.json +2 -1
- package/dist/src/lang/ta.json +2 -1
- package/dist/src/lang/th.json +2 -1
- package/dist/src/lang/tr.json +2 -1
- package/dist/src/lang/uk.json +2 -1
- package/dist/src/lang/ur.json +2 -1
- package/dist/src/lang/uz.json +2 -1
- package/dist/src/lang/zh-CN.json +2 -1
- package/dist/src/lang/zh-TW.json +2 -1
- package/dist/src/screen_recorder.d.ts +16 -0
- package/dist/src/screen_recorder.js +255 -0
- package/package.json +53 -53
- package/src/Blocks.svelte +86 -6
- package/src/Render.svelte +2 -2
- package/src/RenderComponent.svelte +21 -1
- package/src/api_docs/ApiDocs.svelte +7 -1
- package/src/api_docs/Settings.svelte +77 -1
- package/src/api_docs/img/record-stop.svg +1 -0
- package/src/api_docs/img/record.svg +1 -0
- package/src/gradio_helper.ts +5 -21
- package/src/i18n.test.ts +120 -1
- package/src/i18n.ts +126 -24
- package/src/init.ts +48 -26
- package/src/lang/en.json +6 -1
- package/src/lang/es.json +2 -1
- package/src/lang/fr.json +2 -1
- package/src/lang/ja.json +2 -1
- package/src/lang/ko.json +2 -1
- package/src/lang/lt.json +2 -1
- package/src/lang/nb.json +2 -1
- package/src/lang/nl.json +2 -1
- package/src/lang/pl.json +2 -1
- package/src/lang/pt-BR.json +1 -0
- package/src/lang/pt.json +2 -1
- package/src/lang/ro.json +2 -1
- package/src/lang/ru.json +2 -1
- package/src/lang/sv.json +2 -1
- package/src/lang/ta.json +2 -1
- package/src/lang/th.json +2 -1
- package/src/lang/tr.json +2 -1
- package/src/lang/uk.json +2 -1
- package/src/lang/ur.json +2 -1
- package/src/lang/uz.json +2 -1
- package/src/lang/zh-CN.json +2 -1
- package/src/lang/zh-TW.json +2 -1
- package/src/screen_recorder.ts +361 -0
package/package.json
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@gradio/
|
|
7
|
-
"@gradio/
|
|
8
|
-
"@gradio/
|
|
9
|
-
"@gradio/
|
|
10
|
-
"@gradio/
|
|
11
|
-
"@gradio/
|
|
12
|
-
"@gradio/checkbox": "^0.4.
|
|
13
|
-
"@gradio/
|
|
14
|
-
"@gradio/
|
|
15
|
-
"@gradio/
|
|
16
|
-
"@gradio/
|
|
17
|
-
"@gradio/colorpicker": "^0.4.
|
|
6
|
+
"@gradio/accordion": "^0.5.15",
|
|
7
|
+
"@gradio/annotatedimage": "^0.9.19",
|
|
8
|
+
"@gradio/box": "^0.2.19",
|
|
9
|
+
"@gradio/atoms": "^0.16.1",
|
|
10
|
+
"@gradio/audio": "^0.17.14",
|
|
11
|
+
"@gradio/button": "^0.5.0",
|
|
12
|
+
"@gradio/checkbox": "^0.4.21",
|
|
13
|
+
"@gradio/checkboxgroup": "^0.6.21",
|
|
14
|
+
"@gradio/chatbot": "^0.26.8",
|
|
15
|
+
"@gradio/code": "^0.14.4",
|
|
16
|
+
"@gradio/client": "^1.15.0",
|
|
17
|
+
"@gradio/colorpicker": "^0.4.21",
|
|
18
18
|
"@gradio/column": "^0.2.0",
|
|
19
|
-
"@gradio/dataframe": "^0.17.
|
|
20
|
-
"@gradio/dataset": "^0.4.
|
|
21
|
-
"@gradio/downloadbutton": "^0.
|
|
22
|
-
"@gradio/datetime": "^0.3.
|
|
23
|
-
"@gradio/dropdown": "^0.9.
|
|
24
|
-
"@gradio/fallback": "^0.4.
|
|
25
|
-
"@gradio/
|
|
26
|
-
"@gradio/
|
|
27
|
-
"@gradio/form": "^0.2.
|
|
28
|
-
"@gradio/gallery": "^0.15.
|
|
29
|
-
"@gradio/highlightedtext": "^0.9.3",
|
|
19
|
+
"@gradio/dataframe": "^0.17.12",
|
|
20
|
+
"@gradio/dataset": "^0.4.19",
|
|
21
|
+
"@gradio/downloadbutton": "^0.4.0",
|
|
22
|
+
"@gradio/datetime": "^0.3.13",
|
|
23
|
+
"@gradio/dropdown": "^0.9.21",
|
|
24
|
+
"@gradio/fallback": "^0.4.21",
|
|
25
|
+
"@gradio/file": "^0.12.18",
|
|
26
|
+
"@gradio/fileexplorer": "^0.5.29",
|
|
27
|
+
"@gradio/form": "^0.2.19",
|
|
28
|
+
"@gradio/gallery": "^0.15.19",
|
|
30
29
|
"@gradio/group": "^0.2.0",
|
|
30
|
+
"@gradio/html": "^0.6.13",
|
|
31
|
+
"@gradio/highlightedtext": "^0.9.4",
|
|
31
32
|
"@gradio/icons": "^0.12.0",
|
|
32
|
-
"@gradio/image": "^0.22.
|
|
33
|
-
"@gradio/
|
|
34
|
-
"@gradio/
|
|
35
|
-
"@gradio/
|
|
36
|
-
"@gradio/json": "^0.5.20",
|
|
33
|
+
"@gradio/image": "^0.22.6",
|
|
34
|
+
"@gradio/imageslider": "^0.2.2",
|
|
35
|
+
"@gradio/label": "^0.5.13",
|
|
36
|
+
"@gradio/imageeditor": "^0.15.0",
|
|
37
37
|
"@gradio/browserstate": "^0.3.2",
|
|
38
|
-
"@gradio/
|
|
39
|
-
"@gradio/model3d": "^0.14.
|
|
40
|
-
"@gradio/
|
|
41
|
-
"@gradio/
|
|
42
|
-
"@gradio/
|
|
43
|
-
"@gradio/
|
|
44
|
-
"@gradio/
|
|
45
|
-
"@gradio/
|
|
46
|
-
"@gradio/
|
|
38
|
+
"@gradio/json": "^0.5.23",
|
|
39
|
+
"@gradio/model3d": "^0.14.14",
|
|
40
|
+
"@gradio/multimodaltextbox": "^0.10.6",
|
|
41
|
+
"@gradio/markdown": "^0.13.13",
|
|
42
|
+
"@gradio/number": "^0.5.21",
|
|
43
|
+
"@gradio/nativeplot": "^0.5.16",
|
|
44
|
+
"@gradio/plot": "^0.9.16",
|
|
45
|
+
"@gradio/paramviewer": "^0.7.9",
|
|
46
|
+
"@gradio/radio": "^0.7.4",
|
|
47
|
+
"@gradio/sidebar": "^0.1.13",
|
|
47
48
|
"@gradio/row": "^0.2.1",
|
|
48
|
-
"@gradio/
|
|
49
|
-
"@gradio/
|
|
50
|
-
"@gradio/simpleimage": "^0.8.
|
|
51
|
-
"@gradio/
|
|
52
|
-
"@gradio/simpletextbox": "^0.3.20",
|
|
49
|
+
"@gradio/simpledropdown": "^0.3.21",
|
|
50
|
+
"@gradio/simpletextbox": "^0.3.21",
|
|
51
|
+
"@gradio/simpleimage": "^0.8.29",
|
|
52
|
+
"@gradio/slider": "^0.6.10",
|
|
53
53
|
"@gradio/state": "^0.1.2",
|
|
54
|
-
"@gradio/
|
|
55
|
-
"@gradio/
|
|
56
|
-
"@gradio/
|
|
57
|
-
"@gradio/tabs": "^0.4.
|
|
58
|
-
"@gradio/textbox": "^0.10.
|
|
59
|
-
"@gradio/theme": "^0.4.0",
|
|
54
|
+
"@gradio/sketchbox": "^0.6.8",
|
|
55
|
+
"@gradio/statustracker": "^0.10.11",
|
|
56
|
+
"@gradio/tabitem": "^0.4.4",
|
|
57
|
+
"@gradio/tabs": "^0.4.4",
|
|
58
|
+
"@gradio/textbox": "^0.10.11",
|
|
60
59
|
"@gradio/timer": "^0.4.5",
|
|
61
|
-
"@gradio/
|
|
62
|
-
"@gradio/
|
|
63
|
-
"@gradio/
|
|
60
|
+
"@gradio/theme": "^0.4.0",
|
|
61
|
+
"@gradio/upload": "^0.16.5",
|
|
62
|
+
"@gradio/uploadbutton": "^0.9.0",
|
|
63
|
+
"@gradio/video": "^0.14.14",
|
|
64
64
|
"@gradio/utils": "^0.10.2",
|
|
65
|
-
"@gradio/
|
|
65
|
+
"@gradio/wasm": "^0.18.1"
|
|
66
66
|
},
|
|
67
67
|
"msw": {
|
|
68
68
|
"workerDirectory": "public"
|
package/src/Blocks.svelte
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { tick, onMount } from "svelte";
|
|
3
3
|
import { _ } from "svelte-i18n";
|
|
4
4
|
import { Client } from "@gradio/client";
|
|
5
|
+
import { writable } from "svelte/store";
|
|
5
6
|
|
|
6
7
|
import type { LoadingStatus, LoadingStatusCollection } from "./stores";
|
|
7
8
|
|
|
@@ -19,14 +20,14 @@
|
|
|
19
20
|
import logo from "./images/logo.svg";
|
|
20
21
|
import api_logo from "./api_docs/img/api-logo.svg";
|
|
21
22
|
import settings_logo from "./api_docs/img/settings-logo.svg";
|
|
23
|
+
import record_stop from "./api_docs/img/record-stop.svg";
|
|
22
24
|
import { create_components, AsyncFunction } from "./init";
|
|
23
25
|
import type {
|
|
24
26
|
LogMessage,
|
|
25
27
|
RenderMessage,
|
|
26
28
|
StatusMessage
|
|
27
29
|
} from "@gradio/client";
|
|
28
|
-
|
|
29
|
-
setupi18n();
|
|
30
|
+
import * as screen_recorder from "./screen_recorder";
|
|
30
31
|
|
|
31
32
|
export let root: string;
|
|
32
33
|
export let components: ComponentMeta[];
|
|
@@ -52,6 +53,8 @@
|
|
|
52
53
|
export let initial_layout: ComponentMeta | undefined = undefined;
|
|
53
54
|
export let css: string | null | undefined = null;
|
|
54
55
|
|
|
56
|
+
setupi18n(app.config?.i18n_translations ?? undefined);
|
|
57
|
+
|
|
55
58
|
let {
|
|
56
59
|
layout: _layout,
|
|
57
60
|
targets,
|
|
@@ -97,6 +100,8 @@
|
|
|
97
100
|
let settings_visible = search_params.get("view") === "settings";
|
|
98
101
|
let api_recorder_visible =
|
|
99
102
|
search_params.get("view") === "api-recorder" && show_api;
|
|
103
|
+
let allow_zoom = true;
|
|
104
|
+
let allow_video_trim = true;
|
|
100
105
|
|
|
101
106
|
function set_api_docs_visible(visible: boolean): void {
|
|
102
107
|
api_recorder_visible = false;
|
|
@@ -126,11 +131,28 @@
|
|
|
126
131
|
export let render_complete = false;
|
|
127
132
|
async function handle_update(data: any, fn_index: number): Promise<void> {
|
|
128
133
|
const dep = dependencies.find((dep) => dep.id === fn_index);
|
|
134
|
+
const input_type = components.find(
|
|
135
|
+
(comp) => comp.id === dep?.inputs[0]
|
|
136
|
+
)?.type;
|
|
137
|
+
if (allow_zoom && dep && input_type !== "dataset") {
|
|
138
|
+
if (dep && dep.inputs && dep.inputs.length > 0 && $is_screen_recording) {
|
|
139
|
+
screen_recorder.zoom(true, dep.inputs, 1.0);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (
|
|
143
|
+
dep &&
|
|
144
|
+
dep.outputs &&
|
|
145
|
+
dep.outputs.length > 0 &&
|
|
146
|
+
$is_screen_recording
|
|
147
|
+
) {
|
|
148
|
+
screen_recorder.zoom(false, dep.outputs, 2.0);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
129
152
|
if (!dep) {
|
|
130
153
|
return;
|
|
131
154
|
}
|
|
132
155
|
const outputs = dep.outputs;
|
|
133
|
-
|
|
134
156
|
const meta_updates = data?.map((value: any, i: number) => {
|
|
135
157
|
return {
|
|
136
158
|
id: outputs[i],
|
|
@@ -372,6 +394,9 @@
|
|
|
372
394
|
payload: Payload,
|
|
373
395
|
streaming = false
|
|
374
396
|
): Promise<void> {
|
|
397
|
+
if (allow_video_trim) {
|
|
398
|
+
screen_recorder.markRemoveSegmentStart();
|
|
399
|
+
}
|
|
375
400
|
if (api_recorder_visible) {
|
|
376
401
|
api_calls = [...api_calls, JSON.parse(JSON.stringify(payload))];
|
|
377
402
|
}
|
|
@@ -601,6 +626,9 @@
|
|
|
601
626
|
});
|
|
602
627
|
}
|
|
603
628
|
}
|
|
629
|
+
if (allow_video_trim) {
|
|
630
|
+
screen_recorder.markRemoveSegmentEnd();
|
|
631
|
+
}
|
|
604
632
|
}
|
|
605
633
|
}
|
|
606
634
|
/* eslint-enable complexity */
|
|
@@ -773,6 +801,8 @@
|
|
|
773
801
|
return "detail" in event;
|
|
774
802
|
}
|
|
775
803
|
|
|
804
|
+
let is_screen_recording = writable(false);
|
|
805
|
+
|
|
776
806
|
onMount(() => {
|
|
777
807
|
document.addEventListener("visibilitychange", function () {
|
|
778
808
|
if (document.visibilityState === "hidden") {
|
|
@@ -784,7 +814,25 @@
|
|
|
784
814
|
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
785
815
|
navigator.userAgent
|
|
786
816
|
);
|
|
817
|
+
|
|
818
|
+
screen_recorder.initialize(
|
|
819
|
+
root,
|
|
820
|
+
(title, message, type) => {
|
|
821
|
+
add_new_message(title, message, type);
|
|
822
|
+
},
|
|
823
|
+
(isRecording) => {
|
|
824
|
+
$is_screen_recording = isRecording;
|
|
825
|
+
}
|
|
826
|
+
);
|
|
787
827
|
});
|
|
828
|
+
|
|
829
|
+
function screen_recording(): void {
|
|
830
|
+
if ($is_screen_recording) {
|
|
831
|
+
screen_recorder.stopRecording();
|
|
832
|
+
} else {
|
|
833
|
+
screen_recorder.startRecording();
|
|
834
|
+
}
|
|
835
|
+
}
|
|
788
836
|
</script>
|
|
789
837
|
|
|
790
838
|
<svelte:head>
|
|
@@ -822,7 +870,11 @@
|
|
|
822
870
|
}}
|
|
823
871
|
class="show-api"
|
|
824
872
|
>
|
|
825
|
-
{
|
|
873
|
+
{#if app.config?.mcp_server}
|
|
874
|
+
{$_("errors.use_via_api_or_mcp")}
|
|
875
|
+
{:else}
|
|
876
|
+
{$_("errors.use_via_api")}
|
|
877
|
+
{/if}
|
|
826
878
|
<img src={api_logo} alt={$_("common.logo")} />
|
|
827
879
|
</button>
|
|
828
880
|
<div class="divider show-api-divider">·</div>
|
|
@@ -836,6 +888,17 @@
|
|
|
836
888
|
{$_("common.built_with_gradio")}
|
|
837
889
|
<img src={logo} alt={$_("common.logo")} />
|
|
838
890
|
</a>
|
|
891
|
+
<div class="divider" class:hidden={!$is_screen_recording}>·</div>
|
|
892
|
+
<button
|
|
893
|
+
class:hidden={!$is_screen_recording}
|
|
894
|
+
on:click={() => {
|
|
895
|
+
screen_recording();
|
|
896
|
+
}}
|
|
897
|
+
class="record"
|
|
898
|
+
>
|
|
899
|
+
{$_("common.stop_recording")}
|
|
900
|
+
<img src={record_stop} alt={$_("common.stop_recording")} />
|
|
901
|
+
</button>
|
|
839
902
|
<div class="divider">·</div>
|
|
840
903
|
<button
|
|
841
904
|
on:click={() => {
|
|
@@ -908,9 +971,14 @@
|
|
|
908
971
|
/>
|
|
909
972
|
<div class="api-docs-wrap">
|
|
910
973
|
<Settings
|
|
974
|
+
bind:allow_zoom
|
|
975
|
+
bind:allow_video_trim
|
|
911
976
|
on:close={(event) => {
|
|
912
977
|
set_settings_visible(false);
|
|
913
978
|
}}
|
|
979
|
+
on:start_recording={(event) => {
|
|
980
|
+
screen_recording();
|
|
981
|
+
}}
|
|
914
982
|
pwa_enabled={app.config.pwa}
|
|
915
983
|
{root}
|
|
916
984
|
{space_id}
|
|
@@ -950,7 +1018,8 @@
|
|
|
950
1018
|
}
|
|
951
1019
|
|
|
952
1020
|
.show-api,
|
|
953
|
-
.settings
|
|
1021
|
+
.settings,
|
|
1022
|
+
.record {
|
|
954
1023
|
display: flex;
|
|
955
1024
|
align-items: center;
|
|
956
1025
|
}
|
|
@@ -970,13 +1039,20 @@
|
|
|
970
1039
|
width: var(--size-4);
|
|
971
1040
|
}
|
|
972
1041
|
|
|
1042
|
+
.record img {
|
|
1043
|
+
margin-right: var(--size-1);
|
|
1044
|
+
margin-left: var(--size-1);
|
|
1045
|
+
width: var(--size-3);
|
|
1046
|
+
}
|
|
1047
|
+
|
|
973
1048
|
.built-with {
|
|
974
1049
|
display: flex;
|
|
975
1050
|
align-items: center;
|
|
976
1051
|
}
|
|
977
1052
|
|
|
978
1053
|
.built-with:hover,
|
|
979
|
-
.settings:hover
|
|
1054
|
+
.settings:hover,
|
|
1055
|
+
.record:hover {
|
|
980
1056
|
color: var(--body-text-color);
|
|
981
1057
|
}
|
|
982
1058
|
|
|
@@ -1047,4 +1123,8 @@
|
|
|
1047
1123
|
.show-api:hover {
|
|
1048
1124
|
color: var(--body-text-color);
|
|
1049
1125
|
}
|
|
1126
|
+
|
|
1127
|
+
.hidden {
|
|
1128
|
+
display: none;
|
|
1129
|
+
}
|
|
1050
1130
|
</style>
|
package/src/Render.svelte
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { Gradio,
|
|
2
|
+
import { Gradio, reactive_formatter } from "./gradio_helper";
|
|
3
3
|
import { onMount, createEventDispatcher, setContext } from "svelte";
|
|
4
4
|
import type { ComponentMeta, ThemeMode } from "./types";
|
|
5
5
|
import type { Client } from "@gradio/client";
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
root,
|
|
71
71
|
autoscroll,
|
|
72
72
|
max_file_size,
|
|
73
|
-
|
|
73
|
+
$reactive_formatter,
|
|
74
74
|
client,
|
|
75
75
|
load_component
|
|
76
76
|
);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<svelte:options immutable={true} />
|
|
2
2
|
|
|
3
3
|
<script lang="ts">
|
|
4
|
-
import type { Gradio } from "./gradio_helper";
|
|
5
4
|
import type { ComponentMeta, ThemeMode } from "./types";
|
|
6
5
|
import type { SvelteComponent, ComponentType } from "svelte";
|
|
6
|
+
import { translate_if_needed } from "./i18n";
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
import { bind, binding_callbacks } from "svelte/internal";
|
|
9
9
|
|
|
@@ -50,6 +50,26 @@
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const _component = wrap(component);
|
|
53
|
+
|
|
54
|
+
const supported_props = [
|
|
55
|
+
"description",
|
|
56
|
+
"info",
|
|
57
|
+
"title",
|
|
58
|
+
"placeholder",
|
|
59
|
+
"value",
|
|
60
|
+
"label"
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
function translate_prop(obj: SvelteRestProps): void {
|
|
64
|
+
for (const key in obj) {
|
|
65
|
+
if (supported_props.includes(key as string)) {
|
|
66
|
+
obj[key] = translate_if_needed(obj[key]);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
$: translate_prop($$restProps);
|
|
72
|
+
$: value = translate_if_needed(value);
|
|
53
73
|
</script>
|
|
54
74
|
|
|
55
75
|
<!-- {#if visible} -->
|
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
const bash_docs =
|
|
36
36
|
"https://www.gradio.app/guides/querying-gradio-apps-with-curl";
|
|
37
37
|
const spaces_docs_suffix = "#connecting-to-a-hugging-face-space";
|
|
38
|
+
const mcp_docs =
|
|
39
|
+
"https://www.gradio.app/guides/building-mcp-server-with-gradio";
|
|
38
40
|
|
|
39
41
|
let api_count = dependencies.filter(
|
|
40
42
|
(dependency) => dependency.show_api
|
|
@@ -379,7 +381,11 @@
|
|
|
379
381
|
</code>
|
|
380
382
|
</Block>
|
|
381
383
|
<p> </p>
|
|
382
|
-
<p
|
|
384
|
+
<p>
|
|
385
|
+
<a href={mcp_docs} target="_blank">
|
|
386
|
+
Read more about MCP in the Gradio docs
|
|
387
|
+
</a>
|
|
388
|
+
</p>
|
|
383
389
|
{:else}
|
|
384
390
|
This Gradio app can also serve as an MCP server, with an MCP
|
|
385
391
|
tool corresponding to each API endpoint. To enable this, launch
|
|
@@ -6,10 +6,14 @@
|
|
|
6
6
|
export let space_id: string | null;
|
|
7
7
|
export let pwa_enabled: boolean | undefined;
|
|
8
8
|
import { BaseDropdown as Dropdown } from "@gradio/dropdown";
|
|
9
|
+
import { BaseCheckbox as Checkbox } from "@gradio/checkbox";
|
|
9
10
|
import { language_choices, changeLocale } from "../i18n";
|
|
10
11
|
import { locale, _ } from "svelte-i18n";
|
|
11
12
|
import { setupi18n } from "../i18n";
|
|
13
|
+
import record from "./img/record.svg";
|
|
14
|
+
import { createEventDispatcher } from "svelte";
|
|
12
15
|
|
|
16
|
+
const dispatch = createEventDispatcher();
|
|
13
17
|
if (root === "") {
|
|
14
18
|
root = location.protocol + "//" + location.host + location.pathname;
|
|
15
19
|
}
|
|
@@ -44,6 +48,8 @@
|
|
|
44
48
|
|
|
45
49
|
let current_locale: string;
|
|
46
50
|
let current_theme: "light" | "dark" | "system" = "system";
|
|
51
|
+
export let allow_zoom = true;
|
|
52
|
+
export let allow_video_trim = true;
|
|
47
53
|
|
|
48
54
|
locale.subscribe((value) => {
|
|
49
55
|
if (value) {
|
|
@@ -55,6 +61,15 @@
|
|
|
55
61
|
const new_locale = e.detail;
|
|
56
62
|
changeLocale(new_locale);
|
|
57
63
|
}
|
|
64
|
+
|
|
65
|
+
function handleZoomChange(e: CustomEvent): void {
|
|
66
|
+
allow_zoom = e.detail;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function handleVideoTrimChange(e: CustomEvent): void {
|
|
70
|
+
allow_video_trim = e.detail;
|
|
71
|
+
}
|
|
72
|
+
|
|
58
73
|
setupi18n();
|
|
59
74
|
</script>
|
|
60
75
|
|
|
@@ -120,6 +135,44 @@
|
|
|
120
135
|
{/if}
|
|
121
136
|
</p>
|
|
122
137
|
</div>
|
|
138
|
+
<div class="banner-wrap">
|
|
139
|
+
<h2>{$_("common.screen_studio")} <span class="beta-tag">beta</span></h2>
|
|
140
|
+
<p class="padded">
|
|
141
|
+
Screen Studio allows you to record your screen and generates a video of your
|
|
142
|
+
app with automatically adding zoom in and zoom out effects as well as
|
|
143
|
+
trimming the video to remove the prediction time.
|
|
144
|
+
<br /><br />
|
|
145
|
+
Start recording by clicking the <i>Start Recording</i> button below and then
|
|
146
|
+
sharing the current browser tab of your Gradio demo. Use your app as you
|
|
147
|
+
would normally to generate a prediction.
|
|
148
|
+
<br />
|
|
149
|
+
Stop recording by clicking the <i>Stop Recording</i> button in the footer of
|
|
150
|
+
the demo.
|
|
151
|
+
<br /><br />
|
|
152
|
+
<Checkbox
|
|
153
|
+
label="Include automatic zoom in/out"
|
|
154
|
+
interactive={true}
|
|
155
|
+
value={allow_zoom}
|
|
156
|
+
on:change={handleZoomChange}
|
|
157
|
+
/>
|
|
158
|
+
<Checkbox
|
|
159
|
+
label="Include automatic video trimming"
|
|
160
|
+
interactive={true}
|
|
161
|
+
value={allow_video_trim}
|
|
162
|
+
on:change={handleVideoTrimChange}
|
|
163
|
+
/>
|
|
164
|
+
</p>
|
|
165
|
+
<button
|
|
166
|
+
class="record-button"
|
|
167
|
+
on:click={() => {
|
|
168
|
+
dispatch("close");
|
|
169
|
+
dispatch("start_recording");
|
|
170
|
+
}}
|
|
171
|
+
>
|
|
172
|
+
<img src={record} alt="Start Recording" />
|
|
173
|
+
Start Recording
|
|
174
|
+
</button>
|
|
175
|
+
</div>
|
|
123
176
|
|
|
124
177
|
<style>
|
|
125
178
|
.banner-wrap {
|
|
@@ -150,7 +203,8 @@
|
|
|
150
203
|
margin-left: var(--size-2);
|
|
151
204
|
}
|
|
152
205
|
|
|
153
|
-
.theme-button
|
|
206
|
+
.theme-button,
|
|
207
|
+
.record-button {
|
|
154
208
|
display: flex;
|
|
155
209
|
align-items: center;
|
|
156
210
|
border: 1px solid var(--border-color-primary);
|
|
@@ -162,6 +216,15 @@
|
|
|
162
216
|
cursor: pointer;
|
|
163
217
|
}
|
|
164
218
|
|
|
219
|
+
.record-button img {
|
|
220
|
+
margin-right: var(--size-1);
|
|
221
|
+
margin-left: var(--size-1);
|
|
222
|
+
width: var(--size-3);
|
|
223
|
+
}
|
|
224
|
+
.record-button:hover {
|
|
225
|
+
border-color: red;
|
|
226
|
+
}
|
|
227
|
+
|
|
165
228
|
.current-theme {
|
|
166
229
|
border: 1px solid var(--body-text-color-subdued);
|
|
167
230
|
color: var(--body-text-color);
|
|
@@ -181,4 +244,17 @@
|
|
|
181
244
|
all: unset;
|
|
182
245
|
cursor: pointer;
|
|
183
246
|
}
|
|
247
|
+
|
|
248
|
+
.beta-tag {
|
|
249
|
+
position: relative;
|
|
250
|
+
top: -5px;
|
|
251
|
+
font-size: var(--text-xs);
|
|
252
|
+
background-color: var(--color-accent);
|
|
253
|
+
color: white;
|
|
254
|
+
padding: 2px 6px;
|
|
255
|
+
border-radius: 10px;
|
|
256
|
+
margin-left: 5px;
|
|
257
|
+
font-weight: normal;
|
|
258
|
+
text-transform: uppercase;
|
|
259
|
+
}
|
|
184
260
|
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <title>record [#982]</title> <desc>Created with Sketch.</desc> <defs> </defs> <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> <g id="Dribbble-Light-Preview" transform="translate(-380.000000, -3839.000000)" fill="#FF0000"> <g id="icons" transform="translate(56.000000, 160.000000)"> <path d="M338,3689 C338,3691.209 336.209,3693 334,3693 C331.791,3693 330,3691.209 330,3689 C330,3686.791 331.791,3685 334,3685 C336.209,3685 338,3686.791 338,3689 M334,3697 C329.589,3697 326,3693.411 326,3689 C326,3684.589 329.589,3681 334,3681 C338.411,3681 342,3684.589 342,3689 C342,3693.411 338.411,3697 334,3697 M334,3679 C328.477,3679 324,3683.477 324,3689 C324,3694.523 328.477,3699 334,3699 C339.523,3699 344,3694.523 344,3689 C344,3683.477 339.523,3679 334,3679" id="record-[#982]"> </path> </g> </g> </g> </g></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <title>record [#982]</title> <desc>Created with Sketch.</desc> <defs> </defs> <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> <g id="Dribbble-Light-Preview" transform="translate(-380.000000, -3839.000000)" fill="#808080"> <g id="icons" transform="translate(56.000000, 160.000000)"> <path d="M338,3689 C338,3691.209 336.209,3693 334,3693 C331.791,3693 330,3691.209 330,3689 C330,3686.791 331.791,3685 334,3685 C336.209,3685 338,3686.791 338,3689 M334,3697 C329.589,3697 326,3693.411 326,3689 C326,3684.589 329.589,3681 334,3681 C338.411,3681 342,3684.589 342,3689 C342,3693.411 338.411,3697 334,3697 M334,3679 C328.477,3679 324,3683.477 324,3689 C324,3694.523 328.477,3699 334,3699 C339.523,3699 344,3694.523 344,3689 C344,3683.477 339.523,3679 334,3679" id="record-[#982]"> </path> </g> </g> </g> </g></svg>
|
package/src/gradio_helper.ts
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
|
-
import { format, _ } from "svelte-i18n";
|
|
2
|
-
import { get } from "svelte/store";
|
|
3
1
|
import { all_common_keys } from "./i18n";
|
|
4
|
-
|
|
2
|
+
import { _ } from "svelte-i18n";
|
|
3
|
+
import { get, derived } from "svelte/store";
|
|
5
4
|
export { Gradio } from "@gradio/utils";
|
|
5
|
+
|
|
6
6
|
export type I18nFormatter = typeof formatter;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* i18n formatter with fallback to svelte-i18n's format function.
|
|
10
|
-
*
|
|
11
|
-
* @param value - The string to translate or format
|
|
12
|
-
* @returns The translated string
|
|
13
|
-
*
|
|
14
|
-
* This formatter attempts translation in the following order:
|
|
15
|
-
* 1. Direct translation of the input string
|
|
16
|
-
* 2. Checks if input matches any common key names
|
|
17
|
-
* 3. Falls back to svelte-i18n's format function
|
|
18
|
-
*/
|
|
19
8
|
export function formatter(value: string | null | undefined): string {
|
|
20
9
|
if (value == null) {
|
|
21
10
|
return "";
|
|
22
11
|
}
|
|
23
12
|
const string_value = String(value);
|
|
24
13
|
const translate = get(_);
|
|
25
|
-
const initial_formatter = get(format);
|
|
26
14
|
|
|
27
15
|
let direct_translation = translate(string_value);
|
|
28
16
|
|
|
@@ -45,11 +33,7 @@ export function formatter(value: string | null | undefined): string {
|
|
|
45
33
|
}
|
|
46
34
|
}
|
|
47
35
|
|
|
48
|
-
// fall back to the svelte-i18n formatter to maintain compatibility
|
|
49
|
-
const formatted = initial_formatter(string_value);
|
|
50
|
-
if (formatted !== string_value) {
|
|
51
|
-
return formatted;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
36
|
return string_value;
|
|
55
37
|
}
|
|
38
|
+
|
|
39
|
+
export const reactive_formatter = derived(_, () => formatter);
|