@novnc/novnc 1.2.0 → 1.3.0-g0ef7582

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