@gallop.software/studio 2.3.80 → 2.3.82
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/server/index.js +98 -36
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -454,7 +454,10 @@ function streamResponse(stream, init) {
|
|
|
454
454
|
function getExistingThumbnails(originalPath, entry) {
|
|
455
455
|
const thumbnails = [];
|
|
456
456
|
if (entry.f) {
|
|
457
|
-
thumbnails.push({
|
|
457
|
+
thumbnails.push({
|
|
458
|
+
path: getThumbnailPath(originalPath, "full"),
|
|
459
|
+
size: "f"
|
|
460
|
+
});
|
|
458
461
|
}
|
|
459
462
|
if (entry.lg) {
|
|
460
463
|
thumbnails.push({ path: getThumbnailPath(originalPath, "lg"), size: "lg" });
|
|
@@ -519,7 +522,9 @@ async function handleList(request) {
|
|
|
519
522
|
}
|
|
520
523
|
for (const thumb of allThumbnails) {
|
|
521
524
|
const thumbRelative = thumb.path.replace(/^\/images\/?/, "");
|
|
522
|
-
const originalEntry = fileEntries.find(
|
|
525
|
+
const originalEntry = fileEntries.find(
|
|
526
|
+
([k]) => k === thumb.originalKey
|
|
527
|
+
)?.[1];
|
|
523
528
|
const cdnIndex = originalEntry?.c;
|
|
524
529
|
const cdnBaseUrl = cdnIndex !== void 0 ? cdnUrls[cdnIndex] : void 0;
|
|
525
530
|
const thumbnailUrl = cdnBaseUrl ? `${cdnBaseUrl}${thumb.path}` : thumb.path;
|
|
@@ -582,7 +587,8 @@ async function handleList(request) {
|
|
|
582
587
|
}
|
|
583
588
|
}
|
|
584
589
|
} else {
|
|
585
|
-
if (!thumbRelative.startsWith(imagesSubPath + "/") && thumbRelative !== imagesSubPath)
|
|
590
|
+
if (!thumbRelative.startsWith(imagesSubPath + "/") && thumbRelative !== imagesSubPath)
|
|
591
|
+
continue;
|
|
586
592
|
const remaining = thumbRelative.slice(imagesSubPath.length + 1);
|
|
587
593
|
if (!remaining) continue;
|
|
588
594
|
const slashIndex = remaining.indexOf("/");
|
|
@@ -658,10 +664,16 @@ async function handleList(request) {
|
|
|
658
664
|
if (isImagesFolder) {
|
|
659
665
|
for (const [key, metaEntry] of fileEntries) {
|
|
660
666
|
if (isProcessed(metaEntry)) {
|
|
661
|
-
const thumbCount = getExistingThumbnails(
|
|
667
|
+
const thumbCount = getExistingThumbnails(
|
|
668
|
+
key,
|
|
669
|
+
metaEntry
|
|
670
|
+
).length;
|
|
662
671
|
fileCount += thumbCount;
|
|
663
672
|
if (metaEntry.c !== void 0) {
|
|
664
|
-
const entryCdnUrl = cdnUrls[metaEntry.c]?.replace(
|
|
673
|
+
const entryCdnUrl = cdnUrls[metaEntry.c]?.replace(
|
|
674
|
+
/\/?$/,
|
|
675
|
+
""
|
|
676
|
+
);
|
|
665
677
|
if (r2PublicUrl && entryCdnUrl === r2PublicUrl) {
|
|
666
678
|
cloudCount += thumbCount;
|
|
667
679
|
} else {
|
|
@@ -677,7 +689,12 @@ async function handleList(request) {
|
|
|
677
689
|
for (const k of metaKeys) {
|
|
678
690
|
if (k.startsWith(folderPrefix)) fileCount++;
|
|
679
691
|
}
|
|
680
|
-
const counts = countFileTypes(
|
|
692
|
+
const counts = countFileTypes(
|
|
693
|
+
folderPrefix,
|
|
694
|
+
fileEntries,
|
|
695
|
+
cdnUrls,
|
|
696
|
+
r2PublicUrl
|
|
697
|
+
);
|
|
681
698
|
cloudCount = counts.cloudCount;
|
|
682
699
|
remoteCount = counts.remoteCount;
|
|
683
700
|
localCount = counts.localCount;
|
|
@@ -751,7 +768,12 @@ async function handleList(request) {
|
|
|
751
768
|
for (const k of metaKeys) {
|
|
752
769
|
if (k.startsWith(folderPrefix)) fileCount++;
|
|
753
770
|
}
|
|
754
|
-
const counts = countFileTypes(
|
|
771
|
+
const counts = countFileTypes(
|
|
772
|
+
folderPrefix,
|
|
773
|
+
fileEntries,
|
|
774
|
+
cdnUrls,
|
|
775
|
+
r2PublicUrl
|
|
776
|
+
);
|
|
755
777
|
items.push({
|
|
756
778
|
name: folderName,
|
|
757
779
|
path: relativePath ? `public/${relativePath}/${folderName}` : `public/${folderName}`,
|
|
@@ -776,23 +798,42 @@ async function handleList(request) {
|
|
|
776
798
|
let fileSize;
|
|
777
799
|
const entryIsProcessed = isProcessed(entry);
|
|
778
800
|
if (isImage && entryIsProcessed) {
|
|
779
|
-
const
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
801
|
+
const hasSm = !!entry.sm;
|
|
802
|
+
const hasMd = !!entry.md;
|
|
803
|
+
const hasLg = !!entry.lg;
|
|
804
|
+
const hasFull = !!entry.f;
|
|
805
|
+
let thumbSize = null;
|
|
806
|
+
if (hasSm) thumbSize = "sm";
|
|
807
|
+
else if (hasMd) thumbSize = "md";
|
|
808
|
+
else if (hasLg) thumbSize = "lg";
|
|
809
|
+
else if (hasFull) thumbSize = "full";
|
|
810
|
+
if (thumbSize) {
|
|
811
|
+
const thumbPath = getThumbnailPath(key, thumbSize);
|
|
812
|
+
if (isPushedToCloud && entry.c !== void 0) {
|
|
813
|
+
const cdnUrl = cdnUrls[entry.c];
|
|
814
|
+
if (cdnUrl) {
|
|
815
|
+
thumbnail = `${cdnUrl}${thumbPath}`;
|
|
816
|
+
hasThumbnail = true;
|
|
817
|
+
}
|
|
818
|
+
} else {
|
|
819
|
+
const localThumbPath = getPublicPath(thumbPath);
|
|
820
|
+
try {
|
|
821
|
+
await fs4.access(localThumbPath);
|
|
822
|
+
thumbnail = thumbPath;
|
|
823
|
+
hasThumbnail = true;
|
|
824
|
+
} catch {
|
|
825
|
+
thumbnail = key;
|
|
826
|
+
hasThumbnail = false;
|
|
827
|
+
}
|
|
785
828
|
}
|
|
786
829
|
} else {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
hasThumbnail = true;
|
|
792
|
-
} catch {
|
|
830
|
+
if (isPushedToCloud && entry.c !== void 0) {
|
|
831
|
+
const cdnUrl = cdnUrls[entry.c];
|
|
832
|
+
thumbnail = cdnUrl ? `${cdnUrl}${key}` : key;
|
|
833
|
+
} else {
|
|
793
834
|
thumbnail = key;
|
|
794
|
-
hasThumbnail = false;
|
|
795
835
|
}
|
|
836
|
+
hasThumbnail = false;
|
|
796
837
|
}
|
|
797
838
|
} else if (isImage) {
|
|
798
839
|
if (isPushedToCloud && entry.c !== void 0) {
|
|
@@ -868,23 +909,42 @@ async function handleSearch(request) {
|
|
|
868
909
|
let hasThumbnail = false;
|
|
869
910
|
const entryIsProcessed = isProcessed(entry);
|
|
870
911
|
if (isImage && entryIsProcessed) {
|
|
871
|
-
const
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
912
|
+
const hasSm = !!entry.sm;
|
|
913
|
+
const hasMd = !!entry.md;
|
|
914
|
+
const hasLg = !!entry.lg;
|
|
915
|
+
const hasFull = !!entry.f;
|
|
916
|
+
let thumbSize = null;
|
|
917
|
+
if (hasSm) thumbSize = "sm";
|
|
918
|
+
else if (hasMd) thumbSize = "md";
|
|
919
|
+
else if (hasLg) thumbSize = "lg";
|
|
920
|
+
else if (hasFull) thumbSize = "full";
|
|
921
|
+
if (thumbSize) {
|
|
922
|
+
const thumbPath = getThumbnailPath(key, thumbSize);
|
|
923
|
+
if (isPushedToCloud && entry.c !== void 0) {
|
|
924
|
+
const cdnUrl = cdnUrls[entry.c];
|
|
925
|
+
if (cdnUrl) {
|
|
926
|
+
thumbnail = `${cdnUrl}${thumbPath}`;
|
|
927
|
+
hasThumbnail = true;
|
|
928
|
+
}
|
|
929
|
+
} else {
|
|
930
|
+
const localThumbPath = getPublicPath(thumbPath);
|
|
931
|
+
try {
|
|
932
|
+
await fs4.access(localThumbPath);
|
|
933
|
+
thumbnail = thumbPath;
|
|
934
|
+
hasThumbnail = true;
|
|
935
|
+
} catch {
|
|
936
|
+
thumbnail = key;
|
|
937
|
+
hasThumbnail = false;
|
|
938
|
+
}
|
|
877
939
|
}
|
|
878
940
|
} else {
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
hasThumbnail = true;
|
|
884
|
-
} catch {
|
|
941
|
+
if (isPushedToCloud && entry.c !== void 0) {
|
|
942
|
+
const cdnUrl = cdnUrls[entry.c];
|
|
943
|
+
thumbnail = cdnUrl ? `${cdnUrl}${key}` : key;
|
|
944
|
+
} else {
|
|
885
945
|
thumbnail = key;
|
|
886
|
-
hasThumbnail = false;
|
|
887
946
|
}
|
|
947
|
+
hasThumbnail = false;
|
|
888
948
|
}
|
|
889
949
|
} else if (isImage) {
|
|
890
950
|
if (isPushedToCloud && entry.c !== void 0) {
|
|
@@ -1016,7 +1076,10 @@ async function handleFolderImages(request) {
|
|
|
1016
1076
|
});
|
|
1017
1077
|
} catch (error) {
|
|
1018
1078
|
console.error("Failed to get folder files:", error);
|
|
1019
|
-
return jsonResponse(
|
|
1079
|
+
return jsonResponse(
|
|
1080
|
+
{ error: "Failed to get folder files" },
|
|
1081
|
+
{ status: 500 }
|
|
1082
|
+
);
|
|
1020
1083
|
}
|
|
1021
1084
|
}
|
|
1022
1085
|
|
|
@@ -4015,8 +4078,7 @@ async function handleGenerateFeaturedImage(request) {
|
|
|
4015
4078
|
const meta = await loadMeta();
|
|
4016
4079
|
const metaKey = `/${projectName}.jpg`;
|
|
4017
4080
|
setMetaEntry(meta, metaKey, {
|
|
4018
|
-
o: { w: width, h: height }
|
|
4019
|
-
f: { w: width, h: height }
|
|
4081
|
+
o: { w: width, h: height }
|
|
4020
4082
|
});
|
|
4021
4083
|
await saveMeta(meta);
|
|
4022
4084
|
sendEvent({
|