@@ -42,15 +42,14 @@ import {
4242 STUDIO_MOTION_ORIGINAL_VISIBILITY_ATTR ,
4343} from "./studioMotionTypes" ;
4444import {
45- buildPathOffsetPatches ,
4645 buildClearPathOffsetPatches ,
4746 buildBoxSizePatches ,
4847 buildClearBoxSizePatches ,
4948 buildClearRotationPatches ,
5049 buildMotionPatches ,
5150 buildClearMotionPatches ,
5251} from "./manualEditsDomPatches" ;
53- import { applyStudioBoxSize , applyStudioPathOffset } from "./manualEditsDom" ;
52+ import { applyStudioBoxSize } from "./manualEditsDom" ;
5453
5554/* ── helpers ── */
5655
@@ -71,39 +70,7 @@ function assertClearCoversKeys(buildOps: PatchOperation[], clearOps: PatchOperat
7170
7271/* ── Path offset ─────────────────────────────────────────────────────────── */
7372
74- describe ( "buildPathOffsetPatches / buildClearPathOffsetPatches" , ( ) => {
75- function populatedPathEl ( ) : HTMLElement {
76- const e = div ( ) ;
77- e . style . setProperty ( STUDIO_OFFSET_X_PROP , "10px" ) ;
78- e . style . setProperty ( STUDIO_OFFSET_Y_PROP , "20px" ) ;
79- e . style . setProperty ( "translate" , "10px 20px" ) ;
80- e . setAttribute ( STUDIO_ORIGINAL_TRANSLATE_ATTR , "5px 10px" ) ;
81- e . setAttribute ( STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR , "3px" ) ;
82- e . style . setProperty ( "display" , "flex" ) ;
83- e . setAttribute ( STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR , "block" ) ;
84- return e ;
85- }
86-
87- it ( "populated: captures offset styles, attrs, display, and transform-display marker in declaration order" , ( ) => {
88- const ops = buildPathOffsetPatches ( populatedPathEl ( ) ) ;
89- expect ( ops ) . toEqual ( [
90- { type : "inline-style" , property : STUDIO_OFFSET_X_PROP , value : "10px" } ,
91- { type : "inline-style" , property : STUDIO_OFFSET_Y_PROP , value : "20px" } ,
92- { type : "inline-style" , property : "translate" , value : "10px 20px" } ,
93- { type : "attribute" , property : STUDIO_PATH_OFFSET_ATTR , value : "true" } ,
94- { type : "attribute" , property : STUDIO_ORIGINAL_TRANSLATE_ATTR , value : "5px 10px" } ,
95- { type : "attribute" , property : STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR , value : "3px" } ,
96- { type : "inline-style" , property : "display" , value : "flex" } ,
97- { type : "attribute" , property : STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR , value : "block" } ,
98- ] ) ;
99- } ) ;
100-
101- it ( "empty: bare element yields only the path-offset marker" , ( ) => {
102- expect ( buildPathOffsetPatches ( div ( ) ) ) . toEqual ( [
103- { type : "attribute" , property : STUDIO_PATH_OFFSET_ATTR , value : "true" } ,
104- ] ) ;
105- } ) ;
106-
73+ describe ( "buildClearPathOffsetPatches" , ( ) => {
10774 it ( "clear: restores translate from STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR and display from STUDIO_ORIGINAL_TRANSFORM_DISPLAY_ATTR" , ( ) => {
10875 const e = div ( ) ;
10976 e . setAttribute ( STUDIO_ORIGINAL_INLINE_TRANSLATE_ATTR , "5px" ) ;
@@ -127,11 +94,6 @@ describe("buildPathOffsetPatches / buildClearPathOffsetPatches", () => {
12794 const ops = buildClearPathOffsetPatches ( e ) ;
12895 expect ( ops . find ( ( o ) => o . property === "translate" ) ?. value ) . toBeNull ( ) ;
12996 } ) ;
130-
131- it ( "build/clear symmetry: clear addresses every {type,property} key that build emits" , ( ) => {
132- const e = populatedPathEl ( ) ;
133- assertClearCoversKeys ( buildPathOffsetPatches ( e ) , buildClearPathOffsetPatches ( e ) ) ;
134- } ) ;
13597} ) ;
13698
13799/* ── Box size ────────────────────────────────────────────────────────────── */
@@ -286,52 +248,6 @@ describe("buildBoxSizePatches / buildClearBoxSizePatches", () => {
286248 } ) ;
287249} ) ;
288250
289- /* ── Combined box-size + path-offset (anchored-corner resize) ──────────────── */
290-
291- describe ( "anchored-corner combined patch: [...buildBoxSizePatches, ...buildPathOffsetPatches]" , ( ) => {
292- // NW/NE/SW resize commits size AND anchor offset in ONE persist. The two
293- // builders read the same already-mutated element and are concatenated; this
294- // is only safe if their {type,property} keys are disjoint (no builder
295- // overwrites the other's op when the source patcher applies them in order).
296- it ( "concatenation of both builders emits disjoint {type,property} keys (no collision)" , ( ) => {
297- const e = div ( ) ;
298- applyStudioBoxSize ( e , { width : 300 , height : 200 } ) ;
299- applyStudioPathOffset ( e , { x : 10 , y : 20 } ) ;
300-
301- const combined = [ ...buildBoxSizePatches ( e ) , ...buildPathOffsetPatches ( e ) ] ;
302- const keys = combined . map ( opKey ) ;
303- expect ( new Set ( keys ) . size , `duplicate {type,property} key in combined patch: ${ keys } ` ) . toBe (
304- keys . length ,
305- ) ;
306- } ) ;
307-
308- it ( "combined patch carries BOTH markers so a soft-reload re-hydrates size and offset together" , ( ) => {
309- const e = div ( ) ;
310- applyStudioBoxSize ( e , { width : 300 , height : 200 } ) ;
311- applyStudioPathOffset ( e , { x : 10 , y : 20 } ) ;
312-
313- const combined = [ ...buildBoxSizePatches ( e ) , ...buildPathOffsetPatches ( e ) ] ;
314- const has = ( property : string ) =>
315- combined . some ( ( op ) => op . type === "attribute" && op . property === property ) ;
316- expect ( has ( STUDIO_BOX_SIZE_ATTR ) ) . toBe ( true ) ;
317- expect ( has ( STUDIO_PATH_OFFSET_ATTR ) ) . toBe ( true ) ;
318- } ) ;
319-
320- it ( "order is size-first: every box-size op precedes every path-offset op" , ( ) => {
321- const e = div ( ) ;
322- applyStudioBoxSize ( e , { width : 300 , height : 200 } ) ;
323- applyStudioPathOffset ( e , { x : 10 , y : 20 } ) ;
324-
325- const boxKeys = new Set ( buildBoxSizePatches ( e ) . map ( opKey ) ) ;
326- const combined = [ ...buildBoxSizePatches ( e ) , ...buildPathOffsetPatches ( e ) ] ;
327- const lastBoxIdx = combined . reduce ( ( acc , op , i ) => ( boxKeys . has ( opKey ( op ) ) ? i : acc ) , - 1 ) ;
328- const firstOffsetIdx = combined . findIndex (
329- ( op ) => op . type === "attribute" && op . property === STUDIO_PATH_OFFSET_ATTR ,
330- ) ;
331- expect ( firstOffsetIdx ) . toBeGreaterThan ( lastBoxIdx ) ;
332- } ) ;
333- } ) ;
334-
335251/* ── Rotation ────────────────────────────────────────────────────────────── */
336252
337253describe ( "buildClearRotationPatches" , ( ) => {
0 commit comments