Giter Club home page Giter Club logo

replite's Introduction

replite

⚠️ Archived ⚠️

JupyterLite now includes a REPL application by default.

Check out the documentation to learn how to use it and configure it: https://jupyterlite.readthedocs.io/en/latest/quickstart/embed-repl.html


An embeddable REPL, powered by JupyterLite.

replite-numpy

Usage

To embed the code console in your website:

<iframe src="https://replite.vercel.app/repl/index.html" width="100%" height="100%">
</iframe>

Configuration

The behavior and the look of the REPL can be configured via URL parameters.

Select a kernel by default

To avoid the kernel selection dialog and choose a given kernel by default:

<iframe src="https://replite.vercel.app/repl?kernel=python" width="100%" height="100%">
</iframe>

Enable the toolbar

The toolbar can be enabled (opt-in) to add a couple of useful buttons:

<iframe src="https://replite.vercel.app/repl?toolbar=1" width="100%" height="100%">
</iframe>

toolbar

Auto execute code on startup

Custom starter code can automatically be executed on startup:

<iframe src="https://replite.vercel.app/repl?kernel=python&code=import numpy as np" width="100%" height="100%">
</iframe>
auto-execute.mp4

Themes

It is also possible to select a theme, for example JupyterLab Dark:

<iframe src="https://replite.vercel.app/repl?theme=JupyterLab Dark" width="100%" height="100%">
</iframe>

Additional themes can be installed with pip if they are distributed as a JupyterLab prebuilt extension. For example:

pip install jupyterlab-gt-coar-theme
themes.mp4

Create your custom deployment

TBD

replite's People

Contributors

github-actions[bot] avatar jtpio 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

Watchers

 avatar  avatar  avatar

replite's Issues

Add a postMessage API

Problem

The URL api is robust for one-off solutions, but makes it harder to integrate.

Proposed Solution

In addition to a well-documented URL param scheme, offer a postMessage API that allows for basic things like "run some code", arbitrary lumino commands, or anything that an extender can imagine.

Background

Having fought with more than a few IFrames, it can be nice to offer both a bare-minimum, fire-and-mostly-forget URL api, as well as a well-structured, message-based API. A good (counter-)example is the drawio embed mode:

  • hooray! it can do lots of things!
  • boo! that's pretty much it for docs!
    • a robust API in a JSON schema and typings would go a long way to helping implementers who wanted to build e.g. replite-react or replite-vue or whatever they want
      • indeed, as a low-effort integrator demo, it could use rjsf to draw a message builder/viewer

Why both?

By splitting "long term" URL params and "on-demand" postMessage an integrator can then get interesting interplay effects: pass ?ui=0&input=0 and then have the host take over firing all of the execute methods with their own buttons

For e.g. wasm-based kernels, until we can figure out a SharedWorker worker kernels it's particularly important to not add 10s of 100mb kernels, even if in iframes. In a long-form document, a more feasible approach one would be to have a single iframe/kernel/cell, fixed in the viewport, that gets updated as the reader scrolls/clicks on things.

Design Considerations

As for what actually goes in this API: a really quick win is the app.commands.execute... while no a-priori schema exists, a running lab could at least enumerate what commands it has.

Add buttons to the toolbar

Right now the console toolbar is empty:

image

Maybe we should add a couple of buttons to it, for example:

  • run
  • restart
  • clear

Distribute in JupyterLite by default

Eventually this minimal REPL should be one of the apps distributed by default in JupyterLite.

For now lite ships lab and retro by default: https://jupyterlite.readthedocs.io/en/latest/api/py/jupyterlite.html#jupyterlite.constants.JUPYTERLITE_APPS

There could be a new app called cell.

If this is a standalone app like retro, the look and UX could be different and not limited to the JupyterLab code console.

We'll want to fix jupyterlite/jupyterlite#118 first though.

The cell app could be either in core, or as a third-party app under the jupyterlite org. The latter might require some work in the jupyterlite CLI to allow apps as (federated) plugins.

Related to jupyterlite/jupyterlite#148

Choose the theme via a query string parameter

It would be great to be able to choose the default theme via a command line parameter.

For example the JupyterLab light and dark themes. But this would also work with other third-party themes distributed as prebuilt extensions.

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.