scratch-blocks 2.0.0-spork.2 → 2.0.0-spork.4

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 (85) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/main.js +1 -1
  3. package/dist/main.js.LICENSE.txt +0 -12
  4. package/package.json +4 -4
  5. package/src/{block_reporting.js → block_reporting.ts} +7 -5
  6. package/src/blocks/{colour.js → colour.ts} +6 -6
  7. package/src/blocks/{control.js → control.ts} +21 -54
  8. package/src/blocks/{data.js → data.ts} +134 -142
  9. package/src/blocks/{event.js → event.ts} +12 -33
  10. package/src/blocks/{looks.js → looks.ts} +24 -73
  11. package/src/blocks/{math.js → math.ts} +6 -11
  12. package/src/blocks/{matrix.js → matrix.ts} +2 -3
  13. package/src/blocks/{motion.js → motion.ts} +23 -70
  14. package/src/blocks/{note.js → note.ts} +2 -3
  15. package/src/blocks/{operators.js → operators.ts} +18 -55
  16. package/src/blocks/{procedures.js → procedures.ts} +418 -269
  17. package/src/blocks/{sensing.js → sensing.ts} +21 -61
  18. package/src/blocks/{sound.js → sound.ts} +9 -28
  19. package/src/blocks/{text.js → text.ts} +1 -2
  20. package/src/blocks/{vertical_extensions.js → vertical_extensions.ts} +63 -100
  21. package/src/checkable_continuous_flyout.ts +112 -0
  22. package/src/{checkbox_bubble.js → checkbox_bubble.ts} +40 -58
  23. package/src/{colours.js → colours.ts} +11 -4
  24. package/src/{constants.js → constants.ts} +13 -0
  25. package/src/{context_menu_items.js → context_menu_items.ts} +18 -12
  26. package/src/{css.js → css.ts} +13 -7
  27. package/src/{data_category.js → data_category.ts} +216 -150
  28. package/src/events/{events_block_comment_base.js → events_block_comment_base.ts} +23 -4
  29. package/src/events/{events_block_comment_change.js → events_block_comment_change.ts} +29 -5
  30. package/src/events/{events_block_comment_collapse.js → events_block_comment_collapse.ts} +24 -6
  31. package/src/events/{events_block_comment_create.js → events_block_comment_create.ts} +36 -10
  32. package/src/events/{events_block_comment_delete.js → events_block_comment_delete.ts} +6 -2
  33. package/src/events/{events_block_comment_move.js → events_block_comment_move.ts} +36 -6
  34. package/src/events/events_block_comment_resize.ts +88 -0
  35. package/src/events/events_block_drag_end.ts +49 -0
  36. package/src/events/events_block_drag_outside.ts +44 -0
  37. package/src/events/{events_scratch_variable_create.js → events_scratch_variable_create.ts} +28 -15
  38. package/src/fields/{field_colour_slider.js → field_colour_slider.ts} +117 -106
  39. package/src/fields/{field_matrix.js → field_matrix.ts} +189 -215
  40. package/src/fields/{field_note.js → field_note.ts} +227 -286
  41. package/src/fields/{field_textinput_removable.js → field_textinput_removable.ts} +17 -20
  42. package/src/fields/{field_variable_getter.js → field_variable_getter.ts} +28 -17
  43. package/src/fields/{field_vertical_separator.js → field_vertical_separator.ts} +14 -30
  44. package/src/fields/{field_angle.js → scratch_field_angle.ts} +124 -80
  45. package/src/fields/{field_dropdown.js → scratch_field_dropdown.ts} +9 -7
  46. package/src/fields/{field_number.js → scratch_field_number.ts} +60 -55
  47. package/src/fields/{field_variable.js → scratch_field_variable.ts} +46 -27
  48. package/src/{flyout_checkbox_icon.js → flyout_checkbox_icon.ts} +15 -19
  49. package/src/{glows.js → glows.ts} +29 -18
  50. package/src/index.ts +62 -63
  51. package/src/procedures.ts +462 -0
  52. package/src/recyclable_block_flyout_inflater.ts +51 -0
  53. package/src/renderer/{bowler_hat.js → bowler_hat.ts} +1 -1
  54. package/src/renderer/{constants.js → constants.ts} +26 -12
  55. package/src/renderer/{drawer.js → drawer.ts} +8 -3
  56. package/src/renderer/{path_object.js → path_object.ts} +2 -2
  57. package/src/renderer/{render_info.js → render_info.ts} +19 -7
  58. package/src/renderer/renderer.ts +76 -0
  59. package/src/{scratch_block_paster.js → scratch_block_paster.ts} +9 -7
  60. package/src/scratch_blocks_utils.ts +39 -0
  61. package/src/{scratch_comment_icon.js → scratch_comment_icon.ts} +43 -26
  62. package/src/scratch_connection_checker.ts +44 -0
  63. package/src/{scratch_continuous_category.js → scratch_continuous_category.ts} +20 -13
  64. package/src/scratch_continuous_toolbox.ts +70 -0
  65. package/src/{scratch_dragger.js → scratch_dragger.ts} +97 -28
  66. package/src/{scratch_variable_map.js → scratch_variable_map.ts} +4 -1
  67. package/src/scratch_variable_model.ts +30 -0
  68. package/src/{shadows.js → shadows.ts} +8 -4
  69. package/src/{status_indicator_label.js → status_indicator_label.ts} +24 -36
  70. package/src/{status_indicator_label_flyout_inflater.js → status_indicator_label_flyout_inflater.ts} +13 -9
  71. package/src/{variables.js → variables.ts} +153 -123
  72. package/tsconfig.json +5 -0
  73. package/src/categories.js +0 -15
  74. package/src/checkable_continuous_flyout.js +0 -138
  75. package/src/events/events_block_comment_resize.js +0 -52
  76. package/src/events/events_block_drag_end.js +0 -33
  77. package/src/events/events_block_drag_outside.js +0 -30
  78. package/src/procedures.js +0 -425
  79. package/src/recyclable_block_flyout_inflater.js +0 -194
  80. package/src/renderer/renderer.js +0 -74
  81. package/src/scratch_blocks_utils.js +0 -148
  82. package/src/scratch_connection_checker.js +0 -29
  83. package/src/scratch_continuous_toolbox.js +0 -78
  84. package/src/scratch_variable_model.js +0 -24
  85. /package/{continuous-toolbox.d.ts → types/continuous-toolbox.d.ts} +0 -0
@@ -19,14 +19,12 @@
19
19
  */
20
20
 
21
21
  import * as Blockly from "blockly/core";
22
- import { Categories } from "../categories.js";
23
22
 
24
23
  Blockly.Blocks["motion_movesteps"] = {
25
24
  /**
26
25
  * Block to move steps.
27
- * @this Blockly.Block
28
26
  */
29
- init: function () {
27
+ init: function (this: Blockly.Block) {
30
28
  this.jsonInit({
31
29
  message0: Blockly.Msg.MOTION_MOVESTEPS,
32
30
  args0: [
@@ -35,7 +33,6 @@ Blockly.Blocks["motion_movesteps"] = {
35
33
  name: "STEPS",
36
34
  },
37
35
  ],
38
- category: Categories.motion,
39
36
  extensions: ["colours_motion", "shape_statement"],
40
37
  });
41
38
  },
@@ -44,9 +41,8 @@ Blockly.Blocks["motion_movesteps"] = {
44
41
  Blockly.Blocks["motion_turnright"] = {
45
42
  /**
46
43
  * Block to turn right.
47
- * @this Blockly.Block
48
44
  */
49
- init: function () {
45
+ init: function (this: Blockly.Block) {
50
46
  const ws = this.workspace.options.parentWorkspace || this.workspace;
51
47
  this.jsonInit({
52
48
  message0: Blockly.Msg.MOTION_TURNRIGHT,
@@ -62,7 +58,6 @@ Blockly.Blocks["motion_turnright"] = {
62
58
  name: "DEGREES",
63
59
  },
64
60
  ],
65
- category: Categories.motion,
66
61
  extensions: ["colours_motion", "shape_statement"],
67
62
  });
68
63
  },
@@ -71,9 +66,8 @@ Blockly.Blocks["motion_turnright"] = {
71
66
  Blockly.Blocks["motion_turnleft"] = {
72
67
  /**
73
68
  * Block to turn left.
74
- * @this Blockly.Block
75
69
  */
76
- init: function () {
70
+ init: function (this: Blockly.Block) {
77
71
  const ws = this.workspace.options.parentWorkspace || this.workspace;
78
72
  this.jsonInit({
79
73
  message0: Blockly.Msg.MOTION_TURNLEFT,
@@ -89,7 +83,6 @@ Blockly.Blocks["motion_turnleft"] = {
89
83
  name: "DEGREES",
90
84
  },
91
85
  ],
92
- category: Categories.motion,
93
86
  extensions: ["colours_motion", "shape_statement"],
94
87
  });
95
88
  },
@@ -98,9 +91,8 @@ Blockly.Blocks["motion_turnleft"] = {
98
91
  Blockly.Blocks["motion_pointindirection"] = {
99
92
  /**
100
93
  * Block to point in direction.
101
- * @this Blockly.Block
102
94
  */
103
- init: function () {
95
+ init: function (this: Blockly.Block) {
104
96
  this.jsonInit({
105
97
  message0: Blockly.Msg.MOTION_POINTINDIRECTION,
106
98
  args0: [
@@ -109,7 +101,6 @@ Blockly.Blocks["motion_pointindirection"] = {
109
101
  name: "DIRECTION",
110
102
  },
111
103
  ],
112
- category: Categories.motion,
113
104
  extensions: ["colours_motion", "shape_statement"],
114
105
  });
115
106
  },
@@ -123,9 +114,8 @@ Blockly.Blocks["motion_pointtowards_menu"] = {};
123
114
  Blockly.Blocks["motion_pointtowards"] = {
124
115
  /**
125
116
  * Block to point in direction.
126
- * @this Blockly.Block
127
117
  */
128
- init: function () {
118
+ init: function (this: Blockly.Block) {
129
119
  this.jsonInit({
130
120
  message0: Blockly.Msg.MOTION_POINTTOWARDS,
131
121
  args0: [
@@ -134,7 +124,6 @@ Blockly.Blocks["motion_pointtowards"] = {
134
124
  name: "TOWARDS",
135
125
  },
136
126
  ],
137
- category: Categories.motion,
138
127
  extensions: ["colours_motion", "shape_statement"],
139
128
  });
140
129
  },
@@ -148,9 +137,8 @@ Blockly.Blocks["motion_goto_menu"] = {};
148
137
  Blockly.Blocks["motion_gotoxy"] = {
149
138
  /**
150
139
  * Block to go to X, Y.
151
- * @this Blockly.Block
152
140
  */
153
- init: function () {
141
+ init: function (this: Blockly.Block) {
154
142
  this.jsonInit({
155
143
  message0: Blockly.Msg.MOTION_GOTOXY,
156
144
  args0: [
@@ -163,7 +151,6 @@ Blockly.Blocks["motion_gotoxy"] = {
163
151
  name: "Y",
164
152
  },
165
153
  ],
166
- category: Categories.motion,
167
154
  extensions: ["colours_motion", "shape_statement"],
168
155
  });
169
156
  },
@@ -172,9 +159,8 @@ Blockly.Blocks["motion_gotoxy"] = {
172
159
  Blockly.Blocks["motion_goto"] = {
173
160
  /**
174
161
  * Block to go to a menu item.
175
- * @this Blockly.Block
176
162
  */
177
- init: function () {
163
+ init: function (this: Blockly.Block) {
178
164
  this.jsonInit({
179
165
  message0: Blockly.Msg.MOTION_GOTO,
180
166
  args0: [
@@ -183,7 +169,6 @@ Blockly.Blocks["motion_goto"] = {
183
169
  name: "TO",
184
170
  },
185
171
  ],
186
- category: Categories.motion,
187
172
  extensions: ["colours_motion", "shape_statement"],
188
173
  });
189
174
  },
@@ -192,9 +177,8 @@ Blockly.Blocks["motion_goto"] = {
192
177
  Blockly.Blocks["motion_glidesecstoxy"] = {
193
178
  /**
194
179
  * Block to glide for a specified time.
195
- * @this Blockly.Block
196
180
  */
197
- init: function () {
181
+ init: function (this: Blockly.Block) {
198
182
  this.jsonInit({
199
183
  message0: Blockly.Msg.MOTION_GLIDESECSTOXY,
200
184
  args0: [
@@ -211,7 +195,6 @@ Blockly.Blocks["motion_glidesecstoxy"] = {
211
195
  name: "Y",
212
196
  },
213
197
  ],
214
- category: Categories.motion,
215
198
  extensions: ["colours_motion", "shape_statement"],
216
199
  });
217
200
  },
@@ -225,9 +208,8 @@ Blockly.Blocks["motion_glideto_menu"] = {};
225
208
  Blockly.Blocks["motion_glideto"] = {
226
209
  /**
227
210
  * Block to glide to a menu item
228
- * @this Blockly.Block
229
211
  */
230
- init: function () {
212
+ init: function (this: Blockly.Block) {
231
213
  this.jsonInit({
232
214
  message0: Blockly.Msg.MOTION_GLIDETO,
233
215
  args0: [
@@ -240,7 +222,6 @@ Blockly.Blocks["motion_glideto"] = {
240
222
  name: "TO",
241
223
  },
242
224
  ],
243
- category: Categories.motion,
244
225
  extensions: ["colours_motion", "shape_statement"],
245
226
  });
246
227
  },
@@ -249,9 +230,8 @@ Blockly.Blocks["motion_glideto"] = {
249
230
  Blockly.Blocks["motion_changexby"] = {
250
231
  /**
251
232
  * Block to change X.
252
- * @this Blockly.Block
253
233
  */
254
- init: function () {
234
+ init: function (this: Blockly.Block) {
255
235
  this.jsonInit({
256
236
  message0: Blockly.Msg.MOTION_CHANGEXBY,
257
237
  args0: [
@@ -260,7 +240,6 @@ Blockly.Blocks["motion_changexby"] = {
260
240
  name: "DX",
261
241
  },
262
242
  ],
263
- category: Categories.motion,
264
243
  extensions: ["colours_motion", "shape_statement"],
265
244
  });
266
245
  },
@@ -269,9 +248,8 @@ Blockly.Blocks["motion_changexby"] = {
269
248
  Blockly.Blocks["motion_setx"] = {
270
249
  /**
271
250
  * Block to set X.
272
- * @this Blockly.Block
273
251
  */
274
- init: function () {
252
+ init: function (this: Blockly.Block) {
275
253
  this.jsonInit({
276
254
  message0: Blockly.Msg.MOTION_SETX,
277
255
  args0: [
@@ -280,7 +258,6 @@ Blockly.Blocks["motion_setx"] = {
280
258
  name: "X",
281
259
  },
282
260
  ],
283
- category: Categories.motion,
284
261
  extensions: ["colours_motion", "shape_statement"],
285
262
  });
286
263
  },
@@ -289,9 +266,8 @@ Blockly.Blocks["motion_setx"] = {
289
266
  Blockly.Blocks["motion_changeyby"] = {
290
267
  /**
291
268
  * Block to change Y.
292
- * @this Blockly.Block
293
269
  */
294
- init: function () {
270
+ init: function (this: Blockly.Block) {
295
271
  this.jsonInit({
296
272
  message0: Blockly.Msg.MOTION_CHANGEYBY,
297
273
  args0: [
@@ -300,7 +276,6 @@ Blockly.Blocks["motion_changeyby"] = {
300
276
  name: "DY",
301
277
  },
302
278
  ],
303
- category: Categories.motion,
304
279
  extensions: ["colours_motion", "shape_statement"],
305
280
  });
306
281
  },
@@ -309,9 +284,8 @@ Blockly.Blocks["motion_changeyby"] = {
309
284
  Blockly.Blocks["motion_sety"] = {
310
285
  /**
311
286
  * Block to set Y.
312
- * @this Blockly.Block
313
287
  */
314
- init: function () {
288
+ init: function (this: Blockly.Block) {
315
289
  this.jsonInit({
316
290
  message0: Blockly.Msg.MOTION_SETY,
317
291
  args0: [
@@ -320,7 +294,6 @@ Blockly.Blocks["motion_sety"] = {
320
294
  name: "Y",
321
295
  },
322
296
  ],
323
- category: Categories.motion,
324
297
  extensions: ["colours_motion", "shape_statement"],
325
298
  });
326
299
  },
@@ -329,12 +302,10 @@ Blockly.Blocks["motion_sety"] = {
329
302
  Blockly.Blocks["motion_ifonedgebounce"] = {
330
303
  /**
331
304
  * Block to bounce on edge.
332
- * @this Blockly.Block
333
305
  */
334
- init: function () {
306
+ init: function (this: Blockly.Block) {
335
307
  this.jsonInit({
336
308
  message0: Blockly.Msg.MOTION_IFONEDGEBOUNCE,
337
- category: Categories.motion,
338
309
  extensions: ["colours_motion", "shape_statement"],
339
310
  });
340
311
  },
@@ -343,9 +314,8 @@ Blockly.Blocks["motion_ifonedgebounce"] = {
343
314
  Blockly.Blocks["motion_setrotationstyle"] = {
344
315
  /**
345
316
  * Block to set rotation style.
346
- * @this Blockly.Block
347
317
  */
348
- init: function () {
318
+ init: function (this: Blockly.Block) {
349
319
  this.jsonInit({
350
320
  message0: Blockly.Msg.MOTION_SETROTATIONSTYLE,
351
321
  args0: [
@@ -359,7 +329,6 @@ Blockly.Blocks["motion_setrotationstyle"] = {
359
329
  ],
360
330
  },
361
331
  ],
362
- category: Categories.motion,
363
332
  extensions: ["colours_motion", "shape_statement"],
364
333
  });
365
334
  },
@@ -368,12 +337,10 @@ Blockly.Blocks["motion_setrotationstyle"] = {
368
337
  Blockly.Blocks["motion_xposition"] = {
369
338
  /**
370
339
  * Block to report X.
371
- * @this Blockly.Block
372
340
  */
373
- init: function () {
341
+ init: function (this: Blockly.Block) {
374
342
  this.jsonInit({
375
343
  message0: Blockly.Msg.MOTION_XPOSITION,
376
- category: Categories.motion,
377
344
  extensions: ["colours_motion", "output_number", "monitor_block"],
378
345
  });
379
346
  },
@@ -382,12 +349,10 @@ Blockly.Blocks["motion_xposition"] = {
382
349
  Blockly.Blocks["motion_yposition"] = {
383
350
  /**
384
351
  * Block to report Y.
385
- * @this Blockly.Block
386
352
  */
387
- init: function () {
353
+ init: function (this: Blockly.Block) {
388
354
  this.jsonInit({
389
355
  message0: Blockly.Msg.MOTION_YPOSITION,
390
- category: Categories.motion,
391
356
  extensions: ["colours_motion", "output_number", "monitor_block"],
392
357
  });
393
358
  },
@@ -396,12 +361,10 @@ Blockly.Blocks["motion_yposition"] = {
396
361
  Blockly.Blocks["motion_direction"] = {
397
362
  /**
398
363
  * Block to report direction.
399
- * @this Blockly.Block
400
364
  */
401
- init: function () {
365
+ init: function (this: Blockly.Block) {
402
366
  this.jsonInit({
403
367
  message0: Blockly.Msg.MOTION_DIRECTION,
404
- category: Categories.motion,
405
368
  extensions: ["colours_motion", "output_number", "monitor_block"],
406
369
  });
407
370
  },
@@ -412,9 +375,8 @@ Blockly.Blocks["motion_scroll_right"] = {
412
375
  * Block to scroll the stage right. Does not actually do anything. This is
413
376
  * an obsolete block that is implemented for compatibility with Scratch 2.0
414
377
  * projects.
415
- * @this Blockly.Block
416
378
  */
417
- init: function () {
379
+ init: function (this: Blockly.Block) {
418
380
  this.jsonInit({
419
381
  message0: Blockly.Msg.MOTION_SCROLLRIGHT,
420
382
  args0: [
@@ -423,7 +385,6 @@ Blockly.Blocks["motion_scroll_right"] = {
423
385
  name: "DISTANCE",
424
386
  },
425
387
  ],
426
- category: Categories.motion,
427
388
  extensions: ["colours_motion", "shape_statement"],
428
389
  });
429
390
  },
@@ -434,9 +395,8 @@ Blockly.Blocks["motion_scroll_up"] = {
434
395
  * Block to scroll the stage up. Does not actually do anything. This is an
435
396
  * obsolete block that is implemented for compatibility with Scratch 2.0
436
397
  * projects.
437
- * @this Blockly.Block
438
398
  */
439
- init: function () {
399
+ init: function (this: Blockly.Block) {
440
400
  this.jsonInit({
441
401
  message0: Blockly.Msg.MOTION_SCROLLUP,
442
402
  args0: [
@@ -445,7 +405,6 @@ Blockly.Blocks["motion_scroll_up"] = {
445
405
  name: "DISTANCE",
446
406
  },
447
407
  ],
448
- category: Categories.motion,
449
408
  extensions: ["colours_motion", "shape_statement"],
450
409
  });
451
410
  },
@@ -456,9 +415,8 @@ Blockly.Blocks["motion_align_scene"] = {
456
415
  * Block to change the stage's scrolling alignment. Does not actually do
457
416
  * anything. This is an obsolete block that is implemented for compatibility
458
417
  * with Scratch 2.0 projects.
459
- * @this Blockly.Block
460
418
  */
461
- init: function () {
419
+ init: function (this: Blockly.Block) {
462
420
  this.jsonInit({
463
421
  message0: Blockly.Msg.MOTION_ALIGNSCENE,
464
422
  args0: [
@@ -474,7 +432,6 @@ Blockly.Blocks["motion_align_scene"] = {
474
432
  ],
475
433
  },
476
434
  ],
477
- category: Categories.motion,
478
435
  extensions: ["colours_motion", "shape_statement"],
479
436
  });
480
437
  },
@@ -485,12 +442,10 @@ Blockly.Blocks["motion_xscroll"] = {
485
442
  * Block to report the stage's scroll position's X value. Does not actually
486
443
  * do anything. This is an obsolete block that is implemented for
487
444
  * compatibility with Scratch 2.0 projects.
488
- * @this Blockly.Block
489
445
  */
490
- init: function () {
446
+ init: function (this: Blockly.Block) {
491
447
  this.jsonInit({
492
448
  message0: Blockly.Msg.MOTION_XSCROLL,
493
- category: Categories.motion,
494
449
  extensions: ["colours_motion", "output_number"],
495
450
  });
496
451
  },
@@ -501,12 +456,10 @@ Blockly.Blocks["motion_yscroll"] = {
501
456
  * Block to report the stage's scroll position's Y value. Does not actually
502
457
  * do anything. This is an obsolete block that is implemented for
503
458
  * compatibility with Scratch 2.0 projects.
504
- * @this Blockly.Block
505
459
  */
506
- init: function () {
460
+ init: function (this: Blockly.Block) {
507
461
  this.jsonInit({
508
462
  message0: Blockly.Msg.MOTION_YSCROLL,
509
- category: Categories.motion,
510
463
  extensions: ["colours_motion", "output_number"],
511
464
  });
512
465
  },
@@ -23,14 +23,13 @@
23
23
  * @author ericr@media.mit.edu (Eric Rosenbaum)
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
  Blockly.Blocks["note"] = {
29
29
  /**
30
30
  * Block for musical note value.
31
- * @this Blockly.Block
32
31
  */
33
- init: function () {
32
+ init: function (this: Blockly.Block) {
34
33
  this.jsonInit({
35
34
  message0: "%1",
36
35
  args0: [