@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,99 +1,58 @@
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["default"] = inflate_table;
9
-
10
8
  var utils = _interopRequireWildcard(require("../utils/common.js"));
11
-
12
9
  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); }
13
-
14
10
  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; }
15
-
16
11
  var MAXBITS = 15;
17
12
  var ENOUGH_LENS = 852;
18
- var ENOUGH_DISTS = 592; //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
13
+ var ENOUGH_DISTS = 592;
14
+ //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
19
15
 
20
16
  var CODES = 0;
21
17
  var LENS = 1;
22
18
  var DISTS = 2;
23
- var lbase = [
24
- /* Length codes 257..285 base */
19
+ var lbase = [/* Length codes 257..285 base */
25
20
  3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0];
26
- var lext = [
27
- /* Length codes 257..285 extra */
21
+ var lext = [/* Length codes 257..285 extra */
28
22
  16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78];
29
- var dbase = [
30
- /* Distance codes 0..29 base */
23
+ var dbase = [/* Distance codes 0..29 base */
31
24
  1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0];
32
- var dext = [
33
- /* Distance codes 0..29 extra */
25
+ var dext = [/* Distance codes 0..29 extra */
34
26
  16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64];
35
-
36
27
  function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) {
37
- var bits = opts.bits; //here = opts.here; /* table entry for duplication */
38
-
39
- var len = 0;
40
- /* a code's length in bits */
41
-
42
- var sym = 0;
43
- /* index of code symbols */
28
+ var bits = opts.bits;
29
+ //here = opts.here; /* table entry for duplication */
44
30
 
31
+ var len = 0; /* a code's length in bits */
32
+ var sym = 0; /* index of code symbols */
45
33
  var min = 0,
46
- max = 0;
47
- /* minimum and maximum code lengths */
48
-
49
- var root = 0;
50
- /* number of index bits for root table */
51
-
52
- var curr = 0;
53
- /* number of index bits for current table */
54
-
55
- var drop = 0;
56
- /* code bits to drop for sub-table */
57
-
58
- var left = 0;
59
- /* number of prefix codes available */
60
-
61
- var used = 0;
62
- /* code entries in table used */
63
-
64
- var huff = 0;
65
- /* Huffman code */
66
-
67
- var incr;
68
- /* for incrementing code, index */
69
-
70
- var fill;
71
- /* index for replicating entries */
72
-
73
- var low;
74
- /* low bits for current root entry */
75
-
76
- var mask;
77
- /* mask for low root bits */
78
-
79
- var next;
80
- /* next available space in table */
81
-
82
- var base = null;
83
- /* base value table to use */
84
-
85
- var base_index = 0; // var shoextra; /* extra bits table to use */
86
-
87
- var end;
88
- /* use base and extra for symbol > end */
89
-
34
+ max = 0; /* minimum and maximum code lengths */
35
+ var root = 0; /* number of index bits for root table */
36
+ var curr = 0; /* number of index bits for current table */
37
+ var drop = 0; /* code bits to drop for sub-table */
38
+ var left = 0; /* number of prefix codes available */
39
+ var used = 0; /* code entries in table used */
40
+ var huff = 0; /* Huffman code */
41
+ var incr; /* for incrementing code, index */
42
+ var fill; /* index for replicating entries */
43
+ var low; /* low bits for current root entry */
44
+ var mask; /* mask for low root bits */
45
+ var next; /* next available space in table */
46
+ var base = null; /* base value table to use */
47
+ var base_index = 0;
48
+ // var shoextra; /* extra bits table to use */
49
+ var end; /* use base and extra for symbol > end */
90
50
  var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */
91
-
92
51
  var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */
93
-
94
52
  var extra = null;
95
53
  var extra_index = 0;
96
54
  var here_bits, here_op, here_val;
55
+
97
56
  /*
98
57
  Process a set of code lengths to create a canonical Huffman code. The
99
58
  code lengths are lens[0..codes-1]. Each length corresponds to the
@@ -123,42 +82,36 @@ function inflate_table(type, lens, lens_index, codes, table, table_index, work,
123
82
  */
124
83
 
125
84
  /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
126
-
127
85
  for (len = 0; len <= MAXBITS; len++) {
128
86
  count[len] = 0;
129
87
  }
130
-
131
88
  for (sym = 0; sym < codes; sym++) {
132
89
  count[lens[lens_index + sym]]++;
133
90
  }
134
- /* bound code lengths, force root to be within code lengths */
135
-
136
91
 
92
+ /* bound code lengths, force root to be within code lengths */
137
93
  root = bits;
138
-
139
94
  for (max = MAXBITS; max >= 1; max--) {
140
95
  if (count[max] !== 0) {
141
96
  break;
142
97
  }
143
98
  }
144
-
145
99
  if (root > max) {
146
100
  root = max;
147
101
  }
148
-
149
102
  if (max === 0) {
150
103
  /* no symbols to code at all */
151
104
  //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */
152
105
  //table.bits[opts.table_index] = 1; //here.bits = (var char)1;
153
106
  //table.val[opts.table_index++] = 0; //here.val = (var short)0;
154
- table[table_index++] = 1 << 24 | 64 << 16 | 0; //table.op[opts.table_index] = 64;
107
+ table[table_index++] = 1 << 24 | 64 << 16 | 0;
108
+
109
+ //table.op[opts.table_index] = 64;
155
110
  //table.bits[opts.table_index] = 1;
156
111
  //table.val[opts.table_index++] = 0;
157
-
158
112
  table[table_index++] = 1 << 24 | 64 << 16 | 0;
159
113
  opts.bits = 1;
160
- return 0;
161
- /* no symbols, but wait for decoding to report error */
114
+ return 0; /* no symbols, but wait for decoding to report error */
162
115
  }
163
116
 
164
117
  for (min = 1; min < max; min++) {
@@ -166,46 +119,37 @@ function inflate_table(type, lens, lens_index, codes, table, table_index, work,
166
119
  break;
167
120
  }
168
121
  }
169
-
170
122
  if (root < min) {
171
123
  root = min;
172
124
  }
173
- /* check for an over-subscribed or incomplete set of lengths */
174
-
175
125
 
126
+ /* check for an over-subscribed or incomplete set of lengths */
176
127
  left = 1;
177
-
178
128
  for (len = 1; len <= MAXBITS; len++) {
179
129
  left <<= 1;
180
130
  left -= count[len];
181
-
182
131
  if (left < 0) {
183
132
  return -1;
184
- }
185
- /* over-subscribed */
186
-
133
+ } /* over-subscribed */
187
134
  }
188
135
 
189
136
  if (left > 0 && (type === CODES || max !== 1)) {
190
- return -1;
191
- /* incomplete set */
137
+ return -1; /* incomplete set */
192
138
  }
193
- /* generate offsets into symbol table for each length for sorting */
194
-
195
139
 
140
+ /* generate offsets into symbol table for each length for sorting */
196
141
  offs[1] = 0;
197
-
198
142
  for (len = 1; len < MAXBITS; len++) {
199
143
  offs[len + 1] = offs[len] + count[len];
200
144
  }
201
- /* sort symbols by length, by symbol order within each length */
202
-
203
145
 
146
+ /* sort symbols by length, by symbol order within each length */
204
147
  for (sym = 0; sym < codes; sym++) {
205
148
  if (lens[lens_index + sym] !== 0) {
206
149
  work[offs[lens[lens_index + sym]]++] = sym;
207
150
  }
208
151
  }
152
+
209
153
  /*
210
154
  Create and fill in decoding tables. In this loop, the table being
211
155
  filled is at next and has curr index bits. The code being used is huff
@@ -236,12 +180,8 @@ function inflate_table(type, lens, lens_index, codes, table, table_index, work,
236
180
  /* set up for code type */
237
181
  // poor man optimization - use if-else instead of switch,
238
182
  // to avoid deopts in old v8
239
-
240
-
241
183
  if (type === CODES) {
242
- base = extra = work;
243
- /* dummy value--not used */
244
-
184
+ base = extra = work; /* dummy value--not used */
245
185
  end = 19;
246
186
  } else if (type === LENS) {
247
187
  base = lbase;
@@ -255,48 +195,27 @@ function inflate_table(type, lens, lens_index, codes, table, table_index, work,
255
195
  extra = dext;
256
196
  end = -1;
257
197
  }
258
- /* initialize opts for loop */
259
-
260
-
261
- huff = 0;
262
- /* starting code */
263
-
264
- sym = 0;
265
- /* starting code symbol */
266
-
267
- len = min;
268
- /* starting code length */
269
-
270
- next = table_index;
271
- /* current table to fill in */
272
-
273
- curr = root;
274
- /* current table index bits */
275
198
 
276
- drop = 0;
277
- /* current bits to drop from code for index */
278
-
279
- low = -1;
280
- /* trigger new sub-table when len > root */
281
-
282
- used = 1 << root;
283
- /* use root table entries */
284
-
285
- mask = used - 1;
286
- /* mask for comparing low */
199
+ /* initialize opts for loop */
200
+ huff = 0; /* starting code */
201
+ sym = 0; /* starting code symbol */
202
+ len = min; /* starting code length */
203
+ next = table_index; /* current table to fill in */
204
+ curr = root; /* current table index bits */
205
+ drop = 0; /* current bits to drop from code for index */
206
+ low = -1; /* trigger new sub-table when len > root */
207
+ used = 1 << root; /* use root table entries */
208
+ mask = used - 1; /* mask for comparing low */
287
209
 
288
210
  /* check available table space */
289
-
290
211
  if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
291
212
  return 1;
292
213
  }
293
- /* process all codes and make table entries */
294
-
295
214
 
215
+ /* process all codes and make table entries */
296
216
  for (;;) {
297
217
  /* create table entry */
298
218
  here_bits = len - drop;
299
-
300
219
  if (work[sym] < end) {
301
220
  here_op = 0;
302
221
  here_val = work[sym];
@@ -304,115 +223,90 @@ function inflate_table(type, lens, lens_index, codes, table, table_index, work,
304
223
  here_op = extra[extra_index + work[sym]];
305
224
  here_val = base[base_index + work[sym]];
306
225
  } else {
307
- here_op = 32 + 64;
308
- /* end of block */
309
-
226
+ here_op = 32 + 64; /* end of block */
310
227
  here_val = 0;
311
228
  }
312
- /* replicate for those indices with low len bits equal to huff */
313
-
314
229
 
230
+ /* replicate for those indices with low len bits equal to huff */
315
231
  incr = 1 << len - drop;
316
232
  fill = 1 << curr;
317
- min = fill;
318
- /* save offset to next table */
319
-
233
+ min = fill; /* save offset to next table */
320
234
  do {
321
235
  fill -= incr;
322
236
  table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;
323
237
  } while (fill !== 0);
324
- /* backwards increment the len-bit code huff */
325
-
326
238
 
239
+ /* backwards increment the len-bit code huff */
327
240
  incr = 1 << len - 1;
328
-
329
241
  while (huff & incr) {
330
242
  incr >>= 1;
331
243
  }
332
-
333
244
  if (incr !== 0) {
334
245
  huff &= incr - 1;
335
246
  huff += incr;
336
247
  } else {
337
248
  huff = 0;
338
249
  }
339
- /* go to next symbol, update count, len */
340
-
341
250
 
251
+ /* go to next symbol, update count, len */
342
252
  sym++;
343
-
344
253
  if (--count[len] === 0) {
345
254
  if (len === max) {
346
255
  break;
347
256
  }
348
-
349
257
  len = lens[lens_index + work[sym]];
350
258
  }
351
- /* create new sub-table if needed */
352
-
353
259
 
260
+ /* create new sub-table if needed */
354
261
  if (len > root && (huff & mask) !== low) {
355
262
  /* if first time, transition to sub-tables */
356
263
  if (drop === 0) {
357
264
  drop = root;
358
265
  }
359
- /* increment past last table */
360
266
 
361
-
362
- next += min;
363
- /* here min is 1 << curr */
267
+ /* increment past last table */
268
+ next += min; /* here min is 1 << curr */
364
269
 
365
270
  /* determine length of next table */
366
-
367
271
  curr = len - drop;
368
272
  left = 1 << curr;
369
-
370
273
  while (curr + drop < max) {
371
274
  left -= count[curr + drop];
372
-
373
275
  if (left <= 0) {
374
276
  break;
375
277
  }
376
-
377
278
  curr++;
378
279
  left <<= 1;
379
280
  }
380
- /* check for enough space */
381
-
382
281
 
282
+ /* check for enough space */
383
283
  used += 1 << curr;
384
-
385
284
  if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
386
285
  return 1;
387
286
  }
388
- /* point entry in root table to sub-table */
389
-
390
287
 
288
+ /* point entry in root table to sub-table */
391
289
  low = huff & mask;
392
290
  /*table.op[low] = curr;
393
291
  table.bits[low] = root;
394
292
  table.val[low] = next - opts.table_index;*/
395
-
396
293
  table[low] = root << 24 | curr << 16 | next - table_index | 0;
397
294
  }
398
295
  }
296
+
399
297
  /* fill in remaining table entry if code is incomplete (guaranteed to have
400
298
  at most one remaining entry, since if the code is incomplete, the
401
299
  maximum code length that was allowed to get this far is one bit) */
402
-
403
-
404
300
  if (huff !== 0) {
405
301
  //table.op[next + huff] = 64; /* invalid code marker */
406
302
  //table.bits[next + huff] = len - drop;
407
303
  //table.val[next + huff] = 0;
408
304
  table[next + huff] = len - drop << 24 | 64 << 16 | 0;
409
305
  }
306
+
410
307
  /* set return parameters */
411
308
  //opts.table_index += used;
412
-
413
-
414
309
  opts.bits = root;
415
310
  return 0;
416
311
  }
417
-
418
312
  ;
@@ -6,31 +6,21 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports["default"] = void 0;
7
7
  var _default = {
8
8
  2: 'need dictionary',
9
-
10
9
  /* Z_NEED_DICT 2 */
11
10
  1: 'stream end',
12
-
13
11
  /* Z_STREAM_END 1 */
14
12
  0: '',
15
-
16
13
  /* Z_OK 0 */
17
14
  '-1': 'file error',
18
-
19
15
  /* Z_ERRNO (-1) */
20
16
  '-2': 'stream error',
21
-
22
17
  /* Z_STREAM_ERROR (-2) */
23
18
  '-3': 'data error',
24
-
25
19
  /* Z_DATA_ERROR (-3) */
26
20
  '-4': 'insufficient memory',
27
-
28
21
  /* Z_MEM_ERROR (-4) */
29
22
  '-5': 'buffer error',
30
-
31
23
  /* Z_BUF_ERROR (-5) */
32
- '-6': 'incompatible version'
33
- /* Z_VERSION_ERROR (-6) */
34
-
24
+ '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */
35
25
  };
36
26
  exports["default"] = _default;