mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-04 13:12:10 +00:00
Fix Rectangle/Rect type compatibility and unify type system
This commit addresses PR review comments by fixing the fundamental type incompatibility between Rectangle (Array<number>) and strict tuple types (Rect = [x, y, width, height]). Key changes: - Updated Rectangle class methods to accept both Rect and Rectangle unions - Fixed all measure functions (containsRect, overlapBounding, etc.) to accept Rectangle - Updated boundingRect interfaces to consistently use Rectangle instead of Rect - Fixed all tests and Vue components to use Rectangle instead of array literals - Resolved Point type conflicts between litegraph and pathRenderer modules - Removed ReadOnlyPoint types and unified with Point arrays The type system is now consistent: boundingRect properties return Rectangle objects with full functionality, while Rect remains as a simple tuple type for data interchange.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { afterEach, beforeEach, describe, expect, vi } from 'vitest'
|
||||
|
||||
import type { INodeInputSlot, Point } from '@/lib/litegraph/src/litegraph'
|
||||
import { Rectangle } from '@/lib/litegraph/src/litegraph'
|
||||
import { LGraphNode, LiteGraph } from '@/lib/litegraph/src/litegraph'
|
||||
import { LGraph } from '@/lib/litegraph/src/litegraph'
|
||||
import { NodeInputSlot } from '@/lib/litegraph/src/litegraph'
|
||||
@@ -571,7 +572,7 @@ describe('LGraphNode', () => {
|
||||
name: 'test_in',
|
||||
type: 'string',
|
||||
link: null,
|
||||
boundingRect: new Float32Array([0, 0, 0, 0])
|
||||
boundingRect: new Rectangle(0, 0, 0, 0)
|
||||
}
|
||||
})
|
||||
test('should return position based on title height when collapsed', () => {
|
||||
@@ -594,7 +595,7 @@ describe('LGraphNode', () => {
|
||||
name: 'test_in_2',
|
||||
type: 'number',
|
||||
link: null,
|
||||
boundingRect: new Float32Array([0, 0, 0, 0])
|
||||
boundingRect: new Rectangle(0, 0, 0, 0)
|
||||
}
|
||||
node.inputs = [inputSlot, inputSlot2]
|
||||
const slotIndex = 0
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// TODO: Fix these tests after migration
|
||||
import { test as baseTest } from 'vitest'
|
||||
|
||||
import { Rectangle } from '@/lib/litegraph/src/infrastructure/Rectangle'
|
||||
import type { Point, Rect } from '@/lib/litegraph/src/interfaces'
|
||||
import {
|
||||
addDirectionalOffset,
|
||||
@@ -132,8 +133,8 @@ test('snapPoint correctly snaps points to grid', ({ expect }) => {
|
||||
|
||||
test('createBounds correctly creates bounding box', ({ expect }) => {
|
||||
const objects = [
|
||||
{ boundingRect: [0, 0, 10, 10] as Rect },
|
||||
{ boundingRect: [5, 5, 10, 10] as Rect }
|
||||
{ boundingRect: new Rectangle(0, 0, 10, 10) },
|
||||
{ boundingRect: new Rectangle(5, 5, 10, 10) }
|
||||
]
|
||||
|
||||
const defaultBounds = createBounds(objects)
|
||||
|
||||
Reference in New Issue
Block a user