{"_id":"@alfaris/scratch-vm","name":"@alfaris/scratch-vm","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@alfaris/scratch-vm","version":"1.0.0","description":"Virtual Machine for Scratch 3.0","author":{"name":"Massachusetts Institute of Technology"},"license":"AGPL-3.0-only","homepage":"https://github.com/scratchfoundation/scratch-vm#readme","repository":{"type":"git","url":"git+https://github.com/scratchfoundation/scratch-vm.git","sha":"e6f5711f25f607ce8370a5a7afcfb391b349a6e1"},"main":"./dist/node/scratch-vm.js","browser":"./dist/web/scratch-vm.js","exports":{"webpack":"./src/index.js","browser":"./dist/web/scratch-vm.js","node":"./dist/node/scratch-vm.js","default":"./src/index.js"},"scripts":{"build":"npm run docs && webpack --progress","coverage":"tap ./test/{unit,integration}/*.js --coverage --coverage-report=lcov","docs":"jsdoc -c .jsdoc.json","i18n:src":"mkdirp translations/core && format-message extract --out-file translations/core/en.json src/extensions/**/index.js","i18n:push":"tx-push-src scratch-editor extensions translations/core/en.json","lint":"eslint . && format-message lint src/**/*.js","prepare":"husky install","prepublish":"in-publish && npm run build || not-in-publish","start":"webpack serve","tap":"tap ./test/{unit,integration}/*.js","tap:unit":"tap ./test/unit/*.js","tap:integration":"tap ./test/integration/*.js","test":"npm run lint && npm run tap","watch":"webpack --progress --watch","version":"json -f package.json -I -e \"this.repository.sha = '$(git log -n1 --pretty=format:%H)'\""},"config":{"commitizen":{"path":"cz-conventional-changelog"}},"browserslist":["Chrome >= 63","Edge >= 15","Firefox >= 57","Safari >= 11"],"tap":{"branches":60,"functions":70,"lines":70,"statements":70},"dependencies":{"@vernier/godirect":"^1.5.0","arraybuffer-loader":"^1.0.6","atob":"^2.1.2","btoa":"^1.2.1","buffer":"^6.0.3","canvas-toBlob":"^1.0.0","decode-html":"^2.0.0","diff-match-patch":"^1.0.4","format-message":"^6.2.1","htmlparser2":"^3.10.0","immutable":"^3.8.1","jszip":"^3.1.5","minilog":"^3.1.0","scratch-audio":"^2.0.0","scratch-parser":"^6.0.0","scratch-render":"^2.0.0","scratch-sb1-converter":"^2.0.0","scratch-storage":"^4.0.0","scratch-svg-renderer":"3.0.114","scratch-translate-extension-languages":"^1.0.0","text-encoding":"^0.7.0","uuid":"^8.3.2","web-worker":"^1.3.0"},"devDependencies":{"@babel/core":"7.27.1","@babel/eslint-parser":"7.27.1","@babel/preset-env":"7.27.1","@commitlint/cli":"17.8.1","@commitlint/config-conventional":"17.8.1","adm-zip":"0.4.11","babel-loader":"9.2.1","callsite":"1.0.0","copy-webpack-plugin":"4.6.0","docdash":"1.2.0","eslint":"8.57.1","eslint-config-scratch":"9.0.9","expose-loader":"1.0.3","file-loader":"6.2.0","format-message-cli":"6.2.4","husky":"8.0.3","in-publish":"2.0.1","js-md5":"0.7.3","jsdoc":"3.6.11","json":"^9.0.4","pngjs":"3.4.0","scratch-blocks":"1.1.210","scratch-l10n":"5.0.230","scratch-render-fonts":"1.0.190","scratch-semantic-release-config":"3.0.0","scratch-webpack-configuration":"3.0.0","script-loader":"0.7.2","semantic-release":"19.0.5","stats.js":"0.17.0","tap":"16.3.10","webpack":"5.99.7","webpack-cli":"4.10.0","webpack-dev-server":"3.11.3"},"_id":"@alfaris/scratch-vm@1.0.0","gitHead":"4ded743497d58380f07c3ad8889c175b8c419819","bugs":{"url":"https://github.com/scratchfoundation/scratch-vm/issues"},"_nodeVersion":"22.17.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-Thnh/rncut/dj0KCL2f1Gpi5R7xkv/GSNmkxwFGyzLhWb2FI4f72O/Vuf2ZenImgHQDvtor7vH9iVu9+2l6Dyg==","shasum":"c66034d15e86dc9df292c56e26d8dde389885f94","tarball":"https://registry.npmjs.org/@alfaris/scratch-vm/-/scratch-vm-1.0.0.tgz","fileCount":187,"unpackedSize":24769364,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIF+PLX4XQMIIGsqhgFYZQnZ5ZCxATHA6wVtBxivYT+V/AiB51hgPa8v7ovxhVjRrPgTu1YbY8a1EK817jw0uT+ebIQ=="}]},"_npmUser":{"name":"alfaris","email":"muhammedalfariz8003@gmail.com"},"directories":{},"maintainers":[{"name":"alfaris","email":"muhammedalfariz8003@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/scratch-vm_1.0.0_1760606960475_0.11559577735559756"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-16T09:29:20.401Z","1.0.0":"2025-10-16T09:29:20.884Z","modified":"2025-10-16T09:29:21.198Z"},"maintainers":[{"name":"alfaris","email":"muhammedalfariz8003@gmail.com"}],"description":"Virtual Machine for Scratch 3.0","homepage":"https://github.com/scratchfoundation/scratch-vm#readme","repository":{"type":"git","url":"git+https://github.com/scratchfoundation/scratch-vm.git","sha":"e6f5711f25f607ce8370a5a7afcfb391b349a6e1"},"author":{"name":"Massachusetts Institute of Technology"},"bugs":{"url":"https://github.com/scratchfoundation/scratch-vm/issues"},"license":"AGPL-3.0-only","readme":"## scratch-vm\n\n## **⚠️ NOTICE: Repository Migration to Mono-Repo ⚠️**\n\nThe Scratch Team has migrated the `scratch-vm` module into a new mono-repo,\n[`scratch-editor`](https://github.com/scratchfoundation/scratch-editor). This independent `scratch-vm` repository\n**will be archived**. Any new issues or pull requests should be opened in the mono-repo.\n\nThe new mono-repo version of `scratch-vm` is published to the NPM registry as\n[`@scratch/scratch-vm`](https://www.npmjs.com/package/@scratch/scratch-vm).\n\n**Contributors:**\n\n* I would like to thank all past contributors for their work on this repository.\n* If you are aware of valuable issues or pull requests, please consider re-opening them in the mono-repo. If you do\n  so, please link the new issue or pull request to the original one in this repository to help others find it and to\n  reduce the chance of duplicate work.\n* We apologize for the inconvenience and greatly appreciate your help with this transition!\n\nFor more information, see the [`scratch-editor` repository on GitHub](https://github.com/scratchfoundation/scratch-editor).\n\n## Overview\n\n#### Scratch VM is a library for representing, running, and maintaining the state of computer programs written using [Scratch Blocks](https://github.com/scratchfoundation/scratch-blocks).\n\n[![CI/CD](https://github.com/scratchfoundation/scratch-vm/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/scratchfoundation/scratch-vm/actions/workflows/ci-cd.yml)\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/scratchfoundation/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/scratchfoundation/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<script src=\"/path/to/dist/web/scratch-vm.js\"></script>\n<script>\n    var vm = new window.VirtualMachine();\n    // do things\n</script>\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/scratchfoundation/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 <your repo url>\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","readmeFilename":"README.md","_rev":"1-1cfccf9c9d383d8e0cc26d14e70f2e77"}