@gallop.software/studio 1.3.4 → 1.3.5

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.
@@ -2122,33 +2122,83 @@ function StudioToolbar() {
2122
2122
  percent: 0,
2123
2123
  status: "processing"
2124
2124
  });
2125
- const selectedImageKeys = imagesToProcess.map((p) => p.replace(/^public\//, ""));
2126
- const response = await fetch("/api/studio/reprocess", {
2125
+ const selectedImageKeys = imagesToProcess.map((p) => {
2126
+ const key = p.replace(/^public\//, "");
2127
+ return key.startsWith("/") ? key : `/${key}`;
2128
+ });
2129
+ const response = await fetch("/api/studio/reprocess-stream", {
2127
2130
  method: "POST",
2128
2131
  headers: { "Content-Type": "application/json" },
2129
2132
  body: JSON.stringify({ imageKeys: selectedImageKeys }),
2130
2133
  signal
2131
2134
  });
2132
- const data = await response.json();
2133
- if (response.ok) {
2134
- setProgressState({
2135
- current: _optionalChain([data, 'access', _20 => _20.processed, 'optionalAccess', _21 => _21.length]) || 0,
2136
- total: _optionalChain([data, 'access', _22 => _22.processed, 'optionalAccess', _23 => _23.length]) || 0,
2137
- percent: 100,
2138
- status: "complete",
2139
- processed: _optionalChain([data, 'access', _24 => _24.processed, 'optionalAccess', _25 => _25.length]) || 0,
2140
- errors: _optionalChain([data, 'access', _26 => _26.errors, 'optionalAccess', _27 => _27.length]) || 0
2141
- });
2142
- clearSelection();
2143
- triggerRefresh();
2144
- } else {
2135
+ if (!response.ok) {
2136
+ const error = await response.json();
2145
2137
  setProgressState({
2146
2138
  current: 0,
2147
2139
  total: 0,
2148
2140
  percent: 0,
2149
2141
  status: "error",
2150
- message: data.error || "Unknown error"
2142
+ message: error.error || "Unknown error"
2151
2143
  });
2144
+ } else {
2145
+ const reader = _optionalChain([response, 'access', _20 => _20.body, 'optionalAccess', _21 => _21.getReader, 'call', _22 => _22()]);
2146
+ const decoder = new TextDecoder();
2147
+ if (reader) {
2148
+ let buffer = "";
2149
+ while (true) {
2150
+ const { done, value } = await reader.read();
2151
+ if (done) break;
2152
+ buffer += decoder.decode(value, { stream: true });
2153
+ const lines = buffer.split("\n");
2154
+ buffer = lines.pop() || "";
2155
+ for (const line of lines) {
2156
+ if (line.startsWith("data: ")) {
2157
+ try {
2158
+ const data = JSON.parse(line.slice(6));
2159
+ if (data.type === "start") {
2160
+ setProgressState((prev) => ({
2161
+ ...prev,
2162
+ total: data.total
2163
+ }));
2164
+ } else if (data.type === "progress") {
2165
+ setProgressState({
2166
+ current: data.current,
2167
+ total: data.total,
2168
+ percent: data.percent,
2169
+ status: "processing",
2170
+ message: data.message
2171
+ });
2172
+ } else if (data.type === "cleanup") {
2173
+ setProgressState((prev) => ({
2174
+ ...prev,
2175
+ status: "cleanup",
2176
+ message: data.message
2177
+ }));
2178
+ } else if (data.type === "complete") {
2179
+ setProgressState({
2180
+ current: data.processed,
2181
+ total: data.processed,
2182
+ percent: 100,
2183
+ status: data.errors > 0 ? "error" : "complete",
2184
+ processed: data.processed,
2185
+ message: data.message
2186
+ });
2187
+ clearSelection();
2188
+ triggerRefresh();
2189
+ } else if (data.type === "error") {
2190
+ setProgressState((prev) => ({
2191
+ ...prev,
2192
+ status: "error",
2193
+ message: data.message
2194
+ }));
2195
+ }
2196
+ } catch (e4) {
2197
+ }
2198
+ }
2199
+ }
2200
+ }
2201
+ }
2152
2202
  }
2153
2203
  }
2154
2204
  } catch (error) {
@@ -2246,7 +2296,7 @@ function StudioToolbar() {
2246
2296
  const selectedPaths2 = Array.from(selectedItems);
2247
2297
  const imageExtensions = ["jpg", "jpeg", "png", "gif", "webp", "svg", "ico", "bmp", "tiff", "tif"];
2248
2298
  const selectedImagePaths = selectedPaths2.filter((p) => {
2249
- const ext = _optionalChain([p, 'access', _28 => _28.split, 'call', _29 => _29("."), 'access', _30 => _30.pop, 'call', _31 => _31(), 'optionalAccess', _32 => _32.toLowerCase, 'call', _33 => _33()]) || "";
2299
+ const ext = _optionalChain([p, 'access', _23 => _23.split, 'call', _24 => _24("."), 'access', _25 => _25.pop, 'call', _26 => _26(), 'optionalAccess', _27 => _27.toLowerCase, 'call', _28 => _28()]) || "";
2250
2300
  return imageExtensions.includes(ext);
2251
2301
  });
2252
2302
  const selectedFolders = selectedPaths2.filter((p) => !p.includes(".") || p.endsWith("/"));
@@ -2295,7 +2345,7 @@ function StudioToolbar() {
2295
2345
  const selectedPaths2 = Array.from(selectedItems);
2296
2346
  const imageExtensions = ["jpg", "jpeg", "png", "gif", "webp", "svg", "ico", "bmp", "tiff", "tif"];
2297
2347
  const selectedImagePaths = selectedPaths2.filter((p) => {
2298
- const ext = _optionalChain([p, 'access', _34 => _34.split, 'call', _35 => _35("."), 'access', _36 => _36.pop, 'call', _37 => _37(), 'optionalAccess', _38 => _38.toLowerCase, 'call', _39 => _39()]) || "";
2348
+ const ext = _optionalChain([p, 'access', _29 => _29.split, 'call', _30 => _30("."), 'access', _31 => _31.pop, 'call', _32 => _32(), 'optionalAccess', _33 => _33.toLowerCase, 'call', _34 => _34()]) || "";
2299
2349
  return imageExtensions.includes(ext);
2300
2350
  });
2301
2351
  const selectedFolders = selectedPaths2.filter((p) => !p.includes(".") || p.endsWith("/"));
@@ -2346,16 +2396,16 @@ function StudioToolbar() {
2346
2396
  });
2347
2397
  const data = await response.json();
2348
2398
  if (!response.ok) {
2349
- if (_optionalChain([data, 'access', _40 => _40.error, 'optionalAccess', _41 => _41.includes, 'call', _42 => _42("R2 not configured")]) || _optionalChain([data, 'access', _43 => _43.error, 'optionalAccess', _44 => _44.includes, 'call', _45 => _45("CLOUDFLARE_R2")])) {
2399
+ if (_optionalChain([data, 'access', _35 => _35.error, 'optionalAccess', _36 => _36.includes, 'call', _37 => _37("R2 not configured")]) || _optionalChain([data, 'access', _38 => _38.error, 'optionalAccess', _39 => _39.includes, 'call', _40 => _40("CLOUDFLARE_R2")])) {
2350
2400
  setShowProgress(false);
2351
2401
  setShowR2SetupModal(true);
2352
2402
  return;
2353
2403
  }
2354
2404
  errors++;
2355
2405
  errorMessages.push(data.error || `Failed: ${imageKey}`);
2356
- } else if (_optionalChain([data, 'access', _46 => _46.pushed, 'optionalAccess', _47 => _47.length]) > 0) {
2406
+ } else if (_optionalChain([data, 'access', _41 => _41.pushed, 'optionalAccess', _42 => _42.length]) > 0) {
2357
2407
  pushed++;
2358
- } else if (_optionalChain([data, 'access', _48 => _48.errors, 'optionalAccess', _49 => _49.length]) > 0) {
2408
+ } else if (_optionalChain([data, 'access', _43 => _43.errors, 'optionalAccess', _44 => _44.length]) > 0) {
2359
2409
  errors++;
2360
2410
  for (const errMsg of data.errors) {
2361
2411
  errorMessages.push(errMsg);
@@ -2477,7 +2527,7 @@ function StudioToolbar() {
2477
2527
  errorMessage: data.message
2478
2528
  }));
2479
2529
  }
2480
- } catch (e4) {
2530
+ } catch (e5) {
2481
2531
  }
2482
2532
  }
2483
2533
  }
@@ -5372,7 +5422,7 @@ function useStudioActions({
5372
5422
  });
5373
5423
  return;
5374
5424
  }
5375
- const reader = _optionalChain([response, 'access', _50 => _50.body, 'optionalAccess', _51 => _51.getReader, 'call', _52 => _52()]);
5425
+ const reader = _optionalChain([response, 'access', _45 => _45.body, 'optionalAccess', _46 => _46.getReader, 'call', _47 => _47()]);
5376
5426
  const decoder = new TextDecoder();
5377
5427
  if (reader) {
5378
5428
  let buffer = "";
@@ -5402,7 +5452,7 @@ function useStudioActions({
5402
5452
  status: "complete",
5403
5453
  message: `Moved ${data.moved} file${data.moved !== 1 ? "s" : ""}${data.errors > 0 ? `, ${data.errors} error${data.errors !== 1 ? "s" : ""}` : ""}`
5404
5454
  }));
5405
- if (data.errors > 0 && _optionalChain([data, 'access', _53 => _53.errorMessages, 'optionalAccess', _54 => _54.length]) > 0) {
5455
+ if (data.errors > 0 && _optionalChain([data, 'access', _48 => _48.errorMessages, 'optionalAccess', _49 => _49.length]) > 0) {
5406
5456
  showError("Move Failed", data.errorMessages.join("\n"));
5407
5457
  }
5408
5458
  clearSelection();
@@ -5415,7 +5465,7 @@ function useStudioActions({
5415
5465
  message: data.message || "Unknown error"
5416
5466
  }));
5417
5467
  }
5418
- } catch (e5) {
5468
+ } catch (e6) {
5419
5469
  }
5420
5470
  }
5421
5471
  }
@@ -5525,7 +5575,7 @@ function useStudioActions({
5525
5575
  });
5526
5576
  return;
5527
5577
  }
5528
- const reader = _optionalChain([response, 'access', _55 => _55.body, 'optionalAccess', _56 => _56.getReader, 'call', _57 => _57()]);
5578
+ const reader = _optionalChain([response, 'access', _50 => _50.body, 'optionalAccess', _51 => _51.getReader, 'call', _52 => _52()]);
5529
5579
  const decoder = new TextDecoder();
5530
5580
  if (reader) {
5531
5581
  let buffer = "";
@@ -5574,7 +5624,7 @@ function useStudioActions({
5574
5624
  message: data.message
5575
5625
  }));
5576
5626
  }
5577
- } catch (e6) {
5627
+ } catch (e7) {
5578
5628
  }
5579
5629
  }
5580
5630
  }
@@ -5614,7 +5664,7 @@ function useStudioActions({
5614
5664
  setProgressState((prev) => ({
5615
5665
  ...prev,
5616
5666
  orphanedFiles: void 0,
5617
- message: _optionalChain([prev, 'access', _58 => _58.message, 'optionalAccess', _59 => _59.replace, 'call', _60 => _60(/Found \d+ orphaned thumbnail\(s\).*/, "Orphaned thumbnails deleted.")])
5667
+ message: _optionalChain([prev, 'access', _53 => _53.message, 'optionalAccess', _54 => _54.replace, 'call', _55 => _55(/Found \d+ orphaned thumbnail\(s\).*/, "Orphaned thumbnails deleted.")])
5618
5668
  }));
5619
5669
  triggerRefresh();
5620
5670
  } else {
@@ -6111,4 +6161,4 @@ var StudioUI_default = StudioUI;
6111
6161
 
6112
6162
 
6113
6163
  exports.StudioUI = StudioUI; exports.default = StudioUI_default;
6114
- //# sourceMappingURL=StudioUI-X5SN52MU.js.map
6164
+ //# sourceMappingURL=StudioUI-OY33OEG2.js.map