pxt-core 10.3.2 → 10.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/built/pxt.js +130 -125
- package/built/pxtlib.d.ts +15 -0
- package/built/pxtlib.js +129 -124
- package/built/react-common/components/controls/Button.d.ts +1 -0
- package/built/target.js +1 -1
- package/built/web/icons.css +52 -49
- package/built/web/icons.html +1 -0
- package/built/web/kiosk/js/{main.8c0572f9.js → main.2281ac67.js} +2 -2
- package/built/web/main.js +1 -1
- package/built/web/multiplayer/js/{main.de718cb4.js → main.06600d76.js} +2 -2
- package/built/web/pxtapp.js +1 -1
- package/built/web/pxtasseteditor.js +1 -1
- package/built/web/pxtembed.js +1 -1
- package/built/web/pxtlib.js +1 -1
- package/built/web/pxtworker.js +1 -1
- package/built/web/rtlsemantic.css +1 -1
- package/built/web/semantic.css +1 -1
- package/built/web/skillmap/js/{main.97f75f43.js → main.c31cb548.js} +2 -2
- package/built/web/teachertool/css/main.1dcea34b.css +1 -0
- package/built/web/teachertool/js/main.78692989.js +2 -0
- package/built/web/tutorialtool/js/{main.2937c31e.js → main.61e4c167.js} +2 -2
- package/common-docs/teachertool/test/catalog-shared.json +1 -1
- package/package.json +1 -1
- package/react-common/components/controls/Button.tsx +3 -1
- package/webapp/public/kiosk.html +1 -1
- package/webapp/public/multiplayer.html +1 -1
- package/webapp/public/skillmap.html +1 -1
- package/webapp/public/teachertool.html +1 -1
- package/webapp/public/tutorialtool.html +1 -1
- package/built/web/teachertool/css/main.2113fa85.css +0 -1
- package/built/web/teachertool/js/main.8693c6a3.js +0 -2
package/built/pxtlib.js
CHANGED
|
@@ -22720,50 +22720,51 @@ var pxt;
|
|
|
22720
22720
|
this.handleUSBDisconnected = this.handleUSBDisconnected.bind(this);
|
|
22721
22721
|
}
|
|
22722
22722
|
enable() {
|
|
22723
|
+
var _a, _b;
|
|
22723
22724
|
if (this.enabled)
|
|
22724
22725
|
return;
|
|
22725
22726
|
this.enabled = true;
|
|
22726
22727
|
this.log("registering webusb events");
|
|
22727
|
-
navigator.usb.addEventListener('disconnect', this.handleUSBDisconnected, false);
|
|
22728
|
-
navigator.usb.addEventListener('connect', this.handleUSBConnected, false);
|
|
22728
|
+
(_a = navigator.usb) === null || _a === void 0 ? void 0 : _a.addEventListener('disconnect', this.handleUSBDisconnected, false);
|
|
22729
|
+
(_b = navigator.usb) === null || _b === void 0 ? void 0 : _b.addEventListener('connect', this.handleUSBConnected, false);
|
|
22729
22730
|
}
|
|
22730
22731
|
disable() {
|
|
22732
|
+
var _a, _b;
|
|
22731
22733
|
if (!this.enabled)
|
|
22732
22734
|
return;
|
|
22733
22735
|
this.enabled = false;
|
|
22734
22736
|
this.log(`unregistering webusb events`);
|
|
22735
|
-
navigator.usb.removeEventListener('disconnect', this.handleUSBDisconnected);
|
|
22736
|
-
navigator.usb.removeEventListener('connect', this.handleUSBConnected);
|
|
22737
|
+
(_a = navigator.usb) === null || _a === void 0 ? void 0 : _a.removeEventListener('disconnect', this.handleUSBDisconnected);
|
|
22738
|
+
(_b = navigator.usb) === null || _b === void 0 ? void 0 : _b.removeEventListener('connect', this.handleUSBConnected);
|
|
22737
22739
|
}
|
|
22738
|
-
disposeAsync() {
|
|
22740
|
+
async disposeAsync() {
|
|
22739
22741
|
this.disable();
|
|
22740
|
-
return Promise.resolve();
|
|
22741
22742
|
}
|
|
22742
22743
|
handleUSBDisconnected(event) {
|
|
22744
|
+
var _a;
|
|
22743
22745
|
this.log("device disconnected");
|
|
22744
22746
|
if (event.device == this.dev) {
|
|
22745
22747
|
this.log("clear device");
|
|
22746
22748
|
this.clearDev();
|
|
22747
|
-
|
|
22748
|
-
this.onDeviceConnectionChanged(false);
|
|
22749
|
+
(_a = this.onDeviceConnectionChanged) === null || _a === void 0 ? void 0 : _a.call(this, false);
|
|
22749
22750
|
}
|
|
22750
22751
|
}
|
|
22751
22752
|
handleUSBConnected(event) {
|
|
22753
|
+
var _a;
|
|
22752
22754
|
const newdev = event.device;
|
|
22753
22755
|
this.log(`device connected ${newdev.serialNumber}`);
|
|
22754
22756
|
if (!this.dev && !this.connecting) {
|
|
22755
22757
|
this.log("attach device");
|
|
22756
|
-
|
|
22757
|
-
this.onDeviceConnectionChanged(true);
|
|
22758
|
+
(_a = this.onDeviceConnectionChanged) === null || _a === void 0 ? void 0 : _a.call(this, true);
|
|
22758
22759
|
}
|
|
22759
22760
|
}
|
|
22760
22761
|
clearDev() {
|
|
22762
|
+
var _a;
|
|
22761
22763
|
if (this.dev) {
|
|
22762
22764
|
this.dev = null;
|
|
22763
22765
|
this.epIn = null;
|
|
22764
22766
|
this.epOut = null;
|
|
22765
|
-
|
|
22766
|
-
this.onConnectionChanged();
|
|
22767
|
+
(_a = this.onConnectionChanged) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
22767
22768
|
}
|
|
22768
22769
|
}
|
|
22769
22770
|
error(msg) {
|
|
@@ -22772,27 +22773,28 @@ var pxt;
|
|
|
22772
22773
|
log(msg) {
|
|
22773
22774
|
pxt.debug("webusb: " + msg);
|
|
22774
22775
|
}
|
|
22775
|
-
disconnectAsync() {
|
|
22776
|
+
async disconnectAsync() {
|
|
22776
22777
|
this.ready = false;
|
|
22777
22778
|
if (!this.dev)
|
|
22778
|
-
return
|
|
22779
|
+
return;
|
|
22779
22780
|
this.log("close device");
|
|
22780
|
-
|
|
22781
|
-
.
|
|
22781
|
+
try {
|
|
22782
|
+
await this.dev.close();
|
|
22783
|
+
}
|
|
22784
|
+
catch (e) {
|
|
22782
22785
|
// just ignore errors closing, most likely device just disconnected
|
|
22783
|
-
}
|
|
22784
|
-
|
|
22785
|
-
|
|
22786
|
-
return pxt.U.delay(500);
|
|
22787
|
-
});
|
|
22786
|
+
}
|
|
22787
|
+
this.clearDev();
|
|
22788
|
+
await pxt.U.delay(500);
|
|
22788
22789
|
}
|
|
22789
22790
|
async forgetAsync() {
|
|
22790
22791
|
var _a;
|
|
22791
22792
|
if (!((_a = this.dev) === null || _a === void 0 ? void 0 : _a.forget))
|
|
22792
22793
|
return false;
|
|
22793
22794
|
try {
|
|
22795
|
+
const dev = this.dev;
|
|
22794
22796
|
await this.disconnectAsync();
|
|
22795
|
-
await
|
|
22797
|
+
await dev.forget();
|
|
22796
22798
|
return true;
|
|
22797
22799
|
// connection changed listener will handle disconnecting when access is revoked.
|
|
22798
22800
|
}
|
|
@@ -22800,19 +22802,23 @@ var pxt;
|
|
|
22800
22802
|
return false;
|
|
22801
22803
|
}
|
|
22802
22804
|
}
|
|
22803
|
-
reconnectAsync() {
|
|
22805
|
+
async reconnectAsync() {
|
|
22804
22806
|
this.log("reconnect");
|
|
22805
22807
|
this.setConnecting(true);
|
|
22806
|
-
|
|
22807
|
-
.
|
|
22808
|
-
|
|
22809
|
-
|
|
22808
|
+
try {
|
|
22809
|
+
await this.disconnectAsync();
|
|
22810
|
+
const devs = await tryGetDevicesAsync();
|
|
22811
|
+
await this.connectAsync(devs);
|
|
22812
|
+
}
|
|
22813
|
+
finally {
|
|
22814
|
+
this.setConnecting(false);
|
|
22815
|
+
}
|
|
22810
22816
|
}
|
|
22811
22817
|
setConnecting(v) {
|
|
22818
|
+
var _a;
|
|
22812
22819
|
if (v != this.connecting) {
|
|
22813
22820
|
this.connecting = v;
|
|
22814
|
-
|
|
22815
|
-
this.onConnectionChanged();
|
|
22821
|
+
(_a = this.onConnectionChanged) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
22816
22822
|
}
|
|
22817
22823
|
}
|
|
22818
22824
|
isConnecting() {
|
|
@@ -22872,61 +22878,60 @@ var pxt;
|
|
|
22872
22878
|
this.setConnecting(false);
|
|
22873
22879
|
}
|
|
22874
22880
|
}
|
|
22875
|
-
sendPacketAsync(pkt) {
|
|
22881
|
+
async sendPacketAsync(pkt) {
|
|
22876
22882
|
if (!this.dev)
|
|
22877
|
-
|
|
22883
|
+
throw new Error("Disconnected");
|
|
22878
22884
|
pxt.Util.assert(pkt.length <= 64);
|
|
22879
22885
|
if (!this.epOut) {
|
|
22880
|
-
|
|
22886
|
+
const res = await this.dev.controlTransferOut({
|
|
22881
22887
|
requestType: "class",
|
|
22882
22888
|
recipient: "interface",
|
|
22883
22889
|
request: controlTransferSetReport,
|
|
22884
22890
|
value: controlTransferOutReport,
|
|
22885
22891
|
index: this.iface.interfaceNumber
|
|
22886
|
-
}, pkt)
|
|
22887
|
-
|
|
22888
|
-
|
|
22889
|
-
});
|
|
22892
|
+
}, pkt);
|
|
22893
|
+
if (res.status != "ok")
|
|
22894
|
+
this.error("USB CTRL OUT transfer failed");
|
|
22890
22895
|
}
|
|
22891
|
-
|
|
22892
|
-
.
|
|
22896
|
+
else {
|
|
22897
|
+
const res = await this.dev.transferOut(this.epOut.endpointNumber, pkt);
|
|
22893
22898
|
if (res.status != "ok")
|
|
22894
22899
|
this.error("USB OUT transfer failed");
|
|
22895
|
-
}
|
|
22900
|
+
}
|
|
22896
22901
|
}
|
|
22897
|
-
readLoop() {
|
|
22902
|
+
async readLoop() {
|
|
22898
22903
|
if (this.readLoopStarted)
|
|
22899
22904
|
return;
|
|
22900
22905
|
this.readLoopStarted = true;
|
|
22901
22906
|
this.log("start read loop");
|
|
22902
|
-
|
|
22903
|
-
if (!this.ready)
|
|
22904
|
-
pxt.U.delay(300)
|
|
22905
|
-
|
|
22906
|
-
|
|
22907
|
-
|
|
22908
|
-
|
|
22909
|
-
|
|
22910
|
-
|
|
22911
|
-
|
|
22912
|
-
|
|
22913
|
-
|
|
22914
|
-
|
|
22915
|
-
|
|
22916
|
-
|
|
22917
|
-
|
|
22918
|
-
|
|
22919
|
-
|
|
22920
|
-
|
|
22921
|
-
|
|
22922
|
-
|
|
22923
|
-
|
|
22907
|
+
while (true) {
|
|
22908
|
+
if (!this.ready) {
|
|
22909
|
+
await pxt.U.delay(300);
|
|
22910
|
+
continue;
|
|
22911
|
+
}
|
|
22912
|
+
try {
|
|
22913
|
+
const buf = await this.recvPacketAsync();
|
|
22914
|
+
if (buf[0]) {
|
|
22915
|
+
// we've got data; retry reading immedietly after processing it
|
|
22916
|
+
this.onData(buf);
|
|
22917
|
+
}
|
|
22918
|
+
else {
|
|
22919
|
+
// throttle down if no data coming
|
|
22920
|
+
await pxt.U.delay(500);
|
|
22921
|
+
}
|
|
22922
|
+
}
|
|
22923
|
+
catch (e) {
|
|
22924
|
+
if (this.dev)
|
|
22925
|
+
this.onError(e);
|
|
22926
|
+
await pxt.U.delay(300);
|
|
22927
|
+
}
|
|
22928
|
+
}
|
|
22924
22929
|
}
|
|
22925
22930
|
async recvPacketAsync(timeoutMs) {
|
|
22926
22931
|
const startTime = Date.now();
|
|
22927
22932
|
while (!timeoutMs || Date.now() < startTime + timeoutMs) {
|
|
22928
22933
|
if (!this.dev) {
|
|
22929
|
-
|
|
22934
|
+
throw new Error("Disconnected");
|
|
22930
22935
|
}
|
|
22931
22936
|
const res = await (this.epIn ? this.dev.transferIn(this.epIn.endpointNumber, 64) : this.dev.controlTransferIn({
|
|
22932
22937
|
requestType: "class",
|
|
@@ -22944,84 +22949,84 @@ var pxt;
|
|
|
22944
22949
|
}
|
|
22945
22950
|
this.error("USB IN timed out");
|
|
22946
22951
|
}
|
|
22947
|
-
initAsync() {
|
|
22952
|
+
async initAsync() {
|
|
22953
|
+
var _a;
|
|
22948
22954
|
if (!this.dev)
|
|
22949
|
-
|
|
22950
|
-
|
|
22955
|
+
throw new Error("Disconnected");
|
|
22956
|
+
const dev = this.dev;
|
|
22951
22957
|
this.log("open device");
|
|
22952
|
-
|
|
22953
|
-
|
|
22954
|
-
|
|
22955
|
-
|
|
22956
|
-
|
|
22957
|
-
|
|
22958
|
-
.
|
|
22959
|
-
|
|
22960
|
-
|
|
22961
|
-
|
|
22962
|
-
|
|
22963
|
-
|
|
22964
|
-
if (
|
|
22965
|
-
|
|
22966
|
-
|
|
22967
|
-
if (a0.endpoints.length == 2 &&
|
|
22968
|
-
a0.endpoints.every(e => e.packetSize == 64))
|
|
22969
|
-
return true;
|
|
22970
|
-
}
|
|
22958
|
+
await dev.open();
|
|
22959
|
+
// assume one configuration; no one really does more
|
|
22960
|
+
this.log("select configuration");
|
|
22961
|
+
await dev.selectConfiguration(1);
|
|
22962
|
+
let matchesFilters = (iface) => {
|
|
22963
|
+
let a0 = iface.alternates[0];
|
|
22964
|
+
for (let f of usb.filters) {
|
|
22965
|
+
if (f.classCode == null || a0.interfaceClass === f.classCode) {
|
|
22966
|
+
if (f.subclassCode == null || a0.interfaceSubclass === f.subclassCode) {
|
|
22967
|
+
if (f.protocolCode == null || a0.interfaceProtocol === f.protocolCode) {
|
|
22968
|
+
if (a0.endpoints.length == 0)
|
|
22969
|
+
return true;
|
|
22970
|
+
if (a0.endpoints.length == 2 &&
|
|
22971
|
+
a0.endpoints.every(e => e.packetSize == 64))
|
|
22972
|
+
return true;
|
|
22971
22973
|
}
|
|
22972
22974
|
}
|
|
22973
22975
|
}
|
|
22974
|
-
return false;
|
|
22975
|
-
};
|
|
22976
|
-
this.log("got " + dev.configurations[0].interfaces.length + " interfaces");
|
|
22977
|
-
const matching = dev.configurations[0].interfaces.filter(matchesFilters);
|
|
22978
|
-
let iface = matching[matching.length - 1];
|
|
22979
|
-
this.log(`${matching.length} matching interfaces; picking ${iface ? "#" + iface.interfaceNumber : "n/a"}`);
|
|
22980
|
-
if (!iface)
|
|
22981
|
-
this.error("cannot find supported USB interface");
|
|
22982
|
-
this.altIface = iface.alternates[0];
|
|
22983
|
-
this.iface = iface;
|
|
22984
|
-
if (this.altIface.endpoints.length) {
|
|
22985
|
-
this.log("using dedicated endpoints");
|
|
22986
|
-
this.epIn = this.altIface.endpoints.filter(e => e.direction == "in")[0];
|
|
22987
|
-
this.epOut = this.altIface.endpoints.filter(e => e.direction == "out")[0];
|
|
22988
|
-
pxt.Util.assert(this.epIn.packetSize == 64);
|
|
22989
|
-
pxt.Util.assert(this.epOut.packetSize == 64);
|
|
22990
|
-
}
|
|
22991
|
-
else {
|
|
22992
|
-
this.log("using ctrl pipe");
|
|
22993
22976
|
}
|
|
22994
|
-
|
|
22995
|
-
|
|
22996
|
-
|
|
22997
|
-
|
|
22998
|
-
|
|
22999
|
-
|
|
23000
|
-
|
|
23001
|
-
|
|
23002
|
-
|
|
23003
|
-
|
|
23004
|
-
|
|
23005
|
-
|
|
22977
|
+
return false;
|
|
22978
|
+
};
|
|
22979
|
+
this.log("got " + dev.configurations[0].interfaces.length + " interfaces");
|
|
22980
|
+
const matching = dev.configurations[0].interfaces.filter(matchesFilters);
|
|
22981
|
+
let iface = matching[matching.length - 1];
|
|
22982
|
+
this.log(`${matching.length} matching interfaces; picking ${iface ? "#" + iface.interfaceNumber : "n/a"}`);
|
|
22983
|
+
if (!iface)
|
|
22984
|
+
this.error("cannot find supported USB interface");
|
|
22985
|
+
this.altIface = iface.alternates[0];
|
|
22986
|
+
this.iface = iface;
|
|
22987
|
+
if (this.altIface.endpoints.length) {
|
|
22988
|
+
this.log("using dedicated endpoints");
|
|
22989
|
+
this.epIn = this.altIface.endpoints.filter(e => e.direction == "in")[0];
|
|
22990
|
+
this.epOut = this.altIface.endpoints.filter(e => e.direction == "out")[0];
|
|
22991
|
+
pxt.Util.assert(this.epIn.packetSize == 64);
|
|
22992
|
+
pxt.Util.assert(this.epOut.packetSize == 64);
|
|
22993
|
+
}
|
|
22994
|
+
else {
|
|
22995
|
+
this.log("using ctrl pipe");
|
|
22996
|
+
}
|
|
22997
|
+
this.log("claim interface");
|
|
22998
|
+
await dev.claimInterface(iface.interfaceNumber);
|
|
22999
|
+
this.log("device ready");
|
|
23000
|
+
this.lastKnownDeviceSerialNumber = this.dev.serialNumber;
|
|
23001
|
+
this.ready = true;
|
|
23002
|
+
if (isHF2) {
|
|
23003
|
+
// just starting, not waiting on it.
|
|
23004
|
+
/* await */ this.readLoop();
|
|
23005
|
+
}
|
|
23006
|
+
(_a = this.onConnectionChanged) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
23006
23007
|
}
|
|
23007
23008
|
}
|
|
23008
|
-
function pairAsync() {
|
|
23009
|
-
|
|
23010
|
-
|
|
23011
|
-
|
|
23012
|
-
|
|
23013
|
-
|
|
23009
|
+
async function pairAsync() {
|
|
23010
|
+
var _a;
|
|
23011
|
+
try {
|
|
23012
|
+
const dev = await ((_a = navigator.usb) === null || _a === void 0 ? void 0 : _a.requestDevice({
|
|
23013
|
+
filters: usb.filters
|
|
23014
|
+
}));
|
|
23015
|
+
return !!dev;
|
|
23016
|
+
}
|
|
23017
|
+
catch (e) {
|
|
23014
23018
|
// user cancelled
|
|
23015
23019
|
if (e.name == "NotFoundError")
|
|
23016
23020
|
return undefined;
|
|
23017
23021
|
throw e;
|
|
23018
|
-
}
|
|
23022
|
+
}
|
|
23019
23023
|
}
|
|
23020
23024
|
usb.pairAsync = pairAsync;
|
|
23021
23025
|
async function tryGetDevicesAsync() {
|
|
23026
|
+
var _a;
|
|
23022
23027
|
pxt.log(`webusb: get devices`);
|
|
23023
23028
|
try {
|
|
23024
|
-
const devs = await navigator.usb.getDevices();
|
|
23029
|
+
const devs = await ((_a = navigator.usb) === null || _a === void 0 ? void 0 : _a.getDevices());
|
|
23025
23030
|
return devs || [];
|
|
23026
23031
|
}
|
|
23027
23032
|
catch (e) {
|