/scratch-blocks

Modern scratch-blocks.

Primary LanguageJavaScriptApache License 2.0Apache-2.0

Evex Scratch-Blocks

JSR

Scratch Blocks is a library for building creative computing interfaces.

An image of Scratch Blocks running on a tablet

What is this

scratch-blocks is a library to create visual programming environment. It's used in block editor on Scratch. It's also fork of Blockly.

However, Scratch Team forked Blockly in 20161. Currently, there are ESM and most of developers use it. ESM is released 2015, so Blockly which was in 2016 hadn't used ESM, used Google Closure Library. After that, Blockly migrated to ESM, but Scratch Team didn't migrate to ESM. Google Closure Library is a very old architecture. It changes global namespace. And it's difficult to use it with Vite. So we needed to get Scratch Blocks which uses ESM, but Scratch Team is conservative and we think Scratch Team won't migrate and accept PR.

Then we forked Scratch Blocks. It is patched to migrate to ESM. Scratch Blocks can't work with Vite, in contrast it works with Vite!

Usage

The package is published in JSR. You can install this with npm, yarn, pnpm, Deno, Bun, and others.

npx jsr add @evex/scratch-blocks # npm
yarn dlx jsr add @evex/scratch-blocks # yarn
pnpm dlx jsr add @evex/scratch-blocks # pnpm
deno add jsr:@evex/scratch-blocks # Deno
bunx jsr add @evex/scratch-blocks # Bun

Or, you can directly use in browser with esm.sh: https://esm.sh/jsr/@evex/scratch-blocks.

To import API,

import Blockly from '@evex/scratch-blocks'

// Or, with esm.sh
import Blockly from 'https://esm.sh/jsr/@evex/scratch-blocks'

Footnotes

  1. https://github.com/scratchfoundation/scratch-blocks/commit/b66a514a196ffc9be45bc346e3812d3fe8239c8f