Description
Describe the bug
When running the WokWi Diagram Editor as the editor in an editor tab in VSCode, for diagram.json
, if there is a custom chip in the project, e.g. custom.chip.json
and custom.chip.c
files, and the diagram.json
is referring to this in parts
as "type": "chip-custom"
, the WokWi Diagram Editor shows a confusing error message Missing chip chip-custom
in the part image in the editor and drops the connections with the custom chip.
To Reproduce
- Install VSCode and WokWi Simulator extension to VSCode (if you don't have them already)
- Clone any suitable WokWi GIT repository, with a custom chip, to VSCode, e.g. https://github.com/wokwi/inverter-chip which is used by the documentation
- Open
diagram.json
for editing - See the WokWi Diagram Editor to appear.
Expected behavior
The custom chip in the project (Inverter) should appear as the defined custom chip, with connections to the other chips.
Current behavior
The custom chip in the project (Inverter) appears as a Missing chip
, with no connections to other chips.
Work around
There must be a dist
folder, with chip.json
and chip.wasm
. At this point, VSCode does not produce them automatically but one must build the dist
folder and its contents manually.
Environment
macOS 15.2 (24C101)
Safari 18.2 (20620.1.16.11.8)
VSCodium 1.96.2 Release: 24355,
WokWi Simulator extension 2.6.0 - 2024-12-10.
This bug appears to be there also with the WokWi Pro license activated.
Additional context
At https://wokwi.com/_next/static/chunks/4729-9dd899e2e960fade.js in function getChip(t)
, the chips are only looked at https://wokwi.com/api/external/chips
. This does not make sense here, since the chip definition is on the local disk of the VScode host. For custom chips defined in the project, the WokWi extension should first upload the local file to somewhere in the wokwi.com
domain so that the WokWi Editor, running in the iframe, could download and read it. The WokWi Editor cannot try to read the file directly from the local disk, as the iframe cannot escape its sandbox. Or, if the WokWi Simulator extension already does upload the file for including it in https://wokwi.com/api/external/chips
, there appears to be a bug somewhere else.
As a workaround, one could add a possibility to define a custom URL path for custom chips, allowing the WokWi Editor in the iframe to load the code from a custom URL (if allowed by sandboxing, I don't remember...).
( I hate debugging closed source obfuscated JS code. Hence, there may be errors in my analysis. I didn't want to spend too much time in debugging this. )