Added extensions (#385)
* inject file importers as extensions * logging * updated signature
This commit is contained in:
parent
c1dadd9568
commit
33012441bc
28
editor/extension.ts
Normal file
28
editor/extension.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/// <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
|
||||||
|
})
|
||||||
|
}, {
|
||||||
|
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 => this.textEditor.overrideFile(text))
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
return Promise.resolve<pxt.editor.ExtensionResult>(res);
|
||||||
|
}
|
||||||
|
}
|
12
editor/tsconfig.json
Normal file
12
editor/tsconfig.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"declaration": true,
|
||||||
|
"out": "../built/editor.js",
|
||||||
|
"rootDir": ".",
|
||||||
|
"newLine": "LF",
|
||||||
|
"sourceMap": false
|
||||||
|
}
|
||||||
|
}
|
@ -228,33 +228,7 @@
|
|||||||
"feedbackUrl": "https://www.research.net/r/MCmicro",
|
"feedbackUrl": "https://www.research.net/r/MCmicro",
|
||||||
"appStoreID": "1092687276",
|
"appStoreID": "1092687276",
|
||||||
"mobileSafariDownloadProtocol": "microbithex://?data",
|
"mobileSafariDownloadProtocol": "microbithex://?data",
|
||||||
"browserSupport": [
|
"extendEditor": true,
|
||||||
{
|
|
||||||
"name": "unsupported",
|
|
||||||
"os": "*",
|
|
||||||
"path": "/browsers"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "unsupported",
|
|
||||||
"os": "mac",
|
|
||||||
"path": "/browsers/mac"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "unsupported",
|
|
||||||
"os": "linux",
|
|
||||||
"path": "browsers/linux"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "unsupported",
|
|
||||||
"os": "rpi",
|
|
||||||
"path": "/raspberry-pi"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "unsupported",
|
|
||||||
"os": "windows",
|
|
||||||
"path": "/browsers/windows"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"docMenu": [
|
"docMenu": [
|
||||||
{
|
{
|
||||||
"name": "Support",
|
"name": "Support",
|
||||||
|
Loading…
Reference in New Issue
Block a user