npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dodona/papyros

v2.3.4

Published

Scratchpad for multiple programming languages in the browser.

Downloads

354

Readme

Papyros

Papyros is a programming scratchpad in the browser. It allows running code directly in your browser, no installation required. Right now, the focus is on providing a great experience for Python, while also supporting JavaScript. By taking away obstacles between students and coding, the learning experience becomes smoother and less error-prone.

Currently, Papyros provides support for the following programming languages:

  • Python, powered by Pyodide
  • JavaScript, powered by your browser

Using Papyros in your own project

You can add Papyros to your project as follows:

  • npm:
npm install @dodona/papyros
  • yarn:
yarn add @dodona/papyros

Papyros currently supports two modes of operation: stand-alone and embedded.

In stand-alone mode, Papyros runs as a full application in the browser. This includes extra UI elements to allow selecting a locale, a programming language, ...

In embedded mode, the layout is reduced to the minimum. Dynamic selections are not displayed, as the user knows for what purpose Papyros is being used. For example, when used in the scope of a Python exercise in Dodona, there is no need to support other programming languages. The locale should also match that of the actual application.

Using Papyros in your project is done by following a few steps. First, you create a new Papyros instance with a PapyrosConfig object. The following options are supported:

  • standAlone: Whether to operate in stand-alone or embedded mode as described above.
  • programmingLanguage: The programming language to use in the CodeEditor and Backend.
  • locale: The locale to use, currently English and Dutch translations are provided.
  • inputMode: How the users can provide input, according to the InputMode enum
  • example: Optional name of the selected example, only appliccable in standAlone-mode
  • channelOptions: Optional options to provide to the sync-message channel. Extra is the serviceWorkerName, which is the relative pathname to the service worker script

Furthermore, you can provide fine-grained configuration by providing RenderOptions to each main component in the application when rendering Papyros. You minimally need to specify the ID of the parent element. You can also specify attributes, such as style, data-attributes or classNames to be used. The components you can style like this are the following:

  • standAloneOptions: for the global application in standAlone mode
  • codeEditorOptions: for the CodeEditor.
  • statusPanelOptions: for the StatusPanel in the CodeEditor
  • inputOptions: for the field that handles the user input
  • outputOptions: for the panel that displays the output of the code

User input

Important to note is that handling asynchronous input in a synchronous way is not straightforward. This requires advanced features which are not available by default in your browser. We support two options based on sync-message.

The most efficient and practical way is using SharedArrayBuffers, which requires the presence of certain HTTP headers. The following headers must be set on resources using Papyros.

{
  "Cross-Origin-Opener-Policy": "same-origin",
  "Cross-Origin-Embedder-Policy": "require-corp"
}

If you are also embedding other components (such as iframes, videos or images) in those pages, you will also need to set the Cross-Origin-Resource-Policy-header to cross-origin to make them work correctly. If these elements come from external URLs, it will likely not be possible to keep using them. An alternative is described below.

If you would like to use this project without enabling these HTTP headers, we provide a solution using a service worker. If your application does not use a service worker yet, you can create one based on the service worker used in stand-alone mode). If you already use a service worker, simply include our InputWorker in your existing service worker using imports (you can import it separately from /dist/workers/input/InputWorker). An example of how to use it can be found in our described service worker. Afterwards, inform Papyros of the location using the channelOptions described earlier.

Code editor

The editor used in Papyros is powered by CodeMirror 6. It is accessible in code via an instance of Papyros and by default allows configuring many options:

  • the programming language of the contents (for e.g. syntax higlighting)
  • the displayed placeholder
  • the indentation unit
  • the shown panel
  • the autocompletion source
  • the linting source
  • the theme used to style the editor

If you need more specific functionality, this can be added in your own code by accessing the internal CodeMirror editorView.

Documentation

Visit our documentation page at https://docs.dodona.be/papyros/.

Building and developing

Clone the repository using git.

[email protected]:dodona-edu/papyros.git

Install the required dependencies.

yarn install

Start the local dev-server, powered by webpack.

yarn start

You can now develop with live-reloading. You can view the results in your browser by visting http://localhost:8080.

Try it online

Start coding immediately in your browser.