pxt-core 7.5.39 → 7.5.42
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/cli.js +9 -1
- package/built/pxt.js +67 -37
- package/built/pxtblockly.js +157 -16
- package/built/pxtblocks.d.ts +46 -9
- package/built/pxtblocks.js +157 -16
- package/built/pxtlib.d.ts +6 -0
- package/built/pxtlib.js +58 -36
- package/built/target.js +1 -1
- package/built/web/main.js +1 -1
- package/built/web/pxtapp.js +1 -1
- package/built/web/pxtasseteditor.js +1 -1
- package/built/web/pxtblockly.js +2 -2
- package/built/web/pxtblocks.js +1 -1
- package/built/web/pxtembed.js +2 -2
- 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/localtypings/pxtarget.d.ts +5 -7
- package/package.json +1 -1
- package/react-common/components/extensions/ExtensionCard.tsx +4 -4
- package/theme/common.less +30 -2
package/built/pxtblocks.js
CHANGED
|
@@ -2400,6 +2400,7 @@ var pxt;
|
|
|
2400
2400
|
registerFieldEditor('position', pxtblockly.FieldPosition);
|
|
2401
2401
|
registerFieldEditor('melody', pxtblockly.FieldCustomMelody);
|
|
2402
2402
|
registerFieldEditor('soundeffect', pxtblockly.FieldSoundEffect);
|
|
2403
|
+
registerFieldEditor('autocomplete', pxtblockly.FieldAutoComplete);
|
|
2403
2404
|
}
|
|
2404
2405
|
blocks.initFieldEditors = initFieldEditors;
|
|
2405
2406
|
function registerFieldEditor(selector, field, validator) {
|
|
@@ -8475,6 +8476,156 @@ var pxtblockly;
|
|
|
8475
8476
|
}
|
|
8476
8477
|
pxtblockly.FieldArgumentVariable = FieldArgumentVariable;
|
|
8477
8478
|
})(pxtblockly || (pxtblockly = {}));
|
|
8479
|
+
/// <reference path="../../localtypings/pxtblockly.d.ts" />
|
|
8480
|
+
var pxtblockly;
|
|
8481
|
+
(function (pxtblockly) {
|
|
8482
|
+
class FieldTextDropdown extends Blockly.FieldTextDropdown {
|
|
8483
|
+
constructor(text, options, opt_validator) {
|
|
8484
|
+
super(text, options.values, opt_validator);
|
|
8485
|
+
this.isFieldCustom_ = true;
|
|
8486
|
+
}
|
|
8487
|
+
}
|
|
8488
|
+
pxtblockly.FieldTextDropdown = FieldTextDropdown;
|
|
8489
|
+
})(pxtblockly || (pxtblockly = {}));
|
|
8490
|
+
/// <reference path="../../localtypings/pxtblockly.d.ts" />
|
|
8491
|
+
/// <reference path="./field_textdropdown.ts" />
|
|
8492
|
+
var pxtblockly;
|
|
8493
|
+
(function (pxtblockly) {
|
|
8494
|
+
class FieldAutoComplete extends Blockly.FieldTextDropdown {
|
|
8495
|
+
constructor(text, options, opt_validator) {
|
|
8496
|
+
super(text, () => [], opt_validator);
|
|
8497
|
+
this.isFieldCustom_ = true;
|
|
8498
|
+
this.key = options.key;
|
|
8499
|
+
this.isTextValid_ = true;
|
|
8500
|
+
}
|
|
8501
|
+
isOptionListDynamic() {
|
|
8502
|
+
return true;
|
|
8503
|
+
}
|
|
8504
|
+
getDisplayText_() {
|
|
8505
|
+
return this.parsedValue || "";
|
|
8506
|
+
}
|
|
8507
|
+
doValueUpdate_(newValue) {
|
|
8508
|
+
if (newValue === null)
|
|
8509
|
+
return;
|
|
8510
|
+
if (/['"`].*['"`]/.test(newValue)) {
|
|
8511
|
+
this.parsedValue = JSON.parse(newValue);
|
|
8512
|
+
}
|
|
8513
|
+
else {
|
|
8514
|
+
this.parsedValue = newValue;
|
|
8515
|
+
}
|
|
8516
|
+
this.value_ = this.parsedValue;
|
|
8517
|
+
}
|
|
8518
|
+
getValue() {
|
|
8519
|
+
if (this.parsedValue) {
|
|
8520
|
+
return JSON.stringify(this.parsedValue);
|
|
8521
|
+
}
|
|
8522
|
+
else
|
|
8523
|
+
return '""';
|
|
8524
|
+
}
|
|
8525
|
+
getOptions() {
|
|
8526
|
+
var _a;
|
|
8527
|
+
const workspace = (_a = this.sourceBlock_) === null || _a === void 0 ? void 0 : _a.workspace;
|
|
8528
|
+
if (!workspace)
|
|
8529
|
+
return [];
|
|
8530
|
+
const res = [];
|
|
8531
|
+
const fields = pxtblockly.getAllFields(workspace, field => field instanceof FieldAutoComplete && field.getKey() === this.key);
|
|
8532
|
+
const options = fields.map(field => field.ref.getDisplayText_());
|
|
8533
|
+
for (const option of options) {
|
|
8534
|
+
if (!option.trim() || res.some(tuple => tuple[0] === option))
|
|
8535
|
+
continue;
|
|
8536
|
+
res.push([option, option]);
|
|
8537
|
+
}
|
|
8538
|
+
res.sort((a, b) => a[0].localeCompare(b[0]));
|
|
8539
|
+
return res;
|
|
8540
|
+
}
|
|
8541
|
+
showDropdown_() {
|
|
8542
|
+
const options = this.getOptions();
|
|
8543
|
+
if (options.length)
|
|
8544
|
+
super.showDropdown_();
|
|
8545
|
+
}
|
|
8546
|
+
getKey() {
|
|
8547
|
+
if (this.key)
|
|
8548
|
+
return this.key;
|
|
8549
|
+
if (this.sourceBlock_)
|
|
8550
|
+
return this.sourceBlock_.type;
|
|
8551
|
+
return undefined;
|
|
8552
|
+
}
|
|
8553
|
+
// Copied from field_string in pxt-blockly
|
|
8554
|
+
initView() {
|
|
8555
|
+
// Add quotes around the string
|
|
8556
|
+
// Positioned on updatSize, after text size is calculated.
|
|
8557
|
+
this.quoteSize_ = 16;
|
|
8558
|
+
this.quoteWidth_ = 8;
|
|
8559
|
+
this.quoteLeftX_ = 0;
|
|
8560
|
+
this.quoteRightX_ = 0;
|
|
8561
|
+
this.quoteY_ = 10;
|
|
8562
|
+
if (this.quoteLeft_)
|
|
8563
|
+
this.quoteLeft_.parentNode.removeChild(this.quoteLeft_);
|
|
8564
|
+
this.quoteLeft_ = Blockly.utils.dom.createSvgElement('text', {
|
|
8565
|
+
'font-size': this.quoteSize_ + 'px',
|
|
8566
|
+
'class': 'field-text-quote'
|
|
8567
|
+
}, this.fieldGroup_);
|
|
8568
|
+
super.initView();
|
|
8569
|
+
if (this.quoteRight_)
|
|
8570
|
+
this.quoteRight_.parentNode.removeChild(this.quoteRight_);
|
|
8571
|
+
this.quoteRight_ = Blockly.utils.dom.createSvgElement('text', {
|
|
8572
|
+
'font-size': this.quoteSize_ + 'px',
|
|
8573
|
+
'class': 'field-text-quote'
|
|
8574
|
+
}, this.fieldGroup_);
|
|
8575
|
+
this.quoteLeft_.appendChild(document.createTextNode('"'));
|
|
8576
|
+
this.quoteRight_.appendChild(document.createTextNode('"'));
|
|
8577
|
+
}
|
|
8578
|
+
// Copied from field_string in pxt-blockly
|
|
8579
|
+
updateSize_() {
|
|
8580
|
+
super.updateSize_();
|
|
8581
|
+
const sWidth = Math.max(this.size_.width, 1);
|
|
8582
|
+
const xPadding = 3;
|
|
8583
|
+
let addedWidth = this.positionLeft(sWidth + xPadding);
|
|
8584
|
+
this.textElement_.setAttribute('x', addedWidth.toString());
|
|
8585
|
+
addedWidth += this.positionRight(addedWidth + sWidth + xPadding);
|
|
8586
|
+
this.size_.width = sWidth + addedWidth;
|
|
8587
|
+
}
|
|
8588
|
+
// Copied from field_string in pxt-blockly
|
|
8589
|
+
positionRight(x) {
|
|
8590
|
+
if (!this.quoteRight_) {
|
|
8591
|
+
return 0;
|
|
8592
|
+
}
|
|
8593
|
+
let addedWidth = 0;
|
|
8594
|
+
if (this.sourceBlock_.RTL) {
|
|
8595
|
+
this.quoteRightX_ = Blockly.FieldString.quotePadding;
|
|
8596
|
+
addedWidth = this.quoteWidth_ + Blockly.FieldString.quotePadding;
|
|
8597
|
+
}
|
|
8598
|
+
else {
|
|
8599
|
+
this.quoteRightX_ = x + Blockly.FieldString.quotePadding;
|
|
8600
|
+
addedWidth = this.quoteWidth_ + Blockly.FieldString.quotePadding;
|
|
8601
|
+
}
|
|
8602
|
+
this.quoteRight_.setAttribute('transform', 'translate(' + this.quoteRightX_ + ',' + this.quoteY_ + ')');
|
|
8603
|
+
return addedWidth;
|
|
8604
|
+
}
|
|
8605
|
+
// Copied from field_string in pxt-blockly
|
|
8606
|
+
positionLeft(x) {
|
|
8607
|
+
if (!this.quoteLeft_) {
|
|
8608
|
+
return 0;
|
|
8609
|
+
}
|
|
8610
|
+
let addedWidth = 0;
|
|
8611
|
+
if (this.sourceBlock_.RTL) {
|
|
8612
|
+
this.quoteLeftX_ = x + this.quoteWidth_ + Blockly.FieldString.quotePadding * 2;
|
|
8613
|
+
addedWidth = this.quoteWidth_ + Blockly.FieldString.quotePadding;
|
|
8614
|
+
}
|
|
8615
|
+
else {
|
|
8616
|
+
this.quoteLeftX_ = 0;
|
|
8617
|
+
addedWidth = this.quoteWidth_ + Blockly.FieldString.quotePadding;
|
|
8618
|
+
}
|
|
8619
|
+
this.quoteLeft_.setAttribute('transform', 'translate(' + this.quoteLeftX_ + ',' + this.quoteY_ + ')');
|
|
8620
|
+
return addedWidth;
|
|
8621
|
+
}
|
|
8622
|
+
createSVGArrow_() {
|
|
8623
|
+
// This creates the little arrow for dropdown fields. Intentionally
|
|
8624
|
+
// do nothing
|
|
8625
|
+
}
|
|
8626
|
+
}
|
|
8627
|
+
pxtblockly.FieldAutoComplete = FieldAutoComplete;
|
|
8628
|
+
})(pxtblockly || (pxtblockly = {}));
|
|
8478
8629
|
/// <reference path="../../localtypings/blockly.d.ts" />
|
|
8479
8630
|
/// <reference path="../../built/pxtsim.d.ts" />
|
|
8480
8631
|
var pxtblockly;
|
|
@@ -12167,17 +12318,6 @@ var pxtblockly;
|
|
|
12167
12318
|
})(pxtblockly || (pxtblockly = {}));
|
|
12168
12319
|
/// <reference path="../../localtypings/pxtblockly.d.ts" />
|
|
12169
12320
|
var pxtblockly;
|
|
12170
|
-
(function (pxtblockly) {
|
|
12171
|
-
class FieldTextDropdown extends Blockly.FieldTextDropdown {
|
|
12172
|
-
constructor(text, options, opt_validator) {
|
|
12173
|
-
super(text, options.values, opt_validator);
|
|
12174
|
-
this.isFieldCustom_ = true;
|
|
12175
|
-
}
|
|
12176
|
-
}
|
|
12177
|
-
pxtblockly.FieldTextDropdown = FieldTextDropdown;
|
|
12178
|
-
})(pxtblockly || (pxtblockly = {}));
|
|
12179
|
-
/// <reference path="../../localtypings/pxtblockly.d.ts" />
|
|
12180
|
-
var pxtblockly;
|
|
12181
12321
|
(function (pxtblockly) {
|
|
12182
12322
|
class FieldTextInput extends Blockly.FieldTextInput {
|
|
12183
12323
|
constructor(value, options, opt_validator) {
|
|
@@ -13289,11 +13429,11 @@ var pxtblockly;
|
|
|
13289
13429
|
}
|
|
13290
13430
|
}
|
|
13291
13431
|
function getAllBlocksWithTilemaps(ws) {
|
|
13292
|
-
return
|
|
13432
|
+
return getAllFields(ws, f => f instanceof pxtblockly.FieldTilemap && !f.isGreyBlock);
|
|
13293
13433
|
}
|
|
13294
13434
|
pxtblockly.getAllBlocksWithTilemaps = getAllBlocksWithTilemaps;
|
|
13295
13435
|
function getAllBlocksWithTilesets(ws) {
|
|
13296
|
-
return
|
|
13436
|
+
return getAllFields(ws, f => f instanceof pxtblockly.FieldTileset);
|
|
13297
13437
|
}
|
|
13298
13438
|
pxtblockly.getAllBlocksWithTilesets = getAllBlocksWithTilesets;
|
|
13299
13439
|
function needsTilemapUpgrade(ws) {
|
|
@@ -13349,7 +13489,7 @@ var pxtblockly;
|
|
|
13349
13489
|
}
|
|
13350
13490
|
}
|
|
13351
13491
|
pxtblockly.upgradeTilemapsInWorkspace = upgradeTilemapsInWorkspace;
|
|
13352
|
-
function
|
|
13492
|
+
function getAllFields(ws, predicate) {
|
|
13353
13493
|
const result = [];
|
|
13354
13494
|
const top = ws.getTopBlocks(false);
|
|
13355
13495
|
top.forEach(block => getAllFieldsRecursive(block));
|
|
@@ -13370,6 +13510,7 @@ var pxtblockly;
|
|
|
13370
13510
|
}
|
|
13371
13511
|
}
|
|
13372
13512
|
}
|
|
13513
|
+
pxtblockly.getAllFields = getAllFields;
|
|
13373
13514
|
function getAllReferencedTiles(workspace, excludeBlockID) {
|
|
13374
13515
|
var _a;
|
|
13375
13516
|
let all = {};
|
|
@@ -13408,10 +13549,10 @@ var pxtblockly;
|
|
|
13408
13549
|
function getTemporaryAssets(workspace, type) {
|
|
13409
13550
|
switch (type) {
|
|
13410
13551
|
case "image" /* Image */:
|
|
13411
|
-
return
|
|
13552
|
+
return getAllFields(workspace, field => field instanceof pxtblockly.FieldSpriteEditor && field.isTemporaryAsset())
|
|
13412
13553
|
.map(f => f.ref.getAsset());
|
|
13413
13554
|
case "animation" /* Animation */:
|
|
13414
|
-
return
|
|
13555
|
+
return getAllFields(workspace, field => field instanceof pxtblockly.FieldAnimationEditor && field.isTemporaryAsset())
|
|
13415
13556
|
.map(f => f.ref.getAsset());
|
|
13416
13557
|
default: return [];
|
|
13417
13558
|
}
|
package/built/pxtlib.d.ts
CHANGED
|
@@ -1438,6 +1438,7 @@ declare namespace pxt.HF2 {
|
|
|
1438
1438
|
function enableLog(): void;
|
|
1439
1439
|
class Wrapper implements pxt.packetio.PacketIOWrapper {
|
|
1440
1440
|
readonly io: pxt.packetio.PacketIO;
|
|
1441
|
+
private initialized;
|
|
1441
1442
|
private cmdSeq;
|
|
1442
1443
|
constructor(io: pxt.packetio.PacketIO);
|
|
1443
1444
|
private lock;
|
|
@@ -1458,9 +1459,12 @@ declare namespace pxt.HF2 {
|
|
|
1458
1459
|
jacdacAvailable: boolean;
|
|
1459
1460
|
onSerial: (buf: Uint8Array, isStderr: boolean) => void;
|
|
1460
1461
|
onCustomEvent: (type: string, payload: Uint8Array) => void;
|
|
1462
|
+
onConnectionChanged: () => void;
|
|
1461
1463
|
private resetState;
|
|
1462
1464
|
onEvent(id: number, f: (buf: Uint8Array) => void): void;
|
|
1463
1465
|
sendCustomEventAsync(type: string, payload: Uint8Array): Promise<void>;
|
|
1466
|
+
isConnected(): boolean;
|
|
1467
|
+
isConnecting(): boolean;
|
|
1464
1468
|
reconnectAsync(): Promise<void>;
|
|
1465
1469
|
disconnectAsync(): Promise<void>;
|
|
1466
1470
|
error(m: string): any;
|
|
@@ -1849,6 +1853,8 @@ declare namespace pxt.packetio {
|
|
|
1849
1853
|
onSerial: (buf: Uint8Array, isStderr: boolean) => void;
|
|
1850
1854
|
reconnectAsync(): Promise<void>;
|
|
1851
1855
|
disconnectAsync(): Promise<void>;
|
|
1856
|
+
isConnected(): boolean;
|
|
1857
|
+
isConnecting(): boolean;
|
|
1852
1858
|
reflashAsync(resp: pxtc.CompileResult): Promise<void>;
|
|
1853
1859
|
onCustomEvent: (type: string, payload: Uint8Array) => void;
|
|
1854
1860
|
sendCustomEventAsync(type: string, payload: Uint8Array): Promise<void>;
|
package/built/pxtlib.js
CHANGED
|
@@ -10484,13 +10484,13 @@ var pxt;
|
|
|
10484
10484
|
return false;
|
|
10485
10485
|
}
|
|
10486
10486
|
function isRepoApproved(repo, config) {
|
|
10487
|
+
var _a;
|
|
10487
10488
|
if (isOrgApproved(repo, config))
|
|
10488
10489
|
return true;
|
|
10489
10490
|
if (!repo || !config)
|
|
10490
10491
|
return false;
|
|
10491
10492
|
if (repo.fullName
|
|
10492
|
-
&& config.
|
|
10493
|
-
&& config.approvedRepos.some(fn => fn.toLowerCase() == repo.fullName.toLowerCase()))
|
|
10493
|
+
&& ((_a = config.approvedRepoLib) === null || _a === void 0 ? void 0 : _a[repo.fullName.toLowerCase()]))
|
|
10494
10494
|
return true;
|
|
10495
10495
|
return false;
|
|
10496
10496
|
}
|
|
@@ -10623,52 +10623,60 @@ var pxt;
|
|
|
10623
10623
|
return parts.filter(p => !!p).join('/');
|
|
10624
10624
|
}
|
|
10625
10625
|
github.join = join;
|
|
10626
|
-
function
|
|
10627
|
-
|
|
10626
|
+
function upgradeRules(cfg, id) {
|
|
10627
|
+
var _a;
|
|
10628
|
+
if (!cfg)
|
|
10628
10629
|
return null;
|
|
10629
10630
|
const parsed = parseRepoId(id);
|
|
10630
10631
|
if (!parsed)
|
|
10631
10632
|
return null;
|
|
10632
|
-
|
|
10633
|
+
const repoData = cfg.approvedRepoLib;
|
|
10634
|
+
// lookup base repo for upgrade rules
|
|
10633
10635
|
// (since nested repoes share the same version number)
|
|
10634
|
-
return pxt.U.lookup(cfg.
|
|
10636
|
+
return cfg.approvedRepoLib && ((_a = pxt.U.lookup(cfg.approvedRepoLib, parsed.slug.toLowerCase())) === null || _a === void 0 ? void 0 : _a.upgrades);
|
|
10635
10637
|
}
|
|
10636
10638
|
function upgradedDisablesVariants(cfg, id) {
|
|
10637
|
-
const
|
|
10638
|
-
|
|
10639
|
-
|
|
10640
|
-
|
|
10641
|
-
|
|
10642
|
-
|
|
10643
|
-
|
|
10639
|
+
const rules = upgradeRules(cfg, id) || [];
|
|
10640
|
+
if (!rules)
|
|
10641
|
+
return null;
|
|
10642
|
+
for (const upgr of rules) {
|
|
10643
|
+
const m = /^dv:(.*)/.exec(upgr);
|
|
10644
|
+
if (m) {
|
|
10645
|
+
const disabled = m[1].split(/,/);
|
|
10646
|
+
if (disabled.some(d => !/^\w+$/.test(d)))
|
|
10647
|
+
return null;
|
|
10648
|
+
return disabled;
|
|
10649
|
+
}
|
|
10644
10650
|
}
|
|
10645
10651
|
return null;
|
|
10646
10652
|
}
|
|
10647
10653
|
function upgradedPackageReference(cfg, id) {
|
|
10648
|
-
const
|
|
10649
|
-
if (!
|
|
10654
|
+
const rules = upgradeRules(cfg, id);
|
|
10655
|
+
if (!rules)
|
|
10650
10656
|
return null;
|
|
10651
|
-
const
|
|
10652
|
-
|
|
10653
|
-
|
|
10654
|
-
|
|
10655
|
-
|
|
10656
|
-
|
|
10657
|
-
|
|
10658
|
-
|
|
10659
|
-
|
|
10657
|
+
for (const upgr of rules) {
|
|
10658
|
+
const m = /^min:(.*)/.exec(upgr);
|
|
10659
|
+
const minV = m && pxt.semver.tryParse(m[1]);
|
|
10660
|
+
if (minV) {
|
|
10661
|
+
const parsed = parseRepoId(id);
|
|
10662
|
+
const currV = pxt.semver.tryParse(parsed.tag);
|
|
10663
|
+
if (currV && pxt.semver.cmp(currV, minV) < 0) {
|
|
10664
|
+
parsed.tag = m[1];
|
|
10665
|
+
pxt.debug(`upgrading ${id} to ${m[1]}`);
|
|
10666
|
+
return stringifyRepo(parsed);
|
|
10667
|
+
}
|
|
10668
|
+
else {
|
|
10669
|
+
if (!currV)
|
|
10670
|
+
pxt.log(`not upgrading ${id} - cannot parse version`);
|
|
10671
|
+
return null;
|
|
10672
|
+
}
|
|
10660
10673
|
}
|
|
10661
10674
|
else {
|
|
10662
|
-
if
|
|
10663
|
-
|
|
10664
|
-
|
|
10675
|
+
// check if the rule looks valid at all
|
|
10676
|
+
if (!upgradedDisablesVariants(cfg, id))
|
|
10677
|
+
pxt.log(`invalid upgrade rule: ${id} -> ${upgr}`);
|
|
10665
10678
|
}
|
|
10666
10679
|
}
|
|
10667
|
-
else {
|
|
10668
|
-
// check if the rule looks valid at all
|
|
10669
|
-
if (!upgradedDisablesVariants(cfg, id))
|
|
10670
|
-
pxt.log(`invalid upgrade rule: ${id} -> ${upgr}`);
|
|
10671
|
-
}
|
|
10672
10680
|
return id;
|
|
10673
10681
|
}
|
|
10674
10682
|
github.upgradedPackageReference = upgradedPackageReference;
|
|
@@ -10998,6 +11006,7 @@ var pxt;
|
|
|
10998
11006
|
constructor(io) {
|
|
10999
11007
|
var _a;
|
|
11000
11008
|
this.io = io;
|
|
11009
|
+
this.initialized = false;
|
|
11001
11010
|
this.cmdSeq = pxt.U.randomUint32();
|
|
11002
11011
|
this.lock = new pxt.U.PromiseQueue();
|
|
11003
11012
|
this.flashing = false;
|
|
@@ -11012,6 +11021,7 @@ var pxt;
|
|
|
11012
11021
|
this.jacdacAvailable = false;
|
|
11013
11022
|
this.onSerial = (buf, isStderr) => { };
|
|
11014
11023
|
this.onCustomEvent = (type, payload) => { };
|
|
11024
|
+
this.onConnectionChanged = () => { };
|
|
11015
11025
|
let frames = [];
|
|
11016
11026
|
io.onDeviceConnectionChanged = connect => this.disconnectAsync()
|
|
11017
11027
|
.then(() => connect && this.reconnectAsync());
|
|
@@ -11079,6 +11089,7 @@ var pxt;
|
|
|
11079
11089
|
});
|
|
11080
11090
|
}
|
|
11081
11091
|
resetState() {
|
|
11092
|
+
this.initialized = false;
|
|
11082
11093
|
this.lock = new pxt.U.PromiseQueue();
|
|
11083
11094
|
this.info = null;
|
|
11084
11095
|
this.infoRaw = null;
|
|
@@ -11101,6 +11112,12 @@ var pxt;
|
|
|
11101
11112
|
return Promise.resolve(); // ignore
|
|
11102
11113
|
return Promise.reject(new Error("invalid custom event type"));
|
|
11103
11114
|
}
|
|
11115
|
+
isConnected() {
|
|
11116
|
+
return this.io.isConnected() && this.initialized;
|
|
11117
|
+
}
|
|
11118
|
+
isConnecting() {
|
|
11119
|
+
return this.io.isConnecting() || (this.io.isConnected() && !this.initialized);
|
|
11120
|
+
}
|
|
11104
11121
|
reconnectAsync() {
|
|
11105
11122
|
this.resetState();
|
|
11106
11123
|
log(`reconnect raw=${this.rawMode}`);
|
|
@@ -11309,8 +11326,10 @@ var pxt;
|
|
|
11309
11326
|
.then(() => { });
|
|
11310
11327
|
}
|
|
11311
11328
|
initAsync() {
|
|
11312
|
-
if (this.rawMode)
|
|
11329
|
+
if (this.rawMode) {
|
|
11330
|
+
this.initialized = true;
|
|
11313
11331
|
return Promise.resolve();
|
|
11332
|
+
}
|
|
11314
11333
|
return Promise.resolve()
|
|
11315
11334
|
.then(() => this.talkAsync(HF2.HF2_CMD_BININFO))
|
|
11316
11335
|
.then(binfo => {
|
|
@@ -11344,13 +11363,16 @@ var pxt;
|
|
|
11344
11363
|
};
|
|
11345
11364
|
log(`Board-ID: ${this.info.BoardID} v${this.info.Parsed.Version} f${this.info.Parsed.Features}`);
|
|
11346
11365
|
})
|
|
11347
|
-
.then(() => this.talkAsync(HF2.HF2_CMD_JDS_CONFIG, new Uint8Array([1]))
|
|
11366
|
+
.then(() => this.talkAsync(HF2.HF2_CMD_JDS_CONFIG, new Uint8Array([1]))
|
|
11367
|
+
.then(() => {
|
|
11348
11368
|
this.jacdacAvailable = true;
|
|
11349
11369
|
}, _err => {
|
|
11350
11370
|
this.jacdacAvailable = false;
|
|
11351
11371
|
}))
|
|
11352
11372
|
.then(() => {
|
|
11353
11373
|
this.reconnectTries = 0;
|
|
11374
|
+
this.initialized = true;
|
|
11375
|
+
this.io.onConnectionChanged();
|
|
11354
11376
|
});
|
|
11355
11377
|
}
|
|
11356
11378
|
}
|
|
@@ -14852,11 +14874,11 @@ var pxt;
|
|
|
14852
14874
|
* The DAP wrapper is active and the device is connected
|
|
14853
14875
|
*/
|
|
14854
14876
|
function isConnected() {
|
|
14855
|
-
return !!wrapper
|
|
14877
|
+
return !!(wrapper === null || wrapper === void 0 ? void 0 : wrapper.isConnected());
|
|
14856
14878
|
}
|
|
14857
14879
|
packetio.isConnected = isConnected;
|
|
14858
14880
|
function isConnecting() {
|
|
14859
|
-
return !!wrapper
|
|
14881
|
+
return !!(wrapper === null || wrapper === void 0 ? void 0 : wrapper.isConnecting());
|
|
14860
14882
|
}
|
|
14861
14883
|
packetio.isConnecting = isConnecting;
|
|
14862
14884
|
function icon() {
|