Comparing version 0.1.0 to 0.2.0
@@ -52,3 +52,3 @@ "use strict"; | ||
prj.service.runSync("(() => { pxt.savedAppTheme().experimentalHw = true; pxt.reloadAppTargetVariant() })()"); | ||
const hwVariants = prj.service.runSync("pxt.getHwVariants()"); | ||
const hwVariants = prj.service.hwVariants; | ||
if (opts.hw) { | ||
@@ -55,0 +55,0 @@ const hw = opts.hw.toLowerCase(); |
@@ -54,2 +54,6 @@ "use strict"; | ||
exports.guessMkcJson = guessMkcJson; | ||
function merge(trg, src) { | ||
for (const k of Object.keys(src)) | ||
trg[k] = src[k]; | ||
} | ||
function recLoadAsync(ed, ws, myid = "this") { | ||
@@ -60,4 +64,10 @@ return __awaiter(this, void 0, void 0, function* () { | ||
const pending = []; | ||
for (let pkgid of Object.keys(pcfg.dependencies)) { | ||
const ver = pcfg.dependencies[pkgid]; | ||
let deps = pcfg.dependencies; | ||
if (myid == "this" && pcfg.testDependencies) { | ||
deps = {}; | ||
merge(deps, pcfg.dependencies); | ||
merge(deps, pcfg.testDependencies); | ||
} | ||
for (let pkgid of Object.keys(deps)) { | ||
const ver = deps[pkgid]; | ||
if (pkgid == "hw" && mkcJson.hwVariant) | ||
@@ -64,0 +74,0 @@ pkgid = "hw---" + mkcJson.hwVariant; |
@@ -59,2 +59,3 @@ import mkc = require("./mkc"); | ||
lastUser: unknown; | ||
private makerHw; | ||
constructor(editor: mkc.DownloadedEditor); | ||
@@ -70,2 +71,3 @@ runScript(content: string, filename: string): void; | ||
serviceOp(op: string, data: any): any; | ||
get hwVariants(): pxt.PackageConfig[]; | ||
} |
@@ -27,2 +27,3 @@ "use strict"; | ||
this.editor = editor; | ||
this.makerHw = false; | ||
this.sandbox = { | ||
@@ -109,6 +110,6 @@ eval: undefined, | ||
const cdata = opts.extinfo.compileData; | ||
const cdataObj = JSON.parse(new Buffer(cdata, "base64").toString()); | ||
const cdataObj = JSON.parse(Buffer.from(cdata, "base64").toString()); | ||
if (!cdataObj.config) | ||
throw new Error(`Compile config missing in C++; compile variant likely misconfigured`); | ||
// writeFileSync("compilereq.json", JSON.stringify(JSON.parse(new Buffer(cdata, "base64").toString()), null, 4)) | ||
// writeFileSync("compilereq.json", JSON.stringify(JSON.parse(Buffer.from(cdata, "base64").toString()), null, 4)) | ||
const cresp = yield downloader.requestAsync({ | ||
@@ -153,4 +154,14 @@ url: "https://www.makecode.com/api/compile/extension", | ||
this.sandbox._opts = simpleOpts; | ||
this.sandbox._scriptText = prj.files; | ||
this.runFunctionSync("pxt.setHwVariant", [prj.mkcConfig.hwVariant || null]); | ||
if (this.makerHw) { | ||
const tmp = Object.assign({}, prj.files); | ||
const cfg = JSON.parse(tmp["pxt.json"]); | ||
if (prj.mkcConfig.hwVariant) | ||
cfg.dependencies[prj.mkcConfig.hwVariant] = "*"; | ||
tmp["pxt.json"] = JSON.stringify(cfg, null, 4); | ||
this.sandbox._scriptText = tmp; | ||
} | ||
else { | ||
this.sandbox._scriptText = prj.files; | ||
this.runFunctionSync("pxt.setHwVariant", [prj.mkcConfig.hwVariant || ""]); | ||
} | ||
return this.runAsync("pxt.simpleGetCompileOptionsAsync(_scriptText, _opts)"); | ||
@@ -172,4 +183,22 @@ } | ||
} | ||
get hwVariants() { | ||
let hwVariants = this.runSync("pxt.getHwVariants()"); | ||
if (hwVariants.length == 0) { | ||
hwVariants = this.runSync("Object.values(pxt.appTarget.bundledpkgs).map(pkg => JSON.parse(pkg['pxt.json']))"); | ||
hwVariants = hwVariants.filter(pkg => !/prj/.test(pkg.name) && !!pkg.core); | ||
for (const pkg of hwVariants) { | ||
pkg.card = { | ||
name: "", | ||
description: pkg.description | ||
}; | ||
} | ||
if (hwVariants.length > 1) | ||
this.makerHw = true; | ||
else | ||
hwVariants = []; | ||
} | ||
return hwVariants; | ||
} | ||
} | ||
exports.Ctx = Ctx; | ||
//# sourceMappingURL=service.js.map |
{ | ||
"name": "makecode", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "MakeCode (PXT) - web-cached build tool", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
92108
1384
32