blockly 10.3.1 → 10.4.0-beta.0

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 (207) hide show
  1. package/blockly.min.js +108 -87
  2. package/blockly_compressed.js +107 -87
  3. package/blockly_compressed.js.map +1 -1
  4. package/core/block_dragger.d.ts +39 -4
  5. package/core/blockly.d.ts +4 -0
  6. package/core/connection_previewers/insertion_marker_previewer.d.ts +54 -0
  7. package/core/insertion_marker_manager.d.ts +2 -0
  8. package/core/interfaces/i_connection_previewer.d.ts +39 -0
  9. package/core/registry.d.ts +4 -2
  10. package/core/rendered_connection.d.ts +3 -1
  11. package/core/renderers/common/constants.d.ts +6 -2
  12. package/core/renderers/common/drawer.d.ts +18 -0
  13. package/core/renderers/common/i_path_object.d.ts +6 -15
  14. package/core/renderers/common/info.d.ts +5 -2
  15. package/core/renderers/common/path_object.d.ts +13 -0
  16. package/core/renderers/common/renderer.d.ts +3 -0
  17. package/core/renderers/measurables/connection.d.ts +1 -0
  18. package/core/renderers/zelos/drawer.d.ts +4 -0
  19. package/core/renderers/zelos/renderer.d.ts +4 -2
  20. package/core/workspace_audio.d.ts +10 -0
  21. package/dart.d.ts +2 -0
  22. package/generators/dart/colour.d.ts +16 -0
  23. package/generators/dart/dart_generator.d.ts +100 -0
  24. package/generators/dart/lists.d.ts +24 -0
  25. package/generators/dart/logic.d.ts +20 -0
  26. package/generators/dart/loops.d.ts +14 -0
  27. package/generators/dart/math.d.ts +26 -0
  28. package/generators/dart/procedures.d.ts +17 -0
  29. package/generators/dart/text.d.ts +29 -0
  30. package/generators/dart/variables.d.ts +14 -0
  31. package/generators/dart/variables_dynamic.d.ts +10 -0
  32. package/generators/dart.d.ts +18 -0
  33. package/generators/javascript/colour.d.ts +16 -0
  34. package/generators/javascript/javascript_generator.d.ts +120 -0
  35. package/generators/javascript/lists.d.ts +24 -0
  36. package/generators/javascript/logic.d.ts +20 -0
  37. package/generators/javascript/loops.d.ts +14 -0
  38. package/generators/javascript/math.d.ts +26 -0
  39. package/generators/javascript/procedures.d.ts +17 -0
  40. package/generators/javascript/text.d.ts +29 -0
  41. package/generators/javascript/variables.d.ts +14 -0
  42. package/generators/javascript/variables_dynamic.d.ts +10 -0
  43. package/generators/javascript.d.ts +18 -0
  44. package/generators/lua/colour.d.ts +16 -0
  45. package/generators/lua/lists.d.ts +24 -0
  46. package/generators/lua/logic.d.ts +20 -0
  47. package/generators/lua/loops.d.ts +14 -0
  48. package/generators/lua/lua_generator.d.ts +85 -0
  49. package/generators/lua/math.d.ts +26 -0
  50. package/generators/lua/procedures.d.ts +17 -0
  51. package/generators/lua/text.d.ts +29 -0
  52. package/generators/lua/variables.d.ts +14 -0
  53. package/generators/lua/variables_dynamic.d.ts +10 -0
  54. package/generators/lua.d.ts +16 -0
  55. package/generators/php/colour.d.ts +16 -0
  56. package/generators/php/lists.d.ts +21 -0
  57. package/generators/php/logic.d.ts +20 -0
  58. package/generators/php/loops.d.ts +14 -0
  59. package/generators/php/math.d.ts +26 -0
  60. package/generators/php/php_generator.d.ts +118 -0
  61. package/generators/php/procedures.d.ts +14 -0
  62. package/generators/php/text.d.ts +29 -0
  63. package/generators/php/variables.d.ts +14 -0
  64. package/generators/php/variables_dynamic.d.ts +10 -0
  65. package/generators/php.d.ts +18 -0
  66. package/generators/python/colour.d.ts +16 -0
  67. package/generators/python/lists.d.ts +21 -0
  68. package/generators/python/logic.d.ts +20 -0
  69. package/generators/python/loops.d.ts +14 -0
  70. package/generators/python/math.d.ts +26 -0
  71. package/generators/python/procedures.d.ts +14 -0
  72. package/generators/python/python_generator.d.ts +108 -0
  73. package/generators/python/text.d.ts +26 -0
  74. package/generators/python/variables.d.ts +14 -0
  75. package/generators/python/variables_dynamic.d.ts +10 -0
  76. package/generators/python.d.ts +18 -0
  77. package/javascript.d.ts +2 -0
  78. package/lua.d.ts +2 -0
  79. package/msg/ab.js +2 -1
  80. package/msg/ace.js +1 -0
  81. package/msg/af.js +1 -0
  82. package/msg/am.js +1 -0
  83. package/msg/ar.js +8 -7
  84. package/msg/ast.js +2 -1
  85. package/msg/az.js +2 -1
  86. package/msg/ba.js +5 -4
  87. package/msg/bcc.js +6 -5
  88. package/msg/be-tarask.js +1 -0
  89. package/msg/be.js +1 -0
  90. package/msg/bg.js +4 -3
  91. package/msg/bn.js +1 -0
  92. package/msg/br.js +3 -2
  93. package/msg/bs.js +1 -0
  94. package/msg/ca.js +1 -0
  95. package/msg/cdo.js +1 -0
  96. package/msg/ce.js +441 -0
  97. package/msg/cs.js +1 -0
  98. package/msg/da.js +1 -0
  99. package/msg/de.js +3 -2
  100. package/msg/diq.js +5 -4
  101. package/msg/dtp.js +441 -0
  102. package/msg/dty.js +2 -1
  103. package/msg/ee.js +3 -2
  104. package/msg/el.js +2 -1
  105. package/msg/en-gb.js +1 -0
  106. package/msg/en.js +1 -0
  107. package/msg/eo.js +1 -0
  108. package/msg/es.js +1 -0
  109. package/msg/et.js +1 -0
  110. package/msg/eu.js +1 -0
  111. package/msg/fa.js +5 -4
  112. package/msg/fi.js +1 -0
  113. package/msg/fo.js +1 -0
  114. package/msg/fr.js +2 -1
  115. package/msg/frr.js +1 -0
  116. package/msg/gl.js +2 -1
  117. package/msg/gn.js +2 -1
  118. package/msg/gor.js +1 -0
  119. package/msg/ha.js +1 -0
  120. package/msg/hak.js +1 -0
  121. package/msg/he.js +3 -2
  122. package/msg/hi.js +1 -0
  123. package/msg/hr.js +2 -1
  124. package/msg/hrx.js +1 -0
  125. package/msg/hsb.js +441 -0
  126. package/msg/hu.js +1 -0
  127. package/msg/hy.js +9 -8
  128. package/msg/ia.js +1 -0
  129. package/msg/id.js +5 -4
  130. package/msg/ig.js +1 -0
  131. package/msg/inh.js +1 -0
  132. package/msg/is.js +1 -0
  133. package/msg/it.js +2 -1
  134. package/msg/ja.js +1 -0
  135. package/msg/ka.js +1 -0
  136. package/msg/kab.js +5 -4
  137. package/msg/kbd-cyrl.js +1 -0
  138. package/msg/km.js +10 -9
  139. package/msg/kn.js +31 -30
  140. package/msg/ko.js +2 -1
  141. package/msg/ksh.js +1 -0
  142. package/msg/ku-latn.js +1 -0
  143. package/msg/ky.js +4 -3
  144. package/msg/la.js +1 -0
  145. package/msg/lb.js +1 -0
  146. package/msg/lki.js +5 -4
  147. package/msg/lo.js +2 -1
  148. package/msg/lrc.js +1 -0
  149. package/msg/lt.js +5 -4
  150. package/msg/lv.js +1 -0
  151. package/msg/mg.js +1 -0
  152. package/msg/mk.js +2 -1
  153. package/msg/ml.js +1 -0
  154. package/msg/mnw.js +2 -1
  155. package/msg/ms.js +2 -1
  156. package/msg/my.js +2 -1
  157. package/msg/mzn.js +1 -0
  158. package/msg/nb.js +1 -0
  159. package/msg/ne.js +3 -2
  160. package/msg/nl.js +2 -1
  161. package/msg/oc.js +1 -0
  162. package/msg/olo.js +1 -0
  163. package/msg/pa.js +1 -0
  164. package/msg/pl.js +3 -2
  165. package/msg/pms.js +1 -0
  166. package/msg/ps.js +1 -0
  167. package/msg/pt-br.js +1 -0
  168. package/msg/pt.js +17 -16
  169. package/msg/ro.js +2 -1
  170. package/msg/ru.js +7 -6
  171. package/msg/sc.js +2 -1
  172. package/msg/sco.js +1 -0
  173. package/msg/sd.js +1 -0
  174. package/msg/shn.js +2 -1
  175. package/msg/si.js +1 -0
  176. package/msg/sk.js +1 -0
  177. package/msg/skr-arab.js +2 -1
  178. package/msg/sl.js +1 -0
  179. package/msg/smn.js +1 -0
  180. package/msg/sq.js +17 -16
  181. package/msg/sr-latn.js +3 -2
  182. package/msg/sr.js +2 -1
  183. package/msg/sv.js +1 -0
  184. package/msg/sw.js +1 -0
  185. package/msg/ta.js +13 -12
  186. package/msg/tcy.js +6 -5
  187. package/msg/tdd.js +2 -1
  188. package/msg/te.js +2 -1
  189. package/msg/th.js +2 -1
  190. package/msg/ti.js +1 -0
  191. package/msg/tl.js +2 -1
  192. package/msg/tlh.js +1 -0
  193. package/msg/tr.js +2 -1
  194. package/msg/ug-arab.js +15 -14
  195. package/msg/uk.js +3 -2
  196. package/msg/ur.js +5 -4
  197. package/msg/uz.js +1 -0
  198. package/msg/vi.js +2 -1
  199. package/msg/xmf.js +1 -0
  200. package/msg/yo.js +2 -1
  201. package/msg/yue.js +1 -0
  202. package/msg/zgh.js +1 -0
  203. package/msg/zh-hans.js +2 -1
  204. package/msg/zh-hant.js +1 -0
  205. package/package.json +3 -3
  206. package/php.d.ts +2 -0
  207. package/python.d.ts +2 -0
@@ -11,10 +11,10 @@
11
11
  import './events/events_block_drag.js';
12
12
  import type { BlockSvg } from './block_svg.js';
13
13
  import type { Icon } from './icons/icon.js';
14
- import { InsertionMarkerManager } from './insertion_marker_manager.js';
15
14
  import type { IBlockDragger } from './interfaces/i_block_dragger.js';
16
15
  import { Coordinate } from './utils/coordinate.js';
17
16
  import type { WorkspaceSvg } from './workspace_svg.js';
17
+ import { IConnectionPreviewer } from './blockly.js';
18
18
  /**
19
19
  * Class for a block dragger. It moves blocks around the workspace when they
20
20
  * are being dragged by a mouse or touch.
@@ -22,11 +22,12 @@ import type { WorkspaceSvg } from './workspace_svg.js';
22
22
  export declare class BlockDragger implements IBlockDragger {
23
23
  /** The top block in the stack that is being dragged. */
24
24
  protected draggingBlock_: BlockSvg;
25
- protected draggedConnectionManager_: InsertionMarkerManager;
25
+ protected connectionPreviewer: IConnectionPreviewer;
26
26
  /** The workspace on which the block is being dragged. */
27
27
  protected workspace_: WorkspaceSvg;
28
28
  /** Which drag area the mouse pointer is over, if any. */
29
29
  private dragTarget_;
30
+ private connectionCandidate;
30
31
  /** Whether the block would be deleted if dropped immediately. */
31
32
  protected wouldDeleteBlock_: boolean;
32
33
  protected startXY_: Coordinate;
@@ -76,10 +77,43 @@ export declare class BlockDragger implements IBlockDragger {
76
77
  * display accordingly.
77
78
  *
78
79
  * @param e The most recent move event.
79
- * @param currentDragDeltaXY How far the pointer has moved from the position
80
+ * @param delta How far the pointer has moved from the position
80
81
  * at the start of the drag, in pixel units.
81
82
  */
82
- drag(e: PointerEvent, currentDragDeltaXY: Coordinate): void;
83
+ drag(e: PointerEvent, delta: Coordinate): void;
84
+ private moveBlock;
85
+ private updateDragTargets;
86
+ /**
87
+ * Returns true if we would delete the block if it was dropped at this time,
88
+ * false otherwise.
89
+ */
90
+ private wouldDeleteBlock;
91
+ private updateConnectionPreview;
92
+ /**
93
+ * Returns true if the given orphan block can connect at the end of the
94
+ * top block's stack or row, false otherwise.
95
+ */
96
+ private orphanCanConnectAtEnd;
97
+ /**
98
+ * Returns true if the current candidate is better than the new candidate.
99
+ *
100
+ * We slightly prefer the current candidate even if it is farther away.
101
+ */
102
+ private currCandidateIsBetter;
103
+ /**
104
+ * Returns the closest valid candidate connection, if one can be found.
105
+ *
106
+ * Valid neighbour connections are within the configured start radius, with a
107
+ * compatible type (input, output, etc) and connection check.
108
+ */
109
+ private getConnectionCandidate;
110
+ /**
111
+ * Returns all of the connections we might connect to blocks on the workspace.
112
+ *
113
+ * Includes any connections on the dragging block, and any last next
114
+ * connection on the stack (if one exists).
115
+ */
116
+ private getLocalConnections;
83
117
  /**
84
118
  * Finish a block drag and put the block back on the workspace.
85
119
  *
@@ -112,6 +146,7 @@ export declare class BlockDragger implements IBlockDragger {
112
146
  * Updates the necessary information to place a block at a certain location.
113
147
  */
114
148
  protected updateBlockAfterMove_(): void;
149
+ private applyConnections;
115
150
  /** Fire a UI event at the end of a block drag. */
116
151
  protected fireDragEndEvent_(): void;
117
152
  /**
package/core/blockly.d.ts CHANGED
@@ -64,6 +64,7 @@ import { Input } from './inputs/input.js';
64
64
  import { inputTypes } from './inputs/input_types.js';
65
65
  import * as inputs from './inputs.js';
66
66
  import { InsertionMarkerManager } from './insertion_marker_manager.js';
67
+ import { InsertionMarkerPreviewer } from './connection_previewers/insertion_marker_previewer.js';
67
68
  import { IASTNodeLocation } from './interfaces/i_ast_node_location.js';
68
69
  import { IASTNodeLocationSvg } from './interfaces/i_ast_node_location_svg.js';
69
70
  import { IASTNodeLocationWithBlock } from './interfaces/i_ast_node_location_with_block.js';
@@ -74,6 +75,7 @@ import { IBubble } from './interfaces/i_bubble.js';
74
75
  import { ICollapsibleToolboxItem } from './interfaces/i_collapsible_toolbox_item.js';
75
76
  import { IComponent } from './interfaces/i_component.js';
76
77
  import { IConnectionChecker } from './interfaces/i_connection_checker.js';
78
+ import { IConnectionPreviewer } from './interfaces/i_connection_previewer.js';
77
79
  import { IContextMenu } from './interfaces/i_contextmenu.js';
78
80
  import { ICopyable, isCopyable } from './interfaces/i_copyable.js';
79
81
  import { IDeletable } from './interfaces/i_deletable.js';
@@ -370,6 +372,7 @@ export { IBubble };
370
372
  export { ICollapsibleToolboxItem };
371
373
  export { IComponent };
372
374
  export { IConnectionChecker };
375
+ export { IConnectionPreviewer };
373
376
  export { IContextMenu };
374
377
  export { icons };
375
378
  export { ICopyable, isCopyable };
@@ -386,6 +389,7 @@ export { IMovable };
386
389
  export { Input };
387
390
  export { inputs };
388
391
  export { InsertionMarkerManager };
392
+ export { InsertionMarkerPreviewer };
389
393
  export { IObservable, isObservable };
390
394
  export { IPaster, isPaster };
391
395
  export { IPositionable };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { BlockSvg } from '../block_svg.js';
7
+ import { IConnectionPreviewer } from '../interfaces/i_connection_previewer.js';
8
+ import { RenderedConnection } from '../rendered_connection.js';
9
+ export declare class InsertionMarkerPreviewer implements IConnectionPreviewer {
10
+ private readonly workspace;
11
+ private fadedBlock;
12
+ private markerConn;
13
+ private draggedConn;
14
+ private staticConn;
15
+ constructor(draggedBlock: BlockSvg);
16
+ /**
17
+ * Display a connection preview where the draggedCon connects to the
18
+ * staticCon, replacing the replacedBlock (currently connected to the
19
+ * staticCon).
20
+ *
21
+ * @param draggedConn The connection on the block stack being dragged.
22
+ * @param staticConn The connection not being dragged that we are
23
+ * connecting to.
24
+ * @param replacedBlock The block currently connected to the staticCon that
25
+ * is being replaced.
26
+ */
27
+ previewReplacement(draggedConn: RenderedConnection, staticConn: RenderedConnection, replacedBlock: BlockSvg): void;
28
+ /**
29
+ * Display a connection preview where the draggedCon connects to the
30
+ * staticCon, and no block is being relaced.
31
+ *
32
+ * @param draggedConn The connection on the block stack being dragged.
33
+ * @param staticConn The connection not being dragged that we are
34
+ * connecting to.
35
+ */
36
+ previewConnection(draggedConn: RenderedConnection, staticConn: RenderedConnection): void;
37
+ private createInsertionMarker;
38
+ /**
39
+ * Gets the connection on the marker block that matches the original
40
+ * connection on the original block.
41
+ *
42
+ * @param orig The original block.
43
+ * @param marker The marker block (where we want to find the matching
44
+ * connection).
45
+ * @param origConn The original connection.
46
+ */
47
+ private getMatchingConnection;
48
+ /** Hide any previews that are currently displayed. */
49
+ hidePreview(): void;
50
+ private hideInsertionMarker;
51
+ /** Dispose of any references held by this connection previewer. */
52
+ dispose(): void;
53
+ }
54
+ //# sourceMappingURL=insertion_marker_previewer.d.ts.map
@@ -10,6 +10,8 @@ import type { Coordinate } from './utils/coordinate.js';
10
10
  * Class that controls updates to connections during drags. It is primarily
11
11
  * responsible for finding the closest eligible connection and highlighting or
12
12
  * unhighlighting it as needed during a drag.
13
+ *
14
+ * @deprecated v10 - Use an IConnectionPreviewer instead.
13
15
  */
14
16
  export declare class InsertionMarkerManager {
15
17
  /**
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { BlockSvg } from '../block_svg';
7
+ import type { RenderedConnection } from '../rendered_connection';
8
+ /**
9
+ * Displays visual "previews" of where a block will be connected if it is
10
+ * dropped.
11
+ */
12
+ export interface IConnectionPreviewer {
13
+ /**
14
+ * Display a connection preview where the draggedCon connects to the
15
+ * staticCon, replacing the replacedBlock (currently connected to the
16
+ * staticCon).
17
+ *
18
+ * @param draggedCon The connection on the block stack being dragged.
19
+ * @param staticCon The connection not being dragged that we are
20
+ * connecting to.
21
+ * @param replacedBlock The block currently connected to the staticCon that
22
+ * is being replaced.
23
+ */
24
+ previewReplacement(draggedConn: RenderedConnection, staticConn: RenderedConnection, replacedBlock: BlockSvg): void;
25
+ /**
26
+ * Display a connection preview where the draggedCon connects to the
27
+ * staticCon, and no block is being relaced.
28
+ *
29
+ * @param draggedCon The connection on the block stack being dragged.
30
+ * @param staticCon The connection not being dragged that we are
31
+ * connecting to.
32
+ */
33
+ previewConnection(draggedConn: RenderedConnection, staticConn: RenderedConnection): void;
34
+ /** Hide any previews that are currently displayed. */
35
+ hidePreview(): void;
36
+ /** Dispose of any references held by this connection previewer. */
37
+ dispose(): void;
38
+ }
39
+ //# sourceMappingURL=i_connection_previewer.d.ts.map
@@ -18,8 +18,9 @@ import type { Options } from './options.js';
18
18
  import type { Renderer } from './renderers/common/renderer.js';
19
19
  import type { Theme } from './theme.js';
20
20
  import type { ToolboxItem } from './toolbox/toolbox_item.js';
21
- import { IPaster } from './interfaces/i_paster.js';
22
- import { ICopyable } from './interfaces/i_copyable.js';
21
+ import type { IPaster } from './interfaces/i_paster.js';
22
+ import type { ICopyable } from './interfaces/i_copyable.js';
23
+ import type { IConnectionPreviewer } from './interfaces/i_connection_previewer.js';
23
24
  export declare const TEST_ONLY: {
24
25
  typeMap: {
25
26
  [key: string]: {
@@ -45,6 +46,7 @@ export declare class Type<_T> {
45
46
  */
46
47
  toString(): string;
47
48
  static CONNECTION_CHECKER: Type<IConnectionChecker>;
49
+ static CONNECTION_PREVIEWER: Type<IConnectionPreviewer>;
48
50
  static CURSOR: Type<Cursor>;
49
51
  static EVENT: Type<Abstract>;
50
52
  static FIELD: Type<Field<any>>;
@@ -21,7 +21,7 @@ export declare class RenderedConnection extends Connection {
21
21
  private readonly dbOpposite;
22
22
  private readonly offsetInBlock;
23
23
  private trackedState;
24
- private highlightPath;
24
+ private highlighted;
25
25
  /** Connection this connection connects to. Null if not connected. */
26
26
  targetConnection: RenderedConnection | null;
27
27
  /**
@@ -130,6 +130,8 @@ export declare class RenderedConnection extends Connection {
130
130
  highlight(): void;
131
131
  /** Remove the highlighting around this connection. */
132
132
  unhighlight(): void;
133
+ /** Returns true if this connection is highlighted, false otherwise. */
134
+ isHighlighted(): boolean;
133
135
  /**
134
136
  * Set whether this connections is tracked in the database or not.
135
137
  *
@@ -39,8 +39,8 @@ export interface PuzzleTab {
39
39
  type: number;
40
40
  width: number;
41
41
  height: number;
42
- pathDown: string | ((p1: number) => string);
43
- pathUp: string | ((p1: number) => string);
42
+ pathDown: string;
43
+ pathUp: string;
44
44
  }
45
45
  /**
46
46
  * An object containing sizing and path information about collapsed block
@@ -78,6 +78,10 @@ export type Shape = BaseShape | DynamicShape;
78
78
  * @returns Whether the shape is a dynamic shape or not.
79
79
  */
80
80
  export declare function isDynamicShape(shape: Shape): shape is DynamicShape;
81
+ /** Returns whether the shape is a puzzle tab or not. */
82
+ export declare function isPuzzleTab(shape: Shape): shape is PuzzleTab;
83
+ /** Returns whether the shape is a notch or not. */
84
+ export declare function isNotch(shape: Shape): shape is Notch;
81
85
  /**
82
86
  * An object that provides constants for rendering blocks.
83
87
  */
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import type { BlockSvg } from '../../block_svg.js';
7
7
  import { Coordinate } from '../../utils.js';
8
+ import { Connection } from '../measurables/connection.js';
8
9
  import type { Field } from '../measurables/field.js';
9
10
  import type { Icon } from '../measurables/icon.js';
10
11
  import type { InlineInput } from '../measurables/inline_input.js';
@@ -141,5 +142,22 @@ export declare class Drawer {
141
142
  protected positionNextConnection_(): void;
142
143
  /** Position the output connection on a block. */
143
144
  protected positionOutputConnection_(): void;
145
+ /**
146
+ * Updates the path object to reflect which connections on the block are
147
+ * highlighted.
148
+ */
149
+ protected updateConnectionHighlights(): void;
150
+ /** Returns a path to highlight the given connection. */
151
+ drawConnectionHighlightPath(measurable: Connection): void;
152
+ /**
153
+ * Returns a path to highlight the given conneciton, assuming it is an
154
+ * input or output connection.
155
+ */
156
+ private getExpressionConnectionHighlightPath;
157
+ /**
158
+ * Returns a path to highlight the given conneciton, assuming it is a
159
+ * next or previous connection.
160
+ */
161
+ private getStatementConnectionHighlightPath;
144
162
  }
145
163
  //# sourceMappingURL=drawer.d.ts.map
@@ -6,7 +6,8 @@
6
6
  import type { BlockStyle } from '../../theme.js';
7
7
  import type { BlockSvg } from '../../block_svg.js';
8
8
  import type { ConstantProvider } from './constants.js';
9
- import { RenderedConnection } from '../../rendered_connection.js';
9
+ import type { RenderedConnection } from '../../rendered_connection.js';
10
+ import type { Coordinate } from '../../utils/coordinate.js';
10
11
  /**
11
12
  * An interface for a block's path object.
12
13
  *
@@ -101,21 +102,11 @@ export interface IPathObject {
101
102
  * @param enable True if the block is movable, false otherwise.
102
103
  */
103
104
  updateMovable(enabled: boolean): void;
105
+ /** Adds the given path as a connection highlight for the given connection. */
106
+ addConnectionHighlight?(connection: RenderedConnection, connectionPath: string, offset: Coordinate, rtl: boolean): void;
104
107
  /**
105
- * Add or remove styling that shows that if the dragging block is dropped,
106
- * this block will be replaced. If a shadow block, it will disappear.
107
- * Otherwise it will bump.
108
- *
109
- * @param enable True if styling should be added.
110
- */
111
- updateReplacementFade(enabled: boolean): void;
112
- /**
113
- * Add or remove styling that shows that if the dragging block is dropped,
114
- * this block will be connected to the input.
115
- *
116
- * @param conn The connection on the input to highlight.
117
- * @param enable True if styling should be added.
108
+ * Removes any highlight associated with the given connection, if it exists.
118
109
  */
119
- updateShapeForInputHighlight(conn: RenderedConnection, enable: boolean): void;
110
+ removeConnectionHighlight?(connection: RenderedConnection): void;
120
111
  }
121
112
  //# sourceMappingURL=i_path_object.d.ts.map
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import type { BlockSvg } from '../../block_svg.js';
7
7
  import { Input } from '../../inputs/input.js';
8
+ import type { RenderedConnection } from '../../rendered_connection.js';
8
9
  import type { Measurable } from '../measurables/base.js';
9
10
  import { BottomRow } from '../measurables/bottom_row.js';
10
11
  import { InputRow } from '../measurables/input_row.js';
@@ -14,6 +15,7 @@ import { SpacerRow } from '../measurables/spacer_row.js';
14
15
  import { TopRow } from '../measurables/top_row.js';
15
16
  import type { ConstantProvider } from './constants.js';
16
17
  import type { Renderer } from './renderer.js';
18
+ import { Connection } from '../measurables/connection.js';
17
19
  /**
18
20
  * An object containing all sizing information needed to draw this block.
19
21
  *
@@ -61,8 +63,7 @@ export declare class RenderInfo {
61
63
  */
62
64
  getRenderer(): Renderer;
63
65
  /**
64
- * Populate and return an object containing all sizing information needed to
65
- * draw this block.
66
+ * Populate this object with all sizing information needed to draw the block.
66
67
  *
67
68
  * This measure pass does not propagate changes to the block (although fields
68
69
  * may choose to rerender when getSize() is called). However, calling it
@@ -194,5 +195,7 @@ export declare class RenderInfo {
194
195
  * store the y position of each row, and record the height of the full block.
195
196
  */
196
197
  protected finalize_(): void;
198
+ /** Returns the connection measurable associated with the given connection. */
199
+ getMeasureableForConnection(conn: RenderedConnection): Connection | null;
197
200
  }
198
201
  //# sourceMappingURL=info.d.ts.map
@@ -5,7 +5,9 @@
5
5
  */
6
6
  import type { BlockSvg } from '../../block_svg.js';
7
7
  import type { Connection } from '../../connection.js';
8
+ import { RenderedConnection } from '../../rendered_connection.js';
8
9
  import type { BlockStyle } from '../../theme.js';
10
+ import { Coordinate } from '../../utils/coordinate.js';
9
11
  import type { ConstantProvider } from './constants.js';
10
12
  import type { IPathObject } from './i_path_object.js';
11
13
  /**
@@ -27,6 +29,10 @@ export declare class PathObject implements IPathObject {
27
29
  markerSvg: SVGElement | null;
28
30
  constants: ConstantProvider;
29
31
  style: BlockStyle;
32
+ /** Highlight paths associated with connections. */
33
+ private connectionHighlights;
34
+ /** Locations of connection highlights. */
35
+ private highlightOffsets;
30
36
  /**
31
37
  * @param root The root SVG element.
32
38
  * @param style The style object to use for colouring.
@@ -138,5 +144,12 @@ export declare class PathObject implements IPathObject {
138
144
  * @param _enable True if styling should be added.
139
145
  */
140
146
  updateShapeForInputHighlight(_conn: Connection, _enable: boolean): void;
147
+ /** Adds the given path as a connection highlight for the given connection. */
148
+ addConnectionHighlight(connection: RenderedConnection, connectionPath: string, offset: Coordinate, rtl: boolean): void;
149
+ private currentHighlightMatchesNew;
150
+ /**
151
+ * Removes any highlight associated with the given connection, if it exists.
152
+ */
153
+ removeConnectionHighlight(connection: RenderedConnection): void;
141
154
  }
142
155
  //# sourceMappingURL=path_object.d.ts.map
@@ -141,6 +141,9 @@ export declare class Renderer implements IRegistrable {
141
141
  * @param local The connection currently being dragged.
142
142
  * @param topBlock The block currently being dragged.
143
143
  * @returns The preview type to display.
144
+ *
145
+ * @deprecated v10 - This function is no longer respected. A custom
146
+ * IConnectionPreviewer may be able to fulfill the functionality.
144
147
  */
145
148
  getConnectionPreviewMethod(closest: RenderedConnection, local: RenderedConnection, topBlock: BlockSvg): PreviewType;
146
149
  /**
@@ -14,6 +14,7 @@ export declare class Connection extends Measurable {
14
14
  connectionModel: RenderedConnection;
15
15
  shape: Shape;
16
16
  isDynamicShape: boolean;
17
+ highlighted: boolean;
17
18
  /**
18
19
  * @param constants The rendering constants provider.
19
20
  * @param connectionModel The connection object on the block that this
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import type { BlockSvg } from '../../block_svg.js';
7
7
  import { Drawer as BaseDrawer } from '../common/drawer.js';
8
+ import { Connection } from '../measurables/connection.js';
8
9
  import type { InlineInput } from '../measurables/inline_input.js';
9
10
  import type { Row } from '../measurables/row.js';
10
11
  import type { RenderInfo } from './info.js';
@@ -42,6 +43,9 @@ export declare class Drawer extends BaseDrawer {
42
43
  /** Add steps to draw a flat bottom row. */
43
44
  protected drawFlatBottom_(): void;
44
45
  drawInlineInput_(input: InlineInput): void;
46
+ private getInlineInputPath;
45
47
  drawStatementInput_(row: Row): void;
48
+ /** Returns a path to highlight the given connection. */
49
+ drawConnectionHighlightPath(measurable: Connection): void;
46
50
  }
47
51
  //# sourceMappingURL=drawer.d.ts.map
@@ -4,7 +4,6 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import type { BlockSvg } from '../../block_svg.js';
7
- import type { Connection } from '../../connection.js';
8
7
  import { InsertionMarkerManager } from '../../insertion_marker_manager.js';
9
8
  import type { Marker } from '../../keyboard_nav/marker.js';
10
9
  import type { RenderedConnection } from '../../rendered_connection.js';
@@ -74,7 +73,10 @@ export declare class Renderer extends BaseRenderer {
74
73
  * @returns The constant provider.
75
74
  */
76
75
  getConstants(): ConstantProvider;
77
- shouldHighlightConnection(conn: Connection): boolean;
76
+ /**
77
+ * @deprecated v10 - This function is no longer respected. A custom
78
+ * IConnectionPreviewer may be able to fulfill the functionality.
79
+ */
78
80
  getConnectionPreviewMethod(closest: RenderedConnection, local: RenderedConnection, topBlock: BlockSvg): InsertionMarkerManager.PREVIEW_TYPE;
79
81
  }
80
82
  //# sourceMappingURL=renderer.d.ts.map
@@ -13,6 +13,8 @@ export declare class WorkspaceAudio {
13
13
  private sounds;
14
14
  /** Time that the last sound was played. */
15
15
  private lastSound_;
16
+ /** Whether the audio is muted or not. */
17
+ private muted;
16
18
  /**
17
19
  * @param parentWorkspace The parent of the workspace this audio object
18
20
  * belongs to, or null.
@@ -47,5 +49,13 @@ export declare class WorkspaceAudio {
47
49
  * @param opt_volume Volume of sound (0-1).
48
50
  */
49
51
  play(name: string, opt_volume?: number): void;
52
+ /**
53
+ * @param muted If true, mute sounds. Otherwise, play them.
54
+ */
55
+ setMuted(muted: boolean): void;
56
+ /**
57
+ * @returns Whether the audio is currently muted or not.
58
+ */
59
+ getMuted(): boolean;
50
60
  }
51
61
  //# sourceMappingURL=workspace_audio.d.ts.map
package/dart.d.ts CHANGED
@@ -26,3 +26,5 @@ export enum Order {
26
26
  }
27
27
 
28
28
  export declare const dartGenerator: any;
29
+
30
+ export {DartGenerator} from './generators/dart';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2014 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * @file Generating Dart for colour blocks.
8
+ */
9
+ import type { Block } from '../../core/block.js';
10
+ import type { DartGenerator } from './dart_generator.js';
11
+ import { Order } from './dart_generator.js';
12
+ export declare function colour_picker(block: Block, generator: DartGenerator): [string, Order];
13
+ export declare function colour_random(block: Block, generator: DartGenerator): [string, Order];
14
+ export declare function colour_rgb(block: Block, generator: DartGenerator): [string, Order];
15
+ export declare function colour_blend(block: Block, generator: DartGenerator): [string, Order];
16
+ //# sourceMappingURL=colour.d.ts.map
@@ -0,0 +1,100 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2014 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { Block } from '../../core/block.js';
7
+ import { CodeGenerator } from '../../core/generator.js';
8
+ import type { Workspace } from '../../core/workspace.js';
9
+ /**
10
+ * Order of operation ENUMs.
11
+ * https://dart.dev/guides/language/language-tour#operators
12
+ */
13
+ export declare enum Order {
14
+ ATOMIC = 0,
15
+ UNARY_POSTFIX = 1,
16
+ UNARY_PREFIX = 2,
17
+ MULTIPLICATIVE = 3,
18
+ ADDITIVE = 4,
19
+ SHIFT = 5,
20
+ BITWISE_AND = 6,
21
+ BITWISE_XOR = 7,
22
+ BITWISE_OR = 8,
23
+ RELATIONAL = 9,
24
+ EQUALITY = 10,
25
+ LOGICAL_AND = 11,
26
+ LOGICAL_OR = 12,
27
+ IF_NULL = 13,
28
+ CONDITIONAL = 14,
29
+ CASCADE = 15,
30
+ ASSIGNMENT = 16,
31
+ NONE = 99
32
+ }
33
+ /**
34
+ * Dart code generator class.
35
+ */
36
+ export declare class DartGenerator extends CodeGenerator {
37
+ /** @param name Name of the language the generator is for. */
38
+ constructor(name?: string);
39
+ /**
40
+ * Initialise the database of variable names.
41
+ *
42
+ * @param workspace Workspace to generate code from.
43
+ */
44
+ init(workspace: Workspace): void;
45
+ /**
46
+ * Prepend the generated code with import statements and variable definitions.
47
+ *
48
+ * @param code Generated code.
49
+ * @returns Completed code.
50
+ */
51
+ finish(code: string): string;
52
+ /**
53
+ * Naked values are top-level blocks with outputs that aren't plugged into
54
+ * anything.
55
+ *
56
+ * @param line Line of generated code.
57
+ * @returns Legal line of code.
58
+ */
59
+ scrubNakedValue(line: string): string;
60
+ /**
61
+ * Encode a string as a properly escaped Dart string, complete with quotes.
62
+ *
63
+ * @param string Text to encode.
64
+ * @returns Dart string.
65
+ */
66
+ quote_(string: string): string;
67
+ /**
68
+ * Encode a string as a properly escaped multiline Dart string, complete
69
+ * with quotes.
70
+ *
71
+ * @param string Text to encode.
72
+ * @returns Dart string.
73
+ */
74
+ multiline_quote_(string: string): string;
75
+ /**
76
+ * Common tasks for generating Dart from blocks.
77
+ * Handles comments for the specified block and any connected value blocks.
78
+ * Calls any statements following this block.
79
+ *
80
+ * @param block The current block.
81
+ * @param code The Dart code created for this block.
82
+ * @param thisOnly True to generate code for only this statement.
83
+ * @returns Dart code with comments and subsequent blocks added.
84
+ */
85
+ scrub_(block: Block, code: string, thisOnly?: boolean): string;
86
+ /**
87
+ * Generate code representing the specified value input, adjusted to take into
88
+ * account indexing (zero- or one-based) and optionally by a specified delta
89
+ * and/or by negation.
90
+ *
91
+ * @param block The block.
92
+ * @param atId The ID of the input block to get (and adjust) the value of.
93
+ * @param delta Value to add.
94
+ * @param negate Whether to negate the value.
95
+ * @param order The highest order acting on this value.
96
+ * @returns The adjusted value or code that evaluates to it.
97
+ */
98
+ getAdjusted(block: Block, atId: string, delta?: number, negate?: boolean, order?: Order): string;
99
+ }
100
+ //# sourceMappingURL=dart_generator.d.ts.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2014 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * @file Generating Dart for list blocks.
8
+ */
9
+ import type { Block } from '../../core/block.js';
10
+ import type { DartGenerator } from './dart_generator.js';
11
+ import { Order } from './dart_generator.js';
12
+ export declare function lists_create_empty(block: Block, generator: DartGenerator): [string, Order];
13
+ export declare function lists_create_with(block: Block, generator: DartGenerator): [string, Order];
14
+ export declare function lists_repeat(block: Block, generator: DartGenerator): [string, Order];
15
+ export declare function lists_length(block: Block, generator: DartGenerator): [string, Order];
16
+ export declare function lists_isEmpty(block: Block, generator: DartGenerator): [string, Order];
17
+ export declare function lists_indexOf(block: Block, generator: DartGenerator): [string, Order];
18
+ export declare function lists_getIndex(block: Block, generator: DartGenerator): [string, Order] | string;
19
+ export declare function lists_setIndex(block: Block, generator: DartGenerator): string;
20
+ export declare function lists_getSublist(block: Block, generator: DartGenerator): [string, Order];
21
+ export declare function lists_sort(block: Block, generator: DartGenerator): [string, Order];
22
+ export declare function lists_split(block: Block, generator: DartGenerator): [string, Order];
23
+ export declare function lists_reverse(block: Block, generator: DartGenerator): [string, Order];
24
+ //# sourceMappingURL=lists.d.ts.map