@gradio/client 1.19.0 → 2.0.0-dev.0

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/client.d.ts CHANGED
@@ -24,7 +24,6 @@ export declare class Client {
24
24
  abort_controller: AbortController | null;
25
25
  stream_instance: EventSource | null;
26
26
  current_payload: any;
27
- ws_map: Record<string, WebSocket | "pending" | "failed" | "closed">;
28
27
  get_url_config(url?: string | null): Config;
29
28
  get_page_config(page: string): Config;
30
29
  fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
@@ -56,9 +55,6 @@ export declare class Client {
56
55
  }): Promise<unknown>;
57
56
  set_cookies(raw_cookies: string): void;
58
57
  private prepare_return_obj;
59
- private connect_ws;
60
- send_ws_message(url: string, data: any): Promise<void>;
61
- close_ws(url: string): Promise<void>;
62
58
  }
63
59
  /**
64
60
  * @deprecated This method will be removed in v1.0. Use `Client.connect()` instead.
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,OAAO,EACP,OAAO,EACP,aAAa,EACb,MAAM,EACN,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,aAAa,EACb,WAAW,EACX,MAAM,EACN,cAAc,EAEd,cAAc,EACd,WAAW,EACX,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAU,QAAQ,EAAE,MAAM,UAAU,CAAC;AA0B5C,qBAAa,MAAM;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,aAAa,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEhC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,UAAU,SAAM;IAChB,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IACrC,YAAY,EAA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M,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAC9D,OAAO,CAAC,OAAO,CAAC;IA6EZ,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAI7C,OAAO,CAAC,kBAAkB;CAS1B;AAED;;;;;;;GAOG;AACH,wBAAsB,MAAM,CAC3B,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,aAER,GACC,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACpC,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,gBAAgB,GACvB,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import type { ApiData, ApiInfo, Config, JsApiData, EndpointInfo, Status } from "../types";
2
2
  export declare const RE_SPACE_NAME: RegExp;
3
3
  export declare const RE_SPACE_DOMAIN: RegExp;
4
- export declare function process_endpoint(app_reference: string, hf_token?: `hf_${string}`): Promise<{
4
+ export declare function process_endpoint(app_reference: string, token?: `hf_${string}`): Promise<{
5
5
  space_id: string | false;
6
6
  host: string;
7
7
  ws_protocol: "ws" | "wss";
@@ -1 +1 @@
1
- {"version":3,"file":"api_info.d.ts","sourceRoot":"","sources":["../../src/helpers/api_info.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACX,OAAO,EACP,OAAO,EACP,MAAM,EACN,SAAS,EACT,YAAY,EACZ,MAAM,EACN,MAAM,UAAU,CAAC;AAGlB,eAAO,MAAM,aAAa,QAA2C,CAAC;AACtE,eAAO,MAAM,eAAe,QAA0B,CAAC;AAEvD,wBAAsB,gBAAgB,CACrC,aAAa,EAAE,MAAM,EACrB,QAAQ,CAAC,EAAE,MAAM,MAAM,EAAE,GACvB,OAAO,CAAC;IACV,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAC;IACzB,IAAI,EAAE,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B;IACF,IAAI,EACD,MAAM,GACN,MAAM,GACN,QAAQ,GACR,UAAU,GACV,YAAY,GACZ,KAAK,GACL,MAAM,GACN,WAAW,GACX,WAAW,GACX,mBAAmB,GACnB,kBAAkB,CAAC;IACtB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,CAmJA;AAGD;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,eAAO,MAAM,kBAAkB,yEAEf,aAAa,SAAS,GAAG,OAAO,CAAC,KAC9C,OAAO,EAgDT,CAAC"}
@@ -15,7 +15,7 @@ export declare function get_jwt(space: string, token: `hf_${string}`, cookies?:
15
15
  export declare function map_names_to_ids(fns: Config["dependencies"]): Record<string, number>;
16
16
  export declare function resolve_config(this: Client, endpoint: string): Promise<Config | undefined>;
17
17
  export declare function resolve_cookies(this: Client): Promise<void>;
18
- export declare function get_cookie_header(http_protocol: string, host: string, auth: [string, string], _fetch: typeof fetch, hf_token?: `hf_${string}`): Promise<string | null>;
18
+ export declare function get_cookie_header(http_protocol: string, host: string, auth: [string, string], _fetch: typeof fetch, token?: `hf_${string}`): Promise<string | null>;
19
19
  export declare function determine_protocol(endpoint: string): {
20
20
  ws_protocol: "ws" | "wss";
21
21
  http_protocol: "http:" | "https:";
@@ -1 +1 @@
1
- {"version":3,"file":"init_helpers.d.ts","sourceRoot":"","sources":["../../src/helpers/init_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAUvC,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAG5B;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC3B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,OAAO,GACtB,MAAM,CAKR;AAED,wBAAsB,OAAO,CAC5B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MA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AAED,wBAAsB,OAAO,CAC5B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,MAAM,EAAE,EACrB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,CAezB;AAED,wBAAgB,gBAAgB,CAC/B,GAAG,EAAE,MAAM,CAAC,cAAc,CAAC,GACzB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOxB;AAED,wBAAsB,cAAc,CACnC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAuD7B;AA+BD,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBjE;AAGD,wBAAsB,iBAAiB,CACtC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EACtB,MAAM,EAAE,OAAO,KAAK,EACpB,KAAK,CAAC,EAAE,MAAM,MAAM,EAAE,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAyBxB;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG;IACrD,WAAW,EAAE,IAAI,GAAG,KAAK,CAAC;IAC1B,aAAa,EAAE,OAAO,GAAG,QAAQ,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;CACb,CAkBA;AAED,eAAO,MAAM,qBAAqB,kBAAmB,MAAM,KAAG,MAAM,EAUnE,CAAC"}
@@ -2,7 +2,7 @@ import type { SpaceStatusCallback } from "../types";
2
2
  export declare function check_space_status(id: string, type: "subdomain" | "space_name", status_callback: SpaceStatusCallback): Promise<void>;
3
3
  export declare const check_and_wake_space: (space_id: string, status_callback: SpaceStatusCallback) => Promise<void>;
4
4
  export declare function discussions_enabled(space_id: string): Promise<boolean>;
5
- export declare function get_space_hardware(space_id: string, hf_token?: `hf_${string}` | undefined): Promise<(typeof hardware_types)[number]>;
6
- export declare function set_space_timeout(space_id: string, timeout: number, hf_token?: `hf_${string}`): Promise<any>;
5
+ export declare function get_space_hardware(space_id: string, token?: `hf_${string}` | undefined): Promise<(typeof hardware_types)[number]>;
6
+ export declare function set_space_timeout(space_id: string, timeout: number, token?: `hf_${string}`): Promise<any>;
7
7
  export declare const hardware_types: readonly ["cpu-basic", "cpu-upgrade", "cpu-xl", "t4-small", "t4-medium", "a10g-small", "a10g-large", "a10g-largex2", "a10g-largex4", "a100-large", "zero-a10g", "h100", "h100x8"];
8
8
  //# sourceMappingURL=spaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spaces.d.ts","sourceRoot":"","sources":["../../src/helpers/spaces.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,wBAAsB,kBAAkB,CACvC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,WAAW,GAAG,YAAY,EAChC,eAAe,EAAE,mBAAmB,GAClC,OAAO,CAAC,IAAI,CAAC,CAiGf;AAED,eAAO,MAAM,oBAAoB,aACtB,MAAM,mBACC,mBAAmB,KAClC,QAAQ,IAAI,CAoCd,CAAC;AAIF,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAgB5E;AAED,wBAAsB,kBAAkB,CACvC,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,MAAM,EAAE,GAAG,SAAS,GACnC,OAAO,CAAC,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,CAqB1C;AAED,wBAAsB,iBAAiB,CACtC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,MAAM,EAAE,GACvB,OAAO,CAAC,GAAG,CAAC,CAiCd;AAED,eAAO,MAAM,cAAc,mLAcjB,CAAC"}
1
+ {"version":3,"file":"spaces.d.ts","sourceRoot":"","sources":["../../src/helpers/spaces.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,wBAAsB,kBAAkB,CACvC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,WAAW,GAAG,YAAY,EAChC,eAAe,EAAE,mBAAmB,GAClC,OAAO,CAAC,IAAI,CAAC,CAiGf;AAED,eAAO,MAAM,oBAAoB,aACtB,MAAM,mBACC,mBAAmB,KAClC,QAAQ,IAAI,CAoCd,CAAC;AAIF,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAgB5E;AAED,wBAAsB,kBAAkB,CACvC,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,MAAM,EAAE,GAAG,SAAS,GAChC,OAAO,CAAC,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,CAqB1C;AAED,wBAAsB,iBAAiB,CACtC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,MAAM,EAAE,GACpB,OAAO,CAAC,GAAG,CAAC,CAiCd;AAED,eAAO,MAAM,cAAc,mLAcjB,CAAC"}
package/dist/index.js CHANGED
@@ -9,12 +9,6 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
9
9
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
10
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
11
  var _currentLine;
12
- var fn = new Intl.Collator(0, { numeric: 1 }).compare;
13
- function semiver(a, b, bool) {
14
- a = a.split(".");
15
- b = b.split(".");
16
- return fn(a[0], b[0]) || fn(a[1], b[1]) || (b[2] = b.slice(2).join("."), bool = /[.-]/.test(a[2] = a.slice(2).join(".")), bool == /[.-]/.test(b[2]) ? fn(a[2], b[2]) : bool ? -1 : 1);
17
- }
18
12
  const HOST_URL = `host`;
19
13
  const SSE_URL = `queue/data`;
20
14
  const SSE_DATA_URL = `queue/join`;
@@ -29,7 +23,6 @@ const COMPONENT_SERVER_URL = `component_server`;
29
23
  const RESET_URL = `reset`;
30
24
  const CANCEL_URL = `cancel`;
31
25
  const APP_ID_URL = `app_id`;
32
- const SPACE_FETCHER_URL = "https://gradio-space-api-fetcher-v2.hf.space/api";
33
26
  const QUEUE_FULL_MSG = "This application is currently busy. Please try again. ";
34
27
  const BROKEN_CONNECTION_MSG = "Connection errored out. ";
35
28
  const CONFIG_ERROR_MSG = "Could not resolve app config. ";
@@ -43,12 +36,6 @@ const MISSING_CREDENTIALS_MSG = "Login credentials are required to access this s
43
36
  const NODEJS_FS_ERROR_MSG = "File system access is only available in Node.js environments";
44
37
  const ROOT_URL_ERROR_MSG = "Root URL not found in client config";
45
38
  const FILE_PROCESSING_ERROR_MSG = "Error uploading file";
46
- function resolve_root(base_url, root_path, prioritize_base) {
47
- if (root_path.startsWith("http://") || root_path.startsWith("https://")) {
48
- return prioritize_base ? base_url : root_path;
49
- }
50
- return base_url + root_path;
51
- }
52
39
  async function get_jwt(space, token, cookies) {
53
40
  try {
54
41
  const r = await fetch(`https://huggingface.co/api/spaces/${space}/jwt`, {
@@ -71,12 +58,31 @@ function map_names_to_ids(fns) {
71
58
  return apis;
72
59
  }
73
60
  async function resolve_config(endpoint) {
74
- const headers = this.options.hf_token ? { Authorization: `Bearer ${this.options.hf_token}` } : {};
61
+ const headers = this.options.token ? { Authorization: `Bearer ${this.options.token}` } : {};
75
62
  headers["Content-Type"] = "application/json";
76
- if (typeof window !== "undefined" && window.gradio_config && location.origin !== "http://localhost:9876" && !window.gradio_config.dev_mode) {
63
+ if (typeof window !== "undefined" && window.gradio_config && location.origin !== "http://localhost:9876") {
77
64
  if (window.gradio_config.current_page) {
78
65
  endpoint = endpoint.substring(0, endpoint.lastIndexOf("/"));
79
66
  }
67
+ if (window.gradio_config.dev_mode) {
68
+ let config_url = join_urls(
69
+ endpoint,
70
+ this.deep_link ? CONFIG_URL + "?deep_link=" + this.deep_link : CONFIG_URL
71
+ );
72
+ const response = await this.fetch(config_url, {
73
+ headers,
74
+ credentials: "include"
75
+ });
76
+ const config = await handleConfigResponse(
77
+ response,
78
+ endpoint,
79
+ !!this.options.auth
80
+ );
81
+ window.gradio_config = {
82
+ ...config,
83
+ current_page: window.gradio_config.current_page
84
+ };
85
+ }
80
86
  window.gradio_config.root = endpoint;
81
87
  return { ...window.gradio_config };
82
88
  } else if (endpoint) {
@@ -118,7 +124,7 @@ async function handleConfigResponse(response, endpoint, authorized) {
118
124
  async function resolve_cookies() {
119
125
  const { http_protocol, host } = await process_endpoint(
120
126
  this.app_reference,
121
- this.options.hf_token
127
+ this.options.token
122
128
  );
123
129
  try {
124
130
  if (this.options.auth) {
@@ -127,7 +133,7 @@ async function resolve_cookies() {
127
133
  host,
128
134
  this.options.auth,
129
135
  this.fetch,
130
- this.options.hf_token
136
+ this.options.token
131
137
  );
132
138
  if (cookie_header) this.set_cookies(cookie_header);
133
139
  }
@@ -135,13 +141,13 @@ async function resolve_cookies() {
135
141
  throw Error(e.message);
136
142
  }
137
143
  }
138
- async function get_cookie_header(http_protocol, host, auth, _fetch, hf_token) {
144
+ async function get_cookie_header(http_protocol, host, auth, _fetch, token) {
139
145
  const formData = new FormData();
140
146
  formData.append("username", auth == null ? void 0 : auth[0]);
141
147
  formData.append("password", auth == null ? void 0 : auth[1]);
142
148
  let headers = {};
143
- if (hf_token) {
144
- headers.Authorization = `Bearer ${hf_token}`;
149
+ if (token) {
150
+ headers.Authorization = `Bearer ${token}`;
145
151
  }
146
152
  const res = await _fetch(`${http_protocol}//${host}/${LOGIN_URL}`, {
147
153
  headers,
@@ -185,10 +191,10 @@ const parse_and_set_cookies = (cookie_header) => {
185
191
  };
186
192
  const RE_SPACE_NAME = /^[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_\-\.]+$/;
187
193
  const RE_SPACE_DOMAIN = /.*hf\.space\/{0,1}.*$/;
188
- async function process_endpoint(app_reference, hf_token) {
194
+ async function process_endpoint(app_reference, token) {
189
195
  const headers = {};
190
- if (hf_token) {
191
- headers.Authorization = `Bearer ${hf_token}`;
196
+ if (token) {
197
+ headers.Authorization = `Bearer ${token}`;
192
198
  }
193
199
  const _app_reference = app_reference.trim().replace(/\/$/, "");
194
200
  if (RE_SPACE_NAME.test(_app_reference)) {
@@ -507,11 +513,11 @@ const map_data_to_params = (data = [], endpoint_info) => {
507
513
  };
508
514
  async function view_api() {
509
515
  if (this.api_info) return this.api_info;
510
- const { hf_token } = this.options;
516
+ const { token } = this.options;
511
517
  const { config } = this;
512
518
  const headers = { "Content-Type": "application/json" };
513
- if (hf_token) {
514
- headers.Authorization = `Bearer ${hf_token}`;
519
+ if (token) {
520
+ headers.Authorization = `Bearer ${token}`;
515
521
  }
516
522
  if (!config) {
517
523
  return;
@@ -522,23 +528,11 @@ async function view_api() {
522
528
  if (typeof window !== "undefined" && window.gradio_api_info) {
523
529
  api_info = window.gradio_api_info;
524
530
  } else {
525
- if (semiver((config == null ? void 0 : config.version) || "2.0.0", "3.30") < 0) {
526
- response = await this.fetch(SPACE_FETCHER_URL, {
527
- method: "POST",
528
- body: JSON.stringify({
529
- serialize: false,
530
- config: JSON.stringify(config)
531
- }),
532
- headers,
533
- credentials: "include"
534
- });
535
- } else {
536
- const url = join_urls(config.root, this.api_prefix, API_INFO_URL);
537
- response = await this.fetch(url, {
538
- headers,
539
- credentials: "include"
540
- });
541
- }
531
+ const url = join_urls(config.root, this.api_prefix, API_INFO_URL);
532
+ response = await this.fetch(url, {
533
+ headers,
534
+ credentials: "include"
535
+ });
542
536
  if (!response.ok) {
543
537
  throw new Error(BROKEN_CONNECTION_MSG);
544
538
  }
@@ -558,8 +552,8 @@ async function view_api() {
558
552
  async function upload_files(root_url, files, upload_id) {
559
553
  var _a;
560
554
  const headers = {};
561
- if ((_a = this == null ? void 0 : this.options) == null ? void 0 : _a.hf_token) {
562
- headers.Authorization = `Bearer ${this.options.hf_token}`;
555
+ if ((_a = this == null ? void 0 : this.options) == null ? void 0 : _a.token) {
556
+ headers.Authorization = `Bearer ${this.options.token}`;
563
557
  }
564
558
  const chunkSize = 1e3;
565
559
  const uploadResponses = [];
@@ -910,8 +904,8 @@ async function process_single_command(client2, data, key) {
910
904
  }
911
905
  async function post_data(url, body, additional_headers) {
912
906
  const headers = { "Content-Type": "application/json" };
913
- if (this.options.hf_token) {
914
- headers.Authorization = `Bearer ${this.options.hf_token}`;
907
+ if (this.options.token) {
908
+ headers.Authorization = `Bearer ${this.options.token}`;
915
909
  }
916
910
  try {
917
911
  var response = await this.fetch(url, {
@@ -1104,10 +1098,10 @@ async function discussions_enabled(space_id) {
1104
1098
  return false;
1105
1099
  }
1106
1100
  }
1107
- async function get_space_hardware(space_id, hf_token) {
1101
+ async function get_space_hardware(space_id, token) {
1108
1102
  const headers = {};
1109
- if (hf_token) {
1110
- headers.Authorization = `Bearer ${hf_token}`;
1103
+ if (token) {
1104
+ headers.Authorization = `Bearer ${token}`;
1111
1105
  }
1112
1106
  try {
1113
1107
  const res = await fetch(
@@ -1122,10 +1116,10 @@ async function get_space_hardware(space_id, hf_token) {
1122
1116
  throw new Error(e.message);
1123
1117
  }
1124
1118
  }
1125
- async function set_space_timeout(space_id, timeout, hf_token) {
1119
+ async function set_space_timeout(space_id, timeout, token) {
1126
1120
  const headers = {};
1127
- if (hf_token) {
1128
- headers.Authorization = `Bearer ${hf_token}`;
1121
+ if (token) {
1122
+ headers.Authorization = `Bearer ${token}`;
1129
1123
  }
1130
1124
  const body = {
1131
1125
  seconds: timeout
@@ -1166,16 +1160,13 @@ const hardware_types = [
1166
1160
  "h100x8"
1167
1161
  ];
1168
1162
  async function duplicate(app_reference, options) {
1169
- const { hf_token, private: _private, hardware, timeout, auth } = options;
1163
+ const { token, private: _private, hardware, timeout, auth } = options;
1170
1164
  if (hardware && !hardware_types.includes(hardware)) {
1171
1165
  throw new Error(
1172
1166
  `Invalid hardware type provided. Valid types are: ${hardware_types.map((v) => `"${v}"`).join(",")}.`
1173
1167
  );
1174
1168
  }
1175
- const { http_protocol, host } = await process_endpoint(
1176
- app_reference,
1177
- hf_token
1178
- );
1169
+ const { http_protocol, host } = await process_endpoint(app_reference, token);
1179
1170
  let cookies = null;
1180
1171
  if (auth) {
1181
1172
  const cookie_header = await get_cookie_header(
@@ -1187,7 +1178,7 @@ async function duplicate(app_reference, options) {
1187
1178
  if (cookie_header) cookies = parse_and_set_cookies(cookie_header);
1188
1179
  }
1189
1180
  const headers = {
1190
- Authorization: `Bearer ${hf_token}`,
1181
+ Authorization: `Bearer ${token}`,
1191
1182
  "Content-Type": "application/json",
1192
1183
  ...cookies ? { Cookie: cookies.join("; ") } : {}
1193
1184
  };
@@ -1204,7 +1195,7 @@ async function duplicate(app_reference, options) {
1204
1195
  let original_hardware;
1205
1196
  try {
1206
1197
  if (!hardware) {
1207
- original_hardware = await get_space_hardware(app_reference, hf_token);
1198
+ original_hardware = await get_space_hardware(app_reference, token);
1208
1199
  }
1209
1200
  } catch (e) {
1210
1201
  throw Error(SPACE_METADATA_ERROR_MSG + e.message);
@@ -1232,7 +1223,7 @@ async function duplicate(app_reference, options) {
1232
1223
  throw new Error(response.statusText);
1233
1224
  }
1234
1225
  const duplicated_space = await response.json();
1235
- await set_space_timeout(`${user}/${space_name}`, timeout || 300, hf_token);
1226
+ await set_space_timeout(`${user}/${space_name}`, timeout || 300, token);
1236
1227
  return await Client.connect(
1237
1228
  get_space_reference(duplicated_space.url),
1238
1229
  options
@@ -1394,11 +1385,11 @@ async function open_stream() {
1394
1385
  )) {
1395
1386
  unclosed_events.delete(event_id);
1396
1387
  }
1397
- let fn2 = event_callbacks[event_id];
1388
+ let fn = event_callbacks[event_id];
1398
1389
  if (typeof window !== "undefined" && typeof document !== "undefined") {
1399
- setTimeout(fn2, 0, _data);
1390
+ setTimeout(fn, 0, _data);
1400
1391
  } else {
1401
- fn2(_data);
1392
+ fn(_data);
1402
1393
  }
1403
1394
  } else {
1404
1395
  if (!pending_stream_messages[event_id]) {
@@ -1559,7 +1550,7 @@ function submit(endpoint, data = {}, event_data, trigger_id, all_events) {
1559
1550
  }
1560
1551
  return new Promise((resolve) => resolvers.push(resolve));
1561
1552
  };
1562
- const { hf_token } = this.options;
1553
+ const { token } = this.options;
1563
1554
  const {
1564
1555
  fetch: fetch2,
1565
1556
  app_reference,
@@ -1586,9 +1577,11 @@ function submit(endpoint, data = {}, event_data, trigger_id, all_events) {
1586
1577
  config
1587
1578
  );
1588
1579
  let resolved_data = map_data_to_params(data, endpoint_info);
1589
- let websocket;
1590
1580
  let stream2;
1591
1581
  let protocol = config.protocol ?? "ws";
1582
+ if (protocol === "ws") {
1583
+ throw new Error("WebSocket protocol is not supported in this version");
1584
+ }
1592
1585
  let event_id_final = "";
1593
1586
  let event_id_cb = () => event_id_final;
1594
1587
  const _endpoint = typeof endpoint === "number" ? "/predict" : endpoint;
@@ -1607,19 +1600,8 @@ function submit(endpoint, data = {}, event_data, trigger_id, all_events) {
1607
1600
  async function cancel() {
1608
1601
  let reset_request = {};
1609
1602
  let cancel_request = {};
1610
- if (protocol === "ws") {
1611
- if (websocket && websocket.readyState === 0) {
1612
- websocket.addEventListener("open", () => {
1613
- websocket.close();
1614
- });
1615
- } else {
1616
- websocket.close();
1617
- }
1618
- reset_request = { fn_index, session_hash };
1619
- } else {
1620
- reset_request = { event_id };
1621
- cancel_request = { event_id, session_hash, fn_index };
1622
- }
1603
+ reset_request = { event_id };
1604
+ cancel_request = { event_id, session_hash, fn_index };
1623
1605
  try {
1624
1606
  if (!config) {
1625
1607
  throw new Error("Could not resolve app config");
@@ -1752,126 +1734,6 @@ function submit(endpoint, data = {}, event_data, trigger_id, all_events) {
1752
1734
  time: /* @__PURE__ */ new Date()
1753
1735
  });
1754
1736
  });
1755
- } else if (protocol == "ws") {
1756
- const { ws_protocol, host } = await process_endpoint(
1757
- app_reference,
1758
- hf_token
1759
- );
1760
- fire_event({
1761
- type: "status",
1762
- stage: "pending",
1763
- queue: true,
1764
- endpoint: _endpoint,
1765
- fn_index,
1766
- time: /* @__PURE__ */ new Date()
1767
- });
1768
- let url = new URL(
1769
- `${ws_protocol}://${resolve_root(
1770
- host,
1771
- config.root,
1772
- true
1773
- )}/queue/join${url_params ? "?" + url_params : ""}`
1774
- );
1775
- if (this.jwt) {
1776
- url.searchParams.set("__sign", this.jwt);
1777
- }
1778
- websocket = new WebSocket(url);
1779
- websocket.onclose = (evt) => {
1780
- if (!evt.wasClean) {
1781
- fire_event({
1782
- type: "status",
1783
- stage: "error",
1784
- broken: true,
1785
- message: BROKEN_CONNECTION_MSG,
1786
- queue: true,
1787
- endpoint: _endpoint,
1788
- fn_index,
1789
- time: /* @__PURE__ */ new Date()
1790
- });
1791
- }
1792
- };
1793
- websocket.onmessage = function(event) {
1794
- const _data = JSON.parse(event.data);
1795
- const { type, status, data: data2 } = handle_message(
1796
- _data,
1797
- last_status[fn_index]
1798
- );
1799
- if (type === "update" && status && !complete) {
1800
- fire_event({
1801
- type: "status",
1802
- endpoint: _endpoint,
1803
- fn_index,
1804
- time: /* @__PURE__ */ new Date(),
1805
- ...status
1806
- });
1807
- if (status.stage === "error") {
1808
- websocket.close();
1809
- }
1810
- } else if (type === "hash") {
1811
- websocket.send(JSON.stringify({ fn_index, session_hash }));
1812
- return;
1813
- } else if (type === "data") {
1814
- websocket.send(JSON.stringify({ ...payload, session_hash }));
1815
- } else if (type === "complete") {
1816
- complete = status;
1817
- } else if (type === "log") {
1818
- fire_event({
1819
- type: "log",
1820
- title: data2.title,
1821
- log: data2.log,
1822
- level: data2.level,
1823
- endpoint: _endpoint,
1824
- duration: data2.duration,
1825
- visible: data2.visible,
1826
- fn_index
1827
- });
1828
- } else if (type === "generating") {
1829
- fire_event({
1830
- type: "status",
1831
- time: /* @__PURE__ */ new Date(),
1832
- ...status,
1833
- stage: status == null ? void 0 : status.stage,
1834
- queue: true,
1835
- endpoint: _endpoint,
1836
- fn_index
1837
- });
1838
- }
1839
- if (data2) {
1840
- fire_event({
1841
- type: "data",
1842
- time: /* @__PURE__ */ new Date(),
1843
- data: handle_payload(
1844
- data2.data,
1845
- dependency,
1846
- config.components,
1847
- "output",
1848
- options.with_null_state
1849
- ),
1850
- endpoint: _endpoint,
1851
- fn_index,
1852
- event_data,
1853
- trigger_id
1854
- });
1855
- if (complete) {
1856
- fire_event({
1857
- type: "status",
1858
- time: /* @__PURE__ */ new Date(),
1859
- ...complete,
1860
- stage: status == null ? void 0 : status.stage,
1861
- queue: true,
1862
- endpoint: _endpoint,
1863
- fn_index
1864
- });
1865
- websocket.close();
1866
- }
1867
- }
1868
- };
1869
- if (semiver(config.version || "2.0.0", "3.6") < 0) {
1870
- addEventListener(
1871
- "open",
1872
- () => websocket.send(JSON.stringify({ hash: session_hash }))
1873
- );
1874
- }
1875
1737
  } else if (protocol == "sse") {
1876
1738
  fire_event({
1877
1739
  type: "status",
@@ -2263,7 +2125,6 @@ class Client {
2263
2125
  __publicField(this, "abort_controller", null);
2264
2126
  __publicField(this, "stream_instance", null);
2265
2127
  __publicField(this, "current_payload");
2266
- __publicField(this, "ws_map", {});
2267
2128
  __publicField(this, "view_api");
2268
2129
  __publicField(this, "upload_files");
2269
2130
  __publicField(this, "upload");
@@ -2356,8 +2217,8 @@ class Client {
2356
2217
  headers.append(name, this.options.headers[name]);
2357
2218
  }
2358
2219
  }
2359
- if (this && this.options.hf_token) {
2360
- headers.append("Authorization", `Bearer ${this.options.hf_token}`);
2220
+ if (this && this.options.token) {
2221
+ headers.append("Authorization", `Bearer ${this.options.token}`);
2361
2222
  }
2362
2223
  this.abort_controller = new AbortController();
2363
2224
  this.stream_instance = readable_stream(url.toString(), {
@@ -2369,12 +2230,6 @@ class Client {
2369
2230
  }
2370
2231
  async init() {
2371
2232
  var _a;
2372
- if ((typeof window === "undefined" || !("WebSocket" in window)) && !global.WebSocket) {
2373
- {
2374
- const ws = await import("./wrapper-CpGUsf_3.js");
2375
- global.WebSocket = ws.WebSocket;
2376
- }
2377
- }
2378
2233
  if (this.options.auth) {
2379
2234
  await this.resolve_cookies();
2380
2235
  }
@@ -2389,17 +2244,17 @@ class Client {
2389
2244
  this.config = _config;
2390
2245
  this.api_prefix = _config.api_prefix || "";
2391
2246
  if (this.config && this.config.connect_heartbeat) {
2392
- if (this.config.space_id && this.options.hf_token) {
2247
+ if (this.config.space_id && this.options.token) {
2393
2248
  this.jwt = await get_jwt(
2394
2249
  this.config.space_id,
2395
- this.options.hf_token,
2250
+ this.options.token,
2396
2251
  this.cookies
2397
2252
  );
2398
2253
  }
2399
2254
  }
2400
2255
  }
2401
- if (_config.space_id && this.options.hf_token) {
2402
- this.jwt = await get_jwt(_config.space_id, this.options.hf_token);
2256
+ if (_config.space_id && this.options.token) {
2257
+ this.jwt = await get_jwt(_config.space_id, this.options.token);
2403
2258
  }
2404
2259
  if (this.config && this.config.connect_heartbeat) {
2405
2260
  const heartbeat_url = new URL(
@@ -2457,7 +2312,7 @@ class Client {
2457
2312
  async _resolve_config() {
2458
2313
  const { http_protocol, host, space_id } = await process_endpoint(
2459
2314
  this.app_reference,
2460
- this.options.hf_token
2315
+ this.options.token
2461
2316
  );
2462
2317
  const { status_callback } = this.options;
2463
2318
  if (space_id && status_callback) {
@@ -2538,10 +2393,10 @@ class Client {
2538
2393
  throw new Error(CONFIG_ERROR_MSG);
2539
2394
  }
2540
2395
  const headers = {};
2541
- const { hf_token } = this.options;
2396
+ const { token } = this.options;
2542
2397
  const { session_hash } = this;
2543
- if (hf_token) {
2544
- headers.Authorization = `Bearer ${this.options.hf_token}`;
2398
+ if (token) {
2399
+ headers.Authorization = `Bearer ${this.options.token}`;
2545
2400
  }
2546
2401
  let root_url;
2547
2402
  let component = this.config.components.find(
@@ -2571,8 +2426,8 @@ class Client {
2571
2426
  });
2572
2427
  headers["Content-Type"] = "application/json";
2573
2428
  }
2574
- if (hf_token) {
2575
- headers.Authorization = `Bearer ${hf_token}`;
2429
+ if (token) {
2430
+ headers.Authorization = `Bearer ${token}`;
2576
2431
  }
2577
2432
  try {
2578
2433
  const response = await this.fetch(
@@ -2607,55 +2462,6 @@ class Client {
2607
2462
  component_server: this.component_server
2608
2463
  };
2609
2464
  }
2610
- async connect_ws(url) {
2611
- return new Promise((resolve, reject) => {
2612
- let ws;
2613
- try {
2614
- ws = new WebSocket(url);
2615
- } catch (e) {
2616
- this.ws_map[url] = "failed";
2617
- return;
2618
- }
2619
- this.ws_map[url] = "pending";
2620
- ws.onopen = () => {
2621
- this.ws_map[url] = ws;
2622
- resolve();
2623
- };
2624
- ws.onerror = (error) => {
2625
- console.error("WebSocket error:", error);
2626
- this.close_ws(url);
2627
- this.ws_map[url] = "failed";
2628
- resolve();
2629
- };
2630
- ws.onclose = () => {
2631
- this.ws_map[url] = "closed";
2632
- };
2633
- ws.onmessage = (event) => {
2634
- };
2635
- });
2636
- }
2637
- async send_ws_message(url, data) {
2638
- if (!(url in this.ws_map)) {
2639
- await this.connect_ws(url);
2640
- } else if (this.ws_map[url] === "pending" || this.ws_map[url] === "closed" || this.ws_map[url] === "failed") {
2641
- return;
2642
- }
2643
- const ws = this.ws_map[url];
2644
- if (ws instanceof WebSocket) {
2645
- ws.send(JSON.stringify(data));
2646
- } else {
2647
- this.post_data(url, data);
2648
- }
2649
- }
2650
- async close_ws(url) {
2651
- if (url in this.ws_map) {
2652
- const ws = this.ws_map[url];
2653
- if (ws instanceof WebSocket) {
2654
- ws.close();
2655
- delete this.ws_map[url];
2656
- }
2657
- }
2658
- }
2659
2465
  }
2660
2466
  async function client(app_reference, options = {
2661
2467
  events: ["data"]