@gradio/client 0.19.3 → 0.19.4
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 +6 -0
- package/dist/helpers/data.d.ts.map +1 -1
- package/dist/index.js +7 -14
- package/dist/utils/submit.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/helpers/data.ts +6 -20
- package/src/test/data.test.ts +9 -12
- package/src/utils/submit.ts +5 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# @gradio/client
|
2
2
|
|
3
|
+
## 0.19.4
|
4
|
+
|
5
|
+
### Fixes
|
6
|
+
|
7
|
+
- [#8322](https://github.com/gradio-app/gradio/pull/8322) [`47012a0`](https://github.com/gradio-app/gradio/commit/47012a0c4e3e8a80fcae620aaf08b16ceb343cde) - ensure the client correctly handles all binary data. Thanks @Saghen!
|
8
|
+
|
3
9
|
## 0.19.3
|
4
10
|
|
5
11
|
### Features
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/helpers/data.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,OAAO,EACP,OAAO,EACP,MAAM,EACN,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,MAAM,UAAU,CAAC;AAElB,wBAAgB,aAAa,CAC5B,MAAM,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAC5B,QAAQ,EAAE,GAAG,EACb,KAAK,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GACxB,IAAI,CAgBN;AAED,wBAAsB,oBAAoB,CACzC,IAAI,EAAE,QAAQ,EACd,IAAI,GAAE,MAAM,GAAG,SAAqB,EACpC,IAAI,GAAE,MAAM,EAAO,EACnB,IAAI,UAAQ,EACZ,aAAa,GAAE,YAAY,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,SAAqB,GACtE,OAAO,CAAC,OAAO,EAAE,CAAC,
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/helpers/data.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,OAAO,EACP,OAAO,EACP,MAAM,EACN,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,MAAM,UAAU,CAAC;AAElB,wBAAgB,aAAa,CAC5B,MAAM,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAC5B,QAAQ,EAAE,GAAG,EACb,KAAK,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GACxB,IAAI,CAgBN;AAED,wBAAsB,oBAAoB,CACzC,IAAI,EAAE,QAAQ,EACd,IAAI,GAAE,MAAM,GAAG,SAAqB,EACpC,IAAI,GAAE,MAAM,EAAO,EACnB,IAAI,UAAQ,EACZ,aAAa,GAAE,YAAY,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,SAAqB,GACtE,OAAO,CAAC,OAAO,EAAE,CAAC,CAyDpB;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAK9D;AAID,wBAAgB,YAAY,CAAC,GAAG,GAAG,GAAG,EACrC,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC,GAAG,CAAC,CASd"}
|
package/dist/index.js
CHANGED
@@ -558,13 +558,13 @@ async function walk_and_store_blobs(data, type = void 0, path = [], root = false
|
|
558
558
|
if (Array.isArray(data)) {
|
559
559
|
let blob_refs = [];
|
560
560
|
await Promise.all(
|
561
|
-
data.map(async (
|
561
|
+
data.map(async (_, index) => {
|
562
562
|
var _a;
|
563
563
|
let new_path = path.slice();
|
564
|
-
new_path.push(
|
564
|
+
new_path.push(String(index));
|
565
565
|
const array_refs = await walk_and_store_blobs(
|
566
|
-
data[
|
567
|
-
root ? ((_a = endpoint_info == null ? void 0 : endpoint_info.parameters[
|
566
|
+
data[index],
|
567
|
+
root ? ((_a = endpoint_info == null ? void 0 : endpoint_info.parameters[index]) == null ? void 0 : _a.component) || void 0 : type,
|
568
568
|
new_path,
|
569
569
|
false,
|
570
570
|
endpoint_info
|
@@ -597,15 +597,6 @@ async function walk_and_store_blobs(data, type = void 0, path = [], root = false
|
|
597
597
|
)
|
598
598
|
);
|
599
599
|
}
|
600
|
-
if (!blob_refs.length && !(data instanceof Blob || data instanceof ArrayBuffer || data instanceof Uint8Array)) {
|
601
|
-
return [
|
602
|
-
{
|
603
|
-
path,
|
604
|
-
blob: new NodeBlob([JSON.stringify(data)]),
|
605
|
-
type: typeof data
|
606
|
-
}
|
607
|
-
];
|
608
|
-
}
|
609
600
|
return blob_refs;
|
610
601
|
}
|
611
602
|
return [];
|
@@ -1492,7 +1483,9 @@ function submit(endpoint, data, event_data, trigger_id) {
|
|
1492
1483
|
}
|
1493
1484
|
let hfhubdev = "dev.spaces.huggingface.tech";
|
1494
1485
|
const origin = hostname.includes(".dev.") ? `https://moon-${hostname.split(".")[1]}.${hfhubdev}` : `https://huggingface.co`;
|
1495
|
-
const
|
1486
|
+
const is_iframe = typeof window !== "undefined" && window.parent != window;
|
1487
|
+
const is_zerogpu_space = dependency.zerogpu && config.space_id;
|
1488
|
+
const zerogpu_auth_promise = is_iframe && is_zerogpu_space ? post_message("zerogpu-headers", origin) : Promise.resolve(null);
|
1496
1489
|
const post_data_promise = zerogpu_auth_promise.then((headers) => {
|
1497
1490
|
return post_data2(
|
1498
1491
|
`${config.root}/queue/join?${url_params}`,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"submit.d.ts","sourceRoot":"","sources":["../../src/utils/submit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAKX,YAAY,EAQZ,MAAM,UAAU,CAAC;AAYlB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,wBAAgB,MAAM,CACrB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,UAAU,CAAC,EAAE,OAAO,EACpB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GACxB,YAAY,
|
1
|
+
{"version":3,"file":"submit.d.ts","sourceRoot":"","sources":["../../src/utils/submit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAKX,YAAY,EAQZ,MAAM,UAAU,CAAC;AAYlB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,wBAAgB,MAAM,CACrB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,UAAU,CAAC,EAAE,OAAO,EACpB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GACxB,YAAY,CAuoBd"}
|
package/package.json
CHANGED
package/src/helpers/data.ts
CHANGED
@@ -41,13 +41,15 @@ export async function walk_and_store_blobs(
|
|
41
41
|
let blob_refs: BlobRef[] = [];
|
42
42
|
|
43
43
|
await Promise.all(
|
44
|
-
data.map(async (
|
44
|
+
data.map(async (_, index) => {
|
45
45
|
let new_path = path.slice();
|
46
|
-
new_path.push(
|
46
|
+
new_path.push(String(index));
|
47
47
|
|
48
48
|
const array_refs = await walk_and_store_blobs(
|
49
|
-
data[
|
50
|
-
root
|
49
|
+
data[index],
|
50
|
+
root
|
51
|
+
? endpoint_info?.parameters[index]?.component || undefined
|
52
|
+
: type,
|
51
53
|
new_path,
|
52
54
|
false,
|
53
55
|
endpoint_info
|
@@ -87,22 +89,6 @@ export async function walk_and_store_blobs(
|
|
87
89
|
);
|
88
90
|
}
|
89
91
|
|
90
|
-
if (
|
91
|
-
!blob_refs.length &&
|
92
|
-
!(
|
93
|
-
data instanceof Blob ||
|
94
|
-
data instanceof ArrayBuffer ||
|
95
|
-
data instanceof Uint8Array
|
96
|
-
)
|
97
|
-
) {
|
98
|
-
return [
|
99
|
-
{
|
100
|
-
path: path,
|
101
|
-
blob: new NodeBlob([JSON.stringify(data)]),
|
102
|
-
type: typeof data
|
103
|
-
}
|
104
|
-
];
|
105
|
-
}
|
106
92
|
return blob_refs;
|
107
93
|
}
|
108
94
|
|
package/src/test/data.test.ts
CHANGED
@@ -43,6 +43,15 @@ describe("walk_and_store_blobs", () => {
|
|
43
43
|
expect(parts[0].blob).toBe(false);
|
44
44
|
});
|
45
45
|
|
46
|
+
it("should handle arrays", async () => {
|
47
|
+
const image = new Blob([]);
|
48
|
+
const parts = await walk_and_store_blobs([image]);
|
49
|
+
|
50
|
+
expect(parts).toHaveLength(1);
|
51
|
+
expect(parts[0].blob).toBeInstanceOf(NodeBlob);
|
52
|
+
expect(parts[0].path).toEqual(["0"]);
|
53
|
+
});
|
54
|
+
|
46
55
|
it("should handle deep structures", async () => {
|
47
56
|
const image = new Blob([]);
|
48
57
|
const parts = await walk_and_store_blobs({ a: { b: { data: { image } } } });
|
@@ -142,18 +151,6 @@ describe("walk_and_store_blobs", () => {
|
|
142
151
|
expect(parts[0].path).toEqual(["a", "b", "data", "image"]);
|
143
152
|
expect(parts[0].blob).toBeInstanceOf(NodeBlob);
|
144
153
|
});
|
145
|
-
|
146
|
-
it("should convert an object with primitive values to BlobRefs", async () => {
|
147
|
-
const param = {
|
148
|
-
test: "test"
|
149
|
-
};
|
150
|
-
const parts = await walk_and_store_blobs(param);
|
151
|
-
|
152
|
-
expect(parts).toHaveLength(1);
|
153
|
-
expect(parts[0].path).toEqual([]);
|
154
|
-
expect(parts[0].blob).toBeInstanceOf(NodeBlob);
|
155
|
-
expect(parts[0].type).toEqual("object");
|
156
|
-
});
|
157
154
|
});
|
158
155
|
describe("update_object", () => {
|
159
156
|
it("should update the value of a nested property", () => {
|
package/src/utils/submit.ts
CHANGED
@@ -496,8 +496,12 @@ export function submit(
|
|
496
496
|
const origin = hostname.includes(".dev.")
|
497
497
|
? `https://moon-${hostname.split(".")[1]}.${hfhubdev}`
|
498
498
|
: `https://huggingface.co`;
|
499
|
+
|
500
|
+
const is_iframe =
|
501
|
+
typeof window !== "undefined" && window.parent != window;
|
502
|
+
const is_zerogpu_space = dependency.zerogpu && config.space_id;
|
499
503
|
const zerogpu_auth_promise =
|
500
|
-
|
504
|
+
is_iframe && is_zerogpu_space
|
501
505
|
? post_message<Headers>("zerogpu-headers", origin)
|
502
506
|
: Promise.resolve(null);
|
503
507
|
const post_data_promise = zerogpu_auth_promise.then((headers) => {
|