Remove MCI cache and xxhash dependency
The MCI cache is no longer needed as we no longer rely on DSR/CPR
This commit is contained in:
parent
b6c7ced9ca
commit
b5f05b69e3
53
core/art.js
53
core/art.js
|
@ -15,7 +15,6 @@ const paths = require('path');
|
|||
const assert = require('assert');
|
||||
const iconv = require('iconv-lite');
|
||||
const _ = require('lodash');
|
||||
const xxhash = require('xxhash');
|
||||
|
||||
exports.getArt = getArt;
|
||||
exports.getArtFromPath = getArtFromPath;
|
||||
|
@ -251,7 +250,6 @@ function display(client, art, options, cb) {
|
|||
}
|
||||
|
||||
options.mciReplaceChar = options.mciReplaceChar || ' ';
|
||||
options.disableMciCache = options.disableMciCache || false;
|
||||
|
||||
// :TODO: this is going to be broken into two approaches controlled via options:
|
||||
// 1) Standard - use internal tracking of locations for MCI -- no CPR's/etc.
|
||||
|
@ -272,45 +270,7 @@ function display(client, art, options, cb) {
|
|||
startRow : options.startRow,
|
||||
});
|
||||
|
||||
let parseComplete = false;
|
||||
let mciMap;
|
||||
const mciCprQueue = [];
|
||||
let artHash;
|
||||
let mciMapFromCache;
|
||||
|
||||
function completed() {
|
||||
|
||||
if(!options.disableMciCache && !mciMapFromCache) {
|
||||
// cache our MCI findings...
|
||||
client.mciCache[artHash] = mciMap;
|
||||
client.log.trace( { artHash : artHash.toString(16), mciMap : mciMap }, 'Added MCI map to cache');
|
||||
}
|
||||
|
||||
ansiParser.removeAllListeners(); // :TODO: Necessary???
|
||||
|
||||
const extraInfo = {
|
||||
height : ansiParser.row - 1,
|
||||
};
|
||||
|
||||
return cb(null, mciMap, extraInfo);
|
||||
}
|
||||
|
||||
if(!options.disableMciCache) {
|
||||
artHash = xxhash.hash(Buffer.from(art), 0xCAFEBABE);
|
||||
|
||||
// see if we have a mciMap cached for this art
|
||||
if(client.mciCache) {
|
||||
mciMap = client.mciCache[artHash];
|
||||
}
|
||||
}
|
||||
|
||||
if(mciMap) {
|
||||
mciMapFromCache = true;
|
||||
client.log.trace( { artHash : artHash.toString(16), mciMap : mciMap }, 'Loaded MCI map from cache');
|
||||
} else {
|
||||
// no cached MCI info
|
||||
mciMap = {};
|
||||
|
||||
const mciMap = {};
|
||||
let generatedId = 100;
|
||||
|
||||
ansiParser.on('mci', mciInfo => {
|
||||
|
@ -337,17 +297,18 @@ function display(client, art, options, cb) {
|
|||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
ansiParser.on('literal', literal => client.term.write(literal, false) );
|
||||
ansiParser.on('control', control => client.term.rawWrite(control) );
|
||||
|
||||
ansiParser.on('complete', () => {
|
||||
parseComplete = true;
|
||||
ansiParser.removeAllListeners();
|
||||
|
||||
if(0 === mciCprQueue.length) {
|
||||
return completed();
|
||||
}
|
||||
const extraInfo = {
|
||||
height : ansiParser.row - 1,
|
||||
};
|
||||
|
||||
return cb(null, mciMap, extraInfo);
|
||||
});
|
||||
|
||||
let initSeq = '';
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
"uuid": "8.3.2",
|
||||
"uuid-parse": "1.1.0",
|
||||
"ws": "7.4.3",
|
||||
"xxhash": "^0.3.0",
|
||||
"yazl": "^2.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
Loading…
Reference in New Issue