@gradio/client 2.0.3 → 2.0.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 +8 -0
- package/dist/browser.js +409 -391
- package/dist/client.d.ts.map +1 -1
- package/dist/helpers/init_helpers.d.ts.map +1 -1
- package/dist/index.js +39 -15
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +5 -0
- package/src/helpers/init_helpers.ts +50 -17
- package/src/types.ts +1 -0
package/dist/browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
async function
|
|
1
|
+
const We = "host", Te = "queue/data", Ze = "queue/join", ye = "upload", Ke = "login", K = "config", Ve = "info", Ye = "runtime", Qe = "sleeptime", Xe = "heartbeat", et = "component_server", tt = "reset", st = "cancel", nt = "app_id", Ae = "This application is currently busy. Please try again. ", M = "Connection errored out. ", D = "Could not resolve app config. ", it = "Could not get space status. ", ot = "Could not get API info. ", ue = "Space metadata could not be loaded. ", rt = "Invalid URL. A full URL path is required.", at = "Not authorized to access this space. ", xe = "Invalid credentials. Could not login. ", ct = "Login credentials are required to access this space.", ut = "File system access is only available in Node.js environments", Ce = "Root URL not found in client config", lt = "Error uploading file";
|
|
2
|
+
async function be(e, s, t) {
|
|
3
3
|
try {
|
|
4
4
|
return (await (await fetch(`https://huggingface.co/api/spaces/${e}/jwt`, {
|
|
5
5
|
headers: {
|
|
@@ -11,48 +11,66 @@ async function ye(e, s, t) {
|
|
|
11
11
|
return !1;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function pt(e) {
|
|
15
15
|
let s = {};
|
|
16
16
|
return e.forEach(({ api_name: t, id: n }) => {
|
|
17
17
|
t && (s[t] = n);
|
|
18
18
|
}), s;
|
|
19
19
|
}
|
|
20
|
-
async function
|
|
20
|
+
async function dt(e) {
|
|
21
21
|
const s = this.options.token ? { Authorization: `Bearer ${this.options.token}` } : {};
|
|
22
|
-
s["Content-Type"] = "application/json", typeof window < "u" && window
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
if (s["Content-Type"] = "application/json", typeof window < "u" && window.gradio_config && location.origin !== "http://localhost:9876") {
|
|
23
|
+
if (window.gradio_config.current_page && (e = e.substring(0, e.lastIndexOf("/"))), window.gradio_config.dev_mode || typeof window < "u" && window?.BUILD_MODE === "dev") {
|
|
24
|
+
let t = ae(
|
|
25
|
+
e,
|
|
26
|
+
this.deep_link ? K + "?deep_link=" + this.deep_link : K
|
|
27
|
+
);
|
|
28
|
+
const n = await this.fetch(t, {
|
|
29
|
+
headers: s,
|
|
30
|
+
credentials: "include"
|
|
31
|
+
}), i = await ve(n, !!this.options.auth);
|
|
32
|
+
i.root = e || i.root, window.gradio_config = {
|
|
33
|
+
...i,
|
|
34
|
+
current_page: window.gradio_config.current_page
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return { ...window.gradio_config };
|
|
38
|
+
} else if (e) {
|
|
39
|
+
let t = ae(
|
|
40
|
+
e,
|
|
41
|
+
this.deep_link ? K + "?deep_link=" + this.deep_link : K
|
|
42
|
+
);
|
|
43
|
+
const n = await this.fetch(t, {
|
|
44
|
+
headers: s,
|
|
45
|
+
credentials: "include"
|
|
46
|
+
}), i = await ve(n, !!this.options.auth);
|
|
47
|
+
return i.root || (i.root = e), i;
|
|
48
|
+
}
|
|
49
|
+
throw new Error(D);
|
|
32
50
|
}
|
|
33
|
-
async function
|
|
51
|
+
async function ve(e, s) {
|
|
34
52
|
if (e?.status === 401 && !s) {
|
|
35
53
|
const n = (await e.json())?.detail?.auth_message;
|
|
36
|
-
throw new Error(n ||
|
|
54
|
+
throw new Error(n || ct);
|
|
37
55
|
} else if (e?.status === 401 && s)
|
|
38
|
-
throw new Error(
|
|
56
|
+
throw new Error(xe);
|
|
39
57
|
if (e?.status === 200) {
|
|
40
58
|
let t = await e.json();
|
|
41
|
-
return t.dependencies?.forEach((n,
|
|
42
|
-
n.id === void 0 && (n.id =
|
|
59
|
+
return t.dependencies?.forEach((n, i) => {
|
|
60
|
+
n.id === void 0 && (n.id = i);
|
|
43
61
|
}), t;
|
|
44
62
|
} else if (e?.status === 401)
|
|
45
|
-
throw new Error(
|
|
46
|
-
throw new Error(
|
|
63
|
+
throw new Error(at);
|
|
64
|
+
throw new Error(D);
|
|
47
65
|
}
|
|
48
66
|
async function ht() {
|
|
49
|
-
const { http_protocol: e, host: s } = await
|
|
67
|
+
const { http_protocol: e, host: s } = await pe(
|
|
50
68
|
this.app_reference,
|
|
51
69
|
this.options.token
|
|
52
70
|
);
|
|
53
71
|
try {
|
|
54
72
|
if (this.options.auth) {
|
|
55
|
-
const t = await
|
|
73
|
+
const t = await De(
|
|
56
74
|
e,
|
|
57
75
|
s,
|
|
58
76
|
this.options.auth,
|
|
@@ -65,22 +83,22 @@ async function ht() {
|
|
|
65
83
|
throw Error(t.message);
|
|
66
84
|
}
|
|
67
85
|
}
|
|
68
|
-
async function
|
|
86
|
+
async function De(e, s, t, n, i) {
|
|
69
87
|
const r = new FormData();
|
|
70
88
|
r.append("username", t?.[0]), r.append("password", t?.[1]);
|
|
71
|
-
let
|
|
72
|
-
|
|
73
|
-
const a = await n(`${e}//${s}/${
|
|
74
|
-
headers:
|
|
89
|
+
let o = {};
|
|
90
|
+
i && (o.Authorization = `Bearer ${i}`);
|
|
91
|
+
const a = await n(`${e}//${s}/${Ke}`, {
|
|
92
|
+
headers: o,
|
|
75
93
|
method: "POST",
|
|
76
94
|
body: r,
|
|
77
95
|
credentials: "include"
|
|
78
96
|
});
|
|
79
97
|
if (a.status === 200)
|
|
80
98
|
return a.headers.get("set-cookie");
|
|
81
|
-
throw a.status === 401 ? new Error(
|
|
99
|
+
throw a.status === 401 ? new Error(xe) : new Error(ue);
|
|
82
100
|
}
|
|
83
|
-
function
|
|
101
|
+
function re(e) {
|
|
84
102
|
if (e.startsWith("http")) {
|
|
85
103
|
const { protocol: s, host: t, pathname: n } = new URL(e);
|
|
86
104
|
return {
|
|
@@ -95,49 +113,49 @@ function ie(e) {
|
|
|
95
113
|
host: new URL(e).host
|
|
96
114
|
};
|
|
97
115
|
}
|
|
98
|
-
const
|
|
116
|
+
const Ne = (e) => {
|
|
99
117
|
let s = [];
|
|
100
118
|
return e.split(/,(?=\s*[^\s=;]+=[^\s=;]+)/).forEach((n) => {
|
|
101
|
-
const [
|
|
102
|
-
|
|
119
|
+
const [i, r] = n.split(";")[0].split("=");
|
|
120
|
+
i && r && s.push(`${i.trim()}=${r.trim()}`);
|
|
103
121
|
}), s;
|
|
104
|
-
},
|
|
105
|
-
async function
|
|
122
|
+
}, le = /^[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_\-\.]+$/, ft = /.*hf\.space\/{0,1}.*$/;
|
|
123
|
+
async function pe(e, s) {
|
|
106
124
|
const t = {};
|
|
107
125
|
s && (t.Authorization = `Bearer ${s}`);
|
|
108
126
|
const n = e.trim().replace(/\/$/, "");
|
|
109
|
-
if (
|
|
127
|
+
if (le.test(n))
|
|
110
128
|
try {
|
|
111
129
|
const r = (await (await fetch(
|
|
112
|
-
`https://huggingface.co/api/spaces/${n}/${
|
|
130
|
+
`https://huggingface.co/api/spaces/${n}/${We}`,
|
|
113
131
|
{ headers: t }
|
|
114
132
|
)).json()).host;
|
|
115
133
|
return {
|
|
116
134
|
space_id: e,
|
|
117
|
-
...
|
|
135
|
+
...re(r)
|
|
118
136
|
};
|
|
119
137
|
} catch {
|
|
120
|
-
throw new Error(
|
|
138
|
+
throw new Error(ue);
|
|
121
139
|
}
|
|
122
140
|
if (ft.test(n)) {
|
|
123
|
-
const { ws_protocol:
|
|
141
|
+
const { ws_protocol: i, http_protocol: r, host: o } = re(n);
|
|
124
142
|
return {
|
|
125
|
-
space_id:
|
|
126
|
-
ws_protocol:
|
|
143
|
+
space_id: o.split("/")[0].replace(".hf.space", ""),
|
|
144
|
+
ws_protocol: i,
|
|
127
145
|
http_protocol: r,
|
|
128
|
-
host:
|
|
146
|
+
host: o
|
|
129
147
|
};
|
|
130
148
|
}
|
|
131
149
|
return {
|
|
132
150
|
space_id: !1,
|
|
133
|
-
...
|
|
151
|
+
...re(n)
|
|
134
152
|
};
|
|
135
153
|
}
|
|
136
|
-
const
|
|
154
|
+
const ae = (...e) => {
|
|
137
155
|
try {
|
|
138
156
|
return e.reduce((s, t) => (s = s.replace(/\/+$/, ""), t = t.replace(/^\/+/, ""), new URL(t, s + "/").toString()));
|
|
139
157
|
} catch {
|
|
140
|
-
throw new Error(
|
|
158
|
+
throw new Error(rt);
|
|
141
159
|
}
|
|
142
160
|
};
|
|
143
161
|
function _t(e, s, t) {
|
|
@@ -145,20 +163,20 @@ function _t(e, s, t) {
|
|
|
145
163
|
named_endpoints: {},
|
|
146
164
|
unnamed_endpoints: {}
|
|
147
165
|
};
|
|
148
|
-
return Object.keys(e).forEach((
|
|
149
|
-
(
|
|
150
|
-
([r, { parameters:
|
|
166
|
+
return Object.keys(e).forEach((i) => {
|
|
167
|
+
(i === "named_endpoints" || i === "unnamed_endpoints") && (n[i] = {}, Object.entries(e[i]).forEach(
|
|
168
|
+
([r, { parameters: o, returns: a }]) => {
|
|
151
169
|
const u = s.dependencies.find(
|
|
152
170
|
(c) => c.api_name === r || c.api_name === r.replace("/", "")
|
|
153
171
|
)?.id || t[r.replace("/", "")] || -1, l = u !== -1 ? s.dependencies.find((c) => c.id == u)?.types : { generator: !1, cancel: !1 };
|
|
154
|
-
if (u !== -1 && s.dependencies.find((c) => c.id == u)?.inputs?.length !==
|
|
172
|
+
if (u !== -1 && s.dependencies.find((c) => c.id == u)?.inputs?.length !== o.length) {
|
|
155
173
|
const c = s.dependencies.find((m) => m.id == u).inputs.map(
|
|
156
174
|
(m) => s.components.find((w) => w.id === m)?.type
|
|
157
175
|
);
|
|
158
176
|
try {
|
|
159
177
|
c.forEach((m, w) => {
|
|
160
178
|
if (m === "state") {
|
|
161
|
-
const
|
|
179
|
+
const N = {
|
|
162
180
|
component: "state",
|
|
163
181
|
example: null,
|
|
164
182
|
parameter_default: null,
|
|
@@ -166,20 +184,20 @@ function _t(e, s, t) {
|
|
|
166
184
|
parameter_name: null,
|
|
167
185
|
hidden: !0
|
|
168
186
|
};
|
|
169
|
-
|
|
187
|
+
o.splice(w, 0, N);
|
|
170
188
|
}
|
|
171
189
|
});
|
|
172
190
|
} catch (m) {
|
|
173
191
|
console.error(m);
|
|
174
192
|
}
|
|
175
193
|
}
|
|
176
|
-
const p = (c, m, w,
|
|
194
|
+
const p = (c, m, w, N) => ({
|
|
177
195
|
...c,
|
|
178
196
|
description: gt(c?.type, w),
|
|
179
|
-
type: mt(c?.type, m, w,
|
|
197
|
+
type: mt(c?.type, m, w, N) || ""
|
|
180
198
|
});
|
|
181
|
-
n[
|
|
182
|
-
parameters:
|
|
199
|
+
n[i][r] = {
|
|
200
|
+
parameters: o.map(
|
|
183
201
|
(c) => p(c, c?.component, c?.serializer, "parameter")
|
|
184
202
|
),
|
|
185
203
|
returns: a.map(
|
|
@@ -215,7 +233,7 @@ function mt(e, s, t, n) {
|
|
|
215
233
|
function gt(e, s) {
|
|
216
234
|
return s === "GallerySerializable" ? "array of [file, label] tuples" : s === "ListStringSerializable" ? "array of strings" : s === "FileSerializable" ? "array of files or single file" : e?.description;
|
|
217
235
|
}
|
|
218
|
-
function
|
|
236
|
+
function Ee(e, s) {
|
|
219
237
|
switch (e.msg) {
|
|
220
238
|
case "send_data":
|
|
221
239
|
return { type: "data" };
|
|
@@ -226,7 +244,7 @@ function be(e, s) {
|
|
|
226
244
|
type: "update",
|
|
227
245
|
status: {
|
|
228
246
|
queue: !0,
|
|
229
|
-
message:
|
|
247
|
+
message: Ae,
|
|
230
248
|
stage: "error",
|
|
231
249
|
code: e.code,
|
|
232
250
|
success: e.success
|
|
@@ -357,25 +375,25 @@ const wt = (e = [], s) => {
|
|
|
357
375
|
const t = s ? s.parameters : [];
|
|
358
376
|
if (Array.isArray(e))
|
|
359
377
|
return s && t.length > 0 && e.length > t.length && console.warn("Too many arguments provided for the endpoint."), e;
|
|
360
|
-
const n = [],
|
|
361
|
-
return t.forEach((r,
|
|
378
|
+
const n = [], i = Object.keys(e);
|
|
379
|
+
return t.forEach((r, o) => {
|
|
362
380
|
if (e.hasOwnProperty(r.parameter_name))
|
|
363
|
-
n[
|
|
381
|
+
n[o] = e[r.parameter_name];
|
|
364
382
|
else if (r.parameter_has_default)
|
|
365
|
-
n[
|
|
383
|
+
n[o] = r.parameter_default;
|
|
366
384
|
else
|
|
367
385
|
throw new Error(
|
|
368
386
|
`No value provided for required parameter: ${r.parameter_name}`
|
|
369
387
|
);
|
|
370
|
-
}),
|
|
371
|
-
if (!t.some((
|
|
388
|
+
}), i.forEach((r) => {
|
|
389
|
+
if (!t.some((o) => o.parameter_name === r))
|
|
372
390
|
throw new Error(
|
|
373
391
|
`Parameter \`${r}\` is not a valid keyword argument. Please refer to the API for usage.`
|
|
374
392
|
);
|
|
375
|
-
}), n.forEach((r,
|
|
376
|
-
if (r === void 0 && !t[
|
|
393
|
+
}), n.forEach((r, o) => {
|
|
394
|
+
if (r === void 0 && !t[o].parameter_has_default)
|
|
377
395
|
throw new Error(
|
|
378
|
-
`No value provided for required parameter: ${t[
|
|
396
|
+
`No value provided for required parameter: ${t[o].parameter_name}`
|
|
379
397
|
);
|
|
380
398
|
}), n;
|
|
381
399
|
};
|
|
@@ -384,19 +402,19 @@ async function yt() {
|
|
|
384
402
|
const { token: e } = this.options, { config: s } = this, t = { "Content-Type": "application/json" };
|
|
385
403
|
if (e && (t.Authorization = `Bearer ${e}`), !!s)
|
|
386
404
|
try {
|
|
387
|
-
let n,
|
|
405
|
+
let n, i;
|
|
388
406
|
if (typeof window < "u" && window.gradio_api_info)
|
|
389
|
-
|
|
407
|
+
i = window.gradio_api_info;
|
|
390
408
|
else {
|
|
391
|
-
const r =
|
|
409
|
+
const r = ae(s.root, this.api_prefix, Ve);
|
|
392
410
|
if (n = await this.fetch(r, {
|
|
393
411
|
headers: t,
|
|
394
412
|
credentials: "include"
|
|
395
413
|
}), !n.ok)
|
|
396
414
|
throw new Error(M);
|
|
397
|
-
|
|
415
|
+
i = await n.json();
|
|
398
416
|
}
|
|
399
|
-
return "api" in
|
|
417
|
+
return "api" in i && (i = i.api), i.named_endpoints["/predict"] && !i.unnamed_endpoints[0] && (i.unnamed_endpoints[0] = i.named_endpoints["/predict"]), _t(i, s, this.api_map);
|
|
400
418
|
} catch (n) {
|
|
401
419
|
throw new Error("Could not get API info. " + n.message);
|
|
402
420
|
}
|
|
@@ -404,16 +422,16 @@ async function yt() {
|
|
|
404
422
|
async function bt(e, s, t) {
|
|
405
423
|
const n = {};
|
|
406
424
|
this?.options?.token && (n.Authorization = `Bearer ${this.options.token}`);
|
|
407
|
-
const
|
|
408
|
-
let
|
|
409
|
-
for (let a = 0; a < s.length; a +=
|
|
410
|
-
const u = s.slice(a, a +
|
|
425
|
+
const i = 1e3, r = [];
|
|
426
|
+
let o;
|
|
427
|
+
for (let a = 0; a < s.length; a += i) {
|
|
428
|
+
const u = s.slice(a, a + i), l = new FormData();
|
|
411
429
|
u.forEach((c) => {
|
|
412
430
|
l.append("files", c);
|
|
413
431
|
});
|
|
414
432
|
try {
|
|
415
|
-
const c = t ? `${e}${this.api_prefix}/${
|
|
416
|
-
|
|
433
|
+
const c = t ? `${e}${this.api_prefix}/${ye}?upload_id=${t}` : `${e}${this.api_prefix}/${ye}`;
|
|
434
|
+
o = await this.fetch(c, {
|
|
417
435
|
method: "POST",
|
|
418
436
|
body: l,
|
|
419
437
|
headers: n,
|
|
@@ -422,11 +440,11 @@ async function bt(e, s, t) {
|
|
|
422
440
|
} catch (c) {
|
|
423
441
|
throw new Error(M + c.message);
|
|
424
442
|
}
|
|
425
|
-
if (!
|
|
426
|
-
const c = await
|
|
427
|
-
return { error: `HTTP ${
|
|
443
|
+
if (!o.ok) {
|
|
444
|
+
const c = await o.text();
|
|
445
|
+
return { error: `HTTP ${o.status}: ${c}` };
|
|
428
446
|
}
|
|
429
|
-
const p = await
|
|
447
|
+
const p = await o.json();
|
|
430
448
|
p && r.push(...p);
|
|
431
449
|
}
|
|
432
450
|
return { files: r };
|
|
@@ -440,36 +458,36 @@ const vt = {
|
|
|
440
458
|
}, St = {
|
|
441
459
|
radix: 1024,
|
|
442
460
|
unit: ["b", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"]
|
|
443
|
-
},
|
|
461
|
+
}, Se = {
|
|
444
462
|
si: vt,
|
|
445
463
|
iec: Et,
|
|
446
464
|
jedec: St
|
|
447
465
|
};
|
|
448
466
|
function $t(e, s = 1, t = "jedec") {
|
|
449
467
|
e = Math.abs(e);
|
|
450
|
-
const { radix: n, unit:
|
|
468
|
+
const { radix: n, unit: i } = Se[t] || Se.jedec;
|
|
451
469
|
let r = 0;
|
|
452
470
|
for (; e >= n; )
|
|
453
471
|
e /= n, ++r;
|
|
454
|
-
return `${e.toFixed(s)} ${
|
|
472
|
+
return `${e.toFixed(s)} ${i[r]}`;
|
|
455
473
|
}
|
|
456
474
|
async function kt(e, s, t, n) {
|
|
457
|
-
let
|
|
458
|
-
(
|
|
475
|
+
let i = (Array.isArray(e) ? e : [e]).map(
|
|
476
|
+
(o) => o.blob
|
|
459
477
|
);
|
|
460
|
-
const r =
|
|
461
|
-
(
|
|
478
|
+
const r = i.filter(
|
|
479
|
+
(o) => o.size > (n ?? 1 / 0)
|
|
462
480
|
);
|
|
463
481
|
if (r.length)
|
|
464
482
|
throw new Error(
|
|
465
|
-
`File(s) exceed the maximum allowed size of ${$t(n || 1 / 0)}: ${r.map((
|
|
483
|
+
`File(s) exceed the maximum allowed size of ${$t(n || 1 / 0)}: ${r.map((o) => `"${o.name}"`).join(", ")}`
|
|
466
484
|
);
|
|
467
485
|
return await Promise.all(
|
|
468
|
-
await this.upload_files(s,
|
|
469
|
-
async (
|
|
470
|
-
if (
|
|
471
|
-
throw new Error(
|
|
472
|
-
return
|
|
486
|
+
await this.upload_files(s, i, t).then(
|
|
487
|
+
async (o) => {
|
|
488
|
+
if (o.error)
|
|
489
|
+
throw new Error(o.error);
|
|
490
|
+
return o.files ? o.files.map((a, u) => new Q({
|
|
473
491
|
...e[u],
|
|
474
492
|
path: a,
|
|
475
493
|
url: `${s}${this.api_prefix}/file=${a}`
|
|
@@ -480,7 +498,7 @@ async function kt(e, s, t, n) {
|
|
|
480
498
|
}
|
|
481
499
|
async function Xt(e, s) {
|
|
482
500
|
return e.map(
|
|
483
|
-
(t) => new
|
|
501
|
+
(t) => new Q({
|
|
484
502
|
path: t.name,
|
|
485
503
|
orig_name: t.name,
|
|
486
504
|
blob: t,
|
|
@@ -490,7 +508,7 @@ async function Xt(e, s) {
|
|
|
490
508
|
})
|
|
491
509
|
);
|
|
492
510
|
}
|
|
493
|
-
class
|
|
511
|
+
class Q {
|
|
494
512
|
path;
|
|
495
513
|
url;
|
|
496
514
|
orig_name;
|
|
@@ -505,17 +523,17 @@ class Y {
|
|
|
505
523
|
path: s,
|
|
506
524
|
url: t,
|
|
507
525
|
orig_name: n,
|
|
508
|
-
size:
|
|
526
|
+
size: i,
|
|
509
527
|
blob: r,
|
|
510
|
-
is_stream:
|
|
528
|
+
is_stream: o,
|
|
511
529
|
mime_type: a,
|
|
512
530
|
alt_text: u,
|
|
513
531
|
b64: l
|
|
514
532
|
}) {
|
|
515
|
-
this.path = s, this.url = t, this.orig_name = n, this.size =
|
|
533
|
+
this.path = s, this.url = t, this.orig_name = n, this.size = i, this.blob = t ? void 0 : r, this.is_stream = o, this.mime_type = a, this.alt_text = u, this.b64 = l;
|
|
516
534
|
}
|
|
517
535
|
}
|
|
518
|
-
class
|
|
536
|
+
class Le {
|
|
519
537
|
type;
|
|
520
538
|
command;
|
|
521
539
|
meta;
|
|
@@ -525,11 +543,11 @@ class Ne {
|
|
|
525
543
|
}
|
|
526
544
|
}
|
|
527
545
|
const Rt = typeof process < "u" && process.versions && process.versions.node;
|
|
528
|
-
function
|
|
546
|
+
function $e(e, s, t) {
|
|
529
547
|
for (; t.length > 1; ) {
|
|
530
|
-
const
|
|
531
|
-
if (typeof
|
|
532
|
-
e = e[
|
|
548
|
+
const i = t.shift();
|
|
549
|
+
if (typeof i == "string" || typeof i == "number")
|
|
550
|
+
e = e[i];
|
|
533
551
|
else
|
|
534
552
|
throw new Error("Invalid key type");
|
|
535
553
|
}
|
|
@@ -539,19 +557,19 @@ function Ee(e, s, t) {
|
|
|
539
557
|
else
|
|
540
558
|
throw new Error("Invalid key type");
|
|
541
559
|
}
|
|
542
|
-
async function
|
|
560
|
+
async function ce(e, s = void 0, t = [], n = !1, i = void 0) {
|
|
543
561
|
if (Array.isArray(e)) {
|
|
544
562
|
let r = [];
|
|
545
563
|
return await Promise.all(
|
|
546
|
-
e.map(async (
|
|
564
|
+
e.map(async (o, a) => {
|
|
547
565
|
let u = t.slice();
|
|
548
566
|
u.push(String(a));
|
|
549
|
-
const l = await
|
|
567
|
+
const l = await ce(
|
|
550
568
|
e[a],
|
|
551
|
-
n ?
|
|
569
|
+
n ? i?.parameters[a]?.component || void 0 : s,
|
|
552
570
|
u,
|
|
553
571
|
!1,
|
|
554
|
-
|
|
572
|
+
i
|
|
555
573
|
);
|
|
556
574
|
r = r.concat(l);
|
|
557
575
|
})
|
|
@@ -567,15 +585,15 @@ async function re(e, s = void 0, t = [], n = !1, o = void 0) {
|
|
|
567
585
|
];
|
|
568
586
|
if (typeof e == "object" && e !== null) {
|
|
569
587
|
let r = [];
|
|
570
|
-
for (const
|
|
571
|
-
const a = [...t,
|
|
588
|
+
for (const o of Object.keys(e)) {
|
|
589
|
+
const a = [...t, o], u = e[o];
|
|
572
590
|
r = r.concat(
|
|
573
|
-
await
|
|
591
|
+
await ce(
|
|
574
592
|
u,
|
|
575
593
|
void 0,
|
|
576
594
|
a,
|
|
577
595
|
!1,
|
|
578
|
-
|
|
596
|
+
i
|
|
579
597
|
)
|
|
580
598
|
);
|
|
581
599
|
}
|
|
@@ -590,10 +608,10 @@ function Ot(e, s) {
|
|
|
590
608
|
}
|
|
591
609
|
function Tt(e, s) {
|
|
592
610
|
return new Promise((t, n) => {
|
|
593
|
-
const
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
}), window.parent.postMessage(e, s, [
|
|
611
|
+
const i = new MessageChannel();
|
|
612
|
+
i.port1.onmessage = (({ data: r }) => {
|
|
613
|
+
i.port1.close(), t(r);
|
|
614
|
+
}), window.parent.postMessage(e, s, [i.port2]);
|
|
597
615
|
});
|
|
598
616
|
}
|
|
599
617
|
function es(e) {
|
|
@@ -606,7 +624,7 @@ function es(e) {
|
|
|
606
624
|
meta: { _type: "gradio.FileData" }
|
|
607
625
|
};
|
|
608
626
|
if (Rt)
|
|
609
|
-
return new
|
|
627
|
+
return new Le("upload_file", {
|
|
610
628
|
path: e,
|
|
611
629
|
name: e,
|
|
612
630
|
orig_path: e
|
|
@@ -623,30 +641,30 @@ function es(e) {
|
|
|
623
641
|
"Invalid input: must be a URL, File, Blob, or Buffer object."
|
|
624
642
|
);
|
|
625
643
|
}
|
|
626
|
-
function
|
|
627
|
-
if (n === "input" && !
|
|
644
|
+
function V(e, s, t, n, i = !1) {
|
|
645
|
+
if (n === "input" && !i)
|
|
628
646
|
throw new Error("Invalid code path. Cannot skip state inputs for input.");
|
|
629
|
-
if (n === "output" &&
|
|
647
|
+
if (n === "output" && i)
|
|
630
648
|
return e;
|
|
631
|
-
let r = [],
|
|
649
|
+
let r = [], o = 0;
|
|
632
650
|
const a = n === "input" ? s.inputs : s.outputs;
|
|
633
651
|
for (let u = 0; u < a.length; u++) {
|
|
634
652
|
const l = a[u];
|
|
635
653
|
if (t.find((c) => c.id === l)?.type === "state") {
|
|
636
|
-
if (
|
|
654
|
+
if (i)
|
|
637
655
|
if (e.length === a.length) {
|
|
638
|
-
const c = e[
|
|
639
|
-
r.push(c),
|
|
656
|
+
const c = e[o];
|
|
657
|
+
r.push(c), o++;
|
|
640
658
|
} else
|
|
641
659
|
r.push(null);
|
|
642
660
|
else {
|
|
643
|
-
|
|
661
|
+
o++;
|
|
644
662
|
continue;
|
|
645
663
|
}
|
|
646
664
|
continue;
|
|
647
665
|
} else {
|
|
648
|
-
const c = e[
|
|
649
|
-
r.push(c),
|
|
666
|
+
const c = e[o];
|
|
667
|
+
r.push(c), o++;
|
|
650
668
|
}
|
|
651
669
|
}
|
|
652
670
|
return r;
|
|
@@ -654,7 +672,7 @@ function K(e, s, t, n, o = !1) {
|
|
|
654
672
|
async function At(e, s, t) {
|
|
655
673
|
const n = this;
|
|
656
674
|
await xt(n, s);
|
|
657
|
-
const
|
|
675
|
+
const i = await ce(
|
|
658
676
|
s,
|
|
659
677
|
void 0,
|
|
660
678
|
[],
|
|
@@ -662,65 +680,65 @@ async function At(e, s, t) {
|
|
|
662
680
|
t
|
|
663
681
|
);
|
|
664
682
|
return (await Promise.all(
|
|
665
|
-
|
|
666
|
-
if (!a) return { path:
|
|
683
|
+
i.map(async ({ path: o, blob: a, type: u }) => {
|
|
684
|
+
if (!a) return { path: o, type: u };
|
|
667
685
|
const l = await n.upload_files(e, [a]), p = l.files && l.files[0];
|
|
668
686
|
return {
|
|
669
|
-
path:
|
|
687
|
+
path: o,
|
|
670
688
|
file_url: p,
|
|
671
689
|
type: u,
|
|
672
690
|
name: typeof File < "u" && a instanceof File ? a?.name : void 0
|
|
673
691
|
};
|
|
674
692
|
})
|
|
675
|
-
)).forEach(({ path:
|
|
693
|
+
)).forEach(({ path: o, file_url: a, type: u, name: l }) => {
|
|
676
694
|
if (u === "Gallery")
|
|
677
|
-
|
|
695
|
+
$e(s, a, o);
|
|
678
696
|
else if (a) {
|
|
679
|
-
const p = new
|
|
680
|
-
|
|
697
|
+
const p = new Q({ path: a, orig_name: l });
|
|
698
|
+
$e(s, p, o);
|
|
681
699
|
}
|
|
682
700
|
}), s;
|
|
683
701
|
}
|
|
684
702
|
async function xt(e, s) {
|
|
685
703
|
if (!(e.config?.root || e.config?.root_url))
|
|
686
|
-
throw new Error(
|
|
687
|
-
await
|
|
704
|
+
throw new Error(Ce);
|
|
705
|
+
await Pe(e, s);
|
|
688
706
|
}
|
|
689
|
-
async function
|
|
707
|
+
async function Pe(e, s, t = []) {
|
|
690
708
|
for (const n in s)
|
|
691
|
-
s[n] instanceof
|
|
709
|
+
s[n] instanceof Le ? await Ct(e, s, n) : typeof s[n] == "object" && s[n] !== null && await Pe(e, s[n], [...t, n]);
|
|
692
710
|
}
|
|
693
711
|
async function Ct(e, s, t) {
|
|
694
712
|
let n = s[t];
|
|
695
|
-
const
|
|
696
|
-
if (!
|
|
697
|
-
throw new Error(
|
|
713
|
+
const i = e.config?.root || e.config?.root_url;
|
|
714
|
+
if (!i)
|
|
715
|
+
throw new Error(Ce);
|
|
698
716
|
try {
|
|
699
|
-
let r,
|
|
717
|
+
let r, o;
|
|
700
718
|
if (typeof process < "u" && process.versions && process.versions.node) {
|
|
701
719
|
const p = await import("./__vite-browser-external-DYxpcVy9.js");
|
|
702
|
-
|
|
720
|
+
o = (await import("./__vite-browser-external-DYxpcVy9.js")).resolve(process.cwd(), n.meta.path), r = await p.readFile(o);
|
|
703
721
|
} else
|
|
704
|
-
throw new Error(
|
|
722
|
+
throw new Error(ut);
|
|
705
723
|
const a = new Blob([r], {
|
|
706
724
|
type: "application/octet-stream"
|
|
707
|
-
}), u = await e.upload_files(
|
|
725
|
+
}), u = await e.upload_files(i, [a]), l = u.files && u.files[0];
|
|
708
726
|
if (l) {
|
|
709
|
-
const p = new
|
|
727
|
+
const p = new Q({
|
|
710
728
|
path: l,
|
|
711
729
|
orig_name: n.meta.name || ""
|
|
712
730
|
});
|
|
713
731
|
s[t] = p;
|
|
714
732
|
}
|
|
715
733
|
} catch (r) {
|
|
716
|
-
console.error(
|
|
734
|
+
console.error(lt, r);
|
|
717
735
|
}
|
|
718
736
|
}
|
|
719
737
|
async function Dt(e, s, t) {
|
|
720
738
|
const n = { "Content-Type": "application/json" };
|
|
721
739
|
this.options.token && (n.Authorization = `Bearer ${this.options.token}`);
|
|
722
740
|
try {
|
|
723
|
-
var
|
|
741
|
+
var i = await this.fetch(e, {
|
|
724
742
|
method: "POST",
|
|
725
743
|
body: JSON.stringify(s),
|
|
726
744
|
headers: { ...n, ...t },
|
|
@@ -729,61 +747,61 @@ async function Dt(e, s, t) {
|
|
|
729
747
|
} catch {
|
|
730
748
|
return [{ error: M }, 500];
|
|
731
749
|
}
|
|
732
|
-
let r,
|
|
750
|
+
let r, o;
|
|
733
751
|
try {
|
|
734
|
-
r = await
|
|
752
|
+
r = await i.json(), o = i.status;
|
|
735
753
|
} catch (a) {
|
|
736
|
-
r = { error: `Could not parse server response: ${a}` },
|
|
754
|
+
r = { error: `Could not parse server response: ${a}` }, o = 500;
|
|
737
755
|
}
|
|
738
|
-
return [r,
|
|
756
|
+
return [r, o];
|
|
739
757
|
}
|
|
740
758
|
async function Nt(e, s = {}) {
|
|
741
759
|
let t = !1, n = !1;
|
|
742
760
|
if (!this.config)
|
|
743
761
|
throw new Error("Could not resolve app config");
|
|
744
762
|
if (typeof e == "number")
|
|
745
|
-
this.config.dependencies.find((
|
|
763
|
+
this.config.dependencies.find((i) => i.id == e);
|
|
746
764
|
else {
|
|
747
|
-
const
|
|
765
|
+
const i = e.replace(/^\//, "");
|
|
748
766
|
this.config.dependencies.find(
|
|
749
|
-
(r) => r.id == this.api_map[
|
|
767
|
+
(r) => r.id == this.api_map[i]
|
|
750
768
|
);
|
|
751
769
|
}
|
|
752
|
-
return new Promise(async (
|
|
753
|
-
const
|
|
770
|
+
return new Promise(async (i, r) => {
|
|
771
|
+
const o = this.submit(e, s, null, null, !0);
|
|
754
772
|
let a;
|
|
755
|
-
for await (const u of
|
|
756
|
-
u.type === "data" && (n &&
|
|
773
|
+
for await (const u of o)
|
|
774
|
+
u.type === "data" && (n && i(a), t = !0, a = u), u.type === "status" && (u.stage === "error" && r(u), u.stage === "complete" && (n = !0, t && i(a)));
|
|
757
775
|
});
|
|
758
776
|
}
|
|
759
777
|
async function G(e, s, t) {
|
|
760
|
-
let n = s === "subdomain" ? `https://huggingface.co/api/spaces/by-subdomain/${e}` : `https://huggingface.co/api/spaces/${e}`,
|
|
778
|
+
let n = s === "subdomain" ? `https://huggingface.co/api/spaces/by-subdomain/${e}` : `https://huggingface.co/api/spaces/${e}`, i, r;
|
|
761
779
|
try {
|
|
762
|
-
if (
|
|
780
|
+
if (i = await fetch(n), r = i.status, r !== 200)
|
|
763
781
|
throw new Error();
|
|
764
|
-
|
|
782
|
+
i = await i.json();
|
|
765
783
|
} catch {
|
|
766
784
|
t({
|
|
767
785
|
status: "error",
|
|
768
786
|
load_status: "error",
|
|
769
|
-
message:
|
|
787
|
+
message: it,
|
|
770
788
|
detail: "NOT_FOUND"
|
|
771
789
|
});
|
|
772
790
|
return;
|
|
773
791
|
}
|
|
774
|
-
if (!
|
|
792
|
+
if (!i || r !== 200) return;
|
|
775
793
|
const {
|
|
776
|
-
runtime: { stage:
|
|
794
|
+
runtime: { stage: o },
|
|
777
795
|
id: a
|
|
778
|
-
} =
|
|
779
|
-
switch (
|
|
796
|
+
} = i;
|
|
797
|
+
switch (o) {
|
|
780
798
|
case "STOPPED":
|
|
781
799
|
case "SLEEPING":
|
|
782
800
|
t({
|
|
783
801
|
status: "sleeping",
|
|
784
802
|
load_status: "pending",
|
|
785
803
|
message: "Space is asleep. Waking it up...",
|
|
786
|
-
detail:
|
|
804
|
+
detail: o
|
|
787
805
|
}), setTimeout(() => {
|
|
788
806
|
G(e, s, t);
|
|
789
807
|
}, 1e3);
|
|
@@ -793,8 +811,8 @@ async function G(e, s, t) {
|
|
|
793
811
|
status: "paused",
|
|
794
812
|
load_status: "error",
|
|
795
813
|
message: "This space has been paused by the author. If you would like to try this demo, consider duplicating the space.",
|
|
796
|
-
detail:
|
|
797
|
-
discussions_enabled: await
|
|
814
|
+
detail: o,
|
|
815
|
+
discussions_enabled: await ke(a)
|
|
798
816
|
});
|
|
799
817
|
break;
|
|
800
818
|
case "RUNNING":
|
|
@@ -803,7 +821,7 @@ async function G(e, s, t) {
|
|
|
803
821
|
status: "running",
|
|
804
822
|
load_status: "complete",
|
|
805
823
|
message: "Space is running.",
|
|
806
|
-
detail:
|
|
824
|
+
detail: o
|
|
807
825
|
});
|
|
808
826
|
break;
|
|
809
827
|
case "BUILDING":
|
|
@@ -811,7 +829,7 @@ async function G(e, s, t) {
|
|
|
811
829
|
status: "building",
|
|
812
830
|
load_status: "pending",
|
|
813
831
|
message: "Space is building...",
|
|
814
|
-
detail:
|
|
832
|
+
detail: o
|
|
815
833
|
}), setTimeout(() => {
|
|
816
834
|
G(e, s, t);
|
|
817
835
|
}, 1e3);
|
|
@@ -821,7 +839,7 @@ async function G(e, s, t) {
|
|
|
821
839
|
status: "starting",
|
|
822
840
|
load_status: "pending",
|
|
823
841
|
message: "Space is starting...",
|
|
824
|
-
detail:
|
|
842
|
+
detail: o
|
|
825
843
|
}), setTimeout(() => {
|
|
826
844
|
G(e, s, t);
|
|
827
845
|
}, 1e3);
|
|
@@ -831,28 +849,28 @@ async function G(e, s, t) {
|
|
|
831
849
|
status: "space_error",
|
|
832
850
|
load_status: "error",
|
|
833
851
|
message: "This space is experiencing an issue.",
|
|
834
|
-
detail:
|
|
835
|
-
discussions_enabled: await
|
|
852
|
+
detail: o,
|
|
853
|
+
discussions_enabled: await ke(a)
|
|
836
854
|
});
|
|
837
855
|
break;
|
|
838
856
|
}
|
|
839
857
|
}
|
|
840
|
-
const
|
|
858
|
+
const Ie = async (e, s) => {
|
|
841
859
|
let t = 0;
|
|
842
|
-
const n = 12,
|
|
860
|
+
const n = 12, i = 5e3;
|
|
843
861
|
return new Promise((r) => {
|
|
844
862
|
G(
|
|
845
863
|
e,
|
|
846
|
-
|
|
847
|
-
(
|
|
848
|
-
s(
|
|
849
|
-
|
|
850
|
-
},
|
|
864
|
+
le.test(e) ? "space_name" : "subdomain",
|
|
865
|
+
(o) => {
|
|
866
|
+
s(o), o.status === "running" || o.status === "error" || o.status === "paused" || o.status === "space_error" ? r() : (o.status === "sleeping" || o.status === "building") && (t < n ? (t++, setTimeout(() => {
|
|
867
|
+
Ie(e, s).then(r);
|
|
868
|
+
}, i)) : r());
|
|
851
869
|
}
|
|
852
870
|
);
|
|
853
871
|
});
|
|
854
872
|
}, Lt = /^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;
|
|
855
|
-
async function
|
|
873
|
+
async function ke(e) {
|
|
856
874
|
try {
|
|
857
875
|
const s = await fetch(
|
|
858
876
|
`https://huggingface.co/api/spaces/${e}/discussions`,
|
|
@@ -870,13 +888,13 @@ async function Pt(e, s) {
|
|
|
870
888
|
s && (t.Authorization = `Bearer ${s}`);
|
|
871
889
|
try {
|
|
872
890
|
const n = await fetch(
|
|
873
|
-
`https://huggingface.co/api/spaces/${e}/${
|
|
891
|
+
`https://huggingface.co/api/spaces/${e}/${Ye}`,
|
|
874
892
|
{ headers: t }
|
|
875
893
|
);
|
|
876
894
|
if (n.status !== 200)
|
|
877
895
|
throw new Error("Space hardware could not be obtained.");
|
|
878
|
-
const { hardware:
|
|
879
|
-
return
|
|
896
|
+
const { hardware: i } = await n.json();
|
|
897
|
+
return i.current;
|
|
880
898
|
} catch (n) {
|
|
881
899
|
throw new Error(n.message);
|
|
882
900
|
}
|
|
@@ -884,16 +902,16 @@ async function Pt(e, s) {
|
|
|
884
902
|
async function It(e, s, t) {
|
|
885
903
|
const n = {};
|
|
886
904
|
t && (n.Authorization = `Bearer ${t}`);
|
|
887
|
-
const
|
|
905
|
+
const i = {
|
|
888
906
|
seconds: s
|
|
889
907
|
};
|
|
890
908
|
try {
|
|
891
909
|
const r = await fetch(
|
|
892
|
-
`https://huggingface.co/api/spaces/${e}/${
|
|
910
|
+
`https://huggingface.co/api/spaces/${e}/${Qe}`,
|
|
893
911
|
{
|
|
894
912
|
method: "POST",
|
|
895
913
|
headers: { "Content-Type": "application/json", ...n },
|
|
896
|
-
body: JSON.stringify(
|
|
914
|
+
body: JSON.stringify(i)
|
|
897
915
|
}
|
|
898
916
|
);
|
|
899
917
|
if (r.status !== 200)
|
|
@@ -905,7 +923,7 @@ async function It(e, s, t) {
|
|
|
905
923
|
throw new Error(r.message);
|
|
906
924
|
}
|
|
907
925
|
}
|
|
908
|
-
const
|
|
926
|
+
const Re = [
|
|
909
927
|
"cpu-basic",
|
|
910
928
|
"cpu-upgrade",
|
|
911
929
|
"cpu-xl",
|
|
@@ -921,21 +939,21 @@ const $e = [
|
|
|
921
939
|
"h100x8"
|
|
922
940
|
];
|
|
923
941
|
async function jt(e, s) {
|
|
924
|
-
const { token: t, private: n, hardware:
|
|
925
|
-
if (
|
|
942
|
+
const { token: t, private: n, hardware: i, timeout: r, auth: o } = s;
|
|
943
|
+
if (i && !Re.includes(i))
|
|
926
944
|
throw new Error(
|
|
927
|
-
`Invalid hardware type provided. Valid types are: ${
|
|
945
|
+
`Invalid hardware type provided. Valid types are: ${Re.map((g) => `"${g}"`).join(",")}.`
|
|
928
946
|
);
|
|
929
|
-
const { http_protocol: a, host: u } = await
|
|
947
|
+
const { http_protocol: a, host: u } = await pe(e, t);
|
|
930
948
|
let l = null;
|
|
931
|
-
if (
|
|
932
|
-
const g = await
|
|
949
|
+
if (o) {
|
|
950
|
+
const g = await De(
|
|
933
951
|
a,
|
|
934
952
|
u,
|
|
935
|
-
|
|
953
|
+
o,
|
|
936
954
|
fetch
|
|
937
955
|
);
|
|
938
|
-
g && (l =
|
|
956
|
+
g && (l = Ne(g));
|
|
939
957
|
}
|
|
940
958
|
const p = {
|
|
941
959
|
Authorization: `Bearer ${t}`,
|
|
@@ -947,13 +965,13 @@ async function jt(e, s) {
|
|
|
947
965
|
repository: `${c}/${m}`
|
|
948
966
|
};
|
|
949
967
|
n && (w.private = !0);
|
|
950
|
-
let
|
|
968
|
+
let N;
|
|
951
969
|
try {
|
|
952
|
-
|
|
970
|
+
i || (N = await Pt(e, t));
|
|
953
971
|
} catch (g) {
|
|
954
|
-
throw Error(
|
|
972
|
+
throw Error(ue + g.message);
|
|
955
973
|
}
|
|
956
|
-
const f =
|
|
974
|
+
const f = i || N || "cpu-basic";
|
|
957
975
|
w.hardware = f;
|
|
958
976
|
try {
|
|
959
977
|
const g = await fetch(
|
|
@@ -966,14 +984,14 @@ async function jt(e, s) {
|
|
|
966
984
|
);
|
|
967
985
|
if (g.status === 409)
|
|
968
986
|
try {
|
|
969
|
-
return await
|
|
987
|
+
return await Y.connect(`${c}/${m}`, s);
|
|
970
988
|
} catch (q) {
|
|
971
989
|
throw console.error("Failed to connect Client instance:", q), q;
|
|
972
990
|
}
|
|
973
991
|
else if (g.status !== 200)
|
|
974
992
|
throw new Error(g.statusText);
|
|
975
993
|
const H = await g.json();
|
|
976
|
-
return await It(`${c}/${m}`, r || 300, t), await
|
|
994
|
+
return await It(`${c}/${m}`, r || 300, t), await Y.connect(
|
|
977
995
|
Ut(H.url),
|
|
978
996
|
s
|
|
979
997
|
);
|
|
@@ -993,16 +1011,16 @@ class qt extends TransformStream {
|
|
|
993
1011
|
super({
|
|
994
1012
|
transform: (t, n) => {
|
|
995
1013
|
for (t = this.#e + t; ; ) {
|
|
996
|
-
const
|
|
1014
|
+
const i = t.indexOf(`
|
|
997
1015
|
`), r = s.allowCR ? t.indexOf("\r") : -1;
|
|
998
|
-
if (r !== -1 && r !== t.length - 1 && (
|
|
1016
|
+
if (r !== -1 && r !== t.length - 1 && (i === -1 || i - 1 > r)) {
|
|
999
1017
|
n.enqueue(t.slice(0, r)), t = t.slice(r + 1);
|
|
1000
1018
|
continue;
|
|
1001
1019
|
}
|
|
1002
|
-
if (
|
|
1020
|
+
if (i === -1)
|
|
1003
1021
|
break;
|
|
1004
|
-
const
|
|
1005
|
-
n.enqueue(t.slice(0,
|
|
1022
|
+
const o = t[i - 1] === "\r" ? i - 1 : i;
|
|
1023
|
+
n.enqueue(t.slice(0, o)), t = t.slice(i + 1);
|
|
1006
1024
|
}
|
|
1007
1025
|
this.#e = t;
|
|
1008
1026
|
},
|
|
@@ -1027,30 +1045,30 @@ function Bt(e) {
|
|
|
1027
1045
|
e.substring(n + t[0].length)
|
|
1028
1046
|
];
|
|
1029
1047
|
}
|
|
1030
|
-
function
|
|
1048
|
+
function Oe(e, s, t) {
|
|
1031
1049
|
e.get(s) || e.set(s, t);
|
|
1032
1050
|
}
|
|
1033
1051
|
async function* Ft(e, s) {
|
|
1034
1052
|
if (!e.body)
|
|
1035
1053
|
return;
|
|
1036
|
-
let t = zt(e.body), n,
|
|
1054
|
+
let t = zt(e.body), n, i = t.getReader(), r;
|
|
1037
1055
|
for (; ; ) {
|
|
1038
1056
|
if (s && s.aborted)
|
|
1039
|
-
return
|
|
1040
|
-
if (n = await
|
|
1057
|
+
return i.cancel();
|
|
1058
|
+
if (n = await i.read(), n.done)
|
|
1041
1059
|
return;
|
|
1042
1060
|
if (!n.value) {
|
|
1043
1061
|
r && (yield r), r = void 0;
|
|
1044
1062
|
continue;
|
|
1045
1063
|
}
|
|
1046
|
-
let [
|
|
1047
|
-
|
|
1048
|
-
` + a : a) :
|
|
1064
|
+
let [o, a] = Bt(n.value) || [];
|
|
1065
|
+
o === "data" ? (r ||= {}, r[o] = r[o] ? r[o] + `
|
|
1066
|
+
` + a : a) : o === "event" ? (r ||= {}, r[o] = a) : o === "id" ? (r ||= {}, r[o] = String(+a) === a ? +a : a) : o === "retry" && (r ||= {}, r[o] = +a || void 0);
|
|
1049
1067
|
}
|
|
1050
1068
|
}
|
|
1051
1069
|
async function Gt(e, s) {
|
|
1052
1070
|
let t = new Request(e, s);
|
|
1053
|
-
|
|
1071
|
+
Oe(t.headers, "Accept", "text/event-stream"), Oe(t.headers, "Content-Type", "application/json");
|
|
1054
1072
|
let n = await fetch(t);
|
|
1055
1073
|
if (!n.ok)
|
|
1056
1074
|
throw n;
|
|
@@ -1062,16 +1080,16 @@ async function Mt() {
|
|
|
1062
1080
|
unclosed_events: s,
|
|
1063
1081
|
pending_stream_messages: t,
|
|
1064
1082
|
stream_status: n,
|
|
1065
|
-
config:
|
|
1083
|
+
config: i,
|
|
1066
1084
|
jwt: r
|
|
1067
1085
|
} = this;
|
|
1068
|
-
const
|
|
1069
|
-
if (!
|
|
1086
|
+
const o = this;
|
|
1087
|
+
if (!i)
|
|
1070
1088
|
throw new Error("Could not resolve app config");
|
|
1071
1089
|
n.open = !0;
|
|
1072
1090
|
let a = null, u = new URLSearchParams({
|
|
1073
1091
|
session_hash: this.session_hash
|
|
1074
|
-
}).toString(), l = new URL(`${
|
|
1092
|
+
}).toString(), l = new URL(`${i.root}${this.api_prefix}/${Te}?${u}`);
|
|
1075
1093
|
if (r && l.searchParams.set("__sign", r), a = this.stream(l), !a) {
|
|
1076
1094
|
console.warn("Cannot connect to SSE endpoint: " + l.toString());
|
|
1077
1095
|
return;
|
|
@@ -1079,7 +1097,7 @@ async function Mt() {
|
|
|
1079
1097
|
a.onmessage = async function(p) {
|
|
1080
1098
|
let c = JSON.parse(p.data);
|
|
1081
1099
|
if (c.msg === "close_stream") {
|
|
1082
|
-
|
|
1100
|
+
de(n, o.abort_controller);
|
|
1083
1101
|
return;
|
|
1084
1102
|
}
|
|
1085
1103
|
const m = c.event_id;
|
|
@@ -1089,9 +1107,9 @@ async function Mt() {
|
|
|
1089
1107
|
(w) => e[w](c)
|
|
1090
1108
|
)
|
|
1091
1109
|
);
|
|
1092
|
-
else if (e[m] &&
|
|
1110
|
+
else if (e[m] && i) {
|
|
1093
1111
|
c.msg === "process_completed" && ["sse", "sse_v1", "sse_v2", "sse_v2.1", "sse_v3"].includes(
|
|
1094
|
-
|
|
1112
|
+
i.protocol
|
|
1095
1113
|
) && s.delete(m);
|
|
1096
1114
|
let w = e[m];
|
|
1097
1115
|
typeof window < "u" && typeof document < "u" ? setTimeout(w, 0, c) : w(c);
|
|
@@ -1108,20 +1126,20 @@ async function Mt() {
|
|
|
1108
1126
|
);
|
|
1109
1127
|
};
|
|
1110
1128
|
}
|
|
1111
|
-
function
|
|
1129
|
+
function de(e, s) {
|
|
1112
1130
|
e && (e.open = !1, s?.abort());
|
|
1113
1131
|
}
|
|
1114
1132
|
function Ht(e, s, t) {
|
|
1115
|
-
!e[s] ? (e[s] = [], t.data.forEach((
|
|
1116
|
-
e[s][r] =
|
|
1117
|
-
})) : t.data.forEach((
|
|
1118
|
-
let
|
|
1119
|
-
e[s][r] =
|
|
1133
|
+
!e[s] ? (e[s] = [], t.data.forEach((i, r) => {
|
|
1134
|
+
e[s][r] = i;
|
|
1135
|
+
})) : t.data.forEach((i, r) => {
|
|
1136
|
+
let o = Jt(e[s][r], i);
|
|
1137
|
+
e[s][r] = o, t.data[r] = o;
|
|
1120
1138
|
});
|
|
1121
1139
|
}
|
|
1122
1140
|
function Jt(e, s) {
|
|
1123
|
-
return s.forEach(([t, n,
|
|
1124
|
-
e = Wt(e, n, t,
|
|
1141
|
+
return s.forEach(([t, n, i]) => {
|
|
1142
|
+
e = Wt(e, n, t, i);
|
|
1125
1143
|
}), e;
|
|
1126
1144
|
}
|
|
1127
1145
|
function Wt(e, s, t, n) {
|
|
@@ -1132,22 +1150,22 @@ function Wt(e, s, t, n) {
|
|
|
1132
1150
|
return e + n;
|
|
1133
1151
|
throw new Error(`Unsupported action: ${t}`);
|
|
1134
1152
|
}
|
|
1135
|
-
let
|
|
1136
|
-
for (let
|
|
1137
|
-
|
|
1153
|
+
let i = e;
|
|
1154
|
+
for (let o = 0; o < s.length - 1; o++)
|
|
1155
|
+
i = i[s[o]];
|
|
1138
1156
|
const r = s[s.length - 1];
|
|
1139
1157
|
switch (t) {
|
|
1140
1158
|
case "replace":
|
|
1141
|
-
|
|
1159
|
+
i[r] = n;
|
|
1142
1160
|
break;
|
|
1143
1161
|
case "append":
|
|
1144
|
-
|
|
1162
|
+
i[r] += n;
|
|
1145
1163
|
break;
|
|
1146
1164
|
case "add":
|
|
1147
|
-
Array.isArray(
|
|
1165
|
+
Array.isArray(i) ? i.splice(Number(r), 0, n) : i[r] = n;
|
|
1148
1166
|
break;
|
|
1149
1167
|
case "delete":
|
|
1150
|
-
Array.isArray(
|
|
1168
|
+
Array.isArray(i) ? i.splice(Number(r), 1) : delete i[r];
|
|
1151
1169
|
break;
|
|
1152
1170
|
default:
|
|
1153
1171
|
throw new Error(`Unknown action: ${t}`);
|
|
@@ -1181,79 +1199,79 @@ function Zt(e, s = {}) {
|
|
|
1181
1199
|
return Gt(e, s).then(async (n) => {
|
|
1182
1200
|
t.readyState = t.OPEN;
|
|
1183
1201
|
try {
|
|
1184
|
-
for await (const
|
|
1185
|
-
t.onmessage && t.onmessage(
|
|
1202
|
+
for await (const i of n)
|
|
1203
|
+
t.onmessage && t.onmessage(i);
|
|
1186
1204
|
t.readyState = t.CLOSED;
|
|
1187
|
-
} catch (
|
|
1188
|
-
t.onerror && t.onerror(
|
|
1205
|
+
} catch (i) {
|
|
1206
|
+
t.onerror && t.onerror(i), t.readyState = t.CLOSED;
|
|
1189
1207
|
}
|
|
1190
1208
|
}).catch((n) => {
|
|
1191
1209
|
console.error(n), t.onerror && t.onerror(n), t.readyState = t.CLOSED;
|
|
1192
1210
|
}), t;
|
|
1193
1211
|
}
|
|
1194
|
-
function Kt(e, s = {}, t, n,
|
|
1212
|
+
function Kt(e, s = {}, t, n, i, r) {
|
|
1195
1213
|
try {
|
|
1196
|
-
let
|
|
1197
|
-
(
|
|
1214
|
+
let o = function(h) {
|
|
1215
|
+
(i || ze[h.type]) && p(h);
|
|
1198
1216
|
}, a = function() {
|
|
1199
|
-
for (
|
|
1217
|
+
for (Me = !0; F.length > 0; )
|
|
1200
1218
|
F.shift()({
|
|
1201
1219
|
value: void 0,
|
|
1202
1220
|
done: !0
|
|
1203
1221
|
});
|
|
1204
1222
|
}, u = function(h) {
|
|
1205
|
-
F.length > 0 ? F.shift()(h) :
|
|
1223
|
+
F.length > 0 ? F.shift()(h) : ie.push(h);
|
|
1206
1224
|
}, l = function(h) {
|
|
1207
1225
|
u(Vt(h)), a();
|
|
1208
1226
|
}, p = function(h) {
|
|
1209
1227
|
u({ value: h, done: !1 });
|
|
1210
1228
|
}, c = function() {
|
|
1211
|
-
return
|
|
1229
|
+
return ie.length > 0 ? Promise.resolve(ie.shift()) : new Promise((h) => F.push(h));
|
|
1212
1230
|
};
|
|
1213
1231
|
const { token: m } = this.options, {
|
|
1214
1232
|
fetch: w,
|
|
1215
|
-
app_reference:
|
|
1233
|
+
app_reference: N,
|
|
1216
1234
|
config: f,
|
|
1217
1235
|
session_hash: g,
|
|
1218
1236
|
api_info: H,
|
|
1219
1237
|
api_map: q,
|
|
1220
|
-
stream_status:
|
|
1221
|
-
pending_stream_messages:
|
|
1222
|
-
pending_diff_streams:
|
|
1223
|
-
event_callbacks:
|
|
1224
|
-
unclosed_events:
|
|
1225
|
-
post_data:
|
|
1238
|
+
stream_status: X,
|
|
1239
|
+
pending_stream_messages: ee,
|
|
1240
|
+
pending_diff_streams: te,
|
|
1241
|
+
event_callbacks: se,
|
|
1242
|
+
unclosed_events: je,
|
|
1243
|
+
post_data: ne,
|
|
1226
1244
|
options: J,
|
|
1227
1245
|
api_prefix: R
|
|
1228
|
-
} = this,
|
|
1246
|
+
} = this, he = r || { "x-gradio-user": "api" }, Ue = this;
|
|
1229
1247
|
if (!H) throw new Error("No API found");
|
|
1230
1248
|
if (!f) throw new Error("Could not resolve app config");
|
|
1231
|
-
let { fn_index: d, endpoint_info:
|
|
1249
|
+
let { fn_index: d, endpoint_info: fe, dependency: z } = Yt(
|
|
1232
1250
|
H,
|
|
1233
1251
|
e,
|
|
1234
1252
|
q,
|
|
1235
1253
|
f
|
|
1236
|
-
),
|
|
1254
|
+
), qe = wt(s, fe), j, O = f.protocol ?? "ws";
|
|
1237
1255
|
if (O === "ws")
|
|
1238
1256
|
throw new Error("WebSocket protocol is not supported in this version");
|
|
1239
1257
|
let U = "", Qt = () => U;
|
|
1240
1258
|
const _ = typeof e == "number" ? "/predict" : e;
|
|
1241
|
-
let W, b = null, T = !1,
|
|
1242
|
-
const
|
|
1259
|
+
let W, b = null, T = !1, _e = {}, B = typeof window < "u" && typeof document < "u" ? new URLSearchParams(window.location.search).toString() : "";
|
|
1260
|
+
const ze = J?.events?.reduce(
|
|
1243
1261
|
(h, k) => (h[k] = !0, h),
|
|
1244
1262
|
{}
|
|
1245
1263
|
) || {};
|
|
1246
|
-
async function
|
|
1264
|
+
async function Be() {
|
|
1247
1265
|
let h = {}, k = {};
|
|
1248
1266
|
h = { event_id: b }, k = { event_id: b, session_hash: g, fn_index: d };
|
|
1249
1267
|
try {
|
|
1250
1268
|
if (!f)
|
|
1251
1269
|
throw new Error("Could not resolve app config");
|
|
1252
|
-
"event_id" in k && await w(`${f.root}${R}/${
|
|
1270
|
+
"event_id" in k && await w(`${f.root}${R}/${st}`, {
|
|
1253
1271
|
headers: { "Content-Type": "application/json" },
|
|
1254
1272
|
method: "POST",
|
|
1255
1273
|
body: JSON.stringify(k)
|
|
1256
|
-
}), await w(`${f.root}${R}/${
|
|
1274
|
+
}), await w(`${f.root}${R}/${tt}`, {
|
|
1257
1275
|
headers: { "Content-Type": "application/json" },
|
|
1258
1276
|
method: "POST",
|
|
1259
1277
|
body: JSON.stringify(h)
|
|
@@ -1264,10 +1282,10 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1264
1282
|
);
|
|
1265
1283
|
}
|
|
1266
1284
|
}
|
|
1267
|
-
const
|
|
1285
|
+
const Fe = async (h) => {
|
|
1268
1286
|
await this._resolve_heartbeat(h);
|
|
1269
1287
|
};
|
|
1270
|
-
async function
|
|
1288
|
+
async function me(h) {
|
|
1271
1289
|
if (!f) return;
|
|
1272
1290
|
let k = h.render_id;
|
|
1273
1291
|
f.components = [
|
|
@@ -1278,22 +1296,22 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1278
1296
|
...h.dependencies
|
|
1279
1297
|
];
|
|
1280
1298
|
const Z = f.components.some((v) => v.type === "state"), y = f.dependencies.some(
|
|
1281
|
-
(v) => v.targets.some((
|
|
1299
|
+
(v) => v.targets.some((L) => L[1] === "unload")
|
|
1282
1300
|
);
|
|
1283
|
-
f.connect_heartbeat = Z || y, await
|
|
1301
|
+
f.connect_heartbeat = Z || y, await Fe(f), o({
|
|
1284
1302
|
type: "render",
|
|
1285
1303
|
data: h,
|
|
1286
1304
|
endpoint: _,
|
|
1287
1305
|
fn_index: d
|
|
1288
1306
|
});
|
|
1289
1307
|
}
|
|
1290
|
-
const
|
|
1308
|
+
const Ge = this.handle_blob(
|
|
1291
1309
|
f.root,
|
|
1292
|
-
|
|
1293
|
-
|
|
1310
|
+
qe,
|
|
1311
|
+
fe
|
|
1294
1312
|
).then(async (h) => {
|
|
1295
1313
|
if (W = {
|
|
1296
|
-
data:
|
|
1314
|
+
data: V(
|
|
1297
1315
|
h,
|
|
1298
1316
|
z,
|
|
1299
1317
|
f.components,
|
|
@@ -1304,28 +1322,28 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1304
1322
|
fn_index: d,
|
|
1305
1323
|
trigger_id: n
|
|
1306
1324
|
}, Ot(d, f))
|
|
1307
|
-
|
|
1325
|
+
o({
|
|
1308
1326
|
type: "status",
|
|
1309
1327
|
endpoint: _,
|
|
1310
1328
|
stage: "pending",
|
|
1311
1329
|
queue: !1,
|
|
1312
1330
|
fn_index: d,
|
|
1313
1331
|
time: /* @__PURE__ */ new Date()
|
|
1314
|
-
}),
|
|
1332
|
+
}), ne(
|
|
1315
1333
|
`${f.root}${R}/run${_.startsWith("/") ? _ : `/${_}`}${B ? "?" + B : ""}`,
|
|
1316
1334
|
{
|
|
1317
1335
|
...W,
|
|
1318
1336
|
session_hash: g
|
|
1319
1337
|
},
|
|
1320
|
-
|
|
1338
|
+
he
|
|
1321
1339
|
).then(async ([y, v]) => {
|
|
1322
|
-
const
|
|
1323
|
-
v == 200 ? (
|
|
1340
|
+
const L = y.data;
|
|
1341
|
+
v == 200 ? (o({
|
|
1324
1342
|
type: "data",
|
|
1325
1343
|
endpoint: _,
|
|
1326
1344
|
fn_index: d,
|
|
1327
|
-
data:
|
|
1328
|
-
|
|
1345
|
+
data: V(
|
|
1346
|
+
L,
|
|
1329
1347
|
z,
|
|
1330
1348
|
f.components,
|
|
1331
1349
|
"output",
|
|
@@ -1334,7 +1352,7 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1334
1352
|
time: /* @__PURE__ */ new Date(),
|
|
1335
1353
|
event_data: t,
|
|
1336
1354
|
trigger_id: n
|
|
1337
|
-
}), y.render_config && await
|
|
1355
|
+
}), y.render_config && await me(y.render_config), o({
|
|
1338
1356
|
type: "status",
|
|
1339
1357
|
endpoint: _,
|
|
1340
1358
|
fn_index: d,
|
|
@@ -1342,7 +1360,7 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1342
1360
|
eta: y.average_duration,
|
|
1343
1361
|
queue: !1,
|
|
1344
1362
|
time: /* @__PURE__ */ new Date()
|
|
1345
|
-
})) :
|
|
1363
|
+
})) : o({
|
|
1346
1364
|
type: "status",
|
|
1347
1365
|
stage: "error",
|
|
1348
1366
|
endpoint: _,
|
|
@@ -1352,7 +1370,7 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1352
1370
|
time: /* @__PURE__ */ new Date()
|
|
1353
1371
|
});
|
|
1354
1372
|
}).catch((y) => {
|
|
1355
|
-
|
|
1373
|
+
o({
|
|
1356
1374
|
type: "status",
|
|
1357
1375
|
stage: "error",
|
|
1358
1376
|
message: y.message,
|
|
@@ -1363,7 +1381,7 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1363
1381
|
});
|
|
1364
1382
|
});
|
|
1365
1383
|
else if (O == "sse") {
|
|
1366
|
-
|
|
1384
|
+
o({
|
|
1367
1385
|
type: "status",
|
|
1368
1386
|
stage: "pending",
|
|
1369
1387
|
queue: !0,
|
|
@@ -1376,27 +1394,27 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1376
1394
|
session_hash: g
|
|
1377
1395
|
}).toString();
|
|
1378
1396
|
let y = new URL(
|
|
1379
|
-
`${f.root}${R}/${
|
|
1397
|
+
`${f.root}${R}/${Te}?${B ? B + "&" : ""}${Z}`
|
|
1380
1398
|
);
|
|
1381
1399
|
if (this.jwt && y.searchParams.set("__sign", this.jwt), j = this.stream(y), !j)
|
|
1382
1400
|
return Promise.reject(
|
|
1383
1401
|
new Error("Cannot connect to SSE endpoint: " + y.toString())
|
|
1384
1402
|
);
|
|
1385
1403
|
j.onmessage = async function(v) {
|
|
1386
|
-
const
|
|
1387
|
-
|
|
1388
|
-
|
|
1404
|
+
const L = JSON.parse(v.data), { type: P, status: A, data: x } = Ee(
|
|
1405
|
+
L,
|
|
1406
|
+
_e[d]
|
|
1389
1407
|
);
|
|
1390
|
-
if (
|
|
1391
|
-
|
|
1408
|
+
if (P === "update" && A && !T)
|
|
1409
|
+
o({
|
|
1392
1410
|
type: "status",
|
|
1393
1411
|
endpoint: _,
|
|
1394
1412
|
fn_index: d,
|
|
1395
1413
|
time: /* @__PURE__ */ new Date(),
|
|
1396
1414
|
...A
|
|
1397
1415
|
}), A.stage === "error" && (j?.close(), a());
|
|
1398
|
-
else if (
|
|
1399
|
-
let [C,
|
|
1416
|
+
else if (P === "data") {
|
|
1417
|
+
let [C, I] = await ne(
|
|
1400
1418
|
`${f.root}${R}/queue/data`,
|
|
1401
1419
|
{
|
|
1402
1420
|
...W,
|
|
@@ -1404,7 +1422,7 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1404
1422
|
event_id: b
|
|
1405
1423
|
}
|
|
1406
1424
|
);
|
|
1407
|
-
|
|
1425
|
+
I !== 200 && (o({
|
|
1408
1426
|
type: "status",
|
|
1409
1427
|
stage: "error",
|
|
1410
1428
|
message: M,
|
|
@@ -1413,7 +1431,7 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1413
1431
|
fn_index: d,
|
|
1414
1432
|
time: /* @__PURE__ */ new Date()
|
|
1415
1433
|
}), j?.close(), a());
|
|
1416
|
-
} else
|
|
1434
|
+
} else P === "complete" ? T = A : P === "log" ? o({
|
|
1417
1435
|
type: "log",
|
|
1418
1436
|
title: x.title,
|
|
1419
1437
|
log: x.log,
|
|
@@ -1422,7 +1440,7 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1422
1440
|
duration: x.duration,
|
|
1423
1441
|
visible: x.visible,
|
|
1424
1442
|
fn_index: d
|
|
1425
|
-
}) : (
|
|
1443
|
+
}) : (P === "generating" || P === "streaming") && o({
|
|
1426
1444
|
type: "status",
|
|
1427
1445
|
time: /* @__PURE__ */ new Date(),
|
|
1428
1446
|
...A,
|
|
@@ -1431,10 +1449,10 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1431
1449
|
endpoint: _,
|
|
1432
1450
|
fn_index: d
|
|
1433
1451
|
});
|
|
1434
|
-
x && (
|
|
1452
|
+
x && (o({
|
|
1435
1453
|
type: "data",
|
|
1436
1454
|
time: /* @__PURE__ */ new Date(),
|
|
1437
|
-
data:
|
|
1455
|
+
data: V(
|
|
1438
1456
|
x.data,
|
|
1439
1457
|
z,
|
|
1440
1458
|
f.components,
|
|
@@ -1445,7 +1463,7 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1445
1463
|
fn_index: d,
|
|
1446
1464
|
event_data: t,
|
|
1447
1465
|
trigger_id: n
|
|
1448
|
-
}), T && (
|
|
1466
|
+
}), T && (o({
|
|
1449
1467
|
type: "status",
|
|
1450
1468
|
time: /* @__PURE__ */ new Date(),
|
|
1451
1469
|
...T,
|
|
@@ -1456,7 +1474,7 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1456
1474
|
}), j?.close(), a()));
|
|
1457
1475
|
};
|
|
1458
1476
|
} else if (O == "sse_v1" || O == "sse_v2" || O == "sse_v2.1" || O == "sse_v3") {
|
|
1459
|
-
|
|
1477
|
+
o({
|
|
1460
1478
|
type: "status",
|
|
1461
1479
|
stage: "pending",
|
|
1462
1480
|
queue: !0,
|
|
@@ -1466,31 +1484,31 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1466
1484
|
});
|
|
1467
1485
|
let y = "";
|
|
1468
1486
|
typeof window < "u" && typeof document < "u" && (y = window?.location?.hostname);
|
|
1469
|
-
const
|
|
1470
|
-
return (typeof window < "u" && typeof document < "u" && window.parent != window && window.supports_zerogpu_headers ? Tt("zerogpu-headers",
|
|
1471
|
-
const
|
|
1472
|
-
return
|
|
1473
|
-
`${f.root}${R}/${
|
|
1487
|
+
const L = y.includes(".dev.") ? `https://moon-${y.split(".")[1]}.dev.spaces.huggingface.tech` : "https://huggingface.co";
|
|
1488
|
+
return (typeof window < "u" && typeof document < "u" && window.parent != window && window.supports_zerogpu_headers ? Tt("zerogpu-headers", L) : Promise.resolve(null)).then((C) => {
|
|
1489
|
+
const I = { ...he, ...C || {} };
|
|
1490
|
+
return ne(
|
|
1491
|
+
`${f.root}${R}/${Ze}?${B}`,
|
|
1474
1492
|
{
|
|
1475
1493
|
...W,
|
|
1476
1494
|
session_hash: g
|
|
1477
1495
|
},
|
|
1478
|
-
|
|
1496
|
+
I
|
|
1479
1497
|
);
|
|
1480
|
-
}).then(async ([C,
|
|
1481
|
-
if (C.event_id && (U = C.event_id),
|
|
1482
|
-
|
|
1498
|
+
}).then(async ([C, I]) => {
|
|
1499
|
+
if (C.event_id && (U = C.event_id), I === 503)
|
|
1500
|
+
o({
|
|
1483
1501
|
type: "status",
|
|
1484
1502
|
stage: "error",
|
|
1485
|
-
message:
|
|
1503
|
+
message: Ae,
|
|
1486
1504
|
queue: !0,
|
|
1487
1505
|
endpoint: _,
|
|
1488
1506
|
fn_index: d,
|
|
1489
1507
|
time: /* @__PURE__ */ new Date(),
|
|
1490
1508
|
visible: !0
|
|
1491
1509
|
});
|
|
1492
|
-
else if (
|
|
1493
|
-
|
|
1510
|
+
else if (I === 422)
|
|
1511
|
+
o({
|
|
1494
1512
|
type: "status",
|
|
1495
1513
|
stage: "error",
|
|
1496
1514
|
message: C.detail,
|
|
@@ -1501,8 +1519,8 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1501
1519
|
time: /* @__PURE__ */ new Date(),
|
|
1502
1520
|
visible: !0
|
|
1503
1521
|
}), a();
|
|
1504
|
-
else if (
|
|
1505
|
-
|
|
1522
|
+
else if (I !== 200)
|
|
1523
|
+
o({
|
|
1506
1524
|
type: "status",
|
|
1507
1525
|
stage: "error",
|
|
1508
1526
|
broken: !1,
|
|
@@ -1515,41 +1533,41 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1515
1533
|
});
|
|
1516
1534
|
else {
|
|
1517
1535
|
b = C.event_id, U = b;
|
|
1518
|
-
let
|
|
1536
|
+
let we = async function(oe) {
|
|
1519
1537
|
try {
|
|
1520
|
-
const { type: E, status: S, data: $, original_msg:
|
|
1538
|
+
const { type: E, status: S, data: $, original_msg: He } = Ee(
|
|
1521
1539
|
oe,
|
|
1522
|
-
|
|
1540
|
+
_e[d]
|
|
1523
1541
|
);
|
|
1524
1542
|
if (E == "heartbeat")
|
|
1525
1543
|
return;
|
|
1526
1544
|
if (E === "update" && S && !T)
|
|
1527
|
-
|
|
1545
|
+
o({
|
|
1528
1546
|
type: "status",
|
|
1529
1547
|
endpoint: _,
|
|
1530
1548
|
fn_index: d,
|
|
1531
1549
|
time: /* @__PURE__ */ new Date(),
|
|
1532
|
-
original_msg:
|
|
1550
|
+
original_msg: He,
|
|
1533
1551
|
...S
|
|
1534
1552
|
});
|
|
1535
1553
|
else if (E === "complete")
|
|
1536
1554
|
T = S;
|
|
1537
1555
|
else if (E == "unexpected_error" || E == "broken_connection") {
|
|
1538
1556
|
console.error("Unexpected error", S?.message);
|
|
1539
|
-
const
|
|
1540
|
-
|
|
1557
|
+
const Je = E === "broken_connection";
|
|
1558
|
+
o({
|
|
1541
1559
|
type: "status",
|
|
1542
1560
|
stage: "error",
|
|
1543
1561
|
message: S?.message || "An Unexpected Error Occurred!",
|
|
1544
1562
|
queue: !0,
|
|
1545
1563
|
endpoint: _,
|
|
1546
|
-
broken:
|
|
1564
|
+
broken: Je,
|
|
1547
1565
|
session_not_found: S?.session_not_found,
|
|
1548
1566
|
fn_index: d,
|
|
1549
1567
|
time: /* @__PURE__ */ new Date()
|
|
1550
1568
|
});
|
|
1551
1569
|
} else if (E === "log") {
|
|
1552
|
-
|
|
1570
|
+
o({
|
|
1553
1571
|
type: "log",
|
|
1554
1572
|
title: $.title,
|
|
1555
1573
|
log: $.log,
|
|
@@ -1560,7 +1578,7 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1560
1578
|
fn_index: d
|
|
1561
1579
|
});
|
|
1562
1580
|
return;
|
|
1563
|
-
} else (E === "generating" || E === "streaming") && (
|
|
1581
|
+
} else (E === "generating" || E === "streaming") && (o({
|
|
1564
1582
|
type: "status",
|
|
1565
1583
|
time: /* @__PURE__ */ new Date(),
|
|
1566
1584
|
...S,
|
|
@@ -1568,11 +1586,11 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1568
1586
|
queue: !0,
|
|
1569
1587
|
endpoint: _,
|
|
1570
1588
|
fn_index: d
|
|
1571
|
-
}), $ && z.connection !== "stream" && ["sse_v2", "sse_v2.1", "sse_v3"].includes(O) && Ht(
|
|
1572
|
-
$ && (
|
|
1589
|
+
}), $ && z.connection !== "stream" && ["sse_v2", "sse_v2.1", "sse_v3"].includes(O) && Ht(te, b, $));
|
|
1590
|
+
$ && (o({
|
|
1573
1591
|
type: "data",
|
|
1574
1592
|
time: /* @__PURE__ */ new Date(),
|
|
1575
|
-
data:
|
|
1593
|
+
data: V(
|
|
1576
1594
|
$.data,
|
|
1577
1595
|
z,
|
|
1578
1596
|
f.components,
|
|
@@ -1581,7 +1599,7 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1581
1599
|
),
|
|
1582
1600
|
endpoint: _,
|
|
1583
1601
|
fn_index: d
|
|
1584
|
-
}), $.render_config && await
|
|
1602
|
+
}), $.render_config && await me($.render_config), T && (o({
|
|
1585
1603
|
type: "status",
|
|
1586
1604
|
time: /* @__PURE__ */ new Date(),
|
|
1587
1605
|
...T,
|
|
@@ -1589,9 +1607,9 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1589
1607
|
queue: !0,
|
|
1590
1608
|
endpoint: _,
|
|
1591
1609
|
fn_index: d
|
|
1592
|
-
}), a())), (S?.stage === "complete" || S?.stage === "error") && (
|
|
1610
|
+
}), a())), (S?.stage === "complete" || S?.stage === "error") && (se[b] && delete se[b], b in te && delete te[b]);
|
|
1593
1611
|
} catch (E) {
|
|
1594
|
-
console.error("Unexpected client exception", E),
|
|
1612
|
+
console.error("Unexpected client exception", E), o({
|
|
1595
1613
|
type: "status",
|
|
1596
1614
|
stage: "error",
|
|
1597
1615
|
message: "An Unexpected Error Occurred!",
|
|
@@ -1599,21 +1617,21 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1599
1617
|
endpoint: _,
|
|
1600
1618
|
fn_index: d,
|
|
1601
1619
|
time: /* @__PURE__ */ new Date()
|
|
1602
|
-
}), ["sse_v2", "sse_v2.1", "sse_v3"].includes(O) && (
|
|
1620
|
+
}), ["sse_v2", "sse_v2.1", "sse_v3"].includes(O) && (de(X, Ue.abort_controller), X.open = !1, a());
|
|
1603
1621
|
}
|
|
1604
1622
|
};
|
|
1605
|
-
b in
|
|
1623
|
+
b in ee && (ee[b].forEach((oe) => we(oe)), delete ee[b]), se[b] = we, je.add(b), X.open || await this.open_stream();
|
|
1606
1624
|
}
|
|
1607
1625
|
});
|
|
1608
1626
|
}
|
|
1609
1627
|
});
|
|
1610
|
-
let
|
|
1611
|
-
const
|
|
1612
|
-
[Symbol.asyncIterator]: () =>
|
|
1628
|
+
let Me = !1;
|
|
1629
|
+
const ie = [], F = [], ge = {
|
|
1630
|
+
[Symbol.asyncIterator]: () => ge,
|
|
1613
1631
|
next: c,
|
|
1614
1632
|
throw: async (h) => (l(h), c()),
|
|
1615
1633
|
return: async () => (a(), { value: void 0, done: !0 }),
|
|
1616
|
-
cancel:
|
|
1634
|
+
cancel: Be,
|
|
1617
1635
|
send_chunk: (h) => {
|
|
1618
1636
|
this.post_data(`${f.root}${R}/stream/${U}`, {
|
|
1619
1637
|
...h,
|
|
@@ -1627,11 +1645,11 @@ function Kt(e, s = {}, t, n, o, r) {
|
|
|
1627
1645
|
), a();
|
|
1628
1646
|
},
|
|
1629
1647
|
event_id: () => U,
|
|
1630
|
-
wait_for_id: async () => (await
|
|
1648
|
+
wait_for_id: async () => (await Ge, b)
|
|
1631
1649
|
};
|
|
1632
|
-
return
|
|
1633
|
-
} catch (
|
|
1634
|
-
throw console.error("Submit function encountered an error:",
|
|
1650
|
+
return ge;
|
|
1651
|
+
} catch (o) {
|
|
1652
|
+
throw console.error("Submit function encountered an error:", o), o;
|
|
1635
1653
|
}
|
|
1636
1654
|
}
|
|
1637
1655
|
function Vt(e) {
|
|
@@ -1640,22 +1658,22 @@ function Vt(e) {
|
|
|
1640
1658
|
};
|
|
1641
1659
|
}
|
|
1642
1660
|
function Yt(e, s, t, n) {
|
|
1643
|
-
let
|
|
1661
|
+
let i, r, o;
|
|
1644
1662
|
if (typeof s == "number")
|
|
1645
|
-
|
|
1663
|
+
i = s, r = e.unnamed_endpoints[i], o = n.dependencies.find((a) => a.id == s);
|
|
1646
1664
|
else {
|
|
1647
1665
|
const a = s.replace(/^\//, "");
|
|
1648
|
-
|
|
1666
|
+
i = t[a], r = e.named_endpoints[s.trim()], o = n.dependencies.find(
|
|
1649
1667
|
(u) => u.id == t[a]
|
|
1650
1668
|
);
|
|
1651
1669
|
}
|
|
1652
|
-
if (typeof
|
|
1670
|
+
if (typeof i != "number")
|
|
1653
1671
|
throw new Error(
|
|
1654
1672
|
"There is no endpoint matching that name of fn_index matching that number."
|
|
1655
1673
|
);
|
|
1656
|
-
return { fn_index:
|
|
1674
|
+
return { fn_index: i, endpoint_info: r, dependency: o };
|
|
1657
1675
|
}
|
|
1658
|
-
class
|
|
1676
|
+
class Y {
|
|
1659
1677
|
app_reference;
|
|
1660
1678
|
options;
|
|
1661
1679
|
deep_link = null;
|
|
@@ -1680,15 +1698,15 @@ class V {
|
|
|
1680
1698
|
current_payload;
|
|
1681
1699
|
get_url_config(s = null) {
|
|
1682
1700
|
if (!this.config)
|
|
1683
|
-
throw new Error(
|
|
1701
|
+
throw new Error(D);
|
|
1684
1702
|
s === null && (s = window.location.href);
|
|
1685
|
-
const t = (
|
|
1686
|
-
let n = t(new URL(this.config.root).pathname),
|
|
1687
|
-
return
|
|
1703
|
+
const t = (o) => o.replace(/^\/+|\/+$/g, "");
|
|
1704
|
+
let n = t(new URL(this.config.root).pathname), i = t(new URL(s).pathname), r;
|
|
1705
|
+
return i.startsWith(n) ? r = t(i.substring(n.length)) : r = "", this.get_page_config(r);
|
|
1688
1706
|
}
|
|
1689
1707
|
get_page_config(s) {
|
|
1690
1708
|
if (!this.config)
|
|
1691
|
-
throw new Error(
|
|
1709
|
+
throw new Error(D);
|
|
1692
1710
|
let t = this.config;
|
|
1693
1711
|
return s in t.page || (s = ""), {
|
|
1694
1712
|
...t,
|
|
@@ -1704,14 +1722,14 @@ class V {
|
|
|
1704
1722
|
}
|
|
1705
1723
|
fetch(s, t) {
|
|
1706
1724
|
const n = new Headers(t?.headers || {});
|
|
1707
|
-
return this && this.cookies && n.append("Cookie", this.cookies), this && this.options.headers && new Headers(this.options.headers).forEach((r,
|
|
1708
|
-
n.append(
|
|
1725
|
+
return this && this.cookies && n.append("Cookie", this.cookies), this && this.options.headers && new Headers(this.options.headers).forEach((r, o) => {
|
|
1726
|
+
n.append(o, r);
|
|
1709
1727
|
}), fetch(s, { ...t, headers: n });
|
|
1710
1728
|
}
|
|
1711
1729
|
stream(s) {
|
|
1712
1730
|
const t = new Headers();
|
|
1713
|
-
return this && this.cookies && t.append("Cookie", this.cookies), this && this.options.headers && new Headers(this.options.headers).forEach((
|
|
1714
|
-
t.append(r,
|
|
1731
|
+
return this && this.cookies && t.append("Cookie", this.cookies), this && this.options.headers && new Headers(this.options.headers).forEach((i, r) => {
|
|
1732
|
+
t.append(r, i);
|
|
1715
1733
|
}), this && this.options.token && t.append("Authorization", `Bearer ${this.options.token}`), this.abort_controller = new AbortController(), this.stream_instance = Zt(s.toString(), {
|
|
1716
1734
|
credentials: "include",
|
|
1717
1735
|
headers: t,
|
|
@@ -1729,21 +1747,21 @@ class V {
|
|
|
1729
1747
|
resolve_config;
|
|
1730
1748
|
resolve_cookies;
|
|
1731
1749
|
constructor(s, t = { events: ["data"] }) {
|
|
1732
|
-
this.app_reference = s, this.deep_link = t.query_params?.deep_link || null, t.events || (t.events = ["data"]), this.options = t, this.current_payload = {}, this.view_api = yt.bind(this), this.upload_files = bt.bind(this), this.handle_blob = At.bind(this), this.post_data = Dt.bind(this), this.submit = Kt.bind(this), this.predict = Nt.bind(this), this.open_stream = Mt.bind(this), this.resolve_config =
|
|
1750
|
+
this.app_reference = s, this.deep_link = t.query_params?.deep_link || null, t.events || (t.events = ["data"]), this.options = t, this.current_payload = {}, t.cookies && (this.cookies = t.cookies), this.view_api = yt.bind(this), this.upload_files = bt.bind(this), this.handle_blob = At.bind(this), this.post_data = Dt.bind(this), this.submit = Kt.bind(this), this.predict = Nt.bind(this), this.open_stream = Mt.bind(this), this.resolve_config = dt.bind(this), this.resolve_cookies = ht.bind(this), this.upload = kt.bind(this), this.fetch = this.fetch.bind(this), this.handle_space_success = this.handle_space_success.bind(this), this.stream = this.stream.bind(this);
|
|
1733
1751
|
}
|
|
1734
1752
|
async init() {
|
|
1735
1753
|
this.options.auth && await this.resolve_cookies(), await this._resolve_config().then(
|
|
1736
1754
|
({ config: s }) => this._resolve_heartbeat(s)
|
|
1737
|
-
), this.api_info = await this.view_api(), this.api_map =
|
|
1755
|
+
), this.api_info = await this.view_api(), this.api_map = pt(this.config?.dependencies || []);
|
|
1738
1756
|
}
|
|
1739
1757
|
async _resolve_heartbeat(s) {
|
|
1740
|
-
if (s && (this.config = s, this.api_prefix = s.api_prefix || "", this.config && this.config.connect_heartbeat && this.config.space_id && this.options.token && (this.jwt = await
|
|
1758
|
+
if (s && (this.config = s, this.api_prefix = s.api_prefix || "", this.config && this.config.connect_heartbeat && this.config.space_id && this.options.token && (this.jwt = await be(
|
|
1741
1759
|
this.config.space_id,
|
|
1742
1760
|
this.options.token,
|
|
1743
1761
|
this.cookies
|
|
1744
|
-
))), s.space_id && this.options.token && (this.jwt = await
|
|
1762
|
+
))), s.space_id && this.options.token && (this.jwt = await be(s.space_id, this.options.token)), this.config && this.config.connect_heartbeat) {
|
|
1745
1763
|
const t = new URL(
|
|
1746
|
-
`${this.config.root}${this.api_prefix}/${
|
|
1764
|
+
`${this.config.root}${this.api_prefix}/${Xe}/${this.session_hash}`
|
|
1747
1765
|
);
|
|
1748
1766
|
this.jwt && t.searchParams.set("__sign", this.jwt), this.heartbeat_event || (this.heartbeat_event = this.stream(t));
|
|
1749
1767
|
}
|
|
@@ -1756,7 +1774,7 @@ class V {
|
|
|
1756
1774
|
}
|
|
1757
1775
|
async reconnect() {
|
|
1758
1776
|
const s = new URL(
|
|
1759
|
-
`${this.config.root}${this.api_prefix}/${
|
|
1777
|
+
`${this.config.root}${this.api_prefix}/${nt}`
|
|
1760
1778
|
);
|
|
1761
1779
|
let t;
|
|
1762
1780
|
try {
|
|
@@ -1770,7 +1788,7 @@ class V {
|
|
|
1770
1788
|
return t !== this.config.app_id ? "changed" : "connected";
|
|
1771
1789
|
}
|
|
1772
1790
|
close() {
|
|
1773
|
-
this.closed = !0,
|
|
1791
|
+
this.closed = !0, de(this.stream_status, this.abort_controller);
|
|
1774
1792
|
}
|
|
1775
1793
|
set_current_payload(s) {
|
|
1776
1794
|
this.current_payload = s;
|
|
@@ -1781,31 +1799,31 @@ class V {
|
|
|
1781
1799
|
return jt(s, t);
|
|
1782
1800
|
}
|
|
1783
1801
|
async _resolve_config() {
|
|
1784
|
-
const { http_protocol: s, host: t, space_id: n } = await
|
|
1802
|
+
const { http_protocol: s, host: t, space_id: n } = await pe(
|
|
1785
1803
|
this.app_reference,
|
|
1786
1804
|
this.options.token
|
|
1787
|
-
), { status_callback:
|
|
1788
|
-
n &&
|
|
1805
|
+
), { status_callback: i } = this.options;
|
|
1806
|
+
n && i && await Ie(n, i);
|
|
1789
1807
|
let r;
|
|
1790
1808
|
try {
|
|
1791
|
-
let
|
|
1792
|
-
if (r = await this.resolve_config(
|
|
1793
|
-
throw new Error(
|
|
1809
|
+
let o = `${s}//${t}`;
|
|
1810
|
+
if (r = await this.resolve_config(o), !r)
|
|
1811
|
+
throw new Error(D);
|
|
1794
1812
|
return this.config_success(r);
|
|
1795
|
-
} catch (
|
|
1796
|
-
if (n &&
|
|
1813
|
+
} catch (o) {
|
|
1814
|
+
if (n && i)
|
|
1797
1815
|
G(
|
|
1798
1816
|
n,
|
|
1799
|
-
|
|
1817
|
+
le.test(n) ? "space_name" : "subdomain",
|
|
1800
1818
|
this.handle_space_success
|
|
1801
1819
|
);
|
|
1802
1820
|
else
|
|
1803
|
-
throw
|
|
1821
|
+
throw i && i({
|
|
1804
1822
|
status: "error",
|
|
1805
1823
|
message: "Could not load this space.",
|
|
1806
1824
|
load_status: "error",
|
|
1807
1825
|
detail: "NOT_FOUND"
|
|
1808
|
-
}), Error(
|
|
1826
|
+
}), Error(o);
|
|
1809
1827
|
}
|
|
1810
1828
|
}
|
|
1811
1829
|
async config_success(s) {
|
|
@@ -1820,12 +1838,12 @@ class V {
|
|
|
1820
1838
|
}
|
|
1821
1839
|
async handle_space_success(s) {
|
|
1822
1840
|
if (!this)
|
|
1823
|
-
throw new Error(
|
|
1841
|
+
throw new Error(D);
|
|
1824
1842
|
const { status_callback: t } = this.options;
|
|
1825
1843
|
if (t && t(s), s.status === "running")
|
|
1826
1844
|
try {
|
|
1827
1845
|
if (this.config = await this._resolve_config(), this.api_prefix = this?.config?.api_prefix || "", !this.config)
|
|
1828
|
-
throw new Error(
|
|
1846
|
+
throw new Error(D);
|
|
1829
1847
|
return await this.config_success(this.config);
|
|
1830
1848
|
} catch (n) {
|
|
1831
1849
|
throw t && t({
|
|
@@ -1838,9 +1856,9 @@ class V {
|
|
|
1838
1856
|
}
|
|
1839
1857
|
async component_server(s, t, n) {
|
|
1840
1858
|
if (!this.config)
|
|
1841
|
-
throw new Error(
|
|
1842
|
-
const
|
|
1843
|
-
r && (
|
|
1859
|
+
throw new Error(D);
|
|
1860
|
+
const i = {}, { token: r } = this.options, { session_hash: o } = this;
|
|
1861
|
+
r && (i.Authorization = `Bearer ${this.options.token}`);
|
|
1844
1862
|
let a, u = this.config.components.find(
|
|
1845
1863
|
(p) => p.id === s
|
|
1846
1864
|
);
|
|
@@ -1850,22 +1868,22 @@ class V {
|
|
|
1850
1868
|
l = new FormData();
|
|
1851
1869
|
for (const p in n.data)
|
|
1852
1870
|
p !== "binary" && l.append(p, n.data[p]);
|
|
1853
|
-
l.set("component_id", s.toString()), l.set("fn_name", t), l.set("session_hash",
|
|
1871
|
+
l.set("component_id", s.toString()), l.set("fn_name", t), l.set("session_hash", o);
|
|
1854
1872
|
} else
|
|
1855
1873
|
l = JSON.stringify({
|
|
1856
1874
|
data: n,
|
|
1857
1875
|
component_id: s,
|
|
1858
1876
|
fn_name: t,
|
|
1859
|
-
session_hash:
|
|
1860
|
-
}),
|
|
1861
|
-
r && (
|
|
1877
|
+
session_hash: o
|
|
1878
|
+
}), i["Content-Type"] = "application/json";
|
|
1879
|
+
r && (i.Authorization = `Bearer ${r}`);
|
|
1862
1880
|
try {
|
|
1863
1881
|
const p = await this.fetch(
|
|
1864
|
-
`${a}${this.api_prefix}/${
|
|
1882
|
+
`${a}${this.api_prefix}/${et}/`,
|
|
1865
1883
|
{
|
|
1866
1884
|
method: "POST",
|
|
1867
1885
|
body: l,
|
|
1868
|
-
headers:
|
|
1886
|
+
headers: i,
|
|
1869
1887
|
credentials: "include"
|
|
1870
1888
|
}
|
|
1871
1889
|
);
|
|
@@ -1879,7 +1897,7 @@ class V {
|
|
|
1879
1897
|
}
|
|
1880
1898
|
}
|
|
1881
1899
|
set_cookies(s) {
|
|
1882
|
-
this.cookies =
|
|
1900
|
+
this.cookies = Ne(s).join("; ");
|
|
1883
1901
|
}
|
|
1884
1902
|
prepare_return_obj() {
|
|
1885
1903
|
return {
|
|
@@ -1894,15 +1912,15 @@ class V {
|
|
|
1894
1912
|
async function ts(e, s = {
|
|
1895
1913
|
events: ["data"]
|
|
1896
1914
|
}) {
|
|
1897
|
-
return await
|
|
1915
|
+
return await Y.connect(e, s);
|
|
1898
1916
|
}
|
|
1899
1917
|
async function ss(e, s) {
|
|
1900
|
-
return await
|
|
1918
|
+
return await Y.duplicate(e, s);
|
|
1901
1919
|
}
|
|
1902
1920
|
export {
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1921
|
+
Y as Client,
|
|
1922
|
+
Q as FileData,
|
|
1923
|
+
ct as MISSING_CREDENTIALS_MSG,
|
|
1906
1924
|
ts as client,
|
|
1907
1925
|
ss as duplicate,
|
|
1908
1926
|
es as handle_file,
|