New 'espruinotools' which fixes pretokenise issue when ID follows ID (fix #416)

pull/422/head
Gordon Williams 2020-05-14 16:24:14 +01:00
parent 7bf0e57882
commit 4f9d3e7794
2 changed files with 37 additions and 39 deletions

View File

@ -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)

View File

@ -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})
@ -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<data.length;i++) rawdata[i]=data.charCodeAt(i);
var a = document.createElement("a"),
file = new Blob([data], {type: "text/plain"});
file = new Blob([rawdata.buffer], {type: "text/plain"});
var url = URL.createObjectURL(file);
a.href = url;
a.download = filename;
@ -4765,6 +4767,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
console.log("GET chrome.storage.sync = "+JSON.stringify(value));
callback(value);
});
} else if (typeof window !== 'undefined' && window.localStorage) {
var data = {};
var value = window.localStorage.getItem("CONFIG");
console.log("GET window.localStorage = "+JSON.stringify(value));
try {
data = JSON.parse(value);
} catch (e) {
console.log("Invalid config data");
}
callback(data);
} else if (typeof document != "undefined") {
var data = {};
var cookie = document.cookie;
@ -4786,8 +4798,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
function _set(data) {
if (typeof chrome !== 'undefined' && chrome.storage) {
console.log("SET chrome.storage.sync = "+JSON.stringify(data));
console.log("SET chrome.storage.sync = "+JSON.stringify(data,null,2));
chrome.storage.sync.set({ CONFIGS : data });
} else if (typeof window !== 'undefined' && window.localStorage) {
console.log("SET window.localStorage = "+JSON.stringify(data,null,2));
window.localStorage.setItem("CONFIG",JSON.stringify(data));
} else if (typeof document != "undefined") {
document.cookie = "CONFIG="+btoa(JSON.stringify(data));
}
@ -4811,7 +4826,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
addSection("General", { sortOrder:100, description: "General Web IDE Settings" });
addSection("Communications", { sortOrder:200, description: "Settings for communicating with the Espruino Board" });
addSection("Board", { sortOrder:300, description: "Settings for the Espruino Board itself" });
}
function add(name, options) {
@ -5076,6 +5090,7 @@ To add a new serial device, you must add an object to
}
}
var portInfo = { port:serialPort };
connectionInfo = undefined;
flowControlXOFF = false;
currentDevice = portToDevice[serialPort];
@ -5088,7 +5103,6 @@ To add a new serial device, you must add an object to
connectionInfo = cInfo;
connectedPort = serialPort;
console.log("Connected", cInfo);
var portInfo = { port:serialPort };
if (connectionInfo.portName)
portInfo.portName = connectionInfo.portName;
Espruino.callProcessor("connected", portInfo, function() {
@ -5127,8 +5141,8 @@ To add a new serial device, you must add an object to
sendingBinary = false;
flowControlXOFF = false;
Espruino.callProcessor("disconnected", undefined, function() {
disconnectCallback();
Espruino.callProcessor("disconnected", portInfo, function() {
disconnectCallback(portInfo);
});
});
};
@ -5608,9 +5622,6 @@ To add a new serial device, you must add an object to
// When code is sent to Espruino, search it for modules and add extra code required to load them
Espruino.addProcessor("transformForEspruino", function(code, callback) {
if (Espruino.Config.ROLLUP) {
return loadModulesRollup(code, callback);
}
loadModules(code, callback);
});
@ -5787,24 +5798,8 @@ To add a new serial device, you must add an object to
callback(loadedModuleData.join("\n") + "\n" + code);
});
}
}
};
function loadModulesRollup(code, callback) {
rollupTools.loadModulesRollup(code)
.then(generated => {
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
@ -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;