MCPcopy
hub / github.com/simstudioai/sim / noteOverlappedBlockBefore

Function noteOverlappedBlockBefore

apps/sim/lib/workflows/autolayout/utils.ts:358–376  ·  view source on GitHub ↗

* Determines whether a note and a block overlapped at their pre-layout * positions. Used by targeted layout to distinguish overlaps introduced by the * current pass from arrangements that already existed.

(
  previousBlocks: Record<string, BlockState>,
  noteId: string,
  blockId: string
)

Source from the content-addressed store, hash-verified

356 * current pass from arrangements that already existed.
357 */
358function noteOverlappedBlockBefore(
359 previousBlocks: Record<string, BlockState>,
360 noteId: string,
361 blockId: string
362): boolean {
363 const previousNote = previousBlocks[noteId]
364 const previousBlock = previousBlocks[blockId]
365 if (!previousNote || !previousBlock) return false
366
367 // A block without a finite prior position was not yet placed on the canvas,
368 // so it could not have overlapped anything before this pass.
369 if (!hasFinitePosition(previousNote) || !hasFinitePosition(previousBlock)) return false
370
371 // Derive dimensions from the prior blocks so a resize between passes does not
372 // pair new dimensions with the old position.
373 const noteBox = createBoundingBox(previousNote.position, getNoteDimensions(previousNote))
374 const blockBox = createBoundingBox(previousBlock.position, getBlockMetrics(previousBlock))
375 return boxesOverlap(blockBox, noteBox)
376}
377
378export interface ResolveNoteOverlapsOptions {
379 /**

Callers 1

resolveNoteOverlapsFunction · 0.85

Calls 5

hasFinitePositionFunction · 0.85
createBoundingBoxFunction · 0.85
getNoteDimensionsFunction · 0.85
getBlockMetricsFunction · 0.85
boxesOverlapFunction · 0.85

Tested by

no test coverage detected