@gradio/client 2.7.0 → 2.7.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 +6 -0
- package/dist/browser.js +360 -356
- package/dist/index.cjs +8 -2
- package/dist/index.js +8 -2
- package/dist/index.min.js +161 -157
- package/dist/utils/submit.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/test/submit.test.ts +40 -1
- package/src/utils/submit.ts +16 -9
package/dist/index.min.js
CHANGED
|
@@ -8,7 +8,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
8
8
|
}, c = (n, r, a) => (a = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule ? t(a, "default", {
|
|
9
9
|
value: n,
|
|
10
10
|
enumerable: !0
|
|
11
|
-
}) : a, n)), l = "host", u = "queue/data", d = "queue/join", f = "upload", p = "login", m = "config", ee = "info", h = "runtime",
|
|
11
|
+
}) : a, n)), l = "host", u = "queue/data", d = "queue/join", f = "upload", p = "login", m = "config", ee = "info", h = "runtime", g = "sleeptime", _ = "heartbeat", te = "component_server", ne = "reset", re = "cancel", ie = "app_id", ae = "This application is currently busy. Please try again. ", v = "Connection errored out. ", y = "Could not resolve app config. ", b = "Could not get space status. ", oe = "Could not get API info. ", x = "Space metadata could not be loaded. ", se = "Invalid URL. A full URL path is required.", S = "Not authorized to access this space. ", C = "Invalid credentials. Could not login. ", w = "Login credentials are required to access this space.", ce = "Could not access this app (received a 401 response). If it is a private Hugging Face Space, pass a valid Hugging Face token to the `token` option of `Client.connect`. You can generate a token at https://huggingface.co/settings/tokens.", T = (e, t) => `Space "${e}" could not be accessed (received a ${t} response from the Hugging Face API). Check that the Space name is spelled correctly and that the Space exists. If the Space is private, pass a valid Hugging Face token to the \`token\` option of \`Client.connect\`. You can generate a token at https://huggingface.co/settings/tokens.`, le = "No API information is available for this app. This can happen when the app's `/info` endpoint cannot be reached, or when the app is running a legacy version of Gradio that is not supported by this client. ", ue = "This app appears to be running a legacy version of Gradio (3.x or earlier) that communicates over WebSockets, which is not supported by this version of @gradio/client. Please upgrade the app to a newer version of Gradio, or connect to it with @gradio/client version 0.x.", de = "File system access is only available in Node.js environments", fe = "Root URL not found in client config", pe = "Error uploading file";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/helpers/init_helpers.ts
|
|
14
14
|
async function me(e, t, n) {
|
|
@@ -21,26 +21,26 @@ async function me(e, t, n) {
|
|
|
21
21
|
return !1;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function he(e) {
|
|
25
25
|
e.hf_token && !e.token && (e.token = e.hf_token, console.warn("The `hf_token` option has been renamed to `token`. Support for `hf_token` will be removed in a future version of @gradio/client."));
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function E(e) {
|
|
28
28
|
let t = {};
|
|
29
29
|
return e.forEach(({ api_name: e, id: n }) => {
|
|
30
30
|
e && (t[e] = n);
|
|
31
31
|
}), t;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function ge(e, t, n = !1) {
|
|
34
34
|
let r = new URL(t), i = new URL(e, r), a = i.hostname.endsWith(".colab-user-runtimes.internal") || i.hostname.endsWith(".codatalab-user-runtimes.internal");
|
|
35
35
|
return n || a ? new URL(new URL(e, r).pathname, r).toString().replace(/\/$/, "") : i.hostname === r.hostname ? (i.protocol = r.protocol, i.host = r.host, i.toString().replace(/\/$/, "")) : e;
|
|
36
36
|
}
|
|
37
|
-
async function
|
|
37
|
+
async function D(e, t = !0) {
|
|
38
38
|
let n = this.options.token ? { Authorization: `Bearer ${this.options.token}` } : {};
|
|
39
39
|
if (typeof window < "u" && window.gradio_config && location.origin !== "http://localhost:9876") {
|
|
40
40
|
if (t && window.gradio_config.current_page && (e = e.substring(0, e.lastIndexOf("/"))), window.gradio_config.dev_mode || typeof window < "u" && window?.BUILD_MODE === "dev") {
|
|
41
|
-
let t = new URL(
|
|
41
|
+
let t = new URL(I(e, m));
|
|
42
42
|
this.deep_link && t.searchParams.set("deep_link", this.deep_link), this.page !== null && t.searchParams.set("page", this.page);
|
|
43
|
-
let r = await
|
|
43
|
+
let r = await O(await this.fetch(t, {
|
|
44
44
|
headers: n,
|
|
45
45
|
credentials: this.options.credentials ?? "same-origin"
|
|
46
46
|
}), !!this.options.auth);
|
|
@@ -50,11 +50,11 @@ async function O(e, t = !0) {
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
let r = { ...window.gradio_config };
|
|
53
|
-
return r.root =
|
|
53
|
+
return r.root = ge(r.root, location.href, r.is_colab), r;
|
|
54
54
|
} else if (e) {
|
|
55
|
-
let t = new URL(
|
|
55
|
+
let t = new URL(I(e, m));
|
|
56
56
|
this.deep_link && t.searchParams.set("deep_link", this.deep_link), this.page !== null && t.searchParams.set("page", this.page);
|
|
57
|
-
let r = await
|
|
57
|
+
let r = await O(await this.fetch(t, {
|
|
58
58
|
headers: n,
|
|
59
59
|
credentials: this.options.credentials ?? "same-origin"
|
|
60
60
|
}), !!this.options.auth);
|
|
@@ -62,7 +62,7 @@ async function O(e, t = !0) {
|
|
|
62
62
|
}
|
|
63
63
|
throw Error(y);
|
|
64
64
|
}
|
|
65
|
-
async function
|
|
65
|
+
async function O(e, t) {
|
|
66
66
|
if (e?.status === 401 && !t) {
|
|
67
67
|
let t = null;
|
|
68
68
|
try {
|
|
@@ -81,18 +81,18 @@ async function k(e, t) {
|
|
|
81
81
|
} else if (e?.status === 401) throw Error(S);
|
|
82
82
|
throw Error(`${y}(received status ${e?.status} when fetching the app config)`);
|
|
83
83
|
}
|
|
84
|
-
async function
|
|
85
|
-
let { http_protocol: e, host: t } = await
|
|
84
|
+
async function k() {
|
|
85
|
+
let { http_protocol: e, host: t } = await F(this.app_reference, this.options.token);
|
|
86
86
|
try {
|
|
87
87
|
if (this.options.auth) {
|
|
88
|
-
let n = await
|
|
88
|
+
let n = await A(e, t, this.options.auth, this.fetch, this.options.token, this.options.credentials);
|
|
89
89
|
n && this.set_cookies(n);
|
|
90
90
|
}
|
|
91
91
|
} catch (e) {
|
|
92
92
|
throw Error(e.message);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
async function
|
|
95
|
+
async function A(e, t, n, r, i, a) {
|
|
96
96
|
let o = new FormData();
|
|
97
97
|
o.append("username", n?.[0]), o.append("password", n?.[1]);
|
|
98
98
|
let s = {};
|
|
@@ -106,7 +106,7 @@ async function j(e, t, n, r, i, a) {
|
|
|
106
106
|
if (c.status === 200) return c.headers.get("set-cookie");
|
|
107
107
|
throw c.status === 401 ? Error(C) : Error(x);
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function j(e) {
|
|
110
110
|
if (e.startsWith("http")) {
|
|
111
111
|
let { protocol: t, host: n, pathname: r } = new URL(e);
|
|
112
112
|
return {
|
|
@@ -121,18 +121,18 @@ function M(e) {
|
|
|
121
121
|
host: new URL(e).host
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
-
var
|
|
124
|
+
var M = (e) => {
|
|
125
125
|
let t = [];
|
|
126
126
|
return e.split(/,(?=\s*[^\s=;]+=[^\s=;]+)/).forEach((e) => {
|
|
127
127
|
let [n, r] = e.split(";")[0].split("=");
|
|
128
128
|
n && r && t.push(`${n.trim()}=${r.trim()}`);
|
|
129
129
|
}), t;
|
|
130
|
-
},
|
|
131
|
-
async function
|
|
130
|
+
}, N = /^[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_\-\.]+$/, P = /.*hf\.space\/{0,1}.*$/;
|
|
131
|
+
async function F(e, t) {
|
|
132
132
|
let n = {};
|
|
133
133
|
t && (n.Authorization = `Bearer ${t}`);
|
|
134
134
|
let r = e.trim().replace(/\/$/, "");
|
|
135
|
-
if (
|
|
135
|
+
if (N.test(r)) {
|
|
136
136
|
let e;
|
|
137
137
|
try {
|
|
138
138
|
e = await fetch(`https://huggingface.co/api/spaces/${r}/${l}`, { headers: n });
|
|
@@ -149,11 +149,11 @@ async function I(e, t) {
|
|
|
149
149
|
if (!t) throw Error(x);
|
|
150
150
|
return {
|
|
151
151
|
space_id: r,
|
|
152
|
-
...
|
|
152
|
+
...j(t)
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
|
-
if (
|
|
156
|
-
let { ws_protocol: e, http_protocol: t, host: n } =
|
|
155
|
+
if (P.test(r)) {
|
|
156
|
+
let { ws_protocol: e, http_protocol: t, host: n } = j(r);
|
|
157
157
|
return {
|
|
158
158
|
space_id: n.split("/")[0].replace(".hf.space", ""),
|
|
159
159
|
ws_protocol: e,
|
|
@@ -163,17 +163,17 @@ async function I(e, t) {
|
|
|
163
163
|
}
|
|
164
164
|
return {
|
|
165
165
|
space_id: !1,
|
|
166
|
-
...
|
|
166
|
+
...j(r)
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
|
-
var
|
|
169
|
+
var I = (...e) => {
|
|
170
170
|
try {
|
|
171
171
|
return e.reduce((e, t) => (e = e.replace(/\/+$/, ""), t = t.replace(/^\/+/, ""), new URL(t, e + "/").toString()));
|
|
172
172
|
} catch {
|
|
173
173
|
throw Error(se);
|
|
174
174
|
}
|
|
175
175
|
};
|
|
176
|
-
function
|
|
176
|
+
function _e(e, t, n) {
|
|
177
177
|
let r = {
|
|
178
178
|
named_endpoints: {},
|
|
179
179
|
unnamed_endpoints: {}
|
|
@@ -203,8 +203,8 @@ function ge(e, t, n) {
|
|
|
203
203
|
}
|
|
204
204
|
let d = (e, t, n, r) => ({
|
|
205
205
|
...e,
|
|
206
|
-
description:
|
|
207
|
-
type:
|
|
206
|
+
description: ve(e?.type, n),
|
|
207
|
+
type: L(e?.type, t, n, r) || ""
|
|
208
208
|
});
|
|
209
209
|
r[i][e] = {
|
|
210
210
|
parameters: o.map((e) => d(e, e?.component, e?.serializer, "parameter")),
|
|
@@ -215,7 +215,7 @@ function ge(e, t, n) {
|
|
|
215
215
|
}));
|
|
216
216
|
}), r;
|
|
217
217
|
}
|
|
218
|
-
function
|
|
218
|
+
function L(e, t, n, r) {
|
|
219
219
|
if (t === "Api") return e.type;
|
|
220
220
|
switch (e?.type) {
|
|
221
221
|
case "string": return "string";
|
|
@@ -228,10 +228,10 @@ function R(e, t, n, r) {
|
|
|
228
228
|
if (n === "FileSerializable") return e?.type === "array" ? r === "parameter" ? "(Blob | File | Buffer)[]" : "{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}[]" : r === "parameter" ? "Blob | File | Buffer" : "{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}";
|
|
229
229
|
if (n === "GallerySerializable") return r === "parameter" ? "[(Blob | File | Buffer), (string | null)][]" : "[{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}, (string | null))][]";
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function ve(e, t) {
|
|
232
232
|
return t === "GallerySerializable" ? "array of [file, label] tuples" : t === "ListStringSerializable" ? "array of strings" : t === "FileSerializable" ? "array of files or single file" : e?.description;
|
|
233
233
|
}
|
|
234
|
-
function
|
|
234
|
+
function ye(e, t) {
|
|
235
235
|
switch (e.msg) {
|
|
236
236
|
case "send_data": return { type: "data" };
|
|
237
237
|
case "send_hash": return { type: "hash" };
|
|
@@ -367,7 +367,7 @@ function ve(e, t) {
|
|
|
367
367
|
}
|
|
368
368
|
};
|
|
369
369
|
}
|
|
370
|
-
var
|
|
370
|
+
var be = (e = [], t) => {
|
|
371
371
|
let n = t ? t.parameters : [];
|
|
372
372
|
if (Array.isArray(e)) return t && n.length > 0 && e.length > n.length && console.warn("Too many arguments provided for the endpoint."), e;
|
|
373
373
|
let r = [], i = Object.keys(e);
|
|
@@ -383,28 +383,28 @@ var ye = (e = [], t) => {
|
|
|
383
383
|
};
|
|
384
384
|
//#endregion
|
|
385
385
|
//#region src/utils/view_api.ts
|
|
386
|
-
async function
|
|
386
|
+
async function xe() {
|
|
387
387
|
if (this.api_info) return this.api_info;
|
|
388
388
|
let { token: e } = this.options, { config: t } = this, n = {};
|
|
389
389
|
if (e && (n.Authorization = `Bearer ${e}`), t) try {
|
|
390
390
|
let e, r;
|
|
391
391
|
if (typeof window < "u" && window.gradio_api_info) r = window.gradio_api_info;
|
|
392
392
|
else {
|
|
393
|
-
let i = new URL(
|
|
393
|
+
let i = new URL(I(t.root, this.api_prefix, ee));
|
|
394
394
|
if (this.page !== null && i.searchParams.set("page", this.page), e = await this.fetch(i, {
|
|
395
395
|
headers: n,
|
|
396
396
|
credentials: this.options.credentials ?? "same-origin"
|
|
397
397
|
}), !e.ok) throw Error(v);
|
|
398
398
|
r = await e.json();
|
|
399
399
|
}
|
|
400
|
-
return "api" in r && (r = r.api), r.named_endpoints["/predict"] && !r.unnamed_endpoints[0] && (r.unnamed_endpoints[0] = r.named_endpoints["/predict"]),
|
|
400
|
+
return "api" in r && (r = r.api), r.named_endpoints["/predict"] && !r.unnamed_endpoints[0] && (r.unnamed_endpoints[0] = r.named_endpoints["/predict"]), _e(r, t, this.api_map);
|
|
401
401
|
} catch (e) {
|
|
402
402
|
throw Error("Could not get API info. " + e.message);
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
405
|
//#endregion
|
|
406
406
|
//#region src/utils/upload_files.ts
|
|
407
|
-
async function
|
|
407
|
+
async function Se(e, t, n) {
|
|
408
408
|
let r = {};
|
|
409
409
|
this?.options?.token && (r.Authorization = `Bearer ${this.options.token}`);
|
|
410
410
|
let i = 1e3, a = [], o;
|
|
@@ -433,7 +433,7 @@ async function xe(e, t, n) {
|
|
|
433
433
|
}
|
|
434
434
|
return { files: a };
|
|
435
435
|
}
|
|
436
|
-
var
|
|
436
|
+
var R = {
|
|
437
437
|
si: {
|
|
438
438
|
radix: 1e3,
|
|
439
439
|
unit: [
|
|
@@ -479,7 +479,7 @@ var Se = {
|
|
|
479
479
|
};
|
|
480
480
|
function Ce(e, t = 1, n = "jedec") {
|
|
481
481
|
e = Math.abs(e);
|
|
482
|
-
let { radix: r, unit: i } =
|
|
482
|
+
let { radix: r, unit: i } = R[n] || R.jedec, a = 0;
|
|
483
483
|
for (; e >= r;) e /= r, ++a;
|
|
484
484
|
return `${e.toFixed(t)} ${i[a]}`;
|
|
485
485
|
}
|
|
@@ -830,7 +830,7 @@ async function G(e, t, n) {
|
|
|
830
830
|
var ze = async (e, t) => {
|
|
831
831
|
let n = 0;
|
|
832
832
|
return new Promise((r) => {
|
|
833
|
-
G(e,
|
|
833
|
+
G(e, N.test(e) ? "space_name" : "subdomain", (i) => {
|
|
834
834
|
t(i), i.status === "running" || i.status === "error" || i.status === "paused" || i.status === "space_error" ? r() : (i.status === "sleeping" || i.status === "building") && (n < 12 ? (n++, setTimeout(() => {
|
|
835
835
|
ze(e, t).then(r);
|
|
836
836
|
}, 5e3)) : r());
|
|
@@ -862,7 +862,7 @@ async function Ue(e, t, n) {
|
|
|
862
862
|
n && (r.Authorization = `Bearer ${n}`);
|
|
863
863
|
let i = { seconds: t };
|
|
864
864
|
try {
|
|
865
|
-
let t = await fetch(`https://huggingface.co/api/spaces/${e}/${
|
|
865
|
+
let t = await fetch(`https://huggingface.co/api/spaces/${e}/${g}`, {
|
|
866
866
|
method: "POST",
|
|
867
867
|
headers: {
|
|
868
868
|
"Content-Type": "application/json",
|
|
@@ -894,13 +894,13 @@ var We = [
|
|
|
894
894
|
//#endregion
|
|
895
895
|
//#region src/utils/duplicate.ts
|
|
896
896
|
async function Ge(e, t) {
|
|
897
|
-
|
|
897
|
+
he(t);
|
|
898
898
|
let { token: n, private: r, hardware: i, timeout: a, auth: o } = t;
|
|
899
899
|
if (i && !We.includes(i)) throw Error(`Invalid hardware type provided. Valid types are: ${We.map((e) => `"${e}"`).join(",")}.`);
|
|
900
|
-
let { http_protocol: s, host: c } = await
|
|
900
|
+
let { http_protocol: s, host: c } = await F(e, n), l = null;
|
|
901
901
|
if (o) {
|
|
902
|
-
let e = await
|
|
903
|
-
e && (l =
|
|
902
|
+
let e = await A(s, c, o, fetch, void 0, t.credentials);
|
|
903
|
+
e && (l = M(e));
|
|
904
904
|
}
|
|
905
905
|
let u = {
|
|
906
906
|
Authorization: `Bearer ${n}`,
|
|
@@ -1390,10 +1390,10 @@ function Xt(e) {
|
|
|
1390
1390
|
//#region src/utils/submit.ts
|
|
1391
1391
|
function Zt(e, t = {}, n, r, i, a) {
|
|
1392
1392
|
try {
|
|
1393
|
-
let { token: o } = this.options, { fetch: s, app_reference: c, config: l, session_hash: f, api_info: p, api_map: m, stream_status: ee, pending_stream_messages: h, pending_diff_streams:
|
|
1393
|
+
let { token: o } = this.options, { fetch: s, app_reference: c, config: l, session_hash: f, api_info: p, api_map: m, stream_status: ee, pending_stream_messages: h, pending_diff_streams: g, event_callbacks: _, unclosed_events: te, post_data: ie, options: y, api_prefix: b } = this, oe = a || { "x-gradio-user": "api" }, x = this;
|
|
1394
1394
|
if (!p) throw Error(le);
|
|
1395
1395
|
if (!l) throw Error("Could not resolve app config");
|
|
1396
|
-
let se = l.root, { fn_index: S, endpoint_info: C, dependency: w } = $t(p, e, m, l), ce =
|
|
1396
|
+
let se = l.root, { fn_index: S, endpoint_info: C, dependency: w } = $t(p, e, m, l), ce = be(t, C), T = l.protocol ?? "ws";
|
|
1397
1397
|
if (T === "ws") throw Error(ue);
|
|
1398
1398
|
let de = typeof w.api_name == "string" ? `/${w.api_name}` : e, fe = typeof w.api_name == "string" ? `/${w.api_name}` : `Function ${S}`, pe = (e) => {
|
|
1399
1399
|
let t = l.components.find((t) => t.id === e);
|
|
@@ -1402,38 +1402,38 @@ function Zt(e, t = {}, n, r, i, a) {
|
|
|
1402
1402
|
component_class_id: t.component_class_id,
|
|
1403
1403
|
props: t.props
|
|
1404
1404
|
} : null;
|
|
1405
|
-
}, me = w.api_visibility === "public",
|
|
1405
|
+
}, me = w.api_visibility === "public", he = l.run_history !== !1 && this.options.record_history !== !1, E = {
|
|
1406
1406
|
app_id: l.app_id,
|
|
1407
1407
|
username: l.username
|
|
1408
|
-
},
|
|
1408
|
+
}, ge = Bt(E), D = {
|
|
1409
1409
|
...oe,
|
|
1410
|
-
...
|
|
1411
|
-
},
|
|
1412
|
-
...
|
|
1410
|
+
...he && ge.type === "bucket" ? { "x-gradio-history-bucket": ge.bucket_id } : {}
|
|
1411
|
+
}, O = !he || !me ? null : qt({
|
|
1412
|
+
...E,
|
|
1413
1413
|
endpoint: de,
|
|
1414
1414
|
api_name: fe,
|
|
1415
1415
|
fn_index: S,
|
|
1416
1416
|
inputs: W(ce, w, l.components, "input", !0),
|
|
1417
1417
|
input_components: w.inputs.map(pe),
|
|
1418
1418
|
output_components: w.outputs.map(pe)
|
|
1419
|
-
}),
|
|
1420
|
-
function
|
|
1421
|
-
Yt(
|
|
1419
|
+
}), k, A = "", j = typeof e == "number" ? "/predict" : e, M, N = null, P = !1, F = {}, I = typeof window < "u" && typeof document < "u" ? new URLSearchParams(window.location.search).toString() : "", _e = y?.events?.reduce((e, t) => (e[t] = !0, e), {}) || {};
|
|
1420
|
+
function L(e) {
|
|
1421
|
+
Yt(E, O, e), (e.type === "data" || e.type === "render") && Ae(e.data, se, b, x.jwt), (i || _e[e.type]) && Te(e);
|
|
1422
1422
|
}
|
|
1423
|
-
async function
|
|
1423
|
+
async function ve() {
|
|
1424
1424
|
let e = {}, t = {};
|
|
1425
|
-
e = { event_id:
|
|
1426
|
-
event_id:
|
|
1425
|
+
e = { event_id: N }, t = {
|
|
1426
|
+
event_id: N,
|
|
1427
1427
|
session_hash: f,
|
|
1428
1428
|
fn_index: S
|
|
1429
1429
|
};
|
|
1430
1430
|
try {
|
|
1431
1431
|
if (!l) throw Error("Could not resolve app config");
|
|
1432
|
-
"event_id" in t && await s(`${l.root}${b}/${
|
|
1432
|
+
"event_id" in t && await s(`${l.root}${b}/${re}`, {
|
|
1433
1433
|
headers: { "Content-Type": "application/json" },
|
|
1434
1434
|
method: "POST",
|
|
1435
1435
|
body: JSON.stringify(t)
|
|
1436
|
-
}), await s(`${l.root}${b}/${
|
|
1436
|
+
}), await s(`${l.root}${b}/${ne}`, {
|
|
1437
1437
|
headers: { "Content-Type": "application/json" },
|
|
1438
1438
|
method: "POST",
|
|
1439
1439
|
body: JSON.stringify(e)
|
|
@@ -1442,52 +1442,52 @@ function Zt(e, t = {}, n, r, i, a) {
|
|
|
1442
1442
|
console.warn("The `/reset` endpoint could not be called. Subsequent endpoint results may be unreliable.");
|
|
1443
1443
|
}
|
|
1444
1444
|
}
|
|
1445
|
-
let
|
|
1445
|
+
let xe = async (e) => {
|
|
1446
1446
|
await this._resolve_heartbeat(e);
|
|
1447
1447
|
};
|
|
1448
|
-
async function
|
|
1448
|
+
async function Se(e) {
|
|
1449
1449
|
if (!l) return;
|
|
1450
1450
|
let t = e.render_id;
|
|
1451
1451
|
l.components = [...l.components.filter((e) => e.props.rendered_in !== t), ...e.components], l.dependencies = [...l.dependencies.filter((e) => e.rendered_in !== t), ...e.dependencies];
|
|
1452
1452
|
let n = l.components.some((e) => e.type === "state"), r = l.dependencies.some((e) => e.targets.some((e) => e[1] === "unload"));
|
|
1453
|
-
l.connect_heartbeat = n || r, await
|
|
1453
|
+
l.connect_heartbeat = n || r, await xe(l), L({
|
|
1454
1454
|
type: "render",
|
|
1455
1455
|
data: e,
|
|
1456
|
-
endpoint:
|
|
1456
|
+
endpoint: j,
|
|
1457
1457
|
fn_index: S
|
|
1458
1458
|
});
|
|
1459
1459
|
}
|
|
1460
|
-
let
|
|
1460
|
+
let R = this.handle_blob(l.root, ce, C).then(async (e) => {
|
|
1461
1461
|
let t = W(e, w, l.components, "input", !0);
|
|
1462
|
-
if (Jt(
|
|
1462
|
+
if (Jt(E, O, t || []), M = {
|
|
1463
1463
|
data: t || [],
|
|
1464
1464
|
event_data: n,
|
|
1465
1465
|
fn_index: S,
|
|
1466
1466
|
trigger_id: r,
|
|
1467
1467
|
...y.oauth_token && C?.oauth_token ? { oauth_token: y.oauth_token } : {}
|
|
1468
|
-
}, Ee(S, l))
|
|
1468
|
+
}, Ee(S, l)) L({
|
|
1469
1469
|
type: "status",
|
|
1470
|
-
endpoint:
|
|
1470
|
+
endpoint: j,
|
|
1471
1471
|
stage: "pending",
|
|
1472
1472
|
queue: !1,
|
|
1473
1473
|
fn_index: S,
|
|
1474
1474
|
time: /* @__PURE__ */ new Date()
|
|
1475
|
-
}),
|
|
1476
|
-
...
|
|
1475
|
+
}), ie(`${l.root}${b}/run${j.startsWith("/") ? j : `/${j}`}${I ? "?" + I : ""}`, {
|
|
1476
|
+
...M,
|
|
1477
1477
|
session_hash: f
|
|
1478
|
-
},
|
|
1478
|
+
}, D).then(async ([e, t]) => {
|
|
1479
1479
|
let i = e.data;
|
|
1480
|
-
if (t == 200)
|
|
1480
|
+
if (t == 200) L({
|
|
1481
1481
|
type: "data",
|
|
1482
|
-
endpoint:
|
|
1482
|
+
endpoint: j,
|
|
1483
1483
|
fn_index: S,
|
|
1484
1484
|
data: W(i, w, l.components, "output", y.with_null_state),
|
|
1485
1485
|
time: /* @__PURE__ */ new Date(),
|
|
1486
1486
|
event_data: n,
|
|
1487
1487
|
trigger_id: r
|
|
1488
|
-
}), e.render_config && await
|
|
1488
|
+
}), e.render_config && await Se(e.render_config), L({
|
|
1489
1489
|
type: "status",
|
|
1490
|
-
endpoint:
|
|
1490
|
+
endpoint: j,
|
|
1491
1491
|
fn_index: S,
|
|
1492
1492
|
stage: "complete",
|
|
1493
1493
|
eta: e.average_duration,
|
|
@@ -1496,10 +1496,10 @@ function Zt(e, t = {}, n, r, i, a) {
|
|
|
1496
1496
|
});
|
|
1497
1497
|
else {
|
|
1498
1498
|
let t = e?.error === v;
|
|
1499
|
-
|
|
1499
|
+
L({
|
|
1500
1500
|
type: "status",
|
|
1501
1501
|
stage: "error",
|
|
1502
|
-
endpoint:
|
|
1502
|
+
endpoint: j,
|
|
1503
1503
|
fn_index: S,
|
|
1504
1504
|
message: e.error,
|
|
1505
1505
|
broken: t,
|
|
@@ -1508,22 +1508,22 @@ function Zt(e, t = {}, n, r, i, a) {
|
|
|
1508
1508
|
});
|
|
1509
1509
|
}
|
|
1510
1510
|
}).catch((e) => {
|
|
1511
|
-
|
|
1511
|
+
L({
|
|
1512
1512
|
type: "status",
|
|
1513
1513
|
stage: "error",
|
|
1514
1514
|
message: e.message,
|
|
1515
|
-
endpoint:
|
|
1515
|
+
endpoint: j,
|
|
1516
1516
|
fn_index: S,
|
|
1517
1517
|
queue: !1,
|
|
1518
1518
|
time: /* @__PURE__ */ new Date()
|
|
1519
1519
|
});
|
|
1520
1520
|
});
|
|
1521
1521
|
else if (T == "sse") {
|
|
1522
|
-
|
|
1522
|
+
L({
|
|
1523
1523
|
type: "status",
|
|
1524
1524
|
stage: "pending",
|
|
1525
1525
|
queue: !0,
|
|
1526
|
-
endpoint:
|
|
1526
|
+
endpoint: j,
|
|
1527
1527
|
fn_index: S,
|
|
1528
1528
|
time: /* @__PURE__ */ new Date()
|
|
1529
1529
|
});
|
|
@@ -1531,74 +1531,74 @@ function Zt(e, t = {}, n, r, i, a) {
|
|
|
1531
1531
|
fn_index: S.toString(),
|
|
1532
1532
|
session_hash: f
|
|
1533
1533
|
}).toString();
|
|
1534
|
-
let e = new URL(`${l.root}${b}/${u}?${
|
|
1535
|
-
if (this.jwt && e.searchParams.set("__sign", this.jwt),
|
|
1536
|
-
|
|
1537
|
-
let { type: t, status: i, data: a } =
|
|
1538
|
-
if (t === "update" && i && !
|
|
1534
|
+
let e = new URL(`${l.root}${b}/${u}?${I ? I + "&" : ""}${i}`);
|
|
1535
|
+
if (this.jwt && e.searchParams.set("__sign", this.jwt), k = this.stream(e), !k) return Promise.reject(/* @__PURE__ */ Error("Cannot connect to SSE endpoint: " + e.toString()));
|
|
1536
|
+
k.onmessage = async function(e) {
|
|
1537
|
+
let { type: t, status: i, data: a } = ye(JSON.parse(e.data), F[S]);
|
|
1538
|
+
if (t === "update" && i && !P) L({
|
|
1539
1539
|
type: "status",
|
|
1540
|
-
endpoint:
|
|
1540
|
+
endpoint: j,
|
|
1541
1541
|
fn_index: S,
|
|
1542
1542
|
time: /* @__PURE__ */ new Date(),
|
|
1543
1543
|
...i
|
|
1544
|
-
}), i.stage === "error" && (
|
|
1544
|
+
}), i.stage === "error" && (k?.close(), V());
|
|
1545
1545
|
else if (t === "data") {
|
|
1546
|
-
let [e, t] = await
|
|
1547
|
-
...
|
|
1546
|
+
let [e, t] = await ie(`${l.root}${b}/queue/data`, {
|
|
1547
|
+
...M,
|
|
1548
1548
|
session_hash: f,
|
|
1549
|
-
event_id:
|
|
1550
|
-
},
|
|
1551
|
-
t !== 200 && (
|
|
1549
|
+
event_id: N
|
|
1550
|
+
}, D);
|
|
1551
|
+
t !== 200 && (L({
|
|
1552
1552
|
type: "status",
|
|
1553
1553
|
stage: "error",
|
|
1554
1554
|
message: v,
|
|
1555
1555
|
queue: !0,
|
|
1556
|
-
endpoint:
|
|
1556
|
+
endpoint: j,
|
|
1557
1557
|
fn_index: S,
|
|
1558
1558
|
time: /* @__PURE__ */ new Date()
|
|
1559
|
-
}),
|
|
1560
|
-
} else t === "complete" ?
|
|
1559
|
+
}), k?.close(), V());
|
|
1560
|
+
} else t === "complete" ? P = i : t === "log" ? L({
|
|
1561
1561
|
type: "log",
|
|
1562
1562
|
title: a.title,
|
|
1563
1563
|
log: a.log,
|
|
1564
1564
|
level: a.level,
|
|
1565
|
-
endpoint:
|
|
1565
|
+
endpoint: j,
|
|
1566
1566
|
duration: a.duration,
|
|
1567
1567
|
visible: a.visible,
|
|
1568
1568
|
fn_index: S
|
|
1569
|
-
}) : (t === "generating" || t === "streaming") &&
|
|
1569
|
+
}) : (t === "generating" || t === "streaming") && L({
|
|
1570
1570
|
type: "status",
|
|
1571
1571
|
time: /* @__PURE__ */ new Date(),
|
|
1572
1572
|
...i,
|
|
1573
1573
|
stage: i?.stage,
|
|
1574
1574
|
queue: !0,
|
|
1575
|
-
endpoint:
|
|
1575
|
+
endpoint: j,
|
|
1576
1576
|
fn_index: S
|
|
1577
1577
|
});
|
|
1578
|
-
a && (
|
|
1578
|
+
a && (L({
|
|
1579
1579
|
type: "data",
|
|
1580
1580
|
time: /* @__PURE__ */ new Date(),
|
|
1581
1581
|
data: W(a.data, w, l.components, "output", y.with_null_state),
|
|
1582
|
-
endpoint:
|
|
1582
|
+
endpoint: j,
|
|
1583
1583
|
fn_index: S,
|
|
1584
1584
|
event_data: n,
|
|
1585
1585
|
trigger_id: r
|
|
1586
|
-
}),
|
|
1586
|
+
}), P && (L({
|
|
1587
1587
|
type: "status",
|
|
1588
1588
|
time: /* @__PURE__ */ new Date(),
|
|
1589
|
-
...
|
|
1589
|
+
...P,
|
|
1590
1590
|
stage: i?.stage,
|
|
1591
1591
|
queue: !0,
|
|
1592
|
-
endpoint:
|
|
1592
|
+
endpoint: j,
|
|
1593
1593
|
fn_index: S
|
|
1594
|
-
}),
|
|
1594
|
+
}), k?.close(), V()));
|
|
1595
1595
|
};
|
|
1596
1596
|
} else if (T == "sse_v1" || T == "sse_v2" || T == "sse_v2.1" || T == "sse_v3") {
|
|
1597
|
-
|
|
1597
|
+
L({
|
|
1598
1598
|
type: "status",
|
|
1599
1599
|
stage: "pending",
|
|
1600
1600
|
queue: !0,
|
|
1601
|
-
endpoint:
|
|
1601
|
+
endpoint: j,
|
|
1602
1602
|
fn_index: S,
|
|
1603
1603
|
time: /* @__PURE__ */ new Date()
|
|
1604
1604
|
});
|
|
@@ -1607,30 +1607,30 @@ function Zt(e, t = {}, n, r, i, a) {
|
|
|
1607
1607
|
let t = Xe(e);
|
|
1608
1608
|
return (typeof window < "u" && typeof document < "u" && window.parent != window && t && window.supports_zerogpu_headers ? De("zerogpu-headers", t) : Promise.resolve(null)).then((e) => {
|
|
1609
1609
|
let t = {
|
|
1610
|
-
...
|
|
1610
|
+
...D,
|
|
1611
1611
|
...e || {}
|
|
1612
1612
|
};
|
|
1613
|
-
return
|
|
1614
|
-
...
|
|
1613
|
+
return ie(`${l.root}${b}/${d}?${I}`, {
|
|
1614
|
+
...M,
|
|
1615
1615
|
session_hash: f
|
|
1616
1616
|
}, t);
|
|
1617
1617
|
}).then(async ([e, t]) => {
|
|
1618
|
-
if (e.event_id && (
|
|
1618
|
+
if (e.event_id && (A = e.event_id), t === 503) L({
|
|
1619
1619
|
type: "status",
|
|
1620
1620
|
stage: "error",
|
|
1621
1621
|
message: ae,
|
|
1622
1622
|
queue: !0,
|
|
1623
|
-
endpoint:
|
|
1623
|
+
endpoint: j,
|
|
1624
1624
|
fn_index: S,
|
|
1625
1625
|
time: /* @__PURE__ */ new Date(),
|
|
1626
1626
|
visible: !0
|
|
1627
1627
|
}), V();
|
|
1628
|
-
else if (t === 422)
|
|
1628
|
+
else if (t === 422) L({
|
|
1629
1629
|
type: "status",
|
|
1630
1630
|
stage: "error",
|
|
1631
1631
|
message: e.detail,
|
|
1632
1632
|
queue: !0,
|
|
1633
|
-
endpoint:
|
|
1633
|
+
endpoint: j,
|
|
1634
1634
|
fn_index: S,
|
|
1635
1635
|
code: "validation_error",
|
|
1636
1636
|
time: /* @__PURE__ */ new Date(),
|
|
@@ -1638,93 +1638,93 @@ function Zt(e, t = {}, n, r, i, a) {
|
|
|
1638
1638
|
}), V();
|
|
1639
1639
|
else if (t !== 200) {
|
|
1640
1640
|
let t = e?.error === v;
|
|
1641
|
-
|
|
1641
|
+
L({
|
|
1642
1642
|
type: "status",
|
|
1643
1643
|
stage: "error",
|
|
1644
1644
|
broken: t,
|
|
1645
1645
|
message: t ? v : e.detail || e.error,
|
|
1646
1646
|
queue: !0,
|
|
1647
|
-
endpoint:
|
|
1647
|
+
endpoint: j,
|
|
1648
1648
|
fn_index: S,
|
|
1649
1649
|
time: /* @__PURE__ */ new Date(),
|
|
1650
1650
|
visible: !0
|
|
1651
1651
|
}), V();
|
|
1652
1652
|
} else {
|
|
1653
|
-
|
|
1653
|
+
N = e.event_id, A = N;
|
|
1654
1654
|
let t = async function(e) {
|
|
1655
1655
|
try {
|
|
1656
|
-
let { type: t, status: n, data: r, original_msg: i } =
|
|
1656
|
+
let { type: t, status: n, data: r, original_msg: i } = ye(e, F[S]);
|
|
1657
1657
|
if (t == "heartbeat") return;
|
|
1658
|
-
if (t === "update" && n && !
|
|
1658
|
+
if (t === "update" && n && !P) L({
|
|
1659
1659
|
type: "status",
|
|
1660
|
-
endpoint:
|
|
1660
|
+
endpoint: j,
|
|
1661
1661
|
fn_index: S,
|
|
1662
1662
|
time: /* @__PURE__ */ new Date(),
|
|
1663
1663
|
original_msg: i,
|
|
1664
1664
|
...n
|
|
1665
1665
|
});
|
|
1666
|
-
else if (t === "complete")
|
|
1666
|
+
else if (t === "complete") P = n;
|
|
1667
1667
|
else if (t == "unexpected_error" || t == "broken_connection") {
|
|
1668
1668
|
console.error("Unexpected error", n?.message);
|
|
1669
1669
|
let e = t === "broken_connection";
|
|
1670
|
-
|
|
1670
|
+
L({
|
|
1671
1671
|
type: "status",
|
|
1672
1672
|
stage: "error",
|
|
1673
1673
|
message: n?.message || "An Unexpected Error Occurred!",
|
|
1674
1674
|
queue: !0,
|
|
1675
|
-
endpoint:
|
|
1675
|
+
endpoint: j,
|
|
1676
1676
|
broken: e,
|
|
1677
1677
|
session_not_found: n?.session_not_found,
|
|
1678
1678
|
fn_index: S,
|
|
1679
1679
|
time: /* @__PURE__ */ new Date()
|
|
1680
1680
|
});
|
|
1681
1681
|
} else if (t === "log") {
|
|
1682
|
-
|
|
1682
|
+
L({
|
|
1683
1683
|
type: "log",
|
|
1684
1684
|
title: r.title,
|
|
1685
1685
|
log: r.log,
|
|
1686
1686
|
level: r.level,
|
|
1687
|
-
endpoint:
|
|
1687
|
+
endpoint: j,
|
|
1688
1688
|
duration: r.duration,
|
|
1689
1689
|
visible: r.visible,
|
|
1690
1690
|
fn_index: S
|
|
1691
1691
|
});
|
|
1692
1692
|
return;
|
|
1693
|
-
} else (t === "generating" || t === "streaming") && (
|
|
1693
|
+
} else (t === "generating" || t === "streaming") && (L({
|
|
1694
1694
|
type: "status",
|
|
1695
1695
|
time: /* @__PURE__ */ new Date(),
|
|
1696
1696
|
...n,
|
|
1697
1697
|
stage: n?.stage,
|
|
1698
1698
|
queue: !0,
|
|
1699
|
-
endpoint:
|
|
1699
|
+
endpoint: j,
|
|
1700
1700
|
fn_index: S
|
|
1701
1701
|
}), r && w.connection !== "stream" && [
|
|
1702
1702
|
"sse_v2",
|
|
1703
1703
|
"sse_v2.1",
|
|
1704
1704
|
"sse_v3"
|
|
1705
|
-
].includes(T) && ot(
|
|
1706
|
-
r && (
|
|
1705
|
+
].includes(T) && ot(g, N, r));
|
|
1706
|
+
r && (L({
|
|
1707
1707
|
type: "data",
|
|
1708
1708
|
time: /* @__PURE__ */ new Date(),
|
|
1709
1709
|
data: W(r.data, w, l.components, "output", y.with_null_state),
|
|
1710
|
-
endpoint:
|
|
1710
|
+
endpoint: j,
|
|
1711
1711
|
fn_index: S
|
|
1712
|
-
}), r.render_config && await
|
|
1712
|
+
}), r.render_config && await Se(r.render_config), P && (L({
|
|
1713
1713
|
type: "status",
|
|
1714
1714
|
time: /* @__PURE__ */ new Date(),
|
|
1715
|
-
...
|
|
1715
|
+
...P,
|
|
1716
1716
|
stage: n?.stage,
|
|
1717
1717
|
queue: !0,
|
|
1718
|
-
endpoint:
|
|
1718
|
+
endpoint: j,
|
|
1719
1719
|
fn_index: S
|
|
1720
|
-
}), V())), (n?.stage === "complete" || n?.stage === "error") && (
|
|
1720
|
+
}), V())), (n?.stage === "complete" || n?.stage === "error") && (_[N] && delete _[N], N in g && delete g[N], V());
|
|
1721
1721
|
} catch (e) {
|
|
1722
|
-
console.error("Unexpected client exception", e),
|
|
1722
|
+
console.error("Unexpected client exception", e), L({
|
|
1723
1723
|
type: "status",
|
|
1724
1724
|
stage: "error",
|
|
1725
1725
|
message: "An Unexpected Error Occurred!",
|
|
1726
1726
|
queue: !0,
|
|
1727
|
-
endpoint:
|
|
1727
|
+
endpoint: j,
|
|
1728
1728
|
fn_index: S,
|
|
1729
1729
|
time: /* @__PURE__ */ new Date()
|
|
1730
1730
|
}), [
|
|
@@ -1734,18 +1734,18 @@ function Zt(e, t = {}, n, r, i, a) {
|
|
|
1734
1734
|
].includes(T) && (at(ee, x.abort_controller), ee.open = !1, V());
|
|
1735
1735
|
}
|
|
1736
1736
|
};
|
|
1737
|
-
|
|
1737
|
+
N in h && (h[N].forEach((e) => t(e)), delete h[N]), _[N] = t, te.add(N), ee.open || await this.open_stream();
|
|
1738
1738
|
}
|
|
1739
1739
|
});
|
|
1740
1740
|
}
|
|
1741
1741
|
});
|
|
1742
|
-
|
|
1743
|
-
|
|
1742
|
+
R.catch((e) => {
|
|
1743
|
+
L({
|
|
1744
1744
|
type: "status",
|
|
1745
1745
|
stage: "error",
|
|
1746
1746
|
message: e instanceof Error ? e.message : String(e),
|
|
1747
1747
|
queue: !Ee(S, l),
|
|
1748
|
-
endpoint:
|
|
1748
|
+
endpoint: j,
|
|
1749
1749
|
fn_index: S,
|
|
1750
1750
|
time: /* @__PURE__ */ new Date()
|
|
1751
1751
|
}), V();
|
|
@@ -1775,28 +1775,32 @@ function Zt(e, t = {}, n, r, i, a) {
|
|
|
1775
1775
|
done: !0
|
|
1776
1776
|
}) : new Promise((e) => B.push(e));
|
|
1777
1777
|
}
|
|
1778
|
-
let Oe = {
|
|
1779
|
-
|
|
1778
|
+
let Oe = (e, t) => {
|
|
1779
|
+
R.then(() => {
|
|
1780
|
+
A && this.post_data(`${l.root}${b}/stream/${A}${e}`, t);
|
|
1781
|
+
}, () => {});
|
|
1782
|
+
}, ke = {
|
|
1783
|
+
[Symbol.asyncIterator]: () => ke,
|
|
1780
1784
|
next: U,
|
|
1781
1785
|
throw: async (e) => (we(e), U()),
|
|
1782
1786
|
return: async () => (V(), {
|
|
1783
1787
|
value: void 0,
|
|
1784
1788
|
done: !0
|
|
1785
1789
|
}),
|
|
1786
|
-
cancel:
|
|
1790
|
+
cancel: ve,
|
|
1787
1791
|
send_chunk: (e) => {
|
|
1788
|
-
|
|
1792
|
+
Oe("", {
|
|
1789
1793
|
...e,
|
|
1790
1794
|
session_hash: this.session_hash
|
|
1791
1795
|
});
|
|
1792
1796
|
},
|
|
1793
1797
|
close_stream: () => {
|
|
1794
|
-
|
|
1798
|
+
V(), Oe("/close", {});
|
|
1795
1799
|
},
|
|
1796
|
-
event_id: () =>
|
|
1797
|
-
wait_for_id: async () => (await
|
|
1800
|
+
event_id: () => A,
|
|
1801
|
+
wait_for_id: async () => (await R, N)
|
|
1798
1802
|
};
|
|
1799
|
-
return
|
|
1803
|
+
return ke;
|
|
1800
1804
|
} catch (e) {
|
|
1801
1805
|
throw console.error("Submit function encountered an error:", e), e;
|
|
1802
1806
|
}
|
|
@@ -1893,7 +1897,7 @@ var $ = class {
|
|
|
1893
1897
|
resolve_config;
|
|
1894
1898
|
resolve_cookies;
|
|
1895
1899
|
constructor(e, t = { events: ["data"] }) {
|
|
1896
|
-
this.app_reference = e, this.deep_link = t.query_params?.deep_link || null, this.page = t.query_params?.page ?? null, t.events ||= ["data"],
|
|
1900
|
+
this.app_reference = e, this.deep_link = t.query_params?.deep_link || null, this.page = t.query_params?.page ?? null, t.events ||= ["data"], he(t), this.options = t, this.current_payload = {}, t.cookies && (this.cookies = t.cookies), this.view_api = xe.bind(this), this.upload_files = Se.bind(this), this.handle_blob = Ne.bind(this), this.post_data = Le.bind(this), this.submit = Zt.bind(this), this.predict = Re.bind(this), this.open_stream = it.bind(this), this.resolve_config = D.bind(this), this.resolve_cookies = k.bind(this), this.upload = z.bind(this), this.fetch = this.fetch.bind(this), this.handle_space_success = this.handle_space_success.bind(this), this.stream = this.stream.bind(this);
|
|
1897
1901
|
}
|
|
1898
1902
|
async init() {
|
|
1899
1903
|
Ze(), this.options.auth && await this.resolve_cookies(), await this._resolve_config().then((e) => e?.config && this._resolve_heartbeat(e.config));
|
|
@@ -1902,11 +1906,11 @@ var $ = class {
|
|
|
1902
1906
|
} catch (e) {
|
|
1903
1907
|
console.error(e.message);
|
|
1904
1908
|
}
|
|
1905
|
-
this.api_map =
|
|
1909
|
+
this.api_map = E(this.config?.dependencies || []);
|
|
1906
1910
|
}
|
|
1907
1911
|
async _resolve_heartbeat(e) {
|
|
1908
1912
|
if (this.config = e, this.api_prefix = e.api_prefix || "", e.space_id && this.options.token && (this.jwt = await me(e.space_id, this.options.token, this.cookies)), je(this.config, this.jwt), this.config && this.config.connect_heartbeat) {
|
|
1909
|
-
let e = new URL(`${this.config.root}${this.api_prefix}/${
|
|
1913
|
+
let e = new URL(`${this.config.root}${this.api_prefix}/${_}/${this.session_hash}`);
|
|
1910
1914
|
this.jwt && e.searchParams.set("__sign", this.jwt), this.heartbeat_event ||= this.stream(e);
|
|
1911
1915
|
}
|
|
1912
1916
|
}
|
|
@@ -1915,7 +1919,7 @@ var $ = class {
|
|
|
1915
1919
|
return t.session_hash && (n.session_hash = t.session_hash), await n.init(), n;
|
|
1916
1920
|
}
|
|
1917
1921
|
async reconnect() {
|
|
1918
|
-
let e = new URL(`${this.config.root}${this.api_prefix}/${
|
|
1922
|
+
let e = new URL(`${this.config.root}${this.api_prefix}/${ie}`), t;
|
|
1919
1923
|
try {
|
|
1920
1924
|
let n = await this.fetch(e);
|
|
1921
1925
|
if (!n.ok) throw Error();
|
|
@@ -1932,7 +1936,7 @@ var $ = class {
|
|
|
1932
1936
|
if (!this.config) throw Error(y);
|
|
1933
1937
|
let e = await this.resolve_config(this.config.root, !1);
|
|
1934
1938
|
if (!e) throw Error(y);
|
|
1935
|
-
this.config = e, this.api_prefix = e.api_prefix || "", this.api_map =
|
|
1939
|
+
this.config = e, this.api_prefix = e.api_prefix || "", this.api_map = E(e.dependencies || []), je(this.config, this.jwt);
|
|
1936
1940
|
try {
|
|
1937
1941
|
this.api_info = await this.view_api();
|
|
1938
1942
|
} catch (e) {
|
|
@@ -1947,7 +1951,7 @@ var $ = class {
|
|
|
1947
1951
|
return Ge(e, t);
|
|
1948
1952
|
}
|
|
1949
1953
|
async _resolve_config() {
|
|
1950
|
-
let { http_protocol: e, host: t, space_id: n } = await
|
|
1954
|
+
let { http_protocol: e, host: t, space_id: n } = await F(this.app_reference, this.options.token), { status_callback: r } = this.options;
|
|
1951
1955
|
n && r && await ze(n, r);
|
|
1952
1956
|
let i;
|
|
1953
1957
|
try {
|
|
@@ -1955,7 +1959,7 @@ var $ = class {
|
|
|
1955
1959
|
if (i = await this.resolve_config(n), !i) throw Error(y);
|
|
1956
1960
|
return this.config_success(i);
|
|
1957
1961
|
} catch (e) {
|
|
1958
|
-
if (n && r) G(n,
|
|
1962
|
+
if (n && r) G(n, N.test(n) ? "space_name" : "subdomain", this.handle_space_success);
|
|
1959
1963
|
else throw r && r({
|
|
1960
1964
|
status: "error",
|
|
1961
1965
|
message: "Could not load this space.",
|
|
@@ -2011,7 +2015,7 @@ var $ = class {
|
|
|
2011
2015
|
}), r["Content-Type"] = "application/json";
|
|
2012
2016
|
i && (r.Authorization = `Bearer ${i}`);
|
|
2013
2017
|
try {
|
|
2014
|
-
let e = await this.fetch(`${o}${this.api_prefix}/${
|
|
2018
|
+
let e = await this.fetch(`${o}${this.api_prefix}/${te}/`, {
|
|
2015
2019
|
method: "POST",
|
|
2016
2020
|
body: c,
|
|
2017
2021
|
headers: r,
|
|
@@ -2025,7 +2029,7 @@ var $ = class {
|
|
|
2025
2029
|
}
|
|
2026
2030
|
}
|
|
2027
2031
|
set_cookies(e) {
|
|
2028
|
-
this.cookies =
|
|
2032
|
+
this.cookies = M(e).join("; ");
|
|
2029
2033
|
}
|
|
2030
2034
|
prepare_return_obj() {
|
|
2031
2035
|
return {
|
|
@@ -2108,4 +2112,4 @@ function dn(e, t, n, r, i) {
|
|
|
2108
2112
|
return an(e, `records/${encodeURIComponent(n)}/${encodeURIComponent(r)}/assets/${encodeURIComponent(i)}`, { bucket: t });
|
|
2109
2113
|
}
|
|
2110
2114
|
//#endregion
|
|
2111
|
-
export { $ as Client, V as FileData, w as MISSING_CREDENTIALS_MSG, Kt as apply_run_history_replay, dn as asset_url, Ht as clear_run_history, en as client, cn as connect_bucket, Gt as consume_run_history_replay, Ut as delete_run_history, tn as duplicate, Oe as handle_file, rn as is_valid_bucket_id, un as list_bucket_records, ln as list_user_buckets, Xt as on_run_history_change, Re as predict, B as prepare_files, zt as read_run_history, Bt as read_run_history_storage, mt as run_history_url, Vt as set_run_history_storage, Wt as stage_run_history_replay, Zt as submit, z as upload,
|
|
2115
|
+
export { $ as Client, V as FileData, w as MISSING_CREDENTIALS_MSG, Kt as apply_run_history_replay, dn as asset_url, Ht as clear_run_history, en as client, cn as connect_bucket, Gt as consume_run_history_replay, Ut as delete_run_history, tn as duplicate, Oe as handle_file, rn as is_valid_bucket_id, un as list_bucket_records, ln as list_user_buckets, Xt as on_run_history_change, Re as predict, B as prepare_files, zt as read_run_history, Bt as read_run_history_storage, mt as run_history_url, Vt as set_run_history_storage, Wt as stage_run_history_replay, Zt as submit, z as upload, Se as upload_files };
|