@gallop.software/studio 1.1.0 → 1.2.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.
@@ -2,7 +2,7 @@ import {
2
2
  getAllThumbnailPaths,
3
3
  getThumbnailPath,
4
4
  isProcessed
5
- } from "../chunk-CIS6B4SP.mjs";
5
+ } from "../chunk-VQJAJVAQ.mjs";
6
6
 
7
7
  // src/handlers/index.ts
8
8
  import { NextResponse as NextResponse5 } from "next/server";
@@ -128,7 +128,7 @@ async function processImage(buffer, imageKey) {
128
128
  const isPng = ext === ".png";
129
129
  const outputExt = isPng ? ".png" : ".jpg";
130
130
  const entry = {
131
- o: [originalWidth, originalHeight]
131
+ o: { w: originalWidth, h: originalHeight }
132
132
  };
133
133
  const fullFileName = imageDir === "." ? `${baseName}${outputExt}` : `${imageDir}/${baseName}${outputExt}`;
134
134
  const fullPath = path3.join(process.cwd(), "public", "images", fullFileName);
@@ -149,7 +149,7 @@ async function processImage(buffer, imageKey) {
149
149
  await sharp(buffer).jpeg({ quality: 85 }).toFile(fullPath);
150
150
  }
151
151
  }
152
- entry.f = [fullWidth, fullHeight];
152
+ entry.f = { w: fullWidth, h: fullHeight };
153
153
  for (const [, sizeConfig] of Object.entries(DEFAULT_SIZES)) {
154
154
  const { width: maxWidth, suffix, key } = sizeConfig;
155
155
  if (originalWidth <= maxWidth) {
@@ -164,7 +164,7 @@ async function processImage(buffer, imageKey) {
164
164
  } else {
165
165
  await sharp(buffer).resize(maxWidth, newHeight).jpeg({ quality: 80 }).toFile(sizePath);
166
166
  }
167
- entry[key] = [maxWidth, newHeight];
167
+ entry[key] = { w: maxWidth, h: newHeight };
168
168
  }
169
169
  const { data, info } = await sharp(buffer).resize(32, 32, { fit: "inside" }).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
170
170
  entry.b = encode(new Uint8ClampedArray(data), info.width, info.height, 4, 4);
@@ -464,7 +464,7 @@ async function handleList(request) {
464
464
  cdnBaseUrl: fileCdnUrl,
465
465
  isRemote,
466
466
  isProtected: isInsideImagesFolder,
467
- dimensions: entry.o ? { width: entry.o[0], height: entry.o[1] } : void 0
467
+ dimensions: entry.o ? { width: entry.o.w, height: entry.o.h } : void 0
468
468
  });
469
469
  }
470
470
  }
@@ -535,7 +535,7 @@ async function handleSearch(request) {
535
535
  cdnPushed: isPushedToCloud,
536
536
  cdnBaseUrl: fileCdnUrl,
537
537
  isRemote,
538
- dimensions: entry.o ? { width: entry.o[0], height: entry.o[1] } : void 0
538
+ dimensions: entry.o ? { width: entry.o.w, height: entry.o.h } : void 0
539
539
  });
540
540
  }
541
541
  return NextResponse.json({ items });
@@ -705,11 +705,10 @@ async function handleUpload(request) {
705
705
  try {
706
706
  const metadata = await sharp2(buffer).metadata();
707
707
  meta[imageKey] = {
708
- w: metadata.width || 0,
709
- h: metadata.height || 0
708
+ o: { w: metadata.width || 0, h: metadata.height || 0 }
710
709
  };
711
710
  } catch {
712
- meta[imageKey] = { w: 0, h: 0 };
711
+ meta[imageKey] = { o: { w: 0, h: 0 } };
713
712
  }
714
713
  } else {
715
714
  meta[imageKey] = {};
@@ -744,7 +743,7 @@ async function handleDelete(request) {
744
743
  const absolutePath = path6.join(process.cwd(), itemPath);
745
744
  const imageKey = "/" + itemPath.replace(/^public\//, "");
746
745
  const entry = meta[imageKey];
747
- const isPushedToCloud = entry?.c === 1;
746
+ const isPushedToCloud = entry?.c !== void 0;
748
747
  try {
749
748
  const stats = await fs5.stat(absolutePath);
750
749
  if (stats.isDirectory()) {
@@ -752,7 +751,8 @@ async function handleDelete(request) {
752
751
  const prefix = imageKey + "/";
753
752
  for (const key of Object.keys(meta)) {
754
753
  if (key.startsWith(prefix) || key === imageKey) {
755
- if (!meta[key].c) {
754
+ const keyEntry = meta[key];
755
+ if (keyEntry && keyEntry.c === void 0) {
756
756
  for (const thumbPath of getAllThumbnailPaths(key)) {
757
757
  const absoluteThumbPath = path6.join(process.cwd(), "public", thumbPath);
758
758
  try {
@@ -1358,9 +1358,9 @@ async function handleProcessAllStream() {
1358
1358
  await fs6.writeFile(destPath, buffer);
1359
1359
  meta[key] = {
1360
1360
  ...entry,
1361
- o: [0, 0],
1361
+ o: { w: 0, h: 0 },
1362
1362
  b: "",
1363
- f: [0, 0]
1363
+ f: { w: 0, h: 0 }
1364
1364
  // SVG has "full" to indicate processed
1365
1365
  };
1366
1366
  if (isRemote) {
@@ -1566,7 +1566,7 @@ async function handleScanStream() {
1566
1566
  if (isImage) {
1567
1567
  const ext = path8.extname(relativePath).toLowerCase();
1568
1568
  if (ext === ".svg") {
1569
- meta[imageKey] = { o: [0, 0], b: "" };
1569
+ meta[imageKey] = { o: { w: 0, h: 0 }, b: "" };
1570
1570
  } else {
1571
1571
  try {
1572
1572
  const buffer = await fs7.readFile(fullPath);
@@ -1574,11 +1574,11 @@ async function handleScanStream() {
1574
1574
  const { data, info } = await sharp3(buffer).resize(32, 32, { fit: "inside" }).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
1575
1575
  const blurhash = encode2(new Uint8ClampedArray(data), info.width, info.height, 4, 4);
1576
1576
  meta[imageKey] = {
1577
- o: [metadata.width || 0, metadata.height || 0],
1577
+ o: { w: metadata.width || 0, h: metadata.height || 0 },
1578
1578
  b: blurhash
1579
1579
  };
1580
1580
  } catch {
1581
- meta[imageKey] = { o: [0, 0] };
1581
+ meta[imageKey] = { o: { w: 0, h: 0 } };
1582
1582
  }
1583
1583
  }
1584
1584
  } else {
@@ -1728,7 +1728,7 @@ async function processRemoteImage(url) {
1728
1728
  const { data, info } = await sharp4(buffer).resize(32, 32, { fit: "inside" }).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
1729
1729
  const blurhash = encode3(new Uint8ClampedArray(data), info.width, info.height, 4, 4);
1730
1730
  return {
1731
- o: [metadata.width || 0, metadata.height || 0],
1731
+ o: { w: metadata.width || 0, h: metadata.height || 0 },
1732
1732
  b: blurhash
1733
1733
  };
1734
1734
  }