Spaces:
Build error
Build error
File size: 4,810 Bytes
30c32c8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
## PenguinMod/PenguinMod-Vm
Modified Scratch VM with a JIT compiler and more features.
This is a drop-in replacement for LLK/scratch-vm.
## Setup
See https://github.com/TurboWarp/scratch-gui/wiki/Getting-Started to setup the complete TurboWarp environment.
If you just want to play with the VM then it's the same process as upstream scratch-vm.
## Extension authors
If you only use the standard reporter, boolean, and command block types, everything should just work without any changes.
## Compiler Overview
For a high-level overview of how the compiler works, see https://docs.turbowarp.org/how
For more technical information, read the code in src/compiler.
## Public API
This section was too out of date to be useful. We hope to re-add it as some point.
<!--
## scratch-vm
#### 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).
[](https://travis-ci.org/LLK/scratch-vm)
[](https://coveralls.io/github/LLK/scratch-vm?branch=develop)
## Installation
This requires you to have Git and Node.js installed.
To install as a dependency for your own application:
```bash
npm install scratch-vm
```
To set up a development environment to edit scratch-vm yourself:
```bash
git clone https://github.com/LLK/scratch-vm.git
cd scratch-vm
npm install
```
## Development Server
This requires Node.js to be installed.
For 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).
## Running the Development Server
Open a Command Prompt or Terminal in the repository and run:
```bash
npm start
```
## Playground
To 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.

## Standalone Build
```bash
npm run build
```
```html
<script src="/path/to/dist/web/scratch-vm.js"></script>
<script>
var vm = new window.VirtualMachine();
// do things
</script>
```
## How to include in a Node.js App
For an extended setup example, check out the /src/playground directory, which includes a fully running VM instance.
```js
var VirtualMachine = require('scratch-vm');
var vm = new VirtualMachine();
// Block events
Scratch.workspace.addChangeListener(vm.blockListener);
// Run threads
vm.start();
```
## Abstract Syntax Tree
#### Overview
The 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.
#### Anatomy of a Block
The 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:
```json
{
"_blocks": {
"Q]PK~yJ@BTV8Y~FfISeo": {
"id": "Q]PK~yJ@BTV8Y~FfISeo",
"opcode": "event_whenkeypressed",
"inputs": {
},
"fields": {
"KEY_OPTION": {
"name": "KEY_OPTION",
"value": "space"
}
},
"next": null,
"topLevel": true,
"parent": null,
"shadow": false,
"x": -69.333333333333,
"y": 174
}
},
"_scripts": [
"Q]PK~yJ@BTV8Y~FfISeo"
]
}
```
## Testing
```bash
npm test
```
```bash
npm run coverage
```
## Publishing to GitHub Pages
```bash
npm run deploy
```
This will push the currently built playground to the gh-pages branch of the
currently tracked remote. If you would like to change where to push to, add
a repo url argument:
```bash
npm run deploy -- -r <your repo url>
```
## Donate
We 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!
-->
e
|