Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for custom kernels derived from xeus-javascript #16

Open
jtpio opened this issue Feb 2, 2024 · 1 comment
Open

Support for custom kernels derived from xeus-javascript #16

jtpio opened this issue Feb 2, 2024 · 1 comment

Comments

@jtpio
Copy link
Member

jtpio commented Feb 2, 2024

Description

xeus-javascript opens the door for quite some interesting use cases. For example it could be reused for making custom JavaScript kernels with a set of libraries already preloaded.

Looks like we would need a way to:

  • provide a different display name and logo
  • inject custom JavaScript to be run on kernel startup
  • make it possible for derived kernels to hook into the kernel messaging system, for example to send custom display data (maybe the item above would also solve that)

A concrete example would be for the p5 kernel: https://github.com/jupyterlite/p5-kernel
Currently this kernel is a bit tedious to maintain, and would benefit from the features offered by xeus-javascript.

Having such kernel compared to using a generic JavaScript kernel would still be useful, because someone authoring a p5 sketch could directly use global variables (like the setup() and draw() functions, or other globals like TWO_PI or DEGREES) provided by the p5 library, without having to import the library from a CDN.

@MRYingLEE
Copy link

Regarding "inject custom JavaScript to be run on kernel startup", I tried to add some script in post.js. If the script uses no external packages, it works well. For "await import()" is not allowed in post.js in building, so far, I couldn't find a way to use external packages.
For example,
const {default: OpenAI} = await import('https://cdn.jsdelivr.net/npm/openai@4.26.0/+esm');
caused
SyntaxError: Unexpected token ("import").

Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants