Replite - An embeddable REPL powered by JupyterLite

Overview

replite

An embeddable REPL, powered by JupyterLite.

replite-numpy

Usage

To embed the code console in your website:

<iframe src="https://replite.vercel.app/retro/consoles/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/retro/consoles?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/retro/consoles?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/retro/consoles?kernel=python&code=import numpy as np" width="100%" height="100%">
</iframe>
auto-execute.mp4

Create your custom deployment

TBD

Development

# create a new environment
mamba create -n replite -c conda-forge jupyterlab=3 jupyter-packaging python nodejs -y
conda activate replite

# Install JupyterLite
python -m pip install jupyterlite

# Install package in development mode
python -m pip install -e .

# Link your development version of the extension
jupyter labextension develop . --overwrite

# Rebuild extension TypeScript source after making changes
jlpm run build
Comments
  • Allow some code to be silently pre-run

    Allow some code to be silently pre-run

    Hi,

    Just found this repository and it looks great! Inspired by your PRs to numpy and sympy to use this REPL to allow people to try out code in documentation pages, I was interested in using this for some of my code. However, for packages that aren't part of pyodide directly, users would have to first do something like

    import micropip
    await micropip.install('PACKAGE')
    

    before they can import PACKAGE. That would be confusing for users who don't know pyodide. My understanding is that pyodide does not want to include Python packages that have pure Python wheels available on PyPI, so this would be an issue for many packages.

    This quick PR allows for an install URL parameter that lists a set of packages to quietly install with micropip (I wasn't sure whether I should use micropip or piplite, but both work). It works both with lists of packages (&install=kimmy,scipy) or with wheel URLS (&install=https://astro.utoronto.ca/~bovy/galpywheels/galpy-1.8.0.dev0-py3-none-any.whl&code=import%20galpy) .

    I don't have any prior experience with TypeScript or the Jupyter backend, so there might be better ways to do this, but injecting the code and removing the cell seems to do what I want (I couldn't figure out how to just have the kernel execute a bit of code...).

    This works locally, but I could push a version somewhere to illustrate use better if necessary (and can add to CHANGELOG and what not if you're inclined to accept this PR).

    Thanks!

    Edit: Full example using my galaxy chemical evolution code kimmy on the Vercel deployment here.

    opened by jobovy 7
  • Add optional toolbar buttons

    Add optional toolbar buttons

    Fixes #8

    • [x] Add toolbar buttons
    • [x] Control toolbar visibility via a query string parameter (opt-in)

    https://user-images.githubusercontent.com/591645/152146676-dc93489a-11f4-4cc9-88e0-e2075ae5c331.mp4

    Opt-in toolbar

    https://user-images.githubusercontent.com/591645/152147186-f23be261-14c3-4553-b2e3-37db60e675c2.mp4

    enhancement 
    opened by jtpio 3
  • Setup the JupyterLab extension

    Setup the JupyterLab extension

    Fixes #2 Fixes #1

    So it's easier to customize the app than patching the CSS.

    Populate code via query string parameters

    https://user-images.githubusercontent.com/591645/152044572-af203c12-9328-4e48-8ed9-11de2e8f82ec.mp4

    enhancement 
    opened by jtpio 3
  • Add a postMessage API

    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.

    opened by bollwyvl 2
  • Update to the latest JupyterLite

    Update to the latest JupyterLite

    The repl app is now part of the main JupyterLite distribution: https://jupyterlite.readthedocs.io/en/latest/applications/repl.html

    Added in https://github.com/jupyterlite/jupyterlite/pull/498

    This PR updates to using the upstream app:

    • [x] Update to jupyterlite>=0.1.0a24
    • [x] Strip source maps (pending upstream release)
    • [x] Ship only the repl app (pending upstream release)
    enhancement 
    opened by jtpio 1
  • Distribute in JupyterLite by default

    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 https://github.com/jupyterlite/jupyterlite/issues/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 https://github.com/jupyterlite/jupyterlite/issues/148

    opened by jtpio 1
  • Automated Changelog Entry for 0.1.1 on main

    Automated Changelog Entry for 0.1.1 on main

    Automated Changelog Entry for 0.1.1 on main

    After merging this PR run the "Full Release" Workflow on your fork of jupyter_releaser with the following inputs | Input | Value | | ------------- | ------------- | | Target | jtpio/replite | | Branch | main | | Version Spec | 0.1.1 | | Since | first-commit |

    documentation 
    opened by jtpio 1
  • Disable `jupyterlab-plotly` (widgets) plugin

    Disable `jupyterlab-plotly` (widgets) plugin

    Widgets are not supported in code consoles yet (https://github.com/jupyter-widgets/ipywidgets/pull/3004).

    This should help fix the following errors logged in the dev tools console:

    image

    enhancement 
    opened by jtpio 1
  • Inject code directly

    Inject code directly

    As discussed in https://github.com/numpy/numpy.org/pull/547#issuecomment-1028066613.

    Instead of just populating the cell, we execute the code lines directly by injecting them in the console.

    https://user-images.githubusercontent.com/591645/152204519-7980e9f6-ef56-4263-bb79-4fcf3e4fd2be.mp4

    enhancement 
    opened by jtpio 1
  • Fix CSS on mobile layout

    Fix CSS on mobile layout

    Right now the cell prompt is stacked on top of the cell when the width is less than 760px:

    image

    Based on this CSS in JupyterLab: https://github.com/jupyterlab/jupyterlab/blob/3.2.x/packages/cells/style/inputarea.css#L52-L68

    For the console, we should override that or maybe even remove the prompt?

    opened by jtpio 0
  • Choose the theme via a query string parameter

    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.

    opened by jtpio 0
  • Choose the display language (locale) via a query string parameter

    Choose the display language (locale) via a query string parameter

    Similar to #10

    It should be possible to choose a different language than English via a query string parameter. For example French or Simplified Chinese.

    The deployments would need to include the language packs.

    opened by jtpio 1
Releases(v0.1.1)
Owner
Jeremy Tuloup
Scientific Software Engineer, @jupyter Core Developer and Distinguished Contributor
Jeremy Tuloup
A ULauncher/Albert extension that supports currency, units and date time conversion, as well as a calculator that supports complex numbers and functions.

Ulauncher/Albert Calculate Anything Ulauncher/Albert Calculate Anything is an extension for Ulauncher and Albert to calculate things like currency, ti

tchar 67 Jan 01, 2023
A bash-like intrepreted language

A Bash-like interpreted scripting language.

AshVXmc 1 Oct 28, 2021
ViberExport - Export messages from Viber messenger using viber.db file

📲 ViberExport Export messages from Viber messenger using viber.db file ⚡ Usage:

7 Nov 23, 2022
We want to check several batch of web URLs (1~100 K) and find the phishing website/URL among them.

We want to check several batch of web URLs (1~100 K) and find the phishing website/URL among them. This module is designed to do the URL/web attestation by using the API from NUS-Phishperida-Project.

3 Dec 28, 2022
Launcher program to select which version of the Q-Sys software to launch.

QSC-QSYS Launcher Launcher program to select which version of the Q-Sys software to launch. Instructions To use the application simply save the "Q-Sys

Zach Lisko 2 Sep 28, 2022
一个Graia-Saya的插件仓库

一个Graia-Saya的插件仓库 这是一个存储基于 Graia-Saya 的插件的仓库 如果您有这类项目

ZAPHAKIEL 111 Oct 24, 2022
Script to change official Kali repository to mirrors

Script to change official Kali repository to mirrors. This helps increase packages update and downloading for some user.

Vineet Bhavsar 2 Nov 29, 2021
Fastest python library for making asynchronous group requests.

FGrequests: Fastest Asynchronous Group Requests Installation Install using pip: pip install fgrequests Documentation Pretty easy to use. import fgrequ

Farid Chowdhury 14 Nov 22, 2022
Let's pretend you want to create a AWS Lambda project called "sns-processor".

Usage Let's pretend you want to create a AWS Lambda project called "sns-processor". Rather than using lambda and then editing the results to include y

1 Dec 31, 2021
A collection of some leetcode challenges in python and JavaScript

Python and Javascript Coding Challenges Some leetcode questions I'm currently working on to open up my mind to better ways of problem solving. Impleme

Ted Ngeene 1 Dec 20, 2021
Lock a program and kills it indefinitely if it is started.

Kill By Lock Lock a program and kills it indefinitely if it is started. How start it? It' simple, you just have to double-click on the python file (.p

1 Jan 12, 2022
Tutorials on advanced python topics, and literate programming framework to write them.

Advanced course on Python3 This course covers several topics Python decorators The python object system / meta classes Also see my text on Python impo

Michael Moser 59 Dec 19, 2022
🛠️ Learn a technology X by doing a project - Search engine of project-based learning

Learn X by doing Y 🛠️ Learn a technology X by doing a project Y Website You can contribute by adding projects to the CSV file.

William 408 Dec 20, 2022
A python server markup language

PSML - Python server markup language How to install: python install.py

LMFS 6 May 18, 2022
Edorado93 - Unraveling a Rockstar! -- Too much? Fine, Unraveling a humble programmer then?

Hi, I'm Sachin Malhotra ( ⛄ 💻 🎃 🍺 ) Let me set the records straight. Roger Federer is the GOAT and I will not hear otherwise! Now that we have that

Sachin Malhotra 7 Dec 25, 2022
OpenTracing API for Python

OpenTracing API for Python This library is a Python platform API for OpenTracing. Required Reading In order to understand the Python platform API, one

OpenTracing API 767 Dec 16, 2022
Python solution of advent-of-code 2021

Advent of code 2021 Python solutions of Advent of Code 2021 written by Eric Bouteillon Requirements The solutions were developed and tested using Pyth

Eric Bouteillon 3 Oct 25, 2022
Korg Volca Sample uploader for linux.

GnuVolca Korg Volca Sample uploader for linux. GnuVolca Usage Installation Via virtualenv Usage Store all the samples you want to upload on an empty d

Gonzalo Rafuls 12 Oct 11, 2022
JHBuild is a tool designed to ease building collections of source packages, called “modules”.

JHBuild README JHBuild is a tool designed to ease building collections of source packages, called “modules”. JHBuild was originally written for buildi

GNOME Github Mirror 46 Nov 22, 2022