From 1fb204e36b4e395c3fd2d6da451f27fb78f2ad2f Mon Sep 17 00:00:00 2001 From: Maribeth Bottorff Date: Thu, 9 Dec 2021 10:43:43 -0800 Subject: [PATCH] fix: Upload new TypeScript typings for Q4 release (#5802) * fix: Run intial typings script for q4 release * fix: manually fix errors with types * fix: update core module --- typings/blockly.d.ts | 29296 +++++++++++++++++++++++++++++++++++------ typings/core.d.ts | 2 +- 2 files changed, 25438 insertions(+), 3860 deletions(-) diff --git a/typings/blockly.d.ts b/typings/blockly.d.ts index 09563ccd0..291f472fd 100644 --- a/typings/blockly.d.ts +++ b/typings/blockly.d.ts @@ -1,154 +1,25198 @@ -/** - * @license - * Copyright 2019 Google LLC - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * @fileoverview Type definitions for Blockly. - * @author samelh@google.com (Sam El-Husseini) - */ - -export = Blockly; - -declare module Blockly { - - interface BlocklyOptions { - toolbox?: Blockly.utils.toolbox.ToolboxDefinition; - readOnly?: boolean; - trashcan?: boolean; - maxInstances?: {[type: string]: number;}; - maxTrashcanContents?: number; - collapse?: boolean; - comments?: boolean; - disable?: boolean; - sounds?: boolean; - rtl?: boolean; - horizontalLayout?: boolean; - toolboxPosition?: string; - css?: boolean; - oneBasedIndex?: boolean; - media?: string; - theme?: Blockly.Theme | BlocklyThemeOptions; - move?: { - scrollbars?: boolean; - drag?: boolean; - wheel?: boolean; - }; - grid?: { - spacing?: number; - colour?: string; - length?: number; - snap?: boolean; - }; - zoom?: { - controls?: boolean; - wheel?: boolean; - startScale?: number; - maxScale?: number; - minScale?: number; - scaleSpeed?: number; - pinch?: boolean; - }; - renderer?: string; - parentWorkspace?: Blockly.WorkspaceSvg; - } - - interface BlocklyThemeOptions { - base?: string; - blockStyles?: {[blocks: string]: Blockly.Theme.BlockStyle;}; - categoryStyles?: {[category: string]: Blockly.Theme.CategoryStyle;}; - componentStyles?: {[component: string]: any;}; - fontStyle?: Blockly.Theme.FontStyle; - startHats?: boolean; - } - - /** - * Set the Blockly locale. - * Note: this method is only available in the npm release of Blockly. - * @param {!Object} msg An object of Blockly message strings in the desired - * language. - */ - function setLocale(msg: {[key: string]: string;}): void; +declare module "utils/idgenerator" { + namespace internal { + /** + * Generate a random unique ID. This should be globally unique. + * 87 characters ^ 20 length > 128 bits (better than a UUID). + * @return {string} A globally unique ID string. + */ + function genUid(): string; + } + /** + * Generate the next unique element IDs. + * IDs are compatible with the HTML4 id attribute restrictions: + * Use only ASCII letters, digits, '_', '-' and '.' + * + * For UUIDs use genUid (below) instead; this ID generator should + * primarily be used for IDs that end up in the DOM. + * + * @return {string} The next unique identifier. + * @alias Blockly.utils.idGenerator.getNextUniqueId + */ + export function getNextUniqueId(): string; + /** + * Generate a random unique ID. + * @see internal.genUid + * @return {string} A globally unique ID string. + * @alias Blockly.utils.idGenerator.genUid + */ + export function genUid(): string; + export { internal as TEST_ONLY }; } - -declare module Blockly.utils { - interface Metrics { - viewHeight: number; - viewWidth: number; - contentHeight: number; - contentWidth: number; - viewTop: number; - viewLeft: number; - contentTop: number; - contentLeft: number; - absoluteTop: number; - absoluteLeft: number; - svgHeight?: number; - svgWidth?: number; - toolboxWidth?: number; - toolboxHeight?: number; - flyoutWidth?: number; - flyoutHeight?: number; - toolboxPosition?: number; - } +declare module "utils/object" { + /** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview Utility methods for objects. + */ + /** + * Utility methods for objects. + * @namespace Blockly.utils.object + */ + /** + * Inherit the prototype methods from one constructor into another. + * @param {!Function} childCtor Child class. + * @param {!Function} parentCtor Parent class. + * @suppress {strictMissingProperties} superClass_ is not defined on Function. + * @alias Blockly.utils.object.inherits + */ + export function inherits(childCtor: Function, parentCtor: Function): void; + /** + * Copies all the members of a source object to a target object. + * @param {!Object} target Target. + * @param {!Object} source Source. + * @alias Blockly.utils.object.mixin + */ + export function mixin(target: any, source: any): void; + /** + * Complete a deep merge of all members of a source object with a target object. + * @param {!Object} target Target. + * @param {!Object} source Source. + * @return {!Object} The resulting object. + * @alias Blockly.utils.object.deepMerge + */ + export function deepMerge(target: any, source: any): any; + /** + * Returns an array of a given object's own enumerable property values. + * @param {!Object} obj Object containing values. + * @return {!Array} Array of values. + * @alias Blockly.utils.object.values + */ + export function values(obj: any): any[]; } - - -declare module Block { +declare module "connection_type" { + /** + * * + */ + export type ConnectionType = number; + export namespace ConnectionType { + const INPUT_VALUE: number; + const OUTPUT_VALUE: number; + const NEXT_STATEMENT: number; + const PREVIOUS_STATEMENT: number; + } +} +declare module "utils/global" { + /** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview Provides a reference to the global object. + */ + /** + * Provides a reference to the global object. + * @namespace Blockly.utils.global + */ + /** + * Reference to the global object. + * + * More info on this implementation here: + * https://docs.google.com/document/d/1NAeW4Wk7I7FV0Y2tcUFvQdGMc89k2vdgSXInw8_nvCI + */ + export const globalThis: any; +} +declare module "utils/useragent" { + /** + * The raw useragent string. + * @type {string} + */ + let rawUserAgent: string; + /** @type {boolean} */ + let isIe: boolean; + /** @type {boolean} */ + let isEdge: boolean; + /** @type {boolean} */ + let isJavaFx: boolean; + /** @type {boolean} */ + let isChrome: boolean; + /** @type {boolean} */ + let isWebKit: boolean; + /** @type {boolean} */ + let isGecko: boolean; + /** @type {boolean} */ + let isAndroid: boolean; + /** @type {boolean} */ + let isIPad: boolean; + /** @type {boolean} */ + let isIPod: boolean; + /** @type {boolean} */ + let isIPhone: boolean; + /** @type {boolean} */ + let isMac: boolean; + /** @type {boolean} */ + let isTablet: boolean; + /** @type {boolean} */ + let isMobile: boolean; + export { rawUserAgent as raw, isIe as IE, isEdge as EDGE, isJavaFx as JavaFx, isChrome as CHROME, isWebKit as WEBKIT, isGecko as GECKO, isAndroid as ANDROID, isIPad as IPAD, isIPod as IPOD, isIPhone as IPHONE, isMac as MAC, isTablet as TABLET, isMobile as MOBILE }; +} +declare module "utils/svg" { + /** + * @license + * Copyright 2020 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview Defines the Svg class. Its constants enumerate + * all SVG tag names used by Blockly. + */ + /** + * Defines the Svg class. Its constants enumerate + * all SVG tag names used by Blockly. + * @class + */ + /** + * A name with the type of the SVG element stored in the generic. + * @param {string} tagName The SVG element tag name. + * @constructor + * @template T + * @private + * @alias Blockly.utils.Svg + */ + export class Svg { + constructor(tagName: any); + /** + * @type {string} + * @private + */ + private tagName_; + /** + * Returns the SVG element tag name. + * @return {string} The name. + * @override + */ + toString(): string; + } + export namespace Svg { + const ANIMATE: Svg; + const CIRCLE: Svg; + const CLIPPATH: Svg; + const DEFS: Svg; + const FECOMPOSITE: Svg; + const FECOMPONENTTRANSFER: Svg; + const FEFLOOD: Svg; + const FEFUNCA: Svg; + const FEGAUSSIANBLUR: Svg; + const FEPOINTLIGHT: Svg; + const FESPECULARLIGHTING: Svg; + const FILTER: Svg; + const FOREIGNOBJECT: Svg; + const G: Svg; + const IMAGE: Svg; + const LINE: Svg; + const PATH: Svg; + const PATTERN: Svg; + const POLYGON: Svg; + const RECT: Svg; + const SVG: Svg; + const TEXT: Svg; + const TSPAN: Svg; + } +} +declare module "utils/dom" { + /** + * Required name space for SVG elements. + * @const + * @alias Blockly.utils.dom.SVG_NS + */ + export const SVG_NS: "http://www.w3.org/2000/svg"; + /** + * Required name space for HTML elements. + * @const + * @alias Blockly.utils.dom.HTML_NS + */ + export const HTML_NS: "http://www.w3.org/1999/xhtml"; + /** + * Required name space for XLINK elements. + * @const + * @alias Blockly.utils.dom.XLINK_NS + */ + export const XLINK_NS: "http://www.w3.org/1999/xlink"; + /** + * * + */ + export type NodeType = number; + export namespace NodeType { + const ELEMENT_NODE: number; + const TEXT_NODE: number; + const COMMENT_NODE: number; + const DOCUMENT_POSITION_CONTAINED_BY: number; + } + /** + * Helper method for creating SVG elements. + * @param {string|Svg} name Element's tag name. + * @param {!Object} attrs Dictionary of attribute names and values. + * @param {Element=} opt_parent Optional parent on which to append the element. + * @return {T} Newly created SVG element. The return type is {!SVGElement} if + * name is a string or a more specific type if it a member of Svg. + * @template T + * @alias Blockly.utils.dom.createSvgElement + */ + export function createSvgElement(name: string | Svg, attrs: any, opt_parent?: Element | undefined): T; + /** + * Add a CSS class to a element. + * Similar to Closure's goog.dom.classes.add, except it handles SVG elements. + * @param {!Element} element DOM element to add class to. + * @param {string} className Name of class to add. + * @return {boolean} True if class was added, false if already present. + * @alias Blockly.utils.dom.addClass + */ + export function addClass(element: Element, className: string): boolean; + /** + * Removes multiple calsses from an element. + * @param {!Element} element DOM element to remove classes from. + * @param {string} classNames A string of one or multiple class names for an + * element. + * @alias Blockly.utils.dom.removeClasses + */ + export function removeClasses(element: Element, classNames: string): void; + /** + * Remove a CSS class from a element. + * Similar to Closure's goog.dom.classes.remove, except it handles SVG elements. + * @param {!Element} element DOM element to remove class from. + * @param {string} className Name of class to remove. + * @return {boolean} True if class was removed, false if never present. + * @alias Blockly.utils.dom.removeClass + */ + export function removeClass(element: Element, className: string): boolean; + /** + * Checks if an element has the specified CSS class. + * Similar to Closure's goog.dom.classes.has, except it handles SVG elements. + * @param {!Element} element DOM element to check. + * @param {string} className Name of class to check. + * @return {boolean} True if class exists, false otherwise. + * @alias Blockly.utils.dom.hasClass + */ + export function hasClass(element: Element, className: string): boolean; + /** + * Removes a node from its parent. No-op if not attached to a parent. + * @param {?Node} node The node to remove. + * @return {?Node} The node removed if removed; else, null. + * @alias Blockly.utils.dom.removeNode + */ + export function removeNode(node: Node | null): Node | null; + /** + * Insert a node after a reference node. + * Contrast with node.insertBefore function. + * @param {!Element} newNode New element to insert. + * @param {!Element} refNode Existing element to precede new node. + * @alias Blockly.utils.dom.insertAfter + */ + export function insertAfter(newNode: Element, refNode: Element): void; + /** + * Whether a node contains another node. + * @param {!Node} parent The node that should contain the other node. + * @param {!Node} descendant The node to test presence of. + * @return {boolean} Whether the parent node contains the descendant node. + * @alias Blockly.utils.dom.containsNode + */ + export function containsNode(parent: Node, descendant: Node): boolean; + /** + * Sets the CSS transform property on an element. This function sets the + * non-vendor-prefixed and vendor-prefixed versions for backwards compatibility + * with older browsers. See https://caniuse.com/#feat=transforms2d + * @param {!Element} element Element to which the CSS transform will be applied. + * @param {string} transform The value of the CSS `transform` property. + * @alias Blockly.utils.dom.setCssTransform + */ + export function setCssTransform(element: Element, transform: string): void; + /** + * Start caching text widths. Every call to this function MUST also call + * stopTextWidthCache. Caches must not survive between execution threads. + * @alias Blockly.utils.dom.startTextWidthCache + */ + export function startTextWidthCache(): void; + /** + * Stop caching field widths. Unless caching was already on when the + * corresponding call to startTextWidthCache was made. + * @alias Blockly.utils.dom.stopTextWidthCache + */ + export function stopTextWidthCache(): void; + /** + * Gets the width of a text element, caching it in the process. + * @param {!Element} textElement An SVG 'text' element. + * @return {number} Width of element. + * @alias Blockly.utils.dom.getTextWidth + */ + export function getTextWidth(textElement: Element): number; + /** + * Gets the width of a text element using a faster method than `getTextWidth`. + * This method requires that we know the text element's font family and size in + * advance. Similar to `getTextWidth`, we cache the width we compute. + * @param {!Element} textElement An SVG 'text' element. + * @param {number} fontSize The font size to use. + * @param {string} fontWeight The font weight to use. + * @param {string} fontFamily The font family to use. + * @return {number} Width of element. + * @alias Blockly.utils.dom.getFastTextWidth + */ + export function getFastTextWidth(textElement: Element, fontSize: number, fontWeight: string, fontFamily: string): number; + /** + * Gets the width of a text element using a faster method than `getTextWidth`. + * This method requires that we know the text element's font family and size in + * advance. Similar to `getTextWidth`, we cache the width we compute. + * This method is similar to ``getFastTextWidth`` but expects the font size + * parameter to be a string. + * @param {!Element} textElement An SVG 'text' element. + * @param {string} fontSize The font size to use. + * @param {string} fontWeight The font weight to use. + * @param {string} fontFamily The font family to use. + * @return {number} Width of element. + * @alias Blockly.utils.dom.getFastTextWidthWithSizeString + */ + export function getFastTextWidthWithSizeString(textElement: Element, fontSize: string, fontWeight: string, fontFamily: string): number; + /** + * Measure a font's metrics. The height and baseline values. + * @param {string} text Text to measure the font dimensions of. + * @param {string} fontSize The font size to use. + * @param {string} fontWeight The font weight to use. + * @param {string} fontFamily The font family to use. + * @return {{height: number, baseline: number}} Font measurements. + * @alias Blockly.utils.dom.measureFontMetrics + */ + export function measureFontMetrics(text: string, fontSize: string, fontWeight: string, fontFamily: string): { + height: number; + baseline: number; + }; + import { Svg } from "utils/svg"; +} +declare module "utils/xml" { + /** + * Namespace for Blockly's XML. + * @alias Blockly.utils.xml.NAME_SPACE + */ + export const NAME_SPACE: "https://developers.google.com/blockly/xml"; + /** + * Get the document object to use for XML serialization. + * @return {!Document} The document object. + * @alias Blockly.utils.xml.getDocument + */ + export function getDocument(): Document; + /** + * Get the document object to use for XML serialization. + * @param {!Document} document The document object to use. + * @alias Blockly.utils.xml.setDocument + */ + export function setDocument(document: Document): void; + /** + * Create DOM element for XML. + * @param {string} tagName Name of DOM element. + * @return {!Element} New DOM element. + * @alias Blockly.utils.xml.createElement + */ + export function createElement(tagName: string): Element; + /** + * Create text element for XML. + * @param {string} text Text content. + * @return {!Text} New DOM text node. + * @alias Blockly.utils.xml.createTextNode + */ + export function createTextNode(text: string): Text; + /** + * Converts an XML string into a DOM tree. + * @param {string} text XML string. + * @return {Document} The DOM document. + * @throws if XML doesn't parse. + * @alias Blockly.utils.xml.textToDomDocument + */ + export function textToDomDocument(text: string): Document; + /** + * Converts a DOM structure into plain text. + * Currently the text format is fairly ugly: all one line with no whitespace. + * @param {!Node} dom A tree of XML nodes. + * @return {string} Text representation. + * @alias Blockly.utils.xml.domToText + */ + export function domToText(dom: Node): string; +} +declare module "utils/string" { + /** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview Utility methods for string manipulation. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. + */ + /** + * Utility methods for string manipulation. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. + * @namespace Blockly.utils.string + */ + /** + * Fast prefix-checker. + * Copied from Closure's goog.string.startsWith. + * @param {string} str The string to check. + * @param {string} prefix A string to look for at the start of `str`. + * @return {boolean} True if `str` begins with `prefix`. + * @alias Blockly.utils.string.startsWith + */ + export function startsWith(str: string, prefix: string): boolean; + /** + * Given an array of strings, return the length of the shortest one. + * @param {!Array} array Array of strings. + * @return {number} Length of shortest string. + * @alias Blockly.utils.string.shortestStringLength + */ + export function shortestStringLength(array: Array): number; + /** + * Given an array of strings, return the length of the common prefix. + * Words may not be split. Any space after a word is included in the length. + * @param {!Array} array Array of strings. + * @param {number=} opt_shortest Length of shortest string. + * @return {number} Length of common prefix. + * @alias Blockly.utils.string.commonWordPrefix + */ + export function commonWordPrefix(array: Array, opt_shortest?: number | undefined): number; + /** + * Given an array of strings, return the length of the common suffix. + * Words may not be split. Any space after a word is included in the length. + * @param {!Array} array Array of strings. + * @param {number=} opt_shortest Length of shortest string. + * @return {number} Length of common suffix. + * @alias Blockly.utils.string.commonWordSuffix + */ + export function commonWordSuffix(array: Array, opt_shortest?: number | undefined): number; + /** + * Wrap text to the specified width. + * @param {string} text Text to wrap. + * @param {number} limit Width to wrap each line. + * @return {string} Wrapped text. + * @alias Blockly.utils.string.wrap + */ + export function wrap(text: string, limit: number): string; + /** + * Is the given string a number (includes negative and decimals). + * @param {string} str Input string. + * @return {boolean} True if number, false otherwise. + * @alias Blockly.utils.string.isNumber + */ + export function isNumber(str: string): boolean; +} +declare module "internal_constants" { + /** + * The multiplier for scroll wheel deltas using the line delta mode. + * @type {number} + * @alias Blockly.internalConstants.LINE_MODE_MULTIPLIER + */ + export const LINE_MODE_MULTIPLIER: number; + /** + * The multiplier for scroll wheel deltas using the page delta mode. + * @type {number} + * @alias Blockly.internalConstants.PAGE_MODE_MULTIPLIER + */ + export const PAGE_MODE_MULTIPLIER: number; + /** + * Number of pixels the mouse must move before a drag starts. + * @alias Blockly.internalConstants.DRAG_RADIUS + */ + export const DRAG_RADIUS: 5; + /** + * Number of pixels the mouse must move before a drag/scroll starts from the + * flyout. Because the drag-intention is determined when this is reached, it is + * larger than DRAG_RADIUS so that the drag-direction is clearer. + * @alias Blockly.internalConstants.FLYOUT_DRAG_RADIUS + */ + export const FLYOUT_DRAG_RADIUS: 10; + /** + * Maximum misalignment between connections for them to snap together. + * @alias Blockly.internalConstants.SNAP_RADIUS + */ + export const SNAP_RADIUS: 28; + /** + * Maximum misalignment between connections for them to snap together, + * when a connection is already highlighted. + * @alias Blockly.internalConstants.CONNECTING_SNAP_RADIUS + */ + export const CONNECTING_SNAP_RADIUS: 28; + /** + * How much to prefer staying connected to the current connection over moving to + * a new connection. The current previewed connection is considered to be this + * much closer to the matching connection on the block than it actually is. + * @alias Blockly.internalConstants.CURRENT_CONNECTION_PREFERENCE + */ + export const CURRENT_CONNECTION_PREFERENCE: 8; + /** + * Delay in ms between trigger and bumping unconnected block out of alignment. + * @alias Blockly.internalConstants.BUMP_DELAY + */ + export const BUMP_DELAY: 250; + /** + * Maximum randomness in workspace units for bumping a block. + * @alias Blockly.internalConstants.BUMP_RANDOMNESS + */ + export const BUMP_RANDOMNESS: 10; + /** + * Number of characters to truncate a collapsed block to. + * @alias Blockly.internalConstants.COLLAPSE_CHARS + */ + export const COLLAPSE_CHARS: 30; + /** + * Length in ms for a touch to become a long press. + * @alias Blockly.internalConstants.LONGPRESS + */ + export const LONGPRESS: 750; + /** + * Prevent a sound from playing if another sound preceded it within this many + * milliseconds. + * @alias Blockly.internalConstants.SOUND_LIMIT + */ + export const SOUND_LIMIT: 100; + /** + * When dragging a block out of a stack, split the stack in two (true), or drag + * out the block healing the stack (false). + * @alias Blockly.internalConstants.DRAG_STACK + */ + export const DRAG_STACK: true; + /** + * The richness of block colours, regardless of the hue. + * Must be in the range of 0 (inclusive) to 1 (exclusive). + * @alias Blockly.internalConstants.HSV_SATURATION + */ + export const HSV_SATURATION: 0.45; + /** + * The intensity of block colours, regardless of the hue. + * Must be in the range of 0 (inclusive) to 1 (exclusive). + * @alias Blockly.internalConstants.HSV_VALUE + */ + export const HSV_VALUE: 0.65; + export namespace SPRITE { + const width: number; + const height: number; + const url: string; + } + /** + * ENUM for no drag operation. + * @const + * @alias Blockly.internalConstants.DRAG_NONE + */ + export const DRAG_NONE: 0; + /** + * ENUM for inside the sticky DRAG_RADIUS. + * @const + * @alias Blockly.internalConstants.DRAG_STICKY + */ + export const DRAG_STICKY: 1; + /** + * ENUM for inside the non-sticky DRAG_RADIUS, for differentiating between + * clicks and drags. + * @const + * @alias Blockly.internalConstants.DRAG_BEGIN + */ + export const DRAG_BEGIN: 1; + /** + * ENUM for freely draggable (outside the DRAG_RADIUS, if one applies). + * @const + * @alias Blockly.internalConstants.DRAG_FREE + */ + export const DRAG_FREE: 2; + /** + * Lookup table for determining the opposite type of a connection. + * @const + * @alias Blockly.internalConstants.OPPOSITE_TYPE + */ + export const OPPOSITE_TYPE: any[]; + /** + * String for use in the "custom" attribute of a category in toolbox XML. + * This string indicates that the category should be dynamically populated with + * variable blocks. + * @const {string} + * @alias Blockly.internalConstants.VARIABLE_CATEGORY_NAME + */ + export const VARIABLE_CATEGORY_NAME: "VARIABLE"; + /** + * String for use in the "custom" attribute of a category in toolbox XML. + * This string indicates that the category should be dynamically populated with + * variable blocks. + * @const {string} + * @alias Blockly.internalConstants.VARIABLE_DYNAMIC_CATEGORY_NAME + */ + export const VARIABLE_DYNAMIC_CATEGORY_NAME: "VARIABLE_DYNAMIC"; + /** + * String for use in the "custom" attribute of a category in toolbox XML. + * This string indicates that the category should be dynamically populated with + * procedure blocks. + * @const {string} + * @alias Blockly.internalConstants.PROCEDURE_CATEGORY_NAME + */ + export const PROCEDURE_CATEGORY_NAME: "PROCEDURE"; + /** + * String for use in the dropdown created in field_variable. + * This string indicates that this option in the dropdown is 'Rename + * variable...' and if selected, should trigger the prompt to rename a variable. + * @const {string} + * @alias Blockly.internalConstants.RENAME_VARIABLE_ID + */ + export const RENAME_VARIABLE_ID: "RENAME_VARIABLE_ID"; + /** + * String for use in the dropdown created in field_variable. + * This string indicates that this option in the dropdown is 'Delete the "%1" + * variable' and if selected, should trigger the prompt to delete a variable. + * @const {string} + * @alias Blockly.internalConstants.DELETE_VARIABLE_ID + */ + export const DELETE_VARIABLE_ID: "DELETE_VARIABLE_ID"; +} +declare module "msg" { + export {}; +} +declare module "blocks" { + /** + * @license + * Copyright 2013 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview A mapping of block type names to block prototype objects. + */ + /** + * A mapping of block type names to block prototype objects. + * @namespace Blockly.blocks + */ + /** + * A mapping of block type names to block prototype objects. + * @type {!Object} + * @alias Blockly.blocks.Blocks + */ + export const Blocks: { + [x: string]: any; + }; +} +declare module "interfaces/i_deletable" { + /** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview The interface for an object that is deletable. + */ + /** + * The interface for an object that is deletable. + * @namespace Blockly.IDeletable + */ + /** + * The interface for an object that can be deleted. + * @interface + * @alias Blockly.IDeletable + */ + export class IDeletable { + } +} +declare module "interfaces/i_movable" { + /** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview The interface for an object that is movable. + */ + /** + * The interface for an object that is movable. + * @namespace Blockly.IMovable + */ + /** + * The interface for an object that is movable. + * @interface + * @alias Blockly.IMovable + */ + export class IMovable { + } +} +declare module "interfaces/i_selectable" { + /** + * The interface for an object that is selectable. + * @extends {IDeletable} + * @extends {IMovable} + * @interface + * @alias Blockly.ISelectable + */ + export class ISelectable { + /** + * @type {string} + */ + id: string; + } +} +declare module "dialog" { + /** + * Wrapper to window.alert() that app developers may override via setAlert to + * provide alternatives to the modal browser window. + * @param {string} message The message to display to the user. + * @param {function()=} opt_callback The callback when the alert is dismissed. + * @alias Blockly.dialog.alert + */ + export function alert(message: string, opt_callback?: (() => any) | undefined): void; + /** + * Sets the function to be run when Blockly.dialog.alert() is called. + * @param {!function(string, function()=)} alertFunction The function to be run. + * @see Blockly.dialog.alert + * @alias Blockly.dialog.setAlert + */ + export function setAlert(alertFunction: (arg0: string, arg1: (() => any) | undefined) => any): void; + /** + * Wrapper to window.confirm() that app developers may override via setConfirm + * to provide alternatives to the modal browser window. + * @param {string} message The message to display to the user. + * @param {!function(boolean)} callback The callback for handling user response. + * @alias Blockly.dialog.confirm + */ + export function confirm(message: string, callback: (arg0: boolean) => any): void; + /** + * Sets the function to be run when Blockly.dialog.confirm() is called. + * @param {!function(string, !function(boolean))} confirmFunction The function + * to be run. + * @see Blockly.dialog.confirm + * @alias Blockly.dialog.setConfirm + */ + export function setConfirm(confirmFunction: (arg0: string, arg1: (arg0: boolean) => any) => any): void; + /** + * Wrapper to window.prompt() that app developers may override via setPrompt to + * provide alternatives to the modal browser window. Built-in browser prompts + * are often used for better text input experience on mobile device. We strongly + * recommend testing mobile when overriding this. + * @param {string} message The message to display to the user. + * @param {string} defaultValue The value to initialize the prompt with. + * @param {!function(?string)} callback The callback for handling user response. + * @alias Blockly.dialog.prompt + */ + export function prompt(message: string, defaultValue: string, callback: (arg0: string | null) => any): void; + /** + * Sets the function to be run when Blockly.dialog.prompt() is called. + * @param {!function(string, string, !function(?string))} promptFunction The + * function to be run. + * @see Blockly.dialog.prompt + * @alias Blockly.dialog.setPrompt + */ + export function setPrompt(promptFunction: (arg0: string, arg1: string, arg2: (arg0: string | null) => any) => any): void; +} +declare module "utils/array" { + /** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview Utility methods related to arrays. + */ + /** + * @namespace Blockly.utils.array + */ + /** + * Removes the first occurrence of a particular value from an array. + * @param {!Array} arr Array from which to remove value. + * @param {*} value Value to remove. + * @return {boolean} True if an element was removed. + * @alias Blockly.array.removeElem + * @package + */ + export function removeElem(arr: any[], value: any): boolean; +} +declare module "utils/math" { + /** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview Utility methods for math. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. + */ + /** + * Utility methods for math. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. + * @namespace Blockly.utils.math + */ + /** + * Converts degrees to radians. + * Copied from Closure's goog.math.toRadians. + * @param {number} angleDegrees Angle in degrees. + * @return {number} Angle in radians. + * @alias Blockly.utils.math.toRadians + */ + export function toRadians(angleDegrees: number): number; + /** + * Converts radians to degrees. + * Copied from Closure's goog.math.toDegrees. + * @param {number} angleRadians Angle in radians. + * @return {number} Angle in degrees. + * @alias Blockly.utils.math.toDegrees + */ + export function toDegrees(angleRadians: number): number; + /** + * Clamp the provided number between the lower bound and the upper bound. + * @param {number} lowerBound The desired lower bound. + * @param {number} number The number to clamp. + * @param {number} upperBound The desired upper bound. + * @return {number} The clamped number. + * @alias Blockly.utils.math.clamp + */ + export function clamp(lowerBound: number, number: number, upperBound: number): number; +} +declare module "serialization/priorities" { + /** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview The top level namespace for priorities of plugin serializers. + * Includes constants for the priorities of different plugin + * serializers. Higher priorities are deserialized first. + */ + /** + * The top level namespace for priorities of plugin serializers. + * Includes constants for the priorities of different plugin serializers. Higher + * priorities are deserialized first. + * @namespace Blockly.serialization.priorities + */ + /** + * The priority for deserializing variables. + * @type {number} + * @const + * @alias Blockly.serialization.priorities.VARIABLES + */ + export const VARIABLES: number; + /** + * The priority for deserializing blocks. + * @type {number} + * @const + * @alias Blockly.serialization.priorities.BLOCKS + */ + export const BLOCKS: number; +} +declare module "interfaces/i_serializer" { + /** + * Serializes and deserializes a plugin or system. + * @interface + * @alias Blockly.serialization.ISerializer.ISerializer + */ + export class ISerializer { + /** + * A priority value used to determine the order of deserializing state. + * More positive priorities are deserialized before less positive + * priorities. Eg if you have priorities (0, -10, 10, 100) the order of + * deserialiation will be (100, 10, 0, -10). + * If two serializers have the same priority, they are deserialized in an + * arbitrary order relative to each other. + * @type {number} + */ + priority: number; + /** + * Saves the state of the plugin or system. + * @param {!Workspace} workspace The workspace the system to serialize is + * associated with. + * @return {?} A JS object containing the system's state, or null if + * there is no state to record. + */ + save(workspace: Workspace): unknown; + /** + * Loads the state of the plugin or system. + * @param {?} state The state of the system to deserialize. This will always + * be non-null. + * @param {!Workspace} workspace The workspace the system to deserialize is + * associated with. + */ + load(state: unknown, workspace: Workspace): void; + /** + * Clears the state of the plugin or system. + * @param {!Workspace} workspace The workspace the system to clear the state + * of is associated with. + */ + clear(workspace: Workspace): void; + } + import { Workspace } from "workspace"; +} +declare module "serialization/registry" { + /** + * Registers the given serializer so that it can be used for serialization and + * deserialization. + * @param {string} name The name of the serializer to register. + * @param {ISerializer} serializer The serializer to register. + * @alias Blockly.serialization.registry.register + */ + export function register(name: string, serializer: ISerializer): void; + /** + * Unregisters the serializer associated with the given name. + * @param {string} name The name of the serializer to unregister. + * @alias Blockly.serialization.registry.unregister + */ + export function unregister(name: string): void; + import { ISerializer } from "interfaces/i_serializer"; +} +declare module "serialization/exceptions" { + /** + * @alias Blockly.serialization.exceptions.DeserializationError + */ + export class DeserializationError extends Error { + } + /** + * Represents an error where the serialized state is expected to provide a + * block type, but it is not provided. + * @alias Blockly.serialization.exceptions.MissingBlockType + */ + export class MissingBlockType extends DeserializationError { + /** + * @param {!State} state The state object which is missing the block type. + * @package + */ + constructor(state: any); + /** + * The state object containing the bad name. + * @type {!State} + */ + state: any; + } + /** + * Represents an error where deserialization encountered a block that did + * not have a connection that was defined in the serialized state. + * @alias Blockly.serialization.exceptions.MissingConnection + */ + export class MissingConnection extends DeserializationError { + /** + * @param {string} connection The name of the connection that is missing. E.g. + * 'IF0', or 'next'. + * @param {!Block} block The block missing the connection. + * @param {!State} state The state object containing the bad connection. + * @package + */ + constructor(connection: string, block: Block, state: any); + /** + * The block missing the connection. + * @type {!Block} + */ + block: Block; + /** + * The state object containing the bad name. + * @type {!State} + */ + state: any; + } + /** + * Represents an error where deserialization tried to connect two connections + * that were not compatible. + * @alias Blockly.serialization.exceptions.BadConnectionCheck + */ + export class BadConnectionCheck extends DeserializationError { + /** + * @param {string} reason The reason the connections were not compatible. + * @param {string} childConnection The name of the incompatible child + * connection. E.g. 'output' or 'previous'. + * @param {!Block} childBlock The child block that could not connect + * to its parent. + * @param {!State} childState The state object representing the child block. + * @package + */ + constructor(reason: string, childConnection: string, childBlock: Block, childState: any); + /** + * The block that could not connect to its parent. + * @type {!Block} + */ + childBlock: Block; + /** + * The state object representing the block that could not connect to its + * parent. + * @type {!State} + */ + childState: any; + } + /** + * Represents an error where deserialization encountered a real block as it + * was deserializing children of a shadow. + * This is an error because it is an invariant of Blockly that shadow blocks + * do not have real children. + * @alias Blockly.serialization.exceptions.RealChildOfShadow + */ + export class RealChildOfShadow extends DeserializationError { + /** + * @param {!State} state The state object representing the real block. + * @package + */ + constructor(state: any); + /** + * The state object representing the real block. + * @type {!State} + */ + state: any; + } + import { Block } from "block"; +} +declare module "utils/size" { + /** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview Utility methods for size calculation. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. + */ + /** + * Utility methods for size calculation. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. + * @class + */ + /** + * Class for representing sizes consisting of a width and height. + * @param {number} width Width. + * @param {number} height Height. + * @struct + * @constructor + * @alias Blockly.utils.Size + */ + export class Size { + /** + * Compares sizes for equality. + * @param {?Size} a A Size. + * @param {?Size} b A Size. + * @return {boolean} True iff the sizes have equal widths and equal + * heights, or if both are null. + */ + static equals(a: Size | null, b: Size | null): boolean; + constructor(width: any, height: any); + /** + * Width + * @type {number} + */ + width: number; + /** + * Height + * @type {number} + */ + height: number; + } +} +declare module "input_types" { + /** + * * + */ + export type inputTypes = number; + export namespace inputTypes { + const VALUE: number; + const STATEMENT: number; + const DUMMY: number; + } +} +declare module "serialization/blocks" { + /** + * Represents the state of a connection. + */ + export type ConnectionState = { + shadow: (any | undefined); + block: (any | undefined); + }; + /** + * Represents the state of a connection. + * @typedef {{ + * shadow: (!State|undefined), + * block: (!State|undefined) + * }} + * @alias Blockly.serialization.blocks.ConnectionState + */ + export let ConnectionState: any; + /** + * Represents the state of a given block. + * @typedef {{ + * type: string, + * id: (string|undefined), + * x: (number|undefined), + * y: (number|undefined), + * collapsed: (boolean|undefined), + * enabled: (boolean|undefined), + * inline: (boolean|undefined), + * data: (string|undefined), + * extra-state: (*|undefined), + * icons: (!Object|undefined), + * fields: (!Object|undefined), + * inputs: (!Object|undefined), + * next: (!ConnectionState|undefined) + * }} + * @alias Blockly.serialization.blocks.State + */ + export let State: any; + /** + * Returns the state of the given block as a plain JavaScript object. + * @param {!Block} block The block to serialize. + * @param {{addCoordinates: (boolean|undefined), addInputBlocks: + * (boolean|undefined), addNextBlocks: (boolean|undefined), + * doFullSerialization: (boolean|undefined)}=} param1 + * addCoordinates: If true, the coordinates of the block are added to the + * serialized state. False by default. + * addinputBlocks: If true, children of the block which are connected to + * inputs will be serialized. True by default. + * addNextBlocks: If true, children of the block which are connected to the + * block's next connection (if it exists) will be serialized. + * True by default. + * doFullSerialization: If true, fields that normally just save a reference + * to some external state (eg variables) will instead serialize all of the + * info about that state. This supports deserializing the block into a + * workspace where that state doesn't yet exist. True by default. + * @return {?State} The serialized state of the block, or null if the block + * could not be serialied (eg it was an insertion marker). + * @alias Blockly.serialization.blocks.save + */ + export function save(block: Block, { addCoordinates, addInputBlocks, addNextBlocks, doFullSerialization, }?: { + addCoordinates: (boolean | undefined); + addInputBlocks: (boolean | undefined); + addNextBlocks: (boolean | undefined); + doFullSerialization: (boolean | undefined); + } | undefined): any | null; + /** + * Loads the block represented by the given state into the given workspace. + * @param {!State} state The state of a block to deserialize into the workspace. + * @param {!Workspace} workspace The workspace to add the block to. + * @param {{recordUndo: (boolean|undefined)}=} param1 + * recordUndo: If true, events triggered by this function will be undo-able + * by the user. False by default. + * @return {!Block} The block that was just loaded. + * @alias Blockly.serialization.blocks.append + */ + export function append(state: any, workspace: Workspace, { recordUndo }?: { + recordUndo: (boolean | undefined); + } | undefined): Block; + /** + * Loads the block represented by the given state into the given workspace. + * This is defined internally so that the extra parameters don't clutter our + * external API. + * But it is exported so that other places within Blockly can call it directly + * with the extra parameters. + * @param {!State} state The state of a block to deserialize into the workspace. + * @param {!Workspace} workspace The workspace to add the block to. + * @param {{parentConnection: (!Connection|undefined), isShadow: + * (boolean|undefined), recordUndo: (boolean|undefined)}=} param1 + * parentConnection: If provided, the system will attempt to connect the + * block to this connection after it is created. Undefined by default. + * isShadow: If true, the block will be set to a shadow block after it is + * created. False by default. + * recordUndo: If true, events triggered by this function will be undo-able + * by the user. False by default. + * @return {!Block} The block that was just appended. + * @alias Blockly.serialization.blocks.appendInternal + * @package + */ + export function appendInternal(state: any, workspace: Workspace, { parentConnection, isShadow, recordUndo, }?: { + parentConnection: (Connection | undefined); + isShadow: (boolean | undefined); + recordUndo: (boolean | undefined); + } | undefined): Block; + import { Block } from "block"; + import { Workspace } from "workspace"; + import { Connection } from "connection"; +} +declare module "utils/deprecation" { + /** + * @license + * Copyright 2020 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview Helper function for warning developers about deprecations. + * This method is not specific to Blockly. + */ + /** + * Helper function for warning developers about deprecations. + * This method is not specific to Blockly. + * @namespace Blockly.utils.deprecation + */ + /** + * Warn developers that a function or property is deprecated. + * @param {string} name The name of the function or property. + * @param {string} deprecationDate The date of deprecation. + * Prefer 'month yyyy' or 'quarter yyyy' format. + * @param {string} deletionDate The date of deletion, in the same format as the + * deprecation date. + * @param {string=} opt_use The name of a function or property to use instead, + * if any. + * @alias Blockly.utils.deprecation.warn + * @package + */ + export function warn(name: string, deprecationDate: string, deletionDate: string, opt_use?: string | undefined): void; +} +declare module "css" { + /** + * Add some CSS to the blob that will be injected later. Allows optional + * components such as fields and the toolbox to store separate CSS. + * @param {string|!Array} cssContent Multiline CSS string or an array of + * single lines of CSS. + * @alias Blockly.Css.register + */ + export function register(cssContent: string | Array): void; + /** + * Inject the CSS into the DOM. This is preferable over using a regular CSS + * file since: + * a) It loads synchronously and doesn't force a redraw later. + * b) It speeds up loading by not blocking on a separate HTTP transfer. + * c) The CSS content may be made dynamic depending on init options. + * @param {boolean} hasCss If false, don't inject CSS + * (providing CSS becomes the document's responsibility). + * @param {string} pathToMedia Path from page to the Blockly media directory. + * @alias Blockly.Css.inject + */ + export function inject(hasCss: boolean, pathToMedia: string): void; + /** + * The CSS content for Blockly. + * @alias Blockly.Css.content + */ + export let content: string; +} +declare module "utils/aria" { + /** + * * + */ + export type Role = string; + export namespace Role { + const GRID: string; + const GRIDCELL: string; + const GROUP: string; + const LISTBOX: string; + const MENU: string; + const MENUITEM: string; + const MENUITEMCHECKBOX: string; + const OPTION: string; + const PRESENTATION: string; + const ROW: string; + const TREE: string; + const TREEITEM: string; + } + /** + * * + */ + export type State = string; + export namespace State { + const ACTIVEDESCENDANT: string; + const COLCOUNT: string; + const DISABLED: string; + const EXPANDED: string; + const INVALID: string; + const LABEL: string; + const LABELLEDBY: string; + const LEVEL: string; + const ORIENTATION: string; + const POSINSET: string; + const ROWCOUNT: string; + const SELECTED: string; + const SETSIZE: string; + const VALUEMAX: string; + const VALUEMIN: string; + } + /** + * Sets the role of an element. + * + * Similar to Closure's goog.a11y.aria + * + * @param {!Element} element DOM node to set role of. + * @param {!Role} roleName Role name. + * @alias Blockly.utils.aria.setRole + */ + export function setRole(element: Element, roleName: Role): void; + /** + * Sets the state or property of an element. + * Copied from Closure's goog.a11y.aria + * @param {!Element} element DOM node where we set state. + * @param {!State} stateName State attribute being set. + * Automatically adds prefix 'aria-' to the state name if the attribute is + * not an extra attribute. + * @param {string|boolean|number|!Array} value Value + * for the state attribute. + * @alias Blockly.utils.aria.setState + */ + export function setState(element: Element, stateName: State, value: string | boolean | number | Array): void; +} +declare module "utils/colour" { + /** + * Parses a colour from a string. + * .parse('red') -> '#ff0000' + * .parse('#f00') -> '#ff0000' + * .parse('#ff0000') -> '#ff0000' + * .parse('0xff0000') -> '#ff0000' + * .parse('rgb(255, 0, 0)') -> '#ff0000' + * @param {string|number} str Colour in some CSS format. + * @return {?string} A string containing a hex representation of the colour, + * or null if can't be parsed. + * @alias Blockly.utils.colour.parse + */ + export function parse(str: string | number): string | null; + /** + * Converts a colour from RGB to hex representation. + * @param {number} r Amount of red, int between 0 and 255. + * @param {number} g Amount of green, int between 0 and 255. + * @param {number} b Amount of blue, int between 0 and 255. + * @return {string} Hex representation of the colour. + * @alias Blockly.utils.colour.rgbToHex + */ + export function rgbToHex(r: number, g: number, b: number): string; + /** + * Converts a colour to RGB. + * @param {string} colour String representing colour in any + * colour format ('#ff0000', 'red', '0xff000', etc). + * @return {!Array} RGB representation of the colour. + * @alias Blockly.utils.colour.hexToRgb + */ + export function hexToRgb(colour: string): Array; + /** + * Converts an HSV triplet to hex representation. + * @param {number} h Hue value in [0, 360]. + * @param {number} s Saturation value in [0, 1]. + * @param {number} v Brightness in [0, 255]. + * @return {string} Hex representation of the colour. + * @alias Blockly.utils.colour.hsvToHex + */ + export function hsvToHex(h: number, s: number, v: number): string; + /** + * Blend two colours together, using the specified factor to indicate the + * weight given to the first colour. + * @param {string} colour1 First colour. + * @param {string} colour2 Second colour. + * @param {number} factor The weight to be given to colour1 over colour2. + * Values should be in the range [0, 1]. + * @return {?string} Combined colour represented in hex. + * @alias Blockly.utils.colour.blend + */ + export function blend(colour1: string, colour2: string, factor: number): string | null; + /** + * A map that contains the 16 basic colour keywords as defined by W3C: + * https://www.w3.org/TR/2018/REC-css-color-3-20180619/#html4 + * The keys of this map are the lowercase "readable" names of the colours, + * while the values are the "hex" values. + * + * @type {!Object} + * @alias Blockly.utils.colour.names + */ + export const names: { + [x: string]: string; + }; + /** + * Convert a hue (HSV model) into an RGB hex triplet. + * @param {number} hue Hue on a colour wheel (0-360). + * @return {string} RGB code, e.g. '#5ba65b'. + * @alias Blockly.utils.colour.hueToHex + */ + export function hueToHex(hue: number): string; +} +declare module "utils/parsing" { + /** + * Parse a string with any number of interpolation tokens (%1, %2, ...). + * It will also replace string table references (e.g., %{bky_my_msg} and + * %{BKY_MY_MSG} will both be replaced with the value in + * Msg['MY_MSG']). Percentage sign characters '%' may be self-escaped + * (e.g., '%%'). + * @param {string} message Text which might contain string table references and + * interpolation tokens. + * @return {!Array} Array of strings and numbers. + * @alias Blockly.parsing.tokenizeInterpolation + */ + export function tokenizeInterpolation(message: string): Array; + /** + * Replaces string table references in a message, if the message is a string. + * For example, "%{bky_my_msg}" and "%{BKY_MY_MSG}" will both be replaced with + * the value in Msg['MY_MSG']. + * @param {string|?} message Message, which may be a string that contains + * string table references. + * @return {string} String with message references replaced. + * @alias Blockly.parsing.replaceMessageReferences + */ + export function replaceMessageReferences(message: string | unknown): string; + /** + * Validates that any %{MSG_KEY} references in the message refer to keys of + * the Msg string table. + * @param {string} message Text which might contain string table references. + * @return {boolean} True if all message references have matching values. + * Otherwise, false. + * @alias Blockly.parsing.checkMessageReferences + */ + export function checkMessageReferences(message: string): boolean; + /** + * Parse a block colour from a number or string, as provided in a block + * definition. + * @param {number|string} colour HSV hue value (0 to 360), #RRGGBB string, + * or a message reference string pointing to one of those two values. + * @return {{hue: ?number, hex: string}} An object containing the colour as + * a #RRGGBB string, and the hue if the input was an HSV hue value. + * @throws {Error} If the colour cannot be parsed. + * @alias Blockly.parsing.parseBlockColour + */ + export function parseBlockColour(colour: number | string): { + hue: number | null; + hex: string; + }; +} +declare module "interfaces/i_toolbox_item" { + /** + * @license + * Copyright 2020 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview The interface for a toolbox item. + */ + /** + * The interface for a toolbox item. + * @namespace Blockly.IToolboxItem + */ + /** + * Interface for an item in the toolbox. + * @interface + * @alias Blockly.IToolboxItem + */ + export class IToolboxItem { + } +} +declare module "interfaces/i_selectable_toolbox_item" { + /** + * Interface for an item in the toolbox that can be selected. + * @extends {IToolboxItem} + * @interface + * @alias Blockly.ISelectableToolboxItem + */ + export class ISelectableToolboxItem { + } +} +declare module "interfaces/i_collapsible_toolbox_item" { + /** + * Interface for an item in the toolbox that can be collapsed. + * @extends {ISelectableToolboxItem} + * @interface + * @alias Blockly.ICollapsibleToolboxItem + */ + export class ICollapsibleToolboxItem { + } +} +declare module "utils/coordinate" { + /** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview Utility methods for coordinate manipulation. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. + */ + /** + * Utility methods for coordinate manipulation. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. + * @class + */ + /** + * Class for representing coordinates and positions. + * @param {number} x Left. + * @param {number} y Top. + * @struct + * @constructor + * @alias Blockly.utils.Coordinate + */ + export class Coordinate { + /** + * Compares coordinates for equality. + * @param {?Coordinate} a A Coordinate. + * @param {?Coordinate} b A Coordinate. + * @return {boolean} True iff the coordinates are equal, or if both are null. + */ + static equals(a: Coordinate | null, b: Coordinate | null): boolean; + /** + * Returns the distance between two coordinates. + * @param {!Coordinate} a A Coordinate. + * @param {!Coordinate} b A Coordinate. + * @return {number} The distance between `a` and `b`. + */ + static distance(a: Coordinate, b: Coordinate): number; + /** + * Returns the magnitude of a coordinate. + * @param {!Coordinate} a A Coordinate. + * @return {number} The distance between the origin and `a`. + */ + static magnitude(a: Coordinate): number; + /** + * Returns the difference between two coordinates as a new + * Coordinate. + * @param {!Coordinate|!SVGPoint} a An x/y coordinate. + * @param {!Coordinate|!SVGPoint} b An x/y coordinate. + * @return {!Coordinate} A Coordinate representing the difference + * between `a` and `b`. + */ + static difference(a: Coordinate | SVGPoint, b: Coordinate | SVGPoint): Coordinate; + /** + * Returns the sum of two coordinates as a new Coordinate. + * @param {!Coordinate|!SVGPoint} a An x/y coordinate. + * @param {!Coordinate|!SVGPoint} b An x/y coordinate. + * @return {!Coordinate} A Coordinate representing the sum of + * the two coordinates. + */ + static sum(a: Coordinate | SVGPoint, b: Coordinate | SVGPoint): Coordinate; + constructor(x: any, y: any); + /** + * X-value + * @type {number} + */ + x: number; + /** + * Y-value + * @type {number} + */ + y: number; + /** + * Creates a new copy of this coordinate. + * @return {!Coordinate} A copy of this coordinate. + */ + clone(): Coordinate; + /** + * Scales this coordinate by the given scale factor. + * @param {number} s The scale factor to use for both x and y dimensions. + * @return {!Coordinate} This coordinate after scaling. + */ + scale(s: number): Coordinate; + /** + * Translates this coordinate by the given offsets. + * respectively. + * @param {number} tx The value to translate x by. + * @param {number} ty The value to translate y by. + * @return {!Coordinate} This coordinate after translating. + */ + translate(tx: number, ty: number): Coordinate; + } +} +declare module "interfaces/i_registrable" { + /** + * @license + * Copyright 2020 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview The interface for a Blockly component that can be registered. + * (Ex. Toolbox, Fields, Renderers) + */ + /** + * The interface for a Blockly component that can be registered. + * (Ex. Toolbox, Fields, Renderers) + * @namespace Blockly.IRegistrable + */ + /** + * The interface for a Blockly component that can be registered. + * @interface + * @alias Blockly.IRegistrable + */ + export class IRegistrable { + } +} +declare module "interfaces/i_flyout" { + /** + * Interface for a flyout. + * @extends {IRegistrable} + * @interface + * @alias Blockly.IFlyout + */ + export class IFlyout { + /** + * Whether the flyout is laid out horizontally or not. + * @type {boolean} + */ + horizontalLayout: boolean; + /** + * Is RTL vs LTR. + * @type {boolean} + */ + RTL: boolean; + /** + * The target workspace + * @type {?WorkspaceSvg} + */ + targetWorkspace: WorkspaceSvg | null; + /** + * Margin around the edges of the blocks in the flyout. + * @type {number} + * @const + */ + MARGIN: number; + /** + * Does the flyout automatically close when a block is created? + * @type {boolean} + */ + autoClose: boolean; + /** + * Corner radius of the flyout background. + * @type {number} + * @const + */ + CORNER_RADIUS: number; + } + import { WorkspaceSvg } from "workspace_svg"; +} +declare module "interfaces/i_toolbox" { + /** + * Interface for a toolbox. + * @extends {IRegistrable} + * @interface + * @alias Blockly.IToolbox + */ + export class IToolbox { + } +} +declare module "toolbox/toolbox_item" { + /** + * Class for an item in the toolbox. + * @param {!toolbox.ToolboxItemInfo} toolboxItemDef The JSON defining the + * toolbox item. + * @param {!IToolbox} toolbox The toolbox that holds the toolbox item. + * @param {ICollapsibleToolboxItem=} opt_parent The parent toolbox item + * or null if the category does not have a parent. + * @constructor + * @implements {IToolboxItem} + * @alias Blockly.ToolboxItem + */ + export class ToolboxItem implements IToolboxItem { + constructor(toolboxItemDef: any, toolbox: any, opt_parent: any); + /** + * The id for the category. + * @type {string} + * @protected + */ + protected id_: string; + /** + * The parent of the category. + * @type {?ICollapsibleToolboxItem} + * @protected + */ + protected parent_: ICollapsibleToolboxItem | null; + /** + * The level that the category is nested at. + * @type {number} + * @protected + */ + protected level_: number; + /** + * The JSON definition of the toolbox item. + * @type {!toolbox.ToolboxItemInfo} + * @protected + */ + protected toolboxItemDef_: any; + /** + * The toolbox this category belongs to. + * @type {!IToolbox} + * @protected + */ + protected parentToolbox_: IToolbox; + /** + * The workspace of the parent toolbox. + * @type {!WorkspaceSvg} + * @protected + */ + protected workspace_: WorkspaceSvg; + /** + * Initializes the toolbox item. + * This includes creating the DOM and updating the state of any items based + * on the info object. + * @public + */ + public init(): void; + /** + * Gets the div for the toolbox item. + * @return {?Element} The div for the toolbox item. + * @public + */ + public getDiv(): Element | null; + /** + * Gets a unique identifier for this toolbox item. + * @return {string} The ID for the toolbox item. + * @public + */ + public getId(): string; + /** + * Gets the parent if the toolbox item is nested. + * @return {?IToolboxItem} The parent toolbox item, or null if + * this toolbox item is not nested. + * @public + */ + public getParent(): IToolboxItem | null; + /** + * Gets the nested level of the category. + * @return {number} The nested level of the category. + * @package + */ + getLevel(): number; + /** + * Whether the toolbox item is selectable. + * @return {boolean} True if the toolbox item can be selected. + * @public + */ + public isSelectable(): boolean; + /** + * Whether the toolbox item is collapsible. + * @return {boolean} True if the toolbox item is collapsible. + * @public + */ + public isCollapsible(): boolean; + /** + * Dispose of this toolbox item. No-op by default. + * @public + */ + public dispose(): void; + } + import { IToolboxItem } from "interfaces/i_toolbox_item"; + import { ICollapsibleToolboxItem } from "interfaces/i_collapsible_toolbox_item"; + import { IToolbox } from "interfaces/i_toolbox"; + import { WorkspaceSvg } from "workspace_svg"; +} +declare module "toolbox/category" { + import { ToolboxItem } from "toolbox/toolbox_item"; + export class ToolboxCategory extends ToolboxItem { + /** + * Class for a category in a toolbox. + * @param {!toolbox.CategoryInfo} categoryDef The information needed + * to create a category in the toolbox. + * @param {!IToolbox} toolbox The parent toolbox for the category. + * @param {ICollapsibleToolboxItem=} opt_parent The parent category or null if + * the category does not have a parent. + * @constructor + * @extends {ToolboxItem} + * @implements {ISelectableToolboxItem} + * @alias Blockly.ToolboxCategory + */ + constructor(categoryDef: toolbox.CategoryInfo, toolbox: IToolbox, opt_parent?: ICollapsibleToolboxItem | undefined); + /** + * The name that will be displayed on the category. + * @type {string} + * @protected + */ + protected name_: string; + /** + * The colour of the category. + * @type {string} + * @protected + */ + protected colour_: string; + /** + * The html container for the category. + * @type {?Element} + * @protected + */ + protected htmlDiv_: Element | null; + /** + * The html element for the category row. + * @type {?Element} + * @protected + */ + protected rowDiv_: Element | null; + /** + * The html element that holds children elements of the category row. + * @type {?Element} + * @protected + */ + protected rowContents_: Element | null; + /** + * The html element for the toolbox icon. + * @type {?Element} + * @protected + */ + protected iconDom_: Element | null; + /** + * The html element for the toolbox label. + * @type {?Element} + * @protected + */ + protected labelDom_: Element | null; + /** + * All the css class names that are used to create a category. + * @type {!ToolboxCategory.CssConfig} + * @protected + */ + protected cssConfig_: ToolboxCategory.CssConfig; + /** + * True if the category is meant to be hidden, false otherwise. + * @type {boolean} + * @protected + */ + protected isHidden_: boolean; + /** + * True if this category is disabled, false otherwise. + * @type {boolean} + * @protected + */ + protected isDisabled_: boolean; + /** + * The flyout items for this category. + * @type {string|!toolbox.FlyoutItemInfoArray} + * @protected + */ + protected flyoutItems_: string | toolbox.FlyoutItemInfoArray; + /** + * Creates an object holding the default classes for a category. + * @return {!ToolboxCategory.CssConfig} The configuration object holding + * all the CSS classes for a category. + * @protected + */ + protected makeDefaultCssConfig_(): ToolboxCategory.CssConfig; + /** + * Parses the contents array depending on if the category is a dynamic category, + * or if its contents are meant to be shown in the flyout. + * @param {!toolbox.CategoryInfo} categoryDef The information needed + * to create a category. + * @protected + */ + protected parseContents_(categoryDef: toolbox.CategoryInfo): void; + /** + * @override + */ + override init(): void; + /** + * Creates the DOM for the category. + * @return {!Element} The parent element for the category. + * @protected + */ + protected createDom_(): Element; + /** + * Creates the container that holds the row and any subcategories. + * @return {!Element} The div that holds the icon and the label. + * @protected + */ + protected createContainer_(): Element; + /** + * Creates the parent of the contents container. All clicks will happen on this + * div. + * @return {!Element} The div that holds the contents container. + * @protected + */ + protected createRowContainer_(): Element; + /** + * Creates the container for the label and icon. + * This is necessary so we can set all subcategory pointer events to none. + * @return {!Element} The div that holds the icon and the label. + * @protected + */ + protected createRowContentsContainer_(): Element; + /** + * Creates the span that holds the category icon. + * @return {!Element} The span that holds the category icon. + * @protected + */ + protected createIconDom_(): Element; + /** + * Creates the span that holds the category label. + * This should have an ID for accessibility purposes. + * @param {string} name The name of the category. + * @return {!Element} The span that holds the category label. + * @protected + */ + protected createLabelDom_(name: string): Element; + /** + * Updates the colour for this category. + * @public + */ + public refreshTheme(): void; + /** + * Add the strip of colour to the toolbox category. + * @param {string} colour The category colour. + * @protected + */ + protected addColourBorder_(colour: string): void; + /** + * Gets either the colour or the style for a category. + * @param {!toolbox.CategoryInfo} categoryDef The object holding + * information on the category. + * @return {string} The hex colour for the category. + * @protected + */ + protected getColour_(categoryDef: toolbox.CategoryInfo): string; + /** + * Sets the colour for the category using the style name and returns the new + * colour as a hex string. + * @param {string} styleName Name of the style. + * @return {string} The hex colour for the category. + * @private + */ + private getColourfromStyle_; + /** + * Gets the HTML element that is clickable. + * The parent toolbox element receives clicks. The parent toolbox will add an ID + * to this element so it can pass the onClick event to the correct toolboxItem. + * @return {!Element} The HTML element that receives clicks. + * @public + */ + public getClickTarget(): Element; + /** + * Parses the colour on the category. + * @param {number|string} colourValue HSV hue value (0 to 360), #RRGGBB string, + * or a message reference string pointing to one of those two values. + * @return {string} The hex colour for the category. + * @private + */ + private parseColour_; + /** + * Adds appropriate classes to display an open icon. + * @param {?Element} iconDiv The div that holds the icon. + * @protected + */ + protected openIcon_(iconDiv: Element | null): void; + /** + * Adds appropriate classes to display a closed icon. + * @param {?Element} iconDiv The div that holds the icon. + * @protected + */ + protected closeIcon_(iconDiv: Element | null): void; + /** + * Sets whether the category is visible or not. + * For a category to be visible its parent category must also be expanded. + * @param {boolean} isVisible True if category should be visible. + * @protected + */ + protected setVisible_(isVisible: boolean): void; + /** + * Hide the category. + */ + hide(): void; + /** + * Show the category. Category will only appear if its parent category is also + * expanded. + */ + show(): void; + /** + * Whether the category is visible. + * A category is only visible if all of its ancestors are expanded and isHidden_ + * is false. + * @return {boolean} True if the category is visible, false otherwise. + * @public + */ + public isVisible(): boolean; + /** + * Whether all ancestors of a category (parent and parent's parent, etc.) are + * expanded. + * @return {boolean} True only if every ancestor is expanded + * @protected + */ + protected allAncestorsExpanded_(): boolean; + /** + * @override + */ + override isSelectable(): boolean; + /** + * Handles when the toolbox item is clicked. + * @param {!Event} _e Click event to handle. + * @public + */ + public onClick(_e: Event): void; + /** + * Sets the current category as selected. + * @param {boolean} isSelected True if this category is selected, false + * otherwise. + * @public + */ + public setSelected(isSelected: boolean): void; + /** + * Sets whether the category is disabled. + * @param {boolean} isDisabled True to disable the category, false otherwise. + */ + setDisabled(isDisabled: boolean): void; + /** + * Gets the name of the category. Used for emitting events. + * @return {string} The name of the toolbox item. + * @public + */ + public getName(): string; + /** + * @override + */ + override getParent(): any; + /** + * @override + */ + override getDiv(): Element; + /** + * Gets the contents of the category. These are items that are meant to be + * displayed in the flyout. + * @return {!toolbox.FlyoutItemInfoArray|string} The definition + * of items to be displayed in the flyout. + * @public + */ + public getContents(): any | string; + /** + * Updates the contents to be displayed in the flyout. + * If the flyout is open when the contents are updated, refreshSelection on the + * toolbox must also be called. + * @param {!toolbox.FlyoutDefinition|string} contents The contents + * to be displayed in the flyout. A string can be supplied to create a + * dynamic category. + * @public + */ + public updateFlyoutContents(contents: toolbox.FlyoutDefinition | string): void; + /** + * @override + */ + override dispose(): void; + } + export namespace ToolboxCategory { + const registrationName: string; + const nestedPadding: number; + const borderWidth: number; + const defaultBackgroundColour: string; + /** + * All the CSS class names that are used to create a category. + */ + type CssConfig = { + container: (string | undefined); + row: (string | undefined); + rowcontentcontainer: (string | undefined); + icon: (string | undefined); + label: (string | undefined); + selected: (string | undefined); + openicon: (string | undefined); + closedicon: (string | undefined); + }; + } + import * as toolbox from "utils/toolbox"; + import { IToolbox } from "interfaces/i_toolbox"; + import { ICollapsibleToolboxItem } from "interfaces/i_collapsible_toolbox_item"; +} +declare module "toolbox/separator" { + import { ToolboxItem } from "toolbox/toolbox_item"; + /** + * Class for a toolbox separator. This is the thin visual line that appears on + * the toolbox. This item is not interactable. + * @param {!toolbox.SeparatorInfo} separatorDef The information + * needed to create a separator. + * @param {!IToolbox} toolbox The parent toolbox for the separator. + * @constructor + * @extends {ToolboxItem} + * @alias Blockly.ToolboxSeparator + */ + export class ToolboxSeparator extends ToolboxItem { + constructor(separatorDef: any, toolbox: any); + /** + * All the CSS class names that are used to create a separator. + * @type {!ToolboxSeparator.CssConfig} + * @protected + */ + protected cssConfig_: ToolboxSeparator.CssConfig; + /** + * @override + */ + override init(): void; + /** + * Creates the DOM for a separator. + * @return {!Element} The parent element for the separator. + * @protected + */ + protected createDom_(): Element; + htmlDiv_: HTMLDivElement; + /** + * @override + */ + override getDiv(): HTMLDivElement; + /** + * @override + */ + override dispose(): void; + } + export namespace ToolboxSeparator { + const registrationName: string; + /** + * All the CSS class names that are used to create a separator. + */ + type CssConfig = { + container: (string | undefined); + }; + } +} +declare module "utils/toolbox" { +/** + * The information needed to create a block in the toolbox. + * Note that disabled has a different type for backwards compatibility. + * @typedef {{ + * kind:string, + * blockxml:(string|!Node|undefined), + * type:(string|undefined), + * gap:(string|number|undefined), + * disabled: (string|boolean|undefined), + * enabled: (boolean|undefined), + * id: (string|undefined), + * x: (number|undefined), + * y: (number|undefined), + * collapsed: (boolean|undefined), + * inline: (boolean|undefined), + * data: (string|undefined), + * extra-state: (*|undefined), + * icons: (!Object|undefined), + * fields: (!Object|undefined), + * inputs: (!Object|undefined), + * next: (!ConnectionState|undefined) + * }} + * @alias Blockly.utils.toolbox.BlockInfo + */ +export type BlockInfo = any; + /** + * An array holding flyout items. + * @typedef { + * Array + * } + * @alias Blockly.utils.toolbox.FlyoutItemInfoArray + */ + export type FlyoutItemInfoArray = any; /** - * @typedef {{ - * text:?string, - * pinned:boolean, - * size:Size - * }} + * The information needed to create a separator in the toolbox. */ - interface CommentModel { + export type SeparatorInfo = { + kind: string; + id: (string | undefined); + gap: (number | undefined); + cssconfig: (ToolboxSeparator.CssConfig | undefined); + }; + /** + * The information needed to create a separator in the toolbox. + * @typedef {{ + * kind:string, + * id:(string|undefined), + * gap:(number|undefined), + * cssconfig:(!ToolboxSeparator.CssConfig|undefined) + * }} + * @alias Blockly.utils.toolbox.SeparatorInfo + */ + export let SeparatorInfo: any; + /** + * The information needed to create a button in the toolbox. + */ + export type ButtonInfo = { + kind: string; text: string; - pinned: boolean; - size: Size + callbackkey: string; + }; + /** + * The information needed to create a button in the toolbox. + * @typedef {{ + * kind:string, + * text:string, + * callbackkey:string + * }} + * @alias Blockly.utils.toolbox.ButtonInfo + */ + export let ButtonInfo: any; + /** + * The information needed to create a label in the toolbox. + */ + export type LabelInfo = { + kind: string; + text: string; + id: (string | undefined); + }; + /** + * The information needed to create a label in the toolbox. + * @typedef {{ + * kind:string, + * text:string, + * id:(string|undefined) + * }} + * @alias Blockly.utils.toolbox.LabelInfo + */ + export let LabelInfo: any; + /** + * The information needed to create either a button or a label in the flyout. + */ + export type ButtonOrLabelInfo = ButtonInfo | LabelInfo; + /** + * The information needed to create either a button or a label in the flyout. + * @typedef {ButtonInfo| + * LabelInfo} + * @alias Blockly.utils.toolbox.ButtonOrLabelInfo + */ + export let ButtonOrLabelInfo: any; + /** + * The information needed to create a category in the toolbox. + */ + export type StaticCategoryInfo = { + kind: string; + name: string; + contents: Array; + id: (string | undefined); + categorystyle: (string | undefined); + colour: (string | undefined); + cssconfig: (ToolboxCategory.CssConfig | undefined); + hidden: (string | undefined); + }; + /** + * The information needed to create a category in the toolbox. + * @typedef {{ + * kind:string, + * name:string, + * contents:!Array, + * id:(string|undefined), + * categorystyle:(string|undefined), + * colour:(string|undefined), + * cssconfig:(!ToolboxCategory.CssConfig|undefined), + * hidden:(string|undefined) + * }} + * @alias Blockly.utils.toolbox.StaticCategoryInfo + */ + export let StaticCategoryInfo: any; + /** + * The information needed to create a custom category. + */ + export type DynamicCategoryInfo = { + kind: string; + custom: string; + id: (string | undefined); + categorystyle: (string | undefined); + colour: (string | undefined); + cssconfig: (ToolboxCategory.CssConfig | undefined); + hidden: (string | undefined); + }; + /** + * The information needed to create a custom category. + * @typedef {{ + * kind:string, + * custom:string, + * id:(string|undefined), + * categorystyle:(string|undefined), + * colour:(string|undefined), + * cssconfig:(!ToolboxCategory.CssConfig|undefined), + * hidden:(string|undefined) + * }} + * @alias Blockly.utils.toolbox.DynamicCategoryInfo + */ + export let DynamicCategoryInfo: any; + /** + * The information needed to create either a dynamic or static category. + */ + export type CategoryInfo = StaticCategoryInfo | DynamicCategoryInfo; + /** + * The information needed to create either a dynamic or static category. + * @typedef {StaticCategoryInfo| + * DynamicCategoryInfo} + * @alias Blockly.utils.toolbox.CategoryInfo + */ + export let CategoryInfo: any; + /** + * Any information that can be used to create an item in the toolbox. + */ + export type ToolboxItemInfo = FlyoutItemInfo | StaticCategoryInfo; + /** + * Any information that can be used to create an item in the toolbox. + * @typedef {FlyoutItemInfo| + * StaticCategoryInfo} + * @alias Blockly.utils.toolbox.ToolboxItemInfo + */ + export let ToolboxItemInfo: any; + /** + * All the different types that can be displayed in a flyout. + */ + export type FlyoutItemInfo = any | SeparatorInfo | ButtonInfo | LabelInfo | DynamicCategoryInfo; + /** + * All the different types that can be displayed in a flyout. + * @typedef {BlockInfo| + * SeparatorInfo| + * ButtonInfo| + * LabelInfo| + * DynamicCategoryInfo} + * @alias Blockly.utils.toolbox.FlyoutItemInfo + */ + export let FlyoutItemInfo: any; + /** + * The JSON definition of a toolbox. + */ + export type ToolboxInfo = { + kind: (string | undefined); + contents: Array; + }; + /** + * The JSON definition of a toolbox. + * @typedef {{ + * kind:(string|undefined), + * contents:!Array + * }} + * @alias Blockly.utils.toolbox.ToolboxInfo + */ + export let ToolboxInfo: any; + /** + * An array holding flyout items. + * @typedef { + * Array + * } + * @alias Blockly.utils.toolbox.FlyoutItemInfoArray + */ + export let FlyoutItemInfoArray: any; + /** + * All of the different types that can create a toolbox. + */ + export type ToolboxDefinition = Node | ToolboxInfo | string; + /** + * All of the different types that can create a toolbox. + * @typedef {Node| + * ToolboxInfo| + * string} + * @alias Blockly.utils.toolbox.ToolboxDefinition + */ + export let ToolboxDefinition: any; + /** + * All of the different types that can be used to show items in a flyout. + */ + export type FlyoutDefinition = any | NodeList | ToolboxInfo | Array; + /** + * All of the different types that can be used to show items in a flyout. + * @typedef {FlyoutItemInfoArray| + * NodeList| + * ToolboxInfo| + * Array} + * @alias Blockly.utils.toolbox.FlyoutDefinition + */ + export let FlyoutDefinition: any; + /** + * * + */ + export type Position = number; + export namespace Position { + const TOP: number; + const BOTTOM: number; + const LEFT: number; + const RIGHT: number; + } + /** + * Converts the toolbox definition into toolbox JSON. + * @param {?ToolboxDefinition} toolboxDef The definition + * of the toolbox in one of its many forms. + * @return {?ToolboxInfo} Object holding information + * for creating a toolbox. + * @alias Blockly.utils.toolbox.convertToolboxDefToJson + * @package + */ + export function convertToolboxDefToJson(toolboxDef: ToolboxDefinition | null): ToolboxInfo | null; + /** + * Converts the flyout definition into a list of flyout items. + * @param {?FlyoutDefinition} flyoutDef The definition of + * the flyout in one of its many forms. + * @return {!FlyoutItemInfoArray} A list of flyout items. + * @alias Blockly.utils.toolbox.convertFlyoutDefToJsonArray + * @package + */ + export function convertFlyoutDefToJsonArray(flyoutDef: FlyoutDefinition | null): any; + /** + * Whether or not the toolbox definition has categories. + * @param {?ToolboxInfo} toolboxJson Object holding + * information for creating a toolbox. + * @return {boolean} True if the toolbox has categories. + * @alias Blockly.utils.toolbox.hasCategories + * @package + */ + export function hasCategories(toolboxJson: ToolboxInfo | null): boolean; + /** + * Whether or not the category is collapsible. + * @param {!CategoryInfo} categoryInfo Object holing + * information for creating a category. + * @return {boolean} True if the category has subcategories. + * @alias Blockly.utils.toolbox.isCategoryCollapsible + * @package + */ + export function isCategoryCollapsible(categoryInfo: CategoryInfo): boolean; + /** + * Parse the provided toolbox tree into a consistent DOM format. + * @param {?Node|?string} toolboxDef DOM tree of blocks, or text representation + * of same. + * @return {?Node} DOM tree of blocks, or null. + * @alias Blockly.utils.toolbox.parseToolboxTree + */ + export function parseToolboxTree(toolboxDef: (Node | (string | null)) | null): Node | null; + import { ToolboxSeparator } from "toolbox/separator"; + import { ToolboxCategory } from "toolbox/category"; +} +declare module "blockly_options" { + /** + * @license + * Copyright 2016 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview Object that defines user-specified options for the workspace. + */ + /** + * Object that defines user-specified options for the workspace. + * @namespace Blockly.BlocklyOptions + */ + /** + * Blockly options. + * This interface is further described in + * `typings/parts/blockly-interfaces.d.ts`. + * @interface + * @alias Blockly.BlocklyOptions + */ + export class BlocklyOptions { + } +} +declare module "utils/svg_paths" { + /** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview Methods for creating parts of SVG path strings. See + * developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths + */ + /** + * Methods for creating parts of SVG path strings. See + * @namespace Blockly.utils.svgPaths + */ + /** + * Create a string representing the given x, y pair. It does not matter whether + * the coordinate is relative or absolute. The result has leading + * and trailing spaces, and separates the x and y coordinates with a comma but + * no space. + * @param {number} x The x coordinate. + * @param {number} y The y coordinate. + * @return {string} A string of the format ' x,y ' + * @alias Blockly.utils.svgPaths.point + */ + export function point(x: number, y: number): string; + /** + * Draw a cubic or quadratic curve. See + * developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#Cubic_B%C3%A9zier_Curve + * These coordinates are unitless and hence in the user coordinate system. + * @param {string} command The command to use. + * Should be one of: c, C, s, S, q, Q. + * @param {!Array} points An array containing all of the points to pass + * to the curve command, in order. The points are represented as strings of + * the format ' x, y '. + * @return {string} A string defining one or more Bezier curves. See the MDN + * documentation for exact format. + * @alias Blockly.utils.svgPaths.curve + */ + export function curve(command: string, points: Array): string; + /** + * Move the cursor to the given position without drawing a line. + * The coordinates are absolute. + * These coordinates are unitless and hence in the user coordinate system. + * See developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#Line_commands + * @param {number} x The absolute x coordinate. + * @param {number} y The absolute y coordinate. + * @return {string} A string of the format ' M x,y ' + * @alias Blockly.utils.svgPaths.moveTo + */ + export function moveTo(x: number, y: number): string; + /** + * Move the cursor to the given position without drawing a line. + * Coordinates are relative. + * These coordinates are unitless and hence in the user coordinate system. + * See developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#Line_commands + * @param {number} dx The relative x coordinate. + * @param {number} dy The relative y coordinate. + * @return {string} A string of the format ' m dx,dy ' + * @alias Blockly.utils.svgPaths.moveBy + */ + export function moveBy(dx: number, dy: number): string; + /** + * Draw a line from the current point to the end point, which is the current + * point shifted by dx along the x-axis and dy along the y-axis. + * These coordinates are unitless and hence in the user coordinate system. + * See developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#Line_commands + * @param {number} dx The relative x coordinate. + * @param {number} dy The relative y coordinate. + * @return {string} A string of the format ' l dx,dy ' + * @alias Blockly.utils.svgPaths.lineTo + */ + export function lineTo(dx: number, dy: number): string; + /** + * Draw multiple lines connecting all of the given points in order. This is + * equivalent to a series of 'l' commands. + * These coordinates are unitless and hence in the user coordinate system. + * See developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#Line_commands + * @param {!Array} points An array containing all of the points to + * draw lines to, in order. The points are represented as strings of the + * format ' dx,dy '. + * @return {string} A string of the format ' l (dx,dy)+ ' + * @alias Blockly.utils.svgPaths.line + */ + export function line(points: Array): string; + /** + * Draw a horizontal or vertical line. + * The first argument specifies the direction and whether the given position is + * relative or absolute. + * These coordinates are unitless and hence in the user coordinate system. + * See developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#LineTo_path_commands + * @param {string} command The command to prepend to the coordinate. This + * should be one of: V, v, H, h. + * @param {number} val The coordinate to pass to the command. It may be + * absolute or relative. + * @return {string} A string of the format ' command val ' + * @alias Blockly.utils.svgPaths.lineOnAxis + */ + export function lineOnAxis(command: string, val: number): string; + /** + * Draw an elliptical arc curve. + * These coordinates are unitless and hence in the user coordinate system. + * See developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#Elliptical_Arc_Curve + * @param {string} command The command string. Either 'a' or 'A'. + * @param {string} flags The flag string. See the MDN documentation for a + * description and examples. + * @param {number} radius The radius of the arc to draw. + * @param {string} point The point to move the cursor to after drawing the arc, + * specified either in absolute or relative coordinates depending on the + * command. + * @return {string} A string of the format 'command radius radius flags point' + * @alias Blockly.utils.svgPaths.arc + */ + export function arc(command: string, flags: string, radius: number, point: string): string; +} +declare module "utils/style" { + /** + * Gets the height and width of an element. + * Similar to Closure's goog.style.getSize + * @param {!Element} element Element to get size of. + * @return {!Size} Object with width/height properties. + * @alias Blockly.utils.style.getSize + */ + export function getSize(element: Element): Size; + /** + * Retrieves a computed style value of a node. It returns empty string if the + * value cannot be computed (which will be the case in Internet Explorer) or + * "none" if the property requested is an SVG one and it has not been + * explicitly set (firefox and webkit). + * + * Copied from Closure's goog.style.getComputedStyle + * + * @param {!Element} element Element to get style of. + * @param {string} property Property to get (camel-case). + * @return {string} Style value. + * @alias Blockly.utils.style.getComputedStyle + */ + export function getComputedStyle(element: Element, property: string): string; + /** + * Gets the cascaded style value of a node, or null if the value cannot be + * computed (only Internet Explorer can do this). + * + * Copied from Closure's goog.style.getCascadedStyle + * + * @param {!Element} element Element to get style of. + * @param {string} style Property to get (camel-case). + * @return {string} Style value. + * @alias Blockly.utils.style.getCascadedStyle + */ + export function getCascadedStyle(element: Element, style: string): string; + /** + * Returns a Coordinate object relative to the top-left of the HTML document. + * Similar to Closure's goog.style.getPageOffset + * @param {!Element} el Element to get the page offset for. + * @return {!Coordinate} The page offset. + * @alias Blockly.utils.style.getPageOffset + */ + export function getPageOffset(el: Element): Coordinate; + /** + * Calculates the viewport coordinates relative to the document. + * Similar to Closure's goog.style.getViewportPageOffset + * @return {!Coordinate} The page offset of the viewport. + * @alias Blockly.utils.style.getViewportPageOffset + */ + export function getViewportPageOffset(): Coordinate; + /** + * Shows or hides an element from the page. Hiding the element is done by + * setting the display property to "none", removing the element from the + * rendering hierarchy so it takes up no space. To show the element, the default + * inherited display property is restored (defined either in stylesheets or by + * the browser's default style rules). + * Copied from Closure's goog.style.getViewportPageOffset + * + * @param {!Element} el Element to show or hide. + * @param {*} isShown True to render the element in its default style, + * false to disable rendering the element. + * @alias Blockly.utils.style.setElementShown + */ + export function setElementShown(el: Element, isShown: any): void; + /** + * Returns true if the element is using right to left (RTL) direction. + * Copied from Closure's goog.style.isRightToLeft + * + * @param {!Element} el The element to test. + * @return {boolean} True for right to left, false for left to right. + * @alias Blockly.utils.style.isRightToLeft + */ + export function isRightToLeft(el: Element): boolean; + /** + * Gets the computed border widths (on all sides) in pixels + * Copied from Closure's goog.style.getBorderBox + * @param {!Element} element The element to get the border widths for. + * @return {!Object} The computed border widths. + * @alias Blockly.utils.style.getBorderBox + */ + export function getBorderBox(element: Element): any; + /** + * Changes the scroll position of `container` with the minimum amount so + * that the content and the borders of the given `element` become visible. + * If the element is bigger than the container, its top left corner will be + * aligned as close to the container's top left corner as possible. + * Copied from Closure's goog.style.scrollIntoContainerView + * + * @param {!Element} element The element to make visible. + * @param {!Element} container The container to scroll. If not set, then the + * document scroll element will be used. + * @param {boolean=} opt_center Whether to center the element in the container. + * Defaults to false. + * @alias Blockly.utils.style.scrollIntoContainerView + */ + export function scrollIntoContainerView(element: Element, container: Element, opt_center?: boolean | undefined): void; + /** + * Calculate the scroll position of `container` with the minimum amount so + * that the content and the borders of the given `element` become visible. + * If the element is bigger than the container, its top left corner will be + * aligned as close to the container's top left corner as possible. + * Copied from Closure's goog.style.getContainerOffsetToScrollInto + * + * @param {!Element} element The element to make visible. + * @param {!Element} container The container to scroll. If not set, then the + * document scroll element will be used. + * @param {boolean=} opt_center Whether to center the element in the container. + * Defaults to false. + * @return {!Coordinate} The new scroll position of the container, + * in form of goog.math.Coordinate(scrollLeft, scrollTop). + * @alias Blockly.utils.style.getContainerOffsetToScrollInto + */ + export function getContainerOffsetToScrollInto(element: Element, container: Element, opt_center?: boolean | undefined): Coordinate; + import { Size } from "utils/size"; + import { Coordinate } from "utils/coordinate"; +} +declare module "utils/rect" { + /** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview Utility methods for rectangle manipulation. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. + */ + /** + * Utility methods for rectangle manipulation. + * These methods are not specific to Blockly, and could be factored out into + * a JavaScript framework such as Closure. + * @class + */ + /** + * Class for representing rectangular regions. + * @param {number} top Top. + * @param {number} bottom Bottom. + * @param {number} left Left. + * @param {number} right Right. + * @struct + * @constructor + * @alias Blockly.utils.Rect + */ + export class Rect { + constructor(top: any, bottom: any, left: any, right: any); + /** @type {number} */ + top: number; + /** @type {number} */ + bottom: number; + /** @type {number} */ + left: number; + /** @type {number} */ + right: number; + /** + * Tests whether this rectangle contains a x/y coordinate. + * + * @param {number} x The x coordinate to test for containment. + * @param {number} y The y coordinate to test for containment. + * @return {boolean} Whether this rectangle contains given coordinate. + */ + contains(x: number, y: number): boolean; + /** + * Tests whether this rectangle intersects the provided rectangle. + * Assumes that the coordinate system increases going down and left. + * @param {!Rect} other The other rectangle to check for + * intersection with. + * @return {boolean} Whether this rectangle intersects the provided rectangle. + */ + intersects(other: Rect): boolean; + } +} +declare module "utils/svg_math" { + export namespace TEST_ONLY { + export { XY_REGEX }; + export { XY_STYLE_REGEX }; + } + /** + * Return the coordinates of the top-left corner of this element relative to + * its parent. Only for SVG elements and children (e.g. rect, g, path). + * @param {!Element} element SVG element to find the coordinates of. + * @return {!Coordinate} Object with .x and .y properties. + * @alias Blockly.svgMath.getRelativeXY + */ + export function getRelativeXY(element: Element): Coordinate; + /** + * Return the coordinates of the top-left corner of this element relative to + * the div Blockly was injected into. + * @param {!Element} element SVG element to find the coordinates of. If this is + * not a child of the div Blockly was injected into, the behaviour is + * undefined. + * @return {!Coordinate} Object with .x and .y properties. + * @alias Blockly.svgMath.getInjectionDivXY + */ + export function getInjectionDivXY(element: Element): Coordinate; + /** + * Check if 3D transforms are supported by adding an element + * and attempting to set the property. + * @return {boolean} True if 3D transforms are supported. + * @alias Blockly.svgMath.is3dSupported + */ + export function is3dSupported(): boolean; + /** + * Get the position of the current viewport in window coordinates. This takes + * scroll into account. + * @return {!Rect} An object containing window width, height, and + * scroll position in window coordinates. + * @alias Blockly.svgMath.getViewportBBox + * @package + */ + export function getViewportBBox(): Rect; + /** + * Gets the document scroll distance as a coordinate object. + * Copied from Closure's goog.dom.getDocumentScroll. + * @return {!Coordinate} Object with values 'x' and 'y'. + * @alias Blockly.svgMath.getDocumentScroll + */ + export function getDocumentScroll(): Coordinate; + /** + * Converts screen coordinates to workspace coordinates. + * @param {!WorkspaceSvg} ws The workspace to find the coordinates on. + * @param {!Coordinate} screenCoordinates The screen coordinates to + * be converted to workspace coordinates + * @return {!Coordinate} The workspace coordinates. + * @alias Blockly.svgMath.screenToWsCoordinates + */ + export function screenToWsCoordinates(ws: WorkspaceSvg, screenCoordinates: Coordinate): Coordinate; + /** + * Returns the dimensions of the specified SVG image. + * @param {!SVGElement} svg SVG image. + * @return {!Size} Contains width and height properties. + * @deprecated Use workspace.getCachedParentSvgSize. (2021 March 5) + * @alias Blockly.utils.svgMath.svgSize + */ + export function svgSize(svg: SVGElement): Size; + /** + * Static regex to pull the x,y values out of an SVG translate() directive. + * Note that Firefox and IE (9,10) return 'translate(12)' instead of + * 'translate(12, 0)'. + * Note that IE (9,10) returns 'translate(16 8)' instead of 'translate(16, 8)'. + * Note that IE has been reported to return scientific notation (0.123456e-42). + * @type {!RegExp} + */ + const XY_REGEX: RegExp; + /** + * Static regex to pull the x,y values out of a translate() or translate3d() + * style property. + * Accounts for same exceptions as XY_REGEX. + * @type {!RegExp} + */ + const XY_STYLE_REGEX: RegExp; + import { Coordinate } from "utils/coordinate"; + import { Rect } from "utils/rect"; + import { WorkspaceSvg } from "workspace_svg"; + import { Size } from "utils/size"; + export {}; +} +declare module "rendered_connection" { + export class RenderedConnection extends Connection { + /** + * Class for a connection between blocks that may be rendered on screen. + * @param {!BlockSvg} source The block establishing this connection. + * @param {number} type The type of the connection. + * @extends {Connection} + * @constructor + * @alias Blockly.RenderedConnection + */ + constructor(source: BlockSvg, type: number); + /** + * Connection database for connections of this type on the current workspace. + * @const {!ConnectionDB} + * @private + */ + private db_; + /** + * Connection database for connections compatible with this type on the + * current workspace. + * @const {!ConnectionDB} + * @private + */ + private dbOpposite_; + /** + * Workspace units, (0, 0) is top left of block. + * @type {!Coordinate} + * @private + */ + private offsetInBlock_; + /** + * Describes the state of this connection's tracked-ness. + * @type {RenderedConnection.TrackedState} + * @private + */ + private trackedState_; + /** + * Connection this connection connects to. Null if not connected. + * @type {RenderedConnection} + */ + targetConnection: RenderedConnection; + /** + * Dispose of this connection. Remove it from the database (if it is + * tracked) and call the super-function to deal with connected blocks. + * @override + * @package + */ + override dispose(): void; + /** + * Get the source block for this connection. + * @return {!BlockSvg} The source block. + * @override + */ + override getSourceBlock(): BlockSvg; + /** + * Returns the block that this connection connects to. + * @return {?BlockSvg} The connected block or null if none is connected. + * @override + */ + override targetBlock(): BlockSvg | null; + /** + * Returns the distance between this connection and another connection in + * workspace units. + * @param {!Connection} otherConnection The other connection to measure + * the distance to. + * @return {number} The distance between connections, in workspace units. + */ + distanceFrom(otherConnection: Connection): number; + /** + * Move the block(s) belonging to the connection to a point where they don't + * visually interfere with the specified connection. + * @param {!Connection} staticConnection The connection to move away + * from. + * @package + */ + bumpAwayFrom(staticConnection: Connection): void; + /** + * Change the connection's coordinates. + * @param {number} x New absolute x coordinate, in workspace coordinates. + * @param {number} y New absolute y coordinate, in workspace coordinates. + */ + moveTo(x: number, y: number): void; + x: number; + y: number; + /** + * Change the connection's coordinates. + * @param {number} dx Change to x coordinate, in workspace units. + * @param {number} dy Change to y coordinate, in workspace units. + */ + moveBy(dx: number, dy: number): void; + /** + * Move this connection to the location given by its offset within the block and + * the location of the block's top left corner. + * @param {!Coordinate} blockTL The location of the top left + * corner of the block, in workspace coordinates. + */ + moveToOffset(blockTL: Coordinate): void; + /** + * Set the offset of this connection relative to the top left of its block. + * @param {number} x The new relative x, in workspace units. + * @param {number} y The new relative y, in workspace units. + */ + setOffsetInBlock(x: number, y: number): void; + /** + * Get the offset of this connection relative to the top left of its block. + * @return {!Coordinate} The offset of the connection. + * @package + */ + getOffsetInBlock(): Coordinate; + /** + * Move the blocks on either side of this connection right next to each other. + * @package + */ + tighten(): void; + /** + * Find the closest compatible connection to this connection. + * All parameters are in workspace units. + * @param {number} maxLimit The maximum radius to another connection. + * @param {!Coordinate} dxy Offset between this connection's location + * in the database and the current location (as a result of dragging). + * @return {!{connection: ?Connection, radius: number}} Contains two + * properties: 'connection' which is either another connection or null, + * and 'radius' which is the distance. + */ + closest(maxLimit: number, dxy: Coordinate): { + connection: Connection | null; + radius: number; + }; + /** + * Add highlighting around this connection. + */ + highlight(): void; + /** + * Remove the highlighting around this connection. + */ + unhighlight(): void; + /** + * Set whether this connections is tracked in the database or not. + * @param {boolean} doTracking If true, start tracking. If false, stop tracking. + * @package + */ + setTracking(doTracking: boolean): void; + /** + * Stop tracking this connection, as well as all down-stream connections on + * any block attached to this connection. This happens when a block is + * collapsed. + * + * Also closes down-stream icons/bubbles. + * @package + */ + stopTrackingAll(): void; + /** + * Start tracking this connection, as well as all down-stream connections on + * any block attached to this connection. This happens when a block is expanded. + * @return {!Array} List of blocks to render. + */ + startTrackingAll(): Array; + /** + * Check if the two connections can be dragged to connect to each other. + * @param {!Connection} candidate A nearby connection to check. + * @param {number=} maxRadius The maximum radius allowed for connections, in + * workspace units. + * @return {boolean} True if the connection is allowed, false otherwise. + * @deprecated July 2020 + */ + isConnectionAllowed(candidate: Connection, maxRadius?: number | undefined): boolean; + /** + * Behavior after a connection attempt fails. + * Bumps this connection away from the other connection. Called when an + * attempted connection fails. + * @param {!Connection} otherConnection Connection that this connection + * failed to connect to. + * @package + */ + onFailedConnect(otherConnection: Connection): void; + /** + * Disconnect two blocks that are connected by this connection. + * @param {!Block} parentBlock The superior block. + * @param {!Block} childBlock The inferior block. + * @protected + * @override + */ + protected override disconnectInternal_(parentBlock: Block, childBlock: Block): void; + /** + * Respawn the shadow block if there was one connected to the this connection. + * Render/rerender blocks as needed. + * @protected + * @override + */ + protected override respawnShadow_(): void; + /** + * Find all nearby compatible connections to this connection. + * Type checking does not apply, since this function is used for bumping. + * @param {number} maxLimit The maximum radius to another connection, in + * workspace units. + * @return {!Array} List of connections. + * @package + */ + neighbours(maxLimit: number): Array; + /** + * Connect two connections together. This is the connection on the superior + * block. Rerender blocks as needed. + * @param {!Connection} childConnection Connection on inferior block. + * @protected + */ + protected connect_(childConnection: Connection): void; + /** + * Function to be called when this connection's compatible types have changed. + * @protected + */ + protected onCheckChanged_(): void; + } + export namespace RenderedConnection { + namespace TrackedState { + const WILL_TRACK: number; + const UNTRACKED: number; + const TRACKED: number; + } + /** + * Enum for different kinds of tracked states. + * + * WILL_TRACK means that this connection will add itself to + * the db on the next moveTo call it receives. + * + * UNTRACKED means that this connection will not add + * itself to the database until setTracking(true) is explicitly called. + * + * TRACKED means that this connection is currently being tracked. + */ + type TrackedState = number; + } + import { BlockSvg } from "block_svg"; + import { Connection } from "connection"; + import { Coordinate } from "utils/coordinate"; + import { Block } from "block"; +} +declare module "interfaces/i_connection_checker" { + /** + * Class for connection type checking logic. + * @interface + * @alias Blockly.IConnectionChecker + */ + export class IConnectionChecker { + } +} +declare module "constants" { + /** + * * + */ + export type ALIGN = number; + export namespace ALIGN { + const LEFT: number; + const CENTRE: number; + const RIGHT: number; } - /** * The language-neutral ID given to the collapsed input. * @const {string} + * @alias Blockly.constants.COLLAPSED_INPUT_NAME */ - var COLLAPSED_INPUT_NAME: any /*missing*/; - + export const COLLAPSED_INPUT_NAME: "_TEMP_COLLAPSED_INPUT"; /** * The language-neutral ID given to the collapsed field. * @const {string} + * @alias Blockly.constants.COLLAPSED_FIELD_NAME */ - var COLLAPSED_FIELD_NAME: any /*missing*/; + export const COLLAPSED_FIELD_NAME: "_TEMP_COLLAPSED_FIELD"; } - - - - - -declare module BlockSvg { - +declare module "connection_db" { + export class ConnectionDB { + /** + * Initialize a set of connection DBs for a workspace. + * @param {!IConnectionChecker} checker The workspace's + * connection checker, used to decide if connections are valid during a + * drag. + * @return {!Array} Array of databases. + */ + static init(checker: IConnectionChecker): Array; + /** + * Database of connections. + * Connections are stored in order of their vertical component. This way + * connections in an area may be looked up quickly using a binary search. + * @param {!IConnectionChecker} checker The workspace's + * connection type checker, used to decide if connections are valid during a + * drag. + * @constructor + * @alias Blockly.ConnectionDB + */ + constructor(checker: IConnectionChecker); + /** + * Array of connections sorted by y position in workspace units. + * @type {!Array} + * @private + */ + private connections_; + /** + * The workspace's connection type checker, used to decide if connections are + * valid during a drag. + * @type {!IConnectionChecker} + * @private + */ + private connectionChecker_; + /** + * Add a connection to the database. Should not already exist in the database. + * @param {!RenderedConnection} connection The connection to be added. + * @param {number} yPos The y position used to decide where to insert the + * connection. + * @package + */ + addConnection(connection: RenderedConnection, yPos: number): void; + /** + * Finds the index of the given connection. + * + * Starts by doing a binary search to find the approximate location, then + * linearly searches nearby for the exact connection. + * @param {!RenderedConnection} conn The connection to find. + * @param {number} yPos The y position used to find the index of the connection. + * @return {number} The index of the connection, or -1 if the connection was + * not found. + * @private + */ + private findIndexOfConnection_; + /** + * Finds the correct index for the given y position. + * @param {number} yPos The y position used to decide where to + * insert the connection. + * @return {number} The candidate index. + * @private + */ + private calculateIndexForYPos_; + /** + * Remove a connection from the database. Must already exist in DB. + * @param {!RenderedConnection} connection The connection to be removed. + * @param {number} yPos The y position used to find the index of the connection. + * @throws {Error} If the connection cannot be found in the database. + */ + removeConnection(connection: RenderedConnection, yPos: number): void; + /** + * Find all nearby connections to the given connection. + * Type checking does not apply, since this function is used for bumping. + * @param {!RenderedConnection} connection The connection whose + * neighbours should be returned. + * @param {number} maxRadius The maximum radius to another connection. + * @return {!Array} List of connections. + */ + getNeighbours(connection: RenderedConnection, maxRadius: number): Array; + /** + * Is the candidate connection close to the reference connection. + * Extremely fast; only looks at Y distance. + * @param {number} index Index in database of candidate connection. + * @param {number} baseY Reference connection's Y value. + * @param {number} maxRadius The maximum radius to another connection. + * @return {boolean} True if connection is in range. + * @private + */ + private isInYRange_; + /** + * Find the closest compatible connection to this connection. + * @param {!RenderedConnection} conn The connection searching for a compatible + * mate. + * @param {number} maxRadius The maximum radius to another connection. + * @param {!Coordinate} dxy Offset between this connection's + * location in the database and the current location (as a result of + * dragging). + * @return {!{connection: RenderedConnection, radius: number}} + * Contains two properties: 'connection' which is either another + * connection or null, and 'radius' which is the distance. + */ + searchForClosest(conn: RenderedConnection, maxRadius: number, dxy: Coordinate): { + connection: RenderedConnection; + radius: number; + }; + } + import { RenderedConnection } from "rendered_connection"; + import { Coordinate } from "utils/coordinate"; + import { IConnectionChecker } from "interfaces/i_connection_checker"; +} +declare module "interfaces/i_ast_node_location" { /** - * Constant for identifying rows that are to be rendered inline. - * Don't collide with Blockly.inputTypes. - * @const + * @license + * Copyright 2020 Google LLC + * SPDX-License-Identifier: Apache-2.0 */ - var INLINE: any /*missing*/; - /** - * ID to give the "collapsed warnings" warning. Allows us to remove the - * "collapsed warnings" warning without removing any warnings that belong to - * the block. + * @fileoverview The interface for an AST node location. + */ + /** + * The interface for an AST node location. + * @namespace Blockly.IASTNodeLocation + */ + /** + * An AST node location interface. + * @interface + * @alias Blockly.IASTNodeLocation + */ + export class IASTNodeLocation { + } +} +declare module "theme" { + /** + * Class for a theme. + * @param {string} name Theme name. + * @param {!Object=} opt_blockStyles A map + * from style names (strings) to objects with style attributes for blocks. + * @param {!Object=} opt_categoryStyles A + * map from style names (strings) to objects with style attributes for + * categories. + * @param {!Theme.ComponentStyle=} opt_componentStyles A map of Blockly + * component names to style value. + * @constructor + * @alias Blockly.Theme + */ + export class Theme { + /** + * Define a new Blockly theme. + * @param {string} name The name of the theme. + * @param {!Object} themeObj An object containing theme properties. + * @return {!Theme} A new Blockly theme. + */ + static defineTheme(name: string, themeObj: any): Theme; + constructor(name: any, opt_blockStyles: any, opt_categoryStyles: any, opt_componentStyles: any); + /** + * The theme name. This can be used to reference a specific theme in CSS. + * @type {string} + */ + name: string; + /** + * The block styles map. + * @type {!Object} + * @package + */ + blockStyles: { + [x: string]: Theme.BlockStyle; + }; + /** + * The category styles map. + * @type {!Object} + * @package + */ + categoryStyles: { + [x: string]: Theme.CategoryStyle; + }; + /** + * The UI components styles map. + * @type {!Theme.ComponentStyle} + * @package + */ + componentStyles: Theme.ComponentStyle; + /** + * The font style. + * @type {!Theme.FontStyle} + * @package + */ + fontStyle: Theme.FontStyle; + /** + * Whether or not to add a 'hat' on top of all blocks with no previous or + * output connections. + * @type {?boolean} + * @package + */ + startHats: boolean | null; + /** + * Gets the class name that identifies this theme. + * @return {string} The CSS class name. + * @package + */ + getClassName(): string; + /** + * Overrides or adds a style to the blockStyles map. + * @param {string} blockStyleName The name of the block style. + * @param {Theme.BlockStyle} blockStyle The block style. + */ + setBlockStyle(blockStyleName: string, blockStyle: Theme.BlockStyle): void; + /** + * Overrides or adds a style to the categoryStyles map. + * @param {string} categoryStyleName The name of the category style. + * @param {Theme.CategoryStyle} categoryStyle The category style. + */ + setCategoryStyle(categoryStyleName: string, categoryStyle: Theme.CategoryStyle): void; + /** + * Gets the style for a given Blockly UI component. If the style value is a + * string, we attempt to find the value of any named references. + * @param {string} componentName The name of the component. + * @return {?string} The style value. + */ + getComponentStyle(componentName: string): string | null; + /** + * Configure a specific Blockly UI component with a style value. + * @param {string} componentName The name of the component. + * @param {*} styleValue The style value. + */ + setComponentStyle(componentName: string, styleValue: any): void; + /** + * Configure a theme's font style. + * @param {Theme.FontStyle} fontStyle The font style. + */ + setFontStyle(fontStyle: Theme.FontStyle): void; + /** + * Configure a theme's start hats. + * @param {boolean} startHats True if the theme enables start hats, false + * otherwise. + */ + setStartHats(startHats: boolean): void; + } + export namespace Theme { + /** + * A block style. + */ + type BlockStyle = { + colourPrimary: string; + colourSecondary: string; + colourTertiary: string; + hat: string; + }; + /** + * A category style. + */ + type CategoryStyle = { + colour: string; + }; + /** + * A component style. + */ + type ComponentStyle = { + workspaceBackgroundColour: string | null; + toolboxBackgroundColour: string | null; + toolboxForegroundColour: string | null; + flyoutBackgroundColour: string | null; + flyoutForegroundColour: string | null; + flyoutOpacity: number | null; + scrollbarColour: string | null; + scrollbarOpacity: number | null; + insertionMarkerColour: string | null; + insertionMarkerOpacity: number | null; + markerColour: string | null; + cursorColour: string | null; + selectedGlowColour: string | null; + selectedGlowOpacity: number | null; + replacementGlowColour: string | null; + replacementGlowOpacity: number | null; + }; + /** + * A font style. + */ + type FontStyle = { + family: string | null; + weight: string | null; + size: number | null; + }; + } +} +declare module "theme/classic" { + /** + * Classic theme. + * Contains multi-coloured border to create shadow effect. + * @type {Theme} + * @alias Blockly.Themes.Classic + */ + export const Classic: Theme; + import { Theme } from "theme"; +} +declare module "utils/metrics" { + /** + * @license + * Copyright 2020 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + /** + * @fileoverview Workspace metrics definitions. + */ + /** + * Workspace metrics definitions. + * @namespace Blockly.utils.Metrics + */ + /** + * @record + * @alias Blockly.utils.Metrics + */ + export class Metrics { + /** + * Height of the visible portion of the workspace. + * @type {number} + */ + viewHeight: number; + /** + * Width of the visible portion of the workspace. + * @type {number} + */ + viewWidth: number; + /** + * Height of the content. + * @type {number} + */ + contentHeight: number; + /** + * Width of the content. + * @type {number} + */ + contentWidth: number; + /** + * Height of the scroll area. + * @type {number} + */ + scrollHeight: number; + /** + * Width of the scroll area. + * @type {number} + */ + scrollWidth: number; + /** + * Top-edge of the visible portion of the workspace, relative to the workspace + * origin. + * @type {number} + */ + viewTop: number; + /** + * Left-edge of the visible portion of the workspace, relative to the workspace + * origin. + * @type {number} + */ + viewLeft: number; + /** + * Top-edge of the content, relative to the workspace origin. + * @type {number} + */ + contentTop: number; + /** + * Left-edge of the content relative to the workspace origin. + * @type {number} + */ + contentLeft: number; + /** + * Top-edge of the scroll area, relative to the workspace origin. + * @type {number} + */ + scrollTop: number; + /** + * Left-edge of the scroll area relative to the workspace origin. + * @type {number} + */ + scrollLeft: number; + /** + * Top-edge of the visible portion of the workspace, relative to the blocklyDiv. + * @type {number} + */ + absoluteTop: number; + /** + * Left-edge of the visible portion of the workspace, relative to the + * blocklyDiv. + * @type {number} + */ + absoluteLeft: number; + /** + * Height of the Blockly div (the view + the toolbox, simple of otherwise). + * @type {number} + */ + svgHeight: number; + /** + * Width of the Blockly div (the view + the toolbox, simple or otherwise). + * @type {number} + */ + svgWidth: number; + /** + * Width of the toolbox, if it exists. Otherwise zero. + * @type {number} + */ + toolboxWidth: number; + /** + * Height of the toolbox, if it exists. Otherwise zero. + * @type {number} + */ + toolboxHeight: number; + /** + * Top, bottom, left or right. Use TOOLBOX_AT constants to compare. + * @type {number} + */ + toolboxPosition: number; + /** + * Width of the flyout if it is always open. Otherwise zero. + * @type {number} + */ + flyoutWidth: number; + /** + * Height of the flyout if it is always open. Otherwise zero. + * @type {number} + */ + flyoutHeight: number; + } +} +declare module "options" { + export class Options { + /** + * Parse the user-specified move options, using reasonable defaults where + * behaviour is unspecified. + * @param {!Object} options Dictionary of options. + * @param {boolean} hasCategories Whether the workspace has categories or not. + * @return {!Options.MoveOptions} Normalized move options. + * @private + */ + private static parseMoveOptions_; + /** + * Parse the user-specified zoom options, using reasonable defaults where + * behaviour is unspecified. See zoom documentation: + * https://developers.google.com/blockly/guides/configure/web/zoom + * @param {!Object} options Dictionary of options. + * @return {!Options.ZoomOptions} Normalized zoom options. + * @private + */ + private static parseZoomOptions_; + /** + * Parse the user-specified grid options, using reasonable defaults where + * behaviour is unspecified. See grid documentation: + * https://developers.google.com/blockly/guides/configure/web/grid + * @param {!Object} options Dictionary of options. + * @return {!Options.GridOptions} Normalized grid options. + * @private + */ + private static parseGridOptions_; + /** + * Parse the user-specified theme options, using the classic theme as a default. + * https://developers.google.com/blockly/guides/configure/web/themes + * @param {!Object} options Dictionary of options. + * @return {!Theme} A Blockly Theme. + * @private + */ + private static parseThemeOptions_; + /** + * Parse the user-specified options, using reasonable defaults where behaviour + * is unspecified. + * @param {!BlocklyOptions} options Dictionary of options. + * Specification: + * https://developers.google.com/blockly/guides/get-started/web#configuration + * @constructor + * @alias Blockly.Options + */ + constructor(options: BlocklyOptions); + /** @type {boolean} */ + RTL: boolean; + /** @type {boolean} */ + oneBasedIndex: boolean; + /** @type {boolean} */ + collapse: boolean; + /** @type {boolean} */ + comments: boolean; + /** @type {boolean} */ + disable: boolean; + /** @type {boolean} */ + readOnly: boolean; + /** @type {number} */ + maxBlocks: number; + /** @type {?Object} */ + maxInstances: { + [x: string]: number; + } | null; + /** @type {string} */ + pathToMedia: string; + /** @type {boolean} */ + hasCategories: boolean; + /** @type {!Options.MoveOptions} */ + moveOptions: Options.MoveOptions; + /** @deprecated January 2019 */ + hasScrollbars: boolean; + /** @type {boolean} */ + hasTrashcan: boolean; + /** @type {number} */ + maxTrashcanContents: number; + /** @type {boolean} */ + hasSounds: boolean; + /** @type {boolean} */ + hasCss: boolean; + /** @type {boolean} */ + horizontalLayout: boolean; + /** @type {?toolbox.ToolboxInfo} */ + languageTree: toolbox.ToolboxInfo | null; + /** @type {!Options.GridOptions} */ + gridOptions: Options.GridOptions; + /** @type {!Options.ZoomOptions} */ + zoomOptions: Options.ZoomOptions; + /** @type {!toolbox.Position} */ + toolboxPosition: toolbox.Position; + /** @type {!Theme} */ + theme: Theme; + /** @type {string} */ + renderer: string; + /** @type {?Object} */ + rendererOverrides: any | null; + /** + * The SVG element for the grid pattern. + * Created during injection. + * @type {?SVGElement} + */ + gridPattern: SVGElement | null; + /** + * The parent of the current workspace, or null if there is no parent + * workspace. We can assert that this is of type WorkspaceSvg as opposed to + * Workspace as this is only used in a rendered workspace. + * @type {WorkspaceSvg} + */ + parentWorkspace: WorkspaceSvg; + /** + * Map of plugin type to name of registered plugin or plugin class. + * @type {!Object} + */ + plugins: { + [x: string]: ((new (...args: unknown[]) => unknown) | string); + }; + } + export namespace Options { + /** + * Grid Options. + */ + type GridOptions = { + colour: string; + length: number; + snap: boolean; + spacing: number; + }; + /** + * Move Options. + */ + type MoveOptions = { + drag: boolean; + scrollbars: (boolean | Options.ScrollbarOptions); + wheel: boolean; + }; + /** + * Scrollbar Options. + */ + type ScrollbarOptions = { + horizontal: boolean; + vertical: boolean; + }; + /** + * Zoom Options. + */ + type ZoomOptions = { + controls: boolean; + maxScale: number; + minScale: number; + pinch: boolean; + scaleSpeed: number; + startScale: number; + wheel: boolean; + }; + } + import * as toolbox from "utils/toolbox"; + import { Theme } from "theme"; + import { WorkspaceSvg } from "workspace_svg"; + import { BlocklyOptions } from "blockly_options"; +} +declare module "names" { + export class Names { + /** + * Do the given two entity names refer to the same entity? + * Blockly names are case-insensitive. + * @param {string} name1 First name. + * @param {string} name2 Second name. + * @return {boolean} True if names are the same. + */ + static equals(name1: string, name2: string): boolean; + /** + * Class for a database of entity names (variables, procedures, etc). + * @param {string} reservedWords A comma-separated string of words that are + * illegal for use as names in a language (e.g. 'new,if,this,...'). + * @param {string=} opt_variablePrefix Some languages need a '$' or a namespace + * before all variable names (but not procedure names). + * @constructor + * @alias Blockly.Names + */ + constructor(reservedWords: string, opt_variablePrefix?: string | undefined); + variablePrefix_: string; + reservedDict_: any; + /** + * When JavaScript (or most other languages) is generated, variable 'foo' and + * procedure 'foo' would collide. However, Blockly has no such problems since + * variable get 'foo' and procedure call 'foo' are unambiguous. + * Therefore, Blockly keeps a separate realm name to disambiguate. + * getName('foo', 'VARIABLE') -> 'foo' + * getName('foo', 'PROCEDURE') -> 'foo2' + */ + /** + * Empty the database and start from scratch. The reserved words are kept. + */ + reset(): void; + db_: any; + dbReverse_: any; + variableMap_: VariableMap; + /** + * Set the variable map that maps from variable name to variable object. + * @param {!VariableMap} map The map to track. + */ + setVariableMap(map: VariableMap): void; + /** + * Get the name for a user-defined variable, based on its ID. + * This should only be used for variables of realm + * internalConstants.VARIABLE_CATEGORY_NAME. + * @param {string} id The ID to look up in the variable map. + * @return {?string} The name of the referenced variable, or null if there was + * no variable map or the variable was not found in the map. + * @private + */ + private getNameForUserVariable_; + /** + * Generate names for user variables, but only ones that are being used. + * @param {!Workspace} workspace Workspace to generate variables from. + */ + populateVariables(workspace: Workspace): void; + /** + * Generate names for procedures. + * @param {!Workspace} workspace Workspace to generate procedures from. + */ + populateProcedures(workspace: Workspace): void; + /** + * Convert a Blockly entity name to a legal exportable entity name. + * @param {string} nameOrId The Blockly entity name (no constraints) or + * variable ID. + * @param {string} realm The realm of entity in Blockly + * ('VARIABLE', 'PROCEDURE', 'DEVELOPER_VARIABLE', etc...). + * @return {string} An entity name that is legal in the exported language. + */ + getName(nameOrId: string, realm: string): string; + /** + * Return a list of all known user-created names in a specified realm. + * @param {string} realm The realm of entity in Blockly + * ('VARIABLE', 'PROCEDURE', 'DEVELOPER_VARIABLE', etc...). + * @return {!Array} A list of Blockly entity names (no constraints). + */ + getUserNames(realm: string): Array; + /** + * Convert a Blockly entity name to a legal exportable entity name. + * Ensure that this is a new name not overlapping any previously defined name. + * Also check against list of reserved words for the current language and + * ensure name doesn't collide. + * @param {string} name The Blockly entity name (no constraints). + * @param {string} realm The realm of entity in Blockly + * ('VARIABLE', 'PROCEDURE', 'DEVELOPER_VARIABLE', etc...). + * @return {string} An entity name that is legal in the exported language. + */ + getDistinctName(name: string, realm: string): string; + /** + * Given a proposed entity name, generate a name that conforms to the + * [_A-Za-z][_A-Za-z0-9]* format that most languages consider legal for + * variable and function names. + * @param {string} name Potentially illegal entity name. + * @return {string} Safe entity name. + * @private + */ + private safeName_; + } + export namespace Names { + const DEVELOPER_VARIABLE_TYPE: string; + } + import { VariableMap } from "variable_map"; + import { Workspace } from "workspace"; +} +declare module "events/events_var_base" { + /** + * Abstract class for a variable event. + * @param {!VariableModel=} opt_variable The variable this event + * corresponds to. Undefined for a blank event. + * @extends {Abstract} + * @constructor + * @alias Blockly.Events.VarBase + */ + export class VarBase { + constructor(opt_variable: any); + isBlank: boolean; + /** + * The variable id for the variable this event pertains to. + * @type {string} + */ + varId: string; + /** + * The workspace identifier for this event. + * @type {string} + */ + workspaceId: string; + /** + * Encode the event as JSON. + * @return {!Object} JSON representation. + */ + toJson(): any; + /** + * Decode the JSON event. + * @param {!Object} json JSON representation. + */ + fromJson(json: any): void; + } +} +declare module "events/events_var_delete" { + /** + * Class for a variable deletion event. + * @param {!VariableModel=} opt_variable The deleted variable. Undefined + * for a blank event. + * @extends {VarBase} + * @constructor + * @alias Blockly.Events.VarDelete + */ + export class VarDelete { + constructor(opt_variable: any); + varType: any; + varName: any; + /** + * Encode the event as JSON. + * @return {!Object} JSON representation. + */ + toJson(): any; + /** + * Decode the JSON event. + * @param {!Object} json JSON representation. + */ + fromJson(json: any): void; + /** + * Run a variable deletion event. + * @param {boolean} forward True if run forward, false if run backward (undo). + */ + run(forward: boolean): void; + /** + * Type of this event. + * @type {string} + */ + type: string; + } +} +declare module "events/events_var_rename" { + /** + * Class for a variable rename event. + * @param {!VariableModel=} opt_variable The renamed variable. Undefined + * for a blank event. + * @param {string=} newName The new name the variable will be changed to. + * @extends {VarBase} + * @constructor + * @alias Blockly.Events.VarRename + */ + export class VarRename { + constructor(opt_variable: any, newName: any); + oldName: any; + newName: any; + /** + * Encode the event as JSON. + * @return {!Object} JSON representation. + */ + toJson(): any; + /** + * Decode the JSON event. + * @param {!Object} json JSON representation. + */ + fromJson(json: any): void; + /** + * Run a variable rename event. + * @param {boolean} forward True if run forward, false if run backward (undo). + */ + run(forward: boolean): void; + /** + * Type of this event. + * @type {string} + */ + type: string; + } +} +declare module "variable_map" { + export class VariableMap { + /** + * Class for a variable map. This contains a dictionary data structure with + * variable types as keys and lists of variables as values. The list of + * variables are the type indicated by the key. + * @param {!Workspace} workspace The workspace this map belongs to. + * @constructor + * @alias Blockly.VariableMap + */ + constructor(workspace: Workspace); + /** + * A map from variable type to list of variable names. The lists contain all + * of the named variables in the workspace, including variables + * that are not currently in use. + * @type {!Object>} + * @private + */ + private variableMap_; + /** + * The workspace this map belongs to. + * @type {!Workspace} + */ + workspace: Workspace; + /** + * Clear the variable map. + */ + clear(): void; + /** + * Rename the given variable by updating its name in the variable map. + * @param {!VariableModel} variable Variable to rename. + * @param {string} newName New variable name. + * @package + */ + renameVariable(variable: VariableModel, newName: string): void; + /** + * Rename a variable by updating its name in the variable map. Identify the + * variable to rename with the given ID. + * @param {string} id ID of the variable to rename. + * @param {string} newName New variable name. + */ + renameVariableById(id: string, newName: string): void; + /** + * Update the name of the given variable and refresh all references to it. + * The new name must not conflict with any existing variable names. + * @param {!VariableModel} variable Variable to rename. + * @param {string} newName New variable name. + * @param {!Array} blocks The list of all blocks in the + * workspace. + * @private + */ + private renameVariableAndUses_; + /** + * Update the name of the given variable to the same name as an existing + * variable. The two variables are coalesced into a single variable with the ID + * of the existing variable that was already using newName. + * Refresh all references to the variable. + * @param {!VariableModel} variable Variable to rename. + * @param {string} newName New variable name. + * @param {!VariableModel} conflictVar The variable that was already + * using newName. + * @param {!Array} blocks The list of all blocks in the + * workspace. + * @private + */ + private renameVariableWithConflict_; + /** + * Create a variable with a given name, optional type, and optional ID. + * @param {string} name The name of the variable. This must be unique across + * variables and procedures. + * @param {?string=} opt_type The type of the variable like 'int' or 'string'. + * Does not need to be unique. Field_variable can filter variables based on + * their type. This will default to '' which is a specific type. + * @param {?string=} opt_id The unique ID of the variable. This will default to + * a UUID. + * @return {!VariableModel} The newly created variable. + */ + createVariable(name: string, opt_type?: (string | null) | undefined, opt_id?: (string | null) | undefined): VariableModel; + /** + * Delete a variable. + * @param {!VariableModel} variable Variable to delete. + */ + deleteVariable(variable: VariableModel): void; + /** + * Delete a variables by the passed in ID and all of its uses from this + * workspace. May prompt the user for confirmation. + * @param {string} id ID of variable to delete. + */ + deleteVariableById(id: string): void; + /** + * Deletes a variable and all of its uses from this workspace without asking the + * user for confirmation. + * @param {!VariableModel} variable Variable to delete. + * @param {!Array} uses An array of uses of the variable. + * @package + */ + deleteVariableInternal(variable: VariableModel, uses: Array): void; + /** + * Find the variable by the given name and type and return it. Return null if + * it is not found. + * @param {string} name The name to check for. + * @param {?string=} opt_type The type of the variable. If not provided it + * defaults to the empty string, which is a specific type. + * @return {?VariableModel} The variable with the given name, or null if + * it was not found. + */ + getVariable(name: string, opt_type?: (string | null) | undefined): VariableModel | null; + /** + * Find the variable by the given ID and return it. Return null if not found. + * @param {string} id The ID to check for. + * @return {?VariableModel} The variable with the given ID. + */ + getVariableById(id: string): VariableModel | null; + /** + * Get a list containing all of the variables of a specified type. If type is + * null, return list of variables with empty string type. + * @param {?string} type Type of the variables to find. + * @return {!Array} The sought after variables of the + * passed in type. An empty array if none are found. + */ + getVariablesOfType(type: string | null): Array; + /** + * Return all variable and potential variable types. This list always contains + * the empty string. + * @param {?Workspace} ws The workspace used to look for potential + * variables. This can be different than the workspace stored on this object + * if the passed in ws is a flyout workspace. + * @return {!Array} List of variable types. + * @package + */ + getVariableTypes(ws: Workspace | null): Array; + /** + * Return all variables of all types. + * @return {!Array} List of variable models. + */ + getAllVariables(): Array; + /** + * Returns all of the variable names of all types. + * @return {!Array} All of the variable names of all types. + */ + getAllVariableNames(): Array; + /** + * Find all the uses of a named variable. + * @param {string} id ID of the variable to find. + * @return {!Array} Array of block usages. + */ + getVariableUsesById(id: string): Array; + } + import { Workspace } from "workspace"; + import { VariableModel } from "variable_model"; + import { Block } from "block"; +} +declare module "events/events_comment_create" { + /** + * Class for a comment creation event. + * @param {!WorkspaceComment=} opt_comment The created comment. + * Undefined for a blank event. + * @extends {CommentBase} + * @constructor + * @alias Blockly.Events.CommentCreate + */ + export class CommentCreate { + constructor(opt_comment: any); + xml: any; + /** + * Encode the event as JSON. + * @return {!Object} JSON representation. + */ + toJson(): any; + /** + * Decode the JSON event. + * @param {!Object} json JSON representation. + */ + fromJson(json: any): void; + /** + * Run a creation event. + * @param {boolean} forward True if run forward, false if run backward (undo). + */ + run(forward: boolean): void; + /** + * Type of this event. + * @type {string} + */ + type: string; + } +} +declare module "events/events_comment_delete" { + /** + * Class for a comment deletion event. + * @param {!WorkspaceComment=} opt_comment The deleted comment. + * Undefined for a blank event. + * @extends {CommentBase} + * @constructor + * @alias Blockly.Events.CommentDelete + */ + export class CommentDelete { + constructor(opt_comment: any); + xml: any; + /** + * Encode the event as JSON. + * @return {!Object} JSON representation. + */ + toJson(): any; + /** + * Decode the JSON event. + * @param {!Object} json JSON representation. + */ + fromJson(json: any): void; + /** + * Run a creation event. + * @param {boolean} forward True if run forward, false if run backward (undo). + */ + run(forward: boolean): void; + /** + * Type of this event. + * @type {string} + */ + type: string; + } +} +declare module "events/events_comment_base" { + /** + * Abstract class for a comment event. + * @param {!WorkspaceComment=} opt_comment The comment this event + * corresponds to. Undefined for a blank event. + * @extends {AbstractEvents} + * @constructor + * @alias Blockly.Events.CommentBase + */ + export class CommentBase { + /** + * Helper function for Comment[Create|Delete] + * @param {!CommentCreate|!CommentDelete} event + * The event to run. + * @param {boolean} create if True then Create, if False then Delete + */ + static CommentCreateDeleteHelper(event: CommentCreate | CommentDelete, create: boolean): void; + constructor(opt_comment: any); + /** + * Whether or not an event is blank. + * @type {boolean} + */ + isBlank: boolean; + /** + * The ID of the comment this event pertains to. + * @type {string} + */ + commentId: string; + /** + * The workspace identifier for this event. + * @type {string} + */ + workspaceId: string; + /** + * The event group id for the group this event belongs to. Groups define + * events that should be treated as an single action from the user's + * perspective, and should be undone together. + * @type {string} + */ + group: string; + /** + * Sets whether the event should be added to the undo stack. + * @type {boolean} + */ + recordUndo: boolean; + /** + * Encode the event as JSON. + * @return {!Object} JSON representation. + */ + toJson(): any; + /** + * Decode the JSON event. + * @param {!Object} json JSON representation. + */ + fromJson(json: any): void; + } + import { CommentCreate } from "events/events_comment_create"; + import { CommentDelete } from "events/events_comment_delete"; +} +declare module "events/events_comment_change" { + /** + * Class for a comment change event. + * @param {!WorkspaceComment=} opt_comment The comment that is being + * changed. Undefined for a blank event. + * @param {string=} opt_oldContents Previous contents of the comment. + * @param {string=} opt_newContents New contents of the comment. + * @extends {CommentBase} + * @constructor + * @alias Blockly.Events.CommentChange + */ + export class CommentChange { + constructor(opt_comment: any, opt_oldContents: any, opt_newContents: any); + oldContents_: any; + newContents_: any; + /** + * Encode the event as JSON. + * @return {!Object} JSON representation. + */ + toJson(): any; + /** + * Decode the JSON event. + * @param {!Object} json JSON representation. + */ + fromJson(json: any): void; + /** + * Does this event record any change of state? + * @return {boolean} False if something changed. + */ + isNull(): boolean; + /** + * Run a change event. + * @param {boolean} forward True if run forward, false if run backward (undo). + */ + run(forward: boolean): void; + /** + * Type of this event. + * @type {string} + */ + type: string; + } +} +declare module "events/events_comment_move" { + /** + * Class for a comment move event. Created before the move. + * @param {!WorkspaceComment=} opt_comment The comment that is being + * moved. Undefined for a blank event. + * @extends {CommentBase} + * @constructor + * @alias Blockly.Events.CommentMove + */ + export class CommentMove { + constructor(opt_comment: any); + /** + * The comment that is being moved. Will be cleared after recording the new + * location. + * @type {WorkspaceComment} + */ + comment_: WorkspaceComment; + /** + * The location before the move, in workspace coordinates. + * @type {!Coordinate} + */ + oldCoordinate_: Coordinate; + /** + * The location after the move, in workspace coordinates. + * @type {Coordinate} + */ + newCoordinate_: Coordinate; + /** + * Record the comment's new location. Called after the move. Can only be + * called once. + */ + recordNew(): void; + /** + * Override the location before the move. Use this if you don't create the + * event until the end of the move, but you know the original location. + * @param {!Coordinate} xy The location before the move, + * in workspace coordinates. + */ + setOldCoordinate(xy: Coordinate): void; + /** + * Encode the event as JSON. + * @return {!Object} JSON representation. + */ + toJson(): any; + /** + * Decode the JSON event. + * @param {!Object} json JSON representation. + */ + fromJson(json: any): void; + /** + * Does this event record any change of state? + * @return {boolean} False if something changed. + */ + isNull(): boolean; + /** + * Run a move event. + * @param {boolean} forward True if run forward, false if run backward (undo). + */ + run(forward: boolean): void; + /** + * Type of this event. + * @type {string} + */ + type: string; + } + import { WorkspaceComment } from "workspace_comment"; + import { Coordinate } from "utils/coordinate"; +} +declare module "workspace_comment" { + /** + * Class for a workspace comment. + * @param {!Workspace} workspace The block's workspace. + * @param {string} content The content of this workspace comment. + * @param {number} height Height of the comment. + * @param {number} width Width of the comment. + * @param {string=} opt_id Optional ID. Use this ID if provided, otherwise + * create a new ID. + * @constructor + * @alias Blockly.WorkspaceComment + */ + export class WorkspaceComment { + /** + * Fire a create event for the given workspace comment, if comments are enabled. + * @param {!WorkspaceComment} comment The comment that was just created. + * @package + */ + static fireCreateEvent(comment: WorkspaceComment): void; + /** + * Decode an XML comment tag and create a comment on the workspace. + * @param {!Element} xmlComment XML comment element. + * @param {!Workspace} workspace The workspace. + * @return {!WorkspaceComment} The created workspace comment. + * @package + */ + static fromXml(xmlComment: Element, workspace: Workspace): WorkspaceComment; + /** + * Decode an XML comment tag and return the results in an object. + * @param {!Element} xml XML comment element. + * @return {{w: number, h: number, x: number, y: number, content: string}} An + * object containing the id, size, position, and comment string. + * @package + */ + static parseAttributes(xml: Element): { + w: number; + h: number; + x: number; + y: number; + content: string; + }; + constructor(workspace: any, content: any, height: any, width: any, opt_id: any); + /** @type {string} */ + id: string; + /** + * The comment's position in workspace units. (0, 0) is at the workspace's + * origin; scale does not change this value. + * @type {!Coordinate} + * @protected + */ + protected xy_: Coordinate; + /** + * The comment's height in workspace units. Scale does not change this value. + * @type {number} + * @protected + */ + protected height_: number; + /** + * The comment's width in workspace units. Scale does not change this value. + * @type {number} + * @protected + */ + protected width_: number; + /** + * @type {!Workspace} + */ + workspace: Workspace; + /** + * @protected + * @type {boolean} + */ + protected RTL: boolean; + /** + * @type {boolean} + * @private + */ + private deletable_; + /** + * @type {boolean} + * @private + */ + private movable_; + /** + * @type {boolean} + * @private + */ + private editable_; + /** + * @protected + * @type {string} + */ + protected content_: string; + /** + * Whether this comment has been disposed. + * @protected + * @type {boolean} + */ + protected disposed_: boolean; + /** + * @package + * @type {boolean} + */ + isComment: boolean; + /** + * Dispose of this comment. + * @package + */ + dispose(): void; + /** + * Get comment height. + * @return {number} Comment height. + * @package + */ + getHeight(): number; + /** + * Set comment height. + * @param {number} height Comment height. + * @package + */ + setHeight(height: number): void; + /** + * Get comment width. + * @return {number} Comment width. + * @package + */ + getWidth(): number; + /** + * Set comment width. + * @param {number} width comment width. + * @package + */ + setWidth(width: number): void; + /** + * Get stored location. + * @return {!Coordinate} The comment's stored location. + * This is not valid if the comment is currently being dragged. + * @package + */ + getXY(): Coordinate; + /** + * Move a comment by a relative offset. + * @param {number} dx Horizontal offset, in workspace units. + * @param {number} dy Vertical offset, in workspace units. + * @package + */ + moveBy(dx: number, dy: number): void; + /** + * Get whether this comment is deletable or not. + * @return {boolean} True if deletable. + * @package + */ + isDeletable(): boolean; + /** + * Set whether this comment is deletable or not. + * @param {boolean} deletable True if deletable. + * @package + */ + setDeletable(deletable: boolean): void; + /** + * Get whether this comment is movable or not. + * @return {boolean} True if movable. + * @package + */ + isMovable(): boolean; + /** + * Set whether this comment is movable or not. + * @param {boolean} movable True if movable. + * @package + */ + setMovable(movable: boolean): void; + /** + * Get whether this comment is editable or not. + * @return {boolean} True if editable. + */ + isEditable(): boolean; + /** + * Set whether this comment is editable or not. + * @param {boolean} editable True if editable. + */ + setEditable(editable: boolean): void; + /** + * Returns this comment's text. + * @return {string} Comment text. + * @package + */ + getContent(): string; + /** + * Set this comment's content. + * @param {string} content Comment content. + * @package + */ + setContent(content: string): void; + /** + * Encode a comment subtree as XML with XY coordinates. + * @param {boolean=} opt_noId True if the encoder should skip the comment ID. + * @return {!Element} Tree of XML elements. + * @package + */ + toXmlWithXY(opt_noId?: boolean | undefined): Element; + /** + * Encode a comment subtree as XML, but don't serialize the XY coordinates. + * This method avoids some expensive metrics-related calls that are made in + * toXmlWithXY(). + * @param {boolean=} opt_noId True if the encoder should skip the comment ID. + * @return {!Element} Tree of XML elements. + * @package + */ + toXml(opt_noId?: boolean | undefined): Element; + } + import { Coordinate } from "utils/coordinate"; + import { Workspace } from "workspace"; +} +declare module "connection_checker" { + /** + * Class for connection type checking logic. + * @implements {IConnectionChecker} + * @constructor + * @alias Blockly.ConnectionChecker + */ + export class ConnectionChecker implements IConnectionChecker { + /** + * Check whether the current connection can connect with the target + * connection. + * @param {Connection} a Connection to check compatibility with. + * @param {Connection} b Connection to check compatibility with. + * @param {boolean} isDragging True if the connection is being made by dragging + * a block. + * @param {number=} opt_distance The max allowable distance between the + * connections for drag checks. + * @return {boolean} Whether the connection is legal. + * @public + */ + public canConnect(a: Connection, b: Connection, isDragging: boolean, opt_distance?: number | undefined): boolean; + /** + * Checks whether the current connection can connect with the target + * connection, and return an error code if there are problems. + * @param {Connection} a Connection to check compatibility with. + * @param {Connection} b Connection to check compatibility with. + * @param {boolean} isDragging True if the connection is being made by dragging + * a block. + * @param {number=} opt_distance The max allowable distance between the + * connections for drag checks. + * @return {number} Connection.CAN_CONNECT if the connection is legal, + * an error code otherwise. + * @public + */ + public canConnectWithReason(a: Connection, b: Connection, isDragging: boolean, opt_distance?: number | undefined): number; + /** + * Helper method that translates a connection error code into a string. + * @param {number} errorCode The error code. + * @param {Connection} a One of the two connections being checked. + * @param {Connection} b The second of the two connections being + * checked. + * @return {string} A developer-readable error string. + * @public + */ + public getErrorMessage(errorCode: number, a: Connection, b: Connection): string; + /** + * Check that connecting the given connections is safe, meaning that it would + * not break any of Blockly's basic assumptions (e.g. no self connections). + * @param {Connection} a The first of the connections to check. + * @param {Connection} b The second of the connections to check. + * @return {number} An enum with the reason this connection is safe or unsafe. + * @public + */ + public doSafetyChecks(a: Connection, b: Connection): number; + /** + * Check whether this connection is compatible with another connection with + * respect to the value type system. E.g. square_root("Hello") is not + * compatible. + * @param {!Connection} a Connection to compare. + * @param {!Connection} b Connection to compare against. + * @return {boolean} True if the connections share a type. + * @public + */ + public doTypeChecks(a: Connection, b: Connection): boolean; + /** + * Check whether this connection can be made by dragging. + * @param {!RenderedConnection} a Connection to compare. + * @param {!RenderedConnection} b Connection to compare against. + * @param {number} distance The maximum allowable distance between connections. + * @return {boolean} True if the connection is allowed during a drag. + * @public + */ + public doDragChecks(a: RenderedConnection, b: RenderedConnection, distance: number): boolean; + /** + * Helper function for drag checking. + * @param {!Connection} a The connection to check, which must be a + * statement input or next connection. + * @param {!Connection} b A nearby connection to check, which + * must be a previous connection. + * @return {boolean} True if the connection is allowed, false otherwise. + * @protected + */ + protected canConnectToPrevious_(a: Connection, b: Connection): boolean; + } + import { IConnectionChecker } from "interfaces/i_connection_checker"; + import { Connection } from "connection"; + import { RenderedConnection } from "rendered_connection"; +} +declare module "workspace" { + export class Workspace { + /** + * Find the workspace with the specified ID. + * @param {string} id ID of workspace to find. + * @return {?Workspace} The sought after workspace or null if not found. + */ + static getById(id: string): Workspace | null; + /** + * Find all workspaces. + * @return {!Array} Array of workspaces. + */ + static getAll(): Array; + /** + * Class for a workspace. This is a data structure that contains blocks. + * There is no UI, and can be created headlessly. + * @param {!Options=} opt_options Dictionary of options. + * @constructor + * @implements {IASTNodeLocation} + * @alias Blockly.Workspace + */ + constructor(opt_options?: Options | undefined); + /** @type {string} */ + id: string; + /** @type {!Options} */ + options: Options; + /** @type {boolean} */ + RTL: boolean; + /** @type {boolean} */ + horizontalLayout: boolean; + /** @type {toolbox.Position} */ + toolboxPosition: toolbox.Position; + /** + * An object that encapsulates logic for safety, type, and dragging checks. + * @type {!IConnectionChecker} + */ + connectionChecker: IConnectionChecker; + /** + * @type {!Array} + * @private + */ + private topBlocks_; + /** + * @type {!Array} + * @private + */ + private topComments_; + /** + * @type {!Object} + * @private + */ + private commentDB_; + /** + * @type {!Array} + * @private + */ + private listeners_; + /** + * @type {!Array} + * @protected + */ + protected undoStack_: Array; + /** + * @type {!Array} + * @protected + */ + protected redoStack_: Array; + /** + * @type {!Object} + * @private + */ + private blockDB_; + /** + * @type {!Object} + * @private + */ + private typedBlocksDB_; + /** + * A map from variable type to list of variable names. The lists contain all + * of the named variables in the workspace, including variables + * that are not currently in use. + * @type {!VariableMap} + * @private + */ + private variableMap_; + /** + * Blocks in the flyout can refer to variables that don't exist in the main + * workspace. For instance, the "get item in list" block refers to an "item" + * variable regardless of whether the variable has been created yet. + * A FieldVariable must always refer to a VariableModel. We reconcile + * these by tracking "potential" variables in the flyout. These variables + * become real when references to them are dragged into the main workspace. + * @type {?VariableMap} + * @private + */ + private potentialVariableMap_; + /** + * Dispose of this workspace. + * Unlink from all DOM elements to prevent memory leaks. + * @suppress {checkTypes} + */ + dispose(): void; + /** + * Compare function for sorting objects (blocks, comments, etc) by position; + * top to bottom (with slight LTR or RTL bias). + * @param {!Block | !WorkspaceComment} a The first object to + * compare. + * @param {!Block | !WorkspaceComment} b The second object to + * compare. + * @return {number} The comparison value. This tells Array.sort() how to change + * object a's index. + * @private + */ + private sortObjects_; + /** + * Adds a block to the list of top blocks. + * @param {!Block} block Block to add. + */ + addTopBlock(block: Block): void; + /** + * Removes a block from the list of top blocks. + * @param {!Block} block Block to remove. + */ + removeTopBlock(block: Block): void; + /** + * Finds the top-level blocks and returns them. Blocks are optionally sorted + * by position; top to bottom (with slight LTR or RTL bias). + * @param {boolean} ordered Sort the list if true. + * @return {!Array} The top-level block objects. + */ + getTopBlocks(ordered: boolean): Array; + /** + * Add a block to the list of blocks keyed by type. + * @param {!Block} block Block to add. + */ + addTypedBlock(block: Block): void; + /** + * Remove a block from the list of blocks keyed by type. + * @param {!Block} block Block to remove. + */ + removeTypedBlock(block: Block): void; + /** + * Finds the blocks with the associated type and returns them. Blocks are + * optionally sorted by position; top to bottom (with slight LTR or RTL bias). + * @param {string} type The type of block to search for. + * @param {boolean} ordered Sort the list if true. + * @return {!Array} The blocks of the given type. + */ + getBlocksByType(type: string, ordered: boolean): Array; + /** + * Adds a comment to the list of top comments. + * @param {!WorkspaceComment} comment comment to add. + * @package + */ + addTopComment(comment: WorkspaceComment): void; + /** + * Removes a comment from the list of top comments. + * @param {!WorkspaceComment} comment comment to remove. + * @package + */ + removeTopComment(comment: WorkspaceComment): void; + /** + * Finds the top-level comments and returns them. Comments are optionally + * sorted by position; top to bottom (with slight LTR or RTL bias). + * @param {boolean} ordered Sort the list if true. + * @return {!Array} The top-level comment objects. + * @package + */ + getTopComments(ordered: boolean): Array; + /** + * Find all blocks in workspace. Blocks are optionally sorted + * by position; top to bottom (with slight LTR or RTL bias). + * @param {boolean} ordered Sort the list if true. + * @return {!Array} Array of blocks. + */ + getAllBlocks(ordered: boolean): Array; + /** + * Dispose of all blocks and comments in workspace. + */ + clear(): void; + isClearing: boolean; + /** + * Rename a variable by updating its name in the variable map. Identify the + * variable to rename with the given ID. + * @param {string} id ID of the variable to rename. + * @param {string} newName New variable name. + */ + renameVariableById(id: string, newName: string): void; + /** + * Create a variable with a given name, optional type, and optional ID. + * @param {string} name The name of the variable. This must be unique across + * variables and procedures. + * @param {?string=} opt_type The type of the variable like 'int' or 'string'. + * Does not need to be unique. Field_variable can filter variables based on + * their type. This will default to '' which is a specific type. + * @param {?string=} opt_id The unique ID of the variable. This will default to + * a UUID. + * @return {!VariableModel} The newly created variable. + */ + createVariable(name: string, opt_type?: (string | null) | undefined, opt_id?: (string | null) | undefined): VariableModel; + /** + * Find all the uses of the given variable, which is identified by ID. + * @param {string} id ID of the variable to find. + * @return {!Array} Array of block usages. + */ + getVariableUsesById(id: string): Array; + /** + * Delete a variables by the passed in ID and all of its uses from this + * workspace. May prompt the user for confirmation. + * @param {string} id ID of variable to delete. + */ + deleteVariableById(id: string): void; + /** + * Find the variable by the given name and return it. Return null if not found. + * @param {string} name The name to check for. + * @param {string=} opt_type The type of the variable. If not provided it + * defaults to the empty string, which is a specific type. + * @return {?VariableModel} The variable with the given name. + */ + getVariable(name: string, opt_type?: string | undefined): VariableModel | null; + /** + * Find the variable by the given ID and return it. Return null if not found. + * @param {string} id The ID to check for. + * @return {?VariableModel} The variable with the given ID. + */ + getVariableById(id: string): VariableModel | null; + /** + * Find the variable with the specified type. If type is null, return list of + * variables with empty string type. + * @param {?string} type Type of the variables to find. + * @return {!Array} The sought after variables of the + * passed in type. An empty array if none are found. + */ + getVariablesOfType(type: string | null): Array; + /** + * Return all variable types. + * @return {!Array} List of variable types. + * @package + */ + getVariableTypes(): Array; + /** + * Return all variables of all types. + * @return {!Array} List of variable models. + */ + getAllVariables(): Array; + /** + * Returns all variable names of all types. + * @return {!Array} List of all variable names of all types. + */ + getAllVariableNames(): Array; + /** + * Returns the horizontal offset of the workspace. + * Intended for LTR/RTL compatibility in XML. + * Not relevant for a headless workspace. + * @return {number} Width. + */ + getWidth(): number; + /** + * Obtain a newly created block. + * @param {!string} prototypeName Name of the language object containing + * type-specific functions for this block. + * @param {string=} opt_id Optional ID. Use this ID if provided, otherwise + * create a new ID. + * @return {!Block} The created block. + */ + newBlock(prototypeName: string, opt_id?: string | undefined): Block; + /** + * The number of blocks that may be added to the workspace before reaching + * the maxBlocks. + * @return {number} Number of blocks left. + */ + remainingCapacity(): number; + /** + * The number of blocks of the given type that may be added to the workspace + * before reaching the maxInstances allowed for that type. + * @param {string} type Type of block to return capacity for. + * @return {number} Number of blocks of type left. + */ + remainingCapacityOfType(type: string): number; + /** + * Check if there is remaining capacity for blocks of the given counts to be + * created. If the total number of blocks represented by the map is more than + * the total remaining capacity, it returns false. If a type count is more + * than the remaining capacity for that type, it returns false. + * @param {!Object} typeCountsMap A map of types to counts (usually representing + * blocks to be created). + * @return {boolean} True if there is capacity for the given map, + * false otherwise. + */ + isCapacityAvailable(typeCountsMap: any): boolean; + /** + * Checks if the workspace has any limits on the maximum number of blocks, + * or the maximum number of blocks of specific types. + * @return {boolean} True if it has block limits, false otherwise. + */ + hasBlockLimits(): boolean; + /** + * Gets the undo stack for workplace. + * @return {!Array} undo stack + * @package + */ + getUndoStack(): Array; + /** + * Gets the redo stack for workplace. + * @return {!Array} redo stack + * @package + */ + getRedoStack(): Array; + /** + * Undo or redo the previous action. + * @param {boolean} redo False if undo, true if redo. + */ + undo(redo: boolean): void; + /** + * Clear the undo/redo stacks. + */ + clearUndo(): void; + /** + * When something in this workspace changes, call a function. + * Note that there may be a few recent events already on the stack. Thus the + * new change listener might be called with events that occurred a few + * milliseconds before the change listener was added. + * @param {!Function} func Function to call. + * @return {!Function} Obsolete return value, ignore. + */ + addChangeListener(func: Function): Function; + /** + * Stop listening for this workspace's changes. + * @param {!Function} func Function to stop calling. + */ + removeChangeListener(func: Function): void; + /** + * Fire a change event. + * @param {!Abstract} event Event to fire. + */ + fireChangeListener(event: typeof Abstract): void; + /** + * Find the block on this workspace with the specified ID. + * @param {string} id ID of block to find. + * @return {?Block} The sought after block, or null if not found. + */ + getBlockById(id: string): Block | null; + /** + * Set a block on this workspace with the specified ID. + * @param {string} id ID of block to set. + * @param {Block} block The block to set. + * @package + */ + setBlockById(id: string, block: Block): void; + /** + * Delete a block off this workspace with the specified ID. + * @param {string} id ID of block to delete. + * @package + */ + removeBlockById(id: string): void; + /** + * Find the comment on this workspace with the specified ID. + * @param {string} id ID of comment to find. + * @return {?WorkspaceComment} The sought after comment, or null if not + * found. + * @package + */ + getCommentById(id: string): WorkspaceComment | null; + /** + * Checks whether all value and statement inputs in the workspace are filled + * with blocks. + * @param {boolean=} opt_shadowBlocksAreFilled An optional argument controlling + * whether shadow blocks are counted as filled. Defaults to true. + * @return {boolean} True if all inputs are filled, false otherwise. + */ + allInputsFilled(opt_shadowBlocksAreFilled?: boolean | undefined): boolean; + /** + * Return the variable map that contains "potential" variables. + * These exist in the flyout but not in the workspace. + * @return {?VariableMap} The potential variable map. + * @package + */ + getPotentialVariableMap(): VariableMap | null; + /** + * Create and store the potential variable map for this workspace. + * @package + */ + createPotentialVariableMap(): void; + /** + * Return the map of all variables on the workspace. + * @return {!VariableMap} The variable map. + */ + getVariableMap(): VariableMap; + /** + * Set the map of all variables on the workspace. + * @param {!VariableMap} variableMap The variable map. + * @package + */ + setVariableMap(variableMap: VariableMap): void; + /** + * Returns `true` if the workspace is visible and `false` if it's headless. + * @type {boolean} + */ + rendered: boolean; + /** + * Maximum number of undo events in stack. `0` turns off undo, `Infinity` sets + * it to unlimited. + * @type {number} + */ + MAX_UNDO: number; + /** + * Set of databases for rapid lookup of connection locations. + * @type {Array} + */ + connectionDBList: Array; + } + export namespace Workspace { + const SCAN_ANGLE: number; + } + import { Options } from "options"; + import * as toolbox from "utils/toolbox"; + import { IConnectionChecker } from "interfaces/i_connection_checker"; + import * as Abstract from "events/events_abstract"; + import { Block } from "block"; + import { WorkspaceComment } from "workspace_comment"; + import { VariableModel } from "variable_model"; + import { VariableMap } from "variable_map"; + import { ConnectionDB } from "connection_db"; +} +declare module "events/events_var_create" { + /** + * Class for a variable creation event. + * @param {!VariableModel=} opt_variable The created variable. Undefined + * for a blank event. + * @extends {VarBase} + * @constructor + * @alias Blockly.Events.VarCreate + */ + export class VarCreate { + constructor(opt_variable: any); + varType: any; + varName: any; + /** + * Encode the event as JSON. + * @return {!Object} JSON representation. + */ + toJson(): any; + /** + * Decode the JSON event. + * @param {!Object} json JSON representation. + */ + fromJson(json: any): void; + /** + * Run a variable creation event. + * @param {boolean} forward True if run forward, false if run backward (undo). + */ + run(forward: boolean): void; + /** + * Type of this event. + * @type {string} + */ + type: string; + } +} +declare module "variable_model" { + /** + * Class for a variable model. + * Holds information for the variable including name, ID, and type. + * @param {!Workspace} workspace The variable's workspace. + * @param {string} name The name of the variable. This is the user-visible name + * (e.g. 'my var' or '私の変数'), not the generated name. + * @param {string=} opt_type The type of the variable like 'int' or 'string'. + * Does not need to be unique. Field_variable can filter variables based on + * their type. This will default to '' which is a specific type. + * @param {string=} opt_id The unique ID of the variable. This will default to + * a UUID. + * @see {Blockly.FieldVariable} + * @constructor + * @alias Blockly.VariableModel + */ + export class VariableModel { + /** + * A custom compare function for the VariableModel objects. + * @param {VariableModel} var1 First variable to compare. + * @param {VariableModel} var2 Second variable to compare. + * @return {number} -1 if name of var1 is less than name of var2, 0 if equal, + * and 1 if greater. + * @package + */ + static compareByName(var1: VariableModel, var2: VariableModel): number; + constructor(workspace: any, name: any, opt_type: any, opt_id: any); + /** + * The workspace the variable is in. + * @type {!Workspace} + */ + workspace: Workspace; + /** + * The name of the variable, typically defined by the user. It may be + * changed by the user. + * @type {string} + */ + name: string; + /** + * The type of the variable, such as 'int' or 'sound_effect'. This may be + * used to build a list of variables of a specific type. By default this is + * the empty string '', which is a specific type. + * @see {Blockly.FieldVariable} + * @type {string} + */ + type: string; + /** + * A unique ID for the variable. This should be defined at creation and + * not change, even if the name changes. In most cases this should be a + * UUID. + * @type {string} + * @private + */ + private id_; + /** + * @return {string} The ID for the variable. + */ + getId(): string; + } + import { Workspace } from "workspace"; +} +declare module "variables" { + /** + * Find all user-created variables that are in use in the workspace. + * For use by generators. + * To get a list of all variables on a workspace, including unused variables, + * call Workspace.getAllVariables. + * @param {!Workspace} ws The workspace to search for variables. + * @return {!Array} Array of variable models. + * @alias Blockly.Variables.allUsedVarModels + */ + export function allUsedVarModels(ws: Workspace): Array; + /** + * Find all developer variables used by blocks in the workspace. + * Developer variables are never shown to the user, but are declared as global + * variables in the generated code. + * To declare developer variables, define the getDeveloperVariables function on + * your block and return a list of variable names. + * For use by generators. + * @param {!Workspace} workspace The workspace to search. + * @return {!Array} A list of non-duplicated variable names. + * @alias Blockly.Variables.allDeveloperVariables + */ + export function allDeveloperVariables(workspace: Workspace): Array; + /** + * Construct the elements (blocks and button) required by the flyout for the + * variable category. + * @param {!Workspace} workspace The workspace containing variables. + * @return {!Array} Array of XML elements. + * @alias Blockly.Variables.flyoutCategory + */ + export function flyoutCategory(workspace: Workspace): Array; + /** + * Construct the blocks required by the flyout for the variable category. + * @param {!Workspace} workspace The workspace containing variables. + * @return {!Array} Array of XML block elements. + * @alias Blockly.Variables.flyoutCategoryBlocks + */ + export function flyoutCategoryBlocks(workspace: Workspace): Array; + /** + * @alias Blockly.Variables.VAR_LETTER_OPTIONS + */ + export const VAR_LETTER_OPTIONS: "ijkmnopqrstuvwxyzabcdefgh"; + /** + * Return a new variable name that is not yet being used. This will try to + * generate single letter variable names in the range 'i' to 'z' to start with. + * If no unique name is located it will try 'i' to 'z', 'a' to 'h', + * then 'i2' to 'z2' etc. Skip 'l'. + * @param {!Workspace} workspace The workspace to be unique in. + * @return {string} New variable name. + * @alias Blockly.Variables.generateUniqueName + */ + export function generateUniqueName(workspace: Workspace): string; + /** + * Returns a unique name that is not present in the usedNames array. This + * will try to generate single letter names in the range a -> z (skip l). It + * will start with the character passed to startChar. + * @param {string} startChar The character to start the search at. + * @param {!Array} usedNames A list of all of the used names. + * @return {string} A unique name that is not present in the usedNames array. + * @alias Blockly.Variables.generateUniqueNameFromOptions + */ + export function generateUniqueNameFromOptions(startChar: string, usedNames: Array): string; + /** + * Handles "Create Variable" button in the default variables toolbox category. + * It will prompt the user for a variable name, including re-prompts if a name + * is already in use among the workspace's variables. + * + * Custom button handlers can delegate to this function, allowing variables + * types and after-creation processing. More complex customization (e.g., + * prompting for variable type) is beyond the scope of this function. + * + * @param {!Workspace} workspace The workspace on which to create the + * variable. + * @param {function(?string=)=} opt_callback A callback. It will be passed an + * acceptable new variable name, or null if change is to be aborted (cancel + * button), or undefined if an existing variable was chosen. + * @param {string=} opt_type The type of the variable like 'int', 'string', or + * ''. This will default to '', which is a specific type. + * @alias Blockly.Variables.createVariableButtonHandler + */ + export function createVariableButtonHandler(workspace: Workspace, opt_callback?: ((arg0: (string | null) | undefined) => any) | undefined, opt_type?: string | undefined): void; + /** + * Opens a prompt that allows the user to enter a new name for a variable. + * Triggers a rename if the new name is valid. Or re-prompts if there is a + * collision. + * @param {!Workspace} workspace The workspace on which to rename the + * variable. + * @param {!VariableModel} variable Variable to rename. + * @param {function(?string=)=} opt_callback A callback. It will + * be passed an acceptable new variable name, or null if change is to be + * aborted (cancel button), or undefined if an existing variable was chosen. + * @alias Blockly.Variables.renameVariable + */ + export function renameVariable(workspace: Workspace, variable: VariableModel, opt_callback?: ((arg0: (string | null) | undefined) => any) | undefined): void; + /** + * Prompt the user for a new variable name. + * @param {string} promptText The string of the prompt. + * @param {string} defaultText The default value to show in the prompt's field. + * @param {function(?string)} callback A callback. It will return the new + * variable name, or null if the user picked something illegal. + * @alias Blockly.Variables.promptName + */ + export function promptName(promptText: string, defaultText: string, callback: (arg0: string | null) => any): void; + /** + * Check whether there exists a variable with the given name of any type. + * @param {string} name The name to search for. + * @param {!Workspace} workspace The workspace to search for the + * variable. + * @return {?VariableModel} The variable with the given name, + * or null if none was found. + * @alias Blockly.Variables.nameUsedWithAnyType + */ + export function nameUsedWithAnyType(name: string, workspace: Workspace): VariableModel | null; + /** + * Generate DOM objects representing a variable field. + * @param {!VariableModel} variableModel The variable model to + * represent. + * @return {?Element} The generated DOM. + * @alias Blockly.Variables.generateVariableFieldDom + */ + export function generateVariableFieldDom(variableModel: VariableModel): Element | null; + /** + * Helper function to look up or create a variable on the given workspace. + * If no variable exists, creates and returns it. + * @param {!Workspace} workspace The workspace to search for the + * variable. It may be a flyout workspace or main workspace. + * @param {?string} id The ID to use to look up or create the variable, or null. + * @param {string=} opt_name The string to use to look up or create the + * variable. + * @param {string=} opt_type The type to use to look up or create the variable. + * @return {!VariableModel} The variable corresponding to the given ID + * or name + type combination. + * @alias Blockly.Variables.getOrCreateVariablePackage + */ + export function getOrCreateVariablePackage(workspace: Workspace, id: string | null, opt_name?: string | undefined, opt_type?: string | undefined): VariableModel; + /** + * Look up a variable on the given workspace. + * Always looks in the main workspace before looking in the flyout workspace. + * Always prefers lookup by ID to lookup by name + type. + * @param {!Workspace} workspace The workspace to search for the + * variable. It may be a flyout workspace or main workspace. + * @param {?string} id The ID to use to look up the variable, or null. + * @param {string=} opt_name The string to use to look up the variable. + * Only used if lookup by ID fails. + * @param {string=} opt_type The type to use to look up the variable. + * Only used if lookup by ID fails. + * @return {?VariableModel} The variable corresponding to the given ID + * or name + type combination, or null if not found. + * @alias Blockly.Variables.getVariable + */ + export function getVariable(workspace: Workspace, id: string | null, opt_name?: string | undefined, opt_type?: string | undefined): VariableModel | null; + /** + * Helper function to get the list of variables that have been added to the + * workspace after adding a new block, using the given list of variables that + * were in the workspace before the new block was added. + * @param {!Workspace} workspace The workspace to inspect. + * @param {!Array} originalVariables The array of + * variables that existed in the workspace before adding the new block. + * @return {!Array} The new array of variables that + * were freshly added to the workspace after creating the new block, + * or [] if no new variables were added to the workspace. + * @alias Blockly.Variables.getAddedVariables + * @package + */ + export function getAddedVariables(workspace: Workspace, originalVariables: Array): Array; + import { Workspace } from "workspace"; + import { VariableModel } from "variable_model"; +} +declare module "events/events_block_base" { + /** + * Abstract class for a block event. + * @param {!Block=} opt_block The block this event corresponds to. + * Undefined for a blank event. + * @extends {Abstract} + * @constructor + * @alias Blockly.Events.BlockBase + */ + export class BlockBase { + constructor(opt_block: any); + isBlank: boolean; + /** + * The block ID for the block this event pertains to + * @type {string} + */ + blockId: string; + /** + * The workspace identifier for this event. + * @type {string} + */ + workspaceId: string; + /** + * Encode the event as JSON. + * @return {!Object} JSON representation. + */ + toJson(): any; + /** + * Decode the JSON event. + * @param {!Object} json JSON representation. + */ + fromJson(json: any): void; + } +} +declare module "events/events_block_change" { + export class BlockChange { + /** + * Returns the extra state of the given block (either as XML or a JSO, depending + * on the block's definition). + * @param {!BlockSvg} block The block to get the extra state of. + * @return {string} A stringified version of the extra state of the given block. + * @package + */ + static getExtraBlockState_(block: BlockSvg): string; + /** + * Class for a block change event. + * @param {!Block=} opt_block The changed block. Undefined for a blank + * event. + * @param {string=} opt_element One of 'field', 'comment', 'disabled', etc. + * @param {?string=} opt_name Name of input or field affected, or null. + * @param {*=} opt_oldValue Previous value of element. + * @param {*=} opt_newValue New value of element. + * @extends {BlockBase} + * @constructor + * @alias Blockly.Events.BlockChange + */ + constructor(opt_block?: Block | undefined, opt_element?: string | undefined, opt_name?: (string | null) | undefined, opt_oldValue?: any | undefined, opt_newValue?: any | undefined); + element: string; + name: string; + oldValue: any; + newValue: any; + /** + * Encode the event as JSON. + * @return {!Object} JSON representation. + */ + toJson(): any; + /** + * Decode the JSON event. + * @param {!Object} json JSON representation. + */ + fromJson(json: any): void; + /** + * Does this event record any change of state? + * @return {boolean} False if something changed. + */ + isNull(): boolean; + /** + * Run a change event. + * @param {boolean} forward True if run forward, false if run backward (undo). + */ + run(forward: boolean): void; + /** + * Type of this event. + * @type {string} + */ + type: string; + } + import { BlockSvg } from "block_svg"; + import { Block } from "block"; +} +declare module "procedures" { + /** + * The default argument for a procedures_mutatorarg block. * @type {string} + * @alias Blockly.Procedures.DEFAULT_ARG + */ + export const DEFAULT_ARG: string; + /** + * Procedure block type. + */ + export type ProcedureBlock = { + getProcedureCall: () => string; + renameProcedure: (arg0: string, arg1: string) => any; + getProcedureDef: () => any[]; + }; + /** + * Procedure block type. + * @typedef {{ + * getProcedureCall: function():string, + * renameProcedure: function(string,string), + * getProcedureDef: function():!Array + * }} + * @alias Blockly.Procedures.ProcedureBlock + */ + export let ProcedureBlock: any; + /** + * Find all user-created procedure definitions in a workspace. + * @param {!Workspace} root Root workspace. + * @return {!Array>} Pair of arrays, the + * first contains procedures without return variables, the second with. + * Each procedure is defined by a three-element list of name, parameter + * list, and return value boolean. + * @alias Blockly.Procedures.allProcedures + */ + export function allProcedures(root: Workspace): Array>; + /** + * Ensure two identically-named procedures don't exist. + * Take the proposed procedure name, and return a legal name i.e. one that + * is not empty and doesn't collide with other procedures. + * @param {string} name Proposed procedure name. + * @param {!Block} block Block to disambiguate. + * @return {string} Non-colliding name. + * @alias Blockly.Procedures.findLegalName + */ + export function findLegalName(name: string, block: Block): string; + /** + * Return if the given name is already a procedure name. + * @param {string} name The questionable name. + * @param {!Workspace} workspace The workspace to scan for collisions. + * @param {Block=} opt_exclude Optional block to exclude from + * comparisons (one doesn't want to collide with oneself). + * @return {boolean} True if the name is used, otherwise return false. + * @alias Blockly.Procedures.isNameUsed + */ + export function isNameUsed(name: string, workspace: Workspace, opt_exclude?: Block | undefined): boolean; + /** + * Rename a procedure. Called by the editable field. + * @param {string} name The proposed new name. + * @return {string} The accepted name. + * @this {Field} + * @alias Blockly.Procedures.rename + */ + export function rename(name: string): string; + /** + * Construct the blocks required by the flyout for the procedure category. + * @param {!Workspace} workspace The workspace containing procedures. + * @return {!Array} Array of XML block elements. + * @alias Blockly.Procedures.flyoutCategory + */ + export function flyoutCategory(workspace: Workspace): Array; + /** + * Listens for when a procedure mutator is opened. Then it triggers a flyout + * update and adds a mutator change listener to the mutator workspace. + * @param {!Abstract} e The event that triggered this listener. + * @alias Blockly.Procedures.mutatorOpenListener + * @package + */ + export function mutatorOpenListener(e: typeof Abstract): void; + /** + * Find all the callers of a named procedure. + * @param {string} name Name of procedure. + * @param {!Workspace} workspace The workspace to find callers in. + * @return {!Array} Array of caller blocks. + * @alias Blockly.Procedures.getCallers + */ + export function getCallers(name: string, workspace: Workspace): Array; + /** + * When a procedure definition changes its parameters, find and edit all its + * callers. + * @param {!Block} defBlock Procedure definition block. + * @alias Blockly.Procedures.mutateCallers + */ + export function mutateCallers(defBlock: Block): void; + /** + * Find the definition block for the named procedure. + * @param {string} name Name of procedure. + * @param {!Workspace} workspace The workspace to search. + * @return {?Block} The procedure definition block, or null not found. + * @alias Blockly.Procedures.getDefinition + */ + export function getDefinition(name: string, workspace: Workspace): Block | null; + import { Workspace } from "workspace"; + import { Block } from "block"; + import * as Abstract from "events/events_abstract"; +} +declare module "variables_dynamic" { + function stringButtonClickHandler(button: any): void; + function numberButtonClickHandler(button: any): void; + function colourButtonClickHandler(button: any): void; + /** + * Construct the elements (blocks and button) required by the flyout for the + * variable category. + * @param {!Workspace} workspace The workspace containing variables. + * @return {!Array} Array of XML elements. + * @alias Blockly.VariablesDynamic.flyoutCategory + */ + export function flyoutCategory(workspace: Workspace): Array; + /** + * Construct the blocks required by the flyout for the variable category. + * @param {!Workspace} workspace The workspace containing variables. + * @return {!Array} Array of XML block elements. + * @alias Blockly.VariablesDynamic.flyoutCategoryBlocks + */ + export function flyoutCategoryBlocks(workspace: Workspace): Array; + import { Workspace } from "workspace"; + export { stringButtonClickHandler as onCreateVariableButtonClick_String, numberButtonClickHandler as onCreateVariableButtonClick_Number, colourButtonClickHandler as onCreateVariableButtonClick_Colour }; +} +declare module "renderers/common/debug" { + /** + * Returns whether the debugger is turned on. + * @return {boolean} Whether the debugger is turned on. + * @alias Blockly.blockRendering.debug.isDebuggerEnabled + * @package + */ + export function isDebuggerEnabled(): boolean; + /** + * Turn on the blocks debugger. + * @package + * @alias Blockly.blockRendering.debug.startDebugger + */ + export function startDebugger(): void; + /** + * Turn off the blocks debugger. + * @package + * @alias Blockly.blockRendering.debug.stopDebugger + */ + export function stopDebugger(): void; +} +declare module "renderers/common/constants" { + /** + * An object that provides constants for rendering blocks. + * @constructor + * @package + * @alias Blockly.blockRendering.ConstantProvider + */ + export class ConstantProvider { + /** + * The size of an empty spacer. + * @type {number} + */ + NO_PADDING: number; + /** + * The size of small padding. + * @type {number} + */ + SMALL_PADDING: number; + /** + * The size of medium padding. + * @type {number} + */ + MEDIUM_PADDING: number; + /** + * The size of medium-large padding. + * @type {number} + */ + MEDIUM_LARGE_PADDING: number; + /** + * The size of large padding. + * @type {number} + */ + LARGE_PADDING: number; + /** + * Offset from the top of the row for placing fields on inline input rows + * and statement input rows. + * Matches existing rendering (in 2019). + * @type {number} + */ + TALL_INPUT_FIELD_OFFSET_Y: number; + /** + * The height of the puzzle tab used for input and output connections. + * @type {number} + */ + TAB_HEIGHT: number; + /** + * The offset from the top of the block at which a puzzle tab is positioned. + * @type {number} + */ + TAB_OFFSET_FROM_TOP: number; + /** + * Vertical overlap of the puzzle tab, used to make it look more like a puzzle + * piece. + * @type {number} + */ + TAB_VERTICAL_OVERLAP: number; + /** + * The width of the puzzle tab used for input and output connections. + * @type {number} + */ + TAB_WIDTH: number; + /** + * The width of the notch used for previous and next connections. + * @type {number} + */ + NOTCH_WIDTH: number; + /** + * The height of the notch used for previous and next connections. + * @type {number} + */ + NOTCH_HEIGHT: number; + /** + * The minimum width of the block. + * @type {number} + */ + MIN_BLOCK_WIDTH: number; + EMPTY_BLOCK_SPACER_HEIGHT: number; + /** + * The minimum height of a dummy input row. + * @type {number} + */ + DUMMY_INPUT_MIN_HEIGHT: number; + /** + * The minimum height of a dummy input row in a shadow block. + * @type {number} + */ + DUMMY_INPUT_SHADOW_MIN_HEIGHT: number; + /** + * Rounded corner radius. + * @type {number} + */ + CORNER_RADIUS: number; + /** + * Offset from the left side of a block or the inside of a statement input to + * the left side of the notch. + * @type {number} + */ + NOTCH_OFFSET_LEFT: number; + /** + * Additional offset added to the statement input's width to account for the + * notch. + * @type {number} + */ + STATEMENT_INPUT_NOTCH_OFFSET: number; + STATEMENT_BOTTOM_SPACER: number; + STATEMENT_INPUT_PADDING_LEFT: number; + /** + * Vertical padding between consecutive statement inputs. + * @type {number} + */ + BETWEEN_STATEMENT_PADDING_Y: number; + /** + * The top row's minimum height. + * @type {number} + */ + TOP_ROW_MIN_HEIGHT: number; + /** + * The top row's minimum height if it precedes a statement. + * @type {number} + */ + TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT: number; + /** + * The bottom row's minimum height. + * @type {number} + */ + BOTTOM_ROW_MIN_HEIGHT: number; + /** + * The bottom row's minimum height if it follows a statement input. + * @type {number} + */ + BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT: number; + /** + * Whether to add a 'hat' on top of all blocks with no previous or output + * connections. Can be overridden by 'hat' property on Theme.BlockStyle. + * @type {boolean} + */ + ADD_START_HATS: boolean; + /** + * Height of the top hat. + * @type {number} + */ + START_HAT_HEIGHT: number; + /** + * Width of the top hat. + * @type {number} + */ + START_HAT_WIDTH: number; + SPACER_DEFAULT_HEIGHT: number; + MIN_BLOCK_HEIGHT: number; + EMPTY_INLINE_INPUT_PADDING: number; + /** + * The height of an empty inline input. + * @type {number} + */ + EMPTY_INLINE_INPUT_HEIGHT: number; + EXTERNAL_VALUE_INPUT_PADDING: number; + /** + * The height of an empty statement input. Note that in the old rendering + * this varies slightly depending on whether the block has external or inline + * inputs. In the new rendering this is consistent. It seems unlikely that + * the old behaviour was intentional. + * @type {number} + */ + EMPTY_STATEMENT_INPUT_HEIGHT: number; + START_POINT: string; + /** + * Height of SVG path for jagged teeth at the end of collapsed blocks. + * @type {number} + */ + JAGGED_TEETH_HEIGHT: number; + /** + * Width of SVG path for jagged teeth at the end of collapsed blocks. + * @type {number} + */ + JAGGED_TEETH_WIDTH: number; + /** + * Point size of text. + * @type {number} + */ + FIELD_TEXT_FONTSIZE: number; + /** + * Text font weight. + * @type {string} + */ + FIELD_TEXT_FONTWEIGHT: string; + /** + * Text font family. + * @type {string} + */ + FIELD_TEXT_FONTFAMILY: string; + /** + * Height of text. This constant is dynamically set in ``setFontConstants_`` + * to be the height of the text based on the font used. + * @type {number} + */ + FIELD_TEXT_HEIGHT: number; + /** + * Text baseline. This constant is dynamically set in ``setFontConstants_`` + * to be the baseline of the text based on the font used. + * @type {number} + */ + FIELD_TEXT_BASELINE: number; + /** + * A field's border rect corner radius. + * @type {number} + */ + FIELD_BORDER_RECT_RADIUS: number; + /** + * A field's border rect default height. + * @type {number} + */ + FIELD_BORDER_RECT_HEIGHT: number; + /** + * A field's border rect X padding. + * @type {number} + */ + FIELD_BORDER_RECT_X_PADDING: number; + /** + * A field's border rect Y padding. + * @type {number} + */ + FIELD_BORDER_RECT_Y_PADDING: number; + /** + * The backing colour of a field's border rect. + * @type {string} + * @package + */ + FIELD_BORDER_RECT_COLOUR: string; + /** + * A field's text element's dominant baseline. + * @type {boolean} + */ + FIELD_TEXT_BASELINE_CENTER: boolean; + /** + * A dropdown field's border rect height. + * @type {number} + */ + FIELD_DROPDOWN_BORDER_RECT_HEIGHT: number; + /** + * Whether or not a dropdown field should add a border rect when in a shadow + * block. + * @type {boolean} + */ + FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW: boolean; + /** + * Whether or not a dropdown field's div should be coloured to match the + * block colours. + * @type {boolean} + */ + FIELD_DROPDOWN_COLOURED_DIV: boolean; + /** + * Whether or not a dropdown field uses a text or SVG arrow. + * @type {boolean} + */ + FIELD_DROPDOWN_SVG_ARROW: boolean; + /** + * A dropdown field's SVG arrow padding. + * @type {number} + */ + FIELD_DROPDOWN_SVG_ARROW_PADDING: number; + /** + * A dropdown field's SVG arrow size. + * @type {number} + */ + FIELD_DROPDOWN_SVG_ARROW_SIZE: number; + /** + * A dropdown field's SVG arrow datauri. + * @type {string} + */ + FIELD_DROPDOWN_SVG_ARROW_DATAURI: string; + /** + * Whether or not to show a box shadow around the widget div. This is only a + * feature of full block fields. + * @type {boolean} + */ + FIELD_TEXTINPUT_BOX_SHADOW: boolean; + /** + * Whether or not the colour field should display its colour value on the + * entire block. + * @type {boolean} + */ + FIELD_COLOUR_FULL_BLOCK: boolean; + /** + * A colour field's default width. + * @type {number} + */ + FIELD_COLOUR_DEFAULT_WIDTH: number; + /** + * A colour field's default height. + * @type {number} + */ + FIELD_COLOUR_DEFAULT_HEIGHT: number; + /** + * A checkbox field's X offset. + * @type {number} + */ + FIELD_CHECKBOX_X_OFFSET: number; + /** + * A random identifier used to ensure a unique ID is used for each + * filter/pattern for the case of multiple Blockly instances on a page. + * @type {string} + * @package + */ + randomIdentifier: string; + /** + * The defs tag that contains all filters and patterns for this Blockly + * instance. + * @type {?SVGElement} + * @private + */ + private defs_; + /** + * The ID of the emboss filter, or the empty string if no filter is set. + * @type {string} + * @package + */ + embossFilterId: string; + /** + * The element to use for highlighting, or null if not set. + * @type {SVGElement} + * @private + */ + private embossFilter_; + /** + * The ID of the disabled pattern, or the empty string if no pattern is set. + * @type {string} + * @package + */ + disabledPatternId: string; + /** + * The element to use for disabled blocks, or null if not set. + * @type {SVGElement} + * @private + */ + private disabledPattern_; + /** + * The ID of the debug filter, or the empty string if no pattern is set. + * @type {string} + * @package + */ + debugFilterId: string; + /** + * The element to use for a debug highlight, or null if not set. + * @type {SVGElement} + * @private + */ + private debugFilter_; + /** + * The