@gallop.software/studio 1.2.3 → 1.2.4

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.
@@ -355,6 +355,10 @@ async function handleList(request) {
355
355
  }
356
356
  for (const thumb of allThumbnails) {
357
357
  const thumbRelative = thumb.path.replace(/^\/images\/?/, "");
358
+ const originalEntry = _optionalChain([fileEntries, 'access', _5 => _5.find, 'call', _6 => _6(([k]) => k === thumb.originalKey), 'optionalAccess', _7 => _7[1]]);
359
+ const cdnIndex = _optionalChain([originalEntry, 'optionalAccess', _8 => _8.c]);
360
+ const cdnBaseUrl = cdnIndex !== void 0 ? cdnUrls[cdnIndex] : void 0;
361
+ const thumbnailUrl = cdnBaseUrl ? `${cdnBaseUrl}${thumb.path}` : thumb.path;
358
362
  if (imagesSubPath === "") {
359
363
  const slashIndex = thumbRelative.indexOf("/");
360
364
  if (slashIndex === -1) {
@@ -363,7 +367,7 @@ async function handleList(request) {
363
367
  name: fileName,
364
368
  path: `public/images/${fileName}`,
365
369
  type: "file",
366
- thumbnail: thumb.path,
370
+ thumbnail: thumbnailUrl,
367
371
  hasThumbnail: false,
368
372
  isProtected: true
369
373
  });
@@ -394,7 +398,7 @@ async function handleList(request) {
394
398
  name: remaining,
395
399
  path: `public/images/${imagesSubPath}/${remaining}`,
396
400
  type: "file",
397
- thumbnail: thumb.path,
401
+ thumbnail: thumbnailUrl,
398
402
  hasThumbnail: false,
399
403
  isProtected: true
400
404
  });
@@ -567,7 +571,7 @@ async function handleList(request) {
567
571
  }
568
572
  async function handleSearch(request) {
569
573
  const searchParams = request.nextUrl.searchParams;
570
- const query = _optionalChain([searchParams, 'access', _5 => _5.get, 'call', _6 => _6("q"), 'optionalAccess', _7 => _7.toLowerCase, 'call', _8 => _8()]) || "";
574
+ const query = _optionalChain([searchParams, 'access', _9 => _9.get, 'call', _10 => _10("q"), 'optionalAccess', _11 => _11.toLowerCase, 'call', _12 => _12()]) || "";
571
575
  if (query.length < 2) {
572
576
  return _server.NextResponse.json({ items: [] });
573
577
  }
@@ -575,7 +579,7 @@ async function handleSearch(request) {
575
579
  const meta = await loadMeta();
576
580
  const fileEntries = getFileEntries(meta);
577
581
  const cdnUrls = getCdnUrls(meta);
578
- const r2PublicUrl = _optionalChain([process, 'access', _9 => _9.env, 'access', _10 => _10.CLOUDFLARE_R2_PUBLIC_URL, 'optionalAccess', _11 => _11.replace, 'call', _12 => _12(/\/$/, "")]) || "";
582
+ const r2PublicUrl = _optionalChain([process, 'access', _13 => _13.env, 'access', _14 => _14.CLOUDFLARE_R2_PUBLIC_URL, 'optionalAccess', _15 => _15.replace, 'call', _16 => _16(/\/$/, "")]) || "";
579
583
  const items = [];
580
584
  for (const [key, entry] of fileEntries) {
581
585
  if (!key.toLowerCase().includes(query)) continue;
@@ -834,7 +838,7 @@ async function handleDelete(request) {
834
838
  const absolutePath = _path2.default.join(process.cwd(), itemPath);
835
839
  const imageKey = "/" + itemPath.replace(/^public\//, "");
836
840
  const entry = meta[imageKey];
837
- const isPushedToCloud = _optionalChain([entry, 'optionalAccess', _13 => _13.c]) !== void 0;
841
+ const isPushedToCloud = _optionalChain([entry, 'optionalAccess', _17 => _17.c]) !== void 0;
838
842
  try {
839
843
  const stats = await _fs.promises.stat(absolutePath);
840
844
  if (stats.isDirectory()) {
@@ -1026,7 +1030,7 @@ async function handleMoveStream(request) {
1026
1030
  await _fs.promises.mkdir(absoluteDestination, { recursive: true });
1027
1031
  const meta = await loadMeta();
1028
1032
  const cdnUrls = getCdnUrls(meta);
1029
- const r2PublicUrl = _optionalChain([process, 'access', _14 => _14.env, 'access', _15 => _15.CLOUDFLARE_R2_PUBLIC_URL, 'optionalAccess', _16 => _16.replace, 'call', _17 => _17(/\/$/, "")]) || "";
1033
+ const r2PublicUrl = _optionalChain([process, 'access', _18 => _18.env, 'access', _19 => _19.CLOUDFLARE_R2_PUBLIC_URL, 'optionalAccess', _20 => _20.replace, 'call', _21 => _21(/\/$/, "")]) || "";
1030
1034
  const moved = [];
1031
1035
  const errors = [];
1032
1036
  const total = paths.length;
@@ -1053,7 +1057,7 @@ async function handleMoveStream(request) {
1053
1057
  }
1054
1058
  const entry = meta[oldKey];
1055
1059
  const isImage = isImageFile(itemName);
1056
- const isInCloud = _optionalChain([entry, 'optionalAccess', _18 => _18.c]) !== void 0;
1060
+ const isInCloud = _optionalChain([entry, 'optionalAccess', _22 => _22.c]) !== void 0;
1057
1061
  const fileCdnUrl = isInCloud && entry.c !== void 0 ? cdnUrls[entry.c] : void 0;
1058
1062
  const isRemote = isInCloud && (!r2PublicUrl || fileCdnUrl !== r2PublicUrl);
1059
1063
  const isPushedToR2 = isInCloud && r2PublicUrl && fileCdnUrl === r2PublicUrl;
@@ -1065,8 +1069,8 @@ async function handleMoveStream(request) {
1065
1069
  await _fs.promises.mkdir(_path2.default.dirname(newAbsolutePath), { recursive: true });
1066
1070
  await _fs.promises.writeFile(newAbsolutePath, buffer);
1067
1071
  const newEntry = {
1068
- o: _optionalChain([entry, 'optionalAccess', _19 => _19.o]),
1069
- b: _optionalChain([entry, 'optionalAccess', _20 => _20.b])
1072
+ o: _optionalChain([entry, 'optionalAccess', _23 => _23.o]),
1073
+ b: _optionalChain([entry, 'optionalAccess', _24 => _24.b])
1070
1074
  };
1071
1075
  delete meta[oldKey];
1072
1076
  meta[newKey] = newEntry;
@@ -1076,8 +1080,8 @@ async function handleMoveStream(request) {
1076
1080
  await _fs.promises.mkdir(_path2.default.dirname(newAbsolutePath), { recursive: true });
1077
1081
  await _fs.promises.writeFile(newAbsolutePath, buffer);
1078
1082
  let newEntry = {
1079
- o: _optionalChain([entry, 'optionalAccess', _21 => _21.o]),
1080
- b: _optionalChain([entry, 'optionalAccess', _22 => _22.b])
1083
+ o: _optionalChain([entry, 'optionalAccess', _25 => _25.o]),
1084
+ b: _optionalChain([entry, 'optionalAccess', _26 => _26.b])
1081
1085
  };
1082
1086
  if (hasProcessedThumbnails) {
1083
1087
  const processedEntry = await processImage(buffer, newKey);
@@ -1095,7 +1099,7 @@ async function handleMoveStream(request) {
1095
1099
  if (hasProcessedThumbnails) {
1096
1100
  await deleteLocalThumbnails(newKey);
1097
1101
  }
1098
- newEntry.c = _optionalChain([entry, 'optionalAccess', _23 => _23.c]);
1102
+ newEntry.c = _optionalChain([entry, 'optionalAccess', _27 => _27.c]);
1099
1103
  delete meta[oldKey];
1100
1104
  meta[newKey] = newEntry;
1101
1105
  moved.push(itemPath);
@@ -1185,7 +1189,7 @@ async function handleSync(request) {
1185
1189
  const accessKeyId = process.env.CLOUDFLARE_R2_ACCESS_KEY_ID;
1186
1190
  const secretAccessKey = process.env.CLOUDFLARE_R2_SECRET_ACCESS_KEY;
1187
1191
  const bucketName = process.env.CLOUDFLARE_R2_BUCKET_NAME;
1188
- const publicUrl = _optionalChain([process, 'access', _24 => _24.env, 'access', _25 => _25.CLOUDFLARE_R2_PUBLIC_URL, 'optionalAccess', _26 => _26.replace, 'call', _27 => _27(/\/\s*$/, "")]);
1192
+ const publicUrl = _optionalChain([process, 'access', _28 => _28.env, 'access', _29 => _29.CLOUDFLARE_R2_PUBLIC_URL, 'optionalAccess', _30 => _30.replace, 'call', _31 => _31(/\/\s*$/, "")]);
1189
1193
  if (!accountId || !accessKeyId || !secretAccessKey || !bucketName || !publicUrl) {
1190
1194
  return _server.NextResponse.json(
1191
1195
  { error: "R2 not configured. Set CLOUDFLARE_R2_* environment variables." },
@@ -1301,7 +1305,7 @@ async function handleSync(request) {
1301
1305
  }
1302
1306
  }
1303
1307
  async function handleReprocess(request) {
1304
- const publicUrl = _optionalChain([process, 'access', _28 => _28.env, 'access', _29 => _29.CLOUDFLARE_R2_PUBLIC_URL, 'optionalAccess', _30 => _30.replace, 'call', _31 => _31(/\/\s*$/, "")]);
1308
+ const publicUrl = _optionalChain([process, 'access', _32 => _32.env, 'access', _33 => _33.CLOUDFLARE_R2_PUBLIC_URL, 'optionalAccess', _34 => _34.replace, 'call', _35 => _35(/\/\s*$/, "")]);
1305
1309
  try {
1306
1310
  const { imageKeys } = await request.json();
1307
1311
  if (!imageKeys || !Array.isArray(imageKeys) || imageKeys.length === 0) {
@@ -1319,7 +1323,7 @@ async function handleReprocess(request) {
1319
1323
  try {
1320
1324
  let buffer;
1321
1325
  const entry = getMetaEntry(meta, imageKey);
1322
- const existingCdnIndex = _optionalChain([entry, 'optionalAccess', _32 => _32.c]);
1326
+ const existingCdnIndex = _optionalChain([entry, 'optionalAccess', _36 => _36.c]);
1323
1327
  const existingCdnUrl = existingCdnIndex !== void 0 ? cdnUrls[existingCdnIndex] : void 0;
1324
1328
  const isInOurR2 = existingCdnUrl === publicUrl;
1325
1329
  const isRemote = existingCdnIndex !== void 0 && !isInOurR2;
@@ -1378,7 +1382,7 @@ async function handleReprocess(request) {
1378
1382
  }
1379
1383
  }
1380
1384
  async function handleProcessAllStream() {
1381
- const publicUrl = _optionalChain([process, 'access', _33 => _33.env, 'access', _34 => _34.CLOUDFLARE_R2_PUBLIC_URL, 'optionalAccess', _35 => _35.replace, 'call', _36 => _36(/\/\s*$/, "")]);
1385
+ const publicUrl = _optionalChain([process, 'access', _37 => _37.env, 'access', _38 => _38.CLOUDFLARE_R2_PUBLIC_URL, 'optionalAccess', _39 => _39.replace, 'call', _40 => _40(/\/\s*$/, "")]);
1382
1386
  const encoder = new TextEncoder();
1383
1387
  const stream = new ReadableStream({
1384
1388
  async start(controller) {