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

sb-edit

v0.14.0

Published

Import, edit, and export Scratch project files

Downloads

38

Readme

sb-edit

sb-edit is a javascript library for manipulating Scratch project files.

🚧 Warning!

sb-edit is still a work-in-progress. Not everything will work, and the API will probably change drastically. Don't get too comfortable the way things are. ;)

Importing and exporting

sb-edit allows importing and exporting a variety of Scratch project file types:

| File Format | Import | Export | | ------------------------------------------------------ | ---------- | -------------- | | Scratch 3.0 (.sb3) | ✅ Yes | ✅ Yes | | Scratch 2.0 (.sb2) | 🕒 Planned | 🕒 Planned | | Leopard | ❌ No | ✅ Yes | | scratchblocks | 👻 Maybe! | 🚧 In progress |

Editing

sb-edit can also be used to modify Scratch projects. A few things you can/will be able to do with sb-edit:

| | Add | Edit | Delete | | ------------------- | ---------- | ---------- | ---------- | | Sprites | 🕒 Planned | ✅ Yes | ✅ Yes | | Stage | ❌ No | ✅ Yes | ❌ No | | Scripts | 🕒 Planned | 🕒 Planned | 🕒 Planned | | Costumes and sounds | 🕒 Planned | 🕒 Planned | 🕒 Planned |

CLI Examples

To use the sb-edit CLI, first install it globally using the following command:

$ npm i -g sb-edit

Convert .sb3 project to Leopard

$ sb-edit --input path/to/project.sb3 --output path/to/output-folder

Convert .sb3 project to Leopard .zip

$ sb-edit --input path/to/project.sb3 --output path/to/output-folder.zip

Code Examples

Import an .sb3 file in Node

const { Project } = require("sb-edit");
const fs = require("fs");
const path = require("path");

const file = fs.readFileSync(path.join(__dirname, "myProject.sb3"));
const project = await Project.fromSb3(file);

console.log(project);

Export an .sb3 file in Node

const { Project } = require("sb-edit");
const fs = require("fs");
const path = require("path");

const project = /* Get yourself a `Project`... */;

const saveLocation = path.join(__dirname, "myProject.sb3");
fs.writeFileSync(saveLocation, Buffer.from(await project.toSb3()));

// `project` is now saved at ./myProject.sb3

Get Leopard code for project

const project = /* Get yourself a `Project`... */;

console.log(project.toLeopard({ printWidth: 100 })); // Optionally pass a Prettier config object!

Development

If you want to help develop the sb-edit package, you'll need to follow these steps:

Step 1: Download sb-edit and prepare to use

> git clone https://github.com/PullJosh/sb-edit.git
> cd sb-edit
> npm link # Allow using sb-edit in another local project

Step 2: Add sb-edit as dependency in another project

> cd my-cool-project
> npm init # This should be a node project
> npm link sb-edit # Similar to `npm install` but uses local version

Step 3: Modify sb-edit

If you make any changes to the sb-edit source code, you'll have to rebuild the package. Here's how:

> cd sb-edit # Cloned from Github and then edited
> npm run build # Build the new version!
> npm run watch # Watch files and rebuild automatically when code is changed

You can also run the Jest tests to make sure you didn't break anything:

> cd sb-edit # You're probably already here ;)
> npm test # Run Jest tests
> npm run lint # Check code for style problems

And finally, make sure everything is pretty:

> cd sb-edit
> npm run format # Format code to look nice with Prettier