Code Monkey home page Code Monkey logo

sb-edit's Introduction

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

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

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!

sb-edit's People

Contributors

towerofnix avatar pulljosh avatar adroitwhiz avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.