@gradio/upload 0.7.4 → 0.7.6
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 +13 -1
- package/package.json +5 -5
- package/src/Upload.svelte +25 -11
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# @gradio/upload
|
2
2
|
|
3
|
+
## 0.7.6
|
4
|
+
|
5
|
+
### Features
|
6
|
+
|
7
|
+
- [#7625](https://github.com/gradio-app/gradio/pull/7625) [`8181695`](https://github.com/gradio-app/gradio/commit/8181695e70187e8bc2bf7518697098c8d1b9843d) - image upload fix. Thanks [@dawoodkhan82](https://github.com/dawoodkhan82)!
|
8
|
+
|
9
|
+
## 0.7.5
|
10
|
+
|
11
|
+
### Fixes
|
12
|
+
|
13
|
+
- [#7559](https://github.com/gradio-app/gradio/pull/7559) [`26356a6`](https://github.com/gradio-app/gradio/commit/26356a623c4196f48ca236d973a597831743cdb8) - Fixes: Invalid file_type breaks drag and drop. Thanks [@dawoodkhan82](https://github.com/dawoodkhan82)!
|
14
|
+
|
3
15
|
## 0.7.4
|
4
16
|
|
5
17
|
### Patch Changes
|
@@ -354,4 +366,4 @@ From the backend, streamed outputs are served from the `/stream/` endpoint inste
|
|
354
366
|
### Patch Changes
|
355
367
|
|
356
368
|
- Updated dependencies []:
|
357
|
-
- @gradio/atoms@0.0.2
|
369
|
+
- @gradio/atoms@0.0.2
|
package/package.json
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
{
|
2
2
|
"name": "@gradio/upload",
|
3
|
-
"version": "0.7.
|
3
|
+
"version": "0.7.6",
|
4
4
|
"description": "Gradio UI packages",
|
5
5
|
"type": "module",
|
6
6
|
"main": "src/index.ts",
|
7
7
|
"author": "",
|
8
8
|
"license": "ISC",
|
9
9
|
"dependencies": {
|
10
|
+
"@gradio/icons": "^0.3.3",
|
10
11
|
"@gradio/atoms": "^0.5.3",
|
11
|
-
"@gradio/client": "^0.12.
|
12
|
-
"@gradio/upload": "^0.7.
|
12
|
+
"@gradio/client": "^0.12.2",
|
13
|
+
"@gradio/upload": "^0.7.6",
|
13
14
|
"@gradio/utils": "^0.3.0",
|
14
|
-
"@gradio/wasm": "^0.
|
15
|
-
"@gradio/icons": "^0.3.3"
|
15
|
+
"@gradio/wasm": "^0.7.0"
|
16
16
|
},
|
17
17
|
"main_changeset": true,
|
18
18
|
"exports": {
|
package/src/Upload.svelte
CHANGED
@@ -25,19 +25,27 @@
|
|
25
25
|
const upload_fn = getContext<typeof upload_files>("upload_files");
|
26
26
|
|
27
27
|
let hidden_upload: HTMLInputElement;
|
28
|
-
|
29
28
|
const dispatch = createEventDispatcher();
|
30
|
-
|
31
|
-
|
29
|
+
const validFileTypes = ["image", "video", "audio", "text", "file"];
|
30
|
+
const processFileType = (type: string): string => {
|
31
|
+
if (type.startsWith(".") || type.endsWith("/*")) {
|
32
|
+
return type;
|
33
|
+
}
|
34
|
+
if (validFileTypes.includes(type)) {
|
35
|
+
return type + "/*";
|
36
|
+
}
|
37
|
+
return "." + type;
|
38
|
+
};
|
39
|
+
|
40
|
+
$: if (filetype == null) {
|
41
|
+
accept_file_types = null;
|
42
|
+
} else if (typeof filetype === "string") {
|
43
|
+
accept_file_types = processFileType(filetype);
|
32
44
|
} else {
|
33
|
-
filetype = filetype.map(
|
34
|
-
if (x.startsWith(".")) {
|
35
|
-
return x;
|
36
|
-
}
|
37
|
-
return x + "/*";
|
38
|
-
});
|
45
|
+
filetype = filetype.map(processFileType);
|
39
46
|
accept_file_types = filetype.join(", ");
|
40
47
|
}
|
48
|
+
|
41
49
|
function updateDragging(): void {
|
42
50
|
dragging = !dragging;
|
43
51
|
}
|
@@ -108,7 +116,13 @@
|
|
108
116
|
uploaded_file_extension: string,
|
109
117
|
uploaded_file_type: string
|
110
118
|
): boolean {
|
111
|
-
if (
|
119
|
+
if (
|
120
|
+
!file_accept ||
|
121
|
+
file_accept === "*" ||
|
122
|
+
file_accept === "file/*" ||
|
123
|
+
(Array.isArray(file_accept) &&
|
124
|
+
file_accept.some((accept) => accept === "*" || accept === "file/*"))
|
125
|
+
) {
|
112
126
|
return true;
|
113
127
|
}
|
114
128
|
let acceptArray: string[];
|
@@ -137,7 +151,7 @@
|
|
137
151
|
const file_extension = "." + file.name.split(".").pop();
|
138
152
|
if (
|
139
153
|
file_extension &&
|
140
|
-
is_valid_mimetype(
|
154
|
+
is_valid_mimetype(accept_file_types, file_extension, file.type)
|
141
155
|
) {
|
142
156
|
return true;
|
143
157
|
}
|