/// /// import { deployCoreAsync, initAsync } from "./deploy"; pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): Promise { pxt.debug('loading pxt-ev3 target extensions...') const res: pxt.editor.ExtensionResult = { deployCoreAsync, showUploadInstructionsAsync: (fn: string, url: string, confirmAsync: (options: any) => Promise) => { let resolve: (thenableOrResult?: void | PromiseLike) => void; let reject: (error: any) => void; const deferred = new Promise((res, rej) => { resolve = res; reject = rej; }); const boardName = pxt.appTarget.appTheme.boardName || "???"; const boardDriveName = pxt.appTarget.appTheme.driveDisplayName || pxt.appTarget.compile.driveName || "???"; // https://msdn.microsoft.com/en-us/library/cc848897.aspx // "For security reasons, data URIs are restricted to downloaded resources. // Data URIs cannot be used for navigation, for scripting, or to populate frame or iframe elements" const downloadAgain = !pxt.BrowserUtils.isIE() && !pxt.BrowserUtils.isEdge(); const docUrl = pxt.appTarget.appTheme.usbDocs; const saveAs = pxt.BrowserUtils.hasSaveAs(); const htmlBody = ` 1 ${lf("Connect EV3 to computer with USB cable")} ${lf("Use the miniUSB port on top of EV3 brick")} 2 ${lf("Locate the downloaded .uf2 file and drag it to the EV3 drive")} ${lf("Something wrong? Click here to troubleshoot..")} `; return confirmAsync({ header: lf("Download to your EV3"), htmlBody, hasCloseIcon: true, hideCancel: true, hideAgree: false, agreeLbl: lf("I got it"), buttons: [downloadAgain ? { label: fn, icon: "download", className: "lightgrey focused", url, fileName: fn } : undefined, docUrl ? { label: lf("Help"), icon: "help", className: "lightgrey", url: docUrl } : undefined] //timeout: 20000 }).then(() => { }); } }; initAsync().catch(e => { // probably no HID - we'll try this again upon deployment }) return Promise.resolve(res); } // When require()d from node, bind the global pxt namespace // namespace pxt { // export const dummyExport = 1; // } // eval("if (typeof process === 'object' && process + '' === '[object process]') pxt = global.pxt")