@gallop.software/studio 1.2.3 → 1.2.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.
package/dist/handlers/index.js
CHANGED
|
@@ -355,6 +355,12 @@ 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;
|
|
362
|
+
const isPushedToCloud = cdnIndex !== void 0;
|
|
363
|
+
const isRemote = isPushedToCloud && cdnBaseUrl !== r2PublicUrl;
|
|
358
364
|
if (imagesSubPath === "") {
|
|
359
365
|
const slashIndex = thumbRelative.indexOf("/");
|
|
360
366
|
if (slashIndex === -1) {
|
|
@@ -363,9 +369,12 @@ async function handleList(request) {
|
|
|
363
369
|
name: fileName,
|
|
364
370
|
path: `public/images/${fileName}`,
|
|
365
371
|
type: "file",
|
|
366
|
-
thumbnail:
|
|
372
|
+
thumbnail: thumbnailUrl,
|
|
367
373
|
hasThumbnail: false,
|
|
368
|
-
isProtected: true
|
|
374
|
+
isProtected: true,
|
|
375
|
+
cdnPushed: isPushedToCloud,
|
|
376
|
+
cdnBaseUrl,
|
|
377
|
+
isRemote
|
|
369
378
|
});
|
|
370
379
|
} else {
|
|
371
380
|
const folderName = thumbRelative.slice(0, slashIndex);
|
|
@@ -394,9 +403,12 @@ async function handleList(request) {
|
|
|
394
403
|
name: remaining,
|
|
395
404
|
path: `public/images/${imagesSubPath}/${remaining}`,
|
|
396
405
|
type: "file",
|
|
397
|
-
thumbnail:
|
|
406
|
+
thumbnail: thumbnailUrl,
|
|
398
407
|
hasThumbnail: false,
|
|
399
|
-
isProtected: true
|
|
408
|
+
isProtected: true,
|
|
409
|
+
cdnPushed: isPushedToCloud,
|
|
410
|
+
cdnBaseUrl,
|
|
411
|
+
isRemote
|
|
400
412
|
});
|
|
401
413
|
} else {
|
|
402
414
|
const folderName = remaining.slice(0, slashIndex);
|
|
@@ -567,7 +579,7 @@ async function handleList(request) {
|
|
|
567
579
|
}
|
|
568
580
|
async function handleSearch(request) {
|
|
569
581
|
const searchParams = request.nextUrl.searchParams;
|
|
570
|
-
const query = _optionalChain([searchParams, 'access',
|
|
582
|
+
const query = _optionalChain([searchParams, 'access', _9 => _9.get, 'call', _10 => _10("q"), 'optionalAccess', _11 => _11.toLowerCase, 'call', _12 => _12()]) || "";
|
|
571
583
|
if (query.length < 2) {
|
|
572
584
|
return _server.NextResponse.json({ items: [] });
|
|
573
585
|
}
|
|
@@ -575,7 +587,7 @@ async function handleSearch(request) {
|
|
|
575
587
|
const meta = await loadMeta();
|
|
576
588
|
const fileEntries = getFileEntries(meta);
|
|
577
589
|
const cdnUrls = getCdnUrls(meta);
|
|
578
|
-
const r2PublicUrl = _optionalChain([process, 'access',
|
|
590
|
+
const r2PublicUrl = _optionalChain([process, 'access', _13 => _13.env, 'access', _14 => _14.CLOUDFLARE_R2_PUBLIC_URL, 'optionalAccess', _15 => _15.replace, 'call', _16 => _16(/\/$/, "")]) || "";
|
|
579
591
|
const items = [];
|
|
580
592
|
for (const [key, entry] of fileEntries) {
|
|
581
593
|
if (!key.toLowerCase().includes(query)) continue;
|
|
@@ -834,7 +846,7 @@ async function handleDelete(request) {
|
|
|
834
846
|
const absolutePath = _path2.default.join(process.cwd(), itemPath);
|
|
835
847
|
const imageKey = "/" + itemPath.replace(/^public\//, "");
|
|
836
848
|
const entry = meta[imageKey];
|
|
837
|
-
const isPushedToCloud = _optionalChain([entry, 'optionalAccess',
|
|
849
|
+
const isPushedToCloud = _optionalChain([entry, 'optionalAccess', _17 => _17.c]) !== void 0;
|
|
838
850
|
try {
|
|
839
851
|
const stats = await _fs.promises.stat(absolutePath);
|
|
840
852
|
if (stats.isDirectory()) {
|
|
@@ -1026,7 +1038,7 @@ async function handleMoveStream(request) {
|
|
|
1026
1038
|
await _fs.promises.mkdir(absoluteDestination, { recursive: true });
|
|
1027
1039
|
const meta = await loadMeta();
|
|
1028
1040
|
const cdnUrls = getCdnUrls(meta);
|
|
1029
|
-
const r2PublicUrl = _optionalChain([process, 'access',
|
|
1041
|
+
const r2PublicUrl = _optionalChain([process, 'access', _18 => _18.env, 'access', _19 => _19.CLOUDFLARE_R2_PUBLIC_URL, 'optionalAccess', _20 => _20.replace, 'call', _21 => _21(/\/$/, "")]) || "";
|
|
1030
1042
|
const moved = [];
|
|
1031
1043
|
const errors = [];
|
|
1032
1044
|
const total = paths.length;
|
|
@@ -1053,7 +1065,7 @@ async function handleMoveStream(request) {
|
|
|
1053
1065
|
}
|
|
1054
1066
|
const entry = meta[oldKey];
|
|
1055
1067
|
const isImage = isImageFile(itemName);
|
|
1056
|
-
const isInCloud = _optionalChain([entry, 'optionalAccess',
|
|
1068
|
+
const isInCloud = _optionalChain([entry, 'optionalAccess', _22 => _22.c]) !== void 0;
|
|
1057
1069
|
const fileCdnUrl = isInCloud && entry.c !== void 0 ? cdnUrls[entry.c] : void 0;
|
|
1058
1070
|
const isRemote = isInCloud && (!r2PublicUrl || fileCdnUrl !== r2PublicUrl);
|
|
1059
1071
|
const isPushedToR2 = isInCloud && r2PublicUrl && fileCdnUrl === r2PublicUrl;
|
|
@@ -1065,8 +1077,8 @@ async function handleMoveStream(request) {
|
|
|
1065
1077
|
await _fs.promises.mkdir(_path2.default.dirname(newAbsolutePath), { recursive: true });
|
|
1066
1078
|
await _fs.promises.writeFile(newAbsolutePath, buffer);
|
|
1067
1079
|
const newEntry = {
|
|
1068
|
-
o: _optionalChain([entry, 'optionalAccess',
|
|
1069
|
-
b: _optionalChain([entry, 'optionalAccess',
|
|
1080
|
+
o: _optionalChain([entry, 'optionalAccess', _23 => _23.o]),
|
|
1081
|
+
b: _optionalChain([entry, 'optionalAccess', _24 => _24.b])
|
|
1070
1082
|
};
|
|
1071
1083
|
delete meta[oldKey];
|
|
1072
1084
|
meta[newKey] = newEntry;
|
|
@@ -1076,8 +1088,8 @@ async function handleMoveStream(request) {
|
|
|
1076
1088
|
await _fs.promises.mkdir(_path2.default.dirname(newAbsolutePath), { recursive: true });
|
|
1077
1089
|
await _fs.promises.writeFile(newAbsolutePath, buffer);
|
|
1078
1090
|
let newEntry = {
|
|
1079
|
-
o: _optionalChain([entry, 'optionalAccess',
|
|
1080
|
-
b: _optionalChain([entry, 'optionalAccess',
|
|
1091
|
+
o: _optionalChain([entry, 'optionalAccess', _25 => _25.o]),
|
|
1092
|
+
b: _optionalChain([entry, 'optionalAccess', _26 => _26.b])
|
|
1081
1093
|
};
|
|
1082
1094
|
if (hasProcessedThumbnails) {
|
|
1083
1095
|
const processedEntry = await processImage(buffer, newKey);
|
|
@@ -1095,7 +1107,7 @@ async function handleMoveStream(request) {
|
|
|
1095
1107
|
if (hasProcessedThumbnails) {
|
|
1096
1108
|
await deleteLocalThumbnails(newKey);
|
|
1097
1109
|
}
|
|
1098
|
-
newEntry.c = _optionalChain([entry, 'optionalAccess',
|
|
1110
|
+
newEntry.c = _optionalChain([entry, 'optionalAccess', _27 => _27.c]);
|
|
1099
1111
|
delete meta[oldKey];
|
|
1100
1112
|
meta[newKey] = newEntry;
|
|
1101
1113
|
moved.push(itemPath);
|
|
@@ -1185,7 +1197,7 @@ async function handleSync(request) {
|
|
|
1185
1197
|
const accessKeyId = process.env.CLOUDFLARE_R2_ACCESS_KEY_ID;
|
|
1186
1198
|
const secretAccessKey = process.env.CLOUDFLARE_R2_SECRET_ACCESS_KEY;
|
|
1187
1199
|
const bucketName = process.env.CLOUDFLARE_R2_BUCKET_NAME;
|
|
1188
|
-
const publicUrl = _optionalChain([process, 'access',
|
|
1200
|
+
const publicUrl = _optionalChain([process, 'access', _28 => _28.env, 'access', _29 => _29.CLOUDFLARE_R2_PUBLIC_URL, 'optionalAccess', _30 => _30.replace, 'call', _31 => _31(/\/\s*$/, "")]);
|
|
1189
1201
|
if (!accountId || !accessKeyId || !secretAccessKey || !bucketName || !publicUrl) {
|
|
1190
1202
|
return _server.NextResponse.json(
|
|
1191
1203
|
{ error: "R2 not configured. Set CLOUDFLARE_R2_* environment variables." },
|
|
@@ -1301,7 +1313,7 @@ async function handleSync(request) {
|
|
|
1301
1313
|
}
|
|
1302
1314
|
}
|
|
1303
1315
|
async function handleReprocess(request) {
|
|
1304
|
-
const publicUrl = _optionalChain([process, 'access',
|
|
1316
|
+
const publicUrl = _optionalChain([process, 'access', _32 => _32.env, 'access', _33 => _33.CLOUDFLARE_R2_PUBLIC_URL, 'optionalAccess', _34 => _34.replace, 'call', _35 => _35(/\/\s*$/, "")]);
|
|
1305
1317
|
try {
|
|
1306
1318
|
const { imageKeys } = await request.json();
|
|
1307
1319
|
if (!imageKeys || !Array.isArray(imageKeys) || imageKeys.length === 0) {
|
|
@@ -1319,7 +1331,7 @@ async function handleReprocess(request) {
|
|
|
1319
1331
|
try {
|
|
1320
1332
|
let buffer;
|
|
1321
1333
|
const entry = getMetaEntry(meta, imageKey);
|
|
1322
|
-
const existingCdnIndex = _optionalChain([entry, 'optionalAccess',
|
|
1334
|
+
const existingCdnIndex = _optionalChain([entry, 'optionalAccess', _36 => _36.c]);
|
|
1323
1335
|
const existingCdnUrl = existingCdnIndex !== void 0 ? cdnUrls[existingCdnIndex] : void 0;
|
|
1324
1336
|
const isInOurR2 = existingCdnUrl === publicUrl;
|
|
1325
1337
|
const isRemote = existingCdnIndex !== void 0 && !isInOurR2;
|
|
@@ -1378,7 +1390,7 @@ async function handleReprocess(request) {
|
|
|
1378
1390
|
}
|
|
1379
1391
|
}
|
|
1380
1392
|
async function handleProcessAllStream() {
|
|
1381
|
-
const publicUrl = _optionalChain([process, 'access',
|
|
1393
|
+
const publicUrl = _optionalChain([process, 'access', _37 => _37.env, 'access', _38 => _38.CLOUDFLARE_R2_PUBLIC_URL, 'optionalAccess', _39 => _39.replace, 'call', _40 => _40(/\/\s*$/, "")]);
|
|
1382
1394
|
const encoder = new TextEncoder();
|
|
1383
1395
|
const stream = new ReadableStream({
|
|
1384
1396
|
async start(controller) {
|