From 7297341c51a6dd340c9c516df058e8e098843765 Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford Date: Fri, 6 Oct 2017 09:36:27 -0700 Subject: [PATCH] Fixups from code review - Remove WeDo 2 extension from the runtime's default block packages list - The WeDo 2.0 extension now calls its own `connect` method on startup I also renamed `EXTENSION_NAME` to `EXTENSION_ID` for consistency with the rest of the extension system. --- src/blocks/scratch3_wedo2.js | 10 +++++----- src/engine/runtime.js | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/blocks/scratch3_wedo2.js b/src/blocks/scratch3_wedo2.js index bc0750f56..5e0dc183b 100644 --- a/src/blocks/scratch3_wedo2.js +++ b/src/blocks/scratch3_wedo2.js @@ -373,9 +373,9 @@ const TiltDirection = { class Scratch3WeDo2Blocks { /** - * @return {string} - the name of this extension. + * @return {string} - the ID of this extension. */ - static get EXTENSION_NAME () { + static get EXTENSION_ID () { return 'wedo2'; } @@ -397,7 +397,7 @@ class Scratch3WeDo2Blocks { */ this.runtime = runtime; - this.runtime.HACK_WeDo2Blocks = this; + this.connect(); } /** @@ -405,7 +405,7 @@ class Scratch3WeDo2Blocks { */ getInfo () { return { - id: 'wedo2', + id: Scratch3WeDo2Blocks.EXTENSION_ID, name: 'WeDo 2.0', blocks: [ { @@ -586,7 +586,7 @@ class Scratch3WeDo2Blocks { } const deviceManager = this.runtime.ioDevices.deviceManager; const finder = this._finder = - deviceManager.searchAndConnect(Scratch3WeDo2Blocks.EXTENSION_NAME, WeDo2.DEVICE_TYPE); + deviceManager.searchAndConnect(Scratch3WeDo2Blocks.EXTENSION_ID, WeDo2.DEVICE_TYPE); this._finder.promise.then( socket => { if (this._finder === finder) { diff --git a/src/engine/runtime.js b/src/engine/runtime.js index c2ae3b3e1..dc76452b7 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -23,8 +23,7 @@ const defaultBlockPackages = { scratch3_sound: require('../blocks/scratch3_sound'), scratch3_sensing: require('../blocks/scratch3_sensing'), scratch3_data: require('../blocks/scratch3_data'), - scratch3_procedures: require('../blocks/scratch3_procedures'), - scratch3_wedo2: require('../blocks/scratch3_wedo2') + scratch3_procedures: require('../blocks/scratch3_procedures') }; /**