From 8ad5d1351671b75d92c1642c4a1636c84c005f25 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Tue, 1 Sep 2020 14:43:54 +0100 Subject: [PATCH] Allow customised apps to be minified/pretokenised --- README.md | 6 +++++- apps/beer/custom.html | 2 +- apps/espruinoctrl/custom.html | 2 +- apps/grocery/grocery.html | 16 ++++++++-------- apps/locale/locale.html | 2 +- apps/osmpoi/custom.html | 2 +- apps/qrcode/custom.html | 2 +- apps/route/custom.html | 2 +- core | 2 +- 9 files changed, 20 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index b98afd2f7..22a12bd5b 100644 --- a/README.md +++ b/README.md @@ -291,7 +291,7 @@ version of what's in `apps.json`: sendCustomizedApp({ id : "7chname", storage:[ - {name:"7chname.app.js", content:app_source_code}, + {name:"7chname.app.js", url:"app.js", content:app_source_code}, {name:"7chname.img", content:'require("heatshrink").decompress(atob("mEwg...4"))', evaluate:true}, ] }); @@ -304,6 +304,10 @@ version of what's in `apps.json`: This'll then be loaded in to the watch. See [apps/qrcode/grcode.html](the QR Code app) for a clean example. +**Note:** we specify a `url` for JS files even though it doesn't have to exist +and will never be loaded. This is so the app loader can tell if it's a JavaScript +file based on the extension, and if so it can minify and pretokenise it. + ### `apps.json`: `interface` element Apps that create data that can be read back can define a `interface` element in `apps.json`, diff --git a/apps/beer/custom.html b/apps/beer/custom.html index c4a9a3511..a357ab378 100644 --- a/apps/beer/custom.html +++ b/apps/beer/custom.html @@ -199,7 +199,7 @@ g.clear();`; sendCustomizedApp({ storage:[ - {name:"beer.app.js", content:app} + {name:"beer.app.js", url:"app.js", content:app} ] }); }); diff --git a/apps/espruinoctrl/custom.html b/apps/espruinoctrl/custom.html index 007f3a123..f8e7e38b9 100644 --- a/apps/espruinoctrl/custom.html +++ b/apps/espruinoctrl/custom.html @@ -266,7 +266,7 @@ function sendCommand(device, text, callback) { `; sendCustomizedApp({ storage:[ - {name:"espruinoctrl.app.js", content:app}, + {name:"espruinoctrl.app.js", url:"app.js", content:app}, ] }); }); diff --git a/apps/grocery/grocery.html b/apps/grocery/grocery.html index 9222dd20c..14c406d75 100644 --- a/apps/grocery/grocery.html +++ b/apps/grocery/grocery.html @@ -14,7 +14,7 @@ - +

@@ -34,7 +34,7 @@

- +