@gallop.software/studio 1.1.0 → 1.2.0
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/{chunk-CIS6B4SP.mjs → chunk-VQJAJVAQ.mjs} +1 -1
- package/dist/chunk-VQJAJVAQ.mjs.map +1 -0
- package/dist/{chunk-VSOTEQ7X.js → chunk-WOHZ4LYG.js} +1 -1
- package/dist/chunk-WOHZ4LYG.js.map +1 -0
- package/dist/handlers/index.js +35 -35
- package/dist/handlers/index.js.map +1 -1
- package/dist/handlers/index.mjs +12 -12
- package/dist/handlers/index.mjs.map +1 -1
- package/dist/index.d.mts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-CIS6B4SP.mjs.map +0 -1
- package/dist/chunk-VSOTEQ7X.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * Dimensions object {w, h}\n */\nexport interface Dimensions {\n w: number\n h: number\n}\n\n/**\n * Meta entry - works for images and non-images\n * o: original dimensions, b: blurhash, c: CDN index\n * sm/md/lg/f: thumbnail dimensions (presence implies processed)\n */\nexport interface MetaEntry {\n o?: Dimensions // original dimensions {w, h}\n b?: string // blurhash\n sm?: Dimensions // small thumbnail (300px width)\n md?: Dimensions // medium thumbnail (700px width)\n lg?: Dimensions // large thumbnail (1400px width)\n f?: Dimensions // full size (capped at 2560px width)\n c?: number // CDN index - index into _cdns array\n}\n\n/**\n * Full meta schema including special keys\n * _cdns: Array of CDN base URLs\n * Other keys: file paths from public folder\n */\nexport interface FullMeta {\n _cdns?: string[] // Array of CDN base URLs\n [key: string]: MetaEntry | string[] | undefined\n}\n\n/**\n * Meta schema - keyed by path from public folder\n * Example: { \"/portfolio/photo.jpg\": { o: {w:2400,h:1600}, b: \"...\", sm: {w:300,h:200}, ... } }\n */\nexport type LeanMeta = Record<string, MetaEntry>\n\n// Alias for compatibility\nexport type LeanImageEntry = MetaEntry\n\n/**\n * File/folder item for browser\n */\nexport interface FileItem {\n name: string\n path: string\n type: 'file' | 'folder'\n size?: number\n dimensions?: { width: number; height: number }\n isProcessed?: boolean\n cdnPushed?: boolean\n cdnBaseUrl?: string // CDN base URL when pushed to cloud\n isRemote?: boolean // true if CDN URL doesn't match R2 (external import)\n isProtected?: boolean // true for images folder and its contents (cannot select/modify)\n // Folder-specific properties\n fileCount?: number\n totalSize?: number\n // For showing thumbnails - path to -sm version if exists\n thumbnail?: string\n // Whether a processed thumbnail exists\n hasThumbnail?: boolean\n}\n\n/**\n * Studio configuration\n */\nexport interface StudioConfig {\n r2AccountId?: string\n r2AccessKeyId?: string\n r2SecretAccessKey?: string\n r2BucketName?: string\n r2PublicUrl?: string\n thumbnailSizes?: {\n small: number\n medium: number\n large: number\n }\n}\n\n/**\n * Get thumbnail path from original image path\n */\nexport function getThumbnailPath(originalPath: string, size: 'sm' | 'md' | 'lg' | 'full'): string {\n if (size === 'full') {\n const ext = originalPath.match(/\\.\\w+$/)?.[0] || '.jpg'\n const base = originalPath.replace(/\\.\\w+$/, '')\n const outputExt = ext.toLowerCase() === '.png' ? '.png' : '.jpg'\n return `/images${base}${outputExt}`\n }\n const ext = originalPath.match(/\\.\\w+$/)?.[0] || '.jpg'\n const base = originalPath.replace(/\\.\\w+$/, '')\n const outputExt = ext.toLowerCase() === '.png' ? '.png' : '.jpg'\n return `/images${base}-${size}${outputExt}`\n}\n\n/**\n * Get all thumbnail paths for an image\n */\nexport function getAllThumbnailPaths(originalPath: string): string[] {\n return [\n getThumbnailPath(originalPath, 'full'),\n getThumbnailPath(originalPath, 'lg'),\n getThumbnailPath(originalPath, 'md'),\n getThumbnailPath(originalPath, 'sm'),\n ]\n}\n\n/**\n * Check if an image entry is processed (has any thumbnail dimensions)\n */\nexport function isProcessed(entry: MetaEntry | undefined): boolean {\n if (!entry) return false\n return !!(entry.f || entry.lg || entry.md || entry.sm)\n}\n"],"mappings":";AAoFO,SAAS,iBAAiB,cAAsB,MAA2C;AAChG,MAAI,SAAS,QAAQ;AACnB,UAAMA,OAAM,aAAa,MAAM,QAAQ,IAAI,CAAC,KAAK;AACjD,UAAMC,QAAO,aAAa,QAAQ,UAAU,EAAE;AAC9C,UAAMC,aAAYF,KAAI,YAAY,MAAM,SAAS,SAAS;AAC1D,WAAO,UAAUC,KAAI,GAAGC,UAAS;AAAA,EACnC;AACA,QAAM,MAAM,aAAa,MAAM,QAAQ,IAAI,CAAC,KAAK;AACjD,QAAM,OAAO,aAAa,QAAQ,UAAU,EAAE;AAC9C,QAAM,YAAY,IAAI,YAAY,MAAM,SAAS,SAAS;AAC1D,SAAO,UAAU,IAAI,IAAI,IAAI,GAAG,SAAS;AAC3C;AAKO,SAAS,qBAAqB,cAAgC;AACnE,SAAO;AAAA,IACL,iBAAiB,cAAc,MAAM;AAAA,IACrC,iBAAiB,cAAc,IAAI;AAAA,IACnC,iBAAiB,cAAc,IAAI;AAAA,IACnC,iBAAiB,cAAc,IAAI;AAAA,EACrC;AACF;AAKO,SAAS,YAAY,OAAuC;AACjE,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO,CAAC,EAAE,MAAM,KAAK,MAAM,MAAM,MAAM,MAAM,MAAM;AACrD;","names":["ext","base","outputExt"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/chrisb/Sites/studio/dist/chunk-WOHZ4LYG.js","../src/types.ts"],"names":["ext","base","outputExt"],"mappings":"AAAA;ACoFO,SAAS,gBAAA,CAAiB,YAAA,EAAsB,IAAA,EAA2C;AAChG,EAAA,GAAA,CAAI,KAAA,IAAS,MAAA,EAAQ;AACnB,IAAA,MAAMA,KAAAA,kBAAM,YAAA,mBAAa,KAAA,mBAAM,QAAQ,CAAA,4BAAA,CAAI,CAAC,IAAA,GAAK,MAAA;AACjD,IAAA,MAAMC,MAAAA,EAAO,YAAA,CAAa,OAAA,CAAQ,QAAA,EAAU,EAAE,CAAA;AAC9C,IAAA,MAAMC,WAAAA,EAAYF,IAAAA,CAAI,WAAA,CAAY,EAAA,IAAM,OAAA,EAAS,OAAA,EAAS,MAAA;AAC1D,IAAA,OAAO,CAAA,OAAA,EAAUC,KAAI,CAAA,EAAA;AACvB,EAAA;AACyB,EAAA;AACZ,EAAA;AACS,EAAA;AACG,EAAA;AAC3B;AAKgB;AACP,EAAA;AACY,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACnB,EAAA;AACF;AAK4B;AACP,EAAA;AACE,EAAA;AACvB;AD1F2B;AACA;AACA;AACA;AACA;AACA","file":"/Users/chrisb/Sites/studio/dist/chunk-WOHZ4LYG.js","sourcesContent":[null,"/**\n * Dimensions object {w, h}\n */\nexport interface Dimensions {\n w: number\n h: number\n}\n\n/**\n * Meta entry - works for images and non-images\n * o: original dimensions, b: blurhash, c: CDN index\n * sm/md/lg/f: thumbnail dimensions (presence implies processed)\n */\nexport interface MetaEntry {\n o?: Dimensions // original dimensions {w, h}\n b?: string // blurhash\n sm?: Dimensions // small thumbnail (300px width)\n md?: Dimensions // medium thumbnail (700px width)\n lg?: Dimensions // large thumbnail (1400px width)\n f?: Dimensions // full size (capped at 2560px width)\n c?: number // CDN index - index into _cdns array\n}\n\n/**\n * Full meta schema including special keys\n * _cdns: Array of CDN base URLs\n * Other keys: file paths from public folder\n */\nexport interface FullMeta {\n _cdns?: string[] // Array of CDN base URLs\n [key: string]: MetaEntry | string[] | undefined\n}\n\n/**\n * Meta schema - keyed by path from public folder\n * Example: { \"/portfolio/photo.jpg\": { o: {w:2400,h:1600}, b: \"...\", sm: {w:300,h:200}, ... } }\n */\nexport type LeanMeta = Record<string, MetaEntry>\n\n// Alias for compatibility\nexport type LeanImageEntry = MetaEntry\n\n/**\n * File/folder item for browser\n */\nexport interface FileItem {\n name: string\n path: string\n type: 'file' | 'folder'\n size?: number\n dimensions?: { width: number; height: number }\n isProcessed?: boolean\n cdnPushed?: boolean\n cdnBaseUrl?: string // CDN base URL when pushed to cloud\n isRemote?: boolean // true if CDN URL doesn't match R2 (external import)\n isProtected?: boolean // true for images folder and its contents (cannot select/modify)\n // Folder-specific properties\n fileCount?: number\n totalSize?: number\n // For showing thumbnails - path to -sm version if exists\n thumbnail?: string\n // Whether a processed thumbnail exists\n hasThumbnail?: boolean\n}\n\n/**\n * Studio configuration\n */\nexport interface StudioConfig {\n r2AccountId?: string\n r2AccessKeyId?: string\n r2SecretAccessKey?: string\n r2BucketName?: string\n r2PublicUrl?: string\n thumbnailSizes?: {\n small: number\n medium: number\n large: number\n }\n}\n\n/**\n * Get thumbnail path from original image path\n */\nexport function getThumbnailPath(originalPath: string, size: 'sm' | 'md' | 'lg' | 'full'): string {\n if (size === 'full') {\n const ext = originalPath.match(/\\.\\w+$/)?.[0] || '.jpg'\n const base = originalPath.replace(/\\.\\w+$/, '')\n const outputExt = ext.toLowerCase() === '.png' ? '.png' : '.jpg'\n return `/images${base}${outputExt}`\n }\n const ext = originalPath.match(/\\.\\w+$/)?.[0] || '.jpg'\n const base = originalPath.replace(/\\.\\w+$/, '')\n const outputExt = ext.toLowerCase() === '.png' ? '.png' : '.jpg'\n return `/images${base}-${size}${outputExt}`\n}\n\n/**\n * Get all thumbnail paths for an image\n */\nexport function getAllThumbnailPaths(originalPath: string): string[] {\n return [\n getThumbnailPath(originalPath, 'full'),\n getThumbnailPath(originalPath, 'lg'),\n getThumbnailPath(originalPath, 'md'),\n getThumbnailPath(originalPath, 'sm'),\n ]\n}\n\n/**\n * Check if an image entry is processed (has any thumbnail dimensions)\n */\nexport function isProcessed(entry: MetaEntry | undefined): boolean {\n if (!entry) return false\n return !!(entry.f || entry.lg || entry.md || entry.sm)\n}\n"]}
|
package/dist/handlers/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkWOHZ4LYGjs = require('../chunk-WOHZ4LYG.js');
|
|
6
6
|
|
|
7
7
|
// src/handlers/index.ts
|
|
8
8
|
var _server = require('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:
|
|
131
|
+
o: { w: originalWidth, h: originalHeight }
|
|
132
132
|
};
|
|
133
133
|
const fullFileName = imageDir === "." ? `${baseName}${outputExt}` : `${imageDir}/${baseName}${outputExt}`;
|
|
134
134
|
const fullPath = _path2.default.join(process.cwd(), "public", "images", fullFileName);
|
|
@@ -149,7 +149,7 @@ async function processImage(buffer, imageKey) {
|
|
|
149
149
|
await _sharp2.default.call(void 0, buffer).jpeg({ quality: 85 }).toFile(fullPath);
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
entry.f =
|
|
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 _sharp2.default.call(void 0, buffer).resize(maxWidth, newHeight).jpeg({ quality: 80 }).toFile(sizePath);
|
|
166
166
|
}
|
|
167
|
-
entry[key] =
|
|
167
|
+
entry[key] = { w: maxWidth, h: newHeight };
|
|
168
168
|
}
|
|
169
169
|
const { data, info } = await _sharp2.default.call(void 0, buffer).resize(32, 32, { fit: "inside" }).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
170
170
|
entry.b = _blurhash.encode.call(void 0, new Uint8ClampedArray(data), info.width, info.height, 4, 4);
|
|
@@ -234,7 +234,7 @@ async function uploadToCdn(imageKey) {
|
|
|
234
234
|
const bucketName = process.env.CLOUDFLARE_R2_BUCKET_NAME;
|
|
235
235
|
if (!bucketName) throw new Error("R2 bucket not configured");
|
|
236
236
|
const r2 = getR2Client();
|
|
237
|
-
for (const thumbPath of
|
|
237
|
+
for (const thumbPath of _chunkWOHZ4LYGjs.getAllThumbnailPaths.call(void 0, imageKey)) {
|
|
238
238
|
const localPath = _path2.default.join(process.cwd(), "public", thumbPath);
|
|
239
239
|
try {
|
|
240
240
|
const fileBuffer = await _fs.promises.readFile(localPath);
|
|
@@ -251,7 +251,7 @@ async function uploadToCdn(imageKey) {
|
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
async function deleteLocalThumbnails(imageKey) {
|
|
254
|
-
for (const thumbPath of
|
|
254
|
+
for (const thumbPath of _chunkWOHZ4LYGjs.getAllThumbnailPaths.call(void 0, imageKey)) {
|
|
255
255
|
const localPath = _path2.default.join(process.cwd(), "public", thumbPath);
|
|
256
256
|
try {
|
|
257
257
|
await _fs.promises.unlink(localPath);
|
|
@@ -296,7 +296,7 @@ async function deleteFromCdn(imageKey, hasThumbnails) {
|
|
|
296
296
|
} catch (e4) {
|
|
297
297
|
}
|
|
298
298
|
if (hasThumbnails) {
|
|
299
|
-
for (const thumbPath of
|
|
299
|
+
for (const thumbPath of _chunkWOHZ4LYGjs.getAllThumbnailPaths.call(void 0, imageKey)) {
|
|
300
300
|
try {
|
|
301
301
|
await r2.send(
|
|
302
302
|
new (0, _clients3.DeleteObjectCommand)({
|
|
@@ -415,9 +415,9 @@ async function handleList(request) {
|
|
|
415
415
|
let thumbnail;
|
|
416
416
|
let hasThumbnail = false;
|
|
417
417
|
let fileSize;
|
|
418
|
-
const entryIsProcessed =
|
|
418
|
+
const entryIsProcessed = _chunkWOHZ4LYGjs.isProcessed.call(void 0, entry);
|
|
419
419
|
if (isImage && entryIsProcessed) {
|
|
420
|
-
const thumbPath =
|
|
420
|
+
const thumbPath = _chunkWOHZ4LYGjs.getThumbnailPath.call(void 0, key, "sm");
|
|
421
421
|
if (isPushedToCloud && entry.c !== void 0) {
|
|
422
422
|
const cdnUrl = cdnUrls[entry.c];
|
|
423
423
|
if (cdnUrl) {
|
|
@@ -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
|
|
467
|
+
dimensions: entry.o ? { width: entry.o.w, height: entry.o.h } : void 0
|
|
468
468
|
});
|
|
469
469
|
}
|
|
470
470
|
}
|
|
@@ -496,9 +496,9 @@ async function handleSearch(request) {
|
|
|
496
496
|
const isRemote = isPushedToCloud && (!r2PublicUrl || fileCdnUrl !== r2PublicUrl);
|
|
497
497
|
let thumbnail;
|
|
498
498
|
let hasThumbnail = false;
|
|
499
|
-
const entryIsProcessed =
|
|
499
|
+
const entryIsProcessed = _chunkWOHZ4LYGjs.isProcessed.call(void 0, entry);
|
|
500
500
|
if (isImage && entryIsProcessed) {
|
|
501
|
-
const thumbPath =
|
|
501
|
+
const thumbPath = _chunkWOHZ4LYGjs.getThumbnailPath.call(void 0, key, "sm");
|
|
502
502
|
if (isPushedToCloud && entry.c !== void 0) {
|
|
503
503
|
const cdnUrl = cdnUrls[entry.c];
|
|
504
504
|
if (cdnUrl) {
|
|
@@ -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
|
|
538
|
+
dimensions: entry.o ? { width: entry.o.w, height: entry.o.h } : void 0
|
|
539
539
|
});
|
|
540
540
|
}
|
|
541
541
|
return _server.NextResponse.json({ items });
|
|
@@ -753,7 +753,7 @@ async function handleDelete(request) {
|
|
|
753
753
|
for (const key of Object.keys(meta)) {
|
|
754
754
|
if (key.startsWith(prefix) || key === imageKey) {
|
|
755
755
|
if (!meta[key].c) {
|
|
756
|
-
for (const thumbPath of
|
|
756
|
+
for (const thumbPath of _chunkWOHZ4LYGjs.getAllThumbnailPaths.call(void 0, key)) {
|
|
757
757
|
const absoluteThumbPath = _path2.default.join(process.cwd(), "public", thumbPath);
|
|
758
758
|
try {
|
|
759
759
|
await _fs.promises.unlink(absoluteThumbPath);
|
|
@@ -769,7 +769,7 @@ async function handleDelete(request) {
|
|
|
769
769
|
const isInImagesFolder = itemPath.startsWith("public/images/");
|
|
770
770
|
if (!isInImagesFolder && entry) {
|
|
771
771
|
if (!isPushedToCloud) {
|
|
772
|
-
for (const thumbPath of
|
|
772
|
+
for (const thumbPath of _chunkWOHZ4LYGjs.getAllThumbnailPaths.call(void 0, imageKey)) {
|
|
773
773
|
const absoluteThumbPath = _path2.default.join(process.cwd(), "public", thumbPath);
|
|
774
774
|
try {
|
|
775
775
|
await _fs.promises.unlink(absoluteThumbPath);
|
|
@@ -881,8 +881,8 @@ async function handleRename(request) {
|
|
|
881
881
|
const newKey = "/" + newRelativePath;
|
|
882
882
|
if (meta[oldKey]) {
|
|
883
883
|
const entry = meta[oldKey];
|
|
884
|
-
const oldThumbPaths =
|
|
885
|
-
const newThumbPaths =
|
|
884
|
+
const oldThumbPaths = _chunkWOHZ4LYGjs.getAllThumbnailPaths.call(void 0, oldKey);
|
|
885
|
+
const newThumbPaths = _chunkWOHZ4LYGjs.getAllThumbnailPaths.call(void 0, newKey);
|
|
886
886
|
for (let i = 0; i < oldThumbPaths.length; i++) {
|
|
887
887
|
const oldThumbPath = _path2.default.join(process.cwd(), "public", oldThumbPaths[i]);
|
|
888
888
|
const newThumbPath = _path2.default.join(process.cwd(), "public", newThumbPaths[i]);
|
|
@@ -966,7 +966,7 @@ async function handleMoveStream(request) {
|
|
|
966
966
|
const fileCdnUrl = isInCloud && entry.c !== void 0 ? cdnUrls[entry.c] : void 0;
|
|
967
967
|
const isRemote = isInCloud && (!r2PublicUrl || fileCdnUrl !== r2PublicUrl);
|
|
968
968
|
const isPushedToR2 = isInCloud && r2PublicUrl && fileCdnUrl === r2PublicUrl;
|
|
969
|
-
const hasProcessedThumbnails =
|
|
969
|
+
const hasProcessedThumbnails = _chunkWOHZ4LYGjs.isProcessed.call(void 0, entry);
|
|
970
970
|
try {
|
|
971
971
|
if (isRemote && isImage) {
|
|
972
972
|
const remoteUrl = `${fileCdnUrl}${oldKey}`;
|
|
@@ -1029,8 +1029,8 @@ async function handleMoveStream(request) {
|
|
|
1029
1029
|
await _fs.promises.rename(absolutePath, newAbsolutePath);
|
|
1030
1030
|
const stats = await _fs.promises.stat(newAbsolutePath);
|
|
1031
1031
|
if (stats.isFile() && isImage && entry) {
|
|
1032
|
-
const oldThumbPaths =
|
|
1033
|
-
const newThumbPaths =
|
|
1032
|
+
const oldThumbPaths = _chunkWOHZ4LYGjs.getAllThumbnailPaths.call(void 0, oldKey);
|
|
1033
|
+
const newThumbPaths = _chunkWOHZ4LYGjs.getAllThumbnailPaths.call(void 0, newKey);
|
|
1034
1034
|
for (let j = 0; j < oldThumbPaths.length; j++) {
|
|
1035
1035
|
const oldThumbPath = _path2.default.join(process.cwd(), "public", oldThumbPaths[j]);
|
|
1036
1036
|
const newThumbPath = _path2.default.join(process.cwd(), "public", newThumbPaths[j]);
|
|
@@ -1156,8 +1156,8 @@ async function handleSync(request) {
|
|
|
1156
1156
|
})
|
|
1157
1157
|
);
|
|
1158
1158
|
urlsToPurge.push(`${publicUrl}${imageKey}`);
|
|
1159
|
-
if (!isRemote &&
|
|
1160
|
-
for (const thumbPath of
|
|
1159
|
+
if (!isRemote && _chunkWOHZ4LYGjs.isProcessed.call(void 0, entry)) {
|
|
1160
|
+
for (const thumbPath of _chunkWOHZ4LYGjs.getAllThumbnailPaths.call(void 0, imageKey)) {
|
|
1161
1161
|
const localPath = _path2.default.join(process.cwd(), "public", thumbPath);
|
|
1162
1162
|
try {
|
|
1163
1163
|
const fileBuffer = await _fs.promises.readFile(localPath);
|
|
@@ -1177,7 +1177,7 @@ async function handleSync(request) {
|
|
|
1177
1177
|
entry.c = cdnIndex;
|
|
1178
1178
|
if (!isRemote) {
|
|
1179
1179
|
const originalLocalPath = _path2.default.join(process.cwd(), "public", imageKey);
|
|
1180
|
-
for (const thumbPath of
|
|
1180
|
+
for (const thumbPath of _chunkWOHZ4LYGjs.getAllThumbnailPaths.call(void 0, imageKey)) {
|
|
1181
1181
|
const localPath = _path2.default.join(process.cwd(), "public", thumbPath);
|
|
1182
1182
|
try {
|
|
1183
1183
|
await _fs.promises.unlink(localPath);
|
|
@@ -1255,7 +1255,7 @@ async function handleReprocess(request) {
|
|
|
1255
1255
|
if (isInOurR2) {
|
|
1256
1256
|
updatedEntry.c = existingCdnIndex;
|
|
1257
1257
|
await uploadToCdn(imageKey);
|
|
1258
|
-
for (const thumbPath of
|
|
1258
|
+
for (const thumbPath of _chunkWOHZ4LYGjs.getAllThumbnailPaths.call(void 0, imageKey)) {
|
|
1259
1259
|
urlsToPurge.push(`${publicUrl}${thumbPath}`);
|
|
1260
1260
|
}
|
|
1261
1261
|
await deleteLocalThumbnails(imageKey);
|
|
@@ -1308,7 +1308,7 @@ async function handleProcessAllStream() {
|
|
|
1308
1308
|
for (const [key, entry] of getFileEntries(meta)) {
|
|
1309
1309
|
const fileName = _path2.default.basename(key);
|
|
1310
1310
|
if (!isImageFile(fileName)) continue;
|
|
1311
|
-
if (!
|
|
1311
|
+
if (!_chunkWOHZ4LYGjs.isProcessed.call(void 0, entry)) {
|
|
1312
1312
|
imagesToProcess.push({ key, entry });
|
|
1313
1313
|
} else {
|
|
1314
1314
|
alreadyProcessed++;
|
|
@@ -1358,9 +1358,9 @@ async function handleProcessAllStream() {
|
|
|
1358
1358
|
await _fs.promises.writeFile(destPath, buffer);
|
|
1359
1359
|
meta[key] = {
|
|
1360
1360
|
...entry,
|
|
1361
|
-
o:
|
|
1361
|
+
o: { w: 0, h: 0 },
|
|
1362
1362
|
b: "",
|
|
1363
|
-
f:
|
|
1363
|
+
f: { w: 0, h: 0 }
|
|
1364
1364
|
// SVG has "full" to indicate processed
|
|
1365
1365
|
};
|
|
1366
1366
|
if (isRemote) {
|
|
@@ -1375,7 +1375,7 @@ async function handleProcessAllStream() {
|
|
|
1375
1375
|
}
|
|
1376
1376
|
if (isInOurR2) {
|
|
1377
1377
|
await uploadToCdn(key);
|
|
1378
|
-
for (const thumbPath of
|
|
1378
|
+
for (const thumbPath of _chunkWOHZ4LYGjs.getAllThumbnailPaths.call(void 0, key)) {
|
|
1379
1379
|
urlsToPurge.push(`${publicUrl}${thumbPath}`);
|
|
1380
1380
|
}
|
|
1381
1381
|
await deleteLocalThumbnails(key);
|
|
@@ -1394,7 +1394,7 @@ async function handleProcessAllStream() {
|
|
|
1394
1394
|
const trackedPaths = /* @__PURE__ */ new Set();
|
|
1395
1395
|
for (const [imageKey, entry] of getFileEntries(meta)) {
|
|
1396
1396
|
if (entry.c === void 0) {
|
|
1397
|
-
for (const thumbPath of
|
|
1397
|
+
for (const thumbPath of _chunkWOHZ4LYGjs.getAllThumbnailPaths.call(void 0, imageKey)) {
|
|
1398
1398
|
trackedPaths.add(thumbPath);
|
|
1399
1399
|
}
|
|
1400
1400
|
}
|
|
@@ -1566,7 +1566,7 @@ async function handleScanStream() {
|
|
|
1566
1566
|
if (isImage) {
|
|
1567
1567
|
const ext = _path2.default.extname(relativePath).toLowerCase();
|
|
1568
1568
|
if (ext === ".svg") {
|
|
1569
|
-
meta[imageKey] = { o:
|
|
1569
|
+
meta[imageKey] = { o: { w: 0, h: 0 }, b: "" };
|
|
1570
1570
|
} else {
|
|
1571
1571
|
try {
|
|
1572
1572
|
const buffer = await _fs.promises.readFile(fullPath);
|
|
@@ -1574,11 +1574,11 @@ async function handleScanStream() {
|
|
|
1574
1574
|
const { data, info } = await _sharp2.default.call(void 0, buffer).resize(32, 32, { fit: "inside" }).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
1575
1575
|
const blurhash = _blurhash.encode.call(void 0, new Uint8ClampedArray(data), info.width, info.height, 4, 4);
|
|
1576
1576
|
meta[imageKey] = {
|
|
1577
|
-
o:
|
|
1577
|
+
o: { w: metadata.width || 0, h: metadata.height || 0 },
|
|
1578
1578
|
b: blurhash
|
|
1579
1579
|
};
|
|
1580
1580
|
} catch (e37) {
|
|
1581
|
-
meta[imageKey] = { o:
|
|
1581
|
+
meta[imageKey] = { o: { w: 0, h: 0 } };
|
|
1582
1582
|
}
|
|
1583
1583
|
}
|
|
1584
1584
|
} else {
|
|
@@ -1595,8 +1595,8 @@ async function handleScanStream() {
|
|
|
1595
1595
|
const expectedThumbnails = /* @__PURE__ */ new Set();
|
|
1596
1596
|
const fileEntries = getFileEntries(meta);
|
|
1597
1597
|
for (const [imageKey, entry] of fileEntries) {
|
|
1598
|
-
if (entry.c === void 0 &&
|
|
1599
|
-
for (const thumbPath of
|
|
1598
|
+
if (entry.c === void 0 && _chunkWOHZ4LYGjs.isProcessed.call(void 0, entry)) {
|
|
1599
|
+
for (const thumbPath of _chunkWOHZ4LYGjs.getAllThumbnailPaths.call(void 0, imageKey)) {
|
|
1600
1600
|
expectedThumbnails.add(thumbPath);
|
|
1601
1601
|
}
|
|
1602
1602
|
}
|
|
@@ -1728,7 +1728,7 @@ async function processRemoteImage(url) {
|
|
|
1728
1728
|
const { data, info } = await _sharp2.default.call(void 0, buffer).resize(32, 32, { fit: "inside" }).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
1729
1729
|
const blurhash = _blurhash.encode.call(void 0, new Uint8ClampedArray(data), info.width, info.height, 4, 4);
|
|
1730
1730
|
return {
|
|
1731
|
-
o:
|
|
1731
|
+
o: { w: metadata.width || 0, h: metadata.height || 0 },
|
|
1732
1732
|
b: blurhash
|
|
1733
1733
|
};
|
|
1734
1734
|
}
|