Abstractions for creating and exporting Scratch project (.sb3) files.
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);
Add Package
deno add jsr:@mbw/sb3
Import symbol
import * as sb_ from "@mbw/sb3";
Import directly with a jsr specifier
import * as sb_ from "jsr:@mbw/sb3";
Add Package
pnpm i jsr:@mbw/sb3
pnpm dlx jsr add @mbw/sb3
Import symbol
import * as sb_ from "@mbw/sb3";
Add Package
yarn add jsr:@mbw/sb3
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";