feat: Add integrated console and error reporting to CodeEmbed#1135
feat: Add integrated console and error reporting to CodeEmbed#1135Sumit6307 wants to merge 2 commits intoprocessing:mainfrom
Conversation
@ksen0 Plz Review and Merge this PR |
|
@ksen0 Plz Review and Merge this PR |
|
Hi @Sumit6307 , although this is a potentially interesting idea, this PR does not follow the contributor guidelines. In this case, the motivation does not apply for the code snippets on the website:
A user of the website is not developing their own sketches, they are running (possibly with tiny modifications) snippets that work. A beginner or learner working on their own sketch is either using the p5.js Editor, or another environment that has a console and error output. However, even if this can be motivated, it would need some community feedback in a discussion (in an issue), and approval for work and finally assignment by maintainers before submitting a PR. Please review the contributor guidelines, the process is explained there more thoroughly. You are welcome to consider opening an issue, but please explain the motivation more thoroughly, and create space for input before doing the work. I did test this, and I see that the new button is not legible when toggled, and when there are multiple CodeEmbed objects, the console log is actually shared among them - which is extremely confusing. This indicates to me that the proposal was also not thoroughly tested. For the above reasons, I will close this PR, thanks for understanding! |
Summary
This PR adds an integrated Console Panel to the interactive CodeEmbed component. It allows users to see
console.logoutputs, warnings, and runtime errors (such as syntax errors or missing arguments) directly within the website's interface, without needing to open the browser's developer tools.Motivation
Currently, if a user—especially a beginner learning p5.js—makes a mistake in an interactive sketch (e.g., calling rect() without arguments), the sketch fails silently. This lack of feedback creates a significant barrier to learning. This feature closes the feedback loop by surfacing errors and logs immediately, making the documentation more interactive and helpful.
Implementation Details
log,info,warn, anderrorlevels with distinct visual styling (e.g., red background for errors).console.*methods and globalwindow.onerror/onunhandledrejectionevents inside the sandbox and forwards them to the parent window viapostMessage.Test Plan
I have verified the changes manually with the following scenarios:
console.log("hello p5")in an editor -> confirmed the message appears in the panel.Checklist