Skip to content

Commit aa78c4d

Browse files
committed
refactor(Masonry):[Workspace] replace any casts with proper MouseEvent types
Signed-off-by: Justin Charles <[email protected]>
1 parent 0d71a33 commit aa78c4d

File tree

3 files changed

+227
-256
lines changed

3 files changed

+227
-256
lines changed

modules/masonry/src/brick/utils/spec/path.spec.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ import { generateBrickData } from '../path';
22
import type { TInputUnion } from '../path';
33

44
// Helper function to parse SVG path and calculate actual bounding box
5-
function calculatePathBoundingBox(pathString: string): { w: number; h: number; debug?: any } {
5+
function calculatePathBoundingBox(pathString: string): { w: number; h: number; debug?: unknown } {
66
// More robust parsing - split by spaces but handle commas and multiple spaces
77
const pathData = pathString.trim().replace(/,/g, ' ').replace(/\s+/g, ' ');
88
const tokens = pathData.split(' ');
9-
9+
1010
let currentX = 0;
1111
let currentY = 0;
1212
let minX = 0;
1313
let minY = 0;
1414
let maxX = 0;
1515
let maxY = 0;
16-
16+
1717
let i = 0;
1818
while (i < tokens.length) {
1919
const command = tokens[i];
20-
20+
2121
if (command === 'm') {
2222
// Relative move
2323
const dx = parseFloat(tokens[i + 1]);
@@ -58,7 +58,7 @@ function calculatePathBoundingBox(pathString: string): { w: number; h: number; d
5858
const sweepFlag = parseFloat(tokens[i + 5]);
5959
const dx = parseFloat(tokens[i + 6]);
6060
const dy = parseFloat(tokens[i + 7]);
61-
61+
6262
// For bounding box calculation, we need to consider arc extremes
6363
// Simplified: just use start and end points for now
6464
currentX += dx;
@@ -87,19 +87,19 @@ function calculatePathBoundingBox(pathString: string): { w: number; h: number; d
8787
// Unknown command, skip
8888
i += 1;
8989
}
90-
90+
9191
// Update bounds after each command
9292
minX = Math.min(minX, currentX);
9393
minY = Math.min(minY, currentY);
9494
maxX = Math.max(maxX, currentX);
9595
maxY = Math.max(maxY, currentY);
9696
}
97-
97+
9898
const result = {
9999
w: Math.abs(maxX - minX),
100-
h: Math.abs(maxY - minY)
100+
h: Math.abs(maxY - minY),
101101
};
102-
102+
103103
return result;
104104
}
105105

@@ -265,12 +265,15 @@ describe('Masonry: Brick > Path Generation', () => {
265265
// NEW TEST: Validate bounding box against actual path dimensions
266266
it(`bounding box matches actual path dimensions: ${name}`, () => {
267267
const { path, boundingBox } = generateBrickData(input as TInputUnion);
268-
268+
269269
// Calculate actual bounding box from path
270270
const actualBounds = calculatePathBoundingBox(path);
271-
271+
272272
// Debug output for failed tests
273-
if (Math.abs(boundingBox.w - actualBounds.w) > 1 || Math.abs(boundingBox.h - actualBounds.h) > 1) {
273+
if (
274+
Math.abs(boundingBox.w - actualBounds.w) > 1 ||
275+
Math.abs(boundingBox.h - actualBounds.h) > 1
276+
) {
274277
console.log(`\n=== DEBUG INFO FOR: ${name} ===`);
275278
console.log('Input:', JSON.stringify(input, null, 2));
276279
console.log('Generated Path:', path);
@@ -280,11 +283,11 @@ describe('Masonry: Brick > Path Generation', () => {
280283
console.log('Height Difference:', Math.abs(boundingBox.h - actualBounds.h));
281284
console.log('=====================================\n');
282285
}
283-
286+
284287
// Use larger tolerance since there might be genuine calculation differences
285288
// Especially with arc commands and complex path geometries
286-
const tolerance = 1;
287-
289+
const tolerance = 1;
290+
288291
expect(Math.abs(boundingBox.w - actualBounds.w)).toBeLessThanOrEqual(tolerance);
289292
expect(Math.abs(boundingBox.h - actualBounds.h)).toBeLessThanOrEqual(tolerance);
290293
});

0 commit comments

Comments
 (0)