blockly 12.0.0-beta.2 → 12.0.0-beta.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.
@@ -0,0 +1,313 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * @fileoverview The class representing a line cursor.
8
+ * A line cursor tries to traverse the blocks and connections on a block as if
9
+ * they were lines of code in a text editor. Previous and next traverse previous
10
+ * connections, next connections and blocks, while in and out traverse input
11
+ * connections and fields.
12
+ * @author aschmiedt@google.com (Abby Schmiedt)
13
+ */
14
+ import type { Block } from '../block.js';
15
+ import type { MarkerSvg } from '../renderers/common/marker_svg.js';
16
+ import type { WorkspaceSvg } from '../workspace_svg.js';
17
+ import { ASTNode } from './ast_node.js';
18
+ import { Marker } from './marker.js';
19
+ /** Options object for LineCursor instances. */
20
+ export interface CursorOptions {
21
+ /**
22
+ * Can the cursor visit all stack connections (next/previous), or
23
+ * (if false) only unconnected next connections?
24
+ */
25
+ stackConnections: boolean;
26
+ }
27
+ /**
28
+ * Class for a line cursor.
29
+ */
30
+ export declare class LineCursor extends Marker {
31
+ private readonly workspace;
32
+ type: string;
33
+ /** Options for this line cursor. */
34
+ private readonly options;
35
+ /** Locations to try moving the cursor to after a deletion. */
36
+ private potentialNodes;
37
+ /** Whether the renderer is zelos-style. */
38
+ private isZelos;
39
+ /**
40
+ * @param workspace The workspace this cursor belongs to.
41
+ * @param options Cursor options.
42
+ */
43
+ constructor(workspace: WorkspaceSvg, options?: Partial<CursorOptions>);
44
+ /**
45
+ * Clean up this cursor.
46
+ */
47
+ dispose(): void;
48
+ /**
49
+ * Moves the cursor to the next previous connection, next connection or block
50
+ * in the pre order traversal. Finds the next node in the pre order traversal.
51
+ *
52
+ * @returns The next node, or null if the current node is
53
+ * not set or there is no next value.
54
+ */
55
+ next(): ASTNode | null;
56
+ /**
57
+ * Moves the cursor to the next input connection or field
58
+ * in the pre order traversal.
59
+ *
60
+ * @returns The next node, or null if the current node is
61
+ * not set or there is no next value.
62
+ */
63
+ in(): ASTNode | null;
64
+ /**
65
+ * Moves the cursor to the previous next connection or previous connection in
66
+ * the pre order traversal.
67
+ *
68
+ * @returns The previous node, or null if the current node
69
+ * is not set or there is no previous value.
70
+ */
71
+ prev(): ASTNode | null;
72
+ /**
73
+ * Moves the cursor to the previous input connection or field in the pre order
74
+ * traversal.
75
+ *
76
+ * @returns The previous node, or null if the current node
77
+ * is not set or there is no previous value.
78
+ */
79
+ out(): ASTNode | null;
80
+ /**
81
+ * Returns true iff the node to which we would navigate if in() were
82
+ * called, which will be a validInLineNode, is also a validLineNode
83
+ * - in effect, if the LineCursor is at the end of the 'current
84
+ * line' of the program.
85
+ */
86
+ atEndOfLine(): boolean;
87
+ /**
88
+ * Returns true iff the given node represents the "beginning of a
89
+ * new line of code" (and thus can be visited by pressing the
90
+ * up/down arrow keys). Specifically, if the node is for:
91
+ *
92
+ * - Any block that is not a value block.
93
+ * - A top-level value block (one that is unconnected).
94
+ * - An unconnected next statement input.
95
+ * - An unconnected 'next' connection - the "blank line at the end".
96
+ * This is to facilitate connecting additional blocks to a
97
+ * stack/substack.
98
+ *
99
+ * If options.stackConnections is true (the default) then allow the
100
+ * cursor to visit all (useful) stack connection by additionally
101
+ * returning true for:
102
+ *
103
+ * - Any next statement input
104
+ * - Any 'next' connection.
105
+ * - An unconnected previous statement input.
106
+ *
107
+ * @param node The AST node to check.
108
+ * @returns True if the node should be visited, false otherwise.
109
+ */
110
+ protected validLineNode(node: ASTNode | null): boolean;
111
+ /**
112
+ * Returns true iff the given node can be visited by the cursor when
113
+ * using the left/right arrow keys. Specifically, if the node is
114
+ * any node for which valideLineNode would return true, plus:
115
+ *
116
+ * - Any block.
117
+ * - Any field that is not a full block field.
118
+ * - Any unconnected next or input connection. This is to
119
+ * facilitate connecting additional blocks.
120
+ *
121
+ * @param node The AST node to check whether it is valid.
122
+ * @returns True if the node should be visited, false otherwise.
123
+ */
124
+ protected validInLineNode(node: ASTNode | null): boolean;
125
+ /**
126
+ * Returns true iff the given node can be visited by the cursor.
127
+ * Specifically, if the node is any for which validInLineNode would
128
+ * return true, or if it is a workspace node.
129
+ *
130
+ * @param node The AST node to check whether it is valid.
131
+ * @returns True if the node should be visited, false otherwise.
132
+ */
133
+ protected validNode(node: ASTNode | null): boolean;
134
+ /**
135
+ * Uses pre order traversal to navigate the Blockly AST. This will allow
136
+ * a user to easily navigate the entire Blockly AST without having to go in
137
+ * and out levels on the tree.
138
+ *
139
+ * @param node The current position in the AST.
140
+ * @param isValid A function true/false depending on whether the given node
141
+ * should be traversed.
142
+ * @returns The next node in the traversal.
143
+ */
144
+ getNextNode(node: ASTNode | null, isValid: (p1: ASTNode | null) => boolean): ASTNode | null;
145
+ /**
146
+ * Reverses the pre order traversal in order to find the previous node. This
147
+ * will allow a user to easily navigate the entire Blockly AST without having
148
+ * to go in and out levels on the tree.
149
+ *
150
+ * @param node The current position in the AST.
151
+ * @param isValid A function true/false depending on whether the given node
152
+ * should be traversed.
153
+ * @returns The previous node in the traversal or null if no previous node
154
+ * exists.
155
+ */
156
+ getPreviousNode(node: ASTNode | null, isValid: (p1: ASTNode | null) => boolean): ASTNode | null;
157
+ /**
158
+ * From the given node find either the next valid sibling or the parent's
159
+ * next sibling.
160
+ *
161
+ * @param node The current position in the AST.
162
+ * @returns The next sibling node, the parent's next sibling, or null.
163
+ */
164
+ private findSiblingOrParentSibling;
165
+ /**
166
+ * Get the right most child of a node.
167
+ *
168
+ * @param node The node to find the right most child of.
169
+ * @returns The right most child of the given node, or the node if no child
170
+ * exists.
171
+ */
172
+ private getRightMostChild;
173
+ /**
174
+ * Prepare for the deletion of a block by making a list of nodes we
175
+ * could move the cursor to afterwards and save it to
176
+ * this.potentialNodes.
177
+ *
178
+ * After the deletion has occurred, call postDelete to move it to
179
+ * the first valid node on that list.
180
+ *
181
+ * The locations to try (in order of preference) are:
182
+ *
183
+ * - The current location.
184
+ * - The connection to which the deleted block is attached.
185
+ * - The block connected to the next connection of the deleted block.
186
+ * - The parent block of the deleted block.
187
+ * - A location on the workspace beneath the deleted block.
188
+ *
189
+ * N.B.: When block is deleted, all of the blocks conneccted to that
190
+ * block's inputs are also deleted, but not blocks connected to its
191
+ * next connection.
192
+ *
193
+ * @param deletedBlock The block that is being deleted.
194
+ */
195
+ preDelete(deletedBlock: Block): void;
196
+ /**
197
+ * Move the cursor to the first valid location in
198
+ * this.potentialNodes, following a block deletion.
199
+ */
200
+ postDelete(): void;
201
+ /**
202
+ * Get the current location of the cursor.
203
+ *
204
+ * Overrides normal Marker getCurNode to update the current node from the
205
+ * selected block. This typically happens via the selection listener but that
206
+ * is not called immediately when `Gesture` calls
207
+ * `Blockly.common.setSelected`. In particular the listener runs after showing
208
+ * the context menu.
209
+ *
210
+ * @returns The current field, connection, or block the cursor is on.
211
+ */
212
+ getCurNode(): ASTNode | null;
213
+ /**
214
+ * Sets the object in charge of drawing the marker.
215
+ *
216
+ * We want to customize drawing, so rather than directly setting the given
217
+ * object, we instead set a wrapper proxy object that passes through all
218
+ * method calls and property accesses except for draw(), which it delegates
219
+ * to the drawMarker() method in this class.
220
+ *
221
+ * @param drawer The object ~in charge of drawing the marker.
222
+ */
223
+ setDrawer(drawer: MarkerSvg): void;
224
+ /**
225
+ * Set the location of the cursor and draw it.
226
+ *
227
+ * Overrides normal Marker setCurNode logic to call
228
+ * this.drawMarker() instead of this.drawer.draw() directly.
229
+ *
230
+ * @param newNode The new location of the cursor.
231
+ * @param updateSelection If true (the default) we'll update the selection
232
+ * too.
233
+ */
234
+ setCurNode(newNode: ASTNode | null, updateSelection?: boolean): void;
235
+ /**
236
+ * Draw this cursor's marker.
237
+ *
238
+ * This is a wrapper around this.drawer.draw (usually implemented by
239
+ * MarkerSvg.prototype.draw) that will, if newNode is a BLOCK node,
240
+ * instead call `setSelected` to select it (if it's a regular block)
241
+ * or `addSelect` (if it's a shadow block, since shadow blocks can't
242
+ * be selected) instead of using the normal drawer logic.
243
+ *
244
+ * TODO(#142): The selection and fake-selection code was originally
245
+ * a hack added for testing on October 28 2024, because the default
246
+ * drawer (MarkerSvg) behaviour in Zelos was to draw a box around
247
+ * the block and all attached child blocks, which was confusing when
248
+ * navigating stacks.
249
+ *
250
+ * Since then we have decided that we probably _do_ in most cases
251
+ * want navigating to a block to select the block, but more
252
+ * particularly that we want navigation to move _focus_. Replace
253
+ * this selection hack with non-hacky changing of focus once that's
254
+ * possible.
255
+ *
256
+ * @param oldNode The previous node.
257
+ * @param curNode The current node.
258
+ * @param realDrawer The object ~in charge of drawing the marker.
259
+ */
260
+ private drawMarker;
261
+ /**
262
+ * Check whether the node represents a value input connection.
263
+ *
264
+ * @param node The node to check
265
+ * @returns True if the node represents a value input connection.
266
+ */
267
+ private isValueInputConnection;
268
+ /**
269
+ * Hide the cursor rendering at the given input node.
270
+ *
271
+ * @param node The input node to hide.
272
+ */
273
+ private hideAtInput;
274
+ /**
275
+ * Show the cursor rendering at the given input node.
276
+ *
277
+ * @param node The input node to show.
278
+ */
279
+ private showAtInput;
280
+ /**
281
+ * Event listener that syncs the cursor location to the selected block on
282
+ * SELECTED events.
283
+ *
284
+ * This does not run early enough in all cases so `getCurNode()` also updates
285
+ * the node from the selection.
286
+ *
287
+ * @param event The `Selected` event.
288
+ */
289
+ private changeListener;
290
+ /**
291
+ * Updates the current node to match the selection.
292
+ *
293
+ * Clears the current node if it's on a block but the selection is null.
294
+ * Sets the node to a block if selected for our workspace.
295
+ * For shadow blocks selections the parent is used by default (unless we're
296
+ * already on the shadow block via keyboard) as that's where the visual
297
+ * selection is.
298
+ */
299
+ private updateCurNodeFromSelection;
300
+ /**
301
+ * Updates the selection from the node.
302
+ *
303
+ * Clears the selection for non-block nodes.
304
+ * Clears the selection for shadow blocks as the selection is drawn on
305
+ * the parent but the cursor will be drawn on the shadow block itself.
306
+ * We need to take care not to later clear the current node due to that null
307
+ * selection, so we track the latest selection we're in sync with.
308
+ *
309
+ * @param newNode The new node.
310
+ */
311
+ private updateSelectionFromNode;
312
+ }
313
+ //# sourceMappingURL=line_cursor.d.ts.map
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @class
10
10
  */
11
- import type { Cursor } from './keyboard_nav/cursor.js';
11
+ import type { LineCursor } from './keyboard_nav/line_cursor.js';
12
12
  import type { Marker } from './keyboard_nav/marker.js';
13
13
  import type { WorkspaceSvg } from './workspace_svg.js';
14
14
  /**
@@ -49,7 +49,7 @@ export declare class MarkerManager {
49
49
  *
50
50
  * @returns The cursor for this workspace.
51
51
  */
52
- getCursor(): Cursor | null;
52
+ getCursor(): LineCursor | null;
53
53
  /**
54
54
  * Get a single marker that corresponds to the given ID.
55
55
  *
@@ -64,7 +64,7 @@ export declare class MarkerManager {
64
64
  *
65
65
  * @param cursor The cursor used to move around this workspace.
66
66
  */
67
- setCursor(cursor: Cursor): void;
67
+ setCursor(cursor: LineCursor): void;
68
68
  /**
69
69
  * Add the cursor SVG to this workspace SVG group.
70
70
  *
@@ -19,7 +19,7 @@ import type { ISerializer } from './interfaces/i_serializer.js';
19
19
  import type { IToolbox } from './interfaces/i_toolbox.js';
20
20
  import type { IVariableMap } from './interfaces/i_variable_map.js';
21
21
  import type { IVariableModel, IVariableModelStatic, IVariableState } from './interfaces/i_variable_model.js';
22
- import type { Cursor } from './keyboard_nav/cursor.js';
22
+ import type { LineCursor } from './keyboard_nav/line_cursor.js';
23
23
  import type { Options } from './options.js';
24
24
  import type { Renderer } from './renderers/common/renderer.js';
25
25
  import type { Theme } from './theme.js';
@@ -50,7 +50,7 @@ export declare class Type<_T> {
50
50
  toString(): string;
51
51
  static CONNECTION_CHECKER: Type<IConnectionChecker>;
52
52
  static CONNECTION_PREVIEWER: Type<IConnectionPreviewer>;
53
- static CURSOR: Type<Cursor>;
53
+ static CURSOR: Type<LineCursor>;
54
54
  static EVENT: Type<Abstract>;
55
55
  static FIELD: Type<Field<any>>;
56
56
  static INPUT: Type<Input>;
@@ -61,10 +61,11 @@ export declare class PathObject extends BasePathObject {
61
61
  /**
62
62
  * Create's an outline path for the specified input.
63
63
  *
64
+ * @internal
64
65
  * @param name The input name.
65
66
  * @returns The SVG outline path.
66
67
  */
67
- private getOutlinePath;
68
+ getOutlinePath(name: string): SVGElement;
68
69
  /**
69
70
  * Remove an outline path that is associated with the specified input.
70
71
  *
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
7
+ import type { IFocusableTree } from '../interfaces/i_focusable_tree.js';
8
+ /**
9
+ * A helper utility for IFocusableTree implementations to aid with common
10
+ * tree traversals.
11
+ */
12
+ export declare class FocusableTreeTraverser {
13
+ private static readonly ACTIVE_CLASS_NAME;
14
+ private static readonly PASSIVE_CSS_CLASS_NAME;
15
+ private static readonly ACTIVE_FOCUS_NODE_CSS_SELECTOR;
16
+ private static readonly PASSIVE_FOCUS_NODE_CSS_SELECTOR;
17
+ /**
18
+ * Returns the current IFocusableNode that is styled (and thus represented) as
19
+ * having either passive or active focus, only considering HTML and SVG
20
+ * elements.
21
+ *
22
+ * This can match against the tree's root.
23
+ *
24
+ * Note that this will never return a node from a nested sub-tree as that tree
25
+ * should specifically be used to retrieve its focused node.
26
+ *
27
+ * @param tree The IFocusableTree in which to search for a focused node.
28
+ * @returns The IFocusableNode currently with focus, or null if none.
29
+ */
30
+ static findFocusedNode(tree: IFocusableTree): IFocusableNode | null;
31
+ /**
32
+ * Returns the IFocusableNode corresponding to the specified HTML or SVG
33
+ * element iff it's the root element or a descendent of the root element of
34
+ * the specified IFocusableTree.
35
+ *
36
+ * If the element exists within the specified tree's DOM structure but does
37
+ * not directly correspond to a node, the nearest parent node (or the tree's
38
+ * root) will be returned to represent the provided element.
39
+ *
40
+ * If the tree contains another nested IFocusableTree, the nested tree may be
41
+ * traversed but its nodes will never be returned here per the contract of
42
+ * IFocusableTree.lookUpFocusableNode.
43
+ *
44
+ * The provided element must have a non-null ID that conforms to the contract
45
+ * mentioned in IFocusableNode.
46
+ *
47
+ * @param element The HTML or SVG element being sought.
48
+ * @param tree The tree under which the provided element may be a descendant.
49
+ * @returns The matching IFocusableNode, or null if there is no match.
50
+ */
51
+ static findFocusableNodeFor(element: HTMLElement | SVGElement, tree: IFocusableTree): IFocusableNode | null;
52
+ }
53
+ //# sourceMappingURL=focusable_tree_traverser.d.ts.map
@@ -411,7 +411,6 @@ export declare class Workspace implements IASTNodeLocation {
411
411
  * These exist in the flyout but not in the workspace.
412
412
  *
413
413
  * @returns The potential variable map.
414
- * @internal
415
414
  */
416
415
  getPotentialVariableMap(): IVariableMap<IVariableModel<IVariableState>> | null;
417
416
  /**
@@ -27,7 +27,7 @@ import type { IFlyout } from './interfaces/i_flyout.js';
27
27
  import type { IMetricsManager } from './interfaces/i_metrics_manager.js';
28
28
  import type { IToolbox } from './interfaces/i_toolbox.js';
29
29
  import type { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
30
- import type { Cursor } from './keyboard_nav/cursor.js';
30
+ import type { LineCursor } from './keyboard_nav/line_cursor.js';
31
31
  import type { Marker } from './keyboard_nav/marker.js';
32
32
  import { LayerManager } from './layer_manager.js';
33
33
  import { MarkerManager } from './marker_manager.js';
@@ -304,7 +304,7 @@ export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationS
304
304
  *
305
305
  * @returns The cursor for the workspace.
306
306
  */
307
- getCursor(): Cursor | null;
307
+ getCursor(): LineCursor | null;
308
308
  /**
309
309
  * Get the block renderer attached to this workspace.
310
310
  *
@@ -1004,6 +1004,19 @@ export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationS
1004
1004
  */
1005
1005
  removeClass(className: string): void;
1006
1006
  setIsReadOnly(readOnly: boolean): void;
1007
+ /**
1008
+ * Scrolls the provided bounds into view.
1009
+ *
1010
+ * In the case of small workspaces/large bounds, this function prioritizes
1011
+ * getting the top left corner of the bounds into view. It also adds some
1012
+ * padding around the bounds to allow the element to be comfortably in view.
1013
+ *
1014
+ * @internal
1015
+ * @param bounds A rectangle to scroll into view, as best as possible.
1016
+ * @param padding Amount of spacing to put between the bounds and the edge of
1017
+ * the workspace's viewport.
1018
+ */
1019
+ scrollBoundsIntoView(bounds: Rect, padding?: number): void;
1007
1020
  }
1008
1021
  /**
1009
1022
  * Size the workspace when the contents change. This also updates
package/index.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  import Blockly from './index.js';
2
2
  export const {
3
3
  ASTNode,
4
- BasicCursor,
5
4
  Block,
6
5
  BlockFlyoutInflater,
7
6
  BlockSvg,
@@ -21,7 +20,6 @@ export const {
21
20
  ContextMenuItems,
22
21
  ContextMenuRegistry,
23
22
  Css,
24
- Cursor,
25
23
  DELETE_VARIABLE_ID,
26
24
  DeleteArea,
27
25
  DragTarget,
@@ -42,6 +40,7 @@ export const {
42
40
  FlyoutItem,
43
41
  FlyoutMetricsManager,
44
42
  FlyoutSeparator,
43
+ FocusManager,
45
44
  Generator,
46
45
  Gesture,
47
46
  Grid,
@@ -50,6 +49,7 @@ export const {
50
49
  Input,
51
50
  InsertionMarkerPreviewer,
52
51
  LabelFlyoutInflater,
52
+ LineCursor,
53
53
  Marker,
54
54
  MarkerManager,
55
55
  Menu,
@@ -75,7 +75,6 @@ export const {
75
75
  TOOLBOX_AT_LEFT,
76
76
  TOOLBOX_AT_RIGHT,
77
77
  TOOLBOX_AT_TOP,
78
- TabNavigateCursor,
79
78
  Theme,
80
79
  ThemeManager,
81
80
  Themes,
@@ -117,6 +116,7 @@ export const {
117
116
  dragging,
118
117
  fieldRegistry,
119
118
  geras,
119
+ getFocusManager,
120
120
  getMainWorkspace,
121
121
  getSelected,
122
122
  hasBubble,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blockly",
3
- "version": "12.0.0-beta.2",
3
+ "version": "12.0.0-beta.3",
4
4
  "description": "Blockly is a library for building visual programming editors.",
5
5
  "keywords": [
6
6
  "blockly"
@@ -1,96 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2019 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import { ASTNode } from './ast_node.js';
7
- import { Cursor } from './cursor.js';
8
- /**
9
- * Class for a basic cursor.
10
- * This will allow the user to get to all nodes in the AST by hitting next or
11
- * previous.
12
- */
13
- export declare class BasicCursor extends Cursor {
14
- /** Name used for registering a basic cursor. */
15
- static readonly registrationName = "basicCursor";
16
- constructor();
17
- /**
18
- * Find the next node in the pre order traversal.
19
- *
20
- * @returns The next node, or null if the current node is not set or there is
21
- * no next value.
22
- */
23
- next(): ASTNode | null;
24
- /**
25
- * For a basic cursor we only have the ability to go next and previous, so
26
- * in will also allow the user to get to the next node in the pre order
27
- * traversal.
28
- *
29
- * @returns The next node, or null if the current node is not set or there is
30
- * no next value.
31
- */
32
- in(): ASTNode | null;
33
- /**
34
- * Find the previous node in the pre order traversal.
35
- *
36
- * @returns The previous node, or null if the current node is not set or there
37
- * is no previous value.
38
- */
39
- prev(): ASTNode | null;
40
- /**
41
- * For a basic cursor we only have the ability to go next and previous, so
42
- * out will allow the user to get to the previous node in the pre order
43
- * traversal.
44
- *
45
- * @returns The previous node, or null if the current node is not set or there
46
- * is no previous value.
47
- */
48
- out(): ASTNode | null;
49
- /**
50
- * Uses pre order traversal to navigate the Blockly AST. This will allow
51
- * a user to easily navigate the entire Blockly AST without having to go in
52
- * and out levels on the tree.
53
- *
54
- * @param node The current position in the AST.
55
- * @param isValid A function true/false depending on whether the given node
56
- * should be traversed.
57
- * @returns The next node in the traversal.
58
- */
59
- protected getNextNode_(node: ASTNode | null, isValid: (p1: ASTNode | null) => boolean): ASTNode | null;
60
- /**
61
- * Reverses the pre order traversal in order to find the previous node. This
62
- * will allow a user to easily navigate the entire Blockly AST without having
63
- * to go in and out levels on the tree.
64
- *
65
- * @param node The current position in the AST.
66
- * @param isValid A function true/false depending on whether the given node
67
- * should be traversed.
68
- * @returns The previous node in the traversal or null if no previous node
69
- * exists.
70
- */
71
- protected getPreviousNode_(node: ASTNode | null, isValid: (p1: ASTNode | null) => boolean): ASTNode | null;
72
- /**
73
- * Decides what nodes to traverse and which ones to skip. Currently, it
74
- * skips output, stack and workspace nodes.
75
- *
76
- * @param node The AST node to check whether it is valid.
77
- * @returns True if the node should be visited, false otherwise.
78
- */
79
- protected validNode_(node: ASTNode | null): boolean;
80
- /**
81
- * From the given node find either the next valid sibling or parent.
82
- *
83
- * @param node The current position in the AST.
84
- * @returns The parent AST node or null if there are no valid parents.
85
- */
86
- private findSiblingOrParent;
87
- /**
88
- * Get the right most child of a node.
89
- *
90
- * @param node The node to find the right most child of.
91
- * @returns The right most child of the given node, or the node if no child
92
- * exists.
93
- */
94
- private getRightMostChild;
95
- }
96
- //# sourceMappingURL=basic_cursor.d.ts.map
@@ -1,44 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2019 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import { ASTNode } from './ast_node.js';
7
- import { Marker } from './marker.js';
8
- /**
9
- * Class for a cursor.
10
- * A cursor controls how a user navigates the Blockly AST.
11
- */
12
- export declare class Cursor extends Marker {
13
- type: string;
14
- constructor();
15
- /**
16
- * Find the next connection, field, or block.
17
- *
18
- * @returns The next element, or null if the current node is not set or there
19
- * is no next value.
20
- */
21
- next(): ASTNode | null;
22
- /**
23
- * Find the in connection or field.
24
- *
25
- * @returns The in element, or null if the current node is not set or there is
26
- * no in value.
27
- */
28
- in(): ASTNode | null;
29
- /**
30
- * Find the previous connection, field, or block.
31
- *
32
- * @returns The previous element, or null if the current node is not set or
33
- * there is no previous value.
34
- */
35
- prev(): ASTNode | null;
36
- /**
37
- * Find the out connection, field, or block.
38
- *
39
- * @returns The out element, or null if the current node is not set or there
40
- * is no out value.
41
- */
42
- out(): ASTNode | null;
43
- }
44
- //# sourceMappingURL=cursor.d.ts.map