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

@opentf/react-node-repl

v0.14.0

Published

The Node.js REPL in a React component.

Downloads

16

Readme

 OPEN TECH FOUNDATION

React Node REPL

Demo

The Node.js REPL in a React component.

Live Demo | Documentation

Features

  • Simple API
  • Powered by WebContainers
  • Install npm packages locally, directly in the terminal
  • Switch between Terminal or Console View
  • Keyboard shortcuts
  • TypeScript support

Upcoming

  • Serialization of objects for better console view
  • Code formating
  • Syntax errors highlighting
  • TypeScript errors

Requirements

  • Your site must be served over HTTPS.
  • The following headers must be set in your deployed page.
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin

Installation

npm install @opentf/react-node-repl
yarn add @opentf/react-node-repl
pnpm add @opentf/react-node-repl
bun add @opentf/react-node-repl

Usage

import { NodeREPL } from "@opentf/react-node-repl";
import "@opentf/react-node-repl/lib/style.css";

export default function App() {
  const code = `console.log("Hello World")`;
  const deps = ["pkg1", "[email protected]", "pkg3@beta"];

  return <NodeREPL code={code} deps={deps} layout="SPLIT_PANEL" />;
}

API

Props

| Prop | Type | Required | Default | Description | | --------- | ------------------- | -------- | --------- | ---------------------------------------------------------------------------------------------------------------- | | code | string | No | "" | The main code to execute | | deps | string[] | No | [] | The npm dependencies.Eg: ['lodash', '[email protected]'] | | setupCode | string | No | "" | The setup code, used to init some values. Eg: const log = console.log | | layout | string | No | "DEFAULT" | The predefined layouts for the components.There are two types of layout: 1. DEFAULT2. SPLIT_PANEL | | editor | EditorProps | No | undefined | The editor component config. | | terminal | TerminalProps | No | undefined | The terminal component config. | | console | ConsoleProps | No | undefined | The console component config. | | style | React.CSSProperties | No | {} | It is used to style the component container. |

EditorProps

| Prop | Type | Required | Default | Description | | -------- | ------------------- | -------- | ------- | ----------------------------------------- | | header | boolean | No | true | Show / Hide the editor header component. | | darkMode | boolean | No | false | The editor dark mode toggle. | | style | React.CSSProperties | No | {} | It is used to style the editor container. |

TerminalProps

| Prop | Type | Required | Default | Description | | ----- | ------------------- | -------- | ------- | ------------------------------------------- | | show | boolean | No | true | Show / Hide the terminal component. | | style | React.CSSProperties | No | {} | It is used to style the terminal container. |

ConsoleProps

| Prop | Type | Required | Default | Description | | ----- | ------------------- | -------- | ------- | ------------------------------------------ | | show | boolean | No | true | Show / Hide the console component. | | style | React.CSSProperties | No | {} | It is used to style the console container. |

Limitations

  • Currently, it runs only Node.js v18
  • By default, in REPL mode, you cannot use import statements. You need to fallback to require().
  • You can run ESM modules manually in the terminal with the ESM switch on. Eg: $ node main.js
  • It is not possible to run native addons.

Related

License

Copyright (c) 2021, Thanga Ganapathy (MIT License).