@novnc/novnc 1.2.0 → 1.3.0-g0ef7582

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