UNPKG

pxt-core

Version:

Microsoft MakeCode provides Blocks / JavaScript / Python tools and editors

55 lines (54 loc) 2.57 kB
/// <reference path="../pxtlib.d.ts" /> import * as Blockly from "blockly"; export { initCopyPaste } from "./copyPaste"; export declare const DRAGGABLE_PARAM_INPUT_PREFIX = "HANDLER_DRAG_PARAM_"; interface BlockDefinition { codeCard?: any; init: () => void; getVars?: () => any[]; renameVar?: (oldName: string, newName: string) => void; customContextMenu?: any; getProcedureCall?: () => string; renameProcedure?: (oldName: string, newName: string) => void; defType_?: string; onchange?: (event: any) => void; mutationToDom?: () => Element; domToMutation?: (xmlElement: Element) => void; } export declare function isTupleType(type: string): string[]; export declare function builtinBlocks(): pxt.Map<{ block: BlockDefinition; symbol?: pxtc.SymbolInfo; }>; export declare const buildinBlockStatements: pxt.Map<boolean>; export declare let cachedBlockInfo: pxtc.BlocksInfo; export declare function blockSymbol(type: string): pxtc.SymbolInfo; export declare function injectBlocks(blockInfo: pxtc.BlocksInfo): pxtc.SymbolInfo[]; export declare function hasArrowFunction(fn: pxtc.SymbolInfo): boolean; export declare function cleanBlocks(): void; /** * Used by pxtrunner to initialize blocks in the docs */ export declare function initializeAndInject(blockInfo: pxtc.BlocksInfo): void; /** * Used by main app to initialize blockly blocks. * Blocks are injected separately by called injectBlocks */ export declare function initialize(blockInfo: pxtc.BlocksInfo): void; export declare function initAccessibleBlocksContextMenuItems(): void; /** * Converts a TypeScript type into an array of type checks for Blockly inputs/outputs. Use * with block.setOutput() and input.setCheck(). * * @returns An array of checks if the type is valid, undefined if there are no valid checks * (e.g. type is void), and null if all checks should be accepted (e.g. type is generic) */ export declare function getBlocklyCheckForType(type: string, info: pxtc.BlocksInfo): string[]; export declare function setOutputCheck(block: Blockly.Block, retType: string, info: pxtc.BlocksInfo): void; export declare function getFixedInstanceDropdownValues(apis: pxtc.ApisInfo, qName: string): pxtc.SymbolInfo[]; export declare function generateIcons(instanceSymbols: pxtc.SymbolInfo[]): void; /** * Blockly variable fields can't be set directly; you either have to use the * variable ID or set the value of the model and not the field */ export declare function setVarFieldValue(block: Blockly.Block, fieldName: string, newName: string): void;