2026-05-21 00:02:12 +07:00
|
|
|
export { createProject, setCanvasSize } from "./project";
|
|
|
|
|
export { createLayer, addLayer, removeLayer, moveLayer, updateLayerTransform, reorderLayer, setLayerEffect, removeLayerEffect, setLayerVisible, setEffectEnabled } from "./layers";
|
|
|
|
|
export type { LayerFactoryOptions, TransformPatch } from "./layers";
|
|
|
|
|
export { normalizeProject } from "./normalize";
|
|
|
|
|
export { serializeProjectFile, parseProjectFile } from "./serialization";
|
|
|
|
|
export { getEffectDefinition, normalizeEffect } from "./effects/registry";
|
|
|
|
|
export type { EffectDefinition } from "./effects/registry";
|
|
|
|
|
export { faceBlurDefinition } from "./effects/face-blur";
|
|
|
|
|
export { getToolDefinition, getAllTools } from "./tools/registry";
|
|
|
|
|
export type { ToolDefinition, ToolInteractionMode, EditorToolId } from "./tools/registry";
|
2026-05-10 03:06:54 +07:00
|
|
|
|
2026-05-21 00:02:12 +07:00
|
|
|
import type { Layer, LayerEffect, Project } from "@pien-studio/types";
|
|
|
|
|
import { addLayer, moveLayer, removeLayer, reorderLayer, setLayerEffect, updateLayerTransform } from "./layers";
|
|
|
|
|
import { setCanvasSize } from "./project";
|
2026-05-10 03:06:54 +07:00
|
|
|
|
|
|
|
|
export type EditorOperation =
|
|
|
|
|
| { type: "addLayer"; layer: Layer }
|
|
|
|
|
| { type: "removeLayer"; layerId: string }
|
2026-05-21 00:02:12 +07:00
|
|
|
| { type: "moveLayer"; layerId: string; delta: { dx: number; dy: number } }
|
|
|
|
|
| { type: "updateLayerTransform"; layerId: string; patch: import("./layers").TransformPatch }
|
2026-05-10 03:06:54 +07:00
|
|
|
| { type: "reorderLayer"; layerId: string; toIndex: number }
|
2026-05-21 00:02:12 +07:00
|
|
|
| { type: "setLayerEffect"; layerId: string; effect: LayerEffect }
|
2026-05-10 03:06:54 +07:00
|
|
|
| { type: "setCanvasSize"; width: number; height: number; unit?: "px" | "in" | "cm" };
|
|
|
|
|
|
|
|
|
|
export function applyOperation(project: Project, operation: EditorOperation): Project {
|
|
|
|
|
switch (operation.type) {
|
2026-05-21 00:02:12 +07:00
|
|
|
case "addLayer": return addLayer(project, operation.layer);
|
|
|
|
|
case "removeLayer": return removeLayer(project, operation.layerId);
|
|
|
|
|
case "moveLayer": return moveLayer(project, operation.layerId, operation.delta);
|
|
|
|
|
case "updateLayerTransform": return updateLayerTransform(project, operation.layerId, operation.patch);
|
|
|
|
|
case "reorderLayer": return reorderLayer(project, operation.layerId, operation.toIndex);
|
|
|
|
|
case "setLayerEffect": return setLayerEffect(project, operation.layerId, operation.effect);
|
|
|
|
|
case "setCanvasSize": return setCanvasSize(project, operation.width, operation.height, operation.unit);
|
|
|
|
|
default: return project;
|
2026-05-10 03:06:54 +07:00
|
|
|
}
|
|
|
|
|
}
|