blockly 11.0.0-beta.5 → 11.0.0-beta.7

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 (139) hide show
  1. package/blockly.min.js +722 -763
  2. package/blockly_compressed.js +676 -680
  3. package/blockly_compressed.js.map +1 -1
  4. package/blocks_compressed.js +27 -29
  5. package/blocks_compressed.js.map +1 -1
  6. package/core/block.d.ts +12 -6
  7. package/core/block_svg.d.ts +28 -42
  8. package/core/blockly.d.ts +11 -51
  9. package/core/bubbles/bubble.d.ts +17 -2
  10. package/core/bubbles/mini_workspace_bubble.d.ts +1 -1
  11. package/core/bubbles/text_bubble.d.ts +1 -1
  12. package/core/bubbles/textinput_bubble.d.ts +1 -1
  13. package/core/clipboard.d.ts +0 -19
  14. package/core/comments/comment_view.d.ts +207 -0
  15. package/core/comments/rendered_workspace_comment.d.ts +75 -0
  16. package/core/comments/workspace_comment.d.ts +107 -0
  17. package/core/comments.d.ts +9 -0
  18. package/core/connection.d.ts +1 -1
  19. package/core/delete_area.d.ts +1 -2
  20. package/core/dragging/block_drag_strategy.d.ts +105 -0
  21. package/core/dragging/bubble_drag_strategy.d.ts +20 -0
  22. package/core/dragging/comment_drag_strategy.d.ts +20 -0
  23. package/core/dragging/dragger.d.ts +47 -0
  24. package/core/events/events.d.ts +3 -0
  25. package/core/events/events_click.d.ts +1 -1
  26. package/core/events/events_comment_base.d.ts +6 -1
  27. package/core/events/events_comment_change.d.ts +1 -1
  28. package/core/events/events_comment_collapse.d.ts +39 -0
  29. package/core/events/events_comment_create.d.ts +5 -1
  30. package/core/events/events_comment_delete.d.ts +5 -1
  31. package/core/events/events_comment_move.d.ts +17 -1
  32. package/core/events/utils.d.ts +2 -0
  33. package/core/field_dropdown.d.ts +1 -0
  34. package/core/field_image.d.ts +1 -1
  35. package/core/flyout_base.d.ts +17 -1
  36. package/core/flyout_button.d.ts +26 -1
  37. package/core/generator.d.ts +1 -1
  38. package/core/gesture.d.ts +25 -54
  39. package/core/grid.d.ts +9 -9
  40. package/core/icons/comment_icon.d.ts +8 -3
  41. package/core/icons/icon.d.ts +0 -6
  42. package/core/icons/icon_types.d.ts +2 -2
  43. package/core/icons/mutator_icon.d.ts +1 -16
  44. package/core/icons/warning_icon.d.ts +1 -1
  45. package/core/inputs/input.d.ts +10 -19
  46. package/core/{connection_previewers/insertion_marker_previewer.d.ts → insertion_marker_previewer.d.ts} +3 -3
  47. package/core/interfaces/i_comment_icon.d.ts +21 -0
  48. package/core/interfaces/i_deletable.d.ts +6 -0
  49. package/core/interfaces/i_delete_area.d.ts +1 -2
  50. package/core/interfaces/i_draggable.d.ts +47 -3
  51. package/core/interfaces/i_dragger.d.ts +32 -0
  52. package/core/interfaces/i_has_bubble.d.ts +1 -1
  53. package/core/interfaces/i_parameter_model.d.ts +7 -0
  54. package/core/interfaces/i_procedure_model.d.ts +7 -0
  55. package/core/interfaces/i_selectable.d.ts +5 -3
  56. package/core/internal_constants.d.ts +0 -7
  57. package/core/keyboard_nav/ast_node.d.ts +21 -2
  58. package/core/options.d.ts +1 -0
  59. package/core/registry.d.ts +2 -2
  60. package/core/renderers/common/drawer.d.ts +0 -7
  61. package/core/renderers/common/marker_svg.d.ts +7 -0
  62. package/core/renderers/measurables/icon.d.ts +0 -5
  63. package/core/serialization/priorities.d.ts +2 -0
  64. package/core/serialization/procedures.d.ts +28 -26
  65. package/core/serialization/workspace_comments.d.ts +45 -0
  66. package/core/serialization.d.ts +2 -1
  67. package/core/toolbox/toolbox.d.ts +1 -2
  68. package/core/utils/dom.d.ts +0 -9
  69. package/core/utils/keycodes.d.ts +32 -32
  70. package/core/utils/size.d.ts +10 -0
  71. package/core/utils/string.d.ts +0 -10
  72. package/core/workspace_comment_svg.d.ts +1 -2
  73. package/core/workspace_svg.d.ts +0 -27
  74. package/core/xml.d.ts +9 -3
  75. package/core-node.js +31 -0
  76. package/dart.d.ts +1 -24
  77. package/dart_compressed.js +22 -72
  78. package/dart_compressed.js.map +1 -1
  79. package/generators/dart/dart_generator.d.ts +17 -17
  80. package/generators/dart/text.d.ts +0 -1
  81. package/generators/javascript/javascript_generator.d.ts +34 -35
  82. package/generators/javascript/text.d.ts +0 -1
  83. package/generators/lua/lua_generator.d.ts +10 -10
  84. package/generators/lua/text.d.ts +0 -1
  85. package/generators/php/php_generator.d.ts +36 -36
  86. package/generators/php/text.d.ts +0 -1
  87. package/generators/python/python_generator.d.ts +20 -21
  88. package/generators/python/text.d.ts +0 -1
  89. package/index.js +19 -7
  90. package/javascript.d.ts +1 -41
  91. package/javascript_compressed.js +19 -54
  92. package/javascript_compressed.js.map +1 -1
  93. package/lua.d.ts +1 -18
  94. package/lua_compressed.js +24 -47
  95. package/lua_compressed.js.map +1 -1
  96. package/media/delete-icon.svg +1 -0
  97. package/media/foldout-icon.svg +1 -0
  98. package/media/resize-handle.svg +3 -0
  99. package/msg/ce.d.ts +8 -0
  100. package/msg/dtp.d.ts +8 -0
  101. package/msg/hsb.d.ts +8 -0
  102. package/msg/tdd.d.ts +8 -0
  103. package/package.json +46 -12
  104. package/php.d.ts +1 -43
  105. package/php_compressed.js +13 -46
  106. package/php_compressed.js.map +1 -1
  107. package/python.d.ts +1 -27
  108. package/python_compressed.js +21 -40
  109. package/python_compressed.js.map +1 -1
  110. package/blockly.js +0 -22
  111. package/blocks.js +0 -22
  112. package/browser.js +0 -30
  113. package/core/block_dragger.d.ts +0 -212
  114. package/core/bubble_dragger.d.ts +0 -77
  115. package/core/field_angle.d.ts +0 -208
  116. package/core/field_colour.d.ts +0 -243
  117. package/core/field_multilineinput.d.ts +0 -182
  118. package/core/interfaces/i_block_dragger.d.ts +0 -47
  119. package/core/renderers/minimalist/constants.d.ts +0 -21
  120. package/core/renderers/minimalist/drawer.d.ts +0 -26
  121. package/core/renderers/minimalist/info.d.ts +0 -35
  122. package/core/renderers/minimalist/minimalist.d.ts +0 -12
  123. package/core/renderers/minimalist/renderer.d.ts +0 -48
  124. package/core-browser.js +0 -26
  125. package/core.js +0 -26
  126. package/dart.js +0 -22
  127. package/generators/dart/colour.d.ts +0 -16
  128. package/generators/javascript/colour.d.ts +0 -16
  129. package/generators/lua/colour.d.ts +0 -16
  130. package/generators/php/colour.d.ts +0 -16
  131. package/generators/python/colour.d.ts +0 -16
  132. package/javascript.js +0 -23
  133. package/lua.js +0 -22
  134. package/msg/constants.d.ts +0 -14
  135. package/msg/qqq.d.ts +0 -14
  136. package/msg/synonyms.d.ts +0 -14
  137. package/node.js +0 -21
  138. package/php.js +0 -22
  139. package/python.js +0 -23
@@ -13,5 +13,11 @@ export interface IDeletable {
13
13
  * @returns True if deletable.
14
14
  */
15
15
  isDeletable(): boolean;
16
+ /** Disposes of this object, cleaning up any references or DOM elements. */
17
+ dispose(): void;
18
+ /** Visually indicates that the object is pending deletion. */
19
+ setDeleteStyle(wouldDelete: boolean): void;
16
20
  }
21
+ /** Returns whether the given object is an IDeletable. */
22
+ export declare function isDeletable(obj: any): obj is IDeletable;
17
23
  //# sourceMappingURL=i_deletable.d.ts.map
@@ -17,10 +17,9 @@ export interface IDeleteArea extends IDragTarget {
17
17
  * before onDragEnter/onDragOver/onDragExit.
18
18
  *
19
19
  * @param element The block or bubble currently being dragged.
20
- * @param couldConnect Whether the element could could connect to another.
21
20
  * @returns Whether the element provided would be deleted if dropped on this
22
21
  * area.
23
22
  */
24
- wouldDelete(element: IDraggable, couldConnect: boolean): boolean;
23
+ wouldDelete(element: IDraggable): boolean;
25
24
  }
26
25
  //# sourceMappingURL=i_delete_area.d.ts.map
@@ -3,10 +3,54 @@
3
3
  * Copyright 2021 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { IDeletable } from './i_deletable.js';
6
+ import { Coordinate } from '../utils/coordinate';
7
7
  /**
8
- * The interface for an object that can be dragged.
8
+ * Represents an object that can be dragged.
9
9
  */
10
- export interface IDraggable extends IDeletable {
10
+ export interface IDraggable extends IDragStrategy {
11
+ /**
12
+ * Returns the current location of the draggable in workspace
13
+ * coordinates.
14
+ *
15
+ * @returns Coordinate of current location on workspace.
16
+ */
17
+ getRelativeToSurfaceXY(): Coordinate;
11
18
  }
19
+ export interface IDragStrategy {
20
+ /** Returns true iff the element is currently movable. */
21
+ isMovable(): boolean;
22
+ /**
23
+ * Handles any drag startup (e.g moving elements to the front of the
24
+ * workspace).
25
+ *
26
+ * @param e PointerEvent that started the drag; can be used to
27
+ * check modifier keys, etc. May be missing when dragging is
28
+ * triggered programatically rather than by user.
29
+ */
30
+ startDrag(e?: PointerEvent): void;
31
+ /**
32
+ * Handles moving elements to the new location, and updating any
33
+ * visuals based on that (e.g connection previews for blocks).
34
+ *
35
+ * @param newLoc Workspace coordinate to which the draggable has
36
+ * been dragged.
37
+ * @param e PointerEvent that continued the drag. Can be
38
+ * used to check modifier keys, etc.
39
+ */
40
+ drag(newLoc: Coordinate, e?: PointerEvent): void;
41
+ /**
42
+ * Handles any drag cleanup, including e.g. connecting or deleting
43
+ * blocks.
44
+ *
45
+ * @param newLoc Workspace coordinate at which the drag finished.
46
+ * been dragged.
47
+ * @param e PointerEvent that finished the drag. Can be
48
+ * used to check modifier keys, etc.
49
+ */
50
+ endDrag(e?: PointerEvent): void;
51
+ /** Moves the draggable back to where it was at the start of the drag. */
52
+ revertDrag(): void;
53
+ }
54
+ /** Returns whether the given object is an IDraggable or not. */
55
+ export declare function isDraggable(obj: any): obj is IDraggable;
12
56
  //# sourceMappingURL=i_draggable.d.ts.map
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Coordinate } from '../utils/coordinate';
7
+ export interface IDragger {
8
+ /**
9
+ * Handles any drag startup.
10
+ *
11
+ * @param e PointerEvent that started the drag.
12
+ */
13
+ onDragStart(e: PointerEvent): void;
14
+ /**
15
+ * Handles dragging, including calculating where the element should
16
+ * actually be moved to.
17
+ *
18
+ * @param e PointerEvent that continued the drag.
19
+ * @param totalDelta The total distance, in pixels, that the mouse
20
+ * has moved since the start of the drag.
21
+ */
22
+ onDrag(e: PointerEvent, totalDelta: Coordinate): void;
23
+ /**
24
+ * Handles any drag cleanup.
25
+ *
26
+ * @param e PointerEvent that finished the drag.
27
+ * @param totalDelta The total distance, in pixels, that the mouse
28
+ * has moved since the start of the drag.
29
+ */
30
+ onDragEnd(e: PointerEvent, totalDelta: Coordinate): void;
31
+ }
32
+ //# sourceMappingURL=i_dragger.d.ts.map
@@ -7,7 +7,7 @@ export interface IHasBubble {
7
7
  /** @returns True if the bubble is currently open, false otherwise. */
8
8
  bubbleIsVisible(): boolean;
9
9
  /** Sets whether the bubble is open or not. */
10
- setBubbleVisible(visible: boolean): void;
10
+ setBubbleVisible(visible: boolean): Promise<void>;
11
11
  }
12
12
  /** Type guard that checks whether the given object is a IHasBubble. */
13
13
  export declare function hasBubble(obj: any): obj is IHasBubble;
@@ -3,6 +3,7 @@
3
3
  * Copyright 2022 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import { ParameterState } from '../serialization/procedures';
6
7
  import { IProcedureModel } from './i_procedure_model';
7
8
  /**
8
9
  * A data model for a procedure.
@@ -33,5 +34,11 @@ export interface IParameterModel {
33
34
  getId(): string;
34
35
  /** Sets the procedure model this parameter is associated with. */
35
36
  setProcedureModel(model: IProcedureModel): this;
37
+ /**
38
+ * Serializes the state of the parameter to JSON.
39
+ *
40
+ * @returns JSON serializable state of the parameter.
41
+ */
42
+ saveState(): ParameterState;
36
43
  }
37
44
  //# sourceMappingURL=i_parameter_model.d.ts.map
@@ -3,6 +3,7 @@
3
3
  * Copyright 2022 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import { State } from '../serialization/procedures.js';
6
7
  import { IParameterModel } from './i_parameter_model.js';
7
8
  /**
8
9
  * A data model for a procedure.
@@ -48,5 +49,11 @@ export interface IProcedureModel {
48
49
  * disabled, all procedure caller blocks should be disabled as well.
49
50
  */
50
51
  getEnabled(): boolean;
52
+ /**
53
+ * Serializes the state of the procedure to JSON.
54
+ *
55
+ * @returns JSON serializable state of the procedure.
56
+ */
57
+ saveState(): State;
51
58
  }
52
59
  //# sourceMappingURL=i_procedure_model.d.ts.map
@@ -3,16 +3,18 @@
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { IDeletable } from './i_deletable.js';
7
- import type { IMovable } from './i_movable.js';
6
+ import type { Workspace } from '../workspace.js';
8
7
  /**
9
8
  * The interface for an object that is selectable.
10
9
  */
11
- export interface ISelectable extends IDeletable, IMovable {
10
+ export interface ISelectable {
12
11
  id: string;
12
+ workspace: Workspace;
13
13
  /** Select this. Highlight it visually. */
14
14
  select(): void;
15
15
  /** Unselect this. Unhighlight it visually. */
16
16
  unselect(): void;
17
17
  }
18
+ /** Checks whether the given object is an ISelectable. */
19
+ export declare function isSelectable(obj: Object): obj is ISelectable;
18
20
  //# sourceMappingURL=i_selectable.d.ts.map
@@ -9,13 +9,6 @@
9
9
  * @internal
10
10
  */
11
11
  export declare const COLLAPSE_CHARS = 30;
12
- /**
13
- * When dragging a block out of a stack, split the stack in two (true), or drag
14
- * out the block healing the stack (false).
15
- *
16
- * @internal
17
- */
18
- export declare const DRAG_STACK = true;
19
12
  /**
20
13
  * Lookup table for determining the opposite type of a connection.
21
14
  *
@@ -16,6 +16,7 @@ import type { Input } from '../inputs/input.js';
16
16
  import type { IASTNodeLocation } from '../interfaces/i_ast_node_location.js';
17
17
  import { Coordinate } from '../utils/coordinate.js';
18
18
  import type { Workspace } from '../workspace.js';
19
+ import { FlyoutButton } from '../flyout_button.js';
19
20
  /**
20
21
  * Class for an AST node.
21
22
  * It is recommended that you use one of the createNode methods instead of
@@ -119,6 +120,13 @@ export declare class ASTNode {
119
120
  * on the workspace.
120
121
  */
121
122
  private navigateBetweenStacks;
123
+ /**
124
+ * Navigate between buttons and stacks of blocks on the flyout workspace.
125
+ *
126
+ * @param forward True to go forward. False to go backwards.
127
+ * @returns The next button, or next stack's first block, or null
128
+ */
129
+ private navigateFlyoutContents;
122
130
  /**
123
131
  * Finds the top most AST node for a given block.
124
132
  * This is either the previous connection, output connection or block
@@ -150,7 +158,7 @@ export declare class ASTNode {
150
158
  * Finds the source block of the location of this node.
151
159
  *
152
160
  * @returns The source block of the location, or null if the node is of type
153
- * workspace.
161
+ * workspace or button.
154
162
  */
155
163
  getSourceBlock(): Block | null;
156
164
  /**
@@ -232,6 +240,16 @@ export declare class ASTNode {
232
240
  * stack.
233
241
  */
234
242
  static createStackNode(topBlock: Block): ASTNode | null;
243
+ /**
244
+ * Create an AST node of type button. A button in this case refers
245
+ * specifically to a button in a flyout.
246
+ *
247
+ * @param button A top block has no parent and can be found in the list
248
+ * returned by workspace.getTopBlocks().
249
+ * @returns An AST node of type stack that points to the top block on the
250
+ * stack.
251
+ */
252
+ static createButtonNode(button: FlyoutButton): ASTNode | null;
235
253
  /**
236
254
  * Creates an AST node pointing to a workspace.
237
255
  *
@@ -262,7 +280,8 @@ export declare namespace ASTNode {
262
280
  NEXT = "next",
263
281
  PREVIOUS = "previous",
264
282
  STACK = "stack",
265
- WORKSPACE = "workspace"
283
+ WORKSPACE = "workspace",
284
+ BUTTON = "button"
266
285
  }
267
286
  }
268
287
  export type Params = ASTNode.Params;
package/core/options.d.ts CHANGED
@@ -32,6 +32,7 @@ export declare class Options {
32
32
  pathToMedia: string;
33
33
  hasCategories: boolean;
34
34
  moveOptions: MoveOptions;
35
+ /** @deprecated January 2019 */
35
36
  hasScrollbars: boolean;
36
37
  hasTrashcan: boolean;
37
38
  maxTrashcanContents: number;
@@ -5,7 +5,6 @@
5
5
  */
6
6
  import type { Abstract } from './events/events_abstract.js';
7
7
  import type { Field } from './field.js';
8
- import type { IBlockDragger } from './interfaces/i_block_dragger.js';
9
8
  import type { IConnectionChecker } from './interfaces/i_connection_checker.js';
10
9
  import type { IFlyout } from './interfaces/i_flyout.js';
11
10
  import type { IMetricsManager } from './interfaces/i_metrics_manager.js';
@@ -21,6 +20,7 @@ import type { ToolboxItem } from './toolbox/toolbox_item.js';
21
20
  import type { IPaster } from './interfaces/i_paster.js';
22
21
  import type { ICopyable } from './interfaces/i_copyable.js';
23
22
  import type { IConnectionPreviewer } from './interfaces/i_connection_previewer.js';
23
+ import type { IDragger } from './interfaces/i_dragger.js';
24
24
  export declare const TEST_ONLY: {
25
25
  typeMap: {
26
26
  [key: string]: {
@@ -58,7 +58,7 @@ export declare class Type<_T> {
58
58
  static FLYOUTS_VERTICAL_TOOLBOX: Type<IFlyout>;
59
59
  static FLYOUTS_HORIZONTAL_TOOLBOX: Type<IFlyout>;
60
60
  static METRICS_MANAGER: Type<IMetricsManager>;
61
- static BLOCK_DRAGGER: Type<IBlockDragger>;
61
+ static DRAGGER: Type<IDragger>;
62
62
  /** @internal */
63
63
  static SERIALIZER: Type<ISerializer>;
64
64
  /** @internal */
@@ -38,13 +38,6 @@ export declare class Drawer {
38
38
  * required.
39
39
  */
40
40
  draw(): void;
41
- /**
42
- * Hide icons that were marked as hidden.
43
- *
44
- * @deprecated Manually hiding icons is no longer necessary. To be removed
45
- * in v11.
46
- */
47
- protected hideHiddenIcons_(): void;
48
41
  /**
49
42
  * Save sizing information back to the block
50
43
  * Most of the rendering information can be thrown away at the end of the
@@ -148,6 +148,13 @@ export declare class MarkerSvg {
148
148
  * @param curNode The node to draw the marker for.
149
149
  */
150
150
  protected showWithStack_(curNode: ASTNode): void;
151
+ /**
152
+ * Position and display the marker for a flyout button.
153
+ * This is a box with extra padding around the button.
154
+ *
155
+ * @param curNode The node to draw the marker for.
156
+ */
157
+ protected showWithButton_(curNode: ASTNode): void;
151
158
  /** Show the current marker. */
152
159
  protected showCurrent_(): void;
153
160
  /**************************
@@ -12,11 +12,6 @@ import { Measurable } from './base.js';
12
12
  */
13
13
  export declare class Icon extends Measurable {
14
14
  icon: BlocklyIcon;
15
- /**
16
- * @deprecated Will be removed in v11. Create a subclass of the Icon
17
- * measurable if this data is necessary for you.
18
- */
19
- isVisible: boolean;
20
15
  flipRtl: boolean;
21
16
  /**
22
17
  * An object containing information about the space an icon takes up during
@@ -15,4 +15,6 @@ export declare const PROCEDURES = 75;
15
15
  * The priority for deserializing blocks.
16
16
  */
17
17
  export declare const BLOCKS = 50;
18
+ /** The priority for deserializing workspace comments. */
19
+ export declare const WORKSPACE_COMMENTS = 25;
18
20
  //# sourceMappingURL=priorities.d.ts.map
@@ -7,63 +7,65 @@ import { IParameterModel } from '../interfaces/i_parameter_model.js';
7
7
  import { IProcedureModel } from '../interfaces/i_procedure_model.js';
8
8
  import type { ISerializer } from '../interfaces/i_serializer.js';
9
9
  import type { Workspace } from '../workspace.js';
10
- /**
11
- * Representation of a procedure data model.
12
- */
10
+ /** Represents the state of a procedure model. */
13
11
  export interface State {
14
12
  id: string;
15
13
  name: string;
16
14
  returnTypes: string[] | null;
17
15
  parameters?: ParameterState[];
16
+ [key: string]: unknown;
18
17
  }
19
- /**
20
- * Representation of a parameter data model.
21
- */
18
+ /** Represents the state of a parameter model. */
22
19
  export interface ParameterState {
23
20
  id: string;
24
21
  name: string;
25
22
  types?: string[];
23
+ [key: string]: unknown;
26
24
  }
27
25
  /**
28
26
  * A newable signature for an IProcedureModel.
29
27
  *
30
28
  * Refer to
31
- * https://www.typescriptlang.org/docs/handbook/2/generics.html#using-class-types-in-generics
29
+ * https://www.typescriptlang.org/docs/handbook/interfaces.html#difference-between-the-static-and-instance-sides-of-classes
32
30
  * for what is going on with this.
33
31
  */
34
- type ProcedureModelConstructor<ProcedureModel extends IProcedureModel> = new (workspace: Workspace, name: string, id: string) => ProcedureModel;
32
+ interface ProcedureModelConstructor<ProcedureModel extends IProcedureModel> {
33
+ new (workspace: Workspace, name: string, id: string): ProcedureModel;
34
+ /**
35
+ * Deserializes the JSON state and returns a procedure model.
36
+ *
37
+ * @param state The state to deserialize.
38
+ * @param workspace The workspace to load the procedure model into.
39
+ * @returns The constructed procedure model.
40
+ */
41
+ loadState(state: Object, workspace: Workspace): ProcedureModel;
42
+ }
35
43
  /**
36
44
  * A newable signature for an IParameterModel.
37
45
  *
38
46
  * Refer to
39
- * https://www.typescriptlang.org/docs/handbook/2/generics.html#using-class-types-in-generics
47
+ * https://www.typescriptlang.org/docs/handbook/interfaces.html#difference-between-the-static-and-instance-sides-of-classes
40
48
  * for what is going on with this.
41
49
  */
42
- type ParameterModelConstructor<ParameterModel extends IParameterModel> = new (workspace: Workspace, name: string, id: string) => ParameterModel;
50
+ interface ParameterModelConstructor<ParameterModel extends IParameterModel> {
51
+ new (workspace: Workspace, name: string, id: string): ParameterModel;
52
+ /**
53
+ * Deserializes the JSON state and returns a parameter model.
54
+ *
55
+ * @param state The state to deserialize.
56
+ * @param workspace The workspace to load the parameter model into.
57
+ * @returns The constructed parameter model.
58
+ */
59
+ loadState(state: Object, workspace: Workspace): ParameterModel;
60
+ }
43
61
  /**
44
62
  * Serializes the given IProcedureModel to JSON.
45
- *
46
- * @internal
47
63
  */
48
64
  export declare function saveProcedure(proc: IProcedureModel): State;
49
- /**
50
- * Serializes the given IParameterModel to JSON.
51
- *
52
- * @internal
53
- */
54
- export declare function saveParameter(param: IParameterModel): ParameterState;
55
65
  /**
56
66
  * Deserializes the given procedure model State from JSON.
57
- *
58
- * @internal
59
67
  */
60
68
  export declare function loadProcedure<ProcedureModel extends IProcedureModel, ParameterModel extends IParameterModel>(procedureModelClass: ProcedureModelConstructor<ProcedureModel>, parameterModelClass: ParameterModelConstructor<ParameterModel>, state: State, workspace: Workspace): ProcedureModel;
61
- /**
62
- * Deserializes the given ParameterState from JSON.
63
- *
64
- * @internal
65
- */
66
- export declare function loadParameter<ParameterModel extends IParameterModel>(parameterModelClass: ParameterModelConstructor<ParameterModel>, state: ParameterState, workspace: Workspace): ParameterModel;
67
69
  /** Serializer for saving and loading procedure state. */
68
70
  export declare class ProcedureSerializer<ProcedureModel extends IProcedureModel, ParameterModel extends IParameterModel> implements ISerializer {
69
71
  private readonly procedureModelClass;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { ISerializer } from '../interfaces/i_serializer.js';
7
+ import { Workspace } from '../workspace.js';
8
+ import { WorkspaceComment } from '../comments/workspace_comment.js';
9
+ export interface State {
10
+ id?: string;
11
+ text?: string;
12
+ x?: number;
13
+ y?: number;
14
+ width?: number;
15
+ height?: number;
16
+ collapsed?: boolean;
17
+ editable?: boolean;
18
+ movable?: boolean;
19
+ deletable?: boolean;
20
+ }
21
+ /** Serializes the state of the given comment to JSON. */
22
+ export declare function save(comment: WorkspaceComment, { addCoordinates, saveIds, }?: {
23
+ addCoordinates?: boolean;
24
+ saveIds?: boolean;
25
+ }): State;
26
+ /** Appends the comment defined by the given state to the given workspace. */
27
+ export declare function append(state: State, workspace: Workspace, { recordUndo }?: {
28
+ recordUndo?: boolean;
29
+ }): WorkspaceComment;
30
+ /** Serializer for saving and loading workspace comment state. */
31
+ export declare class WorkspaceCommentSerializer implements ISerializer {
32
+ priority: number;
33
+ /**
34
+ * Returns the state of all workspace comments in the given workspace.
35
+ */
36
+ save(workspace: Workspace): State[] | null;
37
+ /**
38
+ * Deserializes the comments defined by the given state into the given
39
+ * workspace.
40
+ */
41
+ load(state: State[], workspace: Workspace): void;
42
+ /** Disposes of any comments that exist on the given workspace. */
43
+ clear(workspace: Workspace): void;
44
+ }
45
+ //# sourceMappingURL=workspace_comments.d.ts.map
@@ -13,6 +13,7 @@ import * as procedures from './serialization/procedures.js';
13
13
  import * as registry from './serialization/registry.js';
14
14
  import * as variables from './serialization/variables.js';
15
15
  import * as workspaces from './serialization/workspaces.js';
16
+ import * as workspaceComments from './serialization/workspace_comments.js';
16
17
  import { ISerializer } from './interfaces/i_serializer.js';
17
- export { blocks, exceptions, priorities, procedures, registry, variables, workspaces, ISerializer, };
18
+ export { blocks, exceptions, priorities, procedures, registry, variables, workspaces, workspaceComments, ISerializer, };
18
19
  //# sourceMappingURL=serialization.d.ts.map
@@ -187,11 +187,10 @@ export declare class Toolbox extends DeleteArea implements IAutoHideable, IKeybo
187
187
  * before onDragEnter/onDragOver/onDragExit.
188
188
  *
189
189
  * @param element The block or bubble currently being dragged.
190
- * @param _couldConnect Whether the element could could connect to another.
191
190
  * @returns Whether the element provided would be deleted if dropped on this
192
191
  * area.
193
192
  */
194
- wouldDelete(element: IDraggable, _couldConnect: boolean): boolean;
193
+ wouldDelete(element: IDraggable): boolean;
195
194
  /**
196
195
  * Handles when a cursor with a block or bubble enters this drag target.
197
196
  *
@@ -86,15 +86,6 @@ export declare function removeNode(node: Node | null): Node | null;
86
86
  * @param refNode Existing element to precede new node.
87
87
  */
88
88
  export declare function insertAfter(newNode: Element, refNode: Element): void;
89
- /**
90
- * Whether a node contains another node.
91
- *
92
- * @param parent The node that should contain the other node.
93
- * @param descendant The node to test presence of.
94
- * @returns Whether the parent node contains the descendant node.
95
- * @deprecated Use native 'contains' DOM method.
96
- */
97
- export declare function containsNode(parent: Node, descendant: Node): boolean;
98
89
  /**
99
90
  * Sets the CSS transform property on an element. This function sets the
100
91
  * non-vendor-prefixed and vendor-prefixed versions for backwards compatibility
@@ -16,7 +16,7 @@ export declare enum KeyCodes {
16
16
  MAC_ENTER = 3,
17
17
  BACKSPACE = 8,
18
18
  TAB = 9,
19
- NUM_CENTER = 12,
19
+ NUM_CENTER = 12,// NUMLOCK on FF/Safari Mac
20
20
  ENTER = 13,
21
21
  SHIFT = 16,
22
22
  CTRL = 17,
@@ -25,18 +25,18 @@ export declare enum KeyCodes {
25
25
  CAPS_LOCK = 20,
26
26
  ESC = 27,
27
27
  SPACE = 32,
28
- PAGE_UP = 33,
29
- PAGE_DOWN = 34,
30
- END = 35,
31
- HOME = 36,
32
- LEFT = 37,
33
- UP = 38,
34
- RIGHT = 39,
35
- DOWN = 40,
36
- PLUS_SIGN = 43,
28
+ PAGE_UP = 33,// also NUM_NORTH_EAST
29
+ PAGE_DOWN = 34,// also NUM_SOUTH_EAST
30
+ END = 35,// also NUM_SOUTH_WEST
31
+ HOME = 36,// also NUM_NORTH_WEST
32
+ LEFT = 37,// also NUM_WEST
33
+ UP = 38,// also NUM_NORTH
34
+ RIGHT = 39,// also NUM_EAST
35
+ DOWN = 40,// also NUM_SOUTH
36
+ PLUS_SIGN = 43,// NOT numpad plus
37
37
  PRINT_SCREEN = 44,
38
- INSERT = 45,
39
- DELETE = 46,
38
+ INSERT = 45,// also NUM_INSERT
39
+ DELETE = 46,// also NUM_DELETE
40
40
  ZERO = 48,
41
41
  ONE = 49,
42
42
  TWO = 50,
@@ -47,11 +47,11 @@ export declare enum KeyCodes {
47
47
  SEVEN = 55,
48
48
  EIGHT = 56,
49
49
  NINE = 57,
50
- FF_SEMICOLON = 59,
51
- FF_EQUALS = 61,
52
- FF_DASH = 173,
50
+ FF_SEMICOLON = 59,// Firefox (Gecko) fires this for semicolon instead of 186
51
+ FF_EQUALS = 61,// Firefox (Gecko) fires this for equals instead of 187
52
+ FF_DASH = 173,// Firefox (Gecko) fires this for dash instead of 189
53
53
  FF_HASH = 163,
54
- QUESTION_MARK = 63,
54
+ QUESTION_MARK = 63,// needs localization
55
55
  AT_SIGN = 64,
56
56
  A = 65,
57
57
  B = 66,
@@ -79,7 +79,7 @@ export declare enum KeyCodes {
79
79
  X = 88,
80
80
  Y = 89,
81
81
  Z = 90,
82
- META = 91,
82
+ META = 91,// WIN_KEY_LEFT
83
83
  WIN_KEY_RIGHT = 92,
84
84
  CONTEXT_MENU = 93,
85
85
  NUM_ZERO = 96,
@@ -113,22 +113,22 @@ export declare enum KeyCodes {
113
113
  SCROLL_LOCK = 145,
114
114
  FIRST_MEDIA_KEY = 166,
115
115
  LAST_MEDIA_KEY = 183,
116
- SEMICOLON = 186,
117
- DASH = 189,
118
- EQUALS = 187,
119
- COMMA = 188,
120
- PERIOD = 190,
121
- SLASH = 191,
122
- APOSTROPHE = 192,
123
- TILDE = 192,
124
- SINGLE_QUOTE = 222,
125
- OPEN_SQUARE_BRACKET = 219,
126
- BACKSLASH = 220,
127
- CLOSE_SQUARE_BRACKET = 221,
116
+ SEMICOLON = 186,// needs localization
117
+ DASH = 189,// needs localization
118
+ EQUALS = 187,// needs localization
119
+ COMMA = 188,// needs localization
120
+ PERIOD = 190,// needs localization
121
+ SLASH = 191,// needs localization
122
+ APOSTROPHE = 192,// needs localization
123
+ TILDE = 192,// needs localization
124
+ SINGLE_QUOTE = 222,// needs localization
125
+ OPEN_SQUARE_BRACKET = 219,// needs localization
126
+ BACKSLASH = 220,// needs localization
127
+ CLOSE_SQUARE_BRACKET = 221,// needs localization
128
128
  WIN_KEY = 224,
129
- MAC_FF_META = 224,
130
- MAC_WK_CMD_LEFT = 91,
131
- MAC_WK_CMD_RIGHT = 93,
129
+ MAC_FF_META = 224,// Firefox (Gecko) fires this for the meta key instead of 91
130
+ MAC_WK_CMD_LEFT = 91,// WebKit Left Command key fired, same as META
131
+ MAC_WK_CMD_RIGHT = 93,// WebKit Right Command key fired, different from META
132
132
  WIN_IME = 229,
133
133
  VK_NONAME = 252,
134
134
  PHANTOM = 255
@@ -30,5 +30,15 @@ export declare class Size {
30
30
  * are null.
31
31
  */
32
32
  static equals(a: Size | null, b: Size | null): boolean;
33
+ /**
34
+ * Returns a new size with the maximum width and height values out of both
35
+ * sizes.
36
+ */
37
+ static max(a: Size, b: Size): Size;
38
+ /**
39
+ * Returns a new size with the minimum width and height values out of both
40
+ * sizes.
41
+ */
42
+ static min(a: Size, b: Size): Size;
33
43
  }
34
44
  //# sourceMappingURL=size.d.ts.map
@@ -3,16 +3,6 @@
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- /**
7
- * Fast prefix-checker.
8
- * Copied from Closure's goog.string.startsWith.
9
- *
10
- * @param str The string to check.
11
- * @param prefix A string to look for at the start of `str`.
12
- * @returns True if `str` begins with `prefix`.
13
- * @deprecated Use built-in **string.startsWith** instead.
14
- */
15
- export declare function startsWith(str: string, prefix: string): boolean;
16
6
  /**
17
7
  * Given an array of strings, return the length of the shortest one.
18
8
  *