@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.
- package/AUTHORS +13 -0
- package/LICENSE.txt +2 -1
- package/README.md +69 -3
- package/core/base64.js +35 -41
- package/core/decoders/copyrect.js +22 -0
- package/core/decoders/hextile.js +137 -0
- package/core/decoders/raw.js +56 -0
- package/core/decoders/rre.js +44 -0
- package/core/decoders/tight.js +315 -0
- package/core/decoders/tightpng.js +27 -0
- package/core/deflator.js +85 -0
- package/core/des.js +90 -95
- package/core/display.js +254 -297
- package/core/encodings.js +7 -3
- package/core/inflator.js +48 -20
- package/core/input/domkeytable.js +21 -24
- package/core/input/fixedkeys.js +3 -1
- package/core/input/gesturehandler.js +567 -0
- package/core/input/keyboard.js +194 -120
- package/core/input/keysym.js +2 -0
- package/core/input/keysymdef.js +3 -3
- package/core/input/util.js +53 -12
- package/core/input/vkeys.js +2 -1
- package/core/rfb.js +1937 -1496
- package/core/util/browser.js +80 -29
- package/core/util/cursor.js +253 -0
- package/core/util/element.js +32 -0
- package/core/util/events.js +59 -55
- package/core/util/eventtarget.js +25 -30
- package/core/util/int.js +15 -0
- package/core/util/logging.js +21 -16
- package/core/util/polyfill.js +15 -8
- package/core/util/strings.js +21 -8
- package/core/websock.js +145 -167
- package/docs/API.md +31 -10
- package/lib/base64.js +115 -0
- package/lib/decoders/copyrect.js +44 -0
- package/lib/decoders/hextile.js +173 -0
- package/lib/decoders/raw.js +78 -0
- package/lib/decoders/rre.js +65 -0
- package/lib/decoders/tight.js +350 -0
- package/lib/decoders/tightpng.js +67 -0
- package/lib/deflator.js +99 -0
- package/lib/des.js +314 -0
- package/lib/display.js +733 -0
- package/lib/encodings.js +64 -0
- package/lib/inflator.js +87 -0
- package/lib/input/domkeytable.js +282 -0
- package/lib/input/fixedkeys.js +123 -0
- package/lib/input/gesturehandler.js +642 -0
- package/lib/input/keyboard.js +429 -0
- package/lib/input/keysym.js +1135 -0
- package/lib/input/keysymdef.js +1354 -0
- package/lib/input/util.js +304 -0
- package/lib/input/vkeys.js +127 -0
- package/lib/input/xtscancodes.js +505 -0
- package/lib/rfb.js +3448 -0
- package/lib/util/browser.js +131 -0
- package/lib/util/cursor.js +314 -0
- package/lib/util/element.js +43 -0
- package/lib/util/events.js +142 -0
- package/lib/util/eventtarget.js +64 -0
- package/lib/util/int.js +22 -0
- package/lib/util/logging.js +79 -0
- package/lib/util/polyfill.js +72 -0
- package/lib/util/strings.js +38 -0
- package/lib/vendor/pako/lib/utils/common.js +67 -0
- package/lib/vendor/pako/lib/zlib/adler32.js +33 -0
- package/lib/vendor/pako/lib/zlib/constants.js +51 -0
- package/lib/vendor/pako/lib/zlib/crc32.js +42 -0
- package/lib/vendor/pako/lib/zlib/deflate.js +2159 -0
- package/lib/vendor/pako/lib/zlib/gzheader.js +53 -0
- package/lib/vendor/pako/lib/zlib/inffast.js +445 -0
- package/lib/vendor/pako/lib/zlib/inflate.js +2114 -0
- package/lib/vendor/pako/lib/zlib/inftrees.js +418 -0
- package/lib/vendor/pako/lib/zlib/messages.js +36 -0
- package/lib/vendor/pako/lib/zlib/trees.js +1499 -0
- package/lib/vendor/pako/lib/zlib/zstream.js +46 -0
- package/lib/vendor/promise.js +255 -0
- package/lib/websock.js +374 -0
- package/package.json +48 -28
- package/vendor/pako/lib/zlib/deflate.js +30 -30
- package/vendor/pako/lib/zlib/inflate.js +17 -17
- package/core/input/mouse.js +0 -280
- package/docs/API-internal.md +0 -125
- package/docs/EMBEDDING.md +0 -83
- package/docs/VERSION +0 -1
package/lib/util/int.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toUnsigned32bit = toUnsigned32bit;
|
|
7
|
+
exports.toSigned32bit = toSigned32bit;
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* noVNC: HTML5 VNC client
|
|
11
|
+
* Copyright (C) 2020 The noVNC Authors
|
|
12
|
+
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
13
|
+
*
|
|
14
|
+
* See README.md for usage and integration instructions.
|
|
15
|
+
*/
|
|
16
|
+
function toUnsigned32bit(toConvert) {
|
|
17
|
+
return toConvert >>> 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function toSigned32bit(toConvert) {
|
|
21
|
+
return toConvert | 0;
|
|
22
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.initLogging = initLogging;
|
|
7
|
+
exports.getLogging = getLogging;
|
|
8
|
+
exports.Error = exports.Warn = exports.Info = exports.Debug = void 0;
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* noVNC: HTML5 VNC client
|
|
12
|
+
* Copyright (C) 2019 The noVNC Authors
|
|
13
|
+
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
14
|
+
*
|
|
15
|
+
* See README.md for usage and integration instructions.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
* Logging/debug routines
|
|
20
|
+
*/
|
|
21
|
+
var _logLevel = 'warn';
|
|
22
|
+
|
|
23
|
+
var Debug = function Debug() {};
|
|
24
|
+
|
|
25
|
+
exports.Debug = Debug;
|
|
26
|
+
|
|
27
|
+
var Info = function Info() {};
|
|
28
|
+
|
|
29
|
+
exports.Info = Info;
|
|
30
|
+
|
|
31
|
+
var Warn = function Warn() {};
|
|
32
|
+
|
|
33
|
+
exports.Warn = Warn;
|
|
34
|
+
|
|
35
|
+
var Error = function Error() {};
|
|
36
|
+
|
|
37
|
+
exports.Error = Error;
|
|
38
|
+
|
|
39
|
+
function initLogging(level) {
|
|
40
|
+
if (typeof level === 'undefined') {
|
|
41
|
+
level = _logLevel;
|
|
42
|
+
} else {
|
|
43
|
+
_logLevel = level;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exports.Debug = Debug = exports.Info = Info = exports.Warn = Warn = exports.Error = Error = function Error() {};
|
|
47
|
+
|
|
48
|
+
if (typeof window.console !== "undefined") {
|
|
49
|
+
/* eslint-disable no-console, no-fallthrough */
|
|
50
|
+
switch (level) {
|
|
51
|
+
case 'debug':
|
|
52
|
+
exports.Debug = Debug = console.debug.bind(window.console);
|
|
53
|
+
|
|
54
|
+
case 'info':
|
|
55
|
+
exports.Info = Info = console.info.bind(window.console);
|
|
56
|
+
|
|
57
|
+
case 'warn':
|
|
58
|
+
exports.Warn = Warn = console.warn.bind(window.console);
|
|
59
|
+
|
|
60
|
+
case 'error':
|
|
61
|
+
exports.Error = Error = console.error.bind(window.console);
|
|
62
|
+
|
|
63
|
+
case 'none':
|
|
64
|
+
break;
|
|
65
|
+
|
|
66
|
+
default:
|
|
67
|
+
throw new window.Error("invalid logging type '" + level + "'");
|
|
68
|
+
}
|
|
69
|
+
/* eslint-enable no-console, no-fallthrough */
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getLogging() {
|
|
75
|
+
return _logLevel;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Initialize logging level
|
|
79
|
+
initLogging();
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.decodeUTF8 = decodeUTF8;
|
|
7
|
+
exports.encodeUTF8 = encodeUTF8;
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* noVNC: HTML5 VNC client
|
|
11
|
+
* Copyright (C) 2019 The noVNC Authors
|
|
12
|
+
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
13
|
+
*
|
|
14
|
+
* See README.md for usage and integration instructions.
|
|
15
|
+
*/
|
|
16
|
+
// Decode from UTF-8
|
|
17
|
+
function decodeUTF8(utf8string) {
|
|
18
|
+
var allowLatin1 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
return decodeURIComponent(escape(utf8string));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
if (e instanceof URIError) {
|
|
24
|
+
if (allowLatin1) {
|
|
25
|
+
// If we allow Latin1 we can ignore any decoding fails
|
|
26
|
+
// and in these cases return the original string
|
|
27
|
+
return utf8string;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
throw e;
|
|
32
|
+
}
|
|
33
|
+
} // Encode to UTF-8
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
function encodeUTF8(DOMString) {
|
|
37
|
+
return unescape(encodeURIComponent(DOMString));
|
|
38
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.shrinkBuf = shrinkBuf;
|
|
7
|
+
exports.arraySet = arraySet;
|
|
8
|
+
exports.flattenChunks = flattenChunks;
|
|
9
|
+
exports.Buf32 = exports.Buf16 = exports.Buf8 = void 0;
|
|
10
|
+
|
|
11
|
+
// reduce buffer size, avoiding mem copy
|
|
12
|
+
function shrinkBuf(buf, size) {
|
|
13
|
+
if (buf.length === size) {
|
|
14
|
+
return buf;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (buf.subarray) {
|
|
18
|
+
return buf.subarray(0, size);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
buf.length = size;
|
|
22
|
+
return buf;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
;
|
|
26
|
+
|
|
27
|
+
function arraySet(dest, src, src_offs, len, dest_offs) {
|
|
28
|
+
if (src.subarray && dest.subarray) {
|
|
29
|
+
dest.set(src.subarray(src_offs, src_offs + len), dest_offs);
|
|
30
|
+
return;
|
|
31
|
+
} // Fallback to ordinary array
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
for (var i = 0; i < len; i++) {
|
|
35
|
+
dest[dest_offs + i] = src[src_offs + i];
|
|
36
|
+
}
|
|
37
|
+
} // Join array of chunks to single array.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
function flattenChunks(chunks) {
|
|
41
|
+
var i, l, len, pos, chunk, result; // calculate data length
|
|
42
|
+
|
|
43
|
+
len = 0;
|
|
44
|
+
|
|
45
|
+
for (i = 0, l = chunks.length; i < l; i++) {
|
|
46
|
+
len += chunks[i].length;
|
|
47
|
+
} // join chunks
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
result = new Uint8Array(len);
|
|
51
|
+
pos = 0;
|
|
52
|
+
|
|
53
|
+
for (i = 0, l = chunks.length; i < l; i++) {
|
|
54
|
+
chunk = chunks[i];
|
|
55
|
+
result.set(chunk, pos);
|
|
56
|
+
pos += chunk.length;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var Buf8 = Uint8Array;
|
|
63
|
+
exports.Buf8 = Buf8;
|
|
64
|
+
var Buf16 = Uint16Array;
|
|
65
|
+
exports.Buf16 = Buf16;
|
|
66
|
+
var Buf32 = Int32Array;
|
|
67
|
+
exports.Buf32 = Buf32;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = adler32;
|
|
7
|
+
|
|
8
|
+
// Note: adler32 takes 12% for level 0 and 2% for level 6.
|
|
9
|
+
// It doesn't worth to make additional optimizationa as in original.
|
|
10
|
+
// Small size is preferable.
|
|
11
|
+
function adler32(adler, buf, len, pos) {
|
|
12
|
+
var s1 = adler & 0xffff | 0,
|
|
13
|
+
s2 = adler >>> 16 & 0xffff | 0,
|
|
14
|
+
n = 0;
|
|
15
|
+
|
|
16
|
+
while (len !== 0) {
|
|
17
|
+
// Set limit ~ twice less than 5552, to keep
|
|
18
|
+
// s2 in 31-bits, because we force signed ints.
|
|
19
|
+
// in other case %= will fail.
|
|
20
|
+
n = len > 2000 ? 2000 : len;
|
|
21
|
+
len -= n;
|
|
22
|
+
|
|
23
|
+
do {
|
|
24
|
+
s1 = s1 + buf[pos++] | 0;
|
|
25
|
+
s2 = s2 + s1 | 0;
|
|
26
|
+
} while (--n);
|
|
27
|
+
|
|
28
|
+
s1 %= 65521;
|
|
29
|
+
s2 %= 65521;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return s1 | s2 << 16 | 0;
|
|
33
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
/* Allowed flush values; see deflate() and inflate() below for details */
|
|
9
|
+
Z_NO_FLUSH: 0,
|
|
10
|
+
Z_PARTIAL_FLUSH: 1,
|
|
11
|
+
Z_SYNC_FLUSH: 2,
|
|
12
|
+
Z_FULL_FLUSH: 3,
|
|
13
|
+
Z_FINISH: 4,
|
|
14
|
+
Z_BLOCK: 5,
|
|
15
|
+
Z_TREES: 6,
|
|
16
|
+
|
|
17
|
+
/* Return codes for the compression/decompression functions. Negative values
|
|
18
|
+
* are errors, positive values are used for special but normal events.
|
|
19
|
+
*/
|
|
20
|
+
Z_OK: 0,
|
|
21
|
+
Z_STREAM_END: 1,
|
|
22
|
+
Z_NEED_DICT: 2,
|
|
23
|
+
Z_ERRNO: -1,
|
|
24
|
+
Z_STREAM_ERROR: -2,
|
|
25
|
+
Z_DATA_ERROR: -3,
|
|
26
|
+
//Z_MEM_ERROR: -4,
|
|
27
|
+
Z_BUF_ERROR: -5,
|
|
28
|
+
//Z_VERSION_ERROR: -6,
|
|
29
|
+
|
|
30
|
+
/* compression levels */
|
|
31
|
+
Z_NO_COMPRESSION: 0,
|
|
32
|
+
Z_BEST_SPEED: 1,
|
|
33
|
+
Z_BEST_COMPRESSION: 9,
|
|
34
|
+
Z_DEFAULT_COMPRESSION: -1,
|
|
35
|
+
Z_FILTERED: 1,
|
|
36
|
+
Z_HUFFMAN_ONLY: 2,
|
|
37
|
+
Z_RLE: 3,
|
|
38
|
+
Z_FIXED: 4,
|
|
39
|
+
Z_DEFAULT_STRATEGY: 0,
|
|
40
|
+
|
|
41
|
+
/* Possible values of the data_type field (though see inflate()) */
|
|
42
|
+
Z_BINARY: 0,
|
|
43
|
+
Z_TEXT: 1,
|
|
44
|
+
//Z_ASCII: 1, // = Z_TEXT (deprecated)
|
|
45
|
+
Z_UNKNOWN: 2,
|
|
46
|
+
|
|
47
|
+
/* The deflate compression method */
|
|
48
|
+
Z_DEFLATED: 8 //Z_NULL: null // Use -1 or null inline, depending on var type
|
|
49
|
+
|
|
50
|
+
};
|
|
51
|
+
exports.default = _default;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = makeTable;
|
|
7
|
+
|
|
8
|
+
// Note: we can't get significant speed boost here.
|
|
9
|
+
// So write code to minimize size - no pregenerated tables
|
|
10
|
+
// and array tools dependencies.
|
|
11
|
+
// Use ordinary array, since untyped makes no boost here
|
|
12
|
+
function makeTable() {
|
|
13
|
+
var c,
|
|
14
|
+
table = [];
|
|
15
|
+
|
|
16
|
+
for (var n = 0; n < 256; n++) {
|
|
17
|
+
c = n;
|
|
18
|
+
|
|
19
|
+
for (var k = 0; k < 8; k++) {
|
|
20
|
+
c = c & 1 ? 0xEDB88320 ^ c >>> 1 : c >>> 1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
table[n] = c;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return table;
|
|
27
|
+
} // Create table on load. Just 255 signed longs. Not a problem.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var crcTable = makeTable();
|
|
31
|
+
|
|
32
|
+
function crc32(crc, buf, len, pos) {
|
|
33
|
+
var t = crcTable,
|
|
34
|
+
end = pos + len;
|
|
35
|
+
crc ^= -1;
|
|
36
|
+
|
|
37
|
+
for (var i = pos; i < end; i++) {
|
|
38
|
+
crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 0xFF];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return crc ^ -1; // >>> 0;
|
|
42
|
+
}
|