Enforce line max length of 100
This commit is contained in:
parent
14e900c4ae
commit
b527d65c14
14
.eslintrc
14
.eslintrc
|
|
@ -213,13 +213,13 @@
|
|||
|
||||
// specify the maximum length of a line in your program
|
||||
// https://eslint.org/docs/rules/max-len
|
||||
// "max-len": ["error", 100, 2, {
|
||||
// ignoreUrls: true,
|
||||
// ignoreComments: false,
|
||||
// ignoreRegExpLiterals: true,
|
||||
// ignoreStrings: true,
|
||||
// ignoreTemplateLiterals: true,
|
||||
// }],
|
||||
"max-len": ["error", 100, 2, {
|
||||
ignoreUrls: true,
|
||||
ignoreComments: false,
|
||||
ignoreRegExpLiterals: true,
|
||||
ignoreStrings: true,
|
||||
ignoreTemplateLiterals: true,
|
||||
}],
|
||||
|
||||
// specify the max number of lines in a file
|
||||
// https://eslint.org/docs/rules/max-lines
|
||||
|
|
|
|||
|
|
@ -576,7 +576,11 @@ export default class Display {
|
|||
// NB(directxman12): arr must be an Type Array view
|
||||
let img;
|
||||
if (SUPPORTS_IMAGEDATA_CONSTRUCTOR) {
|
||||
img = new ImageData(new Uint8ClampedArray(arr.buffer, arr.byteOffset, width * height * 4), width, height);
|
||||
img = new ImageData(
|
||||
new Uint8ClampedArray(arr.buffer, arr.byteOffset, width * height * 4),
|
||||
width,
|
||||
height
|
||||
);
|
||||
} else {
|
||||
img = this._drawCtx.createImageData(width, height);
|
||||
img.data.set(new Uint8ClampedArray(arr.buffer, arr.byteOffset, width * height * 4));
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
* To re-generate, run:
|
||||
* keymap-gen --lang=js code-map keymaps.csv html atset1
|
||||
*/
|
||||
/* eslint-disable max-len */
|
||||
export default {
|
||||
Again: 0xe005, /* html:Again (Again) -> linux:129 (KEY_AGAIN) -> atset1:57349 */
|
||||
AltLeft: 0x38, /* html:AltLeft (AltLeft) -> linux:56 (KEY_LEFTALT) -> atset1:56 */
|
||||
|
|
|
|||
34
core/rfb.js
34
core/rfb.js
|
|
@ -168,6 +168,7 @@ export default class RFB extends EventTargetMixin {
|
|||
this._cursor = new Cursor();
|
||||
|
||||
// populate encHandlers with bound versions
|
||||
/* eslint-disable max-len */
|
||||
this._encHandlers[encodings.encodingRaw] = RFB.encodingHandlers.RAW.bind(this);
|
||||
this._encHandlers[encodings.encodingCopyRect] = RFB.encodingHandlers.COPYRECT.bind(this);
|
||||
this._encHandlers[encodings.encodingRRE] = RFB.encodingHandlers.RRE.bind(this);
|
||||
|
|
@ -180,6 +181,7 @@ export default class RFB extends EventTargetMixin {
|
|||
this._encHandlers[encodings.pseudoEncodingCursor] = RFB.encodingHandlers.Cursor.bind(this);
|
||||
this._encHandlers[encodings.pseudoEncodingQEMUExtendedKeyEvent] = RFB.encodingHandlers.QEMUExtendedKeyEvent.bind(this);
|
||||
this._encHandlers[encodings.pseudoEncodingExtendedDesktopSize] = RFB.encodingHandlers.ExtendedDesktopSize.bind(this);
|
||||
/* eslint-enable max-len */
|
||||
|
||||
// NB: nothing that needs explicit teardown should be done
|
||||
// before this point, since this can throw an exception
|
||||
|
|
@ -787,7 +789,12 @@ export default class RFB extends EventTargetMixin {
|
|||
if (this._viewOnly) { return; } // View only, skip mouse events
|
||||
|
||||
if (this._rfb_connection_state !== 'connected') { return; }
|
||||
RFB.messages.pointerEvent(this._sock, this._display.absX(x), this._display.absY(y), this._mouse_buttonMask);
|
||||
RFB.messages.pointerEvent(
|
||||
this._sock,
|
||||
this._display.absX(x),
|
||||
this._display.absY(y),
|
||||
this._mouse_buttonMask
|
||||
);
|
||||
}
|
||||
|
||||
_handleMouseMove(x, y) {
|
||||
|
|
@ -814,7 +821,12 @@ export default class RFB extends EventTargetMixin {
|
|||
if (this._viewOnly) { return; } // View only, skip mouse events
|
||||
|
||||
if (this._rfb_connection_state !== 'connected') { return; }
|
||||
RFB.messages.pointerEvent(this._sock, this._display.absX(x), this._display.absY(y), this._mouse_buttonMask);
|
||||
RFB.messages.pointerEvent(
|
||||
this._sock,
|
||||
this._display.absX(x),
|
||||
this._display.absY(y),
|
||||
this._mouse_buttonMask
|
||||
);
|
||||
}
|
||||
|
||||
// Message Handlers
|
||||
|
|
@ -2308,7 +2320,11 @@ RFB.encodingHandlers = {
|
|||
rgbx = indexedToRGBX(data, this._paletteBuff, this._FBU.width, this._FBU.height);
|
||||
}
|
||||
|
||||
this._display.blitRgbxImage(this._FBU.x, this._FBU.y, this._FBU.width, this._FBU.height, rgbx, 0, false);
|
||||
this._display.blitRgbxImage(
|
||||
this._FBU.x, this._FBU.y,
|
||||
this._FBU.width, this._FBU.height,
|
||||
rgbx, 0, false
|
||||
);
|
||||
|
||||
|
||||
return true;
|
||||
|
|
@ -2349,7 +2365,11 @@ RFB.encodingHandlers = {
|
|||
data = decompress(this._sock.rQshiftBytes(cl_data), uncompressedSize);
|
||||
}
|
||||
|
||||
this._display.blitRgbImage(this._FBU.x, this._FBU.y, this._FBU.width, this._FBU.height, data, 0, false);
|
||||
this._display.blitRgbImage(
|
||||
this._FBU.x, this._FBU.y,
|
||||
this._FBU.width, this._FBU.height,
|
||||
data, 0, false
|
||||
);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
|
@ -2404,7 +2424,11 @@ RFB.encodingHandlers = {
|
|||
switch (cmode) {
|
||||
case 'fill':
|
||||
// skip ctl byte
|
||||
this._display.fillRect(this._FBU.x, this._FBU.y, this._FBU.width, this._FBU.height, [rQ[rQi + 3], rQ[rQi + 2], rQ[rQi + 1]], false);
|
||||
this._display.fillRect(
|
||||
this._FBU.x, this._FBU.y,
|
||||
this._FBU.width, this._FBU.height,
|
||||
[rQ[rQi + 3], rQ[rQi + 2], rQ[rQi + 1]], false
|
||||
);
|
||||
this._sock.rQskipBytes(4);
|
||||
break;
|
||||
case 'png':
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ describe('Display/Canvas Helper', function () {
|
|||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
|
||||
]);
|
||||
|
||||
const basic_data = new Uint8Array([0xff, 0x00, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0xff, 0xff, 0xff, 255]);
|
||||
const basic_data = new Uint8Array([
|
||||
0xff, 0x00, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0xff, 0xff, 0xff, 255
|
||||
]);
|
||||
|
||||
function make_image_canvas(input_data) {
|
||||
const canvas = document.createElement('canvas');
|
||||
|
|
@ -261,8 +263,8 @@ describe('Display/Canvas Helper', function () {
|
|||
});
|
||||
|
||||
describe('drawing', function () {
|
||||
// TODO(directxman12): improve the tests for each of the drawing functions to cover more than just the
|
||||
// basic cases
|
||||
// TODO(directxman12): improve the tests for each of the drawing functions to cover
|
||||
// more than just the basic cases
|
||||
let display;
|
||||
beforeEach(function () {
|
||||
display = new Display(document.createElement('canvas'));
|
||||
|
|
|
|||
|
|
@ -1025,7 +1025,8 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||
expect(client._rfb_version).to.equal(0);
|
||||
|
||||
const sent_data = client._sock._websocket._get_sent_data();
|
||||
expect(new Uint8Array(sent_data.buffer, 0, 9)).to.array.equal(new Uint8Array([73, 68, 58, 49, 50, 51, 52, 53, 0]));
|
||||
expect(new Uint8Array(sent_data.buffer, 0, 9))
|
||||
.to.array.equal(new Uint8Array([73, 68, 58, 49, 50, 51, 52, 53, 0]));
|
||||
expect(sent_data).to.have.length(250);
|
||||
});
|
||||
|
||||
|
|
@ -1557,10 +1558,13 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||
expect(RFB.messages.pixelFormat).to.have.been.calledWith(client._sock, 24, true);
|
||||
expect(RFB.messages.pixelFormat).to.have.been.calledBefore(RFB.messages.clientEncodings);
|
||||
expect(RFB.messages.clientEncodings).to.have.been.calledOnce;
|
||||
expect(RFB.messages.clientEncodings.getCall(0).args[1]).to.include(encodings.encodingTight);
|
||||
expect(RFB.messages.clientEncodings).to.have.been.calledBefore(RFB.messages.fbUpdateRequest);
|
||||
expect(RFB.messages.clientEncodings.getCall(0).args[1])
|
||||
.to.include(encodings.encodingTight);
|
||||
expect(RFB.messages.clientEncodings)
|
||||
.to.have.been.calledBefore(RFB.messages.fbUpdateRequest);
|
||||
expect(RFB.messages.fbUpdateRequest).to.have.been.calledOnce;
|
||||
expect(RFB.messages.fbUpdateRequest).to.have.been.calledWith(client._sock, false, 0, 0, 27, 32);
|
||||
expect(RFB.messages.fbUpdateRequest)
|
||||
.to.have.been.calledWith(client._sock, false, 0, 0, 27, 32);
|
||||
});
|
||||
|
||||
it('should reply with restricted settings for Intel AMT servers', function () {
|
||||
|
|
@ -1570,11 +1574,15 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||
expect(RFB.messages.pixelFormat).to.have.been.calledWith(client._sock, 8, true);
|
||||
expect(RFB.messages.pixelFormat).to.have.been.calledBefore(RFB.messages.clientEncodings);
|
||||
expect(RFB.messages.clientEncodings).to.have.been.calledOnce;
|
||||
expect(RFB.messages.clientEncodings.getCall(0).args[1]).to.not.include(encodings.encodingTight);
|
||||
expect(RFB.messages.clientEncodings.getCall(0).args[1]).to.not.include(encodings.encodingHextile);
|
||||
expect(RFB.messages.clientEncodings).to.have.been.calledBefore(RFB.messages.fbUpdateRequest);
|
||||
expect(RFB.messages.clientEncodings.getCall(0).args[1])
|
||||
.to.not.include(encodings.encodingTight);
|
||||
expect(RFB.messages.clientEncodings.getCall(0).args[1])
|
||||
.to.not.include(encodings.encodingHextile);
|
||||
expect(RFB.messages.clientEncodings)
|
||||
.to.have.been.calledBefore(RFB.messages.fbUpdateRequest);
|
||||
expect(RFB.messages.fbUpdateRequest).to.have.been.calledOnce;
|
||||
expect(RFB.messages.fbUpdateRequest).to.have.been.calledWith(client._sock, false, 0, 0, 27, 32);
|
||||
expect(RFB.messages.fbUpdateRequest)
|
||||
.to.have.been.calledWith(client._sock, false, 0, 0, 27, 32);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -1665,7 +1673,8 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 3]));
|
||||
expect(client._sock._websocket._get_sent_data()).to.have.length(0);
|
||||
|
||||
client._framebufferUpdate = function () { this._sock.rQskip8(); return true; }; // we magically have enough data
|
||||
// we magically have enough data
|
||||
client._framebufferUpdate = function () { this._sock.rQskip8(); return true; };
|
||||
// 247 should *not* be used as the message type here
|
||||
client._sock._websocket._receive_data(new Uint8Array([247]));
|
||||
expect(client._sock).to.have.sent(expected_msg._sQ);
|
||||
|
|
@ -1693,7 +1702,8 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||
client._fb_width = 4;
|
||||
client._fb_height = 4;
|
||||
client._display.resize(4, 4);
|
||||
client._display.blitRgbxImage(0, 0, 4, 2, new Uint8Array(target_data_check_arr.slice(0, 32)), 0);
|
||||
client._display.blitRgbxImage(0, 0, 4, 2,
|
||||
new Uint8Array(target_data_check_arr.slice(0, 32)), 0);
|
||||
|
||||
const info = [{
|
||||
x: 0, y: 2, width: 2, height: 2, encoding: 0x01
|
||||
|
|
@ -1765,7 +1775,8 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||
|
||||
it('should handle the COPYRECT encoding', function () {
|
||||
// seed some initial data to copy
|
||||
client._display.blitRgbxImage(0, 0, 4, 2, new Uint8Array(target_data_check_arr.slice(0, 32)), 0);
|
||||
client._display.blitRgbxImage(0, 0, 4, 2,
|
||||
new Uint8Array(target_data_check_arr.slice(0, 32)), 0);
|
||||
|
||||
const info = [{
|
||||
x: 0, y: 2, width: 2, height: 2, encoding: 0x01
|
||||
|
|
@ -1883,7 +1894,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||
|
||||
const expected = [];
|
||||
for (let i = 0; i < 16; i++) { push32(expected, 0xff00ff); } // rect 1: solid
|
||||
for (let i = 0; i < 16; i++) { push32(expected, 0xff00ff); } // rect 2: same bkground color
|
||||
for (let i = 0; i < 16; i++) { push32(expected, 0xff00ff); } // rect 2: same bg color
|
||||
expect(client._display).to.have.displayed(new Uint8Array(expected));
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,8 @@ describe('Websock', function () {
|
|||
const bef_rQi = sock.get_rQi();
|
||||
const shifted = sock.rQshiftStr(3);
|
||||
expect(shifted).to.be.a('string');
|
||||
expect(shifted).to.equal(String.fromCharCode.apply(null, Array.prototype.slice.call(new Uint8Array(RQ_TEMPLATE.buffer, bef_rQi, 3))));
|
||||
expect(shifted).to.equal(String.fromCharCode.apply(null,
|
||||
Array.prototype.slice.call(new Uint8Array(RQ_TEMPLATE.buffer, bef_rQi, 3))));
|
||||
expect(sock.rQlen()).to.equal(bef_len - 3);
|
||||
});
|
||||
|
||||
|
|
@ -225,7 +226,8 @@ describe('Websock', function () {
|
|||
it('should add to the send queue', function () {
|
||||
sock.send([1, 2, 3]);
|
||||
const sq = sock.get_sQ();
|
||||
expect(new Uint8Array(sq.buffer, sock._sQlen - 3, 3)).to.array.equal(new Uint8Array([1, 2, 3]));
|
||||
const sendQueue = new Uint8Array(sq.buffer, sock._sQlen - 3, 3);
|
||||
expect(sendQueue).to.array.equal(new Uint8Array([1, 2, 3]));
|
||||
});
|
||||
|
||||
it('should call flush', function () {
|
||||
|
|
|
|||
Loading…
Reference in New Issue