@novnc/novnc 1.3.0-g58dfb7d → 1.3.0-g64d3d60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/input/keyboard.js +10 -0
- package/core/rfb.js +21 -4
- package/lib/base64.js +19 -33
- package/lib/decoders/copyrect.js +0 -10
- package/lib/decoders/hextile.js +12 -44
- package/lib/decoders/jpeg.js +0 -42
- package/lib/decoders/raw.js +4 -20
- package/lib/decoders/rre.js +0 -14
- package/lib/decoders/tight.js +8 -76
- package/lib/decoders/tightpng.js +0 -22
- package/lib/decoders/zrle.js +2 -51
- package/lib/deflator.js +4 -21
- package/lib/des.js +19 -35
- package/lib/display.js +42 -105
- package/lib/encodings.js +1 -10
- package/lib/inflator.js +1 -17
- package/lib/input/domkeytable.js +77 -48
- package/lib/input/fixedkeys.js +8 -3
- package/lib/input/gesturehandler.js +81 -151
- package/lib/input/keyboard.js +57 -88
- package/lib/input/keysym.js +14 -270
- package/lib/input/keysymdef.js +5 -7
- package/lib/input/util.js +42 -84
- package/lib/input/vkeys.js +0 -3
- package/lib/input/xtscancodes.js +1 -168
- package/lib/ra2.js +9 -235
- package/lib/rfb.js +306 -938
- package/lib/util/browser.js +16 -25
- package/lib/util/cursor.js +20 -64
- package/lib/util/element.js +3 -5
- package/lib/util/events.js +23 -30
- package/lib/util/eventtarget.js +0 -12
- package/lib/util/int.js +1 -2
- package/lib/util/logging.js +1 -19
- package/lib/util/md5.js +7 -27
- package/lib/util/strings.js +3 -5
- package/lib/vendor/pako/lib/utils/common.js +8 -17
- package/lib/vendor/pako/lib/zlib/adler32.js +3 -7
- package/lib/vendor/pako/lib/zlib/constants.js +2 -5
- package/lib/vendor/pako/lib/zlib/crc32.js +5 -12
- package/lib/vendor/pako/lib/zlib/deflate.js +212 -617
- package/lib/vendor/pako/lib/zlib/gzheader.js +1 -13
- package/lib/vendor/pako/lib/zlib/inffast.js +60 -176
- package/lib/vendor/pako/lib/zlib/inflate.js +397 -887
- package/lib/vendor/pako/lib/zlib/inftrees.js +62 -168
- package/lib/vendor/pako/lib/zlib/messages.js +1 -11
- package/lib/vendor/pako/lib/zlib/trees.js +245 -587
- package/lib/vendor/pako/lib/zlib/zstream.js +2 -18
- package/lib/websock.js +31 -84
- package/package.json +31 -31
package/core/input/keyboard.js
CHANGED
|
@@ -153,6 +153,16 @@ export default class Keyboard {
|
|
|
153
153
|
keysym = this._keyDownList[code];
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
// macOS doesn't send proper key releases if a key is pressed
|
|
157
|
+
// while meta is held down
|
|
158
|
+
if ((browser.isMac() || browser.isIOS()) &&
|
|
159
|
+
(e.metaKey && code !== 'MetaLeft' && code !== 'MetaRight')) {
|
|
160
|
+
this._sendKeyEvent(keysym, code, true);
|
|
161
|
+
this._sendKeyEvent(keysym, code, false);
|
|
162
|
+
stopEvent(e);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
156
166
|
// macOS doesn't send proper key events for modifiers, only
|
|
157
167
|
// state change events. That gets extra confusing for CapsLock
|
|
158
168
|
// which toggles on each press, but not on release. So pretend
|
package/core/rfb.js
CHANGED
|
@@ -490,10 +490,27 @@ export default class RFB extends EventTargetMixin {
|
|
|
490
490
|
this._clipboardText = text;
|
|
491
491
|
RFB.messages.extendedClipboardNotify(this._sock, [extendedClipboardFormatText]);
|
|
492
492
|
} else {
|
|
493
|
-
let
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
493
|
+
let length, i;
|
|
494
|
+
let data;
|
|
495
|
+
|
|
496
|
+
length = 0;
|
|
497
|
+
// eslint-disable-next-line no-unused-vars
|
|
498
|
+
for (let codePoint of text) {
|
|
499
|
+
length++;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
data = new Uint8Array(length);
|
|
503
|
+
|
|
504
|
+
i = 0;
|
|
505
|
+
for (let codePoint of text) {
|
|
506
|
+
let code = codePoint.codePointAt(0);
|
|
507
|
+
|
|
508
|
+
/* Only ISO 8859-1 is supported */
|
|
509
|
+
if (code > 0xff) {
|
|
510
|
+
code = 0x3f; // '?'
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
data[i++] = code;
|
|
497
514
|
}
|
|
498
515
|
|
|
499
516
|
RFB.messages.clientCutText(this._sock, data);
|
package/lib/base64.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var Log = _interopRequireWildcard(require("./util/logging.js"));
|
|
11
|
-
|
|
12
9
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
-
|
|
14
10
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
-
|
|
16
11
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
17
12
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
18
13
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
@@ -26,18 +21,18 @@ var _default = {
|
|
|
26
21
|
|
|
27
22
|
var result = '';
|
|
28
23
|
var length = data.length;
|
|
29
|
-
var lengthpad = length % 3;
|
|
24
|
+
var lengthpad = length % 3;
|
|
25
|
+
// Convert every three bytes to 4 ascii characters.
|
|
30
26
|
|
|
31
27
|
for (var i = 0; i < length - 2; i += 3) {
|
|
32
28
|
result += this.toBase64Table[data[i] >> 2];
|
|
33
29
|
result += this.toBase64Table[((data[i] & 0x03) << 4) + (data[i + 1] >> 4)];
|
|
34
30
|
result += this.toBase64Table[((data[i + 1] & 0x0f) << 2) + (data[i + 2] >> 6)];
|
|
35
31
|
result += this.toBase64Table[data[i + 2] & 0x3f];
|
|
36
|
-
}
|
|
37
|
-
|
|
32
|
+
}
|
|
38
33
|
|
|
34
|
+
// Convert the remaining 1 or 2 bytes, pad out to 4 characters.
|
|
39
35
|
var j = length - lengthpad;
|
|
40
|
-
|
|
41
36
|
if (lengthpad === 2) {
|
|
42
37
|
result += this.toBase64Table[data[j] >> 2];
|
|
43
38
|
result += this.toBase64Table[((data[j] & 0x03) << 4) + (data[j + 1] >> 4)];
|
|
@@ -49,67 +44,58 @@ var _default = {
|
|
|
49
44
|
result += this.toBase64Table[64];
|
|
50
45
|
result += this.toBase64Table[64];
|
|
51
46
|
}
|
|
52
|
-
|
|
53
47
|
return result;
|
|
54
48
|
},
|
|
55
|
-
|
|
56
49
|
/* Convert Base64 data to a string */
|
|
57
|
-
|
|
58
50
|
/* eslint-disable comma-spacing */
|
|
59
51
|
toBinaryTable: [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1],
|
|
60
|
-
|
|
61
|
-
/* eslint-enable comma-spacing */
|
|
62
|
-
decode: function decode(data) {
|
|
52
|
+
/* eslint-enable comma-spacing */decode: function decode(data) {
|
|
63
53
|
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
64
54
|
var dataLength = data.indexOf('=') - offset;
|
|
65
|
-
|
|
66
55
|
if (dataLength < 0) {
|
|
67
56
|
dataLength = data.length - offset;
|
|
68
57
|
}
|
|
69
|
-
/* Every four characters is 3 resulting numbers */
|
|
70
|
-
|
|
71
58
|
|
|
59
|
+
/* Every four characters is 3 resulting numbers */
|
|
72
60
|
var resultLength = (dataLength >> 2) * 3 + Math.floor(dataLength % 4 / 1.5);
|
|
73
|
-
var result = new Array(resultLength);
|
|
61
|
+
var result = new Array(resultLength);
|
|
74
62
|
|
|
75
|
-
|
|
63
|
+
// Convert one by one.
|
|
76
64
|
|
|
65
|
+
var leftbits = 0; // number of bits decoded, but yet to be appended
|
|
77
66
|
var leftdata = 0; // bits decoded, but yet to be appended
|
|
78
|
-
|
|
79
67
|
for (var idx = 0, i = offset; i < data.length; i++) {
|
|
80
68
|
var c = this.toBinaryTable[data.charCodeAt(i) & 0x7f];
|
|
81
|
-
var padding = data.charAt(i) === this.base64Pad;
|
|
82
|
-
|
|
69
|
+
var padding = data.charAt(i) === this.base64Pad;
|
|
70
|
+
// Skip illegal characters and whitespace
|
|
83
71
|
if (c === -1) {
|
|
84
72
|
Log.Error("Illegal character code " + data.charCodeAt(i) + " at position " + i);
|
|
85
73
|
continue;
|
|
86
|
-
}
|
|
87
|
-
|
|
74
|
+
}
|
|
88
75
|
|
|
76
|
+
// Collect data into leftdata, update bitcount
|
|
89
77
|
leftdata = leftdata << 6 | c;
|
|
90
|
-
leftbits += 6;
|
|
78
|
+
leftbits += 6;
|
|
91
79
|
|
|
80
|
+
// If we have 8 or more bits, append 8 bits to the result
|
|
92
81
|
if (leftbits >= 8) {
|
|
93
|
-
leftbits -= 8;
|
|
94
|
-
|
|
82
|
+
leftbits -= 8;
|
|
83
|
+
// Append if not padding.
|
|
95
84
|
if (!padding) {
|
|
96
85
|
result[idx++] = leftdata >> leftbits & 0xff;
|
|
97
86
|
}
|
|
98
|
-
|
|
99
87
|
leftdata &= (1 << leftbits) - 1;
|
|
100
88
|
}
|
|
101
|
-
}
|
|
102
|
-
|
|
89
|
+
}
|
|
103
90
|
|
|
91
|
+
// If there are any bits left, the base64 string was corrupted
|
|
104
92
|
if (leftbits) {
|
|
105
93
|
var err = new Error('Corrupted base64 string');
|
|
106
94
|
err.name = 'Base64-Error';
|
|
107
95
|
throw err;
|
|
108
96
|
}
|
|
109
|
-
|
|
110
97
|
return result;
|
|
111
98
|
}
|
|
112
99
|
};
|
|
113
100
|
/* End of Base64 namespace */
|
|
114
|
-
|
|
115
101
|
exports["default"] = _default;
|
package/lib/decoders/copyrect.js
CHANGED
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
-
|
|
10
8
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
11
|
-
|
|
12
9
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
-
|
|
14
10
|
/*
|
|
15
11
|
* noVNC: HTML5 VNC client
|
|
16
12
|
* Copyright (C) 2019 The noVNC Authors
|
|
@@ -23,27 +19,21 @@ var CopyRectDecoder = /*#__PURE__*/function () {
|
|
|
23
19
|
function CopyRectDecoder() {
|
|
24
20
|
_classCallCheck(this, CopyRectDecoder);
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
_createClass(CopyRectDecoder, [{
|
|
28
23
|
key: "decodeRect",
|
|
29
24
|
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
30
25
|
if (sock.rQwait("COPYRECT", 4)) {
|
|
31
26
|
return false;
|
|
32
27
|
}
|
|
33
|
-
|
|
34
28
|
var deltaX = sock.rQshift16();
|
|
35
29
|
var deltaY = sock.rQshift16();
|
|
36
|
-
|
|
37
30
|
if (width === 0 || height === 0) {
|
|
38
31
|
return true;
|
|
39
32
|
}
|
|
40
|
-
|
|
41
33
|
display.copyImage(deltaX, deltaY, x, y, width, height);
|
|
42
34
|
return true;
|
|
43
35
|
}
|
|
44
36
|
}]);
|
|
45
|
-
|
|
46
37
|
return CopyRectDecoder;
|
|
47
38
|
}();
|
|
48
|
-
|
|
49
39
|
exports["default"] = CopyRectDecoder;
|
package/lib/decoders/hextile.js
CHANGED
|
@@ -1,33 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var Log = _interopRequireWildcard(require("../util/logging.js"));
|
|
11
|
-
|
|
12
9
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
-
|
|
14
10
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
-
|
|
16
11
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
-
|
|
18
12
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
19
|
-
|
|
20
13
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
21
|
-
|
|
22
14
|
var HextileDecoder = /*#__PURE__*/function () {
|
|
23
15
|
function HextileDecoder() {
|
|
24
16
|
_classCallCheck(this, HextileDecoder);
|
|
25
|
-
|
|
26
17
|
this._tiles = 0;
|
|
27
18
|
this._lastsubencoding = 0;
|
|
28
19
|
this._tileBuffer = new Uint8Array(16 * 16 * 4);
|
|
29
20
|
}
|
|
30
|
-
|
|
31
21
|
_createClass(HextileDecoder, [{
|
|
32
22
|
key: "decodeRect",
|
|
33
23
|
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
@@ -37,31 +27,27 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
37
27
|
this._totalTiles = this._tilesX * this._tilesY;
|
|
38
28
|
this._tiles = this._totalTiles;
|
|
39
29
|
}
|
|
40
|
-
|
|
41
30
|
while (this._tiles > 0) {
|
|
42
31
|
var bytes = 1;
|
|
43
|
-
|
|
44
32
|
if (sock.rQwait("HEXTILE", bytes)) {
|
|
45
33
|
return false;
|
|
46
34
|
}
|
|
47
|
-
|
|
48
35
|
var rQ = sock.rQ;
|
|
49
36
|
var rQi = sock.rQi;
|
|
50
37
|
var subencoding = rQ[rQi]; // Peek
|
|
51
|
-
|
|
52
38
|
if (subencoding > 30) {
|
|
53
39
|
// Raw
|
|
54
40
|
throw new Error("Illegal hextile subencoding (subencoding: " + subencoding + ")");
|
|
55
41
|
}
|
|
56
|
-
|
|
57
42
|
var currTile = this._totalTiles - this._tiles;
|
|
58
43
|
var tileX = currTile % this._tilesX;
|
|
59
44
|
var tileY = Math.floor(currTile / this._tilesX);
|
|
60
45
|
var tx = x + tileX * 16;
|
|
61
46
|
var ty = y + tileY * 16;
|
|
62
47
|
var tw = Math.min(16, x + width - tx);
|
|
63
|
-
var th = Math.min(16, y + height - ty);
|
|
48
|
+
var th = Math.min(16, y + height - ty);
|
|
64
49
|
|
|
50
|
+
// Figure out how much we are expecting
|
|
65
51
|
if (subencoding & 0x01) {
|
|
66
52
|
// Raw
|
|
67
53
|
bytes += tw * th * 4;
|
|
@@ -70,12 +56,10 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
70
56
|
// Background
|
|
71
57
|
bytes += 4;
|
|
72
58
|
}
|
|
73
|
-
|
|
74
59
|
if (subencoding & 0x04) {
|
|
75
60
|
// Foreground
|
|
76
61
|
bytes += 4;
|
|
77
62
|
}
|
|
78
|
-
|
|
79
63
|
if (subencoding & 0x08) {
|
|
80
64
|
// AnySubrects
|
|
81
65
|
bytes++; // Since we aren't shifting it off
|
|
@@ -83,9 +67,7 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
83
67
|
if (sock.rQwait("HEXTILE", bytes)) {
|
|
84
68
|
return false;
|
|
85
69
|
}
|
|
86
|
-
|
|
87
70
|
var subrects = rQ[rQi + bytes - 1]; // Peek
|
|
88
|
-
|
|
89
71
|
if (subencoding & 0x10) {
|
|
90
72
|
// SubrectsColoured
|
|
91
73
|
bytes += subrects * (4 + 2);
|
|
@@ -94,14 +76,12 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
94
76
|
}
|
|
95
77
|
}
|
|
96
78
|
}
|
|
97
|
-
|
|
98
79
|
if (sock.rQwait("HEXTILE", bytes)) {
|
|
99
80
|
return false;
|
|
100
|
-
}
|
|
101
|
-
|
|
81
|
+
}
|
|
102
82
|
|
|
83
|
+
// We know the encoding and have a whole tile
|
|
103
84
|
rQi++;
|
|
104
|
-
|
|
105
85
|
if (subencoding === 0) {
|
|
106
86
|
if (this._lastsubencoding & 0x01) {
|
|
107
87
|
// Weird: ignore blanks are RAW
|
|
@@ -111,12 +91,11 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
111
91
|
}
|
|
112
92
|
} else if (subencoding & 0x01) {
|
|
113
93
|
// Raw
|
|
114
|
-
var pixels = tw * th;
|
|
115
|
-
|
|
94
|
+
var pixels = tw * th;
|
|
95
|
+
// Max sure the image is fully opaque
|
|
116
96
|
for (var i = 0; i < pixels; i++) {
|
|
117
97
|
rQ[rQi + i * 4 + 3] = 255;
|
|
118
98
|
}
|
|
119
|
-
|
|
120
99
|
display.blitImage(tx, ty, tw, th, rQ, rQi);
|
|
121
100
|
rQi += bytes - 1;
|
|
122
101
|
} else {
|
|
@@ -125,23 +104,18 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
125
104
|
this._background = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
|
|
126
105
|
rQi += 4;
|
|
127
106
|
}
|
|
128
|
-
|
|
129
107
|
if (subencoding & 0x04) {
|
|
130
108
|
// Foreground
|
|
131
109
|
this._foreground = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
|
|
132
110
|
rQi += 4;
|
|
133
111
|
}
|
|
134
|
-
|
|
135
112
|
this._startTile(tx, ty, tw, th, this._background);
|
|
136
|
-
|
|
137
113
|
if (subencoding & 0x08) {
|
|
138
114
|
// AnySubrects
|
|
139
115
|
var _subrects = rQ[rQi];
|
|
140
116
|
rQi++;
|
|
141
|
-
|
|
142
117
|
for (var s = 0; s < _subrects; s++) {
|
|
143
118
|
var color = void 0;
|
|
144
|
-
|
|
145
119
|
if (subencoding & 0x10) {
|
|
146
120
|
// SubrectsColoured
|
|
147
121
|
color = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
|
|
@@ -149,7 +123,6 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
149
123
|
} else {
|
|
150
124
|
color = this._foreground;
|
|
151
125
|
}
|
|
152
|
-
|
|
153
126
|
var xy = rQ[rQi];
|
|
154
127
|
rQi++;
|
|
155
128
|
var sx = xy >> 4;
|
|
@@ -158,22 +131,19 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
158
131
|
rQi++;
|
|
159
132
|
var sw = (wh >> 4) + 1;
|
|
160
133
|
var sh = (wh & 0x0f) + 1;
|
|
161
|
-
|
|
162
134
|
this._subTile(sx, sy, sw, sh, color);
|
|
163
135
|
}
|
|
164
136
|
}
|
|
165
|
-
|
|
166
137
|
this._finishTile(display);
|
|
167
138
|
}
|
|
168
|
-
|
|
169
139
|
sock.rQi = rQi;
|
|
170
140
|
this._lastsubencoding = subencoding;
|
|
171
141
|
this._tiles--;
|
|
172
142
|
}
|
|
173
|
-
|
|
174
143
|
return true;
|
|
175
|
-
}
|
|
144
|
+
}
|
|
176
145
|
|
|
146
|
+
// start updating a tile
|
|
177
147
|
}, {
|
|
178
148
|
key: "_startTile",
|
|
179
149
|
value: function _startTile(x, y, width, height, color) {
|
|
@@ -185,15 +155,15 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
185
155
|
var green = color[1];
|
|
186
156
|
var blue = color[2];
|
|
187
157
|
var data = this._tileBuffer;
|
|
188
|
-
|
|
189
158
|
for (var i = 0; i < width * height * 4; i += 4) {
|
|
190
159
|
data[i] = red;
|
|
191
160
|
data[i + 1] = green;
|
|
192
161
|
data[i + 2] = blue;
|
|
193
162
|
data[i + 3] = 255;
|
|
194
163
|
}
|
|
195
|
-
}
|
|
164
|
+
}
|
|
196
165
|
|
|
166
|
+
// update sub-rectangle of the current tile
|
|
197
167
|
}, {
|
|
198
168
|
key: "_subTile",
|
|
199
169
|
value: function _subTile(x, y, w, h, color) {
|
|
@@ -204,7 +174,6 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
204
174
|
var yend = y + h;
|
|
205
175
|
var data = this._tileBuffer;
|
|
206
176
|
var width = this._tileW;
|
|
207
|
-
|
|
208
177
|
for (var j = y; j < yend; j++) {
|
|
209
178
|
for (var i = x; i < xend; i++) {
|
|
210
179
|
var p = (i + j * width) * 4;
|
|
@@ -214,16 +183,15 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
214
183
|
data[p + 3] = 255;
|
|
215
184
|
}
|
|
216
185
|
}
|
|
217
|
-
}
|
|
186
|
+
}
|
|
218
187
|
|
|
188
|
+
// draw the current tile to the screen
|
|
219
189
|
}, {
|
|
220
190
|
key: "_finishTile",
|
|
221
191
|
value: function _finishTile(display) {
|
|
222
192
|
display.blitImage(this._tileX, this._tileY, this._tileW, this._tileH, this._tileBuffer, 0);
|
|
223
193
|
}
|
|
224
194
|
}]);
|
|
225
|
-
|
|
226
195
|
return HextileDecoder;
|
|
227
196
|
}();
|
|
228
|
-
|
|
229
197
|
exports["default"] = HextileDecoder;
|
package/lib/decoders/jpeg.js
CHANGED
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
-
|
|
10
8
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
11
|
-
|
|
12
9
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
-
|
|
14
10
|
/*
|
|
15
11
|
* noVNC: HTML5 VNC client
|
|
16
12
|
* Copyright (C) 2019 The noVNC Authors
|
|
@@ -22,7 +18,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
22
18
|
var JPEGDecoder = /*#__PURE__*/function () {
|
|
23
19
|
function JPEGDecoder() {
|
|
24
20
|
_classCallCheck(this, JPEGDecoder);
|
|
25
|
-
|
|
26
21
|
// RealVNC will reuse the quantization tables
|
|
27
22
|
// and Huffman tables, so we need to cache them.
|
|
28
23
|
this._quantTables = [];
|
|
@@ -32,7 +27,6 @@ var JPEGDecoder = /*#__PURE__*/function () {
|
|
|
32
27
|
this._jpegLength = 0;
|
|
33
28
|
this._segments = [];
|
|
34
29
|
}
|
|
35
|
-
|
|
36
30
|
_createClass(JPEGDecoder, [{
|
|
37
31
|
key: "decodeRect",
|
|
38
32
|
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
@@ -40,9 +34,7 @@ var JPEGDecoder = /*#__PURE__*/function () {
|
|
|
40
34
|
if (!this._parseJPEG(sock.rQslice(0))) {
|
|
41
35
|
return false;
|
|
42
36
|
}
|
|
43
|
-
|
|
44
37
|
var data = sock.rQshiftBytes(this._jpegLength);
|
|
45
|
-
|
|
46
38
|
if (this._quantTables.length != 0 && this._huffmanTables.length != 0) {
|
|
47
39
|
// If there are quantization tables and Huffman tables in the JPEG
|
|
48
40
|
// image, we can directly render it.
|
|
@@ -53,32 +45,23 @@ var JPEGDecoder = /*#__PURE__*/function () {
|
|
|
53
45
|
var sofIndex = this._segments.findIndex(function (x) {
|
|
54
46
|
return x[1] == 0xC0 || x[1] == 0xC2;
|
|
55
47
|
});
|
|
56
|
-
|
|
57
48
|
if (sofIndex == -1) {
|
|
58
49
|
throw new Error("Illegal JPEG image without SOF");
|
|
59
50
|
}
|
|
60
|
-
|
|
61
51
|
var segments = this._segments.slice(0, sofIndex);
|
|
62
|
-
|
|
63
52
|
segments = segments.concat(this._quantTables.length ? this._quantTables : this._cachedQuantTables);
|
|
64
53
|
segments.push(this._segments[sofIndex]);
|
|
65
54
|
segments = segments.concat(this._huffmanTables.length ? this._huffmanTables : this._cachedHuffmanTables, this._segments.slice(sofIndex + 1));
|
|
66
55
|
var length = 0;
|
|
67
|
-
|
|
68
56
|
for (var i = 0; i < segments.length; i++) {
|
|
69
57
|
length += segments[i].length;
|
|
70
58
|
}
|
|
71
|
-
|
|
72
59
|
var _data = new Uint8Array(length);
|
|
73
|
-
|
|
74
60
|
length = 0;
|
|
75
|
-
|
|
76
61
|
for (var _i = 0; _i < segments.length; _i++) {
|
|
77
62
|
_data.set(segments[_i], length);
|
|
78
|
-
|
|
79
63
|
length += segments[_i].length;
|
|
80
64
|
}
|
|
81
|
-
|
|
82
65
|
display.imageRect(x, y, width, height, "image/jpeg", _data);
|
|
83
66
|
return true;
|
|
84
67
|
}
|
|
@@ -89,41 +72,31 @@ var JPEGDecoder = /*#__PURE__*/function () {
|
|
|
89
72
|
if (this._quantTables.length != 0) {
|
|
90
73
|
this._cachedQuantTables = this._quantTables;
|
|
91
74
|
}
|
|
92
|
-
|
|
93
75
|
if (this._huffmanTables.length != 0) {
|
|
94
76
|
this._cachedHuffmanTables = this._huffmanTables;
|
|
95
77
|
}
|
|
96
|
-
|
|
97
78
|
this._quantTables = [];
|
|
98
79
|
this._huffmanTables = [];
|
|
99
80
|
this._segments = [];
|
|
100
81
|
var i = 0;
|
|
101
82
|
var bufferLength = buffer.length;
|
|
102
|
-
|
|
103
83
|
while (true) {
|
|
104
84
|
var j = i;
|
|
105
|
-
|
|
106
85
|
if (j + 2 > bufferLength) {
|
|
107
86
|
return false;
|
|
108
87
|
}
|
|
109
|
-
|
|
110
88
|
if (buffer[j] != 0xFF) {
|
|
111
89
|
throw new Error("Illegal JPEG marker received (byte: " + buffer[j] + ")");
|
|
112
90
|
}
|
|
113
|
-
|
|
114
91
|
var type = buffer[j + 1];
|
|
115
92
|
j += 2;
|
|
116
|
-
|
|
117
93
|
if (type == 0xD9) {
|
|
118
94
|
this._jpegLength = j;
|
|
119
|
-
|
|
120
95
|
this._segments.push(buffer.slice(i, j));
|
|
121
|
-
|
|
122
96
|
return true;
|
|
123
97
|
} else if (type == 0xDA) {
|
|
124
98
|
// start of scan
|
|
125
99
|
var hasFoundEndOfScan = false;
|
|
126
|
-
|
|
127
100
|
for (var k = j + 3; k + 1 < bufferLength; k++) {
|
|
128
101
|
if (buffer[k] == 0xFF && buffer[k + 1] != 0x00 && !(buffer[k + 1] >= 0xD0 && buffer[k + 1] <= 0xD7)) {
|
|
129
102
|
j = k;
|
|
@@ -131,42 +104,31 @@ var JPEGDecoder = /*#__PURE__*/function () {
|
|
|
131
104
|
break;
|
|
132
105
|
}
|
|
133
106
|
}
|
|
134
|
-
|
|
135
107
|
if (!hasFoundEndOfScan) {
|
|
136
108
|
return false;
|
|
137
109
|
}
|
|
138
|
-
|
|
139
110
|
this._segments.push(buffer.slice(i, j));
|
|
140
|
-
|
|
141
111
|
i = j;
|
|
142
112
|
continue;
|
|
143
113
|
} else if (type >= 0xD0 && type < 0xD9 || type == 0x01) {
|
|
144
114
|
// No length after marker
|
|
145
115
|
this._segments.push(buffer.slice(i, j));
|
|
146
|
-
|
|
147
116
|
i = j;
|
|
148
117
|
continue;
|
|
149
118
|
}
|
|
150
|
-
|
|
151
119
|
if (j + 2 > bufferLength) {
|
|
152
120
|
return false;
|
|
153
121
|
}
|
|
154
|
-
|
|
155
122
|
var length = (buffer[j] << 8) + buffer[j + 1] - 2;
|
|
156
|
-
|
|
157
123
|
if (length < 0) {
|
|
158
124
|
throw new Error("Illegal JPEG length received (length: " + length + ")");
|
|
159
125
|
}
|
|
160
|
-
|
|
161
126
|
j += 2;
|
|
162
|
-
|
|
163
127
|
if (j + length > bufferLength) {
|
|
164
128
|
return false;
|
|
165
129
|
}
|
|
166
|
-
|
|
167
130
|
j += length;
|
|
168
131
|
var segment = buffer.slice(i, j);
|
|
169
|
-
|
|
170
132
|
if (type == 0xC4) {
|
|
171
133
|
// Huffman tables
|
|
172
134
|
this._huffmanTables.push(segment);
|
|
@@ -174,15 +136,11 @@ var JPEGDecoder = /*#__PURE__*/function () {
|
|
|
174
136
|
// Quantization tables
|
|
175
137
|
this._quantTables.push(segment);
|
|
176
138
|
}
|
|
177
|
-
|
|
178
139
|
this._segments.push(segment);
|
|
179
|
-
|
|
180
140
|
i = j;
|
|
181
141
|
}
|
|
182
142
|
}
|
|
183
143
|
}]);
|
|
184
|
-
|
|
185
144
|
return JPEGDecoder;
|
|
186
145
|
}();
|
|
187
|
-
|
|
188
146
|
exports["default"] = JPEGDecoder;
|