Skip to content

Commit

Permalink
Updating npm dependencies and getting the build to work (microsoft#1001)
Browse files Browse the repository at this point in the history
* Updating npm dependencies and getting the build to work

* update node in github actions to 14.x
  • Loading branch information
riknoll authored Sep 22, 2021
1 parent 617fdeb commit bef4eba
Show file tree
Hide file tree
Showing 19 changed files with 123 additions and 662 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pxt-buildmain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
node-version: [8.x]
node-version: [14.x]

steps:
- uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pxt-buildpr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [8.x]
node-version: [14.x]

steps:
- uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pxt-buildpush.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
node-version: [8.x]
node-version: [14.x]

steps:
- uses: actions/checkout@v1
Expand Down
53 changes: 40 additions & 13 deletions editor/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ declare interface Serial extends EventTarget {
requestPort(options: SerialPortRequestOptions): Promise<SerialPort>;
}

class WebSerialPackageIO implements pxt.HF2.PacketIO {
class WebSerialPackageIO implements pxt.packetio.PacketIO {
onData: (v: Uint8Array) => void;
onError: (e: Error) => void;
onEvent: (v: Uint8Array) => void;
Expand Down Expand Up @@ -87,7 +87,7 @@ class WebSerialPackageIO implements pxt.HF2.PacketIO {
}

static portIos: WebSerialPackageIO[] = [];
static async mkPacketIOAsync(): Promise<pxt.HF2.PacketIO> {
static async mkPacketIOAsync(): Promise<pxt.packetio.PacketIO> {
const serial = (<any>navigator).serial;
if (serial) {
try {
Expand Down Expand Up @@ -130,7 +130,7 @@ class WebSerialPackageIO implements pxt.HF2.PacketIO {

private async closeAsync() {
// don't close port
return Promise.delay(500);
return pxt.U.delay(500);
}

reconnectAsync(): Promise<void> {
Expand All @@ -146,11 +146,33 @@ class WebSerialPackageIO implements pxt.HF2.PacketIO {
this._writer = this.port.writable.getWriter();
return this._writer.write(pkt);
}

onDeviceConnectionChanged(connect: boolean) {
throw new Error("onDeviceConnectionChanged not implemented");
}

onConnectionChanged() {
throw new Error("onConnectionChanged not implemented");
}

isConnecting() {
throw new Error("isConnecting not implemented");
return false;
}

isConnected() {
throw new Error("isConnected not implemented");
return false;
}

disposeAsync() {
return Promise.reject("disposeAsync not implemented")
}
}

function hf2Async() {
const pktIOAsync: Promise<pxt.HF2.PacketIO> = useWebSerial
? WebSerialPackageIO.mkPacketIOAsync() : pxt.HF2.mkPacketIOAsync()
const pktIOAsync: Promise<pxt.packetio.PacketIO> = useWebSerial
? WebSerialPackageIO.mkPacketIOAsync() : pxt.packetio.mkPacketIOAsync()
return pktIOAsync.then(h => {
let w = new Ev3Wrapper(h)
ev3 = w
Expand Down Expand Up @@ -190,14 +212,19 @@ export function enableWebSerialAsync() {
else return Promise.resolve();
}

function cleanupAsync() {
async function cleanupAsync() {
if (ev3) {
console.log('cleanup previous port')
return ev3.disconnectAsync()
.catch(e => { })
.finally(() => { ev3 = undefined; });
try {
await ev3.disconnectAsync()
}
catch (e) {

}
finally {
ev3 = undefined;
}
}
return Promise.resolve();
}

let initPromise: Promise<Ev3Wrapper>
Expand All @@ -207,7 +234,7 @@ function initHidAsync() { // needs to run within a click handler
if (useHID) {
initPromise = cleanupAsync()
.then(() => hf2Async())
.catch(err => {
.catch((err: any) => {
console.error(err);
initPromise = null
useHID = false;
Expand Down Expand Up @@ -284,7 +311,7 @@ export function deployCoreAsync(resp: pxtc.CompileResult) {
.catch(e => {
// user easily forgets to stop robot
bluetoothTryAgainAsync().then(() => w.disconnectAsync())
.then(() => Promise.delay(1000))
.then(() => pxt.U.delay(1000))
.then(() => w.reconnectAsync());

// nothing we can do
Expand All @@ -296,7 +323,7 @@ export function deployCoreAsync(resp: pxtc.CompileResult) {
.then(() => w.flashAsync(elfPath, UF2.readBytes(origElfUF2, 0, origElfUF2.length * 256)))
.then(() => w.flashAsync(rbfPath, rbfBIN))
.then(() => w.runAsync(rbfPath))
.then(() => Promise.delay(500))
.then(() => pxt.U.delay(500))
.then(() => {
pxt.tickEvent("webserial.success");
return w.disconnectAsync()
Expand Down
5 changes: 2 additions & 3 deletions editor/dialogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function bluetoothTryAgainAsync(): Promise<void> {

function enableWebSerialAndCompileAsync() {
return enableWebSerialAsync()
.then(() => Promise.delay(500))
.then(() => pxt.U.delay(500))
.then(() => projectView.compile());
}

Expand Down Expand Up @@ -53,7 +53,7 @@ function explainWebSerialPairingAsync(): Promise<void> {
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.
// "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;
Expand Down Expand Up @@ -126,7 +126,6 @@ export function showUploadDialogAsync(fn: string, url: string, _confirmAsync: (o
pxt.tickEvent("bluetooth.enable");
explainWebSerialPairingAsync()
.then(() => enableWebSerialAndCompileAsync())
.done();
}
} : undefined, downloadAgain ? {
label: fn,
Expand Down
8 changes: 4 additions & 4 deletions editor/wrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class Ev3Wrapper {
isStreaming = false;
dataDump = /talkdbg=1/.test(window.location.href);

constructor(public io: pxt.HF2.PacketIO) {
constructor(public io: pxt.packetio.PacketIO) {
io.onData = buf => {
buf = buf.slice(0, HF2.read16(buf, 0) + 2)
if (HF2.read16(buf, 4) == usbMagic) {
Expand Down Expand Up @@ -81,7 +81,7 @@ export class Ev3Wrapper {
log(`stopping PXT app`)
let buf = this.allocCustom(2)
return this.justSendAsync(buf)
.then(() => Promise.delay(500))
.then(() => pxt.U.delay(500))
})
}

Expand Down Expand Up @@ -236,7 +236,7 @@ export class Ev3Wrapper {
let contFileReq = this.allocSystem(1 + 2, 0x97)
HF2.write16(contFileReq, 7, 1000) // maxRead
contFileReq[6] = handle
return Promise.delay(data.length > 0 ? 0 : 500)
return pxt.U.delay(data.length > 0 ? 0 : 500)
.then(() => this.talkAsync(contFileReq, -1))
.then(resp)
}
Expand All @@ -251,7 +251,7 @@ export class Ev3Wrapper {
let loop = (): Promise<void> =>
this.lock.enqueue("file", () =>
this.streamFileOnceAsync(path, cb))
.then(() => Promise.delay(500))
.then(() => pxt.U.delay(500))
.then(loop)
return loop()
}
Expand Down
4 changes: 0 additions & 4 deletions fieldeditors/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/// <reference path="../node_modules/pxt-core/built/pxtsim.d.ts"/>

import { FieldPorts } from "./field_ports";
import { FieldMotors } from "./field_motors";
import { FieldBrickButtons } from "./field_brickbuttons";
import { FieldColorEnum } from "./field_color";
import { FieldMusic } from "./field_music";
Expand All @@ -14,9 +13,6 @@ pxt.editor.initFieldExtensionsAsync = function (opts: pxt.editor.FieldExtensionO
fieldEditors: [{
selector: "ports",
editor: FieldPorts
}, {
selector: "motors",
editor: FieldMotors
}, {
selector: "brickbuttons",
editor: FieldBrickButtons
Expand Down
2 changes: 1 addition & 1 deletion fieldeditors/field_color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class FieldColorEnum extends pxtblockly.FieldColorNumber implements Block
}
this.value_ = colour;
if (this.sourceBlock_) {
this.sourceBlock_.setColour(colour, colour, colour);
this.sourceBlock_.setColour(colour);
}
}
}
Loading

0 comments on commit bef4eba

Please sign in to comment.