@gradio/image 0.23.0 → 0.23.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 +11 -0
- package/dist/shared/ImageUploader.svelte +19 -5
- package/package.json +5 -5
- package/shared/ImageUploader.svelte +20 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @gradio/image
|
|
2
2
|
|
|
3
|
+
## 0.23.1
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- [#11969](https://github.com/gradio-app/gradio/pull/11969) [`c8f7909`](https://github.com/gradio-app/gradio/commit/c8f79090ede3b071a8d9620a885350b6ee5a8926) - Show UploadProgress for Webcam Uploads. Thanks @freddyaboulton!
|
|
8
|
+
|
|
9
|
+
### Dependency updates
|
|
10
|
+
|
|
11
|
+
- @gradio/upload@0.17.1
|
|
12
|
+
- @gradio/atoms@0.18.1
|
|
13
|
+
|
|
3
14
|
## 0.23.0
|
|
4
15
|
|
|
5
16
|
### Features
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "@gradio/utils";
|
|
7
7
|
import { get_coordinates_of_clicked_image } from "./utils";
|
|
8
8
|
import Webcam from "./Webcam.svelte";
|
|
9
|
-
import { Upload } from "@gradio/upload";
|
|
9
|
+
import { Upload, UploadProgress } from "@gradio/upload";
|
|
10
10
|
import { FileData } from "@gradio/client";
|
|
11
11
|
import { SelectSource } from "@gradio/atoms";
|
|
12
12
|
import Image from "./Image.svelte";
|
|
@@ -31,6 +31,8 @@ let upload_input;
|
|
|
31
31
|
export let uploading = false;
|
|
32
32
|
export let active_source = null;
|
|
33
33
|
export let fullscreen = false;
|
|
34
|
+
let files = [];
|
|
35
|
+
let upload_id;
|
|
34
36
|
async function handle_upload({
|
|
35
37
|
detail
|
|
36
38
|
}) {
|
|
@@ -66,10 +68,20 @@ async function handle_save(img_blob, event) {
|
|
|
66
68
|
});
|
|
67
69
|
return;
|
|
68
70
|
}
|
|
71
|
+
upload_id = Math.random().toString(36).substring(2, 15);
|
|
72
|
+
const f_ = new File([img_blob], `image.${streaming ? "jpeg" : "png"}`);
|
|
73
|
+
files = [
|
|
74
|
+
new FileData({
|
|
75
|
+
path: f_.name,
|
|
76
|
+
orig_name: f_.name,
|
|
77
|
+
blob: f_,
|
|
78
|
+
size: f_.size,
|
|
79
|
+
mime_type: f_.type,
|
|
80
|
+
is_stream: false
|
|
81
|
+
})
|
|
82
|
+
];
|
|
69
83
|
pending = true;
|
|
70
|
-
const f = await upload_input.load_files([
|
|
71
|
-
new File([img_blob], `image/${streaming ? "jpeg" : "png"}`)
|
|
72
|
-
]);
|
|
84
|
+
const f = await upload_input.load_files([f_], upload_id);
|
|
73
85
|
if (event === "change" || event === "upload") {
|
|
74
86
|
value = f?.[0] || null;
|
|
75
87
|
await tick();
|
|
@@ -165,7 +177,9 @@ async function on_drop(evt) {
|
|
|
165
177
|
<slot />
|
|
166
178
|
{/if}
|
|
167
179
|
</Upload>
|
|
168
|
-
{#if active_source === "webcam" &&
|
|
180
|
+
{#if active_source === "webcam" && !streaming && pending}
|
|
181
|
+
<UploadProgress {root} {upload_id} {stream_handler} {files} />
|
|
182
|
+
{:else if active_source === "webcam" && (streaming || (!streaming && !value))}
|
|
169
183
|
<Webcam
|
|
170
184
|
{root}
|
|
171
185
|
{value}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/image",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
"cropperjs": "^1.5.12",
|
|
11
11
|
"lazy-brush": "^1.0.1",
|
|
12
12
|
"resize-observer-polyfill": "^1.5.1",
|
|
13
|
-
"@gradio/atoms": "^0.18.
|
|
14
|
-
"@gradio/icons": "^0.14.0",
|
|
15
|
-
"@gradio/statustracker": "^0.11.1",
|
|
13
|
+
"@gradio/atoms": "^0.18.1",
|
|
16
14
|
"@gradio/client": "^1.19.0",
|
|
17
|
-
"@gradio/
|
|
15
|
+
"@gradio/statustracker": "^0.11.1",
|
|
16
|
+
"@gradio/icons": "^0.14.0",
|
|
17
|
+
"@gradio/upload": "^0.17.1",
|
|
18
18
|
"@gradio/utils": "^0.10.2"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { get_coordinates_of_clicked_image } from "./utils";
|
|
12
12
|
import Webcam from "./Webcam.svelte";
|
|
13
13
|
|
|
14
|
-
import { Upload } from "@gradio/upload";
|
|
14
|
+
import { Upload, UploadProgress } from "@gradio/upload";
|
|
15
15
|
import { FileData, type Client } from "@gradio/client";
|
|
16
16
|
import { SelectSource } from "@gradio/atoms";
|
|
17
17
|
import Image from "./Image.svelte";
|
|
@@ -44,6 +44,9 @@
|
|
|
44
44
|
export let active_source: source_type = null;
|
|
45
45
|
export let fullscreen = false;
|
|
46
46
|
|
|
47
|
+
let files: FileData[] = [];
|
|
48
|
+
let upload_id: string;
|
|
49
|
+
|
|
47
50
|
async function handle_upload({
|
|
48
51
|
detail
|
|
49
52
|
}: CustomEvent<FileData>): Promise<void> {
|
|
@@ -86,11 +89,20 @@
|
|
|
86
89
|
});
|
|
87
90
|
return;
|
|
88
91
|
}
|
|
92
|
+
upload_id = Math.random().toString(36).substring(2, 15);
|
|
93
|
+
const f_ = new File([img_blob], `image.${streaming ? "jpeg" : "png"}`);
|
|
94
|
+
files = [
|
|
95
|
+
new FileData({
|
|
96
|
+
path: f_.name,
|
|
97
|
+
orig_name: f_.name,
|
|
98
|
+
blob: f_,
|
|
99
|
+
size: f_.size,
|
|
100
|
+
mime_type: f_.type,
|
|
101
|
+
is_stream: false
|
|
102
|
+
})
|
|
103
|
+
];
|
|
89
104
|
pending = true;
|
|
90
|
-
const f = await upload_input.load_files([
|
|
91
|
-
new File([img_blob], `image/${streaming ? "jpeg" : "png"}`)
|
|
92
|
-
]);
|
|
93
|
-
|
|
105
|
+
const f = await upload_input.load_files([f_], upload_id);
|
|
94
106
|
if (event === "change" || event === "upload") {
|
|
95
107
|
value = f?.[0] || null;
|
|
96
108
|
await tick();
|
|
@@ -209,7 +221,9 @@
|
|
|
209
221
|
<slot />
|
|
210
222
|
{/if}
|
|
211
223
|
</Upload>
|
|
212
|
-
{#if active_source === "webcam" &&
|
|
224
|
+
{#if active_source === "webcam" && !streaming && pending}
|
|
225
|
+
<UploadProgress {root} {upload_id} {stream_handler} {files} />
|
|
226
|
+
{:else if active_source === "webcam" && (streaming || (!streaming && !value))}
|
|
213
227
|
<Webcam
|
|
214
228
|
{root}
|
|
215
229
|
{value}
|