pxt-core-own
Version:
Microsoft MakeCode, also known as Programming Experience Toolkit (PXT), provides Blocks / JavaScript tools and editors
1,385 lines (1,238 loc) • 650 kB
TypeScript
/**
* @license
* PXT Blockly
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* https://github.com/Microsoft/pxt-blockly
*
* See LICENSE file for details.
*/
declare module Blockly {
/**
* Interfaces
*/
interface Metrics {
absoluteLeft: number;
absoluteTop: number;
contentHeight: number;
contentLeft: number;
contentTop: number;
contentWidth: number;
viewHeight: number;
viewLeft: number;
viewTop: number;
viewWidth: number;
}
interface ImageJson {
width: number;
height: number;
src: string;
}
namespace ContextMenu {
interface MenuItem {
enabled?: boolean;
text?: string;
callback?: () => void;
}
}
}
declare module Blockly {
interface Colours {
text: string;
workspace: string;
toolboxHover: string;
toolboxSelected: string;
toolboxText: string;
toolbox: string;
flyout: string;
scrollbar: string;
scrollbarHover: string;
textField: string;
insertionMarker: string;
insertionMarkerOpacity: number;
dragShadowOpacity: number;
stackGlow: string;
stackGlowSize: number;
stackGlowOpacity: number;
replacementGlow: string;
replacementGlowSize: number;
replacementGlowOpacity: number;
highlightGlow: string;
highlightGlowSize: number;
highlightGlowOpacity: number;
selectedGlow: string;
selectedGlowSize: number;
warningGlow: string;
warningGlowSize: number;
warningGlowOpacity: number;
colourPickerStroke: string;
// CSS colours: support RGBA
fieldShadow: string;
dropDownShadow: string;
numPadBackground: string;
numPadBorder: string;
numPadActiveBackground: string;
numPadText: string;
valueReportBackground: string;
valueReportBorder: string;
// Center on block transition
canvasTransitionLength: number;
}
}
declare module Blockly {
interface WorkspaceOptions {
readOnly?: boolean;
toolbox?: Element | string;
hasCategories?: boolean;
trashcan?: boolean;
collapse?: boolean;
comments?: boolean;
disable?: boolean;
scrollbars?: boolean;
sound?: boolean;
css?: boolean;
media?: string;
horizontalLayout?: boolean;
toolboxPosition?: string;
grid?: {
spacing?: number;
length?: number;
colour?: string;
snap?: boolean;
};
zoom?: {
enabled?: boolean;
controls?: boolean;
wheel?: boolean;
maxScale?: number;
minScale?: number;
scaleSpeed?: number;
startScale?: number;
};
enableRealTime?: boolean;
rtl?: boolean;
// PXT specific:
toolboxOptions?: ToolboxOptions;
}
interface ToolboxOptions {
colour?: boolean;
border?: boolean;
inverted?: boolean;
invertedMultiplier?: number;
disabledOpacity?: number;
}
}
declare namespace goog {
function require(name: string): void;
function provide(name: string): void;
function isFunction(f: any): boolean;
function isString(s: any): boolean;
class Disposable {
dispose(): void;
}
namespace string {
let caseInsensitiveCompare: (a: string, b: string) => number;
}
namespace array {
function remove(ar: string[], v: string): void;
}
namespace dom {
function createDom(tagName: string, opt_attributes?: Object, ...var_args: Object[]): Element;
function createDom(name: string, ns?: string, children?: any): HTMLElement;
function removeChildren(el: Element): void;
function removeNode(node: Node): void;
function getViewportSize(): any;
namespace classlist {
function add(el: Element, className: string): void;
}
class DomHelper {
}
}
namespace math {
class Box {
top: number;
right: number;
bottom: number;
left: number;
constructor(top: number, right: number, bottom: number, left: number);
}
class Rect {
}
class Coordinate {
x: number;
y: number;
constructor(x: number, y: number);
clone(): Coordinate;
static difference(a: Coordinate, b: Coordinate): Coordinate;
static sum(a: Coordinate, b: Coordinate): Coordinate;
static magnitude(a: Coordinate): number;
}
class Size {
width: number;
height: number;
constructor(width: number, height: number);
}
function clamp(n: number, min: number, max: number): number;
function toRadians(n: number): number;
function toDegrees(n: number): number;
}
namespace color {
function lighten(rgb: number[], factor: number): number[];
function darken(rgb: number[], factor: number): number[];
function rgbArrayToHex(rgb: number[]): string;
function hexToRgb(hex: string): number[];
function hsvToHex(hue: number, sat: number, val: number): string;
}
namespace ui {
class Control extends Component {
getChildCount(): number;
getContent(): string | Node | Array<Node>;
getContentElement(): Element;
setChecked(checked: boolean): void;
setContent(content: string | Node | Array<Node>): void;
setVisible(visible: boolean, opt_force?: boolean): boolean;
}
class Component {
static EventType: {
BEFORE_SHOW: string;
SHOW: string;
HIDE: string;
DISABLE: string;
ENABLE: string;
HIGHLIGHT: string;
UNHIGHLIGHT: string;
ACTIVATE: string;
DEACTIVATE: string;
SELECT: string;
UNSELECT: string;
CHECK: string;
UNCHECK: string;
FOCUS: string;
BLUR: string;
OPEN: string;
CLOSE: string;
ENTER: string;
LEAVE: string;
ACTION: string;
CHANGE: string;
};
getHandler<T>(): events.EventHandler<T>;
getElement(): Element;
render(opt_parentElement?: Element): void;
setId(id: string): void;
setRightToLeft(rightToLeft: boolean): void;
addChild(child: Component, opt_render?: boolean): void;
getChildAt(index: number): Component;
removeChildren(opt_unrender: boolean): void;
}
class CustomButton extends Control {
title: string;
}
class Container extends Component {
}
class Menu extends Container implements events.Listenable {
listen: () => events.ListenableKey;
setAllowAutoFocus(allow: boolean): void;
}
class MenuItem extends Control {
constructor(content: (string | Node));
setCheckable(checkable: boolean): void;
setValue(value: any): void;
getValue(): any;
addClassName(className: string): void;
}
class Popup extends PopupBase {
setPosition(position: positioning.ClientPosition): void;
}
class PopupBase extends events.EventTarget {
}
class Tooltip extends Popup {
className: string;
cursorPosition: math.Coordinate;
constructor(opt_el?: Node | string, opt_str?: string);
onShow(): void;
setShowDelayMs(ms: number): void;
}
class Slider extends Component {
setMoveToPointEnabled(val: boolean): void;
setMinimum(min: number): void;
setMaximum(max: number): void;
setUnitIncrement(increments: number): void;
setRightToLeft(rightToLeft: boolean): void;
setValue(value: number): void;
animatedSetValue(value: number): void;
setOrientation(orientation: any): void;
setVisible(visible: boolean): void;
}
class ColorPicker extends Component {
static SIMPLE_GRID_COLORS: Array<string>;
setSize(value: goog.math.Size | number): void;
setColors(colurs: Array<string>): void;
setSelectedColor(color: string): void;
}
class ColorPalette extends Control {
constructor(opt_colors?: Array<string>);
setSize(value: goog.math.Size | number): void;
}
class DatePicker extends Component {
}
}
namespace ui.tree {
class BaseNode {
}
class TreeControl__Class {
}
class TreeNode__Class {
}
}
namespace style {
let backgroundColor: number;
function getBorderBox(element: Element): math.Box;
function getMarginBox(element: Element): math.Box;
function getPaddingBox(element: Element): math.Box;
function getSize(element: Element): math.Size;
function getViewportPageOffset(doc: Document): math.Coordinate;
function scrollIntoContainerView(element: Element, opt_container?: Element, opt_center?: boolean): void;
function setHeight(element: Element, height: number | string): void;
function setWidth(element: Element, width: number | string): void;
function getPageOffset(element: Element): math.Coordinate;
function setStyle(element: Element, style: string, value: string): void;
}
namespace events {
function listen(eventSource: Element | Listenable, eventType: EventType, listener: any, capturePhase?: boolean, handler?: Object): void;
function unlistenByKey(key: any): void;
interface ListenableKey {
key: number;
}
interface Listenable {
listen: () => ListenableKey;
}
type EventType = string;
let EventType: {
CLICK: EventType;
RIGHTCLICK: EventType;
DBLCLICK: EventType;
MOUSEDOWN: EventType;
MOUSEUP: EventType;
MOUSEOVER: EventType;
MOUSEOUT: EventType;
MOUSEMOVE: EventType;
MOUSEENTER: EventType;
MOUSELEAVE: EventType;
SELECTSTART: EventType;
WHEEL: EventType;
KEYPRESS: EventType;
KEYDOWN: EventType;
KEYUP: EventType;
BLUR: EventType;
FOCUS: EventType;
DEACTIVATE: EventType;
FOCUSIN: EventType;
FOCUSOUT: EventType;
CHANGE: EventType;
SELECT: EventType;
SUBMIT: EventType;
INPUT: EventType;
PROPERTYCHANGE: EventType;
DRAGSTART: EventType;
DRAG: EventType;
DRAGENTER: EventType;
DRAGOVER: EventType;
DRAGLEAVE: EventType;
DROP: EventType;
DRAGEND: EventType;
TOUCHSTART: EventType;
TOUCHMOVE: EventType;
TOUCHEND: EventType;
TOUCHCANCEL: EventType;
BEFOREUNLOAD: EventType;
CONSOLEMESSAGE: EventType;
CONTEXTMENU: EventType;
DOMCONTENTLOADED: EventType;
ERROR: EventType;
HELP: EventType;
LOAD: EventType;
LOSECAPTURE: EventType;
ORIENTATIONCHANGE: EventType;
READYSTATECHANGE: EventType;
RESIZE: EventType;
SCROLL: EventType;
UNLOAD: EventType;
HASHCHANGE: EventType;
PAGEHIDE: EventType;
PAGESHOW: EventType;
POPSTATE: EventType;
COPY: EventType;
PASTE: EventType;
CUT: EventType;
BEFORECOPY: EventType;
BEFORECUT: EventType;
BEFOREPASTE: EventType;
ONLINE: EventType;
OFFLINE: EventType;
MESSAGE: EventType;
CONNECT: EventType;
ANIMATIONSTART: EventType;
ANIMATIONEND: EventType;
ANIMATIONITERATION: EventType;
TRANSITIONEND: EventType;
POINTERDOWN: EventType;
POINTERUP: EventType;
POINTERCANCEL: EventType;
POINTERMOVE: EventType;
POINTEROVER: EventType;
POINTEROUT: EventType;
POINTERENTER: EventType;
POINTERLEAVE: EventType;
GOTPOINTERCAPTURE: EventType;
LOSTPOINTERCAPTURE: EventType;
MSGESTURECHANGE: EventType;
MSGESTUREEND: EventType;
MSGESTUREHOLD: EventType;
MSGESTURESTART: EventType;
MSGESTURETAP: EventType;
MSGOTPOINTERCAPTURE: EventType;
MSINERTIASTART: EventType;
MSLOSTPOINTERCAPTURE: EventType;
MSPOINTERCANCEL: EventType;
MSPOINTERDOWN: EventType;
MSPOINTERENTER: EventType;
MSPOINTERHOVER: EventType;
MSPOINTERLEAVE: EventType;
MSPOINTERMOVE: EventType;
MSPOINTEROUT: EventType;
MSPOINTEROVER: EventType;
MSPOINTERUP: EventType;
TEXT: EventType;
TEXTINPUT: EventType;
COMPOSITIONSTART: EventType;
COMPOSITIONUPDATE: EventType;
COMPOSITIONEND: EventType;
EXIT: EventType;
LOADABORT: EventType;
LOADCOMMIT: EventType;
LOADREDIRECT: EventType;
LOADSTART: EventType;
LOADSTOP: EventType;
RESPONSIVE: EventType;
SIZECHANGED: EventType;
UNRESPONSIVE: EventType;
VISIBILITYCHANGE: EventType;
STORAGE: EventType;
DOMSUBTREEMODIFIED: EventType;
DOMNODEINSERTED: EventType;
DOMNODEREMOVED: EventType;
DOMNODEREMOVEDFROMDOCUMENT: EventType;
DOMNODEINSERTEDINTODOCUMENT: EventType;
DOMATTRMODIFIED: EventType;
DOMCHARACTERDATAMODIFIED: EventType;
};
let KeyCodes: {
A: number,
ALT: number,
APOSTROPHE: number,
AT_SIGN: number,
B: number,
BACKSLASH: number,
BACKSPACE: number,
C: number,
CAPS_LOCK: number,
CLOSE_SQUARE_BRACKET: number,
COMMA: number,
CONTEXT_MENU: number,
CTRL: number,
D: number,
DASH: number,
DELETE: number,
DOWN: number,
E: number,
EIGHT: number,
END: number,
ENTER: number,
EQUALS: number,
ESC: number,
F: number,
F1: number,
F10: number,
F11: number,
F12: number,
F2: number,
F3: number,
F4: number,
F5: number,
F6: number,
F7: number,
F8: number,
F9: number,
FF_DASH: number,
FF_EQUALS: number,
FF_SEMICOLON: number,
FIRST_MEDIA_KEY: number,
FIVE: number,
FOUR: number,
G: number,
H: number,
HOME: number,
I: number,
INSERT: number,
J: number,
K: number,
L: number,
LAST_MEDIA_KEY: number,
LEFT: number,
M: number,
MAC_ENTER: number,
MAC_FF_META: number,
MAC_WK_CMD_LEFT: number,
MAC_WK_CMD_RIGHT: number,
META: number,
N: number,
NINE: number,
NUMLOCK: number,
NUM_CENTER: number,
NUM_DIVISION: number,
NUM_EIGHT: number,
NUM_FIVE: number,
NUM_FOUR: number,
NUM_MINUS: number,
NUM_MULTIPLY: number,
NUM_NINE: number,
NUM_ONE: number,
NUM_PERIOD: number,
NUM_PLUS: number,
NUM_SEVEN: number,
NUM_SIX: number,
NUM_THREE: number,
NUM_TWO: number,
NUM_ZERO: number,
O: number,
ONE: number,
OPEN_SQUARE_BRACKET: number,
P: number,
PAGE_DOWN: number,
PAGE_UP: number,
PAUSE: number,
PERIOD: number,
PHANTOM: number,
PLUS_SIGN: number,
PRINT_SCREEN: number,
Q: number,
QUESTION_MARK: number,
R: number,
RIGHT: number,
S: number,
SCROLL_LOCK: number,
SEMICOLON: number,
SEVEN: number,
SHIFT: number,
SINGLE_QUOTE: number,
SIX: number,
SLASH: number,
SPACE: number,
T: number,
TAB: number,
THREE: number,
TILDE: number,
TWO: number,
U: number,
UP: number,
V: number,
VK_NONAME: number,
W: number,
WIN_IME: number,
WIN_KEY: number,
WIN_KEY_FF_LINUX: number,
WIN_KEY_RIGHT: number,
X: number,
Y: number,
Z: number,
ZERO: number
}
class EventTarget extends Disposable {
}
class EventHandler<T> {
handleEvent(e: any): void;
listen(src: Element | Listenable, type: string, opt_fn?: any): EventHandler<T>;
}
/**
* Accepts a browser event object and creates a patched, cross browser event
* object.
* The content of this object will not be initialized if no event object is
* provided. If this is the case, init() needs to be invoked separately.
* @param {Event=} opt_e Browser event object.
* @param {EventTarget=} opt_currentTarget Current target for event.
*/
class BrowserEvent {
constructor(opt_e?: Event, opt_currentTarget?: EventTarget);
}
}
namespace userAgent {
/**
* Whether the user agent is running on a mobile device.
*
* TODO(nnaze): Consider deprecating MOBILE when labs.userAgent
* is promoted as the gecko/webkit logic is likely inaccurate.
*
* @type {boolean}
*/
var MOBILE: boolean;
/**
* Whether the user agent is running on Android.
* @type {boolean}
*/
var ANDROID: boolean;
/**
* Whether the user agent is running on an iPhone.
* @type {boolean}
*/
var IPHONE: boolean;
/**
* Whether the user agent is running on an iPad.
* @type {boolean}
*/
var IPAD: boolean;
}
namespace html {
class SafeHtml {
}
}
namespace positioning {
class ClientPosition {
constructor(x: number, y: number);
}
}
}
declare module Blockly {
class Block extends Block__Class { }
/** Fake class which should be extended to avoid inheriting static properties */
class Block__Class {
/**
* Class for one block.
* Not normally called directly, workspace.newBlock() is preferred.
* @param {!Blockly.Workspace} workspace The block's workspace.
* @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.
* @constructor
*/
constructor(workspace: Blockly.Workspace, prototypeName: string, opt_id?: string);
/** @type {string} */
id: string;
/** @type {Blockly.Connection} */
outputConnection: Blockly.Connection;
/** @type {Blockly.Connection} */
nextConnection: Blockly.Connection;
/** @type {Blockly.Connection} */
previousConnection: Blockly.Connection;
/** @type {!Array.<!Blockly.Input>} */
inputList: Blockly.Input[];
/** @type {boolean|undefined} */
inputsInline: boolean|any /*undefined*/;
/** @type {boolean|undefined} */
startHat: boolean|any /*undefined*/;
/** @type {boolean} */
disabled: boolean;
/** @type {string|!Function} */
tooltip: string|Function;
/** @type {boolean} */
contextMenu: boolean;
/**
* @type {Blockly.Block}
* @protected
*/
parentBlock_: Blockly.Block;
/**
* @type {!Array.<!Blockly.Block>}
* @protected
*/
childBlocks_: Blockly.Block[];
/**
* @type {boolean}
* @private
*/
deletable_: boolean;
/**
* @type {boolean}
* @private
*/
movable_: boolean;
/**
* @type {boolean}
* @private
*/
editable_: boolean;
/**
* @type {boolean}
* @private
*/
isShadow_: boolean;
/**
* @type {boolean}
* @protected
*/
collapsed_: boolean;
/** @type {string|Blockly.Comment} */
comment: string|Blockly.Comment;
/**
* @type {?number}
* @private
*/
outputShape_: number;
/**
* @type {?string}
* @private
*/
category_: string;
/**
* The block's position in workspace units. (0, 0) is at the workspace's
* origin; scale does not change this value.
* @type {!goog.math.Coordinate}
* @private
*/
xy_: goog.math.Coordinate;
/** @type {!Blockly.Workspace} */
workspace: Blockly.Workspace;
/** @type {boolean} */
isInFlyout: boolean;
/** @type {boolean} */
isInMutator: boolean;
/** @type {boolean} */
RTL: boolean;
/** @type {boolean} */
isInsertionMarker_: boolean;
/** @type {string} */
type: string;
/** @type {boolean|undefined} */
inputsInlineDefault: boolean|any /*undefined*/;
/**
* Optional text data that round-trips beween blocks and XML.
* Has no effect. May be used by 3rd parties for meta information.
* @type {?string}
*/
data: string;
/**
* Colour of the block in '#RRGGBB' format.
* @type {string}
* @private
*/
colour_: string;
/**
* Secondary colour of the block in '#RRGGBB' format.
* @type {string}
* @private
*/
colourSecondary_: string;
/**
* Tertiary colour of the block in '#RRGGBB' format.
* @type {string}
* @private
*/
colourTertiary_: string;
/**
* Fill colour used to override default shadow colour behaviour.
* @type {string}
* @private
*/
shadowColour_: string;
/**
* Colour of the block as HSV hue value (0-360)
* @type {?number}
* @private
*/
hue_: number;
/**
* Dispose of this block.
* @param {boolean=} healStack If true, then try to heal any gap by connecting
* the next statement with the previous statement. Otherwise, dispose of
* all children of this block.
*/
dispose(healStack?: boolean): void;
/**
* Call initModel on all fields on the block.
* May be called more than once.
* Either initModel or initSvg must be called after creating a block and before
* the first interaction with it. Interactions include UI actions
* (e.g. clicking and dragging) and firing events (e.g. create, delete, and
* change).
* @public
*/
initModel(): void;
/**
* Unplug this block from its superior block. If this block is a statement,
* optionally reconnect the block underneath with the block on top.
* @param {boolean=} opt_healStack Disconnect child statement and reconnect
* stack. Defaults to false.
*/
unplug(opt_healStack?: boolean): void;
/**
* Returns all connections originating from this block.
* @param {boolean} _all If true, return all connections even hidden ones.
* @return {!Array.<!Blockly.Connection>} Array of connections.
* @private
*/
getConnections_(_all: boolean): Blockly.Connection[];
/**
* Walks down a stack of blocks and finds the last next connection on the stack.
* @return {Blockly.Connection} The last next connection on the stack, or null.
* @package
*/
lastConnectionInStack(): Blockly.Connection;
/**
* Bump unconnected blocks out of alignment. Two blocks which aren't actually
* connected should not coincidentally line up on screen.
* @protected
*/
bumpNeighbours_(): void;
/**
* Return the parent block or null if this block is at the top level.
* @return {Blockly.Block} The block that holds the current block.
*/
getParent(): Blockly.Block;
/**
* Return the input that connects to the specified block.
* @param {!Blockly.Block} block A block connected to an input on this block.
* @return {Blockly.Input} The input that connects to the specified block.
*/
getInputWithBlock(block: Blockly.Block): Blockly.Input;
/**
* Return the input that contains the specified connection
* @param {!Blockly.Connection} conn A connection on this block.
* @return {Blockly.Input} The input that contains the specified connection.
*/
getInputWithConnection(conn: Blockly.Connection): Blockly.Input;
/**
* Return the parent block that surrounds the current block, or null if this
* block has no surrounding block. A parent block might just be the previous
* statement, whereas the surrounding block is an if statement, while loop, etc.
* @return {Blockly.Block} The block that surrounds the current block.
*/
getSurroundParent(): Blockly.Block;
/**
* Return the next statement block directly connected to this block.
* @return {Blockly.Block} The next statement block or null.
*/
getNextBlock(): Blockly.Block;
/**
* Return the previous statement block directly connected to this block.
* @return {Blockly.Block} The previous statement block or null.
*/
getPreviousBlock(): Blockly.Block;
/**
* Return the connection on the first statement input on this block, or null if
* there are none.
* @return {Blockly.Connection} The first statement connection or null.
*/
getFirstStatementConnection(): Blockly.Connection;
/**
* Return the top-most block in this block's tree.
* This will return itself if this block is at the top level.
* @return {!Blockly.Block} The root block.
*/
getRootBlock(): Blockly.Block;
/**
* Find all the blocks that are directly nested inside this one.
* Includes value and statement inputs, as well as any following statement.
* Excludes any connection on an output tab or any preceding statement.
* Blocks are optionally sorted by position; top to bottom.
* @param {boolean} ordered Sort the list if true.
* @return {!Array.<!Blockly.Block>} Array of blocks.
*/
getChildren(ordered: boolean): Blockly.Block[];
/**
* Set parent of this block to be a new block or null.
* @param {Blockly.Block|Blockly.BlockSvg} newParent New parent block.
*/
setParent(newParent: Blockly.Block|Blockly.BlockSvg): void;
/**
* Find all the blocks that are directly or indirectly nested inside this one.
* Includes this block in the list.
* Includes value and statement inputs, as well as any following statements.
* Excludes any connection on an output tab or any preceding statements.
* Blocks are optionally sorted by position; top to bottom.
* @param {boolean} ordered Sort the list if true.
* @param {boolean=} opt_ignoreShadows If set, don't include shadow blocks.
* @return {!Array.<!Blockly.Block>} Flattened array of blocks.
*/
getDescendants(ordered: boolean, opt_ignoreShadows?: boolean): Blockly.Block[];
/**
* Get whether this block is deletable or not.
* @return {boolean} True if deletable.
*/
isDeletable(): boolean;
/**
* Set whether this block is deletable or not.
* @param {boolean} deletable True if deletable.
*/
setDeletable(deletable: boolean): void;
/**
* Get whether this block is movable or not.
* @return {boolean} True if movable.
*/
isMovable(): boolean;
/**
* Get whether we should persist this block as movable or not.
* @return {boolean} True if movable.
*/
isMovablePersisted(): boolean;
/**
* Set whether this block is movable or not.
* @param {boolean} movable True if movable.
*/
setMovable(movable: boolean): void;
/**
* Get whether this block is a shadow block or not.
* @return {boolean} True if a shadow.
*/
isShadow(): boolean;
/**
* Set whether this block is a shadow block or not.
* @param {boolean} shadow True if a shadow.
*/
setShadow(shadow: boolean): void;
/**
* Get whether this block is an insertion marker block or not.
* @return {boolean} True if an insertion marker.
*/
isInsertionMarker(): boolean;
/**
* Set whether this block is an insertion marker block or not.
* @param {boolean} insertionMarker True if an insertion marker.
*/
setInsertionMarker(insertionMarker: boolean): void;
/**
* Get whether this block is editable or not.
* @return {boolean} True if editable.
*/
isEditable(): boolean;
/**
* Get whether we should persist this block as editable.
* @return {boolean} True if editable.
*/
isEditablePersisted(): boolean;
/**
* Set whether this block is editable or not.
* @param {boolean} editable True if editable.
*/
setEditable(editable: boolean): void;
/**
* Set whether the connections are hidden (not tracked in a database) or not.
* Recursively walk down all child blocks (except collapsed blocks).
* @param {boolean} hidden True if connections are hidden.
*/
setConnectionsHidden(hidden: boolean): void;
/**
* Find the connection on this block that corresponds to the given connection
* on the other block.
* Used to match connections between a block and its insertion marker.
* @param {!Blockly.Block} otherBlock The other block to match against.
* @param {!Blockly.Connection} conn The other connection to match.
* @return {Blockly.Connection} the matching connection on this block, or null.
*/
getMatchingConnection(otherBlock: Blockly.Block, conn: Blockly.Connection): Blockly.Connection;
/**
* Set the URL of this block's help page.
* @param {string|Function} url URL string for block help, or function that
* returns a URL. Null for no help.
*/
setHelpUrl(url: string|Function): void;
/**
* Change the tooltip text for a block.
* @param {string|!Function} newTip Text for tooltip or a parent element to
* link to for its tooltip. May be a function that returns a string.
*/
setTooltip(newTip: string|Function): void;
/**
* Get the colour of a block.
* @return {string} #RRGGBB string.
*/
getColour(): string;
/**
* Get the HSV hue value of a block. Null if hue not set.
* @return {?number} Hue value (0-360)
*/
getHue(): number;
/**
* Get the secondary colour of a block.
* @return {string} #RRGGBB string.
*/
getColourSecondary(): string;
/**
* Get the tertiary colour of a block.
* @return {string} #RRGGBB string.
*/
getColourTertiary(): string;
/**
* Get the shadow colour of a block.
* @return {string} #RRGGBB string.
*/
getShadowColour(): string;
/**
* Set the shadow colour of a block.
* @param {number|string} colour HSV hue value, or #RRGGBB string.
*/
setShadowColour(colour: number|string): void;
/**
* Clear the shadow colour of a block.
*/
clearShadowColour(): void;
/**
* Create an #RRGGBB string colour from a colour HSV hue value or #RRGGBB string.
* @param {number|string} colour HSV hue value, or #RRGGBB string.
* @return {string} #RRGGBB string.
* @private
*/
makeColour_(colour: number|string): string;
/**
* Change the colour of a block, and optional secondary/teriarty colours.
* @param {number|string} colour HSV hue value, or #RRGGBB string.
* @param {number|string=} colourSecondary HSV hue value, or #RRGGBB string.
* @param {number|string=} colourTertiary HSV hue value, or #RRGGBB string.
*/
setColour(colour: number|string, colourSecondary?: number|string, colourTertiary?: number|string): void;
/**
* Sets a callback function to use whenever the block's parent workspace
* changes, replacing any prior onchange handler. This is usually only called
* from the constructor, the block type initializer function, or an extension
* initializer function.
* @param {function(Blockly.Events.Abstract)} onchangeFn The callback to call
* when the block's workspace changes.
* @throws {Error} if onchangeFn is not falsey or a function.
*/
setOnChange(onchangeFn: { (_0: Blockly.Events.Abstract): any /*missing*/ }): void;
/**
* Returns the named field from a block.
* @param {string} name The name of the field.
* @return {Blockly.Field} Named field, or null if field does not exist.
*/
getField(name: string): Blockly.Field;
/**
* Return all variables referenced by this block.
* @return {!Array.<string>} List of variable names.
* @package
*/
getVars(): string[];
/**
* Return all variables referenced by this block.
* @return {!Array.<!Blockly.VariableModel>} List of variable models.
* @package
*/
getVarModels(): Blockly.VariableModel[];
/**
* Notification that a variable is renaming but keeping the same ID. If the
* variable is in use on this block, rerender to show the new name.
* @param {!Blockly.VariableModel} variable The variable being renamed.
* @package
*/
updateVarName(variable: Blockly.VariableModel): void;
/**
* Notification that a variable is renaming.
* If the ID matches one of this block's variables, rename it.
* @param {string} oldId ID of variable to rename.
* @param {string} newId ID of new variable. May be the same as oldId, but with
* an updated name.
*/
renameVarById(oldId: string, newId: string): void;
/**
* Returns the language-neutral value from the field of a block.
* @param {string} name The name of the field.
* @return {?string} Value from the field or null if field does not exist.
*/
getFieldValue(name: string): string;
/**
* Change the field value for a block (e.g. 'CHOOSE' or 'REMOVE').
* @param {string} newValue Value to be the new field.
* @param {string} name The name of the field.
*/
setFieldValue(newValue: string, name: string): void;
/**
* Set whether this block can chain onto the bottom of another block.
* @param {boolean} newBoolean True if there can be a previous statement.
* @param {(string|Array.<string>|null)=} opt_check Statement type or
* list of statement types. Null/undefined if any type could be connected.
*/
setPreviousStatement(newBoolean: boolean, opt_check?: string|string[]|any /*null*/): void;
/**
* Set whether another block can chain onto the bottom of this block.
* @param {boolean} newBoolean True if there can be a next statement.
* @param {(string|Array.<string>|null)=} opt_check Statement type or
* list of statement types. Null/undefined if any type could be connected.
*/
setNextStatement(newBoolean: boolean, opt_check?: string|string[]|any /*null*/): void;
/**
* Set whether this block returns a value.
* @param {boolean} newBoolean True if there is an output.
* @param {(string|Array.<string>|null)=} opt_check Returned type or list
* of returned types. Null or undefined if any type could be returned
* (e.g. variable get).
*/
setOutput(newBoolean: boolean, opt_check?: string|string[]|any /*null*/): void;
/**
* Set whether value inputs are arranged horizontally or vertically.
* @param {boolean} newBoolean True if inputs are horizontal.
*/
setInputsInline(newBoolean: boolean): void;
/**
* Get whether value inputs are arranged horizontally or vertically.
* @return {boolean} True if inputs are horizontal.
*/
getInputsInline(): boolean;
/**
* Set whether value statements have a start hat or not.
* @param {boolean} newBoolean True if statement should have a start hat.
*/
setStartHat(newBoolean: boolean): void;
/**
* Get whether value inputs are arranged horizontally or vertically.
* @return {boolean} True if inputs are horizontal.
*/
getStartHat(): boolean;
/**
* Set whether the block is disabled or not.
* @param {boolean} disabled True if disabled.
*/
setDisabled(disabled: boolean): void;
/**
* Get whether the block is disabled or not due to parents.
* The block's own disabled property is not considered.
* @return {boolean} True if disabled.
*/
getInheritedDisabled(): boolean;
/**
* Get whether the block is collapsed or not.
* @return {boolean} True if collapsed.
*/
isCollapsed(): boolean;
/**
* Set whether the block is collapsed or not.
* @param {boolean} collapsed True if collapsed.
*/
setCollapsed(collapsed: boolean): void;
/**
* Create a human-readable text representation of this block and any children.
* @param {number=} opt_maxLength Truncate the string to this length.
* @param {string=} opt_emptyToken The placeholder string used to denote an
* empty field. If not specified, '?' is used.
* @return {string} Text of block.
*/
toString(opt_maxLength?: number, opt_emptyToken?: string): string;
/**
* Shortcut for appending a value input row.
* @param {string} name Language-neutral identifier which may used to find this
* input again. Should be unique to this block.
* @return {!Blockly.Input} The input object created.
*/
appendValueInput(name: string): Blockly.Input;
/**
* Shortcut for appending a statement input row.
* @param {string} name Language-neutral identifier which may used to find this
* input again. Should be unique to this block.
* @return {!Blockly.Input} The input object created.
*/
appendStatementInput(name: string): Blockly.Input;
/**
* Shortcut for appending a dummy input row.
* @param {string=} opt_name Language-neutral identifier which may used to find
* this input again. Should be unique to this block.
* @return {!Blockly.Input} The input object created.
*/
appendDummyInput(opt_name?: string): Blockly.Input;
/**
* Initialize this block using a cross-platform, internationalization-friendly
* JSON description.
* @param {!Object} json Structured data describing the block.
*/
jsonInit(json: Object): void;
/**
* Set the colour of the block from strings or string table references.
* @param {string|?} primary Primary colour, which may be a string that contains
* string table references.
* @param {string|?} secondary Secondary colour, which may be a string that
* contains string table references.
* @param {string|?} tertiary Tertiary colour, which may be a string that
* contains string table references.
* @private
*/
setColourFromRawValues_(primary: string|any, secondary: string|any, tertiary: string|any): void;
/**
* Initialize the colour of this block from the JSON description.
* @param {!Object} json Structured data describing the block.
* @param {string} warningPrefix Warning prefix string identifying block.
* @private
*/
jsonInitColour_(json: Object, warningPrefix: string): void;
/**
* Add key/values from mixinObj to this block object. By default, this method
* will check that the keys in mixinObj will not overwrite existing values in
* the block, including prototype values. This provides some insurance against
* mixin / extension incompatibilities with future block features. This check
* can be disabled by passing true as the second argument.
* @param {!Object} mixinObj The key/values pairs to add to this block object.
* @param {boolean=} opt_disableCheck Option flag to disable overwrite checks.
*/
mixin(mixinObj: Object, opt_disableCheck?: boolean): void;
/**
* Interpolate a message description onto the block.
* @param {string} message Text contains interpolation tokens (%1, %2, ...)
* that match with fields or inputs defined in the args array.
* @param {!Array} args Array of arguments to be interpolated.
* @param {string=} lastDummyAlign If a dummy input is added at the end,
* how should it be aligned?
* @private
*/
interpolate_(message: string, args: any[], lastDummyAlign?: string): void;
/**
* Add a value input, statement input or local variable to this block.
* @param {number} type Either Blockly.INPUT_VALUE or Blockly.NEXT_STATEMENT or
* Blockly.DUMMY_INPUT.
* @param {string} name Language-neutral identifier which may used to find this
* input again. Should be unique to this block.
* @return {!Blockly.Input} The input object created.
* @protected
*/
appendInput_(type: number, name: string): Blockly.Input;
/**
* Move a named input to a different location on this block.
* @param {string} name The name of the input to move.
* @param {?string} refName Name of input that should be after the moved input,
* or null to be the input at the end.
*/
moveInputBefore(name: string, refName: string): void;
/**
* Move a numbered input to a different location on this block.
* @param {number} inputIndex Index of the input to move.
* @param {number} refIndex Index of input that should be after the moved input.
*/
moveNumberedInputBefore(inputIndex: number, refIndex: number): void;
/**
* Remove an input from this block.
* @param {string} name The name of the input.
* @param {boolean=} opt_quiet True to prevent error if input is not present.
* @throws {goog.asserts.AssertionError} if the input is not present and
* opt_quiet is not true.
*/
removeInput(name: string, opt_quiet?: boolean): void;
/**
* Fetches the named input object.
* @param {string} name The name of the input.
* @return {Blockly.Input} The input object, or null if input does not exist.
*/
getInput(name: string): Blockly.Input;
/**
* Fetches the block attached to the named input.
* @param {string} name The name of the input.
* @return {Blockly.Block} The attached value block, or null if the input is
* either disconnected or if the input does not exist.
*/
getInputTargetBlock(name: string): Blockly.Block;
/**
* Returns the comment on this block (or '' if none).
* @return {string} Block's comment.
*/
getCommentText(): string;
/**
* Set this block's comment text.
* @param {?string} text The text, or null to delete.
*/
setCommentText(text: string): void;
/**