gradio-pr-bot commited on
Commit
2984145
·
verified ·
1 Parent(s): fc6e040

Upload folder using huggingface_hub

Browse files
6.5.0/client/package.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "@gradio/client",
3
- "version": "2.0.3",
4
  "description": "Gradio API client",
5
  "type": "module",
6
  "main": "dist/index.js",
 
1
  {
2
  "name": "@gradio/client",
3
+ "version": "2.0.4",
4
  "description": "Gradio API client",
5
  "type": "module",
6
  "main": "dist/index.js",
6.5.0/client/src/helpers/init_helpers.ts CHANGED
@@ -74,26 +74,56 @@ export async function resolve_config(
74
 
75
  headers["Content-Type"] = "application/json";
76
 
77
- if (typeof window !== "undefined" && window?.gradio_config?.current_page) {
78
- endpoint = endpoint.substring(0, endpoint.lastIndexOf("/"));
79
- }
80
-
81
- let config_url = join_urls(
82
- endpoint,
83
- this.deep_link ? CONFIG_URL + "?deep_link=" + this.deep_link : CONFIG_URL
84
- );
85
-
86
- const response = await this.fetch(config_url, {
87
- headers,
88
- credentials: "include"
89
- });
90
- const config = await handleConfigResponse(response, !!this.options.auth);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
- if (typeof window !== "undefined" && window?.BUILD_MODE === "dev") {
93
- config.root = endpoint || config.root;
 
94
  }
95
 
96
- return config;
97
  }
98
 
99
  async function handleConfigResponse(
 
74
 
75
  headers["Content-Type"] = "application/json";
76
 
77
+ if (
78
+ typeof window !== "undefined" &&
79
+ window.gradio_config &&
80
+ location.origin !== "http://localhost:9876"
81
+ ) {
82
+ if (window.gradio_config.current_page) {
83
+ endpoint = endpoint.substring(0, endpoint.lastIndexOf("/"));
84
+ }
85
+ if (
86
+ window.gradio_config.dev_mode ||
87
+ (typeof window !== "undefined" && window?.BUILD_MODE === "dev")
88
+ ) {
89
+ let config_url = join_urls(
90
+ endpoint,
91
+ this.deep_link
92
+ ? CONFIG_URL + "?deep_link=" + this.deep_link
93
+ : CONFIG_URL
94
+ );
95
+ const response = await this.fetch(config_url, {
96
+ headers,
97
+ credentials: "include"
98
+ });
99
+ const config = await handleConfigResponse(response, !!this.options.auth);
100
+ config.root = endpoint || config.root;
101
+ // @ts-ignore
102
+ window.gradio_config = {
103
+ ...config,
104
+ current_page: window.gradio_config.current_page
105
+ };
106
+ }
107
+ window.gradio_config.root = endpoint;
108
+ // @ts-ignore
109
+ return { ...window.gradio_config } as Config;
110
+ } else if (endpoint) {
111
+ let config_url = join_urls(
112
+ endpoint,
113
+ this.deep_link ? CONFIG_URL + "?deep_link=" + this.deep_link : CONFIG_URL
114
+ );
115
+
116
+ const response = await this.fetch(config_url, {
117
+ headers,
118
+ credentials: "include"
119
+ });
120
 
121
+ const config = await handleConfigResponse(response, !!this.options.auth);
122
+ config.root = endpoint;
123
+ return config;
124
  }
125
 
126
+ throw new Error(CONFIG_ERROR_MSG);
127
  }
128
 
129
  async function handleConfigResponse(