MCPcopy Index your code
hub / github.com/massCodeIO/massCode / normalizeWindowBounds

Function normalizeWindowBounds

src/main/windowBounds.ts:42–85  ·  view source on GitHub ↗
(
  value: unknown,
  displays: WindowBoundsDisplay[],
)

Source from the content-addressed store, hash-verified

40}
41
42export function normalizeWindowBounds(
43 value: unknown,
44 displays: WindowBoundsDisplay[],
45): Partial<Rectangle> {
46 if (!isRecord(value)) {
47 return {}
48 }
49
50 const width = readDimension(value.width)
51 const height = readDimension(value.height)
52 const x = readNumber(value.x)
53 const y = readNumber(value.y)
54 const bounds: Partial<Rectangle> = {}
55
56 if (width) {
57 bounds.width = width
58 }
59
60 if (height) {
61 bounds.height = height
62 }
63
64 if (x === undefined || y === undefined) {
65 return bounds
66 }
67
68 const positionedBounds: Rectangle = {
69 x,
70 y,
71 width: width ?? DEFAULT_WINDOW_BOUNDS.width,
72 height: height ?? DEFAULT_WINDOW_BOUNDS.height,
73 }
74
75 if (
76 displays.some(display =>
77 hasVisibleIntersection(positionedBounds, display.workArea),
78 )
79 ) {
80 bounds.x = x
81 bounds.y = y
82 }
83
84 return bounds
85}

Callers 2

createWindowFunction · 0.90

Calls 4

readDimensionFunction · 0.85
hasVisibleIntersectionFunction · 0.85
isRecordFunction · 0.70
readNumberFunction · 0.70

Tested by

no test coverage detected