@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,7 +1,6 @@
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
  });
@@ -16,28 +15,19 @@ exports.inflateReset = inflateReset;
16
15
  exports.inflateReset2 = inflateReset2;
17
16
  exports.inflateResetKeep = inflateResetKeep;
18
17
  exports.inflateSetDictionary = inflateSetDictionary;
19
-
20
18
  var utils = _interopRequireWildcard(require("../utils/common.js"));
21
-
22
19
  var _adler = _interopRequireDefault(require("./adler32.js"));
23
-
24
20
  var _crc = _interopRequireDefault(require("./crc32.js"));
25
-
26
21
  var _inffast = _interopRequireDefault(require("./inffast.js"));
27
-
28
22
  var _inftrees = _interopRequireDefault(require("./inftrees.js"));
29
-
30
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
31
-
32
24
  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); }
33
-
34
25
  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; }
35
-
36
26
  var CODES = 0;
37
27
  var LENS = 1;
38
28
  var DISTS = 2;
39
- /* Public constants ==========================================================*/
40
29
 
30
+ /* Public constants ==========================================================*/
41
31
  /* ===========================================================================*/
42
32
 
43
33
  /* Allowed flush values; see deflate() and inflate() below for details */
@@ -45,23 +35,22 @@ var DISTS = 2;
45
35
  //export const Z_PARTIAL_FLUSH = 1;
46
36
  //export const Z_SYNC_FLUSH = 2;
47
37
  //export const Z_FULL_FLUSH = 3;
48
-
49
38
  var Z_FINISH = 4;
50
39
  exports.Z_FINISH = Z_FINISH;
51
40
  var Z_BLOCK = 5;
52
41
  exports.Z_BLOCK = Z_BLOCK;
53
42
  var Z_TREES = 6;
43
+
54
44
  /* Return codes for the compression/decompression functions. Negative values
55
45
  * are errors, positive values are used for special but normal events.
56
46
  */
57
-
58
47
  exports.Z_TREES = Z_TREES;
59
48
  var Z_OK = 0;
60
49
  exports.Z_OK = Z_OK;
61
50
  var Z_STREAM_END = 1;
62
51
  exports.Z_STREAM_END = Z_STREAM_END;
63
- var Z_NEED_DICT = 2; //export const Z_ERRNO = -1;
64
-
52
+ var Z_NEED_DICT = 2;
53
+ //export const Z_ERRNO = -1;
65
54
  exports.Z_NEED_DICT = Z_NEED_DICT;
66
55
  var Z_STREAM_ERROR = -2;
67
56
  exports.Z_STREAM_ERROR = Z_STREAM_ERROR;
@@ -69,372 +58,216 @@ var Z_DATA_ERROR = -3;
69
58
  exports.Z_DATA_ERROR = Z_DATA_ERROR;
70
59
  var Z_MEM_ERROR = -4;
71
60
  exports.Z_MEM_ERROR = Z_MEM_ERROR;
72
- var Z_BUF_ERROR = -5; //export const Z_VERSION_ERROR = -6;
61
+ var Z_BUF_ERROR = -5;
62
+ //export const Z_VERSION_ERROR = -6;
73
63
 
74
64
  /* The deflate compression method */
75
-
76
65
  exports.Z_BUF_ERROR = Z_BUF_ERROR;
77
66
  var Z_DEFLATED = 8;
78
- /* STATES ====================================================================*/
79
67
 
68
+ /* STATES ====================================================================*/
80
69
  /* ===========================================================================*/
81
-
82
70
  exports.Z_DEFLATED = Z_DEFLATED;
83
- var HEAD = 1;
84
- /* i: waiting for magic header */
85
-
86
- var FLAGS = 2;
87
- /* i: waiting for method and flags (gzip) */
88
-
89
- var TIME = 3;
90
- /* i: waiting for modification time (gzip) */
91
-
92
- var OS = 4;
93
- /* i: waiting for extra flags and operating system (gzip) */
94
-
95
- var EXLEN = 5;
96
- /* i: waiting for extra length (gzip) */
97
-
98
- var EXTRA = 6;
99
- /* i: waiting for extra bytes (gzip) */
100
-
101
- var NAME = 7;
102
- /* i: waiting for end of file name (gzip) */
103
-
104
- var COMMENT = 8;
105
- /* i: waiting for end of comment (gzip) */
106
-
107
- var HCRC = 9;
108
- /* i: waiting for header crc (gzip) */
109
-
110
- var DICTID = 10;
111
- /* i: waiting for dictionary check value */
112
-
113
- var DICT = 11;
114
- /* waiting for inflateSetDictionary() call */
115
-
116
- var TYPE = 12;
117
- /* i: waiting for type bits, including last-flag bit */
118
-
119
- var TYPEDO = 13;
120
- /* i: same, but skip check to exit inflate on new block */
121
-
122
- var STORED = 14;
123
- /* i: waiting for stored size (length and complement) */
124
-
125
- var COPY_ = 15;
126
- /* i/o: same as COPY below, but only first time in */
127
-
128
- var COPY = 16;
129
- /* i/o: waiting for input or output to copy stored block */
130
-
131
- var TABLE = 17;
132
- /* i: waiting for dynamic block table lengths */
133
-
134
- var LENLENS = 18;
135
- /* i: waiting for code length code lengths */
136
-
137
- var CODELENS = 19;
138
- /* i: waiting for length/lit and distance code lengths */
139
-
140
- var LEN_ = 20;
141
- /* i: same as LEN below, but only first time in */
142
-
143
- var LEN = 21;
144
- /* i: waiting for length/lit/eob code */
145
-
146
- var LENEXT = 22;
147
- /* i: waiting for length extra bits */
148
-
149
- var DIST = 23;
150
- /* i: waiting for distance code */
151
-
152
- var DISTEXT = 24;
153
- /* i: waiting for distance extra bits */
154
-
155
- var MATCH = 25;
156
- /* o: waiting for output space to copy string */
157
-
158
- var LIT = 26;
159
- /* o: waiting for output space to write literal */
160
-
161
- var CHECK = 27;
162
- /* i: waiting for 32-bit check value */
163
-
164
- var LENGTH = 28;
165
- /* i: waiting for 32-bit length (gzip) */
166
-
167
- var DONE = 29;
168
- /* finished check, done -- remain here until reset */
169
-
170
- var BAD = 30;
171
- /* got a data error -- remain here until reset */
172
-
173
- var MEM = 31;
174
- /* got an inflate() memory error -- remain here until reset */
175
-
176
- var SYNC = 32;
177
- /* looking for synchronization bytes to restart inflate() */
71
+ var HEAD = 1; /* i: waiting for magic header */
72
+ var FLAGS = 2; /* i: waiting for method and flags (gzip) */
73
+ var TIME = 3; /* i: waiting for modification time (gzip) */
74
+ var OS = 4; /* i: waiting for extra flags and operating system (gzip) */
75
+ var EXLEN = 5; /* i: waiting for extra length (gzip) */
76
+ var EXTRA = 6; /* i: waiting for extra bytes (gzip) */
77
+ var NAME = 7; /* i: waiting for end of file name (gzip) */
78
+ var COMMENT = 8; /* i: waiting for end of comment (gzip) */
79
+ var HCRC = 9; /* i: waiting for header crc (gzip) */
80
+ var DICTID = 10; /* i: waiting for dictionary check value */
81
+ var DICT = 11; /* waiting for inflateSetDictionary() call */
82
+ var TYPE = 12; /* i: waiting for type bits, including last-flag bit */
83
+ var TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */
84
+ var STORED = 14; /* i: waiting for stored size (length and complement) */
85
+ var COPY_ = 15; /* i/o: same as COPY below, but only first time in */
86
+ var COPY = 16; /* i/o: waiting for input or output to copy stored block */
87
+ var TABLE = 17; /* i: waiting for dynamic block table lengths */
88
+ var LENLENS = 18; /* i: waiting for code length code lengths */
89
+ var CODELENS = 19; /* i: waiting for length/lit and distance code lengths */
90
+ var LEN_ = 20; /* i: same as LEN below, but only first time in */
91
+ var LEN = 21; /* i: waiting for length/lit/eob code */
92
+ var LENEXT = 22; /* i: waiting for length extra bits */
93
+ var DIST = 23; /* i: waiting for distance code */
94
+ var DISTEXT = 24; /* i: waiting for distance extra bits */
95
+ var MATCH = 25; /* o: waiting for output space to copy string */
96
+ var LIT = 26; /* o: waiting for output space to write literal */
97
+ var CHECK = 27; /* i: waiting for 32-bit check value */
98
+ var LENGTH = 28; /* i: waiting for 32-bit length (gzip) */
99
+ var DONE = 29; /* finished check, done -- remain here until reset */
100
+ var BAD = 30; /* got a data error -- remain here until reset */
101
+ var MEM = 31; /* got an inflate() memory error -- remain here until reset */
102
+ var SYNC = 32; /* looking for synchronization bytes to restart inflate() */
178
103
 
179
104
  /* ===========================================================================*/
180
105
 
181
106
  var ENOUGH_LENS = 852;
182
- var ENOUGH_DISTS = 592; //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
107
+ var ENOUGH_DISTS = 592;
108
+ //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
183
109
 
184
110
  var MAX_WBITS = 15;
185
111
  /* 32K LZ77 window */
186
-
187
112
  var DEF_WBITS = MAX_WBITS;
188
-
189
113
  function zswap32(q) {
190
114
  return (q >>> 24 & 0xff) + (q >>> 8 & 0xff00) + ((q & 0xff00) << 8) + ((q & 0xff) << 24);
191
115
  }
192
-
193
116
  function InflateState() {
194
- this.mode = 0;
195
- /* current inflate mode */
196
-
197
- this.last = false;
198
- /* true if processing last block */
199
-
200
- this.wrap = 0;
201
- /* bit 0 true for zlib, bit 1 true for gzip */
202
-
203
- this.havedict = false;
204
- /* true if dictionary provided */
205
-
206
- this.flags = 0;
207
- /* gzip header method and flags (0 if zlib) */
208
-
209
- this.dmax = 0;
210
- /* zlib header max distance (INFLATE_STRICT) */
211
-
212
- this.check = 0;
213
- /* protected copy of check value */
214
-
215
- this.total = 0;
216
- /* protected copy of output count */
117
+ this.mode = 0; /* current inflate mode */
118
+ this.last = false; /* true if processing last block */
119
+ this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */
120
+ this.havedict = false; /* true if dictionary provided */
121
+ this.flags = 0; /* gzip header method and flags (0 if zlib) */
122
+ this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */
123
+ this.check = 0; /* protected copy of check value */
124
+ this.total = 0; /* protected copy of output count */
217
125
  // TODO: may be {}
218
-
219
- this.head = null;
220
- /* where to save gzip header information */
126
+ this.head = null; /* where to save gzip header information */
221
127
 
222
128
  /* sliding window */
223
-
224
- this.wbits = 0;
225
- /* log base 2 of requested window size */
226
-
227
- this.wsize = 0;
228
- /* window size or zero if not using window */
229
-
230
- this.whave = 0;
231
- /* valid bytes in the window */
232
-
233
- this.wnext = 0;
234
- /* window write index */
235
-
236
- this.window = null;
237
- /* allocated sliding window, if needed */
129
+ this.wbits = 0; /* log base 2 of requested window size */
130
+ this.wsize = 0; /* window size or zero if not using window */
131
+ this.whave = 0; /* valid bytes in the window */
132
+ this.wnext = 0; /* window write index */
133
+ this.window = null; /* allocated sliding window, if needed */
238
134
 
239
135
  /* bit accumulator */
240
-
241
- this.hold = 0;
242
- /* input bit accumulator */
243
-
244
- this.bits = 0;
245
- /* number of bits in "in" */
136
+ this.hold = 0; /* input bit accumulator */
137
+ this.bits = 0; /* number of bits in "in" */
246
138
 
247
139
  /* for string and stored block copying */
248
-
249
- this.length = 0;
250
- /* literal or length of data to copy */
251
-
252
- this.offset = 0;
253
- /* distance back to copy string from */
140
+ this.length = 0; /* literal or length of data to copy */
141
+ this.offset = 0; /* distance back to copy string from */
254
142
 
255
143
  /* for table and code decoding */
256
-
257
- this.extra = 0;
258
- /* extra bits needed */
144
+ this.extra = 0; /* extra bits needed */
259
145
 
260
146
  /* fixed and dynamic code tables */
261
-
262
- this.lencode = null;
263
- /* starting table for length/literal codes */
264
-
265
- this.distcode = null;
266
- /* starting table for distance codes */
267
-
268
- this.lenbits = 0;
269
- /* index bits for lencode */
270
-
271
- this.distbits = 0;
272
- /* index bits for distcode */
147
+ this.lencode = null; /* starting table for length/literal codes */
148
+ this.distcode = null; /* starting table for distance codes */
149
+ this.lenbits = 0; /* index bits for lencode */
150
+ this.distbits = 0; /* index bits for distcode */
273
151
 
274
152
  /* dynamic table building */
153
+ this.ncode = 0; /* number of code length code lengths */
154
+ this.nlen = 0; /* number of length code lengths */
155
+ this.ndist = 0; /* number of distance code lengths */
156
+ this.have = 0; /* number of code lengths in lens[] */
157
+ this.next = null; /* next available space in codes[] */
275
158
 
276
- this.ncode = 0;
277
- /* number of code length code lengths */
278
-
279
- this.nlen = 0;
280
- /* number of length code lengths */
281
-
282
- this.ndist = 0;
283
- /* number of distance code lengths */
284
-
285
- this.have = 0;
286
- /* number of code lengths in lens[] */
287
-
288
- this.next = null;
289
- /* next available space in codes[] */
290
-
291
- this.lens = new utils.Buf16(320);
292
- /* temporary storage for code lengths */
293
-
294
- this.work = new utils.Buf16(288);
295
- /* work area for code table building */
159
+ this.lens = new utils.Buf16(320); /* temporary storage for code lengths */
160
+ this.work = new utils.Buf16(288); /* work area for code table building */
296
161
 
297
162
  /*
298
163
  because we don't have pointers in js, we use lencode and distcode directly
299
164
  as buffers so we don't need codes
300
165
  */
301
166
  //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */
302
-
303
- this.lendyn = null;
304
- /* dynamic table for length/literal codes (JS specific) */
305
-
306
- this.distdyn = null;
307
- /* dynamic table for distance codes (JS specific) */
308
-
309
- this.sane = 0;
310
- /* if false, allow invalid distance too far */
311
-
312
- this.back = 0;
313
- /* bits back of last unprocessed length/lit */
314
-
315
- this.was = 0;
316
- /* initial length of match */
167
+ this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */
168
+ this.distdyn = null; /* dynamic table for distance codes (JS specific) */
169
+ this.sane = 0; /* if false, allow invalid distance too far */
170
+ this.back = 0; /* bits back of last unprocessed length/lit */
171
+ this.was = 0; /* initial length of match */
317
172
  }
318
173
 
319
174
  function inflateResetKeep(strm) {
320
175
  var state;
321
-
322
176
  if (!strm || !strm.state) {
323
177
  return Z_STREAM_ERROR;
324
178
  }
325
-
326
179
  state = strm.state;
327
180
  strm.total_in = strm.total_out = state.total = 0;
328
- strm.msg = '';
329
- /*Z_NULL*/
330
-
181
+ strm.msg = ''; /*Z_NULL*/
331
182
  if (state.wrap) {
332
183
  /* to support ill-conceived Java test suite */
333
184
  strm.adler = state.wrap & 1;
334
185
  }
335
-
336
186
  state.mode = HEAD;
337
187
  state.last = 0;
338
188
  state.havedict = 0;
339
189
  state.dmax = 32768;
340
- state.head = null
341
- /*Z_NULL*/
342
- ;
190
+ state.head = null /*Z_NULL*/;
343
191
  state.hold = 0;
344
- state.bits = 0; //state.lencode = state.distcode = state.next = state.codes;
345
-
192
+ state.bits = 0;
193
+ //state.lencode = state.distcode = state.next = state.codes;
346
194
  state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);
347
195
  state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);
348
196
  state.sane = 1;
349
- state.back = -1; //Tracev((stderr, "inflate: reset\n"));
350
-
197
+ state.back = -1;
198
+ //Tracev((stderr, "inflate: reset\n"));
351
199
  return Z_OK;
352
200
  }
353
-
354
201
  function inflateReset(strm) {
355
202
  var state;
356
-
357
203
  if (!strm || !strm.state) {
358
204
  return Z_STREAM_ERROR;
359
205
  }
360
-
361
206
  state = strm.state;
362
207
  state.wsize = 0;
363
208
  state.whave = 0;
364
209
  state.wnext = 0;
365
210
  return inflateResetKeep(strm);
366
211
  }
367
-
368
212
  function inflateReset2(strm, windowBits) {
369
213
  var wrap;
370
214
  var state;
371
- /* get the state */
372
215
 
216
+ /* get the state */
373
217
  if (!strm || !strm.state) {
374
218
  return Z_STREAM_ERROR;
375
219
  }
376
-
377
220
  state = strm.state;
378
- /* extract wrap request from windowBits parameter */
379
221
 
222
+ /* extract wrap request from windowBits parameter */
380
223
  if (windowBits < 0) {
381
224
  wrap = 0;
382
225
  windowBits = -windowBits;
383
226
  } else {
384
227
  wrap = (windowBits >> 4) + 1;
385
-
386
228
  if (windowBits < 48) {
387
229
  windowBits &= 15;
388
230
  }
389
231
  }
390
- /* set number of window bits, free window if different */
391
-
392
232
 
233
+ /* set number of window bits, free window if different */
393
234
  if (windowBits && (windowBits < 8 || windowBits > 15)) {
394
235
  return Z_STREAM_ERROR;
395
236
  }
396
-
397
237
  if (state.window !== null && state.wbits !== windowBits) {
398
238
  state.window = null;
399
239
  }
400
- /* update state and reset the rest of it */
401
-
402
240
 
241
+ /* update state and reset the rest of it */
403
242
  state.wrap = wrap;
404
243
  state.wbits = windowBits;
405
244
  return inflateReset(strm);
406
245
  }
407
-
408
246
  function inflateInit2(strm, windowBits) {
409
247
  var ret;
410
248
  var state;
411
-
412
249
  if (!strm) {
413
250
  return Z_STREAM_ERROR;
414
- } //strm.msg = Z_NULL; /* in case we return an error */
251
+ }
252
+ //strm.msg = Z_NULL; /* in case we return an error */
415
253
 
254
+ state = new InflateState();
416
255
 
417
- state = new InflateState(); //if (state === Z_NULL) return Z_MEM_ERROR;
256
+ //if (state === Z_NULL) return Z_MEM_ERROR;
418
257
  //Tracev((stderr, "inflate: allocated\n"));
419
-
420
258
  strm.state = state;
421
- state.window = null
422
- /*Z_NULL*/
423
- ;
259
+ state.window = null /*Z_NULL*/;
424
260
  ret = inflateReset2(strm, windowBits);
425
-
426
261
  if (ret !== Z_OK) {
427
- strm.state = null
428
- /*Z_NULL*/
429
- ;
262
+ strm.state = null /*Z_NULL*/;
430
263
  }
431
264
 
432
265
  return ret;
433
266
  }
434
-
435
267
  function inflateInit(strm) {
436
268
  return inflateInit2(strm, DEF_WBITS);
437
269
  }
270
+
438
271
  /*
439
272
  Return state with length and distance decoding tables and index sizes set to
440
273
  fixed code decoding. Normally this returns fixed tables from inffixed.h.
@@ -445,8 +278,6 @@ function inflateInit(strm) {
445
278
  used for threaded applications, since the rewriting of the tables and virgin
446
279
  may not be thread-safe.
447
280
  */
448
-
449
-
450
281
  var virgin = true;
451
282
  var lenfix, distfix; // We have no pointers in JS, so keep tables separate
452
283
 
@@ -456,50 +287,43 @@ function fixedtables(state) {
456
287
  var sym;
457
288
  lenfix = new utils.Buf32(512);
458
289
  distfix = new utils.Buf32(32);
459
- /* literal/length table */
460
290
 
291
+ /* literal/length table */
461
292
  sym = 0;
462
-
463
293
  while (sym < 144) {
464
294
  state.lens[sym++] = 8;
465
295
  }
466
-
467
296
  while (sym < 256) {
468
297
  state.lens[sym++] = 9;
469
298
  }
470
-
471
299
  while (sym < 280) {
472
300
  state.lens[sym++] = 7;
473
301
  }
474
-
475
302
  while (sym < 288) {
476
303
  state.lens[sym++] = 8;
477
304
  }
478
-
479
305
  (0, _inftrees["default"])(LENS, state.lens, 0, 288, lenfix, 0, state.work, {
480
306
  bits: 9
481
307
  });
482
- /* distance table */
483
308
 
309
+ /* distance table */
484
310
  sym = 0;
485
-
486
311
  while (sym < 32) {
487
312
  state.lens[sym++] = 5;
488
313
  }
489
-
490
314
  (0, _inftrees["default"])(DISTS, state.lens, 0, 32, distfix, 0, state.work, {
491
315
  bits: 5
492
316
  });
493
- /* do this just once */
494
317
 
318
+ /* do this just once */
495
319
  virgin = false;
496
320
  }
497
-
498
321
  state.lencode = lenfix;
499
322
  state.lenbits = 9;
500
323
  state.distcode = distfix;
501
324
  state.distbits = 5;
502
325
  }
326
+
503
327
  /*
504
328
  Update the window with the last wsize (normally 32K) bytes written before
505
329
  returning. If window does not exist yet, create it. This is only called
@@ -514,37 +338,31 @@ function fixedtables(state) {
514
338
  output will fall in the output data, making match copies simpler and faster.
515
339
  The advantage may be dependent on the size of the processor's data caches.
516
340
  */
517
-
518
-
519
341
  function updatewindow(strm, src, end, copy) {
520
342
  var dist;
521
343
  var state = strm.state;
522
- /* if it hasn't been done already, allocate space for the window */
523
344
 
345
+ /* if it hasn't been done already, allocate space for the window */
524
346
  if (state.window === null) {
525
347
  state.wsize = 1 << state.wbits;
526
348
  state.wnext = 0;
527
349
  state.whave = 0;
528
350
  state.window = new utils.Buf8(state.wsize);
529
351
  }
530
- /* copy state->wsize or less output bytes into the circular window */
531
-
532
352
 
353
+ /* copy state->wsize or less output bytes into the circular window */
533
354
  if (copy >= state.wsize) {
534
355
  utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);
535
356
  state.wnext = 0;
536
357
  state.whave = state.wsize;
537
358
  } else {
538
359
  dist = state.wsize - state.wnext;
539
-
540
360
  if (dist > copy) {
541
361
  dist = copy;
542
- } //zmemcpy(state->window + state->wnext, end - copy, dist);
543
-
544
-
362
+ }
363
+ //zmemcpy(state->window + state->wnext, end - copy, dist);
545
364
  utils.arraySet(state.window, src, end - copy, dist, state.wnext);
546
365
  copy -= dist;
547
-
548
366
  if (copy) {
549
367
  //zmemcpy(state->window, end - copy, copy);
550
368
  utils.arraySet(state.window, src, end - copy, copy, 0);
@@ -552,87 +370,49 @@ function updatewindow(strm, src, end, copy) {
552
370
  state.whave = state.wsize;
553
371
  } else {
554
372
  state.wnext += dist;
555
-
556
373
  if (state.wnext === state.wsize) {
557
374
  state.wnext = 0;
558
375
  }
559
-
560
376
  if (state.whave < state.wsize) {
561
377
  state.whave += dist;
562
378
  }
563
379
  }
564
380
  }
565
-
566
381
  return 0;
567
382
  }
568
-
569
383
  function inflate(strm, flush) {
570
384
  var state;
571
385
  var input, output; // input/output buffers
572
-
573
- var next;
574
- /* next input INDEX */
575
-
576
- var put;
577
- /* next output INDEX */
578
-
579
- var have, left;
580
- /* available input and output */
581
-
582
- var hold;
583
- /* bit buffer */
584
-
585
- var bits;
586
- /* bits in bit buffer */
587
-
588
- var _in, _out;
589
- /* save starting available input and output */
590
-
591
-
592
- var copy;
593
- /* number of stored or match bytes to copy */
594
-
595
- var from;
596
- /* where to copy match bytes from */
597
-
386
+ var next; /* next input INDEX */
387
+ var put; /* next output INDEX */
388
+ var have, left; /* available input and output */
389
+ var hold; /* bit buffer */
390
+ var bits; /* bits in bit buffer */
391
+ var _in, _out; /* save starting available input and output */
392
+ var copy; /* number of stored or match bytes to copy */
393
+ var from; /* where to copy match bytes from */
598
394
  var from_source;
599
- var here = 0;
600
- /* current decoding table entry */
601
-
395
+ var here = 0; /* current decoding table entry */
602
396
  var here_bits, here_op, here_val; // paked "here" denormalized (JS specific)
603
397
  //var last; /* parent table entry */
604
-
605
398
  var last_bits, last_op, last_val; // paked "last" denormalized (JS specific)
606
-
607
- var len;
608
- /* length to copy for repeats, bits to drop */
609
-
610
- var ret;
611
- /* return code */
612
-
613
- var hbuf = new utils.Buf8(4);
614
- /* buffer for gzip header crc calculation */
615
-
399
+ var len; /* length to copy for repeats, bits to drop */
400
+ var ret; /* return code */
401
+ var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */
616
402
  var opts;
617
403
  var n; // temporary var for NEED_BITS
618
404
 
619
- var order =
620
- /* permutation of code lengths */
405
+ var order = /* permutation of code lengths */
621
406
  [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
622
-
623
407
  if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) {
624
408
  return Z_STREAM_ERROR;
625
409
  }
626
-
627
410
  state = strm.state;
628
-
629
411
  if (state.mode === TYPE) {
630
412
  state.mode = TYPEDO;
631
- }
632
- /* skip check */
633
- //--- LOAD() ---
634
-
413
+ } /* skip check */
635
414
 
415
+ //--- LOAD() ---
636
416
  put = strm.next_out;
637
417
  output = strm.output;
638
418
  left = strm.avail_out;
@@ -640,84 +420,67 @@ function inflate(strm, flush) {
640
420
  input = strm.input;
641
421
  have = strm.avail_in;
642
422
  hold = state.hold;
643
- bits = state.bits; //---
423
+ bits = state.bits;
424
+ //---
644
425
 
645
426
  _in = have;
646
427
  _out = left;
647
428
  ret = Z_OK;
648
-
649
- inf_leave: // goto emulation
429
+ inf_leave:
430
+ // goto emulation
650
431
  for (;;) {
651
432
  switch (state.mode) {
652
433
  case HEAD:
653
434
  if (state.wrap === 0) {
654
435
  state.mode = TYPEDO;
655
436
  break;
656
- } //=== NEEDBITS(16);
657
-
658
-
437
+ }
438
+ //=== NEEDBITS(16);
659
439
  while (bits < 16) {
660
440
  if (have === 0) {
661
441
  break inf_leave;
662
442
  }
663
-
664
443
  have--;
665
444
  hold += input[next++] << bits;
666
445
  bits += 8;
667
- } //===//
668
-
669
-
446
+ }
447
+ //===//
670
448
  if (state.wrap & 2 && hold === 0x8b1f) {
671
449
  /* gzip header */
672
- state.check = 0
673
- /*crc32(0L, Z_NULL, 0)*/
674
- ; //=== CRC2(state.check, hold);
675
-
450
+ state.check = 0 /*crc32(0L, Z_NULL, 0)*/;
451
+ //=== CRC2(state.check, hold);
676
452
  hbuf[0] = hold & 0xff;
677
453
  hbuf[1] = hold >>> 8 & 0xff;
678
- state.check = (0, _crc["default"])(state.check, hbuf, 2, 0); //===//
679
- //=== INITBITS();
454
+ state.check = (0, _crc["default"])(state.check, hbuf, 2, 0);
455
+ //===//
680
456
 
457
+ //=== INITBITS();
681
458
  hold = 0;
682
- bits = 0; //===//
683
-
459
+ bits = 0;
460
+ //===//
684
461
  state.mode = FLAGS;
685
462
  break;
686
463
  }
687
-
688
- state.flags = 0;
689
- /* expect zlib header */
690
-
464
+ state.flags = 0; /* expect zlib header */
691
465
  if (state.head) {
692
466
  state.head.done = false;
693
467
  }
694
-
695
- if (!(state.wrap & 1) ||
696
- /* check if zlib header allowed */
697
- (((hold & 0xff
698
- /*BITS(8)*/
699
- ) << 8) + (hold >> 8)) % 31) {
468
+ if (!(state.wrap & 1) || /* check if zlib header allowed */
469
+ (((hold & 0xff /*BITS(8)*/) << 8) + (hold >> 8)) % 31) {
700
470
  strm.msg = 'incorrect header check';
701
471
  state.mode = BAD;
702
472
  break;
703
473
  }
704
-
705
- if ((hold & 0x0f
706
- /*BITS(4)*/
707
- ) !== Z_DEFLATED) {
474
+ if ((hold & 0x0f /*BITS(4)*/) !== Z_DEFLATED) {
708
475
  strm.msg = 'unknown compression method';
709
476
  state.mode = BAD;
710
477
  break;
711
- } //--- DROPBITS(4) ---//
712
-
713
-
478
+ }
479
+ //--- DROPBITS(4) ---//
714
480
  hold >>>= 4;
715
- bits -= 4; //---//
716
-
717
- len = (hold & 0x0f
718
- /*BITS(4)*/
719
- ) + 8;
720
-
481
+ bits -= 4;
482
+ //---//
483
+ len = (hold & 0x0f /*BITS(4)*/) + 8;
721
484
  if (state.wbits === 0) {
722
485
  state.wbits = len;
723
486
  } else if (len > state.wbits) {
@@ -725,132 +488,110 @@ function inflate(strm, flush) {
725
488
  state.mode = BAD;
726
489
  break;
727
490
  }
728
-
729
- state.dmax = 1 << len; //Tracev((stderr, "inflate: zlib header ok\n"));
730
-
731
- strm.adler = state.check = 1
732
- /*adler32(0L, Z_NULL, 0)*/
733
- ;
734
- state.mode = hold & 0x200 ? DICTID : TYPE; //=== INITBITS();
735
-
491
+ state.dmax = 1 << len;
492
+ //Tracev((stderr, "inflate: zlib header ok\n"));
493
+ strm.adler = state.check = 1 /*adler32(0L, Z_NULL, 0)*/;
494
+ state.mode = hold & 0x200 ? DICTID : TYPE;
495
+ //=== INITBITS();
736
496
  hold = 0;
737
- bits = 0; //===//
738
-
497
+ bits = 0;
498
+ //===//
739
499
  break;
740
-
741
500
  case FLAGS:
742
501
  //=== NEEDBITS(16); */
743
502
  while (bits < 16) {
744
503
  if (have === 0) {
745
504
  break inf_leave;
746
505
  }
747
-
748
506
  have--;
749
507
  hold += input[next++] << bits;
750
508
  bits += 8;
751
- } //===//
752
-
753
-
509
+ }
510
+ //===//
754
511
  state.flags = hold;
755
-
756
512
  if ((state.flags & 0xff) !== Z_DEFLATED) {
757
513
  strm.msg = 'unknown compression method';
758
514
  state.mode = BAD;
759
515
  break;
760
516
  }
761
-
762
517
  if (state.flags & 0xe000) {
763
518
  strm.msg = 'unknown header flags set';
764
519
  state.mode = BAD;
765
520
  break;
766
521
  }
767
-
768
522
  if (state.head) {
769
523
  state.head.text = hold >> 8 & 1;
770
524
  }
771
-
772
525
  if (state.flags & 0x0200) {
773
526
  //=== CRC2(state.check, hold);
774
527
  hbuf[0] = hold & 0xff;
775
528
  hbuf[1] = hold >>> 8 & 0xff;
776
- state.check = (0, _crc["default"])(state.check, hbuf, 2, 0); //===//
777
- } //=== INITBITS();
778
-
779
-
529
+ state.check = (0, _crc["default"])(state.check, hbuf, 2, 0);
530
+ //===//
531
+ }
532
+ //=== INITBITS();
780
533
  hold = 0;
781
- bits = 0; //===//
782
-
534
+ bits = 0;
535
+ //===//
783
536
  state.mode = TIME;
784
-
785
537
  /* falls through */
786
-
787
538
  case TIME:
788
539
  //=== NEEDBITS(32); */
789
540
  while (bits < 32) {
790
541
  if (have === 0) {
791
542
  break inf_leave;
792
543
  }
793
-
794
544
  have--;
795
545
  hold += input[next++] << bits;
796
546
  bits += 8;
797
- } //===//
798
-
799
-
547
+ }
548
+ //===//
800
549
  if (state.head) {
801
550
  state.head.time = hold;
802
551
  }
803
-
804
552
  if (state.flags & 0x0200) {
805
553
  //=== CRC4(state.check, hold)
806
554
  hbuf[0] = hold & 0xff;
807
555
  hbuf[1] = hold >>> 8 & 0xff;
808
556
  hbuf[2] = hold >>> 16 & 0xff;
809
557
  hbuf[3] = hold >>> 24 & 0xff;
810
- state.check = (0, _crc["default"])(state.check, hbuf, 4, 0); //===
811
- } //=== INITBITS();
812
-
813
-
558
+ state.check = (0, _crc["default"])(state.check, hbuf, 4, 0);
559
+ //===
560
+ }
561
+ //=== INITBITS();
814
562
  hold = 0;
815
- bits = 0; //===//
816
-
563
+ bits = 0;
564
+ //===//
817
565
  state.mode = OS;
818
-
819
566
  /* falls through */
820
-
821
567
  case OS:
822
568
  //=== NEEDBITS(16); */
823
569
  while (bits < 16) {
824
570
  if (have === 0) {
825
571
  break inf_leave;
826
572
  }
827
-
828
573
  have--;
829
574
  hold += input[next++] << bits;
830
575
  bits += 8;
831
- } //===//
832
-
833
-
576
+ }
577
+ //===//
834
578
  if (state.head) {
835
579
  state.head.xflags = hold & 0xff;
836
580
  state.head.os = hold >> 8;
837
581
  }
838
-
839
582
  if (state.flags & 0x0200) {
840
583
  //=== CRC2(state.check, hold);
841
584
  hbuf[0] = hold & 0xff;
842
585
  hbuf[1] = hold >>> 8 & 0xff;
843
- state.check = (0, _crc["default"])(state.check, hbuf, 2, 0); //===//
844
- } //=== INITBITS();
845
-
846
-
586
+ state.check = (0, _crc["default"])(state.check, hbuf, 2, 0);
587
+ //===//
588
+ }
589
+ //=== INITBITS();
847
590
  hold = 0;
848
- bits = 0; //===//
849
-
591
+ bits = 0;
592
+ //===//
850
593
  state.mode = EXLEN;
851
-
852
594
  /* falls through */
853
-
854
595
  case EXLEN:
855
596
  if (state.flags & 0x0400) {
856
597
  //=== NEEDBITS(16); */
@@ -858,61 +599,51 @@ function inflate(strm, flush) {
858
599
  if (have === 0) {
859
600
  break inf_leave;
860
601
  }
861
-
862
602
  have--;
863
603
  hold += input[next++] << bits;
864
604
  bits += 8;
865
- } //===//
866
-
867
-
605
+ }
606
+ //===//
868
607
  state.length = hold;
869
-
870
608
  if (state.head) {
871
609
  state.head.extra_len = hold;
872
610
  }
873
-
874
611
  if (state.flags & 0x0200) {
875
612
  //=== CRC2(state.check, hold);
876
613
  hbuf[0] = hold & 0xff;
877
614
  hbuf[1] = hold >>> 8 & 0xff;
878
- state.check = (0, _crc["default"])(state.check, hbuf, 2, 0); //===//
879
- } //=== INITBITS();
880
-
881
-
615
+ state.check = (0, _crc["default"])(state.check, hbuf, 2, 0);
616
+ //===//
617
+ }
618
+ //=== INITBITS();
882
619
  hold = 0;
883
- bits = 0; //===//
620
+ bits = 0;
621
+ //===//
884
622
  } else if (state.head) {
885
- state.head.extra = null
886
- /*Z_NULL*/
887
- ;
623
+ state.head.extra = null /*Z_NULL*/;
888
624
  }
889
625
 
890
626
  state.mode = EXTRA;
891
-
892
627
  /* falls through */
893
-
894
628
  case EXTRA:
895
629
  if (state.flags & 0x0400) {
896
630
  copy = state.length;
897
-
898
631
  if (copy > have) {
899
632
  copy = have;
900
633
  }
901
-
902
634
  if (copy) {
903
635
  if (state.head) {
904
636
  len = state.head.extra_len - state.length;
905
-
906
637
  if (!state.head.extra) {
907
638
  // Use untyped array for more conveniend processing later
908
639
  state.head.extra = new Array(state.head.extra_len);
909
640
  }
910
-
911
- utils.arraySet(state.head.extra, input, next, // extra field is limited to 65536 bytes
641
+ utils.arraySet(state.head.extra, input, next,
642
+ // extra field is limited to 65536 bytes
912
643
  // - no need for additional size check
913
- copy,
914
- /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
915
- len); //zmemcpy(state.head.extra + len, next,
644
+ copy, /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
645
+ len);
646
+ //zmemcpy(state.head.extra + len, next,
916
647
  // len + copy > state.head.extra_max ?
917
648
  // state.head.extra_max - len : copy);
918
649
  }
@@ -920,98 +651,71 @@ function inflate(strm, flush) {
920
651
  if (state.flags & 0x0200) {
921
652
  state.check = (0, _crc["default"])(state.check, input, copy, next);
922
653
  }
923
-
924
654
  have -= copy;
925
655
  next += copy;
926
656
  state.length -= copy;
927
657
  }
928
-
929
658
  if (state.length) {
930
659
  break inf_leave;
931
660
  }
932
661
  }
933
-
934
662
  state.length = 0;
935
663
  state.mode = NAME;
936
-
937
664
  /* falls through */
938
-
939
665
  case NAME:
940
666
  if (state.flags & 0x0800) {
941
667
  if (have === 0) {
942
668
  break inf_leave;
943
669
  }
944
-
945
670
  copy = 0;
946
-
947
671
  do {
948
672
  // TODO: 2 or 1 bytes?
949
673
  len = input[next + copy++];
950
674
  /* use constant limit because in js we should not preallocate memory */
951
-
952
- if (state.head && len && state.length < 65536
953
- /*state.head.name_max*/
954
- ) {
675
+ if (state.head && len && state.length < 65536 /*state.head.name_max*/) {
955
676
  state.head.name += String.fromCharCode(len);
956
677
  }
957
678
  } while (len && copy < have);
958
-
959
679
  if (state.flags & 0x0200) {
960
680
  state.check = (0, _crc["default"])(state.check, input, copy, next);
961
681
  }
962
-
963
682
  have -= copy;
964
683
  next += copy;
965
-
966
684
  if (len) {
967
685
  break inf_leave;
968
686
  }
969
687
  } else if (state.head) {
970
688
  state.head.name = null;
971
689
  }
972
-
973
690
  state.length = 0;
974
691
  state.mode = COMMENT;
975
-
976
692
  /* falls through */
977
-
978
693
  case COMMENT:
979
694
  if (state.flags & 0x1000) {
980
695
  if (have === 0) {
981
696
  break inf_leave;
982
697
  }
983
-
984
698
  copy = 0;
985
-
986
699
  do {
987
700
  len = input[next + copy++];
988
701
  /* use constant limit because in js we should not preallocate memory */
989
-
990
- if (state.head && len && state.length < 65536
991
- /*state.head.comm_max*/
992
- ) {
702
+ if (state.head && len && state.length < 65536 /*state.head.comm_max*/) {
993
703
  state.head.comment += String.fromCharCode(len);
994
704
  }
995
705
  } while (len && copy < have);
996
-
997
706
  if (state.flags & 0x0200) {
998
707
  state.check = (0, _crc["default"])(state.check, input, copy, next);
999
708
  }
1000
-
1001
709
  have -= copy;
1002
710
  next += copy;
1003
-
1004
711
  if (len) {
1005
712
  break inf_leave;
1006
713
  }
1007
714
  } else if (state.head) {
1008
715
  state.head.comment = null;
1009
716
  }
1010
-
1011
717
  state.mode = HCRC;
1012
-
1013
718
  /* falls through */
1014
-
1015
719
  case HCRC:
1016
720
  if (state.flags & 0x0200) {
1017
721
  //=== NEEDBITS(16); */
@@ -1019,55 +723,47 @@ function inflate(strm, flush) {
1019
723
  if (have === 0) {
1020
724
  break inf_leave;
1021
725
  }
1022
-
1023
726
  have--;
1024
727
  hold += input[next++] << bits;
1025
728
  bits += 8;
1026
- } //===//
1027
-
1028
-
729
+ }
730
+ //===//
1029
731
  if (hold !== (state.check & 0xffff)) {
1030
732
  strm.msg = 'header crc mismatch';
1031
733
  state.mode = BAD;
1032
734
  break;
1033
- } //=== INITBITS();
1034
-
1035
-
735
+ }
736
+ //=== INITBITS();
1036
737
  hold = 0;
1037
- bits = 0; //===//
738
+ bits = 0;
739
+ //===//
1038
740
  }
1039
741
 
1040
742
  if (state.head) {
1041
743
  state.head.hcrc = state.flags >> 9 & 1;
1042
744
  state.head.done = true;
1043
745
  }
1044
-
1045
746
  strm.adler = state.check = 0;
1046
747
  state.mode = TYPE;
1047
748
  break;
1048
-
1049
749
  case DICTID:
1050
750
  //=== NEEDBITS(32); */
1051
751
  while (bits < 32) {
1052
752
  if (have === 0) {
1053
753
  break inf_leave;
1054
754
  }
1055
-
1056
755
  have--;
1057
756
  hold += input[next++] << bits;
1058
757
  bits += 8;
1059
- } //===//
1060
-
1061
-
1062
- strm.adler = state.check = zswap32(hold); //=== INITBITS();
1063
-
758
+ }
759
+ //===//
760
+ strm.adler = state.check = zswap32(hold);
761
+ //=== INITBITS();
1064
762
  hold = 0;
1065
- bits = 0; //===//
1066
-
763
+ bits = 0;
764
+ //===//
1067
765
  state.mode = DICT;
1068
-
1069
766
  /* falls through */
1070
-
1071
767
  case DICT:
1072
768
  if (state.havedict === 0) {
1073
769
  //--- RESTORE() ---
@@ -1076,222 +772,176 @@ function inflate(strm, flush) {
1076
772
  strm.next_in = next;
1077
773
  strm.avail_in = have;
1078
774
  state.hold = hold;
1079
- state.bits = bits; //---
1080
-
775
+ state.bits = bits;
776
+ //---
1081
777
  return Z_NEED_DICT;
1082
778
  }
1083
-
1084
- strm.adler = state.check = 1
1085
- /*adler32(0L, Z_NULL, 0)*/
1086
- ;
779
+ strm.adler = state.check = 1 /*adler32(0L, Z_NULL, 0)*/;
1087
780
  state.mode = TYPE;
1088
-
1089
781
  /* falls through */
1090
-
1091
782
  case TYPE:
1092
783
  if (flush === Z_BLOCK || flush === Z_TREES) {
1093
784
  break inf_leave;
1094
785
  }
1095
-
1096
786
  /* falls through */
1097
-
1098
787
  case TYPEDO:
1099
788
  if (state.last) {
1100
789
  //--- BYTEBITS() ---//
1101
790
  hold >>>= bits & 7;
1102
- bits -= bits & 7; //---//
1103
-
791
+ bits -= bits & 7;
792
+ //---//
1104
793
  state.mode = CHECK;
1105
794
  break;
1106
- } //=== NEEDBITS(3); */
1107
-
1108
-
795
+ }
796
+ //=== NEEDBITS(3); */
1109
797
  while (bits < 3) {
1110
798
  if (have === 0) {
1111
799
  break inf_leave;
1112
800
  }
1113
-
1114
801
  have--;
1115
802
  hold += input[next++] << bits;
1116
803
  bits += 8;
1117
- } //===//
1118
-
1119
-
1120
- state.last = hold & 0x01
1121
- /*BITS(1)*/
1122
- ; //--- DROPBITS(1) ---//
1123
-
804
+ }
805
+ //===//
806
+ state.last = hold & 0x01 /*BITS(1)*/;
807
+ //--- DROPBITS(1) ---//
1124
808
  hold >>>= 1;
1125
- bits -= 1; //---//
809
+ bits -= 1;
810
+ //---//
1126
811
 
1127
- switch (hold & 0x03
1128
- /*BITS(2)*/
1129
- ) {
812
+ switch (hold & 0x03 /*BITS(2)*/) {
1130
813
  case 0:
1131
814
  /* stored block */
1132
815
  //Tracev((stderr, "inflate: stored block%s\n",
1133
816
  // state.last ? " (last)" : ""));
1134
817
  state.mode = STORED;
1135
818
  break;
1136
-
1137
819
  case 1:
1138
820
  /* fixed block */
1139
- fixedtables(state); //Tracev((stderr, "inflate: fixed codes block%s\n",
821
+ fixedtables(state);
822
+ //Tracev((stderr, "inflate: fixed codes block%s\n",
1140
823
  // state.last ? " (last)" : ""));
1141
-
1142
- state.mode = LEN_;
1143
- /* decode codes */
1144
-
824
+ state.mode = LEN_; /* decode codes */
1145
825
  if (flush === Z_TREES) {
1146
826
  //--- DROPBITS(2) ---//
1147
827
  hold >>>= 2;
1148
- bits -= 2; //---//
1149
-
828
+ bits -= 2;
829
+ //---//
1150
830
  break inf_leave;
1151
831
  }
1152
-
1153
832
  break;
1154
-
1155
833
  case 2:
1156
834
  /* dynamic block */
1157
835
  //Tracev((stderr, "inflate: dynamic codes block%s\n",
1158
836
  // state.last ? " (last)" : ""));
1159
837
  state.mode = TABLE;
1160
838
  break;
1161
-
1162
839
  case 3:
1163
840
  strm.msg = 'invalid block type';
1164
841
  state.mode = BAD;
1165
- } //--- DROPBITS(2) ---//
1166
-
1167
-
842
+ }
843
+ //--- DROPBITS(2) ---//
1168
844
  hold >>>= 2;
1169
- bits -= 2; //---//
1170
-
845
+ bits -= 2;
846
+ //---//
1171
847
  break;
1172
-
1173
848
  case STORED:
1174
849
  //--- BYTEBITS() ---// /* go to byte boundary */
1175
850
  hold >>>= bits & 7;
1176
- bits -= bits & 7; //---//
851
+ bits -= bits & 7;
852
+ //---//
1177
853
  //=== NEEDBITS(32); */
1178
-
1179
854
  while (bits < 32) {
1180
855
  if (have === 0) {
1181
856
  break inf_leave;
1182
857
  }
1183
-
1184
858
  have--;
1185
859
  hold += input[next++] << bits;
1186
860
  bits += 8;
1187
- } //===//
1188
-
1189
-
861
+ }
862
+ //===//
1190
863
  if ((hold & 0xffff) !== (hold >>> 16 ^ 0xffff)) {
1191
864
  strm.msg = 'invalid stored block lengths';
1192
865
  state.mode = BAD;
1193
866
  break;
1194
867
  }
1195
-
1196
- state.length = hold & 0xffff; //Tracev((stderr, "inflate: stored length %u\n",
868
+ state.length = hold & 0xffff;
869
+ //Tracev((stderr, "inflate: stored length %u\n",
1197
870
  // state.length));
1198
871
  //=== INITBITS();
1199
-
1200
872
  hold = 0;
1201
- bits = 0; //===//
1202
-
873
+ bits = 0;
874
+ //===//
1203
875
  state.mode = COPY_;
1204
-
1205
876
  if (flush === Z_TREES) {
1206
877
  break inf_leave;
1207
878
  }
1208
-
1209
879
  /* falls through */
1210
-
1211
880
  case COPY_:
1212
881
  state.mode = COPY;
1213
-
1214
882
  /* falls through */
1215
-
1216
883
  case COPY:
1217
884
  copy = state.length;
1218
-
1219
885
  if (copy) {
1220
886
  if (copy > have) {
1221
887
  copy = have;
1222
888
  }
1223
-
1224
889
  if (copy > left) {
1225
890
  copy = left;
1226
891
  }
1227
-
1228
892
  if (copy === 0) {
1229
893
  break inf_leave;
1230
- } //--- zmemcpy(put, next, copy); ---
1231
-
1232
-
1233
- utils.arraySet(output, input, next, copy, put); //---//
1234
-
894
+ }
895
+ //--- zmemcpy(put, next, copy); ---
896
+ utils.arraySet(output, input, next, copy, put);
897
+ //---//
1235
898
  have -= copy;
1236
899
  next += copy;
1237
900
  left -= copy;
1238
901
  put += copy;
1239
902
  state.length -= copy;
1240
- break;
1241
- } //Tracev((stderr, "inflate: stored end\n"));
1242
-
1243
-
903
+ break;
904
+ }
905
+ //Tracev((stderr, "inflate: stored end\n"));
1244
906
  state.mode = TYPE;
1245
907
  break;
1246
-
1247
908
  case TABLE:
1248
909
  //=== NEEDBITS(14); */
1249
910
  while (bits < 14) {
1250
911
  if (have === 0) {
1251
912
  break inf_leave;
1252
913
  }
1253
-
1254
914
  have--;
1255
915
  hold += input[next++] << bits;
1256
916
  bits += 8;
1257
- } //===//
1258
-
1259
-
1260
- state.nlen = (hold & 0x1f
1261
- /*BITS(5)*/
1262
- ) + 257; //--- DROPBITS(5) ---//
1263
-
917
+ }
918
+ //===//
919
+ state.nlen = (hold & 0x1f /*BITS(5)*/) + 257;
920
+ //--- DROPBITS(5) ---//
1264
921
  hold >>>= 5;
1265
- bits -= 5; //---//
1266
-
1267
- state.ndist = (hold & 0x1f
1268
- /*BITS(5)*/
1269
- ) + 1; //--- DROPBITS(5) ---//
1270
-
922
+ bits -= 5;
923
+ //---//
924
+ state.ndist = (hold & 0x1f /*BITS(5)*/) + 1;
925
+ //--- DROPBITS(5) ---//
1271
926
  hold >>>= 5;
1272
- bits -= 5; //---//
1273
-
1274
- state.ncode = (hold & 0x0f
1275
- /*BITS(4)*/
1276
- ) + 4; //--- DROPBITS(4) ---//
1277
-
927
+ bits -= 5;
928
+ //---//
929
+ state.ncode = (hold & 0x0f /*BITS(4)*/) + 4;
930
+ //--- DROPBITS(4) ---//
1278
931
  hold >>>= 4;
1279
- bits -= 4; //---//
932
+ bits -= 4;
933
+ //---//
1280
934
  //#ifndef PKZIP_BUG_WORKAROUND
1281
-
1282
935
  if (state.nlen > 286 || state.ndist > 30) {
1283
936
  strm.msg = 'too many length or distance symbols';
1284
937
  state.mode = BAD;
1285
938
  break;
1286
- } //#endif
939
+ }
940
+ //#endif
1287
941
  //Tracev((stderr, "inflate: table sizes ok\n"));
1288
-
1289
-
1290
942
  state.have = 0;
1291
943
  state.mode = LENLENS;
1292
-
1293
944
  /* falls through */
1294
-
1295
945
  case LENLENS:
1296
946
  while (state.have < state.ncode) {
1297
947
  //=== NEEDBITS(3);
@@ -1299,28 +949,25 @@ function inflate(strm, flush) {
1299
949
  if (have === 0) {
1300
950
  break inf_leave;
1301
951
  }
1302
-
1303
952
  have--;
1304
953
  hold += input[next++] << bits;
1305
954
  bits += 8;
1306
- } //===//
1307
-
1308
-
955
+ }
956
+ //===//
1309
957
  state.lens[order[state.have++]] = hold & 0x07; //BITS(3);
1310
958
  //--- DROPBITS(3) ---//
1311
-
1312
959
  hold >>>= 3;
1313
- bits -= 3; //---//
960
+ bits -= 3;
961
+ //---//
1314
962
  }
1315
963
 
1316
964
  while (state.have < 19) {
1317
965
  state.lens[order[state.have++]] = 0;
1318
- } // We have separate tables & no pointers. 2 commented lines below not needed.
966
+ }
967
+ // We have separate tables & no pointers. 2 commented lines below not needed.
1319
968
  //state.next = state.codes;
1320
969
  //state.lencode = state.next;
1321
970
  // Switch to use dynamic table
1322
-
1323
-
1324
971
  state.lencode = state.lendyn;
1325
972
  state.lenbits = 7;
1326
973
  opts = {
@@ -1328,131 +975,113 @@ function inflate(strm, flush) {
1328
975
  };
1329
976
  ret = (0, _inftrees["default"])(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);
1330
977
  state.lenbits = opts.bits;
1331
-
1332
978
  if (ret) {
1333
979
  strm.msg = 'invalid code lengths set';
1334
980
  state.mode = BAD;
1335
981
  break;
1336
- } //Tracev((stderr, "inflate: code lengths ok\n"));
1337
-
1338
-
982
+ }
983
+ //Tracev((stderr, "inflate: code lengths ok\n"));
1339
984
  state.have = 0;
1340
985
  state.mode = CODELENS;
1341
-
1342
986
  /* falls through */
1343
-
1344
987
  case CODELENS:
1345
988
  while (state.have < state.nlen + state.ndist) {
1346
989
  for (;;) {
1347
- here = state.lencode[hold & (1 << state.lenbits) - 1];
1348
- /*BITS(state.lenbits)*/
1349
-
990
+ here = state.lencode[hold & (1 << state.lenbits) - 1]; /*BITS(state.lenbits)*/
1350
991
  here_bits = here >>> 24;
1351
992
  here_op = here >>> 16 & 0xff;
1352
993
  here_val = here & 0xffff;
1353
-
1354
994
  if (here_bits <= bits) {
1355
995
  break;
1356
- } //--- PULLBYTE() ---//
1357
-
1358
-
996
+ }
997
+ //--- PULLBYTE() ---//
1359
998
  if (have === 0) {
1360
999
  break inf_leave;
1361
1000
  }
1362
-
1363
1001
  have--;
1364
1002
  hold += input[next++] << bits;
1365
- bits += 8; //---//
1003
+ bits += 8;
1004
+ //---//
1366
1005
  }
1367
1006
 
1368
1007
  if (here_val < 16) {
1369
1008
  //--- DROPBITS(here.bits) ---//
1370
1009
  hold >>>= here_bits;
1371
- bits -= here_bits; //---//
1372
-
1010
+ bits -= here_bits;
1011
+ //---//
1373
1012
  state.lens[state.have++] = here_val;
1374
1013
  } else {
1375
1014
  if (here_val === 16) {
1376
1015
  //=== NEEDBITS(here.bits + 2);
1377
1016
  n = here_bits + 2;
1378
-
1379
1017
  while (bits < n) {
1380
1018
  if (have === 0) {
1381
1019
  break inf_leave;
1382
1020
  }
1383
-
1384
1021
  have--;
1385
1022
  hold += input[next++] << bits;
1386
1023
  bits += 8;
1387
- } //===//
1024
+ }
1025
+ //===//
1388
1026
  //--- DROPBITS(here.bits) ---//
1389
-
1390
-
1391
1027
  hold >>>= here_bits;
1392
- bits -= here_bits; //---//
1393
-
1028
+ bits -= here_bits;
1029
+ //---//
1394
1030
  if (state.have === 0) {
1395
1031
  strm.msg = 'invalid bit length repeat';
1396
1032
  state.mode = BAD;
1397
1033
  break;
1398
1034
  }
1399
-
1400
1035
  len = state.lens[state.have - 1];
1401
1036
  copy = 3 + (hold & 0x03); //BITS(2);
1402
1037
  //--- DROPBITS(2) ---//
1403
-
1404
1038
  hold >>>= 2;
1405
- bits -= 2; //---//
1039
+ bits -= 2;
1040
+ //---//
1406
1041
  } else if (here_val === 17) {
1407
1042
  //=== NEEDBITS(here.bits + 3);
1408
1043
  n = here_bits + 3;
1409
-
1410
1044
  while (bits < n) {
1411
1045
  if (have === 0) {
1412
1046
  break inf_leave;
1413
1047
  }
1414
-
1415
1048
  have--;
1416
1049
  hold += input[next++] << bits;
1417
1050
  bits += 8;
1418
- } //===//
1051
+ }
1052
+ //===//
1419
1053
  //--- DROPBITS(here.bits) ---//
1420
-
1421
-
1422
1054
  hold >>>= here_bits;
1423
- bits -= here_bits; //---//
1424
-
1055
+ bits -= here_bits;
1056
+ //---//
1425
1057
  len = 0;
1426
1058
  copy = 3 + (hold & 0x07); //BITS(3);
1427
1059
  //--- DROPBITS(3) ---//
1428
-
1429
1060
  hold >>>= 3;
1430
- bits -= 3; //---//
1061
+ bits -= 3;
1062
+ //---//
1431
1063
  } else {
1432
1064
  //=== NEEDBITS(here.bits + 7);
1433
1065
  n = here_bits + 7;
1434
-
1435
1066
  while (bits < n) {
1436
1067
  if (have === 0) {
1437
1068
  break inf_leave;
1438
1069
  }
1439
-
1440
1070
  have--;
1441
1071
  hold += input[next++] << bits;
1442
1072
  bits += 8;
1443
- } //===//
1073
+ }
1074
+ //===//
1444
1075
  //--- DROPBITS(here.bits) ---//
1445
-
1446
-
1447
1076
  hold >>>= here_bits;
1448
- bits -= here_bits; //---//
1449
-
1077
+ bits -= here_bits;
1078
+ //---//
1450
1079
  len = 0;
1451
1080
  copy = 11 + (hold & 0x7f); //BITS(7);
1452
1081
  //--- DROPBITS(7) ---//
1453
-
1454
1082
  hold >>>= 7;
1455
- bits -= 7; //---//
1083
+ bits -= 7;
1084
+ //---//
1456
1085
  }
1457
1086
 
1458
1087
  if (state.have + copy > state.nlen + state.ndist) {
@@ -1460,78 +1089,69 @@ function inflate(strm, flush) {
1460
1089
  state.mode = BAD;
1461
1090
  break;
1462
1091
  }
1463
-
1464
1092
  while (copy--) {
1465
1093
  state.lens[state.have++] = len;
1466
1094
  }
1467
1095
  }
1468
1096
  }
1469
- /* handle error breaks in while */
1470
-
1471
1097
 
1098
+ /* handle error breaks in while */
1472
1099
  if (state.mode === BAD) {
1473
1100
  break;
1474
1101
  }
1475
- /* check for end-of-block code (better have one) */
1476
-
1477
1102
 
1103
+ /* check for end-of-block code (better have one) */
1478
1104
  if (state.lens[256] === 0) {
1479
1105
  strm.msg = 'invalid code -- missing end-of-block';
1480
1106
  state.mode = BAD;
1481
1107
  break;
1482
1108
  }
1109
+
1483
1110
  /* build code tables -- note: do not change the lenbits or distbits
1484
1111
  values here (9 and 6) without reading the comments in inftrees.h
1485
1112
  concerning the ENOUGH constants, which depend on those values */
1486
-
1487
-
1488
1113
  state.lenbits = 9;
1489
1114
  opts = {
1490
1115
  bits: state.lenbits
1491
1116
  };
1492
- ret = (0, _inftrees["default"])(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts); // We have separate tables & no pointers. 2 commented lines below not needed.
1117
+ ret = (0, _inftrees["default"])(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);
1118
+ // We have separate tables & no pointers. 2 commented lines below not needed.
1493
1119
  // state.next_index = opts.table_index;
1494
-
1495
- state.lenbits = opts.bits; // state.lencode = state.next;
1120
+ state.lenbits = opts.bits;
1121
+ // state.lencode = state.next;
1496
1122
 
1497
1123
  if (ret) {
1498
1124
  strm.msg = 'invalid literal/lengths set';
1499
1125
  state.mode = BAD;
1500
1126
  break;
1501
1127
  }
1502
-
1503
- state.distbits = 6; //state.distcode.copy(state.codes);
1128
+ state.distbits = 6;
1129
+ //state.distcode.copy(state.codes);
1504
1130
  // Switch to use dynamic table
1505
-
1506
1131
  state.distcode = state.distdyn;
1507
1132
  opts = {
1508
1133
  bits: state.distbits
1509
1134
  };
1510
- ret = (0, _inftrees["default"])(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts); // We have separate tables & no pointers. 2 commented lines below not needed.
1135
+ ret = (0, _inftrees["default"])(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);
1136
+ // We have separate tables & no pointers. 2 commented lines below not needed.
1511
1137
  // state.next_index = opts.table_index;
1512
-
1513
- state.distbits = opts.bits; // state.distcode = state.next;
1138
+ state.distbits = opts.bits;
1139
+ // state.distcode = state.next;
1514
1140
 
1515
1141
  if (ret) {
1516
1142
  strm.msg = 'invalid distances set';
1517
1143
  state.mode = BAD;
1518
1144
  break;
1519
- } //Tracev((stderr, 'inflate: codes ok\n'));
1520
-
1521
-
1145
+ }
1146
+ //Tracev((stderr, 'inflate: codes ok\n'));
1522
1147
  state.mode = LEN_;
1523
-
1524
1148
  if (flush === Z_TREES) {
1525
1149
  break inf_leave;
1526
1150
  }
1527
-
1528
1151
  /* falls through */
1529
-
1530
1152
  case LEN_:
1531
1153
  state.mode = LEN;
1532
-
1533
1154
  /* falls through */
1534
-
1535
1155
  case LEN:
1536
1156
  if (have >= 6 && left >= 258) {
1537
1157
  //--- RESTORE() ---
@@ -1540,10 +1160,10 @@ function inflate(strm, flush) {
1540
1160
  strm.next_in = next;
1541
1161
  strm.avail_in = have;
1542
1162
  state.hold = hold;
1543
- state.bits = bits; //---
1544
-
1545
- (0, _inffast["default"])(strm, _out); //--- LOAD() ---
1546
-
1163
+ state.bits = bits;
1164
+ //---
1165
+ (0, _inffast["default"])(strm, _out);
1166
+ //--- LOAD() ---
1547
1167
  put = strm.next_out;
1548
1168
  output = strm.output;
1549
1169
  left = strm.avail_out;
@@ -1551,80 +1171,66 @@ function inflate(strm, flush) {
1551
1171
  input = strm.input;
1552
1172
  have = strm.avail_in;
1553
1173
  hold = state.hold;
1554
- bits = state.bits; //---
1174
+ bits = state.bits;
1175
+ //---
1555
1176
 
1556
1177
  if (state.mode === TYPE) {
1557
1178
  state.back = -1;
1558
1179
  }
1559
-
1560
1180
  break;
1561
1181
  }
1562
-
1563
1182
  state.back = 0;
1564
-
1565
1183
  for (;;) {
1566
- here = state.lencode[hold & (1 << state.lenbits) - 1];
1567
- /*BITS(state.lenbits)*/
1568
-
1184
+ here = state.lencode[hold & (1 << state.lenbits) - 1]; /*BITS(state.lenbits)*/
1569
1185
  here_bits = here >>> 24;
1570
1186
  here_op = here >>> 16 & 0xff;
1571
1187
  here_val = here & 0xffff;
1572
-
1573
1188
  if (here_bits <= bits) {
1574
1189
  break;
1575
- } //--- PULLBYTE() ---//
1576
-
1577
-
1190
+ }
1191
+ //--- PULLBYTE() ---//
1578
1192
  if (have === 0) {
1579
1193
  break inf_leave;
1580
1194
  }
1581
-
1582
1195
  have--;
1583
1196
  hold += input[next++] << bits;
1584
- bits += 8; //---//
1197
+ bits += 8;
1198
+ //---//
1585
1199
  }
1586
1200
 
1587
1201
  if (here_op && (here_op & 0xf0) === 0) {
1588
1202
  last_bits = here_bits;
1589
1203
  last_op = here_op;
1590
1204
  last_val = here_val;
1591
-
1592
1205
  for (;;) {
1593
- here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1
1594
- /*BITS(last.bits + last.op)*/
1595
- ) >> last_bits)];
1206
+ here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1 /*BITS(last.bits + last.op)*/) >> last_bits)];
1596
1207
  here_bits = here >>> 24;
1597
1208
  here_op = here >>> 16 & 0xff;
1598
1209
  here_val = here & 0xffff;
1599
-
1600
1210
  if (last_bits + here_bits <= bits) {
1601
1211
  break;
1602
- } //--- PULLBYTE() ---//
1603
-
1604
-
1212
+ }
1213
+ //--- PULLBYTE() ---//
1605
1214
  if (have === 0) {
1606
1215
  break inf_leave;
1607
1216
  }
1608
-
1609
1217
  have--;
1610
1218
  hold += input[next++] << bits;
1611
- bits += 8; //---//
1612
- } //--- DROPBITS(last.bits) ---//
1613
-
1614
-
1219
+ bits += 8;
1220
+ //---//
1221
+ }
1222
+ //--- DROPBITS(last.bits) ---//
1615
1223
  hold >>>= last_bits;
1616
- bits -= last_bits; //---//
1617
-
1224
+ bits -= last_bits;
1225
+ //---//
1618
1226
  state.back += last_bits;
1619
- } //--- DROPBITS(here.bits) ---//
1620
-
1621
-
1227
+ }
1228
+ //--- DROPBITS(here.bits) ---//
1622
1229
  hold >>>= here_bits;
1623
- bits -= here_bits; //---//
1624
-
1230
+ bits -= here_bits;
1231
+ //---//
1625
1232
  state.back += here_bits;
1626
1233
  state.length = here_val;
1627
-
1628
1234
  if (here_op === 0) {
1629
1235
  //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
1630
1236
  // "inflate: literal '%c'\n" :
@@ -1632,188 +1238,149 @@ function inflate(strm, flush) {
1632
1238
  state.mode = LIT;
1633
1239
  break;
1634
1240
  }
1635
-
1636
1241
  if (here_op & 32) {
1637
1242
  //Tracevv((stderr, "inflate: end of block\n"));
1638
1243
  state.back = -1;
1639
1244
  state.mode = TYPE;
1640
1245
  break;
1641
1246
  }
1642
-
1643
1247
  if (here_op & 64) {
1644
1248
  strm.msg = 'invalid literal/length code';
1645
1249
  state.mode = BAD;
1646
1250
  break;
1647
1251
  }
1648
-
1649
1252
  state.extra = here_op & 15;
1650
1253
  state.mode = LENEXT;
1651
-
1652
1254
  /* falls through */
1653
-
1654
1255
  case LENEXT:
1655
1256
  if (state.extra) {
1656
1257
  //=== NEEDBITS(state.extra);
1657
1258
  n = state.extra;
1658
-
1659
1259
  while (bits < n) {
1660
1260
  if (have === 0) {
1661
1261
  break inf_leave;
1662
1262
  }
1663
-
1664
1263
  have--;
1665
1264
  hold += input[next++] << bits;
1666
1265
  bits += 8;
1667
- } //===//
1668
-
1669
-
1670
- state.length += hold & (1 << state.extra) - 1
1671
- /*BITS(state.extra)*/
1672
- ; //--- DROPBITS(state.extra) ---//
1673
-
1266
+ }
1267
+ //===//
1268
+ state.length += hold & (1 << state.extra) - 1 /*BITS(state.extra)*/;
1269
+ //--- DROPBITS(state.extra) ---//
1674
1270
  hold >>>= state.extra;
1675
- bits -= state.extra; //---//
1676
-
1271
+ bits -= state.extra;
1272
+ //---//
1677
1273
  state.back += state.extra;
1678
- } //Tracevv((stderr, "inflate: length %u\n", state.length));
1679
-
1680
-
1274
+ }
1275
+ //Tracevv((stderr, "inflate: length %u\n", state.length));
1681
1276
  state.was = state.length;
1682
1277
  state.mode = DIST;
1683
-
1684
1278
  /* falls through */
1685
-
1686
1279
  case DIST:
1687
1280
  for (;;) {
1688
- here = state.distcode[hold & (1 << state.distbits) - 1];
1689
- /*BITS(state.distbits)*/
1690
-
1281
+ here = state.distcode[hold & (1 << state.distbits) - 1]; /*BITS(state.distbits)*/
1691
1282
  here_bits = here >>> 24;
1692
1283
  here_op = here >>> 16 & 0xff;
1693
1284
  here_val = here & 0xffff;
1694
-
1695
1285
  if (here_bits <= bits) {
1696
1286
  break;
1697
- } //--- PULLBYTE() ---//
1698
-
1699
-
1287
+ }
1288
+ //--- PULLBYTE() ---//
1700
1289
  if (have === 0) {
1701
1290
  break inf_leave;
1702
1291
  }
1703
-
1704
1292
  have--;
1705
1293
  hold += input[next++] << bits;
1706
- bits += 8; //---//
1294
+ bits += 8;
1295
+ //---//
1707
1296
  }
1708
1297
 
1709
1298
  if ((here_op & 0xf0) === 0) {
1710
1299
  last_bits = here_bits;
1711
1300
  last_op = here_op;
1712
1301
  last_val = here_val;
1713
-
1714
1302
  for (;;) {
1715
- here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1
1716
- /*BITS(last.bits + last.op)*/
1717
- ) >> last_bits)];
1303
+ here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1 /*BITS(last.bits + last.op)*/) >> last_bits)];
1718
1304
  here_bits = here >>> 24;
1719
1305
  here_op = here >>> 16 & 0xff;
1720
1306
  here_val = here & 0xffff;
1721
-
1722
1307
  if (last_bits + here_bits <= bits) {
1723
1308
  break;
1724
- } //--- PULLBYTE() ---//
1725
-
1726
-
1309
+ }
1310
+ //--- PULLBYTE() ---//
1727
1311
  if (have === 0) {
1728
1312
  break inf_leave;
1729
1313
  }
1730
-
1731
1314
  have--;
1732
1315
  hold += input[next++] << bits;
1733
- bits += 8; //---//
1734
- } //--- DROPBITS(last.bits) ---//
1735
-
1736
-
1316
+ bits += 8;
1317
+ //---//
1318
+ }
1319
+ //--- DROPBITS(last.bits) ---//
1737
1320
  hold >>>= last_bits;
1738
- bits -= last_bits; //---//
1739
-
1321
+ bits -= last_bits;
1322
+ //---//
1740
1323
  state.back += last_bits;
1741
- } //--- DROPBITS(here.bits) ---//
1742
-
1743
-
1324
+ }
1325
+ //--- DROPBITS(here.bits) ---//
1744
1326
  hold >>>= here_bits;
1745
- bits -= here_bits; //---//
1746
-
1327
+ bits -= here_bits;
1328
+ //---//
1747
1329
  state.back += here_bits;
1748
-
1749
1330
  if (here_op & 64) {
1750
1331
  strm.msg = 'invalid distance code';
1751
1332
  state.mode = BAD;
1752
1333
  break;
1753
1334
  }
1754
-
1755
1335
  state.offset = here_val;
1756
1336
  state.extra = here_op & 15;
1757
1337
  state.mode = DISTEXT;
1758
-
1759
1338
  /* falls through */
1760
-
1761
1339
  case DISTEXT:
1762
1340
  if (state.extra) {
1763
1341
  //=== NEEDBITS(state.extra);
1764
1342
  n = state.extra;
1765
-
1766
1343
  while (bits < n) {
1767
1344
  if (have === 0) {
1768
1345
  break inf_leave;
1769
1346
  }
1770
-
1771
1347
  have--;
1772
1348
  hold += input[next++] << bits;
1773
1349
  bits += 8;
1774
- } //===//
1775
-
1776
-
1777
- state.offset += hold & (1 << state.extra) - 1
1778
- /*BITS(state.extra)*/
1779
- ; //--- DROPBITS(state.extra) ---//
1780
-
1350
+ }
1351
+ //===//
1352
+ state.offset += hold & (1 << state.extra) - 1 /*BITS(state.extra)*/;
1353
+ //--- DROPBITS(state.extra) ---//
1781
1354
  hold >>>= state.extra;
1782
- bits -= state.extra; //---//
1783
-
1355
+ bits -= state.extra;
1356
+ //---//
1784
1357
  state.back += state.extra;
1785
- } //#ifdef INFLATE_STRICT
1786
-
1787
-
1358
+ }
1359
+ //#ifdef INFLATE_STRICT
1788
1360
  if (state.offset > state.dmax) {
1789
1361
  strm.msg = 'invalid distance too far back';
1790
1362
  state.mode = BAD;
1791
1363
  break;
1792
- } //#endif
1364
+ }
1365
+ //#endif
1793
1366
  //Tracevv((stderr, "inflate: distance %u\n", state.offset));
1794
-
1795
-
1796
1367
  state.mode = MATCH;
1797
-
1798
1368
  /* falls through */
1799
-
1800
1369
  case MATCH:
1801
1370
  if (left === 0) {
1802
1371
  break inf_leave;
1803
1372
  }
1804
-
1805
1373
  copy = _out - left;
1806
-
1807
1374
  if (state.offset > copy) {
1808
1375
  /* copy from window */
1809
1376
  copy = state.offset - copy;
1810
-
1811
1377
  if (copy > state.whave) {
1812
1378
  if (state.sane) {
1813
1379
  strm.msg = 'invalid distance too far back';
1814
1380
  state.mode = BAD;
1815
1381
  break;
1816
- } // (!) This block is disabled in zlib defailts,
1382
+ }
1383
+ // (!) This block is disabled in zlib defailts,
1817
1384
  // don't enable it for binary compatibility
1818
1385
  //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
1819
1386
  // Trace((stderr, "inflate.c too far\n"));
@@ -1828,7 +1395,6 @@ function inflate(strm, flush) {
1828
1395
  // if (state.length === 0) { state.mode = LEN; }
1829
1396
  // break;
1830
1397
  //#endif
1831
-
1832
1398
  }
1833
1399
 
1834
1400
  if (copy > state.wnext) {
@@ -1837,11 +1403,9 @@ function inflate(strm, flush) {
1837
1403
  } else {
1838
1404
  from = state.wnext - copy;
1839
1405
  }
1840
-
1841
1406
  if (copy > state.length) {
1842
1407
  copy = state.length;
1843
1408
  }
1844
-
1845
1409
  from_source = state.window;
1846
1410
  } else {
1847
1411
  /* copy from output */
@@ -1849,34 +1413,26 @@ function inflate(strm, flush) {
1849
1413
  from = put - state.offset;
1850
1414
  copy = state.length;
1851
1415
  }
1852
-
1853
1416
  if (copy > left) {
1854
1417
  copy = left;
1855
1418
  }
1856
-
1857
1419
  left -= copy;
1858
1420
  state.length -= copy;
1859
-
1860
1421
  do {
1861
1422
  output[put++] = from_source[from++];
1862
1423
  } while (--copy);
1863
-
1864
1424
  if (state.length === 0) {
1865
1425
  state.mode = LEN;
1866
1426
  }
1867
-
1868
1427
  break;
1869
-
1870
1428
  case LIT:
1871
1429
  if (left === 0) {
1872
1430
  break inf_leave;
1873
1431
  }
1874
-
1875
1432
  output[put++] = state.length;
1876
1433
  left--;
1877
1434
  state.mode = LEN;
1878
1435
  break;
1879
-
1880
1436
  case CHECK:
1881
1437
  if (state.wrap) {
1882
1438
  //=== NEEDBITS(32);
@@ -1884,42 +1440,35 @@ function inflate(strm, flush) {
1884
1440
  if (have === 0) {
1885
1441
  break inf_leave;
1886
1442
  }
1887
-
1888
- have--; // Use '|' insdead of '+' to make sure that result is signed
1889
-
1443
+ have--;
1444
+ // Use '|' insdead of '+' to make sure that result is signed
1890
1445
  hold |= input[next++] << bits;
1891
1446
  bits += 8;
1892
- } //===//
1893
-
1894
-
1447
+ }
1448
+ //===//
1895
1449
  _out -= left;
1896
1450
  strm.total_out += _out;
1897
1451
  state.total += _out;
1898
-
1899
1452
  if (_out) {
1900
- strm.adler = state.check =
1901
- /*UPDATE(state.check, put - _out, _out);*/
1453
+ strm.adler = state.check = /*UPDATE(state.check, put - _out, _out);*/
1902
1454
  state.flags ? (0, _crc["default"])(state.check, output, _out, put - _out) : (0, _adler["default"])(state.check, output, _out, put - _out);
1903
1455
  }
1904
-
1905
- _out = left; // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too
1906
-
1456
+ _out = left;
1457
+ // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too
1907
1458
  if ((state.flags ? hold : zswap32(hold)) !== state.check) {
1908
1459
  strm.msg = 'incorrect data check';
1909
1460
  state.mode = BAD;
1910
1461
  break;
1911
- } //=== INITBITS();
1912
-
1913
-
1462
+ }
1463
+ //=== INITBITS();
1914
1464
  hold = 0;
1915
- bits = 0; //===//
1465
+ bits = 0;
1466
+ //===//
1916
1467
  //Tracev((stderr, "inflate: check matches trailer\n"));
1917
1468
  }
1918
1469
 
1919
1470
  state.mode = LENGTH;
1920
-
1921
1471
  /* falls through */
1922
-
1923
1472
  case LENGTH:
1924
1473
  if (state.wrap && state.flags) {
1925
1474
  //=== NEEDBITS(32);
@@ -1927,47 +1476,41 @@ function inflate(strm, flush) {
1927
1476
  if (have === 0) {
1928
1477
  break inf_leave;
1929
1478
  }
1930
-
1931
1479
  have--;
1932
1480
  hold += input[next++] << bits;
1933
1481
  bits += 8;
1934
- } //===//
1935
-
1936
-
1482
+ }
1483
+ //===//
1937
1484
  if (hold !== (state.total & 0xffffffff)) {
1938
1485
  strm.msg = 'incorrect length check';
1939
1486
  state.mode = BAD;
1940
1487
  break;
1941
- } //=== INITBITS();
1942
-
1943
-
1488
+ }
1489
+ //=== INITBITS();
1944
1490
  hold = 0;
1945
- bits = 0; //===//
1491
+ bits = 0;
1492
+ //===//
1946
1493
  //Tracev((stderr, "inflate: length matches trailer\n"));
1947
1494
  }
1948
1495
 
1949
1496
  state.mode = DONE;
1950
-
1951
1497
  /* falls through */
1952
-
1953
1498
  case DONE:
1954
1499
  ret = Z_STREAM_END;
1955
1500
  break inf_leave;
1956
-
1957
1501
  case BAD:
1958
1502
  ret = Z_DATA_ERROR;
1959
1503
  break inf_leave;
1960
-
1961
1504
  case MEM:
1962
1505
  return Z_MEM_ERROR;
1963
-
1964
1506
  case SYNC:
1965
1507
  /* falls through */
1966
-
1967
1508
  default:
1968
1509
  return Z_STREAM_ERROR;
1969
1510
  }
1970
- } // inf_leave <- here is real place for "goto inf_leave", emulated via "break inf_leave"
1511
+ }
1512
+
1513
+ // inf_leave <- here is real place for "goto inf_leave", emulated via "break inf_leave"
1971
1514
 
1972
1515
  /*
1973
1516
  Return from inflate(), updating the total counts and the check value.
@@ -1975,15 +1518,15 @@ function inflate(strm, flush) {
1975
1518
  error. Call updatewindow() to create and/or update the window state.
1976
1519
  Note: a memory error from inflate() is non-recoverable.
1977
1520
  */
1978
- //--- RESTORE() ---
1979
-
1980
1521
 
1522
+ //--- RESTORE() ---
1981
1523
  strm.next_out = put;
1982
1524
  strm.avail_out = left;
1983
1525
  strm.next_in = next;
1984
1526
  strm.avail_in = have;
1985
1527
  state.hold = hold;
1986
- state.bits = bits; //---
1528
+ state.bits = bits;
1529
+ //---
1987
1530
 
1988
1531
  if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH)) {
1989
1532
  if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {
@@ -1991,118 +1534,86 @@ function inflate(strm, flush) {
1991
1534
  return Z_MEM_ERROR;
1992
1535
  }
1993
1536
  }
1994
-
1995
1537
  _in -= strm.avail_in;
1996
1538
  _out -= strm.avail_out;
1997
1539
  strm.total_in += _in;
1998
1540
  strm.total_out += _out;
1999
1541
  state.total += _out;
2000
-
2001
1542
  if (state.wrap && _out) {
2002
- strm.adler = state.check =
2003
- /*UPDATE(state.check, strm.next_out - _out, _out);*/
1543
+ strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/
2004
1544
  state.flags ? (0, _crc["default"])(state.check, output, _out, strm.next_out - _out) : (0, _adler["default"])(state.check, output, _out, strm.next_out - _out);
2005
1545
  }
2006
-
2007
1546
  strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
2008
-
2009
1547
  if ((_in === 0 && _out === 0 || flush === Z_FINISH) && ret === Z_OK) {
2010
1548
  ret = Z_BUF_ERROR;
2011
1549
  }
2012
-
2013
1550
  return ret;
2014
1551
  }
2015
-
2016
1552
  function inflateEnd(strm) {
2017
- if (!strm || !strm.state
2018
- /*|| strm->zfree == (free_func)0*/
2019
- ) {
1553
+ if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {
2020
1554
  return Z_STREAM_ERROR;
2021
1555
  }
2022
-
2023
1556
  var state = strm.state;
2024
-
2025
1557
  if (state.window) {
2026
1558
  state.window = null;
2027
1559
  }
2028
-
2029
1560
  strm.state = null;
2030
1561
  return Z_OK;
2031
1562
  }
2032
-
2033
1563
  function inflateGetHeader(strm, head) {
2034
1564
  var state;
2035
- /* check state */
2036
1565
 
1566
+ /* check state */
2037
1567
  if (!strm || !strm.state) {
2038
1568
  return Z_STREAM_ERROR;
2039
1569
  }
2040
-
2041
1570
  state = strm.state;
2042
-
2043
1571
  if ((state.wrap & 2) === 0) {
2044
1572
  return Z_STREAM_ERROR;
2045
1573
  }
2046
- /* save header structure */
2047
-
2048
1574
 
1575
+ /* save header structure */
2049
1576
  state.head = head;
2050
1577
  head.done = false;
2051
1578
  return Z_OK;
2052
1579
  }
2053
-
2054
1580
  function inflateSetDictionary(strm, dictionary) {
2055
1581
  var dictLength = dictionary.length;
2056
1582
  var state;
2057
1583
  var dictid;
2058
1584
  var ret;
2059
- /* check state */
2060
1585
 
2061
- if (!strm
2062
- /* == Z_NULL */
2063
- || !strm.state
2064
- /* == Z_NULL */
2065
- ) {
1586
+ /* check state */
1587
+ if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) {
2066
1588
  return Z_STREAM_ERROR;
2067
1589
  }
2068
-
2069
1590
  state = strm.state;
2070
-
2071
1591
  if (state.wrap !== 0 && state.mode !== DICT) {
2072
1592
  return Z_STREAM_ERROR;
2073
1593
  }
2074
- /* check for correct dictionary identifier */
2075
-
2076
1594
 
1595
+ /* check for correct dictionary identifier */
2077
1596
  if (state.mode === DICT) {
2078
- dictid = 1;
2079
- /* adler32(0, null, 0)*/
2080
-
1597
+ dictid = 1; /* adler32(0, null, 0)*/
2081
1598
  /* dictid = adler32(dictid, dictionary, dictLength); */
2082
-
2083
1599
  dictid = (0, _adler["default"])(dictid, dictionary, dictLength, 0);
2084
-
2085
1600
  if (dictid !== state.check) {
2086
1601
  return Z_DATA_ERROR;
2087
1602
  }
2088
1603
  }
2089
1604
  /* copy dictionary to window using updatewindow(), which will amend the
2090
1605
  existing dictionary if appropriate */
2091
-
2092
-
2093
1606
  ret = updatewindow(strm, dictionary, dictLength, dictLength);
2094
-
2095
1607
  if (ret) {
2096
1608
  state.mode = MEM;
2097
1609
  return Z_MEM_ERROR;
2098
1610
  }
2099
-
2100
- state.havedict = 1; // Tracev((stderr, "inflate: dictionary set\n"));
2101
-
1611
+ state.havedict = 1;
1612
+ // Tracev((stderr, "inflate: dictionary set\n"));
2102
1613
  return Z_OK;
2103
1614
  }
2104
-
2105
1615
  var inflateInfo = 'pako inflate (from Nodeca project)';
1616
+
2106
1617
  /* Not implemented
2107
1618
  exports.inflateCopy = inflateCopy;
2108
1619
  exports.inflateGetDictionary = inflateGetDictionary;
@@ -2112,5 +1623,4 @@ exports.inflateSync = inflateSync;
2112
1623
  exports.inflateSyncPoint = inflateSyncPoint;
2113
1624
  exports.inflateUndermine = inflateUndermine;
2114
1625
  */
2115
-
2116
1626
  exports.inflateInfo = inflateInfo;