@novnc/novnc 1.6.0 → 1.7.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.
Files changed (103) hide show
  1. package/core/base64.js +104 -0
  2. package/core/crypto/aes.js +178 -0
  3. package/core/crypto/bigint.js +34 -0
  4. package/core/crypto/crypto.js +90 -0
  5. package/core/crypto/des.js +330 -0
  6. package/core/crypto/dh.js +55 -0
  7. package/core/crypto/md5.js +82 -0
  8. package/core/crypto/rsa.js +132 -0
  9. package/core/decoders/copyrect.js +27 -0
  10. package/core/decoders/h264.js +321 -0
  11. package/core/decoders/hextile.js +181 -0
  12. package/core/decoders/jpeg.js +161 -0
  13. package/core/decoders/raw.js +59 -0
  14. package/core/decoders/rre.js +44 -0
  15. package/core/decoders/tight.js +393 -0
  16. package/core/decoders/tightpng.js +27 -0
  17. package/core/decoders/zlib.js +51 -0
  18. package/core/decoders/zrle.js +185 -0
  19. package/core/deflator.js +84 -0
  20. package/core/display.js +578 -0
  21. package/core/encodings.js +54 -0
  22. package/core/inflator.js +65 -0
  23. package/core/input/domkeytable.js +311 -0
  24. package/core/input/fixedkeys.js +129 -0
  25. package/core/input/gesturehandler.js +567 -0
  26. package/core/input/keyboard.js +294 -0
  27. package/core/input/keysym.js +616 -0
  28. package/core/input/keysymdef.js +688 -0
  29. package/core/input/util.js +191 -0
  30. package/core/input/vkeys.js +116 -0
  31. package/core/input/xtscancodes.js +173 -0
  32. package/core/ra2.js +312 -0
  33. package/core/rfb.js +3411 -0
  34. package/core/util/browser.js +233 -0
  35. package/core/util/cursor.js +249 -0
  36. package/core/util/element.js +32 -0
  37. package/core/util/events.js +138 -0
  38. package/core/util/eventtarget.js +35 -0
  39. package/core/util/int.js +15 -0
  40. package/core/util/logging.js +56 -0
  41. package/core/util/strings.js +28 -0
  42. package/core/websock.js +369 -0
  43. package/docs/API.md +0 -5
  44. package/package.json +6 -10
  45. package/vendor/pako/LICENSE +21 -0
  46. package/vendor/pako/README.md +6 -0
  47. package/{lib/vendor → vendor}/pako/lib/utils/common.js +13 -23
  48. package/{lib/vendor → vendor}/pako/lib/zlib/adler32.js +12 -14
  49. package/vendor/pako/lib/zlib/constants.js +47 -0
  50. package/{lib/vendor → vendor}/pako/lib/zlib/crc32.js +15 -14
  51. package/{lib/vendor → vendor}/pako/lib/zlib/deflate.js +459 -334
  52. package/{lib/vendor → vendor}/pako/lib/zlib/gzheader.js +13 -19
  53. package/{lib/vendor → vendor}/pako/lib/zlib/inffast.js +116 -119
  54. package/vendor/pako/lib/zlib/inflate.js +1527 -0
  55. package/{lib/vendor → vendor}/pako/lib/zlib/inftrees.js +103 -91
  56. package/vendor/pako/lib/zlib/messages.js +11 -0
  57. package/{lib/vendor → vendor}/pako/lib/zlib/trees.js +313 -268
  58. package/{lib/vendor → vendor}/pako/lib/zlib/zstream.js +4 -10
  59. package/lib/base64.js +0 -100
  60. package/lib/crypto/aes.js +0 -481
  61. package/lib/crypto/bigint.js +0 -41
  62. package/lib/crypto/crypto.js +0 -109
  63. package/lib/crypto/des.js +0 -374
  64. package/lib/crypto/dh.js +0 -81
  65. package/lib/crypto/md5.js +0 -97
  66. package/lib/crypto/rsa.js +0 -312
  67. package/lib/decoders/copyrect.js +0 -40
  68. package/lib/decoders/h264.js +0 -349
  69. package/lib/decoders/hextile.js +0 -195
  70. package/lib/decoders/jpeg.js +0 -175
  71. package/lib/decoders/raw.js +0 -66
  72. package/lib/decoders/rre.js +0 -52
  73. package/lib/decoders/tight.js +0 -363
  74. package/lib/decoders/tightpng.js +0 -51
  75. package/lib/decoders/zlib.js +0 -57
  76. package/lib/decoders/zrle.js +0 -192
  77. package/lib/deflator.js +0 -88
  78. package/lib/display.js +0 -588
  79. package/lib/encodings.js +0 -70
  80. package/lib/inflator.js +0 -77
  81. package/lib/input/domkeytable.js +0 -313
  82. package/lib/input/fixedkeys.js +0 -127
  83. package/lib/input/gesturehandler.js +0 -573
  84. package/lib/input/keyboard.js +0 -293
  85. package/lib/input/keysym.js +0 -878
  86. package/lib/input/keysymdef.js +0 -1351
  87. package/lib/input/util.js +0 -217
  88. package/lib/input/vkeys.js +0 -121
  89. package/lib/input/xtscancodes.js +0 -343
  90. package/lib/ra2.js +0 -535
  91. package/lib/rfb.js +0 -3398
  92. package/lib/util/browser.js +0 -239
  93. package/lib/util/cursor.js +0 -269
  94. package/lib/util/element.js +0 -41
  95. package/lib/util/events.js +0 -133
  96. package/lib/util/eventtarget.js +0 -53
  97. package/lib/util/int.js +0 -21
  98. package/lib/util/logging.js +0 -56
  99. package/lib/util/strings.js +0 -36
  100. package/lib/vendor/pako/lib/zlib/constants.js +0 -47
  101. package/lib/vendor/pako/lib/zlib/inflate.js +0 -1602
  102. package/lib/vendor/pako/lib/zlib/messages.js +0 -25
  103. package/lib/websock.js +0 -395
@@ -1,293 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var Log = _interopRequireWildcard(require("../util/logging.js"));
8
- var _events = require("../util/events.js");
9
- var KeyboardUtil = _interopRequireWildcard(require("./util.js"));
10
- var _keysym = _interopRequireDefault(require("./keysym.js"));
11
- var browser = _interopRequireWildcard(require("../util/browser.js"));
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
15
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
16
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
17
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
18
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
19
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
20
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
21
- * noVNC: HTML5 VNC client
22
- * Copyright (C) 2019 The noVNC authors
23
- * Licensed under MPL 2.0 or any later version (see LICENSE.txt)
24
- */
25
- //
26
- // Keyboard event handler
27
- //
28
- var Keyboard = exports["default"] = /*#__PURE__*/function () {
29
- function Keyboard(target) {
30
- _classCallCheck(this, Keyboard);
31
- this._target = target || null;
32
- this._keyDownList = {}; // List of depressed keys
33
- // (even if they are happy)
34
- this._altGrArmed = false; // Windows AltGr detection
35
-
36
- // keep these here so we can refer to them later
37
- this._eventHandlers = {
38
- 'keyup': this._handleKeyUp.bind(this),
39
- 'keydown': this._handleKeyDown.bind(this),
40
- 'blur': this._allKeysUp.bind(this)
41
- };
42
-
43
- // ===== EVENT HANDLERS =====
44
-
45
- this.onkeyevent = function () {}; // Handler for key press/release
46
- }
47
-
48
- // ===== PRIVATE METHODS =====
49
- return _createClass(Keyboard, [{
50
- key: "_sendKeyEvent",
51
- value: function _sendKeyEvent(keysym, code, down) {
52
- var numlock = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
53
- var capslock = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
54
- if (down) {
55
- this._keyDownList[code] = keysym;
56
- } else {
57
- // Do we really think this key is down?
58
- if (!(code in this._keyDownList)) {
59
- return;
60
- }
61
- delete this._keyDownList[code];
62
- }
63
- Log.Debug("onkeyevent " + (down ? "down" : "up") + ", keysym: " + keysym, ", code: " + code + ", numlock: " + numlock + ", capslock: " + capslock);
64
- this.onkeyevent(keysym, code, down, numlock, capslock);
65
- }
66
- }, {
67
- key: "_getKeyCode",
68
- value: function _getKeyCode(e) {
69
- var code = KeyboardUtil.getKeycode(e);
70
- if (code !== 'Unidentified') {
71
- return code;
72
- }
73
-
74
- // Unstable, but we don't have anything else to go on
75
- if (e.keyCode) {
76
- // 229 is used for composition events
77
- if (e.keyCode !== 229) {
78
- return 'Platform' + e.keyCode;
79
- }
80
- }
81
-
82
- // A precursor to the final DOM3 standard. Unfortunately it
83
- // is not layout independent, so it is as bad as using keyCode
84
- if (e.keyIdentifier) {
85
- // Non-character key?
86
- if (e.keyIdentifier.substr(0, 2) !== 'U+') {
87
- return e.keyIdentifier;
88
- }
89
- var codepoint = parseInt(e.keyIdentifier.substr(2), 16);
90
- var _char = String.fromCharCode(codepoint).toUpperCase();
91
- return 'Platform' + _char.charCodeAt();
92
- }
93
- return 'Unidentified';
94
- }
95
- }, {
96
- key: "_handleKeyDown",
97
- value: function _handleKeyDown(e) {
98
- var code = this._getKeyCode(e);
99
- var keysym = KeyboardUtil.getKeysym(e);
100
- var numlock = e.getModifierState('NumLock');
101
- var capslock = e.getModifierState('CapsLock');
102
-
103
- // getModifierState for NumLock is not supported on mac and ios and always returns false.
104
- // Set to null to indicate unknown/unsupported instead.
105
- if (browser.isMac() || browser.isIOS()) {
106
- numlock = null;
107
- }
108
-
109
- // Windows doesn't have a proper AltGr, but handles it using
110
- // fake Ctrl+Alt. However the remote end might not be Windows,
111
- // so we need to merge those in to a single AltGr event. We
112
- // detect this case by seeing the two key events directly after
113
- // each other with a very short time between them (<50ms).
114
- if (this._altGrArmed) {
115
- this._altGrArmed = false;
116
- clearTimeout(this._altGrTimeout);
117
- if (code === "AltRight" && e.timeStamp - this._altGrCtrlTime < 50) {
118
- // FIXME: We fail to detect this if either Ctrl key is
119
- // first manually pressed as Windows then no
120
- // longer sends the fake Ctrl down event. It
121
- // does however happily send real Ctrl events
122
- // even when AltGr is already down. Some
123
- // browsers detect this for us though and set the
124
- // key to "AltGraph".
125
- keysym = _keysym["default"].XK_ISO_Level3_Shift;
126
- } else {
127
- this._sendKeyEvent(_keysym["default"].XK_Control_L, "ControlLeft", true, numlock, capslock);
128
- }
129
- }
130
-
131
- // We cannot handle keys we cannot track, but we also need
132
- // to deal with virtual keyboards which omit key info
133
- if (code === 'Unidentified') {
134
- if (keysym) {
135
- // If it's a virtual keyboard then it should be
136
- // sufficient to just send press and release right
137
- // after each other
138
- this._sendKeyEvent(keysym, code, true, numlock, capslock);
139
- this._sendKeyEvent(keysym, code, false, numlock, capslock);
140
- }
141
- (0, _events.stopEvent)(e);
142
- return;
143
- }
144
-
145
- // Alt behaves more like AltGraph on macOS, so shuffle the
146
- // keys around a bit to make things more sane for the remote
147
- // server. This method is used by RealVNC and TigerVNC (and
148
- // possibly others).
149
- if (browser.isMac() || browser.isIOS()) {
150
- switch (keysym) {
151
- case _keysym["default"].XK_Super_L:
152
- keysym = _keysym["default"].XK_Alt_L;
153
- break;
154
- case _keysym["default"].XK_Super_R:
155
- keysym = _keysym["default"].XK_Super_L;
156
- break;
157
- case _keysym["default"].XK_Alt_L:
158
- keysym = _keysym["default"].XK_Mode_switch;
159
- break;
160
- case _keysym["default"].XK_Alt_R:
161
- keysym = _keysym["default"].XK_ISO_Level3_Shift;
162
- break;
163
- }
164
- }
165
-
166
- // Is this key already pressed? If so, then we must use the
167
- // same keysym or we'll confuse the server
168
- if (code in this._keyDownList) {
169
- keysym = this._keyDownList[code];
170
- }
171
-
172
- // macOS doesn't send proper key releases if a key is pressed
173
- // while meta is held down
174
- if ((browser.isMac() || browser.isIOS()) && e.metaKey && code !== 'MetaLeft' && code !== 'MetaRight') {
175
- this._sendKeyEvent(keysym, code, true, numlock, capslock);
176
- this._sendKeyEvent(keysym, code, false, numlock, capslock);
177
- (0, _events.stopEvent)(e);
178
- return;
179
- }
180
-
181
- // macOS doesn't send proper key events for modifiers, only
182
- // state change events. That gets extra confusing for CapsLock
183
- // which toggles on each press, but not on release. So pretend
184
- // it was a quick press and release of the button.
185
- if ((browser.isMac() || browser.isIOS()) && code === 'CapsLock') {
186
- this._sendKeyEvent(_keysym["default"].XK_Caps_Lock, 'CapsLock', true, numlock, capslock);
187
- this._sendKeyEvent(_keysym["default"].XK_Caps_Lock, 'CapsLock', false, numlock, capslock);
188
- (0, _events.stopEvent)(e);
189
- return;
190
- }
191
-
192
- // Windows doesn't send proper key releases for a bunch of
193
- // Japanese IM keys so we have to fake the release right away
194
- var jpBadKeys = [_keysym["default"].XK_Zenkaku_Hankaku, _keysym["default"].XK_Eisu_toggle, _keysym["default"].XK_Katakana, _keysym["default"].XK_Hiragana, _keysym["default"].XK_Romaji];
195
- if (browser.isWindows() && jpBadKeys.includes(keysym)) {
196
- this._sendKeyEvent(keysym, code, true, numlock, capslock);
197
- this._sendKeyEvent(keysym, code, false, numlock, capslock);
198
- (0, _events.stopEvent)(e);
199
- return;
200
- }
201
- (0, _events.stopEvent)(e);
202
-
203
- // Possible start of AltGr sequence? (see above)
204
- if (code === "ControlLeft" && browser.isWindows() && !("ControlLeft" in this._keyDownList)) {
205
- this._altGrArmed = true;
206
- this._altGrTimeout = setTimeout(this._interruptAltGrSequence.bind(this), 100);
207
- this._altGrCtrlTime = e.timeStamp;
208
- return;
209
- }
210
- this._sendKeyEvent(keysym, code, true, numlock, capslock);
211
- }
212
- }, {
213
- key: "_handleKeyUp",
214
- value: function _handleKeyUp(e) {
215
- (0, _events.stopEvent)(e);
216
- var code = this._getKeyCode(e);
217
-
218
- // We can't get a release in the middle of an AltGr sequence, so
219
- // abort that detection
220
- this._interruptAltGrSequence();
221
-
222
- // See comment in _handleKeyDown()
223
- if ((browser.isMac() || browser.isIOS()) && code === 'CapsLock') {
224
- this._sendKeyEvent(_keysym["default"].XK_Caps_Lock, 'CapsLock', true);
225
- this._sendKeyEvent(_keysym["default"].XK_Caps_Lock, 'CapsLock', false);
226
- return;
227
- }
228
- this._sendKeyEvent(this._keyDownList[code], code, false);
229
-
230
- // Windows has a rather nasty bug where it won't send key
231
- // release events for a Shift button if the other Shift is still
232
- // pressed
233
- if (browser.isWindows() && (code === 'ShiftLeft' || code === 'ShiftRight')) {
234
- if ('ShiftRight' in this._keyDownList) {
235
- this._sendKeyEvent(this._keyDownList['ShiftRight'], 'ShiftRight', false);
236
- }
237
- if ('ShiftLeft' in this._keyDownList) {
238
- this._sendKeyEvent(this._keyDownList['ShiftLeft'], 'ShiftLeft', false);
239
- }
240
- }
241
- }
242
- }, {
243
- key: "_interruptAltGrSequence",
244
- value: function _interruptAltGrSequence() {
245
- if (this._altGrArmed) {
246
- this._altGrArmed = false;
247
- clearTimeout(this._altGrTimeout);
248
- this._sendKeyEvent(_keysym["default"].XK_Control_L, "ControlLeft", true);
249
- }
250
- }
251
- }, {
252
- key: "_allKeysUp",
253
- value: function _allKeysUp() {
254
- Log.Debug(">> Keyboard.allKeysUp");
255
-
256
- // Prevent control key being processed after losing focus.
257
- this._interruptAltGrSequence();
258
- for (var code in this._keyDownList) {
259
- this._sendKeyEvent(this._keyDownList[code], code, false);
260
- }
261
- Log.Debug("<< Keyboard.allKeysUp");
262
- }
263
-
264
- // ===== PUBLIC METHODS =====
265
- }, {
266
- key: "grab",
267
- value: function grab() {
268
- //Log.Debug(">> Keyboard.grab");
269
-
270
- this._target.addEventListener('keydown', this._eventHandlers.keydown);
271
- this._target.addEventListener('keyup', this._eventHandlers.keyup);
272
-
273
- // Release (key up) if window loses focus
274
- window.addEventListener('blur', this._eventHandlers.blur);
275
-
276
- //Log.Debug("<< Keyboard.grab");
277
- }
278
- }, {
279
- key: "ungrab",
280
- value: function ungrab() {
281
- //Log.Debug(">> Keyboard.ungrab");
282
-
283
- this._target.removeEventListener('keydown', this._eventHandlers.keydown);
284
- this._target.removeEventListener('keyup', this._eventHandlers.keyup);
285
- window.removeEventListener('blur', this._eventHandlers.blur);
286
-
287
- // Release (key up) all keys that are in a down state
288
- this._allKeysUp();
289
-
290
- //Log.Debug(">> Keyboard.ungrab");
291
- }
292
- }]);
293
- }();