mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-05-15 07:51:04 -04:00
parent
29a595345a
commit
220d614a9d
3 changed files with 34 additions and 18 deletions
47
README.md
47
README.md
|
@ -6,6 +6,8 @@
|
||||||
[](https://david-dm.org/LLK/scratch-vm#info=devDependencies)
|
[](https://david-dm.org/LLK/scratch-vm#info=devDependencies)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
This requires you to have Git and Node.js installed.
|
||||||
|
|
||||||
In your own node environment/application:
|
In your own node environment/application:
|
||||||
```bash
|
```bash
|
||||||
npm install https://github.com/LLK/scratch-vm.git
|
npm install https://github.com/LLK/scratch-vm.git
|
||||||
|
@ -17,27 +19,23 @@ cd scratch-vm
|
||||||
npm install
|
npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Setup
|
## Development Server
|
||||||
For an extended setup example, check out the /playground directory, which includes a fully running VM instance.
|
This requires Node.js to be installed.
|
||||||
```js
|
|
||||||
var VirtualMachine = require('scratch-vm');
|
|
||||||
var vm = new VirtualMachine();
|
|
||||||
|
|
||||||
// Block events
|
For convenience, we've included a development server with the VM. This is useful because the VM can take advantage of executing in a WebWorker, which is not permitted in a local file.
|
||||||
workspace.addChangeListener(vm.blockListener);
|
|
||||||
var flyoutWorkspace = workspace.toolbox_.flyout_.workspace_;
|
|
||||||
flyoutWorkspace.addChangeListener(vm.flyoutBlockListener);
|
|
||||||
|
|
||||||
// Run threads
|
|
||||||
vm.runtime.start();
|
|
||||||
```
|
|
||||||
## Development Server and Playground
|
|
||||||
For convenience, we've included a development server with the VM. This is useful because the VM can take advantage of executing in a WebWorker, which is not permitted in a local file. To start the server, run:
|
|
||||||
|
|
||||||
|
## Running the Development Server
|
||||||
|
Open a Command Prompt or Terminal in the repository and run:
|
||||||
```bash
|
```bash
|
||||||
make serve
|
npm start
|
||||||
```
|
```
|
||||||
and go to [http://localhost:8080/](http://localhost:8080/) - you will be redirected to the playground, which demonstrates various tools and internal state.
|
Or on Windows:
|
||||||
|
```bash
|
||||||
|
StartServerWindows.bat
|
||||||
|
```
|
||||||
|
|
||||||
|
## Playground
|
||||||
|
To run the Playground, make sure the dev server's running and go to [http://localhost:8080/](http://localhost:8080/) - you will be redirected to the playground, which demonstrates various tools and internal state.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@ -55,6 +53,21 @@ make build
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## How to include in a Node.js App
|
||||||
|
For an extended setup example, check out the /playground directory, which includes a fully running VM instance.
|
||||||
|
```js
|
||||||
|
var VirtualMachine = require('scratch-vm');
|
||||||
|
var vm = new VirtualMachine();
|
||||||
|
|
||||||
|
// Block events
|
||||||
|
workspace.addChangeListener(vm.blockListener);
|
||||||
|
var flyoutWorkspace = workspace.toolbox_.flyout_.workspace_;
|
||||||
|
flyoutWorkspace.addChangeListener(vm.flyoutBlockListener);
|
||||||
|
|
||||||
|
// Run threads
|
||||||
|
vm.runtime.start();
|
||||||
|
```
|
||||||
|
|
||||||
## Abstract Syntax Tree
|
## Abstract Syntax Tree
|
||||||
|
|
||||||
#### Overview
|
#### Overview
|
||||||
|
|
2
StartServerWindows.bat
Normal file
2
StartServerWindows.bat
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
@echo off
|
||||||
|
node_modules\.bin\webpack-dev-server --host 0.0.0.0 --port 80 --content-base .\
|
|
@ -11,7 +11,8 @@
|
||||||
},
|
},
|
||||||
"main": "./src/index.js",
|
"main": "./src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "make test"
|
"test": "make test",
|
||||||
|
"start": "webpack-dev-server --host 0.0.0.0 --content-base ."
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"htmlparser2": "3.9.0",
|
"htmlparser2": "3.9.0",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue