From a173405cc3bb0d4fdd490b0b05de34fd9987b6d0 Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Thu, 15 Sep 2016 00:50:28 -0400 Subject: [PATCH] Initial commit --- .editorconfig | 11 +++++++++++ .eslintignore | 2 ++ .eslintrc | 25 +++++++++++++++++++++++++ .gitignore | 10 ++++++++++ LICENSE | 12 ++++++++++++ Makefile | 26 ++++++++++++++++++++++++++ README.md | 34 ++++++++++++++++++++++++++++++++++ TRADEMARK | 7 +++++++ index.html | 11 +++++++++++ package.json | 35 +++++++++++++++++++++++++++++++++++ playground.config.js | 6 ++++++ src/components/blocks.jsx | 15 +++++++++++++++ src/components/gui.jsx | 17 +++++++++++++++++ src/index.js | 5 +++++ src/playground.jsx | 7 +++++++ webpack.config.js | 33 +++++++++++++++++++++++++++++++++ 16 files changed, 256 insertions(+) create mode 100644 .editorconfig create mode 100644 .eslintignore create mode 100644 .eslintrc create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100644 TRADEMARK create mode 100644 index.html create mode 100644 package.json create mode 100644 playground.config.js create mode 100644 src/components/blocks.jsx create mode 100644 src/components/gui.jsx create mode 100644 src/index.js create mode 100644 src/playground.jsx create mode 100644 webpack.config.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..e84613dd6 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_size = 4 +trim_trailing_whitespace = true + +[*.{js,html}] +indent_style = space diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..3675648e8 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +node_modules/* +build/* diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 000000000..0d2fcadcd --- /dev/null +++ b/.eslintrc @@ -0,0 +1,25 @@ +{ + "parser": "babel-eslint", + "rules": { + "curly": [2, "multi-line"], + "eol-last": [2], + "indent": [2, 4], + "linebreak-style": [2, "unix"], + "max-len": [2, 120, 4], + "no-trailing-spaces": [2, { "skipBlankLines": true }], + "no-unused-vars": [2, {"args": "after-used", "varsIgnorePattern": "^_"}], + "quotes": [2, "single"], + "semi": [2, "always"], + "space-before-function-paren": [2, "always"], + "strict": [2, "never"] + }, + "env": { + "browser": true, + "es6": true, + "node": true + }, + "plugins": [ + "react" + ], + "extends": ["eslint:recommended", "plugin:react/recommended"] +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..db98532d4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# Mac OS +.DS_Store + +# NPM +/node_modules +npm-* + +# Testing +/.nyc_output +/coverage diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..6d00c99e8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,12 @@ +Copyright (c) 2016, Massachusetts Institute of Technology +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..20b8e8eb6 --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +ESLINT=./node_modules/.bin/eslint +NODE=node +WEBPACK=./node_modules/.bin/webpack --progress --colors +WEBPACK_DEV_SERVER=./node_modules/.bin/webpack-dev-server + +# ------------------------------------------------------------------------------ + +build: + $(WEBPACK) + +watch: + $(WEBPACK) --watch + +serve: + $(WEBPACK_DEV_SERVER) --port 8601 --config playground.config.js + +# ------------------------------------------------------------------------------ + +lint: + $(ESLINT) . --ext .js,.jsx + +test: + @make lint + @make build + +.PHONY: build watch serve lint diff --git a/README.md b/README.md new file mode 100644 index 000000000..0b8701c5a --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# scratch-gui +#### Scratch GUI is a set of React components that comprise the interface for creating and running Scratch 3.0 projects + +## Installation +This requires you to have Git and Node.js installed. + +In your own node environment/application: +```bash +npm install https://github.com/LLK/scratch-gui.git +``` +If you want to edit/play yourself: +```bash +git clone git@github.com:LLK/scratch-gui.git +cd scratch-gui +npm install +``` + +## Playground +This requires Node.js to be installed. + +## Running the Playground +Open a Command Prompt or Terminal in the repository and run: +```bash +npm start +``` +Then go to [http://localhost:8601/](http://localhost:8601/) - the playground outputs the default GUI component + +## Testing +```bash +make test +``` + +## 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! diff --git a/TRADEMARK b/TRADEMARK new file mode 100644 index 000000000..3e1ec5bf4 --- /dev/null +++ b/TRADEMARK @@ -0,0 +1,7 @@ +The Scratch trademarks, including the Scratch name, logo, the Scratch Cat, Gobo, Pico, Nano, Tera and Giga graphics (the "Marks"), are property of the Massachusetts Institute of Technology (MIT), and the use of the Marks is governed by this policy. + +You may use the Marks to refer to Scratch in Substantially Unmodified form. + +"Substantially Unmodified" means the source code provided by MIT, possibly with minor modifications including but not limited to: bug fixes (including security), changing the locations of files for better integration with the host operating system, adding documentation, and changes to the dynamic linking of libraries. + +A version is not "Substantially Unmodified" if it incorporates features not present in a release of Scratch by MIT. If you do make a substantial modification, to avoid confusion with versions of Scratch produced by MIT you must remove all Marks from your version of the software and refrain from using any of the Marks to refer to your version. diff --git a/index.html b/index.html new file mode 100644 index 000000000..4abe36c7f --- /dev/null +++ b/index.html @@ -0,0 +1,11 @@ + + + + + Scratch GUI Playground + + +
+ + + diff --git a/package.json b/package.json new file mode 100644 index 000000000..65b347cd3 --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "scratch-gui", + "version": "0.1.0", + "description": "GraphicaL User Interface for creating and running Scratch 3.0 projects", + "main": "./src/index.js", + "scripts": { + "start": "make serve" + }, + "author": "Massachusetts Institute of Technology", + "license": "BSD-3-Clause", + "homepage": "https://github.com/LLK/scratch-gui#readme", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/LLK/scratch-gui.git" + }, + "devDependencies": { + "babel-core": "6.14.0", + "babel-eslint": "6.1.2", + "babel-loader": "6.2.5", + "babel-preset-es2015": "6.14.0", + "babel-preset-react": "6.11.1", + "eslint": "3.5.0", + "eslint-plugin-react": "6.2.1", + "exports-loader": "0.6.3", + "imports-loader": "0.6.5", + "json-loader": "0.5.4", + "react": "15.3.1", + "react-dom": "15.3.1", + "scratch-blocks": "github:llk/scratch-blocks#develop", + "scratch-render": "github:llk/scratch-render#develop", + "scratch-vm": "github:llk/scratch-vm#develop", + "webpack": "1.13.2", + "webpack-dev-server": "1.15.2" + } +} diff --git a/playground.config.js b/playground.config.js new file mode 100644 index 000000000..4d598e2c4 --- /dev/null +++ b/playground.config.js @@ -0,0 +1,6 @@ +var config = require('./webpack.config'); +module.exports = Object.assign({}, config, { + entry: { + playground: './src/playground.jsx' + }, +}); diff --git a/src/components/blocks.jsx b/src/components/blocks.jsx new file mode 100644 index 000000000..c72c17f4c --- /dev/null +++ b/src/components/blocks.jsx @@ -0,0 +1,15 @@ +import React from 'react'; +import ScratchBlocks from 'scratch-blocks/blocks_compressed_vertical'; + +export default class Blocks extends React.Component { + mountBlocks (component) { + ScratchBlocks.inject(component, {}); + } + render () { + return ( +
+ ); + } +} diff --git a/src/components/gui.jsx b/src/components/gui.jsx new file mode 100644 index 000000000..04f465da5 --- /dev/null +++ b/src/components/gui.jsx @@ -0,0 +1,17 @@ +import React from 'react'; +import VM from 'scratch-vm'; +import Blocks from './blocks.jsx'; + +export default class GUI extends React.Component { + render () { + return ( +
+ +
+ ); + } +} + +GUI.defaultProps = { + vm: new VM() +}; diff --git a/src/index.js b/src/index.js new file mode 100644 index 000000000..c8cb9d7e9 --- /dev/null +++ b/src/index.js @@ -0,0 +1,5 @@ +import GUIComponent from './components/gui.jsx'; +import BlocksComponent from './components/blocks.jsx'; + +export const GUI = GUIComponent; +export const Blocks = BlocksComponent; diff --git a/src/playground.jsx b/src/playground.jsx new file mode 100644 index 000000000..d87855ce5 --- /dev/null +++ b/src/playground.jsx @@ -0,0 +1,7 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import {GUI} from '.'; + +ReactDOM.render( + , + document.getElementById('app')); diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 000000000..aff0436e5 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,33 @@ +var path = require('path'); +module.exports = { + entry: { + gui: './src/index.js' + }, + output: { + library: 'ScratchGUI', + path: __dirname, + filename: '[name].js' + }, + module: { + loaders: [{ + test: /\.jsx?$/, + loader: 'babel-loader', + include: path.resolve(__dirname, 'src'), + query: { + presets: ['es2015', 'react'] + } + }, { + test: /\.json$/, + loader: 'json-loader' + }, { + test: require.resolve('scratch-blocks/blockly_compressed_vertical'), + loader: 'exports?Blockly' + }, { + test: require.resolve('scratch-blocks/blocks_compressed'), + loader: 'imports?Blockly=scratch-blocks/blockly_compressed_vertical!exports?Blockly' + }, { + test: require.resolve('scratch-blocks/blocks_compressed_vertical'), + loader: 'imports?Blockly=scratch-blocks/blocks_compressed!exports?Blockly' + }] + } +};