@novnc/novnc 1.0.0 → 1.2.0

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 (87) hide show
  1. package/AUTHORS +13 -0
  2. package/LICENSE.txt +2 -1
  3. package/README.md +69 -3
  4. package/core/base64.js +35 -41
  5. package/core/decoders/copyrect.js +22 -0
  6. package/core/decoders/hextile.js +137 -0
  7. package/core/decoders/raw.js +56 -0
  8. package/core/decoders/rre.js +44 -0
  9. package/core/decoders/tight.js +315 -0
  10. package/core/decoders/tightpng.js +27 -0
  11. package/core/deflator.js +85 -0
  12. package/core/des.js +90 -95
  13. package/core/display.js +254 -297
  14. package/core/encodings.js +7 -3
  15. package/core/inflator.js +48 -20
  16. package/core/input/domkeytable.js +21 -24
  17. package/core/input/fixedkeys.js +3 -1
  18. package/core/input/gesturehandler.js +567 -0
  19. package/core/input/keyboard.js +194 -120
  20. package/core/input/keysym.js +2 -0
  21. package/core/input/keysymdef.js +3 -3
  22. package/core/input/util.js +53 -12
  23. package/core/input/vkeys.js +2 -1
  24. package/core/rfb.js +1937 -1496
  25. package/core/util/browser.js +80 -29
  26. package/core/util/cursor.js +253 -0
  27. package/core/util/element.js +32 -0
  28. package/core/util/events.js +59 -55
  29. package/core/util/eventtarget.js +25 -30
  30. package/core/util/int.js +15 -0
  31. package/core/util/logging.js +21 -16
  32. package/core/util/polyfill.js +15 -8
  33. package/core/util/strings.js +21 -8
  34. package/core/websock.js +145 -167
  35. package/docs/API.md +31 -10
  36. package/lib/base64.js +115 -0
  37. package/lib/decoders/copyrect.js +44 -0
  38. package/lib/decoders/hextile.js +173 -0
  39. package/lib/decoders/raw.js +78 -0
  40. package/lib/decoders/rre.js +65 -0
  41. package/lib/decoders/tight.js +350 -0
  42. package/lib/decoders/tightpng.js +67 -0
  43. package/lib/deflator.js +99 -0
  44. package/lib/des.js +314 -0
  45. package/lib/display.js +733 -0
  46. package/lib/encodings.js +64 -0
  47. package/lib/inflator.js +87 -0
  48. package/lib/input/domkeytable.js +282 -0
  49. package/lib/input/fixedkeys.js +123 -0
  50. package/lib/input/gesturehandler.js +642 -0
  51. package/lib/input/keyboard.js +429 -0
  52. package/lib/input/keysym.js +1135 -0
  53. package/lib/input/keysymdef.js +1354 -0
  54. package/lib/input/util.js +304 -0
  55. package/lib/input/vkeys.js +127 -0
  56. package/lib/input/xtscancodes.js +505 -0
  57. package/lib/rfb.js +3448 -0
  58. package/lib/util/browser.js +131 -0
  59. package/lib/util/cursor.js +314 -0
  60. package/lib/util/element.js +43 -0
  61. package/lib/util/events.js +142 -0
  62. package/lib/util/eventtarget.js +64 -0
  63. package/lib/util/int.js +22 -0
  64. package/lib/util/logging.js +79 -0
  65. package/lib/util/polyfill.js +72 -0
  66. package/lib/util/strings.js +38 -0
  67. package/lib/vendor/pako/lib/utils/common.js +67 -0
  68. package/lib/vendor/pako/lib/zlib/adler32.js +33 -0
  69. package/lib/vendor/pako/lib/zlib/constants.js +51 -0
  70. package/lib/vendor/pako/lib/zlib/crc32.js +42 -0
  71. package/lib/vendor/pako/lib/zlib/deflate.js +2159 -0
  72. package/lib/vendor/pako/lib/zlib/gzheader.js +53 -0
  73. package/lib/vendor/pako/lib/zlib/inffast.js +445 -0
  74. package/lib/vendor/pako/lib/zlib/inflate.js +2114 -0
  75. package/lib/vendor/pako/lib/zlib/inftrees.js +418 -0
  76. package/lib/vendor/pako/lib/zlib/messages.js +36 -0
  77. package/lib/vendor/pako/lib/zlib/trees.js +1499 -0
  78. package/lib/vendor/pako/lib/zlib/zstream.js +46 -0
  79. package/lib/vendor/promise.js +255 -0
  80. package/lib/websock.js +374 -0
  81. package/package.json +48 -28
  82. package/vendor/pako/lib/zlib/deflate.js +30 -30
  83. package/vendor/pako/lib/zlib/inflate.js +17 -17
  84. package/core/input/mouse.js +0 -280
  85. package/docs/API-internal.md +0 -125
  86. package/docs/EMBEDDING.md +0 -83
  87. package/docs/VERSION +0 -1
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
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
+
14
+ /*
15
+ * noVNC: HTML5 VNC client
16
+ * Copyright (C) 2019 The noVNC Authors
17
+ * Licensed under MPL 2.0 (see LICENSE.txt)
18
+ *
19
+ * See README.md for usage and integration instructions.
20
+ *
21
+ */
22
+ var CopyRectDecoder = /*#__PURE__*/function () {
23
+ function CopyRectDecoder() {
24
+ _classCallCheck(this, CopyRectDecoder);
25
+ }
26
+
27
+ _createClass(CopyRectDecoder, [{
28
+ key: "decodeRect",
29
+ value: function decodeRect(x, y, width, height, sock, display, depth) {
30
+ if (sock.rQwait("COPYRECT", 4)) {
31
+ return false;
32
+ }
33
+
34
+ var deltaX = sock.rQshift16();
35
+ var deltaY = sock.rQshift16();
36
+ display.copyImage(deltaX, deltaY, x, y, width, height);
37
+ return true;
38
+ }
39
+ }]);
40
+
41
+ return CopyRectDecoder;
42
+ }();
43
+
44
+ exports.default = CopyRectDecoder;
@@ -0,0 +1,173 @@
1
+ "use strict";
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
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ 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
+
16
+ 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
+
22
+ var HextileDecoder = /*#__PURE__*/function () {
23
+ function HextileDecoder() {
24
+ _classCallCheck(this, HextileDecoder);
25
+
26
+ this._tiles = 0;
27
+ this._lastsubencoding = 0;
28
+ }
29
+
30
+ _createClass(HextileDecoder, [{
31
+ key: "decodeRect",
32
+ value: function decodeRect(x, y, width, height, sock, display, depth) {
33
+ if (this._tiles === 0) {
34
+ this._tilesX = Math.ceil(width / 16);
35
+ this._tilesY = Math.ceil(height / 16);
36
+ this._totalTiles = this._tilesX * this._tilesY;
37
+ this._tiles = this._totalTiles;
38
+ }
39
+
40
+ while (this._tiles > 0) {
41
+ var bytes = 1;
42
+
43
+ if (sock.rQwait("HEXTILE", bytes)) {
44
+ return false;
45
+ }
46
+
47
+ var rQ = sock.rQ;
48
+ var rQi = sock.rQi;
49
+ var subencoding = rQ[rQi]; // Peek
50
+
51
+ if (subencoding > 30) {
52
+ // Raw
53
+ throw new Error("Illegal hextile subencoding (subencoding: " + subencoding + ")");
54
+ }
55
+
56
+ var currTile = this._totalTiles - this._tiles;
57
+ var tileX = currTile % this._tilesX;
58
+ var tileY = Math.floor(currTile / this._tilesX);
59
+ var tx = x + tileX * 16;
60
+ var ty = y + tileY * 16;
61
+ var tw = Math.min(16, x + width - tx);
62
+ var th = Math.min(16, y + height - ty); // Figure out how much we are expecting
63
+
64
+ if (subencoding & 0x01) {
65
+ // Raw
66
+ bytes += tw * th * 4;
67
+ } else {
68
+ if (subencoding & 0x02) {
69
+ // Background
70
+ bytes += 4;
71
+ }
72
+
73
+ if (subencoding & 0x04) {
74
+ // Foreground
75
+ bytes += 4;
76
+ }
77
+
78
+ if (subencoding & 0x08) {
79
+ // AnySubrects
80
+ bytes++; // Since we aren't shifting it off
81
+
82
+ if (sock.rQwait("HEXTILE", bytes)) {
83
+ return false;
84
+ }
85
+
86
+ var subrects = rQ[rQi + bytes - 1]; // Peek
87
+
88
+ if (subencoding & 0x10) {
89
+ // SubrectsColoured
90
+ bytes += subrects * (4 + 2);
91
+ } else {
92
+ bytes += subrects * 2;
93
+ }
94
+ }
95
+ }
96
+
97
+ if (sock.rQwait("HEXTILE", bytes)) {
98
+ return false;
99
+ } // We know the encoding and have a whole tile
100
+
101
+
102
+ rQi++;
103
+
104
+ if (subencoding === 0) {
105
+ if (this._lastsubencoding & 0x01) {
106
+ // Weird: ignore blanks are RAW
107
+ Log.Debug(" Ignoring blank after RAW");
108
+ } else {
109
+ display.fillRect(tx, ty, tw, th, this._background);
110
+ }
111
+ } else if (subencoding & 0x01) {
112
+ // Raw
113
+ display.blitImage(tx, ty, tw, th, rQ, rQi);
114
+ rQi += bytes - 1;
115
+ } else {
116
+ if (subencoding & 0x02) {
117
+ // Background
118
+ this._background = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
119
+ rQi += 4;
120
+ }
121
+
122
+ if (subencoding & 0x04) {
123
+ // Foreground
124
+ this._foreground = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
125
+ rQi += 4;
126
+ }
127
+
128
+ display.startTile(tx, ty, tw, th, this._background);
129
+
130
+ if (subencoding & 0x08) {
131
+ // AnySubrects
132
+ var _subrects = rQ[rQi];
133
+ rQi++;
134
+
135
+ for (var s = 0; s < _subrects; s++) {
136
+ var color = void 0;
137
+
138
+ if (subencoding & 0x10) {
139
+ // SubrectsColoured
140
+ color = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
141
+ rQi += 4;
142
+ } else {
143
+ color = this._foreground;
144
+ }
145
+
146
+ var xy = rQ[rQi];
147
+ rQi++;
148
+ var sx = xy >> 4;
149
+ var sy = xy & 0x0f;
150
+ var wh = rQ[rQi];
151
+ rQi++;
152
+ var sw = (wh >> 4) + 1;
153
+ var sh = (wh & 0x0f) + 1;
154
+ display.subTile(sx, sy, sw, sh, color);
155
+ }
156
+ }
157
+
158
+ display.finishTile();
159
+ }
160
+
161
+ sock.rQi = rQi;
162
+ this._lastsubencoding = subencoding;
163
+ this._tiles--;
164
+ }
165
+
166
+ return true;
167
+ }
168
+ }]);
169
+
170
+ return HextileDecoder;
171
+ }();
172
+
173
+ exports.default = HextileDecoder;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
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
+
14
+ /*
15
+ * noVNC: HTML5 VNC client
16
+ * Copyright (C) 2019 The noVNC Authors
17
+ * Licensed under MPL 2.0 (see LICENSE.txt)
18
+ *
19
+ * See README.md for usage and integration instructions.
20
+ *
21
+ */
22
+ var RawDecoder = /*#__PURE__*/function () {
23
+ function RawDecoder() {
24
+ _classCallCheck(this, RawDecoder);
25
+
26
+ this._lines = 0;
27
+ }
28
+
29
+ _createClass(RawDecoder, [{
30
+ key: "decodeRect",
31
+ value: function decodeRect(x, y, width, height, sock, display, depth) {
32
+ if (this._lines === 0) {
33
+ this._lines = height;
34
+ }
35
+
36
+ var pixelSize = depth == 8 ? 1 : 4;
37
+ var bytesPerLine = width * pixelSize;
38
+
39
+ if (sock.rQwait("RAW", bytesPerLine)) {
40
+ return false;
41
+ }
42
+
43
+ var curY = y + (height - this._lines);
44
+ var currHeight = Math.min(this._lines, Math.floor(sock.rQlen / bytesPerLine));
45
+ var data = sock.rQ;
46
+ var index = sock.rQi; // Convert data if needed
47
+
48
+ if (depth == 8) {
49
+ var pixels = width * currHeight;
50
+ var newdata = new Uint8Array(pixels * 4);
51
+
52
+ for (var i = 0; i < pixels; i++) {
53
+ newdata[i * 4 + 0] = (data[index + i] >> 0 & 0x3) * 255 / 3;
54
+ newdata[i * 4 + 1] = (data[index + i] >> 2 & 0x3) * 255 / 3;
55
+ newdata[i * 4 + 2] = (data[index + i] >> 4 & 0x3) * 255 / 3;
56
+ newdata[i * 4 + 4] = 0;
57
+ }
58
+
59
+ data = newdata;
60
+ index = 0;
61
+ }
62
+
63
+ display.blitImage(x, curY, width, currHeight, data, index);
64
+ sock.rQskipBytes(currHeight * bytesPerLine);
65
+ this._lines -= currHeight;
66
+
67
+ if (this._lines > 0) {
68
+ return false;
69
+ }
70
+
71
+ return true;
72
+ }
73
+ }]);
74
+
75
+ return RawDecoder;
76
+ }();
77
+
78
+ exports.default = RawDecoder;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
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
+
14
+ /*
15
+ * noVNC: HTML5 VNC client
16
+ * Copyright (C) 2019 The noVNC Authors
17
+ * Licensed under MPL 2.0 (see LICENSE.txt)
18
+ *
19
+ * See README.md for usage and integration instructions.
20
+ *
21
+ */
22
+ var RREDecoder = /*#__PURE__*/function () {
23
+ function RREDecoder() {
24
+ _classCallCheck(this, RREDecoder);
25
+
26
+ this._subrects = 0;
27
+ }
28
+
29
+ _createClass(RREDecoder, [{
30
+ key: "decodeRect",
31
+ value: function decodeRect(x, y, width, height, sock, display, depth) {
32
+ if (this._subrects === 0) {
33
+ if (sock.rQwait("RRE", 4 + 4)) {
34
+ return false;
35
+ }
36
+
37
+ this._subrects = sock.rQshift32();
38
+ var color = sock.rQshiftBytes(4); // Background
39
+
40
+ display.fillRect(x, y, width, height, color);
41
+ }
42
+
43
+ while (this._subrects > 0) {
44
+ if (sock.rQwait("RRE", 4 + 8)) {
45
+ return false;
46
+ }
47
+
48
+ var _color = sock.rQshiftBytes(4);
49
+
50
+ var sx = sock.rQshift16();
51
+ var sy = sock.rQshift16();
52
+ var swidth = sock.rQshift16();
53
+ var sheight = sock.rQshift16();
54
+ display.fillRect(x + sx, y + sy, swidth, sheight, _color);
55
+ this._subrects--;
56
+ }
57
+
58
+ return true;
59
+ }
60
+ }]);
61
+
62
+ return RREDecoder;
63
+ }();
64
+
65
+ exports.default = RREDecoder;