scratch-blocks 2.0.2 → 2.0.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 (274) hide show
  1. package/commitlint.config.js +2 -2
  2. package/dist/main.mjs +1 -2
  3. package/dist/types/msg/scratch_msgs.d.ts.map +1 -1
  4. package/dist/types/src/block_reporting.d.ts.map +1 -1
  5. package/dist/types/src/blocks/colour.d.ts +0 -19
  6. package/dist/types/src/blocks/colour.d.ts.map +1 -1
  7. package/dist/types/src/blocks/control.d.ts +0 -19
  8. package/dist/types/src/blocks/control.d.ts.map +1 -1
  9. package/dist/types/src/blocks/data.d.ts +0 -19
  10. package/dist/types/src/blocks/data.d.ts.map +1 -1
  11. package/dist/types/src/blocks/event.d.ts +0 -19
  12. package/dist/types/src/blocks/event.d.ts.map +1 -1
  13. package/dist/types/src/blocks/looks.d.ts +0 -19
  14. package/dist/types/src/blocks/looks.d.ts.map +1 -1
  15. package/dist/types/src/blocks/math.d.ts +0 -19
  16. package/dist/types/src/blocks/math.d.ts.map +1 -1
  17. package/dist/types/src/blocks/matrix.d.ts +0 -19
  18. package/dist/types/src/blocks/matrix.d.ts.map +1 -1
  19. package/dist/types/src/blocks/motion.d.ts +0 -19
  20. package/dist/types/src/blocks/motion.d.ts.map +1 -1
  21. package/dist/types/src/blocks/note.d.ts +0 -19
  22. package/dist/types/src/blocks/note.d.ts.map +1 -1
  23. package/dist/types/src/blocks/operators.d.ts +0 -19
  24. package/dist/types/src/blocks/operators.d.ts.map +1 -1
  25. package/dist/types/src/blocks/procedures.d.ts +6 -9
  26. package/dist/types/src/blocks/procedures.d.ts.map +1 -1
  27. package/dist/types/src/blocks/sensing.d.ts +0 -19
  28. package/dist/types/src/blocks/sensing.d.ts.map +1 -1
  29. package/dist/types/src/blocks/sound.d.ts +0 -19
  30. package/dist/types/src/blocks/sound.d.ts.map +1 -1
  31. package/dist/types/src/blocks/text.d.ts +0 -19
  32. package/dist/types/src/blocks/text.d.ts.map +1 -1
  33. package/dist/types/src/blocks/vertical_extensions.d.ts +0 -19
  34. package/dist/types/src/blocks/vertical_extensions.d.ts.map +1 -1
  35. package/dist/types/src/checkable_continuous_flyout.d.ts +2 -7
  36. package/dist/types/src/checkable_continuous_flyout.d.ts.map +1 -1
  37. package/dist/types/src/checkbox_bubble.d.ts +13 -12
  38. package/dist/types/src/checkbox_bubble.d.ts.map +1 -1
  39. package/dist/types/src/colours.d.ts.map +1 -1
  40. package/dist/types/src/constants.d.ts +0 -7
  41. package/dist/types/src/constants.d.ts.map +1 -1
  42. package/dist/types/src/context_menu_items.d.ts +0 -5
  43. package/dist/types/src/context_menu_items.d.ts.map +1 -1
  44. package/dist/types/src/data_category.d.ts +2 -4
  45. package/dist/types/src/data_category.d.ts.map +1 -1
  46. package/dist/types/src/events/events_block_comment_base.d.ts +2 -3
  47. package/dist/types/src/events/events_block_comment_base.d.ts.map +1 -1
  48. package/dist/types/src/events/events_block_comment_change.d.ts +0 -5
  49. package/dist/types/src/events/events_block_comment_change.d.ts.map +1 -1
  50. package/dist/types/src/events/events_block_comment_collapse.d.ts +0 -5
  51. package/dist/types/src/events/events_block_comment_collapse.d.ts.map +1 -1
  52. package/dist/types/src/events/events_block_comment_create.d.ts +0 -5
  53. package/dist/types/src/events/events_block_comment_create.d.ts.map +1 -1
  54. package/dist/types/src/events/events_block_comment_delete.d.ts +0 -5
  55. package/dist/types/src/events/events_block_comment_delete.d.ts.map +1 -1
  56. package/dist/types/src/events/events_block_comment_move.d.ts +0 -5
  57. package/dist/types/src/events/events_block_comment_move.d.ts.map +1 -1
  58. package/dist/types/src/events/events_block_comment_resize.d.ts +0 -5
  59. package/dist/types/src/events/events_block_comment_resize.d.ts.map +1 -1
  60. package/dist/types/src/events/events_block_drag_end.d.ts +1 -2
  61. package/dist/types/src/events/events_block_drag_end.d.ts.map +1 -1
  62. package/dist/types/src/events/events_block_drag_outside.d.ts +1 -2
  63. package/dist/types/src/events/events_block_drag_outside.d.ts.map +1 -1
  64. package/dist/types/src/events/events_scratch_variable_create.d.ts +0 -5
  65. package/dist/types/src/events/events_scratch_variable_create.d.ts.map +1 -1
  66. package/dist/types/src/fields/field_colour_slider.d.ts +3 -27
  67. package/dist/types/src/fields/field_colour_slider.d.ts.map +1 -1
  68. package/dist/types/src/fields/field_matrix.d.ts +0 -19
  69. package/dist/types/src/fields/field_matrix.d.ts.map +1 -1
  70. package/dist/types/src/fields/field_note.d.ts +8 -23
  71. package/dist/types/src/fields/field_note.d.ts.map +1 -1
  72. package/dist/types/src/fields/field_textinput_removable.d.ts +2 -4
  73. package/dist/types/src/fields/field_textinput_removable.d.ts.map +1 -1
  74. package/dist/types/src/fields/field_variable_getter.d.ts +0 -19
  75. package/dist/types/src/fields/field_variable_getter.d.ts.map +1 -1
  76. package/dist/types/src/fields/field_vertical_separator.d.ts +0 -19
  77. package/dist/types/src/fields/field_vertical_separator.d.ts.map +1 -1
  78. package/dist/types/src/fields/scratch_field_angle.d.ts +0 -19
  79. package/dist/types/src/fields/scratch_field_angle.d.ts.map +1 -1
  80. package/dist/types/src/fields/scratch_field_dropdown.d.ts +0 -5
  81. package/dist/types/src/fields/scratch_field_dropdown.d.ts.map +1 -1
  82. package/dist/types/src/fields/scratch_field_number.d.ts +0 -19
  83. package/dist/types/src/fields/scratch_field_number.d.ts.map +1 -1
  84. package/dist/types/src/fields/scratch_field_variable.d.ts +4 -7
  85. package/dist/types/src/fields/scratch_field_variable.d.ts.map +1 -1
  86. package/dist/types/src/flyout_checkbox_icon.d.ts +2 -3
  87. package/dist/types/src/flyout_checkbox_icon.d.ts.map +1 -1
  88. package/dist/types/src/glows.d.ts +1 -3
  89. package/dist/types/src/glows.d.ts.map +1 -1
  90. package/dist/types/src/index.d.ts +50 -51
  91. package/dist/types/src/index.d.ts.map +1 -1
  92. package/dist/types/src/procedures.d.ts +6 -8
  93. package/dist/types/src/procedures.d.ts.map +1 -1
  94. package/dist/types/src/recyclable_block_flyout_inflater.d.ts +3 -5
  95. package/dist/types/src/recyclable_block_flyout_inflater.d.ts.map +1 -1
  96. package/dist/types/src/renderer/bowler_hat.d.ts +2 -3
  97. package/dist/types/src/renderer/bowler_hat.d.ts.map +1 -1
  98. package/dist/types/src/renderer/cat/cat_face.d.ts +6 -5
  99. package/dist/types/src/renderer/cat/cat_face.d.ts.map +1 -1
  100. package/dist/types/src/renderer/cat/constants.d.ts +2 -2
  101. package/dist/types/src/renderer/cat/constants.d.ts.map +1 -1
  102. package/dist/types/src/renderer/cat/drawer.d.ts +3 -4
  103. package/dist/types/src/renderer/cat/drawer.d.ts.map +1 -1
  104. package/dist/types/src/renderer/cat/path_object.d.ts +2 -3
  105. package/dist/types/src/renderer/cat/path_object.d.ts.map +1 -1
  106. package/dist/types/src/renderer/cat/render_info.d.ts +3 -4
  107. package/dist/types/src/renderer/cat/render_info.d.ts.map +1 -1
  108. package/dist/types/src/renderer/cat/renderer.d.ts +6 -7
  109. package/dist/types/src/renderer/cat/renderer.d.ts.map +1 -1
  110. package/dist/types/src/renderer/constants.d.ts +4 -4
  111. package/dist/types/src/renderer/constants.d.ts.map +1 -1
  112. package/dist/types/src/renderer/drawer.d.ts +5 -4
  113. package/dist/types/src/renderer/drawer.d.ts.map +1 -1
  114. package/dist/types/src/renderer/path_object.d.ts +1 -3
  115. package/dist/types/src/renderer/path_object.d.ts.map +1 -1
  116. package/dist/types/src/renderer/render_info.d.ts +3 -4
  117. package/dist/types/src/renderer/render_info.d.ts.map +1 -1
  118. package/dist/types/src/renderer/renderer.d.ts +8 -15
  119. package/dist/types/src/renderer/renderer.d.ts.map +1 -1
  120. package/dist/types/src/scratch_block_paster.d.ts +0 -5
  121. package/dist/types/src/scratch_block_paster.d.ts.map +1 -1
  122. package/dist/types/src/scratch_blocks_utils.d.ts +0 -20
  123. package/dist/types/src/scratch_blocks_utils.d.ts.map +1 -1
  124. package/dist/types/src/scratch_comment_bubble.d.ts +1 -4
  125. package/dist/types/src/scratch_comment_bubble.d.ts.map +1 -1
  126. package/dist/types/src/scratch_comment_icon.d.ts +2 -3
  127. package/dist/types/src/scratch_comment_icon.d.ts.map +1 -1
  128. package/dist/types/src/scratch_connection_checker.d.ts +0 -5
  129. package/dist/types/src/scratch_connection_checker.d.ts.map +1 -1
  130. package/dist/types/src/scratch_continuous_category.d.ts +5 -5
  131. package/dist/types/src/scratch_continuous_category.d.ts.map +1 -1
  132. package/dist/types/src/scratch_continuous_toolbox.d.ts +3 -6
  133. package/dist/types/src/scratch_continuous_toolbox.d.ts.map +1 -1
  134. package/dist/types/src/scratch_dragger.d.ts +1 -10
  135. package/dist/types/src/scratch_dragger.d.ts.map +1 -1
  136. package/dist/types/src/scratch_insertion_marker_previewer.d.ts +0 -5
  137. package/dist/types/src/scratch_insertion_marker_previewer.d.ts.map +1 -1
  138. package/dist/types/src/scratch_variable_map.d.ts +0 -5
  139. package/dist/types/src/scratch_variable_map.d.ts.map +1 -1
  140. package/dist/types/src/scratch_variable_model.d.ts +1 -2
  141. package/dist/types/src/scratch_variable_model.d.ts.map +1 -1
  142. package/dist/types/src/scratch_zoom_controls.d.ts +4 -6
  143. package/dist/types/src/scratch_zoom_controls.d.ts.map +1 -1
  144. package/dist/types/src/shadows.d.ts +2 -2
  145. package/dist/types/src/shadows.d.ts.map +1 -1
  146. package/dist/types/src/status_indicator_label.d.ts +4 -6
  147. package/dist/types/src/status_indicator_label.d.ts.map +1 -1
  148. package/dist/types/src/status_indicator_label_flyout_inflater.d.ts +1 -6
  149. package/dist/types/src/status_indicator_label_flyout_inflater.d.ts.map +1 -1
  150. package/dist/types/src/variables.d.ts +4 -8
  151. package/dist/types/src/variables.d.ts.map +1 -1
  152. package/dist/types/src/xml.d.ts +2 -3
  153. package/dist/types/src/xml.d.ts.map +1 -1
  154. package/dist/types/tests/jsunit/block_test.d.ts.map +1 -1
  155. package/dist/types/tests/jsunit/connection_db_test.d.ts.map +1 -1
  156. package/dist/types/tests/jsunit/connection_test.d.ts.map +1 -1
  157. package/dist/types/tests/jsunit/event_test.d.ts.map +1 -1
  158. package/dist/types/tests/jsunit/extensions_test.d.ts.map +1 -1
  159. package/dist/types/tests/jsunit/field_number_test.d.ts.map +1 -1
  160. package/dist/types/tests/jsunit/field_test.d.ts.map +1 -1
  161. package/dist/types/tests/jsunit/field_variable_getter_test.d.ts.map +1 -1
  162. package/dist/types/tests/jsunit/field_variable_test.d.ts.map +1 -1
  163. package/dist/types/tests/jsunit/gesture_test.d.ts.map +1 -1
  164. package/dist/types/tests/jsunit/input_test.d.ts +1 -0
  165. package/dist/types/tests/jsunit/input_test.d.ts.map +1 -1
  166. package/dist/types/tests/jsunit/json_test.d.ts.map +1 -1
  167. package/dist/types/tests/jsunit/names_test.d.ts.map +1 -1
  168. package/dist/types/tests/jsunit/procedure_test.d.ts.map +1 -1
  169. package/dist/types/tests/jsunit/scratch_block_comment_test.d.ts.map +1 -1
  170. package/dist/types/tests/jsunit/svg_test.d.ts.map +1 -1
  171. package/dist/types/tests/jsunit/test_utilities.d.ts.map +1 -1
  172. package/dist/types/tests/jsunit/utils_test.d.ts.map +1 -1
  173. package/dist/types/tests/jsunit/variable_map_test.d.ts.map +1 -1
  174. package/dist/types/tests/jsunit/variable_model_test.d.ts.map +1 -1
  175. package/dist/types/tests/jsunit/widget_div_test.d.ts.map +1 -1
  176. package/dist/types/tests/jsunit/workspace_comment_test.d.ts.map +1 -1
  177. package/dist/types/tests/jsunit/workspace_test.d.ts.map +1 -1
  178. package/dist/types/tests/jsunit/workspace_undo_redo_test.d.ts.map +1 -1
  179. package/dist/types/tests/jsunit/xml_test.d.ts.map +1 -1
  180. package/dist/types/tests/workspace_svg/workspace_svg_test.d.ts.map +1 -1
  181. package/eslint.config.mjs +69 -0
  182. package/i18n/create_scratch_msgs.js +44 -45
  183. package/i18n/js_to_json.js +40 -32
  184. package/i18n/json_to_js.js +37 -37
  185. package/i18n/sync_tx_translations.js +64 -65
  186. package/i18n/test_scratch_msgs.js +66 -63
  187. package/msg/js/en.js +289 -287
  188. package/msg/json/en.json +284 -284
  189. package/msg/messages.js +289 -287
  190. package/msg/scratch_msgs.js +22959 -22970
  191. package/package.json +6 -3
  192. package/prettier.config.mjs +3 -0
  193. package/release.config.js +7 -7
  194. package/renovate.json5 +7 -9
  195. package/src/block_reporting.ts +15 -18
  196. package/src/blocks/colour.ts +12 -15
  197. package/src/blocks/control.ts +167 -177
  198. package/src/blocks/data.ts +225 -292
  199. package/src/blocks/event.ts +121 -123
  200. package/src/blocks/looks.ts +165 -167
  201. package/src/blocks/math.ts +44 -46
  202. package/src/blocks/matrix.ts +11 -13
  203. package/src/blocks/motion.ts +151 -153
  204. package/src/blocks/note.ts +11 -13
  205. package/src/blocks/operators.ts +158 -160
  206. package/src/blocks/procedures.ts +415 -523
  207. package/src/blocks/sensing.ts +163 -165
  208. package/src/blocks/sound.ts +58 -60
  209. package/src/blocks/text.ts +10 -12
  210. package/src/blocks/vertical_extensions.ts +86 -102
  211. package/src/checkable_continuous_flyout.ts +25 -42
  212. package/src/checkbox_bubble.ts +83 -100
  213. package/src/colours.ts +35 -37
  214. package/src/constants.ts +22 -29
  215. package/src/context_menu_items.ts +56 -81
  216. package/src/css.ts +3 -4
  217. package/src/data_category.ts +137 -251
  218. package/src/events/events_block_comment_base.ts +21 -31
  219. package/src/events/events_block_comment_change.ts +21 -42
  220. package/src/events/events_block_comment_collapse.ts +22 -43
  221. package/src/events/events_block_comment_create.ts +29 -46
  222. package/src/events/events_block_comment_delete.ts +10 -19
  223. package/src/events/events_block_comment_move.ts +27 -52
  224. package/src/events/events_block_comment_resize.ts +28 -55
  225. package/src/events/events_block_drag_end.ts +16 -26
  226. package/src/events/events_block_drag_outside.ts +12 -22
  227. package/src/events/events_scratch_variable_create.ts +33 -56
  228. package/src/fields/field_colour_slider.ts +173 -228
  229. package/src/fields/field_matrix.ts +200 -269
  230. package/src/fields/field_note.ts +272 -377
  231. package/src/fields/field_textinput_removable.ts +25 -40
  232. package/src/fields/field_variable_getter.ts +26 -31
  233. package/src/fields/field_vertical_separator.ts +19 -24
  234. package/src/fields/scratch_field_angle.ts +150 -186
  235. package/src/fields/scratch_field_dropdown.ts +15 -19
  236. package/src/fields/scratch_field_number.ts +123 -180
  237. package/src/fields/scratch_field_variable.ts +54 -75
  238. package/src/flyout_checkbox_icon.ts +18 -28
  239. package/src/glows.ts +51 -58
  240. package/src/index.ts +119 -133
  241. package/src/procedures.ts +146 -213
  242. package/src/recyclable_block_flyout_inflater.ts +14 -25
  243. package/src/renderer/bowler_hat.ts +6 -8
  244. package/src/renderer/cat/cat_face.ts +98 -99
  245. package/src/renderer/cat/constants.ts +67 -87
  246. package/src/renderer/cat/drawer.ts +21 -27
  247. package/src/renderer/cat/path_object.ts +3 -5
  248. package/src/renderer/cat/render_info.ts +5 -8
  249. package/src/renderer/cat/renderer.ts +11 -15
  250. package/src/renderer/constants.ts +34 -49
  251. package/src/renderer/drawer.ts +35 -51
  252. package/src/renderer/path_object.ts +4 -10
  253. package/src/renderer/render_info.ts +36 -56
  254. package/src/renderer/renderer.ts +16 -29
  255. package/src/scratch_block_paster.ts +12 -20
  256. package/src/scratch_blocks_utils.ts +4 -7
  257. package/src/scratch_comment_bubble.ts +70 -101
  258. package/src/scratch_comment_icon.ts +74 -123
  259. package/src/scratch_connection_checker.ts +7 -17
  260. package/src/scratch_continuous_category.ts +24 -28
  261. package/src/scratch_continuous_toolbox.ts +20 -27
  262. package/src/scratch_dragger.ts +42 -81
  263. package/src/scratch_insertion_marker_previewer.ts +6 -11
  264. package/src/scratch_variable_map.ts +5 -12
  265. package/src/scratch_variable_model.ts +4 -11
  266. package/src/scratch_zoom_controls.ts +101 -156
  267. package/src/shadows.ts +32 -37
  268. package/src/status_indicator_label.ts +54 -67
  269. package/src/status_indicator_label_flyout_inflater.ts +11 -21
  270. package/src/variables.ts +89 -138
  271. package/src/xml.ts +21 -35
  272. package/tsconfig.json +2 -6
  273. package/types/continuous-toolbox.d.ts +1 -1
  274. package/dist/main.mjs.LICENSE.txt +0 -163
@@ -1,10 +1,8 @@
1
1
  /**
2
- * @license
3
2
  * Copyright 2024 Google LLC
4
3
  * SPDX-License-Identifier: Apache-2.0
5
4
  */
6
-
7
- import * as Blockly from "blockly/core";
5
+ import * as Blockly from 'blockly/core'
8
6
 
9
7
  /**
10
8
  * Custom connection checker to restrict which blocks can be connected.
@@ -12,27 +10,19 @@ import * as Blockly from "blockly/core";
12
10
  class ScratchConnectionChecker extends Blockly.ConnectionChecker {
13
11
  /**
14
12
  * Returns whether or not the two connections should be allowed to connect.
15
- *
16
13
  * @param a One of the connections to check.
17
14
  * @param b The other connection to check.
18
15
  * @param distance The maximum allowable distance between connections.
19
16
  * @returns True if the connections should be allowed to connect.
20
17
  */
21
- doDragChecks(
22
- a: Blockly.RenderedConnection,
23
- b: Blockly.RenderedConnection,
24
- distance: number
25
- ): boolean {
18
+ doDragChecks(a: Blockly.RenderedConnection, b: Blockly.RenderedConnection, distance: number): boolean {
26
19
  // This check prevents dragging a block into the slot occupied by the
27
20
  // procedure caller example block in a procedure definition block.
28
- if (
29
- b.getSourceBlock().type === "procedures_definition" &&
30
- b.getParentInput()?.name === "custom_block"
31
- ) {
32
- return false;
21
+ if (b.getSourceBlock().type === 'procedures_definition' && b.getParentInput()?.name === 'custom_block') {
22
+ return false
33
23
  }
34
24
 
35
- return super.doDragChecks(a, b, distance);
25
+ return super.doDragChecks(a, b, distance)
36
26
  }
37
27
  }
38
28
 
@@ -40,5 +30,5 @@ Blockly.registry.register(
40
30
  Blockly.registry.Type.CONNECTION_CHECKER,
41
31
  Blockly.registry.DEFAULT,
42
32
  ScratchConnectionChecker,
43
- true
44
- );
33
+ true,
34
+ )
@@ -1,15 +1,13 @@
1
1
  /**
2
- * @license
3
2
  * Copyright 2024 Google LLC
4
3
  * SPDX-License-Identifier: Apache-2.0
5
4
  */
6
-
7
- import * as Blockly from "blockly/core";
8
- import { ContinuousCategory } from "@blockly/continuous-toolbox";
5
+ import * as Blockly from 'blockly/core'
6
+ import { ContinuousCategory } from '@blockly/continuous-toolbox'
9
7
 
10
8
  type StatusIndicatorCategoryInfo = Blockly.utils.toolbox.CategoryInfo & {
11
- showStatusButton?: string;
12
- };
9
+ showStatusButton?: string
10
+ }
13
11
 
14
12
  /**
15
13
  * Selectable category shown in the Scratch toolbox.
@@ -20,10 +18,10 @@ export class ScratchContinuousCategory extends ContinuousCategory {
20
18
  * in the flyout, typically for extensions that interface with hardware
21
19
  * devices.
22
20
  */
23
- private showStatusButton = false;
21
+ private showStatusButton = false
24
22
 
25
- /** Creates a new ScratchContinuousCategory.
26
- *
23
+ /**
24
+ * Creates a new ScratchContinuousCategory.
27
25
  * @param toolboxItemDef A toolbox item definition.
28
26
  * @param parentToolbox The toolbox this category is being added to.
29
27
  * @param opt_parent The parent toolbox category, if any.
@@ -31,10 +29,10 @@ export class ScratchContinuousCategory extends ContinuousCategory {
31
29
  constructor(
32
30
  toolboxItemDef: StatusIndicatorCategoryInfo,
33
31
  parentToolbox: Blockly.Toolbox,
34
- opt_parent?: Blockly.ICollapsibleToolboxItem
32
+ opt_parent?: Blockly.ICollapsibleToolboxItem,
35
33
  ) {
36
- super(toolboxItemDef, parentToolbox, opt_parent);
37
- this.showStatusButton = toolboxItemDef["showStatusButton"] === "true";
34
+ super(toolboxItemDef, parentToolbox, opt_parent)
35
+ this.showStatusButton = toolboxItemDef.showStatusButton === 'true'
38
36
  }
39
37
 
40
38
  /**
@@ -43,14 +41,14 @@ export class ScratchContinuousCategory extends ContinuousCategory {
43
41
  */
44
42
  createIconDom_(): HTMLElement {
45
43
  if (this.toolboxItemDef_.iconURI) {
46
- const icon = document.createElement("img");
47
- icon.src = this.toolboxItemDef_.iconURI;
48
- icon.className = "categoryIconBubble";
49
- return icon;
44
+ const icon = document.createElement('img')
45
+ icon.src = this.toolboxItemDef_.iconURI
46
+ icon.className = 'categoryIconBubble'
47
+ return icon
50
48
  } else {
51
- const icon = super.createIconDom_();
52
- icon.style.border = `1px solid ${this.toolboxItemDef_["secondaryColour"]}`;
53
- return icon;
49
+ const icon = super.createIconDom_()
50
+ icon.style.border = `1px solid ${this.toolboxItemDef_.secondaryColour}`
51
+ return icon
54
52
  }
55
53
  }
56
54
 
@@ -59,29 +57,27 @@ export class ScratchContinuousCategory extends ContinuousCategory {
59
57
  * @param isSelected True if this category is selected.
60
58
  */
61
59
  setSelected(isSelected: boolean) {
62
- super.setSelected(isSelected);
60
+ super.setSelected(isSelected)
63
61
  // Prevent hardcoding the background color to grey.
64
- this.rowDiv_.style.backgroundColor = "";
62
+ this.rowDiv_.style.backgroundColor = ''
65
63
  }
66
64
 
67
65
  /**
68
66
  * Returns whether or not this category's label in the flyout should display
69
67
  * status indicators.
68
+ * @returns True if the status indicator button should be shown.
70
69
  */
71
70
  shouldShowStatusButton() {
72
- return this.showStatusButton;
71
+ return this.showStatusButton
73
72
  }
74
73
  }
75
74
 
76
75
  /** Registers this toolbox category and unregisters the default one. */
77
76
  export function registerScratchContinuousCategory() {
78
- Blockly.registry.unregister(
79
- Blockly.registry.Type.TOOLBOX_ITEM,
80
- ScratchContinuousCategory.registrationName
81
- );
77
+ Blockly.registry.unregister(Blockly.registry.Type.TOOLBOX_ITEM, ScratchContinuousCategory.registrationName)
82
78
  Blockly.registry.register(
83
79
  Blockly.registry.Type.TOOLBOX_ITEM,
84
80
  ScratchContinuousCategory.registrationName,
85
- ScratchContinuousCategory
86
- );
81
+ ScratchContinuousCategory,
82
+ )
87
83
  }
@@ -1,13 +1,11 @@
1
1
  /**
2
- * @license
3
2
  * Copyright 2024 Google LLC
4
3
  * SPDX-License-Identifier: Apache-2.0
5
4
  */
6
-
7
- import * as Blockly from "blockly/core";
8
- import { ContinuousToolbox } from "@blockly/continuous-toolbox";
9
- import { ScratchContinuousCategory } from "./scratch_continuous_category";
10
- import { STATUS_INDICATOR_LABEL_TYPE } from "./status_indicator_label_flyout_inflater";
5
+ import * as Blockly from 'blockly/core'
6
+ import { ContinuousToolbox } from '@blockly/continuous-toolbox'
7
+ import { ScratchContinuousCategory } from './scratch_continuous_category'
8
+ import { STATUS_INDICATOR_LABEL_TYPE } from './status_indicator_label_flyout_inflater'
11
9
 
12
10
  /**
13
11
  * A toolbox that displays items from all categories in one scrolling list.
@@ -16,7 +14,7 @@ export class ScratchContinuousToolbox extends ContinuousToolbox {
16
14
  /**
17
15
  * List of functions to run after the next time the toolbox renders.
18
16
  */
19
- private postRenderCallbacks: (() => void)[] = [];
17
+ private postRenderCallbacks: (() => void)[] = []
20
18
 
21
19
  refreshSelection() {
22
20
  // Intentionally a no-op, Scratch manually manages refreshing the toolbox
@@ -26,37 +24,33 @@ export class ScratchContinuousToolbox extends ContinuousToolbox {
26
24
  /**
27
25
  * Converts the given toolbox item to a corresponding array of items that
28
26
  * should appear in the flyout.
29
- *
30
- * @param toolboxItem The toolbox item to convert.
27
+ * @param toolboxItem The toolbox item to translate into flyout content.
31
28
  * @returns An array of flyout item definitions.
32
29
  */
33
30
  protected convertToolboxItemToFlyoutItems(
34
- toolboxItem: Blockly.IToolboxItem
31
+ toolboxItem: Blockly.IToolboxItem,
35
32
  ): Blockly.utils.toolbox.FlyoutItemInfoArray {
36
- const contents = super.convertToolboxItemToFlyoutItems(toolboxItem);
37
- if (
38
- toolboxItem instanceof ScratchContinuousCategory &&
39
- toolboxItem.shouldShowStatusButton()
40
- ) {
33
+ const contents = super.convertToolboxItemToFlyoutItems(toolboxItem)
34
+ if (toolboxItem instanceof ScratchContinuousCategory && toolboxItem.shouldShowStatusButton()) {
41
35
  contents.splice(0, 1, {
42
36
  kind: STATUS_INDICATOR_LABEL_TYPE,
43
37
  id: toolboxItem.getId(),
44
38
  text: toolboxItem.getName(),
45
- });
39
+ })
46
40
  }
47
- return contents;
41
+ return contents
48
42
  }
49
43
 
50
44
  /**
51
45
  * Forcibly rerenders the toolbox, preserving selection when possible.
52
46
  */
53
47
  forceRerender() {
54
- const selectedCategoryName = this.selectedItem_?.getName();
55
- this.getFlyout().show(this.getInitialFlyoutContents());
56
- this.selectCategoryByName(selectedCategoryName);
57
- let callback;
48
+ const selectedCategoryName = this.selectedItem_?.getName()
49
+ this.getFlyout().show(this.getInitialFlyoutContents())
50
+ this.selectCategoryByName(selectedCategoryName)
51
+ let callback
58
52
  while ((callback = this.postRenderCallbacks.shift())) {
59
- callback();
53
+ callback()
60
54
  }
61
55
  }
62
56
 
@@ -65,22 +59,21 @@ export class ScratchContinuousToolbox extends ContinuousToolbox {
65
59
  * @param callback A callback to run whenever the toolbox next rerenders.
66
60
  */
67
61
  runAfterRerender(callback: () => void) {
68
- this.postRenderCallbacks.push(callback);
62
+ this.postRenderCallbacks.push(callback)
69
63
  }
70
64
 
71
65
  /**
72
66
  * Returns whether or not the given item should be deselected.
73
67
  * Prevents items from being deselected without a replacement.
74
- *
75
68
  * @param oldItem The item that was previously selected.
76
69
  * @param newItem The item that is proposed to be selected instead.
77
70
  * @returns True if the old item should be allowed to be deselected.
78
71
  */
79
72
  shouldDeselectItem_(
80
73
  oldItem: Blockly.ISelectableToolboxItem | null,
81
- newItem: Blockly.ISelectableToolboxItem | null
74
+ newItem: Blockly.ISelectableToolboxItem | null,
82
75
  ) {
83
- if (!newItem) return false;
84
- return super.shouldDeselectItem_(oldItem, newItem);
76
+ if (!newItem) return false
77
+ return super.shouldDeselectItem_(oldItem, newItem)
85
78
  }
86
79
  }
@@ -1,18 +1,16 @@
1
1
  /**
2
- * @license
3
2
  * Copyright 2024 Google LLC
4
3
  * SPDX-License-Identifier: Apache-2.0
5
4
  */
6
-
7
- import * as Blockly from "blockly/core";
8
- import { BlockDragOutside } from "./events/events_block_drag_outside";
9
- import { BlockDragEnd } from "./events/events_block_drag_end";
10
- import { isProcedureBlock, getCallers } from "./procedures";
5
+ import * as Blockly from 'blockly/core'
6
+ import { BlockDragEnd } from './events/events_block_drag_end'
7
+ import { BlockDragOutside } from './events/events_block_drag_outside'
8
+ import { isProcedureBlock, getCallers } from './procedures'
11
9
 
12
10
  /**
13
11
  * CSS class that allows the workspace to overflow its bounds when set.
14
12
  */
15
- const BOUNDLESS_CLASS = "boundless";
13
+ const BOUNDLESS_CLASS = 'boundless'
16
14
 
17
15
  /**
18
16
  * Class responsible for managing dragging items on the workspace.
@@ -21,138 +19,115 @@ export class ScratchDragger extends Blockly.dragging.Dragger {
21
19
  /**
22
20
  * Whether or not the current drag location is outside of the main workspace.
23
21
  */
24
- draggedOutOfBounds = false;
22
+ draggedOutOfBounds = false
25
23
 
26
24
  /**
27
25
  * Whether or not the current drag started from the flyout.
28
26
  */
29
- originatedFromFlyout = false;
27
+ originatedFromFlyout = false
30
28
 
31
29
  /**
32
30
  * Sets the current item being dragged.
33
- *
34
31
  * @param draggable The item being dragged.
35
32
  */
36
33
  setDraggable(draggable: Blockly.IDraggable) {
37
- this.draggable = draggable;
34
+ this.draggable = draggable
38
35
  }
39
36
 
40
37
  /**
41
38
  * Handles the start of a drag operation.
42
- *
43
39
  * @param event The event that triggered the drag.
44
40
  */
45
41
  onDragStart(event: PointerEvent) {
46
- super.onDragStart(event);
42
+ super.onDragStart(event)
47
43
  if (this.draggable instanceof Blockly.BlockSvg) {
48
- this.workspace.addClass(BOUNDLESS_CLASS);
49
- const absoluteMetrics = this.workspace
50
- .getMetricsManager()
51
- .getAbsoluteMetrics();
52
- const viewMetrics = this.workspace.getMetricsManager().getViewMetrics();
44
+ this.workspace.addClass(BOUNDLESS_CLASS)
45
+ const absoluteMetrics = this.workspace.getMetricsManager().getAbsoluteMetrics()
46
+ const viewMetrics = this.workspace.getMetricsManager().getViewMetrics()
53
47
  if (
54
48
  this.workspace.RTL
55
- ? event.clientX >
56
- this.workspace.getParentSvg().getBoundingClientRect().left +
57
- viewMetrics.width
49
+ ? event.clientX > this.workspace.getParentSvg().getBoundingClientRect().left + viewMetrics.width
58
50
  : event.clientX < absoluteMetrics.left
59
51
  ) {
60
- this.originatedFromFlyout = true;
52
+ this.originatedFromFlyout = true
61
53
  }
62
54
  }
63
55
  }
64
56
 
65
57
  /**
66
58
  * Handles motion during an ongoing drag operation.
67
- *
68
59
  * @param event The event that triggered this call.
69
60
  * @param totalDelta The change in pointer position since the last invocation.
70
61
  */
71
62
  onDrag(event: PointerEvent, totalDelta: Blockly.utils.Coordinate) {
72
- super.onDrag(event, totalDelta);
73
- this.updateOutOfBoundsState(event);
63
+ super.onDrag(event, totalDelta)
64
+ this.updateOutOfBoundsState(event)
74
65
  }
75
66
 
76
67
  /**
77
68
  * Records whether or not the current drag is out of the workspace's bounds.
78
- *
79
69
  * @param event The event that triggered this call.
80
70
  */
81
71
  updateOutOfBoundsState(event: PointerEvent) {
82
72
  if (this.draggable instanceof Blockly.BlockSvg) {
83
- const outOfBounds = !this.isInsideWorkspace(event);
73
+ const outOfBounds = !this.isInsideWorkspace(event)
84
74
  if (outOfBounds !== this.draggedOutOfBounds) {
85
- const event = new BlockDragOutside(
86
- this.getDragRoot(this.draggable) as Blockly.BlockSvg,
87
- outOfBounds
88
- );
89
- Blockly.Events.fire(event);
90
- this.draggedOutOfBounds = outOfBounds;
75
+ const event = new BlockDragOutside(this.getDragRoot(this.draggable) as Blockly.BlockSvg, outOfBounds)
76
+ Blockly.Events.fire(event)
77
+ this.draggedOutOfBounds = outOfBounds
91
78
  }
92
79
  }
93
80
  }
94
81
 
95
82
  /**
96
83
  * Handles the end of a drag.
97
- *
98
84
  * @param event The event that ended the drag.
99
85
  */
100
86
  onDragEnd(event: PointerEvent) {
101
87
  if (
102
88
  this.draggable instanceof Blockly.BlockSvg &&
103
- this.draggable.type === "procedures_definition" &&
89
+ this.draggable.type === 'procedures_definition' &&
104
90
  this.wouldDeleteDraggable(event, this.draggable.getRootBlock())
105
91
  ) {
106
- const prototype = this.draggable
107
- .getInput("custom_block")!
108
- .connection!.targetBlock();
92
+ const prototype = this.draggable.getInput('custom_block')!.connection!.targetBlock()
109
93
  const hasCaller =
110
94
  prototype instanceof Blockly.BlockSvg &&
111
95
  isProcedureBlock(prototype) &&
112
- getCallers(
113
- prototype.getProcCode(),
114
- this.draggable.workspace,
115
- this.draggable.getRootBlock(),
116
- false
117
- ).length > 0;
96
+ getCallers(prototype.getProcCode(), this.draggable.workspace, this.draggable.getRootBlock(), false).length > 0
118
97
 
119
98
  if (hasCaller) {
120
- Blockly.dialog.alert(Blockly.Msg.PROCEDURE_USED);
121
- this.draggable.revertDrag();
122
- this.draggable.endDrag();
123
- return;
99
+ Blockly.dialog.alert(Blockly.Msg.PROCEDURE_USED)
100
+ this.draggable.revertDrag()
101
+ this.draggable.endDrag()
102
+ return
124
103
  }
125
104
  }
126
105
 
127
- super.onDragEnd(event);
106
+ super.onDragEnd(event)
128
107
 
129
- this.updateOutOfBoundsState(event);
108
+ this.updateOutOfBoundsState(event)
130
109
  if (this.draggable instanceof Blockly.BlockSvg) {
131
- const event = new BlockDragEnd(
132
- this.getDragRoot(this.draggable) as Blockly.BlockSvg,
133
- this.draggedOutOfBounds
134
- );
135
- Blockly.Events.fire(event);
110
+ const event = new BlockDragEnd(this.getDragRoot(this.draggable) as Blockly.BlockSvg, this.draggedOutOfBounds)
111
+ Blockly.Events.fire(event)
136
112
  // If this block was dragged out of the flyout and dropped outside of
137
113
  // the workspace (e.g. on a different sprite), the block that was created
138
114
  // on the workspace in order to depict the block mid-drag needs to be
139
115
  // deleted.
140
116
  if (this.originatedFromFlyout && this.draggedOutOfBounds) {
141
117
  Blockly.renderManagement.finishQueuedRenders().then(() => {
142
- const rootBlock = this.getDragRoot(this.draggable);
118
+ const rootBlock = this.getDragRoot(this.draggable)
143
119
  if (rootBlock instanceof Blockly.BlockSvg) {
144
- rootBlock.dispose();
120
+ rootBlock.dispose()
145
121
  }
146
- });
122
+ })
147
123
  }
148
124
  }
149
- this.workspace.removeClass(BOUNDLESS_CLASS);
125
+ this.workspace.removeClass(BOUNDLESS_CLASS)
150
126
  }
151
127
 
152
128
  /**
153
129
  * Returns whether or not the dragged item should return to its starting
154
130
  * position.
155
- *
156
131
  * @param event The drag event that triggered this check.
157
132
  * @param rootDraggable The topmost item being dragged.
158
133
  * @returns True if the draggable should return to its starting position.
@@ -161,15 +136,12 @@ export class ScratchDragger extends Blockly.dragging.Dragger {
161
136
  // If a block is dragged out of the workspace to be e.g. dropped on another
162
137
  // sprite, it should remain in the same place on the workspace where it was,
163
138
  // rather than being moved to an invisible part of the workspace.
164
- return (
165
- this.draggedOutOfBounds || super.shouldReturnToStart(event, rootDraggable)
166
- );
139
+ return this.draggedOutOfBounds || super.shouldReturnToStart(event, rootDraggable)
167
140
  }
168
141
 
169
142
  /**
170
143
  * Returns the root element being dragged. For shadow blocks, this is the
171
144
  * parent block.
172
- *
173
145
  * @param draggable The element being dragged directly.
174
146
  * @returns The element being dragged, or its parent.
175
147
  */
@@ -178,34 +150,23 @@ export class ScratchDragger extends Blockly.dragging.Dragger {
178
150
  // from a stack via dragging, getRootBlock() still returns the root of that
179
151
  // stack.
180
152
  if (draggable instanceof Blockly.BlockSvg && draggable.isShadow()) {
181
- return draggable.getParent();
153
+ return draggable.getParent()
182
154
  }
183
155
 
184
- return draggable;
156
+ return draggable
185
157
  }
186
158
 
187
159
  /**
188
160
  * Returns whether or not the given event occurred within the bounds of the
189
161
  * workspace.
190
- *
191
162
  * @param event The event to check.
192
163
  * @returns True if the event occurred inside the workspace.
193
164
  */
194
165
  isInsideWorkspace(event: PointerEvent) {
195
- const bounds = this.workspace.getParentSvg().getBoundingClientRect();
196
- const workspaceRect = new Blockly.utils.Rect(
197
- bounds.top,
198
- bounds.bottom,
199
- bounds.left,
200
- bounds.right
201
- );
202
- return workspaceRect.contains(event.clientX, event.clientY);
166
+ const bounds = this.workspace.getParentSvg().getBoundingClientRect()
167
+ const workspaceRect = new Blockly.utils.Rect(bounds.top, bounds.bottom, bounds.left, bounds.right)
168
+ return workspaceRect.contains(event.clientX, event.clientY)
203
169
  }
204
170
  }
205
171
 
206
- Blockly.registry.register(
207
- Blockly.registry.Type.BLOCK_DRAGGER,
208
- Blockly.registry.DEFAULT,
209
- ScratchDragger,
210
- true
211
- );
172
+ Blockly.registry.register(Blockly.registry.Type.BLOCK_DRAGGER, Blockly.registry.DEFAULT, ScratchDragger, true)
@@ -1,10 +1,8 @@
1
1
  /**
2
- * @license
3
2
  * Copyright 2025 Google LLC
4
3
  * SPDX-License-Identifier: Apache-2.0
5
4
  */
6
-
7
- import * as Blockly from "blockly/core";
5
+ import * as Blockly from 'blockly/core'
8
6
 
9
7
  /**
10
8
  * Displays an indicator of where a block being dragged will be connected.
@@ -13,7 +11,6 @@ class ScratchInsertionMarkerPreviewer extends Blockly.InsertionMarkerPreviewer {
13
11
  /**
14
12
  * Transforms the given block into a JSON representation used to construct an
15
13
  * insertion marker.
16
- *
17
14
  * @param block The block to serialize and use as an insertion marker.
18
15
  * @returns A JSON-formatted string corresponding to a serialized
19
16
  * representation of the given block suitable for use as an insertion
@@ -25,15 +22,13 @@ class ScratchInsertionMarkerPreviewer extends Blockly.InsertionMarkerPreviewer {
25
22
  addInputBlocks: true,
26
23
  addNextBlocks: false,
27
24
  doFullSerialization: false,
28
- });
25
+ })
29
26
 
30
27
  if (!blockJson) {
31
- throw new Error(
32
- `Failed to serialize source block. ${block.toDevString()}`
33
- );
28
+ throw new Error(`Failed to serialize source block. ${block.toDevString()}`)
34
29
  }
35
30
 
36
- return blockJson;
31
+ return blockJson
37
32
  }
38
33
  }
39
34
 
@@ -41,5 +36,5 @@ Blockly.registry.register(
41
36
  Blockly.registry.Type.CONNECTION_PREVIEWER,
42
37
  Blockly.registry.DEFAULT,
43
38
  ScratchInsertionMarkerPreviewer,
44
- true
45
- );
39
+ true,
40
+ )
@@ -1,10 +1,8 @@
1
1
  /**
2
- * @license
3
2
  * Copyright 2024 Google LLC
4
3
  * SPDX-License-Identifier: Apache-2.0
5
4
  */
6
-
7
- import * as Blockly from "blockly/core";
5
+ import * as Blockly from 'blockly/core'
8
6
 
9
7
  /**
10
8
  * Class that provides storage for variables.
@@ -14,15 +12,10 @@ class ScratchVariableMap extends Blockly.VariableMap {
14
12
  // Variable names in Blockly are case-insensitive, but case sensitive in
15
13
  // Scratch. Override the implementation to only return a variable whose name
16
14
  // is identical to the one requested.
17
- const variables = this.getVariablesOfType(type ?? "");
18
- if (!variables.length) return null;
19
- return variables.find((v) => v.getName() === name) ?? null;
15
+ const variables = this.getVariablesOfType(type ?? '')
16
+ if (!variables.length) return null
17
+ return variables.find(v => v.getName() === name) ?? null
20
18
  }
21
19
  }
22
20
 
23
- Blockly.registry.register(
24
- Blockly.registry.Type.VARIABLE_MAP,
25
- Blockly.registry.DEFAULT,
26
- ScratchVariableMap,
27
- true
28
- );
21
+ Blockly.registry.register(Blockly.registry.Type.VARIABLE_MAP, Blockly.registry.DEFAULT, ScratchVariableMap, true)
@@ -1,10 +1,8 @@
1
1
  /**
2
- * @license
3
2
  * Copyright 2024 Google LLC
4
3
  * SPDX-License-Identifier: Apache-2.0
5
4
  */
6
-
7
- import * as Blockly from "blockly/core";
5
+ import * as Blockly from 'blockly/core'
8
6
 
9
7
  /**
10
8
  * Class that represents a variable with extra fields for Scratch.
@@ -16,15 +14,10 @@ export class ScratchVariableModel extends Blockly.VariableModel {
16
14
  type?: string,
17
15
  id?: string,
18
16
  public isLocal = false,
19
- public isCloud = false
17
+ public isCloud = false,
20
18
  ) {
21
- super(workspace, name, type, id);
19
+ super(workspace, name, type, id)
22
20
  }
23
21
  }
24
22
 
25
- Blockly.registry.register(
26
- Blockly.registry.Type.VARIABLE_MODEL,
27
- Blockly.registry.DEFAULT,
28
- ScratchVariableModel,
29
- true
30
- );
23
+ Blockly.registry.register(Blockly.registry.Type.VARIABLE_MODEL, Blockly.registry.DEFAULT, ScratchVariableModel, true)