@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.
Files changed (87) hide show
  1. package/AUTHORS +13 -0
  2. package/LICENSE.txt +2 -1
  3. package/README.md +69 -3
  4. package/core/base64.js +35 -41
  5. package/core/decoders/copyrect.js +22 -0
  6. package/core/decoders/hextile.js +137 -0
  7. package/core/decoders/raw.js +56 -0
  8. package/core/decoders/rre.js +44 -0
  9. package/core/decoders/tight.js +315 -0
  10. package/core/decoders/tightpng.js +27 -0
  11. package/core/deflator.js +85 -0
  12. package/core/des.js +90 -95
  13. package/core/display.js +254 -297
  14. package/core/encodings.js +7 -3
  15. package/core/inflator.js +48 -20
  16. package/core/input/domkeytable.js +21 -24
  17. package/core/input/fixedkeys.js +3 -1
  18. package/core/input/gesturehandler.js +567 -0
  19. package/core/input/keyboard.js +194 -120
  20. package/core/input/keysym.js +2 -0
  21. package/core/input/keysymdef.js +3 -3
  22. package/core/input/util.js +53 -12
  23. package/core/input/vkeys.js +2 -1
  24. package/core/rfb.js +1937 -1496
  25. package/core/util/browser.js +80 -29
  26. package/core/util/cursor.js +253 -0
  27. package/core/util/element.js +32 -0
  28. package/core/util/events.js +59 -55
  29. package/core/util/eventtarget.js +25 -30
  30. package/core/util/int.js +15 -0
  31. package/core/util/logging.js +21 -16
  32. package/core/util/polyfill.js +15 -8
  33. package/core/util/strings.js +21 -8
  34. package/core/websock.js +145 -167
  35. package/docs/API.md +31 -10
  36. package/lib/base64.js +115 -0
  37. package/lib/decoders/copyrect.js +44 -0
  38. package/lib/decoders/hextile.js +173 -0
  39. package/lib/decoders/raw.js +78 -0
  40. package/lib/decoders/rre.js +65 -0
  41. package/lib/decoders/tight.js +350 -0
  42. package/lib/decoders/tightpng.js +67 -0
  43. package/lib/deflator.js +99 -0
  44. package/lib/des.js +314 -0
  45. package/lib/display.js +733 -0
  46. package/lib/encodings.js +64 -0
  47. package/lib/inflator.js +87 -0
  48. package/lib/input/domkeytable.js +282 -0
  49. package/lib/input/fixedkeys.js +123 -0
  50. package/lib/input/gesturehandler.js +642 -0
  51. package/lib/input/keyboard.js +429 -0
  52. package/lib/input/keysym.js +1135 -0
  53. package/lib/input/keysymdef.js +1354 -0
  54. package/lib/input/util.js +304 -0
  55. package/lib/input/vkeys.js +127 -0
  56. package/lib/input/xtscancodes.js +505 -0
  57. package/lib/rfb.js +3448 -0
  58. package/lib/util/browser.js +131 -0
  59. package/lib/util/cursor.js +314 -0
  60. package/lib/util/element.js +43 -0
  61. package/lib/util/events.js +142 -0
  62. package/lib/util/eventtarget.js +64 -0
  63. package/lib/util/int.js +22 -0
  64. package/lib/util/logging.js +79 -0
  65. package/lib/util/polyfill.js +72 -0
  66. package/lib/util/strings.js +38 -0
  67. package/lib/vendor/pako/lib/utils/common.js +67 -0
  68. package/lib/vendor/pako/lib/zlib/adler32.js +33 -0
  69. package/lib/vendor/pako/lib/zlib/constants.js +51 -0
  70. package/lib/vendor/pako/lib/zlib/crc32.js +42 -0
  71. package/lib/vendor/pako/lib/zlib/deflate.js +2159 -0
  72. package/lib/vendor/pako/lib/zlib/gzheader.js +53 -0
  73. package/lib/vendor/pako/lib/zlib/inffast.js +445 -0
  74. package/lib/vendor/pako/lib/zlib/inflate.js +2114 -0
  75. package/lib/vendor/pako/lib/zlib/inftrees.js +418 -0
  76. package/lib/vendor/pako/lib/zlib/messages.js +36 -0
  77. package/lib/vendor/pako/lib/zlib/trees.js +1499 -0
  78. package/lib/vendor/pako/lib/zlib/zstream.js +46 -0
  79. package/lib/vendor/promise.js +255 -0
  80. package/lib/websock.js +374 -0
  81. package/package.json +48 -28
  82. package/vendor/pako/lib/zlib/deflate.js +30 -30
  83. package/vendor/pako/lib/zlib/inflate.js +17 -17
  84. package/core/input/mouse.js +0 -280
  85. package/docs/API-internal.md +0 -125
  86. package/docs/EMBEDDING.md +0 -83
  87. package/docs/VERSION +0 -1
@@ -0,0 +1,304 @@
1
+ "use strict";
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
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.getKeycode = getKeycode;
9
+ exports.getKey = getKey;
10
+ exports.getKeysym = getKeysym;
11
+
12
+ var _keysym = _interopRequireDefault(require("./keysym.js"));
13
+
14
+ var _keysymdef = _interopRequireDefault(require("./keysymdef.js"));
15
+
16
+ var _vkeys = _interopRequireDefault(require("./vkeys.js"));
17
+
18
+ var _fixedkeys = _interopRequireDefault(require("./fixedkeys.js"));
19
+
20
+ var _domkeytable = _interopRequireDefault(require("./domkeytable.js"));
21
+
22
+ var browser = _interopRequireWildcard(require("../util/browser.js"));
23
+
24
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
25
+
26
+ 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; }
27
+
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+
30
+ // Get 'KeyboardEvent.code', handling legacy browsers
31
+ function getKeycode(evt) {
32
+ // Are we getting proper key identifiers?
33
+ // (unfortunately Firefox and Chrome are crappy here and gives
34
+ // us an empty string on some platforms, rather than leaving it
35
+ // undefined)
36
+ if (evt.code) {
37
+ // Mozilla isn't fully in sync with the spec yet
38
+ switch (evt.code) {
39
+ case 'OSLeft':
40
+ return 'MetaLeft';
41
+
42
+ case 'OSRight':
43
+ return 'MetaRight';
44
+ }
45
+
46
+ return evt.code;
47
+ } // The de-facto standard is to use Windows Virtual-Key codes
48
+ // in the 'keyCode' field for non-printable characters. However
49
+ // Webkit sets it to the same as charCode in 'keypress' events.
50
+
51
+
52
+ if (evt.type !== 'keypress' && evt.keyCode in _vkeys.default) {
53
+ var code = _vkeys.default[evt.keyCode]; // macOS has messed up this code for some reason
54
+
55
+ if (browser.isMac() && code === 'ContextMenu') {
56
+ code = 'MetaRight';
57
+ } // The keyCode doesn't distinguish between left and right
58
+ // for the standard modifiers
59
+
60
+
61
+ if (evt.location === 2) {
62
+ switch (code) {
63
+ case 'ShiftLeft':
64
+ return 'ShiftRight';
65
+
66
+ case 'ControlLeft':
67
+ return 'ControlRight';
68
+
69
+ case 'AltLeft':
70
+ return 'AltRight';
71
+ }
72
+ } // Nor a bunch of the numpad keys
73
+
74
+
75
+ if (evt.location === 3) {
76
+ switch (code) {
77
+ case 'Delete':
78
+ return 'NumpadDecimal';
79
+
80
+ case 'Insert':
81
+ return 'Numpad0';
82
+
83
+ case 'End':
84
+ return 'Numpad1';
85
+
86
+ case 'ArrowDown':
87
+ return 'Numpad2';
88
+
89
+ case 'PageDown':
90
+ return 'Numpad3';
91
+
92
+ case 'ArrowLeft':
93
+ return 'Numpad4';
94
+
95
+ case 'ArrowRight':
96
+ return 'Numpad6';
97
+
98
+ case 'Home':
99
+ return 'Numpad7';
100
+
101
+ case 'ArrowUp':
102
+ return 'Numpad8';
103
+
104
+ case 'PageUp':
105
+ return 'Numpad9';
106
+
107
+ case 'Enter':
108
+ return 'NumpadEnter';
109
+ }
110
+ }
111
+
112
+ return code;
113
+ }
114
+
115
+ return 'Unidentified';
116
+ } // Get 'KeyboardEvent.key', handling legacy browsers
117
+
118
+
119
+ function getKey(evt) {
120
+ // Are we getting a proper key value?
121
+ if (evt.key !== undefined) {
122
+ // IE and Edge use some ancient version of the spec
123
+ // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8860571/
124
+ switch (evt.key) {
125
+ case 'Spacebar':
126
+ return ' ';
127
+
128
+ case 'Esc':
129
+ return 'Escape';
130
+
131
+ case 'Scroll':
132
+ return 'ScrollLock';
133
+
134
+ case 'Win':
135
+ return 'Meta';
136
+
137
+ case 'Apps':
138
+ return 'ContextMenu';
139
+
140
+ case 'Up':
141
+ return 'ArrowUp';
142
+
143
+ case 'Left':
144
+ return 'ArrowLeft';
145
+
146
+ case 'Right':
147
+ return 'ArrowRight';
148
+
149
+ case 'Down':
150
+ return 'ArrowDown';
151
+
152
+ case 'Del':
153
+ return 'Delete';
154
+
155
+ case 'Divide':
156
+ return '/';
157
+
158
+ case 'Multiply':
159
+ return '*';
160
+
161
+ case 'Subtract':
162
+ return '-';
163
+
164
+ case 'Add':
165
+ return '+';
166
+
167
+ case 'Decimal':
168
+ return evt.char;
169
+ } // Mozilla isn't fully in sync with the spec yet
170
+
171
+
172
+ switch (evt.key) {
173
+ case 'OS':
174
+ return 'Meta';
175
+
176
+ case 'LaunchMyComputer':
177
+ return 'LaunchApplication1';
178
+
179
+ case 'LaunchCalculator':
180
+ return 'LaunchApplication2';
181
+ } // iOS leaks some OS names
182
+
183
+
184
+ switch (evt.key) {
185
+ case 'UIKeyInputUpArrow':
186
+ return 'ArrowUp';
187
+
188
+ case 'UIKeyInputDownArrow':
189
+ return 'ArrowDown';
190
+
191
+ case 'UIKeyInputLeftArrow':
192
+ return 'ArrowLeft';
193
+
194
+ case 'UIKeyInputRightArrow':
195
+ return 'ArrowRight';
196
+
197
+ case 'UIKeyInputEscape':
198
+ return 'Escape';
199
+ } // Broken behaviour in Chrome
200
+
201
+
202
+ if (evt.key === '\x00' && evt.code === 'NumpadDecimal') {
203
+ return 'Delete';
204
+ } // IE and Edge need special handling, but for everyone else we
205
+ // can trust the value provided
206
+
207
+
208
+ if (!browser.isIE() && !browser.isEdge()) {
209
+ return evt.key;
210
+ } // IE and Edge have broken handling of AltGraph so we can only
211
+ // trust them for non-printable characters (and unfortunately
212
+ // they also specify 'Unidentified' for some problem keys)
213
+
214
+
215
+ if (evt.key.length !== 1 && evt.key !== 'Unidentified') {
216
+ return evt.key;
217
+ }
218
+ } // Try to deduce it based on the physical key
219
+
220
+
221
+ var code = getKeycode(evt);
222
+
223
+ if (code in _fixedkeys.default) {
224
+ return _fixedkeys.default[code];
225
+ } // If that failed, then see if we have a printable character
226
+
227
+
228
+ if (evt.charCode) {
229
+ return String.fromCharCode(evt.charCode);
230
+ } // At this point we have nothing left to go on
231
+
232
+
233
+ return 'Unidentified';
234
+ } // Get the most reliable keysym value we can get from a key event
235
+
236
+
237
+ function getKeysym(evt) {
238
+ var key = getKey(evt);
239
+
240
+ if (key === 'Unidentified') {
241
+ return null;
242
+ } // First look up special keys
243
+
244
+
245
+ if (key in _domkeytable.default) {
246
+ var location = evt.location; // Safari screws up location for the right cmd key
247
+
248
+ if (key === 'Meta' && location === 0) {
249
+ location = 2;
250
+ } // And for Clear
251
+
252
+
253
+ if (key === 'Clear' && location === 3) {
254
+ var code = getKeycode(evt);
255
+
256
+ if (code === 'NumLock') {
257
+ location = 0;
258
+ }
259
+ }
260
+
261
+ if (location === undefined || location > 3) {
262
+ location = 0;
263
+ } // The original Meta key now gets confused with the Windows key
264
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=1020141
265
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1232918
266
+
267
+
268
+ if (key === 'Meta') {
269
+ var _code = getKeycode(evt);
270
+
271
+ if (_code === 'AltLeft') {
272
+ return _keysym.default.XK_Meta_L;
273
+ } else if (_code === 'AltRight') {
274
+ return _keysym.default.XK_Meta_R;
275
+ }
276
+ } // macOS has Clear instead of NumLock, but the remote system is
277
+ // probably not macOS, so lying here is probably best...
278
+
279
+
280
+ if (key === 'Clear') {
281
+ var _code2 = getKeycode(evt);
282
+
283
+ if (_code2 === 'NumLock') {
284
+ return _keysym.default.XK_Num_Lock;
285
+ }
286
+ }
287
+
288
+ return _domkeytable.default[key][location];
289
+ } // Now we need to look at the Unicode symbol instead
290
+ // Special key? (FIXME: Should have been caught earlier)
291
+
292
+
293
+ if (key.length !== 1) {
294
+ return null;
295
+ }
296
+
297
+ var codepoint = key.charCodeAt();
298
+
299
+ if (codepoint) {
300
+ return _keysymdef.default.lookup(codepoint);
301
+ }
302
+
303
+ return null;
304
+ }
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ /*
9
+ * noVNC: HTML5 VNC client
10
+ * Copyright (C) 2018 The noVNC Authors
11
+ * Licensed under MPL 2.0 or any later version (see LICENSE.txt)
12
+ */
13
+
14
+ /*
15
+ * Mapping between Microsoft® Windows® Virtual-Key codes and
16
+ * HTML key codes.
17
+ */
18
+ var _default = {
19
+ 0x08: 'Backspace',
20
+ 0x09: 'Tab',
21
+ 0x0a: 'NumpadClear',
22
+ 0x0c: 'Numpad5',
23
+ // IE11 sends evt.keyCode: 12 when numlock is off
24
+ 0x0d: 'Enter',
25
+ 0x10: 'ShiftLeft',
26
+ 0x11: 'ControlLeft',
27
+ 0x12: 'AltLeft',
28
+ 0x13: 'Pause',
29
+ 0x14: 'CapsLock',
30
+ 0x15: 'Lang1',
31
+ 0x19: 'Lang2',
32
+ 0x1b: 'Escape',
33
+ 0x1c: 'Convert',
34
+ 0x1d: 'NonConvert',
35
+ 0x20: 'Space',
36
+ 0x21: 'PageUp',
37
+ 0x22: 'PageDown',
38
+ 0x23: 'End',
39
+ 0x24: 'Home',
40
+ 0x25: 'ArrowLeft',
41
+ 0x26: 'ArrowUp',
42
+ 0x27: 'ArrowRight',
43
+ 0x28: 'ArrowDown',
44
+ 0x29: 'Select',
45
+ 0x2c: 'PrintScreen',
46
+ 0x2d: 'Insert',
47
+ 0x2e: 'Delete',
48
+ 0x2f: 'Help',
49
+ 0x30: 'Digit0',
50
+ 0x31: 'Digit1',
51
+ 0x32: 'Digit2',
52
+ 0x33: 'Digit3',
53
+ 0x34: 'Digit4',
54
+ 0x35: 'Digit5',
55
+ 0x36: 'Digit6',
56
+ 0x37: 'Digit7',
57
+ 0x38: 'Digit8',
58
+ 0x39: 'Digit9',
59
+ 0x5b: 'MetaLeft',
60
+ 0x5c: 'MetaRight',
61
+ 0x5d: 'ContextMenu',
62
+ 0x5f: 'Sleep',
63
+ 0x60: 'Numpad0',
64
+ 0x61: 'Numpad1',
65
+ 0x62: 'Numpad2',
66
+ 0x63: 'Numpad3',
67
+ 0x64: 'Numpad4',
68
+ 0x65: 'Numpad5',
69
+ 0x66: 'Numpad6',
70
+ 0x67: 'Numpad7',
71
+ 0x68: 'Numpad8',
72
+ 0x69: 'Numpad9',
73
+ 0x6a: 'NumpadMultiply',
74
+ 0x6b: 'NumpadAdd',
75
+ 0x6c: 'NumpadDecimal',
76
+ 0x6d: 'NumpadSubtract',
77
+ 0x6e: 'NumpadDecimal',
78
+ // Duplicate, because buggy on Windows
79
+ 0x6f: 'NumpadDivide',
80
+ 0x70: 'F1',
81
+ 0x71: 'F2',
82
+ 0x72: 'F3',
83
+ 0x73: 'F4',
84
+ 0x74: 'F5',
85
+ 0x75: 'F6',
86
+ 0x76: 'F7',
87
+ 0x77: 'F8',
88
+ 0x78: 'F9',
89
+ 0x79: 'F10',
90
+ 0x7a: 'F11',
91
+ 0x7b: 'F12',
92
+ 0x7c: 'F13',
93
+ 0x7d: 'F14',
94
+ 0x7e: 'F15',
95
+ 0x7f: 'F16',
96
+ 0x80: 'F17',
97
+ 0x81: 'F18',
98
+ 0x82: 'F19',
99
+ 0x83: 'F20',
100
+ 0x84: 'F21',
101
+ 0x85: 'F22',
102
+ 0x86: 'F23',
103
+ 0x87: 'F24',
104
+ 0x90: 'NumLock',
105
+ 0x91: 'ScrollLock',
106
+ 0xa6: 'BrowserBack',
107
+ 0xa7: 'BrowserForward',
108
+ 0xa8: 'BrowserRefresh',
109
+ 0xa9: 'BrowserStop',
110
+ 0xaa: 'BrowserSearch',
111
+ 0xab: 'BrowserFavorites',
112
+ 0xac: 'BrowserHome',
113
+ 0xad: 'AudioVolumeMute',
114
+ 0xae: 'AudioVolumeDown',
115
+ 0xaf: 'AudioVolumeUp',
116
+ 0xb0: 'MediaTrackNext',
117
+ 0xb1: 'MediaTrackPrevious',
118
+ 0xb2: 'MediaStop',
119
+ 0xb3: 'MediaPlayPause',
120
+ 0xb4: 'LaunchMail',
121
+ 0xb5: 'MediaSelect',
122
+ 0xb6: 'LaunchApp1',
123
+ 0xb7: 'LaunchApp2',
124
+ 0xe1: 'AltRight' // Only when it is AltGraph
125
+
126
+ };
127
+ exports.default = _default;