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

@turbowarp/sb3fix

v0.3.2

Published

Fix corrupted Scratch projects

Downloads

681

Readme

sb3fix

https://turbowarp.github.io/sb3fix/

Fix corrupted Scratch 3 projects.

API

Install with:

npm install @turbowarp/sb3fix

Then use from Node.js:

const sb3fix = require('@turbowarp/sb3fix');
const fs = require('fs');

const run = async () => {
  // Fix a .sb3 or .sprite3 with sb3fix.fixZip()
  // Input can be an ArrayBuffer, Uint8Array, Blob, File, or Node.js Buffer.
  // Output will be Uint8Array.
  // This method returns a Promise. If there is an error, that promise will reject.
  const brokenZip = fs.readFileSync('your-broken-project.sb3');
  const fixedZip = await sb3fix.fixZip(brokenZip);
  console.log(fixedZip);

  // Fix just a project.json or sprite.json with sb3fix.fixJSON()
  // Input can be a parsed project.json object or a parsed sprite.json object or a string.
  // If the input is an object, that object will be modified in-place instead of being copied.
  // Output will be a parsed project.json object or a parsed sprite.json object depending on input.
  // This method is NOT async. If there is an error, a plain JavaScript error will be thrown.
  const brokenJSON = fs.readFileSync('your-broken-project.json', 'utf-8');
  const fixedJSON = sb3fix.fixJSON(brokenJSON);
  console.log(fixedJSON);

  // sb3fix is deterministic. The same input will always give the same output, bit-for-bit.

  // Both sb3fix methods take in an optional options object.
  const options = {
    // While sb3fix runs, it'll log what it's doing and what it fixed. You can monitor those
    // using this callback. These messages are primarily a debugging tool, so the exact output
    // is not stable and may change without warning.
    logCallback: (message) => {
      console.log(message);
    }
  };
  // To use the above options, just supply as the second argument when you call sb3fix:
  await sb3fix.fixZip(brokenZip, options);
  sb3fix.fixJSON(brokenJSON, options);
};

run();

Development

Install things:

git clone https://github.com/TurboWarp/sb3fix.git
cd sb3fix
npm ci

Source code is in the src folder. During development do:

npm start

Then open dist/index.html in your favorite browser (there isn't a localhost development server).

For the final build:

npm run build

All changes should have a corresponding test. Add test sb3 files in tests/samples, then run:

npm run update

Then check that the changes in tests/expected-output match what you expect. No unexpected changes! You can check if all the tests still pass with:

npm run test

License

Copyright (C) 2023-2024 Thomas Weber

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.