@novnc/novnc 1.2.0 → 1.3.0-g05baf14

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 +5 -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 +10 -12
  27. package/lib/decoders/hextile.js +71 -45
  28. package/lib/decoders/jpeg.js +149 -0
  29. package/lib/decoders/raw.js +18 -22
  30. package/lib/decoders/rre.js +7 -18
  31. package/lib/decoders/tight.js +46 -94
  32. package/lib/decoders/tightpng.js +14 -34
  33. package/lib/decoders/zrle.js +188 -0
  34. package/lib/deflator.js +13 -27
  35. package/lib/des.js +26 -39
  36. package/lib/display.js +103 -316
  37. package/lib/encodings.js +7 -8
  38. package/lib/inflator.js +10 -23
  39. package/lib/input/domkeytable.js +240 -208
  40. package/lib/input/fixedkeys.js +10 -5
  41. package/lib/input/gesturehandler.js +88 -155
  42. package/lib/input/keyboard.js +90 -239
  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 +1035 -0
  49. package/lib/rfb.js +950 -1150
  50. package/lib/util/browser.js +25 -52
  51. package/lib/util/cursor.js +33 -82
  52. package/lib/util/element.js +3 -5
  53. package/lib/util/events.js +26 -35
  54. package/lib/util/eventtarget.js +8 -17
  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 +122 -112
  72. package/package.json +32 -40
  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,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
7
-
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
8
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
-
10
- 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 _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,22 +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();
33
+ if (width === 0 || height === 0) {
34
+ return true;
35
+ }
36
36
  display.copyImage(deltaX, deltaY, x, y, width, height);
37
37
  return true;
38
38
  }
39
39
  }]);
40
-
41
40
  return CopyRectDecoder;
42
41
  }();
43
-
44
- exports.default = CopyRectDecoder;
42
+ exports["default"] = CopyRectDecoder;
@@ -1,32 +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
- exports.default = void 0;
9
-
6
+ exports["default"] = void 0;
10
7
  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
-
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); }
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; }
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 _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
-
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;
21
+ this._tileBuffer = new Uint8Array(16 * 16 * 4);
28
22
  }
29
-
30
23
  _createClass(HextileDecoder, [{
31
24
  key: "decodeRect",
32
25
  value: function decodeRect(x, y, width, height, sock, display, depth) {
@@ -36,31 +29,27 @@ var HextileDecoder = /*#__PURE__*/function () {
36
29
  this._totalTiles = this._tilesX * this._tilesY;
37
30
  this._tiles = this._totalTiles;
38
31
  }
39
-
40
32
  while (this._tiles > 0) {
41
33
  var bytes = 1;
42
-
43
34
  if (sock.rQwait("HEXTILE", bytes)) {
44
35
  return false;
45
36
  }
46
-
47
37
  var rQ = sock.rQ;
48
38
  var rQi = sock.rQi;
49
39
  var subencoding = rQ[rQi]; // Peek
50
-
51
40
  if (subencoding > 30) {
52
41
  // Raw
53
42
  throw new Error("Illegal hextile subencoding (subencoding: " + subencoding + ")");
54
43
  }
55
-
56
44
  var currTile = this._totalTiles - this._tiles;
57
45
  var tileX = currTile % this._tilesX;
58
46
  var tileY = Math.floor(currTile / this._tilesX);
59
47
  var tx = x + tileX * 16;
60
48
  var ty = y + tileY * 16;
61
49
  var tw = Math.min(16, x + width - tx);
62
- var th = Math.min(16, y + height - ty); // Figure out how much we are expecting
50
+ var th = Math.min(16, y + height - ty);
63
51
 
52
+ // Figure out how much we are expecting
64
53
  if (subencoding & 0x01) {
65
54
  // Raw
66
55
  bytes += tw * th * 4;
@@ -69,12 +58,10 @@ var HextileDecoder = /*#__PURE__*/function () {
69
58
  // Background
70
59
  bytes += 4;
71
60
  }
72
-
73
61
  if (subencoding & 0x04) {
74
62
  // Foreground
75
63
  bytes += 4;
76
64
  }
77
-
78
65
  if (subencoding & 0x08) {
79
66
  // AnySubrects
80
67
  bytes++; // Since we aren't shifting it off
@@ -82,9 +69,7 @@ var HextileDecoder = /*#__PURE__*/function () {
82
69
  if (sock.rQwait("HEXTILE", bytes)) {
83
70
  return false;
84
71
  }
85
-
86
72
  var subrects = rQ[rQi + bytes - 1]; // Peek
87
-
88
73
  if (subencoding & 0x10) {
89
74
  // SubrectsColoured
90
75
  bytes += subrects * (4 + 2);
@@ -93,14 +78,12 @@ var HextileDecoder = /*#__PURE__*/function () {
93
78
  }
94
79
  }
95
80
  }
96
-
97
81
  if (sock.rQwait("HEXTILE", bytes)) {
98
82
  return false;
99
- } // We know the encoding and have a whole tile
100
-
83
+ }
101
84
 
85
+ // We know the encoding and have a whole tile
102
86
  rQi++;
103
-
104
87
  if (subencoding === 0) {
105
88
  if (this._lastsubencoding & 0x01) {
106
89
  // Weird: ignore blanks are RAW
@@ -110,6 +93,11 @@ var HextileDecoder = /*#__PURE__*/function () {
110
93
  }
111
94
  } else if (subencoding & 0x01) {
112
95
  // Raw
96
+ var pixels = tw * th;
97
+ // Max sure the image is fully opaque
98
+ for (var i = 0; i < pixels; i++) {
99
+ rQ[rQi + i * 4 + 3] = 255;
100
+ }
113
101
  display.blitImage(tx, ty, tw, th, rQ, rQi);
114
102
  rQi += bytes - 1;
115
103
  } else {
@@ -118,23 +106,18 @@ var HextileDecoder = /*#__PURE__*/function () {
118
106
  this._background = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
119
107
  rQi += 4;
120
108
  }
121
-
122
109
  if (subencoding & 0x04) {
123
110
  // Foreground
124
111
  this._foreground = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
125
112
  rQi += 4;
126
113
  }
127
-
128
- display.startTile(tx, ty, tw, th, this._background);
129
-
114
+ this._startTile(tx, ty, tw, th, this._background);
130
115
  if (subencoding & 0x08) {
131
116
  // AnySubrects
132
117
  var _subrects = rQ[rQi];
133
118
  rQi++;
134
-
135
119
  for (var s = 0; s < _subrects; s++) {
136
120
  var color = void 0;
137
-
138
121
  if (subencoding & 0x10) {
139
122
  // SubrectsColoured
140
123
  color = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
@@ -142,7 +125,6 @@ var HextileDecoder = /*#__PURE__*/function () {
142
125
  } else {
143
126
  color = this._foreground;
144
127
  }
145
-
146
128
  var xy = rQ[rQi];
147
129
  rQi++;
148
130
  var sx = xy >> 4;
@@ -151,23 +133,67 @@ var HextileDecoder = /*#__PURE__*/function () {
151
133
  rQi++;
152
134
  var sw = (wh >> 4) + 1;
153
135
  var sh = (wh & 0x0f) + 1;
154
- display.subTile(sx, sy, sw, sh, color);
136
+ this._subTile(sx, sy, sw, sh, color);
155
137
  }
156
138
  }
157
-
158
- display.finishTile();
139
+ this._finishTile(display);
159
140
  }
160
-
161
141
  sock.rQi = rQi;
162
142
  this._lastsubencoding = subencoding;
163
143
  this._tiles--;
164
144
  }
165
-
166
145
  return true;
167
146
  }
168
- }]);
169
147
 
148
+ // start updating a tile
149
+ }, {
150
+ key: "_startTile",
151
+ value: function _startTile(x, y, width, height, color) {
152
+ this._tileX = x;
153
+ this._tileY = y;
154
+ this._tileW = width;
155
+ this._tileH = height;
156
+ var red = color[0];
157
+ var green = color[1];
158
+ var blue = color[2];
159
+ var data = this._tileBuffer;
160
+ for (var i = 0; i < width * height * 4; i += 4) {
161
+ data[i] = red;
162
+ data[i + 1] = green;
163
+ data[i + 2] = blue;
164
+ data[i + 3] = 255;
165
+ }
166
+ }
167
+
168
+ // update sub-rectangle of the current tile
169
+ }, {
170
+ key: "_subTile",
171
+ value: function _subTile(x, y, w, h, color) {
172
+ var red = color[0];
173
+ var green = color[1];
174
+ var blue = color[2];
175
+ var xend = x + w;
176
+ var yend = y + h;
177
+ var data = this._tileBuffer;
178
+ var width = this._tileW;
179
+ for (var j = y; j < yend; j++) {
180
+ for (var i = x; i < xend; i++) {
181
+ var p = (i + j * width) * 4;
182
+ data[p] = red;
183
+ data[p + 1] = green;
184
+ data[p + 2] = blue;
185
+ data[p + 3] = 255;
186
+ }
187
+ }
188
+ }
189
+
190
+ // draw the current tile to the screen
191
+ }, {
192
+ key: "_finishTile",
193
+ value: function _finishTile(display) {
194
+ display.blitImage(this._tileX, this._tileY, this._tileW, this._tileH, this._tileBuffer, 0);
195
+ }
196
+ }]);
170
197
  return HextileDecoder;
171
198
  }();
172
-
173
- exports.default = HextileDecoder;
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;
@@ -3,14 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
7
-
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
8
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
-
10
- 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 _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,57 +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) {
29
+ if (width === 0 || height === 0) {
30
+ return true;
31
+ }
32
32
  if (this._lines === 0) {
33
33
  this._lines = height;
34
34
  }
35
-
36
35
  var pixelSize = depth == 8 ? 1 : 4;
37
36
  var bytesPerLine = width * pixelSize;
38
-
39
37
  if (sock.rQwait("RAW", bytesPerLine)) {
40
38
  return false;
41
39
  }
42
-
43
40
  var curY = y + (height - this._lines);
44
41
  var currHeight = Math.min(this._lines, Math.floor(sock.rQlen / bytesPerLine));
42
+ var pixels = width * currHeight;
45
43
  var data = sock.rQ;
46
- var index = sock.rQi; // Convert data if needed
44
+ var index = sock.rQi;
47
45
 
46
+ // Convert data if needed
48
47
  if (depth == 8) {
49
- var pixels = width * currHeight;
50
48
  var newdata = new Uint8Array(pixels * 4);
51
-
52
49
  for (var i = 0; i < pixels; i++) {
53
50
  newdata[i * 4 + 0] = (data[index + i] >> 0 & 0x3) * 255 / 3;
54
51
  newdata[i * 4 + 1] = (data[index + i] >> 2 & 0x3) * 255 / 3;
55
52
  newdata[i * 4 + 2] = (data[index + i] >> 4 & 0x3) * 255 / 3;
56
- newdata[i * 4 + 4] = 0;
53
+ newdata[i * 4 + 3] = 255;
57
54
  }
58
-
59
55
  data = newdata;
60
56
  index = 0;
61
57
  }
62
58
 
59
+ // Max sure the image is fully opaque
60
+ for (var _i = 0; _i < pixels; _i++) {
61
+ data[index + _i * 4 + 3] = 255;
62
+ }
63
63
  display.blitImage(x, curY, width, currHeight, data, index);
64
64
  sock.rQskipBytes(currHeight * bytesPerLine);
65
65
  this._lines -= currHeight;
66
-
67
66
  if (this._lines > 0) {
68
67
  return false;
69
68
  }
70
-
71
69
  return true;
72
70
  }
73
71
  }]);
74
-
75
72
  return RawDecoder;
76
73
  }();
77
-
78
- exports.default = RawDecoder;
74
+ exports["default"] = RawDecoder;
@@ -3,14 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
7
-
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
8
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
-
10
- 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 _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,10 +21,8 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
22
21
  var RREDecoder = /*#__PURE__*/function () {
23
22
  function RREDecoder() {
24
23
  _classCallCheck(this, RREDecoder);
25
-
26
24
  this._subrects = 0;
27
25
  }
28
-
29
26
  _createClass(RREDecoder, [{
30
27
  key: "decodeRect",
31
28
  value: function decodeRect(x, y, width, height, sock, display, depth) {
@@ -33,20 +30,15 @@ var RREDecoder = /*#__PURE__*/function () {
33
30
  if (sock.rQwait("RRE", 4 + 4)) {
34
31
  return false;
35
32
  }
36
-
37
33
  this._subrects = sock.rQshift32();
38
34
  var color = sock.rQshiftBytes(4); // Background
39
-
40
35
  display.fillRect(x, y, width, height, color);
41
36
  }
42
-
43
37
  while (this._subrects > 0) {
44
38
  if (sock.rQwait("RRE", 4 + 8)) {
45
39
  return false;
46
40
  }
47
-
48
41
  var _color = sock.rQshiftBytes(4);
49
-
50
42
  var sx = sock.rQshift16();
51
43
  var sy = sock.rQshift16();
52
44
  var swidth = sock.rQshift16();
@@ -54,12 +46,9 @@ var RREDecoder = /*#__PURE__*/function () {
54
46
  display.fillRect(x + sx, y + sy, swidth, sheight, _color);
55
47
  this._subrects--;
56
48
  }
57
-
58
49
  return true;
59
50
  }
60
51
  }]);
61
-
62
52
  return RREDecoder;
63
53
  }();
64
-
65
- exports.default = RREDecoder;
54
+ exports["default"] = RREDecoder;