mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-25 16:37:32 +00:00
* test(studio): a second sealed resize of a scaled layer starts from its saved size * fix(studio): a second sealed resize of a scaled layer no longer jumps and saves the jump * test(studio): count and time the two-resize bench cases * test(studio): a sealed frame's GSAP values are read again after a save reruns its script * fix(studio): a second sealed resize scales from the size the first one saved * test(studio): leave GSAP value reads out of the sealed save's sent-edit list * refactor(studio): name the sealed rerun's re-read so the answer handler stays simple * test(studio): a sealed drag on GSAP's route leaves no offset on the stand-in, one re-read per rerun * fix(studio): a sealed drag that GSAP saves clears Studio's offset, as an unsealed one does * fix(studio): a sealed drag of a GSAP-held layer moves GSAP's x/y, as an open preview does * fix(studio): a sealed gesture recording moves the layer live in the preview * fix(studio): a sealed drag draws the rounded position an open preview's drag writes * test(studio): a plain layer's frame draft is the open preview's rounded offset less its start * fix(studio): a sealed recording sets every recorded GSAP value live, as unsealed does * refactor(core): name the checks a recording's draft props pass * fix(studio): queue every sealed recording sample in order instead of replacing a waiting one * fix(studio): drop the move-only draw a merge doubled in the sealed recorder * fix(studio): a sealed restore keeps a later position write, and a rejected undo redraws the drop * fix(studio): a sealed restore keeps each axis a later write set, per landed patch * fix(studio): a sealed restore keeps a tween edit's axes only once that edit has drawn * fix(studio): a failed sealed batch keeps the axes an earlier landed batch queued * fix(studio): a sealed restore shows the base and whatever the timeline draws over it * fix(studio): restoring one sealed draft leaves every other live draft where it is drawn * test(core): another layer's live recording survives a restore or a recording ending * fix(studio): a sealed restore replays only what each live draft draws, rotation included * test(core): the recording-ends row moves the other layer through the root timeline it redraws * test(core): the recording-ends row animates the other layer on the root timeline at the playhead * fix(core): replaying another layer's live recording leaves the playhead where it is * refactor(core): split a live draft's carried rotation and merged props into named steps
32 lines
1.4 KiB
TypeScript
32 lines
1.4 KiB
TypeScript
import { EDITING_ELEMENT_HANDLE, type EditingElementHandle } from "./editingElement";
|
|
|
|
/** `keep-size` drops the drawn translate and keeps the drawn size; `clear` lets the timeline drive what props set.
|
|
* An end naming an older `draft` than the element has does nothing. */
|
|
export type EditingDraftEnd =
|
|
| { handle: EditingElementHandle; end: "keep" | "restore" | "clear" }
|
|
| {
|
|
handle: EditingElementHandle;
|
|
end: "keep" | "restore" | "keep-size" | "clear";
|
|
draft: number;
|
|
};
|
|
|
|
/** `drafts` numbers each element still drawn, for the end that names its draft. */
|
|
export type EditingDraftReply = { drawn: number; drafts: Record<EditingElementHandle, number> };
|
|
|
|
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
Object.prototype.toString.call(value) === "[object Object]";
|
|
|
|
export function parseDraftEnd(value: unknown): EditingDraftEnd | null {
|
|
if (!isRecord(value)) return null;
|
|
const { handle, end, draft } = value;
|
|
if (typeof handle !== "string" || !EDITING_ELEMENT_HANDLE.test(handle)) return null;
|
|
const keys = Object.keys(value).sort().join();
|
|
if (keys === "end,handle")
|
|
return end === "keep" || end === "restore" || end === "clear" ? { handle, end } : null;
|
|
if (keys !== "draft,end,handle" || !Number.isSafeInteger(draft) || (draft as number) < 1)
|
|
return null;
|
|
return end === "keep" || end === "restore" || end === "keep-size" || end === "clear"
|
|
? { handle, end, draft: draft as number }
|
|
: null;
|
|
}
|