blockly 12.0.0-beta.0 → 12.0.0-beta.2

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 (85) hide show
  1. package/blockly.min.js +384 -370
  2. package/blockly.mjs +1 -0
  3. package/blockly_compressed.js +364 -350
  4. package/blockly_compressed.js.map +1 -1
  5. package/blocks_compressed.js +5 -5
  6. package/blocks_compressed.js.map +1 -1
  7. package/core/block.d.ts +8 -3
  8. package/core/block_flyout_inflater.d.ts +15 -10
  9. package/core/block_svg.d.ts +8 -2
  10. package/core/blockly.d.ts +5 -2
  11. package/core/bubbles/text_bubble.d.ts +5 -5
  12. package/core/button_flyout_inflater.d.ts +13 -7
  13. package/core/comments/comment_view.d.ts +3 -3
  14. package/core/connection.d.ts +1 -1
  15. package/core/contextmenu_registry.d.ts +51 -11
  16. package/core/dragging/block_drag_strategy.d.ts +2 -2
  17. package/core/dragging/bubble_drag_strategy.d.ts +0 -2
  18. package/core/dragging/comment_drag_strategy.d.ts +0 -2
  19. package/core/events/events_var_delete.d.ts +0 -2
  20. package/core/events/events_var_rename.d.ts +0 -2
  21. package/core/field.d.ts +0 -2
  22. package/core/field_dropdown.d.ts +7 -9
  23. package/core/flyout_base.d.ts +1 -8
  24. package/core/flyout_horizontal.d.ts +2 -1
  25. package/core/flyout_item.d.ts +32 -0
  26. package/core/flyout_vertical.d.ts +2 -1
  27. package/core/interfaces/i_flyout.d.ts +1 -1
  28. package/core/interfaces/i_flyout_inflater.d.ts +15 -6
  29. package/core/interfaces/i_focusable_node.d.ts +34 -0
  30. package/core/interfaces/i_focusable_tree.d.ts +48 -0
  31. package/core/interfaces/i_metrics_manager.d.ts +1 -1
  32. package/core/interfaces/i_rendered_element.d.ts +1 -4
  33. package/core/keyboard_nav/marker.d.ts +4 -8
  34. package/core/label_flyout_inflater.d.ts +13 -7
  35. package/core/menu.d.ts +30 -26
  36. package/core/menu_separator.d.ts +25 -0
  37. package/core/menuitem.d.ts +7 -0
  38. package/core/metrics_manager.d.ts +1 -1
  39. package/core/procedures.d.ts +7 -4
  40. package/core/renderers/common/marker_svg.d.ts +2 -2
  41. package/core/renderers/common/renderer.d.ts +1 -1
  42. package/core/renderers/measurables/in_row_spacer.d.ts +1 -0
  43. package/core/renderers/measurables/jagged_edge.d.ts +1 -0
  44. package/core/renderers/measurables/next_connection.d.ts +1 -0
  45. package/core/renderers/measurables/previous_connection.d.ts +1 -0
  46. package/core/renderers/measurables/round_corner.d.ts +1 -0
  47. package/core/renderers/measurables/square_corner.d.ts +1 -0
  48. package/core/renderers/measurables/statement_input.d.ts +1 -0
  49. package/core/renderers/measurables/types.d.ts +49 -24
  50. package/core/separator_flyout_inflater.d.ts +17 -7
  51. package/core/utils/aria.d.ts +2 -1
  52. package/core/utils/toolbox.d.ts +0 -2
  53. package/core/variables.d.ts +18 -4
  54. package/core/variables_dynamic.d.ts +7 -5
  55. package/core/workspace.d.ts +13 -0
  56. package/core/workspace_svg.d.ts +2 -0
  57. package/dart_compressed.js +1 -1
  58. package/dart_compressed.js.map +1 -1
  59. package/index.mjs +1 -0
  60. package/javascript_compressed.js +15 -15
  61. package/javascript_compressed.js.map +1 -1
  62. package/lua_compressed.js +1 -1
  63. package/lua_compressed.js.map +1 -1
  64. package/media/1x1.gif +0 -0
  65. package/media/click.mp3 +0 -0
  66. package/media/click.ogg +0 -0
  67. package/media/click.wav +0 -0
  68. package/media/delete.mp3 +0 -0
  69. package/media/delete.ogg +0 -0
  70. package/media/delete.wav +0 -0
  71. package/media/disconnect.mp3 +0 -0
  72. package/media/disconnect.ogg +0 -0
  73. package/media/disconnect.wav +0 -0
  74. package/media/handclosed.cur +0 -0
  75. package/media/handdelete.cur +0 -0
  76. package/media/handopen.cur +0 -0
  77. package/media/pilcrow.png +0 -0
  78. package/media/quote0.png +0 -0
  79. package/media/quote1.png +0 -0
  80. package/media/sprites.png +0 -0
  81. package/package.json +2 -2
  82. package/php_compressed.js +1 -1
  83. package/php_compressed.js.map +1 -1
  84. package/python_compressed.js +3 -3
  85. package/python_compressed.js.map +1 -1
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { IFocusableNode } from './i_focusable_node.js';
7
+ /**
8
+ * Represents a tree of focusable elements with its own active/passive focus
9
+ * context.
10
+ *
11
+ * Note that focus is handled by FocusManager, and tree implementations can have
12
+ * at most one IFocusableNode focused at one time. If the tree itself has focus,
13
+ * then the tree's focused node is considered 'active' ('passive' if another
14
+ * tree has focus).
15
+ *
16
+ * Focus is shared between one or more trees, where each tree can have exactly
17
+ * one active or passive node (and only one active node can exist on the whole
18
+ * page at any given time). The idea of passive focus is to provide context to
19
+ * users on where their focus will be restored upon navigating back to a
20
+ * previously focused tree.
21
+ */
22
+ export interface IFocusableTree {
23
+ /**
24
+ * Returns the current node with focus in this tree, or null if none (or if
25
+ * the root has focus).
26
+ *
27
+ * Note that this will never return a node from a nested sub-tree as that tree
28
+ * should specifically be called in order to retrieve its focused node.
29
+ */
30
+ getFocusedNode(): IFocusableNode | null;
31
+ /**
32
+ * Returns the top-level focusable node of the tree.
33
+ *
34
+ * It's expected that the returned node will be focused in cases where
35
+ * FocusManager wants to focus a tree in a situation where it does not
36
+ * currently have a focused node.
37
+ */
38
+ getRootFocusableNode(): IFocusableNode;
39
+ /**
40
+ * Returns the IFocusableNode corresponding to the select element, or null if
41
+ * the element does not have such a node.
42
+ *
43
+ * The provided element must have a non-null ID that conforms to the contract
44
+ * mentioned in IFocusableNode.
45
+ */
46
+ findFocusableNodeFor(element: HTMLElement | SVGElement): IFocusableNode | null;
47
+ }
48
+ //# sourceMappingURL=i_focusable_tree.d.ts.map
@@ -47,7 +47,7 @@ export interface IMetricsManager {
47
47
  * Gets the width, height and position of the toolbox on the workspace in
48
48
  * pixel coordinates. Returns 0 for the width and height if the workspace has
49
49
  * a simple toolbox instead of a category toolbox. To get the width and height
50
- * of a simple toolbox, see {@link IMetricsManager#getFlyoutMetrics}.
50
+ * of a simple toolbox, see {@link IMetricsManager.getFlyoutMetrics}.
51
51
  *
52
52
  * @returns The object with the width, height and position of the toolbox.
53
53
  */
@@ -3,17 +3,14 @@
3
3
  * Copyright 2023 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- /** @internal */
7
6
  export interface IRenderedElement {
8
7
  /**
9
- * @returns The root SVG element of htis rendered element.
8
+ * @returns The root SVG element of this rendered element.
10
9
  */
11
10
  getSvgRoot(): SVGElement;
12
11
  }
13
12
  /**
14
13
  * @returns True if the given object is an IRenderedElement.
15
- *
16
- * @internal
17
14
  */
18
15
  export declare function isRenderedElement(obj: any): obj is IRenderedElement;
19
16
  //# sourceMappingURL=i_rendered_element.d.ts.map
@@ -27,8 +27,6 @@ export declare class Marker {
27
27
  private drawer;
28
28
  /** The type of the marker. */
29
29
  type: string;
30
- /** Constructs a new Marker instance. */
31
- constructor();
32
30
  /**
33
31
  * Sets the object in charge of drawing the marker.
34
32
  *
@@ -40,21 +38,19 @@ export declare class Marker {
40
38
  *
41
39
  * @returns The object in charge of drawing the marker.
42
40
  */
43
- getDrawer(): MarkerSvg;
41
+ getDrawer(): MarkerSvg | null;
44
42
  /**
45
43
  * Gets the current location of the marker.
46
44
  *
47
45
  * @returns The current field, connection, or block the marker is on.
48
46
  */
49
- getCurNode(): ASTNode;
47
+ getCurNode(): ASTNode | null;
50
48
  /**
51
49
  * Set the location of the marker and call the update method.
52
- * Setting isStack to true will only work if the newLocation is the top most
53
- * output or previous connection on a stack.
54
50
  *
55
- * @param newNode The new location of the marker.
51
+ * @param newNode The new location of the marker, or null to remove it.
56
52
  */
57
- setCurNode(newNode: ASTNode): void;
53
+ setCurNode(newNode: ASTNode | null): void;
58
54
  /**
59
55
  * Redraw the current marker.
60
56
  *
@@ -3,9 +3,9 @@
3
3
  * Copyright 2024 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { IBoundedElement } from './interfaces/i_bounded_element.js';
6
+ import { FlyoutItem } from './flyout_item.js';
7
+ import type { IFlyout } from './interfaces/i_flyout.js';
7
8
  import type { IFlyoutInflater } from './interfaces/i_flyout_inflater.js';
8
- import type { WorkspaceSvg } from './workspace_svg.js';
9
9
  /**
10
10
  * Class responsible for creating labels for flyouts.
11
11
  */
@@ -14,10 +14,10 @@ export declare class LabelFlyoutInflater implements IFlyoutInflater {
14
14
  * Inflates a flyout label from the given state and adds it to the flyout.
15
15
  *
16
16
  * @param state A JSON representation of a flyout label.
17
- * @param flyoutWorkspace The workspace to create the label on.
17
+ * @param flyout The flyout to create the label on.
18
18
  * @returns A FlyoutButton configured as a label.
19
19
  */
20
- load(state: object, flyoutWorkspace: WorkspaceSvg): IBoundedElement;
20
+ load(state: object, flyout: IFlyout): FlyoutItem;
21
21
  /**
22
22
  * Returns the amount of space that should follow this label.
23
23
  *
@@ -25,12 +25,18 @@ export declare class LabelFlyoutInflater implements IFlyoutInflater {
25
25
  * @param defaultGap The default spacing for flyout items.
26
26
  * @returns The amount of space that should follow this label.
27
27
  */
28
- gapForElement(state: object, defaultGap: number): number;
28
+ gapForItem(state: object, defaultGap: number): number;
29
29
  /**
30
30
  * Disposes of the given label.
31
31
  *
32
- * @param element The flyout label to dispose of.
32
+ * @param item The flyout label to dispose of.
33
33
  */
34
- disposeElement(element: IBoundedElement): void;
34
+ disposeItem(item: FlyoutItem): void;
35
+ /**
36
+ * Returns the type of items this inflater is responsible for creating.
37
+ *
38
+ * @returns An identifier for the type of items this inflater creates.
39
+ */
40
+ getType(): string;
35
41
  }
36
42
  //# sourceMappingURL=label_flyout_inflater.d.ts.map
package/core/menu.d.ts CHANGED
@@ -3,7 +3,8 @@
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { MenuItem } from './menuitem.js';
6
+ import type { MenuSeparator } from './menu_separator.js';
7
+ import { MenuItem } from './menuitem.js';
7
8
  import * as aria from './utils/aria.js';
8
9
  import { Coordinate } from './utils/coordinate.js';
9
10
  import type { Size } from './utils/size.js';
@@ -12,14 +13,12 @@ import type { Size } from './utils/size.js';
12
13
  */
13
14
  export declare class Menu {
14
15
  /**
15
- * Array of menu items.
16
- * (Nulls are never in the array, but typing the array as nullable prevents
17
- * the compiler from objecting to .indexOf(null))
16
+ * Array of menu items and separators.
18
17
  */
19
18
  private readonly menuItems;
20
19
  /**
21
- * Coordinates of the mousedown event that caused this menu to open. Used to
22
- * prevent the consequent mouseup event due to a simple click from
20
+ * Coordinates of the pointerdown event that caused this menu to open. Used to
21
+ * prevent the consequent pointerup event due to a simple click from
23
22
  * activating a menu item immediately.
24
23
  */
25
24
  openingCoords: Coordinate | null;
@@ -28,14 +27,14 @@ export declare class Menu {
28
27
  * A value of null means no menu item is highlighted.
29
28
  */
30
29
  private highlightedItem;
31
- /** Mouse over event data. */
32
- private mouseOverHandler;
30
+ /** Pointer over event data. */
31
+ private pointerMoveHandler;
33
32
  /** Click event data. */
34
33
  private clickHandler;
35
- /** Mouse enter event data. */
36
- private mouseEnterHandler;
37
- /** Mouse leave event data. */
38
- private mouseLeaveHandler;
34
+ /** Pointer enter event data. */
35
+ private pointerEnterHandler;
36
+ /** Pointer leave event data. */
37
+ private pointerLeaveHandler;
39
38
  /** Key down event data. */
40
39
  private onKeyDownHandler;
41
40
  /** The menu's root DOM element. */
@@ -47,10 +46,10 @@ export declare class Menu {
47
46
  /**
48
47
  * Add a new menu item to the bottom of this menu.
49
48
  *
50
- * @param menuItem Menu item to append.
49
+ * @param menuItem Menu item or separator to append.
51
50
  * @internal
52
51
  */
53
- addChild(menuItem: MenuItem): void;
52
+ addChild(menuItem: MenuItem | MenuSeparator): void;
54
53
  /**
55
54
  * Creates the menu DOM.
56
55
  *
@@ -124,11 +123,12 @@ export declare class Menu {
124
123
  */
125
124
  private highlightHelper;
126
125
  /**
127
- * Handles mouseover events. Highlight menuitems as the user hovers over them.
126
+ * Handles pointermove events. Highlight menu items as the user hovers over
127
+ * them.
128
128
  *
129
- * @param e Mouse event to handle.
129
+ * @param e Pointer event to handle.
130
130
  */
131
- private handleMouseOver;
131
+ private handlePointerMove;
132
132
  /**
133
133
  * Handles click events. Pass the event onto the child menuitem to handle.
134
134
  *
@@ -136,21 +136,19 @@ export declare class Menu {
136
136
  */
137
137
  private handleClick;
138
138
  /**
139
- * Handles mouse enter events. Focus the element.
139
+ * Handles pointer enter events. Focus the element.
140
140
  *
141
- * @param _e Mouse event to handle.
141
+ * @param _e Pointer event to handle.
142
142
  */
143
- private handleMouseEnter;
143
+ private handlePointerEnter;
144
144
  /**
145
- * Handles mouse leave events. Blur and clear highlight.
145
+ * Handles pointer leave events by clearing the active highlight.
146
146
  *
147
- * @param _e Mouse event to handle.
147
+ * @param _e Pointer event to handle.
148
148
  */
149
- private handleMouseLeave;
149
+ private handlePointerLeave;
150
150
  /**
151
- * Attempts to handle a keyboard event, if the menu item is enabled, by
152
- * calling
153
- * {@link Menu#handleKeyEventInternal_}.
151
+ * Attempts to handle a keyboard event.
154
152
  *
155
153
  * @param e Key event to handle.
156
154
  */
@@ -162,5 +160,11 @@ export declare class Menu {
162
160
  * @internal
163
161
  */
164
162
  getSize(): Size;
163
+ /**
164
+ * Returns the action menu items (omitting separators) in this menu.
165
+ *
166
+ * @returns The MenuItem objects displayed in this menu.
167
+ */
168
+ private getMenuItems;
165
169
  }
166
170
  //# sourceMappingURL=menu.d.ts.map
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Representation of a section separator in a menu.
8
+ */
9
+ export declare class MenuSeparator {
10
+ /**
11
+ * DOM element representing this separator in a menu.
12
+ */
13
+ private element;
14
+ /**
15
+ * Creates the DOM representation of this separator.
16
+ *
17
+ * @returns An <hr> element.
18
+ */
19
+ createDom(): HTMLHRElement;
20
+ /**
21
+ * Disposes of this separator.
22
+ */
23
+ dispose(): void;
24
+ }
25
+ //# sourceMappingURL=menu_separator.d.ts.map
@@ -95,6 +95,13 @@ export declare class MenuItem {
95
95
  * @internal
96
96
  */
97
97
  setChecked(checked: boolean): void;
98
+ /**
99
+ * Highlights or unhighlights the component.
100
+ *
101
+ * @param highlight Whether to highlight or unhighlight the component.
102
+ * @internal
103
+ */
104
+ setHighlighted(highlight: boolean): void;
98
105
  /**
99
106
  * Returns true if the menu item is enabled, false otherwise.
100
107
  *
@@ -48,7 +48,7 @@ export declare class MetricsManager implements IMetricsManager {
48
48
  * Gets the width, height and position of the toolbox on the workspace in
49
49
  * pixel coordinates. Returns 0 for the width and height if the workspace has
50
50
  * a simple toolbox instead of a category toolbox. To get the width and height
51
- * of a simple toolbox, see {@link MetricsManager#getFlyoutMetrics}.
51
+ * of a simple toolbox, see {@link (MetricsManager:class).getFlyoutMetrics}.
52
52
  *
53
53
  * @returns The object with the width, height and position of the toolbox.
54
54
  */
@@ -13,6 +13,7 @@ import { IProcedureBlock, isProcedureBlock } from './interfaces/i_procedure_bloc
13
13
  import { IProcedureMap } from './interfaces/i_procedure_map.js';
14
14
  import { IProcedureModel } from './interfaces/i_procedure_model.js';
15
15
  import { ObservableProcedureMap } from './observable_procedure_map.js';
16
+ import type { FlyoutItemInfo } from './utils/toolbox.js';
16
17
  import type { Workspace } from './workspace.js';
17
18
  import type { WorkspaceSvg } from './workspace_svg.js';
18
19
  /**
@@ -64,12 +65,14 @@ export declare function isNameUsed(name: string, workspace: Workspace, opt_exclu
64
65
  */
65
66
  export declare function rename(this: Field, name: string): string;
66
67
  /**
67
- * Construct the blocks required by the flyout for the procedure category.
68
+ * Internal wrapper that returns the contents of the procedure category.
68
69
  *
69
- * @param workspace The workspace containing procedures.
70
- * @returns Array of XML block elements.
70
+ * @internal
71
+ * @param workspace The workspace to populate procedure blocks for.
71
72
  */
72
- export declare function flyoutCategory(workspace: WorkspaceSvg): Element[];
73
+ export declare function internalFlyoutCategory(workspace: WorkspaceSvg): FlyoutItemInfo[];
74
+ export declare function flyoutCategory(workspace: WorkspaceSvg, useXml: true): Element[];
75
+ export declare function flyoutCategory(workspace: WorkspaceSvg, useXml: false): FlyoutItemInfo[];
73
76
  /**
74
77
  * Listens for when a procedure mutator is opened. Then it triggers a flyout
75
78
  * update and adds a mutator change listener to the mutator workspace.
@@ -78,7 +78,7 @@ export declare class MarkerSvg {
78
78
  * @param oldNode The previous node the marker was on or null.
79
79
  * @param curNode The node that we want to draw the marker for.
80
80
  */
81
- draw(oldNode: ASTNode, curNode: ASTNode): void;
81
+ draw(oldNode: ASTNode | null, curNode: ASTNode | null): void;
82
82
  /**
83
83
  * Update the marker's visible state based on the type of curNode..
84
84
  *
@@ -229,7 +229,7 @@ export declare class MarkerSvg {
229
229
  * @param oldNode The old node the marker used to be on.
230
230
  * @param curNode The new node the marker is currently on.
231
231
  */
232
- protected fireMarkerEvent(oldNode: ASTNode, curNode: ASTNode): void;
232
+ protected fireMarkerEvent(oldNode: ASTNode | null, curNode: ASTNode): void;
233
233
  /**
234
234
  * Get the properties to make a marker blink.
235
235
  *
@@ -47,7 +47,7 @@ export declare class Renderer implements IRegistrable {
47
47
  /**
48
48
  * Create any DOM elements that this renderer needs.
49
49
  * If you need to create additional DOM elements, override the
50
- * {@link ConstantProvider#createDom} method instead.
50
+ * {@link blockRendering#ConstantProvider.createDom} method instead.
51
51
  *
52
52
  * @param svg The root of the workspace's SVG.
53
53
  * @param theme The workspace theme object.
@@ -10,6 +10,7 @@ import { Measurable } from './base.js';
10
10
  * row.
11
11
  */
12
12
  export declare class InRowSpacer extends Measurable {
13
+ private inRowSpacer;
13
14
  /**
14
15
  * @param constants The rendering constants provider.
15
16
  * @param width The width of the spacer.
@@ -10,6 +10,7 @@ import { Measurable } from './base.js';
10
10
  * collapsed block takes up during rendering.
11
11
  */
12
12
  export declare class JaggedEdge extends Measurable {
13
+ private jaggedEdge;
13
14
  /**
14
15
  * @param constants The rendering constants provider.
15
16
  */
@@ -11,6 +11,7 @@ import { Connection } from './connection.js';
11
11
  * up during rendering.
12
12
  */
13
13
  export declare class NextConnection extends Connection {
14
+ private nextConnection;
14
15
  /**
15
16
  * @param constants The rendering constants provider.
16
17
  * @param connectionModel The connection object on the block that this
@@ -11,6 +11,7 @@ import { Connection } from './connection.js';
11
11
  * up during rendering.
12
12
  */
13
13
  export declare class PreviousConnection extends Connection {
14
+ private previousConnection;
14
15
  /**
15
16
  * @param constants The rendering constants provider.
16
17
  * @param connectionModel The connection object on the block that this
@@ -10,6 +10,7 @@ import { Measurable } from './base.js';
10
10
  * during rendering.
11
11
  */
12
12
  export declare class RoundCorner extends Measurable {
13
+ private roundCorner;
13
14
  /**
14
15
  * @param constants The rendering constants provider.
15
16
  * @param opt_position The position of this corner.
@@ -10,6 +10,7 @@ import { Measurable } from './base.js';
10
10
  * during rendering.
11
11
  */
12
12
  export declare class SquareCorner extends Measurable {
13
+ private squareCorner;
13
14
  /**
14
15
  * @param constants The rendering constants provider.
15
16
  * @param opt_position The position of this corner.
@@ -11,6 +11,7 @@ import { InputConnection } from './input_connection.js';
11
11
  * during rendering
12
12
  */
13
13
  export declare class StatementInput extends InputConnection {
14
+ private statementInput;
14
15
  /**
15
16
  * @param constants The rendering constants provider.
16
17
  * @param input The statement input to measure and store information for.