scratch-blocks 2.0.1 → 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.
- package/AGENTS.md +140 -0
- package/commitlint.config.js +2 -2
- package/dist/main.mjs +1 -2
- package/dist/types/msg/scratch_msgs.d.ts.map +1 -1
- package/dist/types/src/block_reporting.d.ts.map +1 -1
- package/dist/types/src/blocks/colour.d.ts +0 -19
- package/dist/types/src/blocks/colour.d.ts.map +1 -1
- package/dist/types/src/blocks/control.d.ts +0 -19
- package/dist/types/src/blocks/control.d.ts.map +1 -1
- package/dist/types/src/blocks/data.d.ts +0 -19
- package/dist/types/src/blocks/data.d.ts.map +1 -1
- package/dist/types/src/blocks/event.d.ts +0 -19
- package/dist/types/src/blocks/event.d.ts.map +1 -1
- package/dist/types/src/blocks/looks.d.ts +0 -19
- package/dist/types/src/blocks/looks.d.ts.map +1 -1
- package/dist/types/src/blocks/math.d.ts +0 -19
- package/dist/types/src/blocks/math.d.ts.map +1 -1
- package/dist/types/src/blocks/matrix.d.ts +0 -19
- package/dist/types/src/blocks/matrix.d.ts.map +1 -1
- package/dist/types/src/blocks/motion.d.ts +0 -19
- package/dist/types/src/blocks/motion.d.ts.map +1 -1
- package/dist/types/src/blocks/note.d.ts +0 -19
- package/dist/types/src/blocks/note.d.ts.map +1 -1
- package/dist/types/src/blocks/operators.d.ts +0 -19
- package/dist/types/src/blocks/operators.d.ts.map +1 -1
- package/dist/types/src/blocks/procedures.d.ts +6 -9
- package/dist/types/src/blocks/procedures.d.ts.map +1 -1
- package/dist/types/src/blocks/sensing.d.ts +0 -19
- package/dist/types/src/blocks/sensing.d.ts.map +1 -1
- package/dist/types/src/blocks/sound.d.ts +0 -19
- package/dist/types/src/blocks/sound.d.ts.map +1 -1
- package/dist/types/src/blocks/text.d.ts +0 -19
- package/dist/types/src/blocks/text.d.ts.map +1 -1
- package/dist/types/src/blocks/vertical_extensions.d.ts +0 -19
- package/dist/types/src/blocks/vertical_extensions.d.ts.map +1 -1
- package/dist/types/src/checkable_continuous_flyout.d.ts +2 -7
- package/dist/types/src/checkable_continuous_flyout.d.ts.map +1 -1
- package/dist/types/src/checkbox_bubble.d.ts +13 -12
- 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/constants.d.ts +0 -7
- package/dist/types/src/constants.d.ts.map +1 -1
- package/dist/types/src/context_menu_items.d.ts +0 -5
- package/dist/types/src/context_menu_items.d.ts.map +1 -1
- package/dist/types/src/data_category.d.ts +2 -4
- package/dist/types/src/data_category.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_base.d.ts +2 -3
- package/dist/types/src/events/events_block_comment_base.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_change.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_change.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_collapse.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_collapse.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_create.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_create.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_delete.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_delete.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_move.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_move.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_resize.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_resize.d.ts.map +1 -1
- package/dist/types/src/events/events_block_drag_end.d.ts +1 -2
- 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 -2
- package/dist/types/src/events/events_block_drag_outside.d.ts.map +1 -1
- package/dist/types/src/events/events_scratch_variable_create.d.ts +0 -5
- package/dist/types/src/events/events_scratch_variable_create.d.ts.map +1 -1
- package/dist/types/src/fields/field_colour_slider.d.ts +7 -31
- package/dist/types/src/fields/field_colour_slider.d.ts.map +1 -1
- package/dist/types/src/fields/field_matrix.d.ts +0 -19
- package/dist/types/src/fields/field_matrix.d.ts.map +1 -1
- package/dist/types/src/fields/field_note.d.ts +8 -23
- package/dist/types/src/fields/field_note.d.ts.map +1 -1
- package/dist/types/src/fields/field_textinput_removable.d.ts +2 -4
- package/dist/types/src/fields/field_textinput_removable.d.ts.map +1 -1
- package/dist/types/src/fields/field_variable_getter.d.ts +0 -19
- package/dist/types/src/fields/field_variable_getter.d.ts.map +1 -1
- package/dist/types/src/fields/field_vertical_separator.d.ts +0 -19
- package/dist/types/src/fields/field_vertical_separator.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_angle.d.ts +0 -19
- package/dist/types/src/fields/scratch_field_angle.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_dropdown.d.ts +0 -5
- package/dist/types/src/fields/scratch_field_dropdown.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_number.d.ts +0 -19
- package/dist/types/src/fields/scratch_field_number.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_variable.d.ts +5 -8
- package/dist/types/src/fields/scratch_field_variable.d.ts.map +1 -1
- package/dist/types/src/flyout_checkbox_icon.d.ts +2 -3
- package/dist/types/src/flyout_checkbox_icon.d.ts.map +1 -1
- package/dist/types/src/glows.d.ts +1 -3
- package/dist/types/src/glows.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +50 -51
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/procedures.d.ts +6 -8
- package/dist/types/src/procedures.d.ts.map +1 -1
- package/dist/types/src/recyclable_block_flyout_inflater.d.ts +3 -5
- package/dist/types/src/recyclable_block_flyout_inflater.d.ts.map +1 -1
- package/dist/types/src/renderer/bowler_hat.d.ts +2 -3
- package/dist/types/src/renderer/bowler_hat.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/cat_face.d.ts +6 -5
- package/dist/types/src/renderer/cat/cat_face.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/constants.d.ts +2 -2
- package/dist/types/src/renderer/cat/constants.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/drawer.d.ts +4 -5
- package/dist/types/src/renderer/cat/drawer.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/path_object.d.ts +2 -3
- package/dist/types/src/renderer/cat/path_object.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/render_info.d.ts +3 -4
- package/dist/types/src/renderer/cat/render_info.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/renderer.d.ts +7 -8
- package/dist/types/src/renderer/cat/renderer.d.ts.map +1 -1
- package/dist/types/src/renderer/constants.d.ts +41 -0
- package/dist/types/src/renderer/constants.d.ts.map +1 -0
- package/dist/types/src/renderer/drawer.d.ts +7 -6
- package/dist/types/src/renderer/drawer.d.ts.map +1 -1
- package/dist/types/src/renderer/path_object.d.ts +1 -3
- package/dist/types/src/renderer/path_object.d.ts.map +1 -1
- package/dist/types/src/renderer/render_info.d.ts +3 -4
- package/dist/types/src/renderer/render_info.d.ts.map +1 -1
- package/dist/types/src/renderer/renderer.d.ts +9 -16
- package/dist/types/src/renderer/renderer.d.ts.map +1 -1
- package/dist/types/src/scratch_block_paster.d.ts +0 -5
- package/dist/types/src/scratch_block_paster.d.ts.map +1 -1
- package/dist/types/src/scratch_blocks_utils.d.ts +0 -20
- package/dist/types/src/scratch_blocks_utils.d.ts.map +1 -1
- package/dist/types/src/scratch_comment_bubble.d.ts +3 -6
- package/dist/types/src/scratch_comment_bubble.d.ts.map +1 -1
- package/dist/types/src/scratch_comment_icon.d.ts +3 -4
- package/dist/types/src/scratch_comment_icon.d.ts.map +1 -1
- package/dist/types/src/scratch_connection_checker.d.ts +0 -5
- package/dist/types/src/scratch_connection_checker.d.ts.map +1 -1
- package/dist/types/src/scratch_continuous_category.d.ts +5 -5
- package/dist/types/src/scratch_continuous_category.d.ts.map +1 -1
- package/dist/types/src/scratch_continuous_toolbox.d.ts +3 -6
- package/dist/types/src/scratch_continuous_toolbox.d.ts.map +1 -1
- package/dist/types/src/scratch_dragger.d.ts +2 -11
- package/dist/types/src/scratch_dragger.d.ts.map +1 -1
- package/dist/types/src/scratch_insertion_marker_previewer.d.ts +0 -5
- package/dist/types/src/scratch_insertion_marker_previewer.d.ts.map +1 -1
- package/dist/types/src/scratch_variable_map.d.ts +0 -5
- package/dist/types/src/scratch_variable_map.d.ts.map +1 -1
- package/dist/types/src/scratch_variable_model.d.ts +2 -3
- package/dist/types/src/scratch_variable_model.d.ts.map +1 -1
- package/dist/types/src/scratch_zoom_controls.d.ts +4 -6
- package/dist/types/src/scratch_zoom_controls.d.ts.map +1 -1
- package/dist/types/src/shadows.d.ts +2 -2
- package/dist/types/src/shadows.d.ts.map +1 -1
- package/dist/types/src/status_indicator_label.d.ts +4 -6
- package/dist/types/src/status_indicator_label.d.ts.map +1 -1
- package/dist/types/src/status_indicator_label_flyout_inflater.d.ts +1 -6
- package/dist/types/src/status_indicator_label_flyout_inflater.d.ts.map +1 -1
- package/dist/types/src/variables.d.ts +4 -8
- package/dist/types/src/variables.d.ts.map +1 -1
- package/dist/types/src/xml.d.ts +2 -3
- package/dist/types/src/xml.d.ts.map +1 -1
- package/dist/types/tests/jsunit/block_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/connection_db_test.d.ts +3 -3
- package/dist/types/tests/jsunit/connection_db_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/connection_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/event_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/extensions_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/field_number_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/field_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/field_variable_getter_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/field_variable_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/gesture_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/input_test.d.ts +1 -0
- package/dist/types/tests/jsunit/input_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/json_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/names_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/procedure_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/scratch_block_comment_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/svg_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/test_utilities.d.ts.map +1 -1
- package/dist/types/tests/jsunit/utils_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/variable_map_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/variable_model_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/widget_div_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/workspace_comment_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/workspace_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/workspace_undo_redo_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/xml_test.d.ts.map +1 -1
- package/dist/types/tests/workspace_svg/workspace_svg_test.d.ts.map +1 -1
- package/eslint.config.mjs +69 -0
- package/i18n/create_scratch_msgs.js +44 -45
- package/i18n/js_to_json.js +40 -32
- package/i18n/json_to_js.js +37 -37
- package/i18n/sync_tx_translations.js +64 -65
- package/i18n/test_scratch_msgs.js +66 -63
- package/msg/js/en.js +289 -287
- package/msg/json/en.json +284 -284
- package/msg/messages.js +289 -287
- package/msg/scratch_msgs.js +22959 -22970
- package/package.json +13 -10
- package/prettier.config.mjs +3 -0
- package/release.config.js +7 -7
- package/renovate.json5 +7 -9
- package/src/block_reporting.ts +16 -19
- package/src/blocks/colour.ts +12 -15
- package/src/blocks/control.ts +171 -174
- package/src/blocks/data.ts +233 -272
- package/src/blocks/event.ts +121 -123
- package/src/blocks/looks.ts +165 -167
- package/src/blocks/math.ts +44 -46
- package/src/blocks/matrix.ts +11 -13
- package/src/blocks/motion.ts +151 -153
- package/src/blocks/note.ts +11 -13
- package/src/blocks/operators.ts +158 -160
- package/src/blocks/procedures.ts +421 -511
- package/src/blocks/sensing.ts +163 -165
- package/src/blocks/sound.ts +58 -60
- package/src/blocks/text.ts +10 -12
- package/src/blocks/vertical_extensions.ts +86 -102
- package/src/checkable_continuous_flyout.ts +25 -42
- package/src/checkbox_bubble.ts +83 -100
- package/src/colours.ts +35 -37
- package/src/constants.ts +22 -29
- package/src/context_menu_items.ts +59 -84
- package/src/css.ts +3 -4
- package/src/data_category.ts +137 -251
- package/src/events/events_block_comment_base.ts +23 -30
- package/src/events/events_block_comment_change.ts +21 -42
- package/src/events/events_block_comment_collapse.ts +27 -36
- package/src/events/events_block_comment_create.ts +32 -46
- package/src/events/events_block_comment_delete.ts +12 -19
- package/src/events/events_block_comment_move.ts +27 -52
- package/src/events/events_block_comment_resize.ts +28 -55
- package/src/events/events_block_drag_end.ts +16 -26
- package/src/events/events_block_drag_outside.ts +12 -22
- package/src/events/events_scratch_variable_create.ts +37 -42
- package/src/fields/field_colour_slider.ts +186 -216
- package/src/fields/field_matrix.ts +202 -270
- package/src/fields/field_note.ts +277 -375
- package/src/fields/field_textinput_removable.ts +25 -40
- package/src/fields/field_variable_getter.ts +26 -31
- package/src/fields/field_vertical_separator.ts +19 -24
- package/src/fields/scratch_field_angle.ts +151 -187
- package/src/fields/scratch_field_dropdown.ts +15 -19
- package/src/fields/scratch_field_number.ts +125 -181
- package/src/fields/scratch_field_variable.ts +57 -75
- package/src/flyout_checkbox_icon.ts +18 -28
- package/src/glows.ts +52 -59
- package/src/index.ts +119 -133
- package/src/procedures.ts +150 -209
- package/src/recyclable_block_flyout_inflater.ts +14 -25
- package/src/renderer/bowler_hat.ts +6 -8
- package/src/renderer/cat/cat_face.ts +98 -99
- package/src/renderer/cat/constants.ts +67 -87
- package/src/renderer/cat/drawer.ts +21 -27
- package/src/renderer/cat/path_object.ts +3 -5
- package/src/renderer/cat/render_info.ts +5 -8
- package/src/renderer/cat/renderer.ts +12 -16
- package/src/renderer/constants.ts +34 -49
- package/src/renderer/drawer.ts +35 -51
- package/src/renderer/path_object.ts +4 -10
- package/src/renderer/render_info.ts +39 -56
- package/src/renderer/renderer.ts +17 -30
- package/src/scratch_block_paster.ts +12 -20
- package/src/scratch_blocks_utils.ts +4 -7
- package/src/scratch_comment_bubble.ts +76 -105
- package/src/scratch_comment_icon.ts +75 -124
- package/src/scratch_connection_checker.ts +7 -17
- package/src/scratch_continuous_category.ts +24 -28
- package/src/scratch_continuous_toolbox.ts +20 -27
- package/src/scratch_dragger.ts +42 -81
- package/src/scratch_insertion_marker_previewer.ts +6 -11
- package/src/scratch_variable_map.ts +5 -12
- package/src/scratch_variable_model.ts +6 -13
- package/src/scratch_zoom_controls.ts +101 -156
- package/src/shadows.ts +32 -37
- package/src/status_indicator_label.ts +54 -67
- package/src/status_indicator_label_flyout_inflater.ts +11 -21
- package/src/variables.ts +92 -141
- package/src/xml.ts +21 -35
- package/tsconfig.json +3 -7
- package/types/continuous-toolbox.d.ts +1 -1
- package/dist/main.mjs.LICENSE.txt +0 -163
package/src/blocks/sound.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license
|
|
3
2
|
* Visual Blocks Editor
|
|
4
3
|
*
|
|
5
4
|
* Copyright 2016 Massachusetts Institute of Technology
|
|
@@ -17,15 +16,14 @@
|
|
|
17
16
|
* See the License for the specific language governing permissions and
|
|
18
17
|
* limitations under the License.
|
|
19
18
|
*/
|
|
20
|
-
|
|
21
|
-
import * as Blockly from "blockly/core";
|
|
19
|
+
import * as Blockly from 'blockly/core'
|
|
22
20
|
|
|
23
21
|
/**
|
|
24
22
|
* Sound effects drop-down menu. Populated dynamically by scratch-gui.
|
|
25
23
|
*/
|
|
26
|
-
Blockly.Blocks
|
|
24
|
+
Blockly.Blocks.sound_sounds_menu = {}
|
|
27
25
|
|
|
28
|
-
Blockly.Blocks
|
|
26
|
+
Blockly.Blocks.sound_play = {
|
|
29
27
|
/**
|
|
30
28
|
* Block to play sound.
|
|
31
29
|
*/
|
|
@@ -34,16 +32,16 @@ Blockly.Blocks["sound_play"] = {
|
|
|
34
32
|
message0: Blockly.Msg.SOUND_PLAY,
|
|
35
33
|
args0: [
|
|
36
34
|
{
|
|
37
|
-
type:
|
|
38
|
-
name:
|
|
35
|
+
type: 'input_value',
|
|
36
|
+
name: 'SOUND_MENU',
|
|
39
37
|
},
|
|
40
38
|
],
|
|
41
|
-
extensions: [
|
|
42
|
-
})
|
|
39
|
+
extensions: ['colours_sounds', 'shape_statement'],
|
|
40
|
+
})
|
|
43
41
|
},
|
|
44
|
-
}
|
|
42
|
+
}
|
|
45
43
|
|
|
46
|
-
Blockly.Blocks
|
|
44
|
+
Blockly.Blocks.sound_playuntildone = {
|
|
47
45
|
/**
|
|
48
46
|
* Block to play sound until done.
|
|
49
47
|
*/
|
|
@@ -52,28 +50,28 @@ Blockly.Blocks["sound_playuntildone"] = {
|
|
|
52
50
|
message0: Blockly.Msg.SOUND_PLAYUNTILDONE,
|
|
53
51
|
args0: [
|
|
54
52
|
{
|
|
55
|
-
type:
|
|
56
|
-
name:
|
|
53
|
+
type: 'input_value',
|
|
54
|
+
name: 'SOUND_MENU',
|
|
57
55
|
},
|
|
58
56
|
],
|
|
59
|
-
extensions: [
|
|
60
|
-
})
|
|
57
|
+
extensions: ['colours_sounds', 'shape_statement'],
|
|
58
|
+
})
|
|
61
59
|
},
|
|
62
|
-
}
|
|
60
|
+
}
|
|
63
61
|
|
|
64
|
-
Blockly.Blocks
|
|
62
|
+
Blockly.Blocks.sound_stopallsounds = {
|
|
65
63
|
/**
|
|
66
64
|
* Block to stop all sounds
|
|
67
65
|
*/
|
|
68
66
|
init: function (this: Blockly.Block) {
|
|
69
67
|
this.jsonInit({
|
|
70
68
|
message0: Blockly.Msg.SOUND_STOPALLSOUNDS,
|
|
71
|
-
extensions: [
|
|
72
|
-
})
|
|
69
|
+
extensions: ['colours_sounds', 'shape_statement'],
|
|
70
|
+
})
|
|
73
71
|
},
|
|
74
|
-
}
|
|
72
|
+
}
|
|
75
73
|
|
|
76
|
-
Blockly.Blocks
|
|
74
|
+
Blockly.Blocks.sound_seteffectto = {
|
|
77
75
|
/**
|
|
78
76
|
* Block to set the audio effect
|
|
79
77
|
*/
|
|
@@ -82,24 +80,24 @@ Blockly.Blocks["sound_seteffectto"] = {
|
|
|
82
80
|
message0: Blockly.Msg.SOUND_SETEFFECTO,
|
|
83
81
|
args0: [
|
|
84
82
|
{
|
|
85
|
-
type:
|
|
86
|
-
name:
|
|
83
|
+
type: 'field_dropdown',
|
|
84
|
+
name: 'EFFECT',
|
|
87
85
|
options: [
|
|
88
|
-
[Blockly.Msg.SOUND_EFFECTS_PITCH,
|
|
89
|
-
[Blockly.Msg.SOUND_EFFECTS_PAN,
|
|
86
|
+
[Blockly.Msg.SOUND_EFFECTS_PITCH, 'PITCH'],
|
|
87
|
+
[Blockly.Msg.SOUND_EFFECTS_PAN, 'PAN'],
|
|
90
88
|
],
|
|
91
89
|
},
|
|
92
90
|
{
|
|
93
|
-
type:
|
|
94
|
-
name:
|
|
91
|
+
type: 'input_value',
|
|
92
|
+
name: 'VALUE',
|
|
95
93
|
},
|
|
96
94
|
],
|
|
97
|
-
extensions: [
|
|
98
|
-
})
|
|
95
|
+
extensions: ['colours_sounds', 'shape_statement'],
|
|
96
|
+
})
|
|
99
97
|
},
|
|
100
|
-
}
|
|
98
|
+
}
|
|
101
99
|
|
|
102
|
-
Blockly.Blocks
|
|
100
|
+
Blockly.Blocks.sound_changeeffectby = {
|
|
103
101
|
/**
|
|
104
102
|
* Block to change the audio effect
|
|
105
103
|
*/
|
|
@@ -108,36 +106,36 @@ Blockly.Blocks["sound_changeeffectby"] = {
|
|
|
108
106
|
message0: Blockly.Msg.SOUND_CHANGEEFFECTBY,
|
|
109
107
|
args0: [
|
|
110
108
|
{
|
|
111
|
-
type:
|
|
112
|
-
name:
|
|
109
|
+
type: 'field_dropdown',
|
|
110
|
+
name: 'EFFECT',
|
|
113
111
|
options: [
|
|
114
|
-
[Blockly.Msg.SOUND_EFFECTS_PITCH,
|
|
115
|
-
[Blockly.Msg.SOUND_EFFECTS_PAN,
|
|
112
|
+
[Blockly.Msg.SOUND_EFFECTS_PITCH, 'PITCH'],
|
|
113
|
+
[Blockly.Msg.SOUND_EFFECTS_PAN, 'PAN'],
|
|
116
114
|
],
|
|
117
115
|
},
|
|
118
116
|
{
|
|
119
|
-
type:
|
|
120
|
-
name:
|
|
117
|
+
type: 'input_value',
|
|
118
|
+
name: 'VALUE',
|
|
121
119
|
},
|
|
122
120
|
],
|
|
123
|
-
extensions: [
|
|
124
|
-
})
|
|
121
|
+
extensions: ['colours_sounds', 'shape_statement'],
|
|
122
|
+
})
|
|
125
123
|
},
|
|
126
|
-
}
|
|
124
|
+
}
|
|
127
125
|
|
|
128
|
-
Blockly.Blocks
|
|
126
|
+
Blockly.Blocks.sound_cleareffects = {
|
|
129
127
|
/**
|
|
130
128
|
* Block to clear audio effects
|
|
131
129
|
*/
|
|
132
130
|
init: function (this: Blockly.Block) {
|
|
133
131
|
this.jsonInit({
|
|
134
132
|
message0: Blockly.Msg.SOUND_CLEAREFFECTS,
|
|
135
|
-
extensions: [
|
|
136
|
-
})
|
|
133
|
+
extensions: ['colours_sounds', 'shape_statement'],
|
|
134
|
+
})
|
|
137
135
|
},
|
|
138
|
-
}
|
|
136
|
+
}
|
|
139
137
|
|
|
140
|
-
Blockly.Blocks
|
|
138
|
+
Blockly.Blocks.sound_changevolumeby = {
|
|
141
139
|
/**
|
|
142
140
|
* Block to change the sprite's volume by a certain value
|
|
143
141
|
*/
|
|
@@ -146,16 +144,16 @@ Blockly.Blocks["sound_changevolumeby"] = {
|
|
|
146
144
|
message0: Blockly.Msg.SOUND_CHANGEVOLUMEBY,
|
|
147
145
|
args0: [
|
|
148
146
|
{
|
|
149
|
-
type:
|
|
150
|
-
name:
|
|
147
|
+
type: 'input_value',
|
|
148
|
+
name: 'VOLUME',
|
|
151
149
|
},
|
|
152
150
|
],
|
|
153
|
-
extensions: [
|
|
154
|
-
})
|
|
151
|
+
extensions: ['colours_sounds', 'shape_statement'],
|
|
152
|
+
})
|
|
155
153
|
},
|
|
156
|
-
}
|
|
154
|
+
}
|
|
157
155
|
|
|
158
|
-
Blockly.Blocks
|
|
156
|
+
Blockly.Blocks.sound_setvolumeto = {
|
|
159
157
|
/**
|
|
160
158
|
* Block to set the sprite's volume to a certain percent
|
|
161
159
|
*/
|
|
@@ -164,23 +162,23 @@ Blockly.Blocks["sound_setvolumeto"] = {
|
|
|
164
162
|
message0: Blockly.Msg.SOUND_SETVOLUMETO,
|
|
165
163
|
args0: [
|
|
166
164
|
{
|
|
167
|
-
type:
|
|
168
|
-
name:
|
|
165
|
+
type: 'input_value',
|
|
166
|
+
name: 'VOLUME',
|
|
169
167
|
},
|
|
170
168
|
],
|
|
171
|
-
extensions: [
|
|
172
|
-
})
|
|
169
|
+
extensions: ['colours_sounds', 'shape_statement'],
|
|
170
|
+
})
|
|
173
171
|
},
|
|
174
|
-
}
|
|
172
|
+
}
|
|
175
173
|
|
|
176
|
-
Blockly.Blocks
|
|
174
|
+
Blockly.Blocks.sound_volume = {
|
|
177
175
|
/**
|
|
178
176
|
* Block to report volume
|
|
179
177
|
*/
|
|
180
178
|
init: function (this: Blockly.Block) {
|
|
181
179
|
this.jsonInit({
|
|
182
180
|
message0: Blockly.Msg.SOUND_VOLUME,
|
|
183
|
-
extensions: [
|
|
184
|
-
})
|
|
181
|
+
extensions: ['colours_sounds', 'output_number', 'monitor_block'],
|
|
182
|
+
})
|
|
185
183
|
},
|
|
186
|
-
}
|
|
184
|
+
}
|
package/src/blocks/text.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license
|
|
3
2
|
* Visual Blocks Editor
|
|
4
3
|
*
|
|
5
4
|
* Copyright 2012 Google Inc.
|
|
@@ -17,28 +16,27 @@
|
|
|
17
16
|
* See the License for the specific language governing permissions and
|
|
18
17
|
* limitations under the License.
|
|
19
18
|
*/
|
|
20
|
-
|
|
21
19
|
/**
|
|
22
|
-
* @
|
|
20
|
+
* @file Text blocks for Blockly.
|
|
23
21
|
* @author fraser@google.com (Neil Fraser)
|
|
24
22
|
*/
|
|
25
|
-
import * as Blockly from
|
|
23
|
+
import * as Blockly from 'blockly/core'
|
|
26
24
|
|
|
27
|
-
Blockly.Blocks
|
|
25
|
+
Blockly.Blocks.text = {
|
|
28
26
|
/**
|
|
29
27
|
* Block for text value.
|
|
30
28
|
*/
|
|
31
29
|
init: function (this: Blockly.Block) {
|
|
32
30
|
this.jsonInit({
|
|
33
|
-
message0:
|
|
31
|
+
message0: '%1',
|
|
34
32
|
args0: [
|
|
35
33
|
{
|
|
36
|
-
type:
|
|
37
|
-
name:
|
|
34
|
+
type: 'field_input',
|
|
35
|
+
name: 'TEXT',
|
|
38
36
|
},
|
|
39
37
|
],
|
|
40
|
-
output:
|
|
41
|
-
extensions: [
|
|
42
|
-
})
|
|
38
|
+
output: 'String',
|
|
39
|
+
extensions: ['colours_textfield'],
|
|
40
|
+
})
|
|
43
41
|
},
|
|
44
|
-
}
|
|
42
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license
|
|
3
2
|
* Visual Blocks Editor
|
|
4
3
|
*
|
|
5
4
|
* Copyright 2017 Google Inc.
|
|
@@ -17,41 +16,39 @@
|
|
|
17
16
|
* See the License for the specific language governing permissions and
|
|
18
17
|
* limitations under the License.
|
|
19
18
|
*/
|
|
20
|
-
|
|
21
19
|
/**
|
|
22
|
-
* @
|
|
20
|
+
* @file Extensions for vertical blocks in scratch-blocks.
|
|
23
21
|
* The following extensions can be used to describe a block in Scratch terms.
|
|
24
22
|
* For instance, a block in the operators colour scheme with a number output
|
|
25
23
|
* would have the "colours_operators" and "output_number" extensions.
|
|
26
24
|
* @author fenichel@google.com (Rachel Fenichel)
|
|
27
25
|
*/
|
|
28
|
-
import * as Blockly from
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import {
|
|
26
|
+
import * as Blockly from 'blockly/core'
|
|
27
|
+
import * as Constants from '../constants'
|
|
28
|
+
import { FlyoutCheckboxIcon } from '../flyout_checkbox_icon'
|
|
29
|
+
import { ScratchProcedures } from '../procedures'
|
|
32
30
|
|
|
33
31
|
/**
|
|
34
32
|
* Helper function that generates an extension based on a category name.
|
|
35
33
|
* The generated function will set the block's style based on the category name.
|
|
36
|
-
*
|
|
37
34
|
* @param category The name of the category to set colours for.
|
|
38
|
-
* @
|
|
35
|
+
* @returns An extension function that sets colours based on the given category.
|
|
39
36
|
*/
|
|
40
37
|
const colourHelper = function (category: string): () => void {
|
|
41
38
|
/**
|
|
42
39
|
* Set the block style on this block for the given category.
|
|
43
40
|
*/
|
|
44
41
|
return function (this: Blockly.Block) {
|
|
45
|
-
this.setStyle(category)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
42
|
+
this.setStyle(category)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
48
45
|
|
|
49
46
|
/**
|
|
50
47
|
* Extension to set the colours of a text field, which are all the same.
|
|
51
48
|
*/
|
|
52
49
|
const COLOUR_TEXTFIELD = function (this: Blockly.Block) {
|
|
53
|
-
colourHelper(
|
|
54
|
-
}
|
|
50
|
+
colourHelper('textField').apply(this)
|
|
51
|
+
}
|
|
55
52
|
|
|
56
53
|
/**
|
|
57
54
|
* Extension to make a block fit into a stack of statements, regardless of its
|
|
@@ -59,10 +56,10 @@ const COLOUR_TEXTFIELD = function (this: Blockly.Block) {
|
|
|
59
56
|
* connection and have inline inputs.
|
|
60
57
|
*/
|
|
61
58
|
const SHAPE_STATEMENT = function (this: Blockly.Block) {
|
|
62
|
-
this.setInputsInline(true)
|
|
63
|
-
this.setPreviousStatement(true, null)
|
|
64
|
-
this.setNextStatement(true, null)
|
|
65
|
-
}
|
|
59
|
+
this.setInputsInline(true)
|
|
60
|
+
this.setPreviousStatement(true, null)
|
|
61
|
+
this.setNextStatement(true, null)
|
|
62
|
+
}
|
|
66
63
|
|
|
67
64
|
/**
|
|
68
65
|
* Extension to make a block be shaped as a hat block, regardless of its
|
|
@@ -70,20 +67,20 @@ const SHAPE_STATEMENT = function (this: Blockly.Block) {
|
|
|
70
67
|
* inputs, but have no previous connection.
|
|
71
68
|
*/
|
|
72
69
|
const SHAPE_HAT = function (this: Blockly.Block) {
|
|
73
|
-
this.setInputsInline(true)
|
|
74
|
-
this.setNextStatement(true, null)
|
|
75
|
-
this.hat =
|
|
76
|
-
}
|
|
70
|
+
this.setInputsInline(true)
|
|
71
|
+
this.setNextStatement(true, null)
|
|
72
|
+
this.hat = 'cap'
|
|
73
|
+
}
|
|
77
74
|
|
|
78
75
|
/**
|
|
79
76
|
* Extension to make a block be shaped as a bowler hat block, with rounded
|
|
80
77
|
* corners on both sides and no indentation for statement blocks.
|
|
81
78
|
*/
|
|
82
79
|
const SHAPE_BOWLER_HAT = function (this: Blockly.Block) {
|
|
83
|
-
this.setInputsInline(true)
|
|
84
|
-
this.setNextStatement(true, null)
|
|
85
|
-
this.hat =
|
|
86
|
-
}
|
|
80
|
+
this.setInputsInline(true)
|
|
81
|
+
this.setNextStatement(true, null)
|
|
82
|
+
this.hat = 'bowler'
|
|
83
|
+
}
|
|
87
84
|
|
|
88
85
|
/**
|
|
89
86
|
* Extension to make a block be shaped as an end block, regardless of its
|
|
@@ -91,9 +88,9 @@ const SHAPE_BOWLER_HAT = function (this: Blockly.Block) {
|
|
|
91
88
|
* inline inputs, but have no next connection.
|
|
92
89
|
*/
|
|
93
90
|
const SHAPE_END = function (this: Blockly.Block) {
|
|
94
|
-
this.setInputsInline(true)
|
|
95
|
-
this.setPreviousStatement(true, null)
|
|
96
|
-
}
|
|
91
|
+
this.setInputsInline(true)
|
|
92
|
+
this.setPreviousStatement(true, null)
|
|
93
|
+
}
|
|
97
94
|
|
|
98
95
|
/**
|
|
99
96
|
* Extension to make represent a number reporter in Scratch-Blocks.
|
|
@@ -101,10 +98,10 @@ const SHAPE_END = function (this: Blockly.Block) {
|
|
|
101
98
|
* output type.
|
|
102
99
|
*/
|
|
103
100
|
const OUTPUT_NUMBER = function (this: Blockly.Block) {
|
|
104
|
-
this.setInputsInline(true)
|
|
105
|
-
this.setOutputShape(Constants.OUTPUT_SHAPE_ROUND)
|
|
106
|
-
this.setOutput(true,
|
|
107
|
-
}
|
|
101
|
+
this.setInputsInline(true)
|
|
102
|
+
this.setOutputShape(Constants.OUTPUT_SHAPE_ROUND)
|
|
103
|
+
this.setOutput(true, 'Number')
|
|
104
|
+
}
|
|
108
105
|
|
|
109
106
|
/**
|
|
110
107
|
* Extension to make represent a string reporter in Scratch-Blocks.
|
|
@@ -112,10 +109,10 @@ const OUTPUT_NUMBER = function (this: Blockly.Block) {
|
|
|
112
109
|
* output type.
|
|
113
110
|
*/
|
|
114
111
|
const OUTPUT_STRING = function (this: Blockly.Block) {
|
|
115
|
-
this.setInputsInline(true)
|
|
116
|
-
this.setOutputShape(Constants.OUTPUT_SHAPE_ROUND)
|
|
117
|
-
this.setOutput(true,
|
|
118
|
-
}
|
|
112
|
+
this.setInputsInline(true)
|
|
113
|
+
this.setOutputShape(Constants.OUTPUT_SHAPE_ROUND)
|
|
114
|
+
this.setOutput(true, 'String')
|
|
115
|
+
}
|
|
119
116
|
|
|
120
117
|
/**
|
|
121
118
|
* Extension to make represent a boolean reporter in Scratch-Blocks.
|
|
@@ -123,10 +120,10 @@ const OUTPUT_STRING = function (this: Blockly.Block) {
|
|
|
123
120
|
* output type.
|
|
124
121
|
*/
|
|
125
122
|
const OUTPUT_BOOLEAN = function (this: Blockly.Block) {
|
|
126
|
-
this.setInputsInline(true)
|
|
127
|
-
this.setOutputShape(Constants.OUTPUT_SHAPE_HEXAGONAL)
|
|
128
|
-
this.setOutput(true,
|
|
129
|
-
}
|
|
123
|
+
this.setInputsInline(true)
|
|
124
|
+
this.setOutputShape(Constants.OUTPUT_SHAPE_HEXAGONAL)
|
|
125
|
+
this.setOutput(true, 'Boolean')
|
|
126
|
+
}
|
|
130
127
|
|
|
131
128
|
/**
|
|
132
129
|
* Extension to make a block a monitor block, capable of reporting its current
|
|
@@ -134,9 +131,9 @@ const OUTPUT_BOOLEAN = function (this: Blockly.Block) {
|
|
|
134
131
|
* flyout to toggle display of their current value in a chip on the stage.
|
|
135
132
|
*/
|
|
136
133
|
const MONITOR_BLOCK = function (this: Blockly.BlockSvg) {
|
|
137
|
-
this.addIcon(new FlyoutCheckboxIcon(this))
|
|
138
|
-
(this as any).checkboxInFlyout = true
|
|
139
|
-
}
|
|
134
|
+
this.addIcon(new FlyoutCheckboxIcon(this))
|
|
135
|
+
;(this as any).checkboxInFlyout = true
|
|
136
|
+
}
|
|
140
137
|
|
|
141
138
|
/**
|
|
142
139
|
* Mixin to add a context menu for a procedure definition block.
|
|
@@ -146,75 +143,68 @@ const PROCEDURE_DEF_CONTEXTMENU = function (this: Blockly.Block) {
|
|
|
146
143
|
/**
|
|
147
144
|
* Add the "edit" option and removes the "duplicate" option from the context
|
|
148
145
|
* menu.
|
|
149
|
-
*
|
|
150
146
|
* @param menuOptions List of menu options to edit.
|
|
151
147
|
*/
|
|
152
148
|
this.mixin(
|
|
153
149
|
{
|
|
154
150
|
customContextMenu: function (
|
|
155
|
-
menuOptions:
|
|
151
|
+
menuOptions: (
|
|
156
152
|
| Blockly.ContextMenuRegistry.ContextMenuOption
|
|
157
153
|
| Blockly.ContextMenuRegistry.LegacyContextMenuOption
|
|
158
|
-
|
|
154
|
+
)[],
|
|
159
155
|
) {
|
|
160
156
|
// Add the edit option at the end.
|
|
161
|
-
menuOptions.push(ScratchProcedures.makeEditOption(this))
|
|
157
|
+
menuOptions.push(ScratchProcedures.makeEditOption(this))
|
|
162
158
|
|
|
163
159
|
// Find and remove the duplicate option
|
|
164
160
|
for (let i = 0, option; (option = menuOptions[i]); i++) {
|
|
165
161
|
if (option.text == Blockly.Msg.DUPLICATE) {
|
|
166
|
-
menuOptions.splice(i, 1)
|
|
167
|
-
break
|
|
162
|
+
menuOptions.splice(i, 1)
|
|
163
|
+
break
|
|
168
164
|
}
|
|
169
165
|
}
|
|
170
166
|
},
|
|
171
167
|
checkAndDelete: function () {
|
|
172
|
-
const input = this.getInput(
|
|
168
|
+
const input = this.getInput('custom_block')
|
|
173
169
|
// this is the root block, not the shadow block.
|
|
174
|
-
if (input
|
|
175
|
-
const procCode = input.connection.targetBlock().getProcCode()
|
|
176
|
-
const didDelete = ScratchProcedures.deleteProcedureDefCallback(
|
|
177
|
-
procCode,
|
|
178
|
-
this
|
|
179
|
-
);
|
|
170
|
+
if (input?.connection?.targetBlock()) {
|
|
171
|
+
const procCode = input.connection.targetBlock().getProcCode()
|
|
172
|
+
const didDelete = ScratchProcedures.deleteProcedureDefCallback(procCode, this)
|
|
180
173
|
if (!didDelete) {
|
|
181
|
-
alert(Blockly.Msg.PROCEDURE_USED)
|
|
174
|
+
alert(Blockly.Msg.PROCEDURE_USED)
|
|
182
175
|
}
|
|
183
176
|
}
|
|
184
177
|
},
|
|
185
178
|
},
|
|
186
|
-
true
|
|
187
|
-
)
|
|
188
|
-
}
|
|
179
|
+
true,
|
|
180
|
+
)
|
|
181
|
+
}
|
|
189
182
|
|
|
190
183
|
/**
|
|
191
184
|
* Mixin to add a context menu for a procedure call block.
|
|
192
185
|
* It adds the "edit" option and the "define" option.
|
|
193
|
-
* @mixin
|
|
194
|
-
* @augments Blockly.Block
|
|
195
186
|
* @package
|
|
196
187
|
*/
|
|
197
188
|
const PROCEDURE_CALL_CONTEXTMENU = {
|
|
198
189
|
/**
|
|
199
190
|
* Add the "edit" option to the context menu.
|
|
200
|
-
*
|
|
201
191
|
* @todo Add "go to definition" option once implemented.
|
|
202
192
|
* @param menuOptions List of menu options to edit.
|
|
203
193
|
*/
|
|
204
194
|
customContextMenu: function (
|
|
205
195
|
this: Blockly.BlockSvg,
|
|
206
|
-
menuOptions:
|
|
196
|
+
menuOptions: (
|
|
207
197
|
| Blockly.ContextMenuRegistry.ContextMenuOption
|
|
208
198
|
| Blockly.ContextMenuRegistry.LegacyContextMenuOption
|
|
209
|
-
|
|
199
|
+
)[],
|
|
210
200
|
) {
|
|
211
|
-
menuOptions.push(ScratchProcedures.makeEditOption(this))
|
|
201
|
+
menuOptions.push(ScratchProcedures.makeEditOption(this))
|
|
212
202
|
},
|
|
213
|
-
}
|
|
203
|
+
}
|
|
214
204
|
|
|
215
205
|
const SCRATCH_EXTENSION = function (this: Blockly.Block) {
|
|
216
|
-
(this as any).isScratchExtension = true
|
|
217
|
-
}
|
|
206
|
+
;(this as any).isScratchExtension = true
|
|
207
|
+
}
|
|
218
208
|
|
|
219
209
|
/**
|
|
220
210
|
* Register all extensions for scratch-blocks.
|
|
@@ -222,51 +212,45 @@ const SCRATCH_EXTENSION = function (this: Blockly.Block) {
|
|
|
222
212
|
*/
|
|
223
213
|
function registerAll() {
|
|
224
214
|
const categoryNames = [
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
]
|
|
215
|
+
'control',
|
|
216
|
+
'data',
|
|
217
|
+
'data_lists',
|
|
218
|
+
'sounds',
|
|
219
|
+
'motion',
|
|
220
|
+
'looks',
|
|
221
|
+
'event',
|
|
222
|
+
'sensing',
|
|
223
|
+
'pen',
|
|
224
|
+
'operators',
|
|
225
|
+
'more',
|
|
226
|
+
]
|
|
237
227
|
// Register functions for all category colours.
|
|
238
228
|
for (const name of categoryNames) {
|
|
239
|
-
Blockly.Extensions.register(
|
|
229
|
+
Blockly.Extensions.register('colours_' + name, colourHelper(name))
|
|
240
230
|
}
|
|
241
231
|
|
|
242
232
|
// Text fields transcend categories.
|
|
243
|
-
Blockly.Extensions.register(
|
|
233
|
+
Blockly.Extensions.register('colours_textfield', COLOUR_TEXTFIELD)
|
|
244
234
|
|
|
245
235
|
// Register extensions for common block shapes.
|
|
246
|
-
Blockly.Extensions.register(
|
|
247
|
-
Blockly.Extensions.register(
|
|
248
|
-
Blockly.Extensions.register(
|
|
249
|
-
Blockly.Extensions.register(
|
|
236
|
+
Blockly.Extensions.register('shape_statement', SHAPE_STATEMENT)
|
|
237
|
+
Blockly.Extensions.register('shape_hat', SHAPE_HAT)
|
|
238
|
+
Blockly.Extensions.register('shape_bowler_hat', SHAPE_BOWLER_HAT)
|
|
239
|
+
Blockly.Extensions.register('shape_end', SHAPE_END)
|
|
250
240
|
|
|
251
241
|
// Output shapes and types are related.
|
|
252
|
-
Blockly.Extensions.register(
|
|
253
|
-
Blockly.Extensions.register(
|
|
254
|
-
Blockly.Extensions.register(
|
|
242
|
+
Blockly.Extensions.register('output_number', OUTPUT_NUMBER)
|
|
243
|
+
Blockly.Extensions.register('output_string', OUTPUT_STRING)
|
|
244
|
+
Blockly.Extensions.register('output_boolean', OUTPUT_BOOLEAN)
|
|
255
245
|
|
|
256
246
|
// Custom procedures have interesting context menus.
|
|
257
|
-
Blockly.Extensions.register(
|
|
258
|
-
|
|
259
|
-
PROCEDURE_DEF_CONTEXTMENU
|
|
260
|
-
);
|
|
261
|
-
Blockly.Extensions.registerMixin(
|
|
262
|
-
"procedure_call_contextmenu",
|
|
263
|
-
PROCEDURE_CALL_CONTEXTMENU
|
|
264
|
-
);
|
|
247
|
+
Blockly.Extensions.register('procedure_def_contextmenu', PROCEDURE_DEF_CONTEXTMENU)
|
|
248
|
+
Blockly.Extensions.registerMixin('procedure_call_contextmenu', PROCEDURE_CALL_CONTEXTMENU)
|
|
265
249
|
|
|
266
250
|
// Extension blocks have slightly different block rendering.
|
|
267
|
-
Blockly.Extensions.register(
|
|
251
|
+
Blockly.Extensions.register('scratch_extension', SCRATCH_EXTENSION)
|
|
268
252
|
|
|
269
|
-
Blockly.Extensions.register(
|
|
253
|
+
Blockly.Extensions.register('monitor_block', MONITOR_BLOCK)
|
|
270
254
|
}
|
|
271
255
|
|
|
272
|
-
registerAll()
|
|
256
|
+
registerAll()
|