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.
@@ -6157,14 +6157,6 @@ class Blocks {
6157
6157
  const stage = this.runtime.getTargetForStage();
6158
6158
  const editingTarget = this.runtime.getEditingTarget();
6159
6159
 
6160
- // UI event: clicked scripts toggle in the runtime.
6161
- if (e.element === 'stackclick') {
6162
- this.runtime.toggleScript(e.blockId, {
6163
- stackClick: true
6164
- });
6165
- return;
6166
- }
6167
-
6168
6160
  // Block create/update/destroy
6169
6161
  switch (e.type) {
6170
6162
  case 'create':
@@ -6273,10 +6265,11 @@ class Blocks {
6273
6265
  this.emitProjectChanged();
6274
6266
  break;
6275
6267
  }
6268
+ case 'block_comment_create':
6276
6269
  case 'comment_create':
6277
6270
  if (this.runtime.getEditingTarget()) {
6278
6271
  const currTarget = this.runtime.getEditingTarget();
6279
- currTarget.createComment(e.commentId, e.blockId, e.text, e.xy.x, e.xy.y, e.width, e.height, e.minimized);
6272
+ currTarget.createComment(e.commentId, e.blockId, '', e.json.x, e.json.y, e.json.width, e.json.height, false);
6280
6273
  if (currTarget.comments[e.commentId].x === null && currTarget.comments[e.commentId].y === null) {
6281
6274
  // Block comments imported from 2.0 projects are imported with their
6282
6275
  // x and y coordinates set to null so that scratch-blocks can
@@ -6284,12 +6277,13 @@ class Blocks {
6284
6277
  // comments, then the auto positioning should have taken place.
6285
6278
  // Update the x and y position of these comments to match the
6286
6279
  // one from the event.
6287
- currTarget.comments[e.commentId].x = e.xy.x;
6288
- currTarget.comments[e.commentId].y = e.xy.y;
6280
+ currTarget.comments[e.commentId].x = e.json.x;
6281
+ currTarget.comments[e.commentId].y = e.json.y;
6289
6282
  }
6290
6283
  }
6291
6284
  this.emitProjectChanged();
6292
6285
  break;
6286
+ case 'block_comment_change':
6293
6287
  case 'comment_change':
6294
6288
  if (this.runtime.getEditingTarget()) {
6295
6289
  const currTarget = this.runtime.getEditingTarget();
@@ -6298,20 +6292,11 @@ class Blocks {
6298
6292
  return;
6299
6293
  }
6300
6294
  const comment = currTarget.comments[e.commentId];
6301
- const change = e.newContents_;
6302
- if (Object.prototype.hasOwnProperty.call(change, 'minimized')) {
6303
- comment.minimized = change.minimized;
6304
- }
6305
- if (Object.prototype.hasOwnProperty.call(change, 'width') && Object.prototype.hasOwnProperty.call(change, 'height')) {
6306
- comment.width = change.width;
6307
- comment.height = change.height;
6308
- }
6309
- if (Object.prototype.hasOwnProperty.call(change, 'text')) {
6310
- comment.text = change.text;
6311
- }
6295
+ comment.text = e.newContents_;
6312
6296
  this.emitProjectChanged();
6313
6297
  }
6314
6298
  break;
6299
+ case 'block_comment_move':
6315
6300
  case 'comment_move':
6316
6301
  if (this.runtime.getEditingTarget()) {
6317
6302
  const currTarget = this.runtime.getEditingTarget();
@@ -6326,6 +6311,34 @@ class Blocks {
6326
6311
  this.emitProjectChanged();
6327
6312
  }
6328
6313
  break;
6314
+ case 'block_comment_collapse':
6315
+ case 'comment_collapse':
6316
+ if (this.runtime.getEditingTarget()) {
6317
+ const currTarget = this.runtime.getEditingTarget();
6318
+ if (currTarget && !Object.prototype.hasOwnProperty.call(currTarget.comments, e.commentId)) {
6319
+ log.warn("Cannot collapse comment with id ".concat(e.commentId, " because it does not exist."));
6320
+ return;
6321
+ }
6322
+ const comment = currTarget.comments[e.commentId];
6323
+ comment.minimized = e.newCollapsed;
6324
+ this.emitProjectChanged();
6325
+ }
6326
+ break;
6327
+ case 'block_comment_resize':
6328
+ case 'comment_resize':
6329
+ if (this.runtime.getEditingTarget()) {
6330
+ const currTarget = this.runtime.getEditingTarget();
6331
+ if (currTarget && !Object.prototype.hasOwnProperty.call(currTarget.comments, e.commentId)) {
6332
+ log.warn("Cannot resize comment with id ".concat(e.commentId, " because it does not exist."));
6333
+ return;
6334
+ }
6335
+ const comment = currTarget.comments[e.commentId];
6336
+ comment.width = e.newSize.width;
6337
+ comment.height = e.newSize.height;
6338
+ this.emitProjectChanged();
6339
+ }
6340
+ break;
6341
+ case 'block_comment_delete':
6329
6342
  case 'comment_delete':
6330
6343
  if (this.runtime.getEditingTarget()) {
6331
6344
  const currTarget = this.runtime.getEditingTarget();
@@ -6348,6 +6361,14 @@ class Blocks {
6348
6361
  this.emitProjectChanged();
6349
6362
  }
6350
6363
  break;
6364
+ case 'click':
6365
+ // UI event: clicked scripts toggle in the runtime.
6366
+ if (e.targetType === 'block') {
6367
+ this.runtime.toggleScript(this.getTopLevelScript(e.blockId), {
6368
+ stackClick: true
6369
+ });
6370
+ }
6371
+ break;
6351
6372
  }
6352
6373
  }
6353
6374
 
@@ -6547,19 +6568,32 @@ class Blocks {
6547
6568
  if (typeof e.oldParent !== 'undefined') {
6548
6569
  const oldParent = this._blocks[e.oldParent];
6549
6570
  if (typeof e.oldInput !== 'undefined' && oldParent.inputs[e.oldInput].block === e.id) {
6550
- // This block was connected to the old parent's input.
6551
- oldParent.inputs[e.oldInput].block = null;
6571
+ // This block was connected to an input. We either want to
6572
+ // restore the shadow block that previously occupied
6573
+ // this input, or null out the input's block.
6574
+ const shadow = oldParent.inputs[e.oldInput].shadow;
6575
+ if (shadow && e.id !== shadow) {
6576
+ oldParent.inputs[e.oldInput].block = shadow;
6577
+ this._blocks[shadow].parent = oldParent.id;
6578
+ } else {
6579
+ oldParent.inputs[e.oldInput].block = null;
6580
+ if (e.id !== shadow) {
6581
+ this._blocks[e.id].parent = null;
6582
+ }
6583
+ }
6552
6584
  } else if (oldParent.next === e.id) {
6553
6585
  // This block was connected to the old parent's next connection.
6554
6586
  oldParent.next = null;
6587
+ this._blocks[e.id].parent = null;
6555
6588
  }
6556
- this._blocks[e.id].parent = null;
6557
6589
  didChange = true;
6558
6590
  }
6559
6591
 
6560
6592
  // Is this block a top-level block?
6561
6593
  if (typeof e.newParent === 'undefined') {
6562
- this._addScript(e.id);
6594
+ if (!this._blocks[e.id].shadow) {
6595
+ this._addScript(e.id);
6596
+ }
6563
6597
  } else {
6564
6598
  // Remove script, if one exists.
6565
6599
  this._deleteScript(e.id);
@@ -7150,7 +7184,7 @@ class Comment {
7150
7184
  this.blockId = null;
7151
7185
  }
7152
7186
  toXML() {
7153
- return "<comment id=\"".concat(this.id, "\" x=\"").concat(this.x, "\" y=\"").concat(this.y, "\" w=\"").concat(this.width, "\" h=\"").concat(this.height, "\" pinned=\"").concat(this.blockId !== null, "\" minimized=\"").concat(this.minimized, "\">").concat(xmlEscape(this.text), "</comment>");
7187
+ return "<comment id=\"".concat(this.id, "\" x=\"").concat(this.x, "\" y=\"").concat(this.y, "\" w=\"").concat(this.width, "\" h=\"").concat(this.height, "\" pinned=\"").concat(!this.minimized, "\" collapsed=\"").concat(this.minimized, "\">").concat(xmlEscape(this.text), "</comment>");
7154
7188
  }
7155
7189
 
7156
7190
  // TODO choose min and defaults for width and height
@@ -9167,9 +9201,7 @@ class Runtime extends EventEmitter {
9167
9201
  type: menuId,
9168
9202
  inputsInline: true,
9169
9203
  output: 'String',
9170
- colour: categoryInfo.color1,
9171
- colourSecondary: categoryInfo.color2,
9172
- colourTertiary: categoryInfo.color3,
9204
+ style: categoryInfo.id,
9173
9205
  outputShape: menuInfo.acceptReporters ? ScratchBlocksConstants.OUTPUT_SHAPE_ROUND : ScratchBlocksConstants.OUTPUT_SHAPE_SQUARE,
9174
9206
  args0: [{
9175
9207
  type: 'field_dropdown',
@@ -9211,9 +9243,7 @@ class Runtime extends EventEmitter {
9211
9243
  message0: '%1',
9212
9244
  inputsInline: true,
9213
9245
  output: output,
9214
- colour: categoryInfo.color1,
9215
- colourSecondary: categoryInfo.color2,
9216
- colourTertiary: categoryInfo.color3,
9246
+ style: categoryInfo.id,
9217
9247
  outputShape: outputShape,
9218
9248
  args0: [{
9219
9249
  name: "field_".concat(fieldName),
@@ -9253,9 +9283,8 @@ class Runtime extends EventEmitter {
9253
9283
  type: extendedOpcode,
9254
9284
  inputsInline: true,
9255
9285
  category: categoryInfo.name,
9256
- colour: categoryInfo.color1,
9257
- colourSecondary: categoryInfo.color2,
9258
- colourTertiary: categoryInfo.color3
9286
+ style: categoryInfo.id,
9287
+ extensions: []
9259
9288
  };
9260
9289
  const context = {
9261
9290
  // TODO: store this somewhere so that we can map args appropriately after translation.
@@ -9274,7 +9303,7 @@ class Runtime extends EventEmitter {
9274
9303
  // the category block icon.
9275
9304
  const iconURI = blockInfo.blockIconURI || categoryInfo.blockIconURI;
9276
9305
  if (iconURI) {
9277
- blockJSON.extensions = ['scratch_extension'];
9306
+ blockJSON.extensions.push('scratch_extension');
9278
9307
  blockJSON.message0 = '%1 %2';
9279
9308
  const iconJSON = {
9280
9309
  type: 'field_image',
@@ -9311,6 +9340,7 @@ class Runtime extends EventEmitter {
9311
9340
  }
9312
9341
  blockJSON.outputShape = ScratchBlocksConstants.OUTPUT_SHAPE_SQUARE;
9313
9342
  blockJSON.nextStatement = null; // null = available connection; undefined = terminal
9343
+ blockJSON.extensions.push('shape_hat');
9314
9344
  break;
9315
9345
  case BlockType.CONDITIONAL:
9316
9346
  case BlockType.LOOP:
@@ -9355,7 +9385,7 @@ class Runtime extends EventEmitter {
9355
9385
  }
9356
9386
  if (blockInfo.blockType === BlockType.REPORTER) {
9357
9387
  if (!blockInfo.disableMonitor && context.inputList.length === 0) {
9358
- blockJSON.checkboxInFlyout = true;
9388
+ blockJSON.extensions.push('monitor_block');
9359
9389
  }
9360
9390
  } else if (blockInfo.blockType === BlockType.LOOP) {
9361
9391
  // Add icon to the bottom right of a loop block
@@ -9582,7 +9612,7 @@ class Runtime extends EventEmitter {
9582
9612
  }
9583
9613
  return {
9584
9614
  id: categoryInfo.id,
9585
- xml: "<category name=\"".concat(name, "\" id=\"").concat(categoryInfo.id, "\" ").concat(statusButtonXML, " ").concat(colorXML, " ").concat(menuIconXML, ">").concat(paletteBlocks.map(block => block.xml).join(''), "</category>")
9615
+ xml: "<category name=\"".concat(name, "\" toolboxitemid=\"").concat(categoryInfo.id, "\" ").concat(statusButtonXML, " ").concat(colorXML, " ").concat(menuIconXML, ">").concat(paletteBlocks.map(block => block.xml).join(''), "</category>")
9586
9616
  };
9587
9617
  });
9588
9618
  }
@@ -80651,7 +80681,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"menuMap":{"cs":[{"code":"am","name":
80651
80681
  /***/ ((module) => {
80652
80682
 
80653
80683
  "use strict";
80654
- module.exports = /*#__PURE__*/JSON.parse('{"name":"scratch-vm","version":"5.0.162","description":"Virtual Machine for Scratch 3.0","author":"Massachusetts Institute of Technology","license":"AGPL-3.0-only","homepage":"https://github.com/scratchfoundation/scratch-vm#readme","repository":{"type":"git","url":"https://github.com/scratchfoundation/scratch-vm.git","sha":"3ea95acb38ab849fa4676d2561838920e161fe0d"},"main":"./dist/node/scratch-vm.js","browser":"./dist/web/scratch-vm.js","exports":{"webpack":"./src/index.js","browser":"./dist/web/scratch-vm.js","node":"./dist/node/scratch-vm.js","default":"./src/index.js"},"scripts":{"build":"npm run docs && webpack --progress","coverage":"tap ./test/{unit,integration}/*.js --coverage --coverage-report=lcov","docs":"jsdoc -c .jsdoc.json","i18n:src":"mkdirp translations/core && format-message extract --out-file translations/core/en.json src/extensions/**/index.js","i18n:push":"tx-push-src scratch-editor extensions translations/core/en.json","lint":"eslint . && format-message lint src/**/*.js","prepare":"husky install","prepublish":"in-publish && npm run build || not-in-publish","start":"webpack serve","tap":"tap ./test/{unit,integration}/*.js","tap:unit":"tap ./test/unit/*.js","tap:integration":"tap ./test/integration/*.js","test":"npm run lint && npm run tap","watch":"webpack --progress --watch","version":"json -f package.json -I -e \\"this.repository.sha = \'$(git log -n1 --pretty=format:%H)\'\\""},"config":{"commitizen":{"path":"cz-conventional-changelog"}},"browserslist":["Chrome >= 63","Edge >= 15","Firefox >= 57","Safari >= 11"],"tap":{"branches":60,"functions":70,"lines":70,"statements":70},"dependencies":{"@vernier/godirect":"^1.5.0","arraybuffer-loader":"^1.0.6","atob":"^2.1.2","btoa":"^1.2.1","buffer":"^6.0.3","canvas-toBlob":"^1.0.0","decode-html":"^2.0.0","diff-match-patch":"^1.0.4","format-message":"^6.2.1","htmlparser2":"^3.10.0","immutable":"^3.8.1","jszip":"^3.1.5","minilog":"^3.1.0","scratch-audio":"^2.0.0","scratch-parser":"^6.0.0","scratch-render":"^2.0.0","scratch-sb1-converter":"^2.0.0","scratch-storage":"^4.0.0","scratch-svg-renderer":"3.0.60","scratch-translate-extension-languages":"^1.0.0","text-encoding":"^0.7.0","uuid":"^8.3.2","web-worker":"^1.3.0"},"devDependencies":{"@babel/core":"7.26.7","@babel/eslint-parser":"7.26.5","@babel/preset-env":"7.26.7","@commitlint/cli":"17.8.1","@commitlint/config-conventional":"17.8.1","adm-zip":"0.4.11","babel-loader":"9.2.1","callsite":"1.0.0","copy-webpack-plugin":"4.6.0","docdash":"1.2.0","eslint":"8.57.1","eslint-config-scratch":"9.0.9","expose-loader":"1.0.3","file-loader":"6.2.0","format-message-cli":"6.2.4","husky":"8.0.3","in-publish":"2.0.1","js-md5":"0.7.3","jsdoc":"3.6.11","json":"^9.0.4","pngjs":"3.4.0","scratch-blocks":"1.1.206","scratch-l10n":"5.0.120","scratch-render-fonts":"1.0.161","scratch-semantic-release-config":"3.0.0","scratch-webpack-configuration":"3.0.0","script-loader":"0.7.2","semantic-release":"19.0.5","stats.js":"0.17.0","tap":"16.3.10","webpack":"5.97.1","webpack-cli":"4.10.0","webpack-dev-server":"3.11.3"}}');
80684
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"scratch-vm","version":"5.0.40-spork.1","description":"Virtual Machine for Scratch 3.0","author":"Massachusetts Institute of Technology","license":"AGPL-3.0-only","homepage":"https://github.com/scratchfoundation/scratch-vm#readme","repository":{"type":"git","url":"https://github.com/scratchfoundation/scratch-vm.git","sha":"0ed962df655549448753dec55cff5cb9678274d8"},"main":"./dist/node/scratch-vm.js","browser":"./dist/web/scratch-vm.js","exports":{"webpack":"./src/index.js","browser":"./dist/web/scratch-vm.js","node":"./dist/node/scratch-vm.js","default":"./src/index.js"},"scripts":{"build":"npm run docs && webpack --progress","coverage":"tap ./test/{unit,integration}/*.js --coverage --coverage-report=lcov","docs":"jsdoc -c .jsdoc.json","i18n:src":"mkdirp translations/core && format-message extract --out-file translations/core/en.json src/extensions/**/index.js","i18n:push":"tx-push-src scratch-editor extensions translations/core/en.json","lint":"eslint . && format-message lint src/**/*.js","prepare":"husky install","prepublish":"in-publish && npm run build || not-in-publish","start":"webpack serve","tap":"tap ./test/{unit,integration}/*.js","tap:unit":"tap ./test/unit/*.js","tap:integration":"tap ./test/integration/*.js","test":"npm run lint && npm run tap","watch":"webpack --progress --watch","version":"json -f package.json -I -e \\"this.repository.sha = \'$(git log -n1 --pretty=format:%H)\'\\""},"config":{"commitizen":{"path":"cz-conventional-changelog"}},"browserslist":["Chrome >= 63","Edge >= 15","Firefox >= 57","Safari >= 11"],"tap":{"branches":60,"functions":70,"lines":70,"statements":70},"dependencies":{"@vernier/godirect":"^1.5.0","arraybuffer-loader":"^1.0.6","atob":"^2.1.2","btoa":"^1.2.1","buffer":"^6.0.3","canvas-toBlob":"^1.0.0","decode-html":"^2.0.0","diff-match-patch":"^1.0.4","format-message":"^6.2.1","htmlparser2":"^3.10.0","immutable":"^3.8.1","jszip":"^3.1.5","minilog":"^3.1.0","scratch-audio":"^2.0.0","scratch-parser":"^6.0.0","scratch-render":"^2.0.0","scratch-sb1-converter":"^2.0.0","scratch-storage":"^4.0.0","scratch-svg-renderer":"3.0.60","scratch-translate-extension-languages":"^1.0.0","text-encoding":"^0.7.0","uuid":"^8.3.2","web-worker":"^1.3.0"},"devDependencies":{"@babel/core":"7.26.8","@babel/eslint-parser":"7.26.8","@babel/preset-env":"7.26.8","@commitlint/cli":"17.8.1","@commitlint/config-conventional":"17.8.1","adm-zip":"0.4.11","babel-loader":"9.2.1","callsite":"1.0.0","copy-webpack-plugin":"4.6.0","docdash":"1.2.0","eslint":"8.57.1","eslint-config-scratch":"9.0.9","expose-loader":"1.0.3","file-loader":"6.2.0","format-message-cli":"6.2.4","husky":"8.0.3","in-publish":"2.0.1","js-md5":"0.7.3","jsdoc":"3.6.11","json":"^9.0.4","pngjs":"3.4.0","scratch-blocks":"2.0.0-spork.4","scratch-l10n":"5.0.121","scratch-render-fonts":"1.0.161","scratch-semantic-release-config":"3.0.0","scratch-webpack-configuration":"3.0.0","script-loader":"0.7.2","semantic-release":"19.0.5","stats.js":"0.17.0","tap":"16.3.10","webpack":"5.97.1","webpack-cli":"4.10.0","webpack-dev-server":"3.11.3"}}');
80655
80685
 
80656
80686
  /***/ })
80657
80687