scratch-blocks 2.0.2 → 2.0.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 (275) hide show
  1. package/.nvmrc +1 -1
  2. package/commitlint.config.js +2 -2
  3. package/dist/main.mjs +1 -2
  4. package/dist/types/msg/scratch_msgs.d.ts.map +1 -1
  5. package/dist/types/src/block_reporting.d.ts.map +1 -1
  6. package/dist/types/src/blocks/colour.d.ts +0 -19
  7. package/dist/types/src/blocks/colour.d.ts.map +1 -1
  8. package/dist/types/src/blocks/control.d.ts +0 -19
  9. package/dist/types/src/blocks/control.d.ts.map +1 -1
  10. package/dist/types/src/blocks/data.d.ts +0 -19
  11. package/dist/types/src/blocks/data.d.ts.map +1 -1
  12. package/dist/types/src/blocks/event.d.ts +0 -19
  13. package/dist/types/src/blocks/event.d.ts.map +1 -1
  14. package/dist/types/src/blocks/looks.d.ts +0 -19
  15. package/dist/types/src/blocks/looks.d.ts.map +1 -1
  16. package/dist/types/src/blocks/math.d.ts +0 -19
  17. package/dist/types/src/blocks/math.d.ts.map +1 -1
  18. package/dist/types/src/blocks/matrix.d.ts +0 -19
  19. package/dist/types/src/blocks/matrix.d.ts.map +1 -1
  20. package/dist/types/src/blocks/motion.d.ts +0 -19
  21. package/dist/types/src/blocks/motion.d.ts.map +1 -1
  22. package/dist/types/src/blocks/note.d.ts +0 -19
  23. package/dist/types/src/blocks/note.d.ts.map +1 -1
  24. package/dist/types/src/blocks/operators.d.ts +0 -19
  25. package/dist/types/src/blocks/operators.d.ts.map +1 -1
  26. package/dist/types/src/blocks/procedures.d.ts +7 -10
  27. package/dist/types/src/blocks/procedures.d.ts.map +1 -1
  28. package/dist/types/src/blocks/sensing.d.ts +0 -19
  29. package/dist/types/src/blocks/sensing.d.ts.map +1 -1
  30. package/dist/types/src/blocks/sound.d.ts +0 -19
  31. package/dist/types/src/blocks/sound.d.ts.map +1 -1
  32. package/dist/types/src/blocks/text.d.ts +0 -19
  33. package/dist/types/src/blocks/text.d.ts.map +1 -1
  34. package/dist/types/src/blocks/vertical_extensions.d.ts +0 -19
  35. package/dist/types/src/blocks/vertical_extensions.d.ts.map +1 -1
  36. package/dist/types/src/checkable_continuous_flyout.d.ts +2 -7
  37. package/dist/types/src/checkable_continuous_flyout.d.ts.map +1 -1
  38. package/dist/types/src/checkbox_bubble.d.ts +13 -12
  39. package/dist/types/src/checkbox_bubble.d.ts.map +1 -1
  40. package/dist/types/src/colours.d.ts.map +1 -1
  41. package/dist/types/src/constants.d.ts +0 -7
  42. package/dist/types/src/constants.d.ts.map +1 -1
  43. package/dist/types/src/context_menu_items.d.ts +0 -5
  44. package/dist/types/src/context_menu_items.d.ts.map +1 -1
  45. package/dist/types/src/data_category.d.ts +2 -4
  46. package/dist/types/src/data_category.d.ts.map +1 -1
  47. package/dist/types/src/events/events_block_comment_base.d.ts +2 -3
  48. package/dist/types/src/events/events_block_comment_base.d.ts.map +1 -1
  49. package/dist/types/src/events/events_block_comment_change.d.ts +0 -5
  50. package/dist/types/src/events/events_block_comment_change.d.ts.map +1 -1
  51. package/dist/types/src/events/events_block_comment_collapse.d.ts +0 -5
  52. package/dist/types/src/events/events_block_comment_collapse.d.ts.map +1 -1
  53. package/dist/types/src/events/events_block_comment_create.d.ts +0 -5
  54. package/dist/types/src/events/events_block_comment_create.d.ts.map +1 -1
  55. package/dist/types/src/events/events_block_comment_delete.d.ts +0 -5
  56. package/dist/types/src/events/events_block_comment_delete.d.ts.map +1 -1
  57. package/dist/types/src/events/events_block_comment_move.d.ts +0 -5
  58. package/dist/types/src/events/events_block_comment_move.d.ts.map +1 -1
  59. package/dist/types/src/events/events_block_comment_resize.d.ts +0 -5
  60. package/dist/types/src/events/events_block_comment_resize.d.ts.map +1 -1
  61. package/dist/types/src/events/events_block_drag_end.d.ts +1 -2
  62. package/dist/types/src/events/events_block_drag_end.d.ts.map +1 -1
  63. package/dist/types/src/events/events_block_drag_outside.d.ts +1 -2
  64. package/dist/types/src/events/events_block_drag_outside.d.ts.map +1 -1
  65. package/dist/types/src/events/events_scratch_variable_create.d.ts +0 -5
  66. package/dist/types/src/events/events_scratch_variable_create.d.ts.map +1 -1
  67. package/dist/types/src/fields/field_colour_slider.d.ts +7 -9
  68. package/dist/types/src/fields/field_colour_slider.d.ts.map +1 -1
  69. package/dist/types/src/fields/field_matrix.d.ts +0 -19
  70. package/dist/types/src/fields/field_matrix.d.ts.map +1 -1
  71. package/dist/types/src/fields/field_note.d.ts +8 -23
  72. package/dist/types/src/fields/field_note.d.ts.map +1 -1
  73. package/dist/types/src/fields/field_textinput_removable.d.ts +2 -4
  74. package/dist/types/src/fields/field_textinput_removable.d.ts.map +1 -1
  75. package/dist/types/src/fields/field_variable_getter.d.ts +0 -19
  76. package/dist/types/src/fields/field_variable_getter.d.ts.map +1 -1
  77. package/dist/types/src/fields/field_vertical_separator.d.ts +0 -19
  78. package/dist/types/src/fields/field_vertical_separator.d.ts.map +1 -1
  79. package/dist/types/src/fields/scratch_field_angle.d.ts +0 -19
  80. package/dist/types/src/fields/scratch_field_angle.d.ts.map +1 -1
  81. package/dist/types/src/fields/scratch_field_dropdown.d.ts +0 -5
  82. package/dist/types/src/fields/scratch_field_dropdown.d.ts.map +1 -1
  83. package/dist/types/src/fields/scratch_field_number.d.ts +0 -19
  84. package/dist/types/src/fields/scratch_field_number.d.ts.map +1 -1
  85. package/dist/types/src/fields/scratch_field_variable.d.ts +4 -7
  86. package/dist/types/src/fields/scratch_field_variable.d.ts.map +1 -1
  87. package/dist/types/src/flyout_checkbox_icon.d.ts +2 -3
  88. package/dist/types/src/flyout_checkbox_icon.d.ts.map +1 -1
  89. package/dist/types/src/glows.d.ts +1 -3
  90. package/dist/types/src/glows.d.ts.map +1 -1
  91. package/dist/types/src/index.d.ts +50 -55
  92. package/dist/types/src/index.d.ts.map +1 -1
  93. package/dist/types/src/procedures.d.ts +6 -8
  94. package/dist/types/src/procedures.d.ts.map +1 -1
  95. package/dist/types/src/recyclable_block_flyout_inflater.d.ts +3 -5
  96. package/dist/types/src/recyclable_block_flyout_inflater.d.ts.map +1 -1
  97. package/dist/types/src/renderer/bowler_hat.d.ts +2 -3
  98. package/dist/types/src/renderer/bowler_hat.d.ts.map +1 -1
  99. package/dist/types/src/renderer/cat/cat_face.d.ts +6 -5
  100. package/dist/types/src/renderer/cat/cat_face.d.ts.map +1 -1
  101. package/dist/types/src/renderer/cat/constants.d.ts +2 -2
  102. package/dist/types/src/renderer/cat/constants.d.ts.map +1 -1
  103. package/dist/types/src/renderer/cat/drawer.d.ts +3 -4
  104. package/dist/types/src/renderer/cat/drawer.d.ts.map +1 -1
  105. package/dist/types/src/renderer/cat/path_object.d.ts +2 -3
  106. package/dist/types/src/renderer/cat/path_object.d.ts.map +1 -1
  107. package/dist/types/src/renderer/cat/render_info.d.ts +3 -4
  108. package/dist/types/src/renderer/cat/render_info.d.ts.map +1 -1
  109. package/dist/types/src/renderer/cat/renderer.d.ts +6 -7
  110. package/dist/types/src/renderer/cat/renderer.d.ts.map +1 -1
  111. package/dist/types/src/renderer/constants.d.ts +4 -4
  112. package/dist/types/src/renderer/constants.d.ts.map +1 -1
  113. package/dist/types/src/renderer/drawer.d.ts +5 -4
  114. package/dist/types/src/renderer/drawer.d.ts.map +1 -1
  115. package/dist/types/src/renderer/path_object.d.ts +1 -3
  116. package/dist/types/src/renderer/path_object.d.ts.map +1 -1
  117. package/dist/types/src/renderer/render_info.d.ts +3 -4
  118. package/dist/types/src/renderer/render_info.d.ts.map +1 -1
  119. package/dist/types/src/renderer/renderer.d.ts +8 -15
  120. package/dist/types/src/renderer/renderer.d.ts.map +1 -1
  121. package/dist/types/src/scratch_block_paster.d.ts +0 -5
  122. package/dist/types/src/scratch_block_paster.d.ts.map +1 -1
  123. package/dist/types/src/scratch_blocks_utils.d.ts +0 -20
  124. package/dist/types/src/scratch_blocks_utils.d.ts.map +1 -1
  125. package/dist/types/src/scratch_comment_bubble.d.ts +1 -4
  126. package/dist/types/src/scratch_comment_bubble.d.ts.map +1 -1
  127. package/dist/types/src/scratch_comment_icon.d.ts +2 -3
  128. package/dist/types/src/scratch_comment_icon.d.ts.map +1 -1
  129. package/dist/types/src/scratch_connection_checker.d.ts +0 -5
  130. package/dist/types/src/scratch_connection_checker.d.ts.map +1 -1
  131. package/dist/types/src/scratch_continuous_category.d.ts +5 -5
  132. package/dist/types/src/scratch_continuous_category.d.ts.map +1 -1
  133. package/dist/types/src/scratch_continuous_toolbox.d.ts +3 -6
  134. package/dist/types/src/scratch_continuous_toolbox.d.ts.map +1 -1
  135. package/dist/types/src/scratch_dragger.d.ts +3 -12
  136. package/dist/types/src/scratch_dragger.d.ts.map +1 -1
  137. package/dist/types/src/scratch_insertion_marker_previewer.d.ts +0 -5
  138. package/dist/types/src/scratch_insertion_marker_previewer.d.ts.map +1 -1
  139. package/dist/types/src/scratch_variable_map.d.ts +0 -5
  140. package/dist/types/src/scratch_variable_map.d.ts.map +1 -1
  141. package/dist/types/src/scratch_variable_model.d.ts +1 -2
  142. package/dist/types/src/scratch_variable_model.d.ts.map +1 -1
  143. package/dist/types/src/scratch_zoom_controls.d.ts +4 -6
  144. package/dist/types/src/scratch_zoom_controls.d.ts.map +1 -1
  145. package/dist/types/src/shadows.d.ts +2 -2
  146. package/dist/types/src/shadows.d.ts.map +1 -1
  147. package/dist/types/src/status_indicator_label.d.ts +4 -6
  148. package/dist/types/src/status_indicator_label.d.ts.map +1 -1
  149. package/dist/types/src/status_indicator_label_flyout_inflater.d.ts +1 -6
  150. package/dist/types/src/status_indicator_label_flyout_inflater.d.ts.map +1 -1
  151. package/dist/types/src/variables.d.ts +4 -8
  152. package/dist/types/src/variables.d.ts.map +1 -1
  153. package/dist/types/src/xml.d.ts +2 -3
  154. package/dist/types/src/xml.d.ts.map +1 -1
  155. package/dist/types/tests/jsunit/block_test.d.ts.map +1 -1
  156. package/dist/types/tests/jsunit/connection_db_test.d.ts.map +1 -1
  157. package/dist/types/tests/jsunit/connection_test.d.ts.map +1 -1
  158. package/dist/types/tests/jsunit/event_test.d.ts.map +1 -1
  159. package/dist/types/tests/jsunit/extensions_test.d.ts.map +1 -1
  160. package/dist/types/tests/jsunit/field_number_test.d.ts.map +1 -1
  161. package/dist/types/tests/jsunit/field_test.d.ts.map +1 -1
  162. package/dist/types/tests/jsunit/field_variable_getter_test.d.ts.map +1 -1
  163. package/dist/types/tests/jsunit/field_variable_test.d.ts.map +1 -1
  164. package/dist/types/tests/jsunit/gesture_test.d.ts.map +1 -1
  165. package/dist/types/tests/jsunit/input_test.d.ts +1 -0
  166. package/dist/types/tests/jsunit/input_test.d.ts.map +1 -1
  167. package/dist/types/tests/jsunit/json_test.d.ts.map +1 -1
  168. package/dist/types/tests/jsunit/names_test.d.ts.map +1 -1
  169. package/dist/types/tests/jsunit/procedure_test.d.ts.map +1 -1
  170. package/dist/types/tests/jsunit/scratch_block_comment_test.d.ts.map +1 -1
  171. package/dist/types/tests/jsunit/svg_test.d.ts.map +1 -1
  172. package/dist/types/tests/jsunit/test_utilities.d.ts.map +1 -1
  173. package/dist/types/tests/jsunit/utils_test.d.ts.map +1 -1
  174. package/dist/types/tests/jsunit/variable_map_test.d.ts.map +1 -1
  175. package/dist/types/tests/jsunit/variable_model_test.d.ts.map +1 -1
  176. package/dist/types/tests/jsunit/widget_div_test.d.ts.map +1 -1
  177. package/dist/types/tests/jsunit/workspace_comment_test.d.ts.map +1 -1
  178. package/dist/types/tests/jsunit/workspace_test.d.ts.map +1 -1
  179. package/dist/types/tests/jsunit/workspace_undo_redo_test.d.ts.map +1 -1
  180. package/dist/types/tests/jsunit/xml_test.d.ts.map +1 -1
  181. package/dist/types/tests/workspace_svg/workspace_svg_test.d.ts.map +1 -1
  182. package/eslint.config.mjs +69 -0
  183. package/i18n/create_scratch_msgs.js +44 -45
  184. package/i18n/js_to_json.js +40 -32
  185. package/i18n/json_to_js.js +37 -37
  186. package/i18n/sync_tx_translations.js +64 -65
  187. package/i18n/test_scratch_msgs.js +66 -63
  188. package/msg/js/en.js +289 -287
  189. package/msg/json/en.json +284 -284
  190. package/msg/messages.js +289 -287
  191. package/msg/scratch_msgs.js +22959 -22970
  192. package/package.json +13 -10
  193. package/prettier.config.mjs +3 -0
  194. package/release.config.js +7 -7
  195. package/renovate.json5 +7 -9
  196. package/src/block_reporting.ts +15 -18
  197. package/src/blocks/colour.ts +12 -15
  198. package/src/blocks/control.ts +167 -177
  199. package/src/blocks/data.ts +225 -292
  200. package/src/blocks/event.ts +121 -123
  201. package/src/blocks/looks.ts +165 -167
  202. package/src/blocks/math.ts +44 -46
  203. package/src/blocks/matrix.ts +11 -13
  204. package/src/blocks/motion.ts +151 -153
  205. package/src/blocks/note.ts +11 -13
  206. package/src/blocks/operators.ts +158 -160
  207. package/src/blocks/procedures.ts +488 -536
  208. package/src/blocks/sensing.ts +163 -165
  209. package/src/blocks/sound.ts +58 -60
  210. package/src/blocks/text.ts +10 -12
  211. package/src/blocks/vertical_extensions.ts +86 -102
  212. package/src/checkable_continuous_flyout.ts +25 -42
  213. package/src/checkbox_bubble.ts +83 -100
  214. package/src/colours.ts +35 -37
  215. package/src/constants.ts +22 -29
  216. package/src/context_menu_items.ts +56 -81
  217. package/src/css.ts +3 -4
  218. package/src/data_category.ts +136 -250
  219. package/src/events/events_block_comment_base.ts +21 -31
  220. package/src/events/events_block_comment_change.ts +21 -42
  221. package/src/events/events_block_comment_collapse.ts +22 -43
  222. package/src/events/events_block_comment_create.ts +29 -46
  223. package/src/events/events_block_comment_delete.ts +10 -19
  224. package/src/events/events_block_comment_move.ts +27 -52
  225. package/src/events/events_block_comment_resize.ts +28 -55
  226. package/src/events/events_block_drag_end.ts +16 -26
  227. package/src/events/events_block_drag_outside.ts +12 -22
  228. package/src/events/events_scratch_variable_create.ts +33 -56
  229. package/src/fields/field_colour_slider.ts +173 -228
  230. package/src/fields/field_matrix.ts +200 -269
  231. package/src/fields/field_note.ts +272 -377
  232. package/src/fields/field_textinput_removable.ts +25 -40
  233. package/src/fields/field_variable_getter.ts +26 -31
  234. package/src/fields/field_vertical_separator.ts +19 -24
  235. package/src/fields/scratch_field_angle.ts +150 -186
  236. package/src/fields/scratch_field_dropdown.ts +15 -19
  237. package/src/fields/scratch_field_number.ts +123 -180
  238. package/src/fields/scratch_field_variable.ts +52 -73
  239. package/src/flyout_checkbox_icon.ts +18 -28
  240. package/src/glows.ts +51 -58
  241. package/src/index.ts +119 -133
  242. package/src/procedures.ts +144 -211
  243. package/src/recyclable_block_flyout_inflater.ts +14 -25
  244. package/src/renderer/bowler_hat.ts +6 -8
  245. package/src/renderer/cat/cat_face.ts +98 -99
  246. package/src/renderer/cat/constants.ts +67 -87
  247. package/src/renderer/cat/drawer.ts +21 -27
  248. package/src/renderer/cat/path_object.ts +3 -5
  249. package/src/renderer/cat/render_info.ts +5 -8
  250. package/src/renderer/cat/renderer.ts +11 -15
  251. package/src/renderer/constants.ts +34 -49
  252. package/src/renderer/drawer.ts +35 -51
  253. package/src/renderer/path_object.ts +13 -15
  254. package/src/renderer/render_info.ts +36 -56
  255. package/src/renderer/renderer.ts +16 -29
  256. package/src/scratch_block_paster.ts +12 -20
  257. package/src/scratch_blocks_utils.ts +4 -7
  258. package/src/scratch_comment_bubble.ts +70 -101
  259. package/src/scratch_comment_icon.ts +74 -123
  260. package/src/scratch_connection_checker.ts +22 -17
  261. package/src/scratch_continuous_category.ts +24 -28
  262. package/src/scratch_continuous_toolbox.ts +20 -27
  263. package/src/scratch_dragger.ts +54 -86
  264. package/src/scratch_insertion_marker_previewer.ts +6 -11
  265. package/src/scratch_variable_map.ts +5 -12
  266. package/src/scratch_variable_model.ts +4 -11
  267. package/src/scratch_zoom_controls.ts +101 -156
  268. package/src/shadows.ts +32 -37
  269. package/src/status_indicator_label.ts +54 -67
  270. package/src/status_indicator_label_flyout_inflater.ts +11 -21
  271. package/src/variables.ts +89 -138
  272. package/src/xml.ts +21 -35
  273. package/tsconfig.json +2 -6
  274. package/types/continuous-toolbox.d.ts +1 -1
  275. package/dist/main.mjs.LICENSE.txt +0 -163
@@ -1,5 +1,4 @@
1
1
  /**
2
- * @license
3
2
  * Visual Blocks Editor
4
3
  *
5
4
  * Copyright 2016 Massachusetts Institute of Technology
@@ -17,40 +16,34 @@
17
16
  * See the License for the specific language governing permissions and
18
17
  * limitations under the License.
19
18
  */
19
+ import * as Blockly from 'blockly/core'
20
+ import * as Constants from '../constants'
21
+ import type { ScratchFieldVariable } from '../fields/scratch_field_variable'
22
+ import * as scratchBlocksUtils from '../scratch_blocks_utils'
23
+ import type { ScratchVariableModel } from '../scratch_variable_model'
24
+ import { renameVariable } from '../variables'
20
25
 
21
- import * as Blockly from "blockly/core";
22
- import * as Constants from "../constants";
23
- import * as scratchBlocksUtils from "../scratch_blocks_utils";
24
- import { renameVariable } from "../variables";
25
- import type { ScratchFieldVariable } from "../fields/scratch_field_variable";
26
- import type { ScratchVariableModel } from "../scratch_variable_model";
27
-
28
- Blockly.Blocks["data_variable"] = {
26
+ Blockly.Blocks.data_variable = {
29
27
  /**
30
28
  * Block of Variables
31
29
  */
32
30
  init: function (this: Blockly.Block) {
33
31
  this.jsonInit({
34
- message0: "%1",
35
- lastDummyAlign0: "CENTRE",
32
+ message0: '%1',
33
+ lastDummyAlign0: 'CENTRE',
36
34
  args0: [
37
35
  {
38
- type: "field_variable_getter",
39
- name: "VARIABLE",
36
+ type: 'field_variable_getter',
37
+ name: 'VARIABLE',
40
38
  allowedVariableType: Constants.SCALAR_VARIABLE_TYPE,
41
39
  },
42
40
  ],
43
- extensions: [
44
- "contextMenu_getVariableBlock",
45
- "colours_data",
46
- "output_string",
47
- "monitor_block",
48
- ],
49
- });
41
+ extensions: ['contextMenu_getVariableBlock', 'colours_data', 'output_string', 'monitor_block'],
42
+ })
50
43
  },
51
- };
44
+ }
52
45
 
53
- Blockly.Blocks["data_setvariableto"] = {
46
+ Blockly.Blocks.data_setvariableto = {
54
47
  /**
55
48
  * Block to set variable to a certain value
56
49
  */
@@ -59,22 +52,22 @@ Blockly.Blocks["data_setvariableto"] = {
59
52
  message0: Blockly.Msg.DATA_SETVARIABLETO,
60
53
  args0: [
61
54
  {
62
- type: "field_variable",
63
- name: "VARIABLE",
55
+ type: 'field_variable',
56
+ name: 'VARIABLE',
64
57
  variableTypes: [Constants.SCALAR_VARIABLE_TYPE],
65
58
  defaultType: Constants.SCALAR_VARIABLE_TYPE,
66
59
  },
67
60
  {
68
- type: "input_value",
69
- name: "VALUE",
61
+ type: 'input_value',
62
+ name: 'VALUE',
70
63
  },
71
64
  ],
72
- extensions: ["colours_data", "shape_statement"],
73
- });
65
+ extensions: ['colours_data', 'shape_statement'],
66
+ })
74
67
  },
75
- };
68
+ }
76
69
 
77
- Blockly.Blocks["data_changevariableby"] = {
70
+ Blockly.Blocks.data_changevariableby = {
78
71
  /**
79
72
  * Block to change variable by a certain value
80
73
  */
@@ -83,22 +76,22 @@ Blockly.Blocks["data_changevariableby"] = {
83
76
  message0: Blockly.Msg.DATA_CHANGEVARIABLEBY,
84
77
  args0: [
85
78
  {
86
- type: "field_variable",
87
- name: "VARIABLE",
79
+ type: 'field_variable',
80
+ name: 'VARIABLE',
88
81
  variableTypes: [Constants.SCALAR_VARIABLE_TYPE],
89
82
  defaultType: Constants.SCALAR_VARIABLE_TYPE,
90
83
  },
91
84
  {
92
- type: "input_value",
93
- name: "VALUE",
85
+ type: 'input_value',
86
+ name: 'VALUE',
94
87
  },
95
88
  ],
96
- extensions: ["colours_data", "shape_statement"],
97
- });
89
+ extensions: ['colours_data', 'shape_statement'],
90
+ })
98
91
  },
99
- };
92
+ }
100
93
 
101
- Blockly.Blocks["data_showvariable"] = {
94
+ Blockly.Blocks.data_showvariable = {
102
95
  /**
103
96
  * Block to show a variable
104
97
  */
@@ -107,20 +100,20 @@ Blockly.Blocks["data_showvariable"] = {
107
100
  message0: Blockly.Msg.DATA_SHOWVARIABLE,
108
101
  args0: [
109
102
  {
110
- type: "field_variable",
111
- name: "VARIABLE",
103
+ type: 'field_variable',
104
+ name: 'VARIABLE',
112
105
  variableTypes: [Constants.SCALAR_VARIABLE_TYPE],
113
106
  defaultType: Constants.SCALAR_VARIABLE_TYPE,
114
107
  },
115
108
  ],
116
109
  previousStatement: null,
117
110
  nextStatement: null,
118
- extensions: ["colours_data"],
119
- });
111
+ extensions: ['colours_data'],
112
+ })
120
113
  },
121
- };
114
+ }
122
115
 
123
- Blockly.Blocks["data_hidevariable"] = {
116
+ Blockly.Blocks.data_hidevariable = {
124
117
  /**
125
118
  * Block to hide a variable
126
119
  */
@@ -129,96 +122,91 @@ Blockly.Blocks["data_hidevariable"] = {
129
122
  message0: Blockly.Msg.DATA_HIDEVARIABLE,
130
123
  args0: [
131
124
  {
132
- type: "field_variable",
133
- name: "VARIABLE",
125
+ type: 'field_variable',
126
+ name: 'VARIABLE',
134
127
  variableTypes: [Constants.SCALAR_VARIABLE_TYPE],
135
128
  defaultType: Constants.SCALAR_VARIABLE_TYPE,
136
129
  },
137
130
  ],
138
131
  previousStatement: null,
139
132
  nextStatement: null,
140
- extensions: ["colours_data"],
141
- });
133
+ extensions: ['colours_data'],
134
+ })
142
135
  },
143
- };
136
+ }
144
137
 
145
- Blockly.Blocks["data_listcontents"] = {
138
+ Blockly.Blocks.data_listcontents = {
146
139
  /**
147
140
  * List reporter.
148
141
  */
149
142
  init: function (this: Blockly.Block) {
150
143
  this.jsonInit({
151
- message0: "%1",
144
+ message0: '%1',
152
145
  args0: [
153
146
  {
154
- type: "field_variable_getter",
155
- name: "LIST",
147
+ type: 'field_variable_getter',
148
+ name: 'LIST',
156
149
  allowedVariableType: Constants.LIST_VARIABLE_TYPE,
157
150
  },
158
151
  ],
159
- extensions: [
160
- "contextMenu_getListBlock",
161
- "colours_data_lists",
162
- "output_string",
163
- "monitor_block",
164
- ],
165
- });
152
+ extensions: ['contextMenu_getListBlock', 'colours_data_lists', 'output_string', 'monitor_block'],
153
+ })
166
154
  },
167
- };
155
+ }
168
156
 
169
- Blockly.Blocks["data_listindexall"] = {
157
+ Blockly.Blocks.data_listindexall = {
170
158
  /**
171
159
  * List index menu, with all option.
172
160
  */
173
161
  init: function (this: Blockly.Block) {
174
162
  this.jsonInit({
175
- message0: "%1",
163
+ message0: '%1',
176
164
  args0: [
177
165
  {
178
- type: "field_numberdropdown",
179
- name: "INDEX",
180
- value: "1",
166
+ type: 'field_numberdropdown',
167
+ name: 'INDEX',
168
+ value: '1',
181
169
  min: 1,
182
170
  precision: 1,
183
171
  options: [
184
- ["1", "1"],
185
- [Blockly.Msg.DATA_INDEX_LAST, "last"],
186
- [Blockly.Msg.DATA_INDEX_ALL, "all"],
172
+ ['1', '1'],
173
+ [Blockly.Msg.DATA_INDEX_LAST, 'last'],
174
+ [Blockly.Msg.DATA_INDEX_ALL, 'all'],
187
175
  ],
188
176
  },
189
177
  ],
190
- extensions: ["colours_textfield", "output_string"],
191
- });
178
+ extensions: ['colours_textfield', 'output_string'],
179
+ })
192
180
  },
193
- };
181
+ }
194
182
 
195
- Blockly.Blocks["data_listindexrandom"] = {
183
+ Blockly.Blocks.data_listindexrandom = {
196
184
  /**
197
185
  * List index menu, with random option.
198
186
  */
199
187
  init: function (this: Blockly.Block) {
200
188
  this.jsonInit({
201
- message0: "%1",
189
+ message0: '%1',
202
190
  args0: [
203
191
  {
204
- type: "field_numberdropdown",
205
- name: "INDEX",
206
- value: "1",
192
+ type: 'field_numberdropdown',
193
+ name: 'INDEX',
194
+ value: '1',
207
195
  min: 1,
208
196
  precision: 1,
209
197
  options: [
210
- ["1", "1"],
211
- [Blockly.Msg.DATA_INDEX_LAST, "last"],
212
- [Blockly.Msg.DATA_INDEX_RANDOM, "random"],
198
+ ['1', '1'],
199
+ [Blockly.Msg.DATA_INDEX_LAST, 'last'],
200
+ [Blockly.Msg.DATA_INDEX_RANDOM, 'random'],
213
201
  ],
214
202
  },
215
203
  ],
216
- extensions: ["colours_textfield", "output_string"],
217
- });
204
+ extensions: ['colours_textfield', 'output_string'],
205
+ })
218
206
  },
219
- };
207
+ }
220
208
 
221
- Blockly.Blocks["data_addtolist"] = {
209
+ Blockly.Blocks.data_addtolist = {
222
210
  /**
223
211
  * Block to add item to list.
224
212
  */
@@ -227,22 +215,22 @@ Blockly.Blocks["data_addtolist"] = {
227
215
  message0: Blockly.Msg.DATA_ADDTOLIST,
228
216
  args0: [
229
217
  {
230
- type: "input_value",
231
- name: "ITEM",
218
+ type: 'input_value',
219
+ name: 'ITEM',
232
220
  },
233
221
  {
234
- type: "field_variable",
235
- name: "LIST",
222
+ type: 'field_variable',
223
+ name: 'LIST',
236
224
  variableTypes: [Constants.LIST_VARIABLE_TYPE],
237
225
  defaultType: Constants.LIST_VARIABLE_TYPE,
238
226
  },
239
227
  ],
240
- extensions: ["colours_data_lists", "shape_statement"],
241
- });
228
+ extensions: ['colours_data_lists', 'shape_statement'],
229
+ })
242
230
  },
243
- };
231
+ }
244
232
 
245
- Blockly.Blocks["data_deleteoflist"] = {
233
+ Blockly.Blocks.data_deleteoflist = {
246
234
  /**
247
235
  * Block to delete item from list.
248
236
  */
@@ -251,22 +239,22 @@ Blockly.Blocks["data_deleteoflist"] = {
251
239
  message0: Blockly.Msg.DATA_DELETEOFLIST,
252
240
  args0: [
253
241
  {
254
- type: "input_value",
255
- name: "INDEX",
242
+ type: 'input_value',
243
+ name: 'INDEX',
256
244
  },
257
245
  {
258
- type: "field_variable",
259
- name: "LIST",
246
+ type: 'field_variable',
247
+ name: 'LIST',
260
248
  variableTypes: [Constants.LIST_VARIABLE_TYPE],
261
249
  defaultType: Constants.LIST_VARIABLE_TYPE,
262
250
  },
263
251
  ],
264
- extensions: ["colours_data_lists", "shape_statement"],
265
- });
252
+ extensions: ['colours_data_lists', 'shape_statement'],
253
+ })
266
254
  },
267
- };
255
+ }
268
256
 
269
- Blockly.Blocks["data_deletealloflist"] = {
257
+ Blockly.Blocks.data_deletealloflist = {
270
258
  /**
271
259
  * Block to delete all items from list.
272
260
  */
@@ -275,18 +263,18 @@ Blockly.Blocks["data_deletealloflist"] = {
275
263
  message0: Blockly.Msg.DATA_DELETEALLOFLIST,
276
264
  args0: [
277
265
  {
278
- type: "field_variable",
279
- name: "LIST",
266
+ type: 'field_variable',
267
+ name: 'LIST',
280
268
  variableTypes: [Constants.LIST_VARIABLE_TYPE],
281
269
  defaultType: Constants.LIST_VARIABLE_TYPE,
282
270
  },
283
271
  ],
284
- extensions: ["colours_data_lists", "shape_statement"],
285
- });
272
+ extensions: ['colours_data_lists', 'shape_statement'],
273
+ })
286
274
  },
287
- };
275
+ }
288
276
 
289
- Blockly.Blocks["data_insertatlist"] = {
277
+ Blockly.Blocks.data_insertatlist = {
290
278
  /**
291
279
  * Block to insert item to list.
292
280
  */
@@ -295,26 +283,26 @@ Blockly.Blocks["data_insertatlist"] = {
295
283
  message0: Blockly.Msg.DATA_INSERTATLIST,
296
284
  args0: [
297
285
  {
298
- type: "input_value",
299
- name: "ITEM",
286
+ type: 'input_value',
287
+ name: 'ITEM',
300
288
  },
301
289
  {
302
- type: "input_value",
303
- name: "INDEX",
290
+ type: 'input_value',
291
+ name: 'INDEX',
304
292
  },
305
293
  {
306
- type: "field_variable",
307
- name: "LIST",
294
+ type: 'field_variable',
295
+ name: 'LIST',
308
296
  variableTypes: [Constants.LIST_VARIABLE_TYPE],
309
297
  defaultType: Constants.LIST_VARIABLE_TYPE,
310
298
  },
311
299
  ],
312
- extensions: ["colours_data_lists", "shape_statement"],
313
- });
300
+ extensions: ['colours_data_lists', 'shape_statement'],
301
+ })
314
302
  },
315
- };
303
+ }
316
304
 
317
- Blockly.Blocks["data_replaceitemoflist"] = {
305
+ Blockly.Blocks.data_replaceitemoflist = {
318
306
  /**
319
307
  * Block to insert item to list.
320
308
  */
@@ -323,26 +311,26 @@ Blockly.Blocks["data_replaceitemoflist"] = {
323
311
  message0: Blockly.Msg.DATA_REPLACEITEMOFLIST,
324
312
  args0: [
325
313
  {
326
- type: "input_value",
327
- name: "INDEX",
314
+ type: 'input_value',
315
+ name: 'INDEX',
328
316
  },
329
317
  {
330
- type: "field_variable",
331
- name: "LIST",
318
+ type: 'field_variable',
319
+ name: 'LIST',
332
320
  variableTypes: [Constants.LIST_VARIABLE_TYPE],
333
321
  defaultType: Constants.LIST_VARIABLE_TYPE,
334
322
  },
335
323
  {
336
- type: "input_value",
337
- name: "ITEM",
324
+ type: 'input_value',
325
+ name: 'ITEM',
338
326
  },
339
327
  ],
340
- extensions: ["colours_data_lists", "shape_statement"],
341
- });
328
+ extensions: ['colours_data_lists', 'shape_statement'],
329
+ })
342
330
  },
343
- };
331
+ }
344
332
 
345
- Blockly.Blocks["data_itemoflist"] = {
333
+ Blockly.Blocks.data_itemoflist = {
346
334
  /**
347
335
  * Block for reporting item of list.
348
336
  */
@@ -351,24 +339,24 @@ Blockly.Blocks["data_itemoflist"] = {
351
339
  message0: Blockly.Msg.DATA_ITEMOFLIST,
352
340
  args0: [
353
341
  {
354
- type: "input_value",
355
- name: "INDEX",
342
+ type: 'input_value',
343
+ name: 'INDEX',
356
344
  },
357
345
  {
358
- type: "field_variable",
359
- name: "LIST",
346
+ type: 'field_variable',
347
+ name: 'LIST',
360
348
  variableTypes: [Constants.LIST_VARIABLE_TYPE],
361
349
  defaultType: Constants.LIST_VARIABLE_TYPE,
362
350
  },
363
351
  ],
364
352
  output: null,
365
- extensions: ["colours_data_lists"],
353
+ extensions: ['colours_data_lists'],
366
354
  outputShape: Constants.OUTPUT_SHAPE_ROUND,
367
- });
355
+ })
368
356
  },
369
- };
357
+ }
370
358
 
371
- Blockly.Blocks["data_itemnumoflist"] = {
359
+ Blockly.Blocks.data_itemnumoflist = {
372
360
  /**
373
361
  * Block for reporting the item # of a string in a list.
374
362
  */
@@ -377,24 +365,24 @@ Blockly.Blocks["data_itemnumoflist"] = {
377
365
  message0: Blockly.Msg.DATA_ITEMNUMOFLIST,
378
366
  args0: [
379
367
  {
380
- type: "input_value",
381
- name: "ITEM",
368
+ type: 'input_value',
369
+ name: 'ITEM',
382
370
  },
383
371
  {
384
- type: "field_variable",
385
- name: "LIST",
372
+ type: 'field_variable',
373
+ name: 'LIST',
386
374
  variableTypes: [Constants.LIST_VARIABLE_TYPE],
387
375
  defaultType: Constants.LIST_VARIABLE_TYPE,
388
376
  },
389
377
  ],
390
378
  output: null,
391
- extensions: ["colours_data_lists"],
379
+ extensions: ['colours_data_lists'],
392
380
  outputShape: Constants.OUTPUT_SHAPE_ROUND,
393
- });
381
+ })
394
382
  },
395
- };
383
+ }
396
384
 
397
- Blockly.Blocks["data_lengthoflist"] = {
385
+ Blockly.Blocks.data_lengthoflist = {
398
386
  /**
399
387
  * Block for reporting length of list.
400
388
  */
@@ -403,18 +391,18 @@ Blockly.Blocks["data_lengthoflist"] = {
403
391
  message0: Blockly.Msg.DATA_LENGTHOFLIST,
404
392
  args0: [
405
393
  {
406
- type: "field_variable",
407
- name: "LIST",
394
+ type: 'field_variable',
395
+ name: 'LIST',
408
396
  variableTypes: [Constants.LIST_VARIABLE_TYPE],
409
397
  defaultType: Constants.LIST_VARIABLE_TYPE,
410
398
  },
411
399
  ],
412
- extensions: ["colours_data_lists", "output_number"],
413
- });
400
+ extensions: ['colours_data_lists', 'output_number'],
401
+ })
414
402
  },
415
- };
403
+ }
416
404
 
417
- Blockly.Blocks["data_listcontainsitem"] = {
405
+ Blockly.Blocks.data_listcontainsitem = {
418
406
  /**
419
407
  * Block to report whether list contains item.
420
408
  */
@@ -423,22 +411,22 @@ Blockly.Blocks["data_listcontainsitem"] = {
423
411
  message0: Blockly.Msg.DATA_LISTCONTAINSITEM,
424
412
  args0: [
425
413
  {
426
- type: "field_variable",
427
- name: "LIST",
414
+ type: 'field_variable',
415
+ name: 'LIST',
428
416
  variableTypes: [Constants.LIST_VARIABLE_TYPE],
429
417
  defaultType: Constants.LIST_VARIABLE_TYPE,
430
418
  },
431
419
  {
432
- type: "input_value",
433
- name: "ITEM",
420
+ type: 'input_value',
421
+ name: 'ITEM',
434
422
  },
435
423
  ],
436
- extensions: ["colours_data_lists", "output_boolean"],
437
- });
424
+ extensions: ['colours_data_lists', 'output_boolean'],
425
+ })
438
426
  },
439
- };
427
+ }
440
428
 
441
- Blockly.Blocks["data_showlist"] = {
429
+ Blockly.Blocks.data_showlist = {
442
430
  /**
443
431
  * Block to show a list.
444
432
  */
@@ -447,18 +435,18 @@ Blockly.Blocks["data_showlist"] = {
447
435
  message0: Blockly.Msg.DATA_SHOWLIST,
448
436
  args0: [
449
437
  {
450
- type: "field_variable",
451
- name: "LIST",
438
+ type: 'field_variable',
439
+ name: 'LIST',
452
440
  variableTypes: [Constants.LIST_VARIABLE_TYPE],
453
441
  defaultType: Constants.LIST_VARIABLE_TYPE,
454
442
  },
455
443
  ],
456
- extensions: ["colours_data_lists", "shape_statement"],
457
- });
444
+ extensions: ['colours_data_lists', 'shape_statement'],
445
+ })
458
446
  },
459
- };
447
+ }
460
448
 
461
- Blockly.Blocks["data_hidelist"] = {
449
+ Blockly.Blocks.data_hidelist = {
462
450
  /**
463
451
  * Block to hide a list.
464
452
  */
@@ -467,16 +455,16 @@ Blockly.Blocks["data_hidelist"] = {
467
455
  message0: Blockly.Msg.DATA_HIDELIST,
468
456
  args0: [
469
457
  {
470
- type: "field_variable",
471
- name: "LIST",
458
+ type: 'field_variable',
459
+ name: 'LIST',
472
460
  variableTypes: [Constants.LIST_VARIABLE_TYPE],
473
461
  defaultType: Constants.LIST_VARIABLE_TYPE,
474
462
  },
475
463
  ],
476
- extensions: ["colours_data_lists", "shape_statement"],
477
- });
464
+ extensions: ['colours_data_lists', 'shape_statement'],
465
+ })
478
466
  },
479
- };
467
+ }
480
468
 
481
469
  /**
482
470
  * Mixin to add a context menu for a data_variable block. It adds one item for
@@ -485,76 +473,57 @@ Blockly.Blocks["data_hidelist"] = {
485
473
  const CUSTOM_CONTEXT_MENU_GET_VARIABLE_MIXIN = {
486
474
  /**
487
475
  * Add context menu option to change the selected variable.
488
- *
489
476
  * @param options List of menu options to add to.
490
477
  */
491
478
  customContextMenu: function (
492
479
  this: Blockly.Block,
493
- options: Array<
494
- | Blockly.ContextMenuRegistry.ContextMenuOption
495
- | Blockly.ContextMenuRegistry.LegacyContextMenuOption
496
- >
480
+ options: (Blockly.ContextMenuRegistry.ContextMenuOption | Blockly.ContextMenuRegistry.LegacyContextMenuOption)[],
497
481
  ) {
498
- const fieldName = "VARIABLE";
482
+ const fieldName = 'VARIABLE'
499
483
  if (this.isCollapsed()) {
500
- return;
484
+ return
501
485
  }
502
- const currentVariable = (this.getField(fieldName) as ScratchFieldVariable)
503
- .getVariable();
486
+ const currentVariable = (this.getField(fieldName) as ScratchFieldVariable).getVariable()
504
487
  if (!currentVariable) {
505
- console.warn(
506
- "contextMenu_getVariableBlock: no variable found for field",
507
- fieldName,
508
- "on block",
509
- this.type
510
- );
511
- return;
488
+ console.warn('contextMenu_getVariableBlock: no variable found for field', fieldName, 'on block', this.type)
489
+ return
512
490
  }
513
- const currentVarName = currentVariable.getName();
491
+ const currentVarName = currentVariable.getName()
514
492
  if (!this.isInFlyout) {
515
493
  this.workspace
516
494
  .getVariablesOfType(Constants.SCALAR_VARIABLE_TYPE)
517
- .sort(function (
518
- a: Blockly.IVariableModel<Blockly.IVariableState>,
519
- b: Blockly.IVariableModel<Blockly.IVariableState>
520
- ) {
521
- return scratchBlocksUtils.compareStrings(a.getName(), b.getName());
522
- })
495
+ .sort(
496
+ (a: Blockly.IVariableModel<Blockly.IVariableState>, b: Blockly.IVariableModel<Blockly.IVariableState>) =>
497
+ scratchBlocksUtils.compareStrings(a.getName(), b.getName()),
498
+ )
523
499
  .forEach((variable: Blockly.IVariableModel<Blockly.IVariableState>) => {
524
- const varName = variable.getName();
525
- if (varName === currentVarName) return;
500
+ const varName = variable.getName()
501
+ if (varName === currentVarName) return
526
502
 
527
503
  options.push({
528
504
  enabled: true,
529
505
  text: varName,
530
- callback: VARIABLE_OPTION_CALLBACK_FACTORY(
531
- this,
532
- variable.getId(),
533
- fieldName
534
- ),
535
- });
536
- });
506
+ callback: VARIABLE_OPTION_CALLBACK_FACTORY(this, variable.getId(), fieldName),
507
+ })
508
+ })
537
509
  } else {
538
510
  const renameOption = {
539
511
  text: Blockly.Msg.RENAME_VARIABLE,
540
512
  enabled: true,
541
513
  callback: RENAME_OPTION_CALLBACK_FACTORY(this, fieldName),
542
- };
514
+ }
543
515
  const deleteOption = {
544
- text: Blockly.Msg.DELETE_VARIABLE.replace("%1", currentVarName),
516
+ text: Blockly.Msg.DELETE_VARIABLE.replace('%1', currentVarName),
545
517
  enabled: true,
546
518
  callback: DELETE_OPTION_CALLBACK_FACTORY(this, fieldName),
547
- };
548
- options.push(renameOption);
549
- options.push(deleteOption);
519
+ }
520
+ options.push(renameOption)
521
+ options.push(deleteOption)
550
522
  }
551
523
  },
552
- };
524
+ }
553
525
 
554
- Blockly.Extensions.registerMixin(
555
- "contextMenu_getVariableBlock",
556
- CUSTOM_CONTEXT_MENU_GET_VARIABLE_MIXIN
557
- );
526
+ Blockly.Extensions.registerMixin('contextMenu_getVariableBlock', CUSTOM_CONTEXT_MENU_GET_VARIABLE_MIXIN)
558
527
 
559
528
  /**
560
529
  * Mixin to add a context menu for a data_listcontents block. It adds one item for
@@ -563,148 +532,112 @@ Blockly.Extensions.registerMixin(
563
532
  const CUSTOM_CONTEXT_MENU_GET_LIST_MIXIN = {
564
533
  /**
565
534
  * Add context menu option to change the selected list.
566
- *
567
535
  * @param options List of menu options to add to.
568
536
  */
569
537
  customContextMenu: function (
570
538
  this: Blockly.Block,
571
- options: Array<
572
- | Blockly.ContextMenuRegistry.ContextMenuOption
573
- | Blockly.ContextMenuRegistry.LegacyContextMenuOption
574
- >
539
+ options: (Blockly.ContextMenuRegistry.ContextMenuOption | Blockly.ContextMenuRegistry.LegacyContextMenuOption)[],
575
540
  ) {
576
- const fieldName = "LIST";
541
+ const fieldName = 'LIST'
577
542
  if (this.isCollapsed()) {
578
- return;
543
+ return
579
544
  }
580
- const currentVariable = (this.getField(fieldName) as ScratchFieldVariable)
581
- .getVariable();
545
+ const currentVariable = (this.getField(fieldName) as ScratchFieldVariable).getVariable()
582
546
  if (!currentVariable) {
583
- console.warn(
584
- "contextMenu_getListBlock: no list variable found for field",
585
- fieldName,
586
- "on block",
587
- this.type
588
- );
589
- return;
547
+ console.warn('contextMenu_getListBlock: no list variable found for field', fieldName, 'on block', this.type)
548
+ return
590
549
  }
591
- const currentVarName = currentVariable.getName();
550
+ const currentVarName = currentVariable.getName()
592
551
  if (!this.isInFlyout) {
593
552
  this.workspace
594
553
  .getVariablesOfType(Constants.LIST_VARIABLE_TYPE)
595
- .sort(function (
596
- a: Blockly.IVariableModel<Blockly.IVariableState>,
597
- b: Blockly.IVariableModel<Blockly.IVariableState>
598
- ) {
599
- return scratchBlocksUtils.compareStrings(a.getName(), b.getName());
600
- })
554
+ .sort(
555
+ (a: Blockly.IVariableModel<Blockly.IVariableState>, b: Blockly.IVariableModel<Blockly.IVariableState>) =>
556
+ scratchBlocksUtils.compareStrings(a.getName(), b.getName()),
557
+ )
601
558
  .forEach((variable: Blockly.IVariableModel<Blockly.IVariableState>) => {
602
- const varName = variable.getName();
603
- if (varName === currentVarName) return;
559
+ const varName = variable.getName()
560
+ if (varName === currentVarName) return
604
561
 
605
562
  options.push({
606
563
  enabled: true,
607
564
  text: varName,
608
- callback: VARIABLE_OPTION_CALLBACK_FACTORY(
609
- this,
610
- variable.getId(),
611
- fieldName
612
- ),
613
- });
614
- });
565
+ callback: VARIABLE_OPTION_CALLBACK_FACTORY(this, variable.getId(), fieldName),
566
+ })
567
+ })
615
568
  } else {
616
569
  const renameOption = {
617
570
  text: Blockly.Msg.RENAME_LIST,
618
571
  enabled: true,
619
572
  callback: RENAME_OPTION_CALLBACK_FACTORY(this, fieldName),
620
- };
573
+ }
621
574
  const deleteOption = {
622
- text: Blockly.Msg.DELETE_LIST.replace("%1", currentVarName),
575
+ text: Blockly.Msg.DELETE_LIST.replace('%1', currentVarName),
623
576
  enabled: true,
624
577
  callback: DELETE_OPTION_CALLBACK_FACTORY(this, fieldName),
625
- };
626
- options.push(renameOption);
627
- options.push(deleteOption);
578
+ }
579
+ options.push(renameOption)
580
+ options.push(deleteOption)
628
581
  }
629
582
  },
630
- };
631
- Blockly.Extensions.registerMixin(
632
- "contextMenu_getListBlock",
633
- CUSTOM_CONTEXT_MENU_GET_LIST_MIXIN
634
- );
583
+ }
584
+ Blockly.Extensions.registerMixin('contextMenu_getListBlock', CUSTOM_CONTEXT_MENU_GET_LIST_MIXIN)
635
585
 
636
586
  /**
637
587
  * Callback factory for dropdown menu options associated with a variable getter
638
588
  * block. Each variable on the workspace gets its own item in the dropdown
639
589
  * menu, and clicking on that item changes the text of the field on the source
640
590
  * block.
641
- *
642
591
  * @param block The block to update.
643
592
  * @param id The id of the variable to set on this block.
644
593
  * @param fieldName The name of the field to update on the block.
645
594
  * @returns A function that updates the block with the new name.
646
595
  */
647
- const VARIABLE_OPTION_CALLBACK_FACTORY = function (
648
- block: Blockly.Block,
649
- id: string,
650
- fieldName: string
651
- ): () => void {
596
+ const VARIABLE_OPTION_CALLBACK_FACTORY = function (block: Blockly.Block, id: string, fieldName: string): () => void {
652
597
  return () => {
653
- const variableField = block.getField(fieldName);
598
+ const variableField = block.getField(fieldName)
654
599
  if (!variableField) {
655
- console.log("Tried to get a variable field on the wrong type of block.");
656
- return;
600
+ console.log('Tried to get a variable field on the wrong type of block.')
601
+ return
657
602
  }
658
- variableField.setValue(id);
659
- };
660
- };
603
+ variableField.setValue(id)
604
+ }
605
+ }
661
606
 
662
607
  /**
663
608
  * Callback for rename variable dropdown menu option associated with a
664
609
  * variable getter block.
665
- *
666
610
  * @param block The block with the variable to rename.
667
611
  * @param fieldName The name of the field to inspect on the block.
668
612
  * @returns A function that renames the variable.
669
613
  */
670
- const RENAME_OPTION_CALLBACK_FACTORY = function (
671
- block: Blockly.Block,
672
- fieldName: string
673
- ): () => void {
614
+ const RENAME_OPTION_CALLBACK_FACTORY = function (block: Blockly.Block, fieldName: string): () => void {
674
615
  return () => {
675
- const workspace = block.workspace;
676
- const variable = (
677
- block.getField(fieldName) as ScratchFieldVariable
678
- ).getVariable() as ScratchVariableModel;
679
- renameVariable(workspace as Blockly.WorkspaceSvg, variable);
680
- };
681
- };
616
+ const workspace = block.workspace
617
+ const variable = (block.getField(fieldName) as ScratchFieldVariable).getVariable() as ScratchVariableModel
618
+ renameVariable(workspace as Blockly.WorkspaceSvg, variable)
619
+ }
620
+ }
682
621
 
683
622
  /**
684
623
  * Callback for delete variable dropdown menu option associated with a
685
624
  * variable getter block.
686
- *
687
625
  * @param block The block with the variable to delete.
688
626
  * @param fieldName The name of the field to inspect on the block.
689
- * @return A function that deletes the variable.
627
+ * @returns A function that deletes the variable.
690
628
  */
691
- const DELETE_OPTION_CALLBACK_FACTORY = function (
692
- block: Blockly.Block,
693
- fieldName: string
694
- ): () => void {
629
+ const DELETE_OPTION_CALLBACK_FACTORY = function (block: Blockly.Block, fieldName: string): () => void {
695
630
  return () => {
696
- const variable = (
697
- block.getField(fieldName) as ScratchFieldVariable
698
- ).getVariable();
631
+ const variable = (block.getField(fieldName) as ScratchFieldVariable).getVariable()
699
632
  if (!variable) {
700
633
  console.warn(
701
- "DELETE_OPTION_CALLBACK_FACTORY: no variable to delete for field",
634
+ 'DELETE_OPTION_CALLBACK_FACTORY: no variable to delete for field',
702
635
  fieldName,
703
- "on block",
704
- block.type
705
- );
706
- return;
636
+ 'on block',
637
+ block.type,
638
+ )
639
+ return
707
640
  }
708
- Blockly.Variables.deleteVariable(variable.getWorkspace(), variable, block);
709
- };
710
- };
641
+ Blockly.Variables.deleteVariable(variable.getWorkspace(), variable, block)
642
+ }
643
+ }