From e489a1025599dcead36279e4d773efdedc0b339d Mon Sep 17 00:00:00 2001 From: David Montero Crespo Date: Tue, 7 Apr 2026 11:19:48 -0300 Subject: [PATCH] fix: update generatedAt timestamp and clean up component metadata defaults feat: enhance wire tracking in DynamicComponent for better event handling chore: mark subproject commits as dirty for rp2040js and wokwi-elements --- frontend/public/components-metadata.json | 18 ++++-------------- frontend/src/components/DynamicComponent.tsx | 11 ++++++++++- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/frontend/public/components-metadata.json b/frontend/public/components-metadata.json index 392c6fd0..29ae02f7 100644 --- a/frontend/public/components-metadata.json +++ b/frontend/public/components-metadata.json @@ -1,6 +1,6 @@ { "version": "1.0.0", - "generatedAt": "2026-04-02T01:25:51.523Z", + "generatedAt": "2026-04-07T14:03:23.074Z", "components": [ { "id": "arduino-mega", @@ -247,17 +247,9 @@ "name": "imageData", "type": "string", "control": "text" - }, - { - "name": "protocol", - "type": "select", - "control": "select", - "options": ["i2c", "spi"], - "defaultValue": "i2c", - "description": "Communication protocol" } ], - "defaultValues": { "protocol": "i2c" }, + "defaultValues": {}, "pinCount": 0, "tags": [ "ssd1306" @@ -1332,11 +1324,9 @@ }, { "name": "color", - "type": "select", + "type": "string", "defaultValue": "red", - "control": "select", - "options": ["red", "green", "blue", "yellow", "orange", "white", "purple"], - "description": "LED color" + "control": "text" }, { "name": "lightColor", diff --git a/frontend/src/components/DynamicComponent.tsx b/frontend/src/components/DynamicComponent.tsx index f77cf33e..a33a8c9c 100644 --- a/frontend/src/components/DynamicComponent.tsx +++ b/frontend/src/components/DynamicComponent.tsx @@ -59,6 +59,15 @@ export const DynamicComponent: React.FC = ({ // display to flash blank and lose its frame buffer. const hexEpoch = useSimulatorStore((s) => s.hexEpoch); + // Track wires connected to this component so attachEvents re-runs when + // wires are added or removed (e.g. disconnecting an LED cathode from GND). + const wireFingerprint = useSimulatorStore((s) => { + const myWires = s.wires.filter( + w => w.start.componentId === id || w.end.componentId === id + ); + return myWires.map(w => w.id).join(','); + }); + // Check if component is interactive (has simulation logic with attachEvents) const logic = PartSimulationRegistry.get(metadata.id || id.split('-')[0]); const isInteractive = logic?.attachEvents !== undefined; @@ -228,7 +237,7 @@ export const DynamicComponent: React.FC = ({ el.removeEventListener('button-press', onButtonPress); el.removeEventListener('button-release', onButtonRelease); }; - }, [id, handleComponentEvent, metadata.id, simulator, hexEpoch]); + }, [id, handleComponentEvent, metadata.id, simulator, hexEpoch, wireFingerprint]); return (