@gradio/image 0.14.0 → 0.15.1
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 +38 -0
- package/Image.stories.svelte +43 -15
- package/Image.test.ts +2 -3
- package/Index.svelte +32 -1
- package/dist/Example.svelte +46 -0
- package/dist/Example.svelte.d.ts +19 -0
- package/dist/Index.svelte +185 -0
- package/dist/Index.svelte.d.ts +158 -0
- package/dist/shared/ClearImage.svelte +28 -0
- package/dist/shared/ClearImage.svelte.d.ts +18 -0
- package/dist/shared/Image.svelte +26 -0
- package/dist/shared/Image.svelte.d.ts +247 -0
- package/dist/shared/ImagePreview.svelte +155 -0
- package/dist/shared/ImagePreview.svelte.d.ts +32 -0
- package/dist/shared/ImageUploader.svelte +181 -0
- package/dist/shared/ImageUploader.svelte.d.ts +42 -0
- package/dist/shared/Webcam.svelte +371 -0
- package/dist/shared/Webcam.svelte.d.ts +33 -0
- package/dist/shared/WebcamPermissions.svelte +42 -0
- package/dist/shared/WebcamPermissions.svelte.d.ts +18 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/index.js +2 -0
- package/dist/shared/stream_utils.d.ts +5 -0
- package/dist/shared/stream_utils.js +31 -0
- package/dist/shared/utils.d.ts +1 -0
- package/dist/shared/utils.js +28 -0
- package/package.json +38 -14
- package/shared/ImagePreview.svelte +17 -6
- package/shared/ImageUploader.svelte +12 -5
@@ -0,0 +1,26 @@
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
2
|
+
const dispatch = createEventDispatcher();
|
3
|
+
import { resolve_wasm_src } from "@gradio/wasm/svelte";
|
4
|
+
export let src = void 0;
|
5
|
+
let resolved_src;
|
6
|
+
let latest_src;
|
7
|
+
$: {
|
8
|
+
resolved_src = src;
|
9
|
+
latest_src = src;
|
10
|
+
const resolving_src = src;
|
11
|
+
resolve_wasm_src(resolving_src).then((s) => {
|
12
|
+
if (latest_src === resolving_src) {
|
13
|
+
resolved_src = s;
|
14
|
+
}
|
15
|
+
});
|
16
|
+
}
|
17
|
+
</script>
|
18
|
+
|
19
|
+
<!-- svelte-ignore a11y-missing-attribute -->
|
20
|
+
<img src={resolved_src} {...$$restProps} on:load={() => dispatch("load")} />
|
21
|
+
|
22
|
+
<style>
|
23
|
+
img {
|
24
|
+
object-fit: cover;
|
25
|
+
}
|
26
|
+
</style>
|
@@ -0,0 +1,247 @@
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
2
|
+
declare const __propDef: {
|
3
|
+
props: {
|
4
|
+
[x: `data-${string}`]: any;
|
5
|
+
alt?: string | undefined | null;
|
6
|
+
crossorigin?: "anonymous" | "use-credentials" | "" | undefined | null;
|
7
|
+
decoding?: "async" | "auto" | "sync" | undefined | null;
|
8
|
+
fetchpriority?: "auto" | "high" | "low" | undefined | null;
|
9
|
+
height?: number | string | undefined | null;
|
10
|
+
ismap?: boolean | undefined | null;
|
11
|
+
loading?: "eager" | "lazy" | undefined | null;
|
12
|
+
referrerpolicy?: ReferrerPolicy | undefined | null;
|
13
|
+
sizes?: string | undefined | null;
|
14
|
+
src?: string | undefined | null;
|
15
|
+
srcset?: string | undefined | null;
|
16
|
+
usemap?: string | undefined | null;
|
17
|
+
width?: number | string | undefined | null;
|
18
|
+
readonly 'bind:naturalWidth'?: number | undefined | null;
|
19
|
+
readonly 'bind:naturalHeight'?: number | undefined | null;
|
20
|
+
accesskey?: string | undefined | null;
|
21
|
+
autofocus?: boolean | undefined | null;
|
22
|
+
class?: string | undefined | null;
|
23
|
+
contenteditable?: import("svelte/elements").Booleanish | "inherit" | "plaintext-only" | undefined | null;
|
24
|
+
contextmenu?: string | undefined | null;
|
25
|
+
dir?: string | undefined | null;
|
26
|
+
draggable?: import("svelte/elements").Booleanish | undefined | null;
|
27
|
+
enterkeyhint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined | null;
|
28
|
+
hidden?: boolean | undefined | null;
|
29
|
+
id?: string | undefined | null;
|
30
|
+
lang?: string | undefined | null;
|
31
|
+
part?: string | undefined | null;
|
32
|
+
placeholder?: string | undefined | null;
|
33
|
+
slot?: string | undefined | null;
|
34
|
+
spellcheck?: import("svelte/elements").Booleanish | undefined | null;
|
35
|
+
style?: string | undefined | null;
|
36
|
+
tabindex?: number | undefined | null;
|
37
|
+
title?: string | undefined | null;
|
38
|
+
translate?: "yes" | "no" | "" | undefined | null;
|
39
|
+
inert?: boolean | undefined | null;
|
40
|
+
popover?: "auto" | "manual" | "" | undefined | null;
|
41
|
+
radiogroup?: string | undefined | null;
|
42
|
+
role?: import("svelte/elements").AriaRole | undefined | null;
|
43
|
+
about?: string | undefined | null;
|
44
|
+
datatype?: string | undefined | null;
|
45
|
+
inlist?: any;
|
46
|
+
prefix?: string | undefined | null;
|
47
|
+
property?: string | undefined | null;
|
48
|
+
resource?: string | undefined | null;
|
49
|
+
typeof?: string | undefined | null;
|
50
|
+
vocab?: string | undefined | null;
|
51
|
+
autocapitalize?: string | undefined | null;
|
52
|
+
autocorrect?: string | undefined | null;
|
53
|
+
autosave?: string | undefined | null;
|
54
|
+
color?: string | undefined | null;
|
55
|
+
itemprop?: string | undefined | null;
|
56
|
+
itemscope?: boolean | undefined | null;
|
57
|
+
itemtype?: string | undefined | null;
|
58
|
+
itemid?: string | undefined | null;
|
59
|
+
itemref?: string | undefined | null;
|
60
|
+
results?: number | undefined | null;
|
61
|
+
security?: string | undefined | null;
|
62
|
+
unselectable?: "on" | "off" | undefined | null;
|
63
|
+
inputmode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | null;
|
64
|
+
is?: string | undefined | null;
|
65
|
+
'bind:innerHTML'?: string | undefined | null;
|
66
|
+
'bind:textContent'?: string | undefined | null;
|
67
|
+
'bind:innerText'?: string | undefined | null;
|
68
|
+
readonly 'bind:contentRect'?: DOMRectReadOnly | undefined | null;
|
69
|
+
readonly 'bind:contentBoxSize'?: ResizeObserverSize[] | undefined | null;
|
70
|
+
readonly 'bind:borderBoxSize'?: ResizeObserverSize[] | undefined | null;
|
71
|
+
readonly 'bind:devicePixelContentBoxSize'?: ResizeObserverSize[] | undefined | null;
|
72
|
+
'data-sveltekit-keepfocus'?: true | "" | "off" | undefined | null;
|
73
|
+
'data-sveltekit-noscroll'?: true | "" | "off" | undefined | null;
|
74
|
+
'data-sveltekit-preload-code'?: true | "" | "eager" | "viewport" | "hover" | "tap" | "off" | undefined | null;
|
75
|
+
'data-sveltekit-preload-data'?: true | "" | "hover" | "tap" | "off" | undefined | null;
|
76
|
+
'data-sveltekit-reload'?: true | "" | "off" | undefined | null;
|
77
|
+
'data-sveltekit-replacestate'?: true | "" | "off" | undefined | null;
|
78
|
+
'aria-activedescendant'?: string | undefined | null;
|
79
|
+
'aria-atomic'?: import("svelte/elements").Booleanish | undefined | null;
|
80
|
+
'aria-autocomplete'?: "none" | "inline" | "list" | "both" | undefined | null;
|
81
|
+
'aria-busy'?: import("svelte/elements").Booleanish | undefined | null;
|
82
|
+
'aria-checked'?: boolean | "false" | "mixed" | "true" | undefined | null;
|
83
|
+
'aria-colcount'?: number | undefined | null;
|
84
|
+
'aria-colindex'?: number | undefined | null;
|
85
|
+
'aria-colspan'?: number | undefined | null;
|
86
|
+
'aria-controls'?: string | undefined | null;
|
87
|
+
'aria-current'?: import("svelte/elements").Booleanish | "page" | "step" | "location" | "date" | "time" | undefined | null;
|
88
|
+
'aria-describedby'?: string | undefined | null;
|
89
|
+
'aria-details'?: string | undefined | null;
|
90
|
+
'aria-disabled'?: import("svelte/elements").Booleanish | undefined | null;
|
91
|
+
'aria-dropeffect'?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined | null;
|
92
|
+
'aria-errormessage'?: string | undefined | null;
|
93
|
+
'aria-expanded'?: import("svelte/elements").Booleanish | undefined | null;
|
94
|
+
'aria-flowto'?: string | undefined | null;
|
95
|
+
'aria-grabbed'?: import("svelte/elements").Booleanish | undefined | null;
|
96
|
+
'aria-haspopup'?: import("svelte/elements").Booleanish | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined | null;
|
97
|
+
'aria-hidden'?: import("svelte/elements").Booleanish | undefined | null;
|
98
|
+
'aria-invalid'?: import("svelte/elements").Booleanish | "grammar" | "spelling" | undefined | null;
|
99
|
+
'aria-keyshortcuts'?: string | undefined | null;
|
100
|
+
'aria-label'?: string | undefined | null;
|
101
|
+
'aria-labelledby'?: string | undefined | null;
|
102
|
+
'aria-level'?: number | undefined | null;
|
103
|
+
'aria-live'?: "off" | "assertive" | "polite" | undefined | null;
|
104
|
+
'aria-modal'?: import("svelte/elements").Booleanish | undefined | null;
|
105
|
+
'aria-multiline'?: import("svelte/elements").Booleanish | undefined | null;
|
106
|
+
'aria-multiselectable'?: import("svelte/elements").Booleanish | undefined | null;
|
107
|
+
'aria-orientation'?: "horizontal" | "vertical" | undefined | null;
|
108
|
+
'aria-owns'?: string | undefined | null;
|
109
|
+
'aria-placeholder'?: string | undefined | null;
|
110
|
+
'aria-posinset'?: number | undefined | null;
|
111
|
+
'aria-pressed'?: boolean | "false" | "mixed" | "true" | undefined | null;
|
112
|
+
'aria-readonly'?: import("svelte/elements").Booleanish | undefined | null;
|
113
|
+
'aria-relevant'?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined | null;
|
114
|
+
'aria-required'?: import("svelte/elements").Booleanish | undefined | null;
|
115
|
+
'aria-roledescription'?: string | undefined | null;
|
116
|
+
'aria-rowcount'?: number | undefined | null;
|
117
|
+
'aria-rowindex'?: number | undefined | null;
|
118
|
+
'aria-rowspan'?: number | undefined | null;
|
119
|
+
'aria-selected'?: import("svelte/elements").Booleanish | undefined | null;
|
120
|
+
'aria-setsize'?: number | undefined | null;
|
121
|
+
'aria-sort'?: "none" | "ascending" | "descending" | "other" | undefined | null;
|
122
|
+
'aria-valuemax'?: number | undefined | null;
|
123
|
+
'aria-valuemin'?: number | undefined | null;
|
124
|
+
'aria-valuenow'?: number | undefined | null;
|
125
|
+
'aria-valuetext'?: string | undefined | null;
|
126
|
+
'on:copy'?: import("svelte/elements").ClipboardEventHandler<HTMLImageElement> | null | undefined;
|
127
|
+
'on:cut'?: import("svelte/elements").ClipboardEventHandler<HTMLImageElement> | null | undefined;
|
128
|
+
'on:paste'?: import("svelte/elements").ClipboardEventHandler<HTMLImageElement> | null | undefined;
|
129
|
+
'on:compositionend'?: import("svelte/elements").CompositionEventHandler<HTMLImageElement> | null | undefined;
|
130
|
+
'on:compositionstart'?: import("svelte/elements").CompositionEventHandler<HTMLImageElement> | null | undefined;
|
131
|
+
'on:compositionupdate'?: import("svelte/elements").CompositionEventHandler<HTMLImageElement> | null | undefined;
|
132
|
+
'on:focus'?: import("svelte/elements").FocusEventHandler<HTMLImageElement> | null | undefined;
|
133
|
+
'on:focusin'?: import("svelte/elements").FocusEventHandler<HTMLImageElement> | null | undefined;
|
134
|
+
'on:focusout'?: import("svelte/elements").FocusEventHandler<HTMLImageElement> | null | undefined;
|
135
|
+
'on:blur'?: import("svelte/elements").FocusEventHandler<HTMLImageElement> | null | undefined;
|
136
|
+
'on:change'?: import("svelte/elements").FormEventHandler<HTMLImageElement> | null | undefined;
|
137
|
+
'on:beforeinput'?: import("svelte/elements").EventHandler<InputEvent, HTMLImageElement> | null | undefined;
|
138
|
+
'on:input'?: import("svelte/elements").FormEventHandler<HTMLImageElement> | null | undefined;
|
139
|
+
'on:reset'?: import("svelte/elements").FormEventHandler<HTMLImageElement> | null | undefined;
|
140
|
+
'on:submit'?: import("svelte/elements").EventHandler<SubmitEvent, HTMLImageElement> | null | undefined;
|
141
|
+
'on:invalid'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
142
|
+
'on:formdata'?: import("svelte/elements").EventHandler<FormDataEvent, HTMLImageElement> | null | undefined;
|
143
|
+
'on:load'?: import("svelte/elements").EventHandler | undefined | null;
|
144
|
+
'on:error'?: import("svelte/elements").EventHandler | undefined | null;
|
145
|
+
'on:beforetoggle'?: import("svelte/elements").ToggleEventHandler<HTMLImageElement> | null | undefined;
|
146
|
+
'on:toggle'?: import("svelte/elements").ToggleEventHandler<HTMLImageElement> | null | undefined;
|
147
|
+
'on:keydown'?: import("svelte/elements").KeyboardEventHandler<HTMLImageElement> | null | undefined;
|
148
|
+
'on:keypress'?: import("svelte/elements").KeyboardEventHandler<HTMLImageElement> | null | undefined;
|
149
|
+
'on:keyup'?: import("svelte/elements").KeyboardEventHandler<HTMLImageElement> | null | undefined;
|
150
|
+
'on:abort'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
151
|
+
'on:canplay'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
152
|
+
'on:canplaythrough'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
153
|
+
'on:cuechange'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
154
|
+
'on:durationchange'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
155
|
+
'on:emptied'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
156
|
+
'on:encrypted'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
157
|
+
'on:ended'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
158
|
+
'on:loadeddata'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
159
|
+
'on:loadedmetadata'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
160
|
+
'on:loadstart'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
161
|
+
'on:pause'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
162
|
+
'on:play'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
163
|
+
'on:playing'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
164
|
+
'on:progress'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
165
|
+
'on:ratechange'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
166
|
+
'on:seeked'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
167
|
+
'on:seeking'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
168
|
+
'on:stalled'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
169
|
+
'on:suspend'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
170
|
+
'on:timeupdate'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
171
|
+
'on:volumechange'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
172
|
+
'on:waiting'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
173
|
+
'on:auxclick'?: import("svelte/elements").MouseEventHandler<HTMLImageElement> | null | undefined;
|
174
|
+
'on:click'?: import("svelte/elements").MouseEventHandler<HTMLImageElement> | null | undefined;
|
175
|
+
'on:contextmenu'?: import("svelte/elements").MouseEventHandler<HTMLImageElement> | null | undefined;
|
176
|
+
'on:dblclick'?: import("svelte/elements").MouseEventHandler<HTMLImageElement> | null | undefined;
|
177
|
+
'on:drag'?: import("svelte/elements").DragEventHandler<HTMLImageElement> | null | undefined;
|
178
|
+
'on:dragend'?: import("svelte/elements").DragEventHandler<HTMLImageElement> | null | undefined;
|
179
|
+
'on:dragenter'?: import("svelte/elements").DragEventHandler<HTMLImageElement> | null | undefined;
|
180
|
+
'on:dragexit'?: import("svelte/elements").DragEventHandler<HTMLImageElement> | null | undefined;
|
181
|
+
'on:dragleave'?: import("svelte/elements").DragEventHandler<HTMLImageElement> | null | undefined;
|
182
|
+
'on:dragover'?: import("svelte/elements").DragEventHandler<HTMLImageElement> | null | undefined;
|
183
|
+
'on:dragstart'?: import("svelte/elements").DragEventHandler<HTMLImageElement> | null | undefined;
|
184
|
+
'on:drop'?: import("svelte/elements").DragEventHandler<HTMLImageElement> | null | undefined;
|
185
|
+
'on:mousedown'?: import("svelte/elements").MouseEventHandler<HTMLImageElement> | null | undefined;
|
186
|
+
'on:mouseenter'?: import("svelte/elements").MouseEventHandler<HTMLImageElement> | null | undefined;
|
187
|
+
'on:mouseleave'?: import("svelte/elements").MouseEventHandler<HTMLImageElement> | null | undefined;
|
188
|
+
'on:mousemove'?: import("svelte/elements").MouseEventHandler<HTMLImageElement> | null | undefined;
|
189
|
+
'on:mouseout'?: import("svelte/elements").MouseEventHandler<HTMLImageElement> | null | undefined;
|
190
|
+
'on:mouseover'?: import("svelte/elements").MouseEventHandler<HTMLImageElement> | null | undefined;
|
191
|
+
'on:mouseup'?: import("svelte/elements").MouseEventHandler<HTMLImageElement> | null | undefined;
|
192
|
+
'on:select'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
193
|
+
'on:selectionchange'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
194
|
+
'on:selectstart'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
195
|
+
'on:touchcancel'?: import("svelte/elements").TouchEventHandler<HTMLImageElement> | null | undefined;
|
196
|
+
'on:touchend'?: import("svelte/elements").TouchEventHandler<HTMLImageElement> | null | undefined;
|
197
|
+
'on:touchmove'?: import("svelte/elements").TouchEventHandler<HTMLImageElement> | null | undefined;
|
198
|
+
'on:touchstart'?: import("svelte/elements").TouchEventHandler<HTMLImageElement> | null | undefined;
|
199
|
+
'on:gotpointercapture'?: import("svelte/elements").PointerEventHandler<HTMLImageElement> | null | undefined;
|
200
|
+
'on:pointercancel'?: import("svelte/elements").PointerEventHandler<HTMLImageElement> | null | undefined;
|
201
|
+
'on:pointerdown'?: import("svelte/elements").PointerEventHandler<HTMLImageElement> | null | undefined;
|
202
|
+
'on:pointerenter'?: import("svelte/elements").PointerEventHandler<HTMLImageElement> | null | undefined;
|
203
|
+
'on:pointerleave'?: import("svelte/elements").PointerEventHandler<HTMLImageElement> | null | undefined;
|
204
|
+
'on:pointermove'?: import("svelte/elements").PointerEventHandler<HTMLImageElement> | null | undefined;
|
205
|
+
'on:pointerout'?: import("svelte/elements").PointerEventHandler<HTMLImageElement> | null | undefined;
|
206
|
+
'on:pointerover'?: import("svelte/elements").PointerEventHandler<HTMLImageElement> | null | undefined;
|
207
|
+
'on:pointerup'?: import("svelte/elements").PointerEventHandler<HTMLImageElement> | null | undefined;
|
208
|
+
'on:lostpointercapture'?: import("svelte/elements").PointerEventHandler<HTMLImageElement> | null | undefined;
|
209
|
+
'on:gamepadconnected'?: import("svelte/elements").GamepadEventHandler<HTMLImageElement> | null | undefined;
|
210
|
+
'on:gamepaddisconnected'?: import("svelte/elements").GamepadEventHandler<HTMLImageElement> | null | undefined;
|
211
|
+
'on:scroll'?: import("svelte/elements").UIEventHandler<HTMLImageElement> | null | undefined;
|
212
|
+
'on:scrollend'?: import("svelte/elements").UIEventHandler<HTMLImageElement> | null | undefined;
|
213
|
+
'on:resize'?: import("svelte/elements").UIEventHandler<HTMLImageElement> | null | undefined;
|
214
|
+
'on:wheel'?: import("svelte/elements").WheelEventHandler<HTMLImageElement> | null | undefined;
|
215
|
+
'on:animationstart'?: import("svelte/elements").AnimationEventHandler<HTMLImageElement> | null | undefined;
|
216
|
+
'on:animationend'?: import("svelte/elements").AnimationEventHandler<HTMLImageElement> | null | undefined;
|
217
|
+
'on:animationiteration'?: import("svelte/elements").AnimationEventHandler<HTMLImageElement> | null | undefined;
|
218
|
+
'on:transitionstart'?: import("svelte/elements").TransitionEventHandler<HTMLImageElement> | null | undefined;
|
219
|
+
'on:transitionrun'?: import("svelte/elements").TransitionEventHandler<HTMLImageElement> | null | undefined;
|
220
|
+
'on:transitionend'?: import("svelte/elements").TransitionEventHandler<HTMLImageElement> | null | undefined;
|
221
|
+
'on:transitioncancel'?: import("svelte/elements").TransitionEventHandler<HTMLImageElement> | null | undefined;
|
222
|
+
'on:outrostart'?: import("svelte/elements").EventHandler<CustomEvent<null>, HTMLImageElement> | null | undefined;
|
223
|
+
'on:outroend'?: import("svelte/elements").EventHandler<CustomEvent<null>, HTMLImageElement> | null | undefined;
|
224
|
+
'on:introstart'?: import("svelte/elements").EventHandler<CustomEvent<null>, HTMLImageElement> | null | undefined;
|
225
|
+
'on:introend'?: import("svelte/elements").EventHandler<CustomEvent<null>, HTMLImageElement> | null | undefined;
|
226
|
+
'on:message'?: import("svelte/elements").MessageEventHandler<HTMLImageElement> | null | undefined;
|
227
|
+
'on:messageerror'?: import("svelte/elements").MessageEventHandler<HTMLImageElement> | null | undefined;
|
228
|
+
'on:visibilitychange'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
229
|
+
'on:cancel'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
230
|
+
'on:close'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
231
|
+
'on:fullscreenchange'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
232
|
+
'on:fullscreenerror'?: import("svelte/elements").EventHandler<Event, HTMLImageElement> | null | undefined;
|
233
|
+
"data-testid"?: string | undefined;
|
234
|
+
};
|
235
|
+
events: {
|
236
|
+
load?: CustomEvent<void | undefined> | undefined;
|
237
|
+
} & {
|
238
|
+
[evt: string]: CustomEvent<any>;
|
239
|
+
};
|
240
|
+
slots: {};
|
241
|
+
};
|
242
|
+
export type ImageProps = typeof __propDef.props;
|
243
|
+
export type ImageEvents = typeof __propDef.events;
|
244
|
+
export type ImageSlots = typeof __propDef.slots;
|
245
|
+
export default class Image extends SvelteComponent<ImageProps, ImageEvents, ImageSlots> {
|
246
|
+
}
|
247
|
+
export {};
|
@@ -0,0 +1,155 @@
|
|
1
|
+
<script>import { createEventDispatcher, onMount } from "svelte";
|
2
|
+
import { uploadToHuggingFace } from "@gradio/utils";
|
3
|
+
import { BlockLabel, Empty, IconButton, ShareButton } from "@gradio/atoms";
|
4
|
+
import { Download } from "@gradio/icons";
|
5
|
+
import { get_coordinates_of_clicked_image } from "./utils";
|
6
|
+
import Image from "./Image.svelte";
|
7
|
+
import { DownloadLink } from "@gradio/wasm/svelte";
|
8
|
+
import { Maximize, Minimize } from "@gradio/icons";
|
9
|
+
import { Image as ImageIcon } from "@gradio/icons";
|
10
|
+
import {} from "@gradio/client";
|
11
|
+
export let value;
|
12
|
+
export let label = void 0;
|
13
|
+
export let show_label;
|
14
|
+
export let show_download_button = true;
|
15
|
+
export let selectable = false;
|
16
|
+
export let show_share_button = false;
|
17
|
+
export let i18n;
|
18
|
+
export let show_fullscreen_button = true;
|
19
|
+
const dispatch = createEventDispatcher();
|
20
|
+
const handle_click = (evt) => {
|
21
|
+
let coordinates = get_coordinates_of_clicked_image(evt);
|
22
|
+
if (coordinates) {
|
23
|
+
dispatch("select", { index: coordinates, value: null });
|
24
|
+
}
|
25
|
+
};
|
26
|
+
let is_full_screen = false;
|
27
|
+
let image_container;
|
28
|
+
onMount(() => {
|
29
|
+
document.addEventListener("fullscreenchange", () => {
|
30
|
+
is_full_screen = !!document.fullscreenElement;
|
31
|
+
});
|
32
|
+
});
|
33
|
+
const toggle_full_screen = async () => {
|
34
|
+
if (!is_full_screen) {
|
35
|
+
await image_container.requestFullscreen();
|
36
|
+
} else {
|
37
|
+
await document.exitFullscreen();
|
38
|
+
is_full_screen = !is_full_screen;
|
39
|
+
}
|
40
|
+
};
|
41
|
+
</script>
|
42
|
+
|
43
|
+
<BlockLabel
|
44
|
+
{show_label}
|
45
|
+
Icon={ImageIcon}
|
46
|
+
label={!show_label ? "" : label || i18n("image.image")}
|
47
|
+
/>
|
48
|
+
{#if value === null || !value.url}
|
49
|
+
<Empty unpadded_box={true} size="large"><ImageIcon /></Empty>
|
50
|
+
{:else}
|
51
|
+
<div class="image-container" bind:this={image_container}>
|
52
|
+
<div class="icon-buttons">
|
53
|
+
{#if !is_full_screen && show_fullscreen_button}
|
54
|
+
<IconButton
|
55
|
+
Icon={Maximize}
|
56
|
+
label={is_full_screen ? "Exit full screen" : "View in full screen"}
|
57
|
+
on:click={toggle_full_screen}
|
58
|
+
/>
|
59
|
+
{/if}
|
60
|
+
|
61
|
+
{#if is_full_screen && show_fullscreen_button}
|
62
|
+
<IconButton
|
63
|
+
Icon={Minimize}
|
64
|
+
label={is_full_screen ? "Exit full screen" : "View in full screen"}
|
65
|
+
on:click={toggle_full_screen}
|
66
|
+
/>
|
67
|
+
{/if}
|
68
|
+
|
69
|
+
{#if show_download_button}
|
70
|
+
<DownloadLink href={value.url} download={value.orig_name || "image"}>
|
71
|
+
<IconButton Icon={Download} label={i18n("common.download")} />
|
72
|
+
</DownloadLink>
|
73
|
+
{/if}
|
74
|
+
{#if show_share_button}
|
75
|
+
<ShareButton
|
76
|
+
{i18n}
|
77
|
+
on:share
|
78
|
+
on:error
|
79
|
+
formatter={async (value) => {
|
80
|
+
if (!value) return "";
|
81
|
+
let url = await uploadToHuggingFace(value, "url");
|
82
|
+
return `<img src="${url}" />`;
|
83
|
+
}}
|
84
|
+
{value}
|
85
|
+
/>
|
86
|
+
{/if}
|
87
|
+
</div>
|
88
|
+
<button on:click={handle_click}>
|
89
|
+
<div class:selectable class="image-frame">
|
90
|
+
<Image src={value.url} alt="" loading="lazy" on:load />
|
91
|
+
</div>
|
92
|
+
</button>
|
93
|
+
</div>
|
94
|
+
{/if}
|
95
|
+
|
96
|
+
<style>
|
97
|
+
.image-container {
|
98
|
+
height: 100%;
|
99
|
+
position: relative;
|
100
|
+
}
|
101
|
+
|
102
|
+
.image-container button {
|
103
|
+
width: var(--size-full);
|
104
|
+
height: var(--size-full);
|
105
|
+
border-radius: var(--radius-lg);
|
106
|
+
|
107
|
+
display: flex;
|
108
|
+
align-items: center;
|
109
|
+
justify-content: center;
|
110
|
+
}
|
111
|
+
|
112
|
+
.image-frame {
|
113
|
+
width: auto;
|
114
|
+
height: 100%;
|
115
|
+
display: flex;
|
116
|
+
align-items: center;
|
117
|
+
justify-content: center;
|
118
|
+
}
|
119
|
+
.image-frame :global(img) {
|
120
|
+
width: var(--size-full);
|
121
|
+
height: var(--size-full);
|
122
|
+
object-fit: scale-down;
|
123
|
+
}
|
124
|
+
|
125
|
+
.selectable {
|
126
|
+
cursor: crosshair;
|
127
|
+
}
|
128
|
+
|
129
|
+
.icon-buttons {
|
130
|
+
display: flex;
|
131
|
+
position: absolute;
|
132
|
+
top: 6px;
|
133
|
+
right: 6px;
|
134
|
+
gap: var(--size-1);
|
135
|
+
z-index: 1;
|
136
|
+
}
|
137
|
+
|
138
|
+
:global(.fullscreen-controls svg) {
|
139
|
+
position: relative;
|
140
|
+
top: 0px;
|
141
|
+
}
|
142
|
+
|
143
|
+
:global(.image-container:fullscreen) {
|
144
|
+
background-color: black;
|
145
|
+
display: flex;
|
146
|
+
justify-content: center;
|
147
|
+
align-items: center;
|
148
|
+
}
|
149
|
+
|
150
|
+
:global(.image-container:fullscreen img) {
|
151
|
+
max-width: 90vw;
|
152
|
+
max-height: 90vh;
|
153
|
+
object-fit: scale-down;
|
154
|
+
}
|
155
|
+
</style>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
2
|
+
import type { SelectData } from "@gradio/utils";
|
3
|
+
import { type FileData } from "@gradio/client";
|
4
|
+
import type { I18nFormatter } from "@gradio/utils";
|
5
|
+
declare const __propDef: {
|
6
|
+
props: {
|
7
|
+
value: null | FileData;
|
8
|
+
label?: string | undefined;
|
9
|
+
show_label: boolean;
|
10
|
+
show_download_button?: boolean | undefined;
|
11
|
+
selectable?: boolean | undefined;
|
12
|
+
show_share_button?: boolean | undefined;
|
13
|
+
i18n: I18nFormatter;
|
14
|
+
show_fullscreen_button?: boolean | undefined;
|
15
|
+
};
|
16
|
+
events: {
|
17
|
+
share: CustomEvent<import("@gradio/utils").ShareData>;
|
18
|
+
error: CustomEvent<string>;
|
19
|
+
load: CustomEvent<void | undefined> | undefined;
|
20
|
+
change: CustomEvent<string>;
|
21
|
+
select: CustomEvent<SelectData>;
|
22
|
+
} & {
|
23
|
+
[evt: string]: CustomEvent<any>;
|
24
|
+
};
|
25
|
+
slots: {};
|
26
|
+
};
|
27
|
+
export type ImagePreviewProps = typeof __propDef.props;
|
28
|
+
export type ImagePreviewEvents = typeof __propDef.events;
|
29
|
+
export type ImagePreviewSlots = typeof __propDef.slots;
|
30
|
+
export default class ImagePreview extends SvelteComponent<ImagePreviewProps, ImagePreviewEvents, ImagePreviewSlots> {
|
31
|
+
}
|
32
|
+
export {};
|
@@ -0,0 +1,181 @@
|
|
1
|
+
<script>import { createEventDispatcher, tick } from "svelte";
|
2
|
+
import { BlockLabel } from "@gradio/atoms";
|
3
|
+
import { Image as ImageIcon } from "@gradio/icons";
|
4
|
+
import { get_coordinates_of_clicked_image } from "./utils";
|
5
|
+
import Webcam from "./Webcam.svelte";
|
6
|
+
import { Upload } from "@gradio/upload";
|
7
|
+
import ClearImage from "./ClearImage.svelte";
|
8
|
+
import { SelectSource } from "@gradio/atoms";
|
9
|
+
import Image from "./Image.svelte";
|
10
|
+
export let value;
|
11
|
+
export let label = void 0;
|
12
|
+
export let show_label;
|
13
|
+
export let sources = ["upload", "clipboard", "webcam"];
|
14
|
+
export let streaming = false;
|
15
|
+
export let pending = false;
|
16
|
+
export let mirror_webcam;
|
17
|
+
export let selectable = false;
|
18
|
+
export let root;
|
19
|
+
export let i18n;
|
20
|
+
export let max_file_size = null;
|
21
|
+
export let upload;
|
22
|
+
export let stream_handler;
|
23
|
+
let upload_input;
|
24
|
+
let uploading = false;
|
25
|
+
export let active_source = null;
|
26
|
+
function handle_upload({ detail }) {
|
27
|
+
value = detail;
|
28
|
+
dispatch("upload");
|
29
|
+
}
|
30
|
+
function handle_clear() {
|
31
|
+
value = null;
|
32
|
+
dispatch("clear");
|
33
|
+
dispatch("change", null);
|
34
|
+
}
|
35
|
+
async function handle_save(img_blob) {
|
36
|
+
pending = true;
|
37
|
+
const f = await upload_input.load_files([
|
38
|
+
new File([img_blob], `webcam.png`)
|
39
|
+
]);
|
40
|
+
value = f?.[0] || null;
|
41
|
+
await tick();
|
42
|
+
dispatch(streaming ? "stream" : "change");
|
43
|
+
pending = false;
|
44
|
+
}
|
45
|
+
$:
|
46
|
+
active_streaming = streaming && active_source === "webcam";
|
47
|
+
$:
|
48
|
+
if (uploading && !active_streaming)
|
49
|
+
value = null;
|
50
|
+
const dispatch = createEventDispatcher();
|
51
|
+
export let dragging = false;
|
52
|
+
$:
|
53
|
+
dispatch("drag", dragging);
|
54
|
+
function handle_click(evt) {
|
55
|
+
let coordinates = get_coordinates_of_clicked_image(evt);
|
56
|
+
if (coordinates) {
|
57
|
+
dispatch("select", { index: coordinates, value: null });
|
58
|
+
}
|
59
|
+
}
|
60
|
+
$:
|
61
|
+
if (!active_source && sources) {
|
62
|
+
active_source = sources[0];
|
63
|
+
}
|
64
|
+
async function handle_select_source(source) {
|
65
|
+
switch (source) {
|
66
|
+
case "clipboard":
|
67
|
+
upload_input.paste_clipboard();
|
68
|
+
break;
|
69
|
+
default:
|
70
|
+
break;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
</script>
|
74
|
+
|
75
|
+
<BlockLabel {show_label} Icon={ImageIcon} label={label || "Image"} />
|
76
|
+
|
77
|
+
<div data-testid="image" class="image-container">
|
78
|
+
{#if value?.url && !active_streaming}
|
79
|
+
<ClearImage
|
80
|
+
on:remove_image={() => {
|
81
|
+
value = null;
|
82
|
+
dispatch("clear");
|
83
|
+
}}
|
84
|
+
/>
|
85
|
+
{/if}
|
86
|
+
<div
|
87
|
+
class="upload-container"
|
88
|
+
class:reduced-height={sources.length > 1}
|
89
|
+
style:width={value ? "auto" : "100%"}
|
90
|
+
>
|
91
|
+
<Upload
|
92
|
+
hidden={value !== null || active_source === "webcam"}
|
93
|
+
bind:this={upload_input}
|
94
|
+
bind:uploading
|
95
|
+
bind:dragging
|
96
|
+
filetype={active_source === "clipboard" ? "clipboard" : "image/*"}
|
97
|
+
on:load={handle_upload}
|
98
|
+
on:error
|
99
|
+
{root}
|
100
|
+
{max_file_size}
|
101
|
+
disable_click={!sources.includes("upload") || value !== null}
|
102
|
+
{upload}
|
103
|
+
{stream_handler}
|
104
|
+
>
|
105
|
+
{#if value === null}
|
106
|
+
<slot />
|
107
|
+
{/if}
|
108
|
+
</Upload>
|
109
|
+
{#if active_source === "webcam" && (streaming || (!streaming && !value))}
|
110
|
+
<Webcam
|
111
|
+
{root}
|
112
|
+
on:capture={(e) => handle_save(e.detail)}
|
113
|
+
on:stream={(e) => handle_save(e.detail)}
|
114
|
+
on:error
|
115
|
+
on:drag
|
116
|
+
on:upload={(e) => handle_save(e.detail)}
|
117
|
+
{mirror_webcam}
|
118
|
+
{streaming}
|
119
|
+
mode="image"
|
120
|
+
include_audio={false}
|
121
|
+
{i18n}
|
122
|
+
{upload}
|
123
|
+
/>
|
124
|
+
{:else if value !== null && !streaming}
|
125
|
+
<!-- svelte-ignore a11y-click-events-have-key-events-->
|
126
|
+
<!-- svelte-ignore a11y-no-static-element-interactions-->
|
127
|
+
<div class:selectable class="image-frame" on:click={handle_click}>
|
128
|
+
<Image src={value.url} alt={value.alt_text} />
|
129
|
+
</div>
|
130
|
+
{/if}
|
131
|
+
</div>
|
132
|
+
{#if sources.length > 1 || sources.includes("clipboard")}
|
133
|
+
<SelectSource
|
134
|
+
{sources}
|
135
|
+
bind:active_source
|
136
|
+
{handle_clear}
|
137
|
+
handle_select={handle_select_source}
|
138
|
+
/>
|
139
|
+
{/if}
|
140
|
+
</div>
|
141
|
+
|
142
|
+
<style>
|
143
|
+
.image-frame :global(img) {
|
144
|
+
width: var(--size-full);
|
145
|
+
height: var(--size-full);
|
146
|
+
object-fit: scale-down;
|
147
|
+
}
|
148
|
+
|
149
|
+
.image-frame {
|
150
|
+
object-fit: cover;
|
151
|
+
width: 100%;
|
152
|
+
height: 100%;
|
153
|
+
}
|
154
|
+
|
155
|
+
.upload-container {
|
156
|
+
display: flex;
|
157
|
+
align-items: center;
|
158
|
+
justify-content: center;
|
159
|
+
|
160
|
+
height: 100%;
|
161
|
+
flex-shrink: 1;
|
162
|
+
max-height: 100%;
|
163
|
+
}
|
164
|
+
|
165
|
+
.reduced-height {
|
166
|
+
height: calc(100% - var(--size-10));
|
167
|
+
}
|
168
|
+
|
169
|
+
.image-container {
|
170
|
+
display: flex;
|
171
|
+
height: 100%;
|
172
|
+
flex-direction: column;
|
173
|
+
justify-content: center;
|
174
|
+
align-items: center;
|
175
|
+
max-height: 100%;
|
176
|
+
}
|
177
|
+
|
178
|
+
.selectable {
|
179
|
+
cursor: crosshair;
|
180
|
+
}
|
181
|
+
</style>
|