♻️ refactor!: massive refactor

This commit is contained in:
2026-05-31 03:04:30 +07:00
parent c1f12c7201
commit df3c944547
86 changed files with 3691 additions and 1129 deletions
+27 -4
View File
@@ -1,4 +1,4 @@
import type { Project } from "@pien-studio/types";
import { getLayerAssetRef, type Project } from "@pien-studio/types";
export function hasProjectChanged(left: Project, right: Project): boolean {
if (left.id !== right.id) return true;
@@ -6,7 +6,11 @@ export function hasProjectChanged(left: Project, right: Project): boolean {
if (left.createdAt !== right.createdAt) return true;
if (left.updatedAt !== right.updatedAt) return true;
if (left.aspectRatio !== right.aspectRatio) return true;
if (left.canvas.width !== right.canvas.width || left.canvas.height !== right.canvas.height || left.canvas.unit !== right.canvas.unit) {
if (
left.canvas.width !== right.canvas.width ||
left.canvas.height !== right.canvas.height ||
left.canvas.unit !== right.canvas.unit
) {
return true;
}
if (left.layers.length !== right.layers.length) return true;
@@ -19,8 +23,6 @@ export function hasProjectChanged(left: Project, right: Project): boolean {
a.id !== b.id ||
a.type !== b.type ||
a.name !== b.name ||
a.assetId !== b.assetId ||
a.sourceUri !== b.sourceUri ||
a.x !== b.x ||
a.y !== b.y ||
a.width !== b.width ||
@@ -33,6 +35,27 @@ export function hasProjectChanged(left: Project, right: Project): boolean {
return true;
}
if (
JSON.stringify(getLayerAssetRef(a)) !==
JSON.stringify(getLayerAssetRef(b))
)
return true;
if (
(a.type === "raster" || a.type === "sticker") &&
(b.type === "raster" || b.type === "sticker") &&
a.runtimeSourceUri !== b.runtimeSourceUri
)
return true;
if (
a.type === "text" &&
b.type === "text" &&
(a.text !== b.text ||
a.fontFamily !== b.fontFamily ||
a.fontSize !== b.fontSize ||
a.color !== b.color)
)
return true;
if (JSON.stringify(a.effects) !== JSON.stringify(b.effects)) return true;
}