This commit is contained in:
Christopher Willis-Ford 2017-09-04 15:48:51 -07:00
parent d99c11ef91
commit 799d61ac98
5 changed files with 14 additions and 31 deletions

View file

@ -43,6 +43,7 @@ const ArgumentTypeMap = (() => {
shadowType: 'text', shadowType: 'text',
fieldType: 'TEXT' fieldType: 'TEXT'
}; };
// @TODO: talk to Rachel & co. to figure out what goes here. Make it OK to not have a field. Add `check` support.
map[ArgumentType.BOOLEAN] = { map[ArgumentType.BOOLEAN] = {
shadowType: '' shadowType: ''
}; };
@ -431,11 +432,12 @@ class Runtime extends EventEmitter {
const argInfo = blockInfo.arguments[placeholder] || {}; const argInfo = blockInfo.arguments[placeholder] || {};
const argTypeInfo = ArgumentTypeMap[argInfo.type] || {}; const argTypeInfo = ArgumentTypeMap[argInfo.type] || {};
const defaultValue = (typeof argInfo.defaultValue === 'undefined' ? '' : argInfo.defaultValue.toString()); const defaultValue = (typeof argInfo.defaultValue === 'undefined' ? '' : argInfo.defaultValue.toString());
inputList.push(`<value name="${placeholder inputList.push(
}"><shadow type="${argTypeInfo.shadowType `<value name="${placeholder}">` +
}"><field name="${argTypeInfo.fieldType `<shadow type="${argTypeInfo.shadowType}">` +
}">${defaultValue `<field name="${argTypeInfo.fieldType}">${defaultValue}</field>` +
}</field></shadow></value>` '</shadow>' +
'</value>'
); );
return `%${argNum}`; return `%${argNum}`;

View file

@ -28,7 +28,7 @@ const BlockType = require('./block-type');
* @property {string} color1 - the primary color for this category, in '#rrggbb' format * @property {string} color1 - the primary color for this category, in '#rrggbb' format
* @property {string} color2 - the secondary color for this category, in '#rrggbb' format * @property {string} color2 - the secondary color for this category, in '#rrggbb' format
* @property {string} color3 - the tertiary color for this category, in '#rrggbb' format * @property {string} color3 - the tertiary color for this category, in '#rrggbb' format
* @property {Array.<BlockInfo> block - the blocks in this category * @property {Array.<BlockInfo>} block - the blocks in this category
*/ */
/** /**

View file

@ -1,8 +1,3 @@
const VirtualMachine = require('./virtual-machine'); const VirtualMachine = require('./virtual-machine');
const CentralDispatch = require('./dispatch/central-dispatch');
global.Scratch = global.Scratch || {};
global.Scratch.dispatch = CentralDispatch;
module.exports = VirtualMachine; module.exports = VirtualMachine;

View file

@ -142,13 +142,6 @@ class VirtualMachine extends EventEmitter {
}); });
} }
/**
* Get the categorized list of all blocks currently available in the VM.
*/
getBlocks () {
}
/** /**
* Post I/O data to the virtual devices. * Post I/O data to the virtual devices.
* @param {?string} device Name of virtual I/O device. * @param {?string} device Name of virtual I/O device.

View file

@ -1,15 +1,8 @@
const CopyWebpackPlugin = require('copy-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin');
const defaultsDeep = require('lodash.defaultsdeep'); const defaultsDeep = require('lodash.defaultsdeep');
const glob = require('glob');
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const extensionEntries = glob.sync('./src/extensions/*.js').reduce((bag, extensionPath) => {
const nameWithoutExtension = path.basename(extensionPath).replace(/\.[^/.]+$/, '');
bag[`extensions/${nameWithoutExtension}`] = extensionPath;
return bag;
}, {});
const base = { const base = {
devServer: { devServer: {
contentBase: false, contentBase: false,
@ -39,10 +32,10 @@ module.exports = [
// Web-compatible // Web-compatible
defaultsDeep({}, base, { defaultsDeep({}, base, {
target: 'web', target: 'web',
entry: defaultsDeep({}, extensionEntries, { entry: {
'scratch-vm': './src/index.js', 'scratch-vm': './src/index.js',
'scratch-vm.min': './src/index.js' 'scratch-vm.min': './src/index.js'
}), },
output: { output: {
path: path.resolve(__dirname, 'dist/web'), path: path.resolve(__dirname, 'dist/web'),
filename: '[name].js' filename: '[name].js'
@ -59,9 +52,9 @@ module.exports = [
// Node-compatible // Node-compatible
defaultsDeep({}, base, { defaultsDeep({}, base, {
target: 'node', target: 'node',
entry: defaultsDeep({}, extensionEntries, { entry: {
'scratch-vm': './src/index.js' 'scratch-vm': './src/index.js'
}), },
output: { output: {
library: 'VirtualMachine', library: 'VirtualMachine',
libraryTarget: 'commonjs2', libraryTarget: 'commonjs2',
@ -72,7 +65,7 @@ module.exports = [
// Playground // Playground
defaultsDeep({}, base, { defaultsDeep({}, base, {
target: 'web', target: 'web',
entry: defaultsDeep({}, extensionEntries, { entry: {
'scratch-vm': './src/index.js', 'scratch-vm': './src/index.js',
'vendor': [ 'vendor': [
// FPS counter // FPS counter
@ -88,7 +81,7 @@ module.exports = [
// Storage // Storage
'scratch-storage' 'scratch-storage'
] ]
}), },
output: { output: {
path: path.resolve(__dirname, 'playground'), path: path.resolve(__dirname, 'playground'),
filename: '[name].js' filename: '[name].js'