The great Blockly upgrade - #9865
Conversation
Eric Anderson (eanders-ms)
left a comment
There was a problem hiding this comment.
LGTM :). Made a small comment on package dependencies.
| "dependencies": { | ||
| "@blockly/keyboard-navigation": "^0.1.18", | ||
| "@blockly/plugin-workspace-search": "^4.0.10", | ||
| "@blockly/keyboard-navigation": "^0.5.4", |
There was a problem hiding this comment.
If we aren't checking in package-lock.json, we need to lock all dependencies to specific versions.
| "@types/jquery": "3.3.29", | ||
| "@types/marked": "0.3.0", | ||
| "@types/mocha": "2.2.44", | ||
| "@types/mocha": "^2.2.44", |
There was a problem hiding this comment.
This is risky unless we check in package-lock.json. This introduces uncertainty around what we develop against vs. what we ship with.
There was a problem hiding this comment.
Is now a good time to include package-lock.json?
There was a problem hiding this comment.
one thing at a time! but i will revert this, not sure how it even happened
|
Richard Knoll (@riknoll) tell me, for example with this code... Now, do you need to specify this for Blockly.BlockSvg? |
|
Dmitriy Antipov (@THEb0nny) you might be better off not taking this change... This was a pretty huge update to Blockly and I expect that all the pxt-ev3 fields will require a major rewrite. To answer your question, though, you don't want to import blockly here as the dependency graph can get a little weird. There are two functions defined in pxt for requiring blockly and pxtblockly: This will import the runtime code, but not the types themselves. Some of the casts being done might throw errors |
|
Richard Knoll (@riknoll) I'm already doing something. |
Why am I asking about import * as Blockly from "blockly" Error in super method for opt_validator. I googled somewhere for the solution opt_validator?: Function. Found opt_validator?: Blockly.FieldValidator but when I add Tell me how to solve this problem correctly. I found it from here. |
|
the and yes, wherever possible you should just use the fields that are defined in pxt (such as FieldImages) and not pxt-ev3. it might be worth looking into if there is a way to deprecate all of them; this will likely change how the blocks look/function but will certainly make keeping up with latest pxt less of a headache. |
|
Richard Knoll (@riknoll) (this.sourceBlock_ as Blockly.BlockSvg) can it be replaced this.sourceBlock_ as any? |
|
Dmitriy Antipov (@THEb0nny) i'm afraid not, there were major changes made to Blockly in the version we updated. many of the methods/properties we were using before either no longer exist or were made private (and thus inaccessible). if you are getting an error for something on Blockly.BlockSvg, I think it's likely something that was removed in that way and you need to either figure out the new way to access those properties or re-implement it from scratch. this is what i meant when i said that all of the field editors will require a major rewrite (if you want to use version 10.X.X of pxt). alternatively, you can take a dependency on the v9 branch of pxt which uses the old version of Blockly. |
|
Richard Knoll (@riknoll) well, I made almost all the changes. I had to import BlockSvg } this way. The only problem left is with field_color. The choice of value does not work there, but there is no error. There is something wrong with the colornumber field with the class setting. Because the class is not installed. |
|
Richard Knoll (@riknoll) In your field_colors showEditor_() was removed, where the class was installed. Was this done intentionally? |
|
I fixed all the fields pxt-ev3. |
pxt's renderer re-runs field.init() on every render (the input.init() sweep in RenderInfo.measure, added in microsoft#9865 to replace the fork-era re-runnable BlockSvg.initSvg). Blockly.Field.init() is idempotent, but FieldBase and FieldCustomMelody ran onInit() unconditionally, rebuilding the field's DOM on every render. On touch, the pointerdown target implicitly captures the pointer, so destroying that element mid-drag breaks event delivery. Dragging a melody_editor shadow by its preview triggers exactly this: duplicate- on-drag forces a render at drag start, updateFieldLabel() removes the captured element, and in an iframe embed Chrome then routes the rest of the touch's events (including pointerup) to the top-level document. The gesture never ends, Blockly's touchIdentifier_ stays pinned to the dead pointer, and every subsequent touch moves the block with no way to drop it. Top-level documents seem to recover from this so we can only reproduce issues in an iframe (e.g. with controller.html). Guard init() so onInit() runs once per field, matching the Blockly.Field.init behavior. Fixes microsoft/pxt-microbit#7045
…ft#11491) pxt's renderer re-runs field.init() on every render (the input.init() sweep in RenderInfo.measure, added in microsoft#9865 to replace the fork-era re-runnable BlockSvg.initSvg). Blockly.Field.init() is idempotent, but FieldBase and FieldCustomMelody ran onInit() unconditionally, rebuilding the field's DOM on every render. On touch, the pointerdown target implicitly captures the pointer, so destroying that element mid-drag breaks event delivery. Dragging a melody_editor shadow by its preview triggers exactly this: duplicate- on-drag forces a render at drag start, updateFieldLabel() removes the captured element, and in an iframe embed Chrome then routes the rest of the touch's events (including pointerup) to the top-level document. The gesture never ends, Blockly's touchIdentifier_ stays pinned to the dead pointer, and every subsequent touch moves the block with no way to drop it. Top-level documents seem to recover from this so we can only reproduce issues in an iframe (e.g. with controller.html). Guard init() so onInit() runs once per field, matching the Blockly.Field.init behavior. Fixes microsoft/pxt-microbit#7045
…#11496) pxt's renderer re-runs field.init() on every render (the input.init() sweep in RenderInfo.measure, added in #9865 to replace the fork-era re-runnable BlockSvg.initSvg). Blockly.Field.init() is idempotent, but FieldBase and FieldCustomMelody ran onInit() unconditionally, rebuilding the field's DOM on every render. On touch, the pointerdown target implicitly captures the pointer, so destroying that element mid-drag breaks event delivery. Dragging a melody_editor shadow by its preview triggers exactly this: duplicate- on-drag forces a render at drag start, updateFieldLabel() removes the captured element, and in an iframe embed Chrome then routes the rest of the touch's events (including pointerup) to the top-level document. The gesture never ends, Blockly's touchIdentifier_ stays pinned to the dead pointer, and every subsequent touch moves the block with no way to drop it. Top-level documents seem to recover from this so we can only reproduce issues in an iframe (e.g. with controller.html). Guard init() so onInit() runs once per field, matching the Blockly.Field.init behavior. Fixes microsoft/pxt-microbit#7045 Co-authored-by: Matt Hillsdon <matt.hillsdon@microbit.org>


It's time!
This PR upgrades us to the latest version of Blockly and removes our dependency on our fork (pxt-blockly). I went over this in the tech talk, but the basic gist of what this PR does:
pxtblocks/into modulespxtblocks/plugins/folderHere are some test links (open in incognito):
https://arcade.makecode.com/app/c5c20c036100e88b7eeca290470f8c45c41118f9-9f2b2b0e96
https://makecode.microbit.org/app/f9ad2136c00106a54df0b4686be1651471195d35-00171f0e8a
There are a few known minor bugs that were discovered in testing today. Jacqueline Russell (@Jaqster) and Sarah Rietkerk (@srietkerk) will be filing them in pxt-microbit so that they're tracked.
Known regressions (will file bugs):
Future work items: