Upload folder using huggingface_hub
Browse files- 6.29.1/client/package-lock.json +2093 -0
- 6.29.1/client/package.json +53 -0
- 6.29.1/client/src/client.ts +625 -0
- 6.29.1/client/src/constants.ts +51 -0
- 6.29.1/client/src/globals.d.ts +13 -0
- 6.29.1/client/src/helpers/api_info.ts +506 -0
- 6.29.1/client/src/helpers/data.ts +303 -0
- 6.29.1/client/src/helpers/init_helpers.ts +312 -0
- 6.29.1/client/src/helpers/spaces.ts +252 -0
- 6.29.1/client/src/helpers/zerogpu.ts +40 -0
- 6.29.1/client/src/index.ts +52 -0
- 6.29.1/client/src/test/handlers.ts +687 -0
- 6.29.1/client/src/test/mock_eventsource.ts +13 -0
- 6.29.1/client/src/test/server.ts +34 -0
- 6.29.1/client/src/test/test_data.ts +562 -0
- 6.29.1/client/src/types.ts +465 -0
- 6.29.1/client/src/upload.ts +113 -0
- 6.29.1/client/src/utils/bucket_sync.ts +153 -0
- 6.29.1/client/src/utils/duplicate.ts +130 -0
- 6.29.1/client/src/utils/filesize.ts +41 -0
- 6.29.1/client/src/utils/handle_blob.ts +142 -0
- 6.29.1/client/src/utils/post_data.ts +38 -0
- 6.29.1/client/src/utils/predict.ts +66 -0
- 6.29.1/client/src/utils/run_history.ts +652 -0
- 6.29.1/client/src/utils/stream.ts +244 -0
- 6.29.1/client/src/utils/submit.ts +880 -0
- 6.29.1/client/src/utils/upload_files.ts +52 -0
- 6.29.1/client/src/utils/view_api.ts +59 -0
- 6.29.1/client/src/vite-env.d.ts +3 -0
- 6.29.1/client/tsconfig.json +28 -0
- 6.29.1/client/vite.config.ts +120 -0
6.29.1/client/package-lock.json
ADDED
|
@@ -0,0 +1,2093 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/client",
|
| 3 |
+
"version": "1.19.1",
|
| 4 |
+
"lockfileVersion": 3,
|
| 5 |
+
"requires": true,
|
| 6 |
+
"packages": {
|
| 7 |
+
"": {
|
| 8 |
+
"name": "@gradio/client",
|
| 9 |
+
"version": "1.19.1",
|
| 10 |
+
"license": "ISC",
|
| 11 |
+
"dependencies": {
|
| 12 |
+
"@types/eventsource": "^1.1.15",
|
| 13 |
+
"bufferutil": "^4.0.7",
|
| 14 |
+
"eventsource": "^2.0.2",
|
| 15 |
+
"fetch-event-stream": "^0.1.5",
|
| 16 |
+
"msw": "^2.2.1",
|
| 17 |
+
"semiver": "^1.1.0",
|
| 18 |
+
"textlinestream": "^1.1.1",
|
| 19 |
+
"typescript": "^5.0.0",
|
| 20 |
+
"vi": "^1.0.0",
|
| 21 |
+
"vite": "^6.4.1",
|
| 22 |
+
"ws": "^8.13.0"
|
| 23 |
+
},
|
| 24 |
+
"devDependencies": {
|
| 25 |
+
"@types/ws": "^8.5.10",
|
| 26 |
+
"esbuild": "^0.21.0"
|
| 27 |
+
},
|
| 28 |
+
"engines": {
|
| 29 |
+
"node": ">=18.0.0"
|
| 30 |
+
}
|
| 31 |
+
},
|
| 32 |
+
"node_modules/@esbuild/aix-ppc64": {
|
| 33 |
+
"version": "0.21.5",
|
| 34 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz",
|
| 35 |
+
"integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==",
|
| 36 |
+
"cpu": [
|
| 37 |
+
"ppc64"
|
| 38 |
+
],
|
| 39 |
+
"dev": true,
|
| 40 |
+
"license": "MIT",
|
| 41 |
+
"optional": true,
|
| 42 |
+
"os": [
|
| 43 |
+
"aix"
|
| 44 |
+
],
|
| 45 |
+
"engines": {
|
| 46 |
+
"node": ">=12"
|
| 47 |
+
}
|
| 48 |
+
},
|
| 49 |
+
"node_modules/@esbuild/android-arm": {
|
| 50 |
+
"version": "0.21.5",
|
| 51 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/android-arm/-/android-arm-0.21.5.tgz",
|
| 52 |
+
"integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==",
|
| 53 |
+
"cpu": [
|
| 54 |
+
"arm"
|
| 55 |
+
],
|
| 56 |
+
"dev": true,
|
| 57 |
+
"license": "MIT",
|
| 58 |
+
"optional": true,
|
| 59 |
+
"os": [
|
| 60 |
+
"android"
|
| 61 |
+
],
|
| 62 |
+
"engines": {
|
| 63 |
+
"node": ">=12"
|
| 64 |
+
}
|
| 65 |
+
},
|
| 66 |
+
"node_modules/@esbuild/android-arm64": {
|
| 67 |
+
"version": "0.21.5",
|
| 68 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz",
|
| 69 |
+
"integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==",
|
| 70 |
+
"cpu": [
|
| 71 |
+
"arm64"
|
| 72 |
+
],
|
| 73 |
+
"dev": true,
|
| 74 |
+
"license": "MIT",
|
| 75 |
+
"optional": true,
|
| 76 |
+
"os": [
|
| 77 |
+
"android"
|
| 78 |
+
],
|
| 79 |
+
"engines": {
|
| 80 |
+
"node": ">=12"
|
| 81 |
+
}
|
| 82 |
+
},
|
| 83 |
+
"node_modules/@esbuild/android-x64": {
|
| 84 |
+
"version": "0.21.5",
|
| 85 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/android-x64/-/android-x64-0.21.5.tgz",
|
| 86 |
+
"integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==",
|
| 87 |
+
"cpu": [
|
| 88 |
+
"x64"
|
| 89 |
+
],
|
| 90 |
+
"dev": true,
|
| 91 |
+
"license": "MIT",
|
| 92 |
+
"optional": true,
|
| 93 |
+
"os": [
|
| 94 |
+
"android"
|
| 95 |
+
],
|
| 96 |
+
"engines": {
|
| 97 |
+
"node": ">=12"
|
| 98 |
+
}
|
| 99 |
+
},
|
| 100 |
+
"node_modules/@esbuild/darwin-arm64": {
|
| 101 |
+
"version": "0.21.5",
|
| 102 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz",
|
| 103 |
+
"integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==",
|
| 104 |
+
"cpu": [
|
| 105 |
+
"arm64"
|
| 106 |
+
],
|
| 107 |
+
"dev": true,
|
| 108 |
+
"license": "MIT",
|
| 109 |
+
"optional": true,
|
| 110 |
+
"os": [
|
| 111 |
+
"darwin"
|
| 112 |
+
],
|
| 113 |
+
"engines": {
|
| 114 |
+
"node": ">=12"
|
| 115 |
+
}
|
| 116 |
+
},
|
| 117 |
+
"node_modules/@esbuild/darwin-x64": {
|
| 118 |
+
"version": "0.21.5",
|
| 119 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz",
|
| 120 |
+
"integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==",
|
| 121 |
+
"cpu": [
|
| 122 |
+
"x64"
|
| 123 |
+
],
|
| 124 |
+
"dev": true,
|
| 125 |
+
"license": "MIT",
|
| 126 |
+
"optional": true,
|
| 127 |
+
"os": [
|
| 128 |
+
"darwin"
|
| 129 |
+
],
|
| 130 |
+
"engines": {
|
| 131 |
+
"node": ">=12"
|
| 132 |
+
}
|
| 133 |
+
},
|
| 134 |
+
"node_modules/@esbuild/freebsd-arm64": {
|
| 135 |
+
"version": "0.21.5",
|
| 136 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz",
|
| 137 |
+
"integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==",
|
| 138 |
+
"cpu": [
|
| 139 |
+
"arm64"
|
| 140 |
+
],
|
| 141 |
+
"dev": true,
|
| 142 |
+
"license": "MIT",
|
| 143 |
+
"optional": true,
|
| 144 |
+
"os": [
|
| 145 |
+
"freebsd"
|
| 146 |
+
],
|
| 147 |
+
"engines": {
|
| 148 |
+
"node": ">=12"
|
| 149 |
+
}
|
| 150 |
+
},
|
| 151 |
+
"node_modules/@esbuild/freebsd-x64": {
|
| 152 |
+
"version": "0.21.5",
|
| 153 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz",
|
| 154 |
+
"integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==",
|
| 155 |
+
"cpu": [
|
| 156 |
+
"x64"
|
| 157 |
+
],
|
| 158 |
+
"dev": true,
|
| 159 |
+
"license": "MIT",
|
| 160 |
+
"optional": true,
|
| 161 |
+
"os": [
|
| 162 |
+
"freebsd"
|
| 163 |
+
],
|
| 164 |
+
"engines": {
|
| 165 |
+
"node": ">=12"
|
| 166 |
+
}
|
| 167 |
+
},
|
| 168 |
+
"node_modules/@esbuild/linux-arm": {
|
| 169 |
+
"version": "0.21.5",
|
| 170 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz",
|
| 171 |
+
"integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==",
|
| 172 |
+
"cpu": [
|
| 173 |
+
"arm"
|
| 174 |
+
],
|
| 175 |
+
"dev": true,
|
| 176 |
+
"license": "MIT",
|
| 177 |
+
"optional": true,
|
| 178 |
+
"os": [
|
| 179 |
+
"linux"
|
| 180 |
+
],
|
| 181 |
+
"engines": {
|
| 182 |
+
"node": ">=12"
|
| 183 |
+
}
|
| 184 |
+
},
|
| 185 |
+
"node_modules/@esbuild/linux-arm64": {
|
| 186 |
+
"version": "0.21.5",
|
| 187 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz",
|
| 188 |
+
"integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==",
|
| 189 |
+
"cpu": [
|
| 190 |
+
"arm64"
|
| 191 |
+
],
|
| 192 |
+
"dev": true,
|
| 193 |
+
"license": "MIT",
|
| 194 |
+
"optional": true,
|
| 195 |
+
"os": [
|
| 196 |
+
"linux"
|
| 197 |
+
],
|
| 198 |
+
"engines": {
|
| 199 |
+
"node": ">=12"
|
| 200 |
+
}
|
| 201 |
+
},
|
| 202 |
+
"node_modules/@esbuild/linux-ia32": {
|
| 203 |
+
"version": "0.21.5",
|
| 204 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz",
|
| 205 |
+
"integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==",
|
| 206 |
+
"cpu": [
|
| 207 |
+
"ia32"
|
| 208 |
+
],
|
| 209 |
+
"dev": true,
|
| 210 |
+
"license": "MIT",
|
| 211 |
+
"optional": true,
|
| 212 |
+
"os": [
|
| 213 |
+
"linux"
|
| 214 |
+
],
|
| 215 |
+
"engines": {
|
| 216 |
+
"node": ">=12"
|
| 217 |
+
}
|
| 218 |
+
},
|
| 219 |
+
"node_modules/@esbuild/linux-loong64": {
|
| 220 |
+
"version": "0.21.5",
|
| 221 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz",
|
| 222 |
+
"integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==",
|
| 223 |
+
"cpu": [
|
| 224 |
+
"loong64"
|
| 225 |
+
],
|
| 226 |
+
"dev": true,
|
| 227 |
+
"license": "MIT",
|
| 228 |
+
"optional": true,
|
| 229 |
+
"os": [
|
| 230 |
+
"linux"
|
| 231 |
+
],
|
| 232 |
+
"engines": {
|
| 233 |
+
"node": ">=12"
|
| 234 |
+
}
|
| 235 |
+
},
|
| 236 |
+
"node_modules/@esbuild/linux-mips64el": {
|
| 237 |
+
"version": "0.21.5",
|
| 238 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz",
|
| 239 |
+
"integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==",
|
| 240 |
+
"cpu": [
|
| 241 |
+
"mips64el"
|
| 242 |
+
],
|
| 243 |
+
"dev": true,
|
| 244 |
+
"license": "MIT",
|
| 245 |
+
"optional": true,
|
| 246 |
+
"os": [
|
| 247 |
+
"linux"
|
| 248 |
+
],
|
| 249 |
+
"engines": {
|
| 250 |
+
"node": ">=12"
|
| 251 |
+
}
|
| 252 |
+
},
|
| 253 |
+
"node_modules/@esbuild/linux-ppc64": {
|
| 254 |
+
"version": "0.21.5",
|
| 255 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz",
|
| 256 |
+
"integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==",
|
| 257 |
+
"cpu": [
|
| 258 |
+
"ppc64"
|
| 259 |
+
],
|
| 260 |
+
"dev": true,
|
| 261 |
+
"license": "MIT",
|
| 262 |
+
"optional": true,
|
| 263 |
+
"os": [
|
| 264 |
+
"linux"
|
| 265 |
+
],
|
| 266 |
+
"engines": {
|
| 267 |
+
"node": ">=12"
|
| 268 |
+
}
|
| 269 |
+
},
|
| 270 |
+
"node_modules/@esbuild/linux-riscv64": {
|
| 271 |
+
"version": "0.21.5",
|
| 272 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz",
|
| 273 |
+
"integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==",
|
| 274 |
+
"cpu": [
|
| 275 |
+
"riscv64"
|
| 276 |
+
],
|
| 277 |
+
"dev": true,
|
| 278 |
+
"license": "MIT",
|
| 279 |
+
"optional": true,
|
| 280 |
+
"os": [
|
| 281 |
+
"linux"
|
| 282 |
+
],
|
| 283 |
+
"engines": {
|
| 284 |
+
"node": ">=12"
|
| 285 |
+
}
|
| 286 |
+
},
|
| 287 |
+
"node_modules/@esbuild/linux-s390x": {
|
| 288 |
+
"version": "0.21.5",
|
| 289 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz",
|
| 290 |
+
"integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==",
|
| 291 |
+
"cpu": [
|
| 292 |
+
"s390x"
|
| 293 |
+
],
|
| 294 |
+
"dev": true,
|
| 295 |
+
"license": "MIT",
|
| 296 |
+
"optional": true,
|
| 297 |
+
"os": [
|
| 298 |
+
"linux"
|
| 299 |
+
],
|
| 300 |
+
"engines": {
|
| 301 |
+
"node": ">=12"
|
| 302 |
+
}
|
| 303 |
+
},
|
| 304 |
+
"node_modules/@esbuild/linux-x64": {
|
| 305 |
+
"version": "0.21.5",
|
| 306 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz",
|
| 307 |
+
"integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==",
|
| 308 |
+
"cpu": [
|
| 309 |
+
"x64"
|
| 310 |
+
],
|
| 311 |
+
"dev": true,
|
| 312 |
+
"license": "MIT",
|
| 313 |
+
"optional": true,
|
| 314 |
+
"os": [
|
| 315 |
+
"linux"
|
| 316 |
+
],
|
| 317 |
+
"engines": {
|
| 318 |
+
"node": ">=12"
|
| 319 |
+
}
|
| 320 |
+
},
|
| 321 |
+
"node_modules/@esbuild/netbsd-arm64": {
|
| 322 |
+
"version": "0.25.11",
|
| 323 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.11.tgz",
|
| 324 |
+
"integrity": "sha512-hr9Oxj1Fa4r04dNpWr3P8QKVVsjQhqrMSUzZzf+LZcYjZNqhA3IAfPQdEh1FLVUJSiu6sgAwp3OmwBfbFgG2Xg==",
|
| 325 |
+
"cpu": [
|
| 326 |
+
"arm64"
|
| 327 |
+
],
|
| 328 |
+
"license": "MIT",
|
| 329 |
+
"optional": true,
|
| 330 |
+
"os": [
|
| 331 |
+
"netbsd"
|
| 332 |
+
],
|
| 333 |
+
"engines": {
|
| 334 |
+
"node": ">=18"
|
| 335 |
+
}
|
| 336 |
+
},
|
| 337 |
+
"node_modules/@esbuild/netbsd-x64": {
|
| 338 |
+
"version": "0.21.5",
|
| 339 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz",
|
| 340 |
+
"integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==",
|
| 341 |
+
"cpu": [
|
| 342 |
+
"x64"
|
| 343 |
+
],
|
| 344 |
+
"dev": true,
|
| 345 |
+
"license": "MIT",
|
| 346 |
+
"optional": true,
|
| 347 |
+
"os": [
|
| 348 |
+
"netbsd"
|
| 349 |
+
],
|
| 350 |
+
"engines": {
|
| 351 |
+
"node": ">=12"
|
| 352 |
+
}
|
| 353 |
+
},
|
| 354 |
+
"node_modules/@esbuild/openbsd-arm64": {
|
| 355 |
+
"version": "0.25.11",
|
| 356 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.11.tgz",
|
| 357 |
+
"integrity": "sha512-Qq6YHhayieor3DxFOoYM1q0q1uMFYb7cSpLD2qzDSvK1NAvqFi8Xgivv0cFC6J+hWVw2teCYltyy9/m/14ryHg==",
|
| 358 |
+
"cpu": [
|
| 359 |
+
"arm64"
|
| 360 |
+
],
|
| 361 |
+
"license": "MIT",
|
| 362 |
+
"optional": true,
|
| 363 |
+
"os": [
|
| 364 |
+
"openbsd"
|
| 365 |
+
],
|
| 366 |
+
"engines": {
|
| 367 |
+
"node": ">=18"
|
| 368 |
+
}
|
| 369 |
+
},
|
| 370 |
+
"node_modules/@esbuild/openbsd-x64": {
|
| 371 |
+
"version": "0.21.5",
|
| 372 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz",
|
| 373 |
+
"integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==",
|
| 374 |
+
"cpu": [
|
| 375 |
+
"x64"
|
| 376 |
+
],
|
| 377 |
+
"dev": true,
|
| 378 |
+
"license": "MIT",
|
| 379 |
+
"optional": true,
|
| 380 |
+
"os": [
|
| 381 |
+
"openbsd"
|
| 382 |
+
],
|
| 383 |
+
"engines": {
|
| 384 |
+
"node": ">=12"
|
| 385 |
+
}
|
| 386 |
+
},
|
| 387 |
+
"node_modules/@esbuild/openharmony-arm64": {
|
| 388 |
+
"version": "0.25.11",
|
| 389 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.11.tgz",
|
| 390 |
+
"integrity": "sha512-rOREuNIQgaiR+9QuNkbkxubbp8MSO9rONmwP5nKncnWJ9v5jQ4JxFnLu4zDSRPf3x4u+2VN4pM4RdyIzDty/wQ==",
|
| 391 |
+
"cpu": [
|
| 392 |
+
"arm64"
|
| 393 |
+
],
|
| 394 |
+
"license": "MIT",
|
| 395 |
+
"optional": true,
|
| 396 |
+
"os": [
|
| 397 |
+
"openharmony"
|
| 398 |
+
],
|
| 399 |
+
"engines": {
|
| 400 |
+
"node": ">=18"
|
| 401 |
+
}
|
| 402 |
+
},
|
| 403 |
+
"node_modules/@esbuild/sunos-x64": {
|
| 404 |
+
"version": "0.21.5",
|
| 405 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz",
|
| 406 |
+
"integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==",
|
| 407 |
+
"cpu": [
|
| 408 |
+
"x64"
|
| 409 |
+
],
|
| 410 |
+
"dev": true,
|
| 411 |
+
"license": "MIT",
|
| 412 |
+
"optional": true,
|
| 413 |
+
"os": [
|
| 414 |
+
"sunos"
|
| 415 |
+
],
|
| 416 |
+
"engines": {
|
| 417 |
+
"node": ">=12"
|
| 418 |
+
}
|
| 419 |
+
},
|
| 420 |
+
"node_modules/@esbuild/win32-arm64": {
|
| 421 |
+
"version": "0.21.5",
|
| 422 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz",
|
| 423 |
+
"integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==",
|
| 424 |
+
"cpu": [
|
| 425 |
+
"arm64"
|
| 426 |
+
],
|
| 427 |
+
"dev": true,
|
| 428 |
+
"license": "MIT",
|
| 429 |
+
"optional": true,
|
| 430 |
+
"os": [
|
| 431 |
+
"win32"
|
| 432 |
+
],
|
| 433 |
+
"engines": {
|
| 434 |
+
"node": ">=12"
|
| 435 |
+
}
|
| 436 |
+
},
|
| 437 |
+
"node_modules/@esbuild/win32-ia32": {
|
| 438 |
+
"version": "0.21.5",
|
| 439 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz",
|
| 440 |
+
"integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==",
|
| 441 |
+
"cpu": [
|
| 442 |
+
"ia32"
|
| 443 |
+
],
|
| 444 |
+
"dev": true,
|
| 445 |
+
"license": "MIT",
|
| 446 |
+
"optional": true,
|
| 447 |
+
"os": [
|
| 448 |
+
"win32"
|
| 449 |
+
],
|
| 450 |
+
"engines": {
|
| 451 |
+
"node": ">=12"
|
| 452 |
+
}
|
| 453 |
+
},
|
| 454 |
+
"node_modules/@esbuild/win32-x64": {
|
| 455 |
+
"version": "0.21.5",
|
| 456 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz",
|
| 457 |
+
"integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==",
|
| 458 |
+
"cpu": [
|
| 459 |
+
"x64"
|
| 460 |
+
],
|
| 461 |
+
"dev": true,
|
| 462 |
+
"license": "MIT",
|
| 463 |
+
"optional": true,
|
| 464 |
+
"os": [
|
| 465 |
+
"win32"
|
| 466 |
+
],
|
| 467 |
+
"engines": {
|
| 468 |
+
"node": ">=12"
|
| 469 |
+
}
|
| 470 |
+
},
|
| 471 |
+
"node_modules/@inquirer/ansi": {
|
| 472 |
+
"version": "1.0.1",
|
| 473 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@inquirer/ansi/-/ansi-1.0.1.tgz",
|
| 474 |
+
"integrity": "sha512-yqq0aJW/5XPhi5xOAL1xRCpe1eh8UFVgYFpFsjEqmIR8rKLyP+HINvFXwUaxYICflJrVlxnp7lLN6As735kVpw==",
|
| 475 |
+
"license": "MIT",
|
| 476 |
+
"engines": {
|
| 477 |
+
"node": ">=18"
|
| 478 |
+
}
|
| 479 |
+
},
|
| 480 |
+
"node_modules/@inquirer/confirm": {
|
| 481 |
+
"version": "5.1.19",
|
| 482 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@inquirer/confirm/-/confirm-5.1.19.tgz",
|
| 483 |
+
"integrity": "sha512-wQNz9cfcxrtEnUyG5PndC8g3gZ7lGDBzmWiXZkX8ot3vfZ+/BLjR8EvyGX4YzQLeVqtAlY/YScZpW7CW8qMoDQ==",
|
| 484 |
+
"license": "MIT",
|
| 485 |
+
"dependencies": {
|
| 486 |
+
"@inquirer/core": "^10.3.0",
|
| 487 |
+
"@inquirer/type": "^3.0.9"
|
| 488 |
+
},
|
| 489 |
+
"engines": {
|
| 490 |
+
"node": ">=18"
|
| 491 |
+
},
|
| 492 |
+
"peerDependencies": {
|
| 493 |
+
"@types/node": ">=18"
|
| 494 |
+
},
|
| 495 |
+
"peerDependenciesMeta": {
|
| 496 |
+
"@types/node": {
|
| 497 |
+
"optional": true
|
| 498 |
+
}
|
| 499 |
+
}
|
| 500 |
+
},
|
| 501 |
+
"node_modules/@inquirer/core": {
|
| 502 |
+
"version": "10.3.0",
|
| 503 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@inquirer/core/-/core-10.3.0.tgz",
|
| 504 |
+
"integrity": "sha512-Uv2aPPPSK5jeCplQmQ9xadnFx2Zhj9b5Dj7bU6ZeCdDNNY11nhYy4btcSdtDguHqCT2h5oNeQTcUNSGGLA7NTA==",
|
| 505 |
+
"license": "MIT",
|
| 506 |
+
"dependencies": {
|
| 507 |
+
"@inquirer/ansi": "^1.0.1",
|
| 508 |
+
"@inquirer/figures": "^1.0.14",
|
| 509 |
+
"@inquirer/type": "^3.0.9",
|
| 510 |
+
"cli-width": "^4.1.0",
|
| 511 |
+
"mute-stream": "^2.0.0",
|
| 512 |
+
"signal-exit": "^4.1.0",
|
| 513 |
+
"wrap-ansi": "^6.2.0",
|
| 514 |
+
"yoctocolors-cjs": "^2.1.2"
|
| 515 |
+
},
|
| 516 |
+
"engines": {
|
| 517 |
+
"node": ">=18"
|
| 518 |
+
},
|
| 519 |
+
"peerDependencies": {
|
| 520 |
+
"@types/node": ">=18"
|
| 521 |
+
},
|
| 522 |
+
"peerDependenciesMeta": {
|
| 523 |
+
"@types/node": {
|
| 524 |
+
"optional": true
|
| 525 |
+
}
|
| 526 |
+
}
|
| 527 |
+
},
|
| 528 |
+
"node_modules/@inquirer/figures": {
|
| 529 |
+
"version": "1.0.14",
|
| 530 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@inquirer/figures/-/figures-1.0.14.tgz",
|
| 531 |
+
"integrity": "sha512-DbFgdt+9/OZYFM+19dbpXOSeAstPy884FPy1KjDu4anWwymZeOYhMY1mdFri172htv6mvc/uvIAAi7b7tvjJBQ==",
|
| 532 |
+
"license": "MIT",
|
| 533 |
+
"engines": {
|
| 534 |
+
"node": ">=18"
|
| 535 |
+
}
|
| 536 |
+
},
|
| 537 |
+
"node_modules/@inquirer/type": {
|
| 538 |
+
"version": "3.0.9",
|
| 539 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@inquirer/type/-/type-3.0.9.tgz",
|
| 540 |
+
"integrity": "sha512-QPaNt/nmE2bLGQa9b7wwyRJoLZ7pN6rcyXvzU0YCmivmJyq1BVo94G98tStRWkoD1RgDX5C+dPlhhHzNdu/W/w==",
|
| 541 |
+
"license": "MIT",
|
| 542 |
+
"engines": {
|
| 543 |
+
"node": ">=18"
|
| 544 |
+
},
|
| 545 |
+
"peerDependencies": {
|
| 546 |
+
"@types/node": ">=18"
|
| 547 |
+
},
|
| 548 |
+
"peerDependenciesMeta": {
|
| 549 |
+
"@types/node": {
|
| 550 |
+
"optional": true
|
| 551 |
+
}
|
| 552 |
+
}
|
| 553 |
+
},
|
| 554 |
+
"node_modules/@mswjs/interceptors": {
|
| 555 |
+
"version": "0.40.0",
|
| 556 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@mswjs/interceptors/-/interceptors-0.40.0.tgz",
|
| 557 |
+
"integrity": "sha512-EFd6cVbHsgLa6wa4RljGj6Wk75qoHxUSyc5asLyyPSyuhIcdS2Q3Phw6ImS1q+CkALthJRShiYfKANcQMuMqsQ==",
|
| 558 |
+
"license": "MIT",
|
| 559 |
+
"dependencies": {
|
| 560 |
+
"@open-draft/deferred-promise": "^2.2.0",
|
| 561 |
+
"@open-draft/logger": "^0.3.0",
|
| 562 |
+
"@open-draft/until": "^2.0.0",
|
| 563 |
+
"is-node-process": "^1.2.0",
|
| 564 |
+
"outvariant": "^1.4.3",
|
| 565 |
+
"strict-event-emitter": "^0.5.1"
|
| 566 |
+
},
|
| 567 |
+
"engines": {
|
| 568 |
+
"node": ">=18"
|
| 569 |
+
}
|
| 570 |
+
},
|
| 571 |
+
"node_modules/@open-draft/deferred-promise": {
|
| 572 |
+
"version": "2.2.0",
|
| 573 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@open-draft/deferred-promise/-/deferred-promise-2.2.0.tgz",
|
| 574 |
+
"integrity": "sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA==",
|
| 575 |
+
"license": "MIT"
|
| 576 |
+
},
|
| 577 |
+
"node_modules/@open-draft/logger": {
|
| 578 |
+
"version": "0.3.0",
|
| 579 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@open-draft/logger/-/logger-0.3.0.tgz",
|
| 580 |
+
"integrity": "sha512-X2g45fzhxH238HKO4xbSr7+wBS8Fvw6ixhTDuvLd5mqh6bJJCFAPwU9mPDxbcrRtfxv4u5IHCEH77BmxvXmmxQ==",
|
| 581 |
+
"license": "MIT",
|
| 582 |
+
"dependencies": {
|
| 583 |
+
"is-node-process": "^1.2.0",
|
| 584 |
+
"outvariant": "^1.4.0"
|
| 585 |
+
}
|
| 586 |
+
},
|
| 587 |
+
"node_modules/@open-draft/until": {
|
| 588 |
+
"version": "2.1.0",
|
| 589 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@open-draft/until/-/until-2.1.0.tgz",
|
| 590 |
+
"integrity": "sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==",
|
| 591 |
+
"license": "MIT"
|
| 592 |
+
},
|
| 593 |
+
"node_modules/@rollup/rollup-android-arm-eabi": {
|
| 594 |
+
"version": "4.52.5",
|
| 595 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.52.5.tgz",
|
| 596 |
+
"integrity": "sha512-8c1vW4ocv3UOMp9K+gToY5zL2XiiVw3k7f1ksf4yO1FlDFQ1C2u72iACFnSOceJFsWskc2WZNqeRhFRPzv+wtQ==",
|
| 597 |
+
"cpu": [
|
| 598 |
+
"arm"
|
| 599 |
+
],
|
| 600 |
+
"license": "MIT",
|
| 601 |
+
"optional": true,
|
| 602 |
+
"os": [
|
| 603 |
+
"android"
|
| 604 |
+
]
|
| 605 |
+
},
|
| 606 |
+
"node_modules/@rollup/rollup-android-arm64": {
|
| 607 |
+
"version": "4.52.5",
|
| 608 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.52.5.tgz",
|
| 609 |
+
"integrity": "sha512-mQGfsIEFcu21mvqkEKKu2dYmtuSZOBMmAl5CFlPGLY94Vlcm+zWApK7F/eocsNzp8tKmbeBP8yXyAbx0XHsFNA==",
|
| 610 |
+
"cpu": [
|
| 611 |
+
"arm64"
|
| 612 |
+
],
|
| 613 |
+
"license": "MIT",
|
| 614 |
+
"optional": true,
|
| 615 |
+
"os": [
|
| 616 |
+
"android"
|
| 617 |
+
]
|
| 618 |
+
},
|
| 619 |
+
"node_modules/@rollup/rollup-darwin-arm64": {
|
| 620 |
+
"version": "4.52.5",
|
| 621 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.52.5.tgz",
|
| 622 |
+
"integrity": "sha512-takF3CR71mCAGA+v794QUZ0b6ZSrgJkArC+gUiG6LB6TQty9T0Mqh3m2ImRBOxS2IeYBo4lKWIieSvnEk2OQWA==",
|
| 623 |
+
"cpu": [
|
| 624 |
+
"arm64"
|
| 625 |
+
],
|
| 626 |
+
"license": "MIT",
|
| 627 |
+
"optional": true,
|
| 628 |
+
"os": [
|
| 629 |
+
"darwin"
|
| 630 |
+
]
|
| 631 |
+
},
|
| 632 |
+
"node_modules/@rollup/rollup-darwin-x64": {
|
| 633 |
+
"version": "4.52.5",
|
| 634 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.52.5.tgz",
|
| 635 |
+
"integrity": "sha512-W901Pla8Ya95WpxDn//VF9K9u2JbocwV/v75TE0YIHNTbhqUTv9w4VuQ9MaWlNOkkEfFwkdNhXgcLqPSmHy0fA==",
|
| 636 |
+
"cpu": [
|
| 637 |
+
"x64"
|
| 638 |
+
],
|
| 639 |
+
"license": "MIT",
|
| 640 |
+
"optional": true,
|
| 641 |
+
"os": [
|
| 642 |
+
"darwin"
|
| 643 |
+
]
|
| 644 |
+
},
|
| 645 |
+
"node_modules/@rollup/rollup-freebsd-arm64": {
|
| 646 |
+
"version": "4.52.5",
|
| 647 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.52.5.tgz",
|
| 648 |
+
"integrity": "sha512-QofO7i7JycsYOWxe0GFqhLmF6l1TqBswJMvICnRUjqCx8b47MTo46W8AoeQwiokAx3zVryVnxtBMcGcnX12LvA==",
|
| 649 |
+
"cpu": [
|
| 650 |
+
"arm64"
|
| 651 |
+
],
|
| 652 |
+
"license": "MIT",
|
| 653 |
+
"optional": true,
|
| 654 |
+
"os": [
|
| 655 |
+
"freebsd"
|
| 656 |
+
]
|
| 657 |
+
},
|
| 658 |
+
"node_modules/@rollup/rollup-freebsd-x64": {
|
| 659 |
+
"version": "4.52.5",
|
| 660 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.52.5.tgz",
|
| 661 |
+
"integrity": "sha512-jr21b/99ew8ujZubPo9skbrItHEIE50WdV86cdSoRkKtmWa+DDr6fu2c/xyRT0F/WazZpam6kk7IHBerSL7LDQ==",
|
| 662 |
+
"cpu": [
|
| 663 |
+
"x64"
|
| 664 |
+
],
|
| 665 |
+
"license": "MIT",
|
| 666 |
+
"optional": true,
|
| 667 |
+
"os": [
|
| 668 |
+
"freebsd"
|
| 669 |
+
]
|
| 670 |
+
},
|
| 671 |
+
"node_modules/@rollup/rollup-linux-arm-gnueabihf": {
|
| 672 |
+
"version": "4.52.5",
|
| 673 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.52.5.tgz",
|
| 674 |
+
"integrity": "sha512-PsNAbcyv9CcecAUagQefwX8fQn9LQ4nZkpDboBOttmyffnInRy8R8dSg6hxxl2Re5QhHBf6FYIDhIj5v982ATQ==",
|
| 675 |
+
"cpu": [
|
| 676 |
+
"arm"
|
| 677 |
+
],
|
| 678 |
+
"license": "MIT",
|
| 679 |
+
"optional": true,
|
| 680 |
+
"os": [
|
| 681 |
+
"linux"
|
| 682 |
+
]
|
| 683 |
+
},
|
| 684 |
+
"node_modules/@rollup/rollup-linux-arm-musleabihf": {
|
| 685 |
+
"version": "4.52.5",
|
| 686 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.52.5.tgz",
|
| 687 |
+
"integrity": "sha512-Fw4tysRutyQc/wwkmcyoqFtJhh0u31K+Q6jYjeicsGJJ7bbEq8LwPWV/w0cnzOqR2m694/Af6hpFayLJZkG2VQ==",
|
| 688 |
+
"cpu": [
|
| 689 |
+
"arm"
|
| 690 |
+
],
|
| 691 |
+
"license": "MIT",
|
| 692 |
+
"optional": true,
|
| 693 |
+
"os": [
|
| 694 |
+
"linux"
|
| 695 |
+
]
|
| 696 |
+
},
|
| 697 |
+
"node_modules/@rollup/rollup-linux-arm64-gnu": {
|
| 698 |
+
"version": "4.52.5",
|
| 699 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.52.5.tgz",
|
| 700 |
+
"integrity": "sha512-a+3wVnAYdQClOTlyapKmyI6BLPAFYs0JM8HRpgYZQO02rMR09ZcV9LbQB+NL6sljzG38869YqThrRnfPMCDtZg==",
|
| 701 |
+
"cpu": [
|
| 702 |
+
"arm64"
|
| 703 |
+
],
|
| 704 |
+
"license": "MIT",
|
| 705 |
+
"optional": true,
|
| 706 |
+
"os": [
|
| 707 |
+
"linux"
|
| 708 |
+
]
|
| 709 |
+
},
|
| 710 |
+
"node_modules/@rollup/rollup-linux-arm64-musl": {
|
| 711 |
+
"version": "4.52.5",
|
| 712 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.52.5.tgz",
|
| 713 |
+
"integrity": "sha512-AvttBOMwO9Pcuuf7m9PkC1PUIKsfaAJ4AYhy944qeTJgQOqJYJ9oVl2nYgY7Rk0mkbsuOpCAYSs6wLYB2Xiw0Q==",
|
| 714 |
+
"cpu": [
|
| 715 |
+
"arm64"
|
| 716 |
+
],
|
| 717 |
+
"license": "MIT",
|
| 718 |
+
"optional": true,
|
| 719 |
+
"os": [
|
| 720 |
+
"linux"
|
| 721 |
+
]
|
| 722 |
+
},
|
| 723 |
+
"node_modules/@rollup/rollup-linux-loong64-gnu": {
|
| 724 |
+
"version": "4.52.5",
|
| 725 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.52.5.tgz",
|
| 726 |
+
"integrity": "sha512-DkDk8pmXQV2wVrF6oq5tONK6UHLz/XcEVow4JTTerdeV1uqPeHxwcg7aFsfnSm9L+OO8WJsWotKM2JJPMWrQtA==",
|
| 727 |
+
"cpu": [
|
| 728 |
+
"loong64"
|
| 729 |
+
],
|
| 730 |
+
"license": "MIT",
|
| 731 |
+
"optional": true,
|
| 732 |
+
"os": [
|
| 733 |
+
"linux"
|
| 734 |
+
]
|
| 735 |
+
},
|
| 736 |
+
"node_modules/@rollup/rollup-linux-ppc64-gnu": {
|
| 737 |
+
"version": "4.52.5",
|
| 738 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.52.5.tgz",
|
| 739 |
+
"integrity": "sha512-W/b9ZN/U9+hPQVvlGwjzi+Wy4xdoH2I8EjaCkMvzpI7wJUs8sWJ03Rq96jRnHkSrcHTpQe8h5Tg3ZzUPGauvAw==",
|
| 740 |
+
"cpu": [
|
| 741 |
+
"ppc64"
|
| 742 |
+
],
|
| 743 |
+
"license": "MIT",
|
| 744 |
+
"optional": true,
|
| 745 |
+
"os": [
|
| 746 |
+
"linux"
|
| 747 |
+
]
|
| 748 |
+
},
|
| 749 |
+
"node_modules/@rollup/rollup-linux-riscv64-gnu": {
|
| 750 |
+
"version": "4.52.5",
|
| 751 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.52.5.tgz",
|
| 752 |
+
"integrity": "sha512-sjQLr9BW7R/ZiXnQiWPkErNfLMkkWIoCz7YMn27HldKsADEKa5WYdobaa1hmN6slu9oWQbB6/jFpJ+P2IkVrmw==",
|
| 753 |
+
"cpu": [
|
| 754 |
+
"riscv64"
|
| 755 |
+
],
|
| 756 |
+
"license": "MIT",
|
| 757 |
+
"optional": true,
|
| 758 |
+
"os": [
|
| 759 |
+
"linux"
|
| 760 |
+
]
|
| 761 |
+
},
|
| 762 |
+
"node_modules/@rollup/rollup-linux-riscv64-musl": {
|
| 763 |
+
"version": "4.52.5",
|
| 764 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.52.5.tgz",
|
| 765 |
+
"integrity": "sha512-hq3jU/kGyjXWTvAh2awn8oHroCbrPm8JqM7RUpKjalIRWWXE01CQOf/tUNWNHjmbMHg/hmNCwc/Pz3k1T/j/Lg==",
|
| 766 |
+
"cpu": [
|
| 767 |
+
"riscv64"
|
| 768 |
+
],
|
| 769 |
+
"license": "MIT",
|
| 770 |
+
"optional": true,
|
| 771 |
+
"os": [
|
| 772 |
+
"linux"
|
| 773 |
+
]
|
| 774 |
+
},
|
| 775 |
+
"node_modules/@rollup/rollup-linux-s390x-gnu": {
|
| 776 |
+
"version": "4.52.5",
|
| 777 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.52.5.tgz",
|
| 778 |
+
"integrity": "sha512-gn8kHOrku8D4NGHMK1Y7NA7INQTRdVOntt1OCYypZPRt6skGbddska44K8iocdpxHTMMNui5oH4elPH4QOLrFQ==",
|
| 779 |
+
"cpu": [
|
| 780 |
+
"s390x"
|
| 781 |
+
],
|
| 782 |
+
"license": "MIT",
|
| 783 |
+
"optional": true,
|
| 784 |
+
"os": [
|
| 785 |
+
"linux"
|
| 786 |
+
]
|
| 787 |
+
},
|
| 788 |
+
"node_modules/@rollup/rollup-linux-x64-gnu": {
|
| 789 |
+
"version": "4.52.5",
|
| 790 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.52.5.tgz",
|
| 791 |
+
"integrity": "sha512-hXGLYpdhiNElzN770+H2nlx+jRog8TyynpTVzdlc6bndktjKWyZyiCsuDAlpd+j+W+WNqfcyAWz9HxxIGfZm1Q==",
|
| 792 |
+
"cpu": [
|
| 793 |
+
"x64"
|
| 794 |
+
],
|
| 795 |
+
"license": "MIT",
|
| 796 |
+
"optional": true,
|
| 797 |
+
"os": [
|
| 798 |
+
"linux"
|
| 799 |
+
]
|
| 800 |
+
},
|
| 801 |
+
"node_modules/@rollup/rollup-linux-x64-musl": {
|
| 802 |
+
"version": "4.52.5",
|
| 803 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.52.5.tgz",
|
| 804 |
+
"integrity": "sha512-arCGIcuNKjBoKAXD+y7XomR9gY6Mw7HnFBv5Rw7wQRvwYLR7gBAgV7Mb2QTyjXfTveBNFAtPt46/36vV9STLNg==",
|
| 805 |
+
"cpu": [
|
| 806 |
+
"x64"
|
| 807 |
+
],
|
| 808 |
+
"license": "MIT",
|
| 809 |
+
"optional": true,
|
| 810 |
+
"os": [
|
| 811 |
+
"linux"
|
| 812 |
+
]
|
| 813 |
+
},
|
| 814 |
+
"node_modules/@rollup/rollup-openharmony-arm64": {
|
| 815 |
+
"version": "4.52.5",
|
| 816 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.52.5.tgz",
|
| 817 |
+
"integrity": "sha512-QoFqB6+/9Rly/RiPjaomPLmR/13cgkIGfA40LHly9zcH1S0bN2HVFYk3a1eAyHQyjs3ZJYlXvIGtcCs5tko9Cw==",
|
| 818 |
+
"cpu": [
|
| 819 |
+
"arm64"
|
| 820 |
+
],
|
| 821 |
+
"license": "MIT",
|
| 822 |
+
"optional": true,
|
| 823 |
+
"os": [
|
| 824 |
+
"openharmony"
|
| 825 |
+
]
|
| 826 |
+
},
|
| 827 |
+
"node_modules/@rollup/rollup-win32-arm64-msvc": {
|
| 828 |
+
"version": "4.52.5",
|
| 829 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.52.5.tgz",
|
| 830 |
+
"integrity": "sha512-w0cDWVR6MlTstla1cIfOGyl8+qb93FlAVutcor14Gf5Md5ap5ySfQ7R9S/NjNaMLSFdUnKGEasmVnu3lCMqB7w==",
|
| 831 |
+
"cpu": [
|
| 832 |
+
"arm64"
|
| 833 |
+
],
|
| 834 |
+
"license": "MIT",
|
| 835 |
+
"optional": true,
|
| 836 |
+
"os": [
|
| 837 |
+
"win32"
|
| 838 |
+
]
|
| 839 |
+
},
|
| 840 |
+
"node_modules/@rollup/rollup-win32-ia32-msvc": {
|
| 841 |
+
"version": "4.52.5",
|
| 842 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.52.5.tgz",
|
| 843 |
+
"integrity": "sha512-Aufdpzp7DpOTULJCuvzqcItSGDH73pF3ko/f+ckJhxQyHtp67rHw3HMNxoIdDMUITJESNE6a8uh4Lo4SLouOUg==",
|
| 844 |
+
"cpu": [
|
| 845 |
+
"ia32"
|
| 846 |
+
],
|
| 847 |
+
"license": "MIT",
|
| 848 |
+
"optional": true,
|
| 849 |
+
"os": [
|
| 850 |
+
"win32"
|
| 851 |
+
]
|
| 852 |
+
},
|
| 853 |
+
"node_modules/@rollup/rollup-win32-x64-gnu": {
|
| 854 |
+
"version": "4.52.5",
|
| 855 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.52.5.tgz",
|
| 856 |
+
"integrity": "sha512-UGBUGPFp1vkj6p8wCRraqNhqwX/4kNQPS57BCFc8wYh0g94iVIW33wJtQAx3G7vrjjNtRaxiMUylM0ktp/TRSQ==",
|
| 857 |
+
"cpu": [
|
| 858 |
+
"x64"
|
| 859 |
+
],
|
| 860 |
+
"license": "MIT",
|
| 861 |
+
"optional": true,
|
| 862 |
+
"os": [
|
| 863 |
+
"win32"
|
| 864 |
+
]
|
| 865 |
+
},
|
| 866 |
+
"node_modules/@rollup/rollup-win32-x64-msvc": {
|
| 867 |
+
"version": "4.52.5",
|
| 868 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.52.5.tgz",
|
| 869 |
+
"integrity": "sha512-TAcgQh2sSkykPRWLrdyy2AiceMckNf5loITqXxFI5VuQjS5tSuw3WlwdN8qv8vzjLAUTvYaH/mVjSFpbkFbpTg==",
|
| 870 |
+
"cpu": [
|
| 871 |
+
"x64"
|
| 872 |
+
],
|
| 873 |
+
"license": "MIT",
|
| 874 |
+
"optional": true,
|
| 875 |
+
"os": [
|
| 876 |
+
"win32"
|
| 877 |
+
]
|
| 878 |
+
},
|
| 879 |
+
"node_modules/@types/estree": {
|
| 880 |
+
"version": "1.0.8",
|
| 881 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@types/estree/-/estree-1.0.8.tgz",
|
| 882 |
+
"integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==",
|
| 883 |
+
"license": "MIT"
|
| 884 |
+
},
|
| 885 |
+
"node_modules/@types/eventsource": {
|
| 886 |
+
"version": "1.1.15",
|
| 887 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@types/eventsource/-/eventsource-1.1.15.tgz",
|
| 888 |
+
"integrity": "sha512-XQmGcbnxUNa06HR3VBVkc9+A2Vpi9ZyLJcdS5dwaQQ/4ZMWFO+5c90FnMUpbtMZwB/FChoYHwuVg8TvkECacTA==",
|
| 889 |
+
"license": "MIT"
|
| 890 |
+
},
|
| 891 |
+
"node_modules/@types/node": {
|
| 892 |
+
"version": "24.8.1",
|
| 893 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@types/node/-/node-24.8.1.tgz",
|
| 894 |
+
"integrity": "sha512-alv65KGRadQVfVcG69MuB4IzdYVpRwMG/mq8KWOaoOdyY617P5ivaDiMCGOFDWD2sAn5Q0mR3mRtUOgm99hL9Q==",
|
| 895 |
+
"devOptional": true,
|
| 896 |
+
"license": "MIT",
|
| 897 |
+
"dependencies": {
|
| 898 |
+
"undici-types": "~7.14.0"
|
| 899 |
+
}
|
| 900 |
+
},
|
| 901 |
+
"node_modules/@types/statuses": {
|
| 902 |
+
"version": "2.0.6",
|
| 903 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@types/statuses/-/statuses-2.0.6.tgz",
|
| 904 |
+
"integrity": "sha512-xMAgYwceFhRA2zY+XbEA7mxYbA093wdiW8Vu6gZPGWy9cmOyU9XesH1tNcEWsKFd5Vzrqx5T3D38PWx1FIIXkA==",
|
| 905 |
+
"license": "MIT"
|
| 906 |
+
},
|
| 907 |
+
"node_modules/@types/ws": {
|
| 908 |
+
"version": "8.18.1",
|
| 909 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@types/ws/-/ws-8.18.1.tgz",
|
| 910 |
+
"integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==",
|
| 911 |
+
"dev": true,
|
| 912 |
+
"license": "MIT",
|
| 913 |
+
"dependencies": {
|
| 914 |
+
"@types/node": "*"
|
| 915 |
+
}
|
| 916 |
+
},
|
| 917 |
+
"node_modules/ansi-regex": {
|
| 918 |
+
"version": "5.0.1",
|
| 919 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
| 920 |
+
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
| 921 |
+
"license": "MIT",
|
| 922 |
+
"engines": {
|
| 923 |
+
"node": ">=8"
|
| 924 |
+
}
|
| 925 |
+
},
|
| 926 |
+
"node_modules/ansi-styles": {
|
| 927 |
+
"version": "4.3.0",
|
| 928 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
| 929 |
+
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
| 930 |
+
"license": "MIT",
|
| 931 |
+
"dependencies": {
|
| 932 |
+
"color-convert": "^2.0.1"
|
| 933 |
+
},
|
| 934 |
+
"engines": {
|
| 935 |
+
"node": ">=8"
|
| 936 |
+
},
|
| 937 |
+
"funding": {
|
| 938 |
+
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
| 939 |
+
}
|
| 940 |
+
},
|
| 941 |
+
"node_modules/bufferutil": {
|
| 942 |
+
"version": "4.0.9",
|
| 943 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/bufferutil/-/bufferutil-4.0.9.tgz",
|
| 944 |
+
"integrity": "sha512-WDtdLmJvAuNNPzByAYpRo2rF1Mmradw6gvWsQKf63476DDXmomT9zUiGypLcG4ibIM67vhAj8jJRdbmEws2Aqw==",
|
| 945 |
+
"hasInstallScript": true,
|
| 946 |
+
"license": "MIT",
|
| 947 |
+
"dependencies": {
|
| 948 |
+
"node-gyp-build": "^4.3.0"
|
| 949 |
+
},
|
| 950 |
+
"engines": {
|
| 951 |
+
"node": ">=6.14.2"
|
| 952 |
+
}
|
| 953 |
+
},
|
| 954 |
+
"node_modules/cli-width": {
|
| 955 |
+
"version": "4.1.0",
|
| 956 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/cli-width/-/cli-width-4.1.0.tgz",
|
| 957 |
+
"integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==",
|
| 958 |
+
"license": "ISC",
|
| 959 |
+
"engines": {
|
| 960 |
+
"node": ">= 12"
|
| 961 |
+
}
|
| 962 |
+
},
|
| 963 |
+
"node_modules/cliui": {
|
| 964 |
+
"version": "8.0.1",
|
| 965 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/cliui/-/cliui-8.0.1.tgz",
|
| 966 |
+
"integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==",
|
| 967 |
+
"license": "ISC",
|
| 968 |
+
"dependencies": {
|
| 969 |
+
"string-width": "^4.2.0",
|
| 970 |
+
"strip-ansi": "^6.0.1",
|
| 971 |
+
"wrap-ansi": "^7.0.0"
|
| 972 |
+
},
|
| 973 |
+
"engines": {
|
| 974 |
+
"node": ">=12"
|
| 975 |
+
}
|
| 976 |
+
},
|
| 977 |
+
"node_modules/cliui/node_modules/wrap-ansi": {
|
| 978 |
+
"version": "7.0.0",
|
| 979 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
|
| 980 |
+
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
|
| 981 |
+
"license": "MIT",
|
| 982 |
+
"dependencies": {
|
| 983 |
+
"ansi-styles": "^4.0.0",
|
| 984 |
+
"string-width": "^4.1.0",
|
| 985 |
+
"strip-ansi": "^6.0.0"
|
| 986 |
+
},
|
| 987 |
+
"engines": {
|
| 988 |
+
"node": ">=10"
|
| 989 |
+
},
|
| 990 |
+
"funding": {
|
| 991 |
+
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
|
| 992 |
+
}
|
| 993 |
+
},
|
| 994 |
+
"node_modules/color-convert": {
|
| 995 |
+
"version": "2.0.1",
|
| 996 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/color-convert/-/color-convert-2.0.1.tgz",
|
| 997 |
+
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
| 998 |
+
"license": "MIT",
|
| 999 |
+
"dependencies": {
|
| 1000 |
+
"color-name": "~1.1.4"
|
| 1001 |
+
},
|
| 1002 |
+
"engines": {
|
| 1003 |
+
"node": ">=7.0.0"
|
| 1004 |
+
}
|
| 1005 |
+
},
|
| 1006 |
+
"node_modules/color-name": {
|
| 1007 |
+
"version": "1.1.4",
|
| 1008 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/color-name/-/color-name-1.1.4.tgz",
|
| 1009 |
+
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
| 1010 |
+
"license": "MIT"
|
| 1011 |
+
},
|
| 1012 |
+
"node_modules/cookie": {
|
| 1013 |
+
"version": "1.0.2",
|
| 1014 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/cookie/-/cookie-1.0.2.tgz",
|
| 1015 |
+
"integrity": "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==",
|
| 1016 |
+
"license": "MIT",
|
| 1017 |
+
"engines": {
|
| 1018 |
+
"node": ">=18"
|
| 1019 |
+
}
|
| 1020 |
+
},
|
| 1021 |
+
"node_modules/emoji-regex": {
|
| 1022 |
+
"version": "8.0.0",
|
| 1023 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
| 1024 |
+
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
|
| 1025 |
+
"license": "MIT"
|
| 1026 |
+
},
|
| 1027 |
+
"node_modules/esbuild": {
|
| 1028 |
+
"version": "0.21.5",
|
| 1029 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/esbuild/-/esbuild-0.21.5.tgz",
|
| 1030 |
+
"integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==",
|
| 1031 |
+
"dev": true,
|
| 1032 |
+
"hasInstallScript": true,
|
| 1033 |
+
"license": "MIT",
|
| 1034 |
+
"bin": {
|
| 1035 |
+
"esbuild": "bin/esbuild"
|
| 1036 |
+
},
|
| 1037 |
+
"engines": {
|
| 1038 |
+
"node": ">=12"
|
| 1039 |
+
},
|
| 1040 |
+
"optionalDependencies": {
|
| 1041 |
+
"@esbuild/aix-ppc64": "0.21.5",
|
| 1042 |
+
"@esbuild/android-arm": "0.21.5",
|
| 1043 |
+
"@esbuild/android-arm64": "0.21.5",
|
| 1044 |
+
"@esbuild/android-x64": "0.21.5",
|
| 1045 |
+
"@esbuild/darwin-arm64": "0.21.5",
|
| 1046 |
+
"@esbuild/darwin-x64": "0.21.5",
|
| 1047 |
+
"@esbuild/freebsd-arm64": "0.21.5",
|
| 1048 |
+
"@esbuild/freebsd-x64": "0.21.5",
|
| 1049 |
+
"@esbuild/linux-arm": "0.21.5",
|
| 1050 |
+
"@esbuild/linux-arm64": "0.21.5",
|
| 1051 |
+
"@esbuild/linux-ia32": "0.21.5",
|
| 1052 |
+
"@esbuild/linux-loong64": "0.21.5",
|
| 1053 |
+
"@esbuild/linux-mips64el": "0.21.5",
|
| 1054 |
+
"@esbuild/linux-ppc64": "0.21.5",
|
| 1055 |
+
"@esbuild/linux-riscv64": "0.21.5",
|
| 1056 |
+
"@esbuild/linux-s390x": "0.21.5",
|
| 1057 |
+
"@esbuild/linux-x64": "0.21.5",
|
| 1058 |
+
"@esbuild/netbsd-x64": "0.21.5",
|
| 1059 |
+
"@esbuild/openbsd-x64": "0.21.5",
|
| 1060 |
+
"@esbuild/sunos-x64": "0.21.5",
|
| 1061 |
+
"@esbuild/win32-arm64": "0.21.5",
|
| 1062 |
+
"@esbuild/win32-ia32": "0.21.5",
|
| 1063 |
+
"@esbuild/win32-x64": "0.21.5"
|
| 1064 |
+
}
|
| 1065 |
+
},
|
| 1066 |
+
"node_modules/escalade": {
|
| 1067 |
+
"version": "3.2.0",
|
| 1068 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/escalade/-/escalade-3.2.0.tgz",
|
| 1069 |
+
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
|
| 1070 |
+
"license": "MIT",
|
| 1071 |
+
"engines": {
|
| 1072 |
+
"node": ">=6"
|
| 1073 |
+
}
|
| 1074 |
+
},
|
| 1075 |
+
"node_modules/eventsource": {
|
| 1076 |
+
"version": "2.0.2",
|
| 1077 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/eventsource/-/eventsource-2.0.2.tgz",
|
| 1078 |
+
"integrity": "sha512-IzUmBGPR3+oUG9dUeXynyNmf91/3zUSJg1lCktzKw47OXuhco54U3r9B7O4XX+Rb1Itm9OZ2b0RkTs10bICOxA==",
|
| 1079 |
+
"license": "MIT",
|
| 1080 |
+
"engines": {
|
| 1081 |
+
"node": ">=12.0.0"
|
| 1082 |
+
}
|
| 1083 |
+
},
|
| 1084 |
+
"node_modules/fdir": {
|
| 1085 |
+
"version": "6.5.0",
|
| 1086 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/fdir/-/fdir-6.5.0.tgz",
|
| 1087 |
+
"integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
|
| 1088 |
+
"license": "MIT",
|
| 1089 |
+
"engines": {
|
| 1090 |
+
"node": ">=12.0.0"
|
| 1091 |
+
},
|
| 1092 |
+
"peerDependencies": {
|
| 1093 |
+
"picomatch": "^3 || ^4"
|
| 1094 |
+
},
|
| 1095 |
+
"peerDependenciesMeta": {
|
| 1096 |
+
"picomatch": {
|
| 1097 |
+
"optional": true
|
| 1098 |
+
}
|
| 1099 |
+
}
|
| 1100 |
+
},
|
| 1101 |
+
"node_modules/fetch-event-stream": {
|
| 1102 |
+
"version": "0.1.5",
|
| 1103 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/fetch-event-stream/-/fetch-event-stream-0.1.5.tgz",
|
| 1104 |
+
"integrity": "sha512-V1PWovkspxQfssq/NnxoEyQo1DV+MRK/laPuPblIZmSjMN8P5u46OhlFQznSr9p/t0Sp8Uc6SbM3yCMfr0KU8g==",
|
| 1105 |
+
"license": "MIT"
|
| 1106 |
+
},
|
| 1107 |
+
"node_modules/fsevents": {
|
| 1108 |
+
"version": "2.3.3",
|
| 1109 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/fsevents/-/fsevents-2.3.3.tgz",
|
| 1110 |
+
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
|
| 1111 |
+
"hasInstallScript": true,
|
| 1112 |
+
"license": "MIT",
|
| 1113 |
+
"optional": true,
|
| 1114 |
+
"os": [
|
| 1115 |
+
"darwin"
|
| 1116 |
+
],
|
| 1117 |
+
"engines": {
|
| 1118 |
+
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
| 1119 |
+
}
|
| 1120 |
+
},
|
| 1121 |
+
"node_modules/get-caller-file": {
|
| 1122 |
+
"version": "2.0.5",
|
| 1123 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/get-caller-file/-/get-caller-file-2.0.5.tgz",
|
| 1124 |
+
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
|
| 1125 |
+
"license": "ISC",
|
| 1126 |
+
"engines": {
|
| 1127 |
+
"node": "6.* || 8.* || >= 10.*"
|
| 1128 |
+
}
|
| 1129 |
+
},
|
| 1130 |
+
"node_modules/graphql": {
|
| 1131 |
+
"version": "16.11.0",
|
| 1132 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/graphql/-/graphql-16.11.0.tgz",
|
| 1133 |
+
"integrity": "sha512-mS1lbMsxgQj6hge1XZ6p7GPhbrtFwUFYi3wRzXAC/FmYnyXMTvvI3td3rjmQ2u8ewXueaSvRPWaEcgVVOT9Jnw==",
|
| 1134 |
+
"license": "MIT",
|
| 1135 |
+
"engines": {
|
| 1136 |
+
"node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0"
|
| 1137 |
+
}
|
| 1138 |
+
},
|
| 1139 |
+
"node_modules/headers-polyfill": {
|
| 1140 |
+
"version": "4.0.3",
|
| 1141 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/headers-polyfill/-/headers-polyfill-4.0.3.tgz",
|
| 1142 |
+
"integrity": "sha512-IScLbePpkvO846sIwOtOTDjutRMWdXdJmXdMvk6gCBHxFO8d+QKOQedyZSxFTTFYRSmlgSTDtXqqq4pcenBXLQ==",
|
| 1143 |
+
"license": "MIT"
|
| 1144 |
+
},
|
| 1145 |
+
"node_modules/is-fullwidth-code-point": {
|
| 1146 |
+
"version": "3.0.0",
|
| 1147 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
|
| 1148 |
+
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
|
| 1149 |
+
"license": "MIT",
|
| 1150 |
+
"engines": {
|
| 1151 |
+
"node": ">=8"
|
| 1152 |
+
}
|
| 1153 |
+
},
|
| 1154 |
+
"node_modules/is-node-process": {
|
| 1155 |
+
"version": "1.2.0",
|
| 1156 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/is-node-process/-/is-node-process-1.2.0.tgz",
|
| 1157 |
+
"integrity": "sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw==",
|
| 1158 |
+
"license": "MIT"
|
| 1159 |
+
},
|
| 1160 |
+
"node_modules/msw": {
|
| 1161 |
+
"version": "2.11.6",
|
| 1162 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/msw/-/msw-2.11.6.tgz",
|
| 1163 |
+
"integrity": "sha512-MCYMykvmiYScyUm7I6y0VCxpNq1rgd5v7kG8ks5dKtvmxRUUPjribX6mUoUNBbM5/3PhUyoelEWiKXGOz84c+w==",
|
| 1164 |
+
"hasInstallScript": true,
|
| 1165 |
+
"license": "MIT",
|
| 1166 |
+
"dependencies": {
|
| 1167 |
+
"@inquirer/confirm": "^5.0.0",
|
| 1168 |
+
"@mswjs/interceptors": "^0.40.0",
|
| 1169 |
+
"@open-draft/deferred-promise": "^2.2.0",
|
| 1170 |
+
"@types/statuses": "^2.0.4",
|
| 1171 |
+
"cookie": "^1.0.2",
|
| 1172 |
+
"graphql": "^16.8.1",
|
| 1173 |
+
"headers-polyfill": "^4.0.2",
|
| 1174 |
+
"is-node-process": "^1.2.0",
|
| 1175 |
+
"outvariant": "^1.4.3",
|
| 1176 |
+
"path-to-regexp": "^6.3.0",
|
| 1177 |
+
"picocolors": "^1.1.1",
|
| 1178 |
+
"rettime": "^0.7.0",
|
| 1179 |
+
"statuses": "^2.0.2",
|
| 1180 |
+
"strict-event-emitter": "^0.5.1",
|
| 1181 |
+
"tough-cookie": "^6.0.0",
|
| 1182 |
+
"type-fest": "^4.26.1",
|
| 1183 |
+
"until-async": "^3.0.2",
|
| 1184 |
+
"yargs": "^17.7.2"
|
| 1185 |
+
},
|
| 1186 |
+
"bin": {
|
| 1187 |
+
"msw": "cli/index.js"
|
| 1188 |
+
},
|
| 1189 |
+
"engines": {
|
| 1190 |
+
"node": ">=18"
|
| 1191 |
+
},
|
| 1192 |
+
"funding": {
|
| 1193 |
+
"url": "https://github.com/sponsors/mswjs"
|
| 1194 |
+
},
|
| 1195 |
+
"peerDependencies": {
|
| 1196 |
+
"typescript": ">= 4.8.x"
|
| 1197 |
+
},
|
| 1198 |
+
"peerDependenciesMeta": {
|
| 1199 |
+
"typescript": {
|
| 1200 |
+
"optional": true
|
| 1201 |
+
}
|
| 1202 |
+
}
|
| 1203 |
+
},
|
| 1204 |
+
"node_modules/mute-stream": {
|
| 1205 |
+
"version": "2.0.0",
|
| 1206 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/mute-stream/-/mute-stream-2.0.0.tgz",
|
| 1207 |
+
"integrity": "sha512-WWdIxpyjEn+FhQJQQv9aQAYlHoNVdzIzUySNV1gHUPDSdZJ3yZn7pAAbQcV7B56Mvu881q9FZV+0Vx2xC44VWA==",
|
| 1208 |
+
"license": "ISC",
|
| 1209 |
+
"engines": {
|
| 1210 |
+
"node": "^18.17.0 || >=20.5.0"
|
| 1211 |
+
}
|
| 1212 |
+
},
|
| 1213 |
+
"node_modules/nanoid": {
|
| 1214 |
+
"version": "3.3.11",
|
| 1215 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/nanoid/-/nanoid-3.3.11.tgz",
|
| 1216 |
+
"integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==",
|
| 1217 |
+
"funding": [
|
| 1218 |
+
{
|
| 1219 |
+
"type": "github",
|
| 1220 |
+
"url": "https://github.com/sponsors/ai"
|
| 1221 |
+
}
|
| 1222 |
+
],
|
| 1223 |
+
"license": "MIT",
|
| 1224 |
+
"bin": {
|
| 1225 |
+
"nanoid": "bin/nanoid.cjs"
|
| 1226 |
+
},
|
| 1227 |
+
"engines": {
|
| 1228 |
+
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
| 1229 |
+
}
|
| 1230 |
+
},
|
| 1231 |
+
"node_modules/node-gyp-build": {
|
| 1232 |
+
"version": "4.8.4",
|
| 1233 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/node-gyp-build/-/node-gyp-build-4.8.4.tgz",
|
| 1234 |
+
"integrity": "sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==",
|
| 1235 |
+
"license": "MIT",
|
| 1236 |
+
"bin": {
|
| 1237 |
+
"node-gyp-build": "bin.js",
|
| 1238 |
+
"node-gyp-build-optional": "optional.js",
|
| 1239 |
+
"node-gyp-build-test": "build-test.js"
|
| 1240 |
+
}
|
| 1241 |
+
},
|
| 1242 |
+
"node_modules/outvariant": {
|
| 1243 |
+
"version": "1.4.3",
|
| 1244 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/outvariant/-/outvariant-1.4.3.tgz",
|
| 1245 |
+
"integrity": "sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA==",
|
| 1246 |
+
"license": "MIT"
|
| 1247 |
+
},
|
| 1248 |
+
"node_modules/path-to-regexp": {
|
| 1249 |
+
"version": "6.3.0",
|
| 1250 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/path-to-regexp/-/path-to-regexp-6.3.0.tgz",
|
| 1251 |
+
"integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==",
|
| 1252 |
+
"license": "MIT"
|
| 1253 |
+
},
|
| 1254 |
+
"node_modules/picocolors": {
|
| 1255 |
+
"version": "1.1.1",
|
| 1256 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/picocolors/-/picocolors-1.1.1.tgz",
|
| 1257 |
+
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
|
| 1258 |
+
"license": "ISC"
|
| 1259 |
+
},
|
| 1260 |
+
"node_modules/picomatch": {
|
| 1261 |
+
"version": "4.0.3",
|
| 1262 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/picomatch/-/picomatch-4.0.3.tgz",
|
| 1263 |
+
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
| 1264 |
+
"license": "MIT",
|
| 1265 |
+
"engines": {
|
| 1266 |
+
"node": ">=12"
|
| 1267 |
+
},
|
| 1268 |
+
"funding": {
|
| 1269 |
+
"url": "https://github.com/sponsors/jonschlinkert"
|
| 1270 |
+
}
|
| 1271 |
+
},
|
| 1272 |
+
"node_modules/postcss": {
|
| 1273 |
+
"version": "8.5.6",
|
| 1274 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/postcss/-/postcss-8.5.6.tgz",
|
| 1275 |
+
"integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==",
|
| 1276 |
+
"funding": [
|
| 1277 |
+
{
|
| 1278 |
+
"type": "opencollective",
|
| 1279 |
+
"url": "https://opencollective.com/postcss/"
|
| 1280 |
+
},
|
| 1281 |
+
{
|
| 1282 |
+
"type": "tidelift",
|
| 1283 |
+
"url": "https://tidelift.com/funding/github/npm/postcss"
|
| 1284 |
+
},
|
| 1285 |
+
{
|
| 1286 |
+
"type": "github",
|
| 1287 |
+
"url": "https://github.com/sponsors/ai"
|
| 1288 |
+
}
|
| 1289 |
+
],
|
| 1290 |
+
"license": "MIT",
|
| 1291 |
+
"dependencies": {
|
| 1292 |
+
"nanoid": "^3.3.11",
|
| 1293 |
+
"picocolors": "^1.1.1",
|
| 1294 |
+
"source-map-js": "^1.2.1"
|
| 1295 |
+
},
|
| 1296 |
+
"engines": {
|
| 1297 |
+
"node": "^10 || ^12 || >=14"
|
| 1298 |
+
}
|
| 1299 |
+
},
|
| 1300 |
+
"node_modules/require-directory": {
|
| 1301 |
+
"version": "2.1.1",
|
| 1302 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/require-directory/-/require-directory-2.1.1.tgz",
|
| 1303 |
+
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
|
| 1304 |
+
"license": "MIT",
|
| 1305 |
+
"engines": {
|
| 1306 |
+
"node": ">=0.10.0"
|
| 1307 |
+
}
|
| 1308 |
+
},
|
| 1309 |
+
"node_modules/rettime": {
|
| 1310 |
+
"version": "0.7.0",
|
| 1311 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/rettime/-/rettime-0.7.0.tgz",
|
| 1312 |
+
"integrity": "sha512-LPRKoHnLKd/r3dVxcwO7vhCW+orkOGj9ViueosEBK6ie89CijnfRlhaDhHq/3Hxu4CkWQtxwlBG0mzTQY6uQjw==",
|
| 1313 |
+
"license": "MIT"
|
| 1314 |
+
},
|
| 1315 |
+
"node_modules/rollup": {
|
| 1316 |
+
"version": "4.52.5",
|
| 1317 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/rollup/-/rollup-4.52.5.tgz",
|
| 1318 |
+
"integrity": "sha512-3GuObel8h7Kqdjt0gxkEzaifHTqLVW56Y/bjN7PSQtkKr0w3V/QYSdt6QWYtd7A1xUtYQigtdUfgj1RvWVtorw==",
|
| 1319 |
+
"license": "MIT",
|
| 1320 |
+
"dependencies": {
|
| 1321 |
+
"@types/estree": "1.0.8"
|
| 1322 |
+
},
|
| 1323 |
+
"bin": {
|
| 1324 |
+
"rollup": "dist/bin/rollup"
|
| 1325 |
+
},
|
| 1326 |
+
"engines": {
|
| 1327 |
+
"node": ">=18.0.0",
|
| 1328 |
+
"npm": ">=8.0.0"
|
| 1329 |
+
},
|
| 1330 |
+
"optionalDependencies": {
|
| 1331 |
+
"@rollup/rollup-android-arm-eabi": "4.52.5",
|
| 1332 |
+
"@rollup/rollup-android-arm64": "4.52.5",
|
| 1333 |
+
"@rollup/rollup-darwin-arm64": "4.52.5",
|
| 1334 |
+
"@rollup/rollup-darwin-x64": "4.52.5",
|
| 1335 |
+
"@rollup/rollup-freebsd-arm64": "4.52.5",
|
| 1336 |
+
"@rollup/rollup-freebsd-x64": "4.52.5",
|
| 1337 |
+
"@rollup/rollup-linux-arm-gnueabihf": "4.52.5",
|
| 1338 |
+
"@rollup/rollup-linux-arm-musleabihf": "4.52.5",
|
| 1339 |
+
"@rollup/rollup-linux-arm64-gnu": "4.52.5",
|
| 1340 |
+
"@rollup/rollup-linux-arm64-musl": "4.52.5",
|
| 1341 |
+
"@rollup/rollup-linux-loong64-gnu": "4.52.5",
|
| 1342 |
+
"@rollup/rollup-linux-ppc64-gnu": "4.52.5",
|
| 1343 |
+
"@rollup/rollup-linux-riscv64-gnu": "4.52.5",
|
| 1344 |
+
"@rollup/rollup-linux-riscv64-musl": "4.52.5",
|
| 1345 |
+
"@rollup/rollup-linux-s390x-gnu": "4.52.5",
|
| 1346 |
+
"@rollup/rollup-linux-x64-gnu": "4.52.5",
|
| 1347 |
+
"@rollup/rollup-linux-x64-musl": "4.52.5",
|
| 1348 |
+
"@rollup/rollup-openharmony-arm64": "4.52.5",
|
| 1349 |
+
"@rollup/rollup-win32-arm64-msvc": "4.52.5",
|
| 1350 |
+
"@rollup/rollup-win32-ia32-msvc": "4.52.5",
|
| 1351 |
+
"@rollup/rollup-win32-x64-gnu": "4.52.5",
|
| 1352 |
+
"@rollup/rollup-win32-x64-msvc": "4.52.5",
|
| 1353 |
+
"fsevents": "~2.3.2"
|
| 1354 |
+
}
|
| 1355 |
+
},
|
| 1356 |
+
"node_modules/semiver": {
|
| 1357 |
+
"version": "1.1.0",
|
| 1358 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/semiver/-/semiver-1.1.0.tgz",
|
| 1359 |
+
"integrity": "sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg==",
|
| 1360 |
+
"license": "MIT",
|
| 1361 |
+
"engines": {
|
| 1362 |
+
"node": ">=6"
|
| 1363 |
+
}
|
| 1364 |
+
},
|
| 1365 |
+
"node_modules/signal-exit": {
|
| 1366 |
+
"version": "4.1.0",
|
| 1367 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/signal-exit/-/signal-exit-4.1.0.tgz",
|
| 1368 |
+
"integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
|
| 1369 |
+
"license": "ISC",
|
| 1370 |
+
"engines": {
|
| 1371 |
+
"node": ">=14"
|
| 1372 |
+
},
|
| 1373 |
+
"funding": {
|
| 1374 |
+
"url": "https://github.com/sponsors/isaacs"
|
| 1375 |
+
}
|
| 1376 |
+
},
|
| 1377 |
+
"node_modules/source-map-js": {
|
| 1378 |
+
"version": "1.2.1",
|
| 1379 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/source-map-js/-/source-map-js-1.2.1.tgz",
|
| 1380 |
+
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
|
| 1381 |
+
"license": "BSD-3-Clause",
|
| 1382 |
+
"engines": {
|
| 1383 |
+
"node": ">=0.10.0"
|
| 1384 |
+
}
|
| 1385 |
+
},
|
| 1386 |
+
"node_modules/statuses": {
|
| 1387 |
+
"version": "2.0.2",
|
| 1388 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/statuses/-/statuses-2.0.2.tgz",
|
| 1389 |
+
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
|
| 1390 |
+
"license": "MIT",
|
| 1391 |
+
"engines": {
|
| 1392 |
+
"node": ">= 0.8"
|
| 1393 |
+
}
|
| 1394 |
+
},
|
| 1395 |
+
"node_modules/strict-event-emitter": {
|
| 1396 |
+
"version": "0.5.1",
|
| 1397 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/strict-event-emitter/-/strict-event-emitter-0.5.1.tgz",
|
| 1398 |
+
"integrity": "sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==",
|
| 1399 |
+
"license": "MIT"
|
| 1400 |
+
},
|
| 1401 |
+
"node_modules/string-width": {
|
| 1402 |
+
"version": "4.2.3",
|
| 1403 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/string-width/-/string-width-4.2.3.tgz",
|
| 1404 |
+
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
|
| 1405 |
+
"license": "MIT",
|
| 1406 |
+
"dependencies": {
|
| 1407 |
+
"emoji-regex": "^8.0.0",
|
| 1408 |
+
"is-fullwidth-code-point": "^3.0.0",
|
| 1409 |
+
"strip-ansi": "^6.0.1"
|
| 1410 |
+
},
|
| 1411 |
+
"engines": {
|
| 1412 |
+
"node": ">=8"
|
| 1413 |
+
}
|
| 1414 |
+
},
|
| 1415 |
+
"node_modules/strip-ansi": {
|
| 1416 |
+
"version": "6.0.1",
|
| 1417 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/strip-ansi/-/strip-ansi-6.0.1.tgz",
|
| 1418 |
+
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
|
| 1419 |
+
"license": "MIT",
|
| 1420 |
+
"dependencies": {
|
| 1421 |
+
"ansi-regex": "^5.0.1"
|
| 1422 |
+
},
|
| 1423 |
+
"engines": {
|
| 1424 |
+
"node": ">=8"
|
| 1425 |
+
}
|
| 1426 |
+
},
|
| 1427 |
+
"node_modules/textlinestream": {
|
| 1428 |
+
"version": "1.1.1",
|
| 1429 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/textlinestream/-/textlinestream-1.1.1.tgz",
|
| 1430 |
+
"integrity": "sha512-iBHbi7BQxrFmwZUQJsT0SjNzlLLsXhvW/kg7EyOMVMBIrlnj/qYofwo1LVLZi+3GbUEo96Iu2eqToI2+lZoAEQ==",
|
| 1431 |
+
"license": "MIT"
|
| 1432 |
+
},
|
| 1433 |
+
"node_modules/tinyglobby": {
|
| 1434 |
+
"version": "0.2.15",
|
| 1435 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/tinyglobby/-/tinyglobby-0.2.15.tgz",
|
| 1436 |
+
"integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==",
|
| 1437 |
+
"license": "MIT",
|
| 1438 |
+
"dependencies": {
|
| 1439 |
+
"fdir": "^6.5.0",
|
| 1440 |
+
"picomatch": "^4.0.3"
|
| 1441 |
+
},
|
| 1442 |
+
"engines": {
|
| 1443 |
+
"node": ">=12.0.0"
|
| 1444 |
+
},
|
| 1445 |
+
"funding": {
|
| 1446 |
+
"url": "https://github.com/sponsors/SuperchupuDev"
|
| 1447 |
+
}
|
| 1448 |
+
},
|
| 1449 |
+
"node_modules/tldts": {
|
| 1450 |
+
"version": "7.0.17",
|
| 1451 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/tldts/-/tldts-7.0.17.tgz",
|
| 1452 |
+
"integrity": "sha512-Y1KQBgDd/NUc+LfOtKS6mNsC9CCaH+m2P1RoIZy7RAPo3C3/t8X45+zgut31cRZtZ3xKPjfn3TkGTrctC2TQIQ==",
|
| 1453 |
+
"license": "MIT",
|
| 1454 |
+
"dependencies": {
|
| 1455 |
+
"tldts-core": "^7.0.17"
|
| 1456 |
+
},
|
| 1457 |
+
"bin": {
|
| 1458 |
+
"tldts": "bin/cli.js"
|
| 1459 |
+
}
|
| 1460 |
+
},
|
| 1461 |
+
"node_modules/tldts-core": {
|
| 1462 |
+
"version": "7.0.17",
|
| 1463 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/tldts-core/-/tldts-core-7.0.17.tgz",
|
| 1464 |
+
"integrity": "sha512-DieYoGrP78PWKsrXr8MZwtQ7GLCUeLxihtjC1jZsW1DnvSMdKPitJSe8OSYDM2u5H6g3kWJZpePqkp43TfLh0g==",
|
| 1465 |
+
"license": "MIT"
|
| 1466 |
+
},
|
| 1467 |
+
"node_modules/tough-cookie": {
|
| 1468 |
+
"version": "6.0.0",
|
| 1469 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/tough-cookie/-/tough-cookie-6.0.0.tgz",
|
| 1470 |
+
"integrity": "sha512-kXuRi1mtaKMrsLUxz3sQYvVl37B0Ns6MzfrtV5DvJceE9bPyspOqk9xxv7XbZWcfLWbFmm997vl83qUWVJA64w==",
|
| 1471 |
+
"license": "BSD-3-Clause",
|
| 1472 |
+
"dependencies": {
|
| 1473 |
+
"tldts": "^7.0.5"
|
| 1474 |
+
},
|
| 1475 |
+
"engines": {
|
| 1476 |
+
"node": ">=16"
|
| 1477 |
+
}
|
| 1478 |
+
},
|
| 1479 |
+
"node_modules/type-fest": {
|
| 1480 |
+
"version": "4.41.0",
|
| 1481 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/type-fest/-/type-fest-4.41.0.tgz",
|
| 1482 |
+
"integrity": "sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==",
|
| 1483 |
+
"license": "(MIT OR CC0-1.0)",
|
| 1484 |
+
"engines": {
|
| 1485 |
+
"node": ">=16"
|
| 1486 |
+
},
|
| 1487 |
+
"funding": {
|
| 1488 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
| 1489 |
+
}
|
| 1490 |
+
},
|
| 1491 |
+
"node_modules/typescript": {
|
| 1492 |
+
"version": "5.9.3",
|
| 1493 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/typescript/-/typescript-5.9.3.tgz",
|
| 1494 |
+
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
| 1495 |
+
"license": "Apache-2.0",
|
| 1496 |
+
"bin": {
|
| 1497 |
+
"tsc": "bin/tsc",
|
| 1498 |
+
"tsserver": "bin/tsserver"
|
| 1499 |
+
},
|
| 1500 |
+
"engines": {
|
| 1501 |
+
"node": ">=14.17"
|
| 1502 |
+
}
|
| 1503 |
+
},
|
| 1504 |
+
"node_modules/undici-types": {
|
| 1505 |
+
"version": "7.14.0",
|
| 1506 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/undici-types/-/undici-types-7.14.0.tgz",
|
| 1507 |
+
"integrity": "sha512-QQiYxHuyZ9gQUIrmPo3IA+hUl4KYk8uSA7cHrcKd/l3p1OTpZcM0Tbp9x7FAtXdAYhlasd60ncPpgu6ihG6TOA==",
|
| 1508 |
+
"devOptional": true,
|
| 1509 |
+
"license": "MIT"
|
| 1510 |
+
},
|
| 1511 |
+
"node_modules/until-async": {
|
| 1512 |
+
"version": "3.0.2",
|
| 1513 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/until-async/-/until-async-3.0.2.tgz",
|
| 1514 |
+
"integrity": "sha512-IiSk4HlzAMqTUseHHe3VhIGyuFmN90zMTpD3Z3y8jeQbzLIq500MVM7Jq2vUAnTKAFPJrqwkzr6PoTcPhGcOiw==",
|
| 1515 |
+
"license": "MIT",
|
| 1516 |
+
"funding": {
|
| 1517 |
+
"url": "https://github.com/sponsors/kettanaito"
|
| 1518 |
+
}
|
| 1519 |
+
},
|
| 1520 |
+
"node_modules/vi": {
|
| 1521 |
+
"version": "1.0.0",
|
| 1522 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/vi/-/vi-1.0.0.tgz",
|
| 1523 |
+
"integrity": "sha512-fLpBeQzBddayFzoNMfCzvkcomwRYHx05qRo8lVCjMmR8ggs36Auw5A6/yH/UU8e2UAsGvh0qmXlNoR1DIdfWUw==",
|
| 1524 |
+
"license": "ISC"
|
| 1525 |
+
},
|
| 1526 |
+
"node_modules/vite": {
|
| 1527 |
+
"version": "6.4.1",
|
| 1528 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/vite/-/vite-6.4.1.tgz",
|
| 1529 |
+
"integrity": "sha512-+Oxm7q9hDoLMyJOYfUYBuHQo+dkAloi33apOPP56pzj+vsdJDzr+j1NISE5pyaAuKL4A3UD34qd0lx5+kfKp2g==",
|
| 1530 |
+
"license": "MIT",
|
| 1531 |
+
"dependencies": {
|
| 1532 |
+
"esbuild": "^0.25.0",
|
| 1533 |
+
"fdir": "^6.4.4",
|
| 1534 |
+
"picomatch": "^4.0.2",
|
| 1535 |
+
"postcss": "^8.5.3",
|
| 1536 |
+
"rollup": "^4.34.9",
|
| 1537 |
+
"tinyglobby": "^0.2.13"
|
| 1538 |
+
},
|
| 1539 |
+
"bin": {
|
| 1540 |
+
"vite": "bin/vite.js"
|
| 1541 |
+
},
|
| 1542 |
+
"engines": {
|
| 1543 |
+
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
|
| 1544 |
+
},
|
| 1545 |
+
"funding": {
|
| 1546 |
+
"url": "https://github.com/vitejs/vite?sponsor=1"
|
| 1547 |
+
},
|
| 1548 |
+
"optionalDependencies": {
|
| 1549 |
+
"fsevents": "~2.3.3"
|
| 1550 |
+
},
|
| 1551 |
+
"peerDependencies": {
|
| 1552 |
+
"@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
|
| 1553 |
+
"jiti": ">=1.21.0",
|
| 1554 |
+
"less": "*",
|
| 1555 |
+
"lightningcss": "^1.21.0",
|
| 1556 |
+
"sass": "*",
|
| 1557 |
+
"sass-embedded": "*",
|
| 1558 |
+
"stylus": "*",
|
| 1559 |
+
"sugarss": "*",
|
| 1560 |
+
"terser": "^5.16.0",
|
| 1561 |
+
"tsx": "^4.8.1",
|
| 1562 |
+
"yaml": "^2.4.2"
|
| 1563 |
+
},
|
| 1564 |
+
"peerDependenciesMeta": {
|
| 1565 |
+
"@types/node": {
|
| 1566 |
+
"optional": true
|
| 1567 |
+
},
|
| 1568 |
+
"jiti": {
|
| 1569 |
+
"optional": true
|
| 1570 |
+
},
|
| 1571 |
+
"less": {
|
| 1572 |
+
"optional": true
|
| 1573 |
+
},
|
| 1574 |
+
"lightningcss": {
|
| 1575 |
+
"optional": true
|
| 1576 |
+
},
|
| 1577 |
+
"sass": {
|
| 1578 |
+
"optional": true
|
| 1579 |
+
},
|
| 1580 |
+
"sass-embedded": {
|
| 1581 |
+
"optional": true
|
| 1582 |
+
},
|
| 1583 |
+
"stylus": {
|
| 1584 |
+
"optional": true
|
| 1585 |
+
},
|
| 1586 |
+
"sugarss": {
|
| 1587 |
+
"optional": true
|
| 1588 |
+
},
|
| 1589 |
+
"terser": {
|
| 1590 |
+
"optional": true
|
| 1591 |
+
},
|
| 1592 |
+
"tsx": {
|
| 1593 |
+
"optional": true
|
| 1594 |
+
},
|
| 1595 |
+
"yaml": {
|
| 1596 |
+
"optional": true
|
| 1597 |
+
}
|
| 1598 |
+
}
|
| 1599 |
+
},
|
| 1600 |
+
"node_modules/vite/node_modules/@esbuild/aix-ppc64": {
|
| 1601 |
+
"version": "0.25.11",
|
| 1602 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/aix-ppc64/-/aix-ppc64-0.25.11.tgz",
|
| 1603 |
+
"integrity": "sha512-Xt1dOL13m8u0WE8iplx9Ibbm+hFAO0GsU2P34UNoDGvZYkY8ifSiy6Zuc1lYxfG7svWE2fzqCUmFp5HCn51gJg==",
|
| 1604 |
+
"cpu": [
|
| 1605 |
+
"ppc64"
|
| 1606 |
+
],
|
| 1607 |
+
"license": "MIT",
|
| 1608 |
+
"optional": true,
|
| 1609 |
+
"os": [
|
| 1610 |
+
"aix"
|
| 1611 |
+
],
|
| 1612 |
+
"engines": {
|
| 1613 |
+
"node": ">=18"
|
| 1614 |
+
}
|
| 1615 |
+
},
|
| 1616 |
+
"node_modules/vite/node_modules/@esbuild/android-arm": {
|
| 1617 |
+
"version": "0.25.11",
|
| 1618 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/android-arm/-/android-arm-0.25.11.tgz",
|
| 1619 |
+
"integrity": "sha512-uoa7dU+Dt3HYsethkJ1k6Z9YdcHjTrSb5NUy66ZfZaSV8hEYGD5ZHbEMXnqLFlbBflLsl89Zke7CAdDJ4JI+Gg==",
|
| 1620 |
+
"cpu": [
|
| 1621 |
+
"arm"
|
| 1622 |
+
],
|
| 1623 |
+
"license": "MIT",
|
| 1624 |
+
"optional": true,
|
| 1625 |
+
"os": [
|
| 1626 |
+
"android"
|
| 1627 |
+
],
|
| 1628 |
+
"engines": {
|
| 1629 |
+
"node": ">=18"
|
| 1630 |
+
}
|
| 1631 |
+
},
|
| 1632 |
+
"node_modules/vite/node_modules/@esbuild/android-arm64": {
|
| 1633 |
+
"version": "0.25.11",
|
| 1634 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/android-arm64/-/android-arm64-0.25.11.tgz",
|
| 1635 |
+
"integrity": "sha512-9slpyFBc4FPPz48+f6jyiXOx/Y4v34TUeDDXJpZqAWQn/08lKGeD8aDp9TMn9jDz2CiEuHwfhRmGBvpnd/PWIQ==",
|
| 1636 |
+
"cpu": [
|
| 1637 |
+
"arm64"
|
| 1638 |
+
],
|
| 1639 |
+
"license": "MIT",
|
| 1640 |
+
"optional": true,
|
| 1641 |
+
"os": [
|
| 1642 |
+
"android"
|
| 1643 |
+
],
|
| 1644 |
+
"engines": {
|
| 1645 |
+
"node": ">=18"
|
| 1646 |
+
}
|
| 1647 |
+
},
|
| 1648 |
+
"node_modules/vite/node_modules/@esbuild/android-x64": {
|
| 1649 |
+
"version": "0.25.11",
|
| 1650 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/android-x64/-/android-x64-0.25.11.tgz",
|
| 1651 |
+
"integrity": "sha512-Sgiab4xBjPU1QoPEIqS3Xx+R2lezu0LKIEcYe6pftr56PqPygbB7+szVnzoShbx64MUupqoE0KyRlN7gezbl8g==",
|
| 1652 |
+
"cpu": [
|
| 1653 |
+
"x64"
|
| 1654 |
+
],
|
| 1655 |
+
"license": "MIT",
|
| 1656 |
+
"optional": true,
|
| 1657 |
+
"os": [
|
| 1658 |
+
"android"
|
| 1659 |
+
],
|
| 1660 |
+
"engines": {
|
| 1661 |
+
"node": ">=18"
|
| 1662 |
+
}
|
| 1663 |
+
},
|
| 1664 |
+
"node_modules/vite/node_modules/@esbuild/darwin-arm64": {
|
| 1665 |
+
"version": "0.25.11",
|
| 1666 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/darwin-arm64/-/darwin-arm64-0.25.11.tgz",
|
| 1667 |
+
"integrity": "sha512-VekY0PBCukppoQrycFxUqkCojnTQhdec0vevUL/EDOCnXd9LKWqD/bHwMPzigIJXPhC59Vd1WFIL57SKs2mg4w==",
|
| 1668 |
+
"cpu": [
|
| 1669 |
+
"arm64"
|
| 1670 |
+
],
|
| 1671 |
+
"license": "MIT",
|
| 1672 |
+
"optional": true,
|
| 1673 |
+
"os": [
|
| 1674 |
+
"darwin"
|
| 1675 |
+
],
|
| 1676 |
+
"engines": {
|
| 1677 |
+
"node": ">=18"
|
| 1678 |
+
}
|
| 1679 |
+
},
|
| 1680 |
+
"node_modules/vite/node_modules/@esbuild/darwin-x64": {
|
| 1681 |
+
"version": "0.25.11",
|
| 1682 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/darwin-x64/-/darwin-x64-0.25.11.tgz",
|
| 1683 |
+
"integrity": "sha512-+hfp3yfBalNEpTGp9loYgbknjR695HkqtY3d3/JjSRUyPg/xd6q+mQqIb5qdywnDxRZykIHs3axEqU6l1+oWEQ==",
|
| 1684 |
+
"cpu": [
|
| 1685 |
+
"x64"
|
| 1686 |
+
],
|
| 1687 |
+
"license": "MIT",
|
| 1688 |
+
"optional": true,
|
| 1689 |
+
"os": [
|
| 1690 |
+
"darwin"
|
| 1691 |
+
],
|
| 1692 |
+
"engines": {
|
| 1693 |
+
"node": ">=18"
|
| 1694 |
+
}
|
| 1695 |
+
},
|
| 1696 |
+
"node_modules/vite/node_modules/@esbuild/freebsd-arm64": {
|
| 1697 |
+
"version": "0.25.11",
|
| 1698 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.11.tgz",
|
| 1699 |
+
"integrity": "sha512-CmKjrnayyTJF2eVuO//uSjl/K3KsMIeYeyN7FyDBjsR3lnSJHaXlVoAK8DZa7lXWChbuOk7NjAc7ygAwrnPBhA==",
|
| 1700 |
+
"cpu": [
|
| 1701 |
+
"arm64"
|
| 1702 |
+
],
|
| 1703 |
+
"license": "MIT",
|
| 1704 |
+
"optional": true,
|
| 1705 |
+
"os": [
|
| 1706 |
+
"freebsd"
|
| 1707 |
+
],
|
| 1708 |
+
"engines": {
|
| 1709 |
+
"node": ">=18"
|
| 1710 |
+
}
|
| 1711 |
+
},
|
| 1712 |
+
"node_modules/vite/node_modules/@esbuild/freebsd-x64": {
|
| 1713 |
+
"version": "0.25.11",
|
| 1714 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/freebsd-x64/-/freebsd-x64-0.25.11.tgz",
|
| 1715 |
+
"integrity": "sha512-Dyq+5oscTJvMaYPvW3x3FLpi2+gSZTCE/1ffdwuM6G1ARang/mb3jvjxs0mw6n3Lsw84ocfo9CrNMqc5lTfGOw==",
|
| 1716 |
+
"cpu": [
|
| 1717 |
+
"x64"
|
| 1718 |
+
],
|
| 1719 |
+
"license": "MIT",
|
| 1720 |
+
"optional": true,
|
| 1721 |
+
"os": [
|
| 1722 |
+
"freebsd"
|
| 1723 |
+
],
|
| 1724 |
+
"engines": {
|
| 1725 |
+
"node": ">=18"
|
| 1726 |
+
}
|
| 1727 |
+
},
|
| 1728 |
+
"node_modules/vite/node_modules/@esbuild/linux-arm": {
|
| 1729 |
+
"version": "0.25.11",
|
| 1730 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-arm/-/linux-arm-0.25.11.tgz",
|
| 1731 |
+
"integrity": "sha512-TBMv6B4kCfrGJ8cUPo7vd6NECZH/8hPpBHHlYI3qzoYFvWu2AdTvZNuU/7hsbKWqu/COU7NIK12dHAAqBLLXgw==",
|
| 1732 |
+
"cpu": [
|
| 1733 |
+
"arm"
|
| 1734 |
+
],
|
| 1735 |
+
"license": "MIT",
|
| 1736 |
+
"optional": true,
|
| 1737 |
+
"os": [
|
| 1738 |
+
"linux"
|
| 1739 |
+
],
|
| 1740 |
+
"engines": {
|
| 1741 |
+
"node": ">=18"
|
| 1742 |
+
}
|
| 1743 |
+
},
|
| 1744 |
+
"node_modules/vite/node_modules/@esbuild/linux-arm64": {
|
| 1745 |
+
"version": "0.25.11",
|
| 1746 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-arm64/-/linux-arm64-0.25.11.tgz",
|
| 1747 |
+
"integrity": "sha512-Qr8AzcplUhGvdyUF08A1kHU3Vr2O88xxP0Tm8GcdVOUm25XYcMPp2YqSVHbLuXzYQMf9Bh/iKx7YPqECs6ffLA==",
|
| 1748 |
+
"cpu": [
|
| 1749 |
+
"arm64"
|
| 1750 |
+
],
|
| 1751 |
+
"license": "MIT",
|
| 1752 |
+
"optional": true,
|
| 1753 |
+
"os": [
|
| 1754 |
+
"linux"
|
| 1755 |
+
],
|
| 1756 |
+
"engines": {
|
| 1757 |
+
"node": ">=18"
|
| 1758 |
+
}
|
| 1759 |
+
},
|
| 1760 |
+
"node_modules/vite/node_modules/@esbuild/linux-ia32": {
|
| 1761 |
+
"version": "0.25.11",
|
| 1762 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-ia32/-/linux-ia32-0.25.11.tgz",
|
| 1763 |
+
"integrity": "sha512-TmnJg8BMGPehs5JKrCLqyWTVAvielc615jbkOirATQvWWB1NMXY77oLMzsUjRLa0+ngecEmDGqt5jiDC6bfvOw==",
|
| 1764 |
+
"cpu": [
|
| 1765 |
+
"ia32"
|
| 1766 |
+
],
|
| 1767 |
+
"license": "MIT",
|
| 1768 |
+
"optional": true,
|
| 1769 |
+
"os": [
|
| 1770 |
+
"linux"
|
| 1771 |
+
],
|
| 1772 |
+
"engines": {
|
| 1773 |
+
"node": ">=18"
|
| 1774 |
+
}
|
| 1775 |
+
},
|
| 1776 |
+
"node_modules/vite/node_modules/@esbuild/linux-loong64": {
|
| 1777 |
+
"version": "0.25.11",
|
| 1778 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-loong64/-/linux-loong64-0.25.11.tgz",
|
| 1779 |
+
"integrity": "sha512-DIGXL2+gvDaXlaq8xruNXUJdT5tF+SBbJQKbWy/0J7OhU8gOHOzKmGIlfTTl6nHaCOoipxQbuJi7O++ldrxgMw==",
|
| 1780 |
+
"cpu": [
|
| 1781 |
+
"loong64"
|
| 1782 |
+
],
|
| 1783 |
+
"license": "MIT",
|
| 1784 |
+
"optional": true,
|
| 1785 |
+
"os": [
|
| 1786 |
+
"linux"
|
| 1787 |
+
],
|
| 1788 |
+
"engines": {
|
| 1789 |
+
"node": ">=18"
|
| 1790 |
+
}
|
| 1791 |
+
},
|
| 1792 |
+
"node_modules/vite/node_modules/@esbuild/linux-mips64el": {
|
| 1793 |
+
"version": "0.25.11",
|
| 1794 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-mips64el/-/linux-mips64el-0.25.11.tgz",
|
| 1795 |
+
"integrity": "sha512-Osx1nALUJu4pU43o9OyjSCXokFkFbyzjXb6VhGIJZQ5JZi8ylCQ9/LFagolPsHtgw6himDSyb5ETSfmp4rpiKQ==",
|
| 1796 |
+
"cpu": [
|
| 1797 |
+
"mips64el"
|
| 1798 |
+
],
|
| 1799 |
+
"license": "MIT",
|
| 1800 |
+
"optional": true,
|
| 1801 |
+
"os": [
|
| 1802 |
+
"linux"
|
| 1803 |
+
],
|
| 1804 |
+
"engines": {
|
| 1805 |
+
"node": ">=18"
|
| 1806 |
+
}
|
| 1807 |
+
},
|
| 1808 |
+
"node_modules/vite/node_modules/@esbuild/linux-ppc64": {
|
| 1809 |
+
"version": "0.25.11",
|
| 1810 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-ppc64/-/linux-ppc64-0.25.11.tgz",
|
| 1811 |
+
"integrity": "sha512-nbLFgsQQEsBa8XSgSTSlrnBSrpoWh7ioFDUmwo158gIm5NNP+17IYmNWzaIzWmgCxq56vfr34xGkOcZ7jX6CPw==",
|
| 1812 |
+
"cpu": [
|
| 1813 |
+
"ppc64"
|
| 1814 |
+
],
|
| 1815 |
+
"license": "MIT",
|
| 1816 |
+
"optional": true,
|
| 1817 |
+
"os": [
|
| 1818 |
+
"linux"
|
| 1819 |
+
],
|
| 1820 |
+
"engines": {
|
| 1821 |
+
"node": ">=18"
|
| 1822 |
+
}
|
| 1823 |
+
},
|
| 1824 |
+
"node_modules/vite/node_modules/@esbuild/linux-riscv64": {
|
| 1825 |
+
"version": "0.25.11",
|
| 1826 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-riscv64/-/linux-riscv64-0.25.11.tgz",
|
| 1827 |
+
"integrity": "sha512-HfyAmqZi9uBAbgKYP1yGuI7tSREXwIb438q0nqvlpxAOs3XnZ8RsisRfmVsgV486NdjD7Mw2UrFSw51lzUk1ww==",
|
| 1828 |
+
"cpu": [
|
| 1829 |
+
"riscv64"
|
| 1830 |
+
],
|
| 1831 |
+
"license": "MIT",
|
| 1832 |
+
"optional": true,
|
| 1833 |
+
"os": [
|
| 1834 |
+
"linux"
|
| 1835 |
+
],
|
| 1836 |
+
"engines": {
|
| 1837 |
+
"node": ">=18"
|
| 1838 |
+
}
|
| 1839 |
+
},
|
| 1840 |
+
"node_modules/vite/node_modules/@esbuild/linux-s390x": {
|
| 1841 |
+
"version": "0.25.11",
|
| 1842 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-s390x/-/linux-s390x-0.25.11.tgz",
|
| 1843 |
+
"integrity": "sha512-HjLqVgSSYnVXRisyfmzsH6mXqyvj0SA7pG5g+9W7ESgwA70AXYNpfKBqh1KbTxmQVaYxpzA/SvlB9oclGPbApw==",
|
| 1844 |
+
"cpu": [
|
| 1845 |
+
"s390x"
|
| 1846 |
+
],
|
| 1847 |
+
"license": "MIT",
|
| 1848 |
+
"optional": true,
|
| 1849 |
+
"os": [
|
| 1850 |
+
"linux"
|
| 1851 |
+
],
|
| 1852 |
+
"engines": {
|
| 1853 |
+
"node": ">=18"
|
| 1854 |
+
}
|
| 1855 |
+
},
|
| 1856 |
+
"node_modules/vite/node_modules/@esbuild/linux-x64": {
|
| 1857 |
+
"version": "0.25.11",
|
| 1858 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/linux-x64/-/linux-x64-0.25.11.tgz",
|
| 1859 |
+
"integrity": "sha512-HSFAT4+WYjIhrHxKBwGmOOSpphjYkcswF449j6EjsjbinTZbp8PJtjsVK1XFJStdzXdy/jaddAep2FGY+wyFAQ==",
|
| 1860 |
+
"cpu": [
|
| 1861 |
+
"x64"
|
| 1862 |
+
],
|
| 1863 |
+
"license": "MIT",
|
| 1864 |
+
"optional": true,
|
| 1865 |
+
"os": [
|
| 1866 |
+
"linux"
|
| 1867 |
+
],
|
| 1868 |
+
"engines": {
|
| 1869 |
+
"node": ">=18"
|
| 1870 |
+
}
|
| 1871 |
+
},
|
| 1872 |
+
"node_modules/vite/node_modules/@esbuild/netbsd-x64": {
|
| 1873 |
+
"version": "0.25.11",
|
| 1874 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/netbsd-x64/-/netbsd-x64-0.25.11.tgz",
|
| 1875 |
+
"integrity": "sha512-u7tKA+qbzBydyj0vgpu+5h5AeudxOAGncb8N6C9Kh1N4n7wU1Xw1JDApsRjpShRpXRQlJLb9wY28ELpwdPcZ7A==",
|
| 1876 |
+
"cpu": [
|
| 1877 |
+
"x64"
|
| 1878 |
+
],
|
| 1879 |
+
"license": "MIT",
|
| 1880 |
+
"optional": true,
|
| 1881 |
+
"os": [
|
| 1882 |
+
"netbsd"
|
| 1883 |
+
],
|
| 1884 |
+
"engines": {
|
| 1885 |
+
"node": ">=18"
|
| 1886 |
+
}
|
| 1887 |
+
},
|
| 1888 |
+
"node_modules/vite/node_modules/@esbuild/openbsd-x64": {
|
| 1889 |
+
"version": "0.25.11",
|
| 1890 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/openbsd-x64/-/openbsd-x64-0.25.11.tgz",
|
| 1891 |
+
"integrity": "sha512-CN+7c++kkbrckTOz5hrehxWN7uIhFFlmS/hqziSFVWpAzpWrQoAG4chH+nN3Be+Kzv/uuo7zhX716x3Sn2Jduw==",
|
| 1892 |
+
"cpu": [
|
| 1893 |
+
"x64"
|
| 1894 |
+
],
|
| 1895 |
+
"license": "MIT",
|
| 1896 |
+
"optional": true,
|
| 1897 |
+
"os": [
|
| 1898 |
+
"openbsd"
|
| 1899 |
+
],
|
| 1900 |
+
"engines": {
|
| 1901 |
+
"node": ">=18"
|
| 1902 |
+
}
|
| 1903 |
+
},
|
| 1904 |
+
"node_modules/vite/node_modules/@esbuild/sunos-x64": {
|
| 1905 |
+
"version": "0.25.11",
|
| 1906 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/sunos-x64/-/sunos-x64-0.25.11.tgz",
|
| 1907 |
+
"integrity": "sha512-nq2xdYaWxyg9DcIyXkZhcYulC6pQ2FuCgem3LI92IwMgIZ69KHeY8T4Y88pcwoLIjbed8n36CyKoYRDygNSGhA==",
|
| 1908 |
+
"cpu": [
|
| 1909 |
+
"x64"
|
| 1910 |
+
],
|
| 1911 |
+
"license": "MIT",
|
| 1912 |
+
"optional": true,
|
| 1913 |
+
"os": [
|
| 1914 |
+
"sunos"
|
| 1915 |
+
],
|
| 1916 |
+
"engines": {
|
| 1917 |
+
"node": ">=18"
|
| 1918 |
+
}
|
| 1919 |
+
},
|
| 1920 |
+
"node_modules/vite/node_modules/@esbuild/win32-arm64": {
|
| 1921 |
+
"version": "0.25.11",
|
| 1922 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/win32-arm64/-/win32-arm64-0.25.11.tgz",
|
| 1923 |
+
"integrity": "sha512-3XxECOWJq1qMZ3MN8srCJ/QfoLpL+VaxD/WfNRm1O3B4+AZ/BnLVgFbUV3eiRYDMXetciH16dwPbbHqwe1uU0Q==",
|
| 1924 |
+
"cpu": [
|
| 1925 |
+
"arm64"
|
| 1926 |
+
],
|
| 1927 |
+
"license": "MIT",
|
| 1928 |
+
"optional": true,
|
| 1929 |
+
"os": [
|
| 1930 |
+
"win32"
|
| 1931 |
+
],
|
| 1932 |
+
"engines": {
|
| 1933 |
+
"node": ">=18"
|
| 1934 |
+
}
|
| 1935 |
+
},
|
| 1936 |
+
"node_modules/vite/node_modules/@esbuild/win32-ia32": {
|
| 1937 |
+
"version": "0.25.11",
|
| 1938 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/win32-ia32/-/win32-ia32-0.25.11.tgz",
|
| 1939 |
+
"integrity": "sha512-3ukss6gb9XZ8TlRyJlgLn17ecsK4NSQTmdIXRASVsiS2sQ6zPPZklNJT5GR5tE/MUarymmy8kCEf5xPCNCqVOA==",
|
| 1940 |
+
"cpu": [
|
| 1941 |
+
"ia32"
|
| 1942 |
+
],
|
| 1943 |
+
"license": "MIT",
|
| 1944 |
+
"optional": true,
|
| 1945 |
+
"os": [
|
| 1946 |
+
"win32"
|
| 1947 |
+
],
|
| 1948 |
+
"engines": {
|
| 1949 |
+
"node": ">=18"
|
| 1950 |
+
}
|
| 1951 |
+
},
|
| 1952 |
+
"node_modules/vite/node_modules/@esbuild/win32-x64": {
|
| 1953 |
+
"version": "0.25.11",
|
| 1954 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/@esbuild/win32-x64/-/win32-x64-0.25.11.tgz",
|
| 1955 |
+
"integrity": "sha512-D7Hpz6A2L4hzsRpPaCYkQnGOotdUpDzSGRIv9I+1ITdHROSFUWW95ZPZWQmGka1Fg7W3zFJowyn9WGwMJ0+KPA==",
|
| 1956 |
+
"cpu": [
|
| 1957 |
+
"x64"
|
| 1958 |
+
],
|
| 1959 |
+
"license": "MIT",
|
| 1960 |
+
"optional": true,
|
| 1961 |
+
"os": [
|
| 1962 |
+
"win32"
|
| 1963 |
+
],
|
| 1964 |
+
"engines": {
|
| 1965 |
+
"node": ">=18"
|
| 1966 |
+
}
|
| 1967 |
+
},
|
| 1968 |
+
"node_modules/vite/node_modules/esbuild": {
|
| 1969 |
+
"version": "0.25.11",
|
| 1970 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/esbuild/-/esbuild-0.25.11.tgz",
|
| 1971 |
+
"integrity": "sha512-KohQwyzrKTQmhXDW1PjCv3Tyspn9n5GcY2RTDqeORIdIJY8yKIF7sTSopFmn/wpMPW4rdPXI0UE5LJLuq3bx0Q==",
|
| 1972 |
+
"hasInstallScript": true,
|
| 1973 |
+
"license": "MIT",
|
| 1974 |
+
"bin": {
|
| 1975 |
+
"esbuild": "bin/esbuild"
|
| 1976 |
+
},
|
| 1977 |
+
"engines": {
|
| 1978 |
+
"node": ">=18"
|
| 1979 |
+
},
|
| 1980 |
+
"optionalDependencies": {
|
| 1981 |
+
"@esbuild/aix-ppc64": "0.25.11",
|
| 1982 |
+
"@esbuild/android-arm": "0.25.11",
|
| 1983 |
+
"@esbuild/android-arm64": "0.25.11",
|
| 1984 |
+
"@esbuild/android-x64": "0.25.11",
|
| 1985 |
+
"@esbuild/darwin-arm64": "0.25.11",
|
| 1986 |
+
"@esbuild/darwin-x64": "0.25.11",
|
| 1987 |
+
"@esbuild/freebsd-arm64": "0.25.11",
|
| 1988 |
+
"@esbuild/freebsd-x64": "0.25.11",
|
| 1989 |
+
"@esbuild/linux-arm": "0.25.11",
|
| 1990 |
+
"@esbuild/linux-arm64": "0.25.11",
|
| 1991 |
+
"@esbuild/linux-ia32": "0.25.11",
|
| 1992 |
+
"@esbuild/linux-loong64": "0.25.11",
|
| 1993 |
+
"@esbuild/linux-mips64el": "0.25.11",
|
| 1994 |
+
"@esbuild/linux-ppc64": "0.25.11",
|
| 1995 |
+
"@esbuild/linux-riscv64": "0.25.11",
|
| 1996 |
+
"@esbuild/linux-s390x": "0.25.11",
|
| 1997 |
+
"@esbuild/linux-x64": "0.25.11",
|
| 1998 |
+
"@esbuild/netbsd-arm64": "0.25.11",
|
| 1999 |
+
"@esbuild/netbsd-x64": "0.25.11",
|
| 2000 |
+
"@esbuild/openbsd-arm64": "0.25.11",
|
| 2001 |
+
"@esbuild/openbsd-x64": "0.25.11",
|
| 2002 |
+
"@esbuild/openharmony-arm64": "0.25.11",
|
| 2003 |
+
"@esbuild/sunos-x64": "0.25.11",
|
| 2004 |
+
"@esbuild/win32-arm64": "0.25.11",
|
| 2005 |
+
"@esbuild/win32-ia32": "0.25.11",
|
| 2006 |
+
"@esbuild/win32-x64": "0.25.11"
|
| 2007 |
+
}
|
| 2008 |
+
},
|
| 2009 |
+
"node_modules/wrap-ansi": {
|
| 2010 |
+
"version": "6.2.0",
|
| 2011 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
|
| 2012 |
+
"integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
|
| 2013 |
+
"license": "MIT",
|
| 2014 |
+
"dependencies": {
|
| 2015 |
+
"ansi-styles": "^4.0.0",
|
| 2016 |
+
"string-width": "^4.1.0",
|
| 2017 |
+
"strip-ansi": "^6.0.0"
|
| 2018 |
+
},
|
| 2019 |
+
"engines": {
|
| 2020 |
+
"node": ">=8"
|
| 2021 |
+
}
|
| 2022 |
+
},
|
| 2023 |
+
"node_modules/ws": {
|
| 2024 |
+
"version": "8.18.3",
|
| 2025 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/ws/-/ws-8.18.3.tgz",
|
| 2026 |
+
"integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==",
|
| 2027 |
+
"license": "MIT",
|
| 2028 |
+
"engines": {
|
| 2029 |
+
"node": ">=10.0.0"
|
| 2030 |
+
},
|
| 2031 |
+
"peerDependencies": {
|
| 2032 |
+
"bufferutil": "^4.0.1",
|
| 2033 |
+
"utf-8-validate": ">=5.0.2"
|
| 2034 |
+
},
|
| 2035 |
+
"peerDependenciesMeta": {
|
| 2036 |
+
"bufferutil": {
|
| 2037 |
+
"optional": true
|
| 2038 |
+
},
|
| 2039 |
+
"utf-8-validate": {
|
| 2040 |
+
"optional": true
|
| 2041 |
+
}
|
| 2042 |
+
}
|
| 2043 |
+
},
|
| 2044 |
+
"node_modules/y18n": {
|
| 2045 |
+
"version": "5.0.8",
|
| 2046 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/y18n/-/y18n-5.0.8.tgz",
|
| 2047 |
+
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
|
| 2048 |
+
"license": "ISC",
|
| 2049 |
+
"engines": {
|
| 2050 |
+
"node": ">=10"
|
| 2051 |
+
}
|
| 2052 |
+
},
|
| 2053 |
+
"node_modules/yargs": {
|
| 2054 |
+
"version": "17.7.2",
|
| 2055 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/yargs/-/yargs-17.7.2.tgz",
|
| 2056 |
+
"integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",
|
| 2057 |
+
"license": "MIT",
|
| 2058 |
+
"dependencies": {
|
| 2059 |
+
"cliui": "^8.0.1",
|
| 2060 |
+
"escalade": "^3.1.1",
|
| 2061 |
+
"get-caller-file": "^2.0.5",
|
| 2062 |
+
"require-directory": "^2.1.1",
|
| 2063 |
+
"string-width": "^4.2.3",
|
| 2064 |
+
"y18n": "^5.0.5",
|
| 2065 |
+
"yargs-parser": "^21.1.1"
|
| 2066 |
+
},
|
| 2067 |
+
"engines": {
|
| 2068 |
+
"node": ">=12"
|
| 2069 |
+
}
|
| 2070 |
+
},
|
| 2071 |
+
"node_modules/yargs-parser": {
|
| 2072 |
+
"version": "21.1.1",
|
| 2073 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/yargs-parser/-/yargs-parser-21.1.1.tgz",
|
| 2074 |
+
"integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
|
| 2075 |
+
"license": "ISC",
|
| 2076 |
+
"engines": {
|
| 2077 |
+
"node": ">=12"
|
| 2078 |
+
}
|
| 2079 |
+
},
|
| 2080 |
+
"node_modules/yoctocolors-cjs": {
|
| 2081 |
+
"version": "2.1.3",
|
| 2082 |
+
"resolved": "https://repos.verz.local/artifactory/api/npm/npm/yoctocolors-cjs/-/yoctocolors-cjs-2.1.3.tgz",
|
| 2083 |
+
"integrity": "sha512-U/PBtDf35ff0D8X8D0jfdzHYEPFxAI7jJlxZXwCSez5M3190m+QobIfh+sWDWSHMCWWJN2AWamkegn6vr6YBTw==",
|
| 2084 |
+
"license": "MIT",
|
| 2085 |
+
"engines": {
|
| 2086 |
+
"node": ">=18"
|
| 2087 |
+
},
|
| 2088 |
+
"funding": {
|
| 2089 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
| 2090 |
+
}
|
| 2091 |
+
}
|
| 2092 |
+
}
|
| 2093 |
+
}
|
6.29.1/client/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/client",
|
| 3 |
+
"version": "2.7.1",
|
| 4 |
+
"description": "Gradio API client",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"main": "dist/index.cjs",
|
| 7 |
+
"module": "dist/index.js",
|
| 8 |
+
"types": "dist/index.d.ts",
|
| 9 |
+
"author": "",
|
| 10 |
+
"license": "ISC",
|
| 11 |
+
"exports": {
|
| 12 |
+
".": {
|
| 13 |
+
"gradio": "./src/index.ts",
|
| 14 |
+
"types": "./dist/index.d.ts",
|
| 15 |
+
"browser": "./dist/browser.js",
|
| 16 |
+
"import": "./dist/index.js",
|
| 17 |
+
"require": "./dist/index.cjs",
|
| 18 |
+
"default": "./dist/index.js"
|
| 19 |
+
},
|
| 20 |
+
"./package.json": "./package.json",
|
| 21 |
+
"./browser.js": "./dist/browser.js",
|
| 22 |
+
"./dist/index.min.js": "./dist/index.min.js"
|
| 23 |
+
},
|
| 24 |
+
"dependencies": {
|
| 25 |
+
"fetch-event-stream": "^0.1.5"
|
| 26 |
+
},
|
| 27 |
+
"devDependencies": {
|
| 28 |
+
"msw": "^2.11.3",
|
| 29 |
+
"typescript": "^5.9.3"
|
| 30 |
+
},
|
| 31 |
+
"scripts": {
|
| 32 |
+
"bundle": "vite build --ssr",
|
| 33 |
+
"bundle:browser": "BROWSER_BUILD=true vite build",
|
| 34 |
+
"bundle:cdn": "BROWSER_BUILD=true CDN_BUILD=true vite build",
|
| 35 |
+
"generate_types": "tsc",
|
| 36 |
+
"clean": "rm -rf dist",
|
| 37 |
+
"build": "pnpm clean && pnpm bundle && pnpm bundle:browser && pnpm bundle:cdn && pnpm generate_types && pnpm verify_dist",
|
| 38 |
+
"verify_dist": "node scripts/verify_dist.mjs",
|
| 39 |
+
"test": "pnpm test:browser && pnpm test:node",
|
| 40 |
+
"test:browser": "vitest run -c vite.config.ts",
|
| 41 |
+
"test:node": "NODE_NO_WARNINGS=1 TEST_MODE=node vitest run -c vite.config.ts",
|
| 42 |
+
"preview:browser": "vite dev --mode=preview"
|
| 43 |
+
},
|
| 44 |
+
"engines": {
|
| 45 |
+
"node": ">=18.0.0"
|
| 46 |
+
},
|
| 47 |
+
"main_changeset": true,
|
| 48 |
+
"repository": {
|
| 49 |
+
"type": "git",
|
| 50 |
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 51 |
+
"directory": "client/js"
|
| 52 |
+
}
|
| 53 |
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type {
|
| 2 |
+
ApiData,
|
| 3 |
+
ApiInfo,
|
| 4 |
+
ClientOptions,
|
| 5 |
+
Config,
|
| 6 |
+
DuplicateOptions,
|
| 7 |
+
EndpointInfo,
|
| 8 |
+
JsApiData,
|
| 9 |
+
PredictReturn,
|
| 10 |
+
SpaceStatus,
|
| 11 |
+
Status,
|
| 12 |
+
UploadResponse,
|
| 13 |
+
client_return,
|
| 14 |
+
SubmitIterable,
|
| 15 |
+
GradioEvent
|
| 16 |
+
} from "./types";
|
| 17 |
+
import { view_api } from "./utils/view_api";
|
| 18 |
+
import { upload_files } from "./utils/upload_files";
|
| 19 |
+
import { upload, FileData } from "./upload";
|
| 20 |
+
import { handle_blob } from "./utils/handle_blob";
|
| 21 |
+
import { post_data } from "./utils/post_data";
|
| 22 |
+
import { predict } from "./utils/predict";
|
| 23 |
+
import { duplicate } from "./utils/duplicate";
|
| 24 |
+
import { submit } from "./utils/submit";
|
| 25 |
+
import { RE_SPACE_NAME, process_endpoint } from "./helpers/api_info";
|
| 26 |
+
import {
|
| 27 |
+
map_names_to_ids,
|
| 28 |
+
normalise_token_option,
|
| 29 |
+
resolve_cookies,
|
| 30 |
+
resolve_config,
|
| 31 |
+
get_jwt,
|
| 32 |
+
parse_and_set_cookies
|
| 33 |
+
} from "./helpers/init_helpers";
|
| 34 |
+
import { check_and_wake_space, check_space_status } from "./helpers/spaces";
|
| 35 |
+
import { initialize_zerogpu_handshake } from "./helpers/zerogpu";
|
| 36 |
+
import { open_stream, readable_stream, close_stream } from "./utils/stream";
|
| 37 |
+
import { clear_run_history } from "./utils/run_history";
|
| 38 |
+
import { sign_config_file_urls, sign_file_urls } from "./helpers/data";
|
| 39 |
+
import {
|
| 40 |
+
API_INFO_ERROR_MSG,
|
| 41 |
+
APP_ID_URL,
|
| 42 |
+
CONFIG_ERROR_MSG,
|
| 43 |
+
HEARTBEAT_URL,
|
| 44 |
+
COMPONENT_SERVER_URL
|
| 45 |
+
} from "./constants";
|
| 46 |
+
declare const BROWSER_BUILD: boolean;
|
| 47 |
+
|
| 48 |
+
export class Client {
|
| 49 |
+
app_reference: string;
|
| 50 |
+
options: ClientOptions;
|
| 51 |
+
deep_link: string | null = null;
|
| 52 |
+
page: string | null = null;
|
| 53 |
+
|
| 54 |
+
config: Config | undefined;
|
| 55 |
+
api_prefix = "";
|
| 56 |
+
api_info: ApiInfo<JsApiData> | undefined;
|
| 57 |
+
api_map: Record<string, number> = {};
|
| 58 |
+
session_hash: string = Math.random().toString(36).substring(2);
|
| 59 |
+
jwt: string | false = false;
|
| 60 |
+
last_status: Record<string, Status["stage"]> = {};
|
| 61 |
+
|
| 62 |
+
private cookies: string | null = null;
|
| 63 |
+
|
| 64 |
+
// streaming
|
| 65 |
+
stream_status = { open: false };
|
| 66 |
+
closed = false;
|
| 67 |
+
pending_stream_messages: Record<string, any[][]> = {};
|
| 68 |
+
pending_diff_streams: Record<string, any[][]> = {};
|
| 69 |
+
event_callbacks: Record<string, (data?: unknown) => Promise<void>> = {};
|
| 70 |
+
unclosed_events: Set<string> = new Set();
|
| 71 |
+
heartbeat_event: EventSource | null = null;
|
| 72 |
+
heartbeat_controller: AbortController | null = null;
|
| 73 |
+
// Outside a browser (e.g. Node, or SSR) a client is often connected only to
|
| 74 |
+
// read its config, so the heartbeat waits for the first submit.
|
| 75 |
+
heartbeat_wanted =
|
| 76 |
+
typeof window !== "undefined" && typeof document !== "undefined";
|
| 77 |
+
abort_controller: AbortController | null = null;
|
| 78 |
+
stream_instance: EventSource | null = null;
|
| 79 |
+
current_payload: any;
|
| 80 |
+
|
| 81 |
+
get_url_config(url: string | null = null): Config {
|
| 82 |
+
if (!this.config) {
|
| 83 |
+
throw new Error(CONFIG_ERROR_MSG);
|
| 84 |
+
}
|
| 85 |
+
if (url === null) {
|
| 86 |
+
url = window.location.href;
|
| 87 |
+
}
|
| 88 |
+
const stripSlashes = (str: string): string => str.replace(/^\/+|\/+$/g, "");
|
| 89 |
+
let root_path = stripSlashes(new URL(this.config.root).pathname);
|
| 90 |
+
let url_path = stripSlashes(new URL(url).pathname);
|
| 91 |
+
let page: string;
|
| 92 |
+
if (!url_path.startsWith(root_path)) {
|
| 93 |
+
page = "";
|
| 94 |
+
} else {
|
| 95 |
+
page = stripSlashes(url_path.substring(root_path.length));
|
| 96 |
+
}
|
| 97 |
+
return this.get_page_config(page);
|
| 98 |
+
}
|
| 99 |
+
get_page_config(page: string): Config {
|
| 100 |
+
if (!this.config) {
|
| 101 |
+
throw new Error(CONFIG_ERROR_MSG);
|
| 102 |
+
}
|
| 103 |
+
let config = this.config;
|
| 104 |
+
if (!(page in config.page)) {
|
| 105 |
+
page = "";
|
| 106 |
+
}
|
| 107 |
+
return {
|
| 108 |
+
...config,
|
| 109 |
+
current_page: page,
|
| 110 |
+
layout: config.page[page].layout,
|
| 111 |
+
components: config.components.filter((c) =>
|
| 112 |
+
config.page[page].components.includes(c.id)
|
| 113 |
+
),
|
| 114 |
+
dependencies: this.config.dependencies.filter((d) =>
|
| 115 |
+
config.page[page].dependencies.includes(d.id)
|
| 116 |
+
)
|
| 117 |
+
};
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
|
| 121 |
+
const headers = new Headers(init?.headers || {});
|
| 122 |
+
if (this && this.cookies) {
|
| 123 |
+
headers.append("Cookie", this.cookies);
|
| 124 |
+
}
|
| 125 |
+
if (this && this.options.headers) {
|
| 126 |
+
let additional_headers = new Headers(this.options.headers);
|
| 127 |
+
|
| 128 |
+
additional_headers.forEach((value, name) => {
|
| 129 |
+
headers.append(name, value);
|
| 130 |
+
});
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
return fetch(input, { ...init, headers });
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
stream(url: URL, abort_controller?: AbortController): EventSource {
|
| 137 |
+
const headers = new Headers();
|
| 138 |
+
if (this && this.cookies) {
|
| 139 |
+
headers.append("Cookie", this.cookies);
|
| 140 |
+
}
|
| 141 |
+
if (this && this.options.headers) {
|
| 142 |
+
let additional_headers = new Headers(this.options.headers);
|
| 143 |
+
|
| 144 |
+
additional_headers.forEach((value, name) => {
|
| 145 |
+
headers.append(name, value);
|
| 146 |
+
});
|
| 147 |
+
}
|
| 148 |
+
if (this && this.options.token) {
|
| 149 |
+
headers.append("Authorization", `Bearer ${this.options.token}`);
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
if (!abort_controller) {
|
| 153 |
+
abort_controller = new AbortController();
|
| 154 |
+
this.abort_controller = abort_controller;
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
this.stream_instance = readable_stream(url.toString(), {
|
| 158 |
+
credentials: this.options.credentials ?? "same-origin",
|
| 159 |
+
headers: headers,
|
| 160 |
+
signal: abort_controller.signal
|
| 161 |
+
});
|
| 162 |
+
|
| 163 |
+
return this.stream_instance;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
view_api: () => Promise<ApiInfo<JsApiData>>;
|
| 167 |
+
upload_files: (
|
| 168 |
+
root_url: string,
|
| 169 |
+
files: (Blob | File)[],
|
| 170 |
+
upload_id?: string
|
| 171 |
+
) => Promise<UploadResponse>;
|
| 172 |
+
upload: (
|
| 173 |
+
file_data: FileData[],
|
| 174 |
+
root_url: string,
|
| 175 |
+
upload_id?: string,
|
| 176 |
+
max_file_size?: number
|
| 177 |
+
) => Promise<(FileData | null)[] | null>;
|
| 178 |
+
handle_blob: (
|
| 179 |
+
endpoint: string,
|
| 180 |
+
data: unknown[],
|
| 181 |
+
endpoint_info: EndpointInfo<ApiData | JsApiData>
|
| 182 |
+
) => Promise<unknown[]>;
|
| 183 |
+
post_data: (
|
| 184 |
+
url: string,
|
| 185 |
+
body: unknown,
|
| 186 |
+
additional_headers?: any
|
| 187 |
+
) => Promise<unknown[]>;
|
| 188 |
+
submit: (
|
| 189 |
+
endpoint: string | number,
|
| 190 |
+
data: unknown[] | Record<string, unknown> | undefined,
|
| 191 |
+
event_data?: unknown,
|
| 192 |
+
trigger_id?: number | null,
|
| 193 |
+
all_events?: boolean
|
| 194 |
+
) => SubmitIterable<GradioEvent>;
|
| 195 |
+
predict: <T = unknown>(
|
| 196 |
+
endpoint: string | number,
|
| 197 |
+
data: unknown[] | Record<string, unknown> | undefined,
|
| 198 |
+
event_data?: unknown
|
| 199 |
+
) => Promise<PredictReturn<T>>;
|
| 200 |
+
open_stream: () => Promise<void>;
|
| 201 |
+
private resolve_config: (
|
| 202 |
+
endpoint: string,
|
| 203 |
+
strip_current_page?: boolean
|
| 204 |
+
) => Promise<Config | undefined>;
|
| 205 |
+
private resolve_cookies: () => Promise<void>;
|
| 206 |
+
constructor(
|
| 207 |
+
app_reference: string,
|
| 208 |
+
options: ClientOptions = { events: ["data"] }
|
| 209 |
+
) {
|
| 210 |
+
this.app_reference = app_reference;
|
| 211 |
+
this.deep_link = options.query_params?.deep_link || null;
|
| 212 |
+
this.page = options.query_params?.page ?? null;
|
| 213 |
+
if (!options.events) {
|
| 214 |
+
options.events = ["data"];
|
| 215 |
+
}
|
| 216 |
+
normalise_token_option(options);
|
| 217 |
+
|
| 218 |
+
this.options = options;
|
| 219 |
+
this.current_payload = {};
|
| 220 |
+
|
| 221 |
+
if (options.cookies) {
|
| 222 |
+
this.cookies = options.cookies;
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
this.view_api = view_api.bind(this);
|
| 226 |
+
this.upload_files = upload_files.bind(this);
|
| 227 |
+
this.handle_blob = handle_blob.bind(this);
|
| 228 |
+
this.post_data = post_data.bind(this);
|
| 229 |
+
this.submit = submit.bind(this);
|
| 230 |
+
this.predict = predict.bind(this) as typeof this.predict;
|
| 231 |
+
this.open_stream = open_stream.bind(this);
|
| 232 |
+
this.resolve_config = resolve_config.bind(this);
|
| 233 |
+
this.resolve_cookies = resolve_cookies.bind(this);
|
| 234 |
+
this.upload = upload.bind(this);
|
| 235 |
+
this.fetch = this.fetch.bind(this);
|
| 236 |
+
this.handle_space_success = this.handle_space_success.bind(this);
|
| 237 |
+
this.stream = this.stream.bind(this);
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
private async init(): Promise<void> {
|
| 241 |
+
initialize_zerogpu_handshake();
|
| 242 |
+
|
| 243 |
+
if (this.options.auth) {
|
| 244 |
+
await this.resolve_cookies();
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
await this._resolve_config().then(
|
| 248 |
+
(res: { config: Config } | undefined) =>
|
| 249 |
+
res?.config && this._resolve_heartbeat(res.config)
|
| 250 |
+
);
|
| 251 |
+
|
| 252 |
+
try {
|
| 253 |
+
this.api_info = await this.view_api();
|
| 254 |
+
} catch (e) {
|
| 255 |
+
// A failure to fetch API info should not prevent the client from
|
| 256 |
+
// connecting: otherwise the SSR server renders a spurious login
|
| 257 |
+
// page whenever the /info endpoint is unreachable.
|
| 258 |
+
console.error((e as Error).message);
|
| 259 |
+
}
|
| 260 |
+
this.api_map = map_names_to_ids(this.config?.dependencies || []);
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
async _resolve_heartbeat(_config: Config): Promise<void> {
|
| 264 |
+
this.config = _config;
|
| 265 |
+
this.api_prefix = _config.api_prefix || "";
|
| 266 |
+
|
| 267 |
+
if (_config.space_id && this.options.token) {
|
| 268 |
+
this.jwt = await get_jwt(
|
| 269 |
+
_config.space_id,
|
| 270 |
+
this.options.token,
|
| 271 |
+
this.cookies
|
| 272 |
+
);
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
sign_config_file_urls(this.config, this.jwt);
|
| 276 |
+
|
| 277 |
+
if (this.heartbeat_wanted) {
|
| 278 |
+
this.open_heartbeat();
|
| 279 |
+
}
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
open_heartbeat(): void {
|
| 283 |
+
this.heartbeat_wanted = true;
|
| 284 |
+
if (!this.config?.connect_heartbeat || this.heartbeat_event) {
|
| 285 |
+
return;
|
| 286 |
+
}
|
| 287 |
+
const heartbeat_url = new URL(
|
| 288 |
+
`${this.config.root}${this.api_prefix}/${HEARTBEAT_URL}/${this.session_hash}`
|
| 289 |
+
);
|
| 290 |
+
|
| 291 |
+
if (this.jwt) {
|
| 292 |
+
heartbeat_url.searchParams.set("__sign", this.jwt);
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
// Its own controller, so that close() still reaches it after other
|
| 296 |
+
// streams have been opened. The response is not parsed. Ref: https://github.com/gradio-app/gradio/pull/7974#discussion_r1557717540
|
| 297 |
+
this.heartbeat_controller = new AbortController();
|
| 298 |
+
this.heartbeat_event = this.stream(
|
| 299 |
+
heartbeat_url,
|
| 300 |
+
this.heartbeat_controller
|
| 301 |
+
);
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
static async connect(
|
| 305 |
+
app_reference: string,
|
| 306 |
+
options: ClientOptions = {
|
| 307 |
+
events: ["data"]
|
| 308 |
+
}
|
| 309 |
+
): Promise<Client> {
|
| 310 |
+
const client = new this(app_reference, options); // this refers to the class itself, not the instance
|
| 311 |
+
if (options.session_hash) {
|
| 312 |
+
client.session_hash = options.session_hash;
|
| 313 |
+
}
|
| 314 |
+
await client.init();
|
| 315 |
+
return client;
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
async reconnect(): Promise<"connected" | "broken" | "changed"> {
|
| 319 |
+
const app_id_url = new URL(
|
| 320 |
+
`${this.config!.root}${this.api_prefix}/${APP_ID_URL}`
|
| 321 |
+
);
|
| 322 |
+
let app_id: string;
|
| 323 |
+
try {
|
| 324 |
+
const response = await this.fetch(app_id_url);
|
| 325 |
+
if (!response.ok) {
|
| 326 |
+
throw new Error();
|
| 327 |
+
}
|
| 328 |
+
app_id = ((await response.json()) as any).app_id;
|
| 329 |
+
} catch (e) {
|
| 330 |
+
return "broken";
|
| 331 |
+
}
|
| 332 |
+
if (app_id !== this.config!.app_id) {
|
| 333 |
+
return "changed";
|
| 334 |
+
}
|
| 335 |
+
return "connected";
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
close(): void {
|
| 339 |
+
this.closed = true;
|
| 340 |
+
close_stream(this.stream_status, this.abort_controller);
|
| 341 |
+
this.heartbeat_controller?.abort();
|
| 342 |
+
this.heartbeat_controller = null;
|
| 343 |
+
this.heartbeat_event = null;
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
/**
|
| 347 |
+
* Re-fetch the app config without closing the SSE stream.
|
| 348 |
+
* Used by hot-reload so in-flight generators keep delivering updates.
|
| 349 |
+
*/
|
| 350 |
+
async refresh(): Promise<Config> {
|
| 351 |
+
if (!this.config) {
|
| 352 |
+
throw new Error(CONFIG_ERROR_MSG);
|
| 353 |
+
}
|
| 354 |
+
// config.root is already the app root. resolve_config normally strips the
|
| 355 |
+
// current page from its endpoint, which would strip one path segment too
|
| 356 |
+
// many when refreshing from a subpage.
|
| 357 |
+
const config = await this.resolve_config(this.config.root, false);
|
| 358 |
+
if (!config) {
|
| 359 |
+
throw new Error(CONFIG_ERROR_MSG);
|
| 360 |
+
}
|
| 361 |
+
this.config = config;
|
| 362 |
+
this.api_prefix = config.api_prefix || "";
|
| 363 |
+
this.api_map = map_names_to_ids(config.dependencies || []);
|
| 364 |
+
sign_config_file_urls(this.config, this.jwt);
|
| 365 |
+
try {
|
| 366 |
+
this.api_info = await this.view_api();
|
| 367 |
+
} catch (e) {
|
| 368 |
+
console.error(API_INFO_ERROR_MSG + (e as Error).message);
|
| 369 |
+
}
|
| 370 |
+
return this.get_url_config();
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
set_current_payload(payload: any): void {
|
| 374 |
+
this.current_payload = payload;
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
static async duplicate(
|
| 378 |
+
app_reference: string,
|
| 379 |
+
options: DuplicateOptions = {
|
| 380 |
+
events: ["data"]
|
| 381 |
+
}
|
| 382 |
+
): Promise<Client> {
|
| 383 |
+
return duplicate(app_reference, options);
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
private async _resolve_config(): Promise<any> {
|
| 387 |
+
const { http_protocol, host, space_id } = await process_endpoint(
|
| 388 |
+
this.app_reference,
|
| 389 |
+
this.options.token
|
| 390 |
+
);
|
| 391 |
+
|
| 392 |
+
const { status_callback } = this.options;
|
| 393 |
+
|
| 394 |
+
if (space_id && status_callback) {
|
| 395 |
+
await check_and_wake_space(space_id, status_callback);
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
let config: Config | undefined;
|
| 399 |
+
|
| 400 |
+
try {
|
| 401 |
+
// Create base URL
|
| 402 |
+
let configUrl = `${http_protocol}//${host}`;
|
| 403 |
+
config = await this.resolve_config(configUrl);
|
| 404 |
+
|
| 405 |
+
if (!config) {
|
| 406 |
+
throw new Error(CONFIG_ERROR_MSG);
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
return this.config_success(config);
|
| 410 |
+
} catch (e: any) {
|
| 411 |
+
if (space_id && status_callback) {
|
| 412 |
+
check_space_status(
|
| 413 |
+
space_id,
|
| 414 |
+
RE_SPACE_NAME.test(space_id) ? "space_name" : "subdomain",
|
| 415 |
+
this.handle_space_success
|
| 416 |
+
);
|
| 417 |
+
} else {
|
| 418 |
+
if (status_callback)
|
| 419 |
+
status_callback({
|
| 420 |
+
status: "error",
|
| 421 |
+
message: "Could not load this space.",
|
| 422 |
+
load_status: "error",
|
| 423 |
+
detail: "NOT_FOUND"
|
| 424 |
+
});
|
| 425 |
+
throw e instanceof Error ? e : new Error(String(e));
|
| 426 |
+
}
|
| 427 |
+
}
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
private async config_success(
|
| 431 |
+
_config: Config
|
| 432 |
+
): Promise<Config | client_return> {
|
| 433 |
+
this.config = _config;
|
| 434 |
+
this.api_prefix = _config.api_prefix || "";
|
| 435 |
+
|
| 436 |
+
// Opting out also purges, so an app that turns the feature off does not
|
| 437 |
+
// leave behind what it stored while it was on.
|
| 438 |
+
if (_config.run_history === false) {
|
| 439 |
+
clear_run_history({
|
| 440 |
+
app_id: _config.app_id,
|
| 441 |
+
username: _config.username
|
| 442 |
+
});
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
if (this.config.auth_required) {
|
| 446 |
+
return this.prepare_return_obj();
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
try {
|
| 450 |
+
this.api_info = await this.view_api();
|
| 451 |
+
} catch (e) {
|
| 452 |
+
console.error(API_INFO_ERROR_MSG + (e as Error).message);
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
return this.prepare_return_obj();
|
| 456 |
+
}
|
| 457 |
+
|
| 458 |
+
async handle_space_success(status: SpaceStatus): Promise<Config | void> {
|
| 459 |
+
if (!this) {
|
| 460 |
+
throw new Error(CONFIG_ERROR_MSG);
|
| 461 |
+
}
|
| 462 |
+
const { status_callback } = this.options;
|
| 463 |
+
if (status_callback) status_callback(status);
|
| 464 |
+
if (status.status === "running") {
|
| 465 |
+
try {
|
| 466 |
+
this.config = await this._resolve_config();
|
| 467 |
+
this.api_prefix = this?.config?.api_prefix || "";
|
| 468 |
+
|
| 469 |
+
if (!this.config) {
|
| 470 |
+
throw new Error(CONFIG_ERROR_MSG);
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
const _config = await this.config_success(this.config);
|
| 474 |
+
|
| 475 |
+
return _config as Config;
|
| 476 |
+
} catch (e) {
|
| 477 |
+
if (status_callback) {
|
| 478 |
+
status_callback({
|
| 479 |
+
status: "error",
|
| 480 |
+
message: "Could not load this space.",
|
| 481 |
+
load_status: "error",
|
| 482 |
+
detail: "NOT_FOUND"
|
| 483 |
+
});
|
| 484 |
+
}
|
| 485 |
+
throw e;
|
| 486 |
+
}
|
| 487 |
+
}
|
| 488 |
+
}
|
| 489 |
+
|
| 490 |
+
public async component_server(
|
| 491 |
+
component_id: number,
|
| 492 |
+
fn_name: string,
|
| 493 |
+
data: unknown | { binary: boolean; data: Record<string, any> }
|
| 494 |
+
): Promise<unknown> {
|
| 495 |
+
if (!this.config) {
|
| 496 |
+
throw new Error(CONFIG_ERROR_MSG);
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
const headers: {
|
| 500 |
+
Authorization?: string;
|
| 501 |
+
"Content-Type"?: "application/json";
|
| 502 |
+
} = {};
|
| 503 |
+
|
| 504 |
+
const { token } = this.options;
|
| 505 |
+
const { session_hash } = this;
|
| 506 |
+
|
| 507 |
+
if (token) {
|
| 508 |
+
headers.Authorization = `Bearer ${this.options.token}`;
|
| 509 |
+
}
|
| 510 |
+
|
| 511 |
+
let root_url: string;
|
| 512 |
+
let component = this.config.components.find(
|
| 513 |
+
(comp) => comp.id === component_id
|
| 514 |
+
);
|
| 515 |
+
if (component?.props?.root_url) {
|
| 516 |
+
root_url = component.props.root_url;
|
| 517 |
+
} else {
|
| 518 |
+
root_url = this.config.root;
|
| 519 |
+
}
|
| 520 |
+
|
| 521 |
+
let body: FormData | string;
|
| 522 |
+
|
| 523 |
+
if (typeof data === "object" && data !== null && "binary" in data) {
|
| 524 |
+
const _data = data as { binary: boolean; data: Record<string, any> };
|
| 525 |
+
body = new FormData();
|
| 526 |
+
for (const key in _data.data) {
|
| 527 |
+
if (key === "binary") continue;
|
| 528 |
+
body.append(key, _data.data[key]);
|
| 529 |
+
}
|
| 530 |
+
body.set("component_id", component_id.toString());
|
| 531 |
+
body.set("fn_name", fn_name);
|
| 532 |
+
body.set("session_hash", session_hash);
|
| 533 |
+
} else {
|
| 534 |
+
body = JSON.stringify({
|
| 535 |
+
data: data,
|
| 536 |
+
component_id,
|
| 537 |
+
fn_name,
|
| 538 |
+
session_hash
|
| 539 |
+
});
|
| 540 |
+
|
| 541 |
+
headers["Content-Type"] = "application/json";
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
+
if (token) {
|
| 545 |
+
headers.Authorization = `Bearer ${token}`;
|
| 546 |
+
}
|
| 547 |
+
|
| 548 |
+
try {
|
| 549 |
+
const response = await this.fetch(
|
| 550 |
+
`${root_url}${this.api_prefix}/${COMPONENT_SERVER_URL}/`,
|
| 551 |
+
{
|
| 552 |
+
method: "POST",
|
| 553 |
+
body: body,
|
| 554 |
+
headers,
|
| 555 |
+
credentials: this.options.credentials ?? "same-origin"
|
| 556 |
+
}
|
| 557 |
+
);
|
| 558 |
+
|
| 559 |
+
if (!response.ok) {
|
| 560 |
+
throw new Error(
|
| 561 |
+
"Could not connect to component server: " + response.statusText
|
| 562 |
+
);
|
| 563 |
+
}
|
| 564 |
+
|
| 565 |
+
const output = await response.json();
|
| 566 |
+
sign_file_urls(
|
| 567 |
+
output,
|
| 568 |
+
this.config.root,
|
| 569 |
+
this.config.api_prefix || "",
|
| 570 |
+
this.jwt
|
| 571 |
+
);
|
| 572 |
+
return output;
|
| 573 |
+
} catch (e) {
|
| 574 |
+
console.warn(e);
|
| 575 |
+
}
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
+
public set_cookies(raw_cookies: string): void {
|
| 579 |
+
this.cookies = parse_and_set_cookies(raw_cookies).join("; ");
|
| 580 |
+
}
|
| 581 |
+
|
| 582 |
+
private prepare_return_obj(): client_return {
|
| 583 |
+
return {
|
| 584 |
+
config: this.config,
|
| 585 |
+
predict: this.predict,
|
| 586 |
+
submit: this.submit,
|
| 587 |
+
view_api: this.view_api,
|
| 588 |
+
component_server: this.component_server
|
| 589 |
+
};
|
| 590 |
+
}
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
/**
|
| 594 |
+
* @deprecated This method will be removed in v1.0. Use `Client.connect()` instead.
|
| 595 |
+
* Creates a client instance for interacting with Gradio apps.
|
| 596 |
+
*
|
| 597 |
+
* @param {string} app_reference - The reference or URL to a Gradio space or app.
|
| 598 |
+
* @param {ClientOptions} options - Configuration options for the client.
|
| 599 |
+
* @returns {Promise<Client>} A promise that resolves to a `Client` instance.
|
| 600 |
+
*/
|
| 601 |
+
export async function client(
|
| 602 |
+
app_reference: string,
|
| 603 |
+
options: ClientOptions = {
|
| 604 |
+
events: ["data"]
|
| 605 |
+
}
|
| 606 |
+
): Promise<Client> {
|
| 607 |
+
return await Client.connect(app_reference, options);
|
| 608 |
+
}
|
| 609 |
+
|
| 610 |
+
/**
|
| 611 |
+
* @deprecated This method will be removed in v1.0. Use `Client.duplicate()` instead.
|
| 612 |
+
* Creates a duplicate of a space and returns a client instance for the duplicated space.
|
| 613 |
+
*
|
| 614 |
+
* @param {string} app_reference - The reference or URL to a Gradio space or app to duplicate.
|
| 615 |
+
* @param {DuplicateOptions} options - Configuration options for the client.
|
| 616 |
+
* @returns {Promise<Client>} A promise that resolves to a `Client` instance.
|
| 617 |
+
*/
|
| 618 |
+
export async function duplicate_space(
|
| 619 |
+
app_reference: string,
|
| 620 |
+
options: DuplicateOptions
|
| 621 |
+
): Promise<Client> {
|
| 622 |
+
return await Client.duplicate(app_reference, options);
|
| 623 |
+
}
|
| 624 |
+
|
| 625 |
+
export type ClientInstance = Client;
|
6.29.1/client/src/constants.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// endpoints
|
| 2 |
+
export const HOST_URL = `host`;
|
| 3 |
+
export const API_URL = `predict/`;
|
| 4 |
+
export const SSE_URL_V0 = `queue/join`;
|
| 5 |
+
export const SSE_DATA_URL_V0 = `queue/data`;
|
| 6 |
+
export const SSE_URL = `queue/data`;
|
| 7 |
+
export const SSE_DATA_URL = `queue/join`;
|
| 8 |
+
export const UPLOAD_URL = `upload`;
|
| 9 |
+
export const LOGIN_URL = `login`;
|
| 10 |
+
export const CONFIG_URL = `config`;
|
| 11 |
+
export const API_INFO_URL = `info`;
|
| 12 |
+
export const RUNTIME_URL = `runtime`;
|
| 13 |
+
export const SLEEPTIME_URL = `sleeptime`;
|
| 14 |
+
export const HEARTBEAT_URL = `heartbeat`;
|
| 15 |
+
export const COMPONENT_SERVER_URL = `component_server`;
|
| 16 |
+
export const RESET_URL = `reset`;
|
| 17 |
+
export const CANCEL_URL = `cancel`;
|
| 18 |
+
export const APP_ID_URL = `app_id`;
|
| 19 |
+
|
| 20 |
+
export const RAW_API_INFO_URL = `info?serialize=False`;
|
| 21 |
+
export const SPACE_FETCHER_URL =
|
| 22 |
+
"https://gradio-space-api-fetcher-v2.hf.space/api";
|
| 23 |
+
export const SPACE_URL = "https://hf.space/{}";
|
| 24 |
+
|
| 25 |
+
// messages
|
| 26 |
+
export const QUEUE_FULL_MSG =
|
| 27 |
+
"This application is currently busy. Please try again. ";
|
| 28 |
+
export const BROKEN_CONNECTION_MSG = "Connection errored out. ";
|
| 29 |
+
export const CONFIG_ERROR_MSG = "Could not resolve app config. ";
|
| 30 |
+
export const SPACE_STATUS_ERROR_MSG = "Could not get space status. ";
|
| 31 |
+
export const API_INFO_ERROR_MSG = "Could not get API info. ";
|
| 32 |
+
export const SPACE_METADATA_ERROR_MSG = "Space metadata could not be loaded. ";
|
| 33 |
+
export const INVALID_URL_MSG = "Invalid URL. A full URL path is required.";
|
| 34 |
+
export const UNAUTHORIZED_MSG = "Not authorized to access this space. ";
|
| 35 |
+
export const INVALID_CREDENTIALS_MSG = "Invalid credentials. Could not login. ";
|
| 36 |
+
export const MISSING_CREDENTIALS_MSG =
|
| 37 |
+
"Login credentials are required to access this space.";
|
| 38 |
+
export const PRIVATE_SPACE_MSG =
|
| 39 |
+
"Could not access this app (received a 401 response). If it is a private Hugging Face Space, pass a valid Hugging Face token to the `token` option of `Client.connect`. You can generate a token at https://huggingface.co/settings/tokens.";
|
| 40 |
+
export const SPACE_NOT_FOUND_MSG = (space: string, status: number): string =>
|
| 41 |
+
`Space "${space}" could not be accessed (received a ${status} response from the Hugging Face API). ` +
|
| 42 |
+
"Check that the Space name is spelled correctly and that the Space exists. If the Space is private, " +
|
| 43 |
+
"pass a valid Hugging Face token to the `token` option of `Client.connect`. You can generate a token at https://huggingface.co/settings/tokens.";
|
| 44 |
+
export const NO_API_INFO_MSG =
|
| 45 |
+
"No API information is available for this app. This can happen when the app's `/info` endpoint cannot be reached, or when the app is running a legacy version of Gradio that is not supported by this client. ";
|
| 46 |
+
export const WS_PROTOCOL_MSG =
|
| 47 |
+
"This app appears to be running a legacy version of Gradio (3.x or earlier) that communicates over WebSockets, which is not supported by this version of @gradio/client. Please upgrade the app to a newer version of Gradio, or connect to it with @gradio/client version 0.x.";
|
| 48 |
+
export const NODEJS_FS_ERROR_MSG =
|
| 49 |
+
"File system access is only available in Node.js environments";
|
| 50 |
+
export const ROOT_URL_ERROR_MSG = "Root URL not found in client config";
|
| 51 |
+
export const FILE_PROCESSING_ERROR_MSG = "Error uploading file";
|
6.29.1/client/src/globals.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { ApiData, ApiInfo, Config } from "./types";
|
| 2 |
+
|
| 3 |
+
declare global {
|
| 4 |
+
interface Window {
|
| 5 |
+
__gradio_mode__: "app" | "website";
|
| 6 |
+
gradio_config: Config;
|
| 7 |
+
gradio_api_info: ApiInfo<ApiData> | { api: ApiInfo<ApiData> };
|
| 8 |
+
__is_colab__: boolean;
|
| 9 |
+
__gradio_space__: string | null;
|
| 10 |
+
supports_zerogpu_headers?: boolean;
|
| 11 |
+
BUILD_MODE?: "dev" | "production";
|
| 12 |
+
}
|
| 13 |
+
}
|
6.29.1/client/src/helpers/api_info.ts
ADDED
|
@@ -0,0 +1,506 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import {
|
| 2 |
+
HOST_URL,
|
| 3 |
+
INVALID_URL_MSG,
|
| 4 |
+
QUEUE_FULL_MSG,
|
| 5 |
+
SPACE_METADATA_ERROR_MSG,
|
| 6 |
+
SPACE_NOT_FOUND_MSG
|
| 7 |
+
} from "../constants";
|
| 8 |
+
import type {
|
| 9 |
+
ApiData,
|
| 10 |
+
ApiInfo,
|
| 11 |
+
Config,
|
| 12 |
+
JsApiData,
|
| 13 |
+
EndpointInfo,
|
| 14 |
+
Status
|
| 15 |
+
} from "../types";
|
| 16 |
+
import { determine_protocol } from "./init_helpers";
|
| 17 |
+
|
| 18 |
+
export const RE_SPACE_NAME = /^[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_\-\.]+$/;
|
| 19 |
+
export const RE_SPACE_DOMAIN = /.*hf\.space\/{0,1}.*$/;
|
| 20 |
+
|
| 21 |
+
export async function process_endpoint(
|
| 22 |
+
app_reference: string,
|
| 23 |
+
token?: `hf_${string}`
|
| 24 |
+
): Promise<{
|
| 25 |
+
space_id: string | false;
|
| 26 |
+
host: string;
|
| 27 |
+
ws_protocol: "ws" | "wss";
|
| 28 |
+
http_protocol: "http:" | "https:";
|
| 29 |
+
}> {
|
| 30 |
+
const headers: { Authorization?: string } = {};
|
| 31 |
+
if (token) {
|
| 32 |
+
headers.Authorization = `Bearer ${token}`;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
const _app_reference = app_reference.trim().replace(/\/$/, "");
|
| 36 |
+
|
| 37 |
+
if (RE_SPACE_NAME.test(_app_reference)) {
|
| 38 |
+
// app_reference is a HF space name
|
| 39 |
+
let res: Response;
|
| 40 |
+
try {
|
| 41 |
+
res = await fetch(
|
| 42 |
+
`https://huggingface.co/api/spaces/${_app_reference}/${HOST_URL}`,
|
| 43 |
+
{ headers }
|
| 44 |
+
);
|
| 45 |
+
} catch (e) {
|
| 46 |
+
throw new Error(SPACE_METADATA_ERROR_MSG);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
if (res.status === 401 || res.status === 404) {
|
| 50 |
+
// the space does not exist, or it is private and the request was made
|
| 51 |
+
// without (or with an invalid) token
|
| 52 |
+
throw new Error(SPACE_NOT_FOUND_MSG(_app_reference, res.status));
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
let _host: string | undefined;
|
| 56 |
+
try {
|
| 57 |
+
_host = (await res.json()).host;
|
| 58 |
+
} catch (e) {
|
| 59 |
+
throw new Error(SPACE_METADATA_ERROR_MSG);
|
| 60 |
+
}
|
| 61 |
+
if (!_host) {
|
| 62 |
+
throw new Error(SPACE_METADATA_ERROR_MSG);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
return {
|
| 66 |
+
space_id: _app_reference,
|
| 67 |
+
...determine_protocol(_host)
|
| 68 |
+
};
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
if (RE_SPACE_DOMAIN.test(_app_reference)) {
|
| 72 |
+
// app_reference is a direct HF space domain
|
| 73 |
+
const { ws_protocol, http_protocol, host } =
|
| 74 |
+
determine_protocol(_app_reference);
|
| 75 |
+
|
| 76 |
+
return {
|
| 77 |
+
space_id: host.split("/")[0].replace(".hf.space", ""),
|
| 78 |
+
ws_protocol,
|
| 79 |
+
http_protocol,
|
| 80 |
+
host
|
| 81 |
+
};
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
return {
|
| 85 |
+
space_id: false,
|
| 86 |
+
...determine_protocol(_app_reference)
|
| 87 |
+
};
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
export const join_urls = (...urls: string[]): string => {
|
| 91 |
+
try {
|
| 92 |
+
return urls.reduce((base_url: string, part: string) => {
|
| 93 |
+
base_url = base_url.replace(/\/+$/, "");
|
| 94 |
+
part = part.replace(/^\/+/, "");
|
| 95 |
+
return new URL(part, base_url + "/").toString();
|
| 96 |
+
});
|
| 97 |
+
} catch (e) {
|
| 98 |
+
throw new Error(INVALID_URL_MSG);
|
| 99 |
+
}
|
| 100 |
+
};
|
| 101 |
+
|
| 102 |
+
export function transform_api_info(
|
| 103 |
+
api_info: ApiInfo<ApiData>,
|
| 104 |
+
config: Config,
|
| 105 |
+
api_map: Record<string, number>
|
| 106 |
+
): ApiInfo<JsApiData> {
|
| 107 |
+
const transformed_info: ApiInfo<JsApiData> = {
|
| 108 |
+
named_endpoints: {},
|
| 109 |
+
unnamed_endpoints: {}
|
| 110 |
+
};
|
| 111 |
+
|
| 112 |
+
Object.keys(api_info).forEach((category) => {
|
| 113 |
+
if (category === "named_endpoints" || category === "unnamed_endpoints") {
|
| 114 |
+
transformed_info[category] = {};
|
| 115 |
+
|
| 116 |
+
Object.entries(api_info[category]).forEach(
|
| 117 |
+
([endpoint, endpoint_info]) => {
|
| 118 |
+
// Guard against malformed or legacy `/info` payloads that are
|
| 119 |
+
// missing `parameters`/`returns` so that we surface a usable API
|
| 120 |
+
// description instead of crashing with
|
| 121 |
+
// "Cannot read properties of undefined (reading 'map')".
|
| 122 |
+
const parameters = endpoint_info?.parameters ?? [];
|
| 123 |
+
const returns = endpoint_info?.returns ?? [];
|
| 124 |
+
const dependencyIndex =
|
| 125 |
+
config.dependencies.find(
|
| 126 |
+
(dep) =>
|
| 127 |
+
dep.api_name === endpoint ||
|
| 128 |
+
dep.api_name === endpoint.replace("/", "")
|
| 129 |
+
)?.id ||
|
| 130 |
+
api_map[endpoint.replace("/", "")] ||
|
| 131 |
+
-1;
|
| 132 |
+
|
| 133 |
+
const dependency =
|
| 134 |
+
dependencyIndex !== -1
|
| 135 |
+
? config.dependencies.find((dep) => dep.id == dependencyIndex)
|
| 136 |
+
: undefined;
|
| 137 |
+
|
| 138 |
+
const dependencyTypes =
|
| 139 |
+
dependencyIndex !== -1
|
| 140 |
+
? dependency?.types
|
| 141 |
+
: { generator: false, cancel: false };
|
| 142 |
+
|
| 143 |
+
if (
|
| 144 |
+
dependency &&
|
| 145 |
+
Array.isArray(dependency.inputs) &&
|
| 146 |
+
dependency.inputs.length !== parameters.length
|
| 147 |
+
) {
|
| 148 |
+
const components = dependency.inputs.map(
|
| 149 |
+
(input) => config.components.find((c) => c.id === input)?.type
|
| 150 |
+
);
|
| 151 |
+
|
| 152 |
+
try {
|
| 153 |
+
components.forEach((comp, idx) => {
|
| 154 |
+
if (comp === "state") {
|
| 155 |
+
const new_param = {
|
| 156 |
+
component: "state",
|
| 157 |
+
example: null,
|
| 158 |
+
parameter_default: null,
|
| 159 |
+
parameter_has_default: true,
|
| 160 |
+
parameter_name: null,
|
| 161 |
+
hidden: true
|
| 162 |
+
};
|
| 163 |
+
|
| 164 |
+
// @ts-ignore
|
| 165 |
+
parameters.splice(idx, 0, new_param);
|
| 166 |
+
}
|
| 167 |
+
});
|
| 168 |
+
} catch (e) {
|
| 169 |
+
console.error(e);
|
| 170 |
+
}
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
const transform_type = (
|
| 174 |
+
data: ApiData,
|
| 175 |
+
component: string,
|
| 176 |
+
serializer: string,
|
| 177 |
+
signature_type: "return" | "parameter"
|
| 178 |
+
): JsApiData => ({
|
| 179 |
+
...data,
|
| 180 |
+
description: get_description(data?.type, serializer),
|
| 181 |
+
type:
|
| 182 |
+
get_type(data?.type, component, serializer, signature_type) || ""
|
| 183 |
+
});
|
| 184 |
+
|
| 185 |
+
transformed_info[category][endpoint] = {
|
| 186 |
+
parameters: parameters.map((p: ApiData) =>
|
| 187 |
+
transform_type(p, p?.component, p?.serializer, "parameter")
|
| 188 |
+
),
|
| 189 |
+
returns: returns.map((r: ApiData) =>
|
| 190 |
+
transform_type(r, r?.component, r?.serializer, "return")
|
| 191 |
+
),
|
| 192 |
+
type: dependencyTypes,
|
| 193 |
+
...(endpoint_info?.oauth_token
|
| 194 |
+
? { oauth_token: endpoint_info.oauth_token }
|
| 195 |
+
: {})
|
| 196 |
+
};
|
| 197 |
+
}
|
| 198 |
+
);
|
| 199 |
+
}
|
| 200 |
+
});
|
| 201 |
+
|
| 202 |
+
return transformed_info;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
export function get_type(
|
| 206 |
+
type: { type: any; description: string },
|
| 207 |
+
component: string,
|
| 208 |
+
serializer: string,
|
| 209 |
+
signature_type: "return" | "parameter"
|
| 210 |
+
): string | undefined {
|
| 211 |
+
if (component === "Api") return type.type;
|
| 212 |
+
switch (type?.type) {
|
| 213 |
+
case "string":
|
| 214 |
+
return "string";
|
| 215 |
+
case "boolean":
|
| 216 |
+
return "boolean";
|
| 217 |
+
case "number":
|
| 218 |
+
return "number";
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
if (
|
| 222 |
+
serializer === "JSONSerializable" ||
|
| 223 |
+
serializer === "StringSerializable"
|
| 224 |
+
) {
|
| 225 |
+
return "any";
|
| 226 |
+
} else if (serializer === "ListStringSerializable") {
|
| 227 |
+
return "string[]";
|
| 228 |
+
} else if (component === "Image") {
|
| 229 |
+
return signature_type === "parameter" ? "Blob | File | Buffer" : "string";
|
| 230 |
+
} else if (serializer === "FileSerializable") {
|
| 231 |
+
if (type?.type === "array") {
|
| 232 |
+
return signature_type === "parameter"
|
| 233 |
+
? "(Blob | File | Buffer)[]"
|
| 234 |
+
: `{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}[]`;
|
| 235 |
+
}
|
| 236 |
+
return signature_type === "parameter"
|
| 237 |
+
? "Blob | File | Buffer"
|
| 238 |
+
: `{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}`;
|
| 239 |
+
} else if (serializer === "GallerySerializable") {
|
| 240 |
+
return signature_type === "parameter"
|
| 241 |
+
? "[(Blob | File | Buffer), (string | null)][]"
|
| 242 |
+
: `[{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}, (string | null))][]`;
|
| 243 |
+
}
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
export function get_description(
|
| 247 |
+
type: { type: any; description: string },
|
| 248 |
+
serializer: string
|
| 249 |
+
): string {
|
| 250 |
+
if (serializer === "GallerySerializable") {
|
| 251 |
+
return "array of [file, label] tuples";
|
| 252 |
+
} else if (serializer === "ListStringSerializable") {
|
| 253 |
+
return "array of strings";
|
| 254 |
+
} else if (serializer === "FileSerializable") {
|
| 255 |
+
return "array of files or single file";
|
| 256 |
+
}
|
| 257 |
+
return type?.description;
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
export function handle_message(
|
| 261 |
+
data: any,
|
| 262 |
+
last_status: Status["stage"]
|
| 263 |
+
): {
|
| 264 |
+
type:
|
| 265 |
+
| "hash"
|
| 266 |
+
| "data"
|
| 267 |
+
| "update"
|
| 268 |
+
| "complete"
|
| 269 |
+
| "generating"
|
| 270 |
+
| "log"
|
| 271 |
+
| "none"
|
| 272 |
+
| "heartbeat"
|
| 273 |
+
| "streaming"
|
| 274 |
+
| "broken_connection"
|
| 275 |
+
| "unexpected_error";
|
| 276 |
+
data?: any;
|
| 277 |
+
status?: Status;
|
| 278 |
+
original_msg?: string;
|
| 279 |
+
} {
|
| 280 |
+
const queue = true;
|
| 281 |
+
switch (data.msg) {
|
| 282 |
+
case "send_data":
|
| 283 |
+
return { type: "data" };
|
| 284 |
+
case "send_hash":
|
| 285 |
+
return { type: "hash" };
|
| 286 |
+
case "queue_full":
|
| 287 |
+
return {
|
| 288 |
+
type: "update",
|
| 289 |
+
status: {
|
| 290 |
+
queue,
|
| 291 |
+
message: QUEUE_FULL_MSG,
|
| 292 |
+
stage: "error",
|
| 293 |
+
code: data.code,
|
| 294 |
+
success: data.success
|
| 295 |
+
}
|
| 296 |
+
};
|
| 297 |
+
case "heartbeat":
|
| 298 |
+
return {
|
| 299 |
+
type: "heartbeat"
|
| 300 |
+
};
|
| 301 |
+
case "unexpected_error":
|
| 302 |
+
return {
|
| 303 |
+
type: "unexpected_error",
|
| 304 |
+
status: {
|
| 305 |
+
queue,
|
| 306 |
+
message: data.message,
|
| 307 |
+
session_not_found: data.session_not_found,
|
| 308 |
+
stage: "error",
|
| 309 |
+
success: false
|
| 310 |
+
}
|
| 311 |
+
};
|
| 312 |
+
case "broken_connection":
|
| 313 |
+
return {
|
| 314 |
+
type: "broken_connection",
|
| 315 |
+
status: {
|
| 316 |
+
queue,
|
| 317 |
+
message: data.message,
|
| 318 |
+
stage: "error",
|
| 319 |
+
success: false
|
| 320 |
+
}
|
| 321 |
+
};
|
| 322 |
+
case "estimation":
|
| 323 |
+
return {
|
| 324 |
+
type: "update",
|
| 325 |
+
status: {
|
| 326 |
+
queue,
|
| 327 |
+
stage: last_status || "pending",
|
| 328 |
+
code: data.code,
|
| 329 |
+
size: data.queue_size,
|
| 330 |
+
position: data.rank,
|
| 331 |
+
eta: data.rank_eta,
|
| 332 |
+
success: data.success
|
| 333 |
+
}
|
| 334 |
+
};
|
| 335 |
+
case "progress":
|
| 336 |
+
return {
|
| 337 |
+
type: "update",
|
| 338 |
+
status: {
|
| 339 |
+
queue,
|
| 340 |
+
stage: "pending",
|
| 341 |
+
code: data.code,
|
| 342 |
+
progress_data: data.progress_data,
|
| 343 |
+
success: data.success
|
| 344 |
+
}
|
| 345 |
+
};
|
| 346 |
+
case "log":
|
| 347 |
+
return { type: "log", data: data };
|
| 348 |
+
case "process_generating":
|
| 349 |
+
return {
|
| 350 |
+
type: "generating",
|
| 351 |
+
status: {
|
| 352 |
+
queue,
|
| 353 |
+
message: !data.success ? data.output.error : null,
|
| 354 |
+
stage: data.success ? "generating" : "error",
|
| 355 |
+
code: data.code,
|
| 356 |
+
progress_data: data.progress_data,
|
| 357 |
+
eta: data.average_duration,
|
| 358 |
+
changed_state_ids: data.success
|
| 359 |
+
? data.output.changed_state_ids
|
| 360 |
+
: undefined
|
| 361 |
+
},
|
| 362 |
+
data: data.success ? data.output : null
|
| 363 |
+
};
|
| 364 |
+
case "process_streaming":
|
| 365 |
+
return {
|
| 366 |
+
type: "streaming",
|
| 367 |
+
status: {
|
| 368 |
+
queue,
|
| 369 |
+
message: data.output.error,
|
| 370 |
+
stage: "streaming",
|
| 371 |
+
time_limit: data.time_limit,
|
| 372 |
+
code: data.code,
|
| 373 |
+
progress_data: data.progress_data,
|
| 374 |
+
changed_state_ids: data.output.changed_state_ids,
|
| 375 |
+
eta: data.eta
|
| 376 |
+
},
|
| 377 |
+
data: data.output
|
| 378 |
+
};
|
| 379 |
+
case "process_completed":
|
| 380 |
+
if ("error" in data.output) {
|
| 381 |
+
return {
|
| 382 |
+
type: "update",
|
| 383 |
+
status: {
|
| 384 |
+
queue,
|
| 385 |
+
title: (data.output.title as string | null) ?? "Error",
|
| 386 |
+
message:
|
| 387 |
+
(data.output.error as string | null) ?? "An error occurred",
|
| 388 |
+
visible: data.output.visible as boolean,
|
| 389 |
+
duration: data.output.duration as number,
|
| 390 |
+
stage: "error",
|
| 391 |
+
code: data.code,
|
| 392 |
+
success: data.success
|
| 393 |
+
}
|
| 394 |
+
};
|
| 395 |
+
}
|
| 396 |
+
return {
|
| 397 |
+
type: "complete",
|
| 398 |
+
status: {
|
| 399 |
+
queue,
|
| 400 |
+
message: !data.success ? data.output.error : undefined,
|
| 401 |
+
stage: data.success ? "complete" : "error",
|
| 402 |
+
code: data.code,
|
| 403 |
+
progress_data: data.progress_data,
|
| 404 |
+
changed_state_ids: data.success
|
| 405 |
+
? data.output.changed_state_ids
|
| 406 |
+
: undefined,
|
| 407 |
+
used_cache: data.used_cache,
|
| 408 |
+
cache_duration: data.cache_duration,
|
| 409 |
+
avg_time: data.avg_time
|
| 410 |
+
},
|
| 411 |
+
data: data.success ? data.output : null
|
| 412 |
+
};
|
| 413 |
+
|
| 414 |
+
case "process_starts":
|
| 415 |
+
return {
|
| 416 |
+
type: "update",
|
| 417 |
+
status: {
|
| 418 |
+
queue,
|
| 419 |
+
stage: "pending",
|
| 420 |
+
code: data.code,
|
| 421 |
+
size: data.rank,
|
| 422 |
+
position: 0,
|
| 423 |
+
success: data.success,
|
| 424 |
+
eta: data.eta
|
| 425 |
+
},
|
| 426 |
+
original_msg: "process_starts"
|
| 427 |
+
};
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
return { type: "none", status: { stage: "error", queue } };
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
/**
|
| 434 |
+
* Maps the provided `data` to the parameters defined by the `/info` endpoint response.
|
| 435 |
+
* This allows us to support both positional and keyword arguments passed to the client
|
| 436 |
+
* and ensures that all parameters are either directly provided or have default values assigned.
|
| 437 |
+
*
|
| 438 |
+
* @param {unknown[] | Record<string, unknown>} data - The input data for the function,
|
| 439 |
+
* which can be either an array of values for positional arguments or an object
|
| 440 |
+
* with key-value pairs for keyword arguments.
|
| 441 |
+
* @param {JsApiData[]} parameters - Array of parameter descriptions retrieved from the
|
| 442 |
+
* `/info` endpoint.
|
| 443 |
+
*
|
| 444 |
+
* @returns {unknown[]} - Returns an array of resolved data where each element corresponds
|
| 445 |
+
* to the expected parameter from the API. The `parameter_default` value is used where
|
| 446 |
+
* a value is not provided for a parameter, and optional parameters without defaults are
|
| 447 |
+
* set to `undefined`.
|
| 448 |
+
*
|
| 449 |
+
* @throws {Error} - Throws an error:
|
| 450 |
+
* - If more arguments are provided than are defined in the parameters.
|
| 451 |
+
* * - If no parameter value is provided for a required parameter and no default value is defined.
|
| 452 |
+
* - If an argument is provided that does not match any defined parameter.
|
| 453 |
+
*/
|
| 454 |
+
|
| 455 |
+
export const map_data_to_params = (
|
| 456 |
+
data: unknown[] | Record<string, unknown> = [],
|
| 457 |
+
endpoint_info: EndpointInfo<JsApiData | ApiData>
|
| 458 |
+
): unknown[] => {
|
| 459 |
+
// Workaround for the case where the endpoint_info is undefined
|
| 460 |
+
// See https://github.com/gradio-app/gradio/pull/8820#issuecomment-2237381761
|
| 461 |
+
const parameters = endpoint_info ? endpoint_info.parameters : [];
|
| 462 |
+
|
| 463 |
+
if (Array.isArray(data)) {
|
| 464 |
+
if (
|
| 465 |
+
endpoint_info &&
|
| 466 |
+
parameters.length > 0 &&
|
| 467 |
+
data.length > parameters.length
|
| 468 |
+
) {
|
| 469 |
+
console.warn("Too many arguments provided for the endpoint.");
|
| 470 |
+
}
|
| 471 |
+
return data;
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
const resolved_data: unknown[] = [];
|
| 475 |
+
const provided_keys = Object.keys(data);
|
| 476 |
+
|
| 477 |
+
parameters.forEach((param, index) => {
|
| 478 |
+
if (data.hasOwnProperty(param.parameter_name)) {
|
| 479 |
+
resolved_data[index] = data[param.parameter_name];
|
| 480 |
+
} else if (param.parameter_has_default) {
|
| 481 |
+
resolved_data[index] = param.parameter_default;
|
| 482 |
+
} else {
|
| 483 |
+
throw new Error(
|
| 484 |
+
`No value provided for required parameter: ${param.parameter_name}`
|
| 485 |
+
);
|
| 486 |
+
}
|
| 487 |
+
});
|
| 488 |
+
|
| 489 |
+
provided_keys.forEach((key) => {
|
| 490 |
+
if (!parameters.some((param) => param.parameter_name === key)) {
|
| 491 |
+
throw new Error(
|
| 492 |
+
`Parameter \`${key}\` is not a valid keyword argument. Please refer to the API for usage.`
|
| 493 |
+
);
|
| 494 |
+
}
|
| 495 |
+
});
|
| 496 |
+
|
| 497 |
+
resolved_data.forEach((value, idx) => {
|
| 498 |
+
if (value === undefined && !parameters[idx].parameter_has_default) {
|
| 499 |
+
throw new Error(
|
| 500 |
+
`No value provided for required parameter: ${parameters[idx].parameter_name}`
|
| 501 |
+
);
|
| 502 |
+
}
|
| 503 |
+
});
|
| 504 |
+
|
| 505 |
+
return resolved_data;
|
| 506 |
+
};
|
6.29.1/client/src/helpers/data.ts
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import {
|
| 2 |
+
type ApiData,
|
| 3 |
+
type BlobRef,
|
| 4 |
+
type Config,
|
| 5 |
+
type EndpointInfo,
|
| 6 |
+
type JsApiData,
|
| 7 |
+
type DataType,
|
| 8 |
+
Command,
|
| 9 |
+
type Dependency,
|
| 10 |
+
type ComponentMeta
|
| 11 |
+
} from "../types";
|
| 12 |
+
import { FileData } from "../upload";
|
| 13 |
+
|
| 14 |
+
const is_node =
|
| 15 |
+
typeof process !== "undefined" && process.versions && process.versions.node;
|
| 16 |
+
|
| 17 |
+
export function update_object(
|
| 18 |
+
object: { [x: string]: any },
|
| 19 |
+
newValue: any,
|
| 20 |
+
stack: (string | number)[]
|
| 21 |
+
): void {
|
| 22 |
+
while (stack.length > 1) {
|
| 23 |
+
const key = stack.shift();
|
| 24 |
+
if (typeof key === "string" || typeof key === "number") {
|
| 25 |
+
object = object[key];
|
| 26 |
+
} else {
|
| 27 |
+
throw new Error("Invalid key type");
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
const key = stack.shift();
|
| 32 |
+
if (typeof key === "string" || typeof key === "number") {
|
| 33 |
+
object[key] = newValue;
|
| 34 |
+
} else {
|
| 35 |
+
throw new Error("Invalid key type");
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
export async function walk_and_store_blobs(
|
| 40 |
+
data: DataType,
|
| 41 |
+
type: string | undefined = undefined,
|
| 42 |
+
path: string[] = [],
|
| 43 |
+
root = false,
|
| 44 |
+
endpoint_info: EndpointInfo<ApiData | JsApiData> | undefined = undefined
|
| 45 |
+
): Promise<BlobRef[]> {
|
| 46 |
+
if (Array.isArray(data)) {
|
| 47 |
+
let blob_refs: BlobRef[] = [];
|
| 48 |
+
|
| 49 |
+
await Promise.all(
|
| 50 |
+
data.map(async (_, index) => {
|
| 51 |
+
let new_path = path.slice();
|
| 52 |
+
new_path.push(String(index));
|
| 53 |
+
|
| 54 |
+
const array_refs = await walk_and_store_blobs(
|
| 55 |
+
data[index],
|
| 56 |
+
root
|
| 57 |
+
? endpoint_info?.parameters[index]?.component || undefined
|
| 58 |
+
: type,
|
| 59 |
+
new_path,
|
| 60 |
+
false,
|
| 61 |
+
endpoint_info
|
| 62 |
+
);
|
| 63 |
+
|
| 64 |
+
blob_refs = blob_refs.concat(array_refs);
|
| 65 |
+
})
|
| 66 |
+
);
|
| 67 |
+
|
| 68 |
+
return blob_refs;
|
| 69 |
+
} else if (
|
| 70 |
+
(globalThis.Buffer && data instanceof globalThis.Buffer) ||
|
| 71 |
+
data instanceof Blob
|
| 72 |
+
) {
|
| 73 |
+
return [
|
| 74 |
+
{
|
| 75 |
+
path: path,
|
| 76 |
+
// Preserve the original Blob/File so that filenames and MIME
|
| 77 |
+
// types survive the upload (see issue #10758). Only Buffers
|
| 78 |
+
// need to be converted to Blobs.
|
| 79 |
+
blob: data instanceof Blob ? data : new Blob([data as any]),
|
| 80 |
+
type
|
| 81 |
+
}
|
| 82 |
+
];
|
| 83 |
+
} else if (typeof data === "object" && data !== null) {
|
| 84 |
+
let blob_refs: BlobRef[] = [];
|
| 85 |
+
for (const key of Object.keys(data) as (keyof typeof data)[]) {
|
| 86 |
+
const new_path = [...path, key];
|
| 87 |
+
const value = data[key];
|
| 88 |
+
|
| 89 |
+
blob_refs = blob_refs.concat(
|
| 90 |
+
await walk_and_store_blobs(
|
| 91 |
+
value,
|
| 92 |
+
undefined,
|
| 93 |
+
new_path,
|
| 94 |
+
false,
|
| 95 |
+
endpoint_info
|
| 96 |
+
)
|
| 97 |
+
);
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
return blob_refs;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
return [];
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
export function skip_queue(id: number, config: Config): boolean {
|
| 107 |
+
let fn_queue = config?.dependencies?.find((dep) => dep.id == id)?.queue;
|
| 108 |
+
if (fn_queue != null) {
|
| 109 |
+
return !fn_queue;
|
| 110 |
+
}
|
| 111 |
+
return !config.enable_queue;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
// todo: add jsdoc for this function
|
| 115 |
+
|
| 116 |
+
export function post_message<Res = any>(
|
| 117 |
+
message: any,
|
| 118 |
+
origin: string
|
| 119 |
+
): Promise<Res> {
|
| 120 |
+
return new Promise((res, _rej) => {
|
| 121 |
+
const channel = new MessageChannel();
|
| 122 |
+
channel.port1.onmessage = (({ data }) => {
|
| 123 |
+
channel.port1.close();
|
| 124 |
+
res(data);
|
| 125 |
+
}) as (ev: MessageEvent<Res>) => void;
|
| 126 |
+
window.parent.postMessage(message, origin, [channel.port2]);
|
| 127 |
+
});
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
export function handle_file(
|
| 131 |
+
file_or_url: File | string | Blob | Buffer
|
| 132 |
+
): FileData | Blob | Command {
|
| 133 |
+
if (typeof file_or_url === "string") {
|
| 134 |
+
if (
|
| 135 |
+
file_or_url.startsWith("http://") ||
|
| 136 |
+
file_or_url.startsWith("https://")
|
| 137 |
+
) {
|
| 138 |
+
return {
|
| 139 |
+
path: file_or_url,
|
| 140 |
+
url: file_or_url,
|
| 141 |
+
orig_name: file_or_url.split("/").pop() ?? "unknown",
|
| 142 |
+
meta: { _type: "gradio.FileData" }
|
| 143 |
+
};
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
if (is_node) {
|
| 147 |
+
// Handle local file paths
|
| 148 |
+
return new Command("upload_file", {
|
| 149 |
+
path: file_or_url,
|
| 150 |
+
name: file_or_url,
|
| 151 |
+
orig_path: file_or_url
|
| 152 |
+
});
|
| 153 |
+
}
|
| 154 |
+
} else if (typeof File !== "undefined" && file_or_url instanceof File) {
|
| 155 |
+
// Return the File as-is so that its filename and MIME type are
|
| 156 |
+
// preserved when it is uploaded (see issue #10758).
|
| 157 |
+
return file_or_url;
|
| 158 |
+
} else if (globalThis.Buffer && file_or_url instanceof globalThis.Buffer) {
|
| 159 |
+
return new Blob([file_or_url as any]);
|
| 160 |
+
} else if (file_or_url instanceof Blob) {
|
| 161 |
+
return file_or_url;
|
| 162 |
+
}
|
| 163 |
+
throw new Error(
|
| 164 |
+
"Invalid input: must be a URL, File, Blob, or Buffer object."
|
| 165 |
+
);
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
/**
|
| 169 |
+
* Handles the payload by filtering out state inputs and returning an array of resolved payload values.
|
| 170 |
+
* We send null values for state inputs to the server, but we don't want to include them in the resolved payload.
|
| 171 |
+
*
|
| 172 |
+
* @param resolved_payload - The resolved payload values received from the client or the server
|
| 173 |
+
* @param dependency - The dependency object.
|
| 174 |
+
* @param components - The array of component metadata.
|
| 175 |
+
* @param with_null_state - Optional. Specifies whether to include null values for state inputs. Default is false.
|
| 176 |
+
* @returns An array of resolved payload values, filtered based on the dependency and component metadata.
|
| 177 |
+
*/
|
| 178 |
+
export function handle_payload(
|
| 179 |
+
resolved_payload: unknown[],
|
| 180 |
+
dependency: Dependency,
|
| 181 |
+
components: ComponentMeta[],
|
| 182 |
+
type: "input" | "output",
|
| 183 |
+
with_null_state = false
|
| 184 |
+
): unknown[] {
|
| 185 |
+
if (type === "input" && !with_null_state) {
|
| 186 |
+
throw new Error("Invalid code path. Cannot skip state inputs for input.");
|
| 187 |
+
}
|
| 188 |
+
// data comes from the server with null state values so we skip
|
| 189 |
+
if (type === "output" && with_null_state) {
|
| 190 |
+
return resolved_payload;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
let updated_payload: unknown[] = [];
|
| 194 |
+
let payload_index = 0;
|
| 195 |
+
const deps = type === "input" ? dependency.inputs : dependency.outputs;
|
| 196 |
+
for (let i = 0; i < deps.length; i++) {
|
| 197 |
+
const input_id = deps[i];
|
| 198 |
+
const component = components.find((c) => c.id === input_id);
|
| 199 |
+
|
| 200 |
+
if (component?.type === "state") {
|
| 201 |
+
// input + with_null_state needs us to fill state with null values
|
| 202 |
+
if (with_null_state) {
|
| 203 |
+
if (resolved_payload.length === deps.length) {
|
| 204 |
+
const value = resolved_payload[payload_index];
|
| 205 |
+
updated_payload.push(value);
|
| 206 |
+
payload_index++;
|
| 207 |
+
} else {
|
| 208 |
+
updated_payload.push(null);
|
| 209 |
+
}
|
| 210 |
+
} else {
|
| 211 |
+
// this is output & !with_null_state, we skip state inputs
|
| 212 |
+
// the server payload always comes with null state values so we move along the payload index
|
| 213 |
+
payload_index++;
|
| 214 |
+
continue;
|
| 215 |
+
}
|
| 216 |
+
// input & !with_null_state isn't a case we care about, server needs null
|
| 217 |
+
continue;
|
| 218 |
+
} else {
|
| 219 |
+
const value = resolved_payload[payload_index];
|
| 220 |
+
updated_payload.push(value);
|
| 221 |
+
payload_index++;
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
return updated_payload;
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
const FILE_ROUTE_PREFIXES = ["/file=", "/file/", "/stream/", "/proxy="];
|
| 229 |
+
|
| 230 |
+
/**
|
| 231 |
+
* Add the Space JWT required for browser-managed media requests.
|
| 232 |
+
*
|
| 233 |
+
* This is a bearer credential and must not be logged or persisted. Restrict it
|
| 234 |
+
* to Gradio routes that serve files; the user's Hugging Face token remains in
|
| 235 |
+
* the Authorization header used to obtain this credential.
|
| 236 |
+
*/
|
| 237 |
+
export function sign_file_urls(
|
| 238 |
+
data: unknown,
|
| 239 |
+
root: string,
|
| 240 |
+
api_prefix: string,
|
| 241 |
+
jwt: string | false
|
| 242 |
+
): void {
|
| 243 |
+
if (!jwt || data === null || typeof data !== "object") return;
|
| 244 |
+
|
| 245 |
+
const signature = jwt;
|
| 246 |
+
const root_url = new URL(root);
|
| 247 |
+
const root_path = root_url.pathname.replace(/\/+$/, "");
|
| 248 |
+
const normalized_api_prefix = api_prefix
|
| 249 |
+
? `/${api_prefix.replace(/^\/+|\/+$/g, "")}`
|
| 250 |
+
: "";
|
| 251 |
+
const route_bases = new Set([
|
| 252 |
+
`${root_path}${normalized_api_prefix}`,
|
| 253 |
+
normalized_api_prefix
|
| 254 |
+
]);
|
| 255 |
+
if (!normalized_api_prefix) {
|
| 256 |
+
route_bases.add(`${root_path}/gradio_api`);
|
| 257 |
+
route_bases.add("/gradio_api");
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
function visit(value: unknown): void {
|
| 261 |
+
if (value === null || typeof value !== "object") return;
|
| 262 |
+
|
| 263 |
+
const object = value as Record<string, unknown>;
|
| 264 |
+
const meta = object.meta as Record<string, unknown> | undefined;
|
| 265 |
+
if (meta?._type === "gradio.FileData" && typeof object.url === "string") {
|
| 266 |
+
const file_url = new URL(
|
| 267 |
+
object.url,
|
| 268 |
+
`${root_url.toString().replace(/\/$/, "")}/`
|
| 269 |
+
);
|
| 270 |
+
const is_file_route = [...route_bases].some((base) =>
|
| 271 |
+
FILE_ROUTE_PREFIXES.some((route) =>
|
| 272 |
+
file_url.pathname.startsWith(`${base}${route}`)
|
| 273 |
+
)
|
| 274 |
+
);
|
| 275 |
+
if (
|
| 276 |
+
(file_url.protocol === "http:" || file_url.protocol === "https:") &&
|
| 277 |
+
file_url.origin === root_url.origin &&
|
| 278 |
+
is_file_route
|
| 279 |
+
) {
|
| 280 |
+
file_url.searchParams.set("__sign", signature);
|
| 281 |
+
object.url = file_url.toString();
|
| 282 |
+
}
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
for (const child of Object.values(object)) visit(child);
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
visit(data);
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
export function sign_config_file_urls(
|
| 292 |
+
config: Config,
|
| 293 |
+
jwt: string | false
|
| 294 |
+
): void {
|
| 295 |
+
for (const component of config.components || []) {
|
| 296 |
+
sign_file_urls(
|
| 297 |
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types";
|
| 2 |
+
import {
|
| 3 |
+
CONFIG_ERROR_MSG,
|
| 4 |
+
CONFIG_URL,
|
| 5 |
+
INVALID_CREDENTIALS_MSG,
|
| 6 |
+
LOGIN_URL,
|
| 7 |
+
MISSING_CREDENTIALS_MSG,
|
| 8 |
+
PRIVATE_SPACE_MSG,
|
| 9 |
+
SPACE_METADATA_ERROR_MSG,
|
| 10 |
+
UNAUTHORIZED_MSG
|
| 11 |
+
} from "../constants";
|
| 12 |
+
import { Client } from "..";
|
| 13 |
+
import { join_urls, process_endpoint } from "./api_info";
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* This function is used to resolve the URL for making requests when the app has a root path.
|
| 17 |
+
* The root path could be a path suffix like "/app" which is appended to the end of the base URL. Or
|
| 18 |
+
* it could be a full URL like "https://abidlabs-test-client-replica--gqf2x.hf.space" which is used when hosting
|
| 19 |
+
* Gradio apps on Hugging Face Spaces.
|
| 20 |
+
* @param {string} base_url The base URL at which the Gradio server is hosted
|
| 21 |
+
* @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)
|
| 22 |
+
* @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.
|
| 23 |
+
* @returns {string} the resolved URL
|
| 24 |
+
*/
|
| 25 |
+
export function resolve_root(
|
| 26 |
+
base_url: string,
|
| 27 |
+
root_path: string,
|
| 28 |
+
prioritize_base: boolean
|
| 29 |
+
): string {
|
| 30 |
+
if (root_path.startsWith("http://") || root_path.startsWith("https://")) {
|
| 31 |
+
return prioritize_base ? base_url : root_path;
|
| 32 |
+
}
|
| 33 |
+
return base_url + root_path;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
export async function get_jwt(
|
| 37 |
+
space: string,
|
| 38 |
+
token: `hf_${string}`,
|
| 39 |
+
cookies?: string | null
|
| 40 |
+
): Promise<string | false> {
|
| 41 |
+
try {
|
| 42 |
+
const r = await fetch(`https://huggingface.co/api/spaces/${space}/jwt`, {
|
| 43 |
+
headers: {
|
| 44 |
+
Authorization: `Bearer ${token}`,
|
| 45 |
+
...(cookies ? { Cookie: cookies } : {})
|
| 46 |
+
}
|
| 47 |
+
});
|
| 48 |
+
|
| 49 |
+
const jwt = (await r.json()).token;
|
| 50 |
+
|
| 51 |
+
return jwt || false;
|
| 52 |
+
} catch (e) {
|
| 53 |
+
return false;
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* The `hf_token` option was renamed to `token`, but a lot of existing code
|
| 59 |
+
* (and the Python client) still uses `hf_token`. Accept it as an alias so
|
| 60 |
+
* that authenticated requests are not silently sent without credentials,
|
| 61 |
+
* which previously surfaced as "Could not resolve app config" errors when
|
| 62 |
+
* connecting to private Spaces.
|
| 63 |
+
*/
|
| 64 |
+
export function normalise_token_option(options: ClientOptions): void {
|
| 65 |
+
if (options.hf_token && !options.token) {
|
| 66 |
+
options.token = options.hf_token;
|
| 67 |
+
console.warn(
|
| 68 |
+
"The `hf_token` option has been renamed to `token`. Support for `hf_token` will be removed in a future version of @gradio/client."
|
| 69 |
+
);
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
export function map_names_to_ids(
|
| 74 |
+
fns: Config["dependencies"]
|
| 75 |
+
): Record<string, number> {
|
| 76 |
+
let apis: Record<string, number> = {};
|
| 77 |
+
|
| 78 |
+
fns.forEach(({ api_name, id }) => {
|
| 79 |
+
if (api_name) apis[api_name] = id;
|
| 80 |
+
});
|
| 81 |
+
return apis;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
export function resolve_config_root(
|
| 85 |
+
root: string,
|
| 86 |
+
current_location: string,
|
| 87 |
+
prioritize_current_location = false
|
| 88 |
+
): string {
|
| 89 |
+
const current_url = new URL(current_location);
|
| 90 |
+
const root_url = new URL(root, current_url);
|
| 91 |
+
// Modern Colab configs can omit is_colab even though the backend root still
|
| 92 |
+
// uses one of Colab's internal-only hostname families.
|
| 93 |
+
const is_colab_runtime =
|
| 94 |
+
root_url.hostname.endsWith(".colab-user-runtimes.internal") ||
|
| 95 |
+
root_url.hostname.endsWith(".codatalab-user-runtimes.internal");
|
| 96 |
+
if (prioritize_current_location || is_colab_runtime) {
|
| 97 |
+
return new URL(new URL(root, current_url).pathname, current_url)
|
| 98 |
+
.toString()
|
| 99 |
+
.replace(/\/$/, "");
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
if (root_url.hostname !== current_url.hostname) {
|
| 103 |
+
return root;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
root_url.protocol = current_url.protocol;
|
| 107 |
+
root_url.host = current_url.host;
|
| 108 |
+
return root_url.toString().replace(/\/$/, "");
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
export async function resolve_config(
|
| 112 |
+
this: Client,
|
| 113 |
+
endpoint: string,
|
| 114 |
+
strip_current_page = true
|
| 115 |
+
): Promise<Config | undefined> {
|
| 116 |
+
const headers: Record<string, string> = this.options.token
|
| 117 |
+
? { Authorization: `Bearer ${this.options.token}` }
|
| 118 |
+
: {};
|
| 119 |
+
|
| 120 |
+
if (
|
| 121 |
+
typeof window !== "undefined" &&
|
| 122 |
+
window.gradio_config &&
|
| 123 |
+
location.origin !== "http://localhost:9876"
|
| 124 |
+
) {
|
| 125 |
+
if (strip_current_page && window.gradio_config.current_page) {
|
| 126 |
+
endpoint = endpoint.substring(0, endpoint.lastIndexOf("/"));
|
| 127 |
+
}
|
| 128 |
+
if (
|
| 129 |
+
window.gradio_config.dev_mode ||
|
| 130 |
+
(typeof window !== "undefined" && window?.BUILD_MODE === "dev")
|
| 131 |
+
) {
|
| 132 |
+
let config_url = new URL(join_urls(endpoint, CONFIG_URL));
|
| 133 |
+
if (this.deep_link)
|
| 134 |
+
config_url.searchParams.set("deep_link", this.deep_link);
|
| 135 |
+
if (this.page !== null) config_url.searchParams.set("page", this.page);
|
| 136 |
+
const response = await this.fetch(config_url, {
|
| 137 |
+
headers,
|
| 138 |
+
credentials: this.options.credentials ?? "same-origin"
|
| 139 |
+
});
|
| 140 |
+
const config = await handleConfigResponse(response, !!this.options.auth);
|
| 141 |
+
config.root = endpoint || config.root;
|
| 142 |
+
// @ts-ignore
|
| 143 |
+
window.gradio_config = {
|
| 144 |
+
...config,
|
| 145 |
+
current_page: window.gradio_config.current_page
|
| 146 |
+
};
|
| 147 |
+
}
|
| 148 |
+
// The page was rendered by this Gradio server, so a same-host root may
|
| 149 |
+
// contain an internal protocol or port supplied by a reverse proxy. Keep
|
| 150 |
+
// the configured path, but use the browser-visible origin for requests
|
| 151 |
+
// made by the client itself (queue, upload, reset, etc.). Colab's public
|
| 152 |
+
// proxy uses a different hostname, so always prefer the browser origin.
|
| 153 |
+
const config = { ...window.gradio_config } as unknown as Config;
|
| 154 |
+
config.root = resolve_config_root(
|
| 155 |
+
config.root,
|
| 156 |
+
location.href,
|
| 157 |
+
config.is_colab
|
| 158 |
+
);
|
| 159 |
+
return config;
|
| 160 |
+
} else if (endpoint) {
|
| 161 |
+
let config_url = new URL(join_urls(endpoint, CONFIG_URL));
|
| 162 |
+
if (this.deep_link)
|
| 163 |
+
config_url.searchParams.set("deep_link", this.deep_link);
|
| 164 |
+
if (this.page !== null) config_url.searchParams.set("page", this.page);
|
| 165 |
+
|
| 166 |
+
const response = await this.fetch(config_url, {
|
| 167 |
+
headers,
|
| 168 |
+
credentials: this.options.credentials ?? "same-origin"
|
| 169 |
+
});
|
| 170 |
+
|
| 171 |
+
const config = await handleConfigResponse(response, !!this.options.auth);
|
| 172 |
+
// Preserve the backend-provided root if available (it contains the correct public URL)
|
| 173 |
+
// Only fall back to endpoint if the backend didn't provide a root
|
| 174 |
+
if (!config.root) {
|
| 175 |
+
config.root = endpoint;
|
| 176 |
+
}
|
| 177 |
+
return config;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
throw new Error(CONFIG_ERROR_MSG);
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
async function handleConfigResponse(
|
| 184 |
+
response: Response,
|
| 185 |
+
authorized: boolean
|
| 186 |
+
): Promise<Config> {
|
| 187 |
+
if (response?.status === 401 && !authorized) {
|
| 188 |
+
let error_data: any = null;
|
| 189 |
+
try {
|
| 190 |
+
error_data = await response.json();
|
| 191 |
+
} catch (e) {
|
| 192 |
+
// Unauthenticated requests to private Spaces receive a non-JSON 401
|
| 193 |
+
// page from the Hugging Face proxy rather than a Gradio auth payload.
|
| 194 |
+
throw new Error(PRIVATE_SPACE_MSG);
|
| 195 |
+
}
|
| 196 |
+
const auth_message = error_data?.detail?.auth_message;
|
| 197 |
+
throw new Error(auth_message || MISSING_CREDENTIALS_MSG);
|
| 198 |
+
} else if (response?.status === 401 && authorized) {
|
| 199 |
+
throw new Error(INVALID_CREDENTIALS_MSG);
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
if (response?.status === 200) {
|
| 203 |
+
let config = await response.json();
|
| 204 |
+
config.dependencies?.forEach((dep: any, i: number) => {
|
| 205 |
+
if (dep.id === undefined) {
|
| 206 |
+
dep.id = i;
|
| 207 |
+
}
|
| 208 |
+
});
|
| 209 |
+
return config;
|
| 210 |
+
} else if (response?.status === 401) {
|
| 211 |
+
throw new Error(UNAUTHORIZED_MSG);
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
throw new Error(
|
| 215 |
+
`${CONFIG_ERROR_MSG}(received status ${response?.status} when fetching the app config)`
|
| 216 |
+
);
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
export async function resolve_cookies(this: Client): Promise<void> {
|
| 220 |
+
const { http_protocol, host } = await process_endpoint(
|
| 221 |
+
this.app_reference,
|
| 222 |
+
this.options.token
|
| 223 |
+
);
|
| 224 |
+
|
| 225 |
+
try {
|
| 226 |
+
if (this.options.auth) {
|
| 227 |
+
const cookie_header = await get_cookie_header(
|
| 228 |
+
http_protocol,
|
| 229 |
+
host,
|
| 230 |
+
this.options.auth,
|
| 231 |
+
this.fetch,
|
| 232 |
+
this.options.token,
|
| 233 |
+
this.options.credentials
|
| 234 |
+
);
|
| 235 |
+
|
| 236 |
+
if (cookie_header) this.set_cookies(cookie_header);
|
| 237 |
+
}
|
| 238 |
+
} catch (e: unknown) {
|
| 239 |
+
throw Error((e as Error).message);
|
| 240 |
+
}
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
// separating this from client-bound resolve_cookies so that it can be used in duplicate
|
| 244 |
+
export async function get_cookie_header(
|
| 245 |
+
http_protocol: string,
|
| 246 |
+
host: string,
|
| 247 |
+
auth: [string, string],
|
| 248 |
+
_fetch: typeof fetch,
|
| 249 |
+
token?: `hf_${string}`,
|
| 250 |
+
credentials?: RequestCredentials
|
| 251 |
+
): Promise<string | null> {
|
| 252 |
+
const formData = new FormData();
|
| 253 |
+
formData.append("username", auth?.[0]);
|
| 254 |
+
formData.append("password", auth?.[1]);
|
| 255 |
+
|
| 256 |
+
let headers: { Authorization?: string } = {};
|
| 257 |
+
|
| 258 |
+
if (token) {
|
| 259 |
+
headers.Authorization = `Bearer ${token}`;
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
const res = await _fetch(`${http_protocol}//${host}/${LOGIN_URL}`, {
|
| 263 |
+
headers,
|
| 264 |
+
method: "POST",
|
| 265 |
+
body: formData,
|
| 266 |
+
credentials: credentials ?? "same-origin"
|
| 267 |
+
});
|
| 268 |
+
|
| 269 |
+
if (res.status === 200) {
|
| 270 |
+
return res.headers.get("set-cookie");
|
| 271 |
+
} else if (res.status === 401) {
|
| 272 |
+
throw new Error(INVALID_CREDENTIALS_MSG);
|
| 273 |
+
} else {
|
| 274 |
+
throw new Error(SPACE_METADATA_ERROR_MSG);
|
| 275 |
+
}
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
export function determine_protocol(endpoint: string): {
|
| 279 |
+
ws_protocol: "ws" | "wss";
|
| 280 |
+
http_protocol: "http:" | "https:";
|
| 281 |
+
host: string;
|
| 282 |
+
} {
|
| 283 |
+
if (endpoint.startsWith("http")) {
|
| 284 |
+
const { protocol, host, pathname } = new URL(endpoint);
|
| 285 |
+
|
| 286 |
+
return {
|
| 287 |
+
ws_protocol: protocol === "https:" ? "wss" : "ws",
|
| 288 |
+
http_protocol: protocol as "http:" | "https:",
|
| 289 |
+
host: host + (pathname !== "/" ? pathname : "")
|
| 290 |
+
};
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
// default to secure if no protocol is provided
|
| 294 |
+
|
| 295 |
+
return {
|
| 296 |
+
ws_protocol: "wss",
|
| 297 |
+
http_protocol: "https:",
|
| 298 |
+
host: new URL(endpoint).host
|
| 299 |
+
};
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
export const parse_and_set_cookies = (cookie_header: string): string[] => {
|
| 303 |
+
let cookies: string[] = [];
|
| 304 |
+
const parts = cookie_header.split(/,(?=\s*[^\s=;]+=[^\s=;]+)/);
|
| 305 |
+
parts.forEach((cookie) => {
|
| 306 |
+
const [cookie_name, cookie_value] = cookie.split(";")[0].split("=");
|
| 307 |
+
if (cookie_name && cookie_value) {
|
| 308 |
+
cookies.push(`${cookie_name.trim()}=${cookie_value.trim()}`);
|
| 309 |
+
}
|
| 310 |
+
});
|
| 311 |
+
return cookies;
|
| 312 |
+
};
|
6.29.1/client/src/helpers/spaces.ts
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import {
|
| 2 |
+
RUNTIME_URL,
|
| 3 |
+
SLEEPTIME_URL,
|
| 4 |
+
SPACE_STATUS_ERROR_MSG
|
| 5 |
+
} from "../constants";
|
| 6 |
+
import { RE_SPACE_NAME } from "./api_info";
|
| 7 |
+
import type { SpaceStatusCallback } from "../types";
|
| 8 |
+
|
| 9 |
+
export async function check_space_status(
|
| 10 |
+
id: string,
|
| 11 |
+
type: "subdomain" | "space_name",
|
| 12 |
+
status_callback: SpaceStatusCallback
|
| 13 |
+
): Promise<void> {
|
| 14 |
+
let endpoint =
|
| 15 |
+
type === "subdomain"
|
| 16 |
+
? `https://huggingface.co/api/spaces/by-subdomain/${id}`
|
| 17 |
+
: `https://huggingface.co/api/spaces/${id}`;
|
| 18 |
+
let response;
|
| 19 |
+
let _status;
|
| 20 |
+
try {
|
| 21 |
+
response = await fetch(endpoint);
|
| 22 |
+
_status = response.status;
|
| 23 |
+
if (_status !== 200) {
|
| 24 |
+
throw new Error();
|
| 25 |
+
}
|
| 26 |
+
response = await response.json();
|
| 27 |
+
} catch (e) {
|
| 28 |
+
status_callback({
|
| 29 |
+
status: "error",
|
| 30 |
+
load_status: "error",
|
| 31 |
+
message: SPACE_STATUS_ERROR_MSG,
|
| 32 |
+
detail: "NOT_FOUND"
|
| 33 |
+
});
|
| 34 |
+
return;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
if (!response || _status !== 200) return;
|
| 38 |
+
const {
|
| 39 |
+
runtime: { stage },
|
| 40 |
+
id: space_name
|
| 41 |
+
} = response;
|
| 42 |
+
|
| 43 |
+
switch (stage) {
|
| 44 |
+
case "STOPPED":
|
| 45 |
+
case "SLEEPING":
|
| 46 |
+
status_callback({
|
| 47 |
+
status: "sleeping",
|
| 48 |
+
load_status: "pending",
|
| 49 |
+
message: "Space is asleep. Waking it up...",
|
| 50 |
+
detail: stage
|
| 51 |
+
});
|
| 52 |
+
|
| 53 |
+
setTimeout(() => {
|
| 54 |
+
check_space_status(id, type, status_callback);
|
| 55 |
+
}, 1000); // poll for status
|
| 56 |
+
break;
|
| 57 |
+
case "PAUSED":
|
| 58 |
+
status_callback({
|
| 59 |
+
status: "paused",
|
| 60 |
+
load_status: "error",
|
| 61 |
+
message:
|
| 62 |
+
"This space has been paused by the author. If you would like to try this demo, consider duplicating the space.",
|
| 63 |
+
detail: stage,
|
| 64 |
+
discussions_enabled: await discussions_enabled(space_name)
|
| 65 |
+
});
|
| 66 |
+
break;
|
| 67 |
+
case "RUNNING":
|
| 68 |
+
case "RUNNING_BUILDING":
|
| 69 |
+
status_callback({
|
| 70 |
+
status: "running",
|
| 71 |
+
load_status: "complete",
|
| 72 |
+
message: "Space is running.",
|
| 73 |
+
detail: stage
|
| 74 |
+
});
|
| 75 |
+
break;
|
| 76 |
+
case "BUILDING":
|
| 77 |
+
status_callback({
|
| 78 |
+
status: "building",
|
| 79 |
+
load_status: "pending",
|
| 80 |
+
message: "Space is building...",
|
| 81 |
+
detail: stage
|
| 82 |
+
});
|
| 83 |
+
|
| 84 |
+
setTimeout(() => {
|
| 85 |
+
check_space_status(id, type, status_callback);
|
| 86 |
+
}, 1000);
|
| 87 |
+
break;
|
| 88 |
+
case "APP_STARTING":
|
| 89 |
+
status_callback({
|
| 90 |
+
status: "starting",
|
| 91 |
+
load_status: "pending",
|
| 92 |
+
message: "Space is starting...",
|
| 93 |
+
detail: stage
|
| 94 |
+
});
|
| 95 |
+
|
| 96 |
+
setTimeout(() => {
|
| 97 |
+
check_space_status(id, type, status_callback);
|
| 98 |
+
}, 1000);
|
| 99 |
+
break;
|
| 100 |
+
default:
|
| 101 |
+
status_callback({
|
| 102 |
+
status: "space_error",
|
| 103 |
+
load_status: "error",
|
| 104 |
+
message: "This space is experiencing an issue.",
|
| 105 |
+
detail: stage,
|
| 106 |
+
discussions_enabled: await discussions_enabled(space_name)
|
| 107 |
+
});
|
| 108 |
+
break;
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
export const check_and_wake_space = async (
|
| 113 |
+
space_id: string,
|
| 114 |
+
status_callback: SpaceStatusCallback
|
| 115 |
+
): Promise<void> => {
|
| 116 |
+
let retries = 0;
|
| 117 |
+
const max_retries = 12;
|
| 118 |
+
const check_interval = 5000;
|
| 119 |
+
|
| 120 |
+
return new Promise((resolve) => {
|
| 121 |
+
check_space_status(
|
| 122 |
+
space_id,
|
| 123 |
+
RE_SPACE_NAME.test(space_id) ? "space_name" : "subdomain",
|
| 124 |
+
(status) => {
|
| 125 |
+
status_callback(status);
|
| 126 |
+
|
| 127 |
+
if (status.status === "running") {
|
| 128 |
+
resolve();
|
| 129 |
+
} else if (
|
| 130 |
+
status.status === "error" ||
|
| 131 |
+
status.status === "paused" ||
|
| 132 |
+
status.status === "space_error"
|
| 133 |
+
) {
|
| 134 |
+
resolve();
|
| 135 |
+
} else if (
|
| 136 |
+
status.status === "sleeping" ||
|
| 137 |
+
status.status === "building"
|
| 138 |
+
) {
|
| 139 |
+
if (retries < max_retries) {
|
| 140 |
+
retries++;
|
| 141 |
+
setTimeout(() => {
|
| 142 |
+
check_and_wake_space(space_id, status_callback).then(resolve);
|
| 143 |
+
}, check_interval);
|
| 144 |
+
} else {
|
| 145 |
+
resolve();
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
);
|
| 150 |
+
});
|
| 151 |
+
};
|
| 152 |
+
|
| 153 |
+
const RE_DISABLED_DISCUSSION =
|
| 154 |
+
/^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;
|
| 155 |
+
export async function discussions_enabled(space_id: string): Promise<boolean> {
|
| 156 |
+
try {
|
| 157 |
+
const r = await fetch(
|
| 158 |
+
`https://huggingface.co/api/spaces/${space_id}/discussions`,
|
| 159 |
+
{
|
| 160 |
+
method: "HEAD"
|
| 161 |
+
}
|
| 162 |
+
);
|
| 163 |
+
|
| 164 |
+
const error = r.headers.get("x-error-message");
|
| 165 |
+
|
| 166 |
+
if (!r.ok || (error && RE_DISABLED_DISCUSSION.test(error))) return false;
|
| 167 |
+
return true;
|
| 168 |
+
} catch (e) {
|
| 169 |
+
return false;
|
| 170 |
+
}
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
export async function get_space_hardware(
|
| 174 |
+
space_id: string,
|
| 175 |
+
token?: `hf_${string}` | undefined
|
| 176 |
+
): Promise<(typeof hardware_types)[number]> {
|
| 177 |
+
const headers: { Authorization?: string } = {};
|
| 178 |
+
if (token) {
|
| 179 |
+
headers.Authorization = `Bearer ${token}`;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
try {
|
| 183 |
+
const res = await fetch(
|
| 184 |
+
`https://huggingface.co/api/spaces/${space_id}/${RUNTIME_URL}`,
|
| 185 |
+
{ headers }
|
| 186 |
+
);
|
| 187 |
+
|
| 188 |
+
if (res.status !== 200)
|
| 189 |
+
throw new Error("Space hardware could not be obtained.");
|
| 190 |
+
|
| 191 |
+
const { hardware } = await res.json();
|
| 192 |
+
|
| 193 |
+
return hardware.current;
|
| 194 |
+
} catch (e: any) {
|
| 195 |
+
throw new Error(e.message);
|
| 196 |
+
}
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
export async function set_space_timeout(
|
| 200 |
+
space_id: string,
|
| 201 |
+
timeout: number,
|
| 202 |
+
token?: `hf_${string}`
|
| 203 |
+
): Promise<any> {
|
| 204 |
+
const headers: { Authorization?: string } = {};
|
| 205 |
+
if (token) {
|
| 206 |
+
headers.Authorization = `Bearer ${token}`;
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
const body: {
|
| 210 |
+
seconds?: number;
|
| 211 |
+
} = {
|
| 212 |
+
seconds: timeout
|
| 213 |
+
};
|
| 214 |
+
|
| 215 |
+
try {
|
| 216 |
+
const res = await fetch(
|
| 217 |
+
`https://huggingface.co/api/spaces/${space_id}/${SLEEPTIME_URL}`,
|
| 218 |
+
{
|
| 219 |
+
method: "POST",
|
| 220 |
+
headers: { "Content-Type": "application/json", ...headers },
|
| 221 |
+
body: JSON.stringify(body)
|
| 222 |
+
}
|
| 223 |
+
);
|
| 224 |
+
|
| 225 |
+
if (res.status !== 200) {
|
| 226 |
+
throw new Error(
|
| 227 |
+
"Could not set sleep timeout on duplicated Space. Please visit *ADD HF LINK TO SETTINGS* to set a timeout manually to reduce billing charges."
|
| 228 |
+
);
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
const response = await res.json();
|
| 232 |
+
return response;
|
| 233 |
+
} catch (e: any) {
|
| 234 |
+
throw new Error(e.message);
|
| 235 |
+
}
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
export const hardware_types = [
|
| 239 |
+
"cpu-basic",
|
| 240 |
+
"cpu-upgrade",
|
| 241 |
+
"cpu-xl",
|
| 242 |
+
"t4-small",
|
| 243 |
+
"t4-medium",
|
| 244 |
+
"a10g-small",
|
| 245 |
+
"a10g-large",
|
| 246 |
+
"a10g-largex2",
|
| 247 |
+
"a10g-largex4",
|
| 248 |
+
"a100-large",
|
| 249 |
+
"zero-a10g",
|
| 250 |
+
"h100",
|
| 251 |
+
"h100x8"
|
| 252 |
+
] as const;
|
6.29.1/client/src/helpers/zerogpu.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const ZEROGPU_HEADERS_MESSAGE = "supports-zerogpu-headers";
|
| 2 |
+
|
| 3 |
+
let zerogpu_handshake_initialized = false;
|
| 4 |
+
|
| 5 |
+
function supports_browser_handshake(): boolean {
|
| 6 |
+
return (
|
| 7 |
+
typeof window !== "undefined" &&
|
| 8 |
+
typeof document !== "undefined" &&
|
| 9 |
+
typeof window.addEventListener === "function"
|
| 10 |
+
);
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
export function get_zerogpu_origin(hostname: string): string | null {
|
| 14 |
+
if (hostname.includes(".dev.")) {
|
| 15 |
+
return `https://moon-${hostname.split(".")[1]}.dev.spaces.huggingface.tech`;
|
| 16 |
+
}
|
| 17 |
+
if (hostname.endsWith(".hf.space")) {
|
| 18 |
+
return "https://huggingface.co";
|
| 19 |
+
}
|
| 20 |
+
return null;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
export function initialize_zerogpu_handshake(): void {
|
| 24 |
+
if (!supports_browser_handshake() || zerogpu_handshake_initialized) {
|
| 25 |
+
return;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
window.addEventListener("message", (event) => {
|
| 29 |
+
if (event.data === ZEROGPU_HEADERS_MESSAGE) {
|
| 30 |
+
window.supports_zerogpu_headers = true;
|
| 31 |
+
}
|
| 32 |
+
});
|
| 33 |
+
|
| 34 |
+
zerogpu_handshake_initialized = true;
|
| 35 |
+
|
| 36 |
+
const origin = get_zerogpu_origin(window.location.hostname);
|
| 37 |
+
if (origin && window.parent !== window) {
|
| 38 |
+
window.parent.postMessage(ZEROGPU_HEADERS_MESSAGE, origin);
|
| 39 |
+
}
|
| 40 |
+
}
|
6.29.1/client/src/index.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export { Client } from "./client";
|
| 2 |
+
|
| 3 |
+
export { predict } from "./utils/predict";
|
| 4 |
+
export { submit } from "./utils/submit";
|
| 5 |
+
export { upload_files } from "./utils/upload_files";
|
| 6 |
+
export { FileData, upload, prepare_files } from "./upload";
|
| 7 |
+
export { handle_file } from "./helpers/data";
|
| 8 |
+
export {
|
| 9 |
+
apply_run_history_replay,
|
| 10 |
+
clear_run_history,
|
| 11 |
+
consume_run_history_replay,
|
| 12 |
+
delete_run_history,
|
| 13 |
+
on_run_history_change,
|
| 14 |
+
read_run_history,
|
| 15 |
+
read_run_history_storage,
|
| 16 |
+
run_history_url,
|
| 17 |
+
set_run_history_storage,
|
| 18 |
+
stage_run_history_replay,
|
| 19 |
+
type ReplayTarget,
|
| 20 |
+
type RunHistoryStorage,
|
| 21 |
+
type RunHistoryScope,
|
| 22 |
+
type StoredRunComponent,
|
| 23 |
+
type StoredRun
|
| 24 |
+
} from "./utils/run_history";
|
| 25 |
+
export {
|
| 26 |
+
asset_url,
|
| 27 |
+
connect_bucket,
|
| 28 |
+
is_valid_bucket_id,
|
| 29 |
+
list_bucket_records,
|
| 30 |
+
list_user_buckets,
|
| 31 |
+
type HistoryRecord,
|
| 32 |
+
type HistoryResult
|
| 33 |
+
} from "./utils/bucket_sync";
|
| 34 |
+
|
| 35 |
+
export type {
|
| 36 |
+
SpaceStatus,
|
| 37 |
+
StatusMessage,
|
| 38 |
+
Status,
|
| 39 |
+
client_return,
|
| 40 |
+
UploadResponse,
|
| 41 |
+
RenderMessage,
|
| 42 |
+
LogMessage,
|
| 43 |
+
Payload,
|
| 44 |
+
Config,
|
| 45 |
+
ValidationError
|
| 46 |
+
} from "./types";
|
| 47 |
+
|
| 48 |
+
export { MISSING_CREDENTIALS_MSG } from "./constants";
|
| 49 |
+
|
| 50 |
+
// todo: remove in @gradio/client v1.0
|
| 51 |
+
export { client } from "./client";
|
| 52 |
+
export { duplicate_space as duplicate } from "./client";
|
6.29.1/client/src/test/handlers.ts
ADDED
|
@@ -0,0 +1,687 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { HttpResponse, http, RequestHandler } from "msw";
|
| 2 |
+
import {
|
| 3 |
+
HOST_URL,
|
| 4 |
+
API_INFO_URL,
|
| 5 |
+
CONFIG_URL,
|
| 6 |
+
RUNTIME_URL,
|
| 7 |
+
SLEEPTIME_URL,
|
| 8 |
+
UPLOAD_URL,
|
| 9 |
+
BROKEN_CONNECTION_MSG,
|
| 10 |
+
LOGIN_URL
|
| 11 |
+
} from "../constants";
|
| 12 |
+
import {
|
| 13 |
+
response_api_info,
|
| 14 |
+
config_response,
|
| 15 |
+
whoami_response,
|
| 16 |
+
duplicate_response,
|
| 17 |
+
hardware_sleeptime_response,
|
| 18 |
+
discussions_response,
|
| 19 |
+
runtime_response
|
| 20 |
+
} from "./test_data";
|
| 21 |
+
|
| 22 |
+
const root_url = "https://huggingface.co";
|
| 23 |
+
|
| 24 |
+
export const direct_space_url = "https://hmb-hello-world.hf.space";
|
| 25 |
+
const private_space_url = "https://hmb-secret-world.hf.space";
|
| 26 |
+
const private_auth_space_url = "https://hmb-private-auth-space.hf.space";
|
| 27 |
+
|
| 28 |
+
const server_error_space_url = "https://hmb-server-error.hf.space";
|
| 29 |
+
const upload_server_test_space_url = "https://hmb-server-test.hf.space";
|
| 30 |
+
const auth_app_space_url = "https://hmb-auth-space.hf.space";
|
| 31 |
+
const unauth_app_space_url = "https://hmb-unauth-space.hf.space";
|
| 32 |
+
const invalid_auth_space_url = "https://hmb-invalid-auth-space.hf.space";
|
| 33 |
+
|
| 34 |
+
const server_error_reference = "hmb/server_error";
|
| 35 |
+
const app_reference = "hmb/hello_world";
|
| 36 |
+
const broken_app_reference = "hmb/bye_world";
|
| 37 |
+
const duplicate_app_reference = "gradio/hello_world";
|
| 38 |
+
const private_app_reference = "hmb/secret_world";
|
| 39 |
+
const server_test_app_reference = "hmb/server_test";
|
| 40 |
+
const auth_app_reference = "hmb/auth_space";
|
| 41 |
+
const unauth_app_reference = "hmb/unauth_space";
|
| 42 |
+
const invalid_auth_app_reference = "hmb/invalid_auth_space";
|
| 43 |
+
const private_auth_app_reference = "hmb/private_auth_space";
|
| 44 |
+
|
| 45 |
+
export const handlers: RequestHandler[] = [
|
| 46 |
+
// /host requests
|
| 47 |
+
http.get(`${root_url}/api/spaces/${app_reference}/${HOST_URL}`, () => {
|
| 48 |
+
return new HttpResponse(
|
| 49 |
+
JSON.stringify({
|
| 50 |
+
subdomain: "hmb-hello-world",
|
| 51 |
+
host: "https://hmb-hello-world.hf.space"
|
| 52 |
+
}),
|
| 53 |
+
{
|
| 54 |
+
status: 200,
|
| 55 |
+
headers: {
|
| 56 |
+
"Content-Type": "application/json"
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
);
|
| 60 |
+
}),
|
| 61 |
+
http.get(`${root_url}/api/spaces/${broken_app_reference}/${HOST_URL}`, () => {
|
| 62 |
+
return new HttpResponse(null, {
|
| 63 |
+
status: 404,
|
| 64 |
+
headers: {
|
| 65 |
+
"Content-Type": "application/json",
|
| 66 |
+
hf_token: "hf_123"
|
| 67 |
+
}
|
| 68 |
+
});
|
| 69 |
+
}),
|
| 70 |
+
http.get(
|
| 71 |
+
`${root_url}/api/spaces/${private_auth_app_reference}/${HOST_URL}`,
|
| 72 |
+
() => {
|
| 73 |
+
return new HttpResponse(
|
| 74 |
+
JSON.stringify({
|
| 75 |
+
subdomain: "hmb-private-auth-space",
|
| 76 |
+
host: "https://hmb-private-auth-space.hf.space"
|
| 77 |
+
}),
|
| 78 |
+
{
|
| 79 |
+
status: 200,
|
| 80 |
+
headers: {
|
| 81 |
+
"Content-Type": "application/json"
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
);
|
| 85 |
+
}
|
| 86 |
+
),
|
| 87 |
+
http.get(
|
| 88 |
+
`${root_url}/api/spaces/${private_app_reference}/${HOST_URL}`,
|
| 89 |
+
({ request }) => {
|
| 90 |
+
const token = request.headers.get("authorization")?.substring(7);
|
| 91 |
+
|
| 92 |
+
if (!token || token !== "hf_123") {
|
| 93 |
+
return new HttpResponse(null, {
|
| 94 |
+
status: 401,
|
| 95 |
+
headers: {
|
| 96 |
+
"Content-Type": "application/json"
|
| 97 |
+
}
|
| 98 |
+
});
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
return new HttpResponse(
|
| 102 |
+
JSON.stringify({
|
| 103 |
+
subdomain: private_app_reference,
|
| 104 |
+
host: private_space_url
|
| 105 |
+
}),
|
| 106 |
+
{
|
| 107 |
+
status: 200,
|
| 108 |
+
headers: {
|
| 109 |
+
"Content-Type": "application/json"
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
);
|
| 113 |
+
}
|
| 114 |
+
),
|
| 115 |
+
http.get(
|
| 116 |
+
`${root_url}/api/spaces/${server_error_reference}/${HOST_URL}`,
|
| 117 |
+
() => {
|
| 118 |
+
return new HttpResponse(
|
| 119 |
+
JSON.stringify({
|
| 120 |
+
subdomain: "hmb-server-test",
|
| 121 |
+
host: "https://hmb-server-test.hf.space"
|
| 122 |
+
}),
|
| 123 |
+
{
|
| 124 |
+
status: 200,
|
| 125 |
+
headers: {
|
| 126 |
+
"Content-Type": "application/json"
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
);
|
| 130 |
+
}
|
| 131 |
+
),
|
| 132 |
+
http.get(
|
| 133 |
+
`${root_url}/api/spaces/${server_test_app_reference}/${HOST_URL}`,
|
| 134 |
+
() => {
|
| 135 |
+
return new HttpResponse(
|
| 136 |
+
JSON.stringify({
|
| 137 |
+
subdomain: "hmb-server-test",
|
| 138 |
+
host: "https://hmb-server-test.hf.space"
|
| 139 |
+
}),
|
| 140 |
+
{
|
| 141 |
+
status: 200,
|
| 142 |
+
headers: {
|
| 143 |
+
"Content-Type": "application/json"
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
);
|
| 147 |
+
}
|
| 148 |
+
),
|
| 149 |
+
http.get(`${root_url}/api/spaces/${auth_app_reference}/${HOST_URL}`, () => {
|
| 150 |
+
return new HttpResponse(
|
| 151 |
+
JSON.stringify({
|
| 152 |
+
subdomain: "hmb-auth-space",
|
| 153 |
+
host: "https://hmb-auth-space.hf.space"
|
| 154 |
+
}),
|
| 155 |
+
{
|
| 156 |
+
status: 200,
|
| 157 |
+
headers: {
|
| 158 |
+
"Content-Type": "application/json"
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
);
|
| 162 |
+
}),
|
| 163 |
+
http.get(
|
| 164 |
+
`${root_url}/api/spaces/${invalid_auth_app_reference}/${HOST_URL}`,
|
| 165 |
+
() => {
|
| 166 |
+
return new HttpResponse(
|
| 167 |
+
JSON.stringify({
|
| 168 |
+
subdomain: "hmb-invalid-auth-space",
|
| 169 |
+
host: "https://hmb-invalid-auth-space.hf.space"
|
| 170 |
+
}),
|
| 171 |
+
{
|
| 172 |
+
status: 200,
|
| 173 |
+
headers: {
|
| 174 |
+
"Content-Type": "application/json"
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
);
|
| 178 |
+
}
|
| 179 |
+
),
|
| 180 |
+
http.get(
|
| 181 |
+
`${root_url}/api/spaces/${duplicate_app_reference}/${HOST_URL}`,
|
| 182 |
+
() => {
|
| 183 |
+
return new HttpResponse(
|
| 184 |
+
JSON.stringify({
|
| 185 |
+
subdomain: "gradio-hello-world",
|
| 186 |
+
host: "https://gradio-hello-world.hf.space"
|
| 187 |
+
}),
|
| 188 |
+
{
|
| 189 |
+
status: 200,
|
| 190 |
+
headers: {
|
| 191 |
+
"Content-Type": "application/json"
|
| 192 |
+
}
|
| 193 |
+
}
|
| 194 |
+
);
|
| 195 |
+
}
|
| 196 |
+
),
|
| 197 |
+
http.get(`${root_url}/api/spaces/${unauth_app_reference}/${HOST_URL}`, () => {
|
| 198 |
+
return new HttpResponse(
|
| 199 |
+
JSON.stringify({
|
| 200 |
+
subdomain: "hmb-unath-space",
|
| 201 |
+
host: "https://hmb-unauth-space.hf.space"
|
| 202 |
+
}),
|
| 203 |
+
{
|
| 204 |
+
status: 200,
|
| 205 |
+
headers: {
|
| 206 |
+
"Content-Type": "application/json"
|
| 207 |
+
}
|
| 208 |
+
}
|
| 209 |
+
);
|
| 210 |
+
}),
|
| 211 |
+
// /info requests
|
| 212 |
+
http.get(`${direct_space_url}/${API_INFO_URL}`, () => {
|
| 213 |
+
return new HttpResponse(JSON.stringify(response_api_info), {
|
| 214 |
+
status: 200,
|
| 215 |
+
headers: {
|
| 216 |
+
"Content-Type": "application/json"
|
| 217 |
+
}
|
| 218 |
+
});
|
| 219 |
+
}),
|
| 220 |
+
http.get(`${upload_server_test_space_url}/${API_INFO_URL}`, () => {
|
| 221 |
+
return new HttpResponse(JSON.stringify(response_api_info), {
|
| 222 |
+
status: 200,
|
| 223 |
+
headers: {
|
| 224 |
+
"Content-Type": "application/json"
|
| 225 |
+
}
|
| 226 |
+
});
|
| 227 |
+
}),
|
| 228 |
+
http.get(`${private_space_url}/${API_INFO_URL}`, () => {
|
| 229 |
+
return new HttpResponse(JSON.stringify(response_api_info), {
|
| 230 |
+
status: 200,
|
| 231 |
+
headers: {
|
| 232 |
+
"Content-Type": "application/json"
|
| 233 |
+
}
|
| 234 |
+
});
|
| 235 |
+
}),
|
| 236 |
+
http.get(`${server_error_space_url}/${API_INFO_URL}`, () => {
|
| 237 |
+
return new HttpResponse(JSON.stringify(response_api_info), {
|
| 238 |
+
status: 200,
|
| 239 |
+
headers: {
|
| 240 |
+
"Content-Type": "application/json"
|
| 241 |
+
}
|
| 242 |
+
});
|
| 243 |
+
}),
|
| 244 |
+
http.get(`${auth_app_space_url}/${API_INFO_URL}`, async () => {
|
| 245 |
+
return new HttpResponse(JSON.stringify(response_api_info), {
|
| 246 |
+
status: 200,
|
| 247 |
+
headers: {
|
| 248 |
+
"Content-Type": "application/json"
|
| 249 |
+
}
|
| 250 |
+
});
|
| 251 |
+
}),
|
| 252 |
+
http.get(`${private_auth_space_url}/${API_INFO_URL}`, async () => {
|
| 253 |
+
return new HttpResponse(JSON.stringify(response_api_info), {
|
| 254 |
+
status: 200,
|
| 255 |
+
headers: {
|
| 256 |
+
"Content-Type": "application/json"
|
| 257 |
+
}
|
| 258 |
+
});
|
| 259 |
+
}),
|
| 260 |
+
// /config requests
|
| 261 |
+
http.get(`${direct_space_url}/${CONFIG_URL}`, () => {
|
| 262 |
+
return new HttpResponse(JSON.stringify(config_response), {
|
| 263 |
+
status: 200,
|
| 264 |
+
headers: {
|
| 265 |
+
"Content-Type": "application/json"
|
| 266 |
+
}
|
| 267 |
+
});
|
| 268 |
+
}),
|
| 269 |
+
http.get(`${private_space_url}/${CONFIG_URL}`, () => {
|
| 270 |
+
return new HttpResponse(
|
| 271 |
+
JSON.stringify({
|
| 272 |
+
...config_response,
|
| 273 |
+
root: "https://hmb-secret-world.hf.space"
|
| 274 |
+
}),
|
| 275 |
+
{
|
| 276 |
+
status: 200,
|
| 277 |
+
headers: {
|
| 278 |
+
"Content-Type": "application/json"
|
| 279 |
+
}
|
| 280 |
+
}
|
| 281 |
+
);
|
| 282 |
+
}),
|
| 283 |
+
http.get(`${upload_server_test_space_url}/${CONFIG_URL}`, () => {
|
| 284 |
+
return new HttpResponse(
|
| 285 |
+
JSON.stringify({
|
| 286 |
+
...config_response,
|
| 287 |
+
root: "https://hmb-server-test.hf.space"
|
| 288 |
+
}),
|
| 289 |
+
{
|
| 290 |
+
status: 200,
|
| 291 |
+
headers: {
|
| 292 |
+
"Content-Type": "application/json"
|
| 293 |
+
}
|
| 294 |
+
}
|
| 295 |
+
);
|
| 296 |
+
}),
|
| 297 |
+
http.get(`${private_auth_space_url}/${CONFIG_URL}`, () => {
|
| 298 |
+
return new HttpResponse(
|
| 299 |
+
JSON.stringify({
|
| 300 |
+
...config_response,
|
| 301 |
+
root: "https://hmb-private-auth-space.hf.space"
|
| 302 |
+
}),
|
| 303 |
+
{
|
| 304 |
+
status: 200,
|
| 305 |
+
headers: {
|
| 306 |
+
"Content-Type": "application/json"
|
| 307 |
+
}
|
| 308 |
+
}
|
| 309 |
+
);
|
| 310 |
+
}),
|
| 311 |
+
http.get(`${direct_space_url}/${CONFIG_URL}`, () => {
|
| 312 |
+
return new HttpResponse(JSON.stringify(config_response), {
|
| 313 |
+
status: 500,
|
| 314 |
+
headers: {
|
| 315 |
+
"Content-Type": "application/json"
|
| 316 |
+
}
|
| 317 |
+
});
|
| 318 |
+
}),
|
| 319 |
+
http.get(`${server_error_space_url}/${CONFIG_URL}`, () => {
|
| 320 |
+
return new HttpResponse(JSON.stringify(config_response), {
|
| 321 |
+
status: 200,
|
| 322 |
+
headers: {
|
| 323 |
+
"Content-Type": "application/json"
|
| 324 |
+
}
|
| 325 |
+
});
|
| 326 |
+
}),
|
| 327 |
+
http.get(`${invalid_auth_space_url}/${CONFIG_URL}`, () => {
|
| 328 |
+
return new HttpResponse(JSON.stringify({ detail: "Unauthorized" }), {
|
| 329 |
+
status: 401,
|
| 330 |
+
headers: {
|
| 331 |
+
"Content-Type": "application/json"
|
| 332 |
+
}
|
| 333 |
+
});
|
| 334 |
+
}),
|
| 335 |
+
http.get(`${auth_app_space_url}/${CONFIG_URL}`, ({ request }) => {
|
| 336 |
+
return new HttpResponse(
|
| 337 |
+
JSON.stringify({
|
| 338 |
+
...config_response,
|
| 339 |
+
root: "https://hmb-auth-space.hf.space",
|
| 340 |
+
space_id: "hmb/auth_space"
|
| 341 |
+
}),
|
| 342 |
+
{
|
| 343 |
+
status: 200,
|
| 344 |
+
headers: {
|
| 345 |
+
"Content-Type": "application/json"
|
| 346 |
+
}
|
| 347 |
+
}
|
| 348 |
+
);
|
| 349 |
+
}),
|
| 350 |
+
http.get(`${unauth_app_space_url}/${CONFIG_URL}`, () => {
|
| 351 |
+
return new HttpResponse(
|
| 352 |
+
JSON.stringify({
|
| 353 |
+
detail: "Unauthorized"
|
| 354 |
+
}),
|
| 355 |
+
{
|
| 356 |
+
status: 401,
|
| 357 |
+
headers: {
|
| 358 |
+
"Content-Type": "application/json"
|
| 359 |
+
}
|
| 360 |
+
}
|
| 361 |
+
);
|
| 362 |
+
}),
|
| 363 |
+
// /whoami requests
|
| 364 |
+
http.get(`${root_url}/api/whoami-v2`, () => {
|
| 365 |
+
return new HttpResponse(JSON.stringify(whoami_response), {
|
| 366 |
+
status: 200,
|
| 367 |
+
headers: {
|
| 368 |
+
"Content-Type": "application/json",
|
| 369 |
+
"hf-token": "hf_123"
|
| 370 |
+
}
|
| 371 |
+
});
|
| 372 |
+
}),
|
| 373 |
+
// /duplicate requests
|
| 374 |
+
http.post(
|
| 375 |
+
`${root_url}/api/spaces/${duplicate_app_reference}/duplicate`,
|
| 376 |
+
({ request }) => {
|
| 377 |
+
if (request.headers.get("authorization")?.substring(7) !== "hf_123") {
|
| 378 |
+
throw new HttpResponse(null, {
|
| 379 |
+
status: 401,
|
| 380 |
+
headers: {
|
| 381 |
+
"Content-Type": "application/json"
|
| 382 |
+
}
|
| 383 |
+
});
|
| 384 |
+
}
|
| 385 |
+
return new HttpResponse(JSON.stringify(duplicate_response), {
|
| 386 |
+
status: 200,
|
| 387 |
+
headers: {
|
| 388 |
+
"Content-Type": "application/json"
|
| 389 |
+
}
|
| 390 |
+
});
|
| 391 |
+
}
|
| 392 |
+
),
|
| 393 |
+
// /sleeptime requests
|
| 394 |
+
http.post(`${root_url}/api/spaces/${app_reference}/${SLEEPTIME_URL}`, () => {
|
| 395 |
+
return new HttpResponse(JSON.stringify(hardware_sleeptime_response), {
|
| 396 |
+
status: 200,
|
| 397 |
+
headers: {
|
| 398 |
+
"Content-Type": "application/json"
|
| 399 |
+
}
|
| 400 |
+
});
|
| 401 |
+
}),
|
| 402 |
+
http.post(
|
| 403 |
+
`${root_url}/api/spaces/${server_test_app_reference}/${SLEEPTIME_URL}`,
|
| 404 |
+
() => {
|
| 405 |
+
throw new HttpResponse(null, {
|
| 406 |
+
status: 500,
|
| 407 |
+
headers: {
|
| 408 |
+
"Content-Type": "application/json"
|
| 409 |
+
}
|
| 410 |
+
});
|
| 411 |
+
}
|
| 412 |
+
),
|
| 413 |
+
// /runtime requests
|
| 414 |
+
http.get(
|
| 415 |
+
`${root_url}/api/spaces/${broken_app_reference}/${RUNTIME_URL}`,
|
| 416 |
+
() => {
|
| 417 |
+
return new HttpResponse(null, {
|
| 418 |
+
status: 404,
|
| 419 |
+
headers: {
|
| 420 |
+
"Content-Type": "application/json"
|
| 421 |
+
}
|
| 422 |
+
});
|
| 423 |
+
}
|
| 424 |
+
),
|
| 425 |
+
http.get(`${root_url}/api/spaces/${app_reference}/${RUNTIME_URL}`, () => {
|
| 426 |
+
return new HttpResponse(JSON.stringify(hardware_sleeptime_response), {
|
| 427 |
+
status: 200,
|
| 428 |
+
headers: {
|
| 429 |
+
"Content-Type": "application/json"
|
| 430 |
+
}
|
| 431 |
+
});
|
| 432 |
+
}),
|
| 433 |
+
// queue requests
|
| 434 |
+
http.get(`${direct_space_url}/queue/data`, () => {
|
| 435 |
+
return new HttpResponse(JSON.stringify({ event_id: "123" }), {
|
| 436 |
+
status: 200,
|
| 437 |
+
headers: {
|
| 438 |
+
"Content-Type": "application/json"
|
| 439 |
+
}
|
| 440 |
+
});
|
| 441 |
+
}),
|
| 442 |
+
http.post(`${direct_space_url}/queue/join`, () => {
|
| 443 |
+
return new HttpResponse(JSON.stringify({ event_id: "123" }), {
|
| 444 |
+
status: 200,
|
| 445 |
+
headers: {
|
| 446 |
+
"Content-Type": "application/json"
|
| 447 |
+
}
|
| 448 |
+
});
|
| 449 |
+
}),
|
| 450 |
+
// upload requests
|
| 451 |
+
http.post(`${direct_space_url}/${UPLOAD_URL}`, () => {
|
| 452 |
+
return new HttpResponse(JSON.stringify(["lion.jpg"]), {
|
| 453 |
+
status: 200,
|
| 454 |
+
headers: {
|
| 455 |
+
"Content-Type": "application/json"
|
| 456 |
+
}
|
| 457 |
+
});
|
| 458 |
+
}),
|
| 459 |
+
http.post(`${upload_server_test_space_url}/${UPLOAD_URL}`, () => {
|
| 460 |
+
throw new HttpResponse(JSON.parse("Internal Server Error"), {
|
| 461 |
+
status: 200,
|
| 462 |
+
headers: {
|
| 463 |
+
"Content-Type": "application/json"
|
| 464 |
+
}
|
| 465 |
+
});
|
| 466 |
+
}),
|
| 467 |
+
// discussions requests
|
| 468 |
+
http.head(`${root_url}/api/spaces/${app_reference}/discussions`, () => {
|
| 469 |
+
return new HttpResponse(JSON.stringify(discussions_response), {
|
| 470 |
+
status: 200,
|
| 471 |
+
headers: {
|
| 472 |
+
"Content-Type": "application/json"
|
| 473 |
+
}
|
| 474 |
+
});
|
| 475 |
+
}),
|
| 476 |
+
http.head(
|
| 477 |
+
`${root_url}/api/spaces/${broken_app_reference}/discussions`,
|
| 478 |
+
() => {
|
| 479 |
+
throw new HttpResponse(
|
| 480 |
+
JSON.parse("Discussions are disabled for this repo"),
|
| 481 |
+
{
|
| 482 |
+
status: 403,
|
| 483 |
+
headers: {
|
| 484 |
+
"Content-Type": "application/json"
|
| 485 |
+
}
|
| 486 |
+
}
|
| 487 |
+
);
|
| 488 |
+
}
|
| 489 |
+
),
|
| 490 |
+
// space requests
|
| 491 |
+
http.get(`${root_url}/api/spaces/${app_reference}`, () => {
|
| 492 |
+
return new HttpResponse(
|
| 493 |
+
JSON.stringify({ id: app_reference, runtime: runtime_response }),
|
| 494 |
+
{
|
| 495 |
+
status: 200,
|
| 496 |
+
headers: {
|
| 497 |
+
"Content-Type": "application/json"
|
| 498 |
+
}
|
| 499 |
+
}
|
| 500 |
+
);
|
| 501 |
+
}),
|
| 502 |
+
http.get(`${root_url}/api/spaces/hmb/paused_space`, () => {
|
| 503 |
+
return new HttpResponse(
|
| 504 |
+
JSON.stringify({
|
| 505 |
+
id: app_reference,
|
| 506 |
+
runtime: { ...runtime_response, stage: "PAUSED" }
|
| 507 |
+
}),
|
| 508 |
+
{
|
| 509 |
+
status: 200,
|
| 510 |
+
headers: {
|
| 511 |
+
"Content-Type": "application/json"
|
| 512 |
+
}
|
| 513 |
+
}
|
| 514 |
+
);
|
| 515 |
+
}),
|
| 516 |
+
http.get(`${root_url}/api/spaces/hmb/building_space`, () => {
|
| 517 |
+
return new HttpResponse(
|
| 518 |
+
JSON.stringify({
|
| 519 |
+
id: app_reference,
|
| 520 |
+
runtime: { ...runtime_response, stage: "BUILDING" }
|
| 521 |
+
}),
|
| 522 |
+
{
|
| 523 |
+
status: 200,
|
| 524 |
+
headers: {
|
| 525 |
+
"Content-Type": "application/json"
|
| 526 |
+
}
|
| 527 |
+
}
|
| 528 |
+
);
|
| 529 |
+
}),
|
| 530 |
+
http.get(`${root_url}/api/spaces/hmb/stopped_space`, () => {
|
| 531 |
+
return new HttpResponse(
|
| 532 |
+
JSON.stringify({
|
| 533 |
+
id: app_reference,
|
| 534 |
+
runtime: { ...runtime_response, stage: "STOPPED" }
|
| 535 |
+
}),
|
| 536 |
+
{
|
| 537 |
+
status: 200,
|
| 538 |
+
headers: {
|
| 539 |
+
"Content-Type": "application/json"
|
| 540 |
+
}
|
| 541 |
+
}
|
| 542 |
+
);
|
| 543 |
+
}),
|
| 544 |
+
http.get(`${root_url}/api/spaces/hmb/failed_space`, () => {
|
| 545 |
+
throw new HttpResponse(null, {
|
| 546 |
+
status: 500,
|
| 547 |
+
headers: {
|
| 548 |
+
"Content-Type": "application/json"
|
| 549 |
+
}
|
| 550 |
+
});
|
| 551 |
+
}),
|
| 552 |
+
http.get(`${root_url}/api/spaces/${unauth_app_reference}`, () => {
|
| 553 |
+
return new HttpResponse(
|
| 554 |
+
JSON.stringify({
|
| 555 |
+
id: unauth_app_reference,
|
| 556 |
+
runtime: { ...runtime_response }
|
| 557 |
+
}),
|
| 558 |
+
{
|
| 559 |
+
status: 200,
|
| 560 |
+
headers: {
|
| 561 |
+
"Content-Type": "application/json"
|
| 562 |
+
}
|
| 563 |
+
}
|
| 564 |
+
);
|
| 565 |
+
}),
|
| 566 |
+
// jwt requests
|
| 567 |
+
http.get(`${root_url}/api/spaces/${app_reference}/jwt`, () => {
|
| 568 |
+
return new HttpResponse(
|
| 569 |
+
JSON.stringify({
|
| 570 |
+
token: "jwt_123"
|
| 571 |
+
}),
|
| 572 |
+
{
|
| 573 |
+
status: 200,
|
| 574 |
+
headers: {
|
| 575 |
+
"Content-Type": "application/json"
|
| 576 |
+
}
|
| 577 |
+
}
|
| 578 |
+
);
|
| 579 |
+
}),
|
| 580 |
+
http.get(`${root_url}/api/spaces/${broken_app_reference}/jwt`, () => {
|
| 581 |
+
return new HttpResponse(null, {
|
| 582 |
+
status: 500,
|
| 583 |
+
headers: {
|
| 584 |
+
"Content-Type": "application/json"
|
| 585 |
+
}
|
| 586 |
+
});
|
| 587 |
+
}),
|
| 588 |
+
// post_data requests
|
| 589 |
+
http.post(`${direct_space_url}`, () => {
|
| 590 |
+
return new HttpResponse(JSON.stringify({}), {
|
| 591 |
+
status: 200,
|
| 592 |
+
headers: {
|
| 593 |
+
"Content-Type": "application/json"
|
| 594 |
+
}
|
| 595 |
+
});
|
| 596 |
+
}),
|
| 597 |
+
http.post(`${private_space_url}`, () => {
|
| 598 |
+
return new HttpResponse(JSON.stringify(BROKEN_CONNECTION_MSG), {
|
| 599 |
+
status: 500,
|
| 600 |
+
headers: {
|
| 601 |
+
"Content-Type": "application/json"
|
| 602 |
+
}
|
| 603 |
+
});
|
| 604 |
+
}),
|
| 605 |
+
// heartbeat requests
|
| 606 |
+
http.get(`*/heartbeat/*`, () => {
|
| 607 |
+
return new HttpResponse(null, {
|
| 608 |
+
status: 200,
|
| 609 |
+
headers: {
|
| 610 |
+
"Content-Type": "application/json"
|
| 611 |
+
}
|
| 612 |
+
});
|
| 613 |
+
}),
|
| 614 |
+
// login requests
|
| 615 |
+
http.post(`${auth_app_space_url}/${LOGIN_URL}`, async ({ request }) => {
|
| 616 |
+
let username;
|
| 617 |
+
let password;
|
| 618 |
+
|
| 619 |
+
await request.formData().then((data) => {
|
| 620 |
+
username = data.get("username");
|
| 621 |
+
password = data.get("password");
|
| 622 |
+
});
|
| 623 |
+
|
| 624 |
+
if (username === "admin" && password === "pass1234") {
|
| 625 |
+
return new HttpResponse(
|
| 626 |
+
JSON.stringify({
|
| 627 |
+
success: true
|
| 628 |
+
}),
|
| 629 |
+
{
|
| 630 |
+
status: 200,
|
| 631 |
+
headers: {
|
| 632 |
+
"Content-Type": "application/json",
|
| 633 |
+
"Set-Cookie":
|
| 634 |
+
"access-token-unsecure-123=abc; HttpOnly; Path=/; SameSite=none; Secure"
|
| 635 |
+
}
|
| 636 |
+
}
|
| 637 |
+
);
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
+
return new HttpResponse(null, {
|
| 641 |
+
status: 401,
|
| 642 |
+
headers: {
|
| 643 |
+
"Content-Type": "application/json"
|
| 644 |
+
}
|
| 645 |
+
});
|
| 646 |
+
}),
|
| 647 |
+
http.post(`${invalid_auth_space_url}/${LOGIN_URL}`, async () => {
|
| 648 |
+
return new HttpResponse(null, {
|
| 649 |
+
status: 401,
|
| 650 |
+
headers: {
|
| 651 |
+
"Content-Type": "application/json"
|
| 652 |
+
}
|
| 653 |
+
});
|
| 654 |
+
}),
|
| 655 |
+
http.post(`${private_auth_space_url}/${LOGIN_URL}`, async ({ request }) => {
|
| 656 |
+
let username;
|
| 657 |
+
let password;
|
| 658 |
+
|
| 659 |
+
await request.formData().then((data) => {
|
| 660 |
+
username = data.get("username");
|
| 661 |
+
password = data.get("password");
|
| 662 |
+
});
|
| 663 |
+
|
| 664 |
+
if (username === "admin" && password === "pass1234") {
|
| 665 |
+
return new HttpResponse(
|
| 666 |
+
JSON.stringify({
|
| 667 |
+
success: true
|
| 668 |
+
}),
|
| 669 |
+
{
|
| 670 |
+
status: 200,
|
| 671 |
+
headers: {
|
| 672 |
+
"Content-Type": "application/json",
|
| 673 |
+
"Set-Cookie":
|
| 674 |
+
"access-token-unsecure-123=abc; HttpOnly; Path=/; SameSite=none; Secure"
|
| 675 |
+
}
|
| 676 |
+
}
|
| 677 |
+
);
|
| 678 |
+
}
|
| 679 |
+
|
| 680 |
+
return new HttpResponse(null, {
|
| 681 |
+
status: 401,
|
| 682 |
+
headers: {
|
| 683 |
+
"Content-Type": "application/json"
|
| 684 |
+
}
|
| 685 |
+
});
|
| 686 |
+
})
|
| 687 |
+
];
|
6.29.1/client/src/test/mock_eventsource.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { vi } from "vitest";
|
| 2 |
+
|
| 3 |
+
if (import.meta.env.TEST_MODE !== "node") {
|
| 4 |
+
Object.defineProperty(window, "EventSource", {
|
| 5 |
+
writable: true,
|
| 6 |
+
value: vi.fn().mockImplementation(() => ({
|
| 7 |
+
close: vi.fn(() => {}),
|
| 8 |
+
addEventListener: vi.fn(),
|
| 9 |
+
onmessage: vi.fn((_event: MessageEvent) => {}),
|
| 10 |
+
onerror: vi.fn((_event: Event) => {})
|
| 11 |
+
}))
|
| 12 |
+
});
|
| 13 |
+
}
|
6.29.1/client/src/test/server.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { handlers } from "./handlers";
|
| 2 |
+
// import type { StartOptions } from 'msw';
|
| 3 |
+
import type { SetupWorker, StartOptions } from "msw/browser";
|
| 4 |
+
|
| 5 |
+
const IS_NODE =
|
| 6 |
+
typeof process !== "undefined" && process.env.TEST_MODE === "node";
|
| 7 |
+
|
| 8 |
+
interface MockServer {
|
| 9 |
+
start: (opts: StartOptions) => void | ReturnType<SetupWorker["start"]>;
|
| 10 |
+
stop: () => void | Promise<void>;
|
| 11 |
+
use: (...handlers: any[]) => void;
|
| 12 |
+
resetHandlers: (...handlers: any[]) => void;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
export async function initialise_server(): Promise<MockServer> {
|
| 16 |
+
if (IS_NODE) {
|
| 17 |
+
const { setupServer } = await import("msw/node");
|
| 18 |
+
const server = setupServer(...handlers);
|
| 19 |
+
return {
|
| 20 |
+
start: (opts: StartOptions) => server.listen(opts),
|
| 21 |
+
stop: () => server.close(),
|
| 22 |
+
use: (...h) => server.use(...h),
|
| 23 |
+
resetHandlers: (...h) => server.resetHandlers(...h)
|
| 24 |
+
};
|
| 25 |
+
}
|
| 26 |
+
const { setupWorker } = await import("msw/browser");
|
| 27 |
+
const worker = setupWorker(...handlers);
|
| 28 |
+
return {
|
| 29 |
+
start: (opts: StartOptions) => worker.start(opts),
|
| 30 |
+
stop: () => worker.stop(),
|
| 31 |
+
use: (...h) => worker.use(...h),
|
| 32 |
+
resetHandlers: (...h) => worker.resetHandlers(...h)
|
| 33 |
+
};
|
| 34 |
+
}
|
6.29.1/client/src/test/test_data.ts
ADDED
|
@@ -0,0 +1,562 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// @ts-nocheck
|
| 2 |
+
import { ApiData, ApiInfo, Config, EndpointInfo } from "../types";
|
| 3 |
+
|
| 4 |
+
export const runtime_response = {
|
| 5 |
+
stage: "RUNNING",
|
| 6 |
+
hardware: {
|
| 7 |
+
current: "cpu-basic",
|
| 8 |
+
requested: "cpu-basic"
|
| 9 |
+
},
|
| 10 |
+
storage: {
|
| 11 |
+
current: null,
|
| 12 |
+
requested: null
|
| 13 |
+
},
|
| 14 |
+
gcTimeout: 86400,
|
| 15 |
+
replicas: {
|
| 16 |
+
current: 1,
|
| 17 |
+
requested: 1
|
| 18 |
+
},
|
| 19 |
+
devMode: false,
|
| 20 |
+
domains: [
|
| 21 |
+
{
|
| 22 |
+
domain: "hmb-hello-world.hf.space",
|
| 23 |
+
isCustom: false,
|
| 24 |
+
stage: "READY"
|
| 25 |
+
}
|
| 26 |
+
]
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
export const transformed_api_info: ApiInfo<ApiData> = {
|
| 30 |
+
named_endpoints: {
|
| 31 |
+
"/predict": {
|
| 32 |
+
parameters: [
|
| 33 |
+
{
|
| 34 |
+
label: "name",
|
| 35 |
+
type: "string",
|
| 36 |
+
python_type: { type: "str", description: "" },
|
| 37 |
+
component: "Textbox",
|
| 38 |
+
example_input: "Hello!!"
|
| 39 |
+
}
|
| 40 |
+
],
|
| 41 |
+
returns: [
|
| 42 |
+
{
|
| 43 |
+
label: "output",
|
| 44 |
+
type: "string",
|
| 45 |
+
python_type: { type: "str", description: "" },
|
| 46 |
+
component: "Textbox"
|
| 47 |
+
}
|
| 48 |
+
],
|
| 49 |
+
type: { generator: false, cancel: false }
|
| 50 |
+
}
|
| 51 |
+
},
|
| 52 |
+
unnamed_endpoints: {
|
| 53 |
+
"0": {
|
| 54 |
+
parameters: [
|
| 55 |
+
{
|
| 56 |
+
label: "name",
|
| 57 |
+
type: "string",
|
| 58 |
+
python_type: { type: "str", description: "" },
|
| 59 |
+
component: "Textbox",
|
| 60 |
+
example_input: "Hello!!"
|
| 61 |
+
}
|
| 62 |
+
],
|
| 63 |
+
returns: [
|
| 64 |
+
{
|
| 65 |
+
label: "output",
|
| 66 |
+
type: "string",
|
| 67 |
+
python_type: { type: "str", description: "" },
|
| 68 |
+
component: "Textbox"
|
| 69 |
+
}
|
| 70 |
+
],
|
| 71 |
+
type: { generator: false, cancel: false }
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
};
|
| 75 |
+
|
| 76 |
+
export const response_api_info: ApiInfo<ApiData> = {
|
| 77 |
+
named_endpoints: {
|
| 78 |
+
"/predict": {
|
| 79 |
+
parameters: [
|
| 80 |
+
{
|
| 81 |
+
label: "name",
|
| 82 |
+
type: {
|
| 83 |
+
type: "string"
|
| 84 |
+
},
|
| 85 |
+
python_type: {
|
| 86 |
+
type: "str",
|
| 87 |
+
description: ""
|
| 88 |
+
},
|
| 89 |
+
component: "Textbox",
|
| 90 |
+
example_input: "Hello!!"
|
| 91 |
+
}
|
| 92 |
+
],
|
| 93 |
+
returns: [
|
| 94 |
+
{
|
| 95 |
+
label: "output",
|
| 96 |
+
type: {
|
| 97 |
+
type: "string"
|
| 98 |
+
},
|
| 99 |
+
python_type: {
|
| 100 |
+
type: "str",
|
| 101 |
+
description: ""
|
| 102 |
+
},
|
| 103 |
+
component: "Textbox"
|
| 104 |
+
}
|
| 105 |
+
]
|
| 106 |
+
}
|
| 107 |
+
},
|
| 108 |
+
unnamed_endpoints: {}
|
| 109 |
+
};
|
| 110 |
+
|
| 111 |
+
export const config_response: Config = {
|
| 112 |
+
version: "4.27.0",
|
| 113 |
+
mode: "interface",
|
| 114 |
+
app_id: 123,
|
| 115 |
+
dev_mode: false,
|
| 116 |
+
analytics_enabled: true,
|
| 117 |
+
components: [
|
| 118 |
+
{
|
| 119 |
+
id: 3,
|
| 120 |
+
type: "row",
|
| 121 |
+
props: {
|
| 122 |
+
variant: "default",
|
| 123 |
+
visible: true,
|
| 124 |
+
equal_height: false,
|
| 125 |
+
name: "row"
|
| 126 |
+
},
|
| 127 |
+
skip_api: true,
|
| 128 |
+
component_class_id: ""
|
| 129 |
+
},
|
| 130 |
+
{
|
| 131 |
+
id: 4,
|
| 132 |
+
type: "column",
|
| 133 |
+
props: {
|
| 134 |
+
scale: 1,
|
| 135 |
+
min_width: 320,
|
| 136 |
+
variant: "panel",
|
| 137 |
+
visible: true,
|
| 138 |
+
name: "column"
|
| 139 |
+
},
|
| 140 |
+
skip_api: true,
|
| 141 |
+
component_class_id: ""
|
| 142 |
+
},
|
| 143 |
+
{
|
| 144 |
+
id: 5,
|
| 145 |
+
type: "column",
|
| 146 |
+
props: {
|
| 147 |
+
scale: 1,
|
| 148 |
+
min_width: 320,
|
| 149 |
+
variant: "default",
|
| 150 |
+
visible: true,
|
| 151 |
+
name: "column"
|
| 152 |
+
},
|
| 153 |
+
skip_api: true,
|
| 154 |
+
component_class_id: ""
|
| 155 |
+
},
|
| 156 |
+
{
|
| 157 |
+
id: 1,
|
| 158 |
+
type: "textbox",
|
| 159 |
+
props: {
|
| 160 |
+
lines: 1,
|
| 161 |
+
max_lines: 20,
|
| 162 |
+
label: "name",
|
| 163 |
+
show_label: true,
|
| 164 |
+
container: true,
|
| 165 |
+
min_width: 160,
|
| 166 |
+
visible: true,
|
| 167 |
+
autofocus: false,
|
| 168 |
+
autoscroll: true,
|
| 169 |
+
elem_classes: [],
|
| 170 |
+
type: "text",
|
| 171 |
+
rtl: false,
|
| 172 |
+
show_copy_button: false,
|
| 173 |
+
name: "textbox",
|
| 174 |
+
_selectable: false
|
| 175 |
+
},
|
| 176 |
+
skip_api: false,
|
| 177 |
+
component_class_id: "",
|
| 178 |
+
api_info: {
|
| 179 |
+
type: "string"
|
| 180 |
+
},
|
| 181 |
+
example_inputs: "Hello!!"
|
| 182 |
+
},
|
| 183 |
+
{
|
| 184 |
+
id: 6,
|
| 185 |
+
type: "form",
|
| 186 |
+
props: {
|
| 187 |
+
scale: 0,
|
| 188 |
+
min_width: 0,
|
| 189 |
+
name: "form"
|
| 190 |
+
},
|
| 191 |
+
skip_api: true,
|
| 192 |
+
component_class_id: ""
|
| 193 |
+
},
|
| 194 |
+
{
|
| 195 |
+
id: 7,
|
| 196 |
+
type: "row",
|
| 197 |
+
props: {
|
| 198 |
+
variant: "default",
|
| 199 |
+
visible: true,
|
| 200 |
+
equal_height: true,
|
| 201 |
+
name: "row"
|
| 202 |
+
},
|
| 203 |
+
skip_api: true,
|
| 204 |
+
component_class_id: ""
|
| 205 |
+
},
|
| 206 |
+
{
|
| 207 |
+
id: 8,
|
| 208 |
+
type: "button",
|
| 209 |
+
props: {
|
| 210 |
+
value: "Clear",
|
| 211 |
+
variant: "secondary",
|
| 212 |
+
visible: true,
|
| 213 |
+
interactive: true,
|
| 214 |
+
elem_classes: [],
|
| 215 |
+
api_visibility: "undocumented",
|
| 216 |
+
name: "button",
|
| 217 |
+
_selectable: false
|
| 218 |
+
},
|
| 219 |
+
skip_api: true,
|
| 220 |
+
component_class_id: ""
|
| 221 |
+
},
|
| 222 |
+
{
|
| 223 |
+
id: 9,
|
| 224 |
+
type: "button",
|
| 225 |
+
props: {
|
| 226 |
+
value: "Submit",
|
| 227 |
+
variant: "primary",
|
| 228 |
+
visible: true,
|
| 229 |
+
interactive: true,
|
| 230 |
+
elem_classes: [],
|
| 231 |
+
name: "button",
|
| 232 |
+
_selectable: false
|
| 233 |
+
},
|
| 234 |
+
skip_api: true,
|
| 235 |
+
component_class_id: ""
|
| 236 |
+
},
|
| 237 |
+
{
|
| 238 |
+
id: 10,
|
| 239 |
+
type: "column",
|
| 240 |
+
props: {
|
| 241 |
+
scale: 1,
|
| 242 |
+
min_width: 320,
|
| 243 |
+
variant: "panel",
|
| 244 |
+
visible: true,
|
| 245 |
+
name: "column"
|
| 246 |
+
},
|
| 247 |
+
skip_api: true,
|
| 248 |
+
component_class_id: ""
|
| 249 |
+
},
|
| 250 |
+
{
|
| 251 |
+
id: 2,
|
| 252 |
+
type: "textbox",
|
| 253 |
+
props: {
|
| 254 |
+
lines: 1,
|
| 255 |
+
max_lines: 20,
|
| 256 |
+
label: "output",
|
| 257 |
+
show_label: true,
|
| 258 |
+
container: true,
|
| 259 |
+
min_width: 160,
|
| 260 |
+
interactive: false,
|
| 261 |
+
visible: true,
|
| 262 |
+
autofocus: false,
|
| 263 |
+
autoscroll: true,
|
| 264 |
+
elem_classes: [],
|
| 265 |
+
type: "text",
|
| 266 |
+
rtl: false,
|
| 267 |
+
show_copy_button: false,
|
| 268 |
+
name: "textbox",
|
| 269 |
+
_selectable: false
|
| 270 |
+
},
|
| 271 |
+
skip_api: false,
|
| 272 |
+
component_class_id: "",
|
| 273 |
+
api_info: {
|
| 274 |
+
type: "string"
|
| 275 |
+
},
|
| 276 |
+
example_inputs: "Hello!!"
|
| 277 |
+
},
|
| 278 |
+
{
|
| 279 |
+
id: 11,
|
| 280 |
+
type: "row",
|
| 281 |
+
props: {
|
| 282 |
+
variant: "default",
|
| 283 |
+
visible: true,
|
| 284 |
+
equal_height: true,
|
| 285 |
+
name: "row"
|
| 286 |
+
},
|
| 287 |
+
skip_api: true,
|
| 288 |
+
component_class_id: ""
|
| 289 |
+
},
|
| 290 |
+
{
|
| 291 |
+
id: 12,
|
| 292 |
+
type: "form",
|
| 293 |
+
props: {
|
| 294 |
+
scale: 0,
|
| 295 |
+
min_width: 0,
|
| 296 |
+
name: "form"
|
| 297 |
+
},
|
| 298 |
+
skip_api: true,
|
| 299 |
+
component_class_id: ""
|
| 300 |
+
}
|
| 301 |
+
],
|
| 302 |
+
css: null,
|
| 303 |
+
js: null,
|
| 304 |
+
head: null,
|
| 305 |
+
title: "Gradio",
|
| 306 |
+
space_id: "hmb/hello_world",
|
| 307 |
+
enable_queue: true,
|
| 308 |
+
show_error: false,
|
| 309 |
+
footer_links: ["api", "gradio", "settings"],
|
| 310 |
+
is_colab: false,
|
| 311 |
+
stylesheets: [],
|
| 312 |
+
theme: "default",
|
| 313 |
+
protocol: "sse_v3",
|
| 314 |
+
body_css: {
|
| 315 |
+
body_background_fill: "white",
|
| 316 |
+
body_text_color: "#1f2937",
|
| 317 |
+
body_background_fill_dark: "#0b0f19",
|
| 318 |
+
body_text_color_dark: "#f3f4f6"
|
| 319 |
+
},
|
| 320 |
+
fill_height: false,
|
| 321 |
+
layout: {
|
| 322 |
+
id: 0,
|
| 323 |
+
children: [
|
| 324 |
+
{
|
| 325 |
+
id: 3,
|
| 326 |
+
children: [
|
| 327 |
+
{
|
| 328 |
+
id: 4,
|
| 329 |
+
children: [
|
| 330 |
+
{
|
| 331 |
+
id: 5,
|
| 332 |
+
children: [
|
| 333 |
+
{
|
| 334 |
+
id: 6,
|
| 335 |
+
children: [
|
| 336 |
+
{
|
| 337 |
+
id: 1
|
| 338 |
+
}
|
| 339 |
+
]
|
| 340 |
+
}
|
| 341 |
+
]
|
| 342 |
+
},
|
| 343 |
+
{
|
| 344 |
+
id: 7,
|
| 345 |
+
children: [
|
| 346 |
+
{
|
| 347 |
+
id: 8
|
| 348 |
+
},
|
| 349 |
+
{
|
| 350 |
+
id: 9
|
| 351 |
+
}
|
| 352 |
+
]
|
| 353 |
+
}
|
| 354 |
+
]
|
| 355 |
+
},
|
| 356 |
+
{
|
| 357 |
+
id: 10,
|
| 358 |
+
children: [
|
| 359 |
+
{
|
| 360 |
+
id: 12,
|
| 361 |
+
children: [
|
| 362 |
+
{
|
| 363 |
+
id: 2
|
| 364 |
+
}
|
| 365 |
+
]
|
| 366 |
+
},
|
| 367 |
+
{
|
| 368 |
+
id: 11,
|
| 369 |
+
children: []
|
| 370 |
+
}
|
| 371 |
+
]
|
| 372 |
+
}
|
| 373 |
+
]
|
| 374 |
+
}
|
| 375 |
+
]
|
| 376 |
+
},
|
| 377 |
+
dependencies: [
|
| 378 |
+
{
|
| 379 |
+
id: 0,
|
| 380 |
+
targets: [
|
| 381 |
+
[9, "click"],
|
| 382 |
+
[1, "submit"]
|
| 383 |
+
],
|
| 384 |
+
inputs: [1],
|
| 385 |
+
outputs: [2],
|
| 386 |
+
backend_fn: true,
|
| 387 |
+
js: null,
|
| 388 |
+
queue: null,
|
| 389 |
+
api_name: "predict",
|
| 390 |
+
scroll_to_output: false,
|
| 391 |
+
show_progress: "full",
|
| 392 |
+
every: null,
|
| 393 |
+
batch: false,
|
| 394 |
+
max_batch_size: 4,
|
| 395 |
+
cancels: [],
|
| 396 |
+
types: {
|
| 397 |
+
generator: false,
|
| 398 |
+
cancel: false
|
| 399 |
+
},
|
| 400 |
+
collects_event_data: false,
|
| 401 |
+
trigger_after: null,
|
| 402 |
+
trigger_only_on_success: false,
|
| 403 |
+
trigger_only_on_failure: false,
|
| 404 |
+
trigger_mode: "once",
|
| 405 |
+
api_visibility: "public",
|
| 406 |
+
zerogpu: false
|
| 407 |
+
},
|
| 408 |
+
{
|
| 409 |
+
id: 1,
|
| 410 |
+
targets: [[8, "click"]],
|
| 411 |
+
inputs: [],
|
| 412 |
+
outputs: [1, 2],
|
| 413 |
+
backend_fn: false,
|
| 414 |
+
js: "() => [null, null]",
|
| 415 |
+
queue: false,
|
| 416 |
+
api_name: "js_fn",
|
| 417 |
+
scroll_to_output: false,
|
| 418 |
+
show_progress: "full",
|
| 419 |
+
every: null,
|
| 420 |
+
batch: false,
|
| 421 |
+
max_batch_size: 4,
|
| 422 |
+
cancels: [],
|
| 423 |
+
types: {
|
| 424 |
+
generator: false,
|
| 425 |
+
cancel: false
|
| 426 |
+
},
|
| 427 |
+
collects_event_data: false,
|
| 428 |
+
trigger_after: null,
|
| 429 |
+
trigger_only_on_success: false,
|
| 430 |
+
trigger_only_on_failure: false,
|
| 431 |
+
trigger_mode: "once",
|
| 432 |
+
api_visibility: "private",
|
| 433 |
+
zerogpu: false
|
| 434 |
+
},
|
| 435 |
+
{
|
| 436 |
+
id: 2,
|
| 437 |
+
targets: [[8, "click"]],
|
| 438 |
+
inputs: [],
|
| 439 |
+
outputs: [5],
|
| 440 |
+
backend_fn: false,
|
| 441 |
+
js: '() => [{"variant": null, "visible": true, "__type__": "update"}]\n ',
|
| 442 |
+
queue: false,
|
| 443 |
+
api_name: "js_fn_1",
|
| 444 |
+
scroll_to_output: false,
|
| 445 |
+
show_progress: "full",
|
| 446 |
+
every: null,
|
| 447 |
+
batch: false,
|
| 448 |
+
max_batch_size: 4,
|
| 449 |
+
cancels: [],
|
| 450 |
+
types: {
|
| 451 |
+
generator: false,
|
| 452 |
+
cancel: false
|
| 453 |
+
},
|
| 454 |
+
collects_event_data: false,
|
| 455 |
+
trigger_after: null,
|
| 456 |
+
trigger_only_on_success: false,
|
| 457 |
+
trigger_only_on_failure: false,
|
| 458 |
+
trigger_mode: "once",
|
| 459 |
+
api_visibility: "private",
|
| 460 |
+
zerogpu: false
|
| 461 |
+
}
|
| 462 |
+
],
|
| 463 |
+
root: "https://hmb-hello-world.hf.space",
|
| 464 |
+
path: ""
|
| 465 |
+
};
|
| 466 |
+
|
| 467 |
+
export const whoami_response = {
|
| 468 |
+
type: "user",
|
| 469 |
+
id: "123",
|
| 470 |
+
name: "hmb",
|
| 471 |
+
fullname: "jerry",
|
| 472 |
+
email: "jerry@gradio.com",
|
| 473 |
+
emailVerified: true,
|
| 474 |
+
canPay: true,
|
| 475 |
+
periodEnd: 123,
|
| 476 |
+
isPro: false,
|
| 477 |
+
avatarUrl: "",
|
| 478 |
+
orgs: [],
|
| 479 |
+
auth: {
|
| 480 |
+
type: "access_token",
|
| 481 |
+
accessToken: {
|
| 482 |
+
displayName: "Gradio Client",
|
| 483 |
+
role: "write"
|
| 484 |
+
}
|
| 485 |
+
}
|
| 486 |
+
};
|
| 487 |
+
|
| 488 |
+
export const duplicate_response = {
|
| 489 |
+
url: "https://huggingface.co/spaces/hmb/hello_world"
|
| 490 |
+
};
|
| 491 |
+
|
| 492 |
+
export const hardware_sleeptime_response = {
|
| 493 |
+
stage: "RUNNING",
|
| 494 |
+
hardware: {
|
| 495 |
+
current: "cpu-basic",
|
| 496 |
+
requested: "cpu-upgrade"
|
| 497 |
+
},
|
| 498 |
+
storage: null,
|
| 499 |
+
gcTimeout: 300,
|
| 500 |
+
replicas: {
|
| 501 |
+
current: 1,
|
| 502 |
+
requested: 1
|
| 503 |
+
},
|
| 504 |
+
devMode: false,
|
| 505 |
+
domains: [
|
| 506 |
+
{
|
| 507 |
+
domain: "hmb-hello-world.hf.space",
|
| 508 |
+
isCustom: false,
|
| 509 |
+
stage: "READY"
|
| 510 |
+
}
|
| 511 |
+
]
|
| 512 |
+
};
|
| 513 |
+
|
| 514 |
+
export const endpoint_info: EndpointInfo<ApiData> = {
|
| 515 |
+
parameters: [
|
| 516 |
+
{
|
| 517 |
+
label: "parameter_2",
|
| 518 |
+
parameter_name: "im",
|
| 519 |
+
parameter_has_default: false,
|
| 520 |
+
parameter_default: null,
|
| 521 |
+
type: "",
|
| 522 |
+
python_type: {
|
| 523 |
+
type: "Dict(background: filepath | None, layers: List[filepath], composite: filepath | None, id: str | None)",
|
| 524 |
+
description: ""
|
| 525 |
+
},
|
| 526 |
+
component: "Imageeditor",
|
| 527 |
+
example_input: {
|
| 528 |
+
background: {
|
| 529 |
+
path: "",
|
| 530 |
+
meta: {
|
| 531 |
+
_type: "gradio.FileData"
|
| 532 |
+
},
|
| 533 |
+
orig_name: "bus.png",
|
| 534 |
+
url: ""
|
| 535 |
+
},
|
| 536 |
+
layers: [],
|
| 537 |
+
composite: null
|
| 538 |
+
}
|
| 539 |
+
}
|
| 540 |
+
],
|
| 541 |
+
returns: [
|
| 542 |
+
{
|
| 543 |
+
label: "value_3",
|
| 544 |
+
type: "string",
|
| 545 |
+
python_type: {
|
| 546 |
+
type: "filepath",
|
| 547 |
+
description: ""
|
| 548 |
+
},
|
| 549 |
+
component: "Image"
|
| 550 |
+
}
|
| 551 |
+
],
|
| 552 |
+
type: {
|
| 553 |
+
generator: false
|
|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entType } from "svelte";
|
| 6 |
+
|
| 7 |
+
export interface ApiData {
|
| 8 |
+
label: string;
|
| 9 |
+
parameter_name: string;
|
| 10 |
+
parameter_default?: any;
|
| 11 |
+
parameter_has_default?: boolean;
|
| 12 |
+
type: {
|
| 13 |
+
type: any;
|
| 14 |
+
description: string;
|
| 15 |
+
};
|
| 16 |
+
component: string;
|
| 17 |
+
example_input?: any;
|
| 18 |
+
python_type: { type: string; description: string };
|
| 19 |
+
serializer: string;
|
| 20 |
+
}
|
| 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: { type: string; description: string };
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
export interface EndpointInfo<T extends ApiData | JsApiData> {
|
| 36 |
+
parameters: T[];
|
| 37 |
+
returns: T[];
|
| 38 |
+
type?: DependencyTypes;
|
| 39 |
+
/** Set when the endpoint's function takes a `gr.OAuthToken`. */
|
| 40 |
+
oauth_token?: "required" | "optional";
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
export interface ApiInfo<T extends ApiData | JsApiData> {
|
| 44 |
+
named_endpoints: Record<string, EndpointInfo<T>>;
|
| 45 |
+
unnamed_endpoints: Record<string, EndpointInfo<T>>;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
export interface BlobRef {
|
| 49 |
+
path: string[];
|
| 50 |
+
type: string | undefined;
|
| 51 |
+
blob: Blob | File | false;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
export type DataType = string | Buffer | Record<string, any> | any[];
|
| 55 |
+
|
| 56 |
+
// custom class used for uploading local files
|
| 57 |
+
export class Command {
|
| 58 |
+
type: string;
|
| 59 |
+
command: string;
|
| 60 |
+
meta: {
|
| 61 |
+
path: string;
|
| 62 |
+
name: string;
|
| 63 |
+
orig_path: string;
|
| 64 |
+
};
|
| 65 |
+
fileData?: FileData;
|
| 66 |
+
|
| 67 |
+
constructor(
|
| 68 |
+
command: string,
|
| 69 |
+
meta: { path: string; name: string; orig_path: string }
|
| 70 |
+
) {
|
| 71 |
+
this.type = "command";
|
| 72 |
+
this.command = command;
|
| 73 |
+
this.meta = meta;
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
// Function Signature Types
|
| 78 |
+
|
| 79 |
+
export type SubmitFunction = (
|
| 80 |
+
endpoint: string | number,
|
| 81 |
+
data?: unknown[] | Record<string, unknown>,
|
| 82 |
+
event_data?: unknown,
|
| 83 |
+
trigger_id?: number | null,
|
| 84 |
+
all_events?: boolean,
|
| 85 |
+
additional_headers?: Record<string, string>
|
| 86 |
+
) => SubmitIterable<GradioEvent>;
|
| 87 |
+
|
| 88 |
+
export type PredictFunction = <T = unknown>(
|
| 89 |
+
endpoint: string | number,
|
| 90 |
+
data?: unknown[] | Record<string, unknown>,
|
| 91 |
+
event_data?: unknown
|
| 92 |
+
) => Promise<PredictReturn<T>>;
|
| 93 |
+
|
| 94 |
+
export type client_return = {
|
| 95 |
+
config: Config | undefined;
|
| 96 |
+
predict: PredictFunction;
|
| 97 |
+
submit: SubmitFunction;
|
| 98 |
+
component_server: (
|
| 99 |
+
component_id: number,
|
| 100 |
+
fn_name: string,
|
| 101 |
+
data: unknown[]
|
| 102 |
+
) => any;
|
| 103 |
+
view_api: (_fetch: typeof fetch) => Promise<ApiInfo<JsApiData>>;
|
| 104 |
+
};
|
| 105 |
+
|
| 106 |
+
export interface SubmitIterable<T> extends AsyncIterable<T> {
|
| 107 |
+
[Symbol.asyncIterator](): SubmitIterable<T>;
|
| 108 |
+
next: () => Promise<IteratorResult<T, unknown>>;
|
| 109 |
+
throw: (value: unknown) => Promise<IteratorResult<T, unknown>>;
|
| 110 |
+
return: () => Promise<IteratorReturnResult<undefined>>;
|
| 111 |
+
cancel: () => Promise<void>;
|
| 112 |
+
event_id: () => string;
|
| 113 |
+
send_chunk: (payload: Record<string, unknown>) => void;
|
| 114 |
+
wait_for_id: () => Promise<string | null>;
|
| 115 |
+
close_stream: () => void;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
export type PredictReturn<T = unknown> = {
|
| 119 |
+
type: EventType;
|
| 120 |
+
time: Date;
|
| 121 |
+
data: T;
|
| 122 |
+
endpoint: string;
|
| 123 |
+
fn_index: number;
|
| 124 |
+
};
|
| 125 |
+
|
| 126 |
+
// Space Status Types
|
| 127 |
+
|
| 128 |
+
export type SpaceStatus = SpaceStatusNormal | SpaceStatusError;
|
| 129 |
+
|
| 130 |
+
export interface SpaceStatusNormal {
|
| 131 |
+
status:
|
| 132 |
+
| "sleeping"
|
| 133 |
+
| "running"
|
| 134 |
+
| "building"
|
| 135 |
+
| "error"
|
| 136 |
+
| "stopped"
|
| 137 |
+
| "starting";
|
| 138 |
+
detail:
|
| 139 |
+
| "SLEEPING"
|
| 140 |
+
| "RUNNING"
|
| 141 |
+
| "RUNNING_BUILDING"
|
| 142 |
+
| "BUILDING"
|
| 143 |
+
| "APP_STARTING"
|
| 144 |
+
| "NOT_FOUND";
|
| 145 |
+
load_status: "pending" | "error" | "complete" | "generating";
|
| 146 |
+
message: string;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
export interface SpaceStatusError {
|
| 150 |
+
status: "space_error" | "paused";
|
| 151 |
+
detail:
|
| 152 |
+
| "NO_APP_FILE"
|
| 153 |
+
| "CONFIG_ERROR"
|
| 154 |
+
| "BUILD_ERROR"
|
| 155 |
+
| "RUNTIME_ERROR"
|
| 156 |
+
| "PAUSED";
|
| 157 |
+
load_status: "error";
|
| 158 |
+
message: string;
|
| 159 |
+
discussions_enabled: boolean;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
export type SpaceStatusCallback = (a: SpaceStatus) => void;
|
| 163 |
+
|
| 164 |
+
// Configuration and Response Types
|
| 165 |
+
// --------------------------------
|
| 166 |
+
export interface Config {
|
| 167 |
+
deep_link_state?: "none" | "valid" | "invalid";
|
| 168 |
+
auth_required?: true;
|
| 169 |
+
app_id?: string;
|
| 170 |
+
analytics_enabled: boolean;
|
| 171 |
+
connect_heartbeat: boolean;
|
| 172 |
+
dev_mode: boolean;
|
| 173 |
+
vibe_mode: boolean;
|
| 174 |
+
auth_message: string;
|
| 175 |
+
components: ComponentMeta[];
|
| 176 |
+
css: string | null;
|
| 177 |
+
js: string | null;
|
| 178 |
+
head: string | null;
|
| 179 |
+
dependencies: Dependency[];
|
| 180 |
+
enable_queue: boolean;
|
| 181 |
+
show_error: boolean;
|
| 182 |
+
layout: any;
|
| 183 |
+
mode: "blocks" | "interface" | "chat_interface";
|
| 184 |
+
root: string;
|
| 185 |
+
root_url?: string;
|
| 186 |
+
theme: string;
|
| 187 |
+
title: string;
|
| 188 |
+
version: string;
|
| 189 |
+
space_id: string | null;
|
| 190 |
+
is_space: boolean;
|
| 191 |
+
is_colab: boolean;
|
| 192 |
+
footer_links: string[];
|
| 193 |
+
stylesheets: string[];
|
| 194 |
+
current_page: string;
|
| 195 |
+
page: Record<
|
| 196 |
+
string,
|
| 197 |
+
{
|
| 198 |
+
components: number[];
|
| 199 |
+
dependencies: number[];
|
| 200 |
+
layout: any;
|
| 201 |
+
}
|
| 202 |
+
>;
|
| 203 |
+
pages: [string, string, boolean][];
|
| 204 |
+
protocol: "sse_v3" | "sse_v2.1" | "sse_v2" | "sse_v1" | "sse" | "ws";
|
| 205 |
+
max_file_size?: number;
|
| 206 |
+
theme_hash?: number;
|
| 207 |
+
username: string | null;
|
| 208 |
+
api_prefix?: string;
|
| 209 |
+
fill_height?: boolean;
|
| 210 |
+
fill_width?: boolean;
|
| 211 |
+
pwa?: boolean;
|
| 212 |
+
i18n_translations?: Record<string, Record<string, string>> | null;
|
| 213 |
+
mcp_server?: boolean;
|
| 214 |
+
/**
|
| 215 |
+
* Whether the app permits its runs being saved in the browser. Set from
|
| 216 |
+
* `run_history` on `launch()`; absent on apps served by older versions of
|
| 217 |
+
* Gradio, which is treated as permitted.
|
| 218 |
+
*/
|
| 219 |
+
run_history?: boolean;
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
// todo: DRY up types
|
| 223 |
+
export interface ComponentMeta {
|
| 224 |
+
type: string;
|
| 225 |
+
id: number;
|
| 226 |
+
has_modes: boolean;
|
| 227 |
+
props: SharedProps;
|
| 228 |
+
instance: SvelteComponent;
|
| 229 |
+
component: ComponentType<SvelteComponent>;
|
| 230 |
+
documentation?: Documentation;
|
| 231 |
+
children?: ComponentMeta[];
|
| 232 |
+
parent?: ComponentMeta;
|
| 233 |
+
value?: any;
|
| 234 |
+
component_class_id: string;
|
| 235 |
+
key: string | number | null;
|
| 236 |
+
rendered_in?: number;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
interface SharedProps {
|
| 240 |
+
elem_id?: string;
|
| 241 |
+
elem_classes?: string[];
|
| 242 |
+
components?: string[];
|
| 243 |
+
server_fns?: string[];
|
| 244 |
+
interactive: boolean;
|
| 245 |
+
visible: boolean | "hidden";
|
| 246 |
+
[key: string]: unknown;
|
| 247 |
+
root_url?: string;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
export interface Documentation {
|
| 251 |
+
type?: TypeDescription;
|
| 252 |
+
description?: TypeDescription;
|
| 253 |
+
example_data?: string;
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
interface TypeDescription {
|
| 257 |
+
input_payload?: string;
|
| 258 |
+
response_object?: string;
|
| 259 |
+
payload?: string;
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
export interface Dependency {
|
| 263 |
+
id: number;
|
| 264 |
+
targets: [number, string][];
|
| 265 |
+
inputs: number[];
|
| 266 |
+
outputs: number[];
|
| 267 |
+
backend_fn: boolean;
|
| 268 |
+
js: string | null;
|
| 269 |
+
scroll_to_output: boolean;
|
| 270 |
+
trigger: "click" | "load" | string;
|
| 271 |
+
max_batch_size: number;
|
| 272 |
+
show_progress: "full" | "minimal" | "hidden";
|
| 273 |
+
show_progress_on: number[] | null;
|
| 274 |
+
frontend_fn: ((...args: unknown[]) => Promise<unknown[]>) | null;
|
| 275 |
+
status?: string;
|
| 276 |
+
queue: boolean | null;
|
| 277 |
+
every: number | null;
|
| 278 |
+
batch: boolean;
|
| 279 |
+
api_name: string | null;
|
| 280 |
+
cancels: number[];
|
| 281 |
+
types: DependencyTypes;
|
| 282 |
+
collects_event_data: boolean;
|
| 283 |
+
pending_request?: boolean;
|
| 284 |
+
trigger_after?: number;
|
| 285 |
+
trigger_only_on_success?: boolean;
|
| 286 |
+
trigger_only_on_failure?: boolean;
|
| 287 |
+
trigger_mode: "once" | "multiple" | "always_last";
|
| 288 |
+
final_event: Payload | null;
|
| 289 |
+
api_visibility: "public" | "private" | "undocumented";
|
| 290 |
+
rendered_in: number | null;
|
| 291 |
+
render_id: number | null;
|
| 292 |
+
connection: "stream" | "sse";
|
| 293 |
+
time_limit: number;
|
| 294 |
+
stream_every: number;
|
| 295 |
+
like_user_message: boolean;
|
| 296 |
+
event_specific_args: string[];
|
| 297 |
+
component_prop_inputs: number[];
|
| 298 |
+
js_implementation: string | null;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
export interface DependencyTypes {
|
| 302 |
+
generator: boolean;
|
| 303 |
+
cancel: boolean;
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
export interface Payload {
|
| 307 |
+
fn_index: number;
|
| 308 |
+
data: unknown[];
|
| 309 |
+
time?: Date;
|
| 310 |
+
event_data?: unknown;
|
| 311 |
+
trigger_id?: number | null;
|
| 312 |
+
oauth_token?: string;
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
export interface PostResponse {
|
| 316 |
+
error?: string;
|
| 317 |
+
[x: string]: any;
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
export interface UploadResponse {
|
| 321 |
+
error?: string;
|
| 322 |
+
files?: string[];
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
// Client and File Handling Types
|
| 326 |
+
|
| 327 |
+
export interface DuplicateOptions extends ClientOptions {
|
| 328 |
+
private?: boolean;
|
| 329 |
+
hardware?: (typeof hardware_types)[number];
|
| 330 |
+
timeout?: number;
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
export interface ClientOptions {
|
| 334 |
+
token?: `hf_${string}`;
|
| 335 |
+
/**
|
| 336 |
+
* @deprecated Use `token` instead. Kept as an alias so that code written
|
| 337 |
+
* for older versions of the client keeps working.
|
| 338 |
+
*/
|
| 339 |
+
hf_token?: `hf_${string}`;
|
| 340 |
+
status_callback?: SpaceStatusCallback | null;
|
| 341 |
+
auth?: [string, string] | null;
|
| 342 |
+
with_null_state?: boolean;
|
| 343 |
+
events?: EventType[];
|
| 344 |
+
headers?: Record<string, string> | Headers;
|
| 345 |
+
query_params?: Record<string, string>;
|
| 346 |
+
session_hash?: string;
|
| 347 |
+
cookies?: string;
|
| 348 |
+
credentials?: RequestCredentials;
|
| 349 |
+
/**
|
| 350 |
+
* A Hugging Face token passed to the app's own code, for endpoints whose
|
| 351 |
+
* function takes a `gr.OAuthToken`. Unlike `token`, which only authenticates
|
| 352 |
+
* you to the app, this lets the app act on your behalf, so it is sent only to
|
| 353 |
+
* endpoints that declare they need it.
|
| 354 |
+
*/
|
| 355 |
+
oauth_token?: string;
|
| 356 |
+
/**
|
| 357 |
+
* Whether to save each call's inputs and outputs to the history destination
|
| 358 |
+
* selected in this browser (local storage by default, or a connected bucket).
|
| 359 |
+
* Defaults to true, and only ever applies in a browser: in Node there is no
|
| 360 |
+
* selected destination and nothing is recorded. The app can turn it off for
|
| 361 |
+
* everyone with `run_history=False` on `launch()`, which takes precedence.
|
| 362 |
+
*/
|
| 363 |
+
record_history?: boolean;
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
export interface FileData {
|
| 367 |
+
name: string;
|
| 368 |
+
orig_name?: string;
|
| 369 |
+
size?: number;
|
| 370 |
+
data: string;
|
| 371 |
+
blob?: File;
|
| 372 |
+
is_file?: boolean;
|
| 373 |
+
mime_type?: string;
|
| 374 |
+
alt_text?: string;
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
// Event and Listener Types
|
| 378 |
+
|
| 379 |
+
export type EventType = "data" | "status" | "log" | "render";
|
| 380 |
+
|
| 381 |
+
export interface EventMap {
|
| 382 |
+
data: PayloadMessage;
|
| 383 |
+
status: StatusMessage;
|
| 384 |
+
log: LogMessage;
|
| 385 |
+
render: RenderMessage;
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
export type GradioEvent = {
|
| 389 |
+
[P in EventType]: EventMap[P];
|
| 390 |
+
}[EventType];
|
| 391 |
+
|
| 392 |
+
export interface Log {
|
| 393 |
+
log: string;
|
| 394 |
+
title: string;
|
| 395 |
+
level: "warning" | "info" | "success" | "error";
|
| 396 |
+
}
|
| 397 |
+
export interface Render {
|
| 398 |
+
data: {
|
| 399 |
+
components: any[];
|
| 400 |
+
layout: any;
|
| 401 |
+
dependencies: Dependency[];
|
| 402 |
+
render_id: number;
|
| 403 |
+
};
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
export interface ValidationError {
|
| 407 |
+
is_valid: boolean;
|
| 408 |
+
message: string;
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
export interface Status {
|
| 412 |
+
queue: boolean;
|
| 413 |
+
code?: string;
|
| 414 |
+
success?: boolean;
|
| 415 |
+
stage: "pending" | "error" | "complete" | "generating" | "streaming";
|
| 416 |
+
duration?: number;
|
| 417 |
+
visible?: boolean;
|
| 418 |
+
broken?: boolean;
|
| 419 |
+
size?: number;
|
| 420 |
+
position?: number;
|
| 421 |
+
eta?: number;
|
| 422 |
+
title?: string;
|
| 423 |
+
message?: string | ValidationError[];
|
| 424 |
+
progress_data?: {
|
| 425 |
+
progress: number | null;
|
| 426 |
+
index: number | null;
|
| 427 |
+
length: number | null;
|
| 428 |
+
unit: string | null;
|
| 429 |
+
desc: string | null;
|
| 430 |
+
}[];
|
| 431 |
+
time?: Date;
|
| 432 |
+
changed_state_ids?: number[];
|
| 433 |
+
time_limit?: number;
|
| 434 |
+
session_not_found?: boolean;
|
| 435 |
+
used_cache?: "full" | "partial" | null;
|
| 436 |
+
cache_duration?: number;
|
| 437 |
+
avg_time?: number;
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
export interface StatusMessage extends Status {
|
| 441 |
+
type: "status";
|
| 442 |
+
endpoint: string;
|
| 443 |
+
fn_index: number;
|
| 444 |
+
original_msg?: string;
|
| 445 |
+
}
|
| 446 |
+
|
| 447 |
+
export interface PayloadMessage extends Payload {
|
| 448 |
+
type: "data";
|
| 449 |
+
endpoint: string;
|
| 450 |
+
fn_index: number;
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
export interface LogMessage extends Log {
|
| 454 |
+
type: "log";
|
| 455 |
+
endpoint: string;
|
| 456 |
+
fn_index: number;
|
| 457 |
+
duration: number | null;
|
| 458 |
+
visible: boolean;
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
export interface RenderMessage extends Render {
|
| 462 |
+
type: "render";
|
| 463 |
+
endpoint: string;
|
| 464 |
+
fn_index: number;
|
| 465 |
+
}
|
6.29.1/client/src/upload.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Client } from "./client";
|
| 2 |
+
import { filesize } from "./utils/filesize";
|
| 3 |
+
export async function upload(
|
| 4 |
+
this: Client,
|
| 5 |
+
file_data: FileData[],
|
| 6 |
+
root_url: string,
|
| 7 |
+
upload_id?: string,
|
| 8 |
+
max_file_size?: number
|
| 9 |
+
): Promise<(FileData | null)[] | null> {
|
| 10 |
+
let files = (Array.isArray(file_data) ? file_data : [file_data]).map(
|
| 11 |
+
(file_data) => file_data.blob!
|
| 12 |
+
);
|
| 13 |
+
|
| 14 |
+
const oversized_files = files.filter(
|
| 15 |
+
(f) => f.size > (max_file_size ?? Infinity)
|
| 16 |
+
);
|
| 17 |
+
if (oversized_files.length) {
|
| 18 |
+
throw new Error(
|
| 19 |
+
`File(s) exceed the maximum allowed size of ${filesize(max_file_size || Infinity)}: ${oversized_files
|
| 20 |
+
.map((f) => `"${f.name}"`)
|
| 21 |
+
.join(", ")}`
|
| 22 |
+
);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
return await Promise.all(
|
| 26 |
+
await this.upload_files(root_url, files, upload_id).then(
|
| 27 |
+
async (response: { files?: string[]; error?: string }) => {
|
| 28 |
+
if (response.error) {
|
| 29 |
+
throw new Error(response.error);
|
| 30 |
+
} else {
|
| 31 |
+
if (response.files) {
|
| 32 |
+
return response.files.map((f, i) => {
|
| 33 |
+
const encoded_path = f
|
| 34 |
+
.split("/")
|
| 35 |
+
.map((segment) => encodeURIComponent(segment))
|
| 36 |
+
.join("/");
|
| 37 |
+
const file = new FileData({
|
| 38 |
+
...file_data[i],
|
| 39 |
+
path: f,
|
| 40 |
+
url: `${root_url}${this.api_prefix}/file=${encoded_path}`
|
| 41 |
+
});
|
| 42 |
+
return file;
|
| 43 |
+
});
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
return [];
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
)
|
| 50 |
+
);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
export async function prepare_files(
|
| 54 |
+
files: File[],
|
| 55 |
+
is_stream?: boolean
|
| 56 |
+
): Promise<FileData[]> {
|
| 57 |
+
return files.map(
|
| 58 |
+
(f) =>
|
| 59 |
+
new FileData({
|
| 60 |
+
path: f.name,
|
| 61 |
+
orig_name: f.name,
|
| 62 |
+
blob: f,
|
| 63 |
+
size: f.size,
|
| 64 |
+
mime_type: f.type,
|
| 65 |
+
is_stream
|
| 66 |
+
})
|
| 67 |
+
);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
export class FileData {
|
| 71 |
+
path: string;
|
| 72 |
+
url?: string;
|
| 73 |
+
orig_name?: string;
|
| 74 |
+
size?: number;
|
| 75 |
+
blob?: File;
|
| 76 |
+
is_stream?: boolean;
|
| 77 |
+
mime_type?: string;
|
| 78 |
+
alt_text?: string;
|
| 79 |
+
b64?: string;
|
| 80 |
+
readonly meta = { _type: "gradio.FileData" };
|
| 81 |
+
|
| 82 |
+
constructor({
|
| 83 |
+
path,
|
| 84 |
+
url,
|
| 85 |
+
orig_name,
|
| 86 |
+
size,
|
| 87 |
+
blob,
|
| 88 |
+
is_stream,
|
| 89 |
+
mime_type,
|
| 90 |
+
alt_text,
|
| 91 |
+
b64
|
| 92 |
+
}: {
|
| 93 |
+
path: string;
|
| 94 |
+
url?: string;
|
| 95 |
+
orig_name?: string;
|
| 96 |
+
size?: number;
|
| 97 |
+
blob?: File;
|
| 98 |
+
is_stream?: boolean;
|
| 99 |
+
mime_type?: string;
|
| 100 |
+
alt_text?: string;
|
| 101 |
+
b64?: string;
|
| 102 |
+
}) {
|
| 103 |
+
this.path = path;
|
| 104 |
+
this.url = url;
|
| 105 |
+
this.orig_name = orig_name;
|
| 106 |
+
this.size = size;
|
| 107 |
+
this.blob = url ? undefined : blob;
|
| 108 |
+
this.is_stream = is_stream;
|
| 109 |
+
this.mime_type = mime_type;
|
| 110 |
+
this.alt_text = alt_text;
|
| 111 |
+
this.b64 = b64;
|
| 112 |
+
}
|
| 113 |
+
}
|
6.29.1/client/src/utils/bucket_sync.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Client for the durable run history in an HF Hub bucket
|
| 3 |
+
* (`/gradio_api/run-history/*`).
|
| 4 |
+
*
|
| 5 |
+
* Read-only by design. Records are written by the server from the run it
|
| 6 |
+
* actually executed — there is no push function here, and nothing in this
|
| 7 |
+
* module can create a record.
|
| 8 |
+
*
|
| 9 |
+
* Every call names the bucket it is talking about. The server holds no
|
| 10 |
+
* per-session binding, so two tabs (or two apps on one origin) cannot end up
|
| 11 |
+
* reading each other's history.
|
| 12 |
+
*/
|
| 13 |
+
|
| 14 |
+
const BUCKET_ID_RE = /^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-][a-zA-Z0-9_./-]*$/;
|
| 15 |
+
|
| 16 |
+
export function is_valid_bucket_id(id: string): boolean {
|
| 17 |
+
if (!BUCKET_ID_RE.test(id)) return false;
|
| 18 |
+
return !id
|
| 19 |
+
.split("/")
|
| 20 |
+
.some((seg) => seg === "" || seg === "." || seg === "..");
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
/** Mirrors `HistoryRecord` in `gradio/history.py`. */
|
| 24 |
+
export interface HistoryRecord {
|
| 25 |
+
record_id: string;
|
| 26 |
+
endpoint: string;
|
| 27 |
+
inputs: unknown;
|
| 28 |
+
outputs: unknown;
|
| 29 |
+
started_at: string;
|
| 30 |
+
schema_version: number;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
export interface HistoryResult<T> {
|
| 34 |
+
ok: boolean;
|
| 35 |
+
status: number;
|
| 36 |
+
data: T;
|
| 37 |
+
detail?: string;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
function url(
|
| 41 |
+
root: string,
|
| 42 |
+
path: string,
|
| 43 |
+
params?: Record<string, string>
|
| 44 |
+
): string {
|
| 45 |
+
const query = params ? `?${new URLSearchParams(params)}` : "";
|
| 46 |
+
const base = root.replace(/\/+$/, "");
|
| 47 |
+
if (base) return `${base}/gradio_api/run-history/${path}${query}`;
|
| 48 |
+
// No configured root. A leading slash would drop any mount subpath
|
| 49 |
+
// (`mount_gradio_app(app, path="/myapp")`), so resolve against the document
|
| 50 |
+
// base, which gradio sets via <base href> on the app shell.
|
| 51 |
+
if (typeof document !== "undefined" && document.baseURI) {
|
| 52 |
+
return new URL(
|
| 53 |
+
`gradio_api/run-history/${path}${query}`,
|
| 54 |
+
document.baseURI
|
| 55 |
+
).toString();
|
| 56 |
+
}
|
| 57 |
+
return `gradio_api/run-history/${path}${query}`;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
async function parse_error(res: Response): Promise<string> {
|
| 61 |
+
try {
|
| 62 |
+
const j = await res.json();
|
| 63 |
+
return typeof j?.detail === "string" ? j.detail : `${res.status}`;
|
| 64 |
+
} catch {
|
| 65 |
+
return `${res.status}`;
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
async function request<T>(
|
| 70 |
+
input: string,
|
| 71 |
+
init: RequestInit,
|
| 72 |
+
fallback: T,
|
| 73 |
+
pick: (body: any) => T
|
| 74 |
+
): Promise<HistoryResult<T>> {
|
| 75 |
+
try {
|
| 76 |
+
const res = await fetch(input, { credentials: "include", ...init });
|
| 77 |
+
if (!res.ok) {
|
| 78 |
+
// An empty list and a failed request are different things: a 401 here
|
| 79 |
+
// means "sign in", not "no runs yet".
|
| 80 |
+
return {
|
| 81 |
+
ok: false,
|
| 82 |
+
status: res.status,
|
| 83 |
+
data: fallback,
|
| 84 |
+
detail: await parse_error(res)
|
| 85 |
+
};
|
| 86 |
+
}
|
| 87 |
+
return { ok: true, status: res.status, data: pick(await res.json()) };
|
| 88 |
+
} catch (e) {
|
| 89 |
+
return { ok: false, status: 0, data: fallback, detail: String(e) };
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
/**
|
| 94 |
+
* Create the bucket if it does not exist and confirm it is writable. Stores
|
| 95 |
+
* nothing server-side — the caller keeps its own choice and names it on every
|
| 96 |
+
* later request.
|
| 97 |
+
*/
|
| 98 |
+
export async function connect_bucket(
|
| 99 |
+
root: string,
|
| 100 |
+
bucket_id: string
|
| 101 |
+
): Promise<HistoryResult<null>> {
|
| 102 |
+
if (!is_valid_bucket_id(bucket_id)) {
|
| 103 |
+
return {
|
| 104 |
+
ok: false,
|
| 105 |
+
status: 422,
|
| 106 |
+
data: null,
|
| 107 |
+
detail: "invalid bucket id"
|
| 108 |
+
};
|
| 109 |
+
}
|
| 110 |
+
return request(
|
| 111 |
+
url(root, "connect"),
|
| 112 |
+
{
|
| 113 |
+
method: "POST",
|
| 114 |
+
headers: { "Content-Type": "application/json" },
|
| 115 |
+
body: JSON.stringify({ bucket_id })
|
| 116 |
+
},
|
| 117 |
+
null,
|
| 118 |
+
() => null
|
| 119 |
+
);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
export async function list_user_buckets(
|
| 123 |
+
root: string
|
| 124 |
+
): Promise<HistoryResult<string[]>> {
|
| 125 |
+
return request<string[]>(url(root, "buckets"), {}, [], (b) =>
|
| 126 |
+
Array.isArray(b?.buckets) ? b.buckets : []
|
| 127 |
+
);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
export async function list_bucket_records(
|
| 131 |
+
root: string,
|
| 132 |
+
bucket: string
|
| 133 |
+
): Promise<HistoryResult<HistoryRecord[]>> {
|
| 134 |
+
return request(url(root, "records", { bucket }), {}, [], (b) =>
|
| 135 |
+
Array.isArray(b?.records) ? b.records : []
|
| 136 |
+
);
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
export function asset_url(
|
| 140 |
+
root: string,
|
| 141 |
+
bucket: string,
|
| 142 |
+
endpoint: string,
|
| 143 |
+
record_id: string,
|
| 144 |
+
filename: string
|
| 145 |
+
): string {
|
| 146 |
+
return url(
|
| 147 |
+
root,
|
| 148 |
+
`records/${encodeURIComponent(endpoint)}/${encodeURIComponent(
|
| 149 |
+
record_id
|
| 150 |
+
)}/assets/${encodeURIComponent(filename)}`,
|
| 151 |
+
{ bucket }
|
| 152 |
+
);
|
| 153 |
+
}
|
6.29.1/client/src/utils/duplicate.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import {
|
| 2 |
+
get_space_hardware,
|
| 3 |
+
hardware_types,
|
| 4 |
+
set_space_timeout
|
| 5 |
+
} from "../helpers/spaces";
|
| 6 |
+
import type { DuplicateOptions } from "../types";
|
| 7 |
+
import { Client } from "../client";
|
| 8 |
+
import { SPACE_METADATA_ERROR_MSG } from "../constants";
|
| 9 |
+
import {
|
| 10 |
+
get_cookie_header,
|
| 11 |
+
normalise_token_option,
|
| 12 |
+
parse_and_set_cookies
|
| 13 |
+
} from "../helpers/init_helpers";
|
| 14 |
+
import { process_endpoint } from "../helpers/api_info";
|
| 15 |
+
|
| 16 |
+
export async function duplicate(
|
| 17 |
+
app_reference: string,
|
| 18 |
+
options: DuplicateOptions
|
| 19 |
+
): Promise<Client> {
|
| 20 |
+
normalise_token_option(options);
|
| 21 |
+
const { token, private: _private, hardware, timeout, auth } = options;
|
| 22 |
+
|
| 23 |
+
if (hardware && !hardware_types.includes(hardware)) {
|
| 24 |
+
throw new Error(
|
| 25 |
+
`Invalid hardware type provided. Valid types are: ${hardware_types
|
| 26 |
+
.map((v) => `"${v}"`)
|
| 27 |
+
.join(",")}.`
|
| 28 |
+
);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
const { http_protocol, host } = await process_endpoint(app_reference, token);
|
| 32 |
+
|
| 33 |
+
let cookies: string[] | null = null;
|
| 34 |
+
|
| 35 |
+
if (auth) {
|
| 36 |
+
const cookie_header = await get_cookie_header(
|
| 37 |
+
http_protocol,
|
| 38 |
+
host,
|
| 39 |
+
auth,
|
| 40 |
+
fetch,
|
| 41 |
+
undefined,
|
| 42 |
+
options.credentials
|
| 43 |
+
);
|
| 44 |
+
|
| 45 |
+
if (cookie_header) cookies = parse_and_set_cookies(cookie_header);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
const headers = {
|
| 49 |
+
Authorization: `Bearer ${token}`,
|
| 50 |
+
"Content-Type": "application/json",
|
| 51 |
+
...(cookies ? { Cookie: cookies.join("; ") } : {})
|
| 52 |
+
};
|
| 53 |
+
|
| 54 |
+
const user = (
|
| 55 |
+
await (
|
| 56 |
+
await fetch(`https://huggingface.co/api/whoami-v2`, {
|
| 57 |
+
headers
|
| 58 |
+
})
|
| 59 |
+
).json()
|
| 60 |
+
).name;
|
| 61 |
+
|
| 62 |
+
const space_name = app_reference.split("/")[1];
|
| 63 |
+
const body: {
|
| 64 |
+
repository: string;
|
| 65 |
+
private?: boolean;
|
| 66 |
+
hardware?: string;
|
| 67 |
+
} = {
|
| 68 |
+
repository: `${user}/${space_name}`
|
| 69 |
+
};
|
| 70 |
+
|
| 71 |
+
if (_private) {
|
| 72 |
+
body.private = true;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
let original_hardware;
|
| 76 |
+
|
| 77 |
+
try {
|
| 78 |
+
if (!hardware) {
|
| 79 |
+
original_hardware = await get_space_hardware(app_reference, token);
|
| 80 |
+
}
|
| 81 |
+
} catch (e) {
|
| 82 |
+
throw Error(SPACE_METADATA_ERROR_MSG + (e as Error).message);
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
const requested_hardware = hardware || original_hardware || "cpu-basic";
|
| 86 |
+
|
| 87 |
+
body.hardware = requested_hardware;
|
| 88 |
+
|
| 89 |
+
try {
|
| 90 |
+
const response = await fetch(
|
| 91 |
+
`https://huggingface.co/api/spaces/${app_reference}/duplicate`,
|
| 92 |
+
{
|
| 93 |
+
method: "POST",
|
| 94 |
+
headers,
|
| 95 |
+
body: JSON.stringify(body)
|
| 96 |
+
}
|
| 97 |
+
);
|
| 98 |
+
|
| 99 |
+
if (response.status === 409) {
|
| 100 |
+
try {
|
| 101 |
+
const client = await Client.connect(`${user}/${space_name}`, options);
|
| 102 |
+
return client;
|
| 103 |
+
} catch (error) {
|
| 104 |
+
console.error("Failed to connect Client instance:", error);
|
| 105 |
+
throw error;
|
| 106 |
+
}
|
| 107 |
+
} else if (response.status !== 200) {
|
| 108 |
+
throw new Error(response.statusText);
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
const duplicated_space = await response.json();
|
| 112 |
+
|
| 113 |
+
await set_space_timeout(`${user}/${space_name}`, timeout || 300, token);
|
| 114 |
+
|
| 115 |
+
return await Client.connect(
|
| 116 |
+
get_space_reference(duplicated_space.url),
|
| 117 |
+
options
|
| 118 |
+
);
|
| 119 |
+
} catch (e: any) {
|
| 120 |
+
throw new Error(e);
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
function get_space_reference(url: string): any {
|
| 125 |
+
const regex = /https:\/\/huggingface.co\/spaces\/([^/]+\/[^/]+)/;
|
| 126 |
+
const match = url.match(regex);
|
| 127 |
+
if (match) {
|
| 128 |
+
return match[1];
|
| 129 |
+
}
|
| 130 |
+
}
|
6.29.1/client/src/utils/filesize.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
type SPEC = {
|
| 2 |
+
readonly radix: number;
|
| 3 |
+
readonly unit: string[];
|
| 4 |
+
};
|
| 5 |
+
|
| 6 |
+
const si = {
|
| 7 |
+
radix: 1e3,
|
| 8 |
+
unit: ["b", "kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"]
|
| 9 |
+
};
|
| 10 |
+
const iec = {
|
| 11 |
+
radix: 1024,
|
| 12 |
+
unit: ["b", "Kib", "Mib", "Gib", "Tib", "Pib", "Eib", "Zib", "Yib"]
|
| 13 |
+
};
|
| 14 |
+
const jedec = {
|
| 15 |
+
radix: 1024,
|
| 16 |
+
unit: ["b", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"]
|
| 17 |
+
};
|
| 18 |
+
|
| 19 |
+
export const SPECS: Record<string, SPEC> = {
|
| 20 |
+
si,
|
| 21 |
+
iec,
|
| 22 |
+
jedec
|
| 23 |
+
};
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* file size from https://github.com/hustcc/filesize.js
|
| 27 |
+
* @param bytes - The number of bytes to convert to human-readable format
|
| 28 |
+
* @param fixed - Number of decimal places to display (default: 1)
|
| 29 |
+
* @param spec - Size specification to use: "si", "iec", or "jedec" (default: "jedec")
|
| 30 |
+
* @returns Human-readable file size string
|
| 31 |
+
*/
|
| 32 |
+
export function filesize(bytes: number, fixed = 1, spec = "jedec"): string {
|
| 33 |
+
bytes = Math.abs(bytes);
|
| 34 |
+
const { radix, unit } = SPECS[spec] || SPECS.jedec;
|
| 35 |
+
let loop = 0;
|
| 36 |
+
while (bytes >= radix) {
|
| 37 |
+
bytes /= radix;
|
| 38 |
+
++loop;
|
| 39 |
+
}
|
| 40 |
+
return `${bytes.toFixed(fixed)} ${unit[loop]}`;
|
| 41 |
+
}
|
6.29.1/client/src/utils/handle_blob.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { update_object, walk_and_store_blobs } from "../helpers/data";
|
| 2 |
+
import {
|
| 3 |
+
Command,
|
| 4 |
+
type ApiData,
|
| 5 |
+
type EndpointInfo,
|
| 6 |
+
type JsApiData
|
| 7 |
+
} from "../types";
|
| 8 |
+
import { FileData } from "../upload";
|
| 9 |
+
import type { Client } from "..";
|
| 10 |
+
import {
|
| 11 |
+
FILE_PROCESSING_ERROR_MSG,
|
| 12 |
+
NODEJS_FS_ERROR_MSG,
|
| 13 |
+
ROOT_URL_ERROR_MSG
|
| 14 |
+
} from "../constants";
|
| 15 |
+
|
| 16 |
+
export async function handle_blob(
|
| 17 |
+
this: Client,
|
| 18 |
+
endpoint: string,
|
| 19 |
+
data: unknown[],
|
| 20 |
+
api_info: EndpointInfo<JsApiData | ApiData>
|
| 21 |
+
): Promise<unknown[]> {
|
| 22 |
+
const self = this;
|
| 23 |
+
|
| 24 |
+
await process_local_file_commands(self, data);
|
| 25 |
+
|
| 26 |
+
const blobRefs = await walk_and_store_blobs(
|
| 27 |
+
data,
|
| 28 |
+
undefined,
|
| 29 |
+
[],
|
| 30 |
+
true,
|
| 31 |
+
api_info
|
| 32 |
+
);
|
| 33 |
+
|
| 34 |
+
const results = await Promise.all(
|
| 35 |
+
blobRefs.map(async ({ path, blob, type }) => {
|
| 36 |
+
if (!blob) return { path, type };
|
| 37 |
+
|
| 38 |
+
const response = await self.upload_files(endpoint, [blob]);
|
| 39 |
+
const file_url = response.files && response.files[0];
|
| 40 |
+
return {
|
| 41 |
+
path,
|
| 42 |
+
file_url,
|
| 43 |
+
type,
|
| 44 |
+
name:
|
| 45 |
+
typeof File !== "undefined" && blob instanceof File
|
| 46 |
+
? blob?.name
|
| 47 |
+
: undefined
|
| 48 |
+
};
|
| 49 |
+
})
|
| 50 |
+
);
|
| 51 |
+
|
| 52 |
+
results.forEach(({ path, file_url, type, name }) => {
|
| 53 |
+
if (type === "Gallery") {
|
| 54 |
+
update_object(data, file_url, path);
|
| 55 |
+
} else if (file_url) {
|
| 56 |
+
const file = new FileData({ path: file_url, orig_name: name });
|
| 57 |
+
update_object(data, file, path);
|
| 58 |
+
}
|
| 59 |
+
});
|
| 60 |
+
|
| 61 |
+
return data;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
export async function process_local_file_commands(
|
| 65 |
+
client: Client,
|
| 66 |
+
data: unknown[]
|
| 67 |
+
): Promise<void> {
|
| 68 |
+
const root = client.config?.root || client.config?.root_url;
|
| 69 |
+
|
| 70 |
+
if (!root) {
|
| 71 |
+
throw new Error(ROOT_URL_ERROR_MSG);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
await recursively_process_commands(client, data);
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
async function recursively_process_commands(
|
| 78 |
+
client: Client,
|
| 79 |
+
data: any,
|
| 80 |
+
path: string[] = []
|
| 81 |
+
): Promise<void> {
|
| 82 |
+
for (const key in data) {
|
| 83 |
+
if (data[key] instanceof Command) {
|
| 84 |
+
await process_single_command(client, data, key);
|
| 85 |
+
} else if (typeof data[key] === "object" && data[key] !== null) {
|
| 86 |
+
await recursively_process_commands(client, data[key], [...path, key]);
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
async function process_single_command(
|
| 92 |
+
client: Client,
|
| 93 |
+
data: any,
|
| 94 |
+
key: string
|
| 95 |
+
): Promise<void> {
|
| 96 |
+
let cmd_item = data[key] as Command;
|
| 97 |
+
const root = client.config?.root || client.config?.root_url;
|
| 98 |
+
|
| 99 |
+
if (!root) {
|
| 100 |
+
throw new Error(ROOT_URL_ERROR_MSG);
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
try {
|
| 104 |
+
let fileBuffer: Buffer;
|
| 105 |
+
let fullPath: string;
|
| 106 |
+
|
| 107 |
+
// check if running in a Node.js environment
|
| 108 |
+
if (
|
| 109 |
+
typeof process !== "undefined" &&
|
| 110 |
+
process.versions &&
|
| 111 |
+
process.versions.node
|
| 112 |
+
) {
|
| 113 |
+
const fs = await import("fs/promises");
|
| 114 |
+
const path = await import("path");
|
| 115 |
+
|
| 116 |
+
fullPath = path.resolve(process.cwd(), cmd_item.meta.path);
|
| 117 |
+
fileBuffer = await fs.readFile(fullPath); // Read file from disk
|
| 118 |
+
} else {
|
| 119 |
+
throw new Error(NODEJS_FS_ERROR_MSG);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
const file = new Blob([fileBuffer as any], {
|
| 123 |
+
type: "application/octet-stream"
|
| 124 |
+
});
|
| 125 |
+
|
| 126 |
+
const response = await client.upload_files(root, [file]);
|
| 127 |
+
|
| 128 |
+
const file_url = response.files && response.files[0];
|
| 129 |
+
|
| 130 |
+
if (file_url) {
|
| 131 |
+
const fileData = new FileData({
|
| 132 |
+
path: file_url,
|
| 133 |
+
orig_name: cmd_item.meta.name || ""
|
| 134 |
+
});
|
| 135 |
+
|
| 136 |
+
// replace the command object with the fileData object
|
| 137 |
+
data[key] = fileData;
|
| 138 |
+
}
|
| 139 |
+
} catch (error) {
|
| 140 |
+
console.error(FILE_PROCESSING_ERROR_MSG, error);
|
| 141 |
+
}
|
| 142 |
+
}
|
6.29.1/client/src/utils/post_data.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { BROKEN_CONNECTION_MSG } from "../constants";
|
| 2 |
+
import type { PostResponse } from "../types";
|
| 3 |
+
import { Client } from "..";
|
| 4 |
+
|
| 5 |
+
export async function post_data(
|
| 6 |
+
this: Client,
|
| 7 |
+
url: string,
|
| 8 |
+
body: unknown,
|
| 9 |
+
additional_headers?: any
|
| 10 |
+
): Promise<[PostResponse, number]> {
|
| 11 |
+
const headers: {
|
| 12 |
+
Authorization?: string;
|
| 13 |
+
"Content-Type": "application/json";
|
| 14 |
+
} = { "Content-Type": "application/json" };
|
| 15 |
+
if (this.options.token) {
|
| 16 |
+
headers.Authorization = `Bearer ${this.options.token}`;
|
| 17 |
+
}
|
| 18 |
+
try {
|
| 19 |
+
var response = await this.fetch(url, {
|
| 20 |
+
method: "POST",
|
| 21 |
+
body: JSON.stringify(body),
|
| 22 |
+
headers: { ...headers, ...additional_headers },
|
| 23 |
+
credentials: this.options.credentials ?? "same-origin"
|
| 24 |
+
});
|
| 25 |
+
} catch (e) {
|
| 26 |
+
return [{ error: BROKEN_CONNECTION_MSG }, 500];
|
| 27 |
+
}
|
| 28 |
+
let output: PostResponse;
|
| 29 |
+
let status: number;
|
| 30 |
+
try {
|
| 31 |
+
output = await response.json();
|
| 32 |
+
status = response.status;
|
| 33 |
+
} catch (e) {
|
| 34 |
+
output = { error: `Could not parse server response: ${e}` };
|
| 35 |
+
status = 500;
|
| 36 |
+
}
|
| 37 |
+
return [output, status];
|
| 38 |
+
}
|
6.29.1/client/src/utils/predict.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Client } from "../client";
|
| 2 |
+
import type { Dependency, PredictReturn } from "../types";
|
| 3 |
+
|
| 4 |
+
export async function predict<T = unknown>(
|
| 5 |
+
this: Client,
|
| 6 |
+
endpoint: string | number,
|
| 7 |
+
data: unknown[] | Record<string, unknown> = {}
|
| 8 |
+
): Promise<PredictReturn<T>> {
|
| 9 |
+
let data_returned = false;
|
| 10 |
+
let status_complete = false;
|
| 11 |
+
let dependency: Dependency;
|
| 12 |
+
|
| 13 |
+
if (!this.config) {
|
| 14 |
+
throw new Error("Could not resolve app config");
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
if (typeof endpoint === "number") {
|
| 18 |
+
dependency = this.config.dependencies.find((dep) => dep.id == endpoint)!;
|
| 19 |
+
} else {
|
| 20 |
+
const trimmed_endpoint = endpoint.replace(/^\//, "");
|
| 21 |
+
dependency = this.config.dependencies.find(
|
| 22 |
+
(dep) => dep.id == this.api_map[trimmed_endpoint]
|
| 23 |
+
)!;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
const app = this.submit(endpoint, data, null, null, true);
|
| 27 |
+
let result: unknown;
|
| 28 |
+
|
| 29 |
+
for await (const message of app) {
|
| 30 |
+
if (message.type === "data") {
|
| 31 |
+
data_returned = true;
|
| 32 |
+
result = message;
|
| 33 |
+
if (status_complete) {
|
| 34 |
+
return result as PredictReturn<T>;
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
if (message.type === "status") {
|
| 39 |
+
if (message.stage === "error") {
|
| 40 |
+
// Throw a real `Error` (rather than the raw status object) so that
|
| 41 |
+
// uncaught failures surface a readable message instead of
|
| 42 |
+
// crashing Node with `ERR_UNHANDLED_REJECTION ... reason "#<Object>"`.
|
| 43 |
+
// The status fields are preserved on the error for callers that
|
| 44 |
+
// inspect them.
|
| 45 |
+
const { message: error_message, ...status } = message;
|
| 46 |
+
const error = new Error(
|
| 47 |
+
(typeof error_message === "string"
|
| 48 |
+
? error_message
|
| 49 |
+
: error_message && JSON.stringify(error_message)) ||
|
| 50 |
+
"An unknown error occurred while making a prediction."
|
| 51 |
+
);
|
| 52 |
+
Object.assign(error, status);
|
| 53 |
+
throw error;
|
| 54 |
+
}
|
| 55 |
+
if (message.stage === "complete") {
|
| 56 |
+
status_complete = true;
|
| 57 |
+
// if complete message comes after data, resolve here
|
| 58 |
+
if (data_returned) {
|
| 59 |
+
return result as PredictReturn<T>;
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
return result as PredictReturn<T>;
|
| 66 |
+
}
|
6.29.1/client/src/utils/run_history.ts
ADDED
|
@@ -0,0 +1,652 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { GradioEvent, StatusMessage } from "../types";
|
| 2 |
+
|
| 3 |
+
// Keyed on the app id, so two different apps served on the same port never
|
| 4 |
+
// share a history. The id is regenerated whenever an app starts, so a restart
|
| 5 |
+
// begins a fresh history and leaves the previous one orphaned; `prune_apps`
|
| 6 |
+
// keeps those from accumulating.
|
| 7 |
+
//
|
| 8 |
+
// The key also carries the logged-in user, because local storage outlives a
|
| 9 |
+
// session: without it, whoever logs into an authenticated app next on this
|
| 10 |
+
// browser would open the previous user's runs.
|
| 11 |
+
const KEY_ROOT = "gradio:run-history:";
|
| 12 |
+
const STORAGE_PREFIX = `${KEY_ROOT}v2:`;
|
| 13 |
+
const REPLAY_PREFIX = `${KEY_ROOT}replay:v2:`;
|
| 14 |
+
const DESTINATION_PREFIX = `${KEY_ROOT}destination:v1:`;
|
| 15 |
+
const MAX_RUNS = 100;
|
| 16 |
+
const MAX_APPS = 8;
|
| 17 |
+
|
| 18 |
+
export type AppId = string | number | null | undefined;
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* Which history to read or write. `Config` satisfies this shape, so callers
|
| 22 |
+
* that hold one can pass it straight through.
|
| 23 |
+
*/
|
| 24 |
+
export interface RunHistoryScope {
|
| 25 |
+
app_id?: AppId;
|
| 26 |
+
/** The authenticated user, when the app uses `auth`. */
|
| 27 |
+
username?: string | null;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
export type RunHistoryStorage =
|
| 31 |
+
| { type: "browser"; bucket_id?: string }
|
| 32 |
+
| { type: "bucket"; bucket_id: string };
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* Run history is a side effect of submitting, never the point of it, so no
|
| 36 |
+
* failure in here may propagate into the caller and break the app. Every
|
| 37 |
+
* exported function routes through this.
|
| 38 |
+
*/
|
| 39 |
+
function safely<T>(operation: () => T, fallback: T): T {
|
| 40 |
+
try {
|
| 41 |
+
return operation();
|
| 42 |
+
} catch (error) {
|
| 43 |
+
console.warn("Could not update the run history.", error);
|
| 44 |
+
return fallback;
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
export type RunStatus = "running" | "completed" | "failed";
|
| 49 |
+
|
| 50 |
+
export interface StoredRunComponent {
|
| 51 |
+
type: string;
|
| 52 |
+
component_class_id: string;
|
| 53 |
+
props: Record<string, unknown>;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
export interface StoredRun {
|
| 57 |
+
id: string;
|
| 58 |
+
endpoint: string | number;
|
| 59 |
+
api_name: string;
|
| 60 |
+
fn_index: number;
|
| 61 |
+
page: string;
|
| 62 |
+
inputs: unknown;
|
| 63 |
+
outputs: unknown | null;
|
| 64 |
+
input_components?: (StoredRunComponent | null)[];
|
| 65 |
+
output_components?: (StoredRunComponent | null)[];
|
| 66 |
+
status: RunStatus;
|
| 67 |
+
error?: string;
|
| 68 |
+
started_at: string;
|
| 69 |
+
/** When the server started running the function, if it reported queueing. */
|
| 70 |
+
process_started_at?: string;
|
| 71 |
+
completed_at?: string;
|
| 72 |
+
/** How long the function itself took, server-reported where available. */
|
| 73 |
+
duration_ms?: number;
|
| 74 |
+
/** How long the run waited in the queue before the function started. */
|
| 75 |
+
queued_ms?: number;
|
| 76 |
+
/** Whether the run produced its output in chunks, i.e. came from a generator. */
|
| 77 |
+
streamed?: boolean;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
interface StartRunOptions extends RunHistoryScope {
|
| 81 |
+
endpoint: string | number;
|
| 82 |
+
api_name: string;
|
| 83 |
+
fn_index: number;
|
| 84 |
+
inputs: unknown;
|
| 85 |
+
input_components?: (StoredRunComponent | null)[];
|
| 86 |
+
output_components?: (StoredRunComponent | null)[];
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* The URL of the run history page for an app. `root` never carries a trailing
|
| 91 |
+
* slash, so it cannot simply be concatenated with the path.
|
| 92 |
+
*/
|
| 93 |
+
export function run_history_url(
|
| 94 |
+
root: string,
|
| 95 |
+
api_prefix = "/gradio_api"
|
| 96 |
+
): string {
|
| 97 |
+
return `${root.replace(/\/+$/, "")}${api_prefix}/runs`;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
function storage_key(scope: RunHistoryScope | null | undefined): string | null {
|
| 101 |
+
if (typeof window === "undefined") return null;
|
| 102 |
+
const app_id = scope?.app_id;
|
| 103 |
+
if (app_id === null || app_id === undefined || app_id === "") return null;
|
| 104 |
+
|
| 105 |
+
try {
|
| 106 |
+
if (!window.localStorage) return null;
|
| 107 |
+
// Encoded so that a username containing the separator cannot be made to
|
| 108 |
+
// collide with another user's key.
|
| 109 |
+
const user = scope?.username
|
| 110 |
+
? `:user:${encodeURIComponent(scope.username)}`
|
| 111 |
+
: "";
|
| 112 |
+
return `${STORAGE_PREFIX}${app_id}${user}`;
|
| 113 |
+
} catch {
|
| 114 |
+
return null;
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
function replay_key(scope: RunHistoryScope | null | undefined): string | null {
|
| 119 |
+
const key = storage_key(scope);
|
| 120 |
+
return key ? key.replace(STORAGE_PREFIX, REPLAY_PREFIX) : null;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
function destination_key(
|
| 124 |
+
scope: RunHistoryScope | null | undefined
|
| 125 |
+
): string | null {
|
| 126 |
+
const key = storage_key(scope);
|
| 127 |
+
return key ? key.replace(STORAGE_PREFIX, DESTINATION_PREFIX) : null;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
function read_run_history_storage_impl(
|
| 131 |
+
scope: RunHistoryScope | null | undefined
|
| 132 |
+
): RunHistoryStorage {
|
| 133 |
+
const key = destination_key(scope);
|
| 134 |
+
if (!key) return { type: "browser" };
|
| 135 |
+
try {
|
| 136 |
+
const value = JSON.parse(window.localStorage.getItem(key) || "null");
|
| 137 |
+
if (typeof value?.bucket_id === "string") {
|
| 138 |
+
return value.type === "bucket"
|
| 139 |
+
? { type: "bucket", bucket_id: value.bucket_id }
|
| 140 |
+
: { type: "browser", bucket_id: value.bucket_id };
|
| 141 |
+
}
|
| 142 |
+
return { type: "browser" };
|
| 143 |
+
} catch {
|
| 144 |
+
return { type: "browser" };
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
function set_run_history_storage_impl(
|
| 149 |
+
scope: RunHistoryScope | null | undefined,
|
| 150 |
+
storage: RunHistoryStorage
|
| 151 |
+
): void {
|
| 152 |
+
const key = destination_key(scope);
|
| 153 |
+
if (!key) return;
|
| 154 |
+
if (storage.type === "browser" && !storage.bucket_id) {
|
| 155 |
+
window.localStorage.removeItem(key);
|
| 156 |
+
} else {
|
| 157 |
+
window.localStorage.setItem(key, JSON.stringify(storage));
|
| 158 |
+
}
|
| 159 |
+
notify_run_history_change();
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
/** When a run was most recently saved under a key, for deciding what to drop. */
|
| 163 |
+
function last_saved_at(key: string): number {
|
| 164 |
+
try {
|
| 165 |
+
const runs = JSON.parse(window.localStorage.getItem(key) || "[]");
|
| 166 |
+
// Runs are stored newest first.
|
| 167 |
+
return Array.isArray(runs) && runs.length
|
| 168 |
+
? Date.parse(runs[0]?.started_at) || 0
|
| 169 |
+
: 0;
|
| 170 |
+
} catch {
|
| 171 |
+
return 0;
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
/**
|
| 176 |
+
* Drops the histories of long-gone app instances. Every restart mints a new app
|
| 177 |
+
* id, so without this the browser would keep every history an app ever had and
|
| 178 |
+
* eventually run out of room for the current one.
|
| 179 |
+
*/
|
| 180 |
+
function prune_apps(current_key: string): void {
|
| 181 |
+
const keys = Object.keys(window.localStorage).filter((key) =>
|
| 182 |
+
key.startsWith(KEY_ROOT)
|
| 183 |
+
);
|
| 184 |
+
const stale = [
|
| 185 |
+
// Keys written by an older layout can never be read again.
|
| 186 |
+
...keys.filter(
|
| 187 |
+
(key) =>
|
| 188 |
+
!key.startsWith(STORAGE_PREFIX) &&
|
| 189 |
+
!key.startsWith(REPLAY_PREFIX) &&
|
| 190 |
+
!key.startsWith(DESTINATION_PREFIX)
|
| 191 |
+
),
|
| 192 |
+
...keys
|
| 193 |
+
.filter((key) => key.startsWith(STORAGE_PREFIX) && key !== current_key)
|
| 194 |
+
.sort((a, b) => last_saved_at(b) - last_saved_at(a))
|
| 195 |
+
.slice(MAX_APPS - 1)
|
| 196 |
+
];
|
| 197 |
+
for (const key of stale) {
|
| 198 |
+
try {
|
| 199 |
+
window.localStorage.removeItem(key);
|
| 200 |
+
window.sessionStorage.removeItem(
|
| 201 |
+
key.replace(STORAGE_PREFIX, REPLAY_PREFIX)
|
| 202 |
+
);
|
| 203 |
+
} catch {
|
| 204 |
+
// Nothing to do if the browser will not let us clean up.
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
function make_id(): string {
|
| 210 |
+
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
| 211 |
+
return crypto.randomUUID();
|
| 212 |
+
}
|
| 213 |
+
return `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
function clone_for_storage(value: unknown): unknown {
|
| 217 |
+
const seen = new WeakSet<object>();
|
| 218 |
+
try {
|
| 219 |
+
return JSON.parse(
|
| 220 |
+
JSON.stringify(value, (_key, item) => {
|
| 221 |
+
if (typeof item === "bigint") return item.toString();
|
| 222 |
+
if (typeof item === "object" && item !== null) {
|
| 223 |
+
if (seen.has(item)) return "[Circular]";
|
| 224 |
+
seen.add(item);
|
| 225 |
+
}
|
| 226 |
+
return item;
|
| 227 |
+
})
|
| 228 |
+
);
|
| 229 |
+
} catch {
|
| 230 |
+
return "[Unserializable value]";
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
function read_run_history_impl(
|
| 235 |
+
scope: RunHistoryScope | null | undefined
|
| 236 |
+
): StoredRun[] {
|
| 237 |
+
const key = storage_key(scope);
|
| 238 |
+
if (!key) return [];
|
| 239 |
+
|
| 240 |
+
try {
|
| 241 |
+
const value = JSON.parse(window.localStorage.getItem(key) || "[]");
|
| 242 |
+
return Array.isArray(value) ? value : [];
|
| 243 |
+
} catch {
|
| 244 |
+
return [];
|
| 245 |
+
}
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
function write_run_history(
|
| 249 |
+
scope: RunHistoryScope | null | undefined,
|
| 250 |
+
runs: StoredRun[]
|
| 251 |
+
): void {
|
| 252 |
+
const key = storage_key(scope);
|
| 253 |
+
if (!key) return;
|
| 254 |
+
|
| 255 |
+
let next = runs.slice(0, MAX_RUNS);
|
| 256 |
+
let pruned = false;
|
| 257 |
+
while (next.length > 0) {
|
| 258 |
+
try {
|
| 259 |
+
window.localStorage.setItem(key, JSON.stringify(next));
|
| 260 |
+
return;
|
| 261 |
+
} catch {
|
| 262 |
+
// Reclaim the space held by app instances that are long gone before
|
| 263 |
+
// giving up on the oldest runs of the current one.
|
| 264 |
+
if (!pruned) {
|
| 265 |
+
pruned = true;
|
| 266 |
+
prune_apps(key);
|
| 267 |
+
continue;
|
| 268 |
+
}
|
| 269 |
+
next = next.slice(0, -1);
|
| 270 |
+
}
|
| 271 |
+
}
|
| 272 |
+
try {
|
| 273 |
+
window.localStorage.removeItem(key);
|
| 274 |
+
} catch {
|
| 275 |
+
// Run history must never interfere with an app submission.
|
| 276 |
+
}
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
function clear_run_history_impl(
|
| 280 |
+
scope: RunHistoryScope | null | undefined
|
| 281 |
+
): void {
|
| 282 |
+
const key = storage_key(scope);
|
| 283 |
+
if (!key) return;
|
| 284 |
+
try {
|
| 285 |
+
window.localStorage.removeItem(key);
|
| 286 |
+
} catch {
|
| 287 |
+
// Storage may be disabled by the browser.
|
| 288 |
+
}
|
| 289 |
+
notify_run_history_change();
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
function delete_run_history_impl(
|
| 293 |
+
scope: RunHistoryScope | null | undefined,
|
| 294 |
+
id: string
|
| 295 |
+
): void {
|
| 296 |
+
write_run_history(
|
| 297 |
+
scope,
|
| 298 |
+
read_run_history_impl(scope).filter((run) => run.id !== id)
|
| 299 |
+
);
|
| 300 |
+
notify_run_history_change();
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
const CHANGE_EVENT = "gradio:run-history-change";
|
| 304 |
+
|
| 305 |
+
function notify_run_history_change(): void {
|
| 306 |
+
if (typeof window === "undefined") return;
|
| 307 |
+
try {
|
| 308 |
+
window.dispatchEvent(new Event(CHANGE_EVENT));
|
| 309 |
+
} catch {
|
| 310 |
+
// Nothing depends on the notification arriving.
|
| 311 |
+
}
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
/**
|
| 315 |
+
* Subscribes to runs being added, deleted or cleared. `storage` covers other
|
| 316 |
+
* tabs; the custom event covers this one, which `storage` never fires for.
|
| 317 |
+
* Only counts change, not per-run progress, so listeners stay cheap.
|
| 318 |
+
*
|
| 319 |
+
* @returns a function that unsubscribes.
|
| 320 |
+
*/
|
| 321 |
+
function on_run_history_change_impl(listener: () => void): () => void {
|
| 322 |
+
if (typeof window === "undefined") return () => {};
|
| 323 |
+
window.addEventListener(CHANGE_EVENT, listener);
|
| 324 |
+
window.addEventListener("storage", listener);
|
| 325 |
+
return () => {
|
| 326 |
+
window.removeEventListener(CHANGE_EVENT, listener);
|
| 327 |
+
window.removeEventListener("storage", listener);
|
| 328 |
+
};
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
function stage_run_history_replay_impl(
|
| 332 |
+
scope: RunHistoryScope | null | undefined,
|
| 333 |
+
run: StoredRun
|
| 334 |
+
): void {
|
| 335 |
+
const key = replay_key(scope);
|
| 336 |
+
if (!key) return;
|
| 337 |
+
try {
|
| 338 |
+
window.sessionStorage.setItem(key, JSON.stringify(run));
|
| 339 |
+
} catch {
|
| 340 |
+
// Session storage may be disabled by the browser.
|
| 341 |
+
}
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
function consume_run_history_replay_impl(
|
| 345 |
+
scope: RunHistoryScope | null | undefined
|
| 346 |
+
): StoredRun | null {
|
| 347 |
+
const key = replay_key(scope);
|
| 348 |
+
if (!key) return null;
|
| 349 |
+
try {
|
| 350 |
+
const value = window.sessionStorage.getItem(key);
|
| 351 |
+
window.sessionStorage.removeItem(key);
|
| 352 |
+
return value ? (JSON.parse(value) as StoredRun) : null;
|
| 353 |
+
} catch {
|
| 354 |
+
return null;
|
| 355 |
+
}
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
/**
|
| 359 |
+
* The parts of an app config a replayed run writes back into. Kept structural
|
| 360 |
+
* so every entry point — the SPA and the SSR app each carry their own `Config`
|
| 361 |
+
* declaration — can hand its config straight over.
|
| 362 |
+
*/
|
| 363 |
+
export interface ReplayTarget {
|
| 364 |
+
components: { id: number; type: string; props: Record<string, any> }[];
|
| 365 |
+
dependencies: {
|
| 366 |
+
id: number;
|
| 367 |
+
api_name?: string | null;
|
| 368 |
+
inputs: number[];
|
| 369 |
+
outputs: number[];
|
| 370 |
+
}[];
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
function restore_run_impl(config: ReplayTarget, run: StoredRun): boolean {
|
| 374 |
+
const dependency = config.dependencies.find(
|
| 375 |
+
(item) =>
|
| 376 |
+
item.id === run.fn_index ||
|
| 377 |
+
(typeof item.api_name === "string" &&
|
| 378 |
+
`/${item.api_name.replace(/^\//, "")}` === run.api_name)
|
| 379 |
+
);
|
| 380 |
+
if (!dependency) return false;
|
| 381 |
+
|
| 382 |
+
const inputs = Array.isArray(run.inputs)
|
| 383 |
+
? run.inputs
|
| 384 |
+
: Object.values((run.inputs ?? {}) as Record<string, unknown>);
|
| 385 |
+
const outputs = Array.isArray(run.outputs)
|
| 386 |
+
? run.outputs
|
| 387 |
+
: run.outputs === null || run.outputs === undefined
|
| 388 |
+
? []
|
| 389 |
+
: [run.outputs];
|
| 390 |
+
|
| 391 |
+
const restore = (ids: number[], saved: unknown[]): void => {
|
| 392 |
+
for (const [index, id] of ids.entries()) {
|
| 393 |
+
const component = config.components.find((item) => item.id === id);
|
| 394 |
+
if (!component || index >= saved.length) continue;
|
| 395 |
+
// `gr.State` is held on the server and always saved as null, so
|
| 396 |
+
// writing it back would wipe out the component's real default.
|
| 397 |
+
if (component.type === "state") continue;
|
| 398 |
+
component.props.value = saved[index];
|
| 399 |
+
}
|
| 400 |
+
};
|
| 401 |
+
|
| 402 |
+
restore(dependency.inputs, inputs);
|
| 403 |
+
restore(dependency.outputs, outputs);
|
| 404 |
+
return true;
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
function apply_run_history_replay_impl(
|
| 408 |
+
config: ReplayTarget & RunHistoryScope
|
| 409 |
+
): boolean {
|
| 410 |
+
const run = consume_run_history_replay_impl(config);
|
| 411 |
+
return run ? restore_run_impl(config, run) : false;
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
function start_run_history_impl(options: StartRunOptions): string | null {
|
| 415 |
+
if (read_run_history_storage_impl(options).type === "bucket") return null;
|
| 416 |
+
const key = storage_key(options);
|
| 417 |
+
if (!key) return null;
|
| 418 |
+
|
| 419 |
+
// A new app id means a new key, so clear out the ones left behind before
|
| 420 |
+
// adding to this one.
|
| 421 |
+
prune_apps(key);
|
| 422 |
+
|
| 423 |
+
const run: StoredRun = {
|
| 424 |
+
id: make_id(),
|
| 425 |
+
endpoint: options.endpoint,
|
| 426 |
+
api_name: options.api_name,
|
| 427 |
+
fn_index: options.fn_index,
|
| 428 |
+
page: `${window.location.pathname}${window.location.search}`,
|
| 429 |
+
inputs: clone_for_storage(options.inputs),
|
| 430 |
+
outputs: null,
|
| 431 |
+
...(options.input_components
|
| 432 |
+
? {
|
| 433 |
+
input_components: clone_for_storage(
|
| 434 |
+
options.input_components
|
| 435 |
+
) as (StoredRunComponent | null)[]
|
| 436 |
+
}
|
| 437 |
+
: {}),
|
| 438 |
+
...(options.output_components
|
| 439 |
+
? {
|
| 440 |
+
output_components: clone_for_storage(
|
| 441 |
+
options.output_components
|
| 442 |
+
) as (StoredRunComponent | null)[]
|
| 443 |
+
}
|
| 444 |
+
: {}),
|
| 445 |
+
status: "running",
|
| 446 |
+
started_at: new Date().toISOString()
|
| 447 |
+
};
|
| 448 |
+
write_run_history(options, [run, ...read_run_history_impl(options)]);
|
| 449 |
+
notify_run_history_change();
|
| 450 |
+
return run.id;
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
function update_run_inputs_impl(
|
| 454 |
+
scope: RunHistoryScope | null | undefined,
|
| 455 |
+
id: string | null,
|
| 456 |
+
inputs: unknown
|
| 457 |
+
): void {
|
| 458 |
+
if (!id) return;
|
| 459 |
+
|
| 460 |
+
const runs = read_run_history_impl(scope);
|
| 461 |
+
const run = runs.find((item) => item.id === id);
|
| 462 |
+
if (!run) return;
|
| 463 |
+
run.inputs = clone_for_storage(inputs);
|
| 464 |
+
write_run_history(scope, runs);
|
| 465 |
+
}
|
| 466 |
+
|
| 467 |
+
function update_run_history_impl(
|
| 468 |
+
scope: RunHistoryScope | null | undefined,
|
| 469 |
+
id: string | null,
|
| 470 |
+
event: GradioEvent
|
| 471 |
+
): void {
|
| 472 |
+
if (!id) return;
|
| 473 |
+
|
| 474 |
+
const runs = read_run_history_impl(scope);
|
| 475 |
+
const run = runs.find((item) => item.id === id);
|
| 476 |
+
if (!run) return;
|
| 477 |
+
|
| 478 |
+
let finished = false;
|
| 479 |
+
if (event.type === "data") {
|
| 480 |
+
run.outputs = clone_for_storage(event.data);
|
| 481 |
+
deferred_outputs.set(id, run.outputs);
|
| 482 |
+
} else if (
|
| 483 |
+
event.type === "status" &&
|
| 484 |
+
event.original_msg === "process_starts"
|
| 485 |
+
) {
|
| 486 |
+
mark_process_start(run, event.time);
|
| 487 |
+
} else if (
|
| 488 |
+
event.type === "status" &&
|
| 489 |
+
(event.stage === "generating" || event.stage === "streaming")
|
| 490 |
+
) {
|
| 491 |
+
run.streamed = true;
|
| 492 |
+
} else if (event.type === "status" && event.stage === "complete") {
|
| 493 |
+
run.status = "completed";
|
| 494 |
+
mark_complete(run, event);
|
| 495 |
+
finished = true;
|
| 496 |
+
} else if (event.type === "status" && event.stage === "error") {
|
| 497 |
+
run.status = "failed";
|
| 498 |
+
run.error =
|
| 499 |
+
typeof event.message === "string"
|
| 500 |
+
? event.message
|
| 501 |
+
: JSON.stringify(event.message || "Unknown error");
|
| 502 |
+
mark_complete(run, event);
|
| 503 |
+
finished = true;
|
| 504 |
+
} else {
|
| 505 |
+
// Logs, renders and progress updates change nothing worth saving, and
|
| 506 |
+
// writing serialises every run we hold.
|
| 507 |
+
return;
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
+
if (finished) {
|
| 511 |
+
// Every call re-reads from storage, so a chunk that was held back above is
|
| 512 |
+
// missing from `run`. Put the last one back before this final write.
|
| 513 |
+
if (deferred_outputs.has(id)) run.outputs = deferred_outputs.get(id);
|
| 514 |
+
deferred_outputs.delete(id);
|
| 515 |
+
last_write.delete(id);
|
| 516 |
+
} else if (run.streamed) {
|
| 517 |
+
// A generator emits an event per chunk. Saving each one would stringify
|
| 518 |
+
// the whole history on the main thread over and over, so write at most
|
| 519 |
+
// once an interval and let the run's completion flush the rest.
|
| 520 |
+
const since = Date.now() - (last_write.get(id) ?? 0);
|
| 521 |
+
if (since < STREAM_WRITE_INTERVAL_MS) return;
|
| 522 |
+
last_write.set(id, Date.now());
|
| 523 |
+
deferred_outputs.delete(id);
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
write_run_history(scope, runs);
|
| 527 |
+
}
|
| 528 |
+
|
| 529 |
+
const STREAM_WRITE_INTERVAL_MS = 500;
|
| 530 |
+
/** When each in-flight streamed run was last written. */
|
| 531 |
+
const last_write = new Map<string, number>();
|
| 532 |
+
/** The newest output of a streamed run that has not been written yet. */
|
| 533 |
+
const deferred_outputs = new Map<string, unknown>();
|
| 534 |
+
|
| 535 |
+
function mark_process_start(run: StoredRun, time: Date | undefined): void {
|
| 536 |
+
// The queue tells us when the function actually started, which lets us
|
| 537 |
+
// report a runtime that excludes however long the run sat in the queue.
|
| 538 |
+
if (run.process_started_at) return;
|
| 539 |
+
const started = time || new Date();
|
| 540 |
+
run.process_started_at = started.toISOString();
|
| 541 |
+
run.queued_ms = Math.max(0, started.getTime() - Date.parse(run.started_at));
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
+
function mark_complete(run: StoredRun, event: StatusMessage): void {
|
| 545 |
+
const completed = event.time || new Date();
|
| 546 |
+
run.completed_at = completed.toISOString();
|
| 547 |
+
// `cache_duration` is how long the function took on the server, which the
|
| 548 |
+
// queue reports on every completed run (not just cached ones). A generator
|
| 549 |
+
// reports it per chunk though, so the final value covers only the last one
|
| 550 |
+
// and the elapsed time is the honest number for a streamed run.
|
| 551 |
+
const server_duration =
|
| 552 |
+
!run.streamed &&
|
| 553 |
+
typeof event.cache_duration === "number" &&
|
| 554 |
+
event.cache_duration >= 0
|
| 555 |
+
? event.cache_duration * 1000
|
| 556 |
+
: null;
|
| 557 |
+
run.duration_ms =
|
| 558 |
+
server_duration ??
|
| 559 |
+
Math.max(
|
| 560 |
+
0,
|
| 561 |
+
completed.getTime() - Date.parse(run.process_started_at || run.started_at)
|
| 562 |
+
);
|
| 563 |
+
}
|
| 564 |
+
|
| 565 |
+
// Public API. Each of these is a no-op if anything goes wrong.
|
| 566 |
+
|
| 567 |
+
export function read_run_history(
|
| 568 |
+
scope: RunHistoryScope | null | undefined
|
| 569 |
+
): StoredRun[] {
|
| 570 |
+
return safely(() => read_run_history_impl(scope), []);
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
export function read_run_history_storage(
|
| 574 |
+
scope: RunHistoryScope | null | undefined
|
| 575 |
+
): RunHistoryStorage {
|
| 576 |
+
return safely(() => read_run_history_storage_impl(scope), {
|
| 577 |
+
type: "browser"
|
| 578 |
+
});
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
export function set_run_history_storage(
|
| 582 |
+
scope: RunHistoryScope | null | undefined,
|
| 583 |
+
storage: RunHistoryStorage
|
| 584 |
+
): void {
|
| 585 |
+
safely(() => set_run_history_storage_impl(scope, storage), undefined);
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
export function clear_run_history(
|
| 589 |
+
scope: RunHistoryScope | null | undefined
|
| 590 |
+
): void {
|
| 591 |
+
safely(() => clear_run_history_impl(scope), undefined);
|
| 592 |
+
}
|
| 593 |
+
|
| 594 |
+
export function delete_run_history(
|
| 595 |
+
scope: RunHistoryScope | null | undefined,
|
| 596 |
+
id: string
|
| 597 |
+
): void {
|
| 598 |
+
safely(() => delete_run_history_impl(scope, id), undefined);
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
export function stage_run_history_replay(
|
| 602 |
+
scope: RunHistoryScope | null | undefined,
|
| 603 |
+
run: StoredRun
|
| 604 |
+
): void {
|
| 605 |
+
safely(() => stage_run_history_replay_impl(scope, run), undefined);
|
| 606 |
+
}
|
| 607 |
+
|
| 608 |
+
export function consume_run_history_replay(
|
| 609 |
+
scope: RunHistoryScope | null | undefined
|
| 610 |
+
): StoredRun | null {
|
| 611 |
+
return safely(() => consume_run_history_replay_impl(scope), null);
|
| 612 |
+
}
|
| 613 |
+
|
| 614 |
+
/**
|
| 615 |
+
* Applies the run staged by the history page, if this page load is the one it
|
| 616 |
+
* was staged for. Every entry point that renders an app has to call this, or
|
| 617 |
+
* "Load run" silently does nothing on that entry point.
|
| 618 |
+
*
|
| 619 |
+
* @returns whether a staged run was found and applied.
|
| 620 |
+
*/
|
| 621 |
+
export function apply_run_history_replay(
|
| 622 |
+
config: ReplayTarget & RunHistoryScope
|
| 623 |
+
): boolean {
|
| 624 |
+
return safely(() => apply_run_history_replay_impl(config), false);
|
| 625 |
+
}
|
| 626 |
+
|
| 627 |
+
export function start_run_history(options: StartRunOptions): string | null {
|
| 628 |
+
return safely(() => start_run_history_impl(options), null);
|
| 629 |
+
}
|
| 630 |
+
|
| 631 |
+
export function update_run_inputs(
|
| 632 |
+
scope: RunHistoryScope | null | undefined,
|
| 633 |
+
id: string | null,
|
| 634 |
+
inputs: unknown
|
| 635 |
+
): void {
|
| 636 |
+
safely(() => update_run_inputs_impl(scope, id, inputs), undefined);
|
| 637 |
+
}
|
| 638 |
+
|
| 639 |
+
export function update_run_history(
|
| 640 |
+
scope: RunHistoryScope | null | undefined,
|
| 641 |
+
id: string | null,
|
| 642 |
+
event: GradioEvent
|
| 643 |
+
): void {
|
| 644 |
+
safely(() => update_run_history_impl(scope, id, event), undefined);
|
| 645 |
+
}
|
| 646 |
+
|
| 647 |
+
export function on_run_history_change(listener: () => void): () => void {
|
| 648 |
+
return safely(
|
| 649 |
+
() => on_run_history_change_impl(() => safely(listener, undefined)),
|
| 650 |
+
() => {}
|
| 651 |
+
);
|
| 652 |
+
}
|
6.29.1/client/src/utils/stream.ts
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { BROKEN_CONNECTION_MSG, SSE_URL } from "../constants";
|
| 2 |
+
import type { Client } from "../client";
|
| 3 |
+
import { stream } from "fetch-event-stream";
|
| 4 |
+
|
| 5 |
+
export async function open_stream(this: Client): Promise<void> {
|
| 6 |
+
let {
|
| 7 |
+
event_callbacks,
|
| 8 |
+
unclosed_events,
|
| 9 |
+
pending_stream_messages,
|
| 10 |
+
stream_status,
|
| 11 |
+
config,
|
| 12 |
+
jwt
|
| 13 |
+
} = this;
|
| 14 |
+
|
| 15 |
+
const that = this;
|
| 16 |
+
|
| 17 |
+
if (!config) {
|
| 18 |
+
throw new Error("Could not resolve app config");
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
stream_status.open = true;
|
| 22 |
+
|
| 23 |
+
let stream: EventSource | null = null;
|
| 24 |
+
let params = new URLSearchParams({
|
| 25 |
+
session_hash: this.session_hash
|
| 26 |
+
}).toString();
|
| 27 |
+
|
| 28 |
+
let url = new URL(`${config.root}${this.api_prefix}/${SSE_URL}?${params}`);
|
| 29 |
+
|
| 30 |
+
if (jwt) {
|
| 31 |
+
url.searchParams.set("__sign", jwt);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
stream = this.stream(url);
|
| 35 |
+
|
| 36 |
+
if (!stream) {
|
| 37 |
+
console.warn("Cannot connect to SSE endpoint: " + url.toString());
|
| 38 |
+
return;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
stream.onmessage = async function (event: MessageEvent) {
|
| 42 |
+
let _data = JSON.parse(event.data);
|
| 43 |
+
if (_data.msg === "close_stream") {
|
| 44 |
+
close_stream(stream_status, that.abort_controller);
|
| 45 |
+
return;
|
| 46 |
+
}
|
| 47 |
+
const event_id = _data.event_id;
|
| 48 |
+
if (!event_id) {
|
| 49 |
+
await Promise.all(
|
| 50 |
+
Object.keys(event_callbacks).map((event_id) =>
|
| 51 |
+
event_callbacks[event_id](_data)
|
| 52 |
+
)
|
| 53 |
+
);
|
| 54 |
+
} else if (event_callbacks[event_id] && config) {
|
| 55 |
+
if (
|
| 56 |
+
_data.msg === "process_completed" &&
|
| 57 |
+
["sse", "sse_v1", "sse_v2", "sse_v2.1", "sse_v3"].includes(
|
| 58 |
+
config.protocol
|
| 59 |
+
)
|
| 60 |
+
) {
|
| 61 |
+
unclosed_events.delete(event_id);
|
| 62 |
+
}
|
| 63 |
+
let fn: (data: any) => void = event_callbacks[event_id];
|
| 64 |
+
|
| 65 |
+
if (
|
| 66 |
+
typeof window !== "undefined" &&
|
| 67 |
+
typeof document !== "undefined" &&
|
| 68 |
+
document.visibilityState !== "hidden"
|
| 69 |
+
) {
|
| 70 |
+
// Put the event at the end of the event loop so the browser can refresh
|
| 71 |
+
// between callbacks and not freeze during quick generations. Hidden tabs
|
| 72 |
+
// throttle timers, so process those messages immediately instead.
|
| 73 |
+
setTimeout(fn, 0, _data); // See https://github.com/gradio-app/gradio/pull/7055
|
| 74 |
+
} else {
|
| 75 |
+
fn(_data);
|
| 76 |
+
}
|
| 77 |
+
} else {
|
| 78 |
+
if (!pending_stream_messages[event_id]) {
|
| 79 |
+
pending_stream_messages[event_id] = [];
|
| 80 |
+
}
|
| 81 |
+
pending_stream_messages[event_id].push(_data);
|
| 82 |
+
}
|
| 83 |
+
};
|
| 84 |
+
stream.onerror = async function (e) {
|
| 85 |
+
console.error(e);
|
| 86 |
+
await Promise.all(
|
| 87 |
+
Object.keys(event_callbacks).map((event_id) =>
|
| 88 |
+
event_callbacks[event_id]({
|
| 89 |
+
msg: "broken_connection",
|
| 90 |
+
message: BROKEN_CONNECTION_MSG
|
| 91 |
+
})
|
| 92 |
+
)
|
| 93 |
+
);
|
| 94 |
+
};
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
export function close_stream(
|
| 98 |
+
stream_status: { open: boolean },
|
| 99 |
+
abort_controller: AbortController | null
|
| 100 |
+
): void {
|
| 101 |
+
if (stream_status) {
|
| 102 |
+
stream_status.open = false;
|
| 103 |
+
abort_controller?.abort();
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
export function apply_diff_stream(
|
| 108 |
+
pending_diff_streams: Record<string, any[][]>,
|
| 109 |
+
event_id: string,
|
| 110 |
+
data: any
|
| 111 |
+
): void {
|
| 112 |
+
let is_first_generation = !pending_diff_streams[event_id];
|
| 113 |
+
if (is_first_generation) {
|
| 114 |
+
pending_diff_streams[event_id] = [];
|
| 115 |
+
data.data.forEach((value: any, i: number) => {
|
| 116 |
+
pending_diff_streams[event_id][i] = value;
|
| 117 |
+
});
|
| 118 |
+
} else {
|
| 119 |
+
data.data.forEach((value: any, i: number) => {
|
| 120 |
+
// A new output can appear mid-stream if the app was hot-reloaded
|
| 121 |
+
// while a generator was running; such outputs are diffed against
|
| 122 |
+
// null on the server, so start from null when we haven't seen it.
|
| 123 |
+
const prev =
|
| 124 |
+
i < pending_diff_streams[event_id].length
|
| 125 |
+
? pending_diff_streams[event_id][i]
|
| 126 |
+
: null;
|
| 127 |
+
let new_data = apply_diff(prev, value);
|
| 128 |
+
pending_diff_streams[event_id][i] = new_data;
|
| 129 |
+
data.data[i] = new_data;
|
| 130 |
+
});
|
| 131 |
+
}
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
export function apply_diff(
|
| 135 |
+
obj: any,
|
| 136 |
+
diff: [string, (number | string)[], any][]
|
| 137 |
+
): any {
|
| 138 |
+
diff.forEach(([action, path, value]) => {
|
| 139 |
+
obj = apply_edit(obj, path, action, value);
|
| 140 |
+
});
|
| 141 |
+
|
| 142 |
+
return obj;
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
function apply_edit(
|
| 146 |
+
target: any,
|
| 147 |
+
path: (number | string)[],
|
| 148 |
+
action: string,
|
| 149 |
+
value: any
|
| 150 |
+
): any {
|
| 151 |
+
if (path.length === 0) {
|
| 152 |
+
if (action === "replace") {
|
| 153 |
+
return value;
|
| 154 |
+
} else if (action === "append") {
|
| 155 |
+
return target + value;
|
| 156 |
+
}
|
| 157 |
+
throw new Error(`Unsupported action: ${action}`);
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
let current = target;
|
| 161 |
+
for (let i = 0; i < path.length - 1; i++) {
|
| 162 |
+
current = current[path[i]];
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
const last_path = path[path.length - 1];
|
| 166 |
+
switch (action) {
|
| 167 |
+
case "replace":
|
| 168 |
+
current[last_path] = value;
|
| 169 |
+
break;
|
| 170 |
+
case "append":
|
| 171 |
+
current[last_path] += value;
|
| 172 |
+
break;
|
| 173 |
+
case "add":
|
| 174 |
+
if (Array.isArray(current)) {
|
| 175 |
+
current.splice(Number(last_path), 0, value);
|
| 176 |
+
} else {
|
| 177 |
+
current[last_path] = value;
|
| 178 |
+
}
|
| 179 |
+
break;
|
| 180 |
+
case "delete":
|
| 181 |
+
if (Array.isArray(current)) {
|
| 182 |
+
current.splice(Number(last_path), 1);
|
| 183 |
+
} else {
|
| 184 |
+
delete current[last_path];
|
| 185 |
+
}
|
| 186 |
+
break;
|
| 187 |
+
default:
|
| 188 |
+
throw new Error(`Unknown action: ${action}`);
|
| 189 |
+
}
|
| 190 |
+
return target;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
export function readable_stream(
|
| 194 |
+
input: RequestInfo | URL,
|
| 195 |
+
init: RequestInit = {}
|
| 196 |
+
): EventSource {
|
| 197 |
+
const instance: EventSource & { readyState: number } = {
|
| 198 |
+
close: () => {
|
| 199 |
+
console.warn("Method not implemented.");
|
| 200 |
+
},
|
| 201 |
+
onerror: null,
|
| 202 |
+
onmessage: null,
|
| 203 |
+
onopen: null,
|
| 204 |
+
readyState: 0,
|
| 205 |
+
url: input.toString(),
|
| 206 |
+
withCredentials: false,
|
| 207 |
+
CONNECTING: 0,
|
| 208 |
+
OPEN: 1,
|
| 209 |
+
CLOSED: 2,
|
| 210 |
+
addEventListener: () => {
|
| 211 |
+
throw new Error("Method not implemented.");
|
| 212 |
+
},
|
| 213 |
+
dispatchEvent: () => {
|
| 214 |
+
throw new Error("Method not implemented.");
|
| 215 |
+
},
|
| 216 |
+
removeEventListener: () => {
|
| 217 |
+
throw new Error("Method not implemented.");
|
| 218 |
+
}
|
| 219 |
+
};
|
| 220 |
+
|
| 221 |
+
stream(input, init)
|
| 222 |
+
.then(async (res) => {
|
| 223 |
+
instance.readyState = instance.OPEN;
|
| 224 |
+
try {
|
| 225 |
+
for await (const chunk of res) {
|
| 226 |
+
//@ts-ignore
|
| 227 |
+
instance.onmessage && instance.onmessage(chunk);
|
| 228 |
+
}
|
| 229 |
+
instance.readyState = instance.CLOSED;
|
| 230 |
+
} catch (e) {
|
| 231 |
+
instance.onerror && instance.onerror(e as Event);
|
| 232 |
+
instance.readyState = instance.CLOSED;
|
| 233 |
+
}
|
| 234 |
+
})
|
| 235 |
+
.catch((e) => {
|
| 236 |
+
if ((e as Error)?.name !== "AbortError") {
|
| 237 |
+
console.error(e);
|
| 238 |
+
}
|
| 239 |
+
instance.onerror && instance.onerror(e as Event);
|
| 240 |
+
instance.readyState = instance.CLOSED;
|
| 241 |
+
});
|
| 242 |
+
|
| 243 |
+
return instance as EventSource;
|
| 244 |
+
}
|
6.29.1/client/src/utils/submit.ts
ADDED
|
@@ -0,0 +1,880 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type {
|
| 2 |
+
Status,
|
| 3 |
+
Payload,
|
| 4 |
+
GradioEvent,
|
| 5 |
+
JsApiData,
|
| 6 |
+
EndpointInfo,
|
| 7 |
+
ApiInfo,
|
| 8 |
+
Config,
|
| 9 |
+
Dependency,
|
| 10 |
+
SubmitIterable
|
| 11 |
+
} from "../types";
|
| 12 |
+
|
| 13 |
+
import {
|
| 14 |
+
skip_queue,
|
| 15 |
+
post_message,
|
| 16 |
+
handle_payload,
|
| 17 |
+
sign_file_urls
|
| 18 |
+
} from "../helpers/data";
|
| 19 |
+
import { get_zerogpu_origin } from "../helpers/zerogpu";
|
| 20 |
+
import {
|
| 21 |
+
handle_message,
|
| 22 |
+
map_data_to_params,
|
| 23 |
+
process_endpoint
|
| 24 |
+
} from "../helpers/api_info";
|
| 25 |
+
import {
|
| 26 |
+
BROKEN_CONNECTION_MSG,
|
| 27 |
+
NO_API_INFO_MSG,
|
| 28 |
+
QUEUE_FULL_MSG,
|
| 29 |
+
SSE_URL,
|
| 30 |
+
SSE_DATA_URL,
|
| 31 |
+
RESET_URL,
|
| 32 |
+
CANCEL_URL,
|
| 33 |
+
WS_PROTOCOL_MSG
|
| 34 |
+
} from "../constants";
|
| 35 |
+
import { apply_diff_stream, close_stream } from "./stream";
|
| 36 |
+
import { Client } from "../client";
|
| 37 |
+
import {
|
| 38 |
+
read_run_history_storage,
|
| 39 |
+
start_run_history,
|
| 40 |
+
update_run_history,
|
| 41 |
+
update_run_inputs
|
| 42 |
+
} from "./run_history";
|
| 43 |
+
|
| 44 |
+
export function submit(
|
| 45 |
+
this: Client,
|
| 46 |
+
endpoint: string | number,
|
| 47 |
+
data: unknown[] | Record<string, unknown> = {},
|
| 48 |
+
event_data?: unknown,
|
| 49 |
+
trigger_id?: number | null,
|
| 50 |
+
all_events?: boolean,
|
| 51 |
+
additional_headers?: Record<string, string>
|
| 52 |
+
): SubmitIterable<GradioEvent> {
|
| 53 |
+
try {
|
| 54 |
+
const { token } = this.options;
|
| 55 |
+
const {
|
| 56 |
+
fetch,
|
| 57 |
+
app_reference,
|
| 58 |
+
config,
|
| 59 |
+
session_hash,
|
| 60 |
+
api_info,
|
| 61 |
+
api_map,
|
| 62 |
+
stream_status,
|
| 63 |
+
pending_stream_messages,
|
| 64 |
+
pending_diff_streams,
|
| 65 |
+
event_callbacks,
|
| 66 |
+
unclosed_events,
|
| 67 |
+
post_data,
|
| 68 |
+
options,
|
| 69 |
+
api_prefix
|
| 70 |
+
} = this;
|
| 71 |
+
|
| 72 |
+
const base_headers = additional_headers || { "x-gradio-user": "api" };
|
| 73 |
+
|
| 74 |
+
const that = this;
|
| 75 |
+
|
| 76 |
+
if (!api_info) throw new Error(NO_API_INFO_MSG);
|
| 77 |
+
if (!config) throw new Error("Could not resolve app config");
|
| 78 |
+
const root = config.root;
|
| 79 |
+
|
| 80 |
+
this.open_heartbeat();
|
| 81 |
+
|
| 82 |
+
let { fn_index, endpoint_info, dependency } = get_endpoint_info(
|
| 83 |
+
api_info,
|
| 84 |
+
endpoint,
|
| 85 |
+
api_map,
|
| 86 |
+
config
|
| 87 |
+
);
|
| 88 |
+
|
| 89 |
+
let resolved_data = map_data_to_params(data, endpoint_info);
|
| 90 |
+
let protocol = config.protocol ?? "ws";
|
| 91 |
+
if (protocol === "ws") {
|
| 92 |
+
throw new Error(WS_PROTOCOL_MSG);
|
| 93 |
+
}
|
| 94 |
+
const history_endpoint =
|
| 95 |
+
typeof dependency.api_name === "string"
|
| 96 |
+
? `/${dependency.api_name}`
|
| 97 |
+
: endpoint;
|
| 98 |
+
const history_api_name =
|
| 99 |
+
typeof dependency.api_name === "string"
|
| 100 |
+
? `/${dependency.api_name}`
|
| 101 |
+
: `Function ${fn_index}`;
|
| 102 |
+
// Kept index-aligned with the stored payloads (null for components we
|
| 103 |
+
// cannot resolve) so every saved value stays matched to its component.
|
| 104 |
+
const component_metadata = (id: number) => {
|
| 105 |
+
const component = config.components.find((item) => item.id === id);
|
| 106 |
+
if (!component) return null;
|
| 107 |
+
return {
|
| 108 |
+
type: component.type,
|
| 109 |
+
component_class_id: component.component_class_id,
|
| 110 |
+
props: component.props
|
| 111 |
+
};
|
| 112 |
+
};
|
| 113 |
+
// The run history covers the same endpoints the API page documents, which
|
| 114 |
+
// it selects with exactly this predicate (see `ApiDocs.svelte`). That also
|
| 115 |
+
// keeps out the dependencies Gradio wires up for itself, since example
|
| 116 |
+
// loading, flagging and clear buttons are all "undocumented" or "private"
|
| 117 |
+
// and some of them fire on page load. The trade is that a component whose
|
| 118 |
+
// UI submits through an undocumented dependency — `gr.ChatInterface` does
|
| 119 |
+
// — records nothing for its in-app use.
|
| 120 |
+
const is_documented_endpoint = dependency.api_visibility === "public";
|
| 121 |
+
// Either side may opt out: the app for everyone who uses it, and this
|
| 122 |
+
// caller for itself.
|
| 123 |
+
const history_enabled =
|
| 124 |
+
config.run_history !== false && this.options.record_history !== false;
|
| 125 |
+
const history_scope = { app_id: config.app_id, username: config.username };
|
| 126 |
+
const history_storage = read_run_history_storage(history_scope);
|
| 127 |
+
const addt_headers = {
|
| 128 |
+
...base_headers,
|
| 129 |
+
...(history_enabled && history_storage.type === "bucket"
|
| 130 |
+
? { "x-gradio-history-bucket": history_storage.bucket_id }
|
| 131 |
+
: {})
|
| 132 |
+
};
|
| 133 |
+
const history_run_id =
|
| 134 |
+
!history_enabled || !is_documented_endpoint
|
| 135 |
+
? null
|
| 136 |
+
: start_run_history({
|
| 137 |
+
...history_scope,
|
| 138 |
+
endpoint: history_endpoint,
|
| 139 |
+
api_name: history_api_name,
|
| 140 |
+
fn_index,
|
| 141 |
+
// Aligned to `dependency.inputs` the same way the submitted payload
|
| 142 |
+
// is, so this placeholder matches the components until the uploaded
|
| 143 |
+
// files are swapped in by `update_run_inputs` below.
|
| 144 |
+
inputs: handle_payload(
|
| 145 |
+
resolved_data,
|
| 146 |
+
dependency,
|
| 147 |
+
config.components,
|
| 148 |
+
"input",
|
| 149 |
+
true
|
| 150 |
+
),
|
| 151 |
+
input_components: dependency.inputs.map(component_metadata),
|
| 152 |
+
output_components: dependency.outputs.map(component_metadata)
|
| 153 |
+
});
|
| 154 |
+
|
| 155 |
+
let stream: EventSource | null;
|
| 156 |
+
let event_id_final = "";
|
| 157 |
+
let event_id_cb: () => string = () => event_id_final;
|
| 158 |
+
|
| 159 |
+
const _endpoint = typeof endpoint === "number" ? "/predict" : endpoint;
|
| 160 |
+
let payload: Payload;
|
| 161 |
+
let event_id: string | null = null;
|
| 162 |
+
let complete: Status | undefined | false = false;
|
| 163 |
+
let last_status: Record<string, Status["stage"]> = {};
|
| 164 |
+
let url_params =
|
| 165 |
+
typeof window !== "undefined" && typeof document !== "undefined"
|
| 166 |
+
? new URLSearchParams(window.location.search).toString()
|
| 167 |
+
: "";
|
| 168 |
+
|
| 169 |
+
const events_to_publish =
|
| 170 |
+
options?.events?.reduce(
|
| 171 |
+
(acc, event) => {
|
| 172 |
+
acc[event] = true;
|
| 173 |
+
return acc;
|
| 174 |
+
},
|
| 175 |
+
{} as Record<string, boolean>
|
| 176 |
+
) || {};
|
| 177 |
+
|
| 178 |
+
// event subscription methods
|
| 179 |
+
function fire_event(event: GradioEvent): void {
|
| 180 |
+
update_run_history(history_scope, history_run_id, event);
|
| 181 |
+
if (event.type === "data" || event.type === "render") {
|
| 182 |
+
sign_file_urls(event.data, root, api_prefix, that.jwt);
|
| 183 |
+
}
|
| 184 |
+
if (all_events || events_to_publish[event.type]) {
|
| 185 |
+
push_event(event);
|
| 186 |
+
}
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
async function cancel(): Promise<void> {
|
| 190 |
+
let reset_request = {};
|
| 191 |
+
let cancel_request = {};
|
| 192 |
+
reset_request = { event_id };
|
| 193 |
+
cancel_request = { event_id, session_hash, fn_index };
|
| 194 |
+
|
| 195 |
+
try {
|
| 196 |
+
if (!config) {
|
| 197 |
+
throw new Error("Could not resolve app config");
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
if ("event_id" in cancel_request) {
|
| 201 |
+
await fetch(`${config.root}${api_prefix}/${CANCEL_URL}`, {
|
| 202 |
+
headers: { "Content-Type": "application/json" },
|
| 203 |
+
method: "POST",
|
| 204 |
+
body: JSON.stringify(cancel_request)
|
| 205 |
+
});
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
await fetch(`${config.root}${api_prefix}/${RESET_URL}`, {
|
| 209 |
+
headers: { "Content-Type": "application/json" },
|
| 210 |
+
method: "POST",
|
| 211 |
+
body: JSON.stringify(reset_request)
|
| 212 |
+
});
|
| 213 |
+
} catch (e) {
|
| 214 |
+
console.warn(
|
| 215 |
+
"The `/reset` endpoint could not be called. Subsequent endpoint results may be unreliable."
|
| 216 |
+
);
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
const resolve_heartbeat = async (config: Config): Promise<void> => {
|
| 221 |
+
await this._resolve_heartbeat(config);
|
| 222 |
+
};
|
| 223 |
+
|
| 224 |
+
async function handle_render_config(render_config: any): Promise<void> {
|
| 225 |
+
if (!config) return;
|
| 226 |
+
let render_id: number = render_config.render_id;
|
| 227 |
+
config.components = [
|
| 228 |
+
...config.components.filter((c) => c.props.rendered_in !== render_id),
|
| 229 |
+
...render_config.components
|
| 230 |
+
];
|
| 231 |
+
config.dependencies = [
|
| 232 |
+
...config.dependencies.filter((d) => d.rendered_in !== render_id),
|
| 233 |
+
...render_config.dependencies
|
| 234 |
+
];
|
| 235 |
+
const any_state = config.components.some((c) => c.type === "state");
|
| 236 |
+
const any_unload = config.dependencies.some((d) =>
|
| 237 |
+
d.targets.some((t) => t[1] === "unload")
|
| 238 |
+
);
|
| 239 |
+
config.connect_heartbeat = any_state || any_unload;
|
| 240 |
+
await resolve_heartbeat(config);
|
| 241 |
+
fire_event({
|
| 242 |
+
type: "render",
|
| 243 |
+
data: render_config,
|
| 244 |
+
endpoint: _endpoint,
|
| 245 |
+
fn_index
|
| 246 |
+
});
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
const job = this.handle_blob(
|
| 250 |
+
config.root,
|
| 251 |
+
resolved_data,
|
| 252 |
+
endpoint_info
|
| 253 |
+
).then(async (_payload) => {
|
| 254 |
+
let input_data = handle_payload(
|
| 255 |
+
_payload,
|
| 256 |
+
dependency,
|
| 257 |
+
config.components,
|
| 258 |
+
"input",
|
| 259 |
+
true
|
| 260 |
+
);
|
| 261 |
+
update_run_inputs(history_scope, history_run_id, input_data || []);
|
| 262 |
+
payload = {
|
| 263 |
+
data: input_data || [],
|
| 264 |
+
event_data,
|
| 265 |
+
fn_index,
|
| 266 |
+
trigger_id,
|
| 267 |
+
...(options.oauth_token && endpoint_info?.oauth_token
|
| 268 |
+
? { oauth_token: options.oauth_token }
|
| 269 |
+
: {})
|
| 270 |
+
};
|
| 271 |
+
if (skip_queue(fn_index, config)) {
|
| 272 |
+
fire_event({
|
| 273 |
+
type: "status",
|
| 274 |
+
endpoint: _endpoint,
|
| 275 |
+
stage: "pending",
|
| 276 |
+
queue: false,
|
| 277 |
+
fn_index,
|
| 278 |
+
time: new Date()
|
| 279 |
+
});
|
| 280 |
+
|
| 281 |
+
post_data(
|
| 282 |
+
`${config.root}${api_prefix}/run${
|
| 283 |
+
_endpoint.startsWith("/") ? _endpoint : `/${_endpoint}`
|
| 284 |
+
}${url_params ? "?" + url_params : ""}`,
|
| 285 |
+
{
|
| 286 |
+
...payload,
|
| 287 |
+
session_hash
|
| 288 |
+
},
|
| 289 |
+
addt_headers
|
| 290 |
+
)
|
| 291 |
+
.then(async ([output, status_code]: any) => {
|
| 292 |
+
const data = output.data;
|
| 293 |
+
|
| 294 |
+
if (status_code == 200) {
|
| 295 |
+
fire_event({
|
| 296 |
+
type: "data",
|
| 297 |
+
endpoint: _endpoint,
|
| 298 |
+
fn_index,
|
| 299 |
+
data: handle_payload(
|
| 300 |
+
data,
|
| 301 |
+
dependency,
|
| 302 |
+
config.components,
|
| 303 |
+
"output",
|
| 304 |
+
options.with_null_state
|
| 305 |
+
),
|
| 306 |
+
time: new Date(),
|
| 307 |
+
event_data,
|
| 308 |
+
trigger_id
|
| 309 |
+
});
|
| 310 |
+
if (output.render_config) {
|
| 311 |
+
await handle_render_config(output.render_config);
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
fire_event({
|
| 315 |
+
type: "status",
|
| 316 |
+
endpoint: _endpoint,
|
| 317 |
+
fn_index,
|
| 318 |
+
stage: "complete",
|
| 319 |
+
eta: output.average_duration,
|
| 320 |
+
queue: false,
|
| 321 |
+
time: new Date()
|
| 322 |
+
});
|
| 323 |
+
} else {
|
| 324 |
+
const is_connection_error =
|
| 325 |
+
output?.error === BROKEN_CONNECTION_MSG;
|
| 326 |
+
fire_event({
|
| 327 |
+
type: "status",
|
| 328 |
+
stage: "error",
|
| 329 |
+
endpoint: _endpoint,
|
| 330 |
+
fn_index,
|
| 331 |
+
message: output.error,
|
| 332 |
+
broken: is_connection_error,
|
| 333 |
+
queue: false,
|
| 334 |
+
time: new Date()
|
| 335 |
+
});
|
| 336 |
+
}
|
| 337 |
+
})
|
| 338 |
+
.catch((e) => {
|
| 339 |
+
fire_event({
|
| 340 |
+
type: "status",
|
| 341 |
+
stage: "error",
|
| 342 |
+
message: e.message,
|
| 343 |
+
endpoint: _endpoint,
|
| 344 |
+
fn_index,
|
| 345 |
+
queue: false,
|
| 346 |
+
time: new Date()
|
| 347 |
+
});
|
| 348 |
+
});
|
| 349 |
+
} else if (protocol == "sse") {
|
| 350 |
+
fire_event({
|
| 351 |
+
type: "status",
|
| 352 |
+
stage: "pending",
|
| 353 |
+
queue: true,
|
| 354 |
+
endpoint: _endpoint,
|
| 355 |
+
fn_index,
|
| 356 |
+
time: new Date()
|
| 357 |
+
});
|
| 358 |
+
var params = new URLSearchParams({
|
| 359 |
+
fn_index: fn_index.toString(),
|
| 360 |
+
session_hash: session_hash
|
| 361 |
+
}).toString();
|
| 362 |
+
let url = new URL(
|
| 363 |
+
`${config.root}${api_prefix}/${SSE_URL}?${
|
| 364 |
+
url_params ? url_params + "&" : ""
|
| 365 |
+
}${params}`
|
| 366 |
+
);
|
| 367 |
+
|
| 368 |
+
if (this.jwt) {
|
| 369 |
+
url.searchParams.set("__sign", this.jwt);
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
stream = this.stream(url);
|
| 373 |
+
|
| 374 |
+
if (!stream) {
|
| 375 |
+
return Promise.reject(
|
| 376 |
+
new Error("Cannot connect to SSE endpoint: " + url.toString())
|
| 377 |
+
);
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
stream.onmessage = async function (event: MessageEvent) {
|
| 381 |
+
const _data = JSON.parse(event.data);
|
| 382 |
+
const { type, status, data } = handle_message(
|
| 383 |
+
_data,
|
| 384 |
+
last_status[fn_index]
|
| 385 |
+
);
|
| 386 |
+
|
| 387 |
+
if (type === "update" && status && !complete) {
|
| 388 |
+
// call 'status' listeners
|
| 389 |
+
fire_event({
|
| 390 |
+
type: "status",
|
| 391 |
+
endpoint: _endpoint,
|
| 392 |
+
fn_index,
|
| 393 |
+
time: new Date(),
|
| 394 |
+
...status
|
| 395 |
+
});
|
| 396 |
+
if (status.stage === "error") {
|
| 397 |
+
stream?.close();
|
| 398 |
+
close();
|
| 399 |
+
}
|
| 400 |
+
} else if (type === "data") {
|
| 401 |
+
let [_, status] = await post_data(
|
| 402 |
+
`${config.root}${api_prefix}/queue/data`,
|
| 403 |
+
{
|
| 404 |
+
...payload,
|
| 405 |
+
session_hash,
|
| 406 |
+
event_id
|
| 407 |
+
},
|
| 408 |
+
addt_headers
|
| 409 |
+
);
|
| 410 |
+
if (status !== 200) {
|
| 411 |
+
fire_event({
|
| 412 |
+
type: "status",
|
| 413 |
+
stage: "error",
|
| 414 |
+
message: BROKEN_CONNECTION_MSG,
|
| 415 |
+
queue: true,
|
| 416 |
+
endpoint: _endpoint,
|
| 417 |
+
fn_index,
|
| 418 |
+
time: new Date()
|
| 419 |
+
});
|
| 420 |
+
stream?.close();
|
| 421 |
+
close();
|
| 422 |
+
}
|
| 423 |
+
} else if (type === "complete") {
|
| 424 |
+
complete = status;
|
| 425 |
+
} else if (type === "log") {
|
| 426 |
+
fire_event({
|
| 427 |
+
type: "log",
|
| 428 |
+
title: data.title,
|
| 429 |
+
log: data.log,
|
| 430 |
+
level: data.level,
|
| 431 |
+
endpoint: _endpoint,
|
| 432 |
+
duration: data.duration,
|
| 433 |
+
visible: data.visible,
|
| 434 |
+
fn_index
|
| 435 |
+
});
|
| 436 |
+
} else if (type === "generating" || type === "streaming") {
|
| 437 |
+
fire_event({
|
| 438 |
+
type: "status",
|
| 439 |
+
time: new Date(),
|
| 440 |
+
...status,
|
| 441 |
+
stage: status?.stage!,
|
| 442 |
+
queue: true,
|
| 443 |
+
endpoint: _endpoint,
|
| 444 |
+
fn_index
|
| 445 |
+
});
|
| 446 |
+
}
|
| 447 |
+
if (data) {
|
| 448 |
+
fire_event({
|
| 449 |
+
type: "data",
|
| 450 |
+
time: new Date(),
|
| 451 |
+
data: handle_payload(
|
| 452 |
+
data.data,
|
| 453 |
+
dependency,
|
| 454 |
+
config.components,
|
| 455 |
+
"output",
|
| 456 |
+
options.with_null_state
|
| 457 |
+
),
|
| 458 |
+
endpoint: _endpoint,
|
| 459 |
+
fn_index,
|
| 460 |
+
event_data,
|
| 461 |
+
trigger_id
|
| 462 |
+
});
|
| 463 |
+
|
| 464 |
+
if (complete) {
|
| 465 |
+
fire_event({
|
| 466 |
+
type: "status",
|
| 467 |
+
time: new Date(),
|
| 468 |
+
...complete,
|
| 469 |
+
stage: status?.stage!,
|
| 470 |
+
queue: true,
|
| 471 |
+
endpoint: _endpoint,
|
| 472 |
+
fn_index
|
| 473 |
+
});
|
| 474 |
+
stream?.close();
|
| 475 |
+
close();
|
| 476 |
+
}
|
| 477 |
+
}
|
| 478 |
+
};
|
| 479 |
+
} else if (
|
| 480 |
+
protocol == "sse_v1" ||
|
| 481 |
+
protocol == "sse_v2" ||
|
| 482 |
+
protocol == "sse_v2.1" ||
|
| 483 |
+
protocol == "sse_v3"
|
| 484 |
+
) {
|
| 485 |
+
// latest API format. v2 introduces sending diffs for intermediate outputs in generative functions, which makes payloads lighter.
|
| 486 |
+
// v3 only closes the stream when the backend sends the close stream message.
|
| 487 |
+
fire_event({
|
| 488 |
+
type: "status",
|
| 489 |
+
stage: "pending",
|
| 490 |
+
queue: true,
|
| 491 |
+
endpoint: _endpoint,
|
| 492 |
+
fn_index,
|
| 493 |
+
time: new Date()
|
| 494 |
+
});
|
| 495 |
+
let hostname = "";
|
| 496 |
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
| 497 |
+
hostname = window?.location?.hostname;
|
| 498 |
+
}
|
| 499 |
+
|
| 500 |
+
const origin = get_zerogpu_origin(hostname);
|
| 501 |
+
|
| 502 |
+
const is_zerogpu_iframe =
|
| 503 |
+
typeof window !== "undefined" &&
|
| 504 |
+
typeof document !== "undefined" &&
|
| 505 |
+
window.parent != window &&
|
| 506 |
+
!!origin &&
|
| 507 |
+
window.supports_zerogpu_headers;
|
| 508 |
+
const zerogpu_auth_promise = is_zerogpu_iframe
|
| 509 |
+
? post_message<Map<string, string>>("zerogpu-headers", origin)
|
| 510 |
+
: Promise.resolve(null);
|
| 511 |
+
const post_data_promise = zerogpu_auth_promise.then((headers) => {
|
| 512 |
+
const combined_headers = { ...addt_headers, ...(headers || {}) };
|
| 513 |
+
return post_data(
|
| 514 |
+
`${config.root}${api_prefix}/${SSE_DATA_URL}?${url_params}`,
|
| 515 |
+
{
|
| 516 |
+
...payload,
|
| 517 |
+
session_hash
|
| 518 |
+
},
|
| 519 |
+
combined_headers
|
| 520 |
+
);
|
| 521 |
+
});
|
| 522 |
+
|
| 523 |
+
return post_data_promise.then(async ([response, status]: any) => {
|
| 524 |
+
if (response.event_id) {
|
| 525 |
+
event_id_final = response.event_id as string;
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
if (status === 503) {
|
| 529 |
+
fire_event({
|
| 530 |
+
type: "status",
|
| 531 |
+
stage: "error",
|
| 532 |
+
message: QUEUE_FULL_MSG,
|
| 533 |
+
queue: true,
|
| 534 |
+
endpoint: _endpoint,
|
| 535 |
+
fn_index,
|
| 536 |
+
time: new Date(),
|
| 537 |
+
visible: true
|
| 538 |
+
});
|
| 539 |
+
close();
|
| 540 |
+
} else if (status === 422) {
|
| 541 |
+
fire_event({
|
| 542 |
+
type: "status",
|
| 543 |
+
stage: "error",
|
| 544 |
+
message: response.detail,
|
| 545 |
+
queue: true,
|
| 546 |
+
endpoint: _endpoint,
|
| 547 |
+
fn_index,
|
| 548 |
+
code: "validation_error",
|
| 549 |
+
time: new Date(),
|
| 550 |
+
visible: true
|
| 551 |
+
});
|
| 552 |
+
close();
|
| 553 |
+
} else if (status !== 200) {
|
| 554 |
+
const is_connection_error =
|
| 555 |
+
response?.error === BROKEN_CONNECTION_MSG;
|
| 556 |
+
fire_event({
|
| 557 |
+
type: "status",
|
| 558 |
+
stage: "error",
|
| 559 |
+
broken: is_connection_error,
|
| 560 |
+
message: is_connection_error
|
| 561 |
+
? BROKEN_CONNECTION_MSG
|
| 562 |
+
: response.detail || response.error,
|
| 563 |
+
queue: true,
|
| 564 |
+
endpoint: _endpoint,
|
| 565 |
+
fn_index,
|
| 566 |
+
time: new Date(),
|
| 567 |
+
visible: true
|
| 568 |
+
});
|
| 569 |
+
close();
|
| 570 |
+
} else {
|
| 571 |
+
event_id = response.event_id as string;
|
| 572 |
+
event_id_final = event_id;
|
| 573 |
+
let callback = async function (_data: object): Promise<void> {
|
| 574 |
+
try {
|
| 575 |
+
const { type, status, data, original_msg } = handle_message(
|
| 576 |
+
_data,
|
| 577 |
+
last_status[fn_index]
|
| 578 |
+
);
|
| 579 |
+
|
| 580 |
+
if (type == "heartbeat") {
|
| 581 |
+
return;
|
| 582 |
+
}
|
| 583 |
+
|
| 584 |
+
if (type === "update" && status && !complete) {
|
| 585 |
+
// call 'status' listeners
|
| 586 |
+
fire_event({
|
| 587 |
+
type: "status",
|
| 588 |
+
endpoint: _endpoint,
|
| 589 |
+
fn_index,
|
| 590 |
+
time: new Date(),
|
| 591 |
+
original_msg: original_msg,
|
| 592 |
+
...status
|
| 593 |
+
});
|
| 594 |
+
} else if (type === "complete") {
|
| 595 |
+
complete = status;
|
| 596 |
+
} else if (
|
| 597 |
+
type == "unexpected_error" ||
|
| 598 |
+
type == "broken_connection"
|
| 599 |
+
) {
|
| 600 |
+
console.error("Unexpected error", status?.message);
|
| 601 |
+
const broken = type === "broken_connection";
|
| 602 |
+
fire_event({
|
| 603 |
+
type: "status",
|
| 604 |
+
stage: "error",
|
| 605 |
+
message: status?.message || "An Unexpected Error Occurred!",
|
| 606 |
+
queue: true,
|
| 607 |
+
endpoint: _endpoint,
|
| 608 |
+
broken,
|
| 609 |
+
session_not_found: status?.session_not_found,
|
| 610 |
+
fn_index,
|
| 611 |
+
time: new Date()
|
| 612 |
+
});
|
| 613 |
+
} else if (type === "log") {
|
| 614 |
+
fire_event({
|
| 615 |
+
type: "log",
|
| 616 |
+
title: data.title,
|
| 617 |
+
log: data.log,
|
| 618 |
+
level: data.level,
|
| 619 |
+
endpoint: _endpoint,
|
| 620 |
+
duration: data.duration,
|
| 621 |
+
visible: data.visible,
|
| 622 |
+
fn_index
|
| 623 |
+
});
|
| 624 |
+
return;
|
| 625 |
+
} else if (type === "generating" || type === "streaming") {
|
| 626 |
+
fire_event({
|
| 627 |
+
type: "status",
|
| 628 |
+
time: new Date(),
|
| 629 |
+
...status,
|
| 630 |
+
stage: status?.stage!,
|
| 631 |
+
queue: true,
|
| 632 |
+
endpoint: _endpoint,
|
| 633 |
+
fn_index
|
| 634 |
+
});
|
| 635 |
+
if (
|
| 636 |
+
data &&
|
| 637 |
+
dependency.connection !== "stream" &&
|
| 638 |
+
["sse_v2", "sse_v2.1", "sse_v3"].includes(protocol)
|
| 639 |
+
) {
|
| 640 |
+
apply_diff_stream(pending_diff_streams, event_id!, data);
|
| 641 |
+
}
|
| 642 |
+
}
|
| 643 |
+
if (data) {
|
| 644 |
+
fire_event({
|
| 645 |
+
type: "data",
|
| 646 |
+
time: new Date(),
|
| 647 |
+
data: handle_payload(
|
| 648 |
+
data.data,
|
| 649 |
+
dependency,
|
| 650 |
+
config.components,
|
| 651 |
+
"output",
|
| 652 |
+
options.with_null_state
|
| 653 |
+
),
|
| 654 |
+
endpoint: _endpoint,
|
| 655 |
+
fn_index
|
| 656 |
+
});
|
| 657 |
+
if (data.render_config) {
|
| 658 |
+
await handle_render_config(data.render_config);
|
| 659 |
+
}
|
| 660 |
+
|
| 661 |
+
if (complete) {
|
| 662 |
+
fire_event({
|
| 663 |
+
type: "status",
|
| 664 |
+
time: new Date(),
|
| 665 |
+
...complete,
|
| 666 |
+
stage: status?.stage!,
|
| 667 |
+
queue: true,
|
| 668 |
+
endpoint: _endpoint,
|
| 669 |
+
fn_index
|
| 670 |
+
});
|
| 671 |
+
close();
|
| 672 |
+
}
|
| 673 |
+
}
|
| 674 |
+
|
| 675 |
+
if (status?.stage === "complete" || status?.stage === "error") {
|
| 676 |
+
if (event_callbacks[event_id!]) {
|
| 677 |
+
delete event_callbacks[event_id!];
|
| 678 |
+
}
|
| 679 |
+
if (event_id! in pending_diff_streams) {
|
| 680 |
+
delete pending_diff_streams[event_id!];
|
| 681 |
+
}
|
| 682 |
+
close();
|
| 683 |
+
}
|
| 684 |
+
} catch (e) {
|
| 685 |
+
console.error("Unexpected client exception", e);
|
| 686 |
+
fire_event({
|
| 687 |
+
type: "status",
|
| 688 |
+
stage: "error",
|
| 689 |
+
message: "An Unexpected Error Occurred!",
|
| 690 |
+
queue: true,
|
| 691 |
+
endpoint: _endpoint,
|
| 692 |
+
fn_index,
|
| 693 |
+
time: new Date()
|
| 694 |
+
});
|
| 695 |
+
if (["sse_v2", "sse_v2.1", "sse_v3"].includes(protocol)) {
|
| 696 |
+
close_stream(stream_status, that.abort_controller);
|
| 697 |
+
stream_status.open = false;
|
| 698 |
+
close();
|
| 699 |
+
}
|
| 700 |
+
}
|
| 701 |
+
};
|
| 702 |
+
|
| 703 |
+
if (event_id in pending_stream_messages) {
|
| 704 |
+
pending_stream_messages[event_id].forEach((msg) => callback(msg));
|
| 705 |
+
delete pending_stream_messages[event_id];
|
| 706 |
+
}
|
| 707 |
+
// @ts-ignore
|
| 708 |
+
event_callbacks[event_id] = callback;
|
| 709 |
+
unclosed_events.add(event_id);
|
| 710 |
+
if (!stream_status.open) {
|
| 711 |
+
await this.open_stream();
|
| 712 |
+
}
|
| 713 |
+
}
|
| 714 |
+
});
|
| 715 |
+
}
|
| 716 |
+
});
|
| 717 |
+
|
| 718 |
+
// Surface internal failures (e.g. malformed payloads or configs) as an
|
| 719 |
+
// error event instead of leaving the returned iterator hanging forever
|
| 720 |
+
// with an unhandled promise rejection.
|
| 721 |
+
job.catch((e) => {
|
| 722 |
+
fire_event({
|
| 723 |
+
type: "status",
|
| 724 |
+
stage: "error",
|
| 725 |
+
message: e instanceof Error ? e.message : String(e),
|
| 726 |
+
queue: !skip_queue(fn_index, config),
|
| 727 |
+
endpoint: _endpoint,
|
| 728 |
+
fn_index,
|
| 729 |
+
time: new Date()
|
| 730 |
+
});
|
| 731 |
+
close();
|
| 732 |
+
});
|
| 733 |
+
|
| 734 |
+
let done = false;
|
| 735 |
+
const values: (IteratorResult<GradioEvent> | PromiseLike<never>)[] = [];
|
| 736 |
+
const resolvers: ((
|
| 737 |
+
value: IteratorResult<GradioEvent> | PromiseLike<never>
|
| 738 |
+
) => void)[] = [];
|
| 739 |
+
|
| 740 |
+
function close(): void {
|
| 741 |
+
done = true;
|
| 742 |
+
while (resolvers.length > 0)
|
| 743 |
+
(resolvers.shift() as (typeof resolvers)[0])({
|
| 744 |
+
value: undefined,
|
| 745 |
+
done: true
|
| 746 |
+
});
|
| 747 |
+
}
|
| 748 |
+
|
| 749 |
+
function push(
|
| 750 |
+
data: { value: GradioEvent; done: boolean } | PromiseLike<never>
|
| 751 |
+
): void {
|
| 752 |
+
if (resolvers.length > 0) {
|
| 753 |
+
(resolvers.shift() as (typeof resolvers)[0])(data);
|
| 754 |
+
} else {
|
| 755 |
+
values.push(data);
|
| 756 |
+
}
|
| 757 |
+
}
|
| 758 |
+
|
| 759 |
+
function push_error(error: unknown): void {
|
| 760 |
+
push(thenable_reject(error));
|
| 761 |
+
close();
|
| 762 |
+
}
|
| 763 |
+
|
| 764 |
+
function push_event(event: GradioEvent): void {
|
| 765 |
+
push({ value: event, done: false });
|
| 766 |
+
}
|
| 767 |
+
|
| 768 |
+
function next(): Promise<IteratorResult<GradioEvent, unknown>> {
|
| 769 |
+
if (values.length > 0) {
|
| 770 |
+
return Promise.resolve(values.shift() as (typeof values)[0]);
|
| 771 |
+
}
|
| 772 |
+
if (done) {
|
| 773 |
+
return Promise.resolve({ value: undefined, done: true });
|
| 774 |
+
}
|
| 775 |
+
return new Promise((resolve) => resolvers.push(resolve));
|
| 776 |
+
}
|
| 777 |
+
|
| 778 |
+
// The event id is only known once queue/join has responded.
|
| 779 |
+
const post_to_event = (suffix: string, body: unknown): void => {
|
| 780 |
+
job.then(
|
| 781 |
+
() => {
|
| 782 |
+
if (!event_id_final) return;
|
| 783 |
+
this.post_data(
|
| 784 |
+
`${config.root}${api_prefix}/stream/${event_id_final}${suffix}`,
|
| 785 |
+
body
|
| 786 |
+
);
|
| 787 |
+
},
|
| 788 |
+
() => {}
|
| 789 |
+
);
|
| 790 |
+
};
|
| 791 |
+
|
| 792 |
+
const iterator: SubmitIterable<GradioEvent> = {
|
| 793 |
+
[Symbol.asyncIterator]: () => iterator,
|
| 794 |
+
next,
|
| 795 |
+
throw: async (value: unknown) => {
|
| 796 |
+
push_error(value);
|
| 797 |
+
return next();
|
| 798 |
+
},
|
| 799 |
+
return: async () => {
|
| 800 |
+
close();
|
| 801 |
+
return { value: undefined, done: true as const };
|
| 802 |
+
},
|
| 803 |
+
cancel,
|
| 804 |
+
send_chunk: (payload: Record<string, unknown>) => {
|
| 805 |
+
post_to_event("", { ...payload, session_hash: this.session_hash });
|
| 806 |
+
},
|
| 807 |
+
close_stream: () => {
|
| 808 |
+
close();
|
| 809 |
+
post_to_event("/close", {});
|
| 810 |
+
},
|
| 811 |
+
event_id: () => event_id_final,
|
| 812 |
+
wait_for_id: async () => {
|
| 813 |
+
await job;
|
| 814 |
+
return event_id;
|
| 815 |
+
}
|
| 816 |
+
};
|
| 817 |
+
|
| 818 |
+
return iterator;
|
| 819 |
+
} catch (error) {
|
| 820 |
+
console.error("Submit function encountered an error:", error);
|
| 821 |
+
throw error;
|
| 822 |
+
}
|
| 823 |
+
}
|
| 824 |
+
|
| 825 |
+
function thenable_reject<T>(error: T): PromiseLike<never> {
|
| 826 |
+
return {
|
| 827 |
+
then: (
|
| 828 |
+
resolve: (value: never) => PromiseLike<never>,
|
| 829 |
+
reject: (error: T) => PromiseLike<never>
|
| 830 |
+
) => reject(error)
|
| 831 |
+
};
|
| 832 |
+
}
|
| 833 |
+
|
| 834 |
+
function get_endpoint_info(
|
| 835 |
+
api_info: ApiInfo<JsApiData>,
|
| 836 |
+
endpoint: string | number,
|
| 837 |
+
api_map: Record<string, number>,
|
| 838 |
+
config: Config
|
| 839 |
+
): {
|
| 840 |
+
fn_index: number;
|
| 841 |
+
endpoint_info: EndpointInfo<JsApiData>;
|
| 842 |
+
dependency: Dependency;
|
| 843 |
+
} {
|
| 844 |
+
let fn_index: number;
|
| 845 |
+
let endpoint_info: EndpointInfo<JsApiData>;
|
| 846 |
+
let dependency: Dependency | undefined;
|
| 847 |
+
|
| 848 |
+
if (typeof endpoint === "number") {
|
| 849 |
+
fn_index = endpoint;
|
| 850 |
+
endpoint_info = api_info.unnamed_endpoints[fn_index];
|
| 851 |
+
dependency = config.dependencies.find((dep) => dep.id == endpoint);
|
| 852 |
+
} else {
|
| 853 |
+
const trimmed_endpoint = endpoint.replace(/^\//, "");
|
| 854 |
+
|
| 855 |
+
fn_index = api_map[trimmed_endpoint];
|
| 856 |
+
// named endpoints are keyed with a leading slash in the API info, but
|
| 857 |
+
// accept endpoint names passed without one (e.g. "predict")
|
| 858 |
+
endpoint_info =
|
| 859 |
+
api_info.named_endpoints[endpoint.trim()] ??
|
| 860 |
+
api_info.named_endpoints[`/${trimmed_endpoint}`];
|
| 861 |
+
dependency = config.dependencies.find(
|
| 862 |
+
(dep) => dep.id == api_map[trimmed_endpoint]
|
| 863 |
+
);
|
| 864 |
+
}
|
| 865 |
+
|
| 866 |
+
if (typeof fn_index !== "number" || !dependency) {
|
| 867 |
+
const valid_endpoints = config.dependencies
|
| 868 |
+
.filter((dep) => dep.api_name)
|
| 869 |
+
.map((dep) => `"/${dep.api_name}"`)
|
| 870 |
+
.join(", ");
|
| 871 |
+
throw new Error(
|
| 872 |
+
`No endpoint matching ${JSON.stringify(endpoint)} was found. ` +
|
| 873 |
+
(valid_endpoints
|
| 874 |
+
? `Valid named endpoints are: ${valid_endpoints}. `
|
| 875 |
+
: "This app exposes no named endpoints. ") +
|
| 876 |
+
"An fn_index (number) of an existing dependency can also be used."
|
| 877 |
+
);
|
| 878 |
+
}
|
| 879 |
+
return { fn_index, endpoint_info, dependency };
|
| 880 |
+
}
|
6.29.1/client/src/utils/upload_files.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Client } from "..";
|
| 2 |
+
import { BROKEN_CONNECTION_MSG, UPLOAD_URL } from "../constants";
|
| 3 |
+
import type { UploadResponse } from "../types";
|
| 4 |
+
|
| 5 |
+
export async function upload_files(
|
| 6 |
+
this: Client,
|
| 7 |
+
root_url: string,
|
| 8 |
+
files: (Blob | File)[],
|
| 9 |
+
upload_id?: string
|
| 10 |
+
): Promise<UploadResponse> {
|
| 11 |
+
const headers: {
|
| 12 |
+
Authorization?: string;
|
| 13 |
+
} = {};
|
| 14 |
+
if (this?.options?.token) {
|
| 15 |
+
headers.Authorization = `Bearer ${this.options.token}`;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
const chunkSize = 1000;
|
| 19 |
+
const uploadResponses = [];
|
| 20 |
+
let response: Response;
|
| 21 |
+
|
| 22 |
+
for (let i = 0; i < files.length; i += chunkSize) {
|
| 23 |
+
const chunk = files.slice(i, i + chunkSize);
|
| 24 |
+
const formData = new FormData();
|
| 25 |
+
chunk.forEach((file) => {
|
| 26 |
+
formData.append("files", file);
|
| 27 |
+
});
|
| 28 |
+
try {
|
| 29 |
+
const upload_url = upload_id
|
| 30 |
+
? `${root_url}${this.api_prefix}/${UPLOAD_URL}?upload_id=${upload_id}`
|
| 31 |
+
: `${root_url}${this.api_prefix}/${UPLOAD_URL}`;
|
| 32 |
+
|
| 33 |
+
response = await this.fetch(upload_url, {
|
| 34 |
+
method: "POST",
|
| 35 |
+
body: formData,
|
| 36 |
+
headers,
|
| 37 |
+
credentials: this.options.credentials ?? "same-origin"
|
| 38 |
+
});
|
| 39 |
+
} catch (e) {
|
| 40 |
+
throw new Error(BROKEN_CONNECTION_MSG + (e as Error).message);
|
| 41 |
+
}
|
| 42 |
+
if (!response.ok) {
|
| 43 |
+
const error_text = await response.text();
|
| 44 |
+
return { error: `HTTP ${response.status}: ${error_text}` };
|
| 45 |
+
}
|
| 46 |
+
const output: UploadResponse["files"] = await response.json();
|
| 47 |
+
if (output) {
|
| 48 |
+
uploadResponses.push(...output);
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
return { files: uploadResponses };
|
| 52 |
+
}
|
6.29.1/client/src/utils/view_api.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { ApiInfo, ApiData } from "../types";
|
| 2 |
+
import { API_INFO_URL, BROKEN_CONNECTION_MSG } from "../constants";
|
| 3 |
+
import { Client } from "../client";
|
| 4 |
+
import { SPACE_FETCHER_URL } from "../constants";
|
| 5 |
+
import { join_urls, transform_api_info } from "../helpers/api_info";
|
| 6 |
+
|
| 7 |
+
export async function view_api(this: Client): Promise<any> {
|
| 8 |
+
if (this.api_info) return this.api_info;
|
| 9 |
+
|
| 10 |
+
const { token } = this.options;
|
| 11 |
+
const { config } = this;
|
| 12 |
+
|
| 13 |
+
const headers: {
|
| 14 |
+
Authorization?: string;
|
| 15 |
+
} = {};
|
| 16 |
+
|
| 17 |
+
if (token) {
|
| 18 |
+
headers.Authorization = `Bearer ${token}`;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
if (!config) {
|
| 22 |
+
return;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
try {
|
| 26 |
+
let response: Response;
|
| 27 |
+
let api_info: ApiInfo<ApiData> | { api: ApiInfo<ApiData> };
|
| 28 |
+
if (typeof window !== "undefined" && window.gradio_api_info) {
|
| 29 |
+
api_info = window.gradio_api_info;
|
| 30 |
+
} else {
|
| 31 |
+
const url = new URL(
|
| 32 |
+
join_urls(config.root, this.api_prefix, API_INFO_URL)
|
| 33 |
+
);
|
| 34 |
+
if (this.page !== null) url.searchParams.set("page", this.page);
|
| 35 |
+
response = await this.fetch(url, {
|
| 36 |
+
headers,
|
| 37 |
+
credentials: this.options.credentials ?? "same-origin"
|
| 38 |
+
});
|
| 39 |
+
if (!response.ok) {
|
| 40 |
+
throw new Error(BROKEN_CONNECTION_MSG);
|
| 41 |
+
}
|
| 42 |
+
api_info = await response.json();
|
| 43 |
+
}
|
| 44 |
+
if ("api" in api_info) {
|
| 45 |
+
api_info = api_info.api;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
if (
|
| 49 |
+
api_info.named_endpoints["/predict"] &&
|
| 50 |
+
!api_info.unnamed_endpoints["0"]
|
| 51 |
+
) {
|
| 52 |
+
api_info.unnamed_endpoints[0] = api_info.named_endpoints["/predict"];
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
return transform_api_info(api_info, config, this.api_map);
|
| 56 |
+
} catch (e) {
|
| 57 |
+
throw new Error("Could not get API info. " + (e as Error).message);
|
| 58 |
+
}
|
| 59 |
+
}
|
6.29.1/client/src/vite-env.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/// <reference types="vite/client" />
|
| 2 |
+
|
| 3 |
+
declare const BROWSER_BUILD: boolean;
|
6.29.1/client/tsconfig.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"include": ["src/**/*"],
|
| 3 |
+
"exclude": ["src/**/*.test.ts", "src/**/*.node-test.ts", "src/test/**/*"],
|
| 4 |
+
"compilerOptions": {
|
| 5 |
+
"allowJs": true,
|
| 6 |
+
"declaration": true,
|
| 7 |
+
"emitDeclarationOnly": true,
|
| 8 |
+
"outDir": "dist",
|
| 9 |
+
"declarationMap": true,
|
| 10 |
+
"module": "ESNext",
|
| 11 |
+
"target": "ES2020",
|
| 12 |
+
"useDefineForClassFields": true,
|
| 13 |
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
| 14 |
+
"skipLibCheck": true,
|
| 15 |
+
"types": ["node"],
|
| 16 |
+
|
| 17 |
+
/* Bundler */
|
| 18 |
+
"moduleResolution": "Bundler",
|
| 19 |
+
"skipDefaultLibCheck": true,
|
| 20 |
+
"allowImportingTsExtensions": true,
|
| 21 |
+
"esModuleInterop": true,
|
| 22 |
+
"resolveJsonModule": true,
|
| 23 |
+
"isolatedModules": true,
|
| 24 |
+
|
| 25 |
+
/* Linting */
|
| 26 |
+
"strict": true
|
| 27 |
+
}
|
| 28 |
+
}
|
6.29.1/client/vite.config.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { defineConfig, createLogger } from "vite";
|
| 2 |
+
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
| 3 |
+
import { playwright } from "@vitest/browser-playwright";
|
| 4 |
+
|
| 5 |
+
const TEST_MODE = process.env.TEST_MODE || "browser";
|
| 6 |
+
|
| 7 |
+
const logger = createLogger();
|
| 8 |
+
const originalWarning = logger.warn;
|
| 9 |
+
|
| 10 |
+
logger.warn = (log, options) => {
|
| 11 |
+
if (log.includes("was created with unknown prop")) return false;
|
| 12 |
+
if (log.includes("https://svelte.dev")) return false;
|
| 13 |
+
if (log.includes("[vite-plugin-svelte]")) return false;
|
| 14 |
+
if (log && log.includes("[MSW]")) return false;
|
| 15 |
+
if (log && log.includes("node:")) return false;
|
| 16 |
+
originalWarning(log, options);
|
| 17 |
+
};
|
| 18 |
+
|
| 19 |
+
const originalError = logger.error;
|
| 20 |
+
|
| 21 |
+
logger.error = (log, options) => {
|
| 22 |
+
if (log.includes("was created with unknown prop")) return false;
|
| 23 |
+
if (log.includes("https://svelte.dev")) return false;
|
| 24 |
+
if (log.includes("[vite-plugin-svelte]")) return false;
|
| 25 |
+
if (log && log.includes("[MSW]")) return false;
|
| 26 |
+
if (log && log.includes("(node:")) return false;
|
| 27 |
+
originalError(log, options);
|
| 28 |
+
};
|
| 29 |
+
|
| 30 |
+
const original_info = logger.info;
|
| 31 |
+
logger.info = (log, options) => {
|
| 32 |
+
if (log.includes("was created with unknown prop")) return false;
|
| 33 |
+
if (log.includes("https://svelte.dev")) return false;
|
| 34 |
+
if (log.includes("[vite-plugin-svelte]")) return false;
|
| 35 |
+
if (log && log.includes("[MSW]")) return false;
|
| 36 |
+
if (log && log.includes("node:")) return false;
|
| 37 |
+
original_info(log, options);
|
| 38 |
+
};
|
| 39 |
+
export default defineConfig(({ mode }) => {
|
| 40 |
+
const production = mode === "production";
|
| 41 |
+
// Single-file, minified browser bundle served from CDNs at
|
| 42 |
+
// dist/index.min.js (see https://github.com/gradio-app/gradio/issues/10028)
|
| 43 |
+
const isCdnBuild = process.env.CDN_BUILD === "true";
|
| 44 |
+
// a CDN build is always a browser build (guards against CDN_BUILD=true
|
| 45 |
+
// without BROWSER_BUILD=true emitting es+cjs into the same file name)
|
| 46 |
+
const isBrowserBuild = process.env.BROWSER_BUILD === "true" || isCdnBuild;
|
| 47 |
+
|
| 48 |
+
if (mode === "preview") {
|
| 49 |
+
return {
|
| 50 |
+
entry: "index.html"
|
| 51 |
+
};
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
return {
|
| 55 |
+
customLogger: logger,
|
| 56 |
+
build: {
|
| 57 |
+
emptyOutDir: false,
|
| 58 |
+
...(isCdnBuild ? { minify: true } : {}),
|
| 59 |
+
lib: {
|
| 60 |
+
entry: "src/index.ts",
|
| 61 |
+
// the node build also emits a CommonJS bundle (dist/index.cjs)
|
| 62 |
+
// so that require("@gradio/client") works on all supported
|
| 63 |
+
// node versions (see https://github.com/gradio-app/gradio/issues/9214)
|
| 64 |
+
formats: isBrowserBuild ? ["es"] : ["es", "cjs"],
|
| 65 |
+
fileName: (format) => {
|
| 66 |
+
if (isCdnBuild) return "index.min.js";
|
| 67 |
+
if (isBrowserBuild) return "browser.js";
|
| 68 |
+
return format === "cjs" ? "index.cjs" : "index.js";
|
| 69 |
+
}
|
| 70 |
+
},
|
| 71 |
+
rollupOptions: {
|
| 72 |
+
input: "src/index.ts",
|
| 73 |
+
output: {
|
| 74 |
+
dir: "dist",
|
| 75 |
+
// keep the CDN bundle as a single file so the documented
|
| 76 |
+
// <script type="module"> import works without extra chunks
|
| 77 |
+
inlineDynamicImports: isCdnBuild
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
},
|
| 81 |
+
plugins: [svelte()],
|
| 82 |
+
define: {
|
| 83 |
+
BROWSER_BUILD: JSON.stringify(isBrowserBuild)
|
| 84 |
+
},
|
| 85 |
+
mode: process.env.MODE || "development",
|
| 86 |
+
test: {
|
| 87 |
+
include: ["./src/test/*.test.*"],
|
| 88 |
+
onConsoleLog(log) {
|
| 89 |
+
if (log.includes("[MSW]")) return false;
|
| 90 |
+
if (log.includes("node:")) return false;
|
| 91 |
+
if (log.includes("data: '\"404\"'")) return false;
|
| 92 |
+
if (log.includes("Too many arguments")) return false;
|
| 93 |
+
},
|
| 94 |
+
...(TEST_MODE === "node"
|
| 95 |
+
? { environment: "node" }
|
| 96 |
+
: {
|
| 97 |
+
browser: {
|
| 98 |
+
enabled: true,
|
| 99 |
+
provider: playwright(),
|
| 100 |
+
instances: [
|
| 101 |
+
{
|
| 102 |
+
browser: "chromium"
|
| 103 |
+
}
|
| 104 |
+
]
|
| 105 |
+
}
|
| 106 |
+
})
|
| 107 |
+
},
|
| 108 |
+
ssr: {
|
| 109 |
+
target: "node",
|
| 110 |
+
format: "esm",
|
| 111 |
+
noExternal: [
|
| 112 |
+
"ws",
|
| 113 |
+
"semiver",
|
| 114 |
+
"bufferutil",
|
| 115 |
+
"@gradio/upload",
|
| 116 |
+
"fetch-event-stream"
|
| 117 |
+
]
|
| 118 |
+
}
|
| 119 |
+
};
|
| 120 |
+
});
|