2017-04-19 01:26:13 +02:00
|
|
|
/// <reference path="../node_modules/pxt-core/built/pxteditor.d.ts" />
|
|
|
|
|
|
|
|
namespace pxt.editor {
|
|
|
|
initExtensionsAsync = function(opts: pxt.editor.ExtensionOptions): Promise<pxt.editor.ExtensionResult> {
|
|
|
|
pxt.debug('loading microbit target extensions...')
|
|
|
|
const res: pxt.editor.ExtensionResult = {
|
|
|
|
hexFileImporters: [{
|
|
|
|
id: "blockly",
|
|
|
|
canImport: data => data.meta.cloudId == "microbit.co.uk" && data.meta.editor == "blockly",
|
|
|
|
importAsync: (project, data) => project.createProjectAsync({
|
|
|
|
filesOverride: {
|
|
|
|
"main.blocks": data.source
|
|
|
|
}, name: data.meta.name
|
|
|
|
})
|
|
|
|
}, {
|
2017-04-19 19:40:39 +02:00
|
|
|
id: "td",
|
|
|
|
canImport: data => data.meta.cloudId == "microbit.co.uk" && data.meta.editor == "touchdevelop",
|
|
|
|
importAsync: (project, data) =>
|
|
|
|
project.createProjectAsync({
|
|
|
|
filesOverride: { "main.blocks": "", "main.ts": " " },
|
|
|
|
name: data.meta.name
|
|
|
|
})
|
|
|
|
.then(() => project.convertTouchDevelopToTypeScriptAsync(data.source))
|
|
|
|
.then(text => project.overrideTypescriptFile(text))
|
|
|
|
}]
|
2017-04-19 01:26:13 +02:00
|
|
|
};
|
|
|
|
return Promise.resolve<pxt.editor.ExtensionResult>(res);
|
|
|
|
}
|
|
|
|
}
|