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.
- package/AGENTS.md +76 -24
- package/README.md +40 -0
- package/dist/main.mjs +1 -1
- package/dist/types/src/block_reporting.d.ts.map +1 -1
- package/dist/types/src/blocks/procedures.d.ts +2 -2
- package/dist/types/src/blocks/procedures.d.ts.map +1 -1
- package/dist/types/src/checkable_continuous_flyout.d.ts +6 -3
- package/dist/types/src/checkable_continuous_flyout.d.ts.map +1 -1
- package/dist/types/src/checkbox_bubble.d.ts +7 -7
- package/dist/types/src/checkbox_bubble.d.ts.map +1 -1
- package/dist/types/src/colours.d.ts.map +1 -1
- package/dist/types/src/context_menu_items.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_base.d.ts +1 -1
- package/dist/types/src/events/events_block_comment_base.d.ts.map +1 -1
- package/dist/types/src/events/events_block_drag_end.d.ts +1 -1
- package/dist/types/src/events/events_block_drag_end.d.ts.map +1 -1
- package/dist/types/src/events/events_block_drag_outside.d.ts +1 -1
- package/dist/types/src/events/events_block_drag_outside.d.ts.map +1 -1
- package/dist/types/src/fields/field_colour_slider.d.ts.map +1 -1
- package/dist/types/src/fields/field_matrix.d.ts.map +1 -1
- package/dist/types/src/fields/field_note.d.ts +6 -4
- package/dist/types/src/fields/field_note.d.ts.map +1 -1
- package/dist/types/src/fields/field_textinput_removable.d.ts.map +1 -1
- package/dist/types/src/fields/field_variable_getter.d.ts.map +1 -1
- package/dist/types/src/fields/field_vertical_separator.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_angle.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_dropdown.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_number.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_variable.d.ts +1 -0
- package/dist/types/src/fields/scratch_field_variable.d.ts.map +1 -1
- package/dist/types/src/flyout_checkbox_icon.d.ts +5 -5
- package/dist/types/src/flyout_checkbox_icon.d.ts.map +1 -1
- package/dist/types/src/glows.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/procedures.d.ts +4 -4
- package/dist/types/src/procedures.d.ts.map +1 -1
- package/dist/types/src/recyclable_block_flyout_inflater.d.ts +2 -2
- package/dist/types/src/recyclable_block_flyout_inflater.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/cat_face.d.ts +1 -1
- package/dist/types/src/renderer/cat/cat_face.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/drawer.d.ts.map +1 -1
- package/dist/types/src/renderer/constants.d.ts.map +1 -1
- package/dist/types/src/renderer/drawer.d.ts.map +1 -1
- package/dist/types/src/renderer/render_info.d.ts.map +1 -1
- package/dist/types/src/scratch_blocks_utils.d.ts +22 -0
- package/dist/types/src/scratch_blocks_utils.d.ts.map +1 -1
- package/dist/types/src/scratch_c_block_wrap.d.ts +2 -0
- package/dist/types/src/scratch_c_block_wrap.d.ts.map +1 -0
- package/dist/types/src/scratch_comment_bubble.d.ts +4 -4
- package/dist/types/src/scratch_comment_bubble.d.ts.map +1 -1
- package/dist/types/src/scratch_comment_icon.d.ts +1 -1
- package/dist/types/src/scratch_comment_icon.d.ts.map +1 -1
- package/dist/types/src/scratch_continuous_category.d.ts +3 -1
- package/dist/types/src/scratch_continuous_category.d.ts.map +1 -1
- package/dist/types/src/scratch_continuous_toolbox.d.ts +2 -1
- package/dist/types/src/scratch_continuous_toolbox.d.ts.map +1 -1
- package/dist/types/src/status_indicator_label.d.ts +3 -3
- package/dist/types/src/status_indicator_label.d.ts.map +1 -1
- package/dist/types/src/status_indicator_label_flyout_inflater.d.ts.map +1 -1
- package/dist/types/src/variables.d.ts +1 -1
- package/dist/types/src/variables.d.ts.map +1 -1
- package/dist/types/src/workspace_block_lookup.d.ts +4 -0
- package/dist/types/src/workspace_block_lookup.d.ts.map +1 -0
- package/eslint.config.mjs +23 -26
- package/package.json +10 -3
- package/src/block_reporting.ts +5 -5
- package/src/blocks/control.ts +5 -5
- package/src/blocks/event.ts +1 -1
- package/src/blocks/motion.ts +2 -2
- package/src/blocks/procedures.ts +162 -69
- package/src/blocks/sensing.ts +0 -1
- package/src/blocks/vertical_extensions.ts +11 -8
- package/src/checkable_continuous_flyout.ts +45 -12
- package/src/checkbox_bubble.ts +7 -7
- package/src/colours.ts +4 -2
- package/src/context_menu_items.ts +41 -16
- package/src/data_category.ts +11 -3
- package/src/events/events_block_comment_base.ts +5 -1
- package/src/events/events_block_comment_change.ts +5 -1
- package/src/events/events_block_comment_collapse.ts +6 -2
- package/src/events/events_block_comment_create.ts +5 -1
- package/src/events/events_block_comment_move.ts +6 -2
- package/src/events/events_block_comment_resize.ts +6 -2
- package/src/events/events_block_drag_end.ts +5 -1
- package/src/events/events_block_drag_outside.ts +5 -1
- package/src/events/events_scratch_variable_create.ts +5 -1
- package/src/fields/field_colour_slider.ts +3 -5
- package/src/fields/field_matrix.ts +33 -17
- package/src/fields/field_note.ts +56 -20
- package/src/fields/field_textinput_removable.ts +13 -4
- package/src/fields/field_variable_getter.ts +20 -6
- package/src/fields/field_vertical_separator.ts +5 -1
- package/src/fields/scratch_field_angle.ts +32 -21
- package/src/fields/scratch_field_dropdown.ts +6 -2
- package/src/fields/scratch_field_number.ts +22 -13
- package/src/fields/scratch_field_variable.ts +26 -12
- package/src/flyout_checkbox_icon.ts +9 -5
- package/src/glows.ts +5 -5
- package/src/index.ts +21 -11
- package/src/procedures.ts +92 -42
- package/src/recyclable_block_flyout_inflater.ts +5 -4
- package/src/renderer/cat/cat_face.ts +1 -1
- package/src/renderer/cat/drawer.ts +4 -1
- package/src/renderer/constants.ts +19 -14
- package/src/renderer/drawer.ts +2 -1
- package/src/renderer/render_info.ts +12 -9
- package/src/renderer/renderer.ts +1 -1
- package/src/scratch_blocks_utils.ts +0 -2
- package/src/scratch_c_block_wrap.ts +108 -0
- package/src/scratch_comment_bubble.ts +30 -19
- package/src/scratch_comment_icon.ts +9 -12
- package/src/scratch_connection_checker.ts +1 -2
- package/src/scratch_continuous_category.ts +20 -11
- package/src/scratch_continuous_toolbox.ts +12 -3
- package/src/scratch_dragger.ts +2 -2
- package/src/scratch_variable_map.ts +1 -1
- package/src/status_indicator_label.ts +13 -9
- package/src/status_indicator_label_flyout_inflater.ts +2 -1
- package/src/variables.ts +21 -14
- package/src/workspace_block_lookup.ts +14 -0
- package/src/xml.ts +1 -1
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +1 -1
- package/vitest.config.ts +35 -0
- package/dist/types/tests/blocks/logic_ternary_test.d.ts +0 -13
- package/dist/types/tests/blocks/logic_ternary_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/block_test.d.ts +0 -4
- package/dist/types/tests/jsunit/block_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/connection_db_test.d.ts +0 -25
- package/dist/types/tests/jsunit/connection_db_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/connection_test.d.ts +0 -39
- package/dist/types/tests/jsunit/connection_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/db_test.d.ts +0 -7
- package/dist/types/tests/jsunit/db_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/event_test.d.ts +0 -76
- package/dist/types/tests/jsunit/event_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/extensions_test.d.ts +0 -18
- package/dist/types/tests/jsunit/extensions_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/field_angle_test.d.ts +0 -3
- package/dist/types/tests/jsunit/field_angle_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/field_number_test.d.ts +0 -3
- package/dist/types/tests/jsunit/field_number_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/field_test.d.ts +0 -8
- package/dist/types/tests/jsunit/field_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/field_variable_getter_test.d.ts +0 -5
- package/dist/types/tests/jsunit/field_variable_getter_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/field_variable_test.d.ts +0 -19
- package/dist/types/tests/jsunit/field_variable_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/generator_test.d.ts +0 -2
- package/dist/types/tests/jsunit/generator_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/gesture_test.d.ts +0 -10
- package/dist/types/tests/jsunit/gesture_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/input_test.d.ts +0 -9
- package/dist/types/tests/jsunit/input_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/json_test.d.ts +0 -11
- package/dist/types/tests/jsunit/json_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/names_test.d.ts +0 -5
- package/dist/types/tests/jsunit/names_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/procedure_test.d.ts +0 -15
- package/dist/types/tests/jsunit/procedure_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/scratch_block_comment_test.d.ts +0 -14
- package/dist/types/tests/jsunit/scratch_block_comment_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/svg_test.d.ts +0 -14
- package/dist/types/tests/jsunit/svg_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/test_runner.d.ts +0 -2
- package/dist/types/tests/jsunit/test_runner.d.ts.map +0 -1
- package/dist/types/tests/jsunit/test_utilities.d.ts +0 -50
- package/dist/types/tests/jsunit/test_utilities.d.ts.map +0 -1
- package/dist/types/tests/jsunit/utils_test.d.ts +0 -10
- package/dist/types/tests/jsunit/utils_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/variable_map_test.d.ts +0 -28
- package/dist/types/tests/jsunit/variable_map_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/variable_model_test.d.ts +0 -14
- package/dist/types/tests/jsunit/variable_model_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/widget_div_test.d.ts +0 -37
- package/dist/types/tests/jsunit/widget_div_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/workspace_comment_test.d.ts +0 -13
- package/dist/types/tests/jsunit/workspace_comment_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/workspace_test.d.ts +0 -22
- package/dist/types/tests/jsunit/workspace_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/workspace_undo_redo_test.d.ts +0 -33
- package/dist/types/tests/jsunit/workspace_undo_redo_test.d.ts.map +0 -1
- package/dist/types/tests/jsunit/xml_test.d.ts +0 -55
- package/dist/types/tests/jsunit/xml_test.d.ts.map +0 -1
- package/dist/types/tests/workspace_svg/workspace_svg_test.d.ts +0 -12
- package/dist/types/tests/workspace_svg/workspace_svg_test.d.ts.map +0 -1
- 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):
|
|
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;
|
|
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
|
|
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(
|
|
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;IACH,cAAc,EAAE,OAAO,CAAC,aAAa,CAAC,IAAI,CAAA;IAE1C;;OAEG;IACH,MAAM,CAAC,oBAAoB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,
|
|
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;IACH,cAAc,EAAE,OAAO,CAAC,aAAa,CAAC,IAAI,CAAA;IAE1C;;OAEG;IACH,MAAM,CAAC,oBAAoB,EAAE,CAAC,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,CAAO;IAE1E;;;;;OAKG;gBAED,SAAS,EAAE,OAAO,CAAC,YAAY,EAC/B,eAAe,EAAE,OAAO,CAAC,YAAY,EACrC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS;IA0DvC;;OAEG;IACH,aAAa;IAWb;;;;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;
|
|
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.
|
|
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,MAAM,EACpB,QAAQ,EAAE,CACR,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EAAE,EACxB,eAAe,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,KACpD,IAAI,EACT,KAAK,CAAC,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,
|
|
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,MAAM,EACpB,QAAQ,EAAE,CACR,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EAAE,EACxB,eAAe,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,KACpD,IAAI,EACT,KAAK,CAAC,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
|
-
|
|
21
|
-
'@typescript-eslint/no-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
'@typescript-eslint/no-
|
|
37
|
-
'@typescript-eslint/no-
|
|
38
|
-
'@typescript-eslint/no-
|
|
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.
|
|
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": "
|
|
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.
|
|
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"
|
package/src/block_reporting.ts
CHANGED
|
@@ -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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
}
|
package/src/blocks/control.ts
CHANGED
|
@@ -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
|
|
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
|
|
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_
|
|
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
|
|
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
|
|
275
|
+
const ws = this.workspace.options.parentWorkspace ?? this.workspace
|
|
276
276
|
this.jsonInit({
|
|
277
277
|
message0: Blockly.Msg.CONTROL_WHILE,
|
|
278
278
|
message1: '%1',
|
package/src/blocks/event.ts
CHANGED
|
@@ -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
|
|
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,
|
package/src/blocks/motion.ts
CHANGED
|
@@ -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
|
|
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
|
|
69
|
+
const ws = this.workspace.options.parentWorkspace ?? this.workspace
|
|
70
70
|
this.jsonInit({
|
|
71
71
|
message0: Blockly.Msg.MOTION_TURNLEFT,
|
|
72
72
|
args0: [
|