Spaces:
Running
Running
node
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +1 -0
- node_modules/.bin/msw +1 -0
- node_modules/.bin/node-gyp-build +1 -0
- node_modules/.bin/node-gyp-build-optional +1 -0
- node_modules/.bin/node-gyp-build-test +1 -0
- node_modules/.bin/tsc +1 -0
- node_modules/.bin/tsserver +1 -0
- node_modules/.package-lock.json +726 -0
- node_modules/@bundled-es-modules/cookie/README.md +18 -0
- node_modules/@bundled-es-modules/cookie/index-cjs.cjs +2 -0
- node_modules/@bundled-es-modules/cookie/index-esm.js +208 -0
- node_modules/@bundled-es-modules/cookie/package.json +34 -0
- node_modules/@bundled-es-modules/statuses/README.md +17 -0
- node_modules/@bundled-es-modules/statuses/index-cjs.cjs +2 -0
- node_modules/@bundled-es-modules/statuses/index-esm.js +184 -0
- node_modules/@bundled-es-modules/statuses/package.json +30 -0
- node_modules/@bundled-es-modules/tough-cookie/index-cjs.cjs +2 -0
- node_modules/@bundled-es-modules/tough-cookie/index-esm.js +0 -0
- node_modules/@bundled-es-modules/tough-cookie/index.d.ts +4 -0
- node_modules/@bundled-es-modules/tough-cookie/package.json +39 -0
- node_modules/@gradio/client/CHANGELOG.md +850 -0
- node_modules/@gradio/client/LICENSE +201 -0
- node_modules/@gradio/client/README.md +448 -0
- node_modules/@gradio/client/dist/client.d.ts +81 -0
- node_modules/@gradio/client/dist/client.d.ts.map +1 -0
- node_modules/@gradio/client/dist/constants.d.ts +33 -0
- node_modules/@gradio/client/dist/constants.d.ts.map +1 -0
- node_modules/@gradio/client/dist/helpers/api_info.d.ts +48 -0
- node_modules/@gradio/client/dist/helpers/api_info.d.ts.map +1 -0
- node_modules/@gradio/client/dist/helpers/data.d.ts +22 -0
- node_modules/@gradio/client/dist/helpers/data.d.ts.map +1 -0
- node_modules/@gradio/client/dist/helpers/init_helpers.d.ts +25 -0
- node_modules/@gradio/client/dist/helpers/init_helpers.d.ts.map +1 -0
- node_modules/@gradio/client/dist/helpers/spaces.d.ts +8 -0
- node_modules/@gradio/client/dist/helpers/spaces.d.ts.map +1 -0
- node_modules/@gradio/client/dist/index.d.ts +10 -0
- node_modules/@gradio/client/dist/index.d.ts.map +1 -0
- node_modules/@gradio/client/dist/index.js +2674 -0
- node_modules/@gradio/client/dist/test/handlers.d.ts +4 -0
- node_modules/@gradio/client/dist/test/handlers.d.ts.map +1 -0
- node_modules/@gradio/client/dist/test/mock_eventsource.d.ts +2 -0
- node_modules/@gradio/client/dist/test/mock_eventsource.d.ts.map +1 -0
- node_modules/@gradio/client/dist/test/server.d.ts +2 -0
- node_modules/@gradio/client/dist/test/server.d.ts.map +1 -0
- node_modules/@gradio/client/dist/test/test_data.d.ts +76 -0
- node_modules/@gradio/client/dist/test/test_data.d.ts.map +1 -0
- node_modules/@gradio/client/dist/types.d.ts +330 -0
- node_modules/@gradio/client/dist/types.d.ts.map +1 -0
- node_modules/@gradio/client/dist/upload.d.ts +29 -0
- node_modules/@gradio/client/dist/upload.d.ts.map +1 -0
.gitattributes
CHANGED
@@ -11,6 +11,7 @@
|
|
11 |
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
|
|
14 |
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
|
|
11 |
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.node filter=lfs diff=lfs merge=lfs -text
|
15 |
*.npy filter=lfs diff=lfs merge=lfs -text
|
16 |
*.npz filter=lfs diff=lfs merge=lfs -text
|
17 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
node_modules/.bin/msw
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
../msw/cli/index.js
|
node_modules/.bin/node-gyp-build
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
../node-gyp-build/bin.js
|
node_modules/.bin/node-gyp-build-optional
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
../node-gyp-build/optional.js
|
node_modules/.bin/node-gyp-build-test
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
../node-gyp-build/build-test.js
|
node_modules/.bin/tsc
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
../typescript/bin/tsc
|
node_modules/.bin/tsserver
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
../typescript/bin/tsserver
|
node_modules/.package-lock.json
ADDED
@@ -0,0 +1,726 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "app",
|
3 |
+
"lockfileVersion": 3,
|
4 |
+
"requires": true,
|
5 |
+
"packages": {
|
6 |
+
"node_modules/@bundled-es-modules/cookie": {
|
7 |
+
"version": "2.0.1",
|
8 |
+
"resolved": "https://registry.npmjs.org/@bundled-es-modules/cookie/-/cookie-2.0.1.tgz",
|
9 |
+
"integrity": "sha512-8o+5fRPLNbjbdGRRmJj3h6Hh1AQJf2dk3qQ/5ZFb+PXkRNiSoMGGUKlsgLfrxneb72axVJyIYji64E2+nNfYyw==",
|
10 |
+
"license": "ISC",
|
11 |
+
"dependencies": {
|
12 |
+
"cookie": "^0.7.2"
|
13 |
+
}
|
14 |
+
},
|
15 |
+
"node_modules/@bundled-es-modules/statuses": {
|
16 |
+
"version": "1.0.1",
|
17 |
+
"resolved": "https://registry.npmjs.org/@bundled-es-modules/statuses/-/statuses-1.0.1.tgz",
|
18 |
+
"integrity": "sha512-yn7BklA5acgcBr+7w064fGV+SGIFySjCKpqjcWgBAIfrAkY+4GQTJJHQMeT3V/sgz23VTEVV8TtOmkvJAhFVfg==",
|
19 |
+
"license": "ISC",
|
20 |
+
"dependencies": {
|
21 |
+
"statuses": "^2.0.1"
|
22 |
+
}
|
23 |
+
},
|
24 |
+
"node_modules/@bundled-es-modules/tough-cookie": {
|
25 |
+
"version": "0.1.6",
|
26 |
+
"resolved": "https://registry.npmjs.org/@bundled-es-modules/tough-cookie/-/tough-cookie-0.1.6.tgz",
|
27 |
+
"integrity": "sha512-dvMHbL464C0zI+Yqxbz6kZ5TOEp7GLW+pry/RWndAR8MJQAXZ2rPmIs8tziTZjeIyhSNZgZbCePtfSbdWqStJw==",
|
28 |
+
"license": "ISC",
|
29 |
+
"dependencies": {
|
30 |
+
"@types/tough-cookie": "^4.0.5",
|
31 |
+
"tough-cookie": "^4.1.4"
|
32 |
+
}
|
33 |
+
},
|
34 |
+
"node_modules/@gradio/client": {
|
35 |
+
"version": "1.14.1",
|
36 |
+
"resolved": "https://registry.npmjs.org/@gradio/client/-/client-1.14.1.tgz",
|
37 |
+
"integrity": "sha512-0ey5deyei0bXOCl2+ghfPWnOCnteDdp5rdlKyq7mq0PDYMwjsonS1VhMaoNo0Yks01KDTe7rrdvYOUXueDn9Cg==",
|
38 |
+
"license": "ISC",
|
39 |
+
"dependencies": {
|
40 |
+
"@types/eventsource": "^1.1.15",
|
41 |
+
"bufferutil": "^4.0.7",
|
42 |
+
"eventsource": "^2.0.2",
|
43 |
+
"fetch-event-stream": "^0.1.5",
|
44 |
+
"msw": "^2.2.1",
|
45 |
+
"semiver": "^1.1.0",
|
46 |
+
"textlinestream": "^1.1.1",
|
47 |
+
"typescript": "^5.0.0",
|
48 |
+
"ws": "^8.13.0"
|
49 |
+
},
|
50 |
+
"engines": {
|
51 |
+
"node": ">=18.0.0"
|
52 |
+
}
|
53 |
+
},
|
54 |
+
"node_modules/@inquirer/confirm": {
|
55 |
+
"version": "5.1.9",
|
56 |
+
"resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-5.1.9.tgz",
|
57 |
+
"integrity": "sha512-NgQCnHqFTjF7Ys2fsqK2WtnA8X1kHyInyG+nMIuHowVTIgIuS10T4AznI/PvbqSpJqjCUqNBlKGh1v3bwLFL4w==",
|
58 |
+
"license": "MIT",
|
59 |
+
"dependencies": {
|
60 |
+
"@inquirer/core": "^10.1.10",
|
61 |
+
"@inquirer/type": "^3.0.6"
|
62 |
+
},
|
63 |
+
"engines": {
|
64 |
+
"node": ">=18"
|
65 |
+
},
|
66 |
+
"peerDependencies": {
|
67 |
+
"@types/node": ">=18"
|
68 |
+
},
|
69 |
+
"peerDependenciesMeta": {
|
70 |
+
"@types/node": {
|
71 |
+
"optional": true
|
72 |
+
}
|
73 |
+
}
|
74 |
+
},
|
75 |
+
"node_modules/@inquirer/core": {
|
76 |
+
"version": "10.1.10",
|
77 |
+
"resolved": "https://registry.npmjs.org/@inquirer/core/-/core-10.1.10.tgz",
|
78 |
+
"integrity": "sha512-roDaKeY1PYY0aCqhRmXihrHjoSW2A00pV3Ke5fTpMCkzcGF64R8e0lw3dK+eLEHwS4vB5RnW1wuQmvzoRul8Mw==",
|
79 |
+
"license": "MIT",
|
80 |
+
"dependencies": {
|
81 |
+
"@inquirer/figures": "^1.0.11",
|
82 |
+
"@inquirer/type": "^3.0.6",
|
83 |
+
"ansi-escapes": "^4.3.2",
|
84 |
+
"cli-width": "^4.1.0",
|
85 |
+
"mute-stream": "^2.0.0",
|
86 |
+
"signal-exit": "^4.1.0",
|
87 |
+
"wrap-ansi": "^6.2.0",
|
88 |
+
"yoctocolors-cjs": "^2.1.2"
|
89 |
+
},
|
90 |
+
"engines": {
|
91 |
+
"node": ">=18"
|
92 |
+
},
|
93 |
+
"peerDependencies": {
|
94 |
+
"@types/node": ">=18"
|
95 |
+
},
|
96 |
+
"peerDependenciesMeta": {
|
97 |
+
"@types/node": {
|
98 |
+
"optional": true
|
99 |
+
}
|
100 |
+
}
|
101 |
+
},
|
102 |
+
"node_modules/@inquirer/figures": {
|
103 |
+
"version": "1.0.11",
|
104 |
+
"resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-1.0.11.tgz",
|
105 |
+
"integrity": "sha512-eOg92lvrn/aRUqbxRyvpEWnrvRuTYRifixHkYVpJiygTgVSBIHDqLh0SrMQXkafvULg3ck11V7xvR+zcgvpHFw==",
|
106 |
+
"license": "MIT",
|
107 |
+
"engines": {
|
108 |
+
"node": ">=18"
|
109 |
+
}
|
110 |
+
},
|
111 |
+
"node_modules/@inquirer/type": {
|
112 |
+
"version": "3.0.6",
|
113 |
+
"resolved": "https://registry.npmjs.org/@inquirer/type/-/type-3.0.6.tgz",
|
114 |
+
"integrity": "sha512-/mKVCtVpyBu3IDarv0G+59KC4stsD5mDsGpYh+GKs1NZT88Jh52+cuoA1AtLk2Q0r/quNl+1cSUyLRHBFeD0XA==",
|
115 |
+
"license": "MIT",
|
116 |
+
"engines": {
|
117 |
+
"node": ">=18"
|
118 |
+
},
|
119 |
+
"peerDependencies": {
|
120 |
+
"@types/node": ">=18"
|
121 |
+
},
|
122 |
+
"peerDependenciesMeta": {
|
123 |
+
"@types/node": {
|
124 |
+
"optional": true
|
125 |
+
}
|
126 |
+
}
|
127 |
+
},
|
128 |
+
"node_modules/@mswjs/interceptors": {
|
129 |
+
"version": "0.37.6",
|
130 |
+
"resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.37.6.tgz",
|
131 |
+
"integrity": "sha512-wK+5pLK5XFmgtH3aQ2YVvA3HohS3xqV/OxuVOdNx9Wpnz7VE/fnC+e1A7ln6LFYeck7gOJ/dsZV6OLplOtAJ2w==",
|
132 |
+
"license": "MIT",
|
133 |
+
"dependencies": {
|
134 |
+
"@open-draft/deferred-promise": "^2.2.0",
|
135 |
+
"@open-draft/logger": "^0.3.0",
|
136 |
+
"@open-draft/until": "^2.0.0",
|
137 |
+
"is-node-process": "^1.2.0",
|
138 |
+
"outvariant": "^1.4.3",
|
139 |
+
"strict-event-emitter": "^0.5.1"
|
140 |
+
},
|
141 |
+
"engines": {
|
142 |
+
"node": ">=18"
|
143 |
+
}
|
144 |
+
},
|
145 |
+
"node_modules/@open-draft/deferred-promise": {
|
146 |
+
"version": "2.2.0",
|
147 |
+
"resolved": "https://registry.npmjs.org/@open-draft/deferred-promise/-/deferred-promise-2.2.0.tgz",
|
148 |
+
"integrity": "sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA==",
|
149 |
+
"license": "MIT"
|
150 |
+
},
|
151 |
+
"node_modules/@open-draft/logger": {
|
152 |
+
"version": "0.3.0",
|
153 |
+
"resolved": "https://registry.npmjs.org/@open-draft/logger/-/logger-0.3.0.tgz",
|
154 |
+
"integrity": "sha512-X2g45fzhxH238HKO4xbSr7+wBS8Fvw6ixhTDuvLd5mqh6bJJCFAPwU9mPDxbcrRtfxv4u5IHCEH77BmxvXmmxQ==",
|
155 |
+
"license": "MIT",
|
156 |
+
"dependencies": {
|
157 |
+
"is-node-process": "^1.2.0",
|
158 |
+
"outvariant": "^1.4.0"
|
159 |
+
}
|
160 |
+
},
|
161 |
+
"node_modules/@open-draft/until": {
|
162 |
+
"version": "2.1.0",
|
163 |
+
"resolved": "https://registry.npmjs.org/@open-draft/until/-/until-2.1.0.tgz",
|
164 |
+
"integrity": "sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==",
|
165 |
+
"license": "MIT"
|
166 |
+
},
|
167 |
+
"node_modules/@types/cookie": {
|
168 |
+
"version": "0.6.0",
|
169 |
+
"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz",
|
170 |
+
"integrity": "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==",
|
171 |
+
"license": "MIT"
|
172 |
+
},
|
173 |
+
"node_modules/@types/eventsource": {
|
174 |
+
"version": "1.1.15",
|
175 |
+
"resolved": "https://registry.npmjs.org/@types/eventsource/-/eventsource-1.1.15.tgz",
|
176 |
+
"integrity": "sha512-XQmGcbnxUNa06HR3VBVkc9+A2Vpi9ZyLJcdS5dwaQQ/4ZMWFO+5c90FnMUpbtMZwB/FChoYHwuVg8TvkECacTA==",
|
177 |
+
"license": "MIT"
|
178 |
+
},
|
179 |
+
"node_modules/@types/statuses": {
|
180 |
+
"version": "2.0.5",
|
181 |
+
"resolved": "https://registry.npmjs.org/@types/statuses/-/statuses-2.0.5.tgz",
|
182 |
+
"integrity": "sha512-jmIUGWrAiwu3dZpxntxieC+1n/5c3mjrImkmOSQ2NC5uP6cYO4aAZDdSmRcI5C1oiTmqlZGHC+/NmJrKogbP5A==",
|
183 |
+
"license": "MIT"
|
184 |
+
},
|
185 |
+
"node_modules/@types/tough-cookie": {
|
186 |
+
"version": "4.0.5",
|
187 |
+
"resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.5.tgz",
|
188 |
+
"integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==",
|
189 |
+
"license": "MIT"
|
190 |
+
},
|
191 |
+
"node_modules/ansi-escapes": {
|
192 |
+
"version": "4.3.2",
|
193 |
+
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz",
|
194 |
+
"integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==",
|
195 |
+
"license": "MIT",
|
196 |
+
"dependencies": {
|
197 |
+
"type-fest": "^0.21.3"
|
198 |
+
},
|
199 |
+
"engines": {
|
200 |
+
"node": ">=8"
|
201 |
+
},
|
202 |
+
"funding": {
|
203 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
204 |
+
}
|
205 |
+
},
|
206 |
+
"node_modules/ansi-escapes/node_modules/type-fest": {
|
207 |
+
"version": "0.21.3",
|
208 |
+
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz",
|
209 |
+
"integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==",
|
210 |
+
"license": "(MIT OR CC0-1.0)",
|
211 |
+
"engines": {
|
212 |
+
"node": ">=10"
|
213 |
+
},
|
214 |
+
"funding": {
|
215 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
216 |
+
}
|
217 |
+
},
|
218 |
+
"node_modules/ansi-regex": {
|
219 |
+
"version": "5.0.1",
|
220 |
+
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
221 |
+
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
222 |
+
"license": "MIT",
|
223 |
+
"engines": {
|
224 |
+
"node": ">=8"
|
225 |
+
}
|
226 |
+
},
|
227 |
+
"node_modules/ansi-styles": {
|
228 |
+
"version": "4.3.0",
|
229 |
+
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
230 |
+
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
231 |
+
"license": "MIT",
|
232 |
+
"dependencies": {
|
233 |
+
"color-convert": "^2.0.1"
|
234 |
+
},
|
235 |
+
"engines": {
|
236 |
+
"node": ">=8"
|
237 |
+
},
|
238 |
+
"funding": {
|
239 |
+
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
240 |
+
}
|
241 |
+
},
|
242 |
+
"node_modules/bufferutil": {
|
243 |
+
"version": "4.0.9",
|
244 |
+
"resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.9.tgz",
|
245 |
+
"integrity": "sha512-WDtdLmJvAuNNPzByAYpRo2rF1Mmradw6gvWsQKf63476DDXmomT9zUiGypLcG4ibIM67vhAj8jJRdbmEws2Aqw==",
|
246 |
+
"hasInstallScript": true,
|
247 |
+
"license": "MIT",
|
248 |
+
"dependencies": {
|
249 |
+
"node-gyp-build": "^4.3.0"
|
250 |
+
},
|
251 |
+
"engines": {
|
252 |
+
"node": ">=6.14.2"
|
253 |
+
}
|
254 |
+
},
|
255 |
+
"node_modules/cli-width": {
|
256 |
+
"version": "4.1.0",
|
257 |
+
"resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz",
|
258 |
+
"integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==",
|
259 |
+
"license": "ISC",
|
260 |
+
"engines": {
|
261 |
+
"node": ">= 12"
|
262 |
+
}
|
263 |
+
},
|
264 |
+
"node_modules/cliui": {
|
265 |
+
"version": "8.0.1",
|
266 |
+
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
|
267 |
+
"integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==",
|
268 |
+
"license": "ISC",
|
269 |
+
"dependencies": {
|
270 |
+
"string-width": "^4.2.0",
|
271 |
+
"strip-ansi": "^6.0.1",
|
272 |
+
"wrap-ansi": "^7.0.0"
|
273 |
+
},
|
274 |
+
"engines": {
|
275 |
+
"node": ">=12"
|
276 |
+
}
|
277 |
+
},
|
278 |
+
"node_modules/cliui/node_modules/wrap-ansi": {
|
279 |
+
"version": "7.0.0",
|
280 |
+
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
|
281 |
+
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
|
282 |
+
"license": "MIT",
|
283 |
+
"dependencies": {
|
284 |
+
"ansi-styles": "^4.0.0",
|
285 |
+
"string-width": "^4.1.0",
|
286 |
+
"strip-ansi": "^6.0.0"
|
287 |
+
},
|
288 |
+
"engines": {
|
289 |
+
"node": ">=10"
|
290 |
+
},
|
291 |
+
"funding": {
|
292 |
+
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
|
293 |
+
}
|
294 |
+
},
|
295 |
+
"node_modules/color-convert": {
|
296 |
+
"version": "2.0.1",
|
297 |
+
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
298 |
+
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
299 |
+
"license": "MIT",
|
300 |
+
"dependencies": {
|
301 |
+
"color-name": "~1.1.4"
|
302 |
+
},
|
303 |
+
"engines": {
|
304 |
+
"node": ">=7.0.0"
|
305 |
+
}
|
306 |
+
},
|
307 |
+
"node_modules/color-name": {
|
308 |
+
"version": "1.1.4",
|
309 |
+
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
310 |
+
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
311 |
+
"license": "MIT"
|
312 |
+
},
|
313 |
+
"node_modules/cookie": {
|
314 |
+
"version": "0.7.2",
|
315 |
+
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
|
316 |
+
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
|
317 |
+
"license": "MIT",
|
318 |
+
"engines": {
|
319 |
+
"node": ">= 0.6"
|
320 |
+
}
|
321 |
+
},
|
322 |
+
"node_modules/emoji-regex": {
|
323 |
+
"version": "8.0.0",
|
324 |
+
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
325 |
+
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
|
326 |
+
"license": "MIT"
|
327 |
+
},
|
328 |
+
"node_modules/escalade": {
|
329 |
+
"version": "3.2.0",
|
330 |
+
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
|
331 |
+
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
|
332 |
+
"license": "MIT",
|
333 |
+
"engines": {
|
334 |
+
"node": ">=6"
|
335 |
+
}
|
336 |
+
},
|
337 |
+
"node_modules/eventsource": {
|
338 |
+
"version": "2.0.2",
|
339 |
+
"resolved": "https://registry.npmjs.org/eventsource/-/eventsource-2.0.2.tgz",
|
340 |
+
"integrity": "sha512-IzUmBGPR3+oUG9dUeXynyNmf91/3zUSJg1lCktzKw47OXuhco54U3r9B7O4XX+Rb1Itm9OZ2b0RkTs10bICOxA==",
|
341 |
+
"license": "MIT",
|
342 |
+
"engines": {
|
343 |
+
"node": ">=12.0.0"
|
344 |
+
}
|
345 |
+
},
|
346 |
+
"node_modules/fetch-event-stream": {
|
347 |
+
"version": "0.1.5",
|
348 |
+
"resolved": "https://registry.npmjs.org/fetch-event-stream/-/fetch-event-stream-0.1.5.tgz",
|
349 |
+
"integrity": "sha512-V1PWovkspxQfssq/NnxoEyQo1DV+MRK/laPuPblIZmSjMN8P5u46OhlFQznSr9p/t0Sp8Uc6SbM3yCMfr0KU8g==",
|
350 |
+
"license": "MIT"
|
351 |
+
},
|
352 |
+
"node_modules/get-caller-file": {
|
353 |
+
"version": "2.0.5",
|
354 |
+
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
|
355 |
+
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
|
356 |
+
"license": "ISC",
|
357 |
+
"engines": {
|
358 |
+
"node": "6.* || 8.* || >= 10.*"
|
359 |
+
}
|
360 |
+
},
|
361 |
+
"node_modules/graphql": {
|
362 |
+
"version": "16.10.0",
|
363 |
+
"resolved": "https://registry.npmjs.org/graphql/-/graphql-16.10.0.tgz",
|
364 |
+
"integrity": "sha512-AjqGKbDGUFRKIRCP9tCKiIGHyriz2oHEbPIbEtcSLSs4YjReZOIPQQWek4+6hjw62H9QShXHyaGivGiYVLeYFQ==",
|
365 |
+
"license": "MIT",
|
366 |
+
"engines": {
|
367 |
+
"node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0"
|
368 |
+
}
|
369 |
+
},
|
370 |
+
"node_modules/headers-polyfill": {
|
371 |
+
"version": "4.0.3",
|
372 |
+
"resolved": "https://registry.npmjs.org/headers-polyfill/-/headers-polyfill-4.0.3.tgz",
|
373 |
+
"integrity": "sha512-IScLbePpkvO846sIwOtOTDjutRMWdXdJmXdMvk6gCBHxFO8d+QKOQedyZSxFTTFYRSmlgSTDtXqqq4pcenBXLQ==",
|
374 |
+
"license": "MIT"
|
375 |
+
},
|
376 |
+
"node_modules/is-fullwidth-code-point": {
|
377 |
+
"version": "3.0.0",
|
378 |
+
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
|
379 |
+
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
|
380 |
+
"license": "MIT",
|
381 |
+
"engines": {
|
382 |
+
"node": ">=8"
|
383 |
+
}
|
384 |
+
},
|
385 |
+
"node_modules/is-node-process": {
|
386 |
+
"version": "1.2.0",
|
387 |
+
"resolved": "https://registry.npmjs.org/is-node-process/-/is-node-process-1.2.0.tgz",
|
388 |
+
"integrity": "sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw==",
|
389 |
+
"license": "MIT"
|
390 |
+
},
|
391 |
+
"node_modules/msw": {
|
392 |
+
"version": "2.7.3",
|
393 |
+
"resolved": "https://registry.npmjs.org/msw/-/msw-2.7.3.tgz",
|
394 |
+
"integrity": "sha512-+mycXv8l2fEAjFZ5sjrtjJDmm2ceKGjrNbBr1durRg6VkU9fNUE/gsmQ51hWbHqs+l35W1iM+ZsmOD9Fd6lspw==",
|
395 |
+
"hasInstallScript": true,
|
396 |
+
"license": "MIT",
|
397 |
+
"dependencies": {
|
398 |
+
"@bundled-es-modules/cookie": "^2.0.1",
|
399 |
+
"@bundled-es-modules/statuses": "^1.0.1",
|
400 |
+
"@bundled-es-modules/tough-cookie": "^0.1.6",
|
401 |
+
"@inquirer/confirm": "^5.0.0",
|
402 |
+
"@mswjs/interceptors": "^0.37.0",
|
403 |
+
"@open-draft/deferred-promise": "^2.2.0",
|
404 |
+
"@open-draft/until": "^2.1.0",
|
405 |
+
"@types/cookie": "^0.6.0",
|
406 |
+
"@types/statuses": "^2.0.4",
|
407 |
+
"graphql": "^16.8.1",
|
408 |
+
"headers-polyfill": "^4.0.2",
|
409 |
+
"is-node-process": "^1.2.0",
|
410 |
+
"outvariant": "^1.4.3",
|
411 |
+
"path-to-regexp": "^6.3.0",
|
412 |
+
"picocolors": "^1.1.1",
|
413 |
+
"strict-event-emitter": "^0.5.1",
|
414 |
+
"type-fest": "^4.26.1",
|
415 |
+
"yargs": "^17.7.2"
|
416 |
+
},
|
417 |
+
"bin": {
|
418 |
+
"msw": "cli/index.js"
|
419 |
+
},
|
420 |
+
"engines": {
|
421 |
+
"node": ">=18"
|
422 |
+
},
|
423 |
+
"funding": {
|
424 |
+
"url": "https://github.com/sponsors/mswjs"
|
425 |
+
},
|
426 |
+
"peerDependencies": {
|
427 |
+
"typescript": ">= 4.8.x"
|
428 |
+
},
|
429 |
+
"peerDependenciesMeta": {
|
430 |
+
"typescript": {
|
431 |
+
"optional": true
|
432 |
+
}
|
433 |
+
}
|
434 |
+
},
|
435 |
+
"node_modules/mute-stream": {
|
436 |
+
"version": "2.0.0",
|
437 |
+
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-2.0.0.tgz",
|
438 |
+
"integrity": "sha512-WWdIxpyjEn+FhQJQQv9aQAYlHoNVdzIzUySNV1gHUPDSdZJ3yZn7pAAbQcV7B56Mvu881q9FZV+0Vx2xC44VWA==",
|
439 |
+
"license": "ISC",
|
440 |
+
"engines": {
|
441 |
+
"node": "^18.17.0 || >=20.5.0"
|
442 |
+
}
|
443 |
+
},
|
444 |
+
"node_modules/node-gyp-build": {
|
445 |
+
"version": "4.8.4",
|
446 |
+
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.4.tgz",
|
447 |
+
"integrity": "sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==",
|
448 |
+
"license": "MIT",
|
449 |
+
"bin": {
|
450 |
+
"node-gyp-build": "bin.js",
|
451 |
+
"node-gyp-build-optional": "optional.js",
|
452 |
+
"node-gyp-build-test": "build-test.js"
|
453 |
+
}
|
454 |
+
},
|
455 |
+
"node_modules/outvariant": {
|
456 |
+
"version": "1.4.3",
|
457 |
+
"resolved": "https://registry.npmjs.org/outvariant/-/outvariant-1.4.3.tgz",
|
458 |
+
"integrity": "sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA==",
|
459 |
+
"license": "MIT"
|
460 |
+
},
|
461 |
+
"node_modules/path-to-regexp": {
|
462 |
+
"version": "6.3.0",
|
463 |
+
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz",
|
464 |
+
"integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==",
|
465 |
+
"license": "MIT"
|
466 |
+
},
|
467 |
+
"node_modules/picocolors": {
|
468 |
+
"version": "1.1.1",
|
469 |
+
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
470 |
+
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
|
471 |
+
"license": "ISC"
|
472 |
+
},
|
473 |
+
"node_modules/psl": {
|
474 |
+
"version": "1.15.0",
|
475 |
+
"resolved": "https://registry.npmjs.org/psl/-/psl-1.15.0.tgz",
|
476 |
+
"integrity": "sha512-JZd3gMVBAVQkSs6HdNZo9Sdo0LNcQeMNP3CozBJb3JYC/QUYZTnKxP+f8oWRX4rHP5EurWxqAHTSwUCjlNKa1w==",
|
477 |
+
"license": "MIT",
|
478 |
+
"dependencies": {
|
479 |
+
"punycode": "^2.3.1"
|
480 |
+
},
|
481 |
+
"funding": {
|
482 |
+
"url": "https://github.com/sponsors/lupomontero"
|
483 |
+
}
|
484 |
+
},
|
485 |
+
"node_modules/punycode": {
|
486 |
+
"version": "2.3.1",
|
487 |
+
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
488 |
+
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
|
489 |
+
"license": "MIT",
|
490 |
+
"engines": {
|
491 |
+
"node": ">=6"
|
492 |
+
}
|
493 |
+
},
|
494 |
+
"node_modules/querystringify": {
|
495 |
+
"version": "2.2.0",
|
496 |
+
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
|
497 |
+
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==",
|
498 |
+
"license": "MIT"
|
499 |
+
},
|
500 |
+
"node_modules/require-directory": {
|
501 |
+
"version": "2.1.1",
|
502 |
+
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
503 |
+
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
|
504 |
+
"license": "MIT",
|
505 |
+
"engines": {
|
506 |
+
"node": ">=0.10.0"
|
507 |
+
}
|
508 |
+
},
|
509 |
+
"node_modules/requires-port": {
|
510 |
+
"version": "1.0.0",
|
511 |
+
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
|
512 |
+
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==",
|
513 |
+
"license": "MIT"
|
514 |
+
},
|
515 |
+
"node_modules/semiver": {
|
516 |
+
"version": "1.1.0",
|
517 |
+
"resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz",
|
518 |
+
"integrity": "sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg==",
|
519 |
+
"license": "MIT",
|
520 |
+
"engines": {
|
521 |
+
"node": ">=6"
|
522 |
+
}
|
523 |
+
},
|
524 |
+
"node_modules/signal-exit": {
|
525 |
+
"version": "4.1.0",
|
526 |
+
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
|
527 |
+
"integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
|
528 |
+
"license": "ISC",
|
529 |
+
"engines": {
|
530 |
+
"node": ">=14"
|
531 |
+
},
|
532 |
+
"funding": {
|
533 |
+
"url": "https://github.com/sponsors/isaacs"
|
534 |
+
}
|
535 |
+
},
|
536 |
+
"node_modules/statuses": {
|
537 |
+
"version": "2.0.1",
|
538 |
+
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
|
539 |
+
"integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
|
540 |
+
"license": "MIT",
|
541 |
+
"engines": {
|
542 |
+
"node": ">= 0.8"
|
543 |
+
}
|
544 |
+
},
|
545 |
+
"node_modules/strict-event-emitter": {
|
546 |
+
"version": "0.5.1",
|
547 |
+
"resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.5.1.tgz",
|
548 |
+
"integrity": "sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==",
|
549 |
+
"license": "MIT"
|
550 |
+
},
|
551 |
+
"node_modules/string-width": {
|
552 |
+
"version": "4.2.3",
|
553 |
+
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
554 |
+
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
|
555 |
+
"license": "MIT",
|
556 |
+
"dependencies": {
|
557 |
+
"emoji-regex": "^8.0.0",
|
558 |
+
"is-fullwidth-code-point": "^3.0.0",
|
559 |
+
"strip-ansi": "^6.0.1"
|
560 |
+
},
|
561 |
+
"engines": {
|
562 |
+
"node": ">=8"
|
563 |
+
}
|
564 |
+
},
|
565 |
+
"node_modules/strip-ansi": {
|
566 |
+
"version": "6.0.1",
|
567 |
+
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
|
568 |
+
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
|
569 |
+
"license": "MIT",
|
570 |
+
"dependencies": {
|
571 |
+
"ansi-regex": "^5.0.1"
|
572 |
+
},
|
573 |
+
"engines": {
|
574 |
+
"node": ">=8"
|
575 |
+
}
|
576 |
+
},
|
577 |
+
"node_modules/textlinestream": {
|
578 |
+
"version": "1.1.1",
|
579 |
+
"resolved": "https://registry.npmjs.org/textlinestream/-/textlinestream-1.1.1.tgz",
|
580 |
+
"integrity": "sha512-iBHbi7BQxrFmwZUQJsT0SjNzlLLsXhvW/kg7EyOMVMBIrlnj/qYofwo1LVLZi+3GbUEo96Iu2eqToI2+lZoAEQ==",
|
581 |
+
"license": "MIT"
|
582 |
+
},
|
583 |
+
"node_modules/tough-cookie": {
|
584 |
+
"version": "4.1.4",
|
585 |
+
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.4.tgz",
|
586 |
+
"integrity": "sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag==",
|
587 |
+
"license": "BSD-3-Clause",
|
588 |
+
"dependencies": {
|
589 |
+
"psl": "^1.1.33",
|
590 |
+
"punycode": "^2.1.1",
|
591 |
+
"universalify": "^0.2.0",
|
592 |
+
"url-parse": "^1.5.3"
|
593 |
+
},
|
594 |
+
"engines": {
|
595 |
+
"node": ">=6"
|
596 |
+
}
|
597 |
+
},
|
598 |
+
"node_modules/type-fest": {
|
599 |
+
"version": "4.39.1",
|
600 |
+
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.39.1.tgz",
|
601 |
+
"integrity": "sha512-uW9qzd66uyHYxwyVBYiwS4Oi0qZyUqwjU+Oevr6ZogYiXt99EOYtwvzMSLw1c3lYo2HzJsep/NB23iEVEgjG/w==",
|
602 |
+
"license": "(MIT OR CC0-1.0)",
|
603 |
+
"engines": {
|
604 |
+
"node": ">=16"
|
605 |
+
},
|
606 |
+
"funding": {
|
607 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
608 |
+
}
|
609 |
+
},
|
610 |
+
"node_modules/typescript": {
|
611 |
+
"version": "5.8.3",
|
612 |
+
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
|
613 |
+
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
|
614 |
+
"license": "Apache-2.0",
|
615 |
+
"bin": {
|
616 |
+
"tsc": "bin/tsc",
|
617 |
+
"tsserver": "bin/tsserver"
|
618 |
+
},
|
619 |
+
"engines": {
|
620 |
+
"node": ">=14.17"
|
621 |
+
}
|
622 |
+
},
|
623 |
+
"node_modules/universalify": {
|
624 |
+
"version": "0.2.0",
|
625 |
+
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz",
|
626 |
+
"integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==",
|
627 |
+
"license": "MIT",
|
628 |
+
"engines": {
|
629 |
+
"node": ">= 4.0.0"
|
630 |
+
}
|
631 |
+
},
|
632 |
+
"node_modules/url-parse": {
|
633 |
+
"version": "1.5.10",
|
634 |
+
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz",
|
635 |
+
"integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==",
|
636 |
+
"license": "MIT",
|
637 |
+
"dependencies": {
|
638 |
+
"querystringify": "^2.1.1",
|
639 |
+
"requires-port": "^1.0.0"
|
640 |
+
}
|
641 |
+
},
|
642 |
+
"node_modules/wrap-ansi": {
|
643 |
+
"version": "6.2.0",
|
644 |
+
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
|
645 |
+
"integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
|
646 |
+
"license": "MIT",
|
647 |
+
"dependencies": {
|
648 |
+
"ansi-styles": "^4.0.0",
|
649 |
+
"string-width": "^4.1.0",
|
650 |
+
"strip-ansi": "^6.0.0"
|
651 |
+
},
|
652 |
+
"engines": {
|
653 |
+
"node": ">=8"
|
654 |
+
}
|
655 |
+
},
|
656 |
+
"node_modules/ws": {
|
657 |
+
"version": "8.18.1",
|
658 |
+
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.1.tgz",
|
659 |
+
"integrity": "sha512-RKW2aJZMXeMxVpnZ6bck+RswznaxmzdULiBr6KY7XkTnW8uvt0iT9H5DkHUChXrc+uurzwa0rVI16n/Xzjdz1w==",
|
660 |
+
"license": "MIT",
|
661 |
+
"engines": {
|
662 |
+
"node": ">=10.0.0"
|
663 |
+
},
|
664 |
+
"peerDependencies": {
|
665 |
+
"bufferutil": "^4.0.1",
|
666 |
+
"utf-8-validate": ">=5.0.2"
|
667 |
+
},
|
668 |
+
"peerDependenciesMeta": {
|
669 |
+
"bufferutil": {
|
670 |
+
"optional": true
|
671 |
+
},
|
672 |
+
"utf-8-validate": {
|
673 |
+
"optional": true
|
674 |
+
}
|
675 |
+
}
|
676 |
+
},
|
677 |
+
"node_modules/y18n": {
|
678 |
+
"version": "5.0.8",
|
679 |
+
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
680 |
+
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
|
681 |
+
"license": "ISC",
|
682 |
+
"engines": {
|
683 |
+
"node": ">=10"
|
684 |
+
}
|
685 |
+
},
|
686 |
+
"node_modules/yargs": {
|
687 |
+
"version": "17.7.2",
|
688 |
+
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",
|
689 |
+
"integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",
|
690 |
+
"license": "MIT",
|
691 |
+
"dependencies": {
|
692 |
+
"cliui": "^8.0.1",
|
693 |
+
"escalade": "^3.1.1",
|
694 |
+
"get-caller-file": "^2.0.5",
|
695 |
+
"require-directory": "^2.1.1",
|
696 |
+
"string-width": "^4.2.3",
|
697 |
+
"y18n": "^5.0.5",
|
698 |
+
"yargs-parser": "^21.1.1"
|
699 |
+
},
|
700 |
+
"engines": {
|
701 |
+
"node": ">=12"
|
702 |
+
}
|
703 |
+
},
|
704 |
+
"node_modules/yargs-parser": {
|
705 |
+
"version": "21.1.1",
|
706 |
+
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
|
707 |
+
"integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
|
708 |
+
"license": "ISC",
|
709 |
+
"engines": {
|
710 |
+
"node": ">=12"
|
711 |
+
}
|
712 |
+
},
|
713 |
+
"node_modules/yoctocolors-cjs": {
|
714 |
+
"version": "2.1.2",
|
715 |
+
"resolved": "https://registry.npmjs.org/yoctocolors-cjs/-/yoctocolors-cjs-2.1.2.tgz",
|
716 |
+
"integrity": "sha512-cYVsTjKl8b+FrnidjibDWskAv7UKOfcwaVZdp/it9n1s9fU3IkgDbhdIRKCW4JDsAlECJY0ytoVPT3sK6kideA==",
|
717 |
+
"license": "MIT",
|
718 |
+
"engines": {
|
719 |
+
"node": ">=18"
|
720 |
+
},
|
721 |
+
"funding": {
|
722 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
723 |
+
}
|
724 |
+
}
|
725 |
+
}
|
726 |
+
}
|
node_modules/@bundled-es-modules/cookie/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# cookie
|
2 |
+
|
3 |
+
This is a mirror of [cookie](https://www.npmjs.com/package/cookie), bundled and exposed as ES module.
|
4 |
+
|
5 |
+
## Install
|
6 |
+
|
7 |
+
```
|
8 |
+
npm install @bundled-es-modules/cookie
|
9 |
+
```
|
10 |
+
|
11 |
+
## Use
|
12 |
+
|
13 |
+
```html
|
14 |
+
<script type="module">
|
15 |
+
import cookie from '@bundled-es-modules/cookie';
|
16 |
+
cookie.parse('foo=bar;'); // { foo: 'bar' }
|
17 |
+
</script>
|
18 |
+
```
|
node_modules/@bundled-es-modules/cookie/index-cjs.cjs
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
const cookie = require('cookie');
|
2 |
+
module.exports = cookie;
|
node_modules/@bundled-es-modules/cookie/index-esm.js
ADDED
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var __create = Object.create;
|
2 |
+
var __defProp = Object.defineProperty;
|
3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5 |
+
var __getProtoOf = Object.getPrototypeOf;
|
6 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7 |
+
var __commonJS = (cb, mod) => function __require() {
|
8 |
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
9 |
+
};
|
10 |
+
var __copyProps = (to, from, except, desc) => {
|
11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
12 |
+
for (let key of __getOwnPropNames(from))
|
13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15 |
+
}
|
16 |
+
return to;
|
17 |
+
};
|
18 |
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
19 |
+
// If the importer is in node compatibility mode or this is not an ESM
|
20 |
+
// file that has been converted to a CommonJS file using a Babel-
|
21 |
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
22 |
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
23 |
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
24 |
+
mod
|
25 |
+
));
|
26 |
+
|
27 |
+
// node_modules/cookie/index.js
|
28 |
+
var require_cookie = __commonJS({
|
29 |
+
"node_modules/cookie/index.js"(exports) {
|
30 |
+
"use strict";
|
31 |
+
exports.parse = parse;
|
32 |
+
exports.serialize = serialize;
|
33 |
+
var __toString = Object.prototype.toString;
|
34 |
+
var __hasOwnProperty = Object.prototype.hasOwnProperty;
|
35 |
+
var cookieNameRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
36 |
+
var cookieValueRegExp = /^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/;
|
37 |
+
var domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
|
38 |
+
var pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
|
39 |
+
function parse(str, opt) {
|
40 |
+
if (typeof str !== "string") {
|
41 |
+
throw new TypeError("argument str must be a string");
|
42 |
+
}
|
43 |
+
var obj = {};
|
44 |
+
var len = str.length;
|
45 |
+
if (len < 2) return obj;
|
46 |
+
var dec = opt && opt.decode || decode;
|
47 |
+
var index = 0;
|
48 |
+
var eqIdx = 0;
|
49 |
+
var endIdx = 0;
|
50 |
+
do {
|
51 |
+
eqIdx = str.indexOf("=", index);
|
52 |
+
if (eqIdx === -1) break;
|
53 |
+
endIdx = str.indexOf(";", index);
|
54 |
+
if (endIdx === -1) {
|
55 |
+
endIdx = len;
|
56 |
+
} else if (eqIdx > endIdx) {
|
57 |
+
index = str.lastIndexOf(";", eqIdx - 1) + 1;
|
58 |
+
continue;
|
59 |
+
}
|
60 |
+
var keyStartIdx = startIndex(str, index, eqIdx);
|
61 |
+
var keyEndIdx = endIndex(str, eqIdx, keyStartIdx);
|
62 |
+
var key = str.slice(keyStartIdx, keyEndIdx);
|
63 |
+
if (!__hasOwnProperty.call(obj, key)) {
|
64 |
+
var valStartIdx = startIndex(str, eqIdx + 1, endIdx);
|
65 |
+
var valEndIdx = endIndex(str, endIdx, valStartIdx);
|
66 |
+
if (str.charCodeAt(valStartIdx) === 34 && str.charCodeAt(valEndIdx - 1) === 34) {
|
67 |
+
valStartIdx++;
|
68 |
+
valEndIdx--;
|
69 |
+
}
|
70 |
+
var val = str.slice(valStartIdx, valEndIdx);
|
71 |
+
obj[key] = tryDecode(val, dec);
|
72 |
+
}
|
73 |
+
index = endIdx + 1;
|
74 |
+
} while (index < len);
|
75 |
+
return obj;
|
76 |
+
}
|
77 |
+
function startIndex(str, index, max) {
|
78 |
+
do {
|
79 |
+
var code = str.charCodeAt(index);
|
80 |
+
if (code !== 32 && code !== 9) return index;
|
81 |
+
} while (++index < max);
|
82 |
+
return max;
|
83 |
+
}
|
84 |
+
function endIndex(str, index, min) {
|
85 |
+
while (index > min) {
|
86 |
+
var code = str.charCodeAt(--index);
|
87 |
+
if (code !== 32 && code !== 9) return index + 1;
|
88 |
+
}
|
89 |
+
return min;
|
90 |
+
}
|
91 |
+
function serialize(name, val, opt) {
|
92 |
+
var enc = opt && opt.encode || encodeURIComponent;
|
93 |
+
if (typeof enc !== "function") {
|
94 |
+
throw new TypeError("option encode is invalid");
|
95 |
+
}
|
96 |
+
if (!cookieNameRegExp.test(name)) {
|
97 |
+
throw new TypeError("argument name is invalid");
|
98 |
+
}
|
99 |
+
var value = enc(val);
|
100 |
+
if (!cookieValueRegExp.test(value)) {
|
101 |
+
throw new TypeError("argument val is invalid");
|
102 |
+
}
|
103 |
+
var str = name + "=" + value;
|
104 |
+
if (!opt) return str;
|
105 |
+
if (null != opt.maxAge) {
|
106 |
+
var maxAge = Math.floor(opt.maxAge);
|
107 |
+
if (!isFinite(maxAge)) {
|
108 |
+
throw new TypeError("option maxAge is invalid");
|
109 |
+
}
|
110 |
+
str += "; Max-Age=" + maxAge;
|
111 |
+
}
|
112 |
+
if (opt.domain) {
|
113 |
+
if (!domainValueRegExp.test(opt.domain)) {
|
114 |
+
throw new TypeError("option domain is invalid");
|
115 |
+
}
|
116 |
+
str += "; Domain=" + opt.domain;
|
117 |
+
}
|
118 |
+
if (opt.path) {
|
119 |
+
if (!pathValueRegExp.test(opt.path)) {
|
120 |
+
throw new TypeError("option path is invalid");
|
121 |
+
}
|
122 |
+
str += "; Path=" + opt.path;
|
123 |
+
}
|
124 |
+
if (opt.expires) {
|
125 |
+
var expires = opt.expires;
|
126 |
+
if (!isDate(expires) || isNaN(expires.valueOf())) {
|
127 |
+
throw new TypeError("option expires is invalid");
|
128 |
+
}
|
129 |
+
str += "; Expires=" + expires.toUTCString();
|
130 |
+
}
|
131 |
+
if (opt.httpOnly) {
|
132 |
+
str += "; HttpOnly";
|
133 |
+
}
|
134 |
+
if (opt.secure) {
|
135 |
+
str += "; Secure";
|
136 |
+
}
|
137 |
+
if (opt.partitioned) {
|
138 |
+
str += "; Partitioned";
|
139 |
+
}
|
140 |
+
if (opt.priority) {
|
141 |
+
var priority = typeof opt.priority === "string" ? opt.priority.toLowerCase() : opt.priority;
|
142 |
+
switch (priority) {
|
143 |
+
case "low":
|
144 |
+
str += "; Priority=Low";
|
145 |
+
break;
|
146 |
+
case "medium":
|
147 |
+
str += "; Priority=Medium";
|
148 |
+
break;
|
149 |
+
case "high":
|
150 |
+
str += "; Priority=High";
|
151 |
+
break;
|
152 |
+
default:
|
153 |
+
throw new TypeError("option priority is invalid");
|
154 |
+
}
|
155 |
+
}
|
156 |
+
if (opt.sameSite) {
|
157 |
+
var sameSite = typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite;
|
158 |
+
switch (sameSite) {
|
159 |
+
case true:
|
160 |
+
str += "; SameSite=Strict";
|
161 |
+
break;
|
162 |
+
case "lax":
|
163 |
+
str += "; SameSite=Lax";
|
164 |
+
break;
|
165 |
+
case "strict":
|
166 |
+
str += "; SameSite=Strict";
|
167 |
+
break;
|
168 |
+
case "none":
|
169 |
+
str += "; SameSite=None";
|
170 |
+
break;
|
171 |
+
default:
|
172 |
+
throw new TypeError("option sameSite is invalid");
|
173 |
+
}
|
174 |
+
}
|
175 |
+
return str;
|
176 |
+
}
|
177 |
+
function decode(str) {
|
178 |
+
return str.indexOf("%") !== -1 ? decodeURIComponent(str) : str;
|
179 |
+
}
|
180 |
+
function isDate(val) {
|
181 |
+
return __toString.call(val) === "[object Date]";
|
182 |
+
}
|
183 |
+
function tryDecode(str, decode2) {
|
184 |
+
try {
|
185 |
+
return decode2(str);
|
186 |
+
} catch (e) {
|
187 |
+
return str;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
}
|
191 |
+
});
|
192 |
+
|
193 |
+
// source.js
|
194 |
+
var import_cookie = __toESM(require_cookie(), 1);
|
195 |
+
var source_default = import_cookie.default;
|
196 |
+
export {
|
197 |
+
source_default as default
|
198 |
+
};
|
199 |
+
/*! Bundled license information:
|
200 |
+
|
201 |
+
cookie/index.js:
|
202 |
+
(*!
|
203 |
+
* cookie
|
204 |
+
* Copyright(c) 2012-2014 Roman Shtylman
|
205 |
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
206 |
+
* MIT Licensed
|
207 |
+
*)
|
208 |
+
*/
|
node_modules/@bundled-es-modules/cookie/package.json
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@bundled-es-modules/cookie",
|
3 |
+
"version": "2.0.1",
|
4 |
+
"description": "mirror of cookie, bundled and exposed as ES module",
|
5 |
+
"author": "Pascal Schilp <[email protected]>",
|
6 |
+
"main": "index-esm.js",
|
7 |
+
"type": "module",
|
8 |
+
"repository": {
|
9 |
+
"type": "git",
|
10 |
+
"url": "https://github.com/bundled-es-modules/cookie"
|
11 |
+
},
|
12 |
+
"exports": {
|
13 |
+
".": {
|
14 |
+
"import": "./index-esm.js",
|
15 |
+
"require": "./index-cjs.cjs"
|
16 |
+
}
|
17 |
+
},
|
18 |
+
"scripts": {
|
19 |
+
"dev": "node --watch dev.js",
|
20 |
+
"build": "esbuild source.js --bundle --format=esm --outfile=index-esm.js"
|
21 |
+
},
|
22 |
+
"keywords": [],
|
23 |
+
"files": [
|
24 |
+
"index-esm.js",
|
25 |
+
"index-cjs.cjs"
|
26 |
+
],
|
27 |
+
"license": "ISC",
|
28 |
+
"dependencies": {
|
29 |
+
"cookie": "^0.7.2"
|
30 |
+
},
|
31 |
+
"devDependencies": {
|
32 |
+
"esbuild": "^0.24.0"
|
33 |
+
}
|
34 |
+
}
|
node_modules/@bundled-es-modules/statuses/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# statuses
|
2 |
+
|
3 |
+
This is a mirror of [statuses](https://www.npmjs.com/package/statuses), bundled and exposed as ES module.
|
4 |
+
|
5 |
+
## Install
|
6 |
+
|
7 |
+
```
|
8 |
+
npm install @bundled-es-modules/statuses
|
9 |
+
```
|
10 |
+
|
11 |
+
## Use
|
12 |
+
|
13 |
+
```html
|
14 |
+
<script type="module">
|
15 |
+
import status from '@bundled-es-modules/statuses';
|
16 |
+
</script>
|
17 |
+
```
|
node_modules/@bundled-es-modules/statuses/index-cjs.cjs
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
const status = require('statuses');
|
2 |
+
module.exports = status;
|
node_modules/@bundled-es-modules/statuses/index-esm.js
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var __create = Object.create;
|
2 |
+
var __defProp = Object.defineProperty;
|
3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5 |
+
var __getProtoOf = Object.getPrototypeOf;
|
6 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7 |
+
var __commonJS = (cb, mod) => function __require() {
|
8 |
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
9 |
+
};
|
10 |
+
var __copyProps = (to, from, except, desc) => {
|
11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
12 |
+
for (let key of __getOwnPropNames(from))
|
13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15 |
+
}
|
16 |
+
return to;
|
17 |
+
};
|
18 |
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
19 |
+
// If the importer is in node compatibility mode or this is not an ESM
|
20 |
+
// file that has been converted to a CommonJS file using a Babel-
|
21 |
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
22 |
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
23 |
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
24 |
+
mod
|
25 |
+
));
|
26 |
+
|
27 |
+
// node_modules/statuses/codes.json
|
28 |
+
var require_codes = __commonJS({
|
29 |
+
"node_modules/statuses/codes.json"(exports, module) {
|
30 |
+
module.exports = {
|
31 |
+
"100": "Continue",
|
32 |
+
"101": "Switching Protocols",
|
33 |
+
"102": "Processing",
|
34 |
+
"103": "Early Hints",
|
35 |
+
"200": "OK",
|
36 |
+
"201": "Created",
|
37 |
+
"202": "Accepted",
|
38 |
+
"203": "Non-Authoritative Information",
|
39 |
+
"204": "No Content",
|
40 |
+
"205": "Reset Content",
|
41 |
+
"206": "Partial Content",
|
42 |
+
"207": "Multi-Status",
|
43 |
+
"208": "Already Reported",
|
44 |
+
"226": "IM Used",
|
45 |
+
"300": "Multiple Choices",
|
46 |
+
"301": "Moved Permanently",
|
47 |
+
"302": "Found",
|
48 |
+
"303": "See Other",
|
49 |
+
"304": "Not Modified",
|
50 |
+
"305": "Use Proxy",
|
51 |
+
"307": "Temporary Redirect",
|
52 |
+
"308": "Permanent Redirect",
|
53 |
+
"400": "Bad Request",
|
54 |
+
"401": "Unauthorized",
|
55 |
+
"402": "Payment Required",
|
56 |
+
"403": "Forbidden",
|
57 |
+
"404": "Not Found",
|
58 |
+
"405": "Method Not Allowed",
|
59 |
+
"406": "Not Acceptable",
|
60 |
+
"407": "Proxy Authentication Required",
|
61 |
+
"408": "Request Timeout",
|
62 |
+
"409": "Conflict",
|
63 |
+
"410": "Gone",
|
64 |
+
"411": "Length Required",
|
65 |
+
"412": "Precondition Failed",
|
66 |
+
"413": "Payload Too Large",
|
67 |
+
"414": "URI Too Long",
|
68 |
+
"415": "Unsupported Media Type",
|
69 |
+
"416": "Range Not Satisfiable",
|
70 |
+
"417": "Expectation Failed",
|
71 |
+
"418": "I'm a Teapot",
|
72 |
+
"421": "Misdirected Request",
|
73 |
+
"422": "Unprocessable Entity",
|
74 |
+
"423": "Locked",
|
75 |
+
"424": "Failed Dependency",
|
76 |
+
"425": "Too Early",
|
77 |
+
"426": "Upgrade Required",
|
78 |
+
"428": "Precondition Required",
|
79 |
+
"429": "Too Many Requests",
|
80 |
+
"431": "Request Header Fields Too Large",
|
81 |
+
"451": "Unavailable For Legal Reasons",
|
82 |
+
"500": "Internal Server Error",
|
83 |
+
"501": "Not Implemented",
|
84 |
+
"502": "Bad Gateway",
|
85 |
+
"503": "Service Unavailable",
|
86 |
+
"504": "Gateway Timeout",
|
87 |
+
"505": "HTTP Version Not Supported",
|
88 |
+
"506": "Variant Also Negotiates",
|
89 |
+
"507": "Insufficient Storage",
|
90 |
+
"508": "Loop Detected",
|
91 |
+
"509": "Bandwidth Limit Exceeded",
|
92 |
+
"510": "Not Extended",
|
93 |
+
"511": "Network Authentication Required"
|
94 |
+
};
|
95 |
+
}
|
96 |
+
});
|
97 |
+
|
98 |
+
// node_modules/statuses/index.js
|
99 |
+
var require_statuses = __commonJS({
|
100 |
+
"node_modules/statuses/index.js"(exports, module) {
|
101 |
+
"use strict";
|
102 |
+
var codes = require_codes();
|
103 |
+
module.exports = status2;
|
104 |
+
status2.message = codes;
|
105 |
+
status2.code = createMessageToStatusCodeMap(codes);
|
106 |
+
status2.codes = createStatusCodeList(codes);
|
107 |
+
status2.redirect = {
|
108 |
+
300: true,
|
109 |
+
301: true,
|
110 |
+
302: true,
|
111 |
+
303: true,
|
112 |
+
305: true,
|
113 |
+
307: true,
|
114 |
+
308: true
|
115 |
+
};
|
116 |
+
status2.empty = {
|
117 |
+
204: true,
|
118 |
+
205: true,
|
119 |
+
304: true
|
120 |
+
};
|
121 |
+
status2.retry = {
|
122 |
+
502: true,
|
123 |
+
503: true,
|
124 |
+
504: true
|
125 |
+
};
|
126 |
+
function createMessageToStatusCodeMap(codes2) {
|
127 |
+
var map = {};
|
128 |
+
Object.keys(codes2).forEach(function forEachCode(code) {
|
129 |
+
var message = codes2[code];
|
130 |
+
var status3 = Number(code);
|
131 |
+
map[message.toLowerCase()] = status3;
|
132 |
+
});
|
133 |
+
return map;
|
134 |
+
}
|
135 |
+
function createStatusCodeList(codes2) {
|
136 |
+
return Object.keys(codes2).map(function mapCode(code) {
|
137 |
+
return Number(code);
|
138 |
+
});
|
139 |
+
}
|
140 |
+
function getStatusCode(message) {
|
141 |
+
var msg = message.toLowerCase();
|
142 |
+
if (!Object.prototype.hasOwnProperty.call(status2.code, msg)) {
|
143 |
+
throw new Error('invalid status message: "' + message + '"');
|
144 |
+
}
|
145 |
+
return status2.code[msg];
|
146 |
+
}
|
147 |
+
function getStatusMessage(code) {
|
148 |
+
if (!Object.prototype.hasOwnProperty.call(status2.message, code)) {
|
149 |
+
throw new Error("invalid status code: " + code);
|
150 |
+
}
|
151 |
+
return status2.message[code];
|
152 |
+
}
|
153 |
+
function status2(code) {
|
154 |
+
if (typeof code === "number") {
|
155 |
+
return getStatusMessage(code);
|
156 |
+
}
|
157 |
+
if (typeof code !== "string") {
|
158 |
+
throw new TypeError("code must be a number or string");
|
159 |
+
}
|
160 |
+
var n = parseInt(code, 10);
|
161 |
+
if (!isNaN(n)) {
|
162 |
+
return getStatusMessage(n);
|
163 |
+
}
|
164 |
+
return getStatusCode(code);
|
165 |
+
}
|
166 |
+
}
|
167 |
+
});
|
168 |
+
|
169 |
+
// source.js
|
170 |
+
var import_statuses = __toESM(require_statuses(), 1);
|
171 |
+
var source_default = import_statuses.default;
|
172 |
+
export {
|
173 |
+
source_default as default
|
174 |
+
};
|
175 |
+
/*! Bundled license information:
|
176 |
+
|
177 |
+
statuses/index.js:
|
178 |
+
(*!
|
179 |
+
* statuses
|
180 |
+
* Copyright(c) 2014 Jonathan Ong
|
181 |
+
* Copyright(c) 2016 Douglas Christopher Wilson
|
182 |
+
* MIT Licensed
|
183 |
+
*)
|
184 |
+
*/
|
node_modules/@bundled-es-modules/statuses/package.json
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@bundled-es-modules/statuses",
|
3 |
+
"version": "1.0.1",
|
4 |
+
"description": "mirror of statuses, bundled and exposed as ES module",
|
5 |
+
"author": "Pascal Schilp <[email protected]>",
|
6 |
+
"main": "index-esm.js",
|
7 |
+
"type": "module",
|
8 |
+
"exports": {
|
9 |
+
".": {
|
10 |
+
"import": "./index-esm.js",
|
11 |
+
"require": "./index-cjs.cjs"
|
12 |
+
}
|
13 |
+
},
|
14 |
+
"scripts": {
|
15 |
+
"dev": "node dev.js",
|
16 |
+
"build": "esbuild source.js --bundle --format=esm --outfile=index-esm.js"
|
17 |
+
},
|
18 |
+
"keywords": [],
|
19 |
+
"files": [
|
20 |
+
"index-esm.js",
|
21 |
+
"index-cjs.cjs"
|
22 |
+
],
|
23 |
+
"license": "ISC",
|
24 |
+
"dependencies": {
|
25 |
+
"statuses": "^2.0.1"
|
26 |
+
},
|
27 |
+
"devDependencies": {
|
28 |
+
"esbuild": "^0.17.17"
|
29 |
+
}
|
30 |
+
}
|
node_modules/@bundled-es-modules/tough-cookie/index-cjs.cjs
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
const toughCookie = require('tough-cookie')
|
2 |
+
module.exports = toughCookie
|
node_modules/@bundled-es-modules/tough-cookie/index-esm.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
node_modules/@bundled-es-modules/tough-cookie/index.d.ts
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export * from 'tough-cookie'
|
2 |
+
|
3 |
+
import * as toughCookie from 'tough-cookie'
|
4 |
+
export default toughCookie
|
node_modules/@bundled-es-modules/tough-cookie/package.json
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"type": "module",
|
3 |
+
"name": "@bundled-es-modules/tough-cookie",
|
4 |
+
"version": "0.1.6",
|
5 |
+
"description": "Mirror of tough-cookie, bundled and exposed as ES module",
|
6 |
+
"main": "./index-esm.js",
|
7 |
+
"typings": "./index.d.ts",
|
8 |
+
"exports": {
|
9 |
+
".": {
|
10 |
+
"import": "./index-esm.js",
|
11 |
+
"require": "./index-cjs.cjs"
|
12 |
+
}
|
13 |
+
},
|
14 |
+
"scripts": {
|
15 |
+
"build": "esbuild source.js --bundle --format=esm --outfile=index-esm.js",
|
16 |
+
"release": "release publish"
|
17 |
+
},
|
18 |
+
"files": [
|
19 |
+
"index.d.ts",
|
20 |
+
"index-esm.js",
|
21 |
+
"index-cjs.cjs"
|
22 |
+
],
|
23 |
+
"repository": {
|
24 |
+
"type": "git",
|
25 |
+
"url": "https://github.com/bundled-es-modules/tough-cookie"
|
26 |
+
},
|
27 |
+
"license": "ISC",
|
28 |
+
"dependencies": {
|
29 |
+
"@types/tough-cookie": "^4.0.5",
|
30 |
+
"tough-cookie": "^4.1.4"
|
31 |
+
},
|
32 |
+
"devDependencies": {
|
33 |
+
"@ossjs/release": "^0.8.1",
|
34 |
+
"esbuild": "^0.23.0"
|
35 |
+
},
|
36 |
+
"publishConfig": {
|
37 |
+
"access": "public"
|
38 |
+
}
|
39 |
+
}
|
node_modules/@gradio/client/CHANGELOG.md
ADDED
@@ -0,0 +1,850 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# @gradio/client
|
2 |
+
|
3 |
+
## 1.14.1
|
4 |
+
|
5 |
+
### Features
|
6 |
+
|
7 |
+
- [#10890](https://github.com/gradio-app/gradio/pull/10890) [`01b88c7`](https://github.com/gradio-app/gradio/commit/01b88c7fdedb413ba92ef6191967a8aed25e185f) - Improve API error handling in JS Client. Thanks @l2dy!
|
8 |
+
|
9 |
+
## 1.14.0
|
10 |
+
|
11 |
+
### Features
|
12 |
+
|
13 |
+
- [#10834](https://github.com/gradio-app/gradio/pull/10834) [`c05610c`](https://github.com/gradio-app/gradio/commit/c05610c87dd7f9e9fe5d0aed2fe93e40fdd32648) - Add Deep Links. Thanks @freddyaboulton!
|
14 |
+
|
15 |
+
## 1.13.1
|
16 |
+
|
17 |
+
### Features
|
18 |
+
|
19 |
+
- [#10694](https://github.com/gradio-app/gradio/pull/10694) [`16244f3`](https://github.com/gradio-app/gradio/commit/16244f3c1cb1a65ac1f719142f8fab67512fbb25) - Event Listeners in gradio sketch. Thanks @aliabid94!
|
20 |
+
|
21 |
+
### Fixes
|
22 |
+
|
23 |
+
- [#10719](https://github.com/gradio-app/gradio/pull/10719) [`b710d7c`](https://github.com/gradio-app/gradio/commit/b710d7cf13c1277fd18c7809cad0f707b880ef70) - Fix error display. Thanks @aliabid94!
|
24 |
+
|
25 |
+
## 1.13.0
|
26 |
+
|
27 |
+
### Features
|
28 |
+
|
29 |
+
- [#10500](https://github.com/gradio-app/gradio/pull/10500) [`16d419b`](https://github.com/gradio-app/gradio/commit/16d419b9f1f18ae4507d18a4739eb83ac4f3fae9) - Allow functions that solely update component properties to run in the frontend by setting `js=True`. Thanks @abidlabs!
|
30 |
+
|
31 |
+
## 1.12.0
|
32 |
+
|
33 |
+
### Features
|
34 |
+
|
35 |
+
- [#10492](https://github.com/gradio-app/gradio/pull/10492) [`29880d5`](https://github.com/gradio-app/gradio/commit/29880d51fbe7fbd222b0765a83c95134dc7d0e90) - Allow showing progress updates on arbitrary components. Thanks @abidlabs!
|
36 |
+
|
37 |
+
### Fixes
|
38 |
+
|
39 |
+
- [#10547](https://github.com/gradio-app/gradio/pull/10547) [`083d68b`](https://github.com/gradio-app/gradio/commit/083d68b223be82a65f18c553df9ae690a8118a49) - quick_fix_client. Thanks @aliabid94!
|
40 |
+
|
41 |
+
## 1.11.0
|
42 |
+
|
43 |
+
### Features
|
44 |
+
|
45 |
+
- [#10433](https://github.com/gradio-app/gradio/pull/10433) [`2e8dc74`](https://github.com/gradio-app/gradio/commit/2e8dc74f751be02f7217f78d241806b42fcdca04) - Allow building multipage Gradio apps. Thanks @aliabid94!
|
46 |
+
|
47 |
+
## 1.10.0
|
48 |
+
|
49 |
+
### Features
|
50 |
+
|
51 |
+
- [#10270](https://github.com/gradio-app/gradio/pull/10270) [`bb11a2a`](https://github.com/gradio-app/gradio/commit/bb11a2a702ca04fde245e7d54d155cbcbde7791e) - [ZeroGPU] Handshake-based postMessage. Thanks @cbensimon!
|
52 |
+
|
53 |
+
### Fixes
|
54 |
+
|
55 |
+
- [#10332](https://github.com/gradio-app/gradio/pull/10332) [`e742dcc`](https://github.com/gradio-app/gradio/commit/e742dcccb376692c9ddd5a6c251080e7c5936574) - Allow users to add a custom API route. Thanks @aliabid94!
|
56 |
+
|
57 |
+
## 1.9.0
|
58 |
+
|
59 |
+
### Features
|
60 |
+
|
61 |
+
- [#10262](https://github.com/gradio-app/gradio/pull/10262) [`f3bedd4`](https://github.com/gradio-app/gradio/commit/f3bedd4011bdfdecc952eb1275a9dd96af3e8d71) - add gr.Success and update windows contributing. Thanks @not-lain!
|
62 |
+
- [#10254](https://github.com/gradio-app/gradio/pull/10254) [`da07707`](https://github.com/gradio-app/gradio/commit/da0770748db9ea40194a43c9138ee2c6536b1247) - Add a `settings` link to the footer with i18n options & pwa instructions. Thanks @abidlabs!
|
63 |
+
|
64 |
+
## 1.8.0
|
65 |
+
|
66 |
+
### Features
|
67 |
+
|
68 |
+
- [#9930](https://github.com/gradio-app/gradio/pull/9930) [`eae345e`](https://github.com/gradio-app/gradio/commit/eae345e5fde39aea220b57c6a954cd7d72ff32d5) - Allow settings custom headers in js client. Thanks @elgiano!
|
69 |
+
- [#9950](https://github.com/gradio-app/gradio/pull/9950) [`fc06fe4`](https://github.com/gradio-app/gradio/commit/fc06fe41f015678a0545f4e5c99f6ae2704f0031) - Add ability to read and write from LocalStorage. Thanks @abidlabs!
|
70 |
+
|
71 |
+
## 1.7.1
|
72 |
+
|
73 |
+
### Fixes
|
74 |
+
|
75 |
+
- [#9814](https://github.com/gradio-app/gradio/pull/9814) [`6505d42`](https://github.com/gradio-app/gradio/commit/6505d4289a3e3d27d9133b1c8af41697fdc1476d) - support gradio apps on spaces served on subpaths. Thanks @pngwn!
|
76 |
+
|
77 |
+
## 1.7.0
|
78 |
+
|
79 |
+
### Features
|
80 |
+
|
81 |
+
- [#9681](https://github.com/gradio-app/gradio/pull/9681) [`2ed2361`](https://github.com/gradio-app/gradio/commit/2ed236187a9aab18e17fc4a8079eddef7dd195a5) - Allow setting title in gr.Info/Warning/Error. Thanks @ABucket!
|
82 |
+
|
83 |
+
## 1.6.0
|
84 |
+
|
85 |
+
### Features
|
86 |
+
|
87 |
+
- [#8843](https://github.com/gradio-app/gradio/pull/8843) [`6f95286`](https://github.com/gradio-app/gradio/commit/6f95286337459efbccb95c9cfac63355669df9ee) - Disable liking user message in chatbot by default but make it configurable
|
88 |
+
- [#8843](https://github.com/gradio-app/gradio/pull/8843) [`6f95286`](https://github.com/gradio-app/gradio/commit/6f95286337459efbccb95c9cfac63355669df9ee) - Open audio/image input stream only when queue is ready
|
89 |
+
- [#8843](https://github.com/gradio-app/gradio/pull/8843) [`6f95286`](https://github.com/gradio-app/gradio/commit/6f95286337459efbccb95c9cfac63355669df9ee) - Send Streaming data over Websocket if possible. Also support base64 output format for images.
|
90 |
+
- [#8843](https://github.com/gradio-app/gradio/pull/8843) [`6f95286`](https://github.com/gradio-app/gradio/commit/6f95286337459efbccb95c9cfac63355669df9ee) - Streaming inputs for 5.0
|
91 |
+
- [#8843](https://github.com/gradio-app/gradio/pull/8843) [`6f95286`](https://github.com/gradio-app/gradio/commit/6f95286337459efbccb95c9cfac63355669df9ee) - fix SSR apps on spaces
|
92 |
+
- [#8843](https://github.com/gradio-app/gradio/pull/8843) [`6f95286`](https://github.com/gradio-app/gradio/commit/6f95286337459efbccb95c9cfac63355669df9ee) - Ssr part 2
|
93 |
+
- [#8843](https://github.com/gradio-app/gradio/pull/8843) [`6f95286`](https://github.com/gradio-app/gradio/commit/6f95286337459efbccb95c9cfac63355669df9ee) - prefix api routes
|
94 |
+
|
95 |
+
### Fixes
|
96 |
+
|
97 |
+
|
98 |
+
- [#8843](https://github.com/gradio-app/gradio/pull/8843) [`6f95286`](https://github.com/gradio-app/gradio/commit/6f95286337459efbccb95c9cfac63355669df9ee) - Trigger state change event on iterators
|
99 |
+
|
100 |
+
## 1.6.0-beta.4
|
101 |
+
|
102 |
+
### Features
|
103 |
+
|
104 |
+
- [#9483](https://github.com/gradio-app/gradio/pull/9483) [`8dc7c12`](https://github.com/gradio-app/gradio/commit/8dc7c12389311b60efcde1b9d3e3668a34d2dc00) - Send Streaming data over Websocket if possible. Also support base64 output format for images. Thanks @freddyaboulton!
|
105 |
+
|
106 |
+
## 1.6.0-beta.3
|
107 |
+
|
108 |
+
### Features
|
109 |
+
|
110 |
+
- [#9412](https://github.com/gradio-app/gradio/pull/9412) [`c2c2fd9`](https://github.com/gradio-app/gradio/commit/c2c2fd989348f826566773c07c0e0bda200199ff) - fix SSR apps on spaces. Thanks @pngwn!
|
111 |
+
|
112 |
+
## 1.6.0-beta.2
|
113 |
+
|
114 |
+
### Features
|
115 |
+
|
116 |
+
- [#9323](https://github.com/gradio-app/gradio/pull/9323) [`06babda`](https://github.com/gradio-app/gradio/commit/06babda0395fd3fbd323c1c3cb33704ecfd6deb0) - Disable liking user message in chatbot by default but make it configurable. Thanks @freddyaboulton!
|
117 |
+
- [#9339](https://github.com/gradio-app/gradio/pull/9339) [`4c8c6f2`](https://github.com/gradio-app/gradio/commit/4c8c6f2fe603081941c5fdc43f48a0632b9f31ad) - Ssr part 2. Thanks @pngwn!
|
118 |
+
|
119 |
+
### Fixes
|
120 |
+
|
121 |
+
- [#9299](https://github.com/gradio-app/gradio/pull/9299) [`aa35b07`](https://github.com/gradio-app/gradio/commit/aa35b0788e613fdd45446d267513e6f94fa208ea) - Trigger state change event on iterators. Thanks @freddyaboulton!
|
122 |
+
|
123 |
+
## 1.6.0-beta.1
|
124 |
+
|
125 |
+
### Features
|
126 |
+
|
127 |
+
- [#9200](https://github.com/gradio-app/gradio/pull/9200) [`2e179d3`](https://github.com/gradio-app/gradio/commit/2e179d35be6ed60a5a6bfc7303178d63e41781ad) - prefix api routes. Thanks @pngwn!
|
128 |
+
|
129 |
+
## 1.6.0-beta.0
|
130 |
+
|
131 |
+
### Features
|
132 |
+
|
133 |
+
- [#9149](https://github.com/gradio-app/gradio/pull/9149) [`3d7a9b8`](https://github.com/gradio-app/gradio/commit/3d7a9b81f6fef06187eca832471dc1692eb493a0) - Open audio/image input stream only when queue is ready. Thanks @freddyaboulton!
|
134 |
+
- [#8941](https://github.com/gradio-app/gradio/pull/8941) [`97a7bf6`](https://github.com/gradio-app/gradio/commit/97a7bf66a79179d1b91a3199d68e5c11216ca500) - Streaming inputs for 5.0. Thanks @freddyaboulton!
|
135 |
+
|
136 |
+
## 1.5.2
|
137 |
+
|
138 |
+
### Fixes
|
139 |
+
|
140 |
+
- [#9163](https://github.com/gradio-app/gradio/pull/9163) [`2b6cbf2`](https://github.com/gradio-app/gradio/commit/2b6cbf25908e42cf027324e54ef2cc0baad11a91) - fix exports and generate types. Thanks @pngwn!
|
141 |
+
|
142 |
+
## 1.5.1
|
143 |
+
|
144 |
+
### Features
|
145 |
+
|
146 |
+
- [#9118](https://github.com/gradio-app/gradio/pull/9118) [`e1c404d`](https://github.com/gradio-app/gradio/commit/e1c404da1143fb52b659d03e028bdba1badf443d) - setup npm-previews of all packages. Thanks @pngwn!
|
147 |
+
|
148 |
+
## 1.5.0
|
149 |
+
|
150 |
+
### Features
|
151 |
+
|
152 |
+
- [#8965](https://github.com/gradio-app/gradio/pull/8965) [`d30432e`](https://github.com/gradio-app/gradio/commit/d30432e9c6d4cc1e5cfd989a1a3ae4aba7e21290) - harden CI. Thanks @pngwn!
|
153 |
+
|
154 |
+
### Fixes
|
155 |
+
|
156 |
+
- [#8847](https://github.com/gradio-app/gradio/pull/8847) [`4d8a473`](https://github.com/gradio-app/gradio/commit/4d8a473632e388a312aee5c705b3c1f79853441b) - fix: wrong named param check for js client. Thanks @freddyaboulton!
|
157 |
+
|
158 |
+
## 1.4.0
|
159 |
+
|
160 |
+
### Features
|
161 |
+
|
162 |
+
- [#8816](https://github.com/gradio-app/gradio/pull/8816) [`9ee6839`](https://github.com/gradio-app/gradio/commit/9ee6839f94d23d685a800ed3a275206e0b0e48f6) - Change optionality of the `data` param in `submit` + `predict`. Thanks @hannahblair!
|
163 |
+
|
164 |
+
### Fixes
|
165 |
+
|
166 |
+
- [#8820](https://github.com/gradio-app/gradio/pull/8820) [`5050b36`](https://github.com/gradio-app/gradio/commit/5050b36221e75a18d8a5d4f74a725e70768a4c4a) - fix: wrong named param check for js client. Thanks @JacobLinCool!
|
167 |
+
|
168 |
+
## 1.3.0
|
169 |
+
|
170 |
+
### Fixes
|
171 |
+
|
172 |
+
- [#8699](https://github.com/gradio-app/gradio/pull/8699) [`012da05`](https://github.com/gradio-app/gradio/commit/012da05287846d94beb0ecdc28d7fbc48c4248ff) - Ensure JS client `status_callback` functionality works and improve status messages. Thanks @hannahblair!
|
173 |
+
- [#8505](https://github.com/gradio-app/gradio/pull/8505) [`2943d6d`](https://github.com/gradio-app/gradio/commit/2943d6d68847314885dc6c5c0247083116017ca0) - Add Timer component. Thanks @aliabid94!
|
174 |
+
- [#8715](https://github.com/gradio-app/gradio/pull/8715) [`a6b3c6c`](https://github.com/gradio-app/gradio/commit/a6b3c6ce4e1d06253860c72740024a9138e3a93a) - Ensure `@gradio/client`'s `submit` iterator releases as expected. Thanks @pngwn!
|
175 |
+
- [#8716](https://github.com/gradio-app/gradio/pull/8716) [`e834d30`](https://github.com/gradio-app/gradio/commit/e834d302e44f7a54565129bf2c11acf4e882a59b) - ensure `@gradio/client` always returns the correct data. Thanks @pngwn!
|
176 |
+
- [#8714](https://github.com/gradio-app/gradio/pull/8714) [`1b5b5b0`](https://github.com/gradio-app/gradio/commit/1b5b5b0b43e69ee84f3baad2aae59ffc9c4d995a) - Bind `fetch` and `stream` in JS client. Thanks @hannahblair!
|
177 |
+
- [#8720](https://github.com/gradio-app/gradio/pull/8720) [`936c713`](https://github.com/gradio-app/gradio/commit/936c7137a99ef59efdf75bae5dd27eea2ac1f577) - Documents auth in the guides, in the view API page, and also types the Blocks.config object. Thanks @abidlabs!
|
178 |
+
|
179 |
+
## 1.2.1
|
180 |
+
|
181 |
+
### Features
|
182 |
+
|
183 |
+
- [#8649](https://github.com/gradio-app/gradio/pull/8649) [`4b6c8b1`](https://github.com/gradio-app/gradio/commit/4b6c8b1c004cee67345a7f103ba2dc8e90b82e6c) - ensure `File` objects are handled in JS client `handle_file`. Thanks @hannahblair!
|
184 |
+
|
185 |
+
## 1.2.0
|
186 |
+
|
187 |
+
### Features
|
188 |
+
|
189 |
+
- [#8489](https://github.com/gradio-app/gradio/pull/8489) [`c2a0d05`](https://github.com/gradio-app/gradio/commit/c2a0d056d679d90631d9ccd944dadd67e7e03b7f) - Control Display of Error, Info, Warning. Thanks @freddyaboulton!
|
190 |
+
- [#8571](https://github.com/gradio-app/gradio/pull/8571) [`a77877f`](https://github.com/gradio-app/gradio/commit/a77877f62df7c610fcfac7b3b00e186a087c8ec6) - First time loading performance optimization. Thanks @baojianting!
|
191 |
+
- [#8600](https://github.com/gradio-app/gradio/pull/8600) [`7289c4b`](https://github.com/gradio-app/gradio/commit/7289c4b036d8a78c48f8c9e66ba998e6730e80d2) - Add credentials: include and Cookie header to prevent 401 error. Thanks @yinkiu602!
|
192 |
+
- [#8522](https://github.com/gradio-app/gradio/pull/8522) [`bdaa678`](https://github.com/gradio-app/gradio/commit/bdaa678d0c0a22250b41104f32e9121f98dc7437) - add handle_file docs. Thanks @pngwn!
|
193 |
+
|
194 |
+
### Fixes
|
195 |
+
|
196 |
+
- [#8521](https://github.com/gradio-app/gradio/pull/8521) [`900cf25`](https://github.com/gradio-app/gradio/commit/900cf25256a5b0563860097d69aac28b6afbfd8b) - Ensure frontend functions work when they don't return a value. Thanks @pngwn!
|
197 |
+
- [#8548](https://github.com/gradio-app/gradio/pull/8548) [`7fc0f51`](https://github.com/gradio-app/gradio/commit/7fc0f5149bb8d31f3d01b4151b478070499751ee) - Fix reload mode by implementing `close` on the client. Thanks @freddyaboulton!
|
198 |
+
|
199 |
+
## 1.1.1
|
200 |
+
|
201 |
+
### Features
|
202 |
+
|
203 |
+
- [#8499](https://github.com/gradio-app/gradio/pull/8499) [`c5f6e77`](https://github.com/gradio-app/gradio/commit/c5f6e7722a197d4706419ade14276ddecf3196f8) - Cache break themes on change. Thanks @aliabid94!
|
204 |
+
|
205 |
+
## 1.1.0
|
206 |
+
|
207 |
+
### Features
|
208 |
+
|
209 |
+
- [#8483](https://github.com/gradio-app/gradio/pull/8483) [`e2271e2`](https://github.com/gradio-app/gradio/commit/e2271e207d98074bf39b02ae3c5443b2f097627d) - documentation for @gradio/client. Thanks @pngwn!
|
210 |
+
- [#8485](https://github.com/gradio-app/gradio/pull/8485) [`f8ebace`](https://github.com/gradio-app/gradio/commit/f8ebaceccef60a112603d290d10072ef4e938a6a) - Ensure all status are reported internally when calling `predict`. Thanks @pngwn!
|
211 |
+
|
212 |
+
## 1.0.0
|
213 |
+
|
214 |
+
### Highlights
|
215 |
+
|
216 |
+
#### Clients 1.0 Launch! ([#8468](https://github.com/gradio-app/gradio/pull/8468) [`7cc0a0c`](https://github.com/gradio-app/gradio/commit/7cc0a0c1abea585c3f50ffb1ff78d2b08ddbdd92))
|
217 |
+
|
218 |
+
We're excited to unveil the first major release of the Gradio clients.
|
219 |
+
We've made it even easier to turn any Gradio application into a production endpoint thanks to the clients' **ergonomic**, **transparent**, and **portable** design.
|
220 |
+
|
221 |
+
#### Ergonomic API 💆
|
222 |
+
|
223 |
+
**Stream From a Gradio app in 5 lines**
|
224 |
+
|
225 |
+
Use the `submit` method to get a job you can iterate over:
|
226 |
+
|
227 |
+
```python
|
228 |
+
from gradio_client import Client
|
229 |
+
|
230 |
+
client = Client("gradio/llm_stream")
|
231 |
+
|
232 |
+
for result in client.submit("What's the best UI framework in Python?"):
|
233 |
+
print(result)
|
234 |
+
```
|
235 |
+
|
236 |
+
```ts
|
237 |
+
import { Client } from "@gradio/client";
|
238 |
+
|
239 |
+
const client = await Client.connect("gradio/llm_stream")
|
240 |
+
const job = client.submit("/predict", {"text": "What's the best UI framework in Python?"})
|
241 |
+
|
242 |
+
for await (const msg of job) console.log(msg.data)
|
243 |
+
```
|
244 |
+
|
245 |
+
**Use the same keyword arguments as the app**
|
246 |
+
|
247 |
+
|
248 |
+
```python
|
249 |
+
from gradio_client import Client
|
250 |
+
|
251 |
+
client = Client("http://127.0.0.1:7860/")
|
252 |
+
result = client.predict(
|
253 |
+
message="Hello!!",
|
254 |
+
system_prompt="You are helpful AI.",
|
255 |
+
tokens=10,
|
256 |
+
api_name="/chat"
|
257 |
+
)
|
258 |
+
print(result)
|
259 |
+
```
|
260 |
+
|
261 |
+
```ts
|
262 |
+
import { Client } from "@gradio/client";
|
263 |
+
|
264 |
+
const client = await Client.connect("http://127.0.0.1:7860/");
|
265 |
+
const result = await client.predict("/chat", {
|
266 |
+
message: "Hello!!",
|
267 |
+
system_prompt: "Hello!!",
|
268 |
+
tokens: 10,
|
269 |
+
});
|
270 |
+
|
271 |
+
console.log(result.data);
|
272 |
+
```
|
273 |
+
|
274 |
+
**Better Error Messages**
|
275 |
+
|
276 |
+
If something goes wrong in the upstream app, the client will raise the same exception as the app provided that `show_error=True` in the original app's `launch()` function, or it's a `gr.Error` exception.
|
277 |
+
|
278 |
+
#### Transparent Design 🪟
|
279 |
+
|
280 |
+
Anything you can do in the UI, you can do with the client:
|
281 |
+
* 🔒 Authentication
|
282 |
+
* 🛑 Job Cancelling
|
283 |
+
* ℹ️ Access Queue Position and API
|
284 |
+
* 📕 View the API information
|
285 |
+
|
286 |
+
Here's an example showing how to display the queue position of a pending job:
|
287 |
+
|
288 |
+
```python
|
289 |
+
from gradio_client import Client
|
290 |
+
|
291 |
+
client = Client("gradio/diffusion_model")
|
292 |
+
|
293 |
+
job = client.submit("A cute cat")
|
294 |
+
while not job.done():
|
295 |
+
status = job.status()
|
296 |
+
print(f"Current in position {status.rank} out of {status.queue_size}")
|
297 |
+
```
|
298 |
+
|
299 |
+
#### Portable Design ⛺️
|
300 |
+
|
301 |
+
The client can run from pretty much any python and javascript environment (node, deno, the browser, Service Workers).
|
302 |
+
|
303 |
+
Here's an example using the client from a Flask server using gevent:
|
304 |
+
|
305 |
+
```python
|
306 |
+
from gevent import monkey
|
307 |
+
monkey.patch_all()
|
308 |
+
|
309 |
+
from gradio_client import Client
|
310 |
+
from flask import Flask, send_file
|
311 |
+
import time
|
312 |
+
|
313 |
+
app = Flask(__name__)
|
314 |
+
|
315 |
+
imageclient = Client("gradio/diffusion_model")
|
316 |
+
|
317 |
+
@app.route("/gen")
|
318 |
+
def gen():
|
319 |
+
result = imageclient.predict(
|
320 |
+
"A cute cat",
|
321 |
+
api_name="/predict"
|
322 |
+
)
|
323 |
+
return send_file(result)
|
324 |
+
|
325 |
+
if __name__ == "__main__":
|
326 |
+
app.run(host="0.0.0.0", port=5000)
|
327 |
+
```
|
328 |
+
|
329 |
+
#### 1.0 Migration Guide and Breaking Changes
|
330 |
+
|
331 |
+
**Python**
|
332 |
+
- The `serialize` argument of the `Client` class was removed. Has no effect.
|
333 |
+
- The `upload_files` argument of the `Client` was removed.
|
334 |
+
- All filepaths must be wrapped in the `handle_file` method. Example:
|
335 |
+
```python
|
336 |
+
from gradio_client import Client, handle_file
|
337 |
+
|
338 |
+
client = Client("gradio/image_captioner")
|
339 |
+
client.predict(handle_file("cute_cat.jpg"))
|
340 |
+
```
|
341 |
+
- The `output_dir` argument was removed. It is not specified in the `download_files` argument.
|
342 |
+
|
343 |
+
|
344 |
+
**Javascript**
|
345 |
+
The client has been redesigned entirely. It was refactored from a function into a class. An instance can now be constructed by awaiting the `connect` method.
|
346 |
+
|
347 |
+
```js
|
348 |
+
const app = await Client.connect("gradio/whisper")
|
349 |
+
```
|
350 |
+
The app variable has the same methods as the python class (`submit`, `predict`, `view_api`, `duplicate`).
|
351 |
+
|
352 |
+
|
353 |
+
|
354 |
+
#### Additional Changes
|
355 |
+
|
356 |
+
- [#8243](https://github.com/gradio-app/gradio/pull/8243) - Set orig_name in python client file uploads.
|
357 |
+
- [#8264](https://github.com/gradio-app/gradio/pull/8264) - Make exceptions in the Client more specific.
|
358 |
+
- [#8247](https://github.com/gradio-app/gradio/pull/8247) - Fix api recorder.
|
359 |
+
- [#8276](https://github.com/gradio-app/gradio/pull/8276) - Fix bug where client could not connect to apps that had self signed certificates.
|
360 |
+
- [#8245](https://github.com/gradio-app/gradio/pull/8245) - Cancel server progress from the python client.
|
361 |
+
- [#8200](https://github.com/gradio-app/gradio/pull/8200) - Support custom components in gr.load
|
362 |
+
- [#8182](https://github.com/gradio-app/gradio/pull/8182) - Convert sse calls in client from async to sync.
|
363 |
+
- [#7732](https://github.com/gradio-app/gradio/pull/7732) - Adds support for kwargs and default arguments in the python client, and improves how parameter information is displayed in the "view API" page.
|
364 |
+
- [#7888](https://github.com/gradio-app/gradio/pull/7888) - Cache view_api info in server and python client.
|
365 |
+
- [#7575](https://github.com/gradio-app/gradio/pull/7575) - Files should now be supplied as `file(...)` in the Client, and some fixes to `gr.load()` as well.
|
366 |
+
- [#8401](https://github.com/gradio-app/gradio/pull/8401) - Add CDN installation to JS docs.
|
367 |
+
- [#8299](https://github.com/gradio-app/gradio/pull/8299) - Allow JS Client to work with authenticated spaces 🍪.
|
368 |
+
- [#8408](https://github.com/gradio-app/gradio/pull/8408) - Connect heartbeat if state created in render. Also fix config cleanup bug #8407.
|
369 |
+
- [#8258](https://github.com/gradio-app/gradio/pull/8258) - Improve URL handling in JS Client.
|
370 |
+
- [#8322](https://github.com/gradio-app/gradio/pull/8322) - ensure the client correctly handles all binary data.
|
371 |
+
- [#8296](https://github.com/gradio-app/gradio/pull/8296) - always create a jwt when connecting to a space if a hf_token is present.
|
372 |
+
- [#8285](https://github.com/gradio-app/gradio/pull/8285) - use the correct query param to pass the jwt to the heartbeat event.
|
373 |
+
- [#8272](https://github.com/gradio-app/gradio/pull/8272) - ensure client works for private spaces.
|
374 |
+
- [#8197](https://github.com/gradio-app/gradio/pull/8197) - Add support for passing keyword args to `data` in JS client.
|
375 |
+
- [#8252](https://github.com/gradio-app/gradio/pull/8252) - Client node fix.
|
376 |
+
- [#8209](https://github.com/gradio-app/gradio/pull/8209) - Rename `eventSource_Factory` and `fetch_implementation`.
|
377 |
+
- [#8109](https://github.com/gradio-app/gradio/pull/8109) - Implement JS Client tests.
|
378 |
+
- [#8211](https://github.com/gradio-app/gradio/pull/8211) - remove redundant event source logic.
|
379 |
+
- [#8179](https://github.com/gradio-app/gradio/pull/8179) - rework upload to be a class method + pass client into each component.
|
380 |
+
- [#8181](https://github.com/gradio-app/gradio/pull/8181) - Ensure connectivity to private HF spaces with SSE protocol.
|
381 |
+
- [#8169](https://github.com/gradio-app/gradio/pull/8169) - Only connect to heartbeat if needed.
|
382 |
+
- [#8118](https://github.com/gradio-app/gradio/pull/8118) - Add eventsource polyfill for Node.js and browser environments.
|
383 |
+
- [#7646](https://github.com/gradio-app/gradio/pull/7646) - Refactor JS Client.
|
384 |
+
- [#7974](https://github.com/gradio-app/gradio/pull/7974) - Fix heartbeat in the js client to be Lite compatible.
|
385 |
+
- [#7926](https://github.com/gradio-app/gradio/pull/7926) - Fixes streaming event race condition.
|
386 |
+
|
387 |
+
Thanks @freddyaboulton!
|
388 |
+
|
389 |
+
### Features
|
390 |
+
|
391 |
+
- [#8370](https://github.com/gradio-app/gradio/pull/8370) [`48eeea4`](https://github.com/gradio-app/gradio/commit/48eeea4eaab7e24168688e3c3fbafb30e4e78d51) - Refactor Cancelling Logic To Use /cancel. Thanks @freddyaboulton!
|
392 |
+
|
393 |
+
### Fixes
|
394 |
+
|
395 |
+
- [#8477](https://github.com/gradio-app/gradio/pull/8477) [`d5a9604`](https://github.com/gradio-app/gradio/commit/d5a960493017a4890685af61d78ce7d3b3b12e6b) - Fix js client bundle. Thanks @pngwn!
|
396 |
+
- [#8451](https://github.com/gradio-app/gradio/pull/8451) [`9d2d605`](https://github.com/gradio-app/gradio/commit/9d2d6051caed5c8749a26a6fa7480a5ae6e6c4f3) - Change client submit API to be an AsyncIterable and support more platforms. Thanks @pngwn!
|
397 |
+
- [#8462](https://github.com/gradio-app/gradio/pull/8462) [`6447dfa`](https://github.com/gradio-app/gradio/commit/6447dface4d46db1c69460e8325a1928d0476a46) - Improve file handling in JS Client. Thanks @hannahblair!
|
398 |
+
- [#8439](https://github.com/gradio-app/gradio/pull/8439) [`63d36fb`](https://github.com/gradio-app/gradio/commit/63d36fbbf4bf6dc909be9a0ffc7b6bf6621d83e8) - Handle gradio apps using `state` in the JS Client. Thanks @hannahblair!
|
399 |
+
|
400 |
+
## 0.20.1
|
401 |
+
|
402 |
+
### Features
|
403 |
+
|
404 |
+
- [#8415](https://github.com/gradio-app/gradio/pull/8415) [`227de35`](https://github.com/gradio-app/gradio/commit/227de352982b3dcdf9384eaa28b7e9cf09afb6e8) - Fix spaces load error. Thanks @aliabid94!
|
405 |
+
|
406 |
+
## 0.20.0
|
407 |
+
|
408 |
+
### Features
|
409 |
+
|
410 |
+
- [#8401](https://github.com/gradio-app/gradio/pull/8401) [`d078621`](https://github.com/gradio-app/gradio/commit/d078621928136c09ca902d2f37594ed887c67d2e) - Add CDN installation to JS docs. Thanks @hannahblair!
|
411 |
+
- [#8243](https://github.com/gradio-app/gradio/pull/8243) [`55f664f`](https://github.com/gradio-app/gradio/commit/55f664f2979a49acc29a73cde16c6ebdfcc91db2) - Add event listener support to render blocks. Thanks @aliabid94!
|
412 |
+
- [#8398](https://github.com/gradio-app/gradio/pull/8398) [`945ac83`](https://github.com/gradio-app/gradio/commit/945ac837e779b120790814ea6f6f81bd2712f5f8) - Improve rendering. Thanks @aliabid94!
|
413 |
+
- [#8299](https://github.com/gradio-app/gradio/pull/8299) [`ab65360`](https://github.com/gradio-app/gradio/commit/ab653608045ff9462db7ad9fe63e1c60bf20e773) - Allow JS Client to work with authenticated spaces 🍪. Thanks @hannahblair!
|
414 |
+
|
415 |
+
### Fixes
|
416 |
+
|
417 |
+
- [#8408](https://github.com/gradio-app/gradio/pull/8408) [`e86dd01`](https://github.com/gradio-app/gradio/commit/e86dd01b6e8f7bab3d3c25b84f2ad33129138af4) - Connect heartbeat if state created in render. Also fix config cleanup bug #8407. Thanks @freddyaboulton!
|
418 |
+
- [#8258](https://github.com/gradio-app/gradio/pull/8258) [`1f8e5c4`](https://github.com/gradio-app/gradio/commit/1f8e5c44e054b943052d8f24d044696ddfd01a54) - Improve URL handling in JS Client. Thanks @hannahblair!
|
419 |
+
|
420 |
+
## 0.19.4
|
421 |
+
|
422 |
+
### Fixes
|
423 |
+
|
424 |
+
- [#8322](https://github.com/gradio-app/gradio/pull/8322) [`47012a0`](https://github.com/gradio-app/gradio/commit/47012a0c4e3e8a80fcae620aaf08b16ceb343cde) - ensure the client correctly handles all binary data. Thanks @Saghen!
|
425 |
+
|
426 |
+
## 0.19.3
|
427 |
+
|
428 |
+
### Features
|
429 |
+
|
430 |
+
- [#8229](https://github.com/gradio-app/gradio/pull/8229) [`7c81897`](https://github.com/gradio-app/gradio/commit/7c81897076ddcd0bb05e0e4ffec35bb9a986d330) - chore(deps): update dependency esbuild to ^0.21.0. Thanks @renovate!
|
431 |
+
|
432 |
+
### Fixes
|
433 |
+
|
434 |
+
- [#8296](https://github.com/gradio-app/gradio/pull/8296) [`929d216`](https://github.com/gradio-app/gradio/commit/929d216d49aa05614bc83f0761cf7b1cd803d8fe) - always create a jwt when connecting to a space if a hf_token is present. Thanks @pngwn!
|
435 |
+
|
436 |
+
## 0.19.2
|
437 |
+
|
438 |
+
### Fixes
|
439 |
+
|
440 |
+
- [#8285](https://github.com/gradio-app/gradio/pull/8285) [`7d9d8ea`](https://github.com/gradio-app/gradio/commit/7d9d8eab50d36cbecbb84c6a0f3cc1bca7215604) - use the correct query param to pass the jwt to the heartbeat event. Thanks @pngwn!
|
441 |
+
|
442 |
+
## 0.19.1
|
443 |
+
|
444 |
+
### Fixes
|
445 |
+
|
446 |
+
- [#8272](https://github.com/gradio-app/gradio/pull/8272) [`fbf4edd`](https://github.com/gradio-app/gradio/commit/fbf4edde7c896cdf4c903463e44c31ed96111b3c) - ensure client works for private spaces. Thanks @pngwn!
|
447 |
+
|
448 |
+
## 0.19.0
|
449 |
+
|
450 |
+
### Features
|
451 |
+
|
452 |
+
- [#8110](https://github.com/gradio-app/gradio/pull/8110) [`5436031`](https://github.com/gradio-app/gradio/commit/5436031f92c1596282eb64e1e74d555f279e9697) - Render decorator 2. Thanks @aliabid94!
|
453 |
+
- [#8197](https://github.com/gradio-app/gradio/pull/8197) [`e09b4e8`](https://github.com/gradio-app/gradio/commit/e09b4e8216b970bc1b142a0f08e7d190b954eb35) - Add support for passing keyword args to `data` in JS client. Thanks @hannahblair!
|
454 |
+
|
455 |
+
### Fixes
|
456 |
+
|
457 |
+
- [#8252](https://github.com/gradio-app/gradio/pull/8252) [`22df61a`](https://github.com/gradio-app/gradio/commit/22df61a26adf8023f6dd49c051979990e8d3879a) - Client node fix. Thanks @pngwn!
|
458 |
+
|
459 |
+
## 0.18.0
|
460 |
+
|
461 |
+
### Features
|
462 |
+
|
463 |
+
- [#8121](https://github.com/gradio-app/gradio/pull/8121) [`f5b710c`](https://github.com/gradio-app/gradio/commit/f5b710c919b0ce604ea955f0d5f4faa91095ca4a) - chore(deps): update dependency eslint to v9. Thanks @renovate!
|
464 |
+
- [#8209](https://github.com/gradio-app/gradio/pull/8209) [`b9afe93`](https://github.com/gradio-app/gradio/commit/b9afe93915401df5bd6737c89395c2477acfa585) - Rename `eventSource_Factory` and `fetch_implementation`. Thanks @hannahblair!
|
465 |
+
- [#8109](https://github.com/gradio-app/gradio/pull/8109) [`bed2f82`](https://github.com/gradio-app/gradio/commit/bed2f82e2297b50f7b59423a3de05af0b9910724) - Implement JS Client tests. Thanks @hannahblair!
|
466 |
+
- [#8211](https://github.com/gradio-app/gradio/pull/8211) [`91b5cd6`](https://github.com/gradio-app/gradio/commit/91b5cd6132fb8903c92f70fce0800324836a1fc3) - remove redundant event source logic. Thanks @hannahblair!
|
467 |
+
|
468 |
+
### Fixes
|
469 |
+
|
470 |
+
- [#8179](https://github.com/gradio-app/gradio/pull/8179) [`6a218b4`](https://github.com/gradio-app/gradio/commit/6a218b4148095aaa0c58d8c20973ba01c8764fc2) - rework upload to be a class method + pass client into each component. Thanks @pngwn!
|
471 |
+
- [#8181](https://github.com/gradio-app/gradio/pull/8181) [`cf52ca6`](https://github.com/gradio-app/gradio/commit/cf52ca6a51320ece97f009a177792840b5fbc785) - Ensure connectivity to private HF spaces with SSE protocol. Thanks @hannahblair!
|
472 |
+
- [#8169](https://github.com/gradio-app/gradio/pull/8169) [`3a6f1a5`](https://github.com/gradio-app/gradio/commit/3a6f1a50b263e0a733f609a08019fc4d05480e1a) - Only connect to heartbeat if needed. Thanks @freddyaboulton!
|
473 |
+
- [#8118](https://github.com/gradio-app/gradio/pull/8118) [`7aca673`](https://github.com/gradio-app/gradio/commit/7aca673b38a087533524b2fd8dd3a03e0e4bacfe) - Add eventsource polyfill for Node.js and browser environments. Thanks @hannahblair!
|
474 |
+
|
475 |
+
## 0.17.0
|
476 |
+
|
477 |
+
### Highlights
|
478 |
+
|
479 |
+
#### Setting File Upload Limits ([#7909](https://github.com/gradio-app/gradio/pull/7909) [`2afca65`](https://github.com/gradio-app/gradio/commit/2afca6541912b37dc84f447c7ad4af21607d7c72))
|
480 |
+
|
481 |
+
We have added a `max_file_size` size parameter to `launch()` that limits to size of files uploaded to the server. This limit applies to each individual file. This parameter can be specified as a string or an integer (corresponding to the size in bytes).
|
482 |
+
|
483 |
+
The following code snippet sets a max file size of 5 megabytes.
|
484 |
+
|
485 |
+
```python
|
486 |
+
import gradio as gr
|
487 |
+
|
488 |
+
demo = gr.Interface(lambda x: x, "image", "image")
|
489 |
+
|
490 |
+
demo.launch(max_file_size="5mb")
|
491 |
+
# or
|
492 |
+
demo.launch(max_file_size=5 * gr.FileSize.MB)
|
493 |
+
```
|
494 |
+
|
495 |
+

|
496 |
+
|
497 |
+
|
498 |
+
#### Error states can now be cleared
|
499 |
+
|
500 |
+
When a component encounters an error, the error state shown in the UI can now be cleared by clicking on the `x` icon in the top right of the component. This applies to all types of errors, whether it's raised in the UI or the server.
|
501 |
+
|
502 |
+

|
503 |
+
|
504 |
+
Thanks @freddyaboulton!
|
505 |
+
|
506 |
+
### Features
|
507 |
+
|
508 |
+
- [#8056](https://github.com/gradio-app/gradio/pull/8056) [`2e469a5`](https://github.com/gradio-app/gradio/commit/2e469a5f99e52a5011a010f46e47dde7bb0c7140) - Using keys to preserve values between reloads. Thanks @aliabid94!
|
509 |
+
- [#7646](https://github.com/gradio-app/gradio/pull/7646) [`450b8cc`](https://github.com/gradio-app/gradio/commit/450b8cc898f130f15caa3742f65c17b9f7a8f398) - Refactor JS Client. Thanks @hannahblair!
|
510 |
+
- [#8061](https://github.com/gradio-app/gradio/pull/8061) [`17e83c9`](https://github.com/gradio-app/gradio/commit/17e83c958ebb35b3e122ca486067d1bd5ce33a22) - Docs Reorg and Intro Page. Thanks @aliabd!
|
511 |
+
|
512 |
+
### Fixes
|
513 |
+
|
514 |
+
- [#8066](https://github.com/gradio-app/gradio/pull/8066) [`624f9b9`](https://github.com/gradio-app/gradio/commit/624f9b9477f74a581a6c14119234f9efdfcda398) - make gradio dev tools a local dependency rather than bundling. Thanks @pngwn!
|
515 |
+
|
516 |
+
## 0.16.0
|
517 |
+
|
518 |
+
### Features
|
519 |
+
|
520 |
+
- [#7845](https://github.com/gradio-app/gradio/pull/7845) [`dbb7373`](https://github.com/gradio-app/gradio/commit/dbb7373dde69d4ed2741942b5a1898f8620cec24) - ensure `ImageEditor` events work as expected. Thanks @pngwn!
|
521 |
+
|
522 |
+
### Fixes
|
523 |
+
|
524 |
+
- [#7974](https://github.com/gradio-app/gradio/pull/7974) [`79e0aa8`](https://github.com/gradio-app/gradio/commit/79e0aa81c94e755faa6e85d76ac5d5a666313e6a) - Fix heartbeat in the js client to be Lite compatible. Thanks @whitphx!
|
525 |
+
|
526 |
+
## 0.15.1
|
527 |
+
|
528 |
+
### Fixes
|
529 |
+
|
530 |
+
- [#7926](https://github.com/gradio-app/gradio/pull/7926) [`9666854`](https://github.com/gradio-app/gradio/commit/966685479078f59430b3bced7e6068eb8157c003) - Fixes streaming event race condition. Thanks @aliabid94!
|
531 |
+
|
532 |
+
## 0.15.0
|
533 |
+
|
534 |
+
### Highlights
|
535 |
+
|
536 |
+
#### Automatically delete state after user has disconnected from the webpage ([#7829](https://github.com/gradio-app/gradio/pull/7829) [`6a4bf7a`](https://github.com/gradio-app/gradio/commit/6a4bf7abe29059dbdc6a342e0366fdaa2e4120ee))
|
537 |
+
|
538 |
+
Gradio now automatically deletes `gr.State` variables stored in the server's RAM when users close their browser tab.
|
539 |
+
The deletion will happen 60 minutes after the server detected a disconnect from the user's browser.
|
540 |
+
If the user connects again in that timeframe, their state will not be deleted.
|
541 |
+
|
542 |
+
Additionally, Gradio now includes a `Blocks.unload()` event, allowing you to run arbitrary cleanup functions when users disconnect (this does not have a 60 minute delay).
|
543 |
+
You can think of the `unload` event as the opposite of the `load` event.
|
544 |
+
|
545 |
+
|
546 |
+
```python
|
547 |
+
with gr.Blocks() as demo:
|
548 |
+
gr.Markdown(
|
549 |
+
"""# State Cleanup Demo
|
550 |
+
🖼️ Images are saved in a user-specific directory and deleted when the users closes the page via demo.unload.
|
551 |
+
""")
|
552 |
+
with gr.Row():
|
553 |
+
with gr.Column(scale=1):
|
554 |
+
with gr.Row():
|
555 |
+
img = gr.Image(label="Generated Image", height=300, width=300)
|
556 |
+
with gr.Row():
|
557 |
+
gen = gr.Button(value="Generate")
|
558 |
+
with gr.Row():
|
559 |
+
history = gr.Gallery(label="Previous Generations", height=500, columns=10)
|
560 |
+
state = gr.State(value=[], delete_callback=lambda v: print("STATE DELETED"))
|
561 |
+
|
562 |
+
demo.load(generate_random_img, [state], [img, state, history])
|
563 |
+
gen.click(generate_random_img, [state], [img, state, history])
|
564 |
+
demo.unload(delete_directory)
|
565 |
+
|
566 |
+
|
567 |
+
demo.launch(auth=lambda user,pwd: True,
|
568 |
+
auth_message="Enter any username and password to continue")
|
569 |
+
```
|
570 |
+
|
571 |
+
Thanks @freddyaboulton!
|
572 |
+
|
573 |
+
## 0.14.0
|
574 |
+
|
575 |
+
### Features
|
576 |
+
|
577 |
+
- [#7691](https://github.com/gradio-app/gradio/pull/7691) [`84f81fe`](https://github.com/gradio-app/gradio/commit/84f81fec9287b041203a141bbf2852720f7d199c) - Closing stream from the backend. Thanks @aliabid94!
|
578 |
+
|
579 |
+
### Fixes
|
580 |
+
|
581 |
+
- [#7564](https://github.com/gradio-app/gradio/pull/7564) [`5d1e8da`](https://github.com/gradio-app/gradio/commit/5d1e8dae5ac23f605c3b5f41dbe18751dff380a0) - batch UI updates on a per frame basis. Thanks @pngwn!
|
582 |
+
|
583 |
+
## 0.13.0
|
584 |
+
|
585 |
+
### Fixes
|
586 |
+
|
587 |
+
- [#7575](https://github.com/gradio-app/gradio/pull/7575) [`d0688b3`](https://github.com/gradio-app/gradio/commit/d0688b3c25feabb4fc7dfa0ab86086b3af7eb337) - Files should now be supplied as `file(...)` in the Client, and some fixes to `gr.load()` as well. Thanks @abidlabs!
|
588 |
+
|
589 |
+
## 0.12.2
|
590 |
+
|
591 |
+
### Features
|
592 |
+
|
593 |
+
- [#7528](https://github.com/gradio-app/gradio/pull/7528) [`eda33b3`](https://github.com/gradio-app/gradio/commit/eda33b3763897a542acf298e523fa493dc655aee) - Refactors `get_fetchable_url_or_file()` to remove it from the frontend. Thanks [@abidlabs](https://github.com/abidlabs)!
|
594 |
+
- [#7340](https://github.com/gradio-app/gradio/pull/7340) [`4b0d589`](https://github.com/gradio-app/gradio/commit/4b0d58933057432758a54169a360eb352903d6b4) - chore(deps): update all non-major dependencies. Thanks [@renovate](https://github.com/apps/renovate)!
|
595 |
+
|
596 |
+
## 0.12.1
|
597 |
+
|
598 |
+
### Fixes
|
599 |
+
|
600 |
+
- [#7411](https://github.com/gradio-app/gradio/pull/7411) [`32b317f`](https://github.com/gradio-app/gradio/commit/32b317f24e3d43f26684bb9f3964f31efd0ea556) - Set `root` correctly for Gradio apps that are deployed behind reverse proxies. Thanks [@abidlabs](https://github.com/abidlabs)!
|
601 |
+
|
602 |
+
## 0.12.0
|
603 |
+
|
604 |
+
### Features
|
605 |
+
|
606 |
+
- [#7183](https://github.com/gradio-app/gradio/pull/7183) [`49d9c48`](https://github.com/gradio-app/gradio/commit/49d9c48537aa706bf72628e3640389470138bdc6) - [WIP] Refactor file normalization to be in the backend and remove it from the frontend of each component. Thanks [@abidlabs](https://github.com/abidlabs)!
|
607 |
+
|
608 |
+
## 0.11.0
|
609 |
+
|
610 |
+
### Features
|
611 |
+
|
612 |
+
- [#7102](https://github.com/gradio-app/gradio/pull/7102) [`68a54a7`](https://github.com/gradio-app/gradio/commit/68a54a7a310d8d7072fdae930bf1cfdf12c45a7f) - Improve chatbot streaming performance with diffs. Thanks [@aliabid94](https://github.com/aliabid94)!/n Note that this PR changes the API format for generator functions, which would be a breaking change for any clients reading the EventStream directly
|
613 |
+
|
614 |
+
## 0.10.1
|
615 |
+
|
616 |
+
### Fixes
|
617 |
+
|
618 |
+
- [#7055](https://github.com/gradio-app/gradio/pull/7055) [`3c3cf86`](https://github.com/gradio-app/gradio/commit/3c3cf8618a8cad1ef66a7f96664923d2c9f5e0e2) - Fix UI freeze on rapid generators. Thanks [@aliabid94](https://github.com/aliabid94)!
|
619 |
+
|
620 |
+
## 0.10.0
|
621 |
+
|
622 |
+
### Features
|
623 |
+
|
624 |
+
- [#6931](https://github.com/gradio-app/gradio/pull/6931) [`6c863af`](https://github.com/gradio-app/gradio/commit/6c863af92fa9ceb5c638857eb22cc5ddb718d549) - Fix functional tests. Thanks [@aliabid94](https://github.com/aliabid94)!
|
625 |
+
- [#6820](https://github.com/gradio-app/gradio/pull/6820) [`649cd4d`](https://github.com/gradio-app/gradio/commit/649cd4d68041d11fcbe31f8efa455345ac49fc74) - Use `EventSource_factory` in `open_stream()` for Wasm. Thanks [@whitphx](https://github.com/whitphx)!
|
626 |
+
|
627 |
+
## 0.9.4
|
628 |
+
|
629 |
+
### Fixes
|
630 |
+
|
631 |
+
- [#6863](https://github.com/gradio-app/gradio/pull/6863) [`d406855`](https://github.com/gradio-app/gradio/commit/d4068557953746662235d595ec435c42ceb24414) - Fix JS Client when app is running behind a proxy. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
|
632 |
+
|
633 |
+
## 0.9.3
|
634 |
+
|
635 |
+
### Features
|
636 |
+
|
637 |
+
- [#6814](https://github.com/gradio-app/gradio/pull/6814) [`828fb9e`](https://github.com/gradio-app/gradio/commit/828fb9e6ce15b6ea08318675a2361117596a1b5d) - Refactor queue so that there are separate queues for each concurrency id. Thanks [@aliabid94](https://github.com/aliabid94)!
|
638 |
+
|
639 |
+
## 0.9.2
|
640 |
+
|
641 |
+
### Features
|
642 |
+
|
643 |
+
- [#6798](https://github.com/gradio-app/gradio/pull/6798) [`245d58e`](https://github.com/gradio-app/gradio/commit/245d58eff788e8d44a59d37a2d9b26d0f08a62b4) - Improve how server/js client handle unexpected errors. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
|
644 |
+
|
645 |
+
## 0.9.1
|
646 |
+
|
647 |
+
### Fixes
|
648 |
+
|
649 |
+
- [#6693](https://github.com/gradio-app/gradio/pull/6693) [`34f9431`](https://github.com/gradio-app/gradio/commit/34f943101bf7dd6b8a8974a6131c1ed7c4a0dac0) - Python client properly handles hearbeat and log messages. Also handles responses longer than 65k. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
|
650 |
+
|
651 |
+
## 0.9.0
|
652 |
+
|
653 |
+
### Features
|
654 |
+
|
655 |
+
- [#6398](https://github.com/gradio-app/gradio/pull/6398) [`67ddd40`](https://github.com/gradio-app/gradio/commit/67ddd40b4b70d3a37cb1637c33620f8d197dbee0) - Lite v4. Thanks [@whitphx](https://github.com/whitphx)!
|
656 |
+
|
657 |
+
### Fixes
|
658 |
+
|
659 |
+
- [#6556](https://github.com/gradio-app/gradio/pull/6556) [`d76bcaa`](https://github.com/gradio-app/gradio/commit/d76bcaaaf0734aaf49a680f94ea9d4d22a602e70) - Fix api event drops. Thanks [@aliabid94](https://github.com/aliabid94)!
|
660 |
+
|
661 |
+
## 0.8.2
|
662 |
+
|
663 |
+
### Features
|
664 |
+
|
665 |
+
- [#6511](https://github.com/gradio-app/gradio/pull/6511) [`71f1a1f99`](https://github.com/gradio-app/gradio/commit/71f1a1f9931489d465c2c1302a5c8d768a3cd23a) - Mark `FileData.orig_name` optional on the frontend aligning the type definition on the Python side. Thanks [@whitphx](https://github.com/whitphx)!
|
666 |
+
|
667 |
+
## 0.8.1
|
668 |
+
|
669 |
+
### Fixes
|
670 |
+
|
671 |
+
- [#6383](https://github.com/gradio-app/gradio/pull/6383) [`324867f63`](https://github.com/gradio-app/gradio/commit/324867f63c920113d89a565892aa596cf8b1e486) - Fix event target. Thanks [@aliabid94](https://github.com/aliabid94)!
|
672 |
+
|
673 |
+
## 0.8.0
|
674 |
+
|
675 |
+
### Features
|
676 |
+
|
677 |
+
- [#6307](https://github.com/gradio-app/gradio/pull/6307) [`f1409f95e`](https://github.com/gradio-app/gradio/commit/f1409f95ed39c5565bed6a601e41f94e30196a57) - Provide status updates on file uploads. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
|
678 |
+
|
679 |
+
## 0.7.2
|
680 |
+
|
681 |
+
### Fixes
|
682 |
+
|
683 |
+
- [#6327](https://github.com/gradio-app/gradio/pull/6327) [`bca6c2c80`](https://github.com/gradio-app/gradio/commit/bca6c2c80f7e5062427019de45c282238388af95) - Restore query parameters in request. Thanks [@aliabid94](https://github.com/aliabid94)!
|
684 |
+
|
685 |
+
## 0.7.1
|
686 |
+
|
687 |
+
### Features
|
688 |
+
|
689 |
+
- [#6137](https://github.com/gradio-app/gradio/pull/6137) [`2ba14b284`](https://github.com/gradio-app/gradio/commit/2ba14b284f908aa13859f4337167a157075a68eb) - JS Param. Thanks [@dawoodkhan82](https://github.com/dawoodkhan82)!
|
690 |
+
|
691 |
+
## 0.7.0
|
692 |
+
|
693 |
+
### Features
|
694 |
+
|
695 |
+
- [#5498](https://github.com/gradio-app/gradio/pull/5498) [`287fe6782`](https://github.com/gradio-app/gradio/commit/287fe6782825479513e79a5cf0ba0fbfe51443d7) - fix circular dependency with client + upload. Thanks [@pngwn](https://github.com/pngwn)!
|
696 |
+
- [#5498](https://github.com/gradio-app/gradio/pull/5498) [`287fe6782`](https://github.com/gradio-app/gradio/commit/287fe6782825479513e79a5cf0ba0fbfe51443d7) - Image v4. Thanks [@pngwn](https://github.com/pngwn)!
|
697 |
+
- [#5498](https://github.com/gradio-app/gradio/pull/5498) [`287fe6782`](https://github.com/gradio-app/gradio/commit/287fe6782825479513e79a5cf0ba0fbfe51443d7) - Swap websockets for SSE. Thanks [@pngwn](https://github.com/pngwn)!
|
698 |
+
|
699 |
+
## 0.7.0-beta.1
|
700 |
+
|
701 |
+
### Features
|
702 |
+
|
703 |
+
- [#6143](https://github.com/gradio-app/gradio/pull/6143) [`e4f7b4b40`](https://github.com/gradio-app/gradio/commit/e4f7b4b409323b01aa01b39e15ce6139e29aa073) - fix circular dependency with client + upload. Thanks [@pngwn](https://github.com/pngwn)!
|
704 |
+
- [#6094](https://github.com/gradio-app/gradio/pull/6094) [`c476bd5a5`](https://github.com/gradio-app/gradio/commit/c476bd5a5b70836163b9c69bf4bfe068b17fbe13) - Image v4. Thanks [@pngwn](https://github.com/pngwn)!
|
705 |
+
- [#6069](https://github.com/gradio-app/gradio/pull/6069) [`bf127e124`](https://github.com/gradio-app/gradio/commit/bf127e1241a41401e144874ea468dff8474eb505) - Swap websockets for SSE. Thanks [@aliabid94](https://github.com/aliabid94)!
|
706 |
+
|
707 |
+
## 0.7.0-beta.0
|
708 |
+
|
709 |
+
### Features
|
710 |
+
|
711 |
+
- [#6016](https://github.com/gradio-app/gradio/pull/6016) [`83e947676`](https://github.com/gradio-app/gradio/commit/83e947676d327ca2ab6ae2a2d710c78961c771a0) - Format js in v4 branch. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
|
712 |
+
|
713 |
+
### Fixes
|
714 |
+
|
715 |
+
- [#6046](https://github.com/gradio-app/gradio/pull/6046) [`dbb7de5e0`](https://github.com/gradio-app/gradio/commit/dbb7de5e02c53fee05889d696d764d212cb96c74) - fix tests. Thanks [@pngwn](https://github.com/pngwn)!
|
716 |
+
|
717 |
+
## 0.6.0
|
718 |
+
|
719 |
+
### Features
|
720 |
+
|
721 |
+
- [#5972](https://github.com/gradio-app/gradio/pull/5972) [`11a300791`](https://github.com/gradio-app/gradio/commit/11a3007916071f0791844b0a37f0fb4cec69cea3) - Lite: Support opening the entrypoint HTML page directly in browser via the `file:` protocol. Thanks [@whitphx](https://github.com/whitphx)!
|
722 |
+
|
723 |
+
## 0.5.2
|
724 |
+
|
725 |
+
### Fixes
|
726 |
+
|
727 |
+
- [#5840](https://github.com/gradio-app/gradio/pull/5840) [`4e62b8493`](https://github.com/gradio-app/gradio/commit/4e62b8493dfce50bafafe49f1a5deb929d822103) - Ensure websocket polyfill doesn't load if there is already a `global.Webocket` property set. Thanks [@Jay2theWhy](https://github.com/Jay2theWhy)!
|
728 |
+
|
729 |
+
## 0.5.1
|
730 |
+
|
731 |
+
### Fixes
|
732 |
+
|
733 |
+
- [#5816](https://github.com/gradio-app/gradio/pull/5816) [`796145e2c`](https://github.com/gradio-app/gradio/commit/796145e2c48c4087bec17f8ec0be4ceee47170cb) - Fix calls to the component server so that `gr.FileExplorer` works on Spaces. Thanks [@abidlabs](https://github.com/abidlabs)!
|
734 |
+
|
735 |
+
## 0.5.0
|
736 |
+
|
737 |
+
### Highlights
|
738 |
+
|
739 |
+
#### new `FileExplorer` component ([#5672](https://github.com/gradio-app/gradio/pull/5672) [`e4a307ed6`](https://github.com/gradio-app/gradio/commit/e4a307ed6cde3bbdf4ff2f17655739addeec941e))
|
740 |
+
|
741 |
+
Thanks to a new capability that allows components to communicate directly with the server _without_ passing data via the value, we have created a new `FileExplorer` component.
|
742 |
+
|
743 |
+
This component allows you to populate the explorer by passing a glob, but only provides the selected file(s) in your prediction function.
|
744 |
+
|
745 |
+
Users can then navigate the virtual filesystem and select files which will be accessible in your predict function. This component will allow developers to build more complex spaces, with more flexible input options.
|
746 |
+
|
747 |
+

|
748 |
+
|
749 |
+
For more information check the [`FileExplorer` documentation](https://gradio.app/docs/fileexplorer).
|
750 |
+
|
751 |
+
Thanks [@aliabid94](https://github.com/aliabid94)!
|
752 |
+
|
753 |
+
### Features
|
754 |
+
|
755 |
+
- [#5787](https://github.com/gradio-app/gradio/pull/5787) [`caeee8bf7`](https://github.com/gradio-app/gradio/commit/caeee8bf7821fd5fe2f936ed82483bed00f613ec) - ensure the client does not depend on `window` when running in a node environment. Thanks [@gibiee](https://github.com/gibiee)!
|
756 |
+
|
757 |
+
### Fixes
|
758 |
+
|
759 |
+
- [#5776](https://github.com/gradio-app/gradio/pull/5776) [`c0fef4454`](https://github.com/gradio-app/gradio/commit/c0fef44541bfa61568bdcfcdfc7d7d79869ab1df) - Revert replica proxy logic and instead implement using the `root` variable. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
|
760 |
+
|
761 |
+
## 0.4.2
|
762 |
+
|
763 |
+
### Features
|
764 |
+
|
765 |
+
- [#5124](https://github.com/gradio-app/gradio/pull/5124) [`6e56a0d9b`](https://github.com/gradio-app/gradio/commit/6e56a0d9b0c863e76c69e1183d9d40196922b4cd) - Lite: Websocket queueing. Thanks [@whitphx](https://github.com/whitphx)!
|
766 |
+
|
767 |
+
## 0.4.1
|
768 |
+
|
769 |
+
### Fixes
|
770 |
+
|
771 |
+
- [#5705](https://github.com/gradio-app/gradio/pull/5705) [`78e7cf516`](https://github.com/gradio-app/gradio/commit/78e7cf5163e8d205e8999428fce4c02dbdece25f) - ensure internal data has updated before dispatching `success` or `then` events. Thanks [@pngwn](https://github.com/pngwn)!
|
772 |
+
|
773 |
+
## 0.4.0
|
774 |
+
|
775 |
+
### Features
|
776 |
+
|
777 |
+
- [#5682](https://github.com/gradio-app/gradio/pull/5682) [`c57f1b75e`](https://github.com/gradio-app/gradio/commit/c57f1b75e272c76b0af4d6bd0c7f44743ff34f26) - Fix functional tests. Thanks [@abidlabs](https://github.com/abidlabs)!
|
778 |
+
- [#5681](https://github.com/gradio-app/gradio/pull/5681) [`40de3d217`](https://github.com/gradio-app/gradio/commit/40de3d2178b61ebe424b6f6228f94c0c6f679bea) - add query parameters to the `gr.Request` object through the `query_params` attribute. Thanks [@DarhkVoyd](https://github.com/DarhkVoyd)!
|
779 |
+
- [#5653](https://github.com/gradio-app/gradio/pull/5653) [`ea0e00b20`](https://github.com/gradio-app/gradio/commit/ea0e00b207b4b90a10e9d054c4202d4e705a29ba) - Prevent Clients from accessing API endpoints that set `api_name=False`. Thanks [@abidlabs](https://github.com/abidlabs)!
|
780 |
+
|
781 |
+
## 0.3.1
|
782 |
+
|
783 |
+
### Fixes
|
784 |
+
|
785 |
+
- [#5412](https://github.com/gradio-app/gradio/pull/5412) [`26fef8c7`](https://github.com/gradio-app/gradio/commit/26fef8c7f85a006c7e25cdbed1792df19c512d02) - Skip view_api request in js client when auth enabled. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
|
786 |
+
|
787 |
+
## 0.3.0
|
788 |
+
|
789 |
+
### Features
|
790 |
+
|
791 |
+
- [#5267](https://github.com/gradio-app/gradio/pull/5267) [`119c8343`](https://github.com/gradio-app/gradio/commit/119c834331bfae60d4742c8f20e9cdecdd67e8c2) - Faster reload mode. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
|
792 |
+
|
793 |
+
## 0.2.1
|
794 |
+
|
795 |
+
### Features
|
796 |
+
|
797 |
+
- [#5173](https://github.com/gradio-app/gradio/pull/5173) [`730f0c1d`](https://github.com/gradio-app/gradio/commit/730f0c1d54792eb11359e40c9f2326e8a6e39203) - Ensure gradio client works as expected for functions that return nothing. Thanks [@raymondtri](https://github.com/raymondtri)!
|
798 |
+
|
799 |
+
## 0.2.0
|
800 |
+
|
801 |
+
### Features
|
802 |
+
|
803 |
+
- [#5133](https://github.com/gradio-app/gradio/pull/5133) [`61129052`](https://github.com/gradio-app/gradio/commit/61129052ed1391a75c825c891d57fa0ad6c09fc8) - Update dependency esbuild to ^0.19.0. Thanks [@renovate](https://github.com/apps/renovate)!
|
804 |
+
- [#5035](https://github.com/gradio-app/gradio/pull/5035) [`8b4eb8ca`](https://github.com/gradio-app/gradio/commit/8b4eb8cac9ea07bde31b44e2006ca2b7b5f4de36) - JS Client: Fixes cannot read properties of null (reading 'is_file'). Thanks [@raymondtri](https://github.com/raymondtri)!
|
805 |
+
|
806 |
+
### Fixes
|
807 |
+
|
808 |
+
- [#5075](https://github.com/gradio-app/gradio/pull/5075) [`67265a58`](https://github.com/gradio-app/gradio/commit/67265a58027ef1f9e4c0eb849a532f72eaebde48) - Allow supporting >1000 files in `gr.File()` and `gr.UploadButton()`. Thanks [@abidlabs](https://github.com/abidlabs)!
|
809 |
+
|
810 |
+
## 0.1.4
|
811 |
+
|
812 |
+
### Patch Changes
|
813 |
+
|
814 |
+
- [#4717](https://github.com/gradio-app/gradio/pull/4717) [`ab5d1ea0`](https://github.com/gradio-app/gradio/commit/ab5d1ea0de87ed888779b66fd2a705583bd29e02) Thanks [@whitphx](https://github.com/whitphx)! - Fix the package description
|
815 |
+
|
816 |
+
## 0.1.3
|
817 |
+
|
818 |
+
### Patch Changes
|
819 |
+
|
820 |
+
- [#4357](https://github.com/gradio-app/gradio/pull/4357) [`0dbd8f7f`](https://github.com/gradio-app/gradio/commit/0dbd8f7fee4b4877f783fa7bc493f98bbfc3d01d) Thanks [@pngwn](https://github.com/pngwn)! - Various internal refactors and cleanups.
|
821 |
+
|
822 |
+
## 0.1.2
|
823 |
+
|
824 |
+
### Patch Changes
|
825 |
+
|
826 |
+
- [#4273](https://github.com/gradio-app/gradio/pull/4273) [`1d0f0a9d`](https://github.com/gradio-app/gradio/commit/1d0f0a9db096552e67eb2197c932342587e9e61e) Thanks [@pngwn](https://github.com/pngwn)! - Ensure websocket error messages are correctly handled.
|
827 |
+
|
828 |
+
- [#4315](https://github.com/gradio-app/gradio/pull/4315) [`b525b122`](https://github.com/gradio-app/gradio/commit/b525b122dd8569bbaf7e06db5b90d622d2e9073d) Thanks [@whitphx](https://github.com/whitphx)! - Refacor types.
|
829 |
+
|
830 |
+
- [#4271](https://github.com/gradio-app/gradio/pull/4271) [`1151c525`](https://github.com/gradio-app/gradio/commit/1151c5253554cb87ebd4a44a8a470ac215ff782b) Thanks [@pngwn](https://github.com/pngwn)! - Ensure the full root path is always respected when making requests to a gradio app server.
|
831 |
+
|
832 |
+
## 0.1.1
|
833 |
+
|
834 |
+
### Patch Changes
|
835 |
+
|
836 |
+
- [#4201](https://github.com/gradio-app/gradio/pull/4201) [`da5b4ee1`](https://github.com/gradio-app/gradio/commit/da5b4ee11721175858ded96e5710225369097f74) Thanks [@pngwn](https://github.com/pngwn)! - Ensure semiver is bundled so CDN links work correctly.
|
837 |
+
|
838 |
+
- [#4202](https://github.com/gradio-app/gradio/pull/4202) [`a26e9afd`](https://github.com/gradio-app/gradio/commit/a26e9afde319382993e6ddc77cc4e56337a31248) Thanks [@pngwn](https://github.com/pngwn)! - Ensure all URLs returned by the client are complete URLs with the correct host instead of an absolute path relative to a server.
|
839 |
+
|
840 |
+
## 0.1.0
|
841 |
+
|
842 |
+
### Minor Changes
|
843 |
+
|
844 |
+
- [#4185](https://github.com/gradio-app/gradio/pull/4185) [`67239ca9`](https://github.com/gradio-app/gradio/commit/67239ca9b2fe3796853fbf7bf865c9e4b383200d) Thanks [@pngwn](https://github.com/pngwn)! - Update client for initial release
|
845 |
+
|
846 |
+
### Patch Changes
|
847 |
+
|
848 |
+
- [#3692](https://github.com/gradio-app/gradio/pull/3692) [`48e8b113`](https://github.com/gradio-app/gradio/commit/48e8b113f4b55e461d9da4f153bf72aeb4adf0f1) Thanks [@pngwn](https://github.com/pngwn)! - Ensure client works in node, create ESM bundle and generate typescript declaration files.
|
849 |
+
|
850 |
+
- [#3605](https://github.com/gradio-app/gradio/pull/3605) [`ae4277a9`](https://github.com/gradio-app/gradio/commit/ae4277a9a83d49bdadfe523b0739ba988128e73b) Thanks [@pngwn](https://github.com/pngwn)! - Update readme.
|
node_modules/@gradio/client/LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Apache License
|
2 |
+
Version 2.0, January 2004
|
3 |
+
http://www.apache.org/licenses/
|
4 |
+
|
5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6 |
+
|
7 |
+
1. Definitions.
|
8 |
+
|
9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
11 |
+
|
12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13 |
+
the copyright owner that is granting the License.
|
14 |
+
|
15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
16 |
+
other entities that control, are controlled by, or are under common
|
17 |
+
control with that entity. For the purposes of this definition,
|
18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
19 |
+
direction or management of such entity, whether by contract or
|
20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22 |
+
|
23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24 |
+
exercising permissions granted by this License.
|
25 |
+
|
26 |
+
"Source" form shall mean the preferred form for making modifications,
|
27 |
+
including but not limited to software source code, documentation
|
28 |
+
source, and configuration files.
|
29 |
+
|
30 |
+
"Object" form shall mean any form resulting from mechanical
|
31 |
+
transformation or translation of a Source form, including but
|
32 |
+
not limited to compiled object code, generated documentation,
|
33 |
+
and conversions to other media types.
|
34 |
+
|
35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
36 |
+
Object form, made available under the License, as indicated by a
|
37 |
+
copyright notice that is included in or attached to the work
|
38 |
+
(an example is provided in the Appendix below).
|
39 |
+
|
40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41 |
+
form, that is based on (or derived from) the Work and for which the
|
42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
44 |
+
of this License, Derivative Works shall not include works that remain
|
45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46 |
+
the Work and Derivative Works thereof.
|
47 |
+
|
48 |
+
"Contribution" shall mean any work of authorship, including
|
49 |
+
the original version of the Work and any modifications or additions
|
50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
54 |
+
means any form of electronic, verbal, or written communication sent
|
55 |
+
to the Licensor or its representatives, including but not limited to
|
56 |
+
communication on electronic mailing lists, source code control systems,
|
57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
59 |
+
excluding communication that is conspicuously marked or otherwise
|
60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
61 |
+
|
62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
64 |
+
subsequently incorporated within the Work.
|
65 |
+
|
66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
71 |
+
Work and such Derivative Works in Source or Object form.
|
72 |
+
|
73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76 |
+
(except as stated in this section) patent license to make, have made,
|
77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78 |
+
where such license applies only to those patent claims licensable
|
79 |
+
by such Contributor that are necessarily infringed by their
|
80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
82 |
+
institute patent litigation against any entity (including a
|
83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84 |
+
or a Contribution incorporated within the Work constitutes direct
|
85 |
+
or contributory patent infringement, then any patent licenses
|
86 |
+
granted to You under this License for that Work shall terminate
|
87 |
+
as of the date such litigation is filed.
|
88 |
+
|
89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
90 |
+
Work or Derivative Works thereof in any medium, with or without
|
91 |
+
modifications, and in Source or Object form, provided that You
|
92 |
+
meet the following conditions:
|
93 |
+
|
94 |
+
(a) You must give any other recipients of the Work or
|
95 |
+
Derivative Works a copy of this License; and
|
96 |
+
|
97 |
+
(b) You must cause any modified files to carry prominent notices
|
98 |
+
stating that You changed the files; and
|
99 |
+
|
100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
101 |
+
that You distribute, all copyright, patent, trademark, and
|
102 |
+
attribution notices from the Source form of the Work,
|
103 |
+
excluding those notices that do not pertain to any part of
|
104 |
+
the Derivative Works; and
|
105 |
+
|
106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107 |
+
distribution, then any Derivative Works that You distribute must
|
108 |
+
include a readable copy of the attribution notices contained
|
109 |
+
within such NOTICE file, excluding those notices that do not
|
110 |
+
pertain to any part of the Derivative Works, in at least one
|
111 |
+
of the following places: within a NOTICE text file distributed
|
112 |
+
as part of the Derivative Works; within the Source form or
|
113 |
+
documentation, if provided along with the Derivative Works; or,
|
114 |
+
within a display generated by the Derivative Works, if and
|
115 |
+
wherever such third-party notices normally appear. The contents
|
116 |
+
of the NOTICE file are for informational purposes only and
|
117 |
+
do not modify the License. You may add Your own attribution
|
118 |
+
notices within Derivative Works that You distribute, alongside
|
119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
120 |
+
that such additional attribution notices cannot be construed
|
121 |
+
as modifying the License.
|
122 |
+
|
123 |
+
You may add Your own copyright statement to Your modifications and
|
124 |
+
may provide additional or different license terms and conditions
|
125 |
+
for use, reproduction, or distribution of Your modifications, or
|
126 |
+
for any such Derivative Works as a whole, provided Your use,
|
127 |
+
reproduction, and distribution of the Work otherwise complies with
|
128 |
+
the conditions stated in this License.
|
129 |
+
|
130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
132 |
+
by You to the Licensor shall be under the terms and conditions of
|
133 |
+
this License, without any additional terms or conditions.
|
134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135 |
+
the terms of any separate license agreement you may have executed
|
136 |
+
with Licensor regarding such Contributions.
|
137 |
+
|
138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
140 |
+
except as required for reasonable and customary use in describing the
|
141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
142 |
+
|
143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144 |
+
agreed to in writing, Licensor provides the Work (and each
|
145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147 |
+
implied, including, without limitation, any warranties or conditions
|
148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150 |
+
appropriateness of using or redistributing the Work and assume any
|
151 |
+
risks associated with Your exercise of permissions under this License.
|
152 |
+
|
153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
154 |
+
whether in tort (including negligence), contract, or otherwise,
|
155 |
+
unless required by applicable law (such as deliberate and grossly
|
156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157 |
+
liable to You for damages, including any direct, indirect, special,
|
158 |
+
incidental, or consequential damages of any character arising as a
|
159 |
+
result of this License or out of the use or inability to use the
|
160 |
+
Work (including but not limited to damages for loss of goodwill,
|
161 |
+
work stoppage, computer failure or malfunction, or any and all
|
162 |
+
other commercial damages or losses), even if such Contributor
|
163 |
+
has been advised of the possibility of such damages.
|
164 |
+
|
165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168 |
+
or other liability obligations and/or rights consistent with this
|
169 |
+
License. However, in accepting such obligations, You may act only
|
170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171 |
+
of any other Contributor, and only if You agree to indemnify,
|
172 |
+
defend, and hold each Contributor harmless for any liability
|
173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
174 |
+
of your accepting any such warranty or additional liability.
|
175 |
+
|
176 |
+
END OF TERMS AND CONDITIONS
|
177 |
+
|
178 |
+
APPENDIX: How to apply the Apache License to your work.
|
179 |
+
|
180 |
+
To apply the Apache License to your work, attach the following
|
181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182 |
+
replaced with your own identifying information. (Don't include
|
183 |
+
the brackets!) The text should be enclosed in the appropriate
|
184 |
+
comment syntax for the file format. We also recommend that a
|
185 |
+
file or class name and description of purpose be included on the
|
186 |
+
same "printed page" as the copyright notice for easier
|
187 |
+
identification within third-party archives.
|
188 |
+
|
189 |
+
Copyright [yyyy] [name of copyright owner]
|
190 |
+
|
191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192 |
+
you may not use this file except in compliance with the License.
|
193 |
+
You may obtain a copy of the License at
|
194 |
+
|
195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
196 |
+
|
197 |
+
Unless required by applicable law or agreed to in writing, software
|
198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200 |
+
See the License for the specific language governing permissions and
|
201 |
+
limitations under the License.
|
node_modules/@gradio/client/README.md
ADDED
@@ -0,0 +1,448 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## JavaScript Client Library
|
2 |
+
|
3 |
+
Interact with Gradio APIs using our JavaScript (and TypeScript) client.
|
4 |
+
|
5 |
+
|
6 |
+
## Installation
|
7 |
+
|
8 |
+
The Gradio JavaScript Client is available on npm as `@gradio/client`. You can install it as below:
|
9 |
+
|
10 |
+
```shell
|
11 |
+
npm i @gradio/client
|
12 |
+
```
|
13 |
+
|
14 |
+
Or, you can include it directly in your HTML via the jsDelivr CDN:
|
15 |
+
|
16 |
+
```shell
|
17 |
+
<script src="https://cdn.jsdelivr.net/npm/@gradio/client/dist/index.min.js"></script>
|
18 |
+
```
|
19 |
+
|
20 |
+
## Usage
|
21 |
+
|
22 |
+
The JavaScript Gradio Client exposes the Client class, `Client`, along with various other utility functions. `Client` is used to initialise and establish a connection to, or duplicate, a Gradio app.
|
23 |
+
|
24 |
+
### `Client`
|
25 |
+
|
26 |
+
The Client function connects to the API of a hosted Gradio space and returns an object that allows you to make calls to that API.
|
27 |
+
|
28 |
+
The simplest example looks like this:
|
29 |
+
|
30 |
+
```ts
|
31 |
+
import { Client } from "@gradio/client";
|
32 |
+
|
33 |
+
const app = await Client.connect("user/space-name");
|
34 |
+
const result = await app.predict("/predict");
|
35 |
+
```
|
36 |
+
|
37 |
+
This function accepts two arguments: `source` and `options`:
|
38 |
+
|
39 |
+
#### `source`
|
40 |
+
|
41 |
+
This is the url or name of the gradio app whose API you wish to connect to. This parameter is required and should always be a string. For example:
|
42 |
+
|
43 |
+
```ts
|
44 |
+
Client.connect("user/space-name");
|
45 |
+
```
|
46 |
+
|
47 |
+
#### `options`
|
48 |
+
|
49 |
+
The options object can optionally be passed a second parameter. This object has two properties, `hf_token` and `status_callback`.
|
50 |
+
|
51 |
+
##### `hf_token`
|
52 |
+
|
53 |
+
This should be a Hugging Face personal access token and is required if you wish to make calls to a private gradio api. This option is optional and should be a string starting with `"hf_"`.
|
54 |
+
|
55 |
+
Example:
|
56 |
+
|
57 |
+
```ts
|
58 |
+
import { Client } from "@gradio/client";
|
59 |
+
|
60 |
+
const app = await Client.connect("user/space-name", { hf_token: "hf_..." });
|
61 |
+
```
|
62 |
+
|
63 |
+
##### `status_callback`
|
64 |
+
|
65 |
+
This should be a function which will notify you of the status of a space if it is not running. If the gradio API you are connecting to is not awake and running or is not hosted on Hugging Face space then this function will do nothing.
|
66 |
+
|
67 |
+
**Additional context**
|
68 |
+
|
69 |
+
Applications hosted on Hugging Face spaces can be in a number of different states. As spaces are a GitOps tool and will rebuild when new changes are pushed to the repository, they have various building, running and error states. If a space is not 'running' then the function passed as the `status_callback` will notify you of the current state of the space and the status of the space as it changes. Spaces that are building or sleeping can take longer than usual to respond, so you can use this information to give users feedback about the progress of their action.
|
70 |
+
|
71 |
+
```ts
|
72 |
+
import { Client, type SpaceStatus } from "@gradio/client";
|
73 |
+
|
74 |
+
const app = await Client.connect("user/space-name", {
|
75 |
+
// The space_status parameter does not need to be manually annotated, this is just for illustration.
|
76 |
+
space_status: (space_status: SpaceStatus) => console.log(space_status)
|
77 |
+
});
|
78 |
+
```
|
79 |
+
|
80 |
+
```ts
|
81 |
+
interface SpaceStatusNormal {
|
82 |
+
status: "sleeping" | "running" | "building" | "error" | "stopped";
|
83 |
+
detail:
|
84 |
+
| "SLEEPING"
|
85 |
+
| "RUNNING"
|
86 |
+
| "RUNNING_BUILDING"
|
87 |
+
| "BUILDING"
|
88 |
+
| "NOT_FOUND";
|
89 |
+
load_status: "pending" | "error" | "complete" | "generating";
|
90 |
+
message: string;
|
91 |
+
}
|
92 |
+
|
93 |
+
interface SpaceStatusError {
|
94 |
+
status: "space_error";
|
95 |
+
detail: "NO_APP_FILE" | "CONFIG_ERROR" | "BUILD_ERROR" | "RUNTIME_ERROR";
|
96 |
+
load_status: "error";
|
97 |
+
message: string;
|
98 |
+
discussions_enabled: boolean;
|
99 |
+
|
100 |
+
type SpaceStatus = SpaceStatusNormal | SpaceStatusError;
|
101 |
+
```
|
102 |
+
|
103 |
+
The gradio client returns an object with a number of methods and properties:
|
104 |
+
|
105 |
+
#### `predict`
|
106 |
+
|
107 |
+
The `predict` method allows you to call an api endpoint and get a prediction result:
|
108 |
+
|
109 |
+
```ts
|
110 |
+
import { Client } from "@gradio/client";
|
111 |
+
|
112 |
+
const app = await Client.connect("user/space-name");
|
113 |
+
const result = await app.predict("/predict");
|
114 |
+
```
|
115 |
+
|
116 |
+
`predict` accepts two parameters, `endpoint` and `payload`. It returns a promise that resolves to the prediction result.
|
117 |
+
|
118 |
+
##### `endpoint`
|
119 |
+
|
120 |
+
This is the endpoint for an api request and is required. The default endpoint for a `gradio.Interface` is `"/predict"`. Explicitly named endpoints have a custom name. The endpoint names can be found on the "View API" page of a space.
|
121 |
+
|
122 |
+
```ts
|
123 |
+
import { Client } from "@gradio/client";
|
124 |
+
|
125 |
+
const app = await Client.connect("user/space-name");
|
126 |
+
const result = await app.predict("/predict");
|
127 |
+
```
|
128 |
+
|
129 |
+
##### `payload`
|
130 |
+
|
131 |
+
The `payload` argument is generally required but this depends on the API itself. If the API endpoint depends on values being passed in then the argument is required for the API request to succeed. The data that should be passed in is detailed on the "View API" page of a space, or accessible via the `view_api()` method of the client.
|
132 |
+
|
133 |
+
```ts
|
134 |
+
import { Client } from "@gradio/client";
|
135 |
+
|
136 |
+
const app = await Client.connect("user/space-name");
|
137 |
+
const result = await app.predict("/predict", {
|
138 |
+
input: 1,
|
139 |
+
word_1: "Hello",
|
140 |
+
word_2: "friends"
|
141 |
+
});
|
142 |
+
```
|
143 |
+
|
144 |
+
#### `submit`
|
145 |
+
|
146 |
+
The `submit` method provides a more flexible way to call an API endpoint, providing you with status updates about the current progress of the prediction as well as supporting more complex endpoint types.
|
147 |
+
|
148 |
+
```ts
|
149 |
+
import { Client } from "@gradio/client";
|
150 |
+
|
151 |
+
const app = await Client.connect("user/space-name");
|
152 |
+
const submission = app.submit("/predict", { name: "Chewbacca" });
|
153 |
+
```
|
154 |
+
|
155 |
+
The `submit` method accepts the same [`endpoint`](#endpoint) and [`payload`](#payload) arguments as `predict`.
|
156 |
+
|
157 |
+
The `submit` method does not return a promise and should not be awaited, instead it returns an async iterator with a `cancel` method.
|
158 |
+
|
159 |
+
##### Accessing values
|
160 |
+
|
161 |
+
Iterating the submission allows you to access the events related to the submitted API request. There are two types of events that can be listened for: `"data"` updates and `"status"` updates. By default only the `"data"` event is reported, but you can listen for the `"status"` event by manually passing the events you care about when instantiating the client:
|
162 |
+
|
163 |
+
```ts
|
164 |
+
import { Client } from "@gradio/client";
|
165 |
+
|
166 |
+
const app = await Client.connect("user/space-name", {
|
167 |
+
events: ["data", "status"]
|
168 |
+
});
|
169 |
+
```
|
170 |
+
|
171 |
+
`"data"` updates are issued when the API computes a value, the callback provided as the second argument will be called when such a value is sent to the client. The shape of the data depends on the way the API itself is constructed. This event may fire more than once if that endpoint supports emmitting new values over time.
|
172 |
+
|
173 |
+
`"status` updates are issued when the status of a request changes. This information allows you to offer feedback to users when the queue position of the request changes, or when the request changes from queued to processing.
|
174 |
+
|
175 |
+
The status payload look like this:
|
176 |
+
|
177 |
+
```ts
|
178 |
+
interface Status {
|
179 |
+
queue: boolean;
|
180 |
+
code?: string;
|
181 |
+
success?: boolean;
|
182 |
+
stage: "pending" | "error" | "complete" | "generating";
|
183 |
+
size?: number;
|
184 |
+
position?: number;
|
185 |
+
eta?: number;
|
186 |
+
message?: string;
|
187 |
+
progress_data?: Array<{
|
188 |
+
progress: number | null;
|
189 |
+
index: number | null;
|
190 |
+
length: number | null;
|
191 |
+
unit: string | null;
|
192 |
+
desc: string | null;
|
193 |
+
}>;
|
194 |
+
time?: Date;
|
195 |
+
}
|
196 |
+
```
|
197 |
+
|
198 |
+
Usage looks like this:
|
199 |
+
|
200 |
+
```ts
|
201 |
+
import { Client } from "@gradio/client";
|
202 |
+
|
203 |
+
const app = await Client.connect("user/space-name");
|
204 |
+
const submission = app
|
205 |
+
.submit("/predict", { name: "Chewbacca" })
|
206 |
+
|
207 |
+
for await (const msg of submission) {
|
208 |
+
if (msg.type === "data") {
|
209 |
+
console.log(msg.data);
|
210 |
+
}
|
211 |
+
|
212 |
+
if (msg.type === "status") {
|
213 |
+
console.log(msg);
|
214 |
+
}
|
215 |
+
}
|
216 |
+
```
|
217 |
+
|
218 |
+
|
219 |
+
##### `cancel`
|
220 |
+
|
221 |
+
Certain types of gradio function can run repeatedly and in some cases indefinitely. the `cancel` method will stop such an endpoints and prevent the API from issuing additional updates.
|
222 |
+
|
223 |
+
```ts
|
224 |
+
import { Client } from "@gradio/client";
|
225 |
+
|
226 |
+
const app = await Client.connect("user/space-name");
|
227 |
+
const submission = app
|
228 |
+
.submit("/predict", { name: "Chewbacca" })
|
229 |
+
|
230 |
+
|
231 |
+
// later
|
232 |
+
|
233 |
+
submission.cancel();
|
234 |
+
```
|
235 |
+
|
236 |
+
#### `view_api`
|
237 |
+
|
238 |
+
The `view_api` method provides details about the API you are connected to. It returns a JavaScript object of all named endpoints, unnamed endpoints and what values they accept and return. This method does not accept arguments.
|
239 |
+
|
240 |
+
```ts
|
241 |
+
import { Client } from "@gradio/client";
|
242 |
+
|
243 |
+
const app = await Client.connect("user/space-name");
|
244 |
+
const api_info = await app.view_api();
|
245 |
+
|
246 |
+
console.log(api_info);
|
247 |
+
```
|
248 |
+
|
249 |
+
#### `config`
|
250 |
+
|
251 |
+
The `config` property contains the configuration for the gradio application you are connected to. This object may contain useful meta information about the application.
|
252 |
+
|
253 |
+
```ts
|
254 |
+
import { Client } from "@gradio/client";
|
255 |
+
|
256 |
+
const app = await Client.connect("user/space-name");
|
257 |
+
console.log(app.config);
|
258 |
+
```
|
259 |
+
|
260 |
+
### `duplicate`
|
261 |
+
|
262 |
+
The duplicate function will attempt to duplicate the space that is referenced and return an instance of `client` connected to that space. If the space has already been duplicated then it will not create a new duplicate and will instead connect to the existing duplicated space. The huggingface token that is passed in will dictate the user under which the space is created.
|
263 |
+
|
264 |
+
`duplicate` accepts the same arguments as `client` with the addition of a `private` options property dictating whether the duplicated space should be private or public. A huggingface token is required for duplication to work.
|
265 |
+
|
266 |
+
```ts
|
267 |
+
import { Client } from "@gradio/client";
|
268 |
+
|
269 |
+
const app = await Client.duplicate("user/space-name", {
|
270 |
+
hf_token: "hf_..."
|
271 |
+
});
|
272 |
+
```
|
273 |
+
|
274 |
+
This function accepts two arguments: `source` and `options`:
|
275 |
+
|
276 |
+
#### `source`
|
277 |
+
|
278 |
+
The space to duplicate and connect to. [See `client`'s `source` parameter](#source).
|
279 |
+
|
280 |
+
#### `options`
|
281 |
+
|
282 |
+
Accepts all options that `client` accepts, except `hf_token` is required. [See `client`'s `options` parameter](#source).
|
283 |
+
|
284 |
+
`duplicate` also accepts one additional `options` property.
|
285 |
+
|
286 |
+
##### `private`
|
287 |
+
|
288 |
+
This is an optional property specific to `duplicate`'s options object and will determine whether the space should be public or private. Spaces duplicated via the `duplicate` method are public by default.
|
289 |
+
|
290 |
+
```ts
|
291 |
+
import { Client } from "@gradio/client";
|
292 |
+
|
293 |
+
const app = await Client.duplicate("user/space-name", {
|
294 |
+
hf_token: "hf_...",
|
295 |
+
private: true
|
296 |
+
});
|
297 |
+
```
|
298 |
+
|
299 |
+
##### `timeout`
|
300 |
+
|
301 |
+
This is an optional property specific to `duplicate`'s options object and will set the timeout in minutes before the duplicated space will go to sleep.
|
302 |
+
|
303 |
+
```ts
|
304 |
+
import { Client } from "@gradio/client";
|
305 |
+
|
306 |
+
const app = await Client.duplicate("user/space-name", {
|
307 |
+
hf_token: "hf_...",
|
308 |
+
private: true,
|
309 |
+
timeout: 5
|
310 |
+
});
|
311 |
+
```
|
312 |
+
|
313 |
+
##### `hardware`
|
314 |
+
|
315 |
+
This is an optional property specific to `duplicate`'s options object and will set the hardware for the duplicated space. By default the hardware used will match that of the original space. If this cannot be obtained it will default to `"cpu-basic"`. For hardware upgrades (beyond the basic CPU tier), you may be required to provide [billing information on Hugging Face](https://huggingface.co/settings/billing).
|
316 |
+
|
317 |
+
Possible hardware options are:
|
318 |
+
|
319 |
+
- `"cpu-basic"`
|
320 |
+
- `"cpu-upgrade"`
|
321 |
+
- `"cpu-xl"`
|
322 |
+
- `"t4-small"`
|
323 |
+
- `"t4-medium"`
|
324 |
+
- `"a10g-small"`
|
325 |
+
- `"a10g-large"`
|
326 |
+
- `"a10g-largex2"`
|
327 |
+
- `"a10g-largex4"`
|
328 |
+
- `"a100-large"`
|
329 |
+
- `"zero-a10g"`
|
330 |
+
- `"h100"`
|
331 |
+
- `"h100x8"`
|
332 |
+
|
333 |
+
```ts
|
334 |
+
import { Client } from "@gradio/client";
|
335 |
+
|
336 |
+
const app = await Client.duplicate("user/space-name", {
|
337 |
+
hf_token: "hf_...",
|
338 |
+
private: true,
|
339 |
+
hardware: "a10g-small"
|
340 |
+
});
|
341 |
+
```
|
342 |
+
|
343 |
+
### `handle_file(file_or_url: File | string | Blob | Buffer)`
|
344 |
+
|
345 |
+
This utility function is used to simplify the process of handling file inputs for the client.
|
346 |
+
|
347 |
+
Gradio APIs expect a special file datastructure that references a location on the server. These files can be manually uploaded but figuring what to do with different file types can be difficult depending on your environment.
|
348 |
+
|
349 |
+
This function will handle files regardless of whether or not they are local files (node only), URLs, Blobs, or Buffers. It will take in a reference and handle it accordingly,uploading the file where appropriate and generating the correct data structure for the client.
|
350 |
+
|
351 |
+
The return value of this function can be used anywhere in the input data where a file is expected:
|
352 |
+
|
353 |
+
```ts
|
354 |
+
import { handle_file } from "@gradio/client";
|
355 |
+
|
356 |
+
const app = await Client.connect("user/space-name");
|
357 |
+
const result = await app.predict("/predict", {
|
358 |
+
single: handle_file(file),
|
359 |
+
flat: [handle_file(url), handle_file(buffer)],
|
360 |
+
nested: {
|
361 |
+
image: handle_file(url),
|
362 |
+
layers: [handle_file(buffer)]
|
363 |
+
},
|
364 |
+
deeply_nested: {
|
365 |
+
image: handle_file(url),
|
366 |
+
layers: [{
|
367 |
+
layer1: handle_file(buffer),
|
368 |
+
layer2: handle_file(buffer)
|
369 |
+
}]
|
370 |
+
}
|
371 |
+
});
|
372 |
+
```
|
373 |
+
|
374 |
+
#### filepaths
|
375 |
+
|
376 |
+
`handle_file` can be passed a local filepath which it will upload to the client server and return a reference that the client can understand.
|
377 |
+
|
378 |
+
This only works in a node environment.
|
379 |
+
|
380 |
+
Filepaths are resolved relative to the current working directory, not the location of the file that calls `handle_file`.
|
381 |
+
|
382 |
+
```ts
|
383 |
+
import { handle_file } from "@gradio/client";
|
384 |
+
|
385 |
+
// not uploaded yet
|
386 |
+
const file_ref = handle_file("path/to/file");
|
387 |
+
|
388 |
+
const app = await Client.connect("user/space-name");
|
389 |
+
|
390 |
+
// upload happens here
|
391 |
+
const result = await app.predict("/predict", {
|
392 |
+
file: file_ref,
|
393 |
+
});
|
394 |
+
```
|
395 |
+
|
396 |
+
#### URLs
|
397 |
+
|
398 |
+
`handle_file` can be passed a URL which it will convert into a reference that the client can understand.
|
399 |
+
|
400 |
+
```ts
|
401 |
+
import { handle_file } from "@gradio/client";
|
402 |
+
|
403 |
+
const url_ref = handle_file("https://example.com/file.png");
|
404 |
+
|
405 |
+
const app = await Client.connect("user/space-name");
|
406 |
+
const result = await app.predict("/predict", {
|
407 |
+
url: url_ref,
|
408 |
+
});
|
409 |
+
```
|
410 |
+
|
411 |
+
#### Blobs
|
412 |
+
|
413 |
+
`handle_file` can be passed a Blob which it will upload to the client server and return a reference that the client can understand.
|
414 |
+
|
415 |
+
The upload is not initiated until predict or submit are called.
|
416 |
+
|
417 |
+
```ts
|
418 |
+
import { handle_file } from "@gradio/client";
|
419 |
+
|
420 |
+
// not uploaded yet
|
421 |
+
const blob_ref = handle_file(new Blob(["Hello, world!"]));
|
422 |
+
|
423 |
+
const app = await Client.connect("user/space-name");
|
424 |
+
|
425 |
+
// upload happens here
|
426 |
+
const result = await app.predict("/predict", {
|
427 |
+
blob: blob_ref,
|
428 |
+
});
|
429 |
+
```
|
430 |
+
|
431 |
+
#### Buffers
|
432 |
+
|
433 |
+
`handle_file` can be passed a Buffer which it will upload to the client server and return a reference that the client can understand.
|
434 |
+
|
435 |
+
```ts
|
436 |
+
import { handle_file } from "@gradio/client";
|
437 |
+
import { readFileSync } from "fs";
|
438 |
+
|
439 |
+
// not uploaded yet
|
440 |
+
const buffer_ref = handle_file(readFileSync("file.png"));
|
441 |
+
|
442 |
+
const app = await Client.connect("user/space-name");
|
443 |
+
|
444 |
+
// upload happens here
|
445 |
+
const result = await app.predict("/predict", {
|
446 |
+
buffer: buffer_ref,
|
447 |
+
});
|
448 |
+
```
|
node_modules/@gradio/client/dist/client.d.ts
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { ApiData, ApiInfo, ClientOptions, Config, DuplicateOptions, EndpointInfo, JsApiData, PredictReturn, SpaceStatus, Status, UploadResponse, SubmitIterable, GradioEvent } from "./types";
|
2 |
+
import { FileData } from "./upload";
|
3 |
+
export declare class Client {
|
4 |
+
app_reference: string;
|
5 |
+
options: ClientOptions;
|
6 |
+
deep_link: string | null;
|
7 |
+
config: Config | undefined;
|
8 |
+
api_prefix: string;
|
9 |
+
api_info: ApiInfo<JsApiData> | undefined;
|
10 |
+
api_map: Record<string, number>;
|
11 |
+
session_hash: string;
|
12 |
+
jwt: string | false;
|
13 |
+
last_status: Record<string, Status["stage"]>;
|
14 |
+
private cookies;
|
15 |
+
stream_status: {
|
16 |
+
open: boolean;
|
17 |
+
};
|
18 |
+
closed: boolean;
|
19 |
+
pending_stream_messages: Record<string, any[][]>;
|
20 |
+
pending_diff_streams: Record<string, any[][]>;
|
21 |
+
event_callbacks: Record<string, (data?: unknown) => Promise<void>>;
|
22 |
+
unclosed_events: Set<string>;
|
23 |
+
heartbeat_event: EventSource | null;
|
24 |
+
abort_controller: AbortController | null;
|
25 |
+
stream_instance: EventSource | null;
|
26 |
+
current_payload: any;
|
27 |
+
ws_map: Record<string, WebSocket | "failed">;
|
28 |
+
get_url_config(url?: string | null): Config;
|
29 |
+
get_page_config(page: string): Config;
|
30 |
+
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
31 |
+
stream(url: URL): EventSource;
|
32 |
+
view_api: () => Promise<ApiInfo<JsApiData>>;
|
33 |
+
upload_files: (root_url: string, files: (Blob | File)[], upload_id?: string) => Promise<UploadResponse>;
|
34 |
+
upload: (file_data: FileData[], root_url: string, upload_id?: string, max_file_size?: number) => Promise<(FileData | null)[] | null>;
|
35 |
+
handle_blob: (endpoint: string, data: unknown[], endpoint_info: EndpointInfo<ApiData | JsApiData>) => Promise<unknown[]>;
|
36 |
+
post_data: (url: string, body: unknown, additional_headers?: any) => Promise<unknown[]>;
|
37 |
+
submit: (endpoint: string | number, data: unknown[] | Record<string, unknown> | undefined, event_data?: unknown, trigger_id?: number | null, all_events?: boolean) => SubmitIterable<GradioEvent>;
|
38 |
+
predict: (endpoint: string | number, data: unknown[] | Record<string, unknown> | undefined, event_data?: unknown) => Promise<PredictReturn>;
|
39 |
+
open_stream: () => Promise<void>;
|
40 |
+
private resolve_config;
|
41 |
+
private resolve_cookies;
|
42 |
+
constructor(app_reference: string, options?: ClientOptions);
|
43 |
+
private init;
|
44 |
+
_resolve_hearbeat(_config: Config): Promise<void>;
|
45 |
+
static connect(app_reference: string, options?: ClientOptions): Promise<Client>;
|
46 |
+
close(): void;
|
47 |
+
set_current_payload(payload: any): void;
|
48 |
+
static duplicate(app_reference: string, options?: DuplicateOptions): Promise<Client>;
|
49 |
+
private _resolve_config;
|
50 |
+
private config_success;
|
51 |
+
handle_space_success(status: SpaceStatus): Promise<Config | void>;
|
52 |
+
component_server(component_id: number, fn_name: string, data: unknown[] | {
|
53 |
+
binary: boolean;
|
54 |
+
data: Record<string, any>;
|
55 |
+
}): Promise<unknown>;
|
56 |
+
set_cookies(raw_cookies: string): void;
|
57 |
+
private prepare_return_obj;
|
58 |
+
private connect_ws;
|
59 |
+
send_ws_message(url: string, data: any): Promise<void>;
|
60 |
+
close_ws(url: string): Promise<void>;
|
61 |
+
}
|
62 |
+
/**
|
63 |
+
* @deprecated This method will be removed in v1.0. Use `Client.connect()` instead.
|
64 |
+
* Creates a client instance for interacting with Gradio apps.
|
65 |
+
*
|
66 |
+
* @param {string} app_reference - The reference or URL to a Gradio space or app.
|
67 |
+
* @param {ClientOptions} options - Configuration options for the client.
|
68 |
+
* @returns {Promise<Client>} A promise that resolves to a `Client` instance.
|
69 |
+
*/
|
70 |
+
export declare function client(app_reference: string, options?: ClientOptions): Promise<Client>;
|
71 |
+
/**
|
72 |
+
* @deprecated This method will be removed in v1.0. Use `Client.duplicate()` instead.
|
73 |
+
* Creates a duplicate of a space and returns a client instance for the duplicated space.
|
74 |
+
*
|
75 |
+
* @param {string} app_reference - The reference or URL to a Gradio space or app to duplicate.
|
76 |
+
* @param {DuplicateOptions} options - Configuration options for the client.
|
77 |
+
* @returns {Promise<Client>} A promise that resolves to a `Client` instance.
|
78 |
+
*/
|
79 |
+
export declare function duplicate_space(app_reference: string, options: DuplicateOptions): Promise<Client>;
|
80 |
+
export type ClientInstance = Client;
|
81 |
+
//# sourceMappingURL=client.d.ts.map
|
node_modules/@gradio/client/dist/client.d.ts.map
ADDED
@@ -0,0 +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;AAuB5C,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,EAAE,MAAM,CAA2C;IAC/D,GAAG,EAAE,MAAM,GAAG,KAAK,CAAS;IAC5B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAM;IAElD,OAAO,CA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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export declare const HOST_URL = "host";
|
2 |
+
export declare const API_URL = "predict/";
|
3 |
+
export declare const SSE_URL_V0 = "queue/join";
|
4 |
+
export declare const SSE_DATA_URL_V0 = "queue/data";
|
5 |
+
export declare const SSE_URL = "queue/data";
|
6 |
+
export declare const SSE_DATA_URL = "queue/join";
|
7 |
+
export declare const UPLOAD_URL = "upload";
|
8 |
+
export declare const LOGIN_URL = "login";
|
9 |
+
export declare const CONFIG_URL = "config";
|
10 |
+
export declare const API_INFO_URL = "info";
|
11 |
+
export declare const RUNTIME_URL = "runtime";
|
12 |
+
export declare const SLEEPTIME_URL = "sleeptime";
|
13 |
+
export declare const HEARTBEAT_URL = "heartbeat";
|
14 |
+
export declare const COMPONENT_SERVER_URL = "component_server";
|
15 |
+
export declare const RESET_URL = "reset";
|
16 |
+
export declare const CANCEL_URL = "cancel";
|
17 |
+
export declare const RAW_API_INFO_URL = "info?serialize=False";
|
18 |
+
export declare const SPACE_FETCHER_URL = "https://gradio-space-api-fetcher-v2.hf.space/api";
|
19 |
+
export declare const SPACE_URL = "https://hf.space/{}";
|
20 |
+
export declare const QUEUE_FULL_MSG = "This application is currently busy. Please try again. ";
|
21 |
+
export declare const BROKEN_CONNECTION_MSG = "Connection errored out. ";
|
22 |
+
export declare const CONFIG_ERROR_MSG = "Could not resolve app config. ";
|
23 |
+
export declare const SPACE_STATUS_ERROR_MSG = "Could not get space status. ";
|
24 |
+
export declare const API_INFO_ERROR_MSG = "Could not get API info. ";
|
25 |
+
export declare const SPACE_METADATA_ERROR_MSG = "Space metadata could not be loaded. ";
|
26 |
+
export declare const INVALID_URL_MSG = "Invalid URL. A full URL path is required.";
|
27 |
+
export declare const UNAUTHORIZED_MSG = "Not authorized to access this space. ";
|
28 |
+
export declare const INVALID_CREDENTIALS_MSG = "Invalid credentials. Could not login. ";
|
29 |
+
export declare const MISSING_CREDENTIALS_MSG = "Login credentials are required to access this space.";
|
30 |
+
export declare const NODEJS_FS_ERROR_MSG = "File system access is only available in Node.js environments";
|
31 |
+
export declare const ROOT_URL_ERROR_MSG = "Root URL not found in client config";
|
32 |
+
export declare const FILE_PROCESSING_ERROR_MSG = "Error uploading file";
|
33 |
+
//# sourceMappingURL=constants.d.ts.map
|
node_modules/@gradio/client/dist/constants.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,QAAQ,SAAS,CAAC;AAC/B,eAAO,MAAM,OAAO,aAAa,CAAC;AAClC,eAAO,MAAM,UAAU,eAAe,CAAC;AACvC,eAAO,MAAM,eAAe,eAAe,CAAC;AAC5C,eAAO,MAAM,OAAO,eAAe,CAAC;AACpC,eAAO,MAAM,YAAY,eAAe,CAAC;AACzC,eAAO,MAAM,UAAU,WAAW,CAAC;AACnC,eAAO,MAAM,SAAS,UAAU,CAAC;AACjC,eAAO,MAAM,UAAU,WAAW,CAAC;AACnC,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,eAAO,MAAM,WAAW,YAAY,CAAC;AACrC,eAAO,MAAM,aAAa,cAAc,CAAC;AACzC,eAAO,MAAM,aAAa,cAAc,CAAC;AACzC,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AACvD,eAAO,MAAM,SAAS,UAAU,CAAC;AACjC,eAAO,MAAM,UAAU,WAAW,CAAC;AAEnC,eAAO,MAAM,gBAAgB,yBAAyB,CAAC;AACvD,eAAO,MAAM,iBAAiB,qDACqB,CAAC;AACpD,eAAO,MAAM,SAAS,wBAAwB,CAAC;AAG/C,eAAO,MAAM,cAAc,2DAC8B,CAAC;AAC1D,eAAO,MAAM,qBAAqB,6BAA6B,CAAC;AAChE,eAAO,MAAM,gBAAgB,mCAAmC,CAAC;AACjE,eAAO,MAAM,sBAAsB,iCAAiC,CAAC;AACrE,eAAO,MAAM,kBAAkB,6BAA6B,CAAC;AAC7D,eAAO,MAAM,wBAAwB,yCAAyC,CAAC;AAC/E,eAAO,MAAM,eAAe,8CAA8C,CAAC;AAC3E,eAAO,MAAM,gBAAgB,0CAA0C,CAAC;AACxE,eAAO,MAAM,uBAAuB,2CAA2C,CAAC;AAChF,eAAO,MAAM,uBAAuB,yDACmB,CAAC;AACxD,eAAO,MAAM,mBAAmB,iEAC+B,CAAC;AAChE,eAAO,MAAM,kBAAkB,wCAAwC,CAAC;AACxE,eAAO,MAAM,yBAAyB,yBAAyB,CAAC"}
|
node_modules/@gradio/client/dist/helpers/api_info.d.ts
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { ApiData, ApiInfo, Config, JsApiData, EndpointInfo, Status } from "../types";
|
2 |
+
export declare const RE_SPACE_NAME: RegExp;
|
3 |
+
export declare const RE_SPACE_DOMAIN: RegExp;
|
4 |
+
export declare function process_endpoint(app_reference: string, hf_token?: `hf_${string}`): Promise<{
|
5 |
+
space_id: string | false;
|
6 |
+
host: string;
|
7 |
+
ws_protocol: "ws" | "wss";
|
8 |
+
http_protocol: "http:" | "https:";
|
9 |
+
}>;
|
10 |
+
export declare const join_urls: (...urls: string[]) => string;
|
11 |
+
export declare function transform_api_info(api_info: ApiInfo<ApiData>, config: Config, api_map: Record<string, number>): ApiInfo<JsApiData>;
|
12 |
+
export declare function get_type(type: {
|
13 |
+
type: any;
|
14 |
+
description: string;
|
15 |
+
}, component: string, serializer: string, signature_type: "return" | "parameter"): string | undefined;
|
16 |
+
export declare function get_description(type: {
|
17 |
+
type: any;
|
18 |
+
description: string;
|
19 |
+
}, serializer: string): string;
|
20 |
+
export declare function handle_message(data: any, last_status: Status["stage"]): {
|
21 |
+
type: "hash" | "data" | "update" | "complete" | "generating" | "log" | "none" | "heartbeat" | "streaming" | "unexpected_error";
|
22 |
+
data?: any;
|
23 |
+
status?: Status;
|
24 |
+
original_msg?: string;
|
25 |
+
};
|
26 |
+
/**
|
27 |
+
* Maps the provided `data` to the parameters defined by the `/info` endpoint response.
|
28 |
+
* This allows us to support both positional and keyword arguments passed to the client
|
29 |
+
* and ensures that all parameters are either directly provided or have default values assigned.
|
30 |
+
*
|
31 |
+
* @param {unknown[] | Record<string, unknown>} data - The input data for the function,
|
32 |
+
* which can be either an array of values for positional arguments or an object
|
33 |
+
* with key-value pairs for keyword arguments.
|
34 |
+
* @param {JsApiData[]} parameters - Array of parameter descriptions retrieved from the
|
35 |
+
* `/info` endpoint.
|
36 |
+
*
|
37 |
+
* @returns {unknown[]} - Returns an array of resolved data where each element corresponds
|
38 |
+
* to the expected parameter from the API. The `parameter_default` value is used where
|
39 |
+
* a value is not provided for a parameter, and optional parameters without defaults are
|
40 |
+
* set to `undefined`.
|
41 |
+
*
|
42 |
+
* @throws {Error} - Throws an error:
|
43 |
+
* - If more arguments are provided than are defined in the parameters.
|
44 |
+
* * - If no parameter value is provided for a required parameter and no default value is defined.
|
45 |
+
* - If an argument is provided that does not match any defined parameter.
|
46 |
+
*/
|
47 |
+
export declare const map_data_to_params: (data: Record<string, unknown> | unknown[] | undefined, endpoint_info: EndpointInfo<JsApiData | ApiData>) => unknown[];
|
48 |
+
//# sourceMappingURL=api_info.d.ts.map
|
node_modules/@gradio/client/dist/helpers/api_info.d.ts.map
ADDED
@@ -0,0 +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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,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,CAwIA;AAGD;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,eAAO,MAAM,kBAAkB,yEAEf,aAAa,SAAS,GAAG,OAAO,CAAC,KAC9C,OAAO,EA4CT,CAAC"}
|
node_modules/@gradio/client/dist/helpers/data.d.ts
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/// <reference types="node" />
|
2 |
+
import { type ApiData, type BlobRef, type Config, type EndpointInfo, type JsApiData, type DataType, Command, type Dependency, type ComponentMeta } from "../types";
|
3 |
+
import { FileData } from "../upload";
|
4 |
+
export declare function update_object(object: {
|
5 |
+
[x: string]: any;
|
6 |
+
}, newValue: any, stack: (string | number)[]): void;
|
7 |
+
export declare function walk_and_store_blobs(data: DataType, type?: string | undefined, path?: string[], root?: boolean, endpoint_info?: EndpointInfo<ApiData | JsApiData> | undefined): Promise<BlobRef[]>;
|
8 |
+
export declare function skip_queue(id: number, config: Config): boolean;
|
9 |
+
export declare function post_message<Res = any>(message: any, origin: string): Promise<Res>;
|
10 |
+
export declare function handle_file(file_or_url: File | string | Blob | Buffer): FileData | Blob | Command;
|
11 |
+
/**
|
12 |
+
* Handles the payload by filtering out state inputs and returning an array of resolved payload values.
|
13 |
+
* We send null values for state inputs to the server, but we don't want to include them in the resolved payload.
|
14 |
+
*
|
15 |
+
* @param resolved_payload - The resolved payload values received from the client or the server
|
16 |
+
* @param dependency - The dependency object.
|
17 |
+
* @param components - The array of component metadata.
|
18 |
+
* @param with_null_state - Optional. Specifies whether to include null values for state inputs. Default is false.
|
19 |
+
* @returns An array of resolved payload values, filtered based on the dependency and component metadata.
|
20 |
+
*/
|
21 |
+
export declare function handle_payload(resolved_payload: unknown[], dependency: Dependency, components: ComponentMeta[], type: "input" | "output", with_null_state?: boolean): unknown[];
|
22 |
+
//# sourceMappingURL=data.d.ts.map
|
node_modules/@gradio/client/dist/helpers/data.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/helpers/data.ts"],"names":[],"mappings":";AAAA,OAAO,EACN,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,OAAO,EACP,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAKrC,wBAAgB,aAAa,CAC5B,MAAM,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAC5B,QAAQ,EAAE,GAAG,EACb,KAAK,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GACxB,IAAI,CAgBN;AAED,wBAAsB,oBAAoB,CACzC,IAAI,EAAE,QAAQ,EACd,IAAI,GAAE,MAAM,GAAG,SAAqB,EACpC,IAAI,GAAE,MAAM,EAAO,EACnB,IAAI,UAAQ,EACZ,aAAa,GAAE,YAAY,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,SAAqB,GACtE,OAAO,CAAC,OAAO,EAAE,CAAC,CAwDpB;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAM9D;AAID,wBAAgB,YAAY,CAAC,GAAG,GAAG,GAAG,EACrC,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC,GAAG,CAAC,CASd;AAED,wBAAgB,WAAW,CAC1B,WAAW,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,GACxC,QAAQ,GAAG,IAAI,GAAG,OAAO,CAgC3B;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC7B,gBAAgB,EAAE,OAAO,EAAE,EAC3B,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,aAAa,EAAE,EAC3B,IAAI,EAAE,OAAO,GAAG,QAAQ,EACxB,eAAe,UAAQ,GACrB,OAAO,EAAE,CA0CX"}
|
node_modules/@gradio/client/dist/helpers/init_helpers.d.ts
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { Config } from "../types";
|
2 |
+
import { Client } from "..";
|
3 |
+
/**
|
4 |
+
* This function is used to resolve the URL for making requests when the app has a root path.
|
5 |
+
* The root path could be a path suffix like "/app" which is appended to the end of the base URL. Or
|
6 |
+
* it could be a full URL like "https://abidlabs-test-client-replica--gqf2x.hf.space" which is used when hosting
|
7 |
+
* Gradio apps on Hugging Face Spaces.
|
8 |
+
* @param {string} base_url The base URL at which the Gradio server is hosted
|
9 |
+
* @param {string} root_path The root path, which could be a path suffix (e.g. mounted in FastAPI app) or a full URL (e.g. hosted on Hugging Face Spaces)
|
10 |
+
* @param {boolean} prioritize_base Whether to prioritize the base URL over the root path. This is used when both the base path and root paths are full URLs. For example, for fetching files the root path should be prioritized, but for making requests, the base URL should be prioritized.
|
11 |
+
* @returns {string} the resolved URL
|
12 |
+
*/
|
13 |
+
export declare function resolve_root(base_url: string, root_path: string, prioritize_base: boolean): string;
|
14 |
+
export declare function get_jwt(space: string, token: `hf_${string}`, cookies?: string | null): Promise<string | false>;
|
15 |
+
export declare function map_names_to_ids(fns: Config["dependencies"]): Record<string, number>;
|
16 |
+
export declare function resolve_config(this: Client, endpoint: string): Promise<Config | undefined>;
|
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>;
|
19 |
+
export declare function determine_protocol(endpoint: string): {
|
20 |
+
ws_protocol: "ws" | "wss";
|
21 |
+
http_protocol: "http:" | "https:";
|
22 |
+
host: string;
|
23 |
+
};
|
24 |
+
export declare const parse_and_set_cookies: (cookie_header: string) => string[];
|
25 |
+
//# sourceMappingURL=init_helpers.d.ts.map
|
node_modules/@gradio/client/dist/helpers/init_helpers.d.ts.map
ADDED
@@ -0,0 +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,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,CAmD7B;AAED,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,QAAQ,CAAC,EAAE,MAAM,MAAM,EAAE,GACvB,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,CA0BA;AAED,eAAO,MAAM,qBAAqB,kBAAmB,MAAM,KAAG,MAAM,EAUnE,CAAC"}
|
node_modules/@gradio/client/dist/helpers/spaces.d.ts
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { SpaceStatusCallback } from "../types";
|
2 |
+
export declare function check_space_status(id: string, type: "subdomain" | "space_name", status_callback: SpaceStatusCallback): Promise<void>;
|
3 |
+
export declare const check_and_wake_space: (space_id: string, status_callback: SpaceStatusCallback) => Promise<void>;
|
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>;
|
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 |
+
//# sourceMappingURL=spaces.d.ts.map
|
node_modules/@gradio/client/dist/helpers/spaces.d.ts.map
ADDED
@@ -0,0 +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"}
|
node_modules/@gradio/client/dist/index.d.ts
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export { Client } from "./client";
|
2 |
+
export { predict } from "./utils/predict";
|
3 |
+
export { submit } from "./utils/submit";
|
4 |
+
export { upload_files } from "./utils/upload_files";
|
5 |
+
export { FileData, upload, prepare_files } from "./upload";
|
6 |
+
export { handle_file } from "./helpers/data";
|
7 |
+
export type { SpaceStatus, StatusMessage, Status, client_return, UploadResponse, RenderMessage, LogMessage, Payload, Config } from "./types";
|
8 |
+
export { client } from "./client";
|
9 |
+
export { duplicate_space as duplicate } from "./client";
|
10 |
+
//# sourceMappingURL=index.d.ts.map
|
node_modules/@gradio/client/dist/index.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"index.d.ts","source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.defineProperty;
|
2 |
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3 |
+
var __publicField = (obj, key, value) => {
|
4 |
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
5 |
+
return value;
|
6 |
+
};
|
7 |
+
var __accessCheck = (obj, member, msg) => {
|
8 |
+
if (!member.has(obj))
|
9 |
+
throw TypeError("Cannot " + msg);
|
10 |
+
};
|
11 |
+
var __privateGet = (obj, member, getter) => {
|
12 |
+
__accessCheck(obj, member, "read from private field");
|
13 |
+
return getter ? getter.call(obj) : member.get(obj);
|
14 |
+
};
|
15 |
+
var __privateAdd = (obj, member, value) => {
|
16 |
+
if (member.has(obj))
|
17 |
+
throw TypeError("Cannot add the same private member more than once");
|
18 |
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
19 |
+
};
|
20 |
+
var __privateSet = (obj, member, value, setter) => {
|
21 |
+
__accessCheck(obj, member, "write to private field");
|
22 |
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
23 |
+
return value;
|
24 |
+
};
|
25 |
+
var _currentLine;
|
26 |
+
var fn = new Intl.Collator(0, { numeric: 1 }).compare;
|
27 |
+
function semiver(a, b, bool) {
|
28 |
+
a = a.split(".");
|
29 |
+
b = b.split(".");
|
30 |
+
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);
|
31 |
+
}
|
32 |
+
const HOST_URL = `host`;
|
33 |
+
const SSE_URL = `queue/data`;
|
34 |
+
const SSE_DATA_URL = `queue/join`;
|
35 |
+
const UPLOAD_URL = `upload`;
|
36 |
+
const LOGIN_URL = `login`;
|
37 |
+
const CONFIG_URL = `config`;
|
38 |
+
const API_INFO_URL = `info`;
|
39 |
+
const RUNTIME_URL = `runtime`;
|
40 |
+
const SLEEPTIME_URL = `sleeptime`;
|
41 |
+
const HEARTBEAT_URL = `heartbeat`;
|
42 |
+
const COMPONENT_SERVER_URL = `component_server`;
|
43 |
+
const RESET_URL = `reset`;
|
44 |
+
const CANCEL_URL = `cancel`;
|
45 |
+
const SPACE_FETCHER_URL = "https://gradio-space-api-fetcher-v2.hf.space/api";
|
46 |
+
const QUEUE_FULL_MSG = "This application is currently busy. Please try again. ";
|
47 |
+
const BROKEN_CONNECTION_MSG = "Connection errored out. ";
|
48 |
+
const CONFIG_ERROR_MSG = "Could not resolve app config. ";
|
49 |
+
const SPACE_STATUS_ERROR_MSG = "Could not get space status. ";
|
50 |
+
const API_INFO_ERROR_MSG = "Could not get API info. ";
|
51 |
+
const SPACE_METADATA_ERROR_MSG = "Space metadata could not be loaded. ";
|
52 |
+
const INVALID_URL_MSG = "Invalid URL. A full URL path is required.";
|
53 |
+
const UNAUTHORIZED_MSG = "Not authorized to access this space. ";
|
54 |
+
const INVALID_CREDENTIALS_MSG = "Invalid credentials. Could not login. ";
|
55 |
+
const MISSING_CREDENTIALS_MSG = "Login credentials are required to access this space.";
|
56 |
+
const NODEJS_FS_ERROR_MSG = "File system access is only available in Node.js environments";
|
57 |
+
const ROOT_URL_ERROR_MSG = "Root URL not found in client config";
|
58 |
+
const FILE_PROCESSING_ERROR_MSG = "Error uploading file";
|
59 |
+
function resolve_root(base_url, root_path, prioritize_base) {
|
60 |
+
if (root_path.startsWith("http://") || root_path.startsWith("https://")) {
|
61 |
+
return prioritize_base ? base_url : root_path;
|
62 |
+
}
|
63 |
+
return base_url + root_path;
|
64 |
+
}
|
65 |
+
async function get_jwt(space, token, cookies) {
|
66 |
+
try {
|
67 |
+
const r = await fetch(`https://huggingface.co/api/spaces/${space}/jwt`, {
|
68 |
+
headers: {
|
69 |
+
Authorization: `Bearer ${token}`,
|
70 |
+
...cookies ? { Cookie: cookies } : {}
|
71 |
+
}
|
72 |
+
});
|
73 |
+
const jwt = (await r.json()).token;
|
74 |
+
return jwt || false;
|
75 |
+
} catch (e) {
|
76 |
+
return false;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
function map_names_to_ids(fns) {
|
80 |
+
let apis = {};
|
81 |
+
fns.forEach(({ api_name, id }) => {
|
82 |
+
if (api_name)
|
83 |
+
apis[api_name] = id;
|
84 |
+
});
|
85 |
+
return apis;
|
86 |
+
}
|
87 |
+
async function resolve_config(endpoint) {
|
88 |
+
var _a;
|
89 |
+
const headers = this.options.hf_token ? { Authorization: `Bearer ${this.options.hf_token}` } : {};
|
90 |
+
headers["Content-Type"] = "application/json";
|
91 |
+
if (typeof window !== "undefined" && window.gradio_config && location.origin !== "http://localhost:9876" && !window.gradio_config.dev_mode) {
|
92 |
+
const path = window.gradio_config.root;
|
93 |
+
const config = window.gradio_config;
|
94 |
+
let config_root = resolve_root(endpoint, config.root, false);
|
95 |
+
config.root = config_root;
|
96 |
+
return { ...config, path };
|
97 |
+
} else if (endpoint) {
|
98 |
+
let config_url = join_urls(
|
99 |
+
endpoint,
|
100 |
+
this.deep_link ? CONFIG_URL + "?deep_link=" + this.deep_link : CONFIG_URL
|
101 |
+
);
|
102 |
+
const response = await this.fetch(config_url, {
|
103 |
+
headers,
|
104 |
+
credentials: "include"
|
105 |
+
});
|
106 |
+
if ((response == null ? void 0 : response.status) === 401 && !this.options.auth) {
|
107 |
+
throw new Error(MISSING_CREDENTIALS_MSG);
|
108 |
+
} else if ((response == null ? void 0 : response.status) === 401 && this.options.auth) {
|
109 |
+
throw new Error(INVALID_CREDENTIALS_MSG);
|
110 |
+
}
|
111 |
+
if ((response == null ? void 0 : response.status) === 200) {
|
112 |
+
let config = await response.json();
|
113 |
+
config.path = config.path ?? "";
|
114 |
+
config.root = endpoint;
|
115 |
+
(_a = config.dependencies) == null ? void 0 : _a.forEach((dep, i) => {
|
116 |
+
if (dep.id === void 0) {
|
117 |
+
dep.id = i;
|
118 |
+
}
|
119 |
+
});
|
120 |
+
return config;
|
121 |
+
} else if ((response == null ? void 0 : response.status) === 401) {
|
122 |
+
throw new Error(UNAUTHORIZED_MSG);
|
123 |
+
}
|
124 |
+
throw new Error(CONFIG_ERROR_MSG);
|
125 |
+
}
|
126 |
+
throw new Error(CONFIG_ERROR_MSG);
|
127 |
+
}
|
128 |
+
async function resolve_cookies() {
|
129 |
+
const { http_protocol, host } = await process_endpoint(
|
130 |
+
this.app_reference,
|
131 |
+
this.options.hf_token
|
132 |
+
);
|
133 |
+
try {
|
134 |
+
if (this.options.auth) {
|
135 |
+
const cookie_header = await get_cookie_header(
|
136 |
+
http_protocol,
|
137 |
+
host,
|
138 |
+
this.options.auth,
|
139 |
+
this.fetch,
|
140 |
+
this.options.hf_token
|
141 |
+
);
|
142 |
+
if (cookie_header)
|
143 |
+
this.set_cookies(cookie_header);
|
144 |
+
}
|
145 |
+
} catch (e) {
|
146 |
+
throw Error(e.message);
|
147 |
+
}
|
148 |
+
}
|
149 |
+
async function get_cookie_header(http_protocol, host, auth, _fetch, hf_token) {
|
150 |
+
const formData = new FormData();
|
151 |
+
formData.append("username", auth == null ? void 0 : auth[0]);
|
152 |
+
formData.append("password", auth == null ? void 0 : auth[1]);
|
153 |
+
let headers = {};
|
154 |
+
if (hf_token) {
|
155 |
+
headers.Authorization = `Bearer ${hf_token}`;
|
156 |
+
}
|
157 |
+
const res = await _fetch(`${http_protocol}//${host}/${LOGIN_URL}`, {
|
158 |
+
headers,
|
159 |
+
method: "POST",
|
160 |
+
body: formData,
|
161 |
+
credentials: "include"
|
162 |
+
});
|
163 |
+
if (res.status === 200) {
|
164 |
+
return res.headers.get("set-cookie");
|
165 |
+
} else if (res.status === 401) {
|
166 |
+
throw new Error(INVALID_CREDENTIALS_MSG);
|
167 |
+
} else {
|
168 |
+
throw new Error(SPACE_METADATA_ERROR_MSG);
|
169 |
+
}
|
170 |
+
}
|
171 |
+
function determine_protocol(endpoint) {
|
172 |
+
if (endpoint.startsWith("http")) {
|
173 |
+
const { protocol, host, pathname } = new URL(endpoint);
|
174 |
+
return {
|
175 |
+
ws_protocol: protocol === "https:" ? "wss" : "ws",
|
176 |
+
http_protocol: protocol,
|
177 |
+
host: host + (pathname !== "/" ? pathname : "")
|
178 |
+
};
|
179 |
+
} else if (endpoint.startsWith("file:")) {
|
180 |
+
return {
|
181 |
+
ws_protocol: "ws",
|
182 |
+
http_protocol: "http:",
|
183 |
+
host: "lite.local"
|
184 |
+
// Special fake hostname only used for this case. This matches the hostname allowed in `is_self_host()` in `js/wasm/network/host.ts`.
|
185 |
+
};
|
186 |
+
}
|
187 |
+
return {
|
188 |
+
ws_protocol: "wss",
|
189 |
+
http_protocol: "https:",
|
190 |
+
host: new URL(endpoint).host
|
191 |
+
};
|
192 |
+
}
|
193 |
+
const parse_and_set_cookies = (cookie_header) => {
|
194 |
+
let cookies = [];
|
195 |
+
const parts = cookie_header.split(/,(?=\s*[^\s=;]+=[^\s=;]+)/);
|
196 |
+
parts.forEach((cookie) => {
|
197 |
+
const [cookie_name, cookie_value] = cookie.split(";")[0].split("=");
|
198 |
+
if (cookie_name && cookie_value) {
|
199 |
+
cookies.push(`${cookie_name.trim()}=${cookie_value.trim()}`);
|
200 |
+
}
|
201 |
+
});
|
202 |
+
return cookies;
|
203 |
+
};
|
204 |
+
const RE_SPACE_NAME = /^[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_\-\.]+$/;
|
205 |
+
const RE_SPACE_DOMAIN = /.*hf\.space\/{0,1}.*$/;
|
206 |
+
async function process_endpoint(app_reference, hf_token) {
|
207 |
+
const headers = {};
|
208 |
+
if (hf_token) {
|
209 |
+
headers.Authorization = `Bearer ${hf_token}`;
|
210 |
+
}
|
211 |
+
const _app_reference = app_reference.trim().replace(/\/$/, "");
|
212 |
+
if (RE_SPACE_NAME.test(_app_reference)) {
|
213 |
+
try {
|
214 |
+
const res = await fetch(
|
215 |
+
`https://huggingface.co/api/spaces/${_app_reference}/${HOST_URL}`,
|
216 |
+
{ headers }
|
217 |
+
);
|
218 |
+
const _host = (await res.json()).host;
|
219 |
+
return {
|
220 |
+
space_id: app_reference,
|
221 |
+
...determine_protocol(_host)
|
222 |
+
};
|
223 |
+
} catch (e) {
|
224 |
+
throw new Error(SPACE_METADATA_ERROR_MSG);
|
225 |
+
}
|
226 |
+
}
|
227 |
+
if (RE_SPACE_DOMAIN.test(_app_reference)) {
|
228 |
+
const { ws_protocol, http_protocol, host } = determine_protocol(_app_reference);
|
229 |
+
return {
|
230 |
+
space_id: host.split("/")[0].replace(".hf.space", ""),
|
231 |
+
ws_protocol,
|
232 |
+
http_protocol,
|
233 |
+
host
|
234 |
+
};
|
235 |
+
}
|
236 |
+
return {
|
237 |
+
space_id: false,
|
238 |
+
...determine_protocol(_app_reference)
|
239 |
+
};
|
240 |
+
}
|
241 |
+
const join_urls = (...urls) => {
|
242 |
+
try {
|
243 |
+
return urls.reduce((base_url, part) => {
|
244 |
+
base_url = base_url.replace(/\/+$/, "");
|
245 |
+
part = part.replace(/^\/+/, "");
|
246 |
+
return new URL(part, base_url + "/").toString();
|
247 |
+
});
|
248 |
+
} catch (e) {
|
249 |
+
throw new Error(INVALID_URL_MSG);
|
250 |
+
}
|
251 |
+
};
|
252 |
+
function transform_api_info(api_info, config, api_map) {
|
253 |
+
const transformed_info = {
|
254 |
+
named_endpoints: {},
|
255 |
+
unnamed_endpoints: {}
|
256 |
+
};
|
257 |
+
Object.keys(api_info).forEach((category) => {
|
258 |
+
if (category === "named_endpoints" || category === "unnamed_endpoints") {
|
259 |
+
transformed_info[category] = {};
|
260 |
+
Object.entries(api_info[category]).forEach(
|
261 |
+
([endpoint, { parameters, returns }]) => {
|
262 |
+
var _a, _b, _c, _d;
|
263 |
+
const dependencyIndex = ((_a = config.dependencies.find(
|
264 |
+
(dep) => dep.api_name === endpoint || dep.api_name === endpoint.replace("/", "")
|
265 |
+
)) == null ? void 0 : _a.id) || api_map[endpoint.replace("/", "")] || -1;
|
266 |
+
const dependencyTypes = dependencyIndex !== -1 ? (_b = config.dependencies.find((dep) => dep.id == dependencyIndex)) == null ? void 0 : _b.types : { generator: false, cancel: false };
|
267 |
+
if (dependencyIndex !== -1 && ((_d = (_c = config.dependencies.find((dep) => dep.id == dependencyIndex)) == null ? void 0 : _c.inputs) == null ? void 0 : _d.length) !== parameters.length) {
|
268 |
+
const components = config.dependencies.find((dep) => dep.id == dependencyIndex).inputs.map(
|
269 |
+
(input) => {
|
270 |
+
var _a2;
|
271 |
+
return (_a2 = config.components.find((c) => c.id === input)) == null ? void 0 : _a2.type;
|
272 |
+
}
|
273 |
+
);
|
274 |
+
try {
|
275 |
+
components.forEach((comp, idx) => {
|
276 |
+
if (comp === "state") {
|
277 |
+
const new_param = {
|
278 |
+
component: "state",
|
279 |
+
example: null,
|
280 |
+
parameter_default: null,
|
281 |
+
parameter_has_default: true,
|
282 |
+
parameter_name: null,
|
283 |
+
hidden: true
|
284 |
+
};
|
285 |
+
parameters.splice(idx, 0, new_param);
|
286 |
+
}
|
287 |
+
});
|
288 |
+
} catch (e) {
|
289 |
+
console.error(e);
|
290 |
+
}
|
291 |
+
}
|
292 |
+
const transform_type = (data, component, serializer, signature_type) => ({
|
293 |
+
...data,
|
294 |
+
description: get_description(data == null ? void 0 : data.type, serializer),
|
295 |
+
type: get_type(data == null ? void 0 : data.type, component, serializer, signature_type) || ""
|
296 |
+
});
|
297 |
+
transformed_info[category][endpoint] = {
|
298 |
+
parameters: parameters.map(
|
299 |
+
(p) => transform_type(p, p == null ? void 0 : p.component, p == null ? void 0 : p.serializer, "parameter")
|
300 |
+
),
|
301 |
+
returns: returns.map(
|
302 |
+
(r) => transform_type(r, r == null ? void 0 : r.component, r == null ? void 0 : r.serializer, "return")
|
303 |
+
),
|
304 |
+
type: dependencyTypes
|
305 |
+
};
|
306 |
+
}
|
307 |
+
);
|
308 |
+
}
|
309 |
+
});
|
310 |
+
return transformed_info;
|
311 |
+
}
|
312 |
+
function get_type(type, component, serializer, signature_type) {
|
313 |
+
if (component === "Api")
|
314 |
+
return type.type;
|
315 |
+
switch (type == null ? void 0 : type.type) {
|
316 |
+
case "string":
|
317 |
+
return "string";
|
318 |
+
case "boolean":
|
319 |
+
return "boolean";
|
320 |
+
case "number":
|
321 |
+
return "number";
|
322 |
+
}
|
323 |
+
if (serializer === "JSONSerializable" || serializer === "StringSerializable") {
|
324 |
+
return "any";
|
325 |
+
} else if (serializer === "ListStringSerializable") {
|
326 |
+
return "string[]";
|
327 |
+
} else if (component === "Image") {
|
328 |
+
return signature_type === "parameter" ? "Blob | File | Buffer" : "string";
|
329 |
+
} else if (serializer === "FileSerializable") {
|
330 |
+
if ((type == null ? void 0 : type.type) === "array") {
|
331 |
+
return signature_type === "parameter" ? "(Blob | File | Buffer)[]" : `{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}[]`;
|
332 |
+
}
|
333 |
+
return signature_type === "parameter" ? "Blob | File | Buffer" : `{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}`;
|
334 |
+
} else if (serializer === "GallerySerializable") {
|
335 |
+
return signature_type === "parameter" ? "[(Blob | File | Buffer), (string | null)][]" : `[{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}, (string | null))][]`;
|
336 |
+
}
|
337 |
+
}
|
338 |
+
function get_description(type, serializer) {
|
339 |
+
if (serializer === "GallerySerializable") {
|
340 |
+
return "array of [file, label] tuples";
|
341 |
+
} else if (serializer === "ListStringSerializable") {
|
342 |
+
return "array of strings";
|
343 |
+
} else if (serializer === "FileSerializable") {
|
344 |
+
return "array of files or single file";
|
345 |
+
}
|
346 |
+
return type == null ? void 0 : type.description;
|
347 |
+
}
|
348 |
+
function handle_message(data, last_status) {
|
349 |
+
const queue = true;
|
350 |
+
switch (data.msg) {
|
351 |
+
case "send_data":
|
352 |
+
return { type: "data" };
|
353 |
+
case "send_hash":
|
354 |
+
return { type: "hash" };
|
355 |
+
case "queue_full":
|
356 |
+
return {
|
357 |
+
type: "update",
|
358 |
+
status: {
|
359 |
+
queue,
|
360 |
+
message: QUEUE_FULL_MSG,
|
361 |
+
stage: "error",
|
362 |
+
code: data.code,
|
363 |
+
success: data.success
|
364 |
+
}
|
365 |
+
};
|
366 |
+
case "heartbeat":
|
367 |
+
return {
|
368 |
+
type: "heartbeat"
|
369 |
+
};
|
370 |
+
case "unexpected_error":
|
371 |
+
return {
|
372 |
+
type: "unexpected_error",
|
373 |
+
status: {
|
374 |
+
queue,
|
375 |
+
message: data.message,
|
376 |
+
stage: "error",
|
377 |
+
success: false
|
378 |
+
}
|
379 |
+
};
|
380 |
+
case "estimation":
|
381 |
+
return {
|
382 |
+
type: "update",
|
383 |
+
status: {
|
384 |
+
queue,
|
385 |
+
stage: last_status || "pending",
|
386 |
+
code: data.code,
|
387 |
+
size: data.queue_size,
|
388 |
+
position: data.rank,
|
389 |
+
eta: data.rank_eta,
|
390 |
+
success: data.success
|
391 |
+
}
|
392 |
+
};
|
393 |
+
case "progress":
|
394 |
+
return {
|
395 |
+
type: "update",
|
396 |
+
status: {
|
397 |
+
queue,
|
398 |
+
stage: "pending",
|
399 |
+
code: data.code,
|
400 |
+
progress_data: data.progress_data,
|
401 |
+
success: data.success
|
402 |
+
}
|
403 |
+
};
|
404 |
+
case "log":
|
405 |
+
return { type: "log", data };
|
406 |
+
case "process_generating":
|
407 |
+
return {
|
408 |
+
type: "generating",
|
409 |
+
status: {
|
410 |
+
queue,
|
411 |
+
message: !data.success ? data.output.error : null,
|
412 |
+
stage: data.success ? "generating" : "error",
|
413 |
+
code: data.code,
|
414 |
+
progress_data: data.progress_data,
|
415 |
+
eta: data.average_duration,
|
416 |
+
changed_state_ids: data.success ? data.output.changed_state_ids : void 0
|
417 |
+
},
|
418 |
+
data: data.success ? data.output : null
|
419 |
+
};
|
420 |
+
case "process_streaming":
|
421 |
+
return {
|
422 |
+
type: "streaming",
|
423 |
+
status: {
|
424 |
+
queue,
|
425 |
+
message: data.output.error,
|
426 |
+
stage: "streaming",
|
427 |
+
time_limit: data.time_limit,
|
428 |
+
code: data.code,
|
429 |
+
progress_data: data.progress_data,
|
430 |
+
eta: data.eta
|
431 |
+
},
|
432 |
+
data: data.output
|
433 |
+
};
|
434 |
+
case "process_completed":
|
435 |
+
if ("error" in data.output) {
|
436 |
+
return {
|
437 |
+
type: "update",
|
438 |
+
status: {
|
439 |
+
queue,
|
440 |
+
title: data.output.title,
|
441 |
+
message: data.output.error,
|
442 |
+
visible: data.output.visible,
|
443 |
+
duration: data.output.duration,
|
444 |
+
stage: "error",
|
445 |
+
code: data.code,
|
446 |
+
success: data.success
|
447 |
+
}
|
448 |
+
};
|
449 |
+
}
|
450 |
+
return {
|
451 |
+
type: "complete",
|
452 |
+
status: {
|
453 |
+
queue,
|
454 |
+
message: !data.success ? data.output.error : void 0,
|
455 |
+
stage: data.success ? "complete" : "error",
|
456 |
+
code: data.code,
|
457 |
+
progress_data: data.progress_data,
|
458 |
+
changed_state_ids: data.success ? data.output.changed_state_ids : void 0
|
459 |
+
},
|
460 |
+
data: data.success ? data.output : null
|
461 |
+
};
|
462 |
+
case "process_starts":
|
463 |
+
return {
|
464 |
+
type: "update",
|
465 |
+
status: {
|
466 |
+
queue,
|
467 |
+
stage: "pending",
|
468 |
+
code: data.code,
|
469 |
+
size: data.rank,
|
470 |
+
position: 0,
|
471 |
+
success: data.success,
|
472 |
+
eta: data.eta
|
473 |
+
},
|
474 |
+
original_msg: "process_starts"
|
475 |
+
};
|
476 |
+
}
|
477 |
+
return { type: "none", status: { stage: "error", queue } };
|
478 |
+
}
|
479 |
+
const map_data_to_params = (data = [], endpoint_info) => {
|
480 |
+
const parameters = endpoint_info ? endpoint_info.parameters : [];
|
481 |
+
if (Array.isArray(data)) {
|
482 |
+
if (data.length > parameters.length) {
|
483 |
+
console.warn("Too many arguments provided for the endpoint.");
|
484 |
+
}
|
485 |
+
return data;
|
486 |
+
}
|
487 |
+
const resolved_data = [];
|
488 |
+
const provided_keys = Object.keys(data);
|
489 |
+
parameters.forEach((param, index) => {
|
490 |
+
if (data.hasOwnProperty(param.parameter_name)) {
|
491 |
+
resolved_data[index] = data[param.parameter_name];
|
492 |
+
} else if (param.parameter_has_default) {
|
493 |
+
resolved_data[index] = param.parameter_default;
|
494 |
+
} else {
|
495 |
+
throw new Error(
|
496 |
+
`No value provided for required parameter: ${param.parameter_name}`
|
497 |
+
);
|
498 |
+
}
|
499 |
+
});
|
500 |
+
provided_keys.forEach((key) => {
|
501 |
+
if (!parameters.some((param) => param.parameter_name === key)) {
|
502 |
+
throw new Error(
|
503 |
+
`Parameter \`${key}\` is not a valid keyword argument. Please refer to the API for usage.`
|
504 |
+
);
|
505 |
+
}
|
506 |
+
});
|
507 |
+
resolved_data.forEach((value, idx) => {
|
508 |
+
if (value === void 0 && !parameters[idx].parameter_has_default) {
|
509 |
+
throw new Error(
|
510 |
+
`No value provided for required parameter: ${parameters[idx].parameter_name}`
|
511 |
+
);
|
512 |
+
}
|
513 |
+
});
|
514 |
+
return resolved_data;
|
515 |
+
};
|
516 |
+
async function view_api() {
|
517 |
+
if (this.api_info)
|
518 |
+
return this.api_info;
|
519 |
+
const { hf_token } = this.options;
|
520 |
+
const { config } = this;
|
521 |
+
const headers = { "Content-Type": "application/json" };
|
522 |
+
if (hf_token) {
|
523 |
+
headers.Authorization = `Bearer ${hf_token}`;
|
524 |
+
}
|
525 |
+
if (!config) {
|
526 |
+
return;
|
527 |
+
}
|
528 |
+
try {
|
529 |
+
let response;
|
530 |
+
let api_info;
|
531 |
+
if (typeof window !== "undefined" && window.gradio_api_info) {
|
532 |
+
api_info = window.gradio_api_info;
|
533 |
+
} else {
|
534 |
+
if (semiver((config == null ? void 0 : config.version) || "2.0.0", "3.30") < 0) {
|
535 |
+
response = await this.fetch(SPACE_FETCHER_URL, {
|
536 |
+
method: "POST",
|
537 |
+
body: JSON.stringify({
|
538 |
+
serialize: false,
|
539 |
+
config: JSON.stringify(config)
|
540 |
+
}),
|
541 |
+
headers,
|
542 |
+
credentials: "include"
|
543 |
+
});
|
544 |
+
} else {
|
545 |
+
const url = join_urls(config.root, this.api_prefix, API_INFO_URL);
|
546 |
+
response = await this.fetch(url, {
|
547 |
+
headers,
|
548 |
+
credentials: "include"
|
549 |
+
});
|
550 |
+
}
|
551 |
+
if (!response.ok) {
|
552 |
+
throw new Error(BROKEN_CONNECTION_MSG);
|
553 |
+
}
|
554 |
+
api_info = await response.json();
|
555 |
+
}
|
556 |
+
if ("api" in api_info) {
|
557 |
+
api_info = api_info.api;
|
558 |
+
}
|
559 |
+
if (api_info.named_endpoints["/predict"] && !api_info.unnamed_endpoints["0"]) {
|
560 |
+
api_info.unnamed_endpoints[0] = api_info.named_endpoints["/predict"];
|
561 |
+
}
|
562 |
+
return transform_api_info(api_info, config, this.api_map);
|
563 |
+
} catch (e) {
|
564 |
+
throw new Error("Could not get API info. " + e.message);
|
565 |
+
}
|
566 |
+
}
|
567 |
+
async function upload_files(root_url, files, upload_id) {
|
568 |
+
var _a;
|
569 |
+
const headers = {};
|
570 |
+
if ((_a = this == null ? void 0 : this.options) == null ? void 0 : _a.hf_token) {
|
571 |
+
headers.Authorization = `Bearer ${this.options.hf_token}`;
|
572 |
+
}
|
573 |
+
const chunkSize = 1e3;
|
574 |
+
const uploadResponses = [];
|
575 |
+
let response;
|
576 |
+
for (let i = 0; i < files.length; i += chunkSize) {
|
577 |
+
const chunk = files.slice(i, i + chunkSize);
|
578 |
+
const formData = new FormData();
|
579 |
+
chunk.forEach((file) => {
|
580 |
+
formData.append("files", file);
|
581 |
+
});
|
582 |
+
try {
|
583 |
+
const upload_url = upload_id ? `${root_url}${this.api_prefix}/${UPLOAD_URL}?upload_id=${upload_id}` : `${root_url}${this.api_prefix}/${UPLOAD_URL}`;
|
584 |
+
response = await this.fetch(upload_url, {
|
585 |
+
method: "POST",
|
586 |
+
body: formData,
|
587 |
+
headers,
|
588 |
+
credentials: "include"
|
589 |
+
});
|
590 |
+
} catch (e) {
|
591 |
+
throw new Error(BROKEN_CONNECTION_MSG + e.message);
|
592 |
+
}
|
593 |
+
if (!response.ok) {
|
594 |
+
const error_text = await response.text();
|
595 |
+
return { error: `HTTP ${response.status}: ${error_text}` };
|
596 |
+
}
|
597 |
+
const output = await response.json();
|
598 |
+
if (output) {
|
599 |
+
uploadResponses.push(...output);
|
600 |
+
}
|
601 |
+
}
|
602 |
+
return { files: uploadResponses };
|
603 |
+
}
|
604 |
+
async function upload(file_data, root_url, upload_id, max_file_size) {
|
605 |
+
let files = (Array.isArray(file_data) ? file_data : [file_data]).map(
|
606 |
+
(file_data2) => file_data2.blob
|
607 |
+
);
|
608 |
+
const oversized_files = files.filter(
|
609 |
+
(f) => f.size > (max_file_size ?? Infinity)
|
610 |
+
);
|
611 |
+
if (oversized_files.length) {
|
612 |
+
throw new Error(
|
613 |
+
`File size exceeds the maximum allowed size of ${max_file_size} bytes: ${oversized_files.map((f) => f.name).join(", ")}`
|
614 |
+
);
|
615 |
+
}
|
616 |
+
return await Promise.all(
|
617 |
+
await this.upload_files(root_url, files, upload_id).then(
|
618 |
+
async (response) => {
|
619 |
+
if (response.error) {
|
620 |
+
throw new Error(response.error);
|
621 |
+
} else {
|
622 |
+
if (response.files) {
|
623 |
+
return response.files.map((f, i) => {
|
624 |
+
const file = new FileData({
|
625 |
+
...file_data[i],
|
626 |
+
path: f,
|
627 |
+
url: `${root_url}${this.api_prefix}/file=${f}`
|
628 |
+
});
|
629 |
+
return file;
|
630 |
+
});
|
631 |
+
}
|
632 |
+
return [];
|
633 |
+
}
|
634 |
+
}
|
635 |
+
)
|
636 |
+
);
|
637 |
+
}
|
638 |
+
async function prepare_files(files, is_stream) {
|
639 |
+
return files.map(
|
640 |
+
(f) => new FileData({
|
641 |
+
path: f.name,
|
642 |
+
orig_name: f.name,
|
643 |
+
blob: f,
|
644 |
+
size: f.size,
|
645 |
+
mime_type: f.type,
|
646 |
+
is_stream
|
647 |
+
})
|
648 |
+
);
|
649 |
+
}
|
650 |
+
class FileData {
|
651 |
+
constructor({
|
652 |
+
path,
|
653 |
+
url,
|
654 |
+
orig_name,
|
655 |
+
size,
|
656 |
+
blob,
|
657 |
+
is_stream,
|
658 |
+
mime_type,
|
659 |
+
alt_text,
|
660 |
+
b64
|
661 |
+
}) {
|
662 |
+
__publicField(this, "path");
|
663 |
+
__publicField(this, "url");
|
664 |
+
__publicField(this, "orig_name");
|
665 |
+
__publicField(this, "size");
|
666 |
+
__publicField(this, "blob");
|
667 |
+
__publicField(this, "is_stream");
|
668 |
+
__publicField(this, "mime_type");
|
669 |
+
__publicField(this, "alt_text");
|
670 |
+
__publicField(this, "b64");
|
671 |
+
__publicField(this, "meta", { _type: "gradio.FileData" });
|
672 |
+
this.path = path;
|
673 |
+
this.url = url;
|
674 |
+
this.orig_name = orig_name;
|
675 |
+
this.size = size;
|
676 |
+
this.blob = url ? void 0 : blob;
|
677 |
+
this.is_stream = is_stream;
|
678 |
+
this.mime_type = mime_type;
|
679 |
+
this.alt_text = alt_text;
|
680 |
+
this.b64 = b64;
|
681 |
+
}
|
682 |
+
}
|
683 |
+
class Command {
|
684 |
+
constructor(command, meta) {
|
685 |
+
__publicField(this, "type");
|
686 |
+
__publicField(this, "command");
|
687 |
+
__publicField(this, "meta");
|
688 |
+
__publicField(this, "fileData");
|
689 |
+
this.type = "command";
|
690 |
+
this.command = command;
|
691 |
+
this.meta = meta;
|
692 |
+
}
|
693 |
+
}
|
694 |
+
const is_node = typeof process !== "undefined" && process.versions && process.versions.node;
|
695 |
+
function update_object(object, newValue, stack) {
|
696 |
+
while (stack.length > 1) {
|
697 |
+
const key2 = stack.shift();
|
698 |
+
if (typeof key2 === "string" || typeof key2 === "number") {
|
699 |
+
object = object[key2];
|
700 |
+
} else {
|
701 |
+
throw new Error("Invalid key type");
|
702 |
+
}
|
703 |
+
}
|
704 |
+
const key = stack.shift();
|
705 |
+
if (typeof key === "string" || typeof key === "number") {
|
706 |
+
object[key] = newValue;
|
707 |
+
} else {
|
708 |
+
throw new Error("Invalid key type");
|
709 |
+
}
|
710 |
+
}
|
711 |
+
async function walk_and_store_blobs(data, type = void 0, path = [], root = false, endpoint_info = void 0) {
|
712 |
+
if (Array.isArray(data)) {
|
713 |
+
let blob_refs = [];
|
714 |
+
await Promise.all(
|
715 |
+
data.map(async (_, index) => {
|
716 |
+
var _a;
|
717 |
+
let new_path = path.slice();
|
718 |
+
new_path.push(String(index));
|
719 |
+
const array_refs = await walk_and_store_blobs(
|
720 |
+
data[index],
|
721 |
+
root ? ((_a = endpoint_info == null ? void 0 : endpoint_info.parameters[index]) == null ? void 0 : _a.component) || void 0 : type,
|
722 |
+
new_path,
|
723 |
+
false,
|
724 |
+
endpoint_info
|
725 |
+
);
|
726 |
+
blob_refs = blob_refs.concat(array_refs);
|
727 |
+
})
|
728 |
+
);
|
729 |
+
return blob_refs;
|
730 |
+
} else if (globalThis.Buffer && data instanceof globalThis.Buffer || data instanceof Blob) {
|
731 |
+
return [
|
732 |
+
{
|
733 |
+
path,
|
734 |
+
blob: new Blob([data]),
|
735 |
+
type
|
736 |
+
}
|
737 |
+
];
|
738 |
+
} else if (typeof data === "object" && data !== null) {
|
739 |
+
let blob_refs = [];
|
740 |
+
for (const key of Object.keys(data)) {
|
741 |
+
const new_path = [...path, key];
|
742 |
+
const value = data[key];
|
743 |
+
blob_refs = blob_refs.concat(
|
744 |
+
await walk_and_store_blobs(
|
745 |
+
value,
|
746 |
+
void 0,
|
747 |
+
new_path,
|
748 |
+
false,
|
749 |
+
endpoint_info
|
750 |
+
)
|
751 |
+
);
|
752 |
+
}
|
753 |
+
return blob_refs;
|
754 |
+
}
|
755 |
+
return [];
|
756 |
+
}
|
757 |
+
function skip_queue(id, config) {
|
758 |
+
var _a, _b;
|
759 |
+
let fn_queue = (_b = (_a = config == null ? void 0 : config.dependencies) == null ? void 0 : _a.find((dep) => dep.id == id)) == null ? void 0 : _b.queue;
|
760 |
+
if (fn_queue != null) {
|
761 |
+
return !fn_queue;
|
762 |
+
}
|
763 |
+
return !config.enable_queue;
|
764 |
+
}
|
765 |
+
function post_message(message, origin) {
|
766 |
+
return new Promise((res, _rej) => {
|
767 |
+
const channel = new MessageChannel();
|
768 |
+
channel.port1.onmessage = ({ data }) => {
|
769 |
+
channel.port1.close();
|
770 |
+
res(data);
|
771 |
+
};
|
772 |
+
window.parent.postMessage(message, origin, [channel.port2]);
|
773 |
+
});
|
774 |
+
}
|
775 |
+
function handle_file(file_or_url) {
|
776 |
+
if (typeof file_or_url === "string") {
|
777 |
+
if (file_or_url.startsWith("http://") || file_or_url.startsWith("https://")) {
|
778 |
+
return {
|
779 |
+
path: file_or_url,
|
780 |
+
url: file_or_url,
|
781 |
+
orig_name: file_or_url.split("/").pop() ?? "unknown",
|
782 |
+
meta: { _type: "gradio.FileData" }
|
783 |
+
};
|
784 |
+
}
|
785 |
+
if (is_node) {
|
786 |
+
return new Command("upload_file", {
|
787 |
+
path: file_or_url,
|
788 |
+
name: file_or_url,
|
789 |
+
orig_path: file_or_url
|
790 |
+
});
|
791 |
+
}
|
792 |
+
} else if (typeof File !== "undefined" && file_or_url instanceof File) {
|
793 |
+
return new Blob([file_or_url]);
|
794 |
+
} else if (file_or_url instanceof Buffer) {
|
795 |
+
return new Blob([file_or_url]);
|
796 |
+
} else if (file_or_url instanceof Blob) {
|
797 |
+
return file_or_url;
|
798 |
+
}
|
799 |
+
throw new Error(
|
800 |
+
"Invalid input: must be a URL, File, Blob, or Buffer object."
|
801 |
+
);
|
802 |
+
}
|
803 |
+
function handle_payload(resolved_payload, dependency, components, type, with_null_state = false) {
|
804 |
+
if (type === "input" && !with_null_state) {
|
805 |
+
throw new Error("Invalid code path. Cannot skip state inputs for input.");
|
806 |
+
}
|
807 |
+
if (type === "output" && with_null_state) {
|
808 |
+
return resolved_payload;
|
809 |
+
}
|
810 |
+
let updated_payload = [];
|
811 |
+
let payload_index = 0;
|
812 |
+
const deps = type === "input" ? dependency.inputs : dependency.outputs;
|
813 |
+
for (let i = 0; i < deps.length; i++) {
|
814 |
+
const input_id = deps[i];
|
815 |
+
const component = components.find((c) => c.id === input_id);
|
816 |
+
if ((component == null ? void 0 : component.type) === "state") {
|
817 |
+
if (with_null_state) {
|
818 |
+
if (resolved_payload.length === deps.length) {
|
819 |
+
const value = resolved_payload[payload_index];
|
820 |
+
updated_payload.push(value);
|
821 |
+
payload_index++;
|
822 |
+
} else {
|
823 |
+
updated_payload.push(null);
|
824 |
+
}
|
825 |
+
} else {
|
826 |
+
payload_index++;
|
827 |
+
continue;
|
828 |
+
}
|
829 |
+
continue;
|
830 |
+
} else {
|
831 |
+
const value = resolved_payload[payload_index];
|
832 |
+
updated_payload.push(value);
|
833 |
+
payload_index++;
|
834 |
+
}
|
835 |
+
}
|
836 |
+
return updated_payload;
|
837 |
+
}
|
838 |
+
async function handle_blob(endpoint, data, api_info) {
|
839 |
+
const self = this;
|
840 |
+
await process_local_file_commands(self, data);
|
841 |
+
const blobRefs = await walk_and_store_blobs(
|
842 |
+
data,
|
843 |
+
void 0,
|
844 |
+
[],
|
845 |
+
true,
|
846 |
+
api_info
|
847 |
+
);
|
848 |
+
const results = await Promise.all(
|
849 |
+
blobRefs.map(async ({ path, blob, type }) => {
|
850 |
+
if (!blob)
|
851 |
+
return { path, type };
|
852 |
+
const response = await self.upload_files(endpoint, [blob]);
|
853 |
+
const file_url = response.files && response.files[0];
|
854 |
+
return {
|
855 |
+
path,
|
856 |
+
file_url,
|
857 |
+
type,
|
858 |
+
name: typeof File !== "undefined" && blob instanceof File ? blob == null ? void 0 : blob.name : void 0
|
859 |
+
};
|
860 |
+
})
|
861 |
+
);
|
862 |
+
results.forEach(({ path, file_url, type, name }) => {
|
863 |
+
if (type === "Gallery") {
|
864 |
+
update_object(data, file_url, path);
|
865 |
+
} else if (file_url) {
|
866 |
+
const file = new FileData({ path: file_url, orig_name: name });
|
867 |
+
update_object(data, file, path);
|
868 |
+
}
|
869 |
+
});
|
870 |
+
return data;
|
871 |
+
}
|
872 |
+
async function process_local_file_commands(client2, data) {
|
873 |
+
var _a, _b;
|
874 |
+
const root = ((_a = client2.config) == null ? void 0 : _a.root) || ((_b = client2.config) == null ? void 0 : _b.root_url);
|
875 |
+
if (!root) {
|
876 |
+
throw new Error(ROOT_URL_ERROR_MSG);
|
877 |
+
}
|
878 |
+
await recursively_process_commands(client2, data);
|
879 |
+
}
|
880 |
+
async function recursively_process_commands(client2, data, path = []) {
|
881 |
+
for (const key in data) {
|
882 |
+
if (data[key] instanceof Command) {
|
883 |
+
await process_single_command(client2, data, key);
|
884 |
+
} else if (typeof data[key] === "object" && data[key] !== null) {
|
885 |
+
await recursively_process_commands(client2, data[key], [...path, key]);
|
886 |
+
}
|
887 |
+
}
|
888 |
+
}
|
889 |
+
async function process_single_command(client2, data, key) {
|
890 |
+
var _a, _b;
|
891 |
+
let cmd_item = data[key];
|
892 |
+
const root = ((_a = client2.config) == null ? void 0 : _a.root) || ((_b = client2.config) == null ? void 0 : _b.root_url);
|
893 |
+
if (!root) {
|
894 |
+
throw new Error(ROOT_URL_ERROR_MSG);
|
895 |
+
}
|
896 |
+
try {
|
897 |
+
let fileBuffer;
|
898 |
+
let fullPath;
|
899 |
+
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
900 |
+
const fs = await import("fs/promises");
|
901 |
+
const path = await import("path");
|
902 |
+
fullPath = path.resolve(process.cwd(), cmd_item.meta.path);
|
903 |
+
fileBuffer = await fs.readFile(fullPath);
|
904 |
+
} else {
|
905 |
+
throw new Error(NODEJS_FS_ERROR_MSG);
|
906 |
+
}
|
907 |
+
const file = new Blob([fileBuffer], { type: "application/octet-stream" });
|
908 |
+
const response = await client2.upload_files(root, [file]);
|
909 |
+
const file_url = response.files && response.files[0];
|
910 |
+
if (file_url) {
|
911 |
+
const fileData = new FileData({
|
912 |
+
path: file_url,
|
913 |
+
orig_name: cmd_item.meta.name || ""
|
914 |
+
});
|
915 |
+
data[key] = fileData;
|
916 |
+
}
|
917 |
+
} catch (error) {
|
918 |
+
console.error(FILE_PROCESSING_ERROR_MSG, error);
|
919 |
+
}
|
920 |
+
}
|
921 |
+
async function post_data(url, body, additional_headers) {
|
922 |
+
const headers = { "Content-Type": "application/json" };
|
923 |
+
if (this.options.hf_token) {
|
924 |
+
headers.Authorization = `Bearer ${this.options.hf_token}`;
|
925 |
+
}
|
926 |
+
try {
|
927 |
+
var response = await this.fetch(url, {
|
928 |
+
method: "POST",
|
929 |
+
body: JSON.stringify(body),
|
930 |
+
headers: { ...headers, ...additional_headers },
|
931 |
+
credentials: "include"
|
932 |
+
});
|
933 |
+
} catch (e) {
|
934 |
+
return [{ error: BROKEN_CONNECTION_MSG }, 500];
|
935 |
+
}
|
936 |
+
let output;
|
937 |
+
let status;
|
938 |
+
try {
|
939 |
+
output = await response.json();
|
940 |
+
status = response.status;
|
941 |
+
} catch (e) {
|
942 |
+
output = { error: `Could not parse server response: ${e}` };
|
943 |
+
status = 500;
|
944 |
+
}
|
945 |
+
return [output, status];
|
946 |
+
}
|
947 |
+
async function predict(endpoint, data = {}) {
|
948 |
+
let data_returned = false;
|
949 |
+
let status_complete = false;
|
950 |
+
if (!this.config) {
|
951 |
+
throw new Error("Could not resolve app config");
|
952 |
+
}
|
953 |
+
if (typeof endpoint === "number") {
|
954 |
+
this.config.dependencies.find((dep) => dep.id == endpoint);
|
955 |
+
} else {
|
956 |
+
const trimmed_endpoint = endpoint.replace(/^\//, "");
|
957 |
+
this.config.dependencies.find(
|
958 |
+
(dep) => dep.id == this.api_map[trimmed_endpoint]
|
959 |
+
);
|
960 |
+
}
|
961 |
+
return new Promise(async (resolve, reject) => {
|
962 |
+
const app = this.submit(endpoint, data, null, null, true);
|
963 |
+
let result;
|
964 |
+
for await (const message of app) {
|
965 |
+
if (message.type === "data") {
|
966 |
+
if (status_complete) {
|
967 |
+
resolve(result);
|
968 |
+
}
|
969 |
+
data_returned = true;
|
970 |
+
result = message;
|
971 |
+
}
|
972 |
+
if (message.type === "status") {
|
973 |
+
if (message.stage === "error")
|
974 |
+
reject(message);
|
975 |
+
if (message.stage === "complete") {
|
976 |
+
status_complete = true;
|
977 |
+
if (data_returned) {
|
978 |
+
resolve(result);
|
979 |
+
}
|
980 |
+
}
|
981 |
+
}
|
982 |
+
}
|
983 |
+
});
|
984 |
+
}
|
985 |
+
async function check_space_status(id, type, status_callback) {
|
986 |
+
let endpoint = type === "subdomain" ? `https://huggingface.co/api/spaces/by-subdomain/${id}` : `https://huggingface.co/api/spaces/${id}`;
|
987 |
+
let response;
|
988 |
+
let _status;
|
989 |
+
try {
|
990 |
+
response = await fetch(endpoint);
|
991 |
+
_status = response.status;
|
992 |
+
if (_status !== 200) {
|
993 |
+
throw new Error();
|
994 |
+
}
|
995 |
+
response = await response.json();
|
996 |
+
} catch (e) {
|
997 |
+
status_callback({
|
998 |
+
status: "error",
|
999 |
+
load_status: "error",
|
1000 |
+
message: SPACE_STATUS_ERROR_MSG,
|
1001 |
+
detail: "NOT_FOUND"
|
1002 |
+
});
|
1003 |
+
return;
|
1004 |
+
}
|
1005 |
+
if (!response || _status !== 200)
|
1006 |
+
return;
|
1007 |
+
const {
|
1008 |
+
runtime: { stage },
|
1009 |
+
id: space_name
|
1010 |
+
} = response;
|
1011 |
+
switch (stage) {
|
1012 |
+
case "STOPPED":
|
1013 |
+
case "SLEEPING":
|
1014 |
+
status_callback({
|
1015 |
+
status: "sleeping",
|
1016 |
+
load_status: "pending",
|
1017 |
+
message: "Space is asleep. Waking it up...",
|
1018 |
+
detail: stage
|
1019 |
+
});
|
1020 |
+
setTimeout(() => {
|
1021 |
+
check_space_status(id, type, status_callback);
|
1022 |
+
}, 1e3);
|
1023 |
+
break;
|
1024 |
+
case "PAUSED":
|
1025 |
+
status_callback({
|
1026 |
+
status: "paused",
|
1027 |
+
load_status: "error",
|
1028 |
+
message: "This space has been paused by the author. If you would like to try this demo, consider duplicating the space.",
|
1029 |
+
detail: stage,
|
1030 |
+
discussions_enabled: await discussions_enabled(space_name)
|
1031 |
+
});
|
1032 |
+
break;
|
1033 |
+
case "RUNNING":
|
1034 |
+
case "RUNNING_BUILDING":
|
1035 |
+
status_callback({
|
1036 |
+
status: "running",
|
1037 |
+
load_status: "complete",
|
1038 |
+
message: "Space is running.",
|
1039 |
+
detail: stage
|
1040 |
+
});
|
1041 |
+
break;
|
1042 |
+
case "BUILDING":
|
1043 |
+
status_callback({
|
1044 |
+
status: "building",
|
1045 |
+
load_status: "pending",
|
1046 |
+
message: "Space is building...",
|
1047 |
+
detail: stage
|
1048 |
+
});
|
1049 |
+
setTimeout(() => {
|
1050 |
+
check_space_status(id, type, status_callback);
|
1051 |
+
}, 1e3);
|
1052 |
+
break;
|
1053 |
+
case "APP_STARTING":
|
1054 |
+
status_callback({
|
1055 |
+
status: "starting",
|
1056 |
+
load_status: "pending",
|
1057 |
+
message: "Space is starting...",
|
1058 |
+
detail: stage
|
1059 |
+
});
|
1060 |
+
setTimeout(() => {
|
1061 |
+
check_space_status(id, type, status_callback);
|
1062 |
+
}, 1e3);
|
1063 |
+
break;
|
1064 |
+
default:
|
1065 |
+
status_callback({
|
1066 |
+
status: "space_error",
|
1067 |
+
load_status: "error",
|
1068 |
+
message: "This space is experiencing an issue.",
|
1069 |
+
detail: stage,
|
1070 |
+
discussions_enabled: await discussions_enabled(space_name)
|
1071 |
+
});
|
1072 |
+
break;
|
1073 |
+
}
|
1074 |
+
}
|
1075 |
+
const check_and_wake_space = async (space_id, status_callback) => {
|
1076 |
+
let retries = 0;
|
1077 |
+
const max_retries = 12;
|
1078 |
+
const check_interval = 5e3;
|
1079 |
+
return new Promise((resolve) => {
|
1080 |
+
check_space_status(
|
1081 |
+
space_id,
|
1082 |
+
RE_SPACE_NAME.test(space_id) ? "space_name" : "subdomain",
|
1083 |
+
(status) => {
|
1084 |
+
status_callback(status);
|
1085 |
+
if (status.status === "running") {
|
1086 |
+
resolve();
|
1087 |
+
} else if (status.status === "error" || status.status === "paused" || status.status === "space_error") {
|
1088 |
+
resolve();
|
1089 |
+
} else if (status.status === "sleeping" || status.status === "building") {
|
1090 |
+
if (retries < max_retries) {
|
1091 |
+
retries++;
|
1092 |
+
setTimeout(() => {
|
1093 |
+
check_and_wake_space(space_id, status_callback).then(resolve);
|
1094 |
+
}, check_interval);
|
1095 |
+
} else {
|
1096 |
+
resolve();
|
1097 |
+
}
|
1098 |
+
}
|
1099 |
+
}
|
1100 |
+
);
|
1101 |
+
});
|
1102 |
+
};
|
1103 |
+
const RE_DISABLED_DISCUSSION = /^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;
|
1104 |
+
async function discussions_enabled(space_id) {
|
1105 |
+
try {
|
1106 |
+
const r = await fetch(
|
1107 |
+
`https://huggingface.co/api/spaces/${space_id}/discussions`,
|
1108 |
+
{
|
1109 |
+
method: "HEAD"
|
1110 |
+
}
|
1111 |
+
);
|
1112 |
+
const error = r.headers.get("x-error-message");
|
1113 |
+
if (!r.ok || error && RE_DISABLED_DISCUSSION.test(error))
|
1114 |
+
return false;
|
1115 |
+
return true;
|
1116 |
+
} catch (e) {
|
1117 |
+
return false;
|
1118 |
+
}
|
1119 |
+
}
|
1120 |
+
async function get_space_hardware(space_id, hf_token) {
|
1121 |
+
const headers = {};
|
1122 |
+
if (hf_token) {
|
1123 |
+
headers.Authorization = `Bearer ${hf_token}`;
|
1124 |
+
}
|
1125 |
+
try {
|
1126 |
+
const res = await fetch(
|
1127 |
+
`https://huggingface.co/api/spaces/${space_id}/${RUNTIME_URL}`,
|
1128 |
+
{ headers }
|
1129 |
+
);
|
1130 |
+
if (res.status !== 200)
|
1131 |
+
throw new Error("Space hardware could not be obtained.");
|
1132 |
+
const { hardware } = await res.json();
|
1133 |
+
return hardware.current;
|
1134 |
+
} catch (e) {
|
1135 |
+
throw new Error(e.message);
|
1136 |
+
}
|
1137 |
+
}
|
1138 |
+
async function set_space_timeout(space_id, timeout, hf_token) {
|
1139 |
+
const headers = {};
|
1140 |
+
if (hf_token) {
|
1141 |
+
headers.Authorization = `Bearer ${hf_token}`;
|
1142 |
+
}
|
1143 |
+
const body = {
|
1144 |
+
seconds: timeout
|
1145 |
+
};
|
1146 |
+
try {
|
1147 |
+
const res = await fetch(
|
1148 |
+
`https://huggingface.co/api/spaces/${space_id}/${SLEEPTIME_URL}`,
|
1149 |
+
{
|
1150 |
+
method: "POST",
|
1151 |
+
headers: { "Content-Type": "application/json", ...headers },
|
1152 |
+
body: JSON.stringify(body)
|
1153 |
+
}
|
1154 |
+
);
|
1155 |
+
if (res.status !== 200) {
|
1156 |
+
throw new Error(
|
1157 |
+
"Could not set sleep timeout on duplicated Space. Please visit *ADD HF LINK TO SETTINGS* to set a timeout manually to reduce billing charges."
|
1158 |
+
);
|
1159 |
+
}
|
1160 |
+
const response = await res.json();
|
1161 |
+
return response;
|
1162 |
+
} catch (e) {
|
1163 |
+
throw new Error(e.message);
|
1164 |
+
}
|
1165 |
+
}
|
1166 |
+
const hardware_types = [
|
1167 |
+
"cpu-basic",
|
1168 |
+
"cpu-upgrade",
|
1169 |
+
"cpu-xl",
|
1170 |
+
"t4-small",
|
1171 |
+
"t4-medium",
|
1172 |
+
"a10g-small",
|
1173 |
+
"a10g-large",
|
1174 |
+
"a10g-largex2",
|
1175 |
+
"a10g-largex4",
|
1176 |
+
"a100-large",
|
1177 |
+
"zero-a10g",
|
1178 |
+
"h100",
|
1179 |
+
"h100x8"
|
1180 |
+
];
|
1181 |
+
async function duplicate(app_reference, options) {
|
1182 |
+
const { hf_token, private: _private, hardware, timeout, auth } = options;
|
1183 |
+
if (hardware && !hardware_types.includes(hardware)) {
|
1184 |
+
throw new Error(
|
1185 |
+
`Invalid hardware type provided. Valid types are: ${hardware_types.map((v) => `"${v}"`).join(",")}.`
|
1186 |
+
);
|
1187 |
+
}
|
1188 |
+
const { http_protocol, host } = await process_endpoint(
|
1189 |
+
app_reference,
|
1190 |
+
hf_token
|
1191 |
+
);
|
1192 |
+
let cookies = null;
|
1193 |
+
if (auth) {
|
1194 |
+
const cookie_header = await get_cookie_header(
|
1195 |
+
http_protocol,
|
1196 |
+
host,
|
1197 |
+
auth,
|
1198 |
+
fetch
|
1199 |
+
);
|
1200 |
+
if (cookie_header)
|
1201 |
+
cookies = parse_and_set_cookies(cookie_header);
|
1202 |
+
}
|
1203 |
+
const headers = {
|
1204 |
+
Authorization: `Bearer ${hf_token}`,
|
1205 |
+
"Content-Type": "application/json",
|
1206 |
+
...cookies ? { Cookie: cookies.join("; ") } : {}
|
1207 |
+
};
|
1208 |
+
const user = (await (await fetch(`https://huggingface.co/api/whoami-v2`, {
|
1209 |
+
headers
|
1210 |
+
})).json()).name;
|
1211 |
+
const space_name = app_reference.split("/")[1];
|
1212 |
+
const body = {
|
1213 |
+
repository: `${user}/${space_name}`
|
1214 |
+
};
|
1215 |
+
if (_private) {
|
1216 |
+
body.private = true;
|
1217 |
+
}
|
1218 |
+
let original_hardware;
|
1219 |
+
try {
|
1220 |
+
if (!hardware) {
|
1221 |
+
original_hardware = await get_space_hardware(app_reference, hf_token);
|
1222 |
+
}
|
1223 |
+
} catch (e) {
|
1224 |
+
throw Error(SPACE_METADATA_ERROR_MSG + e.message);
|
1225 |
+
}
|
1226 |
+
const requested_hardware = hardware || original_hardware || "cpu-basic";
|
1227 |
+
body.hardware = requested_hardware;
|
1228 |
+
try {
|
1229 |
+
const response = await fetch(
|
1230 |
+
`https://huggingface.co/api/spaces/${app_reference}/duplicate`,
|
1231 |
+
{
|
1232 |
+
method: "POST",
|
1233 |
+
headers,
|
1234 |
+
body: JSON.stringify(body)
|
1235 |
+
}
|
1236 |
+
);
|
1237 |
+
if (response.status === 409) {
|
1238 |
+
try {
|
1239 |
+
const client2 = await Client.connect(`${user}/${space_name}`, options);
|
1240 |
+
return client2;
|
1241 |
+
} catch (error) {
|
1242 |
+
console.error("Failed to connect Client instance:", error);
|
1243 |
+
throw error;
|
1244 |
+
}
|
1245 |
+
} else if (response.status !== 200) {
|
1246 |
+
throw new Error(response.statusText);
|
1247 |
+
}
|
1248 |
+
const duplicated_space = await response.json();
|
1249 |
+
await set_space_timeout(`${user}/${space_name}`, timeout || 300, hf_token);
|
1250 |
+
return await Client.connect(
|
1251 |
+
get_space_reference(duplicated_space.url),
|
1252 |
+
options
|
1253 |
+
);
|
1254 |
+
} catch (e) {
|
1255 |
+
throw new Error(e);
|
1256 |
+
}
|
1257 |
+
}
|
1258 |
+
function get_space_reference(url) {
|
1259 |
+
const regex = /https:\/\/huggingface.co\/spaces\/([^/]+\/[^/]+)/;
|
1260 |
+
const match = url.match(regex);
|
1261 |
+
if (match) {
|
1262 |
+
return match[1];
|
1263 |
+
}
|
1264 |
+
}
|
1265 |
+
class TextLineStream extends TransformStream {
|
1266 |
+
/** Constructs a new instance. */
|
1267 |
+
constructor(options = { allowCR: false }) {
|
1268 |
+
super({
|
1269 |
+
transform: (chars, controller) => {
|
1270 |
+
chars = __privateGet(this, _currentLine) + chars;
|
1271 |
+
while (true) {
|
1272 |
+
const lfIndex = chars.indexOf("\n");
|
1273 |
+
const crIndex = options.allowCR ? chars.indexOf("\r") : -1;
|
1274 |
+
if (crIndex !== -1 && crIndex !== chars.length - 1 && (lfIndex === -1 || lfIndex - 1 > crIndex)) {
|
1275 |
+
controller.enqueue(chars.slice(0, crIndex));
|
1276 |
+
chars = chars.slice(crIndex + 1);
|
1277 |
+
continue;
|
1278 |
+
}
|
1279 |
+
if (lfIndex === -1)
|
1280 |
+
break;
|
1281 |
+
const endIndex = chars[lfIndex - 1] === "\r" ? lfIndex - 1 : lfIndex;
|
1282 |
+
controller.enqueue(chars.slice(0, endIndex));
|
1283 |
+
chars = chars.slice(lfIndex + 1);
|
1284 |
+
}
|
1285 |
+
__privateSet(this, _currentLine, chars);
|
1286 |
+
},
|
1287 |
+
flush: (controller) => {
|
1288 |
+
if (__privateGet(this, _currentLine) === "")
|
1289 |
+
return;
|
1290 |
+
const currentLine = options.allowCR && __privateGet(this, _currentLine).endsWith("\r") ? __privateGet(this, _currentLine).slice(0, -1) : __privateGet(this, _currentLine);
|
1291 |
+
controller.enqueue(currentLine);
|
1292 |
+
}
|
1293 |
+
});
|
1294 |
+
__privateAdd(this, _currentLine, "");
|
1295 |
+
}
|
1296 |
+
}
|
1297 |
+
_currentLine = new WeakMap();
|
1298 |
+
function stream$1(input) {
|
1299 |
+
let decoder = new TextDecoderStream();
|
1300 |
+
let split2 = new TextLineStream({ allowCR: true });
|
1301 |
+
return input.pipeThrough(decoder).pipeThrough(split2);
|
1302 |
+
}
|
1303 |
+
function split(input) {
|
1304 |
+
let rgx = /[:]\s*/;
|
1305 |
+
let match = rgx.exec(input);
|
1306 |
+
let idx = match && match.index;
|
1307 |
+
if (idx) {
|
1308 |
+
return [
|
1309 |
+
input.substring(0, idx),
|
1310 |
+
input.substring(idx + match[0].length)
|
1311 |
+
];
|
1312 |
+
}
|
1313 |
+
}
|
1314 |
+
function fallback(headers, key, value) {
|
1315 |
+
let tmp = headers.get(key);
|
1316 |
+
if (!tmp)
|
1317 |
+
headers.set(key, value);
|
1318 |
+
}
|
1319 |
+
async function* events(res, signal) {
|
1320 |
+
if (!res.body)
|
1321 |
+
return;
|
1322 |
+
let iter = stream$1(res.body);
|
1323 |
+
let line, reader = iter.getReader();
|
1324 |
+
let event;
|
1325 |
+
for (; ; ) {
|
1326 |
+
if (signal && signal.aborted) {
|
1327 |
+
return reader.cancel();
|
1328 |
+
}
|
1329 |
+
line = await reader.read();
|
1330 |
+
if (line.done)
|
1331 |
+
return;
|
1332 |
+
if (!line.value) {
|
1333 |
+
if (event)
|
1334 |
+
yield event;
|
1335 |
+
event = void 0;
|
1336 |
+
continue;
|
1337 |
+
}
|
1338 |
+
let [field, value] = split(line.value) || [];
|
1339 |
+
if (!field)
|
1340 |
+
continue;
|
1341 |
+
if (field === "data") {
|
1342 |
+
event || (event = {});
|
1343 |
+
event[field] = event[field] ? event[field] + "\n" + value : value;
|
1344 |
+
} else if (field === "event") {
|
1345 |
+
event || (event = {});
|
1346 |
+
event[field] = value;
|
1347 |
+
} else if (field === "id") {
|
1348 |
+
event || (event = {});
|
1349 |
+
event[field] = +value || value;
|
1350 |
+
} else if (field === "retry") {
|
1351 |
+
event || (event = {});
|
1352 |
+
event[field] = +value || void 0;
|
1353 |
+
}
|
1354 |
+
}
|
1355 |
+
}
|
1356 |
+
async function stream(input, init) {
|
1357 |
+
let req = new Request(input, init);
|
1358 |
+
fallback(req.headers, "Accept", "text/event-stream");
|
1359 |
+
fallback(req.headers, "Content-Type", "application/json");
|
1360 |
+
let r = await fetch(req);
|
1361 |
+
if (!r.ok)
|
1362 |
+
throw r;
|
1363 |
+
return events(r, req.signal);
|
1364 |
+
}
|
1365 |
+
async function open_stream() {
|
1366 |
+
let {
|
1367 |
+
event_callbacks,
|
1368 |
+
unclosed_events,
|
1369 |
+
pending_stream_messages,
|
1370 |
+
stream_status,
|
1371 |
+
config,
|
1372 |
+
jwt
|
1373 |
+
} = this;
|
1374 |
+
const that = this;
|
1375 |
+
if (!config) {
|
1376 |
+
throw new Error("Could not resolve app config");
|
1377 |
+
}
|
1378 |
+
stream_status.open = true;
|
1379 |
+
let stream2 = null;
|
1380 |
+
let params = new URLSearchParams({
|
1381 |
+
session_hash: this.session_hash
|
1382 |
+
}).toString();
|
1383 |
+
let url = new URL(`${config.root}${this.api_prefix}/${SSE_URL}?${params}`);
|
1384 |
+
if (jwt) {
|
1385 |
+
url.searchParams.set("__sign", jwt);
|
1386 |
+
}
|
1387 |
+
stream2 = this.stream(url);
|
1388 |
+
if (!stream2) {
|
1389 |
+
console.warn("Cannot connect to SSE endpoint: " + url.toString());
|
1390 |
+
return;
|
1391 |
+
}
|
1392 |
+
stream2.onmessage = async function(event) {
|
1393 |
+
let _data = JSON.parse(event.data);
|
1394 |
+
if (_data.msg === "close_stream") {
|
1395 |
+
close_stream(stream_status, that.abort_controller);
|
1396 |
+
return;
|
1397 |
+
}
|
1398 |
+
const event_id = _data.event_id;
|
1399 |
+
if (!event_id) {
|
1400 |
+
await Promise.all(
|
1401 |
+
Object.keys(event_callbacks).map(
|
1402 |
+
(event_id2) => event_callbacks[event_id2](_data)
|
1403 |
+
)
|
1404 |
+
);
|
1405 |
+
} else if (event_callbacks[event_id] && config) {
|
1406 |
+
if (_data.msg === "process_completed" && ["sse", "sse_v1", "sse_v2", "sse_v2.1", "sse_v3"].includes(
|
1407 |
+
config.protocol
|
1408 |
+
)) {
|
1409 |
+
unclosed_events.delete(event_id);
|
1410 |
+
}
|
1411 |
+
let fn2 = event_callbacks[event_id];
|
1412 |
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
1413 |
+
setTimeout(fn2, 0, _data);
|
1414 |
+
} else {
|
1415 |
+
fn2(_data);
|
1416 |
+
}
|
1417 |
+
} else {
|
1418 |
+
if (!pending_stream_messages[event_id]) {
|
1419 |
+
pending_stream_messages[event_id] = [];
|
1420 |
+
}
|
1421 |
+
pending_stream_messages[event_id].push(_data);
|
1422 |
+
}
|
1423 |
+
};
|
1424 |
+
stream2.onerror = async function() {
|
1425 |
+
await Promise.all(
|
1426 |
+
Object.keys(event_callbacks).map(
|
1427 |
+
(event_id) => event_callbacks[event_id]({
|
1428 |
+
msg: "unexpected_error",
|
1429 |
+
message: BROKEN_CONNECTION_MSG
|
1430 |
+
})
|
1431 |
+
)
|
1432 |
+
);
|
1433 |
+
};
|
1434 |
+
}
|
1435 |
+
function close_stream(stream_status, abort_controller) {
|
1436 |
+
if (stream_status) {
|
1437 |
+
stream_status.open = false;
|
1438 |
+
abort_controller == null ? void 0 : abort_controller.abort();
|
1439 |
+
}
|
1440 |
+
}
|
1441 |
+
function apply_diff_stream(pending_diff_streams, event_id, data) {
|
1442 |
+
let is_first_generation = !pending_diff_streams[event_id];
|
1443 |
+
if (is_first_generation) {
|
1444 |
+
pending_diff_streams[event_id] = [];
|
1445 |
+
data.data.forEach((value, i) => {
|
1446 |
+
pending_diff_streams[event_id][i] = value;
|
1447 |
+
});
|
1448 |
+
} else {
|
1449 |
+
data.data.forEach((value, i) => {
|
1450 |
+
let new_data = apply_diff(pending_diff_streams[event_id][i], value);
|
1451 |
+
pending_diff_streams[event_id][i] = new_data;
|
1452 |
+
data.data[i] = new_data;
|
1453 |
+
});
|
1454 |
+
}
|
1455 |
+
}
|
1456 |
+
function apply_diff(obj, diff) {
|
1457 |
+
diff.forEach(([action, path, value]) => {
|
1458 |
+
obj = apply_edit(obj, path, action, value);
|
1459 |
+
});
|
1460 |
+
return obj;
|
1461 |
+
}
|
1462 |
+
function apply_edit(target, path, action, value) {
|
1463 |
+
if (path.length === 0) {
|
1464 |
+
if (action === "replace") {
|
1465 |
+
return value;
|
1466 |
+
} else if (action === "append") {
|
1467 |
+
return target + value;
|
1468 |
+
}
|
1469 |
+
throw new Error(`Unsupported action: ${action}`);
|
1470 |
+
}
|
1471 |
+
let current = target;
|
1472 |
+
for (let i = 0; i < path.length - 1; i++) {
|
1473 |
+
current = current[path[i]];
|
1474 |
+
}
|
1475 |
+
const last_path = path[path.length - 1];
|
1476 |
+
switch (action) {
|
1477 |
+
case "replace":
|
1478 |
+
current[last_path] = value;
|
1479 |
+
break;
|
1480 |
+
case "append":
|
1481 |
+
current[last_path] += value;
|
1482 |
+
break;
|
1483 |
+
case "add":
|
1484 |
+
if (Array.isArray(current)) {
|
1485 |
+
current.splice(Number(last_path), 0, value);
|
1486 |
+
} else {
|
1487 |
+
current[last_path] = value;
|
1488 |
+
}
|
1489 |
+
break;
|
1490 |
+
case "delete":
|
1491 |
+
if (Array.isArray(current)) {
|
1492 |
+
current.splice(Number(last_path), 1);
|
1493 |
+
} else {
|
1494 |
+
delete current[last_path];
|
1495 |
+
}
|
1496 |
+
break;
|
1497 |
+
default:
|
1498 |
+
throw new Error(`Unknown action: ${action}`);
|
1499 |
+
}
|
1500 |
+
return target;
|
1501 |
+
}
|
1502 |
+
function readable_stream(input, init = {}) {
|
1503 |
+
const instance = {
|
1504 |
+
close: () => {
|
1505 |
+
console.warn("Method not implemented.");
|
1506 |
+
},
|
1507 |
+
onerror: null,
|
1508 |
+
onmessage: null,
|
1509 |
+
onopen: null,
|
1510 |
+
readyState: 0,
|
1511 |
+
url: input.toString(),
|
1512 |
+
withCredentials: false,
|
1513 |
+
CONNECTING: 0,
|
1514 |
+
OPEN: 1,
|
1515 |
+
CLOSED: 2,
|
1516 |
+
addEventListener: () => {
|
1517 |
+
throw new Error("Method not implemented.");
|
1518 |
+
},
|
1519 |
+
dispatchEvent: () => {
|
1520 |
+
throw new Error("Method not implemented.");
|
1521 |
+
},
|
1522 |
+
removeEventListener: () => {
|
1523 |
+
throw new Error("Method not implemented.");
|
1524 |
+
}
|
1525 |
+
};
|
1526 |
+
stream(input, init).then(async (res) => {
|
1527 |
+
instance.readyState = instance.OPEN;
|
1528 |
+
try {
|
1529 |
+
for await (const chunk of res) {
|
1530 |
+
instance.onmessage && instance.onmessage(chunk);
|
1531 |
+
}
|
1532 |
+
instance.readyState = instance.CLOSED;
|
1533 |
+
} catch (e) {
|
1534 |
+
instance.onerror && instance.onerror(e);
|
1535 |
+
instance.readyState = instance.CLOSED;
|
1536 |
+
}
|
1537 |
+
}).catch((e) => {
|
1538 |
+
console.error(e);
|
1539 |
+
instance.onerror && instance.onerror(e);
|
1540 |
+
instance.readyState = instance.CLOSED;
|
1541 |
+
});
|
1542 |
+
return instance;
|
1543 |
+
}
|
1544 |
+
function submit(endpoint, data = {}, event_data, trigger_id, all_events) {
|
1545 |
+
var _a;
|
1546 |
+
try {
|
1547 |
+
let fire_event = function(event) {
|
1548 |
+
if (all_events || events_to_publish[event.type]) {
|
1549 |
+
push_event(event);
|
1550 |
+
}
|
1551 |
+
}, close = function() {
|
1552 |
+
done = true;
|
1553 |
+
while (resolvers.length > 0)
|
1554 |
+
resolvers.shift()({
|
1555 |
+
value: void 0,
|
1556 |
+
done: true
|
1557 |
+
});
|
1558 |
+
}, push = function(data2) {
|
1559 |
+
if (done)
|
1560 |
+
return;
|
1561 |
+
if (resolvers.length > 0) {
|
1562 |
+
resolvers.shift()(data2);
|
1563 |
+
} else {
|
1564 |
+
values.push(data2);
|
1565 |
+
}
|
1566 |
+
}, push_error = function(error) {
|
1567 |
+
push(thenable_reject(error));
|
1568 |
+
close();
|
1569 |
+
}, push_event = function(event) {
|
1570 |
+
push({ value: event, done: false });
|
1571 |
+
}, next = function() {
|
1572 |
+
if (values.length > 0)
|
1573 |
+
return Promise.resolve(values.shift());
|
1574 |
+
if (done)
|
1575 |
+
return Promise.resolve({ value: void 0, done: true });
|
1576 |
+
return new Promise((resolve) => resolvers.push(resolve));
|
1577 |
+
};
|
1578 |
+
const { hf_token } = this.options;
|
1579 |
+
const {
|
1580 |
+
fetch: fetch2,
|
1581 |
+
app_reference,
|
1582 |
+
config,
|
1583 |
+
session_hash,
|
1584 |
+
api_info,
|
1585 |
+
api_map,
|
1586 |
+
stream_status,
|
1587 |
+
pending_stream_messages,
|
1588 |
+
pending_diff_streams,
|
1589 |
+
event_callbacks,
|
1590 |
+
unclosed_events,
|
1591 |
+
post_data: post_data2,
|
1592 |
+
options,
|
1593 |
+
api_prefix
|
1594 |
+
} = this;
|
1595 |
+
const that = this;
|
1596 |
+
if (!api_info)
|
1597 |
+
throw new Error("No API found");
|
1598 |
+
if (!config)
|
1599 |
+
throw new Error("Could not resolve app config");
|
1600 |
+
let { fn_index, endpoint_info, dependency } = get_endpoint_info(
|
1601 |
+
api_info,
|
1602 |
+
endpoint,
|
1603 |
+
api_map,
|
1604 |
+
config
|
1605 |
+
);
|
1606 |
+
let resolved_data = map_data_to_params(data, endpoint_info);
|
1607 |
+
let websocket;
|
1608 |
+
let stream2;
|
1609 |
+
let protocol = config.protocol ?? "ws";
|
1610 |
+
let event_id_final = "";
|
1611 |
+
let event_id_cb = () => event_id_final;
|
1612 |
+
const _endpoint = typeof endpoint === "number" ? "/predict" : endpoint;
|
1613 |
+
let payload;
|
1614 |
+
let event_id = null;
|
1615 |
+
let complete = false;
|
1616 |
+
let last_status = {};
|
1617 |
+
let url_params = typeof window !== "undefined" && typeof document !== "undefined" ? new URLSearchParams(window.location.search).toString() : "";
|
1618 |
+
const events_to_publish = ((_a = options == null ? void 0 : options.events) == null ? void 0 : _a.reduce(
|
1619 |
+
(acc, event) => {
|
1620 |
+
acc[event] = true;
|
1621 |
+
return acc;
|
1622 |
+
},
|
1623 |
+
{}
|
1624 |
+
)) || {};
|
1625 |
+
async function cancel() {
|
1626 |
+
const _status = {
|
1627 |
+
stage: "complete",
|
1628 |
+
queue: false,
|
1629 |
+
time: /* @__PURE__ */ new Date()
|
1630 |
+
};
|
1631 |
+
complete = _status;
|
1632 |
+
fire_event({
|
1633 |
+
..._status,
|
1634 |
+
type: "status",
|
1635 |
+
endpoint: _endpoint,
|
1636 |
+
fn_index
|
1637 |
+
});
|
1638 |
+
let reset_request = {};
|
1639 |
+
let cancel_request = {};
|
1640 |
+
if (protocol === "ws") {
|
1641 |
+
if (websocket && websocket.readyState === 0) {
|
1642 |
+
websocket.addEventListener("open", () => {
|
1643 |
+
websocket.close();
|
1644 |
+
});
|
1645 |
+
} else {
|
1646 |
+
websocket.close();
|
1647 |
+
}
|
1648 |
+
reset_request = { fn_index, session_hash };
|
1649 |
+
} else {
|
1650 |
+
close_stream(stream_status, that.abort_controller);
|
1651 |
+
close();
|
1652 |
+
reset_request = { event_id };
|
1653 |
+
cancel_request = { event_id, session_hash, fn_index };
|
1654 |
+
}
|
1655 |
+
try {
|
1656 |
+
if (!config) {
|
1657 |
+
throw new Error("Could not resolve app config");
|
1658 |
+
}
|
1659 |
+
if ("event_id" in cancel_request) {
|
1660 |
+
await fetch2(`${config.root}${api_prefix}/${CANCEL_URL}`, {
|
1661 |
+
headers: { "Content-Type": "application/json" },
|
1662 |
+
method: "POST",
|
1663 |
+
body: JSON.stringify(cancel_request)
|
1664 |
+
});
|
1665 |
+
}
|
1666 |
+
await fetch2(`${config.root}${api_prefix}/${RESET_URL}`, {
|
1667 |
+
headers: { "Content-Type": "application/json" },
|
1668 |
+
method: "POST",
|
1669 |
+
body: JSON.stringify(reset_request)
|
1670 |
+
});
|
1671 |
+
} catch (e) {
|
1672 |
+
console.warn(
|
1673 |
+
"The `/reset` endpoint could not be called. Subsequent endpoint results may be unreliable."
|
1674 |
+
);
|
1675 |
+
}
|
1676 |
+
}
|
1677 |
+
const resolve_heartbeat = async (config2) => {
|
1678 |
+
await this._resolve_hearbeat(config2);
|
1679 |
+
};
|
1680 |
+
async function handle_render_config(render_config) {
|
1681 |
+
if (!config)
|
1682 |
+
return;
|
1683 |
+
let render_id = render_config.render_id;
|
1684 |
+
config.components = [
|
1685 |
+
...config.components.filter((c) => c.props.rendered_in !== render_id),
|
1686 |
+
...render_config.components
|
1687 |
+
];
|
1688 |
+
config.dependencies = [
|
1689 |
+
...config.dependencies.filter((d) => d.rendered_in !== render_id),
|
1690 |
+
...render_config.dependencies
|
1691 |
+
];
|
1692 |
+
const any_state = config.components.some((c) => c.type === "state");
|
1693 |
+
const any_unload = config.dependencies.some(
|
1694 |
+
(d) => d.targets.some((t) => t[1] === "unload")
|
1695 |
+
);
|
1696 |
+
config.connect_heartbeat = any_state || any_unload;
|
1697 |
+
await resolve_heartbeat(config);
|
1698 |
+
fire_event({
|
1699 |
+
type: "render",
|
1700 |
+
data: render_config,
|
1701 |
+
endpoint: _endpoint,
|
1702 |
+
fn_index
|
1703 |
+
});
|
1704 |
+
}
|
1705 |
+
this.handle_blob(config.root, resolved_data, endpoint_info).then(
|
1706 |
+
async (_payload) => {
|
1707 |
+
var _a2;
|
1708 |
+
let input_data = handle_payload(
|
1709 |
+
_payload,
|
1710 |
+
dependency,
|
1711 |
+
config.components,
|
1712 |
+
"input",
|
1713 |
+
true
|
1714 |
+
);
|
1715 |
+
payload = {
|
1716 |
+
data: input_data || [],
|
1717 |
+
event_data,
|
1718 |
+
fn_index,
|
1719 |
+
trigger_id
|
1720 |
+
};
|
1721 |
+
if (skip_queue(fn_index, config)) {
|
1722 |
+
fire_event({
|
1723 |
+
type: "status",
|
1724 |
+
endpoint: _endpoint,
|
1725 |
+
stage: "pending",
|
1726 |
+
queue: false,
|
1727 |
+
fn_index,
|
1728 |
+
time: /* @__PURE__ */ new Date()
|
1729 |
+
});
|
1730 |
+
post_data2(
|
1731 |
+
`${config.root}${api_prefix}/run${_endpoint.startsWith("/") ? _endpoint : `/${_endpoint}`}${url_params ? "?" + url_params : ""}`,
|
1732 |
+
{
|
1733 |
+
...payload,
|
1734 |
+
session_hash
|
1735 |
+
}
|
1736 |
+
).then(([output, status_code]) => {
|
1737 |
+
const data2 = output.data;
|
1738 |
+
if (status_code == 200) {
|
1739 |
+
fire_event({
|
1740 |
+
type: "data",
|
1741 |
+
endpoint: _endpoint,
|
1742 |
+
fn_index,
|
1743 |
+
data: handle_payload(
|
1744 |
+
data2,
|
1745 |
+
dependency,
|
1746 |
+
config.components,
|
1747 |
+
"output",
|
1748 |
+
options.with_null_state
|
1749 |
+
),
|
1750 |
+
time: /* @__PURE__ */ new Date(),
|
1751 |
+
event_data,
|
1752 |
+
trigger_id
|
1753 |
+
});
|
1754 |
+
if (output.render_config) {
|
1755 |
+
handle_render_config(output.render_config);
|
1756 |
+
}
|
1757 |
+
fire_event({
|
1758 |
+
type: "status",
|
1759 |
+
endpoint: _endpoint,
|
1760 |
+
fn_index,
|
1761 |
+
stage: "complete",
|
1762 |
+
eta: output.average_duration,
|
1763 |
+
queue: false,
|
1764 |
+
time: /* @__PURE__ */ new Date()
|
1765 |
+
});
|
1766 |
+
} else {
|
1767 |
+
fire_event({
|
1768 |
+
type: "status",
|
1769 |
+
stage: "error",
|
1770 |
+
endpoint: _endpoint,
|
1771 |
+
fn_index,
|
1772 |
+
message: output.error,
|
1773 |
+
queue: false,
|
1774 |
+
time: /* @__PURE__ */ new Date()
|
1775 |
+
});
|
1776 |
+
}
|
1777 |
+
}).catch((e) => {
|
1778 |
+
fire_event({
|
1779 |
+
type: "status",
|
1780 |
+
stage: "error",
|
1781 |
+
message: e.message,
|
1782 |
+
endpoint: _endpoint,
|
1783 |
+
fn_index,
|
1784 |
+
queue: false,
|
1785 |
+
time: /* @__PURE__ */ new Date()
|
1786 |
+
});
|
1787 |
+
});
|
1788 |
+
} else if (protocol == "ws") {
|
1789 |
+
const { ws_protocol, host } = await process_endpoint(
|
1790 |
+
app_reference,
|
1791 |
+
hf_token
|
1792 |
+
);
|
1793 |
+
fire_event({
|
1794 |
+
type: "status",
|
1795 |
+
stage: "pending",
|
1796 |
+
queue: true,
|
1797 |
+
endpoint: _endpoint,
|
1798 |
+
fn_index,
|
1799 |
+
time: /* @__PURE__ */ new Date()
|
1800 |
+
});
|
1801 |
+
let url = new URL(
|
1802 |
+
`${ws_protocol}://${resolve_root(
|
1803 |
+
host,
|
1804 |
+
config.path,
|
1805 |
+
true
|
1806 |
+
)}/queue/join${url_params ? "?" + url_params : ""}`
|
1807 |
+
);
|
1808 |
+
if (this.jwt) {
|
1809 |
+
url.searchParams.set("__sign", this.jwt);
|
1810 |
+
}
|
1811 |
+
websocket = new WebSocket(url);
|
1812 |
+
websocket.onclose = (evt) => {
|
1813 |
+
if (!evt.wasClean) {
|
1814 |
+
fire_event({
|
1815 |
+
type: "status",
|
1816 |
+
stage: "error",
|
1817 |
+
broken: true,
|
1818 |
+
message: BROKEN_CONNECTION_MSG,
|
1819 |
+
queue: true,
|
1820 |
+
endpoint: _endpoint,
|
1821 |
+
fn_index,
|
1822 |
+
time: /* @__PURE__ */ new Date()
|
1823 |
+
});
|
1824 |
+
}
|
1825 |
+
};
|
1826 |
+
websocket.onmessage = function(event) {
|
1827 |
+
const _data = JSON.parse(event.data);
|
1828 |
+
const { type, status, data: data2 } = handle_message(
|
1829 |
+
_data,
|
1830 |
+
last_status[fn_index]
|
1831 |
+
);
|
1832 |
+
if (type === "update" && status && !complete) {
|
1833 |
+
fire_event({
|
1834 |
+
type: "status",
|
1835 |
+
endpoint: _endpoint,
|
1836 |
+
fn_index,
|
1837 |
+
time: /* @__PURE__ */ new Date(),
|
1838 |
+
...status
|
1839 |
+
});
|
1840 |
+
if (status.stage === "error") {
|
1841 |
+
websocket.close();
|
1842 |
+
}
|
1843 |
+
} else if (type === "hash") {
|
1844 |
+
websocket.send(JSON.stringify({ fn_index, session_hash }));
|
1845 |
+
return;
|
1846 |
+
} else if (type === "data") {
|
1847 |
+
websocket.send(JSON.stringify({ ...payload, session_hash }));
|
1848 |
+
} else if (type === "complete") {
|
1849 |
+
complete = status;
|
1850 |
+
} else if (type === "log") {
|
1851 |
+
fire_event({
|
1852 |
+
type: "log",
|
1853 |
+
title: data2.title,
|
1854 |
+
log: data2.log,
|
1855 |
+
level: data2.level,
|
1856 |
+
endpoint: _endpoint,
|
1857 |
+
duration: data2.duration,
|
1858 |
+
visible: data2.visible,
|
1859 |
+
fn_index
|
1860 |
+
});
|
1861 |
+
} else if (type === "generating") {
|
1862 |
+
fire_event({
|
1863 |
+
type: "status",
|
1864 |
+
time: /* @__PURE__ */ new Date(),
|
1865 |
+
...status,
|
1866 |
+
stage: status == null ? void 0 : status.stage,
|
1867 |
+
queue: true,
|
1868 |
+
endpoint: _endpoint,
|
1869 |
+
fn_index
|
1870 |
+
});
|
1871 |
+
}
|
1872 |
+
if (data2) {
|
1873 |
+
fire_event({
|
1874 |
+
type: "data",
|
1875 |
+
time: /* @__PURE__ */ new Date(),
|
1876 |
+
data: handle_payload(
|
1877 |
+
data2.data,
|
1878 |
+
dependency,
|
1879 |
+
config.components,
|
1880 |
+
"output",
|
1881 |
+
options.with_null_state
|
1882 |
+
),
|
1883 |
+
endpoint: _endpoint,
|
1884 |
+
fn_index,
|
1885 |
+
event_data,
|
1886 |
+
trigger_id
|
1887 |
+
});
|
1888 |
+
if (complete) {
|
1889 |
+
fire_event({
|
1890 |
+
type: "status",
|
1891 |
+
time: /* @__PURE__ */ new Date(),
|
1892 |
+
...complete,
|
1893 |
+
stage: status == null ? void 0 : status.stage,
|
1894 |
+
queue: true,
|
1895 |
+
endpoint: _endpoint,
|
1896 |
+
fn_index
|
1897 |
+
});
|
1898 |
+
websocket.close();
|
1899 |
+
}
|
1900 |
+
}
|
1901 |
+
};
|
1902 |
+
if (semiver(config.version || "2.0.0", "3.6") < 0) {
|
1903 |
+
addEventListener(
|
1904 |
+
"open",
|
1905 |
+
() => websocket.send(JSON.stringify({ hash: session_hash }))
|
1906 |
+
);
|
1907 |
+
}
|
1908 |
+
} else if (protocol == "sse") {
|
1909 |
+
fire_event({
|
1910 |
+
type: "status",
|
1911 |
+
stage: "pending",
|
1912 |
+
queue: true,
|
1913 |
+
endpoint: _endpoint,
|
1914 |
+
fn_index,
|
1915 |
+
time: /* @__PURE__ */ new Date()
|
1916 |
+
});
|
1917 |
+
var params = new URLSearchParams({
|
1918 |
+
fn_index: fn_index.toString(),
|
1919 |
+
session_hash
|
1920 |
+
}).toString();
|
1921 |
+
let url = new URL(
|
1922 |
+
`${config.root}${api_prefix}/${SSE_URL}?${url_params ? url_params + "&" : ""}${params}`
|
1923 |
+
);
|
1924 |
+
if (this.jwt) {
|
1925 |
+
url.searchParams.set("__sign", this.jwt);
|
1926 |
+
}
|
1927 |
+
stream2 = this.stream(url);
|
1928 |
+
if (!stream2) {
|
1929 |
+
return Promise.reject(
|
1930 |
+
new Error("Cannot connect to SSE endpoint: " + url.toString())
|
1931 |
+
);
|
1932 |
+
}
|
1933 |
+
stream2.onmessage = async function(event) {
|
1934 |
+
const _data = JSON.parse(event.data);
|
1935 |
+
const { type, status, data: data2 } = handle_message(
|
1936 |
+
_data,
|
1937 |
+
last_status[fn_index]
|
1938 |
+
);
|
1939 |
+
if (type === "update" && status && !complete) {
|
1940 |
+
fire_event({
|
1941 |
+
type: "status",
|
1942 |
+
endpoint: _endpoint,
|
1943 |
+
fn_index,
|
1944 |
+
time: /* @__PURE__ */ new Date(),
|
1945 |
+
...status
|
1946 |
+
});
|
1947 |
+
if (status.stage === "error") {
|
1948 |
+
stream2 == null ? void 0 : stream2.close();
|
1949 |
+
close();
|
1950 |
+
}
|
1951 |
+
} else if (type === "data") {
|
1952 |
+
let [_, status2] = await post_data2(
|
1953 |
+
`${config.root}${api_prefix}/queue/data`,
|
1954 |
+
{
|
1955 |
+
...payload,
|
1956 |
+
session_hash,
|
1957 |
+
event_id
|
1958 |
+
}
|
1959 |
+
);
|
1960 |
+
if (status2 !== 200) {
|
1961 |
+
fire_event({
|
1962 |
+
type: "status",
|
1963 |
+
stage: "error",
|
1964 |
+
message: BROKEN_CONNECTION_MSG,
|
1965 |
+
queue: true,
|
1966 |
+
endpoint: _endpoint,
|
1967 |
+
fn_index,
|
1968 |
+
time: /* @__PURE__ */ new Date()
|
1969 |
+
});
|
1970 |
+
stream2 == null ? void 0 : stream2.close();
|
1971 |
+
close();
|
1972 |
+
}
|
1973 |
+
} else if (type === "complete") {
|
1974 |
+
complete = status;
|
1975 |
+
} else if (type === "log") {
|
1976 |
+
fire_event({
|
1977 |
+
type: "log",
|
1978 |
+
title: data2.title,
|
1979 |
+
log: data2.log,
|
1980 |
+
level: data2.level,
|
1981 |
+
endpoint: _endpoint,
|
1982 |
+
duration: data2.duration,
|
1983 |
+
visible: data2.visible,
|
1984 |
+
fn_index
|
1985 |
+
});
|
1986 |
+
} else if (type === "generating" || type === "streaming") {
|
1987 |
+
fire_event({
|
1988 |
+
type: "status",
|
1989 |
+
time: /* @__PURE__ */ new Date(),
|
1990 |
+
...status,
|
1991 |
+
stage: status == null ? void 0 : status.stage,
|
1992 |
+
queue: true,
|
1993 |
+
endpoint: _endpoint,
|
1994 |
+
fn_index
|
1995 |
+
});
|
1996 |
+
}
|
1997 |
+
if (data2) {
|
1998 |
+
fire_event({
|
1999 |
+
type: "data",
|
2000 |
+
time: /* @__PURE__ */ new Date(),
|
2001 |
+
data: handle_payload(
|
2002 |
+
data2.data,
|
2003 |
+
dependency,
|
2004 |
+
config.components,
|
2005 |
+
"output",
|
2006 |
+
options.with_null_state
|
2007 |
+
),
|
2008 |
+
endpoint: _endpoint,
|
2009 |
+
fn_index,
|
2010 |
+
event_data,
|
2011 |
+
trigger_id
|
2012 |
+
});
|
2013 |
+
if (complete) {
|
2014 |
+
fire_event({
|
2015 |
+
type: "status",
|
2016 |
+
time: /* @__PURE__ */ new Date(),
|
2017 |
+
...complete,
|
2018 |
+
stage: status == null ? void 0 : status.stage,
|
2019 |
+
queue: true,
|
2020 |
+
endpoint: _endpoint,
|
2021 |
+
fn_index
|
2022 |
+
});
|
2023 |
+
stream2 == null ? void 0 : stream2.close();
|
2024 |
+
close();
|
2025 |
+
}
|
2026 |
+
}
|
2027 |
+
};
|
2028 |
+
} else if (protocol == "sse_v1" || protocol == "sse_v2" || protocol == "sse_v2.1" || protocol == "sse_v3") {
|
2029 |
+
fire_event({
|
2030 |
+
type: "status",
|
2031 |
+
stage: "pending",
|
2032 |
+
queue: true,
|
2033 |
+
endpoint: _endpoint,
|
2034 |
+
fn_index,
|
2035 |
+
time: /* @__PURE__ */ new Date()
|
2036 |
+
});
|
2037 |
+
let hostname = "";
|
2038 |
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
2039 |
+
hostname = (_a2 = window == null ? void 0 : window.location) == null ? void 0 : _a2.hostname;
|
2040 |
+
}
|
2041 |
+
let hfhubdev = "dev.spaces.huggingface.tech";
|
2042 |
+
const origin = hostname.includes(".dev.") ? `https://moon-${hostname.split(".")[1]}.${hfhubdev}` : `https://huggingface.co`;
|
2043 |
+
const is_zerogpu_iframe = typeof window !== "undefined" && typeof document !== "undefined" && window.parent != window && window.supports_zerogpu_headers;
|
2044 |
+
const zerogpu_auth_promise = is_zerogpu_iframe ? post_message("zerogpu-headers", origin) : Promise.resolve(null);
|
2045 |
+
const post_data_promise = zerogpu_auth_promise.then((headers) => {
|
2046 |
+
return post_data2(
|
2047 |
+
`${config.root}${api_prefix}/${SSE_DATA_URL}?${url_params}`,
|
2048 |
+
{
|
2049 |
+
...payload,
|
2050 |
+
session_hash
|
2051 |
+
},
|
2052 |
+
headers
|
2053 |
+
);
|
2054 |
+
});
|
2055 |
+
post_data_promise.then(async ([response, status]) => {
|
2056 |
+
if (status === 503) {
|
2057 |
+
fire_event({
|
2058 |
+
type: "status",
|
2059 |
+
stage: "error",
|
2060 |
+
message: QUEUE_FULL_MSG,
|
2061 |
+
queue: true,
|
2062 |
+
endpoint: _endpoint,
|
2063 |
+
fn_index,
|
2064 |
+
time: /* @__PURE__ */ new Date()
|
2065 |
+
});
|
2066 |
+
} else if (status !== 200) {
|
2067 |
+
fire_event({
|
2068 |
+
type: "status",
|
2069 |
+
stage: "error",
|
2070 |
+
message: BROKEN_CONNECTION_MSG,
|
2071 |
+
queue: true,
|
2072 |
+
endpoint: _endpoint,
|
2073 |
+
fn_index,
|
2074 |
+
time: /* @__PURE__ */ new Date()
|
2075 |
+
});
|
2076 |
+
} else {
|
2077 |
+
event_id = response.event_id;
|
2078 |
+
event_id_final = event_id;
|
2079 |
+
let callback = async function(_data) {
|
2080 |
+
try {
|
2081 |
+
const { type, status: status2, data: data2, original_msg } = handle_message(
|
2082 |
+
_data,
|
2083 |
+
last_status[fn_index]
|
2084 |
+
);
|
2085 |
+
if (type == "heartbeat") {
|
2086 |
+
return;
|
2087 |
+
}
|
2088 |
+
if (type === "update" && status2 && !complete) {
|
2089 |
+
fire_event({
|
2090 |
+
type: "status",
|
2091 |
+
endpoint: _endpoint,
|
2092 |
+
fn_index,
|
2093 |
+
time: /* @__PURE__ */ new Date(),
|
2094 |
+
original_msg,
|
2095 |
+
...status2
|
2096 |
+
});
|
2097 |
+
} else if (type === "complete") {
|
2098 |
+
complete = status2;
|
2099 |
+
} else if (type == "unexpected_error") {
|
2100 |
+
console.error("Unexpected error", status2 == null ? void 0 : status2.message);
|
2101 |
+
fire_event({
|
2102 |
+
type: "status",
|
2103 |
+
stage: "error",
|
2104 |
+
message: (status2 == null ? void 0 : status2.message) || "An Unexpected Error Occurred!",
|
2105 |
+
queue: true,
|
2106 |
+
endpoint: _endpoint,
|
2107 |
+
fn_index,
|
2108 |
+
time: /* @__PURE__ */ new Date()
|
2109 |
+
});
|
2110 |
+
} else if (type === "log") {
|
2111 |
+
fire_event({
|
2112 |
+
type: "log",
|
2113 |
+
title: data2.title,
|
2114 |
+
log: data2.log,
|
2115 |
+
level: data2.level,
|
2116 |
+
endpoint: _endpoint,
|
2117 |
+
duration: data2.duration,
|
2118 |
+
visible: data2.visible,
|
2119 |
+
fn_index
|
2120 |
+
});
|
2121 |
+
return;
|
2122 |
+
} else if (type === "generating" || type === "streaming") {
|
2123 |
+
fire_event({
|
2124 |
+
type: "status",
|
2125 |
+
time: /* @__PURE__ */ new Date(),
|
2126 |
+
...status2,
|
2127 |
+
stage: status2 == null ? void 0 : status2.stage,
|
2128 |
+
queue: true,
|
2129 |
+
endpoint: _endpoint,
|
2130 |
+
fn_index
|
2131 |
+
});
|
2132 |
+
if (data2 && dependency.connection !== "stream" && ["sse_v2", "sse_v2.1", "sse_v3"].includes(protocol)) {
|
2133 |
+
apply_diff_stream(pending_diff_streams, event_id, data2);
|
2134 |
+
}
|
2135 |
+
}
|
2136 |
+
if (data2) {
|
2137 |
+
fire_event({
|
2138 |
+
type: "data",
|
2139 |
+
time: /* @__PURE__ */ new Date(),
|
2140 |
+
data: handle_payload(
|
2141 |
+
data2.data,
|
2142 |
+
dependency,
|
2143 |
+
config.components,
|
2144 |
+
"output",
|
2145 |
+
options.with_null_state
|
2146 |
+
),
|
2147 |
+
endpoint: _endpoint,
|
2148 |
+
fn_index
|
2149 |
+
});
|
2150 |
+
if (data2.render_config) {
|
2151 |
+
await handle_render_config(data2.render_config);
|
2152 |
+
}
|
2153 |
+
if (complete) {
|
2154 |
+
fire_event({
|
2155 |
+
type: "status",
|
2156 |
+
time: /* @__PURE__ */ new Date(),
|
2157 |
+
...complete,
|
2158 |
+
stage: status2 == null ? void 0 : status2.stage,
|
2159 |
+
queue: true,
|
2160 |
+
endpoint: _endpoint,
|
2161 |
+
fn_index
|
2162 |
+
});
|
2163 |
+
close();
|
2164 |
+
}
|
2165 |
+
}
|
2166 |
+
if ((status2 == null ? void 0 : status2.stage) === "complete" || (status2 == null ? void 0 : status2.stage) === "error") {
|
2167 |
+
if (event_callbacks[event_id]) {
|
2168 |
+
delete event_callbacks[event_id];
|
2169 |
+
}
|
2170 |
+
if (event_id in pending_diff_streams) {
|
2171 |
+
delete pending_diff_streams[event_id];
|
2172 |
+
}
|
2173 |
+
}
|
2174 |
+
} catch (e) {
|
2175 |
+
console.error("Unexpected client exception", e);
|
2176 |
+
fire_event({
|
2177 |
+
type: "status",
|
2178 |
+
stage: "error",
|
2179 |
+
message: "An Unexpected Error Occurred!",
|
2180 |
+
queue: true,
|
2181 |
+
endpoint: _endpoint,
|
2182 |
+
fn_index,
|
2183 |
+
time: /* @__PURE__ */ new Date()
|
2184 |
+
});
|
2185 |
+
if (["sse_v2", "sse_v2.1", "sse_v3"].includes(protocol)) {
|
2186 |
+
close_stream(stream_status, that.abort_controller);
|
2187 |
+
stream_status.open = false;
|
2188 |
+
close();
|
2189 |
+
}
|
2190 |
+
}
|
2191 |
+
};
|
2192 |
+
if (event_id in pending_stream_messages) {
|
2193 |
+
pending_stream_messages[event_id].forEach(
|
2194 |
+
(msg) => callback(msg)
|
2195 |
+
);
|
2196 |
+
delete pending_stream_messages[event_id];
|
2197 |
+
}
|
2198 |
+
event_callbacks[event_id] = callback;
|
2199 |
+
unclosed_events.add(event_id);
|
2200 |
+
if (!stream_status.open) {
|
2201 |
+
await this.open_stream();
|
2202 |
+
}
|
2203 |
+
}
|
2204 |
+
});
|
2205 |
+
}
|
2206 |
+
}
|
2207 |
+
);
|
2208 |
+
let done = false;
|
2209 |
+
const values = [];
|
2210 |
+
const resolvers = [];
|
2211 |
+
const iterator = {
|
2212 |
+
[Symbol.asyncIterator]: () => iterator,
|
2213 |
+
next,
|
2214 |
+
throw: async (value) => {
|
2215 |
+
push_error(value);
|
2216 |
+
return next();
|
2217 |
+
},
|
2218 |
+
return: async () => {
|
2219 |
+
close();
|
2220 |
+
return next();
|
2221 |
+
},
|
2222 |
+
cancel,
|
2223 |
+
event_id: event_id_cb
|
2224 |
+
};
|
2225 |
+
return iterator;
|
2226 |
+
} catch (error) {
|
2227 |
+
console.error("Submit function encountered an error:", error);
|
2228 |
+
throw error;
|
2229 |
+
}
|
2230 |
+
}
|
2231 |
+
function thenable_reject(error) {
|
2232 |
+
return {
|
2233 |
+
then: (resolve, reject) => reject(error)
|
2234 |
+
};
|
2235 |
+
}
|
2236 |
+
function get_endpoint_info(api_info, endpoint, api_map, config) {
|
2237 |
+
let fn_index;
|
2238 |
+
let endpoint_info;
|
2239 |
+
let dependency;
|
2240 |
+
if (typeof endpoint === "number") {
|
2241 |
+
fn_index = endpoint;
|
2242 |
+
endpoint_info = api_info.unnamed_endpoints[fn_index];
|
2243 |
+
dependency = config.dependencies.find((dep) => dep.id == endpoint);
|
2244 |
+
} else {
|
2245 |
+
const trimmed_endpoint = endpoint.replace(/^\//, "");
|
2246 |
+
fn_index = api_map[trimmed_endpoint];
|
2247 |
+
endpoint_info = api_info.named_endpoints[endpoint.trim()];
|
2248 |
+
dependency = config.dependencies.find(
|
2249 |
+
(dep) => dep.id == api_map[trimmed_endpoint]
|
2250 |
+
);
|
2251 |
+
}
|
2252 |
+
if (typeof fn_index !== "number") {
|
2253 |
+
throw new Error(
|
2254 |
+
"There is no endpoint matching that name of fn_index matching that number."
|
2255 |
+
);
|
2256 |
+
}
|
2257 |
+
return { fn_index, endpoint_info, dependency };
|
2258 |
+
}
|
2259 |
+
class Client {
|
2260 |
+
constructor(app_reference, options = { events: ["data"] }) {
|
2261 |
+
__publicField(this, "app_reference");
|
2262 |
+
__publicField(this, "options");
|
2263 |
+
__publicField(this, "deep_link", null);
|
2264 |
+
__publicField(this, "config");
|
2265 |
+
__publicField(this, "api_prefix", "");
|
2266 |
+
__publicField(this, "api_info");
|
2267 |
+
__publicField(this, "api_map", {});
|
2268 |
+
__publicField(this, "session_hash", Math.random().toString(36).substring(2));
|
2269 |
+
__publicField(this, "jwt", false);
|
2270 |
+
__publicField(this, "last_status", {});
|
2271 |
+
__publicField(this, "cookies", null);
|
2272 |
+
// streaming
|
2273 |
+
__publicField(this, "stream_status", { open: false });
|
2274 |
+
__publicField(this, "closed", false);
|
2275 |
+
__publicField(this, "pending_stream_messages", {});
|
2276 |
+
__publicField(this, "pending_diff_streams", {});
|
2277 |
+
__publicField(this, "event_callbacks", {});
|
2278 |
+
__publicField(this, "unclosed_events", /* @__PURE__ */ new Set());
|
2279 |
+
__publicField(this, "heartbeat_event", null);
|
2280 |
+
__publicField(this, "abort_controller", null);
|
2281 |
+
__publicField(this, "stream_instance", null);
|
2282 |
+
__publicField(this, "current_payload");
|
2283 |
+
__publicField(this, "ws_map", {});
|
2284 |
+
__publicField(this, "view_api");
|
2285 |
+
__publicField(this, "upload_files");
|
2286 |
+
__publicField(this, "upload");
|
2287 |
+
__publicField(this, "handle_blob");
|
2288 |
+
__publicField(this, "post_data");
|
2289 |
+
__publicField(this, "submit");
|
2290 |
+
__publicField(this, "predict");
|
2291 |
+
__publicField(this, "open_stream");
|
2292 |
+
__publicField(this, "resolve_config");
|
2293 |
+
__publicField(this, "resolve_cookies");
|
2294 |
+
var _a;
|
2295 |
+
this.app_reference = app_reference;
|
2296 |
+
this.deep_link = ((_a = options.query_params) == null ? void 0 : _a.deep_link) || null;
|
2297 |
+
if (!options.events) {
|
2298 |
+
options.events = ["data"];
|
2299 |
+
}
|
2300 |
+
this.options = options;
|
2301 |
+
this.current_payload = {};
|
2302 |
+
this.view_api = view_api.bind(this);
|
2303 |
+
this.upload_files = upload_files.bind(this);
|
2304 |
+
this.handle_blob = handle_blob.bind(this);
|
2305 |
+
this.post_data = post_data.bind(this);
|
2306 |
+
this.submit = submit.bind(this);
|
2307 |
+
this.predict = predict.bind(this);
|
2308 |
+
this.open_stream = open_stream.bind(this);
|
2309 |
+
this.resolve_config = resolve_config.bind(this);
|
2310 |
+
this.resolve_cookies = resolve_cookies.bind(this);
|
2311 |
+
this.upload = upload.bind(this);
|
2312 |
+
this.fetch = this.fetch.bind(this);
|
2313 |
+
this.handle_space_success = this.handle_space_success.bind(this);
|
2314 |
+
this.stream = this.stream.bind(this);
|
2315 |
+
}
|
2316 |
+
get_url_config(url = null) {
|
2317 |
+
if (!this.config) {
|
2318 |
+
throw new Error(CONFIG_ERROR_MSG);
|
2319 |
+
}
|
2320 |
+
if (url === null) {
|
2321 |
+
url = window.location.href;
|
2322 |
+
}
|
2323 |
+
const stripSlashes = (str) => str.replace(/^\/+|\/+$/g, "");
|
2324 |
+
let root_path = stripSlashes(new URL(this.config.root).pathname);
|
2325 |
+
let url_path = stripSlashes(new URL(url).pathname);
|
2326 |
+
let page;
|
2327 |
+
if (!url_path.startsWith(root_path)) {
|
2328 |
+
page = "";
|
2329 |
+
} else {
|
2330 |
+
page = stripSlashes(url_path.substring(root_path.length));
|
2331 |
+
}
|
2332 |
+
return this.get_page_config(page);
|
2333 |
+
}
|
2334 |
+
get_page_config(page) {
|
2335 |
+
if (!this.config) {
|
2336 |
+
throw new Error(CONFIG_ERROR_MSG);
|
2337 |
+
}
|
2338 |
+
let config = this.config;
|
2339 |
+
if (!(page in config.page)) {
|
2340 |
+
page = "";
|
2341 |
+
}
|
2342 |
+
return {
|
2343 |
+
...config,
|
2344 |
+
current_page: page,
|
2345 |
+
layout: config.page[page].layout,
|
2346 |
+
components: config.components.filter(
|
2347 |
+
(c) => config.page[page].components.includes(c.id)
|
2348 |
+
),
|
2349 |
+
dependencies: this.config.dependencies.filter(
|
2350 |
+
(d) => config.page[page].dependencies.includes(d.id)
|
2351 |
+
)
|
2352 |
+
};
|
2353 |
+
}
|
2354 |
+
fetch(input, init) {
|
2355 |
+
const headers = new Headers((init == null ? void 0 : init.headers) || {});
|
2356 |
+
if (this && this.cookies) {
|
2357 |
+
headers.append("Cookie", this.cookies);
|
2358 |
+
}
|
2359 |
+
if (this && this.options.headers) {
|
2360 |
+
for (const name in this.options.headers) {
|
2361 |
+
headers.append(name, this.options.headers[name]);
|
2362 |
+
}
|
2363 |
+
}
|
2364 |
+
return fetch(input, { ...init, headers });
|
2365 |
+
}
|
2366 |
+
stream(url) {
|
2367 |
+
const headers = new Headers();
|
2368 |
+
if (this && this.cookies) {
|
2369 |
+
headers.append("Cookie", this.cookies);
|
2370 |
+
}
|
2371 |
+
if (this && this.options.headers) {
|
2372 |
+
for (const name in this.options.headers) {
|
2373 |
+
headers.append(name, this.options.headers[name]);
|
2374 |
+
}
|
2375 |
+
}
|
2376 |
+
this.abort_controller = new AbortController();
|
2377 |
+
this.stream_instance = readable_stream(url.toString(), {
|
2378 |
+
credentials: "include",
|
2379 |
+
headers,
|
2380 |
+
signal: this.abort_controller.signal
|
2381 |
+
});
|
2382 |
+
return this.stream_instance;
|
2383 |
+
}
|
2384 |
+
async init() {
|
2385 |
+
var _a;
|
2386 |
+
if ((typeof window === "undefined" || !("WebSocket" in window)) && !global.WebSocket) {
|
2387 |
+
const ws = await import("./wrapper-CviSselG.js");
|
2388 |
+
global.WebSocket = ws.WebSocket;
|
2389 |
+
}
|
2390 |
+
if (this.options.auth) {
|
2391 |
+
await this.resolve_cookies();
|
2392 |
+
}
|
2393 |
+
await this._resolve_config().then(
|
2394 |
+
({ config }) => this._resolve_hearbeat(config)
|
2395 |
+
);
|
2396 |
+
this.api_info = await this.view_api();
|
2397 |
+
this.api_map = map_names_to_ids(((_a = this.config) == null ? void 0 : _a.dependencies) || []);
|
2398 |
+
}
|
2399 |
+
async _resolve_hearbeat(_config) {
|
2400 |
+
if (_config) {
|
2401 |
+
this.config = _config;
|
2402 |
+
this.api_prefix = _config.api_prefix || "";
|
2403 |
+
if (this.config && this.config.connect_heartbeat) {
|
2404 |
+
if (this.config.space_id && this.options.hf_token) {
|
2405 |
+
this.jwt = await get_jwt(
|
2406 |
+
this.config.space_id,
|
2407 |
+
this.options.hf_token,
|
2408 |
+
this.cookies
|
2409 |
+
);
|
2410 |
+
}
|
2411 |
+
}
|
2412 |
+
}
|
2413 |
+
if (_config.space_id && this.options.hf_token) {
|
2414 |
+
this.jwt = await get_jwt(_config.space_id, this.options.hf_token);
|
2415 |
+
}
|
2416 |
+
if (this.config && this.config.connect_heartbeat) {
|
2417 |
+
const heartbeat_url = new URL(
|
2418 |
+
`${this.config.root}${this.api_prefix}/${HEARTBEAT_URL}/${this.session_hash}`
|
2419 |
+
);
|
2420 |
+
if (this.jwt) {
|
2421 |
+
heartbeat_url.searchParams.set("__sign", this.jwt);
|
2422 |
+
}
|
2423 |
+
if (!this.heartbeat_event) {
|
2424 |
+
this.heartbeat_event = this.stream(heartbeat_url);
|
2425 |
+
}
|
2426 |
+
}
|
2427 |
+
}
|
2428 |
+
static async connect(app_reference, options = {
|
2429 |
+
events: ["data"]
|
2430 |
+
}) {
|
2431 |
+
const client2 = new this(app_reference, options);
|
2432 |
+
await client2.init();
|
2433 |
+
return client2;
|
2434 |
+
}
|
2435 |
+
close() {
|
2436 |
+
this.closed = true;
|
2437 |
+
close_stream(this.stream_status, this.abort_controller);
|
2438 |
+
}
|
2439 |
+
set_current_payload(payload) {
|
2440 |
+
this.current_payload = payload;
|
2441 |
+
}
|
2442 |
+
static async duplicate(app_reference, options = {
|
2443 |
+
events: ["data"]
|
2444 |
+
}) {
|
2445 |
+
return duplicate(app_reference, options);
|
2446 |
+
}
|
2447 |
+
async _resolve_config() {
|
2448 |
+
const { http_protocol, host, space_id } = await process_endpoint(
|
2449 |
+
this.app_reference,
|
2450 |
+
this.options.hf_token
|
2451 |
+
);
|
2452 |
+
const { status_callback } = this.options;
|
2453 |
+
if (space_id && status_callback) {
|
2454 |
+
await check_and_wake_space(space_id, status_callback);
|
2455 |
+
}
|
2456 |
+
let config;
|
2457 |
+
try {
|
2458 |
+
let configUrl = `${http_protocol}//${host}`;
|
2459 |
+
config = await this.resolve_config(configUrl);
|
2460 |
+
if (!config) {
|
2461 |
+
throw new Error(CONFIG_ERROR_MSG);
|
2462 |
+
}
|
2463 |
+
return this.config_success(config);
|
2464 |
+
} catch (e) {
|
2465 |
+
if (space_id && status_callback) {
|
2466 |
+
check_space_status(
|
2467 |
+
space_id,
|
2468 |
+
RE_SPACE_NAME.test(space_id) ? "space_name" : "subdomain",
|
2469 |
+
this.handle_space_success
|
2470 |
+
);
|
2471 |
+
} else {
|
2472 |
+
if (status_callback)
|
2473 |
+
status_callback({
|
2474 |
+
status: "error",
|
2475 |
+
message: "Could not load this space.",
|
2476 |
+
load_status: "error",
|
2477 |
+
detail: "NOT_FOUND"
|
2478 |
+
});
|
2479 |
+
throw Error(e);
|
2480 |
+
}
|
2481 |
+
}
|
2482 |
+
}
|
2483 |
+
async config_success(_config) {
|
2484 |
+
this.config = _config;
|
2485 |
+
this.api_prefix = _config.api_prefix || "";
|
2486 |
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
2487 |
+
if (window.location.protocol === "https:") {
|
2488 |
+
this.config.root = this.config.root.replace("http://", "https://");
|
2489 |
+
}
|
2490 |
+
}
|
2491 |
+
if (this.config.auth_required) {
|
2492 |
+
return this.prepare_return_obj();
|
2493 |
+
}
|
2494 |
+
try {
|
2495 |
+
this.api_info = await this.view_api();
|
2496 |
+
} catch (e) {
|
2497 |
+
console.error(API_INFO_ERROR_MSG + e.message);
|
2498 |
+
}
|
2499 |
+
return this.prepare_return_obj();
|
2500 |
+
}
|
2501 |
+
async handle_space_success(status) {
|
2502 |
+
var _a;
|
2503 |
+
if (!this) {
|
2504 |
+
throw new Error(CONFIG_ERROR_MSG);
|
2505 |
+
}
|
2506 |
+
const { status_callback } = this.options;
|
2507 |
+
if (status_callback)
|
2508 |
+
status_callback(status);
|
2509 |
+
if (status.status === "running") {
|
2510 |
+
try {
|
2511 |
+
this.config = await this._resolve_config();
|
2512 |
+
this.api_prefix = ((_a = this == null ? void 0 : this.config) == null ? void 0 : _a.api_prefix) || "";
|
2513 |
+
if (!this.config) {
|
2514 |
+
throw new Error(CONFIG_ERROR_MSG);
|
2515 |
+
}
|
2516 |
+
const _config = await this.config_success(this.config);
|
2517 |
+
return _config;
|
2518 |
+
} catch (e) {
|
2519 |
+
if (status_callback) {
|
2520 |
+
status_callback({
|
2521 |
+
status: "error",
|
2522 |
+
message: "Could not load this space.",
|
2523 |
+
load_status: "error",
|
2524 |
+
detail: "NOT_FOUND"
|
2525 |
+
});
|
2526 |
+
}
|
2527 |
+
throw e;
|
2528 |
+
}
|
2529 |
+
}
|
2530 |
+
}
|
2531 |
+
async component_server(component_id, fn_name, data) {
|
2532 |
+
var _a;
|
2533 |
+
if (!this.config) {
|
2534 |
+
throw new Error(CONFIG_ERROR_MSG);
|
2535 |
+
}
|
2536 |
+
const headers = {};
|
2537 |
+
const { hf_token } = this.options;
|
2538 |
+
const { session_hash } = this;
|
2539 |
+
if (hf_token) {
|
2540 |
+
headers.Authorization = `Bearer ${this.options.hf_token}`;
|
2541 |
+
}
|
2542 |
+
let root_url;
|
2543 |
+
let component = this.config.components.find(
|
2544 |
+
(comp) => comp.id === component_id
|
2545 |
+
);
|
2546 |
+
if ((_a = component == null ? void 0 : component.props) == null ? void 0 : _a.root_url) {
|
2547 |
+
root_url = component.props.root_url;
|
2548 |
+
} else {
|
2549 |
+
root_url = this.config.root;
|
2550 |
+
}
|
2551 |
+
let body;
|
2552 |
+
if ("binary" in data) {
|
2553 |
+
body = new FormData();
|
2554 |
+
for (const key in data.data) {
|
2555 |
+
if (key === "binary")
|
2556 |
+
continue;
|
2557 |
+
body.append(key, data.data[key]);
|
2558 |
+
}
|
2559 |
+
body.set("component_id", component_id.toString());
|
2560 |
+
body.set("fn_name", fn_name);
|
2561 |
+
body.set("session_hash", session_hash);
|
2562 |
+
} else {
|
2563 |
+
body = JSON.stringify({
|
2564 |
+
data,
|
2565 |
+
component_id,
|
2566 |
+
fn_name,
|
2567 |
+
session_hash
|
2568 |
+
});
|
2569 |
+
headers["Content-Type"] = "application/json";
|
2570 |
+
}
|
2571 |
+
if (hf_token) {
|
2572 |
+
headers.Authorization = `Bearer ${hf_token}`;
|
2573 |
+
}
|
2574 |
+
try {
|
2575 |
+
const response = await this.fetch(
|
2576 |
+
`${root_url}${this.api_prefix}/${COMPONENT_SERVER_URL}/`,
|
2577 |
+
{
|
2578 |
+
method: "POST",
|
2579 |
+
body,
|
2580 |
+
headers,
|
2581 |
+
credentials: "include"
|
2582 |
+
}
|
2583 |
+
);
|
2584 |
+
if (!response.ok) {
|
2585 |
+
throw new Error(
|
2586 |
+
"Could not connect to component server: " + response.statusText
|
2587 |
+
);
|
2588 |
+
}
|
2589 |
+
const output = await response.json();
|
2590 |
+
return output;
|
2591 |
+
} catch (e) {
|
2592 |
+
console.warn(e);
|
2593 |
+
}
|
2594 |
+
}
|
2595 |
+
set_cookies(raw_cookies) {
|
2596 |
+
this.cookies = parse_and_set_cookies(raw_cookies).join("; ");
|
2597 |
+
}
|
2598 |
+
prepare_return_obj() {
|
2599 |
+
return {
|
2600 |
+
config: this.config,
|
2601 |
+
predict: this.predict,
|
2602 |
+
submit: this.submit,
|
2603 |
+
view_api: this.view_api,
|
2604 |
+
component_server: this.component_server
|
2605 |
+
};
|
2606 |
+
}
|
2607 |
+
async connect_ws(url) {
|
2608 |
+
return new Promise((resolve, reject) => {
|
2609 |
+
let ws;
|
2610 |
+
try {
|
2611 |
+
ws = new WebSocket(url);
|
2612 |
+
} catch (e) {
|
2613 |
+
this.ws_map[url] = "failed";
|
2614 |
+
return;
|
2615 |
+
}
|
2616 |
+
ws.onopen = () => {
|
2617 |
+
resolve();
|
2618 |
+
};
|
2619 |
+
ws.onerror = (error) => {
|
2620 |
+
console.error("WebSocket error:", error);
|
2621 |
+
this.close_ws(url);
|
2622 |
+
this.ws_map[url] = "failed";
|
2623 |
+
resolve();
|
2624 |
+
};
|
2625 |
+
ws.onclose = () => {
|
2626 |
+
delete this.ws_map[url];
|
2627 |
+
this.ws_map[url] = "failed";
|
2628 |
+
};
|
2629 |
+
ws.onmessage = (event) => {
|
2630 |
+
};
|
2631 |
+
this.ws_map[url] = ws;
|
2632 |
+
});
|
2633 |
+
}
|
2634 |
+
async send_ws_message(url, data) {
|
2635 |
+
if (!(url in this.ws_map)) {
|
2636 |
+
await this.connect_ws(url);
|
2637 |
+
}
|
2638 |
+
const ws = this.ws_map[url];
|
2639 |
+
if (ws instanceof WebSocket) {
|
2640 |
+
ws.send(JSON.stringify(data));
|
2641 |
+
} else {
|
2642 |
+
this.post_data(url, data);
|
2643 |
+
}
|
2644 |
+
}
|
2645 |
+
async close_ws(url) {
|
2646 |
+
if (url in this.ws_map) {
|
2647 |
+
const ws = this.ws_map[url];
|
2648 |
+
if (ws instanceof WebSocket) {
|
2649 |
+
ws.close();
|
2650 |
+
delete this.ws_map[url];
|
2651 |
+
}
|
2652 |
+
}
|
2653 |
+
}
|
2654 |
+
}
|
2655 |
+
async function client(app_reference, options = {
|
2656 |
+
events: ["data"]
|
2657 |
+
}) {
|
2658 |
+
return await Client.connect(app_reference, options);
|
2659 |
+
}
|
2660 |
+
async function duplicate_space(app_reference, options) {
|
2661 |
+
return await Client.duplicate(app_reference, options);
|
2662 |
+
}
|
2663 |
+
export {
|
2664 |
+
Client,
|
2665 |
+
FileData,
|
2666 |
+
client,
|
2667 |
+
duplicate_space as duplicate,
|
2668 |
+
handle_file,
|
2669 |
+
predict,
|
2670 |
+
prepare_files,
|
2671 |
+
submit,
|
2672 |
+
upload,
|
2673 |
+
upload_files
|
2674 |
+
};
|
node_modules/@gradio/client/dist/test/handlers.d.ts
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { RequestHandler } from "msw";
|
2 |
+
export declare const direct_space_url = "https://hmb-hello-world.hf.space";
|
3 |
+
export declare const handlers: RequestHandler[];
|
4 |
+
//# sourceMappingURL=handlers.d.ts.map
|
node_modules/@gradio/client/dist/test/handlers.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/test/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,cAAc,EAAE,MAAM,KAAK,CAAC;AAuBzD,eAAO,MAAM,gBAAgB,qCAAqC,CAAC;AAqBnE,eAAO,MAAM,QAAQ,EAAE,cAAc,EAwoBpC,CAAC"}
|
node_modules/@gradio/client/dist/test/mock_eventsource.d.ts
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
export {};
|
2 |
+
//# sourceMappingURL=mock_eventsource.d.ts.map
|
node_modules/@gradio/client/dist/test/mock_eventsource.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"mock_eventsource.d.ts","sourceRoot":"","sources":["../../src/test/mock_eventsource.ts"],"names":[],"mappings":""}
|
node_modules/@gradio/client/dist/test/server.d.ts
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
export declare function initialise_server(): any;
|
2 |
+
//# sourceMappingURL=server.d.ts.map
|
node_modules/@gradio/client/dist/test/server.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/test/server.ts"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB,IAAI,GAAG,CAEvC"}
|
node_modules/@gradio/client/dist/test/test_data.d.ts
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { ApiData, ApiInfo, Config, EndpointInfo } from "../types";
|
2 |
+
export declare const runtime_response: {
|
3 |
+
stage: string;
|
4 |
+
hardware: {
|
5 |
+
current: string;
|
6 |
+
requested: string;
|
7 |
+
};
|
8 |
+
storage: {
|
9 |
+
current: null;
|
10 |
+
requested: null;
|
11 |
+
};
|
12 |
+
gcTimeout: number;
|
13 |
+
replicas: {
|
14 |
+
current: number;
|
15 |
+
requested: number;
|
16 |
+
};
|
17 |
+
devMode: boolean;
|
18 |
+
domains: {
|
19 |
+
domain: string;
|
20 |
+
isCustom: boolean;
|
21 |
+
stage: string;
|
22 |
+
}[];
|
23 |
+
};
|
24 |
+
export declare const transformed_api_info: ApiInfo<ApiData>;
|
25 |
+
export declare const response_api_info: ApiInfo<ApiData>;
|
26 |
+
export declare const config_response: Config;
|
27 |
+
export declare const whoami_response: {
|
28 |
+
type: string;
|
29 |
+
id: string;
|
30 |
+
name: string;
|
31 |
+
fullname: string;
|
32 |
+
email: string;
|
33 |
+
emailVerified: boolean;
|
34 |
+
canPay: boolean;
|
35 |
+
periodEnd: number;
|
36 |
+
isPro: boolean;
|
37 |
+
avatarUrl: string;
|
38 |
+
orgs: never[];
|
39 |
+
auth: {
|
40 |
+
type: string;
|
41 |
+
accessToken: {
|
42 |
+
displayName: string;
|
43 |
+
role: string;
|
44 |
+
};
|
45 |
+
};
|
46 |
+
};
|
47 |
+
export declare const duplicate_response: {
|
48 |
+
url: string;
|
49 |
+
};
|
50 |
+
export declare const hardware_sleeptime_response: {
|
51 |
+
stage: string;
|
52 |
+
hardware: {
|
53 |
+
current: string;
|
54 |
+
requested: string;
|
55 |
+
};
|
56 |
+
storage: null;
|
57 |
+
gcTimeout: number;
|
58 |
+
replicas: {
|
59 |
+
current: number;
|
60 |
+
requested: number;
|
61 |
+
};
|
62 |
+
devMode: boolean;
|
63 |
+
domains: {
|
64 |
+
domain: string;
|
65 |
+
isCustom: boolean;
|
66 |
+
stage: string;
|
67 |
+
}[];
|
68 |
+
};
|
69 |
+
export declare const endpoint_info: EndpointInfo<ApiData>;
|
70 |
+
export declare const discussions_response: {
|
71 |
+
discussions: never[];
|
72 |
+
count: number;
|
73 |
+
start: number;
|
74 |
+
numClosedDiscussions: number;
|
75 |
+
};
|
76 |
+
//# sourceMappingURL=test_data.d.ts.map
|
node_modules/@gradio/client/dist/test/test_data.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"test_data.d.ts","sourceRoot":"","sources":["../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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/// <reference types="node" />
|
2 |
+
import { hardware_types } from "./helpers/spaces";
|
3 |
+
import type { SvelteComponent } from "svelte";
|
4 |
+
import type { ComponentType } from "svelte";
|
5 |
+
export interface ApiData {
|
6 |
+
label: string;
|
7 |
+
parameter_name: string;
|
8 |
+
parameter_default?: any;
|
9 |
+
parameter_has_default?: boolean;
|
10 |
+
type: {
|
11 |
+
type: any;
|
12 |
+
description: string;
|
13 |
+
};
|
14 |
+
component: string;
|
15 |
+
example_input?: any;
|
16 |
+
python_type: {
|
17 |
+
type: string;
|
18 |
+
description: string;
|
19 |
+
};
|
20 |
+
serializer: string;
|
21 |
+
}
|
22 |
+
export interface JsApiData {
|
23 |
+
label: string;
|
24 |
+
parameter_name: string;
|
25 |
+
parameter_default?: any;
|
26 |
+
parameter_has_default?: boolean;
|
27 |
+
type: string;
|
28 |
+
description: string;
|
29 |
+
component: string;
|
30 |
+
example_input?: any;
|
31 |
+
serializer: string;
|
32 |
+
python_type: {
|
33 |
+
type: string;
|
34 |
+
description: string;
|
35 |
+
};
|
36 |
+
}
|
37 |
+
export interface EndpointInfo<T extends ApiData | JsApiData> {
|
38 |
+
parameters: T[];
|
39 |
+
returns: T[];
|
40 |
+
type?: DependencyTypes;
|
41 |
+
}
|
42 |
+
export interface ApiInfo<T extends ApiData | JsApiData> {
|
43 |
+
named_endpoints: Record<string, EndpointInfo<T>>;
|
44 |
+
unnamed_endpoints: Record<string, EndpointInfo<T>>;
|
45 |
+
}
|
46 |
+
export interface BlobRef {
|
47 |
+
path: string[];
|
48 |
+
type: string | undefined;
|
49 |
+
blob: Blob | File | false;
|
50 |
+
}
|
51 |
+
export type DataType = string | Buffer | Record<string, any> | any[];
|
52 |
+
export declare class Command {
|
53 |
+
type: string;
|
54 |
+
command: string;
|
55 |
+
meta: {
|
56 |
+
path: string;
|
57 |
+
name: string;
|
58 |
+
orig_path: string;
|
59 |
+
};
|
60 |
+
fileData?: FileData;
|
61 |
+
constructor(command: string, meta: {
|
62 |
+
path: string;
|
63 |
+
name: string;
|
64 |
+
orig_path: string;
|
65 |
+
});
|
66 |
+
}
|
67 |
+
export type SubmitFunction = (endpoint: string | number, data?: unknown[] | Record<string, unknown>, event_data?: unknown, trigger_id?: number | null) => SubmitIterable<GradioEvent>;
|
68 |
+
export type PredictFunction = (endpoint: string | number, data?: unknown[] | Record<string, unknown>, event_data?: unknown) => Promise<PredictReturn>;
|
69 |
+
export type client_return = {
|
70 |
+
config: Config | undefined;
|
71 |
+
predict: PredictFunction;
|
72 |
+
submit: SubmitFunction;
|
73 |
+
component_server: (component_id: number, fn_name: string, data: unknown[]) => any;
|
74 |
+
view_api: (_fetch: typeof fetch) => Promise<ApiInfo<JsApiData>>;
|
75 |
+
};
|
76 |
+
export interface SubmitIterable<T> extends AsyncIterable<T> {
|
77 |
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
78 |
+
cancel: () => Promise<void>;
|
79 |
+
event_id: () => string;
|
80 |
+
}
|
81 |
+
export type PredictReturn = {
|
82 |
+
type: EventType;
|
83 |
+
time: Date;
|
84 |
+
data: unknown;
|
85 |
+
endpoint: string;
|
86 |
+
fn_index: number;
|
87 |
+
};
|
88 |
+
export type SpaceStatus = SpaceStatusNormal | SpaceStatusError;
|
89 |
+
export interface SpaceStatusNormal {
|
90 |
+
status: "sleeping" | "running" | "building" | "error" | "stopped" | "starting";
|
91 |
+
detail: "SLEEPING" | "RUNNING" | "RUNNING_BUILDING" | "BUILDING" | "APP_STARTING" | "NOT_FOUND";
|
92 |
+
load_status: "pending" | "error" | "complete" | "generating";
|
93 |
+
message: string;
|
94 |
+
}
|
95 |
+
export interface SpaceStatusError {
|
96 |
+
status: "space_error" | "paused";
|
97 |
+
detail: "NO_APP_FILE" | "CONFIG_ERROR" | "BUILD_ERROR" | "RUNTIME_ERROR" | "PAUSED";
|
98 |
+
load_status: "error";
|
99 |
+
message: string;
|
100 |
+
discussions_enabled: boolean;
|
101 |
+
}
|
102 |
+
export type SpaceStatusCallback = (a: SpaceStatus) => void;
|
103 |
+
export interface Config {
|
104 |
+
deep_link_state?: "none" | "valid" | "invalid";
|
105 |
+
auth_required?: true;
|
106 |
+
analytics_enabled: boolean;
|
107 |
+
connect_heartbeat: boolean;
|
108 |
+
auth_message: string;
|
109 |
+
components: ComponentMeta[];
|
110 |
+
css: string | null;
|
111 |
+
js: string | null;
|
112 |
+
head: string | null;
|
113 |
+
dependencies: Dependency[];
|
114 |
+
dev_mode: boolean;
|
115 |
+
enable_queue: boolean;
|
116 |
+
show_error: boolean;
|
117 |
+
layout: any;
|
118 |
+
mode: "blocks" | "interface";
|
119 |
+
root: string;
|
120 |
+
root_url?: string;
|
121 |
+
theme: string;
|
122 |
+
title: string;
|
123 |
+
version: string;
|
124 |
+
space_id: string | null;
|
125 |
+
is_space: boolean;
|
126 |
+
is_colab: boolean;
|
127 |
+
show_api: boolean;
|
128 |
+
stylesheets: string[];
|
129 |
+
path: string;
|
130 |
+
current_page: string;
|
131 |
+
page: Record<string, {
|
132 |
+
components: number[];
|
133 |
+
dependencies: number[];
|
134 |
+
layout: any;
|
135 |
+
}>;
|
136 |
+
pages: [string, string][];
|
137 |
+
protocol: "sse_v3" | "sse_v2.1" | "sse_v2" | "sse_v1" | "sse" | "ws";
|
138 |
+
max_file_size?: number;
|
139 |
+
theme_hash?: number;
|
140 |
+
username: string | null;
|
141 |
+
api_prefix?: string;
|
142 |
+
fill_height?: boolean;
|
143 |
+
fill_width?: boolean;
|
144 |
+
pwa?: boolean;
|
145 |
+
}
|
146 |
+
export interface ComponentMeta {
|
147 |
+
type: string;
|
148 |
+
id: number;
|
149 |
+
has_modes: boolean;
|
150 |
+
props: SharedProps;
|
151 |
+
instance: SvelteComponent;
|
152 |
+
component: ComponentType<SvelteComponent>;
|
153 |
+
documentation?: Documentation;
|
154 |
+
children?: ComponentMeta[];
|
155 |
+
parent?: ComponentMeta;
|
156 |
+
value?: any;
|
157 |
+
component_class_id: string;
|
158 |
+
key: string | number | null;
|
159 |
+
rendered_in?: number;
|
160 |
+
}
|
161 |
+
interface SharedProps {
|
162 |
+
elem_id?: string;
|
163 |
+
elem_classes?: string[];
|
164 |
+
components?: string[];
|
165 |
+
server_fns?: string[];
|
166 |
+
interactive: boolean;
|
167 |
+
[key: string]: unknown;
|
168 |
+
root_url?: string;
|
169 |
+
}
|
170 |
+
export interface Documentation {
|
171 |
+
type?: TypeDescription;
|
172 |
+
description?: TypeDescription;
|
173 |
+
example_data?: string;
|
174 |
+
}
|
175 |
+
interface TypeDescription {
|
176 |
+
input_payload?: string;
|
177 |
+
response_object?: string;
|
178 |
+
payload?: string;
|
179 |
+
}
|
180 |
+
export interface Dependency {
|
181 |
+
id: number;
|
182 |
+
targets: [number, string][];
|
183 |
+
inputs: number[];
|
184 |
+
outputs: number[];
|
185 |
+
backend_fn: boolean;
|
186 |
+
js: string | null;
|
187 |
+
scroll_to_output: boolean;
|
188 |
+
trigger: "click" | "load" | string;
|
189 |
+
max_batch_size: number;
|
190 |
+
show_progress: "full" | "minimal" | "hidden";
|
191 |
+
show_progress_on: number[] | null;
|
192 |
+
frontend_fn: ((...args: unknown[]) => Promise<unknown[]>) | null;
|
193 |
+
status?: string;
|
194 |
+
queue: boolean | null;
|
195 |
+
every: number | null;
|
196 |
+
batch: boolean;
|
197 |
+
api_name: string | null;
|
198 |
+
cancels: number[];
|
199 |
+
types: DependencyTypes;
|
200 |
+
collects_event_data: boolean;
|
201 |
+
pending_request?: boolean;
|
202 |
+
trigger_after?: number;
|
203 |
+
trigger_only_on_success?: boolean;
|
204 |
+
trigger_mode: "once" | "multiple" | "always_last";
|
205 |
+
final_event: Payload | null;
|
206 |
+
show_api: boolean;
|
207 |
+
rendered_in: number | null;
|
208 |
+
render_id: number | null;
|
209 |
+
connection: "stream" | "sse";
|
210 |
+
time_limit: number;
|
211 |
+
stream_every: number;
|
212 |
+
like_user_message: boolean;
|
213 |
+
event_specific_args: string[];
|
214 |
+
js_implementation: string | null;
|
215 |
+
}
|
216 |
+
export interface DependencyTypes {
|
217 |
+
generator: boolean;
|
218 |
+
cancel: boolean;
|
219 |
+
}
|
220 |
+
export interface Payload {
|
221 |
+
fn_index: number;
|
222 |
+
data: unknown[];
|
223 |
+
time?: Date;
|
224 |
+
event_data?: unknown;
|
225 |
+
trigger_id?: number | null;
|
226 |
+
}
|
227 |
+
export interface PostResponse {
|
228 |
+
error?: string;
|
229 |
+
[x: string]: any;
|
230 |
+
}
|
231 |
+
export interface UploadResponse {
|
232 |
+
error?: string;
|
233 |
+
files?: string[];
|
234 |
+
}
|
235 |
+
export interface DuplicateOptions extends ClientOptions {
|
236 |
+
private?: boolean;
|
237 |
+
hardware?: (typeof hardware_types)[number];
|
238 |
+
timeout?: number;
|
239 |
+
}
|
240 |
+
export interface ClientOptions {
|
241 |
+
hf_token?: `hf_${string}`;
|
242 |
+
status_callback?: SpaceStatusCallback | null;
|
243 |
+
auth?: [string, string] | null;
|
244 |
+
with_null_state?: boolean;
|
245 |
+
events?: EventType[];
|
246 |
+
headers?: Record<string, string>;
|
247 |
+
query_params?: Record<string, string>;
|
248 |
+
}
|
249 |
+
export interface FileData {
|
250 |
+
name: string;
|
251 |
+
orig_name?: string;
|
252 |
+
size?: number;
|
253 |
+
data: string;
|
254 |
+
blob?: File;
|
255 |
+
is_file?: boolean;
|
256 |
+
mime_type?: string;
|
257 |
+
alt_text?: string;
|
258 |
+
}
|
259 |
+
export type EventType = "data" | "status" | "log" | "render";
|
260 |
+
export interface EventMap {
|
261 |
+
data: PayloadMessage;
|
262 |
+
status: StatusMessage;
|
263 |
+
log: LogMessage;
|
264 |
+
render: RenderMessage;
|
265 |
+
}
|
266 |
+
export type GradioEvent = {
|
267 |
+
[P in EventType]: EventMap[P];
|
268 |
+
}[EventType];
|
269 |
+
export interface Log {
|
270 |
+
log: string;
|
271 |
+
title: string;
|
272 |
+
level: "warning" | "info" | "success";
|
273 |
+
}
|
274 |
+
export interface Render {
|
275 |
+
data: {
|
276 |
+
components: any[];
|
277 |
+
layout: any;
|
278 |
+
dependencies: Dependency[];
|
279 |
+
render_id: number;
|
280 |
+
};
|
281 |
+
}
|
282 |
+
export interface Status {
|
283 |
+
queue: boolean;
|
284 |
+
code?: string;
|
285 |
+
success?: boolean;
|
286 |
+
stage: "pending" | "error" | "complete" | "generating" | "streaming";
|
287 |
+
duration?: number;
|
288 |
+
visible?: boolean;
|
289 |
+
broken?: boolean;
|
290 |
+
size?: number;
|
291 |
+
position?: number;
|
292 |
+
eta?: number;
|
293 |
+
title?: string;
|
294 |
+
message?: string;
|
295 |
+
progress_data?: {
|
296 |
+
progress: number | null;
|
297 |
+
index: number | null;
|
298 |
+
length: number | null;
|
299 |
+
unit: string | null;
|
300 |
+
desc: string | null;
|
301 |
+
}[];
|
302 |
+
time?: Date;
|
303 |
+
changed_state_ids?: number[];
|
304 |
+
time_limit?: number;
|
305 |
+
}
|
306 |
+
export interface StatusMessage extends Status {
|
307 |
+
type: "status";
|
308 |
+
endpoint: string;
|
309 |
+
fn_index: number;
|
310 |
+
original_msg?: string;
|
311 |
+
}
|
312 |
+
export interface PayloadMessage extends Payload {
|
313 |
+
type: "data";
|
314 |
+
endpoint: string;
|
315 |
+
fn_index: number;
|
316 |
+
}
|
317 |
+
export interface LogMessage extends Log {
|
318 |
+
type: "log";
|
319 |
+
endpoint: string;
|
320 |
+
fn_index: number;
|
321 |
+
duration: number | null;
|
322 |
+
visible: boolean;
|
323 |
+
}
|
324 |
+
export interface RenderMessage extends Render {
|
325 |
+
type: "render";
|
326 |
+
endpoint: string;
|
327 |
+
fn_index: number;
|
328 |
+
}
|
329 |
+
export {};
|
330 |
+
//# sourceMappingURL=types.d.ts.map
|
node_modules/@gradio/client/dist/types.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE5C,MAAM,WAAW,OAAO;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE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AAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAW,SAAQ,GAAG;IACtC,IAAI,EAAE,KAAK,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,aAAc,SAAQ,MAAM;IAC5C,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CACjB"}
|
node_modules/@gradio/client/dist/upload.d.ts
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { Client } from "./client";
|
2 |
+
export declare function upload(this: Client, file_data: FileData[], root_url: string, upload_id?: string, max_file_size?: number): Promise<(FileData | null)[] | null>;
|
3 |
+
export declare function prepare_files(files: File[], is_stream?: boolean): Promise<FileData[]>;
|
4 |
+
export declare class FileData {
|
5 |
+
path: string;
|
6 |
+
url?: string;
|
7 |
+
orig_name?: string;
|
8 |
+
size?: number;
|
9 |
+
blob?: File;
|
10 |
+
is_stream?: boolean;
|
11 |
+
mime_type?: string;
|
12 |
+
alt_text?: string;
|
13 |
+
b64?: string;
|
14 |
+
readonly meta: {
|
15 |
+
_type: string;
|
16 |
+
};
|
17 |
+
constructor({ path, url, orig_name, size, blob, is_stream, mime_type, alt_text, b64 }: {
|
18 |
+
path: string;
|
19 |
+
url?: string;
|
20 |
+
orig_name?: string;
|
21 |
+
size?: number;
|
22 |
+
blob?: File;
|
23 |
+
is_stream?: boolean;
|
24 |
+
mime_type?: string;
|
25 |
+
alt_text?: string;
|
26 |
+
b64?: string;
|
27 |
+
});
|
28 |
+
}
|
29 |
+
//# sourceMappingURL=upload.d.ts.map
|
node_modules/@gradio/client/dist/upload.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,wBAAsB,MAAM,CAC3B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,QAAQ,EAAE,EACrB,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,EAClB,aAAa,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,CAsCrC;AAED,wBAAsB,aAAa,CAClC,KAAK,EAAE,IAAI,EAAE,EACb,SAAS,CAAC,EAAE,OAAO,GACjB,OAAO,CAAC,QAAQ,EAAE,CAAC,CAYrB;AAED,qBAAa,QAAQ;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,IAAI;;MAAgC;gBAEjC,EACX,IAAI,EACJ,GAAG,EACH,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,SAAS,EACT,QAAQ,EACR,GAAG,EACH,EAAE;QACF,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC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