@scratch/scratch-vm 13.6.5 → 13.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scratch/scratch-vm",
3
- "version": "13.6.5",
3
+ "version": "13.6.7",
4
4
  "description": "Virtual Machine for Scratch 3.0",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/scratchfoundation/scratch-vm#readme",
@@ -60,8 +60,8 @@
60
60
  "allow-incomplete-coverage": true
61
61
  },
62
62
  "dependencies": {
63
- "@scratch/scratch-render": "13.6.5",
64
- "@scratch/scratch-svg-renderer": "13.6.5",
63
+ "@scratch/scratch-render": "13.6.7",
64
+ "@scratch/scratch-svg-renderer": "13.6.7",
65
65
  "@vernier/godirect": "1.8.3",
66
66
  "arraybuffer-loader": "1.0.8",
67
67
  "atob": "2.1.2",
@@ -99,7 +99,7 @@
99
99
  "in-publish": "2.0.1",
100
100
  "js-md5": "0.7.3",
101
101
  "pngjs": "3.4.0",
102
- "scratch-blocks": "2.1.10",
102
+ "scratch-blocks": "2.1.11",
103
103
  "scratch-l10n": "6.1.68",
104
104
  "scratch-render-fonts": "1.0.252",
105
105
  "scratch-semantic-release-config": "4.0.1",
@@ -305,6 +305,20 @@ class Blocks {
305
305
  typeof e.commentId !== 'string') {
306
306
  return;
307
307
  }
308
+ // Intermediate field changes fire on every keystroke while editing
309
+ // a text input. Update the field value so running scripts see the
310
+ // change, but skip project-changed and other side effects. Handle
311
+ // this before the stage/editingTarget lookups to avoid per-keystroke
312
+ // overhead from getTargetForStage's linear scan.
313
+ if (e.type === 'block_field_intermediate_change') {
314
+ const block = this._blocks[e.blockId];
315
+ if (block && block.fields && block.fields[e.name]) {
316
+ block.fields[e.name].value = e.newValue;
317
+ this._cache._executeCached = {};
318
+ }
319
+ return;
320
+ }
321
+
308
322
  const stage = this.runtime.getTargetForStage();
309
323
  const editingTarget = this.runtime.getEditingTarget();
310
324
 
@@ -763,6 +777,7 @@ class Blocks {
763
777
  if (shadow && e.id !== shadow) {
764
778
  oldParent.inputs[e.oldInput].block = shadow;
765
779
  this._blocks[shadow].parent = oldParent.id;
780
+ this._blocks[e.id].parent = null;
766
781
  } else {
767
782
  oldParent.inputs[e.oldInput].block = null;
768
783
  if (e.id !== shadow) {
@@ -201,7 +201,7 @@ const serializeBlock = function (block) {
201
201
  obj.inputs = serializeInputs(block.inputs);
202
202
  obj.fields = serializeFields(block.fields);
203
203
  obj.shadow = block.shadow;
204
- if (block.topLevel) {
204
+ if (block.topLevel && !block.shadow) {
205
205
  obj.topLevel = true;
206
206
  obj.x = block.x ? Math.round(block.x) : 0;
207
207
  obj.y = block.y ? Math.round(block.y) : 0;
@@ -840,6 +840,12 @@ const deserializeBlocks = function (blocks) {
840
840
  block.id = blockId; // add id back to block since it wasn't serialized
841
841
  block.inputs = deserializeInputs(block.inputs, blockId, blocks);
842
842
  block.fields = deserializeFields(block.fields);
843
+ // Obscured shadow blocks can be serialized as top-level by
844
+ // production Scratch. Upstream Blockly throws if a shadow
845
+ // appears at the top level of the workspace XML.
846
+ if (block.shadow && block.topLevel) {
847
+ block.topLevel = false;
848
+ }
843
849
 
844
850
  if (block.comment) {
845
851
  // Pre-Blockly v12 Scratch used arbitrary IDs for block comments.