scratch-blocks 2.1.4 → 2.1.6

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 (188) hide show
  1. package/AGENTS.md +76 -24
  2. package/README.md +40 -0
  3. package/dist/main.mjs +1 -1
  4. package/dist/types/src/block_reporting.d.ts.map +1 -1
  5. package/dist/types/src/blocks/procedures.d.ts +2 -2
  6. package/dist/types/src/blocks/procedures.d.ts.map +1 -1
  7. package/dist/types/src/checkable_continuous_flyout.d.ts +6 -3
  8. package/dist/types/src/checkable_continuous_flyout.d.ts.map +1 -1
  9. package/dist/types/src/checkbox_bubble.d.ts +7 -7
  10. package/dist/types/src/checkbox_bubble.d.ts.map +1 -1
  11. package/dist/types/src/colours.d.ts.map +1 -1
  12. package/dist/types/src/context_menu_items.d.ts.map +1 -1
  13. package/dist/types/src/events/events_block_comment_base.d.ts +1 -1
  14. package/dist/types/src/events/events_block_comment_base.d.ts.map +1 -1
  15. package/dist/types/src/events/events_block_drag_end.d.ts +1 -1
  16. package/dist/types/src/events/events_block_drag_end.d.ts.map +1 -1
  17. package/dist/types/src/events/events_block_drag_outside.d.ts +1 -1
  18. package/dist/types/src/events/events_block_drag_outside.d.ts.map +1 -1
  19. package/dist/types/src/fields/field_colour_slider.d.ts.map +1 -1
  20. package/dist/types/src/fields/field_matrix.d.ts.map +1 -1
  21. package/dist/types/src/fields/field_note.d.ts +6 -4
  22. package/dist/types/src/fields/field_note.d.ts.map +1 -1
  23. package/dist/types/src/fields/field_textinput_removable.d.ts.map +1 -1
  24. package/dist/types/src/fields/field_variable_getter.d.ts.map +1 -1
  25. package/dist/types/src/fields/field_vertical_separator.d.ts.map +1 -1
  26. package/dist/types/src/fields/scratch_field_angle.d.ts.map +1 -1
  27. package/dist/types/src/fields/scratch_field_dropdown.d.ts.map +1 -1
  28. package/dist/types/src/fields/scratch_field_number.d.ts.map +1 -1
  29. package/dist/types/src/fields/scratch_field_variable.d.ts +1 -0
  30. package/dist/types/src/fields/scratch_field_variable.d.ts.map +1 -1
  31. package/dist/types/src/flyout_checkbox_icon.d.ts +5 -5
  32. package/dist/types/src/flyout_checkbox_icon.d.ts.map +1 -1
  33. package/dist/types/src/glows.d.ts.map +1 -1
  34. package/dist/types/src/index.d.ts +1 -0
  35. package/dist/types/src/index.d.ts.map +1 -1
  36. package/dist/types/src/procedures.d.ts +4 -4
  37. package/dist/types/src/procedures.d.ts.map +1 -1
  38. package/dist/types/src/recyclable_block_flyout_inflater.d.ts +2 -2
  39. package/dist/types/src/recyclable_block_flyout_inflater.d.ts.map +1 -1
  40. package/dist/types/src/renderer/cat/cat_face.d.ts +1 -1
  41. package/dist/types/src/renderer/cat/cat_face.d.ts.map +1 -1
  42. package/dist/types/src/renderer/cat/drawer.d.ts.map +1 -1
  43. package/dist/types/src/renderer/constants.d.ts.map +1 -1
  44. package/dist/types/src/renderer/drawer.d.ts.map +1 -1
  45. package/dist/types/src/renderer/render_info.d.ts.map +1 -1
  46. package/dist/types/src/scratch_blocks_utils.d.ts +22 -0
  47. package/dist/types/src/scratch_blocks_utils.d.ts.map +1 -1
  48. package/dist/types/src/scratch_c_block_wrap.d.ts +2 -0
  49. package/dist/types/src/scratch_c_block_wrap.d.ts.map +1 -0
  50. package/dist/types/src/scratch_comment_bubble.d.ts +4 -4
  51. package/dist/types/src/scratch_comment_bubble.d.ts.map +1 -1
  52. package/dist/types/src/scratch_comment_icon.d.ts +1 -1
  53. package/dist/types/src/scratch_comment_icon.d.ts.map +1 -1
  54. package/dist/types/src/scratch_continuous_category.d.ts +3 -1
  55. package/dist/types/src/scratch_continuous_category.d.ts.map +1 -1
  56. package/dist/types/src/scratch_continuous_toolbox.d.ts +2 -1
  57. package/dist/types/src/scratch_continuous_toolbox.d.ts.map +1 -1
  58. package/dist/types/src/status_indicator_label.d.ts +3 -3
  59. package/dist/types/src/status_indicator_label.d.ts.map +1 -1
  60. package/dist/types/src/status_indicator_label_flyout_inflater.d.ts.map +1 -1
  61. package/dist/types/src/variables.d.ts +1 -1
  62. package/dist/types/src/variables.d.ts.map +1 -1
  63. package/dist/types/src/workspace_block_lookup.d.ts +4 -0
  64. package/dist/types/src/workspace_block_lookup.d.ts.map +1 -0
  65. package/eslint.config.mjs +23 -26
  66. package/package.json +10 -3
  67. package/src/block_reporting.ts +5 -5
  68. package/src/blocks/control.ts +5 -5
  69. package/src/blocks/event.ts +1 -1
  70. package/src/blocks/motion.ts +2 -2
  71. package/src/blocks/procedures.ts +162 -69
  72. package/src/blocks/sensing.ts +0 -1
  73. package/src/blocks/vertical_extensions.ts +11 -8
  74. package/src/checkable_continuous_flyout.ts +45 -12
  75. package/src/checkbox_bubble.ts +7 -7
  76. package/src/colours.ts +4 -2
  77. package/src/context_menu_items.ts +41 -16
  78. package/src/data_category.ts +11 -3
  79. package/src/events/events_block_comment_base.ts +5 -1
  80. package/src/events/events_block_comment_change.ts +5 -1
  81. package/src/events/events_block_comment_collapse.ts +6 -2
  82. package/src/events/events_block_comment_create.ts +5 -1
  83. package/src/events/events_block_comment_move.ts +6 -2
  84. package/src/events/events_block_comment_resize.ts +6 -2
  85. package/src/events/events_block_drag_end.ts +5 -1
  86. package/src/events/events_block_drag_outside.ts +5 -1
  87. package/src/events/events_scratch_variable_create.ts +5 -1
  88. package/src/fields/field_colour_slider.ts +3 -5
  89. package/src/fields/field_matrix.ts +33 -17
  90. package/src/fields/field_note.ts +56 -20
  91. package/src/fields/field_textinput_removable.ts +13 -4
  92. package/src/fields/field_variable_getter.ts +20 -6
  93. package/src/fields/field_vertical_separator.ts +5 -1
  94. package/src/fields/scratch_field_angle.ts +32 -21
  95. package/src/fields/scratch_field_dropdown.ts +6 -2
  96. package/src/fields/scratch_field_number.ts +22 -13
  97. package/src/fields/scratch_field_variable.ts +26 -12
  98. package/src/flyout_checkbox_icon.ts +9 -5
  99. package/src/glows.ts +5 -5
  100. package/src/index.ts +21 -11
  101. package/src/procedures.ts +92 -42
  102. package/src/recyclable_block_flyout_inflater.ts +5 -4
  103. package/src/renderer/cat/cat_face.ts +1 -1
  104. package/src/renderer/cat/drawer.ts +4 -1
  105. package/src/renderer/constants.ts +19 -14
  106. package/src/renderer/drawer.ts +2 -1
  107. package/src/renderer/render_info.ts +12 -9
  108. package/src/renderer/renderer.ts +1 -1
  109. package/src/scratch_blocks_utils.ts +0 -2
  110. package/src/scratch_c_block_wrap.ts +108 -0
  111. package/src/scratch_comment_bubble.ts +30 -19
  112. package/src/scratch_comment_icon.ts +9 -12
  113. package/src/scratch_connection_checker.ts +1 -2
  114. package/src/scratch_continuous_category.ts +20 -11
  115. package/src/scratch_continuous_toolbox.ts +12 -3
  116. package/src/scratch_dragger.ts +2 -2
  117. package/src/scratch_variable_map.ts +1 -1
  118. package/src/status_indicator_label.ts +13 -9
  119. package/src/status_indicator_label_flyout_inflater.ts +2 -1
  120. package/src/variables.ts +21 -14
  121. package/src/workspace_block_lookup.ts +14 -0
  122. package/src/xml.ts +1 -1
  123. package/tsconfig.build.json +4 -0
  124. package/tsconfig.json +1 -1
  125. package/vitest.config.ts +35 -0
  126. package/dist/types/tests/blocks/logic_ternary_test.d.ts +0 -13
  127. package/dist/types/tests/blocks/logic_ternary_test.d.ts.map +0 -1
  128. package/dist/types/tests/jsunit/block_test.d.ts +0 -4
  129. package/dist/types/tests/jsunit/block_test.d.ts.map +0 -1
  130. package/dist/types/tests/jsunit/connection_db_test.d.ts +0 -25
  131. package/dist/types/tests/jsunit/connection_db_test.d.ts.map +0 -1
  132. package/dist/types/tests/jsunit/connection_test.d.ts +0 -39
  133. package/dist/types/tests/jsunit/connection_test.d.ts.map +0 -1
  134. package/dist/types/tests/jsunit/db_test.d.ts +0 -7
  135. package/dist/types/tests/jsunit/db_test.d.ts.map +0 -1
  136. package/dist/types/tests/jsunit/event_test.d.ts +0 -76
  137. package/dist/types/tests/jsunit/event_test.d.ts.map +0 -1
  138. package/dist/types/tests/jsunit/extensions_test.d.ts +0 -18
  139. package/dist/types/tests/jsunit/extensions_test.d.ts.map +0 -1
  140. package/dist/types/tests/jsunit/field_angle_test.d.ts +0 -3
  141. package/dist/types/tests/jsunit/field_angle_test.d.ts.map +0 -1
  142. package/dist/types/tests/jsunit/field_number_test.d.ts +0 -3
  143. package/dist/types/tests/jsunit/field_number_test.d.ts.map +0 -1
  144. package/dist/types/tests/jsunit/field_test.d.ts +0 -8
  145. package/dist/types/tests/jsunit/field_test.d.ts.map +0 -1
  146. package/dist/types/tests/jsunit/field_variable_getter_test.d.ts +0 -5
  147. package/dist/types/tests/jsunit/field_variable_getter_test.d.ts.map +0 -1
  148. package/dist/types/tests/jsunit/field_variable_test.d.ts +0 -19
  149. package/dist/types/tests/jsunit/field_variable_test.d.ts.map +0 -1
  150. package/dist/types/tests/jsunit/generator_test.d.ts +0 -2
  151. package/dist/types/tests/jsunit/generator_test.d.ts.map +0 -1
  152. package/dist/types/tests/jsunit/gesture_test.d.ts +0 -10
  153. package/dist/types/tests/jsunit/gesture_test.d.ts.map +0 -1
  154. package/dist/types/tests/jsunit/input_test.d.ts +0 -9
  155. package/dist/types/tests/jsunit/input_test.d.ts.map +0 -1
  156. package/dist/types/tests/jsunit/json_test.d.ts +0 -11
  157. package/dist/types/tests/jsunit/json_test.d.ts.map +0 -1
  158. package/dist/types/tests/jsunit/names_test.d.ts +0 -5
  159. package/dist/types/tests/jsunit/names_test.d.ts.map +0 -1
  160. package/dist/types/tests/jsunit/procedure_test.d.ts +0 -15
  161. package/dist/types/tests/jsunit/procedure_test.d.ts.map +0 -1
  162. package/dist/types/tests/jsunit/scratch_block_comment_test.d.ts +0 -14
  163. package/dist/types/tests/jsunit/scratch_block_comment_test.d.ts.map +0 -1
  164. package/dist/types/tests/jsunit/svg_test.d.ts +0 -14
  165. package/dist/types/tests/jsunit/svg_test.d.ts.map +0 -1
  166. package/dist/types/tests/jsunit/test_runner.d.ts +0 -2
  167. package/dist/types/tests/jsunit/test_runner.d.ts.map +0 -1
  168. package/dist/types/tests/jsunit/test_utilities.d.ts +0 -50
  169. package/dist/types/tests/jsunit/test_utilities.d.ts.map +0 -1
  170. package/dist/types/tests/jsunit/utils_test.d.ts +0 -10
  171. package/dist/types/tests/jsunit/utils_test.d.ts.map +0 -1
  172. package/dist/types/tests/jsunit/variable_map_test.d.ts +0 -28
  173. package/dist/types/tests/jsunit/variable_map_test.d.ts.map +0 -1
  174. package/dist/types/tests/jsunit/variable_model_test.d.ts +0 -14
  175. package/dist/types/tests/jsunit/variable_model_test.d.ts.map +0 -1
  176. package/dist/types/tests/jsunit/widget_div_test.d.ts +0 -37
  177. package/dist/types/tests/jsunit/widget_div_test.d.ts.map +0 -1
  178. package/dist/types/tests/jsunit/workspace_comment_test.d.ts +0 -13
  179. package/dist/types/tests/jsunit/workspace_comment_test.d.ts.map +0 -1
  180. package/dist/types/tests/jsunit/workspace_test.d.ts +0 -22
  181. package/dist/types/tests/jsunit/workspace_test.d.ts.map +0 -1
  182. package/dist/types/tests/jsunit/workspace_undo_redo_test.d.ts +0 -33
  183. package/dist/types/tests/jsunit/workspace_undo_redo_test.d.ts.map +0 -1
  184. package/dist/types/tests/jsunit/xml_test.d.ts +0 -55
  185. package/dist/types/tests/jsunit/xml_test.d.ts.map +0 -1
  186. package/dist/types/tests/workspace_svg/workspace_svg_test.d.ts +0 -12
  187. package/dist/types/tests/workspace_svg/workspace_svg_test.d.ts.map +0 -1
  188. package/types/continuous-toolbox.d.ts +0 -1
@@ -12,6 +12,7 @@ export declare class ScratchContinuousToolbox extends ContinuousToolbox {
12
12
  * List of functions to run after the next time the toolbox renders.
13
13
  */
14
14
  private postRenderCallbacks;
15
+ private getInitialFlyoutContents_;
15
16
  refreshSelection(): void;
16
17
  /**
17
18
  * Converts the given toolbox item to a corresponding array of items that
@@ -36,6 +37,6 @@ export declare class ScratchContinuousToolbox extends ContinuousToolbox {
36
37
  * @param newItem The item that is proposed to be selected instead.
37
38
  * @returns True if the old item should be allowed to be deselected.
38
39
  */
39
- shouldDeselectItem_(oldItem: Blockly.ISelectableToolboxItem | null, newItem: Blockly.ISelectableToolboxItem | null): any;
40
+ shouldDeselectItem_(oldItem: Blockly.ISelectableToolboxItem | null, newItem: Blockly.ISelectableToolboxItem | null): boolean;
40
41
  }
41
42
  //# sourceMappingURL=scratch_continuous_toolbox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scratch_continuous_toolbox.d.ts","sourceRoot":"","sources":["../../../src/scratch_continuous_toolbox.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAC/D,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAIvC;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,iBAAiB;IAC7D;;OAEG;IACH,OAAO,CAAC,mBAAmB,CAAqB;IAEhD,gBAAgB;IAKhB;;;;;OAKG;IACH,SAAS,CAAC,+BAA+B,CACvC,WAAW,EAAE,OAAO,CAAC,YAAY,GAChC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,mBAAmB;IAY5C;;OAEG;IACH,aAAa;IAUb;;;OAGG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI;IAIrC;;;;;;OAMG;IACH,mBAAmB,CACjB,OAAO,EAAE,OAAO,CAAC,sBAAsB,GAAG,IAAI,EAC9C,OAAO,EAAE,OAAO,CAAC,sBAAsB,GAAG,IAAI;CAKjD"}
1
+ {"version":3,"file":"scratch_continuous_toolbox.d.ts","sourceRoot":"","sources":["../../../src/scratch_continuous_toolbox.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAC/D,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAIvC;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,iBAAiB;IAC7D;;OAEG;IACH,OAAO,CAAC,mBAAmB,CAAqB;IAEhD,OAAO,CAAC,yBAAyB;IAIjC,gBAAgB;IAKhB;;;;;OAKG;IACH,SAAS,CAAC,+BAA+B,CACvC,WAAW,EAAE,OAAO,CAAC,YAAY,GAChC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,mBAAmB;IAY5C;;OAEG;IACH,aAAa;IAeb;;;OAGG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI;IAIrC;;;;;;OAMG;IACH,mBAAmB,CACjB,OAAO,EAAE,OAAO,CAAC,sBAAsB,GAAG,IAAI,EAC9C,OAAO,EAAE,OAAO,CAAC,sBAAsB,GAAG,IAAI;CAKjD"}
@@ -42,7 +42,7 @@ export declare class StatusIndicatorLabel extends Blockly.FlyoutButton {
42
42
  /**
43
43
  * Function to be invoked when the status indicator is clicked.
44
44
  */
45
- static statusButtonCallback: (extensionId: string) => void;
45
+ static statusButtonCallback: ((extensionId: string) => void) | null;
46
46
  /**
47
47
  * Creates a new StatusIndicatorLabel.
48
48
  * @param workspace The workspace in which to place this header.
@@ -62,10 +62,10 @@ export declare class StatusIndicatorLabel extends Blockly.FlyoutButton {
62
62
  setImageSrc(src: string): void;
63
63
  /**
64
64
  * Gets the extension state. Overridden externally.
65
- * @param extensionId A string identifying which extension's state to retrieve.
65
+ * @param _extensionId A string identifying which extension's state to retrieve.
66
66
  * @returns Whether the extension is ready to be used.
67
67
  */
68
- getExtensionState(extensionId: string): StatusButtonState;
68
+ getExtensionState(_extensionId: string): StatusButtonState;
69
69
  /**
70
70
  * Disposes of this status indicator label.
71
71
  */
@@ -1 +1 @@
1
- {"version":3,"file":"status_indicator_label.d.ts","sourceRoot":"","sources":["../../../src/status_indicator_label.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH;;;;GAIG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,OAAO,CAAC,YAAY;IAC5D;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,YAAY,EAAE,eAAe,CAAA;IAE7B;;OAEG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OAIG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM;IAIvB;;;;OAIG;IACH,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,iBAAiB;IAI1D;;OAEG;IACH,OAAO;CAIR;AAED;;GAEG;AACH,oBAAY,iBAAiB;IAC3B,KAAK,UAAU;IACf,SAAS,cAAc;CACxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"status_indicator_label_flyout_inflater.d.ts","sourceRoot":"","sources":["../../../src/status_indicator_label_flyout_inflater.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,2BAA2B,2BAA2B,CAAA;AAmBnE;;GAEG;AACH,wBAAgB,0CAA0C,SAMzD"}
1
+ {"version":3,"file":"status_indicator_label_flyout_inflater.d.ts","sourceRoot":"","sources":["../../../src/status_indicator_label_flyout_inflater.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,2BAA2B,2BAA2B,CAAA;AAoBnE;;GAEG;AACH,wBAAgB,0CAA0C,SAMzD"}
@@ -49,6 +49,6 @@ export declare function createVariable(workspace: Blockly.WorkspaceSvg, opt_call
49
49
  * name, or null if change is to be aborted (cancel button), or undefined if
50
50
  * an existing variable was chosen.
51
51
  */
52
- export declare function renameVariable(workspace: Blockly.WorkspaceSvg, variable: ScratchVariableModel, opt_callback?: (id?: string) => void): void;
52
+ export declare function renameVariable(workspace: Blockly.Workspace, variable: ScratchVariableModel, opt_callback?: (id?: string) => void): void;
53
53
  export { getVariablesCategory } from './data_category';
54
54
  //# sourceMappingURL=variables.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../../src/variables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH;;;GAGG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAIvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAS/D,KAAK,UAAU,GAAG,CAChB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,M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AC,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,KACb,IAAI,CAAA;AAIT;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU,QAEnD;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,OAAO,CAAC,YAAY,EAC/B,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,EACpC,QAAQ,CAAC,EAAE,MAAM,QAoElB;AAsID;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,OAAO,CAAC,SAAS,EAC5B,QAAQ,EAAE,oBAAoB,EAC9B,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,QA0DrC;AAED,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import * as Blockly from 'blockly/core';
2
+ export declare function getRequiredMainWorkspaceSvg(): Blockly.WorkspaceSvg;
3
+ export declare function getBlockSvgById(workspace: Blockly.WorkspaceSvg, id: string): Blockly.BlockSvg | null;
4
+ //# sourceMappingURL=workspace_block_lookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace_block_lookup.d.ts","sourceRoot":"","sources":["../../../src/workspace_block_lookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC,wBAAgB,2BAA2B,IAAI,OAAO,CAAC,YAAY,CAMlE;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC,YAAY,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAGpG"}
package/eslint.config.mjs CHANGED
@@ -13,35 +13,32 @@ export default eslintConfigScratch.defineConfig(
13
13
  },
14
14
  },
15
15
  {
16
- // TypeScript rule overrides (type-checked rules must be scoped to TS files)
17
16
  files: ['**/*.{ts,tsx,mts,cts}'],
18
17
  plugins: { '@typescript-eslint': tseslint.plugin },
18
+ },
19
+ {
20
+ // TODO: upstream to eslint-config-scratch
21
+ files: ['**/*.{ts,tsx,mts,cts}'],
19
22
  rules: {
20
- // TODO: improve TypeScript type annotations to remove `any` usage
21
- '@typescript-eslint/no-explicit-any': 'warn',
22
- '@typescript-eslint/no-unsafe-argument': 'warn',
23
- '@typescript-eslint/no-unsafe-assignment': 'warn',
24
- '@typescript-eslint/no-unsafe-call': 'warn',
25
- '@typescript-eslint/no-unsafe-enum-comparison': 'warn',
26
- '@typescript-eslint/no-unsafe-member-access': 'warn',
27
- '@typescript-eslint/no-unsafe-return': 'warn',
28
- '@typescript-eslint/unbound-method': 'warn',
29
-
30
- // TODO: fix incrementally
31
- '@typescript-eslint/no-non-null-assertion': 'warn',
32
- '@typescript-eslint/no-unnecessary-condition': 'warn',
33
- '@typescript-eslint/prefer-nullish-coalescing': 'warn',
34
- '@typescript-eslint/no-base-to-string': 'warn',
35
- '@typescript-eslint/no-empty-function': 'warn',
36
- '@typescript-eslint/no-floating-promises': 'warn',
37
- '@typescript-eslint/no-unnecessary-type-assertion': 'warn',
38
- '@typescript-eslint/no-unused-vars': 'warn',
39
- '@typescript-eslint/only-throw-error': 'warn',
40
- '@typescript-eslint/prefer-optional-chain': 'warn',
41
- '@typescript-eslint/require-await': 'warn',
42
- '@typescript-eslint/restrict-plus-operands': 'warn',
43
- '@typescript-eslint/prefer-for-of': 'warn',
44
- '@typescript-eslint/restrict-template-expressions': 'warn',
23
+ '@typescript-eslint/no-empty-function': 'off',
24
+ '@typescript-eslint/no-unused-vars': [
25
+ 'error',
26
+ {
27
+ argsIgnorePattern: '^_',
28
+ caughtErrorsIgnorePattern: '^_',
29
+ destructuredArrayIgnorePattern: '^_',
30
+ ignoreRestSiblings: true,
31
+ },
32
+ ],
33
+ },
34
+ },
35
+ {
36
+ // Tests frequently introspect internals and invoke prototype methods directly.
37
+ files: ['tests/**/*.{ts,tsx,mts,cts}'],
38
+ rules: {
39
+ '@typescript-eslint/no-explicit-any': 'off',
40
+ '@typescript-eslint/no-unsafe-call': 'off',
41
+ '@typescript-eslint/no-unsafe-member-access': 'off',
45
42
  },
46
43
  },
47
44
  globalIgnores([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scratch-blocks",
3
- "version": "2.1.4",
3
+ "version": "2.1.6",
4
4
  "description": "Scratch Blocks is a library for building creative computing interfaces.",
5
5
  "author": "Massachusetts Institute of Technology",
6
6
  "license": "Apache-2.0",
@@ -23,8 +23,11 @@
23
23
  "format": "prettier --write . && eslint --fix",
24
24
  "prepare": "husky || true",
25
25
  "start": "webpack serve --open --mode development",
26
- "test": "echo \"Error: no test specified\" && exit 1",
26
+ "test": "vitest run",
27
+ "test:browser": "vitest run --project browser",
27
28
  "test:lint": "eslint && prettier --check .",
29
+ "test:unit": "vitest run --project unit",
30
+ "test:watch": "vitest",
28
31
  "watch": "webpack --mode development --watch"
29
32
  },
30
33
  "dependencies": {
@@ -35,15 +38,19 @@
35
38
  "devDependencies": {
36
39
  "@commitlint/cli": "20.5.0",
37
40
  "@commitlint/config-conventional": "20.5.0",
41
+ "@vitest/browser": "4.1.0",
42
+ "@vitest/browser-playwright": "4.1.0",
38
43
  "eslint": "9.39.4",
39
- "eslint-config-scratch": "14.0.11",
44
+ "eslint-config-scratch": "14.0.12",
40
45
  "husky": "9.1.7",
46
+ "playwright": "1.58.2",
41
47
  "prettier": "3.8.1",
42
48
  "scratch-semantic-release-config": "4.0.1",
43
49
  "semantic-release": "25.0.3",
44
50
  "source-map-loader": "5.0.0",
45
51
  "ts-loader": "9.5.4",
46
52
  "typescript": "5.9.3",
53
+ "vitest": "4.1.0",
47
54
  "webpack": "5.105.4",
48
55
  "webpack-cli": "6.0.1",
49
56
  "webpack-dev-server": "5.2.3"
@@ -1,12 +1,12 @@
1
1
  import * as Blockly from 'blockly/core'
2
2
  import { Colours } from './colours'
3
+ import { getBlockSvgById, getRequiredMainWorkspaceSvg } from './workspace_block_lookup'
3
4
 
4
5
  export function reportValue(id: string, value: string) {
5
- const block = (Blockly.getMainWorkspace().getBlockById(id) ||
6
- (Blockly.getMainWorkspace() as Blockly.WorkspaceSvg)
7
- .getFlyout()
8
- ?.getWorkspace()
9
- ?.getBlockById(id)) as Blockly.BlockSvg
6
+ const mainWorkspace = getRequiredMainWorkspaceSvg()
7
+ const flyout = mainWorkspace.getFlyout()
8
+ const flyoutBlock = flyout ? getBlockSvgById(flyout.getWorkspace(), id) : null
9
+ const block = getBlockSvgById(mainWorkspace, id) ?? flyoutBlock
10
10
  if (!block) {
11
11
  throw new Error('Tried to report value on block that does not exist.')
12
12
  }
@@ -24,7 +24,7 @@ Blockly.Blocks.control_forever = {
24
24
  * https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#5eke39
25
25
  */
26
26
  init: function (this: Blockly.Block) {
27
- const ws = this.workspace.options.parentWorkspace || this.workspace
27
+ const ws = this.workspace.options.parentWorkspace ?? this.workspace
28
28
  this.jsonInit({
29
29
  id: 'control_forever',
30
30
  message0: Blockly.Msg.CONTROL_FOREVER,
@@ -58,7 +58,7 @@ Blockly.Blocks.control_repeat = {
58
58
  * https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#so57n9
59
59
  */
60
60
  init: function (this: Blockly.Block) {
61
- const ws = this.workspace.options.parentWorkspace || this.workspace
61
+ const ws = this.workspace.options.parentWorkspace ?? this.workspace
62
62
  this.jsonInit({
63
63
  id: 'control_repeat',
64
64
  message0: Blockly.Msg.CONTROL_REPEAT,
@@ -164,7 +164,7 @@ Blockly.Blocks.control_stop = {
164
164
  const OTHER_SCRIPTS = 'other scripts in sprite'
165
165
  const stopDropdown = new Blockly.FieldDropdown(
166
166
  function () {
167
- if (this.sourceBlock_ && this.sourceBlock_.nextConnection && this.sourceBlock_.nextConnection.isConnected()) {
167
+ if (this.sourceBlock_?.nextConnection?.isConnected()) {
168
168
  return [[Blockly.Msg.CONTROL_STOP_OTHER, OTHER_SCRIPTS]]
169
169
  }
170
170
  return [
@@ -232,7 +232,7 @@ Blockly.Blocks.control_repeat_until = {
232
232
  * Block to repeat until a condition becomes true.
233
233
  */
234
234
  init: function (this: Blockly.Block) {
235
- const ws = this.workspace.options.parentWorkspace || this.workspace
235
+ const ws = this.workspace.options.parentWorkspace ?? this.workspace
236
236
  this.jsonInit({
237
237
  message0: Blockly.Msg.CONTROL_REPEATUNTIL,
238
238
  message1: '%1',
@@ -272,7 +272,7 @@ Blockly.Blocks.control_while = {
272
272
  * (This is an obsolete "hacked" block, for compatibility with 2.0.)
273
273
  */
274
274
  init: function (this: Blockly.Block) {
275
- const ws = this.workspace.options.parentWorkspace || this.workspace
275
+ const ws = this.workspace.options.parentWorkspace ?? this.workspace
276
276
  this.jsonInit({
277
277
  message0: Blockly.Msg.CONTROL_WHILE,
278
278
  message1: '%1',
@@ -64,7 +64,7 @@ Blockly.Blocks.event_whenflagclicked = {
64
64
  * Block for when flag clicked.
65
65
  */
66
66
  init: function (this: Blockly.Block) {
67
- const ws = this.workspace.options.parentWorkspace || this.workspace
67
+ const ws = this.workspace.options.parentWorkspace ?? this.workspace
68
68
  this.jsonInit({
69
69
  id: 'event_whenflagclicked',
70
70
  message0: Blockly.Msg.EVENT_WHENFLAGCLICKED,
@@ -41,7 +41,7 @@ Blockly.Blocks.motion_turnright = {
41
41
  * Block to turn right.
42
42
  */
43
43
  init: function (this: Blockly.Block) {
44
- const ws = this.workspace.options.parentWorkspace || this.workspace
44
+ const ws = this.workspace.options.parentWorkspace ?? this.workspace
45
45
  this.jsonInit({
46
46
  message0: Blockly.Msg.MOTION_TURNRIGHT,
47
47
  args0: [
@@ -66,7 +66,7 @@ Blockly.Blocks.motion_turnleft = {
66
66
  * Block to turn left.
67
67
  */
68
68
  init: function (this: Blockly.Block) {
69
- const ws = this.workspace.options.parentWorkspace || this.workspace
69
+ const ws = this.workspace.options.parentWorkspace ?? this.workspace
70
70
  this.jsonInit({
71
71
  message0: Blockly.Msg.MOTION_TURNLEFT,
72
72
  args0: [