{"id":23792480,"url":"https://github.com/se2p/scratch-vm","last_synced_at":"2026-06-30T10:31:43.754Z","repository":{"id":80478201,"uuid":"267892789","full_name":"se2p/scratch-vm","owner":"se2p","description":null,"archived":false,"fork":false,"pushed_at":"2022-09-21T10:54:48.000Z","size":16644,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-02-21T13:30:35.311Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/se2p.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-29T15:33:25.000Z","updated_at":"2022-02-03T21:13:40.000Z","dependencies_parsed_at":"2023-02-27T13:16:10.000Z","dependency_job_id":null,"html_url":"https://github.com/se2p/scratch-vm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/se2p/scratch-vm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/se2p%2Fscratch-vm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/se2p%2Fscratch-vm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/se2p%2Fscratch-vm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/se2p%2Fscratch-vm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/se2p","download_url":"https://codeload.github.com/se2p/scratch-vm/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/se2p%2Fscratch-vm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34963633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-30T02:00:05.919Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-01T18:35:17.921Z","updated_at":"2026-06-30T10:31:43.733Z","avatar_url":"https://github.com/se2p.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## scratch-vm\n#### Scratch VM is a library for representing, running, and maintaining the state of computer programs written using [Scratch Blocks](https://github.com/LLK/scratch-blocks).\n\n[![Build Status](https://travis-ci.org/LLK/scratch-vm.svg?branch=develop)](https://travis-ci.org/LLK/scratch-vm)\n[![Coverage Status](https://coveralls.io/repos/github/LLK/scratch-vm/badge.svg?branch=develop)](https://coveralls.io/github/LLK/scratch-vm?branch=develop)\n[![Greenkeeper badge](https://badges.greenkeeper.io/LLK/scratch-vm.svg)](https://greenkeeper.io/)\n\n## Installation\nThis requires you to have Git and Node.js installed.\n\nTo install as a dependency for your own application:\n```bash\nnpm install scratch-vm\n```\nTo set up a development environment to edit scratch-vm yourself:\n```bash\ngit clone https://github.com/LLK/scratch-vm.git\ncd scratch-vm\nnpm install\n```\n\n## Development Server\nThis requires Node.js to be installed.\n\nFor convenience, we've included a development server with the VM. This is sometimes useful when running in an environment that's loading remote resources (e.g., SVGs from the Scratch server). If you would like to use your modified VM with the full Scratch 3.0 GUI, [follow the instructions to link the VM to the GUI](https://github.com/LLK/scratch-gui/wiki/Getting-Started).\n\n## Running the Development Server\nOpen a Command Prompt or Terminal in the repository and run:\n```bash\nnpm start\n```\n\n## Playground\nTo view the Playground, make sure the dev server's running and go to [http://localhost:8073/playground/](http://localhost:8073/playground/) - you will be directed to the playground, which demonstrates various tools and internal state.\n\n![VM Playground Screenshot](https://i.imgur.com/nOCNqEc.gif)\n\n\n## Standalone Build\n```bash\nnpm run build\n```\n\n```html\n\u003cscript src=\"/path/to/dist/web/scratch-vm.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    var vm = new window.VirtualMachine();\n    // do things\n\u003c/script\u003e\n```\n\n## How to include in a Node.js App\nFor an extended setup example, check out the /src/playground directory, which includes a fully running VM instance.\n```js\nvar VirtualMachine = require('scratch-vm');\nvar vm = new VirtualMachine();\n\n// Block events\nScratch.workspace.addChangeListener(vm.blockListener);\n\n// Run threads\nvm.start();\n```\n\n## Abstract Syntax Tree\n\n#### Overview\nThe Virtual Machine constructs and maintains the state of an [Abstract Syntax Tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree) (AST) by listening to events emitted by the [scratch-blocks](https://github.com/LLK/scratch-blocks) workspace via the `blockListener`. Each target (code-running object, for example, a sprite) keeps an AST for its blocks. At any time, the current state of an AST can be viewed by inspecting the `vm.runtime.targets[...].blocks` object.\n\n#### Anatomy of a Block\nThe VM's block representation contains all the important information for execution and storage. Here's an example representing the \"when key pressed\" script on a workspace:\n```json\n{\n  \"_blocks\": {\n    \"Q]PK~yJ@BTV8Y~FfISeo\": {\n      \"id\": \"Q]PK~yJ@BTV8Y~FfISeo\",\n      \"opcode\": \"event_whenkeypressed\",\n      \"inputs\": {\n      },\n      \"fields\": {\n        \"KEY_OPTION\": {\n          \"name\": \"KEY_OPTION\",\n          \"value\": \"space\"\n        }\n      },\n      \"next\": null,\n      \"topLevel\": true,\n      \"parent\": null,\n      \"shadow\": false,\n      \"x\": -69.333333333333,\n      \"y\": 174\n    }\n  },\n  \"_scripts\": [\n    \"Q]PK~yJ@BTV8Y~FfISeo\"\n  ]\n}\n```\n\n## Testing\n```bash\nnpm test\n```\n\n```bash\nnpm run coverage\n```\n\n## Publishing to GitHub Pages\n```bash\nnpm run deploy\n```\n\nThis will push the currently built playground to the gh-pages branch of the\ncurrently tracked remote.  If you would like to change where to push to, add\na repo url argument:\n```bash\nnpm run deploy -- -r \u003cyour repo url\u003e\n```\n\n## Donate\nWe provide [Scratch](https://scratch.mit.edu) free of charge, and want to keep it that way! Please consider making a [donation](https://secure.donationpay.org/scratchfoundation/) to support our continued engineering, design, community, and resource development efforts. Donations of any size are appreciated. Thank you!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fse2p%2Fscratch-vm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fse2p%2Fscratch-vm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fse2p%2Fscratch-vm/lists"}