Skip to content

Commit 8c37d16

Browse files
authored
Merge branch 'main' into radio-input-select
2 parents b667fc8 + 394423d commit 8c37d16

36 files changed

+1180
-122
lines changed

.changeset/eleven-paths-flash.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@gradio/column": patch
3+
"@gradio/dataset": patch
4+
"@gradio/form": patch
5+
"@gradio/group": patch
6+
"@gradio/row": patch
7+
"@gradio/sidebar": patch
8+
"gradio": patch
9+
---
10+
11+
feat:Layout tests

.changeset/fruity-taxis-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@self/tootils": minor
3+
---
4+
5+
feat:Button Unit Tests

.changeset/full-zoos-decide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gradio": patch
3+
---
4+
5+
fix:fix(share): clearer error message when cert write failed during sharing init

.changeset/loose-horses-lead.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gradio": patch
3+
---
4+
5+
feat:reloading: Copy `server` attr for Space reloader

.changeset/nine-hairs-stare.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@self/tootils": minor
3+
---
4+
5+
feat:clear DOM after cleanup in render

.changeset/puny-shoes-attack.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@self/app": patch
3+
"@self/spa": patch
4+
"gradio": patch
5+
---
6+
7+
fix:Reduce `gradio` package size by restoring frontend settings

.changeset/soft-meals-listen.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@gradio/client": patch
3+
"@self/app": patch
4+
"@self/spa": patch
5+
"gradio": patch
6+
---
7+
8+
fix:Fix ZeroGPU handling for `gr.Server`

client/js/src/client.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
parse_and_set_cookies
3232
} from "./helpers/init_helpers";
3333
import { check_and_wake_space, check_space_status } from "./helpers/spaces";
34+
import { initialize_zerogpu_handshake } from "./helpers/zerogpu";
3435
import { open_stream, readable_stream, close_stream } from "./utils/stream";
3536
import {
3637
API_INFO_ERROR_MSG,
@@ -220,6 +221,8 @@ export class Client {
220221
}
221222

222223
private async init(): Promise<void> {
224+
initialize_zerogpu_handshake();
225+
223226
if (this.options.auth) {
224227
await this.resolve_cookies();
225228
}

client/js/src/helpers/zerogpu.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const ZEROGPU_HEADERS_MESSAGE = "supports-zerogpu-headers";
2+
3+
let zerogpu_handshake_initialized = false;
4+
5+
function supports_browser_handshake(): boolean {
6+
return (
7+
typeof window !== "undefined" &&
8+
typeof document !== "undefined" &&
9+
typeof window.addEventListener === "function"
10+
);
11+
}
12+
13+
export function get_zerogpu_origin(hostname: string): string | null {
14+
if (hostname.includes(".dev.")) {
15+
return `https://moon-${hostname.split(".")[1]}.dev.spaces.huggingface.tech`;
16+
}
17+
if (hostname.endsWith(".hf.space")) {
18+
return "https://huggingface.co";
19+
}
20+
return null;
21+
}
22+
23+
export function initialize_zerogpu_handshake(): void {
24+
if (!supports_browser_handshake() || zerogpu_handshake_initialized) {
25+
return;
26+
}
27+
28+
window.addEventListener("message", (event) => {
29+
if (event.data === ZEROGPU_HEADERS_MESSAGE) {
30+
window.supports_zerogpu_headers = true;
31+
}
32+
});
33+
34+
zerogpu_handshake_initialized = true;
35+
36+
const origin = get_zerogpu_origin(window.location.hostname);
37+
if (origin && window.parent !== window) {
38+
window.parent.postMessage(ZEROGPU_HEADERS_MESSAGE, origin);
39+
}
40+
}

client/js/src/utils/submit.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {
1212
} from "../types";
1313

1414
import { skip_queue, post_message, handle_payload } from "../helpers/data";
15+
import { get_zerogpu_origin } from "../helpers/zerogpu";
1516
import {
1617
handle_message,
1718
map_data_to_params,
@@ -412,15 +413,13 @@ export function submit(
412413
hostname = window?.location?.hostname;
413414
}
414415

415-
let hfhubdev = "dev.spaces.huggingface.tech";
416-
const origin = hostname.includes(".dev.")
417-
? `https://moon-${hostname.split(".")[1]}.${hfhubdev}`
418-
: `https://huggingface.co`;
416+
const origin = get_zerogpu_origin(hostname);
419417

420418
const is_zerogpu_iframe =
421419
typeof window !== "undefined" &&
422420
typeof document !== "undefined" &&
423421
window.parent != window &&
422+
!!origin &&
424423
window.supports_zerogpu_headers;
425424
const zerogpu_auth_promise = is_zerogpu_iframe
426425
? post_message<Map<string, string>>("zerogpu-headers", origin)

0 commit comments

Comments
 (0)