Add backend and frontend test suites for Arduino compilation and simulation
- Implemented a comprehensive backend test suite in `test_compilation.py` to validate the Arduino CLI installation, AVR core presence, compilation service, and API endpoint functionality.
- Created a frontend test suite in `simulation.test.ts` to test the `PinManager` and `AVRSimulator` components, ensuring proper functionality and integration.
- Introduced new components for wire management in the simulator, including `PinOverlay`, `WireInProgressRenderer`, `WireLayer`, and `WireRenderer`, enhancing the visual wiring system.
- Developed utility functions for pin position calculations and wire color management, ensuring accurate connections and visual representation.
- Added types for wire management in `wire.ts`, defining structures for wire endpoints, control points, and signal types.
2026-03-04 02:44:07 +07:00
|
|
|
/**
|
|
|
|
|
* PinOverlay Component
|
|
|
|
|
*
|
|
|
|
|
* Renders clickable pin indicators over components to enable wire creation.
|
|
|
|
|
* Shows when hovering over a component or when creating a wire.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
|
|
|
|
|
|
interface PinInfo {
|
|
|
|
|
name: string;
|
|
|
|
|
x: number; // mm
|
|
|
|
|
y: number; // mm
|
|
|
|
|
signals?: Array<{ type: string; signal?: string }>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface PinOverlayProps {
|
|
|
|
|
componentId: string;
|
|
|
|
|
componentX: number;
|
|
|
|
|
componentY: number;
|
|
|
|
|
onPinClick: (componentId: string, pinName: string, x: number, y: number) => void;
|
|
|
|
|
showPins: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const MM_TO_PX = 3.7795275591;
|
|
|
|
|
|
|
|
|
|
export const PinOverlay: React.FC<PinOverlayProps> = ({
|
|
|
|
|
componentId,
|
|
|
|
|
componentX,
|
|
|
|
|
componentY,
|
|
|
|
|
onPinClick,
|
|
|
|
|
showPins,
|
|
|
|
|
}) => {
|
|
|
|
|
const [pins, setPins] = useState<PinInfo[]>([]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
// Get pin info from wokwi-element
|
|
|
|
|
const element = document.getElementById(componentId);
|
|
|
|
|
if (element && (element as any).pinInfo) {
|
|
|
|
|
setPins((element as any).pinInfo);
|
|
|
|
|
}
|
|
|
|
|
}, [componentId]);
|
|
|
|
|
|
|
|
|
|
if (!showPins || pins.length === 0) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
position: 'absolute',
|
2026-03-04 05:30:25 +07:00
|
|
|
left: `${componentX + 6}px`, // +6px for wrapper padding (4px padding + 2px border)
|
|
|
|
|
top: `${componentY + 6}px`,
|
Add backend and frontend test suites for Arduino compilation and simulation
- Implemented a comprehensive backend test suite in `test_compilation.py` to validate the Arduino CLI installation, AVR core presence, compilation service, and API endpoint functionality.
- Created a frontend test suite in `simulation.test.ts` to test the `PinManager` and `AVRSimulator` components, ensuring proper functionality and integration.
- Introduced new components for wire management in the simulator, including `PinOverlay`, `WireInProgressRenderer`, `WireLayer`, and `WireRenderer`, enhancing the visual wiring system.
- Developed utility functions for pin position calculations and wire color management, ensuring accurate connections and visual representation.
- Added types for wire management in `wire.ts`, defining structures for wire endpoints, control points, and signal types.
2026-03-04 02:44:07 +07:00
|
|
|
pointerEvents: 'none',
|
|
|
|
|
zIndex: 10,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{pins.map((pin) => {
|
|
|
|
|
const pinX = pin.x * MM_TO_PX;
|
|
|
|
|
const pinY = pin.y * MM_TO_PX;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
key={pin.name}
|
|
|
|
|
onClick={(e) => {
|
|
|
|
|
e.stopPropagation();
|
2026-03-04 05:30:25 +07:00
|
|
|
onPinClick(componentId, pin.name, componentX + 6 + pinX, componentY + 6 + pinY);
|
Add backend and frontend test suites for Arduino compilation and simulation
- Implemented a comprehensive backend test suite in `test_compilation.py` to validate the Arduino CLI installation, AVR core presence, compilation service, and API endpoint functionality.
- Created a frontend test suite in `simulation.test.ts` to test the `PinManager` and `AVRSimulator` components, ensuring proper functionality and integration.
- Introduced new components for wire management in the simulator, including `PinOverlay`, `WireInProgressRenderer`, `WireLayer`, and `WireRenderer`, enhancing the visual wiring system.
- Developed utility functions for pin position calculations and wire color management, ensuring accurate connections and visual representation.
- Added types for wire management in `wire.ts`, defining structures for wire endpoints, control points, and signal types.
2026-03-04 02:44:07 +07:00
|
|
|
}}
|
|
|
|
|
style={{
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
left: `${pinX - 6}px`,
|
|
|
|
|
top: `${pinY - 6}px`,
|
|
|
|
|
width: '12px',
|
|
|
|
|
height: '12px',
|
|
|
|
|
borderRadius: '50%',
|
|
|
|
|
backgroundColor: 'rgba(0, 200, 255, 0.7)',
|
|
|
|
|
border: '2px solid white',
|
|
|
|
|
cursor: 'crosshair',
|
|
|
|
|
pointerEvents: 'all',
|
|
|
|
|
transition: 'all 0.2s',
|
|
|
|
|
}}
|
|
|
|
|
onMouseEnter={(e) => {
|
|
|
|
|
e.currentTarget.style.backgroundColor = 'rgba(0, 255, 100, 1)';
|
|
|
|
|
e.currentTarget.style.transform = 'scale(1.3)';
|
|
|
|
|
}}
|
|
|
|
|
onMouseLeave={(e) => {
|
|
|
|
|
e.currentTarget.style.backgroundColor = 'rgba(0, 200, 255, 0.7)';
|
|
|
|
|
e.currentTarget.style.transform = 'scale(1)';
|
|
|
|
|
}}
|
|
|
|
|
title={pin.name}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|