@gradio/upload 0.17.10 → 0.18.0
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 +18 -0
- package/dist/src/Upload.svelte +16 -11
- package/dist/src/Upload.svelte.d.ts +2 -2
- package/dist/src/UploadProgress.svelte +1 -2
- package/package.json +4 -4
- package/src/Upload.svelte +16 -11
- package/src/UploadProgress.svelte +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @gradio/upload
|
|
2
2
|
|
|
3
|
+
## 0.18.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- [#13526](https://github.com/gradio-app/gradio/pull/13526) [`53cb4ca`](https://github.com/gradio-app/gradio/commit/53cb4cae1ec3521e9170d12867253516413ba37a) - Run `pnpm lint` and `pnpm ts:check` on CI. Thanks @abidlabs!
|
|
8
|
+
|
|
9
|
+
### Dependency updates
|
|
10
|
+
|
|
11
|
+
- @gradio/atoms@0.25.0
|
|
12
|
+
- @gradio/utils@0.13.0
|
|
13
|
+
- @gradio/client@2.3.0
|
|
14
|
+
|
|
15
|
+
## 0.17.10
|
|
16
|
+
|
|
17
|
+
### Dependency updates
|
|
18
|
+
|
|
19
|
+
- @gradio/client@2.2.2
|
|
20
|
+
|
|
3
21
|
## 0.17.10
|
|
4
22
|
|
|
5
23
|
### Fixes
|
package/dist/src/Upload.svelte
CHANGED
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
icon_upload?: boolean;
|
|
50
50
|
height?: number | string | undefined;
|
|
51
51
|
aria_label?: string | undefined;
|
|
52
|
-
upload_promise?: Promise<(FileData | null)[]
|
|
53
|
-
onload?: (data:
|
|
52
|
+
upload_promise?: Promise<(FileData | null)[]> | null;
|
|
53
|
+
onload?: (data: any) => void;
|
|
54
54
|
onerror?: (error: string) => void;
|
|
55
55
|
children?: import("svelte").Snippet;
|
|
56
56
|
} = $props();
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
_open_file_upload();
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
let upload_id
|
|
62
|
+
let upload_id = "";
|
|
63
63
|
let file_data: FileData[];
|
|
64
64
|
let accept_file_types: string | null = $state(null);
|
|
65
65
|
let use_post_upload_validation: boolean | null = null;
|
|
@@ -141,14 +141,19 @@
|
|
|
141
141
|
uploading = true;
|
|
142
142
|
upload_promise = new Promise(async (resolve) => {
|
|
143
143
|
try {
|
|
144
|
-
const _file_data =
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
144
|
+
const _file_data =
|
|
145
|
+
(await upload(
|
|
146
|
+
file_data,
|
|
147
|
+
root,
|
|
148
|
+
upload_id,
|
|
149
|
+
max_file_size ?? Infinity
|
|
150
|
+
)) || [];
|
|
151
|
+
if (file_count === "single") {
|
|
152
|
+
if (_file_data[0] !== undefined) onload?.(_file_data[0]);
|
|
153
|
+
} else {
|
|
154
|
+
onload?.(_file_data);
|
|
155
|
+
}
|
|
156
|
+
resolve(_file_data);
|
|
152
157
|
uploading = false;
|
|
153
158
|
} catch (e) {
|
|
154
159
|
onerror?.((e as Error).message);
|
|
@@ -19,8 +19,8 @@ type $$ComponentProps = {
|
|
|
19
19
|
icon_upload?: boolean;
|
|
20
20
|
height?: number | string | undefined;
|
|
21
21
|
aria_label?: string | undefined;
|
|
22
|
-
upload_promise?: Promise<(FileData | null)[]
|
|
23
|
-
onload?: (data:
|
|
22
|
+
upload_promise?: Promise<(FileData | null)[]> | null;
|
|
23
|
+
onload?: (data: any) => void;
|
|
24
24
|
onerror?: (error: string) => void;
|
|
25
25
|
children?: import("svelte").Snippet;
|
|
26
26
|
};
|
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
let stream: Awaited<ReturnType<Client["stream"]>>;
|
|
22
22
|
let progress = $state(false);
|
|
23
23
|
let current_file_upload = $state<FileDataWithProgress>();
|
|
24
|
-
let file_to_display = $derived(current_file_upload || files_with_progress[0]);
|
|
25
|
-
|
|
26
24
|
let files_with_progress = $state<FileDataWithProgress[]>(
|
|
27
25
|
files.map((file) => {
|
|
28
26
|
return {
|
|
@@ -31,6 +29,7 @@
|
|
|
31
29
|
};
|
|
32
30
|
})
|
|
33
31
|
);
|
|
32
|
+
let file_to_display = $derived(current_file_upload || files_with_progress[0]);
|
|
34
33
|
|
|
35
34
|
function handleProgress(filename: string, chunk_size: number): void {
|
|
36
35
|
// Find the corresponding file in the array and update its progress
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/upload",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
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/atoms": "^0.25.0",
|
|
10
11
|
"@gradio/icons": "^0.15.1",
|
|
11
|
-
"@gradio/
|
|
12
|
-
"@gradio/
|
|
13
|
-
"@gradio/utils": "^0.12.2"
|
|
12
|
+
"@gradio/client": "^2.3.0",
|
|
13
|
+
"@gradio/utils": "^0.13.0"
|
|
14
14
|
},
|
|
15
15
|
"main_changeset": true,
|
|
16
16
|
"exports": {
|
package/src/Upload.svelte
CHANGED
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
icon_upload?: boolean;
|
|
50
50
|
height?: number | string | undefined;
|
|
51
51
|
aria_label?: string | undefined;
|
|
52
|
-
upload_promise?: Promise<(FileData | null)[]
|
|
53
|
-
onload?: (data:
|
|
52
|
+
upload_promise?: Promise<(FileData | null)[]> | null;
|
|
53
|
+
onload?: (data: any) => void;
|
|
54
54
|
onerror?: (error: string) => void;
|
|
55
55
|
children?: import("svelte").Snippet;
|
|
56
56
|
} = $props();
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
_open_file_upload();
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
let upload_id
|
|
62
|
+
let upload_id = "";
|
|
63
63
|
let file_data: FileData[];
|
|
64
64
|
let accept_file_types: string | null = $state(null);
|
|
65
65
|
let use_post_upload_validation: boolean | null = null;
|
|
@@ -141,14 +141,19 @@
|
|
|
141
141
|
uploading = true;
|
|
142
142
|
upload_promise = new Promise(async (resolve) => {
|
|
143
143
|
try {
|
|
144
|
-
const _file_data =
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
144
|
+
const _file_data =
|
|
145
|
+
(await upload(
|
|
146
|
+
file_data,
|
|
147
|
+
root,
|
|
148
|
+
upload_id,
|
|
149
|
+
max_file_size ?? Infinity
|
|
150
|
+
)) || [];
|
|
151
|
+
if (file_count === "single") {
|
|
152
|
+
if (_file_data[0] !== undefined) onload?.(_file_data[0]);
|
|
153
|
+
} else {
|
|
154
|
+
onload?.(_file_data);
|
|
155
|
+
}
|
|
156
|
+
resolve(_file_data);
|
|
152
157
|
uploading = false;
|
|
153
158
|
} catch (e) {
|
|
154
159
|
onerror?.((e as Error).message);
|
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
let stream: Awaited<ReturnType<Client["stream"]>>;
|
|
22
22
|
let progress = $state(false);
|
|
23
23
|
let current_file_upload = $state<FileDataWithProgress>();
|
|
24
|
-
let file_to_display = $derived(current_file_upload || files_with_progress[0]);
|
|
25
|
-
|
|
26
24
|
let files_with_progress = $state<FileDataWithProgress[]>(
|
|
27
25
|
files.map((file) => {
|
|
28
26
|
return {
|
|
@@ -31,6 +29,7 @@
|
|
|
31
29
|
};
|
|
32
30
|
})
|
|
33
31
|
);
|
|
32
|
+
let file_to_display = $derived(current_file_upload || files_with_progress[0]);
|
|
34
33
|
|
|
35
34
|
function handleProgress(filename: string, chunk_size: number): void {
|
|
36
35
|
// Find the corresponding file in the array and update its progress
|