blockly 11.2.0-beta.2 → 12.0.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 (70) hide show
  1. package/blockly.min.js +700 -698
  2. package/blockly.mjs +5 -1
  3. package/blockly_compressed.js +688 -686
  4. package/blockly_compressed.js.map +1 -1
  5. package/blocks_compressed.js +12 -12
  6. package/blocks_compressed.js.map +1 -1
  7. package/core/block.d.ts +3 -3
  8. package/core/block_flyout_inflater.d.ts +89 -0
  9. package/core/block_svg.d.ts +18 -0
  10. package/core/blockly.d.ts +11 -4
  11. package/core/bubbles/textinput_bubble.d.ts +9 -0
  12. package/core/button_flyout_inflater.d.ts +36 -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/dropdowndiv.d.ts +1 -1
  17. package/core/events/events.d.ts +1 -0
  18. package/core/events/events_var_base.d.ts +2 -2
  19. package/core/events/events_var_create.d.ts +7 -2
  20. package/core/events/events_var_delete.d.ts +2 -2
  21. package/core/events/events_var_rename.d.ts +2 -2
  22. package/core/events/events_var_type_change.d.ts +55 -0
  23. package/core/events/type.d.ts +2 -0
  24. package/core/field.d.ts +0 -13
  25. package/core/field_checkbox.d.ts +0 -4
  26. package/core/field_dropdown.d.ts +0 -2
  27. package/core/field_input.d.ts +0 -2
  28. package/core/field_number.d.ts +6 -0
  29. package/core/field_textinput.d.ts +1 -0
  30. package/core/field_variable.d.ts +9 -2
  31. package/core/flyout_base.d.ts +47 -176
  32. package/core/flyout_button.d.ts +25 -6
  33. package/core/flyout_horizontal.d.ts +2 -3
  34. package/core/flyout_separator.d.ts +45 -0
  35. package/core/flyout_vertical.d.ts +3 -4
  36. package/core/grid.d.ts +4 -1
  37. package/core/icons/comment_icon.d.ts +15 -0
  38. package/core/interfaces/i_comment_icon.d.ts +3 -0
  39. package/core/interfaces/i_flyout_inflater.d.ts +39 -0
  40. package/core/interfaces/i_toolbox.d.ts +8 -1
  41. package/core/interfaces/i_variable_backed_parameter_model.d.ts +2 -2
  42. package/core/interfaces/i_variable_map.d.ts +48 -0
  43. package/core/interfaces/i_variable_model.d.ts +36 -0
  44. package/core/label_flyout_inflater.d.ts +36 -0
  45. package/core/menuitem.d.ts +0 -7
  46. package/core/names.d.ts +8 -2
  47. package/core/registry.d.ts +6 -0
  48. package/core/renderers/common/constants.d.ts +6 -1
  49. package/core/renderers/common/i_path_object.d.ts +13 -13
  50. package/core/renderers/common/renderer.d.ts +12 -17
  51. package/core/renderers/geras/renderer.d.ts +1 -1
  52. package/core/renderers/zelos/constants.d.ts +8 -2
  53. package/core/renderers/zelos/renderer.d.ts +0 -7
  54. package/core/separator_flyout_inflater.d.ts +47 -0
  55. package/core/serialization/variables.d.ts +3 -10
  56. package/core/toolbox/toolbox.d.ts +2 -5
  57. package/core/variable_map.d.ts +27 -29
  58. package/core/variable_model.d.ts +37 -11
  59. package/core/variables.d.ts +38 -8
  60. package/core/widgetdiv.d.ts +2 -2
  61. package/core/workspace.d.ts +21 -19
  62. package/core/workspace_svg.d.ts +33 -6
  63. package/core/xml.d.ts +2 -2
  64. package/index.mjs +5 -1
  65. package/package.json +1 -1
  66. package/php_compressed.js +1 -1
  67. package/php_compressed.js.map +1 -1
  68. package/python_compressed.js +1 -1
  69. package/python_compressed.js.map +1 -1
  70. package/core/insertion_marker_manager.d.ts +0 -249
@@ -9,6 +9,7 @@
9
9
  * @class
10
10
  */
11
11
  import './events/events_var_create.js';
12
+ import { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
12
13
  import type { Workspace } from './workspace.js';
13
14
  /**
14
15
  * Class for a variable model.
@@ -16,10 +17,10 @@ import type { Workspace } from './workspace.js';
16
17
  *
17
18
  * @see {Blockly.FieldVariable}
18
19
  */
19
- export declare class VariableModel {
20
- workspace: Workspace;
21
- name: string;
22
- type: string;
20
+ export declare class VariableModel implements IVariableModel<IVariableState> {
21
+ private readonly workspace;
22
+ private name;
23
+ private type;
23
24
  private readonly id;
24
25
  /**
25
26
  * @param workspace The variable's workspace.
@@ -33,15 +34,40 @@ export declare class VariableModel {
33
34
  constructor(workspace: Workspace, name: string, opt_type?: string, opt_id?: string);
34
35
  /** @returns The ID for the variable. */
35
36
  getId(): string;
37
+ /** @returns The name of this variable. */
38
+ getName(): string;
36
39
  /**
37
- * A custom compare function for the VariableModel objects.
40
+ * Updates the user-visible name of this variable.
38
41
  *
39
- * @param var1 First variable to compare.
40
- * @param var2 Second variable to compare.
41
- * @returns -1 if name of var1 is less than name of var2, 0 if equal, and 1 if
42
- * greater.
43
- * @internal
42
+ * @returns The newly-updated variable.
44
43
  */
45
- static compareByName(var1: VariableModel, var2: VariableModel): number;
44
+ setName(newName: string): this;
45
+ /** @returns The type of this variable. */
46
+ getType(): string;
47
+ /**
48
+ * Updates the type of this variable.
49
+ *
50
+ * @returns The newly-updated variable.
51
+ */
52
+ setType(newType: string): this;
53
+ /**
54
+ * Returns the workspace this VariableModel belongs to.
55
+ *
56
+ * @returns The workspace this VariableModel belongs to.
57
+ */
58
+ getWorkspace(): Workspace;
59
+ /**
60
+ * Serializes this VariableModel.
61
+ *
62
+ * @returns a JSON representation of this VariableModel.
63
+ */
64
+ save(): IVariableState;
65
+ /**
66
+ * Loads the persisted state into a new variable in the given workspace.
67
+ *
68
+ * @param state The serialized state of a variable model from save().
69
+ * @param workspace The workspace to create the new variable in.
70
+ */
71
+ static load(state: IVariableState, workspace: Workspace): void;
46
72
  }
47
73
  //# sourceMappingURL=variable_model.d.ts.map
@@ -3,7 +3,8 @@
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';
7
8
  import type { Workspace } from './workspace.js';
8
9
  import type { WorkspaceSvg } from './workspace_svg.js';
9
10
  /**
@@ -23,7 +24,7 @@ export declare const CATEGORY_NAME = "VARIABLE";
23
24
  * @param ws The workspace to search for variables.
24
25
  * @returns Array of variable models.
25
26
  */
26
- export declare function allUsedVarModels(ws: Workspace): VariableModel[];
27
+ export declare function allUsedVarModels(ws: Workspace): IVariableModel<IVariableState>[];
27
28
  /**
28
29
  * Find all developer variables used by blocks in the workspace.
29
30
  * Developer variables are never shown to the user, but are declared as global
@@ -104,7 +105,7 @@ export declare function createVariableButtonHandler(workspace: Workspace, opt_ca
104
105
  * name, or null if change is to be aborted (cancel button), or undefined if
105
106
  * an existing variable was chosen.
106
107
  */
107
- export declare function renameVariable(workspace: Workspace, variable: VariableModel, opt_callback?: (p1?: string | null) => void): void;
108
+ export declare function renameVariable(workspace: Workspace, variable: IVariableModel<IVariableState>, opt_callback?: (p1?: string | null) => void): void;
108
109
  /**
109
110
  * Prompt the user for a new variable name.
110
111
  *
@@ -121,7 +122,7 @@ export declare function promptName(promptText: string, defaultText: string, call
121
122
  * @param workspace The workspace to search for the variable.
122
123
  * @returns The variable with the given name, or null if none was found.
123
124
  */
124
- export declare function nameUsedWithAnyType(name: string, workspace: Workspace): VariableModel | null;
125
+ export declare function nameUsedWithAnyType(name: string, workspace: Workspace): IVariableModel<IVariableState> | null;
125
126
  /**
126
127
  * Returns the name of the procedure with a conflicting parameter name, or null
127
128
  * if one does not exist.
@@ -141,7 +142,7 @@ export declare function nameUsedWithConflictingParam(oldName: string, newName: s
141
142
  * @param variableModel The variable model to represent.
142
143
  * @returns The generated DOM.
143
144
  */
144
- export declare function generateVariableFieldDom(variableModel: VariableModel): Element;
145
+ export declare function generateVariableFieldDom(variableModel: IVariableModel<IVariableState>): Element;
145
146
  /**
146
147
  * Helper function to look up or create a variable on the given workspace.
147
148
  * If no variable exists, creates and returns it.
@@ -154,7 +155,7 @@ export declare function generateVariableFieldDom(variableModel: VariableModel):
154
155
  * @returns The variable corresponding to the given ID or name + type
155
156
  * combination.
156
157
  */
157
- export declare function getOrCreateVariablePackage(workspace: Workspace, id: string | null, opt_name?: string, opt_type?: string): VariableModel;
158
+ export declare function getOrCreateVariablePackage(workspace: Workspace, id: string | null, opt_name?: string, opt_type?: string): IVariableModel<IVariableState>;
158
159
  /**
159
160
  * Look up a variable on the given workspace.
160
161
  * Always looks in the main workspace before looking in the flyout workspace.
@@ -170,7 +171,7 @@ export declare function getOrCreateVariablePackage(workspace: Workspace, id: str
170
171
  * @returns The variable corresponding to the given ID or name + type
171
172
  * combination, or null if not found.
172
173
  */
173
- export declare function getVariable(workspace: Workspace, id: string | null, opt_name?: string, opt_type?: string): VariableModel | null;
174
+ export declare function getVariable(workspace: Workspace, id: string | null, opt_name?: string, opt_type?: string): IVariableModel<IVariableState> | null;
174
175
  /**
175
176
  * Helper function to get the list of variables that have been added to the
176
177
  * workspace after adding a new block, using the given list of variables that
@@ -184,7 +185,36 @@ export declare function getVariable(workspace: Workspace, id: string | null, opt
184
185
  * workspace.
185
186
  * @internal
186
187
  */
187
- export declare function getAddedVariables(workspace: Workspace, originalVariables: VariableModel[]): VariableModel[];
188
+ export declare function getAddedVariables(workspace: Workspace, originalVariables: IVariableModel<IVariableState>[]): IVariableModel<IVariableState>[];
189
+ /**
190
+ * A custom compare function for the VariableModel objects.
191
+ *
192
+ * @param var1 First variable to compare.
193
+ * @param var2 Second variable to compare.
194
+ * @returns -1 if name of var1 is less than name of var2, 0 if equal, and 1 if
195
+ * greater.
196
+ * @internal
197
+ */
198
+ export declare function compareByName(var1: IVariableModel<IVariableState>, var2: IVariableModel<IVariableState>): number;
199
+ /**
200
+ * Find all the uses of a named variable.
201
+ *
202
+ * @param workspace The workspace to search for the variable.
203
+ * @param id ID of the variable to find.
204
+ * @returns Array of block usages.
205
+ */
206
+ export declare function getVariableUsesById(workspace: Workspace, id: string): Block[];
207
+ /**
208
+ * Delete a variable and all of its uses from the given workspace. May prompt
209
+ * the user for confirmation.
210
+ *
211
+ * @param workspace The workspace from which to delete the variable.
212
+ * @param variable The variable to delete.
213
+ * @param triggeringBlock The block from which this deletion was triggered, if
214
+ * any. Used to exclude it from checking and warning about blocks
215
+ * referencing the variable being deleted.
216
+ */
217
+ export declare function deleteVariable(workspace: Workspace, variable: IVariableModel<IVariableState>, triggeringBlock?: Block): void;
188
218
  export declare const TEST_ONLY: {
189
219
  generateUniqueNameInternal: typeof generateUniqueNameInternal;
190
220
  };
@@ -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.
@@ -603,7 +603,7 @@ export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationS
603
603
  * @param opt_id The unique ID of the variable. This will default to a UUID.
604
604
  * @returns The newly created variable.
605
605
  */
606
- createVariable(name: string, opt_type?: string | null, opt_id?: string | null): VariableModel;
606
+ createVariable(name: string, opt_type?: string | null, opt_id?: string | null): IVariableModel<IVariableState>;
607
607
  /** Make a list of all the delete areas for this workspace. */
608
608
  recordDragTargets(): void;
609
609
  /**
@@ -773,12 +773,27 @@ export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationS
773
773
  */
774
774
  setScale(newScale: number): void;
775
775
  /**
776
- * Get the workspace's zoom factor. If the workspace has a parent, we call
777
- * into the parent to get the workspace scale.
776
+ * Get the workspace's zoom factor.
778
777
  *
779
778
  * @returns The workspace zoom factor. Units: (pixels / workspaceUnit).
780
779
  */
781
780
  getScale(): number;
781
+ /**
782
+ * Returns the absolute scale of the workspace.
783
+ *
784
+ * Workspace scaling is multiplicative; if a workspace B (e.g. a mutator editor)
785
+ * with scale Y is nested within a root workspace A with scale X, workspace B's
786
+ * effective scale is X * Y, because, as a child of A, it is already transformed
787
+ * by A's scaling factor, and then further transforms itself by its own scaling
788
+ * factor. Normally this Just Works, but for global elements (e.g. field
789
+ * editors) that are visually associated with a particular workspace but live at
790
+ * the top level of the DOM rather than being a child of their associated
791
+ * workspace, the absolute/effective scale may be needed to render
792
+ * appropriately.
793
+ *
794
+ * @returns The absolute/effective scale of the given workspace.
795
+ */
796
+ getAbsoluteScale(): number;
782
797
  /**
783
798
  * Scroll the workspace to a specified offset (in pixels), keeping in the
784
799
  * workspace bounds. See comment on workspaceSvg.scrollX for more detail on
@@ -975,6 +990,18 @@ export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationS
975
990
  * and 1 specifying the degree of scrolling.
976
991
  */
977
992
  private static setTopLevelWorkspaceMetrics;
993
+ /**
994
+ * Adds a CSS class to the workspace.
995
+ *
996
+ * @param className Name of class to add.
997
+ */
998
+ addClass(className: string): void;
999
+ /**
1000
+ * Removes a CSS class from the workspace.
1001
+ *
1002
+ * @param className Name of class to remove.
1003
+ */
1004
+ removeClass(className: string): void;
978
1005
  }
979
1006
  /**
980
1007
  * 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,
@@ -38,14 +40,15 @@ export const {
38
40
  Flyout,
39
41
  FlyoutButton,
40
42
  FlyoutMetricsManager,
43
+ FlyoutSeparator,
41
44
  Generator,
42
45
  Gesture,
43
46
  Grid,
44
47
  HorizontalFlyout,
45
48
  INPUT_VALUE,
46
49
  Input,
47
- InsertionMarkerManager,
48
50
  InsertionMarkerPreviewer,
51
+ LabelFlyoutInflater,
49
52
  Marker,
50
53
  MarkerManager,
51
54
  Menu,
@@ -64,6 +67,7 @@ export const {
64
67
  RenderedConnection,
65
68
  Scrollbar,
66
69
  ScrollbarPair,
70
+ SeparatorFlyoutInflater,
67
71
  ShortcutItems,
68
72
  ShortcutRegistry,
69
73
  TOOLBOX_AT_BOTTOM,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blockly",
3
- "version": "11.2.0-beta.2",
3
+ "version": "12.0.0-beta.0",
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,