Skip to content

Bashamega/scratch-compiler

Repository files navigation

Scratch Compiler

A monorepo for compiling Scratch 3 (.sb3) projects into standalone, high-performance web applications using TypeScript and Konva.js.

Overview

The Scratch Compiler transforms Scratch project files into a directory containing:

  • index.html: A clean entry point for the web application.
  • assets/: All costumes and sounds extracted from the original .sb3 file.
  • src/main.js: A generated JavaScript file that initializes the project state.
  • src/engine.min.js: A lightweight runtime that handles rendering and execution.

Project Structure

This project is managed as a PNPM workspace:

  • packages/cli: The command-line interface used to compile .sb3 files.
    • Extracts assets and project.json.
    • Generates the main.js loader.
    • Packages the static web template.
  • packages/client: The browser runtime (engine).
    • Built with Konva.js for hardware-accelerated 2D rendering.
    • Defines the Stage and Sprite primitives.
  • packages/types: Shared TypeScript definitions for the Scratch 3.0 file format.

Current State

The project is currently in early development.

Supported Features

  • Extraction of .sb3 archives.
  • Automated asset extraction (Images, SVGs, Audio).
  • Migration of project structure (Stage and Sprite initial states).
  • Generation of a readable main.js file.
  • Basic rendering engine using Konva.js.
  • Basic events (flag, click, keypress, broadcast).
  • Monorepo setup with optimized build pipeline (esbuild + TSC).

In Progress / Roadmap

  • Block execution engine (interpreting Scratch scripts).
  • Support for Scratch variables and lists.
  • Sound playback integration.
  • Advanced graphic effects (ghost, color, etc.).
  • Pen extension support.

Getting Started

Prerequisites

Installation

pnpm install

Building

Build the entire workspace:

pnpm run build

Compiling a Scratch Project

To compile a .sb3 file:

pnpm run cli:start --file path/to/your/project.sb3 --output ./dist-web

License

MIT

About

Compile Scratch projects into HTML, JavaScript, and CSS - UNDER DEVELOPMENT

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages