@gradio/gallery 0.14.0 → 0.14.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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @gradio/gallery
2
2
 
3
+ ## 0.14.1
4
+
5
+ ### Fixes
6
+
7
+ - [#10269](https://github.com/gradio-app/gradio/pull/10269) [`890eaa3`](https://github.com/gradio-app/gradio/commit/890eaa3a9e53dab5bcb16c5d017ae0470109b8fb) - Allow displaying SVG images securely in `gr.Image` and `gr.Gallery` components. Thanks @abidlabs!
8
+
9
+ ### Dependency updates
10
+
11
+ - @gradio/atoms@0.13.0
12
+ - @gradio/utils@0.10.0
13
+ - @gradio/upload@0.14.4
14
+ - @gradio/client@1.9.0
15
+ - @gradio/icons@0.9.0
16
+ - @gradio/statustracker@0.10.0
17
+ - @gradio/image@0.20.0
18
+ - @gradio/video@0.13.0
19
+ - @gradio/file@0.12.0
20
+
3
21
  ## 0.14.0
4
22
 
5
23
  ### Features
package/Index.svelte CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  <script lang="ts">
6
6
  import type { GalleryImage, GalleryVideo } from "./types";
7
+ import type { FileData } from "@gradio/client";
7
8
  import type { Gradio, ShareData, SelectData } from "@gradio/utils";
8
9
  import { Block, UploadText } from "@gradio/atoms";
9
10
  import Gallery from "./shared/Gallery.svelte";
@@ -52,6 +53,30 @@
52
53
 
53
54
  $: no_value = value === null ? true : value.length === 0;
54
55
  $: selected_index, dispatch("prop_change", { selected_index });
56
+
57
+ async function process_upload_files(
58
+ files: FileData[]
59
+ ): Promise<GalleryData[]> {
60
+ const processed_files = await Promise.all(
61
+ files.map(async (x) => {
62
+ if (x.path?.toLowerCase().endsWith(".svg") && x.url) {
63
+ const response = await fetch(x.url);
64
+ const svgContent = await response.text();
65
+ return {
66
+ ...x,
67
+ url: `data:image/svg+xml,${encodeURIComponent(svgContent)}`
68
+ };
69
+ }
70
+ return x;
71
+ })
72
+ );
73
+
74
+ return processed_files.map((x) =>
75
+ x.mime_type?.includes("video")
76
+ ? { video: x, caption: null }
77
+ : { image: x, caption: null }
78
+ );
79
+ }
55
80
  </script>
56
81
 
57
82
  <Block
@@ -83,13 +108,9 @@
83
108
  i18n={gradio.i18n}
84
109
  upload={(...args) => gradio.client.upload(...args)}
85
110
  stream_handler={(...args) => gradio.client.stream(...args)}
86
- on:upload={(e) => {
111
+ on:upload={async (e) => {
87
112
  const files = Array.isArray(e.detail) ? e.detail : [e.detail];
88
- value = files.map((x) =>
89
- x.mime_type?.includes("video")
90
- ? { video: x, caption: null }
91
- : { image: x, caption: null }
92
- );
113
+ value = await process_upload_files(files);
93
114
  gradio.dispatch("upload", value);
94
115
  }}
95
116
  on:error={({ detail }) => {
package/dist/Index.svelte CHANGED
@@ -35,6 +35,24 @@ $:
35
35
  no_value = value === null ? true : value.length === 0;
36
36
  $:
37
37
  selected_index, dispatch("prop_change", { selected_index });
38
+ async function process_upload_files(files) {
39
+ const processed_files = await Promise.all(
40
+ files.map(async (x) => {
41
+ if (x.path?.toLowerCase().endsWith(".svg") && x.url) {
42
+ const response = await fetch(x.url);
43
+ const svgContent = await response.text();
44
+ return {
45
+ ...x,
46
+ url: `data:image/svg+xml,${encodeURIComponent(svgContent)}`
47
+ };
48
+ }
49
+ return x;
50
+ })
51
+ );
52
+ return processed_files.map(
53
+ (x) => x.mime_type?.includes("video") ? { video: x, caption: null } : { image: x, caption: null }
54
+ );
55
+ }
38
56
  </script>
39
57
 
40
58
  <Block
@@ -66,13 +84,9 @@ $:
66
84
  i18n={gradio.i18n}
67
85
  upload={(...args) => gradio.client.upload(...args)}
68
86
  stream_handler={(...args) => gradio.client.stream(...args)}
69
- on:upload={(e) => {
87
+ on:upload={async (e) => {
70
88
  const files = Array.isArray(e.detail) ? e.detail : [e.detail];
71
- value = files.map((x) =>
72
- x.mime_type?.includes("video")
73
- ? { video: x, caption: null }
74
- : { image: x, caption: null }
75
- );
89
+ value = await process_upload_files(files);
76
90
  gradio.dispatch("upload", value);
77
91
  }}
78
92
  on:error={({ detail }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradio/gallery",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "author": "",
@@ -8,15 +8,15 @@
8
8
  "private": false,
9
9
  "dependencies": {
10
10
  "dequal": "^2.0.2",
11
- "@gradio/atoms": "^0.12.0",
12
- "@gradio/client": "^1.8.0",
13
- "@gradio/upload": "^0.14.3",
14
- "@gradio/image": "^0.19.0",
15
- "@gradio/icons": "^0.8.1",
16
- "@gradio/statustracker": "^0.9.7",
17
- "@gradio/utils": "^0.9.0",
18
- "@gradio/video": "^0.12.1",
19
- "@gradio/file": "^0.11.3"
11
+ "@gradio/client": "^1.9.0",
12
+ "@gradio/atoms": "^0.13.0",
13
+ "@gradio/icons": "^0.9.0",
14
+ "@gradio/image": "^0.20.0",
15
+ "@gradio/statustracker": "^0.10.0",
16
+ "@gradio/utils": "^0.10.0",
17
+ "@gradio/video": "^0.13.0",
18
+ "@gradio/upload": "^0.14.4",
19
+ "@gradio/file": "^0.12.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@gradio/preview": "^0.13.0"