New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade playground-io #12979
Upgrade playground-io #12979
Conversation
ffffd63
to
660497c
Compare
Codecov Report
Continue to review full report at Codecov.
|
c28a33f
to
ae87ce0
Compare
@@ -138,7 +138,7 @@ | |||
"node-sass": "^4.0.0", | |||
"npm-which": "2.0.0", | |||
"phantomjs-prebuilt": "^2.1.3", | |||
"playground-io": "bcjordan/playground-io#tap-cap-touch", | |||
"playground-io": "0.4.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
@@ -74,7 +79,7 @@ export function initializeCircuitPlaygroundComponents(io, five, PlaygroundIO) { | |||
addSensorFeatures(five.Board.fmap, s); | |||
}); | |||
|
|||
return _.assign({}, touchSensors, { | |||
return Object.assign({}, touchPads, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also do this using object destructuring (which has become my general preference)
return {
...touchPads,
colorLeds: colorLeds,
// etc
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep forgetting I can do this. That's way cleaner. Thanks!
|
||
/** | ||
* @private {number} Which single pin this controller will monitor and | ||
* forward events for. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we always indent so much in comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I habitually indent past the @tag
for line wraps in JSDoc comments (have been doing this for a while) because I think it reads nicely in parameter lists, but I don't know what our preferred style is. It looks like Use JSDoc doesn't illustrate any indenting. Do you have a preference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I don't indent like that (i just indent the next line two spaces). I also don't think it's that big of a deal if our styles are slightly different in this respect.
const UP = 'up'; | ||
|
||
describe('TouchSensor', function () { | ||
let fakeTouchPad, touchSensor, spy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure whether/if we call this out in our style doc, but i think we usually put each of these on separate lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you're right and this is called out by AirBnB rule 13.2, enforced via ESLint one-var.
We've never enforced this - ESLint finds 8017 violations of this rule in /apps
right now, and unfortunately it's not autofixable.
Personally, I prefer the "one-var": ["error", {"initialized": "never"}],
variant on this rule that enforces one-var-per-declaration for initialized variables, but permits lists of uninitialized variables like this one. For what it's worth, there are only 62 violations of that rule right now. It might be a good place to start if we want to begin enforcing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel strongly about this (tho I guess we should either have a lint rule, or I shouldn't call it out as I see it in code reviews).
@@ -138,7 +138,7 @@ | |||
"node-sass": "^4.0.0", | |||
"npm-which": "2.0.0", | |||
"phantomjs-prebuilt": "^2.1.3", | |||
"playground-io": "bcjordan/playground-io#tap-cap-touch", | |||
"playground-io": "0.4.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
apps/src/makerlab/BoardController.js
Outdated
@@ -164,6 +159,9 @@ export default class BoardController { | |||
} | |||
|
|||
onBoardEvent(component, event, callback) { | |||
// TODO: Add accelerometer events for "singletap" and "doubletap" that map to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could you assign this TODO?
apps/src/makerlab/TouchSensor.js
Outdated
this.touchpadsController_.removeListener('up', this.upHandler); | ||
this.upHandler = null; | ||
} | ||
this.removeAllListeners(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given that start
immediately removes all listeners, is this necessary? Or just here for safety?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“All through my life I've had this strange unaccountable feeling that something was going on in the world, something big, even sinister, and no one would tell me what it was."
"No," said the old man, "that's just perfectly normal paranoia. Everyone in the Universe has that.”
Good call - the removeAllListeners
call in start
always gets called after this one, and that in turn is a paranoid redundant call with this one in BoardController::resetComponent
. I got a little reset-happy.
022911d
to
0f05058
Compare
Update: Right now this upgrade is stopped cold because unit tests are breaking on the upgrade to
This is visible in recent circle builds on this branch and on my local machine. In fact, I find the following minimal change repro's the problem: # Run from [cdo]/apps directory
# Get a clean staging build
git checkout staging
# Change the playground-io version in package.json and update dependencies
sed -i '/"playground-io"/ s/bcjordan\/playground-io#tap-cap-touch/0.4.0/' package.json && yarn
# Do a clean build
rm -rf build && npm run build
# Run unit tests
grunt karma:unit
# Expected: Tests run, maybe a few failures related to upgrade.
# Actual: No tests run, error message above. We're not getting a decent sourcemapped location for the error, and the problem seems to only occur when running with PhantomJS - tests run when you use Chrome ( |
Testing playground-io commits in the update:
This makes it look like rwaldron/playground-io@f85c244 is the culprit - extra-surprising because that's a tiny diff, just removing a supposedly-unused dependency on something called Even stranger, putting that dependency back (by depending on branch islemaster/playground-io@restore-bufferpack-dependency) doesn't fix the problem. Update: After reverting f85c244 didn't seem to fix anything, I'm doing a second round of testing (and wondering if I wasn't clearing things out sufficiently well before). My new command at each commit is:
So today, with this (hopefully more complete) test it looks like 1cf5a8d is the problem commit - which is more promising as it contains actual changes, but tracking down the offending change is going to be harder because it's a big commit. |
New strategy, assuming 1cf5a8d is the problem commit: I've created a branch on my fork, find-breakage, at 84b20ac and I'm going to slowly reintroduce the changes from 1cf5a8d to work out what's causing the break.
It looks like our culprit is ES6 in the I thought that our transpiler covered this for imported modules too - or that we'd at least get a more useful error message. I'll have to track down why this is not the case here. Quick solutions that come to mind:
|
I like the idea of transpiling more things for our test build process; do we have any idea how big of a work item that is? |
Fairly minimal effort - right now we only transpile I'm not thrilled with the idea of maintaining a list of packages that need transpilation, but neither do I think it's a good idea to always transpile all of our dependencies (which may be prohibitively slow). I do think I prefer the transpilation list to a fork of |
Okay, proposed solution for now: 7a9118a Feedback please! |
Woah, we don't even transpile other installed modules in production? That seems odd; I'd be interested to see how much slowdown we actually get from adding that step. Otherwise, this approach seems like a great first step! |
Timing reported by
Trying to transpile all of |
Update playground-io from bcjordan/playground-io#tap-cap-touch branch to official rwaldron/playground-io@0.4.0. This commit temporarily removes support for capacitive touch sensors because in addition to the API change the new version doesn't provide support for lazy-enabling sensors and hurts overall performance. Getting this change checked in with the one known regression and fixing up before merge. Includes updated yarn.lock
Wraps playground-io's Touchpad controller in the (re-introduced) TouchSensor controller which surfaces up/down events for a single pin.
When the first parameter to onBoardEvent was not recognized, the code generating the second param dropdown raised an error because its lookup against the first param failed. Now when it's not recognized it will list all possible second parameter values. Includes tests over the new helper method.
7a9118a
to
5553af2
Compare
Update playground-io from @bcjordan's fork back to mainline v0.4.0 (rwaldron/playground-io@0.4.0, diff of this upgrade). Pair: @bcjordan.
Major API change in the upgrade is the introduction of a
Touchpad
controller to help treat the capacitive touch sensors as buttons. We in turn wrap this component into individual objects for each touch sensor to create the requestedAlso fixes an
onBoardEvent
dropdown bug: When the first parameter to onBoardEvent was not recognized, the code generating the second param dropdown raised an error because its lookup against the first param failed. Now when it's not recognized it will list all possible second parameter values. Includes tests over the new helper method.Finally there's quite a bit of cleanup, and commenting, as I'm still getting to know the maker code.
Testing
Added unit tests for the
TouchSensor
wrapper and for the dropdown bug that got fixed.Manually tested the eight cap-touch sensors, ten neopixels, and two buttons via App Lab+Maker Toolkit.