@gradio/image 0.5.4 → 0.6.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,24 @@
1
1
  # @gradio/image
2
2
 
3
+ ## 0.6.1
4
+
5
+ ### Fixes
6
+
7
+ - [#6885](https://github.com/gradio-app/gradio/pull/6885) [`640b7fe`](https://github.com/gradio-app/gradio/commit/640b7fe05276e11720b4341cadf088491395e53d) - Fix issue with Webcam Recording. Thanks [@dawoodkhan82](https://github.com/dawoodkhan82)!
8
+ - [#6967](https://github.com/gradio-app/gradio/pull/6967) [`5e00162`](https://github.com/gradio-app/gradio/commit/5e0016267f1d683e2daab82ee4a33d2f09513a34) - Make <Gallery /> Wasm-compatible. Thanks [@whitphx](https://github.com/whitphx)!
9
+
10
+ ## 0.6.0
11
+
12
+ ### Features
13
+
14
+ - [#6133](https://github.com/gradio-app/gradio/pull/6133) [`f742d0e`](https://github.com/gradio-app/gradio/commit/f742d0e861c8e25c5d77d9102c9d50f94b0d3383) - Lite: Support AnnotatedImage on Wasm. Thanks [@whitphx](https://github.com/whitphx)!
15
+ - [#6931](https://github.com/gradio-app/gradio/pull/6931) [`6c863af`](https://github.com/gradio-app/gradio/commit/6c863af92fa9ceb5c638857eb22cc5ddb718d549) - Fix functional tests. Thanks [@aliabid94](https://github.com/aliabid94)!
16
+ - [#6897](https://github.com/gradio-app/gradio/pull/6897) [`fb9c6ca`](https://github.com/gradio-app/gradio/commit/fb9c6cacd7ca4598c000f1f97d7d39a8c4463519) - Lite: Chatbot. Thanks [@whitphx](https://github.com/whitphx)!
17
+
18
+ ### Fixes
19
+
20
+ - [#6942](https://github.com/gradio-app/gradio/pull/6942) [`b1b78c2`](https://github.com/gradio-app/gradio/commit/b1b78c2168e24fb65251a9b9b6cbc9382179a8ca) - Fix `.select` for `gr.Image`, `gr.CheckboxGroup`. Thanks [@abidlabs](https://github.com/abidlabs)!
21
+
3
22
  ## 0.5.4
4
23
 
5
24
  ### Fixes
package/Index.svelte CHANGED
@@ -65,7 +65,7 @@
65
65
  }>;
66
66
 
67
67
  $: url = _value?.url;
68
- $: url && gradio.dispatch("change");
68
+ $: url, gradio.dispatch("change");
69
69
 
70
70
  let dragging: boolean;
71
71
  let active_source: sources = null;
@@ -134,7 +134,6 @@
134
134
  on:edit={() => gradio.dispatch("edit")}
135
135
  on:clear={() => {
136
136
  gradio.dispatch("clear");
137
- gradio.dispatch("change");
138
137
  }}
139
138
  on:stream={() => gradio.dispatch("stream")}
140
139
  on:drag={({ detail }) => (dragging = detail)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradio/image",
3
- "version": "0.5.4",
3
+ "version": "0.6.1",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "author": "",
@@ -11,17 +11,18 @@
11
11
  "lazy-brush": "^1.0.1",
12
12
  "resize-observer-polyfill": "^1.5.1",
13
13
  "@gradio/atoms": "^0.4.1",
14
- "@gradio/client": "^0.9.4",
14
+ "@gradio/client": "^0.10.0",
15
15
  "@gradio/icons": "^0.3.2",
16
- "@gradio/statustracker": "^0.4.3",
16
+ "@gradio/upload": "^0.6.0",
17
17
  "@gradio/utils": "^0.2.0",
18
- "@gradio/upload": "^0.5.7",
19
- "@gradio/wasm": "^0.4.0"
18
+ "@gradio/statustracker": "^0.4.3",
19
+ "@gradio/wasm": "^0.5.0"
20
20
  },
21
21
  "main_changeset": true,
22
22
  "main": "./Index.svelte",
23
23
  "exports": {
24
24
  ".": "./Index.svelte",
25
+ "./shared": "./shared/index.ts",
25
26
  "./example": "./Example.svelte",
26
27
  "./package.json": "./package.json"
27
28
  }
@@ -1,6 +1,9 @@
1
1
  <script lang="ts">
2
2
  import type { HTMLImgAttributes } from "svelte/elements";
3
- type $$Props = HTMLImgAttributes;
3
+ interface Props extends HTMLImgAttributes {
4
+ "data-testid"?: string;
5
+ }
6
+ type $$Props = Props;
4
7
 
5
8
  import { resolve_wasm_src } from "@gradio/wasm/svelte";
6
9
 
@@ -15,7 +18,7 @@
15
18
  $: {
16
19
  // In normal (non-Wasm) Gradio, the `<img>` element should be rendered with the passed `src` props immediately
17
20
  // without waiting for `resolve_wasm_src()` to resolve.
18
- // If it waits, a black image is displayed until the async task finishes
21
+ // If it waits, a blank image is displayed until the async task finishes
19
22
  // and it leads to undesirable flickering.
20
23
  // So set `src` to `resolved_src` here.
21
24
  resolved_src = src;
@@ -124,6 +124,7 @@
124
124
  </Upload>
125
125
  {#if active_source === "webcam" && (streaming || (!streaming && !value))}
126
126
  <Webcam
127
+ {root}
127
128
  on:capture={(e) => handle_save(e.detail)}
128
129
  on:stream={(e) => handle_save(e.detail)}
129
130
  on:error
@@ -1,12 +1,15 @@
1
1
  <script lang="ts">
2
- import { createEventDispatcher, onMount, tick } from "svelte";
2
+ import { createEventDispatcher, onMount } from "svelte";
3
3
  import { Camera, Circle, Square, DropdownArrow } from "@gradio/icons";
4
4
  import type { I18nFormatter } from "@gradio/utils";
5
+ import type { FileData } from "@gradio/client";
6
+ import { prepare_files, upload } from "@gradio/client";
5
7
 
6
8
  let video_source: HTMLVideoElement;
7
9
  let canvas: HTMLCanvasElement;
8
10
  export let streaming = false;
9
11
  export let pending = false;
12
+ export let root = "";
10
13
 
11
14
  export let mode: "image" | "video" = "image";
12
15
  export let mirror_webcam: boolean;
@@ -15,7 +18,7 @@
15
18
 
16
19
  const dispatch = createEventDispatcher<{
17
20
  stream: undefined;
18
- capture: Blob;
21
+ capture: FileData | Blob | null;
19
22
  error: string;
20
23
  start_recording: undefined;
21
24
  stop_recording: undefined;
@@ -88,15 +91,17 @@
88
91
  media_recorder.stop();
89
92
  let video_blob = new Blob(recorded_blobs, { type: mimeType });
90
93
  let ReaderObj = new FileReader();
91
- ReaderObj.onload = function (e): void {
94
+ ReaderObj.onload = async function (e): Promise<void> {
92
95
  if (e.target) {
93
- dispatch("capture", {
94
- //@ts-ignore
95
- data: e.target.result,
96
- name: "sample." + mimeType.substring(6),
97
- is_example: false,
98
- is_file: false
99
- });
96
+ let _video_blob = new File(
97
+ [video_blob],
98
+ "sample." + mimeType.substring(6)
99
+ );
100
+ const val = await prepare_files([_video_blob]);
101
+ let value = (
102
+ (await upload(val, root))?.filter(Boolean) as FileData[]
103
+ )[0];
104
+ dispatch("capture", value);
100
105
  dispatch("stop_recording");
101
106
  }
102
107
  };
@@ -0,0 +1 @@
1
+ export { default as Image } from "./Image.svelte";
package/shared/utils.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  export const get_coordinates_of_clicked_image = (
2
2
  evt: MouseEvent
3
3
  ): [number, number] | null => {
4
- let image = evt.currentTarget as HTMLImageElement;
4
+ let image;
5
+ if (evt.currentTarget instanceof Element) {
6
+ image = evt.currentTarget.querySelector("img") as HTMLImageElement;
7
+ } else {
8
+ return [NaN, NaN];
9
+ }
5
10
 
6
11
  const imageRect = image.getBoundingClientRect();
7
12
  const xScale = image.naturalWidth / imageRect.width;