@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,418 @@
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.default = inflate_table;
9
+
10
+ var utils = _interopRequireWildcard(require("../utils/common.js"));
11
+
12
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
13
+
14
+ 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; }
15
+
16
+ var MAXBITS = 15;
17
+ var ENOUGH_LENS = 852;
18
+ var ENOUGH_DISTS = 592; //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
19
+
20
+ var CODES = 0;
21
+ var LENS = 1;
22
+ var DISTS = 2;
23
+ var lbase = [
24
+ /* Length codes 257..285 base */
25
+ 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 */
28
+ 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 */
31
+ 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 */
34
+ 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
+ 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 */
44
+
45
+ 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
+
90
+ var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */
91
+
92
+ var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */
93
+
94
+ var extra = null;
95
+ var extra_index = 0;
96
+ var here_bits, here_op, here_val;
97
+ /*
98
+ Process a set of code lengths to create a canonical Huffman code. The
99
+ code lengths are lens[0..codes-1]. Each length corresponds to the
100
+ symbols 0..codes-1. The Huffman code is generated by first sorting the
101
+ symbols by length from short to long, and retaining the symbol order
102
+ for codes with equal lengths. Then the code starts with all zero bits
103
+ for the first code of the shortest length, and the codes are integer
104
+ increments for the same length, and zeros are appended as the length
105
+ increases. For the deflate format, these bits are stored backwards
106
+ from their more natural integer increment ordering, and so when the
107
+ decoding tables are built in the large loop below, the integer codes
108
+ are incremented backwards.
109
+ This routine assumes, but does not check, that all of the entries in
110
+ lens[] are in the range 0..MAXBITS. The caller must assure this.
111
+ 1..MAXBITS is interpreted as that code length. zero means that that
112
+ symbol does not occur in this code.
113
+ The codes are sorted by computing a count of codes for each length,
114
+ creating from that a table of starting indices for each length in the
115
+ sorted table, and then entering the symbols in order in the sorted
116
+ table. The sorted table is work[], with that space being provided by
117
+ the caller.
118
+ The length counts are used for other purposes as well, i.e. finding
119
+ the minimum and maximum length codes, determining if there are any
120
+ codes at all, checking for a valid set of lengths, and looking ahead
121
+ at length counts to determine sub-table sizes when building the
122
+ decoding tables.
123
+ */
124
+
125
+ /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
126
+
127
+ for (len = 0; len <= MAXBITS; len++) {
128
+ count[len] = 0;
129
+ }
130
+
131
+ for (sym = 0; sym < codes; sym++) {
132
+ count[lens[lens_index + sym]]++;
133
+ }
134
+ /* bound code lengths, force root to be within code lengths */
135
+
136
+
137
+ root = bits;
138
+
139
+ for (max = MAXBITS; max >= 1; max--) {
140
+ if (count[max] !== 0) {
141
+ break;
142
+ }
143
+ }
144
+
145
+ if (root > max) {
146
+ root = max;
147
+ }
148
+
149
+ if (max === 0) {
150
+ /* no symbols to code at all */
151
+ //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */
152
+ //table.bits[opts.table_index] = 1; //here.bits = (var char)1;
153
+ //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;
155
+ //table.bits[opts.table_index] = 1;
156
+ //table.val[opts.table_index++] = 0;
157
+
158
+ table[table_index++] = 1 << 24 | 64 << 16 | 0;
159
+ opts.bits = 1;
160
+ return 0;
161
+ /* no symbols, but wait for decoding to report error */
162
+ }
163
+
164
+ for (min = 1; min < max; min++) {
165
+ if (count[min] !== 0) {
166
+ break;
167
+ }
168
+ }
169
+
170
+ if (root < min) {
171
+ root = min;
172
+ }
173
+ /* check for an over-subscribed or incomplete set of lengths */
174
+
175
+
176
+ left = 1;
177
+
178
+ for (len = 1; len <= MAXBITS; len++) {
179
+ left <<= 1;
180
+ left -= count[len];
181
+
182
+ if (left < 0) {
183
+ return -1;
184
+ }
185
+ /* over-subscribed */
186
+
187
+ }
188
+
189
+ if (left > 0 && (type === CODES || max !== 1)) {
190
+ return -1;
191
+ /* incomplete set */
192
+ }
193
+ /* generate offsets into symbol table for each length for sorting */
194
+
195
+
196
+ offs[1] = 0;
197
+
198
+ for (len = 1; len < MAXBITS; len++) {
199
+ offs[len + 1] = offs[len] + count[len];
200
+ }
201
+ /* sort symbols by length, by symbol order within each length */
202
+
203
+
204
+ for (sym = 0; sym < codes; sym++) {
205
+ if (lens[lens_index + sym] !== 0) {
206
+ work[offs[lens[lens_index + sym]]++] = sym;
207
+ }
208
+ }
209
+ /*
210
+ Create and fill in decoding tables. In this loop, the table being
211
+ filled is at next and has curr index bits. The code being used is huff
212
+ with length len. That code is converted to an index by dropping drop
213
+ bits off of the bottom. For codes where len is less than drop + curr,
214
+ those top drop + curr - len bits are incremented through all values to
215
+ fill the table with replicated entries.
216
+ root is the number of index bits for the root table. When len exceeds
217
+ root, sub-tables are created pointed to by the root entry with an index
218
+ of the low root bits of huff. This is saved in low to check for when a
219
+ new sub-table should be started. drop is zero when the root table is
220
+ being filled, and drop is root when sub-tables are being filled.
221
+ When a new sub-table is needed, it is necessary to look ahead in the
222
+ code lengths to determine what size sub-table is needed. The length
223
+ counts are used for this, and so count[] is decremented as codes are
224
+ entered in the tables.
225
+ used keeps track of how many table entries have been allocated from the
226
+ provided *table space. It is checked for LENS and DIST tables against
227
+ the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
228
+ the initial root table size constants. See the comments in inftrees.h
229
+ for more information.
230
+ sym increments through all symbols, and the loop terminates when
231
+ all codes of length max, i.e. all codes, have been processed. This
232
+ routine permits incomplete codes, so another loop after this one fills
233
+ in the rest of the decoding tables with invalid code markers.
234
+ */
235
+
236
+ /* set up for code type */
237
+ // poor man optimization - use if-else instead of switch,
238
+ // to avoid deopts in old v8
239
+
240
+
241
+ if (type === CODES) {
242
+ base = extra = work;
243
+ /* dummy value--not used */
244
+
245
+ end = 19;
246
+ } else if (type === LENS) {
247
+ base = lbase;
248
+ base_index -= 257;
249
+ extra = lext;
250
+ extra_index -= 257;
251
+ end = 256;
252
+ } else {
253
+ /* DISTS */
254
+ base = dbase;
255
+ extra = dext;
256
+ end = -1;
257
+ }
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
+
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 */
287
+
288
+ /* check available table space */
289
+
290
+ if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
291
+ return 1;
292
+ }
293
+ /* process all codes and make table entries */
294
+
295
+
296
+ for (;;) {
297
+ /* create table entry */
298
+ here_bits = len - drop;
299
+
300
+ if (work[sym] < end) {
301
+ here_op = 0;
302
+ here_val = work[sym];
303
+ } else if (work[sym] > end) {
304
+ here_op = extra[extra_index + work[sym]];
305
+ here_val = base[base_index + work[sym]];
306
+ } else {
307
+ here_op = 32 + 64;
308
+ /* end of block */
309
+
310
+ here_val = 0;
311
+ }
312
+ /* replicate for those indices with low len bits equal to huff */
313
+
314
+
315
+ incr = 1 << len - drop;
316
+ fill = 1 << curr;
317
+ min = fill;
318
+ /* save offset to next table */
319
+
320
+ do {
321
+ fill -= incr;
322
+ table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;
323
+ } while (fill !== 0);
324
+ /* backwards increment the len-bit code huff */
325
+
326
+
327
+ incr = 1 << len - 1;
328
+
329
+ while (huff & incr) {
330
+ incr >>= 1;
331
+ }
332
+
333
+ if (incr !== 0) {
334
+ huff &= incr - 1;
335
+ huff += incr;
336
+ } else {
337
+ huff = 0;
338
+ }
339
+ /* go to next symbol, update count, len */
340
+
341
+
342
+ sym++;
343
+
344
+ if (--count[len] === 0) {
345
+ if (len === max) {
346
+ break;
347
+ }
348
+
349
+ len = lens[lens_index + work[sym]];
350
+ }
351
+ /* create new sub-table if needed */
352
+
353
+
354
+ if (len > root && (huff & mask) !== low) {
355
+ /* if first time, transition to sub-tables */
356
+ if (drop === 0) {
357
+ drop = root;
358
+ }
359
+ /* increment past last table */
360
+
361
+
362
+ next += min;
363
+ /* here min is 1 << curr */
364
+
365
+ /* determine length of next table */
366
+
367
+ curr = len - drop;
368
+ left = 1 << curr;
369
+
370
+ while (curr + drop < max) {
371
+ left -= count[curr + drop];
372
+
373
+ if (left <= 0) {
374
+ break;
375
+ }
376
+
377
+ curr++;
378
+ left <<= 1;
379
+ }
380
+ /* check for enough space */
381
+
382
+
383
+ used += 1 << curr;
384
+
385
+ if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
386
+ return 1;
387
+ }
388
+ /* point entry in root table to sub-table */
389
+
390
+
391
+ low = huff & mask;
392
+ /*table.op[low] = curr;
393
+ table.bits[low] = root;
394
+ table.val[low] = next - opts.table_index;*/
395
+
396
+ table[low] = root << 24 | curr << 16 | next - table_index | 0;
397
+ }
398
+ }
399
+ /* fill in remaining table entry if code is incomplete (guaranteed to have
400
+ at most one remaining entry, since if the code is incomplete, the
401
+ maximum code length that was allowed to get this far is one bit) */
402
+
403
+
404
+ if (huff !== 0) {
405
+ //table.op[next + huff] = 64; /* invalid code marker */
406
+ //table.bits[next + huff] = len - drop;
407
+ //table.val[next + huff] = 0;
408
+ table[next + huff] = len - drop << 24 | 64 << 16 | 0;
409
+ }
410
+ /* set return parameters */
411
+ //opts.table_index += used;
412
+
413
+
414
+ opts.bits = root;
415
+ return 0;
416
+ }
417
+
418
+ ;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ 2: 'need dictionary',
9
+
10
+ /* Z_NEED_DICT 2 */
11
+ 1: 'stream end',
12
+
13
+ /* Z_STREAM_END 1 */
14
+ 0: '',
15
+
16
+ /* Z_OK 0 */
17
+ '-1': 'file error',
18
+
19
+ /* Z_ERRNO (-1) */
20
+ '-2': 'stream error',
21
+
22
+ /* Z_STREAM_ERROR (-2) */
23
+ '-3': 'data error',
24
+
25
+ /* Z_DATA_ERROR (-3) */
26
+ '-4': 'insufficient memory',
27
+
28
+ /* Z_MEM_ERROR (-4) */
29
+ '-5': 'buffer error',
30
+
31
+ /* Z_BUF_ERROR (-5) */
32
+ '-6': 'incompatible version'
33
+ /* Z_VERSION_ERROR (-6) */
34
+
35
+ };
36
+ exports.default = _default;