scratch-vm 5.0.163 → 5.0.165-spork.1

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-vm",
3
- "version": "5.0.163",
3
+ "version": "5.0.165-spork.1",
4
4
  "description": "Virtual Machine for Scratch 3.0",
5
5
  "author": "Massachusetts Institute of Technology",
6
6
  "license": "AGPL-3.0-only",
@@ -8,7 +8,7 @@
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/scratchfoundation/scratch-vm.git",
11
- "sha": "fb791aa761397c4ec5ee63e695069cb71f275860"
11
+ "sha": "6ec8b4011cf106e14a8ccd442b83971f289c5748"
12
12
  },
13
13
  "main": "./dist/node/scratch-vm.js",
14
14
  "browser": "./dist/web/scratch-vm.js",
@@ -78,9 +78,9 @@
78
78
  "web-worker": "^1.3.0"
79
79
  },
80
80
  "devDependencies": {
81
- "@babel/core": "7.26.7",
82
- "@babel/eslint-parser": "7.26.5",
83
- "@babel/preset-env": "7.26.7",
81
+ "@babel/core": "7.26.8",
82
+ "@babel/eslint-parser": "7.26.8",
83
+ "@babel/preset-env": "7.26.8",
84
84
  "@commitlint/cli": "17.8.1",
85
85
  "@commitlint/config-conventional": "17.8.1",
86
86
  "adm-zip": "0.4.11",
@@ -99,8 +99,8 @@
99
99
  "jsdoc": "3.6.11",
100
100
  "json": "^9.0.4",
101
101
  "pngjs": "3.4.0",
102
- "scratch-blocks": "1.1.206",
103
- "scratch-l10n": "5.0.120",
102
+ "scratch-blocks": "2.0.0-spork.4",
103
+ "scratch-l10n": "5.0.121",
104
104
  "scratch-render-fonts": "1.0.161",
105
105
  "scratch-semantic-release-config": "3.0.0",
106
106
  "scratch-webpack-configuration": "3.0.0",
package/release.config.js CHANGED
@@ -5,6 +5,18 @@ module.exports = {
5
5
  name: 'develop'
6
6
  // default channel
7
7
  },
8
+ {
9
+ name: 'alpha',
10
+ prerelease: true
11
+ },
12
+ {
13
+ name: 'beta',
14
+ prerelease: true
15
+ },
16
+ {
17
+ name: 'spork',
18
+ prerelease: true
19
+ },
8
20
  {
9
21
  name: 'hotfix/*',
10
22
  channel: 'hotfix'
@@ -322,12 +322,6 @@ class Blocks {
322
322
  const stage = this.runtime.getTargetForStage();
323
323
  const editingTarget = this.runtime.getEditingTarget();
324
324
 
325
- // UI event: clicked scripts toggle in the runtime.
326
- if (e.element === 'stackclick') {
327
- this.runtime.toggleScript(e.blockId, {stackClick: true});
328
- return;
329
- }
330
-
331
325
  // Block create/update/destroy
332
326
  switch (e.type) {
333
327
  case 'create': {
@@ -481,18 +475,19 @@ class Blocks {
481
475
  this.emitProjectChanged();
482
476
  break;
483
477
  }
478
+ case 'block_comment_create':
484
479
  case 'comment_create':
485
480
  if (this.runtime.getEditingTarget()) {
486
481
  const currTarget = this.runtime.getEditingTarget();
487
482
  currTarget.createComment(
488
483
  e.commentId,
489
484
  e.blockId,
490
- e.text,
491
- e.xy.x,
492
- e.xy.y,
493
- e.width,
494
- e.height,
495
- e.minimized
485
+ '',
486
+ e.json.x,
487
+ e.json.y,
488
+ e.json.width,
489
+ e.json.height,
490
+ false
496
491
  );
497
492
 
498
493
  if (
@@ -505,12 +500,13 @@ class Blocks {
505
500
  // comments, then the auto positioning should have taken place.
506
501
  // Update the x and y position of these comments to match the
507
502
  // one from the event.
508
- currTarget.comments[e.commentId].x = e.xy.x;
509
- currTarget.comments[e.commentId].y = e.xy.y;
503
+ currTarget.comments[e.commentId].x = e.json.x;
504
+ currTarget.comments[e.commentId].y = e.json.y;
510
505
  }
511
506
  }
512
507
  this.emitProjectChanged();
513
508
  break;
509
+ case 'block_comment_change':
514
510
  case 'comment_change':
515
511
  if (this.runtime.getEditingTarget()) {
516
512
  const currTarget = this.runtime.getEditingTarget();
@@ -526,21 +522,11 @@ class Blocks {
526
522
  return;
527
523
  }
528
524
  const comment = currTarget.comments[e.commentId];
529
- const change = e.newContents_;
530
- if (Object.prototype.hasOwnProperty.call(change, 'minimized')) {
531
- comment.minimized = change.minimized;
532
- }
533
- if (Object.prototype.hasOwnProperty.call(change, 'width') &&
534
- Object.prototype.hasOwnProperty.call(change, 'height')) {
535
- comment.width = change.width;
536
- comment.height = change.height;
537
- }
538
- if (Object.prototype.hasOwnProperty.call(change, 'text')) {
539
- comment.text = change.text;
540
- }
525
+ comment.text = e.newContents_;
541
526
  this.emitProjectChanged();
542
527
  }
543
528
  break;
529
+ case 'block_comment_move':
544
530
  case 'comment_move':
545
531
  if (this.runtime.getEditingTarget()) {
546
532
  const currTarget = this.runtime.getEditingTarget();
@@ -564,6 +550,50 @@ class Blocks {
564
550
  this.emitProjectChanged();
565
551
  }
566
552
  break;
553
+ case 'block_comment_collapse':
554
+ case 'comment_collapse':
555
+ if (this.runtime.getEditingTarget()) {
556
+ const currTarget = this.runtime.getEditingTarget();
557
+ if (
558
+ currTarget &&
559
+ !Object.prototype.hasOwnProperty.call(
560
+ currTarget.comments,
561
+ e.commentId
562
+ )
563
+ ) {
564
+ log.warn(
565
+ `Cannot collapse comment with id ${e.commentId} because it does not exist.`
566
+ );
567
+ return;
568
+ }
569
+ const comment = currTarget.comments[e.commentId];
570
+ comment.minimized = e.newCollapsed;
571
+ this.emitProjectChanged();
572
+ }
573
+ break;
574
+ case 'block_comment_resize':
575
+ case 'comment_resize':
576
+ if (this.runtime.getEditingTarget()) {
577
+ const currTarget = this.runtime.getEditingTarget();
578
+ if (
579
+ currTarget &&
580
+ !Object.prototype.hasOwnProperty.call(
581
+ currTarget.comments,
582
+ e.commentId
583
+ )
584
+ ) {
585
+ log.warn(
586
+ `Cannot resize comment with id ${e.commentId} because it does not exist.`
587
+ );
588
+ return;
589
+ }
590
+ const comment = currTarget.comments[e.commentId];
591
+ comment.width = e.newSize.width;
592
+ comment.height = e.newSize.height;
593
+ this.emitProjectChanged();
594
+ }
595
+ break;
596
+ case 'block_comment_delete':
567
597
  case 'comment_delete':
568
598
  if (this.runtime.getEditingTarget()) {
569
599
  const currTarget = this.runtime.getEditingTarget();
@@ -594,6 +624,15 @@ class Blocks {
594
624
  this.emitProjectChanged();
595
625
  }
596
626
  break;
627
+ case 'click':
628
+ // UI event: clicked scripts toggle in the runtime.
629
+ if (e.targetType === 'block') {
630
+ this.runtime.toggleScript(
631
+ this.getTopLevelScript(e.blockId),
632
+ {stackClick: true}
633
+ );
634
+ }
635
+ break;
597
636
  }
598
637
  }
599
638
 
@@ -850,19 +889,32 @@ class Blocks {
850
889
  typeof e.oldInput !== 'undefined' &&
851
890
  oldParent.inputs[e.oldInput].block === e.id
852
891
  ) {
853
- // This block was connected to the old parent's input.
854
- oldParent.inputs[e.oldInput].block = null;
892
+ // This block was connected to an input. We either want to
893
+ // restore the shadow block that previously occupied
894
+ // this input, or null out the input's block.
895
+ const shadow = oldParent.inputs[e.oldInput].shadow;
896
+ if (shadow && e.id !== shadow) {
897
+ oldParent.inputs[e.oldInput].block = shadow;
898
+ this._blocks[shadow].parent = oldParent.id;
899
+ } else {
900
+ oldParent.inputs[e.oldInput].block = null;
901
+ if (e.id !== shadow) {
902
+ this._blocks[e.id].parent = null;
903
+ }
904
+ }
855
905
  } else if (oldParent.next === e.id) {
856
906
  // This block was connected to the old parent's next connection.
857
907
  oldParent.next = null;
908
+ this._blocks[e.id].parent = null;
858
909
  }
859
- this._blocks[e.id].parent = null;
860
910
  didChange = true;
861
911
  }
862
912
 
863
913
  // Is this block a top-level block?
864
914
  if (typeof e.newParent === 'undefined') {
865
- this._addScript(e.id);
915
+ if (!this._blocks[e.id].shadow) {
916
+ this._addScript(e.id);
917
+ }
866
918
  } else {
867
919
  // Remove script, if one exists.
868
920
  this._deleteScript(e.id);
@@ -31,7 +31,7 @@ class Comment {
31
31
  toXML () {
32
32
  return `<comment id="${this.id}" x="${this.x}" y="${
33
33
  this.y}" w="${this.width}" h="${this.height}" pinned="${
34
- this.blockId !== null}" minimized="${this.minimized}">${xmlEscape(this.text)}</comment>`;
34
+ !this.minimized}" collapsed="${this.minimized}">${xmlEscape(this.text)}</comment>`;
35
35
  }
36
36
 
37
37
  // TODO choose min and defaults for width and height
@@ -1049,9 +1049,7 @@ class Runtime extends EventEmitter {
1049
1049
  type: menuId,
1050
1050
  inputsInline: true,
1051
1051
  output: 'String',
1052
- colour: categoryInfo.color1,
1053
- colourSecondary: categoryInfo.color2,
1054
- colourTertiary: categoryInfo.color3,
1052
+ style: categoryInfo.id,
1055
1053
  outputShape: menuInfo.acceptReporters ?
1056
1054
  ScratchBlocksConstants.OUTPUT_SHAPE_ROUND :
1057
1055
  ScratchBlocksConstants.OUTPUT_SHAPE_SQUARE,
@@ -1108,9 +1106,7 @@ class Runtime extends EventEmitter {
1108
1106
  message0: '%1',
1109
1107
  inputsInline: true,
1110
1108
  output: output,
1111
- colour: categoryInfo.color1,
1112
- colourSecondary: categoryInfo.color2,
1113
- colourTertiary: categoryInfo.color3,
1109
+ style: categoryInfo.id,
1114
1110
  outputShape: outputShape,
1115
1111
  args0: [
1116
1112
  {
@@ -1155,9 +1151,8 @@ class Runtime extends EventEmitter {
1155
1151
  type: extendedOpcode,
1156
1152
  inputsInline: true,
1157
1153
  category: categoryInfo.name,
1158
- colour: categoryInfo.color1,
1159
- colourSecondary: categoryInfo.color2,
1160
- colourTertiary: categoryInfo.color3
1154
+ style: categoryInfo.id,
1155
+ extensions: []
1161
1156
  };
1162
1157
  const context = {
1163
1158
  // TODO: store this somewhere so that we can map args appropriately after translation.
@@ -1177,7 +1172,7 @@ class Runtime extends EventEmitter {
1177
1172
  const iconURI = blockInfo.blockIconURI || categoryInfo.blockIconURI;
1178
1173
 
1179
1174
  if (iconURI) {
1180
- blockJSON.extensions = ['scratch_extension'];
1175
+ blockJSON.extensions.push('scratch_extension');
1181
1176
  blockJSON.message0 = '%1 %2';
1182
1177
  const iconJSON = {
1183
1178
  type: 'field_image',
@@ -1224,6 +1219,7 @@ class Runtime extends EventEmitter {
1224
1219
  blockJSON.outputShape =
1225
1220
  ScratchBlocksConstants.OUTPUT_SHAPE_SQUARE;
1226
1221
  blockJSON.nextStatement = null; // null = available connection; undefined = terminal
1222
+ blockJSON.extensions.push('shape_hat');
1227
1223
  break;
1228
1224
  case BlockType.CONDITIONAL:
1229
1225
  case BlockType.LOOP:
@@ -1289,7 +1285,7 @@ class Runtime extends EventEmitter {
1289
1285
 
1290
1286
  if (blockInfo.blockType === BlockType.REPORTER) {
1291
1287
  if (!blockInfo.disableMonitor && context.inputList.length === 0) {
1292
- blockJSON.checkboxInFlyout = true;
1288
+ blockJSON.extensions.push('monitor_block');
1293
1289
  }
1294
1290
  } else if (blockInfo.blockType === BlockType.LOOP) {
1295
1291
  // Add icon to the bottom right of a loop block
@@ -1562,7 +1558,7 @@ class Runtime extends EventEmitter {
1562
1558
 
1563
1559
  return {
1564
1560
  id: categoryInfo.id,
1565
- xml: `<category name="${name}" id="${
1561
+ xml: `<category name="${name}" toolboxitemid="${
1566
1562
  categoryInfo.id
1567
1563
  }" ${statusButtonXML} ${colorXML} ${menuIconXML}>${paletteBlocks
1568
1564
  .map(block => block.xml)
package/webpack.config.js CHANGED
@@ -81,7 +81,7 @@ const playgroundBuilder = webBuilder.clone()
81
81
  }
82
82
  })
83
83
  .addModuleRule({
84
- test: require.resolve('scratch-blocks/dist/vertical.js'),
84
+ test: require.resolve('scratch-blocks/dist/main.js'),
85
85
  loader: 'expose-loader',
86
86
  options: {
87
87
  exposes: 'Blockly'