@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/package.json
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novnc/novnc",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "An HTML5 VNC client",
|
|
5
|
+
"browser": "lib/rfb",
|
|
5
6
|
"directories": {
|
|
7
|
+
"lib": "lib",
|
|
6
8
|
"doc": "docs",
|
|
7
9
|
"test": "tests"
|
|
8
10
|
},
|
|
11
|
+
"files": [
|
|
12
|
+
"lib",
|
|
13
|
+
"AUTHORS",
|
|
14
|
+
"VERSION",
|
|
15
|
+
"docs/API.md",
|
|
16
|
+
"docs/LIBRARY.md",
|
|
17
|
+
"docs/LICENSE*",
|
|
18
|
+
"core",
|
|
19
|
+
"vendor/pako"
|
|
20
|
+
],
|
|
9
21
|
"scripts": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
22
|
+
"lint": "eslint app core po/po2js po/xgettext-html tests utils",
|
|
23
|
+
"test": "karma start karma.conf.js",
|
|
24
|
+
"prepublish": "node ./utils/use_require.js --as commonjs --clean"
|
|
12
25
|
},
|
|
13
26
|
"repository": {
|
|
14
27
|
"type": "git",
|
|
@@ -27,35 +40,42 @@
|
|
|
27
40
|
},
|
|
28
41
|
"homepage": "https://github.com/novnc/noVNC",
|
|
29
42
|
"devDependencies": {
|
|
30
|
-
"babel
|
|
31
|
-
"babel
|
|
43
|
+
"@babel/core": "*",
|
|
44
|
+
"@babel/plugin-syntax-dynamic-import": "*",
|
|
45
|
+
"@babel/plugin-transform-modules-amd": "*",
|
|
46
|
+
"@babel/plugin-transform-modules-commonjs": "*",
|
|
47
|
+
"@babel/plugin-transform-modules-systemjs": "*",
|
|
48
|
+
"@babel/plugin-transform-modules-umd": "*",
|
|
49
|
+
"@babel/preset-env": "*",
|
|
50
|
+
"@babel/cli": "*",
|
|
32
51
|
"babel-plugin-import-redirect": "*",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"commander": "^2.9.0",
|
|
42
|
-
"es-module-loader": "^2.1.0",
|
|
43
|
-
"fs-extra": "^1.0.0",
|
|
52
|
+
"browserify": "*",
|
|
53
|
+
"babelify": "*",
|
|
54
|
+
"core-js": "*",
|
|
55
|
+
"chai": "*",
|
|
56
|
+
"commander": "*",
|
|
57
|
+
"es-module-loader": "*",
|
|
58
|
+
"eslint": "*",
|
|
59
|
+
"fs-extra": "*",
|
|
44
60
|
"jsdom": "*",
|
|
45
|
-
"karma": "
|
|
46
|
-
"karma-
|
|
47
|
-
"karma-
|
|
48
|
-
"karma-
|
|
49
|
-
"karma-
|
|
50
|
-
"karma-
|
|
51
|
-
"karma-
|
|
52
|
-
"
|
|
61
|
+
"karma": "*",
|
|
62
|
+
"karma-mocha": "*",
|
|
63
|
+
"karma-chrome-launcher": "*",
|
|
64
|
+
"@chiragrupani/karma-chromium-edge-launcher": "*",
|
|
65
|
+
"karma-firefox-launcher": "*",
|
|
66
|
+
"karma-ie-launcher": "*",
|
|
67
|
+
"karma-mocha-reporter": "*",
|
|
68
|
+
"karma-safari-launcher": "*",
|
|
69
|
+
"karma-script-launcher": "*",
|
|
70
|
+
"karma-sinon-chai": "*",
|
|
71
|
+
"mocha": "*",
|
|
53
72
|
"node-getopt": "*",
|
|
54
73
|
"po2json": "*",
|
|
55
|
-
"requirejs": "
|
|
56
|
-
"rollup": "
|
|
57
|
-
"rollup-plugin-node-resolve": "
|
|
58
|
-
"sinon
|
|
74
|
+
"requirejs": "*",
|
|
75
|
+
"rollup": "*",
|
|
76
|
+
"rollup-plugin-node-resolve": "*",
|
|
77
|
+
"sinon": "*",
|
|
78
|
+
"sinon-chai": "*"
|
|
59
79
|
},
|
|
60
80
|
"dependencies": {},
|
|
61
81
|
"keywords": [
|
|
@@ -9,51 +9,51 @@ import msg from "./messages.js";
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
/* Allowed flush values; see deflate() and inflate() below for details */
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
//
|
|
12
|
+
export const Z_NO_FLUSH = 0;
|
|
13
|
+
export const Z_PARTIAL_FLUSH = 1;
|
|
14
|
+
//export const Z_SYNC_FLUSH = 2;
|
|
15
|
+
export const Z_FULL_FLUSH = 3;
|
|
16
|
+
export const Z_FINISH = 4;
|
|
17
|
+
export const Z_BLOCK = 5;
|
|
18
|
+
//export const Z_TREES = 6;
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
/* Return codes for the compression/decompression functions. Negative values
|
|
22
22
|
* are errors, positive values are used for special but normal events.
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
//
|
|
24
|
+
export const Z_OK = 0;
|
|
25
|
+
export const Z_STREAM_END = 1;
|
|
26
|
+
//export const Z_NEED_DICT = 2;
|
|
27
|
+
//export const Z_ERRNO = -1;
|
|
28
|
+
export const Z_STREAM_ERROR = -2;
|
|
29
|
+
export const Z_DATA_ERROR = -3;
|
|
30
|
+
//export const Z_MEM_ERROR = -4;
|
|
31
|
+
export const Z_BUF_ERROR = -5;
|
|
32
|
+
//export const Z_VERSION_ERROR = -6;
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
/* compression levels */
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
|
|
36
|
+
//export const Z_NO_COMPRESSION = 0;
|
|
37
|
+
//export const Z_BEST_SPEED = 1;
|
|
38
|
+
//export const Z_BEST_COMPRESSION = 9;
|
|
39
|
+
export const Z_DEFAULT_COMPRESSION = -1;
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
export const Z_FILTERED = 1;
|
|
43
|
+
export const Z_HUFFMAN_ONLY = 2;
|
|
44
|
+
export const Z_RLE = 3;
|
|
45
|
+
export const Z_FIXED = 4;
|
|
46
|
+
export const Z_DEFAULT_STRATEGY = 0;
|
|
47
47
|
|
|
48
48
|
/* Possible values of the data_type field (though see inflate()) */
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
|
|
49
|
+
//export const Z_BINARY = 0;
|
|
50
|
+
//export const Z_TEXT = 1;
|
|
51
|
+
//export const Z_ASCII = 1; // = Z_TEXT
|
|
52
|
+
export const Z_UNKNOWN = 2;
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
/* The deflate compression method */
|
|
56
|
-
|
|
56
|
+
export const Z_DEFLATED = 8;
|
|
57
57
|
|
|
58
58
|
/*============================================================================*/
|
|
59
59
|
|
|
@@ -13,30 +13,30 @@ var DISTS = 2;
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
/* Allowed flush values; see deflate() and inflate() below for details */
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
//export const Z_NO_FLUSH = 0;
|
|
17
|
+
//export const Z_PARTIAL_FLUSH = 1;
|
|
18
|
+
//export const Z_SYNC_FLUSH = 2;
|
|
19
|
+
//export const Z_FULL_FLUSH = 3;
|
|
20
|
+
export const Z_FINISH = 4;
|
|
21
|
+
export const Z_BLOCK = 5;
|
|
22
|
+
export const Z_TREES = 6;
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
/* Return codes for the compression/decompression functions. Negative values
|
|
26
26
|
* are errors, positive values are used for special but normal events.
|
|
27
27
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
//
|
|
28
|
+
export const Z_OK = 0;
|
|
29
|
+
export const Z_STREAM_END = 1;
|
|
30
|
+
export const Z_NEED_DICT = 2;
|
|
31
|
+
//export const Z_ERRNO = -1;
|
|
32
|
+
export const Z_STREAM_ERROR = -2;
|
|
33
|
+
export const Z_DATA_ERROR = -3;
|
|
34
|
+
export const Z_MEM_ERROR = -4;
|
|
35
|
+
export const Z_BUF_ERROR = -5;
|
|
36
|
+
//export const Z_VERSION_ERROR = -6;
|
|
37
37
|
|
|
38
38
|
/* The deflate compression method */
|
|
39
|
-
|
|
39
|
+
export const Z_DEFLATED = 8;
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
/* STATES ====================================================================*/
|
package/core/input/mouse.js
DELETED
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* noVNC: HTML5 VNC client
|
|
3
|
-
* Copyright (C) 2012 Joel Martin
|
|
4
|
-
* Copyright (C) 2013 Samuel Mannehed for Cendio AB
|
|
5
|
-
* Licensed under MPL 2.0 or any later version (see LICENSE.txt)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import * as Log from '../util/logging.js';
|
|
9
|
-
import { isTouchDevice } from '../util/browser.js';
|
|
10
|
-
import { setCapture, stopEvent, getPointerEvent } from '../util/events.js';
|
|
11
|
-
|
|
12
|
-
var WHEEL_STEP = 10; // Delta threshold for a mouse wheel step
|
|
13
|
-
var WHEEL_STEP_TIMEOUT = 50; // ms
|
|
14
|
-
var WHEEL_LINE_HEIGHT = 19;
|
|
15
|
-
|
|
16
|
-
export default function Mouse(target) {
|
|
17
|
-
this._target = target || document;
|
|
18
|
-
|
|
19
|
-
this._doubleClickTimer = null;
|
|
20
|
-
this._lastTouchPos = null;
|
|
21
|
-
|
|
22
|
-
this._pos = null;
|
|
23
|
-
this._wheelStepXTimer = null;
|
|
24
|
-
this._wheelStepYTimer = null;
|
|
25
|
-
this._accumulatedWheelDeltaX = 0;
|
|
26
|
-
this._accumulatedWheelDeltaY = 0;
|
|
27
|
-
|
|
28
|
-
this._eventHandlers = {
|
|
29
|
-
'mousedown': this._handleMouseDown.bind(this),
|
|
30
|
-
'mouseup': this._handleMouseUp.bind(this),
|
|
31
|
-
'mousemove': this._handleMouseMove.bind(this),
|
|
32
|
-
'mousewheel': this._handleMouseWheel.bind(this),
|
|
33
|
-
'mousedisable': this._handleMouseDisable.bind(this)
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
Mouse.prototype = {
|
|
38
|
-
// ===== PROPERTIES =====
|
|
39
|
-
|
|
40
|
-
touchButton: 1, // Button mask (1, 2, 4) for touch devices (0 means ignore clicks)
|
|
41
|
-
|
|
42
|
-
// ===== EVENT HANDLERS =====
|
|
43
|
-
|
|
44
|
-
onmousebutton: function () {}, // Handler for mouse button click/release
|
|
45
|
-
onmousemove: function () {}, // Handler for mouse movement
|
|
46
|
-
|
|
47
|
-
// ===== PRIVATE METHODS =====
|
|
48
|
-
|
|
49
|
-
_resetDoubleClickTimer: function () {
|
|
50
|
-
this._doubleClickTimer = null;
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
_handleMouseButton: function (e, down) {
|
|
54
|
-
this._updateMousePosition(e);
|
|
55
|
-
var pos = this._pos;
|
|
56
|
-
|
|
57
|
-
var bmask;
|
|
58
|
-
if (e.touches || e.changedTouches) {
|
|
59
|
-
// Touch device
|
|
60
|
-
|
|
61
|
-
// When two touches occur within 500 ms of each other and are
|
|
62
|
-
// close enough together a double click is triggered.
|
|
63
|
-
if (down == 1) {
|
|
64
|
-
if (this._doubleClickTimer === null) {
|
|
65
|
-
this._lastTouchPos = pos;
|
|
66
|
-
} else {
|
|
67
|
-
clearTimeout(this._doubleClickTimer);
|
|
68
|
-
|
|
69
|
-
// When the distance between the two touches is small enough
|
|
70
|
-
// force the position of the latter touch to the position of
|
|
71
|
-
// the first.
|
|
72
|
-
|
|
73
|
-
var xs = this._lastTouchPos.x - pos.x;
|
|
74
|
-
var ys = this._lastTouchPos.y - pos.y;
|
|
75
|
-
var d = Math.sqrt((xs * xs) + (ys * ys));
|
|
76
|
-
|
|
77
|
-
// The goal is to trigger on a certain physical width, the
|
|
78
|
-
// devicePixelRatio brings us a bit closer but is not optimal.
|
|
79
|
-
var threshold = 20 * (window.devicePixelRatio || 1);
|
|
80
|
-
if (d < threshold) {
|
|
81
|
-
pos = this._lastTouchPos;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
this._doubleClickTimer = setTimeout(this._resetDoubleClickTimer.bind(this), 500);
|
|
85
|
-
}
|
|
86
|
-
bmask = this.touchButton;
|
|
87
|
-
// If bmask is set
|
|
88
|
-
} else if (e.which) {
|
|
89
|
-
/* everything except IE */
|
|
90
|
-
bmask = 1 << e.button;
|
|
91
|
-
} else {
|
|
92
|
-
/* IE including 9 */
|
|
93
|
-
bmask = (e.button & 0x1) + // Left
|
|
94
|
-
(e.button & 0x2) * 2 + // Right
|
|
95
|
-
(e.button & 0x4) / 2; // Middle
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
Log.Debug("onmousebutton " + (down ? "down" : "up") +
|
|
99
|
-
", x: " + pos.x + ", y: " + pos.y + ", bmask: " + bmask);
|
|
100
|
-
this.onmousebutton(pos.x, pos.y, down, bmask);
|
|
101
|
-
|
|
102
|
-
stopEvent(e);
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
_handleMouseDown: function (e) {
|
|
106
|
-
// Touch events have implicit capture
|
|
107
|
-
if (e.type === "mousedown") {
|
|
108
|
-
setCapture(this._target);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
this._handleMouseButton(e, 1);
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
_handleMouseUp: function (e) {
|
|
115
|
-
this._handleMouseButton(e, 0);
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
// Mouse wheel events are sent in steps over VNC. This means that the VNC
|
|
119
|
-
// protocol can't handle a wheel event with specific distance or speed.
|
|
120
|
-
// Therefor, if we get a lot of small mouse wheel events we combine them.
|
|
121
|
-
_generateWheelStepX: function () {
|
|
122
|
-
|
|
123
|
-
if (this._accumulatedWheelDeltaX < 0) {
|
|
124
|
-
this.onmousebutton(this._pos.x, this._pos.y, 1, 1 << 5);
|
|
125
|
-
this.onmousebutton(this._pos.x, this._pos.y, 0, 1 << 5);
|
|
126
|
-
} else if (this._accumulatedWheelDeltaX > 0) {
|
|
127
|
-
this.onmousebutton(this._pos.x, this._pos.y, 1, 1 << 6);
|
|
128
|
-
this.onmousebutton(this._pos.x, this._pos.y, 0, 1 << 6);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
this._accumulatedWheelDeltaX = 0;
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
_generateWheelStepY: function () {
|
|
135
|
-
|
|
136
|
-
if (this._accumulatedWheelDeltaY < 0) {
|
|
137
|
-
this.onmousebutton(this._pos.x, this._pos.y, 1, 1 << 3);
|
|
138
|
-
this.onmousebutton(this._pos.x, this._pos.y, 0, 1 << 3);
|
|
139
|
-
} else if (this._accumulatedWheelDeltaY > 0) {
|
|
140
|
-
this.onmousebutton(this._pos.x, this._pos.y, 1, 1 << 4);
|
|
141
|
-
this.onmousebutton(this._pos.x, this._pos.y, 0, 1 << 4);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
this._accumulatedWheelDeltaY = 0;
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
-
_resetWheelStepTimers: function () {
|
|
148
|
-
window.clearTimeout(this._wheelStepXTimer);
|
|
149
|
-
window.clearTimeout(this._wheelStepYTimer);
|
|
150
|
-
this._wheelStepXTimer = null;
|
|
151
|
-
this._wheelStepYTimer = null;
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
_handleMouseWheel: function (e) {
|
|
155
|
-
this._resetWheelStepTimers();
|
|
156
|
-
|
|
157
|
-
this._updateMousePosition(e);
|
|
158
|
-
|
|
159
|
-
var dX = e.deltaX;
|
|
160
|
-
var dY = e.deltaY;
|
|
161
|
-
|
|
162
|
-
// Pixel units unless it's non-zero.
|
|
163
|
-
// Note that if deltamode is line or page won't matter since we aren't
|
|
164
|
-
// sending the mouse wheel delta to the server anyway.
|
|
165
|
-
// The difference between pixel and line can be important however since
|
|
166
|
-
// we have a threshold that can be smaller than the line height.
|
|
167
|
-
if (e.deltaMode !== 0) {
|
|
168
|
-
dX *= WHEEL_LINE_HEIGHT;
|
|
169
|
-
dY *= WHEEL_LINE_HEIGHT;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
this._accumulatedWheelDeltaX += dX;
|
|
173
|
-
this._accumulatedWheelDeltaY += dY;
|
|
174
|
-
|
|
175
|
-
// Generate a mouse wheel step event when the accumulated delta
|
|
176
|
-
// for one of the axes is large enough.
|
|
177
|
-
// Small delta events that do not pass the threshold get sent
|
|
178
|
-
// after a timeout.
|
|
179
|
-
if (Math.abs(this._accumulatedWheelDeltaX) > WHEEL_STEP) {
|
|
180
|
-
this._generateWheelStepX();
|
|
181
|
-
} else {
|
|
182
|
-
this._wheelStepXTimer =
|
|
183
|
-
window.setTimeout(this._generateWheelStepX.bind(this),
|
|
184
|
-
WHEEL_STEP_TIMEOUT);
|
|
185
|
-
}
|
|
186
|
-
if (Math.abs(this._accumulatedWheelDeltaY) > WHEEL_STEP) {
|
|
187
|
-
this._generateWheelStepY();
|
|
188
|
-
} else {
|
|
189
|
-
this._wheelStepYTimer =
|
|
190
|
-
window.setTimeout(this._generateWheelStepY.bind(this),
|
|
191
|
-
WHEEL_STEP_TIMEOUT);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
stopEvent(e);
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
_handleMouseMove: function (e) {
|
|
198
|
-
this._updateMousePosition(e);
|
|
199
|
-
this.onmousemove(this._pos.x, this._pos.y);
|
|
200
|
-
stopEvent(e);
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
_handleMouseDisable: function (e) {
|
|
204
|
-
/*
|
|
205
|
-
* Stop propagation if inside canvas area
|
|
206
|
-
* Note: This is only needed for the 'click' event as it fails
|
|
207
|
-
* to fire properly for the target element so we have
|
|
208
|
-
* to listen on the document element instead.
|
|
209
|
-
*/
|
|
210
|
-
if (e.target == this._target) {
|
|
211
|
-
stopEvent(e);
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
|
-
|
|
215
|
-
// Update coordinates relative to target
|
|
216
|
-
_updateMousePosition: function(e) {
|
|
217
|
-
e = getPointerEvent(e);
|
|
218
|
-
var bounds = this._target.getBoundingClientRect();
|
|
219
|
-
var x, y;
|
|
220
|
-
// Clip to target bounds
|
|
221
|
-
if (e.clientX < bounds.left) {
|
|
222
|
-
x = 0;
|
|
223
|
-
} else if (e.clientX >= bounds.right) {
|
|
224
|
-
x = bounds.width - 1;
|
|
225
|
-
} else {
|
|
226
|
-
x = e.clientX - bounds.left;
|
|
227
|
-
}
|
|
228
|
-
if (e.clientY < bounds.top) {
|
|
229
|
-
y = 0;
|
|
230
|
-
} else if (e.clientY >= bounds.bottom) {
|
|
231
|
-
y = bounds.height - 1;
|
|
232
|
-
} else {
|
|
233
|
-
y = e.clientY - bounds.top;
|
|
234
|
-
}
|
|
235
|
-
this._pos = {x:x, y:y};
|
|
236
|
-
},
|
|
237
|
-
|
|
238
|
-
// ===== PUBLIC METHODS =====
|
|
239
|
-
|
|
240
|
-
grab: function () {
|
|
241
|
-
var c = this._target;
|
|
242
|
-
|
|
243
|
-
if (isTouchDevice) {
|
|
244
|
-
c.addEventListener('touchstart', this._eventHandlers.mousedown);
|
|
245
|
-
c.addEventListener('touchend', this._eventHandlers.mouseup);
|
|
246
|
-
c.addEventListener('touchmove', this._eventHandlers.mousemove);
|
|
247
|
-
}
|
|
248
|
-
c.addEventListener('mousedown', this._eventHandlers.mousedown);
|
|
249
|
-
c.addEventListener('mouseup', this._eventHandlers.mouseup);
|
|
250
|
-
c.addEventListener('mousemove', this._eventHandlers.mousemove);
|
|
251
|
-
c.addEventListener('wheel', this._eventHandlers.mousewheel);
|
|
252
|
-
|
|
253
|
-
/* Prevent middle-click pasting (see above for why we bind to document) */
|
|
254
|
-
document.addEventListener('click', this._eventHandlers.mousedisable);
|
|
255
|
-
|
|
256
|
-
/* preventDefault() on mousedown doesn't stop this event for some
|
|
257
|
-
reason so we have to explicitly block it */
|
|
258
|
-
c.addEventListener('contextmenu', this._eventHandlers.mousedisable);
|
|
259
|
-
},
|
|
260
|
-
|
|
261
|
-
ungrab: function () {
|
|
262
|
-
var c = this._target;
|
|
263
|
-
|
|
264
|
-
this._resetWheelStepTimers();
|
|
265
|
-
|
|
266
|
-
if (isTouchDevice) {
|
|
267
|
-
c.removeEventListener('touchstart', this._eventHandlers.mousedown);
|
|
268
|
-
c.removeEventListener('touchend', this._eventHandlers.mouseup);
|
|
269
|
-
c.removeEventListener('touchmove', this._eventHandlers.mousemove);
|
|
270
|
-
}
|
|
271
|
-
c.removeEventListener('mousedown', this._eventHandlers.mousedown);
|
|
272
|
-
c.removeEventListener('mouseup', this._eventHandlers.mouseup);
|
|
273
|
-
c.removeEventListener('mousemove', this._eventHandlers.mousemove);
|
|
274
|
-
c.removeEventListener('wheel', this._eventHandlers.mousewheel);
|
|
275
|
-
|
|
276
|
-
document.removeEventListener('click', this._eventHandlers.mousedisable);
|
|
277
|
-
|
|
278
|
-
c.removeEventListener('contextmenu', this._eventHandlers.mousedisable);
|
|
279
|
-
}
|
|
280
|
-
};
|
package/docs/API-internal.md
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
# 1. Internal Modules
|
|
2
|
-
|
|
3
|
-
The noVNC client is composed of several internal modules that handle
|
|
4
|
-
rendering, input, networking, etc. Each of the modules is designed to
|
|
5
|
-
be cross-browser and independent from each other.
|
|
6
|
-
|
|
7
|
-
Note however that the API of these modules is not guaranteed to be
|
|
8
|
-
stable, and this documentation is not maintained as well as the
|
|
9
|
-
official external API.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## 1.1 Module List
|
|
13
|
-
|
|
14
|
-
* __Mouse__ (core/input/mouse.js): Mouse input event handler with
|
|
15
|
-
limited touch support.
|
|
16
|
-
|
|
17
|
-
* __Keyboard__ (core/input/keyboard.js): Keyboard input event handler with
|
|
18
|
-
non-US keyboard support. Translates keyDown and keyUp events to X11
|
|
19
|
-
keysym values.
|
|
20
|
-
|
|
21
|
-
* __Display__ (core/display.js): Efficient 2D rendering abstraction
|
|
22
|
-
layered on the HTML5 canvas element.
|
|
23
|
-
|
|
24
|
-
* __Websock__ (core/websock.js): Websock client from websockify
|
|
25
|
-
with transparent binary data support.
|
|
26
|
-
[Websock API](https://github.com/novnc/websockify/wiki/websock.js) wiki page.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
## 1.2 Callbacks
|
|
30
|
-
|
|
31
|
-
For the Mouse, Keyboard and Display objects the callback functions are
|
|
32
|
-
assigned to configuration attributes, just as for the RFB object. The
|
|
33
|
-
WebSock module has a method named 'on' that takes two parameters: the
|
|
34
|
-
callback event name, and the callback function.
|
|
35
|
-
|
|
36
|
-
## 2. Modules
|
|
37
|
-
|
|
38
|
-
## 2.1 Mouse Module
|
|
39
|
-
|
|
40
|
-
### 2.1.1 Configuration Attributes
|
|
41
|
-
|
|
42
|
-
| name | type | mode | default | description
|
|
43
|
-
| ----------- | ---- | ---- | -------- | ------------
|
|
44
|
-
| touchButton | int | RW | 1 | Button mask (1, 2, 4) for which click to send on touch devices. 0 means ignore clicks.
|
|
45
|
-
|
|
46
|
-
### 2.1.2 Methods
|
|
47
|
-
|
|
48
|
-
| name | parameters | description
|
|
49
|
-
| ------ | ---------- | ------------
|
|
50
|
-
| grab | () | Begin capturing mouse events
|
|
51
|
-
| ungrab | () | Stop capturing mouse events
|
|
52
|
-
|
|
53
|
-
### 2.1.2 Callbacks
|
|
54
|
-
|
|
55
|
-
| name | parameters | description
|
|
56
|
-
| ------------- | ------------------- | ------------
|
|
57
|
-
| onmousebutton | (x, y, down, bmask) | Handler for mouse button click/release
|
|
58
|
-
| onmousemove | (x, y) | Handler for mouse movement
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
## 2.2 Keyboard Module
|
|
62
|
-
|
|
63
|
-
### 2.2.1 Configuration Attributes
|
|
64
|
-
|
|
65
|
-
None
|
|
66
|
-
|
|
67
|
-
### 2.2.2 Methods
|
|
68
|
-
|
|
69
|
-
| name | parameters | description
|
|
70
|
-
| ------ | ---------- | ------------
|
|
71
|
-
| grab | () | Begin capturing keyboard events
|
|
72
|
-
| ungrab | () | Stop capturing keyboard events
|
|
73
|
-
|
|
74
|
-
### 2.2.3 Callbacks
|
|
75
|
-
|
|
76
|
-
| name | parameters | description
|
|
77
|
-
| ---------- | -------------------- | ------------
|
|
78
|
-
| onkeypress | (keysym, code, down) | Handler for key press/release
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
## 2.3 Display Module
|
|
82
|
-
|
|
83
|
-
### 2.3.1 Configuration Attributes
|
|
84
|
-
|
|
85
|
-
| name | type | mode | default | description
|
|
86
|
-
| ------------ | ----- | ---- | ------- | ------------
|
|
87
|
-
| logo | raw | RW | | Logo to display when cleared: {"width": width, "height": height, "type": mime-type, "data": data}
|
|
88
|
-
| scale | float | RW | 1.0 | Display area scale factor 0.0 - 1.0
|
|
89
|
-
| clipViewport | bool | RW | false | Use viewport clipping
|
|
90
|
-
| width | int | RO | | Display area width
|
|
91
|
-
| height | int | RO | | Display area height
|
|
92
|
-
|
|
93
|
-
### 2.3.2 Methods
|
|
94
|
-
|
|
95
|
-
| name | parameters | description
|
|
96
|
-
| ------------------ | ------------------------------------------------------- | ------------
|
|
97
|
-
| viewportChangePos | (deltaX, deltaY) | Move the viewport relative to the current location
|
|
98
|
-
| viewportChangeSize | (width, height) | Change size of the viewport
|
|
99
|
-
| absX | (x) | Return X relative to the remote display
|
|
100
|
-
| absY | (y) | Return Y relative to the remote display
|
|
101
|
-
| resize | (width, height) | Set width and height
|
|
102
|
-
| flip | (from_queue) | Update the visible canvas with the contents of the rendering canvas
|
|
103
|
-
| clear | () | Clear the display (show logo if set)
|
|
104
|
-
| pending | () | Check if there are waiting items in the render queue
|
|
105
|
-
| flush | () | Resume processing the render queue unless it's empty
|
|
106
|
-
| fillRect | (x, y, width, height, color, from_queue) | Draw a filled in rectangle
|
|
107
|
-
| copyImage | (old_x, old_y, new_x, new_y, width, height, from_queue) | Copy a rectangular area
|
|
108
|
-
| imageRect | (x, y, mime, arr) | Draw a rectangle with an image
|
|
109
|
-
| startTile | (x, y, width, height, color) | Begin updating a tile
|
|
110
|
-
| subTile | (tile, x, y, w, h, color) | Update a sub-rectangle within the given tile
|
|
111
|
-
| finishTile | () | Draw the current tile to the display
|
|
112
|
-
| blitImage | (x, y, width, height, arr, offset, from_queue) | Blit pixels (of R,G,B,A) to the display
|
|
113
|
-
| blitRgbImage | (x, y, width, height, arr, offset, from_queue) | Blit RGB encoded image to display
|
|
114
|
-
| blitRgbxImage | (x, y, width, height, arr, offset, from_queue) | Blit RGBX encoded image to display
|
|
115
|
-
| drawImage | (img, x, y) | Draw image and track damage
|
|
116
|
-
| changeCursor | (pixels, mask, hotx, hoty, w, h) | Change cursor appearance
|
|
117
|
-
| defaultCursor | () | Restore default cursor appearance
|
|
118
|
-
| disableLocalCursor | () | Disable local (client-side) cursor
|
|
119
|
-
| autoscale | (containerWidth, containerHeight) | Scale the display
|
|
120
|
-
|
|
121
|
-
### 2.3.3 Callbacks
|
|
122
|
-
|
|
123
|
-
| name | parameters | description
|
|
124
|
-
| ------- | ---------- | ------------
|
|
125
|
-
| onflush | () | A display flush has been requested and we are now ready to resume FBU processing
|