@gradio/image 0.23.2-dev.0 → 0.24.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 +29 -0
- package/Index.svelte +105 -135
- package/dist/Example.svelte +7 -4
- package/dist/Example.svelte.d.ts +20 -18
- package/dist/Index.svelte +147 -146
- package/dist/Index.svelte.d.ts +3 -170
- package/dist/shared/Image.svelte +19 -2
- package/dist/shared/Image.svelte.d.ts +24 -19
- package/dist/shared/ImagePreview.svelte +51 -32
- package/dist/shared/ImagePreview.svelte.d.ts +33 -30
- package/dist/shared/ImageUploader.svelte +185 -138
- package/dist/shared/ImageUploader.svelte.d.ts +59 -49
- package/dist/shared/Webcam.svelte +264 -228
- package/dist/shared/Webcam.svelte.d.ts +42 -41
- package/dist/shared/WebcamPermissions.svelte +7 -3
- package/dist/shared/WebcamPermissions.svelte.d.ts +18 -16
- package/dist/shared/types.d.ts +30 -0
- package/package.json +11 -11
- package/shared/Image.svelte +18 -9
- package/shared/ImagePreview.svelte +8 -2
- package/shared/ImageUploader.svelte +9 -6
- package/shared/Webcam.svelte +6 -30
- package/shared/types.ts +33 -0
|
@@ -1,229 +1,265 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
let
|
|
38
|
-
export let
|
|
39
|
-
export let
|
|
40
|
-
export let
|
|
41
|
-
export let
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createEventDispatcher, onDestroy, onMount } from "svelte";
|
|
3
|
+
import {
|
|
4
|
+
Camera,
|
|
5
|
+
Circle,
|
|
6
|
+
Square,
|
|
7
|
+
DropdownArrow,
|
|
8
|
+
Spinner
|
|
9
|
+
} from "@gradio/icons";
|
|
10
|
+
import type { I18nFormatter } from "@gradio/utils";
|
|
11
|
+
import { StreamingBar } from "@gradio/statustracker";
|
|
12
|
+
import { type FileData, type Client, prepare_files } from "@gradio/client";
|
|
13
|
+
import WebcamPermissions from "./WebcamPermissions.svelte";
|
|
14
|
+
import { fade } from "svelte/transition";
|
|
15
|
+
import {
|
|
16
|
+
get_devices,
|
|
17
|
+
get_video_stream,
|
|
18
|
+
set_available_devices
|
|
19
|
+
} from "./stream_utils";
|
|
20
|
+
import type { Base64File } from "./types";
|
|
21
|
+
|
|
22
|
+
let video_source: HTMLVideoElement;
|
|
23
|
+
let available_video_devices: MediaDeviceInfo[] = [];
|
|
24
|
+
let selected_device: MediaDeviceInfo | null = null;
|
|
25
|
+
|
|
26
|
+
export let stream_state: "open" | "waiting" | "closed" = "closed";
|
|
27
|
+
|
|
28
|
+
let canvas: HTMLCanvasElement;
|
|
29
|
+
export let streaming = false;
|
|
30
|
+
export let pending = false;
|
|
31
|
+
export let root = "";
|
|
32
|
+
export let stream_every = 1;
|
|
33
|
+
|
|
34
|
+
export let mode: "image" | "video" = "image";
|
|
35
|
+
export let mirror_webcam: boolean;
|
|
36
|
+
export let include_audio: boolean;
|
|
37
|
+
export let webcam_constraints: { [key: string]: any } | null = null;
|
|
38
|
+
export let i18n: I18nFormatter;
|
|
39
|
+
export let upload: Client["upload"];
|
|
40
|
+
export let value: FileData | null | Base64File = null;
|
|
41
|
+
export let time_limit: number | null = null;
|
|
42
|
+
const dispatch = createEventDispatcher<{
|
|
43
|
+
stream: Blob | string;
|
|
44
|
+
capture: FileData | Blob | null;
|
|
45
|
+
error: string;
|
|
46
|
+
start_recording: undefined;
|
|
47
|
+
stop_recording: undefined;
|
|
48
|
+
close_stream: undefined;
|
|
49
|
+
}>();
|
|
50
|
+
|
|
51
|
+
onMount(() => {
|
|
52
|
+
canvas = document.createElement("canvas");
|
|
53
|
+
if (streaming && mode === "image") {
|
|
54
|
+
window.setInterval(() => {
|
|
55
|
+
if (video_source && !pending) {
|
|
56
|
+
take_picture();
|
|
57
|
+
}
|
|
58
|
+
}, stream_every * 1000);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const handle_device_change = async (event: InputEvent): Promise<void> => {
|
|
63
|
+
const target = event.target as HTMLInputElement;
|
|
64
|
+
const device_id = target.value;
|
|
65
|
+
|
|
66
|
+
await get_video_stream(
|
|
67
|
+
include_audio,
|
|
68
|
+
video_source,
|
|
69
|
+
webcam_constraints,
|
|
70
|
+
device_id
|
|
71
|
+
).then(async (local_stream) => {
|
|
72
|
+
stream = local_stream;
|
|
73
|
+
selected_device =
|
|
74
|
+
available_video_devices.find(
|
|
75
|
+
(device) => device.deviceId === device_id
|
|
76
|
+
) || null;
|
|
77
|
+
options_open = false;
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
async function access_webcam(): Promise<void> {
|
|
82
|
+
try {
|
|
83
|
+
get_video_stream(include_audio, video_source, webcam_constraints)
|
|
84
|
+
.then(async (local_stream) => {
|
|
85
|
+
webcam_accessed = true;
|
|
86
|
+
available_video_devices = await get_devices();
|
|
87
|
+
stream = local_stream;
|
|
88
|
+
})
|
|
89
|
+
.then(() => set_available_devices(available_video_devices))
|
|
90
|
+
.then((devices) => {
|
|
91
|
+
available_video_devices = devices;
|
|
92
|
+
|
|
93
|
+
const used_devices = stream
|
|
94
|
+
.getTracks()
|
|
95
|
+
.map((track) => track.getSettings()?.deviceId)[0];
|
|
96
|
+
|
|
97
|
+
selected_device = used_devices
|
|
98
|
+
? devices.find((device) => device.deviceId === used_devices) ||
|
|
99
|
+
available_video_devices[0]
|
|
100
|
+
: available_video_devices[0];
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
|
|
104
|
+
dispatch("error", i18n("image.no_webcam_support"));
|
|
105
|
+
}
|
|
106
|
+
} catch (err) {
|
|
107
|
+
if (err instanceof DOMException && err.name == "NotAllowedError") {
|
|
108
|
+
dispatch("error", i18n("image.allow_webcam_access"));
|
|
109
|
+
} else {
|
|
110
|
+
throw err;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function take_picture(): void {
|
|
116
|
+
if (
|
|
117
|
+
(!streaming || (streaming && recording)) &&
|
|
118
|
+
video_source.videoWidth &&
|
|
119
|
+
video_source.videoHeight
|
|
120
|
+
) {
|
|
121
|
+
console.log("Taking picture from webcam");
|
|
122
|
+
var context = canvas.getContext("2d")!;
|
|
123
|
+
canvas.width = video_source.videoWidth;
|
|
124
|
+
canvas.height = video_source.videoHeight;
|
|
125
|
+
context.drawImage(
|
|
126
|
+
video_source,
|
|
127
|
+
0,
|
|
128
|
+
0,
|
|
129
|
+
video_source.videoWidth,
|
|
130
|
+
video_source.videoHeight
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
if (mirror_webcam) {
|
|
134
|
+
context.scale(-1, 1);
|
|
135
|
+
context.drawImage(video_source, -video_source.videoWidth, 0);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (streaming && (!recording || stream_state === "waiting")) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (streaming) {
|
|
142
|
+
const image_data = canvas.toDataURL("image/jpeg");
|
|
143
|
+
dispatch("stream", image_data);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
canvas.toBlob(
|
|
148
|
+
(blob) => {
|
|
149
|
+
dispatch(streaming ? "stream" : "capture", blob);
|
|
150
|
+
},
|
|
151
|
+
`image/${streaming ? "jpeg" : "png"}`,
|
|
152
|
+
0.8
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
let recording = false;
|
|
158
|
+
let recorded_blobs: BlobPart[] = [];
|
|
159
|
+
let stream: MediaStream;
|
|
160
|
+
let mimeType: string;
|
|
161
|
+
let media_recorder: MediaRecorder;
|
|
162
|
+
|
|
163
|
+
function take_recording(): void {
|
|
164
|
+
if (recording) {
|
|
165
|
+
media_recorder.stop();
|
|
166
|
+
let video_blob = new Blob(recorded_blobs, { type: mimeType });
|
|
167
|
+
let ReaderObj = new FileReader();
|
|
168
|
+
ReaderObj.onload = async function (e): Promise<void> {
|
|
169
|
+
if (e.target) {
|
|
170
|
+
let _video_blob = new File(
|
|
171
|
+
[video_blob],
|
|
172
|
+
"sample." + mimeType.substring(6)
|
|
173
|
+
);
|
|
174
|
+
const val = await prepare_files([_video_blob]);
|
|
175
|
+
let val_ = (
|
|
176
|
+
(await upload(val, root))?.filter(Boolean) as FileData[]
|
|
177
|
+
)[0];
|
|
178
|
+
dispatch("capture", val_);
|
|
179
|
+
dispatch("stop_recording");
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
ReaderObj.readAsDataURL(video_blob);
|
|
183
|
+
} else if (typeof MediaRecorder !== "undefined") {
|
|
184
|
+
dispatch("start_recording");
|
|
185
|
+
recorded_blobs = [];
|
|
186
|
+
let validMimeTypes = ["video/webm", "video/mp4"];
|
|
187
|
+
for (let validMimeType of validMimeTypes) {
|
|
188
|
+
if (MediaRecorder.isTypeSupported(validMimeType)) {
|
|
189
|
+
mimeType = validMimeType;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (mimeType === null) {
|
|
194
|
+
console.error("No supported MediaRecorder mimeType");
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
media_recorder = new MediaRecorder(stream, {
|
|
198
|
+
mimeType: mimeType
|
|
199
|
+
});
|
|
200
|
+
media_recorder.addEventListener("dataavailable", function (e) {
|
|
201
|
+
recorded_blobs.push(e.data);
|
|
202
|
+
});
|
|
203
|
+
media_recorder.start(200);
|
|
204
|
+
}
|
|
205
|
+
recording = !recording;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
let webcam_accessed = false;
|
|
209
|
+
|
|
210
|
+
function record_video_or_photo({
|
|
211
|
+
destroy
|
|
212
|
+
}: { destroy?: boolean } = {}): void {
|
|
213
|
+
if (mode === "image" && streaming) {
|
|
214
|
+
recording = !recording;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (!destroy) {
|
|
218
|
+
if (mode === "image") {
|
|
219
|
+
take_picture();
|
|
220
|
+
} else {
|
|
221
|
+
take_recording();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (!recording && stream) {
|
|
226
|
+
dispatch("close_stream");
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
let options_open = false;
|
|
231
|
+
|
|
232
|
+
export function click_outside(node: Node, cb: any): any {
|
|
233
|
+
const handle_click = (event: MouseEvent): void => {
|
|
234
|
+
if (
|
|
235
|
+
node &&
|
|
236
|
+
!node.contains(event.target as Node) &&
|
|
237
|
+
!event.defaultPrevented
|
|
238
|
+
) {
|
|
239
|
+
cb(event);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
document.addEventListener("click", handle_click, true);
|
|
244
|
+
|
|
245
|
+
return {
|
|
246
|
+
destroy() {
|
|
247
|
+
document.removeEventListener("click", handle_click, true);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function handle_click_outside(event: MouseEvent): void {
|
|
253
|
+
event.preventDefault();
|
|
254
|
+
event.stopPropagation();
|
|
255
|
+
options_open = false;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
onDestroy(() => {
|
|
259
|
+
if (typeof window === "undefined") return;
|
|
260
|
+
record_video_or_photo({ destroy: true });
|
|
261
|
+
stream?.getTracks().forEach((track) => track.stop());
|
|
262
|
+
});
|
|
227
263
|
</script>
|
|
228
264
|
|
|
229
265
|
<div class="wrap">
|
|
@@ -300,12 +336,12 @@ onDestroy(() => {
|
|
|
300
336
|
use:click_outside={handle_click_outside}
|
|
301
337
|
on:change={handle_device_change}
|
|
302
338
|
>
|
|
303
|
-
<button
|
|
339
|
+
<!-- <button
|
|
304
340
|
class="inset-icon"
|
|
305
341
|
on:click|stopPropagation={() => (options_open = false)}
|
|
306
342
|
>
|
|
307
343
|
<DropdownArrow />
|
|
308
|
-
</button>
|
|
344
|
+
</button> -->
|
|
309
345
|
{#if available_video_devices.length === 0}
|
|
310
346
|
<option value="">{i18n("common.no_devices")}</option>
|
|
311
347
|
{:else}
|
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { I18nFormatter } from "@gradio/utils";
|
|
3
2
|
import { type FileData, type Client } from "@gradio/client";
|
|
4
3
|
import type { Base64File } from "./types";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
include_audio: boolean;
|
|
16
|
-
webcam_constraints?: {
|
|
17
|
-
[key: string]: any;
|
|
18
|
-
} | null;
|
|
19
|
-
i18n: I18nFormatter;
|
|
20
|
-
upload: Client["upload"];
|
|
21
|
-
value?: FileData | null | Base64File;
|
|
22
|
-
click_outside?: (node: Node, cb: any) => any;
|
|
4
|
+
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> {
|
|
5
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
6
|
+
$$bindings?: Bindings;
|
|
7
|
+
} & Exports;
|
|
8
|
+
(internal: unknown, props: Props & {
|
|
9
|
+
$$events?: Events;
|
|
10
|
+
$$slots?: Slots;
|
|
11
|
+
}): Exports & {
|
|
12
|
+
$set?: any;
|
|
13
|
+
$on?: any;
|
|
23
14
|
};
|
|
24
|
-
|
|
25
|
-
stream: CustomEvent<string | Blob>;
|
|
26
|
-
capture: CustomEvent<any>;
|
|
27
|
-
error: CustomEvent<string>;
|
|
28
|
-
start_recording: CustomEvent<undefined>;
|
|
29
|
-
stop_recording: CustomEvent<undefined>;
|
|
30
|
-
close_stream: CustomEvent<undefined>;
|
|
31
|
-
} & {
|
|
32
|
-
[evt: string]: CustomEvent<any>;
|
|
33
|
-
};
|
|
34
|
-
slots: {};
|
|
35
|
-
exports?: {} | undefined;
|
|
36
|
-
bindings?: string | undefined;
|
|
37
|
-
};
|
|
38
|
-
export type WebcamProps = typeof __propDef.props;
|
|
39
|
-
export type WebcamEvents = typeof __propDef.events;
|
|
40
|
-
export type WebcamSlots = typeof __propDef.slots;
|
|
41
|
-
export default class Webcam extends SvelteComponent<WebcamProps, WebcamEvents, WebcamSlots> {
|
|
42
|
-
get modify_stream(): (state: "open" | "closed" | "waiting") => void;
|
|
43
|
-
get set_time_limit(): (time: number) => void;
|
|
44
|
-
get click_outside(): (node: Node, cb: any) => any;
|
|
15
|
+
z_$$bindings?: Bindings;
|
|
45
16
|
}
|
|
46
|
-
|
|
17
|
+
declare const Webcam: $$__sveltets_2_IsomorphicComponent<{
|
|
18
|
+
stream_state?: "open" | "waiting" | "closed";
|
|
19
|
+
streaming?: boolean;
|
|
20
|
+
pending?: boolean;
|
|
21
|
+
root?: string;
|
|
22
|
+
stream_every?: number;
|
|
23
|
+
mode?: "image" | "video";
|
|
24
|
+
mirror_webcam: boolean;
|
|
25
|
+
include_audio: boolean;
|
|
26
|
+
webcam_constraints?: {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
} | null;
|
|
29
|
+
i18n: I18nFormatter;
|
|
30
|
+
upload: Client["upload"];
|
|
31
|
+
value?: FileData | null | Base64File;
|
|
32
|
+
time_limit?: number | null;
|
|
33
|
+
click_outside?: (node: Node, cb: any) => any;
|
|
34
|
+
}, {
|
|
35
|
+
stream: CustomEvent<string | Blob>;
|
|
36
|
+
capture: CustomEvent<Blob | FileData | null>;
|
|
37
|
+
error: CustomEvent<string>;
|
|
38
|
+
start_recording: CustomEvent<undefined>;
|
|
39
|
+
stop_recording: CustomEvent<undefined>;
|
|
40
|
+
close_stream: CustomEvent<undefined>;
|
|
41
|
+
} & {
|
|
42
|
+
[evt: string]: CustomEvent<any>;
|
|
43
|
+
}, {}, {
|
|
44
|
+
click_outside: (node: Node, cb: any) => any;
|
|
45
|
+
}, string>;
|
|
46
|
+
type Webcam = InstanceType<typeof Webcam>;
|
|
47
|
+
export default Webcam;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Webcam } from "@gradio/icons";
|
|
3
|
+
import { createEventDispatcher } from "svelte";
|
|
4
|
+
|
|
5
|
+
const dispatch = createEventDispatcher<{
|
|
6
|
+
click: undefined;
|
|
7
|
+
}>();
|
|
4
8
|
</script>
|
|
5
9
|
|
|
6
10
|
<button style:height="100%" on:click={() => dispatch("click")}>
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
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> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
8
11
|
};
|
|
9
|
-
|
|
10
|
-
exports?: {} | undefined;
|
|
11
|
-
bindings?: string | undefined;
|
|
12
|
-
};
|
|
13
|
-
export type WebcamPermissionsProps = typeof __propDef.props;
|
|
14
|
-
export type WebcamPermissionsEvents = typeof __propDef.events;
|
|
15
|
-
export type WebcamPermissionsSlots = typeof __propDef.slots;
|
|
16
|
-
export default class WebcamPermissions extends SvelteComponent<WebcamPermissionsProps, WebcamPermissionsEvents, WebcamPermissionsSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
17
13
|
}
|
|
18
|
-
|
|
14
|
+
declare const WebcamPermissions: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
click: CustomEvent<undefined>;
|
|
16
|
+
} & {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
}, {}, {}, string>;
|
|
19
|
+
type WebcamPermissions = InstanceType<typeof WebcamPermissions>;
|
|
20
|
+
export default WebcamPermissions;
|