update to pxt 5 and pxt-common-packages 6 (#934)
* bump pxt * fix build issues * Auto-gen of projects/summary * removing feild editors moved to pxt * various typing fixes * more typing fixes * fixing various typing issues * Start on integration of new pxt * serial number fixes * gc-ify MMap object * Re-build generated files * fix console listeners * clear lf() warnings * More generated files * also auto-generated * Compilation fixes * fix merge * mostly fixing blocks * fix sim * fix field motors * enable a few features * moving to tsx * try to fix edtiro compilation * more defs * removing commands * removing extra $ * fix blockly warning * hiding images * enabling more pxt features * hide images * setup autorun * add lock on target_reset * update deps * return trylock result * updated pxt * rename video section * add alpha channel * upgraded pxt * bump pxt/version * removed alpha ref * var ceanup * don't do major bump
This commit is contained in:
committed by
Peli de Halleux
parent
ba94322d4c
commit
c5cec3a6ba
@ -3,20 +3,15 @@
|
||||
|
||||
import UF2 = pxtc.UF2;
|
||||
import { Ev3Wrapper } from "./wrap";
|
||||
import { bluetoothTryAgainAsync } from "./dialogs";
|
||||
|
||||
export let ev3: Ev3Wrapper;
|
||||
let confirmAsync: (options: any) => Promise<number>;
|
||||
|
||||
export function setConfirmAsync(cf: (options: any) => Promise<number>) {
|
||||
confirmAsync = cf;
|
||||
}
|
||||
|
||||
export function debug() {
|
||||
return initHidAsync()
|
||||
.then(w => w.downloadFileAsync("/tmp/dmesg.txt", v => console.log(pxt.Util.uint8ArrayToString(v))))
|
||||
}
|
||||
|
||||
|
||||
// Web Serial API https://wicg.github.io/serial/
|
||||
// chromium bug https://bugs.chromium.org/p/chromium/issues/detail?id=884928
|
||||
// Under experimental features in Chrome Desktop 77+
|
||||
@ -167,7 +162,7 @@ export function initAsync(): Promise<void> {
|
||||
useHID = false
|
||||
} else {
|
||||
const nodehid = /nodehid/i.test(window.location.href);
|
||||
if (pxt.Cloud.isLocalHost() && pxt.Cloud.localToken && nodehid)
|
||||
if (pxt.BrowserUtils.isLocalHost() && pxt.Cloud.localToken && nodehid)
|
||||
useHID = true;
|
||||
}
|
||||
|
||||
@ -283,22 +278,9 @@ export function deployCoreAsync(resp: pxtc.CompileResult) {
|
||||
return w.reconnectAsync(false)
|
||||
.catch(e => {
|
||||
// user easily forgets to stop robot
|
||||
if (confirmAsync)
|
||||
return confirmAsync({
|
||||
header: lf("Bluetooth download failed..."),
|
||||
htmlBody:
|
||||
`<ul>
|
||||
<li>${lf("Make sure to stop your program or exit portview on the EV3.")}</li>
|
||||
<li>${lf("Check your battery level.")}</li>
|
||||
<li>${lf("Close EV3 LabView or other MakeCode editor tabs.")}
|
||||
</ul>`,
|
||||
hasCloseIcon: true,
|
||||
hideCancel: true,
|
||||
hideAgree: false,
|
||||
agreeLbl: lf("Try again"),
|
||||
}).then(() => w.disconnectAsync())
|
||||
.then(() => Promise.delay(1000))
|
||||
.then(() => w.reconnectAsync());
|
||||
bluetoothTryAgainAsync().then(() => w.disconnectAsync())
|
||||
.then(() => Promise.delay(1000))
|
||||
.then(() => w.reconnectAsync());
|
||||
|
||||
// nothing we can do
|
||||
return Promise.reject(e);
|
||||
|
145
editor/dialogs.tsx
Normal file
145
editor/dialogs.tsx
Normal file
@ -0,0 +1,145 @@
|
||||
import * as React from "react";
|
||||
import { canUseWebSerial, enableWebSerialAsync } from "./deploy";
|
||||
import { projectView } from "./extension";
|
||||
|
||||
let confirmAsync: (options: any) => Promise<number>;
|
||||
|
||||
export function bluetoothTryAgainAsync(): Promise<void> {
|
||||
return confirmAsync({
|
||||
header: lf("Bluetooth download failed..."),
|
||||
jsx: <ul>
|
||||
<li>{lf("Make sure to stop your program or exit portview on the EV3.")}</li>
|
||||
<li>{lf("Check your battery level.")}</li>
|
||||
<li>{lf("Close EV3 LabView or other MakeCode editor tabs.")}</li>
|
||||
</ul>,
|
||||
hasCloseIcon: false,
|
||||
hideCancel: true,
|
||||
hideAgree: false,
|
||||
agreeLbl: lf("Try again")
|
||||
}).then(r => {});
|
||||
}
|
||||
|
||||
function enableWebSerialAndCompileAsync() {
|
||||
return enableWebSerialAsync()
|
||||
.then(() => Promise.delay(500))
|
||||
.then(() => projectView.compile());
|
||||
}
|
||||
|
||||
let bluetoothDialogShown = false;
|
||||
function explainWebSerialPairingAsync(): Promise<void> {
|
||||
if (!confirmAsync || bluetoothDialogShown) return Promise.resolve();
|
||||
|
||||
bluetoothDialogShown = true;
|
||||
return confirmAsync({
|
||||
header: lf("Bluetooth pairing"),
|
||||
hasCloseIcon: false,
|
||||
hideCancel: true,
|
||||
buttons: [{
|
||||
label: lf("Help"),
|
||||
icon: "question circle",
|
||||
className: "lightgrey",
|
||||
url: "/bluetooth"
|
||||
}],
|
||||
jsx: <p>
|
||||
{lf("You will be prompted to select a serial port.")}
|
||||
{pxt.BrowserUtils.isWindows()
|
||||
? lf("Look for 'Standard Serial over Bluetooth link'.")
|
||||
: lf("Loop for 'cu.EV3-SerialPort'.")}
|
||||
{lf("If you have paired multiple EV3, you might have to try out multiple ports until you find the correct one.")}
|
||||
</p>
|
||||
}).then(() => { })
|
||||
}
|
||||
|
||||
export function showUploadDialogAsync(fn: string, url: string, _confirmAsync: (options: any) => Promise<number>): Promise<void> {
|
||||
confirmAsync = _confirmAsync;
|
||||
// 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 jsx =
|
||||
<div className="ui grid stackable">
|
||||
<div className="column five wide" style={{ backgroundColor: "#E2E2E2" }}>
|
||||
<div className="ui header">{lf("First time here?")}</div>
|
||||
<strong style={{ fontSize: "small" }}>{lf("You must have version 1.10E or above of the firmware")}</strong>
|
||||
<div style={{ justifyContent: "center", display: "flex", padding: "1rem" }}>
|
||||
<img className="ui image" src="/static/download/firmware.png" style={{ height: "100px" }} />
|
||||
</div>
|
||||
<a href="/troubleshoot" target="_blank">{lf("Check your firmware version here and update if needed")}</a>
|
||||
</div>
|
||||
<div className="column eleven wide">
|
||||
<div className="ui grid">
|
||||
<div className="row">
|
||||
<div className="column">
|
||||
<div className="ui two column grid padded">
|
||||
<div className="column">
|
||||
<div className="ui">
|
||||
<div className="image">
|
||||
<img className="ui medium rounded image" src="/static/download/connect.svg" style={{ height: "109px", width: "261px", marginBottom: "1rem" }} />
|
||||
</div>
|
||||
<div className="content">
|
||||
<div className="description">
|
||||
<span className="ui yellow circular label">1</span>
|
||||
<strong>{lf("Connect the EV3 to your computer with a USB cable")}</strong>
|
||||
<br />
|
||||
<span style={{ fontSize: "small" }}>{lf("Use the miniUSB port on the top of the EV3 Brick")}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="column">
|
||||
<div className="ui">
|
||||
<div className="image">
|
||||
<img className="ui medium rounded image" src="/static/download/transfer.svg" style={{ height: "109px", width: "261px", marginBottom: "1rem" }} />
|
||||
</div>
|
||||
<div className="content">
|
||||
<div className="description">
|
||||
<span className="ui yellow circular label">2</span>
|
||||
<strong>{lf("Move the .uf2 file to the EV3 Brick")}</strong>
|
||||
<br />
|
||||
<span style={{ fontSize: "small" }}>{lf("Locate the downloaded .uf2 file and drag it to the EV3 USB drive")}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>;
|
||||
|
||||
return confirmAsync({
|
||||
header: lf("Download to your EV3"),
|
||||
jsx,
|
||||
hasCloseIcon: true,
|
||||
hideCancel: true,
|
||||
hideAgree: false,
|
||||
agreeLbl: lf("I got it"),
|
||||
className: 'downloaddialog',
|
||||
buttons: [canUseWebSerial() ? {
|
||||
label: lf("Bluetooth"),
|
||||
icon: "bluetooth",
|
||||
className: "bluetooth focused",
|
||||
onclick: () => {
|
||||
pxt.tickEvent("bluetooth.enable");
|
||||
explainWebSerialPairingAsync()
|
||||
.then(() => enableWebSerialAndCompileAsync())
|
||||
.done();
|
||||
}
|
||||
} : undefined, 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(() => { });
|
||||
}
|
@ -1,144 +1,26 @@
|
||||
/// <reference path="../node_modules/pxt-core/localtypings/pxtarget.d.ts" />
|
||||
/// <reference path="../node_modules/pxt-core/built/pxtblocks.d.ts" />
|
||||
/// <reference path="../node_modules/pxt-core/built/pxtcompiler.d.ts" />
|
||||
/// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
|
||||
/// <reference path="../node_modules/pxt-core/built/pxteditor.d.ts"/>
|
||||
/// <reference path="../node_modules/pxt-core/built/pxtsim.d.ts"/>
|
||||
|
||||
import { deployCoreAsync, initAsync, canUseWebSerial, enableWebSerialAsync, setConfirmAsync } from "./deploy";
|
||||
import { deployCoreAsync, initAsync } from "./deploy";
|
||||
import { showUploadDialogAsync } from "./dialogs";
|
||||
|
||||
export let projectView: pxt.editor.IProjectView;
|
||||
|
||||
let bluetoothDialogShown = false;
|
||||
pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): Promise<pxt.editor.ExtensionResult> {
|
||||
const projectView = opts.projectView;
|
||||
pxt.debug('loading pxt-ev3 target extensions...')
|
||||
|
||||
function enableWebSerialAndCompileAsync() {
|
||||
return enableWebSerialAsync()
|
||||
.then(() => Promise.delay(500))
|
||||
.then(() => projectView.compile());
|
||||
}
|
||||
projectView = opts.projectView;
|
||||
|
||||
const res: pxt.editor.ExtensionResult = {
|
||||
deployCoreAsync,
|
||||
showUploadInstructionsAsync: (fn: string, url: string, confirmAsync: (options: any) => Promise<number>) => {
|
||||
setConfirmAsync(confirmAsync);
|
||||
// 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 htmlBody = `
|
||||
<div class="ui grid stackable">
|
||||
<div class="column five wide" style="background-color: #E2E2E2;">
|
||||
<div class="ui header">${lf("First time here?")}</div>
|
||||
<strong style="font-size:small">${lf("You must have version 1.10E or above of the firmware")}</strong>
|
||||
<div style="justify-content: center;display: flex;padding: 1rem;">
|
||||
<img class="ui image" src="/static/download/firmware.png" style="height:100px;" />
|
||||
</div>
|
||||
<a href="/troubleshoot" target="_blank">${lf("Check your firmware version here and update if needed")}</a>
|
||||
</div>
|
||||
<div class="column eleven wide">
|
||||
<div class="ui grid">
|
||||
<div class="row">
|
||||
<div class="column">
|
||||
<div class="ui two column grid padded">
|
||||
<div class="column">
|
||||
<div class="ui">
|
||||
<div class="image">
|
||||
<img class="ui medium rounded image" src="/static/download/connect.svg" style="height:109px;width:261px;margin-bottom:1rem;" />
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="description">
|
||||
<span class="ui yellow circular label">1</span>
|
||||
<strong>${lf("Connect the EV3 to your computer with a USB cable")}</strong>
|
||||
<br />
|
||||
<span style="font-size:small">${lf("Use the miniUSB port on the top of the EV3 Brick")}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="ui">
|
||||
<div class="image">
|
||||
<img class="ui medium rounded image" src="/static/download/transfer.svg" style="height:109px;width:261px;margin-bottom:1rem;" />
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="description">
|
||||
<span class="ui yellow circular label">2</span>
|
||||
<strong>${lf("Move the .uf2 file to the EV3 Brick")}</strong>
|
||||
<br />
|
||||
<span style="font-size:small">${lf("Locate the downloaded .uf2 file and drag it to the EV3 USB drive")}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
return confirmAsync({
|
||||
header: lf("Download to your EV3"),
|
||||
htmlBody,
|
||||
hasCloseIcon: true,
|
||||
hideCancel: true,
|
||||
hideAgree: false,
|
||||
agreeLbl: lf("I got it"),
|
||||
className: 'downloaddialog',
|
||||
buttons: [canUseWebSerial() ? {
|
||||
label: lf("Bluetooth"),
|
||||
icon: "bluetooth",
|
||||
className: "bluetooth focused",
|
||||
onclick: () => {
|
||||
pxt.tickEvent("bluetooth.enable");
|
||||
if (bluetoothDialogShown) {
|
||||
enableWebSerialAndCompileAsync().done();
|
||||
} else {
|
||||
bluetoothDialogShown = true;
|
||||
confirmAsync({
|
||||
header: lf("Bluetooth pairing"),
|
||||
hasCloseIcon: true,
|
||||
hideCancel: true,
|
||||
buttons: [{
|
||||
label: lf("Help"),
|
||||
icon: "question circle",
|
||||
className: "lightgrey",
|
||||
url: "/bluetooth"
|
||||
}],
|
||||
htmlBody: `<p>
|
||||
${lf("You will be prompted to select a serial port.")}
|
||||
${pxt.BrowserUtils.isWindows()
|
||||
? lf("Look for 'Standard Serial over Bluetooth link'.")
|
||||
: lf("Loop for 'cu.EV3-SerialPort'.")}
|
||||
${lf("If you have paired multiple EV3, you might have to try out multiple ports until you find the correct one.")}
|
||||
</p>
|
||||
`
|
||||
}).then(() => enableWebSerialAndCompileAsync())
|
||||
}
|
||||
}
|
||||
} : undefined, 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(() => { });
|
||||
}
|
||||
deployAsync: deployCoreAsync,
|
||||
showUploadInstructionsAsync: showUploadDialogAsync
|
||||
};
|
||||
|
||||
initAsync().catch(e => {
|
||||
// probably no HID - we'll try this again upon deployment
|
||||
})
|
||||
return Promise.resolve<pxt.editor.ExtensionResult>(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")
|
||||
|
@ -1,14 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"noImplicitAny": false,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitThis": true,
|
||||
"declaration": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"isolatedModules": false,
|
||||
"outDir": "../built/editor",
|
||||
"rootDir": ".",
|
||||
"newLine": "LF",
|
||||
"sourceMap": false,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"declaration": true
|
||||
"jsx": "react"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user