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