Редактор: превью с поворотом, проекты, безопасное сохранение zip, dev-меню
RotatedImage: размер контейнера через clientWidth/Height (не getBoundingClientRect), чтобы cover при 90°/270° работал под zoom React Flow; убраны отладочные логи. Главное меню в dev: пункт «Вид» с DevTools (Ctrl+Shift+I без пустого application menu). Список проектов: project.list без лицензии; список подгружается при неактивной лицензии; ProjectPicker с подсказками; listProjects пропускает битые zip. Сохранение проектов: atomicReplace — замена zip без rm до commit; восстановление *.dnd.zip.tmp при старте; тесты. EditorApp: блокировка UI при открытых окнах презентации и пульта; стили оверлея. Made-with: Cursor
This commit is contained in:
@@ -24,6 +24,7 @@ import { asAssetId, asGraphNodeId, asProjectId } from '../../shared/types/ids';
|
||||
import { getAppSemanticVersion } from '../versionInfo';
|
||||
|
||||
import { reconcileAssetFiles } from './assetPrune';
|
||||
import { recoverOrphanDndZipTmpInRoot, replaceFileAtomic } from './atomicReplace';
|
||||
import { rmWithRetries } from './fsRetry';
|
||||
import { optimizeImageBufferVisuallyLossless } from './optimizeImageImport.lib.mjs';
|
||||
import { getLegacyProjectsRootDirs, getProjectsCacheRootDir, getProjectsRootDir } from './paths';
|
||||
@@ -75,6 +76,7 @@ export class ZipProjectStore {
|
||||
await fs.mkdir(getProjectsRootDir(), { recursive: true });
|
||||
await fs.mkdir(getProjectsCacheRootDir(), { recursive: true });
|
||||
await this.migrateLegacyProjectZipsIfNeeded();
|
||||
await recoverOrphanDndZipTmpInRoot(getProjectsRootDir());
|
||||
}
|
||||
|
||||
/** Копирует .dnd.zip из каталогов с «чужим» app name, если в текущем каталоге такого файла ещё нет. */
|
||||
@@ -135,13 +137,17 @@ export class ZipProjectStore {
|
||||
|
||||
const out: ProjectIndexEntry[] = [];
|
||||
for (const filePath of files) {
|
||||
const project = await readProjectJsonFromZip(filePath);
|
||||
out.push({
|
||||
id: project.id,
|
||||
name: project.meta.name,
|
||||
updatedAt: project.meta.updatedAt,
|
||||
fileName: path.basename(filePath),
|
||||
});
|
||||
try {
|
||||
const project = await readProjectJsonFromZip(filePath);
|
||||
out.push({
|
||||
id: project.id,
|
||||
name: project.meta.name,
|
||||
updatedAt: project.meta.updatedAt,
|
||||
fileName: path.basename(filePath),
|
||||
});
|
||||
} catch {
|
||||
// Один битый архив не должен скрывать остальные проекты в списке.
|
||||
}
|
||||
}
|
||||
out.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
||||
return out;
|
||||
@@ -868,6 +874,11 @@ export class ZipProjectStore {
|
||||
const tmpPath = `${zipPath}.tmp`;
|
||||
await fs.mkdir(path.dirname(zipPath), { recursive: true });
|
||||
await zipDir(cacheDir, tmpPath);
|
||||
const st = await fs.stat(tmpPath).catch(() => null);
|
||||
if (!st?.isFile() || st.size < 22) {
|
||||
await fs.unlink(tmpPath).catch(() => undefined);
|
||||
throw new Error('Сборка архива проекта не удалась (пустой или повреждённый временный файл)');
|
||||
}
|
||||
await replaceFileAtomic(tmpPath, zipPath);
|
||||
}
|
||||
|
||||
@@ -1226,20 +1237,6 @@ async function uniqueDndZipFileName(root: string, preferredBaseFileName: string)
|
||||
}
|
||||
}
|
||||
|
||||
async function replaceFileAtomic(srcPath: string, destPath: string): Promise<void> {
|
||||
try {
|
||||
await fs.rename(srcPath, destPath);
|
||||
} catch {
|
||||
try {
|
||||
await fs.rm(destPath, { force: true });
|
||||
await fs.rename(srcPath, destPath);
|
||||
} catch (second: unknown) {
|
||||
await fs.unlink(srcPath).catch(() => undefined);
|
||||
throw second instanceof Error ? second : new Error(String(second));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function copyFileWithProgress(
|
||||
src: string,
|
||||
dest: string,
|
||||
@@ -1339,17 +1336,7 @@ async function atomicWriteFile(filePath: string, contents: string): Promise<void
|
||||
await fs.mkdir(dir, { recursive: true });
|
||||
const tmp = path.join(dir, `.tmp_${path.basename(filePath)}_${crypto.randomBytes(8).toString('hex')}`);
|
||||
await fs.writeFile(tmp, contents, 'utf8');
|
||||
try {
|
||||
await fs.rename(tmp, filePath);
|
||||
} catch {
|
||||
try {
|
||||
await fs.rm(filePath, { force: true });
|
||||
await fs.rename(tmp, filePath);
|
||||
} catch (second: unknown) {
|
||||
await fs.unlink(tmp).catch(() => undefined);
|
||||
throw second instanceof Error ? second : new Error(String(second));
|
||||
}
|
||||
}
|
||||
await replaceFileAtomic(tmp, filePath);
|
||||
}
|
||||
|
||||
/** Уже сжатые контейнеры/кодеки — в ZIP кладём без deflate, качество не трогаем; project.json и сырьё — deflate 9. */
|
||||
|
||||
Reference in New Issue
Block a user