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:
jaeone94
2026-04-15 17:31:58 +09:00
parent 4ded224173
commit 38934fc3b5
3 changed files with 3 additions and 10 deletions

View File

@@ -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) {

View File

@@ -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 {

View File

@@ -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
}