mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
refactor: drop NodeLayout.collapsedSize, keep it on the ynode only
collapsedSize was added to NodeLayout earlier in this PR as a first-class
field alongside a special-case tail in yNodeToLayout. Nothing outside of
the mapper actually reads it via the layout shape — measure() goes
through LiteGraph.getCollapsedSize and reads the ynode directly via
layoutStore.getNodeCollapsedSize, bypassing NodeLayout entirely.
With the per-frame cache removed in 2693ec256, there is also no longer
any reason to expose the value on NodeLayout as a feeder for a future
reactive-ref-based cache (Y.Map.get is O(1) and not a bottleneck).
Treat this as undoing an unneeded addition from this PR rather than
introducing new indirection:
- Remove collapsedSize from NodeLayout (types.ts).
- Drop the dead conditional write in layoutToYNode and the
special-case tail in yNodeToLayout — mappers.ts is now identical to
main.
- layoutStore.updateNodeCollapsedSize / getNodeCollapsedSize /
clearNodeCollapsedSize keep writing and reading collapsedSize on
the ynode via Y.Map's string-keyed API.
This commit is contained in:
@@ -242,7 +242,8 @@ class LayoutStoreImpl implements LayoutStore {
|
||||
get: () => {
|
||||
track()
|
||||
const ynode = this.ynodes.get(nodeId)
|
||||
return ynode ? yNodeToLayout(ynode) : null
|
||||
const layout = ynode ? yNodeToLayout(ynode) : null
|
||||
return layout
|
||||
},
|
||||
set: (newLayout: NodeLayout | null) => {
|
||||
if (newLayout === null) {
|
||||
|
||||
@@ -50,9 +50,6 @@ export interface NodeLayout {
|
||||
visible: boolean
|
||||
// Computed bounds for hit testing
|
||||
bounds: Bounds
|
||||
// Collapsed node dimensions (Vue mode only, separate from size to
|
||||
// preserve expanded size across collapse/expand cycles)
|
||||
collapsedSize?: Size
|
||||
}
|
||||
|
||||
export interface SlotLayout {
|
||||
|
||||
@@ -21,7 +21,6 @@ export function layoutToYNode(layout: NodeLayout): NodeLayoutMap {
|
||||
ynode.set('zIndex', layout.zIndex)
|
||||
ynode.set('visible', layout.visible)
|
||||
ynode.set('bounds', layout.bounds)
|
||||
if (layout.collapsedSize) ynode.set('collapsedSize', layout.collapsedSize)
|
||||
return ynode
|
||||
}
|
||||
|
||||
@@ -35,7 +34,7 @@ function getOr<K extends keyof NodeLayout>(
|
||||
}
|
||||
|
||||
export function yNodeToLayout(ynode: NodeLayoutMap): NodeLayout {
|
||||
const layout: NodeLayout = {
|
||||
return {
|
||||
id: getOr(ynode, 'id', NODE_LAYOUT_DEFAULTS.id),
|
||||
position: getOr(ynode, 'position', NODE_LAYOUT_DEFAULTS.position),
|
||||
size: getOr(ynode, 'size', NODE_LAYOUT_DEFAULTS.size),
|
||||
@@ -43,8 +42,4 @@ export function yNodeToLayout(ynode: NodeLayoutMap): NodeLayout {
|
||||
visible: getOr(ynode, 'visible', NODE_LAYOUT_DEFAULTS.visible),
|
||||
bounds: getOr(ynode, 'bounds', NODE_LAYOUT_DEFAULTS.bounds)
|
||||
}
|
||||
const collapsedSize = ynode.get('collapsedSize')
|
||||
if (collapsedSize)
|
||||
layout.collapsedSize = collapsedSize as NodeLayout['collapsedSize']
|
||||
return layout
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user