@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.
- package/LICENSE.txt +0 -6
- package/README.md +16 -6
- package/core/decoders/copyrect.js +5 -0
- package/core/decoders/hextile.js +57 -3
- package/core/decoders/jpeg.js +141 -0
- package/core/decoders/raw.js +12 -2
- package/core/decoders/tight.js +24 -8
- package/core/decoders/zrle.js +185 -0
- package/core/display.js +21 -151
- package/core/encodings.js +4 -0
- package/core/input/domkeytable.js +25 -21
- package/core/input/keyboard.js +22 -127
- package/core/input/util.js +18 -35
- package/core/input/vkeys.js +0 -1
- package/core/input/xtscancodes.js +5 -3
- package/core/ra2.js +567 -0
- package/core/rfb.js +487 -171
- package/core/util/browser.js +0 -17
- package/core/util/cursor.js +1 -11
- package/core/util/events.js +0 -4
- package/core/util/md5.js +79 -0
- package/core/websock.js +76 -17
- package/docs/API.md +107 -6
- package/docs/LIBRARY.md +3 -7
- package/lib/base64.js +24 -38
- package/lib/decoders/copyrect.js +6 -11
- package/lib/decoders/hextile.js +68 -44
- package/lib/decoders/jpeg.js +146 -0
- package/lib/decoders/raw.js +14 -21
- package/lib/decoders/rre.js +3 -17
- package/lib/decoders/tight.js +43 -93
- package/lib/decoders/tightpng.js +11 -33
- package/lib/decoders/zrle.js +185 -0
- package/lib/deflator.js +9 -26
- package/lib/des.js +22 -38
- package/lib/display.js +100 -315
- package/lib/encodings.js +7 -8
- package/lib/inflator.js +6 -22
- package/lib/input/domkeytable.js +240 -208
- package/lib/input/fixedkeys.js +10 -5
- package/lib/input/gesturehandler.js +84 -154
- package/lib/input/keyboard.js +87 -238
- package/lib/input/keysym.js +16 -272
- package/lib/input/keysymdef.js +7 -9
- package/lib/input/util.js +69 -156
- package/lib/input/vkeys.js +2 -7
- package/lib/input/xtscancodes.js +10 -171
- package/lib/ra2.js +1033 -0
- package/lib/rfb.js +947 -1149
- package/lib/util/browser.js +25 -52
- package/lib/util/cursor.js +25 -81
- package/lib/util/element.js +3 -5
- package/lib/util/events.js +26 -35
- package/lib/util/eventtarget.js +4 -16
- package/lib/util/int.js +2 -3
- package/lib/util/logging.js +3 -21
- package/lib/util/md5.js +83 -0
- package/lib/util/strings.js +3 -5
- package/lib/vendor/pako/lib/utils/common.js +10 -19
- package/lib/vendor/pako/lib/zlib/adler32.js +4 -8
- package/lib/vendor/pako/lib/zlib/constants.js +4 -7
- package/lib/vendor/pako/lib/zlib/crc32.js +6 -13
- package/lib/vendor/pako/lib/zlib/deflate.js +304 -708
- package/lib/vendor/pako/lib/zlib/gzheader.js +2 -14
- package/lib/vendor/pako/lib/zlib/inffast.js +61 -177
- package/lib/vendor/pako/lib/zlib/inflate.js +421 -909
- package/lib/vendor/pako/lib/zlib/inftrees.js +66 -172
- package/lib/vendor/pako/lib/zlib/messages.js +3 -13
- package/lib/vendor/pako/lib/zlib/trees.js +250 -592
- package/lib/vendor/pako/lib/zlib/zstream.js +3 -19
- package/lib/websock.js +119 -111
- package/package.json +2 -10
- package/core/util/polyfill.js +0 -61
- package/lib/util/polyfill.js +0 -72
- package/lib/vendor/promise.js +0 -255
package/lib/util/browser.js
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
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.
|
|
9
|
-
exports.
|
|
7
|
+
exports.hasScrollbarGutter = exports.dragThreshold = void 0;
|
|
8
|
+
exports.isFirefox = isFirefox;
|
|
10
9
|
exports.isIOS = isIOS;
|
|
10
|
+
exports.isMac = isMac;
|
|
11
11
|
exports.isSafari = isSafari;
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
exports.hasScrollbarGutter = exports.supportsImageMetadata = exports.supportsCursorURIs = exports.dragThreshold = exports.isTouchDevice = void 0;
|
|
16
|
-
|
|
12
|
+
exports.isTouchDevice = void 0;
|
|
13
|
+
exports.isWindows = isWindows;
|
|
14
|
+
exports.supportsCursorURIs = void 0;
|
|
17
15
|
var Log = _interopRequireWildcard(require("./logging.js"));
|
|
18
|
-
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
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; }
|
|
22
|
-
|
|
16
|
+
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); }
|
|
17
|
+
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; }
|
|
23
18
|
/*
|
|
24
19
|
* noVNC: HTML5 VNC client
|
|
25
20
|
* Copyright (C) 2019 The noVNC Authors
|
|
@@ -29,25 +24,27 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
29
24
|
*
|
|
30
25
|
* Browser feature support detection
|
|
31
26
|
*/
|
|
27
|
+
|
|
32
28
|
// Touch detection
|
|
33
|
-
var isTouchDevice = 'ontouchstart' in document.documentElement ||
|
|
34
|
-
|
|
29
|
+
var isTouchDevice = 'ontouchstart' in document.documentElement ||
|
|
30
|
+
// requried for Chrome debugger
|
|
31
|
+
document.ontouchstart !== undefined ||
|
|
32
|
+
// required for MS Surface
|
|
35
33
|
navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
|
|
36
34
|
exports.isTouchDevice = isTouchDevice;
|
|
37
35
|
window.addEventListener('touchstart', function onFirstTouch() {
|
|
38
36
|
exports.isTouchDevice = isTouchDevice = true;
|
|
39
37
|
window.removeEventListener('touchstart', onFirstTouch, false);
|
|
40
|
-
}, false);
|
|
41
|
-
// brings us a bit closer but is not optimal.
|
|
38
|
+
}, false);
|
|
42
39
|
|
|
40
|
+
// The goal is to find a certain physical width, the devicePixelRatio
|
|
41
|
+
// brings us a bit closer but is not optimal.
|
|
43
42
|
var dragThreshold = 10 * (window.devicePixelRatio || 1);
|
|
44
43
|
exports.dragThreshold = dragThreshold;
|
|
45
44
|
var _supportsCursorURIs = false;
|
|
46
|
-
|
|
47
45
|
try {
|
|
48
46
|
var target = document.createElement('canvas');
|
|
49
47
|
target.style.cursor = 'url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default';
|
|
50
|
-
|
|
51
48
|
if (target.style.cursor.indexOf("url") === 0) {
|
|
52
49
|
Log.Info("Data URI scheme cursor supported");
|
|
53
50
|
_supportsCursorURIs = true;
|
|
@@ -57,75 +54,51 @@ try {
|
|
|
57
54
|
} catch (exc) {
|
|
58
55
|
Log.Error("Data URI scheme cursor test exception: " + exc);
|
|
59
56
|
}
|
|
60
|
-
|
|
61
57
|
var supportsCursorURIs = _supportsCursorURIs;
|
|
62
58
|
exports.supportsCursorURIs = supportsCursorURIs;
|
|
63
|
-
var _supportsImageMetadata = false;
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
new ImageData(new Uint8ClampedArray(4), 1, 1);
|
|
67
|
-
_supportsImageMetadata = true;
|
|
68
|
-
} catch (ex) {// ignore failure
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
var supportsImageMetadata = _supportsImageMetadata;
|
|
72
|
-
exports.supportsImageMetadata = supportsImageMetadata;
|
|
73
59
|
var _hasScrollbarGutter = true;
|
|
74
|
-
|
|
75
60
|
try {
|
|
76
61
|
// Create invisible container
|
|
77
62
|
var container = document.createElement('div');
|
|
78
63
|
container.style.visibility = 'hidden';
|
|
79
64
|
container.style.overflow = 'scroll'; // forcing scrollbars
|
|
65
|
+
document.body.appendChild(container);
|
|
80
66
|
|
|
81
|
-
|
|
82
|
-
|
|
67
|
+
// Create a div and place it in the container
|
|
83
68
|
var child = document.createElement('div');
|
|
84
|
-
container.appendChild(child);
|
|
85
|
-
// and the child's width - the difference is the scrollbars
|
|
69
|
+
container.appendChild(child);
|
|
86
70
|
|
|
87
|
-
|
|
71
|
+
// Calculate the difference between the container's full width
|
|
72
|
+
// and the child's width - the difference is the scrollbars
|
|
73
|
+
var scrollbarWidth = container.offsetWidth - child.offsetWidth;
|
|
88
74
|
|
|
75
|
+
// Clean up
|
|
89
76
|
container.parentNode.removeChild(container);
|
|
90
77
|
_hasScrollbarGutter = scrollbarWidth != 0;
|
|
91
78
|
} catch (exc) {
|
|
92
79
|
Log.Error("Scrollbar test exception: " + exc);
|
|
93
80
|
}
|
|
94
|
-
|
|
95
81
|
var hasScrollbarGutter = _hasScrollbarGutter;
|
|
82
|
+
|
|
96
83
|
/*
|
|
97
84
|
* The functions for detection of platforms and browsers below are exported
|
|
98
85
|
* but the use of these should be minimized as much as possible.
|
|
99
86
|
*
|
|
100
87
|
* It's better to use feature detection than platform detection.
|
|
101
88
|
*/
|
|
102
|
-
|
|
103
89
|
exports.hasScrollbarGutter = hasScrollbarGutter;
|
|
104
|
-
|
|
105
90
|
function isMac() {
|
|
106
91
|
return navigator && !!/mac/i.exec(navigator.platform);
|
|
107
92
|
}
|
|
108
|
-
|
|
109
93
|
function isWindows() {
|
|
110
94
|
return navigator && !!/win/i.exec(navigator.platform);
|
|
111
95
|
}
|
|
112
|
-
|
|
113
96
|
function isIOS() {
|
|
114
97
|
return navigator && (!!/ipad/i.exec(navigator.platform) || !!/iphone/i.exec(navigator.platform) || !!/ipod/i.exec(navigator.platform));
|
|
115
98
|
}
|
|
116
|
-
|
|
117
99
|
function isSafari() {
|
|
118
100
|
return navigator && navigator.userAgent.indexOf('Safari') !== -1 && navigator.userAgent.indexOf('Chrome') === -1;
|
|
119
101
|
}
|
|
120
|
-
|
|
121
|
-
function isIE() {
|
|
122
|
-
return navigator && !!/trident/i.exec(navigator.userAgent);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function isEdge() {
|
|
126
|
-
return navigator && !!/edge/i.exec(navigator.userAgent);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
102
|
function isFirefox() {
|
|
130
103
|
return navigator && !!/firefox/i.exec(navigator.userAgent);
|
|
131
104
|
}
|
package/lib/util/cursor.js
CHANGED
|
@@ -3,33 +3,24 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
6
|
+
exports["default"] = void 0;
|
|
8
7
|
var _browser = require("./browser.js");
|
|
9
|
-
|
|
10
8
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
-
|
|
12
9
|
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); } }
|
|
13
|
-
|
|
14
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
15
|
-
|
|
10
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
16
11
|
var useFallback = !_browser.supportsCursorURIs || _browser.isTouchDevice;
|
|
17
|
-
|
|
18
12
|
var Cursor = /*#__PURE__*/function () {
|
|
19
13
|
function Cursor() {
|
|
20
14
|
_classCallCheck(this, Cursor);
|
|
21
|
-
|
|
22
15
|
this._target = null;
|
|
23
16
|
this._canvas = document.createElement('canvas');
|
|
24
|
-
|
|
25
17
|
if (useFallback) {
|
|
26
18
|
this._canvas.style.position = 'fixed';
|
|
27
19
|
this._canvas.style.zIndex = '65535';
|
|
28
|
-
this._canvas.style.pointerEvents = 'none';
|
|
29
|
-
|
|
20
|
+
this._canvas.style.pointerEvents = 'none';
|
|
21
|
+
// Can't use "display" because of Firefox bug #1445997
|
|
30
22
|
this._canvas.style.visibility = 'hidden';
|
|
31
23
|
}
|
|
32
|
-
|
|
33
24
|
this._position = {
|
|
34
25
|
x: 0,
|
|
35
26
|
y: 0
|
|
@@ -45,35 +36,24 @@ var Cursor = /*#__PURE__*/function () {
|
|
|
45
36
|
'mouseup': this._handleMouseUp.bind(this)
|
|
46
37
|
};
|
|
47
38
|
}
|
|
48
|
-
|
|
49
39
|
_createClass(Cursor, [{
|
|
50
40
|
key: "attach",
|
|
51
41
|
value: function attach(target) {
|
|
52
42
|
if (this._target) {
|
|
53
43
|
this.detach();
|
|
54
44
|
}
|
|
55
|
-
|
|
56
45
|
this._target = target;
|
|
57
|
-
|
|
58
46
|
if (useFallback) {
|
|
59
|
-
document.body.appendChild(this._canvas);
|
|
60
|
-
/// movement in IE. We want to also capture element
|
|
61
|
-
// movement, size changes, visibility, etc.
|
|
62
|
-
|
|
47
|
+
document.body.appendChild(this._canvas);
|
|
63
48
|
var options = {
|
|
64
49
|
capture: true,
|
|
65
50
|
passive: true
|
|
66
51
|
};
|
|
67
|
-
|
|
68
52
|
this._target.addEventListener('mouseover', this._eventHandlers.mouseover, options);
|
|
69
|
-
|
|
70
53
|
this._target.addEventListener('mouseleave', this._eventHandlers.mouseleave, options);
|
|
71
|
-
|
|
72
54
|
this._target.addEventListener('mousemove', this._eventHandlers.mousemove, options);
|
|
73
|
-
|
|
74
55
|
this._target.addEventListener('mouseup', this._eventHandlers.mouseup, options);
|
|
75
56
|
}
|
|
76
|
-
|
|
77
57
|
this.clear();
|
|
78
58
|
}
|
|
79
59
|
}, {
|
|
@@ -82,24 +62,17 @@ var Cursor = /*#__PURE__*/function () {
|
|
|
82
62
|
if (!this._target) {
|
|
83
63
|
return;
|
|
84
64
|
}
|
|
85
|
-
|
|
86
65
|
if (useFallback) {
|
|
87
66
|
var options = {
|
|
88
67
|
capture: true,
|
|
89
68
|
passive: true
|
|
90
69
|
};
|
|
91
|
-
|
|
92
70
|
this._target.removeEventListener('mouseover', this._eventHandlers.mouseover, options);
|
|
93
|
-
|
|
94
71
|
this._target.removeEventListener('mouseleave', this._eventHandlers.mouseleave, options);
|
|
95
|
-
|
|
96
72
|
this._target.removeEventListener('mousemove', this._eventHandlers.mousemove, options);
|
|
97
|
-
|
|
98
73
|
this._target.removeEventListener('mouseup', this._eventHandlers.mouseup, options);
|
|
99
|
-
|
|
100
74
|
document.body.removeChild(this._canvas);
|
|
101
75
|
}
|
|
102
|
-
|
|
103
76
|
this._target = null;
|
|
104
77
|
}
|
|
105
78
|
}, {
|
|
@@ -109,34 +82,20 @@ var Cursor = /*#__PURE__*/function () {
|
|
|
109
82
|
this.clear();
|
|
110
83
|
return;
|
|
111
84
|
}
|
|
112
|
-
|
|
113
85
|
this._position.x = this._position.x + this._hotSpot.x - hotx;
|
|
114
86
|
this._position.y = this._position.y + this._hotSpot.y - hoty;
|
|
115
87
|
this._hotSpot.x = hotx;
|
|
116
88
|
this._hotSpot.y = hoty;
|
|
117
|
-
|
|
118
89
|
var ctx = this._canvas.getContext('2d');
|
|
119
|
-
|
|
120
90
|
this._canvas.width = w;
|
|
121
91
|
this._canvas.height = h;
|
|
122
|
-
var img;
|
|
123
|
-
|
|
124
|
-
try {
|
|
125
|
-
// IE doesn't support this
|
|
126
|
-
img = new ImageData(new Uint8ClampedArray(rgba), w, h);
|
|
127
|
-
} catch (ex) {
|
|
128
|
-
img = ctx.createImageData(w, h);
|
|
129
|
-
img.data.set(new Uint8ClampedArray(rgba));
|
|
130
|
-
}
|
|
131
|
-
|
|
92
|
+
var img = new ImageData(new Uint8ClampedArray(rgba), w, h);
|
|
132
93
|
ctx.clearRect(0, 0, w, h);
|
|
133
94
|
ctx.putImageData(img, 0, 0);
|
|
134
|
-
|
|
135
95
|
if (useFallback) {
|
|
136
96
|
this._updatePosition();
|
|
137
97
|
} else {
|
|
138
98
|
var url = this._canvas.toDataURL();
|
|
139
|
-
|
|
140
99
|
this._target.style.cursor = 'url(' + url + ')' + hotx + ' ' + hoty + ', default';
|
|
141
100
|
}
|
|
142
101
|
}
|
|
@@ -150,19 +109,19 @@ var Cursor = /*#__PURE__*/function () {
|
|
|
150
109
|
this._position.y = this._position.y + this._hotSpot.y;
|
|
151
110
|
this._hotSpot.x = 0;
|
|
152
111
|
this._hotSpot.y = 0;
|
|
153
|
-
}
|
|
154
|
-
// moving the cursor in such cases
|
|
112
|
+
}
|
|
155
113
|
|
|
114
|
+
// Mouse events might be emulated, this allows
|
|
115
|
+
// moving the cursor in such cases
|
|
156
116
|
}, {
|
|
157
117
|
key: "move",
|
|
158
118
|
value: function move(clientX, clientY) {
|
|
159
119
|
if (!useFallback) {
|
|
160
120
|
return;
|
|
161
|
-
}
|
|
121
|
+
}
|
|
122
|
+
// clientX/clientY are relative the _visual viewport_,
|
|
162
123
|
// but our position is relative the _layout viewport_,
|
|
163
124
|
// so try to compensate when we can
|
|
164
|
-
|
|
165
|
-
|
|
166
125
|
if (window.visualViewport) {
|
|
167
126
|
this._position.x = clientX + window.visualViewport.offsetLeft;
|
|
168
127
|
this._position.y = clientY + window.visualViewport.offsetTop;
|
|
@@ -170,11 +129,8 @@ var Cursor = /*#__PURE__*/function () {
|
|
|
170
129
|
this._position.x = clientX;
|
|
171
130
|
this._position.y = clientY;
|
|
172
131
|
}
|
|
173
|
-
|
|
174
132
|
this._updatePosition();
|
|
175
|
-
|
|
176
133
|
var target = document.elementFromPoint(clientX, clientY);
|
|
177
|
-
|
|
178
134
|
this._updateVisibility(target);
|
|
179
135
|
}
|
|
180
136
|
}, {
|
|
@@ -195,23 +151,21 @@ var Cursor = /*#__PURE__*/function () {
|
|
|
195
151
|
key: "_handleMouseMove",
|
|
196
152
|
value: function _handleMouseMove(event) {
|
|
197
153
|
this._updateVisibility(event.target);
|
|
198
|
-
|
|
199
154
|
this._position.x = event.clientX - this._hotSpot.x;
|
|
200
155
|
this._position.y = event.clientY - this._hotSpot.y;
|
|
201
|
-
|
|
202
156
|
this._updatePosition();
|
|
203
157
|
}
|
|
204
158
|
}, {
|
|
205
159
|
key: "_handleMouseUp",
|
|
206
160
|
value: function _handleMouseUp(event) {
|
|
207
161
|
var _this = this;
|
|
208
|
-
|
|
209
162
|
// We might get this event because of a drag operation that
|
|
210
163
|
// moved outside of the target. Check what's under the cursor
|
|
211
164
|
// now and adjust visibility based on that.
|
|
212
165
|
var target = document.elementFromPoint(event.clientX, event.clientY);
|
|
166
|
+
this._updateVisibility(target);
|
|
213
167
|
|
|
214
|
-
|
|
168
|
+
// Captures end with a mouseup but we can't know the event order of
|
|
215
169
|
// mouseup vs releaseCapture.
|
|
216
170
|
//
|
|
217
171
|
// In the cases when releaseCapture comes first, the code above is
|
|
@@ -220,19 +174,15 @@ var Cursor = /*#__PURE__*/function () {
|
|
|
220
174
|
// In the cases when the mouseup comes first, we need wait for the
|
|
221
175
|
// browser to flush all events and then check again if the cursor
|
|
222
176
|
// should be visible.
|
|
223
|
-
|
|
224
|
-
|
|
225
177
|
if (this._captureIsActive()) {
|
|
226
178
|
window.setTimeout(function () {
|
|
227
179
|
// We might have detached at this point
|
|
228
180
|
if (!_this._target) {
|
|
229
181
|
return;
|
|
230
|
-
}
|
|
182
|
+
}
|
|
183
|
+
// Refresh the target from elementFromPoint since queued events
|
|
231
184
|
// might have altered the DOM
|
|
232
|
-
|
|
233
|
-
|
|
234
185
|
target = document.elementFromPoint(event.clientX, event.clientY);
|
|
235
|
-
|
|
236
186
|
_this._updateVisibility(target);
|
|
237
187
|
}, 0);
|
|
238
188
|
}
|
|
@@ -250,34 +200,31 @@ var Cursor = /*#__PURE__*/function () {
|
|
|
250
200
|
if (this._canvas.style.visibility !== 'hidden') {
|
|
251
201
|
this._canvas.style.visibility = 'hidden';
|
|
252
202
|
}
|
|
253
|
-
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Should we currently display the cursor?
|
|
254
206
|
// (i.e. are we over the target, or a child of the target without a
|
|
255
207
|
// different cursor set)
|
|
256
|
-
|
|
257
208
|
}, {
|
|
258
209
|
key: "_shouldShowCursor",
|
|
259
210
|
value: function _shouldShowCursor(target) {
|
|
260
211
|
if (!target) {
|
|
261
212
|
return false;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
|
|
213
|
+
}
|
|
214
|
+
// Easy case
|
|
265
215
|
if (target === this._target) {
|
|
266
216
|
return true;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
217
|
+
}
|
|
218
|
+
// Other part of the DOM?
|
|
270
219
|
if (!this._target.contains(target)) {
|
|
271
220
|
return false;
|
|
272
|
-
}
|
|
221
|
+
}
|
|
222
|
+
// Has the child its own cursor?
|
|
273
223
|
// FIXME: How can we tell that a sub element has an
|
|
274
224
|
// explicit "cursor: none;"?
|
|
275
|
-
|
|
276
|
-
|
|
277
225
|
if (window.getComputedStyle(target).cursor !== 'none') {
|
|
278
226
|
return false;
|
|
279
227
|
}
|
|
280
|
-
|
|
281
228
|
return true;
|
|
282
229
|
}
|
|
283
230
|
}, {
|
|
@@ -288,7 +235,6 @@ var Cursor = /*#__PURE__*/function () {
|
|
|
288
235
|
if (this._captureIsActive()) {
|
|
289
236
|
target = document.captureElement;
|
|
290
237
|
}
|
|
291
|
-
|
|
292
238
|
if (this._shouldShowCursor(target)) {
|
|
293
239
|
this._showCursor();
|
|
294
240
|
} else {
|
|
@@ -307,8 +253,6 @@ var Cursor = /*#__PURE__*/function () {
|
|
|
307
253
|
return document.captureElement && document.documentElement.contains(document.captureElement);
|
|
308
254
|
}
|
|
309
255
|
}]);
|
|
310
|
-
|
|
311
256
|
return Cursor;
|
|
312
257
|
}();
|
|
313
|
-
|
|
314
|
-
exports.default = Cursor;
|
|
258
|
+
exports["default"] = Cursor;
|
package/lib/util/element.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.clientToElement = clientToElement;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* noVNC: HTML5 VNC client
|
|
10
9
|
* Copyright (C) 2020 The noVNC Authors
|
|
@@ -16,13 +15,14 @@ exports.clientToElement = clientToElement;
|
|
|
16
15
|
/*
|
|
17
16
|
* HTML element utility functions
|
|
18
17
|
*/
|
|
18
|
+
|
|
19
19
|
function clientToElement(x, y, elem) {
|
|
20
20
|
var bounds = elem.getBoundingClientRect();
|
|
21
21
|
var pos = {
|
|
22
22
|
x: 0,
|
|
23
23
|
y: 0
|
|
24
|
-
};
|
|
25
|
-
|
|
24
|
+
};
|
|
25
|
+
// Clip to target bounds
|
|
26
26
|
if (x < bounds.left) {
|
|
27
27
|
pos.x = 0;
|
|
28
28
|
} else if (x >= bounds.right) {
|
|
@@ -30,7 +30,6 @@ function clientToElement(x, y, elem) {
|
|
|
30
30
|
} else {
|
|
31
31
|
pos.x = x - bounds.left;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
33
|
if (y < bounds.top) {
|
|
35
34
|
pos.y = 0;
|
|
36
35
|
} else if (y >= bounds.bottom) {
|
|
@@ -38,6 +37,5 @@ function clientToElement(x, y, elem) {
|
|
|
38
37
|
} else {
|
|
39
38
|
pos.y = y - bounds.top;
|
|
40
39
|
}
|
|
41
|
-
|
|
42
40
|
return pos;
|
|
43
41
|
}
|
package/lib/util/events.js
CHANGED
|
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getPointerEvent = getPointerEvent;
|
|
7
|
-
exports.stopEvent = stopEvent;
|
|
8
|
-
exports.setCapture = setCapture;
|
|
9
7
|
exports.releaseCapture = releaseCapture;
|
|
10
|
-
|
|
8
|
+
exports.setCapture = setCapture;
|
|
9
|
+
exports.stopEvent = stopEvent;
|
|
11
10
|
/*
|
|
12
11
|
* noVNC: HTML5 VNC client
|
|
13
12
|
* Copyright (C) 2018 The noVNC Authors
|
|
@@ -19,67 +18,62 @@ exports.releaseCapture = releaseCapture;
|
|
|
19
18
|
/*
|
|
20
19
|
* Cross-browser event and position routines
|
|
21
20
|
*/
|
|
21
|
+
|
|
22
22
|
function getPointerEvent(e) {
|
|
23
23
|
return e.changedTouches ? e.changedTouches[0] : e.touches ? e.touches[0] : e;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
25
|
function stopEvent(e) {
|
|
27
26
|
e.stopPropagation();
|
|
28
27
|
e.preventDefault();
|
|
29
|
-
}
|
|
30
|
-
|
|
28
|
+
}
|
|
31
29
|
|
|
30
|
+
// Emulate Element.setCapture() when not supported
|
|
32
31
|
var _captureRecursion = false;
|
|
33
32
|
var _elementForUnflushedEvents = null;
|
|
34
33
|
document.captureElement = null;
|
|
35
|
-
|
|
36
34
|
function _captureProxy(e) {
|
|
37
35
|
// Recursion protection as we'll see our own event
|
|
38
|
-
if (_captureRecursion) return;
|
|
36
|
+
if (_captureRecursion) return;
|
|
39
37
|
|
|
38
|
+
// Clone the event as we cannot dispatch an already dispatched event
|
|
40
39
|
var newEv = new e.constructor(e.type, e);
|
|
41
40
|
_captureRecursion = true;
|
|
42
|
-
|
|
43
41
|
if (document.captureElement) {
|
|
44
42
|
document.captureElement.dispatchEvent(newEv);
|
|
45
43
|
} else {
|
|
46
44
|
_elementForUnflushedEvents.dispatchEvent(newEv);
|
|
47
45
|
}
|
|
46
|
+
_captureRecursion = false;
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
e.stopPropagation(); // Respect the wishes of the redirected event handlers
|
|
48
|
+
// Avoid double events
|
|
49
|
+
e.stopPropagation();
|
|
52
50
|
|
|
51
|
+
// Respect the wishes of the redirected event handlers
|
|
53
52
|
if (newEv.defaultPrevented) {
|
|
54
53
|
e.preventDefault();
|
|
55
|
-
}
|
|
56
|
-
|
|
54
|
+
}
|
|
57
55
|
|
|
56
|
+
// Implicitly release the capture on button release
|
|
58
57
|
if (e.type === "mouseup") {
|
|
59
58
|
releaseCapture();
|
|
60
59
|
}
|
|
61
|
-
}
|
|
62
|
-
|
|
60
|
+
}
|
|
63
61
|
|
|
62
|
+
// Follow cursor style of target element
|
|
64
63
|
function _capturedElemChanged() {
|
|
65
64
|
var proxyElem = document.getElementById("noVNC_mouse_capture_elem");
|
|
66
65
|
proxyElem.style.cursor = window.getComputedStyle(document.captureElement).cursor;
|
|
67
66
|
}
|
|
68
|
-
|
|
69
67
|
var _captureObserver = new MutationObserver(_capturedElemChanged);
|
|
70
|
-
|
|
71
68
|
function setCapture(target) {
|
|
72
69
|
if (target.setCapture) {
|
|
73
70
|
target.setCapture();
|
|
74
|
-
document.captureElement = target;
|
|
75
|
-
|
|
76
|
-
target.addEventListener('mouseup', releaseCapture);
|
|
71
|
+
document.captureElement = target;
|
|
77
72
|
} else {
|
|
78
73
|
// Release any existing capture in case this method is
|
|
79
74
|
// called multiple times without coordination
|
|
80
75
|
releaseCapture();
|
|
81
76
|
var proxyElem = document.getElementById("noVNC_mouse_capture_elem");
|
|
82
|
-
|
|
83
77
|
if (proxyElem === null) {
|
|
84
78
|
proxyElem = document.createElement("div");
|
|
85
79
|
proxyElem.id = "noVNC_mouse_capture_elem";
|
|
@@ -90,30 +84,29 @@ function setCapture(target) {
|
|
|
90
84
|
proxyElem.style.height = "100%";
|
|
91
85
|
proxyElem.style.zIndex = 10000;
|
|
92
86
|
proxyElem.style.display = "none";
|
|
93
|
-
document.body.appendChild(proxyElem);
|
|
94
|
-
// our blocking element as the target
|
|
87
|
+
document.body.appendChild(proxyElem);
|
|
95
88
|
|
|
89
|
+
// This is to make sure callers don't get confused by having
|
|
90
|
+
// our blocking element as the target
|
|
96
91
|
proxyElem.addEventListener('contextmenu', _captureProxy);
|
|
97
92
|
proxyElem.addEventListener('mousemove', _captureProxy);
|
|
98
93
|
proxyElem.addEventListener('mouseup', _captureProxy);
|
|
99
94
|
}
|
|
95
|
+
document.captureElement = target;
|
|
100
96
|
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
// Track cursor and get initial cursor
|
|
103
98
|
_captureObserver.observe(target, {
|
|
104
99
|
attributes: true
|
|
105
100
|
});
|
|
106
|
-
|
|
107
101
|
_capturedElemChanged();
|
|
102
|
+
proxyElem.style.display = "";
|
|
108
103
|
|
|
109
|
-
|
|
104
|
+
// We listen to events on window in order to keep tracking if it
|
|
110
105
|
// happens to leave the viewport
|
|
111
|
-
|
|
112
106
|
window.addEventListener('mousemove', _captureProxy);
|
|
113
107
|
window.addEventListener('mouseup', _captureProxy);
|
|
114
108
|
}
|
|
115
109
|
}
|
|
116
|
-
|
|
117
110
|
function releaseCapture() {
|
|
118
111
|
if (document.releaseCapture) {
|
|
119
112
|
document.releaseCapture();
|
|
@@ -121,19 +114,17 @@ function releaseCapture() {
|
|
|
121
114
|
} else {
|
|
122
115
|
if (!document.captureElement) {
|
|
123
116
|
return;
|
|
124
|
-
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// There might be events already queued. The event proxy needs
|
|
125
120
|
// access to the captured element for these queued events.
|
|
126
121
|
// E.g. contextmenu (right-click) in Microsoft Edge
|
|
127
122
|
//
|
|
128
123
|
// Before removing the capturedElem pointer we save it to a
|
|
129
124
|
// temporary variable that the unflushed events can use.
|
|
130
|
-
|
|
131
|
-
|
|
132
125
|
_elementForUnflushedEvents = document.captureElement;
|
|
133
126
|
document.captureElement = null;
|
|
134
|
-
|
|
135
127
|
_captureObserver.disconnect();
|
|
136
|
-
|
|
137
128
|
var proxyElem = document.getElementById("noVNC_mouse_capture_elem");
|
|
138
129
|
proxyElem.style.display = "none";
|
|
139
130
|
window.removeEventListener('mousemove', _captureProxy);
|