Template for generating rust-based native projects

Overview

Speedy NAPI-RS template

Use this template

Click use this template above, then find and replace speedy-sourcemap to your desired naming.

Setup Rust toolchain

This project uses Rust and NAPI-RS, so you can install it with:

# Install Rust toolchain on MacOS, Linux.
# For Windows users, you may refer to the website listed above and install the corresponding `.exe`.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

This command will install the latest stable version of Rust standard library, Cargo and other toolchain.

This project is also using Rust 2021, for those developers who have already installed Rust, you may update your toolchain to the latest stable version, which you can update it as follows:

rustup update stable

For more information about the setup, please heads to Rust and NAPI-RS

Setup Node.js

Pnpm is required for handling node modules, also pnpm workspace is enabled for the project, so you can install node modules with:

npm install -g pnpm

pnpm install # Install all node modules in the workspace

Setup WebAssembly

curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

Note: for Apple Silicons, you need to use cargo install wasm-pack to install wasm-pack

Repo Structure

.
├── Cargo.lock
├── Cargo.toml
├── README.md
├── benchmark # Your benchmark goes here
├── core
│   └── your_native_repo_goes_here # Your native repo goes here
├── node
│   ├── Cargo.toml
│   ├── __tests__
│   │   └── unit.spec.ts
│   ├── binding.js
│   ├── build.rs
│   ├── index.d.ts
│   ├── npm # This package is not intended for editing
│   ├── package.json
│   ├── src
│   │   ├── lib.rs
│   │   ├── test.rs
│   │   └── types.rs
│   └── tsconfig.json
├── wasm # Your wasm binding goes here
├── package.json
├── pnpm-workspace.yaml
└── rustfmt.toml # This file is not intended for editing

This project is also using Cargo workspaces for managing multiple crates.

Development

Build Node bindings

# This will only build the unoptimized version for testing
# , which is hugely useful when testing projects with heavy dependencies.
pnpm build:debug --dir node

# Regular optimized build
pnpm build --dir node

Build WebAssembly bindings

pnpm build:wasm

Testing

Rust

cargo test # This will test the whole cargo workspaces, and workspace members are declared in the <project-root>/Cargo.toml

Node

pnpm test # This will run tests under the `node` and `wasm` directory

Publishing

Rust(Cargo)

cargo publish

Node

Node addons are divided into difference npm packages for different platforms and architectures, which you can find here and this is not intended to be edited manually.

# Create a new npm release
cd node
npm version

Make sure you have your commit message starts with chore(release): publish, and CI will automatically publish the release. For more details please refer to CI.yaml

You might also like...

An iterator wrapper that supports Rust-style chaining

Riter (in development) An iterator wrapper that supports Rust-style chaining Install TODO: This package is not yet available. Once it's mature enough,

Mar 3, 2022

Quick One Liners in JavaScript, TypeScript, Python, Rust, Java, Ruby, C, C++

ONE LINERS This repository contains cool and simple one line utility functions to easily use common repetitive methods in JavaScript, TypeScript, Pyth

Mar 2, 2022

Gutenberg + Rust + TypeScript

Gutenberg + Rust + TypeScript This is a minimum block plugin template to rapidly get started building WP blocks using Rust + TypeScript. Follow me on

Dec 23, 2022

Rust's OptionT and ResultT, E, implemented for TypeScript.

oxide.ts Rust's OptionT and ResultT, E, implemented for TypeScript. Features Zero dependencies, full test coverage and examples for every function

Jan 3, 2023

A TOML parsing tool written in Rust for Node.js

@daydog/toml A TOML parsing tool written in Rust for Node.js Installation @daydog/toml is available via npm. npm install @daydog/toml Usage parse You

Jul 20, 2022

Drawing Newton's fractal using pure js, rust-wasm, SIMDs, threads and GPU

Drawing Newton's fractal using pure js, rust-wasm, SIMDs, threads and GPU

Newton's fractal Runtime Newton's fractal renderer. Click to open in your browser Inspired by 3blue1brown's video about Newton's fractal. Drawing

Nov 17, 2022

A simple Rust DApp Calculator in Solana 🦀

Rust Calculator 🖩 in Solana 🦀 This Calculator written Rust using Anchor ⚓ Setting up the Environment: Rust Installation: curl --proto '=https' --tls

Oct 11, 2022

A low-feature, dependency-free and performant test runner inspired by Rust and Deno

minitest A low-feature, dependency-free and performant test runner inspired by Rust and Deno Simplicity: Use the mt test runner with the test function

Nov 12, 2022

A Remix stack setup to run on Deno with support for Rust WASM modules!

Remix + Deno + Rust - Webassembly - The Air Metal Stack Welcome to the Air Metal Stack for Remix! 🦕 + 🦀 This stack is a good choice if you want to

Jan 5, 2023
Comments
  • Unify NAPI and WebAssembly packages

    Unify NAPI and WebAssembly packages

    Currently node and wasm are two separate packages, which is not good for us to unify logic cross platform, thus we have to unify which into one and load them for platform respectively

    opened by h-a-n-a 0
Releases(v0.1)
Owner
speedystack
speedystack
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
An Electron app using NAPI-RS and a native Rust module to implement a Svelte store.

Svelte Store Written in Rust This repo shows a demo of an Electron app running a Svelte UI that reads and writes a Svelte store, but with a twist: the

Dave Ceddia 27 Sep 20, 2022
Remix sandbox repo for Rust compiled to WASM and to native N-API modules

Rust <-> Remix Sandbox Now with both native Rust and WASM versions! If you want to combine the Web Fundamentals & Modern UX of Remix together with the

Ben Wishovich 26 Dec 30, 2022
This template is for generating a .NET C# wrapper for the RabbitMQ client based on your AsyncAPI document.

.NET C# RabbitMQ template This is a .NET C# RabbitMQ template for the AsyncAPI generator This template is for generating a .NET C# wrapper for the Rab

AsyncAPI Initiative 5 Dec 21, 2022
JustGage is a handy JavaScript plugin for generating and animating nice & clean dashboard gauges. It is based on Raphaël library for vector drawing.

JustGage JustGage is a handy JavaScript plugin for generating and animating nice & clean dashboard gauges. It is based on Raphaël library for vector d

Bojan Djuricic 1.8k Jan 3, 2023
Next-level academia! Repository for the Native Overleaf project, attempting to integrate Overleaf with native OS features for macOS, Linux and Windows.

Native Overleaf Overleaf is a fantastic webtool for writing and cooperating on LaTeX documents. However, would it not be even better if it were to beh

Floris-Jan Willemsen 40 Dec 18, 2022
Full-stack-todo-rust-course - we are building this out now in prep for the real course

full-stack-todo-rust-course wip - we are building this out now in prep for the real course Plan Come up with the requirements Create user stories Desi

Brooks Builds 89 Jan 2, 2023
A Rust rewrite of Flameboi that will be more approachable for new developers to contribute to.

Devil Bot Rust Overview A Rust implementation of a Slack bot that will be used by the CodeDevils Slack workspace. All resources are managed using AWS

CodeDevils 11 Dec 21, 2022
A Minecraft launcher written in Rust, with an Electron frontend.

RustMine A Minecraft launcher written in Rust, with an Electron frontend. Why? I thought it would be fun to use two of my most familiar languages, Rus

sussyimpostor 1 Oct 16, 2022