scratch-blocks 2.0.0-spork.1 → 2.0.0-spork.3

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.
Files changed (81) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/main.js +1 -1
  3. package/package.json +2 -3
  4. package/src/{block_reporting.js → block_reporting.ts} +7 -5
  5. package/src/blocks/{colour.js → colour.ts} +6 -6
  6. package/src/blocks/{control.js → control.ts} +21 -54
  7. package/src/blocks/{data.js → data.ts} +134 -142
  8. package/src/blocks/{event.js → event.ts} +12 -33
  9. package/src/blocks/{looks.js → looks.ts} +24 -73
  10. package/src/blocks/{math.js → math.ts} +6 -11
  11. package/src/blocks/{matrix.js → matrix.ts} +2 -3
  12. package/src/blocks/{motion.js → motion.ts} +23 -70
  13. package/src/blocks/{note.js → note.ts} +2 -3
  14. package/src/blocks/{operators.js → operators.ts} +18 -55
  15. package/src/blocks/{procedures.js → procedures.ts} +418 -269
  16. package/src/blocks/{sensing.js → sensing.ts} +21 -61
  17. package/src/blocks/{sound.js → sound.ts} +9 -28
  18. package/src/blocks/{text.js → text.ts} +1 -2
  19. package/src/blocks/{vertical_extensions.js → vertical_extensions.ts} +63 -100
  20. package/src/checkable_continuous_flyout.js +2 -2
  21. package/src/{checkbox_bubble.js → checkbox_bubble.ts} +36 -53
  22. package/src/{colours.js → colours.ts} +11 -4
  23. package/src/{constants.js → constants.ts} +13 -0
  24. package/src/{context_menu_items.js → context_menu_items.ts} +18 -12
  25. package/src/{data_category.js → data_category.ts} +216 -150
  26. package/src/events/{events_block_comment_base.js → events_block_comment_base.ts} +23 -4
  27. package/src/events/{events_block_comment_change.js → events_block_comment_change.ts} +29 -5
  28. package/src/events/{events_block_comment_collapse.js → events_block_comment_collapse.ts} +24 -6
  29. package/src/events/{events_block_comment_create.js → events_block_comment_create.ts} +36 -10
  30. package/src/events/{events_block_comment_delete.js → events_block_comment_delete.ts} +6 -2
  31. package/src/events/{events_block_comment_move.js → events_block_comment_move.ts} +36 -6
  32. package/src/events/events_block_comment_resize.ts +88 -0
  33. package/src/events/events_block_drag_end.ts +49 -0
  34. package/src/events/events_block_drag_outside.ts +44 -0
  35. package/src/events/{events_scratch_variable_create.js → events_scratch_variable_create.ts} +28 -15
  36. package/src/fields/{field_colour_slider.js → field_colour_slider.ts} +117 -106
  37. package/src/fields/{field_matrix.js → field_matrix.ts} +189 -215
  38. package/src/fields/{field_note.js → field_note.ts} +227 -286
  39. package/src/fields/{field_textinput_removable.js → field_textinput_removable.ts} +17 -20
  40. package/src/fields/{field_variable_getter.js → field_variable_getter.ts} +28 -17
  41. package/src/fields/{field_vertical_separator.js → field_vertical_separator.ts} +14 -30
  42. package/src/fields/{field_angle.js → scratch_field_angle.ts} +124 -80
  43. package/src/fields/{field_dropdown.js → scratch_field_dropdown.ts} +9 -7
  44. package/src/fields/{field_number.js → scratch_field_number.ts} +60 -55
  45. package/src/fields/{field_variable.js → scratch_field_variable.ts} +46 -27
  46. package/src/{flyout_checkbox_icon.js → flyout_checkbox_icon.ts} +15 -19
  47. package/src/{glows.js → glows.ts} +29 -18
  48. package/src/index.ts +59 -60
  49. package/src/procedures.ts +462 -0
  50. package/src/{recyclable_block_flyout_inflater.js → recyclable_block_flyout_inflater.ts} +35 -35
  51. package/src/renderer/{bowler_hat.js → bowler_hat.ts} +1 -1
  52. package/src/renderer/{constants.js → constants.ts} +26 -12
  53. package/src/renderer/{drawer.js → drawer.ts} +8 -3
  54. package/src/renderer/{path_object.js → path_object.ts} +2 -2
  55. package/src/renderer/{render_info.js → render_info.ts} +19 -7
  56. package/src/renderer/renderer.ts +76 -0
  57. package/src/{scratch_block_paster.js → scratch_block_paster.ts} +9 -7
  58. package/src/scratch_blocks_utils.ts +39 -0
  59. package/src/{scratch_comment_icon.js → scratch_comment_icon.ts} +43 -26
  60. package/src/scratch_connection_checker.ts +44 -0
  61. package/src/{scratch_continuous_category.js → scratch_continuous_category.ts} +20 -13
  62. package/src/{scratch_continuous_toolbox.js → scratch_continuous_toolbox.ts} +20 -18
  63. package/src/{scratch_dragger.js → scratch_dragger.ts} +97 -28
  64. package/src/{scratch_variable_map.js → scratch_variable_map.ts} +4 -1
  65. package/src/scratch_variable_model.ts +30 -0
  66. package/src/{shadows.js → shadows.ts} +8 -4
  67. package/src/{status_indicator_label.js → status_indicator_label.ts} +24 -36
  68. package/src/{status_indicator_label_flyout_inflater.js → status_indicator_label_flyout_inflater.ts} +9 -7
  69. package/src/{variables.js → variables.ts} +153 -123
  70. package/tsconfig.json +4 -2
  71. package/src/categories.js +0 -15
  72. package/src/events/events_block_comment_resize.js +0 -52
  73. package/src/events/events_block_drag_end.js +0 -33
  74. package/src/events/events_block_drag_outside.js +0 -30
  75. package/src/procedures.js +0 -425
  76. package/src/renderer/renderer.js +0 -74
  77. package/src/scratch_blocks_utils.js +0 -148
  78. package/src/scratch_connection_checker.js +0 -29
  79. package/src/scratch_variable_model.js +0 -24
  80. /package/src/{css.js → css.ts} +0 -0
  81. /package/{continuous-toolbox.d.ts → types/continuous-toolbox.d.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scratch-blocks",
3
- "version": "2.0.0-spork.1",
3
+ "version": "2.0.0-spork.3",
4
4
  "description": "Scratch Blocks is a library for building creative computing interfaces.",
5
5
  "author": "Massachusetts Institute of Technology",
6
6
  "license": "Apache-2.0",
@@ -13,7 +13,6 @@
13
13
  "scripts": {
14
14
  "build": "webpack --mode production",
15
15
  "prepare": "husky || true",
16
- "prepublish": "./temp-use-blockly-v12-rc.sh",
17
16
  "start": "webpack serve --open --mode development",
18
17
  "test": "echo \"Error: no test specified\" && exit 1",
19
18
  "test:lint": "eslint ."
@@ -35,7 +34,7 @@
35
34
  "dependencies": {
36
35
  "@blockly/continuous-toolbox": "^6.0.9",
37
36
  "@blockly/field-colour": "^5.0.9",
38
- "blockly": "^11.0.0"
37
+ "blockly": "^12.0.0-beta.0"
39
38
  },
40
39
  "config": {
41
40
  "commitizen": {
@@ -1,10 +1,12 @@
1
1
  import * as Blockly from "blockly/core";
2
- import { Colours } from "./colours.js";
2
+ import { Colours } from "./colours";
3
3
 
4
- export function reportValue(id, value) {
5
- const block =
6
- Blockly.getMainWorkspace().getBlockById(id) ||
7
- Blockly.getMainWorkspace().getFlyout().getWorkspace().getBlockById(id);
4
+ export function reportValue(id: string, value: string) {
5
+ const block = (Blockly.getMainWorkspace().getBlockById(id) ||
6
+ (Blockly.getMainWorkspace() as Blockly.WorkspaceSvg)
7
+ .getFlyout()
8
+ .getWorkspace()
9
+ .getBlockById(id)) as Blockly.BlockSvg;
8
10
  if (!block) {
9
11
  throw "Tried to report value on block that does not exist.";
10
12
  }
@@ -23,23 +23,23 @@
23
23
  * @author fraser@google.com (Neil Fraser)
24
24
  */
25
25
  import * as Blockly from "blockly/core";
26
- import * as Constants from "../constants.js";
26
+ import * as Constants from "../constants";
27
27
 
28
28
  /**
29
29
  * Pick a random colour.
30
- * @return {string} #RRGGBB for random colour.
30
+ *
31
+ * @returns #RRGGBB for random colour.
31
32
  */
32
- function randomColour() {
33
- var num = Math.floor(Math.random() * Math.pow(2, 24));
33
+ function randomColour(): string {
34
+ const num = Math.floor(Math.random() * Math.pow(2, 24));
34
35
  return "#" + ("00000" + num.toString(16)).substr(-6);
35
36
  }
36
37
 
37
38
  Blockly.Blocks["colour_picker"] = {
38
39
  /**
39
40
  * Block for colour picker.
40
- * @this Blockly.Block
41
41
  */
42
- init: function () {
42
+ init: function (this: Blockly.Block) {
43
43
  this.jsonInit({
44
44
  message0: "%1",
45
45
  args0: [
@@ -19,15 +19,13 @@
19
19
  */
20
20
 
21
21
  import * as Blockly from "blockly/core";
22
- import { Categories } from "../categories.js";
23
22
 
24
23
  Blockly.Blocks["control_forever"] = {
25
24
  /**
26
25
  * Block for repeat n times (external number).
27
26
  * https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#5eke39
28
- * @this Blockly.Block
29
27
  */
30
- init: function () {
28
+ init: function (this: Blockly.Block) {
31
29
  const ws = this.workspace.options.parentWorkspace || this.workspace;
32
30
  this.jsonInit({
33
31
  id: "control_forever",
@@ -51,7 +49,6 @@ Blockly.Blocks["control_forever"] = {
51
49
  flip_rtl: true,
52
50
  },
53
51
  ],
54
- category: Categories.control,
55
52
  extensions: ["colours_control", "shape_end"],
56
53
  });
57
54
  },
@@ -61,9 +58,8 @@ Blockly.Blocks["control_repeat"] = {
61
58
  /**
62
59
  * Block for repeat n times (external number).
63
60
  * https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#so57n9
64
- * @this Blockly.Block
65
61
  */
66
- init: function () {
62
+ init: function (this: Blockly.Block) {
67
63
  const ws = this.workspace.options.parentWorkspace || this.workspace;
68
64
  this.jsonInit({
69
65
  id: "control_repeat",
@@ -93,7 +89,6 @@ Blockly.Blocks["control_repeat"] = {
93
89
  flip_rtl: true,
94
90
  },
95
91
  ],
96
- category: Categories.control,
97
92
  extensions: ["colours_control", "shape_statement"],
98
93
  });
99
94
  },
@@ -102,9 +97,8 @@ Blockly.Blocks["control_repeat"] = {
102
97
  Blockly.Blocks["control_if"] = {
103
98
  /**
104
99
  * Block for if-then.
105
- * @this Blockly.Block
106
100
  */
107
- init: function () {
101
+ init: function (this: Blockly.Block) {
108
102
  this.jsonInit({
109
103
  type: "control_if",
110
104
  message0: Blockly.Msg.CONTROL_IF,
@@ -122,7 +116,6 @@ Blockly.Blocks["control_if"] = {
122
116
  name: "SUBSTACK",
123
117
  },
124
118
  ],
125
- category: Categories.control,
126
119
  extensions: ["colours_control", "shape_statement"],
127
120
  });
128
121
  },
@@ -131,9 +124,8 @@ Blockly.Blocks["control_if"] = {
131
124
  Blockly.Blocks["control_if_else"] = {
132
125
  /**
133
126
  * Block for if-else.
134
- * @this Blockly.Block
135
127
  */
136
- init: function () {
128
+ init: function (this: Blockly.Block) {
137
129
  this.jsonInit({
138
130
  type: "control_if_else",
139
131
  message0: Blockly.Msg.CONTROL_IF,
@@ -159,7 +151,6 @@ Blockly.Blocks["control_if_else"] = {
159
151
  name: "SUBSTACK2",
160
152
  },
161
153
  ],
162
- category: Categories.control,
163
154
  extensions: ["colours_control", "shape_statement"],
164
155
  });
165
156
  },
@@ -168,13 +159,12 @@ Blockly.Blocks["control_if_else"] = {
168
159
  Blockly.Blocks["control_stop"] = {
169
160
  /**
170
161
  * Block for stop all scripts.
171
- * @this Blockly.Block
172
162
  */
173
- init: function () {
174
- var ALL_SCRIPTS = "all";
175
- var THIS_SCRIPT = "this script";
176
- var OTHER_SCRIPTS = "other scripts in sprite";
177
- var stopDropdown = new Blockly.FieldDropdown(
163
+ init: function (this: Blockly.Block) {
164
+ const ALL_SCRIPTS = "all";
165
+ const THIS_SCRIPT = "this script";
166
+ const OTHER_SCRIPTS = "other scripts in sprite";
167
+ const stopDropdown = new Blockly.FieldDropdown(
178
168
  function () {
179
169
  if (
180
170
  this.sourceBlock_ &&
@@ -205,9 +195,8 @@ Blockly.Blocks["control_stop"] = {
205
195
  Blockly.Blocks["control_wait"] = {
206
196
  /**
207
197
  * Block to wait (pause) stack.
208
- * @this Blockly.Block
209
198
  */
210
- init: function () {
199
+ init: function (this: Blockly.Block) {
211
200
  this.jsonInit({
212
201
  id: "control_wait",
213
202
  message0: Blockly.Msg.CONTROL_WAIT,
@@ -217,7 +206,6 @@ Blockly.Blocks["control_wait"] = {
217
206
  name: "DURATION",
218
207
  },
219
208
  ],
220
- category: Categories.control,
221
209
  extensions: ["colours_control", "shape_statement"],
222
210
  });
223
211
  },
@@ -226,9 +214,8 @@ Blockly.Blocks["control_wait"] = {
226
214
  Blockly.Blocks["control_wait_until"] = {
227
215
  /**
228
216
  * Block to wait until a condition becomes true.
229
- * @this Blockly.Block
230
217
  */
231
- init: function () {
218
+ init: function (this: Blockly.Block) {
232
219
  this.jsonInit({
233
220
  message0: Blockly.Msg.CONTROL_WAITUNTIL,
234
221
  args0: [
@@ -238,7 +225,6 @@ Blockly.Blocks["control_wait_until"] = {
238
225
  check: "Boolean",
239
226
  },
240
227
  ],
241
- category: Categories.control,
242
228
  extensions: ["colours_control", "shape_statement"],
243
229
  });
244
230
  },
@@ -247,9 +233,8 @@ Blockly.Blocks["control_wait_until"] = {
247
233
  Blockly.Blocks["control_repeat_until"] = {
248
234
  /**
249
235
  * Block to repeat until a condition becomes true.
250
- * @this Blockly.Block
251
236
  */
252
- init: function () {
237
+ init: function (this: Blockly.Block) {
253
238
  const ws = this.workspace.options.parentWorkspace || this.workspace;
254
239
  this.jsonInit({
255
240
  message0: Blockly.Msg.CONTROL_REPEATUNTIL,
@@ -279,7 +264,6 @@ Blockly.Blocks["control_repeat_until"] = {
279
264
  flip_rtl: true,
280
265
  },
281
266
  ],
282
- category: Categories.control,
283
267
  extensions: ["colours_control", "shape_statement"],
284
268
  });
285
269
  },
@@ -290,7 +274,7 @@ Blockly.Blocks["control_while"] = {
290
274
  * Block to repeat until a condition becomes false.
291
275
  * (This is an obsolete "hacked" block, for compatibility with 2.0.)
292
276
  */
293
- init: function () {
277
+ init: function (this: Blockly.Block) {
294
278
  const ws = this.workspace.options.parentWorkspace || this.workspace;
295
279
  this.jsonInit({
296
280
  message0: Blockly.Msg.CONTROL_WHILE,
@@ -320,7 +304,6 @@ Blockly.Blocks["control_while"] = {
320
304
  flip_rtl: true,
321
305
  },
322
306
  ],
323
- category: Categories.control,
324
307
  extensions: ["colours_control", "shape_statement"],
325
308
  });
326
309
  },
@@ -330,9 +313,8 @@ Blockly.Blocks["control_for_each"] = {
330
313
  /**
331
314
  * Block for for-each. This is an obsolete block that is implemented for
332
315
  * compatibility with Scratch 2.0 projects.
333
- * @this Blockly.Block
334
316
  */
335
- init: function () {
317
+ init: function (this: Blockly.Block) {
336
318
  this.jsonInit({
337
319
  type: "control_for_each",
338
320
  message0: Blockly.Msg.CONTROL_FOREACH,
@@ -353,7 +335,6 @@ Blockly.Blocks["control_for_each"] = {
353
335
  name: "SUBSTACK",
354
336
  },
355
337
  ],
356
- category: Categories.control,
357
338
  extensions: ["colours_control", "shape_statement"],
358
339
  });
359
340
  },
@@ -362,14 +343,12 @@ Blockly.Blocks["control_for_each"] = {
362
343
  Blockly.Blocks["control_start_as_clone"] = {
363
344
  /**
364
345
  * Block for "when I start as a clone" hat.
365
- * @this Blockly.Block
366
346
  */
367
- init: function () {
347
+ init: function (this: Blockly.Block) {
368
348
  this.jsonInit({
369
349
  id: "control_start_as_clone",
370
350
  message0: Blockly.Msg.CONTROL_STARTASCLONE,
371
351
  args0: [],
372
- category: Categories.control,
373
352
  extensions: ["colours_control", "shape_hat"],
374
353
  });
375
354
  },
@@ -383,9 +362,8 @@ Blockly.Blocks["control_create_clone_of_menu"] = {};
383
362
  Blockly.Blocks["control_create_clone_of"] = {
384
363
  /**
385
364
  * Block for "create clone of..."
386
- * @this Blockly.Block
387
365
  */
388
- init: function () {
366
+ init: function (this: Blockly.Block) {
389
367
  this.jsonInit({
390
368
  id: "control_start_as_clone",
391
369
  message0: Blockly.Msg.CONTROL_CREATECLONEOF,
@@ -395,7 +373,6 @@ Blockly.Blocks["control_create_clone_of"] = {
395
373
  name: "CLONE_OPTION",
396
374
  },
397
375
  ],
398
- category: Categories.control,
399
376
  extensions: ["colours_control", "shape_statement"],
400
377
  });
401
378
  },
@@ -404,13 +381,11 @@ Blockly.Blocks["control_create_clone_of"] = {
404
381
  Blockly.Blocks["control_delete_this_clone"] = {
405
382
  /**
406
383
  * Block for "delete this clone."
407
- * @this Blockly.Block
408
384
  */
409
- init: function () {
385
+ init: function (this: Blockly.Block) {
410
386
  this.jsonInit({
411
387
  message0: Blockly.Msg.CONTROL_DELETETHISCLONE,
412
388
  args0: [],
413
- category: Categories.control,
414
389
  extensions: ["colours_control", "shape_end"],
415
390
  });
416
391
  },
@@ -420,12 +395,10 @@ Blockly.Blocks["control_get_counter"] = {
420
395
  /**
421
396
  * Block to get the counter value. This is an obsolete block that is
422
397
  * implemented for compatibility with Scratch 2.0 projects.
423
- * @this Blockly.Block
424
398
  */
425
- init: function () {
399
+ init: function (this: Blockly.Block) {
426
400
  this.jsonInit({
427
401
  message0: Blockly.Msg.CONTROL_COUNTER,
428
- category: Categories.control,
429
402
  extensions: ["colours_control", "output_number"],
430
403
  });
431
404
  },
@@ -435,12 +408,10 @@ Blockly.Blocks["control_incr_counter"] = {
435
408
  /**
436
409
  * Block to add one to the counter value. This is an obsolete block that is
437
410
  * implemented for compatibility with Scratch 2.0 projects.
438
- * @this Blockly.Block
439
411
  */
440
- init: function () {
412
+ init: function (this: Blockly.Block) {
441
413
  this.jsonInit({
442
414
  message0: Blockly.Msg.CONTROL_INCRCOUNTER,
443
- category: Categories.control,
444
415
  extensions: ["colours_control", "shape_statement"],
445
416
  });
446
417
  },
@@ -450,12 +421,10 @@ Blockly.Blocks["control_clear_counter"] = {
450
421
  /**
451
422
  * Block to clear the counter value. This is an obsolete block that is
452
423
  * implemented for compatibility with Scratch 2.0 projects.
453
- * @this Blockly.Block
454
424
  */
455
- init: function () {
425
+ init: function (this: Blockly.Block) {
456
426
  this.jsonInit({
457
427
  message0: Blockly.Msg.CONTROL_CLEARCOUNTER,
458
- category: Categories.control,
459
428
  extensions: ["colours_control", "shape_statement"],
460
429
  });
461
430
  },
@@ -473,9 +442,8 @@ Blockly.Blocks["control_all_at_once"] = {
473
442
  * reporter that is always true (e.g. "if 1 = 1"). Also note that the
474
443
  * Scratch 2.0 spec for this block is "warpSpeed", but the label shows
475
444
  * "all at once".
476
- * @this Blockly.Block
477
445
  */
478
- init: function () {
446
+ init: function (this: Blockly.Block) {
479
447
  this.jsonInit({
480
448
  message0: Blockly.Msg.CONTROL_ALLATONCE,
481
449
  message1: "%1", // Statement
@@ -485,7 +453,6 @@ Blockly.Blocks["control_all_at_once"] = {
485
453
  name: "SUBSTACK",
486
454
  },
487
455
  ],
488
- category: Categories.control,
489
456
  extensions: ["colours_control", "shape_statement"],
490
457
  });
491
458
  },