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 🙏

© 2025 – Pkg Stats / Ryan Hefner

tswarp

v0.2.1

Published

This package converts TS to Stylus

Downloads

15

Readme

Tswarp

Tswarp

🚀 Tswarp is a powerful tool that simplifies the process of converting TypeScript code to Stylus Rust and managing Stylus Rust projects. With just a few commands, you can initialize projects, compile TypeScript to Stylus Rust, and validate Stylus Rust projects using cargo stylus check.


Requirements

Before using tswarp, ensure your environment is properly set up with the following:

1. Rustup

Install Rustup, the Rust toolchain installer:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

2. Cargo

Cargo is the Rust package manager and is included with Rustup.

3. Add the WASM Compilation Target

Add the WebAssembly (WASM) target for Rust:

rustup target add wasm32-unknown-unknown
# Verify it's installed
rustup target list --installed | grep wasm

4. Install cargo-stylus

Install the cargo-stylus package for Stylus Rust validation:

cargo install --force cargo-stylus
# Quick check to ensure it's installed
cargo stylus --version  # Should show 0.4.0 or newer

5. Install Node.js Dependencies

Globally install the required Node.js packages for TypeScript support:

npm install -g typescript ts-node @types/node

Ensure that the above packages are properly installed before proceeding with the installation of tswarp.


Setting Up Your Local Development Environment

To set up a local Stylus Rust development environment, follow these steps:

Prerequisite: Install Docker

Ensure you have Docker installed on your system. You can download and install Docker from Docker's official website.

Steps:

  1. Clone the Devnode Repository
git clone https://github.com/OffchainLabs/nitro-devnode.git
cd nitro-devnode
  1. Launch Your Local Arbitrum Chain
./run-dev-node.sh

This command uses Docker to set up and run the local Arbitrum chain. Ensure Docker is running before executing this command.


Installation

Install the CLI via NPM

Install the tswarp CLI globally via npm:

npm install -g tswarp

You can now use tswarp as a global command.


Usage

Commands

1. Initialize a New Project

tswarp init <projectname>
  • Description: Creates a new project with a TypeScript converter and Stylus Rust logic templates.
  • Example:
    tswarp init myproject
  • Result:
    • A new directory myproject is created.
    • TypeScript templates are placed under converter/.
    • Stylus Rust templates are placed under logic/.

2. Compile TypeScript to Stylus Rust

tswarp compile
  • Description: Compiles the TypeScript files in the converter directory into Stylus Rust code.
  • Note: This command should be run inside the converter directory.
  • Example:
    cd converter
    tswarp compile

3. Run cargo stylus check

tswarp build
  • Description: Runs the cargo stylus check command in the current directory to validate Stylus Rust projects.
  • Note: This command should be run inside the logic directory.
  • Example:
    cd logic
    tswarp build

4. View CLI Version

tswarp --version
  • Description: Displays the current version of the Tswarp.
  • Example:
    tswarp --version

5. View Help Information

tswarp --help
  • Description: Shows the help menu with a list of all available commands.
  • Example:
    tswarp --help

Project Structure

When you initialize a new project with tswarp init <projectname>, the following structure is created:

<projectname>/
├── converter/                 # TypeScript project
│   ├── counter.ts             # TypeScript example file
│   ├── package.json           # Node.js package configuration
│   └── node_modules/          # Node.js dependencies
├── logic/                     # Stylus Rust project
│   ├── Cargo.toml             # Stylus Rust package configuration
│   ├── Cargo.lock             # Stylus Rust dependencies lock file
│   ├── rust-toolchain.toml    # Stylus Rust toolchain configuration
│   ├── src/                   # Stylus Rust source code
│   │   ├── main.rs            # Main Stylus Rust entry point
│   │   └── lib.rs             # Stylus Rust library code
│   └── examples/              # Example Stylus Rust files
│       └── counter.rs

Development Workflow

Initializing a Project

  1. Create a New Project:

    tswarp init myproject
  2. Navigate to the Project Directory:

    cd myproject

Compiling TypeScript to Stylus Rust

  1. Run the Compiler:

    cd converter
    tswarp compile
  2. Check the Generated Stylus Rust Files:

    • Output files will be added to the Stylus Rust logic directory.

Validating Stylus Rust Code

  1. Run cargo stylus check:

    cd logic
    tswarp build
  2. Fix Any Stylus Rust Issues:

    • Review and fix any warnings or errors reported by the cargo stylus check command.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork this repository.
  2. Create a new branch for your feature or bug fix.
  3. Commit your changes with clear messages.
  4. Submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Acknowledgments

  • Stylus Rust: The powerful toolchain for systems programming.
  • TypeScript: A strongly typed programming language for JavaScript.
  • Node.js: The runtime for running the CLI.

Enjoy using Tswarp! 🚀