Skip to content

Commit

Permalink
remove spyMetadata and domMetadata references (#6266)
Browse files Browse the repository at this point in the history
**Problem:**
A few places in the codebase refer to EditorState.domMetadata and
EditorState.spyMetadata. This was never supposed to be happening, but it
was never urgent to fix this, because both the domMetadata and
spyMetadata behaved in a reliable way. But the upcoming dom-walker
refactor pull requests will remove these helper states, and unify
everything into EditorState.jsxMetadata.

**Fix:**
To make the big PR cleaner, I am now deleting uses of spyMetadata and
domMetadata, and move all code to only use jsxMetadata
  • Loading branch information
balazsbajorics authored Aug 28, 2024
1 parent f0e3337 commit 454cc9a
Show file tree
Hide file tree
Showing 6 changed files with 259 additions and 1,860 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ describe('Flow Reorder Strategy (Mixed Display Type)', () => {

await renderResult.getDispatchFollowUpActionsFinished()

expect(Object.keys(renderResult.getEditorState().editor.spyMetadata)).toEqual([
expect(Object.keys(renderResult.getEditorState().editor.jsxMetadata)).toEqual([
'utopia-storyboard-uid',
'utopia-storyboard-uid/scene-aaa',
'utopia-storyboard-uid/scene-aaa/app-entity',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,10 @@ export function getReparentOutcomeMultiselect(

export function cursorForMissingReparentedItems(
reparentedToPaths: Array<ElementPath>,
spyMetadata: ElementInstanceMetadataMap,
metadata: ElementInstanceMetadataMap,
): CSSCursor | null {
for (const reparentedToPath of reparentedToPaths) {
if (!(EP.toString(reparentedToPath) in spyMetadata)) {
if (!(EP.toString(reparentedToPath) in metadata)) {
return CSSCursor.NotPermitted
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useDelayedEditorState } from '../../canvas-strategies/canvas-strategies
export function getCursorFromEditor(editorState: EditorState): CSSCursor | null {
const forMissingReparentedItems = cursorForMissingReparentedItems(
editorState.canvas.controls.reparentedToPaths,
editorState.spyMetadata,
editorState.jsxMetadata,
)
return forMissingReparentedItems ?? editorState.canvas.cursor
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1854,8 +1854,7 @@ export default function Index() {
// Nothing should have changed
expect({ left: absoluteDiv.style.left, top: absoluteDiv.style.top }).toEqual(styleBefore)

// Ensure we have both types of metadata for all paths
expect(Object.keys(renderResult.getEditorState().editor.spyMetadata)).toEqual([
expect(Object.keys(renderResult.getEditorState().editor.jsxMetadata)).toEqual([
'sb',
'sb/remix-scene',
'sb/remix-scene:app',
Expand All @@ -1867,18 +1866,6 @@ export default function Index() {
'sb/remix-scene:app/outlet:index/flex-div/child-2',
'sb/remix-scene:app/outlet:index/flex-div/child-3',
])
expect(Object.keys(renderResult.getEditorState().editor.domMetadata)).toEqual([
'sb/remix-scene:app/outlet:index/absolute-div',
'sb/remix-scene:app/outlet:index/flex-div/child-1',
'sb/remix-scene:app/outlet:index/flex-div/child-2',
'sb/remix-scene:app/outlet:index/flex-div/child-3',
'sb/remix-scene:app/outlet:index/flex-div',
'sb/remix-scene:app/outlet:index',
'sb/remix-scene:app/outlet',
'sb/remix-scene:app',
'sb/remix-scene',
'sb',
])
})

it('draw to insert into Remix', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,39 +240,6 @@ xdescribe('Spy Wrapper Tests For React Three Fiber', () => {
}
`,
)
const domMetadata = getEditorState().editor.domMetadata
const sanitizedDomMetadata = simplifiedMetadataMap(domMetadata)
matchInlineSnapshotBrowser(
sanitizedDomMetadata,
`
Object {
"storyboard": Object {
"name": "Storyboard",
},
"storyboard/scene-1": Object {
"name": "div",
},
"storyboard/scene-1/canvas-app": Object {
"name": "div",
},
"storyboard/scene-1/canvas-app:canvas-app-div": Object {
"name": "div",
},
"storyboard/scene-2": Object {
"name": "div",
},
"storyboard/scene-2/app": Object {
"name": "div",
},
"storyboard/scene-2/app:app-root": Object {
"name": "div",
},
"storyboard/scene-2/app:app-root/app-inner-div": Object {
"name": "div",
},
}
`,
)
const jsxMetadata = getEditorState().editor.jsxMetadata
const sanitizedJsxMetadata = simplifiedMetadataMap(jsxMetadata)
matchInlineSnapshotBrowser(
Expand Down
Loading

0 comments on commit 454cc9a

Please sign in to comment.