feat: layer effects, bucket fill, simple brush

This commit is contained in:
2026-05-21 00:02:12 +07:00
parent bcf4650c70
commit e7dd9420e7
47 changed files with 1675 additions and 1038 deletions
+26
View File
@@ -0,0 +1,26 @@
import { ProjectFileSchema, type Project, type ProjectFile } from "@pien-studio/types";
import { normalizeProject } from "./normalize";
export function serializeProjectFile(project: Project, options?: { checkpointCount?: number }): string {
const document: ProjectFile = {
format: "pien.project",
version: 1,
exportedAt: new Date().toISOString(),
app: { name: "pien.studio", platform: "web" },
project,
assets: [],
history: { checkpointCount: options?.checkpointCount ?? 0 },
};
return JSON.stringify(document, null, 2);
}
export function parseProjectFile(raw: string): { ok: true; project: Project } | { ok: false; error: string } {
try {
const data = JSON.parse(raw) as unknown;
const result = ProjectFileSchema.safeParse(data);
if (result.success) return { ok: true, project: normalizeProject(result.data.project) };
return { ok: false, error: "Invalid project format" };
} catch {
return { ok: false, error: "Invalid JSON" };
}
}