blockly 11.2.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 (104) hide show
  1. package/blockly.min.js +783 -767
  2. package/blockly.mjs +6 -1
  3. package/blockly_compressed.js +768 -752
  4. package/blockly_compressed.js.map +1 -1
  5. package/blocks_compressed.js +15 -15
  6. package/blocks_compressed.js.map +1 -1
  7. package/core/block.d.ts +11 -6
  8. package/core/block_flyout_inflater.d.ts +95 -0
  9. package/core/block_svg.d.ts +26 -2
  10. package/core/blockly.d.ts +11 -3
  11. package/core/bubbles/textinput_bubble.d.ts +9 -0
  12. package/core/button_flyout_inflater.d.ts +42 -0
  13. package/core/clipboard.d.ts +2 -2
  14. package/core/comments/comment_view.d.ts +4 -0
  15. package/core/comments/rendered_workspace_comment.d.ts +2 -0
  16. package/core/connection.d.ts +1 -1
  17. package/core/dropdowndiv.d.ts +1 -1
  18. package/core/events/events.d.ts +1 -0
  19. package/core/events/events_var_base.d.ts +2 -2
  20. package/core/events/events_var_create.d.ts +7 -2
  21. package/core/events/events_var_delete.d.ts +2 -4
  22. package/core/events/events_var_rename.d.ts +2 -4
  23. package/core/events/events_var_type_change.d.ts +55 -0
  24. package/core/events/type.d.ts +2 -0
  25. package/core/field.d.ts +0 -13
  26. package/core/field_checkbox.d.ts +0 -4
  27. package/core/field_dropdown.d.ts +0 -2
  28. package/core/field_input.d.ts +0 -2
  29. package/core/field_number.d.ts +6 -0
  30. package/core/field_textinput.d.ts +1 -0
  31. package/core/field_variable.d.ts +9 -2
  32. package/core/flyout_base.d.ts +45 -181
  33. package/core/flyout_button.d.ts +25 -6
  34. package/core/flyout_horizontal.d.ts +4 -4
  35. package/core/flyout_item.d.ts +32 -0
  36. package/core/flyout_separator.d.ts +45 -0
  37. package/core/flyout_vertical.d.ts +5 -5
  38. package/core/grid.d.ts +4 -1
  39. package/core/icons/comment_icon.d.ts +15 -0
  40. package/core/interfaces/i_comment_icon.d.ts +3 -0
  41. package/core/interfaces/i_flyout.d.ts +1 -1
  42. package/core/interfaces/i_flyout_inflater.d.ts +48 -0
  43. package/core/interfaces/i_metrics_manager.d.ts +1 -1
  44. package/core/interfaces/i_rendered_element.d.ts +1 -4
  45. package/core/interfaces/i_toolbox.d.ts +8 -1
  46. package/core/interfaces/i_variable_backed_parameter_model.d.ts +2 -2
  47. package/core/interfaces/i_variable_map.d.ts +48 -0
  48. package/core/interfaces/i_variable_model.d.ts +36 -0
  49. package/core/label_flyout_inflater.d.ts +42 -0
  50. package/core/menu.d.ts +1 -3
  51. package/core/menuitem.d.ts +0 -7
  52. package/core/metrics_manager.d.ts +1 -1
  53. package/core/names.d.ts +8 -2
  54. package/core/procedures.d.ts +7 -4
  55. package/core/registry.d.ts +6 -0
  56. package/core/renderers/common/constants.d.ts +6 -1
  57. package/core/renderers/common/i_path_object.d.ts +13 -13
  58. package/core/renderers/common/renderer.d.ts +13 -18
  59. package/core/renderers/geras/renderer.d.ts +1 -1
  60. package/core/renderers/measurables/in_row_spacer.d.ts +1 -0
  61. package/core/renderers/measurables/jagged_edge.d.ts +1 -0
  62. package/core/renderers/measurables/next_connection.d.ts +1 -0
  63. package/core/renderers/measurables/previous_connection.d.ts +1 -0
  64. package/core/renderers/measurables/round_corner.d.ts +1 -0
  65. package/core/renderers/measurables/square_corner.d.ts +1 -0
  66. package/core/renderers/measurables/statement_input.d.ts +1 -0
  67. package/core/renderers/measurables/types.d.ts +49 -24
  68. package/core/renderers/zelos/constants.d.ts +8 -2
  69. package/core/renderers/zelos/renderer.d.ts +0 -7
  70. package/core/separator_flyout_inflater.d.ts +57 -0
  71. package/core/serialization/variables.d.ts +3 -10
  72. package/core/toolbox/toolbox.d.ts +2 -5
  73. package/core/variable_map.d.ts +27 -29
  74. package/core/variable_model.d.ts +37 -11
  75. package/core/variables.d.ts +56 -12
  76. package/core/variables_dynamic.d.ts +7 -5
  77. package/core/widgetdiv.d.ts +2 -2
  78. package/core/workspace.d.ts +21 -19
  79. package/core/workspace_svg.d.ts +34 -6
  80. package/core/xml.d.ts +2 -2
  81. package/index.mjs +6 -1
  82. package/media/1x1.gif +0 -0
  83. package/media/click.mp3 +0 -0
  84. package/media/click.ogg +0 -0
  85. package/media/click.wav +0 -0
  86. package/media/delete.mp3 +0 -0
  87. package/media/delete.ogg +0 -0
  88. package/media/delete.wav +0 -0
  89. package/media/disconnect.mp3 +0 -0
  90. package/media/disconnect.ogg +0 -0
  91. package/media/disconnect.wav +0 -0
  92. package/media/handclosed.cur +0 -0
  93. package/media/handdelete.cur +0 -0
  94. package/media/handopen.cur +0 -0
  95. package/media/pilcrow.png +0 -0
  96. package/media/quote0.png +0 -0
  97. package/media/quote1.png +0 -0
  98. package/media/sprites.png +0 -0
  99. package/package.json +1 -1
  100. package/php_compressed.js +1 -1
  101. package/php_compressed.js.map +1 -1
  102. package/python_compressed.js +1 -1
  103. package/python_compressed.js.map +1 -1
  104. package/core/insertion_marker_manager.d.ts +0 -249
@@ -3,7 +3,9 @@
3
3
  * Copyright 2012 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { VariableModel } from './variable_model.js';
6
+ import type { Block } from './block.js';
7
+ import { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
8
+ import type { BlockInfo, FlyoutItemInfo } from './utils/toolbox.js';
7
9
  import type { Workspace } from './workspace.js';
8
10
  import type { WorkspaceSvg } from './workspace_svg.js';
9
11
  /**
@@ -23,7 +25,7 @@ export declare const CATEGORY_NAME = "VARIABLE";
23
25
  * @param ws The workspace to search for variables.
24
26
  * @returns Array of variable models.
25
27
  */
26
- export declare function allUsedVarModels(ws: Workspace): VariableModel[];
28
+ export declare function allUsedVarModels(ws: Workspace): IVariableModel<IVariableState>[];
27
29
  /**
28
30
  * Find all developer variables used by blocks in the workspace.
29
31
  * Developer variables are never shown to the user, but are declared as global
@@ -37,13 +39,26 @@ export declare function allUsedVarModels(ws: Workspace): VariableModel[];
37
39
  */
38
40
  export declare function allDeveloperVariables(workspace: Workspace): string[];
39
41
  /**
40
- * Construct the elements (blocks and button) required by the flyout for the
41
- * variable category.
42
+ * Internal wrapper that returns the contents of the variables category.
42
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
43
54
  * @param workspace The workspace containing variables.
44
- * @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.
45
60
  */
46
- export declare function flyoutCategory(workspace: WorkspaceSvg): Element[];
61
+ export declare function jsonFlyoutCategoryBlocks(workspace: Workspace, variables: IVariableModel<IVariableState>[], includeChangeBlocks: boolean, getterType?: string, setterType?: string): BlockInfo[];
47
62
  /**
48
63
  * Construct the blocks required by the flyout for the variable category.
49
64
  *
@@ -104,7 +119,7 @@ export declare function createVariableButtonHandler(workspace: Workspace, opt_ca
104
119
  * name, or null if change is to be aborted (cancel button), or undefined if
105
120
  * an existing variable was chosen.
106
121
  */
107
- export declare function renameVariable(workspace: Workspace, variable: VariableModel, opt_callback?: (p1?: string | null) => void): void;
122
+ export declare function renameVariable(workspace: Workspace, variable: IVariableModel<IVariableState>, opt_callback?: (p1?: string | null) => void): void;
108
123
  /**
109
124
  * Prompt the user for a new variable name.
110
125
  *
@@ -121,7 +136,7 @@ export declare function promptName(promptText: string, defaultText: string, call
121
136
  * @param workspace The workspace to search for the variable.
122
137
  * @returns The variable with the given name, or null if none was found.
123
138
  */
124
- export declare function nameUsedWithAnyType(name: string, workspace: Workspace): VariableModel | null;
139
+ export declare function nameUsedWithAnyType(name: string, workspace: Workspace): IVariableModel<IVariableState> | null;
125
140
  /**
126
141
  * Returns the name of the procedure with a conflicting parameter name, or null
127
142
  * if one does not exist.
@@ -141,7 +156,7 @@ export declare function nameUsedWithConflictingParam(oldName: string, newName: s
141
156
  * @param variableModel The variable model to represent.
142
157
  * @returns The generated DOM.
143
158
  */
144
- export declare function generateVariableFieldDom(variableModel: VariableModel): Element;
159
+ export declare function generateVariableFieldDom(variableModel: IVariableModel<IVariableState>): Element;
145
160
  /**
146
161
  * Helper function to look up or create a variable on the given workspace.
147
162
  * If no variable exists, creates and returns it.
@@ -154,7 +169,7 @@ export declare function generateVariableFieldDom(variableModel: VariableModel):
154
169
  * @returns The variable corresponding to the given ID or name + type
155
170
  * combination.
156
171
  */
157
- export declare function getOrCreateVariablePackage(workspace: Workspace, id: string | null, opt_name?: string, opt_type?: string): VariableModel;
172
+ export declare function getOrCreateVariablePackage(workspace: Workspace, id: string | null, opt_name?: string, opt_type?: string): IVariableModel<IVariableState>;
158
173
  /**
159
174
  * Look up a variable on the given workspace.
160
175
  * Always looks in the main workspace before looking in the flyout workspace.
@@ -170,7 +185,7 @@ export declare function getOrCreateVariablePackage(workspace: Workspace, id: str
170
185
  * @returns The variable corresponding to the given ID or name + type
171
186
  * combination, or null if not found.
172
187
  */
173
- export declare function getVariable(workspace: Workspace, id: string | null, opt_name?: string, opt_type?: string): VariableModel | null;
188
+ export declare function getVariable(workspace: Workspace, id: string | null, opt_name?: string, opt_type?: string): IVariableModel<IVariableState> | null;
174
189
  /**
175
190
  * Helper function to get the list of variables that have been added to the
176
191
  * workspace after adding a new block, using the given list of variables that
@@ -184,7 +199,36 @@ export declare function getVariable(workspace: Workspace, id: string | null, opt
184
199
  * workspace.
185
200
  * @internal
186
201
  */
187
- export declare function getAddedVariables(workspace: Workspace, originalVariables: VariableModel[]): VariableModel[];
202
+ export declare function getAddedVariables(workspace: Workspace, originalVariables: IVariableModel<IVariableState>[]): IVariableModel<IVariableState>[];
203
+ /**
204
+ * A custom compare function for the VariableModel objects.
205
+ *
206
+ * @param var1 First variable to compare.
207
+ * @param var2 Second variable to compare.
208
+ * @returns -1 if name of var1 is less than name of var2, 0 if equal, and 1 if
209
+ * greater.
210
+ * @internal
211
+ */
212
+ export declare function compareByName(var1: IVariableModel<IVariableState>, var2: IVariableModel<IVariableState>): number;
213
+ /**
214
+ * Find all the uses of a named variable.
215
+ *
216
+ * @param workspace The workspace to search for the variable.
217
+ * @param id ID of the variable to find.
218
+ * @returns Array of block usages.
219
+ */
220
+ export declare function getVariableUsesById(workspace: Workspace, id: string): Block[];
221
+ /**
222
+ * Delete a variable and all of its uses from the given workspace. May prompt
223
+ * the user for confirmation.
224
+ *
225
+ * @param workspace The workspace from which to delete the variable.
226
+ * @param variable The variable to delete.
227
+ * @param triggeringBlock The block from which this deletion was triggered, if
228
+ * any. Used to exclude it from checking and warning about blocks
229
+ * referencing the variable being deleted.
230
+ */
231
+ export declare function deleteVariable(workspace: Workspace, variable: IVariableModel<IVariableState>, triggeringBlock?: Block): void;
188
232
  export declare const TEST_ONLY: {
189
233
  generateUniqueNameInternal: typeof generateUniqueNameInternal;
190
234
  };
@@ -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
  *
@@ -54,9 +54,9 @@ export declare function hideIfOwner(oldOwner: unknown): void;
54
54
  * Destroy the widget and hide the div if it is being used by an object in the
55
55
  * specified workspace, or if it is used by an unknown workspace.
56
56
  *
57
- * @param oldOwnerWorkspace The workspace that was using this container.
57
+ * @param workspace The workspace that was using this container.
58
58
  */
59
- export declare function hideIfOwnerIsInWorkspace(oldOwnerWorkspace: WorkspaceSvg): void;
59
+ export declare function hideIfOwnerIsInWorkspace(workspace: WorkspaceSvg): void;
60
60
  /**
61
61
  * Position the widget div based on an anchor rectangle.
62
62
  * The widget should be placed adjacent to but not overlapping the anchor
@@ -16,10 +16,10 @@ import type { Abstract } from './events/events_abstract.js';
16
16
  import type { IASTNodeLocation } from './interfaces/i_ast_node_location.js';
17
17
  import type { IConnectionChecker } from './interfaces/i_connection_checker.js';
18
18
  import { IProcedureMap } from './interfaces/i_procedure_map.js';
19
+ import type { IVariableMap } from './interfaces/i_variable_map.js';
20
+ import type { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
19
21
  import { Options } from './options.js';
20
22
  import type * as toolbox from './utils/toolbox.js';
21
- import { VariableMap } from './variable_map.js';
22
- import type { VariableModel } from './variable_model.js';
23
23
  /**
24
24
  * Class for a workspace. This is a data structure that contains blocks.
25
25
  * There is no UI, and can be created headlessly.
@@ -183,8 +183,8 @@ export declare class Workspace implements IASTNodeLocation {
183
183
  /** Dispose of all blocks and comments in workspace. */
184
184
  clear(): void;
185
185
  /**
186
- * Rename a variable by updating its name in the variable map. Identify the
187
- * variable to rename with the given ID.
186
+ * @deprecated v12 - Rename a variable by updating its name in the variable
187
+ * map. Identify the variable to rename with the given ID.
188
188
  *
189
189
  * @param id ID of the variable to rename.
190
190
  * @param newName New variable name.
@@ -193,6 +193,7 @@ export declare class Workspace implements IASTNodeLocation {
193
193
  /**
194
194
  * Create a variable with a given name, optional type, and optional ID.
195
195
  *
196
+ * @deprecated v12, use Blockly.Workspace.getVariableMap().createVariable.
196
197
  * @param name The name of the variable. This must be unique across variables
197
198
  * and procedures.
198
199
  * @param opt_type The type of the variable like 'int' or 'string'.
@@ -201,10 +202,11 @@ export declare class Workspace implements IASTNodeLocation {
201
202
  * @param opt_id The unique ID of the variable. This will default to a UUID.
202
203
  * @returns The newly created variable.
203
204
  */
204
- createVariable(name: string, opt_type?: string | null, opt_id?: string | null): VariableModel;
205
+ createVariable(name: string, opt_type?: string | null, opt_id?: string | null): IVariableModel<IVariableState>;
205
206
  /**
206
207
  * Find all the uses of the given variable, which is identified by ID.
207
208
  *
209
+ * @deprecated v12, use Blockly.Workspace.getVariableMap().getVariableUsesById
208
210
  * @param id ID of the variable to find.
209
211
  * @returns Array of block usages.
210
212
  */
@@ -213,6 +215,7 @@ export declare class Workspace implements IASTNodeLocation {
213
215
  * Delete a variables by the passed in ID and all of its uses from this
214
216
  * workspace. May prompt the user for confirmation.
215
217
  *
218
+ * @deprecated v12, use Blockly.Workspace.getVariableMap().deleteVariable.
216
219
  * @param id ID of variable to delete.
217
220
  */
218
221
  deleteVariableById(id: string): void;
@@ -220,44 +223,42 @@ export declare class Workspace implements IASTNodeLocation {
220
223
  * Find the variable by the given name and return it. Return null if not
221
224
  * found.
222
225
  *
226
+ * @deprecated v12, use Blockly.Workspace.getVariableMap().getVariable.
223
227
  * @param name The name to check for.
224
228
  * @param opt_type The type of the variable. If not provided it defaults to
225
229
  * the empty string, which is a specific type.
226
230
  * @returns The variable with the given name.
227
231
  */
228
- getVariable(name: string, opt_type?: string): VariableModel | null;
232
+ getVariable(name: string, opt_type?: string): IVariableModel<IVariableState> | null;
229
233
  /**
230
234
  * Find the variable by the given ID and return it. Return null if not found.
231
235
  *
236
+ * @deprecated v12, use Blockly.Workspace.getVariableMap().getVariableById.
232
237
  * @param id The ID to check for.
233
238
  * @returns The variable with the given ID.
234
239
  */
235
- getVariableById(id: string): VariableModel | null;
240
+ getVariableById(id: string): IVariableModel<IVariableState> | null;
236
241
  /**
237
242
  * Find the variable with the specified type. If type is null, return list of
238
243
  * variables with empty string type.
239
244
  *
245
+ * @deprecated v12, use Blockly.Workspace.getVariableMap().getVariablesOfType.
240
246
  * @param type Type of the variables to find.
241
247
  * @returns The sought after variables of the passed in type. An empty array
242
248
  * if none are found.
243
249
  */
244
- getVariablesOfType(type: string | null): VariableModel[];
245
- /**
246
- * Return all variable types.
247
- *
248
- * @returns List of variable types.
249
- * @internal
250
- */
251
- getVariableTypes(): string[];
250
+ getVariablesOfType(type: string | null): IVariableModel<IVariableState>[];
252
251
  /**
253
252
  * Return all variables of all types.
254
253
  *
254
+ * @deprecated v12, use Blockly.Workspace.getVariableMap().getAllVariables.
255
255
  * @returns List of variable models.
256
256
  */
257
- getAllVariables(): VariableModel[];
257
+ getAllVariables(): IVariableModel<IVariableState>[];
258
258
  /**
259
259
  * Returns all variable names of all types.
260
260
  *
261
+ * @deprecated v12, use Blockly.Workspace.getVariableMap().getAllVariables.
261
262
  * @returns List of all variable names of all types.
262
263
  */
263
264
  getAllVariableNames(): string[];
@@ -411,7 +412,7 @@ export declare class Workspace implements IASTNodeLocation {
411
412
  * @returns The potential variable map.
412
413
  * @internal
413
414
  */
414
- getPotentialVariableMap(): VariableMap | null;
415
+ getPotentialVariableMap(): IVariableMap<IVariableModel<IVariableState>> | null;
415
416
  /**
416
417
  * Create and store the potential variable map for this workspace.
417
418
  *
@@ -423,14 +424,14 @@ export declare class Workspace implements IASTNodeLocation {
423
424
  *
424
425
  * @returns The variable map.
425
426
  */
426
- getVariableMap(): VariableMap;
427
+ getVariableMap(): IVariableMap<IVariableModel<IVariableState>>;
427
428
  /**
428
429
  * Set the map of all variables on the workspace.
429
430
  *
430
431
  * @param variableMap The variable map.
431
432
  * @internal
432
433
  */
433
- setVariableMap(variableMap: VariableMap): void;
434
+ setVariableMap(variableMap: IVariableMap<IVariableModel<IVariableState>>): void;
434
435
  /** Returns the map of all procedures on the workpace. */
435
436
  getProcedureMap(): IProcedureMap;
436
437
  /**
@@ -454,5 +455,6 @@ export declare class Workspace implements IASTNodeLocation {
454
455
  * @returns Array of workspaces.
455
456
  */
456
457
  static getAll(): Workspace[];
458
+ protected getVariableMapClass(): new (...p1: any[]) => IVariableMap<IVariableModel<IVariableState>>;
457
459
  }
458
460
  //# sourceMappingURL=workspace.d.ts.map
@@ -26,6 +26,7 @@ import type { IDragTarget } from './interfaces/i_drag_target.js';
26
26
  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
+ import type { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
29
30
  import type { Cursor } from './keyboard_nav/cursor.js';
30
31
  import type { Marker } from './keyboard_nav/marker.js';
31
32
  import { LayerManager } from './layer_manager.js';
@@ -42,7 +43,6 @@ import { Rect } from './utils/rect.js';
42
43
  import { Size } from './utils/size.js';
43
44
  import { Svg } from './utils/svg.js';
44
45
  import * as toolbox from './utils/toolbox.js';
45
- import type { VariableModel } from './variable_model.js';
46
46
  import { Workspace } from './workspace.js';
47
47
  import { WorkspaceAudio } from './workspace_audio.js';
48
48
  import { ZoomControls } from './zoom_controls.js';
@@ -392,7 +392,7 @@ export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationS
392
392
  * @returns The first parent div with 'injectionDiv' in the name.
393
393
  * @internal
394
394
  */
395
- getInjectionDiv(): Element;
395
+ getInjectionDiv(): HTMLElement;
396
396
  /**
397
397
  * Returns the SVG group for the workspace.
398
398
  *
@@ -419,7 +419,7 @@ export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationS
419
419
  * 'blocklyMutatorBackground'.
420
420
  * @returns The workspace's SVG group.
421
421
  */
422
- createDom(opt_backgroundClass?: string, injectionDiv?: Element): Element;
422
+ createDom(opt_backgroundClass?: string, injectionDiv?: HTMLElement): Element;
423
423
  /**
424
424
  * Dispose of this workspace.
425
425
  * Unlink from all DOM elements to prevent memory leaks.
@@ -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
  /**
@@ -603,7 +604,7 @@ export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationS
603
604
  * @param opt_id The unique ID of the variable. This will default to a UUID.
604
605
  * @returns The newly created variable.
605
606
  */
606
- createVariable(name: string, opt_type?: string | null, opt_id?: string | null): VariableModel;
607
+ createVariable(name: string, opt_type?: string | null, opt_id?: string | null): IVariableModel<IVariableState>;
607
608
  /** Make a list of all the delete areas for this workspace. */
608
609
  recordDragTargets(): void;
609
610
  /**
@@ -773,12 +774,27 @@ export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationS
773
774
  */
774
775
  setScale(newScale: number): void;
775
776
  /**
776
- * Get the workspace's zoom factor. If the workspace has a parent, we call
777
- * into the parent to get the workspace scale.
777
+ * Get the workspace's zoom factor.
778
778
  *
779
779
  * @returns The workspace zoom factor. Units: (pixels / workspaceUnit).
780
780
  */
781
781
  getScale(): number;
782
+ /**
783
+ * Returns the absolute scale of the workspace.
784
+ *
785
+ * Workspace scaling is multiplicative; if a workspace B (e.g. a mutator editor)
786
+ * with scale Y is nested within a root workspace A with scale X, workspace B's
787
+ * effective scale is X * Y, because, as a child of A, it is already transformed
788
+ * by A's scaling factor, and then further transforms itself by its own scaling
789
+ * factor. Normally this Just Works, but for global elements (e.g. field
790
+ * editors) that are visually associated with a particular workspace but live at
791
+ * the top level of the DOM rather than being a child of their associated
792
+ * workspace, the absolute/effective scale may be needed to render
793
+ * appropriately.
794
+ *
795
+ * @returns The absolute/effective scale of the given workspace.
796
+ */
797
+ getAbsoluteScale(): number;
782
798
  /**
783
799
  * Scroll the workspace to a specified offset (in pixels), keeping in the
784
800
  * workspace bounds. See comment on workspaceSvg.scrollX for more detail on
@@ -975,6 +991,18 @@ export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationS
975
991
  * and 1 specifying the degree of scrolling.
976
992
  */
977
993
  private static setTopLevelWorkspaceMetrics;
994
+ /**
995
+ * Adds a CSS class to the workspace.
996
+ *
997
+ * @param className Name of class to add.
998
+ */
999
+ addClass(className: string): void;
1000
+ /**
1001
+ * Removes a CSS class from the workspace.
1002
+ *
1003
+ * @param className Name of class to remove.
1004
+ */
1005
+ removeClass(className: string): void;
978
1006
  }
979
1007
  /**
980
1008
  * Size the workspace when the contents change. This also updates
package/core/xml.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import type { Block } from './block.js';
7
7
  import { WorkspaceComment } from './comments/workspace_comment.js';
8
- import type { VariableModel } from './variable_model.js';
8
+ import type { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
9
9
  import type { Workspace } from './workspace.js';
10
10
  import { WorkspaceSvg } from './workspace_svg.js';
11
11
  /**
@@ -25,7 +25,7 @@ export declare function saveWorkspaceComment(comment: WorkspaceComment, skipId?:
25
25
  * @param variableList List of all variable models.
26
26
  * @returns Tree of XML elements.
27
27
  */
28
- export declare function variablesToDom(variableList: VariableModel[]): Element;
28
+ export declare function variablesToDom(variableList: IVariableModel<IVariableState>[]): Element;
29
29
  /**
30
30
  * Encode a block subtree as XML with XY coordinates.
31
31
  *
package/index.mjs CHANGED
@@ -3,8 +3,10 @@ export const {
3
3
  ASTNode,
4
4
  BasicCursor,
5
5
  Block,
6
+ BlockFlyoutInflater,
6
7
  BlockSvg,
7
8
  Blocks,
9
+ ButtonFlyoutInflater,
8
10
  COLLAPSED_FIELD_NAME,
9
11
  COLLAPSED_INPUT_NAME,
10
12
  COLLAPSE_CHARS,
@@ -37,15 +39,17 @@ export const {
37
39
  FieldVariable,
38
40
  Flyout,
39
41
  FlyoutButton,
42
+ FlyoutItem,
40
43
  FlyoutMetricsManager,
44
+ FlyoutSeparator,
41
45
  Generator,
42
46
  Gesture,
43
47
  Grid,
44
48
  HorizontalFlyout,
45
49
  INPUT_VALUE,
46
50
  Input,
47
- InsertionMarkerManager,
48
51
  InsertionMarkerPreviewer,
52
+ LabelFlyoutInflater,
49
53
  Marker,
50
54
  MarkerManager,
51
55
  Menu,
@@ -64,6 +68,7 @@ export const {
64
68
  RenderedConnection,
65
69
  Scrollbar,
66
70
  ScrollbarPair,
71
+ SeparatorFlyoutInflater,
67
72
  ShortcutItems,
68
73
  ShortcutRegistry,
69
74
  TOOLBOX_AT_BOTTOM,
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": "11.2.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"
package/php_compressed.js CHANGED
@@ -200,7 +200,7 @@ function ${b.FUNCTION_NAME_PLACEHOLDER_}($a, $b) {
200
200
  return rand($a, $b);
201
201
  }
202
202
  `)+"("+c+", "+a+")",Order$$module$build$src$generators$php$php_generator.FUNCTION_CALL]},math_random_float$$module$build$src$generators$php$math=function(a,b){return["(float)rand()/(float)getrandmax()",Order$$module$build$src$generators$php$php_generator.FUNCTION_CALL]},math_atan2$$module$build$src$generators$php$math=function(a,b){const c=b.valueToCode(a,"X",Order$$module$build$src$generators$php$php_generator.NONE)||"0";return["atan2("+(b.valueToCode(a,"Y",Order$$module$build$src$generators$php$php_generator.NONE)||
203
- "0")+", "+c+") / pi() * 180",Order$$module$build$src$generators$php$php_generator.DIVISION]},procedures_defreturn$$module$build$src$generators$php$procedures=function(a,b){var c=[],d=a.workspace,e=$.allUsedVarModels$$module$build$src$core$variables(d)||[];for(var f of e)e=f.name,a.getVars().includes(e)||c.push(b.getVariableName(e));d=$.allDeveloperVariables$$module$build$src$core$variables(d);for(f=0;f<d.length;f++)c.push(b.nameDB_.getName(d[f],$.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE));
203
+ "0")+", "+c+") / pi() * 180",Order$$module$build$src$generators$php$php_generator.DIVISION]},procedures_defreturn$$module$build$src$generators$php$procedures=function(a,b){var c=[],d=a.workspace,e=$.allUsedVarModels$$module$build$src$core$variables(d)||[];for(var f of e)e=f.getName(),a.getVars().includes(e)||c.push(b.getVariableName(e));d=$.allDeveloperVariables$$module$build$src$core$variables(d);for(f=0;f<d.length;f++)c.push(b.nameDB_.getName(d[f],$.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE));
204
204
  d=c.length?b.INDENT+"global "+c.join(", ")+";\n":"";c=b.getProcedureName(a.getFieldValue("NAME"));f="";b.STATEMENT_PREFIX&&(f+=b.injectId(b.STATEMENT_PREFIX,a));b.STATEMENT_SUFFIX&&(f+=b.injectId(b.STATEMENT_SUFFIX,a));f&&(f=b.prefixLines(f,b.INDENT));e="";b.INFINITE_LOOP_TRAP&&(e=b.prefixLines(b.injectId(b.INFINITE_LOOP_TRAP,a),b.INDENT));let g="";a.getInput("STACK")&&(g=b.statementToCode(a,"STACK"));let h="";a.getInput("RETURN")&&(h=b.valueToCode(a,"RETURN",Order$$module$build$src$generators$php$php_generator.NONE)||
205
205
  "");let k="";g&&h&&(k=f);h&&(h=b.INDENT+"return "+h+";\n");const l=[],m=a.getVars();for(let n=0;n<m.length;n++)l[n]=b.getVariableName(m[n]);d="function "+c+"("+l.join(", ")+") {\n"+d+f+e+g+k+h+"}";d=b.scrub_(a,d);b.definitions_["%"+c]=d;return null},procedures_callreturn$$module$build$src$generators$php$procedures=function(a,b){const c=b.getProcedureName(a.getFieldValue("NAME")),d=[],e=a.getVars();for(let f=0;f<e.length;f++)d[f]=b.valueToCode(a,"ARG"+f,Order$$module$build$src$generators$php$php_generator.NONE)||
206
206
  "null";return[c+"("+d.join(", ")+")",Order$$module$build$src$generators$php$php_generator.FUNCTION_CALL]},procedures_callnoreturn$$module$build$src$generators$php$procedures=function(a,b){return b.forBlock.procedures_callreturn(a,b)[0]+";\n"},procedures_ifreturn$$module$build$src$generators$php$procedures=function(a,b){let c="if ("+(b.valueToCode(a,"CONDITION",Order$$module$build$src$generators$php$php_generator.NONE)||"false")+") {\n";b.STATEMENT_SUFFIX&&(c+=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,