@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,44 +3,28 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = ZStream;
7
-
6
+ exports["default"] = ZStream;
8
7
  function ZStream() {
9
8
  /* next input byte */
10
9
  this.input = null; // JS specific, because we have no pointers
11
-
12
10
  this.next_in = 0;
13
11
  /* number of bytes available at input */
14
-
15
12
  this.avail_in = 0;
16
13
  /* total number of input bytes read so far */
17
-
18
14
  this.total_in = 0;
19
15
  /* next output byte should be put there */
20
-
21
16
  this.output = null; // JS specific, because we have no pointers
22
-
23
17
  this.next_out = 0;
24
18
  /* remaining free space at output */
25
-
26
19
  this.avail_out = 0;
27
20
  /* total number of bytes output so far */
28
-
29
21
  this.total_out = 0;
30
22
  /* last error message, NULL if no error */
31
-
32
- this.msg = ''
33
- /*Z_NULL*/
34
- ;
23
+ this.msg = '' /*Z_NULL*/;
35
24
  /* not visible by applications */
36
-
37
25
  this.state = null;
38
26
  /* best guess about the data type: binary or text */
39
-
40
- this.data_type = 2
41
- /*Z_UNKNOWN*/
42
- ;
27
+ this.data_type = 2 /*Z_UNKNOWN*/;
43
28
  /* adler32 value of the uncompressed data */
44
-
45
29
  this.adler = 0;
46
30
  }
package/lib/websock.js CHANGED
@@ -1,50 +1,57 @@
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; }
11
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
15
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
16
17
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
-
18
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
-
19
+ 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
20
  // this has performance issues in some versions Chromium, and
23
21
  // doesn't gain a tremendous amount of performance increase in Firefox
24
22
  // at the moment. It may be valuable to turn it on in the future.
25
- // Also copyWithin() for TypedArrays is not supported in IE 11 or
26
- // Safari 13 (at the moment we want to support Safari 11).
27
- var ENABLE_COPYWITHIN = false;
28
23
  var MAX_RQ_GROW_SIZE = 40 * 1024 * 1024; // 40 MiB
29
24
 
25
+ // Constants pulled from RTCDataChannelState enum
26
+ // https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/readyState#RTCDataChannelState_enum
27
+ var DataChannel = {
28
+ CONNECTING: "connecting",
29
+ OPEN: "open",
30
+ CLOSING: "closing",
31
+ CLOSED: "closed"
32
+ };
33
+ var ReadyStates = {
34
+ CONNECTING: [WebSocket.CONNECTING, DataChannel.CONNECTING],
35
+ OPEN: [WebSocket.OPEN, DataChannel.OPEN],
36
+ CLOSING: [WebSocket.CLOSING, DataChannel.CLOSING],
37
+ CLOSED: [WebSocket.CLOSED, DataChannel.CLOSED]
38
+ };
39
+
40
+ // Properties a raw channel must have, WebSocket and RTCDataChannel are two examples
41
+ var rawChannelProps = ["send", "close", "binaryType", "onerror", "onmessage", "onopen", "protocol", "readyState"];
30
42
  var Websock = /*#__PURE__*/function () {
31
43
  function Websock() {
32
44
  _classCallCheck(this, Websock);
33
-
34
- this._websocket = null; // WebSocket object
45
+ this._websocket = null; // WebSocket or RTCDataChannel object
35
46
 
36
47
  this._rQi = 0; // Receive queue index
37
-
38
48
  this._rQlen = 0; // Next write position in the receive queue
39
-
40
49
  this._rQbufferSize = 1024 * 1024 * 4; // Receive queue buffer size (4 MiB)
41
50
  // called in init: this._rQ = new Uint8Array(this._rQbufferSize);
42
-
43
51
  this._rQ = null; // Receive queue
44
52
 
45
53
  this._sQbufferSize = 1024 * 10; // 10 KiB
46
54
  // called in init: this._sQ = new Uint8Array(this._sQbufferSize);
47
-
48
55
  this._sQlen = 0;
49
56
  this._sQ = null; // Send queue
50
57
 
@@ -54,10 +61,54 @@ var Websock = /*#__PURE__*/function () {
54
61
  close: function close() {},
55
62
  error: function error() {}
56
63
  };
57
- } // Getters and Setters
58
-
64
+ }
59
65
 
66
+ // Getters and Setters
60
67
  _createClass(Websock, [{
68
+ key: "readyState",
69
+ get: function get() {
70
+ var subState;
71
+ if (this._websocket === null) {
72
+ return "unused";
73
+ }
74
+ subState = this._websocket.readyState;
75
+ if (ReadyStates.CONNECTING.includes(subState)) {
76
+ return "connecting";
77
+ } else if (ReadyStates.OPEN.includes(subState)) {
78
+ return "open";
79
+ } else if (ReadyStates.CLOSING.includes(subState)) {
80
+ return "closing";
81
+ } else if (ReadyStates.CLOSED.includes(subState)) {
82
+ return "closed";
83
+ }
84
+ return "unknown";
85
+ }
86
+ }, {
87
+ key: "sQ",
88
+ get: function get() {
89
+ return this._sQ;
90
+ }
91
+ }, {
92
+ key: "rQ",
93
+ get: function get() {
94
+ return this._rQ;
95
+ }
96
+ }, {
97
+ key: "rQi",
98
+ get: function get() {
99
+ return this._rQi;
100
+ },
101
+ set: function set(val) {
102
+ this._rQi = val;
103
+ }
104
+
105
+ // Receive Queue
106
+ }, {
107
+ key: "rQlen",
108
+ get: function get() {
109
+ return this._rQlen - this._rQi;
110
+ }
111
+ }, {
61
112
  key: "rQpeek8",
62
113
  value: function rQpeek8() {
63
114
  return this._rQ[this._rQi];
@@ -81,17 +132,16 @@ var Websock = /*#__PURE__*/function () {
81
132
  key: "rQshift32",
82
133
  value: function rQshift32() {
83
134
  return this._rQshift(4);
84
- } // TODO(directxman12): test performance with these vs a DataView
135
+ }
85
136
 
137
+ // TODO(directxman12): test performance with these vs a DataView
86
138
  }, {
87
139
  key: "_rQshift",
88
140
  value: function _rQshift(bytes) {
89
141
  var res = 0;
90
-
91
- for (var byte = bytes - 1; byte >= 0; byte--) {
92
- res += this._rQ[this._rQi++] << byte * 8;
142
+ for (var _byte = bytes - 1; _byte >= 0; _byte--) {
143
+ res += this._rQ[this._rQi++] << _byte * 8;
93
144
  }
94
-
95
145
  return res;
96
146
  }
97
147
  }, {
@@ -100,14 +150,12 @@ var Websock = /*#__PURE__*/function () {
100
150
  if (typeof len === 'undefined') {
101
151
  len = this.rQlen;
102
152
  }
103
-
104
- var str = ""; // Handle large arrays in steps to avoid long strings on the stack
105
-
153
+ var str = "";
154
+ // Handle large arrays in steps to avoid long strings on the stack
106
155
  for (var i = 0; i < len; i += 4096) {
107
156
  var part = this.rQshiftBytes(Math.min(4096, len - i));
108
157
  str += String.fromCharCode.apply(null, part);
109
158
  }
110
-
111
159
  return str;
112
160
  }
113
161
  }, {
@@ -116,7 +164,6 @@ var Websock = /*#__PURE__*/function () {
116
164
  if (typeof len === 'undefined') {
117
165
  len = this.rQlen;
118
166
  }
119
-
120
167
  this._rQi += len;
121
168
  return new Uint8Array(this._rQ.buffer, this._rQi - len, len);
122
169
  }
@@ -125,9 +172,8 @@ var Websock = /*#__PURE__*/function () {
125
172
  value: function rQshiftTo(target, len) {
126
173
  if (len === undefined) {
127
174
  len = this.rQlen;
128
- } // TODO: make this just use set with views when using a ArrayBuffer to store the rQ
129
-
130
-
175
+ }
176
+ // TODO: make this just use set with views when using a ArrayBuffer to store the rQ
131
177
  target.set(new Uint8Array(this._rQ.buffer, this._rQi, len));
132
178
  this._rQi += len;
133
179
  }
@@ -136,10 +182,11 @@ var Websock = /*#__PURE__*/function () {
136
182
  value: function rQslice(start) {
137
183
  var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.rQlen;
138
184
  return new Uint8Array(this._rQ.buffer, this._rQi + start, end - start);
139
- } // Check to see if we must wait for 'num' bytes (default to FBU.bytes)
185
+ }
186
+
187
+ // Check to see if we must wait for 'num' bytes (default to FBU.bytes)
140
188
  // to be available in the receive queue. Return true if we need to
141
189
  // wait (and possibly print a debug message), otherwise false.
142
-
143
190
  }, {
144
191
  key: "rQwait",
145
192
  value: function rQwait(msg, num, goback) {
@@ -148,22 +195,20 @@ var Websock = /*#__PURE__*/function () {
148
195
  if (this._rQi < goback) {
149
196
  throw new Error("rQwait cannot backup " + goback + " bytes");
150
197
  }
151
-
152
198
  this._rQi -= goback;
153
199
  }
154
-
155
200
  return true; // true means need more data
156
201
  }
157
202
 
158
203
  return false;
159
- } // Send Queue
204
+ }
160
205
 
206
+ // Send Queue
161
207
  }, {
162
208
  key: "flush",
163
209
  value: function flush() {
164
- if (this._sQlen > 0 && this._websocket.readyState === WebSocket.OPEN) {
210
+ if (this._sQlen > 0 && this.readyState === 'open') {
165
211
  this._websocket.send(this._encodeMessage());
166
-
167
212
  this._sQlen = 0;
168
213
  }
169
214
  }
@@ -171,7 +216,6 @@ var Websock = /*#__PURE__*/function () {
171
216
  key: "send",
172
217
  value: function send(arr) {
173
218
  this._sQ.set(arr, this._sQlen);
174
-
175
219
  this._sQlen += arr.length;
176
220
  this.flush();
177
221
  }
@@ -181,8 +225,9 @@ var Websock = /*#__PURE__*/function () {
181
225
  this.send(str.split('').map(function (chr) {
182
226
  return chr.charCodeAt(0);
183
227
  }));
184
- } // Event Handlers
228
+ }
185
229
 
230
+ // Event Handlers
186
231
  }, {
187
232
  key: "off",
188
233
  value: function off(evt) {
@@ -203,45 +248,47 @@ var Websock = /*#__PURE__*/function () {
203
248
  key: "init",
204
249
  value: function init() {
205
250
  this._allocateBuffers();
206
-
207
251
  this._rQi = 0;
208
252
  this._websocket = null;
209
253
  }
210
254
  }, {
211
255
  key: "open",
212
256
  value: function open(uri, protocols) {
257
+ this.attach(new WebSocket(uri, protocols));
258
+ }
259
+ }, {
260
+ key: "attach",
261
+ value: function attach(rawChannel) {
213
262
  var _this = this;
214
-
215
263
  this.init();
216
- this._websocket = new WebSocket(uri, protocols);
217
- this._websocket.binaryType = 'arraybuffer';
218
- this._websocket.onmessage = this._recvMessage.bind(this);
219
264
 
265
+ // Must get object and class methods to be compatible with the tests.
266
+ var channelProps = [].concat(_toConsumableArray(Object.keys(rawChannel)), _toConsumableArray(Object.getOwnPropertyNames(Object.getPrototypeOf(rawChannel))));
267
+ for (var i = 0; i < rawChannelProps.length; i++) {
268
+ var prop = rawChannelProps[i];
269
+ if (channelProps.indexOf(prop) < 0) {
270
+ throw new Error('Raw channel missing property: ' + prop);
271
+ }
272
+ }
273
+ this._websocket = rawChannel;
274
+ this._websocket.binaryType = "arraybuffer";
275
+ this._websocket.onmessage = this._recvMessage.bind(this);
220
276
  this._websocket.onopen = function () {
221
277
  Log.Debug('>> WebSock.onopen');
222
-
223
278
  if (_this._websocket.protocol) {
224
279
  Log.Info("Server choose sub-protocol: " + _this._websocket.protocol);
225
280
  }
226
-
227
281
  _this._eventHandlers.open();
228
-
229
282
  Log.Debug("<< WebSock.onopen");
230
283
  };
231
-
232
284
  this._websocket.onclose = function (e) {
233
285
  Log.Debug(">> WebSock.onclose");
234
-
235
286
  _this._eventHandlers.close(e);
236
-
237
287
  Log.Debug("<< WebSock.onclose");
238
288
  };
239
-
240
289
  this._websocket.onerror = function (e) {
241
290
  Log.Debug(">> WebSock.onerror: " + e);
242
-
243
291
  _this._eventHandlers.error(e);
244
-
245
292
  Log.Debug("<< WebSock.onerror: " + e);
246
293
  };
247
294
  }
@@ -249,28 +296,28 @@ var Websock = /*#__PURE__*/function () {
249
296
  key: "close",
250
297
  value: function close() {
251
298
  if (this._websocket) {
252
- if (this._websocket.readyState === WebSocket.OPEN || this._websocket.readyState === WebSocket.CONNECTING) {
299
+ if (this.readyState === 'connecting' || this.readyState === 'open') {
253
300
  Log.Info("Closing WebSocket connection");
254
-
255
301
  this._websocket.close();
256
302
  }
257
-
258
303
  this._websocket.onmessage = function () {};
259
304
  }
260
- } // private methods
305
+ }
261
306
 
307
+ // private methods
262
308
  }, {
263
309
  key: "_encodeMessage",
264
310
  value: function _encodeMessage() {
265
311
  // Put in a binary arraybuffer
266
312
  // according to the spec, you can send ArrayBufferViews with the send method
267
313
  return new Uint8Array(this._sQ.buffer, 0, this._sQlen);
268
- } // We want to move all the unread data to the start of the queue,
314
+ }
315
+
316
+ // We want to move all the unread data to the start of the queue,
269
317
  // e.g. compacting.
270
318
  // The function also expands the receive que if needed, and for
271
319
  // performance reasons we combine these two actions to avoid
272
320
  // unneccessary copying.
273
-
274
321
  }, {
275
322
  key: "_expandCompactRQ",
276
323
  value: function _expandCompactRQ(minFit) {
@@ -278,60 +325,47 @@ var Websock = /*#__PURE__*/function () {
278
325
  // instead of resizing
279
326
  var requiredBufferSize = (this._rQlen - this._rQi + minFit) * 8;
280
327
  var resizeNeeded = this._rQbufferSize < requiredBufferSize;
281
-
282
328
  if (resizeNeeded) {
283
329
  // Make sure we always *at least* double the buffer size, and have at least space for 8x
284
330
  // the current amount of data
285
331
  this._rQbufferSize = Math.max(this._rQbufferSize * 2, requiredBufferSize);
286
- } // we don't want to grow unboundedly
287
-
332
+ }
288
333
 
334
+ // we don't want to grow unboundedly
289
335
  if (this._rQbufferSize > MAX_RQ_GROW_SIZE) {
290
336
  this._rQbufferSize = MAX_RQ_GROW_SIZE;
291
-
292
337
  if (this._rQbufferSize - this.rQlen < minFit) {
293
338
  throw new Error("Receive Queue buffer exceeded " + MAX_RQ_GROW_SIZE + " bytes, and the new message could not fit");
294
339
  }
295
340
  }
296
-
297
341
  if (resizeNeeded) {
298
342
  var oldRQbuffer = this._rQ.buffer;
299
343
  this._rQ = new Uint8Array(this._rQbufferSize);
300
-
301
344
  this._rQ.set(new Uint8Array(oldRQbuffer, this._rQi, this._rQlen - this._rQi));
302
345
  } else {
303
- if (ENABLE_COPYWITHIN) {
304
- this._rQ.copyWithin(0, this._rQi, this._rQlen);
305
- } else {
306
- this._rQ.set(new Uint8Array(this._rQ.buffer, this._rQi, this._rQlen - this._rQi));
307
- }
346
+ this._rQ.copyWithin(0, this._rQi, this._rQlen);
308
347
  }
309
-
310
348
  this._rQlen = this._rQlen - this._rQi;
311
349
  this._rQi = 0;
312
- } // push arraybuffer values onto the end of the receive que
350
+ }
313
351
 
352
+ // push arraybuffer values onto the end of the receive que
314
353
  }, {
315
354
  key: "_DecodeMessage",
316
355
  value: function _DecodeMessage(data) {
317
356
  var u8 = new Uint8Array(data);
318
-
319
357
  if (u8.length > this._rQbufferSize - this._rQlen) {
320
358
  this._expandCompactRQ(u8.length);
321
359
  }
322
-
323
360
  this._rQ.set(u8, this._rQlen);
324
-
325
361
  this._rQlen += u8.length;
326
362
  }
327
363
  }, {
328
364
  key: "_recvMessage",
329
365
  value: function _recvMessage(e) {
330
366
  this._DecodeMessage(e.data);
331
-
332
367
  if (this.rQlen > 0) {
333
368
  this._eventHandlers.message();
334
-
335
369
  if (this._rQlen == this._rQi) {
336
370
  // All data has now been processed, this means we
337
371
  // can reset the receive queue.
@@ -342,33 +376,7 @@ var Websock = /*#__PURE__*/function () {
342
376
  Log.Debug("Ignoring empty message");
343
377
  }
344
378
  }
345
- }, {
346
- key: "sQ",
347
- get: function get() {
348
- return this._sQ;
349
- }
350
- }, {
351
- key: "rQ",
352
- get: function get() {
353
- return this._rQ;
354
- }
355
- }, {
356
- key: "rQi",
357
- get: function get() {
358
- return this._rQi;
359
- },
360
- set: function set(val) {
361
- this._rQi = val;
362
- } // Receive Queue
363
-
364
- }, {
365
- key: "rQlen",
366
- get: function get() {
367
- return this._rQlen - this._rQi;
368
- }
369
379
  }]);
370
-
371
380
  return Websock;
372
381
  }();
373
-
374
- exports.default = Websock;
382
+ exports["default"] = Websock;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novnc/novnc",
3
- "version": "1.2.0",
3
+ "version": "1.3.0-g0ef7582",
4
4
  "description": "An HTML5 VNC client",
5
5
  "browser": "lib/rfb",
6
6
  "directories": {
@@ -21,7 +21,7 @@
21
21
  "scripts": {
22
22
  "lint": "eslint app core po/po2js po/xgettext-html tests utils",
23
23
  "test": "karma start karma.conf.js",
24
- "prepublish": "node ./utils/use_require.js --as commonjs --clean"
24
+ "prepublish": "node ./utils/convert.js --clean"
25
25
  },
26
26
  "repository": {
27
27
  "type": "git",
@@ -29,8 +29,6 @@
29
29
  },
30
30
  "author": "Joel Martin <github@martintribe.org> (https://github.com/kanaka)",
31
31
  "contributors": [
32
- "Solly Ross <sross@redhat.com> (https://github.com/directxman12)",
33
- "Peter Åstrand <astrand@cendio.se> (https://github.com/astrand)",
34
32
  "Samuel Mannehed <samuel@cendio.se> (https://github.com/samhed)",
35
33
  "Pierre Ossman <ossman@cendio.se> (https://github.com/CendioOssman)"
36
34
  ],
@@ -42,10 +40,7 @@
42
40
  "devDependencies": {
43
41
  "@babel/core": "*",
44
42
  "@babel/plugin-syntax-dynamic-import": "*",
45
- "@babel/plugin-transform-modules-amd": "*",
46
43
  "@babel/plugin-transform-modules-commonjs": "*",
47
- "@babel/plugin-transform-modules-systemjs": "*",
48
- "@babel/plugin-transform-modules-umd": "*",
49
44
  "@babel/preset-env": "*",
50
45
  "@babel/cli": "*",
51
46
  "babel-plugin-import-redirect": "*",
@@ -71,9 +66,6 @@
71
66
  "mocha": "*",
72
67
  "node-getopt": "*",
73
68
  "po2json": "*",
74
- "requirejs": "*",
75
- "rollup": "*",
76
- "rollup-plugin-node-resolve": "*",
77
69
  "sinon": "*",
78
70
  "sinon-chai": "*"
79
71
  },
@@ -1,61 +0,0 @@
1
- /*
2
- * noVNC: HTML5 VNC client
3
- * Copyright (C) 2020 The noVNC Authors
4
- * Licensed under MPL 2.0 or any later version (see LICENSE.txt)
5
- */
6
-
7
- /* Polyfills to provide new APIs in old browsers */
8
-
9
- /* Object.assign() (taken from MDN) */
10
- if (typeof Object.assign != 'function') {
11
- // Must be writable: true, enumerable: false, configurable: true
12
- Object.defineProperty(Object, "assign", {
13
- value: function assign(target, varArgs) { // .length of function is 2
14
- 'use strict';
15
- if (target == null) { // TypeError if undefined or null
16
- throw new TypeError('Cannot convert undefined or null to object');
17
- }
18
-
19
- const to = Object(target);
20
-
21
- for (let index = 1; index < arguments.length; index++) {
22
- const nextSource = arguments[index];
23
-
24
- if (nextSource != null) { // Skip over if undefined or null
25
- for (let nextKey in nextSource) {
26
- // Avoid bugs when hasOwnProperty is shadowed
27
- if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
28
- to[nextKey] = nextSource[nextKey];
29
- }
30
- }
31
- }
32
- }
33
- return to;
34
- },
35
- writable: true,
36
- configurable: true
37
- });
38
- }
39
-
40
- /* CustomEvent constructor (taken from MDN) */
41
- (() => {
42
- function CustomEvent(event, params) {
43
- params = params || { bubbles: false, cancelable: false, detail: undefined };
44
- const evt = document.createEvent( 'CustomEvent' );
45
- evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
46
- return evt;
47
- }
48
-
49
- CustomEvent.prototype = window.Event.prototype;
50
-
51
- if (typeof window.CustomEvent !== "function") {
52
- window.CustomEvent = CustomEvent;
53
- }
54
- })();
55
-
56
- /* Number.isInteger() (taken from MDN) */
57
- Number.isInteger = Number.isInteger || function isInteger(value) {
58
- return typeof value === 'number' &&
59
- isFinite(value) &&
60
- Math.floor(value) === value;
61
- };
@@ -1,72 +0,0 @@
1
- "use strict";
2
-
3
- /*
4
- * noVNC: HTML5 VNC client
5
- * Copyright (C) 2020 The noVNC Authors
6
- * Licensed under MPL 2.0 or any later version (see LICENSE.txt)
7
- */
8
-
9
- /* Polyfills to provide new APIs in old browsers */
10
-
11
- /* Object.assign() (taken from MDN) */
12
- if (typeof Object.assign != 'function') {
13
- // Must be writable: true, enumerable: false, configurable: true
14
- Object.defineProperty(Object, "assign", {
15
- value: function assign(target, varArgs) {
16
- // .length of function is 2
17
- 'use strict';
18
-
19
- if (target == null) {
20
- // TypeError if undefined or null
21
- throw new TypeError('Cannot convert undefined or null to object');
22
- }
23
-
24
- var to = Object(target);
25
-
26
- for (var index = 1; index < arguments.length; index++) {
27
- var nextSource = arguments[index];
28
-
29
- if (nextSource != null) {
30
- // Skip over if undefined or null
31
- for (var nextKey in nextSource) {
32
- // Avoid bugs when hasOwnProperty is shadowed
33
- if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
34
- to[nextKey] = nextSource[nextKey];
35
- }
36
- }
37
- }
38
- }
39
-
40
- return to;
41
- },
42
- writable: true,
43
- configurable: true
44
- });
45
- }
46
- /* CustomEvent constructor (taken from MDN) */
47
-
48
-
49
- (function () {
50
- function CustomEvent(event, params) {
51
- params = params || {
52
- bubbles: false,
53
- cancelable: false,
54
- detail: undefined
55
- };
56
- var evt = document.createEvent('CustomEvent');
57
- evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
58
- return evt;
59
- }
60
-
61
- CustomEvent.prototype = window.Event.prototype;
62
-
63
- if (typeof window.CustomEvent !== "function") {
64
- window.CustomEvent = CustomEvent;
65
- }
66
- })();
67
- /* Number.isInteger() (taken from MDN) */
68
-
69
-
70
- Number.isInteger = Number.isInteger || function isInteger(value) {
71
- return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
72
- };