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

@betteridea/codecell

v1.4.4

Published

Now you can integrate our code cells into your webapps and run AO LUA anywhere πŸŽ‰

Downloads

54

Readme

BetterIDEa CodeCell

Now you can integrate our code cells into your webapps and run AO LUA anywhere πŸŽ‰

npm downloads X Follow

Installation

npm install @betteridea/codecell

API

<CodeCell .../>

A react component to render a code cell in your app.

Props

| Prop | Type | Description | | -------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | | cellId | string | Unique id for the cell | | appName | string | Unique app name | | code | string | Initial code for the cell | | nowallet | boolean | Set this to true if you dont want to use a web wallet, and generate a local jwk file (works on mobile) Recommended for playgrounds | | enableToasts | boolean | Set this to true if you want to enable toast notifications for the cell | | onAOProcess | (pid:string) => void | Callback function that run whenever a process is is loaded | | onNewMessage | (msgs: msg[]) => void | Callback function, runs whenever process gets new messages | | onInbox | (inbox: msg[]) => void | Callback function, runs whenever Inbox is received after calling getInbox() | | width | string | Width of the cell | | height | string | Height of the cell | | className | string | Class names for styling | | style | React.CSSProperties | Inline styles | | devMode | boolean | Boolean to enable dev mode |

getInbox(...)

Fetches latest Inbox messages from the process.

Arguments

| Argument | Type | Description | | --------- | --------- | -------------------------- | | cellId | string | Unique id of the cell | | devMode | boolean | Boolean to enable dev mode |

setCellCode(...)

To update the code in a cell, after it has been rendered. It is discouraged to update code by changing the code prop directly, since it re-renders the webview, again this is personal preference.

Arguments

| Argument | Type | Description | | --------- | --------- | -------------------------- | | cellId | string | Unique id of the cell | | code | string | Code to set in the cell | | devMode | boolean | Boolean to enable dev mode |

Usage

import { CodeCell } from '@betteridea/codecell';

// in your react app
<CodeCell
  cellId="1"
  appName="BetterIDEa-Code-Cell"
  code="print('Portable code cell ftw!')"
  onAOProcess={(pid)=> console.log("using process: ", pid)}
  onNewMessage={(msgs) => console.log("new messages: ", msgs)}
  onInbox={(inbox) => console.log("got inbox: ", inbox)}
/>

To update the cell with a different code snippet, you can use the setCellCode function.

import { setCellCode, getInbox } from '@betteridea/codecell';

...

// This will update the code in the cell with the id provided
setCellCode("1", "print('Updated code!')");

// This will fetch the latest inbox messages from the process
getInbox("1");
// as soon as the inbox is received, onInbox callback will be called

runCell() function has been deprecated due to security reasons, since it might be possible anyone can run some mischevious code in your process without you knowing.

~~runCell(...)~~ (deprecated due to security reasons)

~~To run the code in a cell, after it has been rendered (optional, since the cell already has a run button)~~

~~Arguments~~

  • ~~cellId - Unique id of the cell to run~~
  • ~~devMode - Boolean to enable dev mode~~
import { runCell } from '@betteridea/codecell';

...

// This will run whatever code is typed in the cell with the id provided
runCell("1");

Developing

To start the vite development server, run:

cd packages/codecell
npm install
npm run dev

then make changes to the component and run function and test them in the vite app at http://localhost:5173

  1. CodeCell component -> ./src/components/CodeCell.tsx

  2. Library functions -> ./src/lib

  3. /codecell webview -> next_app/src/pages/codecell.tsx

The package is essentially a wrapper around https://ide.betteridea.dev/codecell route from the main IDE to run code in any webapp through a webview.