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

codehelium

v0.1.10

Published

A lightweight editor component that compiles, executes and returns the outputs of any user-written code via Pyodide/Emscripten/Webassembly.

Downloads

6

Readme

codehelium 👾

Codehelium is a lightweight editor component that compiles, executes and returns the outputs of any user-written code via Pyodide/Emscripten/Webassembly.

It is currently only usable as a React component with support for Python code editing/execution.

Check out the demo - it is quite "bloat-free" and can also serve as a useful site for if you need to quickly hack up and test concepts/ideas!

Installation 🖥️

To get started with using codehelium in your React application run npm i codehelium, import the component and you're good to go!

import PythonEditor from 'codehelium'
...
<PythonEditor width="90vw" height="80vh" />

More Examples 😎

Obtaining Console Outputs from Parent Components

Oftentimes, you may desire to obtain the stdout or stderr from user-written code in codehelium editor components. For a given state variable in your parent component, you can pass the corresponding setter function via the consoleOutputSetter prop to utilise console outputs from user-written code in the PythonEditor component.

import PythonEditor from 'codehelium';
import { useEffect, useState } from 'react';

function App() {
    const [consoleOutputs, setConsoleOutputs] = useState([]);

    useEffect(() => {
        console.log("Printing from App... Console output received");
        console.log(consoleOutputs);
    }, [consoleOutputs])

    return (
        <div>
            <PythonEditor width="90vw" height="80vh" 
            consoleOutputSetter={setConsoleOutputs} />
        </div>
    );
}

export default App;

Using an External Pyodide Instance

By default, the PythonEditor component will initialise its own Pyodide instance with the indexURL set to jsDelivr. However if you have initialised Pyodide elsewhere in your application, you can pass this instance to the PythonEditor component by using the pyodideInstance prop. The following example demonstrates how to do so:

import PythonEditor from 'codehelium';
import { loadPyodide } from 'pyodide';
import { useEffect, useState } from 'react';

function App() {
    const [myPyodideInstance, setMyPyodideInstance] = useState(null);

    useEffect(() => {
        async function createPyodideInstance() {
            let pyodide = await loadPyodide({
            indexURL: window.location.href + "/pyodide"
            });
            
            setMyPyodideInstance(pyodide);
        }

        // Initialize pyodide instance in parent component
        createPyodideInstance();
    }, []);

    return (
        <div>
            <div className="w-screen h-screen grid place-content-center">
                <PythonEditor width="90vw" height="80vh"
                pyodideInstance={myPyodideInstance}/>
            </div>
        </div>
    );
}

export default App;

This is a good practice as it allows you to have full control of the Pyodide instance whilst also being able to leverage the component's capabilities. Consider using this when developing applications that use a singleton model for Pyodide functionality.

Guide to Contributing 🫶

To get started with contributing, fork this repository and then run the following once you have cloned the forked repo:

npm install
npm start

Library components can then be changed by visiting src/lib/, with changes reflected in the development server (from running npm start). Once complete, send a PR (filled with basic details) to bring your changes into this repo!

Additional Notes 📝

codehelium is great for applications such as:

  • Educational tools requiring users to write code and get feedback
  • Building quick and personalised, web-based editors for you to quickly access and test your ideas

Future work includes:

  • Support importing external Python packages in the editor
  • Ability to code in other languages
  • Controlling editor themes and custom-styling

Support this Project 💛

Starring this repo, creating issues and sending PRs with useful features/improvements are always appreciated and welcomed!