@novnc/novnc 1.3.0 → 1.4.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUTHORS +2 -2
- package/LICENSE.txt +1 -1
- package/README.md +23 -7
- package/core/decoders/jpeg.js +141 -0
- package/core/decoders/raw.js +1 -1
- package/core/decoders/zrle.js +185 -0
- package/core/des.js +1 -1
- package/core/display.js +12 -0
- package/core/encodings.js +4 -0
- package/core/input/keyboard.js +10 -0
- package/core/ra2.js +567 -0
- package/core/rfb.js +469 -84
- package/core/util/browser.js +56 -7
- package/core/util/cursor.js +4 -0
- package/core/util/md5.js +79 -0
- package/docs/API.md +318 -157
- package/lib/base64.js +20 -34
- package/lib/decoders/copyrect.js +5 -12
- package/lib/decoders/hextile.js +17 -47
- package/lib/decoders/jpeg.js +149 -0
- package/lib/decoders/raw.js +10 -23
- package/lib/decoders/rre.js +5 -16
- package/lib/decoders/tight.js +13 -79
- package/lib/decoders/tightpng.js +8 -28
- package/lib/decoders/zrle.js +188 -0
- package/lib/deflator.js +9 -23
- package/lib/des.js +24 -37
- package/lib/display.js +62 -108
- package/lib/encodings.js +7 -8
- package/lib/inflator.js +6 -19
- package/lib/input/domkeytable.js +77 -48
- package/lib/input/fixedkeys.js +8 -3
- package/lib/input/gesturehandler.js +86 -153
- package/lib/input/keyboard.js +62 -91
- package/lib/input/keysym.js +14 -270
- package/lib/input/keysymdef.js +5 -7
- package/lib/input/util.js +43 -85
- package/lib/input/vkeys.js +0 -3
- package/lib/input/xtscancodes.js +1 -168
- package/lib/ra2.js +1005 -0
- package/lib/rfb.js +795 -923
- package/lib/util/browser.js +66 -29
- package/lib/util/cursor.js +29 -66
- package/lib/util/element.js +3 -5
- package/lib/util/events.js +23 -30
- package/lib/util/eventtarget.js +5 -14
- package/lib/util/int.js +1 -2
- package/lib/util/logging.js +1 -19
- package/lib/util/md5.js +77 -0
- package/lib/util/strings.js +3 -5
- package/lib/vendor/pako/lib/utils/common.js +8 -17
- package/lib/vendor/pako/lib/zlib/adler32.js +3 -7
- package/lib/vendor/pako/lib/zlib/constants.js +2 -5
- package/lib/vendor/pako/lib/zlib/crc32.js +5 -12
- package/lib/vendor/pako/lib/zlib/deflate.js +213 -618
- package/lib/vendor/pako/lib/zlib/gzheader.js +1 -13
- package/lib/vendor/pako/lib/zlib/inffast.js +60 -176
- package/lib/vendor/pako/lib/zlib/inflate.js +398 -888
- package/lib/vendor/pako/lib/zlib/inftrees.js +63 -169
- package/lib/vendor/pako/lib/zlib/messages.js +1 -11
- package/lib/vendor/pako/lib/zlib/trees.js +246 -588
- package/lib/vendor/pako/lib/zlib/zstream.js +2 -18
- package/lib/websock.js +37 -88
- package/package.json +32 -35
|
@@ -4,43 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = ZStream;
|
|
7
|
-
|
|
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,43 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
7
|
var Log = _interopRequireWildcard(require("./util/logging.js"));
|
|
11
|
-
|
|
12
8
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
-
|
|
14
9
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
-
|
|
10
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
16
11
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
17
|
-
|
|
18
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."); }
|
|
19
|
-
|
|
20
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); }
|
|
21
|
-
|
|
22
14
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
23
|
-
|
|
24
15
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
25
|
-
|
|
26
|
-
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; }
|
|
27
|
-
|
|
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; }
|
|
28
17
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
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, _toPropertyKey(descriptor.key), descriptor); } }
|
|
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; }
|
|
20
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
21
|
+
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); }
|
|
34
22
|
// this has performance issues in some versions Chromium, and
|
|
35
23
|
// doesn't gain a tremendous amount of performance increase in Firefox
|
|
36
24
|
// at the moment. It may be valuable to turn it on in the future.
|
|
37
25
|
var MAX_RQ_GROW_SIZE = 40 * 1024 * 1024; // 40 MiB
|
|
26
|
+
|
|
38
27
|
// Constants pulled from RTCDataChannelState enum
|
|
39
28
|
// https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/readyState#RTCDataChannelState_enum
|
|
40
|
-
|
|
41
29
|
var DataChannel = {
|
|
42
30
|
CONNECTING: "connecting",
|
|
43
31
|
OPEN: "open",
|
|
@@ -49,28 +37,23 @@ var ReadyStates = {
|
|
|
49
37
|
OPEN: [WebSocket.OPEN, DataChannel.OPEN],
|
|
50
38
|
CLOSING: [WebSocket.CLOSING, DataChannel.CLOSING],
|
|
51
39
|
CLOSED: [WebSocket.CLOSED, DataChannel.CLOSED]
|
|
52
|
-
};
|
|
40
|
+
};
|
|
53
41
|
|
|
42
|
+
// Properties a raw channel must have, WebSocket and RTCDataChannel are two examples
|
|
54
43
|
var rawChannelProps = ["send", "close", "binaryType", "onerror", "onmessage", "onopen", "protocol", "readyState"];
|
|
55
|
-
|
|
56
44
|
var Websock = /*#__PURE__*/function () {
|
|
57
45
|
function Websock() {
|
|
58
46
|
_classCallCheck(this, Websock);
|
|
59
|
-
|
|
60
47
|
this._websocket = null; // WebSocket or RTCDataChannel object
|
|
61
48
|
|
|
62
49
|
this._rQi = 0; // Receive queue index
|
|
63
|
-
|
|
64
50
|
this._rQlen = 0; // Next write position in the receive queue
|
|
65
|
-
|
|
66
51
|
this._rQbufferSize = 1024 * 1024 * 4; // Receive queue buffer size (4 MiB)
|
|
67
52
|
// called in init: this._rQ = new Uint8Array(this._rQbufferSize);
|
|
68
|
-
|
|
69
53
|
this._rQ = null; // Receive queue
|
|
70
54
|
|
|
71
55
|
this._sQbufferSize = 1024 * 10; // 10 KiB
|
|
72
56
|
// called in init: this._sQ = new Uint8Array(this._sQbufferSize);
|
|
73
|
-
|
|
74
57
|
this._sQlen = 0;
|
|
75
58
|
this._sQ = null; // Send queue
|
|
76
59
|
|
|
@@ -80,20 +63,17 @@ var Websock = /*#__PURE__*/function () {
|
|
|
80
63
|
close: function close() {},
|
|
81
64
|
error: function error() {}
|
|
82
65
|
};
|
|
83
|
-
}
|
|
84
|
-
|
|
66
|
+
}
|
|
85
67
|
|
|
68
|
+
// Getters and Setters
|
|
86
69
|
_createClass(Websock, [{
|
|
87
70
|
key: "readyState",
|
|
88
71
|
get: function get() {
|
|
89
72
|
var subState;
|
|
90
|
-
|
|
91
73
|
if (this._websocket === null) {
|
|
92
74
|
return "unused";
|
|
93
75
|
}
|
|
94
|
-
|
|
95
76
|
subState = this._websocket.readyState;
|
|
96
|
-
|
|
97
77
|
if (ReadyStates.CONNECTING.includes(subState)) {
|
|
98
78
|
return "connecting";
|
|
99
79
|
} else if (ReadyStates.OPEN.includes(subState)) {
|
|
@@ -103,7 +83,6 @@ var Websock = /*#__PURE__*/function () {
|
|
|
103
83
|
} else if (ReadyStates.CLOSED.includes(subState)) {
|
|
104
84
|
return "closed";
|
|
105
85
|
}
|
|
106
|
-
|
|
107
86
|
return "unknown";
|
|
108
87
|
}
|
|
109
88
|
}, {
|
|
@@ -123,8 +102,9 @@ var Websock = /*#__PURE__*/function () {
|
|
|
123
102
|
},
|
|
124
103
|
set: function set(val) {
|
|
125
104
|
this._rQi = val;
|
|
126
|
-
}
|
|
105
|
+
}
|
|
127
106
|
|
|
107
|
+
// Receive Queue
|
|
128
108
|
}, {
|
|
129
109
|
key: "rQlen",
|
|
130
110
|
get: function get() {
|
|
@@ -154,17 +134,16 @@ var Websock = /*#__PURE__*/function () {
|
|
|
154
134
|
key: "rQshift32",
|
|
155
135
|
value: function rQshift32() {
|
|
156
136
|
return this._rQshift(4);
|
|
157
|
-
}
|
|
137
|
+
}
|
|
158
138
|
|
|
139
|
+
// TODO(directxman12): test performance with these vs a DataView
|
|
159
140
|
}, {
|
|
160
141
|
key: "_rQshift",
|
|
161
142
|
value: function _rQshift(bytes) {
|
|
162
143
|
var res = 0;
|
|
163
|
-
|
|
164
144
|
for (var _byte = bytes - 1; _byte >= 0; _byte--) {
|
|
165
145
|
res += this._rQ[this._rQi++] << _byte * 8;
|
|
166
146
|
}
|
|
167
|
-
|
|
168
147
|
return res;
|
|
169
148
|
}
|
|
170
149
|
}, {
|
|
@@ -173,14 +152,12 @@ var Websock = /*#__PURE__*/function () {
|
|
|
173
152
|
if (typeof len === 'undefined') {
|
|
174
153
|
len = this.rQlen;
|
|
175
154
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
155
|
+
var str = "";
|
|
156
|
+
// Handle large arrays in steps to avoid long strings on the stack
|
|
179
157
|
for (var i = 0; i < len; i += 4096) {
|
|
180
158
|
var part = this.rQshiftBytes(Math.min(4096, len - i));
|
|
181
159
|
str += String.fromCharCode.apply(null, part);
|
|
182
160
|
}
|
|
183
|
-
|
|
184
161
|
return str;
|
|
185
162
|
}
|
|
186
163
|
}, {
|
|
@@ -189,7 +166,6 @@ var Websock = /*#__PURE__*/function () {
|
|
|
189
166
|
if (typeof len === 'undefined') {
|
|
190
167
|
len = this.rQlen;
|
|
191
168
|
}
|
|
192
|
-
|
|
193
169
|
this._rQi += len;
|
|
194
170
|
return new Uint8Array(this._rQ.buffer, this._rQi - len, len);
|
|
195
171
|
}
|
|
@@ -198,9 +174,8 @@ var Websock = /*#__PURE__*/function () {
|
|
|
198
174
|
value: function rQshiftTo(target, len) {
|
|
199
175
|
if (len === undefined) {
|
|
200
176
|
len = this.rQlen;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
177
|
+
}
|
|
178
|
+
// TODO: make this just use set with views when using a ArrayBuffer to store the rQ
|
|
204
179
|
target.set(new Uint8Array(this._rQ.buffer, this._rQi, len));
|
|
205
180
|
this._rQi += len;
|
|
206
181
|
}
|
|
@@ -209,10 +184,11 @@ var Websock = /*#__PURE__*/function () {
|
|
|
209
184
|
value: function rQslice(start) {
|
|
210
185
|
var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.rQlen;
|
|
211
186
|
return new Uint8Array(this._rQ.buffer, this._rQi + start, end - start);
|
|
212
|
-
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Check to see if we must wait for 'num' bytes (default to FBU.bytes)
|
|
213
190
|
// to be available in the receive queue. Return true if we need to
|
|
214
191
|
// wait (and possibly print a debug message), otherwise false.
|
|
215
|
-
|
|
216
192
|
}, {
|
|
217
193
|
key: "rQwait",
|
|
218
194
|
value: function rQwait(msg, num, goback) {
|
|
@@ -221,22 +197,20 @@ var Websock = /*#__PURE__*/function () {
|
|
|
221
197
|
if (this._rQi < goback) {
|
|
222
198
|
throw new Error("rQwait cannot backup " + goback + " bytes");
|
|
223
199
|
}
|
|
224
|
-
|
|
225
200
|
this._rQi -= goback;
|
|
226
201
|
}
|
|
227
|
-
|
|
228
202
|
return true; // true means need more data
|
|
229
203
|
}
|
|
230
204
|
|
|
231
205
|
return false;
|
|
232
|
-
}
|
|
206
|
+
}
|
|
233
207
|
|
|
208
|
+
// Send Queue
|
|
234
209
|
}, {
|
|
235
210
|
key: "flush",
|
|
236
211
|
value: function flush() {
|
|
237
212
|
if (this._sQlen > 0 && this.readyState === 'open') {
|
|
238
213
|
this._websocket.send(this._encodeMessage());
|
|
239
|
-
|
|
240
214
|
this._sQlen = 0;
|
|
241
215
|
}
|
|
242
216
|
}
|
|
@@ -244,7 +218,6 @@ var Websock = /*#__PURE__*/function () {
|
|
|
244
218
|
key: "send",
|
|
245
219
|
value: function send(arr) {
|
|
246
220
|
this._sQ.set(arr, this._sQlen);
|
|
247
|
-
|
|
248
221
|
this._sQlen += arr.length;
|
|
249
222
|
this.flush();
|
|
250
223
|
}
|
|
@@ -254,8 +227,9 @@ var Websock = /*#__PURE__*/function () {
|
|
|
254
227
|
this.send(str.split('').map(function (chr) {
|
|
255
228
|
return chr.charCodeAt(0);
|
|
256
229
|
}));
|
|
257
|
-
}
|
|
230
|
+
}
|
|
258
231
|
|
|
232
|
+
// Event Handlers
|
|
259
233
|
}, {
|
|
260
234
|
key: "off",
|
|
261
235
|
value: function off(evt) {
|
|
@@ -276,7 +250,6 @@ var Websock = /*#__PURE__*/function () {
|
|
|
276
250
|
key: "init",
|
|
277
251
|
value: function init() {
|
|
278
252
|
this._allocateBuffers();
|
|
279
|
-
|
|
280
253
|
this._rQi = 0;
|
|
281
254
|
this._websocket = null;
|
|
282
255
|
}
|
|
@@ -289,48 +262,35 @@ var Websock = /*#__PURE__*/function () {
|
|
|
289
262
|
key: "attach",
|
|
290
263
|
value: function attach(rawChannel) {
|
|
291
264
|
var _this = this;
|
|
265
|
+
this.init();
|
|
292
266
|
|
|
293
|
-
|
|
294
|
-
|
|
267
|
+
// Must get object and class methods to be compatible with the tests.
|
|
295
268
|
var channelProps = [].concat(_toConsumableArray(Object.keys(rawChannel)), _toConsumableArray(Object.getOwnPropertyNames(Object.getPrototypeOf(rawChannel))));
|
|
296
|
-
|
|
297
269
|
for (var i = 0; i < rawChannelProps.length; i++) {
|
|
298
270
|
var prop = rawChannelProps[i];
|
|
299
|
-
|
|
300
271
|
if (channelProps.indexOf(prop) < 0) {
|
|
301
272
|
throw new Error('Raw channel missing property: ' + prop);
|
|
302
273
|
}
|
|
303
274
|
}
|
|
304
|
-
|
|
305
275
|
this._websocket = rawChannel;
|
|
306
276
|
this._websocket.binaryType = "arraybuffer";
|
|
307
277
|
this._websocket.onmessage = this._recvMessage.bind(this);
|
|
308
|
-
|
|
309
278
|
this._websocket.onopen = function () {
|
|
310
279
|
Log.Debug('>> WebSock.onopen');
|
|
311
|
-
|
|
312
280
|
if (_this._websocket.protocol) {
|
|
313
281
|
Log.Info("Server choose sub-protocol: " + _this._websocket.protocol);
|
|
314
282
|
}
|
|
315
|
-
|
|
316
283
|
_this._eventHandlers.open();
|
|
317
|
-
|
|
318
284
|
Log.Debug("<< WebSock.onopen");
|
|
319
285
|
};
|
|
320
|
-
|
|
321
286
|
this._websocket.onclose = function (e) {
|
|
322
287
|
Log.Debug(">> WebSock.onclose");
|
|
323
|
-
|
|
324
288
|
_this._eventHandlers.close(e);
|
|
325
|
-
|
|
326
289
|
Log.Debug("<< WebSock.onclose");
|
|
327
290
|
};
|
|
328
|
-
|
|
329
291
|
this._websocket.onerror = function (e) {
|
|
330
292
|
Log.Debug(">> WebSock.onerror: " + e);
|
|
331
|
-
|
|
332
293
|
_this._eventHandlers.error(e);
|
|
333
|
-
|
|
334
294
|
Log.Debug("<< WebSock.onerror: " + e);
|
|
335
295
|
};
|
|
336
296
|
}
|
|
@@ -340,26 +300,26 @@ var Websock = /*#__PURE__*/function () {
|
|
|
340
300
|
if (this._websocket) {
|
|
341
301
|
if (this.readyState === 'connecting' || this.readyState === 'open') {
|
|
342
302
|
Log.Info("Closing WebSocket connection");
|
|
343
|
-
|
|
344
303
|
this._websocket.close();
|
|
345
304
|
}
|
|
346
|
-
|
|
347
305
|
this._websocket.onmessage = function () {};
|
|
348
306
|
}
|
|
349
|
-
}
|
|
307
|
+
}
|
|
350
308
|
|
|
309
|
+
// private methods
|
|
351
310
|
}, {
|
|
352
311
|
key: "_encodeMessage",
|
|
353
312
|
value: function _encodeMessage() {
|
|
354
313
|
// Put in a binary arraybuffer
|
|
355
314
|
// according to the spec, you can send ArrayBufferViews with the send method
|
|
356
315
|
return new Uint8Array(this._sQ.buffer, 0, this._sQlen);
|
|
357
|
-
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// We want to move all the unread data to the start of the queue,
|
|
358
319
|
// e.g. compacting.
|
|
359
320
|
// The function also expands the receive que if needed, and for
|
|
360
321
|
// performance reasons we combine these two actions to avoid
|
|
361
322
|
// unneccessary copying.
|
|
362
|
-
|
|
363
323
|
}, {
|
|
364
324
|
key: "_expandCompactRQ",
|
|
365
325
|
value: function _expandCompactRQ(minFit) {
|
|
@@ -367,56 +327,47 @@ var Websock = /*#__PURE__*/function () {
|
|
|
367
327
|
// instead of resizing
|
|
368
328
|
var requiredBufferSize = (this._rQlen - this._rQi + minFit) * 8;
|
|
369
329
|
var resizeNeeded = this._rQbufferSize < requiredBufferSize;
|
|
370
|
-
|
|
371
330
|
if (resizeNeeded) {
|
|
372
331
|
// Make sure we always *at least* double the buffer size, and have at least space for 8x
|
|
373
332
|
// the current amount of data
|
|
374
333
|
this._rQbufferSize = Math.max(this._rQbufferSize * 2, requiredBufferSize);
|
|
375
|
-
}
|
|
376
|
-
|
|
334
|
+
}
|
|
377
335
|
|
|
336
|
+
// we don't want to grow unboundedly
|
|
378
337
|
if (this._rQbufferSize > MAX_RQ_GROW_SIZE) {
|
|
379
338
|
this._rQbufferSize = MAX_RQ_GROW_SIZE;
|
|
380
|
-
|
|
381
339
|
if (this._rQbufferSize - this.rQlen < minFit) {
|
|
382
340
|
throw new Error("Receive Queue buffer exceeded " + MAX_RQ_GROW_SIZE + " bytes, and the new message could not fit");
|
|
383
341
|
}
|
|
384
342
|
}
|
|
385
|
-
|
|
386
343
|
if (resizeNeeded) {
|
|
387
344
|
var oldRQbuffer = this._rQ.buffer;
|
|
388
345
|
this._rQ = new Uint8Array(this._rQbufferSize);
|
|
389
|
-
|
|
390
346
|
this._rQ.set(new Uint8Array(oldRQbuffer, this._rQi, this._rQlen - this._rQi));
|
|
391
347
|
} else {
|
|
392
348
|
this._rQ.copyWithin(0, this._rQi, this._rQlen);
|
|
393
349
|
}
|
|
394
|
-
|
|
395
350
|
this._rQlen = this._rQlen - this._rQi;
|
|
396
351
|
this._rQi = 0;
|
|
397
|
-
}
|
|
352
|
+
}
|
|
398
353
|
|
|
354
|
+
// push arraybuffer values onto the end of the receive que
|
|
399
355
|
}, {
|
|
400
356
|
key: "_DecodeMessage",
|
|
401
357
|
value: function _DecodeMessage(data) {
|
|
402
358
|
var u8 = new Uint8Array(data);
|
|
403
|
-
|
|
404
359
|
if (u8.length > this._rQbufferSize - this._rQlen) {
|
|
405
360
|
this._expandCompactRQ(u8.length);
|
|
406
361
|
}
|
|
407
|
-
|
|
408
362
|
this._rQ.set(u8, this._rQlen);
|
|
409
|
-
|
|
410
363
|
this._rQlen += u8.length;
|
|
411
364
|
}
|
|
412
365
|
}, {
|
|
413
366
|
key: "_recvMessage",
|
|
414
367
|
value: function _recvMessage(e) {
|
|
415
368
|
this._DecodeMessage(e.data);
|
|
416
|
-
|
|
417
369
|
if (this.rQlen > 0) {
|
|
418
370
|
this._eventHandlers.message();
|
|
419
|
-
|
|
420
371
|
if (this._rQlen == this._rQi) {
|
|
421
372
|
// All data has now been processed, this means we
|
|
422
373
|
// can reset the receive queue.
|
|
@@ -428,8 +379,6 @@ var Websock = /*#__PURE__*/function () {
|
|
|
428
379
|
}
|
|
429
380
|
}
|
|
430
381
|
}]);
|
|
431
|
-
|
|
432
382
|
return Websock;
|
|
433
383
|
}();
|
|
434
|
-
|
|
435
384
|
exports["default"] = Websock;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novnc/novnc",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-beta",
|
|
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/
|
|
24
|
+
"prepublish": "node ./utils/convert.js --clean"
|
|
25
25
|
},
|
|
26
26
|
"repository": {
|
|
27
27
|
"type": "git",
|
|
@@ -38,39 +38,36 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/novnc/noVNC",
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@babel/core": "
|
|
42
|
-
"@babel/plugin-syntax-dynamic-import": "
|
|
43
|
-
"@babel/plugin-transform-modules-commonjs": "
|
|
44
|
-
"@babel/preset-env": "
|
|
45
|
-
"@babel/cli": "
|
|
46
|
-
"babel-plugin-import-redirect": "
|
|
47
|
-
"browserify": "
|
|
48
|
-
"babelify": "
|
|
49
|
-
"core-js": "
|
|
50
|
-
"chai": "
|
|
51
|
-
"commander": "
|
|
52
|
-
"es-module-loader": "
|
|
53
|
-
"eslint": "
|
|
54
|
-
"fs-extra": "
|
|
55
|
-
"jsdom": "
|
|
56
|
-
"karma": "
|
|
57
|
-
"karma-mocha": "
|
|
58
|
-
"karma-chrome-launcher": "
|
|
59
|
-
"@chiragrupani/karma-chromium-edge-launcher": "
|
|
60
|
-
"karma-firefox-launcher": "
|
|
61
|
-
"karma-ie-launcher": "
|
|
62
|
-
"karma-mocha-reporter": "
|
|
63
|
-
"karma-safari-launcher": "
|
|
64
|
-
"karma-script-launcher": "
|
|
65
|
-
"karma-sinon-chai": "
|
|
66
|
-
"mocha": "
|
|
67
|
-
"node-getopt": "
|
|
68
|
-
"po2json": "
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"rollup-plugin-node-resolve": "*",
|
|
72
|
-
"sinon": "*",
|
|
73
|
-
"sinon-chai": "*"
|
|
41
|
+
"@babel/core": "latest",
|
|
42
|
+
"@babel/plugin-syntax-dynamic-import": "latest",
|
|
43
|
+
"@babel/plugin-transform-modules-commonjs": "latest",
|
|
44
|
+
"@babel/preset-env": "latest",
|
|
45
|
+
"@babel/cli": "latest",
|
|
46
|
+
"babel-plugin-import-redirect": "latest",
|
|
47
|
+
"browserify": "latest",
|
|
48
|
+
"babelify": "latest",
|
|
49
|
+
"core-js": "latest",
|
|
50
|
+
"chai": "latest",
|
|
51
|
+
"commander": "latest",
|
|
52
|
+
"es-module-loader": "latest",
|
|
53
|
+
"eslint": "latest",
|
|
54
|
+
"fs-extra": "latest",
|
|
55
|
+
"jsdom": "latest",
|
|
56
|
+
"karma": "latest",
|
|
57
|
+
"karma-mocha": "latest",
|
|
58
|
+
"karma-chrome-launcher": "latest",
|
|
59
|
+
"@chiragrupani/karma-chromium-edge-launcher": "latest",
|
|
60
|
+
"karma-firefox-launcher": "latest",
|
|
61
|
+
"karma-ie-launcher": "latest",
|
|
62
|
+
"karma-mocha-reporter": "latest",
|
|
63
|
+
"karma-safari-launcher": "latest",
|
|
64
|
+
"karma-script-launcher": "latest",
|
|
65
|
+
"karma-sinon-chai": "latest",
|
|
66
|
+
"mocha": "latest",
|
|
67
|
+
"node-getopt": "latest",
|
|
68
|
+
"po2json": "latest",
|
|
69
|
+
"sinon": "latest",
|
|
70
|
+
"sinon-chai": "latest"
|
|
74
71
|
},
|
|
75
72
|
"dependencies": {},
|
|
76
73
|
"keywords": [
|