@gradio/video 0.17.0-dev.0 → 0.17.0-dev.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 +27 -0
- package/Index.svelte +98 -122
- package/Video.test.ts +2 -2
- package/dist/Example.svelte +20 -16
- package/dist/Example.svelte.d.ts +21 -19
- package/dist/Index.svelte +127 -114
- package/dist/Index.svelte.d.ts +3 -155
- package/dist/shared/InteractiveVideo.svelte +79 -51
- package/dist/shared/InteractiveVideo.svelte.d.ts +57 -47
- package/dist/shared/Player.svelte +103 -71
- package/dist/shared/Player.svelte.d.ts +44 -42
- package/dist/shared/Video.svelte +77 -62
- package/dist/shared/Video.svelte.d.ts +44 -36
- package/dist/shared/VideoControls.svelte +49 -40
- package/dist/shared/VideoControls.svelte.d.ts +29 -27
- package/dist/shared/VideoPreview.svelte +58 -37
- package/dist/shared/VideoPreview.svelte.d.ts +37 -35
- package/dist/shared/VideoTimeline.svelte +148 -106
- package/dist/shared/VideoTimeline.svelte.d.ts +22 -20
- package/dist/types.d.ts +31 -0
- package/dist/types.js +1 -0
- package/package.json +14 -14
- package/shared/InteractiveVideo.svelte +3 -1
- package/shared/Video.svelte +1 -1
- package/types.ts +37 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @gradio/video
|
|
2
2
|
|
|
3
|
+
## 0.17.0-dev.2
|
|
4
|
+
|
|
5
|
+
### Dependency updates
|
|
6
|
+
|
|
7
|
+
- @gradio/atoms@0.19.0-dev.1
|
|
8
|
+
- @gradio/client@2.0.0-dev.2
|
|
9
|
+
- @gradio/statustracker@0.12.0-dev.1
|
|
10
|
+
- @gradio/upload@0.17.2-dev.2
|
|
11
|
+
- @gradio/image@0.24.0-dev.2
|
|
12
|
+
|
|
13
|
+
## 0.17.0-dev.1
|
|
14
|
+
|
|
15
|
+
### Dependency updates
|
|
16
|
+
|
|
17
|
+
- @gradio/atoms@0.18.2-dev.0
|
|
18
|
+
- @gradio/upload@0.17.2-dev.1
|
|
19
|
+
- @gradio/utils@0.10.3-dev.0
|
|
20
|
+
- @gradio/image@0.23.2-dev.1
|
|
21
|
+
- @gradio/statustracker@0.12.0-dev.0
|
|
22
|
+
- @gradio/icons@0.15.0-dev.0
|
|
23
|
+
|
|
24
|
+
## 0.17.0-dev.0
|
|
25
|
+
|
|
26
|
+
### Dependency updates
|
|
27
|
+
|
|
28
|
+
- @gradio/client@2.0.0-dev.1
|
|
29
|
+
|
|
3
30
|
## 0.17.0-dev.0
|
|
4
31
|
|
|
5
32
|
### Features
|
package/Index.svelte
CHANGED
|
@@ -1,95 +1,60 @@
|
|
|
1
1
|
<svelte:options accessors={true} />
|
|
2
2
|
|
|
3
3
|
<script lang="ts">
|
|
4
|
-
import
|
|
5
|
-
|
|
4
|
+
import { tick } from "svelte";
|
|
6
5
|
import type { FileData } from "@gradio/client";
|
|
7
6
|
import { Block, UploadText } from "@gradio/atoms";
|
|
8
7
|
import StaticVideo from "./shared/VideoPreview.svelte";
|
|
9
8
|
import Video from "./shared/InteractiveVideo.svelte";
|
|
10
9
|
import { StatusTracker } from "@gradio/statustracker";
|
|
11
|
-
import
|
|
12
|
-
import type {
|
|
13
|
-
export let elem_id = "";
|
|
14
|
-
export let elem_classes: string[] = [];
|
|
15
|
-
export let visible: boolean | "hidden" = true;
|
|
16
|
-
export let value: null | FileData = null;
|
|
17
|
-
let old_value: null | FileData = null;
|
|
18
|
-
export let subtitles: null | FileData = null;
|
|
19
|
-
|
|
20
|
-
export let label: string;
|
|
21
|
-
export let sources:
|
|
22
|
-
| ["webcam"]
|
|
23
|
-
| ["upload"]
|
|
24
|
-
| ["webcam", "upload"]
|
|
25
|
-
| ["upload", "webcam"];
|
|
26
|
-
export let root: string;
|
|
27
|
-
export let show_label: boolean;
|
|
28
|
-
export let loading_status: LoadingStatus;
|
|
29
|
-
export let height: number | undefined;
|
|
30
|
-
export let width: number | undefined;
|
|
10
|
+
import { Gradio } from "@gradio/utils";
|
|
11
|
+
import type { VideoProps, VideoEvents } from "./types";
|
|
31
12
|
|
|
32
|
-
|
|
33
|
-
export let scale: number | null = null;
|
|
34
|
-
export let min_width: number | undefined = undefined;
|
|
35
|
-
export let autoplay = false;
|
|
36
|
-
export let buttons: string[] | null = null;
|
|
37
|
-
export let gradio: Gradio<{
|
|
38
|
-
change: never;
|
|
39
|
-
clear: never;
|
|
40
|
-
play: never;
|
|
41
|
-
pause: never;
|
|
42
|
-
upload: never;
|
|
43
|
-
stop: never;
|
|
44
|
-
end: never;
|
|
45
|
-
start_recording: never;
|
|
46
|
-
stop_recording: never;
|
|
47
|
-
share: ShareData;
|
|
48
|
-
error: string;
|
|
49
|
-
warning: string;
|
|
50
|
-
clear_status: LoadingStatus;
|
|
51
|
-
}>;
|
|
52
|
-
export let interactive: boolean;
|
|
53
|
-
export let webcam_options: WebcamOptions;
|
|
54
|
-
export let include_audio: boolean;
|
|
55
|
-
export let loop = false;
|
|
56
|
-
export let input_ready: boolean;
|
|
57
|
-
let uploading = false;
|
|
58
|
-
$: input_ready = !uploading;
|
|
59
|
-
let active_source: "webcam" | "upload";
|
|
13
|
+
const props = $props();
|
|
60
14
|
|
|
61
|
-
let
|
|
15
|
+
let upload_promise = $state<Promise<any>>();
|
|
62
16
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
17
|
+
class VideoGradio extends Gradio<VideoEvents, VideoProps> {
|
|
18
|
+
async get_data() {
|
|
19
|
+
if (upload_promise) {
|
|
20
|
+
await upload_promise;
|
|
21
|
+
await tick();
|
|
22
|
+
}
|
|
23
|
+
const data = await super.get_data();
|
|
66
24
|
|
|
67
|
-
|
|
68
|
-
if (initial_value === null || value === initial_value) {
|
|
69
|
-
return;
|
|
25
|
+
return data;
|
|
70
26
|
}
|
|
71
|
-
|
|
72
|
-
value = initial_value;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
$: if (sources && !active_source) {
|
|
76
|
-
active_source = sources[0];
|
|
77
27
|
}
|
|
78
28
|
|
|
79
|
-
|
|
29
|
+
const gradio = new VideoGradio(props);
|
|
30
|
+
let old_value = $state(gradio.props.value);
|
|
80
31
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
32
|
+
let uploading = $state(false);
|
|
33
|
+
let dragging = $state(false);
|
|
34
|
+
let active_source = $derived.by(() =>
|
|
35
|
+
gradio.props.sources ? gradio.props.sources[0] : undefined
|
|
36
|
+
);
|
|
37
|
+
let initial_value: FileData | null = gradio.props.value;
|
|
38
|
+
|
|
39
|
+
$effect(() => {
|
|
40
|
+
if (old_value != gradio.props.value) {
|
|
41
|
+
old_value = gradio.props.value;
|
|
84
42
|
gradio.dispatch("change");
|
|
85
43
|
}
|
|
86
|
-
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const handle_reset_value = (): void => {
|
|
47
|
+
if (initial_value === null || gradio.props.value === initial_value) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
gradio.props.value = initial_value;
|
|
51
|
+
};
|
|
87
52
|
|
|
88
53
|
function handle_change({ detail }: CustomEvent<FileData | null>): void {
|
|
89
54
|
if (detail != null) {
|
|
90
|
-
value = detail;
|
|
55
|
+
gradio.props.value = detail as FileData;
|
|
91
56
|
} else {
|
|
92
|
-
value = null;
|
|
57
|
+
gradio.props.value = null;
|
|
93
58
|
}
|
|
94
59
|
}
|
|
95
60
|
|
|
@@ -97,44 +62,48 @@
|
|
|
97
62
|
const [level, status] = detail.includes("Invalid file type")
|
|
98
63
|
? ["warning", "complete"]
|
|
99
64
|
: ["error", "error"];
|
|
100
|
-
loading_status =
|
|
101
|
-
loading_status.
|
|
102
|
-
loading_status.message = detail;
|
|
65
|
+
gradio.shared.loading_status.status = status as any;
|
|
66
|
+
gradio.shared.loading_status.message = detail;
|
|
103
67
|
gradio.dispatch(level as "error" | "warning", detail);
|
|
104
68
|
}
|
|
105
69
|
</script>
|
|
106
70
|
|
|
107
|
-
{#if !interactive}
|
|
71
|
+
{#if !gradio.shared.interactive}
|
|
108
72
|
<Block
|
|
109
|
-
{visible}
|
|
110
|
-
variant={value === null && active_source === "upload"
|
|
73
|
+
visible={gradio.shared.visible}
|
|
74
|
+
variant={gradio.props.value === null && active_source === "upload"
|
|
75
|
+
? "dashed"
|
|
76
|
+
: "solid"}
|
|
111
77
|
border_mode={dragging ? "focus" : "base"}
|
|
112
78
|
padding={false}
|
|
113
|
-
{elem_id}
|
|
114
|
-
{elem_classes}
|
|
115
|
-
{height}
|
|
116
|
-
{width}
|
|
117
|
-
{container}
|
|
118
|
-
{scale}
|
|
119
|
-
{min_width}
|
|
79
|
+
elem_id={gradio.shared.elem_id}
|
|
80
|
+
elem_classes={gradio.shared.elem_classes}
|
|
81
|
+
height={gradio.props.height || undefined}
|
|
82
|
+
width={gradio.props.width}
|
|
83
|
+
container={gradio.shared.container}
|
|
84
|
+
scale={gradio.shared.scale}
|
|
85
|
+
min_width={gradio.shared.min_width}
|
|
120
86
|
allow_overflow={false}
|
|
121
87
|
>
|
|
122
88
|
<StatusTracker
|
|
123
|
-
autoscroll={gradio.autoscroll}
|
|
89
|
+
autoscroll={gradio.shared.autoscroll}
|
|
124
90
|
i18n={gradio.i18n}
|
|
125
|
-
{...loading_status}
|
|
126
|
-
on:clear_status={() =>
|
|
91
|
+
{...gradio.shared.loading_status}
|
|
92
|
+
on:clear_status={() =>
|
|
93
|
+
gradio.dispatch("clear_status", gradio.shared.loading_status)}
|
|
127
94
|
/>
|
|
128
95
|
|
|
129
96
|
<StaticVideo
|
|
130
|
-
{value}
|
|
131
|
-
subtitle={subtitles}
|
|
132
|
-
{label}
|
|
133
|
-
{show_label}
|
|
134
|
-
{autoplay}
|
|
135
|
-
{loop}
|
|
136
|
-
show_share_button={buttons
|
|
137
|
-
show_download_button={buttons
|
|
97
|
+
value={gradio.props.value}
|
|
98
|
+
subtitle={gradio.props.subtitles}
|
|
99
|
+
label={gradio.shared.label}
|
|
100
|
+
show_label={gradio.shared.show_label}
|
|
101
|
+
autoplay={gradio.props.autoplay}
|
|
102
|
+
loop={gradio.props.loop}
|
|
103
|
+
show_share_button={(gradio.props.buttons || []).includes("share")}
|
|
104
|
+
show_download_button={(gradio.props.buttons || ["download"]).includes(
|
|
105
|
+
"download"
|
|
106
|
+
)}
|
|
138
107
|
on:play={() => gradio.dispatch("play")}
|
|
139
108
|
on:pause={() => gradio.dispatch("pause")}
|
|
140
109
|
on:stop={() => gradio.dispatch("stop")}
|
|
@@ -142,50 +111,57 @@
|
|
|
142
111
|
on:share={({ detail }) => gradio.dispatch("share", detail)}
|
|
143
112
|
on:error={({ detail }) => gradio.dispatch("error", detail)}
|
|
144
113
|
i18n={gradio.i18n}
|
|
145
|
-
upload={(...args) => gradio.client.upload(...args)}
|
|
114
|
+
upload={(...args) => gradio.shared.client.upload(...args)}
|
|
146
115
|
/>
|
|
147
116
|
</Block>
|
|
148
117
|
{:else}
|
|
149
118
|
<Block
|
|
150
|
-
{visible}
|
|
151
|
-
variant={value === null && active_source === "upload"
|
|
119
|
+
visible={gradio.shared.visible}
|
|
120
|
+
variant={gradio.props.value === null && active_source === "upload"
|
|
121
|
+
? "dashed"
|
|
122
|
+
: "solid"}
|
|
152
123
|
border_mode={dragging ? "focus" : "base"}
|
|
153
124
|
padding={false}
|
|
154
|
-
{elem_id}
|
|
155
|
-
{elem_classes}
|
|
156
|
-
{height}
|
|
157
|
-
{width}
|
|
158
|
-
{container}
|
|
159
|
-
{scale}
|
|
160
|
-
{min_width}
|
|
125
|
+
elem_id={gradio.shared.elem_id}
|
|
126
|
+
elem_classes={gradio.shared.elem_classes}
|
|
127
|
+
height={gradio.props.height || undefined}
|
|
128
|
+
width={gradio.props.width}
|
|
129
|
+
container={gradio.shared.container}
|
|
130
|
+
scale={gradio.shared.scale}
|
|
131
|
+
min_width={gradio.shared.min_width}
|
|
161
132
|
allow_overflow={false}
|
|
162
133
|
>
|
|
163
134
|
<StatusTracker
|
|
164
|
-
autoscroll={gradio.autoscroll}
|
|
135
|
+
autoscroll={gradio.shared.autoscroll}
|
|
165
136
|
i18n={gradio.i18n}
|
|
166
|
-
{...loading_status}
|
|
167
|
-
on:clear_status={() =>
|
|
137
|
+
{...gradio.shared.loading_status}
|
|
138
|
+
on:clear_status={() =>
|
|
139
|
+
gradio.dispatch("clear_status", gradio.shared.loading_status)}
|
|
168
140
|
/>
|
|
169
141
|
|
|
170
142
|
<Video
|
|
171
|
-
|
|
172
|
-
|
|
143
|
+
bind:upload_promise
|
|
144
|
+
value={gradio.props.value}
|
|
145
|
+
subtitle={gradio.props.subtitles}
|
|
173
146
|
on:change={handle_change}
|
|
174
147
|
on:drag={({ detail }) => (dragging = detail)}
|
|
175
148
|
on:error={handle_error}
|
|
176
149
|
bind:uploading
|
|
177
|
-
{label}
|
|
178
|
-
{show_label}
|
|
179
|
-
show_download_button={buttons
|
|
180
|
-
{sources}
|
|
150
|
+
label={gradio.shared.label}
|
|
151
|
+
show_label={gradio.shared.show_label}
|
|
152
|
+
show_download_button={(gradio.props.buttons || []).includes("download")}
|
|
153
|
+
sources={gradio.props.sources}
|
|
181
154
|
{active_source}
|
|
182
|
-
{webcam_options}
|
|
183
|
-
{include_audio}
|
|
184
|
-
{autoplay}
|
|
185
|
-
{root}
|
|
186
|
-
{loop}
|
|
155
|
+
webcam_options={gradio.props.webcam_options}
|
|
156
|
+
include_audio={gradio.props.include_audio}
|
|
157
|
+
autoplay={gradio.props.autoplay}
|
|
158
|
+
root={gradio.shared.root}
|
|
159
|
+
loop={gradio.props.loop}
|
|
187
160
|
{handle_reset_value}
|
|
188
|
-
on:clear={() =>
|
|
161
|
+
on:clear={() => {
|
|
162
|
+
gradio.props.value = null;
|
|
163
|
+
gradio.dispatch("clear");
|
|
164
|
+
}}
|
|
189
165
|
on:play={() => gradio.dispatch("play")}
|
|
190
166
|
on:pause={() => gradio.dispatch("pause")}
|
|
191
167
|
on:upload={() => gradio.dispatch("upload")}
|
|
@@ -194,9 +170,9 @@
|
|
|
194
170
|
on:start_recording={() => gradio.dispatch("start_recording")}
|
|
195
171
|
on:stop_recording={() => gradio.dispatch("stop_recording")}
|
|
196
172
|
i18n={gradio.i18n}
|
|
197
|
-
max_file_size={gradio.max_file_size}
|
|
198
|
-
upload={(...args) => gradio.client.upload(...args)}
|
|
199
|
-
stream_handler={(...args) => gradio.client.stream(...args)}
|
|
173
|
+
max_file_size={gradio.shared.max_file_size}
|
|
174
|
+
upload={(...args) => gradio.shared.client.upload(...args)}
|
|
175
|
+
stream_handler={(...args) => gradio.shared.client.stream(...args)}
|
|
200
176
|
>
|
|
201
177
|
<UploadText i18n={gradio.i18n} type="video" />
|
|
202
178
|
</Video>
|
package/Video.test.ts
CHANGED
|
@@ -280,11 +280,11 @@ describe("Video", () => {
|
|
|
280
280
|
|
|
281
281
|
const mock = listen("change");
|
|
282
282
|
|
|
283
|
-
(component.value = [
|
|
283
|
+
((component.value = [
|
|
284
284
|
{
|
|
285
285
|
path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/b.mp4"
|
|
286
286
|
}
|
|
287
287
|
]),
|
|
288
|
-
assert.equal(mock.callCount, 1);
|
|
288
|
+
assert.equal(mock.callCount, 1));
|
|
289
289
|
});
|
|
290
290
|
});
|
package/dist/Example.svelte
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
import {} from "
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export let
|
|
7
|
-
export let
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Video from "./shared/Video.svelte";
|
|
3
|
+
import { playable } from "./shared/utils";
|
|
4
|
+
import { type FileData } from "@gradio/client";
|
|
5
|
+
|
|
6
|
+
export let type: "gallery" | "table";
|
|
7
|
+
export let selected = false;
|
|
8
|
+
export let value: null | FileData = null;
|
|
9
|
+
export let loop: boolean;
|
|
10
|
+
let video: HTMLVideoElement;
|
|
11
|
+
|
|
12
|
+
async function init(): Promise<void> {
|
|
13
|
+
video.muted = true;
|
|
14
|
+
video.playsInline = true;
|
|
15
|
+
video.controls = false;
|
|
16
|
+
video.setAttribute("muted", "");
|
|
17
|
+
|
|
18
|
+
await video.play();
|
|
19
|
+
video.pause();
|
|
20
|
+
}
|
|
17
21
|
</script>
|
|
18
22
|
|
|
19
23
|
{#if value}
|
package/dist/Example.svelte.d.ts
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import { type FileData } from "@gradio/client";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
9
12
|
};
|
|
10
|
-
|
|
11
|
-
[evt: string]: CustomEvent<any>;
|
|
12
|
-
};
|
|
13
|
-
slots: {};
|
|
14
|
-
exports?: {} | undefined;
|
|
15
|
-
bindings?: string | undefined;
|
|
16
|
-
};
|
|
17
|
-
export type ExampleProps = typeof __propDef.props;
|
|
18
|
-
export type ExampleEvents = typeof __propDef.events;
|
|
19
|
-
export type ExampleSlots = typeof __propDef.slots;
|
|
20
|
-
export default class Example extends SvelteComponent<ExampleProps, ExampleEvents, ExampleSlots> {
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
21
14
|
}
|
|
22
|
-
|
|
15
|
+
declare const Example: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
+
type: "gallery" | "table";
|
|
17
|
+
selected?: boolean;
|
|
18
|
+
value?: null | FileData;
|
|
19
|
+
loop: boolean;
|
|
20
|
+
}, {
|
|
21
|
+
[evt: string]: CustomEvent<any>;
|
|
22
|
+
}, {}, {}, string>;
|
|
23
|
+
type Example = InstanceType<typeof Example>;
|
|
24
|
+
export default Example;
|