@gallop.software/studio 1.3.0 → 1.3.1

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.
@@ -5359,7 +5359,7 @@ function useStudioActions({
5359
5359
  }
5360
5360
  }));
5361
5361
  try {
5362
- const response = await fetch("/api/studio/move-stream", {
5362
+ const response = await fetch("/api/studio/move", {
5363
5363
  method: "POST",
5364
5364
  headers: { "Content-Type": "application/json" },
5365
5365
  body: JSON.stringify({ paths, destination })
@@ -5488,7 +5488,10 @@ function useStudioActions({
5488
5488
  }, [actionState.actionPaths, clearSelection, triggerRefresh, showError, setProgressState]);
5489
5489
  const confirmProcess = _react.useCallback.call(void 0, async () => {
5490
5490
  const paths = actionState.actionPaths;
5491
- const imageKeys = paths.map((p) => "/" + p.replace(/^public\//, ""));
5491
+ const imageKeys = paths.map((p) => {
5492
+ const key = p.replace(/^public\//, "");
5493
+ return key.startsWith("/") ? key : `/${key}`;
5494
+ });
5492
5495
  setActionState((prev) => ({
5493
5496
  ...prev,
5494
5497
  showProcessConfirm: false,
@@ -5502,96 +5505,42 @@ function useStudioActions({
5502
5505
  message: "Processing images..."
5503
5506
  }
5504
5507
  }));
5505
- abortControllerRef.current = new AbortController();
5506
- const signal = abortControllerRef.current.signal;
5507
5508
  try {
5508
- const response = await fetch("/api/studio/process-stream", {
5509
+ const response = await fetch("/api/studio/reprocess", {
5509
5510
  method: "POST",
5510
5511
  headers: { "Content-Type": "application/json" },
5511
- body: JSON.stringify({ imageKeys }),
5512
- signal
5512
+ body: JSON.stringify({ imageKeys })
5513
5513
  });
5514
+ const data = await response.json();
5514
5515
  if (!response.ok) {
5515
- const error = await response.json();
5516
5516
  setProgressState({
5517
+ current: 0,
5518
+ total: imageKeys.length,
5519
+ percent: 0,
5517
5520
  status: "error",
5518
- message: error.error || "Processing failed"
5521
+ message: data.error || "Processing failed"
5519
5522
  });
5520
5523
  return;
5521
5524
  }
5522
- const reader = _optionalChain([response, 'access', _55 => _55.body, 'optionalAccess', _56 => _56.getReader, 'call', _57 => _57()]);
5523
- const decoder = new TextDecoder();
5524
- if (reader) {
5525
- let buffer = "";
5526
- while (true) {
5527
- const { done, value } = await reader.read();
5528
- if (done) break;
5529
- buffer += decoder.decode(value, { stream: true });
5530
- const lines = buffer.split("\n");
5531
- buffer = lines.pop() || "";
5532
- for (const line of lines) {
5533
- if (line.startsWith("data: ")) {
5534
- try {
5535
- const data = JSON.parse(line.slice(6));
5536
- if (data.type === "start") {
5537
- setProgressState((prev) => ({
5538
- ...prev,
5539
- total: data.total
5540
- }));
5541
- } else if (data.type === "progress") {
5542
- setProgressState({
5543
- current: data.current,
5544
- total: data.total,
5545
- percent: Math.round(data.current / data.total * 100),
5546
- status: "processing",
5547
- message: data.message
5548
- });
5549
- } else if (data.type === "cleanup") {
5550
- setProgressState((prev) => ({
5551
- ...prev,
5552
- status: "cleanup",
5553
- message: data.message
5554
- }));
5555
- } else if (data.type === "complete") {
5556
- setProgressState({
5557
- current: data.processed,
5558
- total: data.processed,
5559
- percent: 100,
5560
- status: "complete",
5561
- message: `Processed ${data.processed} image${data.processed !== 1 ? "s" : ""}${data.errors > 0 ? `, ${data.errors} error${data.errors !== 1 ? "s" : ""}` : ""}`
5562
- });
5563
- triggerRefresh();
5564
- } else if (data.type === "error") {
5565
- setProgressState((prev) => ({
5566
- ...prev,
5567
- status: "error",
5568
- message: data.message
5569
- }));
5570
- }
5571
- } catch (e6) {
5572
- }
5573
- }
5574
- }
5575
- }
5576
- }
5525
+ const processed = _optionalChain([data, 'access', _55 => _55.processed, 'optionalAccess', _56 => _56.length]) || 0;
5526
+ const errors = _optionalChain([data, 'access', _57 => _57.errors, 'optionalAccess', _58 => _58.length]) || 0;
5527
+ setProgressState({
5528
+ current: processed,
5529
+ total: imageKeys.length,
5530
+ percent: 100,
5531
+ status: errors > 0 ? "error" : "complete",
5532
+ message: `Processed ${processed} image${processed !== 1 ? "s" : ""}${errors > 0 ? `, ${errors} error${errors !== 1 ? "s" : ""}` : ""}`
5533
+ });
5534
+ triggerRefresh();
5577
5535
  } catch (error) {
5578
- if (signal.aborted) {
5579
- setProgressState((prev) => ({
5580
- ...prev,
5581
- status: "stopped",
5582
- message: "Processing stopped by user"
5583
- }));
5584
- } else {
5585
- console.error("Processing error:", error);
5586
- setProgressState({
5587
- current: 0,
5588
- total: 0,
5589
- status: "error",
5590
- message: "Processing failed. Check console for details."
5591
- });
5592
- }
5593
- } finally {
5594
- abortControllerRef.current = null;
5536
+ console.error("Processing error:", error);
5537
+ setProgressState({
5538
+ current: 0,
5539
+ total: imageKeys.length,
5540
+ percent: 0,
5541
+ status: "error",
5542
+ message: "Processing failed. Check console for details."
5543
+ });
5595
5544
  }
5596
5545
  }, [actionState.actionPaths, triggerRefresh, setProgressState]);
5597
5546
  const deleteOrphans = _react.useCallback.call(void 0, async () => {
@@ -5607,7 +5556,7 @@ function useStudioActions({
5607
5556
  setProgressState((prev) => ({
5608
5557
  ...prev,
5609
5558
  orphanedFiles: void 0,
5610
- message: _optionalChain([prev, 'access', _58 => _58.message, 'optionalAccess', _59 => _59.replace, 'call', _60 => _60(/Found \d+ orphaned thumbnail\(s\).*/, "Orphaned thumbnails deleted.")])
5559
+ message: _optionalChain([prev, 'access', _59 => _59.message, 'optionalAccess', _60 => _60.replace, 'call', _61 => _61(/Found \d+ orphaned thumbnail\(s\).*/, "Orphaned thumbnails deleted.")])
5611
5560
  }));
5612
5561
  triggerRefresh();
5613
5562
  } else {
@@ -6104,4 +6053,4 @@ var StudioUI_default = StudioUI;
6104
6053
 
6105
6054
 
6106
6055
  exports.StudioUI = StudioUI; exports.default = StudioUI_default;
6107
- //# sourceMappingURL=StudioUI-52NHWBVJ.js.map
6056
+ //# sourceMappingURL=StudioUI-LORP7MIK.js.map