| 1 |
|
| 2 |
|
| 3 |
(function (global, factory) { |
| 4 |
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
| 5 |
typeof define === 'function' && define.amd ? define(['exports'], factory) : |
| 6 |
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.pako = {})); |
| 7 |
})(this, (function (exports) { 'use strict'; |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
const Z_FIXED$1 = 4; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
const Z_BINARY = 0; |
| 42 |
const Z_TEXT = 1; |
| 43 |
|
| 44 |
const Z_UNKNOWN$1 = 2; |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
function zero$1(buf) { let len = buf.length; while (--len >= 0) { buf[len] = 0; } } |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
const STORED_BLOCK = 0; |
| 54 |
const STATIC_TREES = 1; |
| 55 |
const DYN_TREES = 2; |
| 56 |
|
| 57 |
|
| 58 |
const MIN_MATCH$1 = 3; |
| 59 |
const MAX_MATCH$1 = 258; |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
const LENGTH_CODES$1 = 29; |
| 68 |
|
| 69 |
|
| 70 |
const LITERALS$1 = 256; |
| 71 |
|
| 72 |
|
| 73 |
const L_CODES$1 = LITERALS$1 + 1 + LENGTH_CODES$1; |
| 74 |
|
| 75 |
|
| 76 |
const D_CODES$1 = 30; |
| 77 |
|
| 78 |
|
| 79 |
const BL_CODES$1 = 19; |
| 80 |
|
| 81 |
|
| 82 |
const HEAP_SIZE$1 = 2 * L_CODES$1 + 1; |
| 83 |
|
| 84 |
|
| 85 |
const MAX_BITS$1 = 15; |
| 86 |
|
| 87 |
|
| 88 |
const Buf_size = 16; |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
const MAX_BL_BITS = 7; |
| 97 |
|
| 98 |
|
| 99 |
const END_BLOCK = 256; |
| 100 |
|
| 101 |
|
| 102 |
const REP_3_6 = 16; |
| 103 |
|
| 104 |
|
| 105 |
const REPZ_3_10 = 17; |
| 106 |
|
| 107 |
|
| 108 |
const REPZ_11_138 = 18; |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
const extra_lbits = |
| 113 |
new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]); |
| 114 |
|
| 115 |
const extra_dbits = |
| 116 |
new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]); |
| 117 |
|
| 118 |
const extra_blbits = |
| 119 |
new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]); |
| 120 |
|
| 121 |
const bl_order = |
| 122 |
new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]); |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
const DIST_CODE_LEN = 512; |
| 136 |
|
| 137 |
|
| 138 |
const static_ltree = new Array((L_CODES$1 + 2) * 2); |
| 139 |
zero$1(static_ltree); |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
const static_dtree = new Array(D_CODES$1 * 2); |
| 147 |
zero$1(static_dtree); |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
const _dist_code = new Array(DIST_CODE_LEN); |
| 153 |
zero$1(_dist_code); |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
const _length_code = new Array(MAX_MATCH$1 - MIN_MATCH$1 + 1); |
| 160 |
zero$1(_length_code); |
| 161 |
|
| 162 |
|
| 163 |
const base_length = new Array(LENGTH_CODES$1); |
| 164 |
zero$1(base_length); |
| 165 |
|
| 166 |
|
| 167 |
const base_dist = new Array(D_CODES$1); |
| 168 |
zero$1(base_dist); |
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) { |
| 173 |
|
| 174 |
this.static_tree = static_tree; |
| 175 |
this.extra_bits = extra_bits; |
| 176 |
this.extra_base = extra_base; |
| 177 |
this.elems = elems; |
| 178 |
this.max_length = max_length; |
| 179 |
|
| 180 |
|
| 181 |
this.has_stree = static_tree && static_tree.length; |
| 182 |
} |
| 183 |
|
| 184 |
|
| 185 |
let static_l_desc; |
| 186 |
let static_d_desc; |
| 187 |
let static_bl_desc; |
| 188 |
|
| 189 |
|
| 190 |
function TreeDesc(dyn_tree, stat_desc) { |
| 191 |
this.dyn_tree = dyn_tree; |
| 192 |
this.max_code = 0; |
| 193 |
this.stat_desc = stat_desc; |
| 194 |
} |
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
const d_code = (dist) => { |
| 199 |
|
| 200 |
return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)]; |
| 201 |
}; |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
const put_short = (s, w) => { |
| 209 |
|
| 210 |
|
| 211 |
s.pending_buf[s.pending++] = (w) & 0xff; |
| 212 |
s.pending_buf[s.pending++] = (w >>> 8) & 0xff; |
| 213 |
}; |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
const send_bits = (s, value, length) => { |
| 221 |
|
| 222 |
if (s.bi_valid > (Buf_size - length)) { |
| 223 |
s.bi_buf |= (value << s.bi_valid) & 0xffff; |
| 224 |
put_short(s, s.bi_buf); |
| 225 |
s.bi_buf = value >> (Buf_size - s.bi_valid); |
| 226 |
s.bi_valid += length - Buf_size; |
| 227 |
} else { |
| 228 |
s.bi_buf |= (value << s.bi_valid) & 0xffff; |
| 229 |
s.bi_valid += length; |
| 230 |
} |
| 231 |
}; |
| 232 |
|
| 233 |
|
| 234 |
const send_code = (s, c, tree) => { |
| 235 |
|
| 236 |
send_bits(s, tree[c * 2], tree[c * 2 + 1]); |
| 237 |
}; |
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
const bi_reverse = (code, len) => { |
| 246 |
|
| 247 |
let res = 0; |
| 248 |
do { |
| 249 |
res |= code & 1; |
| 250 |
code >>>= 1; |
| 251 |
res <<= 1; |
| 252 |
} while (--len > 0); |
| 253 |
return res >>> 1; |
| 254 |
}; |
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
const bi_flush = (s) => { |
| 261 |
|
| 262 |
if (s.bi_valid === 16) { |
| 263 |
put_short(s, s.bi_buf); |
| 264 |
s.bi_buf = 0; |
| 265 |
s.bi_valid = 0; |
| 266 |
|
| 267 |
} else if (s.bi_valid >= 8) { |
| 268 |
s.pending_buf[s.pending++] = s.bi_buf & 0xff; |
| 269 |
s.bi_buf >>= 8; |
| 270 |
s.bi_valid -= 8; |
| 271 |
} |
| 272 |
}; |
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
const gen_bitlen = (s, desc) => { |
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
const tree = desc.dyn_tree; |
| 290 |
const max_code = desc.max_code; |
| 291 |
const stree = desc.stat_desc.static_tree; |
| 292 |
const has_stree = desc.stat_desc.has_stree; |
| 293 |
const extra = desc.stat_desc.extra_bits; |
| 294 |
const base = desc.stat_desc.extra_base; |
| 295 |
const max_length = desc.stat_desc.max_length; |
| 296 |
let h; |
| 297 |
let n, m; |
| 298 |
let bits; |
| 299 |
let xbits; |
| 300 |
let f; |
| 301 |
let overflow = 0; |
| 302 |
|
| 303 |
for (bits = 0; bits <= MAX_BITS$1; bits++) { |
| 304 |
s.bl_count[bits] = 0; |
| 305 |
} |
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
tree[s.heap[s.heap_max] * 2 + 1] = 0; |
| 311 |
|
| 312 |
for (h = s.heap_max + 1; h < HEAP_SIZE$1; h++) { |
| 313 |
n = s.heap[h]; |
| 314 |
bits = tree[tree[n * 2 + 1] * 2 + 1] + 1; |
| 315 |
if (bits > max_length) { |
| 316 |
bits = max_length; |
| 317 |
overflow++; |
| 318 |
} |
| 319 |
tree[n * 2 + 1] = bits; |
| 320 |
|
| 321 |
|
| 322 |
if (n > max_code) { continue; } |
| 323 |
|
| 324 |
s.bl_count[bits]++; |
| 325 |
xbits = 0; |
| 326 |
if (n >= base) { |
| 327 |
xbits = extra[n - base]; |
| 328 |
} |
| 329 |
f = tree[n * 2]; |
| 330 |
s.opt_len += f * (bits + xbits); |
| 331 |
if (has_stree) { |
| 332 |
s.static_len += f * (stree[n * 2 + 1] + xbits); |
| 333 |
} |
| 334 |
} |
| 335 |
if (overflow === 0) { return; } |
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
do { |
| 342 |
bits = max_length - 1; |
| 343 |
while (s.bl_count[bits] === 0) { bits--; } |
| 344 |
s.bl_count[bits]--; |
| 345 |
s.bl_count[bits + 1] += 2; |
| 346 |
s.bl_count[max_length]--; |
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
overflow -= 2; |
| 351 |
} while (overflow > 0); |
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
for (bits = max_length; bits !== 0; bits--) { |
| 359 |
n = s.bl_count[bits]; |
| 360 |
while (n !== 0) { |
| 361 |
m = s.heap[--h]; |
| 362 |
if (m > max_code) { continue; } |
| 363 |
if (tree[m * 2 + 1] !== bits) { |
| 364 |
|
| 365 |
s.opt_len += (bits - tree[m * 2 + 1]) * tree[m * 2]; |
| 366 |
tree[m * 2 + 1] = bits; |
| 367 |
} |
| 368 |
n--; |
| 369 |
} |
| 370 |
} |
| 371 |
}; |
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
const gen_codes = (tree, max_code, bl_count) => { |
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
const next_code = new Array(MAX_BITS$1 + 1); |
| 388 |
let code = 0; |
| 389 |
let bits; |
| 390 |
let n; |
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
for (bits = 1; bits <= MAX_BITS$1; bits++) { |
| 396 |
code = (code + bl_count[bits - 1]) << 1; |
| 397 |
next_code[bits] = code; |
| 398 |
} |
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
for (n = 0; n <= max_code; n++) { |
| 407 |
let len = tree[n * 2 + 1]; |
| 408 |
if (len === 0) { continue; } |
| 409 |
|
| 410 |
tree[n * 2] = bi_reverse(next_code[len]++, len); |
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
} |
| 415 |
}; |
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
const tr_static_init = () => { |
| 422 |
|
| 423 |
let n; |
| 424 |
let bits; |
| 425 |
let length; |
| 426 |
let code; |
| 427 |
let dist; |
| 428 |
const bl_count = new Array(MAX_BITS$1 + 1); |
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
length = 0; |
| 445 |
for (code = 0; code < LENGTH_CODES$1 - 1; code++) { |
| 446 |
base_length[code] = length; |
| 447 |
for (n = 0; n < (1 << extra_lbits[code]); n++) { |
| 448 |
_length_code[length++] = code; |
| 449 |
} |
| 450 |
} |
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
_length_code[length - 1] = code; |
| 457 |
|
| 458 |
|
| 459 |
dist = 0; |
| 460 |
for (code = 0; code < 16; code++) { |
| 461 |
base_dist[code] = dist; |
| 462 |
for (n = 0; n < (1 << extra_dbits[code]); n++) { |
| 463 |
_dist_code[dist++] = code; |
| 464 |
} |
| 465 |
} |
| 466 |
|
| 467 |
dist >>= 7; |
| 468 |
for (; code < D_CODES$1; code++) { |
| 469 |
base_dist[code] = dist << 7; |
| 470 |
for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) { |
| 471 |
_dist_code[256 + dist++] = code; |
| 472 |
} |
| 473 |
} |
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
for (bits = 0; bits <= MAX_BITS$1; bits++) { |
| 478 |
bl_count[bits] = 0; |
| 479 |
} |
| 480 |
|
| 481 |
n = 0; |
| 482 |
while (n <= 143) { |
| 483 |
static_ltree[n * 2 + 1] = 8; |
| 484 |
n++; |
| 485 |
bl_count[8]++; |
| 486 |
} |
| 487 |
while (n <= 255) { |
| 488 |
static_ltree[n * 2 + 1] = 9; |
| 489 |
n++; |
| 490 |
bl_count[9]++; |
| 491 |
} |
| 492 |
while (n <= 279) { |
| 493 |
static_ltree[n * 2 + 1] = 7; |
| 494 |
n++; |
| 495 |
bl_count[7]++; |
| 496 |
} |
| 497 |
while (n <= 287) { |
| 498 |
static_ltree[n * 2 + 1] = 8; |
| 499 |
n++; |
| 500 |
bl_count[8]++; |
| 501 |
} |
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
gen_codes(static_ltree, L_CODES$1 + 1, bl_count); |
| 507 |
|
| 508 |
|
| 509 |
for (n = 0; n < D_CODES$1; n++) { |
| 510 |
static_dtree[n * 2 + 1] = 5; |
| 511 |
static_dtree[n * 2] = bi_reverse(n, 5); |
| 512 |
} |
| 513 |
|
| 514 |
|
| 515 |
static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS$1 + 1, L_CODES$1, MAX_BITS$1); |
| 516 |
static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES$1, MAX_BITS$1); |
| 517 |
static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES$1, MAX_BL_BITS); |
| 518 |
|
| 519 |
|
| 520 |
}; |
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
const init_block = (s) => { |
| 527 |
|
| 528 |
let n; |
| 529 |
|
| 530 |
|
| 531 |
for (n = 0; n < L_CODES$1; n++) { s.dyn_ltree[n * 2] = 0; } |
| 532 |
for (n = 0; n < D_CODES$1; n++) { s.dyn_dtree[n * 2] = 0; } |
| 533 |
for (n = 0; n < BL_CODES$1; n++) { s.bl_tree[n * 2] = 0; } |
| 534 |
|
| 535 |
s.dyn_ltree[END_BLOCK * 2] = 1; |
| 536 |
s.opt_len = s.static_len = 0; |
| 537 |
s.sym_next = s.matches = 0; |
| 538 |
}; |
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
const bi_windup = (s) => |
| 545 |
{ |
| 546 |
if (s.bi_valid > 8) { |
| 547 |
put_short(s, s.bi_buf); |
| 548 |
} else if (s.bi_valid > 0) { |
| 549 |
|
| 550 |
s.pending_buf[s.pending++] = s.bi_buf; |
| 551 |
} |
| 552 |
s.bi_buf = 0; |
| 553 |
s.bi_valid = 0; |
| 554 |
}; |
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
const smaller = (tree, n, m, depth) => { |
| 561 |
|
| 562 |
const _n2 = n * 2; |
| 563 |
const _m2 = m * 2; |
| 564 |
return (tree[_n2] < tree[_m2] || |
| 565 |
(tree[_n2] === tree[_m2] && depth[n] <= depth[m])); |
| 566 |
}; |
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
const pqdownheap = (s, tree, k) => { |
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
const v = s.heap[k]; |
| 580 |
let j = k << 1; |
| 581 |
while (j <= s.heap_len) { |
| 582 |
|
| 583 |
if (j < s.heap_len && |
| 584 |
smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) { |
| 585 |
j++; |
| 586 |
} |
| 587 |
|
| 588 |
if (smaller(tree, v, s.heap[j], s.depth)) { break; } |
| 589 |
|
| 590 |
|
| 591 |
s.heap[k] = s.heap[j]; |
| 592 |
k = j; |
| 593 |
|
| 594 |
|
| 595 |
j <<= 1; |
| 596 |
} |
| 597 |
s.heap[k] = v; |
| 598 |
}; |
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
const compress_block = (s, ltree, dtree) => { |
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
let dist; |
| 613 |
let lc; |
| 614 |
let sx = 0; |
| 615 |
let code; |
| 616 |
let extra; |
| 617 |
|
| 618 |
if (s.sym_next !== 0) { |
| 619 |
do { |
| 620 |
dist = s.pending_buf[s.sym_buf + sx++] & 0xff; |
| 621 |
dist += (s.pending_buf[s.sym_buf + sx++] & 0xff) << 8; |
| 622 |
lc = s.pending_buf[s.sym_buf + sx++]; |
| 623 |
if (dist === 0) { |
| 624 |
send_code(s, lc, ltree); |
| 625 |
|
| 626 |
} else { |
| 627 |
|
| 628 |
code = _length_code[lc]; |
| 629 |
send_code(s, code + LITERALS$1 + 1, ltree); |
| 630 |
extra = extra_lbits[code]; |
| 631 |
if (extra !== 0) { |
| 632 |
lc -= base_length[code]; |
| 633 |
send_bits(s, lc, extra); |
| 634 |
} |
| 635 |
dist--; |
| 636 |
code = d_code(dist); |
| 637 |
|
| 638 |
|
| 639 |
send_code(s, code, dtree); |
| 640 |
extra = extra_dbits[code]; |
| 641 |
if (extra !== 0) { |
| 642 |
dist -= base_dist[code]; |
| 643 |
send_bits(s, dist, extra); |
| 644 |
} |
| 645 |
} |
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
} while (sx < s.sym_next); |
| 651 |
} |
| 652 |
|
| 653 |
send_code(s, END_BLOCK, ltree); |
| 654 |
}; |
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
const build_tree = (s, desc) => { |
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
const tree = desc.dyn_tree; |
| 670 |
const stree = desc.stat_desc.static_tree; |
| 671 |
const has_stree = desc.stat_desc.has_stree; |
| 672 |
const elems = desc.stat_desc.elems; |
| 673 |
let n, m; |
| 674 |
let max_code = -1; |
| 675 |
let node; |
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
s.heap_len = 0; |
| 682 |
s.heap_max = HEAP_SIZE$1; |
| 683 |
|
| 684 |
for (n = 0; n < elems; n++) { |
| 685 |
if (tree[n * 2] !== 0) { |
| 686 |
s.heap[++s.heap_len] = max_code = n; |
| 687 |
s.depth[n] = 0; |
| 688 |
|
| 689 |
} else { |
| 690 |
tree[n * 2 + 1] = 0; |
| 691 |
} |
| 692 |
} |
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
while (s.heap_len < 2) { |
| 700 |
node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0); |
| 701 |
tree[node * 2] = 1; |
| 702 |
s.depth[node] = 0; |
| 703 |
s.opt_len--; |
| 704 |
|
| 705 |
if (has_stree) { |
| 706 |
s.static_len -= stree[node * 2 + 1]; |
| 707 |
} |
| 708 |
|
| 709 |
} |
| 710 |
desc.max_code = max_code; |
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
for (n = (s.heap_len >> 1); n >= 1; n--) { pqdownheap(s, tree, n); } |
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
node = elems; |
| 721 |
do { |
| 722 |
|
| 723 |
|
| 724 |
n = s.heap[1]; |
| 725 |
s.heap[1] = s.heap[s.heap_len--]; |
| 726 |
pqdownheap(s, tree, 1); |
| 727 |
|
| 728 |
|
| 729 |
m = s.heap[1]; |
| 730 |
|
| 731 |
s.heap[--s.heap_max] = n; |
| 732 |
s.heap[--s.heap_max] = m; |
| 733 |
|
| 734 |
|
| 735 |
tree[node * 2] = tree[n * 2] + tree[m * 2]; |
| 736 |
s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1; |
| 737 |
tree[n * 2 + 1] = tree[m * 2 + 1] = node; |
| 738 |
|
| 739 |
|
| 740 |
s.heap[1] = node++; |
| 741 |
pqdownheap(s, tree, 1); |
| 742 |
|
| 743 |
} while (s.heap_len >= 2); |
| 744 |
|
| 745 |
s.heap[--s.heap_max] = s.heap[1]; |
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
gen_bitlen(s, desc); |
| 751 |
|
| 752 |
|
| 753 |
gen_codes(tree, max_code, s.bl_count); |
| 754 |
}; |
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
const scan_tree = (s, tree, max_code) => { |
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
let n; |
| 767 |
let prevlen = -1; |
| 768 |
let curlen; |
| 769 |
|
| 770 |
let nextlen = tree[0 * 2 + 1]; |
| 771 |
|
| 772 |
let count = 0; |
| 773 |
let max_count = 7; |
| 774 |
let min_count = 4; |
| 775 |
|
| 776 |
if (nextlen === 0) { |
| 777 |
max_count = 138; |
| 778 |
min_count = 3; |
| 779 |
} |
| 780 |
tree[(max_code + 1) * 2 + 1] = 0xffff; |
| 781 |
|
| 782 |
for (n = 0; n <= max_code; n++) { |
| 783 |
curlen = nextlen; |
| 784 |
nextlen = tree[(n + 1) * 2 + 1]; |
| 785 |
|
| 786 |
if (++count < max_count && curlen === nextlen) { |
| 787 |
continue; |
| 788 |
|
| 789 |
} else if (count < min_count) { |
| 790 |
s.bl_tree[curlen * 2] += count; |
| 791 |
|
| 792 |
} else if (curlen !== 0) { |
| 793 |
|
| 794 |
if (curlen !== prevlen) { s.bl_tree[curlen * 2]++; } |
| 795 |
s.bl_tree[REP_3_6 * 2]++; |
| 796 |
|
| 797 |
} else if (count <= 10) { |
| 798 |
s.bl_tree[REPZ_3_10 * 2]++; |
| 799 |
|
| 800 |
} else { |
| 801 |
s.bl_tree[REPZ_11_138 * 2]++; |
| 802 |
} |
| 803 |
|
| 804 |
count = 0; |
| 805 |
prevlen = curlen; |
| 806 |
|
| 807 |
if (nextlen === 0) { |
| 808 |
max_count = 138; |
| 809 |
min_count = 3; |
| 810 |
|
| 811 |
} else if (curlen === nextlen) { |
| 812 |
max_count = 6; |
| 813 |
min_count = 3; |
| 814 |
|
| 815 |
} else { |
| 816 |
max_count = 7; |
| 817 |
min_count = 4; |
| 818 |
} |
| 819 |
} |
| 820 |
}; |
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
const send_tree = (s, tree, max_code) => { |
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
let n; |
| 833 |
let prevlen = -1; |
| 834 |
let curlen; |
| 835 |
|
| 836 |
let nextlen = tree[0 * 2 + 1]; |
| 837 |
|
| 838 |
let count = 0; |
| 839 |
let max_count = 7; |
| 840 |
let min_count = 4; |
| 841 |
|
| 842 |
|
| 843 |
if (nextlen === 0) { |
| 844 |
max_count = 138; |
| 845 |
min_count = 3; |
| 846 |
} |
| 847 |
|
| 848 |
for (n = 0; n <= max_code; n++) { |
| 849 |
curlen = nextlen; |
| 850 |
nextlen = tree[(n + 1) * 2 + 1]; |
| 851 |
|
| 852 |
if (++count < max_count && curlen === nextlen) { |
| 853 |
continue; |
| 854 |
|
| 855 |
} else if (count < min_count) { |
| 856 |
do { send_code(s, curlen, s.bl_tree); } while (--count !== 0); |
| 857 |
|
| 858 |
} else if (curlen !== 0) { |
| 859 |
if (curlen !== prevlen) { |
| 860 |
send_code(s, curlen, s.bl_tree); |
| 861 |
count--; |
| 862 |
} |
| 863 |
|
| 864 |
send_code(s, REP_3_6, s.bl_tree); |
| 865 |
send_bits(s, count - 3, 2); |
| 866 |
|
| 867 |
} else if (count <= 10) { |
| 868 |
send_code(s, REPZ_3_10, s.bl_tree); |
| 869 |
send_bits(s, count - 3, 3); |
| 870 |
|
| 871 |
} else { |
| 872 |
send_code(s, REPZ_11_138, s.bl_tree); |
| 873 |
send_bits(s, count - 11, 7); |
| 874 |
} |
| 875 |
|
| 876 |
count = 0; |
| 877 |
prevlen = curlen; |
| 878 |
if (nextlen === 0) { |
| 879 |
max_count = 138; |
| 880 |
min_count = 3; |
| 881 |
|
| 882 |
} else if (curlen === nextlen) { |
| 883 |
max_count = 6; |
| 884 |
min_count = 3; |
| 885 |
|
| 886 |
} else { |
| 887 |
max_count = 7; |
| 888 |
min_count = 4; |
| 889 |
} |
| 890 |
} |
| 891 |
}; |
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
|
| 897 |
|
| 898 |
const build_bl_tree = (s) => { |
| 899 |
|
| 900 |
let max_blindex; |
| 901 |
|
| 902 |
|
| 903 |
scan_tree(s, s.dyn_ltree, s.l_desc.max_code); |
| 904 |
scan_tree(s, s.dyn_dtree, s.d_desc.max_code); |
| 905 |
|
| 906 |
|
| 907 |
build_tree(s, s.bl_desc); |
| 908 |
|
| 909 |
|
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
|
| 914 |
|
| 915 |
|
| 916 |
for (max_blindex = BL_CODES$1 - 1; max_blindex >= 3; max_blindex--) { |
| 917 |
if (s.bl_tree[bl_order[max_blindex] * 2 + 1] !== 0) { |
| 918 |
break; |
| 919 |
} |
| 920 |
} |
| 921 |
|
| 922 |
s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; |
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
return max_blindex; |
| 927 |
}; |
| 928 |
|
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
|
| 935 |
const send_all_trees = (s, lcodes, dcodes, blcodes) => { |
| 936 |
|
| 937 |
|
| 938 |
|
| 939 |
let rank; |
| 940 |
|
| 941 |
|
| 942 |
|
| 943 |
|
| 944 |
|
| 945 |
send_bits(s, lcodes - 257, 5); |
| 946 |
send_bits(s, dcodes - 1, 5); |
| 947 |
send_bits(s, blcodes - 4, 4); |
| 948 |
for (rank = 0; rank < blcodes; rank++) { |
| 949 |
|
| 950 |
send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1], 3); |
| 951 |
} |
| 952 |
|
| 953 |
|
| 954 |
send_tree(s, s.dyn_ltree, lcodes - 1); |
| 955 |
|
| 956 |
|
| 957 |
send_tree(s, s.dyn_dtree, dcodes - 1); |
| 958 |
|
| 959 |
}; |
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
|
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
const detect_data_type = (s) => { |
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
let block_mask = 0xf3ffc07f; |
| 981 |
let n; |
| 982 |
|
| 983 |
|
| 984 |
for (n = 0; n <= 31; n++, block_mask >>>= 1) { |
| 985 |
if ((block_mask & 1) && (s.dyn_ltree[n * 2] !== 0)) { |
| 986 |
return Z_BINARY; |
| 987 |
} |
| 988 |
} |
| 989 |
|
| 990 |
|
| 991 |
if (s.dyn_ltree[9 * 2] !== 0 || s.dyn_ltree[10 * 2] !== 0 || |
| 992 |
s.dyn_ltree[13 * 2] !== 0) { |
| 993 |
return Z_TEXT; |
| 994 |
} |
| 995 |
for (n = 32; n < LITERALS$1; n++) { |
| 996 |
if (s.dyn_ltree[n * 2] !== 0) { |
| 997 |
return Z_TEXT; |
| 998 |
} |
| 999 |
} |
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
|
| 1004 |
return Z_BINARY; |
| 1005 |
}; |
| 1006 |
|
| 1007 |
|
| 1008 |
let static_init_done = false; |
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
|
| 1013 |
const _tr_init$1 = (s) => |
| 1014 |
{ |
| 1015 |
|
| 1016 |
if (!static_init_done) { |
| 1017 |
tr_static_init(); |
| 1018 |
static_init_done = true; |
| 1019 |
} |
| 1020 |
|
| 1021 |
s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc); |
| 1022 |
s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc); |
| 1023 |
s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc); |
| 1024 |
|
| 1025 |
s.bi_buf = 0; |
| 1026 |
s.bi_valid = 0; |
| 1027 |
|
| 1028 |
|
| 1029 |
init_block(s); |
| 1030 |
}; |
| 1031 |
|
| 1032 |
|
| 1033 |
|
| 1034 |
|
| 1035 |
|
| 1036 |
const _tr_stored_block$1 = (s, buf, stored_len, last) => { |
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); |
| 1043 |
bi_windup(s); |
| 1044 |
put_short(s, stored_len); |
| 1045 |
put_short(s, ~stored_len); |
| 1046 |
if (stored_len) { |
| 1047 |
s.pending_buf.set(s.window.subarray(buf, buf + stored_len), s.pending); |
| 1048 |
} |
| 1049 |
s.pending += stored_len; |
| 1050 |
}; |
| 1051 |
|
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
|
| 1057 |
const _tr_align$1 = (s) => { |
| 1058 |
send_bits(s, STATIC_TREES << 1, 3); |
| 1059 |
send_code(s, END_BLOCK, static_ltree); |
| 1060 |
bi_flush(s); |
| 1061 |
}; |
| 1062 |
|
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
const _tr_flush_block$1 = (s, buf, stored_len, last) => { |
| 1069 |
|
| 1070 |
|
| 1071 |
|
| 1072 |
|
| 1073 |
|
| 1074 |
let opt_lenb, static_lenb; |
| 1075 |
let max_blindex = 0; |
| 1076 |
|
| 1077 |
|
| 1078 |
if (s.level > 0) { |
| 1079 |
|
| 1080 |
|
| 1081 |
if (s.strm.data_type === Z_UNKNOWN$1) { |
| 1082 |
s.strm.data_type = detect_data_type(s); |
| 1083 |
} |
| 1084 |
|
| 1085 |
|
| 1086 |
build_tree(s, s.l_desc); |
| 1087 |
|
| 1088 |
|
| 1089 |
|
| 1090 |
build_tree(s, s.d_desc); |
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
|
| 1096 |
|
| 1097 |
|
| 1098 |
|
| 1099 |
|
| 1100 |
max_blindex = build_bl_tree(s); |
| 1101 |
|
| 1102 |
|
| 1103 |
opt_lenb = (s.opt_len + 3 + 7) >>> 3; |
| 1104 |
static_lenb = (s.static_len + 3 + 7) >>> 3; |
| 1105 |
|
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
|
| 1110 |
if (static_lenb <= opt_lenb) { opt_lenb = static_lenb; } |
| 1111 |
|
| 1112 |
} else { |
| 1113 |
|
| 1114 |
opt_lenb = static_lenb = stored_len + 5; |
| 1115 |
} |
| 1116 |
|
| 1117 |
if ((stored_len + 4 <= opt_lenb) && (buf !== -1)) { |
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
|
| 1123 |
|
| 1124 |
|
| 1125 |
|
| 1126 |
_tr_stored_block$1(s, buf, stored_len, last); |
| 1127 |
|
| 1128 |
} else if (s.strategy === Z_FIXED$1 || static_lenb === opt_lenb) { |
| 1129 |
|
| 1130 |
send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3); |
| 1131 |
compress_block(s, static_ltree, static_dtree); |
| 1132 |
|
| 1133 |
} else { |
| 1134 |
send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3); |
| 1135 |
send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1); |
| 1136 |
compress_block(s, s.dyn_ltree, s.dyn_dtree); |
| 1137 |
} |
| 1138 |
|
| 1139 |
|
| 1140 |
|
| 1141 |
|
| 1142 |
init_block(s); |
| 1143 |
|
| 1144 |
if (last) { |
| 1145 |
bi_windup(s); |
| 1146 |
} |
| 1147 |
|
| 1148 |
|
| 1149 |
}; |
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
|
| 1155 |
const _tr_tally$1 = (s, dist, lc) => { |
| 1156 |
|
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
s.pending_buf[s.sym_buf + s.sym_next++] = dist; |
| 1161 |
s.pending_buf[s.sym_buf + s.sym_next++] = dist >> 8; |
| 1162 |
s.pending_buf[s.sym_buf + s.sym_next++] = lc; |
| 1163 |
if (dist === 0) { |
| 1164 |
|
| 1165 |
s.dyn_ltree[lc * 2]++; |
| 1166 |
} else { |
| 1167 |
s.matches++; |
| 1168 |
|
| 1169 |
dist--; |
| 1170 |
|
| 1171 |
|
| 1172 |
|
| 1173 |
|
| 1174 |
s.dyn_ltree[(_length_code[lc] + LITERALS$1 + 1) * 2]++; |
| 1175 |
s.dyn_dtree[d_code(dist) * 2]++; |
| 1176 |
} |
| 1177 |
|
| 1178 |
return (s.sym_next === s.sym_end); |
| 1179 |
}; |
| 1180 |
|
| 1181 |
var _tr_init_1 = _tr_init$1; |
| 1182 |
var _tr_stored_block_1 = _tr_stored_block$1; |
| 1183 |
var _tr_flush_block_1 = _tr_flush_block$1; |
| 1184 |
var _tr_tally_1 = _tr_tally$1; |
| 1185 |
var _tr_align_1 = _tr_align$1; |
| 1186 |
|
| 1187 |
var trees = { |
| 1188 |
_tr_init: _tr_init_1, |
| 1189 |
_tr_stored_block: _tr_stored_block_1, |
| 1190 |
_tr_flush_block: _tr_flush_block_1, |
| 1191 |
_tr_tally: _tr_tally_1, |
| 1192 |
_tr_align: _tr_align_1 |
| 1193 |
}; |
| 1194 |
|
| 1195 |
|
| 1196 |
|
| 1197 |
|
| 1198 |
|
| 1199 |
|
| 1200 |
|
| 1201 |
|
| 1202 |
|
| 1203 |
|
| 1204 |
|
| 1205 |
|
| 1206 |
|
| 1207 |
|
| 1208 |
|
| 1209 |
|
| 1210 |
|
| 1211 |
|
| 1212 |
|
| 1213 |
|
| 1214 |
|
| 1215 |
|
| 1216 |
|
| 1217 |
|
| 1218 |
const adler32 = (adler, buf, len, pos) => { |
| 1219 |
let s1 = (adler & 0xffff) |0, |
| 1220 |
s2 = ((adler >>> 16) & 0xffff) |0, |
| 1221 |
n = 0; |
| 1222 |
|
| 1223 |
while (len !== 0) { |
| 1224 |
|
| 1225 |
|
| 1226 |
|
| 1227 |
n = len > 2000 ? 2000 : len; |
| 1228 |
len -= n; |
| 1229 |
|
| 1230 |
do { |
| 1231 |
s1 = (s1 + buf[pos++]) |0; |
| 1232 |
s2 = (s2 + s1) |0; |
| 1233 |
} while (--n); |
| 1234 |
|
| 1235 |
s1 %= 65521; |
| 1236 |
s2 %= 65521; |
| 1237 |
} |
| 1238 |
|
| 1239 |
return (s1 | (s2 << 16)) |0; |
| 1240 |
}; |
| 1241 |
|
| 1242 |
|
| 1243 |
var adler32_1 = adler32; |
| 1244 |
|
| 1245 |
|
| 1246 |
|
| 1247 |
|
| 1248 |
|
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
|
| 1253 |
|
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
|
| 1259 |
|
| 1260 |
|
| 1261 |
|
| 1262 |
|
| 1263 |
|
| 1264 |
|
| 1265 |
|
| 1266 |
|
| 1267 |
|
| 1268 |
|
| 1269 |
const makeTable = () => { |
| 1270 |
let c, table = []; |
| 1271 |
|
| 1272 |
for (var n = 0; n < 256; n++) { |
| 1273 |
c = n; |
| 1274 |
for (var k = 0; k < 8; k++) { |
| 1275 |
c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1)); |
| 1276 |
} |
| 1277 |
table[n] = c; |
| 1278 |
} |
| 1279 |
|
| 1280 |
return table; |
| 1281 |
}; |
| 1282 |
|
| 1283 |
|
| 1284 |
const crcTable = new Uint32Array(makeTable()); |
| 1285 |
|
| 1286 |
|
| 1287 |
const crc32 = (crc, buf, len, pos) => { |
| 1288 |
const t = crcTable; |
| 1289 |
const end = pos + len; |
| 1290 |
|
| 1291 |
crc ^= -1; |
| 1292 |
|
| 1293 |
for (let i = pos; i < end; i++) { |
| 1294 |
crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF]; |
| 1295 |
} |
| 1296 |
|
| 1297 |
return (crc ^ (-1)); |
| 1298 |
}; |
| 1299 |
|
| 1300 |
|
| 1301 |
var crc32_1 = crc32; |
| 1302 |
|
| 1303 |
|
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
|
| 1308 |
|
| 1309 |
|
| 1310 |
|
| 1311 |
|
| 1312 |
|
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
var messages = { |
| 1323 |
2: 'need dictionary', |
| 1324 |
1: 'stream end', |
| 1325 |
0: '', |
| 1326 |
'-1': 'file error', |
| 1327 |
'-2': 'stream error', |
| 1328 |
'-3': 'data error', |
| 1329 |
'-4': 'insufficient memory', |
| 1330 |
'-5': 'buffer error', |
| 1331 |
'-6': 'incompatible version' |
| 1332 |
}; |
| 1333 |
|
| 1334 |
|
| 1335 |
|
| 1336 |
|
| 1337 |
|
| 1338 |
|
| 1339 |
|
| 1340 |
|
| 1341 |
|
| 1342 |
|
| 1343 |
|
| 1344 |
|
| 1345 |
|
| 1346 |
|
| 1347 |
|
| 1348 |
|
| 1349 |
|
| 1350 |
|
| 1351 |
|
| 1352 |
|
| 1353 |
var constants$1 = { |
| 1354 |
|
| 1355 |
|
| 1356 |
Z_NO_FLUSH: 0, |
| 1357 |
Z_PARTIAL_FLUSH: 1, |
| 1358 |
Z_SYNC_FLUSH: 2, |
| 1359 |
Z_FULL_FLUSH: 3, |
| 1360 |
Z_FINISH: 4, |
| 1361 |
Z_BLOCK: 5, |
| 1362 |
Z_TREES: 6, |
| 1363 |
|
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
Z_OK: 0, |
| 1368 |
Z_STREAM_END: 1, |
| 1369 |
Z_NEED_DICT: 2, |
| 1370 |
Z_ERRNO: -1, |
| 1371 |
Z_STREAM_ERROR: -2, |
| 1372 |
Z_DATA_ERROR: -3, |
| 1373 |
Z_MEM_ERROR: -4, |
| 1374 |
Z_BUF_ERROR: -5, |
| 1375 |
|
| 1376 |
|
| 1377 |
|
| 1378 |
Z_NO_COMPRESSION: 0, |
| 1379 |
Z_BEST_SPEED: 1, |
| 1380 |
Z_BEST_COMPRESSION: 9, |
| 1381 |
Z_DEFAULT_COMPRESSION: -1, |
| 1382 |
|
| 1383 |
|
| 1384 |
Z_FILTERED: 1, |
| 1385 |
Z_HUFFMAN_ONLY: 2, |
| 1386 |
Z_RLE: 3, |
| 1387 |
Z_FIXED: 4, |
| 1388 |
Z_DEFAULT_STRATEGY: 0, |
| 1389 |
|
| 1390 |
|
| 1391 |
Z_BINARY: 0, |
| 1392 |
Z_TEXT: 1, |
| 1393 |
|
| 1394 |
Z_UNKNOWN: 2, |
| 1395 |
|
| 1396 |
|
| 1397 |
Z_DEFLATED: 8 |
| 1398 |
|
| 1399 |
}; |
| 1400 |
|
| 1401 |
|
| 1402 |
|
| 1403 |
|
| 1404 |
|
| 1405 |
|
| 1406 |
|
| 1407 |
|
| 1408 |
|
| 1409 |
|
| 1410 |
|
| 1411 |
|
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
|
| 1418 |
|
| 1419 |
|
| 1420 |
const { _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align } = trees; |
| 1421 |
|
| 1422 |
|
| 1423 |
|
| 1424 |
|
| 1425 |
|
| 1426 |
|
| 1427 |
|
| 1428 |
const { |
| 1429 |
Z_NO_FLUSH: Z_NO_FLUSH$1, Z_PARTIAL_FLUSH, Z_FULL_FLUSH: Z_FULL_FLUSH$1, Z_FINISH: Z_FINISH$1, Z_BLOCK, |
| 1430 |
Z_OK: Z_OK$1, Z_STREAM_END: Z_STREAM_END$1, Z_STREAM_ERROR, Z_DATA_ERROR, Z_BUF_ERROR, |
| 1431 |
Z_DEFAULT_COMPRESSION: Z_DEFAULT_COMPRESSION$1, |
| 1432 |
Z_FILTERED, Z_HUFFMAN_ONLY, Z_RLE, Z_FIXED, Z_DEFAULT_STRATEGY: Z_DEFAULT_STRATEGY$1, |
| 1433 |
Z_UNKNOWN, |
| 1434 |
Z_DEFLATED: Z_DEFLATED$1 |
| 1435 |
} = constants$1; |
| 1436 |
|
| 1437 |
|
| 1438 |
|
| 1439 |
|
| 1440 |
const MAX_MEM_LEVEL = 9; |
| 1441 |
|
| 1442 |
const MAX_WBITS = 15; |
| 1443 |
|
| 1444 |
const DEF_MEM_LEVEL = 8; |
| 1445 |
|
| 1446 |
|
| 1447 |
const LENGTH_CODES = 29; |
| 1448 |
|
| 1449 |
const LITERALS = 256; |
| 1450 |
|
| 1451 |
const L_CODES = LITERALS + 1 + LENGTH_CODES; |
| 1452 |
|
| 1453 |
const D_CODES = 30; |
| 1454 |
|
| 1455 |
const BL_CODES = 19; |
| 1456 |
|
| 1457 |
const HEAP_SIZE = 2 * L_CODES + 1; |
| 1458 |
|
| 1459 |
const MAX_BITS = 15; |
| 1460 |
|
| 1461 |
|
| 1462 |
const MIN_MATCH = 3; |
| 1463 |
const MAX_MATCH = 258; |
| 1464 |
const MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1); |
| 1465 |
|
| 1466 |
const PRESET_DICT = 0x20; |
| 1467 |
|
| 1468 |
const INIT_STATE = 42; |
| 1469 |
|
| 1470 |
const GZIP_STATE = 57; |
| 1471 |
|
| 1472 |
const EXTRA_STATE = 69; |
| 1473 |
const NAME_STATE = 73; |
| 1474 |
const COMMENT_STATE = 91; |
| 1475 |
const HCRC_STATE = 103; |
| 1476 |
const BUSY_STATE = 113; |
| 1477 |
const FINISH_STATE = 666; |
| 1478 |
|
| 1479 |
const BS_NEED_MORE = 1; |
| 1480 |
const BS_BLOCK_DONE = 2; |
| 1481 |
const BS_FINISH_STARTED = 3; |
| 1482 |
const BS_FINISH_DONE = 4; |
| 1483 |
|
| 1484 |
const OS_CODE = 0x03; |
| 1485 |
|
| 1486 |
const err = (strm, errorCode) => { |
| 1487 |
strm.msg = messages[errorCode]; |
| 1488 |
return errorCode; |
| 1489 |
}; |
| 1490 |
|
| 1491 |
const rank = (f) => { |
| 1492 |
return ((f) * 2) - ((f) > 4 ? 9 : 0); |
| 1493 |
}; |
| 1494 |
|
| 1495 |
const zero = (buf) => { |
| 1496 |
let len = buf.length; while (--len >= 0) { buf[len] = 0; } |
| 1497 |
}; |
| 1498 |
|
| 1499 |
|
| 1500 |
|
| 1501 |
|
| 1502 |
|
| 1503 |
|
| 1504 |
const slide_hash = (s) => { |
| 1505 |
let n, m; |
| 1506 |
let p; |
| 1507 |
let wsize = s.w_size; |
| 1508 |
|
| 1509 |
n = s.hash_size; |
| 1510 |
p = n; |
| 1511 |
do { |
| 1512 |
m = s.head[--p]; |
| 1513 |
s.head[p] = (m >= wsize ? m - wsize : 0); |
| 1514 |
} while (--n); |
| 1515 |
n = wsize; |
| 1516 |
|
| 1517 |
p = n; |
| 1518 |
do { |
| 1519 |
m = s.prev[--p]; |
| 1520 |
s.prev[p] = (m >= wsize ? m - wsize : 0); |
| 1521 |
|
| 1522 |
|
| 1523 |
|
| 1524 |
} while (--n); |
| 1525 |
|
| 1526 |
}; |
| 1527 |
|
| 1528 |
|
| 1529 |
let HASH_ZLIB = (s, prev, data) => ((prev << s.hash_shift) ^ data) & s.hash_mask; |
| 1530 |
|
| 1531 |
|
| 1532 |
|
| 1533 |
let HASH = HASH_ZLIB; |
| 1534 |
|
| 1535 |
|
| 1536 |
|
| 1537 |
|
| 1538 |
|
| 1539 |
|
| 1540 |
|
| 1541 |
|
| 1542 |
const flush_pending = (strm) => { |
| 1543 |
const s = strm.state; |
| 1544 |
|
| 1545 |
|
| 1546 |
let len = s.pending; |
| 1547 |
if (len > strm.avail_out) { |
| 1548 |
len = strm.avail_out; |
| 1549 |
} |
| 1550 |
if (len === 0) { return; } |
| 1551 |
|
| 1552 |
strm.output.set(s.pending_buf.subarray(s.pending_out, s.pending_out + len), strm.next_out); |
| 1553 |
strm.next_out += len; |
| 1554 |
s.pending_out += len; |
| 1555 |
strm.total_out += len; |
| 1556 |
strm.avail_out -= len; |
| 1557 |
s.pending -= len; |
| 1558 |
if (s.pending === 0) { |
| 1559 |
s.pending_out = 0; |
| 1560 |
} |
| 1561 |
}; |
| 1562 |
|
| 1563 |
|
| 1564 |
const flush_block_only = (s, last) => { |
| 1565 |
_tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, last); |
| 1566 |
s.block_start = s.strstart; |
| 1567 |
flush_pending(s.strm); |
| 1568 |
}; |
| 1569 |
|
| 1570 |
|
| 1571 |
const put_byte = (s, b) => { |
| 1572 |
s.pending_buf[s.pending++] = b; |
| 1573 |
}; |
| 1574 |
|
| 1575 |
|
| 1576 |
|
| 1577 |
|
| 1578 |
|
| 1579 |
|
| 1580 |
|
| 1581 |
const putShortMSB = (s, b) => { |
| 1582 |
|
| 1583 |
|
| 1584 |
|
| 1585 |
s.pending_buf[s.pending++] = (b >>> 8) & 0xff; |
| 1586 |
s.pending_buf[s.pending++] = b & 0xff; |
| 1587 |
}; |
| 1588 |
|
| 1589 |
|
| 1590 |
|
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
|
| 1595 |
|
| 1596 |
|
| 1597 |
const read_buf = (strm, buf, start, size) => { |
| 1598 |
|
| 1599 |
let len = strm.avail_in; |
| 1600 |
|
| 1601 |
if (len > size) { len = size; } |
| 1602 |
if (len === 0) { return 0; } |
| 1603 |
|
| 1604 |
strm.avail_in -= len; |
| 1605 |
|
| 1606 |
|
| 1607 |
buf.set(strm.input.subarray(strm.next_in, strm.next_in + len), start); |
| 1608 |
if (strm.state.wrap === 1) { |
| 1609 |
strm.adler = adler32_1(strm.adler, buf, len, start); |
| 1610 |
} |
| 1611 |
|
| 1612 |
else if (strm.state.wrap === 2) { |
| 1613 |
strm.adler = crc32_1(strm.adler, buf, len, start); |
| 1614 |
} |
| 1615 |
|
| 1616 |
strm.next_in += len; |
| 1617 |
strm.total_in += len; |
| 1618 |
|
| 1619 |
return len; |
| 1620 |
}; |
| 1621 |
|
| 1622 |
|
| 1623 |
|
| 1624 |
|
| 1625 |
|
| 1626 |
|
| 1627 |
|
| 1628 |
|
| 1629 |
|
| 1630 |
|
| 1631 |
|
| 1632 |
const longest_match = (s, cur_match) => { |
| 1633 |
|
| 1634 |
let chain_length = s.max_chain_length; |
| 1635 |
let scan = s.strstart; |
| 1636 |
let match; |
| 1637 |
let len; |
| 1638 |
let best_len = s.prev_length; |
| 1639 |
let nice_match = s.nice_match; |
| 1640 |
const limit = (s.strstart > (s.w_size - MIN_LOOKAHEAD)) ? |
| 1641 |
s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0; |
| 1642 |
|
| 1643 |
const _win = s.window; |
| 1644 |
|
| 1645 |
const wmask = s.w_mask; |
| 1646 |
const prev = s.prev; |
| 1647 |
|
| 1648 |
|
| 1649 |
|
| 1650 |
|
| 1651 |
|
| 1652 |
const strend = s.strstart + MAX_MATCH; |
| 1653 |
let scan_end1 = _win[scan + best_len - 1]; |
| 1654 |
let scan_end = _win[scan + best_len]; |
| 1655 |
|
| 1656 |
|
| 1657 |
|
| 1658 |
|
| 1659 |
|
| 1660 |
|
| 1661 |
|
| 1662 |
if (s.prev_length >= s.good_match) { |
| 1663 |
chain_length >>= 2; |
| 1664 |
} |
| 1665 |
|
| 1666 |
|
| 1667 |
|
| 1668 |
if (nice_match > s.lookahead) { nice_match = s.lookahead; } |
| 1669 |
|
| 1670 |
|
| 1671 |
|
| 1672 |
do { |
| 1673 |
|
| 1674 |
match = cur_match; |
| 1675 |
|
| 1676 |
|
| 1677 |
|
| 1678 |
|
| 1679 |
|
| 1680 |
|
| 1681 |
|
| 1682 |
|
| 1683 |
|
| 1684 |
|
| 1685 |
if (_win[match + best_len] !== scan_end || |
| 1686 |
_win[match + best_len - 1] !== scan_end1 || |
| 1687 |
_win[match] !== _win[scan] || |
| 1688 |
_win[++match] !== _win[scan + 1]) { |
| 1689 |
continue; |
| 1690 |
} |
| 1691 |
|
| 1692 |
|
| 1693 |
|
| 1694 |
|
| 1695 |
|
| 1696 |
|
| 1697 |
|
| 1698 |
scan += 2; |
| 1699 |
match++; |
| 1700 |
|
| 1701 |
|
| 1702 |
|
| 1703 |
|
| 1704 |
|
| 1705 |
do { |
| 1706 |
|
| 1707 |
} while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && |
| 1708 |
_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && |
| 1709 |
_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && |
| 1710 |
_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && |
| 1711 |
scan < strend); |
| 1712 |
|
| 1713 |
|
| 1714 |
|
| 1715 |
len = MAX_MATCH - (strend - scan); |
| 1716 |
scan = strend - MAX_MATCH; |
| 1717 |
|
| 1718 |
if (len > best_len) { |
| 1719 |
s.match_start = cur_match; |
| 1720 |
best_len = len; |
| 1721 |
if (len >= nice_match) { |
| 1722 |
break; |
| 1723 |
} |
| 1724 |
scan_end1 = _win[scan + best_len - 1]; |
| 1725 |
scan_end = _win[scan + best_len]; |
| 1726 |
} |
| 1727 |
} while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0); |
| 1728 |
|
| 1729 |
if (best_len <= s.lookahead) { |
| 1730 |
return best_len; |
| 1731 |
} |
| 1732 |
return s.lookahead; |
| 1733 |
}; |
| 1734 |
|
| 1735 |
|
| 1736 |
|
| 1737 |
|
| 1738 |
|
| 1739 |
|
| 1740 |
|
| 1741 |
|
| 1742 |
|
| 1743 |
|
| 1744 |
|
| 1745 |
|
| 1746 |
const fill_window = (s) => { |
| 1747 |
|
| 1748 |
const _w_size = s.w_size; |
| 1749 |
let n, more, str; |
| 1750 |
|
| 1751 |
|
| 1752 |
|
| 1753 |
do { |
| 1754 |
more = s.window_size - s.lookahead - s.strstart; |
| 1755 |
|
| 1756 |
|
| 1757 |
|
| 1758 |
|
| 1759 |
|
| 1760 |
|
| 1761 |
|
| 1762 |
|
| 1763 |
|
| 1764 |
|
| 1765 |
|
| 1766 |
|
| 1767 |
|
| 1768 |
|
| 1769 |
|
| 1770 |
|
| 1771 |
|
| 1772 |
|
| 1773 |
|
| 1774 |
if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) { |
| 1775 |
|
| 1776 |
s.window.set(s.window.subarray(_w_size, _w_size + _w_size - more), 0); |
| 1777 |
s.match_start -= _w_size; |
| 1778 |
s.strstart -= _w_size; |
| 1779 |
|
| 1780 |
s.block_start -= _w_size; |
| 1781 |
if (s.insert > s.strstart) { |
| 1782 |
s.insert = s.strstart; |
| 1783 |
} |
| 1784 |
slide_hash(s); |
| 1785 |
more += _w_size; |
| 1786 |
} |
| 1787 |
if (s.strm.avail_in === 0) { |
| 1788 |
break; |
| 1789 |
} |
| 1790 |
|
| 1791 |
|
| 1792 |
|
| 1793 |
|
| 1794 |
|
| 1795 |
|
| 1796 |
|
| 1797 |
|
| 1798 |
|
| 1799 |
|
| 1800 |
|
| 1801 |
|
| 1802 |
|
| 1803 |
n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more); |
| 1804 |
s.lookahead += n; |
| 1805 |
|
| 1806 |
|
| 1807 |
if (s.lookahead + s.insert >= MIN_MATCH) { |
| 1808 |
str = s.strstart - s.insert; |
| 1809 |
s.ins_h = s.window[str]; |
| 1810 |
|
| 1811 |
|
| 1812 |
s.ins_h = HASH(s, s.ins_h, s.window[str + 1]); |
| 1813 |
|
| 1814 |
|
| 1815 |
|
| 1816 |
while (s.insert) { |
| 1817 |
|
| 1818 |
s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]); |
| 1819 |
|
| 1820 |
s.prev[str & s.w_mask] = s.head[s.ins_h]; |
| 1821 |
s.head[s.ins_h] = str; |
| 1822 |
str++; |
| 1823 |
s.insert--; |
| 1824 |
if (s.lookahead + s.insert < MIN_MATCH) { |
| 1825 |
break; |
| 1826 |
} |
| 1827 |
} |
| 1828 |
} |
| 1829 |
|
| 1830 |
|
| 1831 |
|
| 1832 |
|
| 1833 |
} while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0); |
| 1834 |
|
| 1835 |
|
| 1836 |
|
| 1837 |
|
| 1838 |
|
| 1839 |
|
| 1840 |
|
| 1841 |
|
| 1842 |
|
| 1843 |
|
| 1844 |
|
| 1845 |
|
| 1846 |
|
| 1847 |
|
| 1848 |
|
| 1849 |
|
| 1850 |
|
| 1851 |
|
| 1852 |
|
| 1853 |
|
| 1854 |
|
| 1855 |
|
| 1856 |
|
| 1857 |
|
| 1858 |
|
| 1859 |
|
| 1860 |
|
| 1861 |
|
| 1862 |
|
| 1863 |
|
| 1864 |
|
| 1865 |
|
| 1866 |
|
| 1867 |
|
| 1868 |
|
| 1869 |
|
| 1870 |
|
| 1871 |
}; |
| 1872 |
|
| 1873 |
|
| 1874 |
|
| 1875 |
|
| 1876 |
|
| 1877 |
|
| 1878 |
|
| 1879 |
|
| 1880 |
|
| 1881 |
|
| 1882 |
|
| 1883 |
|
| 1884 |
|
| 1885 |
|
| 1886 |
|
| 1887 |
|
| 1888 |
const deflate_stored = (s, flush) => { |
| 1889 |
|
| 1890 |
|
| 1891 |
|
| 1892 |
|
| 1893 |
|
| 1894 |
let min_block = s.pending_buf_size - 5 > s.w_size ? s.w_size : s.pending_buf_size - 5; |
| 1895 |
|
| 1896 |
|
| 1897 |
|
| 1898 |
|
| 1899 |
|
| 1900 |
let len, left, have, last = 0; |
| 1901 |
let used = s.strm.avail_in; |
| 1902 |
do { |
| 1903 |
|
| 1904 |
|
| 1905 |
|
| 1906 |
|
| 1907 |
len = 65535; |
| 1908 |
have = (s.bi_valid + 42) >> 3; |
| 1909 |
if (s.strm.avail_out < have) { |
| 1910 |
break; |
| 1911 |
} |
| 1912 |
|
| 1913 |
have = s.strm.avail_out - have; |
| 1914 |
left = s.strstart - s.block_start; |
| 1915 |
if (len > left + s.strm.avail_in) { |
| 1916 |
len = left + s.strm.avail_in; |
| 1917 |
} |
| 1918 |
if (len > have) { |
| 1919 |
len = have; |
| 1920 |
} |
| 1921 |
|
| 1922 |
|
| 1923 |
|
| 1924 |
|
| 1925 |
|
| 1926 |
|
| 1927 |
if (len < min_block && ((len === 0 && flush !== Z_FINISH$1) || |
| 1928 |
flush === Z_NO_FLUSH$1 || |
| 1929 |
len !== left + s.strm.avail_in)) { |
| 1930 |
break; |
| 1931 |
} |
| 1932 |
|
| 1933 |
|
| 1934 |
|
| 1935 |
|
| 1936 |
last = flush === Z_FINISH$1 && len === left + s.strm.avail_in ? 1 : 0; |
| 1937 |
_tr_stored_block(s, 0, 0, last); |
| 1938 |
|
| 1939 |
|
| 1940 |
s.pending_buf[s.pending - 4] = len; |
| 1941 |
s.pending_buf[s.pending - 3] = len >> 8; |
| 1942 |
s.pending_buf[s.pending - 2] = ~len; |
| 1943 |
s.pending_buf[s.pending - 1] = ~len >> 8; |
| 1944 |
|
| 1945 |
|
| 1946 |
flush_pending(s.strm); |
| 1947 |
|
| 1948 |
|
| 1949 |
|
| 1950 |
|
| 1951 |
|
| 1952 |
|
| 1953 |
|
| 1954 |
|
| 1955 |
if (left) { |
| 1956 |
if (left > len) { |
| 1957 |
left = len; |
| 1958 |
} |
| 1959 |
|
| 1960 |
s.strm.output.set(s.window.subarray(s.block_start, s.block_start + left), s.strm.next_out); |
| 1961 |
s.strm.next_out += left; |
| 1962 |
s.strm.avail_out -= left; |
| 1963 |
s.strm.total_out += left; |
| 1964 |
s.block_start += left; |
| 1965 |
len -= left; |
| 1966 |
} |
| 1967 |
|
| 1968 |
|
| 1969 |
|
| 1970 |
|
| 1971 |
if (len) { |
| 1972 |
read_buf(s.strm, s.strm.output, s.strm.next_out, len); |
| 1973 |
s.strm.next_out += len; |
| 1974 |
s.strm.avail_out -= len; |
| 1975 |
s.strm.total_out += len; |
| 1976 |
} |
| 1977 |
} while (last === 0); |
| 1978 |
|
| 1979 |
|
| 1980 |
|
| 1981 |
|
| 1982 |
|
| 1983 |
|
| 1984 |
|
| 1985 |
used -= s.strm.avail_in; |
| 1986 |
if (used) { |
| 1987 |
|
| 1988 |
|
| 1989 |
|
| 1990 |
if (used >= s.w_size) { |
| 1991 |
s.matches = 2; |
| 1992 |
|
| 1993 |
s.window.set(s.strm.input.subarray(s.strm.next_in - s.w_size, s.strm.next_in), 0); |
| 1994 |
s.strstart = s.w_size; |
| 1995 |
s.insert = s.strstart; |
| 1996 |
} |
| 1997 |
else { |
| 1998 |
if (s.window_size - s.strstart <= used) { |
| 1999 |
|
| 2000 |
s.strstart -= s.w_size; |
| 2001 |
|
| 2002 |
s.window.set(s.window.subarray(s.w_size, s.w_size + s.strstart), 0); |
| 2003 |
if (s.matches < 2) { |
| 2004 |
s.matches++; |
| 2005 |
} |
| 2006 |
if (s.insert > s.strstart) { |
| 2007 |
s.insert = s.strstart; |
| 2008 |
} |
| 2009 |
} |
| 2010 |
|
| 2011 |
s.window.set(s.strm.input.subarray(s.strm.next_in - used, s.strm.next_in), s.strstart); |
| 2012 |
s.strstart += used; |
| 2013 |
s.insert += used > s.w_size - s.insert ? s.w_size - s.insert : used; |
| 2014 |
} |
| 2015 |
s.block_start = s.strstart; |
| 2016 |
} |
| 2017 |
if (s.high_water < s.strstart) { |
| 2018 |
s.high_water = s.strstart; |
| 2019 |
} |
| 2020 |
|
| 2021 |
|
| 2022 |
if (last) { |
| 2023 |
return BS_FINISH_DONE; |
| 2024 |
} |
| 2025 |
|
| 2026 |
|
| 2027 |
if (flush !== Z_NO_FLUSH$1 && flush !== Z_FINISH$1 && |
| 2028 |
s.strm.avail_in === 0 && s.strstart === s.block_start) { |
| 2029 |
return BS_BLOCK_DONE; |
| 2030 |
} |
| 2031 |
|
| 2032 |
|
| 2033 |
have = s.window_size - s.strstart; |
| 2034 |
if (s.strm.avail_in > have && s.block_start >= s.w_size) { |
| 2035 |
|
| 2036 |
s.block_start -= s.w_size; |
| 2037 |
s.strstart -= s.w_size; |
| 2038 |
|
| 2039 |
s.window.set(s.window.subarray(s.w_size, s.w_size + s.strstart), 0); |
| 2040 |
if (s.matches < 2) { |
| 2041 |
s.matches++; |
| 2042 |
} |
| 2043 |
have += s.w_size; |
| 2044 |
if (s.insert > s.strstart) { |
| 2045 |
s.insert = s.strstart; |
| 2046 |
} |
| 2047 |
} |
| 2048 |
if (have > s.strm.avail_in) { |
| 2049 |
have = s.strm.avail_in; |
| 2050 |
} |
| 2051 |
if (have) { |
| 2052 |
read_buf(s.strm, s.window, s.strstart, have); |
| 2053 |
s.strstart += have; |
| 2054 |
s.insert += have > s.w_size - s.insert ? s.w_size - s.insert : have; |
| 2055 |
} |
| 2056 |
if (s.high_water < s.strstart) { |
| 2057 |
s.high_water = s.strstart; |
| 2058 |
} |
| 2059 |
|
| 2060 |
|
| 2061 |
|
| 2062 |
|
| 2063 |
|
| 2064 |
|
| 2065 |
have = (s.bi_valid + 42) >> 3; |
| 2066 |
|
| 2067 |
have = s.pending_buf_size - have > 65535 ? 65535 : s.pending_buf_size - have; |
| 2068 |
min_block = have > s.w_size ? s.w_size : have; |
| 2069 |
left = s.strstart - s.block_start; |
| 2070 |
if (left >= min_block || |
| 2071 |
((left || flush === Z_FINISH$1) && flush !== Z_NO_FLUSH$1 && |
| 2072 |
s.strm.avail_in === 0 && left <= have)) { |
| 2073 |
len = left > have ? have : left; |
| 2074 |
last = flush === Z_FINISH$1 && s.strm.avail_in === 0 && |
| 2075 |
len === left ? 1 : 0; |
| 2076 |
_tr_stored_block(s, s.block_start, len, last); |
| 2077 |
s.block_start += len; |
| 2078 |
flush_pending(s.strm); |
| 2079 |
} |
| 2080 |
|
| 2081 |
|
| 2082 |
return last ? BS_FINISH_STARTED : BS_NEED_MORE; |
| 2083 |
}; |
| 2084 |
|
| 2085 |
|
| 2086 |
|
| 2087 |
|
| 2088 |
|
| 2089 |
|
| 2090 |
|
| 2091 |
|
| 2092 |
|
| 2093 |
const deflate_fast = (s, flush) => { |
| 2094 |
|
| 2095 |
let hash_head; |
| 2096 |
let bflush; |
| 2097 |
|
| 2098 |
for (;;) { |
| 2099 |
|
| 2100 |
|
| 2101 |
|
| 2102 |
|
| 2103 |
|
| 2104 |
if (s.lookahead < MIN_LOOKAHEAD) { |
| 2105 |
fill_window(s); |
| 2106 |
if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH$1) { |
| 2107 |
return BS_NEED_MORE; |
| 2108 |
} |
| 2109 |
if (s.lookahead === 0) { |
| 2110 |
break; |
| 2111 |
} |
| 2112 |
} |
| 2113 |
|
| 2114 |
|
| 2115 |
|
| 2116 |
|
| 2117 |
hash_head = 0; |
| 2118 |
if (s.lookahead >= MIN_MATCH) { |
| 2119 |
|
| 2120 |
s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]); |
| 2121 |
hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; |
| 2122 |
s.head[s.ins_h] = s.strstart; |
| 2123 |
|
| 2124 |
} |
| 2125 |
|
| 2126 |
|
| 2127 |
|
| 2128 |
|
| 2129 |
if (hash_head !== 0 && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) { |
| 2130 |
|
| 2131 |
|
| 2132 |
|
| 2133 |
|
| 2134 |
s.match_length = longest_match(s, hash_head); |
| 2135 |
|
| 2136 |
} |
| 2137 |
if (s.match_length >= MIN_MATCH) { |
| 2138 |
|
| 2139 |
|
| 2140 |
|
| 2141 |
|
| 2142 |
bflush = _tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH); |
| 2143 |
|
| 2144 |
s.lookahead -= s.match_length; |
| 2145 |
|
| 2146 |
|
| 2147 |
|
| 2148 |
|
| 2149 |
if (s.match_length <= s.max_lazy_match && s.lookahead >= MIN_MATCH) { |
| 2150 |
s.match_length--; |
| 2151 |
do { |
| 2152 |
s.strstart++; |
| 2153 |
|
| 2154 |
s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]); |
| 2155 |
hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; |
| 2156 |
s.head[s.ins_h] = s.strstart; |
| 2157 |
|
| 2158 |
|
| 2159 |
|
| 2160 |
|
| 2161 |
} while (--s.match_length !== 0); |
| 2162 |
s.strstart++; |
| 2163 |
} else |
| 2164 |
{ |
| 2165 |
s.strstart += s.match_length; |
| 2166 |
s.match_length = 0; |
| 2167 |
s.ins_h = s.window[s.strstart]; |
| 2168 |
|
| 2169 |
s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + 1]); |
| 2170 |
|
| 2171 |
|
| 2172 |
|
| 2173 |
|
| 2174 |
|
| 2175 |
|
| 2176 |
|
| 2177 |
} |
| 2178 |
} else { |
| 2179 |
|
| 2180 |
|
| 2181 |
|
| 2182 |
bflush = _tr_tally(s, 0, s.window[s.strstart]); |
| 2183 |
|
| 2184 |
s.lookahead--; |
| 2185 |
s.strstart++; |
| 2186 |
} |
| 2187 |
if (bflush) { |
| 2188 |
|
| 2189 |
flush_block_only(s, false); |
| 2190 |
if (s.strm.avail_out === 0) { |
| 2191 |
return BS_NEED_MORE; |
| 2192 |
} |
| 2193 |
|
| 2194 |
} |
| 2195 |
} |
| 2196 |
s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1); |
| 2197 |
if (flush === Z_FINISH$1) { |
| 2198 |
|
| 2199 |
flush_block_only(s, true); |
| 2200 |
if (s.strm.avail_out === 0) { |
| 2201 |
return BS_FINISH_STARTED; |
| 2202 |
} |
| 2203 |
|
| 2204 |
return BS_FINISH_DONE; |
| 2205 |
} |
| 2206 |
if (s.sym_next) { |
| 2207 |
|
| 2208 |
flush_block_only(s, false); |
| 2209 |
if (s.strm.avail_out === 0) { |
| 2210 |
return BS_NEED_MORE; |
| 2211 |
} |
| 2212 |
|
| 2213 |
} |
| 2214 |
return BS_BLOCK_DONE; |
| 2215 |
}; |
| 2216 |
|
| 2217 |
|
| 2218 |
|
| 2219 |
|
| 2220 |
|
| 2221 |
|
| 2222 |
const deflate_slow = (s, flush) => { |
| 2223 |
|
| 2224 |
let hash_head; |
| 2225 |
let bflush; |
| 2226 |
|
| 2227 |
let max_insert; |
| 2228 |
|
| 2229 |
|
| 2230 |
for (;;) { |
| 2231 |
|
| 2232 |
|
| 2233 |
|
| 2234 |
|
| 2235 |
|
| 2236 |
if (s.lookahead < MIN_LOOKAHEAD) { |
| 2237 |
fill_window(s); |
| 2238 |
if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH$1) { |
| 2239 |
return BS_NEED_MORE; |
| 2240 |
} |
| 2241 |
if (s.lookahead === 0) { break; } |
| 2242 |
} |
| 2243 |
|
| 2244 |
|
| 2245 |
|
| 2246 |
|
| 2247 |
hash_head = 0; |
| 2248 |
if (s.lookahead >= MIN_MATCH) { |
| 2249 |
|
| 2250 |
s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]); |
| 2251 |
hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; |
| 2252 |
s.head[s.ins_h] = s.strstart; |
| 2253 |
|
| 2254 |
} |
| 2255 |
|
| 2256 |
|
| 2257 |
|
| 2258 |
s.prev_length = s.match_length; |
| 2259 |
s.prev_match = s.match_start; |
| 2260 |
s.match_length = MIN_MATCH - 1; |
| 2261 |
|
| 2262 |
if (hash_head !== 0 && s.prev_length < s.max_lazy_match && |
| 2263 |
s.strstart - hash_head <= (s.w_size - MIN_LOOKAHEAD)) { |
| 2264 |
|
| 2265 |
|
| 2266 |
|
| 2267 |
|
| 2268 |
s.match_length = longest_match(s, hash_head); |
| 2269 |
|
| 2270 |
|
| 2271 |
if (s.match_length <= 5 && |
| 2272 |
(s.strategy === Z_FILTERED || (s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096))) { |
| 2273 |
|
| 2274 |
|
| 2275 |
|
| 2276 |
|
| 2277 |
s.match_length = MIN_MATCH - 1; |
| 2278 |
} |
| 2279 |
} |
| 2280 |
|
| 2281 |
|
| 2282 |
|
| 2283 |
if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) { |
| 2284 |
max_insert = s.strstart + s.lookahead - MIN_MATCH; |
| 2285 |
|
| 2286 |
|
| 2287 |
|
| 2288 |
|
| 2289 |
|
| 2290 |
|
| 2291 |
bflush = _tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH); |
| 2292 |
|
| 2293 |
|
| 2294 |
|
| 2295 |
|
| 2296 |
|
| 2297 |
s.lookahead -= s.prev_length - 1; |
| 2298 |
s.prev_length -= 2; |
| 2299 |
do { |
| 2300 |
if (++s.strstart <= max_insert) { |
| 2301 |
|
| 2302 |
s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]); |
| 2303 |
hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; |
| 2304 |
s.head[s.ins_h] = s.strstart; |
| 2305 |
|
| 2306 |
} |
| 2307 |
} while (--s.prev_length !== 0); |
| 2308 |
s.match_available = 0; |
| 2309 |
s.match_length = MIN_MATCH - 1; |
| 2310 |
s.strstart++; |
| 2311 |
|
| 2312 |
if (bflush) { |
| 2313 |
|
| 2314 |
flush_block_only(s, false); |
| 2315 |
if (s.strm.avail_out === 0) { |
| 2316 |
return BS_NEED_MORE; |
| 2317 |
} |
| 2318 |
|
| 2319 |
} |
| 2320 |
|
| 2321 |
} else if (s.match_available) { |
| 2322 |
|
| 2323 |
|
| 2324 |
|
| 2325 |
|
| 2326 |
|
| 2327 |
|
| 2328 |
bflush = _tr_tally(s, 0, s.window[s.strstart - 1]); |
| 2329 |
|
| 2330 |
if (bflush) { |
| 2331 |
|
| 2332 |
flush_block_only(s, false); |
| 2333 |
|
| 2334 |
} |
| 2335 |
s.strstart++; |
| 2336 |
s.lookahead--; |
| 2337 |
if (s.strm.avail_out === 0) { |
| 2338 |
return BS_NEED_MORE; |
| 2339 |
} |
| 2340 |
} else { |
| 2341 |
|
| 2342 |
|
| 2343 |
|
| 2344 |
s.match_available = 1; |
| 2345 |
s.strstart++; |
| 2346 |
s.lookahead--; |
| 2347 |
} |
| 2348 |
} |
| 2349 |
|
| 2350 |
if (s.match_available) { |
| 2351 |
|
| 2352 |
|
| 2353 |
bflush = _tr_tally(s, 0, s.window[s.strstart - 1]); |
| 2354 |
|
| 2355 |
s.match_available = 0; |
| 2356 |
} |
| 2357 |
s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1; |
| 2358 |
if (flush === Z_FINISH$1) { |
| 2359 |
|
| 2360 |
flush_block_only(s, true); |
| 2361 |
if (s.strm.avail_out === 0) { |
| 2362 |
return BS_FINISH_STARTED; |
| 2363 |
} |
| 2364 |
|
| 2365 |
return BS_FINISH_DONE; |
| 2366 |
} |
| 2367 |
if (s.sym_next) { |
| 2368 |
|
| 2369 |
flush_block_only(s, false); |
| 2370 |
if (s.strm.avail_out === 0) { |
| 2371 |
return BS_NEED_MORE; |
| 2372 |
} |
| 2373 |
|
| 2374 |
} |
| 2375 |
|
| 2376 |
return BS_BLOCK_DONE; |
| 2377 |
}; |
| 2378 |
|
| 2379 |
|
| 2380 |
|
| 2381 |
|
| 2382 |
|
| 2383 |
|
| 2384 |
|
| 2385 |
const deflate_rle = (s, flush) => { |
| 2386 |
|
| 2387 |
let bflush; |
| 2388 |
let prev; |
| 2389 |
let scan, strend; |
| 2390 |
|
| 2391 |
const _win = s.window; |
| 2392 |
|
| 2393 |
for (;;) { |
| 2394 |
|
| 2395 |
|
| 2396 |
|
| 2397 |
|
| 2398 |
if (s.lookahead <= MAX_MATCH) { |
| 2399 |
fill_window(s); |
| 2400 |
if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH$1) { |
| 2401 |
return BS_NEED_MORE; |
| 2402 |
} |
| 2403 |
if (s.lookahead === 0) { break; } |
| 2404 |
} |
| 2405 |
|
| 2406 |
|
| 2407 |
s.match_length = 0; |
| 2408 |
if (s.lookahead >= MIN_MATCH && s.strstart > 0) { |
| 2409 |
scan = s.strstart - 1; |
| 2410 |
prev = _win[scan]; |
| 2411 |
if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) { |
| 2412 |
strend = s.strstart + MAX_MATCH; |
| 2413 |
do { |
| 2414 |
|
| 2415 |
} while (prev === _win[++scan] && prev === _win[++scan] && |
| 2416 |
prev === _win[++scan] && prev === _win[++scan] && |
| 2417 |
prev === _win[++scan] && prev === _win[++scan] && |
| 2418 |
prev === _win[++scan] && prev === _win[++scan] && |
| 2419 |
scan < strend); |
| 2420 |
s.match_length = MAX_MATCH - (strend - scan); |
| 2421 |
if (s.match_length > s.lookahead) { |
| 2422 |
s.match_length = s.lookahead; |
| 2423 |
} |
| 2424 |
} |
| 2425 |
|
| 2426 |
} |
| 2427 |
|
| 2428 |
|
| 2429 |
if (s.match_length >= MIN_MATCH) { |
| 2430 |
|
| 2431 |
|
| 2432 |
|
| 2433 |
bflush = _tr_tally(s, 1, s.match_length - MIN_MATCH); |
| 2434 |
|
| 2435 |
s.lookahead -= s.match_length; |
| 2436 |
s.strstart += s.match_length; |
| 2437 |
s.match_length = 0; |
| 2438 |
} else { |
| 2439 |
|
| 2440 |
|
| 2441 |
|
| 2442 |
bflush = _tr_tally(s, 0, s.window[s.strstart]); |
| 2443 |
|
| 2444 |
s.lookahead--; |
| 2445 |
s.strstart++; |
| 2446 |
} |
| 2447 |
if (bflush) { |
| 2448 |
|
| 2449 |
flush_block_only(s, false); |
| 2450 |
if (s.strm.avail_out === 0) { |
| 2451 |
return BS_NEED_MORE; |
| 2452 |
} |
| 2453 |
|
| 2454 |
} |
| 2455 |
} |
| 2456 |
s.insert = 0; |
| 2457 |
if (flush === Z_FINISH$1) { |
| 2458 |
|
| 2459 |
flush_block_only(s, true); |
| 2460 |
if (s.strm.avail_out === 0) { |
| 2461 |
return BS_FINISH_STARTED; |
| 2462 |
} |
| 2463 |
|
| 2464 |
return BS_FINISH_DONE; |
| 2465 |
} |
| 2466 |
if (s.sym_next) { |
| 2467 |
|
| 2468 |
flush_block_only(s, false); |
| 2469 |
if (s.strm.avail_out === 0) { |
| 2470 |
return BS_NEED_MORE; |
| 2471 |
} |
| 2472 |
|
| 2473 |
} |
| 2474 |
return BS_BLOCK_DONE; |
| 2475 |
}; |
| 2476 |
|
| 2477 |
|
| 2478 |
|
| 2479 |
|
| 2480 |
|
| 2481 |
const deflate_huff = (s, flush) => { |
| 2482 |
|
| 2483 |
let bflush; |
| 2484 |
|
| 2485 |
for (;;) { |
| 2486 |
|
| 2487 |
if (s.lookahead === 0) { |
| 2488 |
fill_window(s); |
| 2489 |
if (s.lookahead === 0) { |
| 2490 |
if (flush === Z_NO_FLUSH$1) { |
| 2491 |
return BS_NEED_MORE; |
| 2492 |
} |
| 2493 |
break; |
| 2494 |
} |
| 2495 |
} |
| 2496 |
|
| 2497 |
|
| 2498 |
s.match_length = 0; |
| 2499 |
|
| 2500 |
|
| 2501 |
bflush = _tr_tally(s, 0, s.window[s.strstart]); |
| 2502 |
s.lookahead--; |
| 2503 |
s.strstart++; |
| 2504 |
if (bflush) { |
| 2505 |
|
| 2506 |
flush_block_only(s, false); |
| 2507 |
if (s.strm.avail_out === 0) { |
| 2508 |
return BS_NEED_MORE; |
| 2509 |
} |
| 2510 |
|
| 2511 |
} |
| 2512 |
} |
| 2513 |
s.insert = 0; |
| 2514 |
if (flush === Z_FINISH$1) { |
| 2515 |
|
| 2516 |
flush_block_only(s, true); |
| 2517 |
if (s.strm.avail_out === 0) { |
| 2518 |
return BS_FINISH_STARTED; |
| 2519 |
} |
| 2520 |
|
| 2521 |
return BS_FINISH_DONE; |
| 2522 |
} |
| 2523 |
if (s.sym_next) { |
| 2524 |
|
| 2525 |
flush_block_only(s, false); |
| 2526 |
if (s.strm.avail_out === 0) { |
| 2527 |
return BS_NEED_MORE; |
| 2528 |
} |
| 2529 |
|
| 2530 |
} |
| 2531 |
return BS_BLOCK_DONE; |
| 2532 |
}; |
| 2533 |
|
| 2534 |
|
| 2535 |
|
| 2536 |
|
| 2537 |
|
| 2538 |
|
| 2539 |
function Config(good_length, max_lazy, nice_length, max_chain, func) { |
| 2540 |
|
| 2541 |
this.good_length = good_length; |
| 2542 |
this.max_lazy = max_lazy; |
| 2543 |
this.nice_length = nice_length; |
| 2544 |
this.max_chain = max_chain; |
| 2545 |
this.func = func; |
| 2546 |
} |
| 2547 |
|
| 2548 |
const configuration_table = [ |
| 2549 |
|
| 2550 |
new Config(0, 0, 0, 0, deflate_stored), |
| 2551 |
new Config(4, 4, 8, 4, deflate_fast), |
| 2552 |
new Config(4, 5, 16, 8, deflate_fast), |
| 2553 |
new Config(4, 6, 32, 32, deflate_fast), |
| 2554 |
|
| 2555 |
new Config(4, 4, 16, 16, deflate_slow), |
| 2556 |
new Config(8, 16, 32, 32, deflate_slow), |
| 2557 |
new Config(8, 16, 128, 128, deflate_slow), |
| 2558 |
new Config(8, 32, 128, 256, deflate_slow), |
| 2559 |
new Config(32, 128, 258, 1024, deflate_slow), |
| 2560 |
new Config(32, 258, 258, 4096, deflate_slow) |
| 2561 |
]; |
| 2562 |
|
| 2563 |
|
| 2564 |
|
| 2565 |
|
| 2566 |
|
| 2567 |
const lm_init = (s) => { |
| 2568 |
|
| 2569 |
s.window_size = 2 * s.w_size; |
| 2570 |
|
| 2571 |
|
| 2572 |
zero(s.head); |
| 2573 |
|
| 2574 |
|
| 2575 |
|
| 2576 |
s.max_lazy_match = configuration_table[s.level].max_lazy; |
| 2577 |
s.good_match = configuration_table[s.level].good_length; |
| 2578 |
s.nice_match = configuration_table[s.level].nice_length; |
| 2579 |
s.max_chain_length = configuration_table[s.level].max_chain; |
| 2580 |
|
| 2581 |
s.strstart = 0; |
| 2582 |
s.block_start = 0; |
| 2583 |
s.lookahead = 0; |
| 2584 |
s.insert = 0; |
| 2585 |
s.match_length = s.prev_length = MIN_MATCH - 1; |
| 2586 |
s.match_available = 0; |
| 2587 |
s.ins_h = 0; |
| 2588 |
}; |
| 2589 |
|
| 2590 |
|
| 2591 |
function DeflateState() { |
| 2592 |
this.strm = null; |
| 2593 |
this.status = 0; |
| 2594 |
this.pending_buf = null; |
| 2595 |
this.pending_buf_size = 0; |
| 2596 |
this.pending_out = 0; |
| 2597 |
this.pending = 0; |
| 2598 |
this.wrap = 0; |
| 2599 |
this.gzhead = null; |
| 2600 |
this.gzindex = 0; |
| 2601 |
this.method = Z_DEFLATED$1; |
| 2602 |
this.last_flush = -1; |
| 2603 |
|
| 2604 |
this.w_size = 0; |
| 2605 |
this.w_bits = 0; |
| 2606 |
this.w_mask = 0; |
| 2607 |
|
| 2608 |
this.window = null; |
| 2609 |
|
| 2610 |
|
| 2611 |
|
| 2612 |
|
| 2613 |
|
| 2614 |
|
| 2615 |
|
| 2616 |
this.window_size = 0; |
| 2617 |
|
| 2618 |
|
| 2619 |
|
| 2620 |
|
| 2621 |
this.prev = null; |
| 2622 |
|
| 2623 |
|
| 2624 |
|
| 2625 |
|
| 2626 |
|
| 2627 |
this.head = null; |
| 2628 |
|
| 2629 |
this.ins_h = 0; |
| 2630 |
this.hash_size = 0; |
| 2631 |
this.hash_bits = 0; |
| 2632 |
this.hash_mask = 0; |
| 2633 |
|
| 2634 |
this.hash_shift = 0; |
| 2635 |
|
| 2636 |
|
| 2637 |
|
| 2638 |
|
| 2639 |
|
| 2640 |
|
| 2641 |
this.block_start = 0; |
| 2642 |
|
| 2643 |
|
| 2644 |
|
| 2645 |
|
| 2646 |
this.match_length = 0; |
| 2647 |
this.prev_match = 0; |
| 2648 |
this.match_available = 0; |
| 2649 |
this.strstart = 0; |
| 2650 |
this.match_start = 0; |
| 2651 |
this.lookahead = 0; |
| 2652 |
|
| 2653 |
this.prev_length = 0; |
| 2654 |
|
| 2655 |
|
| 2656 |
|
| 2657 |
|
| 2658 |
this.max_chain_length = 0; |
| 2659 |
|
| 2660 |
|
| 2661 |
|
| 2662 |
|
| 2663 |
|
| 2664 |
this.max_lazy_match = 0; |
| 2665 |
|
| 2666 |
|
| 2667 |
|
| 2668 |
|
| 2669 |
|
| 2670 |
|
| 2671 |
|
| 2672 |
|
| 2673 |
|
| 2674 |
|
| 2675 |
|
| 2676 |
this.level = 0; |
| 2677 |
this.strategy = 0; |
| 2678 |
|
| 2679 |
this.good_match = 0; |
| 2680 |
|
| 2681 |
|
| 2682 |
this.nice_match = 0; |
| 2683 |
|
| 2684 |
|
| 2685 |
|
| 2686 |
|
| 2687 |
|
| 2688 |
|
| 2689 |
|
| 2690 |
|
| 2691 |
|
| 2692 |
|
| 2693 |
|
| 2694 |
this.dyn_ltree = new Uint16Array(HEAP_SIZE * 2); |
| 2695 |
this.dyn_dtree = new Uint16Array((2 * D_CODES + 1) * 2); |
| 2696 |
this.bl_tree = new Uint16Array((2 * BL_CODES + 1) * 2); |
| 2697 |
zero(this.dyn_ltree); |
| 2698 |
zero(this.dyn_dtree); |
| 2699 |
zero(this.bl_tree); |
| 2700 |
|
| 2701 |
this.l_desc = null; |
| 2702 |
this.d_desc = null; |
| 2703 |
this.bl_desc = null; |
| 2704 |
|
| 2705 |
|
| 2706 |
this.bl_count = new Uint16Array(MAX_BITS + 1); |
| 2707 |
|
| 2708 |
|
| 2709 |
|
| 2710 |
this.heap = new Uint16Array(2 * L_CODES + 1); |
| 2711 |
zero(this.heap); |
| 2712 |
|
| 2713 |
this.heap_len = 0; |
| 2714 |
this.heap_max = 0; |
| 2715 |
|
| 2716 |
|
| 2717 |
|
| 2718 |
|
| 2719 |
this.depth = new Uint16Array(2 * L_CODES + 1); |
| 2720 |
zero(this.depth); |
| 2721 |
|
| 2722 |
|
| 2723 |
|
| 2724 |
this.sym_buf = 0; |
| 2725 |
|
| 2726 |
this.lit_bufsize = 0; |
| 2727 |
|
| 2728 |
|
| 2729 |
|
| 2730 |
|
| 2731 |
|
| 2732 |
|
| 2733 |
|
| 2734 |
|
| 2735 |
|
| 2736 |
|
| 2737 |
|
| 2738 |
|
| 2739 |
|
| 2740 |
|
| 2741 |
|
| 2742 |
|
| 2743 |
|
| 2744 |
|
| 2745 |
|
| 2746 |
this.sym_next = 0; |
| 2747 |
this.sym_end = 0; |
| 2748 |
|
| 2749 |
this.opt_len = 0; |
| 2750 |
this.static_len = 0; |
| 2751 |
this.matches = 0; |
| 2752 |
this.insert = 0; |
| 2753 |
|
| 2754 |
|
| 2755 |
this.bi_buf = 0; |
| 2756 |
|
| 2757 |
|
| 2758 |
|
| 2759 |
this.bi_valid = 0; |
| 2760 |
|
| 2761 |
|
| 2762 |
|
| 2763 |
|
| 2764 |
|
| 2765 |
|
| 2766 |
|
| 2767 |
|
| 2768 |
|
| 2769 |
|
| 2770 |
|
| 2771 |
|
| 2772 |
} |
| 2773 |
|
| 2774 |
|
| 2775 |
|
| 2776 |
|
| 2777 |
|
| 2778 |
const deflateStateCheck = (strm) => { |
| 2779 |
|
| 2780 |
if (!strm) { |
| 2781 |
return 1; |
| 2782 |
} |
| 2783 |
const s = strm.state; |
| 2784 |
if (!s || s.strm !== strm || (s.status !== INIT_STATE && |
| 2785 |
|
| 2786 |
s.status !== GZIP_STATE && |
| 2787 |
|
| 2788 |
s.status !== EXTRA_STATE && |
| 2789 |
s.status !== NAME_STATE && |
| 2790 |
s.status !== COMMENT_STATE && |
| 2791 |
s.status !== HCRC_STATE && |
| 2792 |
s.status !== BUSY_STATE && |
| 2793 |
s.status !== FINISH_STATE)) { |
| 2794 |
return 1; |
| 2795 |
} |
| 2796 |
return 0; |
| 2797 |
}; |
| 2798 |
|
| 2799 |
|
| 2800 |
const deflateResetKeep = (strm) => { |
| 2801 |
|
| 2802 |
if (deflateStateCheck(strm)) { |
| 2803 |
return err(strm, Z_STREAM_ERROR); |
| 2804 |
} |
| 2805 |
|
| 2806 |
strm.total_in = strm.total_out = 0; |
| 2807 |
strm.data_type = Z_UNKNOWN; |
| 2808 |
|
| 2809 |
const s = strm.state; |
| 2810 |
s.pending = 0; |
| 2811 |
s.pending_out = 0; |
| 2812 |
|
| 2813 |
if (s.wrap < 0) { |
| 2814 |
s.wrap = -s.wrap; |
| 2815 |
|
| 2816 |
} |
| 2817 |
s.status = |
| 2818 |
|
| 2819 |
s.wrap === 2 ? GZIP_STATE : |
| 2820 |
|
| 2821 |
s.wrap ? INIT_STATE : BUSY_STATE; |
| 2822 |
strm.adler = (s.wrap === 2) ? |
| 2823 |
0 |
| 2824 |
: |
| 2825 |
1; |
| 2826 |
s.last_flush = -2; |
| 2827 |
_tr_init(s); |
| 2828 |
return Z_OK$1; |
| 2829 |
}; |
| 2830 |
|
| 2831 |
|
| 2832 |
const deflateReset = (strm) => { |
| 2833 |
|
| 2834 |
const ret = deflateResetKeep(strm); |
| 2835 |
if (ret === Z_OK$1) { |
| 2836 |
lm_init(strm.state); |
| 2837 |
} |
| 2838 |
return ret; |
| 2839 |
}; |
| 2840 |
|
| 2841 |
|
| 2842 |
const deflateSetHeader = (strm, head) => { |
| 2843 |
|
| 2844 |
if (deflateStateCheck(strm) || strm.state.wrap !== 2) { |
| 2845 |
return Z_STREAM_ERROR; |
| 2846 |
} |
| 2847 |
strm.state.gzhead = head; |
| 2848 |
return Z_OK$1; |
| 2849 |
}; |
| 2850 |
|
| 2851 |
|
| 2852 |
const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => { |
| 2853 |
|
| 2854 |
if (!strm) { |
| 2855 |
return Z_STREAM_ERROR; |
| 2856 |
} |
| 2857 |
let wrap = 1; |
| 2858 |
|
| 2859 |
if (level === Z_DEFAULT_COMPRESSION$1) { |
| 2860 |
level = 6; |
| 2861 |
} |
| 2862 |
|
| 2863 |
if (windowBits < 0) { |
| 2864 |
wrap = 0; |
| 2865 |
windowBits = -windowBits; |
| 2866 |
} |
| 2867 |
|
| 2868 |
else if (windowBits > 15) { |
| 2869 |
wrap = 2; |
| 2870 |
windowBits -= 16; |
| 2871 |
} |
| 2872 |
|
| 2873 |
|
| 2874 |
if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED$1 || |
| 2875 |
windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || |
| 2876 |
strategy < 0 || strategy > Z_FIXED || (windowBits === 8 && wrap !== 1)) { |
| 2877 |
return err(strm, Z_STREAM_ERROR); |
| 2878 |
} |
| 2879 |
|
| 2880 |
|
| 2881 |
if (windowBits === 8) { |
| 2882 |
windowBits = 9; |
| 2883 |
} |
| 2884 |
|
| 2885 |
|
| 2886 |
const s = new DeflateState(); |
| 2887 |
|
| 2888 |
strm.state = s; |
| 2889 |
s.strm = strm; |
| 2890 |
s.status = INIT_STATE; |
| 2891 |
|
| 2892 |
s.wrap = wrap; |
| 2893 |
s.gzhead = null; |
| 2894 |
s.w_bits = windowBits; |
| 2895 |
s.w_size = 1 << s.w_bits; |
| 2896 |
s.w_mask = s.w_size - 1; |
| 2897 |
|
| 2898 |
s.hash_bits = memLevel + 7; |
| 2899 |
s.hash_size = 1 << s.hash_bits; |
| 2900 |
s.hash_mask = s.hash_size - 1; |
| 2901 |
s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH); |
| 2902 |
|
| 2903 |
s.window = new Uint8Array(s.w_size * 2); |
| 2904 |
s.head = new Uint16Array(s.hash_size); |
| 2905 |
s.prev = new Uint16Array(s.w_size); |
| 2906 |
|
| 2907 |
|
| 2908 |
|
| 2909 |
|
| 2910 |
s.lit_bufsize = 1 << (memLevel + 6); |
| 2911 |
|
| 2912 |
|
| 2913 |
|
| 2914 |
|
| 2915 |
|
| 2916 |
|
| 2917 |
|
| 2918 |
|
| 2919 |
|
| 2920 |
|
| 2921 |
|
| 2922 |
|
| 2923 |
|
| 2924 |
|
| 2925 |
|
| 2926 |
|
| 2927 |
|
| 2928 |
|
| 2929 |
|
| 2930 |
|
| 2931 |
|
| 2932 |
|
| 2933 |
|
| 2934 |
|
| 2935 |
|
| 2936 |
|
| 2937 |
|
| 2938 |
|
| 2939 |
|
| 2940 |
|
| 2941 |
|
| 2942 |
|
| 2943 |
|
| 2944 |
|
| 2945 |
|
| 2946 |
|
| 2947 |
|
| 2948 |
|
| 2949 |
|
| 2950 |
|
| 2951 |
s.pending_buf_size = s.lit_bufsize * 4; |
| 2952 |
s.pending_buf = new Uint8Array(s.pending_buf_size); |
| 2953 |
|
| 2954 |
|
| 2955 |
|
| 2956 |
s.sym_buf = s.lit_bufsize; |
| 2957 |
|
| 2958 |
|
| 2959 |
s.sym_end = (s.lit_bufsize - 1) * 3; |
| 2960 |
|
| 2961 |
|
| 2962 |
|
| 2963 |
|
| 2964 |
|
| 2965 |
s.level = level; |
| 2966 |
s.strategy = strategy; |
| 2967 |
s.method = method; |
| 2968 |
|
| 2969 |
return deflateReset(strm); |
| 2970 |
}; |
| 2971 |
|
| 2972 |
const deflateInit = (strm, level) => { |
| 2973 |
|
| 2974 |
return deflateInit2(strm, level, Z_DEFLATED$1, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY$1); |
| 2975 |
}; |
| 2976 |
|
| 2977 |
|
| 2978 |
|
| 2979 |
const deflate$1 = (strm, flush) => { |
| 2980 |
|
| 2981 |
if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) { |
| 2982 |
return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR; |
| 2983 |
} |
| 2984 |
|
| 2985 |
const s = strm.state; |
| 2986 |
|
| 2987 |
if (!strm.output || |
| 2988 |
(strm.avail_in !== 0 && !strm.input) || |
| 2989 |
(s.status === FINISH_STATE && flush !== Z_FINISH$1)) { |
| 2990 |
return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR : Z_STREAM_ERROR); |
| 2991 |
} |
| 2992 |
|
| 2993 |
const old_flush = s.last_flush; |
| 2994 |
s.last_flush = flush; |
| 2995 |
|
| 2996 |
|
| 2997 |
if (s.pending !== 0) { |
| 2998 |
flush_pending(strm); |
| 2999 |
if (strm.avail_out === 0) { |
| 3000 |
|
| 3001 |
|
| 3002 |
|
| 3003 |
|
| 3004 |
|
| 3005 |
|
| 3006 |
s.last_flush = -1; |
| 3007 |
return Z_OK$1; |
| 3008 |
} |
| 3009 |
|
| 3010 |
|
| 3011 |
|
| 3012 |
|
| 3013 |
|
| 3014 |
} else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && |
| 3015 |
flush !== Z_FINISH$1) { |
| 3016 |
return err(strm, Z_BUF_ERROR); |
| 3017 |
} |
| 3018 |
|
| 3019 |
|
| 3020 |
if (s.status === FINISH_STATE && strm.avail_in !== 0) { |
| 3021 |
return err(strm, Z_BUF_ERROR); |
| 3022 |
} |
| 3023 |
|
| 3024 |
|
| 3025 |
if (s.status === INIT_STATE && s.wrap === 0) { |
| 3026 |
s.status = BUSY_STATE; |
| 3027 |
} |
| 3028 |
if (s.status === INIT_STATE) { |
| 3029 |
|
| 3030 |
let header = (Z_DEFLATED$1 + ((s.w_bits - 8) << 4)) << 8; |
| 3031 |
let level_flags = -1; |
| 3032 |
|
| 3033 |
if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) { |
| 3034 |
level_flags = 0; |
| 3035 |
} else if (s.level < 6) { |
| 3036 |
level_flags = 1; |
| 3037 |
} else if (s.level === 6) { |
| 3038 |
level_flags = 2; |
| 3039 |
} else { |
| 3040 |
level_flags = 3; |
| 3041 |
} |
| 3042 |
header |= (level_flags << 6); |
| 3043 |
if (s.strstart !== 0) { header |= PRESET_DICT; } |
| 3044 |
header += 31 - (header % 31); |
| 3045 |
|
| 3046 |
putShortMSB(s, header); |
| 3047 |
|
| 3048 |
|
| 3049 |
if (s.strstart !== 0) { |
| 3050 |
putShortMSB(s, strm.adler >>> 16); |
| 3051 |
putShortMSB(s, strm.adler & 0xffff); |
| 3052 |
} |
| 3053 |
strm.adler = 1; |
| 3054 |
s.status = BUSY_STATE; |
| 3055 |
|
| 3056 |
|
| 3057 |
flush_pending(strm); |
| 3058 |
if (s.pending !== 0) { |
| 3059 |
s.last_flush = -1; |
| 3060 |
return Z_OK$1; |
| 3061 |
} |
| 3062 |
} |
| 3063 |
|
| 3064 |
if (s.status === GZIP_STATE) { |
| 3065 |
|
| 3066 |
strm.adler = 0; |
| 3067 |
put_byte(s, 31); |
| 3068 |
put_byte(s, 139); |
| 3069 |
put_byte(s, 8); |
| 3070 |
if (!s.gzhead) { |
| 3071 |
put_byte(s, 0); |
| 3072 |
put_byte(s, 0); |
| 3073 |
put_byte(s, 0); |
| 3074 |
put_byte(s, 0); |
| 3075 |
put_byte(s, 0); |
| 3076 |
put_byte(s, s.level === 9 ? 2 : |
| 3077 |
(s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? |
| 3078 |
4 : 0)); |
| 3079 |
put_byte(s, OS_CODE); |
| 3080 |
s.status = BUSY_STATE; |
| 3081 |
|
| 3082 |
|
| 3083 |
flush_pending(strm); |
| 3084 |
if (s.pending !== 0) { |
| 3085 |
s.last_flush = -1; |
| 3086 |
return Z_OK$1; |
| 3087 |
} |
| 3088 |
} |
| 3089 |
else { |
| 3090 |
put_byte(s, (s.gzhead.text ? 1 : 0) + |
| 3091 |
(s.gzhead.hcrc ? 2 : 0) + |
| 3092 |
(!s.gzhead.extra ? 0 : 4) + |
| 3093 |
(!s.gzhead.name ? 0 : 8) + |
| 3094 |
(!s.gzhead.comment ? 0 : 16) |
| 3095 |
); |
| 3096 |
put_byte(s, s.gzhead.time & 0xff); |
| 3097 |
put_byte(s, (s.gzhead.time >> 8) & 0xff); |
| 3098 |
put_byte(s, (s.gzhead.time >> 16) & 0xff); |
| 3099 |
put_byte(s, (s.gzhead.time >> 24) & 0xff); |
| 3100 |
put_byte(s, s.level === 9 ? 2 : |
| 3101 |
(s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? |
| 3102 |
4 : 0)); |
| 3103 |
put_byte(s, s.gzhead.os & 0xff); |
| 3104 |
if (s.gzhead.extra && s.gzhead.extra.length) { |
| 3105 |
put_byte(s, s.gzhead.extra.length & 0xff); |
| 3106 |
put_byte(s, (s.gzhead.extra.length >> 8) & 0xff); |
| 3107 |
} |
| 3108 |
if (s.gzhead.hcrc) { |
| 3109 |
strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending, 0); |
| 3110 |
} |
| 3111 |
s.gzindex = 0; |
| 3112 |
s.status = EXTRA_STATE; |
| 3113 |
} |
| 3114 |
} |
| 3115 |
if (s.status === EXTRA_STATE) { |
| 3116 |
if (s.gzhead.extra) { |
| 3117 |
let beg = s.pending; |
| 3118 |
let left = (s.gzhead.extra.length & 0xffff) - s.gzindex; |
| 3119 |
while (s.pending + left > s.pending_buf_size) { |
| 3120 |
let copy = s.pending_buf_size - s.pending; |
| 3121 |
|
| 3122 |
|
| 3123 |
s.pending_buf.set(s.gzhead.extra.subarray(s.gzindex, s.gzindex + copy), s.pending); |
| 3124 |
s.pending = s.pending_buf_size; |
| 3125 |
|
| 3126 |
if (s.gzhead.hcrc && s.pending > beg) { |
| 3127 |
strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg); |
| 3128 |
} |
| 3129 |
|
| 3130 |
s.gzindex += copy; |
| 3131 |
flush_pending(strm); |
| 3132 |
if (s.pending !== 0) { |
| 3133 |
s.last_flush = -1; |
| 3134 |
return Z_OK$1; |
| 3135 |
} |
| 3136 |
beg = 0; |
| 3137 |
left -= copy; |
| 3138 |
} |
| 3139 |
|
| 3140 |
|
| 3141 |
let gzhead_extra = new Uint8Array(s.gzhead.extra); |
| 3142 |
|
| 3143 |
|
| 3144 |
s.pending_buf.set(gzhead_extra.subarray(s.gzindex, s.gzindex + left), s.pending); |
| 3145 |
s.pending += left; |
| 3146 |
|
| 3147 |
if (s.gzhead.hcrc && s.pending > beg) { |
| 3148 |
strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg); |
| 3149 |
} |
| 3150 |
|
| 3151 |
s.gzindex = 0; |
| 3152 |
} |
| 3153 |
s.status = NAME_STATE; |
| 3154 |
} |
| 3155 |
if (s.status === NAME_STATE) { |
| 3156 |
if (s.gzhead.name) { |
| 3157 |
let beg = s.pending; |
| 3158 |
let val; |
| 3159 |
do { |
| 3160 |
if (s.pending === s.pending_buf_size) { |
| 3161 |
|
| 3162 |
if (s.gzhead.hcrc && s.pending > beg) { |
| 3163 |
strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg); |
| 3164 |
} |
| 3165 |
|
| 3166 |
flush_pending(strm); |
| 3167 |
if (s.pending !== 0) { |
| 3168 |
s.last_flush = -1; |
| 3169 |
return Z_OK$1; |
| 3170 |
} |
| 3171 |
beg = 0; |
| 3172 |
} |
| 3173 |
|
| 3174 |
if (s.gzindex < s.gzhead.name.length) { |
| 3175 |
val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff; |
| 3176 |
} else { |
| 3177 |
val = 0; |
| 3178 |
} |
| 3179 |
put_byte(s, val); |
| 3180 |
} while (val !== 0); |
| 3181 |
|
| 3182 |
if (s.gzhead.hcrc && s.pending > beg) { |
| 3183 |
strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg); |
| 3184 |
} |
| 3185 |
|
| 3186 |
s.gzindex = 0; |
| 3187 |
} |
| 3188 |
s.status = COMMENT_STATE; |
| 3189 |
} |
| 3190 |
if (s.status === COMMENT_STATE) { |
| 3191 |
if (s.gzhead.comment) { |
| 3192 |
let beg = s.pending; |
| 3193 |
let val; |
| 3194 |
do { |
| 3195 |
if (s.pending === s.pending_buf_size) { |
| 3196 |
|
| 3197 |
if (s.gzhead.hcrc && s.pending > beg) { |
| 3198 |
strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg); |
| 3199 |
} |
| 3200 |
|
| 3201 |
flush_pending(strm); |
| 3202 |
if (s.pending !== 0) { |
| 3203 |
s.last_flush = -1; |
| 3204 |
return Z_OK$1; |
| 3205 |
} |
| 3206 |
beg = 0; |
| 3207 |
} |
| 3208 |
|
| 3209 |
if (s.gzindex < s.gzhead.comment.length) { |
| 3210 |
val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff; |
| 3211 |
} else { |
| 3212 |
val = 0; |
| 3213 |
} |
| 3214 |
put_byte(s, val); |
| 3215 |
} while (val !== 0); |
| 3216 |
|
| 3217 |
if (s.gzhead.hcrc && s.pending > beg) { |
| 3218 |
strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg); |
| 3219 |
} |
| 3220 |
|
| 3221 |
} |
| 3222 |
s.status = HCRC_STATE; |
| 3223 |
} |
| 3224 |
if (s.status === HCRC_STATE) { |
| 3225 |
if (s.gzhead.hcrc) { |
| 3226 |
if (s.pending + 2 > s.pending_buf_size) { |
| 3227 |
flush_pending(strm); |
| 3228 |
if (s.pending !== 0) { |
| 3229 |
s.last_flush = -1; |
| 3230 |
return Z_OK$1; |
| 3231 |
} |
| 3232 |
} |
| 3233 |
put_byte(s, strm.adler & 0xff); |
| 3234 |
put_byte(s, (strm.adler >> 8) & 0xff); |
| 3235 |
strm.adler = 0; |
| 3236 |
} |
| 3237 |
s.status = BUSY_STATE; |
| 3238 |
|
| 3239 |
|
| 3240 |
flush_pending(strm); |
| 3241 |
if (s.pending !== 0) { |
| 3242 |
s.last_flush = -1; |
| 3243 |
return Z_OK$1; |
| 3244 |
} |
| 3245 |
} |
| 3246 |
|
| 3247 |
|
| 3248 |
|
| 3249 |
|
| 3250 |
if (strm.avail_in !== 0 || s.lookahead !== 0 || |
| 3251 |
(flush !== Z_NO_FLUSH$1 && s.status !== FINISH_STATE)) { |
| 3252 |
let bstate = s.level === 0 ? deflate_stored(s, flush) : |
| 3253 |
s.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : |
| 3254 |
s.strategy === Z_RLE ? deflate_rle(s, flush) : |
| 3255 |
configuration_table[s.level].func(s, flush); |
| 3256 |
|
| 3257 |
if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) { |
| 3258 |
s.status = FINISH_STATE; |
| 3259 |
} |
| 3260 |
if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) { |
| 3261 |
if (strm.avail_out === 0) { |
| 3262 |
s.last_flush = -1; |
| 3263 |
|
| 3264 |
} |
| 3265 |
return Z_OK$1; |
| 3266 |
|
| 3267 |
|
| 3268 |
|
| 3269 |
|
| 3270 |
|
| 3271 |
|
| 3272 |
|
| 3273 |
} |
| 3274 |
if (bstate === BS_BLOCK_DONE) { |
| 3275 |
if (flush === Z_PARTIAL_FLUSH) { |
| 3276 |
_tr_align(s); |
| 3277 |
} |
| 3278 |
else if (flush !== Z_BLOCK) { |
| 3279 |
|
| 3280 |
_tr_stored_block(s, 0, 0, false); |
| 3281 |
|
| 3282 |
|
| 3283 |
|
| 3284 |
if (flush === Z_FULL_FLUSH$1) { |
| 3285 |
|
| 3286 |
zero(s.head); |
| 3287 |
|
| 3288 |
if (s.lookahead === 0) { |
| 3289 |
s.strstart = 0; |
| 3290 |
s.block_start = 0; |
| 3291 |
s.insert = 0; |
| 3292 |
} |
| 3293 |
} |
| 3294 |
} |
| 3295 |
flush_pending(strm); |
| 3296 |
if (strm.avail_out === 0) { |
| 3297 |
s.last_flush = -1; |
| 3298 |
return Z_OK$1; |
| 3299 |
} |
| 3300 |
} |
| 3301 |
} |
| 3302 |
|
| 3303 |
if (flush !== Z_FINISH$1) { return Z_OK$1; } |
| 3304 |
if (s.wrap <= 0) { return Z_STREAM_END$1; } |
| 3305 |
|
| 3306 |
|
| 3307 |
if (s.wrap === 2) { |
| 3308 |
put_byte(s, strm.adler & 0xff); |
| 3309 |
put_byte(s, (strm.adler >> 8) & 0xff); |
| 3310 |
put_byte(s, (strm.adler >> 16) & 0xff); |
| 3311 |
put_byte(s, (strm.adler >> 24) & 0xff); |
| 3312 |
put_byte(s, strm.total_in & 0xff); |
| 3313 |
put_byte(s, (strm.total_in >> 8) & 0xff); |
| 3314 |
put_byte(s, (strm.total_in >> 16) & 0xff); |
| 3315 |
put_byte(s, (strm.total_in >> 24) & 0xff); |
| 3316 |
} |
| 3317 |
else |
| 3318 |
{ |
| 3319 |
putShortMSB(s, strm.adler >>> 16); |
| 3320 |
putShortMSB(s, strm.adler & 0xffff); |
| 3321 |
} |
| 3322 |
|
| 3323 |
flush_pending(strm); |
| 3324 |
|
| 3325 |
|
| 3326 |
|
| 3327 |
if (s.wrap > 0) { s.wrap = -s.wrap; } |
| 3328 |
|
| 3329 |
return s.pending !== 0 ? Z_OK$1 : Z_STREAM_END$1; |
| 3330 |
}; |
| 3331 |
|
| 3332 |
|
| 3333 |
const deflateEnd = (strm) => { |
| 3334 |
|
| 3335 |
if (deflateStateCheck(strm)) { |
| 3336 |
return Z_STREAM_ERROR; |
| 3337 |
} |
| 3338 |
|
| 3339 |
const status = strm.state.status; |
| 3340 |
|
| 3341 |
strm.state = null; |
| 3342 |
|
| 3343 |
return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK$1; |
| 3344 |
}; |
| 3345 |
|
| 3346 |
|
| 3347 |
|
| 3348 |
|
| 3349 |
|
| 3350 |
|
| 3351 |
const deflateSetDictionary = (strm, dictionary) => { |
| 3352 |
|
| 3353 |
let dictLength = dictionary.length; |
| 3354 |
|
| 3355 |
if (deflateStateCheck(strm)) { |
| 3356 |
return Z_STREAM_ERROR; |
| 3357 |
} |
| 3358 |
|
| 3359 |
const s = strm.state; |
| 3360 |
const wrap = s.wrap; |
| 3361 |
|
| 3362 |
if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) { |
| 3363 |
return Z_STREAM_ERROR; |
| 3364 |
} |
| 3365 |
|
| 3366 |
|
| 3367 |
if (wrap === 1) { |
| 3368 |
|
| 3369 |
strm.adler = adler32_1(strm.adler, dictionary, dictLength, 0); |
| 3370 |
} |
| 3371 |
|
| 3372 |
s.wrap = 0; |
| 3373 |
|
| 3374 |
|
| 3375 |
if (dictLength >= s.w_size) { |
| 3376 |
if (wrap === 0) { |
| 3377 |
|
| 3378 |
zero(s.head); |
| 3379 |
s.strstart = 0; |
| 3380 |
s.block_start = 0; |
| 3381 |
s.insert = 0; |
| 3382 |
} |
| 3383 |
|
| 3384 |
|
| 3385 |
let tmpDict = new Uint8Array(s.w_size); |
| 3386 |
tmpDict.set(dictionary.subarray(dictLength - s.w_size, dictLength), 0); |
| 3387 |
dictionary = tmpDict; |
| 3388 |
dictLength = s.w_size; |
| 3389 |
} |
| 3390 |
|
| 3391 |
const avail = strm.avail_in; |
| 3392 |
const next = strm.next_in; |
| 3393 |
const input = strm.input; |
| 3394 |
strm.avail_in = dictLength; |
| 3395 |
strm.next_in = 0; |
| 3396 |
strm.input = dictionary; |
| 3397 |
fill_window(s); |
| 3398 |
while (s.lookahead >= MIN_MATCH) { |
| 3399 |
let str = s.strstart; |
| 3400 |
let n = s.lookahead - (MIN_MATCH - 1); |
| 3401 |
do { |
| 3402 |
|
| 3403 |
s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]); |
| 3404 |
|
| 3405 |
s.prev[str & s.w_mask] = s.head[s.ins_h]; |
| 3406 |
|
| 3407 |
s.head[s.ins_h] = str; |
| 3408 |
str++; |
| 3409 |
} while (--n); |
| 3410 |
s.strstart = str; |
| 3411 |
s.lookahead = MIN_MATCH - 1; |
| 3412 |
fill_window(s); |
| 3413 |
} |
| 3414 |
s.strstart += s.lookahead; |
| 3415 |
s.block_start = s.strstart; |
| 3416 |
s.insert = s.lookahead; |
| 3417 |
s.lookahead = 0; |
| 3418 |
s.match_length = s.prev_length = MIN_MATCH - 1; |
| 3419 |
s.match_available = 0; |
| 3420 |
strm.next_in = next; |
| 3421 |
strm.input = input; |
| 3422 |
strm.avail_in = avail; |
| 3423 |
s.wrap = wrap; |
| 3424 |
return Z_OK$1; |
| 3425 |
}; |
| 3426 |
|
| 3427 |
|
| 3428 |
var deflateInit_1 = deflateInit; |
| 3429 |
var deflateInit2_1 = deflateInit2; |
| 3430 |
var deflateReset_1 = deflateReset; |
| 3431 |
var deflateResetKeep_1 = deflateResetKeep; |
| 3432 |
var deflateSetHeader_1 = deflateSetHeader; |
| 3433 |
var deflate_2$1 = deflate$1; |
| 3434 |
var deflateEnd_1 = deflateEnd; |
| 3435 |
var deflateSetDictionary_1 = deflateSetDictionary; |
| 3436 |
var deflateInfo = 'pako deflate (from Nodeca project)'; |
| 3437 |
|
| 3438 |
|
| 3439 |
|
| 3440 |
|
| 3441 |
|
| 3442 |
|
| 3443 |
|
| 3444 |
|
| 3445 |
|
| 3446 |
|
| 3447 |
|
| 3448 |
var deflate_1$1 = { |
| 3449 |
deflateInit: deflateInit_1, |
| 3450 |
deflateInit2: deflateInit2_1, |
| 3451 |
deflateReset: deflateReset_1, |
| 3452 |
deflateResetKeep: deflateResetKeep_1, |
| 3453 |
deflateSetHeader: deflateSetHeader_1, |
| 3454 |
deflate: deflate_2$1, |
| 3455 |
deflateEnd: deflateEnd_1, |
| 3456 |
deflateSetDictionary: deflateSetDictionary_1, |
| 3457 |
deflateInfo: deflateInfo |
| 3458 |
}; |
| 3459 |
|
| 3460 |
const _has = (obj, key) => { |
| 3461 |
return Object.prototype.hasOwnProperty.call(obj, key); |
| 3462 |
}; |
| 3463 |
|
| 3464 |
var assign = function (obj ) { |
| 3465 |
const sources = Array.prototype.slice.call(arguments, 1); |
| 3466 |
while (sources.length) { |
| 3467 |
const source = sources.shift(); |
| 3468 |
if (!source) { continue; } |
| 3469 |
|
| 3470 |
if (typeof source !== 'object') { |
| 3471 |
throw new TypeError(source + 'must be non-object'); |
| 3472 |
} |
| 3473 |
|
| 3474 |
for (const p in source) { |
| 3475 |
if (_has(source, p)) { |
| 3476 |
obj[p] = source[p]; |
| 3477 |
} |
| 3478 |
} |
| 3479 |
} |
| 3480 |
|
| 3481 |
return obj; |
| 3482 |
}; |
| 3483 |
|
| 3484 |
|
| 3485 |
|
| 3486 |
var flattenChunks = (chunks) => { |
| 3487 |
|
| 3488 |
let len = 0; |
| 3489 |
|
| 3490 |
for (let i = 0, l = chunks.length; i < l; i++) { |
| 3491 |
len += chunks[i].length; |
| 3492 |
} |
| 3493 |
|
| 3494 |
|
| 3495 |
const result = new Uint8Array(len); |
| 3496 |
|
| 3497 |
for (let i = 0, pos = 0, l = chunks.length; i < l; i++) { |
| 3498 |
let chunk = chunks[i]; |
| 3499 |
result.set(chunk, pos); |
| 3500 |
pos += chunk.length; |
| 3501 |
} |
| 3502 |
|
| 3503 |
return result; |
| 3504 |
}; |
| 3505 |
|
| 3506 |
var common = { |
| 3507 |
assign: assign, |
| 3508 |
flattenChunks: flattenChunks |
| 3509 |
}; |
| 3510 |
|
| 3511 |
|
| 3512 |
|
| 3513 |
|
| 3514 |
|
| 3515 |
|
| 3516 |
|
| 3517 |
|
| 3518 |
|
| 3519 |
let STR_APPLY_UIA_OK = true; |
| 3520 |
|
| 3521 |
try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; } |
| 3522 |
|
| 3523 |
|
| 3524 |
|
| 3525 |
|
| 3526 |
|
| 3527 |
const _utf8len = new Uint8Array(256); |
| 3528 |
for (let q = 0; q < 256; q++) { |
| 3529 |
_utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1); |
| 3530 |
} |
| 3531 |
_utf8len[254] = _utf8len[254] = 1; |
| 3532 |
|
| 3533 |
|
| 3534 |
|
| 3535 |
var string2buf = (str) => { |
| 3536 |
if (typeof TextEncoder === 'function' && TextEncoder.prototype.encode) { |
| 3537 |
return new TextEncoder().encode(str); |
| 3538 |
} |
| 3539 |
|
| 3540 |
let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0; |
| 3541 |
|
| 3542 |
|
| 3543 |
for (m_pos = 0; m_pos < str_len; m_pos++) { |
| 3544 |
c = str.charCodeAt(m_pos); |
| 3545 |
if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) { |
| 3546 |
c2 = str.charCodeAt(m_pos + 1); |
| 3547 |
if ((c2 & 0xfc00) === 0xdc00) { |
| 3548 |
c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00); |
| 3549 |
m_pos++; |
| 3550 |
} |
| 3551 |
} |
| 3552 |
buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4; |
| 3553 |
} |
| 3554 |
|
| 3555 |
|
| 3556 |
buf = new Uint8Array(buf_len); |
| 3557 |
|
| 3558 |
|
| 3559 |
for (i = 0, m_pos = 0; i < buf_len; m_pos++) { |
| 3560 |
c = str.charCodeAt(m_pos); |
| 3561 |
if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) { |
| 3562 |
c2 = str.charCodeAt(m_pos + 1); |
| 3563 |
if ((c2 & 0xfc00) === 0xdc00) { |
| 3564 |
c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00); |
| 3565 |
m_pos++; |
| 3566 |
} |
| 3567 |
} |
| 3568 |
if (c < 0x80) { |
| 3569 |
|
| 3570 |
buf[i++] = c; |
| 3571 |
} else if (c < 0x800) { |
| 3572 |
|
| 3573 |
buf[i++] = 0xC0 | (c >>> 6); |
| 3574 |
buf[i++] = 0x80 | (c & 0x3f); |
| 3575 |
} else if (c < 0x10000) { |
| 3576 |
|
| 3577 |
buf[i++] = 0xE0 | (c >>> 12); |
| 3578 |
buf[i++] = 0x80 | (c >>> 6 & 0x3f); |
| 3579 |
buf[i++] = 0x80 | (c & 0x3f); |
| 3580 |
} else { |
| 3581 |
|
| 3582 |
buf[i++] = 0xf0 | (c >>> 18); |
| 3583 |
buf[i++] = 0x80 | (c >>> 12 & 0x3f); |
| 3584 |
buf[i++] = 0x80 | (c >>> 6 & 0x3f); |
| 3585 |
buf[i++] = 0x80 | (c & 0x3f); |
| 3586 |
} |
| 3587 |
} |
| 3588 |
|
| 3589 |
return buf; |
| 3590 |
}; |
| 3591 |
|
| 3592 |
|
| 3593 |
const buf2binstring = (buf, len) => { |
| 3594 |
|
| 3595 |
|
| 3596 |
|
| 3597 |
if (len < 65534) { |
| 3598 |
if (buf.subarray && STR_APPLY_UIA_OK) { |
| 3599 |
return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len)); |
| 3600 |
} |
| 3601 |
} |
| 3602 |
|
| 3603 |
let result = ''; |
| 3604 |
for (let i = 0; i < len; i++) { |
| 3605 |
result += String.fromCharCode(buf[i]); |
| 3606 |
} |
| 3607 |
return result; |
| 3608 |
}; |
| 3609 |
|
| 3610 |
|
| 3611 |
|
| 3612 |
var buf2string = (buf, max) => { |
| 3613 |
const len = max || buf.length; |
| 3614 |
|
| 3615 |
if (typeof TextDecoder === 'function' && TextDecoder.prototype.decode) { |
| 3616 |
return new TextDecoder().decode(buf.subarray(0, max)); |
| 3617 |
} |
| 3618 |
|
| 3619 |
let i, out; |
| 3620 |
|
| 3621 |
|
| 3622 |
|
| 3623 |
|
| 3624 |
const utf16buf = new Array(len * 2); |
| 3625 |
|
| 3626 |
for (out = 0, i = 0; i < len;) { |
| 3627 |
let c = buf[i++]; |
| 3628 |
|
| 3629 |
if (c < 0x80) { utf16buf[out++] = c; continue; } |
| 3630 |
|
| 3631 |
let c_len = _utf8len[c]; |
| 3632 |
|
| 3633 |
if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; } |
| 3634 |
|
| 3635 |
|
| 3636 |
c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07; |
| 3637 |
|
| 3638 |
while (c_len > 1 && i < len) { |
| 3639 |
c = (c << 6) | (buf[i++] & 0x3f); |
| 3640 |
c_len--; |
| 3641 |
} |
| 3642 |
|
| 3643 |
|
| 3644 |
if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; } |
| 3645 |
|
| 3646 |
if (c < 0x10000) { |
| 3647 |
utf16buf[out++] = c; |
| 3648 |
} else { |
| 3649 |
c -= 0x10000; |
| 3650 |
utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff); |
| 3651 |
utf16buf[out++] = 0xdc00 | (c & 0x3ff); |
| 3652 |
} |
| 3653 |
} |
| 3654 |
|
| 3655 |
return buf2binstring(utf16buf, out); |
| 3656 |
}; |
| 3657 |
|
| 3658 |
|
| 3659 |
|
| 3660 |
|
| 3661 |
|
| 3662 |
|
| 3663 |
|
| 3664 |
|
| 3665 |
var utf8border = (buf, max) => { |
| 3666 |
|
| 3667 |
max = max || buf.length; |
| 3668 |
if (max > buf.length) { max = buf.length; } |
| 3669 |
|
| 3670 |
|
| 3671 |
let pos = max - 1; |
| 3672 |
while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; } |
| 3673 |
|
| 3674 |
|
| 3675 |
|
| 3676 |
if (pos < 0) { return max; } |
| 3677 |
|
| 3678 |
|
| 3679 |
|
| 3680 |
if (pos === 0) { return max; } |
| 3681 |
|
| 3682 |
return (pos + _utf8len[buf[pos]] > max) ? pos : max; |
| 3683 |
}; |
| 3684 |
|
| 3685 |
var strings = { |
| 3686 |
string2buf: string2buf, |
| 3687 |
buf2string: buf2string, |
| 3688 |
utf8border: utf8border |
| 3689 |
}; |
| 3690 |
|
| 3691 |
|
| 3692 |
|
| 3693 |
|
| 3694 |
|
| 3695 |
|
| 3696 |
|
| 3697 |
|
| 3698 |
|
| 3699 |
|
| 3700 |
|
| 3701 |
|
| 3702 |
|
| 3703 |
|
| 3704 |
|
| 3705 |
|
| 3706 |
|
| 3707 |
|
| 3708 |
|
| 3709 |
|
| 3710 |
function ZStream() { |
| 3711 |
|
| 3712 |
this.input = null; |
| 3713 |
this.next_in = 0; |
| 3714 |
|
| 3715 |
this.avail_in = 0; |
| 3716 |
|
| 3717 |
this.total_in = 0; |
| 3718 |
|
| 3719 |
this.output = null; |
| 3720 |
this.next_out = 0; |
| 3721 |
|
| 3722 |
this.avail_out = 0; |
| 3723 |
|
| 3724 |
this.total_out = 0; |
| 3725 |
|
| 3726 |
this.msg = ''; |
| 3727 |
|
| 3728 |
this.state = null; |
| 3729 |
|
| 3730 |
this.data_type = 2; |
| 3731 |
|
| 3732 |
this.adler = 0; |
| 3733 |
} |
| 3734 |
|
| 3735 |
var zstream = ZStream; |
| 3736 |
|
| 3737 |
const toString = Object.prototype.toString; |
| 3738 |
|
| 3739 |
|
| 3740 |
|
| 3741 |
|
| 3742 |
const { |
| 3743 |
Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_FINISH, |
| 3744 |
Z_OK, Z_STREAM_END, |
| 3745 |
Z_DEFAULT_COMPRESSION, |
| 3746 |
Z_DEFAULT_STRATEGY, |
| 3747 |
Z_DEFLATED |
| 3748 |
} = constants$1; |
| 3749 |
|
| 3750 |
|
| 3751 |
|
| 3752 |
|
| 3753 |
|
| 3754 |
|
| 3755 |
|
| 3756 |
|
| 3757 |
|
| 3758 |
|
| 3759 |
|
| 3760 |
|
| 3761 |
|
| 3762 |
|
| 3763 |
|
| 3764 |
|
| 3765 |
|
| 3766 |
|
| 3767 |
|
| 3768 |
|
| 3769 |
|
| 3770 |
|
| 3771 |
|
| 3772 |
|
| 3773 |
|
| 3774 |
|
| 3775 |
|
| 3776 |
|
| 3777 |
|
| 3778 |
|
| 3779 |
|
| 3780 |
|
| 3781 |
|
| 3782 |
|
| 3783 |
|
| 3784 |
|
| 3785 |
|
| 3786 |
|
| 3787 |
|
| 3788 |
|
| 3789 |
|
| 3790 |
|
| 3791 |
|
| 3792 |
|
| 3793 |
|
| 3794 |
|
| 3795 |
|
| 3796 |
|
| 3797 |
|
| 3798 |
|
| 3799 |
|
| 3800 |
|
| 3801 |
|
| 3802 |
|
| 3803 |
|
| 3804 |
|
| 3805 |
|
| 3806 |
|
| 3807 |
|
| 3808 |
|
| 3809 |
|
| 3810 |
|
| 3811 |
|
| 3812 |
|
| 3813 |
|
| 3814 |
|
| 3815 |
|
| 3816 |
|
| 3817 |
|
| 3818 |
|
| 3819 |
|
| 3820 |
|
| 3821 |
|
| 3822 |
|
| 3823 |
|
| 3824 |
|
| 3825 |
|
| 3826 |
|
| 3827 |
|
| 3828 |
|
| 3829 |
|
| 3830 |
|
| 3831 |
|
| 3832 |
|
| 3833 |
|
| 3834 |
|
| 3835 |
|
| 3836 |
|
| 3837 |
|
| 3838 |
function Deflate(options) { |
| 3839 |
this.options = common.assign({ |
| 3840 |
level: Z_DEFAULT_COMPRESSION, |
| 3841 |
method: Z_DEFLATED, |
| 3842 |
chunkSize: 16384, |
| 3843 |
windowBits: 15, |
| 3844 |
memLevel: 8, |
| 3845 |
strategy: Z_DEFAULT_STRATEGY |
| 3846 |
}, options || {}); |
| 3847 |
|
| 3848 |
let opt = this.options; |
| 3849 |
|
| 3850 |
if (opt.raw && (opt.windowBits > 0)) { |
| 3851 |
opt.windowBits = -opt.windowBits; |
| 3852 |
} |
| 3853 |
|
| 3854 |
else if (opt.gzip && (opt.windowBits > 0) && (opt.windowBits < 16)) { |
| 3855 |
opt.windowBits += 16; |
| 3856 |
} |
| 3857 |
|
| 3858 |
this.err = 0; |
| 3859 |
this.msg = ''; |
| 3860 |
this.ended = false; |
| 3861 |
this.chunks = []; |
| 3862 |
|
| 3863 |
this.strm = new zstream(); |
| 3864 |
this.strm.avail_out = 0; |
| 3865 |
|
| 3866 |
let status = deflate_1$1.deflateInit2( |
| 3867 |
this.strm, |
| 3868 |
opt.level, |
| 3869 |
opt.method, |
| 3870 |
opt.windowBits, |
| 3871 |
opt.memLevel, |
| 3872 |
opt.strategy |
| 3873 |
); |
| 3874 |
|
| 3875 |
if (status !== Z_OK) { |
| 3876 |
throw new Error(messages[status]); |
| 3877 |
} |
| 3878 |
|
| 3879 |
if (opt.header) { |
| 3880 |
deflate_1$1.deflateSetHeader(this.strm, opt.header); |
| 3881 |
} |
| 3882 |
|
| 3883 |
if (opt.dictionary) { |
| 3884 |
let dict; |
| 3885 |
|
| 3886 |
if (typeof opt.dictionary === 'string') { |
| 3887 |
|
| 3888 |
dict = strings.string2buf(opt.dictionary); |
| 3889 |
} else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') { |
| 3890 |
dict = new Uint8Array(opt.dictionary); |
| 3891 |
} else { |
| 3892 |
dict = opt.dictionary; |
| 3893 |
} |
| 3894 |
|
| 3895 |
status = deflate_1$1.deflateSetDictionary(this.strm, dict); |
| 3896 |
|
| 3897 |
if (status !== Z_OK) { |
| 3898 |
throw new Error(messages[status]); |
| 3899 |
} |
| 3900 |
|
| 3901 |
this._dict_set = true; |
| 3902 |
} |
| 3903 |
} |
| 3904 |
|
| 3905 |
|
| 3906 |
|
| 3907 |
|
| 3908 |
|
| 3909 |
|
| 3910 |
|
| 3911 |
|
| 3912 |
|
| 3913 |
|
| 3914 |
|
| 3915 |
|
| 3916 |
|
| 3917 |
|
| 3918 |
|
| 3919 |
|
| 3920 |
|
| 3921 |
|
| 3922 |
|
| 3923 |
|
| 3924 |
|
| 3925 |
|
| 3926 |
|
| 3927 |
Deflate.prototype.push = function (data, flush_mode) { |
| 3928 |
const strm = this.strm; |
| 3929 |
const chunkSize = this.options.chunkSize; |
| 3930 |
let status, _flush_mode; |
| 3931 |
|
| 3932 |
if (this.ended) { return false; } |
| 3933 |
|
| 3934 |
if (flush_mode === ~~flush_mode) _flush_mode = flush_mode; |
| 3935 |
else _flush_mode = flush_mode === true ? Z_FINISH : Z_NO_FLUSH; |
| 3936 |
|
| 3937 |
|
| 3938 |
if (typeof data === 'string') { |
| 3939 |
|
| 3940 |
strm.input = strings.string2buf(data); |
| 3941 |
} else if (toString.call(data) === '[object ArrayBuffer]') { |
| 3942 |
strm.input = new Uint8Array(data); |
| 3943 |
} else { |
| 3944 |
strm.input = data; |
| 3945 |
} |
| 3946 |
|
| 3947 |
strm.next_in = 0; |
| 3948 |
strm.avail_in = strm.input.length; |
| 3949 |
|
| 3950 |
for (;;) { |
| 3951 |
if (strm.avail_out === 0) { |
| 3952 |
strm.output = new Uint8Array(chunkSize); |
| 3953 |
strm.next_out = 0; |
| 3954 |
strm.avail_out = chunkSize; |
| 3955 |
} |
| 3956 |
|
| 3957 |
|
| 3958 |
if ((_flush_mode === Z_SYNC_FLUSH || _flush_mode === Z_FULL_FLUSH) && strm.avail_out <= 6) { |
| 3959 |
this.onData(strm.output.subarray(0, strm.next_out)); |
| 3960 |
strm.avail_out = 0; |
| 3961 |
continue; |
| 3962 |
} |
| 3963 |
|
| 3964 |
status = deflate_1$1.deflate(strm, _flush_mode); |
| 3965 |
|
| 3966 |
|
| 3967 |
if (status === Z_STREAM_END) { |
| 3968 |
if (strm.next_out > 0) { |
| 3969 |
this.onData(strm.output.subarray(0, strm.next_out)); |
| 3970 |
} |
| 3971 |
status = deflate_1$1.deflateEnd(this.strm); |
| 3972 |
this.onEnd(status); |
| 3973 |
this.ended = true; |
| 3974 |
return status === Z_OK; |
| 3975 |
} |
| 3976 |
|
| 3977 |
|
| 3978 |
if (strm.avail_out === 0) { |
| 3979 |
this.onData(strm.output); |
| 3980 |
continue; |
| 3981 |
} |
| 3982 |
|
| 3983 |
|
| 3984 |
if (_flush_mode > 0 && strm.next_out > 0) { |
| 3985 |
this.onData(strm.output.subarray(0, strm.next_out)); |
| 3986 |
strm.avail_out = 0; |
| 3987 |
continue; |
| 3988 |
} |
| 3989 |
|
| 3990 |
if (strm.avail_in === 0) break; |
| 3991 |
} |
| 3992 |
|
| 3993 |
return true; |
| 3994 |
}; |
| 3995 |
|
| 3996 |
|
| 3997 |
|
| 3998 |
|
| 3999 |
|
| 4000 |
|
| 4001 |
|
| 4002 |
|
| 4003 |
|
| 4004 |
Deflate.prototype.onData = function (chunk) { |
| 4005 |
this.chunks.push(chunk); |
| 4006 |
}; |
| 4007 |
|
| 4008 |
|
| 4009 |
|
| 4010 |
|
| 4011 |
|
| 4012 |
|
| 4013 |
|
| 4014 |
|
| 4015 |
|
| 4016 |
|
| 4017 |
|
| 4018 |
Deflate.prototype.onEnd = function (status) { |
| 4019 |
|
| 4020 |
if (status === Z_OK) { |
| 4021 |
this.result = common.flattenChunks(this.chunks); |
| 4022 |
} |
| 4023 |
this.chunks = []; |
| 4024 |
this.err = status; |
| 4025 |
this.msg = this.strm.msg; |
| 4026 |
}; |
| 4027 |
|
| 4028 |
|
| 4029 |
|
| 4030 |
|
| 4031 |
|
| 4032 |
|
| 4033 |
|
| 4034 |
|
| 4035 |
|
| 4036 |
|
| 4037 |
|
| 4038 |
|
| 4039 |
|
| 4040 |
|
| 4041 |
|
| 4042 |
|
| 4043 |
|
| 4044 |
|
| 4045 |
|
| 4046 |
|
| 4047 |
|
| 4048 |
|
| 4049 |
|
| 4050 |
|
| 4051 |
|
| 4052 |
|
| 4053 |
|
| 4054 |
|
| 4055 |
|
| 4056 |
|
| 4057 |
|
| 4058 |
|
| 4059 |
|
| 4060 |
|
| 4061 |
function deflate(input, options) { |
| 4062 |
const deflator = new Deflate(options); |
| 4063 |
|
| 4064 |
deflator.push(input, true); |
| 4065 |
|
| 4066 |
|
| 4067 |
if (deflator.err) { throw deflator.msg || messages[deflator.err]; } |
| 4068 |
|
| 4069 |
return deflator.result; |
| 4070 |
} |
| 4071 |
|
| 4072 |
|
| 4073 |
|
| 4074 |
|
| 4075 |
|
| 4076 |
|
| 4077 |
|
| 4078 |
|
| 4079 |
|
| 4080 |
|
| 4081 |
function deflateRaw(input, options) { |
| 4082 |
options = options || {}; |
| 4083 |
options.raw = true; |
| 4084 |
return deflate(input, options); |
| 4085 |
} |
| 4086 |
|
| 4087 |
|
| 4088 |
|
| 4089 |
|
| 4090 |
|
| 4091 |
|
| 4092 |
|
| 4093 |
|
| 4094 |
|
| 4095 |
|
| 4096 |
function gzip(input, options) { |
| 4097 |
options = options || {}; |
| 4098 |
options.gzip = true; |
| 4099 |
return deflate(input, options); |
| 4100 |
} |
| 4101 |
|
| 4102 |
|
| 4103 |
var Deflate_1 = Deflate; |
| 4104 |
var deflate_2 = deflate; |
| 4105 |
var deflateRaw_1 = deflateRaw; |
| 4106 |
var gzip_1 = gzip; |
| 4107 |
var constants = constants$1; |
| 4108 |
|
| 4109 |
var deflate_1 = { |
| 4110 |
Deflate: Deflate_1, |
| 4111 |
deflate: deflate_2, |
| 4112 |
deflateRaw: deflateRaw_1, |
| 4113 |
gzip: gzip_1, |
| 4114 |
constants: constants |
| 4115 |
}; |
| 4116 |
|
| 4117 |
exports.Deflate = Deflate_1; |
| 4118 |
exports.constants = constants; |
| 4119 |
exports["default"] = deflate_1; |
| 4120 |
exports.deflate = deflate_2; |
| 4121 |
exports.deflateRaw = deflateRaw_1; |
| 4122 |
exports.gzip = gzip_1; |
| 4123 |
|
| 4124 |
Object.defineProperty(exports, '__esModule', { value: true }); |
| 4125 |
|
| 4126 |
})); |