@gradio/upload 0.16.14 → 0.16.16

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @gradio/upload
2
2
 
3
+ ## 0.16.16
4
+
5
+ ### Fixes
6
+
7
+ - [#11771](https://github.com/gradio-app/gradio/pull/11771) [`f53b24b`](https://github.com/gradio-app/gradio/commit/f53b24b010a98d9028d8bade39db9c4dd37782d1) - Fix file upload error due to file extension case differences. Thanks @rca-umb!
8
+
9
+ ### Dependency updates
10
+
11
+ - @gradio/icons@0.13.1
12
+
13
+ ## 0.16.15
14
+
15
+ ### Dependency updates
16
+
17
+ - @gradio/atoms@0.16.5
18
+ - @gradio/client@1.17.1
19
+ - @gradio/icons@0.13.0
20
+
3
21
  ## 0.16.14
4
22
 
5
23
  ### Dependency updates
@@ -2,9 +2,9 @@ import { SvelteComponent } from "svelte";
2
2
  import type { I18nFormatter } from "@gradio/utils";
3
3
  declare const __propDef: {
4
4
  props: {
5
- editable?: boolean | undefined;
6
- undoable?: boolean | undefined;
7
- download?: (string | null) | undefined;
5
+ editable?: boolean;
6
+ undoable?: boolean;
7
+ download?: string | null;
8
8
  i18n: I18nFormatter;
9
9
  };
10
10
  events: {
@@ -17,6 +17,8 @@ declare const __propDef: {
17
17
  slots: {
18
18
  default: {};
19
19
  };
20
+ exports?: {} | undefined;
21
+ bindings?: string | undefined;
20
22
  };
21
23
  export type ModifyUploadProps = typeof __propDef.props;
22
24
  export type ModifyUploadEvents = typeof __propDef.events;
@@ -1,6 +1,5 @@
1
1
  <script>import { createEventDispatcher, tick, getContext } from "svelte";
2
2
  import { prepare_files } from "@gradio/client";
3
- import { _ } from "svelte-i18n";
4
3
  import UploadProgress from "./UploadProgress.svelte";
5
4
  import { create_drag } from "./utils";
6
5
  const { drag, open_file_upload: _open_file_upload } = create_drag();
@@ -36,8 +35,7 @@ const get_ios = () => {
36
35
  }
37
36
  return false;
38
37
  };
39
- $:
40
- ios = get_ios();
38
+ $: ios = get_ios();
41
39
  const dispatch = createEventDispatcher();
42
40
  const validFileTypes = ["image", "video", "audio", "text", "file"];
43
41
  const process_file_type = (type) => {
@@ -56,17 +54,16 @@ const process_file_type = (type) => {
56
54
  }
57
55
  return "." + type;
58
56
  };
59
- $:
60
- if (filetype == null) {
61
- accept_file_types = null;
62
- } else if (typeof filetype === "string") {
63
- accept_file_types = process_file_type(filetype);
64
- } else if (ios && filetype.includes("file/*")) {
65
- accept_file_types = "*";
66
- } else {
67
- filetype = filetype.map(process_file_type);
68
- accept_file_types = filetype.join(", ");
69
- }
57
+ $: if (filetype == null) {
58
+ accept_file_types = null;
59
+ } else if (typeof filetype === "string") {
60
+ accept_file_types = process_file_type(filetype);
61
+ } else if (ios && filetype.includes("file/*")) {
62
+ accept_file_types = "*";
63
+ } else {
64
+ filetype = filetype.map(process_file_type);
65
+ accept_file_types = filetype.join(", ");
66
+ }
70
67
  export function paste_clipboard() {
71
68
  navigator.clipboard.read().then(async (items) => {
72
69
  for (let i = 0; i < items.length; i++) {
@@ -150,8 +147,7 @@ export async function load_files(files) {
150
147
  return await handle_upload(file_data);
151
148
  }
152
149
  function is_valid_file(file) {
153
- if (!filetype)
154
- return true;
150
+ if (!filetype) return true;
155
151
  const allowed_types = Array.isArray(filetype) ? filetype : [filetype];
156
152
  return allowed_types.some((type) => {
157
153
  const processed_type = process_file_type(type);
@@ -170,7 +166,7 @@ function is_valid_file(file) {
170
166
  }
171
167
  async function load_files_from_upload(files) {
172
168
  const files_to_load = files.filter((file) => {
173
- const file_extension = "." + file.name.split(".").pop();
169
+ const file_extension = "." + file.name.toLowerCase().split(".").pop();
174
170
  if (file_extension && is_valid_mimetype(accept_file_types, file_extension, file.type)) {
175
171
  return true;
176
172
  }
@@ -192,8 +188,7 @@ async function load_files_from_upload(files) {
192
188
  }
193
189
  export async function load_files_from_drop(e) {
194
190
  dragging = false;
195
- if (!e.dataTransfer?.files)
196
- return;
191
+ if (!e.dataTransfer?.files) return;
197
192
  const files_to_load = Array.from(e.dataTransfer.files).filter(
198
193
  is_valid_file
199
194
  );
@@ -3,29 +3,29 @@ import type { FileData } from "@gradio/client";
3
3
  import { type Client } from "@gradio/client";
4
4
  declare const __propDef: {
5
5
  props: {
6
- filetype?: (string | string[] | null) | undefined;
7
- dragging?: boolean | undefined;
8
- boundedheight?: boolean | undefined;
9
- center?: boolean | undefined;
10
- flex?: boolean | undefined;
11
- file_count?: ("single" | "multiple" | "directory") | undefined;
12
- disable_click?: boolean | undefined;
6
+ filetype?: string | string[] | null;
7
+ dragging?: boolean;
8
+ boundedheight?: boolean;
9
+ center?: boolean;
10
+ flex?: boolean;
11
+ file_count?: "single" | "multiple" | "directory";
12
+ disable_click?: boolean;
13
13
  root: string;
14
- hidden?: boolean | undefined;
15
- format?: ("blob" | "file") | undefined;
16
- uploading?: boolean | undefined;
17
- show_progress?: boolean | undefined;
18
- max_file_size?: (number | null) | undefined;
14
+ hidden?: boolean;
15
+ format?: "blob" | "file";
16
+ uploading?: boolean;
17
+ show_progress?: boolean;
18
+ max_file_size?: number | null;
19
19
  upload: Client["upload"];
20
20
  stream_handler: Client["stream"];
21
- icon_upload?: boolean | undefined;
21
+ icon_upload?: boolean;
22
22
  height?: number | string | undefined;
23
23
  aria_label?: string | undefined;
24
- open_upload?: (() => void) | undefined;
25
- paste_clipboard?: (() => void) | undefined;
26
- open_file_upload?: (() => void) | undefined;
27
- load_files?: ((files: File[] | Blob[]) => Promise<(FileData | null)[] | void>) | undefined;
28
- load_files_from_drop?: ((e: DragEvent) => Promise<void>) | undefined;
24
+ open_upload?: () => void;
25
+ paste_clipboard?: () => void;
26
+ open_file_upload?: () => void;
27
+ load_files?: (files: File[] | Blob[]) => Promise<(FileData | null)[] | void>;
28
+ load_files_from_drop?: (e: DragEvent) => Promise<void>;
29
29
  };
30
30
  events: {
31
31
  load: CustomEvent<any>;
@@ -36,6 +36,8 @@ declare const __propDef: {
36
36
  slots: {
37
37
  default: {};
38
38
  };
39
+ exports?: {} | undefined;
40
+ bindings?: string | undefined;
39
41
  };
40
42
  export type UploadProps = typeof __propDef.props;
41
43
  export type UploadEvents = typeof __propDef.events;
@@ -35,8 +35,7 @@ onMount(async () => {
35
35
  }
36
36
  stream.onmessage = async function(event) {
37
37
  const _data = JSON.parse(event.data);
38
- if (!progress)
39
- progress = true;
38
+ if (!progress) progress = true;
40
39
  if (_data.msg === "done") {
41
40
  stream?.close();
42
41
  dispatch("done");
@@ -47,8 +46,7 @@ onMount(async () => {
47
46
  };
48
47
  });
49
48
  onDestroy(() => {
50
- if (stream != null || stream != void 0)
51
- stream.close();
49
+ if (stream != null || stream != void 0) stream.close();
52
50
  });
53
51
  function calculateTotalProgress(files2) {
54
52
  let totalProgress = 0;
@@ -61,10 +59,8 @@ function calculateTotalProgress(files2) {
61
59
  );
62
60
  return totalProgress / files2.length;
63
61
  }
64
- $:
65
- calculateTotalProgress(files_with_progress);
66
- $:
67
- file_to_display = current_file_upload || files_with_progress[0];
62
+ $: calculateTotalProgress(files_with_progress);
63
+ $: file_to_display = current_file_upload || files_with_progress[0];
68
64
  </script>
69
65
 
70
66
  <div class="wrap" class:progress>
@@ -13,6 +13,8 @@ declare const __propDef: {
13
13
  [evt: string]: CustomEvent<any>;
14
14
  };
15
15
  slots: {};
16
+ exports?: {} | undefined;
17
+ bindings?: string | undefined;
16
18
  };
17
19
  export type UploadProgressProps = typeof __propDef.props;
18
20
  export type UploadProgressEvents = typeof __propDef.events;
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@gradio/upload",
3
- "version": "0.16.14",
3
+ "version": "0.16.16",
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.16.4",
11
- "@gradio/icons": "^0.12.0",
10
+ "@gradio/atoms": "^0.16.5",
12
11
  "@gradio/utils": "^0.10.2",
13
- "@gradio/client": "^1.17.0",
14
- "@gradio/wasm": "^0.18.1"
12
+ "@gradio/wasm": "^0.18.1",
13
+ "@gradio/client": "^1.17.1",
14
+ "@gradio/icons": "^0.13.1"
15
15
  },
16
16
  "main_changeset": true,
17
17
  "exports": {
package/src/Upload.svelte CHANGED
@@ -2,7 +2,6 @@
2
2
  import { createEventDispatcher, tick, getContext } from "svelte";
3
3
  import type { FileData } from "@gradio/client";
4
4
  import { prepare_files, type Client } from "@gradio/client";
5
- import { _ } from "svelte-i18n";
6
5
  import UploadProgress from "./UploadProgress.svelte";
7
6
  import { create_drag } from "./utils";
8
7
 
@@ -212,7 +211,7 @@
212
211
 
213
212
  async function load_files_from_upload(files: File[]): Promise<void> {
214
213
  const files_to_load = files.filter((file) => {
215
- const file_extension = "." + file.name.split(".").pop();
214
+ const file_extension = "." + file.name.toLowerCase().split(".").pop();
216
215
  if (
217
216
  file_extension &&
218
217
  is_valid_mimetype(accept_file_types, file_extension, file.type)