pxt icon indicating copy to clipboard operation
pxt copied to clipboard

How to integrate Makecode into React.js or Vue.js frameworks with a custom simulator.

Open kartikbhargav11 opened this issue 3 years ago • 3 comments

kartikbhargav11 avatar Feb 09 '22 04:02 kartikbhargav11

I am also curious about how this would work, I know to register an external simulator you would have to fork pxt, and edit pxtarget.json as shown here. this will launch the iframe when an extension is loaded to the custom simulator you want.

however, the iframe will only load if the extension uses the channel specified in pxtarget.json, and sends a command through. the channel: Screenshot 2023-02-20 at 11 57 47 (this is from the pxt-jacdac)

However, there is very little documentation on how to integrate and use external simulators with pxt and/or what APIs to use. @abchatra is there any update on this? any information would be helpful.

resolute-support avatar Feb 20 '23 10:02 resolute-support

Just an Update

I have made considerable progress with communication with an external simulator and Makecode, using control.simmessages.send() on Makecode and setting a listener for the "message" event you can send data from Makecode to the simulator and parse the data:

image

However I am now struggling with sending data to Makecode from the simulator, You can use: window.parent.postMessage(sensorData, "*") to send Json to Makecode.

However I am unsure of how to listen for the incoming data on the Makecode side, I assume it must be done through the extension but I am unsure of how to implement it. @abchatra do you have any knowledge on how to listen for data?

resolute-support avatar May 05 '23 18:05 resolute-support

Unfortunately, there is no support for custom simulator today as all the URL loaded has to be from the Microsoft domain. Saying this, we always evaluate improvement to the platform. I will discuss with my team.

abchatra avatar May 05 '23 20:05 abchatra