diff --git a/js/appinfo.js b/js/appinfo.js index 2f4c70a..1e7c6dc 100644 --- a/js/appinfo.js +++ b/js/appinfo.js @@ -100,6 +100,8 @@ function translateJS(options, app, code) { // Run JS through EspruinoTools to pull in modules/etc function parseJS(storageFile, options, app) { + options = options||{}; + options.device = options.device||{}; if (storageFile.url && storageFile.url.endsWith(".js") && !storageFile.url.endsWith(".min.js")) { // if original file ends in '.js'... let js = storageFile.content; @@ -111,8 +113,12 @@ function parseJS(storageFile, options, app) { if (typeof window!=="undefined") localModulesURL = window.location.origin + window.location.pathname.replace(/[^/]*$/,"") + "modules"; let builtinModules = ["Flash","Storage","heatshrink","tensorflow","locale","notify"]; - if (options && options.device && options.device.id=="BANGLEJS2") - builtinModules.push("crypto"); + // FIXME: now we check options.device.modules below, do we need the hard-coded list above? + if (options.device.modules) + options.device.modules.forEach(mod => { + if (!builtinModules.includes(mod)) builtinModules.push(mod); + }); + // add any modules that were defined for this app (no need to search for them!) builtinModules = builtinModules.concat(app.storage.map(f=>f.name).filter(name => name && !name.includes("."))); // Check for modules in pre-installed apps? diff --git a/js/comms.js b/js/comms.js index 38a483d..0485694 100644 --- a/js/comms.js +++ b/js/comms.js @@ -240,7 +240,7 @@ const Comms = { return; } - let cmd, finalJS = `JSON.stringify(require("Storage").getStats?require("Storage").getStats():{})+","+E.toJS([process.env.BOARD,process.env.VERSION,process.env.EXPTR,0|getTime(),E.CRC32(getSerial()+NRF.getAddress())]).substr(1)`; + let cmd, finalJS = `JSON.stringify(require("Storage").getStats?require("Storage").getStats():{})+","+E.toJS([process.env.BOARD,process.env.VERSION,process.env.EXPTR,process.env.MODULES,0|getTime(),E.CRC32(getSerial()+NRF.getAddress())]).substr(1)`; if (Const.SINGLE_APP_ONLY) // only one app on device, info file is in app.info cmd = `\x10Bluetooth.println("["+(require("Storage").read("app.info")||"null")+","+${finalJS})\n`; else @@ -262,6 +262,7 @@ const Comms = { // unpack the last 6 elements which are board info (See finalJS above) info.uid = appList.pop(); // unique ID for watch (hash of internal serial number and MAC) info.currentTime = appList.pop()*1000; // time in ms + info.modules = appList.pop().split(","); // see what modules we have internally so we don't have to upload them if they exist info.exptr = appList.pop(); // used for compilation info.version = appList.pop(); info.id = appList.pop(); diff --git a/js/index.js b/js/index.js index 0f3cbce..e9a0ccc 100644 --- a/js/index.js +++ b/js/index.js @@ -995,6 +995,7 @@ function getInstalledApps(refresh) { device.id = info.id; device.version = info.version; device.exptr = info.exptr; + device.modules = info.modules||[]; device.storageStats = info.storageStats; device.appsInstalled = info.apps; haveInstalledApps = true;