Skip to main content
This release is 2 versions behind 0.2.0 — the latest version of @mbw/sb3. Jump to latest

@mbw/sb3@0.1.7
Built and signed on GitHub Actions

Abstractions for creating and exporting Scratch project files.

This package works with Node.js, Deno, Bun, Browsers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
a week ago (0.1.7)

@mbw/sb3

Abstractions for creating and exporting Scratch project (.sb3) files.

Note

This package is not affiliated with Scratch or the Scratch foundation.

import { block, Script, Project, Target } from "@mbw/sb3";

using EMPTY_FILE = await Deno.open("./empty.svg");
const EMPTY_SVG = EMPTY_FILE.readable;

const project = new Project();

const sprite = new Target("sprite");
sprite.costumes.push({
  name: "Blank",
  file: EMPTY_SVG,
  type: "svg",
});
sprite.addScript(
  new Script({ topLevel: true }).push(block("event_whenflagclicked")).push(
    block("looks_sayforsecs", {
      inputs: {
        MESSAGE: { type: 10, value: "Hello, world!" },
        SECS: { type: 4, value: "2" },
      },
    })
  )
);
project.addTarget(sprite);

const stage = new Target();
stage.costumes.push({
  name: "Blank",
  file: EMPTY_SVG,
  type: "svg",
});
project.addTarget(stage);

const zip = await project.zip();
await Deno.writeFile("project.sb3", zip);
Built and signed on
GitHub Actions
View transparency log

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@mbw/sb3

Import symbol

import * as sb_ from "@mbw/sb3";
or

Import directly with a jsr specifier

import * as sb_ from "jsr:@mbw/sb3";

Add Package

pnpm i jsr:@mbw/sb3
or (using pnpm 10.8 or older)
pnpm dlx jsr add @mbw/sb3

Import symbol

import * as sb_ from "@mbw/sb3";

Add Package

yarn add jsr:@mbw/sb3
or (using Yarn 4.8 or older)
yarn dlx jsr add @mbw/sb3

Import symbol

import * as sb_ from "@mbw/sb3";

Add Package

npx jsr add @mbw/sb3

Import symbol

import * as sb_ from "@mbw/sb3";

Add Package

bunx jsr add @mbw/sb3

Import symbol

import * as sb_ from "@mbw/sb3";