blockly 12.0.0-beta.0 → 12.0.0-beta.1

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 (58) hide show
  1. package/blockly.min.js +264 -250
  2. package/blockly.mjs +1 -0
  3. package/blockly_compressed.js +259 -245
  4. package/blockly_compressed.js.map +1 -1
  5. package/blocks_compressed.js +5 -5
  6. package/blocks_compressed.js.map +1 -1
  7. package/core/block.d.ts +8 -3
  8. package/core/block_flyout_inflater.d.ts +11 -5
  9. package/core/block_svg.d.ts +8 -2
  10. package/core/blockly.d.ts +2 -1
  11. package/core/button_flyout_inflater.d.ts +11 -5
  12. package/core/connection.d.ts +1 -1
  13. package/core/events/events_var_delete.d.ts +0 -2
  14. package/core/events/events_var_rename.d.ts +0 -2
  15. package/core/flyout_base.d.ts +1 -8
  16. package/core/flyout_horizontal.d.ts +2 -1
  17. package/core/flyout_item.d.ts +32 -0
  18. package/core/flyout_vertical.d.ts +2 -1
  19. package/core/interfaces/i_flyout.d.ts +1 -1
  20. package/core/interfaces/i_flyout_inflater.d.ts +13 -4
  21. package/core/interfaces/i_metrics_manager.d.ts +1 -1
  22. package/core/interfaces/i_rendered_element.d.ts +1 -4
  23. package/core/label_flyout_inflater.d.ts +11 -5
  24. package/core/menu.d.ts +1 -3
  25. package/core/metrics_manager.d.ts +1 -1
  26. package/core/procedures.d.ts +7 -4
  27. package/core/renderers/common/renderer.d.ts +1 -1
  28. package/core/renderers/measurables/in_row_spacer.d.ts +1 -0
  29. package/core/renderers/measurables/jagged_edge.d.ts +1 -0
  30. package/core/renderers/measurables/next_connection.d.ts +1 -0
  31. package/core/renderers/measurables/previous_connection.d.ts +1 -0
  32. package/core/renderers/measurables/round_corner.d.ts +1 -0
  33. package/core/renderers/measurables/square_corner.d.ts +1 -0
  34. package/core/renderers/measurables/statement_input.d.ts +1 -0
  35. package/core/renderers/measurables/types.d.ts +49 -24
  36. package/core/separator_flyout_inflater.d.ts +15 -5
  37. package/core/variables.d.ts +18 -4
  38. package/core/variables_dynamic.d.ts +7 -5
  39. package/core/workspace_svg.d.ts +1 -0
  40. package/index.mjs +1 -0
  41. package/media/1x1.gif +0 -0
  42. package/media/click.mp3 +0 -0
  43. package/media/click.ogg +0 -0
  44. package/media/click.wav +0 -0
  45. package/media/delete.mp3 +0 -0
  46. package/media/delete.ogg +0 -0
  47. package/media/delete.wav +0 -0
  48. package/media/disconnect.mp3 +0 -0
  49. package/media/disconnect.ogg +0 -0
  50. package/media/disconnect.wav +0 -0
  51. package/media/handclosed.cur +0 -0
  52. package/media/handdelete.cur +0 -0
  53. package/media/handopen.cur +0 -0
  54. package/media/pilcrow.png +0 -0
  55. package/media/quote0.png +0 -0
  56. package/media/quote1.png +0 -0
  57. package/media/sprites.png +0 -0
  58. package/package.json +1 -1
@@ -4,7 +4,24 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import type { Measurable } from './base.js';
7
+ import type { BottomRow } from './bottom_row.js';
8
+ import type { ExternalValueInput } from './external_value_input.js';
9
+ import type { Field } from './field.js';
10
+ import type { Hat } from './hat.js';
11
+ import type { Icon } from './icon.js';
12
+ import type { InRowSpacer } from './in_row_spacer.js';
13
+ import type { InlineInput } from './inline_input.js';
14
+ import type { InputConnection } from './input_connection.js';
15
+ import type { InputRow } from './input_row.js';
16
+ import type { JaggedEdge } from './jagged_edge.js';
17
+ import type { NextConnection } from './next_connection.js';
18
+ import type { PreviousConnection } from './previous_connection.js';
19
+ import type { RoundCorner } from './round_corner.js';
7
20
  import type { Row } from './row.js';
21
+ import type { SpacerRow } from './spacer_row.js';
22
+ import type { SquareCorner } from './square_corner.js';
23
+ import type { StatementInput } from './statement_input.js';
24
+ import type { TopRow } from './top_row.js';
8
25
  /**
9
26
  * Types of rendering elements.
10
27
  */
@@ -63,77 +80,84 @@ declare class TypesContainer {
63
80
  * @param elem The element to check.
64
81
  * @returns 1 if the object stores information about a field.
65
82
  */
66
- isField(elem: Measurable): number;
83
+ isField(elem: Measurable): elem is Field;
67
84
  /**
68
85
  * Whether a measurable stores information about a hat.
69
86
  *
70
87
  * @param elem The element to check.
71
88
  * @returns 1 if the object stores information about a hat.
72
89
  */
73
- isHat(elem: Measurable): number;
90
+ isHat(elem: Measurable): elem is Hat;
74
91
  /**
75
92
  * Whether a measurable stores information about an icon.
76
93
  *
77
94
  * @param elem The element to check.
78
95
  * @returns 1 if the object stores information about an icon.
79
96
  */
80
- isIcon(elem: Measurable): number;
97
+ isIcon(elem: Measurable): elem is Icon;
81
98
  /**
82
99
  * Whether a measurable stores information about a spacer.
83
100
  *
84
101
  * @param elem The element to check.
85
102
  * @returns 1 if the object stores information about a spacer.
86
103
  */
87
- isSpacer(elem: Measurable | Row): number;
104
+ isSpacer(elem: Measurable | Row): elem is SpacerRow | InRowSpacer;
88
105
  /**
89
106
  * Whether a measurable stores information about an in-row spacer.
90
107
  *
91
108
  * @param elem The element to check.
92
109
  * @returns 1 if the object stores information about an in-row spacer.
93
110
  */
94
- isInRowSpacer(elem: Measurable): number;
111
+ isInRowSpacer(elem: Measurable): elem is InRowSpacer;
112
+ /**
113
+ * Whether a row is a spacer row.
114
+ *
115
+ * @param row The row to check.
116
+ * @returns True if the row is a spacer row.
117
+ */
118
+ isSpacerRow(row: Row): row is SpacerRow;
95
119
  /**
96
120
  * Whether a measurable stores information about an input.
97
121
  *
98
122
  * @param elem The element to check.
99
123
  * @returns 1 if the object stores information about an input.
100
124
  */
101
- isInput(elem: Measurable): number;
125
+ isInput(elem: Measurable): elem is InputConnection;
102
126
  /**
103
127
  * Whether a measurable stores information about an external input.
104
128
  *
105
129
  * @param elem The element to check.
106
130
  * @returns 1 if the object stores information about an external input.
107
131
  */
108
- isExternalInput(elem: Measurable): number;
132
+ isExternalInput(elem: Measurable): elem is ExternalValueInput;
109
133
  /**
110
134
  * Whether a measurable stores information about an inline input.
111
135
  *
112
136
  * @param elem The element to check.
113
137
  * @returns 1 if the object stores information about an inline input.
114
138
  */
115
- isInlineInput(elem: Measurable): number;
139
+ isInlineInput(elem: Measurable): elem is InlineInput;
116
140
  /**
117
141
  * Whether a measurable stores information about a statement input.
118
142
  *
119
143
  * @param elem The element to check.
120
144
  * @returns 1 if the object stores information about a statement input.
121
145
  */
122
- isStatementInput(elem: Measurable): number;
146
+ isStatementInput(elem: Measurable): elem is StatementInput;
123
147
  /**
124
148
  * Whether a measurable stores information about a previous connection.
125
149
  *
126
150
  * @param elem The element to check.
127
151
  * @returns 1 if the object stores information about a previous connection.
128
152
  */
129
- isPreviousConnection(elem: Measurable): number;
153
+ isPreviousConnection(elem: Measurable): elem is PreviousConnection;
130
154
  /**
131
155
  * Whether a measurable stores information about a next connection.
132
156
  *
133
157
  * @param elem The element to check.
134
158
  * @returns 1 if the object stores information about a next connection.
135
159
  */
136
- isNextConnection(elem: Measurable): number;
160
+ isNextConnection(elem: Measurable): elem is NextConnection;
137
161
  /**
138
162
  * Whether a measurable stores information about a previous or next
139
163
  * connection.
@@ -142,91 +166,92 @@ declare class TypesContainer {
142
166
  * @returns 1 if the object stores information about a previous or next
143
167
  * connection.
144
168
  */
145
- isPreviousOrNextConnection(elem: Measurable): number;
169
+ isPreviousOrNextConnection(elem: Measurable): elem is PreviousConnection | NextConnection;
170
+ isRoundCorner(elem: Measurable): elem is RoundCorner;
146
171
  /**
147
172
  * Whether a measurable stores information about a left round corner.
148
173
  *
149
174
  * @param elem The element to check.
150
175
  * @returns 1 if the object stores information about a left round corner.
151
176
  */
152
- isLeftRoundedCorner(elem: Measurable): number;
177
+ isLeftRoundedCorner(elem: Measurable): boolean;
153
178
  /**
154
179
  * Whether a measurable stores information about a right round corner.
155
180
  *
156
181
  * @param elem The element to check.
157
182
  * @returns 1 if the object stores information about a right round corner.
158
183
  */
159
- isRightRoundedCorner(elem: Measurable): number;
184
+ isRightRoundedCorner(elem: Measurable): boolean;
160
185
  /**
161
186
  * Whether a measurable stores information about a left square corner.
162
187
  *
163
188
  * @param elem The element to check.
164
189
  * @returns 1 if the object stores information about a left square corner.
165
190
  */
166
- isLeftSquareCorner(elem: Measurable): number;
191
+ isLeftSquareCorner(elem: Measurable): boolean;
167
192
  /**
168
193
  * Whether a measurable stores information about a right square corner.
169
194
  *
170
195
  * @param elem The element to check.
171
196
  * @returns 1 if the object stores information about a right square corner.
172
197
  */
173
- isRightSquareCorner(elem: Measurable): number;
198
+ isRightSquareCorner(elem: Measurable): boolean;
174
199
  /**
175
200
  * Whether a measurable stores information about a corner.
176
201
  *
177
202
  * @param elem The element to check.
178
203
  * @returns 1 if the object stores information about a corner.
179
204
  */
180
- isCorner(elem: Measurable): number;
205
+ isCorner(elem: Measurable): elem is SquareCorner | RoundCorner;
181
206
  /**
182
207
  * Whether a measurable stores information about a jagged edge.
183
208
  *
184
209
  * @param elem The element to check.
185
210
  * @returns 1 if the object stores information about a jagged edge.
186
211
  */
187
- isJaggedEdge(elem: Measurable): number;
212
+ isJaggedEdge(elem: Measurable): elem is JaggedEdge;
188
213
  /**
189
214
  * Whether a measurable stores information about a row.
190
215
  *
191
216
  * @param row The row to check.
192
217
  * @returns 1 if the object stores information about a row.
193
218
  */
194
- isRow(row: Row): number;
219
+ isRow(row: Row): row is Row;
195
220
  /**
196
221
  * Whether a measurable stores information about a between-row spacer.
197
222
  *
198
223
  * @param row The row to check.
199
224
  * @returns 1 if the object stores information about a between-row spacer.
200
225
  */
201
- isBetweenRowSpacer(row: Row): number;
226
+ isBetweenRowSpacer(row: Row): row is SpacerRow;
202
227
  /**
203
228
  * Whether a measurable stores information about a top row.
204
229
  *
205
230
  * @param row The row to check.
206
231
  * @returns 1 if the object stores information about a top row.
207
232
  */
208
- isTopRow(row: Row): number;
233
+ isTopRow(row: Row): row is TopRow;
209
234
  /**
210
235
  * Whether a measurable stores information about a bottom row.
211
236
  *
212
237
  * @param row The row to check.
213
238
  * @returns 1 if the object stores information about a bottom row.
214
239
  */
215
- isBottomRow(row: Row): number;
240
+ isBottomRow(row: Row): row is BottomRow;
216
241
  /**
217
242
  * Whether a measurable stores information about a top or bottom row.
218
243
  *
219
244
  * @param row The row to check.
220
245
  * @returns 1 if the object stores information about a top or bottom row.
221
246
  */
222
- isTopOrBottomRow(row: Row): number;
247
+ isTopOrBottomRow(row: Row): row is TopRow | BottomRow;
223
248
  /**
224
249
  * Whether a measurable stores information about an input row.
225
250
  *
226
251
  * @param row The row to check.
227
252
  * @returns 1 if the object stores information about an input row.
228
253
  */
229
- isInputRow(row: Row): number;
254
+ isInputRow(row: Row): row is InputRow;
230
255
  }
231
256
  export declare const Types: TypesContainer;
232
257
  export {};
@@ -3,9 +3,13 @@
3
3
  * Copyright 2024 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { IBoundedElement } from './interfaces/i_bounded_element.js';
6
+ import { FlyoutItem } from './flyout_item.js';
7
7
  import type { IFlyoutInflater } from './interfaces/i_flyout_inflater.js';
8
8
  import type { WorkspaceSvg } from './workspace_svg.js';
9
+ /**
10
+ * @internal
11
+ */
12
+ export declare const SEPARATOR_TYPE = "sep";
9
13
  /**
10
14
  * Class responsible for creating separators for flyouts.
11
15
  */
@@ -28,7 +32,7 @@ export declare class SeparatorFlyoutInflater implements IFlyoutInflater {
28
32
  * @param flyoutWorkspace The workspace the separator belongs to.
29
33
  * @returns A newly created FlyoutSeparator.
30
34
  */
31
- load(_state: object, flyoutWorkspace: WorkspaceSvg): IBoundedElement;
35
+ load(_state: object, flyoutWorkspace: WorkspaceSvg): FlyoutItem;
32
36
  /**
33
37
  * Returns the size of the separator. See `load` for more details.
34
38
  *
@@ -36,12 +40,18 @@ export declare class SeparatorFlyoutInflater implements IFlyoutInflater {
36
40
  * @param defaultGap The default spacing for flyout items.
37
41
  * @returns The desired size of the separator.
38
42
  */
39
- gapForElement(state: object, defaultGap: number): number;
43
+ gapForItem(state: object, defaultGap: number): number;
40
44
  /**
41
45
  * Disposes of the given separator. Intentional no-op.
42
46
  *
43
- * @param _element The flyout separator to dispose of.
47
+ * @param _item The flyout separator to dispose of.
48
+ */
49
+ disposeItem(_item: FlyoutItem): void;
50
+ /**
51
+ * Returns the type of items this inflater is responsible for creating.
52
+ *
53
+ * @returns An identifier for the type of items this inflater creates.
44
54
  */
45
- disposeElement(_element: IBoundedElement): void;
55
+ getType(): string;
46
56
  }
47
57
  //# sourceMappingURL=separator_flyout_inflater.d.ts.map
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import type { Block } from './block.js';
7
7
  import { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
8
+ import type { BlockInfo, FlyoutItemInfo } from './utils/toolbox.js';
8
9
  import type { Workspace } from './workspace.js';
9
10
  import type { WorkspaceSvg } from './workspace_svg.js';
10
11
  /**
@@ -38,13 +39,26 @@ export declare function allUsedVarModels(ws: Workspace): IVariableModel<IVariabl
38
39
  */
39
40
  export declare function allDeveloperVariables(workspace: Workspace): string[];
40
41
  /**
41
- * Construct the elements (blocks and button) required by the flyout for the
42
- * variable category.
42
+ * Internal wrapper that returns the contents of the variables category.
43
43
  *
44
+ * @internal
45
+ * @param workspace The workspace to populate variable blocks for.
46
+ */
47
+ export declare function internalFlyoutCategory(workspace: WorkspaceSvg): FlyoutItemInfo[];
48
+ export declare function flyoutCategory(workspace: WorkspaceSvg, useXml: true): Element[];
49
+ export declare function flyoutCategory(workspace: WorkspaceSvg, useXml: false): FlyoutItemInfo[];
50
+ /**
51
+ * Construct the blocks required by the flyout for the variable category.
52
+ *
53
+ * @internal
44
54
  * @param workspace The workspace containing variables.
45
- * @returns Array of XML elements.
55
+ * @param variables List of variables to create blocks for.
56
+ * @param includeChangeBlocks True to include `change x by _` blocks.
57
+ * @param getterType The type of the variable getter block to generate.
58
+ * @param setterType The type of the variable setter block to generate.
59
+ * @returns JSON list of blocks.
46
60
  */
47
- export declare function flyoutCategory(workspace: WorkspaceSvg): Element[];
61
+ export declare function jsonFlyoutCategoryBlocks(workspace: Workspace, variables: IVariableModel<IVariableState>[], includeChangeBlocks: boolean, getterType?: string, setterType?: string): BlockInfo[];
48
62
  /**
49
63
  * Construct the blocks required by the flyout for the variable category.
50
64
  *
@@ -4,6 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import type { FlyoutButton } from './flyout_button.js';
7
+ import type { FlyoutItemInfo } from './utils/toolbox.js';
7
8
  import type { Workspace } from './workspace.js';
8
9
  import type { WorkspaceSvg } from './workspace_svg.js';
9
10
  /**
@@ -36,13 +37,14 @@ export declare const onCreateVariableButtonClick_Number: typeof numberButtonClic
36
37
  declare function colourButtonClickHandler(button: FlyoutButton): void;
37
38
  export declare const onCreateVariableButtonClick_Colour: typeof colourButtonClickHandler;
38
39
  /**
39
- * Construct the elements (blocks and button) required by the flyout for the
40
- * variable category.
40
+ * Internal wrapper that returns the contents of the dynamic variables category.
41
41
  *
42
- * @param workspace The workspace containing variables.
43
- * @returns Array of XML elements.
42
+ * @internal
43
+ * @param workspace The workspace to populate variable blocks for.
44
44
  */
45
- export declare function flyoutCategory(workspace: WorkspaceSvg): Element[];
45
+ export declare function internalFlyoutCategory(workspace: WorkspaceSvg): FlyoutItemInfo[];
46
+ export declare function flyoutCategory(workspace: WorkspaceSvg, useXml: true): Element[];
47
+ export declare function flyoutCategory(workspace: WorkspaceSvg, useXml: false): FlyoutItemInfo[];
46
48
  /**
47
49
  * Construct the blocks required by the flyout for the variable category.
48
50
  *
@@ -495,6 +495,7 @@ export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationS
495
495
  updateScreenCalculationsIfScrolled(): void;
496
496
  /**
497
497
  * @returns The layer manager for this workspace.
498
+ * @internal
498
499
  */
499
500
  getLayerManager(): LayerManager | null;
500
501
  /**
package/index.mjs CHANGED
@@ -39,6 +39,7 @@ export const {
39
39
  FieldVariable,
40
40
  Flyout,
41
41
  FlyoutButton,
42
+ FlyoutItem,
42
43
  FlyoutMetricsManager,
43
44
  FlyoutSeparator,
44
45
  Generator,
package/media/1x1.gif CHANGED
Binary file
package/media/click.mp3 CHANGED
Binary file
package/media/click.ogg CHANGED
Binary file
package/media/click.wav CHANGED
Binary file
package/media/delete.mp3 CHANGED
Binary file
package/media/delete.ogg CHANGED
Binary file
package/media/delete.wav CHANGED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/media/pilcrow.png CHANGED
Binary file
package/media/quote0.png CHANGED
Binary file
package/media/quote1.png CHANGED
Binary file
package/media/sprites.png CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blockly",
3
- "version": "12.0.0-beta.0",
3
+ "version": "12.0.0-beta.1",
4
4
  "description": "Blockly is a library for building visual programming editors.",
5
5
  "keywords": [
6
6
  "blockly"