chore: Upgrade all node deps
This commit is contained in:
parent
b4dae67660
commit
07ccc9d9d7
|
@ -9,3 +9,9 @@ function golang_lint_check() {
|
|||
function golang_lint_fix() {
|
||||
gofmt -w ./interfacer
|
||||
}
|
||||
|
||||
function prettier_fix() {
|
||||
pushd "$PROJECT_ROOT"/webext || _panic
|
||||
prettier --write '{src,test}/**/*.js'
|
||||
popd || _panic
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
require: 'babel-register',
|
||||
recursive: true,
|
||||
timeout: '60000'
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build_webextension": "../ctl.sh build_webextension",
|
||||
"lint": "prettier --list-different '{src,test}/**/*.js'",
|
||||
|
@ -11,22 +12,22 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"babel-eslint": "^8.2.6",
|
||||
"babel-loader": "^7.1.5",
|
||||
"babel-loader": "^8.2.5",
|
||||
"babel-preset-es2015": "^6.24.1",
|
||||
"babel-register": "^6.26.0",
|
||||
"chai": "^4.2.0",
|
||||
"copy-webpack-plugin": "^4.6.0",
|
||||
"eslint": "^5.16.0",
|
||||
"mocha": "^5.2.0",
|
||||
"prettier": "1.18.2",
|
||||
"sinon": "^6.3.5",
|
||||
"strip-ansi": "^4.0.0",
|
||||
"web-ext": "^7.1.0",
|
||||
"webpack": "^4.33.0",
|
||||
"webpack-cli": "^3.3.4"
|
||||
"chai": "^4.3.6",
|
||||
"copy-webpack-plugin": "^11.0.0",
|
||||
"eslint": "^8.20.0",
|
||||
"mocha": "^10.0.0",
|
||||
"prettier": "2.7.1",
|
||||
"sinon": "^14.0.0",
|
||||
"strip-ansi": "^7.0.1",
|
||||
"web-ext": "^7.1.1",
|
||||
"webpack": "^5.73.0",
|
||||
"webpack-cli": "^4.10.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.19",
|
||||
"string-width": "^2.1.1"
|
||||
"lodash": "^4.17.21",
|
||||
"string-width": "^5.1.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import stripAnsi from "strip-ansi";
|
|||
|
||||
// Here we keep the public functions used to mediate communications between
|
||||
// the background process, tabs and the terminal.
|
||||
export default MixinBase =>
|
||||
export default (MixinBase) =>
|
||||
class extends MixinBase {
|
||||
sendToCurrentTab(message) {
|
||||
if (this.currentTab().channel === undefined) {
|
||||
|
|
|
@ -46,7 +46,7 @@ export default class extends utils.mixins(CommonMixin) {
|
|||
_setRawTextTTYSize() {
|
||||
this.raw_text_tty_size = {
|
||||
width: this.config["http-server"].columns,
|
||||
height: this.config["http-server"].rows
|
||||
height: this.config["http-server"].rows,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -73,14 +73,14 @@ export default class extends utils.mixins(CommonMixin) {
|
|||
);
|
||||
const current_window = browser.windows.getCurrent();
|
||||
current_window.then(
|
||||
active_window => {
|
||||
(active_window) => {
|
||||
this._sendWindowResizeRequest(
|
||||
active_window,
|
||||
window_width,
|
||||
window_height
|
||||
);
|
||||
},
|
||||
error => {
|
||||
(error) => {
|
||||
this.log("Error getting current browser window", error);
|
||||
}
|
||||
);
|
||||
|
@ -91,11 +91,11 @@ export default class extends utils.mixins(CommonMixin) {
|
|||
const updating = browser.windows.update(active_window.id, {
|
||||
width: width,
|
||||
height: height,
|
||||
focused: false
|
||||
focused: false,
|
||||
});
|
||||
updating.then(
|
||||
info => this.log(`${tag} successful (${info.width}x${info.height})`),
|
||||
error => this.log(tag + " error: ", error)
|
||||
(info) => this.log(`${tag} successful (${info.width}x${info.height})`),
|
||||
(error) => this.log(tag + " error: ", error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,13 +39,13 @@ export default class extends utils.mixins(CommonMixin, TTYCommandsMixin) {
|
|||
_connectToTerminal() {
|
||||
// This is the websocket server run by the CLI client
|
||||
this.terminal = new WebSocket("ws://localhost:3334");
|
||||
this.terminal.addEventListener("open", _event => {
|
||||
this.terminal.addEventListener("open", (_event) => {
|
||||
this.log("Webextension connected to the terminal's websocket server");
|
||||
this.dimensions.terminal = this.terminal;
|
||||
this._listenForTerminalMessages();
|
||||
this._connectToBrowserDOM();
|
||||
});
|
||||
this.terminal.addEventListener("close", _event => {
|
||||
this.terminal.addEventListener("close", (_event) => {
|
||||
this._reconnectToTerminal();
|
||||
});
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ export default class extends utils.mixins(CommonMixin, TTYCommandsMixin) {
|
|||
// to TTY resize events too.
|
||||
_listenForTerminalMessages() {
|
||||
this.log("Starting to listen to TTY");
|
||||
this.terminal.addEventListener("message", event => {
|
||||
this.terminal.addEventListener("message", (event) => {
|
||||
this.log("Message from terminal: " + event.data);
|
||||
this.handleTerminalMessage(event.data);
|
||||
});
|
||||
|
@ -111,7 +111,7 @@ export default class extends utils.mixins(CommonMixin, TTYCommandsMixin) {
|
|||
// TODO: Detect deleted tabs to remove the key from `this.tabs[]`
|
||||
_listenForTabUpdates() {
|
||||
setInterval(() => {
|
||||
this._pollAllTabs(native_tab_object => {
|
||||
this._pollAllTabs((native_tab_object) => {
|
||||
let tab = this._applyUpdates(native_tab_object);
|
||||
tab.ensureConnectionToBackground();
|
||||
});
|
||||
|
@ -157,7 +157,7 @@ export default class extends utils.mixins(CommonMixin, TTYCommandsMixin) {
|
|||
|
||||
_applyUpdates(tabish_object) {
|
||||
let tab = this._maybeNewTab({
|
||||
id: tabish_object.id
|
||||
id: tabish_object.id,
|
||||
});
|
||||
[
|
||||
"id",
|
||||
|
@ -166,8 +166,8 @@ export default class extends utils.mixins(CommonMixin, TTYCommandsMixin) {
|
|||
"active",
|
||||
"request_id",
|
||||
"raw_text_mode_type",
|
||||
"start_time"
|
||||
].map(key => {
|
||||
"start_time",
|
||||
].map((key) => {
|
||||
if (tabish_object.hasOwnProperty(key)) {
|
||||
tab[key] = tabish_object[key];
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ export default class extends utils.mixins(CommonMixin, TTYCommandsMixin) {
|
|||
|
||||
_getTabsOnSuccess(windowInfoArray, callback) {
|
||||
for (let windowInfo of windowInfoArray) {
|
||||
windowInfo.tabs.map(tab => {
|
||||
windowInfo.tabs.map((tab) => {
|
||||
callback(tab);
|
||||
});
|
||||
}
|
||||
|
@ -221,10 +221,10 @@ export default class extends utils.mixins(CommonMixin, TTYCommandsMixin) {
|
|||
_pollAllTabs(callback) {
|
||||
var getting = browser.windows.getAll({
|
||||
populate: true,
|
||||
windowTypes: ["normal"]
|
||||
windowTypes: ["normal"],
|
||||
});
|
||||
getting.then(
|
||||
windowInfoArray => this._getTabsOnSuccess(windowInfoArray, callback),
|
||||
(windowInfoArray) => this._getTabsOnSuccess(windowInfoArray, callback),
|
||||
() => this._getTabsOnError(callback)
|
||||
);
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ export default class extends utils.mixins(CommonMixin, TTYCommandsMixin) {
|
|||
// Listen for HTTP activity so we can notify the user that something is loading in the background
|
||||
_addWebRequestListener() {
|
||||
browser.webRequest.onBeforeRequest.addListener(
|
||||
e => {
|
||||
(e) => {
|
||||
let message;
|
||||
if (e.type == "main_frame") {
|
||||
message = `Loading ${e.url}`;
|
||||
|
@ -294,7 +294,7 @@ export default class extends utils.mixins(CommonMixin, TTYCommandsMixin) {
|
|||
}
|
||||
},
|
||||
{
|
||||
urls: ["*://*/*"]
|
||||
urls: ["*://*/*"],
|
||||
},
|
||||
["blocking"]
|
||||
);
|
||||
|
|
|
@ -40,8 +40,8 @@ export default class extends utils.mixins(CommonMixin, TabCommandsMixin) {
|
|||
reload() {
|
||||
const reloading = browser.tabs.reload(this.id);
|
||||
reloading.then(
|
||||
tab => this.log(`Tab ${tab.id} reloaded.`),
|
||||
error => this.log(error)
|
||||
(tab) => this.log(`Tab ${tab.id} reloaded.`),
|
||||
(error) => this.log(error)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ export default class extends utils.mixins(CommonMixin, TabCommandsMixin) {
|
|||
const removing = browser.tabs.remove(this.id);
|
||||
removing.then(
|
||||
() => this.log(`Tab ${this.id} removed.`),
|
||||
error => this.log(error)
|
||||
(error) => this.log(error)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ export default class extends utils.mixins(CommonMixin, TabCommandsMixin) {
|
|||
title: this.title,
|
||||
uri: this.url,
|
||||
page_state: this.page_state,
|
||||
status_message: this.status_message
|
||||
status_message: this.status_message,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import utils from "utils";
|
|||
|
||||
// Handle commands from tabs, like sending a frame or information about
|
||||
// the current character dimensions.
|
||||
export default MixinBase =>
|
||||
export default (MixinBase) =>
|
||||
class extends MixinBase {
|
||||
// TODO: There needs to be some consistency in this message sending protocol.
|
||||
// Eg; always requiring JSON.
|
||||
|
@ -53,11 +53,11 @@ export default MixinBase =>
|
|||
if (this.request_id) {
|
||||
let payload = {
|
||||
json: JSON.stringify(incoming),
|
||||
request_id: this.request_id
|
||||
request_id: this.request_id,
|
||||
};
|
||||
this.sendToTerminal(`/raw_text,${JSON.stringify(payload)}`);
|
||||
}
|
||||
this._tabCount(count => {
|
||||
this._tabCount((count) => {
|
||||
if (count > 1) {
|
||||
this.remove();
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ export default MixinBase =>
|
|||
}
|
||||
|
||||
_tabCount(callback) {
|
||||
this._getAllTabs(windowInfoArray => {
|
||||
this._getAllTabs((windowInfoArray) => {
|
||||
callback(windowInfoArray[0].tabs.length);
|
||||
});
|
||||
}
|
||||
|
@ -73,10 +73,10 @@ export default MixinBase =>
|
|||
_getAllTabs(callback) {
|
||||
var getting = browser.windows.getAll({
|
||||
populate: true,
|
||||
windowTypes: ["normal"]
|
||||
windowTypes: ["normal"],
|
||||
});
|
||||
getting.then(
|
||||
windowInfoArray => callback(windowInfoArray),
|
||||
(windowInfoArray) => callback(windowInfoArray),
|
||||
() => this.log("Error getting all tabs in Tab class")
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import utils from "utils";
|
||||
|
||||
// Handle commands coming in from the terminal, like; STDIN keystrokes, TTY resize, etc
|
||||
export default MixinBase =>
|
||||
export default (MixinBase) =>
|
||||
class extends MixinBase {
|
||||
handleTerminalMessage(message) {
|
||||
const parts = message.split(",");
|
||||
|
@ -127,16 +127,16 @@ export default MixinBase =>
|
|||
createNewTab(url, callback) {
|
||||
const final_url = this._getURLfromUserInput(url);
|
||||
let creating = browser.tabs.create({
|
||||
url: final_url
|
||||
url: final_url,
|
||||
});
|
||||
creating.then(
|
||||
tab => {
|
||||
(tab) => {
|
||||
if (callback) {
|
||||
callback(tab);
|
||||
}
|
||||
this.log(`New tab created: ${tab}`);
|
||||
},
|
||||
error => {
|
||||
(error) => {
|
||||
this.log(`Error creating new tab: ${error}`);
|
||||
}
|
||||
);
|
||||
|
@ -144,13 +144,13 @@ export default MixinBase =>
|
|||
|
||||
gotoURL(url) {
|
||||
let updating = browser.tabs.update(parseInt(this.currentTab().id), {
|
||||
url: url
|
||||
url: url,
|
||||
});
|
||||
updating.then(
|
||||
tab => {
|
||||
(tab) => {
|
||||
this.log(`Tab ${tab.id} loaded: ${url}`);
|
||||
},
|
||||
error => {
|
||||
(error) => {
|
||||
this.log(`Error loading: ${url} \nError: ${error}`);
|
||||
}
|
||||
);
|
||||
|
@ -158,13 +158,13 @@ export default MixinBase =>
|
|||
|
||||
switchToTab(id) {
|
||||
let updating = browser.tabs.update(parseInt(id), {
|
||||
active: true
|
||||
active: true,
|
||||
});
|
||||
updating.then(
|
||||
tab => {
|
||||
(tab) => {
|
||||
this.log(`Switched to tab: ${tab.id}`);
|
||||
},
|
||||
error => {
|
||||
(error) => {
|
||||
this.log(`Error switching to tab: ${error}`);
|
||||
}
|
||||
);
|
||||
|
@ -179,9 +179,11 @@ export default MixinBase =>
|
|||
// because the content script may have crashed, even never loaded.
|
||||
screenshotActiveTab() {
|
||||
const capturing = browser.tabs.captureVisibleTab({
|
||||
format: "jpeg"
|
||||
format: "jpeg",
|
||||
});
|
||||
capturing.then(this._saveScreenshot.bind(this), error => this.log(error));
|
||||
capturing.then(this._saveScreenshot.bind(this), (error) =>
|
||||
this.log(error)
|
||||
);
|
||||
}
|
||||
|
||||
_saveScreenshot(imageUri) {
|
||||
|
@ -190,12 +192,12 @@ export default MixinBase =>
|
|||
}
|
||||
|
||||
_rawTextRequest(request_id, mode, url) {
|
||||
this.createNewTab(url, native_tab => {
|
||||
this.createNewTab(url, (native_tab) => {
|
||||
this._acknowledgeNewTab({
|
||||
id: native_tab.id,
|
||||
request_id: request_id,
|
||||
raw_text_mode_type: mode.toLowerCase(),
|
||||
start_time: Date.now()
|
||||
start_time: Date.now(),
|
||||
});
|
||||
// Sometimes tabs fail to load for whatever reason. Make sure they get
|
||||
// removed to save RAM in long-lived Browsh HTTP servers
|
||||
|
@ -218,20 +220,20 @@ export default MixinBase =>
|
|||
|
||||
_addUserAgentListener() {
|
||||
browser.webRequest.onBeforeSendHeaders.addListener(
|
||||
e => {
|
||||
(e) => {
|
||||
if (this._is_using_mobile_user_agent) {
|
||||
e.requestHeaders.forEach(header => {
|
||||
e.requestHeaders.forEach((header) => {
|
||||
if (header.name.toLowerCase() == "user-agent") {
|
||||
header.value = this.config.mobile_user_agent;
|
||||
}
|
||||
});
|
||||
return {
|
||||
requestHeaders: e.requestHeaders
|
||||
requestHeaders: e.requestHeaders,
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
urls: ["*://*/*"]
|
||||
urls: ["*://*/*"],
|
||||
},
|
||||
["blocking", "requestHeaders"]
|
||||
);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import utils from "utils";
|
||||
|
||||
export default MixinBase =>
|
||||
export default (MixinBase) =>
|
||||
class extends MixinBase {
|
||||
_handleBackgroundMessage(message) {
|
||||
let input, url, config;
|
||||
|
@ -169,7 +169,7 @@ export default MixinBase =>
|
|||
}
|
||||
const key_object = {
|
||||
key: key.char,
|
||||
keyCode: key.key
|
||||
keyCode: key.key,
|
||||
};
|
||||
let event_press = new KeyboardEvent("keypress", key_object);
|
||||
let event_down = new KeyboardEvent("keydown", key_object);
|
||||
|
@ -241,7 +241,7 @@ export default MixinBase =>
|
|||
}
|
||||
return [
|
||||
dom_x + this.dimensions.char.width / 2,
|
||||
dom_y + this.dimensions.char.height / 2
|
||||
dom_y + this.dimensions.char.height / 2,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ export default MixinBase =>
|
|||
const title_object = document.getElementsByTagName("title");
|
||||
let info = {
|
||||
url: document.location.href,
|
||||
title: title_object.length ? title_object[0].innerHTML : ""
|
||||
title: title_object.length ? title_object[0].innerHTML : "",
|
||||
};
|
||||
this.sendMessage(`/tab_info,${JSON.stringify(info)}`);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export default MixinBase =>
|
||||
export default (MixinBase) =>
|
||||
class extends MixinBase {
|
||||
constructor() {
|
||||
super();
|
||||
|
|
|
@ -17,11 +17,11 @@ export default class extends utils.mixins(CommonMixin) {
|
|||
this._pre_calculated_char = !TEST
|
||||
? {
|
||||
width: 9,
|
||||
height: 15
|
||||
height: 15,
|
||||
}
|
||||
: {
|
||||
width: 1,
|
||||
height: 2
|
||||
height: 2,
|
||||
};
|
||||
|
||||
// TODO: WTF is this magic number? The gap between lines?
|
||||
|
@ -42,7 +42,7 @@ export default class extends utils.mixins(CommonMixin) {
|
|||
x_scroll: 0,
|
||||
y_scroll: 0,
|
||||
x_last_big_frame: 0,
|
||||
y_last_big_frame: 0
|
||||
y_last_big_frame: 0,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ export default class extends utils.mixins(CommonMixin) {
|
|||
sub_width: utils.snap(this.frame.sub.width),
|
||||
sub_height: utils.snap(this.frame.sub.height),
|
||||
total_width: utils.snap(this.frame.width),
|
||||
total_height: utils.snap(this.frame.height)
|
||||
total_height: utils.snap(this.frame.height),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ export default class extends utils.mixins(CommonMixin) {
|
|||
left: this.frame.x_scroll,
|
||||
top: this.frame.y_scroll,
|
||||
width: this.tty.width,
|
||||
height: this.tty.height * 2
|
||||
height: this.tty.height * 2,
|
||||
};
|
||||
|
||||
this._scaleSubFrameToSubDOM();
|
||||
|
@ -101,7 +101,7 @@ export default class extends utils.mixins(CommonMixin) {
|
|||
this.frame.y_scroll - this._big_sub_frame_factor * this.tty.height * 2,
|
||||
width: this.tty.width + this._big_sub_frame_factor * 2 * this.tty.width,
|
||||
height:
|
||||
this.tty.height + this._big_sub_frame_factor * 2 * this.tty.height * 2
|
||||
this.tty.height + this._big_sub_frame_factor * 2 * this.tty.height * 2,
|
||||
};
|
||||
this._limitSubFrameDimensions();
|
||||
this._scaleSubFrameToSubDOM();
|
||||
|
@ -114,7 +114,7 @@ export default class extends utils.mixins(CommonMixin) {
|
|||
left: 0,
|
||||
top: 0,
|
||||
width: this.dom.width,
|
||||
height: this.dom.height
|
||||
height: this.dom.height,
|
||||
};
|
||||
if (this.dom.sub.width > this._entire_dom_limit) {
|
||||
this.dom.sub.width = this._entire_dom_limit;
|
||||
|
@ -128,7 +128,7 @@ export default class extends utils.mixins(CommonMixin) {
|
|||
left: 0,
|
||||
top: 0,
|
||||
width: this.dom.sub.width * this.scale_factor.width,
|
||||
height: this.dom.sub.height * this.scale_factor.height
|
||||
height: this.dom.sub.height * this.scale_factor.height,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ export default class extends utils.mixins(CommonMixin) {
|
|||
left: this.frame.sub.left / this.scale_factor.width,
|
||||
top: this.frame.sub.top / this.scale_factor.height,
|
||||
width: this.frame.sub.width / this.scale_factor.width,
|
||||
height: this.frame.sub.height / this.scale_factor.height
|
||||
height: this.frame.sub.height / this.scale_factor.height,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ export default class extends utils.mixins(CommonMixin) {
|
|||
}
|
||||
this.char = {
|
||||
width: this._pre_calculated_char.width,
|
||||
height: this._pre_calculated_char.height + this._char_height_magic_number
|
||||
height: this._pre_calculated_char.height + this._char_height_magic_number,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ export default class extends utils.mixins(CommonMixin) {
|
|||
sub: this.dom.sub,
|
||||
width: new_width,
|
||||
height: new_height,
|
||||
is_new: is_new
|
||||
is_new: is_new,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ export default class extends utils.mixins(CommonMixin) {
|
|||
this.scale_factor = {
|
||||
width: 1 / this.char.width,
|
||||
// Recall that 2 UTF8 half-black "pixels" can fit into a single TTY cell
|
||||
height: 2 / this.char.height
|
||||
height: 2 / this.char.height,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ export default class extends utils.mixins(CommonMixin) {
|
|||
const dimensions = {
|
||||
dom: this.dom,
|
||||
frame: this.frame,
|
||||
char: this.char
|
||||
char: this.char,
|
||||
};
|
||||
this.sendMessage(`/dimensions,${JSON.stringify(dimensions)}`);
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@ export default class extends utils.mixins(CommonMixin) {
|
|||
for (let y = 0; y < height; y++) {
|
||||
for (let x = 0; x < width; x++) {
|
||||
// TODO: Explore sending as binary data
|
||||
this._getScaledPixelAt(x, y).map(c => this.frame.colours.push(c));
|
||||
this._getScaledPixelAt(x, y).map((c) => this.frame.colours.push(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ export default class extends utils.mixins(CommonMixin) {
|
|||
_setupFrameMeta() {
|
||||
this.frame = {
|
||||
meta: this.dimensions.getFrameMeta(),
|
||||
colours: []
|
||||
colours: [],
|
||||
};
|
||||
this.frame.meta.id = parseInt(this.channel.name);
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ export default class extends utils.mixins(CommonMixin, CommandsMixin) {
|
|||
|
||||
_setupDebouncedFunctions() {
|
||||
this._debouncedSmallTextFrame = _.debounce(this.sendSmallTextFrame, 100, {
|
||||
leading: true
|
||||
leading: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -169,8 +169,8 @@ export default class extends utils.mixins(CommonMixin, CommandsMixin) {
|
|||
_registerWithBackground() {
|
||||
let sending = browser.runtime.sendMessage("/register");
|
||||
sending.then(
|
||||
r => this._registrationSuccess(r),
|
||||
e => this._registrationError(e)
|
||||
(r) => this._registrationSuccess(r),
|
||||
(e) => this._registrationError(e)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ export default class extends utils.mixins(CommonMixin, CommandsMixin) {
|
|||
this.channel = browser.runtime.connect({
|
||||
// We need to give ourselves a unique channel name, so the background
|
||||
// process can identify us amongst other tabs.
|
||||
name: registered.id.toString()
|
||||
name: registered.id.toString(),
|
||||
});
|
||||
this._postCommsInit();
|
||||
}
|
||||
|
@ -202,15 +202,15 @@ export default class extends utils.mixins(CommonMixin, CommandsMixin) {
|
|||
window.addEventListener("unload", () => {
|
||||
this.sendMessage("/status,window_unload");
|
||||
});
|
||||
window.addEventListener("error", error => {
|
||||
window.addEventListener("error", (error) => {
|
||||
this.logError(error);
|
||||
});
|
||||
}
|
||||
|
||||
_startMutationObserver() {
|
||||
let target = document.querySelector("body");
|
||||
let observer = new MutationObserver(mutations => {
|
||||
mutations.forEach(mutation => {
|
||||
let observer = new MutationObserver((mutations) => {
|
||||
mutations.forEach((mutation) => {
|
||||
this.log("!!MUTATION!!", mutation);
|
||||
this._debouncedSmallTextFrame();
|
||||
});
|
||||
|
@ -218,12 +218,12 @@ export default class extends utils.mixins(CommonMixin, CommandsMixin) {
|
|||
observer.observe(target, {
|
||||
subtree: true,
|
||||
characterData: true,
|
||||
childList: true
|
||||
childList: true,
|
||||
});
|
||||
}
|
||||
|
||||
_listenForBackgroundMessages() {
|
||||
this.channel.onMessage.addListener(message => {
|
||||
this.channel.onMessage.addListener((message) => {
|
||||
try {
|
||||
this._handleBackgroundMessage(message);
|
||||
} catch (error) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import utils from "utils";
|
||||
|
||||
export default MixinBase =>
|
||||
export default (MixinBase) =>
|
||||
class extends MixinBase {
|
||||
__serialiseFrame() {
|
||||
let cell, index;
|
||||
|
@ -20,7 +20,7 @@ export default MixinBase =>
|
|||
this.frame.colours.push(0);
|
||||
this.frame.text.push("");
|
||||
} else {
|
||||
cell.fg_colour.map(c => this.frame.colours.push(c));
|
||||
cell.fg_colour.map((c) => this.frame.colours.push(c));
|
||||
this.frame.text.push(cell.rune);
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ export default MixinBase =>
|
|||
let raw_input_boxes = document.querySelectorAll(
|
||||
"input, " + "textarea, " + '[role="textbox"]'
|
||||
);
|
||||
raw_input_boxes.forEach(i => {
|
||||
raw_input_boxes.forEach((i) => {
|
||||
let type;
|
||||
this._ensureBrowshID(i);
|
||||
dom_rect = this._convertDOMRectToAbsoluteCoords(
|
||||
|
@ -247,7 +247,7 @@ export default MixinBase =>
|
|||
font_rgb = styles["color"]
|
||||
.replace(/[^\d,]/g, "")
|
||||
.split(",")
|
||||
.map(i => parseInt(i));
|
||||
.map((i) => parseInt(i));
|
||||
const padding_top = parseInt(styles["padding-top"].replace("px", ""));
|
||||
const padding_left = parseInt(styles["padding-left"].replace("px", ""));
|
||||
if (this._isUnwantedInboxBox(i, styles)) {
|
||||
|
@ -265,7 +265,7 @@ export default MixinBase =>
|
|||
height: height,
|
||||
tag_name: i.nodeName,
|
||||
type: type,
|
||||
colour: [font_rgb[0], font_rgb[1], font_rgb[2]]
|
||||
colour: [font_rgb[0], font_rgb[1], font_rgb[2]],
|
||||
};
|
||||
});
|
||||
return parsed_input_boxes;
|
||||
|
@ -298,7 +298,7 @@ export default MixinBase =>
|
|||
let payload = {
|
||||
body: body,
|
||||
page_load_duration: this.config.page_load_duration,
|
||||
parsing_duration: this._parsing_duration
|
||||
parsing_duration: this._parsing_duration,
|
||||
};
|
||||
this.sendMessage(`/raw_text,${JSON.stringify(payload)}`);
|
||||
}
|
||||
|
@ -398,7 +398,7 @@ export default MixinBase =>
|
|||
this.frame = {
|
||||
meta: this.dimensions.getFrameMeta(),
|
||||
text: [],
|
||||
colours: []
|
||||
colours: [],
|
||||
};
|
||||
this.frame.meta.id = parseInt(this.channel.name);
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ export default class extends utils.mixins(CommonMixin, SerialiseMixin) {
|
|||
right:
|
||||
this.dimensions.dom.sub.left +
|
||||
this.dimensions.dom.sub.width -
|
||||
window.scrollX
|
||||
window.scrollX,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -299,11 +299,11 @@ export default class extends utils.mixins(CommonMixin, SerialiseMixin) {
|
|||
_createTrackers() {
|
||||
this._dom_tracker = {
|
||||
x: this._dom_box.left,
|
||||
y: this._dom_box.top
|
||||
y: this._dom_box.top,
|
||||
};
|
||||
this._tty_tracker = {
|
||||
x: this._tty_box.col_start,
|
||||
y: this._tty_box.row
|
||||
y: this._tty_box.row,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,7 @@ export default class extends utils.mixins(CommonMixin, SerialiseMixin) {
|
|||
left: dom_rect.left + window.scrollX,
|
||||
right: dom_rect.right + window.scrollX,
|
||||
height: dom_rect.height,
|
||||
width: dom_rect.width
|
||||
width: dom_rect.width,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -368,7 +368,7 @@ export default class extends utils.mixins(CommonMixin, SerialiseMixin) {
|
|||
),
|
||||
width: utils.snap(
|
||||
this._dom_box.width * this.dimensions.scale_factor.width
|
||||
)
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
export default {
|
||||
mixins: function(...mixins) {
|
||||
mixins: function (...mixins) {
|
||||
return mixins.reduce((base, mixin) => {
|
||||
return mixin(base);
|
||||
}, class {});
|
||||
},
|
||||
|
||||
ttyCell: function(
|
||||
ttyCell: function (
|
||||
fg_colour = [255, 255, 255],
|
||||
bg_colour = [0, 0, 0],
|
||||
character
|
||||
|
@ -15,15 +15,15 @@ export default {
|
|||
return cell;
|
||||
},
|
||||
|
||||
ttyPlainCell: function(character) {
|
||||
ttyPlainCell: function (character) {
|
||||
return this.ttyCell(null, null, character);
|
||||
},
|
||||
|
||||
snap: function(number) {
|
||||
snap: function (number) {
|
||||
return parseInt(Math.round(number));
|
||||
},
|
||||
|
||||
ensureEven: function(number) {
|
||||
ensureEven: function (number) {
|
||||
number = this.snap(number);
|
||||
if (number % 2) {
|
||||
number++;
|
||||
|
@ -31,15 +31,18 @@ export default {
|
|||
return number;
|
||||
},
|
||||
|
||||
rebuildArgsToSingleArg: function(args) {
|
||||
rebuildArgsToSingleArg: function (args) {
|
||||
return args.slice(1).join(",");
|
||||
},
|
||||
|
||||
uuidv4: function() {
|
||||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
||||
var r = (Math.random() * 16) | 0,
|
||||
v = c == "x" ? r : (r & 0x3) | 0x8;
|
||||
return v.toString(16);
|
||||
});
|
||||
}
|
||||
uuidv4: function () {
|
||||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
|
||||
/[xy]/g,
|
||||
function (c) {
|
||||
var r = (Math.random() * 16) | 0,
|
||||
v = c == "x" ? r : (r & 0x3) | 0x8;
|
||||
return v.toString(16);
|
||||
}
|
||||
);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -17,11 +17,11 @@ export default class TextNodes {
|
|||
{
|
||||
textContent: global.mock_DOM_text.join(""),
|
||||
parentElement: {
|
||||
style: {}
|
||||
style: {},
|
||||
},
|
||||
bounding_box: this.boundingBox(),
|
||||
dom_rects: this.dom_rects
|
||||
}
|
||||
dom_rects: this.dom_rects,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ export default class TextNodes {
|
|||
left: this.offset,
|
||||
right: this.total_width + this.offset,
|
||||
width: this.total_width,
|
||||
height: this.total_height
|
||||
height: this.total_height,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ export default class TextNodes {
|
|||
left: this.offset,
|
||||
right: width + this.offset,
|
||||
width: width,
|
||||
height: height
|
||||
height: height,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ describe("Graphics Builder", () => {
|
|||
width: 4,
|
||||
height: 2,
|
||||
x_scroll: 0,
|
||||
y_scroll: 0
|
||||
y_scroll: 0,
|
||||
};
|
||||
graphics_builder = helper.runGraphicsBuilder();
|
||||
});
|
||||
|
@ -35,7 +35,7 @@ describe("Graphics Builder", () => {
|
|||
sub_height: 4,
|
||||
total_width: 4,
|
||||
total_height: 4,
|
||||
id: 1
|
||||
id: 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -46,7 +46,7 @@ describe("Graphics Builder", () => {
|
|||
width: 2,
|
||||
height: 2,
|
||||
x_scroll: 2,
|
||||
y_scroll: 1
|
||||
y_scroll: 1,
|
||||
};
|
||||
global.frame_type = "small";
|
||||
global.mock_DOM_template = [" ", " ", " ", " "];
|
||||
|
@ -71,7 +71,7 @@ describe("Graphics Builder", () => {
|
|||
sub_height: 4,
|
||||
total_width: 4,
|
||||
total_height: 8,
|
||||
id: 1
|
||||
id: 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,7 +9,7 @@ import MockRange from "mocks/range";
|
|||
import TextNodes from "fixtures/text_nodes";
|
||||
import CanvasPixels from "fixtures/canvas_pixels";
|
||||
|
||||
var sandbox = sinon.sandbox.create();
|
||||
var sandbox = sinon.createSandbox();
|
||||
let getPixelsStub;
|
||||
let channel = { name: 1 };
|
||||
|
||||
|
@ -34,8 +34,8 @@ afterEach(() => {
|
|||
global.dimensions = {
|
||||
char: {
|
||||
width: 1,
|
||||
height: 2
|
||||
}
|
||||
height: 2,
|
||||
},
|
||||
};
|
||||
|
||||
global.document = {
|
||||
|
@ -43,14 +43,14 @@ global.document = {
|
|||
body: {
|
||||
contains: () => {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
},
|
||||
getElementById: () => {},
|
||||
getElementsByTagName: () => {
|
||||
return [
|
||||
{
|
||||
innerHTML: "Google"
|
||||
}
|
||||
innerHTML: "Google",
|
||||
},
|
||||
];
|
||||
},
|
||||
createRange: () => {
|
||||
|
@ -58,21 +58,21 @@ global.document = {
|
|||
},
|
||||
createElement: () => {
|
||||
return {
|
||||
getContext: () => {}
|
||||
getContext: () => {},
|
||||
};
|
||||
},
|
||||
documentElement: {
|
||||
scrollWidth: null,
|
||||
scrollHeight: null
|
||||
scrollHeight: null,
|
||||
},
|
||||
location: {
|
||||
href: "https://www.google.com"
|
||||
href: "https://www.google.com",
|
||||
},
|
||||
scrollX: 0,
|
||||
scrollY: 0,
|
||||
|
||||
innerWidth: null,
|
||||
innerHeight: null
|
||||
innerHeight: null,
|
||||
};
|
||||
|
||||
global.DEVELOPMENT = false;
|
||||
|
@ -80,16 +80,16 @@ global.PRODUCTION = false;
|
|||
global.TEST = true;
|
||||
global.window = global.document;
|
||||
global.performance = {
|
||||
now: () => {}
|
||||
now: () => {},
|
||||
};
|
||||
|
||||
let element = {
|
||||
getBoundingClientRect: () => {
|
||||
return {
|
||||
width: global.dimensions.char.width,
|
||||
height: global.dimensions.char.height
|
||||
height: global.dimensions.char.height,
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
function _setupMockDOMSize() {
|
||||
|
@ -126,15 +126,15 @@ function _setupGraphicsBuilder(type) {
|
|||
let config = {
|
||||
"http-server": {
|
||||
"jpeg-compression": 0.9,
|
||||
render_delay: 0
|
||||
}
|
||||
render_delay: 0,
|
||||
},
|
||||
};
|
||||
let graphics_builder = new GraphicsBuilder(channel, dimensions, config);
|
||||
return graphics_builder;
|
||||
}
|
||||
|
||||
let functions = {
|
||||
runTextBuilder: callback => {
|
||||
runTextBuilder: (callback) => {
|
||||
let text_nodes = new TextNodes();
|
||||
let graphics_builder = _setupGraphicsBuilder("with_text");
|
||||
let text_builder = new TextBuilder(
|
||||
|
@ -143,8 +143,8 @@ let functions = {
|
|||
graphics_builder,
|
||||
{
|
||||
browsh: {
|
||||
use_experimental_text_visibility: true
|
||||
}
|
||||
use_experimental_text_visibility: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
graphics_builder._getScreenshotWithText(() => {
|
||||
|
@ -162,7 +162,7 @@ let functions = {
|
|||
graphics_builder.__getScaledScreenshot();
|
||||
graphics_builder._serialiseFrame();
|
||||
return graphics_builder;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default functions;
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
--require babel-register
|
||||
--timeout 60000
|
|
@ -4,7 +4,7 @@ import helper from "helper";
|
|||
let text_builder, grid;
|
||||
|
||||
describe("Text Builder", () => {
|
||||
beforeEach(done => {
|
||||
beforeEach((done) => {
|
||||
global.mock_DOM_template = [
|
||||
" ",
|
||||
" ",
|
||||
|
@ -12,7 +12,7 @@ describe("Text Builder", () => {
|
|||
" ",
|
||||
" ",
|
||||
" !!! ",
|
||||
" !!! "
|
||||
" !!! ",
|
||||
];
|
||||
|
||||
// We can't simulate anything that uses groups of spaces, as TextBuilder collapses all spaces
|
||||
|
@ -28,17 +28,17 @@ describe("Text Builder", () => {
|
|||
"Diff kinds of ",
|
||||
"Whitespace. ",
|
||||
"Also we need to ",
|
||||
"test subframes."
|
||||
"test subframes.",
|
||||
];
|
||||
|
||||
global.tty = {
|
||||
width: 5,
|
||||
height: 3,
|
||||
x_scroll: 0,
|
||||
y_scroll: 0
|
||||
y_scroll: 0,
|
||||
};
|
||||
global.frame_type = "small";
|
||||
helper.runTextBuilder(returned_text_builder => {
|
||||
helper.runTextBuilder((returned_text_builder) => {
|
||||
text_builder = returned_text_builder;
|
||||
grid = text_builder.tty_grid.cells;
|
||||
done();
|
||||
|
@ -54,17 +54,17 @@ describe("Text Builder", () => {
|
|||
bg_colour: [0, 0, 6],
|
||||
parent_element: {
|
||||
style: {
|
||||
textAlign: "left"
|
||||
}
|
||||
textAlign: "left",
|
||||
},
|
||||
},
|
||||
tty_coords: {
|
||||
x: 0,
|
||||
y: 0
|
||||
y: 0,
|
||||
},
|
||||
dom_coords: {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
y: 0,
|
||||
},
|
||||
});
|
||||
expect(grid[5]).to.equal(undefined);
|
||||
expect(grid[16]).to.deep.equal({
|
||||
|
@ -74,17 +74,17 @@ describe("Text Builder", () => {
|
|||
bg_colour: [0, 0, 16],
|
||||
parent_element: {
|
||||
style: {
|
||||
textAlign: "left"
|
||||
}
|
||||
textAlign: "left",
|
||||
},
|
||||
},
|
||||
tty_coords: {
|
||||
x: 0,
|
||||
y: 1
|
||||
y: 1,
|
||||
},
|
||||
dom_coords: {
|
||||
x: 0,
|
||||
y: 2
|
||||
}
|
||||
y: 2,
|
||||
},
|
||||
});
|
||||
expect(grid[36]).to.deep.equal({
|
||||
index: 36,
|
||||
|
@ -93,17 +93,17 @@ describe("Text Builder", () => {
|
|||
bg_colour: [0, 0, 30],
|
||||
parent_element: {
|
||||
style: {
|
||||
textAlign: "left"
|
||||
}
|
||||
textAlign: "left",
|
||||
},
|
||||
},
|
||||
tty_coords: {
|
||||
x: 4,
|
||||
y: 2
|
||||
y: 2,
|
||||
},
|
||||
dom_coords: {
|
||||
x: 4,
|
||||
y: 4
|
||||
}
|
||||
y: 4,
|
||||
},
|
||||
});
|
||||
expect(grid[37]).to.equal(undefined);
|
||||
});
|
||||
|
@ -122,7 +122,7 @@ describe("Text Builder", () => {
|
|||
sub_height: 6,
|
||||
total_width: 16,
|
||||
total_height: 14,
|
||||
id: 1
|
||||
id: 1,
|
||||
});
|
||||
expect(text_builder.frame.text).to.deep.equal([
|
||||
"T",
|
||||
|
@ -139,54 +139,11 @@ describe("Text Builder", () => {
|
|||
"i",
|
||||
"d",
|
||||
"e",
|
||||
"."
|
||||
".",
|
||||
]);
|
||||
expect(text_builder.frame.colours).to.deep.equal([
|
||||
6,
|
||||
0,
|
||||
0,
|
||||
7,
|
||||
0,
|
||||
0,
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
9,
|
||||
0,
|
||||
0,
|
||||
10,
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
17,
|
||||
0,
|
||||
0,
|
||||
18,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
19,
|
||||
0,
|
||||
20,
|
||||
0,
|
||||
0,
|
||||
26,
|
||||
0,
|
||||
0,
|
||||
27,
|
||||
0,
|
||||
0,
|
||||
28,
|
||||
0,
|
||||
0,
|
||||
29,
|
||||
0,
|
||||
0,
|
||||
30,
|
||||
0,
|
||||
0
|
||||
6, 0, 0, 7, 0, 0, 8, 0, 0, 9, 0, 0, 10, 0, 0, 16, 0, 0, 17, 0, 0, 18, 0,
|
||||
0, 0, 19, 0, 20, 0, 0, 26, 0, 0, 27, 0, 0, 28, 0, 0, 29, 0, 0, 30, 0, 0,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
const webpack = require('webpack');
|
||||
const path = require('path');
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
const fs = require('fs');
|
||||
import webpack from 'webpack';
|
||||
import path from 'path';
|
||||
import CopyWebpackPlugin from 'copy-webpack-plugin';
|
||||
import fs from 'fs';
|
||||
|
||||
module.exports = {
|
||||
const dirname = process.cwd();
|
||||
|
||||
export default {
|
||||
mode: process.env['BROWSH_ENV'] === 'RELEASE' ? 'production' : 'development',
|
||||
target: 'node',
|
||||
entry: {
|
||||
|
@ -11,13 +13,23 @@ module.exports = {
|
|||
background: './background.js'
|
||||
},
|
||||
output: {
|
||||
path: __dirname,
|
||||
path: dirname,
|
||||
filename: 'dist/[name].js',
|
||||
},
|
||||
resolve: {
|
||||
modules: [
|
||||
path.resolve(__dirname, './src'),
|
||||
path.resolve(dirname, './src'),
|
||||
'node_modules'
|
||||
],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.m?js/,
|
||||
resolve: {
|
||||
fullySpecified: false,
|
||||
},
|
||||
},
|
||||
]
|
||||
},
|
||||
devtool: 'source-map',
|
||||
|
@ -28,19 +40,22 @@ module.exports = {
|
|||
// TODO: For production use a different webpack.config.js
|
||||
PRODUCTION: JSON.stringify(false)
|
||||
}),
|
||||
new CopyWebpackPlugin([
|
||||
{ from: 'assets', to: 'dist/assets' },
|
||||
{ from: '.web-extension-id', to: 'dist/' },
|
||||
{ from: 'manifest.json', to: 'dist/',
|
||||
// Inject the current Browsh version into the manifest JSON
|
||||
transform(manifest, _) {
|
||||
const version_path = '../interfacer/src/browsh/version.go';
|
||||
let buffer = fs.readFileSync(version_path);
|
||||
let version_contents = buffer.toString();
|
||||
const matches = version_contents.match(/"(.*?)"/);
|
||||
return manifest.toString().replace('BROWSH_VERSION', matches[1]);
|
||||
}
|
||||
},
|
||||
])
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [
|
||||
{ from: 'assets', to: 'dist/assets' },
|
||||
{ from: '.web-extension-id', to: 'dist/' },
|
||||
{
|
||||
from: 'manifest.json', to: 'dist/',
|
||||
// Inject the current Browsh version into the manifest JSON
|
||||
transform(manifest, _) {
|
||||
const version_path = '../interfacer/src/browsh/version.go';
|
||||
let buffer = fs.readFileSync(version_path);
|
||||
let version_contents = buffer.toString();
|
||||
const matches = version_contents.match(/"(.*?)"/);
|
||||
return manifest.toString().replace('BROWSH_VERSION', matches[1]);
|
||||
}
|
||||
},
|
||||
]
|
||||
})
|
||||
]
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue