Coder Social home page Coder Social logo

jtpio / p5-notebook Goto Github PK

View Code? Open in Web Editor NEW
139.0 3.0 16.0 1008 KB

A Jupyter Notebook environment for p5.js kernels running in the browser, powered by JupyterLite ๐Ÿ’ก

Home Page: https://p5nb.vercel.app

License: BSD 3-Clause "New" or "Revised" License

TypeScript 9.08% CSS 84.85% JavaScript 3.56% Shell 1.15% Python 1.35%
p5js jupyter notebook processing jupyterlite jupyter-notebook

p5-notebook's Introduction

p5-icon p5-notebook p5-icon

Github Actions Status

A minimal Jupyter Notebook UI for p5.js kernels.

p5-screencast-1.webm

Usage

โœจ Try it in your browser! โœจ

Features ๐ŸŽ

Opens with Jupyter Notebook by default ๐Ÿ“’

By default, the p5 notebook opens with the simpler notebook interface.

p5-screencast-1.webm

JupyterLab interface ๐Ÿงช

The JupyterLab interface is still accessible via the View > Open in JupyterLab menu entry:

p5-screencast-2.webm

Live preview of HTML-based sketches โšก

With the JupyterLab interface, .html files can be edited and rendered live with the built-in HTML viewer:

p5-screencast-3.webm

Support for themes ๐ŸŒˆ

The p5 notebook includes the default JupyterLab Light and Dark themes, as well as p5.js branded light and dark themes:

p5-screencast-4.webm

Support for additional display languages ๐ŸŒ

Just like with JupyterLab, the p5 notebook also supports additional display languages like French and Simplified Chinese:

p5-screencast-5.webm

JupyterLab and Notebook features ๐ŸŽจ

Most of the JupyterLab and Jupyter Notebook features are also available, such as switching to the Simple Interface and opening the command palette:

p5-screencast-6.webm

Real Time Collaboration

Coming soon!

Dev install

This repo includes a couple of additional plugins to tweak the Jupyter UI. To setup a local environment and be able to iterate on them, make sure Node.js is installed, then:

# install dependencies
pixi install

# Install package in development mode
pixi run develop

# Rebuild the extension Typescript source after making changes
pixi run build

Related projects

p5-notebook's People

Contributors

dependabot[bot] avatar jtpio avatar westurner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

p5-notebook's Issues

Add a pyp5js with pyodide kernel

It would be nice to be able to switch between:

  • a pure p5.js JavaScript kernel
  • a Python kernel that exposes the p5 API, using pyp5js with pyodide, and everything still running in the browser

This would also be useful to prepare the ground for a tighter integration with Jupyter Widgets in a more traditional setup: jtpio/ipyp5#4

Add p5 branded theme

With some pink-ish colors.

And in jupyter-lite.json:

  • Enable themed scrollbars by default
  • Enable that theme by default

Implement streams

This will most likely involve patching console.log and console.error, as well as gracefully handling exceptions.

Rebuild with JupyterLite

Once the JupyterLite tooling is ready:

  • convenient jupyterlite Python package, or JS equivalent to get the main app assets
  • tooling to support serverlite extensions to add the p5 related kernels

We should "reboot" this repo, which might end up being a light monorepo with just a couple of packages for the kernel (the rest being reuse from JupyterLite).

For the UI, we can also default to RetroLab.

Open from URL

Sketches could be imported from other notebooks by pasting a URL in an input field.

Open the sketch in a split view

Just like JupyterLab make it possible to open to have 2 documents side by side, it would be useful to open the sketch in a split view (left or right), so the notebook can still be edited and scrolled.

This could be achieved by adding a button to the notebook toolbar.

Roadmap

Here are a couple of items for the p5 notebook roadmap.

Some of them actually apply to a wider scope than just p5, and would define the building blocks for more generic in-browser jupyter kernels.

The idea is to start with the special case of the p5 notebook with multiple notebooks, and make it more generic afterwards.

  • Add a pyp5js kernel backed by pyodide: #52
  • Improve kernel management (#7)
  • Define a public interface to register kernels
  • Save notebooks to local storage: #20
  • Add a simple file browser to create, save and re-open existing notebooks
  • Consolidate the jupyterlab server to it's functional for most of the use cases (but it doesn't have to be feature complete)
  • Make the jupyterlab server pluggable using the same lab / lumino plugin system:
    • So users could replace some of the plugins, for example the contents manager
    • For example instead of writing to local storage this could be talking to external services using API calls
  • Split up the components and switch to a monorepo structure
  • Move some of the components to a separate repo
  • p5 notebook should only be a distribution:
    • depending on the jupyterlab server in the browser
    • shipping with a predefined set of kernels
    • with its own minimal notebook UI (logo + p5 touch)
  • Add a splash screen: #23
  • Publish to npm: #27

Update Readme

Update the main README to serve as documentation and:

  • showcase features
  • where the project fits compared to the p5js web editor and the Jupyter ecosystem
  • document how to install on a custom lite deployment
  • lab vs retro

Add a top area

A top area similar to the classic notebook, but trimmed down to the minimal, would be useful to:

  • show the p5 logo
  • manage notebooks (download, upload, create new) and load examples.
  • show the help
  • add extra widgets such as the theme-toggle topbar plugin
  • manage multiple notebooks (if not too complicated)

Replace raw localStorage by StateDB + DataConnector

Instead of using localStoragedirectly, we could instead make use of a StateDB with a DataConnector that would use localStorage as storage.

This would make the implementation more generic, and could be reused to store other type of content.

Split frontend parts into plugins

The "frontend" should be split into plugins (JupyterFrontEndPlugin[]).

The app would load all the predefined plugins at start-up using app.registerPluginModules(plugins);

This leaves the door open for adding plugins from existing third-party JupyterLab extensions.

Implement a Web Worker kernel

It would be interesting to implement a Web Worker kernel, just for fun.

Also the users of the p5 notebook could switch between a pure JS kernel and a p5.js kernel using the kernel selection dialog from the notebook toolbar.

Similar project: Starboard

Hi Jeremy,

I came across this repo when exploring the rabbit hole that is alternative notebook projects. I'm building a notebook system, not based on Jupyter, that runs entirely in the browser by design and is entirely static (like p5-notebook). I recreated the P5 example notebook here, here it is entirely statically which you could embed anywhere.

One cool thing is that there is no one 'kernel' and no 'magic' (it's all just JS), so you can really mix different languages. Also you can "build the ship as you sail", similar to Jyve. You can even write P5 code in Python through pyodide if you want :). The homepage has some more details, it's open source here.

Curious to hear your thoughts and happy to bounce ideas!

Publish to npm

The package should be published to npm, so it can used on a local machine too.

It can also be made compatible with npx, so that running npx p5-notebook (or npx p5nb) starts a server in the local directory and open a new browser tab. It should also serve other type of content such as images.

Save notebook to local storage

The example notebook should be put in the menu: "File -> Load Example".

The notebooks could be stored in the browser localStorage, so they are not lost after a page refreshed.

Handle multiple notebooks

Ideally there should be a way to have multiple notebooks on the page (each with a separate kernel), and be able to switch between them easily, while keeping the interface as simple as possible.

Add a Help menu

With the following entries:

  • about + link to this repo
  • link to the p5.js reference
  • link to jupyter.org?
  • show shortcuts

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.