@novnc/novnc 1.3.0 → 1.4.0-beta
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/AUTHORS +2 -2
- package/LICENSE.txt +1 -1
- package/README.md +23 -7
- package/core/decoders/jpeg.js +141 -0
- package/core/decoders/raw.js +1 -1
- package/core/decoders/zrle.js +185 -0
- package/core/des.js +1 -1
- package/core/display.js +12 -0
- package/core/encodings.js +4 -0
- package/core/input/keyboard.js +10 -0
- package/core/ra2.js +567 -0
- package/core/rfb.js +469 -84
- package/core/util/browser.js +56 -7
- package/core/util/cursor.js +4 -0
- package/core/util/md5.js +79 -0
- package/docs/API.md +318 -157
- package/lib/base64.js +20 -34
- package/lib/decoders/copyrect.js +5 -12
- package/lib/decoders/hextile.js +17 -47
- package/lib/decoders/jpeg.js +149 -0
- package/lib/decoders/raw.js +10 -23
- package/lib/decoders/rre.js +5 -16
- package/lib/decoders/tight.js +13 -79
- package/lib/decoders/tightpng.js +8 -28
- package/lib/decoders/zrle.js +188 -0
- package/lib/deflator.js +9 -23
- package/lib/des.js +24 -37
- package/lib/display.js +62 -108
- package/lib/encodings.js +7 -8
- package/lib/inflator.js +6 -19
- package/lib/input/domkeytable.js +77 -48
- package/lib/input/fixedkeys.js +8 -3
- package/lib/input/gesturehandler.js +86 -153
- package/lib/input/keyboard.js +62 -91
- package/lib/input/keysym.js +14 -270
- package/lib/input/keysymdef.js +5 -7
- package/lib/input/util.js +43 -85
- package/lib/input/vkeys.js +0 -3
- package/lib/input/xtscancodes.js +1 -168
- package/lib/ra2.js +1005 -0
- package/lib/rfb.js +795 -923
- package/lib/util/browser.js +66 -29
- package/lib/util/cursor.js +29 -66
- package/lib/util/element.js +3 -5
- package/lib/util/events.js +23 -30
- package/lib/util/eventtarget.js +5 -14
- package/lib/util/int.js +1 -2
- package/lib/util/logging.js +1 -19
- package/lib/util/md5.js +77 -0
- 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 +213 -618
- 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 +398 -888
- package/lib/vendor/pako/lib/zlib/inftrees.js +63 -169
- package/lib/vendor/pako/lib/zlib/messages.js +1 -11
- package/lib/vendor/pako/lib/zlib/trees.js +246 -588
- package/lib/vendor/pako/lib/zlib/zstream.js +2 -18
- package/lib/websock.js +37 -88
- package/package.json +32 -35
package/lib/base64.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
4
|
-
|
|
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); }
|
|
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,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
7
|
+
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); }
|
|
8
8
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
9
|
+
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, _toPropertyKey(descriptor.key), descriptor); } }
|
|
10
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
14
13
|
/*
|
|
15
14
|
* noVNC: HTML5 VNC client
|
|
16
15
|
* Copyright (C) 2019 The noVNC Authors
|
|
@@ -23,27 +22,21 @@ var CopyRectDecoder = /*#__PURE__*/function () {
|
|
|
23
22
|
function CopyRectDecoder() {
|
|
24
23
|
_classCallCheck(this, CopyRectDecoder);
|
|
25
24
|
}
|
|
26
|
-
|
|
27
25
|
_createClass(CopyRectDecoder, [{
|
|
28
26
|
key: "decodeRect",
|
|
29
27
|
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
30
28
|
if (sock.rQwait("COPYRECT", 4)) {
|
|
31
29
|
return false;
|
|
32
30
|
}
|
|
33
|
-
|
|
34
31
|
var deltaX = sock.rQshift16();
|
|
35
32
|
var deltaY = sock.rQshift16();
|
|
36
|
-
|
|
37
33
|
if (width === 0 || height === 0) {
|
|
38
34
|
return true;
|
|
39
35
|
}
|
|
40
|
-
|
|
41
36
|
display.copyImage(deltaX, deltaY, x, y, width, height);
|
|
42
37
|
return true;
|
|
43
38
|
}
|
|
44
39
|
}]);
|
|
45
|
-
|
|
46
40
|
return CopyRectDecoder;
|
|
47
41
|
}();
|
|
48
|
-
|
|
49
42
|
exports["default"] = CopyRectDecoder;
|
package/lib/decoders/hextile.js
CHANGED
|
@@ -1,33 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
7
|
var Log = _interopRequireWildcard(require("../util/logging.js"));
|
|
11
|
-
|
|
12
8
|
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
9
|
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
|
-
|
|
10
|
+
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); }
|
|
16
11
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
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, _toPropertyKey(descriptor.key), descriptor); } }
|
|
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; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
22
16
|
var HextileDecoder = /*#__PURE__*/function () {
|
|
23
17
|
function HextileDecoder() {
|
|
24
18
|
_classCallCheck(this, HextileDecoder);
|
|
25
|
-
|
|
26
19
|
this._tiles = 0;
|
|
27
20
|
this._lastsubencoding = 0;
|
|
28
21
|
this._tileBuffer = new Uint8Array(16 * 16 * 4);
|
|
29
22
|
}
|
|
30
|
-
|
|
31
23
|
_createClass(HextileDecoder, [{
|
|
32
24
|
key: "decodeRect",
|
|
33
25
|
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
@@ -37,31 +29,27 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
37
29
|
this._totalTiles = this._tilesX * this._tilesY;
|
|
38
30
|
this._tiles = this._totalTiles;
|
|
39
31
|
}
|
|
40
|
-
|
|
41
32
|
while (this._tiles > 0) {
|
|
42
33
|
var bytes = 1;
|
|
43
|
-
|
|
44
34
|
if (sock.rQwait("HEXTILE", bytes)) {
|
|
45
35
|
return false;
|
|
46
36
|
}
|
|
47
|
-
|
|
48
37
|
var rQ = sock.rQ;
|
|
49
38
|
var rQi = sock.rQi;
|
|
50
39
|
var subencoding = rQ[rQi]; // Peek
|
|
51
|
-
|
|
52
40
|
if (subencoding > 30) {
|
|
53
41
|
// Raw
|
|
54
42
|
throw new Error("Illegal hextile subencoding (subencoding: " + subencoding + ")");
|
|
55
43
|
}
|
|
56
|
-
|
|
57
44
|
var currTile = this._totalTiles - this._tiles;
|
|
58
45
|
var tileX = currTile % this._tilesX;
|
|
59
46
|
var tileY = Math.floor(currTile / this._tilesX);
|
|
60
47
|
var tx = x + tileX * 16;
|
|
61
48
|
var ty = y + tileY * 16;
|
|
62
49
|
var tw = Math.min(16, x + width - tx);
|
|
63
|
-
var th = Math.min(16, y + height - ty);
|
|
50
|
+
var th = Math.min(16, y + height - ty);
|
|
64
51
|
|
|
52
|
+
// Figure out how much we are expecting
|
|
65
53
|
if (subencoding & 0x01) {
|
|
66
54
|
// Raw
|
|
67
55
|
bytes += tw * th * 4;
|
|
@@ -70,12 +58,10 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
70
58
|
// Background
|
|
71
59
|
bytes += 4;
|
|
72
60
|
}
|
|
73
|
-
|
|
74
61
|
if (subencoding & 0x04) {
|
|
75
62
|
// Foreground
|
|
76
63
|
bytes += 4;
|
|
77
64
|
}
|
|
78
|
-
|
|
79
65
|
if (subencoding & 0x08) {
|
|
80
66
|
// AnySubrects
|
|
81
67
|
bytes++; // Since we aren't shifting it off
|
|
@@ -83,9 +69,7 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
83
69
|
if (sock.rQwait("HEXTILE", bytes)) {
|
|
84
70
|
return false;
|
|
85
71
|
}
|
|
86
|
-
|
|
87
72
|
var subrects = rQ[rQi + bytes - 1]; // Peek
|
|
88
|
-
|
|
89
73
|
if (subencoding & 0x10) {
|
|
90
74
|
// SubrectsColoured
|
|
91
75
|
bytes += subrects * (4 + 2);
|
|
@@ -94,14 +78,12 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
94
78
|
}
|
|
95
79
|
}
|
|
96
80
|
}
|
|
97
|
-
|
|
98
81
|
if (sock.rQwait("HEXTILE", bytes)) {
|
|
99
82
|
return false;
|
|
100
|
-
}
|
|
101
|
-
|
|
83
|
+
}
|
|
102
84
|
|
|
85
|
+
// We know the encoding and have a whole tile
|
|
103
86
|
rQi++;
|
|
104
|
-
|
|
105
87
|
if (subencoding === 0) {
|
|
106
88
|
if (this._lastsubencoding & 0x01) {
|
|
107
89
|
// Weird: ignore blanks are RAW
|
|
@@ -111,12 +93,11 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
111
93
|
}
|
|
112
94
|
} else if (subencoding & 0x01) {
|
|
113
95
|
// Raw
|
|
114
|
-
var pixels = tw * th;
|
|
115
|
-
|
|
96
|
+
var pixels = tw * th;
|
|
97
|
+
// Max sure the image is fully opaque
|
|
116
98
|
for (var i = 0; i < pixels; i++) {
|
|
117
99
|
rQ[rQi + i * 4 + 3] = 255;
|
|
118
100
|
}
|
|
119
|
-
|
|
120
101
|
display.blitImage(tx, ty, tw, th, rQ, rQi);
|
|
121
102
|
rQi += bytes - 1;
|
|
122
103
|
} else {
|
|
@@ -125,23 +106,18 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
125
106
|
this._background = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
|
|
126
107
|
rQi += 4;
|
|
127
108
|
}
|
|
128
|
-
|
|
129
109
|
if (subencoding & 0x04) {
|
|
130
110
|
// Foreground
|
|
131
111
|
this._foreground = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
|
|
132
112
|
rQi += 4;
|
|
133
113
|
}
|
|
134
|
-
|
|
135
114
|
this._startTile(tx, ty, tw, th, this._background);
|
|
136
|
-
|
|
137
115
|
if (subencoding & 0x08) {
|
|
138
116
|
// AnySubrects
|
|
139
117
|
var _subrects = rQ[rQi];
|
|
140
118
|
rQi++;
|
|
141
|
-
|
|
142
119
|
for (var s = 0; s < _subrects; s++) {
|
|
143
120
|
var color = void 0;
|
|
144
|
-
|
|
145
121
|
if (subencoding & 0x10) {
|
|
146
122
|
// SubrectsColoured
|
|
147
123
|
color = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
|
|
@@ -149,7 +125,6 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
149
125
|
} else {
|
|
150
126
|
color = this._foreground;
|
|
151
127
|
}
|
|
152
|
-
|
|
153
128
|
var xy = rQ[rQi];
|
|
154
129
|
rQi++;
|
|
155
130
|
var sx = xy >> 4;
|
|
@@ -158,22 +133,19 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
158
133
|
rQi++;
|
|
159
134
|
var sw = (wh >> 4) + 1;
|
|
160
135
|
var sh = (wh & 0x0f) + 1;
|
|
161
|
-
|
|
162
136
|
this._subTile(sx, sy, sw, sh, color);
|
|
163
137
|
}
|
|
164
138
|
}
|
|
165
|
-
|
|
166
139
|
this._finishTile(display);
|
|
167
140
|
}
|
|
168
|
-
|
|
169
141
|
sock.rQi = rQi;
|
|
170
142
|
this._lastsubencoding = subencoding;
|
|
171
143
|
this._tiles--;
|
|
172
144
|
}
|
|
173
|
-
|
|
174
145
|
return true;
|
|
175
|
-
}
|
|
146
|
+
}
|
|
176
147
|
|
|
148
|
+
// start updating a tile
|
|
177
149
|
}, {
|
|
178
150
|
key: "_startTile",
|
|
179
151
|
value: function _startTile(x, y, width, height, color) {
|
|
@@ -185,15 +157,15 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
185
157
|
var green = color[1];
|
|
186
158
|
var blue = color[2];
|
|
187
159
|
var data = this._tileBuffer;
|
|
188
|
-
|
|
189
160
|
for (var i = 0; i < width * height * 4; i += 4) {
|
|
190
161
|
data[i] = red;
|
|
191
162
|
data[i + 1] = green;
|
|
192
163
|
data[i + 2] = blue;
|
|
193
164
|
data[i + 3] = 255;
|
|
194
165
|
}
|
|
195
|
-
}
|
|
166
|
+
}
|
|
196
167
|
|
|
168
|
+
// update sub-rectangle of the current tile
|
|
197
169
|
}, {
|
|
198
170
|
key: "_subTile",
|
|
199
171
|
value: function _subTile(x, y, w, h, color) {
|
|
@@ -204,7 +176,6 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
204
176
|
var yend = y + h;
|
|
205
177
|
var data = this._tileBuffer;
|
|
206
178
|
var width = this._tileW;
|
|
207
|
-
|
|
208
179
|
for (var j = y; j < yend; j++) {
|
|
209
180
|
for (var i = x; i < xend; i++) {
|
|
210
181
|
var p = (i + j * width) * 4;
|
|
@@ -214,16 +185,15 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
214
185
|
data[p + 3] = 255;
|
|
215
186
|
}
|
|
216
187
|
}
|
|
217
|
-
}
|
|
188
|
+
}
|
|
218
189
|
|
|
190
|
+
// draw the current tile to the screen
|
|
219
191
|
}, {
|
|
220
192
|
key: "_finishTile",
|
|
221
193
|
value: function _finishTile(display) {
|
|
222
194
|
display.blitImage(this._tileX, this._tileY, this._tileW, this._tileH, this._tileBuffer, 0);
|
|
223
195
|
}
|
|
224
196
|
}]);
|
|
225
|
-
|
|
226
197
|
return HextileDecoder;
|
|
227
198
|
}();
|
|
228
|
-
|
|
229
199
|
exports["default"] = HextileDecoder;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
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); }
|
|
8
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
+
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, _toPropertyKey(descriptor.key), descriptor); } }
|
|
10
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
|
+
/*
|
|
14
|
+
* noVNC: HTML5 VNC client
|
|
15
|
+
* Copyright (C) 2019 The noVNC Authors
|
|
16
|
+
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
17
|
+
*
|
|
18
|
+
* See README.md for usage and integration instructions.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
var JPEGDecoder = /*#__PURE__*/function () {
|
|
22
|
+
function JPEGDecoder() {
|
|
23
|
+
_classCallCheck(this, JPEGDecoder);
|
|
24
|
+
// RealVNC will reuse the quantization tables
|
|
25
|
+
// and Huffman tables, so we need to cache them.
|
|
26
|
+
this._quantTables = [];
|
|
27
|
+
this._huffmanTables = [];
|
|
28
|
+
this._cachedQuantTables = [];
|
|
29
|
+
this._cachedHuffmanTables = [];
|
|
30
|
+
this._jpegLength = 0;
|
|
31
|
+
this._segments = [];
|
|
32
|
+
}
|
|
33
|
+
_createClass(JPEGDecoder, [{
|
|
34
|
+
key: "decodeRect",
|
|
35
|
+
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
36
|
+
// A rect of JPEG encodings is simply a JPEG file
|
|
37
|
+
if (!this._parseJPEG(sock.rQslice(0))) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
var data = sock.rQshiftBytes(this._jpegLength);
|
|
41
|
+
if (this._quantTables.length != 0 && this._huffmanTables.length != 0) {
|
|
42
|
+
// If there are quantization tables and Huffman tables in the JPEG
|
|
43
|
+
// image, we can directly render it.
|
|
44
|
+
display.imageRect(x, y, width, height, "image/jpeg", data);
|
|
45
|
+
return true;
|
|
46
|
+
} else {
|
|
47
|
+
// Otherwise we need to insert cached tables.
|
|
48
|
+
var sofIndex = this._segments.findIndex(function (x) {
|
|
49
|
+
return x[1] == 0xC0 || x[1] == 0xC2;
|
|
50
|
+
});
|
|
51
|
+
if (sofIndex == -1) {
|
|
52
|
+
throw new Error("Illegal JPEG image without SOF");
|
|
53
|
+
}
|
|
54
|
+
var segments = this._segments.slice(0, sofIndex);
|
|
55
|
+
segments = segments.concat(this._quantTables.length ? this._quantTables : this._cachedQuantTables);
|
|
56
|
+
segments.push(this._segments[sofIndex]);
|
|
57
|
+
segments = segments.concat(this._huffmanTables.length ? this._huffmanTables : this._cachedHuffmanTables, this._segments.slice(sofIndex + 1));
|
|
58
|
+
var length = 0;
|
|
59
|
+
for (var i = 0; i < segments.length; i++) {
|
|
60
|
+
length += segments[i].length;
|
|
61
|
+
}
|
|
62
|
+
var _data = new Uint8Array(length);
|
|
63
|
+
length = 0;
|
|
64
|
+
for (var _i = 0; _i < segments.length; _i++) {
|
|
65
|
+
_data.set(segments[_i], length);
|
|
66
|
+
length += segments[_i].length;
|
|
67
|
+
}
|
|
68
|
+
display.imageRect(x, y, width, height, "image/jpeg", _data);
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
73
|
+
key: "_parseJPEG",
|
|
74
|
+
value: function _parseJPEG(buffer) {
|
|
75
|
+
if (this._quantTables.length != 0) {
|
|
76
|
+
this._cachedQuantTables = this._quantTables;
|
|
77
|
+
}
|
|
78
|
+
if (this._huffmanTables.length != 0) {
|
|
79
|
+
this._cachedHuffmanTables = this._huffmanTables;
|
|
80
|
+
}
|
|
81
|
+
this._quantTables = [];
|
|
82
|
+
this._huffmanTables = [];
|
|
83
|
+
this._segments = [];
|
|
84
|
+
var i = 0;
|
|
85
|
+
var bufferLength = buffer.length;
|
|
86
|
+
while (true) {
|
|
87
|
+
var j = i;
|
|
88
|
+
if (j + 2 > bufferLength) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
if (buffer[j] != 0xFF) {
|
|
92
|
+
throw new Error("Illegal JPEG marker received (byte: " + buffer[j] + ")");
|
|
93
|
+
}
|
|
94
|
+
var type = buffer[j + 1];
|
|
95
|
+
j += 2;
|
|
96
|
+
if (type == 0xD9) {
|
|
97
|
+
this._jpegLength = j;
|
|
98
|
+
this._segments.push(buffer.slice(i, j));
|
|
99
|
+
return true;
|
|
100
|
+
} else if (type == 0xDA) {
|
|
101
|
+
// start of scan
|
|
102
|
+
var hasFoundEndOfScan = false;
|
|
103
|
+
for (var k = j + 3; k + 1 < bufferLength; k++) {
|
|
104
|
+
if (buffer[k] == 0xFF && buffer[k + 1] != 0x00 && !(buffer[k + 1] >= 0xD0 && buffer[k + 1] <= 0xD7)) {
|
|
105
|
+
j = k;
|
|
106
|
+
hasFoundEndOfScan = true;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (!hasFoundEndOfScan) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
this._segments.push(buffer.slice(i, j));
|
|
114
|
+
i = j;
|
|
115
|
+
continue;
|
|
116
|
+
} else if (type >= 0xD0 && type < 0xD9 || type == 0x01) {
|
|
117
|
+
// No length after marker
|
|
118
|
+
this._segments.push(buffer.slice(i, j));
|
|
119
|
+
i = j;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (j + 2 > bufferLength) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
var length = (buffer[j] << 8) + buffer[j + 1] - 2;
|
|
126
|
+
if (length < 0) {
|
|
127
|
+
throw new Error("Illegal JPEG length received (length: " + length + ")");
|
|
128
|
+
}
|
|
129
|
+
j += 2;
|
|
130
|
+
if (j + length > bufferLength) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
j += length;
|
|
134
|
+
var segment = buffer.slice(i, j);
|
|
135
|
+
if (type == 0xC4) {
|
|
136
|
+
// Huffman tables
|
|
137
|
+
this._huffmanTables.push(segment);
|
|
138
|
+
} else if (type == 0xDB) {
|
|
139
|
+
// Quantization tables
|
|
140
|
+
this._quantTables.push(segment);
|
|
141
|
+
}
|
|
142
|
+
this._segments.push(segment);
|
|
143
|
+
i = j;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}]);
|
|
147
|
+
return JPEGDecoder;
|
|
148
|
+
}();
|
|
149
|
+
exports["default"] = JPEGDecoder;
|
package/lib/decoders/raw.js
CHANGED
|
@@ -4,13 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
7
|
+
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); }
|
|
8
8
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
9
|
+
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, _toPropertyKey(descriptor.key), descriptor); } }
|
|
10
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
14
13
|
/*
|
|
15
14
|
* noVNC: HTML5 VNC client
|
|
16
15
|
* Copyright (C) 2019 The noVNC Authors
|
|
@@ -22,66 +21,54 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
22
21
|
var RawDecoder = /*#__PURE__*/function () {
|
|
23
22
|
function RawDecoder() {
|
|
24
23
|
_classCallCheck(this, RawDecoder);
|
|
25
|
-
|
|
26
24
|
this._lines = 0;
|
|
27
25
|
}
|
|
28
|
-
|
|
29
26
|
_createClass(RawDecoder, [{
|
|
30
27
|
key: "decodeRect",
|
|
31
28
|
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
32
29
|
if (width === 0 || height === 0) {
|
|
33
30
|
return true;
|
|
34
31
|
}
|
|
35
|
-
|
|
36
32
|
if (this._lines === 0) {
|
|
37
33
|
this._lines = height;
|
|
38
34
|
}
|
|
39
|
-
|
|
40
35
|
var pixelSize = depth == 8 ? 1 : 4;
|
|
41
36
|
var bytesPerLine = width * pixelSize;
|
|
42
|
-
|
|
43
37
|
if (sock.rQwait("RAW", bytesPerLine)) {
|
|
44
38
|
return false;
|
|
45
39
|
}
|
|
46
|
-
|
|
47
40
|
var curY = y + (height - this._lines);
|
|
48
41
|
var currHeight = Math.min(this._lines, Math.floor(sock.rQlen / bytesPerLine));
|
|
49
42
|
var pixels = width * currHeight;
|
|
50
43
|
var data = sock.rQ;
|
|
51
|
-
var index = sock.rQi;
|
|
44
|
+
var index = sock.rQi;
|
|
52
45
|
|
|
46
|
+
// Convert data if needed
|
|
53
47
|
if (depth == 8) {
|
|
54
48
|
var newdata = new Uint8Array(pixels * 4);
|
|
55
|
-
|
|
56
49
|
for (var i = 0; i < pixels; i++) {
|
|
57
50
|
newdata[i * 4 + 0] = (data[index + i] >> 0 & 0x3) * 255 / 3;
|
|
58
51
|
newdata[i * 4 + 1] = (data[index + i] >> 2 & 0x3) * 255 / 3;
|
|
59
52
|
newdata[i * 4 + 2] = (data[index + i] >> 4 & 0x3) * 255 / 3;
|
|
60
53
|
newdata[i * 4 + 3] = 255;
|
|
61
54
|
}
|
|
62
|
-
|
|
63
55
|
data = newdata;
|
|
64
56
|
index = 0;
|
|
65
|
-
}
|
|
66
|
-
|
|
57
|
+
}
|
|
67
58
|
|
|
59
|
+
// Max sure the image is fully opaque
|
|
68
60
|
for (var _i = 0; _i < pixels; _i++) {
|
|
69
|
-
data[_i * 4 + 3] = 255;
|
|
61
|
+
data[index + _i * 4 + 3] = 255;
|
|
70
62
|
}
|
|
71
|
-
|
|
72
63
|
display.blitImage(x, curY, width, currHeight, data, index);
|
|
73
64
|
sock.rQskipBytes(currHeight * bytesPerLine);
|
|
74
65
|
this._lines -= currHeight;
|
|
75
|
-
|
|
76
66
|
if (this._lines > 0) {
|
|
77
67
|
return false;
|
|
78
68
|
}
|
|
79
|
-
|
|
80
69
|
return true;
|
|
81
70
|
}
|
|
82
71
|
}]);
|
|
83
|
-
|
|
84
72
|
return RawDecoder;
|
|
85
73
|
}();
|
|
86
|
-
|
|
87
74
|
exports["default"] = RawDecoder;
|