@gradio/client 2.2.2 → 2.3.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/dist/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- const Ke = "host", xe = "queue/data", Ve = "queue/join", ye = "upload", Ye = "login", K = "config", Qe = "info", Xe = "runtime", et = "sleeptime", tt = "heartbeat", st = "component_server", nt = "reset", ot = "cancel", it = "app_id", De = "This application is currently busy. Please try again. ", L = "Connection errored out. ", C = "Could not resolve app config. ", rt = "Could not get space status. ", at = "Could not get API info. ", ue = "Space metadata could not be loaded. ", ct = "Invalid URL. A full URL path is required.", ut = "Not authorized to access this space. ", Ce = "Invalid credentials. Could not login. ", lt = "Login credentials are required to access this space.", pt = "File system access is only available in Node.js environments", Le = "Root URL not found in client config", dt = "Error uploading file";
1
+ const Ke = "host", xe = "queue/data", Ve = "queue/join", ye = "upload", Ye = "login", K = "config", Qe = "info", Xe = "runtime", et = "sleeptime", tt = "heartbeat", st = "component_server", nt = "reset", it = "cancel", ot = "app_id", De = "This application is currently busy. Please try again. ", N = "Connection errored out. ", L = "Could not resolve app config. ", rt = "Could not get space status. ", at = "Could not get API info. ", ue = "Space metadata could not be loaded. ", ct = "Invalid URL. A full URL path is required.", ut = "Not authorized to access this space. ", Le = "Invalid credentials. Could not login. ", lt = "Login credentials are required to access this space.", pt = "File system access is only available in Node.js environments", Ne = "Root URL not found in client config", dt = "Error uploading file";
2
2
  async function be(e, s, t) {
3
3
  try {
4
4
  return (await (await fetch(`https://huggingface.co/api/spaces/${e}/jwt`, {
@@ -19,7 +19,7 @@ function ht(e) {
19
19
  }
20
20
  async function ft(e) {
21
21
  const s = this.options.token ? { Authorization: `Bearer ${this.options.token}` } : {};
22
- if (s["Content-Type"] = "application/json", typeof window < "u" && window.gradio_config && location.origin !== "http://localhost:9876") {
22
+ if (typeof window < "u" && window.gradio_config && location.origin !== "http://localhost:9876") {
23
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
24
  let t = ae(
25
25
  e,
@@ -27,7 +27,7 @@ async function ft(e) {
27
27
  );
28
28
  const n = await this.fetch(t, {
29
29
  headers: s,
30
- credentials: "include"
30
+ credentials: this.options.credentials ?? "same-origin"
31
31
  }), o = await ve(n, !!this.options.auth);
32
32
  o.root = e || o.root, window.gradio_config = {
33
33
  ...o,
@@ -42,18 +42,18 @@ async function ft(e) {
42
42
  );
43
43
  const n = await this.fetch(t, {
44
44
  headers: s,
45
- credentials: "include"
45
+ credentials: this.options.credentials ?? "same-origin"
46
46
  }), o = await ve(n, !!this.options.auth);
47
47
  return o.root || (o.root = e), o;
48
48
  }
49
- throw new Error(C);
49
+ throw new Error(L);
50
50
  }
51
51
  async function ve(e, s) {
52
52
  if (e?.status === 401 && !s) {
53
53
  const n = (await e.json())?.detail?.auth_message;
54
54
  throw new Error(n || lt);
55
55
  } else if (e?.status === 401 && s)
56
- throw new Error(Ce);
56
+ throw new Error(Le);
57
57
  if (e?.status === 200) {
58
58
  let t = await e.json();
59
59
  return t.dependencies?.forEach((n, o) => {
@@ -61,7 +61,7 @@ async function ve(e, s) {
61
61
  }), t;
62
62
  } else if (e?.status === 401)
63
63
  throw new Error(ut);
64
- throw new Error(C);
64
+ throw new Error(L);
65
65
  }
66
66
  async function _t() {
67
67
  const { http_protocol: e, host: s } = await pe(
@@ -70,12 +70,13 @@ async function _t() {
70
70
  );
71
71
  try {
72
72
  if (this.options.auth) {
73
- const t = await Ne(
73
+ const t = await Ce(
74
74
  e,
75
75
  s,
76
76
  this.options.auth,
77
77
  this.fetch,
78
- this.options.token
78
+ this.options.token,
79
+ this.options.credentials
79
80
  );
80
81
  t && this.set_cookies(t);
81
82
  }
@@ -83,20 +84,20 @@ async function _t() {
83
84
  throw Error(t.message);
84
85
  }
85
86
  }
86
- async function Ne(e, s, t, n, o) {
87
- const r = new FormData();
88
- r.append("username", t?.[0]), r.append("password", t?.[1]);
89
- let i = {};
90
- o && (i.Authorization = `Bearer ${o}`);
91
- const a = await n(`${e}//${s}/${Ye}`, {
92
- headers: i,
87
+ async function Ce(e, s, t, n, o, r) {
88
+ const i = new FormData();
89
+ i.append("username", t?.[0]), i.append("password", t?.[1]);
90
+ let a = {};
91
+ o && (a.Authorization = `Bearer ${o}`);
92
+ const u = await n(`${e}//${s}/${Ye}`, {
93
+ headers: a,
93
94
  method: "POST",
94
- body: r,
95
- credentials: "include"
95
+ body: i,
96
+ credentials: r ?? "same-origin"
96
97
  });
97
- if (a.status === 200)
98
- return a.headers.get("set-cookie");
99
- throw a.status === 401 ? new Error(Ce) : new Error(ue);
98
+ if (u.status === 200)
99
+ return u.headers.get("set-cookie");
100
+ throw u.status === 401 ? new Error(Le) : new Error(ue);
100
101
  }
101
102
  function re(e) {
102
103
  if (e.startsWith("http")) {
@@ -176,7 +177,7 @@ function mt(e, s, t) {
176
177
  try {
177
178
  c.forEach((g, w) => {
178
179
  if (g === "state") {
179
- const N = {
180
+ const C = {
180
181
  component: "state",
181
182
  example: null,
182
183
  parameter_default: null,
@@ -184,17 +185,17 @@ function mt(e, s, t) {
184
185
  parameter_name: null,
185
186
  hidden: !0
186
187
  };
187
- i.splice(w, 0, N);
188
+ i.splice(w, 0, C);
188
189
  }
189
190
  });
190
191
  } catch (g) {
191
192
  console.error(g);
192
193
  }
193
194
  }
194
- const p = (c, g, w, N) => ({
195
+ const p = (c, g, w, C) => ({
195
196
  ...c,
196
197
  description: yt(c?.type, w),
197
- type: wt(c?.type, g, w, N) || ""
198
+ type: wt(c?.type, g, w, C) || ""
198
199
  });
199
200
  n[o][r] = {
200
201
  parameters: i.map(
@@ -325,6 +326,7 @@ function Ee(e, s) {
325
326
  time_limit: e.time_limit,
326
327
  code: e.code,
327
328
  progress_data: e.progress_data,
329
+ changed_state_ids: e.output.changed_state_ids,
328
330
  eta: e.eta
329
331
  },
330
332
  data: e.output
@@ -402,7 +404,7 @@ const bt = (e = [], s) => {
402
404
  };
403
405
  async function vt() {
404
406
  if (this.api_info) return this.api_info;
405
- const { token: e } = this.options, { config: s } = this, t = { "Content-Type": "application/json" };
407
+ const { token: e } = this.options, { config: s } = this, t = {};
406
408
  if (e && (t.Authorization = `Bearer ${e}`), !!s)
407
409
  try {
408
410
  let n, o;
@@ -412,9 +414,9 @@ async function vt() {
412
414
  const r = ae(s.root, this.api_prefix, Qe);
413
415
  if (n = await this.fetch(r, {
414
416
  headers: t,
415
- credentials: "include"
417
+ credentials: this.options.credentials ?? "same-origin"
416
418
  }), !n.ok)
417
- throw new Error(L);
419
+ throw new Error(N);
418
420
  o = await n.json();
419
421
  }
420
422
  return "api" in o && (o = o.api), o.named_endpoints["/predict"] && !o.unnamed_endpoints[0] && (o.unnamed_endpoints[0] = o.named_endpoints["/predict"]), mt(o, s, this.api_map);
@@ -438,10 +440,10 @@ async function Et(e, s, t) {
438
440
  method: "POST",
439
441
  body: l,
440
442
  headers: n,
441
- credentials: "include"
443
+ credentials: this.options.credentials ?? "same-origin"
442
444
  });
443
445
  } catch (c) {
444
- throw new Error(L + c.message);
446
+ throw new Error(N + c.message);
445
447
  }
446
448
  if (!i.ok) {
447
449
  const c = await i.text();
@@ -536,7 +538,7 @@ class Q {
536
538
  this.path = s, this.url = t, this.orig_name = n, this.size = o, this.blob = t ? void 0 : r, this.is_stream = i, this.mime_type = a, this.alt_text = u, this.b64 = l;
537
539
  }
538
540
  }
539
- class je {
541
+ class Ie {
540
542
  type;
541
543
  command;
542
544
  meta;
@@ -545,7 +547,7 @@ class je {
545
547
  this.type = "command", this.command = s, this.meta = t;
546
548
  }
547
549
  }
548
- const Tt = typeof process < "u" && process.versions && process.versions.node;
550
+ const At = typeof process < "u" && process.versions && process.versions.node;
549
551
  function $e(e, s, t) {
550
552
  for (; t.length > 1; ) {
551
553
  const o = t.shift();
@@ -605,7 +607,7 @@ async function ce(e, s = void 0, t = [], n = !1, o = void 0) {
605
607
  }
606
608
  return [];
607
609
  }
608
- function At(e, s) {
610
+ function Tt(e, s) {
609
611
  let t = s?.dependencies?.find((n) => n.id == e)?.queue;
610
612
  return t != null ? !t : !s.enable_queue;
611
613
  }
@@ -617,7 +619,7 @@ function xt(e, s) {
617
619
  }), window.parent.postMessage(e, s, [o.port2]);
618
620
  });
619
621
  }
620
- function os(e) {
622
+ function is(e) {
621
623
  if (typeof e == "string") {
622
624
  if (e.startsWith("http://") || e.startsWith("https://"))
623
625
  return {
@@ -626,8 +628,8 @@ function os(e) {
626
628
  orig_name: e.split("/").pop() ?? "unknown",
627
629
  meta: { _type: "gradio.FileData" }
628
630
  };
629
- if (Tt)
630
- return new je("upload_file", {
631
+ if (At)
632
+ return new Ie("upload_file", {
631
633
  path: e,
632
634
  name: e,
633
635
  orig_path: e
@@ -674,7 +676,7 @@ function V(e, s, t, n, o = !1) {
674
676
  }
675
677
  async function Dt(e, s, t) {
676
678
  const n = this;
677
- await Ct(n, s);
679
+ await Lt(n, s);
678
680
  const o = await ce(
679
681
  s,
680
682
  void 0,
@@ -702,20 +704,20 @@ async function Dt(e, s, t) {
702
704
  }
703
705
  }), s;
704
706
  }
705
- async function Ct(e, s) {
707
+ async function Lt(e, s) {
706
708
  if (!(e.config?.root || e.config?.root_url))
707
- throw new Error(Le);
708
- await Ie(e, s);
709
+ throw new Error(Ne);
710
+ await Ue(e, s);
709
711
  }
710
- async function Ie(e, s, t = []) {
712
+ async function Ue(e, s, t = []) {
711
713
  for (const n in s)
712
- s[n] instanceof je ? await Lt(e, s, n) : typeof s[n] == "object" && s[n] !== null && await Ie(e, s[n], [...t, n]);
714
+ s[n] instanceof Ie ? await Nt(e, s, n) : typeof s[n] == "object" && s[n] !== null && await Ue(e, s[n], [...t, n]);
713
715
  }
714
- async function Lt(e, s, t) {
716
+ async function Nt(e, s, t) {
715
717
  let n = s[t];
716
718
  const o = e.config?.root || e.config?.root_url;
717
719
  if (!o)
718
- throw new Error(Le);
720
+ throw new Error(Ne);
719
721
  try {
720
722
  let r, i;
721
723
  if (typeof process < "u" && process.versions && process.versions.node) {
@@ -737,7 +739,7 @@ async function Lt(e, s, t) {
737
739
  console.error(dt, r);
738
740
  }
739
741
  }
740
- async function Nt(e, s, t) {
742
+ async function Ct(e, s, t) {
741
743
  const n = { "Content-Type": "application/json" };
742
744
  this.options.token && (n.Authorization = `Bearer ${this.options.token}`);
743
745
  try {
@@ -745,10 +747,10 @@ async function Nt(e, s, t) {
745
747
  method: "POST",
746
748
  body: JSON.stringify(s),
747
749
  headers: { ...n, ...t },
748
- credentials: "include"
750
+ credentials: this.options.credentials ?? "same-origin"
749
751
  });
750
752
  } catch {
751
- return [{ error: L }, 500];
753
+ return [{ error: N }, 500];
752
754
  }
753
755
  let r, i;
754
756
  try {
@@ -763,19 +765,26 @@ async function Pt(e, s = {}) {
763
765
  if (!this.config)
764
766
  throw new Error("Could not resolve app config");
765
767
  if (typeof e == "number")
766
- this.config.dependencies.find((o) => o.id == e);
768
+ this.config.dependencies.find((i) => i.id == e);
767
769
  else {
768
- const o = e.replace(/^\//, "");
770
+ const i = e.replace(/^\//, "");
769
771
  this.config.dependencies.find(
770
- (r) => r.id == this.api_map[o]
772
+ (a) => a.id == this.api_map[i]
771
773
  );
772
774
  }
773
- return new Promise(async (o, r) => {
774
- const i = this.submit(e, s, null, null, !0);
775
- let a;
776
- for await (const u of i)
777
- u.type === "data" && (n && o(a), t = !0, a = u), u.type === "status" && (u.stage === "error" && r(u), u.stage === "complete" && (n = !0, t && o(a)));
778
- });
775
+ const o = this.submit(e, s, null, null, !0);
776
+ let r;
777
+ for await (const i of o) {
778
+ if (i.type === "data" && (t = !0, r = i, n))
779
+ return r;
780
+ if (i.type === "status") {
781
+ if (i.stage === "error")
782
+ throw i;
783
+ if (i.stage === "complete" && (n = !0, t))
784
+ return r;
785
+ }
786
+ }
787
+ return r;
779
788
  }
780
789
  async function F(e, s, t) {
781
790
  let n = s === "subdomain" ? `https://huggingface.co/api/spaces/by-subdomain/${e}` : `https://huggingface.co/api/spaces/${e}`, o, r;
@@ -858,7 +867,7 @@ async function F(e, s, t) {
858
867
  break;
859
868
  }
860
869
  }
861
- const Ue = async (e, s) => {
870
+ const je = async (e, s) => {
862
871
  let t = 0;
863
872
  const n = 12, o = 5e3;
864
873
  return new Promise((r) => {
@@ -867,12 +876,12 @@ const Ue = async (e, s) => {
867
876
  le.test(e) ? "space_name" : "subdomain",
868
877
  (i) => {
869
878
  s(i), i.status === "running" || i.status === "error" || i.status === "paused" || i.status === "space_error" ? r() : (i.status === "sleeping" || i.status === "building") && (t < n ? (t++, setTimeout(() => {
870
- Ue(e, s).then(r);
879
+ je(e, s).then(r);
871
880
  }, o)) : r());
872
881
  }
873
882
  );
874
883
  });
875
- }, jt = /^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;
884
+ }, It = /^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;
876
885
  async function ke(e) {
877
886
  try {
878
887
  const s = await fetch(
@@ -881,12 +890,12 @@ async function ke(e) {
881
890
  method: "HEAD"
882
891
  }
883
892
  ), t = s.headers.get("x-error-message");
884
- return !(!s.ok || t && jt.test(t));
893
+ return !(!s.ok || t && It.test(t));
885
894
  } catch {
886
895
  return !1;
887
896
  }
888
897
  }
889
- async function It(e, s) {
898
+ async function Ut(e, s) {
890
899
  const t = {};
891
900
  s && (t.Authorization = `Bearer ${s}`);
892
901
  try {
@@ -902,7 +911,7 @@ async function It(e, s) {
902
911
  throw new Error(n.message);
903
912
  }
904
913
  }
905
- async function Ut(e, s, t) {
914
+ async function jt(e, s, t) {
906
915
  const n = {};
907
916
  t && (n.Authorization = `Bearer ${t}`);
908
917
  const o = {
@@ -950,11 +959,13 @@ async function qt(e, s) {
950
959
  const { http_protocol: a, host: u } = await pe(e, t);
951
960
  let l = null;
952
961
  if (i) {
953
- const m = await Ne(
962
+ const m = await Ce(
954
963
  a,
955
964
  u,
956
965
  i,
957
- fetch
966
+ fetch,
967
+ void 0,
968
+ s.credentials
958
969
  );
959
970
  m && (l = Pe(m));
960
971
  }
@@ -968,13 +979,13 @@ async function qt(e, s) {
968
979
  repository: `${c}/${g}`
969
980
  };
970
981
  n && (w.private = !0);
971
- let N;
982
+ let C;
972
983
  try {
973
- o || (N = await It(e, t));
984
+ o || (C = await Ut(e, t));
974
985
  } catch (m) {
975
986
  throw Error(ue + m.message);
976
987
  }
977
- const f = o || N || "cpu-basic";
988
+ const f = o || C || "cpu-basic";
978
989
  w.hardware = f;
979
990
  try {
980
991
  const m = await fetch(
@@ -994,7 +1005,7 @@ async function qt(e, s) {
994
1005
  else if (m.status !== 200)
995
1006
  throw new Error(m.statusText);
996
1007
  const H = await m.json();
997
- return await Ut(`${c}/${g}`, r || 300, t), await Y.connect(
1008
+ return await jt(`${c}/${g}`, r || 300, t), await Y.connect(
998
1009
  zt(H.url),
999
1010
  s
1000
1011
  );
@@ -1008,7 +1019,7 @@ function zt(e) {
1008
1019
  return t[1];
1009
1020
  }
1010
1021
  const Oe = "supports-zerogpu-headers";
1011
- let Te = !1;
1022
+ let Ae = !1;
1012
1023
  function Bt() {
1013
1024
  return typeof window < "u" && typeof document < "u" && typeof window.addEventListener == "function";
1014
1025
  }
@@ -1016,11 +1027,11 @@ function qe(e) {
1016
1027
  return e.includes(".dev.") ? `https://moon-${e.split(".")[1]}.dev.spaces.huggingface.tech` : e.endsWith(".hf.space") ? "https://huggingface.co" : null;
1017
1028
  }
1018
1029
  function Gt() {
1019
- if (!Bt() || Te)
1030
+ if (!Bt() || Ae)
1020
1031
  return;
1021
1032
  window.addEventListener("message", (s) => {
1022
1033
  s.data === Oe && (window.supports_zerogpu_headers = !0);
1023
- }), Te = !0;
1034
+ }), Ae = !0;
1024
1035
  const e = qe(window.location.hostname);
1025
1036
  e && window.parent !== window && window.parent.postMessage(Oe, e);
1026
1037
  }
@@ -1065,7 +1076,7 @@ function Ht(e) {
1065
1076
  e.substring(n + t[0].length)
1066
1077
  ];
1067
1078
  }
1068
- function Ae(e, s, t) {
1079
+ function Te(e, s, t) {
1069
1080
  e.get(s) || e.set(s, t);
1070
1081
  }
1071
1082
  async function* Jt(e, s) {
@@ -1088,7 +1099,7 @@ async function* Jt(e, s) {
1088
1099
  }
1089
1100
  async function Wt(e, s) {
1090
1101
  let t = new Request(e, s);
1091
- Ae(t.headers, "Accept", "text/event-stream"), Ae(t.headers, "Content-Type", "application/json");
1102
+ Te(t.headers, "Accept", "text/event-stream"), Te(t.headers, "Content-Type", "application/json");
1092
1103
  let n = await fetch(t);
1093
1104
  if (!n.ok)
1094
1105
  throw n;
@@ -1140,7 +1151,7 @@ async function Zt() {
1140
1151
  Object.keys(e).map(
1141
1152
  (c) => e[c]({
1142
1153
  msg: "broken_connection",
1143
- message: L
1154
+ message: N
1144
1155
  })
1145
1156
  )
1146
1157
  );
@@ -1240,17 +1251,17 @@ function Xt(e, s = {}, t, n, o, r) {
1240
1251
  done: !0
1241
1252
  });
1242
1253
  }, u = function(h) {
1243
- M.length > 0 ? M.shift()(h) : oe.push(h);
1254
+ M.length > 0 ? M.shift()(h) : ie.push(h);
1244
1255
  }, l = function(h) {
1245
1256
  u(es(h)), a();
1246
1257
  }, p = function(h) {
1247
1258
  u({ value: h, done: !1 });
1248
1259
  }, c = function() {
1249
- return oe.length > 0 ? Promise.resolve(oe.shift()) : me ? Promise.resolve({ value: void 0, done: !0 }) : new Promise((h) => M.push(h));
1260
+ return ie.length > 0 ? Promise.resolve(ie.shift()) : me ? Promise.resolve({ value: void 0, done: !0 }) : new Promise((h) => M.push(h));
1250
1261
  };
1251
1262
  const { token: g } = this.options, {
1252
1263
  fetch: w,
1253
- app_reference: N,
1264
+ app_reference: C,
1254
1265
  config: f,
1255
1266
  session_hash: m,
1256
1267
  api_info: H,
@@ -1262,7 +1273,7 @@ function Xt(e, s = {}, t, n, o, r) {
1262
1273
  unclosed_events: ze,
1263
1274
  post_data: ne,
1264
1275
  options: J,
1265
- api_prefix: T
1276
+ api_prefix: A
1266
1277
  } = this, he = r || { "x-gradio-user": "api" }, Be = this;
1267
1278
  if (!H) throw new Error("No API found");
1268
1279
  if (!f) throw new Error("Could not resolve app config");
@@ -1271,10 +1282,10 @@ function Xt(e, s = {}, t, n, o, r) {
1271
1282
  e,
1272
1283
  z,
1273
1284
  f
1274
- ), Ge = bt(s, fe), j, A = f.protocol ?? "ws";
1275
- if (A === "ws")
1285
+ ), Ge = bt(s, fe), I, T = f.protocol ?? "ws";
1286
+ if (T === "ws")
1276
1287
  throw new Error("WebSocket protocol is not supported in this version");
1277
- let I = "", ss = () => I;
1288
+ let U = "", ss = () => U;
1278
1289
  const _ = typeof e == "number" ? "/predict" : e;
1279
1290
  let W, v = null, x = !1, _e = {}, G = typeof window < "u" && typeof document < "u" ? new URLSearchParams(window.location.search).toString() : "";
1280
1291
  const Me = J?.events?.reduce(
@@ -1287,11 +1298,11 @@ function Xt(e, s = {}, t, n, o, r) {
1287
1298
  try {
1288
1299
  if (!f)
1289
1300
  throw new Error("Could not resolve app config");
1290
- "event_id" in R && await w(`${f.root}${T}/${ot}`, {
1301
+ "event_id" in R && await w(`${f.root}${A}/${it}`, {
1291
1302
  headers: { "Content-Type": "application/json" },
1292
1303
  method: "POST",
1293
1304
  body: JSON.stringify(R)
1294
- }), await w(`${f.root}${T}/${nt}`, {
1305
+ }), await w(`${f.root}${A}/${nt}`, {
1295
1306
  headers: { "Content-Type": "application/json" },
1296
1307
  method: "POST",
1297
1308
  body: JSON.stringify(h)
@@ -1316,7 +1327,7 @@ function Xt(e, s = {}, t, n, o, r) {
1316
1327
  ...h.dependencies
1317
1328
  ];
1318
1329
  const Z = f.components.some((E) => E.type === "state"), y = f.dependencies.some(
1319
- (E) => E.targets.some((U) => U[1] === "unload")
1330
+ (E) => E.targets.some((j) => j[1] === "unload")
1320
1331
  );
1321
1332
  f.connect_heartbeat = Z || y, await He(f), i({
1322
1333
  type: "render",
@@ -1341,7 +1352,7 @@ function Xt(e, s = {}, t, n, o, r) {
1341
1352
  event_data: t,
1342
1353
  fn_index: d,
1343
1354
  trigger_id: n
1344
- }, At(d, f))
1355
+ }, Tt(d, f))
1345
1356
  i({
1346
1357
  type: "status",
1347
1358
  endpoint: _,
@@ -1350,21 +1361,21 @@ function Xt(e, s = {}, t, n, o, r) {
1350
1361
  fn_index: d,
1351
1362
  time: /* @__PURE__ */ new Date()
1352
1363
  }), ne(
1353
- `${f.root}${T}/run${_.startsWith("/") ? _ : `/${_}`}${G ? "?" + G : ""}`,
1364
+ `${f.root}${A}/run${_.startsWith("/") ? _ : `/${_}`}${G ? "?" + G : ""}`,
1354
1365
  {
1355
1366
  ...W,
1356
1367
  session_hash: m
1357
1368
  },
1358
1369
  he
1359
1370
  ).then(async ([y, E]) => {
1360
- const U = y.data;
1371
+ const j = y.data;
1361
1372
  if (E == 200)
1362
1373
  i({
1363
1374
  type: "data",
1364
1375
  endpoint: _,
1365
1376
  fn_index: d,
1366
1377
  data: V(
1367
- U,
1378
+ j,
1368
1379
  B,
1369
1380
  f.components,
1370
1381
  "output",
@@ -1383,7 +1394,7 @@ function Xt(e, s = {}, t, n, o, r) {
1383
1394
  time: /* @__PURE__ */ new Date()
1384
1395
  });
1385
1396
  else {
1386
- const O = y?.error === L;
1397
+ const O = y?.error === N;
1387
1398
  i({
1388
1399
  type: "status",
1389
1400
  stage: "error",
@@ -1406,7 +1417,7 @@ function Xt(e, s = {}, t, n, o, r) {
1406
1417
  time: /* @__PURE__ */ new Date()
1407
1418
  });
1408
1419
  });
1409
- else if (A == "sse") {
1420
+ else if (T == "sse") {
1410
1421
  i({
1411
1422
  type: "status",
1412
1423
  stage: "pending",
@@ -1420,15 +1431,15 @@ function Xt(e, s = {}, t, n, o, r) {
1420
1431
  session_hash: m
1421
1432
  }).toString();
1422
1433
  let y = new URL(
1423
- `${f.root}${T}/${xe}?${G ? G + "&" : ""}${Z}`
1434
+ `${f.root}${A}/${xe}?${G ? G + "&" : ""}${Z}`
1424
1435
  );
1425
- if (this.jwt && y.searchParams.set("__sign", this.jwt), j = this.stream(y), !j)
1436
+ if (this.jwt && y.searchParams.set("__sign", this.jwt), I = this.stream(y), !I)
1426
1437
  return Promise.reject(
1427
1438
  new Error("Cannot connect to SSE endpoint: " + y.toString())
1428
1439
  );
1429
- j.onmessage = async function(E) {
1430
- const U = JSON.parse(E.data), { type: O, status: D, data: b } = Ee(
1431
- U,
1440
+ I.onmessage = async function(E) {
1441
+ const j = JSON.parse(E.data), { type: O, status: D, data: b } = Ee(
1442
+ j,
1432
1443
  _e[d]
1433
1444
  );
1434
1445
  if (O === "update" && D && !x)
@@ -1438,10 +1449,10 @@ function Xt(e, s = {}, t, n, o, r) {
1438
1449
  fn_index: d,
1439
1450
  time: /* @__PURE__ */ new Date(),
1440
1451
  ...D
1441
- }), D.stage === "error" && (j?.close(), a());
1452
+ }), D.stage === "error" && (I?.close(), a());
1442
1453
  else if (O === "data") {
1443
1454
  let [q, P] = await ne(
1444
- `${f.root}${T}/queue/data`,
1455
+ `${f.root}${A}/queue/data`,
1445
1456
  {
1446
1457
  ...W,
1447
1458
  session_hash: m,
@@ -1451,12 +1462,12 @@ function Xt(e, s = {}, t, n, o, r) {
1451
1462
  P !== 200 && (i({
1452
1463
  type: "status",
1453
1464
  stage: "error",
1454
- message: L,
1465
+ message: N,
1455
1466
  queue: !0,
1456
1467
  endpoint: _,
1457
1468
  fn_index: d,
1458
1469
  time: /* @__PURE__ */ new Date()
1459
- }), j?.close(), a());
1470
+ }), I?.close(), a());
1460
1471
  } else O === "complete" ? x = D : O === "log" ? i({
1461
1472
  type: "log",
1462
1473
  title: b.title,
@@ -1497,9 +1508,9 @@ function Xt(e, s = {}, t, n, o, r) {
1497
1508
  queue: !0,
1498
1509
  endpoint: _,
1499
1510
  fn_index: d
1500
- }), j?.close(), a()));
1511
+ }), I?.close(), a()));
1501
1512
  };
1502
- } else if (A == "sse_v1" || A == "sse_v2" || A == "sse_v2.1" || A == "sse_v3") {
1513
+ } else if (T == "sse_v1" || T == "sse_v2" || T == "sse_v2.1" || T == "sse_v3") {
1503
1514
  i({
1504
1515
  type: "status",
1505
1516
  stage: "pending",
@@ -1514,7 +1525,7 @@ function Xt(e, s = {}, t, n, o, r) {
1514
1525
  return (typeof window < "u" && typeof document < "u" && window.parent != window && !!E && window.supports_zerogpu_headers ? xt("zerogpu-headers", E) : Promise.resolve(null)).then((b) => {
1515
1526
  const q = { ...he, ...b || {} };
1516
1527
  return ne(
1517
- `${f.root}${T}/${Ve}?${G}`,
1528
+ `${f.root}${A}/${Ve}?${G}`,
1518
1529
  {
1519
1530
  ...W,
1520
1531
  session_hash: m
@@ -1522,7 +1533,7 @@ function Xt(e, s = {}, t, n, o, r) {
1522
1533
  q
1523
1534
  );
1524
1535
  }).then(async ([b, q]) => {
1525
- if (b.event_id && (I = b.event_id), q === 503)
1536
+ if (b.event_id && (U = b.event_id), q === 503)
1526
1537
  i({
1527
1538
  type: "status",
1528
1539
  stage: "error",
@@ -1546,12 +1557,12 @@ function Xt(e, s = {}, t, n, o, r) {
1546
1557
  visible: !0
1547
1558
  }), a();
1548
1559
  else if (q !== 200) {
1549
- const P = b?.error === L;
1560
+ const P = b?.error === N;
1550
1561
  i({
1551
1562
  type: "status",
1552
1563
  stage: "error",
1553
1564
  broken: P,
1554
- message: P ? L : b.detail || b.error,
1565
+ message: P ? N : b.detail || b.error,
1555
1566
  queue: !0,
1556
1567
  endpoint: _,
1557
1568
  fn_index: d,
@@ -1559,11 +1570,11 @@ function Xt(e, s = {}, t, n, o, r) {
1559
1570
  visible: !0
1560
1571
  }), a();
1561
1572
  } else {
1562
- v = b.event_id, I = v;
1563
- let P = async function(ie) {
1573
+ v = b.event_id, U = v;
1574
+ let P = async function(oe) {
1564
1575
  try {
1565
1576
  const { type: S, status: $, data: k, original_msg: We } = Ee(
1566
- ie,
1577
+ oe,
1567
1578
  _e[d]
1568
1579
  );
1569
1580
  if (S == "heartbeat")
@@ -1613,7 +1624,7 @@ function Xt(e, s = {}, t, n, o, r) {
1613
1624
  queue: !0,
1614
1625
  endpoint: _,
1615
1626
  fn_index: d
1616
- }), k && B.connection !== "stream" && ["sse_v2", "sse_v2.1", "sse_v3"].includes(A) && Kt(te, v, k));
1627
+ }), k && B.connection !== "stream" && ["sse_v2", "sse_v2.1", "sse_v3"].includes(T) && Kt(te, v, k));
1617
1628
  k && (i({
1618
1629
  type: "data",
1619
1630
  time: /* @__PURE__ */ new Date(),
@@ -1644,34 +1655,34 @@ function Xt(e, s = {}, t, n, o, r) {
1644
1655
  endpoint: _,
1645
1656
  fn_index: d,
1646
1657
  time: /* @__PURE__ */ new Date()
1647
- }), ["sse_v2", "sse_v2.1", "sse_v3"].includes(A) && (de(X, Be.abort_controller), X.open = !1, a());
1658
+ }), ["sse_v2", "sse_v2.1", "sse_v3"].includes(T) && (de(X, Be.abort_controller), X.open = !1, a());
1648
1659
  }
1649
1660
  };
1650
- v in ee && (ee[v].forEach((ie) => P(ie)), delete ee[v]), se[v] = P, ze.add(v), X.open || await this.open_stream();
1661
+ v in ee && (ee[v].forEach((oe) => P(oe)), delete ee[v]), se[v] = P, ze.add(v), X.open || await this.open_stream();
1651
1662
  }
1652
1663
  });
1653
1664
  }
1654
1665
  });
1655
1666
  let me = !1;
1656
- const oe = [], M = [], we = {
1667
+ const ie = [], M = [], we = {
1657
1668
  [Symbol.asyncIterator]: () => we,
1658
1669
  next: c,
1659
1670
  throw: async (h) => (l(h), c()),
1660
1671
  return: async () => (a(), { value: void 0, done: !0 }),
1661
1672
  cancel: Fe,
1662
1673
  send_chunk: (h) => {
1663
- this.post_data(`${f.root}${T}/stream/${I}`, {
1674
+ this.post_data(`${f.root}${A}/stream/${U}`, {
1664
1675
  ...h,
1665
1676
  session_hash: this.session_hash
1666
1677
  });
1667
1678
  },
1668
1679
  close_stream: () => {
1669
1680
  this.post_data(
1670
- `${f.root}${T}/stream/${I}/close`,
1681
+ `${f.root}${A}/stream/${U}/close`,
1671
1682
  {}
1672
1683
  ), a();
1673
1684
  },
1674
- event_id: () => I,
1685
+ event_id: () => U,
1675
1686
  wait_for_id: async () => (await Je, v)
1676
1687
  };
1677
1688
  return we;
@@ -1725,7 +1736,7 @@ class Y {
1725
1736
  current_payload;
1726
1737
  get_url_config(s = null) {
1727
1738
  if (!this.config)
1728
- throw new Error(C);
1739
+ throw new Error(L);
1729
1740
  s === null && (s = window.location.href);
1730
1741
  const t = (i) => i.replace(/^\/+|\/+$/g, "");
1731
1742
  let n = t(new URL(this.config.root).pathname), o = t(new URL(s).pathname), r;
@@ -1733,7 +1744,7 @@ class Y {
1733
1744
  }
1734
1745
  get_page_config(s) {
1735
1746
  if (!this.config)
1736
- throw new Error(C);
1747
+ throw new Error(L);
1737
1748
  let t = this.config;
1738
1749
  return s in t.page || (s = ""), {
1739
1750
  ...t,
@@ -1758,7 +1769,7 @@ class Y {
1758
1769
  return this && this.cookies && t.append("Cookie", this.cookies), this && this.options.headers && new Headers(this.options.headers).forEach((o, r) => {
1759
1770
  t.append(r, o);
1760
1771
  }), this && this.options.token && t.append("Authorization", `Bearer ${this.options.token}`), this.abort_controller = new AbortController(), this.stream_instance = Qt(s.toString(), {
1761
- credentials: "include",
1772
+ credentials: this.options.credentials ?? "same-origin",
1762
1773
  headers: t,
1763
1774
  signal: this.abort_controller.signal
1764
1775
  }), this.stream_instance;
@@ -1774,7 +1785,7 @@ class Y {
1774
1785
  resolve_config;
1775
1786
  resolve_cookies;
1776
1787
  constructor(s, t = { events: ["data"] }) {
1777
- 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 = vt.bind(this), this.upload_files = Et.bind(this), this.handle_blob = Dt.bind(this), this.post_data = Nt.bind(this), this.submit = Xt.bind(this), this.predict = Pt.bind(this), this.open_stream = Zt.bind(this), this.resolve_config = ft.bind(this), this.resolve_cookies = _t.bind(this), this.upload = Ot.bind(this), this.fetch = this.fetch.bind(this), this.handle_space_success = this.handle_space_success.bind(this), this.stream = this.stream.bind(this);
1788
+ 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 = vt.bind(this), this.upload_files = Et.bind(this), this.handle_blob = Dt.bind(this), this.post_data = Ct.bind(this), this.submit = Xt.bind(this), this.predict = Pt.bind(this), this.open_stream = Zt.bind(this), this.resolve_config = ft.bind(this), this.resolve_cookies = _t.bind(this), this.upload = Ot.bind(this), this.fetch = this.fetch.bind(this), this.handle_space_success = this.handle_space_success.bind(this), this.stream = this.stream.bind(this);
1778
1789
  }
1779
1790
  async init() {
1780
1791
  Gt(), this.options.auth && await this.resolve_cookies(), await this._resolve_config().then(
@@ -1801,7 +1812,7 @@ class Y {
1801
1812
  }
1802
1813
  async reconnect() {
1803
1814
  const s = new URL(
1804
- `${this.config.root}${this.api_prefix}/${it}`
1815
+ `${this.config.root}${this.api_prefix}/${ot}`
1805
1816
  );
1806
1817
  let t;
1807
1818
  try {
@@ -1830,12 +1841,12 @@ class Y {
1830
1841
  this.app_reference,
1831
1842
  this.options.token
1832
1843
  ), { status_callback: o } = this.options;
1833
- n && o && await Ue(n, o);
1844
+ n && o && await je(n, o);
1834
1845
  let r;
1835
1846
  try {
1836
1847
  let i = `${s}//${t}`;
1837
1848
  if (r = await this.resolve_config(i), !r)
1838
- throw new Error(C);
1849
+ throw new Error(L);
1839
1850
  return this.config_success(r);
1840
1851
  } catch (i) {
1841
1852
  if (n && o)
@@ -1865,12 +1876,12 @@ class Y {
1865
1876
  }
1866
1877
  async handle_space_success(s) {
1867
1878
  if (!this)
1868
- throw new Error(C);
1879
+ throw new Error(L);
1869
1880
  const { status_callback: t } = this.options;
1870
1881
  if (t && t(s), s.status === "running")
1871
1882
  try {
1872
1883
  if (this.config = await this._resolve_config(), this.api_prefix = this?.config?.api_prefix || "", !this.config)
1873
- throw new Error(C);
1884
+ throw new Error(L);
1874
1885
  return await this.config_success(this.config);
1875
1886
  } catch (n) {
1876
1887
  throw t && t({
@@ -1883,7 +1894,7 @@ class Y {
1883
1894
  }
1884
1895
  async component_server(s, t, n) {
1885
1896
  if (!this.config)
1886
- throw new Error(C);
1897
+ throw new Error(L);
1887
1898
  const o = {}, { token: r } = this.options, { session_hash: i } = this;
1888
1899
  r && (o.Authorization = `Bearer ${this.options.token}`);
1889
1900
  let a, u = this.config.components.find(
@@ -1912,7 +1923,7 @@ class Y {
1912
1923
  method: "POST",
1913
1924
  body: l,
1914
1925
  headers: o,
1915
- credentials: "include"
1926
+ credentials: this.options.credentials ?? "same-origin"
1916
1927
  }
1917
1928
  );
1918
1929
  if (!p.ok)
@@ -1937,7 +1948,7 @@ class Y {
1937
1948
  };
1938
1949
  }
1939
1950
  }
1940
- async function is(e, s = {
1951
+ async function os(e, s = {
1941
1952
  events: ["data"]
1942
1953
  }) {
1943
1954
  return await Y.connect(e, s);
@@ -1949,9 +1960,9 @@ export {
1949
1960
  Y as Client,
1950
1961
  Q as FileData,
1951
1962
  lt as MISSING_CREDENTIALS_MSG,
1952
- is as client,
1963
+ os as client,
1953
1964
  rs as duplicate,
1954
- os as handle_file,
1965
+ is as handle_file,
1955
1966
  Pt as predict,
1956
1967
  ns as prepare_files,
1957
1968
  Xt as submit,