vslides 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +41 -15
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -3247,22 +3247,48 @@ async function getGuide() {
3247
3247
  return request("/api/slides/guide");
3248
3248
  }
3249
3249
  async function uploadAsset(slug, token, filename, content) {
3250
- const response = await fetch(`${BASE_URL}/api/slides/assets`, {
3251
- method: "POST",
3252
- headers: {
3253
- "X-Slug": slug,
3254
- "X-Session-Token": token,
3255
- "X-Filename": filename,
3256
- "Content-Type": "application/octet-stream"
3257
- },
3258
- body: content
3259
- });
3260
- if (response.status === 401) {
3261
- clearCLIAuth();
3262
- throw new AuthExpiredError();
3250
+ for (let i = 0; i < MAX_RETRIES; i++) {
3251
+ let response;
3252
+ try {
3253
+ response = await fetch(`${BASE_URL}/api/slides/assets`, {
3254
+ method: "POST",
3255
+ headers: {
3256
+ "X-Slug": slug,
3257
+ "X-Session-Token": token,
3258
+ "X-Filename": filename,
3259
+ "Content-Type": "application/octet-stream"
3260
+ },
3261
+ body: content
3262
+ // Node.js fetch handles Buffer directly
3263
+ });
3264
+ } catch (err) {
3265
+ if (i < MAX_RETRIES - 1) {
3266
+ const errMsg = err instanceof Error ? err.message : String(err);
3267
+ console.log(`Upload network error: ${errMsg}, retrying... (${i + 1}/${MAX_RETRIES})`);
3268
+ await sleep(RETRY_DELAY);
3269
+ continue;
3270
+ }
3271
+ throw err;
3272
+ }
3273
+ if (response.status === 503) {
3274
+ console.log("Sandbox waking up...");
3275
+ await sleep(RETRY_DELAY);
3276
+ continue;
3277
+ }
3278
+ if (response.status === 401) {
3279
+ clearCLIAuth();
3280
+ throw new AuthExpiredError();
3281
+ }
3282
+ let data;
3283
+ try {
3284
+ data = await response.json();
3285
+ } catch {
3286
+ const text = await response.text().catch(() => "unknown");
3287
+ throw new Error(`Upload failed (${response.status}): ${text}`);
3288
+ }
3289
+ return { ok: response.ok, status: response.status, data };
3263
3290
  }
3264
- const data = await response.json();
3265
- return { ok: response.ok, status: response.status, data };
3291
+ throw new Error("Upload failed after max retries");
3266
3292
  }
3267
3293
  async function exportSlides(slug, token, format) {
3268
3294
  const response = await fetch(`${BASE_URL}/api/slides/export?format=${format}`, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vslides",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "CLI for Vercel Slides API",
5
5
  "license": "MIT",
6
6
  "author": "Vercel",