jupyter-xeus / xeus-javascript

A JavaScript kernel for JupyterLite, powered by Xeus
https://jupyter-xeus.github.io/xeus-javascript/lab/index.html?path=xeus-javascript.ipynb
BSD 3-Clause "New" or "Revised" License
9 stars 5 forks source link

User prompt support is wanted #22

Closed MRYingLEE closed 7 months ago

MRYingLEE commented 7 months ago

Description

User prompt is a basic feature for user input. For example,


const userInput =prompt("Please enter your name:",false);
if (userInput !== null) {
    alert("Hello, " + userInput + "!");
} else {
    alert("You canceled the input.");
}

What I Did

I tried to add user prompt support by myself. The core related code is at: https://github.com/MRYingLEE/xeus-javascript/blob/ce274fa060447dbf2dccf882faeed677261b0c51/src/xinterpreter.cpp#L105

The test code is at: https://mryinglee.github.io/xeus-javascript/lab/index.html?path=prompt_test.ipynb

Although the input reply message has been gotten, but the code execution is always pending.

I guess I misunderstood something.

If you have time, please add user prompt support.

DerThorsten commented 7 months ago

this might not work due to some limitations of jupyterlite / async code execution. Also, for an interactive notebook, I think having userInput is not crucial since users can just manipulate variables like userInput directly