UNPKG

pxt-core

Version:

Microsoft MakeCode provides Blocks / JavaScript / Python tools and editors

151 lines (150 loc) • 5.66 kB
/// <reference path="pxtlib.d.ts" /> /// <reference path="pxteditor.d.ts" /> /// <reference path="pxtcompiler.d.ts" /> /// <reference path="pxtblocks.d.ts" /> /// <reference path="pxtsim.d.ts" /> declare namespace pxt.runner { /** * Starts the simulator and injects it into the provided container. * the simulator will attempt to establish a websocket connection * to the debugger's user interface on port 3234. * * @param container The container to inject the simulator into */ function startDebuggerAsync(container: HTMLElement): void; /** * Runner for the debugger that handles communication with the user * interface. Also talks to the server for anything to do with * the filesystem (like reading code) */ class DebugRunner implements pxsim.protocol.DebugSessionHost { private container; private static RETRY_MS; private session; private ws; private pkgLoaded; private dataListener; private errorListener; private closeListener; private intervalId; private intervalRunning; constructor(container: HTMLElement); start(): void; private initializeWebsocket; send(msg: string): void; onData(cb: (msg: DebugProtocol.ProtocolMessage) => void): void; onError(cb: (e?: any) => void): void; onClose(cb: () => void): void; close(): void; private handleRunnerMessage; private runCode; private sendRunnerMessage; } } declare namespace pxt.runner { interface ClientRenderOptions { snippetClass?: string; signatureClass?: string; blocksClass?: string; blocksXmlClass?: string; diffBlocksXmlClass?: string; diffBlocksClass?: string; diffClass?: string; staticPythonClass?: string; diffStaticPythonClass?: string; projectClass?: string; blocksAspectRatio?: number; simulatorClass?: string; linksClass?: string; namespacesClass?: string; apisClass?: string; codeCardClass?: string; tutorial?: boolean; snippetReplaceParent?: boolean; simulator?: boolean; hex?: boolean; hexName?: string; pxtUrl?: string; packageClass?: string; package?: string; jresClass?: string; assetJSONClass?: string; assetJSON?: Map<string>; showEdit?: boolean; showJavaScript?: boolean; split?: boolean; } function defaultClientRenderOptions(): ClientRenderOptions; interface WidgetOptions { showEdit?: boolean; showJs?: boolean; showPy?: boolean; hideGutter?: boolean; run?: boolean; hexname?: string; hex?: string; } function renderAsync(options?: ClientRenderOptions): Promise<void>; } declare namespace pxt.runner { interface SimulateOptions { embedId?: string; id?: string; code?: string; assets?: string; highContrast?: boolean; light?: boolean; fullScreen?: boolean; dependencies?: string[]; builtJsInfo?: pxtc.BuiltSimJsInfo; single?: boolean; mute?: boolean; hideSimButtons?: boolean; autofocus?: boolean; additionalQueryParameters?: string; debug?: boolean; mpRole?: "server" | "client"; } let mainPkg: pxt.MainPackage; function initHost(): void; function initFooter(footer: HTMLElement, shareId?: string): void; function showError(msg: string): void; function generateHexFileAsync(options: SimulateOptions): Promise<string>; function generateVMFileAsync(options: SimulateOptions): Promise<any>; function simulateAsync(container: HTMLElement, simOptions: SimulateOptions): Promise<pxtc.BuiltSimJsInfo>; function preloadSim(container: HTMLElement, simOpts: SimulateOptions): void; function currentDriver(): pxsim.SimulatorDriver; function postSimMessage(msg: pxsim.SimulatorMessage): void; function buildSimJsInfo(simOptions: SimulateOptions): Promise<pxtc.BuiltSimJsInfo>; enum LanguageMode { Blocks = 0, TypeScript = 1, Python = 2 } let editorLanguageMode: LanguageMode; function setEditorContextAsync(mode: LanguageMode, localeInfo: string): Promise<void>; function startRenderServer(): void; function startDocsServer(loading: HTMLElement, content: HTMLElement, backButton?: HTMLElement): void; function renderProjectAsync(content: HTMLElement, projectid: string): Promise<void>; function renderProjectFilesAsync(content: HTMLElement, files: Map<string>, projectid?: string, escapeLinks?: boolean): Promise<void>; interface RenderMarkdownOptions { path?: string; tutorial?: boolean; blocksAspectRatio?: number; print?: boolean; } function renderMarkdownAsync(content: HTMLElement, md: string, options?: RenderMarkdownOptions): Promise<void>; interface DecompileResult { package: pxt.MainPackage; compileProgram?: ts.Program; compileJS?: pxtc.CompileResult; compileBlocks?: pxtc.CompileResult; compilePython?: pxtc.transpile.TranspileResult; apiInfo?: pxtc.ApisInfo; blocksSvg?: Element; } function decompileSnippetAsync(code: string, options?: blocks.BlocksRenderOptions): Promise<DecompileResult>; function compileBlocksAsync(code: string, options?: blocks.BlocksRenderOptions): Promise<DecompileResult>; let initCallbacks: (() => void)[]; function init(): void; }