2019-12-02 05:58:26 +01:00
|
|
|
/// <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="dapjs.d.ts" />
|
2020-08-19 22:03:58 +02:00
|
|
|
import * as dialogs from "./dialogs";
|
|
|
|
import * as flash from "./flash";
|
|
|
|
import * as patch from "./patch";
|
2019-12-02 05:58:26 +01:00
|
|
|
|
|
|
|
pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): Promise<pxt.editor.ExtensionResult> {
|
|
|
|
pxt.debug('loading microbit target extensions...')
|
|
|
|
|
|
|
|
const manyAny = Math as any;
|
|
|
|
if (!manyAny.imul)
|
|
|
|
manyAny.imul = function (a: number, b: number): number {
|
|
|
|
const ah = (a >>> 16) & 0xffff;
|
|
|
|
const al = a & 0xffff;
|
|
|
|
const bh = (b >>> 16) & 0xffff;
|
|
|
|
const bl = b & 0xffff;
|
|
|
|
// the shift by 0 fixes the sign on the high part
|
|
|
|
// the final |0 converts the unsigned value into a signed value
|
|
|
|
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0) | 0);
|
|
|
|
};
|
|
|
|
|
|
|
|
const res: pxt.editor.ExtensionResult = {
|
|
|
|
hexFileImporters: [{
|
|
|
|
id: "blockly",
|
|
|
|
canImport: data => data.meta.cloudId == "microbit.co.uk" && data.meta.editor == "blockly",
|
|
|
|
importAsync: (project, data) => {
|
|
|
|
pxt.tickEvent('import.legacyblocks.redirect');
|
2020-08-19 22:03:58 +02:00
|
|
|
return dialogs.cantImportAsync(project);
|
2019-12-02 05:58:26 +01:00
|
|
|
}
|
|
|
|
}, {
|
|
|
|
id: "td",
|
|
|
|
canImport: data => data.meta.cloudId == "microbit.co.uk" && data.meta.editor == "touchdevelop",
|
|
|
|
importAsync: (project, data) => {
|
|
|
|
pxt.tickEvent('import.legacytd.redirect');
|
2020-08-19 22:03:58 +02:00
|
|
|
return dialogs.cantImportAsync(project);
|
2019-12-02 05:58:26 +01:00
|
|
|
}
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
|
|
|
|
pxt.usb.setFilters([{
|
2020-08-19 22:03:58 +02:00
|
|
|
vendorId: 0x1366,
|
|
|
|
productId: 0x1025
|
|
|
|
},
|
|
|
|
{
|
2019-12-02 05:58:26 +01:00
|
|
|
vendorId: 0x0D28,
|
2020-08-19 22:03:58 +02:00
|
|
|
productId: 0x0204
|
2019-12-02 05:58:26 +01:00
|
|
|
}])
|
|
|
|
|
2020-08-19 22:03:58 +02:00
|
|
|
res.mkPacketIOWrapper = flash.mkDAPLinkPacketIOWrapper;
|
|
|
|
res.blocklyPatch = patch.patchBlocks;
|
|
|
|
res.renderBrowserDownloadInstructions = dialogs.renderBrowserDownloadInstructions;
|
|
|
|
res.renderUsbPairDialog = dialogs.renderUsbPairDialog;
|
2019-12-02 05:58:26 +01:00
|
|
|
return Promise.resolve<pxt.editor.ExtensionResult>(res);
|
|
|
|
}
|