fix(pack): lazy-load sharp and verify unpacked natives

Avoid crashing Electron at startup when sharp is corrupt, and fail pack if asarUnpack natives look truncated.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Ivan Fontosh
2026-08-07 07:47:36 +08:00
parent 4456eb0277
commit 8d5a68c71e
8 changed files with 370 additions and 7 deletions
+3 -1
View File
@@ -5,7 +5,8 @@ import path from 'node:path';
import { promisify } from 'node:util';
import ffmpegStatic from 'ffmpeg-static';
import sharp from 'sharp';
import { getSharp } from './sharpRuntime.mjs';
const execFileAsync = promisify(execFile);
@@ -21,6 +22,7 @@ export async function generateScenePreviewThumbnailBytes(
kind: 'image' | 'video',
): Promise<Buffer | null> {
try {
const sharp = getSharp();
if (kind === 'image') {
return await sharp(source)
.rotate()