From 4f9d3e779418689a1f1e1c65438d66ded8986457 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 14 May 2020 16:24:14 +0100 Subject: [PATCH] New 'espruinotools' which fixes pretokenise issue when ID follows ID (fix #416) --- CHANGELOG.md | 1 + js/espruinotools.js | 75 ++++++++++++++++++++++----------------------- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e157951f..e5cd6aef5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,3 +17,4 @@ Changed for individual apps are listed in `apps/appname/ChangeLog` * URL fetch is now async * Adding '#search' after the URL (when not the name of a 'filter' chip) will set up search for that term * If `bin/pre-publish.sh` has been run and recent.csv created, add 'Sort By' chip +* New 'espruinotools' which fixes pretokenise issue when ID follows ID (fix #416) diff --git a/js/espruinotools.js b/js/espruinotools.js index df766fc7d..a201a7fd3 100644 --- a/js/espruinotools.js +++ b/js/espruinotools.js @@ -1,6 +1,6 @@ // EspruinoTools bundle (https://github.com/espruino/EspruinoTools) // Created with https://github.com/espruino/EspruinoWebIDE/blob/gh-pages/extras/create_espruinotools_js.sh -// Based on EspruinoWebIDE 0.73.4 +// Based on EspruinoWebIDE 0.73.7 /** Copyright 2014 Gordon Williams (gw@pur3.co.uk) @@ -23,6 +23,7 @@ var Espruino; * * Common processors are: * + * jsCodeChanged - called when the code in the editor changes with {code} * sending - sending code to Espruino (no data) * transformForEspruino - transform code ready to be sent to Espruino * transformModuleForEspruino({code,name}) @@ -4123,7 +4124,7 @@ Object.defineProperty(exports, '__esModule', { value: true }); } else if (isIn(chNum,ch)) { // NUMBER type = "NUMBER"; var chRange = chNum; - if (ch=="0") { // Handle + if (ch=="0") { // Handle s+=ch; nextCh(); if ("xXoObB".indexOf(ch)>=0) { @@ -4132,12 +4133,12 @@ Object.defineProperty(exports, '__esModule', { value: true }); if (ch=="x" || ch=="X") chRange="0123456789ABCDEFabcdef"; s+=ch; nextCh(); - } + } } while (isIn(chRange,ch) || ch==".") { s+=ch; nextCh(); - } + } } else if (isIn(chQuotes,ch)) { // STRING type = "STRING"; var q = ch; @@ -4507,8 +4508,8 @@ Object.defineProperty(exports, '__esModule', { value: true }); fileLoader.click(); } - /* Save a file with a save file dialog. callback(savedFileName) only called in chrome app case when we knopw the filename*/ - function fileSaveDialog(data, filename, callback) { + // Save a file with a save file dialog + function fileSaveDialog(data, filename) { function errorHandler() { Espruino.Core.Notifications.error("Error Saving", true); } @@ -4524,7 +4525,6 @@ Object.defineProperty(exports, '__esModule', { value: true }); writer.onwriteend = function(e) { writer.onwriteend = function(e) { console.log('FileWriter: complete'); - if (callback) callback(writableFileEntry.name); }; console.log('FileWriter: writing'); writer.write(blob); @@ -4535,8 +4535,10 @@ Object.defineProperty(exports, '__esModule', { value: true }); }, errorHandler); }); } else { + var rawdata = new Uint8Array(data.length); + for (var i=0;i { - const minified = generated.code; - console.log('rollup: '+minified.length+' bytes'); - - // FIXME: needs warnings? - Espruino.Core.Notifications.info('Rollup no errors. Bundling ' + code.length + ' bytes to ' + minified.length + ' bytes'); - callback(minified); - }) - .catch(err => { - console.log('rollup:error', err); - Espruino.Core.Notifications.error("Rollup errors - Bundling failed: " + String(err).trim()); - callback(code); - }); - } Espruino.Core.Modules = { init : init @@ -6436,18 +6431,18 @@ To add a new serial device, you must add an object to This Source Code is subject to the terms of the Mozilla Public License, v2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - + ------------------------------------------------------------------ Try and get any URLS that are from GitHub ------------------------------------------------------------------ **/ "use strict"; (function(){ - + function init() { - Espruino.addProcessor("getURL", getGitHub); + Espruino.addProcessor("getURL", getGitHub); } - + function getGitHub(data, callback) { var match = data.url.match(/^https?:\/\/github.com\/([^\/]+)\/([^\/]+)\/blob\/([^\/]+)\/(.*)$/); if (match) { @@ -6457,7 +6452,7 @@ To add a new serial device, you must add an object to branch : match[3], path : match[4] }; - + var url = "https://raw.githubusercontent.com/"+git.owner+"/"+git.repo+"/"+git.branch+"/"+git.path; console.log("Found GitHub", JSON.stringify(git)); callback({url: url}); @@ -6591,7 +6586,7 @@ To add a new serial device, you must add an object to return { startIdx : tk.start, endIdx : tk.end, - str : code.substr(tk.start, tk.end), + str : code.substring(tk.start, tk.end), type : tp }; }}; @@ -6802,5 +6797,7 @@ Espruino.transform = function(code, options) { }); }; +if (!document) Espruino.init(); if ("undefined"!=typeof module) module.exports = Espruino; +